@foris/ai-agent 0.8.1 → 0.8.2

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.
Files changed (45) hide show
  1. package/dist/ai-agent.es.js +1 -1
  2. package/dist/ai-agent.umd.js +3 -3
  3. package/dist/{arc-DUm6ddPk.js → arc-DD7EWc2o.js} +1 -1
  4. package/dist/{architectureDiagram-VXUJARFQ-BuAJ-b-Q.js → architectureDiagram-VXUJARFQ-z-lO8_zV.js} +3 -3
  5. package/dist/{blockDiagram-VD42YOAC-DWfghfNe.js → blockDiagram-VD42YOAC-mdYaWjxq.js} +4 -4
  6. package/dist/{c4Diagram-YG6GDRKO-BN-Roy_f.js → c4Diagram-YG6GDRKO-CEhWWXTP.js} +3 -3
  7. package/dist/{channel-IEE0yAws.js → channel-DweYN3Uo.js} +1 -1
  8. package/dist/{chunk-4BX2VUAB-ug55k04o.js → chunk-4BX2VUAB-pnX9CsN3.js} +1 -1
  9. package/dist/{chunk-55IACEB6-DJdzuVHC.js → chunk-55IACEB6-DZbbVbej.js} +1 -1
  10. package/dist/{chunk-B4BG7PRW-hHCqXVzb.js → chunk-B4BG7PRW-c6EDWLtX.js} +4 -4
  11. package/dist/{chunk-DI55MBZ5-BSUbXwVO.js → chunk-DI55MBZ5-DXQYoam7.js} +3 -3
  12. package/dist/{chunk-FMBD7UC4-BvUnP_RB.js → chunk-FMBD7UC4-ja30rsmh.js} +1 -1
  13. package/dist/{chunk-QN33PNHL-CSGS4VHp.js → chunk-QN33PNHL-BVuO3wOv.js} +1 -1
  14. package/dist/{chunk-QZHKN3VN-9rHaz8C2.js → chunk-QZHKN3VN-CUbap1Md.js} +1 -1
  15. package/dist/{chunk-TZMSLE5B-CHVCvS4o.js → chunk-TZMSLE5B-shA9_xfd.js} +1 -1
  16. package/dist/{classDiagram-2ON5EDUG-Ca_Re9Eo.js → classDiagram-2ON5EDUG-BSzZ_mBF.js} +6 -6
  17. package/dist/{classDiagram-v2-WZHVMYZB-Ca_Re9Eo.js → classDiagram-v2-WZHVMYZB-BSzZ_mBF.js} +6 -6
  18. package/dist/{code-block-QI2IAROF-BUoocJ8i.js → code-block-QI2IAROF-CzMm-WRX.js} +1 -1
  19. package/dist/{cose-bilkent-S5V4N54A-wF92R3Cr.js → cose-bilkent-S5V4N54A-DSaZywPx.js} +2 -2
  20. package/dist/{dagre-6UL2VRFP-SvF4wiyd.js → dagre-6UL2VRFP-C2B9kxbK.js} +2 -2
  21. package/dist/{diagram-PSM6KHXK-CxvFasuJ.js → diagram-PSM6KHXK-CZ98rTlL.js} +4 -4
  22. package/dist/{diagram-QEK2KX5R-zFsxiYQJ.js → diagram-QEK2KX5R-cDTi0Itu.js} +3 -3
  23. package/dist/{diagram-S2PKOQOG-9ZJIY7sj.js → diagram-S2PKOQOG-B-_ERFKa.js} +3 -3
  24. package/dist/{erDiagram-Q2GNP2WA-nPDlTs9W.js → erDiagram-Q2GNP2WA-CiWT2_n-.js} +5 -5
  25. package/dist/{flowDiagram-NV44I4VS-VlIzo8b6.js → flowDiagram-NV44I4VS-DEgKqeKg.js} +6 -6
  26. package/dist/{ganttDiagram-JELNMOA3-DVh8YBhR.js → ganttDiagram-JELNMOA3-Dswz_Zlv.js} +3 -3
  27. package/dist/{gitGraphDiagram-NY62KEGX-DBHLIYTA.js → gitGraphDiagram-NY62KEGX-Cq3wclm3.js} +4 -4
  28. package/dist/{index-CuVzs6oC.js → index-RZrnTzzg.js} +9 -9
  29. package/dist/{infoDiagram-WHAUD3N6-5JO8ZQDE.js → infoDiagram-WHAUD3N6-B7B16_8X.js} +2 -2
  30. package/dist/{journeyDiagram-XKPGCS4Q-BhpmqmP0.js → journeyDiagram-XKPGCS4Q-k3PEqTd_.js} +5 -5
  31. package/dist/{kanban-definition-3W4ZIXB7-CGodIqoI.js → kanban-definition-3W4ZIXB7-DsbKyAPh.js} +3 -3
  32. package/dist/{linear-CwOM-hzM.js → linear-CW9vGjyk.js} +1 -1
  33. package/dist/{mermaid-NA5CF7SZ-CHTOBmqN.js → mermaid-NA5CF7SZ-lt2RqOBP.js} +1 -1
  34. package/dist/{mermaid.core-03Xis8Us.js → mermaid.core-DPTeIFw-.js} +31 -31
  35. package/dist/{mindmap-definition-VGOIOE7T-1ZxCxXhT.js → mindmap-definition-VGOIOE7T-Duupessq.js} +4 -4
  36. package/dist/{pieDiagram-ADFJNKIX-C3fb-DBU.js → pieDiagram-ADFJNKIX-CmdD-jGR.js} +4 -4
  37. package/dist/{quadrantDiagram-AYHSOK5B-Cer3tmBz.js → quadrantDiagram-AYHSOK5B-DjH5G5JZ.js} +3 -3
  38. package/dist/{requirementDiagram-UZGBJVZJ-DH0WrmP_.js → requirementDiagram-UZGBJVZJ-DBJoHbWG.js} +4 -4
  39. package/dist/{sankeyDiagram-TZEHDZUN--V2gFp3Z.js → sankeyDiagram-TZEHDZUN-ePS2-kEn.js} +2 -2
  40. package/dist/{sequenceDiagram-WL72ISMW-CLuY-ILU.js → sequenceDiagram-WL72ISMW-BOZHCiVD.js} +4 -4
  41. package/dist/{stateDiagram-FKZM4ZOC-6T2KPynB.js → stateDiagram-FKZM4ZOC-Dnipu4Oq.js} +5 -5
  42. package/dist/{stateDiagram-v2-4FDKWEC3-BgmiMQ3T.js → stateDiagram-v2-4FDKWEC3-DlW89C_k.js} +5 -5
  43. package/dist/{timeline-definition-IT6M3QCI-waAIY7L3.js → timeline-definition-IT6M3QCI-fOQBhAJW.js} +3 -3
  44. package/dist/{xychartDiagram-PRI3JC2R-HPOK6EBx.js → xychartDiagram-PRI3JC2R-SSxc3j1Q.js} +3 -3
  45. package/package.json +1 -1
@@ -535,7 +535,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error
535
535
  `)},R5=t=>{let e=!1;for(let a=0;a<t.length;a+=1){let r=t[a];if(r==="\\"||r==="|"){e=!0;break}}if(!e)return t;let n=[];for(let a=0;a<t.length;a+=1){let r=t[a];r==="\\"?n.push("\\\\"):r==="|"?n.push("\\|"):n.push(r)}return n.join("")},Uqe=t=>{let{headers:e,rows:n}=t;if(e.length===0)return"";let a=new Array(n.length+2),r=0,i=e.map(s=>R5(s));a[r]=`| ${i.join(" | ")} |`,r+=1;let o=new Array(e.length);for(let s=0;s<e.length;s+=1)o[s]="---";a[r]=`| ${o.join(" | ")} |`,r+=1;for(let s of n)if(s.length<e.length){let l=new Array(e.length);for(let u=0;u<e.length;u+=1)l[u]=u<s.length?R5(s[u]):"";a[r]=`| ${l.join(" | ")} |`,r+=1}else{let l=s.map(u=>R5(u));a[r]=`| ${l.join(" | ")} |`,r+=1}return a.join(`
536
536
  `)},Yqe=({children:t,className:e,onCopy:n,onError:a,timeout:r=2e3})=>{let[i,o]=he.useState(!1),[s,l]=he.useState(!1),u=he.useRef(null),d=he.useRef(0),{isAnimating:p}=he.useContext(Ac),m=async g=>{var h,f;if(typeof window>"u"||!((h=navigator==null?void 0:navigator.clipboard)!=null&&h.write)){a==null||a(new Error("Clipboard API not available"));return}try{let b=(f=u.current)==null?void 0:f.closest('[data-streamdown="table-wrapper"]'),y=b==null?void 0:b.querySelector("table");if(!y){a==null||a(new Error("Table not found"));return}let w=KJ(y),k=g==="csv"?ZJ(w):Hqe(w),C=new ClipboardItem({"text/plain":new Blob([k],{type:"text/plain"}),"text/html":new Blob([y.outerHTML],{type:"text/html"})});await navigator.clipboard.write([C]),l(!0),o(!1),n==null||n(g),d.current=window.setTimeout(()=>l(!1),r)}catch(b){a==null||a(b)}};he.useEffect(()=>{let g=h=>{u.current&&!u.current.contains(h.target)&&o(!1)};return document.addEventListener("mousedown",g),()=>{document.removeEventListener("mousedown",g),window.clearTimeout(d.current)}},[]);let A=s?NV:MV;return H.jsxs("div",{className:"relative",ref:u,children:[H.jsx("button",{className:xn("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",e),disabled:p,onClick:()=>o(!i),title:"Copy table",type:"button",children:t??H.jsx(A,{size:14})}),i&&H.jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[H.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>m("csv"),title:"Copy table as CSV",type:"button",children:"CSV"}),H.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>m("tsv"),title:"Copy table as TSV",type:"button",children:"TSV"})]})]})},Wqe=({children:t,className:e,onDownload:n,onError:a})=>{let[r,i]=he.useState(!1),o=he.useRef(null),{isAnimating:s}=he.useContext(Ac),l=u=>{var d;try{let p=(d=o.current)==null?void 0:d.closest('[data-streamdown="table-wrapper"]'),m=p==null?void 0:p.querySelector("table");if(!m){a==null||a(new Error("Table not found"));return}let A=KJ(m),g=u==="csv"?ZJ(A):Uqe(A);Mf(`table.${u==="csv"?"csv":"md"}`,g,u==="csv"?"text/csv":"text/markdown"),i(!1),n==null||n(u)}catch(p){a==null||a(p)}};return he.useEffect(()=>{let u=d=>{o.current&&!o.current.contains(d.target)&&i(!1)};return document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u)}},[]),H.jsxs("div",{className:"relative",ref:o,children:[H.jsx("button",{className:xn("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",e),disabled:s,onClick:()=>i(!r),title:"Download table",type:"button",children:t??H.jsx(ZE,{size:14})}),r&&H.jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[H.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>l("csv"),title:"Download table as CSV",type:"button",children:"CSV"}),H.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>l("markdown"),title:"Download table as Markdown",type:"button",children:"Markdown"})]})]})},Kqe=({children:t,className:e,showControls:n,...a})=>H.jsxs("div",{className:"my-4 flex flex-col space-y-2","data-streamdown":"table-wrapper",children:[n&&H.jsxs("div",{className:"flex items-center justify-end gap-1",children:[H.jsx(Yqe,{}),H.jsx(Wqe,{})]}),H.jsx("div",{className:"overflow-x-auto",children:H.jsx("table",{className:xn("w-full border-collapse border border-border",e),"data-streamdown":"table",...a,children:t})})]}),Zqe=he.lazy(()=>Promise.resolve().then(()=>KBt).then(t=>({default:t.CodeBlock}))),Vqe=he.lazy(()=>Promise.resolve().then(()=>ZBt).then(t=>({default:t.Mermaid}))),Jqe=/language-([^\s]+)/;function cB(t,e){if(!(t!=null&&t.position||e!=null&&e.position))return!0;if(!(t!=null&&t.position&&e!=null&&e.position))return!1;let n=t.position.start,a=e.position.start,r=t.position.end,i=e.position.end;return(n==null?void 0:n.line)===(a==null?void 0:a.line)&&(n==null?void 0:n.column)===(a==null?void 0:a.column)&&(r==null?void 0:r.line)===(i==null?void 0:i.line)&&(r==null?void 0:r.column)===(i==null?void 0:i.column)}function pr(t,e){return t.className===e.className&&cB(t.node,e.node)}var $5=(t,e)=>typeof t=="boolean"?t:t[e]!==!1,lB=(t,e)=>{if(typeof t=="boolean")return t;let n=t.mermaid;return n===!1?!1:n===!0||n===void 0?!0:n[e]!==!1},P5=he.memo(({children:t,className:e,node:n,...a})=>H.jsx("ol",{className:xn("list-inside list-decimal whitespace-normal",e),"data-streamdown":"ordered-list",...a,children:t}),(t,e)=>pr(t,e));P5.displayName="MarkdownOl";var VJ=he.memo(({children:t,className:e,node:n,...a})=>H.jsx("li",{className:xn("py-1 [&>p]:inline",e),"data-streamdown":"list-item",...a,children:t}),(t,e)=>t.className===e.className&&cB(t.node,e.node));VJ.displayName="MarkdownLi";var JJ=he.memo(({children:t,className:e,node:n,...a})=>H.jsx("ul",{className:xn("list-inside list-disc whitespace-normal",e),"data-streamdown":"unordered-list",...a,children:t}),(t,e)=>pr(t,e));JJ.displayName="MarkdownUl";var XJ=he.memo(({className:t,node:e,...n})=>H.jsx("hr",{className:xn("my-6 border-border",t),"data-streamdown":"horizontal-rule",...n}),(t,e)=>pr(t,e));XJ.displayName="MarkdownHr";var eX=he.memo(({children:t,className:e,node:n,...a})=>H.jsx("span",{className:xn("font-semibold",e),"data-streamdown":"strong",...a,children:t}),(t,e)=>pr(t,e));eX.displayName="MarkdownStrong";var tX=he.memo(({children:t,className:e,href:n,node:a,...r})=>{let i=n==="streamdown:incomplete-link";return H.jsx("a",{className:xn("wrap-anywhere font-medium text-primary underline",e),"data-incomplete":i,"data-streamdown":"link",href:n,rel:"noreferrer",target:"_blank",...r,children:t})},(t,e)=>pr(t,e)&&t.href===e.href);tX.displayName="MarkdownA";var nX=he.memo(({children:t,className:e,node:n,...a})=>H.jsx("h1",{className:xn("mt-6 mb-2 font-semibold text-3xl",e),"data-streamdown":"heading-1",...a,children:t}),(t,e)=>pr(t,e));nX.displayName="MarkdownH1";var aX=he.memo(({children:t,className:e,node:n,...a})=>H.jsx("h2",{className:xn("mt-6 mb-2 font-semibold text-2xl",e),"data-streamdown":"heading-2",...a,children:t}),(t,e)=>pr(t,e));aX.displayName="MarkdownH2";var rX=he.memo(({children:t,className:e,node:n,...a})=>H.jsx("h3",{className:xn("mt-6 mb-2 font-semibold text-xl",e),"data-streamdown":"heading-3",...a,children:t}),(t,e)=>pr(t,e));rX.displayName="MarkdownH3";var iX=he.memo(({children:t,className:e,node:n,...a})=>H.jsx("h4",{className:xn("mt-6 mb-2 font-semibold text-lg",e),"data-streamdown":"heading-4",...a,children:t}),(t,e)=>pr(t,e));iX.displayName="MarkdownH4";var oX=he.memo(({children:t,className:e,node:n,...a})=>H.jsx("h5",{className:xn("mt-6 mb-2 font-semibold text-base",e),"data-streamdown":"heading-5",...a,children:t}),(t,e)=>pr(t,e));oX.displayName="MarkdownH5";var sX=he.memo(({children:t,className:e,node:n,...a})=>H.jsx("h6",{className:xn("mt-6 mb-2 font-semibold text-sm",e),"data-streamdown":"heading-6",...a,children:t}),(t,e)=>pr(t,e));sX.displayName="MarkdownH6";var cX=he.memo(({children:t,className:e,node:n,...a})=>{let{controls:r}=he.useContext(Ac),i=$5(r,"table");return H.jsx(Kqe,{className:e,"data-streamdown":"table-wrapper",showControls:i,...a,children:t})},(t,e)=>pr(t,e));cX.displayName="MarkdownTable";var lX=he.memo(({children:t,className:e,node:n,...a})=>H.jsx("thead",{className:xn("bg-muted/80",e),"data-streamdown":"table-header",...a,children:t}),(t,e)=>pr(t,e));lX.displayName="MarkdownThead";var uX=he.memo(({children:t,className:e,node:n,...a})=>H.jsx("tbody",{className:xn("divide-y divide-border bg-muted/40",e),"data-streamdown":"table-body",...a,children:t}),(t,e)=>pr(t,e));uX.displayName="MarkdownTbody";var dX=he.memo(({children:t,className:e,node:n,...a})=>H.jsx("tr",{className:xn("border-border border-b",e),"data-streamdown":"table-row",...a,children:t}),(t,e)=>pr(t,e));dX.displayName="MarkdownTr";var pX=he.memo(({children:t,className:e,node:n,...a})=>H.jsx("th",{className:xn("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",e),"data-streamdown":"table-header-cell",...a,children:t}),(t,e)=>pr(t,e));pX.displayName="MarkdownTh";var mX=he.memo(({children:t,className:e,node:n,...a})=>H.jsx("td",{className:xn("px-4 py-2 text-sm",e),"data-streamdown":"table-cell",...a,children:t}),(t,e)=>pr(t,e));mX.displayName="MarkdownTd";var AX=he.memo(({children:t,className:e,node:n,...a})=>H.jsx("blockquote",{className:xn("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",e),"data-streamdown":"blockquote",...a,children:t}),(t,e)=>pr(t,e));AX.displayName="MarkdownBlockquote";var gX=he.memo(({children:t,className:e,node:n,...a})=>H.jsx("sup",{className:xn("text-sm",e),"data-streamdown":"superscript",...a,children:t}),(t,e)=>pr(t,e));gX.displayName="MarkdownSup";var hX=he.memo(({children:t,className:e,node:n,...a})=>H.jsx("sub",{className:xn("text-sm",e),"data-streamdown":"subscript",...a,children:t}),(t,e)=>pr(t,e));hX.displayName="MarkdownSub";var fX=he.memo(({children:t,className:e,node:n,...a})=>{if("data-footnotes"in a){let r=o=>{var s,l;if(!he.isValidElement(o))return!1;let u=Array.isArray(o.props.children)?o.props.children:[o.props.children],d=!1,p=!1;for(let m of u)if(m){if(typeof m=="string")m.trim()!==""&&(d=!0);else if(he.isValidElement(m))if(((s=m.props)==null?void 0:s["data-footnote-backref"])!==void 0)p=!0;else{let A=Array.isArray(m.props.children)?m.props.children:[m.props.children];for(let g of A){if(typeof g=="string"&&g.trim()!==""){d=!0;break}if(he.isValidElement(g)&&((l=g.props)==null?void 0:l["data-footnote-backref"])===void 0){d=!0;break}}}}return p&&!d},i=Array.isArray(t)?t.map(o=>{if(!he.isValidElement(o))return o;if(o.type===P5){let s=(Array.isArray(o.props.children)?o.props.children:[o.props.children]).filter(l=>!r(l));return s.length===0?null:{...o,props:{...o.props,children:s}}}return o}):t;return(Array.isArray(i)?i.some(o=>o!==null):i!==null)?H.jsx("section",{className:e,...a,children:i}):null}return H.jsx("section",{className:e,...a,children:t})},(t,e)=>pr(t,e));fX.displayName="MarkdownSection";var Xqe=({node:t,className:e,children:n,...a})=>{var r,i,o;let s=((r=t==null?void 0:t.position)==null?void 0:r.start.line)===((i=t==null?void 0:t.position)==null?void 0:i.end.line),{mermaid:l,controls:u}=he.useContext(Ac);if(s)return H.jsx("code",{className:xn("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",e),"data-streamdown":"inline-code",...a,children:n});let d=e==null?void 0:e.match(Jqe),p=(o=d==null?void 0:d.at(1))!=null?o:"",m="";if(he.isValidElement(n)&&n.props&&typeof n.props=="object"&&"children"in n.props&&typeof n.props.children=="string"?m=n.props.children:typeof n=="string"&&(m=n),p==="mermaid"){let g=$5(u,"mermaid"),h=lB(u,"download"),f=lB(u,"copy"),b=lB(u,"fullscreen"),y=lB(u,"panZoom");return H.jsx(he.Suspense,{fallback:H.jsx(YJ,{}),children:H.jsxs("div",{className:xn("group relative my-4 h-auto rounded-xl border p-4",e),"data-streamdown":"mermaid-block",children:[g&&(h||f||b)&&H.jsxs("div",{className:"flex items-center justify-end gap-2",children:[h&&H.jsx(jqe,{chart:m,config:l==null?void 0:l.config}),f&&H.jsx(HJ,{code:m}),b&&H.jsx(zqe,{chart:m,config:l==null?void 0:l.config})]}),H.jsx(Vqe,{chart:m,config:l==null?void 0:l.config,showControls:y})]})})}let A=$5(u,"code");return H.jsx(he.Suspense,{fallback:H.jsx(YJ,{}),children:H.jsx(Zqe,{className:xn("overflow-x-auto border-border border-t",e),code:m,language:p,children:A&&H.jsxs(H.Fragment,{children:[H.jsx(Rqe,{code:m,language:p}),H.jsx(HJ,{})]})})})},bX=he.memo(Xqe,(t,e)=>t.className===e.className&&cB(t.node,e.node));bX.displayName="MarkdownCode";var yX=he.memo(Pqe,(t,e)=>t.className===e.className&&cB(t.node,e.node));yX.displayName="MarkdownImg";var wX=he.memo(({children:t,className:e,node:n,...a})=>{var r;let i=(Array.isArray(t)?t:[t]).filter(o=>o!=null&&o!=="");return i.length===1&&he.isValidElement(i[0])&&((r=i[0].props.node)==null?void 0:r.tagName)==="img"?H.jsx(H.Fragment,{children:t}):H.jsx("p",{className:e,...a,children:t})},(t,e)=>pr(t,e));wX.displayName="MarkdownParagraph";var eze={ol:P5,li:VJ,ul:JJ,hr:XJ,strong:eX,a:tX,h1:nX,h2:aX,h3:rX,h4:iX,h5:oX,h6:sX,table:cX,thead:lX,tbody:uX,tr:dX,th:pX,td:mX,blockquote:AX,code:bX,img:yX,pre:({children:t})=>t,sup:gX,sub:hX,p:wX,section:fX},kX=[],vX={allowDangerousHtml:!0},uB=new WeakMap,tze=class{constructor(){this.cache=new Map,this.keyCache=new WeakMap,this.maxSize=100}generateCacheKey(t){let e=this.keyCache.get(t);if(e)return e;let n=t.rehypePlugins,a=t.remarkPlugins,r=t.remarkRehypeOptions;if(!(n||a||r)){let d="default";return this.keyCache.set(t,d),d}let i=d=>{if(!d||d.length===0)return"";let p="";for(let m=0;m<d.length;m+=1){let A=d[m];if(m>0&&(p+=","),Array.isArray(A)){let[g,h]=A;if(typeof g=="function"){let f=uB.get(g);f||(f=g.name,uB.set(g,f)),p+=f}else p+=String(g);p+=":",p+=JSON.stringify(h)}else if(typeof A=="function"){let g=uB.get(A);g||(g=A.name,uB.set(A,g)),p+=g}else p+=String(A)}return p},o=i(n),s=i(a),l=r?JSON.stringify(r):"",u=`${s}::${o}::${l}`;return this.keyCache.set(t,u),u}get(t){let e=this.generateCacheKey(t),n=this.cache.get(e);return n&&(this.cache.delete(e),this.cache.set(e,n)),n}set(t,e){let n=this.generateCacheKey(t);if(this.cache.size>=this.maxSize){let a=this.cache.keys().next().value;a&&this.cache.delete(a)}this.cache.set(n,e)}clear(){this.cache.clear()}},CX=new tze,_X=t=>{let e=nze(t),n=t.children||"";return rze(e.runSync(e.parse(n),n),t)},nze=t=>{let e=CX.get(t);if(e)return e;let n=aze(t);return CX.set(t,n),n},aze=t=>{let e=t.rehypePlugins||kX,n=t.remarkPlugins||kX,a=t.remarkRehypeOptions?{...vX,...t.remarkRehypeOptions}:vX;return CJ().use(rJ).use(n).use(pJ,a).use(e)},rze=(t,e)=>YV(t,{Fragment:H.Fragment,components:e.components,ignoreInvalidStyle:!0,jsx:H.jsx,jsxs:H.jsxs,passKeys:!0,passNode:!0}),ize=/\[\^[^\]\s]{1,200}\](?!:)/,oze=/\[\^[^\]\s]{1,200}\]:/,sze=/<\/(\w+)>/,cze=/<(\w+)[\s>]/,O5=t=>{let e=0;for(;e<t.length&&(t[e]===" "||t[e]===" "||t[e]===`
537
537
  `||t[e]==="\r");)e+=1;return e+1<t.length&&t[e]==="$"&&t[e+1]==="$"},lze=t=>{let e=t.length-1;for(;e>=0&&(t[e]===" "||t[e]===" "||t[e]===`
538
- `||t[e]==="\r");)e-=1;return e>=1&&t[e]==="$"&&t[e-1]==="$"},j5=t=>{let e=0;for(let n=0;n<t.length-1;n+=1)t[n]==="$"&&t[n+1]==="$"&&(e+=1,n+=1);return e},uze=t=>{let e=ize.test(t),n=oze.test(t);if(e||n)return[t];let a=mc.lex(t,{gfm:!0}),r=[],i=[];for(let o of a){let s=o.raw,l=r.length;if(i.length>0){if(r[l-1]+=s,o.type==="html"){let u=s.match(sze);if(u){let d=u[1];i.at(-1)===d&&i.pop()}}continue}if(o.type==="html"&&o.block){let u=s.match(cze);if(u){let d=u[1];s.includes(`</${d}>`)||i.push(d)}}if(s.trim()==="$$"&&l>0){let u=r[l-1],d=O5(u),p=j5(u);if(d&&p%2===1){r[l-1]=u+s;continue}}if(l>0&&lze(s)){let u=r[l-1],d=O5(u),p=j5(u),m=j5(s);if(d&&p%2===1&&!O5(s)&&m===1){r[l-1]=u+s;continue}}r.push(s)}return r},dze={raw:_Ne,katex:[ES,{errorColor:"var(--color-muted-foreground)"}],harden:[NSe,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:!0}]},pze={gfm:[DPe,{}],math:[c5,{singleDollarTextMath:!1}],cjkFriendly:[VNe,{}],cjkFriendlyGfmStrikethrough:[XNe,{}]},mze=Object.values(dze),Aze=Object.values(pze),gze={shikiTheme:["github-light","github-dark"],controls:!0,isAnimating:!1,mode:"streaming",mermaid:void 0},Ac=he.createContext(gze),xX=he.memo(({content:t,shouldParseIncompleteMarkdown:e,...n})=>{let a=he.useMemo(()=>typeof t=="string"&&e?_Oe(t.trim()):t,[t,e]);return H.jsx(_X,{...n,children:a})},(t,e)=>{if(t.content!==e.content||t.shouldParseIncompleteMarkdown!==e.shouldParseIncompleteMarkdown||t.index!==e.index)return!1;if(t.components!==e.components){let n=Object.keys(t.components||{}),a=Object.keys(e.components||{});if(n.length!==a.length||n.some(r=>{var i,o;return((i=t.components)==null?void 0:i[r])!==((o=e.components)==null?void 0:o[r])}))return!1}return!(t.rehypePlugins!==e.rehypePlugins||t.remarkPlugins!==e.remarkPlugins)});xX.displayName="Block";var hze=["github-light","github-dark"],G5=he.memo(({children:t,mode:e="streaming",parseIncompleteMarkdown:n=!0,components:a,rehypePlugins:r=mze,remarkPlugins:i=Aze,className:o,shikiTheme:s=hze,mermaid:l,controls:u=!0,isAnimating:d=!1,BlockComponent:p=xX,parseMarkdownIntoBlocksFn:m=uze,...A})=>{let g=he.useId(),[h,f]=he.useTransition(),[b,y]=he.useState([]),w=he.useMemo(()=>m(typeof t=="string"?t:""),[t,m]);he.useEffect(()=>{e==="streaming"?f(()=>{y(w)}):y(w)},[w,e]);let k=e==="streaming"?b:w,C=he.useMemo(()=>k.map((E,D)=>`${g}-${D}`),[k.length,g]),x=he.useMemo(()=>({shikiTheme:s,controls:u,isAnimating:d,mode:e,mermaid:l}),[s,u,d,e,l]),_=he.useMemo(()=>({...eze,...a}),[a]);return he.useEffect(()=>{if(!(Array.isArray(r)&&r.some(T=>Array.isArray(T)?T[0]===ES:T===ES)))return;let E=!1;if(Array.isArray(i)){let T=i.find(N=>Array.isArray(N)?N[0]===c5:N===c5);T&&Array.isArray(T)&&T[1]&&(E=T[1].singleDollarTextMath===!0)}let D=typeof t=="string"?t:"",Q=D.includes("$$"),B=E&&(/[^$]\$[^$]/.test(D)||/^\$[^$]/.test(D)||/[^$]\$$/.test(D));(Q||B)&&Promise.resolve().then(()=>VBt)},[r,i,t]),e==="static"?H.jsx(Ac.Provider,{value:x,children:H.jsx("div",{className:xn("space-y-4 whitespace-normal",o),children:H.jsx(_X,{components:_,rehypePlugins:r,remarkPlugins:i,...A,children:t})})}):H.jsx(Ac.Provider,{value:x,children:H.jsx("div",{className:xn("space-y-4 whitespace-normal",o),children:k.map((E,D)=>H.jsx(p,{components:_,content:E,index:D,rehypePlugins:r,remarkPlugins:i,shouldParseIncompleteMarkdown:n,...A},C[D]))})})},(t,e)=>t.children===e.children&&t.shikiTheme===e.shikiTheme&&t.isAnimating===e.isAnimating&&t.mode===e.mode);G5.displayName="Streamdown";var fze=({children:t,className:e,minZoom:n=.5,maxZoom:a=3,zoomStep:r=.1,showControls:i=!0,initialZoom:o=1,fullscreen:s=!1})=>{let l=he.useRef(null),u=he.useRef(null),[d,p]=he.useState(o),[m,A]=he.useState({x:0,y:0}),[g,h]=he.useState(!1),[f,b]=he.useState({x:0,y:0}),[y,w]=he.useState({x:0,y:0}),k=he.useCallback(T=>{p(N=>Math.max(n,Math.min(a,N+T)))},[n,a]),C=he.useCallback(()=>{k(r)},[k,r]),x=he.useCallback(()=>{k(-r)},[k,r]),_=he.useCallback(()=>{p(o),A({x:0,y:0})},[o]),E=he.useCallback(T=>{T.preventDefault();let N=T.deltaY>0?-r:r;k(N)},[k,r]),D=he.useCallback(T=>{if(T.button!==0||T.isPrimary===!1)return;h(!0),b({x:T.clientX,y:T.clientY}),w(m);let N=T.currentTarget;N instanceof HTMLElement&&N.setPointerCapture(T.pointerId)},[m]),Q=he.useCallback(T=>{if(!g)return;T.preventDefault();let N=T.clientX-f.x,I=T.clientY-f.y;A({x:y.x+N,y:y.y+I})},[g,f,y]),B=he.useCallback(T=>{h(!1);let N=T.currentTarget;N instanceof HTMLElement&&N.releasePointerCapture(T.pointerId)},[]);return he.useEffect(()=>{let T=l.current;if(T)return T.addEventListener("wheel",E,{passive:!1}),()=>{T.removeEventListener("wheel",E)}},[E]),he.useEffect(()=>{let T=u.current;if(T&&g)return document.body.style.userSelect="none",T.addEventListener("pointermove",Q,{passive:!1}),T.addEventListener("pointerup",B),T.addEventListener("pointercancel",B),()=>{document.body.style.userSelect="",T.removeEventListener("pointermove",Q),T.removeEventListener("pointerup",B),T.removeEventListener("pointercancel",B)}},[g,Q,B]),H.jsxs("div",{className:xn("relative",s?"h-full w-full":"w-full",e),ref:l,style:{cursor:g?"grabbing":"grab"},children:[i&&H.jsxs("div",{className:xn("absolute z-10 flex flex-col gap-1 rounded-md border border-border bg-background/90 p-1 shadow-sm backdrop-blur-sm",s?"bottom-4 left-4":"bottom-2 left-2"),children:[H.jsx("button",{className:"flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",disabled:d>=a,onClick:C,title:"Zoom in",type:"button",children:H.jsx(LOe,{size:16})}),H.jsx("button",{className:"flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",disabled:d<=n,onClick:x,title:"Zoom out",type:"button",children:H.jsx(NOe,{size:16})}),H.jsx("button",{className:"flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",onClick:_,title:"Reset zoom and pan",type:"button",children:H.jsx(TOe,{size:16})})]}),H.jsx("div",{className:xn("origin-center transition-transform duration-150 ease-out",s&&"flex w-full items-center justify-center"),onPointerDown:D,ref:u,role:"application",style:{transform:`translate(${m.x}px, ${m.y}px) scale(${d})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:t})]})},EX=({chart:t,className:e,config:n,fullscreen:a=!1,showControls:r=!0})=>{let[i,o]=he.useState(null),[s,l]=he.useState(!0),[u,d]=he.useState(""),[p,m]=he.useState(""),[A,g]=he.useState(0),{mermaid:h}=he.useContext(Ac),f=h==null?void 0:h.errorComponent;if(he.useEffect(()=>{(async()=>{try{o(null),l(!0);let y=await WJ(n),w=t.split("").reduce((x,_)=>(x<<5)-x+_.charCodeAt(0)|0,0),k=`mermaid-${Math.abs(w)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:C}=await y.render(k,t);d(C),m(C)}catch(y){if(!(p||u)){let w=y instanceof Error?y.message:"Failed to render Mermaid chart";o(w)}}finally{l(!1)}})()},[t,n,A]),s&&!u&&!p)return H.jsx("div",{className:xn("my-4 flex justify-center p-4",e),children:H.jsxs("div",{className:"flex items-center space-x-2 text-muted-foreground",children:[H.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-current border-b-2"}),H.jsx("span",{className:"text-sm",children:"Loading diagram..."})]})});if(i&&!u&&!p){let y=()=>g(w=>w+1);return f?H.jsx(f,{chart:t,error:i,retry:y}):H.jsxs("div",{className:xn("rounded-lg border border-red-200 bg-red-50 p-4",e),children:[H.jsxs("p",{className:"font-mono text-red-700 text-sm",children:["Mermaid Error: ",i]}),H.jsxs("details",{className:"mt-2",children:[H.jsx("summary",{className:"cursor-pointer text-red-600 text-xs",children:"Show Code"}),H.jsx("pre",{className:"mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs",children:t})]})]})}let b=u||p;return H.jsx(fze,{className:xn(a?"h-full w-full overflow-hidden":"my-4 overflow-hidden",e),fullscreen:a,maxZoom:3,minZoom:.5,showControls:r,zoomStep:.1,children:H.jsx("div",{"aria-label":"Mermaid chart",className:xn("flex justify-center",a&&"h-full w-full items-center"),dangerouslySetInnerHTML:{__html:b},role:"img"})})};const bze=({className:t,from:e,...n})=>H.jsx("div",{className:Tn("message-box group flex w-full max-w-[95%] flex-col gap-2",e==="user"?"is-user ml-auto justify-end":"is-assistant",t),...n}),yze=({children:t,className:e,...n})=>H.jsx("div",{className:Tn("message-content is-user:dark flex w-fit max-w-full min-w-0 flex-col gap-2 overflow-hidden text-sm","group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground","group-[.is-assistant]:text-foreground",e),...n,children:t});he.createContext(null);const q5=he.memo(({className:t,...e})=>H.jsx(G5,{className:Tn("message-response size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",t),...e}),(t,e)=>t.children===e.children);q5.displayName="MessageResponse";var dB="Collapsible",[wze,D0n]=SA(dB),[kze,z5]=wze(dB),BX=_e.forwardRef((t,e)=>{const{__scopeCollapsible:n,open:a,defaultOpen:r,disabled:i,onOpenChange:o,...s}=t,[l,u]=mf({prop:a,defaultProp:r??!1,onChange:o,caller:dB});return H.jsx(kze,{scope:n,disabled:i,contentId:Hx(),open:l,onOpenToggle:_e.useCallback(()=>u(d=>!d),[u]),children:H.jsx(Kr.div,{"data-state":U5(l),"data-disabled":i?"":void 0,...s,ref:e})})});BX.displayName=dB;var IX="CollapsibleTrigger",DX=_e.forwardRef((t,e)=>{const{__scopeCollapsible:n,...a}=t,r=z5(IX,n);return H.jsx(Kr.button,{type:"button","aria-controls":r.contentId,"aria-expanded":r.open||!1,"data-state":U5(r.open),"data-disabled":r.disabled?"":void 0,disabled:r.disabled,...a,ref:e,onClick:_n(t.onClick,r.onOpenToggle)})});DX.displayName=IX;var H5="CollapsibleContent",QX=_e.forwardRef((t,e)=>{const{forceMount:n,...a}=t,r=z5(H5,t.__scopeCollapsible);return H.jsx(Sp,{present:n||r.open,children:({present:i})=>H.jsx(vze,{...a,ref:e,present:i})})});QX.displayName=H5;var vze=_e.forwardRef((t,e)=>{const{__scopeCollapsible:n,present:a,children:r,...i}=t,o=z5(H5,n),[s,l]=_e.useState(a),u=_e.useRef(null),d=Ji(e,u),p=_e.useRef(0),m=p.current,A=_e.useRef(0),g=A.current,h=o.open||s,f=_e.useRef(h),b=_e.useRef(void 0);return _e.useEffect(()=>{const y=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(y)},[]),id(()=>{const y=u.current;if(y){b.current=b.current||{transitionDuration:y.style.transitionDuration,animationName:y.style.animationName},y.style.transitionDuration="0s",y.style.animationName="none";const w=y.getBoundingClientRect();p.current=w.height,A.current=w.width,f.current||(y.style.transitionDuration=b.current.transitionDuration,y.style.animationName=b.current.animationName),l(a)}},[o.open,a]),H.jsx(Kr.div,{"data-state":U5(o.open),"data-disabled":o.disabled?"":void 0,id:o.contentId,hidden:!h,...i,ref:d,style:{"--radix-collapsible-content-height":m?`${m}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...t.style},children:h&&r})});function U5(t){return t?"open":"closed"}var Cze=BX;function Y5({...t}){return H.jsx(Cze,{"data-slot":"collapsible",...t})}function W5({...t}){return H.jsx(DX,{"data-slot":"collapsible-trigger",...t})}function K5({...t}){return H.jsx(QX,{"data-slot":"collapsible-content",...t})}const SX=he.createContext({});function _ze(t){const e=he.useRef(null);return e.current===null&&(e.current=t()),e.current}const TX=typeof window<"u",xze=TX?he.useLayoutEffect:he.useEffect,Z5=he.createContext(null);function V5(t,e){t.indexOf(e)===-1&&t.push(e)}function J5(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const tu=(t,e,n)=>n>e?e:n<t?t:n;function FX(t,e){return e?`${t}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${e}`:t}var X5={npm_package_exports___require:"./dist/ai-agent.umd.js",npm_package_devDependencies__types_node:"20.2.5",npm_package_devDependencies_tw_animate_css:"1.4.0",npm_package_devDependencies_vitest:"1.2.2",npm_package_devDependencies__testing_library_jest_dom:"6.4.0",npm_config_user_agent:"pnpm/9.10.0 npm/? node/v20.17.0 linux x64",CI:"true",npm_package_devDependencies__testing_library_user_event:"14.5.2",npm_package_dependencies_cmdk:"1.1.1",npm_package_dependencies_embla_carousel_react:"8.6.0",npm_package_devDependencies_vite:"5.0.12",npm_node_execpath:"/opt/hostedtoolcache/node/20.17.0/x64/bin/node",npm_package_publishConfig_access:"public",npm_package_files_0:"dist",npm_package_dependencies__radix_ui_react_tooltip:"1.2.8",HOME:"/home/runner",npm_package_dependencies__radix_ui_react_dialog:"1.1.15",npm_package_dependencies__radix_ui_react_hover_card:"1.1.15",npm_package_devDependencies_classnames:"2.3.2",npm_package_devDependencies_sass:"1.62.1",npm_package_devDependencies_vite_plugin_static_copy:"1.0.0",npm_package_dependencies__radix_ui_react_separator:"1.1.8",npm_package_dependencies_shiki:"3.20.0",npm_config_auto_install_peers:"true",npm_package_dependencies_class_variance_authority:"0.7.1",npm_package_devDependencies_vite_plugin_dts:"3.7.1",npm_package_dependencies__radix_ui_react_dropdown_menu:"2.1.16",npm_package_dependencies__xyflow_react:"12.10.0",npm_package_devDependencies_tailwindcss:"4.1.18",npm_package_devDependencies_typescript:"5.1.3",npm_package_types:"./dist/index.d.ts",npm_package_devDependencies__types_react_dom:"18.3.1",npm_package_devDependencies__vitejs_plugin_react_swc:"3.5.0",npm_package_type:"module",npm_package_exports___default:"./dist/ai-agent.es.js",npm_package_dependencies__radix_ui_react_use_controllable_state:"1.2.2",npm_package_module:"./dist/ai-agent.es.js",npm_package_devDependencies__types_testing_library__jest_dom:"6.0.0",npm_package_dependencies_motion:"12.23.26",npm_package_devDependencies__vitest_coverage_v8:"1.2.2",npm_config_registry:"https://registry.npmjs.org/",npm_config_node_linker:"hoisted",npm_package_dependencies__codemirror_lang_json:"6.0.1",npm_package_dependencies_streamdown:"1.6.10",npm_package_exports___import:"./dist/ai-agent.es.js",npm_package_dependencies_tailwind_merge:"3.4.0",npm_config_node_gyp:"/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules/pnpm/dist/node_modules/node-gyp/bin/node-gyp.js",PATH:"/home/runner/work/avocado/avocado/packages/ai-agent/node_modules/.bin:/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules/pnpm/dist/node-gyp-bin:/home/runner/work/avocado/avocado/node_modules/.bin:/home/runner/work/avocado/avocado/node_modules/.bin:/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules/pnpm/dist/node-gyp-bin:/home/runner/work/avocado/avocado/node_modules/.bin:/opt/hostedtoolcache/node/20.17.0/x64/bin:/home/runner/setup-pnpm/node_modules/.bin:/snap/bin:/home/runner/.local/bin:/opt/pipx_bin:/home/runner/.cargo/bin:/home/runner/.config/composer/vendor/bin:/usr/local/.ghcup/bin:/home/runner/.dotnet/tools:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin",TURBO_HASH:"4020ef3d6a612e93",npm_package_name:"@foris/ai-agent",npm_package_dependencies_postcss:"8.5.6",NODE:"/opt/hostedtoolcache/node/20.17.0/x64/bin/node",npm_package_dependencies__radix_ui_react_select:"2.2.6",npm_package_dependencies_lucide_react:"0.561.0",npm_package_dependencies_tokenlens:"1.3.1",npm_config_frozen_lockfile:"",npm_package_devDependencies__vitest_ui:"1.2.2",npm_config_legacy_peer_deps:"true",LANG:"C.UTF-8",npm_package_dependencies_react_dom:"18.3.1",npm_package_main:"./dist/ai-agent.umd.js",npm_package_dependencies_ai:"5.0.115",npm_package_dependencies_react_markdown:"10.1.0",npm_lifecycle_script:"tsc && vite build",npm_package_dependencies__uiw_react_codemirror:"4.25.4",SHELL:"/bin/bash",NODE_PATH:"/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules/pnpm/bin/node_modules:/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules/pnpm/node_modules:/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules:/home/runner/setup-pnpm/node_modules/.pnpm/node_modules",npm_package_version:"0.8.1",npm_package_dependencies__radix_ui_react_slot:"1.2.4",npm_package_dependencies_nanoid:"5.1.6",npm_package_devDependencies__testing_library_react:"14.2.0",npm_package_devDependencies__types_react:"18.3.1",npm_package_devDependencies_jsdom:"24.0.0",npm_lifecycle_event:"build",npm_package_scripts_build:"tsc && vite build",npm_package_dependencies__ai_sdk_react:"2.0.117",npm_package_dependencies_clsx:"2.1.1",npm_package_devDependencies__foris_tsconfig:"workspace:*",npm_package_scripts_test_watch:"vitest --ui",npm_package_scripts_coverage:"vitest run --coverage",PWD:"/home/runner/work/avocado/avocado/packages/ai-agent",npm_package_dependencies__radix_ui_react_progress:"1.1.8",npm_execpath:"/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules/pnpm/bin/pnpm.cjs",npm_package_exports___types:"./dist/index.d.ts",npm_package_dependencies__radix_ui_react_scroll_area:"1.2.10",npm_package_dependencies__tailwindcss_postcss:"4.1.18",npm_package_devDependencies__shikijs_transformers:"3.20.0",npm_command:"run-script",PNPM_SCRIPT_SRC_DIR:"/home/runner/work/avocado/avocado/packages/ai-agent",npm_package_dependencies__radix_ui_react_collapsible:"1.1.12",npm_package_dependencies_react:"18.3.1",npm_package_dependencies_use_stick_to_bottom:"1.1.1",INIT_CWD:"/home/runner/work/avocado/avocado/packages/ai-agent",NODE_ENV:"production"};let Qw=()=>{},WA=()=>{};typeof process<"u"&&(X5==null?void 0:X5.NODE_ENV)!=="production"&&(Qw=(t,e,n)=>{!t&&typeof console<"u"&&console.warn(FX(e,n))},WA=(t,e,n)=>{if(!t)throw new Error(FX(e,n))});const wd={},LX=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function NX(t){return typeof t=="object"&&t!==null}const MX=t=>/^0[^.\s]+$/u.test(t);function e7(t){let e;return()=>(e===void 0&&(e=t()),e)}const gc=t=>t,Eze=(t,e)=>n=>e(t(n)),Sw=(...t)=>t.reduce(Eze),Tw=(t,e,n)=>{const a=e-t;return a===0?1:(n-t)/a};class t7{constructor(){this.subscriptions=[]}add(e){return V5(this.subscriptions,e),()=>J5(this.subscriptions,e)}notify(e,n,a){const r=this.subscriptions.length;if(r)if(r===1)this.subscriptions[0](e,n,a);else for(let i=0;i<r;i++){const o=this.subscriptions[i];o&&o(e,n,a)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const nu=t=>t*1e3,hc=t=>t/1e3;function RX(t,e){return e?t*(1e3/e):0}const $X=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,Bze=1e-7,Ize=12;function Dze(t,e,n,a,r){let i,o,s=0;do o=e+(n-e)/2,i=$X(o,a,r)-t,i>0?n=o:e=o;while(Math.abs(i)>Bze&&++s<Ize);return o}function Fw(t,e,n,a){if(t===e&&n===a)return gc;const r=i=>Dze(i,0,1,t,n);return i=>i===0||i===1?i:$X(r(i),e,a)}const PX=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,OX=t=>e=>1-t(1-e),jX=Fw(.33,1.53,.69,.99),n7=OX(jX),GX=PX(n7),qX=t=>(t*=2)<1?.5*n7(t):.5*(2-Math.pow(2,-10*(t-1))),a7=t=>1-Math.sin(Math.acos(t)),zX=OX(a7),HX=PX(a7),Qze=Fw(.42,0,1,1),Sze=Fw(0,0,.58,1),UX=Fw(.42,0,.58,1),Tze=t=>Array.isArray(t)&&typeof t[0]!="number",YX=t=>Array.isArray(t)&&typeof t[0]=="number",WX={linear:gc,easeIn:Qze,easeInOut:UX,easeOut:Sze,circIn:a7,circInOut:HX,circOut:zX,backIn:n7,backInOut:GX,backOut:jX,anticipate:qX},Fze=t=>typeof t=="string",KX=t=>{if(YX(t)){WA(t.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[e,n,a,r]=t;return Fw(e,n,a,r)}else if(Fze(t))return WA(WX[t]!==void 0,`Invalid easing type '${t}'`,"invalid-easing-type"),WX[t];return t},pB=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"],ZX={value:null,addProjectionMetrics:null};function Lze(t,e){let n=new Set,a=new Set,r=!1,i=!1;const o=new WeakSet;let s={delta:0,timestamp:0,isProcessing:!1},l=0;function u(p){o.has(p)&&(d.schedule(p),t()),l++,p(s)}const d={schedule:(p,m=!1,A=!1)=>{const h=A&&r?n:a;return m&&o.add(p),h.has(p)||h.add(p),p},cancel:p=>{a.delete(p),o.delete(p)},process:p=>{if(s=p,r){i=!0;return}r=!0,[n,a]=[a,n],n.forEach(u),e&&ZX.value&&ZX.value.frameloop[e].push(l),l=0,n.clear(),r=!1,i&&(i=!1,d.process(p))}};return d}const Nze=40;function VX(t,e){let n=!1,a=!0;const r={delta:0,timestamp:0,isProcessing:!1},i=()=>n=!0,o=pB.reduce((w,k)=>(w[k]=Lze(i,e?k:void 0),w),{}),{setup:s,read:l,resolveKeyframes:u,preUpdate:d,update:p,preRender:m,render:A,postRender:g}=o,h=()=>{const w=wd.useManualTiming?r.timestamp:performance.now();n=!1,wd.useManualTiming||(r.delta=a?1e3/60:Math.max(Math.min(w-r.timestamp,Nze),1)),r.timestamp=w,r.isProcessing=!0,s.process(r),l.process(r),u.process(r),d.process(r),p.process(r),m.process(r),A.process(r),g.process(r),r.isProcessing=!1,n&&e&&(a=!1,t(h))},f=()=>{n=!0,a=!0,r.isProcessing||t(h)};return{schedule:pB.reduce((w,k)=>{const C=o[k];return w[k]=(x,_=!1,E=!1)=>(n||f(),C.schedule(x,_,E)),w},{}),cancel:w=>{for(let k=0;k<pB.length;k++)o[pB[k]].cancel(w)},state:r,steps:o}}const{schedule:Ma,cancel:Hp,state:Li,steps:r7}=VX(typeof requestAnimationFrame<"u"?requestAnimationFrame:gc,!0);let mB;function Mze(){mB=void 0}const Fo={now:()=>(mB===void 0&&Fo.set(Li.isProcessing||wd.useManualTiming?Li.timestamp:performance.now()),mB),set:t=>{mB=t,queueMicrotask(Mze)}},JX=t=>e=>typeof e=="string"&&e.startsWith(t),XX=JX("--"),Rze=JX("var(--"),i7=t=>Rze(t)?$ze.test(t.split("/*")[0].trim()):!1,$ze=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function eee(t){return typeof t!="string"?!1:t.split("/*")[0].includes("var(--")}const Rf={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},Lw={...Rf,transform:t=>tu(0,1,t)},AB={...Rf,default:1},Nw=t=>Math.round(t*1e5)/1e5,o7=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Pze(t){return t==null}const Oze=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,s7=(t,e)=>n=>!!(typeof n=="string"&&Oze.test(n)&&n.startsWith(t)||e&&!Pze(n)&&Object.prototype.hasOwnProperty.call(n,e)),tee=(t,e,n)=>a=>{if(typeof a!="string")return a;const[r,i,o,s]=a.match(o7);return{[t]:parseFloat(r),[e]:parseFloat(i),[n]:parseFloat(o),alpha:s!==void 0?parseFloat(s):1}},jze=t=>tu(0,255,t),c7={...Rf,transform:t=>Math.round(jze(t))},KA={test:s7("rgb","red"),parse:tee("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:a=1})=>"rgba("+c7.transform(t)+", "+c7.transform(e)+", "+c7.transform(n)+", "+Nw(Lw.transform(a))+")"};function Gze(t){let e="",n="",a="",r="";return t.length>5?(e=t.substring(1,3),n=t.substring(3,5),a=t.substring(5,7),r=t.substring(7,9)):(e=t.substring(1,2),n=t.substring(2,3),a=t.substring(3,4),r=t.substring(4,5),e+=e,n+=n,a+=a,r+=r),{red:parseInt(e,16),green:parseInt(n,16),blue:parseInt(a,16),alpha:r?parseInt(r,16)/255:1}}const l7={test:s7("#"),parse:Gze,transform:KA.transform},Mw=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),Up=Mw("deg"),au=Mw("%"),Vt=Mw("px"),qze=Mw("vh"),zze=Mw("vw"),nee={...au,parse:t=>au.parse(t)/100,transform:t=>au.transform(t*100)},$f={test:s7("hsl","hue"),parse:tee("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:a=1})=>"hsla("+Math.round(t)+", "+au.transform(Nw(e))+", "+au.transform(Nw(n))+", "+Nw(Lw.transform(a))+")"},Tr={test:t=>KA.test(t)||l7.test(t)||$f.test(t),parse:t=>KA.test(t)?KA.parse(t):$f.test(t)?$f.parse(t):l7.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?KA.transform(t):$f.transform(t),getAnimatableNone:t=>{const e=Tr.parse(t);return e.alpha=0,Tr.transform(e)}},Hze=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function Uze(t){var e,n;return isNaN(t)&&typeof t=="string"&&(((e=t.match(o7))==null?void 0:e.length)||0)+(((n=t.match(Hze))==null?void 0:n.length)||0)>0}const aee="number",ree="color",Yze="var",Wze="var(",iee="${}",Kze=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function Rw(t){const e=t.toString(),n=[],a={color:[],number:[],var:[]},r=[];let i=0;const s=e.replace(Kze,l=>(Tr.test(l)?(a.color.push(i),r.push(ree),n.push(Tr.parse(l))):l.startsWith(Wze)?(a.var.push(i),r.push(Yze),n.push(l)):(a.number.push(i),r.push(aee),n.push(parseFloat(l))),++i,iee)).split(iee);return{values:n,split:s,indexes:a,types:r}}function oee(t){return Rw(t).values}function see(t){const{split:e,types:n}=Rw(t),a=e.length;return r=>{let i="";for(let o=0;o<a;o++)if(i+=e[o],r[o]!==void 0){const s=n[o];s===aee?i+=Nw(r[o]):s===ree?i+=Tr.transform(r[o]):i+=r[o]}return i}}const Zze=t=>typeof t=="number"?0:Tr.test(t)?Tr.getAnimatableNone(t):t;function Vze(t){const e=oee(t);return see(t)(e.map(Zze))}const Yp={test:Uze,parse:oee,createTransformer:see,getAnimatableNone:Vze};function u7(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*(2/3-n)*6:t}function Jze({hue:t,saturation:e,lightness:n,alpha:a}){t/=360,e/=100,n/=100;let r=0,i=0,o=0;if(!e)r=i=o=n;else{const s=n<.5?n*(1+e):n+e-n*e,l=2*n-s;r=u7(l,s,t+1/3),i=u7(l,s,t),o=u7(l,s,t-1/3)}return{red:Math.round(r*255),green:Math.round(i*255),blue:Math.round(o*255),alpha:a}}function gB(t,e){return n=>n>0?e:t}const or=(t,e,n)=>t+(e-t)*n,d7=(t,e,n)=>{const a=t*t,r=n*(e*e-a)+a;return r<0?0:Math.sqrt(r)},Xze=[l7,KA,$f],eHe=t=>Xze.find(e=>e.test(t));function cee(t){const e=eHe(t);if(Qw(!!e,`'${t}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!e)return!1;let n=e.parse(t);return e===$f&&(n=Jze(n)),n}const lee=(t,e)=>{const n=cee(t),a=cee(e);if(!n||!a)return gB(t,e);const r={...n};return i=>(r.red=d7(n.red,a.red,i),r.green=d7(n.green,a.green,i),r.blue=d7(n.blue,a.blue,i),r.alpha=or(n.alpha,a.alpha,i),KA.transform(r))},p7=new Set(["none","hidden"]);function tHe(t,e){return p7.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function nHe(t,e){return n=>or(t,e,n)}function m7(t){return typeof t=="number"?nHe:typeof t=="string"?i7(t)?gB:Tr.test(t)?lee:iHe:Array.isArray(t)?uee:typeof t=="object"?Tr.test(t)?lee:aHe:gB}function uee(t,e){const n=[...t],a=n.length,r=t.map((i,o)=>m7(i)(i,e[o]));return i=>{for(let o=0;o<a;o++)n[o]=r[o](i);return n}}function aHe(t,e){const n={...t,...e},a={};for(const r in n)t[r]!==void 0&&e[r]!==void 0&&(a[r]=m7(t[r])(t[r],e[r]));return r=>{for(const i in a)n[i]=a[i](r);return n}}function rHe(t,e){const n=[],a={color:0,var:0,number:0};for(let r=0;r<e.values.length;r++){const i=e.types[r],o=t.indexes[i][a[i]],s=t.values[o]??0;n[r]=s,a[i]++}return n}const iHe=(t,e)=>{const n=Yp.createTransformer(e),a=Rw(t),r=Rw(e);return a.indexes.var.length===r.indexes.var.length&&a.indexes.color.length===r.indexes.color.length&&a.indexes.number.length>=r.indexes.number.length?p7.has(t)&&!r.values.length||p7.has(e)&&!a.values.length?tHe(t,e):Sw(uee(rHe(a,r),r.values),n):(Qw(!0,`Complex values '${t}' and '${e}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`,"complex-values-different"),gB(t,e))};function dee(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?or(t,e,n):m7(t)(t,e)}const oHe=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>Ma.update(e,n),stop:()=>Hp(e),now:()=>Li.isProcessing?Li.timestamp:Fo.now()}},pee=(t,e,n=10)=>{let a="";const r=Math.max(Math.round(e/n),2);for(let i=0;i<r;i++)a+=Math.round(t(i/(r-1))*1e4)/1e4+", ";return`linear(${a.substring(0,a.length-2)})`},hB=2e4;function A7(t){let e=0;const n=50;let a=t.next(e);for(;!a.done&&e<hB;)e+=n,a=t.next(e);return e>=hB?1/0:e}function sHe(t,e=100,n){const a=n({...t,keyframes:[0,e]}),r=Math.min(A7(a),hB);return{type:"keyframes",ease:i=>a.next(r*i).value/e,duration:hc(r)}}const cHe=5;function mee(t,e,n){const a=Math.max(e-cHe,0);return RX(n-t(a),e-a)}const sr={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},g7=.001;function lHe({duration:t=sr.duration,bounce:e=sr.bounce,velocity:n=sr.velocity,mass:a=sr.mass}){let r,i;Qw(t<=nu(sr.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let o=1-e;o=tu(sr.minDamping,sr.maxDamping,o),t=tu(sr.minDuration,sr.maxDuration,hc(t)),o<1?(r=u=>{const d=u*o,p=d*t,m=d-n,A=h7(u,o),g=Math.exp(-p);return g7-m/A*g},i=u=>{const p=u*o*t,m=p*n+n,A=Math.pow(o,2)*Math.pow(u,2)*t,g=Math.exp(-p),h=h7(Math.pow(u,2),o);return(-r(u)+g7>0?-1:1)*((m-A)*g)/h}):(r=u=>{const d=Math.exp(-u*t),p=(u-n)*t+1;return-g7+d*p},i=u=>{const d=Math.exp(-u*t),p=(n-u)*(t*t);return d*p});const s=5/t,l=dHe(r,i,s);if(t=nu(t),isNaN(l))return{stiffness:sr.stiffness,damping:sr.damping,duration:t};{const u=Math.pow(l,2)*a;return{stiffness:u,damping:o*2*Math.sqrt(a*u),duration:t}}}const uHe=12;function dHe(t,e,n){let a=n;for(let r=1;r<uHe;r++)a=a-t(a)/e(a);return a}function h7(t,e){return t*Math.sqrt(1-e*e)}const pHe=["duration","bounce"],mHe=["stiffness","damping","mass"];function Aee(t,e){return e.some(n=>t[n]!==void 0)}function AHe(t){let e={velocity:sr.velocity,stiffness:sr.stiffness,damping:sr.damping,mass:sr.mass,isResolvedFromDuration:!1,...t};if(!Aee(t,mHe)&&Aee(t,pHe))if(t.visualDuration){const n=t.visualDuration,a=2*Math.PI/(n*1.2),r=a*a,i=2*tu(.05,1,1-(t.bounce||0))*Math.sqrt(r);e={...e,mass:sr.mass,stiffness:r,damping:i}}else{const n=lHe(t);e={...e,...n,mass:sr.mass},e.isResolvedFromDuration=!0}return e}function fB(t=sr.visualDuration,e=sr.bounce){const n=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:a,restDelta:r}=n;const i=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],s={done:!1,value:i},{stiffness:l,damping:u,mass:d,duration:p,velocity:m,isResolvedFromDuration:A}=AHe({...n,velocity:-hc(n.velocity||0)}),g=m||0,h=u/(2*Math.sqrt(l*d)),f=o-i,b=hc(Math.sqrt(l/d)),y=Math.abs(f)<5;a||(a=y?sr.restSpeed.granular:sr.restSpeed.default),r||(r=y?sr.restDelta.granular:sr.restDelta.default);let w;if(h<1){const C=h7(b,h);w=x=>{const _=Math.exp(-h*b*x);return o-_*((g+h*b*f)/C*Math.sin(C*x)+f*Math.cos(C*x))}}else if(h===1)w=C=>o-Math.exp(-b*C)*(f+(g+b*f)*C);else{const C=b*Math.sqrt(h*h-1);w=x=>{const _=Math.exp(-h*b*x),E=Math.min(C*x,300);return o-_*((g+h*b*f)*Math.sinh(E)+C*f*Math.cosh(E))/C}}const k={calculatedDuration:A&&p||null,next:C=>{const x=w(C);if(A)s.done=C>=p;else{let _=C===0?g:0;h<1&&(_=C===0?nu(g):mee(w,C,x));const E=Math.abs(_)<=a,D=Math.abs(o-x)<=r;s.done=E&&D}return s.value=s.done?o:x,s},toString:()=>{const C=Math.min(A7(k),hB),x=pee(_=>k.next(C*_).value,C,30);return C+"ms "+x},toTransition:()=>{}};return k}fB.applyToOptions=t=>{const e=sHe(t,100,fB);return t.ease=e.ease,t.duration=nu(e.duration),t.type="keyframes",t};function f7({keyframes:t,velocity:e=0,power:n=.8,timeConstant:a=325,bounceDamping:r=10,bounceStiffness:i=500,modifyTarget:o,min:s,max:l,restDelta:u=.5,restSpeed:d}){const p=t[0],m={done:!1,value:p},A=E=>s!==void 0&&E<s||l!==void 0&&E>l,g=E=>s===void 0?l:l===void 0||Math.abs(s-E)<Math.abs(l-E)?s:l;let h=n*e;const f=p+h,b=o===void 0?f:o(f);b!==f&&(h=b-p);const y=E=>-h*Math.exp(-E/a),w=E=>b+y(E),k=E=>{const D=y(E),Q=w(E);m.done=Math.abs(D)<=u,m.value=m.done?b:Q};let C,x;const _=E=>{A(m.value)&&(C=E,x=fB({keyframes:[m.value,g(m.value)],velocity:mee(w,E,m.value),damping:r,stiffness:i,restDelta:u,restSpeed:d}))};return _(0),{calculatedDuration:null,next:E=>{let D=!1;return!x&&C===void 0&&(D=!0,k(E),_(E)),C!==void 0&&E>=C?x.next(E-C):(!D&&k(E),m)}}}function gHe(t,e,n){const a=[],r=n||wd.mix||dee,i=t.length-1;for(let o=0;o<i;o++){let s=r(t[o],t[o+1]);if(e){const l=Array.isArray(e)?e[o]||gc:e;s=Sw(l,s)}a.push(s)}return a}function hHe(t,e,{clamp:n=!0,ease:a,mixer:r}={}){const i=t.length;if(WA(i===e.length,"Both input and output ranges must be the same length","range-length"),i===1)return()=>e[0];if(i===2&&e[0]===e[1])return()=>e[1];const o=t[0]===t[1];t[0]>t[i-1]&&(t=[...t].reverse(),e=[...e].reverse());const s=gHe(e,a,r),l=s.length,u=d=>{if(o&&d<t[0])return e[0];let p=0;if(l>1)for(;p<t.length-2&&!(d<t[p+1]);p++);const m=Tw(t[p],t[p+1],d);return s[p](m)};return n?d=>u(tu(t[0],t[i-1],d)):u}function fHe(t,e){const n=t[t.length-1];for(let a=1;a<=e;a++){const r=Tw(0,e,a);t.push(or(n,1,r))}}function bHe(t){const e=[0];return fHe(e,t.length-1),e}function yHe(t,e){return t.map(n=>n*e)}function wHe(t,e){return t.map(()=>e||UX).splice(0,t.length-1)}function $w({duration:t=300,keyframes:e,times:n,ease:a="easeInOut"}){const r=Tze(a)?a.map(KX):KX(a),i={done:!1,value:e[0]},o=yHe(n&&n.length===e.length?n:bHe(e),t),s=hHe(o,e,{ease:Array.isArray(r)?r:wHe(e,r)});return{calculatedDuration:t,next:l=>(i.value=s(l),i.done=l>=t,i)}}const kHe=t=>t!==null;function b7(t,{repeat:e,repeatType:n="loop"},a,r=1){const i=t.filter(kHe),s=r<0||e&&n!=="loop"&&e%2===1?0:i.length-1;return!s||a===void 0?i[s]:a}const vHe={decay:f7,inertia:f7,tween:$w,keyframes:$w,spring:fB};function gee(t){typeof t.type=="string"&&(t.type=vHe[t.type])}class y7{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,n){return this.finished.then(e,n)}}const CHe=t=>t/100;class w7 extends y7{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{var a,r;const{motionValue:n}=this.options;n&&n.updatedAt!==Fo.now()&&this.tick(Fo.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),(r=(a=this.options).onStop)==null||r.call(a))},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){const{options:e}=this;gee(e);const{type:n=$w,repeat:a=0,repeatDelay:r=0,repeatType:i,velocity:o=0}=e;let{keyframes:s}=e;const l=n||$w;l!==$w&&typeof s[0]!="number"&&(this.mixKeyframes=Sw(CHe,dee(s[0],s[1])),s=[0,100]);const u=l({...e,keyframes:s});i==="mirror"&&(this.mirroredGenerator=l({...e,keyframes:[...s].reverse(),velocity:-o})),u.calculatedDuration===null&&(u.calculatedDuration=A7(u));const{calculatedDuration:d}=u;this.calculatedDuration=d,this.resolvedDuration=d+r,this.totalDuration=this.resolvedDuration*(a+1)-r,this.generator=u}updateTime(e){const n=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(e,n=!1){const{generator:a,totalDuration:r,mixKeyframes:i,mirroredGenerator:o,resolvedDuration:s,calculatedDuration:l}=this;if(this.startTime===null)return a.next(0);const{delay:u=0,keyframes:d,repeat:p,repeatType:m,repeatDelay:A,type:g,onUpdate:h,finalKeyframe:f}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-r/this.speed,this.startTime)),n?this.currentTime=e:this.updateTime(e);const b=this.currentTime-u*(this.playbackSpeed>=0?1:-1),y=this.playbackSpeed>=0?b<0:b>r;this.currentTime=Math.max(b,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=r);let w=this.currentTime,k=a;if(p){const E=Math.min(this.currentTime,r)/s;let D=Math.floor(E),Q=E%1;!Q&&E>=1&&(Q=1),Q===1&&D--,D=Math.min(D,p+1),!!(D%2)&&(m==="reverse"?(Q=1-Q,A&&(Q-=A/s)):m==="mirror"&&(k=o)),w=tu(0,1,Q)*s}const C=y?{done:!1,value:d[0]}:k.next(w);i&&(C.value=i(C.value));let{done:x}=C;!y&&l!==null&&(x=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);const _=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&x);return _&&g!==f7&&(C.value=b7(d,this.options,f,this.speed)),h&&h(C.value),_&&this.finish(),C}then(e,n){return this.finished.then(e,n)}get duration(){return hc(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+hc(e)}get time(){return hc(this.currentTime)}set time(e){var n;e=nu(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),(n=this.driver)==null||n.start(!1)}get speed(){return this.playbackSpeed}set speed(e){this.updateTime(Fo.now());const n=this.playbackSpeed!==e;this.playbackSpeed=e,n&&(this.time=hc(this.currentTime))}play(){var r,i;if(this.isStopped)return;const{driver:e=oHe,startTime:n}=this.options;this.driver||(this.driver=e(o=>this.tick(o))),(i=(r=this.options).onPlay)==null||i.call(r);const a=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=a):this.holdTime!==null?this.startTime=a-this.holdTime:this.startTime||(this.startTime=n??a),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(Fo.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){var e,n;this.notifyFinished(),this.teardown(),this.state="finished",(n=(e=this.options).onComplete)==null||n.call(e)}cancel(){var e,n;this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),(n=(e=this.options).onCancel)==null||n.call(e)}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){var n;return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),(n=this.driver)==null||n.stop(),e.observe(this)}}function _He(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const ZA=t=>t*180/Math.PI,k7=t=>{const e=ZA(Math.atan2(t[1],t[0]));return v7(e)},xHe={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:k7,rotateZ:k7,skewX:t=>ZA(Math.atan(t[1])),skewY:t=>ZA(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},v7=t=>(t=t%360,t<0&&(t+=360),t),hee=k7,fee=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),bee=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),EHe={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:fee,scaleY:bee,scale:t=>(fee(t)+bee(t))/2,rotateX:t=>v7(ZA(Math.atan2(t[6],t[5]))),rotateY:t=>v7(ZA(Math.atan2(-t[2],t[0]))),rotateZ:hee,rotate:hee,skewX:t=>ZA(Math.atan(t[4])),skewY:t=>ZA(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function C7(t){return t.includes("scale")?1:0}function _7(t,e){if(!t||t==="none")return C7(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let a,r;if(n)a=EHe,r=n;else{const s=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);a=xHe,r=s}if(!r)return C7(e);const i=a[e],o=r[1].split(",").map(IHe);return typeof i=="function"?i(o):o[i]}const BHe=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return _7(n,e)};function IHe(t){return parseFloat(t.trim())}const Pf=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Of=new Set(Pf),yee=t=>t===Rf||t===Vt,DHe=new Set(["x","y","z"]),QHe=Pf.filter(t=>!DHe.has(t));function SHe(t){const e=[];return QHe.forEach(n=>{const a=t.getValue(n);a!==void 0&&(e.push([n,a.get()]),a.set(n.startsWith("scale")?1:0))}),e}const Wp={width:({x:t},{paddingLeft:e="0",paddingRight:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),height:({y:t},{paddingTop:e="0",paddingBottom:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),top:(t,{top:e})=>parseFloat(e),left:(t,{left:e})=>parseFloat(e),bottom:({y:t},{top:e})=>parseFloat(e)+(t.max-t.min),right:({x:t},{left:e})=>parseFloat(e)+(t.max-t.min),x:(t,{transform:e})=>_7(e,"x"),y:(t,{transform:e})=>_7(e,"y")};Wp.translateX=Wp.x,Wp.translateY=Wp.y;const VA=new Set;let x7=!1,E7=!1,B7=!1;function wee(){if(E7){const t=Array.from(VA).filter(a=>a.needsMeasurement),e=new Set(t.map(a=>a.element)),n=new Map;e.forEach(a=>{const r=SHe(a);r.length&&(n.set(a,r),a.render())}),t.forEach(a=>a.measureInitialState()),e.forEach(a=>{a.render();const r=n.get(a);r&&r.forEach(([i,o])=>{var s;(s=a.getValue(i))==null||s.set(o)})}),t.forEach(a=>a.measureEndState()),t.forEach(a=>{a.suspendedScrollY!==void 0&&window.scrollTo(0,a.suspendedScrollY)})}E7=!1,x7=!1,VA.forEach(t=>t.complete(B7)),VA.clear()}function kee(){VA.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(E7=!0)})}function THe(){B7=!0,kee(),wee(),B7=!1}class I7{constructor(e,n,a,r,i,o=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=n,this.name=a,this.motionValue=r,this.element=i,this.isAsync=o}scheduleResolve(){this.state="scheduled",this.isAsync?(VA.add(this),x7||(x7=!0,Ma.read(kee),Ma.resolveKeyframes(wee))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:n,element:a,motionValue:r}=this;if(e[0]===null){const i=r==null?void 0:r.get(),o=e[e.length-1];if(i!==void 0)e[0]=i;else if(a&&n){const s=a.readValue(n,o);s!=null&&(e[0]=s)}e[0]===void 0&&(e[0]=o),r&&i===void 0&&r.set(e[0])}_He(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),VA.delete(this)}cancel(){this.state==="scheduled"&&(VA.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const FHe=t=>t.startsWith("--");function LHe(t,e,n){FHe(e)?t.style.setProperty(e,n):t.style[e]=n}const NHe=e7(()=>window.ScrollTimeline!==void 0),MHe={};function RHe(t,e){const n=e7(t);return()=>MHe[e]??n()}const vee=RHe(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),Pw=([t,e,n,a])=>`cubic-bezier(${t}, ${e}, ${n}, ${a})`,Cee={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Pw([0,.65,.55,1]),circOut:Pw([.55,0,1,.45]),backIn:Pw([.31,.01,.66,-.59]),backOut:Pw([.33,1.53,.69,.99])};function _ee(t,e){if(t)return typeof t=="function"?vee()?pee(t,e):"ease-out":YX(t)?Pw(t):Array.isArray(t)?t.map(n=>_ee(n,e)||Cee.easeOut):Cee[t]}function $He(t,e,n,{delay:a=0,duration:r=300,repeat:i=0,repeatType:o="loop",ease:s="easeOut",times:l}={},u=void 0){const d={[e]:n};l&&(d.offset=l);const p=_ee(s,r);Array.isArray(p)&&(d.easing=p);const m={delay:a,duration:r,easing:Array.isArray(p)?"linear":p,fill:"both",iterations:i+1,direction:o==="reverse"?"alternate":"normal"};return u&&(m.pseudoElement=u),t.animate(d,m)}function xee(t){return typeof t=="function"&&"applyToOptions"in t}function PHe({type:t,...e}){return xee(t)&&vee()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class OHe extends y7{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;const{element:n,name:a,keyframes:r,pseudoElement:i,allowFlatten:o=!1,finalKeyframe:s,onComplete:l}=e;this.isPseudoElement=!!i,this.allowFlatten=o,this.options=e,WA(typeof e.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const u=PHe(e);this.animation=$He(n,a,r,u,i),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){const d=b7(r,this.options,s,this.speed);this.updateMotionValue?this.updateMotionValue(d):LHe(n,a,d),this.animation.cancel()}l==null||l(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){var e,n;(n=(e=this.animation).finish)==null||n.call(e)}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:e}=this;e==="idle"||e==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){var e,n;this.isPseudoElement||(n=(e=this.animation).commitStyles)==null||n.call(e)}get duration(){var n,a;const e=((a=(n=this.animation.effect)==null?void 0:n.getComputedTiming)==null?void 0:a.call(n).duration)||0;return hc(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+hc(e)}get time(){return hc(Number(this.animation.currentTime)||0)}set time(e){this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=nu(e)}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,observe:n}){var a;return this.allowFlatten&&((a=this.animation.effect)==null||a.updateTiming({easing:"linear"})),this.animation.onfinish=null,e&&NHe()?(this.animation.timeline=e,gc):n(this)}}const Eee={anticipate:qX,backInOut:GX,circInOut:HX};function jHe(t){return t in Eee}function GHe(t){typeof t.ease=="string"&&jHe(t.ease)&&(t.ease=Eee[t.ease])}const D7=10;class qHe extends OHe{constructor(e){GHe(e),gee(e),super(e),e.startTime!==void 0&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:n,onUpdate:a,onComplete:r,element:i,...o}=this.options;if(!n)return;if(e!==void 0){n.set(e);return}const s=new w7({...o,autoplay:!1}),l=Math.max(D7,Fo.now()-this.startTime),u=tu(0,D7,l-D7);n.setWithVelocity(s.sample(Math.max(0,l-u)).value,s.sample(l).value,u),s.stop()}}const Bee=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Yp.test(t)||t==="0")&&!t.startsWith("url("));function zHe(t){const e=t[0];if(t.length===1)return!0;for(let n=0;n<t.length;n++)if(t[n]!==e)return!0}function HHe(t,e,n,a){const r=t[0];if(r===null)return!1;if(e==="display"||e==="visibility")return!0;const i=t[t.length-1],o=Bee(r,e),s=Bee(i,e);return Qw(o===s,`You are trying to animate ${e} from "${r}" to "${i}". "${o?i:r}" is not an animatable value.`,"value-not-animatable"),!o||!s?!1:zHe(t)||(n==="spring"||xee(n))&&a}function Q7(t){t.duration=0,t.type="keyframes"}const UHe=new Set(["opacity","clipPath","filter","transform"]),YHe=e7(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function WHe(t){var d;const{motionValue:e,name:n,repeatDelay:a,repeatType:r,damping:i,type:o}=t;if(!(((d=e==null?void 0:e.owner)==null?void 0:d.current)instanceof HTMLElement))return!1;const{onUpdate:l,transformTemplate:u}=e.owner.getProps();return YHe()&&n&&UHe.has(n)&&(n!=="transform"||!u)&&!l&&!a&&r!=="mirror"&&i!==0&&o!=="inertia"}const KHe=40;class ZHe extends y7{constructor({autoplay:e=!0,delay:n=0,type:a="keyframes",repeat:r=0,repeatDelay:i=0,repeatType:o="loop",keyframes:s,name:l,motionValue:u,element:d,...p}){var g;super(),this.stop=()=>{var h,f;this._animation&&(this._animation.stop(),(h=this.stopTimeline)==null||h.call(this)),(f=this.keyframeResolver)==null||f.cancel()},this.createdAt=Fo.now();const m={autoplay:e,delay:n,type:a,repeat:r,repeatDelay:i,repeatType:o,name:l,motionValue:u,element:d,...p},A=(d==null?void 0:d.KeyframeResolver)||I7;this.keyframeResolver=new A(s,(h,f,b)=>this.onKeyframesResolved(h,f,m,!b),l,u,d),(g=this.keyframeResolver)==null||g.scheduleResolve()}onKeyframesResolved(e,n,a,r){var f,b;this.keyframeResolver=void 0;const{name:i,type:o,velocity:s,delay:l,isHandoff:u,onUpdate:d}=a;this.resolvedAt=Fo.now(),HHe(e,i,o,s)||((wd.instantAnimations||!l)&&(d==null||d(b7(e,a,n))),e[0]=e[e.length-1],Q7(a),a.repeat=0);const m={startTime:r?this.resolvedAt?this.resolvedAt-this.createdAt>KHe?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...a,keyframes:e},A=!u&&WHe(m),g=(b=(f=m.motionValue)==null?void 0:f.owner)==null?void 0:b.current,h=A?new qHe({...m,element:g}):new w7(m);h.finished.then(()=>{this.notifyFinished()}).catch(gc),this.pendingTimeline&&(this.stopTimeline=h.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=h}get finished(){return this._animation?this.animation.finished:this._finished}then(e,n){return this.finished.finally(e).then(()=>{})}get animation(){var e;return this._animation||((e=this.keyframeResolver)==null||e.resume(),THe()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){var e;this._animation&&this.animation.cancel(),(e=this.keyframeResolver)==null||e.cancel()}}function Iee(t,e,n,a=0,r=1){const i=Array.from(t).sort((u,d)=>u.sortNodePosition(d)).indexOf(e),o=t.size,s=(o-1)*a;return typeof n=="function"?n(i,o):r===1?i*a:s-i*a}const VHe=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function JHe(t){const e=VHe.exec(t);if(!e)return[,];const[,n,a,r]=e;return[`--${n??a}`,r]}const XHe=4;function Dee(t,e,n=1){WA(n<=XHe,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[a,r]=JHe(t);if(!a)return;const i=window.getComputedStyle(e).getPropertyValue(a);if(i){const o=i.trim();return LX(o)?parseFloat(o):o}return i7(r)?Dee(r,e,n+1):r}const eUe={type:"spring",stiffness:500,damping:25,restSpeed:10},tUe=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),nUe={type:"keyframes",duration:.8},aUe={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},rUe=(t,{keyframes:e})=>e.length>2?nUe:Of.has(t)?t.startsWith("scale")?tUe(e[1]):eUe:aUe,iUe=t=>t!==null;function oUe(t,{repeat:e,repeatType:n="loop"},a){const r=t.filter(iUe),i=e&&n!=="loop"&&e%2===1?0:r.length-1;return!i||a===void 0?r[i]:a}function S7(t,e){return(t==null?void 0:t[e])??(t==null?void 0:t.default)??t}function sUe({when:t,delay:e,delayChildren:n,staggerChildren:a,staggerDirection:r,repeat:i,repeatType:o,repeatDelay:s,from:l,elapsed:u,...d}){return!!Object.keys(d).length}const T7=(t,e,n,a={},r,i)=>o=>{const s=S7(a,t)||{},l=s.delay||a.delay||0;let{elapsed:u=0}=a;u=u-nu(l);const d={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...s,delay:-u,onUpdate:m=>{e.set(m),s.onUpdate&&s.onUpdate(m)},onComplete:()=>{o(),s.onComplete&&s.onComplete()},name:t,motionValue:e,element:i?void 0:r};sUe(s)||Object.assign(d,rUe(t,d)),d.duration&&(d.duration=nu(d.duration)),d.repeatDelay&&(d.repeatDelay=nu(d.repeatDelay)),d.from!==void 0&&(d.keyframes[0]=d.from);let p=!1;if((d.type===!1||d.duration===0&&!d.repeatDelay)&&(Q7(d),d.delay===0&&(p=!0)),(wd.instantAnimations||wd.skipAnimations)&&(p=!0,Q7(d),d.delay=0),d.allowFlatten=!s.type&&!s.ease,p&&!i&&e.get()!==void 0){const m=oUe(d.keyframes,s);if(m!==void 0){Ma.update(()=>{d.onUpdate(m),d.onComplete()});return}}return s.isSync?new w7(d):new ZHe(d)};function Qee(t){const e=[{},{}];return t==null||t.values.forEach((n,a)=>{e[0][a]=n.get(),e[1][a]=n.getVelocity()}),e}function F7(t,e,n,a){if(typeof e=="function"){const[r,i]=Qee(a);e=e(n!==void 0?n:t.custom,r,i)}if(typeof e=="string"&&(e=t.variants&&t.variants[e]),typeof e=="function"){const[r,i]=Qee(a);e=e(n!==void 0?n:t.custom,r,i)}return e}function jf(t,e,n){const a=t.getProps();return F7(a,e,n!==void 0?n:a.custom,t)}const See=new Set(["width","height","top","left","right","bottom",...Pf]),Tee=30,cUe=t=>!isNaN(parseFloat(t));class lUe{constructor(e,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=a=>{var i;const r=Fo.now();if(this.updatedAt!==r&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(a),this.current!==this.prev&&((i=this.events.change)==null||i.notify(this.current),this.dependents))for(const o of this.dependents)o.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=n.owner}setCurrent(e){this.current=e,this.updatedAt=Fo.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=cUe(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on("change",e)}on(e,n){this.events[e]||(this.events[e]=new t7);const a=this.events[e].add(n);return e==="change"?()=>{a(),Ma.read(()=>{this.events.change.getSize()||this.stop()})}:a}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,n){this.passiveEffect=e,this.stopPassiveEffect=n}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,n,a){this.set(n),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-a}jump(e,n=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){var e;(e=this.events.change)==null||e.notify(this.current)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const e=Fo.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Tee)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,Tee);return RX(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(e){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=e(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){var e,n;(e=this.dependents)==null||e.clear(),(n=this.events.destroy)==null||n.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function Gf(t,e){return new lUe(t,e)}const L7=t=>Array.isArray(t);function uUe(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,Gf(n))}function dUe(t){return L7(t)?t[t.length-1]||0:t}function pUe(t,e){const n=jf(t,e);let{transitionEnd:a={},transition:r={},...i}=n||{};i={...i,...a};for(const o in i){const s=dUe(i[o]);uUe(t,o,s)}}const no=t=>!!(t&&t.getVelocity);function mUe(t){return!!(no(t)&&t.add)}function N7(t,e){const n=t.getValue("willChange");if(mUe(n))return n.add(e);if(!n&&wd.WillChange){const a=new wd.WillChange("auto");t.addValue("willChange",a),a.add(e)}}function M7(t){return t.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}const Fee="data-"+M7("framerAppearId");function Lee(t){return t.props[Fee]}function AUe({protectedKeys:t,needsAnimating:e},n){const a=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,a}function Nee(t,e,{delay:n=0,transitionOverride:a,type:r}={}){let{transition:i=t.getDefaultTransition(),transitionEnd:o,...s}=e;a&&(i=a);const l=[],u=r&&t.animationState&&t.animationState.getState()[r];for(const d in s){const p=t.getValue(d,t.latestValues[d]??null),m=s[d];if(m===void 0||u&&AUe(u,d))continue;const A={delay:n,...S7(i||{},d)},g=p.get();if(g!==void 0&&!p.isAnimating&&!Array.isArray(m)&&m===g&&!A.velocity)continue;let h=!1;if(window.MotionHandoffAnimation){const b=Lee(t);if(b){const y=window.MotionHandoffAnimation(b,d,Ma);y!==null&&(A.startTime=y,h=!0)}}N7(t,d),p.start(T7(d,p,m,t.shouldReduceMotion&&See.has(d)?{type:!1}:A,t,h));const f=p.animation;f&&l.push(f)}return o&&Promise.all(l).then(()=>{Ma.update(()=>{o&&pUe(t,o)})}),l}function R7(t,e,n={}){var l;const a=jf(t,e,n.type==="exit"?(l=t.presenceContext)==null?void 0:l.custom:void 0);let{transition:r=t.getDefaultTransition()||{}}=a||{};n.transitionOverride&&(r=n.transitionOverride);const i=a?()=>Promise.all(Nee(t,a,n)):()=>Promise.resolve(),o=t.variantChildren&&t.variantChildren.size?(u=0)=>{const{delayChildren:d=0,staggerChildren:p,staggerDirection:m}=r;return gUe(t,e,u,d,p,m,n)}:()=>Promise.resolve(),{when:s}=r;if(s){const[u,d]=s==="beforeChildren"?[i,o]:[o,i];return u().then(()=>d())}else return Promise.all([i(),o(n.delay)])}function gUe(t,e,n=0,a=0,r=0,i=1,o){const s=[];for(const l of t.variantChildren)l.notify("AnimationStart",e),s.push(R7(l,e,{...o,delay:n+(typeof a=="function"?0:a)+Iee(t.variantChildren,l,a,r,i)}).then(()=>l.notify("AnimationComplete",e)));return Promise.all(s)}function hUe(t,e,n={}){t.notify("AnimationStart",e);let a;if(Array.isArray(e)){const r=e.map(i=>R7(t,i,n));a=Promise.all(r)}else if(typeof e=="string")a=R7(t,e,n);else{const r=typeof e=="function"?jf(t,e,n.custom):e;a=Promise.all(Nee(t,r,n))}return a.then(()=>{t.notify("AnimationComplete",e)})}const fUe={test:t=>t==="auto",parse:t=>t},Mee=t=>e=>e.test(t),Ree=[Rf,Vt,au,Up,zze,qze,fUe],$ee=t=>Ree.find(Mee(t));function bUe(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||MX(t):!0}const yUe=new Set(["brightness","contrast","saturate","opacity"]);function wUe(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[a]=n.match(o7)||[];if(!a)return t;const r=n.replace(a,"");let i=yUe.has(e)?1:0;return a!==n&&(i*=100),e+"("+i+r+")"}const kUe=/\b([a-z-]*)\(.*?\)/gu,$7={...Yp,getAnimatableNone:t=>{const e=t.match(kUe);return e?e.map(wUe).join(" "):t}},Pee={...Rf,transform:Math.round},P7={borderWidth:Vt,borderTopWidth:Vt,borderRightWidth:Vt,borderBottomWidth:Vt,borderLeftWidth:Vt,borderRadius:Vt,borderTopLeftRadius:Vt,borderTopRightRadius:Vt,borderBottomRightRadius:Vt,borderBottomLeftRadius:Vt,width:Vt,maxWidth:Vt,height:Vt,maxHeight:Vt,top:Vt,right:Vt,bottom:Vt,left:Vt,inset:Vt,insetBlock:Vt,insetBlockStart:Vt,insetBlockEnd:Vt,insetInline:Vt,insetInlineStart:Vt,insetInlineEnd:Vt,padding:Vt,paddingTop:Vt,paddingRight:Vt,paddingBottom:Vt,paddingLeft:Vt,paddingBlock:Vt,paddingBlockStart:Vt,paddingBlockEnd:Vt,paddingInline:Vt,paddingInlineStart:Vt,paddingInlineEnd:Vt,margin:Vt,marginTop:Vt,marginRight:Vt,marginBottom:Vt,marginLeft:Vt,marginBlock:Vt,marginBlockStart:Vt,marginBlockEnd:Vt,marginInline:Vt,marginInlineStart:Vt,marginInlineEnd:Vt,fontSize:Vt,backgroundPositionX:Vt,backgroundPositionY:Vt,...{rotate:Up,rotateX:Up,rotateY:Up,rotateZ:Up,scale:AB,scaleX:AB,scaleY:AB,scaleZ:AB,skew:Up,skewX:Up,skewY:Up,distance:Vt,translateX:Vt,translateY:Vt,translateZ:Vt,x:Vt,y:Vt,z:Vt,perspective:Vt,transformPerspective:Vt,opacity:Lw,originX:nee,originY:nee,originZ:Vt},zIndex:Pee,fillOpacity:Lw,strokeOpacity:Lw,numOctaves:Pee},vUe={...P7,color:Tr,backgroundColor:Tr,outlineColor:Tr,fill:Tr,stroke:Tr,borderColor:Tr,borderTopColor:Tr,borderRightColor:Tr,borderBottomColor:Tr,borderLeftColor:Tr,filter:$7,WebkitFilter:$7},Oee=t=>vUe[t];function jee(t,e){let n=Oee(t);return n!==$7&&(n=Yp),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const CUe=new Set(["auto","none","0"]);function _Ue(t,e,n){let a=0,r;for(;a<t.length&&!r;){const i=t[a];typeof i=="string"&&!CUe.has(i)&&Rw(i).values.length&&(r=t[a]),a++}if(r&&n)for(const i of e)t[i]=jee(n,r)}class xUe extends I7{constructor(e,n,a,r,i){super(e,n,a,r,i,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:n,name:a}=this;if(!n||!n.current)return;super.readKeyframes();for(let d=0;d<e.length;d++){let p=e[d];if(typeof p=="string"&&(p=p.trim(),i7(p))){const m=Dee(p,n.current);m!==void 0&&(e[d]=m),d===e.length-1&&(this.finalKeyframe=p)}}if(this.resolveNoneKeyframes(),!See.has(a)||e.length!==2)return;const[r,i]=e,o=$ee(r),s=$ee(i),l=eee(r),u=eee(i);if(l!==u&&Wp[a]){this.needsMeasurement=!0;return}if(o!==s)if(yee(o)&&yee(s))for(let d=0;d<e.length;d++){const p=e[d];typeof p=="string"&&(e[d]=parseFloat(p))}else Wp[a]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,a=[];for(let r=0;r<e.length;r++)(e[r]===null||bUe(e[r]))&&a.push(r);a.length&&_Ue(e,a,n)}measureInitialState(){const{element:e,unresolvedKeyframes:n,name:a}=this;if(!e||!e.current)return;a==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Wp[a](e.measureViewportBox(),window.getComputedStyle(e.current)),n[0]=this.measuredOrigin;const r=n[n.length-1];r!==void 0&&e.getValue(a,r).jump(r,!1)}measureEndState(){var s;const{element:e,name:n,unresolvedKeyframes:a}=this;if(!e||!e.current)return;const r=e.getValue(n);r&&r.jump(this.measuredOrigin,!1);const i=a.length-1,o=a[i];a[i]=Wp[n](e.measureViewportBox(),window.getComputedStyle(e.current)),o!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=o),(s=this.removedTransforms)!=null&&s.length&&this.removedTransforms.forEach(([l,u])=>{e.getValue(l).set(u)}),this.resolveNoneKeyframes()}}function EUe(t,e,n){if(t==null)return[];if(t instanceof EventTarget)return[t];if(typeof t=="string"){const r=document.querySelectorAll(t);return r?Array.from(r):[]}return Array.from(t).filter(a=>a!=null)}const Gee=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function BUe(t){return NX(t)&&"offsetHeight"in t}const{schedule:O7,cancel:T0n}=VX(queueMicrotask,!1),nl={x:!1,y:!1};function qee(){return nl.x||nl.y}function IUe(t){return t==="x"||t==="y"?nl[t]?null:(nl[t]=!0,()=>{nl[t]=!1}):nl.x||nl.y?null:(nl.x=nl.y=!0,()=>{nl.x=nl.y=!1})}function zee(t,e){const n=EUe(t),a=new AbortController,r={passive:!0,...e,signal:a.signal};return[n,r,()=>a.abort()]}function Hee(t){return!(t.pointerType==="touch"||qee())}function DUe(t,e,n={}){const[a,r,i]=zee(t,n),o=s=>{if(!Hee(s))return;const{target:l}=s,u=e(l,s);if(typeof u!="function"||!l)return;const d=p=>{Hee(p)&&(u(p),l.removeEventListener("pointerleave",d))};l.addEventListener("pointerleave",d,r)};return a.forEach(s=>{s.addEventListener("pointerenter",o,r)}),i}const Uee=(t,e)=>e?t===e?!0:Uee(t,e.parentElement):!1,j7=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,QUe=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Yee(t){return QUe.has(t.tagName)||t.isContentEditable===!0}const bB=new WeakSet;function Wee(t){return e=>{e.key==="Enter"&&t(e)}}function G7(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const SUe=(t,e)=>{const n=t.currentTarget;if(!n)return;const a=Wee(()=>{if(bB.has(n))return;G7(n,"down");const r=Wee(()=>{G7(n,"up")}),i=()=>G7(n,"cancel");n.addEventListener("keyup",r,e),n.addEventListener("blur",i,e)});n.addEventListener("keydown",a,e),n.addEventListener("blur",()=>n.removeEventListener("keydown",a),e)};function Kee(t){return j7(t)&&!qee()}function TUe(t,e,n={}){const[a,r,i]=zee(t,n),o=s=>{const l=s.currentTarget;if(!Kee(s))return;bB.add(l);const u=e(l,s),d=(A,g)=>{window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",m),bB.has(l)&&bB.delete(l),Kee(A)&&typeof u=="function"&&u(A,{success:g})},p=A=>{d(A,l===window||l===document||n.useGlobalTarget||Uee(l,A.target))},m=A=>{d(A,!1)};window.addEventListener("pointerup",p,r),window.addEventListener("pointercancel",m,r)};return a.forEach(s=>{(n.useGlobalTarget?window:s).addEventListener("pointerdown",o,r),BUe(s)&&(s.addEventListener("focus",u=>SUe(u,r)),!Yee(s)&&!s.hasAttribute("tabindex")&&(s.tabIndex=0))}),i}function Zee(t){return NX(t)&&"ownerSVGElement"in t}function FUe(t){return Zee(t)&&t.tagName==="svg"}const LUe=[...Ree,Tr,Yp],NUe=t=>LUe.find(Mee(t)),Vee=()=>({translate:0,scale:1,origin:0,originPoint:0}),qf=()=>({x:Vee(),y:Vee()}),Jee=()=>({min:0,max:0}),Vr=()=>({x:Jee(),y:Jee()}),q7={current:null},Xee={current:!1},MUe=typeof window<"u";function RUe(){if(Xee.current=!0,!!MUe)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>q7.current=t.matches;t.addEventListener("change",e),e()}else q7.current=!1}const $Ue=new WeakMap;function yB(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function Ow(t){return typeof t=="string"||Array.isArray(t)}const z7=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],H7=["initial",...z7];function wB(t){return yB(t.animate)||H7.some(e=>Ow(t[e]))}function ete(t){return!!(wB(t)||t.variants)}function PUe(t,e,n){for(const a in e){const r=e[a],i=n[a];if(no(r))t.addValue(a,r);else if(no(i))t.addValue(a,Gf(r,{owner:t}));else if(i!==r)if(t.hasValue(a)){const o=t.getValue(a);o.liveStyle===!0?o.jump(r):o.hasAnimated||o.set(r)}else{const o=t.getStaticValue(a);t.addValue(a,Gf(o!==void 0?o:r,{owner:t}))}}for(const a in n)e[a]===void 0&&t.removeValue(a);return e}const tte=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let kB={};function nte(t){kB=t}function OUe(){return kB}class jUe{scrapeMotionValuesFromProps(e,n,a){return{}}constructor({parent:e,props:n,presenceContext:a,reducedMotionConfig:r,blockInitialAnimation:i,visualState:o},s={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=I7,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const m=Fo.now();this.renderScheduledAt<m&&(this.renderScheduledAt=m,Ma.render(this.render,!1,!0))};const{latestValues:l,renderState:u}=o;this.latestValues=l,this.baseTarget={...l},this.initialValues=n.initial?{...l}:{},this.renderState=u,this.parent=e,this.props=n,this.presenceContext=a,this.depth=e?e.depth+1:0,this.reducedMotionConfig=r,this.options=s,this.blockInitialAnimation=!!i,this.isControllingVariants=wB(n),this.isVariantNode=ete(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:d,...p}=this.scrapeMotionValuesFromProps(n,{},this);for(const m in p){const A=p[m];l[m]!==void 0&&no(A)&&A.set(l[m])}}mount(e){var n;this.current=e,$Ue.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((a,r)=>this.bindToMotionValue(r,a)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(Xee.current||RUe(),this.shouldReduceMotion=q7.current),(n=this.parent)==null||n.addChild(this),this.update(this.props,this.presenceContext)}unmount(){var e;this.projection&&this.projection.unmount(),Hp(this.notifyUpdate),Hp(this.render),this.valueSubscriptions.forEach(n=>n()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),(e=this.parent)==null||e.removeChild(this);for(const n in this.events)this.events[n].clear();for(const n in this.features){const a=this.features[n];a&&(a.unmount(),a.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,n){this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)();const a=Of.has(e);a&&this.onBindTransform&&this.onBindTransform();const r=n.on("change",o=>{this.latestValues[e]=o,this.props.onUpdate&&Ma.preRender(this.notifyUpdate),a&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let i;typeof window<"u"&&window.MotionCheckAppearSync&&(i=window.MotionCheckAppearSync(this,e,n)),this.valueSubscriptions.set(e,()=>{r(),i&&i(),n.owner&&n.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in kB){const n=kB[e];if(!n)continue;const{isEnabled:a,Feature:r}=n;if(!this.features[e]&&r&&a(this.props)&&(this.features[e]=new r(this)),this.features[e]){const i=this.features[e];i.isMounted?i.update():(i.mount(),i.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Vr()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,n){this.latestValues[e]=n}update(e,n){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let a=0;a<tte.length;a++){const r=tte[a];this.propEventSubscriptions[r]&&(this.propEventSubscriptions[r](),delete this.propEventSubscriptions[r]);const i="on"+r,o=e[i];o&&(this.propEventSubscriptions[r]=this.on(r,o))}this.prevMotionValues=PUe(this,this.scrapeMotionValuesFromProps(e,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(e),()=>n.variantChildren.delete(e)}addValue(e,n){const a=this.values.get(e);n!==a&&(a&&this.removeValue(e),this.bindToMotionValue(e,n),this.values.set(e,n),this.latestValues[e]=n.get())}removeValue(e){this.values.delete(e);const n=this.valueSubscriptions.get(e);n&&(n(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,n){if(this.props.values&&this.props.values[e])return this.props.values[e];let a=this.values.get(e);return a===void 0&&n!==void 0&&(a=Gf(n===null?void 0:n,{owner:this}),this.addValue(e,a)),a}readValue(e,n){let a=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return a!=null&&(typeof a=="string"&&(LX(a)||MX(a))?a=parseFloat(a):!NUe(a)&&Yp.test(n)&&(a=jee(e,n)),this.setBaseTarget(e,no(a)?a.get():a)),no(a)?a.get():a}setBaseTarget(e,n){this.baseTarget[e]=n}getBaseTarget(e){var i;const{initial:n}=this.props;let a;if(typeof n=="string"||typeof n=="object"){const o=F7(this.props,n,(i=this.presenceContext)==null?void 0:i.custom);o&&(a=o[e])}if(n&&a!==void 0)return a;const r=this.getBaseTargetFromProps(this.props,e);return r!==void 0&&!no(r)?r:this.initialValues[e]!==void 0&&a===void 0?void 0:this.baseTarget[e]}on(e,n){return this.events[e]||(this.events[e]=new t7),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}scheduleRenderMicrotask(){O7.render(this.render)}}class ate extends jUe{constructor(){super(...arguments),this.KeyframeResolver=xUe}sortInstanceNodePosition(e,n){return e.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(e,n){const a=e.style;return a?a[n]:void 0}removeValueFromRenderState(e,{vars:n,style:a}){delete n[e],delete a[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;no(e)&&(this.childSubscription=e.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}class Kp{constructor(e){this.isMounted=!1,this.node=e}update(){}}function rte({top:t,left:e,right:n,bottom:a}){return{x:{min:e,max:n},y:{min:t,max:a}}}function GUe({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function qUe(t,e){if(!e)return t;const n=e({x:t.left,y:t.top}),a=e({x:t.right,y:t.bottom});return{top:n.y,left:n.x,bottom:a.y,right:a.x}}function U7(t){return t===void 0||t===1}function Y7({scale:t,scaleX:e,scaleY:n}){return!U7(t)||!U7(e)||!U7(n)}function JA(t){return Y7(t)||ite(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function ite(t){return ote(t.x)||ote(t.y)}function ote(t){return t&&t!=="0%"}function vB(t,e,n){const a=t-n,r=e*a;return n+r}function ste(t,e,n,a,r){return r!==void 0&&(t=vB(t,r,a)),vB(t,n,a)+e}function W7(t,e=0,n=1,a,r){t.min=ste(t.min,e,n,a,r),t.max=ste(t.max,e,n,a,r)}function cte(t,{x:e,y:n}){W7(t.x,e.translate,e.scale,e.originPoint),W7(t.y,n.translate,n.scale,n.originPoint)}const lte=.999999999999,ute=1.0000000000001;function zUe(t,e,n,a=!1){const r=n.length;if(!r)return;e.x=e.y=1;let i,o;for(let s=0;s<r;s++){i=n[s],o=i.projectionDelta;const{visualElement:l}=i.options;l&&l.props.style&&l.props.style.display==="contents"||(a&&i.options.layoutScroll&&i.scroll&&i!==i.root&&Hf(t,{x:-i.scroll.offset.x,y:-i.scroll.offset.y}),o&&(e.x*=o.x.scale,e.y*=o.y.scale,cte(t,o)),a&&JA(i.latestValues)&&Hf(t,i.latestValues))}e.x<ute&&e.x>lte&&(e.x=1),e.y<ute&&e.y>lte&&(e.y=1)}function zf(t,e){t.min=t.min+e,t.max=t.max+e}function dte(t,e,n,a,r=.5){const i=or(t.min,t.max,r);W7(t,e,n,i,a)}function Hf(t,e){dte(t.x,e.x,e.scaleX,e.scale,e.originX),dte(t.y,e.y,e.scaleY,e.scale,e.originY)}function pte(t,e){return rte(qUe(t.getBoundingClientRect(),e))}function HUe(t,e,n){const a=pte(t,n),{scroll:r}=e;return r&&(zf(a.x,r.offset.x),zf(a.y,r.offset.y)),a}const UUe={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},YUe=Pf.length;function WUe(t,e,n){let a="",r=!0;for(let i=0;i<YUe;i++){const o=Pf[i],s=t[o];if(s===void 0)continue;let l=!0;if(typeof s=="number")l=s===(o.startsWith("scale")?1:0);else{const u=parseFloat(s);l=o.startsWith("scale")?u===1:u===0}if(!l||n){const u=Gee(s,P7[o]);if(!l){r=!1;const d=UUe[o]||o;a+=`${d}(${u}) `}n&&(e[o]=u)}}return a=a.trim(),n?a=n(e,r?"":a):r&&(a="none"),a}function K7(t,e,n){const{style:a,vars:r,transformOrigin:i}=t;let o=!1,s=!1;for(const l in e){const u=e[l];if(Of.has(l)){o=!0;continue}else if(XX(l)){r[l]=u;continue}else{const d=Gee(u,P7[l]);l.startsWith("origin")?(s=!0,i[l]=d):a[l]=d}}if(e.transform||(o||n?a.transform=WUe(e,t.transform,n):a.transform&&(a.transform="none")),s){const{originX:l="50%",originY:u="50%",originZ:d=0}=i;a.transformOrigin=`${l} ${u} ${d}`}}function mte(t,{style:e,vars:n},a,r){const i=t.style;let o;for(o in e)i[o]=e[o];r==null||r.applyProjectionStyles(i,a);for(o in n)i.setProperty(o,n[o])}function Ate(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const jw={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(Vt.test(t))t=parseFloat(t);else return t;const n=Ate(t,e.target.x),a=Ate(t,e.target.y);return`${n}% ${a}%`}},KUe={correct:(t,{treeScale:e,projectionDelta:n})=>{const a=t,r=Yp.parse(t);if(r.length>5)return a;const i=Yp.createTransformer(t),o=typeof r[0]!="number"?1:0,s=n.x.scale*e.x,l=n.y.scale*e.y;r[0+o]/=s,r[1+o]/=l;const u=or(s,l,.5);return typeof r[2+o]=="number"&&(r[2+o]/=u),typeof r[3+o]=="number"&&(r[3+o]/=u),i(r)}},Z7={borderRadius:{...jw,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:jw,borderTopRightRadius:jw,borderBottomLeftRadius:jw,borderBottomRightRadius:jw,boxShadow:KUe};function gte(t,{layout:e,layoutId:n}){return Of.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!Z7[t]||t==="opacity")}function V7(t,e,n){var o;const a=t.style,r=e==null?void 0:e.style,i={};if(!a)return i;for(const s in a)(no(a[s])||r&&no(r[s])||gte(s,t)||((o=n==null?void 0:n.getValue(s))==null?void 0:o.liveStyle)!==void 0)&&(i[s]=a[s]);return i}function ZUe(t){return window.getComputedStyle(t)}class VUe extends ate{constructor(){super(...arguments),this.type="html",this.renderInstance=mte}readValueFromInstance(e,n){var a;if(Of.has(n))return(a=this.projection)!=null&&a.isProjecting?C7(n):BHe(e,n);{const r=ZUe(e),i=(XX(n)?r.getPropertyValue(n):r[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:n}){return pte(e,n)}build(e,n,a){K7(e,n,a.transformTemplate)}scrapeMotionValuesFromProps(e,n,a){return V7(e,n,a)}}const JUe={offset:"stroke-dashoffset",array:"stroke-dasharray"},XUe={offset:"strokeDashoffset",array:"strokeDasharray"};function eYe(t,e,n=1,a=0,r=!0){t.pathLength=1;const i=r?JUe:XUe;t[i.offset]=`${-a}`,t[i.array]=`${e} ${n}`}const tYe=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function hte(t,{attrX:e,attrY:n,attrScale:a,pathLength:r,pathSpacing:i=1,pathOffset:o=0,...s},l,u,d){if(K7(t,s,u),l){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:p,style:m}=t;p.transform&&(m.transform=p.transform,delete p.transform),(m.transform||p.transformOrigin)&&(m.transformOrigin=p.transformOrigin??"50% 50%",delete p.transformOrigin),m.transform&&(m.transformBox=(d==null?void 0:d.transformBox)??"fill-box",delete p.transformBox);for(const A of tYe)p[A]!==void 0&&(m[A]=p[A],delete p[A]);e!==void 0&&(p.x=e),n!==void 0&&(p.y=n),a!==void 0&&(p.scale=a),r!==void 0&&eYe(p,r,i,o,!1)}const fte=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]),bte=t=>typeof t=="string"&&t.toLowerCase()==="svg";function nYe(t,e,n,a){mte(t,e,void 0,a);for(const r in e.attrs)t.setAttribute(fte.has(r)?r:M7(r),e.attrs[r])}function yte(t,e,n){const a=V7(t,e,n);for(const r in t)if(no(t[r])||no(e[r])){const i=Pf.indexOf(r)!==-1?"attr"+r.charAt(0).toUpperCase()+r.substring(1):r;a[i]=t[r]}return a}class aYe extends ate{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Vr}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(Of.has(n)){const a=Oee(n);return a&&a.default||0}return n=fte.has(n)?n:M7(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,a){return yte(e,n,a)}build(e,n,a){hte(e,n,this.isSVGTag,a.transformTemplate,a.style)}renderInstance(e,n,a,r){nYe(e,n,a,r)}mount(e){this.isSVGTag=bte(e.tagName),super.mount(e)}}const rYe=H7.length;function wte(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?wte(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<rYe;n++){const a=H7[n],r=t.props[a];(Ow(r)||r===!1)&&(e[a]=r)}return e}function kte(t,e){if(!Array.isArray(e))return!1;const n=e.length;if(n!==t.length)return!1;for(let a=0;a<n;a++)if(e[a]!==t[a])return!1;return!0}const iYe=[...z7].reverse(),oYe=z7.length;function sYe(t){return e=>Promise.all(e.map(({animation:n,options:a})=>hUe(t,n,a)))}function cYe(t){let e=sYe(t),n=vte(),a=!0;const r=l=>(u,d)=>{var m;const p=jf(t,d,l==="exit"?(m=t.presenceContext)==null?void 0:m.custom:void 0);if(p){const{transition:A,transitionEnd:g,...h}=p;u={...u,...h,...g}}return u};function i(l){e=l(t)}function o(l){const{props:u}=t,d=wte(t.parent)||{},p=[],m=new Set;let A={},g=1/0;for(let f=0;f<oYe;f++){const b=iYe[f],y=n[b],w=u[b]!==void 0?u[b]:d[b],k=Ow(w),C=b===l?y.isActive:null;C===!1&&(g=f);let x=w===d[b]&&w!==u[b]&&k;if(x&&a&&t.manuallyAnimateOnMount&&(x=!1),y.protectedKeys={...A},!y.isActive&&C===null||!w&&!y.prevProp||yB(w)||typeof w=="boolean")continue;const _=lYe(y.prevProp,w);let E=_||b===l&&y.isActive&&!x&&k||f>g&&k,D=!1;const Q=Array.isArray(w)?w:[w];let B=Q.reduce(r(b),{});C===!1&&(B={});const{prevResolvedValues:T={}}=y,N={...T,...B},I=L=>{E=!0,m.has(L)&&(D=!0,m.delete(L)),y.needsAnimating[L]=!0;const F=t.getValue(L);F&&(F.liveStyle=!1)};for(const L in N){const F=B[L],R=T[L];if(A.hasOwnProperty(L))continue;let $=!1;L7(F)&&L7(R)?$=!kte(F,R):$=F!==R,$?F!=null?I(L):m.add(L):F!==void 0&&m.has(L)?I(L):y.protectedKeys[L]=!0}y.prevProp=w,y.prevResolvedValues=B,y.isActive&&(A={...A,...B}),a&&t.blockInitialAnimation&&(E=!1);const S=x&&_;E&&(!S||D)&&p.push(...Q.map(L=>{const F={type:b};if(typeof L=="string"&&a&&!S&&t.manuallyAnimateOnMount&&t.parent){const{parent:R}=t,$=jf(R,L);if(R.enteringChildren&&$){const{delayChildren:P}=$.transition||{};F.delay=Iee(R.enteringChildren,t,P)}}return{animation:L,options:F}}))}if(m.size){const f={};if(typeof u.initial!="boolean"){const b=jf(t,Array.isArray(u.initial)?u.initial[0]:u.initial);b&&b.transition&&(f.transition=b.transition)}m.forEach(b=>{const y=t.getBaseTarget(b),w=t.getValue(b);w&&(w.liveStyle=!0),f[b]=y??null}),p.push({animation:f})}let h=!!p.length;return a&&(u.initial===!1||u.initial===u.animate)&&!t.manuallyAnimateOnMount&&(h=!1),a=!1,h?e(p):Promise.resolve()}function s(l,u){var p;if(n[l].isActive===u)return Promise.resolve();(p=t.variantChildren)==null||p.forEach(m=>{var A;return(A=m.animationState)==null?void 0:A.setActive(l,u)}),n[l].isActive=u;const d=o(l);for(const m in n)n[m].protectedKeys={};return d}return{animateChanges:o,setActive:s,setAnimateFunction:i,getState:()=>n,reset:()=>{n=vte()}}}function lYe(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!kte(e,t):!1}function XA(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function vte(){return{animate:XA(!0),whileInView:XA(),whileHover:XA(),whileTap:XA(),whileDrag:XA(),whileFocus:XA(),exit:XA()}}function Cte(t,e){t.min=e.min,t.max=e.max}function al(t,e){Cte(t.x,e.x),Cte(t.y,e.y)}function _te(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}const xte=1e-4,uYe=1-xte,dYe=1+xte,Ete=.01,pYe=0-Ete,mYe=0+Ete;function Lo(t){return t.max-t.min}function AYe(t,e,n){return Math.abs(t-e)<=n}function Bte(t,e,n,a=.5){t.origin=a,t.originPoint=or(e.min,e.max,t.origin),t.scale=Lo(n)/Lo(e),t.translate=or(n.min,n.max,t.origin)-t.originPoint,(t.scale>=uYe&&t.scale<=dYe||isNaN(t.scale))&&(t.scale=1),(t.translate>=pYe&&t.translate<=mYe||isNaN(t.translate))&&(t.translate=0)}function Gw(t,e,n,a){Bte(t.x,e.x,n.x,a?a.originX:void 0),Bte(t.y,e.y,n.y,a?a.originY:void 0)}function Ite(t,e,n){t.min=n.min+e.min,t.max=t.min+Lo(e)}function gYe(t,e,n){Ite(t.x,e.x,n.x),Ite(t.y,e.y,n.y)}function Dte(t,e,n){t.min=e.min-n.min,t.max=t.min+Lo(e)}function CB(t,e,n){Dte(t.x,e.x,n.x),Dte(t.y,e.y,n.y)}function Qte(t,e,n,a,r){return t-=e,t=vB(t,1/n,a),r!==void 0&&(t=vB(t,1/r,a)),t}function hYe(t,e=0,n=1,a=.5,r,i=t,o=t){if(au.test(e)&&(e=parseFloat(e),e=or(o.min,o.max,e/100)-o.min),typeof e!="number")return;let s=or(i.min,i.max,a);t===i&&(s-=e),t.min=Qte(t.min,e,n,s,r),t.max=Qte(t.max,e,n,s,r)}function Ste(t,e,[n,a,r],i,o){hYe(t,e[n],e[a],e[r],e.scale,i,o)}const fYe=["x","scaleX","originX"],bYe=["y","scaleY","originY"];function Tte(t,e,n,a){Ste(t.x,e,fYe,n?n.x:void 0,a?a.x:void 0),Ste(t.y,e,bYe,n?n.y:void 0,a?a.y:void 0)}function Fte(t){return t.translate===0&&t.scale===1}function Lte(t){return Fte(t.x)&&Fte(t.y)}function Nte(t,e){return t.min===e.min&&t.max===e.max}function yYe(t,e){return Nte(t.x,e.x)&&Nte(t.y,e.y)}function Mte(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function Rte(t,e){return Mte(t.x,e.x)&&Mte(t.y,e.y)}function $te(t){return Lo(t.x)/Lo(t.y)}function Pte(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}function fc(t){return[t("x"),t("y")]}function wYe(t,e,n){let a="";const r=t.x.translate/e.x,i=t.y.translate/e.y,o=(n==null?void 0:n.z)||0;if((r||i||o)&&(a=`translate3d(${r}px, ${i}px, ${o}px) `),(e.x!==1||e.y!==1)&&(a+=`scale(${1/e.x}, ${1/e.y}) `),n){const{transformPerspective:u,rotate:d,rotateX:p,rotateY:m,skewX:A,skewY:g}=n;u&&(a=`perspective(${u}px) ${a}`),d&&(a+=`rotate(${d}deg) `),p&&(a+=`rotateX(${p}deg) `),m&&(a+=`rotateY(${m}deg) `),A&&(a+=`skewX(${A}deg) `),g&&(a+=`skewY(${g}deg) `)}const s=t.x.scale*e.x,l=t.y.scale*e.y;return(s!==1||l!==1)&&(a+=`scale(${s}, ${l})`),a||"none"}const Ote=["TopLeft","TopRight","BottomLeft","BottomRight"],kYe=Ote.length,jte=t=>typeof t=="string"?parseFloat(t):t,Gte=t=>typeof t=="number"||Vt.test(t);function vYe(t,e,n,a,r,i){r?(t.opacity=or(0,n.opacity??1,CYe(a)),t.opacityExit=or(e.opacity??1,0,_Ye(a))):i&&(t.opacity=or(e.opacity??1,n.opacity??1,a));for(let o=0;o<kYe;o++){const s=`border${Ote[o]}Radius`;let l=qte(e,s),u=qte(n,s);if(l===void 0&&u===void 0)continue;l||(l=0),u||(u=0),l===0||u===0||Gte(l)===Gte(u)?(t[s]=Math.max(or(jte(l),jte(u),a),0),(au.test(u)||au.test(l))&&(t[s]+="%")):t[s]=u}(e.rotate||n.rotate)&&(t.rotate=or(e.rotate||0,n.rotate||0,a))}function qte(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const CYe=zte(0,.5,zX),_Ye=zte(.5,.95,gc);function zte(t,e,n){return a=>a<t?0:a>e?1:n(Tw(t,e,a))}function xYe(t,e,n){const a=no(t)?t:Gf(t);return a.start(T7("",a,e,n)),a.animation}function qw(t,e,n,a={passive:!0}){return t.addEventListener(e,n,a),()=>t.removeEventListener(e,n)}const EYe=(t,e)=>t.depth-e.depth;class BYe{constructor(){this.children=[],this.isDirty=!1}add(e){V5(this.children,e),this.isDirty=!0}remove(e){J5(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(EYe),this.isDirty=!1,this.children.forEach(e)}}function IYe(t,e){const n=Fo.now(),a=({timestamp:r})=>{const i=r-n;i>=e&&(Hp(a),t(i-e))};return Ma.setup(a,!0),()=>Hp(a)}function _B(t){return no(t)?t.get():t}class DYe{constructor(){this.members=[]}add(e){V5(this.members,e),e.scheduleRender()}remove(e){if(J5(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(e){const n=this.members.findIndex(r=>e===r);if(n===0)return!1;let a;for(let r=n;r>=0;r--){const i=this.members[r];if(i.isPresent!==!1){a=i;break}}return a?(this.promote(a),!0):!1}promote(e,n){const a=this.lead;if(e!==a&&(this.prevLead=a,this.lead=e,e.show(),a)){a.instance&&a.scheduleRender(),e.scheduleRender();const r=a.options.layoutDependency,i=e.options.layoutDependency;r!==void 0&&i!==void 0&&r===i||(e.resumeFrom=a,n&&(e.resumeFrom.preserveOpacity=!0),a.snapshot&&(e.snapshot=a.snapshot,e.snapshot.latestValues=a.animationValues||a.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0));const{crossfade:s}=e.options;s===!1&&a.hide()}}exitAnimationComplete(){this.members.forEach(e=>{const{options:n,resumingFrom:a}=e;n.onExitComplete&&n.onExitComplete(),a&&a.options.onExitComplete&&a.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}const xB={hasAnimatedSinceResize:!0,hasEverUpdated:!1},J7=["","X","Y","Z"],QYe=1e3;let SYe=0;function X7(t,e,n,a){const{latestValues:r}=e;r[t]&&(n[t]=r[t],e.setStaticValue(t,0),a&&(a[t]=0))}function Hte(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=Lee(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:r,layoutId:i}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",Ma,!(r||i))}const{parent:a}=t;a&&!a.hasCheckedOptimisedAppear&&Hte(a)}function Ute({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:a,resetTransform:r}){return class{constructor(o={},s=e==null?void 0:e()){this.id=SYe++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(LYe),this.nodes.forEach($Ye),this.nodes.forEach(PYe),this.nodes.forEach(NYe)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=o,this.root=s?s.root||s:this,this.path=s?[...s.path,s]:[],this.parent=s,this.depth=s?s.depth+1:0;for(let l=0;l<this.path.length;l++)this.path[l].shouldResetTransform=!0;this.root===this&&(this.nodes=new BYe)}addEventListener(o,s){return this.eventHandlers.has(o)||this.eventHandlers.set(o,new t7),this.eventHandlers.get(o).add(s)}notifyListeners(o,...s){const l=this.eventHandlers.get(o);l&&l.notify(...s)}hasListeners(o){return this.eventHandlers.has(o)}mount(o){if(this.instance)return;this.isSVG=Zee(o)&&!FUe(o),this.instance=o;const{layoutId:s,layout:l,visualElement:u}=this.options;if(u&&!u.current&&u.mount(o),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(l||s)&&(this.isLayoutDirty=!0),t){let d,p=0;const m=()=>this.root.updateBlockedByResize=!1;Ma.read(()=>{p=window.innerWidth}),t(o,()=>{const A=window.innerWidth;A!==p&&(p=A,this.root.updateBlockedByResize=!0,d&&d(),d=IYe(m,250),xB.hasAnimatedSinceResize&&(xB.hasAnimatedSinceResize=!1,this.nodes.forEach(Kte)))})}s&&this.root.registerSharedNode(s,this),this.options.animate!==!1&&u&&(s||l)&&this.addEventListener("didUpdate",({delta:d,hasLayoutChanged:p,hasRelativeLayoutChanged:m,layout:A})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const g=this.options.transition||u.getDefaultTransition()||zYe,{onLayoutAnimationStart:h,onLayoutAnimationComplete:f}=u.getProps(),b=!this.targetLayout||!Rte(this.targetLayout,A),y=!p&&m;if(this.options.layoutRoot||this.resumeFrom||y||p&&(b||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const w={...S7(g,"layout"),onPlay:h,onComplete:f};(u.shouldReduceMotion||this.options.layoutRoot)&&(w.delay=0,w.type=!1),this.startAnimation(w),this.setAnimationOrigin(d,y)}else p||Kte(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=A})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const o=this.getStack();o&&o.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Hp(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(OYe),this.animationId++)}getTransformTemplate(){const{visualElement:o}=this.options;return o&&o.getProps().transformTemplate}willUpdate(o=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&Hte(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let d=0;d<this.path.length;d++){const p=this.path[d];p.shouldResetTransform=!0,p.updateScroll("snapshot"),p.options.layoutRoot&&p.willUpdate(!1)}const{layoutId:s,layout:l}=this.options;if(s===void 0&&!l)return;const u=this.getTransformTemplate();this.prevTransformTemplateValue=u?u(this.latestValues,""):void 0,this.updateSnapshot(),o&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(Yte);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Wte);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(RYe),this.nodes.forEach(TYe),this.nodes.forEach(FYe)):this.nodes.forEach(Wte),this.clearAllSnapshots();const s=Fo.now();Li.delta=tu(0,1e3/60,s-Li.timestamp),Li.timestamp=s,Li.isProcessing=!0,r7.update.process(Li),r7.preRender.process(Li),r7.render.process(Li),Li.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,O7.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(MYe),this.sharedNodes.forEach(jYe)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,Ma.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){Ma.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Lo(this.snapshot.measuredBox.x)&&!Lo(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let l=0;l<this.path.length;l++)this.path[l].updateScroll();const o=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected=Vr(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:s}=this.options;s&&s.notify("LayoutMeasure",this.layout.layoutBox,o?o.layoutBox:void 0)}updateScroll(o="measure"){let s=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===o&&(s=!1),s&&this.instance){const l=a(this.instance);this.scroll={animationId:this.root.animationId,phase:o,isRoot:l,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:l}}}resetTransform(){if(!r)return;const o=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,s=this.projectionDelta&&!Lte(this.projectionDelta),l=this.getTransformTemplate(),u=l?l(this.latestValues,""):void 0,d=u!==this.prevTransformTemplateValue;o&&this.instance&&(s||JA(this.latestValues)||d)&&(r(this.instance,u),this.shouldResetTransform=!1,this.scheduleRender())}measure(o=!0){const s=this.measurePageBox();let l=this.removeElementScroll(s);return o&&(l=this.removeTransform(l)),HYe(l),{animationId:this.root.animationId,measuredBox:s,layoutBox:l,latestValues:{},source:this.id}}measurePageBox(){var u;const{visualElement:o}=this.options;if(!o)return Vr();const s=o.measureViewportBox();if(!(((u=this.scroll)==null?void 0:u.wasRoot)||this.path.some(UYe))){const{scroll:d}=this.root;d&&(zf(s.x,d.offset.x),zf(s.y,d.offset.y))}return s}removeElementScroll(o){var l;const s=Vr();if(al(s,o),(l=this.scroll)!=null&&l.wasRoot)return s;for(let u=0;u<this.path.length;u++){const d=this.path[u],{scroll:p,options:m}=d;d!==this.root&&p&&m.layoutScroll&&(p.wasRoot&&al(s,o),zf(s.x,p.offset.x),zf(s.y,p.offset.y))}return s}applyTransform(o,s=!1){const l=Vr();al(l,o);for(let u=0;u<this.path.length;u++){const d=this.path[u];!s&&d.options.layoutScroll&&d.scroll&&d!==d.root&&Hf(l,{x:-d.scroll.offset.x,y:-d.scroll.offset.y}),JA(d.latestValues)&&Hf(l,d.latestValues)}return JA(this.latestValues)&&Hf(l,this.latestValues),l}removeTransform(o){const s=Vr();al(s,o);for(let l=0;l<this.path.length;l++){const u=this.path[l];if(!u.instance||!JA(u.latestValues))continue;Y7(u.latestValues)&&u.updateSnapshot();const d=Vr(),p=u.measurePageBox();al(d,p),Tte(s,u.latestValues,u.snapshot?u.snapshot.layoutBox:void 0,d)}return JA(this.latestValues)&&Tte(s,this.latestValues),s}setTargetDelta(o){this.targetDelta=o,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(o){this.options={...this.options,...o,crossfade:o.crossfade!==void 0?o.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==Li.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(o=!1){var A;const s=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=s.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=s.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=s.isSharedProjectionDirty);const l=!!this.resumingFrom||this!==s;if(!(o||l&&this.isSharedProjectionDirty||this.isProjectionDirty||(A=this.parent)!=null&&A.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:d,layoutId:p}=this.options;if(!this.layout||!(d||p))return;this.resolvedRelativeTargetAt=Li.timestamp;const m=this.getClosestProjectingParent();m&&this.linkedParentVersion!==m.layoutVersion&&!m.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(m&&m.layout?this.createRelativeTarget(m,this.layout.layoutBox,m.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=Vr(),this.targetWithTransforms=Vr()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),gYe(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):al(this.target,this.layout.layoutBox),cte(this.target,this.targetDelta)):al(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,m&&!!m.resumingFrom==!!this.resumingFrom&&!m.options.layoutScroll&&m.target&&this.animationProgress!==1?this.createRelativeTarget(m,this.target,m.target):this.relativeParent=this.relativeTarget=void 0))}getClosestProjectingParent(){if(!(!this.parent||Y7(this.parent.latestValues)||ite(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(o,s,l){this.relativeParent=o,this.linkedParentVersion=o.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Vr(),this.relativeTargetOrigin=Vr(),CB(this.relativeTargetOrigin,s,l),al(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){var g;const o=this.getLead(),s=!!this.resumingFrom||this!==o;let l=!0;if((this.isProjectionDirty||(g=this.parent)!=null&&g.isProjectionDirty)&&(l=!1),s&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(l=!1),this.resolvedRelativeTargetAt===Li.timestamp&&(l=!1),l)return;const{layout:u,layoutId:d}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(u||d))return;al(this.layoutCorrected,this.layout.layoutBox);const p=this.treeScale.x,m=this.treeScale.y;zUe(this.layoutCorrected,this.treeScale,this.path,s),o.layout&&!o.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(o.target=o.layout.layoutBox,o.targetWithTransforms=Vr());const{target:A}=o;if(!A){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(_te(this.prevProjectionDelta.x,this.projectionDelta.x),_te(this.prevProjectionDelta.y,this.projectionDelta.y)),Gw(this.projectionDelta,this.layoutCorrected,A,this.latestValues),(this.treeScale.x!==p||this.treeScale.y!==m||!Pte(this.projectionDelta.x,this.prevProjectionDelta.x)||!Pte(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",A))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(o=!0){var s;if((s=this.options.visualElement)==null||s.scheduleRender(),o){const l=this.getStack();l&&l.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=qf(),this.projectionDelta=qf(),this.projectionDeltaWithTransform=qf()}setAnimationOrigin(o,s=!1){const l=this.snapshot,u=l?l.latestValues:{},d={...this.latestValues},p=qf();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!s;const m=Vr(),A=l?l.source:void 0,g=this.layout?this.layout.source:void 0,h=A!==g,f=this.getStack(),b=!f||f.members.length<=1,y=!!(h&&!b&&this.options.crossfade===!0&&!this.path.some(qYe));this.animationProgress=0;let w;this.mixTargetDelta=k=>{const C=k/1e3;Zte(p.x,o.x,C),Zte(p.y,o.y,C),this.setTargetDelta(p),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(CB(m,this.layout.layoutBox,this.relativeParent.layout.layoutBox),GYe(this.relativeTarget,this.relativeTargetOrigin,m,C),w&&yYe(this.relativeTarget,w)&&(this.isProjectionDirty=!1),w||(w=Vr()),al(w,this.relativeTarget)),h&&(this.animationValues=d,vYe(d,u,this.latestValues,C,y,b)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=C},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(o){var s,l,u;this.notifyListeners("animationStart"),(s=this.currentAnimation)==null||s.stop(),(u=(l=this.resumingFrom)==null?void 0:l.currentAnimation)==null||u.stop(),this.pendingAnimation&&(Hp(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=Ma.update(()=>{xB.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=Gf(0)),this.currentAnimation=xYe(this.motionValue,[0,1e3],{...o,velocity:0,isSync:!0,onUpdate:d=>{this.mixTargetDelta(d),o.onUpdate&&o.onUpdate(d)},onStop:()=>{},onComplete:()=>{o.onComplete&&o.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const o=this.getStack();o&&o.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(QYe),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const o=this.getLead();let{targetWithTransforms:s,target:l,layout:u,latestValues:d}=o;if(!(!s||!l||!u)){if(this!==o&&this.layout&&u&&tne(this.options.animationType,this.layout.layoutBox,u.layoutBox)){l=this.target||Vr();const p=Lo(this.layout.layoutBox.x);l.x.min=o.target.x.min,l.x.max=l.x.min+p;const m=Lo(this.layout.layoutBox.y);l.y.min=o.target.y.min,l.y.max=l.y.min+m}al(s,l),Hf(s,d),Gw(this.projectionDeltaWithTransform,this.layoutCorrected,s,d)}}registerSharedNode(o,s){this.sharedNodes.has(o)||this.sharedNodes.set(o,new DYe),this.sharedNodes.get(o).add(s);const u=s.options.initialPromotionConfig;s.promote({transition:u?u.transition:void 0,preserveFollowOpacity:u&&u.shouldPreserveFollowOpacity?u.shouldPreserveFollowOpacity(s):void 0})}isLead(){const o=this.getStack();return o?o.lead===this:!0}getLead(){var s;const{layoutId:o}=this.options;return o?((s=this.getStack())==null?void 0:s.lead)||this:this}getPrevLead(){var s;const{layoutId:o}=this.options;return o?(s=this.getStack())==null?void 0:s.prevLead:void 0}getStack(){const{layoutId:o}=this.options;if(o)return this.root.sharedNodes.get(o)}promote({needsReset:o,transition:s,preserveFollowOpacity:l}={}){const u=this.getStack();u&&u.promote(this,l),o&&(this.projectionDelta=void 0,this.needsReset=!0),s&&this.setOptions({transition:s})}relegate(){const o=this.getStack();return o?o.relegate(this):!1}resetSkewAndRotation(){const{visualElement:o}=this.options;if(!o)return;let s=!1;const{latestValues:l}=o;if((l.z||l.rotate||l.rotateX||l.rotateY||l.rotateZ||l.skewX||l.skewY)&&(s=!0),!s)return;const u={};l.z&&X7("z",o,u,this.animationValues);for(let d=0;d<J7.length;d++)X7(`rotate${J7[d]}`,o,u,this.animationValues),X7(`skew${J7[d]}`,o,u,this.animationValues);o.render();for(const d in u)o.setStaticValue(d,u[d]),this.animationValues&&(this.animationValues[d]=u[d]);o.scheduleRender()}applyProjectionStyles(o,s){if(!this.instance||this.isSVG)return;if(!this.isVisible){o.visibility="hidden";return}const l=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,o.visibility="",o.opacity="",o.pointerEvents=_B(s==null?void 0:s.pointerEvents)||"",o.transform=l?l(this.latestValues,""):"none";return}const u=this.getLead();if(!this.projectionDelta||!this.layout||!u.target){this.options.layoutId&&(o.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,o.pointerEvents=_B(s==null?void 0:s.pointerEvents)||""),this.hasProjected&&!JA(this.latestValues)&&(o.transform=l?l({},""):"none",this.hasProjected=!1);return}o.visibility="";const d=u.animationValues||u.latestValues;this.applyTransformsToTarget();let p=wYe(this.projectionDeltaWithTransform,this.treeScale,d);l&&(p=l(d,p)),o.transform=p;const{x:m,y:A}=this.projectionDelta;o.transformOrigin=`${m.origin*100}% ${A.origin*100}% 0`,u.animationValues?o.opacity=u===this?d.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:d.opacityExit:o.opacity=u===this?d.opacity!==void 0?d.opacity:"":d.opacityExit!==void 0?d.opacityExit:0;for(const g in Z7){if(d[g]===void 0)continue;const{correct:h,applyTo:f,isCSSVariable:b}=Z7[g],y=p==="none"?d[g]:h(d[g],u);if(f){const w=f.length;for(let k=0;k<w;k++)o[f[k]]=y}else b?this.options.visualElement.renderState.vars[g]=y:o[g]=y}this.options.layoutId&&(o.pointerEvents=u===this?_B(s==null?void 0:s.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(o=>{var s;return(s=o.currentAnimation)==null?void 0:s.stop()}),this.root.nodes.forEach(Yte),this.root.sharedNodes.clear()}}}function TYe(t){t.updateLayout()}function FYe(t){var n;const e=((n=t.resumeFrom)==null?void 0:n.snapshot)||t.snapshot;if(t.isLead()&&t.layout&&e&&t.hasListeners("didUpdate")){const{layoutBox:a,measuredBox:r}=t.layout,{animationType:i}=t.options,o=e.source!==t.layout.source;i==="size"?fc(p=>{const m=o?e.measuredBox[p]:e.layoutBox[p],A=Lo(m);m.min=a[p].min,m.max=m.min+A}):tne(i,e.layoutBox,a)&&fc(p=>{const m=o?e.measuredBox[p]:e.layoutBox[p],A=Lo(a[p]);m.max=m.min+A,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[p].max=t.relativeTarget[p].min+A)});const s=qf();Gw(s,a,e.layoutBox);const l=qf();o?Gw(l,t.applyTransform(r,!0),e.measuredBox):Gw(l,a,e.layoutBox);const u=!Lte(s);let d=!1;if(!t.resumeFrom){const p=t.getClosestProjectingParent();if(p&&!p.resumeFrom){const{snapshot:m,layout:A}=p;if(m&&A){const g=Vr();CB(g,e.layoutBox,m.layoutBox);const h=Vr();CB(h,a,A.layoutBox),Rte(g,h)||(d=!0),p.options.layoutRoot&&(t.relativeTarget=h,t.relativeTargetOrigin=g,t.relativeParent=p)}}}t.notifyListeners("didUpdate",{layout:a,snapshot:e,delta:l,layoutDelta:s,hasLayoutChanged:u,hasRelativeLayoutChanged:d})}else if(t.isLead()){const{onExitComplete:a}=t.options;a&&a()}t.options.transition=void 0}function LYe(t){t.parent&&(t.isProjecting()||(t.isProjectionDirty=t.parent.isProjectionDirty),t.isSharedProjectionDirty||(t.isSharedProjectionDirty=!!(t.isProjectionDirty||t.parent.isProjectionDirty||t.parent.isSharedProjectionDirty)),t.isTransformDirty||(t.isTransformDirty=t.parent.isTransformDirty))}function NYe(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function MYe(t){t.clearSnapshot()}function Yte(t){t.clearMeasurements()}function Wte(t){t.isLayoutDirty=!1}function RYe(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function Kte(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function $Ye(t){t.resolveTargetDelta()}function PYe(t){t.calcProjection()}function OYe(t){t.resetSkewAndRotation()}function jYe(t){t.removeLeadSnapshot()}function Zte(t,e,n){t.translate=or(e.translate,0,n),t.scale=or(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function Vte(t,e,n,a){t.min=or(e.min,n.min,a),t.max=or(e.max,n.max,a)}function GYe(t,e,n,a){Vte(t.x,e.x,n.x,a),Vte(t.y,e.y,n.y,a)}function qYe(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const zYe={duration:.45,ease:[.4,0,.1,1]},Jte=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),Xte=Jte("applewebkit/")&&!Jte("chrome/")?Math.round:gc;function ene(t){t.min=Xte(t.min),t.max=Xte(t.max)}function HYe(t){ene(t.x),ene(t.y)}function tne(t,e,n){return t==="position"||t==="preserve-aspect"&&!AYe($te(e),$te(n),.2)}function UYe(t){var e;return t!==t.root&&((e=t.scroll)==null?void 0:e.wasRoot)}const YYe=Ute({attachResizeListener:(t,e)=>qw(t,"resize",e),measureScroll:()=>{var t,e;return{x:document.documentElement.scrollLeft||((t=document.body)==null?void 0:t.scrollLeft)||0,y:document.documentElement.scrollTop||((e=document.body)==null?void 0:e.scrollTop)||0}},checkIsScrollRoot:()=>!0}),eT={current:void 0},nne=Ute({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!eT.current){const t=new YYe({});t.mount(window),t.setOptions({layoutScroll:!0}),eT.current=t}return eT.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),ane=he.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function WYe(t=!0){const e=he.useContext(Z5);if(e===null)return[!0,null];const{isPresent:n,onExitComplete:a,register:r}=e,i=he.useId();he.useEffect(()=>{if(t)return r(i)},[t]);const o=he.useCallback(()=>t&&a&&a(i),[i,a,t]);return!n&&a?[!1,o]:[!0]}const rne=he.createContext({strict:!1}),ine={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let one=!1;function KYe(){if(one)return;const t={};for(const e in ine)t[e]={isEnabled:n=>ine[e].some(a=>!!n[a])};nte(t),one=!0}function sne(){return KYe(),OUe()}function ZYe(t){const e=sne();for(const n in t)e[n]={...e[n],...t[n]};nte(e)}const VYe=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function EB(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||VYe.has(t)}let cne=t=>!EB(t);function JYe(t){typeof t=="function"&&(cne=e=>e.startsWith("on")?!EB(e):t(e))}try{JYe(require("@emotion/is-prop-valid").default)}catch{}function XYe(t,e,n){const a={};for(const r in t)r==="values"&&typeof t.values=="object"||(cne(r)||n===!0&&EB(r)||!e&&!EB(r)||t.draggable&&r.startsWith("onDrag"))&&(a[r]=t[r]);return a}const BB=he.createContext({});function eWe(t,e){if(wB(t)){const{initial:n,animate:a}=t;return{initial:n===!1||Ow(n)?n:void 0,animate:Ow(a)?a:void 0}}return t.inherit!==!1?e:{}}function tWe(t){const{initial:e,animate:n}=eWe(t,he.useContext(BB));return he.useMemo(()=>({initial:e,animate:n}),[lne(e),lne(n)])}function lne(t){return Array.isArray(t)?t.join(" "):t}const tT=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function une(t,e,n){for(const a in e)!no(e[a])&&!gte(a,n)&&(t[a]=e[a])}function nWe({transformTemplate:t},e){return he.useMemo(()=>{const n=tT();return K7(n,e,t),Object.assign({},n.vars,n.style)},[e])}function aWe(t,e){const n=t.style||{},a={};return une(a,n,t),Object.assign(a,nWe(t,e)),a}function rWe(t,e){const n={},a=aWe(t,e);return t.drag&&t.dragListener!==!1&&(n.draggable=!1,a.userSelect=a.WebkitUserSelect=a.WebkitTouchCallout="none",a.touchAction=t.drag===!0?"none":`pan-${t.drag==="x"?"y":"x"}`),t.tabIndex===void 0&&(t.onTap||t.onTapStart||t.whileTap)&&(n.tabIndex=0),n.style=a,n}const dne=()=>({...tT(),attrs:{}});function iWe(t,e,n,a){const r=he.useMemo(()=>{const i=dne();return hte(i,e,bte(a),t.transformTemplate,t.style),{...i.attrs,style:{...i.style}}},[e]);if(t.style){const i={};une(i,t.style,t),r.style={...i,...r.style}}return r}const oWe=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function nT(t){return typeof t!="string"||t.includes("-")?!1:!!(oWe.indexOf(t)>-1||/[A-Z]/u.test(t))}function sWe(t,e,n,{latestValues:a},r,i=!1,o){const l=(o??nT(t)?iWe:rWe)(e,a,r,t),u=XYe(e,typeof t=="string",i),d=t!==he.Fragment?{...u,...l,ref:n}:{},{children:p}=e,m=he.useMemo(()=>no(p)?p.get():p,[p]);return he.createElement(t,{...d,children:m})}function cWe({scrapeMotionValuesFromProps:t,createRenderState:e},n,a,r){return{latestValues:lWe(n,a,r,t),renderState:e()}}function lWe(t,e,n,a){const r={},i=a(t,{});for(const m in i)r[m]=_B(i[m]);let{initial:o,animate:s}=t;const l=wB(t),u=ete(t);e&&u&&!l&&t.inherit!==!1&&(o===void 0&&(o=e.initial),s===void 0&&(s=e.animate));let d=n?n.initial===!1:!1;d=d||o===!1;const p=d?s:o;if(p&&typeof p!="boolean"&&!yB(p)){const m=Array.isArray(p)?p:[p];for(let A=0;A<m.length;A++){const g=F7(t,m[A]);if(g){const{transitionEnd:h,transition:f,...b}=g;for(const y in b){let w=b[y];if(Array.isArray(w)){const k=d?w.length-1:0;w=w[k]}w!==null&&(r[y]=w)}for(const y in h)r[y]=h[y]}}}return r}const pne=t=>(e,n)=>{const a=he.useContext(BB),r=he.useContext(Z5),i=()=>cWe(t,e,a,r);return n?i():_ze(i)},uWe=pne({scrapeMotionValuesFromProps:V7,createRenderState:tT}),dWe=pne({scrapeMotionValuesFromProps:yte,createRenderState:dne}),pWe=Symbol.for("motionComponentSymbol");function mWe(t,e,n){const a=he.useRef(n);he.useInsertionEffect(()=>{a.current=n});const r=he.useRef(null);return he.useCallback(i=>{var s;i&&((s=t.onMount)==null||s.call(t,i)),e&&(i?e.mount(i):e.unmount());const o=a.current;if(typeof o=="function")if(i){const l=o(i);typeof l=="function"&&(r.current=l)}else r.current?(r.current(),r.current=null):o(i);else o&&(o.current=i)},[e])}const mne=he.createContext({});function zw(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function AWe(t,e,n,a,r,i){var b,y;const{visualElement:o}=he.useContext(BB),s=he.useContext(rne),l=he.useContext(Z5),u=he.useContext(ane).reducedMotion,d=he.useRef(null),p=he.useRef(!1);a=a||s.renderer,!d.current&&a&&(d.current=a(t,{visualState:e,parent:o,props:n,presenceContext:l,blockInitialAnimation:l?l.initial===!1:!1,reducedMotionConfig:u,isSVG:i}),p.current&&d.current&&(d.current.manuallyAnimateOnMount=!0));const m=d.current,A=he.useContext(mne);m&&!m.projection&&r&&(m.type==="html"||m.type==="svg")&&gWe(d.current,n,r,A);const g=he.useRef(!1);he.useInsertionEffect(()=>{m&&g.current&&m.update(n,l)});const h=n[Fee],f=he.useRef(!!h&&!((b=window.MotionHandoffIsComplete)!=null&&b.call(window,h))&&((y=window.MotionHasOptimisedAnimation)==null?void 0:y.call(window,h)));return xze(()=>{p.current=!0,m&&(g.current=!0,window.MotionIsMounted=!0,m.updateFeatures(),m.scheduleRenderMicrotask(),f.current&&m.animationState&&m.animationState.animateChanges())}),he.useEffect(()=>{m&&(!f.current&&m.animationState&&m.animationState.animateChanges(),f.current&&(queueMicrotask(()=>{var w;(w=window.MotionHandoffMarkAsComplete)==null||w.call(window,h)}),f.current=!1),m.enteringChildren=void 0)}),m}function gWe(t,e,n,a){const{layoutId:r,layout:i,drag:o,dragConstraints:s,layoutScroll:l,layoutRoot:u,layoutCrossfade:d}=e;t.projection=new n(t.latestValues,e["data-framer-portal-id"]?void 0:Ane(t.parent)),t.projection.setOptions({layoutId:r,layout:i,alwaysMeasureLayout:!!o||s&&zw(s),visualElement:t,animationType:typeof i=="string"?i:"both",initialPromotionConfig:a,crossfade:d,layoutScroll:l,layoutRoot:u})}function Ane(t){if(t)return t.options.allowProjection!==!1?t.projection:Ane(t.parent)}function aT(t,{forwardMotionProps:e=!1,type:n}={},a,r){a&&ZYe(a);const i=n?n==="svg":nT(t),o=i?dWe:uWe;function s(u,d){let p;const m={...he.useContext(ane),...u,layoutId:hWe(u)},{isStatic:A}=m,g=tWe(u),h=o(u,A);if(!A&&TX){fWe();const f=bWe(m);p=f.MeasureLayout,g.visualElement=AWe(t,h,m,r,f.ProjectionNode,i)}return H.jsxs(BB.Provider,{value:g,children:[p&&g.visualElement?H.jsx(p,{visualElement:g.visualElement,...m}):null,sWe(t,u,mWe(h,g.visualElement,d),h,A,e,i)]})}s.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const l=he.forwardRef(s);return l[pWe]=t,l}function hWe({layoutId:t}){const e=he.useContext(SX).id;return e&&t!==void 0?e+"-"+t:t}function fWe(t,e){he.useContext(rne).strict}function bWe(t){const e=sne(),{drag:n,layout:a}=e;if(!n&&!a)return{};const r={...n,...a};return{MeasureLayout:n!=null&&n.isEnabled(t)||a!=null&&a.isEnabled(t)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function yWe(t,e){if(typeof Proxy>"u")return aT;const n=new Map,a=(i,o)=>aT(i,o,t,e),r=(i,o)=>a(i,o);return new Proxy(r,{get:(i,o)=>o==="create"?a:(n.has(o)||n.set(o,aT(o,void 0,t,e)),n.get(o))})}const wWe=(t,e)=>e.isSVG??nT(t)?new aYe(e):new VUe(e,{allowProjection:t!==he.Fragment});class kWe extends Kp{constructor(e){super(e),e.animationState||(e.animationState=cYe(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();yB(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:n}=this.node.prevProps||{};e!==n&&this.updateAnimationControlsSubscription()}unmount(){var e;this.node.animationState.reset(),(e=this.unmountControls)==null||e.call(this)}}let vWe=0;class CWe extends Kp{constructor(){super(...arguments),this.id=vWe++}update(){if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:n}=this.node.presenceContext,{isPresent:a}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===a)return;const r=this.node.animationState.setActive("exit",!e);n&&!e&&r.then(()=>{n(this.id)})}mount(){const{register:e,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),e&&(this.unmount=e(this.id))}unmount(){}}const _We={animation:{Feature:kWe},exit:{Feature:CWe}};function Hw(t){return{point:{x:t.pageX,y:t.pageY}}}const xWe=t=>e=>j7(e)&&t(e,Hw(e));function Uw(t,e,n,a){return qw(t,e,xWe(n),a)}const gne=({current:t})=>t?t.ownerDocument.defaultView:null,hne=(t,e)=>Math.abs(t-e);function EWe(t,e){const n=hne(t.x,e.x),a=hne(t.y,e.y);return Math.sqrt(n**2+a**2)}const fne=new Set(["auto","scroll"]);class bne{constructor(e,n,{transformPagePoint:a,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:o=3,element:s}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=A=>{this.handleScroll(A.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const A=iT(this.lastMoveEventInfo,this.history),g=this.startEvent!==null,h=EWe(A.offset,{x:0,y:0})>=this.distanceThreshold;if(!g&&!h)return;const{point:f}=A,{timestamp:b}=Li;this.history.push({...f,timestamp:b});const{onStart:y,onMove:w}=this.handlers;g||(y&&y(this.lastMoveEvent,A),this.startEvent=this.lastMoveEvent),w&&w(this.lastMoveEvent,A)},this.handlePointerMove=(A,g)=>{this.lastMoveEvent=A,this.lastMoveEventInfo=rT(g,this.transformPagePoint),Ma.update(this.updatePoint,!0)},this.handlePointerUp=(A,g)=>{this.end();const{onEnd:h,onSessionEnd:f,resumeAnimation:b}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&b&&b(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const y=iT(A.type==="pointercancel"?this.lastMoveEventInfo:rT(g,this.transformPagePoint),this.history);this.startEvent&&h&&h(A,y),f&&f(A,y)},!j7(e))return;this.dragSnapToOrigin=i,this.handlers=n,this.transformPagePoint=a,this.distanceThreshold=o,this.contextWindow=r||window;const l=Hw(e),u=rT(l,this.transformPagePoint),{point:d}=u,{timestamp:p}=Li;this.history=[{...d,timestamp:p}];const{onSessionStart:m}=n;m&&m(e,iT(u,this.history)),this.removeListeners=Sw(Uw(this.contextWindow,"pointermove",this.handlePointerMove),Uw(this.contextWindow,"pointerup",this.handlePointerUp),Uw(this.contextWindow,"pointercancel",this.handlePointerUp)),s&&this.startScrollTracking(s)}startScrollTracking(e){let n=e.parentElement;for(;n;){const a=getComputedStyle(n);(fne.has(a.overflowX)||fne.has(a.overflowY))&&this.scrollPositions.set(n,{x:n.scrollLeft,y:n.scrollTop}),n=n.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0,passive:!0}),window.addEventListener("scroll",this.onWindowScroll,{passive:!0}),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(e){const n=this.scrollPositions.get(e);if(!n)return;const a=e===window,r=a?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},i={x:r.x-n.x,y:r.y-n.y};i.x===0&&i.y===0||(a?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(e,r),Ma.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Hp(this.updatePoint)}}function rT(t,e){return e?{point:e(t.point)}:t}function yne(t,e){return{x:t.x-e.x,y:t.y-e.y}}function iT({point:t},e){return{point:t,delta:yne(t,wne(e)),offset:yne(t,BWe(e)),velocity:IWe(e,.1)}}function BWe(t){return t[0]}function wne(t){return t[t.length-1]}function IWe(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,a=null;const r=wne(t);for(;n>=0&&(a=t[n],!(r.timestamp-a.timestamp>nu(e)));)n--;if(!a)return{x:0,y:0};const i=hc(r.timestamp-a.timestamp);if(i===0)return{x:0,y:0};const o={x:(r.x-a.x)/i,y:(r.y-a.y)/i};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function DWe(t,{min:e,max:n},a){return e!==void 0&&t<e?t=a?or(e,t,a.min):Math.max(t,e):n!==void 0&&t>n&&(t=a?or(n,t,a.max):Math.min(t,n)),t}function kne(t,e,n){return{min:e!==void 0?t.min+e:void 0,max:n!==void 0?t.max+n-(t.max-t.min):void 0}}function QWe(t,{top:e,left:n,bottom:a,right:r}){return{x:kne(t.x,n,r),y:kne(t.y,e,a)}}function vne(t,e){let n=e.min-t.min,a=e.max-t.max;return e.max-e.min<t.max-t.min&&([n,a]=[a,n]),{min:n,max:a}}function SWe(t,e){return{x:vne(t.x,e.x),y:vne(t.y,e.y)}}function TWe(t,e){let n=.5;const a=Lo(t),r=Lo(e);return r>a?n=Tw(e.min,e.max-a,t.min):a>r&&(n=Tw(t.min,t.max-r,e.min)),tu(0,1,n)}function FWe(t,e){const n={};return e.min!==void 0&&(n.min=e.min-t.min),e.max!==void 0&&(n.max=e.max-t.min),n}const oT=.35;function LWe(t=oT){return t===!1?t=0:t===!0&&(t=oT),{x:Cne(t,"left","right"),y:Cne(t,"top","bottom")}}function Cne(t,e,n){return{min:_ne(t,e),max:_ne(t,n)}}function _ne(t,e){return typeof t=="number"?t:t[e]||0}const NWe=new WeakMap;class MWe{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Vr(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:n=!1,distanceThreshold:a}={}){const{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;const i=p=>{n?(this.stopAnimation(),this.snapToCursor(Hw(p).point)):this.pauseAnimation()},o=(p,m)=>{this.stopAnimation();const{drag:A,dragPropagation:g,onDragStart:h}=this.getProps();if(A&&!g&&(this.openDragLock&&this.openDragLock(),this.openDragLock=IUe(A),!this.openDragLock))return;this.latestPointerEvent=p,this.latestPanInfo=m,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),fc(b=>{let y=this.getAxisMotionValue(b).get()||0;if(au.test(y)){const{projection:w}=this.visualElement;if(w&&w.layout){const k=w.layout.layoutBox[b];k&&(y=Lo(k)*(parseFloat(y)/100))}}this.originPoint[b]=y}),h&&Ma.postRender(()=>h(p,m)),N7(this.visualElement,"transform");const{animationState:f}=this.visualElement;f&&f.setActive("whileDrag",!0)},s=(p,m)=>{this.latestPointerEvent=p,this.latestPanInfo=m;const{dragPropagation:A,dragDirectionLock:g,onDirectionLock:h,onDrag:f}=this.getProps();if(!A&&!this.openDragLock)return;const{offset:b}=m;if(g&&this.currentDirection===null){this.currentDirection=RWe(b),this.currentDirection!==null&&h&&h(this.currentDirection);return}this.updateAxis("x",m.point,b),this.updateAxis("y",m.point,b),this.visualElement.render(),f&&f(p,m)},l=(p,m)=>{this.latestPointerEvent=p,this.latestPanInfo=m,this.stop(p,m),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>fc(p=>{var m;return this.getAnimationState(p)==="paused"&&((m=this.getAxisMotionValue(p).animation)==null?void 0:m.play())}),{dragSnapToOrigin:d}=this.getProps();this.panSession=new bne(e,{onSessionStart:i,onStart:o,onMove:s,onSessionEnd:l,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:d,distanceThreshold:a,contextWindow:gne(this.visualElement),element:this.visualElement.current})}stop(e,n){const a=e||this.latestPointerEvent,r=n||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!r||!a)return;const{velocity:o}=r;this.startAnimation(o);const{onDragEnd:s}=this.getProps();s&&Ma.postRender(()=>s(a,r))}cancel(){this.isDragging=!1;const{projection:e,animationState:n}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:a}=this.getProps();!a&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,n,a){const{drag:r}=this.getProps();if(!a||!IB(e,r,this.currentDirection))return;const i=this.getAxisMotionValue(e);let o=this.originPoint[e]+a[e];this.constraints&&this.constraints[e]&&(o=DWe(o,this.constraints[e],this.elastic[e])),i.set(o)}resolveConstraints(){var i;const{dragConstraints:e,dragElastic:n}=this.getProps(),a=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(i=this.visualElement.projection)==null?void 0:i.layout,r=this.constraints;e&&zw(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&a?this.constraints=QWe(a.layoutBox,e):this.constraints=!1,this.elastic=LWe(n),r!==this.constraints&&a&&this.constraints&&!this.hasMutatedConstraints&&fc(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=FWe(a.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:n}=this.getProps();if(!e||!zw(e))return!1;const a=e.current;WA(a!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:r}=this.visualElement;if(!r||!r.layout)return!1;const i=HUe(a,r.root,this.visualElement.getTransformPagePoint());let o=SWe(r.layout.layoutBox,i);if(n){const s=n(GUe(o));this.hasMutatedConstraints=!!s,s&&(o=rte(s))}return o}startAnimation(e){const{drag:n,dragMomentum:a,dragElastic:r,dragTransition:i,dragSnapToOrigin:o,onDragTransitionEnd:s}=this.getProps(),l=this.constraints||{},u=fc(d=>{if(!IB(d,n,this.currentDirection))return;let p=l&&l[d]||{};o&&(p={min:0,max:0});const m=r?200:1e6,A=r?40:1e7,g={type:"inertia",velocity:a?e[d]:0,bounceStiffness:m,bounceDamping:A,timeConstant:750,restDelta:1,restSpeed:10,...i,...p};return this.startAxisValueAnimation(d,g)});return Promise.all(u).then(s)}startAxisValueAnimation(e,n){const a=this.getAxisMotionValue(e);return N7(this.visualElement,e),a.start(T7(e,a,0,n,this.visualElement,!1))}stopAnimation(){fc(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){fc(e=>{var n;return(n=this.getAxisMotionValue(e).animation)==null?void 0:n.pause()})}getAnimationState(e){var n;return(n=this.getAxisMotionValue(e).animation)==null?void 0:n.state}getAxisMotionValue(e){const n=`_drag${e.toUpperCase()}`,a=this.visualElement.getProps(),r=a[n];return r||this.visualElement.getValue(e,(a.initial?a.initial[e]:void 0)||0)}snapToCursor(e){fc(n=>{const{drag:a}=this.getProps();if(!IB(n,a,this.currentDirection))return;const{projection:r}=this.visualElement,i=this.getAxisMotionValue(n);if(r&&r.layout){const{min:o,max:s}=r.layout.layoutBox[n],l=i.get()||0;i.set(e[n]-or(o,s,.5)+l)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:n}=this.getProps(),{projection:a}=this.visualElement;if(!zw(n)||!a||!this.constraints)return;this.stopAnimation();const r={x:0,y:0};fc(o=>{const s=this.getAxisMotionValue(o);if(s&&this.constraints!==!1){const l=s.get();r[o]=TWe({min:l,max:l},this.constraints[o])}});const{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},""):"none",a.root&&a.root.updateScroll(),a.updateLayout(),this.resolveConstraints(),fc(o=>{if(!IB(o,e,null))return;const s=this.getAxisMotionValue(o),{min:l,max:u}=this.constraints[o];s.set(or(l,u,r[o]))})}addListeners(){if(!this.visualElement.current)return;NWe.set(this.visualElement,this);const e=this.visualElement.current,n=Uw(e,"pointerdown",l=>{const{drag:u,dragListener:d=!0}=this.getProps(),p=l.target,m=p!==e&&Yee(p);u&&d&&!m&&this.start(l)}),a=()=>{const{dragConstraints:l}=this.getProps();zw(l)&&l.current&&(this.constraints=this.resolveRefConstraints())},{projection:r}=this.visualElement,i=r.addEventListener("measure",a);r&&!r.layout&&(r.root&&r.root.updateScroll(),r.updateLayout()),Ma.read(a);const o=qw(window,"resize",()=>this.scalePositionWithinConstraints()),s=r.addEventListener("didUpdate",({delta:l,hasLayoutChanged:u})=>{this.isDragging&&u&&(fc(d=>{const p=this.getAxisMotionValue(d);p&&(this.originPoint[d]+=l[d].translate,p.set(p.get()+l[d].translate))}),this.visualElement.render())});return()=>{o(),n(),i(),s&&s()}}getProps(){const e=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:a=!1,dragPropagation:r=!1,dragConstraints:i=!1,dragElastic:o=oT,dragMomentum:s=!0}=e;return{...e,drag:n,dragDirectionLock:a,dragPropagation:r,dragConstraints:i,dragElastic:o,dragMomentum:s}}}function IB(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function RWe(t,e=10){let n=null;return Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x"),n}class $We extends Kp{constructor(e){super(e),this.removeGroupControls=gc,this.removeListeners=gc,this.controls=new MWe(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||gc}update(){const{dragControls:e}=this.node.getProps(),{dragControls:n}=this.node.prevProps||{};e!==n&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const xne=t=>(e,n)=>{t&&Ma.postRender(()=>t(e,n))};class PWe extends Kp{constructor(){super(...arguments),this.removePointerDownListener=gc}onPointerDown(e){this.session=new bne(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:gne(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:n,onPan:a,onPanEnd:r}=this.node.getProps();return{onSessionStart:xne(e),onStart:xne(n),onMove:a,onEnd:(i,o)=>{delete this.session,r&&Ma.postRender(()=>r(i,o))}}}mount(){this.removePointerDownListener=Uw(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let sT=!1;class OWe extends he.Component{componentDidMount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:a,layoutId:r}=this.props,{projection:i}=e;i&&(n.group&&n.group.add(i),a&&a.register&&r&&a.register(i),sT&&i.root.didUpdate(),i.addEventListener("animationComplete",()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),xB.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:n,visualElement:a,drag:r,isPresent:i}=this.props,{projection:o}=a;return o&&(o.isPresent=i,e.layoutDependency!==n&&o.setOptions({...o.options,layoutDependency:n}),sT=!0,r||e.layoutDependency!==n||n===void 0||e.isPresent!==i?o.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?o.promote():o.relegate()||Ma.postRender(()=>{const s=o.getStack();(!s||!s.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),O7.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:a}=this.props,{projection:r}=e;sT=!0,r&&(r.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(r),a&&a.deregister&&a.deregister(r))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function Ene(t){const[e,n]=WYe(),a=he.useContext(SX);return H.jsx(OWe,{...t,layoutGroup:a,switchLayoutGroup:he.useContext(mne),isPresent:e,safeToRemove:n})}const jWe={pan:{Feature:PWe},drag:{Feature:$We,ProjectionNode:nne,MeasureLayout:Ene}};function Bne(t,e,n){const{props:a}=t;t.animationState&&a.whileHover&&t.animationState.setActive("whileHover",n==="Start");const r="onHover"+n,i=a[r];i&&Ma.postRender(()=>i(e,Hw(e)))}class GWe extends Kp{mount(){const{current:e}=this.node;e&&(this.unmount=DUe(e,(n,a)=>(Bne(this.node,a,"Start"),r=>Bne(this.node,r,"End"))))}unmount(){}}class qWe extends Kp{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=Sw(qw(this.node.current,"focus",()=>this.onFocus()),qw(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Ine(t,e,n){const{props:a}=t;if(t.current instanceof HTMLButtonElement&&t.current.disabled)return;t.animationState&&a.whileTap&&t.animationState.setActive("whileTap",n==="Start");const r="onTap"+(n==="End"?"":n),i=a[r];i&&Ma.postRender(()=>i(e,Hw(e)))}class zWe extends Kp{mount(){const{current:e}=this.node;e&&(this.unmount=TUe(e,(n,a)=>(Ine(this.node,a,"Start"),(r,{success:i})=>Ine(this.node,r,i?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const cT=new WeakMap,lT=new WeakMap,HWe=t=>{const e=cT.get(t.target);e&&e(t)},UWe=t=>{t.forEach(HWe)};function YWe({root:t,...e}){const n=t||document;lT.has(n)||lT.set(n,{});const a=lT.get(n),r=JSON.stringify(e);return a[r]||(a[r]=new IntersectionObserver(UWe,{root:t,...e})),a[r]}function WWe(t,e,n){const a=YWe(e);return cT.set(t,n),a.observe(t),()=>{cT.delete(t),a.unobserve(t)}}const KWe={some:0,all:1};class ZWe extends Kp{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:e={}}=this.node.getProps(),{root:n,margin:a,amount:r="some",once:i}=e,o={root:n?n.current:void 0,rootMargin:a,threshold:typeof r=="number"?r:KWe[r]},s=l=>{const{isIntersecting:u}=l;if(this.isInView===u||(this.isInView=u,i&&!u&&this.hasEnteredView))return;u&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",u);const{onViewportEnter:d,onViewportLeave:p}=this.node.getProps(),m=u?d:p;m&&m(l)};return WWe(this.node.current,o,s)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:n}=this.node;["amount","margin","root"].some(VWe(e,n))&&this.startObserver()}unmount(){}}function VWe({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}const JWe={..._We,...{inView:{Feature:ZWe},tap:{Feature:zWe},focus:{Feature:qWe},hover:{Feature:GWe}},...jWe,...{layout:{ProjectionNode:nne,MeasureLayout:Ene}}},XWe=yWe(JWe,wWe),eKe=({children:t,as:e="p",className:n,duration:a=2,spread:r=2})=>{const i=XWe.create(e),o=he.useMemo(()=>((t==null?void 0:t.length)??0)*r,[t,r]);return H.jsx(i,{animate:{backgroundPosition:"0% center"},className:Tn("relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent","[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]",n),initial:{backgroundPosition:"100% center"},style:{"--spread":`${o}px`,backgroundImage:"var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"},transition:{repeat:Number.POSITIVE_INFINITY,duration:a,ease:"linear"},children:t})},tKe=he.memo(eKe),Dne=he.createContext(null),nKe=()=>{const t=he.useContext(Dne);if(!t)throw new Error("Reasoning components must be used within Reasoning");return t},aKe=1e3,rKe=1e3,Qne=he.memo(({className:t,isStreaming:e=!1,open:n,defaultOpen:a=!0,onOpenChange:r,duration:i,children:o,...s})=>{const[l,u]=mf({prop:n,defaultProp:a,onChange:r}),[d,p]=mf({prop:i,defaultProp:void 0}),[m,A]=he.useState(!1),[g,h]=he.useState(null);he.useEffect(()=>{e?g===null&&h(Date.now()):g!==null&&(p(Math.ceil((Date.now()-g)/rKe)),h(null))},[e,g,p]),he.useEffect(()=>{if(a&&!e&&l&&!m){const b=setTimeout(()=>{u(!1),A(!0)},aKe);return()=>clearTimeout(b)}},[e,l,a,u,m]);const f=b=>{u(b)};return H.jsx(Dne.Provider,{value:{isStreaming:e,isOpen:l,setIsOpen:u,duration:d},children:H.jsx(Y5,{className:Tn("not-prose mb-4",t),onOpenChange:f,open:l,...s,children:o})})}),iKe=(t,e)=>t||e===0?H.jsx(tKe,{duration:1,children:"Thinking..."}):e===void 0?H.jsx("p",{children:"Thought for a few seconds"}):H.jsxs("p",{children:["Thought for ",e," seconds"]}),Sne=he.memo(({className:t,children:e,getThinkingMessage:n=iKe,...a})=>{const{isStreaming:r,isOpen:i,duration:o}=nKe();return H.jsx(W5,{className:Tn("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",t),...a,children:e??H.jsxs(H.Fragment,{children:[H.jsx(wSe,{className:"size-4"}),n(r,o),H.jsx(v9,{className:Tn("size-4 transition-transform",i?"rotate-180":"rotate-0")})]})})}),Tne=he.memo(({className:t,children:e,...n})=>H.jsx(K5,{className:Tn("mt-4 text-sm","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",t),...n,children:H.jsx(G5,{...n,children:e})}));Qne.displayName="Reasoning",Sne.displayName="ReasoningTrigger",Tne.displayName="ReasoningContent";const oKe=({className:t,...e})=>H.jsx(Y5,{className:Tn("not-prose mb-4 text-primary text-xs",t),...e}),sKe=({className:t,count:e,children:n,...a})=>H.jsx(W5,{className:Tn("flex items-center gap-2",t),...a,children:n??H.jsxs(H.Fragment,{children:[H.jsxs("p",{className:"font-medium",children:["Used ",e," sources"]}),H.jsx(v9,{className:"h-4 w-4"})]})}),cKe=({className:t,...e})=>H.jsx(K5,{className:Tn("mt-3 flex w-fit flex-col gap-2","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",t),...e}),lKe=({href:t,title:e,children:n,...a})=>H.jsx("a",{className:"flex items-center gap-2",href:t,rel:"noreferrer",target:"_blank",...a,children:n??H.jsxs(H.Fragment,{children:[H.jsx(ySe,{className:"h-4 w-4"}),H.jsx("span",{className:"block font-medium",children:e})]})}),uKe=Ox("inline-flex items-center justify-center rounded-full border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function dKe({className:t,variant:e,asChild:n=!1,...a}){const r=n?VH:"span";return H.jsx(r,{"data-slot":"badge",className:Tn(uKe({variant:e}),t),...a})}let Fr=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function pKe(t){return uT(t)}function uT(t){return Array.isArray(t)?mKe(t):t instanceof RegExp?t:typeof t=="object"?AKe(t):t}function mKe(t){let e=[];for(let n=0,a=t.length;n<a;n++)e[n]=uT(t[n]);return e}function AKe(t){let e={};for(let n in t)e[n]=uT(t[n]);return e}function Fne(t,...e){return e.forEach(n=>{for(let a in n)t[a]=n[a]}),t}function Lne(t){const e=~t.lastIndexOf("/")||~t.lastIndexOf("\\");return e===0?t:~e===t.length-1?Lne(t.substring(0,t.length-1)):t.substr(~e+1)}var dT=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,DB=class{static hasCaptures(t){return t===null?!1:(dT.lastIndex=0,dT.test(t))}static replaceCaptures(t,e,n){return t.replace(dT,(a,r,i,o)=>{let s=n[parseInt(r||i,10)];if(s){let l=e.substring(s.start,s.end);for(;l[0]===".";)l=l.substring(1);switch(o){case"downcase":return l.toLowerCase();case"upcase":return l.toUpperCase();default:return l}}else return a})}};function Nne(t,e){return t<e?-1:t>e?1:0}function Mne(t,e){if(t===null&&e===null)return 0;if(!t)return-1;if(!e)return 1;let n=t.length,a=e.length;if(n===a){for(let r=0;r<n;r++){let i=Nne(t[r],e[r]);if(i!==0)return i}return 0}return n-a}function Rne(t){return!!(/^#[0-9a-f]{6}$/i.test(t)||/^#[0-9a-f]{8}$/i.test(t)||/^#[0-9a-f]{3}$/i.test(t)||/^#[0-9a-f]{4}$/i.test(t))}function $ne(t){return t.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var Pne=class{constructor(t){We(this,"cache",new Map);this.fn=t}get(t){if(this.cache.has(t))return this.cache.get(t);const e=this.fn(t);return this.cache.set(t,e),e}},QB=class{constructor(e,n,a){We(this,"_cachedMatchRoot",new Pne(e=>this._root.match(e)));this._colorMap=e,this._defaults=n,this._root=a}static createFromRawTheme(e,n){return this.createFromParsedTheme(fKe(e),n)}static createFromParsedTheme(e,n){return yKe(e,n)}getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;const n=e.scopeName,r=this._cachedMatchRoot.get(n).find(i=>gKe(e.parent,i.parentScopes));return r?new One(r.fontStyle,r.foreground,r.background):null}},pT=class t9{constructor(e,n){this.parent=e,this.scopeName=n}static push(e,n){for(const a of n)e=new t9(e,a);return e}static from(...e){let n=null;for(let a=0;a<e.length;a++)n=new t9(n,e[a]);return n}push(e){return new t9(this,e)}getSegments(){let e=this;const n=[];for(;e;)n.push(e.scopeName),e=e.parent;return n.reverse(),n}toString(){return this.getSegments().join(" ")}extends(e){return this===e?!0:this.parent===null?!1:this.parent.extends(e)}getExtensionIfDefined(e){const n=[];let a=this;for(;a&&a!==e;)n.push(a.scopeName),a=a.parent;return a===e?n.reverse():void 0}};function gKe(t,e){if(e.length===0)return!0;for(let n=0;n<e.length;n++){let a=e[n],r=!1;if(a===">"){if(n===e.length-1)return!1;a=e[++n],r=!0}for(;t&&!hKe(t.scopeName,a);){if(r)return!1;t=t.parent}if(!t)return!1;t=t.parent}return!0}function hKe(t,e){return e===t||t.startsWith(e)&&t[e.length]==="."}var One=class{constructor(t,e,n){this.fontStyle=t,this.foregroundId=e,this.backgroundId=n}};function fKe(t){if(!t)return[];if(!t.settings||!Array.isArray(t.settings))return[];let e=t.settings,n=[],a=0;for(let r=0,i=e.length;r<i;r++){let o=e[r];if(!o.settings)continue;let s;if(typeof o.scope=="string"){let p=o.scope;p=p.replace(/^[,]+/,""),p=p.replace(/[,]+$/,""),s=p.split(",")}else Array.isArray(o.scope)?s=o.scope:s=[""];let l=-1;if(typeof o.settings.fontStyle=="string"){l=0;let p=o.settings.fontStyle.split(" ");for(let m=0,A=p.length;m<A;m++)switch(p[m]){case"italic":l=l|1;break;case"bold":l=l|2;break;case"underline":l=l|4;break;case"strikethrough":l=l|8;break}}let u=null;typeof o.settings.foreground=="string"&&Rne(o.settings.foreground)&&(u=o.settings.foreground);let d=null;typeof o.settings.background=="string"&&Rne(o.settings.background)&&(d=o.settings.background);for(let p=0,m=s.length;p<m;p++){let g=s[p].trim().split(" "),h=g[g.length-1],f=null;g.length>1&&(f=g.slice(0,g.length-1),f.reverse()),n[a++]=new bKe(h,f,r,l,u,d)}}return n}var bKe=class{constructor(t,e,n,a,r,i){this.scope=t,this.parentScopes=e,this.index=n,this.fontStyle=a,this.foreground=r,this.background=i}},ao=(t=>(t[t.NotSet=-1]="NotSet",t[t.None=0]="None",t[t.Italic=1]="Italic",t[t.Bold=2]="Bold",t[t.Underline=4]="Underline",t[t.Strikethrough=8]="Strikethrough",t))(ao||{});function yKe(t,e){t.sort((l,u)=>{let d=Nne(l.scope,u.scope);return d!==0||(d=Mne(l.parentScopes,u.parentScopes),d!==0)?d:l.index-u.index});let n=0,a="#000000",r="#ffffff";for(;t.length>=1&&t[0].scope==="";){let l=t.shift();l.fontStyle!==-1&&(n=l.fontStyle),l.foreground!==null&&(a=l.foreground),l.background!==null&&(r=l.background)}let i=new wKe(e),o=new One(n,i.getId(a),i.getId(r)),s=new vKe(new mT(0,null,-1,0,0),[]);for(let l=0,u=t.length;l<u;l++){let d=t[l];s.insert(0,d.scope,d.parentScopes,d.fontStyle,i.getId(d.foreground),i.getId(d.background))}return new QB(i,o,s)}var wKe=class{constructor(t){We(this,"_isFrozen");We(this,"_lastColorId");We(this,"_id2color");We(this,"_color2id");if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(t)){this._isFrozen=!0;for(let e=0,n=t.length;e<n;e++)this._color2id[t[e]]=e,this._id2color[e]=t[e]}else this._isFrozen=!1}getId(t){if(t===null)return 0;t=t.toUpperCase();let e=this._color2id[t];if(e)return e;if(this._isFrozen)throw new Error(`Missing color in color map - ${t}`);return e=++this._lastColorId,this._color2id[t]=e,this._id2color[e]=t,e}getColorMap(){return this._id2color.slice(0)}},kKe=Object.freeze([]),mT=class $De{constructor(e,n,a,r,i){We(this,"scopeDepth");We(this,"parentScopes");We(this,"fontStyle");We(this,"foreground");We(this,"background");this.scopeDepth=e,this.parentScopes=n||kKe,this.fontStyle=a,this.foreground=r,this.background=i}clone(){return new $De(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let n=[];for(let a=0,r=e.length;a<r;a++)n[a]=e[a].clone();return n}acceptOverwrite(e,n,a,r){this.scopeDepth>e?console.log("how did this happen?"):this.scopeDepth=e,n!==-1&&(this.fontStyle=n),a!==0&&(this.foreground=a),r!==0&&(this.background=r)}},vKe=class GH{constructor(e,n=[],a={}){We(this,"_rulesWithParentScopes");this._mainRule=e,this._children=a,this._rulesWithParentScopes=n}static _cmpBySpecificity(e,n){if(e.scopeDepth!==n.scopeDepth)return n.scopeDepth-e.scopeDepth;let a=0,r=0;for(;e.parentScopes[a]===">"&&a++,n.parentScopes[r]===">"&&r++,!(a>=e.parentScopes.length||r>=n.parentScopes.length);){const i=n.parentScopes[r].length-e.parentScopes[a].length;if(i!==0)return i;a++,r++}return n.parentScopes.length-e.parentScopes.length}match(e){if(e!==""){let a=e.indexOf("."),r,i;if(a===-1?(r=e,i=""):(r=e.substring(0,a),i=e.substring(a+1)),this._children.hasOwnProperty(r))return this._children[r].match(i)}const n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(GH._cmpBySpecificity),n}insert(e,n,a,r,i,o){if(n===""){this._doInsertHere(e,a,r,i,o);return}let s=n.indexOf("."),l,u;s===-1?(l=n,u=""):(l=n.substring(0,s),u=n.substring(s+1));let d;this._children.hasOwnProperty(l)?d=this._children[l]:(d=new GH(this._mainRule.clone(),mT.cloneArr(this._rulesWithParentScopes)),this._children[l]=d),d.insert(e+1,u,a,r,i,o)}_doInsertHere(e,n,a,r,i){if(n===null){this._mainRule.acceptOverwrite(e,a,r,i);return}for(let o=0,s=this._rulesWithParentScopes.length;o<s;o++){let l=this._rulesWithParentScopes[o];if(Mne(l.parentScopes,n)===0){l.acceptOverwrite(e,a,r,i);return}}a===-1&&(a=this._mainRule.fontStyle),r===0&&(r=this._mainRule.foreground),i===0&&(i=this._mainRule.background),this._rulesWithParentScopes.push(new mT(e,n,a,r,i))}},Uf=class Zc{static toBinaryStr(e){return e.toString(2).padStart(32,"0")}static print(e){const n=Zc.getLanguageId(e),a=Zc.getTokenType(e),r=Zc.getFontStyle(e),i=Zc.getForeground(e),o=Zc.getBackground(e);console.log({languageId:n,tokenType:a,fontStyle:r,foreground:i,background:o})}static getLanguageId(e){return(e&255)>>>0}static getTokenType(e){return(e&768)>>>8}static containsBalancedBrackets(e){return(e&1024)!==0}static getFontStyle(e){return(e&30720)>>>11}static getForeground(e){return(e&16744448)>>>15}static getBackground(e){return(e&4278190080)>>>24}static set(e,n,a,r,i,o,s){let l=Zc.getLanguageId(e),u=Zc.getTokenType(e),d=Zc.containsBalancedBrackets(e)?1:0,p=Zc.getFontStyle(e),m=Zc.getForeground(e),A=Zc.getBackground(e);return n!==0&&(l=n),a!==8&&(u=a),r!==null&&(d=r?1:0),i!==-1&&(p=i),o!==0&&(m=o),s!==0&&(A=s),(l<<0|u<<8|d<<10|p<<11|m<<15|A<<24)>>>0}};function N0n(t){return t}function M0n(t){return t}function SB(t,e){const n=[],a=CKe(t);let r=a.next();for(;r!==null;){let l=0;if(r.length===2&&r.charAt(1)===":"){switch(r.charAt(0)){case"R":l=1;break;case"L":l=-1;break;default:console.log(`Unknown priority ${r} in scope selector`)}r=a.next()}let u=o();if(n.push({matcher:u,priority:l}),r!==",")break;r=a.next()}return n;function i(){if(r==="-"){r=a.next();const l=i();return u=>!!l&&!l(u)}if(r==="("){r=a.next();const l=s();return r===")"&&(r=a.next()),l}if(jne(r)){const l=[];do l.push(r),r=a.next();while(jne(r));return u=>e(l,u)}return null}function o(){const l=[];let u=i();for(;u;)l.push(u),u=i();return d=>l.every(p=>p(d))}function s(){const l=[];let u=o();for(;u&&(l.push(u),r==="|"||r===",");){do r=a.next();while(r==="|"||r===",");u=o()}return d=>l.some(p=>p(d))}}function jne(t){return!!t&&!!t.match(/[\w\.:]+/)}function CKe(t){let e=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=e.exec(t);return{next:()=>{if(!n)return null;const a=n[0];return n=e.exec(t),a}}}function Gne(t){typeof t.dispose=="function"&&t.dispose()}var Yw=class{constructor(t){this.scopeName=t}toKey(){return this.scopeName}},_Ke=class{constructor(t,e){this.scopeName=t,this.ruleName=e}toKey(){return`${this.scopeName}#${this.ruleName}`}},xKe=class{constructor(){We(this,"_references",[]);We(this,"_seenReferenceKeys",new Set);We(this,"visitedRule",new Set)}get references(){return this._references}add(t){const e=t.toKey();this._seenReferenceKeys.has(e)||(this._seenReferenceKeys.add(e),this._references.push(t))}},EKe=class{constructor(t,e){We(this,"seenFullScopeRequests",new Set);We(this,"seenPartialScopeRequests",new Set);We(this,"Q");this.repo=t,this.initialScopeName=e,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new Yw(this.initialScopeName)]}processQueue(){const t=this.Q;this.Q=[];const e=new xKe;for(const n of t)BKe(n,this.initialScopeName,this.repo,e);for(const n of e.references)if(n instanceof Yw){if(this.seenFullScopeRequests.has(n.scopeName))continue;this.seenFullScopeRequests.add(n.scopeName),this.Q.push(n)}else{if(this.seenFullScopeRequests.has(n.scopeName)||this.seenPartialScopeRequests.has(n.toKey()))continue;this.seenPartialScopeRequests.add(n.toKey()),this.Q.push(n)}}};function BKe(t,e,n,a){const r=n.lookup(t.scopeName);if(!r){if(t.scopeName===e)throw new Error(`No grammar provided for <${e}>`);return}const i=n.lookup(e);t instanceof Yw?TB({baseGrammar:i,selfGrammar:r},a):AT(t.ruleName,{baseGrammar:i,selfGrammar:r,repository:r.repository},a);const o=n.injections(t.scopeName);if(o)for(const s of o)a.add(new Yw(s))}function AT(t,e,n){if(e.repository&&e.repository[t]){const a=e.repository[t];FB([a],e,n)}}function TB(t,e){t.selfGrammar.patterns&&Array.isArray(t.selfGrammar.patterns)&&FB(t.selfGrammar.patterns,{...t,repository:t.selfGrammar.repository},e),t.selfGrammar.injections&&FB(Object.values(t.selfGrammar.injections),{...t,repository:t.selfGrammar.repository},e)}function FB(t,e,n){for(const a of t){if(n.visitedRule.has(a))continue;n.visitedRule.add(a);const r=a.repository?Fne({},e.repository,a.repository):e.repository;Array.isArray(a.patterns)&&FB(a.patterns,{...e,repository:r},n);const i=a.include;if(!i)continue;const o=qne(i);switch(o.kind){case 0:TB({...e,selfGrammar:e.baseGrammar},n);break;case 1:TB(e,n);break;case 2:AT(o.ruleName,{...e,repository:r},n);break;case 3:case 4:const s=o.scopeName===e.selfGrammar.scopeName?e.selfGrammar:o.scopeName===e.baseGrammar.scopeName?e.baseGrammar:void 0;if(s){const l={baseGrammar:e.baseGrammar,selfGrammar:s,repository:r};o.kind===4?AT(o.ruleName,l,n):TB(l,n)}else o.kind===4?n.add(new _Ke(o.scopeName,o.ruleName)):n.add(new Yw(o.scopeName));break}}}var IKe=class{constructor(){We(this,"kind",0)}},DKe=class{constructor(){We(this,"kind",1)}},QKe=class{constructor(t){We(this,"kind",2);this.ruleName=t}},SKe=class{constructor(t){We(this,"kind",3);this.scopeName=t}},TKe=class{constructor(t,e){We(this,"kind",4);this.scopeName=t,this.ruleName=e}};function qne(t){if(t==="$base")return new IKe;if(t==="$self")return new DKe;const e=t.indexOf("#");if(e===-1)return new SKe(t);if(e===0)return new QKe(t.substring(1));{const n=t.substring(0,e),a=t.substring(e+1);return new TKe(n,a)}}var FKe=/\\(\d+)/,zne=/\\(\d+)/g,LKe=-1,Hne=-2;function R0n(t){return t}function $0n(t){return t}var Ww=class{constructor(e,n,a,r){We(this,"$location");We(this,"id");We(this,"_nameIsCapturing");We(this,"_name");We(this,"_contentNameIsCapturing");We(this,"_contentName");this.$location=e,this.id=n,this._name=a||null,this._nameIsCapturing=DB.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=DB.hasCaptures(this._contentName)}get debugName(){const e=this.$location?`${Lne(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,n){return!this._nameIsCapturing||this._name===null||e===null||n===null?this._name:DB.replaceCaptures(this._name,e,n)}getContentName(e,n){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:DB.replaceCaptures(this._contentName,e,n)}},NKe=class extends Ww{constructor(e,n,a,r,i){super(e,n,a,r);We(this,"retokenizeCapturedWithRuleId");this.retokenizeCapturedWithRuleId=i}dispose(){}collectPatterns(e,n){throw new Error("Not supported!")}compile(e,n){throw new Error("Not supported!")}compileAG(e,n,a,r){throw new Error("Not supported!")}},MKe=class extends Ww{constructor(e,n,a,r,i){super(e,n,a,null);We(this,"_match");We(this,"captures");We(this,"_cachedCompiledPatterns");this._match=new Kw(r,this.id),this.captures=i,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,n){n.push(this._match)}compile(e,n){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,n,a,r){return this._getCachedCompiledPatterns(e).compileAG(e,a,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Zw,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Une=class extends Ww{constructor(e,n,a,r,i){super(e,n,a,r);We(this,"hasMissingPatterns");We(this,"patterns");We(this,"_cachedCompiledPatterns");this.patterns=i.patterns,this.hasMissingPatterns=i.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(e,n){for(const a of this.patterns)e.getRule(a).collectPatterns(e,n)}compile(e,n){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,n,a,r){return this._getCachedCompiledPatterns(e).compileAG(e,a,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Zw,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},gT=class extends Ww{constructor(e,n,a,r,i,o,s,l,u,d){super(e,n,a,r);We(this,"_begin");We(this,"beginCaptures");We(this,"_end");We(this,"endHasBackReferences");We(this,"endCaptures");We(this,"applyEndPatternLast");We(this,"hasMissingPatterns");We(this,"patterns");We(this,"_cachedCompiledPatterns");this._begin=new Kw(i,this.id),this.beginCaptures=o,this._end=new Kw(s||"￿",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=l,this.applyEndPatternLast=u||!1,this.patterns=d.patterns,this.hasMissingPatterns=d.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,n){return this._end.resolveBackReferences(e,n)}collectPatterns(e,n){n.push(this._begin)}compile(e,n){return this._getCachedCompiledPatterns(e,n).compile(e)}compileAG(e,n,a,r){return this._getCachedCompiledPatterns(e,n).compileAG(e,a,r)}_getCachedCompiledPatterns(e,n){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Zw;for(const a of this.patterns)e.getRule(a).collectPatterns(e,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,n):this._cachedCompiledPatterns.setSource(0,n)),this._cachedCompiledPatterns}},LB=class extends Ww{constructor(e,n,a,r,i,o,s,l,u){super(e,n,a,r);We(this,"_begin");We(this,"beginCaptures");We(this,"whileCaptures");We(this,"_while");We(this,"whileHasBackReferences");We(this,"hasMissingPatterns");We(this,"patterns");We(this,"_cachedCompiledPatterns");We(this,"_cachedCompiledWhilePatterns");this._begin=new Kw(i,this.id),this.beginCaptures=o,this.whileCaptures=l,this._while=new Kw(s,Hne),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=u.patterns,this.hasMissingPatterns=u.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,n){return this._while.resolveBackReferences(e,n)}collectPatterns(e,n){n.push(this._begin)}compile(e,n){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,n,a,r){return this._getCachedCompiledPatterns(e).compileAG(e,a,r)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Zw;for(const n of this.patterns)e.getRule(n).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,n){return this._getCachedCompiledWhilePatterns(e,n).compile(e)}compileWhileAG(e,n,a,r){return this._getCachedCompiledWhilePatterns(e,n).compileAG(e,a,r)}_getCachedCompiledWhilePatterns(e,n){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new Zw,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,n||"￿"),this._cachedCompiledWhilePatterns}},Yne=class Eo{static createCaptureRule(e,n,a,r,i){return e.registerRule(o=>new NKe(n,o,a,r,i))}static getCompiledRuleId(e,n,a){return e.id||n.registerRule(r=>{if(e.id=r,e.match)return new MKe(e.$vscodeTextmateLocation,e.id,e.name,e.match,Eo._compileCaptures(e.captures,n,a));if(typeof e.begin>"u"){e.repository&&(a=Fne({},a,e.repository));let i=e.patterns;return typeof i>"u"&&e.include&&(i=[{include:e.include}]),new Une(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,Eo._compilePatterns(i,n,a))}return e.while?new LB(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,Eo._compileCaptures(e.beginCaptures||e.captures,n,a),e.while,Eo._compileCaptures(e.whileCaptures||e.captures,n,a),Eo._compilePatterns(e.patterns,n,a)):new gT(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,Eo._compileCaptures(e.beginCaptures||e.captures,n,a),e.end,Eo._compileCaptures(e.endCaptures||e.captures,n,a),e.applyEndPatternLast,Eo._compilePatterns(e.patterns,n,a))}),e.id}static _compileCaptures(e,n,a){let r=[];if(e){let i=0;for(const o in e){if(o==="$vscodeTextmateLocation")continue;const s=parseInt(o,10);s>i&&(i=s)}for(let o=0;o<=i;o++)r[o]=null;for(const o in e){if(o==="$vscodeTextmateLocation")continue;const s=parseInt(o,10);let l=0;e[o].patterns&&(l=Eo.getCompiledRuleId(e[o],n,a)),r[s]=Eo.createCaptureRule(n,e[o].$vscodeTextmateLocation,e[o].name,e[o].contentName,l)}}return r}static _compilePatterns(e,n,a){let r=[];if(e)for(let i=0,o=e.length;i<o;i++){const s=e[i];let l=-1;if(s.include){const u=qne(s.include);switch(u.kind){case 0:case 1:l=Eo.getCompiledRuleId(a[s.include],n,a);break;case 2:let d=a[u.ruleName];d&&(l=Eo.getCompiledRuleId(d,n,a));break;case 3:case 4:const p=u.scopeName,m=u.kind===4?u.ruleName:null,A=n.getExternalGrammar(p,a);if(A)if(m){let g=A.repository[m];g&&(l=Eo.getCompiledRuleId(g,n,A.repository))}else l=Eo.getCompiledRuleId(A.repository.$self,n,A.repository);break}}else l=Eo.getCompiledRuleId(s,n,a);if(l!==-1){const u=n.getRule(l);let d=!1;if((u instanceof Une||u instanceof gT||u instanceof LB)&&u.hasMissingPatterns&&u.patterns.length===0&&(d=!0),d)continue;r.push(l)}}return{patterns:r,hasMissingPatterns:(e?e.length:0)!==r.length}}},Kw=class PDe{constructor(e,n){We(this,"source");We(this,"ruleId");We(this,"hasAnchor");We(this,"hasBackReferences");We(this,"_anchorCache");if(e&&typeof e=="string"){const a=e.length;let r=0,i=[],o=!1;for(let s=0;s<a;s++)if(e.charAt(s)==="\\"&&s+1<a){const u=e.charAt(s+1);u==="z"?(i.push(e.substring(r,s)),i.push("$(?!\\n)(?<!\\n)"),r=s+2):(u==="A"||u==="G")&&(o=!0),s++}this.hasAnchor=o,r===0?this.source=e:(i.push(e.substring(r,a)),this.source=i.join(""))}else this.hasAnchor=!1,this.source=e;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=n,typeof this.source=="string"?this.hasBackReferences=FKe.test(this.source):this.hasBackReferences=!1}clone(){return new PDe(this.source,this.ruleId)}setSource(e){this.source!==e&&(this.source=e,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(e,n){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let a=n.map(r=>e.substring(r.start,r.end));return zne.lastIndex=0,this.source.replace(zne,(r,i)=>$ne(a[parseInt(i,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let e=[],n=[],a=[],r=[],i,o,s,l;for(i=0,o=this.source.length;i<o;i++)s=this.source.charAt(i),e[i]=s,n[i]=s,a[i]=s,r[i]=s,s==="\\"&&i+1<o&&(l=this.source.charAt(i+1),l==="A"?(e[i+1]="￿",n[i+1]="￿",a[i+1]="A",r[i+1]="A"):l==="G"?(e[i+1]="￿",n[i+1]="G",a[i+1]="￿",r[i+1]="G"):(e[i+1]=l,n[i+1]=l,a[i+1]=l,r[i+1]=l),i++);return{A0_G0:e.join(""),A0_G1:n.join(""),A1_G0:a.join(""),A1_G1:r.join("")}}resolveAnchors(e,n){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:e?n?this._anchorCache.A1_G1:this._anchorCache.A1_G0:n?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},Zw=class{constructor(){We(this,"_items");We(this,"_hasAnchors");We(this,"_cached");We(this,"_anchorCache");this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&(this._cached.dispose(),this._cached=null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(t){this._items.push(t),this._hasAnchors=this._hasAnchors||t.hasAnchor}unshift(t){this._items.unshift(t),this._hasAnchors=this._hasAnchors||t.hasAnchor}length(){return this._items.length}setSource(t,e){this._items[t].source!==e&&(this._disposeCaches(),this._items[t].setSource(e))}compile(t){if(!this._cached){let e=this._items.map(n=>n.source);this._cached=new Wne(t,e,this._items.map(n=>n.ruleId))}return this._cached}compileAG(t,e,n){return this._hasAnchors?e?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(t,e,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(t,e,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(t,e,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(t,e,n)),this._anchorCache.A0_G0):this.compile(t)}_resolveAnchors(t,e,n){let a=this._items.map(r=>r.resolveAnchors(e,n));return new Wne(t,a,this._items.map(r=>r.ruleId))}},Wne=class{constructor(t,e,n){We(this,"scanner");this.regExps=e,this.rules=n,this.scanner=t.createOnigScanner(e)}dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){const t=[];for(let e=0,n=this.rules.length;e<n;e++)t.push(" - "+this.rules[e]+": "+this.regExps[e]);return t.join(`
538
+ `||t[e]==="\r");)e-=1;return e>=1&&t[e]==="$"&&t[e-1]==="$"},j5=t=>{let e=0;for(let n=0;n<t.length-1;n+=1)t[n]==="$"&&t[n+1]==="$"&&(e+=1,n+=1);return e},uze=t=>{let e=ize.test(t),n=oze.test(t);if(e||n)return[t];let a=mc.lex(t,{gfm:!0}),r=[],i=[];for(let o of a){let s=o.raw,l=r.length;if(i.length>0){if(r[l-1]+=s,o.type==="html"){let u=s.match(sze);if(u){let d=u[1];i.at(-1)===d&&i.pop()}}continue}if(o.type==="html"&&o.block){let u=s.match(cze);if(u){let d=u[1];s.includes(`</${d}>`)||i.push(d)}}if(s.trim()==="$$"&&l>0){let u=r[l-1],d=O5(u),p=j5(u);if(d&&p%2===1){r[l-1]=u+s;continue}}if(l>0&&lze(s)){let u=r[l-1],d=O5(u),p=j5(u),m=j5(s);if(d&&p%2===1&&!O5(s)&&m===1){r[l-1]=u+s;continue}}r.push(s)}return r},dze={raw:_Ne,katex:[ES,{errorColor:"var(--color-muted-foreground)"}],harden:[NSe,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:!0}]},pze={gfm:[DPe,{}],math:[c5,{singleDollarTextMath:!1}],cjkFriendly:[VNe,{}],cjkFriendlyGfmStrikethrough:[XNe,{}]},mze=Object.values(dze),Aze=Object.values(pze),gze={shikiTheme:["github-light","github-dark"],controls:!0,isAnimating:!1,mode:"streaming",mermaid:void 0},Ac=he.createContext(gze),xX=he.memo(({content:t,shouldParseIncompleteMarkdown:e,...n})=>{let a=he.useMemo(()=>typeof t=="string"&&e?_Oe(t.trim()):t,[t,e]);return H.jsx(_X,{...n,children:a})},(t,e)=>{if(t.content!==e.content||t.shouldParseIncompleteMarkdown!==e.shouldParseIncompleteMarkdown||t.index!==e.index)return!1;if(t.components!==e.components){let n=Object.keys(t.components||{}),a=Object.keys(e.components||{});if(n.length!==a.length||n.some(r=>{var i,o;return((i=t.components)==null?void 0:i[r])!==((o=e.components)==null?void 0:o[r])}))return!1}return!(t.rehypePlugins!==e.rehypePlugins||t.remarkPlugins!==e.remarkPlugins)});xX.displayName="Block";var hze=["github-light","github-dark"],G5=he.memo(({children:t,mode:e="streaming",parseIncompleteMarkdown:n=!0,components:a,rehypePlugins:r=mze,remarkPlugins:i=Aze,className:o,shikiTheme:s=hze,mermaid:l,controls:u=!0,isAnimating:d=!1,BlockComponent:p=xX,parseMarkdownIntoBlocksFn:m=uze,...A})=>{let g=he.useId(),[h,f]=he.useTransition(),[b,y]=he.useState([]),w=he.useMemo(()=>m(typeof t=="string"?t:""),[t,m]);he.useEffect(()=>{e==="streaming"?f(()=>{y(w)}):y(w)},[w,e]);let k=e==="streaming"?b:w,C=he.useMemo(()=>k.map((E,D)=>`${g}-${D}`),[k.length,g]),x=he.useMemo(()=>({shikiTheme:s,controls:u,isAnimating:d,mode:e,mermaid:l}),[s,u,d,e,l]),_=he.useMemo(()=>({...eze,...a}),[a]);return he.useEffect(()=>{if(!(Array.isArray(r)&&r.some(T=>Array.isArray(T)?T[0]===ES:T===ES)))return;let E=!1;if(Array.isArray(i)){let T=i.find(N=>Array.isArray(N)?N[0]===c5:N===c5);T&&Array.isArray(T)&&T[1]&&(E=T[1].singleDollarTextMath===!0)}let D=typeof t=="string"?t:"",Q=D.includes("$$"),B=E&&(/[^$]\$[^$]/.test(D)||/^\$[^$]/.test(D)||/[^$]\$$/.test(D));(Q||B)&&Promise.resolve().then(()=>VBt)},[r,i,t]),e==="static"?H.jsx(Ac.Provider,{value:x,children:H.jsx("div",{className:xn("space-y-4 whitespace-normal",o),children:H.jsx(_X,{components:_,rehypePlugins:r,remarkPlugins:i,...A,children:t})})}):H.jsx(Ac.Provider,{value:x,children:H.jsx("div",{className:xn("space-y-4 whitespace-normal",o),children:k.map((E,D)=>H.jsx(p,{components:_,content:E,index:D,rehypePlugins:r,remarkPlugins:i,shouldParseIncompleteMarkdown:n,...A},C[D]))})})},(t,e)=>t.children===e.children&&t.shikiTheme===e.shikiTheme&&t.isAnimating===e.isAnimating&&t.mode===e.mode);G5.displayName="Streamdown";var fze=({children:t,className:e,minZoom:n=.5,maxZoom:a=3,zoomStep:r=.1,showControls:i=!0,initialZoom:o=1,fullscreen:s=!1})=>{let l=he.useRef(null),u=he.useRef(null),[d,p]=he.useState(o),[m,A]=he.useState({x:0,y:0}),[g,h]=he.useState(!1),[f,b]=he.useState({x:0,y:0}),[y,w]=he.useState({x:0,y:0}),k=he.useCallback(T=>{p(N=>Math.max(n,Math.min(a,N+T)))},[n,a]),C=he.useCallback(()=>{k(r)},[k,r]),x=he.useCallback(()=>{k(-r)},[k,r]),_=he.useCallback(()=>{p(o),A({x:0,y:0})},[o]),E=he.useCallback(T=>{T.preventDefault();let N=T.deltaY>0?-r:r;k(N)},[k,r]),D=he.useCallback(T=>{if(T.button!==0||T.isPrimary===!1)return;h(!0),b({x:T.clientX,y:T.clientY}),w(m);let N=T.currentTarget;N instanceof HTMLElement&&N.setPointerCapture(T.pointerId)},[m]),Q=he.useCallback(T=>{if(!g)return;T.preventDefault();let N=T.clientX-f.x,I=T.clientY-f.y;A({x:y.x+N,y:y.y+I})},[g,f,y]),B=he.useCallback(T=>{h(!1);let N=T.currentTarget;N instanceof HTMLElement&&N.releasePointerCapture(T.pointerId)},[]);return he.useEffect(()=>{let T=l.current;if(T)return T.addEventListener("wheel",E,{passive:!1}),()=>{T.removeEventListener("wheel",E)}},[E]),he.useEffect(()=>{let T=u.current;if(T&&g)return document.body.style.userSelect="none",T.addEventListener("pointermove",Q,{passive:!1}),T.addEventListener("pointerup",B),T.addEventListener("pointercancel",B),()=>{document.body.style.userSelect="",T.removeEventListener("pointermove",Q),T.removeEventListener("pointerup",B),T.removeEventListener("pointercancel",B)}},[g,Q,B]),H.jsxs("div",{className:xn("relative",s?"h-full w-full":"w-full",e),ref:l,style:{cursor:g?"grabbing":"grab"},children:[i&&H.jsxs("div",{className:xn("absolute z-10 flex flex-col gap-1 rounded-md border border-border bg-background/90 p-1 shadow-sm backdrop-blur-sm",s?"bottom-4 left-4":"bottom-2 left-2"),children:[H.jsx("button",{className:"flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",disabled:d>=a,onClick:C,title:"Zoom in",type:"button",children:H.jsx(LOe,{size:16})}),H.jsx("button",{className:"flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",disabled:d<=n,onClick:x,title:"Zoom out",type:"button",children:H.jsx(NOe,{size:16})}),H.jsx("button",{className:"flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",onClick:_,title:"Reset zoom and pan",type:"button",children:H.jsx(TOe,{size:16})})]}),H.jsx("div",{className:xn("origin-center transition-transform duration-150 ease-out",s&&"flex w-full items-center justify-center"),onPointerDown:D,ref:u,role:"application",style:{transform:`translate(${m.x}px, ${m.y}px) scale(${d})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:t})]})},EX=({chart:t,className:e,config:n,fullscreen:a=!1,showControls:r=!0})=>{let[i,o]=he.useState(null),[s,l]=he.useState(!0),[u,d]=he.useState(""),[p,m]=he.useState(""),[A,g]=he.useState(0),{mermaid:h}=he.useContext(Ac),f=h==null?void 0:h.errorComponent;if(he.useEffect(()=>{(async()=>{try{o(null),l(!0);let y=await WJ(n),w=t.split("").reduce((x,_)=>(x<<5)-x+_.charCodeAt(0)|0,0),k=`mermaid-${Math.abs(w)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:C}=await y.render(k,t);d(C),m(C)}catch(y){if(!(p||u)){let w=y instanceof Error?y.message:"Failed to render Mermaid chart";o(w)}}finally{l(!1)}})()},[t,n,A]),s&&!u&&!p)return H.jsx("div",{className:xn("my-4 flex justify-center p-4",e),children:H.jsxs("div",{className:"flex items-center space-x-2 text-muted-foreground",children:[H.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-current border-b-2"}),H.jsx("span",{className:"text-sm",children:"Loading diagram..."})]})});if(i&&!u&&!p){let y=()=>g(w=>w+1);return f?H.jsx(f,{chart:t,error:i,retry:y}):H.jsxs("div",{className:xn("rounded-lg border border-red-200 bg-red-50 p-4",e),children:[H.jsxs("p",{className:"font-mono text-red-700 text-sm",children:["Mermaid Error: ",i]}),H.jsxs("details",{className:"mt-2",children:[H.jsx("summary",{className:"cursor-pointer text-red-600 text-xs",children:"Show Code"}),H.jsx("pre",{className:"mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs",children:t})]})]})}let b=u||p;return H.jsx(fze,{className:xn(a?"h-full w-full overflow-hidden":"my-4 overflow-hidden",e),fullscreen:a,maxZoom:3,minZoom:.5,showControls:r,zoomStep:.1,children:H.jsx("div",{"aria-label":"Mermaid chart",className:xn("flex justify-center",a&&"h-full w-full items-center"),dangerouslySetInnerHTML:{__html:b},role:"img"})})};const bze=({className:t,from:e,...n})=>H.jsx("div",{className:Tn("message-box group flex w-full max-w-[95%] flex-col gap-2",e==="user"?"is-user ml-auto justify-end":"is-assistant",t),...n}),yze=({children:t,className:e,...n})=>H.jsx("div",{className:Tn("message-content is-user:dark flex w-fit max-w-full min-w-0 flex-col gap-2 overflow-hidden text-sm","group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground","group-[.is-assistant]:text-foreground",e),...n,children:t});he.createContext(null);const q5=he.memo(({className:t,...e})=>H.jsx(G5,{className:Tn("message-response size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",t),...e}),(t,e)=>t.children===e.children);q5.displayName="MessageResponse";var dB="Collapsible",[wze,D0n]=SA(dB),[kze,z5]=wze(dB),BX=_e.forwardRef((t,e)=>{const{__scopeCollapsible:n,open:a,defaultOpen:r,disabled:i,onOpenChange:o,...s}=t,[l,u]=mf({prop:a,defaultProp:r??!1,onChange:o,caller:dB});return H.jsx(kze,{scope:n,disabled:i,contentId:Hx(),open:l,onOpenToggle:_e.useCallback(()=>u(d=>!d),[u]),children:H.jsx(Kr.div,{"data-state":U5(l),"data-disabled":i?"":void 0,...s,ref:e})})});BX.displayName=dB;var IX="CollapsibleTrigger",DX=_e.forwardRef((t,e)=>{const{__scopeCollapsible:n,...a}=t,r=z5(IX,n);return H.jsx(Kr.button,{type:"button","aria-controls":r.contentId,"aria-expanded":r.open||!1,"data-state":U5(r.open),"data-disabled":r.disabled?"":void 0,disabled:r.disabled,...a,ref:e,onClick:_n(t.onClick,r.onOpenToggle)})});DX.displayName=IX;var H5="CollapsibleContent",QX=_e.forwardRef((t,e)=>{const{forceMount:n,...a}=t,r=z5(H5,t.__scopeCollapsible);return H.jsx(Sp,{present:n||r.open,children:({present:i})=>H.jsx(vze,{...a,ref:e,present:i})})});QX.displayName=H5;var vze=_e.forwardRef((t,e)=>{const{__scopeCollapsible:n,present:a,children:r,...i}=t,o=z5(H5,n),[s,l]=_e.useState(a),u=_e.useRef(null),d=Ji(e,u),p=_e.useRef(0),m=p.current,A=_e.useRef(0),g=A.current,h=o.open||s,f=_e.useRef(h),b=_e.useRef(void 0);return _e.useEffect(()=>{const y=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(y)},[]),id(()=>{const y=u.current;if(y){b.current=b.current||{transitionDuration:y.style.transitionDuration,animationName:y.style.animationName},y.style.transitionDuration="0s",y.style.animationName="none";const w=y.getBoundingClientRect();p.current=w.height,A.current=w.width,f.current||(y.style.transitionDuration=b.current.transitionDuration,y.style.animationName=b.current.animationName),l(a)}},[o.open,a]),H.jsx(Kr.div,{"data-state":U5(o.open),"data-disabled":o.disabled?"":void 0,id:o.contentId,hidden:!h,...i,ref:d,style:{"--radix-collapsible-content-height":m?`${m}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...t.style},children:h&&r})});function U5(t){return t?"open":"closed"}var Cze=BX;function Y5({...t}){return H.jsx(Cze,{"data-slot":"collapsible",...t})}function W5({...t}){return H.jsx(DX,{"data-slot":"collapsible-trigger",...t})}function K5({...t}){return H.jsx(QX,{"data-slot":"collapsible-content",...t})}const SX=he.createContext({});function _ze(t){const e=he.useRef(null);return e.current===null&&(e.current=t()),e.current}const TX=typeof window<"u",xze=TX?he.useLayoutEffect:he.useEffect,Z5=he.createContext(null);function V5(t,e){t.indexOf(e)===-1&&t.push(e)}function J5(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const tu=(t,e,n)=>n>e?e:n<t?t:n;function FX(t,e){return e?`${t}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${e}`:t}var X5={npm_package_exports___require:"./dist/ai-agent.umd.js",npm_package_devDependencies__types_node:"20.2.5",npm_package_devDependencies_tw_animate_css:"1.4.0",npm_package_devDependencies_vitest:"1.2.2",npm_package_devDependencies__testing_library_jest_dom:"6.4.0",npm_config_user_agent:"pnpm/9.10.0 npm/? node/v20.17.0 linux x64",CI:"true",npm_package_devDependencies__testing_library_user_event:"14.5.2",npm_package_dependencies_cmdk:"1.1.1",npm_package_dependencies_embla_carousel_react:"8.6.0",npm_package_devDependencies_vite:"5.0.12",npm_node_execpath:"/opt/hostedtoolcache/node/20.17.0/x64/bin/node",npm_package_publishConfig_access:"public",npm_package_files_0:"dist",npm_package_dependencies__radix_ui_react_tooltip:"1.2.8",HOME:"/home/runner",npm_package_dependencies__radix_ui_react_dialog:"1.1.15",npm_package_dependencies__radix_ui_react_hover_card:"1.1.15",npm_package_devDependencies_classnames:"2.3.2",npm_package_devDependencies_sass:"1.62.1",npm_package_devDependencies_vite_plugin_static_copy:"1.0.0",npm_package_dependencies__radix_ui_react_separator:"1.1.8",npm_package_dependencies_shiki:"3.20.0",npm_config_auto_install_peers:"true",npm_package_dependencies_class_variance_authority:"0.7.1",npm_package_devDependencies_vite_plugin_dts:"3.7.1",npm_package_dependencies__radix_ui_react_dropdown_menu:"2.1.16",npm_package_dependencies__xyflow_react:"12.10.0",npm_package_devDependencies_tailwindcss:"4.1.18",npm_package_devDependencies_typescript:"5.1.3",npm_package_types:"./dist/index.d.ts",npm_package_devDependencies__types_react_dom:"18.3.1",npm_package_devDependencies__vitejs_plugin_react_swc:"3.5.0",npm_package_type:"module",npm_package_exports___default:"./dist/ai-agent.es.js",npm_package_dependencies__radix_ui_react_use_controllable_state:"1.2.2",npm_package_module:"./dist/ai-agent.es.js",npm_package_devDependencies__types_testing_library__jest_dom:"6.0.0",npm_package_dependencies_motion:"12.23.26",npm_package_devDependencies__vitest_coverage_v8:"1.2.2",npm_config_registry:"https://registry.npmjs.org/",npm_config_node_linker:"hoisted",npm_package_dependencies__codemirror_lang_json:"6.0.1",npm_package_dependencies_streamdown:"1.6.10",npm_package_exports___import:"./dist/ai-agent.es.js",npm_package_dependencies_tailwind_merge:"3.4.0",npm_config_node_gyp:"/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules/pnpm/dist/node_modules/node-gyp/bin/node-gyp.js",PATH:"/home/runner/work/avocado/avocado/packages/ai-agent/node_modules/.bin:/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules/pnpm/dist/node-gyp-bin:/home/runner/work/avocado/avocado/node_modules/.bin:/home/runner/work/avocado/avocado/node_modules/.bin:/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules/pnpm/dist/node-gyp-bin:/home/runner/work/avocado/avocado/node_modules/.bin:/opt/hostedtoolcache/node/20.17.0/x64/bin:/home/runner/setup-pnpm/node_modules/.bin:/snap/bin:/home/runner/.local/bin:/opt/pipx_bin:/home/runner/.cargo/bin:/home/runner/.config/composer/vendor/bin:/usr/local/.ghcup/bin:/home/runner/.dotnet/tools:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin",TURBO_HASH:"f12dd1fb9509a194",npm_package_name:"@foris/ai-agent",npm_package_dependencies_postcss:"8.5.6",NODE:"/opt/hostedtoolcache/node/20.17.0/x64/bin/node",npm_package_dependencies__radix_ui_react_select:"2.2.6",npm_package_dependencies_lucide_react:"0.561.0",npm_package_dependencies_tokenlens:"1.3.1",npm_config_frozen_lockfile:"",npm_package_devDependencies__vitest_ui:"1.2.2",npm_config_legacy_peer_deps:"true",LANG:"C.UTF-8",npm_package_dependencies_react_dom:"18.3.1",npm_package_main:"./dist/ai-agent.umd.js",npm_package_dependencies_ai:"5.0.115",npm_package_dependencies_react_markdown:"10.1.0",npm_lifecycle_script:"tsc && vite build",npm_package_dependencies__uiw_react_codemirror:"4.25.4",SHELL:"/bin/bash",NODE_PATH:"/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules/pnpm/bin/node_modules:/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules/pnpm/node_modules:/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules:/home/runner/setup-pnpm/node_modules/.pnpm/node_modules",npm_package_version:"0.8.2",npm_package_dependencies__radix_ui_react_slot:"1.2.4",npm_package_dependencies_nanoid:"5.1.6",npm_package_devDependencies__testing_library_react:"14.2.0",npm_package_devDependencies__types_react:"18.3.1",npm_package_devDependencies_jsdom:"24.0.0",npm_lifecycle_event:"build",npm_package_scripts_build:"tsc && vite build",npm_package_dependencies__ai_sdk_react:"2.0.117",npm_package_dependencies_clsx:"2.1.1",npm_package_devDependencies__foris_tsconfig:"workspace:*",npm_package_scripts_test_watch:"vitest --ui",npm_package_scripts_coverage:"vitest run --coverage",PWD:"/home/runner/work/avocado/avocado/packages/ai-agent",npm_package_dependencies__radix_ui_react_progress:"1.1.8",npm_execpath:"/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules/pnpm/bin/pnpm.cjs",npm_package_exports___types:"./dist/index.d.ts",npm_package_dependencies__radix_ui_react_scroll_area:"1.2.10",npm_package_dependencies__tailwindcss_postcss:"4.1.18",npm_package_devDependencies__shikijs_transformers:"3.20.0",npm_command:"run-script",PNPM_SCRIPT_SRC_DIR:"/home/runner/work/avocado/avocado/packages/ai-agent",npm_package_dependencies__radix_ui_react_collapsible:"1.1.12",npm_package_dependencies_react:"18.3.1",npm_package_dependencies_use_stick_to_bottom:"1.1.1",INIT_CWD:"/home/runner/work/avocado/avocado/packages/ai-agent",NODE_ENV:"production"};let Qw=()=>{},WA=()=>{};typeof process<"u"&&(X5==null?void 0:X5.NODE_ENV)!=="production"&&(Qw=(t,e,n)=>{!t&&typeof console<"u"&&console.warn(FX(e,n))},WA=(t,e,n)=>{if(!t)throw new Error(FX(e,n))});const wd={},LX=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function NX(t){return typeof t=="object"&&t!==null}const MX=t=>/^0[^.\s]+$/u.test(t);function e7(t){let e;return()=>(e===void 0&&(e=t()),e)}const gc=t=>t,Eze=(t,e)=>n=>e(t(n)),Sw=(...t)=>t.reduce(Eze),Tw=(t,e,n)=>{const a=e-t;return a===0?1:(n-t)/a};class t7{constructor(){this.subscriptions=[]}add(e){return V5(this.subscriptions,e),()=>J5(this.subscriptions,e)}notify(e,n,a){const r=this.subscriptions.length;if(r)if(r===1)this.subscriptions[0](e,n,a);else for(let i=0;i<r;i++){const o=this.subscriptions[i];o&&o(e,n,a)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const nu=t=>t*1e3,hc=t=>t/1e3;function RX(t,e){return e?t*(1e3/e):0}const $X=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,Bze=1e-7,Ize=12;function Dze(t,e,n,a,r){let i,o,s=0;do o=e+(n-e)/2,i=$X(o,a,r)-t,i>0?n=o:e=o;while(Math.abs(i)>Bze&&++s<Ize);return o}function Fw(t,e,n,a){if(t===e&&n===a)return gc;const r=i=>Dze(i,0,1,t,n);return i=>i===0||i===1?i:$X(r(i),e,a)}const PX=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,OX=t=>e=>1-t(1-e),jX=Fw(.33,1.53,.69,.99),n7=OX(jX),GX=PX(n7),qX=t=>(t*=2)<1?.5*n7(t):.5*(2-Math.pow(2,-10*(t-1))),a7=t=>1-Math.sin(Math.acos(t)),zX=OX(a7),HX=PX(a7),Qze=Fw(.42,0,1,1),Sze=Fw(0,0,.58,1),UX=Fw(.42,0,.58,1),Tze=t=>Array.isArray(t)&&typeof t[0]!="number",YX=t=>Array.isArray(t)&&typeof t[0]=="number",WX={linear:gc,easeIn:Qze,easeInOut:UX,easeOut:Sze,circIn:a7,circInOut:HX,circOut:zX,backIn:n7,backInOut:GX,backOut:jX,anticipate:qX},Fze=t=>typeof t=="string",KX=t=>{if(YX(t)){WA(t.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[e,n,a,r]=t;return Fw(e,n,a,r)}else if(Fze(t))return WA(WX[t]!==void 0,`Invalid easing type '${t}'`,"invalid-easing-type"),WX[t];return t},pB=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"],ZX={value:null,addProjectionMetrics:null};function Lze(t,e){let n=new Set,a=new Set,r=!1,i=!1;const o=new WeakSet;let s={delta:0,timestamp:0,isProcessing:!1},l=0;function u(p){o.has(p)&&(d.schedule(p),t()),l++,p(s)}const d={schedule:(p,m=!1,A=!1)=>{const h=A&&r?n:a;return m&&o.add(p),h.has(p)||h.add(p),p},cancel:p=>{a.delete(p),o.delete(p)},process:p=>{if(s=p,r){i=!0;return}r=!0,[n,a]=[a,n],n.forEach(u),e&&ZX.value&&ZX.value.frameloop[e].push(l),l=0,n.clear(),r=!1,i&&(i=!1,d.process(p))}};return d}const Nze=40;function VX(t,e){let n=!1,a=!0;const r={delta:0,timestamp:0,isProcessing:!1},i=()=>n=!0,o=pB.reduce((w,k)=>(w[k]=Lze(i,e?k:void 0),w),{}),{setup:s,read:l,resolveKeyframes:u,preUpdate:d,update:p,preRender:m,render:A,postRender:g}=o,h=()=>{const w=wd.useManualTiming?r.timestamp:performance.now();n=!1,wd.useManualTiming||(r.delta=a?1e3/60:Math.max(Math.min(w-r.timestamp,Nze),1)),r.timestamp=w,r.isProcessing=!0,s.process(r),l.process(r),u.process(r),d.process(r),p.process(r),m.process(r),A.process(r),g.process(r),r.isProcessing=!1,n&&e&&(a=!1,t(h))},f=()=>{n=!0,a=!0,r.isProcessing||t(h)};return{schedule:pB.reduce((w,k)=>{const C=o[k];return w[k]=(x,_=!1,E=!1)=>(n||f(),C.schedule(x,_,E)),w},{}),cancel:w=>{for(let k=0;k<pB.length;k++)o[pB[k]].cancel(w)},state:r,steps:o}}const{schedule:Ma,cancel:Hp,state:Li,steps:r7}=VX(typeof requestAnimationFrame<"u"?requestAnimationFrame:gc,!0);let mB;function Mze(){mB=void 0}const Fo={now:()=>(mB===void 0&&Fo.set(Li.isProcessing||wd.useManualTiming?Li.timestamp:performance.now()),mB),set:t=>{mB=t,queueMicrotask(Mze)}},JX=t=>e=>typeof e=="string"&&e.startsWith(t),XX=JX("--"),Rze=JX("var(--"),i7=t=>Rze(t)?$ze.test(t.split("/*")[0].trim()):!1,$ze=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function eee(t){return typeof t!="string"?!1:t.split("/*")[0].includes("var(--")}const Rf={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},Lw={...Rf,transform:t=>tu(0,1,t)},AB={...Rf,default:1},Nw=t=>Math.round(t*1e5)/1e5,o7=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Pze(t){return t==null}const Oze=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,s7=(t,e)=>n=>!!(typeof n=="string"&&Oze.test(n)&&n.startsWith(t)||e&&!Pze(n)&&Object.prototype.hasOwnProperty.call(n,e)),tee=(t,e,n)=>a=>{if(typeof a!="string")return a;const[r,i,o,s]=a.match(o7);return{[t]:parseFloat(r),[e]:parseFloat(i),[n]:parseFloat(o),alpha:s!==void 0?parseFloat(s):1}},jze=t=>tu(0,255,t),c7={...Rf,transform:t=>Math.round(jze(t))},KA={test:s7("rgb","red"),parse:tee("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:a=1})=>"rgba("+c7.transform(t)+", "+c7.transform(e)+", "+c7.transform(n)+", "+Nw(Lw.transform(a))+")"};function Gze(t){let e="",n="",a="",r="";return t.length>5?(e=t.substring(1,3),n=t.substring(3,5),a=t.substring(5,7),r=t.substring(7,9)):(e=t.substring(1,2),n=t.substring(2,3),a=t.substring(3,4),r=t.substring(4,5),e+=e,n+=n,a+=a,r+=r),{red:parseInt(e,16),green:parseInt(n,16),blue:parseInt(a,16),alpha:r?parseInt(r,16)/255:1}}const l7={test:s7("#"),parse:Gze,transform:KA.transform},Mw=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),Up=Mw("deg"),au=Mw("%"),Vt=Mw("px"),qze=Mw("vh"),zze=Mw("vw"),nee={...au,parse:t=>au.parse(t)/100,transform:t=>au.transform(t*100)},$f={test:s7("hsl","hue"),parse:tee("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:a=1})=>"hsla("+Math.round(t)+", "+au.transform(Nw(e))+", "+au.transform(Nw(n))+", "+Nw(Lw.transform(a))+")"},Tr={test:t=>KA.test(t)||l7.test(t)||$f.test(t),parse:t=>KA.test(t)?KA.parse(t):$f.test(t)?$f.parse(t):l7.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?KA.transform(t):$f.transform(t),getAnimatableNone:t=>{const e=Tr.parse(t);return e.alpha=0,Tr.transform(e)}},Hze=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function Uze(t){var e,n;return isNaN(t)&&typeof t=="string"&&(((e=t.match(o7))==null?void 0:e.length)||0)+(((n=t.match(Hze))==null?void 0:n.length)||0)>0}const aee="number",ree="color",Yze="var",Wze="var(",iee="${}",Kze=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function Rw(t){const e=t.toString(),n=[],a={color:[],number:[],var:[]},r=[];let i=0;const s=e.replace(Kze,l=>(Tr.test(l)?(a.color.push(i),r.push(ree),n.push(Tr.parse(l))):l.startsWith(Wze)?(a.var.push(i),r.push(Yze),n.push(l)):(a.number.push(i),r.push(aee),n.push(parseFloat(l))),++i,iee)).split(iee);return{values:n,split:s,indexes:a,types:r}}function oee(t){return Rw(t).values}function see(t){const{split:e,types:n}=Rw(t),a=e.length;return r=>{let i="";for(let o=0;o<a;o++)if(i+=e[o],r[o]!==void 0){const s=n[o];s===aee?i+=Nw(r[o]):s===ree?i+=Tr.transform(r[o]):i+=r[o]}return i}}const Zze=t=>typeof t=="number"?0:Tr.test(t)?Tr.getAnimatableNone(t):t;function Vze(t){const e=oee(t);return see(t)(e.map(Zze))}const Yp={test:Uze,parse:oee,createTransformer:see,getAnimatableNone:Vze};function u7(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*(2/3-n)*6:t}function Jze({hue:t,saturation:e,lightness:n,alpha:a}){t/=360,e/=100,n/=100;let r=0,i=0,o=0;if(!e)r=i=o=n;else{const s=n<.5?n*(1+e):n+e-n*e,l=2*n-s;r=u7(l,s,t+1/3),i=u7(l,s,t),o=u7(l,s,t-1/3)}return{red:Math.round(r*255),green:Math.round(i*255),blue:Math.round(o*255),alpha:a}}function gB(t,e){return n=>n>0?e:t}const or=(t,e,n)=>t+(e-t)*n,d7=(t,e,n)=>{const a=t*t,r=n*(e*e-a)+a;return r<0?0:Math.sqrt(r)},Xze=[l7,KA,$f],eHe=t=>Xze.find(e=>e.test(t));function cee(t){const e=eHe(t);if(Qw(!!e,`'${t}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!e)return!1;let n=e.parse(t);return e===$f&&(n=Jze(n)),n}const lee=(t,e)=>{const n=cee(t),a=cee(e);if(!n||!a)return gB(t,e);const r={...n};return i=>(r.red=d7(n.red,a.red,i),r.green=d7(n.green,a.green,i),r.blue=d7(n.blue,a.blue,i),r.alpha=or(n.alpha,a.alpha,i),KA.transform(r))},p7=new Set(["none","hidden"]);function tHe(t,e){return p7.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function nHe(t,e){return n=>or(t,e,n)}function m7(t){return typeof t=="number"?nHe:typeof t=="string"?i7(t)?gB:Tr.test(t)?lee:iHe:Array.isArray(t)?uee:typeof t=="object"?Tr.test(t)?lee:aHe:gB}function uee(t,e){const n=[...t],a=n.length,r=t.map((i,o)=>m7(i)(i,e[o]));return i=>{for(let o=0;o<a;o++)n[o]=r[o](i);return n}}function aHe(t,e){const n={...t,...e},a={};for(const r in n)t[r]!==void 0&&e[r]!==void 0&&(a[r]=m7(t[r])(t[r],e[r]));return r=>{for(const i in a)n[i]=a[i](r);return n}}function rHe(t,e){const n=[],a={color:0,var:0,number:0};for(let r=0;r<e.values.length;r++){const i=e.types[r],o=t.indexes[i][a[i]],s=t.values[o]??0;n[r]=s,a[i]++}return n}const iHe=(t,e)=>{const n=Yp.createTransformer(e),a=Rw(t),r=Rw(e);return a.indexes.var.length===r.indexes.var.length&&a.indexes.color.length===r.indexes.color.length&&a.indexes.number.length>=r.indexes.number.length?p7.has(t)&&!r.values.length||p7.has(e)&&!a.values.length?tHe(t,e):Sw(uee(rHe(a,r),r.values),n):(Qw(!0,`Complex values '${t}' and '${e}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`,"complex-values-different"),gB(t,e))};function dee(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?or(t,e,n):m7(t)(t,e)}const oHe=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>Ma.update(e,n),stop:()=>Hp(e),now:()=>Li.isProcessing?Li.timestamp:Fo.now()}},pee=(t,e,n=10)=>{let a="";const r=Math.max(Math.round(e/n),2);for(let i=0;i<r;i++)a+=Math.round(t(i/(r-1))*1e4)/1e4+", ";return`linear(${a.substring(0,a.length-2)})`},hB=2e4;function A7(t){let e=0;const n=50;let a=t.next(e);for(;!a.done&&e<hB;)e+=n,a=t.next(e);return e>=hB?1/0:e}function sHe(t,e=100,n){const a=n({...t,keyframes:[0,e]}),r=Math.min(A7(a),hB);return{type:"keyframes",ease:i=>a.next(r*i).value/e,duration:hc(r)}}const cHe=5;function mee(t,e,n){const a=Math.max(e-cHe,0);return RX(n-t(a),e-a)}const sr={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},g7=.001;function lHe({duration:t=sr.duration,bounce:e=sr.bounce,velocity:n=sr.velocity,mass:a=sr.mass}){let r,i;Qw(t<=nu(sr.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let o=1-e;o=tu(sr.minDamping,sr.maxDamping,o),t=tu(sr.minDuration,sr.maxDuration,hc(t)),o<1?(r=u=>{const d=u*o,p=d*t,m=d-n,A=h7(u,o),g=Math.exp(-p);return g7-m/A*g},i=u=>{const p=u*o*t,m=p*n+n,A=Math.pow(o,2)*Math.pow(u,2)*t,g=Math.exp(-p),h=h7(Math.pow(u,2),o);return(-r(u)+g7>0?-1:1)*((m-A)*g)/h}):(r=u=>{const d=Math.exp(-u*t),p=(u-n)*t+1;return-g7+d*p},i=u=>{const d=Math.exp(-u*t),p=(n-u)*(t*t);return d*p});const s=5/t,l=dHe(r,i,s);if(t=nu(t),isNaN(l))return{stiffness:sr.stiffness,damping:sr.damping,duration:t};{const u=Math.pow(l,2)*a;return{stiffness:u,damping:o*2*Math.sqrt(a*u),duration:t}}}const uHe=12;function dHe(t,e,n){let a=n;for(let r=1;r<uHe;r++)a=a-t(a)/e(a);return a}function h7(t,e){return t*Math.sqrt(1-e*e)}const pHe=["duration","bounce"],mHe=["stiffness","damping","mass"];function Aee(t,e){return e.some(n=>t[n]!==void 0)}function AHe(t){let e={velocity:sr.velocity,stiffness:sr.stiffness,damping:sr.damping,mass:sr.mass,isResolvedFromDuration:!1,...t};if(!Aee(t,mHe)&&Aee(t,pHe))if(t.visualDuration){const n=t.visualDuration,a=2*Math.PI/(n*1.2),r=a*a,i=2*tu(.05,1,1-(t.bounce||0))*Math.sqrt(r);e={...e,mass:sr.mass,stiffness:r,damping:i}}else{const n=lHe(t);e={...e,...n,mass:sr.mass},e.isResolvedFromDuration=!0}return e}function fB(t=sr.visualDuration,e=sr.bounce){const n=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:a,restDelta:r}=n;const i=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],s={done:!1,value:i},{stiffness:l,damping:u,mass:d,duration:p,velocity:m,isResolvedFromDuration:A}=AHe({...n,velocity:-hc(n.velocity||0)}),g=m||0,h=u/(2*Math.sqrt(l*d)),f=o-i,b=hc(Math.sqrt(l/d)),y=Math.abs(f)<5;a||(a=y?sr.restSpeed.granular:sr.restSpeed.default),r||(r=y?sr.restDelta.granular:sr.restDelta.default);let w;if(h<1){const C=h7(b,h);w=x=>{const _=Math.exp(-h*b*x);return o-_*((g+h*b*f)/C*Math.sin(C*x)+f*Math.cos(C*x))}}else if(h===1)w=C=>o-Math.exp(-b*C)*(f+(g+b*f)*C);else{const C=b*Math.sqrt(h*h-1);w=x=>{const _=Math.exp(-h*b*x),E=Math.min(C*x,300);return o-_*((g+h*b*f)*Math.sinh(E)+C*f*Math.cosh(E))/C}}const k={calculatedDuration:A&&p||null,next:C=>{const x=w(C);if(A)s.done=C>=p;else{let _=C===0?g:0;h<1&&(_=C===0?nu(g):mee(w,C,x));const E=Math.abs(_)<=a,D=Math.abs(o-x)<=r;s.done=E&&D}return s.value=s.done?o:x,s},toString:()=>{const C=Math.min(A7(k),hB),x=pee(_=>k.next(C*_).value,C,30);return C+"ms "+x},toTransition:()=>{}};return k}fB.applyToOptions=t=>{const e=sHe(t,100,fB);return t.ease=e.ease,t.duration=nu(e.duration),t.type="keyframes",t};function f7({keyframes:t,velocity:e=0,power:n=.8,timeConstant:a=325,bounceDamping:r=10,bounceStiffness:i=500,modifyTarget:o,min:s,max:l,restDelta:u=.5,restSpeed:d}){const p=t[0],m={done:!1,value:p},A=E=>s!==void 0&&E<s||l!==void 0&&E>l,g=E=>s===void 0?l:l===void 0||Math.abs(s-E)<Math.abs(l-E)?s:l;let h=n*e;const f=p+h,b=o===void 0?f:o(f);b!==f&&(h=b-p);const y=E=>-h*Math.exp(-E/a),w=E=>b+y(E),k=E=>{const D=y(E),Q=w(E);m.done=Math.abs(D)<=u,m.value=m.done?b:Q};let C,x;const _=E=>{A(m.value)&&(C=E,x=fB({keyframes:[m.value,g(m.value)],velocity:mee(w,E,m.value),damping:r,stiffness:i,restDelta:u,restSpeed:d}))};return _(0),{calculatedDuration:null,next:E=>{let D=!1;return!x&&C===void 0&&(D=!0,k(E),_(E)),C!==void 0&&E>=C?x.next(E-C):(!D&&k(E),m)}}}function gHe(t,e,n){const a=[],r=n||wd.mix||dee,i=t.length-1;for(let o=0;o<i;o++){let s=r(t[o],t[o+1]);if(e){const l=Array.isArray(e)?e[o]||gc:e;s=Sw(l,s)}a.push(s)}return a}function hHe(t,e,{clamp:n=!0,ease:a,mixer:r}={}){const i=t.length;if(WA(i===e.length,"Both input and output ranges must be the same length","range-length"),i===1)return()=>e[0];if(i===2&&e[0]===e[1])return()=>e[1];const o=t[0]===t[1];t[0]>t[i-1]&&(t=[...t].reverse(),e=[...e].reverse());const s=gHe(e,a,r),l=s.length,u=d=>{if(o&&d<t[0])return e[0];let p=0;if(l>1)for(;p<t.length-2&&!(d<t[p+1]);p++);const m=Tw(t[p],t[p+1],d);return s[p](m)};return n?d=>u(tu(t[0],t[i-1],d)):u}function fHe(t,e){const n=t[t.length-1];for(let a=1;a<=e;a++){const r=Tw(0,e,a);t.push(or(n,1,r))}}function bHe(t){const e=[0];return fHe(e,t.length-1),e}function yHe(t,e){return t.map(n=>n*e)}function wHe(t,e){return t.map(()=>e||UX).splice(0,t.length-1)}function $w({duration:t=300,keyframes:e,times:n,ease:a="easeInOut"}){const r=Tze(a)?a.map(KX):KX(a),i={done:!1,value:e[0]},o=yHe(n&&n.length===e.length?n:bHe(e),t),s=hHe(o,e,{ease:Array.isArray(r)?r:wHe(e,r)});return{calculatedDuration:t,next:l=>(i.value=s(l),i.done=l>=t,i)}}const kHe=t=>t!==null;function b7(t,{repeat:e,repeatType:n="loop"},a,r=1){const i=t.filter(kHe),s=r<0||e&&n!=="loop"&&e%2===1?0:i.length-1;return!s||a===void 0?i[s]:a}const vHe={decay:f7,inertia:f7,tween:$w,keyframes:$w,spring:fB};function gee(t){typeof t.type=="string"&&(t.type=vHe[t.type])}class y7{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,n){return this.finished.then(e,n)}}const CHe=t=>t/100;class w7 extends y7{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{var a,r;const{motionValue:n}=this.options;n&&n.updatedAt!==Fo.now()&&this.tick(Fo.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),(r=(a=this.options).onStop)==null||r.call(a))},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){const{options:e}=this;gee(e);const{type:n=$w,repeat:a=0,repeatDelay:r=0,repeatType:i,velocity:o=0}=e;let{keyframes:s}=e;const l=n||$w;l!==$w&&typeof s[0]!="number"&&(this.mixKeyframes=Sw(CHe,dee(s[0],s[1])),s=[0,100]);const u=l({...e,keyframes:s});i==="mirror"&&(this.mirroredGenerator=l({...e,keyframes:[...s].reverse(),velocity:-o})),u.calculatedDuration===null&&(u.calculatedDuration=A7(u));const{calculatedDuration:d}=u;this.calculatedDuration=d,this.resolvedDuration=d+r,this.totalDuration=this.resolvedDuration*(a+1)-r,this.generator=u}updateTime(e){const n=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(e,n=!1){const{generator:a,totalDuration:r,mixKeyframes:i,mirroredGenerator:o,resolvedDuration:s,calculatedDuration:l}=this;if(this.startTime===null)return a.next(0);const{delay:u=0,keyframes:d,repeat:p,repeatType:m,repeatDelay:A,type:g,onUpdate:h,finalKeyframe:f}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-r/this.speed,this.startTime)),n?this.currentTime=e:this.updateTime(e);const b=this.currentTime-u*(this.playbackSpeed>=0?1:-1),y=this.playbackSpeed>=0?b<0:b>r;this.currentTime=Math.max(b,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=r);let w=this.currentTime,k=a;if(p){const E=Math.min(this.currentTime,r)/s;let D=Math.floor(E),Q=E%1;!Q&&E>=1&&(Q=1),Q===1&&D--,D=Math.min(D,p+1),!!(D%2)&&(m==="reverse"?(Q=1-Q,A&&(Q-=A/s)):m==="mirror"&&(k=o)),w=tu(0,1,Q)*s}const C=y?{done:!1,value:d[0]}:k.next(w);i&&(C.value=i(C.value));let{done:x}=C;!y&&l!==null&&(x=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);const _=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&x);return _&&g!==f7&&(C.value=b7(d,this.options,f,this.speed)),h&&h(C.value),_&&this.finish(),C}then(e,n){return this.finished.then(e,n)}get duration(){return hc(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+hc(e)}get time(){return hc(this.currentTime)}set time(e){var n;e=nu(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),(n=this.driver)==null||n.start(!1)}get speed(){return this.playbackSpeed}set speed(e){this.updateTime(Fo.now());const n=this.playbackSpeed!==e;this.playbackSpeed=e,n&&(this.time=hc(this.currentTime))}play(){var r,i;if(this.isStopped)return;const{driver:e=oHe,startTime:n}=this.options;this.driver||(this.driver=e(o=>this.tick(o))),(i=(r=this.options).onPlay)==null||i.call(r);const a=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=a):this.holdTime!==null?this.startTime=a-this.holdTime:this.startTime||(this.startTime=n??a),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(Fo.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){var e,n;this.notifyFinished(),this.teardown(),this.state="finished",(n=(e=this.options).onComplete)==null||n.call(e)}cancel(){var e,n;this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),(n=(e=this.options).onCancel)==null||n.call(e)}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){var n;return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),(n=this.driver)==null||n.stop(),e.observe(this)}}function _He(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const ZA=t=>t*180/Math.PI,k7=t=>{const e=ZA(Math.atan2(t[1],t[0]));return v7(e)},xHe={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:k7,rotateZ:k7,skewX:t=>ZA(Math.atan(t[1])),skewY:t=>ZA(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},v7=t=>(t=t%360,t<0&&(t+=360),t),hee=k7,fee=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),bee=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),EHe={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:fee,scaleY:bee,scale:t=>(fee(t)+bee(t))/2,rotateX:t=>v7(ZA(Math.atan2(t[6],t[5]))),rotateY:t=>v7(ZA(Math.atan2(-t[2],t[0]))),rotateZ:hee,rotate:hee,skewX:t=>ZA(Math.atan(t[4])),skewY:t=>ZA(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function C7(t){return t.includes("scale")?1:0}function _7(t,e){if(!t||t==="none")return C7(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let a,r;if(n)a=EHe,r=n;else{const s=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);a=xHe,r=s}if(!r)return C7(e);const i=a[e],o=r[1].split(",").map(IHe);return typeof i=="function"?i(o):o[i]}const BHe=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return _7(n,e)};function IHe(t){return parseFloat(t.trim())}const Pf=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Of=new Set(Pf),yee=t=>t===Rf||t===Vt,DHe=new Set(["x","y","z"]),QHe=Pf.filter(t=>!DHe.has(t));function SHe(t){const e=[];return QHe.forEach(n=>{const a=t.getValue(n);a!==void 0&&(e.push([n,a.get()]),a.set(n.startsWith("scale")?1:0))}),e}const Wp={width:({x:t},{paddingLeft:e="0",paddingRight:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),height:({y:t},{paddingTop:e="0",paddingBottom:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),top:(t,{top:e})=>parseFloat(e),left:(t,{left:e})=>parseFloat(e),bottom:({y:t},{top:e})=>parseFloat(e)+(t.max-t.min),right:({x:t},{left:e})=>parseFloat(e)+(t.max-t.min),x:(t,{transform:e})=>_7(e,"x"),y:(t,{transform:e})=>_7(e,"y")};Wp.translateX=Wp.x,Wp.translateY=Wp.y;const VA=new Set;let x7=!1,E7=!1,B7=!1;function wee(){if(E7){const t=Array.from(VA).filter(a=>a.needsMeasurement),e=new Set(t.map(a=>a.element)),n=new Map;e.forEach(a=>{const r=SHe(a);r.length&&(n.set(a,r),a.render())}),t.forEach(a=>a.measureInitialState()),e.forEach(a=>{a.render();const r=n.get(a);r&&r.forEach(([i,o])=>{var s;(s=a.getValue(i))==null||s.set(o)})}),t.forEach(a=>a.measureEndState()),t.forEach(a=>{a.suspendedScrollY!==void 0&&window.scrollTo(0,a.suspendedScrollY)})}E7=!1,x7=!1,VA.forEach(t=>t.complete(B7)),VA.clear()}function kee(){VA.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(E7=!0)})}function THe(){B7=!0,kee(),wee(),B7=!1}class I7{constructor(e,n,a,r,i,o=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=n,this.name=a,this.motionValue=r,this.element=i,this.isAsync=o}scheduleResolve(){this.state="scheduled",this.isAsync?(VA.add(this),x7||(x7=!0,Ma.read(kee),Ma.resolveKeyframes(wee))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:n,element:a,motionValue:r}=this;if(e[0]===null){const i=r==null?void 0:r.get(),o=e[e.length-1];if(i!==void 0)e[0]=i;else if(a&&n){const s=a.readValue(n,o);s!=null&&(e[0]=s)}e[0]===void 0&&(e[0]=o),r&&i===void 0&&r.set(e[0])}_He(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),VA.delete(this)}cancel(){this.state==="scheduled"&&(VA.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const FHe=t=>t.startsWith("--");function LHe(t,e,n){FHe(e)?t.style.setProperty(e,n):t.style[e]=n}const NHe=e7(()=>window.ScrollTimeline!==void 0),MHe={};function RHe(t,e){const n=e7(t);return()=>MHe[e]??n()}const vee=RHe(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),Pw=([t,e,n,a])=>`cubic-bezier(${t}, ${e}, ${n}, ${a})`,Cee={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Pw([0,.65,.55,1]),circOut:Pw([.55,0,1,.45]),backIn:Pw([.31,.01,.66,-.59]),backOut:Pw([.33,1.53,.69,.99])};function _ee(t,e){if(t)return typeof t=="function"?vee()?pee(t,e):"ease-out":YX(t)?Pw(t):Array.isArray(t)?t.map(n=>_ee(n,e)||Cee.easeOut):Cee[t]}function $He(t,e,n,{delay:a=0,duration:r=300,repeat:i=0,repeatType:o="loop",ease:s="easeOut",times:l}={},u=void 0){const d={[e]:n};l&&(d.offset=l);const p=_ee(s,r);Array.isArray(p)&&(d.easing=p);const m={delay:a,duration:r,easing:Array.isArray(p)?"linear":p,fill:"both",iterations:i+1,direction:o==="reverse"?"alternate":"normal"};return u&&(m.pseudoElement=u),t.animate(d,m)}function xee(t){return typeof t=="function"&&"applyToOptions"in t}function PHe({type:t,...e}){return xee(t)&&vee()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class OHe extends y7{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;const{element:n,name:a,keyframes:r,pseudoElement:i,allowFlatten:o=!1,finalKeyframe:s,onComplete:l}=e;this.isPseudoElement=!!i,this.allowFlatten=o,this.options=e,WA(typeof e.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const u=PHe(e);this.animation=$He(n,a,r,u,i),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){const d=b7(r,this.options,s,this.speed);this.updateMotionValue?this.updateMotionValue(d):LHe(n,a,d),this.animation.cancel()}l==null||l(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){var e,n;(n=(e=this.animation).finish)==null||n.call(e)}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:e}=this;e==="idle"||e==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){var e,n;this.isPseudoElement||(n=(e=this.animation).commitStyles)==null||n.call(e)}get duration(){var n,a;const e=((a=(n=this.animation.effect)==null?void 0:n.getComputedTiming)==null?void 0:a.call(n).duration)||0;return hc(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+hc(e)}get time(){return hc(Number(this.animation.currentTime)||0)}set time(e){this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=nu(e)}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,observe:n}){var a;return this.allowFlatten&&((a=this.animation.effect)==null||a.updateTiming({easing:"linear"})),this.animation.onfinish=null,e&&NHe()?(this.animation.timeline=e,gc):n(this)}}const Eee={anticipate:qX,backInOut:GX,circInOut:HX};function jHe(t){return t in Eee}function GHe(t){typeof t.ease=="string"&&jHe(t.ease)&&(t.ease=Eee[t.ease])}const D7=10;class qHe extends OHe{constructor(e){GHe(e),gee(e),super(e),e.startTime!==void 0&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:n,onUpdate:a,onComplete:r,element:i,...o}=this.options;if(!n)return;if(e!==void 0){n.set(e);return}const s=new w7({...o,autoplay:!1}),l=Math.max(D7,Fo.now()-this.startTime),u=tu(0,D7,l-D7);n.setWithVelocity(s.sample(Math.max(0,l-u)).value,s.sample(l).value,u),s.stop()}}const Bee=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Yp.test(t)||t==="0")&&!t.startsWith("url("));function zHe(t){const e=t[0];if(t.length===1)return!0;for(let n=0;n<t.length;n++)if(t[n]!==e)return!0}function HHe(t,e,n,a){const r=t[0];if(r===null)return!1;if(e==="display"||e==="visibility")return!0;const i=t[t.length-1],o=Bee(r,e),s=Bee(i,e);return Qw(o===s,`You are trying to animate ${e} from "${r}" to "${i}". "${o?i:r}" is not an animatable value.`,"value-not-animatable"),!o||!s?!1:zHe(t)||(n==="spring"||xee(n))&&a}function Q7(t){t.duration=0,t.type="keyframes"}const UHe=new Set(["opacity","clipPath","filter","transform"]),YHe=e7(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function WHe(t){var d;const{motionValue:e,name:n,repeatDelay:a,repeatType:r,damping:i,type:o}=t;if(!(((d=e==null?void 0:e.owner)==null?void 0:d.current)instanceof HTMLElement))return!1;const{onUpdate:l,transformTemplate:u}=e.owner.getProps();return YHe()&&n&&UHe.has(n)&&(n!=="transform"||!u)&&!l&&!a&&r!=="mirror"&&i!==0&&o!=="inertia"}const KHe=40;class ZHe extends y7{constructor({autoplay:e=!0,delay:n=0,type:a="keyframes",repeat:r=0,repeatDelay:i=0,repeatType:o="loop",keyframes:s,name:l,motionValue:u,element:d,...p}){var g;super(),this.stop=()=>{var h,f;this._animation&&(this._animation.stop(),(h=this.stopTimeline)==null||h.call(this)),(f=this.keyframeResolver)==null||f.cancel()},this.createdAt=Fo.now();const m={autoplay:e,delay:n,type:a,repeat:r,repeatDelay:i,repeatType:o,name:l,motionValue:u,element:d,...p},A=(d==null?void 0:d.KeyframeResolver)||I7;this.keyframeResolver=new A(s,(h,f,b)=>this.onKeyframesResolved(h,f,m,!b),l,u,d),(g=this.keyframeResolver)==null||g.scheduleResolve()}onKeyframesResolved(e,n,a,r){var f,b;this.keyframeResolver=void 0;const{name:i,type:o,velocity:s,delay:l,isHandoff:u,onUpdate:d}=a;this.resolvedAt=Fo.now(),HHe(e,i,o,s)||((wd.instantAnimations||!l)&&(d==null||d(b7(e,a,n))),e[0]=e[e.length-1],Q7(a),a.repeat=0);const m={startTime:r?this.resolvedAt?this.resolvedAt-this.createdAt>KHe?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...a,keyframes:e},A=!u&&WHe(m),g=(b=(f=m.motionValue)==null?void 0:f.owner)==null?void 0:b.current,h=A?new qHe({...m,element:g}):new w7(m);h.finished.then(()=>{this.notifyFinished()}).catch(gc),this.pendingTimeline&&(this.stopTimeline=h.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=h}get finished(){return this._animation?this.animation.finished:this._finished}then(e,n){return this.finished.finally(e).then(()=>{})}get animation(){var e;return this._animation||((e=this.keyframeResolver)==null||e.resume(),THe()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){var e;this._animation&&this.animation.cancel(),(e=this.keyframeResolver)==null||e.cancel()}}function Iee(t,e,n,a=0,r=1){const i=Array.from(t).sort((u,d)=>u.sortNodePosition(d)).indexOf(e),o=t.size,s=(o-1)*a;return typeof n=="function"?n(i,o):r===1?i*a:s-i*a}const VHe=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function JHe(t){const e=VHe.exec(t);if(!e)return[,];const[,n,a,r]=e;return[`--${n??a}`,r]}const XHe=4;function Dee(t,e,n=1){WA(n<=XHe,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[a,r]=JHe(t);if(!a)return;const i=window.getComputedStyle(e).getPropertyValue(a);if(i){const o=i.trim();return LX(o)?parseFloat(o):o}return i7(r)?Dee(r,e,n+1):r}const eUe={type:"spring",stiffness:500,damping:25,restSpeed:10},tUe=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),nUe={type:"keyframes",duration:.8},aUe={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},rUe=(t,{keyframes:e})=>e.length>2?nUe:Of.has(t)?t.startsWith("scale")?tUe(e[1]):eUe:aUe,iUe=t=>t!==null;function oUe(t,{repeat:e,repeatType:n="loop"},a){const r=t.filter(iUe),i=e&&n!=="loop"&&e%2===1?0:r.length-1;return!i||a===void 0?r[i]:a}function S7(t,e){return(t==null?void 0:t[e])??(t==null?void 0:t.default)??t}function sUe({when:t,delay:e,delayChildren:n,staggerChildren:a,staggerDirection:r,repeat:i,repeatType:o,repeatDelay:s,from:l,elapsed:u,...d}){return!!Object.keys(d).length}const T7=(t,e,n,a={},r,i)=>o=>{const s=S7(a,t)||{},l=s.delay||a.delay||0;let{elapsed:u=0}=a;u=u-nu(l);const d={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...s,delay:-u,onUpdate:m=>{e.set(m),s.onUpdate&&s.onUpdate(m)},onComplete:()=>{o(),s.onComplete&&s.onComplete()},name:t,motionValue:e,element:i?void 0:r};sUe(s)||Object.assign(d,rUe(t,d)),d.duration&&(d.duration=nu(d.duration)),d.repeatDelay&&(d.repeatDelay=nu(d.repeatDelay)),d.from!==void 0&&(d.keyframes[0]=d.from);let p=!1;if((d.type===!1||d.duration===0&&!d.repeatDelay)&&(Q7(d),d.delay===0&&(p=!0)),(wd.instantAnimations||wd.skipAnimations)&&(p=!0,Q7(d),d.delay=0),d.allowFlatten=!s.type&&!s.ease,p&&!i&&e.get()!==void 0){const m=oUe(d.keyframes,s);if(m!==void 0){Ma.update(()=>{d.onUpdate(m),d.onComplete()});return}}return s.isSync?new w7(d):new ZHe(d)};function Qee(t){const e=[{},{}];return t==null||t.values.forEach((n,a)=>{e[0][a]=n.get(),e[1][a]=n.getVelocity()}),e}function F7(t,e,n,a){if(typeof e=="function"){const[r,i]=Qee(a);e=e(n!==void 0?n:t.custom,r,i)}if(typeof e=="string"&&(e=t.variants&&t.variants[e]),typeof e=="function"){const[r,i]=Qee(a);e=e(n!==void 0?n:t.custom,r,i)}return e}function jf(t,e,n){const a=t.getProps();return F7(a,e,n!==void 0?n:a.custom,t)}const See=new Set(["width","height","top","left","right","bottom",...Pf]),Tee=30,cUe=t=>!isNaN(parseFloat(t));class lUe{constructor(e,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=a=>{var i;const r=Fo.now();if(this.updatedAt!==r&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(a),this.current!==this.prev&&((i=this.events.change)==null||i.notify(this.current),this.dependents))for(const o of this.dependents)o.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=n.owner}setCurrent(e){this.current=e,this.updatedAt=Fo.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=cUe(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on("change",e)}on(e,n){this.events[e]||(this.events[e]=new t7);const a=this.events[e].add(n);return e==="change"?()=>{a(),Ma.read(()=>{this.events.change.getSize()||this.stop()})}:a}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,n){this.passiveEffect=e,this.stopPassiveEffect=n}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,n,a){this.set(n),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-a}jump(e,n=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){var e;(e=this.events.change)==null||e.notify(this.current)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const e=Fo.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Tee)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,Tee);return RX(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(e){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=e(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){var e,n;(e=this.dependents)==null||e.clear(),(n=this.events.destroy)==null||n.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function Gf(t,e){return new lUe(t,e)}const L7=t=>Array.isArray(t);function uUe(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,Gf(n))}function dUe(t){return L7(t)?t[t.length-1]||0:t}function pUe(t,e){const n=jf(t,e);let{transitionEnd:a={},transition:r={},...i}=n||{};i={...i,...a};for(const o in i){const s=dUe(i[o]);uUe(t,o,s)}}const no=t=>!!(t&&t.getVelocity);function mUe(t){return!!(no(t)&&t.add)}function N7(t,e){const n=t.getValue("willChange");if(mUe(n))return n.add(e);if(!n&&wd.WillChange){const a=new wd.WillChange("auto");t.addValue("willChange",a),a.add(e)}}function M7(t){return t.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}const Fee="data-"+M7("framerAppearId");function Lee(t){return t.props[Fee]}function AUe({protectedKeys:t,needsAnimating:e},n){const a=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,a}function Nee(t,e,{delay:n=0,transitionOverride:a,type:r}={}){let{transition:i=t.getDefaultTransition(),transitionEnd:o,...s}=e;a&&(i=a);const l=[],u=r&&t.animationState&&t.animationState.getState()[r];for(const d in s){const p=t.getValue(d,t.latestValues[d]??null),m=s[d];if(m===void 0||u&&AUe(u,d))continue;const A={delay:n,...S7(i||{},d)},g=p.get();if(g!==void 0&&!p.isAnimating&&!Array.isArray(m)&&m===g&&!A.velocity)continue;let h=!1;if(window.MotionHandoffAnimation){const b=Lee(t);if(b){const y=window.MotionHandoffAnimation(b,d,Ma);y!==null&&(A.startTime=y,h=!0)}}N7(t,d),p.start(T7(d,p,m,t.shouldReduceMotion&&See.has(d)?{type:!1}:A,t,h));const f=p.animation;f&&l.push(f)}return o&&Promise.all(l).then(()=>{Ma.update(()=>{o&&pUe(t,o)})}),l}function R7(t,e,n={}){var l;const a=jf(t,e,n.type==="exit"?(l=t.presenceContext)==null?void 0:l.custom:void 0);let{transition:r=t.getDefaultTransition()||{}}=a||{};n.transitionOverride&&(r=n.transitionOverride);const i=a?()=>Promise.all(Nee(t,a,n)):()=>Promise.resolve(),o=t.variantChildren&&t.variantChildren.size?(u=0)=>{const{delayChildren:d=0,staggerChildren:p,staggerDirection:m}=r;return gUe(t,e,u,d,p,m,n)}:()=>Promise.resolve(),{when:s}=r;if(s){const[u,d]=s==="beforeChildren"?[i,o]:[o,i];return u().then(()=>d())}else return Promise.all([i(),o(n.delay)])}function gUe(t,e,n=0,a=0,r=0,i=1,o){const s=[];for(const l of t.variantChildren)l.notify("AnimationStart",e),s.push(R7(l,e,{...o,delay:n+(typeof a=="function"?0:a)+Iee(t.variantChildren,l,a,r,i)}).then(()=>l.notify("AnimationComplete",e)));return Promise.all(s)}function hUe(t,e,n={}){t.notify("AnimationStart",e);let a;if(Array.isArray(e)){const r=e.map(i=>R7(t,i,n));a=Promise.all(r)}else if(typeof e=="string")a=R7(t,e,n);else{const r=typeof e=="function"?jf(t,e,n.custom):e;a=Promise.all(Nee(t,r,n))}return a.then(()=>{t.notify("AnimationComplete",e)})}const fUe={test:t=>t==="auto",parse:t=>t},Mee=t=>e=>e.test(t),Ree=[Rf,Vt,au,Up,zze,qze,fUe],$ee=t=>Ree.find(Mee(t));function bUe(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||MX(t):!0}const yUe=new Set(["brightness","contrast","saturate","opacity"]);function wUe(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[a]=n.match(o7)||[];if(!a)return t;const r=n.replace(a,"");let i=yUe.has(e)?1:0;return a!==n&&(i*=100),e+"("+i+r+")"}const kUe=/\b([a-z-]*)\(.*?\)/gu,$7={...Yp,getAnimatableNone:t=>{const e=t.match(kUe);return e?e.map(wUe).join(" "):t}},Pee={...Rf,transform:Math.round},P7={borderWidth:Vt,borderTopWidth:Vt,borderRightWidth:Vt,borderBottomWidth:Vt,borderLeftWidth:Vt,borderRadius:Vt,borderTopLeftRadius:Vt,borderTopRightRadius:Vt,borderBottomRightRadius:Vt,borderBottomLeftRadius:Vt,width:Vt,maxWidth:Vt,height:Vt,maxHeight:Vt,top:Vt,right:Vt,bottom:Vt,left:Vt,inset:Vt,insetBlock:Vt,insetBlockStart:Vt,insetBlockEnd:Vt,insetInline:Vt,insetInlineStart:Vt,insetInlineEnd:Vt,padding:Vt,paddingTop:Vt,paddingRight:Vt,paddingBottom:Vt,paddingLeft:Vt,paddingBlock:Vt,paddingBlockStart:Vt,paddingBlockEnd:Vt,paddingInline:Vt,paddingInlineStart:Vt,paddingInlineEnd:Vt,margin:Vt,marginTop:Vt,marginRight:Vt,marginBottom:Vt,marginLeft:Vt,marginBlock:Vt,marginBlockStart:Vt,marginBlockEnd:Vt,marginInline:Vt,marginInlineStart:Vt,marginInlineEnd:Vt,fontSize:Vt,backgroundPositionX:Vt,backgroundPositionY:Vt,...{rotate:Up,rotateX:Up,rotateY:Up,rotateZ:Up,scale:AB,scaleX:AB,scaleY:AB,scaleZ:AB,skew:Up,skewX:Up,skewY:Up,distance:Vt,translateX:Vt,translateY:Vt,translateZ:Vt,x:Vt,y:Vt,z:Vt,perspective:Vt,transformPerspective:Vt,opacity:Lw,originX:nee,originY:nee,originZ:Vt},zIndex:Pee,fillOpacity:Lw,strokeOpacity:Lw,numOctaves:Pee},vUe={...P7,color:Tr,backgroundColor:Tr,outlineColor:Tr,fill:Tr,stroke:Tr,borderColor:Tr,borderTopColor:Tr,borderRightColor:Tr,borderBottomColor:Tr,borderLeftColor:Tr,filter:$7,WebkitFilter:$7},Oee=t=>vUe[t];function jee(t,e){let n=Oee(t);return n!==$7&&(n=Yp),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const CUe=new Set(["auto","none","0"]);function _Ue(t,e,n){let a=0,r;for(;a<t.length&&!r;){const i=t[a];typeof i=="string"&&!CUe.has(i)&&Rw(i).values.length&&(r=t[a]),a++}if(r&&n)for(const i of e)t[i]=jee(n,r)}class xUe extends I7{constructor(e,n,a,r,i){super(e,n,a,r,i,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:n,name:a}=this;if(!n||!n.current)return;super.readKeyframes();for(let d=0;d<e.length;d++){let p=e[d];if(typeof p=="string"&&(p=p.trim(),i7(p))){const m=Dee(p,n.current);m!==void 0&&(e[d]=m),d===e.length-1&&(this.finalKeyframe=p)}}if(this.resolveNoneKeyframes(),!See.has(a)||e.length!==2)return;const[r,i]=e,o=$ee(r),s=$ee(i),l=eee(r),u=eee(i);if(l!==u&&Wp[a]){this.needsMeasurement=!0;return}if(o!==s)if(yee(o)&&yee(s))for(let d=0;d<e.length;d++){const p=e[d];typeof p=="string"&&(e[d]=parseFloat(p))}else Wp[a]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,a=[];for(let r=0;r<e.length;r++)(e[r]===null||bUe(e[r]))&&a.push(r);a.length&&_Ue(e,a,n)}measureInitialState(){const{element:e,unresolvedKeyframes:n,name:a}=this;if(!e||!e.current)return;a==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Wp[a](e.measureViewportBox(),window.getComputedStyle(e.current)),n[0]=this.measuredOrigin;const r=n[n.length-1];r!==void 0&&e.getValue(a,r).jump(r,!1)}measureEndState(){var s;const{element:e,name:n,unresolvedKeyframes:a}=this;if(!e||!e.current)return;const r=e.getValue(n);r&&r.jump(this.measuredOrigin,!1);const i=a.length-1,o=a[i];a[i]=Wp[n](e.measureViewportBox(),window.getComputedStyle(e.current)),o!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=o),(s=this.removedTransforms)!=null&&s.length&&this.removedTransforms.forEach(([l,u])=>{e.getValue(l).set(u)}),this.resolveNoneKeyframes()}}function EUe(t,e,n){if(t==null)return[];if(t instanceof EventTarget)return[t];if(typeof t=="string"){const r=document.querySelectorAll(t);return r?Array.from(r):[]}return Array.from(t).filter(a=>a!=null)}const Gee=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function BUe(t){return NX(t)&&"offsetHeight"in t}const{schedule:O7,cancel:T0n}=VX(queueMicrotask,!1),nl={x:!1,y:!1};function qee(){return nl.x||nl.y}function IUe(t){return t==="x"||t==="y"?nl[t]?null:(nl[t]=!0,()=>{nl[t]=!1}):nl.x||nl.y?null:(nl.x=nl.y=!0,()=>{nl.x=nl.y=!1})}function zee(t,e){const n=EUe(t),a=new AbortController,r={passive:!0,...e,signal:a.signal};return[n,r,()=>a.abort()]}function Hee(t){return!(t.pointerType==="touch"||qee())}function DUe(t,e,n={}){const[a,r,i]=zee(t,n),o=s=>{if(!Hee(s))return;const{target:l}=s,u=e(l,s);if(typeof u!="function"||!l)return;const d=p=>{Hee(p)&&(u(p),l.removeEventListener("pointerleave",d))};l.addEventListener("pointerleave",d,r)};return a.forEach(s=>{s.addEventListener("pointerenter",o,r)}),i}const Uee=(t,e)=>e?t===e?!0:Uee(t,e.parentElement):!1,j7=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,QUe=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Yee(t){return QUe.has(t.tagName)||t.isContentEditable===!0}const bB=new WeakSet;function Wee(t){return e=>{e.key==="Enter"&&t(e)}}function G7(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const SUe=(t,e)=>{const n=t.currentTarget;if(!n)return;const a=Wee(()=>{if(bB.has(n))return;G7(n,"down");const r=Wee(()=>{G7(n,"up")}),i=()=>G7(n,"cancel");n.addEventListener("keyup",r,e),n.addEventListener("blur",i,e)});n.addEventListener("keydown",a,e),n.addEventListener("blur",()=>n.removeEventListener("keydown",a),e)};function Kee(t){return j7(t)&&!qee()}function TUe(t,e,n={}){const[a,r,i]=zee(t,n),o=s=>{const l=s.currentTarget;if(!Kee(s))return;bB.add(l);const u=e(l,s),d=(A,g)=>{window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",m),bB.has(l)&&bB.delete(l),Kee(A)&&typeof u=="function"&&u(A,{success:g})},p=A=>{d(A,l===window||l===document||n.useGlobalTarget||Uee(l,A.target))},m=A=>{d(A,!1)};window.addEventListener("pointerup",p,r),window.addEventListener("pointercancel",m,r)};return a.forEach(s=>{(n.useGlobalTarget?window:s).addEventListener("pointerdown",o,r),BUe(s)&&(s.addEventListener("focus",u=>SUe(u,r)),!Yee(s)&&!s.hasAttribute("tabindex")&&(s.tabIndex=0))}),i}function Zee(t){return NX(t)&&"ownerSVGElement"in t}function FUe(t){return Zee(t)&&t.tagName==="svg"}const LUe=[...Ree,Tr,Yp],NUe=t=>LUe.find(Mee(t)),Vee=()=>({translate:0,scale:1,origin:0,originPoint:0}),qf=()=>({x:Vee(),y:Vee()}),Jee=()=>({min:0,max:0}),Vr=()=>({x:Jee(),y:Jee()}),q7={current:null},Xee={current:!1},MUe=typeof window<"u";function RUe(){if(Xee.current=!0,!!MUe)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>q7.current=t.matches;t.addEventListener("change",e),e()}else q7.current=!1}const $Ue=new WeakMap;function yB(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function Ow(t){return typeof t=="string"||Array.isArray(t)}const z7=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],H7=["initial",...z7];function wB(t){return yB(t.animate)||H7.some(e=>Ow(t[e]))}function ete(t){return!!(wB(t)||t.variants)}function PUe(t,e,n){for(const a in e){const r=e[a],i=n[a];if(no(r))t.addValue(a,r);else if(no(i))t.addValue(a,Gf(r,{owner:t}));else if(i!==r)if(t.hasValue(a)){const o=t.getValue(a);o.liveStyle===!0?o.jump(r):o.hasAnimated||o.set(r)}else{const o=t.getStaticValue(a);t.addValue(a,Gf(o!==void 0?o:r,{owner:t}))}}for(const a in n)e[a]===void 0&&t.removeValue(a);return e}const tte=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let kB={};function nte(t){kB=t}function OUe(){return kB}class jUe{scrapeMotionValuesFromProps(e,n,a){return{}}constructor({parent:e,props:n,presenceContext:a,reducedMotionConfig:r,blockInitialAnimation:i,visualState:o},s={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=I7,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const m=Fo.now();this.renderScheduledAt<m&&(this.renderScheduledAt=m,Ma.render(this.render,!1,!0))};const{latestValues:l,renderState:u}=o;this.latestValues=l,this.baseTarget={...l},this.initialValues=n.initial?{...l}:{},this.renderState=u,this.parent=e,this.props=n,this.presenceContext=a,this.depth=e?e.depth+1:0,this.reducedMotionConfig=r,this.options=s,this.blockInitialAnimation=!!i,this.isControllingVariants=wB(n),this.isVariantNode=ete(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:d,...p}=this.scrapeMotionValuesFromProps(n,{},this);for(const m in p){const A=p[m];l[m]!==void 0&&no(A)&&A.set(l[m])}}mount(e){var n;this.current=e,$Ue.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((a,r)=>this.bindToMotionValue(r,a)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(Xee.current||RUe(),this.shouldReduceMotion=q7.current),(n=this.parent)==null||n.addChild(this),this.update(this.props,this.presenceContext)}unmount(){var e;this.projection&&this.projection.unmount(),Hp(this.notifyUpdate),Hp(this.render),this.valueSubscriptions.forEach(n=>n()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),(e=this.parent)==null||e.removeChild(this);for(const n in this.events)this.events[n].clear();for(const n in this.features){const a=this.features[n];a&&(a.unmount(),a.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,n){this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)();const a=Of.has(e);a&&this.onBindTransform&&this.onBindTransform();const r=n.on("change",o=>{this.latestValues[e]=o,this.props.onUpdate&&Ma.preRender(this.notifyUpdate),a&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let i;typeof window<"u"&&window.MotionCheckAppearSync&&(i=window.MotionCheckAppearSync(this,e,n)),this.valueSubscriptions.set(e,()=>{r(),i&&i(),n.owner&&n.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in kB){const n=kB[e];if(!n)continue;const{isEnabled:a,Feature:r}=n;if(!this.features[e]&&r&&a(this.props)&&(this.features[e]=new r(this)),this.features[e]){const i=this.features[e];i.isMounted?i.update():(i.mount(),i.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Vr()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,n){this.latestValues[e]=n}update(e,n){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let a=0;a<tte.length;a++){const r=tte[a];this.propEventSubscriptions[r]&&(this.propEventSubscriptions[r](),delete this.propEventSubscriptions[r]);const i="on"+r,o=e[i];o&&(this.propEventSubscriptions[r]=this.on(r,o))}this.prevMotionValues=PUe(this,this.scrapeMotionValuesFromProps(e,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(e),()=>n.variantChildren.delete(e)}addValue(e,n){const a=this.values.get(e);n!==a&&(a&&this.removeValue(e),this.bindToMotionValue(e,n),this.values.set(e,n),this.latestValues[e]=n.get())}removeValue(e){this.values.delete(e);const n=this.valueSubscriptions.get(e);n&&(n(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,n){if(this.props.values&&this.props.values[e])return this.props.values[e];let a=this.values.get(e);return a===void 0&&n!==void 0&&(a=Gf(n===null?void 0:n,{owner:this}),this.addValue(e,a)),a}readValue(e,n){let a=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return a!=null&&(typeof a=="string"&&(LX(a)||MX(a))?a=parseFloat(a):!NUe(a)&&Yp.test(n)&&(a=jee(e,n)),this.setBaseTarget(e,no(a)?a.get():a)),no(a)?a.get():a}setBaseTarget(e,n){this.baseTarget[e]=n}getBaseTarget(e){var i;const{initial:n}=this.props;let a;if(typeof n=="string"||typeof n=="object"){const o=F7(this.props,n,(i=this.presenceContext)==null?void 0:i.custom);o&&(a=o[e])}if(n&&a!==void 0)return a;const r=this.getBaseTargetFromProps(this.props,e);return r!==void 0&&!no(r)?r:this.initialValues[e]!==void 0&&a===void 0?void 0:this.baseTarget[e]}on(e,n){return this.events[e]||(this.events[e]=new t7),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}scheduleRenderMicrotask(){O7.render(this.render)}}class ate extends jUe{constructor(){super(...arguments),this.KeyframeResolver=xUe}sortInstanceNodePosition(e,n){return e.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(e,n){const a=e.style;return a?a[n]:void 0}removeValueFromRenderState(e,{vars:n,style:a}){delete n[e],delete a[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;no(e)&&(this.childSubscription=e.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}class Kp{constructor(e){this.isMounted=!1,this.node=e}update(){}}function rte({top:t,left:e,right:n,bottom:a}){return{x:{min:e,max:n},y:{min:t,max:a}}}function GUe({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function qUe(t,e){if(!e)return t;const n=e({x:t.left,y:t.top}),a=e({x:t.right,y:t.bottom});return{top:n.y,left:n.x,bottom:a.y,right:a.x}}function U7(t){return t===void 0||t===1}function Y7({scale:t,scaleX:e,scaleY:n}){return!U7(t)||!U7(e)||!U7(n)}function JA(t){return Y7(t)||ite(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function ite(t){return ote(t.x)||ote(t.y)}function ote(t){return t&&t!=="0%"}function vB(t,e,n){const a=t-n,r=e*a;return n+r}function ste(t,e,n,a,r){return r!==void 0&&(t=vB(t,r,a)),vB(t,n,a)+e}function W7(t,e=0,n=1,a,r){t.min=ste(t.min,e,n,a,r),t.max=ste(t.max,e,n,a,r)}function cte(t,{x:e,y:n}){W7(t.x,e.translate,e.scale,e.originPoint),W7(t.y,n.translate,n.scale,n.originPoint)}const lte=.999999999999,ute=1.0000000000001;function zUe(t,e,n,a=!1){const r=n.length;if(!r)return;e.x=e.y=1;let i,o;for(let s=0;s<r;s++){i=n[s],o=i.projectionDelta;const{visualElement:l}=i.options;l&&l.props.style&&l.props.style.display==="contents"||(a&&i.options.layoutScroll&&i.scroll&&i!==i.root&&Hf(t,{x:-i.scroll.offset.x,y:-i.scroll.offset.y}),o&&(e.x*=o.x.scale,e.y*=o.y.scale,cte(t,o)),a&&JA(i.latestValues)&&Hf(t,i.latestValues))}e.x<ute&&e.x>lte&&(e.x=1),e.y<ute&&e.y>lte&&(e.y=1)}function zf(t,e){t.min=t.min+e,t.max=t.max+e}function dte(t,e,n,a,r=.5){const i=or(t.min,t.max,r);W7(t,e,n,i,a)}function Hf(t,e){dte(t.x,e.x,e.scaleX,e.scale,e.originX),dte(t.y,e.y,e.scaleY,e.scale,e.originY)}function pte(t,e){return rte(qUe(t.getBoundingClientRect(),e))}function HUe(t,e,n){const a=pte(t,n),{scroll:r}=e;return r&&(zf(a.x,r.offset.x),zf(a.y,r.offset.y)),a}const UUe={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},YUe=Pf.length;function WUe(t,e,n){let a="",r=!0;for(let i=0;i<YUe;i++){const o=Pf[i],s=t[o];if(s===void 0)continue;let l=!0;if(typeof s=="number")l=s===(o.startsWith("scale")?1:0);else{const u=parseFloat(s);l=o.startsWith("scale")?u===1:u===0}if(!l||n){const u=Gee(s,P7[o]);if(!l){r=!1;const d=UUe[o]||o;a+=`${d}(${u}) `}n&&(e[o]=u)}}return a=a.trim(),n?a=n(e,r?"":a):r&&(a="none"),a}function K7(t,e,n){const{style:a,vars:r,transformOrigin:i}=t;let o=!1,s=!1;for(const l in e){const u=e[l];if(Of.has(l)){o=!0;continue}else if(XX(l)){r[l]=u;continue}else{const d=Gee(u,P7[l]);l.startsWith("origin")?(s=!0,i[l]=d):a[l]=d}}if(e.transform||(o||n?a.transform=WUe(e,t.transform,n):a.transform&&(a.transform="none")),s){const{originX:l="50%",originY:u="50%",originZ:d=0}=i;a.transformOrigin=`${l} ${u} ${d}`}}function mte(t,{style:e,vars:n},a,r){const i=t.style;let o;for(o in e)i[o]=e[o];r==null||r.applyProjectionStyles(i,a);for(o in n)i.setProperty(o,n[o])}function Ate(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const jw={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(Vt.test(t))t=parseFloat(t);else return t;const n=Ate(t,e.target.x),a=Ate(t,e.target.y);return`${n}% ${a}%`}},KUe={correct:(t,{treeScale:e,projectionDelta:n})=>{const a=t,r=Yp.parse(t);if(r.length>5)return a;const i=Yp.createTransformer(t),o=typeof r[0]!="number"?1:0,s=n.x.scale*e.x,l=n.y.scale*e.y;r[0+o]/=s,r[1+o]/=l;const u=or(s,l,.5);return typeof r[2+o]=="number"&&(r[2+o]/=u),typeof r[3+o]=="number"&&(r[3+o]/=u),i(r)}},Z7={borderRadius:{...jw,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:jw,borderTopRightRadius:jw,borderBottomLeftRadius:jw,borderBottomRightRadius:jw,boxShadow:KUe};function gte(t,{layout:e,layoutId:n}){return Of.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!Z7[t]||t==="opacity")}function V7(t,e,n){var o;const a=t.style,r=e==null?void 0:e.style,i={};if(!a)return i;for(const s in a)(no(a[s])||r&&no(r[s])||gte(s,t)||((o=n==null?void 0:n.getValue(s))==null?void 0:o.liveStyle)!==void 0)&&(i[s]=a[s]);return i}function ZUe(t){return window.getComputedStyle(t)}class VUe extends ate{constructor(){super(...arguments),this.type="html",this.renderInstance=mte}readValueFromInstance(e,n){var a;if(Of.has(n))return(a=this.projection)!=null&&a.isProjecting?C7(n):BHe(e,n);{const r=ZUe(e),i=(XX(n)?r.getPropertyValue(n):r[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:n}){return pte(e,n)}build(e,n,a){K7(e,n,a.transformTemplate)}scrapeMotionValuesFromProps(e,n,a){return V7(e,n,a)}}const JUe={offset:"stroke-dashoffset",array:"stroke-dasharray"},XUe={offset:"strokeDashoffset",array:"strokeDasharray"};function eYe(t,e,n=1,a=0,r=!0){t.pathLength=1;const i=r?JUe:XUe;t[i.offset]=`${-a}`,t[i.array]=`${e} ${n}`}const tYe=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function hte(t,{attrX:e,attrY:n,attrScale:a,pathLength:r,pathSpacing:i=1,pathOffset:o=0,...s},l,u,d){if(K7(t,s,u),l){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:p,style:m}=t;p.transform&&(m.transform=p.transform,delete p.transform),(m.transform||p.transformOrigin)&&(m.transformOrigin=p.transformOrigin??"50% 50%",delete p.transformOrigin),m.transform&&(m.transformBox=(d==null?void 0:d.transformBox)??"fill-box",delete p.transformBox);for(const A of tYe)p[A]!==void 0&&(m[A]=p[A],delete p[A]);e!==void 0&&(p.x=e),n!==void 0&&(p.y=n),a!==void 0&&(p.scale=a),r!==void 0&&eYe(p,r,i,o,!1)}const fte=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]),bte=t=>typeof t=="string"&&t.toLowerCase()==="svg";function nYe(t,e,n,a){mte(t,e,void 0,a);for(const r in e.attrs)t.setAttribute(fte.has(r)?r:M7(r),e.attrs[r])}function yte(t,e,n){const a=V7(t,e,n);for(const r in t)if(no(t[r])||no(e[r])){const i=Pf.indexOf(r)!==-1?"attr"+r.charAt(0).toUpperCase()+r.substring(1):r;a[i]=t[r]}return a}class aYe extends ate{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Vr}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(Of.has(n)){const a=Oee(n);return a&&a.default||0}return n=fte.has(n)?n:M7(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,a){return yte(e,n,a)}build(e,n,a){hte(e,n,this.isSVGTag,a.transformTemplate,a.style)}renderInstance(e,n,a,r){nYe(e,n,a,r)}mount(e){this.isSVGTag=bte(e.tagName),super.mount(e)}}const rYe=H7.length;function wte(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?wte(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<rYe;n++){const a=H7[n],r=t.props[a];(Ow(r)||r===!1)&&(e[a]=r)}return e}function kte(t,e){if(!Array.isArray(e))return!1;const n=e.length;if(n!==t.length)return!1;for(let a=0;a<n;a++)if(e[a]!==t[a])return!1;return!0}const iYe=[...z7].reverse(),oYe=z7.length;function sYe(t){return e=>Promise.all(e.map(({animation:n,options:a})=>hUe(t,n,a)))}function cYe(t){let e=sYe(t),n=vte(),a=!0;const r=l=>(u,d)=>{var m;const p=jf(t,d,l==="exit"?(m=t.presenceContext)==null?void 0:m.custom:void 0);if(p){const{transition:A,transitionEnd:g,...h}=p;u={...u,...h,...g}}return u};function i(l){e=l(t)}function o(l){const{props:u}=t,d=wte(t.parent)||{},p=[],m=new Set;let A={},g=1/0;for(let f=0;f<oYe;f++){const b=iYe[f],y=n[b],w=u[b]!==void 0?u[b]:d[b],k=Ow(w),C=b===l?y.isActive:null;C===!1&&(g=f);let x=w===d[b]&&w!==u[b]&&k;if(x&&a&&t.manuallyAnimateOnMount&&(x=!1),y.protectedKeys={...A},!y.isActive&&C===null||!w&&!y.prevProp||yB(w)||typeof w=="boolean")continue;const _=lYe(y.prevProp,w);let E=_||b===l&&y.isActive&&!x&&k||f>g&&k,D=!1;const Q=Array.isArray(w)?w:[w];let B=Q.reduce(r(b),{});C===!1&&(B={});const{prevResolvedValues:T={}}=y,N={...T,...B},I=L=>{E=!0,m.has(L)&&(D=!0,m.delete(L)),y.needsAnimating[L]=!0;const F=t.getValue(L);F&&(F.liveStyle=!1)};for(const L in N){const F=B[L],R=T[L];if(A.hasOwnProperty(L))continue;let $=!1;L7(F)&&L7(R)?$=!kte(F,R):$=F!==R,$?F!=null?I(L):m.add(L):F!==void 0&&m.has(L)?I(L):y.protectedKeys[L]=!0}y.prevProp=w,y.prevResolvedValues=B,y.isActive&&(A={...A,...B}),a&&t.blockInitialAnimation&&(E=!1);const S=x&&_;E&&(!S||D)&&p.push(...Q.map(L=>{const F={type:b};if(typeof L=="string"&&a&&!S&&t.manuallyAnimateOnMount&&t.parent){const{parent:R}=t,$=jf(R,L);if(R.enteringChildren&&$){const{delayChildren:P}=$.transition||{};F.delay=Iee(R.enteringChildren,t,P)}}return{animation:L,options:F}}))}if(m.size){const f={};if(typeof u.initial!="boolean"){const b=jf(t,Array.isArray(u.initial)?u.initial[0]:u.initial);b&&b.transition&&(f.transition=b.transition)}m.forEach(b=>{const y=t.getBaseTarget(b),w=t.getValue(b);w&&(w.liveStyle=!0),f[b]=y??null}),p.push({animation:f})}let h=!!p.length;return a&&(u.initial===!1||u.initial===u.animate)&&!t.manuallyAnimateOnMount&&(h=!1),a=!1,h?e(p):Promise.resolve()}function s(l,u){var p;if(n[l].isActive===u)return Promise.resolve();(p=t.variantChildren)==null||p.forEach(m=>{var A;return(A=m.animationState)==null?void 0:A.setActive(l,u)}),n[l].isActive=u;const d=o(l);for(const m in n)n[m].protectedKeys={};return d}return{animateChanges:o,setActive:s,setAnimateFunction:i,getState:()=>n,reset:()=>{n=vte()}}}function lYe(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!kte(e,t):!1}function XA(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function vte(){return{animate:XA(!0),whileInView:XA(),whileHover:XA(),whileTap:XA(),whileDrag:XA(),whileFocus:XA(),exit:XA()}}function Cte(t,e){t.min=e.min,t.max=e.max}function al(t,e){Cte(t.x,e.x),Cte(t.y,e.y)}function _te(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}const xte=1e-4,uYe=1-xte,dYe=1+xte,Ete=.01,pYe=0-Ete,mYe=0+Ete;function Lo(t){return t.max-t.min}function AYe(t,e,n){return Math.abs(t-e)<=n}function Bte(t,e,n,a=.5){t.origin=a,t.originPoint=or(e.min,e.max,t.origin),t.scale=Lo(n)/Lo(e),t.translate=or(n.min,n.max,t.origin)-t.originPoint,(t.scale>=uYe&&t.scale<=dYe||isNaN(t.scale))&&(t.scale=1),(t.translate>=pYe&&t.translate<=mYe||isNaN(t.translate))&&(t.translate=0)}function Gw(t,e,n,a){Bte(t.x,e.x,n.x,a?a.originX:void 0),Bte(t.y,e.y,n.y,a?a.originY:void 0)}function Ite(t,e,n){t.min=n.min+e.min,t.max=t.min+Lo(e)}function gYe(t,e,n){Ite(t.x,e.x,n.x),Ite(t.y,e.y,n.y)}function Dte(t,e,n){t.min=e.min-n.min,t.max=t.min+Lo(e)}function CB(t,e,n){Dte(t.x,e.x,n.x),Dte(t.y,e.y,n.y)}function Qte(t,e,n,a,r){return t-=e,t=vB(t,1/n,a),r!==void 0&&(t=vB(t,1/r,a)),t}function hYe(t,e=0,n=1,a=.5,r,i=t,o=t){if(au.test(e)&&(e=parseFloat(e),e=or(o.min,o.max,e/100)-o.min),typeof e!="number")return;let s=or(i.min,i.max,a);t===i&&(s-=e),t.min=Qte(t.min,e,n,s,r),t.max=Qte(t.max,e,n,s,r)}function Ste(t,e,[n,a,r],i,o){hYe(t,e[n],e[a],e[r],e.scale,i,o)}const fYe=["x","scaleX","originX"],bYe=["y","scaleY","originY"];function Tte(t,e,n,a){Ste(t.x,e,fYe,n?n.x:void 0,a?a.x:void 0),Ste(t.y,e,bYe,n?n.y:void 0,a?a.y:void 0)}function Fte(t){return t.translate===0&&t.scale===1}function Lte(t){return Fte(t.x)&&Fte(t.y)}function Nte(t,e){return t.min===e.min&&t.max===e.max}function yYe(t,e){return Nte(t.x,e.x)&&Nte(t.y,e.y)}function Mte(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function Rte(t,e){return Mte(t.x,e.x)&&Mte(t.y,e.y)}function $te(t){return Lo(t.x)/Lo(t.y)}function Pte(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}function fc(t){return[t("x"),t("y")]}function wYe(t,e,n){let a="";const r=t.x.translate/e.x,i=t.y.translate/e.y,o=(n==null?void 0:n.z)||0;if((r||i||o)&&(a=`translate3d(${r}px, ${i}px, ${o}px) `),(e.x!==1||e.y!==1)&&(a+=`scale(${1/e.x}, ${1/e.y}) `),n){const{transformPerspective:u,rotate:d,rotateX:p,rotateY:m,skewX:A,skewY:g}=n;u&&(a=`perspective(${u}px) ${a}`),d&&(a+=`rotate(${d}deg) `),p&&(a+=`rotateX(${p}deg) `),m&&(a+=`rotateY(${m}deg) `),A&&(a+=`skewX(${A}deg) `),g&&(a+=`skewY(${g}deg) `)}const s=t.x.scale*e.x,l=t.y.scale*e.y;return(s!==1||l!==1)&&(a+=`scale(${s}, ${l})`),a||"none"}const Ote=["TopLeft","TopRight","BottomLeft","BottomRight"],kYe=Ote.length,jte=t=>typeof t=="string"?parseFloat(t):t,Gte=t=>typeof t=="number"||Vt.test(t);function vYe(t,e,n,a,r,i){r?(t.opacity=or(0,n.opacity??1,CYe(a)),t.opacityExit=or(e.opacity??1,0,_Ye(a))):i&&(t.opacity=or(e.opacity??1,n.opacity??1,a));for(let o=0;o<kYe;o++){const s=`border${Ote[o]}Radius`;let l=qte(e,s),u=qte(n,s);if(l===void 0&&u===void 0)continue;l||(l=0),u||(u=0),l===0||u===0||Gte(l)===Gte(u)?(t[s]=Math.max(or(jte(l),jte(u),a),0),(au.test(u)||au.test(l))&&(t[s]+="%")):t[s]=u}(e.rotate||n.rotate)&&(t.rotate=or(e.rotate||0,n.rotate||0,a))}function qte(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const CYe=zte(0,.5,zX),_Ye=zte(.5,.95,gc);function zte(t,e,n){return a=>a<t?0:a>e?1:n(Tw(t,e,a))}function xYe(t,e,n){const a=no(t)?t:Gf(t);return a.start(T7("",a,e,n)),a.animation}function qw(t,e,n,a={passive:!0}){return t.addEventListener(e,n,a),()=>t.removeEventListener(e,n)}const EYe=(t,e)=>t.depth-e.depth;class BYe{constructor(){this.children=[],this.isDirty=!1}add(e){V5(this.children,e),this.isDirty=!0}remove(e){J5(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(EYe),this.isDirty=!1,this.children.forEach(e)}}function IYe(t,e){const n=Fo.now(),a=({timestamp:r})=>{const i=r-n;i>=e&&(Hp(a),t(i-e))};return Ma.setup(a,!0),()=>Hp(a)}function _B(t){return no(t)?t.get():t}class DYe{constructor(){this.members=[]}add(e){V5(this.members,e),e.scheduleRender()}remove(e){if(J5(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(e){const n=this.members.findIndex(r=>e===r);if(n===0)return!1;let a;for(let r=n;r>=0;r--){const i=this.members[r];if(i.isPresent!==!1){a=i;break}}return a?(this.promote(a),!0):!1}promote(e,n){const a=this.lead;if(e!==a&&(this.prevLead=a,this.lead=e,e.show(),a)){a.instance&&a.scheduleRender(),e.scheduleRender();const r=a.options.layoutDependency,i=e.options.layoutDependency;r!==void 0&&i!==void 0&&r===i||(e.resumeFrom=a,n&&(e.resumeFrom.preserveOpacity=!0),a.snapshot&&(e.snapshot=a.snapshot,e.snapshot.latestValues=a.animationValues||a.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0));const{crossfade:s}=e.options;s===!1&&a.hide()}}exitAnimationComplete(){this.members.forEach(e=>{const{options:n,resumingFrom:a}=e;n.onExitComplete&&n.onExitComplete(),a&&a.options.onExitComplete&&a.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}const xB={hasAnimatedSinceResize:!0,hasEverUpdated:!1},J7=["","X","Y","Z"],QYe=1e3;let SYe=0;function X7(t,e,n,a){const{latestValues:r}=e;r[t]&&(n[t]=r[t],e.setStaticValue(t,0),a&&(a[t]=0))}function Hte(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=Lee(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:r,layoutId:i}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",Ma,!(r||i))}const{parent:a}=t;a&&!a.hasCheckedOptimisedAppear&&Hte(a)}function Ute({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:a,resetTransform:r}){return class{constructor(o={},s=e==null?void 0:e()){this.id=SYe++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(LYe),this.nodes.forEach($Ye),this.nodes.forEach(PYe),this.nodes.forEach(NYe)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=o,this.root=s?s.root||s:this,this.path=s?[...s.path,s]:[],this.parent=s,this.depth=s?s.depth+1:0;for(let l=0;l<this.path.length;l++)this.path[l].shouldResetTransform=!0;this.root===this&&(this.nodes=new BYe)}addEventListener(o,s){return this.eventHandlers.has(o)||this.eventHandlers.set(o,new t7),this.eventHandlers.get(o).add(s)}notifyListeners(o,...s){const l=this.eventHandlers.get(o);l&&l.notify(...s)}hasListeners(o){return this.eventHandlers.has(o)}mount(o){if(this.instance)return;this.isSVG=Zee(o)&&!FUe(o),this.instance=o;const{layoutId:s,layout:l,visualElement:u}=this.options;if(u&&!u.current&&u.mount(o),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(l||s)&&(this.isLayoutDirty=!0),t){let d,p=0;const m=()=>this.root.updateBlockedByResize=!1;Ma.read(()=>{p=window.innerWidth}),t(o,()=>{const A=window.innerWidth;A!==p&&(p=A,this.root.updateBlockedByResize=!0,d&&d(),d=IYe(m,250),xB.hasAnimatedSinceResize&&(xB.hasAnimatedSinceResize=!1,this.nodes.forEach(Kte)))})}s&&this.root.registerSharedNode(s,this),this.options.animate!==!1&&u&&(s||l)&&this.addEventListener("didUpdate",({delta:d,hasLayoutChanged:p,hasRelativeLayoutChanged:m,layout:A})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const g=this.options.transition||u.getDefaultTransition()||zYe,{onLayoutAnimationStart:h,onLayoutAnimationComplete:f}=u.getProps(),b=!this.targetLayout||!Rte(this.targetLayout,A),y=!p&&m;if(this.options.layoutRoot||this.resumeFrom||y||p&&(b||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const w={...S7(g,"layout"),onPlay:h,onComplete:f};(u.shouldReduceMotion||this.options.layoutRoot)&&(w.delay=0,w.type=!1),this.startAnimation(w),this.setAnimationOrigin(d,y)}else p||Kte(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=A})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const o=this.getStack();o&&o.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Hp(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(OYe),this.animationId++)}getTransformTemplate(){const{visualElement:o}=this.options;return o&&o.getProps().transformTemplate}willUpdate(o=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&Hte(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let d=0;d<this.path.length;d++){const p=this.path[d];p.shouldResetTransform=!0,p.updateScroll("snapshot"),p.options.layoutRoot&&p.willUpdate(!1)}const{layoutId:s,layout:l}=this.options;if(s===void 0&&!l)return;const u=this.getTransformTemplate();this.prevTransformTemplateValue=u?u(this.latestValues,""):void 0,this.updateSnapshot(),o&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(Yte);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Wte);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(RYe),this.nodes.forEach(TYe),this.nodes.forEach(FYe)):this.nodes.forEach(Wte),this.clearAllSnapshots();const s=Fo.now();Li.delta=tu(0,1e3/60,s-Li.timestamp),Li.timestamp=s,Li.isProcessing=!0,r7.update.process(Li),r7.preRender.process(Li),r7.render.process(Li),Li.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,O7.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(MYe),this.sharedNodes.forEach(jYe)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,Ma.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){Ma.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Lo(this.snapshot.measuredBox.x)&&!Lo(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let l=0;l<this.path.length;l++)this.path[l].updateScroll();const o=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected=Vr(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:s}=this.options;s&&s.notify("LayoutMeasure",this.layout.layoutBox,o?o.layoutBox:void 0)}updateScroll(o="measure"){let s=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===o&&(s=!1),s&&this.instance){const l=a(this.instance);this.scroll={animationId:this.root.animationId,phase:o,isRoot:l,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:l}}}resetTransform(){if(!r)return;const o=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,s=this.projectionDelta&&!Lte(this.projectionDelta),l=this.getTransformTemplate(),u=l?l(this.latestValues,""):void 0,d=u!==this.prevTransformTemplateValue;o&&this.instance&&(s||JA(this.latestValues)||d)&&(r(this.instance,u),this.shouldResetTransform=!1,this.scheduleRender())}measure(o=!0){const s=this.measurePageBox();let l=this.removeElementScroll(s);return o&&(l=this.removeTransform(l)),HYe(l),{animationId:this.root.animationId,measuredBox:s,layoutBox:l,latestValues:{},source:this.id}}measurePageBox(){var u;const{visualElement:o}=this.options;if(!o)return Vr();const s=o.measureViewportBox();if(!(((u=this.scroll)==null?void 0:u.wasRoot)||this.path.some(UYe))){const{scroll:d}=this.root;d&&(zf(s.x,d.offset.x),zf(s.y,d.offset.y))}return s}removeElementScroll(o){var l;const s=Vr();if(al(s,o),(l=this.scroll)!=null&&l.wasRoot)return s;for(let u=0;u<this.path.length;u++){const d=this.path[u],{scroll:p,options:m}=d;d!==this.root&&p&&m.layoutScroll&&(p.wasRoot&&al(s,o),zf(s.x,p.offset.x),zf(s.y,p.offset.y))}return s}applyTransform(o,s=!1){const l=Vr();al(l,o);for(let u=0;u<this.path.length;u++){const d=this.path[u];!s&&d.options.layoutScroll&&d.scroll&&d!==d.root&&Hf(l,{x:-d.scroll.offset.x,y:-d.scroll.offset.y}),JA(d.latestValues)&&Hf(l,d.latestValues)}return JA(this.latestValues)&&Hf(l,this.latestValues),l}removeTransform(o){const s=Vr();al(s,o);for(let l=0;l<this.path.length;l++){const u=this.path[l];if(!u.instance||!JA(u.latestValues))continue;Y7(u.latestValues)&&u.updateSnapshot();const d=Vr(),p=u.measurePageBox();al(d,p),Tte(s,u.latestValues,u.snapshot?u.snapshot.layoutBox:void 0,d)}return JA(this.latestValues)&&Tte(s,this.latestValues),s}setTargetDelta(o){this.targetDelta=o,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(o){this.options={...this.options,...o,crossfade:o.crossfade!==void 0?o.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==Li.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(o=!1){var A;const s=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=s.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=s.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=s.isSharedProjectionDirty);const l=!!this.resumingFrom||this!==s;if(!(o||l&&this.isSharedProjectionDirty||this.isProjectionDirty||(A=this.parent)!=null&&A.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:d,layoutId:p}=this.options;if(!this.layout||!(d||p))return;this.resolvedRelativeTargetAt=Li.timestamp;const m=this.getClosestProjectingParent();m&&this.linkedParentVersion!==m.layoutVersion&&!m.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(m&&m.layout?this.createRelativeTarget(m,this.layout.layoutBox,m.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=Vr(),this.targetWithTransforms=Vr()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),gYe(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):al(this.target,this.layout.layoutBox),cte(this.target,this.targetDelta)):al(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,m&&!!m.resumingFrom==!!this.resumingFrom&&!m.options.layoutScroll&&m.target&&this.animationProgress!==1?this.createRelativeTarget(m,this.target,m.target):this.relativeParent=this.relativeTarget=void 0))}getClosestProjectingParent(){if(!(!this.parent||Y7(this.parent.latestValues)||ite(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(o,s,l){this.relativeParent=o,this.linkedParentVersion=o.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Vr(),this.relativeTargetOrigin=Vr(),CB(this.relativeTargetOrigin,s,l),al(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){var g;const o=this.getLead(),s=!!this.resumingFrom||this!==o;let l=!0;if((this.isProjectionDirty||(g=this.parent)!=null&&g.isProjectionDirty)&&(l=!1),s&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(l=!1),this.resolvedRelativeTargetAt===Li.timestamp&&(l=!1),l)return;const{layout:u,layoutId:d}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(u||d))return;al(this.layoutCorrected,this.layout.layoutBox);const p=this.treeScale.x,m=this.treeScale.y;zUe(this.layoutCorrected,this.treeScale,this.path,s),o.layout&&!o.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(o.target=o.layout.layoutBox,o.targetWithTransforms=Vr());const{target:A}=o;if(!A){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(_te(this.prevProjectionDelta.x,this.projectionDelta.x),_te(this.prevProjectionDelta.y,this.projectionDelta.y)),Gw(this.projectionDelta,this.layoutCorrected,A,this.latestValues),(this.treeScale.x!==p||this.treeScale.y!==m||!Pte(this.projectionDelta.x,this.prevProjectionDelta.x)||!Pte(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",A))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(o=!0){var s;if((s=this.options.visualElement)==null||s.scheduleRender(),o){const l=this.getStack();l&&l.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=qf(),this.projectionDelta=qf(),this.projectionDeltaWithTransform=qf()}setAnimationOrigin(o,s=!1){const l=this.snapshot,u=l?l.latestValues:{},d={...this.latestValues},p=qf();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!s;const m=Vr(),A=l?l.source:void 0,g=this.layout?this.layout.source:void 0,h=A!==g,f=this.getStack(),b=!f||f.members.length<=1,y=!!(h&&!b&&this.options.crossfade===!0&&!this.path.some(qYe));this.animationProgress=0;let w;this.mixTargetDelta=k=>{const C=k/1e3;Zte(p.x,o.x,C),Zte(p.y,o.y,C),this.setTargetDelta(p),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(CB(m,this.layout.layoutBox,this.relativeParent.layout.layoutBox),GYe(this.relativeTarget,this.relativeTargetOrigin,m,C),w&&yYe(this.relativeTarget,w)&&(this.isProjectionDirty=!1),w||(w=Vr()),al(w,this.relativeTarget)),h&&(this.animationValues=d,vYe(d,u,this.latestValues,C,y,b)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=C},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(o){var s,l,u;this.notifyListeners("animationStart"),(s=this.currentAnimation)==null||s.stop(),(u=(l=this.resumingFrom)==null?void 0:l.currentAnimation)==null||u.stop(),this.pendingAnimation&&(Hp(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=Ma.update(()=>{xB.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=Gf(0)),this.currentAnimation=xYe(this.motionValue,[0,1e3],{...o,velocity:0,isSync:!0,onUpdate:d=>{this.mixTargetDelta(d),o.onUpdate&&o.onUpdate(d)},onStop:()=>{},onComplete:()=>{o.onComplete&&o.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const o=this.getStack();o&&o.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(QYe),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const o=this.getLead();let{targetWithTransforms:s,target:l,layout:u,latestValues:d}=o;if(!(!s||!l||!u)){if(this!==o&&this.layout&&u&&tne(this.options.animationType,this.layout.layoutBox,u.layoutBox)){l=this.target||Vr();const p=Lo(this.layout.layoutBox.x);l.x.min=o.target.x.min,l.x.max=l.x.min+p;const m=Lo(this.layout.layoutBox.y);l.y.min=o.target.y.min,l.y.max=l.y.min+m}al(s,l),Hf(s,d),Gw(this.projectionDeltaWithTransform,this.layoutCorrected,s,d)}}registerSharedNode(o,s){this.sharedNodes.has(o)||this.sharedNodes.set(o,new DYe),this.sharedNodes.get(o).add(s);const u=s.options.initialPromotionConfig;s.promote({transition:u?u.transition:void 0,preserveFollowOpacity:u&&u.shouldPreserveFollowOpacity?u.shouldPreserveFollowOpacity(s):void 0})}isLead(){const o=this.getStack();return o?o.lead===this:!0}getLead(){var s;const{layoutId:o}=this.options;return o?((s=this.getStack())==null?void 0:s.lead)||this:this}getPrevLead(){var s;const{layoutId:o}=this.options;return o?(s=this.getStack())==null?void 0:s.prevLead:void 0}getStack(){const{layoutId:o}=this.options;if(o)return this.root.sharedNodes.get(o)}promote({needsReset:o,transition:s,preserveFollowOpacity:l}={}){const u=this.getStack();u&&u.promote(this,l),o&&(this.projectionDelta=void 0,this.needsReset=!0),s&&this.setOptions({transition:s})}relegate(){const o=this.getStack();return o?o.relegate(this):!1}resetSkewAndRotation(){const{visualElement:o}=this.options;if(!o)return;let s=!1;const{latestValues:l}=o;if((l.z||l.rotate||l.rotateX||l.rotateY||l.rotateZ||l.skewX||l.skewY)&&(s=!0),!s)return;const u={};l.z&&X7("z",o,u,this.animationValues);for(let d=0;d<J7.length;d++)X7(`rotate${J7[d]}`,o,u,this.animationValues),X7(`skew${J7[d]}`,o,u,this.animationValues);o.render();for(const d in u)o.setStaticValue(d,u[d]),this.animationValues&&(this.animationValues[d]=u[d]);o.scheduleRender()}applyProjectionStyles(o,s){if(!this.instance||this.isSVG)return;if(!this.isVisible){o.visibility="hidden";return}const l=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,o.visibility="",o.opacity="",o.pointerEvents=_B(s==null?void 0:s.pointerEvents)||"",o.transform=l?l(this.latestValues,""):"none";return}const u=this.getLead();if(!this.projectionDelta||!this.layout||!u.target){this.options.layoutId&&(o.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,o.pointerEvents=_B(s==null?void 0:s.pointerEvents)||""),this.hasProjected&&!JA(this.latestValues)&&(o.transform=l?l({},""):"none",this.hasProjected=!1);return}o.visibility="";const d=u.animationValues||u.latestValues;this.applyTransformsToTarget();let p=wYe(this.projectionDeltaWithTransform,this.treeScale,d);l&&(p=l(d,p)),o.transform=p;const{x:m,y:A}=this.projectionDelta;o.transformOrigin=`${m.origin*100}% ${A.origin*100}% 0`,u.animationValues?o.opacity=u===this?d.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:d.opacityExit:o.opacity=u===this?d.opacity!==void 0?d.opacity:"":d.opacityExit!==void 0?d.opacityExit:0;for(const g in Z7){if(d[g]===void 0)continue;const{correct:h,applyTo:f,isCSSVariable:b}=Z7[g],y=p==="none"?d[g]:h(d[g],u);if(f){const w=f.length;for(let k=0;k<w;k++)o[f[k]]=y}else b?this.options.visualElement.renderState.vars[g]=y:o[g]=y}this.options.layoutId&&(o.pointerEvents=u===this?_B(s==null?void 0:s.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(o=>{var s;return(s=o.currentAnimation)==null?void 0:s.stop()}),this.root.nodes.forEach(Yte),this.root.sharedNodes.clear()}}}function TYe(t){t.updateLayout()}function FYe(t){var n;const e=((n=t.resumeFrom)==null?void 0:n.snapshot)||t.snapshot;if(t.isLead()&&t.layout&&e&&t.hasListeners("didUpdate")){const{layoutBox:a,measuredBox:r}=t.layout,{animationType:i}=t.options,o=e.source!==t.layout.source;i==="size"?fc(p=>{const m=o?e.measuredBox[p]:e.layoutBox[p],A=Lo(m);m.min=a[p].min,m.max=m.min+A}):tne(i,e.layoutBox,a)&&fc(p=>{const m=o?e.measuredBox[p]:e.layoutBox[p],A=Lo(a[p]);m.max=m.min+A,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[p].max=t.relativeTarget[p].min+A)});const s=qf();Gw(s,a,e.layoutBox);const l=qf();o?Gw(l,t.applyTransform(r,!0),e.measuredBox):Gw(l,a,e.layoutBox);const u=!Lte(s);let d=!1;if(!t.resumeFrom){const p=t.getClosestProjectingParent();if(p&&!p.resumeFrom){const{snapshot:m,layout:A}=p;if(m&&A){const g=Vr();CB(g,e.layoutBox,m.layoutBox);const h=Vr();CB(h,a,A.layoutBox),Rte(g,h)||(d=!0),p.options.layoutRoot&&(t.relativeTarget=h,t.relativeTargetOrigin=g,t.relativeParent=p)}}}t.notifyListeners("didUpdate",{layout:a,snapshot:e,delta:l,layoutDelta:s,hasLayoutChanged:u,hasRelativeLayoutChanged:d})}else if(t.isLead()){const{onExitComplete:a}=t.options;a&&a()}t.options.transition=void 0}function LYe(t){t.parent&&(t.isProjecting()||(t.isProjectionDirty=t.parent.isProjectionDirty),t.isSharedProjectionDirty||(t.isSharedProjectionDirty=!!(t.isProjectionDirty||t.parent.isProjectionDirty||t.parent.isSharedProjectionDirty)),t.isTransformDirty||(t.isTransformDirty=t.parent.isTransformDirty))}function NYe(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function MYe(t){t.clearSnapshot()}function Yte(t){t.clearMeasurements()}function Wte(t){t.isLayoutDirty=!1}function RYe(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function Kte(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function $Ye(t){t.resolveTargetDelta()}function PYe(t){t.calcProjection()}function OYe(t){t.resetSkewAndRotation()}function jYe(t){t.removeLeadSnapshot()}function Zte(t,e,n){t.translate=or(e.translate,0,n),t.scale=or(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function Vte(t,e,n,a){t.min=or(e.min,n.min,a),t.max=or(e.max,n.max,a)}function GYe(t,e,n,a){Vte(t.x,e.x,n.x,a),Vte(t.y,e.y,n.y,a)}function qYe(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const zYe={duration:.45,ease:[.4,0,.1,1]},Jte=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),Xte=Jte("applewebkit/")&&!Jte("chrome/")?Math.round:gc;function ene(t){t.min=Xte(t.min),t.max=Xte(t.max)}function HYe(t){ene(t.x),ene(t.y)}function tne(t,e,n){return t==="position"||t==="preserve-aspect"&&!AYe($te(e),$te(n),.2)}function UYe(t){var e;return t!==t.root&&((e=t.scroll)==null?void 0:e.wasRoot)}const YYe=Ute({attachResizeListener:(t,e)=>qw(t,"resize",e),measureScroll:()=>{var t,e;return{x:document.documentElement.scrollLeft||((t=document.body)==null?void 0:t.scrollLeft)||0,y:document.documentElement.scrollTop||((e=document.body)==null?void 0:e.scrollTop)||0}},checkIsScrollRoot:()=>!0}),eT={current:void 0},nne=Ute({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!eT.current){const t=new YYe({});t.mount(window),t.setOptions({layoutScroll:!0}),eT.current=t}return eT.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),ane=he.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function WYe(t=!0){const e=he.useContext(Z5);if(e===null)return[!0,null];const{isPresent:n,onExitComplete:a,register:r}=e,i=he.useId();he.useEffect(()=>{if(t)return r(i)},[t]);const o=he.useCallback(()=>t&&a&&a(i),[i,a,t]);return!n&&a?[!1,o]:[!0]}const rne=he.createContext({strict:!1}),ine={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let one=!1;function KYe(){if(one)return;const t={};for(const e in ine)t[e]={isEnabled:n=>ine[e].some(a=>!!n[a])};nte(t),one=!0}function sne(){return KYe(),OUe()}function ZYe(t){const e=sne();for(const n in t)e[n]={...e[n],...t[n]};nte(e)}const VYe=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function EB(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||VYe.has(t)}let cne=t=>!EB(t);function JYe(t){typeof t=="function"&&(cne=e=>e.startsWith("on")?!EB(e):t(e))}try{JYe(require("@emotion/is-prop-valid").default)}catch{}function XYe(t,e,n){const a={};for(const r in t)r==="values"&&typeof t.values=="object"||(cne(r)||n===!0&&EB(r)||!e&&!EB(r)||t.draggable&&r.startsWith("onDrag"))&&(a[r]=t[r]);return a}const BB=he.createContext({});function eWe(t,e){if(wB(t)){const{initial:n,animate:a}=t;return{initial:n===!1||Ow(n)?n:void 0,animate:Ow(a)?a:void 0}}return t.inherit!==!1?e:{}}function tWe(t){const{initial:e,animate:n}=eWe(t,he.useContext(BB));return he.useMemo(()=>({initial:e,animate:n}),[lne(e),lne(n)])}function lne(t){return Array.isArray(t)?t.join(" "):t}const tT=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function une(t,e,n){for(const a in e)!no(e[a])&&!gte(a,n)&&(t[a]=e[a])}function nWe({transformTemplate:t},e){return he.useMemo(()=>{const n=tT();return K7(n,e,t),Object.assign({},n.vars,n.style)},[e])}function aWe(t,e){const n=t.style||{},a={};return une(a,n,t),Object.assign(a,nWe(t,e)),a}function rWe(t,e){const n={},a=aWe(t,e);return t.drag&&t.dragListener!==!1&&(n.draggable=!1,a.userSelect=a.WebkitUserSelect=a.WebkitTouchCallout="none",a.touchAction=t.drag===!0?"none":`pan-${t.drag==="x"?"y":"x"}`),t.tabIndex===void 0&&(t.onTap||t.onTapStart||t.whileTap)&&(n.tabIndex=0),n.style=a,n}const dne=()=>({...tT(),attrs:{}});function iWe(t,e,n,a){const r=he.useMemo(()=>{const i=dne();return hte(i,e,bte(a),t.transformTemplate,t.style),{...i.attrs,style:{...i.style}}},[e]);if(t.style){const i={};une(i,t.style,t),r.style={...i,...r.style}}return r}const oWe=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function nT(t){return typeof t!="string"||t.includes("-")?!1:!!(oWe.indexOf(t)>-1||/[A-Z]/u.test(t))}function sWe(t,e,n,{latestValues:a},r,i=!1,o){const l=(o??nT(t)?iWe:rWe)(e,a,r,t),u=XYe(e,typeof t=="string",i),d=t!==he.Fragment?{...u,...l,ref:n}:{},{children:p}=e,m=he.useMemo(()=>no(p)?p.get():p,[p]);return he.createElement(t,{...d,children:m})}function cWe({scrapeMotionValuesFromProps:t,createRenderState:e},n,a,r){return{latestValues:lWe(n,a,r,t),renderState:e()}}function lWe(t,e,n,a){const r={},i=a(t,{});for(const m in i)r[m]=_B(i[m]);let{initial:o,animate:s}=t;const l=wB(t),u=ete(t);e&&u&&!l&&t.inherit!==!1&&(o===void 0&&(o=e.initial),s===void 0&&(s=e.animate));let d=n?n.initial===!1:!1;d=d||o===!1;const p=d?s:o;if(p&&typeof p!="boolean"&&!yB(p)){const m=Array.isArray(p)?p:[p];for(let A=0;A<m.length;A++){const g=F7(t,m[A]);if(g){const{transitionEnd:h,transition:f,...b}=g;for(const y in b){let w=b[y];if(Array.isArray(w)){const k=d?w.length-1:0;w=w[k]}w!==null&&(r[y]=w)}for(const y in h)r[y]=h[y]}}}return r}const pne=t=>(e,n)=>{const a=he.useContext(BB),r=he.useContext(Z5),i=()=>cWe(t,e,a,r);return n?i():_ze(i)},uWe=pne({scrapeMotionValuesFromProps:V7,createRenderState:tT}),dWe=pne({scrapeMotionValuesFromProps:yte,createRenderState:dne}),pWe=Symbol.for("motionComponentSymbol");function mWe(t,e,n){const a=he.useRef(n);he.useInsertionEffect(()=>{a.current=n});const r=he.useRef(null);return he.useCallback(i=>{var s;i&&((s=t.onMount)==null||s.call(t,i)),e&&(i?e.mount(i):e.unmount());const o=a.current;if(typeof o=="function")if(i){const l=o(i);typeof l=="function"&&(r.current=l)}else r.current?(r.current(),r.current=null):o(i);else o&&(o.current=i)},[e])}const mne=he.createContext({});function zw(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function AWe(t,e,n,a,r,i){var b,y;const{visualElement:o}=he.useContext(BB),s=he.useContext(rne),l=he.useContext(Z5),u=he.useContext(ane).reducedMotion,d=he.useRef(null),p=he.useRef(!1);a=a||s.renderer,!d.current&&a&&(d.current=a(t,{visualState:e,parent:o,props:n,presenceContext:l,blockInitialAnimation:l?l.initial===!1:!1,reducedMotionConfig:u,isSVG:i}),p.current&&d.current&&(d.current.manuallyAnimateOnMount=!0));const m=d.current,A=he.useContext(mne);m&&!m.projection&&r&&(m.type==="html"||m.type==="svg")&&gWe(d.current,n,r,A);const g=he.useRef(!1);he.useInsertionEffect(()=>{m&&g.current&&m.update(n,l)});const h=n[Fee],f=he.useRef(!!h&&!((b=window.MotionHandoffIsComplete)!=null&&b.call(window,h))&&((y=window.MotionHasOptimisedAnimation)==null?void 0:y.call(window,h)));return xze(()=>{p.current=!0,m&&(g.current=!0,window.MotionIsMounted=!0,m.updateFeatures(),m.scheduleRenderMicrotask(),f.current&&m.animationState&&m.animationState.animateChanges())}),he.useEffect(()=>{m&&(!f.current&&m.animationState&&m.animationState.animateChanges(),f.current&&(queueMicrotask(()=>{var w;(w=window.MotionHandoffMarkAsComplete)==null||w.call(window,h)}),f.current=!1),m.enteringChildren=void 0)}),m}function gWe(t,e,n,a){const{layoutId:r,layout:i,drag:o,dragConstraints:s,layoutScroll:l,layoutRoot:u,layoutCrossfade:d}=e;t.projection=new n(t.latestValues,e["data-framer-portal-id"]?void 0:Ane(t.parent)),t.projection.setOptions({layoutId:r,layout:i,alwaysMeasureLayout:!!o||s&&zw(s),visualElement:t,animationType:typeof i=="string"?i:"both",initialPromotionConfig:a,crossfade:d,layoutScroll:l,layoutRoot:u})}function Ane(t){if(t)return t.options.allowProjection!==!1?t.projection:Ane(t.parent)}function aT(t,{forwardMotionProps:e=!1,type:n}={},a,r){a&&ZYe(a);const i=n?n==="svg":nT(t),o=i?dWe:uWe;function s(u,d){let p;const m={...he.useContext(ane),...u,layoutId:hWe(u)},{isStatic:A}=m,g=tWe(u),h=o(u,A);if(!A&&TX){fWe();const f=bWe(m);p=f.MeasureLayout,g.visualElement=AWe(t,h,m,r,f.ProjectionNode,i)}return H.jsxs(BB.Provider,{value:g,children:[p&&g.visualElement?H.jsx(p,{visualElement:g.visualElement,...m}):null,sWe(t,u,mWe(h,g.visualElement,d),h,A,e,i)]})}s.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const l=he.forwardRef(s);return l[pWe]=t,l}function hWe({layoutId:t}){const e=he.useContext(SX).id;return e&&t!==void 0?e+"-"+t:t}function fWe(t,e){he.useContext(rne).strict}function bWe(t){const e=sne(),{drag:n,layout:a}=e;if(!n&&!a)return{};const r={...n,...a};return{MeasureLayout:n!=null&&n.isEnabled(t)||a!=null&&a.isEnabled(t)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function yWe(t,e){if(typeof Proxy>"u")return aT;const n=new Map,a=(i,o)=>aT(i,o,t,e),r=(i,o)=>a(i,o);return new Proxy(r,{get:(i,o)=>o==="create"?a:(n.has(o)||n.set(o,aT(o,void 0,t,e)),n.get(o))})}const wWe=(t,e)=>e.isSVG??nT(t)?new aYe(e):new VUe(e,{allowProjection:t!==he.Fragment});class kWe extends Kp{constructor(e){super(e),e.animationState||(e.animationState=cYe(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();yB(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:n}=this.node.prevProps||{};e!==n&&this.updateAnimationControlsSubscription()}unmount(){var e;this.node.animationState.reset(),(e=this.unmountControls)==null||e.call(this)}}let vWe=0;class CWe extends Kp{constructor(){super(...arguments),this.id=vWe++}update(){if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:n}=this.node.presenceContext,{isPresent:a}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===a)return;const r=this.node.animationState.setActive("exit",!e);n&&!e&&r.then(()=>{n(this.id)})}mount(){const{register:e,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),e&&(this.unmount=e(this.id))}unmount(){}}const _We={animation:{Feature:kWe},exit:{Feature:CWe}};function Hw(t){return{point:{x:t.pageX,y:t.pageY}}}const xWe=t=>e=>j7(e)&&t(e,Hw(e));function Uw(t,e,n,a){return qw(t,e,xWe(n),a)}const gne=({current:t})=>t?t.ownerDocument.defaultView:null,hne=(t,e)=>Math.abs(t-e);function EWe(t,e){const n=hne(t.x,e.x),a=hne(t.y,e.y);return Math.sqrt(n**2+a**2)}const fne=new Set(["auto","scroll"]);class bne{constructor(e,n,{transformPagePoint:a,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:o=3,element:s}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=A=>{this.handleScroll(A.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const A=iT(this.lastMoveEventInfo,this.history),g=this.startEvent!==null,h=EWe(A.offset,{x:0,y:0})>=this.distanceThreshold;if(!g&&!h)return;const{point:f}=A,{timestamp:b}=Li;this.history.push({...f,timestamp:b});const{onStart:y,onMove:w}=this.handlers;g||(y&&y(this.lastMoveEvent,A),this.startEvent=this.lastMoveEvent),w&&w(this.lastMoveEvent,A)},this.handlePointerMove=(A,g)=>{this.lastMoveEvent=A,this.lastMoveEventInfo=rT(g,this.transformPagePoint),Ma.update(this.updatePoint,!0)},this.handlePointerUp=(A,g)=>{this.end();const{onEnd:h,onSessionEnd:f,resumeAnimation:b}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&b&&b(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const y=iT(A.type==="pointercancel"?this.lastMoveEventInfo:rT(g,this.transformPagePoint),this.history);this.startEvent&&h&&h(A,y),f&&f(A,y)},!j7(e))return;this.dragSnapToOrigin=i,this.handlers=n,this.transformPagePoint=a,this.distanceThreshold=o,this.contextWindow=r||window;const l=Hw(e),u=rT(l,this.transformPagePoint),{point:d}=u,{timestamp:p}=Li;this.history=[{...d,timestamp:p}];const{onSessionStart:m}=n;m&&m(e,iT(u,this.history)),this.removeListeners=Sw(Uw(this.contextWindow,"pointermove",this.handlePointerMove),Uw(this.contextWindow,"pointerup",this.handlePointerUp),Uw(this.contextWindow,"pointercancel",this.handlePointerUp)),s&&this.startScrollTracking(s)}startScrollTracking(e){let n=e.parentElement;for(;n;){const a=getComputedStyle(n);(fne.has(a.overflowX)||fne.has(a.overflowY))&&this.scrollPositions.set(n,{x:n.scrollLeft,y:n.scrollTop}),n=n.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0,passive:!0}),window.addEventListener("scroll",this.onWindowScroll,{passive:!0}),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(e){const n=this.scrollPositions.get(e);if(!n)return;const a=e===window,r=a?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},i={x:r.x-n.x,y:r.y-n.y};i.x===0&&i.y===0||(a?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(e,r),Ma.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Hp(this.updatePoint)}}function rT(t,e){return e?{point:e(t.point)}:t}function yne(t,e){return{x:t.x-e.x,y:t.y-e.y}}function iT({point:t},e){return{point:t,delta:yne(t,wne(e)),offset:yne(t,BWe(e)),velocity:IWe(e,.1)}}function BWe(t){return t[0]}function wne(t){return t[t.length-1]}function IWe(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,a=null;const r=wne(t);for(;n>=0&&(a=t[n],!(r.timestamp-a.timestamp>nu(e)));)n--;if(!a)return{x:0,y:0};const i=hc(r.timestamp-a.timestamp);if(i===0)return{x:0,y:0};const o={x:(r.x-a.x)/i,y:(r.y-a.y)/i};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function DWe(t,{min:e,max:n},a){return e!==void 0&&t<e?t=a?or(e,t,a.min):Math.max(t,e):n!==void 0&&t>n&&(t=a?or(n,t,a.max):Math.min(t,n)),t}function kne(t,e,n){return{min:e!==void 0?t.min+e:void 0,max:n!==void 0?t.max+n-(t.max-t.min):void 0}}function QWe(t,{top:e,left:n,bottom:a,right:r}){return{x:kne(t.x,n,r),y:kne(t.y,e,a)}}function vne(t,e){let n=e.min-t.min,a=e.max-t.max;return e.max-e.min<t.max-t.min&&([n,a]=[a,n]),{min:n,max:a}}function SWe(t,e){return{x:vne(t.x,e.x),y:vne(t.y,e.y)}}function TWe(t,e){let n=.5;const a=Lo(t),r=Lo(e);return r>a?n=Tw(e.min,e.max-a,t.min):a>r&&(n=Tw(t.min,t.max-r,e.min)),tu(0,1,n)}function FWe(t,e){const n={};return e.min!==void 0&&(n.min=e.min-t.min),e.max!==void 0&&(n.max=e.max-t.min),n}const oT=.35;function LWe(t=oT){return t===!1?t=0:t===!0&&(t=oT),{x:Cne(t,"left","right"),y:Cne(t,"top","bottom")}}function Cne(t,e,n){return{min:_ne(t,e),max:_ne(t,n)}}function _ne(t,e){return typeof t=="number"?t:t[e]||0}const NWe=new WeakMap;class MWe{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Vr(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:n=!1,distanceThreshold:a}={}){const{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;const i=p=>{n?(this.stopAnimation(),this.snapToCursor(Hw(p).point)):this.pauseAnimation()},o=(p,m)=>{this.stopAnimation();const{drag:A,dragPropagation:g,onDragStart:h}=this.getProps();if(A&&!g&&(this.openDragLock&&this.openDragLock(),this.openDragLock=IUe(A),!this.openDragLock))return;this.latestPointerEvent=p,this.latestPanInfo=m,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),fc(b=>{let y=this.getAxisMotionValue(b).get()||0;if(au.test(y)){const{projection:w}=this.visualElement;if(w&&w.layout){const k=w.layout.layoutBox[b];k&&(y=Lo(k)*(parseFloat(y)/100))}}this.originPoint[b]=y}),h&&Ma.postRender(()=>h(p,m)),N7(this.visualElement,"transform");const{animationState:f}=this.visualElement;f&&f.setActive("whileDrag",!0)},s=(p,m)=>{this.latestPointerEvent=p,this.latestPanInfo=m;const{dragPropagation:A,dragDirectionLock:g,onDirectionLock:h,onDrag:f}=this.getProps();if(!A&&!this.openDragLock)return;const{offset:b}=m;if(g&&this.currentDirection===null){this.currentDirection=RWe(b),this.currentDirection!==null&&h&&h(this.currentDirection);return}this.updateAxis("x",m.point,b),this.updateAxis("y",m.point,b),this.visualElement.render(),f&&f(p,m)},l=(p,m)=>{this.latestPointerEvent=p,this.latestPanInfo=m,this.stop(p,m),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>fc(p=>{var m;return this.getAnimationState(p)==="paused"&&((m=this.getAxisMotionValue(p).animation)==null?void 0:m.play())}),{dragSnapToOrigin:d}=this.getProps();this.panSession=new bne(e,{onSessionStart:i,onStart:o,onMove:s,onSessionEnd:l,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:d,distanceThreshold:a,contextWindow:gne(this.visualElement),element:this.visualElement.current})}stop(e,n){const a=e||this.latestPointerEvent,r=n||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!r||!a)return;const{velocity:o}=r;this.startAnimation(o);const{onDragEnd:s}=this.getProps();s&&Ma.postRender(()=>s(a,r))}cancel(){this.isDragging=!1;const{projection:e,animationState:n}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:a}=this.getProps();!a&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,n,a){const{drag:r}=this.getProps();if(!a||!IB(e,r,this.currentDirection))return;const i=this.getAxisMotionValue(e);let o=this.originPoint[e]+a[e];this.constraints&&this.constraints[e]&&(o=DWe(o,this.constraints[e],this.elastic[e])),i.set(o)}resolveConstraints(){var i;const{dragConstraints:e,dragElastic:n}=this.getProps(),a=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(i=this.visualElement.projection)==null?void 0:i.layout,r=this.constraints;e&&zw(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&a?this.constraints=QWe(a.layoutBox,e):this.constraints=!1,this.elastic=LWe(n),r!==this.constraints&&a&&this.constraints&&!this.hasMutatedConstraints&&fc(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=FWe(a.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:n}=this.getProps();if(!e||!zw(e))return!1;const a=e.current;WA(a!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:r}=this.visualElement;if(!r||!r.layout)return!1;const i=HUe(a,r.root,this.visualElement.getTransformPagePoint());let o=SWe(r.layout.layoutBox,i);if(n){const s=n(GUe(o));this.hasMutatedConstraints=!!s,s&&(o=rte(s))}return o}startAnimation(e){const{drag:n,dragMomentum:a,dragElastic:r,dragTransition:i,dragSnapToOrigin:o,onDragTransitionEnd:s}=this.getProps(),l=this.constraints||{},u=fc(d=>{if(!IB(d,n,this.currentDirection))return;let p=l&&l[d]||{};o&&(p={min:0,max:0});const m=r?200:1e6,A=r?40:1e7,g={type:"inertia",velocity:a?e[d]:0,bounceStiffness:m,bounceDamping:A,timeConstant:750,restDelta:1,restSpeed:10,...i,...p};return this.startAxisValueAnimation(d,g)});return Promise.all(u).then(s)}startAxisValueAnimation(e,n){const a=this.getAxisMotionValue(e);return N7(this.visualElement,e),a.start(T7(e,a,0,n,this.visualElement,!1))}stopAnimation(){fc(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){fc(e=>{var n;return(n=this.getAxisMotionValue(e).animation)==null?void 0:n.pause()})}getAnimationState(e){var n;return(n=this.getAxisMotionValue(e).animation)==null?void 0:n.state}getAxisMotionValue(e){const n=`_drag${e.toUpperCase()}`,a=this.visualElement.getProps(),r=a[n];return r||this.visualElement.getValue(e,(a.initial?a.initial[e]:void 0)||0)}snapToCursor(e){fc(n=>{const{drag:a}=this.getProps();if(!IB(n,a,this.currentDirection))return;const{projection:r}=this.visualElement,i=this.getAxisMotionValue(n);if(r&&r.layout){const{min:o,max:s}=r.layout.layoutBox[n],l=i.get()||0;i.set(e[n]-or(o,s,.5)+l)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:n}=this.getProps(),{projection:a}=this.visualElement;if(!zw(n)||!a||!this.constraints)return;this.stopAnimation();const r={x:0,y:0};fc(o=>{const s=this.getAxisMotionValue(o);if(s&&this.constraints!==!1){const l=s.get();r[o]=TWe({min:l,max:l},this.constraints[o])}});const{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},""):"none",a.root&&a.root.updateScroll(),a.updateLayout(),this.resolveConstraints(),fc(o=>{if(!IB(o,e,null))return;const s=this.getAxisMotionValue(o),{min:l,max:u}=this.constraints[o];s.set(or(l,u,r[o]))})}addListeners(){if(!this.visualElement.current)return;NWe.set(this.visualElement,this);const e=this.visualElement.current,n=Uw(e,"pointerdown",l=>{const{drag:u,dragListener:d=!0}=this.getProps(),p=l.target,m=p!==e&&Yee(p);u&&d&&!m&&this.start(l)}),a=()=>{const{dragConstraints:l}=this.getProps();zw(l)&&l.current&&(this.constraints=this.resolveRefConstraints())},{projection:r}=this.visualElement,i=r.addEventListener("measure",a);r&&!r.layout&&(r.root&&r.root.updateScroll(),r.updateLayout()),Ma.read(a);const o=qw(window,"resize",()=>this.scalePositionWithinConstraints()),s=r.addEventListener("didUpdate",({delta:l,hasLayoutChanged:u})=>{this.isDragging&&u&&(fc(d=>{const p=this.getAxisMotionValue(d);p&&(this.originPoint[d]+=l[d].translate,p.set(p.get()+l[d].translate))}),this.visualElement.render())});return()=>{o(),n(),i(),s&&s()}}getProps(){const e=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:a=!1,dragPropagation:r=!1,dragConstraints:i=!1,dragElastic:o=oT,dragMomentum:s=!0}=e;return{...e,drag:n,dragDirectionLock:a,dragPropagation:r,dragConstraints:i,dragElastic:o,dragMomentum:s}}}function IB(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function RWe(t,e=10){let n=null;return Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x"),n}class $We extends Kp{constructor(e){super(e),this.removeGroupControls=gc,this.removeListeners=gc,this.controls=new MWe(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||gc}update(){const{dragControls:e}=this.node.getProps(),{dragControls:n}=this.node.prevProps||{};e!==n&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const xne=t=>(e,n)=>{t&&Ma.postRender(()=>t(e,n))};class PWe extends Kp{constructor(){super(...arguments),this.removePointerDownListener=gc}onPointerDown(e){this.session=new bne(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:gne(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:n,onPan:a,onPanEnd:r}=this.node.getProps();return{onSessionStart:xne(e),onStart:xne(n),onMove:a,onEnd:(i,o)=>{delete this.session,r&&Ma.postRender(()=>r(i,o))}}}mount(){this.removePointerDownListener=Uw(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let sT=!1;class OWe extends he.Component{componentDidMount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:a,layoutId:r}=this.props,{projection:i}=e;i&&(n.group&&n.group.add(i),a&&a.register&&r&&a.register(i),sT&&i.root.didUpdate(),i.addEventListener("animationComplete",()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),xB.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:n,visualElement:a,drag:r,isPresent:i}=this.props,{projection:o}=a;return o&&(o.isPresent=i,e.layoutDependency!==n&&o.setOptions({...o.options,layoutDependency:n}),sT=!0,r||e.layoutDependency!==n||n===void 0||e.isPresent!==i?o.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?o.promote():o.relegate()||Ma.postRender(()=>{const s=o.getStack();(!s||!s.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),O7.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:a}=this.props,{projection:r}=e;sT=!0,r&&(r.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(r),a&&a.deregister&&a.deregister(r))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function Ene(t){const[e,n]=WYe(),a=he.useContext(SX);return H.jsx(OWe,{...t,layoutGroup:a,switchLayoutGroup:he.useContext(mne),isPresent:e,safeToRemove:n})}const jWe={pan:{Feature:PWe},drag:{Feature:$We,ProjectionNode:nne,MeasureLayout:Ene}};function Bne(t,e,n){const{props:a}=t;t.animationState&&a.whileHover&&t.animationState.setActive("whileHover",n==="Start");const r="onHover"+n,i=a[r];i&&Ma.postRender(()=>i(e,Hw(e)))}class GWe extends Kp{mount(){const{current:e}=this.node;e&&(this.unmount=DUe(e,(n,a)=>(Bne(this.node,a,"Start"),r=>Bne(this.node,r,"End"))))}unmount(){}}class qWe extends Kp{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=Sw(qw(this.node.current,"focus",()=>this.onFocus()),qw(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Ine(t,e,n){const{props:a}=t;if(t.current instanceof HTMLButtonElement&&t.current.disabled)return;t.animationState&&a.whileTap&&t.animationState.setActive("whileTap",n==="Start");const r="onTap"+(n==="End"?"":n),i=a[r];i&&Ma.postRender(()=>i(e,Hw(e)))}class zWe extends Kp{mount(){const{current:e}=this.node;e&&(this.unmount=TUe(e,(n,a)=>(Ine(this.node,a,"Start"),(r,{success:i})=>Ine(this.node,r,i?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const cT=new WeakMap,lT=new WeakMap,HWe=t=>{const e=cT.get(t.target);e&&e(t)},UWe=t=>{t.forEach(HWe)};function YWe({root:t,...e}){const n=t||document;lT.has(n)||lT.set(n,{});const a=lT.get(n),r=JSON.stringify(e);return a[r]||(a[r]=new IntersectionObserver(UWe,{root:t,...e})),a[r]}function WWe(t,e,n){const a=YWe(e);return cT.set(t,n),a.observe(t),()=>{cT.delete(t),a.unobserve(t)}}const KWe={some:0,all:1};class ZWe extends Kp{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:e={}}=this.node.getProps(),{root:n,margin:a,amount:r="some",once:i}=e,o={root:n?n.current:void 0,rootMargin:a,threshold:typeof r=="number"?r:KWe[r]},s=l=>{const{isIntersecting:u}=l;if(this.isInView===u||(this.isInView=u,i&&!u&&this.hasEnteredView))return;u&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",u);const{onViewportEnter:d,onViewportLeave:p}=this.node.getProps(),m=u?d:p;m&&m(l)};return WWe(this.node.current,o,s)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:n}=this.node;["amount","margin","root"].some(VWe(e,n))&&this.startObserver()}unmount(){}}function VWe({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}const JWe={..._We,...{inView:{Feature:ZWe},tap:{Feature:zWe},focus:{Feature:qWe},hover:{Feature:GWe}},...jWe,...{layout:{ProjectionNode:nne,MeasureLayout:Ene}}},XWe=yWe(JWe,wWe),eKe=({children:t,as:e="p",className:n,duration:a=2,spread:r=2})=>{const i=XWe.create(e),o=he.useMemo(()=>((t==null?void 0:t.length)??0)*r,[t,r]);return H.jsx(i,{animate:{backgroundPosition:"0% center"},className:Tn("relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent","[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]",n),initial:{backgroundPosition:"100% center"},style:{"--spread":`${o}px`,backgroundImage:"var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"},transition:{repeat:Number.POSITIVE_INFINITY,duration:a,ease:"linear"},children:t})},tKe=he.memo(eKe),Dne=he.createContext(null),nKe=()=>{const t=he.useContext(Dne);if(!t)throw new Error("Reasoning components must be used within Reasoning");return t},aKe=1e3,rKe=1e3,Qne=he.memo(({className:t,isStreaming:e=!1,open:n,defaultOpen:a=!0,onOpenChange:r,duration:i,children:o,...s})=>{const[l,u]=mf({prop:n,defaultProp:a,onChange:r}),[d,p]=mf({prop:i,defaultProp:void 0}),[m,A]=he.useState(!1),[g,h]=he.useState(null);he.useEffect(()=>{e?g===null&&h(Date.now()):g!==null&&(p(Math.ceil((Date.now()-g)/rKe)),h(null))},[e,g,p]),he.useEffect(()=>{if(a&&!e&&l&&!m){const b=setTimeout(()=>{u(!1),A(!0)},aKe);return()=>clearTimeout(b)}},[e,l,a,u,m]);const f=b=>{u(b)};return H.jsx(Dne.Provider,{value:{isStreaming:e,isOpen:l,setIsOpen:u,duration:d},children:H.jsx(Y5,{className:Tn("not-prose mb-4",t),onOpenChange:f,open:l,...s,children:o})})}),iKe=(t,e)=>t||e===0?H.jsx(tKe,{duration:1,children:"Thinking..."}):e===void 0?H.jsx("p",{children:"Thought for a few seconds"}):H.jsxs("p",{children:["Thought for ",e," seconds"]}),Sne=he.memo(({className:t,children:e,getThinkingMessage:n=iKe,...a})=>{const{isStreaming:r,isOpen:i,duration:o}=nKe();return H.jsx(W5,{className:Tn("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",t),...a,children:e??H.jsxs(H.Fragment,{children:[H.jsx(wSe,{className:"size-4"}),n(r,o),H.jsx(v9,{className:Tn("size-4 transition-transform",i?"rotate-180":"rotate-0")})]})})}),Tne=he.memo(({className:t,children:e,...n})=>H.jsx(K5,{className:Tn("mt-4 text-sm","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",t),...n,children:H.jsx(G5,{...n,children:e})}));Qne.displayName="Reasoning",Sne.displayName="ReasoningTrigger",Tne.displayName="ReasoningContent";const oKe=({className:t,...e})=>H.jsx(Y5,{className:Tn("not-prose mb-4 text-primary text-xs",t),...e}),sKe=({className:t,count:e,children:n,...a})=>H.jsx(W5,{className:Tn("flex items-center gap-2",t),...a,children:n??H.jsxs(H.Fragment,{children:[H.jsxs("p",{className:"font-medium",children:["Used ",e," sources"]}),H.jsx(v9,{className:"h-4 w-4"})]})}),cKe=({className:t,...e})=>H.jsx(K5,{className:Tn("mt-3 flex w-fit flex-col gap-2","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",t),...e}),lKe=({href:t,title:e,children:n,...a})=>H.jsx("a",{className:"flex items-center gap-2",href:t,rel:"noreferrer",target:"_blank",...a,children:n??H.jsxs(H.Fragment,{children:[H.jsx(ySe,{className:"h-4 w-4"}),H.jsx("span",{className:"block font-medium",children:e})]})}),uKe=Ox("inline-flex items-center justify-center rounded-full border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function dKe({className:t,variant:e,asChild:n=!1,...a}){const r=n?VH:"span";return H.jsx(r,{"data-slot":"badge",className:Tn(uKe({variant:e}),t),...a})}let Fr=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function pKe(t){return uT(t)}function uT(t){return Array.isArray(t)?mKe(t):t instanceof RegExp?t:typeof t=="object"?AKe(t):t}function mKe(t){let e=[];for(let n=0,a=t.length;n<a;n++)e[n]=uT(t[n]);return e}function AKe(t){let e={};for(let n in t)e[n]=uT(t[n]);return e}function Fne(t,...e){return e.forEach(n=>{for(let a in n)t[a]=n[a]}),t}function Lne(t){const e=~t.lastIndexOf("/")||~t.lastIndexOf("\\");return e===0?t:~e===t.length-1?Lne(t.substring(0,t.length-1)):t.substr(~e+1)}var dT=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,DB=class{static hasCaptures(t){return t===null?!1:(dT.lastIndex=0,dT.test(t))}static replaceCaptures(t,e,n){return t.replace(dT,(a,r,i,o)=>{let s=n[parseInt(r||i,10)];if(s){let l=e.substring(s.start,s.end);for(;l[0]===".";)l=l.substring(1);switch(o){case"downcase":return l.toLowerCase();case"upcase":return l.toUpperCase();default:return l}}else return a})}};function Nne(t,e){return t<e?-1:t>e?1:0}function Mne(t,e){if(t===null&&e===null)return 0;if(!t)return-1;if(!e)return 1;let n=t.length,a=e.length;if(n===a){for(let r=0;r<n;r++){let i=Nne(t[r],e[r]);if(i!==0)return i}return 0}return n-a}function Rne(t){return!!(/^#[0-9a-f]{6}$/i.test(t)||/^#[0-9a-f]{8}$/i.test(t)||/^#[0-9a-f]{3}$/i.test(t)||/^#[0-9a-f]{4}$/i.test(t))}function $ne(t){return t.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var Pne=class{constructor(t){We(this,"cache",new Map);this.fn=t}get(t){if(this.cache.has(t))return this.cache.get(t);const e=this.fn(t);return this.cache.set(t,e),e}},QB=class{constructor(e,n,a){We(this,"_cachedMatchRoot",new Pne(e=>this._root.match(e)));this._colorMap=e,this._defaults=n,this._root=a}static createFromRawTheme(e,n){return this.createFromParsedTheme(fKe(e),n)}static createFromParsedTheme(e,n){return yKe(e,n)}getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;const n=e.scopeName,r=this._cachedMatchRoot.get(n).find(i=>gKe(e.parent,i.parentScopes));return r?new One(r.fontStyle,r.foreground,r.background):null}},pT=class t9{constructor(e,n){this.parent=e,this.scopeName=n}static push(e,n){for(const a of n)e=new t9(e,a);return e}static from(...e){let n=null;for(let a=0;a<e.length;a++)n=new t9(n,e[a]);return n}push(e){return new t9(this,e)}getSegments(){let e=this;const n=[];for(;e;)n.push(e.scopeName),e=e.parent;return n.reverse(),n}toString(){return this.getSegments().join(" ")}extends(e){return this===e?!0:this.parent===null?!1:this.parent.extends(e)}getExtensionIfDefined(e){const n=[];let a=this;for(;a&&a!==e;)n.push(a.scopeName),a=a.parent;return a===e?n.reverse():void 0}};function gKe(t,e){if(e.length===0)return!0;for(let n=0;n<e.length;n++){let a=e[n],r=!1;if(a===">"){if(n===e.length-1)return!1;a=e[++n],r=!0}for(;t&&!hKe(t.scopeName,a);){if(r)return!1;t=t.parent}if(!t)return!1;t=t.parent}return!0}function hKe(t,e){return e===t||t.startsWith(e)&&t[e.length]==="."}var One=class{constructor(t,e,n){this.fontStyle=t,this.foregroundId=e,this.backgroundId=n}};function fKe(t){if(!t)return[];if(!t.settings||!Array.isArray(t.settings))return[];let e=t.settings,n=[],a=0;for(let r=0,i=e.length;r<i;r++){let o=e[r];if(!o.settings)continue;let s;if(typeof o.scope=="string"){let p=o.scope;p=p.replace(/^[,]+/,""),p=p.replace(/[,]+$/,""),s=p.split(",")}else Array.isArray(o.scope)?s=o.scope:s=[""];let l=-1;if(typeof o.settings.fontStyle=="string"){l=0;let p=o.settings.fontStyle.split(" ");for(let m=0,A=p.length;m<A;m++)switch(p[m]){case"italic":l=l|1;break;case"bold":l=l|2;break;case"underline":l=l|4;break;case"strikethrough":l=l|8;break}}let u=null;typeof o.settings.foreground=="string"&&Rne(o.settings.foreground)&&(u=o.settings.foreground);let d=null;typeof o.settings.background=="string"&&Rne(o.settings.background)&&(d=o.settings.background);for(let p=0,m=s.length;p<m;p++){let g=s[p].trim().split(" "),h=g[g.length-1],f=null;g.length>1&&(f=g.slice(0,g.length-1),f.reverse()),n[a++]=new bKe(h,f,r,l,u,d)}}return n}var bKe=class{constructor(t,e,n,a,r,i){this.scope=t,this.parentScopes=e,this.index=n,this.fontStyle=a,this.foreground=r,this.background=i}},ao=(t=>(t[t.NotSet=-1]="NotSet",t[t.None=0]="None",t[t.Italic=1]="Italic",t[t.Bold=2]="Bold",t[t.Underline=4]="Underline",t[t.Strikethrough=8]="Strikethrough",t))(ao||{});function yKe(t,e){t.sort((l,u)=>{let d=Nne(l.scope,u.scope);return d!==0||(d=Mne(l.parentScopes,u.parentScopes),d!==0)?d:l.index-u.index});let n=0,a="#000000",r="#ffffff";for(;t.length>=1&&t[0].scope==="";){let l=t.shift();l.fontStyle!==-1&&(n=l.fontStyle),l.foreground!==null&&(a=l.foreground),l.background!==null&&(r=l.background)}let i=new wKe(e),o=new One(n,i.getId(a),i.getId(r)),s=new vKe(new mT(0,null,-1,0,0),[]);for(let l=0,u=t.length;l<u;l++){let d=t[l];s.insert(0,d.scope,d.parentScopes,d.fontStyle,i.getId(d.foreground),i.getId(d.background))}return new QB(i,o,s)}var wKe=class{constructor(t){We(this,"_isFrozen");We(this,"_lastColorId");We(this,"_id2color");We(this,"_color2id");if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(t)){this._isFrozen=!0;for(let e=0,n=t.length;e<n;e++)this._color2id[t[e]]=e,this._id2color[e]=t[e]}else this._isFrozen=!1}getId(t){if(t===null)return 0;t=t.toUpperCase();let e=this._color2id[t];if(e)return e;if(this._isFrozen)throw new Error(`Missing color in color map - ${t}`);return e=++this._lastColorId,this._color2id[t]=e,this._id2color[e]=t,e}getColorMap(){return this._id2color.slice(0)}},kKe=Object.freeze([]),mT=class $De{constructor(e,n,a,r,i){We(this,"scopeDepth");We(this,"parentScopes");We(this,"fontStyle");We(this,"foreground");We(this,"background");this.scopeDepth=e,this.parentScopes=n||kKe,this.fontStyle=a,this.foreground=r,this.background=i}clone(){return new $De(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let n=[];for(let a=0,r=e.length;a<r;a++)n[a]=e[a].clone();return n}acceptOverwrite(e,n,a,r){this.scopeDepth>e?console.log("how did this happen?"):this.scopeDepth=e,n!==-1&&(this.fontStyle=n),a!==0&&(this.foreground=a),r!==0&&(this.background=r)}},vKe=class GH{constructor(e,n=[],a={}){We(this,"_rulesWithParentScopes");this._mainRule=e,this._children=a,this._rulesWithParentScopes=n}static _cmpBySpecificity(e,n){if(e.scopeDepth!==n.scopeDepth)return n.scopeDepth-e.scopeDepth;let a=0,r=0;for(;e.parentScopes[a]===">"&&a++,n.parentScopes[r]===">"&&r++,!(a>=e.parentScopes.length||r>=n.parentScopes.length);){const i=n.parentScopes[r].length-e.parentScopes[a].length;if(i!==0)return i;a++,r++}return n.parentScopes.length-e.parentScopes.length}match(e){if(e!==""){let a=e.indexOf("."),r,i;if(a===-1?(r=e,i=""):(r=e.substring(0,a),i=e.substring(a+1)),this._children.hasOwnProperty(r))return this._children[r].match(i)}const n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(GH._cmpBySpecificity),n}insert(e,n,a,r,i,o){if(n===""){this._doInsertHere(e,a,r,i,o);return}let s=n.indexOf("."),l,u;s===-1?(l=n,u=""):(l=n.substring(0,s),u=n.substring(s+1));let d;this._children.hasOwnProperty(l)?d=this._children[l]:(d=new GH(this._mainRule.clone(),mT.cloneArr(this._rulesWithParentScopes)),this._children[l]=d),d.insert(e+1,u,a,r,i,o)}_doInsertHere(e,n,a,r,i){if(n===null){this._mainRule.acceptOverwrite(e,a,r,i);return}for(let o=0,s=this._rulesWithParentScopes.length;o<s;o++){let l=this._rulesWithParentScopes[o];if(Mne(l.parentScopes,n)===0){l.acceptOverwrite(e,a,r,i);return}}a===-1&&(a=this._mainRule.fontStyle),r===0&&(r=this._mainRule.foreground),i===0&&(i=this._mainRule.background),this._rulesWithParentScopes.push(new mT(e,n,a,r,i))}},Uf=class Zc{static toBinaryStr(e){return e.toString(2).padStart(32,"0")}static print(e){const n=Zc.getLanguageId(e),a=Zc.getTokenType(e),r=Zc.getFontStyle(e),i=Zc.getForeground(e),o=Zc.getBackground(e);console.log({languageId:n,tokenType:a,fontStyle:r,foreground:i,background:o})}static getLanguageId(e){return(e&255)>>>0}static getTokenType(e){return(e&768)>>>8}static containsBalancedBrackets(e){return(e&1024)!==0}static getFontStyle(e){return(e&30720)>>>11}static getForeground(e){return(e&16744448)>>>15}static getBackground(e){return(e&4278190080)>>>24}static set(e,n,a,r,i,o,s){let l=Zc.getLanguageId(e),u=Zc.getTokenType(e),d=Zc.containsBalancedBrackets(e)?1:0,p=Zc.getFontStyle(e),m=Zc.getForeground(e),A=Zc.getBackground(e);return n!==0&&(l=n),a!==8&&(u=a),r!==null&&(d=r?1:0),i!==-1&&(p=i),o!==0&&(m=o),s!==0&&(A=s),(l<<0|u<<8|d<<10|p<<11|m<<15|A<<24)>>>0}};function N0n(t){return t}function M0n(t){return t}function SB(t,e){const n=[],a=CKe(t);let r=a.next();for(;r!==null;){let l=0;if(r.length===2&&r.charAt(1)===":"){switch(r.charAt(0)){case"R":l=1;break;case"L":l=-1;break;default:console.log(`Unknown priority ${r} in scope selector`)}r=a.next()}let u=o();if(n.push({matcher:u,priority:l}),r!==",")break;r=a.next()}return n;function i(){if(r==="-"){r=a.next();const l=i();return u=>!!l&&!l(u)}if(r==="("){r=a.next();const l=s();return r===")"&&(r=a.next()),l}if(jne(r)){const l=[];do l.push(r),r=a.next();while(jne(r));return u=>e(l,u)}return null}function o(){const l=[];let u=i();for(;u;)l.push(u),u=i();return d=>l.every(p=>p(d))}function s(){const l=[];let u=o();for(;u&&(l.push(u),r==="|"||r===",");){do r=a.next();while(r==="|"||r===",");u=o()}return d=>l.some(p=>p(d))}}function jne(t){return!!t&&!!t.match(/[\w\.:]+/)}function CKe(t){let e=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=e.exec(t);return{next:()=>{if(!n)return null;const a=n[0];return n=e.exec(t),a}}}function Gne(t){typeof t.dispose=="function"&&t.dispose()}var Yw=class{constructor(t){this.scopeName=t}toKey(){return this.scopeName}},_Ke=class{constructor(t,e){this.scopeName=t,this.ruleName=e}toKey(){return`${this.scopeName}#${this.ruleName}`}},xKe=class{constructor(){We(this,"_references",[]);We(this,"_seenReferenceKeys",new Set);We(this,"visitedRule",new Set)}get references(){return this._references}add(t){const e=t.toKey();this._seenReferenceKeys.has(e)||(this._seenReferenceKeys.add(e),this._references.push(t))}},EKe=class{constructor(t,e){We(this,"seenFullScopeRequests",new Set);We(this,"seenPartialScopeRequests",new Set);We(this,"Q");this.repo=t,this.initialScopeName=e,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new Yw(this.initialScopeName)]}processQueue(){const t=this.Q;this.Q=[];const e=new xKe;for(const n of t)BKe(n,this.initialScopeName,this.repo,e);for(const n of e.references)if(n instanceof Yw){if(this.seenFullScopeRequests.has(n.scopeName))continue;this.seenFullScopeRequests.add(n.scopeName),this.Q.push(n)}else{if(this.seenFullScopeRequests.has(n.scopeName)||this.seenPartialScopeRequests.has(n.toKey()))continue;this.seenPartialScopeRequests.add(n.toKey()),this.Q.push(n)}}};function BKe(t,e,n,a){const r=n.lookup(t.scopeName);if(!r){if(t.scopeName===e)throw new Error(`No grammar provided for <${e}>`);return}const i=n.lookup(e);t instanceof Yw?TB({baseGrammar:i,selfGrammar:r},a):AT(t.ruleName,{baseGrammar:i,selfGrammar:r,repository:r.repository},a);const o=n.injections(t.scopeName);if(o)for(const s of o)a.add(new Yw(s))}function AT(t,e,n){if(e.repository&&e.repository[t]){const a=e.repository[t];FB([a],e,n)}}function TB(t,e){t.selfGrammar.patterns&&Array.isArray(t.selfGrammar.patterns)&&FB(t.selfGrammar.patterns,{...t,repository:t.selfGrammar.repository},e),t.selfGrammar.injections&&FB(Object.values(t.selfGrammar.injections),{...t,repository:t.selfGrammar.repository},e)}function FB(t,e,n){for(const a of t){if(n.visitedRule.has(a))continue;n.visitedRule.add(a);const r=a.repository?Fne({},e.repository,a.repository):e.repository;Array.isArray(a.patterns)&&FB(a.patterns,{...e,repository:r},n);const i=a.include;if(!i)continue;const o=qne(i);switch(o.kind){case 0:TB({...e,selfGrammar:e.baseGrammar},n);break;case 1:TB(e,n);break;case 2:AT(o.ruleName,{...e,repository:r},n);break;case 3:case 4:const s=o.scopeName===e.selfGrammar.scopeName?e.selfGrammar:o.scopeName===e.baseGrammar.scopeName?e.baseGrammar:void 0;if(s){const l={baseGrammar:e.baseGrammar,selfGrammar:s,repository:r};o.kind===4?AT(o.ruleName,l,n):TB(l,n)}else o.kind===4?n.add(new _Ke(o.scopeName,o.ruleName)):n.add(new Yw(o.scopeName));break}}}var IKe=class{constructor(){We(this,"kind",0)}},DKe=class{constructor(){We(this,"kind",1)}},QKe=class{constructor(t){We(this,"kind",2);this.ruleName=t}},SKe=class{constructor(t){We(this,"kind",3);this.scopeName=t}},TKe=class{constructor(t,e){We(this,"kind",4);this.scopeName=t,this.ruleName=e}};function qne(t){if(t==="$base")return new IKe;if(t==="$self")return new DKe;const e=t.indexOf("#");if(e===-1)return new SKe(t);if(e===0)return new QKe(t.substring(1));{const n=t.substring(0,e),a=t.substring(e+1);return new TKe(n,a)}}var FKe=/\\(\d+)/,zne=/\\(\d+)/g,LKe=-1,Hne=-2;function R0n(t){return t}function $0n(t){return t}var Ww=class{constructor(e,n,a,r){We(this,"$location");We(this,"id");We(this,"_nameIsCapturing");We(this,"_name");We(this,"_contentNameIsCapturing");We(this,"_contentName");this.$location=e,this.id=n,this._name=a||null,this._nameIsCapturing=DB.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=DB.hasCaptures(this._contentName)}get debugName(){const e=this.$location?`${Lne(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,n){return!this._nameIsCapturing||this._name===null||e===null||n===null?this._name:DB.replaceCaptures(this._name,e,n)}getContentName(e,n){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:DB.replaceCaptures(this._contentName,e,n)}},NKe=class extends Ww{constructor(e,n,a,r,i){super(e,n,a,r);We(this,"retokenizeCapturedWithRuleId");this.retokenizeCapturedWithRuleId=i}dispose(){}collectPatterns(e,n){throw new Error("Not supported!")}compile(e,n){throw new Error("Not supported!")}compileAG(e,n,a,r){throw new Error("Not supported!")}},MKe=class extends Ww{constructor(e,n,a,r,i){super(e,n,a,null);We(this,"_match");We(this,"captures");We(this,"_cachedCompiledPatterns");this._match=new Kw(r,this.id),this.captures=i,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,n){n.push(this._match)}compile(e,n){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,n,a,r){return this._getCachedCompiledPatterns(e).compileAG(e,a,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Zw,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Une=class extends Ww{constructor(e,n,a,r,i){super(e,n,a,r);We(this,"hasMissingPatterns");We(this,"patterns");We(this,"_cachedCompiledPatterns");this.patterns=i.patterns,this.hasMissingPatterns=i.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(e,n){for(const a of this.patterns)e.getRule(a).collectPatterns(e,n)}compile(e,n){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,n,a,r){return this._getCachedCompiledPatterns(e).compileAG(e,a,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Zw,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},gT=class extends Ww{constructor(e,n,a,r,i,o,s,l,u,d){super(e,n,a,r);We(this,"_begin");We(this,"beginCaptures");We(this,"_end");We(this,"endHasBackReferences");We(this,"endCaptures");We(this,"applyEndPatternLast");We(this,"hasMissingPatterns");We(this,"patterns");We(this,"_cachedCompiledPatterns");this._begin=new Kw(i,this.id),this.beginCaptures=o,this._end=new Kw(s||"￿",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=l,this.applyEndPatternLast=u||!1,this.patterns=d.patterns,this.hasMissingPatterns=d.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,n){return this._end.resolveBackReferences(e,n)}collectPatterns(e,n){n.push(this._begin)}compile(e,n){return this._getCachedCompiledPatterns(e,n).compile(e)}compileAG(e,n,a,r){return this._getCachedCompiledPatterns(e,n).compileAG(e,a,r)}_getCachedCompiledPatterns(e,n){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Zw;for(const a of this.patterns)e.getRule(a).collectPatterns(e,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,n):this._cachedCompiledPatterns.setSource(0,n)),this._cachedCompiledPatterns}},LB=class extends Ww{constructor(e,n,a,r,i,o,s,l,u){super(e,n,a,r);We(this,"_begin");We(this,"beginCaptures");We(this,"whileCaptures");We(this,"_while");We(this,"whileHasBackReferences");We(this,"hasMissingPatterns");We(this,"patterns");We(this,"_cachedCompiledPatterns");We(this,"_cachedCompiledWhilePatterns");this._begin=new Kw(i,this.id),this.beginCaptures=o,this.whileCaptures=l,this._while=new Kw(s,Hne),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=u.patterns,this.hasMissingPatterns=u.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,n){return this._while.resolveBackReferences(e,n)}collectPatterns(e,n){n.push(this._begin)}compile(e,n){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,n,a,r){return this._getCachedCompiledPatterns(e).compileAG(e,a,r)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Zw;for(const n of this.patterns)e.getRule(n).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,n){return this._getCachedCompiledWhilePatterns(e,n).compile(e)}compileWhileAG(e,n,a,r){return this._getCachedCompiledWhilePatterns(e,n).compileAG(e,a,r)}_getCachedCompiledWhilePatterns(e,n){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new Zw,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,n||"￿"),this._cachedCompiledWhilePatterns}},Yne=class Eo{static createCaptureRule(e,n,a,r,i){return e.registerRule(o=>new NKe(n,o,a,r,i))}static getCompiledRuleId(e,n,a){return e.id||n.registerRule(r=>{if(e.id=r,e.match)return new MKe(e.$vscodeTextmateLocation,e.id,e.name,e.match,Eo._compileCaptures(e.captures,n,a));if(typeof e.begin>"u"){e.repository&&(a=Fne({},a,e.repository));let i=e.patterns;return typeof i>"u"&&e.include&&(i=[{include:e.include}]),new Une(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,Eo._compilePatterns(i,n,a))}return e.while?new LB(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,Eo._compileCaptures(e.beginCaptures||e.captures,n,a),e.while,Eo._compileCaptures(e.whileCaptures||e.captures,n,a),Eo._compilePatterns(e.patterns,n,a)):new gT(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,Eo._compileCaptures(e.beginCaptures||e.captures,n,a),e.end,Eo._compileCaptures(e.endCaptures||e.captures,n,a),e.applyEndPatternLast,Eo._compilePatterns(e.patterns,n,a))}),e.id}static _compileCaptures(e,n,a){let r=[];if(e){let i=0;for(const o in e){if(o==="$vscodeTextmateLocation")continue;const s=parseInt(o,10);s>i&&(i=s)}for(let o=0;o<=i;o++)r[o]=null;for(const o in e){if(o==="$vscodeTextmateLocation")continue;const s=parseInt(o,10);let l=0;e[o].patterns&&(l=Eo.getCompiledRuleId(e[o],n,a)),r[s]=Eo.createCaptureRule(n,e[o].$vscodeTextmateLocation,e[o].name,e[o].contentName,l)}}return r}static _compilePatterns(e,n,a){let r=[];if(e)for(let i=0,o=e.length;i<o;i++){const s=e[i];let l=-1;if(s.include){const u=qne(s.include);switch(u.kind){case 0:case 1:l=Eo.getCompiledRuleId(a[s.include],n,a);break;case 2:let d=a[u.ruleName];d&&(l=Eo.getCompiledRuleId(d,n,a));break;case 3:case 4:const p=u.scopeName,m=u.kind===4?u.ruleName:null,A=n.getExternalGrammar(p,a);if(A)if(m){let g=A.repository[m];g&&(l=Eo.getCompiledRuleId(g,n,A.repository))}else l=Eo.getCompiledRuleId(A.repository.$self,n,A.repository);break}}else l=Eo.getCompiledRuleId(s,n,a);if(l!==-1){const u=n.getRule(l);let d=!1;if((u instanceof Une||u instanceof gT||u instanceof LB)&&u.hasMissingPatterns&&u.patterns.length===0&&(d=!0),d)continue;r.push(l)}}return{patterns:r,hasMissingPatterns:(e?e.length:0)!==r.length}}},Kw=class PDe{constructor(e,n){We(this,"source");We(this,"ruleId");We(this,"hasAnchor");We(this,"hasBackReferences");We(this,"_anchorCache");if(e&&typeof e=="string"){const a=e.length;let r=0,i=[],o=!1;for(let s=0;s<a;s++)if(e.charAt(s)==="\\"&&s+1<a){const u=e.charAt(s+1);u==="z"?(i.push(e.substring(r,s)),i.push("$(?!\\n)(?<!\\n)"),r=s+2):(u==="A"||u==="G")&&(o=!0),s++}this.hasAnchor=o,r===0?this.source=e:(i.push(e.substring(r,a)),this.source=i.join(""))}else this.hasAnchor=!1,this.source=e;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=n,typeof this.source=="string"?this.hasBackReferences=FKe.test(this.source):this.hasBackReferences=!1}clone(){return new PDe(this.source,this.ruleId)}setSource(e){this.source!==e&&(this.source=e,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(e,n){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let a=n.map(r=>e.substring(r.start,r.end));return zne.lastIndex=0,this.source.replace(zne,(r,i)=>$ne(a[parseInt(i,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let e=[],n=[],a=[],r=[],i,o,s,l;for(i=0,o=this.source.length;i<o;i++)s=this.source.charAt(i),e[i]=s,n[i]=s,a[i]=s,r[i]=s,s==="\\"&&i+1<o&&(l=this.source.charAt(i+1),l==="A"?(e[i+1]="￿",n[i+1]="￿",a[i+1]="A",r[i+1]="A"):l==="G"?(e[i+1]="￿",n[i+1]="G",a[i+1]="￿",r[i+1]="G"):(e[i+1]=l,n[i+1]=l,a[i+1]=l,r[i+1]=l),i++);return{A0_G0:e.join(""),A0_G1:n.join(""),A1_G0:a.join(""),A1_G1:r.join("")}}resolveAnchors(e,n){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:e?n?this._anchorCache.A1_G1:this._anchorCache.A1_G0:n?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},Zw=class{constructor(){We(this,"_items");We(this,"_hasAnchors");We(this,"_cached");We(this,"_anchorCache");this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&(this._cached.dispose(),this._cached=null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(t){this._items.push(t),this._hasAnchors=this._hasAnchors||t.hasAnchor}unshift(t){this._items.unshift(t),this._hasAnchors=this._hasAnchors||t.hasAnchor}length(){return this._items.length}setSource(t,e){this._items[t].source!==e&&(this._disposeCaches(),this._items[t].setSource(e))}compile(t){if(!this._cached){let e=this._items.map(n=>n.source);this._cached=new Wne(t,e,this._items.map(n=>n.ruleId))}return this._cached}compileAG(t,e,n){return this._hasAnchors?e?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(t,e,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(t,e,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(t,e,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(t,e,n)),this._anchorCache.A0_G0):this.compile(t)}_resolveAnchors(t,e,n){let a=this._items.map(r=>r.resolveAnchors(e,n));return new Wne(t,a,this._items.map(r=>r.ruleId))}},Wne=class{constructor(t,e,n){We(this,"scanner");this.regExps=e,this.rules=n,this.scanner=t.createOnigScanner(e)}dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){const t=[];for(let e=0,n=this.rules.length;e<n;e++)t.push(" - "+this.rules[e]+": "+this.regExps[e]);return t.join(`
539
539
  `)}findNextMatchSync(t,e,n){const a=this.scanner.findNextMatchSync(t,e,n);return a?{ruleId:this.rules[a.index],captureIndices:a.captureIndices}:null}},hT=class{constructor(t,e){this.languageId=t,this.tokenType=e}},RKe=(xA=class{constructor(e,n){We(this,"_defaultAttributes");We(this,"_embeddedLanguagesMatcher");We(this,"_getBasicScopeAttributes",new Pne(e=>{const n=this._scopeToLanguage(e),a=this._toStandardTokenType(e);return new hT(n,a)}));this._defaultAttributes=new hT(e,8),this._embeddedLanguagesMatcher=new $Ke(Object.entries(n||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(e){return e===null?xA._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(e)}_scopeToLanguage(e){return this._embeddedLanguagesMatcher.match(e)||0}_toStandardTokenType(e){const n=e.match(xA.STANDARD_TOKEN_TYPE_REGEXP);if(!n)return 8;switch(n[1]){case"comment":return 1;case"string":return 2;case"regex":return 3;case"meta.embedded":return 0}throw new Error("Unexpected match for standard token type!")}},We(xA,"_NULL_SCOPE_METADATA",new hT(0,0)),We(xA,"STANDARD_TOKEN_TYPE_REGEXP",/\b(comment|string|regex|meta\.embedded)\b/),xA),$Ke=class{constructor(t){We(this,"values");We(this,"scopesRegExp");if(t.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(t);const e=t.map(([n,a])=>$ne(n));e.sort(),e.reverse(),this.scopesRegExp=new RegExp(`^((${e.join(")|(")}))($|\\.)`,"")}}match(t){if(!this.scopesRegExp)return;const e=t.match(this.scopesRegExp);if(e)return this.values.get(e[1])}},Kne=class{constructor(t,e){this.stack=t,this.stoppedEarly=e}};function Zne(t,e,n,a,r,i,o,s){const l=e.content.length;let u=!1,d=-1;if(o){const A=PKe(t,e,n,a,r,i);r=A.stack,a=A.linePos,n=A.isFirstLine,d=A.anchorPosition}const p=Date.now();for(;!u;){if(s!==0&&Date.now()-p>s)return new Kne(r,!0);m()}return new Kne(r,!1);function m(){const A=OKe(t,e,n,a,r,d);if(!A){i.produce(r,l),u=!0;return}const g=A.captureIndices,h=A.matchedRuleId,f=g&&g.length>0?g[0].end>a:!1;if(h===LKe){const b=r.getRule(t);i.produce(r,g[0].start),r=r.withContentNameScopesList(r.nameScopesList),Vw(t,e,n,r,i,b.endCaptures,g),i.produce(r,g[0].end);const y=r;if(r=r.parent,d=y.getAnchorPos(),!f&&y.getEnterPos()===a){r=y,i.produce(r,l),u=!0;return}}else{const b=t.getRule(h);i.produce(r,g[0].start);const y=r,w=b.getName(e.content,g),k=r.contentNameScopesList.pushAttributed(w,t);if(r=r.push(h,a,d,g[0].end===l,null,k,k),b instanceof gT){const C=b;Vw(t,e,n,r,i,C.beginCaptures,g),i.produce(r,g[0].end),d=g[0].end;const x=C.getContentName(e.content,g),_=k.pushAttributed(x,t);if(r=r.withContentNameScopesList(_),C.endHasBackReferences&&(r=r.withEndRule(C.getEndWithResolvedBackReferences(e.content,g))),!f&&y.hasSameRuleAs(r)){r=r.pop(),i.produce(r,l),u=!0;return}}else if(b instanceof LB){const C=b;Vw(t,e,n,r,i,C.beginCaptures,g),i.produce(r,g[0].end),d=g[0].end;const x=C.getContentName(e.content,g),_=k.pushAttributed(x,t);if(r=r.withContentNameScopesList(_),C.whileHasBackReferences&&(r=r.withEndRule(C.getWhileWithResolvedBackReferences(e.content,g))),!f&&y.hasSameRuleAs(r)){r=r.pop(),i.produce(r,l),u=!0;return}}else if(Vw(t,e,n,r,i,b.captures,g),i.produce(r,g[0].end),r=r.pop(),!f){r=r.safePop(),i.produce(r,l),u=!0;return}}g[0].end>a&&(a=g[0].end,n=!1)}}function PKe(t,e,n,a,r,i){let o=r.beginRuleCapturedEOL?0:-1;const s=[];for(let l=r;l;l=l.pop()){const u=l.getRule(t);u instanceof LB&&s.push({rule:u,stack:l})}for(let l=s.pop();l;l=s.pop()){const{ruleScanner:u,findOptions:d}=qKe(l.rule,t,l.stack.endRule,n,a===o),p=u.findNextMatchSync(e,a,d);if(p){if(p.ruleId!==Hne){r=l.stack.pop();break}p.captureIndices&&p.captureIndices.length&&(i.produce(l.stack,p.captureIndices[0].start),Vw(t,e,n,l.stack,i,l.rule.whileCaptures,p.captureIndices),i.produce(l.stack,p.captureIndices[0].end),o=p.captureIndices[0].end,p.captureIndices[0].end>a&&(a=p.captureIndices[0].end,n=!1))}else{r=l.stack.pop();break}}return{stack:r,linePos:a,anchorPosition:o,isFirstLine:n}}function OKe(t,e,n,a,r,i){const o=jKe(t,e,n,a,r,i),s=t.getInjections();if(s.length===0)return o;const l=GKe(s,t,e,n,a,r,i);if(!l)return o;if(!o)return l;const u=o.captureIndices[0].start,d=l.captureIndices[0].start;return d<u||l.priorityMatch&&d===u?l:o}function jKe(t,e,n,a,r,i){const o=r.getRule(t),{ruleScanner:s,findOptions:l}=Vne(o,t,r.endRule,n,a===i),u=s.findNextMatchSync(e,a,l);return u?{captureIndices:u.captureIndices,matchedRuleId:u.ruleId}:null}function GKe(t,e,n,a,r,i,o){let s=Number.MAX_VALUE,l=null,u,d=0;const p=i.contentNameScopesList.getScopeNames();for(let m=0,A=t.length;m<A;m++){const g=t[m];if(!g.matcher(p))continue;const h=e.getRule(g.ruleId),{ruleScanner:f,findOptions:b}=Vne(h,e,null,a,r===o),y=f.findNextMatchSync(n,r,b);if(!y)continue;const w=y.captureIndices[0].start;if(!(w>=s)&&(s=w,l=y.captureIndices,u=y.ruleId,d=g.priority,s===r))break}return l?{priorityMatch:d===-1,captureIndices:l,matchedRuleId:u}:null}function Vne(t,e,n,a,r){return{ruleScanner:t.compileAG(e,n,a,r),findOptions:0}}function qKe(t,e,n,a,r){return{ruleScanner:t.compileWhileAG(e,n,a,r),findOptions:0}}function Vw(t,e,n,a,r,i,o){if(i.length===0)return;const s=e.content,l=Math.min(i.length,o.length),u=[],d=o[0].end;for(let p=0;p<l;p++){const m=i[p];if(m===null)continue;const A=o[p];if(A.length===0)continue;if(A.start>d)break;for(;u.length>0&&u[u.length-1].endPos<=A.start;)r.produceFromScopes(u[u.length-1].scopes,u[u.length-1].endPos),u.pop();if(u.length>0?r.produceFromScopes(u[u.length-1].scopes,A.start):r.produce(a,A.start),m.retokenizeCapturedWithRuleId){const h=m.getName(s,o),f=a.contentNameScopesList.pushAttributed(h,t),b=m.getContentName(s,o),y=f.pushAttributed(b,t),w=a.push(m.retokenizeCapturedWithRuleId,A.start,-1,!1,null,f,y),k=t.createOnigString(s.substring(0,A.end));Zne(t,k,n&&A.start===0,A.start,w,r,!1,0),Gne(k);continue}const g=m.getName(s,o);if(g!==null){const f=(u.length>0?u[u.length-1].scopes:a.contentNameScopesList).pushAttributed(g,t);u.push(new zKe(f,A.end))}}for(;u.length>0;)r.produceFromScopes(u[u.length-1].scopes,u[u.length-1].endPos),u.pop()}var zKe=class{constructor(t,e){We(this,"scopes");We(this,"endPos");this.scopes=t,this.endPos=e}};function HKe(t,e,n,a,r,i,o,s){return new YKe(t,e,n,a,r,i,o,s)}function Jne(t,e,n,a,r){const i=SB(e,NB),o=Yne.getCompiledRuleId(n,a,r.repository);for(const s of i)t.push({debugSelector:e,matcher:s.matcher,ruleId:o,grammar:r,priority:s.priority})}function NB(t,e){if(e.length<t.length)return!1;let n=0;return t.every(a=>{for(let r=n;r<e.length;r++)if(UKe(e[r],a))return n=r+1,!0;return!1})}function UKe(t,e){if(!t)return!1;if(t===e)return!0;const n=e.length;return t.length>n&&t.substr(0,n)===e&&t[n]==="."}var YKe=class{constructor(e,n,a,r,i,o,s,l){We(this,"_rootId");We(this,"_lastRuleId");We(this,"_ruleId2desc");We(this,"_includedGrammars");We(this,"_grammarRepository");We(this,"_grammar");We(this,"_injections");We(this,"_basicScopeAttributesProvider");We(this,"_tokenTypeMatchers");if(this._rootScopeName=e,this.balancedBracketSelectors=o,this._onigLib=l,this._basicScopeAttributesProvider=new RKe(a,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=s,this._grammar=Xne(n,null),this._injections=null,this._tokenTypeMatchers=[],i)for(const u of Object.keys(i)){const d=SB(u,NB);for(const p of d)this._tokenTypeMatchers.push({matcher:p.matcher,type:i[u]})}}get themeProvider(){return this._grammarRepository}dispose(){for(const e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){const e={lookup:i=>i===this._rootScopeName?this._grammar:this.getExternalGrammar(i),injections:i=>this._grammarRepository.injections(i)},n=[],a=this._rootScopeName,r=e.lookup(a);if(r){const i=r.injections;if(i)for(let s in i)Jne(n,s,i[s],this,r);const o=this._grammarRepository.injections(a);o&&o.forEach(s=>{const l=this.getExternalGrammar(s);if(l){const u=l.injectionSelector;u&&Jne(n,u,l,this,l)}})}return n.sort((i,o)=>i.priority-o.priority),n}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(e){const n=++this._lastRuleId,a=e(n);return this._ruleId2desc[n]=a,a}getRule(e){return this._ruleId2desc[e]}getExternalGrammar(e,n){if(this._includedGrammars[e])return this._includedGrammars[e];if(this._grammarRepository){const a=this._grammarRepository.lookup(e);if(a)return this._includedGrammars[e]=Xne(a,n&&n.$base),this._includedGrammars[e]}}tokenizeLine(e,n,a=0){const r=this._tokenize(e,n,!1,a);return{tokens:r.lineTokens.getResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}tokenizeLine2(e,n,a=0){const r=this._tokenize(e,n,!0,a);return{tokens:r.lineTokens.getBinaryResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}_tokenize(e,n,a,r){this._rootId===-1&&(this._rootId=Yne.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let i;if(!n||n===fT.NULL){i=!0;const d=this._basicScopeAttributesProvider.getDefaultAttributes(),p=this.themeProvider.getDefaults(),m=Uf.set(0,d.languageId,d.tokenType,null,p.fontStyle,p.foregroundId,p.backgroundId),A=this.getRule(this._rootId).getName(null,null);let g;A?g=Jw.createRootAndLookUpScopeName(A,m,this):g=Jw.createRoot("unknown",m),n=new fT(null,this._rootId,-1,-1,!1,null,g,g)}else i=!1,n.reset();e=e+`
540
540
  `;const o=this.createOnigString(e),s=o.content.length,l=new KKe(a,e,this._tokenTypeMatchers,this.balancedBracketSelectors),u=Zne(this,o,i,0,n,l,!0,r);return Gne(o),{lineLength:s,lineTokens:l,ruleStack:u.stack,stoppedEarly:u.stoppedEarly}}};function Xne(t,e){return t=pKe(t),t.repository=t.repository||{},t.repository.$self={$vscodeTextmateLocation:t.$vscodeTextmateLocation,patterns:t.patterns,name:t.scopeName},t.repository.$base=e||t.repository.$self,t}var Jw=class td{constructor(e,n,a){this.parent=e,this.scopePath=n,this.tokenAttributes=a}static fromExtension(e,n){let a=e,r=(e==null?void 0:e.scopePath)??null;for(const i of n)r=pT.push(r,i.scopeNames),a=new td(a,r,i.encodedTokenAttributes);return a}static createRoot(e,n){return new td(null,new pT(null,e),n)}static createRootAndLookUpScopeName(e,n,a){const r=a.getMetadataForScope(e),i=new pT(null,e),o=a.themeProvider.themeMatch(i),s=td.mergeAttributes(n,r,o);return new td(null,i,s)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(e){return td.equals(this,e)}static equals(e,n){do{if(e===n||!e&&!n)return!0;if(!e||!n||e.scopeName!==n.scopeName||e.tokenAttributes!==n.tokenAttributes)return!1;e=e.parent,n=n.parent}while(!0)}static mergeAttributes(e,n,a){let r=-1,i=0,o=0;return a!==null&&(r=a.fontStyle,i=a.foregroundId,o=a.backgroundId),Uf.set(e,n.languageId,n.tokenType,null,r,i,o)}pushAttributed(e,n){if(e===null)return this;if(e.indexOf(" ")===-1)return td._pushAttributed(this,e,n);const a=e.split(/ /g);let r=this;for(const i of a)r=td._pushAttributed(r,i,n);return r}static _pushAttributed(e,n,a){const r=a.getMetadataForScope(n),i=e.scopePath.push(n),o=a.themeProvider.themeMatch(i),s=td.mergeAttributes(e.tokenAttributes,r,o);return new td(e,i,s)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(e){var r;const n=[];let a=this;for(;a&&a!==e;)n.push({encodedTokenAttributes:a.tokenAttributes,scopeNames:a.scopePath.getExtensionIfDefined(((r=a.parent)==null?void 0:r.scopePath)??null)}),a=a.parent;return a===e?n.reverse():void 0}},fT=(Ml=class{constructor(e,n,a,r,i,o,s,l){We(this,"_stackElementBrand");We(this,"_enterPos");We(this,"_anchorPos");We(this,"depth");this.parent=e,this.ruleId=n,this.beginRuleCapturedEOL=i,this.endRule=o,this.nameScopesList=s,this.contentNameScopesList=l,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=a,this._anchorPos=r}equals(e){return e===null?!1:Ml._equals(this,e)}static _equals(e,n){return e===n?!0:this._structuralEquals(e,n)?Jw.equals(e.contentNameScopesList,n.contentNameScopesList):!1}static _structuralEquals(e,n){do{if(e===n||!e&&!n)return!0;if(!e||!n||e.depth!==n.depth||e.ruleId!==n.ruleId||e.endRule!==n.endRule)return!1;e=e.parent,n=n.parent}while(!0)}clone(){return this}static _reset(e){for(;e;)e._enterPos=-1,e._anchorPos=-1,e=e.parent}reset(){Ml._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(e,n,a,r,i,o,s){return new Ml(this,e,n,a,r,i,o,s)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(e){return e.getRule(this.ruleId)}toString(){const e=[];return this._writeString(e,0),"["+e.join(",")+"]"}_writeString(e,n){var a,r;return this.parent&&(n=this.parent._writeString(e,n)),e[n++]=`(${this.ruleId}, ${(a=this.nameScopesList)==null?void 0:a.toString()}, ${(r=this.contentNameScopesList)==null?void 0:r.toString()})`,n}withContentNameScopesList(e){return this.contentNameScopesList===e?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,e)}withEndRule(e){return this.endRule===e?this:new Ml(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,e,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(e){let n=this;for(;n&&n._enterPos===e._enterPos;){if(n.ruleId===e.ruleId)return!0;n=n.parent}return!1}toStateStackFrame(){var e,n,a;return{ruleId:this.ruleId,beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:((n=this.nameScopesList)==null?void 0:n.getExtensionIfDefined(((e=this.parent)==null?void 0:e.nameScopesList)??null))??[],contentNameScopesList:((a=this.contentNameScopesList)==null?void 0:a.getExtensionIfDefined(this.nameScopesList))??[]}}static pushFrame(e,n){const a=Jw.fromExtension((e==null?void 0:e.nameScopesList)??null,n.nameScopesList);return new Ml(e,n.ruleId,n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,a,Jw.fromExtension(a,n.contentNameScopesList))}},We(Ml,"NULL",new Ml(null,0,0,0,!1,null,null,null)),Ml),WKe=class{constructor(t,e){We(this,"balancedBracketScopes");We(this,"unbalancedBracketScopes");We(this,"allowAny",!1);this.balancedBracketScopes=t.flatMap(n=>n==="*"?(this.allowAny=!0,[]):SB(n,NB).map(a=>a.matcher)),this.unbalancedBracketScopes=e.flatMap(n=>SB(n,NB).map(a=>a.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(t){for(const e of this.unbalancedBracketScopes)if(e(t))return!1;for(const e of this.balancedBracketScopes)if(e(t))return!0;return this.allowAny}},KKe=class{constructor(t,e,n,a){We(this,"_emitBinaryTokens");We(this,"_lineText");We(this,"_tokens");We(this,"_binaryTokens");We(this,"_lastTokenEndIndex");We(this,"_tokenTypeOverrides");this.balancedBracketSelectors=a,this._emitBinaryTokens=t,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}produce(t,e){this.produceFromScopes(t.contentNameScopesList,e)}produceFromScopes(t,e){var a;if(this._lastTokenEndIndex>=e)return;if(this._emitBinaryTokens){let r=(t==null?void 0:t.tokenAttributes)??0,i=!1;if((a=this.balancedBracketSelectors)!=null&&a.matchesAlways&&(i=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){const o=(t==null?void 0:t.getScopeNames())??[];for(const s of this._tokenTypeOverrides)s.matcher(o)&&(r=Uf.set(r,0,s.type,null,-1,0,0));this.balancedBracketSelectors&&(i=this.balancedBracketSelectors.match(o))}if(i&&(r=Uf.set(r,0,8,i,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===r){this._lastTokenEndIndex=e;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(r),this._lastTokenEndIndex=e;return}const n=(t==null?void 0:t.getScopeNames())??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:e,scopes:n}),this._lastTokenEndIndex=e}getResult(t,e){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===e-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(t,e),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(t,e){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===e-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(t,e),this._binaryTokens[this._binaryTokens.length-2]=0);const n=new Uint32Array(this._binaryTokens.length);for(let a=0,r=this._binaryTokens.length;a<r;a++)n[a]=this._binaryTokens[a];return n}},ZKe=class{constructor(t,e){We(this,"_grammars",new Map);We(this,"_rawGrammars",new Map);We(this,"_injectionGrammars",new Map);We(this,"_theme");this._onigLib=e,this._theme=t}dispose(){for(const t of this._grammars.values())t.dispose()}setTheme(t){this._theme=t}getColorMap(){return this._theme.getColorMap()}addGrammar(t,e){this._rawGrammars.set(t.scopeName,t),e&&this._injectionGrammars.set(t.scopeName,e)}lookup(t){return this._rawGrammars.get(t)}injections(t){return this._injectionGrammars.get(t)}getDefaults(){return this._theme.getDefaults()}themeMatch(t){return this._theme.match(t)}grammarForScopeName(t,e,n,a,r){if(!this._grammars.has(t)){let i=this._rawGrammars.get(t);if(!i)return null;this._grammars.set(t,HKe(t,i,e,n,a,r,this,this._onigLib))}return this._grammars.get(t)}},VKe=class{constructor(e){We(this,"_options");We(this,"_syncRegistry");We(this,"_ensureGrammarCache");this._options=e,this._syncRegistry=new ZKe(QB.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,n){this._syncRegistry.setTheme(QB.createFromRawTheme(e,n))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,n,a){return this.loadGrammarWithConfiguration(e,n,{embeddedLanguages:a})}loadGrammarWithConfiguration(e,n,a){return this._loadGrammar(e,n,a.embeddedLanguages,a.tokenTypes,new WKe(a.balancedBracketSelectors||[],a.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,n,a,r,i){const o=new EKe(this._syncRegistry,e);for(;o.Q.length>0;)o.Q.map(s=>this._loadSingleGrammar(s.scopeName)),o.processQueue();return this._grammarForScopeName(e,n,a,r,i)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){const n=this._options.loadGrammar(e);if(n){const a=typeof this._options.getInjections=="function"?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(n,a)}}addGrammar(e,n=[],a=0,r=null){return this._syncRegistry.addGrammar(e,n),this._grammarForScopeName(e.scopeName,a,r)}_grammarForScopeName(e,n=0,a=null,r=null,i=null){return this._syncRegistry.grammarForScopeName(e,n,a,r,i)}},bT=fT.NULL;const JKe=/["&'<>`]/g,XKe=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,eZe=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,tZe=/[|\\{}()[\]^$+*?.]/g,eae=new WeakMap;function nZe(t,e){if(t=t.replace(e.subset?aZe(e.subset):JKe,a),e.subset||e.escapeOnly)return t;return t.replace(XKe,n).replace(eZe,a);function n(r,i,o){return e.format((r.charCodeAt(0)-55296)*1024+r.charCodeAt(1)-56320+65536,o.charCodeAt(i+2),e)}function a(r,i,o){return e.format(r.charCodeAt(0),o.charCodeAt(i+1),e)}}function aZe(t){let e=eae.get(t);return e||(e=rZe(t),eae.set(t,e)),e}function rZe(t){const e=[];let n=-1;for(;++n<t.length;)e.push(t[n].replace(tZe,"\\$&"));return new RegExp("(?:"+e.join("|")+")","g")}const iZe=/[\dA-Fa-f]/;function oZe(t,e,n){const a="&#x"+t.toString(16).toUpperCase();return n&&e&&!iZe.test(String.fromCharCode(e))?a:a+";"}const sZe=/\d/;function cZe(t,e,n){const a="&#"+String(t);return n&&e&&!sZe.test(String.fromCharCode(e))?a:a+";"}const lZe=["AElig","AMP","Aacute","Acirc","Agrave","Aring","Atilde","Auml","COPY","Ccedil","ETH","Eacute","Ecirc","Egrave","Euml","GT","Iacute","Icirc","Igrave","Iuml","LT","Ntilde","Oacute","Ocirc","Ograve","Oslash","Otilde","Ouml","QUOT","REG","THORN","Uacute","Ucirc","Ugrave","Uuml","Yacute","aacute","acirc","acute","aelig","agrave","amp","aring","atilde","auml","brvbar","ccedil","cedil","cent","copy","curren","deg","divide","eacute","ecirc","egrave","eth","euml","frac12","frac14","frac34","gt","iacute","icirc","iexcl","igrave","iquest","iuml","laquo","lt","macr","micro","middot","nbsp","not","ntilde","oacute","ocirc","ograve","ordf","ordm","oslash","otilde","ouml","para","plusmn","pound","quot","raquo","reg","sect","shy","sup1","sup2","sup3","szlig","thorn","times","uacute","ucirc","ugrave","uml","uuml","yacute","yen","yuml"],yT={nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"­",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",fnof:"ƒ",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",bull:"•",hellip:"…",prime:"′",Prime:"″",oline:"‾",frasl:"⁄",weierp:"℘",image:"ℑ",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦",quot:'"',amp:"&",lt:"<",gt:">",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",lrm:"‎",rlm:"‏",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",permil:"‰",lsaquo:"‹",rsaquo:"›",euro:"€"},uZe=["cent","copy","divide","gt","lt","not","para","times"],tae={}.hasOwnProperty,wT={};let MB;for(MB in yT)tae.call(yT,MB)&&(wT[yT[MB]]=MB);const dZe=/[^\dA-Za-z]/;function pZe(t,e,n,a){const r=String.fromCharCode(t);if(tae.call(wT,r)){const i=wT[r],o="&"+i;return n&&lZe.includes(i)&&!uZe.includes(i)&&(!a||e&&e!==61&&dZe.test(String.fromCharCode(e)))?o:o+";"}return""}function mZe(t,e,n){let a=oZe(t,e,n.omitOptionalSemicolons),r;if((n.useNamedReferences||n.useShortestReferences)&&(r=pZe(t,e,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!r)&&n.useShortestReferences){const i=cZe(t,e,n.omitOptionalSemicolons);i.length<a.length&&(a=i)}return r&&(!n.useShortestReferences||r.length<a.length)?r:a}function Yf(t,e){return nZe(t,Object.assign({format:mZe},e))}const AZe=/^>|^->|<!--|-->|--!>|<!-$/g,gZe=[">"],hZe=["<",">"];function fZe(t,e,n,a){return a.settings.bogusComments?"<?"+Yf(t.value,Object.assign({},a.settings.characterReferences,{subset:gZe}))+">":"<!--"+t.value.replace(AZe,r)+"-->";function r(i){return Yf(i,Object.assign({},a.settings.characterReferences,{subset:hZe}))}}function bZe(t,e,n,a){return"<!"+(a.settings.upperDoctype?"DOCTYPE":"doctype")+(a.settings.tightDoctype?"":" ")+"html>"}const Jr=aae(1),nae=aae(-1),yZe=[];function aae(t){return e;function e(n,a,r){const i=n?n.children:yZe;let o=(a||0)+t,s=i[o];if(!r)for(;s&&VE(s);)o+=t,s=i[o];return s}}const wZe={}.hasOwnProperty;function rae(t){return e;function e(n,a,r){return wZe.call(t,n.tagName)&&t[n.tagName](n,a,r)}}const kT=rae({body:vZe,caption:vT,colgroup:vT,dd:EZe,dt:xZe,head:vT,html:kZe,li:_Ze,optgroup:BZe,option:IZe,p:CZe,rp:iae,rt:iae,tbody:QZe,td:oae,tfoot:SZe,th:oae,thead:DZe,tr:TZe});function vT(t,e,n){const a=Jr(n,e,!0);return!a||a.type!=="comment"&&!(a.type==="text"&&VE(a.value.charAt(0)))}function kZe(t,e,n){const a=Jr(n,e);return!a||a.type!=="comment"}function vZe(t,e,n){const a=Jr(n,e);return!a||a.type!=="comment"}function CZe(t,e,n){const a=Jr(n,e);return a?a.type==="element"&&(a.tagName==="address"||a.tagName==="article"||a.tagName==="aside"||a.tagName==="blockquote"||a.tagName==="details"||a.tagName==="div"||a.tagName==="dl"||a.tagName==="fieldset"||a.tagName==="figcaption"||a.tagName==="figure"||a.tagName==="footer"||a.tagName==="form"||a.tagName==="h1"||a.tagName==="h2"||a.tagName==="h3"||a.tagName==="h4"||a.tagName==="h5"||a.tagName==="h6"||a.tagName==="header"||a.tagName==="hgroup"||a.tagName==="hr"||a.tagName==="main"||a.tagName==="menu"||a.tagName==="nav"||a.tagName==="ol"||a.tagName==="p"||a.tagName==="pre"||a.tagName==="section"||a.tagName==="table"||a.tagName==="ul"):!n||!(n.type==="element"&&(n.tagName==="a"||n.tagName==="audio"||n.tagName==="del"||n.tagName==="ins"||n.tagName==="map"||n.tagName==="noscript"||n.tagName==="video"))}function _Ze(t,e,n){const a=Jr(n,e);return!a||a.type==="element"&&a.tagName==="li"}function xZe(t,e,n){const a=Jr(n,e);return!!(a&&a.type==="element"&&(a.tagName==="dt"||a.tagName==="dd"))}function EZe(t,e,n){const a=Jr(n,e);return!a||a.type==="element"&&(a.tagName==="dt"||a.tagName==="dd")}function iae(t,e,n){const a=Jr(n,e);return!a||a.type==="element"&&(a.tagName==="rp"||a.tagName==="rt")}function BZe(t,e,n){const a=Jr(n,e);return!a||a.type==="element"&&a.tagName==="optgroup"}function IZe(t,e,n){const a=Jr(n,e);return!a||a.type==="element"&&(a.tagName==="option"||a.tagName==="optgroup")}function DZe(t,e,n){const a=Jr(n,e);return!!(a&&a.type==="element"&&(a.tagName==="tbody"||a.tagName==="tfoot"))}function QZe(t,e,n){const a=Jr(n,e);return!a||a.type==="element"&&(a.tagName==="tbody"||a.tagName==="tfoot")}function SZe(t,e,n){return!Jr(n,e)}function TZe(t,e,n){const a=Jr(n,e);return!a||a.type==="element"&&a.tagName==="tr"}function oae(t,e,n){const a=Jr(n,e);return!a||a.type==="element"&&(a.tagName==="td"||a.tagName==="th")}const FZe=rae({body:MZe,colgroup:RZe,head:NZe,html:LZe,tbody:$Ze});function LZe(t){const e=Jr(t,-1);return!e||e.type!=="comment"}function NZe(t){const e=new Set;for(const a of t.children)if(a.type==="element"&&(a.tagName==="base"||a.tagName==="title")){if(e.has(a.tagName))return!1;e.add(a.tagName)}const n=t.children[0];return!n||n.type==="element"}function MZe(t){const e=Jr(t,-1,!0);return!e||e.type!=="comment"&&!(e.type==="text"&&VE(e.value.charAt(0)))&&!(e.type==="element"&&(e.tagName==="meta"||e.tagName==="link"||e.tagName==="script"||e.tagName==="style"||e.tagName==="template"))}function RZe(t,e,n){const a=nae(n,e),r=Jr(t,-1,!0);return n&&a&&a.type==="element"&&a.tagName==="colgroup"&&kT(a,n.children.indexOf(a),n)?!1:!!(r&&r.type==="element"&&r.tagName==="col")}function $Ze(t,e,n){const a=nae(n,e),r=Jr(t,-1);return n&&a&&a.type==="element"&&(a.tagName==="thead"||a.tagName==="tbody")&&kT(a,n.children.indexOf(a),n)?!1:!!(r&&r.type==="element"&&r.tagName==="tr")}const RB={name:[[`
541
541
  \f\r &/=>`.split(""),`
@@ -727,7 +727,7 @@ XID_Start XIDS`.split(/\s/).map(t=>[VB(t),t])),AXe=new Map([["s",ei(383)],[ei(38
727
727
  `)},Tre=function(){var t=parseInt(document.body.getAttribute(nb)||"0",10);return isFinite(t)?t:0},zet=function(){_e.useEffect(function(){return document.body.setAttribute(nb,(Tre()+1).toString()),function(){var t=Tre()-1;t<=0?document.body.removeAttribute(nb):document.body.setAttribute(nb,t.toString())}},[])},Het=function(t){var e=t.noRelative,n=t.noImportant,a=t.gapMode,r=a===void 0?"margin":a;zet();var i=_e.useMemo(function(){return jet(r)},[r]);return _e.createElement(Get,{styles:qet(i,!e,r,n?"":"!important")})},rF=!1;if(typeof window<"u")try{var o2=Object.defineProperty({},"passive",{get:function(){return rF=!0,!0}});window.addEventListener("test",o2,o2),window.removeEventListener("test",o2,o2)}catch{rF=!1}var ab=rF?{passive:!1}:!1,Uet=function(t){return t.tagName==="TEXTAREA"},Fre=function(t,e){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[e]!=="hidden"&&!(n.overflowY===n.overflowX&&!Uet(t)&&n[e]==="visible")},Yet=function(t){return Fre(t,"overflowY")},Wet=function(t){return Fre(t,"overflowX")},Lre=function(t,e){var n=e.ownerDocument,a=e;do{typeof ShadowRoot<"u"&&a instanceof ShadowRoot&&(a=a.host);var r=Nre(t,a);if(r){var i=Mre(t,a),o=i[1],s=i[2];if(o>s)return!0}a=a.parentNode}while(a&&a!==n.body);return!1},Ket=function(t){var e=t.scrollTop,n=t.scrollHeight,a=t.clientHeight;return[e,n,a]},Zet=function(t){var e=t.scrollLeft,n=t.scrollWidth,a=t.clientWidth;return[e,n,a]},Nre=function(t,e){return t==="v"?Yet(e):Wet(e)},Mre=function(t,e){return t==="v"?Ket(e):Zet(e)},Vet=function(t,e){return t==="h"&&e==="rtl"?-1:1},Jet=function(t,e,n,a,r){var i=Vet(t,window.getComputedStyle(e).direction),o=i*a,s=n.target,l=e.contains(s),u=!1,d=o>0,p=0,m=0;do{if(!s)break;var A=Mre(t,s),g=A[0],h=A[1],f=A[2],b=h-f-i*g;(g||b)&&Nre(t,s)&&(p+=b,m+=g);var y=s.parentNode;s=y&&y.nodeType===Node.DOCUMENT_FRAGMENT_NODE?y.host:y}while(!l&&s!==document.body||l&&(e.contains(s)||e===s));return(d&&(Math.abs(p)<1||!r)||!d&&(Math.abs(m)<1||!r))&&(u=!0),u},s2=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},Rre=function(t){return[t.deltaX,t.deltaY]},$re=function(t){return t&&"current"in t?t.current:t},Xet=function(t,e){return t[0]===e[0]&&t[1]===e[1]},ett=function(t){return`
728
728
  .block-interactivity-`.concat(t,` {pointer-events: none;}
729
729
  .allow-interactivity-`).concat(t,` {pointer-events: all;}
730
- `)},ttt=0,rb=[];function ntt(t){var e=_e.useRef([]),n=_e.useRef([0,0]),a=_e.useRef(),r=_e.useState(ttt++)[0],i=_e.useState(Sre)[0],o=_e.useRef(t);_e.useEffect(function(){o.current=t},[t]),_e.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(r));var h=vet([t.lockRef.current],(t.shards||[]).map($re),!0).filter(Boolean);return h.forEach(function(f){return f.classList.add("allow-interactivity-".concat(r))}),function(){document.body.classList.remove("block-interactivity-".concat(r)),h.forEach(function(f){return f.classList.remove("allow-interactivity-".concat(r))})}}},[t.inert,t.lockRef.current,t.shards]);var s=_e.useCallback(function(h,f){if("touches"in h&&h.touches.length===2||h.type==="wheel"&&h.ctrlKey)return!o.current.allowPinchZoom;var b=s2(h),y=n.current,w="deltaX"in h?h.deltaX:y[0]-b[0],k="deltaY"in h?h.deltaY:y[1]-b[1],C,x=h.target,_=Math.abs(w)>Math.abs(k)?"h":"v";if("touches"in h&&_==="h"&&x.type==="range")return!1;var E=window.getSelection(),D=E&&E.anchorNode,Q=D?D===x||D.contains(x):!1;if(Q)return!1;var B=Lre(_,x);if(!B)return!0;if(B?C=_:(C=_==="v"?"h":"v",B=Lre(_,x)),!B)return!1;if(!a.current&&"changedTouches"in h&&(w||k)&&(a.current=C),!C)return!0;var T=a.current||C;return Jet(T,f,h,T==="h"?w:k,!0)},[]),l=_e.useCallback(function(h){var f=h;if(!(!rb.length||rb[rb.length-1]!==i)){var b="deltaY"in f?Rre(f):s2(f),y=e.current.filter(function(C){return C.name===f.type&&(C.target===f.target||f.target===C.shadowParent)&&Xet(C.delta,b)})[0];if(y&&y.should){f.cancelable&&f.preventDefault();return}if(!y){var w=(o.current.shards||[]).map($re).filter(Boolean).filter(function(C){return C.contains(f.target)}),k=w.length>0?s(f,w[0]):!o.current.noIsolation;k&&f.cancelable&&f.preventDefault()}}},[]),u=_e.useCallback(function(h,f,b,y){var w={name:h,delta:f,target:b,should:y,shadowParent:att(b)};e.current.push(w),setTimeout(function(){e.current=e.current.filter(function(k){return k!==w})},1)},[]),d=_e.useCallback(function(h){n.current=s2(h),a.current=void 0},[]),p=_e.useCallback(function(h){u(h.type,Rre(h),h.target,s(h,t.lockRef.current))},[]),m=_e.useCallback(function(h){u(h.type,s2(h),h.target,s(h,t.lockRef.current))},[]);_e.useEffect(function(){return rb.push(i),t.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:m}),document.addEventListener("wheel",l,ab),document.addEventListener("touchmove",l,ab),document.addEventListener("touchstart",d,ab),function(){rb=rb.filter(function(h){return h!==i}),document.removeEventListener("wheel",l,ab),document.removeEventListener("touchmove",l,ab),document.removeEventListener("touchstart",d,ab)}},[]);var A=t.removeScrollBar,g=t.inert;return _e.createElement(_e.Fragment,null,g?_e.createElement(i,{styles:ett(r)}):null,A?_e.createElement(Het,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function att(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const rtt=Tet(Qre,ntt);var Pre=_e.forwardRef(function(t,e){return _e.createElement(i2,ru({},t,{ref:e,sideCar:rtt}))});Pre.classNames=i2.classNames;var itt=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},ib=new WeakMap,c2=new WeakMap,l2={},iF=0,Ore=function(t){return t&&(t.host||Ore(t.parentNode))},ott=function(t,e){return e.map(function(n){if(t.contains(n))return n;var a=Ore(n);return a&&t.contains(a)?a:(console.error("aria-hidden",n,"in not contained inside",t,". Doing nothing"),null)}).filter(function(n){return!!n})},stt=function(t,e,n,a){var r=ott(e,Array.isArray(t)?t:[t]);l2[n]||(l2[n]=new WeakMap);var i=l2[n],o=[],s=new Set,l=new Set(r),u=function(p){!p||s.has(p)||(s.add(p),u(p.parentNode))};r.forEach(u);var d=function(p){!p||l.has(p)||Array.prototype.forEach.call(p.children,function(m){if(s.has(m))d(m);else try{var A=m.getAttribute(a),g=A!==null&&A!=="false",h=(ib.get(m)||0)+1,f=(i.get(m)||0)+1;ib.set(m,h),i.set(m,f),o.push(m),h===1&&g&&c2.set(m,!0),f===1&&m.setAttribute(n,"true"),g||m.setAttribute(a,"true")}catch(b){console.error("aria-hidden: cannot operate on ",m,b)}})};return d(e),s.clear(),iF++,function(){o.forEach(function(p){var m=ib.get(p)-1,A=i.get(p)-1;ib.set(p,m),i.set(p,A),m||(c2.has(p)||p.removeAttribute(a),c2.delete(p)),A||p.removeAttribute(n)}),iF--,iF||(ib=new WeakMap,ib=new WeakMap,c2=new WeakMap,l2={})}},ctt=function(t,e,n){n===void 0&&(n="data-aria-hidden");var a=Array.from(Array.isArray(t)?t:[t]),r=itt(t);return r?(a.push.apply(a,Array.from(r.querySelectorAll("[aria-live], script"))),stt(a,r,n,"aria-hidden")):function(){return null}};function jre(t){const e=t+"CollectionProvider",[n,a]=SA(e),[r,i]=n(e,{collectionRef:{current:null},itemMap:new Map}),o=h=>{const{scope:f,children:b}=h,y=he.useRef(null),w=he.useRef(new Map).current;return H.jsx(r,{scope:f,itemMap:w,collectionRef:y,children:b})};o.displayName=e;const s=t+"CollectionSlot",l=zx(s),u=he.forwardRef((h,f)=>{const{scope:b,children:y}=h,w=i(s,b),k=Ji(f,w.collectionRef);return H.jsx(l,{ref:k,children:y})});u.displayName=s;const d=t+"CollectionItemSlot",p="data-radix-collection-item",m=zx(d),A=he.forwardRef((h,f)=>{const{scope:b,children:y,...w}=h,k=he.useRef(null),C=Ji(f,k),x=i(d,b);return he.useEffect(()=>(x.itemMap.set(k,{ref:k,...w}),()=>void x.itemMap.delete(k))),H.jsx(m,{[p]:"",ref:C,children:y})});A.displayName=d;function g(h){const f=i(t+"CollectionConsumer",h);return he.useCallback(()=>{const y=f.collectionRef.current;if(!y)return[];const w=Array.from(y.querySelectorAll(`[${p}]`));return Array.from(f.itemMap.values()).sort((x,_)=>w.indexOf(x.ref.current)-w.indexOf(_.ref.current))},[f.collectionRef,f.itemMap])}return[{Provider:o,Slot:u,ItemSlot:A},g,a]}var ltt=_e.createContext(void 0);function Gre(t){const e=_e.useContext(ltt);return t||e||"ltr"}var oF="rovingFocusGroup.onEntryFocus",utt={bubbles:!1,cancelable:!0},r1="RovingFocusGroup",[sF,qre,dtt]=jre(r1),[ptt,zre]=SA(r1,[dtt]),[mtt,Att]=ptt(r1),Hre=_e.forwardRef((t,e)=>H.jsx(sF.Provider,{scope:t.__scopeRovingFocusGroup,children:H.jsx(sF.Slot,{scope:t.__scopeRovingFocusGroup,children:H.jsx(gtt,{...t,ref:e})})}));Hre.displayName=r1;var gtt=_e.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,orientation:a,loop:r=!1,dir:i,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...p}=t,m=_e.useRef(null),A=Ji(e,m),g=Gre(i),[h,f]=mf({prop:o,defaultProp:s??null,onChange:l,caller:r1}),[b,y]=_e.useState(!1),w=rd(u),k=qre(n),C=_e.useRef(!1),[x,_]=_e.useState(0);return _e.useEffect(()=>{const E=m.current;if(E)return E.addEventListener(oF,w),()=>E.removeEventListener(oF,w)},[w]),H.jsx(mtt,{scope:n,orientation:a,dir:g,loop:r,currentTabStopId:h,onItemFocus:_e.useCallback(E=>f(E),[f]),onItemShiftTab:_e.useCallback(()=>y(!0),[]),onFocusableItemAdd:_e.useCallback(()=>_(E=>E+1),[]),onFocusableItemRemove:_e.useCallback(()=>_(E=>E-1),[]),children:H.jsx(Kr.div,{tabIndex:b||x===0?-1:0,"data-orientation":a,...p,ref:A,style:{outline:"none",...t.style},onMouseDown:_n(t.onMouseDown,()=>{C.current=!0}),onFocus:_n(t.onFocus,E=>{const D=!C.current;if(E.target===E.currentTarget&&D&&!b){const Q=new CustomEvent(oF,utt);if(E.currentTarget.dispatchEvent(Q),!Q.defaultPrevented){const B=k().filter(M=>M.focusable),T=B.find(M=>M.active),N=B.find(M=>M.id===h),S=[T,N,...B].filter(Boolean).map(M=>M.ref.current);Wre(S,d)}}C.current=!1}),onBlur:_n(t.onBlur,()=>y(!1))})})}),Ure="RovingFocusGroupItem",Yre=_e.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:a=!0,active:r=!1,tabStopId:i,children:o,...s}=t,l=Hx(),u=i||l,d=Att(Ure,n),p=d.currentTabStopId===u,m=qre(n),{onFocusableItemAdd:A,onFocusableItemRemove:g,currentTabStopId:h}=d;return _e.useEffect(()=>{if(a)return A(),()=>g()},[a,A,g]),H.jsx(sF.ItemSlot,{scope:n,id:u,focusable:a,active:r,children:H.jsx(Kr.span,{tabIndex:p?0:-1,"data-orientation":d.orientation,...s,ref:e,onMouseDown:_n(t.onMouseDown,f=>{a?d.onItemFocus(u):f.preventDefault()}),onFocus:_n(t.onFocus,()=>d.onItemFocus(u)),onKeyDown:_n(t.onKeyDown,f=>{if(f.key==="Tab"&&f.shiftKey){d.onItemShiftTab();return}if(f.target!==f.currentTarget)return;const b=btt(f,d.orientation,d.dir);if(b!==void 0){if(f.metaKey||f.ctrlKey||f.altKey||f.shiftKey)return;f.preventDefault();let w=m().filter(k=>k.focusable).map(k=>k.ref.current);if(b==="last")w.reverse();else if(b==="prev"||b==="next"){b==="prev"&&w.reverse();const k=w.indexOf(f.currentTarget);w=d.loop?ytt(w,k+1):w.slice(k+1)}setTimeout(()=>Wre(w))}}),children:typeof o=="function"?o({isCurrentTabStop:p,hasTabStop:h!=null}):o})})});Yre.displayName=Ure;var htt={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function ftt(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function btt(t,e,n){const a=ftt(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(a))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(a)))return htt[a]}function Wre(t,e=!1){const n=document.activeElement;for(const a of t)if(a===n||(a.focus({preventScroll:e}),document.activeElement!==n))return}function ytt(t,e){return t.map((n,a)=>t[(e+a)%t.length])}var wtt=Hre,ktt=Yre,cF=["Enter"," "],vtt=["ArrowDown","PageUp","Home"],Kre=["ArrowUp","PageDown","End"],Ctt=[...vtt,...Kre],_tt={ltr:[...cF,"ArrowRight"],rtl:[...cF,"ArrowLeft"]},xtt={ltr:["ArrowLeft"],rtl:["ArrowRight"]},i1="Menu",[o1,Ett,Btt]=jre(i1),[ig,Zre]=SA(i1,[Btt,tE,zre]),u2=tE(),Vre=zre(),[Itt,og]=ig(i1),[Dtt,s1]=ig(i1),Jre=t=>{const{__scopeMenu:e,open:n=!1,children:a,dir:r,onOpenChange:i,modal:o=!0}=t,s=u2(e),[l,u]=_e.useState(null),d=_e.useRef(!1),p=rd(i),m=Gre(r);return _e.useEffect(()=>{const A=()=>{d.current=!0,document.addEventListener("pointerdown",g,{capture:!0,once:!0}),document.addEventListener("pointermove",g,{capture:!0,once:!0})},g=()=>d.current=!1;return document.addEventListener("keydown",A,{capture:!0}),()=>{document.removeEventListener("keydown",A,{capture:!0}),document.removeEventListener("pointerdown",g,{capture:!0}),document.removeEventListener("pointermove",g,{capture:!0})}},[]),H.jsx(XU,{...s,children:H.jsx(Itt,{scope:e,open:n,onOpenChange:p,content:l,onContentChange:u,children:H.jsx(Dtt,{scope:e,onClose:_e.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:d,dir:m,modal:o,children:a})})})};Jre.displayName=i1;var Qtt="MenuAnchor",lF=_e.forwardRef((t,e)=>{const{__scopeMenu:n,...a}=t,r=u2(n);return H.jsx(eY,{...r,...a,ref:e})});lF.displayName=Qtt;var uF="MenuPortal",[Stt,Xre]=ig(uF,{forceMount:void 0}),eie=t=>{const{__scopeMenu:e,forceMount:n,children:a,container:r}=t,i=og(uF,e);return H.jsx(Stt,{scope:e,forceMount:n,children:H.jsx(Sp,{present:n||i.open,children:H.jsx(k9,{asChild:!0,container:r,children:a})})})};eie.displayName=uF;var wc="MenuContent",[Ttt,dF]=ig(wc),tie=_e.forwardRef((t,e)=>{const n=Xre(wc,t.__scopeMenu),{forceMount:a=n.forceMount,...r}=t,i=og(wc,t.__scopeMenu),o=s1(wc,t.__scopeMenu);return H.jsx(o1.Provider,{scope:t.__scopeMenu,children:H.jsx(Sp,{present:a||i.open,children:H.jsx(o1.Slot,{scope:t.__scopeMenu,children:o.modal?H.jsx(Ftt,{...r,ref:e}):H.jsx(Ltt,{...r,ref:e})})})})}),Ftt=_e.forwardRef((t,e)=>{const n=og(wc,t.__scopeMenu),a=_e.useRef(null),r=Ji(e,a);return _e.useEffect(()=>{const i=a.current;if(i)return ctt(i)},[]),H.jsx(pF,{...t,ref:r,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:_n(t.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Ltt=_e.forwardRef((t,e)=>{const n=og(wc,t.__scopeMenu);return H.jsx(pF,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Ntt=zx("MenuContent.ScrollLock"),pF=_e.forwardRef((t,e)=>{const{__scopeMenu:n,loop:a=!1,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:l,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:p,onInteractOutside:m,onDismiss:A,disableOutsideScroll:g,...h}=t,f=og(wc,n),b=s1(wc,n),y=u2(n),w=Vre(n),k=Ett(n),[C,x]=_e.useState(null),_=_e.useRef(null),E=Ji(e,_,f.onContentChange),D=_e.useRef(0),Q=_e.useRef(""),B=_e.useRef(0),T=_e.useRef(null),N=_e.useRef("right"),I=_e.useRef(0),S=g?Pre:_e.Fragment,M=g?{as:Ntt,allowPinchZoom:!0}:void 0,L=R=>{var ee,me;const $=Q.current+R,P=k().filter(V=>!V.disabled),q=document.activeElement,j=(ee=P.find(V=>V.ref.current===q))==null?void 0:ee.textValue,J=P.map(V=>V.textValue),Y=Ytt(J,$,j),ne=(me=P.find(V=>V.textValue===Y))==null?void 0:me.ref.current;(function V(te){Q.current=te,window.clearTimeout(D.current),te!==""&&(D.current=window.setTimeout(()=>V(""),1e3))})($),ne&&setTimeout(()=>ne.focus())};_e.useEffect(()=>()=>window.clearTimeout(D.current),[]),ket();const F=_e.useCallback(R=>{var P,q;return N.current===((P=T.current)==null?void 0:P.side)&&Ktt(R,(q=T.current)==null?void 0:q.area)},[]);return H.jsx(Ttt,{scope:n,searchRef:Q,onItemEnter:_e.useCallback(R=>{F(R)&&R.preventDefault()},[F]),onItemLeave:_e.useCallback(R=>{var $;F(R)||(($=_.current)==null||$.focus(),x(null))},[F]),onTriggerLeave:_e.useCallback(R=>{F(R)&&R.preventDefault()},[F]),pointerGraceTimerRef:B,onPointerGraceIntentChange:_e.useCallback(R=>{T.current=R},[]),children:H.jsx(S,{...M,children:H.jsx(kre,{asChild:!0,trapped:r,onMountAutoFocus:_n(i,R=>{var $;R.preventDefault(),($=_.current)==null||$.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:H.jsx(c9,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:p,onInteractOutside:m,onDismiss:A,children:H.jsx(wtt,{asChild:!0,...w,dir:b.dir,orientation:"vertical",loop:a,currentTabStopId:C,onCurrentTabStopIdChange:x,onEntryFocus:_n(l,R=>{b.isUsingKeyboardRef.current||R.preventDefault()}),preventScrollOnEntryFocus:!0,children:H.jsx(tY,{role:"menu","aria-orientation":"vertical","data-state":bie(f.open),"data-radix-menu-content":"",dir:b.dir,...y,...h,ref:E,style:{outline:"none",...h.style},onKeyDown:_n(h.onKeyDown,R=>{const P=R.target.closest("[data-radix-menu-content]")===R.currentTarget,q=R.ctrlKey||R.altKey||R.metaKey,j=R.key.length===1;P&&(R.key==="Tab"&&R.preventDefault(),!q&&j&&L(R.key));const J=_.current;if(R.target!==J||!Ctt.includes(R.key))return;R.preventDefault();const ne=k().filter(ee=>!ee.disabled).map(ee=>ee.ref.current);Kre.includes(R.key)&&ne.reverse(),Htt(ne)}),onBlur:_n(t.onBlur,R=>{R.currentTarget.contains(R.target)||(window.clearTimeout(D.current),Q.current="")}),onPointerMove:_n(t.onPointerMove,l1(R=>{const $=R.target,P=I.current!==R.clientX;if(R.currentTarget.contains($)&&P){const q=R.clientX>I.current?"right":"left";N.current=q,I.current=R.clientX}}))})})})})})})});tie.displayName=wc;var Mtt="MenuGroup",mF=_e.forwardRef((t,e)=>{const{__scopeMenu:n,...a}=t;return H.jsx(Kr.div,{role:"group",...a,ref:e})});mF.displayName=Mtt;var Rtt="MenuLabel",nie=_e.forwardRef((t,e)=>{const{__scopeMenu:n,...a}=t;return H.jsx(Kr.div,{...a,ref:e})});nie.displayName=Rtt;var d2="MenuItem",aie="menu.itemSelect",p2=_e.forwardRef((t,e)=>{const{disabled:n=!1,onSelect:a,...r}=t,i=_e.useRef(null),o=s1(d2,t.__scopeMenu),s=dF(d2,t.__scopeMenu),l=Ji(e,i),u=_e.useRef(!1),d=()=>{const p=i.current;if(!n&&p){const m=new CustomEvent(aie,{bubbles:!0,cancelable:!0});p.addEventListener(aie,A=>a==null?void 0:a(A),{once:!0}),yU(p,m),m.defaultPrevented?u.current=!1:o.onClose()}};return H.jsx(rie,{...r,ref:l,disabled:n,onClick:_n(t.onClick,d),onPointerDown:p=>{var m;(m=t.onPointerDown)==null||m.call(t,p),u.current=!0},onPointerUp:_n(t.onPointerUp,p=>{var m;u.current||(m=p.currentTarget)==null||m.click()}),onKeyDown:_n(t.onKeyDown,p=>{const m=s.searchRef.current!=="";n||m&&p.key===" "||cF.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});p2.displayName=d2;var rie=_e.forwardRef((t,e)=>{const{__scopeMenu:n,disabled:a=!1,textValue:r,...i}=t,o=dF(d2,n),s=Vre(n),l=_e.useRef(null),u=Ji(e,l),[d,p]=_e.useState(!1),[m,A]=_e.useState("");return _e.useEffect(()=>{const g=l.current;g&&A((g.textContent??"").trim())},[i.children]),H.jsx(o1.ItemSlot,{scope:n,disabled:a,textValue:r??m,children:H.jsx(ktt,{asChild:!0,...s,focusable:!a,children:H.jsx(Kr.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":a||void 0,"data-disabled":a?"":void 0,...i,ref:u,onPointerMove:_n(t.onPointerMove,l1(g=>{a?o.onItemLeave(g):(o.onItemEnter(g),g.defaultPrevented||g.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:_n(t.onPointerLeave,l1(g=>o.onItemLeave(g))),onFocus:_n(t.onFocus,()=>p(!0)),onBlur:_n(t.onBlur,()=>p(!1))})})})}),$tt="MenuCheckboxItem",iie=_e.forwardRef((t,e)=>{const{checked:n=!1,onCheckedChange:a,...r}=t;return H.jsx(uie,{scope:t.__scopeMenu,checked:n,children:H.jsx(p2,{role:"menuitemcheckbox","aria-checked":m2(n)?"mixed":n,...r,ref:e,"data-state":gF(n),onSelect:_n(r.onSelect,()=>a==null?void 0:a(m2(n)?!0:!n),{checkForDefaultPrevented:!1})})})});iie.displayName=$tt;var oie="MenuRadioGroup",[Ptt,Ott]=ig(oie,{value:void 0,onValueChange:()=>{}}),sie=_e.forwardRef((t,e)=>{const{value:n,onValueChange:a,...r}=t,i=rd(a);return H.jsx(Ptt,{scope:t.__scopeMenu,value:n,onValueChange:i,children:H.jsx(mF,{...r,ref:e})})});sie.displayName=oie;var cie="MenuRadioItem",lie=_e.forwardRef((t,e)=>{const{value:n,...a}=t,r=Ott(cie,t.__scopeMenu),i=n===r.value;return H.jsx(uie,{scope:t.__scopeMenu,checked:i,children:H.jsx(p2,{role:"menuitemradio","aria-checked":i,...a,ref:e,"data-state":gF(i),onSelect:_n(a.onSelect,()=>{var o;return(o=r.onValueChange)==null?void 0:o.call(r,n)},{checkForDefaultPrevented:!1})})})});lie.displayName=cie;var AF="MenuItemIndicator",[uie,jtt]=ig(AF,{checked:!1}),die=_e.forwardRef((t,e)=>{const{__scopeMenu:n,forceMount:a,...r}=t,i=jtt(AF,n);return H.jsx(Sp,{present:a||m2(i.checked)||i.checked===!0,children:H.jsx(Kr.span,{...r,ref:e,"data-state":gF(i.checked)})})});die.displayName=AF;var Gtt="MenuSeparator",pie=_e.forwardRef((t,e)=>{const{__scopeMenu:n,...a}=t;return H.jsx(Kr.div,{role:"separator","aria-orientation":"horizontal",...a,ref:e})});pie.displayName=Gtt;var qtt="MenuArrow",mie=_e.forwardRef((t,e)=>{const{__scopeMenu:n,...a}=t,r=u2(n);return H.jsx(nY,{...r,...a,ref:e})});mie.displayName=qtt;var ztt="MenuSub",[U0n,Aie]=ig(ztt),c1="MenuSubTrigger",gie=_e.forwardRef((t,e)=>{const n=og(c1,t.__scopeMenu),a=s1(c1,t.__scopeMenu),r=Aie(c1,t.__scopeMenu),i=dF(c1,t.__scopeMenu),o=_e.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:l}=i,u={__scopeMenu:t.__scopeMenu},d=_e.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return _e.useEffect(()=>d,[d]),_e.useEffect(()=>{const p=s.current;return()=>{window.clearTimeout(p),l(null)}},[s,l]),H.jsx(lF,{asChild:!0,...u,children:H.jsx(rie,{id:r.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":r.contentId,"data-state":bie(n.open),...t,ref:$0(e,r.onTriggerChange),onClick:p=>{var m;(m=t.onClick)==null||m.call(t,p),!(t.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:_n(t.onPointerMove,l1(p=>{i.onItemEnter(p),!p.defaultPrevented&&!t.disabled&&!n.open&&!o.current&&(i.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:_n(t.onPointerLeave,l1(p=>{var A,g;d();const m=(A=n.content)==null?void 0:A.getBoundingClientRect();if(m){const h=(g=n.content)==null?void 0:g.dataset.side,f=h==="right",b=f?-5:5,y=m[f?"left":"right"],w=m[f?"right":"left"];i.onPointerGraceIntentChange({area:[{x:p.clientX+b,y:p.clientY},{x:y,y:m.top},{x:w,y:m.top},{x:w,y:m.bottom},{x:y,y:m.bottom}],side:h}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(p),p.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:_n(t.onKeyDown,p=>{var A;const m=i.searchRef.current!=="";t.disabled||m&&p.key===" "||_tt[a.dir].includes(p.key)&&(n.onOpenChange(!0),(A=n.content)==null||A.focus(),p.preventDefault())})})})});gie.displayName=c1;var hie="MenuSubContent",fie=_e.forwardRef((t,e)=>{const n=Xre(wc,t.__scopeMenu),{forceMount:a=n.forceMount,...r}=t,i=og(wc,t.__scopeMenu),o=s1(wc,t.__scopeMenu),s=Aie(hie,t.__scopeMenu),l=_e.useRef(null),u=Ji(e,l);return H.jsx(o1.Provider,{scope:t.__scopeMenu,children:H.jsx(Sp,{present:a||i.open,children:H.jsx(o1.Slot,{scope:t.__scopeMenu,children:H.jsx(pF,{id:s.contentId,"aria-labelledby":s.triggerId,...r,ref:u,align:"start",side:o.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var p;o.isUsingKeyboardRef.current&&((p=l.current)==null||p.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:_n(t.onFocusOutside,d=>{d.target!==s.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:_n(t.onEscapeKeyDown,d=>{o.onClose(),d.preventDefault()}),onKeyDown:_n(t.onKeyDown,d=>{var A;const p=d.currentTarget.contains(d.target),m=xtt[o.dir].includes(d.key);p&&m&&(i.onOpenChange(!1),(A=s.trigger)==null||A.focus(),d.preventDefault())})})})})})});fie.displayName=hie;function bie(t){return t?"open":"closed"}function m2(t){return t==="indeterminate"}function gF(t){return m2(t)?"indeterminate":t?"checked":"unchecked"}function Htt(t){const e=document.activeElement;for(const n of t)if(n===e||(n.focus(),document.activeElement!==e))return}function Utt(t,e){return t.map((n,a)=>t[(e+a)%t.length])}function Ytt(t,e,n){const r=e.length>1&&Array.from(e).every(u=>u===e[0])?e[0]:e,i=n?t.indexOf(n):-1;let o=Utt(t,Math.max(i,0));r.length===1&&(o=o.filter(u=>u!==n));const l=o.find(u=>u.toLowerCase().startsWith(r.toLowerCase()));return l!==n?l:void 0}function Wtt(t,e){const{x:n,y:a}=t;let r=!1;for(let i=0,o=e.length-1;i<e.length;o=i++){const s=e[i],l=e[o],u=s.x,d=s.y,p=l.x,m=l.y;d>a!=m>a&&n<(p-u)*(a-d)/(m-d)+u&&(r=!r)}return r}function Ktt(t,e){if(!e)return!1;const n={x:t.clientX,y:t.clientY};return Wtt(n,e)}function l1(t){return e=>e.pointerType==="mouse"?t(e):void 0}var Ztt=Jre,Vtt=lF,Jtt=eie,Xtt=tie,ent=mF,tnt=nie,nnt=p2,ant=iie,rnt=sie,int=lie,ont=die,snt=pie,cnt=mie,lnt=gie,unt=fie,A2="DropdownMenu",[dnt,Y0n]=SA(A2,[Zre]),No=Zre(),[pnt,yie]=dnt(A2),wie=t=>{const{__scopeDropdownMenu:e,children:n,dir:a,open:r,defaultOpen:i,onOpenChange:o,modal:s=!0}=t,l=No(e),u=_e.useRef(null),[d,p]=mf({prop:r,defaultProp:i??!1,onChange:o,caller:A2});return H.jsx(pnt,{scope:e,triggerId:Hx(),triggerRef:u,contentId:Hx(),open:d,onOpenChange:p,onOpenToggle:_e.useCallback(()=>p(m=>!m),[p]),modal:s,children:H.jsx(Ztt,{...l,open:d,onOpenChange:p,dir:a,modal:s,children:n})})};wie.displayName=A2;var kie="DropdownMenuTrigger",vie=_e.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,disabled:a=!1,...r}=t,i=yie(kie,n),o=No(n);return H.jsx(Vtt,{asChild:!0,...o,children:H.jsx(Kr.button,{type:"button",id:i.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":i.open?"open":"closed","data-disabled":a?"":void 0,disabled:a,...r,ref:$0(e,i.triggerRef),onPointerDown:_n(t.onPointerDown,s=>{!a&&s.button===0&&s.ctrlKey===!1&&(i.onOpenToggle(),i.open||s.preventDefault())}),onKeyDown:_n(t.onKeyDown,s=>{a||(["Enter"," "].includes(s.key)&&i.onOpenToggle(),s.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(s.key)&&s.preventDefault())})})})});vie.displayName=kie;var mnt="DropdownMenuPortal",Cie=t=>{const{__scopeDropdownMenu:e,...n}=t,a=No(e);return H.jsx(Jtt,{...a,...n})};Cie.displayName=mnt;var _ie="DropdownMenuContent",xie=_e.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...a}=t,r=yie(_ie,n),i=No(n),o=_e.useRef(!1);return H.jsx(Xtt,{id:r.contentId,"aria-labelledby":r.triggerId,...i,...a,ref:e,onCloseAutoFocus:_n(t.onCloseAutoFocus,s=>{var l;o.current||(l=r.triggerRef.current)==null||l.focus(),o.current=!1,s.preventDefault()}),onInteractOutside:_n(t.onInteractOutside,s=>{const l=s.detail.originalEvent,u=l.button===0&&l.ctrlKey===!0,d=l.button===2||u;(!r.modal||d)&&(o.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});xie.displayName=_ie;var Ant="DropdownMenuGroup",gnt=_e.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...a}=t,r=No(n);return H.jsx(ent,{...r,...a,ref:e})});gnt.displayName=Ant;var hnt="DropdownMenuLabel",fnt=_e.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...a}=t,r=No(n);return H.jsx(tnt,{...r,...a,ref:e})});fnt.displayName=hnt;var bnt="DropdownMenuItem",Eie=_e.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...a}=t,r=No(n);return H.jsx(nnt,{...r,...a,ref:e})});Eie.displayName=bnt;var ynt="DropdownMenuCheckboxItem",wnt=_e.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...a}=t,r=No(n);return H.jsx(ant,{...r,...a,ref:e})});wnt.displayName=ynt;var knt="DropdownMenuRadioGroup",vnt=_e.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...a}=t,r=No(n);return H.jsx(rnt,{...r,...a,ref:e})});vnt.displayName=knt;var Cnt="DropdownMenuRadioItem",_nt=_e.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...a}=t,r=No(n);return H.jsx(int,{...r,...a,ref:e})});_nt.displayName=Cnt;var xnt="DropdownMenuItemIndicator",Ent=_e.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...a}=t,r=No(n);return H.jsx(ont,{...r,...a,ref:e})});Ent.displayName=xnt;var Bnt="DropdownMenuSeparator",Int=_e.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...a}=t,r=No(n);return H.jsx(snt,{...r,...a,ref:e})});Int.displayName=Bnt;var Dnt="DropdownMenuArrow",Qnt=_e.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...a}=t,r=No(n);return H.jsx(cnt,{...r,...a,ref:e})});Qnt.displayName=Dnt;var Snt="DropdownMenuSubTrigger",Tnt=_e.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...a}=t,r=No(n);return H.jsx(lnt,{...r,...a,ref:e})});Tnt.displayName=Snt;var Fnt="DropdownMenuSubContent",Lnt=_e.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...a}=t,r=No(n);return H.jsx(unt,{...r,...a,ref:e,style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Lnt.displayName=Fnt;var Nnt=wie,Mnt=vie,Rnt=Cie,$nt=xie,Pnt=Eie;function Ont({...t}){return H.jsx(Nnt,{"data-slot":"dropdown-menu",...t})}function jnt({...t}){return H.jsx(Mnt,{"data-slot":"dropdown-menu-trigger",...t})}function Gnt({className:t,sideOffset:e=4,...n}){return H.jsx(Rnt,{children:H.jsx($nt,{"data-slot":"dropdown-menu-content",sideOffset:e,className:Tn("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",t),...n})})}function qnt({className:t,inset:e,variant:n="default",...a}){return H.jsx(Pnt,{"data-slot":"dropdown-menu-item","data-inset":e,"data-variant":n,className:Tn("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...a})}var hF,g2="HoverCard",[Bie,W0n]=SA(g2,[tE]),h2=tE(),[znt,f2]=Bie(g2),Iie=t=>{const{__scopeHoverCard:e,children:n,open:a,defaultOpen:r,onOpenChange:i,openDelay:o=700,closeDelay:s=300}=t,l=h2(e),u=_e.useRef(0),d=_e.useRef(0),p=_e.useRef(!1),m=_e.useRef(!1),[A,g]=mf({prop:a,defaultProp:r??!1,onChange:i,caller:g2}),h=_e.useCallback(()=>{clearTimeout(d.current),u.current=window.setTimeout(()=>g(!0),o)},[o,g]),f=_e.useCallback(()=>{clearTimeout(u.current),!p.current&&!m.current&&(d.current=window.setTimeout(()=>g(!1),s))},[s,g]),b=_e.useCallback(()=>g(!1),[g]);return _e.useEffect(()=>()=>{clearTimeout(u.current),clearTimeout(d.current)},[]),H.jsx(znt,{scope:e,open:A,onOpenChange:g,onOpen:h,onClose:f,onDismiss:b,hasSelectionRef:p,isPointerDownOnContentRef:m,children:H.jsx(XU,{...l,children:n})})};Iie.displayName=g2;var Die="HoverCardTrigger",Qie=_e.forwardRef((t,e)=>{const{__scopeHoverCard:n,...a}=t,r=f2(Die,n),i=h2(n);return H.jsx(eY,{asChild:!0,...i,children:H.jsx(Kr.a,{"data-state":r.open?"open":"closed",...a,ref:e,onPointerEnter:_n(t.onPointerEnter,y2(r.onOpen)),onPointerLeave:_n(t.onPointerLeave,y2(r.onClose)),onFocus:_n(t.onFocus,r.onOpen),onBlur:_n(t.onBlur,r.onClose),onTouchStart:_n(t.onTouchStart,o=>o.preventDefault())})})});Qie.displayName=Die;var fF="HoverCardPortal",[Hnt,Unt]=Bie(fF,{forceMount:void 0}),Sie=t=>{const{__scopeHoverCard:e,forceMount:n,children:a,container:r}=t,i=f2(fF,e);return H.jsx(Hnt,{scope:e,forceMount:n,children:H.jsx(Sp,{present:n||i.open,children:H.jsx(k9,{asChild:!0,container:r,children:a})})})};Sie.displayName=fF;var b2="HoverCardContent",Tie=_e.forwardRef((t,e)=>{const n=Unt(b2,t.__scopeHoverCard),{forceMount:a=n.forceMount,...r}=t,i=f2(b2,t.__scopeHoverCard);return H.jsx(Sp,{present:a||i.open,children:H.jsx(Ynt,{"data-state":i.open?"open":"closed",...r,onPointerEnter:_n(t.onPointerEnter,y2(i.onOpen)),onPointerLeave:_n(t.onPointerLeave,y2(i.onClose)),ref:e})})});Tie.displayName=b2;var Ynt=_e.forwardRef((t,e)=>{const{__scopeHoverCard:n,onEscapeKeyDown:a,onPointerDownOutside:r,onFocusOutside:i,onInteractOutside:o,...s}=t,l=f2(b2,n),u=h2(n),d=_e.useRef(null),p=Ji(e,d),[m,A]=_e.useState(!1);return _e.useEffect(()=>{if(m){const g=document.body;return hF=g.style.userSelect||g.style.webkitUserSelect,g.style.userSelect="none",g.style.webkitUserSelect="none",()=>{g.style.userSelect=hF,g.style.webkitUserSelect=hF}}},[m]),_e.useEffect(()=>{if(d.current){const g=()=>{A(!1),l.isPointerDownOnContentRef.current=!1,setTimeout(()=>{var f;((f=document.getSelection())==null?void 0:f.toString())!==""&&(l.hasSelectionRef.current=!0)})};return document.addEventListener("pointerup",g),()=>{document.removeEventListener("pointerup",g),l.hasSelectionRef.current=!1,l.isPointerDownOnContentRef.current=!1}}},[l.isPointerDownOnContentRef,l.hasSelectionRef]),_e.useEffect(()=>{d.current&&Znt(d.current).forEach(h=>h.setAttribute("tabindex","-1"))}),H.jsx(c9,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:o,onEscapeKeyDown:a,onPointerDownOutside:r,onFocusOutside:_n(i,g=>{g.preventDefault()}),onDismiss:l.onDismiss,children:H.jsx(tY,{...u,...s,onPointerDown:_n(s.onPointerDown,g=>{g.currentTarget.contains(g.target)&&A(!0),l.hasSelectionRef.current=!1,l.isPointerDownOnContentRef.current=!0}),ref:p,style:{...s.style,userSelect:m?"text":void 0,WebkitUserSelect:m?"text":void 0,"--radix-hover-card-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-hover-card-content-available-width":"var(--radix-popper-available-width)","--radix-hover-card-content-available-height":"var(--radix-popper-available-height)","--radix-hover-card-trigger-width":"var(--radix-popper-anchor-width)","--radix-hover-card-trigger-height":"var(--radix-popper-anchor-height)"}})})}),Wnt="HoverCardArrow",Knt=_e.forwardRef((t,e)=>{const{__scopeHoverCard:n,...a}=t,r=h2(n);return H.jsx(nY,{...r,...a,ref:e})});Knt.displayName=Wnt;function y2(t){return e=>e.pointerType==="touch"?void 0:t()}function Znt(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:a=>a.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});for(;n.nextNode();)e.push(n.currentNode);return e}var Vnt=Iie,Jnt=Qie,Xnt=Sie,eat=Tie;function tat({...t}){return H.jsx(Vnt,{"data-slot":"hover-card",...t})}function nat({...t}){return H.jsx(Jnt,{"data-slot":"hover-card-trigger",...t})}function aat({className:t,align:e="center",sideOffset:n=4,...a}){return H.jsx(Xnt,{"data-slot":"hover-card-portal",children:H.jsx(eat,{"data-slot":"hover-card-content",align:e,sideOffset:n,className:Tn("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-64 origin-(--radix-hover-card-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",t),...a})})}function rat({className:t,type:e,...n}){return H.jsx("input",{type:e,"data-slot":"input",className:Tn("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",t),...n})}function iat({className:t,...e}){return H.jsx("textarea",{"data-slot":"textarea",className:Tn("border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),...e})}function oat({className:t,...e}){return H.jsx("div",{"data-slot":"input-group",role:"group",className:Tn("group/input-group border-input dark:bg-input/30 relative flex w-full items-center rounded-md border shadow-xs transition-[color,box-shadow] outline-none","h-9 min-w-0 has-[>textarea]:h-auto","has-[>[data-align=inline-start]]:[&>input]:pl-2","has-[>[data-align=inline-end]]:[&>input]:pr-2","has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3","has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3","has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot=input-group-control]:focus-visible]:ring-[3px]","has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[[data-slot][aria-invalid=true]]:border-destructive dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40",t),...e})}const sat=Ox("text-muted-foreground flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium select-none [&>svg:not([class*='size-'])]:size-4 [&>kbd]:rounded-[calc(var(--radius)-5px)] group-data-[disabled=true]/input-group:opacity-50",{variants:{align:{"inline-start":"order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]","inline-end":"order-last pr-3 has-[>button]:mr-[-0.45rem] has-[>kbd]:mr-[-0.35rem]","block-start":"order-first w-full justify-start px-3 pt-3 [.border-b]:pb-3 group-has-[>input]/input-group:pt-2.5","block-end":"order-last w-full justify-start px-3 pb-3 [.border-t]:pt-3 group-has-[>input]/input-group:pb-2.5"}},defaultVariants:{align:"inline-start"}});function Fie({className:t,align:e="inline-start",...n}){return H.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":e,className:Tn(sat({align:e}),t),onClick:a=>{var r,i;a.target.closest("button")||(i=(r=a.currentTarget.parentElement)==null?void 0:r.querySelector("input"))==null||i.focus()},...n})}const cat=Ox(" input-group-button text-sm shadow-none flex gap-2 items-center",{variants:{size:{xs:"h-6 gap-1 px-2 rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-3.5 has-[>svg]:px-2",sm:"h-8 px-2.5 gap-1.5 rounded-md has-[>svg]:px-2.5","icon-xs":"size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function lat({className:t,type:e="button",variant:n="ghost",size:a="xs",...r}){return H.jsx(sf,{type:e,"data-size":a,variant:n,className:Tn(cat({size:a}),t),...r})}function uat({className:t,...e}){return H.jsx(iat,{"data-slot":"input-group-control",className:Tn("input-group-textarea flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent",t),...e})}const dat="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let pat=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=dat[n[t]&63];return e};const mat=he.createContext(null),Aat=he.createContext(null),Lie=()=>he.useContext(mat),gat=()=>he.useContext(Aat),Nie=he.createContext(null),w2=()=>{const t=gat(),e=he.useContext(Nie),n=t??e;if(!n)throw new Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");return n};function hat({data:t,className:e,...n}){var l;const a=w2(),r=t.filename||"",o=((l=t.mediaType)!=null&&l.startsWith("image/")&&t.url?"image":"file")==="image",s=r||(o?"Image":"Attachment");return H.jsxs(Iat,{children:[H.jsx(nat,{asChild:!0,children:H.jsxs("div",{className:Tn("group relative flex h-8 cursor-pointer select-none items-center gap-1.5 rounded-md border border-border px-1.5 font-medium text-sm transition-all hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",e),...n,children:[H.jsxs("div",{className:"relative size-5 shrink-0",children:[H.jsx("div",{className:"absolute inset-0 flex size-5 items-center justify-center overflow-hidden rounded bg-background transition-opacity group-hover:opacity-0",children:o?H.jsx("img",{alt:r||"attachment",className:"size-5 object-cover",height:20,src:t.url,width:20}):H.jsx("div",{className:"flex size-5 items-center justify-center text-muted-foreground",children:H.jsx(xSe,{className:"size-3"})})}),H.jsxs(sf,{"aria-label":"Remove attachment",className:"absolute inset-0 size-5 cursor-pointer rounded p-0 opacity-0 transition-opacity group-hover:pointer-events-auto group-hover:opacity-100 [&>svg]:size-2.5",onClick:u=>{u.stopPropagation(),a.remove(t.id)},type:"button",variant:"ghost",children:[H.jsx(ISe,{}),H.jsx("span",{className:"sr-only",children:"Remove"})]})]}),H.jsx("span",{className:"flex-1 truncate",children:s})]},t.id)}),H.jsx(Dat,{className:"w-auto p-2",children:H.jsxs("div",{className:"w-auto space-y-3",children:[o&&H.jsx("div",{className:"flex max-h-96 w-96 items-center justify-center overflow-hidden rounded-md border",children:H.jsx("img",{alt:r||"attachment preview",className:"max-h-full max-w-full object-contain",height:384,src:t.url,width:448})}),H.jsx("div",{className:"flex items-center gap-2.5",children:H.jsxs("div",{className:"min-w-0 flex-1 space-y-1 px-0.5",children:[H.jsx("h4",{className:"truncate font-semibold text-sm leading-none",children:r||(o?"Image":"Attachment")}),t.mediaType&&H.jsx("p",{className:"truncate font-mono text-muted-foreground text-xs",children:t.mediaType})]})})]})})]})}function fat({children:t,className:e,...n}){const a=w2();return a.files.length?H.jsx("div",{className:Tn("flex flex-wrap items-center gap-2 p-3 w-full",e),...n,children:a.files.map(r=>H.jsx(he.Fragment,{children:t(r)},r.id))}):null}const bat=({label:t="Add photos or files",...e})=>{const n=w2();return H.jsxs(qnt,{...e,onSelect:a=>{a.preventDefault(),n.openFileDialog()},children:[H.jsx(vSe,{className:"mr-2 size-4"})," ",t]})},yat=({className:t,accept:e,multiple:n,globalDrop:a,syncHiddenInput:r,maxFiles:i,maxFileSize:o,onError:s,onSubmit:l,children:u,...d})=>{const p=Lie(),m=!!p,A=he.useRef(null),g=he.useRef(null),[h,f]=he.useState([]),b=m?p.attachments.files:h,y=he.useRef(b);y.current=b;const w=he.useCallback(()=>{var L;(L=A.current)==null||L.click()},[]),k=he.useCallback(L=>!e||e.trim()===""?!0:e.split(",").map(R=>R.trim()).filter(Boolean).some(R=>{if(R.endsWith("/*")){const $=R.slice(0,-1);return L.type.startsWith($)}return L.type===R}),[e]),C=he.useCallback(L=>{const F=Array.from(L),R=F.filter(q=>k(q));if(F.length&&R.length===0){s==null||s({code:"accept",message:"No files match the accepted types."});return}const $=q=>o?q.size<=o:!0,P=R.filter($);if(R.length>0&&P.length===0){s==null||s({code:"max_file_size",message:"All files exceed the maximum size."});return}f(q=>{const j=typeof i=="number"?Math.max(0,i-q.length):void 0,J=typeof j=="number"?P.slice(0,j):P;typeof j=="number"&&P.length>j&&(s==null||s({code:"max_files",message:"Too many files. Some were not added."}));const Y=[];for(const ne of J)Y.push({id:pat(),type:"file",url:URL.createObjectURL(ne),mediaType:ne.type,filename:ne.name});return q.concat(Y)})},[k,i,o,s]),x=he.useCallback(L=>f(F=>{const R=F.find($=>$.id===L);return R!=null&&R.url&&URL.revokeObjectURL(R.url),F.filter($=>$.id!==L)}),[]),_=he.useCallback(()=>f(L=>{for(const F of L)F.url&&URL.revokeObjectURL(F.url);return[]}),[]),E=m?p.attachments.add:C,D=m?p.attachments.remove:x,Q=m?p.attachments.clear:_,B=m?p.attachments.openFileDialog:w;he.useEffect(()=>{m&&p.__registerFileInput(A,()=>{var L;return(L=A.current)==null?void 0:L.click()})},[m,p]),he.useEffect(()=>{r&&A.current&&b.length===0&&(A.current.value="")},[b,r]),he.useEffect(()=>{const L=g.current;if(!L||a)return;const F=$=>{var P,q;(q=(P=$.dataTransfer)==null?void 0:P.types)!=null&&q.includes("Files")&&$.preventDefault()},R=$=>{var P,q,j;(q=(P=$.dataTransfer)==null?void 0:P.types)!=null&&q.includes("Files")&&$.preventDefault(),(j=$.dataTransfer)!=null&&j.files&&$.dataTransfer.files.length>0&&E($.dataTransfer.files)};return L.addEventListener("dragover",F),L.addEventListener("drop",R),()=>{L.removeEventListener("dragover",F),L.removeEventListener("drop",R)}},[E,a]),he.useEffect(()=>{if(!a)return;const L=R=>{var $,P;(P=($=R.dataTransfer)==null?void 0:$.types)!=null&&P.includes("Files")&&R.preventDefault()},F=R=>{var $,P,q;(P=($=R.dataTransfer)==null?void 0:$.types)!=null&&P.includes("Files")&&R.preventDefault(),(q=R.dataTransfer)!=null&&q.files&&R.dataTransfer.files.length>0&&E(R.dataTransfer.files)};return document.addEventListener("dragover",L),document.addEventListener("drop",F),()=>{document.removeEventListener("dragover",L),document.removeEventListener("drop",F)}},[E,a]),he.useEffect(()=>()=>{if(!m)for(const L of y.current)L.url&&URL.revokeObjectURL(L.url)},[m]);const T=L=>{L.currentTarget.files&&E(L.currentTarget.files),L.currentTarget.value=""},N=async L=>{try{const R=await(await fetch(L)).blob();return new Promise($=>{const P=new FileReader;P.onloadend=()=>$(P.result),P.onerror=()=>$(null),P.readAsDataURL(R)})}catch{return null}},I=he.useMemo(()=>({files:b.map(L=>({...L,id:L.id})),add:E,remove:D,clear:Q,openFileDialog:B,fileInputRef:A}),[b,E,D,Q,B]),S=L=>{L.preventDefault();const F=L.currentTarget,R=m?p.textInput.value:new FormData(F).get("message")||"";m||F.reset(),Promise.all(b.map(async({id:$,...P})=>{if(P.url&&P.url.startsWith("blob:")){const q=await N(P.url);return{...P,url:q??P.url}}return P})).then($=>{try{const P=l({text:R,files:$},L);P instanceof Promise?P.then(()=>{Q(),m&&p.textInput.clear()}).catch(()=>{}):(Q(),m&&p.textInput.clear())}catch{}}).catch(()=>{})},M=H.jsxs(H.Fragment,{children:[H.jsx("input",{accept:e,"aria-label":"Upload files",className:"hidden",multiple:n,onChange:T,ref:A,title:"Upload files",type:"file"}),H.jsx("form",{className:Tn("w-full",t),onSubmit:S,ref:g,...d,children:H.jsx(oat,{className:"overflow-hidden",children:u})})]});return m?M:H.jsx(Nie.Provider,{value:I,children:M})},wat=({className:t,...e})=>H.jsx("div",{className:Tn("contents",t),...e}),kat=({onChange:t,className:e,placeholder:n="What would you like to know?",...a})=>{const r=Lie(),i=w2(),[o,s]=he.useState(!1),l=p=>{if(p.key==="Enter"){if(o||p.nativeEvent.isComposing||p.shiftKey)return;p.preventDefault();const m=p.currentTarget.form,A=m==null?void 0:m.querySelector('button[type="submit"]');if(A!=null&&A.disabled)return;m==null||m.requestSubmit()}if(p.key==="Backspace"&&p.currentTarget.value===""&&i.files.length>0){p.preventDefault();const m=i.files.at(-1);m&&i.remove(m.id)}},u=p=>{var g;const m=(g=p.clipboardData)==null?void 0:g.items;if(!m)return;const A=[];for(const h of m)if(h.kind==="file"){const f=h.getAsFile();f&&A.push(f)}A.length>0&&(p.preventDefault(),i.add(A))},d=r?{value:r.textInput.value,onChange:p=>{r.textInput.setInput(p.currentTarget.value),t==null||t(p)}}:{onChange:t};return H.jsx(uat,{className:Tn("field-sizing-content max-h-48 min-h-16",e),name:"message",onCompositionEnd:()=>s(!1),onCompositionStart:()=>s(!0),onKeyDown:l,onPaste:u,placeholder:n,...a,...d})},vat=({className:t,...e})=>H.jsx(Fie,{align:"block-end",className:Tn("order-first flex-wrap gap-1",t),...e}),Cat=({className:t,...e})=>H.jsx(Fie,{align:"block-end",className:Tn("justify-between gap-1",t),...e}),_at=({variant:t="ghost",className:e,size:n,...a})=>{const r=n??(he.Children.count(a.children)>1?"sm":"icon-sm");return H.jsx(lat,{className:Tn(e),size:r,type:"button",variant:t,...a})},xat=t=>H.jsx(Ont,{...t}),Eat=({className:t,children:e,...n})=>H.jsx(jnt,{asChild:!0,children:H.jsx(_at,{className:t,...n,children:e??H.jsx(ESe,{className:"size-4"})})}),Bat=({className:t,...e})=>H.jsx(Gnt,{align:"start",className:Tn(t),...e}),Iat=({openDelay:t=0,closeDelay:e=0,...n})=>H.jsx(tat,{closeDelay:e,openDelay:t,...n}),Dat=({align:t="start",...e})=>H.jsx(aat,{align:t,...e});class bF{constructor(e,n){We(this,"api");We(this,"headers",{"Content-Type":"application/json"});this.api=e,this.headers=n??this.headers}post(e){return fetch(this.api,{method:"POST",headers:this.headers,body:JSON.stringify(e)})}put(e){return fetch(this.api,{method:"PUT",headers:this.headers,body:JSON.stringify(e)})}}const Mie=t=>{let e=!1;const n=d=>{t(p=>{const m=p[p.length-1];return(m==null?void 0:m.role)!=="assistant"?p:[...p.slice(0,-1),d(m)]})},a=d=>{d&&t(p=>{var A;const m=p[p.length-1];return e&&(m==null?void 0:m.role)==="assistant"&&((A=m==null?void 0:m.tool)==null?void 0:A.result)!==void 0?(e=!1,[...p,{role:"assistant",content:d}]):(m==null?void 0:m.role)==="assistant"&&(m!=null&&m.tool)&&!m.tool.result?p:(m==null?void 0:m.role)==="assistant"?[...p.slice(0,-1),{...m,content:m.content+d}]:[...p,{role:"assistant",content:d}]})},r=d=>{n(p=>({...p,tool:{tool:d.tool,input:d.input}}))},i=d=>{e=!0,n(p=>({...p,tool:{...p.tool,result:d.result}}))},o=d=>(d==null?void 0:d.type)==="message_chunk"?d.content:"",s=d=>{const p=d==null?void 0:d.type;if(p==="tool_call"){r(d);return}if(p==="tool_result"){i(d);return}const m=o(d);m&&a(m)},l=d=>{const p=d.trim();return!p||p.startsWith(":")||p.startsWith("event:")?null:p==="[DONE]"?"[DONE]":p.startsWith("data:")?p.slice(5).trim():p};return{splitChunks:async d=>{if(!d.body)return;e=!1;const p=d.body.getReader(),m=new TextDecoder;let A="";for(;;){const{done:g,value:h}=await p.read();if(g)break;A+=m.decode(h,{stream:!0});const f=A.split(`
730
+ `)},ttt=0,rb=[];function ntt(t){var e=_e.useRef([]),n=_e.useRef([0,0]),a=_e.useRef(),r=_e.useState(ttt++)[0],i=_e.useState(Sre)[0],o=_e.useRef(t);_e.useEffect(function(){o.current=t},[t]),_e.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(r));var h=vet([t.lockRef.current],(t.shards||[]).map($re),!0).filter(Boolean);return h.forEach(function(f){return f.classList.add("allow-interactivity-".concat(r))}),function(){document.body.classList.remove("block-interactivity-".concat(r)),h.forEach(function(f){return f.classList.remove("allow-interactivity-".concat(r))})}}},[t.inert,t.lockRef.current,t.shards]);var s=_e.useCallback(function(h,f){if("touches"in h&&h.touches.length===2||h.type==="wheel"&&h.ctrlKey)return!o.current.allowPinchZoom;var b=s2(h),y=n.current,w="deltaX"in h?h.deltaX:y[0]-b[0],k="deltaY"in h?h.deltaY:y[1]-b[1],C,x=h.target,_=Math.abs(w)>Math.abs(k)?"h":"v";if("touches"in h&&_==="h"&&x.type==="range")return!1;var E=window.getSelection(),D=E&&E.anchorNode,Q=D?D===x||D.contains(x):!1;if(Q)return!1;var B=Lre(_,x);if(!B)return!0;if(B?C=_:(C=_==="v"?"h":"v",B=Lre(_,x)),!B)return!1;if(!a.current&&"changedTouches"in h&&(w||k)&&(a.current=C),!C)return!0;var T=a.current||C;return Jet(T,f,h,T==="h"?w:k,!0)},[]),l=_e.useCallback(function(h){var f=h;if(!(!rb.length||rb[rb.length-1]!==i)){var b="deltaY"in f?Rre(f):s2(f),y=e.current.filter(function(C){return C.name===f.type&&(C.target===f.target||f.target===C.shadowParent)&&Xet(C.delta,b)})[0];if(y&&y.should){f.cancelable&&f.preventDefault();return}if(!y){var w=(o.current.shards||[]).map($re).filter(Boolean).filter(function(C){return C.contains(f.target)}),k=w.length>0?s(f,w[0]):!o.current.noIsolation;k&&f.cancelable&&f.preventDefault()}}},[]),u=_e.useCallback(function(h,f,b,y){var w={name:h,delta:f,target:b,should:y,shadowParent:att(b)};e.current.push(w),setTimeout(function(){e.current=e.current.filter(function(k){return k!==w})},1)},[]),d=_e.useCallback(function(h){n.current=s2(h),a.current=void 0},[]),p=_e.useCallback(function(h){u(h.type,Rre(h),h.target,s(h,t.lockRef.current))},[]),m=_e.useCallback(function(h){u(h.type,s2(h),h.target,s(h,t.lockRef.current))},[]);_e.useEffect(function(){return rb.push(i),t.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:m}),document.addEventListener("wheel",l,ab),document.addEventListener("touchmove",l,ab),document.addEventListener("touchstart",d,ab),function(){rb=rb.filter(function(h){return h!==i}),document.removeEventListener("wheel",l,ab),document.removeEventListener("touchmove",l,ab),document.removeEventListener("touchstart",d,ab)}},[]);var A=t.removeScrollBar,g=t.inert;return _e.createElement(_e.Fragment,null,g?_e.createElement(i,{styles:ett(r)}):null,A?_e.createElement(Het,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function att(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const rtt=Tet(Qre,ntt);var Pre=_e.forwardRef(function(t,e){return _e.createElement(i2,ru({},t,{ref:e,sideCar:rtt}))});Pre.classNames=i2.classNames;var itt=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},ib=new WeakMap,c2=new WeakMap,l2={},iF=0,Ore=function(t){return t&&(t.host||Ore(t.parentNode))},ott=function(t,e){return e.map(function(n){if(t.contains(n))return n;var a=Ore(n);return a&&t.contains(a)?a:(console.error("aria-hidden",n,"in not contained inside",t,". Doing nothing"),null)}).filter(function(n){return!!n})},stt=function(t,e,n,a){var r=ott(e,Array.isArray(t)?t:[t]);l2[n]||(l2[n]=new WeakMap);var i=l2[n],o=[],s=new Set,l=new Set(r),u=function(p){!p||s.has(p)||(s.add(p),u(p.parentNode))};r.forEach(u);var d=function(p){!p||l.has(p)||Array.prototype.forEach.call(p.children,function(m){if(s.has(m))d(m);else try{var A=m.getAttribute(a),g=A!==null&&A!=="false",h=(ib.get(m)||0)+1,f=(i.get(m)||0)+1;ib.set(m,h),i.set(m,f),o.push(m),h===1&&g&&c2.set(m,!0),f===1&&m.setAttribute(n,"true"),g||m.setAttribute(a,"true")}catch(b){console.error("aria-hidden: cannot operate on ",m,b)}})};return d(e),s.clear(),iF++,function(){o.forEach(function(p){var m=ib.get(p)-1,A=i.get(p)-1;ib.set(p,m),i.set(p,A),m||(c2.has(p)||p.removeAttribute(a),c2.delete(p)),A||p.removeAttribute(n)}),iF--,iF||(ib=new WeakMap,ib=new WeakMap,c2=new WeakMap,l2={})}},ctt=function(t,e,n){n===void 0&&(n="data-aria-hidden");var a=Array.from(Array.isArray(t)?t:[t]),r=itt(t);return r?(a.push.apply(a,Array.from(r.querySelectorAll("[aria-live], script"))),stt(a,r,n,"aria-hidden")):function(){return null}};function jre(t){const e=t+"CollectionProvider",[n,a]=SA(e),[r,i]=n(e,{collectionRef:{current:null},itemMap:new Map}),o=h=>{const{scope:f,children:b}=h,y=he.useRef(null),w=he.useRef(new Map).current;return H.jsx(r,{scope:f,itemMap:w,collectionRef:y,children:b})};o.displayName=e;const s=t+"CollectionSlot",l=zx(s),u=he.forwardRef((h,f)=>{const{scope:b,children:y}=h,w=i(s,b),k=Ji(f,w.collectionRef);return H.jsx(l,{ref:k,children:y})});u.displayName=s;const d=t+"CollectionItemSlot",p="data-radix-collection-item",m=zx(d),A=he.forwardRef((h,f)=>{const{scope:b,children:y,...w}=h,k=he.useRef(null),C=Ji(f,k),x=i(d,b);return he.useEffect(()=>(x.itemMap.set(k,{ref:k,...w}),()=>void x.itemMap.delete(k))),H.jsx(m,{[p]:"",ref:C,children:y})});A.displayName=d;function g(h){const f=i(t+"CollectionConsumer",h);return he.useCallback(()=>{const y=f.collectionRef.current;if(!y)return[];const w=Array.from(y.querySelectorAll(`[${p}]`));return Array.from(f.itemMap.values()).sort((x,_)=>w.indexOf(x.ref.current)-w.indexOf(_.ref.current))},[f.collectionRef,f.itemMap])}return[{Provider:o,Slot:u,ItemSlot:A},g,a]}var ltt=_e.createContext(void 0);function Gre(t){const e=_e.useContext(ltt);return t||e||"ltr"}var oF="rovingFocusGroup.onEntryFocus",utt={bubbles:!1,cancelable:!0},r1="RovingFocusGroup",[sF,qre,dtt]=jre(r1),[ptt,zre]=SA(r1,[dtt]),[mtt,Att]=ptt(r1),Hre=_e.forwardRef((t,e)=>H.jsx(sF.Provider,{scope:t.__scopeRovingFocusGroup,children:H.jsx(sF.Slot,{scope:t.__scopeRovingFocusGroup,children:H.jsx(gtt,{...t,ref:e})})}));Hre.displayName=r1;var gtt=_e.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,orientation:a,loop:r=!1,dir:i,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...p}=t,m=_e.useRef(null),A=Ji(e,m),g=Gre(i),[h,f]=mf({prop:o,defaultProp:s??null,onChange:l,caller:r1}),[b,y]=_e.useState(!1),w=rd(u),k=qre(n),C=_e.useRef(!1),[x,_]=_e.useState(0);return _e.useEffect(()=>{const E=m.current;if(E)return E.addEventListener(oF,w),()=>E.removeEventListener(oF,w)},[w]),H.jsx(mtt,{scope:n,orientation:a,dir:g,loop:r,currentTabStopId:h,onItemFocus:_e.useCallback(E=>f(E),[f]),onItemShiftTab:_e.useCallback(()=>y(!0),[]),onFocusableItemAdd:_e.useCallback(()=>_(E=>E+1),[]),onFocusableItemRemove:_e.useCallback(()=>_(E=>E-1),[]),children:H.jsx(Kr.div,{tabIndex:b||x===0?-1:0,"data-orientation":a,...p,ref:A,style:{outline:"none",...t.style},onMouseDown:_n(t.onMouseDown,()=>{C.current=!0}),onFocus:_n(t.onFocus,E=>{const D=!C.current;if(E.target===E.currentTarget&&D&&!b){const Q=new CustomEvent(oF,utt);if(E.currentTarget.dispatchEvent(Q),!Q.defaultPrevented){const B=k().filter(M=>M.focusable),T=B.find(M=>M.active),N=B.find(M=>M.id===h),S=[T,N,...B].filter(Boolean).map(M=>M.ref.current);Wre(S,d)}}C.current=!1}),onBlur:_n(t.onBlur,()=>y(!1))})})}),Ure="RovingFocusGroupItem",Yre=_e.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:a=!0,active:r=!1,tabStopId:i,children:o,...s}=t,l=Hx(),u=i||l,d=Att(Ure,n),p=d.currentTabStopId===u,m=qre(n),{onFocusableItemAdd:A,onFocusableItemRemove:g,currentTabStopId:h}=d;return _e.useEffect(()=>{if(a)return A(),()=>g()},[a,A,g]),H.jsx(sF.ItemSlot,{scope:n,id:u,focusable:a,active:r,children:H.jsx(Kr.span,{tabIndex:p?0:-1,"data-orientation":d.orientation,...s,ref:e,onMouseDown:_n(t.onMouseDown,f=>{a?d.onItemFocus(u):f.preventDefault()}),onFocus:_n(t.onFocus,()=>d.onItemFocus(u)),onKeyDown:_n(t.onKeyDown,f=>{if(f.key==="Tab"&&f.shiftKey){d.onItemShiftTab();return}if(f.target!==f.currentTarget)return;const b=btt(f,d.orientation,d.dir);if(b!==void 0){if(f.metaKey||f.ctrlKey||f.altKey||f.shiftKey)return;f.preventDefault();let w=m().filter(k=>k.focusable).map(k=>k.ref.current);if(b==="last")w.reverse();else if(b==="prev"||b==="next"){b==="prev"&&w.reverse();const k=w.indexOf(f.currentTarget);w=d.loop?ytt(w,k+1):w.slice(k+1)}setTimeout(()=>Wre(w))}}),children:typeof o=="function"?o({isCurrentTabStop:p,hasTabStop:h!=null}):o})})});Yre.displayName=Ure;var htt={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function ftt(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function btt(t,e,n){const a=ftt(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(a))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(a)))return htt[a]}function Wre(t,e=!1){const n=document.activeElement;for(const a of t)if(a===n||(a.focus({preventScroll:e}),document.activeElement!==n))return}function ytt(t,e){return t.map((n,a)=>t[(e+a)%t.length])}var wtt=Hre,ktt=Yre,cF=["Enter"," "],vtt=["ArrowDown","PageUp","Home"],Kre=["ArrowUp","PageDown","End"],Ctt=[...vtt,...Kre],_tt={ltr:[...cF,"ArrowRight"],rtl:[...cF,"ArrowLeft"]},xtt={ltr:["ArrowLeft"],rtl:["ArrowRight"]},i1="Menu",[o1,Ett,Btt]=jre(i1),[ig,Zre]=SA(i1,[Btt,tE,zre]),u2=tE(),Vre=zre(),[Itt,og]=ig(i1),[Dtt,s1]=ig(i1),Jre=t=>{const{__scopeMenu:e,open:n=!1,children:a,dir:r,onOpenChange:i,modal:o=!0}=t,s=u2(e),[l,u]=_e.useState(null),d=_e.useRef(!1),p=rd(i),m=Gre(r);return _e.useEffect(()=>{const A=()=>{d.current=!0,document.addEventListener("pointerdown",g,{capture:!0,once:!0}),document.addEventListener("pointermove",g,{capture:!0,once:!0})},g=()=>d.current=!1;return document.addEventListener("keydown",A,{capture:!0}),()=>{document.removeEventListener("keydown",A,{capture:!0}),document.removeEventListener("pointerdown",g,{capture:!0}),document.removeEventListener("pointermove",g,{capture:!0})}},[]),H.jsx(XU,{...s,children:H.jsx(Itt,{scope:e,open:n,onOpenChange:p,content:l,onContentChange:u,children:H.jsx(Dtt,{scope:e,onClose:_e.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:d,dir:m,modal:o,children:a})})})};Jre.displayName=i1;var Qtt="MenuAnchor",lF=_e.forwardRef((t,e)=>{const{__scopeMenu:n,...a}=t,r=u2(n);return H.jsx(eY,{...r,...a,ref:e})});lF.displayName=Qtt;var uF="MenuPortal",[Stt,Xre]=ig(uF,{forceMount:void 0}),eie=t=>{const{__scopeMenu:e,forceMount:n,children:a,container:r}=t,i=og(uF,e);return H.jsx(Stt,{scope:e,forceMount:n,children:H.jsx(Sp,{present:n||i.open,children:H.jsx(k9,{asChild:!0,container:r,children:a})})})};eie.displayName=uF;var wc="MenuContent",[Ttt,dF]=ig(wc),tie=_e.forwardRef((t,e)=>{const n=Xre(wc,t.__scopeMenu),{forceMount:a=n.forceMount,...r}=t,i=og(wc,t.__scopeMenu),o=s1(wc,t.__scopeMenu);return H.jsx(o1.Provider,{scope:t.__scopeMenu,children:H.jsx(Sp,{present:a||i.open,children:H.jsx(o1.Slot,{scope:t.__scopeMenu,children:o.modal?H.jsx(Ftt,{...r,ref:e}):H.jsx(Ltt,{...r,ref:e})})})})}),Ftt=_e.forwardRef((t,e)=>{const n=og(wc,t.__scopeMenu),a=_e.useRef(null),r=Ji(e,a);return _e.useEffect(()=>{const i=a.current;if(i)return ctt(i)},[]),H.jsx(pF,{...t,ref:r,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:_n(t.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Ltt=_e.forwardRef((t,e)=>{const n=og(wc,t.__scopeMenu);return H.jsx(pF,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Ntt=zx("MenuContent.ScrollLock"),pF=_e.forwardRef((t,e)=>{const{__scopeMenu:n,loop:a=!1,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:l,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:p,onInteractOutside:m,onDismiss:A,disableOutsideScroll:g,...h}=t,f=og(wc,n),b=s1(wc,n),y=u2(n),w=Vre(n),k=Ett(n),[C,x]=_e.useState(null),_=_e.useRef(null),E=Ji(e,_,f.onContentChange),D=_e.useRef(0),Q=_e.useRef(""),B=_e.useRef(0),T=_e.useRef(null),N=_e.useRef("right"),I=_e.useRef(0),S=g?Pre:_e.Fragment,M=g?{as:Ntt,allowPinchZoom:!0}:void 0,L=R=>{var ee,me;const $=Q.current+R,P=k().filter(V=>!V.disabled),q=document.activeElement,j=(ee=P.find(V=>V.ref.current===q))==null?void 0:ee.textValue,J=P.map(V=>V.textValue),Y=Ytt(J,$,j),ne=(me=P.find(V=>V.textValue===Y))==null?void 0:me.ref.current;(function V(te){Q.current=te,window.clearTimeout(D.current),te!==""&&(D.current=window.setTimeout(()=>V(""),1e3))})($),ne&&setTimeout(()=>ne.focus())};_e.useEffect(()=>()=>window.clearTimeout(D.current),[]),ket();const F=_e.useCallback(R=>{var P,q;return N.current===((P=T.current)==null?void 0:P.side)&&Ktt(R,(q=T.current)==null?void 0:q.area)},[]);return H.jsx(Ttt,{scope:n,searchRef:Q,onItemEnter:_e.useCallback(R=>{F(R)&&R.preventDefault()},[F]),onItemLeave:_e.useCallback(R=>{var $;F(R)||(($=_.current)==null||$.focus(),x(null))},[F]),onTriggerLeave:_e.useCallback(R=>{F(R)&&R.preventDefault()},[F]),pointerGraceTimerRef:B,onPointerGraceIntentChange:_e.useCallback(R=>{T.current=R},[]),children:H.jsx(S,{...M,children:H.jsx(kre,{asChild:!0,trapped:r,onMountAutoFocus:_n(i,R=>{var $;R.preventDefault(),($=_.current)==null||$.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:H.jsx(c9,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:p,onInteractOutside:m,onDismiss:A,children:H.jsx(wtt,{asChild:!0,...w,dir:b.dir,orientation:"vertical",loop:a,currentTabStopId:C,onCurrentTabStopIdChange:x,onEntryFocus:_n(l,R=>{b.isUsingKeyboardRef.current||R.preventDefault()}),preventScrollOnEntryFocus:!0,children:H.jsx(tY,{role:"menu","aria-orientation":"vertical","data-state":bie(f.open),"data-radix-menu-content":"",dir:b.dir,...y,...h,ref:E,style:{outline:"none",...h.style},onKeyDown:_n(h.onKeyDown,R=>{const P=R.target.closest("[data-radix-menu-content]")===R.currentTarget,q=R.ctrlKey||R.altKey||R.metaKey,j=R.key.length===1;P&&(R.key==="Tab"&&R.preventDefault(),!q&&j&&L(R.key));const J=_.current;if(R.target!==J||!Ctt.includes(R.key))return;R.preventDefault();const ne=k().filter(ee=>!ee.disabled).map(ee=>ee.ref.current);Kre.includes(R.key)&&ne.reverse(),Htt(ne)}),onBlur:_n(t.onBlur,R=>{R.currentTarget.contains(R.target)||(window.clearTimeout(D.current),Q.current="")}),onPointerMove:_n(t.onPointerMove,l1(R=>{const $=R.target,P=I.current!==R.clientX;if(R.currentTarget.contains($)&&P){const q=R.clientX>I.current?"right":"left";N.current=q,I.current=R.clientX}}))})})})})})})});tie.displayName=wc;var Mtt="MenuGroup",mF=_e.forwardRef((t,e)=>{const{__scopeMenu:n,...a}=t;return H.jsx(Kr.div,{role:"group",...a,ref:e})});mF.displayName=Mtt;var Rtt="MenuLabel",nie=_e.forwardRef((t,e)=>{const{__scopeMenu:n,...a}=t;return H.jsx(Kr.div,{...a,ref:e})});nie.displayName=Rtt;var d2="MenuItem",aie="menu.itemSelect",p2=_e.forwardRef((t,e)=>{const{disabled:n=!1,onSelect:a,...r}=t,i=_e.useRef(null),o=s1(d2,t.__scopeMenu),s=dF(d2,t.__scopeMenu),l=Ji(e,i),u=_e.useRef(!1),d=()=>{const p=i.current;if(!n&&p){const m=new CustomEvent(aie,{bubbles:!0,cancelable:!0});p.addEventListener(aie,A=>a==null?void 0:a(A),{once:!0}),yU(p,m),m.defaultPrevented?u.current=!1:o.onClose()}};return H.jsx(rie,{...r,ref:l,disabled:n,onClick:_n(t.onClick,d),onPointerDown:p=>{var m;(m=t.onPointerDown)==null||m.call(t,p),u.current=!0},onPointerUp:_n(t.onPointerUp,p=>{var m;u.current||(m=p.currentTarget)==null||m.click()}),onKeyDown:_n(t.onKeyDown,p=>{const m=s.searchRef.current!=="";n||m&&p.key===" "||cF.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});p2.displayName=d2;var rie=_e.forwardRef((t,e)=>{const{__scopeMenu:n,disabled:a=!1,textValue:r,...i}=t,o=dF(d2,n),s=Vre(n),l=_e.useRef(null),u=Ji(e,l),[d,p]=_e.useState(!1),[m,A]=_e.useState("");return _e.useEffect(()=>{const g=l.current;g&&A((g.textContent??"").trim())},[i.children]),H.jsx(o1.ItemSlot,{scope:n,disabled:a,textValue:r??m,children:H.jsx(ktt,{asChild:!0,...s,focusable:!a,children:H.jsx(Kr.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":a||void 0,"data-disabled":a?"":void 0,...i,ref:u,onPointerMove:_n(t.onPointerMove,l1(g=>{a?o.onItemLeave(g):(o.onItemEnter(g),g.defaultPrevented||g.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:_n(t.onPointerLeave,l1(g=>o.onItemLeave(g))),onFocus:_n(t.onFocus,()=>p(!0)),onBlur:_n(t.onBlur,()=>p(!1))})})})}),$tt="MenuCheckboxItem",iie=_e.forwardRef((t,e)=>{const{checked:n=!1,onCheckedChange:a,...r}=t;return H.jsx(uie,{scope:t.__scopeMenu,checked:n,children:H.jsx(p2,{role:"menuitemcheckbox","aria-checked":m2(n)?"mixed":n,...r,ref:e,"data-state":gF(n),onSelect:_n(r.onSelect,()=>a==null?void 0:a(m2(n)?!0:!n),{checkForDefaultPrevented:!1})})})});iie.displayName=$tt;var oie="MenuRadioGroup",[Ptt,Ott]=ig(oie,{value:void 0,onValueChange:()=>{}}),sie=_e.forwardRef((t,e)=>{const{value:n,onValueChange:a,...r}=t,i=rd(a);return H.jsx(Ptt,{scope:t.__scopeMenu,value:n,onValueChange:i,children:H.jsx(mF,{...r,ref:e})})});sie.displayName=oie;var cie="MenuRadioItem",lie=_e.forwardRef((t,e)=>{const{value:n,...a}=t,r=Ott(cie,t.__scopeMenu),i=n===r.value;return H.jsx(uie,{scope:t.__scopeMenu,checked:i,children:H.jsx(p2,{role:"menuitemradio","aria-checked":i,...a,ref:e,"data-state":gF(i),onSelect:_n(a.onSelect,()=>{var o;return(o=r.onValueChange)==null?void 0:o.call(r,n)},{checkForDefaultPrevented:!1})})})});lie.displayName=cie;var AF="MenuItemIndicator",[uie,jtt]=ig(AF,{checked:!1}),die=_e.forwardRef((t,e)=>{const{__scopeMenu:n,forceMount:a,...r}=t,i=jtt(AF,n);return H.jsx(Sp,{present:a||m2(i.checked)||i.checked===!0,children:H.jsx(Kr.span,{...r,ref:e,"data-state":gF(i.checked)})})});die.displayName=AF;var Gtt="MenuSeparator",pie=_e.forwardRef((t,e)=>{const{__scopeMenu:n,...a}=t;return H.jsx(Kr.div,{role:"separator","aria-orientation":"horizontal",...a,ref:e})});pie.displayName=Gtt;var qtt="MenuArrow",mie=_e.forwardRef((t,e)=>{const{__scopeMenu:n,...a}=t,r=u2(n);return H.jsx(nY,{...r,...a,ref:e})});mie.displayName=qtt;var ztt="MenuSub",[U0n,Aie]=ig(ztt),c1="MenuSubTrigger",gie=_e.forwardRef((t,e)=>{const n=og(c1,t.__scopeMenu),a=s1(c1,t.__scopeMenu),r=Aie(c1,t.__scopeMenu),i=dF(c1,t.__scopeMenu),o=_e.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:l}=i,u={__scopeMenu:t.__scopeMenu},d=_e.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return _e.useEffect(()=>d,[d]),_e.useEffect(()=>{const p=s.current;return()=>{window.clearTimeout(p),l(null)}},[s,l]),H.jsx(lF,{asChild:!0,...u,children:H.jsx(rie,{id:r.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":r.contentId,"data-state":bie(n.open),...t,ref:$0(e,r.onTriggerChange),onClick:p=>{var m;(m=t.onClick)==null||m.call(t,p),!(t.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:_n(t.onPointerMove,l1(p=>{i.onItemEnter(p),!p.defaultPrevented&&!t.disabled&&!n.open&&!o.current&&(i.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:_n(t.onPointerLeave,l1(p=>{var A,g;d();const m=(A=n.content)==null?void 0:A.getBoundingClientRect();if(m){const h=(g=n.content)==null?void 0:g.dataset.side,f=h==="right",b=f?-5:5,y=m[f?"left":"right"],w=m[f?"right":"left"];i.onPointerGraceIntentChange({area:[{x:p.clientX+b,y:p.clientY},{x:y,y:m.top},{x:w,y:m.top},{x:w,y:m.bottom},{x:y,y:m.bottom}],side:h}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(p),p.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:_n(t.onKeyDown,p=>{var A;const m=i.searchRef.current!=="";t.disabled||m&&p.key===" "||_tt[a.dir].includes(p.key)&&(n.onOpenChange(!0),(A=n.content)==null||A.focus(),p.preventDefault())})})})});gie.displayName=c1;var hie="MenuSubContent",fie=_e.forwardRef((t,e)=>{const n=Xre(wc,t.__scopeMenu),{forceMount:a=n.forceMount,...r}=t,i=og(wc,t.__scopeMenu),o=s1(wc,t.__scopeMenu),s=Aie(hie,t.__scopeMenu),l=_e.useRef(null),u=Ji(e,l);return H.jsx(o1.Provider,{scope:t.__scopeMenu,children:H.jsx(Sp,{present:a||i.open,children:H.jsx(o1.Slot,{scope:t.__scopeMenu,children:H.jsx(pF,{id:s.contentId,"aria-labelledby":s.triggerId,...r,ref:u,align:"start",side:o.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var p;o.isUsingKeyboardRef.current&&((p=l.current)==null||p.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:_n(t.onFocusOutside,d=>{d.target!==s.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:_n(t.onEscapeKeyDown,d=>{o.onClose(),d.preventDefault()}),onKeyDown:_n(t.onKeyDown,d=>{var A;const p=d.currentTarget.contains(d.target),m=xtt[o.dir].includes(d.key);p&&m&&(i.onOpenChange(!1),(A=s.trigger)==null||A.focus(),d.preventDefault())})})})})})});fie.displayName=hie;function bie(t){return t?"open":"closed"}function m2(t){return t==="indeterminate"}function gF(t){return m2(t)?"indeterminate":t?"checked":"unchecked"}function Htt(t){const e=document.activeElement;for(const n of t)if(n===e||(n.focus(),document.activeElement!==e))return}function Utt(t,e){return t.map((n,a)=>t[(e+a)%t.length])}function Ytt(t,e,n){const r=e.length>1&&Array.from(e).every(u=>u===e[0])?e[0]:e,i=n?t.indexOf(n):-1;let o=Utt(t,Math.max(i,0));r.length===1&&(o=o.filter(u=>u!==n));const l=o.find(u=>u.toLowerCase().startsWith(r.toLowerCase()));return l!==n?l:void 0}function Wtt(t,e){const{x:n,y:a}=t;let r=!1;for(let i=0,o=e.length-1;i<e.length;o=i++){const s=e[i],l=e[o],u=s.x,d=s.y,p=l.x,m=l.y;d>a!=m>a&&n<(p-u)*(a-d)/(m-d)+u&&(r=!r)}return r}function Ktt(t,e){if(!e)return!1;const n={x:t.clientX,y:t.clientY};return Wtt(n,e)}function l1(t){return e=>e.pointerType==="mouse"?t(e):void 0}var Ztt=Jre,Vtt=lF,Jtt=eie,Xtt=tie,ent=mF,tnt=nie,nnt=p2,ant=iie,rnt=sie,int=lie,ont=die,snt=pie,cnt=mie,lnt=gie,unt=fie,A2="DropdownMenu",[dnt,Y0n]=SA(A2,[Zre]),No=Zre(),[pnt,yie]=dnt(A2),wie=t=>{const{__scopeDropdownMenu:e,children:n,dir:a,open:r,defaultOpen:i,onOpenChange:o,modal:s=!0}=t,l=No(e),u=_e.useRef(null),[d,p]=mf({prop:r,defaultProp:i??!1,onChange:o,caller:A2});return H.jsx(pnt,{scope:e,triggerId:Hx(),triggerRef:u,contentId:Hx(),open:d,onOpenChange:p,onOpenToggle:_e.useCallback(()=>p(m=>!m),[p]),modal:s,children:H.jsx(Ztt,{...l,open:d,onOpenChange:p,dir:a,modal:s,children:n})})};wie.displayName=A2;var kie="DropdownMenuTrigger",vie=_e.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,disabled:a=!1,...r}=t,i=yie(kie,n),o=No(n);return H.jsx(Vtt,{asChild:!0,...o,children:H.jsx(Kr.button,{type:"button",id:i.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":i.open?"open":"closed","data-disabled":a?"":void 0,disabled:a,...r,ref:$0(e,i.triggerRef),onPointerDown:_n(t.onPointerDown,s=>{!a&&s.button===0&&s.ctrlKey===!1&&(i.onOpenToggle(),i.open||s.preventDefault())}),onKeyDown:_n(t.onKeyDown,s=>{a||(["Enter"," "].includes(s.key)&&i.onOpenToggle(),s.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(s.key)&&s.preventDefault())})})})});vie.displayName=kie;var mnt="DropdownMenuPortal",Cie=t=>{const{__scopeDropdownMenu:e,...n}=t,a=No(e);return H.jsx(Jtt,{...a,...n})};Cie.displayName=mnt;var _ie="DropdownMenuContent",xie=_e.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...a}=t,r=yie(_ie,n),i=No(n),o=_e.useRef(!1);return H.jsx(Xtt,{id:r.contentId,"aria-labelledby":r.triggerId,...i,...a,ref:e,onCloseAutoFocus:_n(t.onCloseAutoFocus,s=>{var l;o.current||(l=r.triggerRef.current)==null||l.focus(),o.current=!1,s.preventDefault()}),onInteractOutside:_n(t.onInteractOutside,s=>{const l=s.detail.originalEvent,u=l.button===0&&l.ctrlKey===!0,d=l.button===2||u;(!r.modal||d)&&(o.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});xie.displayName=_ie;var Ant="DropdownMenuGroup",gnt=_e.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...a}=t,r=No(n);return H.jsx(ent,{...r,...a,ref:e})});gnt.displayName=Ant;var hnt="DropdownMenuLabel",fnt=_e.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...a}=t,r=No(n);return H.jsx(tnt,{...r,...a,ref:e})});fnt.displayName=hnt;var bnt="DropdownMenuItem",Eie=_e.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...a}=t,r=No(n);return H.jsx(nnt,{...r,...a,ref:e})});Eie.displayName=bnt;var ynt="DropdownMenuCheckboxItem",wnt=_e.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...a}=t,r=No(n);return H.jsx(ant,{...r,...a,ref:e})});wnt.displayName=ynt;var knt="DropdownMenuRadioGroup",vnt=_e.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...a}=t,r=No(n);return H.jsx(rnt,{...r,...a,ref:e})});vnt.displayName=knt;var Cnt="DropdownMenuRadioItem",_nt=_e.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...a}=t,r=No(n);return H.jsx(int,{...r,...a,ref:e})});_nt.displayName=Cnt;var xnt="DropdownMenuItemIndicator",Ent=_e.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...a}=t,r=No(n);return H.jsx(ont,{...r,...a,ref:e})});Ent.displayName=xnt;var Bnt="DropdownMenuSeparator",Int=_e.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...a}=t,r=No(n);return H.jsx(snt,{...r,...a,ref:e})});Int.displayName=Bnt;var Dnt="DropdownMenuArrow",Qnt=_e.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...a}=t,r=No(n);return H.jsx(cnt,{...r,...a,ref:e})});Qnt.displayName=Dnt;var Snt="DropdownMenuSubTrigger",Tnt=_e.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...a}=t,r=No(n);return H.jsx(lnt,{...r,...a,ref:e})});Tnt.displayName=Snt;var Fnt="DropdownMenuSubContent",Lnt=_e.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...a}=t,r=No(n);return H.jsx(unt,{...r,...a,ref:e,style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Lnt.displayName=Fnt;var Nnt=wie,Mnt=vie,Rnt=Cie,$nt=xie,Pnt=Eie;function Ont({...t}){return H.jsx(Nnt,{"data-slot":"dropdown-menu",...t})}function jnt({...t}){return H.jsx(Mnt,{"data-slot":"dropdown-menu-trigger",...t})}function Gnt({className:t,sideOffset:e=4,...n}){return H.jsx(Rnt,{children:H.jsx($nt,{"data-slot":"dropdown-menu-content",sideOffset:e,className:Tn("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",t),...n})})}function qnt({className:t,inset:e,variant:n="default",...a}){return H.jsx(Pnt,{"data-slot":"dropdown-menu-item","data-inset":e,"data-variant":n,className:Tn("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...a})}var hF,g2="HoverCard",[Bie,W0n]=SA(g2,[tE]),h2=tE(),[znt,f2]=Bie(g2),Iie=t=>{const{__scopeHoverCard:e,children:n,open:a,defaultOpen:r,onOpenChange:i,openDelay:o=700,closeDelay:s=300}=t,l=h2(e),u=_e.useRef(0),d=_e.useRef(0),p=_e.useRef(!1),m=_e.useRef(!1),[A,g]=mf({prop:a,defaultProp:r??!1,onChange:i,caller:g2}),h=_e.useCallback(()=>{clearTimeout(d.current),u.current=window.setTimeout(()=>g(!0),o)},[o,g]),f=_e.useCallback(()=>{clearTimeout(u.current),!p.current&&!m.current&&(d.current=window.setTimeout(()=>g(!1),s))},[s,g]),b=_e.useCallback(()=>g(!1),[g]);return _e.useEffect(()=>()=>{clearTimeout(u.current),clearTimeout(d.current)},[]),H.jsx(znt,{scope:e,open:A,onOpenChange:g,onOpen:h,onClose:f,onDismiss:b,hasSelectionRef:p,isPointerDownOnContentRef:m,children:H.jsx(XU,{...l,children:n})})};Iie.displayName=g2;var Die="HoverCardTrigger",Qie=_e.forwardRef((t,e)=>{const{__scopeHoverCard:n,...a}=t,r=f2(Die,n),i=h2(n);return H.jsx(eY,{asChild:!0,...i,children:H.jsx(Kr.a,{"data-state":r.open?"open":"closed",...a,ref:e,onPointerEnter:_n(t.onPointerEnter,y2(r.onOpen)),onPointerLeave:_n(t.onPointerLeave,y2(r.onClose)),onFocus:_n(t.onFocus,r.onOpen),onBlur:_n(t.onBlur,r.onClose),onTouchStart:_n(t.onTouchStart,o=>o.preventDefault())})})});Qie.displayName=Die;var fF="HoverCardPortal",[Hnt,Unt]=Bie(fF,{forceMount:void 0}),Sie=t=>{const{__scopeHoverCard:e,forceMount:n,children:a,container:r}=t,i=f2(fF,e);return H.jsx(Hnt,{scope:e,forceMount:n,children:H.jsx(Sp,{present:n||i.open,children:H.jsx(k9,{asChild:!0,container:r,children:a})})})};Sie.displayName=fF;var b2="HoverCardContent",Tie=_e.forwardRef((t,e)=>{const n=Unt(b2,t.__scopeHoverCard),{forceMount:a=n.forceMount,...r}=t,i=f2(b2,t.__scopeHoverCard);return H.jsx(Sp,{present:a||i.open,children:H.jsx(Ynt,{"data-state":i.open?"open":"closed",...r,onPointerEnter:_n(t.onPointerEnter,y2(i.onOpen)),onPointerLeave:_n(t.onPointerLeave,y2(i.onClose)),ref:e})})});Tie.displayName=b2;var Ynt=_e.forwardRef((t,e)=>{const{__scopeHoverCard:n,onEscapeKeyDown:a,onPointerDownOutside:r,onFocusOutside:i,onInteractOutside:o,...s}=t,l=f2(b2,n),u=h2(n),d=_e.useRef(null),p=Ji(e,d),[m,A]=_e.useState(!1);return _e.useEffect(()=>{if(m){const g=document.body;return hF=g.style.userSelect||g.style.webkitUserSelect,g.style.userSelect="none",g.style.webkitUserSelect="none",()=>{g.style.userSelect=hF,g.style.webkitUserSelect=hF}}},[m]),_e.useEffect(()=>{if(d.current){const g=()=>{A(!1),l.isPointerDownOnContentRef.current=!1,setTimeout(()=>{var f;((f=document.getSelection())==null?void 0:f.toString())!==""&&(l.hasSelectionRef.current=!0)})};return document.addEventListener("pointerup",g),()=>{document.removeEventListener("pointerup",g),l.hasSelectionRef.current=!1,l.isPointerDownOnContentRef.current=!1}}},[l.isPointerDownOnContentRef,l.hasSelectionRef]),_e.useEffect(()=>{d.current&&Znt(d.current).forEach(h=>h.setAttribute("tabindex","-1"))}),H.jsx(c9,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:o,onEscapeKeyDown:a,onPointerDownOutside:r,onFocusOutside:_n(i,g=>{g.preventDefault()}),onDismiss:l.onDismiss,children:H.jsx(tY,{...u,...s,onPointerDown:_n(s.onPointerDown,g=>{g.currentTarget.contains(g.target)&&A(!0),l.hasSelectionRef.current=!1,l.isPointerDownOnContentRef.current=!0}),ref:p,style:{...s.style,userSelect:m?"text":void 0,WebkitUserSelect:m?"text":void 0,"--radix-hover-card-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-hover-card-content-available-width":"var(--radix-popper-available-width)","--radix-hover-card-content-available-height":"var(--radix-popper-available-height)","--radix-hover-card-trigger-width":"var(--radix-popper-anchor-width)","--radix-hover-card-trigger-height":"var(--radix-popper-anchor-height)"}})})}),Wnt="HoverCardArrow",Knt=_e.forwardRef((t,e)=>{const{__scopeHoverCard:n,...a}=t,r=h2(n);return H.jsx(nY,{...r,...a,ref:e})});Knt.displayName=Wnt;function y2(t){return e=>e.pointerType==="touch"?void 0:t()}function Znt(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:a=>a.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});for(;n.nextNode();)e.push(n.currentNode);return e}var Vnt=Iie,Jnt=Qie,Xnt=Sie,eat=Tie;function tat({...t}){return H.jsx(Vnt,{"data-slot":"hover-card",...t})}function nat({...t}){return H.jsx(Jnt,{"data-slot":"hover-card-trigger",...t})}function aat({className:t,align:e="center",sideOffset:n=4,...a}){return H.jsx(Xnt,{"data-slot":"hover-card-portal",children:H.jsx(eat,{"data-slot":"hover-card-content",align:e,sideOffset:n,className:Tn("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-64 origin-(--radix-hover-card-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",t),...a})})}function rat({className:t,type:e,...n}){return H.jsx("input",{type:e,"data-slot":"input",className:Tn("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",t),...n})}function iat({className:t,...e}){return H.jsx("textarea",{"data-slot":"textarea",className:Tn("border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),...e})}function oat({className:t,...e}){return H.jsx("div",{"data-slot":"input-group",role:"group",className:Tn("group/input-group border-input dark:bg-input/30 relative flex w-full items-center rounded-md border shadow-xs transition-[color,box-shadow] outline-none","h-9 min-w-0 has-[>textarea]:h-auto","has-[>[data-align=inline-start]]:[&>input]:pl-2","has-[>[data-align=inline-end]]:[&>input]:pr-2","has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3","has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3","has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot=input-group-control]:focus-visible]:ring-[3px]","has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[[data-slot][aria-invalid=true]]:border-destructive dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40",t),...e})}const sat=Ox("text-muted-foreground flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium select-none [&>svg:not([class*='size-'])]:size-4 [&>kbd]:rounded-[calc(var(--radius)-5px)] group-data-[disabled=true]/input-group:opacity-50",{variants:{align:{"inline-start":"order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]","inline-end":"order-last pr-3 has-[>button]:mr-[-0.45rem] has-[>kbd]:mr-[-0.35rem]","block-start":"order-first w-full justify-start px-3 pt-3 [.border-b]:pb-3 group-has-[>input]/input-group:pt-2.5","block-end":"order-last w-full justify-start px-3 pb-3 [.border-t]:pt-3 group-has-[>input]/input-group:pb-2.5"}},defaultVariants:{align:"inline-start"}});function Fie({className:t,align:e="inline-start",...n}){return H.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":e,className:Tn(sat({align:e}),t),onClick:a=>{var r,i;a.target.closest("button")||(i=(r=a.currentTarget.parentElement)==null?void 0:r.querySelector("input"))==null||i.focus()},...n})}const cat=Ox(" input-group-button text-sm shadow-none flex gap-2 items-center",{variants:{size:{xs:"h-6 gap-1 px-2 rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-3.5 has-[>svg]:px-2",sm:"h-8 px-2.5 gap-1.5 rounded-md has-[>svg]:px-2.5","icon-xs":"size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function lat({className:t,type:e="button",variant:n="ghost",size:a="xs",...r}){return H.jsx(sf,{type:e,"data-size":a,variant:n,className:Tn(cat({size:a}),t),...r})}function uat({className:t,...e}){return H.jsx(iat,{"data-slot":"input-group-control",className:Tn("input-group-textarea flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent",t),...e})}const dat="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let pat=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=dat[n[t]&63];return e};const mat=he.createContext(null),Aat=he.createContext(null),Lie=()=>he.useContext(mat),gat=()=>he.useContext(Aat),Nie=he.createContext(null),w2=()=>{const t=gat(),e=he.useContext(Nie),n=t??e;if(!n)throw new Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");return n};function hat({data:t,className:e,...n}){var l;const a=w2(),r=t.filename||"",o=((l=t.mediaType)!=null&&l.startsWith("image/")&&t.url?"image":"file")==="image",s=r||(o?"Image":"Attachment");return H.jsxs(Iat,{children:[H.jsx(nat,{asChild:!0,children:H.jsxs("div",{className:Tn("group relative flex h-8 cursor-pointer select-none items-center gap-1.5 rounded-md border border-border px-1.5 font-medium text-sm transition-all hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",e),...n,children:[H.jsxs("div",{className:"relative size-5 shrink-0",children:[H.jsx("div",{className:"absolute inset-0 flex size-5 items-center justify-center overflow-hidden rounded bg-background transition-opacity group-hover:opacity-0",children:o?H.jsx("img",{alt:r||"attachment",className:"size-5 object-cover",height:20,src:t.url,width:20}):H.jsx("div",{className:"flex size-5 items-center justify-center text-muted-foreground",children:H.jsx(xSe,{className:"size-3"})})}),H.jsxs(sf,{"aria-label":"Remove attachment",className:"absolute inset-0 size-5 cursor-pointer rounded p-0 opacity-0 transition-opacity group-hover:pointer-events-auto group-hover:opacity-100 [&>svg]:size-2.5",onClick:u=>{u.stopPropagation(),a.remove(t.id)},type:"button",variant:"ghost",children:[H.jsx(ISe,{}),H.jsx("span",{className:"sr-only",children:"Remove"})]})]}),H.jsx("span",{className:"flex-1 truncate",children:s})]},t.id)}),H.jsx(Dat,{className:"w-auto p-2",children:H.jsxs("div",{className:"w-auto space-y-3",children:[o&&H.jsx("div",{className:"flex max-h-96 w-96 items-center justify-center overflow-hidden rounded-md border",children:H.jsx("img",{alt:r||"attachment preview",className:"max-h-full max-w-full object-contain",height:384,src:t.url,width:448})}),H.jsx("div",{className:"flex items-center gap-2.5",children:H.jsxs("div",{className:"min-w-0 flex-1 space-y-1 px-0.5",children:[H.jsx("h4",{className:"truncate font-semibold text-sm leading-none",children:r||(o?"Image":"Attachment")}),t.mediaType&&H.jsx("p",{className:"truncate font-mono text-muted-foreground text-xs",children:t.mediaType})]})})]})})]})}function fat({children:t,className:e,...n}){const a=w2();return a.files.length?H.jsx("div",{className:Tn("flex flex-wrap items-center gap-2 p-3 w-full",e),...n,children:a.files.map(r=>H.jsx(he.Fragment,{children:t(r)},r.id))}):null}const bat=({label:t="Add photos or files",...e})=>{const n=w2();return H.jsxs(qnt,{...e,onSelect:a=>{a.preventDefault(),n.openFileDialog()},children:[H.jsx(vSe,{className:"mr-2 size-4"})," ",t]})},yat=({className:t,accept:e,multiple:n,globalDrop:a,syncHiddenInput:r,maxFiles:i,maxFileSize:o,onError:s,onSubmit:l,children:u,...d})=>{const p=Lie(),m=!!p,A=he.useRef(null),g=he.useRef(null),[h,f]=he.useState([]),b=m?p.attachments.files:h,y=he.useRef(b);y.current=b;const w=he.useCallback(()=>{var L;(L=A.current)==null||L.click()},[]),k=he.useCallback(L=>!e||e.trim()===""?!0:e.split(",").map(R=>R.trim()).filter(Boolean).some(R=>{if(R.endsWith("/*")){const $=R.slice(0,-1);return L.type.startsWith($)}return L.type===R}),[e]),C=he.useCallback(L=>{const F=Array.from(L),R=F.filter(q=>k(q));if(F.length&&R.length===0){s==null||s({code:"accept",message:"No files match the accepted types."});return}const $=q=>o?q.size<=o:!0,P=R.filter($);if(R.length>0&&P.length===0){s==null||s({code:"max_file_size",message:"All files exceed the maximum size."});return}f(q=>{const j=typeof i=="number"?Math.max(0,i-q.length):void 0,J=typeof j=="number"?P.slice(0,j):P;typeof j=="number"&&P.length>j&&(s==null||s({code:"max_files",message:"Too many files. Some were not added."}));const Y=[];for(const ne of J)Y.push({id:pat(),type:"file",url:URL.createObjectURL(ne),mediaType:ne.type,filename:ne.name});return q.concat(Y)})},[k,i,o,s]),x=he.useCallback(L=>f(F=>{const R=F.find($=>$.id===L);return R!=null&&R.url&&URL.revokeObjectURL(R.url),F.filter($=>$.id!==L)}),[]),_=he.useCallback(()=>f(L=>{for(const F of L)F.url&&URL.revokeObjectURL(F.url);return[]}),[]),E=m?p.attachments.add:C,D=m?p.attachments.remove:x,Q=m?p.attachments.clear:_,B=m?p.attachments.openFileDialog:w;he.useEffect(()=>{m&&p.__registerFileInput(A,()=>{var L;return(L=A.current)==null?void 0:L.click()})},[m,p]),he.useEffect(()=>{r&&A.current&&b.length===0&&(A.current.value="")},[b,r]),he.useEffect(()=>{const L=g.current;if(!L||a)return;const F=$=>{var P,q;(q=(P=$.dataTransfer)==null?void 0:P.types)!=null&&q.includes("Files")&&$.preventDefault()},R=$=>{var P,q,j;(q=(P=$.dataTransfer)==null?void 0:P.types)!=null&&q.includes("Files")&&$.preventDefault(),(j=$.dataTransfer)!=null&&j.files&&$.dataTransfer.files.length>0&&E($.dataTransfer.files)};return L.addEventListener("dragover",F),L.addEventListener("drop",R),()=>{L.removeEventListener("dragover",F),L.removeEventListener("drop",R)}},[E,a]),he.useEffect(()=>{if(!a)return;const L=R=>{var $,P;(P=($=R.dataTransfer)==null?void 0:$.types)!=null&&P.includes("Files")&&R.preventDefault()},F=R=>{var $,P,q;(P=($=R.dataTransfer)==null?void 0:$.types)!=null&&P.includes("Files")&&R.preventDefault(),(q=R.dataTransfer)!=null&&q.files&&R.dataTransfer.files.length>0&&E(R.dataTransfer.files)};return document.addEventListener("dragover",L),document.addEventListener("drop",F),()=>{document.removeEventListener("dragover",L),document.removeEventListener("drop",F)}},[E,a]),he.useEffect(()=>()=>{if(!m)for(const L of y.current)L.url&&URL.revokeObjectURL(L.url)},[m]);const T=L=>{L.currentTarget.files&&E(L.currentTarget.files),L.currentTarget.value=""},N=async L=>{try{const R=await(await fetch(L)).blob();return new Promise($=>{const P=new FileReader;P.onloadend=()=>$(P.result),P.onerror=()=>$(null),P.readAsDataURL(R)})}catch{return null}},I=he.useMemo(()=>({files:b.map(L=>({...L,id:L.id})),add:E,remove:D,clear:Q,openFileDialog:B,fileInputRef:A}),[b,E,D,Q,B]),S=L=>{L.preventDefault();const F=L.currentTarget,R=m?p.textInput.value:new FormData(F).get("message")||"";m||F.reset(),Promise.all(b.map(async({id:$,...P})=>{if(P.url&&P.url.startsWith("blob:")){const q=await N(P.url);return{...P,url:q??P.url}}return P})).then($=>{try{const P=l({text:R,files:$},L);P instanceof Promise?P.then(()=>{Q(),m&&p.textInput.clear()}).catch(()=>{}):(Q(),m&&p.textInput.clear())}catch{}}).catch(()=>{})},M=H.jsxs(H.Fragment,{children:[H.jsx("input",{accept:e,"aria-label":"Upload files",className:"hidden",multiple:n,onChange:T,ref:A,title:"Upload files",type:"file"}),H.jsx("form",{className:Tn("w-full",t),onSubmit:S,ref:g,...d,children:H.jsx(oat,{className:"overflow-hidden",children:u})})]});return m?M:H.jsx(Nie.Provider,{value:I,children:M})},wat=({className:t,...e})=>H.jsx("div",{className:Tn("contents",t),...e}),kat=({onChange:t,className:e,placeholder:n="What would you like to know?",...a})=>{const r=Lie(),i=w2(),[o,s]=he.useState(!1),l=p=>{if(p.key==="Enter"){if(o||p.nativeEvent.isComposing||p.shiftKey)return;p.preventDefault();const m=p.currentTarget.form,A=m==null?void 0:m.querySelector('button[type="submit"]');if(A!=null&&A.disabled)return;m==null||m.requestSubmit()}if(p.key==="Backspace"&&p.currentTarget.value===""&&i.files.length>0){p.preventDefault();const m=i.files.at(-1);m&&i.remove(m.id)}},u=p=>{var g;const m=(g=p.clipboardData)==null?void 0:g.items;if(!m)return;const A=[];for(const h of m)if(h.kind==="file"){const f=h.getAsFile();f&&A.push(f)}A.length>0&&(p.preventDefault(),i.add(A))},d=r?{value:r.textInput.value,onChange:p=>{r.textInput.setInput(p.currentTarget.value),t==null||t(p)}}:{onChange:t};return H.jsx(uat,{className:Tn("field-sizing-content max-h-48 min-h-16",e),name:"message",onCompositionEnd:()=>s(!1),onCompositionStart:()=>s(!0),onKeyDown:l,onPaste:u,placeholder:n,...a,...d})},vat=({className:t,...e})=>H.jsx(Fie,{align:"block-end",className:Tn("order-first flex-wrap gap-1",t),...e}),Cat=({className:t,...e})=>H.jsx(Fie,{align:"block-end",className:Tn("justify-between gap-1",t),...e}),_at=({variant:t="ghost",className:e,size:n,...a})=>{const r=n??(he.Children.count(a.children)>1?"sm":"icon-sm");return H.jsx(lat,{className:Tn(e),size:r,type:"button",variant:t,...a})},xat=t=>H.jsx(Ont,{...t}),Eat=({className:t,children:e,...n})=>H.jsx(jnt,{asChild:!0,children:H.jsx(_at,{className:t,...n,children:e??H.jsx(ESe,{className:"size-4"})})}),Bat=({className:t,...e})=>H.jsx(Gnt,{align:"start",className:Tn(t),...e}),Iat=({openDelay:t=0,closeDelay:e=0,...n})=>H.jsx(tat,{closeDelay:e,openDelay:t,...n}),Dat=({align:t="start",...e})=>H.jsx(aat,{align:t,...e});class bF{constructor(e,n){We(this,"api");We(this,"headers",{"Content-Type":"application/json"});this.api=e,this.headers=n??this.headers}post(e){return fetch(this.api,{method:"POST",headers:this.headers,body:JSON.stringify(e)})}put(e){return fetch(this.api,{method:"PUT",headers:this.headers,body:JSON.stringify(e)})}}const Mie=t=>{let e=!1;const n=d=>{t(p=>{const m=p[p.length-1];return(m==null?void 0:m.role)!=="assistant"?p:[...p.slice(0,-1),d(m)]})},a=d=>{d&&t(p=>{var A;const m=p[p.length-1];return e&&(m==null?void 0:m.role)==="assistant"&&((A=m==null?void 0:m.tool)==null?void 0:A.result)!==void 0?(e=!1,[...p,{role:"assistant",content:d}]):(m==null?void 0:m.role)==="assistant"&&(m!=null&&m.tool)&&!m.tool.result?p:(m==null?void 0:m.role)==="assistant"?[...p.slice(0,-1),{...m,content:m.content+d}]:[...p,{role:"assistant",content:d}]})},r=d=>{t(p=>{const m=p[p.length-1],A={tool:d.tool,input:d.input};return(m==null?void 0:m.role)==="assistant"?[...p.slice(0,-1),{...m,tool:A}]:[...p,{role:"assistant",content:"",tool:A}]})},i=d=>{e=!0,n(p=>({...p,tool:{...p.tool,result:d.result}}))},o=d=>(d==null?void 0:d.type)==="message_chunk"?d.content:"",s=d=>{const p=d==null?void 0:d.type;if(p==="tool_call"){r(d);return}if(p==="tool_result"){i(d);return}const m=o(d);m&&a(m)},l=d=>{const p=d.trim();return!p||p.startsWith(":")||p.startsWith("event:")?null:p==="[DONE]"?"[DONE]":p.startsWith("data:")?p.slice(5).trim():p};return{splitChunks:async d=>{if(!d.body)return;e=!1;const p=d.body.getReader(),m=new TextDecoder;let A="";for(;;){const{done:g,value:h}=await p.read();if(g)break;A+=m.decode(h,{stream:!0});const f=A.split(`
731
731
  `);A=f.pop()??"";for(const b of f){const y=l(b);if(y){if(y==="[DONE]")return;try{const w=JSON.parse(y);s(w)}catch{a(y)}}}}}}},Qat="demo-123",Sat=(t,e)=>{const[n,a]=he.useState([]),{splitChunks:r}=Mie(a);return{onSubmit:async({params:o={},input:s,setInput:l,abortRef:u})=>{var p;if(!s.trim())return;const d=s;l(""),a(m=>[...m,{role:"user",content:d}]);try{(p=u==null?void 0:u.current)==null||p.abort();const m=new AbortController;u.current=m;const A=e?{"Content-Type":"application/json",...e}:{},g=new bF(t,A),h={chat_id:Qat,message:d,...o},f=await g.post(h);if(!f.ok){const b=await f.text().catch(()=>"");throw new Error(`HTTP ${f.status} ${f.statusText} ${b}`)}r(f)}catch(m){console.error("Error onSubmit",m)}},messages:n}},yF=[{key:"suggestion-1",title:"Mostrar reglas del mismo conjunto (rule set)",description:"Lista todas las reglas que pertenecen al mismo conjunto de reglas de esta convocatoria."},{key:"suggestion-2",title:"Buscar reglas por tipo o etiquetas",description:"Encuentra reglas relacionadas filtrando por tipo específico o etiquetas asignadas."},{key:"suggestion-3",title:"Encontrar reglas con descripción similar",description:"Identifica reglas que tienen descripciones parecidas a la regla actual."},{key:"suggestion-4",title:"Listar reglas que afectan estudiantes similares",description:"Descubre reglas que impactan al mismo perfil de estudiantes según criterios compartidos."}];var Rie={exports:{}},u1={};/**
732
732
  * @license React
733
733
  * react-jsx-runtime.production.min.js
@@ -1349,7 +1349,7 @@ clipRule="evenodd"
1349
1349
  `&&t.lineWrapping&&(a&&(a=lt.single(a.main.anchor-1,a.main.head-1)),n={from:r.from,to:r.to,insert:ea.of([" "])}),n)return hL(t,n,a,i);if(a&&!a.main.eq(r)){let o=!1,s="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(o=!0),s=t.inputState.lastSelectionOrigin,s=="select.pointer"&&(a=bse(t.state.facet(x1).map(l=>l(t)),a))),t.dispatch({selection:a,scrollIntoView:o,userEvent:s}),!0}else return!1}function hL(t,e,n,a=-1){if(Ot.ios&&t.inputState.flushIOSKey(e))return!0;let r=t.state.selection.main;if(Ot.android&&(e.to==r.to&&(e.from==r.from||e.from==r.from-1&&t.state.sliceDoc(e.from,r.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&ub(t.contentDOM,"Enter",13)||(e.from==r.from-1&&e.to==r.to&&e.insert.length==0||a==8&&e.insert.length<e.to-e.from&&e.to>r.head)&&ub(t.contentDOM,"Backspace",8)||e.from==r.from&&e.to==r.to+1&&e.insert.length==0&&ub(t.contentDOM,"Delete",46)))return!0;let i=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let o,s=()=>o||(o=tst(t,e,n));return t.state.facet(Joe).some(l=>l(t,e.from,e.to,i,s))||t.dispatch(s()),!0}function tst(t,e,n){let a,r=t.state,i=r.selection.main,o=-1;if(e.from==e.to&&e.from<i.from||e.from>i.to){let l=e.from<i.from?-1:1,u=l<0?i.from:i.to,d=B1(r.facet(x1).map(p=>p(t)),u,l);e.from==d&&(o=d)}if(o>-1)a={changes:e,selection:lt.cursor(e.from+e.insert.length,-1)};else if(e.from>=i.from&&e.to<=i.to&&e.to-e.from>=(i.to-i.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let l=i.from<e.from?r.sliceDoc(i.from,e.from):"",u=i.to>e.to?r.sliceDoc(e.to,i.to):"";a=r.replaceSelection(t.state.toText(l+e.insert.sliceString(0,void 0,t.state.lineBreak)+u))}else{let l=r.changes(e),u=n&&n.main.to<=l.newLength?n.main:void 0;if(r.selection.ranges.length>1&&t.inputState.composing>=0&&e.to<=i.to&&e.to>=i.to-10){let d=t.state.sliceDoc(e.from,e.to),p,m=n&&use(t,n.main.head);if(m){let h=e.insert.length-(e.to-e.from);p={from:m.from,to:m.to-h}}else p=t.state.doc.lineAt(i.head);let A=i.to-e.to,g=i.to-i.from;a=r.changeByRange(h=>{if(h.from==i.from&&h.to==i.to)return{changes:l,range:u||h.map(l)};let f=h.to-A,b=f-d.length;if(h.to-h.from!=g||t.state.sliceDoc(b,f)!=d||h.to>=p.from&&h.from<=p.to)return{range:h};let y=r.changes({from:b,to:f,insert:e.insert}),w=h.to-i.to;return{changes:y,range:u?lt.range(Math.max(0,u.anchor+w),Math.max(0,u.head+w)):h.map(y)}})}else a={changes:l,selection:u&&r.selection.replaceRange(u)}}let s="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,s+=".compose",t.inputState.compositionFirstChange&&(s+=".start",t.inputState.compositionFirstChange=!1)),r.update(a,{userEvent:s,scrollIntoView:!0})}function kse(t,e,n,a){let r=Math.min(t.length,e.length),i=0;for(;i<r&&t.charCodeAt(i)==e.charCodeAt(i);)i++;if(i==r&&t.length==e.length)return null;let o=t.length,s=e.length;for(;o>0&&s>0&&t.charCodeAt(o-1)==e.charCodeAt(s-1);)o--,s--;if(a=="end"){let l=Math.max(0,i-Math.min(o,s));n-=o+l-i}if(o<i&&t.length<e.length){let l=n<=i&&n>=o?i-n:0;i-=l,s=i+(s-o),o=i}else if(s<i){let l=n<=i&&n>=s?i-n:0;i-=l,o=i+(o-s),s=i}return{from:i,toA:o,toB:s}}function nst(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:a,focusNode:r,focusOffset:i}=t.observer.selectionRange;return n&&(e.push(new yse(n,a)),(r!=n||i!=a)&&e.push(new yse(r,i))),e}function ast(t,e){if(t.length==0)return null;let n=t[0].pos,a=t.length==2?t[1].pos:n;return n>-1&&a>-1?lt.single(n+e,a+e):null}class rst{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Ot.safari&&e.contentDOM.addEventListener("input",()=>null),Ot.gecko&&wst(e.contentDOM.ownerDocument)}handleEvent(e){!pst(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let a=this.handlers[e];if(a){for(let r of a.observers)r(this.view,n);for(let r of a.handlers){if(n.defaultPrevented)break;if(r(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=ist(e),a=this.handlers,r=this.view.contentDOM;for(let i in n)if(i!="scroll"){let o=!n[i].handlers.length,s=a[i];s&&o!=!s.handlers.length&&(r.removeEventListener(i,this.handleEvent),s=null),s||r.addEventListener(i,this.handleEvent,{passive:o})}for(let i in a)i!="scroll"&&!n[i]&&r.removeEventListener(i,this.handleEvent);this.handlers=n}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&_se.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Ot.android&&Ot.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let n;return Ot.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((n=Cse.find(a=>a.keyCode==e.keyCode))&&!e.ctrlKey||ost.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(this.pendingIOSKey=n||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let n=this.pendingIOSKey;return!n||n.key=="Enter"&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,ub(this.view.contentDOM,n.key,n.keyCode,n instanceof KeyboardEvent?n:void 0))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:Ot.safari&&!Ot.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function vse(t,e){return(n,a)=>{try{return e.call(t,a,n)}catch(r){As(n.state,r)}}}function ist(t){let e=Object.create(null);function n(a){return e[a]||(e[a]={observers:[],handlers:[]})}for(let a of t){let r=a.spec,i=r&&r.plugin.domEventHandlers,o=r&&r.plugin.domEventObservers;if(i)for(let s in i){let l=i[s];l&&n(s).handlers.push(vse(a.value,l))}if(o)for(let s in o){let l=o[s];l&&n(s).observers.push(vse(a.value,l))}}for(let a in sl)n(a).handlers.push(sl[a]);for(let a in vc)n(a).observers.push(vc[a]);return e}const Cse=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],ost="dthko",_se=[16,17,18,20,91,92,224,225],$2=6;function P2(t){return Math.max(0,t)*.7+8}function sst(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class cst{constructor(e,n,a,r){this.view=e,this.startEvent=n,this.style=a,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=hot(e.contentDOM),this.atoms=e.state.facet(x1).map(o=>o(e));let i=e.contentDOM.ownerDocument;i.addEventListener("mousemove",this.move=this.move.bind(this)),i.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(Hn.allowMultipleSelections)&&lst(e,n),this.dragging=dst(e,n)&&Fse(n)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&sst(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,a=0,r=0,i=0,o=this.view.win.innerWidth,s=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:i,bottom:s}=this.scrollParents.y.getBoundingClientRect());let l=dL(this.view);e.clientX-l.left<=r+$2?n=-P2(r-e.clientX):e.clientX+l.right>=o-$2&&(n=P2(e.clientX-o)),e.clientY-l.top<=i+$2?a=-P2(i-e.clientY):e.clientY+l.bottom>=s-$2&&(a=P2(e.clientY-s)),this.setScrollSpeed(n,a)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,a=bse(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!a.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:a,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function lst(t,e){let n=t.state.facet(Woe);return n.length?n[0](e):Ot.mac?e.metaKey:e.ctrlKey}function ust(t,e){let n=t.state.facet(Koe);return n.length?n[0](e):Ot.mac?!e.altKey:!e.ctrlKey}function dst(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let a=b1(t.root);if(!a||a.rangeCount==0)return!0;let r=a.getRangeAt(0).getClientRects();for(let i=0;i<r.length;i++){let o=r[i];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function pst(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,a;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(a=va.get(n))&&a.ignoreEvent(e))return!1;return!0}const sl=Object.create(null),vc=Object.create(null),xse=Ot.ie&&Ot.ie_version<15||Ot.ios&&Ot.webkit_version<604;function mst(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),Ese(t,n.value)},50)}function O2(t,e,n){for(let a of t.facet(e))n=a(n,t);return n}function Ese(t,e){e=O2(t.state,sL,e);let{state:n}=t,a,r=1,i=n.toText(e),o=i.lines==n.selection.ranges.length;if(fL!=null&&n.selection.ranges.every(l=>l.empty)&&fL==i.toString()){let l=-1;a=n.changeByRange(u=>{let d=n.doc.lineAt(u.from);if(d.from==l)return{range:u};l=d.from;let p=n.toText((o?i.line(r++).text:e)+n.lineBreak);return{changes:{from:d.from,insert:p},range:lt.cursor(u.from+p.length)}})}else o?a=n.changeByRange(l=>{let u=i.line(r++);return{changes:{from:l.from,to:l.to,insert:u.text},range:lt.cursor(l.from+u.length)}}):a=n.replaceSelection(i);t.dispatch(a,{userEvent:"input.paste",scrollIntoView:!0})}vc.scroll=t=>{t.inputState.lastScrollTop=t.scrollDOM.scrollTop,t.inputState.lastScrollLeft=t.scrollDOM.scrollLeft},sl.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),vc.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},vc.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},sl.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let a of t.state.facet(Zoe))if(n=a(t,e),n)break;if(!n&&e.button==0&&(n=hst(t,e)),n){let a=!t.hasFocus;t.inputState.startMouseSelection(new cst(t,e,n,a)),a&&t.observer.ignore(()=>{Ioe(t.contentDOM);let i=t.root.activeElement;i&&!i.contains(t.contentDOM)&&i.blur()});let r=t.inputState.mouseSelection;if(r)return r.start(e),r.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function Bse(t,e,n,a){if(a==1)return lt.cursor(e,n);if(a==2)return qot(t.state,e,n);{let r=Lr.find(t.docView,e),i=t.state.doc.lineAt(r?r.posAtEnd:e),o=r?r.posAtStart:i.from,s=r?r.posAtEnd:i.to;return s<t.state.doc.length&&s==i.to&&s++,lt.range(o,s)}}let Ise=(t,e,n)=>e>=n.top&&e<=n.bottom&&t>=n.left&&t<=n.right;function Ast(t,e,n,a){let r=Lr.find(t.docView,e);if(!r)return 1;let i=e-r.posAtStart;if(i==0)return 1;if(i==r.length)return-1;let o=r.coordsAt(i,-1);if(o&&Ise(n,a,o))return-1;let s=r.coordsAt(i,1);return s&&Ise(n,a,s)?1:o&&o.bottom>=a?-1:1}function Dse(t,e){let n=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:n,bias:Ast(t,n,e.clientX,e.clientY)}}const gst=Ot.ie&&Ot.ie_version<=11;let Qse=null,Sse=0,Tse=0;function Fse(t){if(!gst)return t.detail;let e=Qse,n=Tse;return Qse=t,Tse=Date.now(),Sse=!e||n>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Sse+1)%3:1}function hst(t,e){let n=Dse(t,e),a=Fse(e),r=t.state.selection;return{update(i){i.docChanged&&(n.pos=i.changes.mapPos(n.pos),r=r.map(i.changes))},get(i,o,s){let l=Dse(t,i),u,d=Bse(t,l.pos,l.bias,a);if(n.pos!=l.pos&&!o){let p=Bse(t,n.pos,n.bias,a),m=Math.min(p.from,d.from),A=Math.max(p.to,d.to);d=m<d.from?lt.range(m,A):lt.range(A,m)}return o?r.replaceRange(r.main.extend(d.from,d.to)):s&&a==1&&r.ranges.length>1&&(u=fst(r,l.pos))?u:s?r.addRange(d):lt.create([d])}}}function fst(t,e){for(let n=0;n<t.ranges.length;n++){let{from:a,to:r}=t.ranges[n];if(a<=e&&r>=e)return lt.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}sl.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let r=t.docView.nearest(e.target);if(r&&r.isWidget){let i=r.posAtStart,o=i+r.length;(i>=n.to||o<=n.from)&&(n=lt.range(i,o))}}let{inputState:a}=t;return a.mouseSelection&&(a.mouseSelection.dragging=!0),a.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",O2(t.state,cL,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1},sl.dragend=t=>(t.inputState.draggedContent=null,!1);function Lse(t,e,n,a){if(n=O2(t.state,sL,n),!n)return;let r=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:i}=t.inputState,o=a&&i&&ust(t,e)?{from:i.from,to:i.to}:null,s={from:r,insert:n},l=t.state.changes(o?[o,s]:s);t.focus(),t.dispatch({changes:l,selection:{anchor:l.mapPos(r,-1),head:l.mapPos(r,1)},userEvent:o?"move.drop":"input.drop"}),t.inputState.draggedContent=null}sl.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let a=Array(n.length),r=0,i=()=>{++r==n.length&&Lse(t,e,a.filter(o=>o!=null).join(t.state.lineBreak),!1)};for(let o=0;o<n.length;o++){let s=new FileReader;s.onerror=i,s.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(s.result)||(a[o]=s.result),i()},s.readAsText(n[o])}return!0}else{let a=e.dataTransfer.getData("Text");if(a)return Lse(t,e,a,!0),!0}return!1},sl.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=xse?null:e.clipboardData;return n?(Ese(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(mst(t),!1)};function bst(t,e){let n=t.dom.parentNode;if(!n)return;let a=n.appendChild(document.createElement("textarea"));a.style.cssText="position: fixed; left: -10000px; top: 10px",a.value=e,a.focus(),a.selectionEnd=e.length,a.selectionStart=0,setTimeout(()=>{a.remove(),t.focus()},50)}function yst(t){let e=[],n=[],a=!1;for(let r of t.selection.ranges)r.empty||(e.push(t.sliceDoc(r.from,r.to)),n.push(r));if(!e.length){let r=-1;for(let{from:i}of t.selection.ranges){let o=t.doc.lineAt(i);o.number>r&&(e.push(o.text),n.push({from:o.from,to:Math.min(t.doc.length,o.to+1)})),r=o.number}a=!0}return{text:O2(t,cL,e.join(t.lineBreak)),ranges:n,linewise:a}}let fL=null;sl.copy=sl.cut=(t,e)=>{let{text:n,ranges:a,linewise:r}=yst(t.state);if(!n&&!r)return!1;fL=r?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:a,scrollIntoView:!0,userEvent:"delete.cut"});let i=xse?null:e.clipboardData;return i?(i.clearData(),i.setData("text/plain",n),!0):(bst(t,n),!1)};const Nse=lu.define();function Mse(t,e){let n=[];for(let a of t.facet(Xoe)){let r=a(t,e);r&&n.push(r)}return n.length?t.update({effects:n,annotations:Nse.of(!0)}):null}function Rse(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=Mse(t.state,e);n?t.dispatch(n):t.update([])}},10)}vc.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),Rse(t)},vc.blur=t=>{t.observer.clearSelectionRange(),Rse(t)},vc.compositionstart=vc.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},vc.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Ot.chrome&&Ot.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))},vc.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},sl.beforeinput=(t,e)=>{var n,a;if(e.inputType=="insertReplacementText"&&t.observer.editContext){let i=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),o=e.getTargetRanges();if(i&&o.length){let s=o[0],l=t.posAtDOM(s.startContainer,s.startOffset),u=t.posAtDOM(s.endContainer,s.endOffset);return hL(t,{from:l,to:u,insert:t.state.toText(i)},null),!0}}let r;if(Ot.chrome&&Ot.android&&(r=Cse.find(i=>i.inputType==e.inputType))&&(t.observer.delayAndroidKey(r.key,r.keyCode),r.key=="Backspace"||r.key=="Delete")){let i=((a=window.visualViewport)===null||a===void 0?void 0:a.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>i+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Ot.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Ot.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>vc.compositionend(t,e),20),!1};const $se=new Set;function wst(t){$se.has(t)||($se.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const Pse=["pre-wrap","normal","pre-line","break-spaces"];let gb=!1;function Ose(){gb=!1}class kst{constructor(e){this.lineWrapping=e,this.doc=ea.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let a=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(a+=Math.max(0,Math.ceil((n-e-a*this.lineLength*.5)/this.lineLength))),this.lineHeight*a}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Pse.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let a=0;a<e.length;a++){let r=e[a];r<0?a++:this.heightSamples[Math.floor(r*10)]||(n=!0,this.heightSamples[Math.floor(r*10)]=!0)}return n}refresh(e,n,a,r,i,o){let s=Pse.indexOf(e)>-1,l=Math.round(n)!=Math.round(this.lineHeight)||this.lineWrapping!=s;if(this.lineWrapping=s,this.lineHeight=n,this.charWidth=a,this.textHeight=r,this.lineLength=i,l){this.heightSamples={};for(let u=0;u<o.length;u++){let d=o[u];d<0?u++:this.heightSamples[Math.floor(d*10)]=!0}}return l}}class vst{constructor(e,n){this.from=e,this.heights=n,this.index=0}get more(){return this.index<this.heights.length}}class mu{constructor(e,n,a,r,i){this.from=e,this.length=n,this.top=a,this.height=r,this._content=i}get type(){return typeof this._content=="number"?$o.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof im?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let n=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new mu(this.from,this.length+e.length,this.top,this.height+e.height,n)}}var $a=function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t}($a||($a={}));const j2=.001;class Po{constructor(e,n,a=2){this.length=e,this.height=n,this.flags=a}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>j2&&(gb=!0),this.height=e)}replace(e,n,a){return Po.of(a)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,a,r){let i=this,o=a.doc;for(let s=r.length-1;s>=0;s--){let{fromA:l,toA:u,fromB:d,toB:p}=r[s],m=i.lineAt(l,$a.ByPosNoHeight,a.setDoc(n),0,0),A=m.to>=u?m:i.lineAt(u,$a.ByPosNoHeight,a,0,0);for(p+=A.to-u,u=A.to;s>0&&m.from<=r[s-1].toA;)l=r[s-1].fromA,d=r[s-1].fromB,s--,l<m.from&&(m=i.lineAt(l,$a.ByPosNoHeight,a,0,0));d+=m.from-l,l=m.from;let g=bL.build(a.setDoc(o),e,d,p);i=G2(i,i.replace(l,u,g))}return i.updateHeight(a,0)}static empty(){return new js(0,0)}static of(e){if(e.length==1)return e[0];let n=0,a=e.length,r=0,i=0;for(;;)if(n==a)if(r>i*2){let s=e[n-1];s.break?e.splice(--n,1,s.left,null,s.right):e.splice(--n,1,s.left,s.right),a+=1+s.break,r-=s.size}else if(i>r*2){let s=e[a];s.break?e.splice(a,1,s.left,null,s.right):e.splice(a,1,s.left,s.right),a+=2+s.break,i-=s.size}else break;else if(r<i){let s=e[n++];s&&(r+=s.size)}else{let s=e[--a];s&&(i+=s.size)}let o=0;return e[n-1]==null?(o=1,n--):e[n]==null&&(o=1,a++),new Cst(Po.of(e.slice(0,n)),o,Po.of(e.slice(a)))}}function G2(t,e){return t==e?t:(t.constructor!=e.constructor&&(gb=!0),e)}Po.prototype.size=1;class jse extends Po{constructor(e,n,a){super(e,n),this.deco=a}blockAt(e,n,a,r){return new mu(r,this.length,a,this.height,this.deco||0)}lineAt(e,n,a,r,i){return this.blockAt(0,a,r,i)}forEachLine(e,n,a,r,i,o){e<=i+this.length&&n>=i&&o(this.blockAt(0,a,r,i))}updateHeight(e,n=0,a=!1,r){return r&&r.from<=n&&r.more&&this.setHeight(r.heights[r.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class js extends jse{constructor(e,n){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,n,a,r){return new mu(r,this.length,a,this.height,this.breaks)}replace(e,n,a){let r=a[0];return a.length==1&&(r instanceof js||r instanceof $i&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof $i?r=new js(r.length,this.height):r.height=this.height,this.outdated||(r.outdated=!1),r):Po.of(a)}updateHeight(e,n=0,a=!1,r){return r&&r.from<=n&&r.more?this.setHeight(r.heights[r.index++]):(a||this.outdated)&&this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class $i extends Po{constructor(e){super(e,0)}heightMetrics(e,n){let a=e.doc.lineAt(n).number,r=e.doc.lineAt(n+this.length).number,i=r-a+1,o,s=0;if(e.lineWrapping){let l=Math.min(this.height,e.lineHeight*i);o=l/i,this.length>i+1&&(s=(this.height-l)/(this.length-i-1))}else o=this.height/i;return{firstLine:a,lastLine:r,perLine:o,perChar:s}}blockAt(e,n,a,r){let{firstLine:i,lastLine:o,perLine:s,perChar:l}=this.heightMetrics(n,r);if(n.lineWrapping){let u=r+(e<n.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-a)/this.height))*this.length)),d=n.doc.lineAt(u),p=s+d.length*l,m=Math.max(a,e-p/2);return new mu(d.from,d.length,m,p,0)}else{let u=Math.max(0,Math.min(o-i,Math.floor((e-a)/s))),{from:d,length:p}=n.doc.line(i+u);return new mu(d,p,a+s*u,s,0)}}lineAt(e,n,a,r,i){if(n==$a.ByHeight)return this.blockAt(e,a,r,i);if(n==$a.ByPosNoHeight){let{from:A,to:g}=a.doc.lineAt(e);return new mu(A,g-A,0,0,0)}let{firstLine:o,perLine:s,perChar:l}=this.heightMetrics(a,i),u=a.doc.lineAt(e),d=s+u.length*l,p=u.number-o,m=r+s*p+l*(u.from-i-p);return new mu(u.from,u.length,Math.max(r,Math.min(m,r+this.height-d)),d,0)}forEachLine(e,n,a,r,i,o){e=Math.max(e,i),n=Math.min(n,i+this.length);let{firstLine:s,perLine:l,perChar:u}=this.heightMetrics(a,i);for(let d=e,p=r;d<=n;){let m=a.doc.lineAt(d);if(d==e){let g=m.number-s;p+=l*g+u*(e-i-g)}let A=l+u*m.length;o(new mu(m.from,m.length,p,A,0)),p+=A,d=m.to+1}}replace(e,n,a){let r=this.length-n;if(r>0){let i=a[a.length-1];i instanceof $i?a[a.length-1]=new $i(i.length+r):a.push(null,new $i(r-1))}if(e>0){let i=a[0];i instanceof $i?a[0]=new $i(e+i.length):a.unshift(new $i(e-1),null)}return Po.of(a)}decomposeLeft(e,n){n.push(new $i(e-1),null)}decomposeRight(e,n){n.push(null,new $i(this.length-e-1))}updateHeight(e,n=0,a=!1,r){let i=n+this.length;if(r&&r.from<=n+this.length&&r.more){let o=[],s=Math.max(n,r.from),l=-1;for(r.from>n&&o.push(new $i(r.from-n-1).updateHeight(e,n));s<=i&&r.more;){let d=e.doc.lineAt(s).length;o.length&&o.push(null);let p=r.heights[r.index++];l==-1?l=p:Math.abs(p-l)>=j2&&(l=-2);let m=new js(d,p);m.outdated=!1,o.push(m),s+=d+1}s<=i&&o.push(null,new $i(i-s).updateHeight(e,s));let u=Po.of(o);return(l<0||Math.abs(u.height-this.height)>=j2||Math.abs(l-this.heightMetrics(e,n).perLine)>=j2)&&(gb=!0),G2(this,u)}else(a||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class Cst extends Po{constructor(e,n,a){super(e.length+n+a.length,e.height+a.height,n|(e.outdated||a.outdated?2:0)),this.left=e,this.right=a,this.size=e.size+a.size}get break(){return this.flags&1}blockAt(e,n,a,r){let i=a+this.left.height;return e<i?this.left.blockAt(e,n,a,r):this.right.blockAt(e,n,i,r+this.left.length+this.break)}lineAt(e,n,a,r,i){let o=r+this.left.height,s=i+this.left.length+this.break,l=n==$a.ByHeight?e<o:e<s,u=l?this.left.lineAt(e,n,a,r,i):this.right.lineAt(e,n,a,o,s);if(this.break||(l?u.to<s:u.from>s))return u;let d=n==$a.ByPosNoHeight?$a.ByPosNoHeight:$a.ByPos;return l?u.join(this.right.lineAt(s,d,a,o,s)):this.left.lineAt(s,d,a,r,i).join(u)}forEachLine(e,n,a,r,i,o){let s=r+this.left.height,l=i+this.left.length+this.break;if(this.break)e<l&&this.left.forEachLine(e,n,a,r,i,o),n>=l&&this.right.forEachLine(e,n,a,s,l,o);else{let u=this.lineAt(l,$a.ByPos,a,r,i);e<u.from&&this.left.forEachLine(e,u.from-1,a,r,i,o),u.to>=e&&u.from<=n&&o(u),n>u.to&&this.right.forEachLine(u.to+1,n,a,s,l,o)}}replace(e,n,a){let r=this.left.length+this.break;if(n<r)return this.balanced(this.left.replace(e,n,a),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,n-r,a));let i=[];e>0&&this.decomposeLeft(e,i);let o=i.length;for(let s of a)i.push(s);if(e>0&&Gse(i,o-1),n<this.length){let s=i.length;this.decomposeRight(n,i),Gse(i,s)}return Po.of(i)}decomposeLeft(e,n){let a=this.left.length;if(e<=a)return this.left.decomposeLeft(e,n);n.push(this.left),this.break&&(a++,e>=a&&n.push(null)),e>a&&this.right.decomposeLeft(e-a,n)}decomposeRight(e,n){let a=this.left.length,r=a+this.break;if(e>=r)return this.right.decomposeRight(e-r,n);e<a&&this.left.decomposeRight(e,n),this.break&&e<r&&n.push(null),n.push(this.right)}balanced(e,n){return e.size>2*n.size||n.size>2*e.size?Po.of(this.break?[e,null,n]:[e,n]):(this.left=G2(this.left,e),this.right=G2(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,a=!1,r){let{left:i,right:o}=this,s=n+i.length+this.break,l=null;return r&&r.from<=n+i.length&&r.more?l=i=i.updateHeight(e,n,a,r):i.updateHeight(e,n,a),r&&r.from<=s+o.length&&r.more?l=o=o.updateHeight(e,s,a,r):o.updateHeight(e,s,a),l?this.balanced(i,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Gse(t,e){let n,a;t[e]==null&&(n=t[e-1])instanceof $i&&(a=t[e+1])instanceof $i&&t.splice(e-1,3,new $i(n.length+1+a.length))}const _st=5;class bL{constructor(e,n){this.pos=e,this.oracle=n,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,n){if(this.lineStart>-1){let a=Math.min(n,this.lineEnd),r=this.nodes[this.nodes.length-1];r instanceof js?r.length+=a-this.pos:(a>this.pos||!this.isCovered)&&this.nodes.push(new js(a-this.pos,-1)),this.writtenTo=a,n>a&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,a){if(e<n||a.heightRelevant){let r=a.widget?a.widget.estimatedHeight:0,i=a.widget?a.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let o=n-e;a.block?this.addBlock(new jse(o,r,a)):(o||i||r>=_st)&&this.addLineDeco(r,i,o)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new js(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,n){let a=new $i(n-e);return this.oracle.doc.lineAt(e).to==n&&(a.flags|=4),a}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof js)return e;let n=new js(0,-1);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,a){let r=this.ensureLine();r.length+=a,r.collapsed+=a,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=n,this.writtenTo=this.pos=this.pos+a}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof js)&&!this.isCovered?this.nodes.push(new js(0,-1)):(this.writtenTo<this.pos||n==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let a=e;for(let r of this.nodes)r instanceof js&&r.updateHeight(this.oracle,a),a+=r?r.length:1;return this.nodes}static build(e,n,a,r){let i=new bL(a,e);return ta.spans(n,a,r,i,0),i.finish(a)}}function xst(t,e,n){let a=new Est;return ta.compare(t,e,n,a,0),a.changes}class Est{constructor(){this.changes=[]}compareRange(){}comparePoint(e,n,a,r){(e<n||a&&a.heightRelevant||r&&r.heightRelevant)&&L2(e,n,this.changes,5)}}function Bst(t,e){let n=t.getBoundingClientRect(),a=t.ownerDocument,r=a.defaultView||window,i=Math.max(0,n.left),o=Math.min(r.innerWidth,n.right),s=Math.max(0,n.top),l=Math.min(r.innerHeight,n.bottom);for(let u=t.parentNode;u&&u!=a.body;)if(u.nodeType==1){let d=u,p=window.getComputedStyle(d);if((d.scrollHeight>d.clientHeight||d.scrollWidth>d.clientWidth)&&p.overflow!="visible"){let m=d.getBoundingClientRect();i=Math.max(i,m.left),o=Math.min(o,m.right),s=Math.max(s,m.top),l=Math.min(u==t.parentNode?r.innerHeight:l,m.bottom)}u=p.position=="absolute"||p.position=="fixed"?d.offsetParent:d.parentNode}else if(u.nodeType==11)u=u.host;else break;return{left:i-n.left,right:Math.max(i,o)-n.left,top:s-(n.top+e),bottom:Math.max(s,l)-(n.top+e)}}function Ist(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left<n.innerWidth&&e.right>0&&e.top<n.innerHeight&&e.bottom>0}function Dst(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class yL{constructor(e,n,a,r){this.from=e,this.to=n,this.size=a,this.displaySize=r}static same(e,n){if(e.length!=n.length)return!1;for(let a=0;a<e.length;a++){let r=e[a],i=n[a];if(r.from!=i.from||r.to!=i.to||r.size!=i.size)return!1}return!0}draw(e,n){return ln.replace({widget:new Qst(this.displaySize*(n?e.scaleY:e.scaleX),n)}).range(this.from,this.to)}}class Qst extends Bd{constructor(e,n){super(),this.size=e,this.vertical=n}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}}class qse{constructor(e){this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=zse,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Ra.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let n=e.facet(uL).some(a=>typeof a!="function"&&a.class=="cm-lineWrapping");this.heightOracle=new kst(n),this.stateDeco=e.facet(_1).filter(a=>typeof a!="function"),this.heightMap=Po.empty().applyChanges(this.stateDeco,ea.empty,this.heightOracle.setDoc(e.doc),[new kc(0,0,0,e.doc.length)]);for(let a=0;a<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());a++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=ln.set(this.lineGaps.map(a=>a.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let a=0;a<=1;a++){let r=a?n.head:n.anchor;if(!e.some(({from:i,to:o})=>r>=i&&r<=o)){let{from:i,to:o}=this.lineBlockAt(r);e.push(new q2(i,o))}}return this.viewports=e.sort((a,r)=>a.from-r.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?zse:new wL(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(D1(e,this.scaler))})}update(e,n=null){this.state=e.state;let a=this.stateDeco;this.stateDeco=this.state.facet(_1).filter(d=>typeof d!="function");let r=e.changedRanges,i=kc.extendWithRanges(r,xst(a,this.stateDeco,e?e.changes:ti.empty(this.state.doc.length))),o=this.heightMap.height,s=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);Ose(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),i),(this.heightMap.height!=o||gb)&&(e.flags|=2),s?(this.scrollAnchorPos=e.changes.mapPos(s.from,-1),this.scrollAnchorHeight=s.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let l=i.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.head<l.from||n.range.head>l.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,n));let u=l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l,e.flags|=this.updateForViewport(),(u||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(tse)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let n=e.contentDOM,a=window.getComputedStyle(n),r=this.heightOracle,i=a.whiteSpace;this.defaultTextDirection=a.direction=="rtl"?Ra.RTL:Ra.LTR;let o=this.heightOracle.mustRefreshForWrapping(i),s=n.getBoundingClientRect(),l=o||this.mustMeasureContent||this.contentDOMHeight!=s.height;this.contentDOMHeight=s.height,this.mustMeasureContent=!1;let u=0,d=0;if(s.width&&s.height){let{scaleX:k,scaleY:C}=Boe(n,s);(k>.005&&Math.abs(this.scaleX-k)>.005||C>.005&&Math.abs(this.scaleY-C)>.005)&&(this.scaleX=k,this.scaleY=C,u|=16,o=l=!0)}let p=(parseInt(a.paddingTop)||0)*this.scaleY,m=(parseInt(a.paddingBottom)||0)*this.scaleY;(this.paddingTop!=p||this.paddingBottom!=m)&&(this.paddingTop=p,this.paddingBottom=m,u|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(l=!0),this.editorWidth=e.scrollDOM.clientWidth,u|=16);let A=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=A&&(this.scrollAnchorHeight=-1,this.scrollTop=A),this.scrolledToBottom=Soe(e.scrollDOM);let g=(this.printing?Dst:Bst)(n,this.paddingTop),h=g.top-this.pixelViewport.top,f=g.bottom-this.pixelViewport.bottom;this.pixelViewport=g;let b=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(b!=this.inView&&(this.inView=b,b&&(l=!0)),!this.inView&&!this.scrollTarget&&!Ist(e.dom))return 0;let y=s.width;if((this.contentDOMWidth!=y||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=s.width,this.editorHeight=e.scrollDOM.clientHeight,u|=16),l){let k=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(k)&&(o=!0),o||r.lineWrapping&&Math.abs(y-this.contentDOMWidth)>r.charWidth){let{lineHeight:C,charWidth:x,textHeight:_}=e.docView.measureTextSize();o=C>0&&r.refresh(i,C,x,_,Math.max(5,y/x),k),o&&(e.docView.minWidth=0,u|=16)}h>0&&f>0?d=Math.max(h,f):h<0&&f<0&&(d=Math.min(h,f)),Ose();for(let C of this.viewports){let x=C.from==this.viewport.from?k:e.docView.measureVisibleLineHeights(C);this.heightMap=(o?Po.empty().applyChanges(this.stateDeco,ea.empty,this.heightOracle,[new kc(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new vst(C.from,x))}gb&&(u|=2)}let w=!this.viewportIsAppropriate(this.viewport,d)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return w&&(u&2&&(u|=this.updateScaler()),this.viewport=this.getViewport(d,this.scrollTarget),u|=this.updateForViewport()),(u&2||w)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),u|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),u}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let a=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,i=this.heightOracle,{visibleTop:o,visibleBottom:s}=this,l=new q2(r.lineAt(o-a*1e3,$a.ByHeight,i,0,0).from,r.lineAt(s+(1-a)*1e3,$a.ByHeight,i,0,0).to);if(n){let{head:u}=n.range;if(u<l.from||u>l.to){let d=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),p=r.lineAt(u,$a.ByPos,i,0,0),m;n.y=="center"?m=(p.top+p.bottom)/2-d/2:n.y=="start"||n.y=="nearest"&&u<l.from?m=p.top:m=p.bottom-d,l=new q2(r.lineAt(m-1e3/2,$a.ByHeight,i,0,0).from,r.lineAt(m+d+1e3/2,$a.ByHeight,i,0,0).to)}}return l}mapViewport(e,n){let a=n.mapPos(e.from,-1),r=n.mapPos(e.to,1);return new q2(this.heightMap.lineAt(a,$a.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,$a.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:n},a=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,$a.ByPos,this.heightOracle,0,0),{bottom:i}=this.heightMap.lineAt(n,$a.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:s}=this;return(e==0||r<=o-Math.max(10,Math.min(-a,250)))&&(n==this.state.doc.length||i>=s+Math.max(10,Math.min(a,250)))&&r>o-2*1e3&&i<s+2*1e3}mapLineGaps(e,n){if(!e.length||n.empty)return e;let a=[];for(let r of e)n.touchesRange(r.from,r.to)||a.push(new yL(n.mapPos(r.from),n.mapPos(r.to),r.size,r.displaySize));return a}ensureLineGaps(e,n){let a=this.heightOracle.lineWrapping,r=a?1e4:2e3,i=r>>1,o=r<<1;if(this.defaultTextDirection!=Ra.LTR&&!a)return[];let s=[],l=(d,p,m,A)=>{if(p-d<i)return;let g=this.state.selection.main,h=[g.from];g.empty||h.push(g.to);for(let b of h)if(b>d&&b<p){l(d,b-10,m,A),l(b+10,p,m,A);return}let f=Tst(e,b=>b.from>=m.from&&b.to<=m.to&&Math.abs(b.from-d)<i&&Math.abs(b.to-p)<i&&!h.some(y=>b.from<y&&b.to>y));if(!f){if(p<m.to&&n&&a&&n.visibleRanges.some(w=>w.from<=p&&w.to>=p)){let w=n.moveToLineBoundary(lt.cursor(p),!1,!0).head;w>d&&(p=w)}let b=this.gapSize(m,d,p,A),y=a||b<2e6?b:2e6;f=new yL(d,p,b,y)}s.push(f)},u=d=>{if(d.length<o||d.type!=$o.Text)return;let p=Sst(d.from,d.to,this.stateDeco);if(p.total<o)return;let m=this.scrollTarget?this.scrollTarget.range.head:null,A,g;if(a){let h=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,f,b;if(m!=null){let y=H2(p,m),w=((this.visibleBottom-this.visibleTop)/2+h)/d.height;f=y-w,b=y+w}else f=(this.visibleTop-d.top-h)/d.height,b=(this.visibleBottom-d.top+h)/d.height;A=z2(p,f),g=z2(p,b)}else{let h=p.total*this.heightOracle.charWidth,f=r*this.heightOracle.charWidth,b=0;if(h>2e6)for(let x of e)x.from>=d.from&&x.from<d.to&&x.size!=x.displaySize&&x.from*this.heightOracle.charWidth+b<this.pixelViewport.left&&(b=x.size-x.displaySize);let y=this.pixelViewport.left+b,w=this.pixelViewport.right+b,k,C;if(m!=null){let x=H2(p,m),_=((w-y)/2+f)/h;k=x-_,C=x+_}else k=(y-f)/h,C=(w+f)/h;A=z2(p,k),g=z2(p,C)}A>d.from&&l(d.from,A,d,p),g<d.to&&l(g,d.to,d,p)};for(let d of this.viewportLines)Array.isArray(d.type)?d.type.forEach(u):u(d);return s}gapSize(e,n,a,r){let i=H2(r,a)-H2(r,n);return this.heightOracle.lineWrapping?e.height*i:r.total*this.heightOracle.charWidth*i}updateLineGaps(e){yL.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=ln.set(e.map(n=>n.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let a=[];ta.spans(n,this.viewport.from,this.viewport.to,{span(i,o){a.push({from:i,to:o})},point(){}},20);let r=0;if(a.length!=this.visibleRanges.length)r=12;else for(let i=0;i<a.length&&!(r&8);i++){let o=this.visibleRanges[i],s=a[i];(o.from!=s.from||o.to!=s.to)&&(r|=4,e&&e.mapPos(o.from,-1)==s.from&&e.mapPos(o.to,1)==s.to||(r|=8))}return this.visibleRanges=a,r}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||D1(this.heightMap.lineAt(e,$a.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(n=>n.top<=e&&n.bottom>=e)||D1(this.heightMap.lineAt(this.scaler.fromDOM(e),$a.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return D1(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class q2{constructor(e,n){this.from=e,this.to=n}}function Sst(t,e,n){let a=[],r=t,i=0;return ta.spans(n,t,e,{span(){},point(o,s){o>r&&(a.push({from:r,to:o}),i+=o-r),r=s}},20),r<e&&(a.push({from:r,to:e}),i+=e-r),{total:i,ranges:a}}function z2({total:t,ranges:e},n){if(n<=0)return e[0].from;if(n>=1)return e[e.length-1].to;let a=Math.floor(t*n);for(let r=0;;r++){let{from:i,to:o}=e[r],s=o-i;if(a<=s)return i+a;a-=s}}function H2(t,e){let n=0;for(let{from:a,to:r}of t.ranges){if(e<=r){n+=e-a;break}n+=r-a}return n/t.total}function Tst(t,e){for(let n of t)if(e(n))return n}const zse={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};class wL{constructor(e,n,a){let r=0,i=0,o=0;this.viewports=a.map(({from:s,to:l})=>{let u=n.lineAt(s,$a.ByPos,e,0,0).top,d=n.lineAt(l,$a.ByPos,e,0,0).bottom;return r+=d-u,{from:s,to:l,top:u,bottom:d,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(n.height-r);for(let s of this.viewports)s.domTop=o+(s.top-i)*this.scale,o=s.domBottom=s.domTop+(s.bottom-s.top),i=s.bottom}toDOM(e){for(let n=0,a=0,r=0;;n++){let i=n<this.viewports.length?this.viewports[n]:null;if(!i||e<i.top)return r+(e-a)*this.scale;if(e<=i.bottom)return i.domTop+(e-i.top);a=i.bottom,r=i.domBottom}}fromDOM(e){for(let n=0,a=0,r=0;;n++){let i=n<this.viewports.length?this.viewports[n]:null;if(!i||e<i.domTop)return a+(e-r)/this.scale;if(e<=i.domBottom)return i.top+(e-i.domTop);a=i.bottom,r=i.domBottom}}eq(e){return e instanceof wL?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((n,a)=>n.from==e.viewports[a].from&&n.to==e.viewports[a].to):!1}}function D1(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),a=e.toDOM(t.bottom);return new mu(t.from,t.length,n,a-n,Array.isArray(t._content)?t._content.map(r=>D1(r,e)):t._content)}const U2=Ht.define({combine:t=>t.join(" ")}),kL=Ht.define({combine:t=>t.indexOf(!0)>-1}),vL=nm.newName(),Hse=nm.newName(),Use=nm.newName(),Yse={"&light":"."+Hse,"&dark":"."+Use};function CL(t,e,n){return new nm(e,{finish(a){return/&/.test(a)?a.replace(/&\w*/,r=>{if(r=="&")return t;if(!n||!n[r])throw new RangeError(`Unsupported selector: ${r}`);return n[r]}):t+" "+a}})}const Fst=CL("."+vL,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Yse),Lst={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},_L=Ot.ie&&Ot.ie_version<=11;class Nst{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new fot,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(n=>{for(let a of n)this.queue.push(a);(Ot.ie&&Ot.ie_version<=11||Ot.ios&&e.composing)&&n.some(a=>a.type=="childList"&&a.removedNodes.length||a.type=="characterData"&&a.oldValue.length>a.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Ot.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Ot.chrome&&Ot.chrome_version<126)&&(this.editContext=new Rst(e),e.state.facet(Dd)&&(e.contentDOM.editContext=this.editContext.editContext)),_L&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(n=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(n=>{n.length>0&&n[n.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((n,a)=>n!=e[a]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:a}=this,r=this.selectionRange;if(a.state.facet(Dd)?a.root.activeElement!=this.dom:!S2(this.dom,r))return;let i=r.anchorNode&&a.docView.nearest(r.anchorNode);if(i&&i.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Ot.ie&&Ot.ie_version<=11||Ot.android&&Ot.chrome)&&!a.state.selection.main.empty&&r.focusNode&&y1(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=b1(e.root);if(!n)return!1;let a=Ot.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&Mst(this.view,n)||n;if(!a||this.selectionRange.eq(a))return!1;let r=S2(this.dom,a);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&yot(this.dom,a)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(a),r&&(this.selectionChanged=!0),!0)}setSelectionRange(e,n){this.selectionRange.set(e.node,e.offset,n.node,n.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,n=null;for(let a=this.dom;a;)if(a.nodeType==1)!n&&e<this.scrollTargets.length&&this.scrollTargets[e]==a?e++:n||(n=this.scrollTargets.slice(0,e)),n&&n.push(a),a=a.assignedSlot||a.parentNode;else if(a.nodeType==11)a=a.host;else break;if(e<this.scrollTargets.length&&!n&&(n=this.scrollTargets.slice(0,e)),n){for(let a of this.scrollTargets)a.removeEventListener("scroll",this.onScroll);for(let a of this.scrollTargets=n)a.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,Lst),_L&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),_L&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,n){var a;if(!this.delayedAndroidKey){let r=()=>{let i=this.delayedAndroidKey;i&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=i.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&i.force&&ub(this.dom,i.key,i.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange<Date.now()-50||!!(!((a=this.delayedAndroidKey)===null||a===void 0)&&a.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let n=-1,a=-1,r=!1;for(let i of e){let o=this.readMutation(i);o&&(o.typeOver&&(r=!0),n==-1?{from:n,to:a}=o:(n=Math.min(o.from,n),a=Math.max(o.to,a)))}return{from:n,to:a,typeOver:r}}readChange(){let{from:e,to:n,typeOver:a}=this.processRecords(),r=this.selectionChanged&&S2(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let i=new est(this.view,e,n,a);return this.view.docView.domChanged={newSel:i.newSel?i.newSel.main:null},i}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let a=this.view.state,r=wse(this.view,n);return this.view.state==a&&(n.domChanged||n.newSel&&!n.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),r}readMutation(e){let n=this.view.docView.nearest(e.target);if(!n||n.ignoreMutation(e))return null;if(n.markDirty(e.type=="attributes"),e.type=="attributes"&&(n.flags|=4),e.type=="childList"){let a=Wse(n,e.previousSibling||e.target.previousSibling,-1),r=Wse(n,e.nextSibling||e.target.nextSibling,1);return{from:a?n.posAfter(a):n.posAtStart,to:r?n.posBefore(r):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(Dd)!=e.state.facet(Dd)&&(e.view.contentDOM.editContext=e.state.facet(Dd)?this.editContext.editContext:null))}destroy(){var e,n,a;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(a=this.resizeScroll)===null||a===void 0||a.disconnect();for(let r of this.scrollTargets)r.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function Wse(t,e,n){for(;e;){let a=va.get(e);if(a&&a.parent==t)return a;let r=e.parentNode;e=r!=t.dom?r:n>0?e.nextSibling:e.previousSibling}return null}function Kse(t,e){let n=e.startContainer,a=e.startOffset,r=e.endContainer,i=e.endOffset,o=t.docView.domAtPos(t.state.selection.main.anchor);return y1(o.node,o.offset,r,i)&&([n,a,r,i]=[r,i,n,a]),{anchorNode:n,anchorOffset:a,focusNode:r,focusOffset:i}}function Mst(t,e){if(e.getComposedRanges){let r=e.getComposedRanges(t.root)[0];if(r)return Kse(t,r)}let n=null;function a(r){r.preventDefault(),r.stopImmediatePropagation(),n=r.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",a,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",a,!0),n?Kse(t,n):null}class Rst{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=a=>{let r=e.state.selection.main,{anchor:i,head:o}=r,s=this.toEditorPos(a.updateRangeStart),l=this.toEditorPos(a.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:a.updateRangeStart,editorBase:s,drifted:!1});let u=l-s>a.text.length;s==this.from&&i<this.from?s=i:l==this.to&&i>this.to&&(l=i);let d=kse(e.state.sliceDoc(s,l),a.text,(u?r.from:r.to)-s,u?"end":null);if(!d){let m=lt.single(this.toEditorPos(a.selectionStart),this.toEditorPos(a.selectionEnd));m.main.eq(r)||e.dispatch({selection:m,userEvent:"select"});return}let p={from:d.from+s,to:d.toA+s,insert:ea.of(a.text.slice(d.from,d.toB).split(`
1350
1350
  `))};if((Ot.mac||Ot.android)&&p.from==o-1&&/^\. ?$/.test(a.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(p={from:s,to:l,insert:ea.of([a.text.replace("."," ")])}),this.pendingContextChange=p,!e.state.readOnly){let m=this.to-this.from+(p.to-p.from+p.insert.length);hL(e,p,lt.single(this.toEditorPos(a.selectionStart,m),this.toEditorPos(a.selectionEnd,m)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),p.from<p.to&&!p.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,a.updateRangeStart-1),Math.min(n.text.length,a.updateRangeStart+1)))&&this.handlers.compositionend(a)},this.handlers.characterboundsupdate=a=>{let r=[],i=null;for(let o=this.toEditorPos(a.rangeStart),s=this.toEditorPos(a.rangeEnd);o<s;o++){let l=e.coordsForChar(o);i=l&&new DOMRect(l.left,l.top,l.right-l.left,l.bottom-l.top)||i||new DOMRect,r.push(i)}n.updateCharacterBounds(a.rangeStart,r)},this.handlers.textformatupdate=a=>{let r=[];for(let i of a.getTextFormats()){let o=i.underlineStyle,s=i.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(s)){let l=this.toEditorPos(i.rangeStart),u=this.toEditorPos(i.rangeEnd);if(l<u){let d=`text-decoration: underline ${/^[a-z]/.test(o)?o+" ":o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${/thin/i.test(s)?1:2}px`;r.push(ln.mark({attributes:{style:d}}).range(l,u))}}}e.dispatch({effects:ase.of(ln.set(r))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:a}=this.composing;this.composing=null,a&&this.reset(e.state)}};for(let a in this.handlers)n.addEventListener(a,this.handlers[a]);this.measureReq={read:a=>{this.editContext.updateControlBounds(a.contentDOM.getBoundingClientRect());let r=b1(a.root);r&&r.rangeCount&&this.editContext.updateSelectionBounds(r.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,a=!1,r=this.pendingContextChange;return e.changes.iterChanges((i,o,s,l,u)=>{if(a)return;let d=u.length-(o-i);if(r&&o>=r.to)if(r.from==i&&r.to==o&&r.insert.eq(u)){r=this.pendingContextChange=null,n+=d,this.to+=d;return}else r=null,this.revertPending(e.state);if(i+=n,o+=n,o<=this.from)this.from+=d,this.to+=d;else if(i<this.to){if(i<this.from||o>this.to||this.to-this.from+u.length>3e4){a=!0;return}this.editContext.updateText(this.toContextPos(i),this.toContextPos(o),u.toString()),this.to+=d}n+=d}),r&&!a&&this.revertPending(e.state),!a}update(e){let n=this.pendingContextChange,a=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(a.from,a.to)&&e.transactions.some(r=>!r.isUserEvent("input.type")&&r.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,a=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),r=this.toContextPos(n.head);(this.editContext.selectionStart!=a||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(a,r)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to<e.doc.length&&this.to-n<500||this.to-this.from>1e4*3)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let a=this.composing;return a&&a.drifted?a.editorBase+(e-a.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class jt{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var n;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:a}=e;this.dispatchTransactions=e.dispatchTransactions||a&&(r=>r.forEach(i=>a(i,this)))||(r=>this.update(r)),this.dispatch=this.dispatch.bind(this),this._root=e.root||bot(e.parent)||document,this.viewState=new qse(e.state||Hn.create(e)),e.scrollTo&&e.scrollTo.is(M2)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Ab).map(r=>new lL(r));for(let r of this.plugins)r.update(this);this.observer=new Nst(this),this.inputState=new rst(this),this.inputState.ensureHandlers(this.plugins),this.docView=new lse(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>this.requestMeasure())}dispatch(...e){let n=e.length==1&&e[0]instanceof ni?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,a=!1,r,i=this.state;for(let m of e){if(m.startState!=i)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");i=m.state}if(this.destroyed){this.viewState.state=i;return}let o=this.hasFocus,s=0,l=null;e.some(m=>m.annotation(Nse))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=Mse(i,o),l||(s=1));let u=this.observer.delayedAndroidKey,d=null;if(u?(this.observer.clearDelayedAndroidKey(),d=this.observer.readChange(),(d&&!this.state.doc.eq(i.doc)||!this.state.selection.eq(i.selection))&&(d=null)):this.observer.clear(),i.facet(Hn.phrases)!=this.state.facet(Hn.phrases))return this.setState(i);r=R2.create(this,i,e),r.flags|=s;let p=this.viewState.scrollTarget;try{this.updateState=2;for(let m of e){if(p&&(p=p.map(m.changes)),m.scrollIntoView){let{main:A}=m.state.selection;p=new mb(A.empty?A:lt.cursor(A.head,A.head>A.anchor?-1:1))}for(let A of m.effects)A.is(M2)&&(p=A.value.clip(this.state))}this.viewState.update(r,p),this.bidiCache=Y2.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),n=this.docView.update(r),this.state.facet(E1)!=this.styleModules&&this.mountStyles(),a=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(m=>m.isUserEvent("select.pointer")))}finally{this.updateState=0}if(r.startState.facet(U2)!=r.state.facet(U2)&&(this.viewState.mustMeasureContent=!0),(n||a||p||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!r.empty)for(let m of this.state.facet(oL))try{m(r)}catch(A){As(this.state,A,"update listener")}(l||d)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),d&&!wse(this,d)&&u.force&&ub(this.contentDOM,u.key,u.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let n=this.hasFocus;try{for(let a of this.plugins)a.destroy(this);this.viewState=new qse(e),this.plugins=e.facet(Ab).map(a=>new lL(a)),this.pluginMap.clear();for(let a of this.plugins)a.update(this);this.docView.destroy(),this.docView=new lse(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(Ab),a=e.state.facet(Ab);if(n!=a){let r=[];for(let i of a){let o=n.indexOf(i);if(o<0)r.push(new lL(i));else{let s=this.plugins[o];s.mustUpdate=e,r.push(s)}}for(let i of this.plugins)i.mustUpdate!=e&&i.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let r of this.plugins)r.mustUpdate=e;for(let r=0;r<this.plugins.length;r++)this.plugins[r].update(this);n!=a&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let n=e.value;if(n&&n.docViewUpdate)try{n.docViewUpdate(this)}catch(a){As(this.state,a,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,a=this.scrollDOM,r=a.scrollTop*this.scaleY,{scrollAnchorPos:i,scrollAnchorHeight:o}=this.viewState;Math.abs(r-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let s=0;;s++){if(o<0)if(Soe(a))i=-1,o=this.viewState.heightMap.height;else{let A=this.viewState.scrollAnchorAt(r);i=A.from,o=A.top}this.updateState=1;let l=this.viewState.measure(this);if(!l&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(s>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let u=[];l&4||([this.measureRequests,u]=[u,this.measureRequests]);let d=u.map(A=>{try{return A.read(this)}catch(g){return As(this.state,g),Zse}}),p=R2.create(this,this.state,[]),m=!1;p.flags|=l,n?n.flags|=l:n=p,this.updateState=2,p.empty||(this.updatePlugins(p),this.inputState.update(p),this.updateAttrs(),m=this.docView.update(p),m&&this.docViewUpdate());for(let A=0;A<u.length;A++)if(d[A]!=Zse)try{let g=u[A];g.write&&g.write(d[A],this)}catch(g){As(this.state,g)}if(m&&this.docView.updateSelection(!0),!p.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let g=(i<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(i).top)-o;if(g>1||g<-1){r=r+g,a.scrollTop=r/this.scaleY,o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let s of this.state.facet(oL))s(n)}get themeClasses(){return vL+" "+(this.state.facet(kL)?Use:Hse)+" "+this.state.facet(U2)}updateAttrs(){let e=Vse(this,rse,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Dd)?"true":"false",class:"cm-content",style:`${Ot.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),Vse(this,uL,n);let a=this.observer.ignore(()=>{let r=eL(this.contentDOM,this.contentAttrs,n),i=eL(this.dom,this.editorAttrs,e);return r||i});return this.editorAttrs=e,this.contentAttrs=n,a}showAnnouncements(e){let n=!0;for(let a of e)for(let r of a.effects)if(r.is(jt.announce)){n&&(this.announceDOM.textContent=""),n=!1;let i=this.announceDOM.appendChild(document.createElement("div"));i.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(E1);let e=this.state.facet(jt.cspNonce);nm.mount(this.root,this.styleModules.concat(Fst).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let n=0;n<this.measureRequests.length;n++)if(this.measureRequests[n].key===e.key){this.measureRequests[n]=e;return}}this.measureRequests.push(e)}}plugin(e){let n=this.pluginMap.get(e);return(n===void 0||n&&n.plugin!=e)&&this.pluginMap.set(e,n=this.plugins.find(a=>a.plugin==e)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,n,a){return gL(this,e,fse(this,e,n,a))}moveByGroup(e,n){return gL(this,e,fse(this,e,n,a=>Kot(this,e.head,a)))}visualLineSide(e,n){let a=this.bidiSpans(e),r=this.textDirectionAt(e.from),i=a[n?a.length-1:0];return lt.cursor(i.side(n,r)+e.from,i.forward(!n,r)?1:-1)}moveToLineBoundary(e,n,a=!0){return Wot(this,e,n,a)}moveVertically(e,n,a){return gL(this,e,Zot(this,e,n,a))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){return this.readMeasured(),Ase(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let a=this.docView.coordsAt(e,n);if(!a||a.left==a.right)return a;let r=this.state.doc.lineAt(e),i=this.bidiSpans(r),o=i[om.find(i,e-r.from,-1,n)];return w1(a,o.dir==Ra.LTR==n>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(ese)||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>$st)return Uoe(e.length);let n=this.textDirectionAt(e.from),a;for(let i of this.bidiCache)if(i.from==e.from&&i.dir==n&&(i.fresh||Hoe(i.isolates,a=sse(this,e))))return i.order;a||(a=sse(this,e));let r=Tot(e.text,n,a);return this.bidiCache.push(new Y2(e.from,e.to,n,a,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Ot.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Ioe(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,n={}){return M2.of(new mb(typeof e=="number"?lt.cursor(e):e,n.y,n.x,n.yMargin,n.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,a=this.viewState.scrollAnchorAt(e);return M2.of(new mb(lt.cursor(a.from),"start","start",a.top-e,n,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return Cr.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return Cr.define(()=>({}),{eventObservers:e})}static theme(e,n){let a=nm.newName(),r=[U2.of(a),E1.of(CL(`.${a}`,e))];return n&&n.dark&&r.push(kL.of(!0)),r}static baseTheme(e){return cg.lowest(E1.of(CL("."+vL,e,Yse)))}static findFromDOM(e){var n;let a=e.querySelector(".cm-content"),r=a&&va.get(a)||va.get(e);return((n=r==null?void 0:r.rootView)===null||n===void 0?void 0:n.view)||null}}jt.styleModule=E1,jt.inputHandler=Joe,jt.clipboardInputFilter=sL,jt.clipboardOutputFilter=cL,jt.scrollHandler=nse,jt.focusChangeEffect=Xoe,jt.perLineTextDirection=ese,jt.exceptionSink=Voe,jt.updateListener=oL,jt.editable=Dd,jt.mouseSelectionStyle=Zoe,jt.dragMovesSelection=Koe,jt.clickAddsSelectionRange=Woe,jt.decorations=_1,jt.outerDecorations=ise,jt.atomicRanges=x1,jt.bidiIsolatedRanges=ose,jt.scrollMargins=cse,jt.darkTheme=kL,jt.cspNonce=Ht.define({combine:t=>t.length?t[0]:""}),jt.contentAttributes=uL,jt.editorAttributes=rse,jt.lineWrapping=jt.contentAttributes.of({class:"cm-lineWrapping"}),jt.announce=Bn.define();const $st=4096,Zse={};class Y2{constructor(e,n,a,r,i,o){this.from=e,this.to=n,this.dir=a,this.isolates=r,this.fresh=i,this.order=o}static update(e,n){if(n.empty&&!e.some(i=>i.fresh))return e;let a=[],r=e.length?e[e.length-1].dir:Ra.LTR;for(let i=Math.max(0,e.length-10);i<e.length;i++){let o=e[i];o.dir==r&&!n.touchesRange(o.from,o.to)&&a.push(new Y2(n.mapPos(o.from,1),n.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return a}}function Vse(t,e,n){for(let a=t.state.facet(e),r=a.length-1;r>=0;r--){let i=a[r],o=typeof i=="function"?i(t):i;o&&XF(o,n)}return n}const Pst=Ot.mac?"mac":Ot.windows?"win":Ot.linux?"linux":"key";function Ost(t,e){const n=t.split(/-(?!$)/);let a=n[n.length-1];a=="Space"&&(a=" ");let r,i,o,s;for(let l=0;l<n.length-1;++l){const u=n[l];if(/^(cmd|meta|m)$/i.test(u))s=!0;else if(/^a(lt)?$/i.test(u))r=!0;else if(/^(c|ctrl|control)$/i.test(u))i=!0;else if(/^s(hift)?$/i.test(u))o=!0;else if(/^mod$/i.test(u))e=="mac"?s=!0:i=!0;else throw new Error("Unrecognized modifier name: "+u)}return r&&(a="Alt-"+a),i&&(a="Ctrl-"+a),s&&(a="Meta-"+a),o&&(a="Shift-"+a),a}function W2(t,e,n){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n!==!1&&e.shiftKey&&(t="Shift-"+t),t}const jst=cg.default(jt.domEventHandlers({keydown(t,e){return ece(Xse(e.state),t,e,"editor")}})),K2=Ht.define({enables:jst}),Jse=new WeakMap;function Xse(t){let e=t.facet(K2),n=Jse.get(e);return n||Jse.set(e,n=zst(e.reduce((a,r)=>a.concat(r),[]))),n}function Gst(t,e,n){return ece(Xse(t.state),e,t,n)}let sm=null;const qst=4e3;function zst(t,e=Pst){let n=Object.create(null),a=Object.create(null),r=(o,s)=>{let l=a[o];if(l==null)a[o]=s;else if(l!=s)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},i=(o,s,l,u,d)=>{var p,m;let A=n[o]||(n[o]=Object.create(null)),g=s.split(/ (?!$)/).map(b=>Ost(b,e));for(let b=1;b<g.length;b++){let y=g.slice(0,b).join(" ");r(y,!0),A[y]||(A[y]={preventDefault:!0,stopPropagation:!1,run:[w=>{let k=sm={view:w,prefix:y,scope:o};return setTimeout(()=>{sm==k&&(sm=null)},qst),!0}]})}let h=g.join(" ");r(h,!1);let f=A[h]||(A[h]={preventDefault:!1,stopPropagation:!1,run:((m=(p=A._any)===null||p===void 0?void 0:p.run)===null||m===void 0?void 0:m.slice())||[]});l&&f.run.push(l),u&&(f.preventDefault=!0),d&&(f.stopPropagation=!0)};for(let o of t){let s=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let u of s){let d=n[u]||(n[u]=Object.create(null));d._any||(d._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:p}=o;for(let m in d)d[m].run.push(A=>p(A,xL))}let l=o[e]||o.key;if(l)for(let u of s)i(u,l,o.run,o.preventDefault,o.stopPropagation),o.shift&&i(u,"Shift-"+l,o.shift,o.preventDefault,o.stopPropagation)}return n}let xL=null;function ece(t,e,n,a){xL=e;let r=mot(e),i=ms(r,0),o=su(i)==r.length&&r!=" ",s="",l=!1,u=!1,d=!1;sm&&sm.view==n&&sm.scope==a&&(s=sm.prefix+" ",_se.indexOf(e.keyCode)<0&&(u=!0,sm=null));let p=new Set,m=f=>{if(f){for(let b of f.run)if(!p.has(b)&&(p.add(b),b(n)))return f.stopPropagation&&(d=!0),!0;f.preventDefault&&(f.stopPropagation&&(d=!0),u=!0)}return!1},A=t[a],g,h;return A&&(m(A[s+W2(r,e,!o)])?l=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Ot.windows&&e.ctrlKey&&e.altKey)&&!(Ot.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(g=am[e.keyCode])&&g!=r?(m(A[s+W2(g,e,!0)])||e.shiftKey&&(h=f1[e.keyCode])!=r&&h!=g&&m(A[s+W2(h,e,!1)]))&&(l=!0):o&&e.shiftKey&&m(A[s+W2(r,e,!0)])&&(l=!0),!l&&m(A._any)&&(l=!0)),u&&(l=!0),l&&d&&e.stopPropagation(),xL=null,l}class Q1{constructor(e,n,a,r,i){this.className=e,this.left=n,this.top=a,this.width=r,this.height=i}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,n){return n.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,n,a){if(a.empty){let r=e.coordsAtPos(a.head,a.assoc||1);if(!r)return[];let i=tce(e);return[new Q1(n,r.left-i.left,r.top-i.top,null,r.bottom-r.top)]}else return Hst(e,n,a)}}function tce(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==Ra.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function nce(t,e,n,a){let r=t.coordsAtPos(e,n*2);if(!r)return a;let i=t.dom.getBoundingClientRect(),o=(r.top+r.bottom)/2,s=t.posAtCoords({x:i.left+1,y:o}),l=t.posAtCoords({x:i.right-1,y:o});return s==null||l==null?a:{from:Math.max(a.from,Math.min(s,l)),to:Math.min(a.to,Math.max(s,l))}}function Hst(t,e,n){if(n.to<=t.viewport.from||n.from>=t.viewport.to)return[];let a=Math.max(n.from,t.viewport.from),r=Math.min(n.to,t.viewport.to),i=t.textDirection==Ra.LTR,o=t.contentDOM,s=o.getBoundingClientRect(),l=tce(t),u=o.querySelector(".cm-line"),d=u&&window.getComputedStyle(u),p=s.left+(d?parseInt(d.paddingLeft)+Math.min(0,parseInt(d.textIndent)):0),m=s.right-(d?parseInt(d.paddingRight):0),A=AL(t,a,1),g=AL(t,r,-1),h=A.type==$o.Text?A:null,f=g.type==$o.Text?g:null;if(h&&(t.lineWrapping||A.widgetLineBreaks)&&(h=nce(t,a,1,h)),f&&(t.lineWrapping||g.widgetLineBreaks)&&(f=nce(t,r,-1,f)),h&&f&&h.from==f.from&&h.to==f.to)return y(w(n.from,n.to,h));{let C=h?w(n.from,null,h):k(A,!1),x=f?w(null,n.to,f):k(g,!0),_=[];return(h||A).to<(f||g).from-(h&&f?1:0)||A.widgetLineBreaks>1&&C.bottom+t.defaultLineHeight/2<x.top?_.push(b(p,C.bottom,m,x.top)):C.bottom<x.top&&t.elementAtHeight((C.bottom+x.top)/2).type==$o.Text&&(C.bottom=x.top=(C.bottom+x.top)/2),y(C).concat(_).concat(y(x))}function b(C,x,_,E){return new Q1(e,C-l.left,x-l.top,_-C,E-x)}function y({top:C,bottom:x,horizontal:_}){let E=[];for(let D=0;D<_.length;D+=2)E.push(b(_[D],C,_[D+1],x));return E}function w(C,x,_){let E=1e9,D=-1e9,Q=[];function B(I,S,M,L,F){let R=t.coordsAtPos(I,I==_.to?-2:2),$=t.coordsAtPos(M,M==_.from?2:-2);!R||!$||(E=Math.min(R.top,$.top,E),D=Math.max(R.bottom,$.bottom,D),F==Ra.LTR?Q.push(i&&S?p:R.left,i&&L?m:$.right):Q.push(!i&&L?p:$.left,!i&&S?m:R.right))}let T=C??_.from,N=x??_.to;for(let I of t.visibleRanges)if(I.to>T&&I.from<N)for(let S=Math.max(I.from,T),M=Math.min(I.to,N);;){let L=t.state.doc.lineAt(S);for(let F of t.bidiSpans(L)){let R=F.from+L.from,$=F.to+L.from;if(R>=M)break;$>S&&B(Math.max(R,S),C==null&&R<=T,Math.min($,M),x==null&&$>=N,F.dir)}if(S=L.to+1,S>=M)break}return Q.length==0&&B(T,C==null,N,x==null,t.textDirection),{top:E,bottom:D,horizontal:Q}}function k(C,x){let _=s.top+(x?C.top:C.bottom);return{top:_,bottom:_,horizontal:[]}}}function Ust(t,e){return t.constructor==e.constructor&&t.eq(e)}class Yst{constructor(e,n){this.view=e,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,e)}update(e){e.startState.facet(Z2)!=e.state.facet(Z2)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let n=0,a=e.facet(Z2);for(;n<a.length&&a[n]!=this.layer;)n++;this.dom.style.zIndex=String((this.layer.above?150:-1)-n)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:n}=this.view;(e!=this.scaleX||n!=this.scaleY)&&(this.scaleX=e,this.scaleY=n,this.dom.style.transform=`scale(${1/e}, ${1/n})`)}draw(e){if(e.length!=this.drawn.length||e.some((n,a)=>!Ust(n,this.drawn[a]))){let n=this.dom.firstChild,a=0;for(let r of e)r.update&&n&&r.constructor&&this.drawn[a].constructor&&r.update(n,this.drawn[a])?(n=n.nextSibling,a++):this.dom.insertBefore(r.draw(),n);for(;n;){let r=n.nextSibling;n.remove(),n=r}this.drawn=e,Ot.safari&&Ot.safari_version>=26&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const Z2=Ht.define();function ace(t){return[Cr.define(e=>new Yst(e,t)),Z2.of(t)]}const S1=Ht.define({combine(t){return uu(t,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,n)=>Math.min(e,n),drawRangeCursor:(e,n)=>e||n})}});function Wst(t={}){return[S1.of(t),Kst,Zst,Vst,tse.of(!0)]}function rce(t){return t.startState.facet(S1)!=t.state.facet(S1)}const Kst=ace({above:!0,markers(t){let{state:e}=t,n=e.facet(S1),a=[];for(let r of e.selection.ranges){let i=r==e.selection.main;if(r.empty||n.drawRangeCursor){let o=i?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",s=r.empty?r:lt.cursor(r.head,r.head>r.anchor?-1:1);for(let l of Q1.forRange(t,o,s))a.push(l)}}return a},update(t,e){t.transactions.some(a=>a.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=rce(t);return n&&ice(t.state,e),t.docChanged||t.selectionSet||n},mount(t,e){ice(e.state,t)},class:"cm-cursorLayer"});function ice(t,e){e.style.animationDuration=t.facet(S1).cursorBlinkRate+"ms"}const Zst=ace({above:!1,markers(t){return t.state.selection.ranges.map(e=>e.empty?[]:Q1.forRange(t,"cm-selectionBackground",e)).reduce((e,n)=>e.concat(n))},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||rce(t)},class:"cm-selectionLayer"}),Vst=cg.highest(jt.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),oce=Bn.define({map(t,e){return t==null?null:e.mapPos(t)}}),T1=Mi.define({create(){return null},update(t,e){return t!=null&&(t=e.changes.mapPos(t)),e.effects.reduce((n,a)=>a.is(oce)?a.value:n,t)}}),Jst=Cr.fromClass(class{constructor(t){this.view=t,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(t){var e;let n=t.state.field(T1);n==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"),(t.startState.field(T1)!=n||t.docChanged||t.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:t}=this,e=t.state.field(T1),n=e!=null&&t.coordsAtPos(e);if(!n)return null;let a=t.scrollDOM.getBoundingClientRect();return{left:n.left-a.left+t.scrollDOM.scrollLeft*t.scaleX,top:n.top-a.top+t.scrollDOM.scrollTop*t.scaleY,height:n.bottom-n.top}}drawCursor(t){if(this.cursor){let{scaleX:e,scaleY:n}=this.view;t?(this.cursor.style.left=t.left/e+"px",this.cursor.style.top=t.top/n+"px",this.cursor.style.height=t.height/n+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(t){this.view.state.field(T1)!=t&&this.view.dispatch({effects:oce.of(t)})}},{eventObservers:{dragover(t){this.setDropPos(this.view.posAtCoords({x:t.clientX,y:t.clientY}))},dragleave(t){(t.target==this.view.contentDOM||!this.view.contentDOM.contains(t.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function Xst(){return[T1,Jst]}function sce(t,e,n,a,r){e.lastIndex=0;for(let i=t.iterRange(n,a),o=n,s;!i.next().done;o+=i.value.length)if(!i.lineBreak)for(;s=e.exec(i.value);)r(o+s.index,s)}function ect(t,e){let n=t.visibleRanges;if(n.length==1&&n[0].from==t.viewport.from&&n[0].to==t.viewport.to)return n;let a=[];for(let{from:r,to:i}of n)r=Math.max(t.state.doc.lineAt(r).from,r-e),i=Math.min(t.state.doc.lineAt(i).to,i+e),a.length&&a[a.length-1].to>=r?a[a.length-1].to=i:a.push({from:r,to:i});return a}class tct{constructor(e){const{regexp:n,decoration:a,decorate:r,boundary:i,maxLength:o=1e3}=e;if(!n.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=n,r)this.addMatch=(s,l,u,d)=>r(d,u,u+s[0].length,s,l);else if(typeof a=="function")this.addMatch=(s,l,u,d)=>{let p=a(s,l,u);p&&d(u,u+s[0].length,p)};else if(a)this.addMatch=(s,l,u,d)=>d(u,u+s[0].length,a);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=i,this.maxLength=o}createDeco(e){let n=new xd,a=n.add.bind(n);for(let{from:r,to:i}of ect(e,this.maxLength))sce(e.state.doc,this.regexp,r,i,(o,s)=>this.addMatch(s,e,o,a));return n.finish()}updateDeco(e,n){let a=1e9,r=-1;return e.docChanged&&e.changes.iterChanges((i,o,s,l)=>{l>=e.view.viewport.from&&s<=e.view.viewport.to&&(a=Math.min(s,a),r=Math.max(l,r))}),e.viewportMoved||r-a>1e3?this.createDeco(e.view):r>-1?this.updateRange(e.view,n.map(e.changes),a,r):n}updateRange(e,n,a,r){for(let i of e.visibleRanges){let o=Math.max(i.from,a),s=Math.min(i.to,r);if(s>=o){let l=e.state.doc.lineAt(o),u=l.to<s?e.state.doc.lineAt(s):l,d=Math.max(i.from,l.from),p=Math.min(i.to,u.to);if(this.boundary){for(;o>l.from;o--)if(this.boundary.test(l.text[o-1-l.from])){d=o;break}for(;s<u.to;s++)if(this.boundary.test(u.text[s-u.from])){p=s;break}}let m=[],A,g=(h,f,b)=>m.push(b.range(h,f));if(l==u)for(this.regexp.lastIndex=d-l.from;(A=this.regexp.exec(l.text))&&A.index<p-l.from;)this.addMatch(A,e,A.index+l.from,g);else sce(e.state.doc,this.regexp,d,p,(h,f)=>this.addMatch(f,e,h,g));n=n.update({filterFrom:d,filterTo:p,filter:(h,f)=>h<d||f>p,add:m})}}return n}}const EL=/x/.unicode!=null?"gu":"g",nct=new RegExp(`[\0-\b
1351
1351
  --Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,EL),act={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let BL=null;function rct(){var t;if(BL==null&&typeof document<"u"&&document.body){let e=document.body.style;BL=((t=e.tabSize)!==null&&t!==void 0?t:e.MozTabSize)!=null}return BL||!1}const V2=Ht.define({combine(t){let e=uu(t,{render:null,specialChars:nct,addSpecialChars:null});return(e.replaceTabs=!rct())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,EL)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,EL)),e}});function ict(t={}){return[V2.of(t),oct()]}let cce=null;function oct(){return cce||(cce=Cr.fromClass(class{constructor(t){this.view=t,this.decorations=ln.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(t.state.facet(V2)),this.decorations=this.decorator.createDeco(t)}makeDecorator(t){return new tct({regexp:t.specialChars,decoration:(e,n,a)=>{let{doc:r}=n.state,i=ms(e[0],0);if(i==9){let o=r.lineAt(a),s=n.state.tabSize,l=cb(o.text,s,a-o.from);return ln.replace({widget:new uct((s-l%s)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[i]||(this.decorationCache[i]=ln.replace({widget:new lct(t,i)}))},boundary:t.replaceTabs?void 0:/[^]/})}update(t){let e=t.state.facet(V2);t.startState.facet(V2)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(t.view)):this.decorations=this.decorator.updateDeco(t,this.decorations)}},{decorations:t=>t.decorations}))}const sct="•";function cct(t){return t>=32?sct:t==10?"␤":String.fromCharCode(9216+t)}class lct extends Bd{constructor(e,n){super(),this.options=e,this.code=n}eq(e){return e.code==this.code}toDOM(e){let n=cct(this.code),a=e.state.phrase("Control character")+" "+(act[this.code]||"0x"+this.code.toString(16)),r=this.options.render&&this.options.render(this.code,a,n);if(r)return r;let i=document.createElement("span");return i.textContent=n,i.title=a,i.setAttribute("aria-label",a),i.className="cm-specialChar",i}ignoreEvent(){return!1}}class uct extends Bd{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 dct(){return mct}const pct=ln.line({class:"cm-activeLine"}),mct=Cr.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,n=[];for(let a of t.state.selection.ranges){let r=t.lineBlockAt(a.head);r.from>e&&(n.push(pct.range(r.from)),e=r.from)}return ln.set(n)}},{decorations:t=>t.decorations});class Act extends Bd{constructor(e){super(),this.content=e}toDOM(e){let n=document.createElement("span");return n.className="cm-placeholder",n.style.pointerEvents="none",n.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(e):this.content.cloneNode(!0)),n.setAttribute("aria-hidden","true"),n}coordsAt(e){let n=e.firstChild?lb(e.firstChild):[];if(!n.length)return null;let a=window.getComputedStyle(e.parentNode),r=w1(n[0],a.direction!="rtl"),i=parseInt(a.lineHeight);return r.bottom-r.top>i*1.5?{left:r.left,right:r.right,top:r.top,bottom:r.top+i}:r}ignoreEvent(){return!1}}function gct(t){let e=Cr.fromClass(class{constructor(n){this.view=n,this.placeholder=t?ln.set([ln.widget({widget:new Act(t),side:1}).range(0)]):ln.none}get decorations(){return this.view.state.doc.length?ln.none:this.placeholder}},{decorations:n=>n.decorations});return typeof t=="string"?[e,jt.contentAttributes.of({"aria-placeholder":t})]:e}const IL=2e3;function hct(t,e,n){let a=Math.min(e.line,n.line),r=Math.max(e.line,n.line),i=[];if(e.off>IL||n.off>IL||e.col<0||n.col<0){let o=Math.min(e.off,n.off),s=Math.max(e.off,n.off);for(let l=a;l<=r;l++){let u=t.doc.line(l);u.length<=s&&i.push(lt.range(u.from+o,u.to+s))}}else{let o=Math.min(e.col,n.col),s=Math.max(e.col,n.col);for(let l=a;l<=r;l++){let u=t.doc.line(l),d=GF(u.text,o,t.tabSize,!0);if(d<0)i.push(lt.cursor(u.to));else{let p=GF(u.text,s,t.tabSize);i.push(lt.range(u.from+d,u.from+p))}}}return i}function fct(t,e){let n=t.coordsAtPos(t.viewport.from);return n?Math.round(Math.abs((n.left-e)/t.defaultCharacterWidth)):-1}function lce(t,e){let n=t.posAtCoords({x:e.clientX,y:e.clientY},!1),a=t.state.doc.lineAt(n),r=n-a.from,i=r>IL?-1:r==a.length?fct(t,e.clientX):cb(a.text,t.state.tabSize,n-a.from);return{line:a.number,col:i,off:r}}function bct(t,e){let n=lce(t,e),a=t.state.selection;return n?{update(r){if(r.docChanged){let i=r.changes.mapPos(r.startState.doc.line(n.line).from),o=r.state.doc.lineAt(i);n={line:o.number,col:n.col,off:Math.min(n.off,o.length)},a=a.map(r.changes)}},get(r,i,o){let s=lce(t,r);if(!s)return a;let l=hct(t.state,n,s);return l.length?o?lt.create(l.concat(a.ranges)):lt.create(l):a}}:null}function yct(t){let e=n=>n.altKey&&n.button==0;return jt.mouseSelectionStyle.of((n,a)=>e(a)?bct(n,a):null)}const wct={Alt:[18,t=>!!t.altKey],Control:[17,t=>!!t.ctrlKey],Shift:[16,t=>!!t.shiftKey],Meta:[91,t=>!!t.metaKey]},kct={style:"cursor: crosshair"};function vct(t={}){let[e,n]=wct[t.key||"Alt"],a=Cr.fromClass(class{constructor(r){this.view=r,this.isDown=!1}set(r){this.isDown!=r&&(this.isDown=r,this.view.update([]))}},{eventObservers:{keydown(r){this.set(r.keyCode==e||n(r))},keyup(r){(r.keyCode==e||!n(r))&&this.set(!1)},mousemove(r){this.set(n(r))}}});return[a,jt.contentAttributes.of(r=>{var i;return!((i=r.plugin(a))===null||i===void 0)&&i.isDown?kct:null})]}const F1="-10000px";class uce{constructor(e,n,a,r){this.facet=n,this.createTooltipView=a,this.removeTooltipView=r,this.input=e.state.facet(n),this.tooltips=this.input.filter(o=>o);let i=null;this.tooltipViews=this.tooltips.map(o=>i=a(o,i))}update(e,n){var a;let r=e.state.facet(this.facet),i=r.filter(l=>l);if(r===this.input){for(let l of this.tooltipViews)l.update&&l.update(e);return!1}let o=[],s=n?[]:null;for(let l=0;l<i.length;l++){let u=i[l],d=-1;if(u){for(let p=0;p<this.tooltips.length;p++){let m=this.tooltips[p];m&&m.create==u.create&&(d=p)}if(d<0)o[l]=this.createTooltipView(u,l?o[l-1]:null),s&&(s[l]=!!u.above);else{let p=o[l]=this.tooltipViews[d];s&&(s[l]=n[d]),p.update&&p.update(e)}}}for(let l of this.tooltipViews)o.indexOf(l)<0&&(this.removeTooltipView(l),(a=l.destroy)===null||a===void 0||a.call(l));return n&&(s.forEach((l,u)=>n[u]=l),n.length=s.length),this.input=r,this.tooltips=i,this.tooltipViews=o,!0}}function Cct(t){let e=t.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const DL=Ht.define({combine:t=>{var e,n,a;return{position:Ot.ios?"absolute":((e=t.find(r=>r.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((n=t.find(r=>r.parent))===null||n===void 0?void 0:n.parent)||null,tooltipSpace:((a=t.find(r=>r.tooltipSpace))===null||a===void 0?void 0:a.tooltipSpace)||Cct}}}),dce=new WeakMap,QL=Cr.fromClass(class{constructor(t){this.view=t,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=t.state.facet(DL);this.position=e.position,this.parent=e.parent,this.classes=t.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new uce(t,SL,(n,a)=>this.createTooltip(n,a),n=>{this.resizeObserver&&this.resizeObserver.unobserve(n.dom),n.dom.remove()}),this.above=this.manager.tooltips.map(n=>!!n.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(n=>{Date.now()>this.lastTransaction-50&&n.length>0&&n[n.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),t.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let t of this.manager.tooltipViews)this.intersectionObserver.observe(t.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(t){t.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(t,this.above);e&&this.observeIntersection();let n=e||t.geometryChanged,a=t.state.facet(DL);if(a.position!=this.position&&!this.madeAbsolute){this.position=a.position;for(let r of this.manager.tooltipViews)r.dom.style.position=this.position;n=!0}if(a.parent!=this.parent){this.parent&&this.container.remove(),this.parent=a.parent,this.createContainer();for(let r of this.manager.tooltipViews)this.container.appendChild(r.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(t,e){let n=t.create(this.view),a=e?e.dom:null;if(n.dom.classList.add("cm-tooltip"),t.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let r=document.createElement("div");r.className="cm-tooltip-arrow",n.dom.appendChild(r)}return n.dom.style.position=this.position,n.dom.style.top=F1,n.dom.style.left="0px",this.container.insertBefore(n.dom,a),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var t,e,n;this.view.win.removeEventListener("resize",this.measureSoon);for(let a of this.manager.tooltipViews)a.dom.remove(),(t=a.destroy)===null||t===void 0||t.call(a);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(n=this.intersectionObserver)===null||n===void 0||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let t=1,e=1,n=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:i}=this.manager.tooltipViews[0];if(Ot.gecko)n=i.offsetParent!=this.container.ownerDocument.body;else if(i.style.top==F1&&i.style.left=="0px"){let o=i.getBoundingClientRect();n=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}}if(n||this.position=="absolute")if(this.parent){let i=this.parent.getBoundingClientRect();i.width&&i.height&&(t=i.width/this.parent.offsetWidth,e=i.height/this.parent.offsetHeight)}else({scaleX:t,scaleY:e}=this.view.viewState);let a=this.view.scrollDOM.getBoundingClientRect(),r=dL(this.view);return{visible:{left:a.left+r.left,top:a.top+r.top,right:a.right-r.right,bottom:a.bottom-r.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((i,o)=>{let s=this.manager.tooltipViews[o];return s.getCoords?s.getCoords(i.pos):this.view.coordsAtPos(i.pos)}),size:this.manager.tooltipViews.map(({dom:i})=>i.getBoundingClientRect()),space:this.view.state.facet(DL).tooltipSpace(this.view),scaleX:t,scaleY:e,makeAbsolute:n}}writeMeasure(t){var e;if(t.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let s of this.manager.tooltipViews)s.dom.style.position="absolute"}let{visible:n,space:a,scaleX:r,scaleY:i}=t,o=[];for(let s=0;s<this.manager.tooltips.length;s++){let l=this.manager.tooltips[s],u=this.manager.tooltipViews[s],{dom:d}=u,p=t.pos[s],m=t.size[s];if(!p||l.clip!==!1&&(p.bottom<=Math.max(n.top,a.top)||p.top>=Math.min(n.bottom,a.bottom)||p.right<Math.max(n.left,a.left)-.1||p.left>Math.min(n.right,a.right)+.1)){d.style.top=F1;continue}let A=l.arrow?u.dom.querySelector(".cm-tooltip-arrow"):null,g=A?7:0,h=m.right-m.left,f=(e=dce.get(u))!==null&&e!==void 0?e:m.bottom-m.top,b=u.offset||xct,y=this.view.textDirection==Ra.LTR,w=m.width>a.right-a.left?y?a.left:a.right-m.width:y?Math.max(a.left,Math.min(p.left-(A?14:0)+b.x,a.right-h)):Math.min(Math.max(a.left,p.left-h+(A?14:0)-b.x),a.right-h),k=this.above[s];!l.strictSide&&(k?p.top-f-g-b.y<a.top:p.bottom+f+g+b.y>a.bottom)&&k==a.bottom-p.bottom>p.top-a.top&&(k=this.above[s]=!k);let C=(k?p.top-a.top:a.bottom-p.bottom)-g;if(C<f&&u.resize!==!1){if(C<this.view.defaultLineHeight){d.style.top=F1;continue}dce.set(u,f),d.style.height=(f=C)/i+"px"}else d.style.height&&(d.style.height="");let x=k?p.top-f-g-b.y:p.bottom+g+b.y,_=w+h;if(u.overlap!==!0)for(let E of o)E.left<_&&E.right>w&&E.top<x+f&&E.bottom>x&&(x=k?E.top-f-2-g:E.bottom+g+2);if(this.position=="absolute"?(d.style.top=(x-t.parent.top)/i+"px",pce(d,(w-t.parent.left)/r)):(d.style.top=x/i+"px",pce(d,w/r)),A){let E=p.left+(y?b.x:-b.x)-(w+14-7);A.style.left=E/r+"px"}u.overlap!==!0&&o.push({left:w,top:x,right:_,bottom:x+f}),d.classList.toggle("cm-tooltip-above",k),d.classList.toggle("cm-tooltip-below",!k),u.positioned&&u.positioned(t.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let t of this.manager.tooltipViews)t.dom.style.top=F1}},{eventObservers:{scroll(){this.maybeMeasure()}}});function pce(t,e){let n=parseInt(t.style.left,10);(isNaN(n)||Math.abs(e-n)>1)&&(t.style.left=e+"px")}const _ct=jt.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),xct={x:0,y:0},SL=Ht.define({enables:[QL,_ct]}),J2=Ht.define({combine:t=>t.reduce((e,n)=>e.concat(n),[])});class X2{static create(e){return new X2(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new uce(e,J2,(n,a)=>this.createHostedView(n,a),n=>n.dom.remove())}createHostedView(e,n){let a=e.create(this.view);return a.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(a.dom,n?n.dom.nextSibling:this.dom.firstChild),this.mounted&&a.mount&&a.mount(this.view),a}mount(e){for(let n of this.manager.tooltipViews)n.mount&&n.mount(e);this.mounted=!0}positioned(e){for(let n of this.manager.tooltipViews)n.positioned&&n.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let n of this.manager.tooltipViews)(e=n.destroy)===null||e===void 0||e.call(n)}passProp(e){let n;for(let a of this.manager.tooltipViews){let r=a[e];if(r!==void 0){if(n===void 0)n=r;else if(n!==r)return}}return n}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const Ect=SL.compute([J2],t=>{let e=t.facet(J2);return e.length===0?null:{pos:Math.min(...e.map(n=>n.pos)),end:Math.max(...e.map(n=>{var a;return(a=n.end)!==null&&a!==void 0?a:n.pos})),create:X2.create,above:e[0].above,arrow:e.some(n=>n.arrow)}});class Bct{constructor(e,n,a,r,i){this.view=e,this.source=n,this.field=a,this.setHover=r,this.hoverTime=i,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:n}=this,a=e.docView.nearest(n.target);if(!a)return;let r,i=1;if(a instanceof rm)r=a.posAtStart;else{if(r=e.posAtCoords(n),r==null)return;let s=e.coordsAtPos(r);if(!s||n.y<s.top||n.y>s.bottom||n.x<s.left-e.defaultCharacterWidth||n.x>s.right+e.defaultCharacterWidth)return;let l=e.bidiSpans(e.state.doc.lineAt(r)).find(d=>d.from<=r&&d.to>=r),u=l&&l.dir==Ra.RTL?-1:1;i=n.x<s.left?-u:u}let o=this.source(e,r,i);if(o!=null&&o.then){let s=this.pending={pos:r};o.then(l=>{this.pending==s&&(this.pending=null,l&&!(Array.isArray(l)&&!l.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(l)?l:[l])}))},l=>As(e.state,l,"hover tooltip"))}else o&&!(Array.isArray(o)&&!o.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(o)?o:[o])})}get tooltip(){let e=this.view.plugin(QL),n=e?e.manager.tooltips.findIndex(a=>a.create==X2.create):-1;return n>-1?e.manager.tooltipViews[n]:null}mousemove(e){var n,a;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:r,tooltip:i}=this;if(r.length&&i&&!Ict(i.dom,e)||this.pending){let{pos:o}=r[0]||this.pending,s=(a=(n=r[0])===null||n===void 0?void 0:n.end)!==null&&a!==void 0?a:o;(o==s?this.view.posAtCoords(this.lastMove)!=o:!Dct(this.view,o,s,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:n}=this;if(n.length){let{tooltip:a}=this;a&&a.dom.contains(e.relatedTarget)?this.watchTooltipLeave(a.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let n=a=>{e.removeEventListener("mouseleave",n),this.active.length&&!this.view.dom.contains(a.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",n)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const e3=4;function Ict(t,e){let{left:n,right:a,top:r,bottom:i}=t.getBoundingClientRect(),o;if(o=t.querySelector(".cm-tooltip-arrow")){let s=o.getBoundingClientRect();r=Math.min(s.top,r),i=Math.max(s.bottom,i)}return e.clientX>=n-e3&&e.clientX<=a+e3&&e.clientY>=r-e3&&e.clientY<=i+e3}function Dct(t,e,n,a,r,i){let o=t.scrollDOM.getBoundingClientRect(),s=t.documentTop+t.documentPadding.top+t.contentHeight;if(o.left>a||o.right<a||o.top>r||Math.min(o.bottom,s)<r)return!1;let l=t.posAtCoords({x:a,y:r},!1);return l>=e&&l<=n}function Qct(t,e={}){let n=Bn.define(),a=Mi.define({create(){return[]},update(r,i){if(r.length&&(e.hideOnChange&&(i.docChanged||i.selection)?r=[]:e.hideOn&&(r=r.filter(o=>!e.hideOn(i,o))),i.docChanged)){let o=[];for(let s of r){let l=i.changes.mapPos(s.pos,-1,Mo.TrackDel);if(l!=null){let u=Object.assign(Object.create(null),s);u.pos=l,u.end!=null&&(u.end=i.changes.mapPos(u.end)),o.push(u)}}r=o}for(let o of i.effects)o.is(n)&&(r=o.value),o.is(Sct)&&(r=[]);return r},provide:r=>J2.from(r)});return{active:a,extension:[a,Cr.define(r=>new Bct(r,t,a,n,e.hoverTime||300)),Ect]}}function mce(t,e){let n=t.plugin(QL);if(!n)return null;let a=n.manager.tooltips.indexOf(e);return a<0?null:n.manager.tooltipViews[a]}const Sct=Bn.define(),Ace=Ht.define({combine(t){let e,n;for(let a of t)e=e||a.topContainer,n=n||a.bottomContainer;return{topContainer:e,bottomContainer:n}}});function L1(t,e){let n=t.plugin(gce),a=n?n.specs.indexOf(e):-1;return a>-1?n.panels[a]:null}const gce=Cr.fromClass(class{constructor(t){this.input=t.state.facet(N1),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(t));let e=t.state.facet(Ace);this.top=new t3(t,!0,e.topContainer),this.bottom=new t3(t,!1,e.bottomContainer),this.top.sync(this.panels.filter(n=>n.top)),this.bottom.sync(this.panels.filter(n=>!n.top));for(let n of this.panels)n.dom.classList.add("cm-panel"),n.mount&&n.mount()}update(t){let e=t.state.facet(Ace);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new t3(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new t3(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=t.state.facet(N1);if(n!=this.input){let a=n.filter(l=>l),r=[],i=[],o=[],s=[];for(let l of a){let u=this.specs.indexOf(l),d;u<0?(d=l(t.view),s.push(d)):(d=this.panels[u],d.update&&d.update(t)),r.push(d),(d.top?i:o).push(d)}this.specs=a,this.panels=r,this.top.sync(i),this.bottom.sync(o);for(let l of s)l.dom.classList.add("cm-panel"),l.mount&&l.mount()}else for(let a of this.panels)a.update&&a.update(t)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:t=>jt.scrollMargins.of(e=>{let n=e.plugin(t);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class t3{constructor(e,n,a){this.view=e,this.top=n,this.container=a,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let n of this.panels)n.destroy&&e.indexOf(n)<0&&n.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let n=this.container||this.view.dom;n.insertBefore(this.dom,this.top?n.firstChild:null)}let e=this.dom.firstChild;for(let n of this.panels)if(n.dom.parentNode==this.dom){for(;e!=n.dom;)e=hce(e);e=e.nextSibling}else this.dom.insertBefore(n.dom,e);for(;e;)e=hce(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 hce(t){let e=t.nextSibling;return t.remove(),e}const N1=Ht.define({enables:gce});class Qd extends lg{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Qd.prototype.elementClass="",Qd.prototype.toDOM=void 0,Qd.prototype.mapMode=Mo.TrackBefore,Qd.prototype.startSide=Qd.prototype.endSide=-1,Qd.prototype.point=!0;const n3=Ht.define(),Tct=Ht.define(),Fct={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>ta.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},M1=Ht.define();function Lct(t){return[bce(),M1.of({...Fct,...t})]}const fce=Ht.define({combine:t=>t.some(e=>e)});function bce(t){return[Nct]}const Nct=Cr.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(M1).map(e=>new wce(t,e)),this.fixed=!t.state.facet(fce);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(t){if(this.updateGutters(t)){let e=this.prevViewport,n=t.view.viewport,a=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(a<(n.to-n.from)*.8)}if(t.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(fce)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=ta.iter(this.view.state.facet(n3),this.view.viewport.from),a=[],r=this.gutters.map(i=>new Mct(i,this.view.viewport,-this.view.documentPadding.top));for(let i of this.view.viewportLineBlocks)if(a.length&&(a=[]),Array.isArray(i.type)){let o=!0;for(let s of i.type)if(s.type==$o.Text&&o){TL(n,a,s.from);for(let l of r)l.line(this.view,s,a);o=!1}else if(s.widget)for(let l of r)l.widget(this.view,s)}else if(i.type==$o.Text){TL(n,a,i.from);for(let o of r)o.line(this.view,i,a)}else if(i.widget)for(let o of r)o.widget(this.view,i);for(let i of r)i.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(M1),n=t.state.facet(M1),a=t.docChanged||t.heightChanged||t.viewportChanged||!ta.eq(t.startState.facet(n3),t.state.facet(n3),t.view.viewport.from,t.view.viewport.to);if(e==n)for(let r of this.gutters)r.update(t)&&(a=!0);else{a=!0;let r=[];for(let i of n){let o=e.indexOf(i);o<0?r.push(new wce(this.view,i)):(this.gutters[o].update(t),r.push(this.gutters[o]))}for(let i of this.gutters)i.dom.remove(),r.indexOf(i)<0&&i.destroy();for(let i of r)i.config.side=="after"?this.getDOMAfter().appendChild(i.dom):this.dom.appendChild(i.dom);this.gutters=r}return a}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>jt.scrollMargins.of(e=>{let n=e.plugin(t);if(!n||n.gutters.length==0||!n.fixed)return null;let a=n.dom.offsetWidth*e.scaleX,r=n.domAfter?n.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Ra.LTR?{left:a,right:r}:{right:a,left:r}})});function yce(t){return Array.isArray(t)?t:[t]}function TL(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}class Mct{constructor(e,n,a){this.gutter=e,this.height=a,this.i=0,this.cursor=ta.iter(e.markers,n.from)}addElement(e,n,a){let{gutter:r}=this,i=(n.top-this.height)/e.scaleY,o=n.height/e.scaleY;if(this.i==r.elements.length){let s=new kce(e,o,i,a);r.elements.push(s),r.dom.appendChild(s.dom)}else r.elements[this.i].update(e,o,i,a);this.height=n.bottom,this.i++}line(e,n,a){let r=[];TL(this.cursor,r,n.from),a.length&&(r=r.concat(a));let i=this.gutter.config.lineMarker(e,n,r);i&&r.unshift(i);let o=this.gutter;r.length==0&&!o.config.renderEmptyElements||this.addElement(e,n,r)}widget(e,n){let a=this.gutter.config.widgetMarker(e,n.widget,n),r=a?[a]:null;for(let i of e.state.facet(Tct)){let o=i(e,n.widget,n);o&&(r||(r=[])).push(o)}r&&this.addElement(e,n,r)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let n=e.elements.pop();e.dom.removeChild(n.dom),n.destroy()}}}class wce{constructor(e,n){this.view=e,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let a in n.domEventHandlers)this.dom.addEventListener(a,r=>{let i=r.target,o;if(i!=this.dom&&this.dom.contains(i)){for(;i.parentNode!=this.dom;)i=i.parentNode;let l=i.getBoundingClientRect();o=(l.top+l.bottom)/2}else o=r.clientY;let s=e.lineBlockAtHeight(o-e.documentTop);n.domEventHandlers[a](e,s,r)&&r.preventDefault()});this.markers=yce(n.markers(e)),n.initialSpacer&&(this.spacer=new kce(e,0,0,[n.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let n=this.markers;if(this.markers=yce(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let r=this.config.updateSpacer(this.spacer.markers[0],e);r!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[r])}let a=e.view.viewport;return!ta.eq(this.markers,n,a.from,a.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class kce{constructor(e,n,a,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,n,a,r)}update(e,n,a,r){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=a&&(this.dom.style.marginTop=(this.above=a)?a+"px":""),Rct(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,n){let a="cm-gutterElement",r=this.dom.firstChild;for(let i=0,o=0;;){let s=o,l=i<n.length?n[i++]:null,u=!1;if(l){let d=l.elementClass;d&&(a+=" "+d);for(let p=o;p<this.markers.length;p++)if(this.markers[p].compare(l)){s=p,u=!0;break}}else s=this.markers.length;for(;o<s;){let d=this.markers[o++];if(d.toDOM){d.destroy(r);let p=r.nextSibling;r.remove(),r=p}}if(!l)break;l.toDOM&&(u?r=r.nextSibling:this.dom.insertBefore(l.toDOM(e),r)),u&&o++}this.dom.className=a,this.markers=n}destroy(){this.setMarkers(null,[])}}function Rct(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].compare(e[n]))return!1;return!0}const $ct=Ht.define(),Pct=Ht.define(),hb=Ht.define({combine(t){return uu(t,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,n){let a=Object.assign({},e);for(let r in n){let i=a[r],o=n[r];a[r]=i?(s,l,u)=>i(s,l,u)||o(s,l,u):o}return a}})}});class FL extends Qd{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function LL(t,e){return t.state.facet(hb).formatNumber(e,t.state)}const Oct=M1.compute([hb],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet($ct)},lineMarker(e,n,a){return a.some(r=>r.toDOM)?null:new FL(LL(e,e.state.doc.lineAt(n.from).number))},widgetMarker:(e,n,a)=>{for(let r of e.state.facet(Pct)){let i=r(e,n,a);if(i)return i}return null},lineMarkerChange:e=>e.startState.facet(hb)!=e.state.facet(hb),initialSpacer(e){return new FL(LL(e,vce(e.state.doc.lines)))},updateSpacer(e,n){let a=LL(n.view,vce(n.view.state.doc.lines));return a==e.number?e:new FL(a)},domEventHandlers:t.facet(hb).domEventHandlers,side:"before"}));function jct(t={}){return[hb.of(t),bce(),Oct]}function vce(t){let e=9;for(;e<t;)e=e*10+9;return e}const Gct=new class extends Qd{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},qct=n3.compute(["selection"],t=>{let e=[],n=-1;for(let a of t.selection.ranges){let r=t.doc.lineAt(a.head).from;r>n&&(n=r,e.push(Gct.range(r)))}return ta.of(e)});function zct(){return qct}const Cce=1024;let Hct=0,NL=class{constructor(e,n){this.from=e,this.to=n}};class Rn{constructor(e={}){this.id=Hct++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=gs.match(e)),n=>{let a=e(n);return a===void 0?null:[this,a]}}}Rn.closedBy=new Rn({deserialize:t=>t.split(" ")}),Rn.openedBy=new Rn({deserialize:t=>t.split(" ")}),Rn.group=new Rn({deserialize:t=>t.split(" ")}),Rn.isolate=new Rn({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),Rn.contextHash=new Rn({perNode:!0}),Rn.lookAhead=new Rn({perNode:!0}),Rn.mounted=new Rn({perNode:!0});class a3{constructor(e,n,a){this.tree=e,this.overlay=n,this.parser=a}static get(e){return e&&e.props&&e.props[Rn.mounted.id]}}const Uct=Object.create(null);class gs{constructor(e,n,a,r=0){this.name=e,this.props=n,this.id=a,this.flags=r}static define(e){let n=e.props&&e.props.length?Object.create(null):Uct,a=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new gs(e.name||"",n,e.id,a);if(e.props){for(let i of e.props)if(Array.isArray(i)||(i=i(r)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[i[0].id]=i[1]}}return r}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let n=this.prop(Rn.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let a in e)for(let r of a.split(" "))n[r]=e[a];return a=>{for(let r=a.prop(Rn.group),i=-1;i<(r?r.length:0);i++){let o=n[i<0?a.name:r[i]];if(o)return o}}}}gs.none=new gs("",Object.create(null),0,8);class ML{constructor(e){this.types=e;for(let n=0;n<e.length;n++)if(e[n].id!=n)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let n=[];for(let a of this.types){let r=null;for(let i of e){let o=i(a);if(o){r||(r=Object.assign({},a.props));let s=o[1],l=o[0];l.combine&&l.id in r&&(s=l.combine(r[l.id],s)),r[l.id]=s}}n.push(r?new gs(a.name,r,a.id,a.flags):a)}return new ML(n)}}const r3=new WeakMap,_ce=new WeakMap;var wi;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays"})(wi||(wi={}));class Nr{constructor(e,n,a,r,i){if(this.type=e,this.children=n,this.positions=a,this.length=r,this.props=null,i&&i.length){this.props=Object.create(null);for(let[o,s]of i)this.props[typeof o=="number"?o:o.id]=s}}toString(){let e=a3.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let a of this.children){let r=a.toString();r&&(n&&(n+=","),n+=r)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new PL(this.topNode,e)}cursorAt(e,n=0,a=0){let r=r3.get(this)||this.topNode,i=new PL(r);return i.moveTo(e,n),r3.set(this,i._tree),i}get topNode(){return new Cc(this,0,0,null)}resolve(e,n=0){let a=R1(r3.get(this)||this.topNode,e,n,!1);return r3.set(this,a),a}resolveInner(e,n=0){let a=R1(_ce.get(this)||this.topNode,e,n,!0);return _ce.set(this,a),a}resolveStack(e,n=0){return Kct(this,e,n)}iterate(e){let{enter:n,leave:a,from:r=0,to:i=this.length}=e,o=e.mode||0,s=(o&wi.IncludeAnonymous)>0;for(let l=this.cursor(o|wi.IncludeAnonymous);;){let u=!1;if(l.from<=i&&l.to>=r&&(!s&&l.type.isAnonymous||n(l)!==!1)){if(l.firstChild())continue;u=!0}for(;u&&a&&(s||!l.type.isAnonymous)&&a(l),!l.nextSibling();){if(!l.parent())return;u=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:jL(gs.none,this.children,this.positions,0,this.children.length,0,this.length,(n,a,r)=>new Nr(this.type,n,a,r,this.propValues),e.makeTree||((n,a,r)=>new Nr(gs.none,n,a,r)))}static build(e){return Zct(e)}}Nr.empty=new Nr(gs.none,[],[],0);class RL{constructor(e,n){this.buffer=e,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new RL(this.buffer,this.index)}}class cm{constructor(e,n,a){this.buffer=e,this.length=n,this.set=a}get type(){return gs.none}toString(){let e=[];for(let n=0;n<this.buffer.length;)e.push(this.childString(n)),n=this.buffer[n+3];return e.join(",")}childString(e){let n=this.buffer[e],a=this.buffer[e+3],r=this.set.types[n],i=r.name;if(/\W/.test(i)&&!r.isError&&(i=JSON.stringify(i)),e+=4,a==e)return i;let o=[];for(;e<a;)o.push(this.childString(e)),e=this.buffer[e+3];return i+"("+o.join(",")+")"}findChild(e,n,a,r,i){let{buffer:o}=this,s=-1;for(let l=e;l!=n&&!(xce(i,r,o[l+1],o[l+2])&&(s=l,a>0));l=o[l+3]);return s}slice(e,n,a){let r=this.buffer,i=new Uint16Array(n-e),o=0;for(let s=e,l=0;s<n;){i[l++]=r[s++],i[l++]=r[s++]-a;let u=i[l++]=r[s++]-a;i[l++]=r[s++]-e,o=Math.max(o,u)}return new cm(i,o,this.set)}}function xce(t,e,n,a){switch(t){case-2:return n<e;case-1:return a>=e&&n<e;case 0:return n<e&&a>e;case 1:return n<=e&&a>e;case 2:return a>e;case 4:return!0}}function R1(t,e,n,a){for(var r;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to<e);){let o=!a&&t instanceof Cc&&t.index<0?null:t.parent;if(!o)return t;t=o}let i=a?0:wi.IgnoreOverlays;if(a)for(let o=t,s=o.parent;s;o=s,s=o.parent)o instanceof Cc&&o.index<0&&((r=s.enter(e,n,i))===null||r===void 0?void 0:r.from)!=o.from&&(t=s);for(;;){let o=t.enter(e,n,i);if(!o)return t;t=o}}class Ece{cursor(e=0){return new PL(this,e)}getChild(e,n=null,a=null){let r=Bce(this,e,n,a);return r.length?r[0]:null}getChildren(e,n=null,a=null){return Bce(this,e,n,a)}resolve(e,n=0){return R1(this,e,n,!1)}resolveInner(e,n=0){return R1(this,e,n,!0)}matchContext(e){return $L(this.parent,e)}enterUnfinishedNodesBefore(e){let n=this.childBefore(e),a=this;for(;n;){let r=n.lastChild;if(!r||r.to!=n.to)break;r.type.isError&&r.from==r.to?(a=n,n=r.prevSibling):n=r}return a}get node(){return this}get next(){return this.parent}}class Cc extends Ece{constructor(e,n,a,r){super(),this._tree=e,this.from=n,this.index=a,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,n,a,r,i=0){for(let o=this;;){for(let{children:s,positions:l}=o._tree,u=n>0?s.length:-1;e!=u;e+=n){let d=s[e],p=l[e]+o.from;if(xce(r,a,p,p+d.length)){if(d instanceof cm){if(i&wi.ExcludeBuffers)continue;let m=d.findChild(0,d.buffer.length,n,a-p,r);if(m>-1)return new lm(new Yct(o,d,e,p),null,m)}else if(i&wi.IncludeAnonymous||!d.type.isAnonymous||OL(d)){let m;if(!(i&wi.IgnoreMounts)&&(m=a3.get(d))&&!m.overlay)return new Cc(m.tree,p,e,o);let A=new Cc(d,p,e,o);return i&wi.IncludeAnonymous||!A.type.isAnonymous?A:A.nextChild(n<0?d.children.length-1:0,n,a,r)}}}if(i&wi.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+n:e=n<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,n,a=0){let r;if(!(a&wi.IgnoreOverlays)&&(r=a3.get(this._tree))&&r.overlay){let i=e-this.from;for(let{from:o,to:s}of r.overlay)if((n>0?o<=i:o<i)&&(n<0?s>=i:s>i))return new Cc(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,a)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function Bce(t,e,n,a){let r=t.cursor(),i=[];if(!r.firstChild())return i;if(n!=null){for(let o=!1;!o;)if(o=r.type.is(n),!r.nextSibling())return i}for(;;){if(a!=null&&r.type.is(a))return i;if(r.type.is(e)&&i.push(r.node),!r.nextSibling())return a==null?i:[]}}function $L(t,e,n=e.length-1){for(let a=t;n>=0;a=a.parent){if(!a)return!1;if(!a.type.isAnonymous){if(e[n]&&e[n]!=a.name)return!1;n--}}return!0}class Yct{constructor(e,n,a,r){this.parent=e,this.buffer=n,this.index=a,this.start=r}}class lm extends Ece{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,n,a){super(),this.context=e,this._parent=n,this.index=a,this.type=e.buffer.set.types[e.buffer.buffer[a]]}child(e,n,a){let{buffer:r}=this.context,i=r.findChild(this.index+4,r.buffer[this.index+3],e,n-this.context.start,a);return i<0?null:new lm(this.context,this,i)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,n,a=0){if(a&wi.ExcludeBuffers)return null;let{buffer:r}=this.context,i=r.findChild(this.index+4,r.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return i<0?null:new lm(this.context,this,i)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new lm(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new lm(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:a}=this.context,r=this.index+4,i=a.buffer[this.index+3];if(i>r){let o=a.buffer[this.index+1];e.push(a.slice(r,i,o)),n.push(0)}return new Nr(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Ice(t){if(!t.length)return null;let e=0,n=t[0];for(let i=1;i<t.length;i++){let o=t[i];(o.from>n.from||o.to<n.to)&&(n=o,e=i)}let a=n instanceof Cc&&n.index<0?null:n.parent,r=t.slice();return a?r[e]=a:r.splice(e,1),new Wct(r,n)}class Wct{constructor(e,n){this.heads=e,this.node=n}get next(){return Ice(this.heads)}}function Kct(t,e,n){let a=t.resolveInner(e,n),r=null;for(let i=a instanceof Cc?a:a.context.parent;i;i=i.parent)if(i.index<0){let o=i.parent;(r||(r=[a])).push(o.resolve(e,n)),i=o}else{let o=a3.get(i.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let s=new Cc(o.tree,o.overlay[0].from+i.from,-1,i);(r||(r=[a])).push(R1(s,e,n,!1))}}return r?Ice(r):a}class PL{get name(){return this.type.name}constructor(e,n=0){if(this.mode=n,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof Cc)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let a=e._parent;a;a=a._parent)this.stack.unshift(a.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,n){this.index=e;let{start:a,buffer:r}=this.buffer;return this.type=n||r.set.types[r.buffer[e]],this.from=a+r.buffer[e+1],this.to=a+r.buffer[e+2],!0}yield(e){return e?e instanceof Cc?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,n,a){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,a,this.mode));let{buffer:r}=this.buffer,i=r.findChild(this.index+4,r.buffer[this.index+3],e,n-this.buffer.start,a);return i<0?!1:(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,n,a=this.mode){return this.buffer?a&wi.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,a))}parent(){if(!this.buffer)return this.yieldNode(this.mode&wi.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&wi.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:n}=this.buffer,a=this.stack.length-1;if(e<0){let r=a<0?0:this.stack[a]+4;if(this.index!=r)return this.yieldBuf(n.findChild(r,this.index,-1,0,4))}else{let r=n.buffer[this.index+3];if(r<(a<0?n.buffer.length:n.buffer[this.stack[a]+3]))return this.yieldBuf(r)}return a<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let n,a,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let i=0;i<this.index;i++)if(r.buffer.buffer[i+3]<this.index)return!1;({index:n,parent:a}=r)}else({index:n,_parent:a}=this._tree);for(;a;{index:n,_parent:a}=a)if(n>-1)for(let i=n+e,o=e<0?-1:a._tree.children.length;i!=o;i+=e){let s=a._tree.children[i];if(this.mode&wi.IncludeAnonymous||s instanceof cm||!s.type.isAnonymous||OL(s))return!1}return!0}move(e,n){if(n&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,n););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,n=null,a=0;if(e&&e.context==this.buffer)e:for(let r=this.index,i=this.stack.length;i>=0;){for(let o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;n=o,a=i+1;break e}r=this.stack[--i]}for(let r=a;r<this.stack.length;r++)n=new lm(this.buffer,n,this.stack[r]);return this.bufferNode=new lm(this.buffer,n,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,n){for(let a=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){a++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&n&&n(this),r=this.type.isAnonymous,!a)return;if(this.nextSibling())break;this.parent(),a--,r=!0}}}matchContext(e){if(!this.buffer)return $L(this.node.parent,e);let{buffer:n}=this.buffer,{types:a}=n.set;for(let r=e.length-1,i=this.stack.length-1;r>=0;i--){if(i<0)return $L(this._tree,e,r);let o=a[n.buffer[this.stack[i]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}}function OL(t){return t.children.some(e=>e instanceof cm||!e.type.isAnonymous||OL(e))}function Zct(t){var e;let{buffer:n,nodeSet:a,maxBufferLength:r=Cce,reused:i=[],minRepeatType:o=a.types.length}=t,s=Array.isArray(n)?new RL(n,n.length):n,l=a.types,u=0,d=0;function p(C,x,_,E,D,Q){let{id:B,start:T,end:N,size:I}=s,S=d,M=u;if(I<0)if(s.next(),I==-1){let P=i[B];_.push(P),E.push(T-C);return}else if(I==-3){u=B;return}else if(I==-4){d=B;return}else throw new RangeError(`Unrecognized record size: ${I}`);let L=l[B],F,R,$=T-C;if(N-T<=r&&(R=f(s.pos-x,D))){let P=new Uint16Array(R.size-R.skip),q=s.pos-R.size,j=P.length;for(;s.pos>q;)j=b(R.start,P,j);F=new cm(P,N-R.start,a),$=R.start-C}else{let P=s.pos-I;s.next();let q=[],j=[],J=B>=o?B:-1,Y=0,ne=N;for(;s.pos>P;)J>=0&&s.id==J&&s.size>=0?(s.end<=ne-r&&(g(q,j,T,Y,s.end,ne,J,S,M),Y=q.length,ne=s.end),s.next()):Q>2500?m(T,P,q,j):p(T,P,q,j,J,Q+1);if(J>=0&&Y>0&&Y<q.length&&g(q,j,T,Y,T,ne,J,S,M),q.reverse(),j.reverse(),J>-1&&Y>0){let ee=A(L,M);F=jL(L,q,j,0,q.length,0,N-T,ee,ee)}else F=h(L,q,j,N-T,S-N,M)}_.push(F),E.push($)}function m(C,x,_,E){let D=[],Q=0,B=-1;for(;s.pos>x;){let{id:T,start:N,end:I,size:S}=s;if(S>4)s.next();else{if(B>-1&&N<B)break;B<0&&(B=I-r),D.push(T,N,I),Q++,s.next()}}if(Q){let T=new Uint16Array(Q*4),N=D[D.length-2];for(let I=D.length-3,S=0;I>=0;I-=3)T[S++]=D[I],T[S++]=D[I+1]-N,T[S++]=D[I+2]-N,T[S++]=S;_.push(new cm(T,D[2]-N,a)),E.push(N-C)}}function A(C,x){return(_,E,D)=>{let Q=0,B=_.length-1,T,N;if(B>=0&&(T=_[B])instanceof Nr){if(!B&&T.type==C&&T.length==D)return T;(N=T.prop(Rn.lookAhead))&&(Q=E[B]+T.length+N)}return h(C,_,E,D,Q,x)}}function g(C,x,_,E,D,Q,B,T,N){let I=[],S=[];for(;C.length>E;)I.push(C.pop()),S.push(x.pop()+_-D);C.push(h(a.types[B],I,S,Q-D,T-Q,N)),x.push(D-_)}function h(C,x,_,E,D,Q,B){if(Q){let T=[Rn.contextHash,Q];B=B?[T].concat(B):[T]}if(D>25){let T=[Rn.lookAhead,D];B=B?[T].concat(B):[T]}return new Nr(C,x,_,E,B)}function f(C,x){let _=s.fork(),E=0,D=0,Q=0,B=_.end-r,T={size:0,start:0,skip:0};e:for(let N=_.pos-C;_.pos>N;){let I=_.size;if(_.id==x&&I>=0){T.size=E,T.start=D,T.skip=Q,Q+=4,E+=4,_.next();continue}let S=_.pos-I;if(I<0||S<N||_.start<B)break;let M=_.id>=o?4:0,L=_.start;for(_.next();_.pos>S;){if(_.size<0)if(_.size==-3)M+=4;else break e;else _.id>=o&&(M+=4);_.next()}D=L,E+=I,Q+=M}return(x<0||E==C)&&(T.size=E,T.start=D,T.skip=Q),T.size>4?T:void 0}function b(C,x,_){let{id:E,start:D,end:Q,size:B}=s;if(s.next(),B>=0&&E<o){let T=_;if(B>4){let N=s.pos-(B-4);for(;s.pos>N;)_=b(C,x,_)}x[--_]=T,x[--_]=Q-C,x[--_]=D-C,x[--_]=E}else B==-3?u=E:B==-4&&(d=E);return _}let y=[],w=[];for(;s.pos>0;)p(t.start||0,t.bufferStart||0,y,w,-1,0);let k=(e=t.length)!==null&&e!==void 0?e:y.length?w[0]+y[0].length:0;return new Nr(l[t.topID],y.reverse(),w.reverse(),k)}const Dce=new WeakMap;function i3(t,e){if(!t.isAnonymous||e instanceof cm||e.type!=t)return 1;let n=Dce.get(e);if(n==null){n=1;for(let a of e.children){if(a.type!=t||!(a instanceof Nr)){n=1;break}n+=i3(t,a)}Dce.set(e,n)}return n}function jL(t,e,n,a,r,i,o,s,l){let u=0;for(let g=a;g<r;g++)u+=i3(t,e[g]);let d=Math.ceil(u*1.5/8),p=[],m=[];function A(g,h,f,b,y){for(let w=f;w<b;){let k=w,C=h[w],x=i3(t,g[w]);for(w++;w<b;w++){let _=i3(t,g[w]);if(x+_>=d)break;x+=_}if(w==k+1){if(x>d){let _=g[k];A(_.children,_.positions,0,_.children.length,h[k]+y);continue}p.push(g[k])}else{let _=h[w-1]+g[w-1].length-C;p.push(jL(t,g,h,k,w,C,_,null,l))}m.push(C+y-i)}}return A(e,n,a,r,0),(s||l)(p,m,o)}class Ag{constructor(e,n,a,r,i=!1,o=!1){this.from=e,this.to=n,this.tree=a,this.offset=r,this.open=(i?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],a=!1){let r=[new Ag(0,e.length,e,0,!1,a)];for(let i of n)i.to>e.length&&r.push(i);return r}static applyChanges(e,n,a=128){if(!n.length)return e;let r=[],i=1,o=e.length?e[0]:null;for(let s=0,l=0,u=0;;s++){let d=s<n.length?n[s]:null,p=d?d.fromA:1e9;if(p-l>=a)for(;o&&o.from<p;){let m=o;if(l>=m.from||p<=m.to||u){let A=Math.max(m.from,l)-u,g=Math.min(m.to,p)-u;m=A>=g?null:new Ag(A,g,m.tree,m.offset+u,s>0,!!d)}if(m&&r.push(m),o.to>p)break;o=i<e.length?e[i++]:null}if(!d)break;l=d.toA,u=d.toA-d.toB}return r}}let Qce=class{startParse(e,n,a){return typeof e=="string"&&(e=new Vct(e)),a=a?a.length?a.map(r=>new NL(r.from,r.to)):[new NL(0,0)]:[new NL(0,e.length)],this.createParse(e,n||[],a)}parse(e,n,a){let r=this.startParse(e,n,a);for(;;){let i=r.advance();if(i)return i}}};class Vct{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new Rn({perNode:!0});let Jct=0;class _c{constructor(e,n,a,r){this.name=e,this.set=n,this.base=a,this.modified=r,this.id=Jct++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let a=typeof e=="string"?e:"?";if(e instanceof _c&&(n=e),n!=null&&n.base)throw new Error("Can not derive from a modified tag");let r=new _c(a,[],null,[]);if(r.set.push(r),n)for(let i of n.set)r.set.push(i);return r}static defineModifier(e){let n=new o3(e);return a=>a.modified.indexOf(n)>-1?a:o3.get(a.base||a,a.modified.concat(n).sort((r,i)=>r.id-i.id))}}let Xct=0;class o3{constructor(e){this.name=e,this.instances=[],this.id=Xct++}static get(e,n){if(!n.length)return e;let a=n[0].instances.find(s=>s.base==e&&elt(n,s.modified));if(a)return a;let r=[],i=new _c(e.name,r,e,n);for(let s of n)s.instances.push(i);let o=tlt(n);for(let s of e.set)if(!s.modified.length)for(let l of o)r.push(o3.get(s,l));return i}}function elt(t,e){return t.length==e.length&&t.every((n,a)=>n==e[a])}function tlt(t){let e=[[]];for(let n=0;n<t.length;n++)for(let a=0,r=e.length;a<r;a++)e.push(e[a].concat(t[n]));return e.sort((n,a)=>a.length-n.length)}function Sce(t){let e=Object.create(null);for(let n in t){let a=t[n];Array.isArray(a)||(a=[a]);for(let r of n.split(" "))if(r){let i=[],o=2,s=r;for(let p=0;;){if(s=="..."&&p>0&&p+3==r.length){o=1;break}let m=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(s);if(!m)throw new RangeError("Invalid path: "+r);if(i.push(m[0]=="*"?"":m[0][0]=='"'?JSON.parse(m[0]):m[0]),p+=m[0].length,p==r.length)break;let A=r[p++];if(p==r.length&&A=="!"){o=0;break}if(A!="/")throw new RangeError("Invalid path: "+r);s=r.slice(p)}let l=i.length-1,u=i[l];if(!u)throw new RangeError("Invalid path: "+r);let d=new $1(a,o,l>0?i.slice(0,l):null);e[u]=d.sort(e[u])}}return Tce.add(e)}const Tce=new Rn({combine(t,e){let n,a,r;for(;t||e;){if(!t||e&&t.depth>=e.depth?(r=e,e=e.next):(r=t,t=t.next),n&&n.mode==r.mode&&!r.context&&!n.context)continue;let i=new $1(r.tags,r.mode,r.context);n?n.next=i:a=i,n=i}return a}});let $1=class{constructor(e,n,a,r){this.tags=e,this.mode=n,this.context=a,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};$1.empty=new $1([],2,null);function Fce(t,e){let n=Object.create(null);for(let i of t)if(!Array.isArray(i.tag))n[i.tag.id]=i.class;else for(let o of i.tag)n[o.id]=i.class;let{scope:a,all:r=null}=e||{};return{style:i=>{let o=r;for(let s of i)for(let l of s.set){let u=n[l.id];if(u){o=o?o+" "+u:u;break}}return o},scope:a}}function nlt(t,e){let n=null;for(let a of t){let r=a.style(e);r&&(n=n?n+" "+r:r)}return n}function alt(t,e,n,a=0,r=t.length){let i=new rlt(a,Array.isArray(e)?e:[e],n);i.highlightRange(t.cursor(),a,r,"",i.highlighters),i.flush(r)}class rlt{constructor(e,n,a){this.at=e,this.highlighters=n,this.span=a,this.class=""}startSpan(e,n){n!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=n)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,n,a,r,i){let{type:o,from:s,to:l}=e;if(s>=a||l<=n)return;o.isTop&&(i=this.highlighters.filter(A=>!A.scope||A.scope(o)));let u=r,d=ilt(e)||$1.empty,p=nlt(i,d.tags);if(p&&(u&&(u+=" "),u+=p,d.mode==1&&(r+=(r?" ":"")+p)),this.startSpan(Math.max(n,s),u),d.opaque)return;let m=e.tree&&e.tree.prop(Rn.mounted);if(m&&m.overlay){let A=e.node.enter(m.overlay[0].from+s,1),g=this.highlighters.filter(f=>!f.scope||f.scope(m.tree.type)),h=e.firstChild();for(let f=0,b=s;;f++){let y=f<m.overlay.length?m.overlay[f]:null,w=y?y.from+s:l,k=Math.max(n,b),C=Math.min(a,w);if(k<C&&h)for(;e.from<C&&(this.highlightRange(e,k,C,r,i),this.startSpan(Math.min(C,e.to),u),!(e.to>=w||!e.nextSibling())););if(!y||w>a)break;b=y.to+s,b>n&&(this.highlightRange(A.cursor(),Math.max(n,y.from+s),Math.min(a,b),"",g),this.startSpan(Math.min(a,b),u))}h&&e.parent()}else if(e.firstChild()){m&&(r="");do if(!(e.to<=n)){if(e.from>=a)break;this.highlightRange(e,n,a,r,i),this.startSpan(Math.min(a,e.to),u)}while(e.nextSibling());e.parent()}}}function ilt(t){let e=t.type.prop(Tce);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}const Lt=_c.define,s3=Lt(),um=Lt(),Lce=Lt(um),Nce=Lt(um),dm=Lt(),c3=Lt(dm),GL=Lt(dm),Au=Lt(),gg=Lt(Au),gu=Lt(),hu=Lt(),qL=Lt(),P1=Lt(qL),l3=Lt(),Xe={comment:s3,lineComment:Lt(s3),blockComment:Lt(s3),docComment:Lt(s3),name:um,variableName:Lt(um),typeName:Lce,tagName:Lt(Lce),propertyName:Nce,attributeName:Lt(Nce),className:Lt(um),labelName:Lt(um),namespace:Lt(um),macroName:Lt(um),literal:dm,string:c3,docString:Lt(c3),character:Lt(c3),attributeValue:Lt(c3),number:GL,integer:Lt(GL),float:Lt(GL),bool:Lt(dm),regexp:Lt(dm),escape:Lt(dm),color:Lt(dm),url:Lt(dm),keyword:gu,self:Lt(gu),null:Lt(gu),atom:Lt(gu),unit:Lt(gu),modifier:Lt(gu),operatorKeyword:Lt(gu),controlKeyword:Lt(gu),definitionKeyword:Lt(gu),moduleKeyword:Lt(gu),operator:hu,derefOperator:Lt(hu),arithmeticOperator:Lt(hu),logicOperator:Lt(hu),bitwiseOperator:Lt(hu),compareOperator:Lt(hu),updateOperator:Lt(hu),definitionOperator:Lt(hu),typeOperator:Lt(hu),controlOperator:Lt(hu),punctuation:qL,separator:Lt(qL),bracket:P1,angleBracket:Lt(P1),squareBracket:Lt(P1),paren:Lt(P1),brace:Lt(P1),content:Au,heading:gg,heading1:Lt(gg),heading2:Lt(gg),heading3:Lt(gg),heading4:Lt(gg),heading5:Lt(gg),heading6:Lt(gg),contentSeparator:Lt(Au),list:Lt(Au),quote:Lt(Au),emphasis:Lt(Au),strong:Lt(Au),link:Lt(Au),monospace:Lt(Au),strikethrough:Lt(Au),inserted:Lt(),deleted:Lt(),changed:Lt(),invalid:Lt(),meta:l3,documentMeta:Lt(l3),annotation:Lt(l3),processingInstruction:Lt(l3),definition:_c.defineModifier("definition"),constant:_c.defineModifier("constant"),function:_c.defineModifier("function"),standard:_c.defineModifier("standard"),local:_c.defineModifier("local"),special:_c.defineModifier("special")};for(let t in Xe){let e=Xe[t];e instanceof _c&&(e.name=t)}Fce([{tag:Xe.link,class:"tok-link"},{tag:Xe.heading,class:"tok-heading"},{tag:Xe.emphasis,class:"tok-emphasis"},{tag:Xe.strong,class:"tok-strong"},{tag:Xe.keyword,class:"tok-keyword"},{tag:Xe.atom,class:"tok-atom"},{tag:Xe.bool,class:"tok-bool"},{tag:Xe.url,class:"tok-url"},{tag:Xe.labelName,class:"tok-labelName"},{tag:Xe.inserted,class:"tok-inserted"},{tag:Xe.deleted,class:"tok-deleted"},{tag:Xe.literal,class:"tok-literal"},{tag:Xe.string,class:"tok-string"},{tag:Xe.number,class:"tok-number"},{tag:[Xe.regexp,Xe.escape,Xe.special(Xe.string)],class:"tok-string2"},{tag:Xe.variableName,class:"tok-variableName"},{tag:Xe.local(Xe.variableName),class:"tok-variableName tok-local"},{tag:Xe.definition(Xe.variableName),class:"tok-variableName tok-definition"},{tag:Xe.special(Xe.variableName),class:"tok-variableName2"},{tag:Xe.definition(Xe.propertyName),class:"tok-propertyName tok-definition"},{tag:Xe.typeName,class:"tok-typeName"},{tag:Xe.namespace,class:"tok-namespace"},{tag:Xe.className,class:"tok-className"},{tag:Xe.macroName,class:"tok-macroName"},{tag:Xe.propertyName,class:"tok-propertyName"},{tag:Xe.operator,class:"tok-operator"},{tag:Xe.comment,class:"tok-comment"},{tag:Xe.meta,class:"tok-meta"},{tag:Xe.invalid,class:"tok-invalid"},{tag:Xe.punctuation,class:"tok-punctuation"}]);var zL;const fb=new Rn;function olt(t){return Ht.define({combine:t?e=>e.concat(t):void 0})}const slt=new Rn;class cl{constructor(e,n,a=[],r=""){this.data=e,this.name=r,Hn.prototype.hasOwnProperty("tree")||Object.defineProperty(Hn.prototype,"tree",{get(){return oo(this)}}),this.parser=n,this.extension=[pm.of(this),Hn.languageData.of((i,o,s)=>{let l=Mce(i,o,s),u=l.type.prop(fb);if(!u)return[];let d=i.facet(u),p=l.type.prop(slt);if(p){let m=l.resolve(o-l.from,s);for(let A of p)if(A.test(m,i)){let g=i.facet(A.facet);return A.type=="replace"?g:g.concat(d)}}return d})].concat(a)}isActiveAt(e,n,a=-1){return Mce(e,n,a).type.prop(fb)==this.data}findRegions(e){let n=e.facet(pm);if((n==null?void 0:n.data)==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let a=[],r=(i,o)=>{if(i.prop(fb)==this.data){a.push({from:o,to:o+i.length});return}let s=i.prop(Rn.mounted);if(s){if(s.tree.prop(fb)==this.data){if(s.overlay)for(let l of s.overlay)a.push({from:l.from+o,to:l.to+o});else a.push({from:o,to:o+i.length});return}else if(s.overlay){let l=a.length;if(r(s.tree,s.overlay[0].from+o),a.length>l)return}}for(let l=0;l<i.children.length;l++){let u=i.children[l];u instanceof Nr&&r(u,i.positions[l]+o)}};return r(oo(e),0),a}get allowsNesting(){return!0}}cl.setState=Bn.define();function Mce(t,e,n){let a=t.facet(pm),r=oo(t).topNode;if(!a||a.allowsNesting)for(let i=r;i;i=i.enter(e,n,wi.ExcludeBuffers))i.type.isTop&&(r=i);return r}class u3 extends cl{constructor(e,n,a){super(e,n,[],a),this.parser=n}static define(e){let n=olt(e.languageData);return new u3(n,e.parser.configure({props:[fb.add(a=>a.isTop?n:void 0)]}),e.name)}configure(e,n){return new u3(this.data,this.parser.configure(e),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function oo(t){let e=t.field(cl.state,!1);return e?e.tree:Nr.empty}class clt{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,n){let a=this.cursorPos-this.string.length;return e<a||n>=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-a,n-a)}}let O1=null;class d3{constructor(e,n,a=[],r,i,o,s,l){this.parser=e,this.state=n,this.fragments=a,this.tree=r,this.treeLen=i,this.viewport=o,this.skipped=s,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,n,a){return new d3(e,n,[],Nr.empty,0,a,[],null)}startParse(){return this.parser.startParse(new clt(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=Nr.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var a;if(typeof e=="number"){let r=Date.now()+e;e=()=>Date.now()>r}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n<this.state.doc.length&&this.parse.stopAt(n);;){let r=this.parse.advance();if(r)if(this.fragments=this.withoutTempSkipped(Ag.addTree(r,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(a=this.parse.stoppedAt)!==null&&a!==void 0?a:this.state.doc.length,this.tree=r,this.parse=null,this.treeLen<(n??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,n;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(Ag.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=O1;O1=this;try{return e()}finally{O1=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=Rce(e,n.from,n.to);return e}changes(e,n){let{fragments:a,tree:r,treeLen:i,viewport:o,skipped:s}=this;if(this.takeTree(),!e.empty){let l=[];if(e.iterChangedRanges((u,d,p,m)=>l.push({fromA:u,toA:d,fromB:p,toB:m})),a=Ag.applyChanges(a,l),r=Nr.empty,i=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){s=[];for(let u of this.skipped){let d=e.mapPos(u.from,1),p=e.mapPos(u.to,-1);d<p&&s.push({from:d,to:p})}}}return new d3(this.parser,n,a,r,i,o,s,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let n=this.skipped.length;for(let a=0;a<this.skipped.length;a++){let{from:r,to:i}=this.skipped[a];r<e.to&&i>e.from&&(this.fragments=Rce(this.fragments,r,i),this.skipped.splice(a--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends Qce{createParse(n,a,r){let i=r[0].from,o=r[r.length-1].to;return{parsedPos:i,advance(){let l=O1;if(l){for(let u of r)l.tempSkipped.push(u);e&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,e]):e)}return this.parsedPos=o,new Nr(gs.none,[],[],o-i)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return O1}}function Rce(t,e,n){return Ag.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class bb{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),a=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,a)||n.takeTree(),new bb(n)}static init(e){let n=Math.min(3e3,e.doc.length),a=d3.create(e.facet(pm).parser,e,{from:0,to:n});return a.work(20,n)||a.takeTree(),new bb(a)}}cl.state=Mi.define({create:bb.init,update(t,e){for(let n of e.effects)if(n.is(cl.setState))return n.value;return e.startState.facet(pm)!=e.state.facet(pm)?bb.init(e.state):t.apply(e)}});let $ce=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&($ce=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const HL=typeof navigator<"u"&&(!((zL=navigator.scheduling)===null||zL===void 0)&&zL.isInputPending)?()=>navigator.scheduling.isInputPending():null,llt=Cr.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let n=this.view.state.field(cl.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(cl.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=$ce(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEnd<n&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=n+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:a,viewport:{to:r}}=this.view,i=a.field(cl.state);if(i.tree==i.context.tree&&i.context.isDone(r+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!HL?Math.max(25,e.timeRemaining()-5):1e9),s=i.context.treeLen<r&&a.doc.length>r+1e3,l=i.context.work(()=>HL&&HL()||Date.now()>o,r+(s?0:1e5));this.chunkBudget-=Date.now()-n,(l||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:cl.setState.of(new bb(i.context))})),this.chunkBudget>0&&!(l&&!s)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>As(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),pm=Ht.define({combine(t){return t.length?t[0]:null},enables:t=>[cl.state,llt,jt.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]});class ult{constructor(e,n=[]){this.language=e,this.support=n,this.extension=[e,n]}}const dlt=Ht.define(),p3=Ht.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function m3(t){let e=t.facet(p3);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function j1(t,e){let n="",a=t.tabSize,r=t.facet(p3)[0];if(r==" "){for(;e>=a;)n+=" ",e-=a;r=" "}for(let i=0;i<e;i++)n+=r;return n}function UL(t,e){t instanceof Hn&&(t=new A3(t));for(let a of t.state.facet(dlt)){let r=a(t,e);if(r!==void 0)return r}let n=oo(t.state);return n.length>=e?plt(t,n,e):null}class A3{constructor(e,n={}){this.state=e,this.options=n,this.unit=m3(e)}lineAt(e,n=1){let a=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:i}=this.options;return r!=null&&r>=a.from&&r<=a.to?i&&r==e?{text:"",from:e}:(n<0?r<e:r<=e)?{text:a.text.slice(r-a.from),from:r}:{text:a.text.slice(0,r-a.from),from:a.from}:a}textAfterPos(e,n=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:a,from:r}=this.lineAt(e,n);return a.slice(e-r,Math.min(a.length,e+100-r))}column(e,n=1){let{text:a,from:r}=this.lineAt(e,n),i=this.countColumn(a,e-r),o=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return o>-1&&(i+=o-this.countColumn(a,a.search(/\S|$/))),i}countColumn(e,n=e.length){return cb(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:a,from:r}=this.lineAt(e,n),i=this.options.overrideIndentation;if(i){let o=i(r);if(o>-1)return o}return this.countColumn(a,a.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Pce=new Rn;function plt(t,e,n){let a=e.resolveStack(n),r=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(r!=a.node){let i=[];for(let o=r;o&&!(o.from<a.node.from||o.to>a.node.to||o.from==a.node.from&&o.type==a.node.type);o=o.parent)i.push(o);for(let o=i.length-1;o>=0;o--)a={node:i[o],next:a}}return Oce(a,t,n)}function Oce(t,e,n){for(let a=t;a;a=a.next){let r=Alt(a.node);if(r)return r(YL.create(e,n,a))}return 0}function mlt(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function Alt(t){let e=t.type.prop(Pce);if(e)return e;let n=t.firstChild,a;if(n&&(a=n.type.prop(Rn.closedBy))){let r=t.lastChild,i=r&&a.indexOf(r.name)>-1;return o=>blt(o,!0,1,void 0,i&&!mlt(o)?r.from:void 0)}return t.parent==null?glt:null}function glt(){return 0}class YL extends A3{constructor(e,n,a){super(e.state,e.options),this.base=e,this.pos=n,this.context=a}get node(){return this.context.node}static create(e,n,a){return new YL(e,n,a)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let a=e.resolve(n.from);for(;a.parent&&a.parent.from==a.from;)a=a.parent;if(hlt(a,e))break;n=this.state.doc.lineAt(a.from)}return this.lineIndent(n.from)}continue(){return Oce(this.context.next,this.base,this.pos)}}function hlt(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function flt(t){let e=t.node,n=e.childAfter(e.from),a=e.lastChild;if(!n)return null;let r=t.options.simulateBreak,i=t.state.doc.lineAt(n.from),o=r==null||r<=i.from?i.to:Math.min(i.to,r);for(let s=n.to;;){let l=e.childAfter(s);if(!l||l==a)return null;if(!l.type.isSkipped){if(l.from>=o)return null;let u=/^ */.exec(i.text.slice(n.to-i.from))[0].length;return{from:n.from,to:n.to+u}}s=l.to}}function blt(t,e,n,a,r){let i=t.textAfter,o=i.match(/^\s*/)[0].length,s=r==t.pos+o,l=flt(t);return l?s?t.column(l.from):t.column(l.to):t.baseIndent+(s?0:t.unit*n)}function jce({except:t,units:e=1}={}){return n=>{let a=t&&t.test(n.textAfter);return n.baseIndent+(a?0:e*n.unit)}}const ylt=200;function wlt(){return Hn.transactionFilter.of(t=>{if(!t.docChanged||!t.isUserEvent("input.type")&&!t.isUserEvent("input.complete"))return t;let e=t.startState.languageDataAt("indentOnInput",t.startState.selection.main.head);if(!e.length)return t;let n=t.newDoc,{head:a}=t.newSelection.main,r=n.lineAt(a);if(a>r.from+ylt)return t;let i=n.sliceString(r.from,a);if(!e.some(u=>u.test(i)))return t;let{state:o}=t,s=-1,l=[];for(let{head:u}of o.selection.ranges){let d=o.doc.lineAt(u);if(d.from==s)continue;s=d.from;let p=UL(o,d.from);if(p==null)continue;let m=/^\s*/.exec(d.text)[0],A=j1(o,p);m!=A&&l.push({from:d.from,to:d.from+m.length,insert:A})}return l.length?[t,{changes:l,sequential:!0}]:t})}const klt=Ht.define(),Gce=new Rn;function vlt(t){let e=t.firstChild,n=t.lastChild;return e&&e.to<n.from?{from:e.to,to:n.type.isError?t.to:n.from}:null}function Clt(t,e,n){let a=oo(t);if(a.length<n)return null;let r=a.resolveStack(n,1),i=null;for(let o=r;o;o=o.next){let s=o.node;if(s.to<=n||s.from>n)continue;if(i&&s.from<e)break;let l=s.type.prop(Gce);if(l&&(s.to<a.length-50||a.length==t.doc.length||!_lt(s))){let u=l(s,t);u&&u.from<=n&&u.from>=e&&u.to>n&&(i=u)}}return i}function _lt(t){let e=t.lastChild;return e&&e.to==t.to&&e.type.isError}function g3(t,e,n){for(let a of t.facet(klt)){let r=a(t,e,n);if(r)return r}return Clt(t,e,n)}function qce(t,e){let n=e.mapPos(t.from,1),a=e.mapPos(t.to,-1);return n>=a?void 0:{from:n,to:a}}const h3=Bn.define({map:qce}),G1=Bn.define({map:qce});function zce(t){let e=[];for(let{head:n}of t.state.selection.ranges)e.some(a=>a.from<=n&&a.to>=n)||e.push(t.lineBlockAt(n));return e}const hg=Mi.define({create(){return ln.none},update(t,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((n,a)=>t=Hce(t,n,a)),t=t.map(e.changes);for(let n of e.effects)if(n.is(h3)&&!xlt(t,n.value.from,n.value.to)){let{preparePlaceholder:a}=e.state.facet(Wce),r=a?ln.replace({widget:new Qlt(a(e.state,n.value))}):Vce;t=t.update({add:[r.range(n.value.from,n.value.to)]})}else n.is(G1)&&(t=t.update({filter:(a,r)=>n.value.from!=a||n.value.to!=r,filterFrom:n.value.from,filterTo:n.value.to}));return e.selection&&(t=Hce(t,e.selection.main.head)),t},provide:t=>jt.decorations.from(t),toJSON(t,e){let n=[];return t.between(0,e.doc.length,(a,r)=>{n.push(a,r)}),n},fromJSON(t){if(!Array.isArray(t)||t.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let n=0;n<t.length;){let a=t[n++],r=t[n++];if(typeof a!="number"||typeof r!="number")throw new RangeError("Invalid JSON for fold state");e.push(Vce.range(a,r))}return ln.set(e,!0)}});function Hce(t,e,n=e){let a=!1;return t.between(e,n,(r,i)=>{r<n&&i>e&&(a=!0)}),a?t.update({filterFrom:e,filterTo:n,filter:(r,i)=>r>=n||i<=e}):t}function f3(t,e,n){var a;let r=null;return(a=t.field(hg,!1))===null||a===void 0||a.between(e,n,(i,o)=>{(!r||r.from>i)&&(r={from:i,to:o})}),r}function xlt(t,e,n){let a=!1;return t.between(e,e,(r,i)=>{r==e&&i==n&&(a=!0)}),a}function Uce(t,e){return t.field(hg,!1)?e:e.concat(Bn.appendConfig.of(Kce()))}const Elt=t=>{for(let e of zce(t)){let n=g3(t.state,e.from,e.to);if(n)return t.dispatch({effects:Uce(t.state,[h3.of(n),Yce(t,n)])}),!0}return!1},Blt=t=>{if(!t.state.field(hg,!1))return!1;let e=[];for(let n of zce(t)){let a=f3(t.state,n.from,n.to);a&&e.push(G1.of(a),Yce(t,a,!1))}return e.length&&t.dispatch({effects:e}),e.length>0};function Yce(t,e,n=!0){let a=t.state.doc.lineAt(e.from).number,r=t.state.doc.lineAt(e.to).number;return jt.announce.of(`${t.state.phrase(n?"Folded lines":"Unfolded lines")} ${a} ${t.state.phrase("to")} ${r}.`)}const Ilt=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:Elt},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:Blt},{key:"Ctrl-Alt-[",run:t=>{let{state:e}=t,n=[];for(let a=0;a<e.doc.length;){let r=t.lineBlockAt(a),i=g3(e,r.from,r.to);i&&n.push(h3.of(i)),a=(i?t.lineBlockAt(i.to):r).to+1}return n.length&&t.dispatch({effects:Uce(t.state,n)}),!!n.length}},{key:"Ctrl-Alt-]",run:t=>{let e=t.state.field(hg,!1);if(!e||!e.size)return!1;let n=[];return e.between(0,t.state.doc.length,(a,r)=>{n.push(G1.of({from:a,to:r}))}),t.dispatch({effects:n}),!0}}],Dlt={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},Wce=Ht.define({combine(t){return uu(t,Dlt)}});function Kce(t){return[hg,Flt]}function Zce(t,e){let{state:n}=t,a=n.facet(Wce),r=o=>{let s=t.lineBlockAt(t.posAtDOM(o.target)),l=f3(t.state,s.from,s.to);l&&t.dispatch({effects:G1.of(l)}),o.preventDefault()};if(a.placeholderDOM)return a.placeholderDOM(t,r,e);let i=document.createElement("span");return i.textContent=a.placeholderText,i.setAttribute("aria-label",n.phrase("folded code")),i.title=n.phrase("unfold"),i.className="cm-foldPlaceholder",i.onclick=r,i}const Vce=ln.replace({widget:new class extends Bd{toDOM(t){return Zce(t,null)}}});class Qlt extends Bd{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return Zce(e,this.value)}}const Slt={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class WL extends Qd{constructor(e,n){super(),this.config=e,this.open=n}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let n=document.createElement("span");return n.textContent=this.open?this.config.openText:this.config.closedText,n.title=e.state.phrase(this.open?"Fold line":"Unfold line"),n}}function Tlt(t={}){let e={...Slt,...t},n=new WL(e,!0),a=new WL(e,!1),r=Cr.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(pm)!=o.state.facet(pm)||o.startState.field(hg,!1)!=o.state.field(hg,!1)||oo(o.startState)!=oo(o.state)||e.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let s=new xd;for(let l of o.viewportLineBlocks){let u=f3(o.state,l.from,l.to)?a:g3(o.state,l.from,l.to)?n:null;u&&s.add(l.from,l.from,u)}return s.finish()}}),{domEventHandlers:i}=e;return[r,Lct({class:"cm-foldGutter",markers(o){var s;return((s=o.plugin(r))===null||s===void 0?void 0:s.markers)||ta.empty},initialSpacer(){return new WL(e,!1)},domEventHandlers:{...i,click:(o,s,l)=>{if(i.click&&i.click(o,s,l))return!0;let u=f3(o.state,s.from,s.to);if(u)return o.dispatch({effects:G1.of(u)}),!0;let d=g3(o.state,s.from,s.to);return d?(o.dispatch({effects:h3.of(d)}),!0):!1}}}),Kce()]}const Flt=jt.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 q1{constructor(e,n){this.specs=e;let a;function r(s){let l=nm.newName();return(a||(a=Object.create(null)))["."+l]=s,l}const i=typeof n.all=="string"?n.all:n.all?r(n.all):void 0,o=n.scope;this.scope=o instanceof cl?s=>s.prop(fb)==o.data:o?s=>s==o:void 0,this.style=Fce(e.map(s=>({tag:s.tag,class:s.class||r(Object.assign({},s,{tag:null}))})),{all:i}).style,this.module=a?new nm(a):null,this.themeType=n.themeType}static define(e,n){return new q1(e,n||{})}}const KL=Ht.define(),Jce=Ht.define({combine(t){return t.length?[t[0]]:null}});function ZL(t){let e=t.facet(KL);return e.length?e:t.facet(Jce)}function Xce(t,e){let n=[Nlt],a;return t instanceof q1&&(t.module&&n.push(jt.styleModule.of(t.module)),a=t.themeType),e!=null&&e.fallback?n.push(Jce.of(t)):a?n.push(KL.computeN([jt.darkTheme],r=>r.facet(jt.darkTheme)==(a=="dark")?[t]:[])):n.push(KL.of(t)),n}class Llt{constructor(e){this.markCache=Object.create(null),this.tree=oo(e.state),this.decorations=this.buildDeco(e,ZL(e.state)),this.decoratedTo=e.viewport.to}update(e){let n=oo(e.state),a=ZL(e.state),r=a!=ZL(e.startState),{viewport:i}=e.view,o=e.changes.mapPos(this.decoratedTo,1);n.length<i.to&&!r&&n.type==this.tree.type&&o>=i.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(n!=this.tree||e.viewportChanged||r)&&(this.tree=n,this.decorations=this.buildDeco(e.view,a),this.decoratedTo=i.to)}buildDeco(e,n){if(!n||!this.tree.length)return ln.none;let a=new xd;for(let{from:r,to:i}of e.visibleRanges)alt(this.tree,n,(o,s,l)=>{a.add(o,s,this.markCache[l]||(this.markCache[l]=ln.mark({class:l})))},r,i);return a.finish()}}const Nlt=cg.high(Cr.fromClass(Llt,{decorations:t=>t.decorations})),Mlt=q1.define([{tag:Xe.meta,color:"#404740"},{tag:Xe.link,textDecoration:"underline"},{tag:Xe.heading,textDecoration:"underline",fontWeight:"bold"},{tag:Xe.emphasis,fontStyle:"italic"},{tag:Xe.strong,fontWeight:"bold"},{tag:Xe.strikethrough,textDecoration:"line-through"},{tag:Xe.keyword,color:"#708"},{tag:[Xe.atom,Xe.bool,Xe.url,Xe.contentSeparator,Xe.labelName],color:"#219"},{tag:[Xe.literal,Xe.inserted],color:"#164"},{tag:[Xe.string,Xe.deleted],color:"#a11"},{tag:[Xe.regexp,Xe.escape,Xe.special(Xe.string)],color:"#e40"},{tag:Xe.definition(Xe.variableName),color:"#00f"},{tag:Xe.local(Xe.variableName),color:"#30a"},{tag:[Xe.typeName,Xe.namespace],color:"#085"},{tag:Xe.className,color:"#167"},{tag:[Xe.special(Xe.variableName),Xe.macroName],color:"#256"},{tag:Xe.definition(Xe.propertyName),color:"#00c"},{tag:Xe.comment,color:"#940"},{tag:Xe.invalid,color:"#f00"}]),Rlt=jt.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),ele=1e4,tle="()[]{}",nle=Ht.define({combine(t){return uu(t,{afterCursor:!0,brackets:tle,maxScanDistance:ele,renderMatch:Olt})}}),$lt=ln.mark({class:"cm-matchingBracket"}),Plt=ln.mark({class:"cm-nonmatchingBracket"});function Olt(t){let e=[],n=t.matched?$lt:Plt;return e.push(n.range(t.start.from,t.start.to)),t.end&&e.push(n.range(t.end.from,t.end.to)),e}const jlt=[Mi.define({create(){return ln.none},update(t,e){if(!e.docChanged&&!e.selection)return t;let n=[],a=e.state.facet(nle);for(let r of e.state.selection.ranges){if(!r.empty)continue;let i=fu(e.state,r.head,-1,a)||r.head>0&&fu(e.state,r.head-1,1,a)||a.afterCursor&&(fu(e.state,r.head,1,a)||r.head<e.state.doc.length&&fu(e.state,r.head+1,-1,a));i&&(n=n.concat(a.renderMatch(i,e.state)))}return ln.set(n,!0)},provide:t=>jt.decorations.from(t)}),Rlt];function Glt(t={}){return[nle.of(t),jlt]}const qlt=new Rn;function VL(t,e,n){let a=t.prop(e<0?Rn.openedBy:Rn.closedBy);if(a)return a;if(t.name.length==1){let r=n.indexOf(t.name);if(r>-1&&r%2==(e<0?1:0))return[n[r+e]]}return null}function JL(t){let e=t.type.prop(qlt);return e?e(t.node):t}function fu(t,e,n,a={}){let r=a.maxScanDistance||ele,i=a.brackets||tle,o=oo(t),s=o.resolveInner(e,n);for(let l=s;l;l=l.parent){let u=VL(l.type,n,i);if(u&&l.from<l.to){let d=JL(l);if(d&&(n>0?e>=d.from&&e<d.to:e>d.from&&e<=d.to))return zlt(t,e,n,l,d,u,i)}}return Hlt(t,e,n,o,s.type,r,i)}function zlt(t,e,n,a,r,i,o){let s=a.parent,l={from:r.from,to:r.to},u=0,d=s==null?void 0:s.cursor();if(d&&(n<0?d.childBefore(a.from):d.childAfter(a.to)))do if(n<0?d.to<=a.from:d.from>=a.to){if(u==0&&i.indexOf(d.type.name)>-1&&d.from<d.to){let p=JL(d);return{start:l,end:p?{from:p.from,to:p.to}:void 0,matched:!0}}else if(VL(d.type,n,o))u++;else if(VL(d.type,-n,o)){if(u==0){let p=JL(d);return{start:l,end:p&&p.from<p.to?{from:p.from,to:p.to}:void 0,matched:!1}}u--}}while(n<0?d.prevSibling():d.nextSibling());return{start:l,matched:!1}}function Hlt(t,e,n,a,r,i,o){let s=n<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),l=o.indexOf(s);if(l<0||l%2==0!=n>0)return null;let u={from:n<0?e-1:e,to:n>0?e+1:e},d=t.doc.iterRange(e,n>0?t.doc.length:0),p=0;for(let m=0;!d.next().done&&m<=i;){let A=d.value;n<0&&(m+=A.length);let g=e+m*n;for(let h=n>0?0:A.length-1,f=n>0?A.length:-1;h!=f;h+=n){let b=o.indexOf(A[h]);if(!(b<0||a.resolveInner(g+h,1).type!=r))if(b%2==0==n>0)p++;else{if(p==1)return{start:u,end:{from:g+h,to:g+h+1},matched:b>>1==l>>1};p--}}n>0&&(m+=A.length)}return d.done?{start:u,matched:!1}:null}const Ult=Object.create(null),ale=[gs.none],rle=[],ile=Object.create(null),Ylt=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Ylt[t]=Wlt(Ult,e);function XL(t,e){rle.indexOf(t)>-1||(rle.push(t),console.warn(e))}function Wlt(t,e){let n=[];for(let s of e.split(" ")){let l=[];for(let u of s.split(".")){let d=t[u]||Xe[u];d?typeof d=="function"?l.length?l=l.map(d):XL(u,`Modifier ${u} used at start of tag`):l.length?XL(u,`Tag ${u} used as modifier`):l=Array.isArray(d)?d:[d]:XL(u,`Unknown highlighting tag ${u}`)}for(let u of l)n.push(u)}if(!n.length)return 0;let a=e.replace(/ /g,"_"),r=a+" "+n.map(s=>s.id),i=ile[r];if(i)return i.id;let o=ile[r]=gs.define({id:ale.length,name:a,props:[Sce({[a]:n})]});return ale.push(o),o.id}Ra.RTL,Ra.LTR;const Klt=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),a=tN(t.state,n.from);return a.line?Zlt(t):a.block?Jlt(t):!1};function eN(t,e){return({state:n,dispatch:a})=>{if(n.readOnly)return!1;let r=t(e,n);return r?(a(n.update(r)),!0):!1}}const Zlt=eN(tut,0),Vlt=eN(ole,0),Jlt=eN((t,e)=>ole(t,e,eut(e)),0);function tN(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const z1=50;function Xlt(t,{open:e,close:n},a,r){let i=t.sliceDoc(a-z1,a),o=t.sliceDoc(r,r+z1),s=/\s*$/.exec(i)[0].length,l=/^\s*/.exec(o)[0].length,u=i.length-s;if(i.slice(u-e.length,u)==e&&o.slice(l,l+n.length)==n)return{open:{pos:a-s,margin:s&&1},close:{pos:r+l,margin:l&&1}};let d,p;r-a<=2*z1?d=p=t.sliceDoc(a,r):(d=t.sliceDoc(a,a+z1),p=t.sliceDoc(r-z1,r));let m=/^\s*/.exec(d)[0].length,A=/\s*$/.exec(p)[0].length,g=p.length-A-n.length;return d.slice(m,m+e.length)==e&&p.slice(g,g+n.length)==n?{open:{pos:a+m+e.length,margin:/\s/.test(d.charAt(m+e.length))?1:0},close:{pos:r-A-n.length,margin:/\s/.test(p.charAt(g-1))?1:0}}:null}function eut(t){let e=[];for(let n of t.selection.ranges){let a=t.doc.lineAt(n.from),r=n.to<=a.to?a:t.doc.lineAt(n.to);r.from>a.from&&r.from==n.to&&(r=n.to==a.to+1?a:t.doc.lineAt(n.to-1));let i=e.length-1;i>=0&&e[i].to>a.from?e[i].to=r.to:e.push({from:a.from+/^\s*/.exec(a.text)[0].length,to:r.to})}return e}function ole(t,e,n=e.selection.ranges){let a=n.map(i=>tN(e,i.from).block);if(!a.every(i=>i))return null;let r=n.map((i,o)=>Xlt(e,a[o],i.from,i.to));if(t!=2&&!r.every(i=>i))return{changes:e.changes(n.map((i,o)=>r[o]?[]:[{from:i.from,insert:a[o].open+" "},{from:i.to,insert:" "+a[o].close}]))};if(t!=1&&r.some(i=>i)){let i=[];for(let o=0,s;o<r.length;o++)if(s=r[o]){let l=a[o],{open:u,close:d}=s;i.push({from:u.pos-l.open.length,to:u.pos+u.margin},{from:d.pos-d.margin,to:d.pos+l.close.length})}return{changes:i}}return null}function tut(t,e,n=e.selection.ranges){let a=[],r=-1;for(let{from:i,to:o}of n){let s=a.length,l=1e9,u=tN(e,i).line;if(u){for(let d=i;d<=o;){let p=e.doc.lineAt(d);if(p.from>r&&(i==o||o>p.from)){r=p.from;let m=/^\s*/.exec(p.text)[0].length,A=m==p.length,g=p.text.slice(m,m+u.length)==u?m:-1;m<p.text.length&&m<l&&(l=m),a.push({line:p,comment:g,token:u,indent:m,empty:A,single:!1})}d=p.to+1}if(l<1e9)for(let d=s;d<a.length;d++)a[d].indent<a[d].line.text.length&&(a[d].indent=l);a.length==s+1&&(a[s].single=!0)}}if(t!=2&&a.some(i=>i.comment<0&&(!i.empty||i.single))){let i=[];for(let{line:s,token:l,indent:u,empty:d,single:p}of a)(p||!d)&&i.push({from:s.from+u,insert:l+" "});let o=e.changes(i);return{changes:o,selection:e.selection.map(o,1)}}else if(t!=1&&a.some(i=>i.comment>=0)){let i=[];for(let{line:o,comment:s,token:l}of a)if(s>=0){let u=o.from+s,d=u+l.length;o.text[d-o.from]==" "&&d++,i.push({from:u,to:d})}return{changes:i}}return null}const nN=lu.define(),nut=lu.define(),aut=Ht.define(),sle=Ht.define({combine(t){return uu(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(a,r)=>e(a,r)||n(a,r)})}}),cle=Mi.define({create(){return bu.empty},update(t,e){let n=e.state.facet(sle),a=e.annotation(nN);if(a){let l=hs.fromTransaction(e,a.selection),u=a.side,d=u==0?t.undone:t.done;return l?d=y3(d,d.length,n.minDepth,l):d=dle(d,e.startState.selection),new bu(u==0?a.rest:d,u==0?d:a.rest)}let r=e.annotation(nut);if((r=="full"||r=="before")&&(t=t.isolate()),e.annotation(ni.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let i=hs.fromTransaction(e),o=e.annotation(ni.time),s=e.annotation(ni.userEvent);return i?t=t.addChanges(i,o,s,n,e):e.selection&&(t=t.addSelection(e.startState.selection,o,s,n.newGroupDelay)),(r=="full"||r=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new bu(t.done.map(hs.fromJSON),t.undone.map(hs.fromJSON))}});function rut(t={}){return[cle,sle.of(t),jt.domEventHandlers({beforeinput(e,n){let a=e.inputType=="historyUndo"?lle:e.inputType=="historyRedo"?aN:null;return a?(e.preventDefault(),a(n)):!1}})]}function b3(t,e){return function({state:n,dispatch:a}){if(!e&&n.readOnly)return!1;let r=n.field(cle,!1);if(!r)return!1;let i=r.pop(t,n,e);return i?(a(i),!0):!1}}const lle=b3(0,!1),aN=b3(1,!1),iut=b3(0,!0),out=b3(1,!0);class hs{constructor(e,n,a,r,i){this.changes=e,this.effects=n,this.mapped=a,this.startSelection=r,this.selectionsAfter=i}setSelAfter(e){return new hs(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,a;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(a=this.startSelection)===null||a===void 0?void 0:a.toJSON(),selectionsAfter:this.selectionsAfter.map(r=>r.toJSON())}}static fromJSON(e){return new hs(e.changes&&ti.fromJSON(e.changes),[],e.mapped&&cu.fromJSON(e.mapped),e.startSelection&&lt.fromJSON(e.startSelection),e.selectionsAfter.map(lt.fromJSON))}static fromTransaction(e,n){let a=xc;for(let r of e.startState.facet(aut)){let i=r(e);i.length&&(a=a.concat(i))}return!a.length&&e.changes.empty?null:new hs(e.changes.invert(e.startState.doc),a,void 0,n||e.startState.selection,xc)}static selection(e){return new hs(void 0,xc,void 0,void 0,e)}}function y3(t,e,n,a){let r=e+1>n+20?e-n-1:0,i=t.slice(r,e);return i.push(a),i}function sut(t,e){let n=[],a=!1;return t.iterChangedRanges((r,i)=>n.push(r,i)),e.iterChangedRanges((r,i,o,s)=>{for(let l=0;l<n.length;){let u=n[l++],d=n[l++];s>=u&&o<=d&&(a=!0)}}),a}function cut(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,a)=>n.empty!=e.ranges[a].empty).length===0}function ule(t,e){return t.length?e.length?t.concat(e):t:e}const xc=[],lut=200;function dle(t,e){if(t.length){let n=t[t.length-1],a=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-lut));return a.length&&a[a.length-1].eq(e)?t:(a.push(e),y3(t,t.length-1,1e9,n.setSelAfter(a)))}else return[hs.selection([e])]}function uut(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function rN(t,e){if(!t.length)return t;let n=t.length,a=xc;for(;n;){let r=dut(t[n-1],e,a);if(r.changes&&!r.changes.empty||r.effects.length){let i=t.slice(0,n);return i[n-1]=r,i}else e=r.mapped,n--,a=r.selectionsAfter}return a.length?[hs.selection(a)]:xc}function dut(t,e,n){let a=ule(t.selectionsAfter.length?t.selectionsAfter.map(s=>s.map(e)):xc,n);if(!t.changes)return hs.selection(a);let r=t.changes.map(e),i=e.mapDesc(t.changes,!0),o=t.mapped?t.mapped.composeDesc(i):i;return new hs(r,Bn.mapEffects(t.effects,e),o,t.startSelection.map(i),a)}const put=/^(input\.type|delete)($|\.)/;class bu{constructor(e,n,a=0,r=void 0){this.done=e,this.undone=n,this.prevTime=a,this.prevUserEvent=r}isolate(){return this.prevTime?new bu(this.done,this.undone):this}addChanges(e,n,a,r,i){let o=this.done,s=o[o.length-1];return s&&s.changes&&!s.changes.empty&&e.changes&&(!a||put.test(a))&&(!s.selectionsAfter.length&&n-this.prevTime<r.newGroupDelay&&r.joinToEvent(i,sut(s.changes,e.changes))||a=="input.type.compose")?o=y3(o,o.length-1,r.minDepth,new hs(e.changes.compose(s.changes),ule(Bn.mapEffects(e.effects,s.changes),s.effects),s.mapped,s.startSelection,xc)):o=y3(o,o.length,r.minDepth,e),new bu(o,xc,n,a)}addSelection(e,n,a,r){let i=this.done.length?this.done[this.done.length-1].selectionsAfter:xc;return i.length>0&&n-this.prevTime<r&&a==this.prevUserEvent&&a&&/^select($|\.)/.test(a)&&cut(i[i.length-1],e)?this:new bu(dle(this.done,e),this.undone,n,a)}addMapping(e){return new bu(rN(this.done,e),rN(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,n,a){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],o=i.selectionsAfter[0]||n.selection;if(a&&i.selectionsAfter.length)return n.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:nN.of({side:e,rest:uut(r),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(i.changes){let s=r.length==1?xc:r.slice(0,r.length-1);return i.mapped&&(s=rN(s,i.mapped)),n.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:nN.of({side:e,rest:s,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}bu.empty=new bu(xc,xc);const mut=[{key:"Mod-z",run:lle,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:aN,preventDefault:!0},{linux:"Ctrl-Shift-z",run:aN,preventDefault:!0},{key:"Mod-u",run:iut,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:out,preventDefault:!0}];function yb(t,e){return lt.create(t.ranges.map(e),t.mainIndex)}function ll(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function ul({state:t,dispatch:e},n){let a=yb(t.selection,n);return a.eq(t.selection,!0)?!1:(e(ll(t,a)),!0)}function w3(t,e){return lt.cursor(e?t.to:t.from)}function ple(t,e){return ul(t,n=>n.empty?t.moveByChar(n,e):w3(n,e))}function so(t){return t.textDirectionAt(t.state.selection.main.head)==Ra.LTR}const mle=t=>ple(t,!so(t)),Ale=t=>ple(t,so(t));function gle(t,e){return ul(t,n=>n.empty?t.moveByGroup(n,e):w3(n,e))}const Aut=t=>gle(t,!so(t)),gut=t=>gle(t,so(t));function hut(t,e,n){if(e.type.prop(n))return!0;let a=e.to-e.from;return a&&(a>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function k3(t,e,n){let a=oo(t).resolveInner(e.head),r=n?Rn.closedBy:Rn.openedBy;for(let l=e.head;;){let u=n?a.childAfter(l):a.childBefore(l);if(!u)break;hut(t,u,r)?a=u:l=n?u.to:u.from}let i=a.type.prop(r),o,s;return i&&(o=n?fu(t,a.from,1):fu(t,a.to,-1))&&o.matched?s=n?o.end.to:o.end.from:s=n?a.to:a.from,lt.cursor(s,n?-1:1)}const fut=t=>ul(t,e=>k3(t.state,e,!so(t))),but=t=>ul(t,e=>k3(t.state,e,so(t)));function hle(t,e){return ul(t,n=>{if(!n.empty)return w3(n,e);let a=t.moveVertically(n,e);return a.head!=n.head?a:t.moveToLineBoundary(n,e)})}const fle=t=>hle(t,!1),ble=t=>hle(t,!0);function yle(t){let e=t.scrollDOM.clientHeight<t.scrollDOM.scrollHeight-2,n=0,a=0,r;if(e){for(let i of t.state.facet(jt.scrollMargins)){let o=i(t);o!=null&&o.top&&(n=Math.max(o==null?void 0:o.top,n)),o!=null&&o.bottom&&(a=Math.max(o==null?void 0:o.bottom,a))}r=t.scrollDOM.clientHeight-n-a}else r=(t.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:a,selfScroll:e,height:Math.max(t.defaultLineHeight,r-5)}}function wle(t,e){let n=yle(t),{state:a}=t,r=yb(a.selection,o=>o.empty?t.moveVertically(o,e,n.height):w3(o,e));if(r.eq(a.selection))return!1;let i;if(n.selfScroll){let o=t.coordsAtPos(a.selection.main.head),s=t.scrollDOM.getBoundingClientRect(),l=s.top+n.marginTop,u=s.bottom-n.marginBottom;o&&o.top>l&&o.bottom<u&&(i=jt.scrollIntoView(r.main.head,{y:"start",yMargin:o.top-l}))}return t.dispatch(ll(a,r),{effects:i}),!0}const kle=t=>wle(t,!1),iN=t=>wle(t,!0);function mm(t,e,n){let a=t.lineBlockAt(e.head),r=t.moveToLineBoundary(e,n);if(r.head==e.head&&r.head!=(n?a.to:a.from)&&(r=t.moveToLineBoundary(e,n,!1)),!n&&r.head==a.from&&a.length){let i=/^\s*/.exec(t.state.sliceDoc(a.from,Math.min(a.from+100,a.to)))[0].length;i&&e.head!=a.from+i&&(r=lt.cursor(a.from+i))}return r}const yut=t=>ul(t,e=>mm(t,e,!0)),wut=t=>ul(t,e=>mm(t,e,!1)),kut=t=>ul(t,e=>mm(t,e,!so(t))),vut=t=>ul(t,e=>mm(t,e,so(t))),Cut=t=>ul(t,e=>lt.cursor(t.lineBlockAt(e.head).from,1)),_ut=t=>ul(t,e=>lt.cursor(t.lineBlockAt(e.head).to,-1));function xut(t,e,n){let a=!1,r=yb(t.selection,i=>{let o=fu(t,i.head,-1)||fu(t,i.head,1)||i.head>0&&fu(t,i.head-1,1)||i.head<t.doc.length&&fu(t,i.head+1,-1);if(!o||!o.end)return i;a=!0;let s=o.start.from==i.head?o.end.to:o.end.from;return lt.cursor(s)});return a?(e(ll(t,r)),!0):!1}const Eut=({state:t,dispatch:e})=>xut(t,e);function Ec(t,e){let n=yb(t.state.selection,a=>{let r=e(a);return lt.range(a.anchor,r.head,r.goalColumn,r.bidiLevel||void 0)});return n.eq(t.state.selection)?!1:(t.dispatch(ll(t.state,n)),!0)}function vle(t,e){return Ec(t,n=>t.moveByChar(n,e))}const Cle=t=>vle(t,!so(t)),_le=t=>vle(t,so(t));function xle(t,e){return Ec(t,n=>t.moveByGroup(n,e))}const But=t=>xle(t,!so(t)),Iut=t=>xle(t,so(t)),Dut=t=>Ec(t,e=>k3(t.state,e,!so(t))),Qut=t=>Ec(t,e=>k3(t.state,e,so(t)));function Ele(t,e){return Ec(t,n=>t.moveVertically(n,e))}const Ble=t=>Ele(t,!1),Ile=t=>Ele(t,!0);function Dle(t,e){return Ec(t,n=>t.moveVertically(n,e,yle(t).height))}const Qle=t=>Dle(t,!1),Sle=t=>Dle(t,!0),Sut=t=>Ec(t,e=>mm(t,e,!0)),Tut=t=>Ec(t,e=>mm(t,e,!1)),Fut=t=>Ec(t,e=>mm(t,e,!so(t))),Lut=t=>Ec(t,e=>mm(t,e,so(t))),Nut=t=>Ec(t,e=>lt.cursor(t.lineBlockAt(e.head).from)),Mut=t=>Ec(t,e=>lt.cursor(t.lineBlockAt(e.head).to)),Tle=({state:t,dispatch:e})=>(e(ll(t,{anchor:0})),!0),Fle=({state:t,dispatch:e})=>(e(ll(t,{anchor:t.doc.length})),!0),Lle=({state:t,dispatch:e})=>(e(ll(t,{anchor:t.selection.main.anchor,head:0})),!0),Nle=({state:t,dispatch:e})=>(e(ll(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),Rut=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),$ut=({state:t,dispatch:e})=>{let n=C3(t).map(({from:a,to:r})=>lt.range(a,Math.min(r+1,t.doc.length)));return e(t.update({selection:lt.create(n),userEvent:"select"})),!0},Put=({state:t,dispatch:e})=>{let n=yb(t.selection,a=>{let r=oo(t),i=r.resolveStack(a.from,1);if(a.empty){let o=r.resolveStack(a.from,-1);o.node.from>=i.node.from&&o.node.to<=i.node.to&&(i=o)}for(let o=i;o;o=o.next){let{node:s}=o;if((s.from<a.from&&s.to>=a.to||s.to>a.to&&s.from<=a.from)&&o.next)return lt.range(s.to,s.from)}return a});return n.eq(t.selection)?!1:(e(ll(t,n)),!0)};function Mle(t,e){let{state:n}=t,a=n.selection,r=n.selection.ranges.slice();for(let i of n.selection.ranges){let o=n.doc.lineAt(i.head);if(e?o.to<t.state.doc.length:o.from>0)for(let s=i;;){let l=t.moveVertically(s,e);if(l.head<o.from||l.head>o.to){r.some(u=>u.head==l.head)||r.push(l);break}else{if(l.head==s.head)break;s=l}}}return r.length==a.ranges.length?!1:(t.dispatch(ll(n,lt.create(r,r.length-1))),!0)}const Out=t=>Mle(t,!1),jut=t=>Mle(t,!0),Gut=({state:t,dispatch:e})=>{let n=t.selection,a=null;return n.ranges.length>1?a=lt.create([n.main]):n.main.empty||(a=lt.create([lt.cursor(n.main.head)])),a?(e(ll(t,a)),!0):!1};function H1(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:a}=t,r=a.changeByRange(i=>{let{from:o,to:s}=i;if(o==s){let l=e(i);l<o?(n="delete.backward",l=v3(t,l,!1)):l>o&&(n="delete.forward",l=v3(t,l,!0)),o=Math.min(o,l),s=Math.max(s,l)}else o=v3(t,o,!1),s=v3(t,s,!0);return o==s?{range:i}:{changes:{from:o,to:s},range:lt.cursor(o,o<i.head?-1:1)}});return r.changes.empty?!1:(t.dispatch(a.update(r,{scrollIntoView:!0,userEvent:n,effects:n=="delete.selection"?jt.announce.of(a.phrase("Selection deleted")):void 0})),!0)}function v3(t,e,n){if(t instanceof jt)for(let a of t.state.facet(jt.atomicRanges).map(r=>r(t)))a.between(e,e,(r,i)=>{r<e&&i>e&&(e=n?i:r)});return e}const Rle=(t,e,n)=>H1(t,a=>{let r=a.from,{state:i}=t,o=i.doc.lineAt(r),s,l;if(n&&!e&&r>o.from&&r<o.from+200&&!/[^ \t]/.test(s=o.text.slice(0,r-o.from))){if(s[s.length-1]==" ")return r-1;let u=cb(s,i.tabSize),d=u%m3(i)||m3(i);for(let p=0;p<d&&s[s.length-1-p]==" ";p++)r--;l=r}else l=Ni(o.text,r-o.from,e,e)+o.from,l==r&&o.number!=(e?i.doc.lines:1)?l+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(o.text.slice(l-o.from,r-o.from))&&(l=Ni(o.text,l-o.from,!1,!1)+o.from);return l}),oN=t=>Rle(t,!1,!0),$le=t=>Rle(t,!0,!1),Ple=(t,e)=>H1(t,n=>{let a=n.head,{state:r}=t,i=r.doc.lineAt(a),o=r.charCategorizer(a);for(let s=null;;){if(a==(e?i.to:i.from)){a==n.head&&i.number!=(e?r.doc.lines:1)&&(a+=e?1:-1);break}let l=Ni(i.text,a-i.from,e)+i.from,u=i.text.slice(Math.min(a,l)-i.from,Math.max(a,l)-i.from),d=o(u);if(s!=null&&d!=s)break;(u!=" "||a!=n.head)&&(s=d),a=l}return a}),Ole=t=>Ple(t,!1),qut=t=>Ple(t,!0),zut=t=>H1(t,e=>{let n=t.lineBlockAt(e.head).to;return e.head<n?n:Math.min(t.state.doc.length,e.head+1)}),Hut=t=>H1(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),Uut=t=>H1(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head<n?n:Math.min(t.state.doc.length,e.head+1)}),Yut=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(a=>({changes:{from:a.from,to:a.to,insert:ea.of(["",""])},range:lt.cursor(a.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},Wut=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(a=>{if(!a.empty||a.from==0||a.from==t.doc.length)return{range:a};let r=a.from,i=t.doc.lineAt(r),o=r==i.from?r-1:Ni(i.text,r-i.from,!1)+i.from,s=r==i.to?r+1:Ni(i.text,r-i.from,!0)+i.from;return{changes:{from:o,to:s,insert:t.doc.slice(r,s).append(t.doc.slice(o,r))},range:lt.cursor(s)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function C3(t){let e=[],n=-1;for(let a of t.selection.ranges){let r=t.doc.lineAt(a.from),i=t.doc.lineAt(a.to);if(!a.empty&&a.to==i.from&&(i=t.doc.lineAt(a.to-1)),n>=r.number){let o=e[e.length-1];o.to=i.to,o.ranges.push(a)}else e.push({from:r.from,to:i.to,ranges:[a]});n=i.number+1}return e}function jle(t,e,n){if(t.readOnly)return!1;let a=[],r=[];for(let i of C3(t)){if(n?i.to==t.doc.length:i.from==0)continue;let o=t.doc.lineAt(n?i.to+1:i.from-1),s=o.length+1;if(n){a.push({from:i.to,to:o.to},{from:i.from,insert:o.text+t.lineBreak});for(let l of i.ranges)r.push(lt.range(Math.min(t.doc.length,l.anchor+s),Math.min(t.doc.length,l.head+s)))}else{a.push({from:o.from,to:i.from},{from:i.to,insert:t.lineBreak+o.text});for(let l of i.ranges)r.push(lt.range(l.anchor-s,l.head-s))}}return a.length?(e(t.update({changes:a,scrollIntoView:!0,selection:lt.create(r,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const Kut=({state:t,dispatch:e})=>jle(t,e,!1),Zut=({state:t,dispatch:e})=>jle(t,e,!0);function Gle(t,e,n){if(t.readOnly)return!1;let a=[];for(let r of C3(t))n?a.push({from:r.from,insert:t.doc.slice(r.from,r.to)+t.lineBreak}):a.push({from:r.to,insert:t.lineBreak+t.doc.slice(r.from,r.to)});return e(t.update({changes:a,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const Vut=({state:t,dispatch:e})=>Gle(t,e,!1),Jut=({state:t,dispatch:e})=>Gle(t,e,!0),Xut=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(C3(e).map(({from:r,to:i})=>(r>0?r--:i<e.doc.length&&i++,{from:r,to:i}))),a=yb(e.selection,r=>{let i;if(t.lineWrapping){let o=t.lineBlockAt(r.head),s=t.coordsAtPos(r.head,r.assoc||1);s&&(i=o.bottom+t.documentTop-s.bottom+t.defaultLineHeight/2)}return t.moveVertically(r,!0,i)}).map(n);return t.dispatch({changes:n,selection:a,scrollIntoView:!0,userEvent:"delete.line"}),!0};function edt(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=oo(t).resolveInner(e),a=n.childBefore(e),r=n.childAfter(e),i;return a&&r&&a.to<=e&&r.from>=e&&(i=a.type.prop(Rn.closedBy))&&i.indexOf(r.name)>-1&&t.doc.lineAt(a.to).from==t.doc.lineAt(r.from).from&&!/\S/.test(t.sliceDoc(a.to,r.from))?{from:a.to,to:r.from}:null}const qle=zle(!1),tdt=zle(!0);function zle(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let a=e.changeByRange(r=>{let{from:i,to:o}=r,s=e.doc.lineAt(i),l=!t&&i==o&&edt(e,i);t&&(i=o=(o<=s.to?s:e.doc.lineAt(o)).to);let u=new A3(e,{simulateBreak:i,simulateDoubleBreak:!!l}),d=UL(u,i);for(d==null&&(d=cb(/^\s*/.exec(e.doc.lineAt(i).text)[0],e.tabSize));o<s.to&&/\s/.test(s.text[o-s.from]);)o++;l?{from:i,to:o}=l:i>s.from&&i<s.from+100&&!/\S/.test(s.text.slice(0,i))&&(i=s.from);let p=["",j1(e,d)];return l&&p.push(j1(e,u.lineIndent(s.from,-1))),{changes:{from:i,to:o,insert:ea.of(p)},range:lt.cursor(i+1+p[1].length)}});return n(e.update(a,{scrollIntoView:!0,userEvent:"input"})),!0}}function sN(t,e){let n=-1;return t.changeByRange(a=>{let r=[];for(let o=a.from;o<=a.to;){let s=t.doc.lineAt(o);s.number>n&&(a.empty||a.to>s.from)&&(e(s,r,a),n=s.number),o=s.to+1}let i=t.changes(r);return{changes:r,range:lt.range(i.mapPos(a.anchor,1),i.mapPos(a.head,1))}})}const ndt=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),a=new A3(t,{overrideIndentation:i=>{let o=n[i];return o??-1}}),r=sN(t,(i,o,s)=>{let l=UL(a,i.from);if(l==null)return;/\S/.test(i.text)||(l=0);let u=/^\s*/.exec(i.text)[0],d=j1(t,l);(u!=d||s.from<i.from+u.length)&&(n[i.from]=l,o.push({from:i.from,to:i.from+u.length,insert:d}))});return r.changes.empty||e(t.update(r,{userEvent:"indent"})),!0},Hle=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(sN(t,(n,a)=>{a.push({from:n.from,insert:t.facet(p3)})}),{userEvent:"input.indent"})),!0),Ule=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(sN(t,(n,a)=>{let r=/^\s*/.exec(n.text)[0];if(!r)return;let i=cb(r,t.tabSize),o=0,s=j1(t,Math.max(0,i-m3(t)));for(;o<r.length&&o<s.length&&r.charCodeAt(o)==s.charCodeAt(o);)o++;a.push({from:n.from+o,to:n.from+r.length,insert:s.slice(o)})}),{userEvent:"delete.dedent"})),!0),adt=t=>(t.setTabFocusMode(),!0),rdt=[{key:"Ctrl-b",run:mle,shift:Cle,preventDefault:!0},{key:"Ctrl-f",run:Ale,shift:_le},{key:"Ctrl-p",run:fle,shift:Ble},{key:"Ctrl-n",run:ble,shift:Ile},{key:"Ctrl-a",run:Cut,shift:Nut},{key:"Ctrl-e",run:_ut,shift:Mut},{key:"Ctrl-d",run:$le},{key:"Ctrl-h",run:oN},{key:"Ctrl-k",run:zut},{key:"Ctrl-Alt-h",run:Ole},{key:"Ctrl-o",run:Yut},{key:"Ctrl-t",run:Wut},{key:"Ctrl-v",run:iN}],idt=[{key:"ArrowLeft",run:mle,shift:Cle,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Aut,shift:But,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:kut,shift:Fut,preventDefault:!0},{key:"ArrowRight",run:Ale,shift:_le,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:gut,shift:Iut,preventDefault:!0},{mac:"Cmd-ArrowRight",run:vut,shift:Lut,preventDefault:!0},{key:"ArrowUp",run:fle,shift:Ble,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Tle,shift:Lle},{mac:"Ctrl-ArrowUp",run:kle,shift:Qle},{key:"ArrowDown",run:ble,shift:Ile,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Fle,shift:Nle},{mac:"Ctrl-ArrowDown",run:iN,shift:Sle},{key:"PageUp",run:kle,shift:Qle},{key:"PageDown",run:iN,shift:Sle},{key:"Home",run:wut,shift:Tut,preventDefault:!0},{key:"Mod-Home",run:Tle,shift:Lle},{key:"End",run:yut,shift:Sut,preventDefault:!0},{key:"Mod-End",run:Fle,shift:Nle},{key:"Enter",run:qle,shift:qle},{key:"Mod-a",run:Rut},{key:"Backspace",run:oN,shift:oN,preventDefault:!0},{key:"Delete",run:$le,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Ole,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:qut,preventDefault:!0},{mac:"Mod-Backspace",run:Hut,preventDefault:!0},{mac:"Mod-Delete",run:Uut,preventDefault:!0}].concat(rdt.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),odt=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:fut,shift:Dut},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:but,shift:Qut},{key:"Alt-ArrowUp",run:Kut},{key:"Shift-Alt-ArrowUp",run:Vut},{key:"Alt-ArrowDown",run:Zut},{key:"Shift-Alt-ArrowDown",run:Jut},{key:"Mod-Alt-ArrowUp",run:Out},{key:"Mod-Alt-ArrowDown",run:jut},{key:"Escape",run:Gut},{key:"Mod-Enter",run:tdt},{key:"Alt-l",mac:"Ctrl-l",run:$ut},{key:"Mod-i",run:Put,preventDefault:!0},{key:"Mod-[",run:Ule},{key:"Mod-]",run:Hle},{key:"Mod-Alt-\\",run:ndt},{key:"Shift-Mod-k",run:Xut},{key:"Shift-Mod-\\",run:Eut},{key:"Mod-/",run:Klt},{key:"Alt-A",run:Vlt},{key:"Ctrl-m",mac:"Shift-Alt-m",run:adt}].concat(idt),sdt={key:"Tab",run:Hle,shift:Ule},Yle=typeof String.prototype.normalize=="function"?t=>t.normalize("NFKD"):t=>t;class wb{constructor(e,n,a=0,r=e.length,i,o){this.test=o,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(a,r),this.bufferStart=a,this.normalize=i?s=>i(Yle(s)):Yle,this.query=this.normalize(n)}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 ms(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 n=EF(e),a=this.bufferStart+this.bufferPos;this.bufferPos+=su(e);let r=this.normalize(n);if(r.length)for(let i=0,o=a;;i++){let s=r.charCodeAt(i),l=this.match(s,o,this.bufferPos+this.bufferStart);if(i==r.length-1){if(l)return this.value=l,this;break}o==a&&i<n.length&&n.charCodeAt(i)==s&&o++}}}match(e,n,a){let r=null;for(let i=0;i<this.matches.length;i+=2){let o=this.matches[i],s=!1;this.query.charCodeAt(o)==e&&(o==this.query.length-1?r={from:this.matches[i+1],to:a}:(this.matches[i]++,s=!0)),s||(this.matches.splice(i,2),i-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?r={from:n,to:a}:this.matches.push(1,n)),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}}typeof Symbol<"u"&&(wb.prototype[Symbol.iterator]=function(){return this});const Wle={from:-1,to:-1,match:/.*/.exec("")},cN="gm"+(/x/.unicode==null?"":"u");class Kle{constructor(e,n,a,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine="",this.done=!1,this.value=Wle,/\\[sWDnr]|\n|\r|\[\^/.test(n))return new Zle(e,n,a,r,i);this.re=new RegExp(n,cN+(a!=null&&a.ignoreCase?"i":"")),this.test=a==null?void 0:a.test,this.iter=e.iter();let o=e.lineAt(r);this.curLineStart=o.from,this.matchPos=_3(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let n=this.matchPos<=this.to&&this.re.exec(this.curLine);if(n){let a=this.curLineStart+n.index,r=a+n[0].length;if(this.matchPos=_3(this.text,r+(a==r?1:0)),a==this.curLineStart+this.curLine.length&&this.nextLine(),(a<r||a>this.value.to)&&(!this.test||this.test(a,r,n)))return this.value={from:a,to:r,match:n},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 lN=new WeakMap;class kb{constructor(e,n){this.from=e,this.text=n}get to(){return this.from+this.text.length}static get(e,n,a){let r=lN.get(e);if(!r||r.from>=a||r.to<=n){let s=new kb(n,e.sliceString(n,a));return lN.set(e,s),s}if(r.from==n&&r.to==a)return r;let{text:i,from:o}=r;return o>n&&(i=e.sliceString(n,o)+i,o=n),r.to<a&&(i+=e.sliceString(r.to,a)),lN.set(e,new kb(o,i)),new kb(n,i.slice(n-o,a-o))}}class Zle{constructor(e,n,a,r,i){this.text=e,this.to=i,this.done=!1,this.value=Wle,this.matchPos=_3(e,r),this.re=new RegExp(n,cN+(a!=null&&a.ignoreCase?"i":"")),this.test=a==null?void 0:a.test,this.flat=kb.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,n=this.re.exec(this.flat.text);if(n&&!n[0]&&n.index==e&&(this.re.lastIndex=e+1,n=this.re.exec(this.flat.text)),n){let a=this.flat.from+n.index,r=a+n[0].length;if((this.flat.to>=this.to||n.index+n[0].length<=this.flat.text.length-10)&&(!this.test||this.test(a,r,n)))return this.value={from:a,to:r,match:n},this.matchPos=_3(this.text,r+(a==r?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=kb.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(Kle.prototype[Symbol.iterator]=Zle.prototype[Symbol.iterator]=function(){return this});function cdt(t){try{return new RegExp(t,cN),!0}catch{return!1}}function _3(t,e){if(e>=t.length)return e;let n=t.lineAt(e),a;for(;e<n.to&&(a=n.text.charCodeAt(e-n.from))>=56320&&a<57344;)e++;return e}function uN(t){let e=String(t.state.doc.lineAt(t.state.selection.main.head).number),n=xa("input",{class:"cm-textfield",name:"line",value:e}),a=xa("form",{class:"cm-gotoLine",onkeydown:i=>{i.keyCode==27?(i.preventDefault(),t.dispatch({effects:U1.of(!1)}),t.focus()):i.keyCode==13&&(i.preventDefault(),r())},onsubmit:i=>{i.preventDefault(),r()}},xa("label",t.state.phrase("Go to line"),": ",n)," ",xa("button",{class:"cm-button",type:"submit"},t.state.phrase("go")),xa("button",{name:"close",onclick:()=>{t.dispatch({effects:U1.of(!1)}),t.focus()},"aria-label":t.state.phrase("close"),type:"button"},["×"]));function r(){let i=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.value);if(!i)return;let{state:o}=t,s=o.doc.lineAt(o.selection.main.head),[,l,u,d,p]=i,m=d?+d.slice(1):0,A=u?+u:s.number;if(u&&p){let f=A/100;l&&(f=f*(l=="-"?-1:1)+s.number/o.doc.lines),A=Math.round(o.doc.lines*f)}else u&&l&&(A=A*(l=="-"?-1:1)+s.number);let g=o.doc.line(Math.max(1,Math.min(o.doc.lines,A))),h=lt.cursor(g.from+Math.max(0,Math.min(m,g.length)));t.dispatch({effects:[U1.of(!1),jt.scrollIntoView(h.from,{y:"center"})],selection:h}),t.focus()}return{dom:a}}const U1=Bn.define(),Vle=Mi.define({create(){return!0},update(t,e){for(let n of e.effects)n.is(U1)&&(t=n.value);return t},provide:t=>N1.from(t,e=>e?uN:null)}),ldt=t=>{let e=L1(t,uN);if(!e){let n=[U1.of(!0)];t.state.field(Vle,!1)==null&&n.push(Bn.appendConfig.of([Vle,udt])),t.dispatch({effects:n}),e=L1(t,uN)}return e&&e.dom.querySelector("input").select(),!0},udt=jt.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px",position:"relative","& label":{fontSize:"80%"},"& [name=close]":{position:"absolute",top:"0",bottom:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:"0"}}}),ddt={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},pdt=Ht.define({combine(t){return uu(t,ddt,{highlightWordAroundCursor:(e,n)=>e||n,minSelectionLength:Math.min,maxMatches:Math.min})}});function mdt(t){return[bdt,fdt]}const Adt=ln.mark({class:"cm-selectionMatch"}),gdt=ln.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function Jle(t,e,n,a){return(n==0||t(e.sliceDoc(n-1,n))!=Za.Word)&&(a==e.doc.length||t(e.sliceDoc(a,a+1))!=Za.Word)}function hdt(t,e,n,a){return t(e.sliceDoc(n,n+1))==Za.Word&&t(e.sliceDoc(a-1,a))==Za.Word}const fdt=Cr.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.selectionSet||t.docChanged||t.viewportChanged)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=t.state.facet(pdt),{state:n}=t,a=n.selection;if(a.ranges.length>1)return ln.none;let r=a.main,i,o=null;if(r.empty){if(!e.highlightWordAroundCursor)return ln.none;let l=n.wordAt(r.head);if(!l)return ln.none;o=n.charCategorizer(r.head),i=n.sliceDoc(l.from,l.to)}else{let l=r.to-r.from;if(l<e.minSelectionLength||l>200)return ln.none;if(e.wholeWords){if(i=n.sliceDoc(r.from,r.to),o=n.charCategorizer(r.head),!(Jle(o,n,r.from,r.to)&&hdt(o,n,r.from,r.to)))return ln.none}else if(i=n.sliceDoc(r.from,r.to),!i)return ln.none}let s=[];for(let l of t.visibleRanges){let u=new wb(n.doc,i,l.from,l.to);for(;!u.next().done;){let{from:d,to:p}=u.value;if((!o||Jle(o,n,d,p))&&(r.empty&&d<=r.from&&p>=r.to?s.push(gdt.range(d,p)):(d>=r.to||p<=r.from)&&s.push(Adt.range(d,p)),s.length>e.maxMatches))return ln.none}}return ln.set(s)}},{decorations:t=>t.decorations}),bdt=jt.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),ydt=({state:t,dispatch:e})=>{let{selection:n}=t,a=lt.create(n.ranges.map(r=>t.wordAt(r.head)||lt.cursor(r.head)),n.mainIndex);return a.eq(n)?!1:(e(t.update({selection:a})),!0)};function wdt(t,e){let{main:n,ranges:a}=t.selection,r=t.wordAt(n.head),i=r&&r.from==n.from&&r.to==n.to;for(let o=!1,s=new wb(t.doc,e,a[a.length-1].to);;)if(s.next(),s.done){if(o)return null;s=new wb(t.doc,e,0,Math.max(0,a[a.length-1].from-1)),o=!0}else{if(o&&a.some(l=>l.from==s.value.from))continue;if(i){let l=t.wordAt(s.value.from);if(!l||l.from!=s.value.from||l.to!=s.value.to)continue}return s.value}}const kdt=({state:t,dispatch:e})=>{let{ranges:n}=t.selection;if(n.some(i=>i.from===i.to))return ydt({state:t,dispatch:e});let a=t.sliceDoc(n[0].from,n[0].to);if(t.selection.ranges.some(i=>t.sliceDoc(i.from,i.to)!=a))return!1;let r=wdt(t,a);return r?(e(t.update({selection:t.selection.addRange(lt.range(r.from,r.to),!1),effects:jt.scrollIntoView(r.to)})),!0):!1},vb=Ht.define({combine(t){return uu(t,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Fdt(e),scrollToMatch:e=>jt.scrollIntoView(e)})}});class Xle{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||cdt(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(n,a)=>a=="n"?`
1352
- `:a=="r"?"\r":a=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord}create(){return this.regexp?new xdt(this):new Cdt(this)}getCursor(e,n=0,a){let r=e.doc?e:Hn.create({doc:e});return a==null&&(a=r.doc.length),this.regexp?_b(this,r,n,a):Cb(this,r,n,a)}}class eue{constructor(e){this.spec=e}}function Cb(t,e,n,a){return new wb(e.doc,t.unquoted,n,a,t.caseSensitive?void 0:r=>r.toLowerCase(),t.wholeWord?vdt(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function vdt(t,e){return(n,a,r,i)=>((i>n||i+r.length<a)&&(i=Math.max(0,n-2),r=t.sliceString(i,Math.min(t.length,a+2))),(e(x3(r,n-i))!=Za.Word||e(E3(r,n-i))!=Za.Word)&&(e(E3(r,a-i))!=Za.Word||e(x3(r,a-i))!=Za.Word))}class Cdt extends eue{constructor(e){super(e)}nextMatch(e,n,a){let r=Cb(this.spec,e,a,e.doc.length).nextOverlapping();if(r.done){let i=Math.min(e.doc.length,n+this.spec.unquoted.length);r=Cb(this.spec,e,0,i).nextOverlapping()}return r.done||r.value.from==n&&r.value.to==a?null:r.value}prevMatchInRange(e,n,a){for(let r=a;;){let i=Math.max(n,r-1e4-this.spec.unquoted.length),o=Cb(this.spec,e,i,r),s=null;for(;!o.nextOverlapping().done;)s=o.value;if(s)return s;if(i==n)return null;r-=1e4}}prevMatch(e,n,a){let r=this.prevMatchInRange(e,0,n);return r||(r=this.prevMatchInRange(e,Math.max(0,a-this.spec.unquoted.length),e.doc.length)),r&&(r.from!=n||r.to!=a)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,n){let a=Cb(this.spec,e,0,e.doc.length),r=[];for(;!a.next().done;){if(r.length>=n)return null;r.push(a.value)}return r}highlight(e,n,a,r){let i=Cb(this.spec,e,Math.max(0,n-this.spec.unquoted.length),Math.min(a+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}}function _b(t,e,n,a){return new Kle(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:t.wholeWord?_dt(e.charCategorizer(e.selection.main.head)):void 0},n,a)}function x3(t,e){return t.slice(Ni(t,e,!1),e)}function E3(t,e){return t.slice(e,Ni(t,e))}function _dt(t){return(e,n,a)=>!a[0].length||(t(x3(a.input,a.index))!=Za.Word||t(E3(a.input,a.index))!=Za.Word)&&(t(E3(a.input,a.index+a[0].length))!=Za.Word||t(x3(a.input,a.index+a[0].length))!=Za.Word)}class xdt extends eue{nextMatch(e,n,a){let r=_b(this.spec,e,a,e.doc.length).next();return r.done&&(r=_b(this.spec,e,0,n).next()),r.done?null:r.value}prevMatchInRange(e,n,a){for(let r=1;;r++){let i=Math.max(n,a-r*1e4),o=_b(this.spec,e,i,a),s=null;for(;!o.next().done;)s=o.value;if(s&&(i==n||s.from>i+10))return s;if(i==n)return null}}prevMatch(e,n,a){return this.prevMatchInRange(e,0,n)||this.prevMatchInRange(e,a,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(n,a)=>{if(a=="&")return e.match[0];if(a=="$")return"$";for(let r=a.length;r>0;r--){let i=+a.slice(0,r);if(i>0&&i<e.match.length)return e.match[i]+a.slice(r)}return n})}matchAll(e,n){let a=_b(this.spec,e,0,e.doc.length),r=[];for(;!a.next().done;){if(r.length>=n)return null;r.push(a.value)}return r}highlight(e,n,a,r){let i=_b(this.spec,e,Math.max(0,n-250),Math.min(a+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}}const Y1=Bn.define(),dN=Bn.define(),Am=Mi.define({create(t){return new pN(AN(t).create(),null)},update(t,e){for(let n of e.effects)n.is(Y1)?t=new pN(n.value.create(),t.panel):n.is(dN)&&(t=new pN(t.query,n.value?mN:null));return t},provide:t=>N1.from(t,e=>e.panel)});class pN{constructor(e,n){this.query=e,this.panel=n}}const Edt=ln.mark({class:"cm-searchMatch"}),Bdt=ln.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Idt=Cr.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field(Am))}update(t){let e=t.state.field(Am);(e!=t.startState.field(Am)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return ln.none;let{view:n}=this,a=new xd;for(let r=0,i=n.visibleRanges,o=i.length;r<o;r++){let{from:s,to:l}=i[r];for(;r<o-1&&l>i[r+1].from-2*250;)l=i[++r].to;t.highlight(n.state,s,l,(u,d)=>{let p=n.state.selection.ranges.some(m=>m.from==u&&m.to==d);a.add(u,d,p?Bdt:Edt)})}return a.finish()}},{decorations:t=>t.decorations});function W1(t){return e=>{let n=e.state.field(Am,!1);return n&&n.query.spec.valid?t(e,n):rue(e)}}const B3=W1((t,{query:e})=>{let{to:n}=t.state.selection.main,a=e.nextMatch(t.state,n,n);if(!a)return!1;let r=lt.single(a.from,a.to),i=t.state.facet(vb);return t.dispatch({selection:r,effects:[gN(t,a),i.scrollToMatch(r.main,t)],userEvent:"select.search"}),aue(t),!0}),I3=W1((t,{query:e})=>{let{state:n}=t,{from:a}=n.selection.main,r=e.prevMatch(n,a,a);if(!r)return!1;let i=lt.single(r.from,r.to),o=t.state.facet(vb);return t.dispatch({selection:i,effects:[gN(t,r),o.scrollToMatch(i.main,t)],userEvent:"select.search"}),aue(t),!0}),Ddt=W1((t,{query:e})=>{let n=e.matchAll(t.state,1e3);return!n||!n.length?!1:(t.dispatch({selection:lt.create(n.map(a=>lt.range(a.from,a.to))),userEvent:"select.search.matches"}),!0)}),Qdt=({state:t,dispatch:e})=>{let n=t.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:a,to:r}=n.main,i=[],o=0;for(let s=new wb(t.doc,t.sliceDoc(a,r));!s.next().done;){if(i.length>1e3)return!1;s.value.from==a&&(o=i.length),i.push(lt.range(s.value.from,s.value.to))}return e(t.update({selection:lt.create(i,o),userEvent:"select.search.matches"})),!0},tue=W1((t,{query:e})=>{let{state:n}=t,{from:a,to:r}=n.selection.main;if(n.readOnly)return!1;let i=e.nextMatch(n,a,a);if(!i)return!1;let o=i,s=[],l,u,d=[];o.from==a&&o.to==r&&(u=n.toText(e.getReplacement(o)),s.push({from:o.from,to:o.to,insert:u}),o=e.nextMatch(n,o.from,o.to),d.push(jt.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(a).number)+".")));let p=t.state.changes(s);return o&&(l=lt.single(o.from,o.to).map(p),d.push(gN(t,o)),d.push(n.facet(vb).scrollToMatch(l.main,t))),t.dispatch({changes:p,selection:l,effects:d,userEvent:"input.replace"}),!0}),Sdt=W1((t,{query:e})=>{if(t.state.readOnly)return!1;let n=e.matchAll(t.state,1e9).map(r=>{let{from:i,to:o}=r;return{from:i,to:o,insert:e.getReplacement(r)}});if(!n.length)return!1;let a=t.state.phrase("replaced $ matches",n.length)+".";return t.dispatch({changes:n,effects:jt.announce.of(a),userEvent:"input.replace.all"}),!0});function mN(t){return t.state.facet(vb).createPanel(t)}function AN(t,e){var n,a,r,i,o;let s=t.selection.main,l=s.empty||s.to>s.from+100?"":t.sliceDoc(s.from,s.to);if(e&&!l)return e;let u=t.facet(vb);return new Xle({search:((n=e==null?void 0:e.literal)!==null&&n!==void 0?n:u.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:(a=e==null?void 0:e.caseSensitive)!==null&&a!==void 0?a:u.caseSensitive,literal:(r=e==null?void 0:e.literal)!==null&&r!==void 0?r:u.literal,regexp:(i=e==null?void 0:e.regexp)!==null&&i!==void 0?i:u.regexp,wholeWord:(o=e==null?void 0:e.wholeWord)!==null&&o!==void 0?o:u.wholeWord})}function nue(t){let e=L1(t,mN);return e&&e.dom.querySelector("[main-field]")}function aue(t){let e=nue(t);e&&e==t.root.activeElement&&e.select()}const rue=t=>{let e=t.state.field(Am,!1);if(e&&e.panel){let n=nue(t);if(n&&n!=t.root.activeElement){let a=AN(t.state,e.query.spec);a.valid&&t.dispatch({effects:Y1.of(a)}),n.focus(),n.select()}}else t.dispatch({effects:[dN.of(!0),e?Y1.of(AN(t.state,e.query.spec)):Bn.appendConfig.of(Ndt)]});return!0},iue=t=>{let e=t.state.field(Am,!1);if(!e||!e.panel)return!1;let n=L1(t,mN);return n&&n.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:dN.of(!1)}),!0},Tdt=[{key:"Mod-f",run:rue,scope:"editor search-panel"},{key:"F3",run:B3,shift:I3,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:B3,shift:I3,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:iue,scope:"editor search-panel"},{key:"Mod-Shift-l",run:Qdt},{key:"Mod-Alt-g",run:ldt},{key:"Mod-d",run:kdt,preventDefault:!0}];class Fdt{constructor(e){this.view=e;let n=this.query=e.state.field(Am).query.spec;this.commit=this.commit.bind(this),this.searchField=xa("input",{value:n.search,placeholder:Gs(e,"Find"),"aria-label":Gs(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=xa("input",{value:n.replace,placeholder:Gs(e,"Replace"),"aria-label":Gs(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=xa("input",{type:"checkbox",name:"case",form:"",checked:n.caseSensitive,onchange:this.commit}),this.reField=xa("input",{type:"checkbox",name:"re",form:"",checked:n.regexp,onchange:this.commit}),this.wordField=xa("input",{type:"checkbox",name:"word",form:"",checked:n.wholeWord,onchange:this.commit});function a(r,i,o){return xa("button",{class:"cm-button",name:r,onclick:i,type:"button"},o)}this.dom=xa("div",{onkeydown:r=>this.keydown(r),class:"cm-search"},[this.searchField,a("next",()=>B3(e),[Gs(e,"next")]),a("prev",()=>I3(e),[Gs(e,"previous")]),a("select",()=>Ddt(e),[Gs(e,"all")]),xa("label",null,[this.caseField,Gs(e,"match case")]),xa("label",null,[this.reField,Gs(e,"regexp")]),xa("label",null,[this.wordField,Gs(e,"by word")]),...e.state.readOnly?[]:[xa("br"),this.replaceField,a("replace",()=>tue(e),[Gs(e,"replace")]),a("replaceAll",()=>Sdt(e),[Gs(e,"replace all")])],xa("button",{name:"close",onclick:()=>iue(e),"aria-label":Gs(e,"close"),type:"button"},["×"])])}commit(){let e=new Xle({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:Y1.of(e)}))}keydown(e){Gst(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?I3:B3)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),tue(this.view))}update(e){for(let n of e.transactions)for(let a of n.effects)a.is(Y1)&&!a.value.eq(this.query)&&this.setQuery(a.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(vb).top}}function Gs(t,e){return t.state.phrase(e)}const D3=30,Q3=/[\s\.,:;?!]/;function gN(t,{from:e,to:n}){let a=t.state.doc.lineAt(e),r=t.state.doc.lineAt(n).to,i=Math.max(a.from,e-D3),o=Math.min(r,n+D3),s=t.state.sliceDoc(i,o);if(i!=a.from){for(let l=0;l<D3;l++)if(!Q3.test(s[l+1])&&Q3.test(s[l])){s=s.slice(l);break}}if(o!=r){for(let l=s.length-1;l>s.length-D3;l--)if(!Q3.test(s[l-1])&&Q3.test(s[l])){s=s.slice(0,l);break}}return jt.announce.of(`${t.state.phrase("current match")}. ${s} ${t.state.phrase("on line")} ${a.number}.`)}const Ldt=jt.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"}}),Ndt=[Am,cg.low(Idt),Ldt];class oue{constructor(e,n,a,r){this.state=e,this.pos=n,this.explicit=a,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let n=oo(this.state).resolveInner(this.pos,-1);for(;n&&e.indexOf(n.name)<0;)n=n.parent;return n?{from:n.from,to:this.pos,text:this.state.sliceDoc(n.from,this.pos),type:n.type}:null}matchBefore(e){let n=this.state.doc.lineAt(this.pos),a=Math.max(n.from,this.pos-250),r=n.text.slice(a-n.from,this.pos-n.from),i=r.search(lue(e,!1));return i<0?null:{from:a+i,to:this.pos,text:r.slice(i)}}get aborted(){return this.abortListeners==null}addEventListener(e,n,a){e=="abort"&&this.abortListeners&&(this.abortListeners.push(n),a&&a.onDocChange&&(this.abortOnDocChange=!0))}}function sue(t){let e=Object.keys(t).join(""),n=/\w/.test(e);return n&&(e=e.replace(/\w/g,"")),`[${n?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function Mdt(t){let e=Object.create(null),n=Object.create(null);for(let{label:r}of t){e[r[0]]=!0;for(let i=1;i<r.length;i++)n[r[i]]=!0}let a=sue(e)+sue(n)+"*$";return[new RegExp("^"+a),new RegExp(a)]}function Rdt(t){let e=t.map(r=>typeof r=="string"?{label:r}:r),[n,a]=e.every(r=>/^\w+$/.test(r.label))?[/\w*$/,/\w+$/]:Mdt(e);return r=>{let i=r.matchBefore(a);return i||r.explicit?{from:i?i.from:r.pos,options:e,validFor:n}:null}}let cue=class{constructor(e,n,a,r){this.completion=e,this.source=n,this.match=a,this.score=r}};function fg(t){return t.selection.main.from}function lue(t,e){var n;let{source:a}=t,r=e&&a[0]!="^",i=a[a.length-1]!="$";return!r&&!i?t:new RegExp(`${r?"^":""}(?:${a})${i?"$":""}`,(n=t.flags)!==null&&n!==void 0?n:t.ignoreCase?"i":"")}const uue=lu.define();function $dt(t,e,n,a){let{main:r}=t.selection,i=n-r.from,o=a-r.from;return{...t.changeByRange(s=>{if(s!=r&&n!=a&&t.sliceDoc(s.from+i,s.from+o)!=t.sliceDoc(n,a))return{range:s};let l=t.toText(e);return{changes:{from:s.from+i,to:a==r.from?s.to:s.from+o,insert:l},range:lt.cursor(s.from+i+l.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const due=new WeakMap;function Pdt(t){if(!Array.isArray(t))return t;let e=due.get(t);return e||due.set(t,e=Rdt(t)),e}const S3=Bn.define(),K1=Bn.define();class Odt{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let n=0;n<e.length;){let a=ms(e,n),r=su(a);this.chars.push(a);let i=e.slice(n,n+r),o=i.toUpperCase();this.folded.push(ms(o==i?i.toLowerCase():o,0)),n+=r}this.astral=e.length!=this.chars.length}ret(e,n){return this.score=e,this.matched=n,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:n,folded:a,any:r,precise:i,byWord:o}=this;if(n.length==1){let y=ms(e,0),w=su(y),k=w==e.length?0:-100;if(y!=n[0])if(y==a[0])k+=-200;else return null;return this.ret(k,[0,w])}let s=e.indexOf(this.pattern);if(s==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=n.length,u=0;if(s<0){for(let y=0,w=Math.min(e.length,200);y<w&&u<l;){let k=ms(e,y);(k==n[u]||k==a[u])&&(r[u++]=y),y+=su(k)}if(u<l)return null}let d=0,p=0,m=!1,A=0,g=-1,h=-1,f=/[a-z]/.test(e),b=!0;for(let y=0,w=Math.min(e.length,200),k=0;y<w&&p<l;){let C=ms(e,y);s<0&&(d<l&&C==n[d]&&(i[d++]=y),A<l&&(C==n[A]||C==a[A]?(A==0&&(g=y),h=y+1,A++):A=0));let x,_=C<255?C>=48&&C<=57||C>=97&&C<=122?2:C>=65&&C<=90?1:0:(x=EF(C))!=x.toLowerCase()?1:x!=x.toUpperCase()?2:0;(!y||_==1&&f||k==0&&_!=0)&&(n[p]==C||a[p]==C&&(m=!0)?o[p++]=y:o.length&&(b=!1)),k=_,y+=su(C)}return p==l&&o[0]==0&&b?this.result(-100+(m?-200:0),o,e):A==l&&g==0?this.ret(-200-e.length+(h==e.length?0:-100),[0,h]):s>-1?this.ret(-700-e.length,[s,s+this.pattern.length]):A==l?this.ret(-900-e.length,[g,h]):p==l?this.result(-100+(m?-200:0)+-700+(b?0:-1100),o,e):n.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,n,a){let r=[],i=0;for(let o of n){let s=o+(this.astral?su(ms(a,o)):1);i&&r[i-1]==o?r[i-1]=s:(r[i++]=o,r[i++]=s)}return this.ret(e-a.length,r)}}class jdt{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let n=e.slice(0,this.pattern.length),a=n==this.pattern?0:n.toLowerCase()==this.folded?-200:null;return a==null?null:(this.matched=[0,n.length],this.score=a+(e.length==this.pattern.length?0:-100),this)}}const ki=Ht.define({combine(t){return uu(t,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Gdt,filterStrict:!1,compareCompletions:(e,n)=>e.label.localeCompare(n.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,n)=>e&&n,closeOnBlur:(e,n)=>e&&n,icons:(e,n)=>e&&n,tooltipClass:(e,n)=>a=>pue(e(a),n(a)),optionClass:(e,n)=>a=>pue(e(a),n(a)),addToOptions:(e,n)=>e.concat(n),filterStrict:(e,n)=>e||n})}});function pue(t,e){return t?e?t+" "+e:t:e}function Gdt(t,e,n,a,r,i){let o=t.textDirection==Ra.RTL,s=o,l=!1,u="top",d,p,m=e.left-r.left,A=r.right-e.right,g=a.right-a.left,h=a.bottom-a.top;if(s&&m<Math.min(g,A)?s=!1:!s&&A<Math.min(g,m)&&(s=!0),g<=(s?m:A))d=Math.max(r.top,Math.min(n.top,r.bottom-h))-e.top,p=Math.min(400,s?m:A);else{l=!0,p=Math.min(400,(o?e.right:r.right-e.left)-30);let y=r.bottom-e.bottom;y>=h||y>e.top?d=n.bottom-e.top:(u="bottom",d=e.bottom-n.top)}let f=(e.bottom-e.top)/i.offsetHeight,b=(e.right-e.left)/i.offsetWidth;return{style:`${u}: ${d/f}px; max-width: ${p/b}px`,class:"cm-completionInfo-"+(l?o?"left-narrow":"right-narrow":s?"left":"right")}}function qdt(t){let e=t.addToOptions.slice();return t.icons&&e.push({render(n){let a=document.createElement("div");return a.classList.add("cm-completionIcon"),n.type&&a.classList.add(...n.type.split(/\s+/g).map(r=>"cm-completionIcon-"+r)),a.setAttribute("aria-hidden","true"),a},position:20}),e.push({render(n,a,r,i){let o=document.createElement("span");o.className="cm-completionLabel";let s=n.displayLabel||n.label,l=0;for(let u=0;u<i.length;){let d=i[u++],p=i[u++];d>l&&o.appendChild(document.createTextNode(s.slice(l,d)));let m=o.appendChild(document.createElement("span"));m.appendChild(document.createTextNode(s.slice(d,p))),m.className="cm-completionMatchedText",l=p}return l<s.length&&o.appendChild(document.createTextNode(s.slice(l))),o},position:50},{render(n){if(!n.detail)return null;let a=document.createElement("span");return a.className="cm-completionDetail",a.textContent=n.detail,a},position:80}),e.sort((n,a)=>n.position-a.position).map(n=>n.render)}function hN(t,e,n){if(t<=n)return{from:0,to:t};if(e<0&&(e=0),e<=t>>1){let r=Math.floor(e/n);return{from:r*n,to:(r+1)*n}}let a=Math.floor((t-e)/n);return{from:t-(a+1)*n,to:t-a*n}}class zdt{constructor(e,n,a){this.view=e,this.stateField=n,this.applyCompletion=a,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:l=>this.placeInfo(l),key:this},this.space=null,this.currentClass="";let r=e.state.field(n),{options:i,selected:o}=r.open,s=e.state.facet(ki);this.optionContent=qdt(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=hN(i.length,o,s.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",l=>{let{options:u}=e.state.field(n).open;for(let d=l.target,p;d&&d!=this.dom;d=d.parentNode)if(d.nodeName=="LI"&&(p=/-(\d+)$/.exec(d.id))&&+p[1]<u.length){this.applyCompletion(e,u[+p[1]]),l.preventDefault();return}}),this.dom.addEventListener("focusout",l=>{let u=e.state.field(this.stateField,!1);u&&u.tooltip&&e.state.facet(ki).closeOnBlur&&l.relatedTarget!=e.contentDOM&&e.dispatch({effects:K1.of(null)})}),this.showOptions(i,r.id)}mount(){this.updateSel()}showOptions(e,n){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,n,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var n;let a=e.state.field(this.stateField),r=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),a!=r){let{options:i,selected:o,disabled:s}=a.open;(!r.open||r.open.options!=i)&&(this.range=hN(i.length,o,e.state.facet(ki).maxRenderedOptions),this.showOptions(i,a.id)),this.updateSel(),s!=((n=r.open)===null||n===void 0?void 0:n.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!s)}}updateTooltipClass(e){let n=this.tooltipClass(e);if(n!=this.currentClass){for(let a of this.currentClass.split(" "))a&&this.dom.classList.remove(a);for(let a of n.split(" "))a&&this.dom.classList.add(a);this.currentClass=n}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),n=e.open;(n.selected>-1&&n.selected<this.range.from||n.selected>=this.range.to)&&(this.range=hN(n.options.length,n.selected,this.view.state.facet(ki).maxRenderedOptions),this.showOptions(n.options,e.id));let a=this.updateSelectedOption(n.selected);if(a){this.destroyInfo();let{completion:r}=n.options[n.selected],{info:i}=r;if(!i)return;let o=typeof i=="string"?document.createTextNode(i):i(r);if(!o)return;"then"in o?o.then(s=>{s&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(s,r)}).catch(s=>As(this.view.state,s,"completion info")):(this.addInfoPane(o,r),a.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,n){this.destroyInfo();let a=this.info=document.createElement("div");if(a.className="cm-tooltip cm-completionInfo",a.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)a.appendChild(e),this.infoDestroy=null;else{let{dom:r,destroy:i}=e;a.appendChild(r),this.infoDestroy=i||null}this.dom.appendChild(a),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let n=null;for(let a=this.list.firstChild,r=this.range.from;a;a=a.nextSibling,r++)a.nodeName!="LI"||!a.id?r--:r==e?a.hasAttribute("aria-selected")||(a.setAttribute("aria-selected","true"),n=a):a.hasAttribute("aria-selected")&&(a.removeAttribute("aria-selected"),a.removeAttribute("aria-describedby"));return n&&Udt(this.list,n),n}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let n=this.dom.getBoundingClientRect(),a=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),i=this.space;if(!i){let o=this.dom.ownerDocument.documentElement;i={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return r.top>Math.min(i.bottom,n.bottom)-10||r.bottom<Math.max(i.top,n.top)+10?null:this.view.state.facet(ki).positionInfo(this.view,n,r,a,i,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,n,a){const r=document.createElement("ul");r.id=n,r.setAttribute("role","listbox"),r.setAttribute("aria-expanded","true"),r.setAttribute("aria-label",this.view.state.phrase("Completions")),r.addEventListener("mousedown",o=>{o.target==r&&o.preventDefault()});let i=null;for(let o=a.from;o<a.to;o++){let{completion:s,match:l}=e[o],{section:u}=s;if(u){let m=typeof u=="string"?u:u.name;if(m!=i&&(o>a.from||a.from==0))if(i=m,typeof u!="string"&&u.header)r.appendChild(u.header(u));else{let A=r.appendChild(document.createElement("completion-section"));A.textContent=m}}const d=r.appendChild(document.createElement("li"));d.id=n+"-"+o,d.setAttribute("role","option");let p=this.optionClass(s);p&&(d.className=p);for(let m of this.optionContent){let A=m(s,this.view.state,this.view,l);A&&d.appendChild(A)}}return a.from&&r.classList.add("cm-completionListIncompleteTop"),a.to<e.length&&r.classList.add("cm-completionListIncompleteBottom"),r}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function Hdt(t,e){return n=>new zdt(n,t,e)}function Udt(t,e){let n=t.getBoundingClientRect(),a=e.getBoundingClientRect(),r=n.height/t.offsetHeight;a.top<n.top?t.scrollTop-=(n.top-a.top)/r:a.bottom>n.bottom&&(t.scrollTop+=(a.bottom-n.bottom)/r)}function mue(t){return(t.boost||0)*100+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}function Ydt(t,e){let n=[],a=null,r=null,i=d=>{n.push(d);let{section:p}=d.completion;if(p){a||(a=[]);let m=typeof p=="string"?p:p.name;a.some(A=>A.name==m)||a.push(typeof p=="string"?{name:m}:p)}},o=e.facet(ki);for(let d of t)if(d.hasResult()){let p=d.result.getMatch;if(d.result.filter===!1)for(let m of d.result.options)i(new cue(m,d.source,p?p(m):[],1e9-n.length));else{let m=e.sliceDoc(d.from,d.to),A,g=o.filterStrict?new jdt(m):new Odt(m);for(let h of d.result.options)if(A=g.match(h.label)){let f=h.displayLabel?p?p(h,A.matched):[]:A.matched,b=A.score+(h.boost||0);if(i(new cue(h,d.source,f,b)),typeof h.section=="object"&&h.section.rank==="dynamic"){let{name:y}=h.section;r||(r=Object.create(null)),r[y]=Math.max(b,r[y]||-1e9)}}}}if(a){let d=Object.create(null),p=0,m=(A,g)=>(A.rank==="dynamic"&&g.rank==="dynamic"?r[g.name]-r[A.name]:0)||(typeof A.rank=="number"?A.rank:1e9)-(typeof g.rank=="number"?g.rank:1e9)||(A.name<g.name?-1:1);for(let A of a.sort(m))p-=1e5,d[A.name]=p;for(let A of n){let{section:g}=A.completion;g&&(A.score+=d[typeof g=="string"?g:g.name])}}let s=[],l=null,u=o.compareCompletions;for(let d of n.sort((p,m)=>m.score-p.score||u(p.completion,m.completion))){let p=d.completion;!l||l.label!=p.label||l.detail!=p.detail||l.type!=null&&p.type!=null&&l.type!=p.type||l.apply!=p.apply||l.boost!=p.boost?s.push(d):mue(d.completion)>mue(l)&&(s[s.length-1]=d),l=d.completion}return s}class xb{constructor(e,n,a,r,i,o){this.options=e,this.attrs=n,this.tooltip=a,this.timestamp=r,this.selected=i,this.disabled=o}setSelected(e,n){return e==this.selected||e>=this.options.length?this:new xb(this.options,Aue(n,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,n,a,r,i,o){if(r&&!o&&e.some(u=>u.isPending))return r.setDisabled();let s=Ydt(e,n);if(!s.length)return r&&e.some(u=>u.isPending)?r.setDisabled():null;let l=n.facet(ki).selectOnOpen?0:-1;if(r&&r.selected!=l&&r.selected!=-1){let u=r.options[r.selected].completion;for(let d=0;d<s.length;d++)if(s[d].completion==u){l=d;break}}return new xb(s,Aue(a,l),{pos:e.reduce((u,d)=>d.hasResult()?Math.min(u,d.from):u,1e8),create:Xdt,above:i.aboveCursor},r?r.timestamp:Date.now(),l,!1)}map(e){return new xb(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new xb(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class T3{constructor(e,n,a){this.active=e,this.id=n,this.open=a}static start(){return new T3(Vdt,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:n}=e,a=n.facet(ki),i=(a.override||n.languageDataAt("autocomplete",fg(n)).map(Pdt)).map(l=>(this.active.find(d=>d.source==l)||new Bc(l,this.active.some(d=>d.state!=0)?1:0)).update(e,a));i.length==this.active.length&&i.every((l,u)=>l==this.active[u])&&(i=this.active);let o=this.open,s=e.effects.some(l=>l.is(fN));o&&e.docChanged&&(o=o.map(e.changes)),e.selection||i.some(l=>l.hasResult()&&e.changes.touchesRange(l.from,l.to))||!Wdt(i,this.active)||s?o=xb.build(i,n,this.id,o,a,s):o&&o.disabled&&!i.some(l=>l.isPending)&&(o=null),!o&&i.every(l=>!l.isPending)&&i.some(l=>l.hasResult())&&(i=i.map(l=>l.hasResult()?new Bc(l.source,0):l));for(let l of e.effects)l.is(hue)&&(o=o&&o.setSelected(l.value,this.id));return i==this.active&&o==this.open?this:new T3(i,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Kdt:Zdt}}function Wdt(t,e){if(t==e)return!0;for(let n=0,a=0;;){for(;n<t.length&&!t[n].hasResult();)n++;for(;a<e.length&&!e[a].hasResult();)a++;let r=n==t.length,i=a==e.length;if(r||i)return r==i;if(t[n++].result!=e[a++].result)return!1}}const Kdt={"aria-autocomplete":"list"},Zdt={};function Aue(t,e){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(n["aria-activedescendant"]=t+"-"+e),n}const Vdt=[];function gue(t,e){if(t.isUserEvent("input.complete")){let a=t.annotation(uue);if(a&&e.activateOnCompletion(a))return 12}let n=t.isUserEvent("input.type");return n&&e.activateOnTyping?5:n?1:t.isUserEvent("delete.backward")?2:t.selection?8:t.docChanged?16:0}class Bc{constructor(e,n,a=!1){this.source=e,this.state=n,this.explicit=a}hasResult(){return!1}get isPending(){return this.state==1}update(e,n){let a=gue(e,n),r=this;(a&8||a&16&&this.touches(e))&&(r=new Bc(r.source,0)),a&4&&r.state==0&&(r=new Bc(this.source,1)),r=r.updateFor(e,a);for(let i of e.effects)if(i.is(S3))r=new Bc(r.source,1,i.value);else if(i.is(K1))r=new Bc(r.source,0);else if(i.is(fN))for(let o of i.value)o.source==r.source&&(r=o);return r}updateFor(e,n){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(fg(e.state))}}class Eb extends Bc{constructor(e,n,a,r,i,o){super(e,3,n),this.limit=a,this.result=r,this.from=i,this.to=o}hasResult(){return!0}updateFor(e,n){var a;if(!(n&3))return this.map(e.changes);let r=this.result;r.map&&!e.changes.empty&&(r=r.map(r,e.changes));let i=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),s=fg(e.state);if(s>o||!r||n&2&&(fg(e.startState)==this.from||s<this.limit))return new Bc(this.source,n&4?1:0);let l=e.changes.mapPos(this.limit);return Jdt(r.validFor,e.state,i,o)?new Eb(this.source,this.explicit,l,r,i,o):r.update&&(r=r.update(r,i,o,new oue(e.state,s,!1)))?new Eb(this.source,this.explicit,l,r,r.from,(a=r.to)!==null&&a!==void 0?a:fg(e.state)):new Bc(this.source,1,this.explicit)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new Eb(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new Bc(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}function Jdt(t,e,n,a){if(!t)return!1;let r=e.sliceDoc(n,a);return typeof t=="function"?t(r,n,a,e):lue(t,!0).test(r)}const fN=Bn.define({map(t,e){return t.map(n=>n.map(e))}}),hue=Bn.define(),fs=Mi.define({create(){return T3.start()},update(t,e){return t.update(e)},provide:t=>[SL.from(t,e=>e.tooltip),jt.contentAttributes.from(t,e=>e.attrs)]});function bN(t,e){const n=e.completion.apply||e.completion.label;let a=t.state.field(fs).active.find(r=>r.source==e.source);return a instanceof Eb?(typeof n=="string"?t.dispatch({...$dt(t.state,n,a.from,a.to),annotations:uue.of(e.completion)}):n(t,e.completion,a.from,a.to),!0):!1}const Xdt=Hdt(fs,bN);function F3(t,e="option"){return n=>{let a=n.state.field(fs,!1);if(!a||!a.open||a.open.disabled||Date.now()-a.open.timestamp<n.state.facet(ki).interactionDelay)return!1;let r=1,i;e=="page"&&(i=mce(n,a.open.tooltip))&&(r=Math.max(2,Math.floor(i.dom.offsetHeight/i.dom.querySelector("li").offsetHeight)-1));let{length:o}=a.open.options,s=a.open.selected>-1?a.open.selected+r*(t?1:-1):t?0:o-1;return s<0?s=e=="page"?0:o-1:s>=o&&(s=e=="page"?o-1:0),n.dispatch({effects:hue.of(s)}),!0}}const ept=t=>{let e=t.state.field(fs,!1);return t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(ki).interactionDelay?!1:bN(t,e.open.options[e.open.selected])},yN=t=>t.state.field(fs,!1)?(t.dispatch({effects:S3.of(!0)}),!0):!1,tpt=t=>{let e=t.state.field(fs,!1);return!e||!e.active.some(n=>n.state!=0)?!1:(t.dispatch({effects:K1.of(null)}),!0)};class npt{constructor(e,n){this.active=e,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const apt=50,rpt=1e3,ipt=Cr.fromClass(class{constructor(t){this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of t.state.field(fs).active)e.isPending&&this.startQuery(e)}update(t){let e=t.state.field(fs),n=t.state.facet(ki);if(!t.selectionSet&&!t.docChanged&&t.startState.field(fs)==e)return;let a=t.transactions.some(i=>{let o=gue(i,n);return o&8||(i.selection||i.docChanged)&&!(o&3)});for(let i=0;i<this.running.length;i++){let o=this.running[i];if(a||o.context.abortOnDocChange&&t.docChanged||o.updates.length+t.transactions.length>apt&&Date.now()-o.time>rpt){for(let s of o.context.abortListeners)try{s()}catch(l){As(this.view.state,l)}o.context.abortListeners=null,this.running.splice(i--,1)}else o.updates.push(...t.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some(i=>i.effects.some(o=>o.is(S3)))&&(this.pendingStart=!0);let r=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(i=>i.isPending&&!this.running.some(o=>o.active.source==i.source))?setTimeout(()=>this.startUpdate(),r):-1,this.composing!=0)for(let i of t.transactions)i.isUserEvent("input.type")?this.composing=2:this.composing==2&&i.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:t}=this.view,e=t.field(fs);for(let n of e.active)n.isPending&&!this.running.some(a=>a.active.source==n.source)&&this.startQuery(n);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(ki).updateSyncTime))}startQuery(t){let{state:e}=this.view,n=fg(e),a=new oue(e,n,t.explicit,this.view),r=new npt(t,a);this.running.push(r),Promise.resolve(t.source(a)).then(i=>{r.context.aborted||(r.done=i||null,this.scheduleAccept())},i=>{this.view.dispatch({effects:K1.of(null)}),As(this.view.state,i)})}scheduleAccept(){this.running.every(t=>t.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(ki).updateSyncTime))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],n=this.view.state.facet(ki),a=this.view.state.field(fs);for(let r=0;r<this.running.length;r++){let i=this.running[r];if(i.done===void 0)continue;if(this.running.splice(r--,1),i.done){let s=fg(i.updates.length?i.updates[0].startState:this.view.state),l=Math.min(s,i.done.from+(i.active.explicit?0:1)),u=new Eb(i.active.source,i.active.explicit,l,i.done,i.done.from,(t=i.done.to)!==null&&t!==void 0?t:s);for(let d of i.updates)u=u.update(d,n);if(u.hasResult()){e.push(u);continue}}let o=a.active.find(s=>s.source==i.active.source);if(o&&o.isPending)if(i.done==null){let s=new Bc(i.active.source,0);for(let l of i.updates)s=s.update(l,n);s.isPending||e.push(s)}else this.startQuery(o)}(e.length||a.open&&a.open.disabled)&&this.view.dispatch({effects:fN.of(e)})}},{eventHandlers:{blur(t){let e=this.view.state.field(fs,!1);if(e&&e.tooltip&&this.view.state.facet(ki).closeOnBlur){let n=e.open&&mce(this.view,e.open.tooltip);(!n||!n.dom.contains(t.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:K1.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:S3.of(!1)}),20),this.composing=0}}}),opt=typeof navigator=="object"&&/Win/.test(navigator.platform),spt=cg.highest(jt.domEventHandlers({keydown(t,e){let n=e.state.field(fs,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||t.key.length>1||t.ctrlKey&&!(opt&&t.altKey)||t.metaKey)return!1;let a=n.open.options[n.open.selected],r=n.active.find(o=>o.source==a.source),i=a.completion.commitCharacters||r.result.commitCharacters;return i&&i.indexOf(t.key)>-1&&bN(e,a),!1}})),cpt=jt.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),Z1={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},bg=Bn.define({map(t,e){let n=e.mapPos(t,-1,Mo.TrackAfter);return n??void 0}}),wN=new class extends lg{};wN.startSide=1,wN.endSide=-1;const fue=Mi.define({create(){return ta.empty},update(t,e){if(t=t.map(e.changes),e.selection){let n=e.state.doc.lineAt(e.selection.main.head);t=t.update({filter:a=>a>=n.from&&a<=n.to})}for(let n of e.effects)n.is(bg)&&(t=t.update({add:[wN.range(n.value,n.value+1)]}));return t}});function lpt(){return[dpt,fue]}const kN="()[]{}<>«»»«[]{}";function bue(t){for(let e=0;e<kN.length;e+=2)if(kN.charCodeAt(e)==t)return kN.charAt(e+1);return EF(t<128?t:t+1)}function yue(t,e){return t.languageDataAt("closeBrackets",e)[0]||Z1}const upt=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),dpt=jt.inputHandler.of((t,e,n,a)=>{if((upt?t.composing:t.compositionStarted)||t.state.readOnly)return!1;let r=t.state.selection.main;if(a.length>2||a.length==2&&su(ms(a,0))==1||e!=r.from||n!=r.to)return!1;let i=mpt(t.state,a);return i?(t.dispatch(i),!0):!1}),ppt=[{key:"Backspace",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let a=yue(t,t.selection.main.head).brackets||Z1.brackets,r=null,i=t.changeByRange(o=>{if(o.empty){let s=Apt(t.doc,o.head);for(let l of a)if(l==s&&L3(t.doc,o.head)==bue(ms(l,0)))return{changes:{from:o.head-l.length,to:o.head+l.length},range:lt.cursor(o.head-l.length)}}return{range:r=o}});return r||e(t.update(i,{scrollIntoView:!0,userEvent:"delete.backward"})),!r}}];function mpt(t,e){let n=yue(t,t.selection.main.head),a=n.brackets||Z1.brackets;for(let r of a){let i=bue(ms(r,0));if(e==r)return i==r?fpt(t,r,a.indexOf(r+r+r)>-1,n):gpt(t,r,i,n.before||Z1.before);if(e==i&&wue(t,t.selection.main.from))return hpt(t,r,i)}return null}function wue(t,e){let n=!1;return t.field(fue).between(0,t.doc.length,a=>{a==e&&(n=!0)}),n}function L3(t,e){let n=t.sliceString(e,e+2);return n.slice(0,su(ms(n,0)))}function Apt(t,e){let n=t.sliceString(e-2,e);return su(ms(n,0))==n.length?n:n.slice(1)}function gpt(t,e,n,a){let r=null,i=t.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:n,from:o.to}],effects:bg.of(o.to+e.length),range:lt.range(o.anchor+e.length,o.head+e.length)};let s=L3(t.doc,o.head);return!s||/\s/.test(s)||a.indexOf(s)>-1?{changes:{insert:e+n,from:o.head},effects:bg.of(o.head+e.length),range:lt.cursor(o.head+e.length)}:{range:r=o}});return r?null:t.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function hpt(t,e,n){let a=null,r=t.changeByRange(i=>i.empty&&L3(t.doc,i.head)==n?{changes:{from:i.head,to:i.head+n.length,insert:n},range:lt.cursor(i.head+n.length)}:a={range:i});return a?null:t.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function fpt(t,e,n,a){let r=a.stringPrefixes||Z1.stringPrefixes,i=null,o=t.changeByRange(s=>{if(!s.empty)return{changes:[{insert:e,from:s.from},{insert:e,from:s.to}],effects:bg.of(s.to+e.length),range:lt.range(s.anchor+e.length,s.head+e.length)};let l=s.head,u=L3(t.doc,l),d;if(u==e){if(kue(t,l))return{changes:{insert:e+e,from:l},effects:bg.of(l+e.length),range:lt.cursor(l+e.length)};if(wue(t,l)){let m=n&&t.sliceDoc(l,l+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:l,to:l+m.length,insert:m},range:lt.cursor(l+m.length)}}}else{if(n&&t.sliceDoc(l-2*e.length,l)==e+e&&(d=vue(t,l-2*e.length,r))>-1&&kue(t,d))return{changes:{insert:e+e+e+e,from:l},effects:bg.of(l+e.length),range:lt.cursor(l+e.length)};if(t.charCategorizer(l)(u)!=Za.Word&&vue(t,l,r)>-1&&!bpt(t,l,e,r))return{changes:{insert:e+e,from:l},effects:bg.of(l+e.length),range:lt.cursor(l+e.length)}}return{range:i=s}});return i?null:t.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function kue(t,e){let n=oo(t).resolveInner(e+1);return n.parent&&n.from==e}function bpt(t,e,n,a){let r=oo(t).resolveInner(e,-1),i=a.reduce((o,s)=>Math.max(o,s.length),0);for(let o=0;o<5;o++){let s=t.sliceDoc(r.from,Math.min(r.to,r.from+n.length+i)),l=s.indexOf(n);if(!l||l>-1&&a.indexOf(s.slice(0,l))>-1){let d=r.firstChild;for(;d&&d.from==r.from&&d.to-d.from>n.length+l;){if(t.sliceDoc(d.to-n.length,d.to)==n)return!1;d=d.firstChild}return!0}let u=r.to==e&&r.parent;if(!u)break;r=u}return!1}function vue(t,e,n){let a=t.charCategorizer(e);if(a(t.sliceDoc(e-1,e))!=Za.Word)return e;for(let r of n){let i=e-r.length;if(t.sliceDoc(i,e)==r&&a(t.sliceDoc(i-1,i))!=Za.Word)return i}return-1}function ypt(t={}){return[spt,fs,ki.of(t),ipt,wpt,cpt]}const Cue=[{key:"Ctrl-Space",run:yN},{mac:"Alt-`",run:yN},{mac:"Alt-i",run:yN},{key:"Escape",run:tpt},{key:"ArrowDown",run:F3(!0)},{key:"ArrowUp",run:F3(!1)},{key:"PageDown",run:F3(!0,"page")},{key:"PageUp",run:F3(!1,"page")},{key:"Enter",run:ept}],wpt=cg.highest(K2.computeN([ki],t=>t.facet(ki).defaultKeymap?[Cue]:[]));class _ue{constructor(e,n,a){this.from=e,this.to=n,this.diagnostic=a}}class yg{constructor(e,n,a){this.diagnostics=e,this.panel=n,this.selected=a}static init(e,n,a){let r=a.facet(V1).markerFilter;r&&(e=r(e,a));let i=e.slice().sort((A,g)=>A.from-g.from||A.to-g.to),o=new xd,s=[],l=0,u=a.doc.iter(),d=0,p=a.doc.length;for(let A=0;;){let g=A==i.length?null:i[A];if(!g&&!s.length)break;let h,f;if(s.length)h=l,f=s.reduce((w,k)=>Math.min(w,k.to),g&&g.from>h?g.from:1e8);else{if(h=g.from,h>p)break;f=g.to,s.push(g),A++}for(;A<i.length;){let w=i[A];if(w.from==h&&(w.to>w.from||w.to==h))s.push(w),A++,f=Math.min(w.to,f);else{f=Math.min(w.from,f);break}}f=Math.min(f,p);let b=!1;if(s.some(w=>w.from==h&&(w.to==f||f==p))&&(b=h==f,!b&&f-h<10)){let w=h-(d+u.value.length);w>0&&(u.next(w),d=h);for(let k=h;;){if(k>=f){b=!0;break}if(!u.lineBreak&&d+u.value.length>k)break;k=d+u.value.length,d+=u.value.length,u.next()}}let y=Tpt(s);if(b)o.add(h,h,ln.widget({widget:new Ipt(y),diagnostics:s.slice()}));else{let w=s.reduce((k,C)=>C.markClass?k+" "+C.markClass:k,"");o.add(h,f,ln.mark({class:"cm-lintRange cm-lintRange-"+y+w,diagnostics:s.slice(),inclusiveEnd:s.some(k=>k.to>f)}))}if(l=f,l==p)break;for(let w=0;w<s.length;w++)s[w].to<=l&&s.splice(w--,1)}let m=o.finish();return new yg(m,n,Bb(m))}}function Bb(t,e=null,n=0){let a=null;return t.between(n,1e9,(r,i,{spec:o})=>{if(!(e&&o.diagnostics.indexOf(e)<0))if(!a)a=new _ue(r,i,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(a.diagnostic)<0)return!1;a=new _ue(a.from,i,a.diagnostic)}}),a}function kpt(t,e){let n=e.pos,a=e.end||n,r=t.state.facet(V1).hideOn(t,n,a);if(r!=null)return r;let i=t.startState.doc.lineAt(e.pos);return!!(t.effects.some(o=>o.is(xue))||t.changes.touchesRange(i.from,Math.max(i.to,a)))}function vpt(t,e){return t.field(qs,!1)?e:e.concat(Bn.appendConfig.of(Fpt))}const xue=Bn.define(),vN=Bn.define(),Eue=Bn.define(),qs=Mi.define({create(){return new yg(ln.none,null,null)},update(t,e){if(e.docChanged&&t.diagnostics.size){let n=t.diagnostics.map(e.changes),a=null,r=t.panel;if(t.selected){let i=e.changes.mapPos(t.selected.from,1);a=Bb(n,t.selected.diagnostic,i)||Bb(n,null,i)}!n.size&&r&&e.state.facet(V1).autoPanel&&(r=null),t=new yg(n,r,a)}for(let n of e.effects)if(n.is(xue)){let a=e.state.facet(V1).autoPanel?n.value.length?J1.open:null:t.panel;t=yg.init(n.value,a,e.state)}else n.is(vN)?t=new yg(t.diagnostics,n.value?J1.open:null,t.selected):n.is(Eue)&&(t=new yg(t.diagnostics,t.panel,n.value));return t},provide:t=>[N1.from(t,e=>e.panel),jt.decorations.from(t,e=>e.diagnostics)]}),Cpt=ln.mark({class:"cm-lintRange cm-lintRange-active"});function _pt(t,e,n){let{diagnostics:a}=t.state.field(qs),r,i=-1,o=-1;a.between(e-(n<0?1:0),e+(n>0?1:0),(l,u,{spec:d})=>{if(e>=l&&e<=u&&(l==u||(e>l||n>0)&&(e<u||n<0)))return r=d.diagnostics,i=l,o=u,!1});let s=t.state.facet(V1).tooltipFilter;return r&&s&&(r=s(r,t.state)),r?{pos:i,end:o,above:t.state.doc.lineAt(i).to<o,create(){return{dom:xpt(t,r)}}}:null}function xpt(t,e){return xa("ul",{class:"cm-tooltip-lint"},e.map(n=>Que(t,n,!1)))}const Ept=t=>{let e=t.state.field(qs,!1);(!e||!e.panel)&&t.dispatch({effects:vpt(t.state,[vN.of(!0)])});let n=L1(t,J1.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},Bue=t=>{let e=t.state.field(qs,!1);return!e||!e.panel?!1:(t.dispatch({effects:vN.of(!1)}),!0)},Bpt=[{key:"Mod-Shift-m",run:Ept,preventDefault:!0},{key:"F8",run:t=>{let e=t.state.field(qs,!1);if(!e)return!1;let n=t.state.selection.main,a=e.diagnostics.iter(n.to+1);return!a.value&&(a=e.diagnostics.iter(0),!a.value||a.from==n.from&&a.to==n.to)?!1:(t.dispatch({selection:{anchor:a.from,head:a.to},scrollIntoView:!0}),!0)}}],V1=Ht.define({combine(t){return{sources:t.map(e=>e.source).filter(e=>e!=null),...uu(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:Iue,tooltipFilter:Iue,needsRefresh:(e,n)=>e?n?a=>e(a)||n(a):e:n,hideOn:(e,n)=>e?n?(a,r,i)=>e(a,r,i)||n(a,r,i):e:n,autoPanel:(e,n)=>e||n})}}});function Iue(t,e){return t?e?(n,a)=>e(t(n,a),a):t:e}function Due(t){let e=[];if(t)e:for(let{name:n}of t){for(let a=0;a<n.length;a++){let r=n[a];if(/[a-zA-Z]/.test(r)&&!e.some(i=>i.toLowerCase()==r.toLowerCase())){e.push(r);continue e}}e.push("")}return e}function Que(t,e,n){var a;let r=n?Due(e.actions):[];return xa("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},xa("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),(a=e.actions)===null||a===void 0?void 0:a.map((i,o)=>{let s=!1,l=A=>{if(A.preventDefault(),s)return;s=!0;let g=Bb(t.state.field(qs).diagnostics,e);g&&i.apply(t,g.from,g.to)},{name:u}=i,d=r[o]?u.indexOf(r[o]):-1,p=d<0?u:[u.slice(0,d),xa("u",u.slice(d,d+1)),u.slice(d+1)],m=i.markClass?" "+i.markClass:"";return xa("button",{type:"button",class:"cm-diagnosticAction"+m,onclick:l,onmousedown:l,"aria-label":` Action: ${u}${d<0?"":` (access key "${r[o]})"`}.`},p)}),e.source&&xa("div",{class:"cm-diagnosticSource"},e.source))}class Ipt extends Bd{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return xa("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class Sue{constructor(e,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=Que(e,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class J1{constructor(e){this.view=e,this.items=[];let n=r=>{if(r.keyCode==27)Bue(this.view),this.view.focus();else if(r.keyCode==38||r.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(r.keyCode==40||r.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(r.keyCode==36)this.moveSelection(0);else if(r.keyCode==35)this.moveSelection(this.items.length-1);else if(r.keyCode==13)this.view.focus();else if(r.keyCode>=65&&r.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:i}=this.items[this.selectedIndex],o=Due(i.actions);for(let s=0;s<o.length;s++)if(o[s].toUpperCase().charCodeAt(0)==r.keyCode){let l=Bb(this.view.state.field(qs).diagnostics,i);l&&i.actions[s].apply(e,l.from,l.to)}}else return;r.preventDefault()},a=r=>{for(let i=0;i<this.items.length;i++)this.items[i].dom.contains(r.target)&&this.moveSelection(i)};this.list=xa("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:n,onclick:a}),this.dom=xa("div",{class:"cm-panel-lint"},this.list,xa("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>Bue(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(qs).selected;if(!e)return-1;for(let n=0;n<this.items.length;n++)if(this.items[n].diagnostic==e.diagnostic)return n;return-1}update(){let{diagnostics:e,selected:n}=this.view.state.field(qs),a=0,r=!1,i=null,o=new Set;for(e.between(0,this.view.state.doc.length,(s,l,{spec:u})=>{for(let d of u.diagnostics){if(o.has(d))continue;o.add(d);let p=-1,m;for(let A=a;A<this.items.length;A++)if(this.items[A].diagnostic==d){p=A;break}p<0?(m=new Sue(this.view,d),this.items.splice(a,0,m),r=!0):(m=this.items[p],p>a&&(this.items.splice(a,p-a),r=!0)),n&&m.diagnostic==n.diagnostic?m.dom.hasAttribute("aria-selected")||(m.dom.setAttribute("aria-selected","true"),i=m):m.dom.hasAttribute("aria-selected")&&m.dom.removeAttribute("aria-selected"),a++}});a<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new Sue(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),r=!0),i?(this.list.setAttribute("aria-activedescendant",i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:s,panel:l})=>{let u=l.height/this.list.offsetHeight;s.top<l.top?this.list.scrollTop-=(l.top-s.top)/u:s.bottom>l.bottom&&(this.list.scrollTop+=(s.bottom-l.bottom)/u)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),r&&this.sync()}sync(){let e=this.list.firstChild;function n(){let a=e;e=a.nextSibling,a.remove()}for(let a of this.items)if(a.dom.parentNode==this.list){for(;e!=a.dom;)n();e=a.dom.nextSibling}else this.list.insertBefore(a.dom,e);for(;e;)n()}moveSelection(e){if(this.selectedIndex<0)return;let n=this.view.state.field(qs),a=Bb(n.diagnostics,this.items[e].diagnostic);a&&this.view.dispatch({selection:{anchor:a.from,head:a.to},scrollIntoView:!0,effects:Eue.of(a)})}static open(e){return new J1(e)}}function Dpt(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(t)}</svg>')`}function N3(t){return Dpt(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${t}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const Qpt=jt.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:N3("#d11")},".cm-lintRange-warning":{backgroundImage:N3("orange")},".cm-lintRange-info":{backgroundImage:N3("#999")},".cm-lintRange-hint":{backgroundImage:N3("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});function Spt(t){return t=="error"?4:t=="warning"?3:t=="info"?2:1}function Tpt(t){let e="hint",n=1;for(let a of t){let r=Spt(a.severity);r>n&&(n=r,e=a.severity)}return e}const Fpt=[qs,jt.decorations.compute([qs],t=>{let{selected:e,panel:n}=t.field(qs);return!e||!n||e.from==e.to?ln.none:ln.set([Cpt.range(e.from,e.to)])}),Qct(_pt,{hideOn:kpt}),Qpt];var Tue=function(e){e===void 0&&(e={});var{crosshairCursor:n=!1}=e,a=[];e.closeBracketsKeymap!==!1&&(a=a.concat(ppt)),e.defaultKeymap!==!1&&(a=a.concat(odt)),e.searchKeymap!==!1&&(a=a.concat(Tdt)),e.historyKeymap!==!1&&(a=a.concat(mut)),e.foldKeymap!==!1&&(a=a.concat(Ilt)),e.completionKeymap!==!1&&(a=a.concat(Cue)),e.lintKeymap!==!1&&(a=a.concat(Bpt));var r=[];return e.lineNumbers!==!1&&r.push(jct()),e.highlightActiveLineGutter!==!1&&r.push(zct()),e.highlightSpecialChars!==!1&&r.push(ict()),e.history!==!1&&r.push(rut()),e.foldGutter!==!1&&r.push(Tlt()),e.drawSelection!==!1&&r.push(Wst()),e.dropCursor!==!1&&r.push(Xst()),e.allowMultipleSelections!==!1&&r.push(Hn.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&r.push(wlt()),e.syntaxHighlighting!==!1&&r.push(Xce(Mlt,{fallback:!0})),e.bracketMatching!==!1&&r.push(Glt()),e.closeBrackets!==!1&&r.push(lpt()),e.autocompletion!==!1&&r.push(ypt()),e.rectangularSelection!==!1&&r.push(yct()),n!==!1&&r.push(vct()),e.highlightActiveLine!==!1&&r.push(dct()),e.highlightSelectionMatches!==!1&&r.push(mdt()),e.tabSize&&typeof e.tabSize=="number"&&r.push(p3.of(" ".repeat(e.tabSize))),r.concat([K2.of(a.flat())]).filter(Boolean)};const Lpt="#e5c07b",Fue="#e06c75",Npt="#56b6c2",Mpt="#ffffff",M3="#abb2bf",CN="#7d8799",Rpt="#61afef",$pt="#98c379",Lue="#d19a66",Ppt="#c678dd",Opt="#21252b",Nue="#2c313a",Mue="#282c34",_N="#353a42",jpt="#3E4451",Rue="#528bff",Gpt=jt.theme({"&":{color:M3,backgroundColor:Mue},".cm-content":{caretColor:Rue},".cm-cursor, .cm-dropCursor":{borderLeftColor:Rue},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:jpt},".cm-panels":{backgroundColor:Opt,color:M3},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:Mue,color:CN,border:"none"},".cm-activeLineGutter":{backgroundColor:Nue},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:_N},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:_N,borderBottomColor:_N},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:Nue,color:M3}}},{dark:!0}),qpt=q1.define([{tag:Xe.keyword,color:Ppt},{tag:[Xe.name,Xe.deleted,Xe.character,Xe.propertyName,Xe.macroName],color:Fue},{tag:[Xe.function(Xe.variableName),Xe.labelName],color:Rpt},{tag:[Xe.color,Xe.constant(Xe.name),Xe.standard(Xe.name)],color:Lue},{tag:[Xe.definition(Xe.name),Xe.separator],color:M3},{tag:[Xe.typeName,Xe.className,Xe.number,Xe.changed,Xe.annotation,Xe.modifier,Xe.self,Xe.namespace],color:Lpt},{tag:[Xe.operator,Xe.operatorKeyword,Xe.url,Xe.escape,Xe.regexp,Xe.link,Xe.special(Xe.string)],color:Npt},{tag:[Xe.meta,Xe.comment],color:CN},{tag:Xe.strong,fontWeight:"bold"},{tag:Xe.emphasis,fontStyle:"italic"},{tag:Xe.strikethrough,textDecoration:"line-through"},{tag:Xe.link,color:CN,textDecoration:"underline"},{tag:Xe.heading,fontWeight:"bold",color:Fue},{tag:[Xe.atom,Xe.bool,Xe.special(Xe.variableName)],color:Lue},{tag:[Xe.processingInstruction,Xe.string,Xe.inserted],color:$pt},{tag:Xe.invalid,color:Mpt}]),zpt=[Gpt,Xce(qpt)];var Hpt=jt.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),Upt=function(e){e===void 0&&(e={});var{indentWithTab:n=!0,editable:a=!0,readOnly:r=!1,theme:i="light",placeholder:o="",basicSetup:s=!0}=e,l=[];switch(n&&l.unshift(K2.of([sdt])),s&&(typeof s=="boolean"?l.unshift(Tue()):l.unshift(Tue(s))),o&&l.unshift(gct(o)),i){case"light":l.push(Hpt);break;case"dark":l.push(zpt);break;case"none":break;default:l.push(i);break}return a===!1&&l.push(jt.editable.of(!1)),r&&l.push(Hn.readOnly.of(!0)),[...l]},Ypt=t=>({line:t.state.doc.lineAt(t.state.selection.main.from),lineCount:t.state.doc.lines,lineBreak:t.state.lineBreak,length:t.state.doc.length,readOnly:t.state.readOnly,tabSize:t.state.tabSize,selection:t.state.selection,selectionAsSingle:t.state.selection.asSingle().main,ranges:t.state.selection.ranges,selectionCode:t.state.sliceDoc(t.state.selection.main.from,t.state.selection.main.to),selections:t.state.selection.ranges.map(e=>t.state.sliceDoc(e.from,e.to)),selectedText:t.state.selection.ranges.some(e=>!e.empty)});class Wpt{constructor(e,n){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=n,this.timeoutMS=n,this.callbacks.push(e)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var e=this.callbacks.slice();this.callbacks.length=0,e.forEach(n=>{try{n()}catch(a){console.error("TimeoutLatch callback error:",a)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}}class $ue{constructor(){this.interval=null,this.latches=new Set}add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}}var xN=null,Kpt=()=>typeof window>"u"?new $ue:(xN||(xN=new $ue),xN),Pue=lu.define(),Zpt=200,Vpt=[];function Jpt(t){var{value:e,selection:n,onChange:a,onStatistics:r,onCreateEditor:i,onUpdate:o,extensions:s=Vpt,autoFocus:l,theme:u="light",height:d=null,minHeight:p=null,maxHeight:m=null,width:A=null,minWidth:g=null,maxWidth:h=null,placeholder:f="",editable:b=!0,readOnly:y=!1,indentWithTab:w=!0,basicSetup:k=!0,root:C,initialState:x}=t,[_,E]=he.useState(),[D,Q]=he.useState(),[B,T]=he.useState(),N=he.useState(()=>({current:null}))[0],I=he.useState(()=>({current:null}))[0],S=jt.theme({"&":{height:d,minHeight:p,maxHeight:m,width:A,minWidth:g,maxWidth:h},"& .cm-scroller":{height:"100% !important"}}),M=jt.updateListener.of(R=>{if(R.docChanged&&typeof a=="function"&&!R.transactions.some(q=>q.annotation(Pue))){N.current?N.current.reset():(N.current=new Wpt(()=>{if(I.current){var q=I.current;I.current=null,q()}N.current=null},Zpt),Kpt().add(N.current));var $=R.state.doc,P=$.toString();a(P,R)}r&&r(Ypt(R))}),L=Upt({theme:u,editable:b,readOnly:y,placeholder:f,indentWithTab:w,basicSetup:k}),F=[M,S,...L];return o&&typeof o=="function"&&F.push(jt.updateListener.of(o)),F=F.concat(s),he.useLayoutEffect(()=>{if(_&&!B){var R={doc:e,selection:n,extensions:F},$=x?Hn.fromJSON(x.json,R,x.fields):Hn.create(R);if(T($),!D){var P=new jt({state:$,parent:_,root:C});Q(P),i&&i(P,$)}}return()=>{D&&(T(void 0),Q(void 0))}},[_,B]),he.useEffect(()=>{t.container&&E(t.container)},[t.container]),he.useEffect(()=>()=>{D&&(D.destroy(),Q(void 0)),N.current&&(N.current.cancel(),N.current=null)},[D]),he.useEffect(()=>{l&&D&&D.focus()},[l,D]),he.useEffect(()=>{D&&D.dispatch({effects:Bn.reconfigure.of(F)})},[u,s,d,p,m,A,g,h,f,b,y,w,k,a,o]),he.useEffect(()=>{if(e!==void 0){var R=D?D.state.doc.toString():"";if(D&&e!==R){var $=N.current&&!N.current.isDone,P=()=>{D&&e!==D.state.doc.toString()&&D.dispatch({changes:{from:0,to:D.state.doc.toString().length,insert:e||""},annotations:[Pue.of(!0)]})};$?I.current=P:P()}}},[e,D]),{state:B,setState:T,view:D,setView:Q,container:_,setContainer:E}}var Xpt=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],Oue=he.forwardRef((t,e)=>{var{className:n,value:a="",selection:r,extensions:i=[],onChange:o,onStatistics:s,onCreateEditor:l,onUpdate:u,autoFocus:d,theme:p="light",height:m,minHeight:A,maxHeight:g,width:h,minWidth:f,maxWidth:b,basicSetup:y,placeholder:w,indentWithTab:k,editable:C,readOnly:x,root:_,initialState:E}=t,D=zit(t,Xpt),Q=he.useRef(null),{state:B,view:T,container:N,setContainer:I}=Jpt({root:_,value:a,autoFocus:d,theme:p,height:m,minHeight:A,maxHeight:g,width:h,minWidth:f,maxWidth:b,basicSetup:y,placeholder:w,indentWithTab:k,editable:C,readOnly:x,selection:r,onChange:o,onStatistics:s,onCreateEditor:l,onUpdate:u,extensions:i,initialState:E});he.useImperativeHandle(e,()=>({editor:Q.current,state:B,view:T}),[Q,N,B,T]);var S=he.useCallback(L=>{Q.current=L,I(L)},[I]);if(typeof a!="string")throw new Error("value must be typeof string but got "+typeof a);var M=typeof p=="string"?"cm-theme-"+p:"cm-theme";return H.jsx("div",CF({ref:S,className:""+M+(n?" "+n:"")},D))});Oue.displayName="CodeMirror";var jue={npm_package_exports___require:"./dist/ai-agent.umd.js",npm_package_devDependencies__types_node:"20.2.5",npm_package_devDependencies_tw_animate_css:"1.4.0",npm_package_devDependencies_vitest:"1.2.2",npm_package_devDependencies__testing_library_jest_dom:"6.4.0",npm_config_user_agent:"pnpm/9.10.0 npm/? node/v20.17.0 linux x64",CI:"true",npm_package_devDependencies__testing_library_user_event:"14.5.2",npm_package_dependencies_cmdk:"1.1.1",npm_package_dependencies_embla_carousel_react:"8.6.0",npm_package_devDependencies_vite:"5.0.12",npm_node_execpath:"/opt/hostedtoolcache/node/20.17.0/x64/bin/node",npm_package_publishConfig_access:"public",npm_package_files_0:"dist",npm_package_dependencies__radix_ui_react_tooltip:"1.2.8",HOME:"/home/runner",npm_package_dependencies__radix_ui_react_dialog:"1.1.15",npm_package_dependencies__radix_ui_react_hover_card:"1.1.15",npm_package_devDependencies_classnames:"2.3.2",npm_package_devDependencies_sass:"1.62.1",npm_package_devDependencies_vite_plugin_static_copy:"1.0.0",npm_package_dependencies__radix_ui_react_separator:"1.1.8",npm_package_dependencies_shiki:"3.20.0",npm_config_auto_install_peers:"true",npm_package_dependencies_class_variance_authority:"0.7.1",npm_package_devDependencies_vite_plugin_dts:"3.7.1",npm_package_dependencies__radix_ui_react_dropdown_menu:"2.1.16",npm_package_dependencies__xyflow_react:"12.10.0",npm_package_devDependencies_tailwindcss:"4.1.18",npm_package_devDependencies_typescript:"5.1.3",npm_package_types:"./dist/index.d.ts",npm_package_devDependencies__types_react_dom:"18.3.1",npm_package_devDependencies__vitejs_plugin_react_swc:"3.5.0",npm_package_type:"module",npm_package_exports___default:"./dist/ai-agent.es.js",npm_package_dependencies__radix_ui_react_use_controllable_state:"1.2.2",npm_package_module:"./dist/ai-agent.es.js",npm_package_devDependencies__types_testing_library__jest_dom:"6.0.0",npm_package_dependencies_motion:"12.23.26",npm_package_devDependencies__vitest_coverage_v8:"1.2.2",npm_config_registry:"https://registry.npmjs.org/",npm_config_node_linker:"hoisted",npm_package_dependencies__codemirror_lang_json:"6.0.1",npm_package_dependencies_streamdown:"1.6.10",npm_package_exports___import:"./dist/ai-agent.es.js",npm_package_dependencies_tailwind_merge:"3.4.0",npm_config_node_gyp:"/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules/pnpm/dist/node_modules/node-gyp/bin/node-gyp.js",PATH:"/home/runner/work/avocado/avocado/packages/ai-agent/node_modules/.bin:/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules/pnpm/dist/node-gyp-bin:/home/runner/work/avocado/avocado/node_modules/.bin:/home/runner/work/avocado/avocado/node_modules/.bin:/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules/pnpm/dist/node-gyp-bin:/home/runner/work/avocado/avocado/node_modules/.bin:/opt/hostedtoolcache/node/20.17.0/x64/bin:/home/runner/setup-pnpm/node_modules/.bin:/snap/bin:/home/runner/.local/bin:/opt/pipx_bin:/home/runner/.cargo/bin:/home/runner/.config/composer/vendor/bin:/usr/local/.ghcup/bin:/home/runner/.dotnet/tools:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin",TURBO_HASH:"4020ef3d6a612e93",npm_package_name:"@foris/ai-agent",npm_package_dependencies_postcss:"8.5.6",NODE:"/opt/hostedtoolcache/node/20.17.0/x64/bin/node",npm_package_dependencies__radix_ui_react_select:"2.2.6",npm_package_dependencies_lucide_react:"0.561.0",npm_package_dependencies_tokenlens:"1.3.1",npm_config_frozen_lockfile:"",npm_package_devDependencies__vitest_ui:"1.2.2",npm_config_legacy_peer_deps:"true",LANG:"C.UTF-8",npm_package_dependencies_react_dom:"18.3.1",npm_package_main:"./dist/ai-agent.umd.js",npm_package_dependencies_ai:"5.0.115",npm_package_dependencies_react_markdown:"10.1.0",npm_lifecycle_script:"tsc && vite build",npm_package_dependencies__uiw_react_codemirror:"4.25.4",SHELL:"/bin/bash",NODE_PATH:"/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules/pnpm/bin/node_modules:/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules/pnpm/node_modules:/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules:/home/runner/setup-pnpm/node_modules/.pnpm/node_modules",npm_package_version:"0.8.1",npm_package_dependencies__radix_ui_react_slot:"1.2.4",npm_package_dependencies_nanoid:"5.1.6",npm_package_devDependencies__testing_library_react:"14.2.0",npm_package_devDependencies__types_react:"18.3.1",npm_package_devDependencies_jsdom:"24.0.0",npm_lifecycle_event:"build",npm_package_scripts_build:"tsc && vite build",npm_package_dependencies__ai_sdk_react:"2.0.117",npm_package_dependencies_clsx:"2.1.1",npm_package_devDependencies__foris_tsconfig:"workspace:*",npm_package_scripts_test_watch:"vitest --ui",npm_package_scripts_coverage:"vitest run --coverage",PWD:"/home/runner/work/avocado/avocado/packages/ai-agent",npm_package_dependencies__radix_ui_react_progress:"1.1.8",npm_execpath:"/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules/pnpm/bin/pnpm.cjs",npm_package_exports___types:"./dist/index.d.ts",npm_package_dependencies__radix_ui_react_scroll_area:"1.2.10",npm_package_dependencies__tailwindcss_postcss:"4.1.18",npm_package_devDependencies__shikijs_transformers:"3.20.0",npm_command:"run-script",PNPM_SCRIPT_SRC_DIR:"/home/runner/work/avocado/avocado/packages/ai-agent",npm_package_dependencies__radix_ui_react_collapsible:"1.1.12",npm_package_dependencies_react:"18.3.1",npm_package_dependencies_use_stick_to_bottom:"1.1.1",INIT_CWD:"/home/runner/work/avocado/avocado/packages/ai-agent",NODE_ENV:"production"};let emt=class HH{constructor(e,n,a,r,i,o,s,l,u,d=0,p){this.p=e,this.stack=n,this.state=a,this.reducePos=r,this.pos=i,this.score=o,this.buffer=s,this.bufferBase=l,this.curContext=u,this.lookAhead=d,this.parent=p}toString(){return`[${this.stack.filter((e,n)=>n%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,n,a=0){let r=e.parser.context;return new HH(e,[],n,a,a,0,[],0,r?new Gue(r,r.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,n){this.stack.push(this.state,n,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var n;let a=e>>19,r=e&65535,{parser:i}=this.p,o=this.reducePos<this.pos-25;o&&this.setLookAhead(this.pos);let s=i.dynamicPrecedence(r);if(s&&(this.score+=s),a==0){this.pushState(i.getGoto(this.state,r,!0),this.reducePos),r<i.minRepeatTerm&&this.storeNode(r,this.reducePos,this.reducePos,o?8:4,!0),this.reduceContext(r,this.reducePos);return}let l=this.stack.length-(a-1)*3-(e&262144?6:0),u=l?this.stack[l-2]:this.p.ranges[0].from,d=this.reducePos-u;d>=2e3&&!(!((n=this.p.parser.nodeSet.types[r])===null||n===void 0)&&n.isAnonymous)&&(u==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=d):this.p.lastBigReductionSize<d&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=u,this.p.lastBigReductionSize=d));let p=l?this.stack[l-1]:0,m=this.bufferBase+this.buffer.length-p;if(r<i.minRepeatTerm||e&131072){let A=i.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(r,u,A,m+4,!0)}if(e&262144)this.state=this.stack[l];else{let A=this.stack[l-3];this.state=i.getGoto(A,r,!0)}for(;this.stack.length>l;)this.stack.pop();this.reduceContext(r,u)}storeNode(e,n,a,r=4,i=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this,s=this.buffer.length;if(s==0&&o.parent&&(s=o.bufferBase-o.parent.bufferBase,o=o.parent),s>0&&o.buffer[s-4]==0&&o.buffer[s-1]>-1){if(n==a)return;if(o.buffer[s-2]>=n){o.buffer[s-2]=a;return}}}if(!i||this.pos==a)this.buffer.push(e,n,a,r);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let s=!1;for(let l=o;l>0&&this.buffer[l-2]>a;l-=4)if(this.buffer[l-1]>=0){s=!0;break}if(s)for(;o>0&&this.buffer[o-2]>a;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,r>4&&(r-=4)}this.buffer[o]=e,this.buffer[o+1]=n,this.buffer[o+2]=a,this.buffer[o+3]=r}}shift(e,n,a,r){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=r,this.shiftContext(n,a),n<=this.p.parser.maxNode&&this.buffer.push(n,a,r,4);else{let i=e,{parser:o}=this.p;(r>this.pos||n<=o.maxNode)&&(this.pos=r,o.stateFlag(i,1)||(this.reducePos=r)),this.pushState(i,a),this.shiftContext(n,a),n<=o.maxNode&&this.buffer.push(n,a,r,4)}}apply(e,n,a,r){e&65536?this.reduce(e):this.shift(e,n,a,r)}useNode(e,n){let a=this.p.reused.length-1;(a<0||this.p.reused[a]!=e)&&(this.p.reused.push(e),a++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(n,r),this.buffer.push(a,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,n=e.buffer.length;for(;n>0&&e.buffer[n-2]>e.reducePos;)n-=4;let a=e.buffer.slice(n),r=e.bufferBase+n;for(;e&&r==e.bufferBase;)e=e.parent;return new HH(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,a,r,this.curContext,this.lookAhead,e)}recoverByDelete(e,n){let a=e<=this.p.parser.maxNode;a&&this.storeNode(e,this.pos,n,4),this.storeNode(0,this.pos,n,a?8:4),this.pos=this.reducePos=n,this.score-=190}canShift(e){for(let n=new tmt(this);;){let a=this.p.parser.stateSlot(n.state,4)||this.p.parser.hasAction(n.state,e);if(a==0)return!1;if(!(a&65536))return!0;n.reduce(a)}}recoverByInsert(e){if(this.stack.length>=300)return[];let n=this.p.parser.nextStates(this.state);if(n.length>8||this.stack.length>=120){let r=[];for(let i=0,o;i<n.length;i+=2)(o=n[i+1])!=this.state&&this.p.parser.hasAction(o,e)&&r.push(n[i],o);if(this.stack.length<120)for(let i=0;r.length<8&&i<n.length;i+=2){let o=n[i+1];r.some((s,l)=>l&1&&s==o)||r.push(n[i],o)}n=r}let a=[];for(let r=0;r<n.length&&a.length<4;r+=2){let i=n[r+1];if(i==this.state)continue;let o=this.split();o.pushState(i,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(n[r],this.pos),o.reducePos=this.pos,o.score-=200,a.push(o)}return a}forceReduce(){let{parser:e}=this.p,n=e.stateSlot(this.state,5);if(!(n&65536))return!1;if(!e.validAction(this.state,n)){let a=n>>19,r=n&65535,i=this.stack.length-a*3;if(i<0||e.getGoto(this.stack[i],r,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;n=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(n),!0}findForcedReduction(){let{parser:e}=this.p,n=[],a=(r,i)=>{if(!n.includes(r))return n.push(r),e.allActions(r,o=>{if(!(o&393216))if(o&65536){let s=(o>>19)-i;if(s>1){let l=o&65535,u=this.stack.length-s*3;if(u>=0&&e.getGoto(this.stack[u],l,!1)>=0)return s<<19|65536|l}}else{let s=a(o,i+1);if(s!=null)return s}})};return a(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let n=0;n<this.stack.length;n+=3)if(this.stack[n]!=e.stack[n])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,n){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(n)))}reduceContext(e,n){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(n)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let n=new Gue(this.curContext.tracker,e);n.hash!=this.curContext.hash&&this.emitContext(),this.curContext=n}}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 Gue{constructor(e,n){this.tracker=e,this.context=n,this.hash=e.strict?e.hash(n):0}}class tmt{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let n=e&65535,a=e>>19;a==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(a-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],n,!0);this.state=r}}class R3{constructor(e,n,a){this.stack=e,this.pos=n,this.index=a,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,n=e.bufferBase+e.buffer.length){return new R3(e,n,n-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new R3(this.stack,this.pos,this.index)}}function $3(t,e=Uint16Array){if(typeof t!="string")return t;let n=null;for(let a=0,r=0;a<t.length;){let i=0;for(;;){let o=t.charCodeAt(a++),s=!1;if(o==126){i=65535;break}o>=92&&o--,o>=34&&o--;let l=o-32;if(l>=46&&(l-=46,s=!0),i+=l,s)break;i*=46}n?n[r++]=i:n=new e(i)}return n}class P3{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const que=new P3;class nmt{constructor(e,n){this.input=e,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=que,this.rangeIndex=0,this.pos=this.chunkPos=n[0].from,this.range=n[0],this.end=n[n.length-1].to,this.readNext()}resolveOffset(e,n){let a=this.range,r=this.rangeIndex,i=this.pos+e;for(;i<a.from;){if(!r)return null;let o=this.ranges[--r];i-=a.from-o.to,a=o}for(;n<0?i>a.to:i>=a.to;){if(r==this.ranges.length-1)return null;let o=this.ranges[++r];i+=o.from-a.to,a=o}return i}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let n of this.ranges)if(n.to>e)return Math.max(e,n.from);return this.end}peek(e){let n=this.chunkOff+e,a,r;if(n>=0&&n<this.chunk.length)a=this.pos+e,r=this.chunk.charCodeAt(n);else{let i=this.resolveOffset(e,1);if(i==null)return-1;if(a=i,a>=this.chunk2Pos&&a<this.chunk2Pos+this.chunk2.length)r=this.chunk2.charCodeAt(a-this.chunk2Pos);else{let o=this.rangeIndex,s=this.range;for(;s.to<=a;)s=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=a),a+this.chunk2.length>s.to&&(this.chunk2=this.chunk2.slice(0,s.to-a)),r=this.chunk2.charCodeAt(0)}}return a>=this.token.lookAhead&&(this.token.lookAhead=a+1),r}acceptToken(e,n=0){let a=n?this.resolveOffset(n,-1):this.pos;if(a==null||a<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=a}acceptTokenTo(e,n){this.token.value=e,this.token.end=n}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:n}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=n,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),n=this.pos+e.length;this.chunk=n>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,n){if(n?(this.token=n,n.start=e,n.lookAhead=e+1,n.value=n.extended=-1):this.token=que,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,n){if(e>=this.chunkPos&&n<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,n-this.chunkPos);if(e>=this.chunk2Pos&&n<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,n-this.chunk2Pos);if(e>=this.range.from&&n<=this.range.to)return this.input.read(e,n);let a="";for(let r of this.ranges){if(r.from>=n)break;r.to>e&&(a+=this.input.read(Math.max(r.from,e),Math.min(r.to,n)))}return a}}class Ib{constructor(e,n){this.data=e,this.id=n}token(e,n){let{parser:a}=n.p;amt(this.data,e,n,this.id,a.data,a.tokenPrecTable)}}Ib.prototype.contextual=Ib.prototype.fallback=Ib.prototype.extend=!1,Ib.prototype.fallback=Ib.prototype.extend=!1;function amt(t,e,n,a,r,i){let o=0,s=1<<a,{dialect:l}=n.p.parser;e:for(;s&t[o];){let u=t[o+1];for(let A=o+3;A<u;A+=2)if((t[A+1]&s)>0){let g=t[A];if(l.allows(g)&&(e.token.value==-1||e.token.value==g||rmt(g,e.token.value,r,i))){e.acceptToken(g);break}}let d=e.next,p=0,m=t[o+2];if(e.next<0&&m>p&&t[u+m*3-3]==65535){o=t[u+m*3-1];continue e}for(;p<m;){let A=p+m>>1,g=u+A+(A<<1),h=t[g],f=t[g+1]||65536;if(d<h)m=A;else if(d>=f)p=A+1;else{o=t[g+2],e.advance();continue e}}break}}function zue(t,e,n){for(let a=e,r;(r=t[a])!=65535;a++)if(r==n)return a-e;return-1}function rmt(t,e,n,a){let r=zue(n,a,e);return r<0||zue(n,a,t)<r}const zs=typeof process<"u"&&jue&&/\bparse\b/.test(jue.LOG);let EN=null;function Hue(t,e,n){let a=t.cursor(wi.IncludeAnonymous);for(a.moveTo(e);;)if(!(n<0?a.childBefore(e):a.childAfter(e)))for(;;){if((n<0?a.to<e:a.from>e)&&!a.type.isError)return n<0?Math.max(0,Math.min(a.to-1,e-25)):Math.min(t.length,Math.max(a.from+1,e+25));if(n<0?a.prevSibling():a.nextSibling())break;if(!a.parent())return n<0?0:t.length}}class imt{constructor(e,n){this.fragments=e,this.nodeSet=n,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?Hue(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?Hue(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let n=this.trees.length-1;if(n<0)return this.nextFragment(),null;let a=this.trees[n],r=this.index[n];if(r==a.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let i=a.children[r],o=this.start[n]+a.positions[r];if(o>e)return this.nextStart=o,null;if(i instanceof Nr){if(o==e){if(o<this.safeFrom)return null;let s=o+i.length;if(s<=this.safeTo){let l=i.prop(Rn.lookAhead);if(!l||s+l<this.fragment.to)return i}}this.index[n]++,o+i.length>=Math.max(this.safeFrom,e)&&(this.trees.push(i),this.start.push(o),this.index.push(0))}else this.index[n]++,this.nextStart=o+i.length}}}class omt{constructor(e,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(a=>new P3)}getActions(e){let n=0,a=null,{parser:r}=e.p,{tokenizers:i}=r,o=r.stateSlot(e.state,3),s=e.curContext?e.curContext.hash:0,l=0;for(let u=0;u<i.length;u++){if(!(1<<u&o))continue;let d=i[u],p=this.tokens[u];if(!(a&&!d.fallback)&&((d.contextual||p.start!=e.pos||p.mask!=o||p.context!=s)&&(this.updateCachedToken(p,d,e),p.mask=o,p.context=s),p.lookAhead>p.end+25&&(l=Math.max(p.lookAhead,l)),p.value!=0)){let m=n;if(p.extended>-1&&(n=this.addActions(e,p.extended,p.end,n)),n=this.addActions(e,p.value,p.end,n),!d.extend&&(a=p,n>m))break}}for(;this.actions.length>n;)this.actions.pop();return l&&e.setLookAhead(l),!a&&e.pos==this.stream.end&&(a=new P3,a.value=e.p.parser.eofTerm,a.start=a.end=e.pos,n=this.addActions(e,a.value,a.end,n)),this.mainToken=a,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let n=new P3,{pos:a,p:r}=e;return n.start=a,n.end=Math.min(a+1,r.stream.end),n.value=a==r.stream.end?r.parser.eofTerm:0,n}updateCachedToken(e,n,a){let r=this.stream.clipPos(a.pos);if(n.token(this.stream.reset(r,e),a),e.value>-1){let{parser:i}=a.p;for(let o=0;o<i.specialized.length;o++)if(i.specialized[o]==e.value){let s=i.specializers[o](this.stream.read(e.start,e.end),a);if(s>=0&&a.p.parser.dialect.allows(s>>1)){s&1?e.extended=s>>1:e.value=s>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,n,a,r){for(let i=0;i<r;i+=3)if(this.actions[i]==e)return r;return this.actions[r++]=e,this.actions[r++]=n,this.actions[r++]=a,r}addActions(e,n,a,r){let{state:i}=e,{parser:o}=e.p,{data:s}=o;for(let l=0;l<2;l++)for(let u=o.stateSlot(i,l?2:1);;u+=3){if(s[u]==65535)if(s[u+1]==1)u=Sd(s,u+2);else{r==0&&s[u+1]==2&&(r=this.putAction(Sd(s,u+2),n,a,r));break}s[u]==n&&(r=this.putAction(Sd(s,u+1),n,a,r))}return r}}class smt{constructor(e,n,a,r){this.parser=e,this.input=n,this.ranges=r,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new nmt(n,r),this.tokens=new omt(e,this.stream),this.topTerm=e.top[1];let{from:i}=r[0];this.stacks=[emt.start(this,e.top[0],i)],this.fragments=a.length&&this.stream.end-i>e.bufferLength*4?new imt(a,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,n=this.minStackPos,a=this.stacks=[],r,i;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<e.length;o++){let s=e[o];for(;;){if(this.tokens.mainToken=null,s.pos>n)a.push(s);else{if(this.advanceStack(s,a,e))continue;{r||(r=[],i=[]),r.push(s);let l=this.tokens.getMainToken(s);i.push(l.value,l.end)}}break}}if(!a.length){let o=r&&lmt(r);if(o)return zs&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw zs&&r&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+n);this.recovering||(this.recovering=5)}if(this.recovering&&r){let o=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,i,a);if(o)return zs&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(a.length>o)for(a.sort((s,l)=>l.score-s.score);a.length>o;)a.pop();a.some(s=>s.reducePos>n)&&this.recovering--}else if(a.length>1){e:for(let o=0;o<a.length-1;o++){let s=a[o];for(let l=o+1;l<a.length;l++){let u=a[l];if(s.sameState(u)||s.buffer.length>500&&u.buffer.length>500)if((s.score-u.score||s.buffer.length-u.buffer.length)>0)a.splice(l--,1);else{a.splice(o--,1);continue e}}}a.length>12&&a.splice(12,a.length-12)}this.minStackPos=a[0].pos;for(let o=1;o<a.length;o++)a[o].pos<this.minStackPos&&(this.minStackPos=a[o].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,n,a){let r=e.pos,{parser:i}=this,o=zs?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let u=e.curContext&&e.curContext.tracker.strict,d=u?e.curContext.hash:0;for(let p=this.fragments.nodeAt(r);p;){let m=this.parser.nodeSet.types[p.type.id]==p.type?i.getGoto(e.state,p.type.id):-1;if(m>-1&&p.length&&(!u||(p.prop(Rn.contextHash)||0)==d))return e.useNode(p,m),zs&&console.log(o+this.stackID(e)+` (via reuse of ${i.getName(p.type.id)})`),!0;if(!(p instanceof Nr)||p.children.length==0||p.positions[0]>0)break;let A=p.children[0];if(A instanceof Nr&&p.positions[0]==0)p=A;else break}}let s=i.stateSlot(e.state,4);if(s>0)return e.reduce(s),zs&&console.log(o+this.stackID(e)+` (via always-reduce ${i.getName(s&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let l=this.tokens.getActions(e);for(let u=0;u<l.length;){let d=l[u++],p=l[u++],m=l[u++],A=u==l.length||!a,g=A?e:e.split(),h=this.tokens.mainToken;if(g.apply(d,p,h?h.start:g.pos,m),zs&&console.log(o+this.stackID(g)+` (via ${d&65536?`reduce of ${i.getName(d&65535)}`:"shift"} for ${i.getName(p)} @ ${r}${g==e?"":", split"})`),A)return!0;g.pos>r?n.push(g):a.push(g)}return!1}advanceFully(e,n){let a=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>a)return Uue(e,n),!0}}runRecovery(e,n,a){let r=null,i=!1;for(let o=0;o<e.length;o++){let s=e[o],l=n[o<<1],u=n[(o<<1)+1],d=zs?this.stackID(s)+" -> ":"";if(s.deadEnd&&(i||(i=!0,s.restart(),zs&&console.log(d+this.stackID(s)+" (restarted)"),this.advanceFully(s,a))))continue;let p=s.split(),m=d;for(let A=0;A<10&&p.forceReduce()&&(zs&&console.log(m+this.stackID(p)+" (via force-reduce)"),!this.advanceFully(p,a));A++)zs&&(m=this.stackID(p)+" -> ");for(let A of s.recoverByInsert(l))zs&&console.log(d+this.stackID(A)+" (via recover-insert)"),this.advanceFully(A,a);this.stream.end>s.pos?(u==s.pos&&(u++,l=0),s.recoverByDelete(l,u),zs&&console.log(d+this.stackID(s)+` (via recover-delete ${this.parser.getName(l)})`),Uue(s,a)):(!r||r.score<s.score)&&(r=s)}return r}stackToTree(e){return e.close(),Nr.build({buffer:R3.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let n=(EN||(EN=new WeakMap)).get(e);return n||EN.set(e,n=String.fromCodePoint(this.nextStackID++)),n+e}}function Uue(t,e){for(let n=0;n<e.length;n++){let a=e[n];if(a.pos==t.pos&&a.sameState(t)){e[n].score<t.score&&(e[n]=t);return}}e.push(t)}class cmt{constructor(e,n,a){this.source=e,this.flags=n,this.disabled=a}allows(e){return!this.disabled||this.disabled[e]==0}}class O3 extends Qce{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let n=e.nodeNames.split(" ");this.minRepeatTerm=n.length;for(let s=0;s<e.repeatNodeCount;s++)n.push("");let a=Object.keys(e.topRules).map(s=>e.topRules[s][1]),r=[];for(let s=0;s<n.length;s++)r.push([]);function i(s,l,u){r[s].push([l,l.deserialize(String(u))])}if(e.nodeProps)for(let s of e.nodeProps){let l=s[0];typeof l=="string"&&(l=Rn[l]);for(let u=1;u<s.length;){let d=s[u++];if(d>=0)i(d,l,s[u++]);else{let p=s[u+-d];for(let m=-d;m>0;m--)i(s[u++],l,p);u++}}}this.nodeSet=new ML(n.map((s,l)=>gs.define({name:l>=this.minRepeatTerm?void 0:s,id:l,props:r[l],top:a.indexOf(l)>-1,error:l==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(l)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=Cce;let o=$3(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let s=0;s<this.specializerSpecs.length;s++)this.specialized[s]=this.specializerSpecs[s].term;this.specializers=this.specializerSpecs.map(Yue),this.states=$3(e.states,Uint32Array),this.data=$3(e.stateData),this.goto=$3(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(s=>typeof s=="number"?new Ib(o,s):s),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,n,a){let r=new smt(this,e,n,a);for(let i of this.wrappers)r=i(r,e,n,a);return r}getGoto(e,n,a=!1){let r=this.goto;if(n>=r[0])return-1;for(let i=r[n+1];;){let o=r[i++],s=o&1,l=r[i++];if(s&&a)return l;for(let u=i+(o>>1);i<u;i++)if(r[i]==e)return l;if(s)return-1}}hasAction(e,n){let a=this.data;for(let r=0;r<2;r++)for(let i=this.stateSlot(e,r?2:1),o;;i+=3){if((o=a[i])==65535)if(a[i+1]==1)o=a[i=Sd(a,i+2)];else{if(a[i+1]==2)return Sd(a,i+2);break}if(o==n||o==0)return Sd(a,i+1)}return 0}stateSlot(e,n){return this.states[e*6+n]}stateFlag(e,n){return(this.stateSlot(e,0)&n)>0}validAction(e,n){return!!this.allActions(e,a=>a==n?!0:null)}allActions(e,n){let a=this.stateSlot(e,4),r=a?n(a):void 0;for(let i=this.stateSlot(e,1);r==null;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=Sd(this.data,i+2);else break;r=n(Sd(this.data,i+1))}return r}nextStates(e){let n=[];for(let a=this.stateSlot(e,1);;a+=3){if(this.data[a]==65535)if(this.data[a+1]==1)a=Sd(this.data,a+2);else break;if(!(this.data[a+2]&1)){let r=this.data[a+1];n.some((i,o)=>o&1&&i==r)||n.push(this.data[a],r)}}return n}configure(e){let n=Object.assign(Object.create(O3.prototype),this);if(e.props&&(n.nodeSet=this.nodeSet.extend(...e.props)),e.top){let a=this.topRules[e.top];if(!a)throw new RangeError(`Invalid top rule name ${e.top}`);n.top=a}return e.tokenizers&&(n.tokenizers=this.tokenizers.map(a=>{let r=e.tokenizers.find(i=>i.from==a);return r?r.to:a})),e.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((a,r)=>{let i=e.specializers.find(s=>s.from==a.external);if(!i)return a;let o=Object.assign(Object.assign({},a),{external:i.to});return n.specializers[r]=Yue(o),o})),e.contextTracker&&(n.context=e.contextTracker),e.dialect&&(n.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(n.strict=e.strict),e.wrap&&(n.wrappers=n.wrappers.concat(e.wrap)),e.bufferLength!=null&&(n.bufferLength=e.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let n=this.dynamicPrecedences;return n==null?0:n[e]||0}parseDialect(e){let n=Object.keys(this.dialects),a=n.map(()=>!1);if(e)for(let i of e.split(" ")){let o=n.indexOf(i);o>=0&&(a[o]=!0)}let r=null;for(let i=0;i<n.length;i++)if(!a[i])for(let o=this.dialects[n[i]],s;(s=this.data[o++])!=65535;)(r||(r=new Uint8Array(this.maxTerm+1)))[s]=1;return new cmt(e,a,r)}static deserialize(e){return new O3(e)}}function Sd(t,e){return t[e]|t[e+1]<<16}function lmt(t){let e=null;for(let n of t){let a=n.p.stoppedAt;(n.pos==n.p.stream.end||a!=null&&n.pos>a)&&n.p.parser.stateFlag(n.state,2)&&(!e||e.score<n.score)&&(e=n)}return e}function Yue(t){if(t.external){let e=t.extend?1:0;return(n,a)=>t.external(n,a)<<1|e}return t.get}const umt=Sce({String:Xe.string,Number:Xe.number,"True False":Xe.bool,PropertyName:Xe.propertyName,Null:Xe.null,", :":Xe.separator,"[ ]":Xe.squareBracket,"{ }":Xe.brace}),dmt=O3.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[umt],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),pmt=u3.define({name:"json",parser:dmt.configure({props:[Pce.add({Object:jce({except:/^\s*\}/}),Array:jce({except:/^\s*\]/})}),Gce.add({"Object Array":vlt})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function mmt(){return new ult(pmt)}const Amt={codeWithAnnotations:`{
1352
+ `:a=="r"?"\r":a=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord}create(){return this.regexp?new xdt(this):new Cdt(this)}getCursor(e,n=0,a){let r=e.doc?e:Hn.create({doc:e});return a==null&&(a=r.doc.length),this.regexp?_b(this,r,n,a):Cb(this,r,n,a)}}class eue{constructor(e){this.spec=e}}function Cb(t,e,n,a){return new wb(e.doc,t.unquoted,n,a,t.caseSensitive?void 0:r=>r.toLowerCase(),t.wholeWord?vdt(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function vdt(t,e){return(n,a,r,i)=>((i>n||i+r.length<a)&&(i=Math.max(0,n-2),r=t.sliceString(i,Math.min(t.length,a+2))),(e(x3(r,n-i))!=Za.Word||e(E3(r,n-i))!=Za.Word)&&(e(E3(r,a-i))!=Za.Word||e(x3(r,a-i))!=Za.Word))}class Cdt extends eue{constructor(e){super(e)}nextMatch(e,n,a){let r=Cb(this.spec,e,a,e.doc.length).nextOverlapping();if(r.done){let i=Math.min(e.doc.length,n+this.spec.unquoted.length);r=Cb(this.spec,e,0,i).nextOverlapping()}return r.done||r.value.from==n&&r.value.to==a?null:r.value}prevMatchInRange(e,n,a){for(let r=a;;){let i=Math.max(n,r-1e4-this.spec.unquoted.length),o=Cb(this.spec,e,i,r),s=null;for(;!o.nextOverlapping().done;)s=o.value;if(s)return s;if(i==n)return null;r-=1e4}}prevMatch(e,n,a){let r=this.prevMatchInRange(e,0,n);return r||(r=this.prevMatchInRange(e,Math.max(0,a-this.spec.unquoted.length),e.doc.length)),r&&(r.from!=n||r.to!=a)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,n){let a=Cb(this.spec,e,0,e.doc.length),r=[];for(;!a.next().done;){if(r.length>=n)return null;r.push(a.value)}return r}highlight(e,n,a,r){let i=Cb(this.spec,e,Math.max(0,n-this.spec.unquoted.length),Math.min(a+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}}function _b(t,e,n,a){return new Kle(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:t.wholeWord?_dt(e.charCategorizer(e.selection.main.head)):void 0},n,a)}function x3(t,e){return t.slice(Ni(t,e,!1),e)}function E3(t,e){return t.slice(e,Ni(t,e))}function _dt(t){return(e,n,a)=>!a[0].length||(t(x3(a.input,a.index))!=Za.Word||t(E3(a.input,a.index))!=Za.Word)&&(t(E3(a.input,a.index+a[0].length))!=Za.Word||t(x3(a.input,a.index+a[0].length))!=Za.Word)}class xdt extends eue{nextMatch(e,n,a){let r=_b(this.spec,e,a,e.doc.length).next();return r.done&&(r=_b(this.spec,e,0,n).next()),r.done?null:r.value}prevMatchInRange(e,n,a){for(let r=1;;r++){let i=Math.max(n,a-r*1e4),o=_b(this.spec,e,i,a),s=null;for(;!o.next().done;)s=o.value;if(s&&(i==n||s.from>i+10))return s;if(i==n)return null}}prevMatch(e,n,a){return this.prevMatchInRange(e,0,n)||this.prevMatchInRange(e,a,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(n,a)=>{if(a=="&")return e.match[0];if(a=="$")return"$";for(let r=a.length;r>0;r--){let i=+a.slice(0,r);if(i>0&&i<e.match.length)return e.match[i]+a.slice(r)}return n})}matchAll(e,n){let a=_b(this.spec,e,0,e.doc.length),r=[];for(;!a.next().done;){if(r.length>=n)return null;r.push(a.value)}return r}highlight(e,n,a,r){let i=_b(this.spec,e,Math.max(0,n-250),Math.min(a+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}}const Y1=Bn.define(),dN=Bn.define(),Am=Mi.define({create(t){return new pN(AN(t).create(),null)},update(t,e){for(let n of e.effects)n.is(Y1)?t=new pN(n.value.create(),t.panel):n.is(dN)&&(t=new pN(t.query,n.value?mN:null));return t},provide:t=>N1.from(t,e=>e.panel)});class pN{constructor(e,n){this.query=e,this.panel=n}}const Edt=ln.mark({class:"cm-searchMatch"}),Bdt=ln.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Idt=Cr.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field(Am))}update(t){let e=t.state.field(Am);(e!=t.startState.field(Am)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return ln.none;let{view:n}=this,a=new xd;for(let r=0,i=n.visibleRanges,o=i.length;r<o;r++){let{from:s,to:l}=i[r];for(;r<o-1&&l>i[r+1].from-2*250;)l=i[++r].to;t.highlight(n.state,s,l,(u,d)=>{let p=n.state.selection.ranges.some(m=>m.from==u&&m.to==d);a.add(u,d,p?Bdt:Edt)})}return a.finish()}},{decorations:t=>t.decorations});function W1(t){return e=>{let n=e.state.field(Am,!1);return n&&n.query.spec.valid?t(e,n):rue(e)}}const B3=W1((t,{query:e})=>{let{to:n}=t.state.selection.main,a=e.nextMatch(t.state,n,n);if(!a)return!1;let r=lt.single(a.from,a.to),i=t.state.facet(vb);return t.dispatch({selection:r,effects:[gN(t,a),i.scrollToMatch(r.main,t)],userEvent:"select.search"}),aue(t),!0}),I3=W1((t,{query:e})=>{let{state:n}=t,{from:a}=n.selection.main,r=e.prevMatch(n,a,a);if(!r)return!1;let i=lt.single(r.from,r.to),o=t.state.facet(vb);return t.dispatch({selection:i,effects:[gN(t,r),o.scrollToMatch(i.main,t)],userEvent:"select.search"}),aue(t),!0}),Ddt=W1((t,{query:e})=>{let n=e.matchAll(t.state,1e3);return!n||!n.length?!1:(t.dispatch({selection:lt.create(n.map(a=>lt.range(a.from,a.to))),userEvent:"select.search.matches"}),!0)}),Qdt=({state:t,dispatch:e})=>{let n=t.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:a,to:r}=n.main,i=[],o=0;for(let s=new wb(t.doc,t.sliceDoc(a,r));!s.next().done;){if(i.length>1e3)return!1;s.value.from==a&&(o=i.length),i.push(lt.range(s.value.from,s.value.to))}return e(t.update({selection:lt.create(i,o),userEvent:"select.search.matches"})),!0},tue=W1((t,{query:e})=>{let{state:n}=t,{from:a,to:r}=n.selection.main;if(n.readOnly)return!1;let i=e.nextMatch(n,a,a);if(!i)return!1;let o=i,s=[],l,u,d=[];o.from==a&&o.to==r&&(u=n.toText(e.getReplacement(o)),s.push({from:o.from,to:o.to,insert:u}),o=e.nextMatch(n,o.from,o.to),d.push(jt.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(a).number)+".")));let p=t.state.changes(s);return o&&(l=lt.single(o.from,o.to).map(p),d.push(gN(t,o)),d.push(n.facet(vb).scrollToMatch(l.main,t))),t.dispatch({changes:p,selection:l,effects:d,userEvent:"input.replace"}),!0}),Sdt=W1((t,{query:e})=>{if(t.state.readOnly)return!1;let n=e.matchAll(t.state,1e9).map(r=>{let{from:i,to:o}=r;return{from:i,to:o,insert:e.getReplacement(r)}});if(!n.length)return!1;let a=t.state.phrase("replaced $ matches",n.length)+".";return t.dispatch({changes:n,effects:jt.announce.of(a),userEvent:"input.replace.all"}),!0});function mN(t){return t.state.facet(vb).createPanel(t)}function AN(t,e){var n,a,r,i,o;let s=t.selection.main,l=s.empty||s.to>s.from+100?"":t.sliceDoc(s.from,s.to);if(e&&!l)return e;let u=t.facet(vb);return new Xle({search:((n=e==null?void 0:e.literal)!==null&&n!==void 0?n:u.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:(a=e==null?void 0:e.caseSensitive)!==null&&a!==void 0?a:u.caseSensitive,literal:(r=e==null?void 0:e.literal)!==null&&r!==void 0?r:u.literal,regexp:(i=e==null?void 0:e.regexp)!==null&&i!==void 0?i:u.regexp,wholeWord:(o=e==null?void 0:e.wholeWord)!==null&&o!==void 0?o:u.wholeWord})}function nue(t){let e=L1(t,mN);return e&&e.dom.querySelector("[main-field]")}function aue(t){let e=nue(t);e&&e==t.root.activeElement&&e.select()}const rue=t=>{let e=t.state.field(Am,!1);if(e&&e.panel){let n=nue(t);if(n&&n!=t.root.activeElement){let a=AN(t.state,e.query.spec);a.valid&&t.dispatch({effects:Y1.of(a)}),n.focus(),n.select()}}else t.dispatch({effects:[dN.of(!0),e?Y1.of(AN(t.state,e.query.spec)):Bn.appendConfig.of(Ndt)]});return!0},iue=t=>{let e=t.state.field(Am,!1);if(!e||!e.panel)return!1;let n=L1(t,mN);return n&&n.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:dN.of(!1)}),!0},Tdt=[{key:"Mod-f",run:rue,scope:"editor search-panel"},{key:"F3",run:B3,shift:I3,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:B3,shift:I3,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:iue,scope:"editor search-panel"},{key:"Mod-Shift-l",run:Qdt},{key:"Mod-Alt-g",run:ldt},{key:"Mod-d",run:kdt,preventDefault:!0}];class Fdt{constructor(e){this.view=e;let n=this.query=e.state.field(Am).query.spec;this.commit=this.commit.bind(this),this.searchField=xa("input",{value:n.search,placeholder:Gs(e,"Find"),"aria-label":Gs(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=xa("input",{value:n.replace,placeholder:Gs(e,"Replace"),"aria-label":Gs(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=xa("input",{type:"checkbox",name:"case",form:"",checked:n.caseSensitive,onchange:this.commit}),this.reField=xa("input",{type:"checkbox",name:"re",form:"",checked:n.regexp,onchange:this.commit}),this.wordField=xa("input",{type:"checkbox",name:"word",form:"",checked:n.wholeWord,onchange:this.commit});function a(r,i,o){return xa("button",{class:"cm-button",name:r,onclick:i,type:"button"},o)}this.dom=xa("div",{onkeydown:r=>this.keydown(r),class:"cm-search"},[this.searchField,a("next",()=>B3(e),[Gs(e,"next")]),a("prev",()=>I3(e),[Gs(e,"previous")]),a("select",()=>Ddt(e),[Gs(e,"all")]),xa("label",null,[this.caseField,Gs(e,"match case")]),xa("label",null,[this.reField,Gs(e,"regexp")]),xa("label",null,[this.wordField,Gs(e,"by word")]),...e.state.readOnly?[]:[xa("br"),this.replaceField,a("replace",()=>tue(e),[Gs(e,"replace")]),a("replaceAll",()=>Sdt(e),[Gs(e,"replace all")])],xa("button",{name:"close",onclick:()=>iue(e),"aria-label":Gs(e,"close"),type:"button"},["×"])])}commit(){let e=new Xle({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:Y1.of(e)}))}keydown(e){Gst(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?I3:B3)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),tue(this.view))}update(e){for(let n of e.transactions)for(let a of n.effects)a.is(Y1)&&!a.value.eq(this.query)&&this.setQuery(a.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(vb).top}}function Gs(t,e){return t.state.phrase(e)}const D3=30,Q3=/[\s\.,:;?!]/;function gN(t,{from:e,to:n}){let a=t.state.doc.lineAt(e),r=t.state.doc.lineAt(n).to,i=Math.max(a.from,e-D3),o=Math.min(r,n+D3),s=t.state.sliceDoc(i,o);if(i!=a.from){for(let l=0;l<D3;l++)if(!Q3.test(s[l+1])&&Q3.test(s[l])){s=s.slice(l);break}}if(o!=r){for(let l=s.length-1;l>s.length-D3;l--)if(!Q3.test(s[l-1])&&Q3.test(s[l])){s=s.slice(0,l);break}}return jt.announce.of(`${t.state.phrase("current match")}. ${s} ${t.state.phrase("on line")} ${a.number}.`)}const Ldt=jt.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"}}),Ndt=[Am,cg.low(Idt),Ldt];class oue{constructor(e,n,a,r){this.state=e,this.pos=n,this.explicit=a,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let n=oo(this.state).resolveInner(this.pos,-1);for(;n&&e.indexOf(n.name)<0;)n=n.parent;return n?{from:n.from,to:this.pos,text:this.state.sliceDoc(n.from,this.pos),type:n.type}:null}matchBefore(e){let n=this.state.doc.lineAt(this.pos),a=Math.max(n.from,this.pos-250),r=n.text.slice(a-n.from,this.pos-n.from),i=r.search(lue(e,!1));return i<0?null:{from:a+i,to:this.pos,text:r.slice(i)}}get aborted(){return this.abortListeners==null}addEventListener(e,n,a){e=="abort"&&this.abortListeners&&(this.abortListeners.push(n),a&&a.onDocChange&&(this.abortOnDocChange=!0))}}function sue(t){let e=Object.keys(t).join(""),n=/\w/.test(e);return n&&(e=e.replace(/\w/g,"")),`[${n?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function Mdt(t){let e=Object.create(null),n=Object.create(null);for(let{label:r}of t){e[r[0]]=!0;for(let i=1;i<r.length;i++)n[r[i]]=!0}let a=sue(e)+sue(n)+"*$";return[new RegExp("^"+a),new RegExp(a)]}function Rdt(t){let e=t.map(r=>typeof r=="string"?{label:r}:r),[n,a]=e.every(r=>/^\w+$/.test(r.label))?[/\w*$/,/\w+$/]:Mdt(e);return r=>{let i=r.matchBefore(a);return i||r.explicit?{from:i?i.from:r.pos,options:e,validFor:n}:null}}let cue=class{constructor(e,n,a,r){this.completion=e,this.source=n,this.match=a,this.score=r}};function fg(t){return t.selection.main.from}function lue(t,e){var n;let{source:a}=t,r=e&&a[0]!="^",i=a[a.length-1]!="$";return!r&&!i?t:new RegExp(`${r?"^":""}(?:${a})${i?"$":""}`,(n=t.flags)!==null&&n!==void 0?n:t.ignoreCase?"i":"")}const uue=lu.define();function $dt(t,e,n,a){let{main:r}=t.selection,i=n-r.from,o=a-r.from;return{...t.changeByRange(s=>{if(s!=r&&n!=a&&t.sliceDoc(s.from+i,s.from+o)!=t.sliceDoc(n,a))return{range:s};let l=t.toText(e);return{changes:{from:s.from+i,to:a==r.from?s.to:s.from+o,insert:l},range:lt.cursor(s.from+i+l.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const due=new WeakMap;function Pdt(t){if(!Array.isArray(t))return t;let e=due.get(t);return e||due.set(t,e=Rdt(t)),e}const S3=Bn.define(),K1=Bn.define();class Odt{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let n=0;n<e.length;){let a=ms(e,n),r=su(a);this.chars.push(a);let i=e.slice(n,n+r),o=i.toUpperCase();this.folded.push(ms(o==i?i.toLowerCase():o,0)),n+=r}this.astral=e.length!=this.chars.length}ret(e,n){return this.score=e,this.matched=n,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:n,folded:a,any:r,precise:i,byWord:o}=this;if(n.length==1){let y=ms(e,0),w=su(y),k=w==e.length?0:-100;if(y!=n[0])if(y==a[0])k+=-200;else return null;return this.ret(k,[0,w])}let s=e.indexOf(this.pattern);if(s==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=n.length,u=0;if(s<0){for(let y=0,w=Math.min(e.length,200);y<w&&u<l;){let k=ms(e,y);(k==n[u]||k==a[u])&&(r[u++]=y),y+=su(k)}if(u<l)return null}let d=0,p=0,m=!1,A=0,g=-1,h=-1,f=/[a-z]/.test(e),b=!0;for(let y=0,w=Math.min(e.length,200),k=0;y<w&&p<l;){let C=ms(e,y);s<0&&(d<l&&C==n[d]&&(i[d++]=y),A<l&&(C==n[A]||C==a[A]?(A==0&&(g=y),h=y+1,A++):A=0));let x,_=C<255?C>=48&&C<=57||C>=97&&C<=122?2:C>=65&&C<=90?1:0:(x=EF(C))!=x.toLowerCase()?1:x!=x.toUpperCase()?2:0;(!y||_==1&&f||k==0&&_!=0)&&(n[p]==C||a[p]==C&&(m=!0)?o[p++]=y:o.length&&(b=!1)),k=_,y+=su(C)}return p==l&&o[0]==0&&b?this.result(-100+(m?-200:0),o,e):A==l&&g==0?this.ret(-200-e.length+(h==e.length?0:-100),[0,h]):s>-1?this.ret(-700-e.length,[s,s+this.pattern.length]):A==l?this.ret(-900-e.length,[g,h]):p==l?this.result(-100+(m?-200:0)+-700+(b?0:-1100),o,e):n.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,n,a){let r=[],i=0;for(let o of n){let s=o+(this.astral?su(ms(a,o)):1);i&&r[i-1]==o?r[i-1]=s:(r[i++]=o,r[i++]=s)}return this.ret(e-a.length,r)}}class jdt{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let n=e.slice(0,this.pattern.length),a=n==this.pattern?0:n.toLowerCase()==this.folded?-200:null;return a==null?null:(this.matched=[0,n.length],this.score=a+(e.length==this.pattern.length?0:-100),this)}}const ki=Ht.define({combine(t){return uu(t,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Gdt,filterStrict:!1,compareCompletions:(e,n)=>e.label.localeCompare(n.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,n)=>e&&n,closeOnBlur:(e,n)=>e&&n,icons:(e,n)=>e&&n,tooltipClass:(e,n)=>a=>pue(e(a),n(a)),optionClass:(e,n)=>a=>pue(e(a),n(a)),addToOptions:(e,n)=>e.concat(n),filterStrict:(e,n)=>e||n})}});function pue(t,e){return t?e?t+" "+e:t:e}function Gdt(t,e,n,a,r,i){let o=t.textDirection==Ra.RTL,s=o,l=!1,u="top",d,p,m=e.left-r.left,A=r.right-e.right,g=a.right-a.left,h=a.bottom-a.top;if(s&&m<Math.min(g,A)?s=!1:!s&&A<Math.min(g,m)&&(s=!0),g<=(s?m:A))d=Math.max(r.top,Math.min(n.top,r.bottom-h))-e.top,p=Math.min(400,s?m:A);else{l=!0,p=Math.min(400,(o?e.right:r.right-e.left)-30);let y=r.bottom-e.bottom;y>=h||y>e.top?d=n.bottom-e.top:(u="bottom",d=e.bottom-n.top)}let f=(e.bottom-e.top)/i.offsetHeight,b=(e.right-e.left)/i.offsetWidth;return{style:`${u}: ${d/f}px; max-width: ${p/b}px`,class:"cm-completionInfo-"+(l?o?"left-narrow":"right-narrow":s?"left":"right")}}function qdt(t){let e=t.addToOptions.slice();return t.icons&&e.push({render(n){let a=document.createElement("div");return a.classList.add("cm-completionIcon"),n.type&&a.classList.add(...n.type.split(/\s+/g).map(r=>"cm-completionIcon-"+r)),a.setAttribute("aria-hidden","true"),a},position:20}),e.push({render(n,a,r,i){let o=document.createElement("span");o.className="cm-completionLabel";let s=n.displayLabel||n.label,l=0;for(let u=0;u<i.length;){let d=i[u++],p=i[u++];d>l&&o.appendChild(document.createTextNode(s.slice(l,d)));let m=o.appendChild(document.createElement("span"));m.appendChild(document.createTextNode(s.slice(d,p))),m.className="cm-completionMatchedText",l=p}return l<s.length&&o.appendChild(document.createTextNode(s.slice(l))),o},position:50},{render(n){if(!n.detail)return null;let a=document.createElement("span");return a.className="cm-completionDetail",a.textContent=n.detail,a},position:80}),e.sort((n,a)=>n.position-a.position).map(n=>n.render)}function hN(t,e,n){if(t<=n)return{from:0,to:t};if(e<0&&(e=0),e<=t>>1){let r=Math.floor(e/n);return{from:r*n,to:(r+1)*n}}let a=Math.floor((t-e)/n);return{from:t-(a+1)*n,to:t-a*n}}class zdt{constructor(e,n,a){this.view=e,this.stateField=n,this.applyCompletion=a,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:l=>this.placeInfo(l),key:this},this.space=null,this.currentClass="";let r=e.state.field(n),{options:i,selected:o}=r.open,s=e.state.facet(ki);this.optionContent=qdt(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=hN(i.length,o,s.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",l=>{let{options:u}=e.state.field(n).open;for(let d=l.target,p;d&&d!=this.dom;d=d.parentNode)if(d.nodeName=="LI"&&(p=/-(\d+)$/.exec(d.id))&&+p[1]<u.length){this.applyCompletion(e,u[+p[1]]),l.preventDefault();return}}),this.dom.addEventListener("focusout",l=>{let u=e.state.field(this.stateField,!1);u&&u.tooltip&&e.state.facet(ki).closeOnBlur&&l.relatedTarget!=e.contentDOM&&e.dispatch({effects:K1.of(null)})}),this.showOptions(i,r.id)}mount(){this.updateSel()}showOptions(e,n){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,n,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var n;let a=e.state.field(this.stateField),r=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),a!=r){let{options:i,selected:o,disabled:s}=a.open;(!r.open||r.open.options!=i)&&(this.range=hN(i.length,o,e.state.facet(ki).maxRenderedOptions),this.showOptions(i,a.id)),this.updateSel(),s!=((n=r.open)===null||n===void 0?void 0:n.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!s)}}updateTooltipClass(e){let n=this.tooltipClass(e);if(n!=this.currentClass){for(let a of this.currentClass.split(" "))a&&this.dom.classList.remove(a);for(let a of n.split(" "))a&&this.dom.classList.add(a);this.currentClass=n}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),n=e.open;(n.selected>-1&&n.selected<this.range.from||n.selected>=this.range.to)&&(this.range=hN(n.options.length,n.selected,this.view.state.facet(ki).maxRenderedOptions),this.showOptions(n.options,e.id));let a=this.updateSelectedOption(n.selected);if(a){this.destroyInfo();let{completion:r}=n.options[n.selected],{info:i}=r;if(!i)return;let o=typeof i=="string"?document.createTextNode(i):i(r);if(!o)return;"then"in o?o.then(s=>{s&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(s,r)}).catch(s=>As(this.view.state,s,"completion info")):(this.addInfoPane(o,r),a.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,n){this.destroyInfo();let a=this.info=document.createElement("div");if(a.className="cm-tooltip cm-completionInfo",a.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)a.appendChild(e),this.infoDestroy=null;else{let{dom:r,destroy:i}=e;a.appendChild(r),this.infoDestroy=i||null}this.dom.appendChild(a),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let n=null;for(let a=this.list.firstChild,r=this.range.from;a;a=a.nextSibling,r++)a.nodeName!="LI"||!a.id?r--:r==e?a.hasAttribute("aria-selected")||(a.setAttribute("aria-selected","true"),n=a):a.hasAttribute("aria-selected")&&(a.removeAttribute("aria-selected"),a.removeAttribute("aria-describedby"));return n&&Udt(this.list,n),n}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let n=this.dom.getBoundingClientRect(),a=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),i=this.space;if(!i){let o=this.dom.ownerDocument.documentElement;i={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return r.top>Math.min(i.bottom,n.bottom)-10||r.bottom<Math.max(i.top,n.top)+10?null:this.view.state.facet(ki).positionInfo(this.view,n,r,a,i,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,n,a){const r=document.createElement("ul");r.id=n,r.setAttribute("role","listbox"),r.setAttribute("aria-expanded","true"),r.setAttribute("aria-label",this.view.state.phrase("Completions")),r.addEventListener("mousedown",o=>{o.target==r&&o.preventDefault()});let i=null;for(let o=a.from;o<a.to;o++){let{completion:s,match:l}=e[o],{section:u}=s;if(u){let m=typeof u=="string"?u:u.name;if(m!=i&&(o>a.from||a.from==0))if(i=m,typeof u!="string"&&u.header)r.appendChild(u.header(u));else{let A=r.appendChild(document.createElement("completion-section"));A.textContent=m}}const d=r.appendChild(document.createElement("li"));d.id=n+"-"+o,d.setAttribute("role","option");let p=this.optionClass(s);p&&(d.className=p);for(let m of this.optionContent){let A=m(s,this.view.state,this.view,l);A&&d.appendChild(A)}}return a.from&&r.classList.add("cm-completionListIncompleteTop"),a.to<e.length&&r.classList.add("cm-completionListIncompleteBottom"),r}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function Hdt(t,e){return n=>new zdt(n,t,e)}function Udt(t,e){let n=t.getBoundingClientRect(),a=e.getBoundingClientRect(),r=n.height/t.offsetHeight;a.top<n.top?t.scrollTop-=(n.top-a.top)/r:a.bottom>n.bottom&&(t.scrollTop+=(a.bottom-n.bottom)/r)}function mue(t){return(t.boost||0)*100+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}function Ydt(t,e){let n=[],a=null,r=null,i=d=>{n.push(d);let{section:p}=d.completion;if(p){a||(a=[]);let m=typeof p=="string"?p:p.name;a.some(A=>A.name==m)||a.push(typeof p=="string"?{name:m}:p)}},o=e.facet(ki);for(let d of t)if(d.hasResult()){let p=d.result.getMatch;if(d.result.filter===!1)for(let m of d.result.options)i(new cue(m,d.source,p?p(m):[],1e9-n.length));else{let m=e.sliceDoc(d.from,d.to),A,g=o.filterStrict?new jdt(m):new Odt(m);for(let h of d.result.options)if(A=g.match(h.label)){let f=h.displayLabel?p?p(h,A.matched):[]:A.matched,b=A.score+(h.boost||0);if(i(new cue(h,d.source,f,b)),typeof h.section=="object"&&h.section.rank==="dynamic"){let{name:y}=h.section;r||(r=Object.create(null)),r[y]=Math.max(b,r[y]||-1e9)}}}}if(a){let d=Object.create(null),p=0,m=(A,g)=>(A.rank==="dynamic"&&g.rank==="dynamic"?r[g.name]-r[A.name]:0)||(typeof A.rank=="number"?A.rank:1e9)-(typeof g.rank=="number"?g.rank:1e9)||(A.name<g.name?-1:1);for(let A of a.sort(m))p-=1e5,d[A.name]=p;for(let A of n){let{section:g}=A.completion;g&&(A.score+=d[typeof g=="string"?g:g.name])}}let s=[],l=null,u=o.compareCompletions;for(let d of n.sort((p,m)=>m.score-p.score||u(p.completion,m.completion))){let p=d.completion;!l||l.label!=p.label||l.detail!=p.detail||l.type!=null&&p.type!=null&&l.type!=p.type||l.apply!=p.apply||l.boost!=p.boost?s.push(d):mue(d.completion)>mue(l)&&(s[s.length-1]=d),l=d.completion}return s}class xb{constructor(e,n,a,r,i,o){this.options=e,this.attrs=n,this.tooltip=a,this.timestamp=r,this.selected=i,this.disabled=o}setSelected(e,n){return e==this.selected||e>=this.options.length?this:new xb(this.options,Aue(n,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,n,a,r,i,o){if(r&&!o&&e.some(u=>u.isPending))return r.setDisabled();let s=Ydt(e,n);if(!s.length)return r&&e.some(u=>u.isPending)?r.setDisabled():null;let l=n.facet(ki).selectOnOpen?0:-1;if(r&&r.selected!=l&&r.selected!=-1){let u=r.options[r.selected].completion;for(let d=0;d<s.length;d++)if(s[d].completion==u){l=d;break}}return new xb(s,Aue(a,l),{pos:e.reduce((u,d)=>d.hasResult()?Math.min(u,d.from):u,1e8),create:Xdt,above:i.aboveCursor},r?r.timestamp:Date.now(),l,!1)}map(e){return new xb(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new xb(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class T3{constructor(e,n,a){this.active=e,this.id=n,this.open=a}static start(){return new T3(Vdt,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:n}=e,a=n.facet(ki),i=(a.override||n.languageDataAt("autocomplete",fg(n)).map(Pdt)).map(l=>(this.active.find(d=>d.source==l)||new Bc(l,this.active.some(d=>d.state!=0)?1:0)).update(e,a));i.length==this.active.length&&i.every((l,u)=>l==this.active[u])&&(i=this.active);let o=this.open,s=e.effects.some(l=>l.is(fN));o&&e.docChanged&&(o=o.map(e.changes)),e.selection||i.some(l=>l.hasResult()&&e.changes.touchesRange(l.from,l.to))||!Wdt(i,this.active)||s?o=xb.build(i,n,this.id,o,a,s):o&&o.disabled&&!i.some(l=>l.isPending)&&(o=null),!o&&i.every(l=>!l.isPending)&&i.some(l=>l.hasResult())&&(i=i.map(l=>l.hasResult()?new Bc(l.source,0):l));for(let l of e.effects)l.is(hue)&&(o=o&&o.setSelected(l.value,this.id));return i==this.active&&o==this.open?this:new T3(i,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Kdt:Zdt}}function Wdt(t,e){if(t==e)return!0;for(let n=0,a=0;;){for(;n<t.length&&!t[n].hasResult();)n++;for(;a<e.length&&!e[a].hasResult();)a++;let r=n==t.length,i=a==e.length;if(r||i)return r==i;if(t[n++].result!=e[a++].result)return!1}}const Kdt={"aria-autocomplete":"list"},Zdt={};function Aue(t,e){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(n["aria-activedescendant"]=t+"-"+e),n}const Vdt=[];function gue(t,e){if(t.isUserEvent("input.complete")){let a=t.annotation(uue);if(a&&e.activateOnCompletion(a))return 12}let n=t.isUserEvent("input.type");return n&&e.activateOnTyping?5:n?1:t.isUserEvent("delete.backward")?2:t.selection?8:t.docChanged?16:0}class Bc{constructor(e,n,a=!1){this.source=e,this.state=n,this.explicit=a}hasResult(){return!1}get isPending(){return this.state==1}update(e,n){let a=gue(e,n),r=this;(a&8||a&16&&this.touches(e))&&(r=new Bc(r.source,0)),a&4&&r.state==0&&(r=new Bc(this.source,1)),r=r.updateFor(e,a);for(let i of e.effects)if(i.is(S3))r=new Bc(r.source,1,i.value);else if(i.is(K1))r=new Bc(r.source,0);else if(i.is(fN))for(let o of i.value)o.source==r.source&&(r=o);return r}updateFor(e,n){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(fg(e.state))}}class Eb extends Bc{constructor(e,n,a,r,i,o){super(e,3,n),this.limit=a,this.result=r,this.from=i,this.to=o}hasResult(){return!0}updateFor(e,n){var a;if(!(n&3))return this.map(e.changes);let r=this.result;r.map&&!e.changes.empty&&(r=r.map(r,e.changes));let i=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),s=fg(e.state);if(s>o||!r||n&2&&(fg(e.startState)==this.from||s<this.limit))return new Bc(this.source,n&4?1:0);let l=e.changes.mapPos(this.limit);return Jdt(r.validFor,e.state,i,o)?new Eb(this.source,this.explicit,l,r,i,o):r.update&&(r=r.update(r,i,o,new oue(e.state,s,!1)))?new Eb(this.source,this.explicit,l,r,r.from,(a=r.to)!==null&&a!==void 0?a:fg(e.state)):new Bc(this.source,1,this.explicit)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new Eb(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new Bc(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}function Jdt(t,e,n,a){if(!t)return!1;let r=e.sliceDoc(n,a);return typeof t=="function"?t(r,n,a,e):lue(t,!0).test(r)}const fN=Bn.define({map(t,e){return t.map(n=>n.map(e))}}),hue=Bn.define(),fs=Mi.define({create(){return T3.start()},update(t,e){return t.update(e)},provide:t=>[SL.from(t,e=>e.tooltip),jt.contentAttributes.from(t,e=>e.attrs)]});function bN(t,e){const n=e.completion.apply||e.completion.label;let a=t.state.field(fs).active.find(r=>r.source==e.source);return a instanceof Eb?(typeof n=="string"?t.dispatch({...$dt(t.state,n,a.from,a.to),annotations:uue.of(e.completion)}):n(t,e.completion,a.from,a.to),!0):!1}const Xdt=Hdt(fs,bN);function F3(t,e="option"){return n=>{let a=n.state.field(fs,!1);if(!a||!a.open||a.open.disabled||Date.now()-a.open.timestamp<n.state.facet(ki).interactionDelay)return!1;let r=1,i;e=="page"&&(i=mce(n,a.open.tooltip))&&(r=Math.max(2,Math.floor(i.dom.offsetHeight/i.dom.querySelector("li").offsetHeight)-1));let{length:o}=a.open.options,s=a.open.selected>-1?a.open.selected+r*(t?1:-1):t?0:o-1;return s<0?s=e=="page"?0:o-1:s>=o&&(s=e=="page"?o-1:0),n.dispatch({effects:hue.of(s)}),!0}}const ept=t=>{let e=t.state.field(fs,!1);return t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(ki).interactionDelay?!1:bN(t,e.open.options[e.open.selected])},yN=t=>t.state.field(fs,!1)?(t.dispatch({effects:S3.of(!0)}),!0):!1,tpt=t=>{let e=t.state.field(fs,!1);return!e||!e.active.some(n=>n.state!=0)?!1:(t.dispatch({effects:K1.of(null)}),!0)};class npt{constructor(e,n){this.active=e,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const apt=50,rpt=1e3,ipt=Cr.fromClass(class{constructor(t){this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of t.state.field(fs).active)e.isPending&&this.startQuery(e)}update(t){let e=t.state.field(fs),n=t.state.facet(ki);if(!t.selectionSet&&!t.docChanged&&t.startState.field(fs)==e)return;let a=t.transactions.some(i=>{let o=gue(i,n);return o&8||(i.selection||i.docChanged)&&!(o&3)});for(let i=0;i<this.running.length;i++){let o=this.running[i];if(a||o.context.abortOnDocChange&&t.docChanged||o.updates.length+t.transactions.length>apt&&Date.now()-o.time>rpt){for(let s of o.context.abortListeners)try{s()}catch(l){As(this.view.state,l)}o.context.abortListeners=null,this.running.splice(i--,1)}else o.updates.push(...t.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some(i=>i.effects.some(o=>o.is(S3)))&&(this.pendingStart=!0);let r=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(i=>i.isPending&&!this.running.some(o=>o.active.source==i.source))?setTimeout(()=>this.startUpdate(),r):-1,this.composing!=0)for(let i of t.transactions)i.isUserEvent("input.type")?this.composing=2:this.composing==2&&i.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:t}=this.view,e=t.field(fs);for(let n of e.active)n.isPending&&!this.running.some(a=>a.active.source==n.source)&&this.startQuery(n);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(ki).updateSyncTime))}startQuery(t){let{state:e}=this.view,n=fg(e),a=new oue(e,n,t.explicit,this.view),r=new npt(t,a);this.running.push(r),Promise.resolve(t.source(a)).then(i=>{r.context.aborted||(r.done=i||null,this.scheduleAccept())},i=>{this.view.dispatch({effects:K1.of(null)}),As(this.view.state,i)})}scheduleAccept(){this.running.every(t=>t.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(ki).updateSyncTime))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],n=this.view.state.facet(ki),a=this.view.state.field(fs);for(let r=0;r<this.running.length;r++){let i=this.running[r];if(i.done===void 0)continue;if(this.running.splice(r--,1),i.done){let s=fg(i.updates.length?i.updates[0].startState:this.view.state),l=Math.min(s,i.done.from+(i.active.explicit?0:1)),u=new Eb(i.active.source,i.active.explicit,l,i.done,i.done.from,(t=i.done.to)!==null&&t!==void 0?t:s);for(let d of i.updates)u=u.update(d,n);if(u.hasResult()){e.push(u);continue}}let o=a.active.find(s=>s.source==i.active.source);if(o&&o.isPending)if(i.done==null){let s=new Bc(i.active.source,0);for(let l of i.updates)s=s.update(l,n);s.isPending||e.push(s)}else this.startQuery(o)}(e.length||a.open&&a.open.disabled)&&this.view.dispatch({effects:fN.of(e)})}},{eventHandlers:{blur(t){let e=this.view.state.field(fs,!1);if(e&&e.tooltip&&this.view.state.facet(ki).closeOnBlur){let n=e.open&&mce(this.view,e.open.tooltip);(!n||!n.dom.contains(t.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:K1.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:S3.of(!1)}),20),this.composing=0}}}),opt=typeof navigator=="object"&&/Win/.test(navigator.platform),spt=cg.highest(jt.domEventHandlers({keydown(t,e){let n=e.state.field(fs,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||t.key.length>1||t.ctrlKey&&!(opt&&t.altKey)||t.metaKey)return!1;let a=n.open.options[n.open.selected],r=n.active.find(o=>o.source==a.source),i=a.completion.commitCharacters||r.result.commitCharacters;return i&&i.indexOf(t.key)>-1&&bN(e,a),!1}})),cpt=jt.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),Z1={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},bg=Bn.define({map(t,e){let n=e.mapPos(t,-1,Mo.TrackAfter);return n??void 0}}),wN=new class extends lg{};wN.startSide=1,wN.endSide=-1;const fue=Mi.define({create(){return ta.empty},update(t,e){if(t=t.map(e.changes),e.selection){let n=e.state.doc.lineAt(e.selection.main.head);t=t.update({filter:a=>a>=n.from&&a<=n.to})}for(let n of e.effects)n.is(bg)&&(t=t.update({add:[wN.range(n.value,n.value+1)]}));return t}});function lpt(){return[dpt,fue]}const kN="()[]{}<>«»»«[]{}";function bue(t){for(let e=0;e<kN.length;e+=2)if(kN.charCodeAt(e)==t)return kN.charAt(e+1);return EF(t<128?t:t+1)}function yue(t,e){return t.languageDataAt("closeBrackets",e)[0]||Z1}const upt=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),dpt=jt.inputHandler.of((t,e,n,a)=>{if((upt?t.composing:t.compositionStarted)||t.state.readOnly)return!1;let r=t.state.selection.main;if(a.length>2||a.length==2&&su(ms(a,0))==1||e!=r.from||n!=r.to)return!1;let i=mpt(t.state,a);return i?(t.dispatch(i),!0):!1}),ppt=[{key:"Backspace",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let a=yue(t,t.selection.main.head).brackets||Z1.brackets,r=null,i=t.changeByRange(o=>{if(o.empty){let s=Apt(t.doc,o.head);for(let l of a)if(l==s&&L3(t.doc,o.head)==bue(ms(l,0)))return{changes:{from:o.head-l.length,to:o.head+l.length},range:lt.cursor(o.head-l.length)}}return{range:r=o}});return r||e(t.update(i,{scrollIntoView:!0,userEvent:"delete.backward"})),!r}}];function mpt(t,e){let n=yue(t,t.selection.main.head),a=n.brackets||Z1.brackets;for(let r of a){let i=bue(ms(r,0));if(e==r)return i==r?fpt(t,r,a.indexOf(r+r+r)>-1,n):gpt(t,r,i,n.before||Z1.before);if(e==i&&wue(t,t.selection.main.from))return hpt(t,r,i)}return null}function wue(t,e){let n=!1;return t.field(fue).between(0,t.doc.length,a=>{a==e&&(n=!0)}),n}function L3(t,e){let n=t.sliceString(e,e+2);return n.slice(0,su(ms(n,0)))}function Apt(t,e){let n=t.sliceString(e-2,e);return su(ms(n,0))==n.length?n:n.slice(1)}function gpt(t,e,n,a){let r=null,i=t.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:n,from:o.to}],effects:bg.of(o.to+e.length),range:lt.range(o.anchor+e.length,o.head+e.length)};let s=L3(t.doc,o.head);return!s||/\s/.test(s)||a.indexOf(s)>-1?{changes:{insert:e+n,from:o.head},effects:bg.of(o.head+e.length),range:lt.cursor(o.head+e.length)}:{range:r=o}});return r?null:t.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function hpt(t,e,n){let a=null,r=t.changeByRange(i=>i.empty&&L3(t.doc,i.head)==n?{changes:{from:i.head,to:i.head+n.length,insert:n},range:lt.cursor(i.head+n.length)}:a={range:i});return a?null:t.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function fpt(t,e,n,a){let r=a.stringPrefixes||Z1.stringPrefixes,i=null,o=t.changeByRange(s=>{if(!s.empty)return{changes:[{insert:e,from:s.from},{insert:e,from:s.to}],effects:bg.of(s.to+e.length),range:lt.range(s.anchor+e.length,s.head+e.length)};let l=s.head,u=L3(t.doc,l),d;if(u==e){if(kue(t,l))return{changes:{insert:e+e,from:l},effects:bg.of(l+e.length),range:lt.cursor(l+e.length)};if(wue(t,l)){let m=n&&t.sliceDoc(l,l+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:l,to:l+m.length,insert:m},range:lt.cursor(l+m.length)}}}else{if(n&&t.sliceDoc(l-2*e.length,l)==e+e&&(d=vue(t,l-2*e.length,r))>-1&&kue(t,d))return{changes:{insert:e+e+e+e,from:l},effects:bg.of(l+e.length),range:lt.cursor(l+e.length)};if(t.charCategorizer(l)(u)!=Za.Word&&vue(t,l,r)>-1&&!bpt(t,l,e,r))return{changes:{insert:e+e,from:l},effects:bg.of(l+e.length),range:lt.cursor(l+e.length)}}return{range:i=s}});return i?null:t.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function kue(t,e){let n=oo(t).resolveInner(e+1);return n.parent&&n.from==e}function bpt(t,e,n,a){let r=oo(t).resolveInner(e,-1),i=a.reduce((o,s)=>Math.max(o,s.length),0);for(let o=0;o<5;o++){let s=t.sliceDoc(r.from,Math.min(r.to,r.from+n.length+i)),l=s.indexOf(n);if(!l||l>-1&&a.indexOf(s.slice(0,l))>-1){let d=r.firstChild;for(;d&&d.from==r.from&&d.to-d.from>n.length+l;){if(t.sliceDoc(d.to-n.length,d.to)==n)return!1;d=d.firstChild}return!0}let u=r.to==e&&r.parent;if(!u)break;r=u}return!1}function vue(t,e,n){let a=t.charCategorizer(e);if(a(t.sliceDoc(e-1,e))!=Za.Word)return e;for(let r of n){let i=e-r.length;if(t.sliceDoc(i,e)==r&&a(t.sliceDoc(i-1,i))!=Za.Word)return i}return-1}function ypt(t={}){return[spt,fs,ki.of(t),ipt,wpt,cpt]}const Cue=[{key:"Ctrl-Space",run:yN},{mac:"Alt-`",run:yN},{mac:"Alt-i",run:yN},{key:"Escape",run:tpt},{key:"ArrowDown",run:F3(!0)},{key:"ArrowUp",run:F3(!1)},{key:"PageDown",run:F3(!0,"page")},{key:"PageUp",run:F3(!1,"page")},{key:"Enter",run:ept}],wpt=cg.highest(K2.computeN([ki],t=>t.facet(ki).defaultKeymap?[Cue]:[]));class _ue{constructor(e,n,a){this.from=e,this.to=n,this.diagnostic=a}}class yg{constructor(e,n,a){this.diagnostics=e,this.panel=n,this.selected=a}static init(e,n,a){let r=a.facet(V1).markerFilter;r&&(e=r(e,a));let i=e.slice().sort((A,g)=>A.from-g.from||A.to-g.to),o=new xd,s=[],l=0,u=a.doc.iter(),d=0,p=a.doc.length;for(let A=0;;){let g=A==i.length?null:i[A];if(!g&&!s.length)break;let h,f;if(s.length)h=l,f=s.reduce((w,k)=>Math.min(w,k.to),g&&g.from>h?g.from:1e8);else{if(h=g.from,h>p)break;f=g.to,s.push(g),A++}for(;A<i.length;){let w=i[A];if(w.from==h&&(w.to>w.from||w.to==h))s.push(w),A++,f=Math.min(w.to,f);else{f=Math.min(w.from,f);break}}f=Math.min(f,p);let b=!1;if(s.some(w=>w.from==h&&(w.to==f||f==p))&&(b=h==f,!b&&f-h<10)){let w=h-(d+u.value.length);w>0&&(u.next(w),d=h);for(let k=h;;){if(k>=f){b=!0;break}if(!u.lineBreak&&d+u.value.length>k)break;k=d+u.value.length,d+=u.value.length,u.next()}}let y=Tpt(s);if(b)o.add(h,h,ln.widget({widget:new Ipt(y),diagnostics:s.slice()}));else{let w=s.reduce((k,C)=>C.markClass?k+" "+C.markClass:k,"");o.add(h,f,ln.mark({class:"cm-lintRange cm-lintRange-"+y+w,diagnostics:s.slice(),inclusiveEnd:s.some(k=>k.to>f)}))}if(l=f,l==p)break;for(let w=0;w<s.length;w++)s[w].to<=l&&s.splice(w--,1)}let m=o.finish();return new yg(m,n,Bb(m))}}function Bb(t,e=null,n=0){let a=null;return t.between(n,1e9,(r,i,{spec:o})=>{if(!(e&&o.diagnostics.indexOf(e)<0))if(!a)a=new _ue(r,i,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(a.diagnostic)<0)return!1;a=new _ue(a.from,i,a.diagnostic)}}),a}function kpt(t,e){let n=e.pos,a=e.end||n,r=t.state.facet(V1).hideOn(t,n,a);if(r!=null)return r;let i=t.startState.doc.lineAt(e.pos);return!!(t.effects.some(o=>o.is(xue))||t.changes.touchesRange(i.from,Math.max(i.to,a)))}function vpt(t,e){return t.field(qs,!1)?e:e.concat(Bn.appendConfig.of(Fpt))}const xue=Bn.define(),vN=Bn.define(),Eue=Bn.define(),qs=Mi.define({create(){return new yg(ln.none,null,null)},update(t,e){if(e.docChanged&&t.diagnostics.size){let n=t.diagnostics.map(e.changes),a=null,r=t.panel;if(t.selected){let i=e.changes.mapPos(t.selected.from,1);a=Bb(n,t.selected.diagnostic,i)||Bb(n,null,i)}!n.size&&r&&e.state.facet(V1).autoPanel&&(r=null),t=new yg(n,r,a)}for(let n of e.effects)if(n.is(xue)){let a=e.state.facet(V1).autoPanel?n.value.length?J1.open:null:t.panel;t=yg.init(n.value,a,e.state)}else n.is(vN)?t=new yg(t.diagnostics,n.value?J1.open:null,t.selected):n.is(Eue)&&(t=new yg(t.diagnostics,t.panel,n.value));return t},provide:t=>[N1.from(t,e=>e.panel),jt.decorations.from(t,e=>e.diagnostics)]}),Cpt=ln.mark({class:"cm-lintRange cm-lintRange-active"});function _pt(t,e,n){let{diagnostics:a}=t.state.field(qs),r,i=-1,o=-1;a.between(e-(n<0?1:0),e+(n>0?1:0),(l,u,{spec:d})=>{if(e>=l&&e<=u&&(l==u||(e>l||n>0)&&(e<u||n<0)))return r=d.diagnostics,i=l,o=u,!1});let s=t.state.facet(V1).tooltipFilter;return r&&s&&(r=s(r,t.state)),r?{pos:i,end:o,above:t.state.doc.lineAt(i).to<o,create(){return{dom:xpt(t,r)}}}:null}function xpt(t,e){return xa("ul",{class:"cm-tooltip-lint"},e.map(n=>Que(t,n,!1)))}const Ept=t=>{let e=t.state.field(qs,!1);(!e||!e.panel)&&t.dispatch({effects:vpt(t.state,[vN.of(!0)])});let n=L1(t,J1.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},Bue=t=>{let e=t.state.field(qs,!1);return!e||!e.panel?!1:(t.dispatch({effects:vN.of(!1)}),!0)},Bpt=[{key:"Mod-Shift-m",run:Ept,preventDefault:!0},{key:"F8",run:t=>{let e=t.state.field(qs,!1);if(!e)return!1;let n=t.state.selection.main,a=e.diagnostics.iter(n.to+1);return!a.value&&(a=e.diagnostics.iter(0),!a.value||a.from==n.from&&a.to==n.to)?!1:(t.dispatch({selection:{anchor:a.from,head:a.to},scrollIntoView:!0}),!0)}}],V1=Ht.define({combine(t){return{sources:t.map(e=>e.source).filter(e=>e!=null),...uu(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:Iue,tooltipFilter:Iue,needsRefresh:(e,n)=>e?n?a=>e(a)||n(a):e:n,hideOn:(e,n)=>e?n?(a,r,i)=>e(a,r,i)||n(a,r,i):e:n,autoPanel:(e,n)=>e||n})}}});function Iue(t,e){return t?e?(n,a)=>e(t(n,a),a):t:e}function Due(t){let e=[];if(t)e:for(let{name:n}of t){for(let a=0;a<n.length;a++){let r=n[a];if(/[a-zA-Z]/.test(r)&&!e.some(i=>i.toLowerCase()==r.toLowerCase())){e.push(r);continue e}}e.push("")}return e}function Que(t,e,n){var a;let r=n?Due(e.actions):[];return xa("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},xa("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),(a=e.actions)===null||a===void 0?void 0:a.map((i,o)=>{let s=!1,l=A=>{if(A.preventDefault(),s)return;s=!0;let g=Bb(t.state.field(qs).diagnostics,e);g&&i.apply(t,g.from,g.to)},{name:u}=i,d=r[o]?u.indexOf(r[o]):-1,p=d<0?u:[u.slice(0,d),xa("u",u.slice(d,d+1)),u.slice(d+1)],m=i.markClass?" "+i.markClass:"";return xa("button",{type:"button",class:"cm-diagnosticAction"+m,onclick:l,onmousedown:l,"aria-label":` Action: ${u}${d<0?"":` (access key "${r[o]})"`}.`},p)}),e.source&&xa("div",{class:"cm-diagnosticSource"},e.source))}class Ipt extends Bd{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return xa("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class Sue{constructor(e,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=Que(e,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class J1{constructor(e){this.view=e,this.items=[];let n=r=>{if(r.keyCode==27)Bue(this.view),this.view.focus();else if(r.keyCode==38||r.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(r.keyCode==40||r.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(r.keyCode==36)this.moveSelection(0);else if(r.keyCode==35)this.moveSelection(this.items.length-1);else if(r.keyCode==13)this.view.focus();else if(r.keyCode>=65&&r.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:i}=this.items[this.selectedIndex],o=Due(i.actions);for(let s=0;s<o.length;s++)if(o[s].toUpperCase().charCodeAt(0)==r.keyCode){let l=Bb(this.view.state.field(qs).diagnostics,i);l&&i.actions[s].apply(e,l.from,l.to)}}else return;r.preventDefault()},a=r=>{for(let i=0;i<this.items.length;i++)this.items[i].dom.contains(r.target)&&this.moveSelection(i)};this.list=xa("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:n,onclick:a}),this.dom=xa("div",{class:"cm-panel-lint"},this.list,xa("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>Bue(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(qs).selected;if(!e)return-1;for(let n=0;n<this.items.length;n++)if(this.items[n].diagnostic==e.diagnostic)return n;return-1}update(){let{diagnostics:e,selected:n}=this.view.state.field(qs),a=0,r=!1,i=null,o=new Set;for(e.between(0,this.view.state.doc.length,(s,l,{spec:u})=>{for(let d of u.diagnostics){if(o.has(d))continue;o.add(d);let p=-1,m;for(let A=a;A<this.items.length;A++)if(this.items[A].diagnostic==d){p=A;break}p<0?(m=new Sue(this.view,d),this.items.splice(a,0,m),r=!0):(m=this.items[p],p>a&&(this.items.splice(a,p-a),r=!0)),n&&m.diagnostic==n.diagnostic?m.dom.hasAttribute("aria-selected")||(m.dom.setAttribute("aria-selected","true"),i=m):m.dom.hasAttribute("aria-selected")&&m.dom.removeAttribute("aria-selected"),a++}});a<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new Sue(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),r=!0),i?(this.list.setAttribute("aria-activedescendant",i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:s,panel:l})=>{let u=l.height/this.list.offsetHeight;s.top<l.top?this.list.scrollTop-=(l.top-s.top)/u:s.bottom>l.bottom&&(this.list.scrollTop+=(s.bottom-l.bottom)/u)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),r&&this.sync()}sync(){let e=this.list.firstChild;function n(){let a=e;e=a.nextSibling,a.remove()}for(let a of this.items)if(a.dom.parentNode==this.list){for(;e!=a.dom;)n();e=a.dom.nextSibling}else this.list.insertBefore(a.dom,e);for(;e;)n()}moveSelection(e){if(this.selectedIndex<0)return;let n=this.view.state.field(qs),a=Bb(n.diagnostics,this.items[e].diagnostic);a&&this.view.dispatch({selection:{anchor:a.from,head:a.to},scrollIntoView:!0,effects:Eue.of(a)})}static open(e){return new J1(e)}}function Dpt(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(t)}</svg>')`}function N3(t){return Dpt(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${t}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const Qpt=jt.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:N3("#d11")},".cm-lintRange-warning":{backgroundImage:N3("orange")},".cm-lintRange-info":{backgroundImage:N3("#999")},".cm-lintRange-hint":{backgroundImage:N3("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});function Spt(t){return t=="error"?4:t=="warning"?3:t=="info"?2:1}function Tpt(t){let e="hint",n=1;for(let a of t){let r=Spt(a.severity);r>n&&(n=r,e=a.severity)}return e}const Fpt=[qs,jt.decorations.compute([qs],t=>{let{selected:e,panel:n}=t.field(qs);return!e||!n||e.from==e.to?ln.none:ln.set([Cpt.range(e.from,e.to)])}),Qct(_pt,{hideOn:kpt}),Qpt];var Tue=function(e){e===void 0&&(e={});var{crosshairCursor:n=!1}=e,a=[];e.closeBracketsKeymap!==!1&&(a=a.concat(ppt)),e.defaultKeymap!==!1&&(a=a.concat(odt)),e.searchKeymap!==!1&&(a=a.concat(Tdt)),e.historyKeymap!==!1&&(a=a.concat(mut)),e.foldKeymap!==!1&&(a=a.concat(Ilt)),e.completionKeymap!==!1&&(a=a.concat(Cue)),e.lintKeymap!==!1&&(a=a.concat(Bpt));var r=[];return e.lineNumbers!==!1&&r.push(jct()),e.highlightActiveLineGutter!==!1&&r.push(zct()),e.highlightSpecialChars!==!1&&r.push(ict()),e.history!==!1&&r.push(rut()),e.foldGutter!==!1&&r.push(Tlt()),e.drawSelection!==!1&&r.push(Wst()),e.dropCursor!==!1&&r.push(Xst()),e.allowMultipleSelections!==!1&&r.push(Hn.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&r.push(wlt()),e.syntaxHighlighting!==!1&&r.push(Xce(Mlt,{fallback:!0})),e.bracketMatching!==!1&&r.push(Glt()),e.closeBrackets!==!1&&r.push(lpt()),e.autocompletion!==!1&&r.push(ypt()),e.rectangularSelection!==!1&&r.push(yct()),n!==!1&&r.push(vct()),e.highlightActiveLine!==!1&&r.push(dct()),e.highlightSelectionMatches!==!1&&r.push(mdt()),e.tabSize&&typeof e.tabSize=="number"&&r.push(p3.of(" ".repeat(e.tabSize))),r.concat([K2.of(a.flat())]).filter(Boolean)};const Lpt="#e5c07b",Fue="#e06c75",Npt="#56b6c2",Mpt="#ffffff",M3="#abb2bf",CN="#7d8799",Rpt="#61afef",$pt="#98c379",Lue="#d19a66",Ppt="#c678dd",Opt="#21252b",Nue="#2c313a",Mue="#282c34",_N="#353a42",jpt="#3E4451",Rue="#528bff",Gpt=jt.theme({"&":{color:M3,backgroundColor:Mue},".cm-content":{caretColor:Rue},".cm-cursor, .cm-dropCursor":{borderLeftColor:Rue},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:jpt},".cm-panels":{backgroundColor:Opt,color:M3},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:Mue,color:CN,border:"none"},".cm-activeLineGutter":{backgroundColor:Nue},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:_N},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:_N,borderBottomColor:_N},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:Nue,color:M3}}},{dark:!0}),qpt=q1.define([{tag:Xe.keyword,color:Ppt},{tag:[Xe.name,Xe.deleted,Xe.character,Xe.propertyName,Xe.macroName],color:Fue},{tag:[Xe.function(Xe.variableName),Xe.labelName],color:Rpt},{tag:[Xe.color,Xe.constant(Xe.name),Xe.standard(Xe.name)],color:Lue},{tag:[Xe.definition(Xe.name),Xe.separator],color:M3},{tag:[Xe.typeName,Xe.className,Xe.number,Xe.changed,Xe.annotation,Xe.modifier,Xe.self,Xe.namespace],color:Lpt},{tag:[Xe.operator,Xe.operatorKeyword,Xe.url,Xe.escape,Xe.regexp,Xe.link,Xe.special(Xe.string)],color:Npt},{tag:[Xe.meta,Xe.comment],color:CN},{tag:Xe.strong,fontWeight:"bold"},{tag:Xe.emphasis,fontStyle:"italic"},{tag:Xe.strikethrough,textDecoration:"line-through"},{tag:Xe.link,color:CN,textDecoration:"underline"},{tag:Xe.heading,fontWeight:"bold",color:Fue},{tag:[Xe.atom,Xe.bool,Xe.special(Xe.variableName)],color:Lue},{tag:[Xe.processingInstruction,Xe.string,Xe.inserted],color:$pt},{tag:Xe.invalid,color:Mpt}]),zpt=[Gpt,Xce(qpt)];var Hpt=jt.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),Upt=function(e){e===void 0&&(e={});var{indentWithTab:n=!0,editable:a=!0,readOnly:r=!1,theme:i="light",placeholder:o="",basicSetup:s=!0}=e,l=[];switch(n&&l.unshift(K2.of([sdt])),s&&(typeof s=="boolean"?l.unshift(Tue()):l.unshift(Tue(s))),o&&l.unshift(gct(o)),i){case"light":l.push(Hpt);break;case"dark":l.push(zpt);break;case"none":break;default:l.push(i);break}return a===!1&&l.push(jt.editable.of(!1)),r&&l.push(Hn.readOnly.of(!0)),[...l]},Ypt=t=>({line:t.state.doc.lineAt(t.state.selection.main.from),lineCount:t.state.doc.lines,lineBreak:t.state.lineBreak,length:t.state.doc.length,readOnly:t.state.readOnly,tabSize:t.state.tabSize,selection:t.state.selection,selectionAsSingle:t.state.selection.asSingle().main,ranges:t.state.selection.ranges,selectionCode:t.state.sliceDoc(t.state.selection.main.from,t.state.selection.main.to),selections:t.state.selection.ranges.map(e=>t.state.sliceDoc(e.from,e.to)),selectedText:t.state.selection.ranges.some(e=>!e.empty)});class Wpt{constructor(e,n){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=n,this.timeoutMS=n,this.callbacks.push(e)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var e=this.callbacks.slice();this.callbacks.length=0,e.forEach(n=>{try{n()}catch(a){console.error("TimeoutLatch callback error:",a)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}}class $ue{constructor(){this.interval=null,this.latches=new Set}add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}}var xN=null,Kpt=()=>typeof window>"u"?new $ue:(xN||(xN=new $ue),xN),Pue=lu.define(),Zpt=200,Vpt=[];function Jpt(t){var{value:e,selection:n,onChange:a,onStatistics:r,onCreateEditor:i,onUpdate:o,extensions:s=Vpt,autoFocus:l,theme:u="light",height:d=null,minHeight:p=null,maxHeight:m=null,width:A=null,minWidth:g=null,maxWidth:h=null,placeholder:f="",editable:b=!0,readOnly:y=!1,indentWithTab:w=!0,basicSetup:k=!0,root:C,initialState:x}=t,[_,E]=he.useState(),[D,Q]=he.useState(),[B,T]=he.useState(),N=he.useState(()=>({current:null}))[0],I=he.useState(()=>({current:null}))[0],S=jt.theme({"&":{height:d,minHeight:p,maxHeight:m,width:A,minWidth:g,maxWidth:h},"& .cm-scroller":{height:"100% !important"}}),M=jt.updateListener.of(R=>{if(R.docChanged&&typeof a=="function"&&!R.transactions.some(q=>q.annotation(Pue))){N.current?N.current.reset():(N.current=new Wpt(()=>{if(I.current){var q=I.current;I.current=null,q()}N.current=null},Zpt),Kpt().add(N.current));var $=R.state.doc,P=$.toString();a(P,R)}r&&r(Ypt(R))}),L=Upt({theme:u,editable:b,readOnly:y,placeholder:f,indentWithTab:w,basicSetup:k}),F=[M,S,...L];return o&&typeof o=="function"&&F.push(jt.updateListener.of(o)),F=F.concat(s),he.useLayoutEffect(()=>{if(_&&!B){var R={doc:e,selection:n,extensions:F},$=x?Hn.fromJSON(x.json,R,x.fields):Hn.create(R);if(T($),!D){var P=new jt({state:$,parent:_,root:C});Q(P),i&&i(P,$)}}return()=>{D&&(T(void 0),Q(void 0))}},[_,B]),he.useEffect(()=>{t.container&&E(t.container)},[t.container]),he.useEffect(()=>()=>{D&&(D.destroy(),Q(void 0)),N.current&&(N.current.cancel(),N.current=null)},[D]),he.useEffect(()=>{l&&D&&D.focus()},[l,D]),he.useEffect(()=>{D&&D.dispatch({effects:Bn.reconfigure.of(F)})},[u,s,d,p,m,A,g,h,f,b,y,w,k,a,o]),he.useEffect(()=>{if(e!==void 0){var R=D?D.state.doc.toString():"";if(D&&e!==R){var $=N.current&&!N.current.isDone,P=()=>{D&&e!==D.state.doc.toString()&&D.dispatch({changes:{from:0,to:D.state.doc.toString().length,insert:e||""},annotations:[Pue.of(!0)]})};$?I.current=P:P()}}},[e,D]),{state:B,setState:T,view:D,setView:Q,container:_,setContainer:E}}var Xpt=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],Oue=he.forwardRef((t,e)=>{var{className:n,value:a="",selection:r,extensions:i=[],onChange:o,onStatistics:s,onCreateEditor:l,onUpdate:u,autoFocus:d,theme:p="light",height:m,minHeight:A,maxHeight:g,width:h,minWidth:f,maxWidth:b,basicSetup:y,placeholder:w,indentWithTab:k,editable:C,readOnly:x,root:_,initialState:E}=t,D=zit(t,Xpt),Q=he.useRef(null),{state:B,view:T,container:N,setContainer:I}=Jpt({root:_,value:a,autoFocus:d,theme:p,height:m,minHeight:A,maxHeight:g,width:h,minWidth:f,maxWidth:b,basicSetup:y,placeholder:w,indentWithTab:k,editable:C,readOnly:x,selection:r,onChange:o,onStatistics:s,onCreateEditor:l,onUpdate:u,extensions:i,initialState:E});he.useImperativeHandle(e,()=>({editor:Q.current,state:B,view:T}),[Q,N,B,T]);var S=he.useCallback(L=>{Q.current=L,I(L)},[I]);if(typeof a!="string")throw new Error("value must be typeof string but got "+typeof a);var M=typeof p=="string"?"cm-theme-"+p:"cm-theme";return H.jsx("div",CF({ref:S,className:""+M+(n?" "+n:"")},D))});Oue.displayName="CodeMirror";var jue={npm_package_exports___require:"./dist/ai-agent.umd.js",npm_package_devDependencies__types_node:"20.2.5",npm_package_devDependencies_tw_animate_css:"1.4.0",npm_package_devDependencies_vitest:"1.2.2",npm_package_devDependencies__testing_library_jest_dom:"6.4.0",npm_config_user_agent:"pnpm/9.10.0 npm/? node/v20.17.0 linux x64",CI:"true",npm_package_devDependencies__testing_library_user_event:"14.5.2",npm_package_dependencies_cmdk:"1.1.1",npm_package_dependencies_embla_carousel_react:"8.6.0",npm_package_devDependencies_vite:"5.0.12",npm_node_execpath:"/opt/hostedtoolcache/node/20.17.0/x64/bin/node",npm_package_publishConfig_access:"public",npm_package_files_0:"dist",npm_package_dependencies__radix_ui_react_tooltip:"1.2.8",HOME:"/home/runner",npm_package_dependencies__radix_ui_react_dialog:"1.1.15",npm_package_dependencies__radix_ui_react_hover_card:"1.1.15",npm_package_devDependencies_classnames:"2.3.2",npm_package_devDependencies_sass:"1.62.1",npm_package_devDependencies_vite_plugin_static_copy:"1.0.0",npm_package_dependencies__radix_ui_react_separator:"1.1.8",npm_package_dependencies_shiki:"3.20.0",npm_config_auto_install_peers:"true",npm_package_dependencies_class_variance_authority:"0.7.1",npm_package_devDependencies_vite_plugin_dts:"3.7.1",npm_package_dependencies__radix_ui_react_dropdown_menu:"2.1.16",npm_package_dependencies__xyflow_react:"12.10.0",npm_package_devDependencies_tailwindcss:"4.1.18",npm_package_devDependencies_typescript:"5.1.3",npm_package_types:"./dist/index.d.ts",npm_package_devDependencies__types_react_dom:"18.3.1",npm_package_devDependencies__vitejs_plugin_react_swc:"3.5.0",npm_package_type:"module",npm_package_exports___default:"./dist/ai-agent.es.js",npm_package_dependencies__radix_ui_react_use_controllable_state:"1.2.2",npm_package_module:"./dist/ai-agent.es.js",npm_package_devDependencies__types_testing_library__jest_dom:"6.0.0",npm_package_dependencies_motion:"12.23.26",npm_package_devDependencies__vitest_coverage_v8:"1.2.2",npm_config_registry:"https://registry.npmjs.org/",npm_config_node_linker:"hoisted",npm_package_dependencies__codemirror_lang_json:"6.0.1",npm_package_dependencies_streamdown:"1.6.10",npm_package_exports___import:"./dist/ai-agent.es.js",npm_package_dependencies_tailwind_merge:"3.4.0",npm_config_node_gyp:"/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules/pnpm/dist/node_modules/node-gyp/bin/node-gyp.js",PATH:"/home/runner/work/avocado/avocado/packages/ai-agent/node_modules/.bin:/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules/pnpm/dist/node-gyp-bin:/home/runner/work/avocado/avocado/node_modules/.bin:/home/runner/work/avocado/avocado/node_modules/.bin:/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules/pnpm/dist/node-gyp-bin:/home/runner/work/avocado/avocado/node_modules/.bin:/opt/hostedtoolcache/node/20.17.0/x64/bin:/home/runner/setup-pnpm/node_modules/.bin:/snap/bin:/home/runner/.local/bin:/opt/pipx_bin:/home/runner/.cargo/bin:/home/runner/.config/composer/vendor/bin:/usr/local/.ghcup/bin:/home/runner/.dotnet/tools:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin",TURBO_HASH:"f12dd1fb9509a194",npm_package_name:"@foris/ai-agent",npm_package_dependencies_postcss:"8.5.6",NODE:"/opt/hostedtoolcache/node/20.17.0/x64/bin/node",npm_package_dependencies__radix_ui_react_select:"2.2.6",npm_package_dependencies_lucide_react:"0.561.0",npm_package_dependencies_tokenlens:"1.3.1",npm_config_frozen_lockfile:"",npm_package_devDependencies__vitest_ui:"1.2.2",npm_config_legacy_peer_deps:"true",LANG:"C.UTF-8",npm_package_dependencies_react_dom:"18.3.1",npm_package_main:"./dist/ai-agent.umd.js",npm_package_dependencies_ai:"5.0.115",npm_package_dependencies_react_markdown:"10.1.0",npm_lifecycle_script:"tsc && vite build",npm_package_dependencies__uiw_react_codemirror:"4.25.4",SHELL:"/bin/bash",NODE_PATH:"/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules/pnpm/bin/node_modules:/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules/pnpm/node_modules:/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules:/home/runner/setup-pnpm/node_modules/.pnpm/node_modules",npm_package_version:"0.8.2",npm_package_dependencies__radix_ui_react_slot:"1.2.4",npm_package_dependencies_nanoid:"5.1.6",npm_package_devDependencies__testing_library_react:"14.2.0",npm_package_devDependencies__types_react:"18.3.1",npm_package_devDependencies_jsdom:"24.0.0",npm_lifecycle_event:"build",npm_package_scripts_build:"tsc && vite build",npm_package_dependencies__ai_sdk_react:"2.0.117",npm_package_dependencies_clsx:"2.1.1",npm_package_devDependencies__foris_tsconfig:"workspace:*",npm_package_scripts_test_watch:"vitest --ui",npm_package_scripts_coverage:"vitest run --coverage",PWD:"/home/runner/work/avocado/avocado/packages/ai-agent",npm_package_dependencies__radix_ui_react_progress:"1.1.8",npm_execpath:"/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules/pnpm/bin/pnpm.cjs",npm_package_exports___types:"./dist/index.d.ts",npm_package_dependencies__radix_ui_react_scroll_area:"1.2.10",npm_package_dependencies__tailwindcss_postcss:"4.1.18",npm_package_devDependencies__shikijs_transformers:"3.20.0",npm_command:"run-script",PNPM_SCRIPT_SRC_DIR:"/home/runner/work/avocado/avocado/packages/ai-agent",npm_package_dependencies__radix_ui_react_collapsible:"1.1.12",npm_package_dependencies_react:"18.3.1",npm_package_dependencies_use_stick_to_bottom:"1.1.1",INIT_CWD:"/home/runner/work/avocado/avocado/packages/ai-agent",NODE_ENV:"production"};let emt=class HH{constructor(e,n,a,r,i,o,s,l,u,d=0,p){this.p=e,this.stack=n,this.state=a,this.reducePos=r,this.pos=i,this.score=o,this.buffer=s,this.bufferBase=l,this.curContext=u,this.lookAhead=d,this.parent=p}toString(){return`[${this.stack.filter((e,n)=>n%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,n,a=0){let r=e.parser.context;return new HH(e,[],n,a,a,0,[],0,r?new Gue(r,r.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,n){this.stack.push(this.state,n,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var n;let a=e>>19,r=e&65535,{parser:i}=this.p,o=this.reducePos<this.pos-25;o&&this.setLookAhead(this.pos);let s=i.dynamicPrecedence(r);if(s&&(this.score+=s),a==0){this.pushState(i.getGoto(this.state,r,!0),this.reducePos),r<i.minRepeatTerm&&this.storeNode(r,this.reducePos,this.reducePos,o?8:4,!0),this.reduceContext(r,this.reducePos);return}let l=this.stack.length-(a-1)*3-(e&262144?6:0),u=l?this.stack[l-2]:this.p.ranges[0].from,d=this.reducePos-u;d>=2e3&&!(!((n=this.p.parser.nodeSet.types[r])===null||n===void 0)&&n.isAnonymous)&&(u==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=d):this.p.lastBigReductionSize<d&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=u,this.p.lastBigReductionSize=d));let p=l?this.stack[l-1]:0,m=this.bufferBase+this.buffer.length-p;if(r<i.minRepeatTerm||e&131072){let A=i.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(r,u,A,m+4,!0)}if(e&262144)this.state=this.stack[l];else{let A=this.stack[l-3];this.state=i.getGoto(A,r,!0)}for(;this.stack.length>l;)this.stack.pop();this.reduceContext(r,u)}storeNode(e,n,a,r=4,i=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this,s=this.buffer.length;if(s==0&&o.parent&&(s=o.bufferBase-o.parent.bufferBase,o=o.parent),s>0&&o.buffer[s-4]==0&&o.buffer[s-1]>-1){if(n==a)return;if(o.buffer[s-2]>=n){o.buffer[s-2]=a;return}}}if(!i||this.pos==a)this.buffer.push(e,n,a,r);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let s=!1;for(let l=o;l>0&&this.buffer[l-2]>a;l-=4)if(this.buffer[l-1]>=0){s=!0;break}if(s)for(;o>0&&this.buffer[o-2]>a;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,r>4&&(r-=4)}this.buffer[o]=e,this.buffer[o+1]=n,this.buffer[o+2]=a,this.buffer[o+3]=r}}shift(e,n,a,r){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=r,this.shiftContext(n,a),n<=this.p.parser.maxNode&&this.buffer.push(n,a,r,4);else{let i=e,{parser:o}=this.p;(r>this.pos||n<=o.maxNode)&&(this.pos=r,o.stateFlag(i,1)||(this.reducePos=r)),this.pushState(i,a),this.shiftContext(n,a),n<=o.maxNode&&this.buffer.push(n,a,r,4)}}apply(e,n,a,r){e&65536?this.reduce(e):this.shift(e,n,a,r)}useNode(e,n){let a=this.p.reused.length-1;(a<0||this.p.reused[a]!=e)&&(this.p.reused.push(e),a++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(n,r),this.buffer.push(a,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,n=e.buffer.length;for(;n>0&&e.buffer[n-2]>e.reducePos;)n-=4;let a=e.buffer.slice(n),r=e.bufferBase+n;for(;e&&r==e.bufferBase;)e=e.parent;return new HH(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,a,r,this.curContext,this.lookAhead,e)}recoverByDelete(e,n){let a=e<=this.p.parser.maxNode;a&&this.storeNode(e,this.pos,n,4),this.storeNode(0,this.pos,n,a?8:4),this.pos=this.reducePos=n,this.score-=190}canShift(e){for(let n=new tmt(this);;){let a=this.p.parser.stateSlot(n.state,4)||this.p.parser.hasAction(n.state,e);if(a==0)return!1;if(!(a&65536))return!0;n.reduce(a)}}recoverByInsert(e){if(this.stack.length>=300)return[];let n=this.p.parser.nextStates(this.state);if(n.length>8||this.stack.length>=120){let r=[];for(let i=0,o;i<n.length;i+=2)(o=n[i+1])!=this.state&&this.p.parser.hasAction(o,e)&&r.push(n[i],o);if(this.stack.length<120)for(let i=0;r.length<8&&i<n.length;i+=2){let o=n[i+1];r.some((s,l)=>l&1&&s==o)||r.push(n[i],o)}n=r}let a=[];for(let r=0;r<n.length&&a.length<4;r+=2){let i=n[r+1];if(i==this.state)continue;let o=this.split();o.pushState(i,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(n[r],this.pos),o.reducePos=this.pos,o.score-=200,a.push(o)}return a}forceReduce(){let{parser:e}=this.p,n=e.stateSlot(this.state,5);if(!(n&65536))return!1;if(!e.validAction(this.state,n)){let a=n>>19,r=n&65535,i=this.stack.length-a*3;if(i<0||e.getGoto(this.stack[i],r,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;n=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(n),!0}findForcedReduction(){let{parser:e}=this.p,n=[],a=(r,i)=>{if(!n.includes(r))return n.push(r),e.allActions(r,o=>{if(!(o&393216))if(o&65536){let s=(o>>19)-i;if(s>1){let l=o&65535,u=this.stack.length-s*3;if(u>=0&&e.getGoto(this.stack[u],l,!1)>=0)return s<<19|65536|l}}else{let s=a(o,i+1);if(s!=null)return s}})};return a(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let n=0;n<this.stack.length;n+=3)if(this.stack[n]!=e.stack[n])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,n){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(n)))}reduceContext(e,n){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(n)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let n=new Gue(this.curContext.tracker,e);n.hash!=this.curContext.hash&&this.emitContext(),this.curContext=n}}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 Gue{constructor(e,n){this.tracker=e,this.context=n,this.hash=e.strict?e.hash(n):0}}class tmt{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let n=e&65535,a=e>>19;a==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(a-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],n,!0);this.state=r}}class R3{constructor(e,n,a){this.stack=e,this.pos=n,this.index=a,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,n=e.bufferBase+e.buffer.length){return new R3(e,n,n-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new R3(this.stack,this.pos,this.index)}}function $3(t,e=Uint16Array){if(typeof t!="string")return t;let n=null;for(let a=0,r=0;a<t.length;){let i=0;for(;;){let o=t.charCodeAt(a++),s=!1;if(o==126){i=65535;break}o>=92&&o--,o>=34&&o--;let l=o-32;if(l>=46&&(l-=46,s=!0),i+=l,s)break;i*=46}n?n[r++]=i:n=new e(i)}return n}class P3{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const que=new P3;class nmt{constructor(e,n){this.input=e,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=que,this.rangeIndex=0,this.pos=this.chunkPos=n[0].from,this.range=n[0],this.end=n[n.length-1].to,this.readNext()}resolveOffset(e,n){let a=this.range,r=this.rangeIndex,i=this.pos+e;for(;i<a.from;){if(!r)return null;let o=this.ranges[--r];i-=a.from-o.to,a=o}for(;n<0?i>a.to:i>=a.to;){if(r==this.ranges.length-1)return null;let o=this.ranges[++r];i+=o.from-a.to,a=o}return i}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let n of this.ranges)if(n.to>e)return Math.max(e,n.from);return this.end}peek(e){let n=this.chunkOff+e,a,r;if(n>=0&&n<this.chunk.length)a=this.pos+e,r=this.chunk.charCodeAt(n);else{let i=this.resolveOffset(e,1);if(i==null)return-1;if(a=i,a>=this.chunk2Pos&&a<this.chunk2Pos+this.chunk2.length)r=this.chunk2.charCodeAt(a-this.chunk2Pos);else{let o=this.rangeIndex,s=this.range;for(;s.to<=a;)s=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=a),a+this.chunk2.length>s.to&&(this.chunk2=this.chunk2.slice(0,s.to-a)),r=this.chunk2.charCodeAt(0)}}return a>=this.token.lookAhead&&(this.token.lookAhead=a+1),r}acceptToken(e,n=0){let a=n?this.resolveOffset(n,-1):this.pos;if(a==null||a<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=a}acceptTokenTo(e,n){this.token.value=e,this.token.end=n}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:n}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=n,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),n=this.pos+e.length;this.chunk=n>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,n){if(n?(this.token=n,n.start=e,n.lookAhead=e+1,n.value=n.extended=-1):this.token=que,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,n){if(e>=this.chunkPos&&n<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,n-this.chunkPos);if(e>=this.chunk2Pos&&n<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,n-this.chunk2Pos);if(e>=this.range.from&&n<=this.range.to)return this.input.read(e,n);let a="";for(let r of this.ranges){if(r.from>=n)break;r.to>e&&(a+=this.input.read(Math.max(r.from,e),Math.min(r.to,n)))}return a}}class Ib{constructor(e,n){this.data=e,this.id=n}token(e,n){let{parser:a}=n.p;amt(this.data,e,n,this.id,a.data,a.tokenPrecTable)}}Ib.prototype.contextual=Ib.prototype.fallback=Ib.prototype.extend=!1,Ib.prototype.fallback=Ib.prototype.extend=!1;function amt(t,e,n,a,r,i){let o=0,s=1<<a,{dialect:l}=n.p.parser;e:for(;s&t[o];){let u=t[o+1];for(let A=o+3;A<u;A+=2)if((t[A+1]&s)>0){let g=t[A];if(l.allows(g)&&(e.token.value==-1||e.token.value==g||rmt(g,e.token.value,r,i))){e.acceptToken(g);break}}let d=e.next,p=0,m=t[o+2];if(e.next<0&&m>p&&t[u+m*3-3]==65535){o=t[u+m*3-1];continue e}for(;p<m;){let A=p+m>>1,g=u+A+(A<<1),h=t[g],f=t[g+1]||65536;if(d<h)m=A;else if(d>=f)p=A+1;else{o=t[g+2],e.advance();continue e}}break}}function zue(t,e,n){for(let a=e,r;(r=t[a])!=65535;a++)if(r==n)return a-e;return-1}function rmt(t,e,n,a){let r=zue(n,a,e);return r<0||zue(n,a,t)<r}const zs=typeof process<"u"&&jue&&/\bparse\b/.test(jue.LOG);let EN=null;function Hue(t,e,n){let a=t.cursor(wi.IncludeAnonymous);for(a.moveTo(e);;)if(!(n<0?a.childBefore(e):a.childAfter(e)))for(;;){if((n<0?a.to<e:a.from>e)&&!a.type.isError)return n<0?Math.max(0,Math.min(a.to-1,e-25)):Math.min(t.length,Math.max(a.from+1,e+25));if(n<0?a.prevSibling():a.nextSibling())break;if(!a.parent())return n<0?0:t.length}}class imt{constructor(e,n){this.fragments=e,this.nodeSet=n,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?Hue(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?Hue(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let n=this.trees.length-1;if(n<0)return this.nextFragment(),null;let a=this.trees[n],r=this.index[n];if(r==a.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let i=a.children[r],o=this.start[n]+a.positions[r];if(o>e)return this.nextStart=o,null;if(i instanceof Nr){if(o==e){if(o<this.safeFrom)return null;let s=o+i.length;if(s<=this.safeTo){let l=i.prop(Rn.lookAhead);if(!l||s+l<this.fragment.to)return i}}this.index[n]++,o+i.length>=Math.max(this.safeFrom,e)&&(this.trees.push(i),this.start.push(o),this.index.push(0))}else this.index[n]++,this.nextStart=o+i.length}}}class omt{constructor(e,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(a=>new P3)}getActions(e){let n=0,a=null,{parser:r}=e.p,{tokenizers:i}=r,o=r.stateSlot(e.state,3),s=e.curContext?e.curContext.hash:0,l=0;for(let u=0;u<i.length;u++){if(!(1<<u&o))continue;let d=i[u],p=this.tokens[u];if(!(a&&!d.fallback)&&((d.contextual||p.start!=e.pos||p.mask!=o||p.context!=s)&&(this.updateCachedToken(p,d,e),p.mask=o,p.context=s),p.lookAhead>p.end+25&&(l=Math.max(p.lookAhead,l)),p.value!=0)){let m=n;if(p.extended>-1&&(n=this.addActions(e,p.extended,p.end,n)),n=this.addActions(e,p.value,p.end,n),!d.extend&&(a=p,n>m))break}}for(;this.actions.length>n;)this.actions.pop();return l&&e.setLookAhead(l),!a&&e.pos==this.stream.end&&(a=new P3,a.value=e.p.parser.eofTerm,a.start=a.end=e.pos,n=this.addActions(e,a.value,a.end,n)),this.mainToken=a,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let n=new P3,{pos:a,p:r}=e;return n.start=a,n.end=Math.min(a+1,r.stream.end),n.value=a==r.stream.end?r.parser.eofTerm:0,n}updateCachedToken(e,n,a){let r=this.stream.clipPos(a.pos);if(n.token(this.stream.reset(r,e),a),e.value>-1){let{parser:i}=a.p;for(let o=0;o<i.specialized.length;o++)if(i.specialized[o]==e.value){let s=i.specializers[o](this.stream.read(e.start,e.end),a);if(s>=0&&a.p.parser.dialect.allows(s>>1)){s&1?e.extended=s>>1:e.value=s>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,n,a,r){for(let i=0;i<r;i+=3)if(this.actions[i]==e)return r;return this.actions[r++]=e,this.actions[r++]=n,this.actions[r++]=a,r}addActions(e,n,a,r){let{state:i}=e,{parser:o}=e.p,{data:s}=o;for(let l=0;l<2;l++)for(let u=o.stateSlot(i,l?2:1);;u+=3){if(s[u]==65535)if(s[u+1]==1)u=Sd(s,u+2);else{r==0&&s[u+1]==2&&(r=this.putAction(Sd(s,u+2),n,a,r));break}s[u]==n&&(r=this.putAction(Sd(s,u+1),n,a,r))}return r}}class smt{constructor(e,n,a,r){this.parser=e,this.input=n,this.ranges=r,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new nmt(n,r),this.tokens=new omt(e,this.stream),this.topTerm=e.top[1];let{from:i}=r[0];this.stacks=[emt.start(this,e.top[0],i)],this.fragments=a.length&&this.stream.end-i>e.bufferLength*4?new imt(a,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,n=this.minStackPos,a=this.stacks=[],r,i;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<e.length;o++){let s=e[o];for(;;){if(this.tokens.mainToken=null,s.pos>n)a.push(s);else{if(this.advanceStack(s,a,e))continue;{r||(r=[],i=[]),r.push(s);let l=this.tokens.getMainToken(s);i.push(l.value,l.end)}}break}}if(!a.length){let o=r&&lmt(r);if(o)return zs&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw zs&&r&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+n);this.recovering||(this.recovering=5)}if(this.recovering&&r){let o=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,i,a);if(o)return zs&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(a.length>o)for(a.sort((s,l)=>l.score-s.score);a.length>o;)a.pop();a.some(s=>s.reducePos>n)&&this.recovering--}else if(a.length>1){e:for(let o=0;o<a.length-1;o++){let s=a[o];for(let l=o+1;l<a.length;l++){let u=a[l];if(s.sameState(u)||s.buffer.length>500&&u.buffer.length>500)if((s.score-u.score||s.buffer.length-u.buffer.length)>0)a.splice(l--,1);else{a.splice(o--,1);continue e}}}a.length>12&&a.splice(12,a.length-12)}this.minStackPos=a[0].pos;for(let o=1;o<a.length;o++)a[o].pos<this.minStackPos&&(this.minStackPos=a[o].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,n,a){let r=e.pos,{parser:i}=this,o=zs?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let u=e.curContext&&e.curContext.tracker.strict,d=u?e.curContext.hash:0;for(let p=this.fragments.nodeAt(r);p;){let m=this.parser.nodeSet.types[p.type.id]==p.type?i.getGoto(e.state,p.type.id):-1;if(m>-1&&p.length&&(!u||(p.prop(Rn.contextHash)||0)==d))return e.useNode(p,m),zs&&console.log(o+this.stackID(e)+` (via reuse of ${i.getName(p.type.id)})`),!0;if(!(p instanceof Nr)||p.children.length==0||p.positions[0]>0)break;let A=p.children[0];if(A instanceof Nr&&p.positions[0]==0)p=A;else break}}let s=i.stateSlot(e.state,4);if(s>0)return e.reduce(s),zs&&console.log(o+this.stackID(e)+` (via always-reduce ${i.getName(s&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let l=this.tokens.getActions(e);for(let u=0;u<l.length;){let d=l[u++],p=l[u++],m=l[u++],A=u==l.length||!a,g=A?e:e.split(),h=this.tokens.mainToken;if(g.apply(d,p,h?h.start:g.pos,m),zs&&console.log(o+this.stackID(g)+` (via ${d&65536?`reduce of ${i.getName(d&65535)}`:"shift"} for ${i.getName(p)} @ ${r}${g==e?"":", split"})`),A)return!0;g.pos>r?n.push(g):a.push(g)}return!1}advanceFully(e,n){let a=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>a)return Uue(e,n),!0}}runRecovery(e,n,a){let r=null,i=!1;for(let o=0;o<e.length;o++){let s=e[o],l=n[o<<1],u=n[(o<<1)+1],d=zs?this.stackID(s)+" -> ":"";if(s.deadEnd&&(i||(i=!0,s.restart(),zs&&console.log(d+this.stackID(s)+" (restarted)"),this.advanceFully(s,a))))continue;let p=s.split(),m=d;for(let A=0;A<10&&p.forceReduce()&&(zs&&console.log(m+this.stackID(p)+" (via force-reduce)"),!this.advanceFully(p,a));A++)zs&&(m=this.stackID(p)+" -> ");for(let A of s.recoverByInsert(l))zs&&console.log(d+this.stackID(A)+" (via recover-insert)"),this.advanceFully(A,a);this.stream.end>s.pos?(u==s.pos&&(u++,l=0),s.recoverByDelete(l,u),zs&&console.log(d+this.stackID(s)+` (via recover-delete ${this.parser.getName(l)})`),Uue(s,a)):(!r||r.score<s.score)&&(r=s)}return r}stackToTree(e){return e.close(),Nr.build({buffer:R3.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let n=(EN||(EN=new WeakMap)).get(e);return n||EN.set(e,n=String.fromCodePoint(this.nextStackID++)),n+e}}function Uue(t,e){for(let n=0;n<e.length;n++){let a=e[n];if(a.pos==t.pos&&a.sameState(t)){e[n].score<t.score&&(e[n]=t);return}}e.push(t)}class cmt{constructor(e,n,a){this.source=e,this.flags=n,this.disabled=a}allows(e){return!this.disabled||this.disabled[e]==0}}class O3 extends Qce{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let n=e.nodeNames.split(" ");this.minRepeatTerm=n.length;for(let s=0;s<e.repeatNodeCount;s++)n.push("");let a=Object.keys(e.topRules).map(s=>e.topRules[s][1]),r=[];for(let s=0;s<n.length;s++)r.push([]);function i(s,l,u){r[s].push([l,l.deserialize(String(u))])}if(e.nodeProps)for(let s of e.nodeProps){let l=s[0];typeof l=="string"&&(l=Rn[l]);for(let u=1;u<s.length;){let d=s[u++];if(d>=0)i(d,l,s[u++]);else{let p=s[u+-d];for(let m=-d;m>0;m--)i(s[u++],l,p);u++}}}this.nodeSet=new ML(n.map((s,l)=>gs.define({name:l>=this.minRepeatTerm?void 0:s,id:l,props:r[l],top:a.indexOf(l)>-1,error:l==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(l)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=Cce;let o=$3(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let s=0;s<this.specializerSpecs.length;s++)this.specialized[s]=this.specializerSpecs[s].term;this.specializers=this.specializerSpecs.map(Yue),this.states=$3(e.states,Uint32Array),this.data=$3(e.stateData),this.goto=$3(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(s=>typeof s=="number"?new Ib(o,s):s),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,n,a){let r=new smt(this,e,n,a);for(let i of this.wrappers)r=i(r,e,n,a);return r}getGoto(e,n,a=!1){let r=this.goto;if(n>=r[0])return-1;for(let i=r[n+1];;){let o=r[i++],s=o&1,l=r[i++];if(s&&a)return l;for(let u=i+(o>>1);i<u;i++)if(r[i]==e)return l;if(s)return-1}}hasAction(e,n){let a=this.data;for(let r=0;r<2;r++)for(let i=this.stateSlot(e,r?2:1),o;;i+=3){if((o=a[i])==65535)if(a[i+1]==1)o=a[i=Sd(a,i+2)];else{if(a[i+1]==2)return Sd(a,i+2);break}if(o==n||o==0)return Sd(a,i+1)}return 0}stateSlot(e,n){return this.states[e*6+n]}stateFlag(e,n){return(this.stateSlot(e,0)&n)>0}validAction(e,n){return!!this.allActions(e,a=>a==n?!0:null)}allActions(e,n){let a=this.stateSlot(e,4),r=a?n(a):void 0;for(let i=this.stateSlot(e,1);r==null;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=Sd(this.data,i+2);else break;r=n(Sd(this.data,i+1))}return r}nextStates(e){let n=[];for(let a=this.stateSlot(e,1);;a+=3){if(this.data[a]==65535)if(this.data[a+1]==1)a=Sd(this.data,a+2);else break;if(!(this.data[a+2]&1)){let r=this.data[a+1];n.some((i,o)=>o&1&&i==r)||n.push(this.data[a],r)}}return n}configure(e){let n=Object.assign(Object.create(O3.prototype),this);if(e.props&&(n.nodeSet=this.nodeSet.extend(...e.props)),e.top){let a=this.topRules[e.top];if(!a)throw new RangeError(`Invalid top rule name ${e.top}`);n.top=a}return e.tokenizers&&(n.tokenizers=this.tokenizers.map(a=>{let r=e.tokenizers.find(i=>i.from==a);return r?r.to:a})),e.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((a,r)=>{let i=e.specializers.find(s=>s.from==a.external);if(!i)return a;let o=Object.assign(Object.assign({},a),{external:i.to});return n.specializers[r]=Yue(o),o})),e.contextTracker&&(n.context=e.contextTracker),e.dialect&&(n.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(n.strict=e.strict),e.wrap&&(n.wrappers=n.wrappers.concat(e.wrap)),e.bufferLength!=null&&(n.bufferLength=e.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let n=this.dynamicPrecedences;return n==null?0:n[e]||0}parseDialect(e){let n=Object.keys(this.dialects),a=n.map(()=>!1);if(e)for(let i of e.split(" ")){let o=n.indexOf(i);o>=0&&(a[o]=!0)}let r=null;for(let i=0;i<n.length;i++)if(!a[i])for(let o=this.dialects[n[i]],s;(s=this.data[o++])!=65535;)(r||(r=new Uint8Array(this.maxTerm+1)))[s]=1;return new cmt(e,a,r)}static deserialize(e){return new O3(e)}}function Sd(t,e){return t[e]|t[e+1]<<16}function lmt(t){let e=null;for(let n of t){let a=n.p.stoppedAt;(n.pos==n.p.stream.end||a!=null&&n.pos>a)&&n.p.parser.stateFlag(n.state,2)&&(!e||e.score<n.score)&&(e=n)}return e}function Yue(t){if(t.external){let e=t.extend?1:0;return(n,a)=>t.external(n,a)<<1|e}return t.get}const umt=Sce({String:Xe.string,Number:Xe.number,"True False":Xe.bool,PropertyName:Xe.propertyName,Null:Xe.null,", :":Xe.separator,"[ ]":Xe.squareBracket,"{ }":Xe.brace}),dmt=O3.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[umt],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),pmt=u3.define({name:"json",parser:dmt.configure({props:[Pce.add({Object:jce({except:/^\s*\}/}),Array:jce({except:/^\s*\]/})}),Gce.add({"Object Array":vlt})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function mmt(){return new ult(pmt)}const Amt={codeWithAnnotations:`{
1353
1353
  "id": 1,
1354
1354
  "name": "test", // [!code --]
1355
1355
  "description": "Updated description", // [!code ++]