@agent-spaces/server 0.1.2 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/claude-code-runtime/index.js +4 -1
- package/dist/adapters/git.js +2 -21
- package/dist/agents/issue-agent-runner.js +35 -21
- package/dist/agents/issue-task-controller.js +120 -73
- package/dist/agents/planner-agent.js +9 -12
- package/dist/app.js +10 -0
- package/dist/hooks/agent-hooks.js +5 -8
- package/dist/package.json +1 -1
- package/dist/routes/agent.js +40 -17
- package/dist/routes/channel.js +4 -1
- package/dist/routes/command.js +108 -0
- package/dist/routes/folder.js +44 -7
- package/dist/routes/issue.js +57 -23
- package/dist/routes/mcp.js +50 -0
- package/dist/routes/skill.js +57 -0
- package/dist/routes/subscription.js +49 -0
- package/dist/routes/task.js +16 -1
- package/dist/routes/workflow.js +63 -0
- package/dist/routes/workspace.js +2 -21
- package/dist/services/agent.js +140 -76
- package/dist/services/builtin-tools.js +72 -0
- package/dist/services/channel.js +5 -5
- package/dist/services/command-process-manager.js +136 -0
- package/dist/services/command.js +48 -0
- package/dist/services/issue.js +5 -6
- package/dist/services/mcp.js +120 -0
- package/dist/services/notification-hub/bot-commands.js +48 -16
- package/dist/services/notification-hub/helpers.js +12 -0
- package/dist/services/pty.js +10 -3
- package/dist/services/skill.js +171 -0
- package/dist/services/subscription/aicode.js +45 -0
- package/dist/services/subscription/base.js +3 -0
- package/dist/services/subscription/index.js +20 -0
- package/dist/services/subscription/minimax.js +60 -0
- package/dist/services/subscription/zhipu.js +39 -0
- package/dist/services/workflow.js +203 -0
- package/dist/services/workspace.js +0 -1
- package/dist/storage/command-store.js +17 -0
- package/dist/storage/subscription-store.js +44 -0
- package/dist/storage/workflow-store.js +40 -0
- package/dist/web/404.html +1 -1
- package/dist/web/__next.__PAGE__.txt +4 -4
- package/dist/web/__next._full.txt +22 -21
- package/dist/web/__next._head.txt +4 -4
- package/dist/web/__next._index.txt +9 -8
- package/dist/web/__next._tree.txt +2 -2
- package/dist/web/_next/static/MpJepsgfsHGGcc7rwFU8Y/_buildManifest.js +11 -0
- package/dist/web/_next/static/chunks/0-245kun-watp.js +2 -0
- package/dist/web/_next/static/chunks/0-ca_fo-yp3~z.js +1 -0
- package/dist/web/_next/static/chunks/0-vgd3j-zh3m8.js +2 -0
- package/dist/web/_next/static/chunks/0.4.g.8yf4rs0.js +3 -0
- package/dist/web/_next/static/chunks/02m_-ngl9w8co.js +1 -0
- package/dist/web/_next/static/chunks/03jbh7ud0jw~g.js +1 -0
- package/dist/web/_next/static/chunks/07kqxmubf5dua.js +1 -0
- package/dist/web/_next/static/chunks/088q-5_51dsrw.js +1 -0
- package/dist/web/_next/static/chunks/09_ki3dc5cfwv.css +1 -0
- package/dist/web/_next/static/chunks/09jryrjps0vl2.js +1 -0
- package/dist/web/_next/static/chunks/0b2tump5duj9j.js +1 -0
- package/dist/web/_next/static/chunks/0dctkv_2d2r0g.js +8 -0
- package/dist/web/_next/static/chunks/0efgv37kxyht8.js +1 -0
- package/dist/web/_next/static/chunks/0fwvdy-ml8wpk.js +1 -0
- package/dist/web/_next/static/chunks/0g4vm6.v0o_lt.js +1 -0
- package/dist/web/_next/static/chunks/0g_b4t~000.o~.js +179 -0
- package/dist/web/_next/static/chunks/0gyede80jpy3n.js +4 -0
- package/dist/web/_next/static/chunks/0h256h-tu4e0r.js +2 -0
- package/dist/web/_next/static/chunks/0ib18ul605e~a.js +1 -0
- package/dist/web/_next/static/chunks/0j1g_rd9t5ot1.js +1 -0
- package/dist/web/_next/static/chunks/0jn~llaqcxo4q.js +1 -0
- package/dist/web/_next/static/chunks/0jvmviuftg5e2.css +1 -0
- package/dist/web/_next/static/chunks/0lb8l2~6s_owo.js +1 -0
- package/dist/web/_next/static/chunks/0ni5ot2603_28.js +1 -0
- package/dist/web/_next/static/chunks/0pep4mkvt3.rh.js +31 -0
- package/dist/web/_next/static/chunks/0pq2670_ezbcj.js +1 -0
- package/dist/web/_next/static/chunks/0q_scqkk9.t53.js +2 -0
- package/dist/web/_next/static/chunks/0rrdur.v1a5r7.js +1 -0
- package/dist/web/_next/static/chunks/0spo.tmfeas-o.js +1 -0
- package/dist/web/_next/static/chunks/0tta_56qj1z8-.js +1 -0
- package/dist/web/_next/static/chunks/0u88ij9dqqh~-.js +1 -0
- package/dist/web/_next/static/chunks/0zl19l5tuoppw.js +1 -0
- package/dist/web/_next/static/chunks/11n16hogah-5..js +1 -0
- package/dist/web/_next/static/chunks/1250wo~-5dgyx.js +1 -0
- package/dist/web/_next/static/chunks/14n8i2xz4_y-e.js +1 -0
- package/dist/web/_next/static/chunks/160ji-.dfvm20.js +1 -0
- package/dist/web/_next/static/chunks/turbopack-0lxiiw.jhevml.js +1 -0
- package/dist/web/_next/static/media/favicon.0~ekuj.zhggpa.ico +0 -0
- package/dist/web/_not-found/__next._full.txt +24 -19
- package/dist/web/_not-found/__next._head.txt +4 -4
- package/dist/web/_not-found/__next._index.txt +9 -8
- package/dist/web/_not-found/__next._not-found.__PAGE__.txt +2 -2
- package/dist/web/_not-found/__next._not-found.txt +3 -3
- package/dist/web/_not-found/__next._tree.txt +2 -2
- package/dist/web/_not-found.html +1 -1
- package/dist/web/_not-found.txt +24 -19
- package/dist/web/apple-touch-icon.png +0 -0
- package/dist/web/favicon.ico +0 -0
- package/dist/web/icon-192.png +0 -0
- package/dist/web/icon-512.png +0 -0
- package/dist/web/index.html +1 -1
- package/dist/web/index.txt +22 -21
- package/dist/web/login/__next._full.txt +24 -23
- package/dist/web/login/__next._head.txt +4 -4
- package/dist/web/login/__next._index.txt +9 -8
- package/dist/web/login/__next._tree.txt +2 -2
- package/dist/web/login/__next.login.__PAGE__.txt +4 -4
- package/dist/web/login/__next.login.txt +3 -3
- package/dist/web/login.html +1 -1
- package/dist/web/login.txt +24 -23
- package/dist/web/settings/__next._full.txt +34 -0
- package/dist/web/settings/__next._head.txt +6 -0
- package/dist/web/settings/__next._index.txt +11 -0
- package/dist/web/settings/__next._tree.txt +8 -0
- package/dist/web/settings/__next.settings.__PAGE__.txt +9 -0
- package/dist/web/settings/__next.settings.txt +7 -0
- package/dist/web/settings/agents/__next._full.txt +38 -0
- package/dist/web/settings/agents/__next._head.txt +6 -0
- package/dist/web/settings/agents/__next._index.txt +11 -0
- package/dist/web/settings/agents/__next._tree.txt +8 -0
- package/dist/web/settings/agents/__next.settings.agents.__PAGE__.txt +9 -0
- package/dist/web/settings/agents/__next.settings.agents.txt +5 -0
- package/dist/web/settings/agents/__next.settings.txt +7 -0
- package/dist/web/settings/agents.html +1 -0
- package/dist/web/settings/agents.txt +38 -0
- package/dist/web/settings/mcps/__next._full.txt +38 -0
- package/dist/web/settings/mcps/__next._head.txt +6 -0
- package/dist/web/settings/mcps/__next._index.txt +11 -0
- package/dist/web/settings/mcps/__next._tree.txt +8 -0
- package/dist/web/settings/mcps/__next.settings.mcps.__PAGE__.txt +9 -0
- package/dist/web/settings/mcps/__next.settings.mcps.txt +5 -0
- package/dist/web/settings/mcps/__next.settings.txt +7 -0
- package/dist/web/settings/mcps.html +1 -0
- package/dist/web/settings/mcps.txt +38 -0
- package/dist/web/settings/models/__next._full.txt +38 -0
- package/dist/web/settings/models/__next._head.txt +6 -0
- package/dist/web/settings/models/__next._index.txt +11 -0
- package/dist/web/settings/models/__next._tree.txt +8 -0
- package/dist/web/settings/models/__next.settings.models.__PAGE__.txt +9 -0
- package/dist/web/settings/models/__next.settings.models.txt +5 -0
- package/dist/web/settings/models/__next.settings.txt +7 -0
- package/dist/web/settings/models.html +1 -0
- package/dist/web/settings/models.txt +38 -0
- package/dist/web/settings/providers/__next._full.txt +38 -0
- package/dist/web/settings/providers/__next._head.txt +6 -0
- package/dist/web/settings/providers/__next._index.txt +11 -0
- package/dist/web/settings/providers/__next._tree.txt +8 -0
- package/dist/web/settings/providers/__next.settings.providers.__PAGE__.txt +9 -0
- package/dist/web/settings/providers/__next.settings.providers.txt +5 -0
- package/dist/web/settings/providers/__next.settings.txt +7 -0
- package/dist/web/settings/providers.html +1 -0
- package/dist/web/settings/providers.txt +38 -0
- package/dist/web/settings/skills/__next._full.txt +38 -0
- package/dist/web/settings/skills/__next._head.txt +6 -0
- package/dist/web/settings/skills/__next._index.txt +11 -0
- package/dist/web/settings/skills/__next._tree.txt +8 -0
- package/dist/web/settings/skills/__next.settings.skills.__PAGE__.txt +9 -0
- package/dist/web/settings/skills/__next.settings.skills.txt +5 -0
- package/dist/web/settings/skills/__next.settings.txt +7 -0
- package/dist/web/settings/skills.html +1 -0
- package/dist/web/settings/skills.txt +38 -0
- package/dist/web/settings.html +1 -0
- package/dist/web/settings.txt +34 -0
- package/dist/web/workflows/__next._full.txt +35 -0
- package/dist/web/workflows/__next._head.txt +6 -0
- package/dist/web/workflows/__next._index.txt +11 -0
- package/dist/web/workflows/__next._tree.txt +9 -0
- package/dist/web/workflows/__next.workflows.__PAGE__.txt +10 -0
- package/dist/web/workflows/__next.workflows.txt +5 -0
- package/dist/web/workflows.html +1 -0
- package/dist/web/workflows.txt +35 -0
- package/dist/web/workspace/_/__next._full.txt +25 -20
- package/dist/web/workspace/_/__next._head.txt +4 -4
- package/dist/web/workspace/_/__next._index.txt +9 -8
- package/dist/web/workspace/_/__next._tree.txt +2 -2
- package/dist/web/workspace/_/__next.workspace.$d$id.__PAGE__.txt +3 -3
- package/dist/web/workspace/_/__next.workspace.$d$id.txt +3 -3
- package/dist/web/workspace/_/__next.workspace.txt +3 -3
- package/dist/web/workspace/_.html +1 -1
- package/dist/web/workspace/_.txt +25 -20
- package/dist/web/workspaces/__next._full.txt +24 -23
- package/dist/web/workspaces/__next._head.txt +4 -4
- package/dist/web/workspaces/__next._index.txt +9 -8
- package/dist/web/workspaces/__next._tree.txt +2 -2
- package/dist/web/workspaces/__next.workspaces.__PAGE__.txt +4 -4
- package/dist/web/workspaces/__next.workspaces.txt +3 -3
- package/dist/web/workspaces.html +1 -1
- package/dist/web/workspaces.txt +24 -23
- package/dist/ws/agent-prompt.js +84 -0
- package/dist/ws/agent-runner.js +592 -0
- package/dist/ws/handler.js +9 -1200
- package/dist/ws/html-utils.js +30 -0
- package/dist/ws/message-parts.js +498 -0
- package/package.json +3 -2
- package/dist/web/_next/static/chunks/038whpa0zpnas.js +0 -1
- package/dist/web/_next/static/chunks/06q5go~xoz5a3.js +0 -1
- package/dist/web/_next/static/chunks/095.wizobwtyg.js +0 -2
- package/dist/web/_next/static/chunks/0bfg.w~u-83h5.js +0 -1
- package/dist/web/_next/static/chunks/0ce7i6~sb20rv.js +0 -113
- package/dist/web/_next/static/chunks/0d4~pcva1uk-a.js +0 -1
- package/dist/web/_next/static/chunks/0iq70n_u75nyu.js +0 -1
- package/dist/web/_next/static/chunks/0memz-8zsbxpu.js +0 -1
- package/dist/web/_next/static/chunks/0nw~w.3~twebx.js +0 -2
- package/dist/web/_next/static/chunks/0pyytgz~5vt0f.js +0 -31
- package/dist/web/_next/static/chunks/0ujjcrz~1nq.q.css +0 -1
- package/dist/web/_next/static/chunks/0vdnx9n41dyjl.js +0 -1
- package/dist/web/_next/static/chunks/0yl4mqmxtll6g.js +0 -1
- package/dist/web/_next/static/chunks/0zcbfka5tcle3.js +0 -1
- package/dist/web/_next/static/chunks/0~eo58u99i.fr.js +0 -8
- package/dist/web/_next/static/chunks/13_2vxyccsv84.js +0 -4
- package/dist/web/_next/static/chunks/13wfs~urgxu0w.js +0 -1
- package/dist/web/_next/static/chunks/157~3c6wqkt83.js +0 -1
- package/dist/web/_next/static/chunks/15jvow_z4uq-..js +0 -1
- package/dist/web/_next/static/chunks/15v697nf~r-cy.js +0 -2
- package/dist/web/_next/static/chunks/turbopack-164~7ulq9o9yc.js +0 -1
- package/dist/web/_next/static/media/favicon.0x3dzn~oxb6tn.ico +0 -0
- package/dist/web/_next/static/owMnKmxATbtXK_J_k_uHh/_buildManifest.js +0 -21
- /package/dist/web/_next/static/{owMnKmxATbtXK_J_k_uHh → MpJepsgfsHGGcc7rwFU8Y}/_clientMiddlewareManifest.js +0 -0
- /package/dist/web/_next/static/{owMnKmxATbtXK_J_k_uHh → MpJepsgfsHGGcc7rwFU8Y}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,843982,(e,i,n)=>{"use strict";function r({widthInt:e,heightInt:i,blurWidth:n,blurHeight:s,blurDataURL:o,objectFit:a}){let l=n?40*n:e,c=s?40*s:i,h=l&&c?`viewBox='0 0 ${l} ${c}'`:"";return`%3Csvg xmlns='http://www.w3.org/2000/svg' ${h}%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3CfeColorMatrix values='1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 100 -1' result='s'/%3E%3CfeFlood x='0' y='0' width='100%25' height='100%25'/%3E%3CfeComposite operator='out' in='s'/%3E%3CfeComposite in2='SourceGraphic'/%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3Cimage width='100%25' height='100%25' x='0' y='0' preserveAspectRatio='${h?"none":"contain"===a?"xMidYMid":"cover"===a?"xMidYMid slice":"none"}' style='filter: url(%23b);' href='${o}'/%3E%3C/svg%3E`}Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"getImageBlurSvg",{enumerable:!0,get:function(){return r}})},500680,(e,i,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r={VALID_LOADERS:function(){return o},imageConfigDefault:function(){return a}};for(var s in r)Object.defineProperty(n,s,{enumerable:!0,get:r[s]});let o=["default","imgix","cloudinary","akamai","custom"],a={deviceSizes:[640,750,828,1080,1200,1920,2048,3840],imageSizes:[32,48,64,96,128,256,384],path:"/_next/image",loader:"default",loaderFile:"",domains:[],disableStaticImages:!1,minimumCacheTTL:14400,formats:["image/webp"],maximumDiskCacheSize:void 0,maximumRedirects:3,maximumResponseBody:5e7,dangerouslyAllowLocalIP:!1,dangerouslyAllowSVG:!1,contentSecurityPolicy:"script-src 'none'; frame-src 'none'; sandbox;",contentDispositionType:"attachment",localPatterns:void 0,remotePatterns:[],qualities:[75],unoptimized:!1,customCacheHandler:!1}},622398,(e,i,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"getImgProps",{enumerable:!0,get:function(){return h}}),e.r(837121);let r=e.r(745137),s=e.r(843982),o=e.r(500680),a=["-moz-initial","fill","none","scale-down",void 0];function l(e){return void 0!==e.default}function c(e){return void 0===e?e:"number"==typeof e?Number.isFinite(e)?e:NaN:"string"==typeof e&&/^[0-9]+$/.test(e)?parseInt(e,10):NaN}function h({src:e,sizes:i,unoptimized:n=!1,priority:d=!1,preload:u=!1,loading:p,className:f,quality:m,width:g,height:v,fill:y=!1,style:_,overrideSrc:b,onLoad:w,onLoadingComplete:S,placeholder:k="empty",blurDataURL:C,fetchPriority:T,decoding:E="async",layout:N,objectFit:M,objectPosition:O,lazyBoundary:A,lazyRoot:R,...D},L){var j;let I,P,B,{imgConf:z,showAltText:F,blurComplete:W,defaultLoader:H}=L,$=z||o.imageConfigDefault;if("allSizes"in $)I=$;else{let e=[...$.deviceSizes,...$.imageSizes].sort((e,i)=>e-i),i=$.deviceSizes.sort((e,i)=>e-i),n=$.qualities?.sort((e,i)=>e-i);I={...$,allSizes:e,deviceSizes:i,qualities:n}}if(void 0===H)throw Object.defineProperty(Error("images.loaderFile detected but the file is missing default export.\nRead more: https://nextjs.org/docs/messages/invalid-images-config"),"__NEXT_ERROR_CODE",{value:"E163",enumerable:!1,configurable:!0});let U=D.loader||H;delete D.loader,delete D.srcSet;let V="__next_img_default"in U;if(V){if("custom"===I.loader)throw Object.defineProperty(Error(`Image with src "${e}" is missing "loader" prop.
|
|
2
|
+
Read more: https://nextjs.org/docs/messages/next-image-missing-loader`),"__NEXT_ERROR_CODE",{value:"E252",enumerable:!1,configurable:!0})}else{let e=U;U=i=>{let{config:n,...r}=i;return e(r)}}if(N){"fill"===N&&(y=!0);let e={intrinsic:{maxWidth:"100%",height:"auto"},responsive:{width:"100%",height:"auto"}}[N];e&&(_={..._,...e});let n={responsive:"100vw",fill:"100vw"}[N];n&&!i&&(i=n)}let q="",Y=c(g),K=c(v);if((j=e)&&"object"==typeof j&&(l(j)||void 0!==j.src)){let i=l(e)?e.default:e;if(!i.src)throw Object.defineProperty(Error(`An object should only be passed to the image component src parameter if it comes from a static image import. It must include src. Received ${JSON.stringify(i)}`),"__NEXT_ERROR_CODE",{value:"E460",enumerable:!1,configurable:!0});if(!i.height||!i.width)throw Object.defineProperty(Error(`An object should only be passed to the image component src parameter if it comes from a static image import. It must include height and width. Received ${JSON.stringify(i)}`),"__NEXT_ERROR_CODE",{value:"E48",enumerable:!1,configurable:!0});if(P=i.blurWidth,B=i.blurHeight,C=C||i.blurDataURL,q=i.src,!y)if(Y||K){if(Y&&!K){let e=Y/i.width;K=Math.round(i.height*e)}else if(!Y&&K){let e=K/i.height;Y=Math.round(i.width*e)}}else Y=i.width,K=i.height}let X=!d&&!u&&("lazy"===p||void 0===p);(!(e="string"==typeof e?e:q)||e.startsWith("data:")||e.startsWith("blob:"))&&(n=!0,X=!1),I.unoptimized&&(n=!0),V&&!I.dangerouslyAllowSVG&&e.split("?",1)[0].endsWith(".svg")&&(n=!0);let J=c(m),G=Object.assign(y?{position:"absolute",height:"100%",width:"100%",left:0,top:0,right:0,bottom:0,objectFit:M,objectPosition:O}:{},F?{}:{color:"transparent"},_),Z=W||"empty"===k?null:"blur"===k?`url("data:image/svg+xml;charset=utf-8,${(0,s.getImageBlurSvg)({widthInt:Y,heightInt:K,blurWidth:P,blurHeight:B,blurDataURL:C||"",objectFit:G.objectFit})}")`:`url("${k}")`,Q=a.includes(G.objectFit)?"fill"===G.objectFit?"100% 100%":"cover":G.objectFit,ee=Z?{backgroundSize:Q,backgroundPosition:G.objectPosition||"50% 50%",backgroundRepeat:"no-repeat",backgroundImage:Z}:{},et=function({config:e,src:i,unoptimized:n,width:s,quality:o,sizes:a,loader:l}){if(n){if(i.startsWith("/")&&!i.startsWith("//")){let e=(0,r.getDeploymentId)();if(e){let n=i.indexOf("?");if(-1!==n){let r=new URLSearchParams(i.slice(n+1));r.get("dpl")||(r.append("dpl",e),i=i.slice(0,n)+"?"+r.toString())}else i+=`?dpl=${e}`}}return{src:i,srcSet:void 0,sizes:void 0}}let{widths:c,kind:h}=function({deviceSizes:e,allSizes:i},n,r){if(r){let n=/(^|\s)(1?\d?\d)vw/g,s=[];for(let e;e=n.exec(r);)s.push(parseInt(e[2]));if(s.length){let n=.01*Math.min(...s);return{widths:i.filter(i=>i>=e[0]*n),kind:"w"}}return{widths:i,kind:"w"}}return"number"!=typeof n?{widths:e,kind:"w"}:{widths:[...new Set([n,2*n].map(e=>i.find(i=>i>=e)||i[i.length-1]))],kind:"x"}}(e,s,a),d=c.length-1;return{sizes:a||"w"!==h?a:"100vw",srcSet:c.map((n,r)=>`${l({config:e,src:i,quality:o,width:n})} ${"w"===h?n:r+1}${h}`).join(", "),src:l({config:e,src:i,quality:o,width:c[d]})}}({config:I,src:e,unoptimized:n,width:Y,quality:J,sizes:i,loader:U}),ei=X?"lazy":p;return{props:{...D,loading:ei,fetchPriority:T,width:Y,height:K,decoding:E,className:f,style:{...G,...ee},sizes:et.sizes,srcSet:et.srcSet,src:b||et.src},meta:{unoptimized:n,preload:u||d,placeholder:k,fill:y}}}},852824,(e,i,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"default",{enumerable:!0,get:function(){return l}});let r=e.r(764556),s="u"<typeof window,o=s?()=>{}:r.useLayoutEffect,a=s?()=>{}:r.useEffect;function l(e){let{headManager:i,reduceComponentsToState:n}=e;function l(){if(i&&i.mountedInstances){let e=r.Children.toArray(Array.from(i.mountedInstances).filter(Boolean));i.updateHead(n(e))}}return s&&(i?.mountedInstances?.add(e.children),l()),o(()=>(i?.mountedInstances?.add(e.children),()=>{i?.mountedInstances?.delete(e.children)})),o(()=>(i&&(i._pendingUpdate=l),()=>{i&&(i._pendingUpdate=l)})),a(()=>(i&&i._pendingUpdate&&(i._pendingUpdate(),i._pendingUpdate=null),()=>{i&&i._pendingUpdate&&(i._pendingUpdate(),i._pendingUpdate=null)})),null}},120333,(e,i,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r={default:function(){return g},defaultHead:function(){return u}};for(var s in r)Object.defineProperty(n,s,{enumerable:!0,get:r[s]});let o=e.r(481258),a=e.r(744066),l=e.r(344180),c=a._(e.r(764556)),h=o._(e.r(852824)),d=e.r(57426);function u(){return[(0,l.jsx)("meta",{charSet:"utf-8"},"charset"),(0,l.jsx)("meta",{name:"viewport",content:"width=device-width"},"viewport")]}function p(e,i){return"string"==typeof i||"number"==typeof i?e:i.type===c.default.Fragment?e.concat(c.default.Children.toArray(i.props.children).reduce((e,i)=>"string"==typeof i||"number"==typeof i?e:e.concat(i),[])):e.concat(i)}e.r(837121);let f=["name","httpEquiv","charSet","itemProp"];function m(e){let i,n,r,s;return e.reduce(p,[]).reverse().concat(u().reverse()).filter((i=new Set,n=new Set,r=new Set,s={},e=>{let o=!0,a=!1;if(e.key&&"number"!=typeof e.key&&e.key.indexOf("$")>0){a=!0;let n=e.key.slice(e.key.indexOf("$")+1);i.has(n)?o=!1:i.add(n)}switch(e.type){case"title":case"base":n.has(e.type)?o=!1:n.add(e.type);break;case"meta":for(let i=0,n=f.length;i<n;i++){let n=f[i];if(e.props.hasOwnProperty(n))if("charSet"===n)r.has(n)?o=!1:r.add(n);else{let i=e.props[n],r=s[n]||new Set;("name"!==n||!a)&&r.has(i)?o=!1:(r.add(i),s[n]=r)}}}return o})).reverse().map((e,i)=>{let n=e.key||i;return c.default.cloneElement(e,{key:n})})}let g=function({children:e}){let i=(0,c.useContext)(d.HeadManagerContext);return(0,l.jsx)(h.default,{reduceComponentsToState:m,headManager:i,children:e})};("function"==typeof n.default||"object"==typeof n.default&&null!==n.default)&&void 0===n.default.__esModule&&(Object.defineProperty(n.default,"__esModule",{value:!0}),Object.assign(n.default,n),i.exports=n.default)},914272,(e,i,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"ImageConfigContext",{enumerable:!0,get:function(){return o}});let r=e.r(481258)._(e.r(764556)),s=e.r(500680),o=r.default.createContext(s.imageConfigDefault)},338431,(e,i,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"RouterContext",{enumerable:!0,get:function(){return r}});let r=e.r(481258)._(e.r(764556)).default.createContext(null)},741186,(e,i,n)=>{"use strict";function r(e,i){let n=e||75;return i?.qualities?.length?i.qualities.reduce((e,i)=>Math.abs(i-n)<Math.abs(e-n)?i:e,i.qualities[0]):n}Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"findClosestQuality",{enumerable:!0,get:function(){return r}})},99552,(e,i,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"default",{enumerable:!0,get:function(){return a}});let r=e.r(741186),s=e.r(745137);function o({config:e,src:i,width:n,quality:a}){let l=(0,s.getDeploymentId)();if(i.startsWith("/")&&!i.startsWith("//")){let e=i.indexOf("?");if(-1!==e){let n=new URLSearchParams(i.slice(e+1)),r=n.get("dpl");if(r){l=r,n.delete("dpl");let s=n.toString();i=i.slice(0,e)+(s?"?"+s:"")}}}if(i.startsWith("/")&&i.includes("?")&&e.localPatterns?.length===1&&"**"===e.localPatterns[0].pathname&&""===e.localPatterns[0].search)throw Object.defineProperty(Error(`Image with src "${i}" is using a query string which is not configured in images.localPatterns.
|
|
3
|
+
Read more: https://nextjs.org/docs/messages/next-image-unconfigured-localpatterns`),"__NEXT_ERROR_CODE",{value:"E871",enumerable:!1,configurable:!0});let c=(0,r.findClosestQuality)(a,e);return`${e.path}?url=${encodeURIComponent(i)}&w=${n}&q=${c}${i.startsWith("/")&&l?`&dpl=${l}`:""}`}o.__next_img_default=!0;let a=o},822862,(e,i,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"useMergedRef",{enumerable:!0,get:function(){return s}});let r=e.r(764556);function s(e,i){let n=(0,r.useRef)(null),s=(0,r.useRef)(null);return(0,r.useCallback)(r=>{if(null===r){let e=n.current;e&&(n.current=null,e());let i=s.current;i&&(s.current=null,i())}else e&&(n.current=o(e,r)),i&&(s.current=o(i,r))},[e,i])}function o(e,i){if("function"!=typeof e)return e.current=i,()=>{e.current=null};{let n=e(i);return"function"==typeof n?n:()=>e(null)}}("function"==typeof n.default||"object"==typeof n.default&&null!==n.default)&&void 0===n.default.__esModule&&(Object.defineProperty(n.default,"__esModule",{value:!0}),Object.assign(n.default,n),i.exports=n.default)},810034,(e,i,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"Image",{enumerable:!0,get:function(){return w}});let r=e.r(481258),s=e.r(744066),o=e.r(344180),a=s._(e.r(764556)),l=r._(e.r(106206)),c=r._(e.r(120333)),h=e.r(622398),d=e.r(500680),u=e.r(914272);e.r(837121);let p=e.r(338431),f=r._(e.r(99552)),m=e.r(822862),g={deviceSizes:[640,750,828,1080,1200,1920,2048,3840],imageSizes:[32,48,64,96,128,256,384],qualities:[75],path:"/_next/image",loader:"default",dangerouslyAllowSVG:!1,unoptimized:!1};function v(e,i,n,r,s,o,a){let l=e?.src;e&&e["data-loaded-src"]!==l&&(e["data-loaded-src"]=l,("decode"in e?e.decode():Promise.resolve()).catch(()=>{}).then(()=>{if(e.parentElement&&e.isConnected){if("empty"!==i&&s(!0),n?.current){let i=new Event("load");Object.defineProperty(i,"target",{writable:!1,value:e});let r=!1,s=!1;n.current({...i,nativeEvent:i,currentTarget:e,target:e,isDefaultPrevented:()=>r,isPropagationStopped:()=>s,persist:()=>{},preventDefault:()=>{r=!0,i.preventDefault()},stopPropagation:()=>{s=!0,i.stopPropagation()}})}r?.current&&r.current(e)}}))}function y(e){return a.use?{fetchPriority:e}:{fetchpriority:e}}"u"<typeof window&&(globalThis.__NEXT_IMAGE_IMPORTED=!0);let _=(0,a.forwardRef)(({src:e,srcSet:i,sizes:n,height:r,width:s,decoding:l,className:c,style:h,fetchPriority:d,placeholder:u,loading:p,unoptimized:f,fill:g,onLoadRef:_,onLoadingCompleteRef:b,setBlurComplete:w,setShowAltText:S,sizesInput:k,onLoad:C,onError:T,...E},N)=>{let M=(0,a.useCallback)(e=>{e&&(T&&(e.src=e.src),e.complete&&v(e,u,_,b,w,f,k))},[e,u,_,b,w,T,f,k]),O=(0,m.useMergedRef)(N,M);return(0,o.jsx)("img",{...E,...y(d),loading:p,width:s,height:r,decoding:l,"data-nimg":g?"fill":"1",className:c,style:h,sizes:n,srcSet:i,src:e,ref:O,onLoad:e=>{v(e.currentTarget,u,_,b,w,f,k)},onError:e=>{S(!0),"empty"!==u&&w(!0),T&&T(e)}})});function b({isAppRouter:e,imgAttributes:i}){let n={as:"image",imageSrcSet:i.srcSet,imageSizes:i.sizes,crossOrigin:i.crossOrigin,referrerPolicy:i.referrerPolicy,...y(i.fetchPriority)};return e&&l.default.preload?(l.default.preload(i.src,n),null):(0,o.jsx)(c.default,{children:(0,o.jsx)("link",{rel:"preload",href:i.srcSet?void 0:i.src,...n},"__nimg-"+i.src+i.srcSet+i.sizes)})}let w=(0,a.forwardRef)((e,i)=>{let n=(0,a.useContext)(p.RouterContext),r=(0,a.useContext)(u.ImageConfigContext),s=(0,a.useMemo)(()=>{let e=g||r||d.imageConfigDefault,i=[...e.deviceSizes,...e.imageSizes].sort((e,i)=>e-i),n=e.deviceSizes.sort((e,i)=>e-i),s=e.qualities?.sort((e,i)=>e-i);return{...e,allSizes:i,deviceSizes:n,qualities:s,localPatterns:"u"<typeof window?r?.localPatterns:e.localPatterns}},[r]),{onLoad:l,onLoadingComplete:c}=e,m=(0,a.useRef)(l);(0,a.useEffect)(()=>{m.current=l},[l]);let v=(0,a.useRef)(c);(0,a.useEffect)(()=>{v.current=c},[c]);let[y,w]=(0,a.useState)(!1),[S,k]=(0,a.useState)(!1),{props:C,meta:T}=(0,h.getImgProps)(e,{defaultLoader:f.default,imgConf:s,blurComplete:y,showAltText:S});return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(_,{...C,unoptimized:T.unoptimized,placeholder:T.placeholder,fill:T.fill,onLoadRef:m,onLoadingCompleteRef:v,setBlurComplete:w,setShowAltText:k,sizesInput:e.sizes,ref:i}),T.preload?(0,o.jsx)(b,{isAppRouter:!n,imgAttributes:C}):null]})});("function"==typeof n.default||"object"==typeof n.default&&null!==n.default)&&void 0===n.default.__esModule&&(Object.defineProperty(n.default,"__esModule",{value:!0}),Object.assign(n.default,n),i.exports=n.default)},776785,(e,i,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r={default:function(){return d},getImageProps:function(){return h}};for(var s in r)Object.defineProperty(n,s,{enumerable:!0,get:r[s]});let o=e.r(481258),a=e.r(622398),l=e.r(810034),c=o._(e.r(99552));function h(e){let{props:i}=(0,a.getImgProps)(e,{defaultLoader:c.default,imgConf:{deviceSizes:[640,750,828,1080,1200,1920,2048,3840],imageSizes:[32,48,64,96,128,256,384],qualities:[75],path:"/_next/image",loader:"default",dangerouslyAllowSVG:!1,unoptimized:!1}});for(let[e,n]of Object.entries(i))void 0===n&&delete i[e];return{props:i}}let d=l.Image},253937,(e,i,n)=>{i.exports=e.r(776785)},369090,(e,i,n)=>{"use strict";var r=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,s=/\n/g,o=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,l=/^:\s*/,c=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,h=/^[;\s]*/,d=/^\s+|\s+$/g;function u(e){return e?e.replace(d,""):""}i.exports=function(e,i){if("string"!=typeof e)throw TypeError("First argument must be a string");if(!e)return[];i=i||{};var n=1,d=1;function p(e){var i=e.match(s);i&&(n+=i.length);var r=e.lastIndexOf("\n");d=~r?e.length-r:d+e.length}function f(){var e={line:n,column:d};return function(i){return i.position=new m(e),v(o),i}}function m(e){this.start=e,this.end={line:n,column:d},this.source=i.source}function g(r){var s=Error(i.source+":"+n+":"+d+": "+r);if(s.reason=r,s.filename=i.source,s.line=n,s.column=d,s.source=e,i.silent);else throw s}function v(i){var n=i.exec(e);if(n){var r=n[0];return p(r),e=e.slice(r.length),n}}function y(e){var i;for(e=e||[];i=_();)!1!==i&&e.push(i);return e}function _(){var i=f();if("/"==e.charAt(0)&&"*"==e.charAt(1)){for(var n=2;""!=e.charAt(n)&&("*"!=e.charAt(n)||"/"!=e.charAt(n+1));)++n;if(n+=2,""===e.charAt(n-1))return g("End of comment missing");var r=e.slice(2,n-2);return d+=2,p(r),e=e.slice(n),d+=2,i({type:"comment",comment:r})}}m.prototype.content=e,v(o);var b,w=[];for(y(w);b=function(){var e=f(),i=v(a);if(i){if(_(),!v(l))return g("property missing ':'");var n=v(c),s=e({type:"declaration",property:u(i[0].replace(r,"")),value:n?u(n[0].replace(r,"")):""});return v(h),s}}();)!1!==b&&(w.push(b),y(w));return w}},559596,(e,i,n)=>{"use strict";var r=e.e&&e.e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(n,"__esModule",{value:!0}),n.default=function(e,i){let n=null;if(!e||"string"!=typeof e)return n;let r=(0,s.default)(e),o="function"==typeof i;return r.forEach(e=>{if("declaration"!==e.type)return;let{property:r,value:s}=e;o?i(r,s,e):s&&((n=n||{})[r]=s)}),n};let s=r(e.r(369090))},851521,(e,i,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.camelCase=void 0;var r=/^--[a-zA-Z0-9_-]+$/,s=/-([a-z])/g,o=/^[^-]+$/,a=/^-(webkit|moz|ms|o|khtml)-/,l=/^-(ms)-/,c=function(e,i){return i.toUpperCase()},h=function(e,i){return"".concat(i,"-")};n.camelCase=function(e,i){var n;return(void 0===i&&(i={}),!(n=e)||o.test(n)||r.test(n))?e:(e=e.toLowerCase(),(e=i.reactCompat?e.replace(l,h):e.replace(a,h)).replace(s,c))}},763185,(e,i,n)=>{"use strict";var r=(e.e&&e.e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(e.r(559596)),s=e.r(851521);function o(e,i){var n={};return e&&"string"==typeof e&&(0,r.default)(e,function(e,r){e&&r&&(n[(0,s.camelCase)(e,i)]=r)}),n}o.default=o,i.exports=o},975609,(e,i,n)=>{"use strict";var r=Object.prototype.hasOwnProperty,s=Object.prototype.toString,o=Object.defineProperty,a=Object.getOwnPropertyDescriptor,l=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===s.call(e)},c=function(e){if(!e||"[object Object]"!==s.call(e))return!1;var i,n=r.call(e,"constructor"),o=e.constructor&&e.constructor.prototype&&r.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!n&&!o)return!1;for(i in e);return void 0===i||r.call(e,i)},h=function(e,i){o&&"__proto__"===i.name?o(e,i.name,{enumerable:!0,configurable:!0,value:i.newValue,writable:!0}):e[i.name]=i.newValue},d=function(e,i){if("__proto__"===i){if(!r.call(e,i))return;else if(a)return a(e,i).value}return e[i]};i.exports=function e(){var i,n,r,s,o,a,u=arguments[0],p=1,f=arguments.length,m=!1;for("boolean"==typeof u&&(m=u,u=arguments[1]||{},p=2),(null==u||"object"!=typeof u&&"function"!=typeof u)&&(u={});p<f;++p)if(i=arguments[p],null!=i)for(n in i)r=d(u,n),u!==(s=d(i,n))&&(m&&s&&(c(s)||(o=l(s)))?(o?(o=!1,a=r&&l(r)?r:[]):a=r&&c(r)?r:{},h(u,{name:n,newValue:e(m,a,s)})):void 0!==s&&h(u,{name:n,newValue:s}));return u}},191871,e=>{"use strict";let i,n,r,s,o,a,l,c,h,d,u,p,f,m,g,v;var y,_,b,w,S,k,C,T,E,N,M,O,A,R,D,L,j,I,P,B,z,F,W,H,$,U,V,q,Y,K,X,J,G,Z,Q,ee,et,ei,en,er,es,eo,ea,el,ec,eh,ed,eu,ep,ef,em,eg,ev,ey,e_,eb,ex,ew,eS,ek,eC,eT,eE,eN,eM,eO,eA,eR,eD,eL,ej,eI,eP,eB,ez,eF,eW,eH,e$,eU,eV,eq,eY,eK,eX,eJ,eG,eZ,eQ,e0,e1,e2,e5,e3,e4,e6,e8,e9,e7,te,tt,ti,tn,tr,ts,to,ta,tl,tc,th,td,tu,tp,tf,tm,tg,tv,ty,t_,tb,tx,tw,tS,tk,tC,tT,tE,tN,tM,tO,tA,tR,tD,tL,tj,tI,tP,tB,tz,tF,tW,tH,t$,tU,tV,tq,tY,tK,tX,tJ,tG,tZ,tQ,t0,t1,t2,t5,t3,t4,t6,t8,t9,t7,ie,it,ii,ir,is,io,ia,il,ic,ih,id,iu,ip,im,ig,iv,iy,i_,ib,ix,iw,iS,ik,iC,iT,iE,iN=e.i(344180),iM=e.i(764556),iO=e.i(799543),iA=iM,iR=e.i(106206),iD=e.i(51190),iL=class e{static HORZ=new e("horz");static VERT=new e("vert");static flip(i){return i===e.HORZ?e.VERT:e.HORZ}_name;constructor(e){this._name=e}getName(){return this._name}toString(){return this._name}},ij=class e{static empty(){return new e(0,0,0,0)}static fromJson(i){return new e(i.x,i.y,i.width,i.height)}x;y;width;height;constructor(e,i,n,r){this.x=e,this.y=i,this.width=n,this.height=r}toJson(){return{x:this.x,y:this.y,width:this.width,height:this.height}}snap(e){this.x=Math.round(this.x/e)*e,this.y=Math.round(this.y/e)*e,this.width=Math.round(this.width/e)*e,this.height=Math.round(this.height/e)*e}static getBoundingClientRect(i){let{x:n,y:r,width:s,height:o}=i.getBoundingClientRect();return new e(n,r,s,o)}static getContentRect(i){let n=i.getBoundingClientRect(),r=window.getComputedStyle(i),s=parseFloat(r.paddingLeft),o=parseFloat(r.paddingRight),a=parseFloat(r.paddingTop),l=parseFloat(r.paddingBottom),c=parseFloat(r.borderLeftWidth),h=parseFloat(r.borderRightWidth),d=parseFloat(r.borderTopWidth),u=parseFloat(r.borderBottomWidth),p=n.width-c-s-o-h,f=n.height-d-a-l-u;return new e(n.left+c+s,n.top+d+a,p,f)}static fromDomRect(i){return new e(i.x,i.y,i.width,i.height)}relativeTo(i){return new e(this.x-i.x,this.y-i.y,this.width,this.height)}clone(){return new e(this.x,this.y,this.width,this.height)}equals(e){return this.x===e?.x&&this.y===e?.y&&this.width===e?.width&&this.height===e?.height}equalsWhenRounded(e){return!!e&&.5>Math.abs(this.x-e.x)&&.5>Math.abs(this.y-e.y)&&.5>Math.abs(this.width-e.width)&&.5>Math.abs(this.height-e.height)}equalSize(e){return this.width===e?.width&&this.height===e?.height}getBottom(){return this.y+this.height}getRight(){return this.x+this.width}get bottom(){return this.y+this.height}get right(){return this.x+this.width}getCenter(){return{x:this.x+this.width/2,y:this.y+this.height/2}}positionElement(e,i){this.styleWithPosition(e.style,i)}styleWithPosition(e,i="absolute"){return e.left=this.x+"px",e.top=this.y+"px",e.width=Math.max(0,this.width)+"px",e.height=Math.max(0,this.height)+"px",e.position=i,e}contains(e,i){return!!(this.x<=e&&e<=this.getRight()&&this.y<=i&&i<=this.getBottom())}removeInsets(i){return new e(this.x+i.left,this.y+i.top,Math.max(0,this.width-i.left-i.right),Math.max(0,this.height-i.top-i.bottom))}centerInRect(e){this.x=(e.width-this.width)/2,this.y=(e.height-this.height)/2}clamp(e){this.width>e.width&&(this.width=e.width),this.height>e.height&&(this.height=e.height),this.x<e.x&&(this.x=e.x),this.y<e.y&&(this.y=e.y),this.getRight()>e.getRight()&&(this.x=e.getRight()-this.width),this.getBottom()>e.getBottom()&&(this.y=e.getBottom()-this.height),this.x<e.x&&(this.x=e.x),this.y<e.y&&(this.y=e.y)}_getSize(e){let i=this.width;return e===iL.VERT&&(i=this.height),i}toString(){return"(Rect: x="+this.x+", y="+this.y+", width="+this.width+", height="+this.height+")"}},iI=class e{static values=new Map;static TOP=new e("top",iL.VERT,0);static BOTTOM=new e("bottom",iL.VERT,1);static LEFT=new e("left",iL.HORZ,0);static RIGHT=new e("right",iL.HORZ,1);static CENTER=new e("center",iL.VERT,0);static getByName(i){return e.values.get(i)}static getLocation(i,n,r){if(n=(n-i.x)/i.width,r=(r-i.y)/i.height,n>=.25&&n<.75&&r>=.25&&r<.75)return e.CENTER;let s=r>=n,o=r>=1-n;return s?o?e.BOTTOM:e.LEFT:o?e.RIGHT:e.TOP}name;orientation;indexPlus;constructor(i,n,r){this.name=i,this.orientation=n,this.indexPlus=r,e.values.set(this.name,this)}getName(){return this.name}getOrientation(){return this.orientation}getDockRect(i){return this===e.TOP?new ij(i.x,i.y,i.width,i.height/2):this===e.BOTTOM?new ij(i.x,i.getBottom()-i.height/2,i.width,i.height/2):this===e.LEFT?new ij(i.x,i.y,i.width/2,i.height):this===e.RIGHT?new ij(i.getRight()-i.width/2,i.y,i.width/2,i.height):i.clone()}split(i,n){return this===e.TOP?{start:new ij(i.x,i.y,i.width,n),end:new ij(i.x,i.y+n,i.width,i.height-n)}:this===e.LEFT?{start:new ij(i.x,i.y,n,i.height),end:new ij(i.x+n,i.y,i.width-n,i.height)}:this===e.RIGHT?{start:new ij(i.getRight()-n,i.y,n,i.height),end:new ij(i.x,i.y,i.width-n,i.height)}:{start:new ij(i.x,i.getBottom()-n,i.width,n),end:new ij(i.x,i.y,i.width,i.height-n)}}reflect(){return this===e.TOP?e.BOTTOM:this===e.LEFT?e.RIGHT:this===e.RIGHT?e.LEFT:e.TOP}toString(){return"(DockLocation: name="+this.name+", orientation="+this.orientation+")"}},iP=((sI={}).FLEXLAYOUT__BORDER="flexlayout__border",sI.FLEXLAYOUT__BORDER_="flexlayout__border_",sI.FLEXLAYOUT__BORDER_TAB_CONTENTS="flexlayout__border_tab_contents",sI.FLEXLAYOUT__BORDER_BUTTON="flexlayout__border_button",sI.FLEXLAYOUT__BORDER_BUTTON_="flexlayout__border_button_",sI.FLEXLAYOUT__BORDER_BUTTON_CONTENT="flexlayout__border_button_content",sI.FLEXLAYOUT__BORDER_BUTTON_LEADING="flexlayout__border_button_leading",sI.FLEXLAYOUT__BORDER_BUTTON_TRAILING="flexlayout__border_button_trailing",sI.FLEXLAYOUT__BORDER_BUTTON__SELECTED="flexlayout__border_button--selected",sI.FLEXLAYOUT__BORDER_BUTTON__UNSELECTED="flexlayout__border_button--unselected",sI.FLEXLAYOUT__BORDER_TOOLBAR_BUTTON_OVERFLOW="flexlayout__border_toolbar_button_overflow",sI.FLEXLAYOUT__BORDER_TOOLBAR_BUTTON_OVERFLOW_="flexlayout__border_toolbar_button_overflow_",sI.FLEXLAYOUT__BORDER_INNER="flexlayout__border_inner",sI.FLEXLAYOUT__BORDER_INNER_="flexlayout__border_inner_",sI.FLEXLAYOUT__BORDER_INNER_TAB_CONTAINER="flexlayout__border_inner_tab_container",sI.FLEXLAYOUT__BORDER_INNER_TAB_CONTAINER_="flexlayout__border_inner_tab_container_",sI.FLEXLAYOUT__BORDER_TAB_DIVIDER="flexlayout__border_tab_divider",sI.FLEXLAYOUT__BORDER_LEADING="flexlayout__border_leading",sI.FLEXLAYOUT__BORDER_SIZER="flexlayout__border_sizer",sI.FLEXLAYOUT__BORDER_TOOLBAR="flexlayout__border_toolbar",sI.FLEXLAYOUT__BORDER_TOOLBAR_="flexlayout__border_toolbar_",sI.FLEXLAYOUT__BORDER_TOOLBAR_BUTTON="flexlayout__border_toolbar_button",sI.FLEXLAYOUT__BORDER_TOOLBAR_BUTTON_FLOAT="flexlayout__border_toolbar_button-float",sI.FLEXLAYOUT__DRAG_RECT="flexlayout__drag_rect",sI.FLEXLAYOUT__EDGE_RECT="flexlayout__edge_rect",sI.FLEXLAYOUT__EDGE_RECT_TOP="flexlayout__edge_rect_top",sI.FLEXLAYOUT__EDGE_RECT_LEFT="flexlayout__edge_rect_left",sI.FLEXLAYOUT__EDGE_RECT_BOTTOM="flexlayout__edge_rect_bottom",sI.FLEXLAYOUT__EDGE_RECT_RIGHT="flexlayout__edge_rect_right",sI.FLEXLAYOUT__ERROR_BOUNDARY_CONTAINER="flexlayout__error_boundary_container",sI.FLEXLAYOUT__ERROR_BOUNDARY_CONTENT="flexlayout__error_boundary_content",sI.FLEXLAYOUT__FLOAT_WINDOW="flexlayout__float_window",sI.FLEXLAYOUT__FLOAT_WINDOW_HEADER="flexlayout__float_window_header",sI.FLEXLAYOUT__FLOAT_WINDOW_CONTENT="flexlayout__float_window_content",sI.FLEXLAYOUT__FLOATING_WINDOW_CONTENT="flexlayout__floating_window_content",sI.FLEXLAYOUT__LAYOUT="flexlayout__layout",sI.FLEXLAYOUT__LAYOUT_MOVEABLES="flexlayout__layout_moveables",sI.FLEXLAYOUT__LAYOUT_OVERLAY="flexlayout__layout_overlay",sI.FLEXLAYOUT__LAYOUT_TAB_STAMPS="flexlayout__layout_tab_stamps",sI.FLEXLAYOUT__LAYOUT_MAIN="flexlayout__layout_main",sI.FLEXLAYOUT__LAYOUT_BORDER_CONTAINER="flexlayout__layout_border_container",sI.FLEXLAYOUT__LAYOUT_BORDER_CONTAINER_INNER="flexlayout__layout_border_container_inner",sI.FLEXLAYOUT__OUTLINE_RECT="flexlayout__outline_rect",sI.FLEXLAYOUT__OUTLINE_RECT_EDGE="flexlayout__outline_rect_edge",sI.FLEXLAYOUT__SPLITTER="flexlayout__splitter",sI.FLEXLAYOUT__SPLITTER_EXTRA="flexlayout__splitter_extra",sI.FLEXLAYOUT__SPLITTER_="flexlayout__splitter_",sI.FLEXLAYOUT__SPLITTER_BORDER="flexlayout__splitter_border",sI.FLEXLAYOUT__SPLITTER_DRAG="flexlayout__splitter_drag",sI.FLEXLAYOUT__SPLITTER_HANDLE="flexlayout__splitter_handle",sI.FLEXLAYOUT__SPLITTER_HANDLE_HORZ="flexlayout__splitter_handle_horz",sI.FLEXLAYOUT__SPLITTER_HANDLE_VERT="flexlayout__splitter_handle_vert",sI.FLEXLAYOUT__ROW="flexlayout__row",sI.FLEXLAYOUT__TAB="flexlayout__tab",sI.FLEXLAYOUT__TAB_POSITION="flexlayout__tab_position",sI.FLEXLAYOUT__TAB_MOVEABLE="flexlayout__tab_moveable",sI.FLEXLAYOUT__TAB_OVERLAY="flexlayout__tab_overlay",sI.FLEXLAYOUT__TAB_LAYOUT_CONTAINER="flexlayout__tab_layout_container",sI.FLEXLAYOUT__TAB_LAYOUT_CONTAINER_USER="flexlayout__tab_layout_container_user",sI.FLEXLAYOUT__TABSET="flexlayout__tabset",sI.FLEXLAYOUT__TABSET_CONTAINER="flexlayout__tabset_container",sI.FLEXLAYOUT__TABSET_MAXIMIZED="flexlayout__tabset-maximized",sI.FLEXLAYOUT__TABSET_SELECTED="flexlayout__tabset-selected",sI.FLEXLAYOUT__TABSET_TAB_SPACER="flexlayout__tabset_tab_spacer",sI.FLEXLAYOUT__TABSET_TAB_DIVIDER="flexlayout__tabset_tab_divider",sI.FLEXLAYOUT__TABSET_TAB_DIVIDER_SELECTED_BEFORE="flexlayout__tabset_tab_divider_selected_before",sI.FLEXLAYOUT__TABSET_TAB_DIVIDER_SELECTED_AFTER="flexlayout__tabset_tab_divider_selected_after",sI.FLEXLAYOUT__TABSET_TAB_DIVIDER_INNER="flexlayout__tabset_tab_divider_inner",sI.FLEXLAYOUT__TABSET_CONTENT="flexlayout__tabset_content",sI.FLEXLAYOUT__TABSET_TABBAR_INNER="flexlayout__tabset_tabbar_inner",sI.FLEXLAYOUT__TABSET_TABBAR_INNER_="flexlayout__tabset_tabbar_inner_",sI.FLEXLAYOUT__TABSET_LEADING="flexlayout__tabset_leading",sI.FLEXLAYOUT__TABSET_TABBAR_INNER_TAB_CONTAINER="flexlayout__tabset_tabbar_inner_tab_container",sI.FLEXLAYOUT__TABSET_TABBAR_INNER_TAB_CONTAINER_="flexlayout__tabset_tabbar_inner_tab_container_",sI.FLEXLAYOUT__TABSET_TABBAR_OUTER="flexlayout__tabset_tabbar_outer",sI.FLEXLAYOUT__TABSET_TABBAR_OUTER_="flexlayout__tabset_tabbar_outer_",sI.FLEXLAYOUT__TAB_BORDER="flexlayout__tab_border",sI.FLEXLAYOUT__TAB_BORDER_="flexlayout__tab_border_",sI.FLEXLAYOUT__TAB_BUTTON="flexlayout__tab_button",sI.FLEXLAYOUT__TAB_BUTTON_STRETCH="flexlayout__tab_button_stretch",sI.FLEXLAYOUT__TAB_BUTTON_CONTENT="flexlayout__tab_button_content",sI.FLEXLAYOUT__TAB_BUTTON_LEADING="flexlayout__tab_button_leading",sI.FLEXLAYOUT__TAB_BUTTON_OVERFLOW="flexlayout__tab_button_overflow",sI.FLEXLAYOUT__TAB_BUTTON_OVERFLOW_COUNT="flexlayout__tab_button_overflow_count",sI.FLEXLAYOUT__TAB_BUTTON_TEXTBOX="flexlayout__tab_button_textbox",sI.FLEXLAYOUT__TAB_BUTTON_TRAILING="flexlayout__tab_button_trailing",sI.FLEXLAYOUT__TAB_BUTTON_STAMP="flexlayout__tab_button_stamp",sI.FLEXLAYOUT__TAB_TOOLBAR="flexlayout__tab_toolbar",sI.FLEXLAYOUT__TAB_TOOLBAR_BUTTON="flexlayout__tab_toolbar_button",sI.FLEXLAYOUT__TAB_TOOLBAR_ICON="flexlayout__tab_toolbar_icon",sI.FLEXLAYOUT__TAB_TOOLBAR_BUTTON_="flexlayout__tab_toolbar_button-",sI.FLEXLAYOUT__TAB_TOOLBAR_BUTTON_FLOAT="flexlayout__tab_toolbar_button-float",sI.FLEXLAYOUT__TAB_TOOLBAR_STICKY_BUTTONS_CONTAINER="flexlayout__tab_toolbar_sticky_buttons_container",sI.FLEXLAYOUT__TAB_TOOLBAR_BUTTON_CLOSE="flexlayout__tab_toolbar_button-close",sI.FLEXLAYOUT__POPUP_MENU_CONTAINER="flexlayout__popup_menu_container",sI.FLEXLAYOUT__POPUP_MENU_ITEM="flexlayout__popup_menu_item",sI.FLEXLAYOUT__POPUP_MENU_ITEM__SELECTED="flexlayout__popup_menu_item--selected",sI.FLEXLAYOUT__POPUP_MENU="flexlayout__popup_menu",sI.FLEXLAYOUT__MINI_SCROLLBAR="flexlayout__mini_scrollbar",sI.FLEXLAYOUT__MINI_SCROLLBAR_CONTAINER="flexlayout__mini_scrollbar_container",sI),iB=class e{static ADD_TAB="FlexLayout_AddTab";static DELETE_TAB="FlexLayout_DeleteTab";static RENAME_TAB="FlexLayout_RenameTab";static SELECT_TAB="FlexLayout_SelectTab";static MOVE_NODE="FlexLayout_MoveNode";static DELETE_TABSET="FlexLayout_DeleteTabset";static SET_ACTIVE_TABSET="FlexLayout_SetActiveTabset";static ADJUST_WEIGHTS="FlexLayout_AdjustWeights";static ADJUST_BORDER_SPLIT="FlexLayout_AdjustBorderSplit";static MAXIMIZE_TOGGLE="FlexLayout_MaximizeToggle";static UPDATE_MODEL_ATTRIBUTES="FlexLayout_UpdateModelAttributes";static UPDATE_NODE_ATTRIBUTES="FlexLayout_UpdateNodeAttributes";static POPOUT_TAB="FlexLayout_PopoutTab";static POPOUT_TABSET="FlexLayout_PopoutTabset";static CLOSE_POPOUT="FlexLayout_ClosePopout";static MOVE_POPOUT_TO_FRONT="FlexLayout_MoveFloatToFront";static CREATE_SUBLAYOUT="FlexLayout_CreateSubLayout";static addTab(i,n,r,s,o){return new iz(e.ADD_TAB,{json:i,toNode:n,location:r.getName(),index:s,select:o})}static addNode(e,i,n,r,s){return this.addTab(e,i,n,r,s)}static moveNode(i,n,r,s,o){return new iz(e.MOVE_NODE,{fromNode:i,toNode:n,location:r.getName(),index:s,select:o})}static deleteTab(i){return new iz(e.DELETE_TAB,{node:i})}static deleteTabset(i){return new iz(e.DELETE_TABSET,{node:i})}static renameTab(i,n){return new iz(e.RENAME_TAB,{node:i,text:n})}static selectTab(i){return new iz(e.SELECT_TAB,{tabNode:i})}static setActiveTabset(i,n){return new iz(e.SET_ACTIVE_TABSET,{tabsetNode:i,layoutId:n})}static adjustWeights(i,n){return new iz(e.ADJUST_WEIGHTS,{nodeId:i,weights:n})}static adjustBorderSplit(i,n){return new iz(e.ADJUST_BORDER_SPLIT,{node:i,size:n})}static maximizeToggle(i,n){return new iz(e.MAXIMIZE_TOGGLE,{node:i,layoutId:n})}static updateModelAttributes(i){return new iz(e.UPDATE_MODEL_ATTRIBUTES,{json:i})}static updateNodeAttributes(i,n){return new iz(e.UPDATE_NODE_ATTRIBUTES,{node:i,json:n})}static popoutTab(i,n="window"){return new iz(e.POPOUT_TAB,{node:i,type:n})}static popoutTabset(i,n="window"){return new iz(e.POPOUT_TABSET,{node:i,type:n})}static closePopout(i){return new iz(e.CLOSE_POPOUT,{layoutId:i})}static movePopoutToFront(i){return new iz(e.MOVE_POPOUT_TO_FRONT,{layoutId:i})}static createPopout(e,i,n){return this.createSubLayout(e,i,n)}static createSubLayout(i,n,r){return new iz(e.CREATE_SUBLAYOUT,{layout:i,rect:n,type:r})}},iz=class{type;data;constructor(e,i){this.type=e,this.data=i}},iF=class{attributes;nameToAttribute;constructor(){this.attributes=[],this.nameToAttribute=new Map}addWithAll(e,i,n,r){let s=new iW(e,i,n,r);return this.attributes.push(s),this.nameToAttribute.set(e,s),s}addInherited(e,i){return this.addWithAll(e,i,void 0,!1)}add(e,i,n){return this.addWithAll(e,void 0,i,n)}getAttributes(){return this.attributes}getModelName(e){let i=this.nameToAttribute.get(e);if(void 0!==i)return i.modelName}toJson(e,i){for(let n of this.attributes){let r=i[n.name];(n.alwaysWriteJson||r!==n.defaultValue)&&(e[n.name]=r)}}fromJson(e,i){for(let n of this.attributes){let r=e[n.name];void 0===r&&n.alias&&(r=e[n.alias]),void 0===r?i[n.name]=n.defaultValue:i[n.name]=r}}update(e,i){for(let n of this.attributes)if(Object.prototype.hasOwnProperty.call(e,n.name)){let r=e[n.name];void 0===r?delete i[n.name]:i[n.name]=r}}setDefaults(e){for(let i of this.attributes)e[i.name]=i.defaultValue}pairAttributes(e,i){for(let n of i.attributes)if(n.modelName&&this.nameToAttribute.has(n.modelName)){let i=this.nameToAttribute.get(n.modelName);i.setpairedAttr(n),n.setpairedAttr(i),i.setPairedType(e)}}toTypescriptInterface(e,i){let n=[],r=this.attributes.sort((e,i)=>e.name.localeCompare(i.name));n.push("export interface I"+e+"Attributes {");for(let e=0;e<r.length;e++){let s,o,a=r[e],l=a.type,c=a;void 0!==c.defaultValue?s=c.defaultValue:void 0!==c.modelName&&void 0!==i&&void 0!==i.nameToAttribute.get(c.modelName)&&(o=c.modelName,s=(c=i.nameToAttribute.get(o)).defaultValue,l=c.type);let h=JSON.stringify(s),d=c.required?"":"?",u=" /**\n ";a.description?u+=a.description:a.pairedType&&a.pairedAttr?.description&&(u+=`Value for ${a.pairedType} attribute ${a.pairedAttr.name} if not overridden`,u+="\n\n ",u+=a.pairedAttr?.description),u+="\n\n ",a.fixed?u+=`Fixed value: ${h}`:o?u+=`Default: inherited from Global attribute ${a.modelName} (default ${h})`:u+=`Default: ${h}`,u+="\n */",n.push(u),n.push(" "+a.name+d+": "+l+";\n")}return n.push("}"),n.join("\n")}},iW=class{static NUMBER="number";static STRING="string";static BOOLEAN="boolean";name;alias;modelName;pairedAttr;pairedType;defaultValue;alwaysWriteJson;type;required;fixed;description;constructor(e,i,n,r){this.name=e,this.alias=void 0,this.modelName=i,this.defaultValue=n,this.alwaysWriteJson=r,this.required=!1,this.fixed=!1,this.type="any"}setType(e){return this.type=e,this}setAlias(e){return this.alias=e,this}setDescription(e){this.description=e}setRequired(){return this.required=!0,this}setFixed(){return this.fixed=!0,this}setpairedAttr(e){this.pairedAttr=e}setPairedType(e){this.pairedType=e}},iH=class{node;rect;location;index;className;constructor(e,i,n,r,s){this.node=e,this.rect=i,this.location=n,this.index=r,this.className=s}},i$=class{model;attributes;parent;children;rect;path;listeners;constructor(e){this.model=e,this.attributes={},this.children=[],this.rect=ij.empty(),this.listeners=new Map,this.path=""}getId(){let e=this.attributes.id;return void 0!==e||(e=this.model.nextUniqueId(),this.setId(e)),e}getModel(){return this.model}getType(){return this.attributes.type}getParent(){return this.parent}getChildren(){return this.children}getRect(){return this.rect}getPath(){return this.path}isCloseable(){for(let e=0;e<this.children.length;e++)if(!this.children[e].isCloseable())return!1;return!0}isAllowedInWindow(){for(let e=0;e<this.children.length;e++)if(!this.children[e].isAllowedInWindow())return!1;return!0}getOrientation(){return void 0===this.parent?this.model.isRootOrientationVertical()?iL.VERT:iL.HORZ:iL.flip(this.parent.getOrientation())}getLayoutId(){return this.getLayout().getLayoutId()}getLayout(){return this.parent?this.parent.getLayout():this.model.getMainLayout()}setEventListener(e,i){this.listeners.set(e,i)}removeEventListener(e){this.listeners.delete(e)}setId(e){this.attributes.id=e}fireEvent(e,i){this.listeners.has(e)&&this.listeners.get(e)(i)}getAttr(e){let i=this.attributes[e];if(void 0===i){let n=this.getAttributeDefinitions().getModelName(e);void 0!==n&&(i=this.model.getAttribute(n))}return i}forEachNode(e,i){for(let n of(e(this,i),i++,this.children))n.forEachNode(e,i)}setPaths(e){let i=0;for(let n of this.children){let r=e;"row"===n.getType()?r+="/r"+i:"tabset"===n.getType()?r+="/ts"+i:"tab"===n.getType()&&(r+="/t"+i),n.path=r,n.setPaths(r),i++}}setParent(e){this.parent=e}setRect(e){this.rect=e}setPath(e){this.path=e}setWeight(e){this.attributes.weight=e}setSelected(e){this.attributes.selected=e}findDropTargetNode(e,i,n,r){let s;if(this.rect.contains(n,r)){if(void 0!==this.model.getMaximizedTabset(e))s=this.model.getMaximizedTabset(e).canDrop(i,n,r);else if(void 0===(s=this.canDrop(i,n,r))&&0!==this.children.length){for(let o of this.children)if(void 0!==(s=o.findDropTargetNode(e,i,n,r)))break}}return s}canDrop(e,i,n){}canDockInto(e,i){if(null!=i){if(i.location===iI.CENTER&&!1===i.node.isEnableDrop()||i.location===iI.CENTER&&"tabset"===e.getType()&&!1===e.isEnableClose()||i.location!==iI.CENTER&&!1===i.node.isEnableDivide())return!1;if(this.model.getOnAllowDrop())return this.model.getOnAllowDrop()(e,i)}return!0}removeChild(e){let i=this.children.indexOf(e);return -1!==i&&this.children.splice(i,1),i}addChild(e,i){return null!=i?this.children.splice(i,0,e):(this.children.push(e),i=this.children.length-1),e.parent=this,i}removeAll(){this.children=[]}styleWithPosition(e){return null==e&&(e={}),this.rect.styleWithPosition(e)}isEnableDivide(){return!0}toAttributeString(){return JSON.stringify(this.attributes,void 0," ")}},iU=class e extends i${static TYPE="tab";static fromJson(i,n,r=!0){return new e(n,i,r)}tabRect=ij.empty();moveableElement;renderedName;extra;visible;rendered;scrollTop;scrollLeft;tabStamp;constructor(i,n,r=!0){super(i),this.extra={},this.moveableElement=null,this.tabStamp=null,this.rendered=!1,this.visible=!1,e.attributeDefinitions.fromJson(n,this.attributes),!0===r&&i.addNode(this)}getName(){return this.getAttr("name")}getIcon(){return this.getAttr("icon")}getSubLayoutId(){return this.getAttr("subLayoutId")}getHelpText(){return this.getAttr("helpText")}getComponent(){return this.getAttr("component")}getWindowId(){let e=this.getLayout();if(e)return e.getWindowId()}getConfig(){return this.attributes.config}getExtraData(){return this.extra}isPoppedOut(){return this.getLayoutId()!==i9.MAIN_LAYOUT_ID}isSelected(){return this.getParent().getSelectedNode()===this}isCloseable(){let e=this.isEnableClose();return e&&this.getSubLayoutId()&&(e=this.model.getLayouts().get(this.getSubLayoutId()).getRootRow().isCloseable()),e}isAllowedInWindow(){let e=this.isEnablePopout();return e&&this.getSubLayoutId()&&(e=this.model.getLayouts().get(this.getSubLayoutId()).getRootRow().isAllowedInWindow()),e}isEnableClose(){return this.getAttr("enableClose")}getCloseType(){return this.getAttr("closeType")}isEnablePopout(){return this.getAttr("enablePopout")}isEnablePopoutIcon(){return this.getAttr("enablePopoutIcon")}isEnablePopoutFloatIcon(){return this.getAttr("enablePopoutFloatIcon")}isEnablePopoutOverlay(){return this.getAttr("enablePopoutOverlay")}isEnableDrag(){return this.getAttr("enableDrag")}isEnableRename(){return this.getAttr("enableRename")}isEnableWindowReMount(){return this.getAttr("enableWindowReMount")}getClassName(){return this.getAttr("className")}getContentClassName(){return this.getAttr("contentClassName")}getTabSetClassName(){return this.getAttr("tabsetClassName")}isEnableRenderOnDemand(){return this.getAttr("enableRenderOnDemand")}getMinWidth(){return this.getAttr("minWidth")}getMinHeight(){return this.getAttr("minHeight")}getMaxWidth(){return this.getAttr("maxWidth")}getMaxHeight(){return this.getAttr("maxHeight")}isVisible(){return this.visible}toJson(){let i={};return e.attributeDefinitions.toJson(i,this.attributes),i}saveScrollPosition(){this.moveableElement&&(this.scrollLeft=this.moveableElement.scrollLeft,this.scrollTop=this.moveableElement.scrollTop)}restoreScrollPosition(){this.scrollTop&&requestAnimationFrame(()=>{this.moveableElement&&this.scrollTop&&(this.moveableElement.scrollTop=this.scrollTop,this.moveableElement.scrollLeft=this.scrollLeft)})}setRect(e){e.equals(this.rect)||(this.fireEvent("resize",{rect:e}),this.rect=e)}setVisible(e){e!==this.visible&&(this.visible=e,this.fireEvent("visibility",{visible:e}))}getScrollTop(){return this.scrollTop}setScrollTop(e){this.scrollTop=e}getScrollLeft(){return this.scrollLeft}setScrollLeft(e){this.scrollLeft=e}isRendered(){return this.rendered}setRendered(e){this.rendered=e}getTabRect(){return this.tabRect}setTabRect(e){this.tabRect=e}getTabStamp(){return this.tabStamp}setTabStamp(e){this.tabStamp=e}getMoveableElement(){return this.moveableElement}setMoveableElement(e){this.moveableElement=e}setRenderedName(e){this.renderedName=e}getNameForOverflowMenu(){let e=this.getAttr("altName");return void 0!==e?e:this.renderedName}setName(e){this.attributes.name=e}delete(){this.parent.remove(this),this.getSubLayoutId()&&this.model.getLayouts().delete(this.getSubLayoutId()),this.fireEvent("close",{})}updateAttrs(i){e.attributeDefinitions.update(i,this.attributes)}getAttributeDefinitions(){return e.attributeDefinitions}setBorderWidth(e){this.attributes.borderWidth=e}setBorderHeight(e){this.attributes.borderHeight=e}static getAttributeDefinitions(){return e.attributeDefinitions}static attributeDefinitions=e.createAttributeDefinitions();static createAttributeDefinitions(){let i=new iF;return i.add("type",e.TYPE,!0).setType(iW.STRING).setFixed(),i.add("id",void 0).setType(iW.STRING).setDescription("the unique id of the tab, if left undefined a uuid will be assigned"),i.add("name","[Unnamed Tab]").setType(iW.STRING).setDescription("name of tab to be displayed in the tab button"),i.add("component",void 0).setType(iW.STRING).setDescription("string identifying which component to render in this tab (used in the layout factory function)"),i.add("subLayoutId",void 0).setType(iW.STRING).setDescription(`the Id of the sub layout to render in this tab, defined in the subLayouts section of the model json (if
|
|
4
|
+
component is also defined then use the <TabLayout> component in the factory to render the sublayout)`),i.add("altName",void 0).setType(iW.STRING).setDescription("if there is no name specifed then this value will be used in the overflow menu"),i.add("helpText",void 0).setType(iW.STRING).setDescription("help text for the tab to be displayed upon tab hover."),i.add("config",void 0).setType("any").setDescription("a place to hold json config for the hosted component"),i.add("tabsetClassName",void 0).setType(iW.STRING).setDescription("class applied to parent tabset when this is the only tab and it is stretched to fill the tabset"),i.add("enableWindowReMount",!1).setType(iW.BOOLEAN).setDescription("if enabled the tab will re-mount when popped out/in"),i.addInherited("enableClose","tabEnableClose").setType(iW.BOOLEAN).setDescription("allow user to close tab via close button"),i.addInherited("closeType","tabCloseType").setType("ICloseType").setDescription("see values in ICloseType"),i.addInherited("enableDrag","tabEnableDrag").setType(iW.BOOLEAN).setDescription("allow user to drag tab to new location"),i.addInherited("enableRename","tabEnableRename").setType(iW.BOOLEAN).setDescription("allow user to rename tabs by double clicking"),i.addInherited("className","tabClassName").setType(iW.STRING).setDescription("class applied to tab button"),i.addInherited("contentClassName","tabContentClassName").setType(iW.STRING).setDescription("class applied to tab content"),i.addInherited("icon","tabIcon").setType(iW.STRING).setDescription("the tab icon"),i.addInherited("enableRenderOnDemand","tabEnableRenderOnDemand").setType(iW.BOOLEAN).setDescription("whether to avoid rendering component until tab is visible"),i.addInherited("enablePopout","tabEnablePopout").setType(iW.BOOLEAN).setAlias("enableFloat").setDescription("enable popout (in popout capable browser)"),i.addInherited("enablePopoutIcon","tabEnablePopoutIcon").setType(iW.BOOLEAN).setDescription("whether to show the popout icon in the tabset header if this tab enables popouts"),i.addInherited("enablePopoutFloatIcon","tabEnablePopoutFloatIcon").setType(iW.BOOLEAN).setDescription("whether to show the popout float icon in the tabset header if this tab enables floating popouts"),i.addInherited("enablePopoutOverlay","tabEnablePopoutOverlay").setType(iW.BOOLEAN).setDescription(`if this tab will not work correctly in a popout window when the main window is backgrounded (inactive)
|
|
5
|
+
then enabling this option will gray out this tab`),i.addInherited("borderWidth","tabBorderWidth").setType(iW.NUMBER).setDescription("width when added to border, -1 will use border size"),i.addInherited("borderHeight","tabBorderHeight").setType(iW.NUMBER).setDescription("height when added to border, -1 will use border size"),i.addInherited("minWidth","tabMinWidth").setType(iW.NUMBER).setDescription("the min width of this tab"),i.addInherited("minHeight","tabMinHeight").setType(iW.NUMBER).setDescription("the min height of this tab"),i.addInherited("maxWidth","tabMaxWidth").setType(iW.NUMBER).setDescription("the max width of this tab"),i.addInherited("maxHeight","tabMaxHeight").setType(iW.NUMBER).setDescription("the max height of this tab"),i}};function iV(){return window.matchMedia&&window.matchMedia("(hover: hover) and (pointer: fine)").matches}function iq(e,i,n){let r,s=i.getName(),o=i.getName();void 0===n&&(n=0),void 0===r&&void 0!==i.getIcon()&&(r=0!==n?(0,iN.jsx)("img",{style:{width:"1em",height:"1em",transform:"rotate("+n+"deg)"},src:i.getIcon(),alt:"leadingContent"}):(0,iN.jsx)("img",{style:{width:"1em",height:"1em"},src:i.getIcon(),alt:"leadingContent"}));let a={leading:r,content:s,name:o,buttons:[]};return e.customizeTab(i,a),i.setRenderedName(a.name),a}function iY(e){let i=!1;return e.nativeEvent instanceof MouseEvent&&(0!==e.nativeEvent.button||e.ctrlKey||e.altKey||e.metaKey||e.shiftKey)&&(i=!0),i}function iK(e,i){for(let n of[...iX("iframe",i),...iX("webview",i)])n.style.pointerEvents=e?"auto":"none"}function iX(e,i){return[...i.getElementsByTagName(e)]}var iJ=!1;function iG(e,i,n,r,s){iJ=!0,i.preventDefault();let o=e=>{e.preventDefault(),n(e.clientX,e.clientY)},a=e=>{e.preventDefault(),iJ=!1,s()},l=()=>{e.removeEventListener("pointermove",o),e.removeEventListener("pointerup",l),e.removeEventListener("pointercancel",a),iJ=!1,r()};e.addEventListener("pointermove",o),e.addEventListener("pointerup",l),e.addEventListener("pointercancel",a)}function iZ(e,i){let n=i.getType();if("window"===n)return e.isAllowedInWindow();if("float"===n)return!0;if("tab"===n){let n,r=(i.getController().getModel().visitNodes(e=>{e instanceof iU&&e.getSubLayoutId()===i.getLayoutId()&&(n=e.getLayout())}),n);if(r&&"window"===r.getType()&&!r.isMainLayout()&&!e.isAllowedInWindow())return!1;if(e instanceof iU){if(void 0!==e.getSubLayoutId())return!1}else if(e instanceof i1){for(let i of e.getChildren())if(void 0!==i.getSubLayoutId())return!1}return!0}return!1}function iQ(e,i){let n=e.getAttribute("style");return n!==i.getAttribute("style")&&(n?i.setAttribute("style",n):i.removeAttribute("style"),!0)}var i0=class e extends i${static TYPE="row";static fromJson(i,n,r){let s=new e(n,i);if(null!=i.children){for(let o of i.children)if(o.type===i1.TYPE){let e=i1.fromJson(o,n,r);s.addChild(e)}else if(o.type===e.TYPE){let i=e.fromJson(o,n,r);s.addChild(i)}}return s}static attributeDefinitions=e.createAttributeDefinitions();layout;minHeight;minWidth;maxHeight;maxWidth;constructor(i,n){super(i),this.minHeight=1,this.minWidth=1,this.maxHeight=i8,this.maxWidth=i8,e.attributeDefinitions.fromJson(n,this.attributes),this.normalizeWeights(),i.addNode(this)}getWeight(){return this.attributes.weight}toJson(){let i={};for(let n of(e.attributeDefinitions.toJson(i,this.attributes),i.children=[],this.children))i.children.push(n.toJson());return i}getLayout(){return this.layout?this.layout:super.getLayout()}setLayout(e){this.layout=e}setWeight(e){this.attributes.weight=e}getSplitterBounds(e){let i=this.getOrientation()===iL.HORZ,n=this.getChildren(),r=this.model.getSplitterSize(),s=n[0].getRect(),o=n[n.length-1].getRect(),a=i?[s.x,o.getRight()]:[s.y,o.getBottom()],l=i?[s.x,o.getRight()]:[s.y,o.getBottom()];for(let s=0;s<e;s++){let e=n[s];a[0]+=i?e.getMinWidth():e.getMinHeight(),l[0]+=i?e.getMaxWidth():e.getMaxHeight(),s>0&&(a[0]+=r,l[0]+=r)}for(let s=n.length-1;s>=e;s--){let e=n[s];a[1]-=(i?e.getMinWidth():e.getMinHeight())+r,l[1]-=(i?e.getMaxWidth():e.getMaxHeight())+r}return[Math.max(l[1],a[0]),Math.min(l[0],a[1])]}getSplitterInitials(e){let i=this.getOrientation()===iL.HORZ,n=this.getChildren(),r=this.model.getSplitterSize(),s=[],o=0;for(let e=0;e<n.length;e++){let r=n[e].getRect(),a=i?r.width:r.height;s.push(a),o+=a}let a=n[e].getRect();return{initialSizes:s,sum:o,startPosition:(i?a.x:a.y)-r}}calculateSplit(e,i,n,r,s){let o=this.getOrientation()===iL.HORZ,a=this.getChildren(),l=a[e],c=o?l.getMaxWidth():l.getMaxHeight(),h=[...n];if(i<s){let n=s-i,r=0;h[e]+n>c?(r=h[e]+n-c,h[e]=c):h[e]+=n;for(let i=e-1;i>=0;i--){let e=a[i],r=o?e.getMinWidth():e.getMinHeight();if(h[i]-n>r){h[i]-=n;break}n-=h[i]-r,h[i]=r}for(let i=e+1;i<a.length;i++){let e=a[i],n=o?e.getMaxWidth():e.getMaxHeight();if(h[i]+r<n){h[i]+=r;break}r-=n-h[i],h[i]=n}}else{let n=i-s,r=0;h[e-1]+n>c?(r=h[e-1]+n-c,h[e-1]=c):h[e-1]+=n;for(let i=e;i<a.length;i++){let e=a[i],r=o?e.getMinWidth():e.getMinHeight();if(h[i]-n>r){h[i]-=n;break}n-=h[i]-r,h[i]=r}for(let i=e-1;i>=0;i--){let e=a[i],n=o?e.getMaxWidth():e.getMaxHeight();if(h[i]+r<n){h[i]+=r;break}r-=n-h[i],h[i]=n}}return h.map(e=>100*Math.max(.1,e)/r)}getMinSize(e){return e===iL.HORZ?this.getMinWidth():this.getMinHeight()}getMinWidth(){return this.minWidth}getMinHeight(){return this.minHeight}getMaxSize(e){return e===iL.HORZ?this.getMaxWidth():this.getMaxHeight()}getMaxWidth(){return this.maxWidth}getMaxHeight(){return this.maxHeight}calcMinMaxSize(){this.minHeight=1,this.minWidth=1,this.maxHeight=i8,this.maxWidth=i8;let e=!0;for(let i of this.children)i.calcMinMaxSize(),this.getOrientation()===iL.VERT?(this.minHeight+=i.getMinHeight(),this.maxHeight+=i.getMaxHeight(),e||(this.minHeight+=this.model.getSplitterSize(),this.maxHeight+=this.model.getSplitterSize()),this.minWidth=Math.max(this.minWidth,i.getMinWidth()),this.maxWidth=Math.min(this.maxWidth,i.getMaxWidth())):(this.minWidth+=i.getMinWidth(),this.maxWidth+=i.getMaxWidth(),e||(this.minWidth+=this.model.getSplitterSize(),this.maxWidth+=this.model.getSplitterSize()),this.minHeight=Math.max(this.minHeight,i.getMinHeight()),this.maxHeight=Math.min(this.maxHeight,i.getMaxHeight())),e=!1}tidy(){let i=0;for(;i<this.children.length;){let n=this.children[i];if(n instanceof e){n.tidy();let r=n.getChildren();if(0===r.length)this.removeChild(n);else if(1===r.length){let s=r[0];if(this.removeChild(n),s instanceof e){let e=0,r=s.getChildren();for(let i of r)e+=i.getWeight();for(let s=0;s<r.length;s++){let o=r[s];o.setWeight(n.getWeight()*o.getWeight()/e),this.addChild(o,i+s)}}else s.setWeight(n.getWeight()),this.addChild(s,i)}else i++}else n instanceof i1&&0===n.getChildren().length&&n.isEnableDeleteWhenEmpty()&&n.isEnableClose()?(this.removeChild(n),n===this.model.getMaximizedTabset(this.getLayoutId())&&this.model.setMaximizedTabset(void 0,this.getLayoutId())):i++}if(this===this.model.getRootRow(this.getLayoutId())&&0===this.children.length)if(this.getLayout()?.getType()!=="tab"&&this.getLayoutId()!==i9.MAIN_LAYOUT_ID)this.model.getLayouts().delete(this.getLayoutId());else{let e=this.model.getOnCreateTabSet(),i=e?e():{};i={...i,selected:-1};let n=new i1(this.model,i);this.model.setActiveTabset(n,this.getLayoutId()),this.addChild(n)}}canDrop(e,i,n){let r,s=n-this.rect.y,o=i-this.rect.x,a=this.rect.width,l=this.rect.height,c=this.model.isEnableEdgeDockIndicators()?50:9999,h=this.getLayout();if(this.getLayoutId()===i9.MAIN_LAYOUT_ID||iZ(e,h)){if(this.model.isEnableEdgeDock()&&void 0===this.parent){if(i<this.rect.x+10&&s>l/2-c&&s<l/2+c){let e=iI.LEFT,i=e.getDockRect(this.rect);i.width=i.width/2,r=new iH(this,i,e,-1,iP.FLEXLAYOUT__OUTLINE_RECT_EDGE)}else if(i>this.rect.getRight()-10&&s>l/2-c&&s<l/2+c){let e=iI.RIGHT,i=e.getDockRect(this.rect);i.width=i.width/2,i.x+=i.width,r=new iH(this,i,e,-1,iP.FLEXLAYOUT__OUTLINE_RECT_EDGE)}else if(n<this.rect.y+10&&o>a/2-c&&o<a/2+c){let e=iI.TOP,i=e.getDockRect(this.rect);i.height=i.height/2,r=new iH(this,i,e,-1,iP.FLEXLAYOUT__OUTLINE_RECT_EDGE)}else if(n>this.rect.getBottom()-10&&o>a/2-c&&o<a/2+c){let e=iI.BOTTOM,i=e.getDockRect(this.rect);i.height=i.height/2,i.y+=i.height,r=new iH(this,i,e,-1,iP.FLEXLAYOUT__OUTLINE_RECT_EDGE)}if(void 0!==r&&!e.canDockInto(e,r))return}return r}}drop(i,n,r){let s,o=i.getParent();if(o&&o.removeChild(i),void 0!==o&&o instanceof i1&&o.setSelected(0),void 0!==o&&o instanceof i3&&o.setSelected(-1),i instanceof i1||i instanceof e)(s=i)instanceof e&&s.getOrientation()===this.getOrientation()&&(n.getOrientation()===this.getOrientation()||n===iI.CENTER)&&(s=new e(this.model,{})).addChild(i);else{let e=this.model.getOnCreateTabSet(),n=e?e(i):{};(s=new i1(this.model,n)).addChild(i)}let a=this.children.reduce((e,i)=>e+i.getWeight(),0);0===a&&(a=100),s.setWeight(a/3);let l=!this.model.isRootOrientationVertical();if(n===iI.CENTER)-1===r?this.addChild(s,this.children.length):this.addChild(s,r);else if(l&&n===iI.LEFT||!l&&n===iI.TOP)this.addChild(s,0);else if(l&&n===iI.RIGHT||!l&&n===iI.BOTTOM)this.addChild(s);else if(l&&n===iI.TOP||!l&&n===iI.LEFT){let i=new e(this.model,{}),n=new e(this.model,{});for(let e of(n.setWeight(75),s.setWeight(25),this.children))n.addChild(e);this.removeAll(),i.addChild(s),i.addChild(n),this.addChild(i)}else if(l&&n===iI.BOTTOM||!l&&n===iI.RIGHT){let i=new e(this.model,{}),n=new e(this.model,{});for(let e of(n.setWeight(75),s.setWeight(25),this.children))n.addChild(e);this.removeAll(),i.addChild(n),i.addChild(s),this.addChild(i)}s instanceof i1&&this.model.setActiveTabset(s,this.getLayoutId()),this.model.tidy()}isEnableDrop(){return!0}getAttributeDefinitions(){return e.attributeDefinitions}updateAttrs(i){e.attributeDefinitions.update(i,this.attributes)}static getAttributeDefinitions(){return e.attributeDefinitions}normalizeWeights(){let e=0;for(let i of this.children)e+=i.getWeight();for(let i of(0===e&&(e=1),this.children))i.setWeight(Math.max(.001,100*i.getWeight()/e))}static createAttributeDefinitions(){let i=new iF;return i.add("type",e.TYPE,!0).setType(iW.STRING).setFixed(),i.add("id",void 0).setType(iW.STRING).setDescription("the unique id of the row, if left undefined a uuid will be assigned"),i.add("weight",100).setType(iW.NUMBER).setDescription("relative weight for sizing of this row in parent row"),i}},i1=class e extends i${static TYPE="tabset";static fromJson(i,n,r){let s=new e(n,i);if(null!=i.children)for(let e of i.children){let i=iU.fromJson(e,n);s.addChild(i)}return 0===s.children.length&&s.setSelected(-1),i.maximized&&!0===i.maximized&&r.setMaximizedTabSet(s),i.active&&!0===i.active&&r.setActiveTabSet(s),s}static attributeDefinitions=e.createAttributeDefinitions();tabStripRect=ij.empty();contentRect=ij.empty();calculatedMinHeight;calculatedMinWidth;calculatedMaxHeight;calculatedMaxWidth;constructor(i,n){super(i),this.calculatedMinHeight=0,this.calculatedMinWidth=0,this.calculatedMaxHeight=0,this.calculatedMaxWidth=0,e.attributeDefinitions.fromJson(n,this.attributes),i.addNode(this)}getName(){return this.getAttr("name")}isEnableActiveIcon(){return this.getAttr("enableActiveIcon")}getSelected(){let e=this.attributes.selected;return void 0!==e?e:-1}getSelectedNode(){let e=this.getSelected();if(-1!==e)return this.children[e]}getWeight(){return this.getAttr("weight")}getAttrMinWidth(){return this.getAttr("minWidth")}getAttrMinHeight(){return this.getAttr("minHeight")}getMinWidth(){return this.calculatedMinWidth}getMinHeight(){return this.calculatedMinHeight}getMinSize(e){return e===iL.HORZ?this.getMinWidth():this.getMinHeight()}getAttrMaxWidth(){return this.getAttr("maxWidth")}getAttrMaxHeight(){return this.getAttr("maxHeight")}getMaxWidth(){return this.calculatedMaxWidth}getMaxHeight(){return this.calculatedMaxHeight}getMaxSize(e){return e===iL.HORZ?this.getMaxWidth():this.getMaxHeight()}isCloseable(){let e=this.isEnableClose();return e&&(e=super.isCloseable()),e}getConfig(){return this.attributes.config}isMaximized(){return this.model.getMaximizedTabset(this.getLayoutId())===this}isActive(){return this.model.getActiveTabset(this.getLayoutId())===this}isEnableDeleteWhenEmpty(){return this.getAttr("enableDeleteWhenEmpty")}isEnableDrop(){return this.getAttr("enableDrop")}isEnableTabStrip(){return this.getAttr("enableTabStrip")}isEnableTabWrap(){return this.getAttr("enableTabWrap")}isEnableDrag(){return this.getAttr("enableDrag")}isEnableDivide(){return this.getAttr("enableDivide")}isEnableMaximize(){return this.getAttr("enableMaximize")}isEnableClose(){return this.getAttr("enableClose")}isEnableCloseButton(){return this.getAttr("enableCloseButton")}isEnableSingleTabStretch(){return this.getAttr("enableSingleTabStretch")}isAutoSelectTab(){return this.getAttr("autoSelectTab")}isEnableTabScrollbar(){return this.getAttr("enableTabScrollbar")}getClassNameTabStrip(){return this.getAttr("classNameTabStrip")}getTabLocation(){return this.getAttr("tabLocation")}toJson(){let i={};return e.attributeDefinitions.toJson(i,this.attributes),i.children=this.children.map(e=>e.toJson()),this.isActive()&&(i.active=!0),this.isMaximized()&&(i.maximized=!0),i}calcMinMaxSize(){for(let e of(this.calculatedMinHeight=this.getAttrMinHeight(),this.calculatedMinWidth=this.getAttrMinWidth(),this.calculatedMaxHeight=this.getAttrMaxHeight(),this.calculatedMaxWidth=this.getAttrMaxWidth(),this.children))this.calculatedMinWidth=Math.max(this.calculatedMinWidth,e.getMinWidth()),this.calculatedMinHeight=Math.max(this.calculatedMinHeight,e.getMinHeight()),this.calculatedMaxWidth=Math.min(this.calculatedMaxWidth,e.getMaxWidth()),this.calculatedMaxHeight=Math.min(this.calculatedMaxHeight,e.getMaxHeight());this.calculatedMinHeight+=this.tabStripRect.height,this.calculatedMaxHeight+=this.tabStripRect.height}canMaximize(){return!!this.isEnableMaximize()&&(this.getModel().getMaximizedTabset(this.getLayoutId())===this||this.getParent()!==this.getModel().getRootRow(this.getLayoutId())||1!==this.getModel().getRootRow(this.getLayoutId()).getChildren().length)}setContentRect(e){this.contentRect=e}getContentRect(){return this.contentRect}setTabStripRect(e){this.tabStripRect=e}setWeight(e){this.attributes.weight=e}setSelected(e){this.attributes.selected=e}canDrop(e,i,n){let r,s=this.getLayout();if(e===this){let e=iI.CENTER;r=new iH(this,this.tabStripRect,e,-1,iP.FLEXLAYOUT__OUTLINE_RECT)}else if(this.getLayoutId()!==i9.MAIN_LAYOUT_ID&&!iZ(e,s))return;else if(this.contentRect.contains(i,n)){let e=iI.CENTER;void 0===this.model.getMaximizedTabset(this.getLayoutId())&&(e=iI.getLocation(this.contentRect,i,n)),r=new iH(this,e.getDockRect(this.rect),e,-1,iP.FLEXLAYOUT__OUTLINE_RECT)}else if(null!=this.tabStripRect&&this.tabStripRect.contains(i,n)){let e,s,o;if(0===this.children.length)s=(e=this.tabStripRect.clone()).y+3,o=e.height-4,e.width=2;else{let a=this.children[0];s=(e=a.getTabRect()).y,o=e.height;let l=this.tabStripRect.x;for(let o=0;o<this.children.length;o++){(e=(a=this.children[o]).getTabRect()).y!==s&&(s=e.y,l=this.tabStripRect.x);let c=e.x+e.width/2;if(l<=i&&i<c&&e.y<n&&n<e.getBottom()){let i=iI.CENTER,n=new ij(e.x-2,e.y,3,e.height);if(!(this.rect.x<e.x&&e.x<this.rect.getRight()))return;r=new iH(this,n,i,o,iP.FLEXLAYOUT__OUTLINE_RECT);break}l=c}}if(null==r&&e.getRight()<this.rect.getRight()){let i=iI.CENTER;r=new iH(this,new ij(e.getRight()-2,s,3,o),i,this.children.length,iP.FLEXLAYOUT__OUTLINE_RECT)}}if(e.canDockInto(e,r))return r}delete(){this.parent.removeChild(this)}remove(e){let i=this.removeChild(e);this.model.tidy(),i2(this,i)}drop(i,n,r,s){if(this===i)return;let o=i.getParent(),a=0;if(void 0!==o&&(a=o.removeChild(i),o instanceof i3&&o.getSelected()===a?o.setSelected(-1):i2(o,a)),i instanceof iU&&o===this&&a<r&&r>0&&r--,n===iI.CENTER){let e=r;if(-1===e&&(e=this.children.length),i instanceof iU)this.addChild(i,e),(s||!1!==s&&this.isAutoSelectTab())&&this.setSelected(e);else if(i instanceof i0)i.forEachNode((i,n)=>{i instanceof iU&&(this.addChild(i,e),e++)},0);else{for(let n=0;n<i.getChildren().length;n++){let r=i.getChildren()[n];this.addChild(r,e),e++}-1===this.getSelected()&&this.children.length>0&&this.setSelected(0)}this.model.setActiveTabset(this,this.parent.getLayoutId())}else{let r=i;if(i instanceof iU){let n=this.model.getOnCreateTabSet();(r=new e(this.model,n?n(i):{})).addChild(i)}else if(i instanceof i0){let e=this.getParent();if(i.getOrientation()===e.getOrientation()&&(n.getOrientation()===e.getOrientation()||n===iI.CENTER)){let e=new i0(this.model,{});e.addChild(i),r=e}}else r=i;let s=this.parent,o=s.getChildren().indexOf(this);if(s.getOrientation()===n.orientation)r.setWeight(this.getWeight()/2),this.setWeight(this.getWeight()/2),s.addChild(r,o+n.indexPlus);else{let e=new i0(this.model,{});e.setWeight(this.getWeight()),e.addChild(this),this.setWeight(50),r.setWeight(50),e.addChild(r,n.indexPlus),s.removeChild(this),s.addChild(e,o)}r instanceof e&&this.model.setActiveTabset(r,this.getLayoutId())}this.model.tidy()}updateAttrs(i){e.attributeDefinitions.update(i,this.attributes)}getAttributeDefinitions(){return e.attributeDefinitions}static getAttributeDefinitions(){return e.attributeDefinitions}static createAttributeDefinitions(){let i=new iF;return i.add("type",e.TYPE,!0).setType(iW.STRING).setFixed(),i.add("id",void 0).setType(iW.STRING).setDescription("the unique id of the tab set, if left undefined a uuid will be assigned"),i.add("weight",100).setType(iW.NUMBER).setDescription("relative weight for sizing of this tabset in parent row"),i.add("selected",0).setType(iW.NUMBER).setDescription("index of selected/visible tab in tabset"),i.add("name",void 0).setType(iW.STRING),i.add("config",void 0).setType("any").setDescription("a place to hold json config used in your own code"),i.addInherited("enableDeleteWhenEmpty","tabSetEnableDeleteWhenEmpty").setDescription("whether to delete this tabset when is has no tabs"),i.addInherited("enableDrop","tabSetEnableDrop").setDescription("allow user to drag tabs into this tabset"),i.addInherited("enableDrag","tabSetEnableDrag").setDescription("allow user to drag tabs out this tabset"),i.addInherited("enableDivide","tabSetEnableDivide").setDescription("allow user to drag tabs to region of this tabset, splitting into new tabset"),i.addInherited("enableMaximize","tabSetEnableMaximize").setDescription("allow user to maximize tabset to fill view via maximize button"),i.addInherited("enableClose","tabSetEnableClose").setDescription("can this tabset be closed"),i.addInherited("enableCloseButton","tabSetEnableCloseButton").setDescription("if the tabset can be closed then show a close button"),i.addInherited("enableSingleTabStretch","tabSetEnableSingleTabStretch").setDescription("if the tabset has only a single tab then stretch the single tab to fill area and display in a header style"),i.addInherited("classNameTabStrip","tabSetClassNameTabStrip").setDescription("a class name to apply to the tab strip"),i.addInherited("enableTabStrip","tabSetEnableTabStrip").setDescription("enable tab strip and allow multiple tabs in this tabset"),i.addInherited("minWidth","tabSetMinWidth").setDescription("minimum width (in px) for this tabset"),i.addInherited("minHeight","tabSetMinHeight").setDescription("minimum height (in px) for this tabset"),i.addInherited("maxWidth","tabSetMaxWidth").setDescription("maximum width (in px) for this tabset"),i.addInherited("maxHeight","tabSetMaxHeight").setDescription("maximum height (in px) for this tabset"),i.addInherited("enableTabWrap","tabSetEnableTabWrap").setDescription("wrap tabs onto multiple lines"),i.addInherited("tabLocation","tabSetTabLocation").setDescription("the location of the tabs either top or bottom"),i.addInherited("autoSelectTab","tabSetAutoSelectTab").setType(iW.BOOLEAN).setDescription("whether to select new/moved tabs in tabset"),i.addInherited("enableActiveIcon","tabSetEnableActiveIcon").setType(iW.BOOLEAN).setDescription("whether the active icon (*) should be displayed when the tabset is active"),i.addInherited("enableTabScrollbar","tabSetEnableTabScrollbar").setType(iW.BOOLEAN).setDescription("whether to show a mini scrollbar for the tabs"),i}};function i2(e,i){if(void 0!==e&&(e instanceof i1||e instanceof i3)){let n=e.getSelected();-1!==n&&(i===n&&e.getChildren().length>0?i>=e.getChildren().length&&e.setSelected(e.getChildren().length-1):i<n?e.setSelected(n-1):i>n||e.setSelected(-1))}}function i5(){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16))}var i3=class e extends i${static TYPE="border";static fromJson(i,n){let r=new e(iI.getByName(i.location),i,n);return i.children&&(r.children=i.children.map(e=>{let i=iU.fromJson(e,n);return i.setParent(r),i})),r}static attributeDefinitions=e.createAttributeDefinitions();contentRect=ij.empty();tabHeaderRect=ij.empty();location;constructor(i,n,r){super(r),this.location=i,this.attributes.id=`border_${i.getName()}`,e.attributeDefinitions.fromJson(n,this.attributes),r.addNode(this)}getLocation(){return this.location}getClassName(){return this.getAttr("className")}isHorizontal(){return this.location.orientation===iL.HORZ}getSize(){let e=this.getAttr("size"),i=this.getSelected();if(-1===i)return e;{let n=this.children[i],r=this.isHorizontal()?n.getAttr("borderWidth"):n.getAttr("borderHeight");return -1===r?e:r}}getMinSize(){let e=this.getSelectedNode(),i=this.getAttr("minSize");return e&&(i=Math.max(i,this.isHorizontal()?e.getMinWidth():e.getMinHeight())),i}getMaxSize(){let e=this.getSelectedNode(),i=this.getAttr("maxSize");return e&&(i=Math.min(i,this.isHorizontal()?e.getMaxWidth():e.getMaxHeight())),i}getSelected(){return this.attributes.selected}isAutoHide(){return this.getAttr("enableAutoHide")}getSelectedNode(){if(-1!==this.getSelected())return this.children[this.getSelected()]}getOrientation(){return this.location.getOrientation()}getConfig(){return this.attributes.config}isMaximized(){return!1}isShowing(){return this.attributes.show}toJson(){let i={location:"bottom"};return e.attributeDefinitions.toJson(i,this.attributes),i.location=this.location.getName(),i.children=this.children.map(e=>e.toJson()),i}isAutoSelectTab(e){return(null==e&&(e=-1!==this.getSelected()),e)?this.getAttr("autoSelectTabWhenOpen"):this.getAttr("autoSelectTabWhenClosed")}isEnableTabScrollbar(){return this.getAttr("enableTabScrollbar")}setSelected(e){this.attributes.selected=e}getTabHeaderRect(){return this.tabHeaderRect}setTabHeaderRect(e){this.tabHeaderRect=e}getRect(){return this.tabHeaderRect}getContentRect(){return this.contentRect}setContentRect(e){this.contentRect=e}isEnableDrop(){return this.getAttr("enableDrop")}setSize(e){let i=this.getSelected();if(-1===i)this.attributes.size=e;else{let n=this.children[i];(this.isHorizontal()?n.getAttr("borderWidth"):n.getAttr("borderHeight"))===-1?this.attributes.size=e:this.isHorizontal()?n.setBorderWidth(e):n.setBorderHeight(e)}}updateAttrs(i){e.attributeDefinitions.update(i,this.attributes)}remove(e){let i=this.removeChild(e);-1!==this.getSelected()&&i2(this,i)}canDrop(e,i,n){let r;if(!(e instanceof iU))return;let s=iI.CENTER;if(this.tabHeaderRect.contains(i,n)){if(this.location.orientation===iL.VERT)if(this.children.length>0){let e=this.children[0],n=e.getTabRect(),o=n.y,a=n.height,l=this.tabHeaderRect.x;for(let c=0;c<this.children.length;c++){let h=(n=(e=this.children[c]).getTabRect()).x+n.width/2;if(i>=l&&i<h){r=new iH(this,new ij(n.x-2,o,3,a),s,c,iP.FLEXLAYOUT__OUTLINE_RECT);break}l=h}null==r&&(r=new iH(this,new ij(n.getRight()-2,o,3,a),s,this.children.length,iP.FLEXLAYOUT__OUTLINE_RECT))}else r=new iH(this,new ij(this.tabHeaderRect.x+1,this.tabHeaderRect.y+2,3,18),s,0,iP.FLEXLAYOUT__OUTLINE_RECT);else if(this.children.length>0){let e=this.children[0],i=e.getTabRect(),o=i.x,a=i.width,l=this.tabHeaderRect.y;for(let c=0;c<this.children.length;c++){let h=(i=(e=this.children[c]).getTabRect()).y+i.height/2;if(n>=l&&n<h){r=new iH(this,new ij(o,i.y-2,a,3),s,c,iP.FLEXLAYOUT__OUTLINE_RECT);break}l=h}null==r&&(r=new iH(this,new ij(o,i.getBottom()-2,a,3),s,this.children.length,iP.FLEXLAYOUT__OUTLINE_RECT))}else r=new iH(this,new ij(this.tabHeaderRect.x+2,this.tabHeaderRect.y+1,18,3),s,0,iP.FLEXLAYOUT__OUTLINE_RECT);if(!e.canDockInto(e,r))return}else if(-1!==this.getSelected()&&this.contentRect.contains(i,n)&&(r=new iH(this,this.contentRect,s,-1,iP.FLEXLAYOUT__OUTLINE_RECT),!e.canDockInto(e,r)))return;return r}drop(i,n,r,s){let o=0,a=i.getParent();void 0!==a&&(o=a.removeChild(i),a!==this&&a instanceof e&&a.getSelected()===o?a.setSelected(-1):i2(a,o)),i instanceof iU&&a===this&&o<r&&r>0&&r--;let l=r;-1===l&&(l=this.children.length),i instanceof iU&&this.addChild(i,l),(s||!1!==s&&this.isAutoSelectTab())&&this.setSelected(l),this.model.tidy()}getSplitterBounds(e,i=!1){let n=[0,0],r=i?this.getMinSize():0,s=i?this.getMaxSize():99999,o=this.model.getRootRow(i9.MAIN_LAYOUT_ID),a=o.getRect(),l=this.model.getSplitterSize();if(this.location===iI.TOP){n[0]=this.tabHeaderRect.getBottom()+r;let e=this.tabHeaderRect.getBottom()+s;n[1]=Math.max(n[0],a.getBottom()-o.getMinHeight()-l),n[1]=Math.min(n[1],e)}else if(this.location===iI.LEFT){n[0]=this.tabHeaderRect.getRight()+r;let e=this.tabHeaderRect.getRight()+s;n[1]=Math.max(n[0],a.getRight()-o.getMinWidth()-l),n[1]=Math.min(n[1],e)}else if(this.location===iI.BOTTOM){n[1]=this.tabHeaderRect.y-r-l;let e=this.tabHeaderRect.y-s-l;n[0]=Math.min(n[1],a.y+o.getMinHeight()),n[0]=Math.max(n[0],e)}else if(this.location===iI.RIGHT){n[1]=this.tabHeaderRect.x-r-l;let e=this.tabHeaderRect.x-s-l;n[0]=Math.min(n[1],a.x+o.getMinWidth()),n[0]=Math.max(n[0],e)}return n}calculateSplit(e,i){let n=this.getSplitterBounds(i);return this.location===iI.BOTTOM||this.location===iI.RIGHT?Math.max(0,n[1]-i):Math.max(0,i-n[0])}getAttributeDefinitions(){return e.attributeDefinitions}static getAttributeDefinitions(){return e.attributeDefinitions}static createAttributeDefinitions(){let i=new iF;return i.add("type",e.TYPE,!0).setType(iW.STRING).setFixed(),i.add("selected",-1).setType(iW.NUMBER).setDescription("index of selected/visible tab in border; -1 means no tab selected"),i.add("show",!0).setType(iW.BOOLEAN).setDescription("show/hide this border"),i.add("config",void 0).setType("any").setDescription("a place to hold json config used in your own code"),i.addInherited("enableDrop","borderEnableDrop").setType(iW.BOOLEAN).setDescription("whether tabs can be dropped into this border"),i.addInherited("className","borderClassName").setType(iW.STRING).setDescription("class applied to tab button"),i.addInherited("autoSelectTabWhenOpen","borderAutoSelectTabWhenOpen").setType(iW.BOOLEAN).setDescription("whether to select new/moved tabs in border when the border is already open"),i.addInherited("autoSelectTabWhenClosed","borderAutoSelectTabWhenClosed").setType(iW.BOOLEAN).setDescription("whether to select new/moved tabs in border when the border is currently closed"),i.addInherited("size","borderSize").setType(iW.NUMBER).setDescription("size of the tab area when selected"),i.addInherited("minSize","borderMinSize").setType(iW.NUMBER).setDescription("the minimum size of the tab area"),i.addInherited("maxSize","borderMaxSize").setType(iW.NUMBER).setDescription("the maximum size of the tab area"),i.addInherited("enableAutoHide","borderEnableAutoHide").setType(iW.BOOLEAN).setDescription("hide border if it has zero tabs"),i.addInherited("enableTabScrollbar","borderEnableTabScrollbar").setType(iW.BOOLEAN).setDescription("whether to show a mini scrollbar for the tabs"),i}},i4=class e{static fromJson(i,n){let r=new e(n);for(let e of(r.borders=i.map(e=>i3.fromJson(e,n)),r.borders))r.borderMap.set(e.getLocation(),e);return r}borders;borderMap;layoutHorizontal;constructor(e){this.borders=[],this.borderMap=new Map,this.layoutHorizontal=!0}toJson(){return this.borders.map(e=>e.toJson())}getLayoutHorizontal(){return this.layoutHorizontal}getBorders(){return this.borders}getBorderMap(){return this.borderMap}forEachNode(e){for(let i of this.borders)for(let n of(e(i,0),i.getChildren()))n.forEachNode(e,1)}setPaths(){for(let e of this.borders){let i="/border/"+e.getLocation().getName();e.setPath(i);let n=0;for(let r of e.getChildren())r.setPath(i+"/t"+n),n++}}findDropTargetNode(e,i,n){for(let r of this.borders)if(r.isShowing()){let s=r.canDrop(e,i,n);if(void 0!==s)return s}}},i6=class e{_layoutId;_type;_rect;_controller;_rootRow;_maximizedTabSet;_activeTabSet;_toExportRectFunction;constructor(e,i,n){this._layoutId=e,this._type=i,this._rect=n,this._toExportRectFunction=(e,i)=>e}visitNodes(e){this.getRootRow()?.forEachNode(e,0)}isMainLayout(){return this._layoutId===i9.MAIN_LAYOUT_ID}getLayoutId(){return this._layoutId}getType(){return this._type}setType(e){this._type=e}getRect(){return this._rect}getController(){return this._controller}getWindow(){return this._controller?.getCurrentWindow()}getRootRow(){return this._rootRow}getMaximizedTabSet(){return this._maximizedTabSet}getActiveTabSet(){return this._activeTabSet}setRect(e){this._rect=e}setController(e){this._controller=e}getWindowId(){return this._controller?.getWindowId()}setRootRow(e){e?.setLayout(this),this._rootRow=e}setMaximizedTabSet(e){this._maximizedTabSet=e}setActiveTabSet(e){this._activeTabSet=e}getToExportRectFunction(){return this._toExportRectFunction}setToExportRectFunction(e){this._toExportRectFunction=e}toJson(){return"window"===this.getType()&&this.getWindow()&&this.getWindow().screenTop>-1e4&&this.setRect(new ij(this.getWindow().screenLeft,this.getWindow().screenTop,this.getWindow().outerWidth,this.getWindow().outerHeight)),{type:this.getType(),layout:this.getRootRow().toJson(),rect:"tab"===this.getType()?void 0:this.getRect().toJson()}}static fromJson(i,n,r){let s=n.getLayouts().size,o=i.rect?ij.fromJson(i.rect):new ij(50+50*s,50+50*s,600,400);o.snap(10);let a=new e(r,i.type||"window",o);return a.setRootRow(i0.fromJson(i.layout,n,a)),a}},i8=99999,i9=class e{static MAIN_LAYOUT_ID="__main_layout_id__";static attributeDefinitions=e.createAttributeDefinitions();attributes;layouts;borders;changeListeners;idMap;mainLayout;splitterSize;onAllowDrop;onCreateTabSet;constructor(){this.attributes={},this.layouts=new Map,this.borders=new i4(this),this.idMap=new Map,this.changeListeners=[],this.mainLayout=new i6(e.MAIN_LAYOUT_ID,"window",ij.empty()),this.layouts.set(e.MAIN_LAYOUT_ID,this.mainLayout),this.splitterSize=8}doAction(i){let n;switch(i.type){case iB.ADD_TAB:{let e=new iU(this,i.data.json,!0),r=this.idMap.get(i.data.toNode);(r instanceof i1||r instanceof i3||r instanceof i0)&&(r.drop(e,iI.getByName(i.data.location),i.data.index,i.data.select),n=e);break}case iB.MOVE_NODE:{let e=this.idMap.get(i.data.fromNode);if(e instanceof iU||e instanceof i1||e instanceof i0){e===this.getMaximizedTabset(e.getLayoutId())&&this.layouts.get(e.getLayoutId()).setMaximizedTabSet(void 0);let n=this.idMap.get(i.data.toNode);(n instanceof i1||n instanceof i3||n instanceof i0)&&n.drop(e,iI.getByName(i.data.location),i.data.index,i.data.select)}break}case iB.DELETE_TAB:{let e=this.idMap.get(i.data.node);e instanceof iU&&e.delete();break}case iB.DELETE_TABSET:{let e=this.idMap.get(i.data.node);if(e instanceof i1){let i=[...e.getChildren()];for(let e=0;e<i.length;e++){let n=i[e];n.isEnableClose()&&n.delete()}0===e.getChildren().length&&e.delete(),this.tidy()}break}case iB.POPOUT_TABSET:{let e=this.idMap.get(i.data.node);if(e instanceof i1){let n=e.isMaximized(),r=e.getLayout(),s=i5(),o=i.data.type||"window",a=new i6(s,o,r.getToExportRectFunction()(e.getRect(),o)),l=i0.fromJson({type:"row"},this,a);a.setRootRow(l),this.layouts.set(s,a),l.drop(e,iI.CENTER,0),n&&this.mainLayout.setMaximizedTabSet(void 0)}break}case iB.POPOUT_TAB:{let e=this.idMap.get(i.data.node);if(e instanceof iU){let n=i5(),r=e.getParent().getContentRect(),s=e.getLayout(),o=i.data.type||"window",a=new i6(n,o,s.getToExportRectFunction()(r,o)),l=i5(),c=i0.fromJson({type:"row",children:[{type:"tabset",id:l}]},this,a);a.setRootRow(c),this.layouts.set(n,a),this.idMap.get(l).drop(e,iI.CENTER,0,!0)}break}case iB.SELECT_TAB:{let e=this.idMap.get(i.data.tabNode);if(e instanceof iU){let i=e.getParent(),n=i.getChildren().indexOf(e);i instanceof i3?i.getSelected()===n?i.setSelected(-1):i.setSelected(n):i instanceof i1&&(i.getSelected()!==n&&i.setSelected(n),e.getLayout().setActiveTabSet(i))}break}case iB.SET_ACTIVE_TABSET:{let n=i.data.layoutId?i.data.layoutId:e.MAIN_LAYOUT_ID,r=this.layouts.get(n);if(void 0===i.data.tabsetNode)r.setActiveTabSet(void 0);else{let e=this.idMap.get(i.data.tabsetNode);e instanceof i1&&r.setActiveTabSet(e)}break}case iB.ADJUST_WEIGHTS:{let e=this.idMap.get(i.data.nodeId).getChildren();for(let n=0;n<e.length;n++)e[n].setWeight(i.data.weights[n]);break}case iB.ADJUST_BORDER_SPLIT:{let e=this.idMap.get(i.data.node);e instanceof i3&&e.setSize(i.data.size);break}case iB.MAXIMIZE_TOGGLE:{let n=i.data.layoutId?i.data.layoutId:e.MAIN_LAYOUT_ID,r=this.layouts.get(n),s=this.idMap.get(i.data.node);s instanceof i1&&(s===r.getMaximizedTabSet()?r.setMaximizedTabSet(void 0):(r.setMaximizedTabSet(s),r.setActiveTabSet(s)));break}case iB.UPDATE_MODEL_ATTRIBUTES:this.updateAttrs(i.data.json);break;case iB.UPDATE_NODE_ATTRIBUTES:this.idMap.get(i.data.node).updateAttrs(i.data.json);break;case iB.RENAME_TAB:{let e=this.idMap.get(i.data.node);e instanceof iU&&e.setName(i.data.text);break}case iB.CREATE_SUBLAYOUT:{let e=i5(),r=new i6(e,i.data.type||"window",ij.fromJson(i.data.rect)),s=i0.fromJson(i.data.layout,this,r);r.setRootRow(s),this.layouts.set(e,r),n=e;break}case iB.CLOSE_POPOUT:{let e=this.layouts.get(i.data.layoutId);if(e){e.setType("float");let i=this.mainLayout.getController().getDomRect();e.setRect(new ij(i.width/4,i.height/4,i.width/2,i.height/2))}break}case iB.MOVE_POPOUT_TO_FRONT:{let e=i.data.layoutId,n=this.layouts.get(e);n&&(this.layouts.delete(e),this.layouts.set(e,n))}}for(let e of(this.updateIdMap(),this.changeListeners))e(i);return n}getActiveTabset(i=e.MAIN_LAYOUT_ID){let n=this.layouts.get(i);return n&&n.getActiveTabSet()&&this.getNodeById(n.getActiveTabSet().getId())?n.getActiveTabSet():void 0}getMaximizedTabset(i=e.MAIN_LAYOUT_ID){return this.layouts.get(i).getMaximizedTabSet()}getRootRow(i=e.MAIN_LAYOUT_ID){return this.layouts.get(i).getRootRow()}isRootOrientationVertical(){return this.attributes.rootOrientationVertical}isEnableRotateBorderIcons(){return this.attributes.enableRotateBorderIcons}getBorderSet(){return this.borders}visitNodes(e){for(let[i,n]of(this.borders.forEachNode(e),this.layouts))n.getRootRow().forEachNode(e,0)}visitLayoutNodes(i,n){this.layouts.has(i)&&(i===e.MAIN_LAYOUT_ID&&this.borders.forEachNode(n),this.layouts.get(i).visitNodes(n))}getNodeById(e){return this.idMap.get(e)}getFirstTabSet(i=this.layouts.get(e.MAIN_LAYOUT_ID).getRootRow()){let n=i.getChildren()[0];return n instanceof i1?n:this.getFirstTabSet(n)}static fromJson(i){let n=new e;e.attributeDefinitions.fromJson(i.global,n.attributes),i.borders&&(n.borders=i4.fromJson(i.borders,n));let r=i.subLayouts||i.popouts;if(r)for(let e in r){let i=r[e],s=i6.fromJson(i,n,e);n.layouts.set(e,s)}return n.mainLayout.setRootRow(i0.fromJson(i.layout,n,n.mainLayout)),n.tidy(),n}toJson(){let i={};e.attributeDefinitions.toJson(i,this.attributes),this.visitNodes(e=>{e.fireEvent("save",{})});let n={};for(let[i,r]of this.layouts)i!==e.MAIN_LAYOUT_ID&&(n[i]=r.toJson());return{global:i,borders:this.borders.toJson(),layout:this.mainLayout.getRootRow().toJson(),subLayouts:n}}getSplitterSize(){return this.splitterSize}setSplitterSize(e){this.splitterSize=e}isEnableEdgeDock(){return this.attributes.enableEdgeDock}isEnableEdgeDockIndicators(){return this.attributes.enableEdgeDockIndicators}setOnAllowDrop(e){this.onAllowDrop=e}setOnCreateTabSet(e){this.onCreateTabSet=e}addChangeListener(e){this.changeListeners.push(e)}removeChangeListener(e){let i=this.changeListeners.findIndex(i=>i===e);-1!==i&&this.changeListeners.splice(i,1)}toString(){return JSON.stringify(this.toJson())}getMainLayout(){return this.mainLayout}getLayouts(){return this.layouts}sortLayouts(){let e={window:1,tab:2,float:3},i=Array.from(this.getLayouts().values()).sort((i,n)=>e[i.getType()]-e[n.getType()]);this.layouts.clear(),i.forEach(e=>this.layouts.set(e.getLayoutId(),e))}setActiveTabset(e,i){let n=this.layouts.get(i);n&&(e?n.setActiveTabSet(e):n.setActiveTabSet(void 0))}setMaximizedTabset(e,i){let n=this.layouts.get(i);n&&(e?n.setMaximizedTabSet(e):n.setMaximizedTabSet(void 0))}updateIdMap(){this.idMap.clear(),this.visitNodes(e=>{this.idMap.set(e.getId(),e)})}addNode(e){let i=e.getId();if(this.idMap.has(i))throw Error(`Error: each node must have a unique id, duplicate id:${e.getId()}`);this.idMap.set(i,e)}findDropTargetNode(i,n,r,s){let o=this.layouts.get(i).getRootRow().findDropTargetNode(i,n,r,s);return void 0===o&&i===e.MAIN_LAYOUT_ID&&(o=this.borders.findDropTargetNode(n,r,s)),o}tidy(){for(let[e,i]of this.layouts)i.getRootRow().tidy()}updateAttrs(i){e.attributeDefinitions.update(i,this.attributes)}nextUniqueId(){return"#"+i5()}getAttribute(e){return this.attributes[e]}getOnAllowDrop(){return this.onAllowDrop}getOnCreateTabSet(){return this.onCreateTabSet}static toTypescriptInterfaces(){e.attributeDefinitions.pairAttributes("RowNode",i0.getAttributeDefinitions()),e.attributeDefinitions.pairAttributes("TabSetNode",i1.getAttributeDefinitions()),e.attributeDefinitions.pairAttributes("TabNode",iU.getAttributeDefinitions()),e.attributeDefinitions.pairAttributes("BorderNode",i3.getAttributeDefinitions());let i=[];i.push(e.attributeDefinitions.toTypescriptInterface("Global",void 0)),i.push(i0.getAttributeDefinitions().toTypescriptInterface("Row",e.attributeDefinitions)),i.push(i1.getAttributeDefinitions().toTypescriptInterface("TabSet",e.attributeDefinitions)),i.push(iU.getAttributeDefinitions().toTypescriptInterface("Tab",e.attributeDefinitions)),i.push(i3.getAttributeDefinitions().toTypescriptInterface("Border",e.attributeDefinitions)),console.log(i.join("\n"))}static createAttributeDefinitions(){let e=new iF;return e.add("enableEdgeDock",!0).setType(iW.BOOLEAN).setDescription("enable docking to the edges of the layout"),e.add("enableEdgeDockIndicators",!0).setType(iW.BOOLEAN).setDescription("show the edge indicators when dragging"),e.add("rootOrientationVertical",!1).setType(iW.BOOLEAN).setDescription("the top level 'row' will layout horizontally by default, set this option true to make it layout vertically"),e.add("enableRotateBorderIcons",!0).setType(iW.BOOLEAN).setDescription("boolean indicating if tab icons should rotate with the text in the left and right borders"),e.add("tabEnableClose",!0).setType(iW.BOOLEAN),e.add("tabCloseType",1).setType("ICloseType"),e.add("tabEnablePopout",!1).setType(iW.BOOLEAN).setAlias("tabEnableFloat"),e.add("tabEnablePopoutIcon",!0).setType(iW.BOOLEAN),e.add("tabEnablePopoutFloatIcon",!1).setType(iW.BOOLEAN),e.add("tabEnablePopoutOverlay",!1).setType(iW.BOOLEAN),e.add("tabEnableDrag",!0).setType(iW.BOOLEAN),e.add("tabEnableRename",!0).setType(iW.BOOLEAN),e.add("tabContentClassName",void 0).setType(iW.STRING),e.add("tabClassName",void 0).setType(iW.STRING),e.add("tabIcon",void 0).setType(iW.STRING),e.add("tabEnableRenderOnDemand",!0).setType(iW.BOOLEAN),e.add("tabBorderWidth",-1).setType(iW.NUMBER),e.add("tabBorderHeight",-1).setType(iW.NUMBER),e.add("tabSetEnableDeleteWhenEmpty",!0).setType(iW.BOOLEAN),e.add("tabSetEnableDrop",!0).setType(iW.BOOLEAN),e.add("tabSetEnableDrag",!0).setType(iW.BOOLEAN),e.add("tabSetEnableDivide",!0).setType(iW.BOOLEAN),e.add("tabSetEnableMaximize",!0).setType(iW.BOOLEAN),e.add("tabSetEnableClose",!0).setType(iW.BOOLEAN),e.add("tabSetEnableCloseButton",!1).setType(iW.BOOLEAN),e.add("tabSetEnableSingleTabStretch",!1).setType(iW.BOOLEAN),e.add("tabSetAutoSelectTab",!0).setType(iW.BOOLEAN),e.add("tabSetEnableActiveIcon",!1).setType(iW.BOOLEAN),e.add("tabSetClassNameTabStrip",void 0).setType(iW.STRING),e.add("tabSetEnableTabStrip",!0).setType(iW.BOOLEAN),e.add("tabSetEnableTabWrap",!1).setType(iW.BOOLEAN),e.add("tabSetTabLocation","top").setType("ITabLocation"),e.add("tabMinWidth",1).setType(iW.NUMBER),e.add("tabMinHeight",1).setType(iW.NUMBER),e.add("tabSetMinWidth",1).setType(iW.NUMBER),e.add("tabSetMinHeight",1).setType(iW.NUMBER),e.add("tabMaxWidth",i8).setType(iW.NUMBER),e.add("tabMaxHeight",i8).setType(iW.NUMBER),e.add("tabSetMaxWidth",i8).setType(iW.NUMBER),e.add("tabSetMaxHeight",i8).setType(iW.NUMBER),e.add("tabSetEnableTabScrollbar",!1).setType(iW.BOOLEAN),e.add("borderSize",200).setType(iW.NUMBER),e.add("borderMinSize",1).setType(iW.NUMBER),e.add("borderMaxSize",i8).setType(iW.NUMBER),e.add("borderEnableDrop",!0).setType(iW.BOOLEAN),e.add("borderAutoSelectTabWhenOpen",!0).setType(iW.BOOLEAN),e.add("borderAutoSelectTabWhenClosed",!1).setType(iW.BOOLEAN),e.add("borderClassName",void 0).setType(iW.STRING),e.add("borderEnableAutoHide",!1).setType(iW.BOOLEAN),e.add("borderEnableTabScrollbar",!1).setType(iW.BOOLEAN),e}},i7={width:"1em",height:"1em",display:"flex",alignItems:"center"},ne=()=>(0,iN.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",style:i7,viewBox:"0 0 24 24",children:[(0,iN.jsx)("path",{fill:"none",d:"M0 0h24v24H0z"}),(0,iN.jsx)("path",{stroke:"var(--color-icon)",fill:"var(--color-icon)",d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})]}),nt=e=>{let{controller:i,show:n}=e;return(0,iN.jsx)("div",{className:i.getClassName(iP.FLEXLAYOUT__LAYOUT_OVERLAY),style:{display:n?"flex":"none"}})},ni=((sP={}).Close_Tab="Close",sP.Close_Tabset="Close tab set",sP.Active_Tabset="Active tab set",sP.Move_Tabset="Move tab set",sP.Move_Tabs="Move tabs(?)",sP.Maximize="Maximize tab set",sP.Restore="Restore tab set",sP.Popout_Tab="Popout selected tab",sP.Popout_Tab_Float="Float selected tab",sP.Overflow_Menu_Tooltip="Hidden tabs",sP.Error_rendering_component="Error rendering component",sP.Error_rendering_component_retry="Retry",sP),nn=e=>{let{controller:i,tabNode:n}=e,r=i.getClassName,s=r(iP.FLEXLAYOUT__TAB_BUTTON_STAMP),o=iq(i,n),a=o.content?(0,iN.jsx)("div",{className:r(iP.FLEXLAYOUT__TAB_BUTTON_CONTENT),children:o.content}):n.getNameForOverflowMenu(),l=o.leading?(0,iN.jsx)("div",{className:r(iP.FLEXLAYOUT__TAB_BUTTON_LEADING),children:o.leading}):null;return(0,iN.jsxs)("div",{className:s,title:n.getHelpText(),children:[l,a]})};function nr(e,i,n,r,s){let o=s.getRootDiv(),a=s.getClassName,l=e.ownerDocument,c=e.getBoundingClientRect(),h=o?.getBoundingClientRect()??new DOMRect(0,0,100,100),d=l.createElement("div");d.className=a(iP.FLEXLAYOUT__POPUP_MENU_CONTAINER),c.left<h.left+h.width/2?d.style.left=c.left-h.left+"px":d.style.right=h.right-c.right+"px",c.top<h.top+h.height/2?d.style.top=c.top-h.top+"px":d.style.bottom=h.bottom-c.bottom+"px",s.showOverlayOnAllWindows(!0),o&&o.appendChild(d);let u=()=>{s.hideControlInPortal(),s.showOverlayOnAllWindows(!1),o&&o.removeChild(d),d.removeEventListener("pointerdown",p),l.removeEventListener("pointerdown",f)},p=e=>{e.stopPropagation()},f=e=>{u()};d.addEventListener("pointerdown",p),l.addEventListener("pointerdown",f),s.showControlInPortal((0,iN.jsx)(ns,{currentDocument:l,parentNode:i,onSelect:r,onHide:u,items:n,classNameMapper:a,controller:s}),d)}var ns=e=>{let{parentNode:i,items:n,onHide:r,onSelect:s,classNameMapper:o,controller:a}=e,l=(0,iA.useRef)(null);(0,iA.useEffect)(()=>{l.current&&l.current.focus()},[]);let c=e=>{a.getDragDropManager().clearDragMain()},h=n.map((e,n)=>{let l=o(iP.FLEXLAYOUT__POPUP_MENU_ITEM);return i.getSelected()===e.index&&(l+=" "+o(iP.FLEXLAYOUT__POPUP_MENU_ITEM__SELECTED)),(0,iN.jsx)("div",{className:l,"data-layout-path":"/popup-menu/tb"+n,onClick:i=>{s(e),r(),i.stopPropagation()},draggable:!0,onDragStart:i=>{var n;return n=e.node,void(i.stopPropagation(),a.getDragDropManager().setDragNode(i.nativeEvent,n),setTimeout(()=>{r()},0))},onDragEnd:c,title:e.node.getHelpText(),children:(0,iN.jsx)(nn,{tabNode:e.node,controller:a})},e.index)});return(0,iN.jsx)("div",{className:o(iP.FLEXLAYOUT__POPUP_MENU),ref:l,tabIndex:0,onKeyDown:e=>{"Escape"===e.key&&r()},"data-layout-path":"/popup-menu",children:h})},no=((sB={})[sB.Visible=1]="Visible",sB[sB.Always=2]="Always",sB[sB.Selected=3]="Selected",sB),na=e=>{let{controller:i,tabNode:n,selected:r,path:s}=e,o=iA.useRef(null),a=iA.useRef(null),l=i.getIcons();iA.useLayoutEffect(()=>{n.setTabRect(i.getBoundingClientRect(o.current)),i.getEditingTab()===n&&a.current.select()});let c=e=>{e.target!==a.current&&(i.getCurrentDocument().body.removeEventListener("pointerdown",c),i.setEditingTab(void 0))},h=i.getClassName,d=n.getParent(),u=d.isEnableSingleTabStretch()&&1===d.getChildren().length,p=u?iP.FLEXLAYOUT__TAB_BUTTON_STRETCH:iP.FLEXLAYOUT__TAB_BUTTON,f=h(p);f+=" "+h(p+"_"+d.getTabLocation()),u||(r?f+=" "+h(p+"--selected"):f+=" "+h(p+"--unselected")),void 0!==n.getClassName()&&(f+=" "+n.getClassName());let m=iq(i,n),g=m.content?(0,iN.jsx)("div",{className:h(iP.FLEXLAYOUT__TAB_BUTTON_CONTENT),children:m.content}):null,v=m.leading?(0,iN.jsx)("div",{className:h(iP.FLEXLAYOUT__TAB_BUTTON_LEADING),children:m.leading}):null;if(i.getEditingTab()===n&&(g=(0,iN.jsx)("input",{ref:a,className:h(iP.FLEXLAYOUT__TAB_BUTTON_TEXTBOX),"data-layout-path":s+"/textbox",type:"text",autoFocus:!0,defaultValue:n.getName(),onKeyDown:e=>{"Escape"===e.code?i.setEditingTab(void 0):("Enter"===e.code||"NumpadEnter"===e.code)&&(i.setEditingTab(void 0),i.doAction(iB.renameTab(n.getId(),e.target.value)))},onPointerDown:e=>{e.stopPropagation()}})),n.isCloseable()&&!u){let e=i.i18nName(ni.Close_Tab);m.buttons.push((0,iN.jsx)("div",{"data-layout-path":s+"/button/close",title:e,className:h(iP.FLEXLAYOUT__TAB_BUTTON_TRAILING),onPointerDown:e=>{e.stopPropagation()},onClick:e=>{let s;s=n.getCloseType(),(r||s===no.Always||s===no.Visible&&window.matchMedia&&window.matchMedia("(hover: hover) and (pointer: fine)").matches||0)&&(i.doAction(iB.deleteTab(n.getId())),e.stopPropagation())},children:"function"==typeof l.close?l.close(n):l.close},"close"))}return(0,iN.jsxs)("div",{ref:o,"data-layout-path":s,className:f,onClick:()=>{i.doAction(iB.selectTab(n.getId()))},onAuxClick:e=>{iY(e)&&i.auxMouseClick(n,e)},onContextMenu:e=>{i.showContextMenu(n,e)},title:n.getHelpText(),draggable:!0,onDragStart:e=>{n.isEnableDrag()?(e.stopPropagation(),i.getDragDropManager().setDragNode(e.nativeEvent,n)):e.preventDefault()},onDragEnd:e=>{i.getDragDropManager().clearDragMain()},onDoubleClick:e=>{n.isEnableRename()&&(i.setEditingTab(n),i.getCurrentDocument().body.addEventListener("pointerdown",c),e.stopPropagation())},children:[v,g,m.buttons]})},nl=(e,i,n,r,s,o)=>{let[a,l]=iA.useState([]),[c,h]=iA.useState(!1),[d,u]=iA.useState(!1),p=iA.useRef(null),f=iA.useRef(!1),m=iA.useRef(void 0),g=iA.useRef([]),v=iA.useRef(0),y=iA.useRef(!1);g.current=a,iA.useLayoutEffect(()=>{r.current&&D(0)},[i.getId()]),iA.useLayoutEffect(()=>{f.current=!1},[i.getSelectedNode(),i.getRect().width,i.getRect().height]),iA.useLayoutEffect(()=>{T(),!1===f.current&&function(){let n=i.getSelectedNode();if(n&&r.current){let i=e.getBoundingClientRect(r.current),s=n.getTabRect(),o=N(i)-N(s);o>0||A(s)>A(i)?(D(L(r.current)-o),y.current=!0):(o=M(s)-M(i))>0&&(D(L(r.current)+o),y.current=!0)}}(),b(),w()}),iA.useEffect(()=>(p.current?.addEventListener("wheel",_,{passive:!1}),()=>{p.current?.removeEventListener("wheel",_)}),[p.current]);let _=e=>{e.preventDefault()},b=()=>{if(r.current&&s.current){let e=r.current,i=s.current,o=O(e),a=R(e),l=L(e);if(a>o&&a>0){let e=o*o/a,r=0;e<20&&(r=20-e,e=20);let s=l*(o-r)/a;n===iL.HORZ?(i.style.width=e+"px",i.style.left=s+"px"):(i.style.height=e+"px",i.style.top=s+"px"),i.style.display="block"}else i.style.display="none";n===iL.HORZ?i.style.bottom="0px":i.style.right="0px"}},w=()=>{let e=E().length>0;e!==c&&h(e),void 0===m.current&&(m.current=setTimeout(()=>{var e,i;let n=E();e=n,i=g.current,e.length===i.length&&e.every((e,n)=>e===i[n])||l(n),m.current=void 0},100))},S=(e,i)=>{if(r.current&&s.current){let o,a=r.current,l=s.current,c=O(a),h=R(a),d=O(l),u=a.getBoundingClientRect();o=Math.max(0,Math.min(h-d,o=n===iL.HORZ?e-u.x-v.current:i-u.y-v.current)),c>0&&D(o*h/c)}},k=()=>{},C=()=>{},T=()=>{if(r.current){let e=O(r.current.firstElementChild)+10*!!d>O(r.current);e!==d&&u(e)}},E=()=>{let e=[];if(r.current){let i=r.current,n=i.getBoundingClientRect(),s=N(n)-1,a=M(n)+1,l=i.firstElementChild,c=0;Array.from(l.children).forEach(i=>{let n=i.getBoundingClientRect();i.classList.contains(o)&&((N(n)<s||M(n)>a)&&e.push(c),c++)})}return e},N=e=>n===iL.HORZ?e.x:e.y,M=e=>n===iL.HORZ?e.right:e.bottom,O=e=>n===iL.HORZ?e.clientWidth:e.clientHeight,A=e=>n===iL.HORZ?e.width:e.height,R=e=>n===iL.HORZ?e.scrollWidth:e.scrollHeight,D=e=>{n===iL.HORZ?r.current.scrollLeft=e:r.current.scrollTop=e},L=e=>n===iL.HORZ?e.scrollLeft:e.scrollTop;return{selfRef:p,userControlledPositionRef:f,onScroll:()=>{y.current||(f.current=!0),y.current=!1,b(),w()},onScrollPointerDown:e=>{e.stopPropagation(),s.current.setPointerCapture(e.pointerId);let i=s.current.getBoundingClientRect();n===iL.HORZ?v.current=e.clientX-i.x:v.current=e.clientY-i.y,iG(e.currentTarget.ownerDocument,e,S,k,C)},hiddenTabs:a,onMouseWheel:e=>{if(r.current){let n;if(0!==i.getChildren().length&&Math.abs(e.deltaY)>0){n=-e.deltaY,1===e.deltaMode&&(n*=40);let i=L(r.current)-n;D(Math.max(0,Math.min(R(r.current)-O(r.current),i))),e.stopPropagation()}}},isDockStickyButtons:d,isShowHiddenTabs:c}},nc=e=>{let{tabsetNode:i,controller:n}=e,r=iA.useRef(null),s=iA.useRef(null),o=iA.useRef(null),a=iA.useRef(null),l=iA.useRef(null),c=iA.useRef(null),h=iA.useRef(null),d=n.getIcons();iA.useLayoutEffect(()=>{i.setRect(n.getBoundingClientRect(u.current)),r.current&&i.setTabStripRect(n.getBoundingClientRect(r.current));let e=n.getBoundingClientRect(a.current);i.getContentRect().equalsWhenRounded(e)||isNaN(e.x)||(i.setContentRect(e),n.setReLayout(!0))});let{selfRef:u,userControlledPositionRef:p,onScroll:f,onScrollPointerDown:m,hiddenTabs:g,onMouseWheel:v,isDockStickyButtons:y,isShowHiddenTabs:_}=nl(n,i,iL.HORZ,o,s,n.getClassName(iP.FLEXLAYOUT__TAB_BUTTON)),b=e=>{let r=n.getShowOverflowMenu(),s=g.map(e=>({index:e,node:i.getChildren()[e]}));void 0!==r?r(i,e,s,w):nr(c.current,i,s,w,n),e.stopPropagation()},w=e=>{n.doAction(iB.selectTab(e.node.getId())),p.current=!1},S=e=>{n.getEditingTab()?e.preventDefault():i.isEnableDrag()?(e.stopPropagation(),n.getDragDropManager().setDragNode(e.nativeEvent,i)):e.preventDefault()},k=e=>{iY(e)||n.doAction(iB.setActiveTabset(i.getId(),n.getLayoutId()))},C=e=>{iY(e)&&n.auxMouseClick(i,e)},T=e=>{n.showContextMenu(i,e)},E=e=>{e.stopPropagation()},N=e=>{i.canMaximize()&&n.maximize(i),e.stopPropagation()},M=e=>{n.doAction(iB.deleteTabset(i.getId())),e.stopPropagation()},O=e=>{n.doAction(iB.deleteTab(i.getChildren()[0].getId())),e.stopPropagation()},A=e=>{void 0!==j&&n.doAction(iB.popoutTab(j.getId(),"window")),e.stopPropagation()},R=e=>{void 0!==j&&n.doAction(iB.popoutTab(j.getId(),"float")),e.stopPropagation()},D=e=>{i.canMaximize()&&n.maximize(i)},L=n.getClassName,j=i.getSelectedNode(),I=i.getPath(),P=(()=>{let e=[],r=!1;if(i.isEnableTabStrip()){let s=i.isEnableSingleTabStretch()&&1===i.getChildren().length;for(let o=0;o<i.getChildren().length;o++){let a=i.getChildren()[o],l=i.getSelected()===o,c=L(iP.FLEXLAYOUT__TABSET_TAB_SPACER);0!==o&&(c+=" "+L(iP.FLEXLAYOUT__TABSET_TAB_DIVIDER)),i.isEnableTabWrap()||s||(l?c+=" "+L(iP.FLEXLAYOUT__TABSET_TAB_DIVIDER_SELECTED_BEFORE):r&&(c+=" "+L(iP.FLEXLAYOUT__TABSET_TAB_DIVIDER_SELECTED_AFTER))),e.push((0,iN.jsx)("div",{className:c,children:(0,iN.jsx)("div",{className:L(iP.FLEXLAYOUT__TABSET_TAB_DIVIDER_INNER)})},"divider"+o)),e.push((0,iN.jsx)(na,{controller:n,tabNode:a,path:I+"/tb"+o,selected:l},a.getId())),o===i.getChildren().length-1&&(c=L(iP.FLEXLAYOUT__TABSET_TAB_SPACER),i.isEnableTabWrap()||s||!l||(c+=" "+L(iP.FLEXLAYOUT__TABSET_TAB_DIVIDER_SELECTED_AFTER)),e.push((0,iN.jsx)("div",{className:c,children:(0,iN.jsx)("div",{className:L(iP.FLEXLAYOUT__TABSET_TAB_DIVIDER_INNER)})},"divider"+(o+1)))),r=l}}return e})(),{leading:B,buttonbar:z}=(e=>{let r,s=[],o=[],a={leading:r,stickyButtons:s,buttons:o,overflowPosition:void 0};n.customizeTabSet(i,a),r=a.leading,s=a.stickyButtons,o=a.buttons;let u=i.isEnableSingleTabStretch()&&1===i.getChildren().length,p=u&&i.getChildren()[0].isCloseable()||i.isCloseable();if(p=p&&i.isEnableCloseButton(),void 0===a.overflowPosition&&(a.overflowPosition=s.length),s.length>0&&(!i.isEnableTabWrap()&&(y||u)?o=[...s,...o]:e.push((0,iN.jsx)("div",{ref:h,onPointerDown:E,onDragStart:e=>{e.preventDefault()},className:L(iP.FLEXLAYOUT__TAB_TOOLBAR_STICKY_BUTTONS_CONTAINER),children:s},"sticky_buttons_container"))),!i.isEnableTabWrap()&&_){let e,r=n.i18nName(ni.Overflow_Menu_Tooltip);if("function"==typeof d.more){let n=g.map(e=>({index:e,node:i.getChildren()[e]}));e=d.more(i,n)}else e=(0,iN.jsxs)(iN.Fragment,{children:[d.more,(0,iN.jsx)("div",{className:L(iP.FLEXLAYOUT__TAB_BUTTON_OVERFLOW_COUNT),children:g.length>0?g.length:""})]});o.splice(Math.min(a.overflowPosition,o.length),0,(0,iN.jsx)("button",{"data-layout-path":I+"/button/overflow",ref:c,className:L(iP.FLEXLAYOUT__TAB_TOOLBAR_BUTTON)+" "+L(iP.FLEXLAYOUT__TAB_BUTTON_OVERFLOW),title:r,onClick:b,onPointerDown:E,children:e},"overflowbutton"))}if(void 0!==j){if(j.isEnablePopoutFloatIcon()){let e=n.i18nName(ni.Popout_Tab_Float);o.push((0,iN.jsx)("button",{"data-layout-path":I+"/button/popout-float",title:e,className:L(iP.FLEXLAYOUT__TAB_TOOLBAR_BUTTON)+" "+L(iP.FLEXLAYOUT__TAB_TOOLBAR_BUTTON_FLOAT),onClick:R,onPointerDown:E,children:"function"==typeof d.popoutFloat?d.popoutFloat(j):d.popoutFloat},"popout-float"))}if(n.isSupportsPopout()&&j.isAllowedInWindow()&&j.isEnablePopout()){let e=n.i18nName(ni.Popout_Tab);o.push((0,iN.jsx)("button",{"data-layout-path":I+"/button/popout",title:e,className:L(iP.FLEXLAYOUT__TAB_TOOLBAR_BUTTON)+" "+L(iP.FLEXLAYOUT__TAB_TOOLBAR_BUTTON_FLOAT),onClick:A,onPointerDown:E,children:"function"==typeof d.popout?d.popout(j):d.popout},"popout"))}}if(i.canMaximize()){let e=n.i18nName(ni.Restore),r=n.i18nName(ni.Maximize);o.push((0,iN.jsx)("button",{"data-layout-path":I+"/button/max",title:i.isMaximized()?e:r,className:L(iP.FLEXLAYOUT__TAB_TOOLBAR_BUTTON)+" "+L(iP.FLEXLAYOUT__TAB_TOOLBAR_BUTTON_+(i.isMaximized()?"max":"min")),onClick:N,onPointerDown:E,children:i.isMaximized()?"function"==typeof d.restore?d.restore(i):d.restore:"function"==typeof d.maximize?d.maximize(i):d.maximize},"max"))}if(!i.isMaximized()&&p){let e=u?n.i18nName(ni.Close_Tab):n.i18nName(ni.Close_Tabset);o.push((0,iN.jsx)("button",{"data-layout-path":I+"/button/close",title:e,className:L(iP.FLEXLAYOUT__TAB_TOOLBAR_BUTTON)+" "+L(iP.FLEXLAYOUT__TAB_TOOLBAR_BUTTON_CLOSE),onClick:u?O:M,onPointerDown:E,children:"function"==typeof d.closeTabset?d.closeTabset(i):d.closeTabset},"close"))}if(i.isActive()&&i.isEnableActiveIcon()){let e=n.i18nName(ni.Active_Tabset);o.push((0,iN.jsx)("div",{"data-layout-path":I+"/button/active",title:e,className:L(iP.FLEXLAYOUT__TAB_TOOLBAR_ICON),children:"function"==typeof d.activeTabset?d.activeTabset(i):d.activeTabset},"active"))}return{leading:r,buttonbar:(0,iN.jsx)("div",{ref:l,className:L(iP.FLEXLAYOUT__TAB_TOOLBAR),onPointerDown:E,onDragStart:e=>{e.preventDefault()},children:o},"buttonbar")}})(P),F=(e=>{let r;if(0===i.getChildren().length){let e=n.getTabSetPlaceHolderCallback();e&&(r=e(i))}let s=(0,iN.jsx)("div",{ref:a,className:L(iP.FLEXLAYOUT__TABSET_CONTENT),children:r});return"top"===i.getTabLocation()?(0,iN.jsxs)(iN.Fragment,{children:[e,s]}):(0,iN.jsxs)(iN.Fragment,{children:[s,e]})})(((e,n,a)=>{let l,c,h=L(iP.FLEXLAYOUT__TABSET_TABBAR_OUTER);void 0!==i.getClassNameTabStrip()&&(h+=" "+i.getClassNameTabStrip()),h+=" "+iP.FLEXLAYOUT__TABSET_TABBAR_OUTER_+i.getTabLocation(),i.isActive()&&(h+=" "+L(iP.FLEXLAYOUT__TABSET_SELECTED)),i.isMaximized()&&(h+=" "+L(iP.FLEXLAYOUT__TABSET_MAXIMIZED));let d=i.isEnableSingleTabStretch()&&1===i.getChildren().length;if(d){let e=i.getChildren()[0];void 0!==e.getTabSetClassName()&&(h+=" "+e.getTabSetClassName())}if(n&&(l=(0,iN.jsx)("div",{className:L(iP.FLEXLAYOUT__TABSET_LEADING),children:n})),i.isEnableTabWrap())i.isEnableTabStrip()&&(c=(0,iN.jsxs)("div",{className:h,style:{flexWrap:"wrap",gap:"1px",marginTop:"2px"},ref:r,"data-layout-path":I+"/tabstrip",onPointerDown:k,onDoubleClick:D,onContextMenu:T,onClick:C,onAuxClick:C,draggable:!0,onDragStart:S,children:[l,e,(0,iN.jsx)("div",{style:{flexGrow:1}}),a]}));else if(i.isEnableTabStrip()){let n;i.isEnableTabScrollbar()&&(n=(0,iN.jsx)("div",{ref:s,className:L(iP.FLEXLAYOUT__MINI_SCROLLBAR),onPointerDown:m})),c=(0,iN.jsxs)("div",{className:h,ref:r,"data-layout-path":I+"/tabstrip",onPointerDown:k,onDoubleClick:D,onContextMenu:T,onClick:C,onAuxClick:C,draggable:!0,onWheel:v,onDragStart:S,children:[l,(0,iN.jsxs)("div",{className:L(iP.FLEXLAYOUT__MINI_SCROLLBAR_CONTAINER),children:[(0,iN.jsx)("div",{ref:o,className:L(iP.FLEXLAYOUT__TABSET_TABBAR_INNER)+" "+L(iP.FLEXLAYOUT__TABSET_TABBAR_INNER_+i.getTabLocation()),style:{overflowX:"auto",overflowY:"hidden"},onScroll:f,children:(0,iN.jsx)("div",{style:{width:d?"100%":"none"},className:L(iP.FLEXLAYOUT__TABSET_TABBAR_INNER_TAB_CONTAINER)+" "+L(iP.FLEXLAYOUT__TABSET_TABBAR_INNER_TAB_CONTAINER_+i.getTabLocation()),children:e})}),n]}),a]})}return c})(P,B,z)),W={flexGrow:Math.max(1,1e3*i.getWeight()),minWidth:i.getMinWidth(),minHeight:i.getMinHeight(),maxWidth:i.getMaxWidth(),maxHeight:i.getMaxHeight()};void 0===i.getModel().getMaximizedTabset(n.getLayoutId())||i.isMaximized()||(W.display="none");let H=(0,iN.jsx)("div",{ref:u,className:L(iP.FLEXLAYOUT__TABSET_CONTAINER),style:W,children:(0,iN.jsx)("div",{className:L(iP.FLEXLAYOUT__TABSET),"data-layout-path":I,children:F})});return i.isMaximized()&&n.getMainElement()?(0,iR.createPortal)((0,iN.jsx)("div",{style:{position:"absolute",display:"flex",top:0,left:0,bottom:0,right:0},children:H}),n.getMainElement()):H},nh=e=>{let{controller:i,node:n,index:r,horizontal:s}=e,o=iA.useRef(null),a=iA.useRef(null),l=iA.useRef([]),c=iA.useRef(void 0),h=iA.useRef(void 0),d=iA.useRef(0),u=iA.useRef(0),p=iA.useRef({initialSizes:[],sum:0,startPosition:0});iA.useEffect(()=>(o.current?.addEventListener("touchstart",f,{passive:!1}),a.current?.addEventListener("touchstart",f,{passive:!1}),()=>{o.current?.removeEventListener("touchstart",f),a.current?.removeEventListener("touchstart",f)}),[]);let f=e=>{e.preventDefault(),e.stopImmediatePropagation()},m=()=>{let e=i.getRootDiv();e&&c.current&&e.removeChild(c.current),c.current=void 0},g=(e,r)=>{if(c.current){let s=i.getDomRect();s&&(n.getOrientation()===iL.VERT?c.current.style.top=_(r-s.y-u.current)+"px":c.current.style.left=_(e-s.x-d.current)+"px",i.isRealtimeResize()&&y(!0))}},v=()=>{if(c.current){y(!1);let e=i.getRootDiv();e&&c.current&&e.removeChild(c.current),c.current=void 0}iK(!0,i.getCurrentDocument())},y=e=>{if(c.current){let e;if(e=n.getOrientation()===iL.VERT?c.current.offsetTop:c.current.offsetLeft,n instanceof i3){let r=n.calculateSplit(n,e);i.doAction(iB.adjustBorderSplit(n.getId(),r))}else{let s=p.current,o=n.calculateSplit(r,e,s.initialSizes,s.sum,s.startPosition);i.doAction(iB.adjustWeights(n.getId(),o))}}},_=e=>{let i=l.current,n=e;return e<i[0]&&(n=i[0]),e>i[1]&&(n=i[1]),n},b=i.getClassName,w={cursor:s?"ew-resize":"ns-resize",flexDirection:s?"column":"row"},S=b(iP.FLEXLAYOUT__SPLITTER)+" "+b(iP.FLEXLAYOUT__SPLITTER_+n.getOrientation().getName());return n instanceof i3?S+=" "+b(iP.FLEXLAYOUT__SPLITTER_BORDER):void 0!==n.getModel().getMaximizedTabset(i.getLayoutId())&&(w.display="none"),iV()||(w["--splitter-active-size"]="30px"),(0,iN.jsx)("div",{className:S,style:w,ref:o,"data-layout-path":n.getPath()+"/s"+(r-1),onPointerDown:e=>{e.stopPropagation(),n instanceof i0&&(p.current=n.getSplitterInitials(r)),iK(!1,i.getCurrentDocument()),iG(e.currentTarget.ownerDocument,e,g,v,m),l.current=n.getSplitterBounds(r,!0);let a=i.getRootDiv();c.current=i.getCurrentDocument().createElement("div"),c.current.style.flexDirection=s?"row":"column",c.current.className=i.getClassName(iP.FLEXLAYOUT__SPLITTER_DRAG)+(n instanceof i3?" "+i.getClassName(iP.FLEXLAYOUT__SPLITTER_BORDER):""),c.current.style.cursor=n.getOrientation()===iL.VERT?"ns-resize":"ew-resize",h.current=i.getCurrentDocument().createElement("div"),h.current.className=b(iP.FLEXLAYOUT__SPLITTER_HANDLE)+" "+(s?b(iP.FLEXLAYOUT__SPLITTER_HANDLE_HORZ):b(iP.FLEXLAYOUT__SPLITTER_HANDLE_VERT)),c.current.appendChild(h.current);let f=o.current.getBoundingClientRect(),y=new ij(f.x-i.getDomRect().x,f.y-i.getDomRect().y,f.width,f.height);d.current=e.clientX-f.x,u.current=e.clientY-f.y,y.positionElement(c.current),a&&a.appendChild(c.current)},children:(0,iN.jsx)("div",{className:b(iP.FLEXLAYOUT__SPLITTER_HANDLE)+" "+(s?b(iP.FLEXLAYOUT__SPLITTER_HANDLE_HORZ):b(iP.FLEXLAYOUT__SPLITTER_HANDLE_VERT))})})},nd=e=>{let{controller:i,rowNode:n}=e,r=iA.useRef(null),s=n.getOrientation()===iL.HORZ;iA.useLayoutEffect(()=>{n.setRect(i.getBoundingClientRect(r.current))});let o=[],a=0;for(let e of n.getChildren())a>0&&o.push((0,iN.jsx)(nh,{controller:i,node:n,index:a,horizontal:s},"splitter"+a)),e instanceof i0?o.push((0,iN.jsx)(nd,{controller:i,rowNode:e},e.getId())):e instanceof i1&&o.push((0,iN.jsx)(nc,{controller:i,tabsetNode:e},e.getId())),a++;let l={flexGrow:Math.max(1,1e3*n.getWeight()),minWidth:n.getMinWidth(),minHeight:n.getMinHeight(),maxWidth:n.getMaxWidth(),maxHeight:n.getMaxHeight()};return s?l.flexDirection="row":l.flexDirection="column",(0,iN.jsx)("div",{ref:r,className:i.getClassName(iP.FLEXLAYOUT__ROW),style:l,children:o})},nu=e=>{let{controller:i,selected:n,tabNode:r}=e,s=iA.useRef(null),o=iA.useRef(!0),a=r.getParent(),l=a.getContentRect();iA.useLayoutEffect(()=>{let e=()=>{r.saveScrollPosition()},n=r.getMoveableElement();return n&&(s.current.appendChild(n),n.addEventListener("scroll",e)),s.current.addEventListener("pointerdown",c),()=>{s.current&&s.current.removeEventListener("pointerdown",c),n&&(r.isEnableWindowReMount()||i.getMainController()?.getMoveablesDiv()?.appendChild(n),n.removeEventListener("scroll",e)),r.setVisible(!1)}},[r.getMoveableElement()]),iA.useEffect(()=>{r.isSelected()&&o.current&&(r.restoreScrollPosition(),o.current=!1)});let c=()=>{let e=r.getParent();e instanceof i1&&!e.isActive()&&i.doAction(iB.setActiveTabset(e.getId(),i.getLayoutId()))};r.setRect(l);let h=i.getClassName,d={};l.styleWithPosition(d);let u=null;if(n){if(r.setVisible(!0),document.hidden&&r.isEnablePopoutOverlay()){let e={};l.styleWithPosition(e),u=(0,iN.jsx)("div",{style:e,className:h(iP.FLEXLAYOUT__TAB_OVERLAY)})}}else d.display="none",r.setVisible(!1);a instanceof i1&&void 0!==r.getModel().getMaximizedTabset(i.getLayoutId())&&!a.isMaximized()&&(d.display="none"),a instanceof i3&&!a.isShowing()&&(d.display="none");let p=h(iP.FLEXLAYOUT__TAB);return a instanceof i3&&(p+=" "+h(iP.FLEXLAYOUT__TAB_BORDER),p+=" "+h(iP.FLEXLAYOUT__TAB_BORDER_+a.getLocation().getName())),void 0!==r.getContentClassName()&&(p+=" "+r.getContentClassName()),(0,iN.jsxs)(iN.Fragment,{children:[u,(0,iN.jsx)("div",{ref:s,style:d,className:p,"data-layout-path":r.getPath()})]})},np=class extends iA.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0}}componentDidCatch(e,i){console.debug(e),console.debug(i)}retry=()=>{this.setState({hasError:!1})};render(){return this.state.hasError?(0,iN.jsx)("div",{className:iP.FLEXLAYOUT__ERROR_BOUNDARY_CONTAINER,children:(0,iN.jsx)("div",{className:iP.FLEXLAYOUT__ERROR_BOUNDARY_CONTENT,children:(0,iN.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:[this.props.message,(0,iN.jsx)("p",{children:(0,iN.jsx)("button",{onClick:this.retry,children:this.props.retryText})})]})})}):this.props.children}},nf=iA.memo(({controller:e,tabNode:i})=>{let n;return nf.displayName="TabContentRenderer",i.getComponent()?n=e.getFactory()(i):i.getSubLayoutId()&&(n=(0,iN.jsxs)("div",{className:e.getClassName(iP.FLEXLAYOUT__TAB_LAYOUT_CONTAINER),children:[(0,iN.jsx)(nM,{...e.getProps(),layoutId:i.getSubLayoutId(),mainLayoutController:e.getMainController()}),";"]})),(0,iN.jsx)(np,{message:e.i18nName(ni.Error_rendering_component),retryText:e.i18nName(ni.Error_rendering_component_retry),children:n})},function(e,i){return!(i.visible&&(e.windowId!==i.windowId||e.fullRedrawRevision!==i.fullRedrawRevision||e.parentRedrawRevision!==i.parentRedrawRevision||void 0!==i.tabNode.getSubLayoutId()))}),nm=class e{static dragState=void 0;_controller;_dragEnterCount=0;_dragging=!1;_active=!1;_dropInfo;_outlineDiv;_mainController;constructor(e){this._controller=e,this._mainController=e.getMainController()}addTabWithDragAndDrop(i,n,r){let s=iU.fromJson(n,this._controller.getModel(),!1);e.dragState=new nv(this._controller.getMainController(),ng.Add,s,n,r)}moveTabWithDragAndDrop(e,i){this.setDragNode(e,i)}setDragNode=(i,n)=>{if(e.dragState=new nv(this._controller.getMainController(),ng.Internal,n,void 0,void 0),i.dataTransfer.setData("text/plain","--flexlayout--"),i.dataTransfer.effectAllowed="copyMove",i.dataTransfer.dropEffect="move",this._dragEnterCount=0,n instanceof i1){let e=!1,r=this._controller.i18nName(ni.Move_Tabset);if(n.getChildren().length>0&&(r=this._controller.i18nName(ni.Move_Tabs).replace("?",String(n.getChildren().length))),this._controller.getProps().onRenderDragRect){let s=this._controller.getProps().onRenderDragRect(r,n,void 0);s&&(this.setDragComponent(i,s,10,10),e=!0)}e||this.setDragComponent(i,r,10,10)}else{let e=i.target;if(e&&"function"==typeof e.getBoundingClientRect){let r=e.getBoundingClientRect(),s=i.clientX-r.left,o=i.clientY-r.top,a=n?.getParent(),l=a instanceof i3&&a.getOrientation()===iL.HORZ,c=l?10:s,h=l?10:o,d=!1;if(this._controller.getProps().onRenderDragRect){let e=(0,iN.jsx)(nn,{controller:this._controller,tabNode:n},n.getId()),r=this._controller.getProps().onRenderDragRect(e,n,void 0);r&&(this.setDragComponent(i,r,c,h),d=!0)}if(!d){let e;!(e=navigator.userAgent).includes("Safari")||e.includes("Chrome")||e.includes("Chromium")?i.dataTransfer.setDragImage(n.getTabStamp(),c,h):this.setDragComponent(i,(0,iN.jsx)(nn,{tabNode:n,controller:this._controller}),c,h)}}}};setDragComponent(e,i,n,r){let s=(0,iN.jsx)("div",{style:{position:"unset"},className:this._controller.getClassName(iP.FLEXLAYOUT__LAYOUT)+" "+this._controller.getClassName(iP.FLEXLAYOUT__DRAG_RECT),children:i});this._controller.getModel().sortLayouts();let o=this._controller.getCurrentDocument(),a=o.createElement("div");a.setAttribute("data-layout-path","/drag-rectangle"),a.style.position="absolute",a.style.left="-10000px",a.style.top="-10000px",o.body.appendChild(a),(0,iD.createRoot)(a).render(s),e.dataTransfer.setDragImage(a,n,r),setTimeout(()=>{o.body.removeChild(a)},0)}updateActive(e){let i=Array.from(this._controller.getModel().getLayouts().values()),n=!1;for(let r=i.length-1;r>=0;r--){let s=i[r].getController()?.getDragDropManager();if(s){let i=!n&&s.getDragEnterCount()>0;i&&(n=!0),s.setActive(i,e)}}}setActive(e,i){this._active!==e&&(this._active=e,this._active?this.onDragEnter(i):this.onDragLeave(i))}onDragEnterRaw=e=>{this._dragEnterCount++,this.updateActive(e)};onDragLeaveRaw=e=>{this._dragEnterCount--,this.updateActive(e)};clearDragMain(){for(let[,e]of(this._controller.showOverlayOnAllWindows(!1),this._controller.getModel().getLayouts()))e.getController()&&e.getController().getDragDropManager().clearDragLocal()}clearDragLocal(){this._dragEnterCount=0,this._active=!1,this.clearDragLocalVisuals()}clearDragLocalVisuals(){this._controller.setState({showEdges:!1}),this._dragging=!1,this._outlineDiv&&(this._controller.getRootDiv().removeChild(this._outlineDiv),this._outlineDiv=void 0)}onDragEnter=i=>{if(!e.dragState&&this._controller.getProps().onExternalDrag){let n=this._controller.getProps().onExternalDrag(i);if(n){let i=iU.fromJson(n.json,this._controller.getModel(),!1);e.dragState=new nv(this._controller.getMainController(),ng.External,i,n.json,n.onDrop)}}if(this._mainController===e.dragState?.mainLayoutController&&e.dragState){i.preventDefault(),this._dropInfo=void 0;let e=this._controller.getRootDiv();this._outlineDiv=this._controller.getCurrentDocument().createElement("div"),this._outlineDiv.className=this._controller.getClassName(iP.FLEXLAYOUT__OUTLINE_RECT),this._outlineDiv.style.visibility="hidden";let n=this._controller.getTabDragSpeed();this._outlineDiv.style.transition=`top ${n}s, left ${n}s, width ${n}s, height ${n}s`,e.appendChild(this._outlineDiv),this._dragging=!0,this._controller.showOverlayOnAllWindows(!0),void 0===this._controller.getModel().getMaximizedTabset(this._controller.getLayoutId())&&this._controller.setState({showEdges:this._controller.getModel().isEnableEdgeDock()});let r=this._controller.getRootDiv().getBoundingClientRect();new ij(i.clientX-r.left,i.clientY-r.top,1,1).positionElement(this._outlineDiv)}};onDragOver=i=>{if(this._mainController===e.dragState?.mainLayoutController&&this._active){let n=this._controller.getRootDiv()?.getBoundingClientRect(),r={x:i.clientX-(n?.left??0),y:i.clientY-(n?.top??0)};this._controller.checkForBorderToShow(r.x,r.y);let s=this._controller.getModel().findDropTargetNode(this._controller.getLayoutId(),e.dragState.dragNode,r.x,r.y);s&&(i.preventDefault(),this._dropInfo=s,this._outlineDiv&&(this._outlineDiv.className=this._controller.getClassName(s.className),s.rect.positionElement(this._outlineDiv),this._outlineDiv.style.visibility="visible"))}};onDragLeave=i=>{if(this._mainController===e.dragState?.mainLayoutController&&(this.clearDragLocalVisuals(),this._controller.isMainLayout())){let e=!1;for(let[,i]of this._controller.getModel().getLayouts())if(i.getController()&&i.getController().getDragDropManager().isDragging()){e=!0;break}!1===e&&this.clearDragMain()}};onDrop=i=>{if(this._mainController===e.dragState?.mainLayoutController){if(this._active){i.preventDefault();let n=e.dragState;if(this._dropInfo)if(void 0!==n.dragJson){let e=this._controller.doAction(iB.addNode(n.dragJson,this._dropInfo.node.getId(),this._dropInfo.location,this._dropInfo.index));void 0!==n.fnNewNodeDropped&&n.fnNewNodeDropped(e,i)}else void 0!==n.dragNode&&this._controller.doAction(iB.moveNode(n.dragNode.getId(),this._dropInfo.node.getId(),this._dropInfo.location,this._dropInfo.index));this.clearDragMain(),e.dragState=void 0}this._dragEnterCount=0}};getDragEnterCount(){return this._dragEnterCount}isDragging(){return this._dragging}},ng=((sz={}).Internal="internal",sz.External="external",sz.Add="add",sz),nv=class{mainLayoutController;dragSource;dragNode;dragJson;fnNewNodeDropped;constructor(e,i,n,r,s){this.mainLayoutController=e,this.dragSource=i,this.dragNode=n,this.dragJson=r,this.fnNewNodeDropped=s}},ny=({controller:e})=>{let i=[],n=e.getIcons().edgeArrow;if(e.getState().showEdges&&e.getModel().isEnableEdgeDockIndicators()){let r=e.getModel().getRootRow(e.getLayoutId()).getRect(),s=e.getClassName(iP.FLEXLAYOUT__EDGE_RECT);i.push((0,iN.jsx)("div",{style:{top:0,left:r.width/2-50,width:100,height:10,borderBottomLeftRadius:50,borderBottomRightRadius:50},className:s+" "+e.getClassName(iP.FLEXLAYOUT__EDGE_RECT_TOP),children:(0,iN.jsx)("div",{style:{transform:"rotate(180deg)"},children:n})},"North")),i.push((0,iN.jsx)("div",{style:{top:r.height/2-50,left:0,width:10,height:100,borderTopRightRadius:50,borderBottomRightRadius:50},className:s+" "+e.getClassName(iP.FLEXLAYOUT__EDGE_RECT_LEFT),children:(0,iN.jsx)("div",{style:{transform:"rotate(90deg)"},children:n})},"West")),i.push((0,iN.jsx)("div",{style:{top:r.height-10,left:r.width/2-50,width:100,height:10,borderTopLeftRadius:50,borderTopRightRadius:50},className:s+" "+e.getClassName(iP.FLEXLAYOUT__EDGE_RECT_BOTTOM),children:(0,iN.jsx)("div",{children:n})},"South")),i.push((0,iN.jsx)("div",{style:{top:r.height/2-50,left:r.width-10,width:10,height:100,borderTopLeftRadius:50,borderBottomLeftRadius:50},className:s+" "+e.getClassName(iP.FLEXLAYOUT__EDGE_RECT_RIGHT),children:(0,iN.jsx)("div",{style:{transform:"rotate(-90deg)"},children:n})},"East"))}return(0,iN.jsx)(iN.Fragment,{children:i})},n_=e=>{let{title:i,controller:n,layout:r,url:s,onCloseLayout:o,onSetWindow:a,children:l}=e,c=iA.useRef(null),[h,d]=iA.useState(void 0),[u,p]=iA.useState(!0),f=new Map;return(iA.useLayoutEffect(()=>{if(!c.current){let e=r.getLayoutId(),n=r.getRect();c.current=window.open(s,e,`left=${n.x},top=${n.y},width=${n.width},height=${n.height}`),c.current?(a(r,c.current),window.addEventListener("beforeunload",()=>{if(c.current){let e=c.current;c.current=null,e.close()}}),c.current.addEventListener("load",()=>{if(c.current){c.current.focus(),c.current.resizeTo(n.width,n.height),c.current.moveTo(n.x,n.y);let e=c.current.document;e.title=i;let s=e.createElement("div");s.className=iP.FLEXLAYOUT__FLOATING_WINDOW_CONTENT,e.body.appendChild(s),(function(e,i){let n=[];for(let r of document.querySelectorAll('style, link[rel="stylesheet"]'))nb(e,r,i,n);return Promise.all(n)})(e,f).then(()=>{d(s)});let a=new MutationObserver(i=>(function(e,i,n){for(let r of e)if("childList"===r.type){for(let e of r.addedNodes)(e instanceof HTMLLinkElement||e instanceof HTMLStyleElement)&&nb(i,e,n);for(let e of r.removedNodes)if(e instanceof HTMLLinkElement||e instanceof HTMLStyleElement){let r=n.get(e);r&&i.head.removeChild(r)}}})(i,e,f));a.observe(document.head,{childList:!0}),c.current.addEventListener("beforeunload",()=>{c.current&&(o(r),c.current=null,a.disconnect())})}})):(console.warn(`Unable to open window ${s}`),o(r))}return()=>{n.getModel().getLayouts().has(r.getLayoutId())||(c.current?.close(),c.current=null)}},[]),iA.useEffect(()=>{void 0!==h&&u&&(n.redrawLayout(),p(!1))},[h,u,n]),void 0!==h)?(0,iR.createPortal)(l,h):null};function nb(e,i,n,r){if(i instanceof HTMLLinkElement){let s=i.cloneNode(!0);e.head.appendChild(s),n.set(i,s),r&&r.push(new Promise(e=>{s.onload=()=>e(!0)}))}else if(i instanceof HTMLStyleElement)try{let r=i.cloneNode(!0);e.head.appendChild(r),n.set(i,r)}catch(e){}}var nx=((sF=nx||{}).North="n",sF.South="s",sF.East="e",sF.West="w",sF.NorthWest="nw",sF.NorthEast="ne",sF.SouthWest="sw",sF.SouthEast="se",sF),nw=e=>{let{controller:i,layout:n,children:r}=e,[s,o]=iA.useState(n.getRect()),a=i.getClassName,l=iA.useRef(null),c=iA.useRef(null),h=iA.useRef(null),d=iA.useRef(null),u=iA.useRef(null),p=iA.useRef(null),f=iA.useRef(null),m=iA.useRef(null),g=iA.useRef(null),v=iA.useRef(null),y=iA.useRef(!1);iA.useEffect(()=>(c.current?.addEventListener("touchstart",_,{passive:!1}),h.current?.addEventListener("touchstart",_,{passive:!1}),d.current?.addEventListener("touchstart",_,{passive:!1}),u.current?.addEventListener("touchstart",_,{passive:!1}),p.current?.addEventListener("touchstart",_,{passive:!1}),f.current?.addEventListener("touchstart",_,{passive:!1}),m.current?.addEventListener("touchstart",_,{passive:!1}),g.current?.addEventListener("touchstart",_,{passive:!1}),v.current?.addEventListener("touchstart",_,{passive:!1}),()=>{c.current?.removeEventListener("touchstart",_),h.current?.removeEventListener("touchstart",_),d.current?.removeEventListener("touchstart",_),u.current?.removeEventListener("touchstart",_),p.current?.removeEventListener("touchstart",_),f.current?.removeEventListener("touchstart",_),m.current?.removeEventListener("touchstart",_),g.current?.removeEventListener("touchstart",_),v.current?.removeEventListener("touchstart",_)}),[]);let _=e=>{e.preventDefault(),e.stopImmediatePropagation()};iA.useEffect(()=>{let e=()=>{let e=[...i.getModel().getLayouts()];n!==e[e.length-1][1]&&(y.current=!0)},r=()=>{y.current&&(setTimeout(()=>{i.moveWindowToFront(n.getLayoutId())},10),y.current=!1)},s=l.current;return s&&(s.addEventListener("pointerdown",e,{capture:!0}),s.addEventListener("pointerup",r)),()=>{s&&(s.removeEventListener("pointerdown",e,{capture:!0}),s.removeEventListener("pointerup",r))}},[i,n.getLayoutId()]);let b=(e,r)=>{let a={x:e.clientX,y:e.clientY},l=i.getRootDiv(),c=l?l.getBoundingClientRect():{width:window.innerWidth,height:window.innerHeight};iG(document,e,(e,l)=>{i.showOverlayOnAllWindows(!0);let h=e-a.x,d=l-a.y,u=s.x,p=s.y,f=s.width,m=s.height;r.includes("n")&&(p+=d,m-=d),r.includes("s")&&(m+=d),r.includes("w")&&(u+=h,f-=h),r.includes("e")&&(f+=h),f<150&&(r.includes("w")&&(u=s.x+s.width-150),f=150),m<25&&(r.includes("n")&&(p=s.y+s.height-25),m=25),u<0&&(f+=u,u=0),p<0&&(m+=p,p=0),u+f>c.width&&(f=c.width-u),p+m>c.height&&(m=c.height-p),f<150&&(f=150),m<25&&(m=25);let g=new ij(u,p,f,m);o(g),n.setRect(g)},()=>{i.redrawLayout(),i.showOverlayOnAllWindows(!1)},()=>{}),e.stopPropagation()},w=i.getRootDiv(),S=w?w.getBoundingClientRect():{width:window.innerWidth,height:window.innerHeight};return s.clamp(new ij(0,0,S.width,S.height)),(0,iN.jsxs)("div",{ref:l,className:a(iP.FLEXLAYOUT__FLOAT_WINDOW),style:{left:s.x,top:s.y,width:s.width,height:s.height,position:"absolute"},children:[(0,iN.jsx)("div",{ref:c,className:a(iP.FLEXLAYOUT__FLOAT_WINDOW_HEADER),onPointerDown:e=>{e.stopPropagation();let r={x:e.clientX-s.x,y:e.clientY-s.y},a=i.getRootDiv(),l=a?a.getBoundingClientRect():{width:window.innerWidth,height:window.innerHeight};iG(document,e,(e,a)=>{i.showOverlayOnAllWindows(!0),y.current&&(i.moveWindowToFront(n.getLayoutId()),y.current=!1);let c=new ij(e-r.x,a-r.y,s.width,s.height);c.clamp(new ij(0,0,l.width,l.height)),o(c),n.setRect(c)},()=>{i.redrawLayout(),i.showOverlayOnAllWindows(!1)},()=>{})},children:(0,iN.jsx)("div",{style:{flexGrow:1,display:"flex",justifyContent:"center"},children:(0,iN.jsx)("div",{style:{width:50,height:8,display:"flex",flexDirection:"column",justifyContent:"space-around",opacity:.5},children:(0,iN.jsx)("div",{style:{height:2,backgroundColor:"gray",borderRadius:1}})})})}),(0,iN.jsx)("div",{className:a(iP.FLEXLAYOUT__FLOAT_WINDOW_CONTENT),children:r}),(0,iN.jsx)("div",{ref:h,style:{position:"absolute",zIndex:10,top:-4,left:8,right:8,height:8,cursor:"ns-resize"},onPointerDown:e=>b(e,nx.North)}),(0,iN.jsx)("div",{ref:f,style:{position:"absolute",zIndex:10,bottom:-4,left:8,right:8,height:8,cursor:"ns-resize"},onPointerDown:e=>b(e,nx.South)}),(0,iN.jsx)("div",{ref:u,style:{position:"absolute",zIndex:10,top:8,bottom:8,right:-4,width:8,cursor:"ew-resize"},onPointerDown:e=>b(e,nx.East)}),(0,iN.jsx)("div",{ref:g,style:{position:"absolute",zIndex:10,top:8,bottom:8,left:-4,width:8,cursor:"ew-resize"},onPointerDown:e=>b(e,nx.West)}),(0,iN.jsx)("div",{ref:v,style:{position:"absolute",zIndex:10,top:-4,left:-4,width:12,height:12,cursor:"nwse-resize"},onPointerDown:e=>b(e,nx.NorthWest)}),(0,iN.jsx)("div",{ref:d,style:{position:"absolute",zIndex:10,top:-4,right:-4,width:12,height:12,cursor:"nesw-resize"},onPointerDown:e=>b(e,nx.NorthEast)}),(0,iN.jsx)("div",{ref:m,style:{position:"absolute",zIndex:10,bottom:-4,left:-4,width:12,height:12,cursor:"nesw-resize"},onPointerDown:e=>b(e,nx.SouthWest)}),(0,iN.jsx)("div",{ref:p,style:{position:"absolute",zIndex:10,bottom:0,right:0,width:12,height:12,cursor:"nwse-resize"},onPointerDown:e=>b(e,nx.SouthEast)})]})},nS=({controller:e})=>{let i=[],n=e.getModel().getLayouts(),r=0;for(let[s,o]of n)!o.isMainLayout()&&("window"===o.getType()&&e.isSupportsPopout()?(i.push((0,iN.jsx)(n_,{controller:e,layout:o,title:e.getPopoutWindowName()+" "+r,url:e.getPopoutURL()+"?id="+s,onSetWindow:e.onSetWindow,onCloseLayout:e.onCloseLayout,children:(0,iN.jsx)("div",{className:e.getProps().popoutClassName,children:(0,iN.jsx)(nM,{...e.getProps(),layoutId:s,mainLayoutController:e})})},s)),r++):"float"===o.getType()&&i.push((0,iN.jsx)(nw,{controller:e,layout:o,onCloseLayout:e.onCloseLayout,children:(0,iN.jsx)(nM,{...e.getProps(),layoutId:s,mainLayoutController:e})},s+"float")));return(0,iN.jsx)(iN.Fragment,{children:i})},nk=e=>{let{controller:i,tabNode:n,selected:r,border:s,icons:o,path:a}=e,l=iA.useRef(null),c=iA.useRef(null);iA.useLayoutEffect(()=>{n.setTabRect(i.getBoundingClientRect(l.current)),i.getEditingTab()===n&&c.current.select()});let h=i.getClassName,d=h(iP.FLEXLAYOUT__BORDER_BUTTON)+" "+h(iP.FLEXLAYOUT__BORDER_BUTTON_+s);r?d+=" "+h(iP.FLEXLAYOUT__BORDER_BUTTON__SELECTED):d+=" "+h(iP.FLEXLAYOUT__BORDER_BUTTON__UNSELECTED),void 0!==n.getClassName()&&(d+=" "+n.getClassName());let u=0;!1===n.getModel().isEnableRotateBorderIcons()&&("left"===s?u=90:"right"===s&&(u=-90));let p=iq(i,n,u),f=p.content?(0,iN.jsx)("div",{className:h(iP.FLEXLAYOUT__BORDER_BUTTON_CONTENT),children:p.content}):null,m=p.leading?(0,iN.jsx)("div",{className:h(iP.FLEXLAYOUT__BORDER_BUTTON_LEADING),children:p.leading}):null;if(i.getEditingTab()===n&&(f=(0,iN.jsx)("input",{ref:c,className:h(iP.FLEXLAYOUT__TAB_BUTTON_TEXTBOX),"data-layout-path":a+"/textbox",type:"text",autoFocus:!0,defaultValue:n.getName(),onKeyDown:e=>{"Escape"===e.code?i.setEditingTab(void 0):("Enter"===e.code||"NumpadEnter"===e.code)&&(i.setEditingTab(void 0),i.doAction(iB.renameTab(n.getId(),e.target.value)))},onPointerDown:e=>{e.stopPropagation()}})),n.isCloseable()){let e=i.i18nName(ni.Close_Tab);p.buttons.push((0,iN.jsx)("div",{"data-layout-path":a+"/button/close",title:e,className:h(iP.FLEXLAYOUT__BORDER_BUTTON_TRAILING),onPointerDown:e=>{e.stopPropagation()},onClick:e=>{let s;s=n.getCloseType(),(r||s===no.Always||s===no.Visible&&window.matchMedia&&window.matchMedia("(hover: hover) and (pointer: fine)").matches||0)&&(i.doAction(iB.deleteTab(n.getId())),e.stopPropagation())},children:"function"==typeof o.close?o.close(n):o.close},"close"))}return(0,iN.jsxs)("div",{ref:l,"data-layout-path":a,className:d,onClick:()=>{i.doAction(iB.selectTab(n.getId()))},onAuxClick:e=>{iY(e)&&i.auxMouseClick(n,e)},onContextMenu:e=>{i.showContextMenu(n,e)},title:n.getHelpText(),draggable:!0,onDragStart:e=>{n.isEnableDrag()?(e.stopPropagation(),i.getDragDropManager().setDragNode(e.nativeEvent,n)):e.preventDefault()},onDragEnd:e=>{e.stopPropagation(),i.getDragDropManager().clearDragMain()},children:[m,f,p.buttons]})},nC=e=>{let i,n,r,s,{borderNode:o,controller:a,size:l}=e,c=iA.useRef(null),h=iA.useRef(null),d=iA.useRef(null),u=iA.useRef(null),p=iA.useRef(null),f=a.getIcons();iA.useLayoutEffect(()=>{o.setTabHeaderRect(a.getBoundingClientRect(m.current))});let{selfRef:m,userControlledPositionRef:g,onScroll:v,onScrollPointerDown:y,hiddenTabs:_,onMouseWheel:b,isDockStickyButtons:w,isShowHiddenTabs:S}=nl(a,o,iL.flip(o.getOrientation()),p,h,a.getClassName(iP.FLEXLAYOUT__BORDER_BUTTON)),k=e=>{iY(e)&&a.auxMouseClick(o,e)},C=e=>{e.stopPropagation()},T=e=>{let i=a.getShowOverflowMenu(),n=_.map(e=>({index:e,node:o.getChildren()[e]}));void 0!==i?i(o,e,n,E):nr(d.current,o,n,E,a),e.stopPropagation()},E=e=>{a.doAction(iB.selectTab(e.node.getId())),g.current=!1},N=e=>{let i=o.getChildren()[o.getSelected()];void 0!==i&&a.doAction(iB.popoutTab(i.getId(),"window")),e.stopPropagation()},M=e=>{let i=o.getChildren()[o.getSelected()];void 0!==i&&a.doAction(iB.popoutTab(i.getId(),"float")),e.stopPropagation()},O=a.getClassName,A=(()=>{let e=[];for(let i=0;i<o.getChildren().length;i++){let n=o.getSelected()===i,r=o.getChildren()[i];e.push((0,iN.jsx)(nk,{controller:a,border:o.getLocation().getName(),tabNode:r,path:o.getPath()+"/tb"+i,selected:n,icons:f},r.getId())),i<o.getChildren().length-1&&e.push((0,iN.jsx)("div",{className:O(iP.FLEXLAYOUT__BORDER_TAB_DIVIDER)},"divider"+i))}return e})(),{leading:R,toolbar:D}=(e=>{let i,n=[],r=[],s={leading:i,buttons:n,stickyButtons:r,overflowPosition:void 0};if(a.customizeTabSet(o,s),i=s.leading,r=s.stickyButtons,n=s.buttons,void 0===s.overflowPosition&&(s.overflowPosition=r.length),r.length>0&&(w?n=[...r,...n]:e.push((0,iN.jsx)("div",{ref:u,onPointerDown:C,onDragStart:e=>{e.preventDefault()},className:O(iP.FLEXLAYOUT__TAB_TOOLBAR_STICKY_BUTTONS_CONTAINER),children:r},"sticky_buttons_container"))),S){let e,i=a.i18nName(ni.Overflow_Menu_Tooltip);if("function"==typeof f.more){let i=_.map(e=>({index:e,node:o.getChildren()[e]}));e=f.more(o,i)}else e=(0,iN.jsxs)(iN.Fragment,{children:[f.more,(0,iN.jsx)("div",{className:O(iP.FLEXLAYOUT__TAB_BUTTON_OVERFLOW_COUNT),children:_.length>0?_.length:""})]});n.splice(Math.min(s.overflowPosition,n.length),0,(0,iN.jsx)("button",{ref:d,className:O(iP.FLEXLAYOUT__BORDER_TOOLBAR_BUTTON)+" "+O(iP.FLEXLAYOUT__BORDER_TOOLBAR_BUTTON_OVERFLOW)+" "+O(iP.FLEXLAYOUT__BORDER_TOOLBAR_BUTTON_OVERFLOW_+o.getLocation().getName()),title:i,onClick:T,onPointerDown:C,children:e},"overflowbutton"))}let l=o.getSelected();if(-1!==l){let e=o.getChildren()[l];if(void 0!==e&&a.isMainLayout()){if(e.isEnablePopoutFloatIcon()){let i=a.i18nName(ni.Popout_Tab_Float);n.push((0,iN.jsx)("button",{title:i,className:O(iP.FLEXLAYOUT__BORDER_TOOLBAR_BUTTON)+" "+O(iP.FLEXLAYOUT__BORDER_TOOLBAR_BUTTON_FLOAT),onClick:M,onPointerDown:C,children:"function"==typeof f.popoutFloat?f.popoutFloat(e):f.popoutFloat},"popout-float"))}if(a.isSupportsPopout()&&e.isEnablePopoutIcon()&&e.isAllowedInWindow()){let i=a.i18nName(ni.Popout_Tab);n.push((0,iN.jsx)("button",{title:i,className:O(iP.FLEXLAYOUT__BORDER_TOOLBAR_BUTTON)+" "+O(iP.FLEXLAYOUT__BORDER_TOOLBAR_BUTTON_FLOAT),onClick:N,onPointerDown:C,children:"function"==typeof f.popout?f.popout(e):f.popout},"popout"))}}}return{leading:i,toolbar:(0,iN.jsx)("div",{ref:c,className:O(iP.FLEXLAYOUT__BORDER_TOOLBAR)+" "+O(iP.FLEXLAYOUT__BORDER_TOOLBAR_+o.getLocation().getName()),children:n},"toolbar")}})(A),L=O(iP.FLEXLAYOUT__BORDER)+" "+O(iP.FLEXLAYOUT__BORDER_+o.getLocation().getName());void 0!==o.getClassName()&&(L+=" "+o.getClassName());let j=l-1;return o.getLocation()===iI.LEFT?(i={right:"100%",top:0},n={width:j,overflowY:"auto"}):o.getLocation()===iI.RIGHT?(i={left:"100%",top:0},n={width:j,overflowY:"auto"}):(i={left:0},n={height:j,overflowX:"auto"}),o.isEnableTabScrollbar()&&(r=(0,iN.jsx)("div",{ref:h,className:O(iP.FLEXLAYOUT__MINI_SCROLLBAR),onPointerDown:y})),R&&(s=(0,iN.jsx)("div",{className:O(iP.FLEXLAYOUT__BORDER_LEADING),children:R})),(0,iN.jsxs)("div",{ref:m,style:{display:"flex",flexDirection:o.getOrientation()===iL.VERT?"row":"column"},className:L,"data-layout-path":o.getPath(),onClick:k,onAuxClick:k,onContextMenu:e=>{a.showContextMenu(o,e)},onWheel:b,children:[s,(0,iN.jsxs)("div",{className:O(iP.FLEXLAYOUT__MINI_SCROLLBAR_CONTAINER),children:[(0,iN.jsx)("div",{ref:p,className:O(iP.FLEXLAYOUT__BORDER_INNER)+" "+O(iP.FLEXLAYOUT__BORDER_INNER_+o.getLocation().getName()),style:n,onScroll:v,children:(0,iN.jsx)("div",{style:i,className:O(iP.FLEXLAYOUT__BORDER_INNER_TAB_CONTAINER)+" "+O(iP.FLEXLAYOUT__BORDER_INNER_TAB_CONTAINER_+o.getLocation().getName()),children:A})}),r]}),D]})};function nT(e){let{controller:i,borderNode:n,show:r}=e,s=iA.useRef(null);iA.useLayoutEffect(()=>{let e=i.getBoundingClientRect(s.current);isNaN(e.x)||!(e.width>0)||n.getContentRect().equalsWhenRounded(e)||(n.setContentRect(e),i.setReLayout(!0))});let o=!0,a={};n.getOrientation()===iL.HORZ?(a.width=n.getSize(),a.minWidth=n.getMinSize(),a.maxWidth=n.getMaxSize()):(a.height=n.getSize(),a.minHeight=n.getMinSize(),a.maxHeight=n.getMaxSize(),o=!1),a.display=r?"flex":"none";let l=i.getClassName(iP.FLEXLAYOUT__BORDER_TAB_CONTENTS);return n.getLocation()===iI.LEFT||n.getLocation()===iI.TOP?(0,iN.jsxs)(iN.Fragment,{children:[(0,iN.jsx)("div",{ref:s,style:a,className:l}),r&&(0,iN.jsx)(nh,{controller:i,node:n,index:0,horizontal:o})]}):(0,iN.jsxs)(iN.Fragment,{children:[r&&(0,iN.jsx)(nh,{controller:i,node:n,index:0,horizontal:o}),(0,iN.jsx)("div",{ref:s,style:a,className:l})]})}var nE=({controller:e,inner:i})=>{let n=e.getClassName(iP.FLEXLAYOUT__LAYOUT_MAIN),r=e.getModel().getBorderSet().getBorderMap();if(!e.isMainLayout()||!(r.size>0))return(0,iN.jsx)("div",{className:n,ref:e.getMainRef(),style:{position:"absolute",top:0,left:0,bottom:0,right:0,display:"flex"},children:i});{let s=(0,iN.jsx)("div",{className:n,ref:e.getMainRef(),children:i}),o=new Map,a=new Map;for(let[i,n]of iI.values){let i=r.get(n);i&&i.isShowing()&&(!i.isAutoHide()||i.isAutoHide()&&(i.getChildren().length>0||e.getState().showHiddenBorder===n))&&(o.set(n,(0,iN.jsx)(nC,{controller:e,borderNode:i,size:e.getState().calculatedBorderBarSize})),a.set(n,(0,iN.jsx)(nT,{controller:e,borderNode:i,show:-1!==i.getSelected()})))}let l=e.getClassName(iP.FLEXLAYOUT__LAYOUT_BORDER_CONTAINER),c=e.getClassName(iP.FLEXLAYOUT__LAYOUT_BORDER_CONTAINER_INNER);if(e.getModel().getBorderSet().getLayoutHorizontal()){let e=(0,iN.jsxs)("div",{className:c,style:{flexDirection:"column"},children:[a.get(iI.TOP),(0,iN.jsxs)("div",{className:c,style:{flexDirection:"row"},children:[a.get(iI.LEFT),s,a.get(iI.RIGHT)]}),a.get(iI.BOTTOM)]});return(0,iN.jsxs)("div",{className:l,style:{flexDirection:"column"},children:[o.get(iI.TOP),(0,iN.jsxs)("div",{className:c,style:{flexDirection:"row"},children:[o.get(iI.LEFT),e,o.get(iI.RIGHT)]}),o.get(iI.BOTTOM)]})}{let e=(0,iN.jsxs)("div",{className:c,style:{flexDirection:"row"},children:[a.get(iI.LEFT),(0,iN.jsxs)("div",{className:c,style:{flexDirection:"column"},children:[a.get(iI.TOP),s,a.get(iI.BOTTOM)]}),a.get(iI.RIGHT)]});return(0,iN.jsxs)("div",{className:l,style:{flexDirection:"row"},children:[o.get(iI.LEFT),(0,iN.jsxs)("div",{className:c,style:{flexDirection:"column"},children:[o.get(iI.TOP),e,o.get(iI.BOTTOM)]}),o.get(iI.RIGHT)]})}}},nN=iA.memo(e=>{nN.displayName="DragContainer";let{controller:i,tabNode:n}=e,r=iA.useRef(null);iA.useEffect(()=>{n.setTabStamp(r.current)},[n,r.current]);let s=i.getClassName;return(0,iN.jsx)("div",{ref:r,className:s(iP.FLEXLAYOUT__DRAG_RECT),children:(0,iN.jsx)(nn,{controller:i,tabNode:n},n.getId())})},function(e,i){return i.dragging}),nM=iA.forwardRef((e,i)=>{nM.displayName="LayoutInternal";let[n,r]=iA.useState({rect:ij.empty(),editingTab:void 0,showEdges:!1,showOverlay:!1,calculatedBorderBarSize:29,layoutRedrawRevision:0,fullRedrawRevision:0,showHiddenBorder:iI.CENTER,splitterSize:8}),s=iA.useCallback(i=>{r(n=>({...n,..."function"==typeof i?i(n,e):i}))},[e]),o=iA.useRef(null),a=iA.useRef(null),l=iA.useRef(null),c=iA.useRef(null),h=iA.useMemo(()=>new nO(e,n,s),[]);if(h.setProps(e),h.setStateRaw(n),h.setSetState(s),h.setLayoutRef(o),h.setMoveablesRef(a),h.setFindBorderBarSizeRef(l),h.setMainRef(c),iA.useImperativeHandle(i,()=>h,[h]),iA.useLayoutEffect(()=>{h.isMainLayout()&&h.updateLayoutMetrics(),h.isReLayout()&&(h.redrawLayout(),h.setReLayout(!1))}),iA.useEffect(()=>{let e=o.current.ownerDocument,i=e.defaultView;h.setCurrentDocument(e),h.setCurrentWindow(i);let n=new i.ResizeObserver(()=>{i.requestAnimationFrame(()=>{h.updateRect()})});n.observe(o.current);let r=()=>{h.updateRect()};i.addEventListener("resize",r);let s=()=>{for(let[e,i]of h.getProps().model.getLayouts())i.getController()&&h.redrawLayout()};return document.addEventListener("visibilitychange",s),()=>{n.disconnect(),i.removeEventListener("resize",r),document.removeEventListener("visibilitychange",s)}},[h,o.current?.ownerDocument]),iA.useEffect(()=>{let e;if(!h.isMainLayout()&&"window"===h.getLayout().getType()){let i=h.getProps().mainLayoutController?.getRootDiv();if(i){let n=o.current;iQ(i,n),(e=new MutationObserver(()=>{iQ(i,n)&&h.redrawLayout()})).observe(i,{attributeFilter:["style"]})}}return()=>{e&&e.disconnect()}},[h]),iA.useEffect(()=>{let i=e.model,r=i.getLayouts().get(h.getLayoutId());if(r.setController(h),r.setToExportRectFunction((e,i)=>"window"===i?h.getScreenRect(e):h.getRelativeRect(e)),h.setLayout(r),h.isMainLayout()){i.addChangeListener(h.onModelChange);let r=()=>{let i=parseInt(getComputedStyle(o.current).getPropertyValue("--splitter-size"));Number.isFinite(i)&&(e.model.setSplitterSize(i),n.splitterSize!==i&&s({splitterSize:i}))};r();let a=setInterval(r,1e3);return()=>{i.removeChangeListener(h.onModelChange),clearInterval(a),h.tidyMoveablesMap()}}},[e.model,h]),!o.current)return(0,iN.jsxs)("div",{ref:o,className:h.getClassName(iP.FLEXLAYOUT__LAYOUT),children:[(0,iN.jsx)("div",{ref:a,className:h.getClassName(iP.FLEXLAYOUT__LAYOUT_MOVEABLES)},"__moveables__"),(0,iN.jsx)("div",{ref:l,className:h.getClassName(iP.FLEXLAYOUT__BORDER_SIZER),children:"FindBorderBarSize"},"findBorderBarSize")]});let d=e.model,u=h.getLayoutId();d.getRootRow(u).calcMinMaxSize(),d.getRootRow(u).setPaths(""),h.isMainLayout()&&(d.getBorderSet().setPaths(),h.createMoveableDivs());let p=(0,iN.jsx)(nE,{controller:h,inner:h.renderLayout()}),f=h.renderTabContainers(),m=h.reorderComponents(f,h.getOrderedTabIds()),g=null,v=null,y=null,_=null;if(h.isMainLayout()){g=h.renderMetricsElements(),v=(0,iN.jsx)(nS,{controller:h});let e=h.renderTabContents();y=h.reorderComponents(e,h.getOrderedTabMoveableIds()),_=(0,iN.jsx)("div",{className:h.getClassName(iP.FLEXLAYOUT__LAYOUT_TAB_STAMPS),children:h.renderTabStamps()},"__tabStamps__")}return(0,iN.jsxs)("div",{ref:o,className:h.getClassName(iP.FLEXLAYOUT__LAYOUT),onDragEnter:h.getDragDropManager().onDragEnterRaw,onDragLeave:h.getDragDropManager().onDragLeaveRaw,onDragOver:h.getDragDropManager().onDragOver,onDrop:h.getDragDropManager().onDrop,children:[(0,iN.jsx)("div",{ref:a,className:h.getClassName(iP.FLEXLAYOUT__LAYOUT_MOVEABLES)},"__moveables__"),g,(0,iN.jsx)(nt,{controller:h,show:n.showOverlay},"__overlay__"),p,m,y,n.portal,v,_]})}),nO=class e{static Windows=new Map;_props;_state;_setState;_layoutRef;_moveablesRef;_findBorderBarSizeRef;_mainRef;_orderedTabIds;_orderedTabMoveableIds;_moveableElementMap=new Map;_currentDocument;_currentWindow;_supportsPopout;_popoutURL;_icons;_dragDropManager;_layoutId;_layout;_mainController;_popoutWindowName;_cachedLayoutDOMRect;_reLayout;constructor(e,i,n){this._props=e,this._state=i,this._setState=n,this._orderedTabIds=[],this._orderedTabMoveableIds=[],this._supportsPopout=void 0!==e.supportsPopout?e.supportsPopout:nR,this._popoutURL=e.popoutURL?e.popoutURL:"popout.html",this._icons={...nA,...e.icons},this._layoutId=e.layoutId?e.layoutId:i9.MAIN_LAYOUT_ID,this._mainController=e.mainLayoutController?e.mainLayoutController:this,this._dragDropManager=new nm(this),this._layout=e.model.getLayouts().get(this._layoutId),this._layout.setController(this),this._popoutWindowName=e.popoutWindowName||"Popout Window",this._reLayout=!1}renderLayout(){return this._cachedLayoutDOMRect=void 0,(0,iN.jsxs)(iN.Fragment,{children:[(0,iN.jsx)(nd,{controller:this,rowNode:this._props.model.getRootRow(this._layoutId)},"__row__"),(0,iN.jsx)(ny,{controller:this})]})}renderTabContainers(){let e=new Map;return this._props.model.visitLayoutNodes(this._layoutId,i=>{if(i instanceof iU){let n=i.isSelected(),r=i.isRendered(),s=i.isEnableRenderOnDemand();(r||n||!s)&&e.set(i.getId(),(0,iN.jsx)(nu,{controller:this,tabNode:i,selected:n},i.getId()))}}),e}renderTabContents(){let e=new Map;for(let[i,n]of this._props.model.getLayouts())this._props.model.visitLayoutNodes(i,i=>{if(i instanceof iU){let r=i.isSelected(),s=i.isRendered(),o=i.isEnableRenderOnDemand(),a=i.getParent().getContentRect(),l=r||!o;if(s||l&&a.width>0&&a.height>0){let r=i.getMoveableElement(),s=n.getWindowId()||"",o=i.getId()+(i.isEnableWindowReMount()?s:"");e.set(i.getId(),(0,iR.createPortal)((0,iN.jsx)(nf,{controller:this,tabNode:i,rect:a,windowId:s,visible:l,fullRedrawRevision:this._state.fullRedrawRevision,parentRedrawRevision:this._props.parentRedrawRevision},o),r,o)),i.setRendered(!0)}}});return e}renderMetricsElements(){return(0,iN.jsx)("div",{ref:this._findBorderBarSizeRef,className:this.getClassName(iP.FLEXLAYOUT__BORDER_SIZER),children:"FindBorderBarSize"},"findBorderBarSize")}renderTabStamps(){let e=[];return this._props.model.visitNodes(i=>{i instanceof iU&&e.push((0,iN.jsx)(nN,{controller:this,tabNode:i,dragging:iJ},i.getId()))}),e}createMoveableDivs(){this._props.model.visitNodes(e=>{if(e instanceof iU){let i=this.getMoveableElement(e.getId());e.setMoveableElement(i)}})}getMoveablesDiv(){return this._moveablesRef.current}getMoveableElement(e){let i=this._moveableElementMap.get(e);return void 0===i&&(i=document.createElement("div"),this._moveablesRef.current.appendChild(i),i.className=iP.FLEXLAYOUT__TAB_MOVEABLE,this._moveableElementMap.set(e,i)),i}tidyMoveablesMap(){let e=new Map;for(let[i,n]of(this._props.model.visitNodes((i,n)=>{i instanceof iU&&e.set(i.getId(),i)}),this._moveableElementMap))e.has(i)||(n.remove(),this._moveableElementMap.delete(i))}redrawLayout(){this._mainController?.setState(e=>({layoutRedrawRevision:e.layoutRedrawRevision+1}))}redrawLayoutAndTabContent(e=!0){this._mainController?.setState(e=>({fullRedrawRevision:e.fullRedrawRevision+1}))}doAction(e){if(void 0===this._props.onAction)return this._props.model.doAction(e);{let i=this._props.onAction(e);return void 0!==i?this._props.model.doAction(i):void 0}}updateRect=()=>{if(this._layoutRef.current){let e=this._layoutRef.current;if(!this._layout.isMainLayout()&&"float"===this._layout.getType()){let i=e.closest("."+this.getClassName(iP.FLEXLAYOUT__FLOAT_WINDOW));i instanceof HTMLDivElement&&(e=i)}let i=ij.fromDomRect(e.getBoundingClientRect());if(!this._layout.isMainLayout()&&"float"===this._layout.getType()){let e=this._mainController.getDomRect();i=i.relativeTo(e)}!i.equalsWhenRounded(this._state.rect)&&0!==i.width&&0!==i.height&&(this.setState({rect:i}),this._layout.setRect(i),this._layout.isMainLayout()||this.redrawLayout())}};onModelChange=e=>{e.type==iB.DELETE_TAB&&this._state.showHiddenBorder!==iI.CENTER&&0===this._props.model.getBorderSet().getBorderMap().get(this._state.showHiddenBorder).getChildren().length&&this._setState({showHiddenBorder:iI.CENTER}),this.redrawLayout(),this._props.onModelChange&&this._props.onModelChange(this._props.model,e)};reorderComponents(e,i){let n=i.filter(i=>e.has(i)),r=new Set(n);for(let i of e.keys())r.has(i)||n.push(i);return i.splice(0,i.length,...n),i.map(i=>e.get(i))}checkForBorderToShow(e,i){let n=this.getBoundingClientRect(this._mainRef.current),r=n.getCenter(),s=!1;this._props.model.isEnableEdgeDock()&&this._state.showHiddenBorder===iI.CENTER&&(i>r.y-50&&i<r.y+50||e>r.x-50&&e<r.x+50)&&(s=!0);let o=iI.CENTER;!s&&(e<=n.x+10?o=iI.LEFT:e>=n.getRight()-10?o=iI.RIGHT:i<=n.y+10?o=iI.TOP:i>=n.getBottom()-10&&(o=iI.BOTTOM)),o!==this._state.showHiddenBorder&&this.setState({showHiddenBorder:o})}updateLayoutMetrics=()=>{if(this._findBorderBarSizeRef.current){let e=this._findBorderBarSizeRef.current.getBoundingClientRect().height;e!==this._state.calculatedBorderBarSize&&this.setState({calculatedBorderBarSize:e})}};addTabWithDragAndDrop(e,i,n){this._dragDropManager.addTabWithDragAndDrop(e,i,n)}moveTabWithDragAndDrop(e,i){this._dragDropManager.moveTabWithDragAndDrop(e,i)}setDragComponent(e,i,n,r){this._dragDropManager.setDragComponent(e,i,n,r)}getProps(){return this._props}setProps(e){this._props=e}getState(){return this._state}setStateRaw(e){this._state=e}setState(e){this._setState(e)}setSetState(e){this._setState=e}getLayoutRef(){return this._layoutRef}setLayoutRef(e){this._layoutRef=e}getMoveablesRef(){return this._moveablesRef}setMoveablesRef(e){this._moveablesRef=e}getFindBorderBarSizeRef(){return this._findBorderBarSizeRef}setFindBorderBarSizeRef(e){this._findBorderBarSizeRef=e}getMainRef(){return this._mainRef}setMainRef(e){this._mainRef=e}getOrderedTabIds(){return this._orderedTabIds}getOrderedTabMoveableIds(){return this._orderedTabMoveableIds}getCurrentDocument(){return this._currentDocument}setCurrentDocument(e){this._currentDocument=e}getCurrentWindow(){return this._currentWindow}setCurrentWindow(i){this._currentWindow=i,i&&!e.Windows.has(i)&&e.Windows.set(i,i5())}getWindowId(){if(this.getCurrentWindow())return e.Windows.get(this.getCurrentWindow())}isSupportsPopout(){return this._supportsPopout}getPopoutURL(){return this._popoutURL}getIcons(){return this._icons}getDragDropManager(){return this._dragDropManager}getLayoutId(){return this._layoutId}getLayout(){return this._layout}setLayout(e){this._layout=e}getMainController(){return this._mainController}isMainLayout(){return this._layout.isMainLayout()}getPopoutWindowName(){return this._popoutWindowName}isReLayout(){return this._reLayout}setReLayout(e){this._reLayout=e}getBoundingClientRect(e){let i=this.getDomRect();return i?ij.getBoundingClientRect(e).relativeTo(i):ij.empty()}getMoveableContainer(){return this._moveablesRef.current}getClassName=e=>void 0===this._props.classNameMapper?e:this._props.classNameMapper(e);getDomRect(){return void 0!==this._cachedLayoutDOMRect?this._cachedLayoutDOMRect:this._layoutRef.current?(this._cachedLayoutDOMRect=ij.fromDomRect(this._layoutRef.current.getBoundingClientRect()),this._cachedLayoutDOMRect):ij.empty()}getRootDiv(){return this._layoutRef.current}getMainElement(){return this._mainRef.current}getFactory(){return this._props.factory}isRealtimeResize(){return this._props.realtimeResize??!1}setEditingTab(e){this.setState({editingTab:e})}getEditingTab(){return this._state.editingTab}getModel(){return this._props.model}getTabDragSpeed(){return this._props.tabDragSpeed?this._props.tabDragSpeed:.3}onCloseLayout=e=>{this.doAction(iB.closePopout(e.getLayoutId()))};onSetWindow=(e,i)=>{};getScreenRect(e){let i=e.clone(),n=this.getDomRect();return i.x=this._currentWindow.screenX+this._currentWindow.scrollX+1+n.x+i.x,i.y=this._currentWindow.screenY+this._currentWindow.scrollY+59+n.y+i.y,i.height+=60,i.width+=2,i}getRelativeRect(e){let i=e.clone();if(!this._layout.isMainLayout()){let e=this._layout.getRect();i.x+=e.x,i.y+=e.y}return i}moveWindowToFront(e){this.doAction(iB.movePopoutToFront(e))}addTabToTabSet(e,i){if(void 0!==this._props.model.getNodeById(e))return this.doAction(iB.addNode(i,e,iI.CENTER,-1))}addTabToActiveTabSet(e){let i=this._props.model.getActiveTabset(this._layoutId);if(void 0!==i)return this.doAction(iB.addNode(e,i.getId(),iI.CENTER,-1))}showControlInPortal=(e,i)=>{let n=(0,iR.createPortal)(e,i);this.setState({portal:n})};hideControlInPortal=()=>{this.setState({portal:void 0})};maximize(e){this.doAction(iB.maximizeToggle(e.getId(),this.getLayoutId()))}customizeTab(e,i){this._props.onRenderTab&&this._props.onRenderTab(e,i)}customizeTabSet(e,i){this._props.onRenderTabSet&&this._props.onRenderTabSet(e,i)}i18nName(e,i){let n;return this._props.i18nMapper&&(n=this._props.i18nMapper(e,i)),void 0===n&&(n=e+(void 0===i?"":i)),n}getShowOverflowMenu(){return this._props.onShowOverflowMenu}getTabSetPlaceHolderCallback(){return this._props.onTabSetPlaceHolder}showContextMenu(e,i){this._props.onContextMenu&&this._props.onContextMenu(e,i)}auxMouseClick(e,i){this._props.onAuxMouseClick&&this._props.onAuxMouseClick(e,i)}showOverlay(e){this.setState({showOverlay:e}),iK(!e,this._currentDocument)}showOverlayOnAllWindows(e){for(let[,i]of this._props.model.getLayouts())i.getController()&&i.getController().showOverlay(e)}},nA={close:(0,iN.jsx)(ne,{}),closeTabset:(0,iN.jsx)(ne,{}),closeFloatPopout:(0,iN.jsx)(ne,{}),popout:(0,iN.jsx)(()=>(0,iN.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",style:i7,viewBox:"0 0 20 20",fill:"var(--color-icon)",children:[(0,iN.jsx)("path",{d:"M11 3a1 1 0 100 2h2.586l-6.293 6.293a1 1 0 101.414 1.414L15 6.414V9a1 1 0 102 0V4a1 1 0 00-1-1h-5z"}),(0,iN.jsx)("path",{d:"M5 5a2 2 0 00-2 2v8a2 2 0 002 2h8a2 2 0 002-2v-3a1 1 0 10-2 0v3H5V7h3a1 1 0 000-2H5z"})]}),{}),popoutFloat:(0,iN.jsx)(()=>(0,iN.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",style:i7,viewBox:"0 0 20 20",fill:"var(--color-icon)",children:[(0,iN.jsx)("rect",{x:"3",y:"10",width:"7",height:"7",rx:"1",fill:"none",stroke:"var(--color-icon)",strokeWidth:"1.5"}),(0,iN.jsx)("rect",{x:"10",y:"3",width:"7",height:"7",rx:"1",fill:"none",stroke:"var(--color-icon)",strokeWidth:"1.5"}),(0,iN.jsx)("path",{d:"M6 14 L14 6",stroke:"var(--color-icon)",strokeWidth:"1.5",strokeLinecap:"round"}),(0,iN.jsx)("path",{d:"M10 6 h4 v4",fill:"none",stroke:"var(--color-icon)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),{}),maximize:(0,iN.jsx)(()=>(0,iN.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",style:i7,viewBox:"0 0 24 24",fill:"var(--color-icon)",children:[(0,iN.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,iN.jsx)("path",{stroke:"var(--color-icon)",d:"M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"})]}),{}),restore:(0,iN.jsx)(()=>(0,iN.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",style:i7,viewBox:"0 0 24 24",fill:"var(--color-icon)",children:[(0,iN.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,iN.jsx)("path",{stroke:"var(--color-icon)",d:"M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"})]}),{}),more:(0,iN.jsx)(()=>(0,iN.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",style:i7,viewBox:"0 0 24 24",fill:"var(--color-icon)",children:[(0,iN.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,iN.jsx)("path",{stroke:"var(--color-icon)",d:"M7 10l5 5 5-5z"})]}),{}),edgeArrow:(0,iN.jsx)(()=>(0,iN.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",style:{display:"block",width:10,height:10},preserveAspectRatio:"none",viewBox:"0 0 100 100",children:(0,iN.jsx)("path",{fill:"var(--color-edge-icon)",stroke:"var(--color-edge-icon)",d:"M10 30 L90 30 l-40 40 Z"})}),{}),activeTabset:(0,iN.jsx)(()=>(0,iN.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",style:i7,height:"24px",viewBox:"0 -960 960 960",width:"24px",children:(0,iN.jsx)("path",{fill:"var(--color-icon)",stroke:"var(--color-icon)",d:"M440-120v-264L254-197l-57-57 187-186H120v-80h264L197-706l57-57 186 187v-264h80v264l186-187 57 57-187 186h264v80H576l187 186-57 57-186-187v264h-80Z"})}),{})},nR=iV(),nD=iA.forwardRef((e,i)=>{let n=(0,iA.useRef)(null),r=(0,iA.useRef)(0);return nD.displayName="Layout",(0,iA.useImperativeHandle)(i,()=>({redraw:()=>{n.current?.redrawLayoutAndTabContent()},addTabToTabSet:(e,i)=>n.current?.addTabToTabSet(e,i),addTabWithDragAndDrop:(e,i,r)=>{n.current?.addTabWithDragAndDrop(e,i,r)},moveTabWithDragAndDrop:(e,i)=>{n.current?.moveTabWithDragAndDrop(e,i)},addTabToActiveTabSet:e=>n.current?.addTabToActiveTabSet(e),setDragComponent:(e,i,r,s)=>{n.current?.setDragComponent(e,i,r,s)},getRootDiv:()=>n.current.getRootDiv()})),(0,iN.jsx)(nM,{ref:n,...e,parentRedrawRevision:r.current++})}),nL=e.i(433721);let nj=(0,nL.default)("hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]),nI=(0,nL.default)("list-checks",[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}]]);var nP=e.i(451534);let nB=(0,nL.default)("code-xml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]);var nz=e.i(426022),nF=e.i(989484);let nW=(0,nL.default)("square-terminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]),nH=(0,nL.default)("file-diff",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M9 10h6",key:"9gxzsh"}],["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M9 17h6",key:"r8uit2"}]]),n$=(0,nL.default)("git-commit-horizontal",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]]),nU=(0,nL.default)("network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]);var nV=e.i(210),nq=e.i(932031),nY=e.i(984178),nK=e.i(220336),nK=nK,nX=e.i(680422),nX=nX,nJ=e.i(137340),nG=e.i(307858),nZ=e.i(256186),nQ=e.i(465458),n0=e.i(244073);let n1=(0,iM.createContext)({expandedPaths:new Set,togglePath:()=>void 0}),n2=({expanded:e,defaultExpanded:i=new Set,selectedPath:n,onFileSelect:r,onExpandedChange:s,workspaceId:o,onDelete:a,className:l,children:c,...h})=>{let[d,u]=(0,iM.useState)(i),p=e??d;return(0,iN.jsx)(n1.Provider,{value:{expandedPaths:p,togglePath:e=>{let i=new Set(p);i.has(e)?i.delete(e):i.add(e),u(i),s?.(i)},selectedPath:n,onFileSelect:r,workspaceId:o,onDelete:a},children:(0,iN.jsx)("div",{className:(0,nQ.cn)("flex flex-col bg-background font-mono text-sm h-full",l),role:"tree",...h,children:(0,iN.jsx)("div",{className:"p-2 flex-1 min-h-0 overflow-y-auto",children:c})})})},n5=(0,iM.createContext)({path:"",name:"",isExpanded:!1}),n3=({path:e,name:i,folderIcon:n,className:r,children:s,...o})=>{let{expandedPaths:a,togglePath:l,selectedPath:c,onFileSelect:h,workspaceId:d,onDelete:u}=(0,iM.useContext)(n1),p=a.has(e),f=c===e,m=(0,n0.useTranslations)("editor"),g=(0,n0.useTranslations)("common");return(0,iN.jsx)(n5.Provider,{value:{path:e,name:i,isExpanded:p},children:(0,iN.jsx)(nZ.Collapsible,{onOpenChange:()=>l(e),open:p,children:(0,iN.jsxs)("div",{className:r,role:"treeitem",tabIndex:0,...o,children:[(0,iN.jsxs)("div",{className:"group/folder relative",children:[(0,iN.jsxs)(nZ.CollapsibleTrigger,{className:(0,nQ.cn)("flex w-full items-center gap-1 rounded px-2 py-1 pr-16 text-left transition-colors hover:bg-muted/50",f&&"bg-muted"),children:[(0,iN.jsx)(nq.ChevronRightIcon,{className:(0,nQ.cn)("size-4 shrink-0 text-muted-foreground transition-transform",p&&"rotate-90")}),(0,iN.jsx)(n8,{children:n?n(p):p?(0,iN.jsx)(nX.default,{className:"size-4 text-blue-500"}):(0,iN.jsx)(nK.default,{className:"size-4 text-blue-500"})}),(0,iN.jsx)(n9,{children:i})]}),(0,iN.jsxs)("div",{className:"absolute right-1 top-1/2 -translate-y-1/2 flex items-center gap-1 invisible group-hover/folder:visible",onClick:e=>e.stopPropagation(),children:[(0,iN.jsx)("button",{onClick:()=>{fetch(`/api/workspaces/${d}/files/reveal?path=${encodeURIComponent(e)}`,{method:"POST"})},className:"p-0.5 rounded hover:bg-accent",title:m("revealInFinder"),children:(0,iN.jsx)(nG.ExternalLink,{className:"size-3 text-muted-foreground"})}),(0,iN.jsx)("button",{onClick:()=>u?.(e),className:"p-0.5 rounded hover:bg-accent",title:g("delete"),children:(0,iN.jsx)(nJ.Trash2,{className:"size-3 text-muted-foreground hover:text-destructive"})})]})]}),(0,iN.jsx)(nZ.CollapsibleContent,{children:(0,iN.jsx)("div",{className:"ml-4 border-l pl-2",children:s})})]})})})},n4=(0,iM.createContext)({path:"",name:""}),n6=({path:e,name:i,icon:n,className:r,children:s,...o})=>{let{selectedPath:a,onFileSelect:l,workspaceId:c,onDelete:h}=(0,iM.useContext)(n1),d=(0,n0.useTranslations)("editor"),u=(0,n0.useTranslations)("common");return(0,iN.jsx)(n4.Provider,{value:{path:e,name:i},children:(0,iN.jsx)("div",{className:(0,nQ.cn)("group/file flex cursor-pointer items-center gap-1 rounded px-2 py-1 transition-colors hover:bg-muted/50",a===e&&"bg-muted",r),onClick:()=>l?.(e),onKeyDown:i=>{("Enter"===i.key||" "===i.key)&&l?.(e)},role:"treeitem",tabIndex:0,...o,children:s??(0,iN.jsxs)(iN.Fragment,{children:[(0,iN.jsx)("span",{className:"size-4"}),(0,iN.jsx)(n8,{children:n??(0,iN.jsx)(nY.FileIcon,{className:"size-4 text-muted-foreground"})}),(0,iN.jsx)(n9,{children:i}),(0,iN.jsxs)(n7,{children:[(0,iN.jsx)("button",{onClick:()=>{fetch(`/api/workspaces/${c}/files/reveal?path=${encodeURIComponent(e)}`,{method:"POST"})},className:"p-0.5 rounded hover:bg-accent",title:d("revealInFinder"),children:(0,iN.jsx)(nG.ExternalLink,{className:"size-3 text-muted-foreground"})}),(0,iN.jsx)("button",{onClick:()=>h?.(e),className:"p-0.5 rounded hover:bg-accent",title:u("delete"),children:(0,iN.jsx)(nJ.Trash2,{className:"size-3 text-muted-foreground hover:text-destructive"})})]})]})})})},n8=({className:e,children:i,...n})=>(0,iN.jsx)("span",{className:(0,nQ.cn)("shrink-0",e),...n,children:i}),n9=({className:e,children:i,...n})=>(0,iN.jsx)("span",{className:(0,nQ.cn)("truncate flex-1 min-w-0",e),...n,children:i}),n7=({className:e,children:i,...n})=>(0,iN.jsx)("div",{className:(0,nQ.cn)("ml-auto flex items-center gap-1 shrink-0 invisible group-hover/file:visible",e),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),role:"group",...n,children:i});var re=e.i(816709);let rt=(0,re.create)((e,i)=>({tree:[],treeLoading:!1,openFiles:[],activeFilePath:null,loadTree:async i=>{e({treeLoading:!0});try{let n=await fetch(`/api/workspaces/${i}/files/tree`),r=await n.json();e({tree:r,treeLoading:!1})}catch{e({treeLoading:!1})}},openFile:async(n,r)=>{if(i().openFiles.find(e=>e.path===r))return void e({activeFilePath:r});let s=await fetch(`/api/workspaces/${n}/files/content?path=${encodeURIComponent(r)}`),o=await s.json(),a=r.split("/").pop()||r;e(e=>({openFiles:[...e.openFiles,{path:r,name:a,content:o.content,modified:!1}],activeFilePath:r}))},saveFile:async(n,r)=>{let s=i().openFiles.find(e=>e.path===r);s&&(await fetch(`/api/workspaces/${n}/files/content`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:r,content:s.content})}),e(e=>({openFiles:e.openFiles.map(e=>e.path===r?{...e,modified:!1}:e)})))},updateContent:(i,n)=>{e(e=>({openFiles:e.openFiles.map(e=>e.path===i?{...e,content:n,modified:!0}:e)}))},closeFile:i=>{e(e=>{let n=e.openFiles.filter(e=>e.path!==i),r=e.activeFilePath===i?n.length>0?n[n.length-1].path:null:e.activeFilePath;return{openFiles:n,activeFilePath:r}})},setActiveFile:i=>e({activeFilePath:i})}));var ri=e.i(601039),rn=e.i(253937);let rr={".ts":"file_type_typescript",".tsx":"file_type_reactts",".js":"file_type_js",".jsx":"file_type_reactjs",".mjs":"file_type_js",".cjs":"file_type_js",".json":"file_type_json",".json5":"file_type_json5",".jsonc":"file_type_json",".md":"file_type_markdown",".mdx":"file_type_mdx",".css":"file_type_css",".scss":"file_type_scss",".less":"file_type_less",".html":"file_type_html",".svg":"file_type_svg",".png":"file_type_image",".jpg":"file_type_image",".jpeg":"file_type_image",".gif":"file_type_image",".webp":"file_type_webp",".ico":"file_type_favicon",".yaml":"file_type_yaml",".yml":"file_type_yaml",".toml":"file_type_toml",".xml":"file_type_xml",".graphql":"file_type_graphql",".gql":"file_type_graphql",".prisma":"file_type_prisma",".sql":"file_type_sql",".sh":"file_type_shell",".bash":"file_type_shell",".zsh":"file_type_shell",".py":"file_type_python",".rb":"file_type_ruby",".go":"file_type_go",".rs":"file_type_rust",".java":"file_type_java",".kt":"file_type_kotlin",".swift":"file_type_swift",".c":"file_type_c",".cpp":"file_type_cpp",".h":"file_type_cheader",".hpp":"file_type_cppheader",".cs":"file_type_csharp",".php":"file_type_php",".vue":"file_type_vue",".svelte":"file_type_svelte",".dart":"file_type_dartlang",".lua":"file_type_lua",".r":"file_type_r",".ex":"file_type_elixir",".exs":"file_type_elixir",".erl":"file_type_erlang",".hs":"file_type_haskell",".scala":"file_type_scala",".clj":"file_type_clojure",".cljs":"file_type_clojurescript",".coffee":"file_type_coffeescript",".dockerfile":"file_type_docker",".makefile":"file_type_makefile",".txt":"file_type_text",".log":"file_type_log",".env":"file_type_config",".gitignore":"file_type_git",".editorconfig":"file_type_editorconfig",".prettierrc":"file_type_prettier",".eslintrc":"file_type_eslint",".lock":"file_type_lock",".wasm":"file_type_wasm",".pdf":"file_type_pdf",".zip":"file_type_zip",".tar":"file_type_zip",".gz":"file_type_zip"},rs={"tsconfig.json":"file_type_tsconfig","tsconfig.build.json":"file_type_tsconfig","jsconfig.json":"file_type_jsconfig","package.json":"file_type_npm","package-lock.json":"file_type_npm","pnpm-lock.yaml":"file_type_pnpm","pnpm-workspace.yaml":"file_type_pnpm",".pnpmfile.cjs":"file_type_pnpm","yarn.lock":"file_type_yarn",".yarnrc":"file_type_yarn","next.config.ts":"file_type_next","next.config.js":"file_type_next","next.config.mjs":"file_type_next","vite.config.ts":"file_type_vite","vite.config.js":"file_type_vite","tailwind.config.ts":"file_type_tailwind","tailwind.config.js":"file_type_tailwind","postcss.config.mjs":"file_type_postcss","postcss.config.js":"file_type_postcss",".eslintrc":"file_type_eslint",".eslintrc.js":"file_type_eslint",".eslintrc.json":"file_type_eslint",".eslintrc.cjs":"file_type_eslint",".prettierrc":"file_type_prettier",".prettierrc.js":"file_type_prettier",".prettierrc.json":"file_type_prettier",".gitignore":"file_type_git",".gitattributes":"file_type_git",".editorconfig":"file_type_editorconfig",dockerfile:"file_type_docker","docker-compose.yml":"file_type_docker","docker-compose.yaml":"file_type_docker",makefile:"file_type_makefile","readme.md":"file_type_markdown",license:"file_type_license","license.md":"file_type_license",".env":"file_type_config",".env.local":"file_type_config",".env.development":"file_type_config",".env.production":"file_type_config",".env.test":"file_type_config",".npmrc":"file_type_npm",".babelrc":"file_type_babel","babel.config.js":"file_type_babel","babel.config.json":"file_type_babel",".babelrc.js":"file_type_babel",".babelrc.json":"file_type_babel","jest.config.ts":"file_type_jest","jest.config.js":"file_type_jest","vitest.config.ts":"file_type_vite","vitest.config.js":"file_type_vite","webpack.config.js":"file_type_webpack","webpack.config.ts":"file_type_webpack","rollup.config.js":"file_type_rollup","rollup.config.ts":"file_type_rollup","renovate.json":"file_type_renovate",".prettierignore":"file_type_prettier",".eslintignore":"file_type_eslint",".dockerignore":"file_type_docker",prisma:"file_type_prisma"},ro={src:"folder_type_src",lib:"folder_type_library",dist:"folder_type_dist",build:"folder_type_dist",out:"folder_type_dist",public:"folder_type_public",assets:"folder_type_asset",static:"folder_type_asset",components:"folder_type_component",pages:"folder_type_view",views:"folder_type_view",routes:"folder_type_route",api:"folder_type_api",server:"folder_type_server",client:"folder_type_client",test:"folder_type_test",tests:"folder_type_test",__tests__:"folder_type_test",spec:"folder_type_test",specs:"folder_type_test",e2e:"folder_type_e2e",docs:"folder_type_docs",config:"folder_type_config",configs:"folder_type_config",scripts:"folder_type_script",styles:"folder_type_style",css:"folder_type_css",images:"folder_type_images",img:"folder_type_images",icons:"folder_type_images",fonts:"folder_type_fonts",types:"folder_type_typescript",typings:"folder_type_typings",hooks:"folder_type_hook",utils:"folder_type_helper",helpers:"folder_type_helper",tools:"folder_type_tools",services:"folder_type_services",middleware:"folder_type_middleware",models:"folder_type_model",store:"folder_type_redux",stores:"folder_type_redux",state:"folder_type_redux",node_modules:"folder_type_node",".git":"folder_type_git",".github":"folder_type_github",".vscode":"folder_type_vscode",".idea":"folder_type_idea",docker:"folder_type_docker",".docker":"folder_type_docker",kubernetes:"folder_type_kubernetes",k8s:"folder_type_kubernetes",".husky":"folder_type_husky",coverage:"folder_type_coverage",".next":"folder_type_next",".nuxt":"folder_type_nuxt",ios:"folder_type_ios",android:"folder_type_android",app:"folder_type_app",packages:"folder_type_package",modules:"folder_type_module",plugins:"folder_type_plugin",templates:"folder_type_template",i18n:"folder_type_locale",locales:"folder_type_locale",lang:"folder_type_locale",translations:"folder_type_locale",prisma:"folder_type_db",db:"folder_type_db",database:"folder_type_db",migrations:"folder_type_db",seeds:"folder_type_db",storybook:"folder_type_story",stories:"folder_type_story",".storybook":"folder_type_story",".cache":"folder_type_temp",temp:"folder_type_temp",tmp:"folder_type_temp"};function ra({name:e}){return(0,iN.jsx)(rn.default,{src:function(e){let i,n=e.toLowerCase();if(rs[n])return`/icons/${rs[n]}.svg`;let r=(i=e.lastIndexOf("."))>=0?e.slice(i).toLowerCase():"";return r&&rr[r]?`/icons/${rr[r]}.svg`:"/icons/default_file.svg"}(e),alt:e,width:16,height:16,className:"size-4 shrink-0",unoptimized:!0})}function rl({name:e,isOpen:i}){let n;return(0,iN.jsx)(rn.default,{src:(n=ro[e.toLowerCase()])?`/icons/${n}${i?"_opened":""}.svg`:i?"/icons/default_folder_opened.svg":"/icons/default_folder.svg",alt:e,width:16,height:16,className:"size-4 shrink-0",unoptimized:!0})}function rc({nodes:e}){return e.map(e=>"directory"===e.type?(0,iN.jsx)(n3,{path:e.path,name:e.name,folderIcon:i=>(0,iN.jsx)(rl,{name:e.name,isOpen:i}),children:e.children&&(0,iN.jsx)(rc,{nodes:e.children})},e.path):(0,iN.jsx)(n6,{path:e.path,name:e.name,icon:(0,iN.jsx)(ra,{name:e.name})},e.path))}function rh({workspaceId:e}){let{tree:i,treeLoading:n,loadTree:r,openFile:s}=rt(),o=(0,n0.useTranslations)("editor"),[a,l]=(0,iM.useState)();(0,iM.useEffect)(()=>{r(e)},[e,r]);let c=async i=>{await fetch(`/api/workspaces/${e}/files?path=${encodeURIComponent(i)}`,{method:"DELETE"}),r(e)};return(0,iN.jsxs)("div",{className:"flex flex-col h-full",children:[(0,iN.jsxs)("div",{className:"flex items-center justify-between px-2 py-1.5 border-b text-xs font-medium text-muted-foreground",children:[(0,iN.jsx)("span",{children:o("explorer")}),(0,iN.jsx)("button",{onClick:()=>r(e),className:"p-0.5 hover:bg-accent rounded",disabled:n,children:(0,iN.jsx)(ri.RefreshCw,{className:`size-3 ${n?"animate-spin":""}`})})]}),(0,iN.jsxs)("div",{className:"flex-1 overflow-auto py-1",children:[0===i.length&&!n&&(0,iN.jsx)("div",{className:"px-2 py-4 text-xs text-muted-foreground text-center",children:o("noFiles")}),i.length>0&&(0,iN.jsx)(n2,{selectedPath:a,onFileSelect:i=>{l(i),s(e,i)},workspaceId:e,onDelete:c,children:(0,iN.jsx)(rc,{nodes:i})})]})]})}var rd=e.i(887836);e.i(462506);var ru=e.i(972846);function rp({workspaceId:e}){let{openFiles:i,activeFilePath:n,setActiveFile:r,closeFile:s,saveFile:o}=rt();return 0===i.length?null:(0,iN.jsx)("div",{className:"flex items-center border-b bg-muted/30 overflow-x-auto",children:i.map(i=>(0,iN.jsxs)("div",{className:`flex items-center gap-1 px-3 py-1.5 text-xs border-r cursor-pointer shrink-0 ${i.path===n?"bg-background text-foreground":"text-muted-foreground hover:bg-accent"}`,onClick:()=>r(i.path),children:[i.modified&&(0,iN.jsx)("span",{className:"size-1.5 rounded-full bg-orange-400 shrink-0"}),(0,iN.jsx)("span",{className:"truncate max-w-32",children:i.name}),(0,iN.jsx)("button",{className:"ml-1 hover:bg-accent rounded p-0.5",onClick:n=>{n.stopPropagation(),i.modified&&o(e,i.path),s(i.path)},children:(0,iN.jsx)(ru.X,{className:"size-3"})})]},i.path))})}var rf=e.i(950396);function rm(){let e=(0,n0.useTranslations)("editor");return(0,iN.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:e("loadingEditor")})}navigator.clipboard?.write||Object.defineProperty(navigator,"clipboard",{value:{...navigator.clipboard,writeText:navigator.clipboard?.writeText??(e=>Promise.resolve()),write:e=>{let i=e[0]?.getType("text/plain");return i?i.then(e=>e.text()).then(e=>navigator.clipboard.writeText(e)):Promise.resolve()}},writable:!0,configurable:!0});let rg=(0,rd.default)(()=>e.A(863812).then(e=>e.default),{loadableGenerated:{modules:[158480]},ssr:!1,loading:()=>(0,iN.jsx)(rm,{})});function rv({workspaceId:e}){var i;let{openFiles:n,activeFilePath:r,updateContent:s,saveFile:o}=rt(),{resolvedTheme:a}=(0,rf.useTheme)(),l=(0,n0.useTranslations)("editor"),c=n.find(e=>e.path===r);return(0,iN.jsxs)("div",{className:"flex flex-col h-full",children:[(0,iN.jsx)(rp,{workspaceId:e}),(0,iN.jsx)("div",{className:"flex-1 min-h-0",children:c?(0,iN.jsx)(rg,{height:"100%",language:(i=c.path,({ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",json:"json",md:"markdown",css:"css",html:"html",yaml:"yaml",yml:"yaml",py:"python",rs:"rust",go:"go",sql:"sql",sh:"shell",bash:"shell"})[i.split(".").pop()?.toLowerCase()||""]||"plaintext"),value:c.content,onChange:e=>s(c.path,e||""),onMount:i=>{i.addCommand(2097,()=>void(r&&o(e,r)))},options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,padding:{top:8},renderLineHighlight:"gutter"},theme:"dark"===a?"vs-dark":"vs"}):(0,iN.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:l("openFileToEdit")})})]})}var ry=e.i(953700),r_=e.i(650654),rb=e.i(992764);let rx=(0,nL.default)("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]);var rw=e.i(962562),rS=e.i(887354),rk=e.i(193251);let rC=(0,nL.default)("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);var rT=e.i(917955),rE=e.i(209988),rN=e.i(996652);let rM=(0,re.create)((e,i)=>({sessions:[],activeId:null,ws:null,_initialized:!1,init:n=>{let r=i();r._initialized&&r.ws===n||(e({ws:n,_initialized:!0}),n.on("terminal.created",i=>{let{sessionId:n,cwd:r,shell:s}=i;e(e=>e.sessions.some(e=>e.id===n)?e:{sessions:[...e.sessions,{id:n,cwd:r,shell:s}],activeId:n})}),n.on("terminal.closed",i=>{let{sessionId:n}=i;e(e=>{let i=e.sessions.filter(e=>e.id!==n),r=e.activeId===n?i[0]?.id??null:e.activeId;return{sessions:i,activeId:r}})}))},createSession:(e,n)=>{let{ws:r}=i();r?.send("terminal.create",{sessionId:crypto.randomUUID?.()??crypto.getRandomValues(new Uint8Array(16)).reduce((e,i)=>e+i.toString(16).padStart(2,"0"),""),shell:e,cwd:n})},setActive:i=>e({activeId:i}),setSessionName:(i,n)=>e(e=>({sessions:e.sessions.map(e=>e.id===i?{...e,name:n}:e)})),removeSession:n=>{let{ws:r,sessions:s,activeId:o}=i();r?.send("terminal.close",{sessionId:n});let a=s.filter(e=>e.id!==n),l=o===n?a[0]?.id??null:o;e({sessions:a,activeId:l})},sendInput:(e,n)=>{i().ws?.send("terminal.input",{sessionId:e,data:n})},resize:(e,n,r)=>{i().ws?.send("terminal.resize",{sessionId:e,cols:n,rows:r})}}));var rO=e.i(437122),rA=e.i(523592);class rR{workspaceId;ws;handlers;reconnectTimer;url;constructor(e){this.workspaceId=e,this.ws=null,this.handlers=new Map,this.reconnectTimer=null;const i=(0,rA.getActiveServerUrl)(),n=(0,rO.getToken)(),r=new URL("/ws",i??window.location.origin);r.protocol="https:"===r.protocol?"wss:":"ws:",r.searchParams.set("workspaceId",e),n&&r.searchParams.set("token",n),this.url=r.toString()}connect(){this.ws=new WebSocket(this.url),this.ws.onopen=()=>{console.log("[WS] connected")},this.ws.onmessage=e=>{try{let i=JSON.parse(e.data),n=this.handlers.get(i.event);if(n)for(let e of n)e(i.data)}catch{console.error("[WS] parse error")}},this.ws.onclose=e=>{console.log(`[WS] disconnected (${e.code}${e.reason?`: ${e.reason}`:""}), reconnecting...`),this.reconnectTimer=setTimeout(()=>this.connect(),3e3)},this.ws.onerror=()=>{this.ws?.close()}}disconnect(){this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.ws?.close(),this.ws=null}send(e,i){this.ws?.readyState===WebSocket.OPEN&&this.ws.send(JSON.stringify({event:e,data:i}))}on(e,i){return this.handlers.has(e)||this.handlers.set(e,new Set),this.handlers.get(e).add(i),()=>this.handlers.get(e)?.delete(i)}off(e,i){this.handlers.get(e)?.delete(i)}}let rD=null;function rL(e){return rD&&rD.workspaceId!==e&&(rD.disconnect(),rD=null),rD||(rD=new rR(e)).connect(),rD}var rj=e.i(360112);let rI=(0,re.create)((e,i)=>({commands:[],runningMap:{},loaded:!1,wsAttached:!1,load:async n=>{let[r,s]=await Promise.all([(0,rO.fetchWithAuth)(`/api/workspaces/${n}/commands`),(0,rO.fetchWithAuth)(`/api/workspaces/${n}/commands/processes`)]),o=await r.json(),a=await s.json(),l={};for(let e of a)l[e.commandId]={sessionId:e.sessionId,status:e.status};e({commands:o,runningMap:l,loaded:!0}),i().attachWS(n)},create:async(i,n)=>{let r=await (0,rO.fetchWithAuth)(`/api/workspaces/${i}/commands`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}),s=await r.json();e(e=>({commands:[...e.commands,s]}))},update:async(i,n,r)=>{let s=await (0,rO.fetchWithAuth)(`/api/workspaces/${i}/commands/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}),o=await s.json();e(e=>({commands:e.commands.map(e=>e.id===n?o:e)}))},remove:async(i,n)=>{await (0,rO.fetchWithAuth)(`/api/workspaces/${i}/commands/${n}`,{method:"DELETE"}),e(e=>({commands:e.commands.filter(e=>e.id!==n),runningMap:Object.fromEntries(Object.entries(e.runningMap).filter(([e])=>e!==n))}))},run:async(e,i)=>{try{let n=await (0,rO.fetchWithAuth)(`/api/workspaces/${e}/commands/${i}/run`,{method:"POST"});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||"Failed to run command")}}catch(e){throw rj.toast.error(e.message||"Failed to run command"),e}},stop:async(e,i)=>{try{let n=await (0,rO.fetchWithAuth)(`/api/workspaces/${e}/commands/${i}/stop`,{method:"POST"});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||"Failed to stop command")}}catch(e){throw rj.toast.error(e.message||"Failed to stop command"),e}},attachWS:n=>{if(i().wsAttached)return;let r=rL(n);r.on("command.started",n=>{let{commandId:r,sessionId:s}=n,o=i().commands.find(e=>e.id===r);o&&rM.getState().setSessionName(s,o.name),e(e=>({runningMap:{...e.runningMap,[r]:{sessionId:s,status:"running"}}}))}),r.on("command.stopped",i=>{let{commandId:n}=i;e(e=>{let{[n]:i,...r}=e.runningMap;return{runningMap:r}})}),r.on("command.restarted",i=>{let{commandId:n,sessionId:r}=i;e(e=>({runningMap:{...e.runningMap,[n]:{sessionId:r,status:"running"}}}))}),r.on("terminal.closed",i=>{let{sessionId:n}=i;e(e=>{let i=Object.fromEntries(Object.entries(e.runningMap).filter(([e,i])=>i.sessionId!==n));return Object.keys(i).length===Object.keys(e.runningMap).length?e:{runningMap:i}})}),e({wsAttached:!0})},isRunning:e=>!!i().runningMap[e]}));var rP=e.i(8890),rB=Object.defineProperty,rz=Object.getOwnPropertyDescriptor,rF=(e,i,n,r)=>{for(var s,o=r>1?void 0:r?rz(i,n):i,a=e.length-1;a>=0;a--)(s=e[a])&&(o=(r?s(i,n,o):s(o))||o);return r&&o&&rB(i,n,o),o},rW=(e,i)=>(n,r)=>i(n,r,e),rH="Terminal input",r$="Too much output to announce, navigate to rows manually to read";function rU(e,i,n,r){var s;s=e=e.replace(/\r?\n/g,"\r"),e=n.decPrivateModes.bracketedPasteMode&&!0!==r.rawOptions.ignoreBracketedPasteMode?"\x1b[200~"+s+"\x1b[201~":s,n.triggerDataEvent(e,!0),i.value=""}function rV(e,i,n){let r=n.getBoundingClientRect(),s=e.clientX-r.left-10,o=e.clientY-r.top-10;i.style.width="20px",i.style.height="20px",i.style.left=`${s}px`,i.style.top=`${o}px`,i.style.zIndex="1000",i.focus()}function rq(e,i,n,r,s){rV(e,i,n),s&&r.rightClickSelect(e),i.value=r.selectionText,i.select()}function rY(e){return e>65535?String.fromCharCode(((e-=65536)>>10)+55296)+String.fromCharCode(e%1024+56320):String.fromCharCode(e)}function rK(e,i=0,n=e.length){let r="";for(let s=i;s<n;++s){let i=e[s];i>65535?(i-=65536,r+=String.fromCharCode((i>>10)+55296)+String.fromCharCode(i%1024+56320)):r+=String.fromCharCode(i)}return r}var rX=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,i){let n=e.length;if(!n)return 0;let r=0,s=0;if(this._interim){let n=e.charCodeAt(s++);56320<=n&&n<=57343?i[r++]=(this._interim-55296)*1024+n-56320+65536:(i[r++]=this._interim,i[r++]=n),this._interim=0}for(let o=s;o<n;++o){let s=e.charCodeAt(o);if(55296<=s&&s<=56319){if(++o>=n)return this._interim=s,r;let a=e.charCodeAt(o);56320<=a&&a<=57343?i[r++]=(s-55296)*1024+a-56320+65536:(i[r++]=s,i[r++]=a);continue}65279!==s&&(i[r++]=s)}return r}},rJ=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,i){let n=e.length;if(!n)return 0;let r=0,s,o,a,l,c=0,h=0;if(this.interim[0]){let s=!1,o=this.interim[0];o&=(224&o)==192?31:(240&o)==224?15:7;let a=0,l;for(;(l=63&this.interim[++a])&&a<4;)o<<=6,o|=l;let c=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,d=c-a;for(;h<d;){if(h>=n)return 0;if((192&(l=e[h++]))!=128){h--,s=!0;break}this.interim[a++]=l,o<<=6,o|=63&l}s||(2===c?o<128?h--:i[r++]=o:3===c?o<2048||o>=55296&&o<=57343||65279===o||(i[r++]=o):o<65536||o>1114111||(i[r++]=o)),this.interim.fill(0)}let d=n-4,u=h;for(;u<n;){for(;u<d&&!(128&(s=e[u]))&&!(128&(o=e[u+1]))&&!(128&(a=e[u+2]))&&!(128&(l=e[u+3]));)i[r++]=s,i[r++]=o,i[r++]=a,i[r++]=l,u+=4;if((s=e[u++])<128)i[r++]=s;else if((224&s)==192){if(u>=n)return this.interim[0]=s,r;if((192&(o=e[u++]))!=128||(c=(31&s)<<6|63&o)<128){u--;continue}i[r++]=c}else if((240&s)==224){if(u>=n)return this.interim[0]=s,r;if((192&(o=e[u++]))!=128){u--;continue}if(u>=n)return this.interim[0]=s,this.interim[1]=o,r;if((192&(a=e[u++]))!=128){u--;continue}if((c=(15&s)<<12|(63&o)<<6|63&a)<2048||c>=55296&&c<=57343||65279===c)continue;i[r++]=c}else if((248&s)==240){if(u>=n)return this.interim[0]=s,r;if((192&(o=e[u++]))!=128){u--;continue}if(u>=n)return this.interim[0]=s,this.interim[1]=o,r;if((192&(a=e[u++]))!=128){u--;continue}if(u>=n)return this.interim[0]=s,this.interim[1]=o,this.interim[2]=a,r;if((192&(l=e[u++]))!=128){u--;continue}if((c=(7&s)<<18|(63&o)<<12|(63&a)<<6|63&l)<65536||c>1114111)continue;i[r++]=c}}return r}},rG=class e{constructor(){this.fg=0,this.bg=0,this.extended=new rZ}static toColorRGB(e){return[e>>>16&255,e>>>8&255,255&e]}static fromColorRGB(e){return(255&e[0])<<16|(255&e[1])<<8|255&e[2]}clone(){let i=new e;return i.fg=this.fg,i.bg=this.bg,i.extended=this.extended.clone(),i}isInverse(){return 0x4000000&this.fg}isBold(){return 0x8000000&this.fg}isUnderline(){return this.hasExtendedAttrs()&&0!==this.extended.underlineStyle?1:0x10000000&this.fg}isBlink(){return 0x20000000&this.fg}isInvisible(){return 0x40000000&this.fg}isItalic(){return 0x4000000&this.bg}isDim(){return 0x8000000&this.bg}isStrikethrough(){return 0x80000000&this.fg}isProtected(){return 0x20000000&this.bg}isOverline(){return 0x40000000&this.bg}getFgColorMode(){return 0x3000000&this.fg}getBgColorMode(){return 0x3000000&this.bg}isFgRGB(){return(0x3000000&this.fg)==0x3000000}isBgRGB(){return(0x3000000&this.bg)==0x3000000}isFgPalette(){return(0x3000000&this.fg)==0x1000000||(0x3000000&this.fg)==0x2000000}isBgPalette(){return(0x3000000&this.bg)==0x1000000||(0x3000000&this.bg)==0x2000000}isFgDefault(){return(0x3000000&this.fg)==0}isBgDefault(){return(0x3000000&this.bg)==0}isAttributeDefault(){return 0===this.fg&&0===this.bg}getFgColor(){switch(0x3000000&this.fg){case 0x1000000:case 0x2000000:return 255&this.fg;case 0x3000000:return 0xffffff&this.fg;default:return -1}}getBgColor(){switch(0x3000000&this.bg){case 0x1000000:case 0x2000000:return 255&this.bg;case 0x3000000:return 0xffffff&this.bg;default:return -1}}hasExtendedAttrs(){return 0x10000000&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-0x10000001:this.bg|=0x10000000}getUnderlineColor(){if(0x10000000&this.bg&&~this.extended.underlineColor)switch(0x3000000&this.extended.underlineColor){case 0x1000000:case 0x2000000:return 255&this.extended.underlineColor;case 0x3000000:return 0xffffff&this.extended.underlineColor}return this.getFgColor()}getUnderlineColorMode(){return 0x10000000&this.bg&&~this.extended.underlineColor?0x3000000&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 0x10000000&this.bg&&~this.extended.underlineColor?(0x3000000&this.extended.underlineColor)==0x3000000:this.isFgRGB()}isUnderlineColorPalette(){return 0x10000000&this.bg&&~this.extended.underlineColor?(0x3000000&this.extended.underlineColor)==0x1000000||(0x3000000&this.extended.underlineColor)==0x2000000:this.isFgPalette()}isUnderlineColorDefault(){return 0x10000000&this.bg&&~this.extended.underlineColor?(0x3000000&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 0x10000000&this.fg?0x10000000&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},rZ=class e{constructor(e=0,i=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=i}get ext(){return this._urlId?-0x1c000001&this._ext|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(0x1c000000&this._ext)>>26}set underlineStyle(e){this._ext&=-0x1c000001,this._ext|=e<<26&0x1c000000}get underlineColor(){return 0x3ffffff&this._ext}set underlineColor(e){this._ext&=-0x4000000,this._ext|=0x3ffffff&e}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(0xe0000000&this._ext)>>29;return e<0?0xfffffff8^e:e}set underlineVariantOffset(e){this._ext&=0x1fffffff,this._ext|=e<<29&0xe0000000}clone(){return new e(this._ext,this._urlId)}isEmpty(){return 0===this.underlineStyle&&0===this._urlId}},rQ=class e extends rG{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new rZ,this.combinedData=""}static fromCharData(i){let n=new e;return n.setFromCharData(i),n}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?rY(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(e){this.fg=e[0],this.bg=0;let i=!1;if(e[1].length>2)i=!0;else if(2===e[1].length){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:i=!0}else i=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;i&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},r0="di$target",r1="di$dependencies",r2=new Map;function r5(e){if(r2.has(e))return r2.get(e);let i=function(e,n,r){var s,o,a;if(3!=arguments.length)throw Error("@IServiceName-decorator can only be used to decorate a parameter");s=i,o=e,a=r,o[r0]===o?o[r1].push({id:s,index:a}):(o[r1]=[{id:s,index:a}],o[r0]=o)};return i._id=e,r2.set(e,i),i}var r3=r5("BufferService"),r4=r5("CoreMouseService"),r6=r5("CoreService"),r8=r5("CharsetService"),r9=r5("InstantiationService"),r7=r5("LogService"),se=r5("OptionsService"),st=r5("OscLinkService"),si=r5("UnicodeService"),sn=r5("DecorationService"),sr=class{constructor(e,i,n){this._bufferService=e,this._optionsService=i,this._oscLinkService=n}provideLinks(e,i){let n=this._bufferService.buffer.lines.get(e-1);if(!n)return void i(void 0);let r=[],s=this._optionsService.rawOptions.linkHandler,o=new rQ,a=n.getTrimmedLength(),l=-1,c=-1,h=!1;for(let i=0;i<a;i++)if(!(-1===c&&!n.hasContent(i))){if(n.loadCell(i,o),o.hasExtendedAttrs()&&o.extended.urlId)if(-1===c){c=i,l=o.extended.urlId;continue}else h=o.extended.urlId!==l;else -1!==c&&(h=!0);if(h||-1!==c&&i===a-1){let n=this._oscLinkService.getLinkData(l)?.uri;if(n){let o={start:{x:c+1,y:e},end:{x:i+ +(!h&&i===a-1),y:e}},l=!1;if(!s?.allowNonHttpProtocols)try{let e=new URL(n);["http:","https:"].includes(e.protocol)||(l=!0)}catch{l=!0}l||r.push({text:n,range:o,activate:(e,i)=>s?s.activate(e,i,o):function(e){if(confirm(`Do you want to navigate to ${e}?
|
|
6
|
+
|
|
7
|
+
WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=e}else console.warn("Opening link blocked as opener could not be cleared")}}(i),hover:(e,i)=>s?.hover?.(e,i,o),leave:(e,i)=>s?.leave?.(e,i,o)})}h=!1,o.hasExtendedAttrs()&&o.extended.urlId?(c=i,l=o.extended.urlId):(c=-1,l=-1)}}i(r)}};sr=rF([rW(0,r3),rW(1,se),rW(2,st)],sr);var ss=r5("CharSizeService"),so=r5("CoreBrowserService"),sa=r5("MouseService"),sl=r5("RenderService"),sc=r5("SelectionService"),sh=r5("CharacterJoinerService"),sd=r5("ThemeService"),su=r5("LinkProviderService"),sp=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?sv.isErrorNoTelemetry(e)?new sv(e.message+`
|
|
8
|
+
|
|
9
|
+
`+e.stack):Error(e.message+`
|
|
10
|
+
|
|
11
|
+
`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(i=>{i(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}};function sf(e){var i;(i=e)instanceof sg||i instanceof Error&&i.name===sm&&i.message===sm||sp.onUnexpectedError(e)}var sm="Canceled",sg=class extends Error{constructor(){super(sm),this.name=this.message}},sv=class e extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(i){if(i instanceof e)return i;let n=new e;return n.message=i.message,n.stack=i.stack,n}static isErrorNoTelemetry(e){return"CodeExpectedError"===e.name}},sy=class e extends Error{constructor(i){super(i||"An unexpected bug occurred."),Object.setPrototypeOf(this,e.prototype)}};function s_(e,i=0){return e[e.length-(1+i)]}(sW=sH||={}).isLessThan=function(e){return e<0},sW.isLessThanOrEqual=function(e){return e<=0},sW.isGreaterThan=function(e){return e>0},sW.isNeitherLessOrGreaterThan=function(e){return 0===e},sW.greaterThan=1,sW.lessThan=-1,sW.neitherLessOrGreaterThan=0;var sb=class e{constructor(e){this.iterate=e}forEach(e){this.iterate(i=>(e(i),!0))}toArray(){let e=[];return this.iterate(i=>(e.push(i),!0)),e}filter(i){return new e(e=>this.iterate(n=>!i(n)||e(n)))}map(i){return new e(e=>this.iterate(n=>e(i(n))))}some(e){let i=!1;return this.iterate(n=>!(i=e(n))),i}findFirst(e){let i;return this.iterate(n=>!e(n)||(i=n,!1)),i}findLast(e){let i;return this.iterate(n=>(e(n)&&(i=n),!0)),i}findLastMaxBy(e){let i,n=!0;return this.iterate(r=>((n||sH.isGreaterThan(e(r,i)))&&(n=!1,i=r),!0)),i}};sb.empty=new sb(e=>{});function sx(e){}function sw(e,i){}function sS(e){if(s$.is(e)){let i=[];for(let n of e)if(n)try{n.dispose()}catch(e){i.push(e)}if(1===i.length)throw i[0];if(i.length>1)throw AggregateError(i,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}function sk(e){let i={dispose:function(e,i){let n=this,r=!1,s;return function(){if(r)return s;if(r=!0,i)try{s=e.apply(n,arguments)}finally{i()}else s=e.apply(n,arguments);return s}}(()=>{sx(i),e()})};return i}(e=>{function i(e){return e&&"object"==typeof e&&"function"==typeof e[Symbol.iterator]}e.is=i;let n=Object.freeze([]);function*r(e){yield e}e.empty=function(){return n},e.single=r,e.wrap=function(e){return i(e)?e:r(e)},e.from=function(e){return e||n},e.reverse=function*(e){for(let i=e.length-1;i>=0;i--)yield e[i]},e.isEmpty=function(e){return!e||!0===e[Symbol.iterator]().next().done},e.first=function(e){return e[Symbol.iterator]().next().value},e.some=function(e,i){let n=0;for(let r of e)if(i(r,n++))return!0;return!1},e.find=function(e,i){for(let n of e)if(i(n))return n},e.filter=function*(e,i){for(let n of e)i(n)&&(yield n)},e.map=function*(e,i){let n=0;for(let r of e)yield i(r,n++)},e.flatMap=function*(e,i){let n=0;for(let r of e)yield*i(r,n++)},e.concat=function*(...e){for(let i of e)yield*i},e.reduce=function(e,i,n){let r=n;for(let n of e)r=i(r,n);return r},e.slice=function*(e,i,n=e.length){for(i<0&&(i+=e.length),n<0?n+=e.length:n>e.length&&(n=e.length);i<n;i++)yield e[i]},e.consume=function(i,n=1/0){let r=[];if(0===n)return[r,i];let s=i[Symbol.iterator]();for(let i=0;i<n;i++){let i=s.next();if(i.done)return[r,e.empty()];r.push(i.value)}return[r,{[Symbol.iterator]:()=>s}]},e.asyncToArray=async function(e){let i=[];for await(let n of e)i.push(n);return Promise.resolve(i)}})(s$||={});var sC=class e{constructor(){var e;this._toDispose=new Set,this._isDisposed=!1,e=this}dispose(){this._isDisposed||(sx(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(0!==this._toDispose.size)try{sS(this._toDispose)}finally{this._toDispose.clear()}}add(i){if(!i)return i;if(i===this)throw Error("Cannot register a disposable on itself!");return sw(i,this),this._isDisposed?e.DISABLE_DISPOSED_WARNING||console.warn(Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(i),i}delete(e){if(e){if(e===this)throw Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),sw(e,null))}};sC.DISABLE_DISPOSED_WARNING=!1;var sT=sC,sE=class{constructor(){var e;this._store=new sT,e=this,sw(this._store,this)}dispose(){sx(this),this._store.dispose()}_register(e){if(e===this)throw Error("Cannot register a disposable on itself!");return this._store.add(e)}};sE.None=Object.freeze({dispose(){}});var sN=class{constructor(){var e;this._isDisposed=!1,e=this}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&sw(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,sx(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&sw(e,null),e}},sM="object"==typeof window?window:globalThis,sO=class e{constructor(i){this.element=i,this.next=e.Undefined,this.prev=e.Undefined}};sO.Undefined=new sO(void 0);var sA=class{constructor(){this._first=sO.Undefined,this._last=sO.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===sO.Undefined}clear(){let e=this._first;for(;e!==sO.Undefined;){let i=e.next;e.prev=sO.Undefined,e.next=sO.Undefined,e=i}this._first=sO.Undefined,this._last=sO.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,i){let n=new sO(e);if(this._first===sO.Undefined)this._first=n,this._last=n;else if(i){let e=this._last;this._last=n,n.prev=e,e.next=n}else{let e=this._first;this._first=n,n.next=e,e.prev=n}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(n))}}shift(){if(this._first!==sO.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==sO.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==sO.Undefined&&e.next!==sO.Undefined){let i=e.prev;i.next=e.next,e.next.prev=i}else e.prev===sO.Undefined&&e.next===sO.Undefined?(this._first=sO.Undefined,this._last=sO.Undefined):e.next===sO.Undefined?(this._last=this._last.prev,this._last.next=sO.Undefined):e.prev===sO.Undefined&&(this._first=this._first.next,this._first.prev=sO.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==sO.Undefined;)yield e.element,e=e.next}},sR=globalThis.performance&&"function"==typeof globalThis.performance.now,sD=class e{static create(i){return new e(i)}constructor(e){this._now=sR&&!1===e?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return -1!==this._stopTime?this._stopTime-this._startTime:this._now()-this._startTime}};(e=>{function i(e){}function n(e){return(i,n=null,r)=>{let s=!1,o;return o=e(e=>{if(!s)return o?o.dispose():s=!0,i.call(n,e)},null,r),s&&o.dispose(),o}}function r(e,i,n){return o((n,r=null,s)=>e(e=>n.call(r,i(e)),null,s),n)}function s(e,i,n){return o((n,r=null,s)=>e(e=>i(e)&&n.call(r,e),null,s),n)}function o(e,n){let r,s={onWillAddFirstListener(){r=e(o.fire,o)},onDidRemoveLastListener(){r?.dispose()}};n||i(s);let o=new sG(s);return n?.add(o),o.event}function a(e,n,r=100,s=!1,o=!1,l,c){let h,d,u,p=0,f,m={leakWarningThreshold:l,onWillAddFirstListener(){h=e(e=>{p++,d=n(d,e),s&&!u&&(g.fire(d),d=void 0),f=()=>{let e=d;d=void 0,u=void 0,(!s||p>1)&&g.fire(e),p=0},"number"==typeof r?(clearTimeout(u),u=setTimeout(f,r)):void 0===u&&(u=0,queueMicrotask(f))})},onWillRemoveListener(){o&&p>0&&f?.()},onDidRemoveLastListener(){f=void 0,h.dispose()}};c||i(m);let g=new sG(m);return c?.add(g),g.event}e.None=()=>sE.None,e.defer=function(e,i){return a(e,()=>{},0,void 0,!0,void 0,i)},e.once=n,e.map=r,e.forEach=function(e,i,n){return o((n,r=null,s)=>e(e=>{i(e),n.call(r,e)},null,s),n)},e.filter=s,e.signal=function(e){return e},e.any=function(...e){return(i,n=null,r)=>{var s,o;return s=function(...e){let i=sk(()=>sS(e));return i}(...e.map(e=>e(e=>i.call(n,e)))),(o=r)instanceof Array?o.push(s):o&&o.add(s),s}},e.reduce=function(e,i,n,s){let o=n;return r(e,e=>o=i(o,e),s)},e.debounce=a,e.accumulate=function(i,n=0,r){return e.debounce(i,(e,i)=>e?(e.push(i),e):[i],n,void 0,!0,void 0,r)},e.latch=function(e,i=(e,i)=>e===i,n){let r=!0,o;return s(e,e=>{let n=r||!i(e,o);return r=!1,o=e,n},n)},e.split=function(i,n,r){return[e.filter(i,n,r),e.filter(i,e=>!n(e),r)]},e.buffer=function(e,i=!1,n=[],r){let s=n.slice(),o=e(e=>{s?s.push(e):l.fire(e)});r&&r.add(o);let a=()=>{s?.forEach(e=>l.fire(e)),s=null},l=new sG({onWillAddFirstListener(){o||(o=e(e=>l.fire(e)),r&&r.add(o))},onDidAddFirstListener(){s&&(i?setTimeout(a):a())},onDidRemoveLastListener(){o&&o.dispose(),o=null}});return r&&r.add(l),l.event},e.chain=function(e,i){return(n,r,s)=>{let o=i(new c);return e(function(e){let i=o.evaluate(e);i!==l&&n.call(r,i)},void 0,s)}};let l=Symbol("HaltChainable");class c{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(i=>(e(i),i)),this}filter(e){return this.steps.push(i=>e(i)?i:l),this}reduce(e,i){let n=i;return this.steps.push(i=>n=e(n,i)),this}latch(e=(e,i)=>e===i){let i=!0,n;return this.steps.push(r=>{let s=i||!e(r,n);return i=!1,n=r,s?r:l}),this}evaluate(e){for(let i of this.steps)if((e=i(e))===l)break;return e}}e.fromNodeEventEmitter=function(e,i,n=e=>e){let r=(...e)=>s.fire(n(...e)),s=new sG({onWillAddFirstListener:()=>e.on(i,r),onDidRemoveLastListener:()=>e.removeListener(i,r)});return s.event},e.fromDOMEventEmitter=function(e,i,n=e=>e){let r=(...e)=>s.fire(n(...e)),s=new sG({onWillAddFirstListener:()=>e.addEventListener(i,r),onDidRemoveLastListener:()=>e.removeEventListener(i,r)});return s.event},e.toPromise=function(e){return new Promise(i=>n(e)(i))},e.fromPromise=function(e){let i=new sG;return e.then(e=>{i.fire(e)},()=>{i.fire(void 0)}).finally(()=>{i.dispose()}),i.event},e.forward=function(e,i){return e(e=>i.fire(e))},e.runAndSubscribe=function(e,i,n){return i(n),e(e=>i(e))};class h{constructor(e,n){this._observable=e,this._counter=0,this._hasChanged=!1;let r={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};n||i(r),this.emitter=new sG(r),n&&n.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,i){this._hasChanged=!0}endUpdate(e){this._counter--,0===this._counter&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}e.fromObservable=function(e,i){return new h(e,i).emitter.event},e.fromObservableLight=function(e){return(i,n,r)=>{let s=0,o=!1,a={beginUpdate(){s++},endUpdate(){0==--s&&(e.reportChanges(),o&&(o=!1,i.call(n)))},handlePossibleChange(){},handleChange(){o=!0}};e.addObserver(a),e.reportChanges();let l={dispose(){e.removeObserver(a)}};return r instanceof sT?r.add(l):Array.isArray(r)&&r.push(l),l}}})(sU||={});var sL=class e{constructor(i){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${i}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new sD,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};sL.all=new Set,sL._idPool=0;var sj=class e{constructor(i,n,r=(e._idPool++).toString(16).padStart(3,"0")){this._errorHandler=i,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,i){let n=this.threshold;if(n<=0||i<n)return;this._stacks||(this._stacks=new Map);let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=.5*n;let[e,r]=this.getMostFrequentStack(),s=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${r}):`;console.warn(s),console.warn(e);let o=new sY(s,e);this._errorHandler(o)}return()=>{let i=this._stacks.get(e.value)||0;this._stacks.set(e.value,i-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,i=0;for(let[n,r]of this._stacks)(!e||i<r)&&(e=[n,r],i=r);return e}};sj._idPool=1;var sI,sP,sB,sz,sF,sW,sH,s$,sU,sV,sq=class e{constructor(e){this.value=e}static create(){return new e(Error().stack??"")}print(){console.warn(this.value.split(`
|
|
12
|
+
`).slice(2).join(`
|
|
13
|
+
`))}},sY=class extends Error{constructor(e,i){super(e),this.name="ListenerLeakError",this.stack=i}},sK=class extends Error{constructor(e,i){super(e),this.name="ListenerRefusalError",this.stack=i}},sX=0,sJ=class{constructor(e){this.value=e,this.id=sX++}},sG=class{constructor(e){this._size=0,this._options=e,this._leakageMon=this._options?.leakWarningThreshold?new sj(e?.onListenerError??sf,this._options?.leakWarningThreshold??-1):void 0,this._perfMon=this._options?._profName?new sL(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,i,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let i=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],n=new sK(`${e}. HINT: Stack shows most frequent listener (${i[1]}-times)`,i[0]);return(this._options?.onListenerError||sf)(n),sE.None}if(this._disposed)return sE.None;i&&(e=e.bind(i));let r=new sJ(e),s;this._leakageMon&&this._size>=Math.ceil(.2*this._leakageMon.threshold)&&(r.stack=sq.create(),s=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof sJ?(this._deliveryQueue??=new sZ,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let o=sk(()=>{sV?.unregister(o),s?.(),this._removeListener(r)});if(n instanceof sT?n.add(o):Array.isArray(n)&&n.push(o),sV){let e=Error().stack.split(`
|
|
14
|
+
`).slice(2,3).join(`
|
|
15
|
+
`).trim(),i=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(e);sV.register(o,i?.[2]??e,o)}return o},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(1===this._size){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let i=this._listeners,n=i.indexOf(e);if(-1===n)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),Error("Attempted to dispose unknown listener");this._size--,i[n]=void 0;let r=this._deliveryQueue.current===this;if(2*this._size<=i.length){let e=0;for(let n=0;n<i.length;n++)i[n]?i[e++]=i[n]:r&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);i.length=e}}_deliver(e,i){if(!e)return;let n=this._options?.onListenerError||sf;try{e.value(i)}catch(e){n(e)}}_deliverQueue(e){let i=e.current._listeners;for(;e.i<e.end;)this._deliver(i[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof sJ)this._deliver(this._listeners,e);else{let i=this._deliveryQueue;i.enqueue(this,e,this._listeners.length),this._deliverQueue(i)}this._perfMon?.stop()}hasListeners(){return this._size>0}},sZ=class{constructor(){this.i=-1,this.end=0}enqueue(e,i,n){this.i=0,this.end=n,this.current=e,this.value=i}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},sQ=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new sG,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new sG,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,i){if(this.getZoomLevel(i)===e)return;let n=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(n,e),this._onDidChangeZoomLevel.fire(n)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,i){this.mapWindowIdToZoomFactor.set(this.getWindowId(i),e)}setFullscreen(e,i){if(this.isFullscreen(i)===e)return;let n=this.getWindowId(i);this.mapWindowIdToFullScreen.set(n,e),this._onDidChangeFullscreen.fire(n)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};sQ.INSTANCE=new sQ,sQ.INSTANCE.onDidChangeZoomLevel,sQ.INSTANCE.onDidChangeFullscreen;var s0="object"==typeof navigator?navigator.userAgent:"",s1=s0.indexOf("Firefox")>=0,s2=s0.indexOf("AppleWebKit")>=0,s5=s0.indexOf("Chrome")>=0,s3=!s5&&s0.indexOf("Safari")>=0;s0.indexOf("Electron/"),s0.indexOf("Android");var s4=!1;if("function"==typeof sM.matchMedia){let e=sM.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),i=sM.matchMedia("(display-mode: fullscreen)");s4=e.matches,s6=e,"string"==typeof s6&&(s6=sM.matchMedia(s6)),s6.addEventListener("change",({matches:e})=>{s4&&i.matches||(s4=e)})}var s6,s8,s9,s7=!1,oe=!1,ot=!1,oi=!1,on=!1,or="en",oo=globalThis;"u">typeof oo.vscode&&"u">typeof oo.vscode.process?s9=oo.vscode.process:"u">typeof rP.default&&"string"==typeof rP.default?.versions?.node&&(s9=rP.default);var oa="string"==typeof s9?.versions?.electron&&s9?.type==="renderer";if("object"==typeof s9){s7="win32"===s9.platform,oe="darwin"===s9.platform,(ot="linux"===s9.platform)&&s9.env.SNAP&&s9.env.SNAP_REVISION,s9.env.CI||s9.env.BUILD_ARTIFACTSTAGINGDIRECTORY,or="en";let e=s9.env.VSCODE_NLS_CONFIG;if(e)try{let i=JSON.parse(e);i.userLocale,i.osLocale,or=i.resolvedLanguage||"en",i.languagePack?.translationsConfigFile}catch{}oi=!0}else"object"!=typeof navigator||oa?console.error("Unable to resolve platform."):(s7=(s8=navigator.userAgent).indexOf("Windows")>=0,oe=s8.indexOf("Macintosh")>=0,(s8.indexOf("Macintosh")>=0||s8.indexOf("iPad")>=0||s8.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,ot=s8.indexOf("Linux")>=0,s8?.indexOf("Mobi"),on=!0,or=globalThis._VSCODE_NLS_LANGUAGE||"en",navigator.language.toLowerCase());var ol=s7,oc=oe,oh=ot,od=oi;on&&"function"==typeof oo.importScripts&&oo.origin;var ou,op=s8,of=or;(ok=ou||={}).value=function(){return of},ok.isDefaultVariant=function(){return 2===of.length?"en"===of:of.length>=3&&"e"===of[0]&&"n"===of[1]&&"-"===of[2]},ok.isDefault=function(){return"en"===of};var om="function"==typeof oo.postMessage&&!oo.importScripts,og=(()=>{if(om){let e=[];oo.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let n=0,r=e.length;n<r;n++){let r=e[n];if(r.id===i.data.vscodeScheduleAsyncWork){e.splice(n,1),r.callback();return}}});let i=0;return n=>{let r=++i;e.push({id:r,callback:n}),oo.postMessage({vscodeScheduleAsyncWork:r},"*")}}return e=>setTimeout(e)})(),ov=!!(op&&op.indexOf("Chrome")>=0);op&&op.indexOf("Firefox"),!ov&&op&&op.indexOf("Safari"),op&&op.indexOf("Edg/"),op&&op.indexOf("Android");var oy="object"==typeof navigator?navigator:{};od||document.queryCommandSupported&&document.queryCommandSupported("copy")||oy&&oy.clipboard&&oy.clipboard.writeText,od||oy&&oy.clipboard&&oy.clipboard.readText,od||s4||oy.keyboard,"ontouchstart"in sM||oy.maxTouchPoints,sM.PointerEvent&&("ontouchstart"in sM||navigator.maxTouchPoints);var o_=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,i){this._keyCodeToStr[e]=i,this._strToKeyCode[i.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},ob=new o_,ox=new o_,ow=new o_,oS=Array(230);(oC=oT||={}).toString=function(e){return ob.keyCodeToStr(e)},oC.fromString=function(e){return ob.strToKeyCode(e)},oC.toUserSettingsUS=function(e){return ox.keyCodeToStr(e)},oC.toUserSettingsGeneral=function(e){return ow.keyCodeToStr(e)},oC.fromUserSettings=function(e){return ox.strToKeyCode(e)||ow.strToKeyCode(e)},oC.toElectronAccelerator=function(e){if(e>=98&&e<=113)return null;switch(e){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return ob.keyCodeToStr(e)};var ok,oC,oT,oE,oN=class e{constructor(e,i,n,r,s){this.ctrlKey=e,this.shiftKey=i,this.altKey=n,this.metaKey=r,this.keyCode=s}equals(i){return i instanceof e&&this.ctrlKey===i.ctrlKey&&this.shiftKey===i.shiftKey&&this.altKey===i.altKey&&this.metaKey===i.metaKey&&this.keyCode===i.keyCode}getHashCode(){let e=this.ctrlKey?"1":"0",i=this.shiftKey?"1":"0",n=this.altKey?"1":"0",r=this.metaKey?"1":"0";return`K${e}${i}${n}${r}${this.keyCode}`}isModifierKey(){return 0===this.keyCode||5===this.keyCode||57===this.keyCode||6===this.keyCode||4===this.keyCode}toKeybinding(){return new oM([this])}isDuplicateModifierCase(){return this.ctrlKey&&5===this.keyCode||this.shiftKey&&4===this.keyCode||this.altKey&&6===this.keyCode||this.metaKey&&57===this.keyCode}},oM=class{constructor(e){if(0===e.length)throw function(e){return e?Error(`Illegal argument: ${e}`):Error("Illegal argument")}("chords");this.chords=e}getHashCode(){let e="";for(let i=0,n=this.chords.length;i<n;i++)0!==i&&(e+=";"),e+=this.chords[i].getHashCode();return e}equals(e){if(null===e||this.chords.length!==e.chords.length)return!1;for(let i=0;i<this.chords.length;i++)if(!this.chords[i].equals(e.chords[i]))return!1;return!0}},oO=oc?256:2048,oA=oc?2048:256,oR=class{constructor(e){this._standardKeyboardEventBrand=!0,this.browserEvent=e,this.target=e.target,this.ctrlKey=e.ctrlKey,this.shiftKey=e.shiftKey,this.altKey=e.altKey,this.metaKey=e.metaKey,this.altGraphKey=e.getModifierState?.("AltGraph"),this.keyCode=function(e){if(e.charCode){let i=String.fromCharCode(e.charCode).toUpperCase();return oT.fromString(i)}let i=e.keyCode;if(3===i)return 7;if(s1)switch(i){case 59:return 85;case 60:if(oh)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(oc)return 57}else if(s2&&(oc&&93===i||!oc&&92===i))return 57;return oS[i]||0}(e),this.code=e.code,this.ctrlKey=this.ctrlKey||5===this.keyCode,this.altKey=this.altKey||6===this.keyCode,this.shiftKey=this.shiftKey||4===this.keyCode,this.metaKey=this.metaKey||57===this.keyCode,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;5!==this.keyCode&&4!==this.keyCode&&6!==this.keyCode&&57!==this.keyCode&&(e=this.keyCode);let i=0;return this.ctrlKey&&(i|=oO),this.altKey&&(i|=512),this.shiftKey&&(i|=1024),this.metaKey&&(i|=oA),i|=e}_computeKeyCodeChord(){let e=0;return 5!==this.keyCode&&4!==this.keyCode&&6!==this.keyCode&&57!==this.keyCode&&(e=this.keyCode),new oN(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},oD=new WeakMap,oL=class{static getSameOriginWindowChain(e){let i=oD.get(e);if(!i){i=[],oD.set(e,i);let n=e,r;do(r=function(e){if(!e.parent||e.parent===e)return null;try{let i=e.location,n=e.parent.location;if("null"!==i.origin&&"null"!==n.origin&&i.origin!==n.origin)return null}catch{return null}return e.parent}(n))?i.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):i.push({window:new WeakRef(n),iframeElement:null}),n=r;while(n)}return i.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,i){if(!i||e===i)return{top:0,left:0};let n=0,r=0;for(let s of this.getSameOriginWindowChain(e)){let e=s.window.deref();if(n+=e?.scrollY??0,r+=e?.scrollX??0,e===i||!s.iframeElement)break;let o=s.iframeElement.getBoundingClientRect();n+=o.top,r+=o.left}return{top:n,left:r}}},oj=class{constructor(e,i){this.timestamp=Date.now(),this.browserEvent=i,this.leftButton=0===i.button,this.middleButton=1===i.button,this.rightButton=2===i.button,this.buttons=i.buttons,this.target=i.target,this.detail=i.detail||1,"dblclick"===i.type&&(this.detail=2),this.ctrlKey=i.ctrlKey,this.shiftKey=i.shiftKey,this.altKey=i.altKey,this.metaKey=i.metaKey,"number"==typeof i.pageX?(this.posx=i.pageX,this.posy=i.pageY):(this.posx=i.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=i.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let n=oL.getPositionOfChildWindowRelativeToAncestorWindow(e,i.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},oI=class{constructor(e,i=0,n=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=n,this.deltaX=i;let r=!1;if(s5){let e=navigator.userAgent.match(/Chrome\/(\d+)/);r=(e?parseInt(e[1]):123)<=122}if(e){let i=e.view?.devicePixelRatio||1;"u">typeof e.wheelDeltaY?r?this.deltaY=e.wheelDeltaY/(120*i):this.deltaY=e.wheelDeltaY/120:"u">typeof e.VERTICAL_AXIS&&e.axis===e.VERTICAL_AXIS?this.deltaY=-e.detail/3:"wheel"===e.type&&(e.deltaMode===e.DOM_DELTA_LINE?s1&&!oc?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40),"u">typeof e.wheelDeltaX?s3&&ol?this.deltaX=-(e.wheelDeltaX/120):r?this.deltaX=e.wheelDeltaX/(120*i):this.deltaX=e.wheelDeltaX/120:"u">typeof e.HORIZONTAL_AXIS&&e.axis===e.HORIZONTAL_AXIS?this.deltaX=-e.detail/3:"wheel"===e.type&&(e.deltaMode===e.DOM_DELTA_LINE?s1&&!oc?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40),0===this.deltaY&&0===this.deltaX&&e.wheelDelta&&(r?this.deltaY=e.wheelDelta/(120*i):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},oP=Object.freeze(function(e,i){let n=setTimeout(e.bind(i),0);return{dispose(){clearTimeout(n)}}});(aE=oE||={}).isCancellationToken=function(e){return e===aE.None||e===aE.Cancelled||e instanceof oB||!!e&&"object"==typeof e&&"boolean"==typeof e.isCancellationRequested&&"function"==typeof e.onCancellationRequested},aE.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:sU.None}),aE.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:oP});var oB=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?oP:(this._emitter||(this._emitter=new sG),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}};Symbol("MicrotaskDelay");var oz=class{constructor(e,i){this._isDisposed=!1,this._token=-1,"function"==typeof e&&"number"==typeof i&&this.setIfNotSet(e,i)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){-1!==this._token&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,i){if(this._isDisposed)throw new sy("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},i)}setIfNotSet(e,i){if(this._isDisposed)throw new sy("Calling 'setIfNotSet' on a disposed TimeoutTimer");-1===this._token&&(this._token=setTimeout(()=>{this._token=-1,e()},i))}},oF=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,i,n=globalThis){if(this.isDisposed)throw new sy("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let r=n.setInterval(()=>{e()},i);this.disposable=sk(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(aN=aM||={}).settled=async function(e){let i,n=await Promise.all(e.map(e=>e.then(e=>e,e=>{i||(i=e)})));if("u">typeof i)throw i;return n},aN.withAsyncBody=function(e){return new Promise(async(i,n)=>{try{await e(i,n)}catch(e){n(e)}})};var oW=class e{static fromArray(i){return new e(e=>{e.emitMany(i)})}static fromPromise(i){return new e(async e=>{e.emitMany(await i)})}static fromPromises(i){return new e(async e=>{await Promise.all(i.map(async i=>e.emitOne(await i)))})}static merge(i){return new e(async e=>{await Promise.all(i.map(async i=>{for await(let n of i)e.emitOne(n)}))})}constructor(e,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new sG,queueMicrotask(async()=>{let i={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(i)),this.resolve()}catch(e){this.reject(e)}finally{i.emitOne=void 0,i.emitMany=void 0,i.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{for(;;){if(2===this._state)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(1===this._state)return{done:!0,value:void 0};await sU.toPromise(this._onStateChanged.event)}},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(i,n){return new e(async e=>{for await(let r of i)e.emitOne(n(r))})}map(i){return e.map(this,i)}static filter(i,n){return new e(async e=>{for await(let r of i)n(r)&&e.emitOne(r)})}filter(i){return e.filter(this,i)}static coalesce(i){return e.filter(i,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let i=[];for await(let n of e)i.push(n);return i}toPromise(){return e.toPromise(this)}emitOne(e){0===this._state&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){0===this._state&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){0===this._state&&(this._state=1,this._onStateChanged.fire())}reject(e){0===this._state&&(this._state=2,this._error=e,this._onStateChanged.fire())}};oW.EMPTY=oW.fromArray([]);function oH(e,i){return(i<<5)-i+e|0}function o$(e,i){i=oH(149417,i);for(let n=0,r=e.length;n<r;n++)i=oH(e.charCodeAt(n),i);return i}new DataView(new ArrayBuffer(320));var{registerWindow:oU,getWindow:oV,getDocument:oq,getWindows:oY,getWindowsCount:oK,getWindowId:oX,getWindowById:oJ,hasWindow:oG,onDidRegisterWindow:oZ,onWillUnregisterWindow:oQ,onDidUnregisterWindow:o0}=(i=new Map,n={window:sM,disposables:new sT},i.set(sM.vscodeWindowId,n),r=new sG,s=new sG,o=new sG,{onDidRegisterWindow:r.event,onWillUnregisterWindow:o.event,onDidUnregisterWindow:s.event,registerWindow(e){if(i.has(e.vscodeWindowId))return sE.None;let n=new sT,a={window:e,disposables:n.add(new sT)};return i.set(e.vscodeWindowId,a),n.add(sk(()=>{i.delete(e.vscodeWindowId),s.fire(e)})),n.add(o2(e,o8.BEFORE_UNLOAD,()=>{o.fire(e)})),r.fire(a),n},getWindows:()=>i.values(),getWindowsCount:()=>i.size,getWindowId:e=>e.vscodeWindowId,hasWindow:e=>i.has(e),getWindowById:function(e,r){return("number"==typeof e?i.get(e):void 0)??(r?n:void 0)},getWindow:e=>e?.ownerDocument?.defaultView?e.ownerDocument.defaultView.window:e?.view?e.view.window:sM,getDocument:e=>oV(e).document}),o1=class{constructor(e,i,n,r){this._node=e,this._type=i,this._handler=n,this._options=r||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function o2(e,i,n,r){return new o1(e,i,n,r)}var o5=function(e,i,n,r){var s;let o=n;return"click"===i||"mousedown"===i||"contextmenu"===i?(s=oV(e),o=function(e){return n(new oj(s,e))}):("keydown"===i||"keypress"===i||"keyup"===i)&&(o=function(e){return n(new oR(e))}),o2(e,i,o,r)},o3=class extends oF{constructor(e){super(),this.defaultTarget=e&&oV(e)}cancelAndSet(e,i,n){return super.cancelAndSet(e,i,n??this.defaultTarget)}},o4=class{constructor(e,i=0){this._runner=e,this.priority=i,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){sf(e)}}static sort(e,i){return i.priority-e.priority}};a=new Map,l=new Map,c=new Map,h=new Map,aO=(e,i,n=0)=>{let r=oX(e),s=new o4(i,n),o=a.get(r);return o||(o=[],a.set(r,o)),o.push(s),c.get(r)||(c.set(r,!0),e.requestAnimationFrame(()=>(e=>{c.set(e,!1);let i=a.get(e)??[];for(l.set(e,i),a.set(e,[]),h.set(e,!0);i.length>0;)i.sort(o4.sort),i.shift().execute();h.set(e,!1)})(r))),s};var o6=class e{constructor(e,i){this.width=e,this.height=i}with(i=this.width,n=this.height){return i!==this.width||n!==this.height?new e(i,n):this}static is(e){return"object"==typeof e&&"number"==typeof e.height&&"number"==typeof e.width}static lift(i){return i instanceof e?i:new e(i.width,i.height)}static equals(e,i){return e===i||!!e&&!!i&&e.width===i.width&&e.height===i.height}};o6.None=new o6(0,0),new class{constructor(){this.mutationObservers=new Map}observe(e,i,n){let r=this.mutationObservers.get(e);r||(r=new Map,this.mutationObservers.set(e,r));let s=function e(i,n){switch(typeof i){case"object":var r,s,o,a;return null===i?oH(349,n):Array.isArray(i)?(r=i,s=oH(104579,s=n),r.reduce((i,n)=>e(n,i),s)):(o=i,a=oH(181387,a=n),Object.keys(o).sort().reduce((i,n)=>(i=o$(n,i),e(o[n],i)),a));case"string":return o$(i,n);case"boolean":return oH(i?433:863,n);case"number":return oH(i,n);case"undefined":return oH(937,n);default:return oH(617,n)}}(n,0),o=r.get(s);if(o)o.users+=1;else{let a=new sG,l=new MutationObserver(e=>a.fire(e));l.observe(e,n);let c=o={users:1,observer:l,onDidMutate:a.event};i.add(sk(()=>{c.users-=1,0===c.users&&(a.dispose(),l.disconnect(),r?.delete(s),r?.size===0&&this.mutationObservers.delete(e))})),r.set(s,o)}return o.onDidMutate}};var o8={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},o9=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let i=o7(e);this._maxWidth!==i&&(this._maxWidth=i,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let i=o7(e);this._width!==i&&(this._width=i,this.domNode.style.width=this._width)}setHeight(e){let i=o7(e);this._height!==i&&(this._height=i,this.domNode.style.height=this._height)}setTop(e){let i=o7(e);this._top!==i&&(this._top=i,this.domNode.style.top=this._top)}setLeft(e){let i=o7(e);this._left!==i&&(this._left=i,this.domNode.style.left=this._left)}setBottom(e){let i=o7(e);this._bottom!==i&&(this._bottom=i,this.domNode.style.bottom=this._bottom)}setRight(e){let i=o7(e);this._right!==i&&(this._right=i,this.domNode.style.right=this._right)}setPaddingTop(e){let i=o7(e);this._paddingTop!==i&&(this._paddingTop=i,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let i=o7(e);this._paddingLeft!==i&&(this._paddingLeft=i,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let i=o7(e);this._paddingBottom!==i&&(this._paddingBottom=i,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let i=o7(e);this._paddingRight!==i&&(this._paddingRight=i,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let i=o7(e);this._fontSize!==i&&(this._fontSize=i,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let i=o7(e);this._lineHeight!==i&&(this._lineHeight=i,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let i=o7(e);this._letterSpacing!==i&&(this._letterSpacing=i,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,i){this.domNode.classList.toggle(e,i),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,i){this.domNode.setAttribute(e,i)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function o7(e){return"number"==typeof e?`${e}px`:e}function ae(e){return new o9(e)}var at=class{constructor(){this._hooks=new sT,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,i){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(i)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,i,n,r,s){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=s;let o=e;try{e.setPointerCapture(i),this._hooks.add(sk(()=>{try{e.releasePointerCapture(i)}catch{}}))}catch{o=oV(e)}this._hooks.add(o2(o,o8.POINTER_MOVE,e=>{e.buttons!==n?this.stopMonitoring(!0):(e.preventDefault(),this._pointerMoveCallback(e))})),this._hooks.add(o2(o,o8.POINTER_UP,e=>this.stopMonitoring(!0)))}};(d=aA||={}).Tap="-xterm-gesturetap",d.Change="-xterm-gesturechange",d.Start="-xterm-gesturestart",d.End="-xterm-gesturesend",d.Contextmenu="-xterm-gesturecontextmenu";var ai=class e extends sE{constructor(){super(),this.dispatched=!1,this.targets=new sA,this.ignoreTargets=new sA,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(sU.runAndSubscribe(oZ,({window:e,disposables:i})=>{i.add(o2(e.document,"touchstart",e=>this.onTouchStart(e),{passive:!1})),i.add(o2(e.document,"touchend",i=>this.onTouchEnd(e,i))),i.add(o2(e.document,"touchmove",e=>this.onTouchMove(e),{passive:!1}))},{window:sM,disposables:this._store}))}static addTarget(i){return e.isTouchDevice()?(e.INSTANCE||(e.INSTANCE=new e),sk(e.INSTANCE.targets.push(i))):sE.None}static ignoreTarget(i){return e.isTouchDevice()?(e.INSTANCE||(e.INSTANCE=new e),sk(e.INSTANCE.ignoreTargets.push(i))):sE.None}static isTouchDevice(){return"ontouchstart"in sM||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(e){let i=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let n=0,r=e.targetTouches.length;n<r;n++){let r=e.targetTouches.item(n);this.activeTouches[r.identifier]={id:r.identifier,initialTarget:r.target,initialTimeStamp:i,initialPageX:r.pageX,initialPageY:r.pageY,rollingTimestamps:[i],rollingPageX:[r.pageX],rollingPageY:[r.pageY]};let s=this.newGestureEvent(aA.Start,r.target);s.pageX=r.pageX,s.pageY=r.pageY,this.dispatchEvent(s)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}onTouchEnd(i,n){let r=Date.now(),s=Object.keys(this.activeTouches).length;for(let o=0,a=n.changedTouches.length;o<a;o++){let a=n.changedTouches.item(o);if(!this.activeTouches.hasOwnProperty(String(a.identifier))){console.warn("move of an UNKNOWN touch",a);continue}let l=this.activeTouches[a.identifier],c=Date.now()-l.initialTimeStamp;if(c<e.HOLD_DELAY&&30>Math.abs(l.initialPageX-s_(l.rollingPageX))&&30>Math.abs(l.initialPageY-s_(l.rollingPageY))){let e=this.newGestureEvent(aA.Tap,l.initialTarget);e.pageX=s_(l.rollingPageX),e.pageY=s_(l.rollingPageY),this.dispatchEvent(e)}else if(c>=e.HOLD_DELAY&&30>Math.abs(l.initialPageX-s_(l.rollingPageX))&&30>Math.abs(l.initialPageY-s_(l.rollingPageY))){let e=this.newGestureEvent(aA.Contextmenu,l.initialTarget);e.pageX=s_(l.rollingPageX),e.pageY=s_(l.rollingPageY),this.dispatchEvent(e)}else if(1===s){let e=s_(l.rollingPageX),n=s_(l.rollingPageY),s=s_(l.rollingTimestamps)-l.rollingTimestamps[0],o=e-l.rollingPageX[0],a=n-l.rollingPageY[0],c=[...this.targets].filter(e=>l.initialTarget instanceof Node&&e.contains(l.initialTarget));this.inertia(i,c,r,Math.abs(o)/s,o>0?1:-1,e,Math.abs(a)/s,a>0?1:-1,n)}this.dispatchEvent(this.newGestureEvent(aA.End,l.initialTarget)),delete this.activeTouches[a.identifier]}this.dispatched&&(n.preventDefault(),n.stopPropagation(),this.dispatched=!1)}newGestureEvent(e,i){let n=document.createEvent("CustomEvent");return n.initEvent(e,!1,!0),n.initialTarget=i,n.tapCount=0,n}dispatchEvent(i){if(i.type===aA.Tap){let n=new Date().getTime(),r=0;r=n-this._lastSetTapCountTime>e.CLEAR_TAP_COUNT_TIME?1:2,this._lastSetTapCountTime=n,i.tapCount=r}else(i.type===aA.Change||i.type===aA.Contextmenu)&&(this._lastSetTapCountTime=0);if(i.initialTarget instanceof Node){for(let e of this.ignoreTargets)if(e.contains(i.initialTarget))return;let e=[];for(let n of this.targets)if(n.contains(i.initialTarget)){let r=0,s=i.initialTarget;for(;s&&s!==n;)r++,s=s.parentElement;e.push([r,n])}for(let[n,r]of(e.sort((e,i)=>e[0]-i[0]),e))r.dispatchEvent(i),this.dispatched=!0}}inertia(i,n,r,s,o,a,l,c,h){this.handle=aO(i,()=>{let d=Date.now(),u=d-r,p=0,f=0,m=!0;s+=e.SCROLL_FRICTION*u,l+=e.SCROLL_FRICTION*u,s>0&&(m=!1,p=o*s*u),l>0&&(m=!1,f=c*l*u);let g=this.newGestureEvent(aA.Change);g.translationX=p,g.translationY=f,n.forEach(e=>e.dispatchEvent(g)),m||this.inertia(i,n,d,s,o,a+p,l,c,h+f)})}onTouchMove(e){let i=Date.now();for(let n=0,r=e.changedTouches.length;n<r;n++){let r=e.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(r.identifier))){console.warn("end of an UNKNOWN touch",r);continue}let s=this.activeTouches[r.identifier],o=this.newGestureEvent(aA.Change,s.initialTarget);o.translationX=r.pageX-s_(s.rollingPageX),o.translationY=r.pageY-s_(s.rollingPageY),o.pageX=r.pageX,o.pageY=r.pageY,this.dispatchEvent(o),s.rollingPageX.length>3&&(s.rollingPageX.shift(),s.rollingPageY.shift(),s.rollingTimestamps.shift()),s.rollingPageX.push(r.pageX),s.rollingPageY.push(r.pageY),s.rollingTimestamps.push(i)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}};ai.SCROLL_FRICTION=-.005,ai.HOLD_DELAY=700,ai.CLEAR_TAP_COUNT_TIME=400,rF([function(e,i,n){let r=null,s=null;if("function"==typeof n.value?(r="value",0!==(s=n.value).length&&console.warn("Memoize should only be used in functions with zero parameters")):"function"==typeof n.get&&(r="get",s=n.get),!s)throw Error("not supported");let o=`$memoize$${i}`;n[r]=function(...e){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:s.apply(this,e)}),this[o]}}],ai,"isTouchDevice",1);var an=class extends sE{onclick(e,i){this._register(o2(e,o8.CLICK,n=>i(new oj(oV(e),n))))}onmousedown(e,i){this._register(o2(e,o8.MOUSE_DOWN,n=>i(new oj(oV(e),n))))}onmouseover(e,i){this._register(o2(e,o8.MOUSE_OVER,n=>i(new oj(oV(e),n))))}onmouseleave(e,i){this._register(o2(e,o8.MOUSE_LEAVE,n=>i(new oj(oV(e),n))))}onkeydown(e,i){this._register(o2(e,o8.KEY_DOWN,e=>i(new oR(e))))}onkeyup(e,i){this._register(o2(e,o8.KEY_UP,e=>i(new oR(e))))}oninput(e,i){this._register(o2(e,o8.INPUT,i))}onblur(e,i){this._register(o2(e,o8.BLUR,i))}onfocus(e,i){this._register(o2(e,o8.FOCUS,i))}onchange(e,i){this._register(o2(e,o8.CHANGE,i))}ignoreGesture(e){return ai.ignoreTarget(e)}},ar=class extends an{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px","u">typeof e.top&&(this.bgDomNode.style.top="0px"),"u">typeof e.left&&(this.bgDomNode.style.left="0px"),"u">typeof e.bottom&&(this.bgDomNode.style.bottom="0px"),"u">typeof e.right&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width="11px",this.domNode.style.height="11px","u">typeof e.top&&(this.domNode.style.top=e.top+"px"),"u">typeof e.left&&(this.domNode.style.left=e.left+"px"),"u">typeof e.bottom&&(this.domNode.style.bottom=e.bottom+"px"),"u">typeof e.right&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new at),this._register(o5(this.bgDomNode,o8.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(o5(this.domNode,o8.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new o3),this._pointerdownScheduleRepeatTimer=this._register(new oz)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let i=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,oV(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(i,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},as=class e{constructor(e,i,n,r,s,o,a){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(i|=0,n|=0,r|=0,s|=0,o|=0,a|=0),this.rawScrollLeft=r,this.rawScrollTop=a,i<0&&(i=0),r+i>n&&(r=n-i),r<0&&(r=0),s<0&&(s=0),a+s>o&&(a=o-s),a<0&&(a=0),this.width=i,this.scrollWidth=n,this.scrollLeft=r,this.height=s,this.scrollHeight=o,this.scrollTop=a}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(i,n){return new e(this._forceIntegerValues,"u">typeof i.width?i.width:this.width,"u">typeof i.scrollWidth?i.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,"u">typeof i.height?i.height:this.height,"u">typeof i.scrollHeight?i.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(i){return new e(this._forceIntegerValues,this.width,this.scrollWidth,"u">typeof i.scrollLeft?i.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,"u">typeof i.scrollTop?i.scrollTop:this.rawScrollTop)}createScrollEvent(e,i){let n=this.width!==e.width,r=this.scrollWidth!==e.scrollWidth,s=this.scrollLeft!==e.scrollLeft,o=this.height!==e.height,a=this.scrollHeight!==e.scrollHeight,l=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:i,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:n,scrollWidthChanged:r,scrollLeftChanged:s,heightChanged:o,scrollHeightChanged:a,scrollTopChanged:l}}},ao=class extends sE{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new sG),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new as(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,i){let n=this._state.withScrollDimensions(e,i);this._setState(n,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let i=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(i,!1)}setScrollPositionSmooth(e,i){if(0===this._smoothScrollDuration)return this.setScrollPositionNow(e);if(this._smoothScrolling){let n;e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let r=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===r.scrollLeft&&this._smoothScrolling.to.scrollTop===r.scrollTop)return;n=i?new ac(this._smoothScrolling.from,r,this._smoothScrolling.startTime,this._smoothScrolling.duration):this._smoothScrolling.combine(this._state,r,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=n}else{let i=this._state.withScrollPosition(e);this._smoothScrolling=ac.start(this._state,i,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),i=this._state.withScrollPosition(e);if(this._setState(i,!0),this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,i){let n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,i)))}},aa=class{constructor(e,i,n){this.scrollLeft=e,this.scrollTop=i,this.isDone=n}};function al(e,i){let n=i-e;return function(i){return e+n*(1-Math.pow(1-i,3))}}var ac=class e{constructor(e,i,n,r){this.from=e,this.to=i,this.duration=r,this.startTime=n,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(e,i,n){if(Math.abs(e-i)>2.5*n){var r,s;let o,a;return e<i?(o=e+.75*n,a=i-.75*n):(o=e-.75*n,a=i+.75*n),r=al(e,o),s=al(a,i),function(e){return e<.33?r(e/.33):s((e-.33)/(1-.33))}}return al(e,i)}dispose(){null!==this.animationFrameDisposable&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(e){this.to=e.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(e){let i=(e-this.startTime)/this.duration;return i<1?new aa(this.scrollLeft(i),this.scrollTop(i),!1):new aa(this.to.scrollLeft,this.to.scrollTop,!0)}combine(i,n,r){return e.start(i,n,r)}static start(i,n,r){return r+=10,new e(i,n,Date.now()-10,r)}},ah=class extends sE{constructor(e,i,n){super(),this._visibility=e,this._visibleClassName=i,this._invisibleClassName=n,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new oz)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return 2!==this._visibility&&(3===this._visibility||this._rawShouldBeVisible)}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){this._isNeeded?this._shouldBeVisible?this._reveal():this._hide(!0):this._hide(!1)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(e){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(e?" fade":"")))}},ad=class extends an{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new ah(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new at),this._shouldRender=!0,this.domNode=ae(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(o2(this.domNode.domNode,o8.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(e){let i=this._register(new ar(e));this.domNode.domNode.appendChild(i.bgDomNode),this.domNode.domNode.appendChild(i.domNode)}_createSlider(e,i,n,r){this.slider=ae(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(i),"number"==typeof n&&this.slider.setWidth(n),"number"==typeof r&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(o2(this.slider.domNode,o8.POINTER_DOWN,e=>{0===e.button&&(e.preventDefault(),this._sliderPointerDown(e))})),this.onclick(this.slider.domNode,e=>{e.leftButton&&e.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let i=this.domNode.domNode.getClientRects()[0].top,n=i+this._scrollbarState.getSliderPosition(),r=i+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),s=this._sliderPointerPosition(e);n<=s&&s<=r?0===e.button&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let i,n;if(e.target===this.domNode.domNode&&"number"==typeof e.offsetX&&"number"==typeof e.offsetY)i=e.offsetX,n=e.offsetY;else{var r;let s,o,a=(s=(r=this.domNode.domNode).getBoundingClientRect(),o=oV(r),{left:s.left+o.scrollX,top:s.top+o.scrollY,width:s.width,height:s.height});i=e.pageX-a.left,n=e.pageY-a.top}let s=this._pointerDownRelativePosition(i,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),0===e.button&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let i=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{let s=Math.abs(this._sliderOrthogonalPointerPosition(e)-n);if(ol&&s>140)return void this._setDesiredScrollPositionNow(r.getScrollPosition());let o=this._sliderPointerPosition(e)-i;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(o))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let i={};this.writeScrollPosition(i,e),this._scrollable.setScrollPositionNow(i)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},au=class e{constructor(e,i,n,r,s,o){this._scrollbarSize=Math.round(i),this._oppositeScrollbarSize=Math.round(n),this._arrowSize=Math.round(e),this._visibleSize=r,this._scrollSize=s,this._scrollPosition=o,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new e(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let i=Math.round(e);return this._visibleSize!==i&&(this._visibleSize=i,this._refreshComputedValues(),!0)}setScrollSize(e){let i=Math.round(e);return this._scrollSize!==i&&(this._scrollSize=i,this._refreshComputedValues(),!0)}setScrollPosition(e){let i=Math.round(e);return this._scrollPosition!==i&&(this._scrollPosition=i,this._refreshComputedValues(),!0)}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,i,n,r,s){let o=Math.max(0,n-e),a=Math.max(0,o-2*i),l=r>0&&r>n;if(!l)return{computedAvailableSize:Math.round(o),computedIsNeeded:l,computedSliderSize:Math.round(a),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(n*a/r))),h=(a-c)/(r-n);return{computedAvailableSize:Math.round(o),computedIsNeeded:l,computedSliderSize:Math.round(c),computedSliderRatio:h,computedSliderPosition:Math.round(s*h)}}_refreshComputedValues(){let i=e._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=i.computedAvailableSize,this._computedIsNeeded=i.computedIsNeeded,this._computedSliderSize=i.computedSliderSize,this._computedSliderRatio=i.computedSliderRatio,this._computedSliderPosition=i.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(e){return this._computedIsNeeded?Math.round((e-this._arrowSize-this._computedSliderSize/2)/this._computedSliderRatio):0}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let i=e-this._arrowSize,n=this._scrollPosition;return i<this._computedSliderPosition?n-=this._visibleSize:n+=this._visibleSize,n}getDesiredScrollPositionFromDelta(e){return this._computedIsNeeded?Math.round((this._computedSliderPosition+e)/this._computedSliderRatio):0}},ap=class extends ad{constructor(e,i,n){let r=e.getScrollDimensions(),s=e.getCurrentScrollPosition();if(super({lazyRender:i.lazyRender,host:n,scrollbarState:new au(i.horizontalHasArrows?i.arrowSize:0,2===i.horizontal?0:i.horizontalScrollbarSize,2===i.vertical?0:i.verticalScrollbarSize,r.width,r.scrollWidth,s.scrollLeft),visibility:i.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:i.scrollByPage}),i.horizontalHasArrows)throw Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((i.horizontalScrollbarSize-i.horizontalSliderSize)/2),0,void 0,i.horizontalSliderSize)}_updateSlider(e,i){this.slider.setWidth(e),this.slider.setLeft(i)}_renderDomNode(e,i){this.domNode.setWidth(e),this.domNode.setHeight(i),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,i){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,i){e.scrollLeft=i}updateOptions(e){this.updateScrollbarSize(2===e.horizontal?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(2===e.vertical?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},af=class extends ad{constructor(e,i,n){let r=e.getScrollDimensions(),s=e.getCurrentScrollPosition();if(super({lazyRender:i.lazyRender,host:n,scrollbarState:new au(i.verticalHasArrows?i.arrowSize:0,2===i.vertical?0:i.verticalScrollbarSize,0,r.height,r.scrollHeight,s.scrollTop),visibility:i.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:i.scrollByPage}),i.verticalHasArrows)throw Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((i.verticalScrollbarSize-i.verticalSliderSize)/2),i.verticalSliderSize,void 0)}_updateSlider(e,i){this.slider.setHeight(e),this.slider.setTop(i)}_renderDomNode(e,i){this.domNode.setWidth(i),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,i){return i}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,i){e.scrollTop=i}updateOptions(e){this.updateScrollbarSize(2===e.vertical?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},am=class{constructor(e,i,n){this.timestamp=e,this.deltaX=i,this.deltaY=n,this.score=0}},ag=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(-1===this._front&&-1===this._rear)return!1;let e=1,i=0,n=1,r=this._rear;for(;;){let s=r===this._front?e:Math.pow(2,-n);if(e-=s,i+=this._memory[r].score*s,r===this._front)break;r=(this._capacity+r-1)%this._capacity,n++}return i<=.5}acceptStandardWheelEvent(e){if(s5){var i;let n=(i=oV(e.browserEvent),sQ.INSTANCE.getZoomFactor(i));this.accept(Date.now(),e.deltaX*n,e.deltaY*n)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,i,n){let r=null,s=new am(e,i,n);-1===this._front&&-1===this._rear?(this._memory[0]=s,this._front=0,this._rear=0):(r=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=s),s.score=this._computeScore(s,r)}_computeScore(e,i){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let n=.5;if(this._isAlmostInt(e.deltaX)&&this._isAlmostInt(e.deltaY)||(n+=.25),i){let r=Math.abs(e.deltaX),s=Math.abs(e.deltaY),o=Math.abs(i.deltaX),a=Math.abs(i.deltaY),l=Math.max(Math.min(r,o),1),c=Math.max(Math.min(s,a),1),h=Math.max(s,a);Math.max(r,o)%l==0&&h%c==0&&(n-=.5)}return Math.min(Math.max(n,0),1)}_isAlmostInt(e){return .01>Math.abs(Math.round(e)-e)}};ag.INSTANCE=new ag;var av=class extends an{constructor(e,i,n){super(),this._onScroll=this._register(new sG),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new sG),this.onWillScroll=this._onWillScroll.event,this._options=function(e){let i={lazyRender:"u">typeof e.lazyRender&&e.lazyRender,className:"u">typeof e.className?e.className:"",useShadows:!("u">typeof e.useShadows)||e.useShadows,handleMouseWheel:!("u">typeof e.handleMouseWheel)||e.handleMouseWheel,flipAxes:"u">typeof e.flipAxes&&e.flipAxes,consumeMouseWheelIfScrollbarIsNeeded:"u">typeof e.consumeMouseWheelIfScrollbarIsNeeded&&e.consumeMouseWheelIfScrollbarIsNeeded,alwaysConsumeMouseWheel:"u">typeof e.alwaysConsumeMouseWheel&&e.alwaysConsumeMouseWheel,scrollYToX:"u">typeof e.scrollYToX&&e.scrollYToX,mouseWheelScrollSensitivity:"u">typeof e.mouseWheelScrollSensitivity?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:"u">typeof e.fastScrollSensitivity?e.fastScrollSensitivity:5,scrollPredominantAxis:!("u">typeof e.scrollPredominantAxis)||e.scrollPredominantAxis,mouseWheelSmoothScroll:!("u">typeof e.mouseWheelSmoothScroll)||e.mouseWheelSmoothScroll,arrowSize:"u">typeof e.arrowSize?e.arrowSize:11,listenOnDomNode:"u">typeof e.listenOnDomNode?e.listenOnDomNode:null,horizontal:"u">typeof e.horizontal?e.horizontal:1,horizontalScrollbarSize:"u">typeof e.horizontalScrollbarSize?e.horizontalScrollbarSize:10,horizontalSliderSize:"u">typeof e.horizontalSliderSize?e.horizontalSliderSize:0,horizontalHasArrows:"u">typeof e.horizontalHasArrows&&e.horizontalHasArrows,vertical:"u">typeof e.vertical?e.vertical:1,verticalScrollbarSize:"u">typeof e.verticalScrollbarSize?e.verticalScrollbarSize:10,verticalHasArrows:"u">typeof e.verticalHasArrows&&e.verticalHasArrows,verticalSliderSize:"u">typeof e.verticalSliderSize?e.verticalSliderSize:0,scrollByPage:"u">typeof e.scrollByPage&&e.scrollByPage};return i.horizontalSliderSize="u">typeof e.horizontalSliderSize?e.horizontalSliderSize:i.horizontalScrollbarSize,i.verticalSliderSize="u">typeof e.verticalSliderSize?e.verticalSliderSize:i.verticalScrollbarSize,oc&&(i.className+=" mac"),i}(i),this._scrollable=n,this._register(this._scrollable.onScroll(e=>{this._onWillScroll.fire(e),this._onDidScroll(e),this._onScroll.fire(e)}));let r={onMouseWheel:e=>this._onMouseWheel(e),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new af(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new ap(this._scrollable,this._options,r)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=ae(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=ae(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=ae(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,e=>this._onMouseOver(e)),this.onmouseleave(this._listenOnDomNode,e=>this._onMouseLeave(e)),this._hideTimeout=this._register(new oz),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=sS(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,oc&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){"u">typeof e.handleMouseWheel&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),"u">typeof e.mouseWheelScrollSensitivity&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),"u">typeof e.fastScrollSensitivity&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),"u">typeof e.scrollPredominantAxis&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),"u">typeof e.horizontal&&(this._options.horizontal=e.horizontal),"u">typeof e.vertical&&(this._options.vertical=e.vertical),"u">typeof e.horizontalScrollbarSize&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),"u">typeof e.verticalScrollbarSize&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),"u">typeof e.scrollByPage&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new oI(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=sS(this._mouseWheelToDispose),e)){let e=e=>{this._onMouseWheel(new oI(e))};this._mouseWheelToDispose.push(o2(this._listenOnDomNode,o8.MOUSE_WHEEL,e,{passive:!1}))}}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let i=ag.INSTANCE;i.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let r=e.deltaY*this._options.mouseWheelScrollSensitivity,s=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&s+r===0?s=r=0:Math.abs(r)>=Math.abs(s)?s=0:r=0),this._options.flipAxes&&([r,s]=[s,r]);let o=!oc&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||o)&&!s&&(s=r,r=0),e.browserEvent&&e.browserEvent.altKey&&(s*=this._options.fastScrollSensitivity,r*=this._options.fastScrollSensitivity);let a=this._scrollable.getFutureScrollPosition(),l={};if(r){let e=50*r,i=a.scrollTop-(e<0?Math.floor(e):Math.ceil(e));this._verticalScrollbar.writeScrollPosition(l,i)}if(s){let e=50*s,i=a.scrollLeft-(e<0?Math.floor(e):Math.ceil(e));this._horizontalScrollbar.writeScrollPosition(l,i)}l=this._scrollable.validateScrollPosition(l),(a.scrollLeft!==l.scrollLeft||a.scrollTop!==l.scrollTop)&&(this._options.mouseWheelSmoothScroll&&i.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(l):this._scrollable.setScrollPositionNow(l),n=!0)}let r=n;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),i=e.scrollTop>0,n=e.scrollLeft>0,r=n?" left":"",s=i?" top":"";this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${s}`),this._topLeftShadowDomNode.setClassName(`shadow${n||i?" top-left-corner":""}${s}${r}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){this._mouseIsOver||this._isDragging||(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){this._mouseIsOver||this._isDragging||this._hideTimeout.cancelAndSet(()=>this._hide(),500)}},ay=class extends av{constructor(e,i,n){super(e,i,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}},a_=class extends sE{constructor(e,i,n,r,s,o,a,l){super(),this._bufferService=n,this._optionsService=a,this._renderService=l,this._onRequestScrollLines=this._register(new sG),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new ao({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:e=>aO(r.window,e)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new ay(i,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},c)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(s.onProtocolChange(e=>{this._scrollableElement.updateOptions({handleMouseWheel:!(16&e)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(sU.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(sk(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement("style"),i.appendChild(this._styleElement),this._register(sk(()=>this._styleElement.remove())),this._register(sU.runAndSubscribe(o.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${o.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${o.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${o.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
|
|
16
|
+
`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(e=>this._handleScroll(e)))}scrollLines(e){let i=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:i.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,i){i&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!i,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){void 0!==e&&(this._latestYDisp=e),void 0===this._queuedAnimationFrame&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let i=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=i-this._bufferService.buffer.ydisp;0!==n&&(this._latestYDisp=i,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};a_=rF([rW(2,r3),rW(3,so),rW(4,r4),rW(5,sd),rW(6,se),rW(7,sl)],a_);var ab=class extends sE{constructor(e,i,n,r,s){super(),this._screenElement=e,this._bufferService=i,this._coreBrowserService=n,this._decorationService=r,this._renderService=s,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(e=>this._removeDecoration(e))),this._register(sk(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){void 0===this._animationFrame&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let i=this._coreBrowserService.mainDocument.createElement("div");i.classList.add("xterm-decoration"),i.classList.toggle("xterm-decoration-top-layer",e?.options?.layer==="top"),i.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,i.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,i.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,i.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(i.style.display="none"),this._refreshXPosition(e,i),i}_refreshStyle(e){let i=e.marker.line-this._bufferService.buffers.active.ydisp;if(i<0||i>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${i*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,i=e.element){if(!i)return;let n=e.options.x??0;"right"===(e.options.anchor||"left")?i.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:"":i.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};ab=rF([rW(1,r3),rW(2,so),rW(3,sn),rW(4,sl)],ab);var ax=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let i of this._zones)if(i.color===e.options.overviewRulerOptions.color&&i.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(i,e.marker.line))return;if(this._lineAdjacentToZone(i,e.marker.line,e.options.overviewRulerOptions.position))return void this._addLineToZone(i,e.marker.line)}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,i){return i>=e.startBufferLine&&i<=e.endBufferLine}_lineAdjacentToZone(e,i,n){return i>=e.startBufferLine-this._linePadding[n||"full"]&&i<=e.endBufferLine+this._linePadding[n||"full"]}_addLineToZone(e,i){e.startBufferLine=Math.min(e.startBufferLine,i),e.endBufferLine=Math.max(e.endBufferLine,i)}},aw={full:0,left:0,center:0,right:0},aS={full:0,left:0,center:0,right:0},ak={full:0,left:0,center:0,right:0},aC=class extends sE{constructor(e,i,n,r,s,o,a,l){super(),this._viewportElement=e,this._screenElement=i,this._bufferService=n,this._decorationService=r,this._renderService=s,this._optionsService=o,this._themeService=a,this._coreBrowserService=l,this._colorZoneStore=new ax,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(sk(()=>this._canvas?.remove()));let c=this._canvas.getContext("2d");if(c)this._ctx=c;else throw Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{this._containerHeight&&this._containerHeight===this._screenElement.clientHeight||(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),i=Math.ceil((this._canvas.width-1)/3);aS.full=this._canvas.width,aS.left=e,aS.center=i,aS.right=e,this._refreshDrawHeightConstants(),ak.full=1,ak.left=1,ak.center=1+aS.left,ak.right=1+aS.left+aS.center}_refreshDrawHeightConstants(){aw.full=Math.round(2*this._coreBrowserService.dpr);let e=Math.round(Math.max(Math.min(this._canvas.height/this._bufferService.buffer.lines.length,12),6)*this._coreBrowserService.dpr);aw.left=e,aw.center=e,aw.right=e}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*aw.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*aw.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*aw.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*aw.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){for(let e of(this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear(),this._decorationService.decorations))this._colorZoneStore.addDecoration(e);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let i of e)"full"!==i.position&&this._renderColorZone(i);for(let i of e)"full"===i.position&&this._renderColorZone(i);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(ak[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-aw[e.position||"full"]/2),aS[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+aw[e.position||"full"]))}_queueRefresh(e,i){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=i||this._shouldUpdateAnchor,void 0===this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};aC=rF([rW(2,r3),rW(3,sn),rW(4,sl),rW(5,se),rW(6,sd),rW(7,so)],aC),(u=aR||={}).NUL="\0",u.SOH="\x01",u.STX="\x02",u.ETX="\x03",u.EOT="\x04",u.ENQ="\x05",u.ACK="\x06",u.BEL="\x07",u.BS="\b",u.HT=" ",u.LF=`
|
|
17
|
+
`,u.VT="\v",u.FF="\f",u.CR="\r",u.SO="\x0e",u.SI="\x0f",u.DLE="\x10",u.DC1="\x11",u.DC2="\x12",u.DC3="\x13",u.DC4="\x14",u.NAK="\x15",u.SYN="\x16",u.ETB="\x17",u.CAN="\x18",u.EM="\x19",u.SUB="\x1a",u.ESC="\x1b",u.FS="\x1c",u.GS="\x1d",u.RS="\x1e",u.US="\x1f",u.SP=" ",u.DEL="",(p=aD||={}).PAD="",p.HOP="",p.BPH="",p.NBH="",p.IND="",p.NEL="
",p.SSA="",p.ESA="",p.HTS="",p.HTJ="",p.VTS="",p.PLD="",p.PLU="",p.RI="",p.SS2="",p.SS3="",p.DCS="",p.PU1="",p.PU2="",p.STS="",p.CCH="",p.MW="",p.SPA="",p.EPA="",p.SOS="",p.SGCI="",p.SCI="",p.CSI="",p.ST="",p.OSC="",p.PM="",p.APC="",(aL||={}).ST=`${aR.ESC}\\`;var aT=class{constructor(e,i,n,r,s,o){this._textarea=e,this._compositionView=i,this._bufferService=n,this._optionsService=r,this._coreService=s,this._renderService=o,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(20===e.keyCode||229===e.keyCode||16===e.keyCode||17===e.keyCode||18===e.keyCode)return!1;this._finalizeComposition(!1)}return 229!==e.keyCode||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){let i;this._isSendingComposition=!1,e.start+=this._dataAlreadySent.length,(i=this._isComposing?this._textarea.value.substring(e.start,this._compositionPosition.start):this._textarea.value.substring(e.start)).length>0&&this._coreService.triggerDataEvent(i,!0)}},0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let i=this._textarea.value,n=i.replace(e,"");this._dataAlreadySent=n,i.length>e.length?this._coreService.triggerDataEvent(n,!0):i.length<e.length?this._coreService.triggerDataEvent(`${aR.DEL}`,!0):i.length===e.length&&i!==e&&this._coreService.triggerDataEvent(i,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let e=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),i=this._renderService.dimensions.css.cell.height,n=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=e*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+"px",this._compositionView.style.top=n+"px",this._compositionView.style.height=i+"px",this._compositionView.style.lineHeight=i+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let s=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+"px",this._textarea.style.top=n+"px",this._textarea.style.width=Math.max(s.width,1)+"px",this._textarea.style.height=Math.max(s.height,1)+"px",this._textarea.style.lineHeight=s.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};aT=rF([rW(2,r3),rW(3,se),rW(4,r6),rW(5,sl)],aT);var aE,aN,aM,aO,aA,aR,aD,aL,aj,aI=0,aP=0,aB=0,az=0,aF={css:"#00000000",rgba:0};(cm=aj||={}).toCss=function(e,i,n,r){return void 0!==r?`#${aK(e)}${aK(i)}${aK(n)}${aK(r)}`:`#${aK(e)}${aK(i)}${aK(n)}`},cm.toRgba=function(e,i,n,r=255){return(e<<24|i<<16|n<<8|r)>>>0},cm.toColor=function(e,i,n,r){return{css:cm.toCss(e,i,n,r),rgba:cm.toRgba(e,i,n,r)}};var aW=cg||={};function aH(e,i){return az=Math.round(255*i),[aI,aP,aB]=c_.toChannels(e.rgba),{css:aj.toCss(aI,aP,aB,az),rgba:aj.toRgba(aI,aP,aB,az)}}aW.blend=function(e,i){if(1==(az=(255&i.rgba)/255))return{css:i.css,rgba:i.rgba};let n=i.rgba>>24&255,r=i.rgba>>16&255,s=i.rgba>>8&255,o=e.rgba>>24&255,a=e.rgba>>16&255,l=e.rgba>>8&255;return aI=o+Math.round((n-o)*az),aP=a+Math.round((r-a)*az),aB=l+Math.round((s-l)*az),{css:aj.toCss(aI,aP,aB),rgba:aj.toRgba(aI,aP,aB)}},aW.isOpaque=function(e){return(255&e.rgba)==255},aW.ensureContrastRatio=function(e,i,n){let r=c_.ensureContrastRatio(e.rgba,i.rgba,n);if(r)return aj.toColor(r>>24&255,r>>16&255,r>>8&255)},aW.opaque=function(e){let i=(255|e.rgba)>>>0;return[aI,aP,aB]=c_.toChannels(i),{css:aj.toCss(aI,aP,aB),rgba:i}},aW.opacity=aH,aW.multiplyOpacity=function(e,i){return az=255&e.rgba,aH(e,az*i/255)},aW.toColorRGB=function(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]},(e=>{let i,n;try{let e=document.createElement("canvas");e.width=1,e.height=1;let r=e.getContext("2d",{willReadFrequently:!0});r&&((i=r).globalCompositeOperation="copy",n=i.createLinearGradient(0,0,1,1))}catch{}e.toColor=function(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return aI=parseInt(e.slice(1,2).repeat(2),16),aP=parseInt(e.slice(2,3).repeat(2),16),aB=parseInt(e.slice(3,4).repeat(2),16),aj.toColor(aI,aP,aB);case 5:return aI=parseInt(e.slice(1,2).repeat(2),16),aP=parseInt(e.slice(2,3).repeat(2),16),aB=parseInt(e.slice(3,4).repeat(2),16),az=parseInt(e.slice(4,5).repeat(2),16),aj.toColor(aI,aP,aB,az);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let r=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(r)return aI=parseInt(r[1]),aP=parseInt(r[2]),aB=parseInt(r[3]),az=Math.round((void 0===r[5]?1:parseFloat(r[5]))*255),aj.toColor(aI,aP,aB,az);if(!i||!n||(i.fillStyle=n,i.fillStyle=e,"string"!=typeof i.fillStyle)||(i.fillRect(0,0,1,1),[aI,aP,aB,az]=i.getImageData(0,0,1,1).data,255!==az))throw Error("css.toColor: Unsupported css format");return{rgba:aj.toRgba(aI,aP,aB,az),css:e}}})(cv||={});var a$=cy||={};function aU(e,i,n){let r=e/255,s=i/255,o=n/255;return .2126*(r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4))+.7152*(s<=.03928?s/12.92:Math.pow((s+.055)/1.055,2.4))+.0722*(o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4))}a$.relativeLuminance=function(e){return aU(e>>16&255,e>>8&255,255&e)},a$.relativeLuminance2=aU;var aV=c_||={};function aq(e,i,n){let r=e>>24&255,s=e>>16&255,o=e>>8&255,a=i>>24&255,l=i>>16&255,c=i>>8&255,h=aX(cy.relativeLuminance2(a,l,c),cy.relativeLuminance2(r,s,o));for(;h<n&&(a>0||l>0||c>0);)a-=Math.max(0,Math.ceil(.1*a)),l-=Math.max(0,Math.ceil(.1*l)),c-=Math.max(0,Math.ceil(.1*c)),h=aX(cy.relativeLuminance2(a,l,c),cy.relativeLuminance2(r,s,o));return(a<<24|l<<16|c<<8|255)>>>0}function aY(e,i,n){let r=e>>24&255,s=e>>16&255,o=e>>8&255,a=i>>24&255,l=i>>16&255,c=i>>8&255,h=aX(cy.relativeLuminance2(a,l,c),cy.relativeLuminance2(r,s,o));for(;h<n&&(a<255||l<255||c<255);)a=Math.min(255,a+Math.ceil((255-a)*.1)),l=Math.min(255,l+Math.ceil((255-l)*.1)),c=Math.min(255,c+Math.ceil((255-c)*.1)),h=aX(cy.relativeLuminance2(a,l,c),cy.relativeLuminance2(r,s,o));return(a<<24|l<<16|c<<8|255)>>>0}function aK(e){let i=e.toString(16);return i.length<2?"0"+i:i}function aX(e,i){return e<i?(i+.05)/(e+.05):(e+.05)/(i+.05)}aV.blend=function(e,i){if(1==(az=(255&i)/255))return i;let n=e>>24&255,r=e>>16&255,s=e>>8&255;return aI=n+Math.round(((i>>24&255)-n)*az),aP=r+Math.round(((i>>16&255)-r)*az),aB=s+Math.round(((i>>8&255)-s)*az),aj.toRgba(aI,aP,aB)},aV.ensureContrastRatio=function(e,i,n){let r=cy.relativeLuminance(e>>8),s=cy.relativeLuminance(i>>8);if(aX(r,s)<n){if(s<r){let s=aq(e,i,n),o=aX(r,cy.relativeLuminance(s>>8));if(o<n){let a=aY(e,i,n);return o>aX(r,cy.relativeLuminance(a>>8))?s:a}return s}let o=aY(e,i,n),a=aX(r,cy.relativeLuminance(o>>8));if(a<n){let s=aq(e,i,n);return a>aX(r,cy.relativeLuminance(s>>8))?o:s}return o}},aV.reduceLuminance=aq,aV.increaseLuminance=aY,aV.toChannels=function(e){return[e>>24&255,e>>16&255,e>>8&255,255&e]};var aJ=class extends rG{constructor(e,i,n){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=i,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},aG=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new rQ}register(e){let i={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(i),i.id}deregister(e){for(let i=0;i<this._characterJoiners.length;i++)if(this._characterJoiners[i].id===e)return this._characterJoiners.splice(i,1),!0;return!1}getJoinedCharacters(e){if(0===this._characterJoiners.length)return[];let i=this._bufferService.buffer.lines.get(e);if(!i||0===i.length)return[];let n=[],r=i.translateToString(!0),s=0,o=0,a=0,l=i.getFg(0),c=i.getBg(0);for(let e=0;e<i.getTrimmedLength();e++)if(i.loadCell(e,this._workCell),0!==this._workCell.getWidth()){if(this._workCell.fg!==l||this._workCell.bg!==c){if(e-s>1){let e=this._getJoinedRanges(r,a,o,i,s);for(let i=0;i<e.length;i++)n.push(e[i])}s=e,a=o,l=this._workCell.fg,c=this._workCell.bg}o+=this._workCell.getChars().length||1}if(this._bufferService.cols-s>1){let e=this._getJoinedRanges(r,a,o,i,s);for(let i=0;i<e.length;i++)n.push(e[i])}return n}_getJoinedRanges(e,i,n,r,s){let o=e.substring(i,n),a=[];try{a=this._characterJoiners[0].handler(o)}catch(e){console.error(e)}for(let e=1;e<this._characterJoiners.length;e++)try{let i=this._characterJoiners[e].handler(o);for(let e=0;e<i.length;e++)aG._mergeRanges(a,i[e])}catch(e){console.error(e)}return this._stringRangesToCellRanges(a,r,s),a}_stringRangesToCellRanges(e,i,n){let r=0,s=!1,o=0,a=e[0];if(a){for(let l=n;l<this._bufferService.cols;l++){let n=i.getWidth(l),c=i.getString(l).length||1;if(0!==n){if(!s&&a[0]<=o&&(a[0]=l,s=!0),a[1]<=o){if(a[1]=l,!(a=e[++r]))break;a[0]<=o?(a[0]=l,s=!0):s=!1}o+=c}}a&&(a[1]=this._bufferService.cols)}}static _mergeRanges(e,i){let n=!1;for(let r=0;r<e.length;r++){let s=e[r];if(n){if(i[1]<=s[0])return e[r-1][1]=i[1],e;if(i[1]<=s[1])return e[r-1][1]=Math.max(i[1],s[1]),e.splice(r,1),e;e.splice(r,1),r--}else{if(i[1]<=s[0])return e.splice(r,0,i),e;if(i[1]<=s[1])return s[0]=Math.min(i[0],s[0]),e;i[0]<s[1]&&(s[0]=Math.min(i[0],s[0]),n=!0);continue}}return n?e[e.length-1][1]=i[1]:e.push(i),e}};function aZ(){return{width:0,height:0}}aG=rF([rW(0,r3)],aG);var aQ=class{constructor(e,i,n,r,s,o,a){this._document=e,this._characterJoinerService=i,this._optionsService=n,this._coreBrowserService=r,this._coreService=s,this._decorationService=o,this._themeService=a,this._workCell=new rQ,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,i,n){this._selectionStart=e,this._selectionEnd=i,this._columnSelectMode=n}createRow(e,i,n,r,s,o,a,l,c,h,d){let u=[],p=this._characterJoinerService.getJoinedCharacters(i),f=this._themeService.colors,m=e.getNoBgTrimmedLength();n&&m<o+1&&(m=o+1);let g,v=0,y="",_=0,b=0,w=0,S=0,k=!1,C=0,T=!1,E=0,N=0,M=[],O=-1!==h&&-1!==d;for(let A=0;A<m;A++){let m;e.loadCell(A,this._workCell);let R=this._workCell.getWidth();if(0===R)continue;let D=!1,L=A>=N,j=A,I=this._workCell;if(p.length>0&&A===p[0][0]&&L){let r=p.shift(),s=this._isCellInSelection(r[0],i);for(_=r[0]+1;_<r[1];_++)L&&=s===this._isCellInSelection(_,i);(L&&=!n||o<r[0]||o>=r[1])?(D=!0,I=new aJ(this._workCell,e.translateToString(!0,r[0],r[1]),r[1]-r[0]),j=r[1]-1,R=I.getWidth()):N=r[1]}let P=this._isCellInSelection(A,i),B=n&&A===o,z=O&&A>=h&&A<=d,F=!1;this._decorationService.forEachDecorationAtCell(A,i,void 0,e=>{F=!0});let W=I.getChars()||" ";if(" "===W&&(I.isUnderline()||I.isOverline())&&(W=" "),E=R*l-c.get(W,I.isBold(),I.isItalic()),g)if(v&&(P&&T||!P&&!T&&I.bg===b)&&(P&&T&&f.selectionForeground||I.fg===w)&&I.extended.ext===S&&z===k&&E===C&&!B&&!D&&!F&&L){I.isInvisible()?y+=" ":y+=W,v++;continue}else v&&(g.textContent=y),g=this._document.createElement("span"),v=0,y="";else g=this._document.createElement("span");if(b=I.bg,w=I.fg,S=I.extended.ext,k=z,C=E,T=P,D&&o>=A&&o<=j&&(o=A),!this._coreService.isCursorHidden&&B&&this._coreService.isCursorInitialized){if(M.push("xterm-cursor"),this._coreBrowserService.isFocused)a&&M.push("xterm-cursor-blink"),M.push("bar"===r?"xterm-cursor-bar":"underline"===r?"xterm-cursor-underline":"xterm-cursor-block");else if(s)switch(s){case"outline":M.push("xterm-cursor-outline");break;case"block":M.push("xterm-cursor-block");break;case"bar":M.push("xterm-cursor-bar");break;case"underline":M.push("xterm-cursor-underline")}}if(I.isBold()&&M.push("xterm-bold"),I.isItalic()&&M.push("xterm-italic"),I.isDim()&&M.push("xterm-dim"),y=I.isInvisible()?" ":I.getChars()||" ",I.isUnderline()&&(M.push(`xterm-underline-${I.extended.underlineStyle}`)," "===y&&(y=" "),!I.isUnderlineColorDefault()))if(I.isUnderlineColorRGB())g.style.textDecorationColor=`rgb(${rG.toColorRGB(I.getUnderlineColor()).join(",")})`;else{let e=I.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&I.isBold()&&e<8&&(e+=8),g.style.textDecorationColor=f.ansi[e].css}I.isOverline()&&(M.push("xterm-overline")," "===y&&(y=" ")),I.isStrikethrough()&&M.push("xterm-strikethrough"),z&&(g.style.textDecoration="underline");let H=I.getFgColor(),$=I.getFgColorMode(),U=I.getBgColor(),V=I.getBgColorMode(),q=!!I.isInverse();if(q){let e=H;H=U,U=e;let i=$;$=V,V=i}let Y,K,X=!1;switch(this._decorationService.forEachDecorationAtCell(A,i,void 0,e=>{"top"!==e.options.layer&&X||(e.backgroundColorRGB&&(V=0x3000000,U=e.backgroundColorRGB.rgba>>8&0xffffff,Y=e.backgroundColorRGB),e.foregroundColorRGB&&($=0x3000000,H=e.foregroundColorRGB.rgba>>8&0xffffff,K=e.foregroundColorRGB),X="top"===e.options.layer)}),!X&&P&&(U=(Y=this._coreBrowserService.isFocused?f.selectionBackgroundOpaque:f.selectionInactiveBackgroundOpaque).rgba>>8&0xffffff,V=0x3000000,X=!0,f.selectionForeground&&($=0x3000000,H=f.selectionForeground.rgba>>8&0xffffff,K=f.selectionForeground)),X&&M.push("xterm-decoration-top"),V){case 0x1000000:case 0x2000000:m=f.ansi[U],M.push(`xterm-bg-${U}`);break;case 0x3000000:m=aj.toColor(U>>16,U>>8&255,255&U),this._addStyle(g,`background-color:#${a0((U>>>0).toString(16),"0",6)}`);break;default:q?(m=f.foreground,M.push("xterm-bg-257")):m=f.background}switch(Y||I.isDim()&&(Y=cg.multiplyOpacity(m,.5)),$){case 0x1000000:case 0x2000000:I.isBold()&&H<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(H+=8),this._applyMinimumContrast(g,m,f.ansi[H],I,Y,void 0)||M.push(`xterm-fg-${H}`);break;case 0x3000000:let J=aj.toColor(H>>16&255,H>>8&255,255&H);this._applyMinimumContrast(g,m,J,I,Y,K)||this._addStyle(g,`color:#${a0(H.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(g,m,f.foreground,I,Y,K)||q&&M.push("xterm-fg-257")}M.length&&(g.className=M.join(" "),M.length=0),B||D||F||!L?g.textContent=y:v++,E!==this.defaultSpacing&&(g.style.letterSpacing=`${E}px`),u.push(g),A=j}return g&&v&&(g.textContent=y),u}_applyMinimumContrast(e,i,n,r,s,o){var a,l,c;if(1===this._optionsService.rawOptions.minimumContrastRatio||57508<=(l=a=r.getCode())&&l<=57558||9472<=(c=a)&&c<=9631)return!1;let h=this._getContrastCache(r),d;if(s||o||(d=h.getColor(i.rgba,n.rgba)),void 0===d){let e=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);d=cg.ensureContrastRatio(s||i,o||n,e),h.setColor((s||i).rgba,(o||n).rgba,d??null)}return!!d&&(this._addStyle(e,`color:${d.css}`),!0)}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,i){e.setAttribute("style",`${e.getAttribute("style")||""}${i};`)}_isCellInSelection(e,i){let n=this._selectionStart,r=this._selectionEnd;return!!n&&!!r&&(this._columnSelectMode?n[0]<=r[0]?e>=n[0]&&i>=n[1]&&e<r[0]&&i<=r[1]:e<n[0]&&i>=n[1]&&e>=r[0]&&i<=r[1]:i>n[1]&&i<r[1]||n[1]===r[1]&&i===n[1]&&e>=n[0]&&e<r[0]||n[1]<r[1]&&i===r[1]&&e<r[0]||n[1]<r[1]&&i===n[1]&&e>=n[0])}};function a0(e,i,n){for(;e.length<n;)e=i+e;return e}aQ=rF([rW(1,sh),rW(2,se),rW(3,so),rW(4,r6),rW(5,sn),rW(6,sd)],aQ);var a1=class{constructor(e,i){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let n=e.createElement("span");n.classList.add("xterm-char-measure-element");let r=e.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontWeight="bold";let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontStyle="italic";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontWeight="bold",o.style.fontStyle="italic",this._measureElements=[n,r,s,o],this._container.appendChild(n),this._container.appendChild(r),this._container.appendChild(s),this._container.appendChild(o),i.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,i,n,r){e===this._font&&i===this._fontSize&&n===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=i,this._weight=n,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,i,n){let r=0;if(!i&&!n&&1===e.length&&(r=e.charCodeAt(0))<256){if(-9999!==this._flat[r])return this._flat[r];let i=this._measure(e,0);return i>0&&(this._flat[r]=i),i}let s=e;i&&(s+="B"),n&&(s+="I");let o=this._holey.get(s);if(void 0===o){let r=0;i&&(r|=1),n&&(r|=2),(o=this._measure(e,r))>0&&this._holey.set(s,o)}return o}_measure(e,i){let n=this._measureElements[i];return n.textContent=e.repeat(32),n.offsetWidth/32}},a2=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,i,n,r=!1){if(this.selectionStart=i,this.selectionEnd=n,!i||!n||i[0]===n[0]&&i[1]===n[1])return void this.clear();let s=e.buffers.active.ydisp,o=i[1]-s,a=n[1]-s,l=Math.max(o,0),c=Math.min(a,e.rows-1);l>=e.rows||c<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=o,this.viewportEndRow=a,this.viewportCappedStartRow=l,this.viewportCappedEndRow=c,this.startCol=i[0],this.endCol=n[0])}isCellSelected(e,i,n){return!!this.hasSelection&&(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?i>=this.startCol&&n>=this.viewportCappedStartRow&&i<this.endCol&&n<=this.viewportCappedEndRow:i<this.startCol&&n>=this.viewportCappedStartRow&&i>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&i>=this.startCol&&i<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&i<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&i>=this.startCol)}},a5="xterm-dom-renderer-owner-",a3="xterm-rows",a4="xterm-fg-",a6="xterm-bg-",a8="xterm-focus",a9="xterm-selection",a7=1,le=class extends sE{constructor(e,i,n,r,s,o,a,l,c,h,d,u,p,f){super(),this._terminal=e,this._document=i,this._element=n,this._screenElement=r,this._viewportElement=s,this._helperContainer=o,this._linkifier2=a,this._charSizeService=c,this._optionsService=h,this._bufferService=d,this._coreService=u,this._coreBrowserService=p,this._themeService=f,this._terminalClass=a7++,this._rowElements=[],this._selectionRenderModel=new a2,this.onRequestRedraw=this._register(new sG).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(a3),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(a9),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions={css:{canvas:aZ(),cell:aZ()},device:{canvas:aZ(),cell:aZ(),char:{width:0,height:0,left:0,top:0}}},this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(e=>this._injectCss(e))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(aQ,document),this._element.classList.add(a5+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(e=>this._handleLinkHover(e))),this._register(this._linkifier2.onHideLinkUnderline(e=>this._handleLinkLeave(e))),this._register(sk(()=>{this._element.classList.remove(a5+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new a1(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;for(let i of(this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows,this._rowElements))i.style.width=`${this.dimensions.css.canvas.width}px`,i.style.height=`${this.dimensions.css.cell.height}px`,i.style.lineHeight=`${this.dimensions.css.cell.height}px`,i.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let i=`${this._terminalSelector} .${a3} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=i,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let i=`${this._terminalSelector} .${a3} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;i+=`${this._terminalSelector} .${a3} .xterm-dim { color: ${cg.multiplyOpacity(e.foreground,.5).css};}${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,s=`blink_block_${this._terminalClass}`;for(let[o,a]of(i+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}@keyframes ${r} { 50% { box-shadow: none; }}@keyframes ${s} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}${this._terminalSelector} .${a3}.${a8} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${a3}.${a8} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${a3}.${a8} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${a3} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${a3} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${a3} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${a3} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${a3} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}${this._terminalSelector} .${a9} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${a9} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${a9} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`,e.ansi.entries()))i+=`${this._terminalSelector} .${a4}${o} { color: ${a.css}; }${this._terminalSelector} .${a4}${o}.xterm-dim { color: ${cg.multiplyOpacity(a,.5).css}; }${this._terminalSelector} .${a6}${o} { background-color: ${a.css}; }`;i+=`${this._terminalSelector} .${a4}257 { color: ${cg.opaque(e.background).css}; }${this._terminalSelector} .${a4}257.xterm-dim { color: ${cg.multiplyOpacity(cg.opaque(e.background),.5).css}; }${this._terminalSelector} .${a6}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=i}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,i){for(let e=this._rowElements.length;e<=i;e++){let e=this._document.createElement("div");this._rowContainer.appendChild(e),this._rowElements.push(e)}for(;this._rowElements.length>i;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,i){this._refreshRowElements(e,i),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(a8),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(a8),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,i,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,i,n),this.renderRows(0,this._bufferService.rows-1),!e||!i||(this._selectionRenderModel.update(this._terminal,e,i,n),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,s=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,a=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(n){let n=e[0]>i[0];l.appendChild(this._createSelectionElement(o,n?i[0]:e[0],n?e[0]:i[0],a-o+1))}else{let n=r===o?e[0]:0,c=o===s?i[0]:this._bufferService.cols;if(l.appendChild(this._createSelectionElement(o,n,c)),l.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,a-o-1)),o!==a){let e=s===a?i[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(a,0,e))}}this._selectionContainer.appendChild(l)}_createSelectionElement(e,i,n,r=1){let s=this._document.createElement("div"),o=i*this.dimensions.css.cell.width,a=this.dimensions.css.cell.width*(n-i);return o+a>this.dimensions.css.canvas.width&&(a=this.dimensions.css.canvas.width-o),s.style.height=`${r*this.dimensions.css.cell.height}px`,s.style.top=`${e*this.dimensions.css.cell.height}px`,s.style.left=`${o}px`,s.style.width=`${a}px`,s}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,i){let n=this._bufferService.buffer,r=n.ybase+n.y,s=Math.min(n.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,a=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let c=e;c<=i;c++){let e=c+n.ydisp,i=this._rowElements[c],h=n.lines.get(e);if(!i||!h)break;i.replaceChildren(...this._rowFactory.createRow(h,e,e===r,a,l,s,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${a5}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,i,n,r,s,o){n<0&&(e=0),r<0&&(i=0);let a=this._bufferService.rows-1;n=Math.max(Math.min(n,a),0),r=Math.max(Math.min(r,a),0),s=Math.min(s,this._bufferService.cols);let l=this._bufferService.buffer,c=l.ybase+l.y,h=Math.min(l.x,s-1),d=this._optionsService.rawOptions.cursorBlink,u=this._optionsService.rawOptions.cursorStyle,p=this._optionsService.rawOptions.cursorInactiveStyle;for(let a=n;a<=r;++a){let f=a+l.ydisp,m=this._rowElements[a],g=l.lines.get(f);if(!m||!g)break;m.replaceChildren(...this._rowFactory.createRow(g,f,f===c,u,p,h,d,this.dimensions.css.cell.width,this._widthCache,o?a===n?e:0:-1,o?(a===r?i:s)-1:-1))}}};le=rF([rW(7,r9),rW(8,ss),rW(9,se),rW(10,r3),rW(11,r6),rW(12,so),rW(13,sd)],le);var lt=class extends sE{constructor(e,i,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new sG),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new lr(this._optionsService))}catch{this._measureStrategy=this._register(new ln(e,i,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};lt=rF([rW(2,se)],lt);var li=class extends sE{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,i){void 0!==e&&e>0&&void 0!==i&&i>0&&(this._result.width=e,this._result.height=i)}},ln=class extends li{constructor(e,i,n){super(),this._document=e,this._parentElement=i,this._optionsService=n,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},lr=class extends li{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let i=this._ctx.measureText("W");if(!("width"in i&&"fontBoundingBoxAscent"in i&&"fontBoundingBoxDescent"in i))throw Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},ls=class extends sE{constructor(e,i,n){super(),this._textarea=e,this._window=i,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new lo(this._window)),this._onDprChange=this._register(new sG),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new sG),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(e=>this._screenDprMonitor.setWindow(e))),this._register(sU.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(o2(this._textarea,"focus",()=>this._isFocused=!0)),this._register(o2(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return void 0===this._cachedIsFocused&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},lo=class extends sE{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new sN),this._onDprChange=this._register(new sG),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(sk(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=o2(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){this._resolutionMediaMatchList&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},la=class extends sE{constructor(){super(),this.linkProviders=[],this._register(sk(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let i=this.linkProviders.indexOf(e);-1!==i&&this.linkProviders.splice(i,1)}}}};function ll(e,i,n){let r=n.getBoundingClientRect(),s=e.getComputedStyle(n),o=parseInt(s.getPropertyValue("padding-left")),a=parseInt(s.getPropertyValue("padding-top"));return[i.clientX-r.left-o,i.clientY-r.top-a]}var lc=class{constructor(e,i){this._renderService=e,this._charSizeService=i}getCoords(e,i,n,r,s){return function(e,i,n,r,s,o,a,l,c){if(!o)return;let h=ll(e,i,n);return h[0]=Math.ceil((h[0]+(c?a/2:0))/a),h[1]=Math.ceil(h[1]/l),h[0]=Math.min(Math.max(h[0],1),r+ +!!c),h[1]=Math.min(Math.max(h[1],1),s),h}(window,e,i,n,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,s)}getMouseReportCoords(e,i){let n=ll(window,e,i);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};lc=rF([rW(0,sl),rW(1,ss)],lc);var lh=class{constructor(e,i){this._renderCallback=e,this._coreBrowserService=i,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,i,n){this._rowCount=n,e=void 0!==e?e:0,i=void 0!==i?i:this._rowCount-1,this._rowStart=void 0!==this._rowStart?Math.min(this._rowStart,e):e,this._rowEnd=void 0!==this._rowEnd?Math.max(this._rowEnd,i):i,this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,void 0===this._rowStart||void 0===this._rowEnd||void 0===this._rowCount)return void this._runRefreshCallbacks();let e=Math.max(this._rowStart,0),i=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,i),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},ld={},lu={getSafariVersion:()=>lb,isChromeOS:()=>lT,isFirefox:()=>lv,isIpad:()=>lw,isIphone:()=>lS,isLegacyEdge:()=>ly,isLinux:()=>lC,isMac:()=>lx,isNode:()=>lf,isSafari:()=>l_,isWindows:()=>lk};for(var lp in lu)rB(ld,lp,{get:lu[lp],enumerable:!0});var lf="u">typeof rP.default&&"title"in rP.default,lm=lf?"node":navigator.userAgent,lg=lf?"node":navigator.platform,lv=lm.includes("Firefox"),ly=lm.includes("Edge"),l_=/^((?!chrome|android).)*safari/i.test(lm);function lb(){if(!l_)return 0;let e=lm.match(/Version\/(\d+)/);return null===e||e.length<2?0:parseInt(e[1])}var lx=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(lg),lw="iPad"===lg,lS="iPhone"===lg,lk=["Windows","Win16","Win32","WinCE"].includes(lg),lC=lg.indexOf("Linux")>=0,lT=/\bCrOS\b/.test(lm),lE=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let i=0,n=0,r=e.timeRemaining(),s=0;for(;this._i<this._tasks.length;){if(i=performance.now(),this._tasks[this._i]()||this._i++,1.5*(n=Math.max(i=Math.max(1,performance.now()-i),n))>(s=e.timeRemaining())){r-i<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-i))}ms`),this._start();return}r=s}this.clear()}},lN=class extends lE{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let i=performance.now()+e;return{timeRemaining:()=>Math.max(0,i-performance.now())}}},lM=class extends lE{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},lO=!lf&&"requestIdleCallback"in window?lM:lN,lA=class{constructor(){this._queue=new lO}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},lR=class extends sE{constructor(e,i,n,r,s,o,a,l,c){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=r,this._coreService=s,this._coreBrowserService=l,this._renderer=this._register(new sN),this._pausedResizeTask=new lA,this._observerDisposable=this._register(new sN),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new sG),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new sG),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new sG),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new sG),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new lh((e,i)=>this._renderRows(e,i),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new lD(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(sk(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(a.onResize(()=>this._fullRefresh())),this._register(a.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(o.onDecorationRegistered(()=>this._fullRefresh())),this._register(o.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(a.cols,a.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(a.buffer.y,a.buffer.y,!0))),this._register(c.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,i),this._register(this._coreBrowserService.onWindowChange(e=>this._registerIntersectionObserver(e,i)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,i){if("IntersectionObserver"in e){let n=new e.IntersectionObserver(e=>this._handleIntersectionChange(e[e.length-1]),{threshold:0});n.observe(i),this._observerDisposable.value=sk(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=void 0===e.isIntersecting?0===e.intersectionRatio:!e.isIntersecting,this._isPaused||this._charSizeService.hasValidSize||this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,i,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput)return void this._syncOutputHandler.bufferRows(e,i);let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),i=Math.max(i,r.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,i,this._rowCount)}_renderRows(e,i){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput)return void this._syncOutputHandler.bufferRows(e,i);e=Math.min(e,this._rowCount-1),i=Math.min(i,this._rowCount-1),this._renderer.value.renderRows(e,i),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:i}),this._onRender.fire({start:e,end:i}),this._isNextRenderRedrawOnly=!0}}resize(e,i){this._rowCount=i,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(e=>this.refreshRows(e.start,e.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,i){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,i)):this._renderer.value.handleResize(e,i),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,i,n){this._selectionState.start=e,this._selectionState.end=i,this._selectionState.columnSelectMode=n,this._renderer.value?.handleSelectionChanged(e,i,n)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};lR=rF([rW(2,se),rW(3,ss),rW(4,r6),rW(5,sn),rW(6,r3),rW(7,so),rW(8,sd)],lR);var lD=class{constructor(e,i,n){this._coreBrowserService=e,this._coreService=i,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,i){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,i)):(this._start=e,this._end=i,this._isBuffering=!0),void 0===this._timeout&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(void 0!==this._timeout&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){void 0!==this._timeout&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function lL(e,i,n,r){return lB(Math.abs(e-lj(e,n)-(i-lj(i,n)))-function(e,i,n){let r=0,s=e-lj(e,n),o=i-lj(i,n);for(let a=0;a<Math.abs(s-o);a++){let o="A"===function(e,i){return e>i?"A":"B"}(e,i)?-1:1;n.buffer.lines.get(s+o*a)?.isWrapped&&r++}return r}(e,i,n),lP(e>i?"A":"B",r))}function lj(e,i){let n=0,r=i.buffer.lines.get(e),s=r?.isWrapped;for(;s&&e>=0&&e<i.rows;)n++,r=i.buffer.lines.get(--e),s=r?.isWrapped;return n}function lI(e,i,n,r,s,o){let a=e,l=i,c="";for(;(a!==n||l!==r)&&l>=0&&l<o.buffer.lines.length;)a+=s?1:-1,s&&a>o.cols-1?(c+=o.buffer.translateBufferLineToString(l,!1,e,a),a=0,e=0,l++):!s&&a<0&&(c+=o.buffer.translateBufferLineToString(l,!1,0,e+1),e=a=o.cols-1,l--);return c+o.buffer.translateBufferLineToString(l,!1,e,a)}function lP(e,i){return aR.ESC+(i?"O":"[")+e}function lB(e,i){e=Math.floor(e);let n="";for(let r=0;r<e;r++)n+=i;return n}var lz=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,i=this.selectionEnd;return!!e&&!!i&&(e[1]>i[1]||e[1]===i[1]&&e[0]>i[0])}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function lF(e,i){if(e.start.y>e.end.y)throw Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return i*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var lW=RegExp(" ","g"),lH=class extends sE{constructor(e,i,n,r,s,o,a,l,c){super(),this._element=e,this._screenElement=i,this._linkifier=n,this._bufferService=r,this._coreService=s,this._mouseService=o,this._optionsService=a,this._renderService=l,this._coreBrowserService=c,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new rQ,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new sG),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new sG),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new sG),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new sG),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=e=>this._handleMouseMove(e),this._mouseUpListener=e=>this._handleMouseUp(e),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(e=>this._handleTrim(e)),this._register(this._bufferService.buffers.onBufferActivate(e=>this._handleBufferActivate(e))),this.enable(),this._model=new lz(this._bufferService),this._activeSelectionMode=0,this._register(sk(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(e=>{e.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!!e&&!!i&&(e[0]!==i[0]||e[1]!==i[1])}get selectionText(){let e=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;if(!e||!i)return"";let n=this._bufferService.buffer,r=[];if(3===this._activeSelectionMode){if(e[0]===i[0])return"";let s=e[0]<i[0]?e[0]:i[0],o=e[0]<i[0]?i[0]:e[0];for(let a=e[1];a<=i[1];a++){let e=n.translateBufferLineToString(a,!0,s,o);r.push(e)}}else{let s=e[1]===i[1]?i[0]:void 0;r.push(n.translateBufferLineToString(e[1],!0,e[0],s));for(let s=e[1]+1;s<=i[1]-1;s++){let e=n.lines.get(s),i=n.translateBufferLineToString(s,!0);e?.isWrapped?r[r.length-1]+=i:r.push(i)}if(e[1]!==i[1]){let e=n.lines.get(i[1]),s=n.translateBufferLineToString(i[1],!0,0,i[0]);e&&e.isWrapped?r[r.length-1]+=s:r.push(s)}}return r.map(e=>e.replace(lW," ")).join(lk?`\r
|
|
18
|
+
`:`
|
|
19
|
+
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),lC&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:3===this._activeSelectionMode})}_isClickInSelection(e){let i=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!!n&&!!r&&!!i&&this._areCoordsInSelection(i,n,r)}isCellInSelection(e,i){let n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!!n&&!!r&&this._areCoordsInSelection([e,i],n,r)}_areCoordsInSelection(e,i,n){return e[1]>i[1]&&e[1]<n[1]||i[1]===n[1]&&e[1]===i[1]&&e[0]>=i[0]&&e[0]<n[0]||i[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||i[1]<n[1]&&e[1]===i[1]&&e[0]>=i[0]}_selectWordAtCursor(e,i){let n=this._linkifier.currentLink?.link?.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=lF(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return!!r&&(this._selectWordAt(r,i),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,i){this._model.clearSelection(),e=Math.max(e,0),i=Math.min(i,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,i],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let i=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(i)return i[0]--,i[1]--,i[1]+=this._bufferService.buffer.ydisp,i}_getMouseEventScrollAmount(e){let i=ll(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return i>=0&&i<=n?0:(i>n&&(i-=n),(i=Math.min(Math.max(i,-50),50)/50)/Math.abs(i)+Math.round(14*i))}shouldForceSelection(e){return lx?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(2===e.button&&this.hasSelection)&&0===e.button){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):1===e.detail?this._handleSingleClick(e):2===e.detail?this._handleDoubleClick(e):3===e.detail&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),50)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=3*!!this.shouldColumnSelect(e),this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let i=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);i&&i.length!==this._model.selectionStart[0]&&0===i.hasWidth(this._model.selectionStart[0])&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let i=this._getMouseBufferCoords(e);i&&(this._activeSelectionMode=2,this._selectLineAt(i[1]))}shouldColumnSelect(e){return e.altKey&&!(lx&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let i=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd)return void this.refresh(!0);2===this._activeSelectionMode?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:1===this._activeSelectionMode&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),3!==this._activeSelectionMode&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let e=n.lines.get(this._model.selectionEnd[1]);e&&0===e.hasWidth(this._model.selectionEnd[0])&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}i&&i[0]===this._model.selectionEnd[0]&&i[1]===this._model.selectionEnd[1]||this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(3!==this._activeSelectionMode&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(3!==this._activeSelectionMode&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let i=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&i<500&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let i=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(i&&void 0!==i[0]&&void 0!==i[1]){let e=function(e,i,n,r){var s,o,a,l,c,h,d,u,p,f,m,g,v,y,_,b;let w,S=n.buffer.x,k=n.buffer.y;if(!n.buffer.hasScrollback){let b,w,C;return s=S,(0===lL(o=k,i,a=n,l=r).length?"":lB(lI(s,o,s,o-lj(o,a),!1,a).length,lP("D",l)))+lL(k,i,n,r)+(c=S,h=k,d=e,b=lL(h,u=i,p=n,f=r).length>0?u-lj(u,p):h,C=(m=c,g=h,w=lL(v=d,y=u,_=p,f).length>0?y-lj(y,_):g,m<v&&w<=y||m>=v&&w<y?"C":"D"),lB(lI(c,b,d,u,"C"===C,p).length,lP(C,f)))}if(k===i)return w=S>e?"D":"C",lB(Math.abs(S-e),lP(w,r));w=k>i?"D":"C";let C=Math.abs(k-i);return lB((b=k>i?e:S,n.cols-b+(C-1)*n.cols+1+((k>i?S:e)-1)),lP(w,r))}(i[0]-1,i[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(e,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,i=this._model.finalSelectionEnd,n=!!e&&!!i&&(e[0]!==i[0]||e[1]!==i[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,i,n);return}!e||!i||this._oldSelectionStart&&this._oldSelectionEnd&&e[0]===this._oldSelectionStart[0]&&e[1]===this._oldSelectionStart[1]&&i[0]===this._oldSelectionEnd[0]&&i[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(e,i,n)}_fireOnSelectionChange(e,i,n){this._oldSelectionStart=e,this._oldSelectionEnd=i,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(e=>this._handleTrim(e))}_convertViewportColToCharacterIndex(e,i){let n=i;for(let r=0;i>=r;r++){let s=e.loadCell(r,this._workCell).getChars().length;0===this._workCell.getWidth()?n--:s>1&&i!==r&&(n+=s-1)}return n}setSelection(e,i,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,i],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,i,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let s=this._bufferService.buffer,o=s.lines.get(e[1]);if(!o)return;let a=s.translateBufferLineToString(e[1],!1),l=this._convertViewportColToCharacterIndex(o,e[0]),c=l,h=e[0]-l,d=0,u=0,p=0,f=0;if(" "===a.charAt(l)){for(;l>0&&" "===a.charAt(l-1);)l--;for(;c<a.length&&" "===a.charAt(c+1);)c++}else{let i=e[0],n=e[0];0===o.getWidth(i)&&(d++,i--),2===o.getWidth(n)&&(u++,n++);let r=o.getString(n).length;for(r>1&&(f+=r-1,c+=r-1);i>0&&l>0&&!this._isCharWordSeparator(o.loadCell(i-1,this._workCell));){o.loadCell(i-1,this._workCell);let e=this._workCell.getChars().length;0===this._workCell.getWidth()?(d++,i--):e>1&&(p+=e-1,l-=e-1),l--,i--}for(;n<o.length&&c+1<a.length&&!this._isCharWordSeparator(o.loadCell(n+1,this._workCell));){o.loadCell(n+1,this._workCell);let e=this._workCell.getChars().length;2===this._workCell.getWidth()?(u++,n++):e>1&&(f+=e-1,c+=e-1),c++,n++}}c++;let m=l+h-d+p,g=Math.min(this._bufferService.cols,c-l+d+u-p-f);if(!(!i&&""===a.slice(l,c).trim())){if(n&&0===m&&32!==o.getCodePoint(0)){let i=s.lines.get(e[1]-1);if(i&&o.isWrapped&&32!==i.getCodePoint(this._bufferService.cols-1)){let i=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(i){let e=this._bufferService.cols-i.start;m-=e,g+=e}}}if(r&&m+g===this._bufferService.cols&&32!==o.getCodePoint(this._bufferService.cols-1)){let i=s.lines.get(e[1]+1);if(i?.isWrapped&&32!==i.getCodePoint(0)){let i=this._getWordAt([0,e[1]+1],!1,!1,!0);i&&(g+=i.length)}}return{start:m,length:g}}}_selectWordAt(e,i){let n=this._getWordAt(e,i);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let i=this._getWordAt(e,!0);if(i){let n=e[1];for(;i.start<0;)i.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;i.start+i.length>this._bufferService.cols;)i.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?i.start:i.start+i.length,n]}}_isCharWordSeparator(e){return 0!==e.getWidth()&&this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let i=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:i.first},end:{x:this._bufferService.cols-1,y:i.last}};this._model.selectionStart=[0,i.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=lF(n,this._bufferService.cols)}};lH=rF([rW(3,r3),rW(4,r6),rW(5,sa),rW(6,se),rW(7,sl),rW(8,so)],lH);var l$=class{constructor(){this._data={}}set(e,i,n){this._data[e]||(this._data[e]={}),this._data[e][i]=n}get(e,i){return this._data[e]?this._data[e][i]:void 0}clear(){this._data={}}},lU=class{constructor(){this._color=new l$,this._css=new l$}setCss(e,i,n){this._css.set(e,i,n)}getCss(e,i){return this._css.get(e,i)}setColor(e,i,n){this._color.set(e,i,n)}getColor(e,i){return this._color.get(e,i)}clear(){this._color.clear(),this._css.clear()}},lV=Object.freeze((()=>{let e=[cv.toColor("#2e3436"),cv.toColor("#cc0000"),cv.toColor("#4e9a06"),cv.toColor("#c4a000"),cv.toColor("#3465a4"),cv.toColor("#75507b"),cv.toColor("#06989a"),cv.toColor("#d3d7cf"),cv.toColor("#555753"),cv.toColor("#ef2929"),cv.toColor("#8ae234"),cv.toColor("#fce94f"),cv.toColor("#729fcf"),cv.toColor("#ad7fa8"),cv.toColor("#34e2e2"),cv.toColor("#eeeeec")],i=[0,95,135,175,215,255];for(let n=0;n<216;n++){let r=i[n/36%6|0],s=i[n/6%6|0],o=i[n%6];e.push({css:aj.toCss(r,s,o),rgba:aj.toRgba(r,s,o)})}for(let i=0;i<24;i++){let n=8+10*i;e.push({css:aj.toCss(n,n,n),rgba:aj.toRgba(n,n,n)})}return e})()),lq=cv.toColor("#ffffff"),lY=cv.toColor("#000000"),lK=cv.toColor("#ffffff"),lX={css:"rgba(255, 255, 255, 0.3)",rgba:0xffffff4d},lJ=class extends sE{constructor(e){super(),this._optionsService=e,this._contrastCache=new lU,this._halfContrastCache=new lU,this._onChangeColors=this._register(new sG),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:lq,background:lY,cursor:lK,cursorAccent:lY,selectionForeground:void 0,selectionBackgroundTransparent:lX,selectionBackgroundOpaque:cg.blend(lY,lX),selectionInactiveBackgroundTransparent:lX,selectionInactiveBackgroundOpaque:cg.blend(lY,lX),scrollbarSliderBackground:cg.opacity(lq,.2),scrollbarSliderHoverBackground:cg.opacity(lq,.4),scrollbarSliderActiveBackground:cg.opacity(lq,.5),overviewRulerBorder:lq,ansi:lV.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let i=this._colors;if(i.foreground=lG(e.foreground,lq),i.background=lG(e.background,lY),i.cursor=cg.blend(i.background,lG(e.cursor,lK)),i.cursorAccent=cg.blend(i.background,lG(e.cursorAccent,lY)),i.selectionBackgroundTransparent=lG(e.selectionBackground,lX),i.selectionBackgroundOpaque=cg.blend(i.background,i.selectionBackgroundTransparent),i.selectionInactiveBackgroundTransparent=lG(e.selectionInactiveBackground,i.selectionBackgroundTransparent),i.selectionInactiveBackgroundOpaque=cg.blend(i.background,i.selectionInactiveBackgroundTransparent),i.selectionForeground=e.selectionForeground?lG(e.selectionForeground,aF):void 0,i.selectionForeground===aF&&(i.selectionForeground=void 0),cg.isOpaque(i.selectionBackgroundTransparent)&&(i.selectionBackgroundTransparent=cg.opacity(i.selectionBackgroundTransparent,.3)),cg.isOpaque(i.selectionInactiveBackgroundTransparent)&&(i.selectionInactiveBackgroundTransparent=cg.opacity(i.selectionInactiveBackgroundTransparent,.3)),i.scrollbarSliderBackground=lG(e.scrollbarSliderBackground,cg.opacity(i.foreground,.2)),i.scrollbarSliderHoverBackground=lG(e.scrollbarSliderHoverBackground,cg.opacity(i.foreground,.4)),i.scrollbarSliderActiveBackground=lG(e.scrollbarSliderActiveBackground,cg.opacity(i.foreground,.5)),i.overviewRulerBorder=lG(e.overviewRulerBorder,lq),i.ansi=lV.slice(),i.ansi[0]=lG(e.black,lV[0]),i.ansi[1]=lG(e.red,lV[1]),i.ansi[2]=lG(e.green,lV[2]),i.ansi[3]=lG(e.yellow,lV[3]),i.ansi[4]=lG(e.blue,lV[4]),i.ansi[5]=lG(e.magenta,lV[5]),i.ansi[6]=lG(e.cyan,lV[6]),i.ansi[7]=lG(e.white,lV[7]),i.ansi[8]=lG(e.brightBlack,lV[8]),i.ansi[9]=lG(e.brightRed,lV[9]),i.ansi[10]=lG(e.brightGreen,lV[10]),i.ansi[11]=lG(e.brightYellow,lV[11]),i.ansi[12]=lG(e.brightBlue,lV[12]),i.ansi[13]=lG(e.brightMagenta,lV[13]),i.ansi[14]=lG(e.brightCyan,lV[14]),i.ansi[15]=lG(e.brightWhite,lV[15]),e.extendedAnsi){let n=Math.min(i.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<n;r++)i.ansi[r+16]=lG(e.extendedAnsi[r],lV[r+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(void 0===e){for(let e=0;e<this._restoreColors.ansi.length;++e)this._colors.ansi[e]=this._restoreColors.ansi[e];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function lG(e,i){if(void 0!==e)try{return cv.toColor(e)}catch{}return i}lJ=rF([rW(0,se)],lJ);var lZ=class{constructor(...e){for(let[i,n]of(this._entries=new Map,e))this.set(i,n)}set(e,i){let n=this._entries.get(e);return this._entries.set(e,i),n}forEach(e){for(let[i,n]of this._entries.entries())e(i,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},lQ=class{constructor(){this._services=new lZ,this._services.set(r9,this)}setService(e,i){this._services.set(e,i)}getService(e){return this._services.get(e)}createInstance(e,...i){let n=(e[r1]||[]).sort((e,i)=>e.index-i.index),r=[];for(let i of n){let n=this._services.get(i.id);if(!n)throw Error(`[createInstance] ${e.name} depends on UNKNOWN service ${i.id._id}.`);r.push(n)}let s=n.length>0?n[0].index:i.length;if(i.length!==s)throw Error(`[createInstance] First service dependency of ${e.name} at position ${s+1} conflicts with ${i.length} static arguments`);return new e(...i,...r)}},l0={trace:0,debug:1,info:2,warn:3,error:4,off:5},l1=class extends sE{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=l0[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let i=0;i<e.length;i++)"function"==typeof e[i]&&(e[i]=e[i]())}_log(e,i,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+i,...n)}trace(e,...i){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,i)}debug(e,...i){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,i)}info(e,...i){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,i)}warn(e,...i){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,i)}error(e,...i){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,i)}};l1=rF([rW(0,se)],l1);var l2=class extends sE{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new sG),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new sG),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new sG),this.onTrim=this.onTrimEmitter.event,this._array=Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let i=Array(e);for(let n=0;n<Math.min(e,this.length);n++)i[n]=this._array[this._getCyclicIndex(n)];this._array=i,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let i=this._length;i<e;i++)this._array[i]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,i){this._array[this._getCyclicIndex(e)]=i}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,i,...n){if(i){for(let n=e;n<this._length-i;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+i)];this._length-=i,this.onDeleteEmitter.fire({index:e,amount:i})}for(let i=this._length-1;i>=e;i--)this._array[this._getCyclicIndex(i+n.length)]=this._array[this._getCyclicIndex(i)];for(let i=0;i<n.length;i++)this._array[this._getCyclicIndex(e+i)]=n[i];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let e=this._length+n.length-this._maxLength;this._startIndex+=e,this._length=this._maxLength,this.onTrimEmitter.fire(e)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,i,n){if(!(i<=0)){if(e<0||e>=this._length)throw Error("start argument out of range");if(e+n<0)throw Error("Cannot shift elements in list beyond index 0");if(n>0){for(let r=i-1;r>=0;r--)this.set(e+r+n,this.get(e+r));let r=e+i+n-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<i;r++)this.set(e+r+n,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},l5=Object.freeze(new rG),l3=0,l4=class e{constructor(e,i,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*e);let r=i||rQ.fromCharData([0,"",1,0]);for(let i=0;i<e;++i)this.setCell(i,r);this.length=e}get(e){let i=this._data[3*e+0],n=2097151&i;return[this._data[3*e+1],2097152&i?this._combined[e]:n?rY(n):"",i>>22,2097152&i?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,i){this._data[3*e+1]=i[0],i[1].length>1?(this._combined[e]=i[1],this._data[3*e+0]=2097152|e|i[2]<<22):this._data[3*e+0]=i[1].charCodeAt(0)|i[2]<<22}getWidth(e){return this._data[3*e+0]>>22}hasWidth(e){return 0xc00000&this._data[3*e+0]}getFg(e){return this._data[3*e+1]}getBg(e){return this._data[3*e+2]}hasContent(e){return 4194303&this._data[3*e+0]}getCodePoint(e){let i=this._data[3*e+0];return 2097152&i?this._combined[e].charCodeAt(this._combined[e].length-1):2097151&i}isCombined(e){return 2097152&this._data[3*e+0]}getString(e){let i=this._data[3*e+0];return 2097152&i?this._combined[e]:2097151&i?rY(2097151&i):""}isProtected(e){return 0x20000000&this._data[3*e+2]}loadCell(e,i){return l3=3*e,i.content=this._data[l3+0],i.fg=this._data[l3+1],i.bg=this._data[l3+2],2097152&i.content&&(i.combinedData=this._combined[e]),0x10000000&i.bg&&(i.extended=this._extendedAttrs[e]),i}setCell(e,i){2097152&i.content&&(this._combined[e]=i.combinedData),0x10000000&i.bg&&(this._extendedAttrs[e]=i.extended),this._data[3*e+0]=i.content,this._data[3*e+1]=i.fg,this._data[3*e+2]=i.bg}setCellFromCodepoint(e,i,n,r){0x10000000&r.bg&&(this._extendedAttrs[e]=r.extended),this._data[3*e+0]=i|n<<22,this._data[3*e+1]=r.fg,this._data[3*e+2]=r.bg}addCodepointToCell(e,i,n){let r=this._data[3*e+0];2097152&r?this._combined[e]+=rY(i):2097151&r?(this._combined[e]=rY(2097151&r)+rY(i),r&=-2097152,r|=2097152):r=4194304|i,n&&(r&=-0xc00001,r|=n<<22),this._data[3*e+0]=r}insertCells(e,i,n){if((e%=this.length)&&2===this.getWidth(e-1)&&this.setCellFromCodepoint(e-1,0,1,n),i<this.length-e){let r=new rQ;for(let n=this.length-e-i-1;n>=0;--n)this.setCell(e+i+n,this.loadCell(e+n,r));for(let r=0;r<i;++r)this.setCell(e+r,n)}else for(let i=e;i<this.length;++i)this.setCell(i,n);2===this.getWidth(this.length-1)&&this.setCellFromCodepoint(this.length-1,0,1,n)}deleteCells(e,i,n){if(e%=this.length,i<this.length-e){let r=new rQ;for(let n=0;n<this.length-e-i;++n)this.setCell(e+n,this.loadCell(e+i+n,r));for(let e=this.length-i;e<this.length;++e)this.setCell(e,n)}else for(let i=e;i<this.length;++i)this.setCell(i,n);e&&2===this.getWidth(e-1)&&this.setCellFromCodepoint(e-1,0,1,n),0!==this.getWidth(e)||this.hasContent(e)||this.setCellFromCodepoint(e,0,1,n)}replaceCells(e,i,n,r=!1){if(r){for(e&&2===this.getWidth(e-1)&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,n),i<this.length&&2===this.getWidth(i-1)&&!this.isProtected(i)&&this.setCellFromCodepoint(i,0,1,n);e<i&&e<this.length;)this.isProtected(e)||this.setCell(e,n),e++;return}for(e&&2===this.getWidth(e-1)&&this.setCellFromCodepoint(e-1,0,1,n),i<this.length&&2===this.getWidth(i-1)&&this.setCellFromCodepoint(i,0,1,n);e<i&&e<this.length;)this.setCell(e++,n)}resize(e,i){if(e===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;let n=3*e;if(e>this.length){if(this._data.buffer.byteLength>=4*n)this._data=new Uint32Array(this._data.buffer,0,n);else{let e=new Uint32Array(n);e.set(this._data),this._data=e}for(let n=this.length;n<e;++n)this.setCell(n,i)}else{this._data=this._data.subarray(0,n);let i=Object.keys(this._combined);for(let n=0;n<i.length;n++){let r=parseInt(i[n],10);r>=e&&delete this._combined[r]}let r=Object.keys(this._extendedAttrs);for(let i=0;i<r.length;i++){let n=parseInt(r[i],10);n>=e&&delete this._extendedAttrs[n]}}return this.length=e,4*n*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,i=!1){if(i){for(let i=0;i<this.length;++i)this.isProtected(i)||this.setCell(i,e);return}this._combined={},this._extendedAttrs={};for(let i=0;i<this.length;++i)this.setCell(i,e)}copyFrom(e){for(let i in this.length!==e.length?this._data=new Uint32Array(e._data):this._data.set(e._data),this.length=e.length,this._combined={},e._combined)this._combined[i]=e._combined[i];for(let i in this._extendedAttrs={},e._extendedAttrs)this._extendedAttrs[i]=e._extendedAttrs[i];this.isWrapped=e.isWrapped}clone(){let i=new e(0);for(let e in i._data=new Uint32Array(this._data),i.length=this.length,this._combined)i._combined[e]=this._combined[e];for(let e in this._extendedAttrs)i._extendedAttrs[e]=this._extendedAttrs[e];return i.isWrapped=this.isWrapped,i}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(4194303&this._data[3*e+0])return e+(this._data[3*e+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(4194303&this._data[3*e+0]||0x3000000&this._data[3*e+2])return e+(this._data[3*e+0]>>22);return 0}copyCellsFrom(e,i,n,r,s){let o=e._data;if(s)for(let s=r-1;s>=0;s--){for(let e=0;e<3;e++)this._data[(n+s)*3+e]=o[(i+s)*3+e];0x10000000&o[(i+s)*3+2]&&(this._extendedAttrs[n+s]=e._extendedAttrs[i+s])}else for(let s=0;s<r;s++){for(let e=0;e<3;e++)this._data[(n+s)*3+e]=o[(i+s)*3+e];0x10000000&o[(i+s)*3+2]&&(this._extendedAttrs[n+s]=e._extendedAttrs[i+s])}let a=Object.keys(e._combined);for(let r=0;r<a.length;r++){let s=parseInt(a[r],10);s>=i&&(this._combined[s-i+n]=e._combined[s])}}translateToString(e,i,n,r){i=i??0,n=n??this.length,e&&(n=Math.min(n,this.getTrimmedLength())),r&&(r.length=0);let s="";for(;i<n;){let e=this._data[3*i+0],n=2097151&e,o=2097152&e?this._combined[i]:n?rY(n):" ";if(s+=o,r)for(let e=0;e<o.length;++e)r.push(i);i+=e>>22||1}return r&&r.push(i),s}};function l6(e,i,n){if(i===e.length-1)return e[i].getTrimmedLength();let r=!e[i].hasContent(n-1)&&1===e[i].getWidth(n-1),s=2===e[i+1].getWidth(0);return r&&s?n-1:n}var l8=class e{constructor(i){this.line=i,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new sG),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),sS(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};l8._nextId=1;var l9={},l7=l9.B;l9[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},l9.A={"#":"£"},l9.B=void 0,l9[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},l9.C=l9[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},l9.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},l9.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},l9.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},l9.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},l9.E=l9[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},l9.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},l9.H=l9[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},l9["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var ce=class{constructor(e,i,n){this._hasScrollback=e,this._optionsService=i,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=l5.clone(),this.savedCharset=l7,this.markers=[],this._nullCell=rQ.fromCharData([0,"",1,0]),this._whitespaceCell=rQ.fromCharData([0," ",1,32]),this._isClearing=!1,this._memoryCleanupQueue=new lO,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new l2(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new rZ),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new rZ),this._whitespaceCell}getBlankLine(e,i){return new l4(this._bufferService.cols,this.getNullCell(e),i)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let i=e+this._optionsService.rawOptions.scrollback;return i>0xffffffff?0xffffffff:i}fillViewportRows(e){if(0===this.lines.length){void 0===e&&(e=l5);let i=this._rows;for(;i--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new l2(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,i){let n=this.getNullCell(l5),r=0,s=this._getCorrectBufferLength(i);if(s>this.lines.maxLength&&(this.lines.maxLength=s),this.lines.length>0){if(this._cols<e)for(let i=0;i<this.lines.length;i++)r+=+this.lines.get(i).resize(e,n);let o=0;if(this._rows<i)for(let r=this._rows;r<i;r++)this.lines.length<i+this.ybase&&(this._optionsService.rawOptions.windowsMode||void 0!==this._optionsService.rawOptions.windowsPty.backend||void 0!==this._optionsService.rawOptions.windowsPty.buildNumber?this.lines.push(new l4(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+o+1?(this.ybase--,o++,this.ydisp>0&&this.ydisp--):this.lines.push(new l4(e,n)));else for(let e=this._rows;e>i;e--)this.lines.length>i+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(s<this.lines.maxLength){let e=this.lines.length-s;e>0&&(this.lines.trimStart(e),this.ybase=Math.max(this.ybase-e,0),this.ydisp=Math.max(this.ydisp-e,0),this.savedY=Math.max(this.savedY-e,0)),this.lines.maxLength=s}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,i-1),o&&(this.y+=o),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=i-1,this._isReflowEnabled&&(this._reflow(e,i),this._cols>e))for(let i=0;i<this.lines.length;i++)r+=+this.lines.get(i).resize(e,n);this._cols=e,this._rows=i,this._memoryCleanupQueue.clear(),r>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let i=0;for(;this._memoryCleanupPosition<this.lines.length;)if((i+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory())>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&"conpty"===e.backend&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,i){this._cols!==e&&(e>this._cols?this._reflowLarger(e,i):this._reflowSmaller(e,i))}_reflowLarger(e,i){let n=this._optionsService.rawOptions.reflowCursorLine,r=function(e,i,n,r,s,o){let a=[];for(let l=0;l<e.length-1;l++){let c=l,h=e.get(++c);if(!h.isWrapped)continue;let d=[e.get(l)];for(;c<e.length&&h.isWrapped;)d.push(h),h=e.get(++c);if(!o&&r>=l&&r<c){l+=d.length-1;continue}let u=0,p=l6(d,0,i),f=1,m=0;for(;f<d.length;){let e=l6(d,f,i),r=Math.min(e-m,n-p);d[u].copyCellsFrom(d[f],m,p,r,!1),(p+=r)===n&&(u++,p=0),(m+=r)===e&&(f++,m=0),0===p&&0!==u&&2===d[u-1].getWidth(n-1)&&(d[u].copyCellsFrom(d[u-1],n-1,p++,1,!1),d[u-1].setCell(n-1,s))}d[u].replaceCells(p,n,s);let g=0;for(let e=d.length-1;e>0&&(e>u||0===d[e].getTrimmedLength());e--)g++;g>0&&(a.push(l+d.length-g),a.push(g)),l+=d.length-1}return a}(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(l5),n);if(r.length>0){let n=function(e,i){let n=[],r=0,s=i[0],o=0;for(let a=0;a<e.length;a++)if(s===a){let n=i[++r];e.onDeleteEmitter.fire({index:a-o,amount:n}),a+=n-1,o+=n,s=i[++r]}else n.push(a);return{layout:n,countRemoved:o}}(this.lines,r);(function(e,i){let n=[];for(let r=0;r<i.length;r++)n.push(e.get(i[r]));for(let i=0;i<n.length;i++)e.set(i,n[i]);e.length=i.length})(this.lines,n.layout),this._reflowLargerAdjustViewport(e,i,n.countRemoved)}}_reflowLargerAdjustViewport(e,i,n){let r=this.getNullCell(l5),s=n;for(;s-- >0;)0===this.ybase?(this.y>0&&this.y--,this.lines.length<i&&this.lines.push(new l4(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,i){let n=this._optionsService.rawOptions.reflowCursorLine,r=this.getNullCell(l5),s=[],o=0;for(let a=this.lines.length-1;a>=0;a--){let l=this.lines.get(a);if(!l||!l.isWrapped&&l.getTrimmedLength()<=e)continue;let c=[l];for(;l.isWrapped&&a>0;)l=this.lines.get(--a),c.unshift(l);if(!n){let e=this.ybase+this.y;if(e>=a&&e<a+c.length)continue}let h=c[c.length-1].getTrimmedLength(),d=function(e,i,n){let r=[],s=e.map((n,r)=>l6(e,r,i)).reduce((e,i)=>e+i),o=0,a=0,l=0;for(;l<s;){if(s-l<n){r.push(s-l);break}o+=n;let c=l6(e,a,i);o>c&&(o-=c,a++);let h=2===e[a].getWidth(o-1);h&&o--;let d=h?n-1:n;r.push(d),l+=d}return r}(c,this._cols,e),u=d.length-c.length,p;p=0===this.ybase&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+u):Math.max(0,this.lines.length-this.lines.maxLength+u);let f=[];for(let e=0;e<u;e++){let e=this.getBlankLine(l5,!0);f.push(e)}f.length>0&&(s.push({start:a+c.length+o,newLines:f}),o+=f.length),c.push(...f);let m=d.length-1,g=d[m];0===g&&(g=d[--m]);let v=c.length-u-1,y=h;for(;v>=0;){let e=Math.min(y,g);if(void 0===c[m])break;c[m].copyCellsFrom(c[v],y-e,g-e,e,!0),0==(g-=e)&&(g=d[--m]),0==(y-=e)&&(y=l6(c,Math.max(--v,0),this._cols))}for(let i=0;i<c.length;i++)d[i]<e&&c[i].setCell(d[i],r);let _=u-p;for(;_-- >0;)0===this.ybase?this.y<i-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+o)-i&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+u,this.ybase+i-1)}if(s.length>0){let e=[],i=[];for(let e=0;e<this.lines.length;e++)i.push(this.lines.get(e));let n=this.lines.length,r=n-1,a=0,l=s[0];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+o);let c=0;for(let h=Math.min(this.lines.maxLength-1,n+o-1);h>=0;h--)if(l&&l.start>r+c){for(let e=l.newLines.length-1;e>=0;e--)this.lines.set(h--,l.newLines[e]);h++,e.push({index:r+1,amount:l.newLines.length}),c+=l.newLines.length,l=s[++a]}else this.lines.set(h,i[r--]);let h=0;for(let i=e.length-1;i>=0;i--)e[i].index+=h,this.lines.onInsertEmitter.fire(e[i]),h+=e[i].amount;let d=Math.max(0,n+o-this.lines.maxLength);d>0&&this.lines.onTrimEmitter.fire(d)}}translateBufferLineToString(e,i,n=0,r){let s=this.lines.get(e);return s?s.translateToString(i,n,r):""}getWrappedRangeForLine(e){let i=e,n=e;for(;i>0&&this.lines.get(i).isWrapped;)i--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:i,last:n}}setupTabStops(e){for(null!=e?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(null==e&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(null==e&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let i=0;i<this.markers.length;i++)this.markers[i].line===e&&(this.markers[i].dispose(),this.markers.splice(i--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let i=new l8(e);return this.markers.push(i),i.register(this.lines.onTrim(e=>{i.line-=e,i.line<0&&i.dispose()})),i.register(this.lines.onInsert(e=>{i.line>=e.index&&(i.line+=e.amount)})),i.register(this.lines.onDelete(e=>{i.line>=e.index&&i.line<e.index+e.amount&&i.dispose(),i.line>e.index&&(i.line-=e.amount)})),i.register(i.onDispose(()=>this._removeMarker(i))),i}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},ct=class extends sE{constructor(e,i){super(),this._optionsService=e,this._bufferService=i,this._onBufferActivate=this._register(new sG),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new ce(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new ce(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,i){this._normal.resize(e,i),this._alt.resize(e,i),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},ci=class extends sE{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new sG),this.onResize=this._onResize.event,this._onScroll=this._register(new sG),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,2),this.rows=Math.max(e.rawOptions.rows||0,1),this.buffers=this._register(new ct(e,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,i){let n=this.cols!==e,r=this.rows!==i;this.cols=e,this.rows=i,this.buffers.resize(e,i),this._onResize.fire({cols:e,rows:i,colsChanged:n,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,i=!1){let n=this.buffer,r;(r=this._cachedBlankLine)&&r.length===this.cols&&r.getFg(0)===e.fg&&r.getBg(0)===e.bg||(r=n.getBlankLine(e,i),this._cachedBlankLine=r),r.isWrapped=i;let s=n.ybase+n.scrollTop,o=n.ybase+n.scrollBottom;if(0===n.scrollTop){let e=n.lines.isFull;o===n.lines.length-1?e?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(o+1,0,r.clone()),e?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let e=o-s+1;n.lines.shiftElements(s+1,e-1,-1),n.lines.set(o,r.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,i){let n=this.buffer;if(e<0){if(0===n.ydisp)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let r=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),r!==n.ydisp&&(i||this._onScroll.fire(n.ydisp))}};ci=rF([rW(0,se)],ci);var cn={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:lx,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},cr=["normal","bold","100","200","300","400","500","600","700","800","900"],cs=class extends sE{constructor(e){super(),this._onOptionChange=this._register(new sG),this.onOptionChange=this._onOptionChange.event;let i={...cn};for(let n in e)if(n in i)try{let r=e[n];i[n]=this._sanitizeAndValidateOption(n,r)}catch(e){console.error(e)}this.rawOptions=i,this.options={...i},this._setupOptions(),this._register(sk(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,i){return this.onOptionChange(n=>{n===e&&i(this.rawOptions[e])})}onMultipleOptionChange(e,i){return this.onOptionChange(n=>{-1!==e.indexOf(n)&&i()})}_setupOptions(){let e=e=>{if(!(e in cn))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},i=(e,i)=>{if(!(e in cn))throw Error(`No option with key "${e}"`);i=this._sanitizeAndValidateOption(e,i),this.rawOptions[e]!==i&&(this.rawOptions[e]=i,this._onOptionChange.fire(e))};for(let n in this.rawOptions){let r={get:e.bind(this,n),set:i.bind(this,n)};Object.defineProperty(this.options,n,r)}}_sanitizeAndValidateOption(e,i){switch(e){case"cursorStyle":var n;if(i||(i=cn[e]),"block"!==(n=i)&&"underline"!==n&&"bar"!==n)throw Error(`"${i}" is not a valid value for ${e}`);break;case"wordSeparator":i||(i=cn[e]);break;case"fontWeight":case"fontWeightBold":if("number"==typeof i&&1<=i&&i<=1e3)break;i=cr.includes(i)?i:cn[e];break;case"cursorWidth":i=Math.floor(i);case"lineHeight":case"tabStopWidth":if(i<1)throw Error(`${e} cannot be less than 1, value: ${i}`);break;case"minimumContrastRatio":i=Math.max(1,Math.min(21,Math.round(10*i)/10));break;case"scrollback":if((i=Math.min(i,0xffffffff))<0)throw Error(`${e} cannot be less than 0, value: ${i}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(i<=0)throw Error(`${e} cannot be less than or equal to 0, value: ${i}`);break;case"rows":case"cols":if(!i&&0!==i)throw Error(`${e} must be numeric, value: ${i}`);break;case"windowsPty":i=i??{}}return i}};function co(e,i=5){if("object"!=typeof e)return e;let n=Array.isArray(e)?[]:{};for(let r in e)n[r]=i<=1?e[r]:e[r]&&co(e[r],i-1);return n}var ca=Object.freeze({insertMode:!1}),cl=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),cc=class extends sE{constructor(e,i,n){super(),this._bufferService=e,this._logService=i,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new sG),this.onData=this._onData.event,this._onUserInput=this._register(new sG),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new sG),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new sG),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=co(ca),this.decPrivateModes=co(cl)}reset(){this.modes=co(ca),this.decPrivateModes=co(cl)}triggerDataEvent(e,i=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;i&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),i&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(e=>e.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(e=>e.charCodeAt(0))),this._onBinary.fire(e))}};cc=rF([rW(0,r3),rW(1,r7),rW(2,se)],cc);var ch={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>4!==e.button&&1===e.action&&(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>32!==e.action},DRAG:{events:23,restrict:e=>32!==e.action||3!==e.button},ANY:{events:31,restrict:e=>!0}};function cd(e,i){let n=16*!!e.ctrl|4*!!e.shift|8*!!e.alt;return 4===e.button?(n|=64,n|=e.action):(n|=3&e.button,4&e.button&&(n|=64),8&e.button&&(n|=128),32===e.action?n|=32:0!==e.action||i||(n|=3)),n}var cu=String.fromCharCode,cp={DEFAULT:e=>{let i=[cd(e,!1)+32,e.col+32,e.row+32];return i[0]>255||i[1]>255||i[2]>255?"":`\x1b[M${cu(i[0])}${cu(i[1])}${cu(i[2])}`},SGR:e=>{let i=0===e.action&&4!==e.button?"m":"M";return`\x1b[<${cd(e,!0)};${e.col};${e.row}${i}`},SGR_PIXELS:e=>{let i=0===e.action&&4!==e.button?"m":"M";return`\x1b[<${cd(e,!0)};${e.x};${e.y}${i}`}},cf=class extends sE{constructor(e,i,n){for(let r of(super(),this._bufferService=e,this._coreService=i,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new sG),this.onProtocolChange=this._onProtocolChange.event,Object.keys(ch)))this.addProtocol(r,ch[r]);for(let e of Object.keys(cp))this.addEncoding(e,cp[e]);this.reset()}addProtocol(e,i){this._protocols[e]=i}addEncoding(e,i){this._encodings[e]=i}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return 0!==this._protocols[this._activeProtocol].events}set activeProtocol(e){if(!this._protocols[e])throw Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,i,n){if(0===e.deltaY||e.shiftKey||void 0===i||void 0===n)return 0;let r=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=i/n+0,50>Math.abs(e.deltaY)&&(r*=.3),this._wheelPartialScroll+=r,r=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(r*=this._bufferService.rows),r}_applyScrollModifier(e,i){return i.altKey||i.ctrlKey||i.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||4===e.button&&32===e.action||3===e.button&&32!==e.action||4!==e.button&&(2===e.action||3===e.action)||(e.col++,e.row++,32===e.action&&this._lastEvent&&this._equalEvents(this._lastEvent,e,"SGR_PIXELS"===this._activeEncoding))||!this._protocols[this._activeProtocol].restrict(e))return!1;let i=this._encodings[this._activeEncoding](e);return i&&("DEFAULT"===this._activeEncoding?this._coreService.triggerBinaryEvent(i):this._coreService.triggerDataEvent(i,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(1&e),up:!!(2&e),drag:!!(4&e),move:!!(8&e),wheel:!!(16&e)}}_equalEvents(e,i,n){if(n){if(e.x!==i.x||e.y!==i.y)return!1}else if(e.col!==i.col||e.row!==i.row)return!1;return e.button===i.button&&e.action===i.action&&e.ctrl===i.ctrl&&e.alt===i.alt&&e.shift===i.shift}};cf=rF([rW(0,r3),rW(1,r6),rW(2,se)],cf);var cm,cg,cv,cy,c_,cb,cx=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],cw=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],cS=class{constructor(){if(this.version="6",!cb){(cb=new Uint8Array(65536)).fill(1),cb[0]=0,cb.fill(0,1,32),cb.fill(0,127,160),cb.fill(2,4352,4448),cb[9001]=2,cb[9002]=2,cb.fill(2,11904,42192),cb[12351]=1,cb.fill(2,44032,55204),cb.fill(2,63744,64256),cb.fill(2,65040,65050),cb.fill(2,65072,65136),cb.fill(2,65280,65377),cb.fill(2,65504,65511);for(let e=0;e<cx.length;++e)cb.fill(0,cx[e][0],cx[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?cb[e]:!function(e,i){let n=0,r=i.length-1,s;if(e<i[0][0]||e>i[r][1])return!1;for(;r>=n;)if(e>i[s=n+r>>1][1])n=s+1;else{if(!(e<i[s][0]))return!0;r=s-1}return!1}(e,cw)?e>=131072&&e<=196605||e>=196608&&e<=262141?2:1:0}charProperties(e,i){let n=this.wcwidth(e),r=0===n&&0!==i;if(r){let e=ck.extractWidth(i);0===e?r=!1:e>n&&(n=e)}return ck.createPropertyValue(0,n,r)}},ck=class e{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new sG,this.onChange=this._onChange.event;let e=new cS;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return(1&e)!=0}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,i,n=!1){return(0xffffff&e)<<3|(3&i)<<1|!!n}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(i){let n=0,r=0,s=i.length;for(let o=0;o<s;++o){let a=i.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=s)return n+this.wcwidth(a);let e=i.charCodeAt(o);56320<=e&&e<=57343?a=(a-55296)*1024+e-56320+65536:n+=this.wcwidth(e)}let l=this.charProperties(a,r),c=e.extractWidth(l);e.extractShouldJoin(l)&&(c-=e.extractWidth(r)),n+=c,r=l}return n}charProperties(e,i){return this._activeProvider.charProperties(e,i)}},cC=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,i){this._charsets[e]=i,this.glevel===e&&(this.charset=i)}};function cT(e){let i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&i&&(n.isWrapped=0!==i[3]&&32!==i[3])}var cE=class e{constructor(e=32,i=32){if(this.maxLength=e,this.maxSubParamsLength=i,i>256)throw Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(i),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(i){let n=new e;if(!i.length)return n;for(let e=+!!Array.isArray(i[0]);e<i.length;++e){let r=i[e];if(Array.isArray(r))for(let e=0;e<r.length;++e)n.addSubParam(r[e]);else n.addParam(r)}return n}clone(){let i=new e(this.maxLength,this.maxSubParamsLength);return i.params.set(this.params),i.length=this.length,i._subParams.set(this._subParams),i._subParamsLength=this._subParamsLength,i._subParamsIdx.set(this._subParamsIdx),i._rejectDigits=this._rejectDigits,i._rejectSubDigits=this._rejectSubDigits,i._digitIsSub=this._digitIsSub,i}toArray(){let e=[];for(let i=0;i<this.length;++i){e.push(this.params[i]);let n=this._subParamsIdx[i]>>8,r=255&this._subParamsIdx[i];r-n>0&&e.push(Array.prototype.slice.call(this._subParams,n,r))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(e<-1)throw Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>0x7fffffff?0x7fffffff:e}addSubParam(e){if(this._digitIsSub=!0,this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=e>0x7fffffff?0x7fffffff:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(255&this._subParamsIdx[e])-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let i=this._subParamsIdx[e]>>8,n=255&this._subParamsIdx[e];return n-i>0?this._subParams.subarray(i,n):null}getSubParamsAll(){let e={};for(let i=0;i<this.length;++i){let n=this._subParamsIdx[i]>>8,r=255&this._subParamsIdx[i];r-n>0&&(e[i]=this._subParams.slice(n,r))}return e}addDigit(e){let i;if(this._rejectDigits||!(i=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let n=this._digitIsSub?this._subParams:this.params,r=n[i-1];n[i-1]=~r?Math.min(10*r+e,0x7fffffff):e}},cN=[],cM=class{constructor(){this._state=0,this._active=cN,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,i){void 0===this._handlers[e]&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(i),{dispose:()=>{let e=n.indexOf(i);-1!==e&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=cN}reset(){if(2===this._state)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=cN,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||cN,this._active.length)for(let e=this._active.length-1;e>=0;e--)this._active[e].start();else this._handlerFb(this._id,"START")}_put(e,i,n){if(this._active.length)for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,i,n);else this._handlerFb(this._id,"PUT",rK(e,i,n))}start(){this.reset(),this._state=1}put(e,i,n){if(3!==this._state){if(1===this._state)for(;i<n;){let n=e[i++];if(59===n){this._state=2,this._start();break}if(n<48||57<n){this._state=3;return}-1===this._id&&(this._id=0),this._id=10*this._id+n-48}2===this._state&&n-i>0&&this._put(e,i,n)}}end(e,i=!0){if(0!==this._state){if(3!==this._state)if(1===this._state&&this._start(),this._active.length){let n=!1,r=this._active.length-1,s=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=i,s=this._stack.fallThrough,this._stack.paused=!1),!s&&!1===n){for(;r>=0&&!0!==(n=this._active[r].end(e));r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if((n=this._active[r].end(!1))instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}else this._handlerFb(this._id,"END",e);this._active=cN,this._id=-1,this._state=0}}},cO=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,i,n){this._hitLimit||(this._data+=rK(e,i,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let i=!1;if(this._hitLimit)i=!1;else if(e&&(i=this._handler(this._data))instanceof Promise)return i.then(e=>(this._data="",this._hitLimit=!1,e));return this._data="",this._hitLimit=!1,i}},cA=[],cR=class{constructor(){this._handlers=Object.create(null),this._active=cA,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=cA}registerHandler(e,i){void 0===this._handlers[e]&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(i),{dispose:()=>{let e=n.indexOf(i);-1!==e&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=cA,this._ident=0}hook(e,i){if(this.reset(),this._ident=e,this._active=this._handlers[e]||cA,this._active.length)for(let e=this._active.length-1;e>=0;e--)this._active[e].hook(i);else this._handlerFb(this._ident,"HOOK",i)}put(e,i,n){if(this._active.length)for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,i,n);else this._handlerFb(this._ident,"PUT",rK(e,i,n))}unhook(e,i=!0){if(this._active.length){let n=!1,r=this._active.length-1,s=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=i,s=this._stack.fallThrough,this._stack.paused=!1),!s&&!1===n){for(;r>=0&&!0!==(n=this._active[r].unhook(e));r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if((n=this._active[r].unhook(!1))instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}else this._handlerFb(this._ident,"UNHOOK",e);this._active=cA,this._ident=0}},cD=new cE;cD.addParam(0);var cL=class{constructor(e){this._handler=e,this._data="",this._params=cD,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():cD,this._data="",this._hitLimit=!1}put(e,i,n){this._hitLimit||(this._data+=rK(e,i,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let i=!1;if(this._hitLimit)i=!1;else if(e&&(i=this._handler(this._data,this._params))instanceof Promise)return i.then(e=>(this._params=cD,this._data="",this._hitLimit=!1,e));return this._params=cD,this._data="",this._hitLimit=!1,i}},cj=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,i){this.table.fill(e<<4|i)}add(e,i,n,r){this.table[i<<8|e]=n<<4|r}addMany(e,i,n,r){for(let s=0;s<e.length;s++)this.table[i<<8|e[s]]=n<<4|r}},cI=function(){let e=new cj(4095),i=Array.apply(null,Array(256)).map((e,i)=>i),n=(e,n)=>i.slice(e,n),r=n(32,127),s=n(0,24);s.push(25),s.push.apply(s,n(28,32));let o=n(0,14),a;for(a in e.setDefault(1,0),e.addMany(r,0,2,0),o)e.addMany([24,26,153,154],a,3,0),e.addMany(n(128,144),a,3,0),e.addMany(n(144,152),a,3,0),e.add(156,a,0,0),e.add(27,a,11,1),e.add(157,a,4,8),e.addMany([152,158,159],a,0,7),e.add(155,a,11,3),e.add(144,a,11,9);return e.addMany(s,0,3,0),e.addMany(s,1,3,1),e.add(127,1,0,1),e.addMany(s,8,0,8),e.addMany(s,3,3,3),e.add(127,3,0,3),e.addMany(s,4,3,4),e.add(127,4,0,4),e.addMany(s,6,3,6),e.addMany(s,5,3,5),e.add(127,5,0,5),e.addMany(s,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(s,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(s,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(s,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(s,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(s,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(s,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(160,0,2,0),e.add(160,8,5,8),e.add(160,6,0,6),e.add(160,11,0,11),e.add(160,13,13,13),e}(),cP=class extends sE{constructor(e=cI){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new cE,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,i,n)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,i)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(sk(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new cM),this._dcsParser=this._register(new cR),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,i=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw Error("only one byte as prefix supported");if((n=e.prefix.charCodeAt(0))&&60>n||n>63)throw Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw Error("only two bytes as intermediates are supported");for(let i=0;i<e.intermediates.length;++i){let r=e.intermediates.charCodeAt(i);if(32>r||r>47)throw Error("intermediate must be in range 0x20 .. 0x2f");n<<=8,n|=r}}if(1!==e.final.length)throw Error("final must be a single byte");let r=e.final.charCodeAt(0);if(i[0]>r||r>i[1])throw Error(`final must be in range ${i[0]} .. ${i[1]}`);return n<<=8,n|=r}identToString(e){let i=[];for(;e;)i.push(String.fromCharCode(255&e)),e>>=8;return i.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,i){let n=this._identifier(e,[48,126]);void 0===this._escHandlers[n]&&(this._escHandlers[n]=[]);let r=this._escHandlers[n];return r.push(i),{dispose:()=>{let e=r.indexOf(i);-1!==e&&r.splice(e,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,i){this._executeHandlers[e.charCodeAt(0)]=i}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,i){let n=this._identifier(e);void 0===this._csiHandlers[n]&&(this._csiHandlers[n]=[]);let r=this._csiHandlers[n];return r.push(i),{dispose:()=>{let e=r.indexOf(i);-1!==e&&r.splice(e,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,i){return this._dcsParser.registerHandler(this._identifier(e),i)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,i){return this._oscParser.registerHandler(e,i)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,0!==this._parseStack.state&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,i,n,r,s){this._parseStack.state=e,this._parseStack.handlers=i,this._parseStack.handlerPos=n,this._parseStack.transition=r,this._parseStack.chunkPos=s}parse(e,i,n){let r=0,s=0,o=0,a;if(this._parseStack.state)if(2===this._parseStack.state)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(void 0===n||1===this._parseStack.state)throw this._parseStack.state=1,Error("improper continuation due to previous async handler, giving up parsing");let i=this._parseStack.handlers,s=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(!1===n&&s>-1){for(;s>=0&&!0!==(a=i[s](this._params));s--)if(a instanceof Promise)return this._parseStack.handlerPos=s,a}this._parseStack.handlers=[];break;case 4:if(!1===n&&s>-1){for(;s>=0&&!0!==(a=i[s]());s--)if(a instanceof Promise)return this._parseStack.handlerPos=s,a}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],a=this._dcsParser.unhook(24!==r&&26!==r,n))return a;27===r&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],a=this._oscParser.end(24!==r&&26!==r,n))return a;27===r&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let n=o;n<i;++n){switch(r=e[n],(s=this._transitions.table[this.currentState<<8|(r<160?r:160)])>>4){case 2:for(let s=n+1;;++s)if(s>=i||(r=e[s])<32||r>126&&r<160||++s>=i||(r=e[s])<32||r>126&&r<160||++s>=i||(r=e[s])<32||r>126&&r<160||++s>=i||(r=e[s])<32||r>126&&r<160){this._printHandler(e,n,s),n=s-1;break}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:n,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let o=this._csiHandlers[this._collect<<8|r],l=o?o.length-1:-1;for(;l>=0&&!0!==(a=o[l](this._params));l--)if(a instanceof Promise)return this._preserveStack(3,o,l,s,n),a;l<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++n<i&&(r=e[n])>47&&r<60)n--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let c=this._escHandlers[this._collect<<8|r],h=c?c.length-1:-1;for(;h>=0&&!0!==(a=c[h]());h--)if(a instanceof Promise)return this._preserveStack(4,c,h,s,n),a;h<0&&this._escHandlerFb(this._collect<<8|r),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|r,this._params);break;case 13:for(let s=n+1;;++s)if(s>=i||24===(r=e[s])||26===r||27===r||r>127&&r<160){this._dcsParser.put(e,n,s),n=s-1;break}break;case 14:if(a=this._dcsParser.unhook(24!==r&&26!==r))return this._preserveStack(6,[],0,s,n),a;27===r&&(s|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let s=n+1;;s++)if(s>=i||(r=e[s])<32||r>127&&r<160){this._oscParser.put(e,n,s),n=s-1;break}break;case 6:if(a=this._oscParser.end(24!==r&&26!==r))return this._preserveStack(5,[],0,s,n),a;27===r&&(s|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&s}}},cB=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,cz=/^[\da-f]+$/;function cF(e){if(!e)return;let i=e.toLowerCase();if(0===i.indexOf("rgb:")){i=i.slice(4);let e=cB.exec(i);if(e){let i=e[1]?15:e[4]?255:e[7]?4095:65535;return[Math.round(parseInt(e[1]||e[4]||e[7]||e[10],16)/i*255),Math.round(parseInt(e[2]||e[5]||e[8]||e[11],16)/i*255),Math.round(parseInt(e[3]||e[6]||e[9]||e[12],16)/i*255)]}}else if(0===i.indexOf("#")&&(i=i.slice(1),cz.exec(i)&&[3,6,9,12].includes(i.length))){let e=i.length/3,n=[0,0,0];for(let r=0;r<3;++r){let s=parseInt(i.slice(e*r,e*r+e),16);n[r]=1===e?s<<4:2===e?s:3===e?s>>4:s>>8}return n}}function cW(e,i){let n=e.toString(16),r=n.length<2?"0"+n:n;switch(i){case 4:return n[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}var cH={"(":0,")":1,"*":2,"+":3,"-":1,".":2};function c$(e,i){if(e>24)return i.setWinLines||!1;switch(e){case 1:return!!i.restoreWin;case 2:return!!i.minimizeWin;case 3:return!!i.setWinPosition;case 4:return!!i.setWinSizePixels;case 5:return!!i.raiseWin;case 6:return!!i.lowerWin;case 7:return!!i.refreshWin;case 8:return!!i.setWinSizeChars;case 9:return!!i.maximizeWin;case 10:return!!i.fullscreenWin;case 11:return!!i.getWinState;case 13:return!!i.getWinPosition;case 14:return!!i.getWinSizePixels;case 15:return!!i.getScreenSizePixels;case 16:return!!i.getCellSizePixels;case 18:return!!i.getWinSizeChars;case 19:return!!i.getScreenSizeChars;case 20:return!!i.getIconTitle;case 21:return!!i.getWinTitle;case 22:return!!i.pushTitle;case 23:return!!i.popTitle;case 24:return!!i.setWinLines}return!1}var cU=0,cV=class extends sE{constructor(e,i,n,r,s,o,a,l,c=new cP){for(let h in super(),this._bufferService=e,this._charsetService=i,this._coreService=n,this._logService=r,this._optionsService=s,this._oscLinkService=o,this._coreMouseService=a,this._unicodeService=l,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new rX,this._utf8Decoder=new rJ,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=l5.clone(),this._eraseAttrDataInternal=l5.clone(),this._onRequestBell=this._register(new sG),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new sG),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new sG),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new sG),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new sG),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new sG),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new sG),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new sG),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new sG),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new sG),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new sG),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new sG),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new sG),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new cq(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(e=>this._activeBuffer=e.activeBuffer)),this._parser.setCsiHandlerFallback((e,i)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(e),params:i.toArray()})}),this._parser.setEscHandlerFallback(e=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(e)})}),this._parser.setExecuteHandlerFallback(e=>{this._logService.debug("Unknown EXECUTE code: ",{code:e})}),this._parser.setOscHandlerFallback((e,i,n)=>{this._logService.debug("Unknown OSC code: ",{identifier:e,action:i,data:n})}),this._parser.setDcsHandlerFallback((e,i,n)=>{"HOOK"===i&&(n=n.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(e),action:i,payload:n})}),this._parser.setPrintHandler((e,i,n)=>this.print(e,i,n)),this._parser.registerCsiHandler({final:"@"},e=>this.insertChars(e)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},e=>this.scrollLeft(e)),this._parser.registerCsiHandler({final:"A"},e=>this.cursorUp(e)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},e=>this.scrollRight(e)),this._parser.registerCsiHandler({final:"B"},e=>this.cursorDown(e)),this._parser.registerCsiHandler({final:"C"},e=>this.cursorForward(e)),this._parser.registerCsiHandler({final:"D"},e=>this.cursorBackward(e)),this._parser.registerCsiHandler({final:"E"},e=>this.cursorNextLine(e)),this._parser.registerCsiHandler({final:"F"},e=>this.cursorPrecedingLine(e)),this._parser.registerCsiHandler({final:"G"},e=>this.cursorCharAbsolute(e)),this._parser.registerCsiHandler({final:"H"},e=>this.cursorPosition(e)),this._parser.registerCsiHandler({final:"I"},e=>this.cursorForwardTab(e)),this._parser.registerCsiHandler({final:"J"},e=>this.eraseInDisplay(e,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},e=>this.eraseInDisplay(e,!0)),this._parser.registerCsiHandler({final:"K"},e=>this.eraseInLine(e,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},e=>this.eraseInLine(e,!0)),this._parser.registerCsiHandler({final:"L"},e=>this.insertLines(e)),this._parser.registerCsiHandler({final:"M"},e=>this.deleteLines(e)),this._parser.registerCsiHandler({final:"P"},e=>this.deleteChars(e)),this._parser.registerCsiHandler({final:"S"},e=>this.scrollUp(e)),this._parser.registerCsiHandler({final:"T"},e=>this.scrollDown(e)),this._parser.registerCsiHandler({final:"X"},e=>this.eraseChars(e)),this._parser.registerCsiHandler({final:"Z"},e=>this.cursorBackwardTab(e)),this._parser.registerCsiHandler({final:"`"},e=>this.charPosAbsolute(e)),this._parser.registerCsiHandler({final:"a"},e=>this.hPositionRelative(e)),this._parser.registerCsiHandler({final:"b"},e=>this.repeatPrecedingCharacter(e)),this._parser.registerCsiHandler({final:"c"},e=>this.sendDeviceAttributesPrimary(e)),this._parser.registerCsiHandler({prefix:">",final:"c"},e=>this.sendDeviceAttributesSecondary(e)),this._parser.registerCsiHandler({final:"d"},e=>this.linePosAbsolute(e)),this._parser.registerCsiHandler({final:"e"},e=>this.vPositionRelative(e)),this._parser.registerCsiHandler({final:"f"},e=>this.hVPosition(e)),this._parser.registerCsiHandler({final:"g"},e=>this.tabClear(e)),this._parser.registerCsiHandler({final:"h"},e=>this.setMode(e)),this._parser.registerCsiHandler({prefix:"?",final:"h"},e=>this.setModePrivate(e)),this._parser.registerCsiHandler({final:"l"},e=>this.resetMode(e)),this._parser.registerCsiHandler({prefix:"?",final:"l"},e=>this.resetModePrivate(e)),this._parser.registerCsiHandler({final:"m"},e=>this.charAttributes(e)),this._parser.registerCsiHandler({final:"n"},e=>this.deviceStatus(e)),this._parser.registerCsiHandler({prefix:"?",final:"n"},e=>this.deviceStatusPrivate(e)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},e=>this.softReset(e)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},e=>this.setCursorStyle(e)),this._parser.registerCsiHandler({final:"r"},e=>this.setScrollRegion(e)),this._parser.registerCsiHandler({final:"s"},e=>this.saveCursor(e)),this._parser.registerCsiHandler({final:"t"},e=>this.windowOptions(e)),this._parser.registerCsiHandler({final:"u"},e=>this.restoreCursor(e)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},e=>this.insertColumns(e)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},e=>this.deleteColumns(e)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},e=>this.selectProtected(e)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},e=>this.requestMode(e,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},e=>this.requestMode(e,!1)),this._parser.setExecuteHandler(aR.BEL,()=>this.bell()),this._parser.setExecuteHandler(aR.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(aR.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(aR.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(aR.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(aR.BS,()=>this.backspace()),this._parser.setExecuteHandler(aR.HT,()=>this.tab()),this._parser.setExecuteHandler(aR.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(aR.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(aD.IND,()=>this.index()),this._parser.setExecuteHandler(aD.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(aD.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new cO(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new cO(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new cO(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new cO(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new cO(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new cO(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new cO(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new cO(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new cO(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new cO(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new cO(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new cO(e=>this.restoreCursorColor(e))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset()),l9)this._parser.registerEscHandler({intermediates:"(",final:h},()=>this.selectCharset("("+h)),this._parser.registerEscHandler({intermediates:")",final:h},()=>this.selectCharset(")"+h)),this._parser.registerEscHandler({intermediates:"*",final:h},()=>this.selectCharset("*"+h)),this._parser.registerEscHandler({intermediates:"+",final:h},()=>this.selectCharset("+"+h)),this._parser.registerEscHandler({intermediates:"-",final:h},()=>this.selectCharset("-"+h)),this._parser.registerEscHandler({intermediates:".",final:h},()=>this.selectCharset("."+h)),this._parser.registerEscHandler({intermediates:"/",final:h},()=>this.selectCharset("/"+h));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(e=>(this._logService.error("Parsing error: ",e),e)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new cL((e,i)=>this.requestStatusString(e,i)))}getAttrData(){return this._curAttrData}_preserveStack(e,i,n,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=i,this._parseStack.decodedLength=n,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((e,i)=>setTimeout(()=>i("#SLOW_TIMEOUT"),5e3))]).catch(e=>{if("#SLOW_TIMEOUT"!==e)throw e;console.warn("async parser handler taking longer than 5000 ms")})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,i){let n,r=this._activeBuffer.x,s=this._activeBuffer.y,o=0,a=this._parseStack.paused;if(a){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,i))return this._logSlowResolvingAsync(n),n;r=this._parseStack.cursorStartX,s=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>131072&&(o=this._parseStack.position+131072)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${"string"==typeof e?` "${e}"`:` "${Array.prototype.map.call(e,e=>String.fromCharCode(e)).join("")}"`}`),0===this._logService.logLevel&&this._logService.trace("parsing data (codes)","string"==typeof e?e.split("").map(e=>e.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<131072&&(this._parseBuffer=new Uint32Array(Math.min(e.length,131072))),a||this._dirtyRowTracker.clearRange(),e.length>131072)for(let i=o;i<e.length;i+=131072){let o=i+131072<e.length?i+131072:e.length,a="string"==typeof e?this._stringDecoder.decode(e.substring(i,o),this._parseBuffer):this._utf8Decoder.decode(e.subarray(i,o),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,a))return this._preserveStack(r,s,a,i),this._logSlowResolvingAsync(n),n}else if(!a){let i="string"==typeof e?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,i))return this._preserveStack(r,s,i,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==r||this._activeBuffer.y!==s)&&this._onCursorMove.fire();let l=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(c,this._bufferService.rows-1),end:Math.min(l,this._bufferService.rows-1)})}print(e,i,n){let r,s,o=this._charsetService.charset,a=this._optionsService.rawOptions.screenReaderMode,l=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,h=this._coreService.modes.insertMode,d=this._curAttrData,u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-i>0&&2===u.getWidth(this._activeBuffer.x-1)&&u.setCellFromCodepoint(this._activeBuffer.x-1,0,1,d);let p=this._parser.precedingJoinState;for(let f=i;f<n;++f){if((r=e[f])<127&&o){let e=o[String.fromCharCode(r)];e&&(r=e.charCodeAt(0))}let i=this._unicodeService.charProperties(r,p);s=ck.extractWidth(i);let n=ck.extractShouldJoin(i),m=n?ck.extractWidth(p):0;if(p=i,a&&this._onA11yChar.fire(rY(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+s-m>l){if(c){let e=u,i=this._activeBuffer.x-m;for(this._activeBuffer.x=m,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),m>0&&u instanceof l4&&u.copyCellsFrom(e,i,0,m,!1);i<l;)e.setCellFromCodepoint(i++,0,1,d)}else if(this._activeBuffer.x=l-1,2===s)continue}if(n&&this._activeBuffer.x){let e=u.getWidth(this._activeBuffer.x-1)?1:2;u.addCodepointToCell(this._activeBuffer.x-e,r,s);for(let e=s-m;--e>=0;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,d);continue}if(h&&(u.insertCells(this._activeBuffer.x,s-m,this._activeBuffer.getNullCell(d)),2===u.getWidth(l-1)&&u.setCellFromCodepoint(l-1,0,1,d)),u.setCellFromCodepoint(this._activeBuffer.x++,r,s,d),s>0)for(;--s;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,d)}this._parser.precedingJoinState=p,this._activeBuffer.x<l&&n-i>0&&0===u.getWidth(this._activeBuffer.x)&&!u.hasContent(this._activeBuffer.x)&&u.setCellFromCodepoint(this._activeBuffer.x,0,1,d),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,i){return"t"!==e.final||e.prefix||e.intermediates?this._parser.registerCsiHandler(e,i):this._parser.registerCsiHandler(e,e=>!c$(e.params[0],this._optionsService.rawOptions.windowOptions)||i(e))}registerDcsHandler(e,i){return this._parser.registerDcsHandler(e,new cL(i))}registerEscHandler(e,i){return this._parser.registerEscHandler(e,i)}registerOscHandler(e,i){return this._parser.registerOscHandler(e,new cO(i))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(0===this._activeBuffer.x&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,i){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+i):(this._activeBuffer.x=e,this._activeBuffer.y=i),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,i){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+i)}cursorUp(e){let i=this._activeBuffer.y-this._activeBuffer.scrollTop;return i>=0?this._moveCursor(0,-Math.min(i,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let i=this._activeBuffer.scrollBottom-this._activeBuffer.y;return i>=0?this._moveCursor(0,Math.min(i,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let i=e.params[0];return 0===i?delete this._activeBuffer.tabs[this._activeBuffer.x]:3===i&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let i=e.params[0]||1;for(;i--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let i=e.params[0]||1;for(;i--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let i=e.params[0];return 1===i&&(this._curAttrData.bg|=0x20000000),(2===i||0===i)&&(this._curAttrData.bg&=-0x20000001),!0}_eraseInBufferLine(e,i,n,r=!1,s=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);o.replaceCells(i,n,this._activeBuffer.getNullCell(this._eraseAttrData()),s),r&&(o.isWrapped=!1)}_resetBufferLine(e,i=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),i),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,i=!1){let n;switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,0===this._activeBuffer.x,i);n<this._bufferService.rows;n++)this._resetBufferLine(n,i);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,i),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,i);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+n)?.getTrimmedLength(););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,i);this._dirtyRowTracker.markDirty(0)}break;case 3:let r=this._activeBuffer.lines.length-this._bufferService.rows;r>0&&(this._activeBuffer.lines.trimStart(r),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-r,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-r,0),this._onScroll.fire(0))}return!0}eraseInLine(e,i=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,0===this._activeBuffer.x,i);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,i);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,i)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let i=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;i--;)this._activeBuffer.lines.splice(s-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let i=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;i--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return i&&(i.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return i&&(i.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let i=e.params[0]||1;for(;i--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let i=e.params[0]||1;for(;i--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(l5));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(0,i,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(0,i,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(this._activeBuffer.x,i,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(this._activeBuffer.x,i,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return i&&(i.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let i=this._parser.precedingJoinState;if(!i)return!0;let n=e.params[0]||1,r=ck.extractWidth(i),s=this._activeBuffer.x-r,o=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(s),a=new Uint32Array(o.length*n),l=0;for(let e=0;e<o.length;){let i=o.codePointAt(e)||0;a[l++]=i,e+=i>65535?2:1}let c=l;for(let e=1;e<n;++e)a.copyWithin(c,0,l),c+=l;return this.print(a,0,c),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(aR.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(aR.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(aR.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(aR.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(aR.ESC+"[>83;40003;0c")),!0}_is(e){return 0===(this._optionsService.rawOptions.termName+"").indexOf(e)}setMode(e){for(let i=0;i<e.length;i++)switch(e.params[i]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(e){for(let i=0;i<e.length;i++)switch(e.params[i]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,l7),this._charsetService.setgCharset(1,l7),this._charsetService.setgCharset(2,l7),this._charsetService.setgCharset(3,l7);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0}return!0}resetMode(e){for(let i=0;i<e.length;i++)switch(e.params[i]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(e){for(let i=0;i<e.length;i++)switch(e.params[i]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),1049===e.params[i]&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0)}return!0}requestMode(e,i){let n,r,s,o;(r=n||={})[r.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",r[r.SET=1]="SET",r[r.RESET=2]="RESET",r[r.PERMANENTLY_SET=3]="PERMANENTLY_SET",r[r.PERMANENTLY_RESET=4]="PERMANENTLY_RESET";let a=this._coreService.decPrivateModes,{activeProtocol:l,activeEncoding:c}=this._coreMouseService,h=this._coreService,{buffers:d,cols:u}=this._bufferService,{active:p,alt:f}=d,m=this._optionsService.rawOptions,g=e=>e?1:2,v=e.params[0];return s=v,o=i?2===v?4:4===v?g(h.modes.insertMode):12===v?3:20===v?g(m.convertEol):0:1===v?g(a.applicationCursorKeys):3===v?m.windowOptions.setWinLines?80===u?2:+(132===u):0:6===v?g(a.origin):7===v?g(a.wraparound):8===v?3:9===v?g("X10"===l):12===v?g(m.cursorBlink):25===v?g(!h.isCursorHidden):45===v?g(a.reverseWraparound):66===v?g(a.applicationKeypad):67===v?4:1e3===v?g("VT200"===l):1002===v?g("DRAG"===l):1003===v?g("ANY"===l):1004===v?g(a.sendFocus):1005===v?4:1006===v?g("SGR"===c):1015===v?4:1016===v?g("SGR_PIXELS"===c):1048===v?1:47===v||1047===v||1049===v?g(p===f):2004===v?g(a.bracketedPasteMode):2026===v?g(a.synchronizedOutput):0,h.triggerDataEvent(`${aR.ESC}[${i?"":"?"}${s};${o}$y`),!0}_updateAttrColor(e,i,n,r,s){return 2===i?(e|=0x3000000,e&=-0x1000000,e|=rG.fromColorRGB([n,r,s])):5===i&&(e&=-0x3000100,e|=0x2000000|255&n),e}_extractColor(e,i,n){let r=[0,0,-1,0,0,0],s=0,o=0;do{if(r[o+s]=e.params[i+o],e.hasSubParams(i+o)){let n=e.getSubParams(i+o),a=0;do 5===r[1]&&(s=1),r[o+a+1+s]=n[a];while(++a<n.length&&a+o+1+s<r.length)break}if(5===r[1]&&o+s>=2||2===r[1]&&o+s>=5)break;r[1]&&(s=1)}while(++o+i<e.length&&o+s<r.length)for(let e=2;e<r.length;++e)-1===r[e]&&(r[e]=0);switch(r[0]){case 38:n.fg=this._updateAttrColor(n.fg,r[1],r[3],r[4],r[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,r[1],r[3],r[4],r[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,r[1],r[3],r[4],r[5])}return o}_processUnderline(e,i){i.extended=i.extended.clone(),(!~e||e>5)&&(e=1),i.extended.underlineStyle=e,i.fg|=0x10000000,0===e&&(i.fg&=-0x10000001),i.updateExtended()}_processSGR0(e){e.fg=l5.fg,e.bg=l5.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-0x4000000,e.updateExtended()}charAttributes(e){if(1===e.length&&0===e.params[0])return this._processSGR0(this._curAttrData),!0;let i=e.length,n,r=this._curAttrData;for(let s=0;s<i;s++)(n=e.params[s])>=30&&n<=37?(r.fg&=-0x3000100,r.fg|=0x1000000|n-30):n>=40&&n<=47?(r.bg&=-0x3000100,r.bg|=0x1000000|n-40):n>=90&&n<=97?(r.fg&=-0x3000100,r.fg|=0x1000000|n-90|8):n>=100&&n<=107?(r.bg&=-0x3000100,r.bg|=0x1000000|n-100|8):0===n?this._processSGR0(r):1===n?r.fg|=0x8000000:3===n?r.bg|=0x4000000:4===n?(r.fg|=0x10000000,this._processUnderline(e.hasSubParams(s)?e.getSubParams(s)[0]:1,r)):5===n?r.fg|=0x20000000:7===n?r.fg|=0x4000000:8===n?r.fg|=0x40000000:9===n?r.fg|=0x80000000:2===n?r.bg|=0x8000000:21===n?this._processUnderline(2,r):22===n?(r.fg&=-0x8000001,r.bg&=-0x8000001):23===n?r.bg&=-0x4000001:24===n?(r.fg&=-0x10000001,this._processUnderline(0,r)):25===n?r.fg&=-0x20000001:27===n?r.fg&=-0x4000001:28===n?r.fg&=-0x40000001:29===n?r.fg&=0x7fffffff:39===n?(r.fg&=-0x4000000,r.fg|=0xffffff&l5.fg):49===n?(r.bg&=-0x4000000,r.bg|=0xffffff&l5.bg):38===n||48===n||58===n?s+=this._extractColor(e,s,r):53===n?r.bg|=0x40000000:55===n?r.bg&=-0x40000001:59===n?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):100===n?(r.fg&=-0x4000000,r.fg|=0xffffff&l5.fg,r.bg&=-0x4000000,r.bg|=0xffffff&l5.bg):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${aR.ESC}[0n`);break;case 6:let i=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${aR.ESC}[${i};${n}R`)}return!0}deviceStatusPrivate(e){if(6===e.params[0]){let e=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${aR.ESC}[?${e};${i}R`)}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=l5.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let i=0===e.length?1:e.params[0];if(0===i)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(i){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar"}this._coreService.decPrivateModes.cursorBlink=i%2==1}return!0}setScrollRegion(e){let i=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||0===n)&&(n=this._bufferService.rows),n>i&&(this._activeBuffer.scrollTop=i-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!c$(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let i=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:2!==i&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${aR.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(0===i||2===i)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),(0===i||1===i)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:(0===i||2===i)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(0===i||1===i)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let i=[],n=e.split(";");for(;n.length>1;){let e=n.shift(),r=n.shift();if(/^\d+$/.exec(e)){let n=parseInt(e);if(cY(n))if("?"===r)i.push({type:0,index:n});else{let e=cF(r);e&&i.push({type:1,index:n,color:e})}}}return i.length&&this._onColor.fire(i),!0}setHyperlink(e){let i=e.indexOf(";");if(-1===i)return!0;let n=e.slice(0,i).trim(),r=e.slice(i+1);return r?this._createHyperlink(n,r):!n.trim()&&this._finishHyperlink()}_createHyperlink(e,i){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(":"),r,s=n.findIndex(e=>e.startsWith("id="));return -1!==s&&(r=n[s].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:i}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,i){let n=e.split(";");for(let e=0;e<n.length&&!(i>=this._specialColors.length);++e,++i)if("?"===n[e])this._onColor.fire([{type:0,index:this._specialColors[i]}]);else{let r=cF(n[e]);r&&this._onColor.fire([{type:1,index:this._specialColors[i],color:r}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let i=[],n=e.split(";");for(let e=0;e<n.length;++e)if(/^\d+$/.exec(n[e])){let r=parseInt(n[e]);cY(r)&&i.push({type:2,index:r})}return i.length&&this._onColor.fire(i),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,l7),!0}selectCharset(e){return 2!==e.length?this.selectDefaultCharset():"/"===e[0]||this._charsetService.setgCharset(cH[e[0]],l9[e[1]]||l7),!0}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=l5.clone(),this._eraseAttrDataInternal=l5.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-0x4000000,this._eraseAttrDataInternal.bg|=0x3ffffff&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new rQ;e.content=4194373,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let i=0;i<this._bufferService.rows;++i){let n=this._activeBuffer.ybase+this._activeBuffer.y+i,r=this._activeBuffer.lines.get(n);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,i){let n=e=>(this._coreService.triggerDataEvent(`${aR.ESC}${e}${aR.ESC}\\`),!0),r=this._bufferService.buffer,s=this._optionsService.rawOptions;return n('"q'===e?`P1$r${+!!this._curAttrData.isProtected()}"q`:'"p'===e?'P1$r61;1"p':"r"===e?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:"m"===e?"P1$r0m":" q"===e?`P1$r${({block:2,underline:4,bar:6})[s.cursorStyle]-!!s.cursorBlink} q`:"P0$r")}markRangeDirty(e,i){this._dirtyRowTracker.markRangeDirty(e,i)}},cq=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,i){e>i&&(cU=e,e=i,i=cU),e<this.start&&(this.start=e),i>this.end&&(this.end=i)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function cY(e){return 0<=e&&e<256}cq=rF([rW(0,r3)],cq);var cK=class extends sE{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new sG),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,i){let n;if(void 0!==i&&this._syncCalls>i){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,!this._isSyncWriting){for(this._isSyncWriting=!0;n=this._writeBuffer.shift();){this._action(n);let e=this._callbacks.shift();e&&e()}this._pendingData=0,this._bufferOffset=0x7fffffff,this._isSyncWriting=!1,this._syncCalls=0}}write(e,i){if(this._pendingData>5e7)throw Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(i),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(i)}_innerWrite(e=0,i=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let e=this._writeBuffer[this._bufferOffset],r=this._action(e,i);if(r){let e=e=>performance.now()-n>=12?setTimeout(()=>this._innerWrite(0,e)):this._innerWrite(n,e);r.catch(e=>(queueMicrotask(()=>{throw e}),Promise.resolve(!1))).then(e);return}let s=this._callbacks[this._bufferOffset];if(s&&s(),this._bufferOffset++,this._pendingData-=e.length,performance.now()-n>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},cX=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let i=this._bufferService.buffer;if(void 0===e.id){let n=i.addMarker(i.ybase+i.y),r={data:e,id:this._nextId++,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(r,n)),this._dataByLinkId.set(r.id,r),r.id}let n=this._getEntryIdKey(e),r=this._entriesWithId.get(n);if(r)return this.addLineToLink(r.id,i.ybase+i.y),r.id;let s=i.addMarker(i.ybase+i.y),o={id:this._nextId++,key:this._getEntryIdKey(e),data:e,lines:[s]};return s.onDispose(()=>this._removeMarkerFromLink(o,s)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,i){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(e=>e.line!==i)){let e=this._bufferService.buffer.addMarker(i);n.lines.push(e),e.onDispose(()=>this._removeMarkerFromLink(n,e))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,i){let n=e.lines.indexOf(i);-1!==n&&(e.lines.splice(n,1),0===e.lines.length&&(void 0!==e.data.id&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};cX=rF([rW(0,r3)],cX);var cJ=!1,cG=class extends sE{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new sN),this._onBinary=this._register(new sG),this.onBinary=this._onBinary.event,this._onData=this._register(new sG),this.onData=this._onData.event,this._onLineFeed=this._register(new sG),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new sG),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new sG),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new sG),this._instantiationService=new lQ,this.optionsService=this._register(new cs(e)),this._instantiationService.setService(se,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(ci)),this._instantiationService.setService(r3,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(l1)),this._instantiationService.setService(r7,this._logService),this.coreService=this._register(this._instantiationService.createInstance(cc)),this._instantiationService.setService(r6,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(cf)),this._instantiationService.setService(r4,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(ck)),this._instantiationService.setService(si,this.unicodeService),this._charsetService=this._instantiationService.createInstance(cC),this._instantiationService.setService(r8,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(cX),this._instantiationService.setService(st,this._oscLinkService),this._inputHandler=this._register(new cV(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(sU.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(sU.forward(this._bufferService.onResize,this._onResize)),this._register(sU.forward(this.coreService.onData,this._onData)),this._register(sU.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new cK((e,i)=>this._inputHandler.parse(e,i))),this._register(sU.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new sG),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let i in e)this.optionsService.options[i]=e[i]}write(e,i){this._writeBuffer.write(e,i)}writeSync(e,i){this._logService.logLevel<=3&&!cJ&&(this._logService.warn("writeSync is unreliable and will be removed soon."),cJ=!0),this._writeBuffer.writeSync(e,i)}input(e,i=!0){this.coreService.triggerDataEvent(e,i)}resize(e,i){isNaN(e)||isNaN(i)||(e=Math.max(e,2),i=Math.max(i,1),this._bufferService.resize(e,i))}scroll(e,i=!1){this._bufferService.scroll(e,i)}scrollLines(e,i){this._bufferService.scrollLines(e,i)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let i=e-this._bufferService.buffer.ydisp;0!==i&&this.scrollLines(i)}registerEscHandler(e,i){return this._inputHandler.registerEscHandler(e,i)}registerDcsHandler(e,i){return this._inputHandler.registerDcsHandler(e,i)}registerCsiHandler(e,i){return this._inputHandler.registerCsiHandler(e,i)}registerOscHandler(e,i){return this._inputHandler.registerOscHandler(e,i)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,i=this.optionsService.rawOptions.windowsPty;i&&void 0!==i.buildNumber&&void 0!==i.buildNumber?e="conpty"===i.backend&&i.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(cT.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(cT(this._bufferService),!1))),this._windowsWrappingHeuristics.value=sk(()=>{for(let i of e)i.dispose()})}}},cZ={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']},cQ=0,c0=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new lO,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new lO,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),0===this._insertedValues.length&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((e,i)=>this._getKey(e)-this._getKey(i)),i=0,n=0,r=Array(this._array.length+this._insertedValues.length);for(let s=0;s<r.length;s++)n>=this._array.length||this._getKey(e[i])<=this._getKey(this._array[n])?(r[s]=e[i],i++):r[s]=this._array[n++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),0===this._array.length)return!1;let i=this._getKey(e);if(void 0===i||-1===(cQ=this._search(i))||this._getKey(this._array[cQ])!==i)return!1;do if(this._array[cQ]===e)return 0===this._deletedIndices.length&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(cQ),!0;while(++cQ<this._array.length&&this._getKey(this._array[cQ])===i)return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((e,i)=>e-i),i=0,n=Array(this._array.length-e.length),r=0;for(let s=0;s<this._array.length;s++)e[i]===s?i++:n[r++]=this._array[s];this._array=n,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),0!==this._array.length&&!((cQ=this._search(e))<0||cQ>=this._array.length)&&this._getKey(this._array[cQ])===e)do yield this._array[cQ];while(++cQ<this._array.length&&this._getKey(this._array[cQ])===e)}forEachByKey(e,i){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),0!==this._array.length&&!((cQ=this._search(e))<0||cQ>=this._array.length)&&this._getKey(this._array[cQ])===e)do i(this._array[cQ]);while(++cQ<this._array.length&&this._getKey(this._array[cQ])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let i=0,n=this._array.length-1;for(;n>=i;){let r=i+n>>1,s=this._getKey(this._array[r]);if(s>e)n=r-1;else if(s<e)i=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return i}},c1=0,c2=0,c5=class extends sE{constructor(){super(),this._decorations=new c0(e=>e?.marker.line),this._onDecorationRegistered=this._register(new sG),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new sG),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(sk(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let i=new c3(e);if(i){let e=i.marker.onDispose(()=>i.dispose()),n=i.onDispose(()=>{n.dispose(),i&&(this._decorations.delete(i)&&this._onDecorationRemoved.fire(i),e.dispose())});this._decorations.insert(i),this._onDecorationRegistered.fire(i)}return i}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,i,n){let r=0,s=0;for(let o of this._decorations.getKeyIterator(i))s=(r=o.options.x??0)+(o.options.width??1),e>=r&&e<s&&(!n||(o.options.layer??"bottom")===n)&&(yield o)}forEachDecorationAtCell(e,i,n,r){this._decorations.forEachByKey(i,i=>{c2=(c1=i.options.x??0)+(i.options.width??1),e>=c1&&e<c2&&(!n||(i.options.layer??"bottom")===n)&&r(i)})}},c3=class extends sT{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new sG),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new sG),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return null===this._cachedBg&&(this.options.backgroundColor?this._cachedBg=cv.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return null===this._cachedFg&&(this.options.foregroundColor?this._cachedFg=cv.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},c4=class{constructor(e,i=1e3){this._renderCallback=e,this._debounceThresholdMS=i,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,i,n){this._rowCount=n,e=void 0!==e?e:0,i=void 0!==i?i:this._rowCount-1,this._rowStart=void 0!==this._rowStart?Math.min(this._rowStart,e):e,this._rowEnd=void 0!==this._rowEnd?Math.max(this._rowEnd,i):i;let r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let e=r-this._lastRefreshMs,i=this._debounceThresholdMS-e;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},i)}}_innerRefresh(){if(void 0===this._rowStart||void 0===this._rowEnd||void 0===this._rowCount)return;let e=Math.max(this._rowStart,0),i=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,i)}},c6=class extends sE{constructor(e,i,n,r){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let s=this._coreBrowserService.mainDocument;this._accessibilityContainer=s.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=s.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let e=0;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);if(this._topBoundaryFocusListener=e=>this._handleBoundaryFocus(e,0),this._bottomBoundaryFocusListener=e=>this._handleBoundaryFocus(e,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=s.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new c4(this._renderRows.bind(this))),!this._terminal.element)throw Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(e=>this._handleResize(e.rows))),this._register(this._terminal.onRender(e=>this._refreshRows(e.start,e.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(e=>this._handleChar(e))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
20
|
+
`))),this._register(this._terminal.onA11yTab(e=>this._handleTab(e))),this._register(this._terminal.onKey(e=>this._handleKey(e.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(o2(s,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(sk(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let i=0;i<e;i++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
21
|
+
`&&(this._liveRegionLineCount++,21===this._liveRegionLineCount&&(this._liveRegion.textContent+=r$)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,i){this._liveRegionDebouncer.refresh(e,i,this._terminal.rows)}_renderRows(e,i){let n=this._terminal.buffer,r=n.lines.length.toString();for(let s=e;s<=i;s++){let e=n.lines.get(n.ydisp+s),i=[],o=e?.translateToString(!0,void 0,void 0,i)||"",a=(n.ydisp+s+1).toString(),l=this._rowElements[s];l&&(0===o.length?(l.textContent=" ",this._rowColumns.set(l,[0,1])):(l.textContent=o,this._rowColumns.set(l,i)),l.setAttribute("aria-posinset",a),l.setAttribute("aria-setsize",r),this._alignRowWidth(l))}this._announceCharacters()}_announceCharacters(){0!==this._charsToAnnounce.length&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,i){let n,r,s=e.target,o=this._rowElements[0===i?1:this._rowElements.length-2];if(s.getAttribute("aria-posinset")!==(0===i?"1":`${this._terminal.buffer.lines.length}`)&&e.relatedTarget===o){if(0===i?(n=s,r=this._rowElements.pop(),this._rowContainer.removeChild(r)):(n=this._rowElements.shift(),r=s,this._rowContainer.removeChild(n)),n.removeEventListener("focus",this._topBoundaryFocusListener),r.removeEventListener("focus",this._bottomBoundaryFocusListener),0===i){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement("afterbegin",e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(0===i?-1:1),this._rowElements[0===i?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}}_handleSelectionChange(){if(0===this._rowElements.length)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode)return void console.error("anchorNode and/or focusNode are null");let i={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((i.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||i.node===n.node&&i.offset>n.offset)&&([i,n]=[n,i]),i.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(i={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(i.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let s=({node:e,offset:i})=>{let n=e instanceof Text?e.parentNode:e,r=parseInt(n?.getAttribute("aria-posinset"),10)-1;if(isNaN(r))return console.warn("row is invalid. Race condition?"),null;let s=this._rowColumns.get(n);if(!s)return console.warn("columns is null. Race condition?"),null;let o=i<s.length?s[i]:s.slice(-1)[0]+1;return o>=this._terminal.cols&&(++r,o=0),{row:r,column:o}},o=s(i),a=s(n);if(!(!o||!a)){if(o.row>a.row||o.row===a.row&&o.column>=a.column)throw Error("invalid range");this._terminal.select(o.column,o.row,(a.row-o.row)*this._terminal.cols-o.column+a.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform="";let i=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/i})`}};c6=rF([rW(1,r9),rW(2,so),rW(3,sl)],c6);var c8=class extends sE{constructor(e,i,n,r,s){super(),this._element=e,this._mouseService=i,this._renderService=n,this._bufferService=r,this._linkProviderService=s,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new sG),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new sG),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(sk(()=>{sS(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(o2(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(o2(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(o2(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(o2(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let i=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!i)return;this._isMouseOut=!1;let n=e.composedPath();for(let e=0;e<n.length;e++){let i=n[e];if(i.classList.contains("xterm"))break;if(i.classList.contains("xterm-hover"))return}this._lastBufferCell&&i.x===this._lastBufferCell.x&&i.y===this._lastBufferCell.y||(this._handleHover(i),this._lastBufferCell=i)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,i){this._activeProviderReplies&&i||(this._activeProviderReplies?.forEach(e=>{e?.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,s]of this._linkProviderService.linkProviders.entries())i?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):s.provideLinks(e.y,i=>{if(this._isMouseOut)return;let s=i?.map(e=>({link:e}));this._activeProviderReplies?.set(r,s),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,i){let n=new Set;for(let r=0;r<i.size;r++){let s=i.get(r);if(s)for(let i=0;i<s.length;i++){let r=s[i],o=r.link.range.start.y<e?0:r.link.range.start.x,a=r.link.range.end.y>e?this._bufferService.cols:r.link.range.end.x;for(let e=o;e<=a;e++){if(n.has(e)){s.splice(i--,1);break}n.add(e)}}}}_checkLinkProviderResult(e,i,n){if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),s=!1;for(let i=0;i<e;i++)(!this._activeProviderReplies.has(i)||this._activeProviderReplies.get(i))&&(s=!0);if(!s&&r){let e=r.find(e=>this._linkAtPosition(e.link,i));e&&(n=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let e=0;e<this._activeProviderReplies.size;e++){let r=this._activeProviderReplies.get(e)?.find(e=>this._linkAtPosition(e.link,i));if(r){n=!0,this._handleNewLink(r);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){var i,n;if(!this._currentLink)return;let r=this._positionFromMouseEvent(e,this._element,this._mouseService);r&&this._mouseDownLink&&(i=this._mouseDownLink.link,n=this._currentLink.link,i.text===n.text&&i.range.start.x===n.range.start.x&&i.range.start.y===n.range.start.y&&i.range.end.x===n.range.end.x&&i.range.end.y===n.range.end.y)&&this._linkAtPosition(this._currentLink.link,r)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,i){this._currentLink&&this._lastMouseEvent&&(!e||!i||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=i)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,sS(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let i=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);i&&this._linkAtPosition(e.link,i)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:void 0===e.link.decorations||e.link.decorations.underline,pointerCursor:void 0===e.link.decorations||e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:i=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==i&&(this._currentLink.state.decorations.underline=i,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,i))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let i=0===e.start?0:e.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=i&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(i,n),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,i,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(i,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),i.hover&&i.hover(n,i.text)}_fireUnderlineEvent(e,i){let n=e.range,r=this._bufferService.buffer.ydisp,s=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(i?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(s)}_linkLeave(e,i,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(i,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),i.leave&&i.leave(n,i.text)}_linkAtPosition(e,i){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,s=i.y*this._bufferService.cols+i.x;return n<=s&&s<=r}_positionFromMouseEvent(e,i,n){let r=n.getCoords(e,i,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,i,n,r,s){return{x1:e,y1:i,x2:n,y2:r,cols:this._bufferService.cols,fg:s}}};c8=rF([rW(1,sa),rW(2,sl),rW(3,r3),rW(4,su)],c8);var c9=class extends cG{constructor(e={}){super(e),this._linkifier=this._register(new sN),this.browser=ld,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new sN),this._onCursorMove=this._register(new sG),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new sG),this.onKey=this._onKey.event,this._onRender=this._register(new sG),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new sG),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new sG),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new sG),this.onBell=this._onBell.event,this._onFocus=this._register(new sG),this._onBlur=this._register(new sG),this._onA11yCharEmitter=this._register(new sG),this._onA11yTabEmitter=this._register(new sG),this._onWillOpen=this._register(new sG),this._setup(),this._decorationService=this._instantiationService.createInstance(c5),this._instantiationService.setService(sn,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(la),this._instantiationService.setService(su,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(sr)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(sU.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(sU.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(sU.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(sU.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(sk(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let i of e){let e,n="";switch(i.index){case 256:e="foreground",n="10";break;case 257:e="background",n="11";break;case 258:e="cursor",n="12";break;default:e="ansi",n="4;"+i.index}switch(i.type){case 0:let r=cg.toColorRGB("ansi"===e?this._themeService.colors.ansi[i.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${aR.ESC}]${n};${function(e,i=16){let[n,r,s]=e;return`rgb:${cW(n,i)}/${cW(r,i)}/${cW(s,i)}`}(r)}${aL.ST}`);break;case 1:if("ansi"===e)this._themeService.modifyColors(e=>e.ansi[i.index]=aj.toColor(...i.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=aj.toColor(...i.color))}break;case 2:this._themeService.restoreColor(i.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(c6,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(aR.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(aR.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,i=this.buffer.lines.get(e);if(!i)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,s=i.getWidth(n),o=this._renderService.dimensions.css.cell.width*s,a=this.buffer.y*this._renderService.dimensions.css.cell.height,l=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=l+"px",this.textarea.style.top=a+"px",this.textarea.style.width=o+"px",this.textarea.style.height=r+"px",this.textarea.style.lineHeight=r+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(o2(this.element,"copy",e=>{var i;this.hasSelection()&&(i=this._selectionService,e.clipboardData&&e.clipboardData.setData("text/plain",i.selectionText),e.preventDefault())}));let e=e=>{var i,n,r;return i=this.textarea,n=this.coreService,r=this.optionsService,void(e.stopPropagation(),e.clipboardData&&rU(e.clipboardData.getData("text/plain"),i,n,r))};this._register(o2(this.textarea,"paste",e)),this._register(o2(this.element,"paste",e)),lv?this._register(o2(this.element,"mousedown",e=>{2===e.button&&rq(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(o2(this.element,"contextmenu",e=>{rq(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),lC&&this._register(o2(this.element,"auxclick",e=>{1===e.button&&rV(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(o2(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(o2(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(o2(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(o2(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(o2(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(o2(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(o2(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let i=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),i.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(o2(this.screenElement,"mousemove",e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),i.appendChild(this.screenElement);let n=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",rH),lT||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(ls,this.textarea,e.ownerDocument.defaultView??window,this._document??"u">typeof window?window.document:null)),this._instantiationService.setService(so,this._coreBrowserService),this._register(o2(this.textarea,"focus",e=>this._handleTextAreaFocus(e))),this._register(o2(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(lt,this._document,this._helperContainer),this._instantiationService.setService(ss,this._charSizeService),this._themeService=this._instantiationService.createInstance(lJ),this._instantiationService.setService(sd,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(aG),this._instantiationService.setService(sh,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(lR,this.rows,this.screenElement)),this._instantiationService.setService(sl,this._renderService),this._register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(aT,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(lc),this._instantiationService.setService(sa,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(c8,this.screenElement));this.element.appendChild(i);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(a_,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(e=>{super.scrollLines(e,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(lH,this.element,this.screenElement,r)),this._instantiationService.setService(sc,this._selectionService),this._register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this._register(sU.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(ab,this.screenElement)),this._register(o2(this.element,"mousedown",e=>this._selectionService.handleMouseDown(e))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(c6,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(aC,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(aC,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(le,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,i=this.element;function n(i){let n,r,s=e._mouseService.getMouseReportCoords(i,e.screenElement);if(!s)return!1;switch(i.overrideType||i.type){case"mousemove":r=32,void 0===i.buttons?(n=3,void 0!==i.button&&(n=i.button<3?i.button:3)):n=1&i.buttons?0:4&i.buttons?1:2&i.buttons?2:3;break;case"mouseup":r=0,n=i.button<3?i.button:3;break;case"mousedown":r=1,n=i.button<3?i.button:3;break;case"wheel":if(e._customWheelEventHandler&&!1===e._customWheelEventHandler(i))return!1;let o=i.deltaY;if(0===o||0===e.coreMouseService.consumeWheelEvent(i,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr))return!1;r=o<0?0:1,n=4;break;default:return!1}return void 0!==r&&void 0!==n&&!(n>4)&&e.coreMouseService.triggerMouseEvent({col:s.col,row:s.row,x:s.x,y:s.y,button:n,action:r,ctrl:i.ctrlKey,alt:i.altKey,shift:i.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},s=e=>(n(e),e.buttons||(this._document.removeEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.removeEventListener("mousemove",r.mousedrag)),this.cancel(e)),o=e=>(n(e),this.cancel(e,!0)),a=e=>{e.buttons&&n(e)},l=e=>{e.buttons||n(e)};this._register(this.coreMouseService.onProtocolChange(e=>{e?("debug"===this.optionsService.rawOptions.logLevel&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(e)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),8&e?r.mousemove||(i.addEventListener("mousemove",l),r.mousemove=l):(i.removeEventListener("mousemove",r.mousemove),r.mousemove=null),16&e?r.wheel||(i.addEventListener("wheel",o,{passive:!1}),r.wheel=o):(i.removeEventListener("wheel",r.wheel),r.wheel=null),2&e?r.mouseup||(r.mouseup=s):(this._document.removeEventListener("mouseup",r.mouseup),r.mouseup=null),4&e?r.mousedrag||(r.mousedrag=a):(this._document.removeEventListener("mousemove",r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(o2(i,"mousedown",e=>{if(e.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(e)))return n(e),r.mouseup&&this._document.addEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.addEventListener("mousemove",r.mousedrag),this.cancel(e)})),this._register(o2(i,"wheel",i=>{if(!r.wheel){if(this._customWheelEventHandler&&!1===this._customWheelEventHandler(i))return!1;if(!this.buffer.hasScrollback){if(0===i.deltaY)return!1;if(0===e.coreMouseService.consumeWheelEvent(i,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr))return this.cancel(i,!0);let n=aR.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(i.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(n,!0),this.cancel(i,!0)}}},{passive:!1}))}refresh(e,i){this._renderService?.refreshRows(e,i)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,i){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,i),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let i=e-this._bufferService.buffer.ydisp;0!==i&&this.scrollLines(i)}paste(e){rU(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw Error("Terminal must be opened first");let i=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),i}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(e,i,n){this._selectionService.setSelection(e,i,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,i){this._selectionService?.selectLines(e,i)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&!1===this._customKeyEventHandler(e))return!1;let i=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!i&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;i||"Dead"!==e.key&&"AltGraph"!==e.key||(this._unprocessedDeadKey=!0);let n=function(e,i,n,r){let s={type:0,cancel:!1,key:void 0},o=!!e.shiftKey|2*!!e.altKey|4*!!e.ctrlKey|8*!!e.metaKey;switch(e.keyCode){case 0:"UIKeyInputUpArrow"===e.key?i?s.key=aR.ESC+"OA":s.key=aR.ESC+"[A":"UIKeyInputLeftArrow"===e.key?i?s.key=aR.ESC+"OD":s.key=aR.ESC+"[D":"UIKeyInputRightArrow"===e.key?i?s.key=aR.ESC+"OC":s.key=aR.ESC+"[C":"UIKeyInputDownArrow"===e.key&&(i?s.key=aR.ESC+"OB":s.key=aR.ESC+"[B");break;case 8:s.key=e.ctrlKey?"\b":aR.DEL,e.altKey&&(s.key=aR.ESC+s.key);break;case 9:if(e.shiftKey){s.key=aR.ESC+"[Z";break}s.key=aR.HT,s.cancel=!0;break;case 13:s.key=e.altKey?aR.ESC+aR.CR:aR.CR,s.cancel=!0;break;case 27:s.key=aR.ESC,e.altKey&&(s.key=aR.ESC+aR.ESC),s.cancel=!0;break;case 37:if(e.metaKey)break;o?s.key=aR.ESC+"[1;"+(o+1)+"D":i?s.key=aR.ESC+"OD":s.key=aR.ESC+"[D";break;case 39:if(e.metaKey)break;o?s.key=aR.ESC+"[1;"+(o+1)+"C":i?s.key=aR.ESC+"OC":s.key=aR.ESC+"[C";break;case 38:if(e.metaKey)break;o?s.key=aR.ESC+"[1;"+(o+1)+"A":i?s.key=aR.ESC+"OA":s.key=aR.ESC+"[A";break;case 40:if(e.metaKey)break;o?s.key=aR.ESC+"[1;"+(o+1)+"B":i?s.key=aR.ESC+"OB":s.key=aR.ESC+"[B";break;case 45:e.shiftKey||e.ctrlKey||(s.key=aR.ESC+"[2~");break;case 46:o?s.key=aR.ESC+"[3;"+(o+1)+"~":s.key=aR.ESC+"[3~";break;case 36:o?s.key=aR.ESC+"[1;"+(o+1)+"H":i?s.key=aR.ESC+"OH":s.key=aR.ESC+"[H";break;case 35:o?s.key=aR.ESC+"[1;"+(o+1)+"F":i?s.key=aR.ESC+"OF":s.key=aR.ESC+"[F";break;case 33:e.shiftKey?s.type=2:e.ctrlKey?s.key=aR.ESC+"[5;"+(o+1)+"~":s.key=aR.ESC+"[5~";break;case 34:e.shiftKey?s.type=3:e.ctrlKey?s.key=aR.ESC+"[6;"+(o+1)+"~":s.key=aR.ESC+"[6~";break;case 112:o?s.key=aR.ESC+"[1;"+(o+1)+"P":s.key=aR.ESC+"OP";break;case 113:o?s.key=aR.ESC+"[1;"+(o+1)+"Q":s.key=aR.ESC+"OQ";break;case 114:o?s.key=aR.ESC+"[1;"+(o+1)+"R":s.key=aR.ESC+"OR";break;case 115:o?s.key=aR.ESC+"[1;"+(o+1)+"S":s.key=aR.ESC+"OS";break;case 116:o?s.key=aR.ESC+"[15;"+(o+1)+"~":s.key=aR.ESC+"[15~";break;case 117:o?s.key=aR.ESC+"[17;"+(o+1)+"~":s.key=aR.ESC+"[17~";break;case 118:o?s.key=aR.ESC+"[18;"+(o+1)+"~":s.key=aR.ESC+"[18~";break;case 119:o?s.key=aR.ESC+"[19;"+(o+1)+"~":s.key=aR.ESC+"[19~";break;case 120:o?s.key=aR.ESC+"[20;"+(o+1)+"~":s.key=aR.ESC+"[20~";break;case 121:o?s.key=aR.ESC+"[21;"+(o+1)+"~":s.key=aR.ESC+"[21~";break;case 122:o?s.key=aR.ESC+"[23;"+(o+1)+"~":s.key=aR.ESC+"[23~";break;case 123:o?s.key=aR.ESC+"[24;"+(o+1)+"~":s.key=aR.ESC+"[24~";break;default:if(!e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)if((!n||r)&&e.altKey&&!e.metaKey){let i=cZ[e.keyCode]?.[+!!e.shiftKey];if(i)s.key=aR.ESC+i;else if(e.keyCode>=65&&e.keyCode<=90){let i=String.fromCharCode(e.ctrlKey?e.keyCode-64:e.keyCode+32);e.shiftKey&&(i=i.toUpperCase()),s.key=aR.ESC+i}else if(32===e.keyCode)s.key=aR.ESC+(e.ctrlKey?aR.NUL:" ");else if("Dead"===e.key&&e.code.startsWith("Key")){let i=e.code.slice(3,4);e.shiftKey||(i=i.toLowerCase()),s.key=aR.ESC+i,s.cancel=!0}}else!n||e.altKey||e.ctrlKey||e.shiftKey||!e.metaKey?!e.key||e.ctrlKey||e.altKey||e.metaKey||!(e.keyCode>=48)||1!==e.key.length?e.key&&e.ctrlKey&&("_"===e.key&&(s.key=aR.US),"@"===e.key&&(s.key=aR.NUL)):s.key=e.key:65===e.keyCode&&(s.type=1);else e.keyCode>=65&&e.keyCode<=90?s.key=String.fromCharCode(e.keyCode-64):32===e.keyCode?s.key=aR.NUL:e.keyCode>=51&&e.keyCode<=55?s.key=String.fromCharCode(e.keyCode-51+27):56===e.keyCode?s.key=aR.DEL:219===e.keyCode?s.key=aR.ESC:220===e.keyCode?s.key=aR.FS:221===e.keyCode&&(s.key=aR.GS)}return s}(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),3===n.type||2===n.type){let i=this.rows-1;return this.scrollLines(2===n.type?-i:i),this.cancel(e,!0)}return 1===n.type&&this.selectAll(),!!(this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&1===e.key.length&&e.key.charCodeAt(0)>=65&&90>=e.key.charCodeAt(0))||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):((n.key===aR.ETX||n.key===aR.CR)&&(this.textarea.value=""),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)?this.cancel(e,!0):void(this._keyDownHandled=!0))}_isThirdLevelShift(e,i){let n=e.isMac&&!this.options.macOptionIsMeta&&i.altKey&&!i.ctrlKey&&!i.metaKey||e.isWindows&&i.altKey&&i.ctrlKey&&!i.metaKey||e.isWindows&&i.getModifierState("AltGraph");return"keypress"===i.type?n:n&&(!i.keyCode||i.keyCode>47)}_keyUp(e){var i;this._keyDownSeen=!1,this._customKeyEventHandler&&!1===this._customKeyEventHandler(e)||(16===(i=e).keyCode||17===i.keyCode||18===i.keyCode||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let i;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&!1===this._customKeyEventHandler(e))return!1;if(this.cancel(e),e.charCode)i=e.charCode;else if(null===e.which||void 0===e.which)i=e.keyCode;else{if(0===e.which||0===e.charCode)return!1;i=e.which}return!!i&&(!e.altKey&&!e.ctrlKey&&!e.metaKey||!!this._isThirdLevelShift(this.browser,e))&&(i=String.fromCharCode(i),this._onKey.fire({key:i,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(i,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&"insertText"===e.inputType&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let i=e.data;return this.coreService.triggerDataEvent(i,!0),this.cancel(e),!0}return!1}resize(e,i){if(e===this.cols&&i===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,i)}_afterResize(e,i){this._charSizeService?.measure()}clear(){if(0!==this.buffer.ybase||0!==this.buffer.y){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(l5));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(aR.ESC+"[I"):this.coreService.triggerDataEvent(aR.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let i=this._renderService.dimensions.css.canvas.width.toFixed(0),n=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${aR.ESC}[4;${n};${i}t`);break;case 1:let r=this._renderService.dimensions.css.cell.width.toFixed(0),s=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${aR.ESC}[6;${s};${r}t`)}}cancel(e,i){if(!(!this.options.cancelEvents&&!i))return e.preventDefault(),e.stopPropagation(),!1}},c7=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,i){let n={instance:i,dispose:i.dispose,isDisposed:!1};this._addons.push(n),i.dispose=()=>this._wrappedAddonDispose(n),i.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let i=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){i=n;break}if(-1===i)throw Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(i,1)}},he=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,i){if(!(e<0||e>=this._line.length))return i?(this._line.loadCell(e,i),i):this._line.loadCell(e,new rQ)}translateToString(e,i,n){return this._line.translateToString(e,i,n)}},ht=class{constructor(e,i){this._buffer=e,this.type=i}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let i=this._buffer.lines.get(e);if(i)return new he(i)}getNullCell(){return new rQ}},hi=class extends sE{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new sG),this.onBufferChange=this._onBufferChange.event,this._normal=new ht(this._core.buffers.normal,"normal"),this._alternate=new ht(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},hn=class{constructor(e){this._core=e}registerCsiHandler(e,i){return this._core.registerCsiHandler(e,e=>i(e.toArray()))}addCsiHandler(e,i){return this.registerCsiHandler(e,i)}registerDcsHandler(e,i){return this._core.registerDcsHandler(e,(e,n)=>i(e,n.toArray()))}addDcsHandler(e,i){return this.registerDcsHandler(e,i)}registerEscHandler(e,i){return this._core.registerEscHandler(e,i)}addEscHandler(e,i){return this.registerEscHandler(e,i)}registerOscHandler(e,i){return this._core.registerOscHandler(e,i)}addOscHandler(e,i){return this.registerOscHandler(e,i)}},hr=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},hs=["cols","rows"],ho=0,ha=class extends sE{constructor(e){super(),this._core=this._register(new c9(e)),this._addonManager=this._register(new c7),this._publicOptions={...this._core.options};let i=e=>this._core.options[e],n=(e,i)=>{this._checkReadonlyOptions(e),this._core.options[e]=i};for(let e in this._core.options){let r={get:i.bind(this,e),set:n.bind(this,e)};Object.defineProperty(this._publicOptions,e,r)}}_checkReadonlyOptions(e){if(hs.includes(e))throw Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new hn(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new hr(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new hi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,i="none";switch(this._core.coreMouseService.activeProtocol){case"X10":i="x10";break;case"VT200":i="vt200";break;case"DRAG":i="drag";break;case"ANY":i="any"}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:i,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let i in e)this._publicOptions[i]=e[i]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,i=!0){this._core.input(e,i)}resize(e,i){this._verifyIntegers(e,i),this._core.resize(e,i)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,i,n){this._verifyIntegers(e,i,n),this._core.select(e,i,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,i){this._verifyIntegers(e,i),this._core.selectLines(e,i)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,i){this._core.write(e,i)}writeln(e,i){this._core.write(e),this._core.write(`\r
|
|
22
|
+
`,i)}paste(e){this._core.paste(e)}refresh(e,i){this._verifyIntegers(e,i),this._core.refresh(e,i)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return rH},set promptLabel(t){rH=t},get tooMuchOutput(){return r$},set tooMuchOutput(t){r$=t}}}_verifyIntegers(...e){for(ho of e)if(ho===1/0||isNaN(ho)||ho%1!=0)throw Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(ho of e)if(ho&&(ho===1/0||isNaN(ho)||ho%1!=0||ho<0))throw Error("This API only accepts positive integers")}},hl=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let i=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(i._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(0===e.css.cell.width||0===e.css.cell.height)return;let i=0===this._terminal.options.scrollback?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue("height")),s=Math.max(0,parseInt(n.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),a={top:parseInt(o.getPropertyValue("padding-top")),bottom:parseInt(o.getPropertyValue("padding-bottom")),right:parseInt(o.getPropertyValue("padding-right")),left:parseInt(o.getPropertyValue("padding-left"))},l=a.top+a.bottom;return{cols:Math.max(2,Math.floor((s-(a.right+a.left)-i)/e.css.cell.width)),rows:Math.max(1,Math.floor((r-l)/e.css.cell.height))}}},hc=class{constructor(e,i,n,r={}){this._terminal=e,this._regex=i,this._handler=n,this._options=r}provideLinks(e,i){let n=hh.computeLink(e,this._regex,this._terminal,this._handler);i(this._addCallbacks(n))}_addCallbacks(e){return e.map(e=>(e.leave=this._options.leave,e.hover=(i,n)=>{if(this._options.hover){let{range:r}=e;this._options.hover(i,n,r)}},e))}},hh=class e{static computeLink(i,n,r,s){let o=RegExp(n.source,(n.flags||"")+"g"),[a,l]=e._getWindowedLineStrings(i-1,r),c=a.join(""),h,d=[];for(;h=o.exec(c);){let i=h[0];if(!function(e){try{let i=new URL(e),n=i.password&&i.username?`${i.protocol}//${i.username}:${i.password}@${i.host}`:i.username?`${i.protocol}//${i.username}@${i.host}`:`${i.protocol}//${i.host}`;return e.toLocaleLowerCase().startsWith(n.toLocaleLowerCase())}catch{return!1}}(i))continue;let[n,o]=e._mapStrIdx(r,l,0,h.index),[a,c]=e._mapStrIdx(r,n,o,i.length);if(-1===n||-1===o||-1===a||-1===c)continue;let u={start:{x:o+1,y:n+1},end:{x:c,y:a+1}};d.push({range:u,text:i,activate:s})}return d}static _getWindowedLineStrings(e,i){let n,r=e,s=e,o=0,a="",l=[];if(n=i.buffer.active.getLine(e)){let e=n.translateToString(!0);if(n.isWrapped&&" "!==e[0]){for(o=0;(n=i.buffer.active.getLine(--r))&&o<2048&&(o+=(a=n.translateToString(!0)).length,l.push(a),!(!n.isWrapped||-1!==a.indexOf(" "))););l.reverse()}for(l.push(e),o=0;(n=i.buffer.active.getLine(++s))&&n.isWrapped&&o<2048&&(o+=(a=n.translateToString(!0)).length,l.push(a),-1===a.indexOf(" ")););}return[l,r]}static _mapStrIdx(e,i,n,r){let s=e.buffer.active,o=s.getNullCell(),a=n;for(;r;){let e=s.getLine(i);if(!e)return[-1,-1];for(let n=a;n<e.length;++n){e.getCell(n,o);let a=o.getChars();if(o.getWidth()&&(r-=a.length||1,n===e.length-1&&""===a)){let e=s.getLine(i+1);e&&e.isWrapped&&(e.getCell(0,o),2===o.getWidth()&&(r+=1))}if(r<0)return[i,n]}i++,a=0}return[i,a]}},hd=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function hu(e,i){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=i}else console.warn("Opening link blocked as opener could not be cleared")}var hp=class{constructor(e=hu,i={}){this._handler=e,this._options=i}activate(e){this._terminal=e;let i=this._options,n=i.urlRegex||hd;this._linkProvider=this._terminal.registerLinkProvider(new hc(this._terminal,n,this._handler,i))}dispose(){this._linkProvider?.dispose()}};let hf={background:"#ffffff",foreground:"#222222",cursor:"#1456f0",cursorAccent:"#ffffff",selectionBackground:"rgba(20, 86, 240, 0.2)",black:"#222222",red:"#ef4444",green:"#16a34a",yellow:"#ca8a04",blue:"#1456f0",magenta:"#ea5ec1",cyan:"#0891b2",white:"#e5e7eb",brightBlack:"#45515e",brightRed:"#f87171",brightGreen:"#22c55e",brightYellow:"#eab308",brightBlue:"#3b82f6",brightMagenta:"#f472b6",brightCyan:"#06b6d4",brightWhite:"#f9fafb"},hm={background:"#0f1117",foreground:"#e5e7eb",cursor:"#3b82f6",cursorAccent:"#0f1117",selectionBackground:"rgba(59, 130, 246, 0.25)",black:"#0f1117",red:"#ef4444",green:"#22c55e",yellow:"#eab308",blue:"#3b82f6",magenta:"#ea5ec1",cyan:"#06b6d4",white:"#e5e7eb",brightBlack:"#8b8fa3",brightRed:"#f87171",brightGreen:"#4ade80",brightYellow:"#facc15",brightBlue:"#60a5fa",brightMagenta:"#f472b6",brightCyan:"#22d3ee",brightWhite:"#f9fafb"};function hg({sessionId:e,workspaceId:i}){let n=(0,iM.useRef)(null),r=(0,iM.useRef)(null),s=(0,iM.useRef)(null),{resolvedTheme:o}=(0,rf.useTheme)(),a=(0,iM.useCallback)(i=>{let{sessionId:n,data:s}=i;n===e&&r.current&&r.current.write(s)},[e]);return(0,iM.useEffect)(()=>{if(!n.current)return;let l=new ha({cursorBlink:!0,fontSize:13,fontFamily:'Menlo, Monaco, "Courier New", monospace',theme:"dark"===o?hm:hf}),c=new hl;l.loadAddon(c),l.loadAddon(new hp),l.open(n.current),requestAnimationFrame(()=>c.fit()),r.current=l,s.current=c;let h=rL(i),d=l.onData(i=>{h.send("terminal.input",{sessionId:e,data:i})});h.on("terminal.output",a),h.send("terminal.resize",{sessionId:e,cols:l.cols,rows:l.rows});let u=new ResizeObserver(()=>{try{c.fit()}catch{}h.send("terminal.resize",{sessionId:e,cols:l.cols,rows:l.rows})});return u.observe(n.current),()=>{u.disconnect(),d.dispose(),h.off("terminal.output",a),l.dispose()}},[e,i,a]),(0,iM.useEffect)(()=>{r.current&&o&&(r.current.options.theme="dark"===o?hm:hf)},[o]),(0,iN.jsx)("div",{ref:n,className:"h-full w-full"})}var hv=e.i(260218),hy=e.i(681622),h_=e.i(226624),hb=e.i(817854);function hx({open:e,onOpenChange:i,command:n,defaultCwd:r,onSubmit:s}){let o=(0,n0.useTranslations)("commands"),[a,l]=(0,iM.useState)(n?.name??""),[c,h]=(0,iM.useState)(n?.command??""),[d,u]=(0,iM.useState)(n?.cwd??r??""),[p,f]=(0,iM.useState)(n?.shell??""),[m,g]=(0,iM.useState)(n?.env?Object.entries(n.env).map(([e,i])=>({key:e,value:i})):[]),[v,y]=(0,iM.useState)(n?.autoRestart??!1),[_,b]=(0,iM.useState)(!1);(0,iM.useEffect)(()=>{e&&(l(n?.name??""),h(n?.command??""),u(n?.cwd??r??""),f(n?.shell??""),g(n?.env?Object.entries(n.env).map(([e,i])=>({key:e,value:i})):[]),y(n?.autoRestart??!1))},[e,n,r]);let w=async()=>{if(a.trim()&&c.trim()){b(!0);try{let e={};for(let i of m)i.key.trim()&&(e[i.key.trim()]=i.value);await s({name:a.trim(),command:c,cwd:d||void 0,shell:p||void 0,env:Object.keys(e).length>0?e:void 0,autoRestart:v||void 0}),i(!1)}finally{b(!1)}}};return(0,iN.jsx)(rE.Dialog,{open:e,onOpenChange:i,children:(0,iN.jsxs)(rE.DialogContent,{className:"sm:max-w-[480px]",children:[(0,iN.jsx)(rE.DialogHeader,{children:(0,iN.jsx)(rE.DialogTitle,{children:o(n?"editCommand":"addCommand")})}),(0,iN.jsxs)("div",{className:"flex flex-col gap-3 py-2",children:[(0,iN.jsxs)("div",{children:[(0,iN.jsx)(hb.Label,{className:"text-xs",children:o("name")}),(0,iN.jsx)(hy.Input,{value:a,onChange:e=>l(e.target.value),placeholder:"dev",className:"mt-1"})]}),(0,iN.jsxs)("div",{children:[(0,iN.jsx)(hb.Label,{className:"text-xs",children:o("command")}),(0,iN.jsx)(hy.Input,{value:c,onChange:e=>h(e.target.value),placeholder:"pnpm dev",className:"mt-1 font-mono text-sm"})]}),(0,iN.jsxs)("div",{children:[(0,iN.jsx)(hb.Label,{className:"text-xs",children:o("workingDirectory")}),(0,iN.jsx)(hy.Input,{value:d,onChange:e=>u(e.target.value),placeholder:r,className:"mt-1 font-mono text-xs"})]}),(0,iN.jsxs)("div",{children:[(0,iN.jsx)(hb.Label,{className:"text-xs",children:o("shell")}),(0,iN.jsx)(hy.Input,{value:p,onChange:e=>f(e.target.value),placeholder:"Default",className:"mt-1"})]}),(0,iN.jsxs)("div",{children:[(0,iN.jsxs)("div",{className:"flex items-center justify-between",children:[(0,iN.jsx)(hb.Label,{className:"text-xs",children:o("environmentVariables")}),(0,iN.jsx)(hv.Button,{variant:"ghost",size:"sm",className:"h-5 px-1 text-xs",onClick:()=>g(e=>[...e,{key:"",value:""}]),children:(0,iN.jsx)(ry.Plus,{size:12})})]}),(0,iN.jsx)("div",{className:"flex flex-col gap-1 mt-1",children:m.map((e,i)=>(0,iN.jsxs)("div",{className:"flex items-center gap-1",children:[(0,iN.jsx)(hy.Input,{value:e.key,onChange:e=>g(n=>n.map((n,r)=>r===i?{...n,key:e.target.value}:n)),placeholder:"KEY",className:"h-7 text-xs font-mono flex-1"}),(0,iN.jsx)(hy.Input,{value:e.value,onChange:e=>g(n=>n.map((n,r)=>r===i?{...n,value:e.target.value}:n)),placeholder:"value",className:"h-7 text-xs font-mono flex-1"}),(0,iN.jsx)(hv.Button,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 shrink-0",onClick:()=>g(e=>e.filter((e,n)=>n!==i)),children:(0,iN.jsx)(ru.X,{size:12})})]},i))})]}),(0,iN.jsxs)("div",{className:"flex items-center gap-2",children:[(0,iN.jsx)(h_.Switch,{checked:v,onCheckedChange:y}),(0,iN.jsx)(hb.Label,{className:"text-xs",children:o("autoRestart")})]})]}),(0,iN.jsxs)(rE.DialogFooter,{children:[(0,iN.jsx)(hv.Button,{variant:"outline",onClick:()=>i(!1),children:o("cancel")}),(0,iN.jsx)(hv.Button,{onClick:w,disabled:!a.trim()||!c.trim()||_,children:o(n?"save":"addCommand")})]})]})})}var hw=e.i(434805),hS=e.i(344118),hk=e.i(62669);function hC({open:e,onOpenChange:i,defaultPath:n,onImport:r}){let s=(0,n0.useTranslations)("commands"),[o,a]=(0,iM.useState)(n??""),[l,c]=(0,iM.useState)([]),[h,d]=(0,iM.useState)(!1),[u,p]=(0,iM.useState)(!1);(0,iM.useEffect)(()=>{e&&(a(n??""),c([]))},[e,n]);let f=(0,iM.useCallback)(async e=>{if(a(e),c([]),e){d(!0);try{let i=await (0,rO.fetchWithAuth)(`/api/folder/read-file?path=${encodeURIComponent(e)}`);if(!i.ok)return void c([]);let n=await i.json();n.scripts&&"object"==typeof n.scripts?c(Object.entries(n.scripts).map(([e,i])=>({name:e,command:String(i),selected:!0}))):c([])}catch{c([])}finally{d(!1)}}},[]),m=async()=>{let e=l.filter(e=>e.selected);if(0!==e.length){p(!0);try{let n=o.includes("/")?o.substring(0,o.lastIndexOf("/")):o;await r(e.map(e=>({name:e.name,command:e.command,folder:n}))),i(!1)}finally{p(!1)}}};return(0,iN.jsx)(rE.Dialog,{open:e,onOpenChange:i,children:(0,iN.jsxs)(rE.DialogContent,{className:"sm:max-w-[520px]",children:[(0,iN.jsxs)(rE.DialogHeader,{children:[(0,iN.jsx)(rE.DialogTitle,{children:s("importTitle")}),(0,iN.jsx)(rE.DialogDescription,{children:s("importDescription")})]}),(0,iN.jsxs)("div",{className:"flex flex-col gap-3 py-2",children:[(0,iN.jsxs)("div",{children:[(0,iN.jsx)("label",{className:"text-xs text-muted-foreground mb-1 block",children:s("selectProject")}),(0,iN.jsx)(hw.FolderPicker,{value:o,onChange:f,allowFiles:!0,fileFilter:"package.json"})]}),l.length>0&&(0,iN.jsxs)("div",{className:"flex flex-col border border-border rounded-lg overflow-hidden",children:[(0,iN.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-muted/50 border-b border-border",children:[(0,iN.jsx)("button",{onClick:()=>{let e=l.every(e=>e.selected);c(i=>i.map(i=>({...i,selected:!e})))},className:`shrink-0 w-4 h-4 rounded border flex items-center justify-center transition-colors ${l.every(e=>e.selected)?"bg-primary border-primary text-primary-foreground":"border-border hover:border-primary"}`,children:l.every(e=>e.selected)&&(0,iN.jsx)(hS.Check,{size:10})}),(0,iN.jsxs)("span",{className:"text-xs font-medium",children:[s("parsedScripts")," (",l.length,")"]})]}),(0,iN.jsx)("div",{className:"max-h-[280px] overflow-y-auto",children:l.map((e,i)=>(0,iN.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 hover:bg-accent cursor-pointer border-b border-border last:border-b-0",onClick:()=>{c(e=>e.map((e,n)=>n===i?{...e,selected:!e.selected}:e))},children:[(0,iN.jsx)("button",{className:`shrink-0 w-4 h-4 rounded border flex items-center justify-center transition-colors ${e.selected?"bg-primary border-primary text-primary-foreground":"border-border hover:border-primary"}`,children:e.selected&&(0,iN.jsx)(hS.Check,{size:10})}),(0,iN.jsx)("span",{className:"text-xs font-medium w-24 truncate shrink-0",children:e.name}),(0,iN.jsx)("span",{className:"text-xs text-muted-foreground font-mono truncate flex-1",children:e.command})]},e.name))})]}),!h&&o&&0===l.length&&(0,iN.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:s("noScripts")}),h&&(0,iN.jsx)("div",{className:"flex items-center justify-center py-4",children:(0,iN.jsx)(hk.Loader2,{className:"size-4 animate-spin text-muted-foreground"})})]}),(0,iN.jsxs)(rE.DialogFooter,{children:[(0,iN.jsx)(hv.Button,{variant:"outline",onClick:()=>i(!1),children:s("cancel")}),(0,iN.jsx)(hv.Button,{onClick:m,disabled:0===l.filter(e=>e.selected).length||u,children:s("addSelected")})]})]})})}let hT="u">typeof navigator&&/Mac|iPhone|iPad/.test(navigator.userAgent)?[{value:"/bin/zsh",label:"zsh"},{value:"/bin/bash",label:"bash"}]:[{value:"cmd.exe",label:"CMD"},{value:"powershell.exe",label:"PowerShell"}],hE=hT[0];function hN({command:e,running:i,onRun:n,onClose:r,onEdit:s,onDelete:o}){let[a,l]=(0,iM.useState)(!1);return(0,iN.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1 text-xs hover:bg-accent group cursor-default",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[(0,iN.jsx)("button",{onClick:i?r:n,className:`shrink-0 p-0.5 rounded ${i?"text-green-500 hover:text-destructive":"text-muted-foreground hover:text-foreground"}`,children:i?(0,iN.jsx)(ru.X,{size:12}):(0,iN.jsx)(rx,{size:12})}),(0,iN.jsx)("span",{className:"truncate flex-1 font-mono",children:e.name}),i&&(0,iN.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500 animate-pulse shrink-0"}),a&&(0,iN.jsxs)(iN.Fragment,{children:[(0,iN.jsx)("button",{onClick:s,className:"shrink-0 p-0.5 text-muted-foreground hover:text-foreground",children:(0,iN.jsx)(rw.Pencil,{size:11})}),(0,iN.jsx)("button",{onClick:o,className:"shrink-0 p-0.5 text-muted-foreground hover:text-destructive",children:(0,iN.jsx)(nJ.Trash2,{size:11})})]})]})}function hM({workspaceId:e,boundDirs:i}){let{sessions:n,activeId:r,init:s,createSession:o,setActive:a,removeSession:l}=rM(),{commands:c,load:h,run:d,remove:u,update:p,create:f,isRunning:m,runningMap:g}=rI(),v=(0,n0.useTranslations)("terminal"),y=(0,n0.useTranslations)("commands"),[_,b]=(0,iM.useState)(!1),[w,S]=(0,iM.useState)(void 0),[k,C]=(0,iM.useState)(!1),[T,E]=(0,iM.useState)(),[N,M]=(0,iM.useState)(!1),[O,A]=(0,iM.useState)(""),[R,D]=(0,iM.useState)(!0),[L,j]=(0,iM.useState)({}),[I,P]=(0,iM.useState)(!1),B=(0,iM.useCallback)(()=>{if(0!==i.length&&1===i.length)return i[0]},[i]),z=(0,iM.useCallback)(e=>{let n=B();if(void 0===n&&i.length>1){S(e),b(!0);return}o(e,n)},[B,i.length,o]),F=(0,iM.useCallback)(e=>{b(!1),o(w,e),S(void 0)},[w,o]);(0,iM.useEffect)(()=>{s(rL(e)),0===n.length&&z()},[e]),(0,iM.useEffect)(()=>{e&&h(e)},[e]);let{customCommands:W,folderGroups:H}=(0,iM.useMemo)(()=>{let e=O?c.filter(e=>e.name.toLowerCase().includes(O.toLowerCase())||e.command.toLowerCase().includes(O.toLowerCase())):c,i=[],n={};for(let r of e)r.folder?(n[r.folder]||(n[r.folder]=[]),n[r.folder].push(r)):i.push(r);return{customCommands:i,folderGroups:n}},[c,O]),$=e=>{j(i=>({...i,[e]:!i[e]}))},U=async i=>{for(let n of i)await f(e,{name:n.name,command:n.command,folder:n.folder,cwd:n.folder})};return(0,iN.jsxs)("div",{className:"flex flex-col h-full bg-background",children:[(0,iN.jsxs)("div",{className:"flex items-center gap-0.5 px-1 py-0.5 bg-muted border-b border-border overflow-x-auto",children:[n.map(e=>{var i;return(0,iN.jsxs)("button",{onClick:()=>a(e.id),className:`flex items-center gap-1 px-2 py-1 text-xs rounded-t transition-colors shrink-0 ${r===e.id?"bg-background text-foreground":"text-muted-foreground hover:text-foreground hover:bg-background/50"}`,children:[(0,iN.jsx)("span",{className:"font-mono text-[10px] opacity-60",children:e.name??((i=e.shell)?hT.find(e=>e.value===i)?.label??i:hE.label)}),!e.name&&(0,iN.jsx)("span",{children:n.indexOf(e)+1}),(0,iN.jsx)("span",{onClick:i=>{i.stopPropagation(),l(e.id)},className:"ml-1 hover:text-destructive cursor-pointer",children:(0,iN.jsx)(ru.X,{size:12})})]},e.id)}),(0,iN.jsxs)(rT.DropdownMenu,{children:[(0,iN.jsx)(rT.DropdownMenuTrigger,{render:(0,iN.jsxs)("button",{className:"flex items-center gap-0.5 h-6 px-1.5 text-muted-foreground hover:text-foreground transition-colors",title:v("newTerminal"),children:[(0,iN.jsx)(ry.Plus,{size:14}),(0,iN.jsx)(r_.ChevronDown,{size:10})]})}),(0,iN.jsx)(rT.DropdownMenuContent,{align:"start",className:"min-w-[120px]",children:hT.map(e=>(0,iN.jsx)(rT.DropdownMenuItem,{onClick:()=>z(e.value),className:"text-xs",children:e.label},e.value))})]}),(0,iN.jsx)("div",{className:"md:hidden ml-auto",children:(0,iN.jsxs)(rN.Popover,{open:I,onOpenChange:P,children:[(0,iN.jsx)(rN.PopoverTrigger,{render:(0,iN.jsx)("button",{className:"flex items-center gap-1 h-6 px-1.5 text-muted-foreground hover:text-foreground transition-colors",title:y("commands"),children:(0,iN.jsx)(rC,{size:14})})}),(0,iN.jsx)(rN.PopoverContent,{align:"end",sideOffset:4,className:"w-[260px] p-0 overflow-hidden",children:(0,iN.jsx)(hO,{search:O,onSearchChange:A,commands:c,customCommands:W,folderGroups:H,customOpen:R,onCustomOpenChange:D,collapsedFolders:L,onToggleFolder:$,onImport:()=>{M(!0),P(!1)},onAddCommand:()=>{E(void 0),C(!0),P(!1)},workspaceId:e,isRunning:m,runningMap:g,removeSession:l,run:d,remove:u,setEditingCommand:E,setDialogOpen:e=>{if(C(e),!e)return},tc:y})})]})})]}),(0,iN.jsxs)("div",{className:"flex flex-row flex-1 overflow-hidden",children:[(0,iN.jsx)("div",{className:"hidden md:flex w-[200px] flex-col border-r border-border shrink-0 overflow-hidden",children:(0,iN.jsx)(hO,{search:O,onSearchChange:A,commands:c,customCommands:W,folderGroups:H,customOpen:R,onCustomOpenChange:D,collapsedFolders:L,onToggleFolder:$,onImport:()=>M(!0),onAddCommand:()=>{E(void 0),C(!0)},workspaceId:e,isRunning:m,runningMap:g,removeSession:l,run:d,remove:u,setEditingCommand:E,setDialogOpen:C,tc:y})}),(0,iN.jsx)("div",{className:"flex-1 overflow-hidden relative",children:0===n.length?(0,iN.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:v("noSession")}):n.map(i=>(0,iN.jsx)("div",{className:"absolute inset-0",style:{display:r===i.id?"block":"none"},children:(0,iN.jsx)(hg,{sessionId:i.id,workspaceId:e})},i.id))})]}),(0,iN.jsx)(rE.Dialog,{open:_,onOpenChange:b,children:(0,iN.jsxs)(rE.DialogContent,{children:[(0,iN.jsxs)(rE.DialogHeader,{children:[(0,iN.jsx)(rE.DialogTitle,{children:v("selectWorkingDirectory")}),(0,iN.jsx)(rE.DialogDescription,{children:v("selectWorkingDirectoryDescription")})]}),(0,iN.jsx)("div",{className:"flex flex-col gap-2 py-2",children:i.map(e=>(0,iN.jsxs)("button",{onClick:()=>F(e),className:"flex items-center gap-2 px-3 py-2 text-sm text-left rounded-md border border-border hover:bg-accent hover:text-accent-foreground transition-colors",children:[(0,iN.jsx)(nP.FolderOpen,{size:14,className:"shrink-0 text-muted-foreground"}),(0,iN.jsx)("span",{className:"truncate font-mono text-xs",children:e})]},e))})]})}),(0,iN.jsx)(hx,{open:k,onOpenChange:C,command:T,defaultCwd:i[0],onSubmit:async i=>{T?await p(e,T.id,i):await f(e,i)}}),(0,iN.jsx)(hC,{open:N,onOpenChange:M,defaultPath:i[0],onImport:U})]})}function hO({search:e,onSearchChange:i,commands:n,customCommands:r,folderGroups:s,customOpen:o,onCustomOpenChange:a,collapsedFolders:l,onToggleFolder:c,onImport:h,onAddCommand:d,workspaceId:u,isRunning:p,runningMap:f,removeSession:m,run:g,remove:v,setEditingCommand:y,setDialogOpen:_,tc:b}){return(0,iN.jsxs)("div",{className:"flex flex-col h-full max-h-[50vh]",children:[(0,iN.jsxs)("div",{className:"flex items-center gap-1 px-1.5 py-1.5 border-b border-border",children:[(0,iN.jsxs)("div",{className:"flex items-center gap-1 flex-1 bg-muted rounded px-1.5 py-0.5",children:[(0,iN.jsx)(rS.Search,{size:12,className:"text-muted-foreground shrink-0"}),(0,iN.jsx)("input",{value:e,onChange:e=>i(e.target.value),placeholder:b("searchPlaceholder"),className:"flex-1 bg-transparent text-xs outline-none placeholder:text-muted-foreground min-w-0"}),e&&(0,iN.jsx)("button",{onClick:()=>i(""),className:"text-muted-foreground hover:text-foreground",children:(0,iN.jsx)(ru.X,{size:10})})]}),(0,iN.jsx)("button",{onClick:h,className:"shrink-0 p-1 text-muted-foreground hover:text-foreground transition-colors",title:b("import"),children:(0,iN.jsx)(rk.Download,{size:13})})]}),(0,iN.jsx)("div",{className:"flex-1 overflow-y-auto py-1",children:0===n.length?(0,iN.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:b("noCommands")}):(0,iN.jsxs)(iN.Fragment,{children:[r.length>0&&(0,iN.jsxs)(nZ.Collapsible,{open:o,onOpenChange:a,children:[(0,iN.jsxs)("div",{className:"flex items-center gap-1 px-2 py-0.5 group",children:[(0,iN.jsxs)(nZ.CollapsibleTrigger,{className:"flex items-center gap-1 flex-1 text-[10px] font-semibold text-muted-foreground uppercase tracking-wider hover:text-foreground",children:[o?(0,iN.jsx)(r_.ChevronDown,{size:10,className:"shrink-0"}):(0,iN.jsx)(rb.ChevronRight,{size:10,className:"shrink-0"}),(0,iN.jsx)("span",{children:b("customCommands")}),(0,iN.jsxs)("span",{className:"text-muted-foreground/60",children:["(",r.length,")"]})]}),(0,iN.jsx)("button",{onClick:d,className:"shrink-0 p-0.5 text-muted-foreground hover:text-foreground opacity-0 group-hover:opacity-100 transition-opacity",title:b("addCommand"),children:(0,iN.jsx)(ry.Plus,{size:12})})]}),(0,iN.jsx)(nZ.CollapsibleContent,{children:r.map(e=>(0,iN.jsx)(hN,{command:e,running:p(e.id),onRun:()=>g(u,e.id),onClose:()=>{let i=f[e.id];i&&m(i.sessionId)},onEdit:()=>{y(e),_(!0)},onDelete:()=>v(u,e.id)},e.id))})]}),Object.entries(s).map(([e,i])=>{let n=!0!==l[e];return(0,iN.jsxs)(nZ.Collapsible,{open:n,onOpenChange:()=>c(e),children:[(0,iN.jsx)("div",{className:"flex items-center gap-1 px-2 py-0.5 mt-1 group",children:(0,iN.jsxs)(nZ.CollapsibleTrigger,{className:"flex items-center gap-1 flex-1 text-[10px] font-semibold text-muted-foreground uppercase tracking-wider hover:text-foreground",children:[n?(0,iN.jsx)(r_.ChevronDown,{size:10,className:"shrink-0"}):(0,iN.jsx)(rb.ChevronRight,{size:10,className:"shrink-0"}),(0,iN.jsx)("span",{className:"truncate",children:e.split("/").pop()||e}),(0,iN.jsxs)("span",{className:"text-muted-foreground/60",children:["(",i.length,")"]})]})}),(0,iN.jsx)(nZ.CollapsibleContent,{children:i.map(e=>(0,iN.jsx)(hN,{command:e,running:p(e.id),onRun:()=>g(u,e.id),onClose:()=>{let i=f[e.id];i&&m(i.sessionId)},onEdit:()=>{y(e),_(!0)},onDelete:()=>v(u,e.id)},e.id))})]},e)}),0===r.length&&(0,iN.jsxs)("div",{className:"flex items-center gap-1 px-2 py-0.5 group",children:[(0,iN.jsx)("span",{className:"text-[10px] font-semibold text-muted-foreground uppercase tracking-wider flex-1",children:b("customCommands")}),(0,iN.jsx)("button",{onClick:d,className:"shrink-0 p-0.5 text-muted-foreground hover:text-foreground opacity-0 group-hover:opacity-100 transition-opacity",title:b("addCommand"),children:(0,iN.jsx)(ry.Plus,{size:12})})]})]})})]})}let hA="agent-spaces:channel:",hR=(0,re.create)((e,i)=>({workspaceId:null,channels:[],activeChannelId:null,channelSelectSeq:0,messages:{},loadChannels:async i=>{let n=await fetch(`/api/workspaces/${i}/channels`),r=await n.json(),s=function(e,i){try{let n=localStorage.getItem(hA+e);if(n&&i.some(e=>e.id===n))return n}catch{}return i[0]?.id??null}(i,r);e({workspaceId:i,channels:r,activeChannelId:s})},createChannel:async(i,n,r="general",s)=>{let o=await fetch(`/api/workspaces/${i}/channels`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:n,type:r,members:s})}),a=await o.json();e(e=>({channels:e.channels.some(e=>e.id===a.id)?e.channels.map(e=>e.id===a.id?a:e):[...e.channels,a],activeChannelId:a.id}))},updateChannel:async(i,n,r)=>{let s=await fetch(`/api/workspaces/${i}/channels/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}),o=await s.json();e(e=>({channels:e.channels.map(e=>e.id===n?o:e)}))},setActiveChannel:i=>{let{workspaceId:n}=hR.getState();if(n)try{localStorage.setItem(hA+n,i)}catch{}e(e=>({activeChannelId:i,channelSelectSeq:e.channelSelectSeq+1}))},loadMessages:async(i,n)=>{let r=await fetch(`/api/workspaces/${i}/channels/${n}/messages`),s=await r.json();e(e=>({messages:{...e.messages,[n]:s}}))},sendMessage:(e,i,n,r=[],s=[])=>{rL(e).send("channel.message",{channelId:i,content:n,mentions:r,attachments:s})},addMessage:(i,n)=>{e(e=>({messages:{...e.messages,[i]:[...e.messages[i]||[],n]}}))},updateMessage:(i,n)=>{e(e=>({messages:{...e.messages,[i]:(e.messages[i]||[]).map(e=>e.id===n.id?n:e)}}))},stopProcessingMessages:i=>{e(e=>({messages:{...e.messages,[i]:(e.messages[i]||[]).map(e=>"pending"===e.status||"streaming"===e.status||"waiting_for_user"===e.status?{...e,status:"error",content:e.content||"Stopped by user"}:e)}}))},deleteMessage:(i,n)=>{e(e=>({messages:{...e.messages,[i]:(e.messages[i]||[]).filter(e=>e.id!==n)}}))},clearMessages:async(i,n)=>{await fetch(`/api/workspaces/${i}/channels/${n}/messages`,{method:"DELETE"}),e(e=>({messages:{...e.messages,[n]:[]}}))},deleteChannel:async(e,n)=>{await fetch(`/api/workspaces/${e}/channels/${n}`,{method:"DELETE"}),i().removeChannelLocal(n)},removeChannelLocal:i=>{e(e=>{let n=e.channels.filter(e=>e.id!==i),r={...e.messages};return delete r[i],{channels:n,activeChannelId:e.activeChannelId===i?n[0]?.id??null:e.activeChannelId,messages:r}})},saveDraft:async(i,n,r)=>{let s=hR.getState().channels.find(e=>e.id===n);if(s?.draft?.content===r)return;let o={content:r,updatedAt:new Date().toISOString()};e(e=>({channels:e.channels.map(e=>e.id===n?{...e,draft:o}:e)})),await fetch(`/api/workspaces/${i}/channels/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({draft:o})})},clearDraft:async(i,n)=>{e(e=>({channels:e.channels.map(e=>e.id===n?{...e,draft:void 0}:e)})),await fetch(`/api/workspaces/${i}/channels/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({draft:null})})}}));var hD=e.i(355819),hL=e.i(325443);let hj=(0,nL.default)("message-circle",[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]]);var hI=e.i(511800),hP=e.i(562918),hB=e.i(188815),hz=e.i(611176);function hF({candidates:e,selected:i,onToggle:n,searchPlaceholder:r,emptyText:s,label:o}){let[a,l]=(0,iM.useState)(""),c=e.filter(e=>`${e.label} ${e.description||""}`.toLowerCase().includes(a.toLowerCase()));return(0,iN.jsxs)("div",{className:"space-y-2",children:[o&&(0,iN.jsx)("label",{className:"text-sm font-medium",children:o}),(0,iN.jsx)(hy.Input,{value:a,onChange:e=>l(e.target.value),placeholder:r}),(0,iN.jsxs)("div",{className:"max-h-40 overflow-y-auto space-y-0.5",children:[0===c.length&&(0,iN.jsx)("p",{className:"text-sm text-muted-foreground py-2 text-center",children:s||"No items found"}),c.map(e=>(0,iN.jsxs)("button",{type:"button",onClick:()=>n(e.id),className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md hover:bg-muted text-left text-sm transition-colors",children:[(0,iN.jsx)(hz.AgentIcon,{agentId:"user"!==e.id?e.id:void 0,name:e.label,className:"size-5 rounded-full"}),(0,iN.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,iN.jsx)("span",{className:"block truncate",children:e.label}),e.description&&(0,iN.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:e.description})]}),(0,iN.jsx)("div",{className:`flex items-center justify-center size-4 rounded border shrink-0 ${i.includes(e.id)?"bg-primary border-primary text-primary-foreground":"border-input"}`})]},e.id))]}),i.length>0&&(0,iN.jsx)("div",{className:"flex flex-wrap gap-1.5",children:i.map(i=>{let r=e.find(e=>e.id===i),s=r?.label||i;return(0,iN.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-md bg-muted px-2 py-0.5 text-xs",children:["user"===i?s:(0,iN.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,iN.jsx)(hz.AgentIcon,{agentId:i,name:s,className:"size-3.5 rounded-full"}),s]}),(0,iN.jsx)("button",{type:"button",onClick:()=>n(i),className:"hover:text-destructive",children:(0,iN.jsx)(ru.X,{className:"size-3"})})]},i)})})]})}function hW(e){return e.name?.trim()||e.role}function hH(e,i){return e.find(e=>e.id===i)}function h$(e,i){if("user"===i)return"user";let n=hH(e,i);return n?hW(n):i}function hU(e,i){let n=new Set(e.map(e=>e.id)),r=[],s=new Set;for(let e of i)n.has(e)&&(s.has(e)||(s.add(e),r.push(e)));return r}function hV({open:e,onOpenChange:i,channel:n,agents:r=[],onSubmit:s}){let o=(0,n0.useTranslations)("chat"),a=(0,n0.useTranslations)("common"),l=[{value:"general",label:o("channel.general")},{value:"issue",label:o("channel.issue")},{value:"agent",label:o("channel.agent")}],[c,h]=(0,iM.useState)(""),[d,u]=(0,iM.useState)("general"),[p,f]=(0,iM.useState)([]),[m,g]=(0,iM.useState)(0),v=r.filter(e=>!1!==e.enabled).map(e=>({id:e.id,label:h$(r,e.id)}));return(0,iM.useEffect)(()=>{e&&queueMicrotask(()=>{n?(h(n.name),u(n.type),f([...n.members])):(h(""),u("general"),f(["user"])),g(e=>e+1)})},[e,n]),(0,iN.jsx)(rE.Dialog,{open:e,onOpenChange:i,children:(0,iN.jsxs)(rE.DialogContent,{className:"sm:max-w-md",children:[(0,iN.jsxs)(rE.DialogHeader,{children:[(0,iN.jsx)(rE.DialogTitle,{children:o(n?"channel.edit":"channel.create")}),(0,iN.jsx)(rE.DialogDescription,{children:o(n?"channel.edit":"channel.create")})]}),(0,iN.jsxs)("div",{className:"space-y-4 pt-2",children:[(0,iN.jsxs)("div",{className:"space-y-2",children:[(0,iN.jsx)("label",{className:"text-sm font-medium",children:a("name")}),(0,iN.jsx)(hy.Input,{value:c,onChange:e=>h(e.target.value),placeholder:o("channel.namePlaceholder"),onKeyDown:e=>"Enter"===e.key&&e.preventDefault()})]}),(0,iN.jsxs)("div",{className:"space-y-2",children:[(0,iN.jsx)("label",{className:"text-sm font-medium",children:o("channel.type")}),(0,iN.jsx)(hB.SearchSelect,{value:d,onChange:e=>u(e),options:l,allowCustom:!1,placeholder:o("channel.selectType")})]}),(0,iN.jsx)(hF,{candidates:v,selected:p,onToggle:e=>{f(i=>i.includes(e)?i.filter(i=>i!==e):[...i,e])},label:o("channel.members"),searchPlaceholder:o("channel.addMember"),emptyText:o("channel.noAgents")||"No agents found"},m),(0,iN.jsxs)("div",{className:"flex justify-end gap-2 pt-2",children:[(0,iN.jsx)(hv.Button,{variant:"outline",onClick:()=>i(!1),children:a("cancel")}),(0,iN.jsx)(hv.Button,{onClick:()=>{c.trim()&&(s({name:c.trim(),type:d,members:p}),i(!1))},disabled:!c.trim(),children:a(n?"save":"create")})]})]})]})})}e.s([],2365),e.i(2365);var hq=e.i(394822),hY=e.i(174465),hK=e.i(648224),hX=e.i(35359),hJ=e.i(422561),hG=e.i(526850),hZ=e.i(232449),hQ=e.i(410421),h0=e.i(150129),h1=e.i(969490),h2=e.i(602453),h5=e.i(817955),h3=e.i(742665),h4=e.i(87709);let h6=iM.forwardRef(function(e,i){let{render:n,className:r,style:s,...o}=e,{setAnchor:a,actionsRef:l,internalBackdropRef:c,backdropRef:h,positionerRef:d,allowMouseUpTriggerRef:u,initialCursorPointRef:p,rootId:f}=(0,hY.useContextMenuRootContext)(!1),{store:m}=(0,hX.useMenuRootContext)(!1),g=m.useState("open"),v=m.useState("disabled"),y=iM.useRef(null),_=iM.useRef(null),b=(0,hZ.useTimeout)(),w=(0,hZ.useTimeout)(),S=iM.useRef(!1);function k(e,i,n){let r=n.type.startsWith("touch");p.current={x:e,y:i},a({getBoundingClientRect:()=>DOMRect.fromRect({width:10*!!r,height:10*!!r,x:e,y:i})}),S.current=!1,l.current?.setOpen(!0,(0,h2.createChangeEventDetails)(h3.REASONS.triggerPress,n)),w.start(500,()=>{S.current=!0})}function C(){b.clear(),_.current=null}return iM.useEffect(()=>{let e=(0,hG.ownerDocument)(y.current);return(0,hJ.addEventListener)(e,"contextmenu",function(e){if(v)return;let i=(0,hQ.getTarget)(e);((0,hQ.contains)(y.current,i)||(0,hQ.contains)(c.current,i)||(0,hQ.contains)(h.current,i))&&e.preventDefault()})},[h,v,c]),(0,h1.useRenderElement)("div",e,{state:{open:g},ref:[y,i],props:[{onContextMenu:function(e){if(v)return;u.current=!0,(0,h0.stopEvent)(e),k(e.clientX,e.clientY,e.nativeEvent);let i=(0,hG.ownerDocument)(y.current);(0,hJ.addEventListener)(i,"mouseup",e=>{if(u.current=!1,!S.current)return;w.clear(),S.current=!1;let i=(0,hQ.getTarget)(e);(0,hQ.contains)(d.current,i)||f&&i&&(0,h4.findRootOwnerId)(i)===f||l.current?.setOpen(!1,(0,h2.createChangeEventDetails)(h3.REASONS.cancelOpen,e))},{once:!0})},onTouchStart:function(e){if(!v&&(u.current=!1,1===e.touches.length)){e.stopPropagation();let i=e.touches[0];_.current={x:i.clientX,y:i.clientY},b.start(500,()=>{_.current&&k(_.current.x,_.current.y,e.nativeEvent)})}},onTouchMove:function(e){if(b.isStarted()&&_.current&&1===e.touches.length){let i=e.touches[0],n=Math.abs(i.clientX-_.current.x),r=Math.abs(i.clientY-_.current.y);(n>10||r>10)&&b.clear()}},onTouchEnd:C,onTouchCancel:C,style:{WebkitTouchCallout:"none"}},o],stateAttributesMapping:h5.pressableTriggerOpenStateMapping})});var h8=e.i(487455),h9=e.i(293209),h7=e.i(503662),de=e.i(33427),dt=e.i(324573),di=e.i(582883),dn=e.i(277658),dr=e.i(349204),ds=e.i(28051),da=e.i(597375),dl=e.i(81752),dc=e.i(59354),dh=e.i(300637),dd=e.i(281478),du=e.i(65255),dp=e.i(327794),df=e.i(362962);e.s(["Arrow",()=>dt.MenuArrow,"Backdrop",()=>h8.MenuBackdrop,"CheckboxItem",()=>ds.MenuCheckboxItem,"CheckboxItemIndicator",()=>da.MenuCheckboxItemIndicator,"Group",()=>di.MenuGroup,"GroupLabel",()=>dn.MenuGroupLabel,"Item",()=>dr.MenuItem,"LinkItem",()=>dl.MenuLinkItem,"Popup",()=>de.MenuPopup,"Portal",()=>h9.MenuPortal,"Positioner",()=>h7.MenuPositioner,"RadioGroup",()=>dc.MenuRadioGroup,"RadioItem",()=>dh.MenuRadioItem,"RadioItemIndicator",()=>dd.MenuRadioItemIndicator,"Root",0,function(e){let[i,n]=iM.useState({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,x:0,y:0})}),r=iM.useRef(null),s=iM.useRef(null),o=iM.useRef(null),a=iM.useRef(null),l=iM.useRef(!0),c=iM.useRef(null),h=(0,hq.useId)(),d=iM.useMemo(()=>({anchor:i,setAnchor:n,actionsRef:o,backdropRef:r,internalBackdropRef:s,positionerRef:a,allowMouseUpTriggerRef:l,initialCursorPointRef:c,rootId:h}),[i,h]);return(0,iN.jsx)(hY.ContextMenuRootContext.Provider,{value:d,children:(0,iN.jsx)(hX.MenuRootContext.Provider,{value:void 0,children:(0,iN.jsx)(hK.Menu.Root,{...e})})})},"Separator",()=>df.Separator,"SubmenuRoot",()=>du.MenuSubmenuRoot,"SubmenuTrigger",()=>dp.MenuSubmenuTrigger,"Trigger",0,h6],912001);var dm=e.i(912001),dm=dm,dg=e.i(299648);function dv({...e}){return(0,iN.jsx)(dm.Root,{"data-slot":"context-menu",...e})}function dy({className:e,...i}){return(0,iN.jsx)(dm.Trigger,{"data-slot":"context-menu-trigger",className:(0,nQ.cn)("select-none",e),...i})}function d_({className:e,align:i="start",alignOffset:n=4,side:r="right",sideOffset:s=0,...o}){return(0,iN.jsx)(dm.Portal,{children:(0,iN.jsx)(dm.Positioner,{className:"isolate z-50 outline-none",align:i,alignOffset:n,side:r,sideOffset:s,children:(0,iN.jsx)(dm.Popup,{"data-slot":"context-menu-content",className:(0,nQ.cn)("z-50 max-h-(--available-height) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-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 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...o})})})}function db({className:e,inset:i,variant:n="default",...r}){return(0,iN.jsx)(dm.Item,{"data-slot":"context-menu-item","data-inset":i,"data-variant":n,className:(0,nQ.cn)("group/context-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus:*:[svg]:text-accent-foreground data-[variant=destructive]:*:[svg]:text-destructive",e),...r})}function dx({className:e,...i}){return(0,iN.jsx)(dm.Separator,{"data-slot":"context-menu-separator",className:(0,nQ.cn)("-mx-1 my-1 h-px bg-border",e),...i})}let dw={general:{className:"bg-muted text-muted-foreground",icon:nj},issue:{className:"bg-amber-500/15 text-amber-600",icon:hI.AlertCircle},agent:{className:"bg-blue-500/15 text-blue-600",icon:hj}};function dS({workspaceId:e}){let i=(0,n0.useTranslations)("chat"),n=(0,n0.useTranslations)("common"),{channels:r,activeChannelId:s,messages:o,loadChannels:a,createChannel:l,updateChannel:c,setActiveChannel:h}=hR(),[d,u]=(0,iM.useState)(!1),[p,f]=(0,iM.useState)(null),m=(0,hD.useAgentStore)(e=>e.agents),g=(0,hD.useAgentStore)(e=>e.ensure);(0,iM.useEffect)(()=>{a(e),g()},[e,a,g]),(0,iM.useEffect)(()=>{let i=rL(e).on("channel.updated",e=>{hR.setState(i=>{let n=i.channels.findIndex(i=>i.id===e.id);if(n>=0){let r=[...i.channels];return r[n]=e,{channels:r}}return{channels:[...i.channels,e]}})});return()=>{i()}},[e]);let v=async i=>{let n=hU(m,i.members);p?await c(e,p.id,{name:i.name,type:i.type,members:n}):await l(e,i.name,i.type,n)},y=async i=>{await fetch(`/api/workspaces/${e}/files/reveal?channelId=${i}`,{method:"POST"})};return(0,iN.jsxs)("div",{className:"flex flex-col h-full",children:[(0,iN.jsxs)("div",{className:"flex items-center justify-between px-2 py-1.5 border-b text-xs font-medium text-muted-foreground",children:[(0,iN.jsx)("span",{children:i("channel.general")}),(0,iN.jsx)("button",{onClick:()=>u(!0),className:"p-0.5 hover:bg-accent rounded",children:(0,iN.jsx)(ry.Plus,{className:"size-3.5"})})]}),(0,iN.jsxs)("div",{className:"flex-1 overflow-y-auto",children:[0===r.length?(0,iN.jsxs)("div",{className:"flex flex-col items-center justify-center h-full gap-3 px-4 text-center",children:[(0,iN.jsx)("div",{className:"rounded-full bg-muted p-3",children:(0,iN.jsx)(hj,{className:"h-5 w-5 text-muted-foreground"})}),(0,iN.jsxs)("div",{children:[(0,iN.jsx)("p",{className:"text-sm font-medium",children:i("channel.noMembers")}),(0,iN.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:i("channel.create")})]}),(0,iN.jsxs)(hv.Button,{size:"sm",variant:"outline",onClick:()=>u(!0),children:[(0,iN.jsx)(ry.Plus,{className:"h-3.5 w-3.5 mr-1"}),n("add")]})]}):null,r.map(e=>{let r,a=function(e){if(!e||0===e.length)return null;let i=e[e.length-1];return i?{text:(i.content??"").replace(/<[^>]*>/g,"").slice(0,60)||"...",status:i.status}:null}(o[e.id]),l=dw[e.type],c=a?.status==="streaming"||a?.status==="pending",d=e.members.filter(e=>"user"!==e);return(0,iN.jsxs)(dv,{children:[(0,iN.jsxs)(dy,{className:(0,nQ.cn)("flex items-start gap-2.5 w-full px-3 py-2 text-sm hover:bg-accent transition-colors text-left",s===e.id&&"bg-accent text-accent-foreground"),onClick:()=>h(e.id),children:[(r=l.icon,(0,iN.jsx)(r,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0 mt-1"})),(0,iN.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,iN.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,iN.jsx)("span",{className:"truncate font-medium text-[13px]",children:e.name}),(0,iN.jsx)(hP.Badge,{variant:"secondary",className:(0,nQ.cn)("text-[10px] px-1 py-0 h-4 rounded",l.className),children:i(`channel.${e.type}`)}),c&&(0,iN.jsxs)("span",{className:"relative flex h-2 w-2",children:[(0,iN.jsx)("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-blue-400 opacity-75"}),(0,iN.jsx)("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-blue-500"})]}),d.length>0&&(0,iN.jsx)(hL.Bot,{className:"h-3 w-3 text-muted-foreground shrink-0"})]}),a?(0,iN.jsx)("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:a.text}):(0,iN.jsx)("p",{className:"text-xs text-muted-foreground/50 mt-0.5",children:i("emptyState")})]})]}),(0,iN.jsxs)(d_,{children:[(0,iN.jsxs)(db,{onClick:()=>{f(e),u(!0)},children:[(0,iN.jsx)(rw.Pencil,{className:"size-3.5"}),n("edit")]}),(0,iN.jsxs)(db,{onClick:()=>y(e.id),children:[(0,iN.jsx)(nP.FolderOpen,{className:"size-3.5"}),n("open")]})]})]},e.id)})]}),(0,iN.jsx)(hV,{open:d,onOpenChange:e=>{u(e),e||f(null)},workspaceId:e,channel:p,agents:m,onSubmit:v})]})}var dk=e.i(159619);let dC=(0,nL.default)("clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]]),dT=(0,nL.default)("user-minus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);function dE({open:e,onOpenChange:i,memberName:n,displayName:r,channelId:s,workspaceId:o,channels:a=[]}){let[l,c]=(0,iM.useState)(!1),{channels:h,updateChannel:d}=hR(),u=(0,hD.useAgentStore)(e=>e.agents),p="user"!==n?u.find(e=>e.id===n):void 0,f=r||p?.name||n,m="user"===n?localStorage.getItem("userAvatarUrl"):null,g=h.find(e=>e.id===s),v=g?.members.includes(n),y=async()=>{if(g&&v){c(!0);try{await d(o,s,{members:g.members.filter(e=>e!==n)}),i(!1)}finally{c(!1)}}};return(0,iN.jsx)(rE.Dialog,{open:e,onOpenChange:i,children:(0,iN.jsxs)(rE.DialogContent,{className:"sm:max-w-sm",children:[(0,iN.jsxs)(rE.DialogHeader,{children:[(0,iN.jsx)(rE.DialogTitle,{children:"成员信息"}),(0,iN.jsx)(rE.DialogDescription,{})]}),(0,iN.jsxs)("div",{className:"flex items-center gap-3 pt-2",children:[(0,iN.jsx)(hz.AgentIcon,{agentId:"user"!==n?n:void 0,name:f,avatarUrl:m||void 0,className:"size-12 rounded-full"}),(0,iN.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,iN.jsx)("p",{className:"text-sm font-medium truncate",children:f}),(0,iN.jsx)("p",{className:"text-xs text-muted-foreground",children:"user"===n?"成员":p?.role||n})]})]}),a.length>0&&(0,iN.jsxs)("div",{className:"space-y-2 pt-2",children:[(0,iN.jsx)("p",{className:"text-xs font-medium text-muted-foreground",children:"所在频道"}),(0,iN.jsx)("div",{className:"flex flex-wrap gap-1.5",children:a.map(e=>(0,iN.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-md bg-muted px-2 py-0.5 text-xs",children:[(0,iN.jsx)(nz.MessageSquare,{className:"size-3"}),e]},e))})]}),v&&"user"!==n&&(0,iN.jsxs)("button",{onClick:y,disabled:l,className:"flex items-center justify-center gap-2 w-full mt-2 px-3 py-2 rounded-md text-sm text-destructive hover:bg-destructive/10 disabled:opacity-50 transition-colors",children:[(0,iN.jsx)(dT,{className:"size-4"}),l?"移除中...":"从频道移除"]})]})})}let dN=(0,nL.default)("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);var dM=e.i(250438);let dO=(0,nL.default)("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);var dA=e.i(839374),dA=dA,dR=e.i(905724),dR=dR;let dD=(0,nL.default)("circle-question-mark",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),dL=(0,nL.default)("message-square-text",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M7 11h10",key:"1twpyw"}],["path",{d:"M7 15h6",key:"d9of3u"}],["path",{d:"M7 7h8",key:"af5zfr"}]]);function dj(){}function dI(){}let dP=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,dB=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,dz={};function dF(e,i){return((i||dz).jsx?dB:dP).test(e)}let dW=/[ \t\n\f\r]/g;function dH(e){return""===e.replace(dW,"")}class d${constructor(e,i){this.attribute=i,this.property=e}}d$.prototype.attribute="",d$.prototype.booleanish=!1,d$.prototype.boolean=!1,d$.prototype.commaOrSpaceSeparated=!1,d$.prototype.commaSeparated=!1,d$.prototype.defined=!1,d$.prototype.mustUseProperty=!1,d$.prototype.number=!1,d$.prototype.overloadedBoolean=!1,d$.prototype.property="",d$.prototype.spaceSeparated=!1,d$.prototype.space=void 0;let dU=0,dV=dZ(),dq=dZ(),dY=dZ(),dK=dZ(),dX=dZ(),dJ=dZ(),dG=dZ();function dZ(){return 2**++dU}e.s(["boolean",0,dV,"booleanish",0,dq,"commaOrSpaceSeparated",0,dG,"commaSeparated",0,dJ,"number",0,dK,"overloadedBoolean",0,dY,"spaceSeparated",0,dX],383954);var dQ=e.i(383954);let d0=Object.keys(dQ);class d1 extends d${constructor(e,i,n,r){let s=-1;if(super(e,i),function(e,i,n){n&&(e[i]=n)}(this,"space",r),"number"==typeof n)for(;++s<d0.length;){const e=d0[s];!function(e,i,n){n&&(e[i]=n)}(this,d0[s],(n&dQ[e])===dQ[e])}}}function d2(e){return e.toLowerCase()}d1.prototype.defined=!0;let d5=/[A-Z]/g,d3=/-[a-z]/g,d4=/^data[-\w.:]+$/i;function d6(e){return"-"+e.toLowerCase()}function d8(e){return e.charAt(1).toUpperCase()}let d9={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"};class d7{constructor(e,i,n){this.normal=i,this.property=e,n&&(this.space=n)}}function ue(e,i){let n={},r={};for(let i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new d7(n,r,i)}function ut(e){let i={},n={};for(let[r,s]of Object.entries(e.properties)){let o=new d1(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),i[r]=o,n[d2(r)]=r,n[d2(o.attribute)]=r}return new d7(i,n,e.space)}d7.prototype.normal={},d7.prototype.property={},d7.prototype.space=void 0;let ui=ut({properties:{ariaActiveDescendant:null,ariaAtomic:dq,ariaAutoComplete:null,ariaBusy:dq,ariaChecked:dq,ariaColCount:dK,ariaColIndex:dK,ariaColSpan:dK,ariaControls:dX,ariaCurrent:null,ariaDescribedBy:dX,ariaDetails:null,ariaDisabled:dq,ariaDropEffect:dX,ariaErrorMessage:null,ariaExpanded:dq,ariaFlowTo:dX,ariaGrabbed:dq,ariaHasPopup:null,ariaHidden:dq,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:dX,ariaLevel:dK,ariaLive:null,ariaModal:dq,ariaMultiLine:dq,ariaMultiSelectable:dq,ariaOrientation:null,ariaOwns:dX,ariaPlaceholder:null,ariaPosInSet:dK,ariaPressed:dq,ariaReadOnly:dq,ariaRelevant:null,ariaRequired:dq,ariaRoleDescription:dX,ariaRowCount:dK,ariaRowIndex:dK,ariaRowSpan:dK,ariaSelected:dq,ariaSetSize:dK,ariaSort:null,ariaValueMax:dK,ariaValueMin:dK,ariaValueNow:dK,ariaValueText:null,role:null},transform:(e,i)=>"role"===i?i:"aria-"+i.slice(4).toLowerCase()});function un(e,i){return i in e?e[i]:i}function ur(e,i){return un(e,i.toLowerCase())}let us=ut({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:dJ,acceptCharset:dX,accessKey:dX,action:null,allow:null,allowFullScreen:dV,allowPaymentRequest:dV,allowUserMedia:dV,alt:null,as:null,async:dV,autoCapitalize:null,autoComplete:dX,autoFocus:dV,autoPlay:dV,blocking:dX,capture:null,charSet:null,checked:dV,cite:null,className:dX,cols:dK,colSpan:null,content:null,contentEditable:dq,controls:dV,controlsList:dX,coords:dK|dJ,crossOrigin:null,data:null,dateTime:null,decoding:null,default:dV,defer:dV,dir:null,dirName:null,disabled:dV,download:dY,draggable:dq,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:dV,formTarget:null,headers:dX,height:dK,hidden:dY,high:dK,href:null,hrefLang:null,htmlFor:dX,httpEquiv:dX,id:null,imageSizes:null,imageSrcSet:null,inert:dV,inputMode:null,integrity:null,is:null,isMap:dV,itemId:null,itemProp:dX,itemRef:dX,itemScope:dV,itemType:dX,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:dV,low:dK,manifest:null,max:null,maxLength:dK,media:null,method:null,min:null,minLength:dK,multiple:dV,muted:dV,name:null,nonce:null,noModule:dV,noValidate:dV,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:dV,optimum:dK,pattern:null,ping:dX,placeholder:null,playsInline:dV,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:dV,referrerPolicy:null,rel:dX,required:dV,reversed:dV,rows:dK,rowSpan:dK,sandbox:dX,scope:null,scoped:dV,seamless:dV,selected:dV,shadowRootClonable:dV,shadowRootDelegatesFocus:dV,shadowRootMode:null,shape:null,size:dK,sizes:null,slot:null,span:dK,spellCheck:dq,src:null,srcDoc:null,srcLang:null,srcSet:null,start:dK,step:null,style:null,tabIndex:dK,target:null,title:null,translate:null,type:null,typeMustMatch:dV,useMap:null,value:dq,width:dK,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:dX,axis:null,background:null,bgColor:null,border:dK,borderColor:null,bottomMargin:dK,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:dV,declare:dV,event:null,face:null,frame:null,frameBorder:null,hSpace:dK,leftMargin:dK,link:null,longDesc:null,lowSrc:null,marginHeight:dK,marginWidth:dK,noResize:dV,noHref:dV,noShade:dV,noWrap:dV,object:null,profile:null,prompt:null,rev:null,rightMargin:dK,rules:null,scheme:null,scrolling:dq,standby:null,summary:null,text:null,topMargin:dK,valueType:null,version:null,vAlign:null,vLink:null,vSpace:dK,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:dV,disableRemotePlayback:dV,prefix:null,property:null,results:dK,security:null,unselectable:null},space:"html",transform:ur}),uo=ut({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:dG,accentHeight:dK,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:dK,amplitude:dK,arabicForm:null,ascent:dK,attributeName:null,attributeType:null,azimuth:dK,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:dK,by:null,calcMode:null,capHeight:dK,className:dX,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:dK,diffuseConstant:dK,direction:null,display:null,dur:null,divisor:dK,dominantBaseline:null,download:dV,dx:null,dy:null,edgeMode:null,editable:null,elevation:dK,enableBackground:null,end:null,event:null,exponent:dK,externalResourcesRequired:null,fill:null,fillOpacity:dK,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:dJ,g2:dJ,glyphName:dJ,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:dK,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:dK,horizOriginX:dK,horizOriginY:dK,id:null,ideographic:dK,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:dK,k:dK,k1:dK,k2:dK,k3:dK,k4:dK,kernelMatrix:dG,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:dK,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:dK,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:dK,overlineThickness:dK,paintOrder:null,panose1:null,path:null,pathLength:dK,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:dX,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:dK,pointsAtY:dK,pointsAtZ:dK,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:dG,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:dG,rev:dG,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:dG,requiredFeatures:dG,requiredFonts:dG,requiredFormats:dG,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:dK,specularExponent:dK,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:dK,strikethroughThickness:dK,string:null,stroke:null,strokeDashArray:dG,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:dK,strokeOpacity:dK,strokeWidth:null,style:null,surfaceScale:dK,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:dG,tabIndex:dK,tableValues:null,target:null,targetX:dK,targetY:dK,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:dG,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:dK,underlineThickness:dK,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:dK,values:null,vAlphabetic:dK,vMathematical:dK,vectorEffect:null,vHanging:dK,vIdeographic:dK,version:null,vertAdvY:dK,vertOriginX:dK,vertOriginY:dK,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:dK,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:un}),ua=ut({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform:(e,i)=>"xlink:"+i.slice(5).toLowerCase()}),ul=ut({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:ur}),uc=ut({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform:(e,i)=>"xml:"+i.slice(3).toLowerCase()}),uh=ue([ui,us,ua,ul,uc],"html"),ud=ue([ui,uo,ua,ul,uc],"svg");var uu=e.i(763185);let up=um("end"),uf=um("start");function um(e){return function(i){let n=i&&i.position&&i.position[e]||{};if("number"==typeof n.line&&n.line>0&&"number"==typeof n.column&&n.column>0)return{line:n.line,column:n.column,offset:"number"==typeof n.offset&&n.offset>-1?n.offset:void 0}}}function ug(e){return e&&"object"==typeof e?"position"in e||"type"in e?uy(e.position):"start"in e||"end"in e?uy(e):"line"in e||"column"in e?uv(e):"":""}function uv(e){return u_(e&&e.line)+":"+u_(e&&e.column)}function uy(e){return uv(e&&e.start)+"-"+uv(e&&e.end)}function u_(e){return e&&"number"==typeof e?e:1}class ub extends Error{constructor(e,i,n){super(),"string"==typeof i&&(n=i,i=void 0);let r="",s={},o=!1;if(i&&(s="line"in i&&"column"in i||"start"in i&&"end"in i?{place:i}:"type"in i?{ancestors:[i],place:i.position}:{...i}),"string"==typeof e?r=e:!s.cause&&e&&(o=!0,r=e.message,s.cause=e),!s.ruleId&&!s.source&&"string"==typeof n){const e=n.indexOf(":");-1===e?s.ruleId=n:(s.source=n.slice(0,e),s.ruleId=n.slice(e+1))}if(!s.place&&s.ancestors&&s.ancestors){const e=s.ancestors[s.ancestors.length-1];e&&(s.place=e.position)}const a=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=r,this.line=a?a.line:void 0,this.name=ug(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=o&&s.cause&&"string"==typeof s.cause.stack?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}ub.prototype.file="",ub.prototype.name="",ub.prototype.reason="",ub.prototype.message="",ub.prototype.stack="",ub.prototype.column=void 0,ub.prototype.line=void 0,ub.prototype.ancestors=void 0,ub.prototype.cause=void 0,ub.prototype.fatal=void 0,ub.prototype.place=void 0,ub.prototype.ruleId=void 0,ub.prototype.source=void 0;let ux={}.hasOwnProperty,uw=new Map,uS=/[A-Z]/g,uk=new Set(["table","tbody","thead","tfoot","tr"]),uC=new Set(["td","th"]),uT="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function uE(e,i,n){var r,s,o,a,l,c,h,d,u;let p,f,m,g,v,y,_,b,w,S,k;return"element"===i.type?(r=e,s=i,o=n,f=p=r.schema,"svg"===s.tagName.toLowerCase()&&"html"===p.space&&(r.schema=ud),r.ancestors.push(s),m=uA(r,s.tagName,!1),g=function(e,i){let n,r,s={};for(r in i.properties)if("children"!==r&&ux.call(i.properties,r)){let o=function(e,i,n){let r=function(e,i){let n=d2(i),r=i,s=d$;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&"data"===n.slice(0,4)&&d4.test(i)){if("-"===i.charAt(4)){let e=i.slice(5).replace(d3,d8);r="data"+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=i.slice(4);if(!d3.test(e)){let n=e.replace(d5,d6);"-"!==n.charAt(0)&&(n="-"+n),i="data"+n}}s=d1}return new s(r,i)}(e.schema,i);if(!(null==n||"number"==typeof n&&Number.isNaN(n))){var s;let i;if(Array.isArray(n)&&(n=r.commaSeparated?(i={},(""===(s=n)[s.length-1]?[...s,""]:s).join((i.padRight?" ":"")+","+(!1===i.padLeft?"":" ")).trim()):n.join(" ").trim()),"style"===r.property){let i="object"==typeof n?n:function(e,i){try{return(0,uu.default)(i,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};let i=new ub("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=uT+"#cannot-parse-style-attribute",i}}(e,String(n));return"css"===e.stylePropertyNameCase&&(i=function(e){let i,n={};for(i in e)ux.call(e,i)&&(n[function(e){let i=e.replace(uS,uD);return"ms-"===i.slice(0,3)&&(i="-"+i),i}(i)]=e[i]);return n}(i)),["style",i]}return["react"===e.elementAttributeNameCase&&r.space?d9[r.property]||r.property:r.attribute,n]}}(e,r,i.properties[r]);if(o){let[r,a]=o;e.tableCellAlignToStyle&&"align"===r&&"string"==typeof a&&uC.has(i.tagName)?n=a:s[r]=a}}return n&&((s.style||(s.style={}))["css"===e.stylePropertyNameCase?"text-align":"textAlign"]=n),s}(r,s),v=uO(r,s),uk.has(s.tagName)&&(v=v.filter(function(e){return"string"!=typeof e||!("object"==typeof e?"text"===e.type&&dH(e.value):dH(e))})),uN(r,g,m,s),uM(g,v),r.ancestors.pop(),r.schema=p,r.create(s,m,g,o)):"mdxFlowExpression"===i.type||"mdxTextExpression"===i.type?function(e,i){if(i.data&&i.data.estree&&e.evaluater){let n=i.data.estree.body[0];return dj("ExpressionStatement"===n.type),e.evaluater.evaluateExpression(n.expression)}uR(e,i.position)}(e,i):"mdxJsxFlowElement"===i.type||"mdxJsxTextElement"===i.type?(a=e,l=i,c=n,_=y=a.schema,"svg"===l.name&&"html"===y.space&&(a.schema=ud),a.ancestors.push(l),b=null===l.name?a.Fragment:uA(a,l.name,!0),w=function(e,i){let n={};for(let r of i.attributes)if("mdxJsxExpressionAttribute"===r.type)if(r.data&&r.data.estree&&e.evaluater){let i=r.data.estree.body[0];dj("ExpressionStatement"===i.type);let s=i.expression;dj("ObjectExpression"===s.type);let o=s.properties[0];dj("SpreadElement"===o.type),Object.assign(n,e.evaluater.evaluateExpression(o.argument))}else uR(e,i.position);else{let s,o=r.name;if(r.value&&"object"==typeof r.value)if(r.value.data&&r.value.data.estree&&e.evaluater){let i=r.value.data.estree.body[0];dj("ExpressionStatement"===i.type),s=e.evaluater.evaluateExpression(i.expression)}else uR(e,i.position);else s=null===r.value||r.value;n[o]=s}return n}(a,l),S=uO(a,l),uN(a,w,b,l),uM(w,S),a.ancestors.pop(),a.schema=y,a.create(l,b,w,c)):"mdxjsEsm"===i.type?function(e,i){if(i.data&&i.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(i.data.estree);uR(e,i.position)}(e,i):"root"===i.type?(h=e,d=i,u=n,uM(k={},uO(h,d)),h.create(d,h.Fragment,k,u)):"text"===i.type?i.value:void 0}function uN(e,i,n,r){"string"!=typeof n&&n!==e.Fragment&&e.passNode&&(i.node=r)}function uM(e,i){if(i.length>0){let n=i.length>1?i:i[0];n&&(e.children=n)}}function uO(e,i){let n=[],r=-1,s=e.passKeys?new Map:uw;for(;++r<i.children.length;){let o,a=i.children[r];if(e.passKeys){let e="element"===a.type?a.tagName:"mdxJsxFlowElement"===a.type||"mdxJsxTextElement"===a.type?a.name:void 0;if(e){let i=s.get(e)||0;o=e+"-"+i,s.set(e,i+1)}}let l=uE(e,a,o);void 0!==l&&n.push(l)}return n}function uA(e,i,n){let r;if(n)if(i.includes(".")){let e,n=i.split("."),s=-1;for(;++s<n.length;){let i=dF(n[s])?{type:"Identifier",name:n[s]}:{type:"Literal",value:n[s]};e=e?{type:"MemberExpression",object:e,property:i,computed:!!(s&&"Literal"===i.type),optional:!1}:i}dj(e,"always a result"),r=e}else r=dF(i)&&!/^[a-z]/.test(i)?{type:"Identifier",name:i}:{type:"Literal",value:i};else r={type:"Literal",value:i};if("Literal"===r.type){let i=r.value;return ux.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);uR(e)}function uR(e,i){let n=new ub("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:i,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=uT+"#cannot-handle-mdx-estrees-without-createevaluater",n}function uD(e){return"-"+e.toLowerCase()}let uL={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},uj={};function uI(e,i){let n=i||uj;return uP(e,"boolean"!=typeof n.includeImageAlt||n.includeImageAlt,"boolean"!=typeof n.includeHtml||n.includeHtml)}function uP(e,i,n){var r;if((r=e)&&"object"==typeof r){if("value"in e)return"html"!==e.type||n?e.value:"";if(i&&"alt"in e&&e.alt)return e.alt;if("children"in e)return uB(e.children,i,n)}return Array.isArray(e)?uB(e,i,n):""}function uB(e,i,n){let r=[],s=-1;for(;++s<e.length;)r[s]=uP(e[s],i,n);return r.join("")}function uz(e,i,n,r){let s,o=e.length,a=0;if(i=i<0?-i>o?0:o+i:i>o?o:i,n=n>0?n:0,r.length<1e4)(s=Array.from(r)).unshift(i,n),e.splice(...s);else for(n&&e.splice(i,n);a<r.length;)(s=r.slice(a,a+1e4)).unshift(i,0),e.splice(...s),a+=1e4,i+=1e4}function uF(e,i){return e.length>0?(uz(e,e.length,0,i),e):i}let uW={}.hasOwnProperty;function uH(e){let i={},n=-1;for(;++n<e.length;)!function(e,i){let n;for(n in i){let r,s=(uW.call(e,n)?e[n]:void 0)||(e[n]={}),o=i[n];if(o)for(r in o){uW.call(s,r)||(s[r]=[]);let e=o[r];!function(e,i){let n=-1,r=[];for(;++n<i.length;)("after"===i[n].add?e:r).push(i[n]);uz(e,0,0,r)}(s[r],Array.isArray(e)?e:e?[e]:[])}}}(i,e[n]);return i}let u$=u1(/[A-Za-z]/),uU=u1(/[\dA-Za-z]/),uV=u1(/[#-'*+\--9=?A-Z^-~]/);function uq(e){return null!==e&&(e<32||127===e)}let uY=u1(/\d/),uK=u1(/[\dA-Fa-f]/),uX=u1(/[!-/:-@[-`{-~]/);function uJ(e){return null!==e&&e<-2}function uG(e){return null!==e&&(e<0||32===e)}function uZ(e){return -2===e||-1===e||32===e}let uQ=u1(/\p{P}|\p{S}/u),u0=u1(/\s/);function u1(e){return function(i){return null!==i&&i>-1&&e.test(String.fromCharCode(i))}}function u2(e,i,n,r){let s=r?r-1:1/0,o=0;return function(r){return uZ(r)?(e.enter(n),function r(a){return uZ(a)&&o++<s?(e.consume(a),r):(e.exit(n),i(a))}(r)):i(r)}}let u5={tokenize:function(e){let i,n=e.attempt(this.parser.constructs.contentInitial,function(i){return null===i?void e.consume(i):(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),u2(e,n,"linePrefix"))},function(n){return e.enter("paragraph"),function n(r){let s=e.enter("chunkText",{contentType:"text",previous:i});return i&&(i.next=s),i=s,function i(r){if(null===r){e.exit("chunkText"),e.exit("paragraph"),e.consume(r);return}return uJ(r)?(e.consume(r),e.exit("chunkText"),n):(e.consume(r),i)}(r)}(n)});return n}},u3={tokenize:function(e){let i,n,r,s=this,o=[],a=0;return l;function l(i){if(a<o.length){let n=o[a];return s.containerState=n[1],e.attempt(n[0].continuation,c,h)(i)}return h(i)}function c(e){if(a++,s.containerState._closeFlow){let n;s.containerState._closeFlow=void 0,i&&y();let r=s.events.length,o=r;for(;o--;)if("exit"===s.events[o][0]&&"chunkFlow"===s.events[o][1].type){n=s.events[o][1].end;break}v(a);let l=r;for(;l<s.events.length;)s.events[l][1].end={...n},l++;return uz(s.events,o+1,0,s.events.slice(r)),s.events.length=l,h(e)}return l(e)}function h(n){if(a===o.length){if(!i)return p(n);if(i.currentConstruct&&i.currentConstruct.concrete)return m(n);s.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return s.containerState={},e.check(u4,d,u)(n)}function d(e){return i&&y(),v(a),p(e)}function u(e){return s.parser.lazy[s.now().line]=a!==o.length,r=s.now().offset,m(e)}function p(i){return s.containerState={},e.attempt(u4,f,m)(i)}function f(e){return a++,o.push([s.currentConstruct,s.containerState]),p(e)}function m(r){if(null===r){i&&y(),v(0),e.consume(r);return}return i=i||s.parser.flow(s.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:n}),function i(n){if(null===n){g(e.exit("chunkFlow"),!0),v(0),e.consume(n);return}return uJ(n)?(e.consume(n),g(e.exit("chunkFlow")),a=0,s.interrupt=void 0,l):(e.consume(n),i)}(r)}function g(e,o){let l=s.sliceStream(e);if(o&&l.push(null),e.previous=n,n&&(n.next=e),n=e,i.defineSkip(e.start),i.write(l),s.parser.lazy[e.start.line]){let e,n,o=i.events.length;for(;o--;)if(i.events[o][1].start.offset<r&&(!i.events[o][1].end||i.events[o][1].end.offset>r))return;let l=s.events.length,c=l;for(;c--;)if("exit"===s.events[c][0]&&"chunkFlow"===s.events[c][1].type){if(e){n=s.events[c][1].end;break}e=!0}for(v(a),o=l;o<s.events.length;)s.events[o][1].end={...n},o++;uz(s.events,c+1,0,s.events.slice(l)),s.events.length=o}}function v(i){let n=o.length;for(;n-- >i;){let i=o[n];s.containerState=i[1],i[0].exit.call(s,e)}o.length=i}function y(){i.write([null]),n=void 0,i=void 0,s.containerState._closeFlow=void 0}}},u4={tokenize:function(e,i,n){return u2(e,e.attempt(this.parser.constructs.document,i,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}},u6={partial:!0,tokenize:function(e,i,n){return function(i){return uZ(i)?u2(e,r,"linePrefix")(i):r(i)};function r(e){return null===e||uJ(e)?i(e):n(e)}}};class u8{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,i){let n=null==i?1/0:i;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,i,n){this.setCursor(Math.trunc(e));let r=this.right.splice(this.right.length-(i||0),1/0);return n&&u9(this.left,n),r.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),u9(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),u9(this.right,e.reverse())}setCursor(e){if(e!==this.left.length&&(!(e>this.left.length)||0!==this.right.length)&&(!(e<0)||0!==this.left.length))if(e<this.left.length){let i=this.left.splice(e,1/0);u9(this.right,i.reverse())}else{let i=this.right.splice(this.left.length+this.right.length-e,1/0);u9(this.left,i.reverse())}}}function u9(e,i){let n=0;if(i.length<1e4)e.push(...i);else for(;n<i.length;)e.push(...i.slice(n,n+1e4)),n+=1e4}function u7(e){let i,n,r,s,o,a,l,c={},h=-1,d=new u8(e);for(;++h<d.length;){for(;h in c;)h=c[h];if(i=d.get(h),h&&"chunkFlow"===i[1].type&&"listItemPrefix"===d.get(h-1)[1].type&&((r=0)<(a=i[1]._tokenizer.events).length&&"lineEndingBlank"===a[r][1].type&&(r+=2),r<a.length&&"content"===a[r][1].type))for(;++r<a.length&&"content"!==a[r][1].type;)"chunkText"===a[r][1].type&&(a[r][1]._isInFirstContentOfListItem=!0,r++);if("enter"===i[0])i[1].contentType&&(Object.assign(c,function(e,i){let n,r,s=e.get(i)[1],o=e.get(i)[2],a=i-1,l=[],c=s._tokenizer;!c&&(c=o.parser[s.contentType](s.start),s._contentTypeTextTrailing&&(c._contentTypeTextTrailing=!0));let h=c.events,d=[],u={},p=-1,f=s,m=0,g=0,v=[0];for(;f;){for(;e.get(++a)[1]!==f;);l.push(a),!f._tokenizer&&(n=o.sliceStream(f),f.next||n.push(null),r&&c.defineSkip(f.start),f._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=!0),c.write(n),f._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=void 0)),r=f,f=f.next}for(f=s;++p<h.length;)"exit"===h[p][0]&&"enter"===h[p-1][0]&&h[p][1].type===h[p-1][1].type&&h[p][1].start.line!==h[p][1].end.line&&(g=p+1,v.push(g),f._tokenizer=void 0,f.previous=void 0,f=f.next);for(c.events=[],f?(f._tokenizer=void 0,f.previous=void 0):v.pop(),p=v.length;p--;){let i=h.slice(v[p],v[p+1]),n=l.pop();d.push([n,n+i.length-1]),e.splice(n,2,i)}for(d.reverse(),p=-1;++p<d.length;)u[m+d[p][0]]=m+d[p][1],m+=d[p][1]-d[p][0]-1;return u}(d,h)),h=c[h],l=!0);else if(i[1]._container){for(r=h,n=void 0;r--;)if("lineEnding"===(s=d.get(r))[1].type||"lineEndingBlank"===s[1].type)"enter"===s[0]&&(n&&(d.get(n)[1].type="lineEndingBlank"),s[1].type="lineEnding",n=r);else if("linePrefix"===s[1].type||"listItemIndent"===s[1].type);else break;n&&(i[1].end={...d.get(n)[1].start},(o=d.slice(n,h)).unshift(i),d.splice(n,h-n+1,o))}}return uz(e,0,1/0,d.slice(0)),!l}let pe={resolve:function(e){return u7(e),e},tokenize:function(e,i){let n;return function(i){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),r(i)};function r(i){return null===i?s(i):uJ(i)?e.check(pt,o,s)(i):(e.consume(i),r)}function s(n){return e.exit("chunkContent"),e.exit("content"),i(n)}function o(i){return e.consume(i),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,r}}},pt={partial:!0,tokenize:function(e,i,n){let r=this;return function(i){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),u2(e,s,"linePrefix")};function s(s){if(null===s||uJ(s))return n(s);let o=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&o&&"linePrefix"===o[1].type&&o[2].sliceSerialize(o[1],!0).length>=4?i(s):e.interrupt(r.parser.constructs.flow,n,i)(s)}}},pi={tokenize:function(e){let i=this,n=e.attempt(u6,function(r){return null===r?void e.consume(r):(e.enter("lineEndingBlank"),e.consume(r),e.exit("lineEndingBlank"),i.currentConstruct=void 0,n)},e.attempt(this.parser.constructs.flowInitial,r,u2(e,e.attempt(this.parser.constructs.flow,r,e.attempt(pe,r)),"linePrefix")));return n;function r(r){return null===r?void e.consume(r):(e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),i.currentConstruct=void 0,n)}}},pn={resolveAll:pa()},pr=po("string"),ps=po("text");function po(e){return{resolveAll:pa("text"===e?pl:void 0),tokenize:function(i){let n=this,r=this.parser.constructs[e],s=i.attempt(r,o,a);return o;function o(e){return c(e)?s(e):a(e)}function a(e){return null===e?void i.consume(e):(i.enter("data"),i.consume(e),l)}function l(e){return c(e)?(i.exit("data"),s(e)):(i.consume(e),l)}function c(e){if(null===e)return!0;let i=r[e],s=-1;if(i)for(;++s<i.length;){let e=i[s];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}}function pa(e){return function(i,n){let r,s=-1;for(;++s<=i.length;)void 0===r?i[s]&&"data"===i[s][1].type&&(r=s,s++):i[s]&&"data"===i[s][1].type||(s!==r+2&&(i[r][1].end=i[s-1][1].end,i.splice(r+2,s-r-2),s=r+2),r=void 0);return e?e(i,n):i}}function pl(e,i){let n=0;for(;++n<=e.length;)if((n===e.length||"lineEnding"===e[n][1].type)&&"data"===e[n-1][1].type){let r,s=e[n-1][1],o=i.sliceStream(s),a=o.length,l=-1,c=0;for(;a--;){let e=o[a];if("string"==typeof e){for(l=e.length;32===e.charCodeAt(l-1);)c++,l--;if(l)break;l=-1}else if(-2===e)r=!0,c++;else if(-1===e);else{a++;break}}if(i._contentTypeTextTrailing&&n===e.length&&(c=0),c){let o={type:n===e.length||r||c<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:a?l:s.start._bufferIndex+l,_index:s.start._index+a,line:s.end.line,column:s.end.column-c,offset:s.end.offset-c},end:{...s.end}};s.end={...o.start},s.start.offset===s.end.offset?Object.assign(s,o):(e.splice(n,0,["enter",o,i],["exit",o,i]),n+=2)}n++}return e}function pc(e){return null===e||uG(e)||u0(e)?1:uQ(e)?2:void 0}function ph(e,i,n){let r=[],s=-1;for(;++s<e.length;){let o=e[s].resolveAll;o&&!r.includes(o)&&(i=o(i,n),r.push(o))}return i}let pd={name:"attention",resolveAll:function(e,i){let n,r,s,o,a,l,c,h,d=-1;for(;++d<e.length;)if("enter"===e[d][0]&&"attentionSequence"===e[d][1].type&&e[d][1]._close){for(n=d;n--;)if("exit"===e[n][0]&&"attentionSequence"===e[n][1].type&&e[n][1]._open&&i.sliceSerialize(e[n][1]).charCodeAt(0)===i.sliceSerialize(e[d][1]).charCodeAt(0)){if((e[n][1]._close||e[d][1]._open)&&(e[d][1].end.offset-e[d][1].start.offset)%3&&!((e[n][1].end.offset-e[n][1].start.offset+e[d][1].end.offset-e[d][1].start.offset)%3))continue;l=e[n][1].end.offset-e[n][1].start.offset>1&&e[d][1].end.offset-e[d][1].start.offset>1?2:1;let u={...e[n][1].end},p={...e[d][1].start};pu(u,-l),pu(p,l),o={type:l>1?"strongSequence":"emphasisSequence",start:u,end:{...e[n][1].end}},a={type:l>1?"strongSequence":"emphasisSequence",start:{...e[d][1].start},end:p},s={type:l>1?"strongText":"emphasisText",start:{...e[n][1].end},end:{...e[d][1].start}},r={type:l>1?"strong":"emphasis",start:{...o.start},end:{...a.end}},e[n][1].end={...o.start},e[d][1].start={...a.end},c=[],e[n][1].end.offset-e[n][1].start.offset&&(c=uF(c,[["enter",e[n][1],i],["exit",e[n][1],i]])),c=uF(c,[["enter",r,i],["enter",o,i],["exit",o,i],["enter",s,i]]),c=uF(c,ph(i.parser.constructs.insideSpan.null,e.slice(n+1,d),i)),c=uF(c,[["exit",s,i],["enter",a,i],["exit",a,i],["exit",r,i]]),e[d][1].end.offset-e[d][1].start.offset?(h=2,c=uF(c,[["enter",e[d][1],i],["exit",e[d][1],i]])):h=0,uz(e,n-1,d-n+3,c),d=n+c.length-h-2;break}}for(d=-1;++d<e.length;)"attentionSequence"===e[d][1].type&&(e[d][1].type="data");return e},tokenize:function(e,i){let n,r=this.parser.constructs.attentionMarkers.null,s=this.previous,o=pc(s);return function(a){return n=a,e.enter("attentionSequence"),function a(l){if(l===n)return e.consume(l),a;let c=e.exit("attentionSequence"),h=pc(l),d=!h||2===h&&o||r.includes(l),u=!o||2===o&&h||r.includes(s);return c._open=!!(42===n?d:d&&(o||!u)),c._close=!!(42===n?u:u&&(h||!d)),i(l)}(a)}}};function pu(e,i){e.column+=i,e.offset+=i,e._bufferIndex+=i}let pp={continuation:{tokenize:function(e,i,n){let r=this;return function(i){return uZ(i)?u2(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(i):s(i)};function s(r){return e.attempt(pp,i,n)(r)}}},exit:function(e){e.exit("blockQuote")},name:"blockQuote",tokenize:function(e,i,n){let r=this;return function(i){if(62===i){let n=r.containerState;return n.open||(e.enter("blockQuote",{_container:!0}),n.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(i),e.exit("blockQuoteMarker"),s}return n(i)};function s(n){return uZ(n)?(e.enter("blockQuotePrefixWhitespace"),e.consume(n),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),i):(e.exit("blockQuotePrefix"),i(n))}}},pf={name:"characterEscape",tokenize:function(e,i,n){return function(i){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(i),e.exit("escapeMarker"),r};function r(r){return uX(r)?(e.enter("characterEscapeValue"),e.consume(r),e.exit("characterEscapeValue"),e.exit("characterEscape"),i):n(r)}}},pm=document.createElement("i");function pg(e){let i="&"+e+";";pm.innerHTML=i;let n=pm.textContent;return(59!==n.charCodeAt(n.length-1)||"semi"===e)&&n!==i&&n}let pv={name:"characterReference",tokenize:function(e,i,n){let r,s,o=this,a=0;return function(i){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(i),e.exit("characterReferenceMarker"),l};function l(i){return 35===i?(e.enter("characterReferenceMarkerNumeric"),e.consume(i),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),r=31,s=uU,h(i))}function c(i){return 88===i||120===i?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(i),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),r=6,s=uK,h):(e.enter("characterReferenceValue"),r=7,s=uY,h(i))}function h(l){if(59===l&&a){let r=e.exit("characterReferenceValue");return s!==uU||pg(o.sliceSerialize(r))?(e.enter("characterReferenceMarker"),e.consume(l),e.exit("characterReferenceMarker"),e.exit("characterReference"),i):n(l)}return s(l)&&a++<r?(e.consume(l),h):n(l)}}},py={partial:!0,tokenize:function(e,i,n){let r=this;return function(i){return null===i?n(i):(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),s)};function s(e){return r.parser.lazy[r.now().line]?n(e):i(e)}}},p_={concrete:!0,name:"codeFenced",tokenize:function(e,i,n){let r,s=this,o={partial:!0,tokenize:function(e,i,n){let o=0;return function(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),a};function a(i){return e.enter("codeFencedFence"),uZ(i)?u2(e,c,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(i):c(i)}function c(i){return i===r?(e.enter("codeFencedFenceSequence"),function i(s){return s===r?(o++,e.consume(s),i):o>=l?(e.exit("codeFencedFenceSequence"),uZ(s)?u2(e,h,"whitespace")(s):h(s)):n(s)}(i)):n(i)}function h(r){return null===r||uJ(r)?(e.exit("codeFencedFence"),i(r)):n(r)}}},a=0,l=0;return function(i){var o;let h;return o=i,a=(h=s.events[s.events.length-1])&&"linePrefix"===h[1].type?h[2].sliceSerialize(h[1],!0).length:0,r=o,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),function i(s){return s===r?(l++,e.consume(s),i):l<3?n(s):(e.exit("codeFencedFenceSequence"),uZ(s)?u2(e,c,"whitespace")(s):c(s))}(o)};function c(o){return null===o||uJ(o)?(e.exit("codeFencedFence"),s.interrupt?i(o):e.check(py,d,m)(o)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),function i(s){return null===s||uJ(s)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),c(s)):uZ(s)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),u2(e,h,"whitespace")(s)):96===s&&s===r?n(s):(e.consume(s),i)}(o))}function h(i){return null===i||uJ(i)?c(i):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),function i(s){return null===s||uJ(s)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),c(s)):96===s&&s===r?n(s):(e.consume(s),i)}(i))}function d(i){return e.attempt(o,m,u)(i)}function u(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),p}function p(i){return a>0&&uZ(i)?u2(e,f,"linePrefix",a+1)(i):f(i)}function f(i){return null===i||uJ(i)?e.check(py,d,m)(i):(e.enter("codeFlowValue"),function i(n){return null===n||uJ(n)?(e.exit("codeFlowValue"),f(n)):(e.consume(n),i)}(i))}function m(n){return e.exit("codeFenced"),i(n)}}},pb={name:"codeIndented",tokenize:function(e,i,n){let r=this;return function(i){return e.enter("codeIndented"),u2(e,s,"linePrefix",5)(i)};function s(i){let s=r.events[r.events.length-1];return s&&"linePrefix"===s[1].type&&s[2].sliceSerialize(s[1],!0).length>=4?function i(n){return null===n?o(n):uJ(n)?e.attempt(px,i,o)(n):(e.enter("codeFlowValue"),function n(r){return null===r||uJ(r)?(e.exit("codeFlowValue"),i(r)):(e.consume(r),n)}(n))}(i):n(i)}function o(n){return e.exit("codeIndented"),i(n)}}},px={partial:!0,tokenize:function(e,i,n){let r=this;return s;function s(i){return r.parser.lazy[r.now().line]?n(i):uJ(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),s):u2(e,o,"linePrefix",5)(i)}function o(e){let o=r.events[r.events.length-1];return o&&"linePrefix"===o[1].type&&o[2].sliceSerialize(o[1],!0).length>=4?i(e):uJ(e)?s(e):n(e)}}};function pw(e,i,n,r,s,o,a,l,c){let h=c||1/0,d=0;return function(i){return 60===i?(e.enter(r),e.enter(s),e.enter(o),e.consume(i),e.exit(o),u):null===i||32===i||41===i||uq(i)?n(i):(e.enter(r),e.enter(a),e.enter(l),e.enter("chunkString",{contentType:"string"}),m(i))};function u(n){return 62===n?(e.enter(o),e.consume(n),e.exit(o),e.exit(s),e.exit(r),i):(e.enter(l),e.enter("chunkString",{contentType:"string"}),p(n))}function p(i){return 62===i?(e.exit("chunkString"),e.exit(l),u(i)):null===i||60===i||uJ(i)?n(i):(e.consume(i),92===i?f:p)}function f(i){return 60===i||62===i||92===i?(e.consume(i),p):p(i)}function m(s){return!d&&(null===s||41===s||uG(s))?(e.exit("chunkString"),e.exit(l),e.exit(a),e.exit(r),i(s)):d<h&&40===s?(e.consume(s),d++,m):41===s?(e.consume(s),d--,m):null===s||32===s||40===s||uq(s)?n(s):(e.consume(s),92===s?g:m)}function g(i){return 40===i||41===i||92===i?(e.consume(i),m):m(i)}}function pS(e,i,n,r,s,o){let a,l=this,c=0;return function(i){return e.enter(r),e.enter(s),e.consume(i),e.exit(s),e.enter(o),h};function h(u){return c>999||null===u||91===u||93===u&&!a||94===u&&!c&&"_hiddenFootnoteSupport"in l.parser.constructs?n(u):93===u?(e.exit(o),e.enter(s),e.consume(u),e.exit(s),e.exit(r),i):uJ(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),h):(e.enter("chunkString",{contentType:"string"}),d(u))}function d(i){return null===i||91===i||93===i||uJ(i)||c++>999?(e.exit("chunkString"),h(i)):(e.consume(i),a||(a=!uZ(i)),92===i?u:d)}function u(i){return 91===i||92===i||93===i?(e.consume(i),c++,d):d(i)}}function pk(e,i,n,r,s,o){let a;return function(i){return 34===i||39===i||40===i?(e.enter(r),e.enter(s),e.consume(i),e.exit(s),a=40===i?41:i,l):n(i)};function l(n){return n===a?(e.enter(s),e.consume(n),e.exit(s),e.exit(r),i):(e.enter(o),c(n))}function c(i){return i===a?(e.exit(o),l(a)):null===i?n(i):uJ(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),u2(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),h(i))}function h(i){return i===a||null===i||uJ(i)?(e.exit("chunkString"),c(i)):(e.consume(i),92===i?d:h)}function d(i){return i===a||92===i?(e.consume(i),h):h(i)}}function pC(e,i){let n;return function r(s){return uJ(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),n=!0,r):uZ(s)?u2(e,r,n?"linePrefix":"lineSuffix")(s):i(s)}}function pT(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}let pE={partial:!0,tokenize:function(e,i,n){return function(i){return uG(i)?pC(e,r)(i):n(i)};function r(i){return pk(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(i)}function s(i){return uZ(i)?u2(e,o,"whitespace")(i):o(i)}function o(e){return null===e||uJ(e)?i(e):n(e)}}},pN=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],pM=["pre","script","style","textarea"],pO={partial:!0,tokenize:function(e,i,n){return function(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),e.attempt(u6,i,n)}}},pA={partial:!0,tokenize:function(e,i,n){let r=this;return function(i){return uJ(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),s):n(i)};function s(e){return r.parser.lazy[r.now().line]?n(e):i(e)}}},pR={name:"labelEnd",resolveAll:function(e){let i=-1,n=[];for(;++i<e.length;){let r=e[i][1];if(n.push(e[i]),"labelImage"===r.type||"labelLink"===r.type||"labelEnd"===r.type){let e="labelImage"===r.type?4:2;r.type="data",i+=e}}return e.length!==n.length&&uz(e,0,e.length,n),e},resolveTo:function(e,i){let n,r,s,o,a=e.length,l=0;for(;a--;)if(n=e[a][1],r){if("link"===n.type||"labelLink"===n.type&&n._inactive)break;"enter"===e[a][0]&&"labelLink"===n.type&&(n._inactive=!0)}else if(s){if("enter"===e[a][0]&&("labelImage"===n.type||"labelLink"===n.type)&&!n._balanced&&(r=a,"labelLink"!==n.type)){l=2;break}}else"labelEnd"===n.type&&(s=a);let c={type:"labelLink"===e[r][1].type?"link":"image",start:{...e[r][1].start},end:{...e[e.length-1][1].end}},h={type:"label",start:{...e[r][1].start},end:{...e[s][1].end}},d={type:"labelText",start:{...e[r+l+2][1].end},end:{...e[s-2][1].start}};return o=uF(o=[["enter",c,i],["enter",h,i]],e.slice(r+1,r+l+3)),o=uF(o,[["enter",d,i]]),o=uF(o,ph(i.parser.constructs.insideSpan.null,e.slice(r+l+4,s-3),i)),o=uF(o,[["exit",d,i],e[s-2],e[s-1],["exit",h,i]]),o=uF(o,e.slice(s+1)),o=uF(o,[["exit",c,i]]),uz(e,r,e.length,o),e},tokenize:function(e,i,n){let r,s,o=this,a=o.events.length;for(;a--;)if(("labelImage"===o.events[a][1].type||"labelLink"===o.events[a][1].type)&&!o.events[a][1]._balanced){r=o.events[a][1];break}return function(i){return r?r._inactive?d(i):(s=o.parser.defined.includes(pT(o.sliceSerialize({start:r.end,end:o.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(i),e.exit("labelMarker"),e.exit("labelEnd"),l):n(i)};function l(i){return 40===i?e.attempt(pD,h,s?h:d)(i):91===i?e.attempt(pL,h,s?c:d)(i):s?h(i):d(i)}function c(i){return e.attempt(pj,h,d)(i)}function h(e){return i(e)}function d(e){return r._balanced=!0,n(e)}}},pD={tokenize:function(e,i,n){return function(i){return e.enter("resource"),e.enter("resourceMarker"),e.consume(i),e.exit("resourceMarker"),r};function r(i){return uG(i)?pC(e,s)(i):s(i)}function s(i){return 41===i?h(i):pw(e,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(i)}function o(i){return uG(i)?pC(e,l)(i):h(i)}function a(e){return n(e)}function l(i){return 34===i||39===i||40===i?pk(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(i):h(i)}function c(i){return uG(i)?pC(e,h)(i):h(i)}function h(r){return 41===r?(e.enter("resourceMarker"),e.consume(r),e.exit("resourceMarker"),e.exit("resource"),i):n(r)}}},pL={tokenize:function(e,i,n){let r=this;return function(i){return pS.call(r,e,s,o,"reference","referenceMarker","referenceString")(i)};function s(e){return r.parser.defined.includes(pT(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?i(e):n(e)}function o(e){return n(e)}}},pj={tokenize:function(e,i,n){return function(i){return e.enter("reference"),e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),r};function r(r){return 93===r?(e.enter("referenceMarker"),e.consume(r),e.exit("referenceMarker"),e.exit("reference"),i):n(r)}}},pI={name:"labelStartImage",resolveAll:pR.resolveAll,tokenize:function(e,i,n){let r=this;return function(i){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(i),e.exit("labelImageMarker"),s};function s(i){return 91===i?(e.enter("labelMarker"),e.consume(i),e.exit("labelMarker"),e.exit("labelImage"),o):n(i)}function o(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):i(e)}}},pP={name:"labelStartLink",resolveAll:pR.resolveAll,tokenize:function(e,i,n){let r=this;return function(i){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(i),e.exit("labelMarker"),e.exit("labelLink"),s};function s(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):i(e)}}},pB={name:"lineEnding",tokenize:function(e,i){return function(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),u2(e,i,"linePrefix")}}},pz={name:"thematicBreak",tokenize:function(e,i,n){let r,s=0;return function(o){var a;return e.enter("thematicBreak"),r=a=o,function o(a){return a===r?(e.enter("thematicBreakSequence"),function i(n){return n===r?(e.consume(n),s++,i):(e.exit("thematicBreakSequence"),uZ(n)?u2(e,o,"whitespace")(n):o(n))}(a)):s>=3&&(null===a||uJ(a))?(e.exit("thematicBreak"),i(a)):n(a)}(a)}}},pF={continuation:{tokenize:function(e,i,n){let r=this;return r.containerState._closeFlow=void 0,e.check(u6,function(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,u2(e,i,"listItemIndent",r.containerState.size+1)(n)},function(n){return r.containerState.furtherBlankLines||!uZ(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,s(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(pH,i,s)(n))});function s(s){return r.containerState._closeFlow=!0,r.interrupt=void 0,u2(e,e.attempt(pF,i,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s)}}},exit:function(e){e.exit(this.containerState.type)},name:"list",tokenize:function(e,i,n){let r=this,s=r.events[r.events.length-1],o=s&&"linePrefix"===s[1].type?s[2].sliceSerialize(s[1],!0).length:0,a=0;return function(i){let s=r.containerState.type||(42===i||43===i||45===i?"listUnordered":"listOrdered");if("listUnordered"===s?!r.containerState.marker||i===r.containerState.marker:uY(i)){if(r.containerState.type||(r.containerState.type=s,e.enter(s,{_container:!0})),"listUnordered"===s)return e.enter("listItemPrefix"),42===i||45===i?e.check(pz,n,l)(i):l(i);if(!r.interrupt||49===i)return e.enter("listItemPrefix"),e.enter("listItemValue"),function i(s){return uY(s)&&++a<10?(e.consume(s),i):(!r.interrupt||a<2)&&(r.containerState.marker?s===r.containerState.marker:41===s||46===s)?(e.exit("listItemValue"),l(s)):n(s)}(i)}return n(i)};function l(i){return e.enter("listItemMarker"),e.consume(i),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||i,e.check(u6,r.interrupt?n:c,e.attempt(pW,d,h))}function c(e){return r.containerState.initialBlankLine=!0,o++,d(e)}function h(i){return uZ(i)?(e.enter("listItemPrefixWhitespace"),e.consume(i),e.exit("listItemPrefixWhitespace"),d):n(i)}function d(n){return r.containerState.size=o+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,i(n)}}},pW={partial:!0,tokenize:function(e,i,n){let r=this;return u2(e,function(e){let s=r.events[r.events.length-1];return!uZ(e)&&s&&"listItemPrefixWhitespace"===s[1].type?i(e):n(e)},"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},pH={partial:!0,tokenize:function(e,i,n){let r=this;return u2(e,function(e){let s=r.events[r.events.length-1];return s&&"listItemIndent"===s[1].type&&s[2].sliceSerialize(s[1],!0).length===r.containerState.size?i(e):n(e)},"listItemIndent",r.containerState.size+1)}},p$={name:"setextUnderline",resolveTo:function(e,i){let n,r,s,o=e.length;for(;o--;)if("enter"===e[o][0]){if("content"===e[o][1].type){n=o;break}"paragraph"===e[o][1].type&&(r=o)}else"content"===e[o][1].type&&e.splice(o,1),s||"definition"!==e[o][1].type||(s=o);let a={type:"setextHeading",start:{...e[n][1].start},end:{...e[e.length-1][1].end}};return e[r][1].type="setextHeadingText",s?(e.splice(r,0,["enter",a,i]),e.splice(s+1,0,["exit",e[n][1],i]),e[n][1].end={...e[s][1].end}):e[n][1]=a,e.push(["exit",a,i]),e},tokenize:function(e,i,n){let r,s=this;return function(i){var a;let l,c=s.events.length;for(;c--;)if("lineEnding"!==s.events[c][1].type&&"linePrefix"!==s.events[c][1].type&&"content"!==s.events[c][1].type){l="paragraph"===s.events[c][1].type;break}return!s.parser.lazy[s.now().line]&&(s.interrupt||l)?(e.enter("setextHeadingLine"),r=i,a=i,e.enter("setextHeadingLineSequence"),function i(n){return n===r?(e.consume(n),i):(e.exit("setextHeadingLineSequence"),uZ(n)?u2(e,o,"lineSuffix")(n):o(n))}(a)):n(i)};function o(r){return null===r||uJ(r)?(e.exit("setextHeadingLine"),i(r)):n(r)}}};e.s(["attentionMarkers",0,{null:[42,95]},"contentInitial",0,{91:{name:"definition",tokenize:function(e,i,n){let r,s=this;return function(i){var r;return e.enter("definition"),r=i,pS.call(s,e,o,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(r)};function o(i){return(r=pT(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)),58===i)?(e.enter("definitionMarker"),e.consume(i),e.exit("definitionMarker"),a):n(i)}function a(i){return uG(i)?pC(e,l)(i):l(i)}function l(i){return pw(e,c,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(i)}function c(i){return e.attempt(pE,h,h)(i)}function h(i){return uZ(i)?u2(e,d,"whitespace")(i):d(i)}function d(o){return null===o||uJ(o)?(e.exit("definition"),s.parser.defined.push(r),i(o)):n(o)}}}},"disable",0,{null:[]},"document",0,{42:pF,43:pF,45:pF,48:pF,49:pF,50:pF,51:pF,52:pF,53:pF,54:pF,55:pF,56:pF,57:pF,62:pp},"flow",0,{35:{name:"headingAtx",resolve:function(e,i){let n,r,s=e.length-2,o=3;return"whitespace"===e[3][1].type&&(o+=2),s-2>o&&"whitespace"===e[s][1].type&&(s-=2),"atxHeadingSequence"===e[s][1].type&&(o===s-1||s-4>o&&"whitespace"===e[s-2][1].type)&&(s-=o+1===s?2:4),s>o&&(n={type:"atxHeadingText",start:e[o][1].start,end:e[s][1].end},r={type:"chunkText",start:e[o][1].start,end:e[s][1].end,contentType:"text"},uz(e,o,s-o+1,[["enter",n,i],["enter",r,i],["exit",r,i],["exit",n,i]])),e},tokenize:function(e,i,n){let r=0;return function(s){var o;return e.enter("atxHeading"),o=s,e.enter("atxHeadingSequence"),function s(o){return 35===o&&r++<6?(e.consume(o),s):null===o||uG(o)?(e.exit("atxHeadingSequence"),function n(r){return 35===r?(e.enter("atxHeadingSequence"),function i(r){return 35===r?(e.consume(r),i):(e.exit("atxHeadingSequence"),n(r))}(r)):null===r||uJ(r)?(e.exit("atxHeading"),i(r)):uZ(r)?u2(e,n,"whitespace")(r):(e.enter("atxHeadingText"),function i(r){return null===r||35===r||uG(r)?(e.exit("atxHeadingText"),n(r)):(e.consume(r),i)}(r))}(o)):n(o)}(o)}}},42:pz,45:[p$,pz],60:{concrete:!0,name:"htmlFlow",resolveTo:function(e){let i=e.length;for(;i--&&("enter"!==e[i][0]||"htmlFlow"!==e[i][1].type););return i>1&&"linePrefix"===e[i-2][1].type&&(e[i][1].start=e[i-2][1].start,e[i+1][1].start=e[i-2][1].start,e.splice(i-2,2)),e},tokenize:function(e,i,n){let r,s,o,a,l,c=this;return function(i){var n;return n=i,e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(n),h};function h(a){return 33===a?(e.consume(a),d):47===a?(e.consume(a),s=!0,f):63===a?(e.consume(a),r=3,c.interrupt?i:L):u$(a)?(e.consume(a),o=String.fromCharCode(a),m):n(a)}function d(s){return 45===s?(e.consume(s),r=2,u):91===s?(e.consume(s),r=5,a=0,p):u$(s)?(e.consume(s),r=4,c.interrupt?i:L):n(s)}function u(r){return 45===r?(e.consume(r),c.interrupt?i:L):n(r)}function p(r){let s="CDATA[";return r===s.charCodeAt(a++)?(e.consume(r),a===s.length)?c.interrupt?i:T:p:n(r)}function f(i){return u$(i)?(e.consume(i),o=String.fromCharCode(i),m):n(i)}function m(a){if(null===a||47===a||62===a||uG(a)){let l=47===a,h=o.toLowerCase();return!l&&!s&&pM.includes(h)?(r=1,c.interrupt?i(a):T(a)):pN.includes(o.toLowerCase())?(r=6,l)?(e.consume(a),g):c.interrupt?i(a):T(a):(r=7,c.interrupt&&!c.parser.lazy[c.now().line]?n(a):s?function i(n){return uZ(n)?(e.consume(n),i):k(n)}(a):v(a))}return 45===a||uU(a)?(e.consume(a),o+=String.fromCharCode(a),m):n(a)}function g(r){return 62===r?(e.consume(r),c.interrupt?i:T):n(r)}function v(i){return 47===i?(e.consume(i),k):58===i||95===i||u$(i)?(e.consume(i),y):uZ(i)?(e.consume(i),v):k(i)}function y(i){return 45===i||46===i||58===i||95===i||uU(i)?(e.consume(i),y):_(i)}function _(i){return 61===i?(e.consume(i),b):uZ(i)?(e.consume(i),_):v(i)}function b(i){return null===i||60===i||61===i||62===i||96===i?n(i):34===i||39===i?(e.consume(i),l=i,w):uZ(i)?(e.consume(i),b):function i(n){return null===n||34===n||39===n||47===n||60===n||61===n||62===n||96===n||uG(n)?_(n):(e.consume(n),i)}(i)}function w(i){return i===l?(e.consume(i),l=null,S):null===i||uJ(i)?n(i):(e.consume(i),w)}function S(e){return 47===e||62===e||uZ(e)?v(e):n(e)}function k(i){return 62===i?(e.consume(i),C):n(i)}function C(i){return null===i||uJ(i)?T(i):uZ(i)?(e.consume(i),C):n(i)}function T(i){return 45===i&&2===r?(e.consume(i),O):60===i&&1===r?(e.consume(i),A):62===i&&4===r?(e.consume(i),j):63===i&&3===r?(e.consume(i),L):93===i&&5===r?(e.consume(i),D):uJ(i)&&(6===r||7===r)?(e.exit("htmlFlowData"),e.check(pO,I,E)(i)):null===i||uJ(i)?(e.exit("htmlFlowData"),E(i)):(e.consume(i),T)}function E(i){return e.check(pA,N,I)(i)}function N(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),M}function M(i){return null===i||uJ(i)?E(i):(e.enter("htmlFlowData"),T(i))}function O(i){return 45===i?(e.consume(i),L):T(i)}function A(i){return 47===i?(e.consume(i),o="",R):T(i)}function R(i){if(62===i){let n=o.toLowerCase();return pM.includes(n)?(e.consume(i),j):T(i)}return u$(i)&&o.length<8?(e.consume(i),o+=String.fromCharCode(i),R):T(i)}function D(i){return 93===i?(e.consume(i),L):T(i)}function L(i){return 62===i?(e.consume(i),j):45===i&&2===r?(e.consume(i),L):T(i)}function j(i){return null===i||uJ(i)?(e.exit("htmlFlowData"),I(i)):(e.consume(i),j)}function I(n){return e.exit("htmlFlow"),i(n)}}},61:p$,95:pz,96:p_,126:p_},"flowInitial",0,{[-2]:pb,[-1]:pb,32:pb},"insideSpan",0,{null:[pd,pn]},"string",0,{38:pv,92:pf},"text",0,{[-5]:pB,[-4]:pB,[-3]:pB,33:pI,38:pv,42:pd,60:[{name:"autolink",tokenize:function(e,i,n){let r=0;return function(i){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(i),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s};function s(i){return u$(i)?(e.consume(i),o):64===i?n(i):l(i)}function o(i){return 43===i||45===i||46===i||uU(i)?(r=1,function i(n){return 58===n?(e.consume(n),r=0,a):(43===n||45===n||46===n||uU(n))&&r++<32?(e.consume(n),i):(r=0,l(n))}(i)):l(i)}function a(r){return 62===r?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(r),e.exit("autolinkMarker"),e.exit("autolink"),i):null===r||32===r||60===r||uq(r)?n(r):(e.consume(r),a)}function l(i){return 64===i?(e.consume(i),c):uV(i)?(e.consume(i),l):n(i)}function c(s){return uU(s)?function s(o){return 46===o?(e.consume(o),r=0,c):62===o?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(o),e.exit("autolinkMarker"),e.exit("autolink"),i):function i(o){if((45===o||uU(o))&&r++<63){let n=45===o?i:s;return e.consume(o),n}return n(o)}(o)}(s):n(s)}}},{name:"htmlText",tokenize:function(e,i,n){let r,s,o,a=this;return function(i){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(i),l};function l(i){return 33===i?(e.consume(i),c):47===i?(e.consume(i),w):63===i?(e.consume(i),_):u$(i)?(e.consume(i),k):n(i)}function c(i){return 45===i?(e.consume(i),h):91===i?(e.consume(i),s=0,f):u$(i)?(e.consume(i),y):n(i)}function h(i){return 45===i?(e.consume(i),p):n(i)}function d(i){return null===i?n(i):45===i?(e.consume(i),u):uJ(i)?(o=d,R(i)):(e.consume(i),d)}function u(i){return 45===i?(e.consume(i),p):d(i)}function p(e){return 62===e?A(e):45===e?u(e):d(e)}function f(i){let r="CDATA[";return i===r.charCodeAt(s++)?(e.consume(i),s===r.length?m:f):n(i)}function m(i){return null===i?n(i):93===i?(e.consume(i),g):uJ(i)?(o=m,R(i)):(e.consume(i),m)}function g(i){return 93===i?(e.consume(i),v):m(i)}function v(i){return 62===i?A(i):93===i?(e.consume(i),v):m(i)}function y(i){return null===i||62===i?A(i):uJ(i)?(o=y,R(i)):(e.consume(i),y)}function _(i){return null===i?n(i):63===i?(e.consume(i),b):uJ(i)?(o=_,R(i)):(e.consume(i),_)}function b(e){return 62===e?A(e):_(e)}function w(i){return u$(i)?(e.consume(i),S):n(i)}function S(i){return 45===i||uU(i)?(e.consume(i),S):function i(n){return uJ(n)?(o=i,R(n)):uZ(n)?(e.consume(n),i):A(n)}(i)}function k(i){return 45===i||uU(i)?(e.consume(i),k):47===i||62===i||uG(i)?C(i):n(i)}function C(i){return 47===i?(e.consume(i),A):58===i||95===i||u$(i)?(e.consume(i),T):uJ(i)?(o=C,R(i)):uZ(i)?(e.consume(i),C):A(i)}function T(i){return 45===i||46===i||58===i||95===i||uU(i)?(e.consume(i),T):function i(n){return 61===n?(e.consume(n),E):uJ(n)?(o=i,R(n)):uZ(n)?(e.consume(n),i):C(n)}(i)}function E(i){return null===i||60===i||61===i||62===i||96===i?n(i):34===i||39===i?(e.consume(i),r=i,N):uJ(i)?(o=E,R(i)):uZ(i)?(e.consume(i),E):(e.consume(i),M)}function N(i){return i===r?(e.consume(i),r=void 0,O):null===i?n(i):uJ(i)?(o=N,R(i)):(e.consume(i),N)}function M(i){return null===i||34===i||39===i||60===i||61===i||96===i?n(i):47===i||62===i||uG(i)?C(i):(e.consume(i),M)}function O(e){return 47===e||62===e||uG(e)?C(e):n(e)}function A(r){return 62===r?(e.consume(r),e.exit("htmlTextData"),e.exit("htmlText"),i):n(r)}function R(i){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),D}function D(i){return uZ(i)?u2(e,L,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(i):L(i)}function L(i){return e.enter("htmlTextData"),o(i)}}}],91:pP,92:[{name:"hardBreakEscape",tokenize:function(e,i,n){return function(i){return e.enter("hardBreakEscape"),e.consume(i),r};function r(r){return uJ(r)?(e.exit("hardBreakEscape"),i(r)):n(r)}}},pf],93:pR,95:pd,96:{name:"codeText",previous:function(e){return 96!==e||"characterEscape"===this.events[this.events.length-1][1].type},resolve:function(e){let i,n,r=e.length-4,s=3;if(("lineEnding"===e[3][1].type||"space"===e[s][1].type)&&("lineEnding"===e[r][1].type||"space"===e[r][1].type)){for(i=s;++i<r;)if("codeTextData"===e[i][1].type){e[s][1].type="codeTextPadding",e[r][1].type="codeTextPadding",s+=2,r-=2;break}}for(i=s-1,r++;++i<=r;)void 0===n?i!==r&&"lineEnding"!==e[i][1].type&&(n=i):(i===r||"lineEnding"===e[i][1].type)&&(e[n][1].type="codeTextData",i!==n+2&&(e[n][1].end=e[i-1][1].end,e.splice(n+2,i-n-2),r-=i-n-2,i=n+2),n=void 0);return e},tokenize:function(e,i,n){let r,s,o=0;return function(i){return e.enter("codeText"),e.enter("codeTextSequence"),function i(n){return 96===n?(e.consume(n),o++,i):(e.exit("codeTextSequence"),a(n))}(i)};function a(c){return null===c?n(c):32===c?(e.enter("space"),e.consume(c),e.exit("space"),a):96===c?(s=e.enter("codeTextSequence"),r=0,function n(a){return 96===a?(e.consume(a),r++,n):r===o?(e.exit("codeTextSequence"),e.exit("codeText"),i(a)):(s.type="codeTextData",l(a))}(c)):uJ(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),a):(e.enter("codeTextData"),l(c))}function l(i){return null===i||32===i||96===i||uJ(i)?(e.exit("codeTextData"),a(i)):(e.consume(i),l)}}}}],119210);var pU=e.i(119210);let pV=/[\0\t\n\r]/g;function pq(e,i){let n=Number.parseInt(e,i);return n<9||11===n||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(65535&n)==65535||(65535&n)==65534||n>1114111?"�":String.fromCodePoint(n)}let pY=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function pK(e,i,n){if(i)return i;if(35===n.charCodeAt(0)){let e=n.charCodeAt(1),i=120===e||88===e;return pq(n.slice(i?2:1),i?16:10)}return pg(n)||e}let pX={}.hasOwnProperty;function pJ(e){return{line:e.line,column:e.column,offset:e.offset}}function pG(e,i){if(e)throw Error("Cannot close `"+e.type+"` ("+ug({start:e.start,end:e.end})+"): a different token (`"+i.type+"`, "+ug({start:i.start,end:i.end})+") is open");throw Error("Cannot close document, a token (`"+i.type+"`, "+ug({start:i.start,end:i.end})+") is still open")}function pZ(e){let i=this;i.parser=function(n){var r,s;let o,a,l,c;return"object"==typeof(r={...i.data("settings"),...e,extensions:i.data("micromarkExtensions")||[],mdastExtensions:i.data("fromMarkdownExtensions")||[]})&&(s=r,r=void 0),(function(e){let i={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:r(y),autolinkProtocol:h,autolinkEmail:h,atxHeading:r(m),blockQuote:r(function(){return{type:"blockquote",children:[]}}),characterEscape:h,characterReference:h,codeFenced:r(f),codeFencedFenceInfo:s,codeFencedFenceMeta:s,codeIndented:r(f,s),codeText:r(function(){return{type:"inlineCode",value:""}},s),codeTextData:h,data:h,codeFlowValue:h,definition:r(function(){return{type:"definition",identifier:"",label:null,title:null,url:""}}),definitionDestinationString:s,definitionLabelString:s,definitionTitleString:s,emphasis:r(function(){return{type:"emphasis",children:[]}}),hardBreakEscape:r(g),hardBreakTrailing:r(g),htmlFlow:r(v,s),htmlFlowData:h,htmlText:r(v,s),htmlTextData:h,image:r(function(){return{type:"image",title:null,url:"",alt:null}}),label:s,link:r(y),listItem:r(function(e){return{type:"listItem",spread:e._spread,checked:null,children:[]}}),listItemValue:function(e){this.data.expectingFirstListItemValue&&(this.stack[this.stack.length-2].start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0)},listOrdered:r(_,function(){this.data.expectingFirstListItemValue=!0}),listUnordered:r(_),paragraph:r(function(){return{type:"paragraph",children:[]}}),reference:function(){this.data.referenceType="collapsed"},referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:r(m),strong:r(function(){return{type:"strong",children:[]}}),thematicBreak:r(function(){return{type:"thematicBreak"}})},exit:{atxHeading:a(),atxHeadingSequence:function(e){let i=this.stack[this.stack.length-1];i.depth||(i.depth=this.sliceSerialize(e).length)},autolink:a(),autolinkEmail:function(e){d.call(this,e),this.stack[this.stack.length-1].url="mailto:"+this.sliceSerialize(e)},autolinkProtocol:function(e){d.call(this,e),this.stack[this.stack.length-1].url=this.sliceSerialize(e)},blockQuote:a(),characterEscapeValue:d,characterReferenceMarkerHexadecimal:p,characterReferenceMarkerNumeric:p,characterReferenceValue:function(e){let i,n=this.sliceSerialize(e),r=this.data.characterReferenceType;r?(i=pq(n,"characterReferenceMarkerNumeric"===r?10:16),this.data.characterReferenceType=void 0):i=pg(n);let s=this.stack[this.stack.length-1];s.value+=i},characterReference:function(e){this.stack.pop().position.end=pJ(e.end)},codeFenced:a(function(){let e=this.resume();this.stack[this.stack.length-1].value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}),codeFencedFence:function(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)},codeFencedFenceInfo:function(){let e=this.resume();this.stack[this.stack.length-1].lang=e},codeFencedFenceMeta:function(){let e=this.resume();this.stack[this.stack.length-1].meta=e},codeFlowValue:d,codeIndented:a(function(){let e=this.resume();this.stack[this.stack.length-1].value=e.replace(/(\r?\n|\r)$/g,"")}),codeText:a(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),codeTextData:d,data:d,definition:a(),definitionDestinationString:function(){let e=this.resume();this.stack[this.stack.length-1].url=e},definitionLabelString:function(e){let i=this.resume(),n=this.stack[this.stack.length-1];n.label=i,n.identifier=pT(this.sliceSerialize(e)).toLowerCase()},definitionTitleString:function(){let e=this.resume();this.stack[this.stack.length-1].title=e},emphasis:a(),hardBreakEscape:a(u),hardBreakTrailing:a(u),htmlFlow:a(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),htmlFlowData:d,htmlText:a(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),htmlTextData:d,image:a(function(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let i=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=i,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}),label:function(){let e=this.stack[this.stack.length-1],i=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,"link"===n.type?n.children=e.children:n.alt=i},labelText:function(e){let i=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=i.replace(pY,pK),n.identifier=pT(i).toLowerCase()},lineEnding:function(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){n.children[n.children.length-1].position.end=pJ(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&i.canContainEols.includes(n.type)&&(h.call(this,e),d.call(this,e))},link:a(function(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let i=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=i,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}),listItem:a(),listOrdered:a(),listUnordered:a(),paragraph:a(),referenceString:function(e){let i=this.resume(),n=this.stack[this.stack.length-1];n.label=i,n.identifier=pT(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType="full"},resourceDestinationString:function(){let e=this.resume();this.stack[this.stack.length-1].url=e},resourceTitleString:function(){let e=this.resume();this.stack[this.stack.length-1].title=e},resource:function(){this.data.inReference=void 0},setextHeading:a(function(){this.data.setextHeadingSlurpLineEnding=void 0}),setextHeadingLineSequence:function(e){this.stack[this.stack.length-1].depth=61===this.sliceSerialize(e).codePointAt(0)?1:2},setextHeadingText:function(){this.data.setextHeadingSlurpLineEnding=!0},strong:a(),thematicBreak:a()}};!function e(i,n){let r=-1;for(;++r<n.length;){let s=n[r];Array.isArray(s)?e(i,s):function(e,i){let n;for(n in i)if(pX.call(i,n))switch(n){case"canContainEols":{let r=i[n];r&&e[n].push(...r);break}case"transforms":{let r=i[n];r&&e[n].push(...r);break}case"enter":case"exit":{let r=i[n];r&&Object.assign(e[n],r)}}}(i,s)}}(i,(e||{}).mdastExtensions||[]);let n={};return function(e){let r={type:"root",children:[]},a={stack:[r],tokenStack:[],config:i,enter:o,exit:l,buffer:s,resume:c,data:n},h=[],d=-1;for(;++d<e.length;)("listOrdered"===e[d][1].type||"listUnordered"===e[d][1].type)&&("enter"===e[d][0]?h.push(d):d=function(e,i,n){let r,s,o,a,l=i-1,c=-1,h=!1;for(;++l<=n;){let i=e[l];switch(i[1].type){case"listUnordered":case"listOrdered":case"blockQuote":"enter"===i[0]?c++:c--,a=void 0;break;case"lineEndingBlank":"enter"===i[0]&&(!r||a||c||o||(o=l),a=void 0);break;case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:a=void 0}if(!c&&"enter"===i[0]&&"listItemPrefix"===i[1].type||-1===c&&"exit"===i[0]&&("listUnordered"===i[1].type||"listOrdered"===i[1].type)){if(r){let a=l;for(s=void 0;a--;){let i=e[a];if("lineEnding"===i[1].type||"lineEndingBlank"===i[1].type){if("exit"===i[0])continue;s&&(e[s][1].type="lineEndingBlank",h=!0),i[1].type="lineEnding",s=a}else if("linePrefix"===i[1].type||"blockQuotePrefix"===i[1].type||"blockQuotePrefixWhitespace"===i[1].type||"blockQuoteMarker"===i[1].type||"listItemIndent"===i[1].type);else break}o&&(!s||o<s)&&(r._spread=!0),r.end=Object.assign({},s?e[s][1].start:i[1].end),e.splice(s||l,0,["exit",r,i[2]]),l++,n++}if("listItemPrefix"===i[1].type){let s={type:"listItem",_spread:!1,start:Object.assign({},i[1].start),end:void 0};r=s,e.splice(l,0,["enter",s,i[2]]),l++,n++,o=void 0,a=!0}}}return e[i][1]._spread=h,n}(e,h.pop(),d));for(d=-1;++d<e.length;){let n=i[e[d][0]];pX.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||pG).call(a,void 0,e[0])}for(r.position={start:pJ(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:pJ(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<i.transforms.length;)r=i.transforms[d](r)||r;return r};function r(e,i){return function(n){o.call(this,e(n),n),i&&i.call(this,n)}}function s(){this.stack.push({type:"fragment",children:[]})}function o(e,i,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([i,n||void 0]),e.position={start:pJ(i.start),end:void 0}}function a(e){return function(i){e&&e.call(this,i),l.call(this,i)}}function l(e,i){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(i?i.call(this,e,r[0]):(r[1]||pG).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+ug({start:e.start,end:e.end})+"): it’s not open");n.position.end=pJ(e.end)}function c(){return uI(this.stack.pop())}function h(e){let i=this.stack[this.stack.length-1].children,n=i[i.length-1];n&&"text"===n.type||((n={type:"text",value:""}).position={start:pJ(e.start),end:void 0},i.push(n)),this.stack.push(n)}function d(e){let i=this.stack.pop();i.value+=this.sliceSerialize(e),i.position.end=pJ(e.end)}function u(){this.data.atHardBreak=!0}function p(e){this.data.characterReferenceType=e.type}function f(){return{type:"code",lang:null,meta:null,value:""}}function m(){return{type:"heading",depth:0,children:[]}}function g(){return{type:"break"}}function v(){return{type:"html",value:""}}function y(){return{type:"link",title:null,url:"",children:[]}}function _(e){return{type:"list",ordered:"listOrdered"===e.type,start:null,spread:e._spread,children:[]}}})(s)(function(e){for(;!u7(e););return e}((function(e){let i={constructs:uH([pU,...(e||{}).extensions||[]]),content:n(u5),defined:[],document:n(u3),flow:n(pi),lazy:{},string:n(pr),text:n(ps)};return i;function n(e){return function(n){return function(e,i,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},s={},o=[],a=[],l=[],c={attempt:m(function(e,i){g(e,i.from)}),check:m(f),consume:function(e){uJ(e)?(r.line++,r.column=1,r.offset+=-3===e?2:1,v()):-1!==e&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),h.previous=e},enter:function(e,i){let n=i||{};return n.type=e,n.start=p(),h.events.push(["enter",n,h]),l.push(n),n},exit:function(e){let i=l.pop();return i.end=p(),h.events.push(["exit",i,h]),i},interrupt:m(f,{interrupt:!0})},h={code:null,containerState:{},defineSkip:function(e){s[e.line]=e.column,v()},events:[],now:p,parser:e,previous:null,sliceSerialize:function(e,i){return function(e,i){let n,r=-1,s=[];for(;++r<e.length;){let o,a=e[r];if("string"==typeof a)o=a;else switch(a){case -5:o="\r";break;case -4:o="\n";break;case -3:o="\r\n";break;case -2:o=i?" ":" ";break;case -1:if(!i&&n)continue;o=" ";break;default:o=String.fromCharCode(a)}n=-2===a,s.push(o)}return s.join("")}(u(e),i)},sliceStream:u,write:function(e){return(a=uF(a,e),function(){let e;for(;r._index<a.length;){let n=a[r._index];if("string"==typeof n)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<n.length;){var i;i=n.charCodeAt(r._bufferIndex),d=d(i)}else d=d(n)}}(),null!==a[a.length-1])?[]:(g(i,0),h.events=ph(o,h.events,h),h.events)}},d=i.tokenize.call(h,c);return i.resolveAll&&o.push(i),h;function u(e){return function(e,i){let n,r=i.start._index,s=i.start._bufferIndex,o=i.end._index,a=i.end._bufferIndex;if(r===o)n=[e[r].slice(s,a)];else{if(n=e.slice(r,o),s>-1){let e=n[0];"string"==typeof e?n[0]=e.slice(s):n.shift()}a>0&&n.push(e[o].slice(0,a))}return n}(a,e)}function p(){let{_bufferIndex:e,_index:i,line:n,column:s,offset:o}=r;return{_bufferIndex:e,_index:i,line:n,column:s,offset:o}}function f(e,i){i.restore()}function m(e,i){return function(n,s,o){var a;let d,u,f,m;return Array.isArray(n)?g(n):"tokenize"in n?g([n]):(a=n,function(e){let i=null!==e&&a[e],n=null!==e&&a.null;return g([...Array.isArray(i)?i:i?[i]:[],...Array.isArray(n)?n:n?[n]:[]])(e)});function g(e){return(d=e,u=0,0===e.length)?o:y(e[u])}function y(e){return function(n){let s,o,a,d,u;return(s=p(),o=h.previous,a=h.currentConstruct,d=h.events.length,u=Array.from(l),m={from:d,restore:function(){r=s,h.previous=o,h.currentConstruct=a,h.events.length=d,l=u,v()}},f=e,e.partial||(h.currentConstruct=e),e.name&&h.parser.constructs.disable.null.includes(e.name))?b(n):e.tokenize.call(i?Object.assign(Object.create(h),i):h,c,_,b)(n)}}function _(i){return e(f,m),s}function b(e){return(m.restore(),++u<d.length)?y(d[u]):o}}}function g(e,i){e.resolveAll&&!o.includes(e)&&o.push(e),e.resolve&&uz(h.events,i,h.events.length-i,e.resolve(h.events.slice(i),h)),e.resolveTo&&(h.events=e.resolveTo(h.events,h))}function v(){r.line in s&&r.column<2&&(r.column=s[r.line],r.offset+=s[r.line]-1)}}(i,e,n)}}})(s).document().write((a=1,l="",c=!0,function(e,i,n){let r,s,h,d,u,p=[];for(e=l+("string"==typeof e?e.toString():new TextDecoder(i||void 0).decode(e)),h=0,l="",c&&(65279===e.charCodeAt(0)&&h++,c=void 0);h<e.length;){if(pV.lastIndex=h,d=(r=pV.exec(e))&&void 0!==r.index?r.index:e.length,u=e.charCodeAt(d),!r){l=e.slice(h);break}if(10===u&&h===d&&o)p.push(-3),o=void 0;else switch(o&&(p.push(-5),o=void 0),h<d&&(p.push(e.slice(h,d)),a+=d-h),u){case 0:p.push(65533),a++;break;case 9:for(s=4*Math.ceil(a/4),p.push(-2);a++<s;)p.push(-1);break;case 10:p.push(-4),a=1;break;default:o=!0,a=1}h=d+1}return n&&(o&&p.push(-5),l&&p.push(l),p.push(null)),p})(n,r,!0))))}}let pQ="object"==typeof self?self:globalThis,p0=e=>{var i;let n,r;return(i=new Map,n=(e,n)=>(i.set(n,e),e),r=s=>{if(i.has(s))return i.get(s);let[o,a]=e[s];switch(o){case 0:case -1:return n(a,s);case 1:{let e=n([],s);for(let i of a)e.push(r(i));return e}case 2:{let e=n({},s);for(let[i,n]of a)e[r(i)]=r(n);return e}case 3:return n(new Date(a),s);case 4:{let{source:e,flags:i}=a;return n(new RegExp(e,i),s)}case 5:{let e=n(new Map,s);for(let[i,n]of a)e.set(r(i),r(n));return e}case 6:{let e=n(new Set,s);for(let i of a)e.add(r(i));return e}case 7:{let{name:e,message:i}=a;return n(new pQ[e](i),s)}case 8:return n(BigInt(a),s);case"BigInt":return n(Object(BigInt(a)),s);case"ArrayBuffer":return n(new Uint8Array(a).buffer,a);case"DataView":{let{buffer:e}=new Uint8Array(a);return n(new DataView(e),a)}}return n(new pQ[o](a),s)})(0)},{toString:p1}={},{keys:p2}=Object,p5=e=>{let i=typeof e;if("object"!==i||!e)return[0,i];let n=p1.call(e).slice(8,-1);switch(n){case"Array":return[1,""];case"Object":return[2,""];case"Date":return[3,""];case"RegExp":return[4,""];case"Map":return[5,""];case"Set":return[6,""];case"DataView":return[1,n]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},p3=([e,i])=>0===e&&("function"===i||"symbol"===i),p4=(e,{json:i,lossy:n}={})=>{var r,s,o;let a,l,c=[];return(r=!(i||n),s=!!i,o=new Map,a=(e,i)=>{let n=c.push(e)-1;return o.set(i,n),n},l=e=>{if(o.has(e))return o.get(e);let[i,n]=p5(e);switch(i){case 0:{let s=e;switch(n){case"bigint":i=8,s=e.toString();break;case"function":case"symbol":if(r)throw TypeError("unable to serialize "+n);s=null;break;case"undefined":return a([-1],e)}return a([i,s],e)}case 1:{if(n){let i=e;return"DataView"===n?i=new Uint8Array(e.buffer):"ArrayBuffer"===n&&(i=new Uint8Array(e)),a([n,[...i]],e)}let r=[],s=a([i,r],e);for(let i of e)r.push(l(i));return s}case 2:{if(n)switch(n){case"BigInt":return a([n,e.toString()],e);case"Boolean":case"Number":case"String":return a([n,e.valueOf()],e)}if(s&&"toJSON"in e)return l(e.toJSON());let o=[],c=a([i,o],e);for(let i of p2(e))(r||!p3(p5(e[i])))&&o.push([l(i),l(e[i])]);return c}case 3:return a([i,e.toISOString()],e);case 4:{let{source:n,flags:r}=e;return a([i,{source:n,flags:r}],e)}case 5:{let n=[],s=a([i,n],e);for(let[i,s]of e)(r||!(p3(p5(i))||p3(p5(s))))&&n.push([l(i),l(s)]);return s}case 6:{let n=[],s=a([i,n],e);for(let i of e)(r||!p3(p5(i)))&&n.push(l(i));return s}}let{message:c}=e;return a([i,{name:n,message:c}],e)})(e),c},p6="function"==typeof structuredClone?(e,i)=>i&&("json"in i||"lossy"in i)?p0(p4(e,i)):structuredClone(e):(e,i)=>p0(p4(e,i));function p8(e){let i=[],n=-1,r=0,s=0;for(;++n<e.length;){let o=e.charCodeAt(n),a="";if(37===o&&uU(e.charCodeAt(n+1))&&uU(e.charCodeAt(n+2)))s=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(a=String.fromCharCode(o));else if(o>55295&&o<57344){let i=e.charCodeAt(n+1);o<56320&&i>56319&&i<57344?(a=String.fromCharCode(o,i),s=1):a="�"}else a=String.fromCharCode(o);a&&(i.push(e.slice(r,n),encodeURIComponent(a)),r=n+s+1,a=""),s&&(n+=s,s=0)}return i.join("")+e.slice(r)}function p9(e,i){let n=[{type:"text",value:"↩"}];return i>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(i)}]}),n}function p7(e,i){return"Back to reference "+(e+1)+(i>1?"-"+i:"")}let fe=function(e){var i,n;if(null==e)return fi;if("function"==typeof e)return ft(e);if("object"==typeof e){return Array.isArray(e)?function(e){let i=[],n=-1;for(;++n<e.length;)i[n]=fe(e[n]);return ft(function(...e){let n=-1;for(;++n<i.length;)if(i[n].apply(this,e))return!0;return!1})}(e):(i=e,ft(function(e){let n;for(n in i)if(e[n]!==i[n])return!1;return!0}))}if("string"==typeof e){return n=e,ft(function(e){return e&&e.type===n})}throw Error("Expected function, string, or object as test")};function ft(e){return function(i,n,r){return!!(function(e){return null!==e&&"object"==typeof e&&"type"in e}(i)&&e.call(this,i,"number"==typeof n?n:void 0,r||void 0))}}function fi(){return!0}let fn=[];function fr(e,i,n,r){let s;"function"==typeof i&&"function"!=typeof n?(r=n,n=i):s=i;let o=fe(s),a=r?-1:1;(function e(s,l,c){let h=s&&"object"==typeof s?s:{};if("string"==typeof h.type){let e="string"==typeof h.tagName?h.tagName:"string"==typeof h.name?h.name:void 0;Object.defineProperty(d,"name",{value:"node ("+s.type+(e?"<"+e+">":"")+")"})}return d;function d(){var h;let d,u,p,f=fn;if((!i||o(s,l,c[c.length-1]||void 0))&&!1===(f=Array.isArray(h=n(s,c))?h:"number"==typeof h?[!0,h]:null==h?fn:[h])[0])return f;if("children"in s&&s.children&&s.children&&"skip"!==f[0])for(u=(r?s.children.length:-1)+a,p=c.concat(s);u>-1&&u<s.children.length;){if(!1===(d=e(s.children[u],u,p)())[0])return d;u="number"==typeof d[1]?d[1]:u+a}return f}})(e,void 0,[])()}function fs(e,i,n,r){let s,o,a;"function"==typeof i&&"function"!=typeof n?(o=void 0,a=i,s=n):(o=i,a=n,s=r),fr(e,o,function(e,i){let n=i[i.length-1],r=n?n.children.indexOf(e):void 0;return a(e,r,n)},s)}function fo(e,i){let n=i.referenceType,r="]";if("collapsed"===n?r+="[]":"full"===n&&(r+="["+(i.label||i.identifier)+"]"),"imageReference"===i.type)return[{type:"text",value:"!["+i.alt+r}];let s=e.all(i),o=s[0];o&&"text"===o.type?o.value="["+o.value:s.unshift({type:"text",value:"["});let a=s[s.length-1];return a&&"text"===a.type?a.value+=r:s.push({type:"text",value:r}),s}function fa(e){let i=e.spread;return null==i?e.children.length>1:i}function fl(e,i,n){let r=0,s=e.length;if(i){let i=e.codePointAt(r);for(;9===i||32===i;)r++,i=e.codePointAt(r)}if(n){let i=e.codePointAt(s-1);for(;9===i||32===i;)s--,i=e.codePointAt(s-1)}return s>r?e.slice(r,s):""}let fc={blockquote:function(e,i){let n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(i),!0)};return e.patch(i,n),e.applyData(i,n)},break:function(e,i){let n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(i,n),[e.applyData(i,n),{type:"text",value:"\n"}]},code:function(e,i){let n=i.value?i.value+"\n":"",r={},s=i.lang?i.lang.split(/\s+/):[];s.length>0&&(r.className=["language-"+s[0]]);let o={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return i.meta&&(o.data={meta:i.meta}),e.patch(i,o),o={type:"element",tagName:"pre",properties:{},children:[o=e.applyData(i,o)]},e.patch(i,o),o},delete:function(e,i){let n={type:"element",tagName:"del",properties:{},children:e.all(i)};return e.patch(i,n),e.applyData(i,n)},emphasis:function(e,i){let n={type:"element",tagName:"em",properties:{},children:e.all(i)};return e.patch(i,n),e.applyData(i,n)},footnoteReference:function(e,i){let n,r="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",s=String(i.identifier).toUpperCase(),o=p8(s.toLowerCase()),a=e.footnoteOrder.indexOf(s),l=e.footnoteCounts.get(s);void 0===l?(l=0,e.footnoteOrder.push(s),n=e.footnoteOrder.length):n=a+1,l+=1,e.footnoteCounts.set(s,l);let c={type:"element",tagName:"a",properties:{href:"#"+r+"fn-"+o,id:r+"fnref-"+o+(l>1?"-"+l:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(n)}]};e.patch(i,c);let h={type:"element",tagName:"sup",properties:{},children:[c]};return e.patch(i,h),e.applyData(i,h)},heading:function(e,i){let n={type:"element",tagName:"h"+i.depth,properties:{},children:e.all(i)};return e.patch(i,n),e.applyData(i,n)},html:function(e,i){if(e.options.allowDangerousHtml){let n={type:"raw",value:i.value};return e.patch(i,n),e.applyData(i,n)}},imageReference:function(e,i){let n=String(i.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return fo(e,i);let s={src:p8(r.url||""),alt:i.alt};null!==r.title&&void 0!==r.title&&(s.title=r.title);let o={type:"element",tagName:"img",properties:s,children:[]};return e.patch(i,o),e.applyData(i,o)},image:function(e,i){let n={src:p8(i.url)};null!==i.alt&&void 0!==i.alt&&(n.alt=i.alt),null!==i.title&&void 0!==i.title&&(n.title=i.title);let r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(i,r),e.applyData(i,r)},inlineCode:function(e,i){let n={type:"text",value:i.value.replace(/\r?\n|\r/g," ")};e.patch(i,n);let r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(i,r),e.applyData(i,r)},linkReference:function(e,i){let n=String(i.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return fo(e,i);let s={href:p8(r.url||"")};null!==r.title&&void 0!==r.title&&(s.title=r.title);let o={type:"element",tagName:"a",properties:s,children:e.all(i)};return e.patch(i,o),e.applyData(i,o)},link:function(e,i){let n={href:p8(i.url)};null!==i.title&&void 0!==i.title&&(n.title=i.title);let r={type:"element",tagName:"a",properties:n,children:e.all(i)};return e.patch(i,r),e.applyData(i,r)},listItem:function(e,i,n){let r=e.all(i),s=n?function(e){let i=!1;if("list"===e.type){i=e.spread||!1;let n=e.children,r=-1;for(;!i&&++r<n.length;)i=fa(n[r])}return i}(n):fa(i),o={},a=[];if("boolean"==typeof i.checked){let e,n=r[0];n&&"element"===n.type&&"p"===n.tagName?e=n:(e={type:"element",tagName:"p",properties:{},children:[]},r.unshift(e)),e.children.length>0&&e.children.unshift({type:"text",value:" "}),e.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:i.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let l=-1;for(;++l<r.length;){let e=r[l];(s||0!==l||"element"!==e.type||"p"!==e.tagName)&&a.push({type:"text",value:"\n"}),"element"!==e.type||"p"!==e.tagName||s?a.push(e):a.push(...e.children)}let c=r[r.length-1];c&&(s||"element"!==c.type||"p"!==c.tagName)&&a.push({type:"text",value:"\n"});let h={type:"element",tagName:"li",properties:o,children:a};return e.patch(i,h),e.applyData(i,h)},list:function(e,i){let n={},r=e.all(i),s=-1;for("number"==typeof i.start&&1!==i.start&&(n.start=i.start);++s<r.length;){let e=r[s];if("element"===e.type&&"li"===e.tagName&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}let o={type:"element",tagName:i.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(i,o),e.applyData(i,o)},paragraph:function(e,i){let n={type:"element",tagName:"p",properties:{},children:e.all(i)};return e.patch(i,n),e.applyData(i,n)},root:function(e,i){let n={type:"root",children:e.wrap(e.all(i))};return e.patch(i,n),e.applyData(i,n)},strong:function(e,i){let n={type:"element",tagName:"strong",properties:{},children:e.all(i)};return e.patch(i,n),e.applyData(i,n)},table:function(e,i){let n=e.all(i),r=n.shift(),s=[];if(r){let n={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(i.children[0],n),s.push(n)}if(n.length>0){let r={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},o=uf(i.children[1]),a=up(i.children[i.children.length-1]);o&&a&&(r.position={start:o,end:a}),s.push(r)}let o={type:"element",tagName:"table",properties:{},children:e.wrap(s,!0)};return e.patch(i,o),e.applyData(i,o)},tableCell:function(e,i){let n={type:"element",tagName:"td",properties:{},children:e.all(i)};return e.patch(i,n),e.applyData(i,n)},tableRow:function(e,i,n){let r=n?n.children:void 0,s=0===(r?r.indexOf(i):1)?"th":"td",o=n&&"table"===n.type?n.align:void 0,a=o?o.length:i.children.length,l=-1,c=[];for(;++l<a;){let n=i.children[l],r={},a=o?o[l]:void 0;a&&(r.align=a);let h={type:"element",tagName:s,properties:r,children:[]};n&&(h.children=e.all(n),e.patch(n,h),h=e.applyData(n,h)),c.push(h)}let h={type:"element",tagName:"tr",properties:{},children:e.wrap(c,!0)};return e.patch(i,h),e.applyData(i,h)},text:function(e,i){let n={type:"text",value:function(e){let i=String(e),n=/\r?\n|\r/g,r=n.exec(i),s=0,o=[];for(;r;)o.push(fl(i.slice(s,r.index),s>0,!0),r[0]),s=r.index+r[0].length,r=n.exec(i);return o.push(fl(i.slice(s),s>0,!1)),o.join("")}(String(i.value))};return e.patch(i,n),e.applyData(i,n)},thematicBreak:function(e,i){let n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(i,n),e.applyData(i,n)},toml:fh,yaml:fh,definition:fh,footnoteDefinition:fh};function fh(){}let fd={}.hasOwnProperty,fu={};function fp(e,i){e.position&&(i.position=function(e){let i=uf(e),n=up(e);if(i&&n)return{start:i,end:n}}(e))}function ff(e,i){let n=i;if(e&&e.data){let i=e.data.hName,r=e.data.hChildren,s=e.data.hProperties;"string"==typeof i&&("element"===n.type?n.tagName=i:n={type:"element",tagName:i,properties:{},children:"children"in n?n.children:[n]}),"element"===n.type&&s&&Object.assign(n.properties,p6(s)),"children"in n&&n.children&&null!=r&&(n.children=r)}return n}function fm(e,i){let n=[],r=-1;for(i&&n.push({type:"text",value:"\n"});++r<e.length;)r&&n.push({type:"text",value:"\n"}),n.push(e[r]);return i&&e.length>0&&n.push({type:"text",value:"\n"}),n}function fg(e){let i=0,n=e.charCodeAt(i);for(;9===n||32===n;)i++,n=e.charCodeAt(i);return e.slice(i)}function fv(e,i){let n,r,s,o,a=(n=i||fu,r=new Map,s=new Map,o={all:function(e){let i=[];if("children"in e){let n=e.children,r=-1;for(;++r<n.length;){let s=o.one(n[r],e);if(s){if(r&&"break"===n[r-1].type&&(Array.isArray(s)||"text"!==s.type||(s.value=fg(s.value)),!Array.isArray(s)&&"element"===s.type)){let e=s.children[0];e&&"text"===e.type&&(e.value=fg(e.value))}Array.isArray(s)?i.push(...s):i.push(s)}}}return i},applyData:ff,definitionById:r,footnoteById:s,footnoteCounts:new Map,footnoteOrder:[],handlers:{...fc,...n.handlers},one:function(e,i){let n=e.type,r=o.handlers[n];if(fd.call(o.handlers,n)&&r)return r(o,e,i);if(o.options.passThrough&&o.options.passThrough.includes(n)){if("children"in e){let{children:i,...n}=e,r=p6(n);return r.children=o.all(e),r}return p6(e)}return(o.options.unknownHandler||function(e,i){let n=i.data||{},r="value"in i&&!(fd.call(n,"hProperties")||fd.call(n,"hChildren"))?{type:"text",value:i.value}:{type:"element",tagName:"div",properties:{},children:e.all(i)};return e.patch(i,r),e.applyData(i,r)})(o,e,i)},options:n,patch:fp,wrap:fm},fs(e,function(e){if("definition"===e.type||"footnoteDefinition"===e.type){let i="definition"===e.type?r:s,n=String(e.identifier).toUpperCase();i.has(n)||i.set(n,e)}}),o),l=a.one(e,void 0),c=function(e){let i="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||p9,r=e.options.footnoteBackLabel||p7,s=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},l=[],c=-1;for(;++c<e.footnoteOrder.length;){let s=e.footnoteById.get(e.footnoteOrder[c]);if(!s)continue;let o=e.all(s),a=String(s.identifier).toUpperCase(),h=p8(a.toLowerCase()),d=0,u=[],p=e.footnoteCounts.get(a);for(;void 0!==p&&++d<=p;){u.length>0&&u.push({type:"text",value:" "});let e="string"==typeof n?n:n(c,d);"string"==typeof e&&(e={type:"text",value:e}),u.push({type:"element",tagName:"a",properties:{href:"#"+i+"fnref-"+h+(d>1?"-"+d:""),dataFootnoteBackref:"",ariaLabel:"string"==typeof r?r:r(c,d),className:["data-footnote-backref"]},children:Array.isArray(e)?e:[e]})}let f=o[o.length-1];if(f&&"element"===f.type&&"p"===f.tagName){let e=f.children[f.children.length-1];e&&"text"===e.type?e.value+=" ":f.children.push({type:"text",value:" "}),f.children.push(...u)}else o.push(...u);let m={type:"element",tagName:"li",properties:{id:i+"fn-"+h},children:e.wrap(o,!0)};e.patch(s,m),l.push(m)}if(0!==l.length)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...p6(a),id:"footnote-label"},children:[{type:"text",value:s}]},{type:"text",value:"\n"},{type:"element",tagName:"ol",properties:{},children:e.wrap(l,!0)},{type:"text",value:"\n"}]}}(a),h=Array.isArray(l)?{type:"root",children:l}:l||{type:"root",children:[]};return c&&(dj("children"in h),h.children.push({type:"text",value:"\n"},c)),h}function fy(e,i){return e&&"run"in e?async function(n,r){let s=fv(n,{file:r,...i});await e.run(s,r)}:function(n,r){return fv(n,{file:r,...e||i})}}function f_(e){if(e)throw e}var fb=e.i(975609);function fx(e){if("object"!=typeof e||null===e)return!1;let i=Object.getPrototypeOf(e);return(null===i||i===Object.prototype||null===Object.getPrototypeOf(i))&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}let fw=function(e,i){let n;if(void 0!==i&&"string"!=typeof i)throw TypeError('"ext" argument must be a string');fT(e);let r=0,s=-1,o=e.length;if(void 0===i||0===i.length||i.length>e.length){for(;o--;)if(47===e.codePointAt(o)){if(n){r=o+1;break}}else s<0&&(n=!0,s=o+1);return s<0?"":e.slice(r,s)}if(i===e)return"";let a=-1,l=i.length-1;for(;o--;)if(47===e.codePointAt(o)){if(n){r=o+1;break}}else a<0&&(n=!0,a=o+1),l>-1&&(e.codePointAt(o)===i.codePointAt(l--)?l<0&&(s=o):(l=-1,s=a));return r===s?s=a:s<0&&(s=e.length),e.slice(r,s)},fS=function(e){let i;if(fT(e),0===e.length)return".";let n=-1,r=e.length;for(;--r;)if(47===e.codePointAt(r)){if(i){n=r;break}}else i||(i=!0);return n<0?47===e.codePointAt(0)?"/":".":1===n&&47===e.codePointAt(0)?"//":e.slice(0,n)},fk=function(e){let i;fT(e);let n=e.length,r=-1,s=0,o=-1,a=0;for(;n--;){let l=e.codePointAt(n);if(47===l){if(i){s=n+1;break}continue}r<0&&(i=!0,r=n+1),46===l?o<0?o=n:1!==a&&(a=1):o>-1&&(a=-1)}return o<0||r<0||0===a||1===a&&o===r-1&&o===s+1?"":e.slice(o,r)},fC=function(...e){var i;let n,r,s,o=-1;for(;++o<e.length;)fT(e[o]),e[o]&&(s=void 0===s?e[o]:s+"/"+e[o]);return void 0===s?".":(fT(i=s),n=47===i.codePointAt(0),0!==(r=function(e,i){let n,r,s="",o=0,a=-1,l=0,c=-1;for(;++c<=e.length;){if(c<e.length)n=e.codePointAt(c);else if(47===n)break;else n=47;if(47===n){if(a===c-1||1===l);else if(a!==c-1&&2===l){if(s.length<2||2!==o||46!==s.codePointAt(s.length-1)||46!==s.codePointAt(s.length-2)){if(s.length>2){if((r=s.lastIndexOf("/"))!==s.length-1){r<0?(s="",o=0):o=(s=s.slice(0,r)).length-1-s.lastIndexOf("/"),a=c,l=0;continue}}else if(s.length>0){s="",o=0,a=c,l=0;continue}}i&&(s=s.length>0?s+"/..":"..",o=2)}else s.length>0?s+="/"+e.slice(a+1,c):s=e.slice(a+1,c),o=c-a-1;a=c,l=0}else 46===n&&l>-1?l++:l=-1}return s}(i,!n)).length||n||(r="."),r.length>0&&47===i.codePointAt(i.length-1)&&(r+="/"),n?"/"+r:r)};function fT(e){if("string"!=typeof e)throw TypeError("Path must be a string. Received "+JSON.stringify(e))}function fE(e){return!!(null!==e&&"object"==typeof e&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&void 0===e.auth)}let fN=["history","path","basename","stem","extname","dirname"];class fM{constructor(e){let i,n;i=e?fE(e)?{path:e}:"string"==typeof e||function(e){return!!(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}(e)?{value:e}:e:{},this.cwd="cwd"in i?"":"/",this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<fN.length;){const e=fN[r];e in i&&void 0!==i[e]&&null!==i[e]&&(this[e]="history"===e?[...i[e]]:i[e])}for(n in i)fN.includes(n)||(this[n]=i[n])}get basename(){return"string"==typeof this.path?fw(this.path):void 0}set basename(e){fA(e,"basename"),fO(e,"basename"),this.path=fC(this.dirname||"",e)}get dirname(){return"string"==typeof this.path?fS(this.path):void 0}set dirname(e){fR(this.basename,"dirname"),this.path=fC(e||"",this.basename)}get extname(){return"string"==typeof this.path?fk(this.path):void 0}set extname(e){if(fO(e,"extname"),fR(this.dirname,"extname"),e){if(46!==e.codePointAt(0))throw Error("`extname` must start with `.`");if(e.includes(".",1))throw Error("`extname` cannot contain multiple dots")}this.path=fC(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){fE(e)&&(e=function(e){if("string"==typeof e)e=new URL(e);else if(!fE(e)){let i=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw i.code="ERR_INVALID_ARG_TYPE",i}if("file:"!==e.protocol){let e=TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return function(e){if(""!==e.hostname){let e=TypeError('File URL host must be "localhost" or empty on darwin');throw e.code="ERR_INVALID_FILE_URL_HOST",e}let i=e.pathname,n=-1;for(;++n<i.length;)if(37===i.codePointAt(n)&&50===i.codePointAt(n+1)){let e=i.codePointAt(n+2);if(70===e||102===e){let e=TypeError("File URL path must not include encoded / characters");throw e.code="ERR_INVALID_FILE_URL_PATH",e}}return decodeURIComponent(i)}(e)}(e)),fA(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return"string"==typeof this.path?fw(this.path,this.extname):void 0}set stem(e){fA(e,"stem"),fO(e,"stem"),this.path=fC(this.dirname||"",e+(this.extname||""))}fail(e,i,n){let r=this.message(e,i,n);throw r.fatal=!0,r}info(e,i,n){let r=this.message(e,i,n);return r.fatal=void 0,r}message(e,i,n){let r=new ub(e,i,n);return this.path&&(r.name=this.path+":"+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return void 0===this.value?"":"string"==typeof this.value?this.value:new TextDecoder(e||void 0).decode(this.value)}}function fO(e,i){if(e&&e.includes("/"))throw Error("`"+i+"` cannot be a path: did not expect `/`")}function fA(e,i){if(!e)throw Error("`"+i+"` cannot be empty")}function fR(e,i){if(!e)throw Error("Setting `"+i+"` requires `path` to be set too")}let fD=function(e){let i=this.constructor.prototype,n=i[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,i),r},fL={}.hasOwnProperty;class fj extends fD{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=function(){let e=[],i={run:function(...i){let n=-1,r=i.pop();if("function"!=typeof r)throw TypeError("Expected function as last argument, not "+r);!function s(o,...a){let l=e[++n],c=-1;if(o)return void r(o);for(;++c<i.length;)(null===a[c]||void 0===a[c])&&(a[c]=i[c]);i=a,l?(function(e,i){let n;return function(...i){let o,a=e.length>i.length;a&&i.push(r);try{o=e.apply(this,i)}catch(e){if(a&&n)throw e;return r(e)}a||(o&&o.then&&"function"==typeof o.then?o.then(s,r):o instanceof Error?r(o):s(o))};function r(e,...s){n||(n=!0,i(e,...s))}function s(e){r(null,e)}})(l,s)(...a):r(null,...a)}(null,...i)},use:function(n){if("function"!=typeof n)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),i}};return i}()}copy(){let e=new fj,i=-1;for(;++i<this.attachers.length;){let n=this.attachers[i];e.use(...n)}return e.data((0,fb.default)(!0,{},this.namespace)),e}data(e,i){return"string"==typeof e?2==arguments.length?(fz("data",this.frozen),this.namespace[e]=i,this):fL.call(this.namespace,e)&&this.namespace[e]||void 0:e?(fz("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;for(;++this.freezeIndex<this.attachers.length;){let[e,...i]=this.attachers[this.freezeIndex];if(!1===i[0])continue;!0===i[0]&&(i[0]=void 0);let n=e.call(this,...i);"function"==typeof n&&this.transformers.use(n)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let i=fH(e),n=this.parser||this.Parser;return fP("parse",n),n(String(i),i)}process(e,i){let n=this;return this.freeze(),fP("process",this.parser||this.Parser),fB("process",this.compiler||this.Compiler),i?r(void 0,i):new Promise(r);function r(r,s){let o=fH(e),a=n.parse(o);function l(e,n){e||!n?s(e):r?r(n):(dj(i,"`done` is defined if `resolve` is not"),i(void 0,n))}n.run(a,o,function(e,i,r){var s,o;if(e||!i||!r)return l(e);let a=n.stringify(i,r);"string"==typeof(s=a)||(o=s)&&"object"==typeof o&&"byteLength"in o&&"byteOffset"in o?r.value=a:r.result=a,l(e,r)})}}processSync(e){let i,n=!1;return this.freeze(),fP("processSync",this.parser||this.Parser),fB("processSync",this.compiler||this.Compiler),this.process(e,function(e,r){n=!0,f_(e),i=r}),fW("processSync","process",n),dj(i,"we either bailed on an error or have a tree"),i}run(e,i,n){fF(e),this.freeze();let r=this.transformers;return n||"function"!=typeof i||(n=i,i=void 0),n?s(void 0,n):new Promise(s);function s(s,o){dj("function"!=typeof i,"`file` can’t be a `done` anymore, we checked");let a=fH(i);r.run(e,a,function(i,r,a){let l=r||e;i?o(i):s?s(l):(dj(n,"`done` is defined if `resolve` is not"),n(void 0,l,a))})}}runSync(e,i){let n,r=!1;return this.run(e,i,function(e,i){f_(e),n=i,r=!0}),fW("runSync","run",r),dj(n,"we either bailed on an error or have a tree"),n}stringify(e,i){this.freeze();let n=fH(i),r=this.compiler||this.Compiler;return fB("stringify",r),fF(e),r(e,n)}use(e,...i){let n=this.attachers,r=this.namespace;if(fz("use",this.frozen),null==e);else if("function"==typeof e)a(e,i);else if("object"==typeof e)Array.isArray(e)?o(e):s(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function s(e){if(!("plugins"in e)&&!("settings"in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,fb.default)(!0,r.settings,e.settings))}function o(e){let i=-1;if(null==e);else if(Array.isArray(e))for(;++i<e.length;)!function(e){if("function"==typeof e)a(e,[]);else if("object"==typeof e)if(Array.isArray(e)){let[i,...n]=e;a(i,n)}else s(e);else throw TypeError("Expected usable value, not `"+e+"`")}(e[i]);else throw TypeError("Expected a list of plugins, not `"+e+"`")}function a(e,i){let r=-1,s=-1;for(;++r<n.length;)if(n[r][0]===e){s=r;break}if(-1===s)n.push([e,...i]);else if(i.length>0){let[r,...o]=i,a=n[s][1];fx(a)&&fx(r)&&(r=(0,fb.default)(!0,a,r)),n[s]=[e,r,...o]}}}}let fI=new fj().freeze();function fP(e,i){if("function"!=typeof i)throw TypeError("Cannot `"+e+"` without `parser`")}function fB(e,i){if("function"!=typeof i)throw TypeError("Cannot `"+e+"` without `compiler`")}function fz(e,i){if(i)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function fF(e){if(!fx(e)||"string"!=typeof e.type)throw TypeError("Expected node, got `"+e+"`")}function fW(e,i,n){if(!n)throw Error("`"+e+"` finished async. Use `"+i+"` instead")}function fH(e){var i;return(i=e)&&"object"==typeof i&&"message"in i&&"messages"in i?e:new fM(e)}let f$=[],fU={allowDangerousHtml:!0},fV=/^(https?|ircs?|mailto|xmpp)$/i,fq=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function fY(e){var i;let n,r,s,o,a,l=(n=(i=e).rehypePlugins||f$,r=i.remarkPlugins||f$,s=i.remarkRehypeOptions?{...i.remarkRehypeOptions,...fU}:fU,fI().use(pZ).use(r).use(fy,s).use(n)),c=(o=e.children||"",a=new fM,"string"==typeof o?a.value=o:dI("Unexpected value `"+o+"` for `children` prop, expected `string`"),a);return function(e,i){let n=i.allowedElements,r=i.allowElement,s=i.components,o=i.disallowedElements,a=i.skipHtml,l=i.unwrapDisallowed,c=i.urlTransform||fK;for(let e of fq)Object.hasOwn(i,e.from)&&dI("Unexpected `"+e.from+"` prop, "+(e.to?"use `"+e.to+"` instead":"remove it")+" (see <https://github.com/remarkjs/react-markdown/blob/main/changelog.md#"+e.id+"> for more info)");return n&&o&&dI("Unexpected combined `allowedElements` and `disallowedElements`, expected one or the other"),fs(e,function(e,i,s){if("raw"===e.type&&s&&"number"==typeof i)return a?s.children.splice(i,1):s.children[i]={type:"text",value:e.value},i;if("element"===e.type){let i;for(i in uL)if(Object.hasOwn(uL,i)&&Object.hasOwn(e.properties,i)){let n=e.properties[i],r=uL[i];(null===r||r.includes(e.tagName))&&(e.properties[i]=c(String(n||""),i,e))}}if("element"===e.type){let a=n?!n.includes(e.tagName):!!o&&o.includes(e.tagName);if(!a&&r&&"number"==typeof i&&(a=!r(e,i,s)),a&&s&&"number"==typeof i)return l&&e.children?s.children.splice(i,1,...e.children):s.children.splice(i,1),i}}),function(e,i){var n,r,s,o;let a;if(!i||void 0===i.Fragment)throw TypeError("Expected `Fragment` in options");let l=i.filePath||void 0;if(i.development){if("function"!=typeof i.jsxDEV)throw TypeError("Expected `jsxDEV` in options when `development: true`");n=l,r=i.jsxDEV,a=function(e,i,s,o){let a=Array.isArray(s.children),l=uf(e);return r(i,s,o,a,{columnNumber:l?l.column-1:void 0,fileName:n,lineNumber:l?l.line:void 0},void 0)}}else{if("function"!=typeof i.jsx)throw TypeError("Expected `jsx` in production options");if("function"!=typeof i.jsxs)throw TypeError("Expected `jsxs` in production options");s=i.jsx,o=i.jsxs,a=function(e,i,n,r){let a=Array.isArray(n.children)?o:s;return r?a(i,n,r):a(i,n)}}let c={Fragment:i.Fragment,ancestors:[],components:i.components||{},create:a,elementAttributeNameCase:i.elementAttributeNameCase||"react",evaluater:i.createEvaluater?i.createEvaluater():void 0,filePath:l,ignoreInvalidStyle:i.ignoreInvalidStyle||!1,passKeys:!1!==i.passKeys,passNode:i.passNode||!1,schema:"svg"===i.space?ud:uh,stylePropertyNameCase:i.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==i.tableCellAlignToStyle},h=uE(c,e,void 0);return h&&"string"!=typeof h?h:c.create(e,c.Fragment,{children:h||void 0},void 0)}(e,{Fragment:iN.Fragment,components:s,ignoreInvalidStyle:!0,jsx:iN.jsx,jsxs:iN.jsxs,passKeys:!0,passNode:!0})}(l.runSync(l.parse(c),c),e)}function fK(e){let i=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),s=e.indexOf("/");return -1===i||-1!==s&&i>s||-1!==n&&i>n||-1!==r&&i>r||fV.test(e.slice(0,i))?e:""}function fX(e,i){let n=String(e);if("string"!=typeof i)throw TypeError("Expected character");let r=0,s=n.indexOf(i);for(;-1!==s;)r++,s=n.indexOf(i,s+i.length);return r}let fJ="phrasing",fG=["autolink","link","image","label"];function fZ(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function fQ(e){this.config.enter.autolinkProtocol.call(this,e)}function f0(e){this.config.exit.autolinkProtocol.call(this,e)}function f1(e){this.config.exit.data.call(this,e);let i=this.stack[this.stack.length-1];dj("link"===i.type),i.url="http://"+this.sliceSerialize(e)}function f2(e){this.config.exit.autolinkEmail.call(this,e)}function f5(e){this.exit(e)}function f3(e){!function(e,i,n){let r=fe((n||{}).ignore||[]),s=function(e){let i=[];if(!Array.isArray(e))throw TypeError("Expected find and replace tuple or list of tuples");let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){var s;let e=n[r];i.push(["string"==typeof(s=e[0])?RegExp(function(e){if("string"!=typeof e)throw TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}(s),"g"):s,function(e){return"function"==typeof e?e:function(){return e}}(e[1])])}return i}(i),o=-1;for(;++o<s.length;)fr(e,"text",a);function a(e,i){let n,a=-1;for(;++a<i.length;){let e=i[a],s=n?n.children:void 0;if(r(e,s?s.indexOf(e):void 0,n))return;n=e}if(n)return function(e,i){let n=i[i.length-1],r=s[o][0],a=s[o][1],l=0,c=n.children.indexOf(e),h=!1,d=[];r.lastIndex=0;let u=r.exec(e.value);for(;u;){let n=u.index,s={index:u.index,input:u.input,stack:[...i,e]},o=a(...u,s);if("string"==typeof o&&(o=o.length>0?{type:"text",value:o}:void 0),!1===o?r.lastIndex=n+1:(l!==n&&d.push({type:"text",value:e.value.slice(l,n)}),Array.isArray(o)?d.push(...o):o&&d.push(o),l=n+u[0].length,h=!0),!r.global)break;u=r.exec(e.value)}return h?(l<e.value.length&&d.push({type:"text",value:e.value.slice(l)}),n.children.splice(c,1,...d)):d=[e],c+d.length}(e,i)}}(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,f4],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,f6]],{ignore:["link","linkReference"]})}function f4(e,i,n,r,s){let o,a="";if(!f8(s))return!1;if(/^w/i.test(i)&&(n=i+n,i="",a="http://"),(o=n.split(".")).length<2||o[o.length-1]&&(/_/.test(o[o.length-1])||!/[a-zA-Z\d]/.test(o[o.length-1]))||o[o.length-2]&&(/_/.test(o[o.length-2])||!/[a-zA-Z\d]/.test(o[o.length-2])))return!1;let l=function(e){let i=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!i)return[e,void 0];e=e.slice(0,i.index);let n=i[0],r=n.indexOf(")"),s=fX(e,"("),o=fX(e,")");for(;-1!==r&&s>o;)e+=n.slice(0,r+1),r=(n=n.slice(r+1)).indexOf(")"),o++;return[e,n]}(n+r);if(!l[0])return!1;let c={type:"link",title:null,url:a+i+l[0],children:[{type:"text",value:i+l[0]}]};return l[1]?[c,{type:"text",value:l[1]}]:c}function f6(e,i,n,r){return!(!f8(r,!0)||/[-\d_]$/.test(n))&&{type:"link",title:null,url:"mailto:"+i+"@"+n,children:[{type:"text",value:i+"@"+n}]}}function f8(e,i){let n=e.input.charCodeAt(e.index-1);return(0===e.index||u0(n)||uQ(n))&&(!i||47!==n)}function f9(){this.buffer()}function f7(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function me(){this.buffer()}function mt(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function mi(e){let i=this.resume(),n=this.stack[this.stack.length-1];dj("footnoteReference"===n.type),n.identifier=pT(this.sliceSerialize(e)).toLowerCase(),n.label=i}function mn(e){this.exit(e)}function mr(e){let i=this.resume(),n=this.stack[this.stack.length-1];dj("footnoteDefinition"===n.type),n.identifier=pT(this.sliceSerialize(e)).toLowerCase(),n.label=i}function ms(e){this.exit(e)}function mo(e,i,n,r){let s=n.createTracker(r),o=s.move("[^"),a=n.enter("footnoteReference"),l=n.enter("reference");return o+=s.move(n.safe(n.associationId(e),{after:"]",before:o})),l(),a(),o+=s.move("]")}function ma(e,i,n){return 0===i?e:ml(e,i,n)}function ml(e,i,n){return(n?"":" ")+e}mo.peek=function(){return"["};let mc=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];function mh(e){this.enter({type:"delete",children:[]},e)}function md(e){this.exit(e)}function mu(e,i,n,r){let s=n.createTracker(r),o=n.enter("strikethrough"),a=s.move("~~");return a+=n.containerPhrasing(e,{...s.current(),before:a,after:"~"}),a+=s.move("~~"),o(),a}function mp(e){return e.length}function mf(e){let i="string"==typeof e?e.codePointAt(0):0;return 67===i||99===i?99:76===i||108===i?108:114*(82===i||114===i)}mu.peek=function(){return"~"};function mm(e,i,n){let r=e.value||"",s="`",o=-1;for(;RegExp("(^|[^`])"+s+"([^`]|$)").test(r);)s+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++o<n.unsafe.length;){let e,i=n.unsafe[o],s=n.compilePattern(i);if(i.atBreak)for(;e=s.exec(r);){let i=e.index;10===r.charCodeAt(i)&&13===r.charCodeAt(i-1)&&i--,r=r.slice(0,i)+" "+r.slice(e.index+1)}}return s+r+s}mm.peek=function(){return"`"};fe(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);let mg=function(e,i,n,r){let s=function(e){let i=e.options.listItemIndent||"one";if("tab"!==i&&"one"!==i&&"mixed"!==i)throw Error("Cannot serialize items with `"+i+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return i}(n),o=n.bulletCurrent||function(e){let i=e.options.bullet||"*";if("*"!==i&&"+"!==i&&"-"!==i)throw Error("Cannot serialize items with `"+i+"` for `options.bullet`, expected `*`, `+`, or `-`");return i}(n);i&&"list"===i.type&&i.ordered&&(o=("number"==typeof i.start&&i.start>-1?i.start:1)+(!1===n.options.incrementListMarker?0:i.children.indexOf(e))+o);let a=o.length+1;("tab"===s||"mixed"===s&&(i&&"list"===i.type&&i.spread||e.spread))&&(a=4*Math.ceil(a/4));let l=n.createTracker(r);l.move(o+" ".repeat(a-o.length)),l.shift(a);let c=n.enter("listItem"),h=n.indentLines(n.containerFlow(e,l.current()),function(e,i,n){return i?(n?"":" ".repeat(a))+e:(n?o:o+" ".repeat(a-o.length))+e});return c(),h};function mv(e){let i=e._align;dj(i,"expected `_align` on table"),this.enter({type:"table",align:i.map(function(e){return"none"===e?null:e}),children:[]},e),this.data.inTable=!0}function my(e){this.exit(e),this.data.inTable=void 0}function m_(e){this.enter({type:"tableRow",children:[]},e)}function mb(e){this.exit(e)}function mx(e){this.enter({type:"tableCell",children:[]},e)}function mw(e){let i=this.resume();this.data.inTable&&(i=i.replace(/\\([\\|])/g,mS));let n=this.stack[this.stack.length-1];dj("inlineCode"===n.type),n.value=i,this.exit(e)}function mS(e,i){return"|"===i?i:e}function mk(e){let i=this.stack[this.stack.length-2];dj("listItem"===i.type),i.checked="taskListCheckValueChecked"===e.type}function mC(e){let i=this.stack[this.stack.length-2];if(i&&"listItem"===i.type&&"boolean"==typeof i.checked){let e=this.stack[this.stack.length-1];dj("paragraph"===e.type);let n=e.children[0];if(n&&"text"===n.type){let r,s=i.children,o=-1;for(;++o<s.length;){let e=s[o];if("paragraph"===e.type){r=e;break}}r===e&&(n.value=n.value.slice(1),0===n.value.length?e.children.shift():e.position&&n.position&&"number"==typeof n.position.start.offset&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function mT(e,i,n,r){let s=e.children[0],o="boolean"==typeof e.checked&&s&&"paragraph"===s.type,a="["+(e.checked?"x":" ")+"] ",l=n.createTracker(r);o&&l.move(a);let c=mg(e,i,n,{...r,...l.current()});return o&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,function(e){return e+a})),c}let mE={tokenize:function(e,i,n){let r=0;return function i(o){return(87===o||119===o)&&r<3?(r++,e.consume(o),i):46===o&&3===r?(e.consume(o),s):n(o)};function s(e){return null===e?n(e):i(e)}},partial:!0},mN={tokenize:function(e,i,n){let r,s,o;return a;function a(i){return 46===i||95===i?e.check(mO,c,l)(i):null===i||uG(i)||u0(i)||45!==i&&uQ(i)?c(i):(o=!0,e.consume(i),a)}function l(i){return 95===i?r=!0:(s=r,r=void 0),e.consume(i),a}function c(e){return s||r||!o?n(e):i(e)}},partial:!0},mM={tokenize:function(e,i){let n=0,r=0;return s;function s(a){return 40===a?(n++,e.consume(a),s):41===a&&r<n?o(a):33===a||34===a||38===a||39===a||41===a||42===a||44===a||46===a||58===a||59===a||60===a||63===a||93===a||95===a||126===a?e.check(mO,i,o)(a):null===a||uG(a)||u0(a)?i(a):(e.consume(a),s)}function o(i){return 41===i&&r++,e.consume(i),s}},partial:!0},mO={tokenize:function(e,i,n){return r;function r(a){return 33===a||34===a||39===a||41===a||42===a||44===a||46===a||58===a||59===a||63===a||95===a||126===a?(e.consume(a),r):38===a?(e.consume(a),o):93===a?(e.consume(a),s):60===a||null===a||uG(a)||u0(a)?i(a):n(a)}function s(e){return null===e||40===e||91===e||uG(e)||u0(e)?i(e):r(e)}function o(i){return u$(i)?function i(s){return 59===s?(e.consume(s),r):u$(s)?(e.consume(s),i):n(s)}(i):n(i)}},partial:!0},mA={tokenize:function(e,i,n){return function(i){return e.consume(i),r};function r(e){return uU(e)?n(e):i(e)}},partial:!0},mR={name:"wwwAutolink",tokenize:function(e,i,n){let r=this;return function(i){return 87!==i&&119!==i||!mP.call(r,r.previous)||mW(r.events)?n(i):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(mE,e.attempt(mN,e.attempt(mM,s),n),n)(i))};function s(n){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),i(n)}},previous:mP},mD={name:"protocolAutolink",tokenize:function(e,i,n){let r=this,s="",o=!1;return function(i){return(72===i||104===i)&&mB.call(r,r.previous)&&!mW(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),s+=String.fromCodePoint(i),e.consume(i),a):n(i)};function a(i){if(u$(i)&&s.length<5)return s+=String.fromCodePoint(i),e.consume(i),a;if(58===i){let n=s.toLowerCase();if("http"===n||"https"===n)return e.consume(i),l}return n(i)}function l(i){return 47===i?(e.consume(i),o)?c:(o=!0,l):n(i)}function c(i){return null===i||uq(i)||uG(i)||u0(i)||uQ(i)?n(i):e.attempt(mN,e.attempt(mM,h),n)(i)}function h(n){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),i(n)}},previous:mB},mL={name:"emailAutolink",tokenize:function(e,i,n){let r,s,o=this;return function(i){return!mF(i)||!mz.call(o,o.previous)||mW(o.events)?n(i):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),function i(r){return mF(r)?(e.consume(r),i):64===r?(e.consume(r),a):n(r)}(i))};function a(i){return 46===i?e.check(mA,c,l)(i):45===i||95===i||uU(i)?(s=!0,e.consume(i),a):c(i)}function l(i){return e.consume(i),r=!0,a}function c(a){return s&&r&&u$(o.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),i(a)):n(a)}},previous:mz},mj={},mI=48;for(;mI<123;)mj[mI]=mL,58==++mI?mI=65:91===mI&&(mI=97);function mP(e){return null===e||40===e||42===e||95===e||91===e||93===e||126===e||uG(e)}function mB(e){return!u$(e)}function mz(e){return!(47===e||mF(e))}function mF(e){return 43===e||45===e||46===e||95===e||uU(e)}function mW(e){let i=e.length,n=!1;for(;i--;){let r=e[i][1];if(("labelLink"===r.type||"labelImage"===r.type)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}mj[43]=mL,mj[45]=mL,mj[46]=mL,mj[95]=mL,mj[72]=[mL,mD],mj[104]=[mL,mD],mj[87]=[mL,mR],mj[119]=[mL,mR];let mH={tokenize:function(e,i,n){let r=this;return u2(e,function(e){let s=r.events[r.events.length-1];return s&&"gfmFootnoteDefinitionIndent"===s[1].type&&4===s[2].sliceSerialize(s[1],!0).length?i(e):n(e)},"gfmFootnoteDefinitionIndent",5)},partial:!0};function m$(e,i,n){let r,s=this,o=s.events.length,a=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);for(;o--;){let e=s.events[o][1];if("labelImage"===e.type){r=e;break}if("gfmFootnoteCall"===e.type||"labelLink"===e.type||"label"===e.type||"image"===e.type||"link"===e.type)break}return function(o){if(!r||!r._balanced)return n(o);let l=pT(s.sliceSerialize({start:r.end,end:s.now()}));return 94===l.codePointAt(0)&&a.includes(l.slice(1))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(o),e.exit("gfmFootnoteCallLabelMarker"),i(o)):n(o)}}function mU(e,i){let n=e.length;for(;n--;)if("labelImage"===e[n][1].type&&"enter"===e[n][0]){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";let r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},s={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};s.end.column++,s.end.offset++,s.end._bufferIndex++;let o={type:"gfmFootnoteCallString",start:Object.assign({},s.end),end:Object.assign({},e[e.length-1][1].start)},a={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},l=[e[n+1],e[n+2],["enter",r,i],e[n+3],e[n+4],["enter",s,i],["exit",s,i],["enter",o,i],["enter",a,i],["exit",a,i],["exit",o,i],e[e.length-2],e[e.length-1],["exit",r,i]];return e.splice(n,e.length-n+1,...l),e}function mV(e,i,n){let r,s=this,o=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]),a=0;return function(i){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(i),e.exit("gfmFootnoteCallLabelMarker"),l};function l(i){return 94!==i?n(i):(e.enter("gfmFootnoteCallMarker"),e.consume(i),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",c)}function c(l){if(a>999||93===l&&!r||null===l||91===l||uG(l))return n(l);if(93===l){e.exit("chunkString");let r=e.exit("gfmFootnoteCallString");return o.includes(pT(s.sliceSerialize(r)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),i):n(l)}return uG(l)||(r=!0),a++,e.consume(l),92===l?h:c}function h(i){return 91===i||92===i||93===i?(e.consume(i),a++,c):c(i)}}function mq(e,i,n){let r,s,o=this,a=o.parser.gfmFootnotes||(o.parser.gfmFootnotes=[]),l=0;return function(i){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(i),e.exit("gfmFootnoteDefinitionLabelMarker"),c};function c(i){return 94===i?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(i),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",h):n(i)}function h(i){if(l>999||93===i&&!s||null===i||91===i||uG(i))return n(i);if(93===i){e.exit("chunkString");let n=e.exit("gfmFootnoteDefinitionLabelString");return r=pT(o.sliceSerialize(n)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(i),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),u}return uG(i)||(s=!0),l++,e.consume(i),92===i?d:h}function d(i){return 91===i||92===i||93===i?(e.consume(i),l++,h):h(i)}function u(i){return 58===i?(e.enter("definitionMarker"),e.consume(i),e.exit("definitionMarker"),a.includes(r)||a.push(r),u2(e,p,"gfmFootnoteDefinitionWhitespace")):n(i)}function p(e){return i(e)}}function mY(e,i,n){return e.check(u6,i,e.attempt(mH,i,n))}function mK(e){e.exit("gfmFootnoteDefinition")}class mX{constructor(){this.map=[]}add(e,i,n){!function(e,i,n,r){let s=0;if(0!==n||0!==r.length){for(;s<e.map.length;){if(e.map[s][0]===i){e.map[s][1]+=n,e.map[s][2].push(...r);return}s+=1}e.map.push([i,n,r])}}(this,e,i,n)}consume(e){if(this.map.sort(function(e,i){return e[0]-i[0]}),0===this.map.length)return;let i=this.map.length,n=[];for(;i>0;)i-=1,n.push(e.slice(this.map[i][0]+this.map[i][1]),this.map[i][2]),e.length=this.map[i][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let i of r)e.push(i);r=n.pop()}this.map.length=0}}function mJ(e,i,n){let r,s=this,o=0,a=0;return function(e){let i=s.events.length-1;for(;i>-1;){let e=s.events[i][1].type;if("lineEnding"===e||"linePrefix"===e)i--;else break}let r=i>-1?s.events[i][1].type:null,o="tableHead"===r||"tableRow"===r?_:l;return o===_&&s.parser.lazy[s.now().line]?n(e):o(e)};function l(i){var n;return e.enter("tableHead"),e.enter("tableRow"),124===(n=i)||(r=!0,a+=1),c(n)}function c(i){return null===i?n(i):uJ(i)?a>1?(a=0,s.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),u):n(i):uZ(i)?u2(e,c,"whitespace")(i):(a+=1,r&&(r=!1,o+=1),124===i)?(e.enter("tableCellDivider"),e.consume(i),e.exit("tableCellDivider"),r=!0,c):(e.enter("data"),h(i))}function h(i){return null===i||124===i||uG(i)?(e.exit("data"),c(i)):(e.consume(i),92===i?d:h)}function d(i){return 92===i||124===i?(e.consume(i),h):h(i)}function u(i){return(s.interrupt=!1,s.parser.lazy[s.now().line])?n(i):(e.enter("tableDelimiterRow"),r=!1,uZ(i))?u2(e,p,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(i):p(i)}function p(i){return 45===i||58===i?m(i):124===i?(r=!0,e.enter("tableCellDivider"),e.consume(i),e.exit("tableCellDivider"),f):n(i)}function f(i){return uZ(i)?u2(e,m,"whitespace")(i):m(i)}function m(i){return 58===i?(a+=1,r=!0,e.enter("tableDelimiterMarker"),e.consume(i),e.exit("tableDelimiterMarker"),g):45===i?(a+=1,g(i)):null===i||uJ(i)?y(i):n(i)}function g(i){return 45===i?(e.enter("tableDelimiterFiller"),function i(n){return 45===n?(e.consume(n),i):58===n?(r=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(n),e.exit("tableDelimiterMarker"),v):(e.exit("tableDelimiterFiller"),v(n))}(i)):n(i)}function v(i){return uZ(i)?u2(e,y,"whitespace")(i):y(i)}function y(s){if(124===s)return p(s);if(null===s||uJ(s))return r&&o===a?(e.exit("tableDelimiterRow"),e.exit("tableHead"),i(s)):n(s);return n(s)}function _(i){return e.enter("tableRow"),b(i)}function b(n){return 124===n?(e.enter("tableCellDivider"),e.consume(n),e.exit("tableCellDivider"),b):null===n||uJ(n)?(e.exit("tableRow"),i(n)):uZ(n)?u2(e,b,"whitespace")(n):(e.enter("data"),w(n))}function w(i){return null===i||124===i||uG(i)?(e.exit("data"),b(i)):(e.consume(i),92===i?S:w)}function S(i){return 92===i||124===i?(e.consume(i),w):w(i)}}function mG(e,i){let n,r,s,o=-1,a=!0,l=0,c=[0,0,0,0],h=[0,0,0,0],d=!1,u=0,p=new mX;for(;++o<e.length;){let f=e[o],m=f[1];"enter"===f[0]?"tableHead"===m.type?(d=!1,0!==u&&(mQ(p,i,u,n,r),r=void 0,u=0),n={type:"table",start:Object.assign({},m.start),end:Object.assign({},m.end)},p.add(o,0,[["enter",n,i]])):"tableRow"===m.type||"tableDelimiterRow"===m.type?(a=!0,s=void 0,c=[0,0,0,0],h=[0,o+1,0,0],d&&(d=!1,r={type:"tableBody",start:Object.assign({},m.start),end:Object.assign({},m.end)},p.add(o,0,[["enter",r,i]])),l="tableDelimiterRow"===m.type?2:r?3:1):l&&("data"===m.type||"tableDelimiterMarker"===m.type||"tableDelimiterFiller"===m.type)?(a=!1,0===h[2]&&(0!==c[1]&&(h[0]=h[1],s=mZ(p,i,c,l,void 0,s),c=[0,0,0,0]),h[2]=o)):"tableCellDivider"===m.type&&(a?a=!1:(0!==c[1]&&(h[0]=h[1],s=mZ(p,i,c,l,void 0,s)),h=[(c=h)[1],o,0,0])):"tableHead"===m.type?(d=!0,u=o):"tableRow"===m.type||"tableDelimiterRow"===m.type?(u=o,0!==c[1]?(h[0]=h[1],s=mZ(p,i,c,l,o,s)):0!==h[1]&&(s=mZ(p,i,h,l,o,s)),l=0):l&&("data"===m.type||"tableDelimiterMarker"===m.type||"tableDelimiterFiller"===m.type)&&(h[3]=o)}for(0!==u&&mQ(p,i,u,n,r),p.consume(i.events),o=-1;++o<i.events.length;){let e=i.events[o];"enter"===e[0]&&"table"===e[1].type&&(e[1]._align=function(e,i){let n=!1,r=[];for(;i<e.length;){let s=e[i];if(n){if("enter"===s[0])"tableContent"===s[1].type&&r.push("tableDelimiterMarker"===e[i+1][1].type?"left":"none");else if("tableContent"===s[1].type){if("tableDelimiterMarker"===e[i-1][1].type){let e=r.length-1;r[e]="left"===r[e]?"center":"right"}}else if("tableDelimiterRow"===s[1].type)break}else"enter"===s[0]&&"tableDelimiterRow"===s[1].type&&(n=!0);i+=1}return r}(i.events,o))}return e}function mZ(e,i,n,r,s,o){0!==n[0]&&(o.end=Object.assign({},m0(i.events,n[0])),e.add(n[0],0,[["exit",o,i]]));let a=m0(i.events,n[1]);if(o={type:1===r?"tableHeader":2===r?"tableDelimiter":"tableData",start:Object.assign({},a),end:Object.assign({},a)},e.add(n[1],0,[["enter",o,i]]),0!==n[2]){let s=m0(i.events,n[2]),o=m0(i.events,n[3]),a={type:"tableContent",start:Object.assign({},s),end:Object.assign({},o)};if(e.add(n[2],0,[["enter",a,i]]),2!==r){let r=i.events[n[2]],s=i.events[n[3]];if(r[1].end=Object.assign({},s[1].end),r[1].type="chunkText",r[1].contentType="text",n[3]>n[2]+1){let i=n[2]+1,r=n[3]-n[2]-1;e.add(i,r,[])}}e.add(n[3]+1,0,[["exit",a,i]])}return void 0!==s&&(o.end=Object.assign({},m0(i.events,s)),e.add(s,0,[["exit",o,i]]),o=void 0),o}function mQ(e,i,n,r,s){let o=[],a=m0(i.events,n);s&&(s.end=Object.assign({},a),o.push(["exit",s,i])),r.end=Object.assign({},a),o.push(["exit",r,i]),e.add(n+1,0,o)}function m0(e,i){let n=e[i],r="enter"===n[0]?"start":"end";return n[1][r]}let m1={name:"tasklistCheck",tokenize:function(e,i,n){let r=this;return function(i){return null===r.previous&&r._gfmTasklistFirstContentOfListItem?(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(i),e.exit("taskListCheckMarker"),s):n(i)};function s(i){return uG(i)?(e.enter("taskListCheckValueUnchecked"),e.consume(i),e.exit("taskListCheckValueUnchecked"),o):88===i||120===i?(e.enter("taskListCheckValueChecked"),e.consume(i),e.exit("taskListCheckValueChecked"),o):n(i)}function o(i){return 93===i?(e.enter("taskListCheckMarker"),e.consume(i),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),a):n(i)}function a(r){return uJ(r)?i(r):uZ(r)?e.check({tokenize:m2},i,n)(r):n(r)}}};function m2(e,i,n){return u2(e,function(e){return null===e?n(e):i(e)},"whitespace")}let m5={};function m3(e){let i,n,r,s=e||m5,o=this.data(),a=o.micromarkExtensions||(o.micromarkExtensions=[]),l=o.fromMarkdownExtensions||(o.fromMarkdownExtensions=[]),c=o.toMarkdownExtensions||(o.toMarkdownExtensions=[]);a.push(uH([{text:mj},{document:{91:{name:"gfmFootnoteDefinition",tokenize:mq,continuation:{tokenize:mY},exit:mK}},text:{91:{name:"gfmFootnoteCall",tokenize:mV},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:m$,resolveTo:mU}}},(i=(s||{}).singleTilde,n={name:"strikethrough",tokenize:function(e,n,r){let s=this.previous,o=this.events,a=0;return function(l){return 126===s&&"characterEscape"!==o[o.length-1][1].type?r(l):(e.enter("strikethroughSequenceTemporary"),function o(l){let c=pc(s);if(126===l)return a>1?r(l):(e.consume(l),a++,o);if(a<2&&!i)return r(l);let h=e.exit("strikethroughSequenceTemporary"),d=pc(l);return h._open=!d||2===d&&!!c,h._close=!c||2===c&&!!d,n(l)}(l))}},resolveAll:function(e,i){let n=-1;for(;++n<e.length;)if("enter"===e[n][0]&&"strikethroughSequenceTemporary"===e[n][1].type&&e[n][1]._close){let r=n;for(;r--;)if("exit"===e[r][0]&&"strikethroughSequenceTemporary"===e[r][1].type&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset==e[r][1].end.offset-e[r][1].start.offset){e[n][1].type="strikethroughSequence",e[r][1].type="strikethroughSequence";let s={type:"strikethrough",start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},o={type:"strikethroughText",start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},a=[["enter",s,i],["enter",e[r][1],i],["exit",e[r][1],i],["enter",o,i]],l=i.parser.constructs.insideSpan.null;l&&uz(a,a.length,0,ph(l,e.slice(r+1,n),i)),uz(a,a.length,0,[["exit",o,i],["enter",e[n][1],i],["exit",e[n][1],i],["exit",s,i]]),uz(e,r-1,n-r+3,a),n=r+a.length-2;break}}for(n=-1;++n<e.length;)"strikethroughSequenceTemporary"===e[n][1].type&&(e[n][1].type="data");return e}},null==i&&(i=!0),{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}}),{flow:{null:{name:"table",tokenize:mJ,resolveAll:mG}}},{text:{91:m1}}])),l.push([{transforms:[f3],enter:{literalAutolink:fZ,literalAutolinkEmail:fQ,literalAutolinkHttp:fQ,literalAutolinkWww:fQ},exit:{literalAutolink:f5,literalAutolinkEmail:f2,literalAutolinkHttp:f0,literalAutolinkWww:f1}},{enter:{gfmFootnoteCallString:f9,gfmFootnoteCall:f7,gfmFootnoteDefinitionLabelString:me,gfmFootnoteDefinition:mt},exit:{gfmFootnoteCallString:mi,gfmFootnoteCall:mn,gfmFootnoteDefinitionLabelString:mr,gfmFootnoteDefinition:ms}},{canContainEols:["delete"],enter:{strikethrough:mh},exit:{strikethrough:md}},{enter:{table:mv,tableData:mx,tableHeader:mx,tableRow:m_},exit:{codeText:mw,table:my,tableData:mb,tableHeader:mb,tableRow:mb}},{exit:{taskListCheckValueChecked:mk,taskListCheckValueUnchecked:mk,paragraph:mC}}]),c.push({extensions:[{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:fJ,notInConstruct:fG},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:fJ,notInConstruct:fG},{character:":",before:"[ps]",after:"\\/",inConstruct:fJ,notInConstruct:fG}]},(r=!1,s&&s.firstLineBlank&&(r=!0),{handlers:{footnoteDefinition:function(e,i,n,s){let o=n.createTracker(s),a=o.move("[^"),l=n.enter("footnoteDefinition"),c=n.enter("label");return a+=o.move(n.safe(n.associationId(e),{before:a,after:"]"})),c(),a+=o.move("]:"),e.children&&e.children.length>0&&(o.shift(4),a+=o.move((r?"\n":" ")+n.indentLines(n.containerFlow(e,o.current()),r?ml:ma))),l(),a},footnoteReference:mo},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]}),{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:mc}],handlers:{delete:mu}},function(e){let i=e||{},n=i.tableCellPadding,r=i.tablePipeAlign,s=i.stringLength,o=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:"\n",inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:function(e,i,n){let r=mm(e,i,n);return n.stack.includes("tableCell")&&(r=r.replace(/\|/g,"\\$&")),r},table:function(e,i,n,r){return l(function(e,i,n){let r=e.children,s=-1,o=[],a=i.enter("table");for(;++s<r.length;)o[s]=c(r[s],i,n);return a(),o}(e,n,r),e.align)},tableCell:a,tableRow:function(e,i,n,r){let s=l([c(e,n,r)]);return s.slice(0,s.indexOf("\n"))}}};function a(e,i,n,r){let s=n.enter("tableCell"),a=n.enter("phrasing"),l=n.containerPhrasing(e,{...r,before:o,after:o});return a(),s(),l}function l(e,i){return function(e,i){let n=i||{},r=(n.align||[]).concat(),s=n.stringLength||mp,o=[],a=[],l=[],c=[],h=0,d=-1;for(;++d<e.length;){let i=[],r=[],o=-1;for(e[d].length>h&&(h=e[d].length);++o<e[d].length;){var u;let a=null==(u=e[d][o])?"":String(u);if(!1!==n.alignDelimiters){let e=s(a);r[o]=e,(void 0===c[o]||e>c[o])&&(c[o]=e)}i.push(a)}a[d]=i,l[d]=r}let p=-1;if("object"==typeof r&&"length"in r)for(;++p<h;)o[p]=mf(r[p]);else{let e=mf(r);for(;++p<h;)o[p]=e}p=-1;let f=[],m=[];for(;++p<h;){let e=o[p],i="",r="";99===e?(i=":",r=":"):108===e?i=":":114===e&&(r=":");let s=!1===n.alignDelimiters?1:Math.max(1,c[p]-i.length-r.length),a=i+"-".repeat(s)+r;!1!==n.alignDelimiters&&((s=i.length+s+r.length)>c[p]&&(c[p]=s),m[p]=s),f[p]=a}a.splice(1,0,f),l.splice(1,0,m),d=-1;let g=[];for(;++d<a.length;){let e=a[d],i=l[d];p=-1;let r=[];for(;++p<h;){let s=e[p]||"",a="",l="";if(!1!==n.alignDelimiters){let e=c[p]-(i[p]||0),n=o[p];114===n?a=" ".repeat(e):99===n?e%2?(a=" ".repeat(e/2+.5),l=" ".repeat(e/2-.5)):l=a=" ".repeat(e/2):l=" ".repeat(e)}!1===n.delimiterStart||p||r.push("|"),!1!==n.padding&&(!1!==n.alignDelimiters||""!==s)&&(!1!==n.delimiterStart||p)&&r.push(" "),!1!==n.alignDelimiters&&r.push(a),r.push(s),!1!==n.alignDelimiters&&r.push(l),!1!==n.padding&&r.push(" "),(!1!==n.delimiterEnd||p!==h-1)&&r.push("|")}g.push(!1===n.delimiterEnd?r.join("").replace(/ +$/,""):r.join(""))}return g.join("\n")}(e,{align:i,alignDelimiters:r,padding:n,stringLength:s})}function c(e,i,n){let r=e.children,s=-1,o=[],l=i.enter("tableRow");for(;++s<r.length;)o[s]=a(r[s],e,i,n);return l(),o}}(s),{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:mT}}]})}let m4={pre:({children:e})=>(0,iN.jsx)("pre",{className:"bg-background/50 rounded-md p-3 overflow-x-auto text-xs my-2",children:e}),code:({className:e,children:i,...n})=>e?(0,iN.jsx)("code",{className:e,...n,children:i}):(0,iN.jsx)("code",{className:"bg-background/50 px-1 py-0.5 rounded text-xs font-mono",...n,children:i}),p:({children:e})=>(0,iN.jsx)("p",{className:"mb-2 last:mb-0",children:e}),ul:({children:e})=>(0,iN.jsx)("ul",{className:"list-disc pl-4 mb-2 space-y-1",children:e}),ol:({children:e})=>(0,iN.jsx)("ol",{className:"list-decimal pl-4 mb-2 space-y-1",children:e}),li:({children:e})=>(0,iN.jsx)("li",{className:"text-sm",children:e}),h1:({children:e})=>(0,iN.jsx)("h1",{className:"text-lg font-bold mb-2",children:e}),h2:({children:e})=>(0,iN.jsx)("h2",{className:"text-base font-bold mb-2",children:e}),h3:({children:e})=>(0,iN.jsx)("h3",{className:"text-sm font-bold mb-1",children:e}),blockquote:({children:e})=>(0,iN.jsx)("blockquote",{className:"border-l-2 border-muted-foreground/30 pl-3 my-2 text-muted-foreground",children:e}),a:({href:e,children:i})=>(0,iN.jsx)("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline hover:no-underline",children:i}),table:({children:e})=>(0,iN.jsx)("div",{className:"overflow-x-auto my-2",children:(0,iN.jsx)("table",{className:"text-xs border-collapse",children:e})}),th:({children:e})=>(0,iN.jsx)("th",{className:"border border-muted px-2 py-1 bg-muted/50 font-semibold text-left",children:e}),td:({children:e})=>(0,iN.jsx)("td",{className:"border border-muted px-2 py-1",children:e})};function m6({content:e}){return(0,iN.jsx)(fY,{remarkPlugins:[m3],components:m4,children:e})}let m8=({size:e=16})=>(0,iN.jsxs)("svg",{height:e,strokeLinejoin:"round",style:{color:"currentcolor"},viewBox:"0 0 16 16",width:e,children:[(0,iN.jsx)("title",{children:"Loader"}),(0,iN.jsxs)("g",{clipPath:"url(#clip0_2393_1490)",children:[(0,iN.jsx)("path",{d:"M8 0V4",stroke:"currentColor",strokeWidth:"1.5"}),(0,iN.jsx)("path",{d:"M8 16V12",opacity:"0.5",stroke:"currentColor",strokeWidth:"1.5"}),(0,iN.jsx)("path",{d:"M3.29773 1.52783L5.64887 4.7639",opacity:"0.9",stroke:"currentColor",strokeWidth:"1.5"}),(0,iN.jsx)("path",{d:"M12.7023 1.52783L10.3511 4.7639",opacity:"0.1",stroke:"currentColor",strokeWidth:"1.5"}),(0,iN.jsx)("path",{d:"M12.7023 14.472L10.3511 11.236",opacity:"0.4",stroke:"currentColor",strokeWidth:"1.5"}),(0,iN.jsx)("path",{d:"M3.29773 14.472L5.64887 11.236",opacity:"0.6",stroke:"currentColor",strokeWidth:"1.5"}),(0,iN.jsx)("path",{d:"M15.6085 5.52783L11.8043 6.7639",opacity:"0.2",stroke:"currentColor",strokeWidth:"1.5"}),(0,iN.jsx)("path",{d:"M0.391602 10.472L4.19583 9.23598",opacity:"0.7",stroke:"currentColor",strokeWidth:"1.5"}),(0,iN.jsx)("path",{d:"M15.6085 10.4722L11.8043 9.2361",opacity:"0.3",stroke:"currentColor",strokeWidth:"1.5"}),(0,iN.jsx)("path",{d:"M0.391602 5.52783L4.19583 6.7639",opacity:"0.8",stroke:"currentColor",strokeWidth:"1.5"})]}),(0,iN.jsx)("defs",{children:(0,iN.jsx)("clipPath",{id:"clip0_2393_1490",children:(0,iN.jsx)("rect",{fill:"white",height:"16",width:"16"})})})]}),m9=({className:e,size:i=16,...n})=>(0,iN.jsx)("div",{className:(0,nQ.cn)("inline-flex animate-spin items-center justify-center",e),...n,children:(0,iN.jsx)(m8,{size:i})});var m7=e.i(368942),ge=e.i(304271),gt=e.i(564822);function gi({oldContent:e,newContent:i,path:n}){let r,s=(r=n.split(".").pop()?.toLowerCase())?({ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",json:"json",md:"markdown",css:"css",html:"html",py:"python",rs:"rust",go:"go",yaml:"yaml",yml:"yaml"})[r]:void 0,o=(0,iM.useRef)(null),{resolvedTheme:a}=(0,rf.useTheme)(),l=(0,gt.useIsMobile)();return(0,iM.useEffect)(()=>()=>{let e=o.current;e&&(e.setModel(null),o.current=null)},[]),(0,iN.jsxs)("div",{className:"h-full w-full flex flex-col",children:[(0,iN.jsx)("div",{className:"text-xs text-muted-foreground px-2 py-1 border-b bg-muted/30 font-mono truncate",children:n}),(0,iN.jsx)("div",{className:"flex-1",children:(0,iN.jsx)(ge.DiffEditor,{original:e,modified:i,language:s,theme:"dark"===a?"vs-dark":"vs",onMount:e=>{o.current=e},options:{readOnly:!0,renderSideBySide:!l,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:13,lineNumbers:"on"}})})]})}var gn=e.i(946899),gn=gn;e.s([],352264),e.i(352264);var gr=e.i(535270),gs=e.i(29905),go=e.i(756432),ga=e.i(189131),gl=e.i(267805);let gc=iM.createContext(void 0);function gh(){let e=iM.useContext(gc);if(void 0===e)throw Error((0,gl.default)(10));return e}let gd={value:()=>null},gu=iM.forwardRef(function(e,i){let{render:n,className:r,disabled:s=!1,hiddenUntilFound:o,keepMounted:a,loopFocus:l=!0,onValueChange:c,multiple:h=!1,orientation:d="vertical",value:u,defaultValue:p,style:f,...m}=e,g=(0,ga.useDirection)(),v=iM.useMemo(()=>{if(void 0===u)return p??[]},[u,p]),y=(0,gs.useStableCallback)(c),_=iM.useRef([]),[b,w]=(0,gr.useControlled)({controlled:u,default:v,name:"Accordion",state:"value"}),S=(0,gs.useStableCallback)((e,i)=>{let n=(0,h2.createChangeEventDetails)(h3.REASONS.none);if(h)if(i){let i=b.slice();if(i.push(e),y(i,n),n.isCanceled)return;w(i)}else{let i=b.filter(i=>i!==e);if(y(i,n),n.isCanceled)return;w(i)}else{let i=b[0]===e?[]:[e];if(y(i,n),n.isCanceled)return;w(i)}}),k=iM.useMemo(()=>({value:b,disabled:s,orientation:d}),[b,s,d]),C=iM.useMemo(()=>({accordionItemRefs:_,direction:g,disabled:s,handleValueChange:S,hiddenUntilFound:o??!1,keepMounted:a??!1,loopFocus:l,orientation:d,state:k,value:b}),[g,s,S,o,a,l,d,k,b]),T=(0,h1.useRenderElement)("div",e,{state:k,ref:i,props:[{dir:g,role:"region"},m],stateAttributesMapping:gd});return(0,iN.jsx)(gc.Provider,{value:C,children:(0,iN.jsx)(go.CompositeList,{elementsRef:_,children:T})})});var gp=e.i(204133),gf=e.i(139236),gm=e.i(257295),gg=e.i(619279),gv=e.i(296615);let gy=iM.createContext(void 0);function g_(){let e=iM.useContext(gy);if(void 0===e)throw Error((0,gl.default)(9));return e}var gb=e.i(439485),gx=e.i(282458);let gw=((Do={}).index="data-index",Do.disabled="data-disabled",Do.open="data-open",Do),gS={...gb.collapsibleOpenStateMapping,index:e=>Number.isInteger(e)?{[gw.index]:String(e)}:null,...gx.transitionStatusMapping,value:()=>null},gk=iM.forwardRef(function(e,i){let{className:n,disabled:r=!1,onOpenChange:s,render:o,value:a,style:l,...c}=e,{ref:h,index:d}=(0,gv.useCompositeListItem)(),u=(0,gp.useMergedRefs)(i,h),{disabled:p,handleValueChange:f,state:m,value:g}=gh(),v=(0,gf.useBaseUiId)(),y=a??v,_=r||p,b=iM.useMemo(()=>{if(!g)return!1;for(let e=0;e<g.length;e+=1)if(g[e]===y)return!0;return!1},[g,y]),w=(0,gs.useStableCallback)((e,i)=>{s?.(e,i),i.isCanceled||f(y,e)}),S=(0,gm.useCollapsibleRoot)({open:b,onOpenChange:w,disabled:_}),k=iM.useMemo(()=>({open:S.open,disabled:S.disabled,hidden:!S.mounted,transitionStatus:S.transitionStatus}),[S.open,S.disabled,S.mounted,S.transitionStatus]),C=iM.useMemo(()=>({...S,onOpenChange:w,state:k}),[S,k,w]),T=iM.useMemo(()=>({...m,index:d,disabled:_,open:b}),[_,d,b,m]),[E,N]=iM.useState((0,gf.useBaseUiId)()),M=iM.useMemo(()=>({open:b,state:T,setTriggerId:N,triggerId:E}),[b,T,N,E]),O=(0,h1.useRenderElement)("div",e,{state:T,ref:u,props:c,stateAttributesMapping:gS});return(0,iN.jsx)(gg.CollapsibleRootContext.Provider,{value:C,children:(0,iN.jsx)(gy.Provider,{value:M,children:O})})}),gC=iM.forwardRef(function(e,i){let{render:n,className:r,style:s,...o}=e,{state:a}=g_();return(0,h1.useRenderElement)("h3",e,{state:a,ref:i,props:o,stateAttributesMapping:gS})});function gT(e){return null==e||e.hasAttribute("disabled")||"true"===e.getAttribute("aria-disabled")}var gE=e.i(277642),gN=e.i(931709),gM=e.i(100229);let gO=new Set([gM.ARROW_DOWN,gM.ARROW_UP,gM.ARROW_RIGHT,gM.ARROW_LEFT,gM.HOME,gM.END]),gA=iM.forwardRef(function(e,i){let{disabled:n,className:r,id:s,render:o,nativeButton:a=!0,style:l,...c}=e,{panelId:h,open:d,handleTrigger:u,disabled:p}=(0,gg.useCollapsibleRootContext)(),{getButtonProps:f,buttonRef:m}=(0,gN.useButton)({disabled:n??p,focusableWhenDisabled:!0,native:a,composite:!0}),{accordionItemRefs:g,direction:v,loopFocus:y,orientation:_}=gh(),b="rtl"===v,w="horizontal"===_,{state:S,setTriggerId:k,triggerId:C}=g_();(0,gE.useIsoLayoutEffect)(()=>(s&&k(s),()=>{k(void 0)}),[s,k]);let T=iM.useMemo(()=>({"aria-controls":d?h:void 0,"aria-expanded":d,id:C,tabIndex:0,onClick:u,onKeyDown(e){if(!gO.has(e.key))return;(0,h0.stopEvent)(e);let i=function(e){let{current:i}=e,n=[];for(let e=0;e<i.length;e+=1){let r=i[e];if(!gT(r)){let e=r?.querySelector('[type="button"], [role="button"]');e&&!gT(e)&&n.push(e)}}return n}(g),n=i.length-1,r=-1,s=i.indexOf(e.currentTarget);function o(){r=y?s+1>n?0:s+1:Math.min(s+1,n)}function a(){r=y&&0===s?n:s-1}switch(e.key){case gM.ARROW_DOWN:w||o();break;case gM.ARROW_UP:w||a();break;case gM.ARROW_RIGHT:w&&(b?a():o());break;case gM.ARROW_LEFT:w&&(b?o():a());break;case"Home":r=0;break;case"End":r=n}r>-1&&i[r].focus()}}),[g,u,C,w,b,y,d,h]);return(0,h1.useRenderElement)("button",e,{state:S,ref:[i,m],props:[T,c,f],stateAttributesMapping:gb.triggerOpenStateMapping})});var gR=e.i(18158);let gD=((Da={}).accordionPanelHeight="--accordion-panel-height",Da.accordionPanelWidth="--accordion-panel-width",Da);var gL=e.i(273598);let gj=iM.forwardRef(function(e,i){let{className:n,hiddenUntilFound:r,keepMounted:s,id:o,render:a,style:l,...c}=e,{hiddenUntilFound:h,keepMounted:d}=gh(),{abortControllerRef:u,animationTypeRef:p,height:f,mounted:m,onOpenChange:g,open:v,panelId:y,panelRef:_,runOnceAnimationsFinish:b,setDimensions:w,setHiddenUntilFound:S,setKeepMounted:k,setMounted:C,setOpen:T,setVisible:E,transitionDimensionRef:N,visible:M,width:O,setPanelIdState:A,transitionStatus:R}=(0,gg.useCollapsibleRootContext)(),D=r??h,L=s??d;(0,gE.useIsoLayoutEffect)(()=>{if(o)return A(o),()=>{A(void 0)}},[o,A]),(0,gE.useIsoLayoutEffect)(()=>{S(D)},[S,D]),(0,gE.useIsoLayoutEffect)(()=>{k(L)},[k,L]),(0,gL.useOpenChangeComplete)({open:v&&"idle"===R,ref:_,onComplete(){v&&w({width:void 0,height:void 0})}});let{props:j}=(0,gR.useCollapsiblePanel)({abortControllerRef:u,animationTypeRef:p,externalRef:i,height:f,hiddenUntilFound:D,id:o??y,keepMounted:L,mounted:m,onOpenChange:g,open:v,panelRef:_,runOnceAnimationsFinish:b,setDimensions:w,setMounted:C,setOpen:T,setVisible:E,transitionDimensionRef:N,visible:M,width:O}),{state:I,triggerId:P}=g_(),B=iM.useMemo(()=>({...I,transitionStatus:R}),[I,R]),z=(0,h1.useRenderElement)("div",e,{state:B,ref:[i,_],props:[j,{"aria-labelledby":P,role:"region",style:{[gD.accordionPanelHeight]:void 0===f?"auto":`${f}px`,[gD.accordionPanelWidth]:void 0===O?"auto":`${O}px`}},c],stateAttributesMapping:gS});return L||D||m?z:null});e.s(["Header",0,gC,"Item",0,gk,"Panel",0,gj,"Root",0,gu,"Trigger",0,gA],127284);var gI=e.i(127284),gI=gI,gP=e.i(380797),gP=gP;function gB({className:e,...i}){return(0,iN.jsx)(gI.Root,{"data-slot":"accordion",className:(0,nQ.cn)("flex w-full flex-col",e),...i})}function gz({className:e,...i}){return(0,iN.jsx)(gI.Item,{"data-slot":"accordion-item",className:(0,nQ.cn)("not-last:border-b",e),...i})}function gF({className:e,children:i,...n}){return(0,iN.jsx)(gI.Header,{className:"flex",children:(0,iN.jsxs)(gI.Trigger,{"data-slot":"accordion-trigger",className:(0,nQ.cn)("group/accordion-trigger relative flex flex-1 items-start justify-between rounded-lg border border-transparent py-2.5 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:after:border-ring aria-disabled:pointer-events-none aria-disabled:opacity-50 **:data-[slot=accordion-trigger-icon]:ml-auto **:data-[slot=accordion-trigger-icon]:size-4 **:data-[slot=accordion-trigger-icon]:text-muted-foreground",e),...n,children:[i,(0,iN.jsx)(dM.ChevronDownIcon,{"data-slot":"accordion-trigger-icon",className:"pointer-events-none shrink-0 group-aria-expanded/accordion-trigger:hidden"}),(0,iN.jsx)(gP.default,{"data-slot":"accordion-trigger-icon",className:"pointer-events-none hidden shrink-0 group-aria-expanded/accordion-trigger:inline"})]})})}function gW({className:e,children:i,...n}){return(0,iN.jsx)(gI.Panel,{"data-slot":"accordion-content",className:"overflow-hidden text-sm data-open:animate-accordion-down data-closed:animate-accordion-up",...n,children:(0,iN.jsx)("div",{className:(0,nQ.cn)("h-(--accordion-panel-height) pt-0 pb-2.5 data-ending-style:h-0 data-starting-style:h-0 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground [&_p:not(:last-child)]:mb-4",e),children:i})})}let gH=(0,iM.memo)(({className:e,...i})=>(0,iN.jsx)("div",{className:(0,nQ.cn)("not-prose w-full rounded-md border",e),...i})),g$=(0,iM.memo)(({className:e,name:i,model:n,...r})=>(0,iN.jsx)("div",{className:(0,nQ.cn)("flex w-full items-center justify-between gap-4 p-3",e),...r,children:(0,iN.jsxs)("div",{className:"flex items-center gap-2",children:[(0,iN.jsx)(gn.default,{className:"size-4 text-muted-foreground"}),(0,iN.jsx)("span",{className:"font-medium text-sm",children:i}),n&&(0,iN.jsx)(hP.Badge,{className:"font-mono text-xs",variant:"secondary",children:n})]})})),gU=(0,iM.memo)(({className:e,...i})=>(0,iN.jsx)("div",{className:(0,nQ.cn)("space-y-4 p-4 pt-0",e),...i})),gV=(0,iM.memo)(({className:e,children:i,...n})=>{let r=(0,n0.useTranslations)("chat");return(0,iN.jsxs)("div",{className:(0,nQ.cn)("space-y-2",e),...n,children:[(0,iN.jsx)("span",{className:"font-medium text-muted-foreground text-sm",children:r("subagent.instructions")}),(0,iN.jsx)("div",{className:"rounded-md bg-muted/50 p-3 text-muted-foreground text-sm",children:(0,iN.jsx)("p",{children:i})})]})}),gq=(0,iM.memo)(({className:e,...i})=>{let n=(0,n0.useTranslations)("chat");return(0,iN.jsxs)("div",{className:(0,nQ.cn)("space-y-2",e),children:[(0,iN.jsx)("span",{className:"font-medium text-muted-foreground text-sm",children:n("subagent.tools")}),(0,iN.jsx)(gB,{className:"rounded-md border",multiple:!0,...i})]})}),gY=(0,iM.memo)(({className:e,tool:i,value:n,...r})=>{let s="jsonSchema"in i&&i.jsonSchema?i.jsonSchema:i.inputSchema,o=(0,n0.useTranslations)("chat");return(0,iN.jsxs)(gz,{className:(0,nQ.cn)("border-b last:border-b-0",e),value:n,...r,children:[(0,iN.jsx)(gF,{className:"px-3 py-2 text-sm hover:no-underline",children:i.description??o("subagent.noDescription")}),(0,iN.jsx)(gW,{className:"px-3 pb-3",children:(0,iN.jsx)("div",{className:"rounded-md bg-muted/50",children:(0,iN.jsx)("pre",{className:"overflow-auto p-3 font-mono text-xs",children:JSON.stringify(s,null,2)})})})]})}),gK=(0,iM.memo)(({className:e,schema:i,...n})=>{let r=(0,n0.useTranslations)("chat");return(0,iN.jsxs)("div",{className:(0,nQ.cn)("space-y-2",e),...n,children:[(0,iN.jsx)("span",{className:"font-medium text-muted-foreground text-sm",children:r("subagent.outputSchema")}),(0,iN.jsx)("div",{className:"rounded-md bg-muted/50",children:(0,iN.jsx)("pre",{className:"overflow-auto p-3 font-mono text-xs",children:i})})]})});gH.displayName="Agent",g$.displayName="AgentHeader",gU.displayName="AgentContent",gV.displayName="AgentInstructions",gq.displayName="AgentTools",gY.displayName="AgentTool",gK.displayName="AgentOutput";var dR=dR;let gX=(0,nL.default)("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]),gJ=(0,nL.default)("image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]),gG=(0,nL.default)("music-2",[["circle",{cx:"8",cy:"18",r:"4",key:"1fc0mg"}],["path",{d:"M12 18V2l7 4",key:"g04rme"}]]),gZ=(0,nL.default)("paperclip",[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]]),gQ=(0,nL.default)("video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]);var g0=e.i(422373);e.s([],339090),e.i(339090);var g1=e.i(166392),g2=e.i(538501),g5=e.i(427396),g3=e.i(389124);let g4=iM.createContext(void 0);function g6(e){let i=iM.useContext(g4);if(void 0===i&&!e)throw Error((0,gl.default)(50));return i}var g8=e.i(332976),g9=e.i(493696),g7=e.i(549154),ve=e.i(695011),vt=e.i(561213),vi=e.i(107164);let vn={...ve.popupStoreSelectors,instantType:(0,g8.createSelector)(e=>e.instantType),hasViewport:(0,g8.createSelector)(e=>e.hasViewport)};class vr extends g9.ReactStore{constructor(e){super({...(0,ve.createInitialPopupStoreState)(),instantType:void 0,hasViewport:!1,...e},{popupRef:iM.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:new vt.PopupTriggerMap,closeDelayRef:{current:300}},vn)}setOpen=(e,i)=>{let n=i.reason,r=n===h3.REASONS.triggerHover,s=e&&n===h3.REASONS.triggerFocus,o=!e&&(n===h3.REASONS.triggerPress||n===h3.REASONS.escapeKey);if(i.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},this.context.onOpenChange?.(e,i),i.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,i);let a=()=>{let r={open:e};s?r.instantType="focus":o?r.instantType="dismiss":n===h3.REASONS.triggerHover&&(r.instantType=void 0);let a=i.trigger?.id??null;(a||e)&&(r.activeTriggerId=a,r.activeTriggerElement=i.trigger??null),this.update(r)};r?iR.flushSync(a):a()};static useStore(e,i){let n=(0,g7.useRefWithInit)(()=>new vr(i)).current,r=e??n,s=(0,vi.useSyncedFloatingRootContext)({popupStore:r,onOpenChange:r.setOpen});return r.state.floatingRootContext=s,r}}var vs=e.i(279501);function vo(e){let{open:i,defaultOpen:n=!1,onOpenChange:r,onOpenChangeComplete:s,actionsRef:o,handle:a,triggerId:l,defaultTriggerId:c=null,children:h}=e,d=vr.useStore(a?.store,{open:n,openProp:i,activeTriggerId:c,triggerIdProp:l});(0,g1.useOnFirstRender)(()=>{void 0===i&&!1===d.state.open&&!0===n&&d.update({open:!0,activeTriggerId:c})}),d.useControlledProp("openProp",i),d.useControlledProp("triggerIdProp",l),d.useContextCallback("onOpenChange",r),d.useContextCallback("onOpenChangeComplete",s);let u=d.useState("open"),p=d.select("floatingRootContext"),f=d.useState("activeTriggerId"),m=d.useState("payload");(0,vs.useImplicitActiveTrigger)(d);let{forceUnmount:g}=(0,vs.useOpenStateTransitions)(u,d);(0,gE.useIsoLayoutEffect)(()=>{u&&null==f&&d.set("payload",void 0)},[d,f,u]);let v=iM.useCallback(()=>{d.setOpen(!1,(0,h2.createChangeEventDetails)(h3.REASONS.imperativeAction))},[d]);iM.useImperativeHandle(o,()=>({unmount:g,close:v}),[g,v]);let y=(0,g2.useDismiss)(p),{getReferenceProps:_,getTriggerProps:b,getFloatingProps:w}=(0,g5.useInteractions)([y]),S=iM.useMemo(()=>_(),[_]),k=iM.useMemo(()=>b(),[b]),C=iM.useMemo(()=>w(),[w]);return d.useSyncedValues({activeTriggerProps:S,inactiveTriggerProps:k,popupProps:C}),(0,iN.jsx)(g4.Provider,{value:d,children:"function"==typeof h?h({payload:m}):h})}let va=iM.createContext(void 0);var vl=e.i(384389);let vc=iM.forwardRef(function(e,i){let{keepMounted:n=!1,...r}=e;return g6().useState("mounted")||n?(0,iN.jsx)(va.Provider,{value:n,children:(0,iN.jsx)(vl.FloatingPortalLite,{ref:i,...r})}):null});var vh=e.i(499198),vd=e.i(604921),vu=e.i(480283);let vp=iM.forwardRef(function(e,i){let{render:n,className:r,delay:s,closeDelay:o,id:a,payload:l,handle:c,style:h,...d}=e,u=g6(!0),p=c?.store??u;if(!p)throw Error((0,gl.default)(89));let f=(0,gf.useBaseUiId)(a),m=p.useState("isTriggerActive",f),g=p.useState("isOpenedByTrigger",f),v=p.useState("floatingRootContext"),y=iM.useRef(null),_=s??600,b=o??300,{registerTrigger:w,isMountedByThisTrigger:S}=(0,vs.useTriggerDataForwarding)(f,y,p,{payload:l});(0,gE.useIsoLayoutEffect)(()=>{S&&(p.context.closeDelayRef.current=b)},[p,S,b]);let k=(0,vu.useHoverReferenceInteraction)(v,{mouseOnly:!0,move:!1,handleClose:(0,vh.safePolygon)(),delay:()=>({open:_,close:b}),triggerElementRef:y,isActiveTrigger:m,isClosing:()=>"ending"===p.select("transitionStatus")}),C=(0,vd.useFocus)(v,{delay:_}),T=p.useState("triggerProps",S);return(0,h1.useRenderElement)("a",e,{state:{open:g},ref:[i,w,y],props:[k,C.reference,T,{id:f},d],stateAttributesMapping:h5.triggerOpenStateMapping})}),vf=iM.createContext(void 0);function vm(){let e=iM.useContext(vf);if(void 0===e)throw Error((0,gl.default)(49));return e}var vg=e.i(576557),vv=e.i(576487),vy=e.i(909852),v_=e.i(263635);let vb=iM.forwardRef(function(e,i){let{render:n,className:r,anchor:s,positionMethod:o="absolute",side:a="bottom",align:l="center",sideOffset:c=0,alignOffset:h=0,collisionBoundary:d="clipping-ancestors",collisionPadding:u=5,arrowPadding:p=5,sticky:f=!1,disableAnchorTracking:m=!1,collisionAvoidance:g=vv.POPUP_COLLISION_AVOIDANCE,style:v,...y}=e,_=g6(),b=function(){let e=iM.useContext(va);if(void 0===e)throw Error((0,gl.default)(48));return e}(),w=(0,g3.useFloatingNodeId)(),S=_.useState("open"),k=_.useState("mounted"),C=_.useState("floatingRootContext"),T=_.useState("instantType"),E=_.useState("transitionStatus"),N=_.useState("hasViewport"),M=(0,vg.useAnchorPositioning)({anchor:s,floatingRootContext:C,positionMethod:o,mounted:k,side:a,sideOffset:c,align:l,alignOffset:h,arrowPadding:p,collisionBoundary:d,collisionPadding:u,sticky:f,disableAnchorTracking:m,keepMounted:b,nodeId:w,collisionAvoidance:g,adaptiveOrigin:N?vy.adaptiveOrigin:void 0}),O={open:S,side:M.side,align:M.align,anchorHidden:M.anchorHidden,instant:T},A=(0,v_.usePositioner)(e,O,{styles:M.positionerStyles,transitionStatus:E,props:y,refs:[i,_.useStateSetter("positionerElement")],hidden:!k,inert:!S});return(0,iN.jsx)(vf.Provider,{value:M,children:(0,iN.jsx)(g3.FloatingNode,{id:w,children:A})})});var vx=e.i(328657),vw=e.i(795914);let vS={...h5.popupStateMapping,...gx.transitionStatusMapping},vk=iM.forwardRef(function(e,i){let{className:n,render:r,style:s,...o}=e,a=g6(),{side:l,align:c}=vm(),h=a.useState("open"),d=a.useState("instantType"),u=a.useState("transitionStatus"),p=a.useState("popupProps"),f=a.useState("floatingRootContext");(0,gL.useOpenChangeComplete)({open:h,ref:a.context.popupRef,onComplete(){h&&a.context.onOpenChangeComplete?.(!0)}});let m=(0,gs.useStableCallback)(()=>a.context.closeDelayRef.current);return(0,vw.useHoverFloatingInteraction)(f,{closeDelay:m}),(0,h1.useRenderElement)("div",e,{state:{open:h,side:l,align:c,instant:d,transitionStatus:u},ref:[i,a.context.popupRef,a.useStateSetter("popupElement")],props:[p,(0,vx.getDisabledMountTransitionStyles)(u),o],stateAttributesMapping:vS})}),vC=iM.forwardRef(function(e,i){let{render:n,className:r,style:s,...o}=e,a=g6(),{arrowRef:l,side:c,align:h,arrowUncentered:d,arrowStyles:u}=vm(),p=a.useState("open");return(0,h1.useRenderElement)("div",e,{state:{open:p,side:c,align:h,uncentered:d},ref:[l,i],props:[{style:u,"aria-hidden":!0},o],stateAttributesMapping:h5.popupStateMapping})}),vT={...h5.popupStateMapping,...gx.transitionStatusMapping},vE=iM.forwardRef(function(e,i){let{render:n,className:r,style:s,...o}=e,a=g6(),l=a.useState("open"),c=a.useState("mounted"),h=a.useState("transitionStatus");return(0,h1.useRenderElement)("div",e,{state:{open:l,transitionStatus:h},ref:[i],props:[{role:"presentation",hidden:!c,style:{pointerEvents:"none",userSelect:"none",WebkitUserSelect:"none"}},o],stateAttributesMapping:vT})}),vN=((Dl={}).popupWidth="--popup-width",Dl.popupHeight="--popup-height",Dl);var vM=e.i(3310);let vO={activationDirection:e=>e?{"data-activation-direction":e}:null},vA=iM.forwardRef(function(e,i){let{render:n,className:r,style:s,children:o,...a}=e,l=g6(),c=vm(),h=l.useState("instantType"),{children:d,state:u}=(0,vM.usePopupViewport)({store:l,side:c.side,cssVars:vN,children:o}),p={activationDirection:u.activationDirection,transitioning:u.transitioning,instant:h};return(0,h1.useRenderElement)("div",e,{state:p,ref:i,props:[a,{children:d}],stateAttributesMapping:vO})});class vR{constructor(){this.store=new vr}open(e){let i=e?this.store.context.triggerElements.getById(e):void 0;if(e&&!i)throw Error((0,gl.default)(88,e));this.store.setOpen(!0,(0,h2.createChangeEventDetails)(h3.REASONS.imperativeAction,void 0,i))}close(){this.store.setOpen(!1,(0,h2.createChangeEventDetails)(h3.REASONS.imperativeAction,void 0,void 0))}get isOpen(){return this.store.state.open}}e.s(["Arrow",0,vC,"Backdrop",0,vE,"Handle",0,vR,"Popup",0,vk,"Portal",0,vc,"Positioner",0,vb,"Root",0,function(e){return g6(!0)?(0,iN.jsx)(vo,{...e}):(0,iN.jsx)(g3.FloatingTree,{children:(0,iN.jsx)(vo,{...e})})},"Trigger",0,vp,"Viewport",0,vA,"createHandle",0,function(){return new vR}],981923);var vD=e.i(981923),vD=vD;function vL({openDelay:e,closeDelay:i,...n}){return(0,iN.jsx)(vD.Root,{"data-slot":"hover-card",...n})}function vj({delay:e=0,closeDelay:i=0,...n}){return(0,iN.jsx)(vD.Trigger,{"data-slot":"hover-card-trigger",delay:e,closeDelay:i,...n})}function vI({className:e,side:i="bottom",sideOffset:n=6,align:r="center",alignOffset:s=0,children:o,...a}){return(0,iN.jsx)(vD.Portal,{children:(0,iN.jsx)(vD.Positioner,{align:r,alignOffset:s,side:i,sideOffset:n,className:"isolate z-50",children:(0,iN.jsx)(vD.Popup,{"data-slot":"hover-card-content",className:(0,nQ.cn)("z-50 rounded-lg border bg-popover p-3 text-popover-foreground shadow-md outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...a,children:o})})})}let vP=e=>{if("source-document"===e.type)return"source";let i=e.mediaType??"";return i.startsWith("image/")?"image":i.startsWith("video/")?"video":i.startsWith("audio/")?"audio":i.startsWith("application/")||i.startsWith("text/")?"document":"unknown"},vB=(0,iM.createContext)(null),vz=(0,iM.createContext)(null),vF=()=>{let e=(0,iM.useContext)(vz);if(!e)throw Error("Attachment components must be used within <Attachment>");return e},vW=({variant:e="grid",className:i,children:n,...r})=>{let s=(0,iM.useMemo)(()=>({variant:e}),[e]);return(0,iN.jsx)(vB.Provider,{value:s,children:(0,iN.jsx)("div",{className:(0,nQ.cn)("flex items-start","list"===e?"flex-col gap-2":"flex-wrap gap-2","grid"===e&&"ml-auto w-fit",i),...r,children:n})})},vH=({data:e,onRemove:i,className:n,children:r,...s})=>{let{variant:o}=(0,iM.useContext)(vB)??{variant:"grid"},a=vP(e),l=(0,iM.useMemo)(()=>({data:e,mediaCategory:a,onRemove:i,variant:o}),[e,a,i,o]);return(0,iN.jsx)(vz.Provider,{value:l,children:(0,iN.jsx)("div",{className:(0,nQ.cn)("group relative","grid"===o&&"size-24 overflow-hidden rounded-lg","inline"===o&&["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"],"list"===o&&["flex w-full items-center gap-3 rounded-lg border p-3","hover:bg-accent/50"],n),...s,children:r})})},v$=({fallbackIcon:e,className:i,...n})=>{let{data:r,mediaCategory:s,variant:o}=vF(),a="inline"===o?"size-3":"size-4";return(0,iN.jsx)("div",{className:(0,nQ.cn)("flex shrink-0 items-center justify-center overflow-hidden","grid"===o&&"size-full bg-muted","inline"===o&&"size-5 rounded bg-background","list"===o&&"size-12 rounded bg-muted",i),...n,children:(()=>{if("image"===s&&"file"===r.type&&r.url){let e,i;return e=r.url,i=r.filename,"grid"===o?(0,iN.jsx)("img",{alt:i||"Image",className:"size-full object-cover",height:96,src:e,width:96}):(0,iN.jsx)("img",{alt:i||"Image",className:"size-full rounded object-cover",height:20,src:e,width:20})}if("video"===s&&"file"===r.type&&r.url)return(0,iN.jsx)("video",{className:"size-full object-cover",muted:!0,src:r.url});let i={image:gJ,video:gQ,audio:gG,source:gX,document:dR.default,unknown:gZ}[s];return e??(0,iN.jsx)(i,{className:(0,nQ.cn)(a,"text-muted-foreground")})})()})},vU=({showMediaType:e=!1,className:i,...n})=>{let{data:r,variant:s}=vF(),o=function(e){let i=(0,n0.useTranslations)("chat");if("source-document"===e.type)return e.title||e.filename||i("attachments.source");let n=vP(e);return e.filename||i("image"===n?"attachments.image":"attachments.attachment")}(r);return"grid"===s?null:(0,iN.jsxs)("div",{className:(0,nQ.cn)("min-w-0 flex-1",i),...n,children:[(0,iN.jsx)("span",{className:"block truncate",children:o}),e&&r.mediaType&&(0,iN.jsx)("span",{className:"block truncate text-muted-foreground text-xs",children:r.mediaType})]})},vV=({label:e,className:i,children:n,...r})=>{let{onRemove:s,variant:o}=vF(),a=(0,n0.useTranslations)("chat"),l=e??a("attachments.remove");return s?(0,iN.jsxs)(hv.Button,{"aria-label":l,className:(0,nQ.cn)("grid"===o&&["absolute top-2 right-2 size-6 rounded-full p-0","bg-background/80 backdrop-blur-sm","opacity-0 transition-opacity group-hover:opacity-100","hover:bg-background","[&>svg]:size-3"],"inline"===o&&["size-5 rounded p-0","opacity-0 transition-opacity group-hover:opacity-100","[&>svg]:size-2.5"],"list"===o&&["size-8 shrink-0 rounded p-0","[&>svg]:size-4"],i),onClick:e=>{e.stopPropagation(),s()},type:"button",variant:"ghost",...r,children:[n??(0,iN.jsx)(g0.XIcon,{}),(0,iN.jsx)("span",{className:"sr-only",children:l})]}):null};function vq({className:e,...i}){return(0,iN.jsx)("div",{"data-slot":"alert",role:"alert",className:(0,nQ.cn)("rounded-lg border bg-background p-3 text-sm",e),...i})}function vY({className:e,...i}){return(0,iN.jsx)("div",{"data-slot":"alert-description",className:(0,nQ.cn)("text-muted-foreground",e),...i})}let vK=(0,iM.createContext)(null),vX=()=>{let e=(0,iM.useContext)(vK);if(!e)throw Error("Confirmation components must be used within Confirmation");return e},vJ=({className:e,approval:i,state:n,...r})=>i&&"input-streaming"!==n&&"input-available"!==n?(0,iN.jsx)(vK.Provider,{value:{approval:i,state:n},children:(0,iN.jsx)(vq,{className:(0,nQ.cn)("flex flex-col gap-2",e),...r})}):null,vG=({className:e,...i})=>(0,iN.jsx)(vY,{className:(0,nQ.cn)("inline",e),...i}),vZ=({children:e})=>{let{state:i}=vX();return"approval-requested"!==i?null:e},vQ=({children:e})=>{let{approval:i,state:n}=vX();return i?.approved&&("approval-responded"===n||"output-denied"===n||"output-available"===n)?e:null},v0=({children:e})=>{let{approval:i,state:n}=vX();return i?.approved!==!1||"approval-responded"!==n&&"output-denied"!==n&&"output-available"!==n?null:e},v1=({className:e,...i})=>{let{state:n}=vX();return"approval-requested"!==n?null:(0,iN.jsx)("div",{className:(0,nQ.cn)("flex items-center justify-end gap-2 self-end",e),...i})},v2=e=>(0,iN.jsx)(hv.Button,{className:"h-8 px-3 text-sm",type:"button",...e});var v5=e.i(660748);let v3=(0,iM.createContext)(null),v4=()=>{let e=(0,iM.useContext)(v3);if(!e)throw Error("Context components must be used within Context");return e},v6=({usedTokens:e,maxTokens:i,usage:n,modelId:r,...s})=>(0,iN.jsx)(v3.Provider,{value:{usedTokens:e,maxTokens:i,usage:n,modelId:r},children:(0,iN.jsx)(vL,{closeDelay:0,openDelay:0,...s})}),v8=()=>{let{usedTokens:e,maxTokens:i}=v4(),n=2*Math.PI*10;return(0,iN.jsxs)("svg",{"aria-label":"Model context usage",height:"20",role:"img",style:{color:"currentcolor"},viewBox:"0 0 24 24",width:"20",children:[(0,iN.jsx)("circle",{cx:12,cy:12,fill:"none",opacity:"0.25",r:10,stroke:"currentColor",strokeWidth:2}),(0,iN.jsx)("circle",{cx:12,cy:12,fill:"none",opacity:"0.7",r:10,stroke:"currentColor",strokeDasharray:`${n} ${n}`,strokeDashoffset:n*(1-e/i),strokeLinecap:"round",strokeWidth:2,style:{transformOrigin:"center",transform:"rotate(-90deg)"}})]})},v9=({children:e,...i})=>{let{usedTokens:n,maxTokens:r}=v4(),s=new Intl.NumberFormat("en-US",{style:"percent",maximumFractionDigits:1}).format(n/r),o=(0,iM.isValidElement)(e)?e:void 0;return(0,iN.jsx)(vj,{render:o??(0,iN.jsx)(hv.Button,{type:"button",variant:"ghost",...i}),children:o?null:(0,iN.jsxs)(iN.Fragment,{children:[(0,iN.jsx)("span",{className:"font-medium text-muted-foreground",children:s}),(0,iN.jsx)(v8,{})]})})},v7=({className:e,...i})=>(0,iN.jsx)(vI,{className:(0,nQ.cn)("min-w-60 divide-y overflow-hidden p-0",e),...i}),ye=({children:e,className:i,...n})=>{let{usedTokens:r,maxTokens:s}=v4(),o=r/s,a=new Intl.NumberFormat("en-US",{style:"percent",maximumFractionDigits:1}).format(o),l=new Intl.NumberFormat("en-US",{notation:"compact"}).format(r),c=new Intl.NumberFormat("en-US",{notation:"compact"}).format(s);return(0,iN.jsx)("div",{className:(0,nQ.cn)("w-full space-y-2 p-3",i),...n,children:e??(0,iN.jsxs)(iN.Fragment,{children:[(0,iN.jsxs)("div",{className:"flex items-center justify-between gap-3 text-xs",children:[(0,iN.jsx)("p",{children:a}),(0,iN.jsxs)("p",{className:"font-mono text-muted-foreground",children:[l," / ",c]})]}),(0,iN.jsx)("div",{className:"space-y-2",children:(0,iN.jsx)(v5.Progress,{className:"bg-muted",value:100*o})})]})})},yt=({children:e,className:i,...n})=>(0,iN.jsx)("div",{className:(0,nQ.cn)("w-full p-3",i),...n,children:e}),yi=({children:e,className:i,...n})=>{let{modelId:r,usage:s}=v4(),o=(0,n0.useTranslations)("chat"),a=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format((void 0)??0);return(0,iN.jsx)("div",{className:(0,nQ.cn)("flex w-full items-center justify-between gap-3 bg-secondary p-3 text-xs",i),...n,children:e??(0,iN.jsxs)(iN.Fragment,{children:[(0,iN.jsx)("span",{className:"text-muted-foreground",children:o("context.totalCost")}),(0,iN.jsx)("span",{children:a})]})})},yn=({className:e,children:i,...n})=>{let{usage:r,modelId:s}=v4(),o=(0,n0.useTranslations)("chat"),a=r?.inputTokens??0;if(i)return i;if(!a)return null;let l=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format((void 0)??0);return(0,iN.jsxs)("div",{className:(0,nQ.cn)("flex items-center justify-between text-xs",e),...n,children:[(0,iN.jsx)("span",{className:"text-muted-foreground",children:o("context.input")}),(0,iN.jsx)(ya,{costText:l,tokens:a})]})},yr=({className:e,children:i,...n})=>{let{usage:r,modelId:s}=v4(),o=(0,n0.useTranslations)("chat"),a=r?.outputTokens??0;if(i)return i;if(!a)return null;let l=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format((void 0)??0);return(0,iN.jsxs)("div",{className:(0,nQ.cn)("flex items-center justify-between text-xs",e),...n,children:[(0,iN.jsx)("span",{className:"text-muted-foreground",children:o("context.output")}),(0,iN.jsx)(ya,{costText:l,tokens:a})]})},ys=({className:e,children:i,...n})=>{let{usage:r,modelId:s}=v4(),o=(0,n0.useTranslations)("chat"),a=r?.reasoningTokens??0;if(i)return i;if(!a)return null;let l=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format((void 0)??0);return(0,iN.jsxs)("div",{className:(0,nQ.cn)("flex items-center justify-between text-xs",e),...n,children:[(0,iN.jsx)("span",{className:"text-muted-foreground",children:o("context.reasoning")}),(0,iN.jsx)(ya,{costText:l,tokens:a})]})},yo=({className:e,children:i,...n})=>{let{usage:r,modelId:s}=v4(),o=(0,n0.useTranslations)("chat"),a=r?.cachedInputTokens??0;if(i)return i;if(!a)return null;let l=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format((void 0)??0);return(0,iN.jsxs)("div",{className:(0,nQ.cn)("flex items-center justify-between text-xs",e),...n,children:[(0,iN.jsx)("span",{className:"text-muted-foreground",children:o("context.cache")}),(0,iN.jsx)(ya,{costText:l,tokens:a})]})},ya=({tokens:e,costText:i})=>(0,iN.jsxs)("span",{children:[void 0===e?"—":new Intl.NumberFormat("en-US",{notation:"compact"}).format(e),i?(0,iN.jsxs)("span",{className:"ml-2 text-muted-foreground",children:["• ",i]}):null]});var yl=e.i(757106),yl=yl;let yc=(0,nL.default)("dot",[["circle",{cx:"12.1",cy:"12.1",r:"1",key:"18d7e5"}]]),yh=(0,iM.createContext)(null),yd=()=>{let e=(0,iM.useContext)(yh);if(!e)throw Error("ChainOfThought components must be used within ChainOfThought");return e},yu=(0,iM.memo)(({className:e,open:i,defaultOpen:n=!1,onOpenChange:r,children:s,...o})=>{let[a,l]=(0,iM.useState)(n),c=i??a,h=(0,iM.useCallback)(e=>{void 0===i&&l(e),r?.(e)},[r,i]),d=(0,iM.useMemo)(()=>({isOpen:c,setIsOpen:h}),[c,h]);return(0,iN.jsx)(yh.Provider,{value:d,children:(0,iN.jsx)("div",{className:(0,nQ.cn)("not-prose max-w-prose space-y-4",e),...o,children:s})})}),yp=(0,iM.memo)(({className:e,children:i,loading:n,...r})=>{let{isOpen:s,setIsOpen:o}=yd(),a=(0,n0.useTranslations)("chat");return(0,iN.jsx)(nZ.Collapsible,{onOpenChange:o,open:s,children:(0,iN.jsxs)(nZ.CollapsibleTrigger,{className:(0,nQ.cn)("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",e),...r,children:[(0,iN.jsx)(yl.default,{className:"size-4"}),(0,iN.jsx)("span",{className:"flex-1 text-left",children:i??a("chainOfThought.defaultHeader")}),n&&(0,iN.jsx)(m9,{size:14}),(0,iN.jsx)(dM.ChevronDownIcon,{className:(0,nQ.cn)("size-4 transition-transform",s?"rotate-180":"rotate-0")})]})})}),yf=(0,iM.memo)(({className:e,icon:i=yc,label:n,description:r,status:s="complete",children:o,...a})=>(0,iN.jsxs)("div",{className:(0,nQ.cn)("flex gap-2 text-sm",{complete:"text-muted-foreground",active:"text-foreground",pending:"text-muted-foreground/50"}[s],"fade-in-0 slide-in-from-top-2 animate-in",e),...a,children:[(0,iN.jsxs)("div",{className:"relative mt-0.5",children:[(0,iN.jsx)(i,{className:"size-4"}),(0,iN.jsx)("div",{className:"-mx-px absolute top-7 bottom-0 left-1/2 w-px bg-border"})]}),(0,iN.jsxs)("div",{className:"flex-1 space-y-2",children:[(0,iN.jsx)("div",{children:n}),r&&(0,iN.jsx)("div",{className:"text-muted-foreground text-xs",children:r}),o]})]})),ym=(0,iM.memo)(({className:e,...i})=>(0,iN.jsx)("div",{className:(0,nQ.cn)("flex flex-wrap items-center gap-2",e),...i})),yg=(0,iM.memo)(({className:e,children:i,...n})=>(0,iN.jsx)(hP.Badge,{className:(0,nQ.cn)("gap-1 px-2 py-0.5 font-normal text-xs",e),variant:"secondary",...n,children:i})),yv=(0,iM.memo)(({className:e,children:i,...n})=>{let{isOpen:r}=yd();return(0,iN.jsx)(nZ.Collapsible,{open:r,children:(0,iN.jsx)(nZ.CollapsibleContent,{className:(0,nQ.cn)("mt-2 space-y-3","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",e),...n,children:i})})}),yy=(0,iM.memo)(({className:e,children:i,caption:n,...r})=>(0,iN.jsxs)("div",{className:(0,nQ.cn)("mt-2 space-y-2",e),...r,children:[(0,iN.jsx)("div",{className:"relative flex max-h-[22rem] items-center justify-center overflow-hidden rounded-lg bg-muted p-3",children:i}),n&&(0,iN.jsx)("p",{className:"text-muted-foreground text-xs",children:n})]}));yu.displayName="ChainOfThought",yp.displayName="ChainOfThoughtHeader",yf.displayName="ChainOfThoughtStep",ym.displayName="ChainOfThoughtSearchResults",yg.displayName="ChainOfThoughtSearchResult",yv.displayName="ChainOfThoughtContent",yy.displayName="ChainOfThoughtImage";var dA=dA,y_=e.i(288556),y_=y_,yb=e.i(341807);let yx=(0,iM.memo)(({children:e,as:i="p",className:n,duration:r=2,spread:s=2})=>{let o=(0,iM.useMemo)(()=>(e?.length??0)*s,[e,s]);return(0,iN.jsx)(i,{children:(0,iN.jsx)(yb.motion.span,{animate:{backgroundPosition:"0% center"},className:(0,nQ.cn)("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:1/0,duration:r,ease:"linear"},children:e})})}),yw=(0,iM.createContext)({output:"",isStreaming:!1,autoScroll:!0}),yS=({output:e,isStreaming:i=!1,autoScroll:n=!0,onClear:r,className:s,children:o,...a})=>(0,iN.jsx)(yw.Provider,{value:{output:e,isStreaming:i,autoScroll:n,onClear:r},children:(0,iN.jsx)("div",{className:(0,nQ.cn)("flex flex-col overflow-hidden rounded-lg border bg-zinc-950 text-zinc-100",s),...a,children:o??(0,iN.jsxs)(iN.Fragment,{children:[(0,iN.jsxs)(yk,{children:[(0,iN.jsx)(yC,{}),(0,iN.jsxs)("div",{className:"flex items-center gap-1",children:[(0,iN.jsx)(yT,{}),(0,iN.jsxs)(yE,{children:[(0,iN.jsx)(yN,{}),r&&(0,iN.jsx)(yM,{})]})]})]}),(0,iN.jsx)(yO,{})]})})}),yk=({className:e,children:i,...n})=>(0,iN.jsx)("div",{className:(0,nQ.cn)("flex items-center justify-between border-zinc-800 border-b px-4 py-2",e),...n,children:i}),yC=({className:e,children:i,...n})=>{let r=(0,n0.useTranslations)("chat");return(0,iN.jsxs)("div",{className:(0,nQ.cn)("flex items-center gap-2 text-sm text-zinc-400",e),...n,children:[(0,iN.jsx)(rC,{className:"size-4"}),i??r("terminal.title")]})},yT=({className:e,children:i,...n})=>{let{isStreaming:r}=(0,iM.useContext)(yw),s=(0,n0.useTranslations)("chat");return r?(0,iN.jsx)("div",{className:(0,nQ.cn)("flex items-center gap-2 text-xs text-zinc-400",e),...n,children:i??(0,iN.jsx)(yx,{className:"w-16",children:s("terminal.running")})}):null},yE=({className:e,children:i,...n})=>(0,iN.jsx)("div",{className:(0,nQ.cn)("flex items-center gap-1",e),...n,children:i}),yN=({onCopy:e,onError:i,timeout:n=2e3,children:r,className:s,...o})=>{let[a,l]=(0,iM.useState)(!1),{output:c}=(0,iM.useContext)(yw),h=(0,n0.useTranslations)("chat"),d=async()=>{if(!navigator?.clipboard?.writeText)return void i?.(Error(h("terminal.clipboardUnavailable")));try{await navigator.clipboard.writeText(c),l(!0),e?.(),setTimeout(()=>l(!1),n)}catch(e){i?.(e)}},u=a?dg.CheckIcon:dA.default;return(0,iN.jsx)(hv.Button,{className:(0,nQ.cn)("size-7 shrink-0 text-zinc-400 hover:bg-zinc-800 hover:text-zinc-100",s),onClick:d,size:"icon",variant:"ghost",...o,children:r??(0,iN.jsx)(u,{size:14})})},yM=({children:e,className:i,...n})=>{let{onClear:r}=(0,iM.useContext)(yw);return r?(0,iN.jsx)(hv.Button,{className:(0,nQ.cn)("size-7 shrink-0 text-zinc-400 hover:bg-zinc-800 hover:text-zinc-100",i),onClick:r,size:"icon",variant:"ghost",...n,children:e??(0,iN.jsx)(y_.default,{size:14})}):null},yO=({className:e,children:i,...n})=>{let{output:r,isStreaming:s,autoScroll:o}=(0,iM.useContext)(yw),a=(0,iM.useRef)(null);return(0,iM.useEffect)(()=>{o&&a.current&&(a.current.scrollTop=a.current.scrollHeight)},[r,o]),(0,iN.jsx)("div",{className:(0,nQ.cn)("max-h-96 overflow-auto p-4 font-mono text-sm leading-relaxed",e),ref:a,...n,children:i??(0,iN.jsxs)("pre",{className:"whitespace-pre-wrap break-words",children:[r.replace(/\u001b\[[0-9;]*m/g,""),s&&(0,iN.jsx)("span",{className:"ml-0.5 inline-block h-4 w-2 animate-pulse bg-zinc-100"})]})})};function yA(){let e=(0,n0.useTranslations)("chat");return(0,iN.jsx)("div",{className:"flex h-full items-center justify-center text-muted-foreground text-xs",children:e("readonlyCodeBlock.loading")})}let yR=(0,rd.default)(()=>e.A(863812).then(e=>e.default),{loadableGenerated:{modules:[158480]},ssr:!1,loading:()=>(0,iN.jsx)(yA,{})});function yD({value:e,language:i="plaintext",title:n,height:r=220}){let{resolvedTheme:s}=(0,rf.useTheme)();return(0,iN.jsxs)("div",{className:"overflow-hidden rounded-md border bg-background",children:[n?(0,iN.jsx)("div",{className:"border-b bg-muted/30 px-2 py-1 font-mono text-muted-foreground text-xs",children:n}):null,(0,iN.jsx)("div",{style:{height:r},children:(0,iN.jsx)(yR,{height:"100%",language:i,value:e,options:{readOnly:!0,domReadOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:12,lineNumbers:"on",renderLineHighlight:"none",wordWrap:"on",folding:!1,overviewRulerLanes:0},theme:"dark"===s?"vs-dark":"vs"})})]})}function yL({message:e,isUser:i,workspaceId:n}){let r=(0,n0.useTranslations)("chat"),s=e.parts??[],o=s.filter(e=>"context"!==e.type),a=o.some(e=>"text"===e.type),l=0===s.length&&e.content;return(0,iN.jsxs)("div",{className:"space-y-3",children:[e.attachments?.length?(0,iN.jsx)(yq,{attachments:e.attachments,isUser:i}):null,o.length>0?o.map(i=>(0,iN.jsx)(yB,{part:function(e){if("text"!==e.type)return e;let i=yI(e.text);return i===e.text?e:{...e,text:i}}(i),message:e,workspaceId:n},i.id)):null,!a&&l?i?(0,iN.jsx)(yY,{content:e.content}):(0,iN.jsx)(m6,{content:yI(e.content)}):null,"pending"===e.status&&0===o.length?(0,iN.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground",children:[(0,iN.jsx)(m9,{size:14}),(0,iN.jsx)("span",{children:r("messageParts.agentProcessing")})]}):null]})}function yj({message:e}){let i=e.parts?.find(e=>"context"===e.type),n=(0,m7.useLLMStore)(e=>e.models),r=(0,m7.useLLMStore)(e=>e.ensure),s=i?.modelId?n.find(e=>e.modelId===i.modelId||e.name===i.modelId):void 0,o=s?.maxContextTokens??i?.maxTokens;return((0,iM.useEffect)(()=>{i&&r()},[r,i]),i&&o)?(0,iN.jsxs)(v6,{usedTokens:i.usedTokens,maxTokens:o,modelId:i.modelId,usage:{inputTokens:i.usage?.inputTokens??0,outputTokens:i.usage?.outputTokens??0,totalTokens:i.usage?.totalTokens??i.usedTokens,cachedInputTokens:i.usage?.cachedInputTokens??0,reasoningTokens:i.usage?.reasoningTokens??0,inputTokenDetails:{noCacheTokens:void 0,cacheReadTokens:void 0,cacheWriteTokens:void 0},outputTokenDetails:{textTokens:void 0,reasoningTokens:void 0}},children:[(0,iN.jsx)(v9,{className:"h-5 gap-1 px-1.5 text-[10px]"}),(0,iN.jsxs)(v7,{children:[(0,iN.jsx)(ye,{}),(0,iN.jsxs)(yt,{className:"space-y-2",children:[(0,iN.jsx)(yn,{}),(0,iN.jsx)(yr,{}),(0,iN.jsx)(ys,{}),(0,iN.jsx)(yo,{})]}),(0,iN.jsx)(yi,{})]})]}):null}function yI(e){let i=[...e.split(/\r?\n/)];for(;i.length>1&&i.length%2==0;){let e=i.length/2,n=i.slice(0,e),r=i.slice(e);if(yP(n.join("\n"))!==yP(r.join("\n")))break;i=n}return i.join("\n")}function yP(e){return e.trim().replace(/\s+/g," ")}function yB({part:e,message:i,workspaceId:n}){let r=(0,n0.useTranslations)("chat");switch(e.type){case"text":return(0,iN.jsx)(m6,{content:e.text});case"reasoning":return(0,iN.jsxs)(yu,{defaultOpen:"streaming"===e.status,className:"max-w-none",children:[(0,iN.jsx)(yp,{loading:"streaming"===e.status,children:r("streaming"===e.status?"messageParts.agentThinking":"messageParts.aiIntermediateOutput")}),(0,iN.jsx)(yv,{className:"max-h-[300px] overflow-y-auto",children:(0,iN.jsx)(yf,{icon:dL,label:r("streaming"===e.status?"messageParts.streamingResponse":"messageParts.intermediateMessage"),status:"streaming"===e.status?"active":"complete",children:(0,iN.jsx)(m6,{content:e.text})})})]});case"chain":return(0,iN.jsxs)(yu,{defaultOpen:"pending"===i.status,className:"max-w-none",children:[(0,iN.jsx)(yp,{loading:"pending"===i.status||"streaming"===i.status,children:r("messageParts.chainSteps",{count:e.chains.length})}),(0,iN.jsx)(yv,{className:"max-h-[300px] overflow-y-auto",children:e.chains.map(e=>{let r="completed"===e.status;return"message"===e.kind?(0,iN.jsx)(yF,{text:e.text??e.title,status:r?"complete":"active"},e.id):(0,iN.jsx)(yW,{chain:e,message:i,workspaceId:n,status:r?"complete":"active"},e.id)})})]});case"terminal":return(0,iN.jsx)(yS,{output:e.command?`$ ${e.command}
|
|
23
|
+
${e.output}`:e.output,isStreaming:"streaming"===e.status,className:"error"===e.status?"border-destructive/40":void 0});case"confirmation":{var s,o;let i=(s=e.id,(o=e.approval)&&void 0!==o.approved?{id:o.id,approved:o.approved,reason:o.reason}:{id:o?.id??s});return(0,iN.jsxs)(vJ,{approval:i,state:void 0===i.approved?"approval-requested":"approval-responded",children:[(0,iN.jsxs)(vG,{children:[(0,iN.jsxs)(vZ,{children:[e.title,e.description?(0,iN.jsx)("span",{className:"block text-xs",children:e.description}):null]}),(0,iN.jsx)(vQ,{children:e.title}),(0,iN.jsx)(v0,{children:e.approval?.reason??e.title})]}),(0,iN.jsxs)(v1,{children:[(0,iN.jsx)(v2,{variant:"outline",children:r("messageParts.reject")}),(0,iN.jsx)(v2,{children:r("messageParts.approve")})]})]})}case"context":default:return null;case"subagent":return(0,iN.jsxs)(gH,{children:[(0,iN.jsx)(g$,{name:e.name,model:e.model}),e.instructions||e.output||e.tools?.length?(0,iN.jsxs)(gU,{children:[e.instructions?(0,iN.jsx)(gV,{children:e.instructions}):null,e.output?(0,iN.jsxs)("div",{className:"space-y-2",children:[(0,iN.jsx)("span",{className:"font-medium text-muted-foreground text-sm",children:r("messageParts.result")}),(0,iN.jsx)("div",{className:"rounded-md bg-muted/50 p-3 text-sm",children:(0,iN.jsx)(m6,{content:e.output})})]}):null,e.tools?.length?(0,iN.jsx)(gq,{children:e.tools.map((e,i)=>(0,iN.jsx)(gY,{value:`tool-${i}`,tool:{description:e.description??e.name,inputSchema:e.inputSchema,jsonSchema:e.jsonSchema}},`${e.name??"tool"}-${i}`))}):null]}):null]});case"ask_user_question":if("answered"!==e.status&&!e.answer)return null;return(0,iN.jsx)(yz,{question:e.question,answer:e.answer??""})}}function yz({question:e,answer:i}){return(0,iN.jsxs)("div",{className:"not-prose flex items-start gap-2 rounded-md border bg-muted/30 px-3 py-2 text-sm",children:[(0,iN.jsx)(dD,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground"}),(0,iN.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,iN.jsx)("div",{className:"truncate text-muted-foreground",children:e}),(0,iN.jsx)("div",{className:"font-medium",children:i})]})]})}function yF({text:e,status:i}){let n=(0,n0.useTranslations)("chat"),[r,s]=(0,iM.useState)(!1);return(0,iN.jsx)(yf,{icon:dL,label:(0,iN.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5",children:[(0,iN.jsx)("span",{children:n("messageParts.aiMessage")}),(0,iN.jsx)(hv.Button,{type:"button",variant:"ghost",size:"icon",className:"ml-auto size-5",onClick:()=>s(!r),children:(0,iN.jsx)(dM.ChevronDownIcon,{className:(0,nQ.cn)("size-3.5 transition-transform",r&&"rotate-180")})})]}),status:i,children:r?(0,iN.jsx)(m6,{content:e}):null})}function yW({chain:e,message:i,workspaceId:n,status:r}){var s;let o=rt(e=>e.openFile),[a,l]=(0,iM.useState)(!1),[c,h]=(0,iM.useState)(null),[d,u]=(0,iM.useState)(!1),[p,f]=(0,iM.useState)(null),[m,g]=(0,iM.useState)(!1),v=(0,n0.useTranslations)("chat"),y=async()=>{e.filePath&&await o(n,e.filePath)},_=async()=>{if(c||!e.detailId)return c;u(!0),f(null);try{let r=await fetch(`/api/workspaces/${n}/channels/${i.channelId}/messages/${i.id}/tool-details/${e.detailId}`);if(!r.ok)throw Error(await r.text());let s=await r.json();return h(s),s}catch(e){return f(e instanceof Error?e.message:v("messageParts.failedToLoadDetails")),null}finally{u(!1)}},b=async()=>{let e=!a;l(e),e&&!d&&await _()},w=async()=>{var i;let n=c??await _(),r=n?void 0!==(i=n).input||void 0!==i.output?JSON.stringify({input:i.input,output:i.output},null,2):i.raw??"":e.command??e.title;try{await navigator.clipboard.writeText(r),g(!0),setTimeout(()=>g(!1),1500)}catch{}};return(0,iN.jsx)(yf,{icon:"complete"===r?dN:dO,label:(0,iN.jsxs)("div",{className:"group/tool-step flex min-w-0 flex-wrap items-center gap-1.5",children:[(0,iN.jsx)("span",{children:e.filePath?e.title.replace(RegExp(`\\s+${((s=e.filePath).split(/[\\/]/).filter(Boolean).at(-1)??s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}$`),""):e.title}),e.description?(0,iN.jsx)("span",{className:"min-w-0 max-w-72 truncate text-muted-foreground text-xs",children:e.description}):null,e.filePath?(0,iN.jsxs)(hv.Button,{type:"button",variant:"ghost",size:"sm",className:"h-6 max-w-full gap-1 px-1.5 text-xs",onClick:y,children:[(0,iN.jsx)(dR.default,{className:"size-3"}),(0,iN.jsx)("span",{className:"max-w-52 truncate",children:e.filePath})]}):null,(0,iN.jsx)(hv.Button,{type:"button",variant:"ghost",size:"icon",className:"ml-auto size-5 shrink-0 opacity-0 transition-opacity group-hover/tool-step:opacity-100 focus-visible:opacity-100",onClick:w,children:m?(0,iN.jsx)(dg.CheckIcon,{className:"size-3 text-green-500"}):(0,iN.jsx)(dA.default,{className:"size-3"})}),e.detailId?(0,iN.jsx)(hv.Button,{type:"button",variant:"ghost",size:"icon",className:"size-5 shrink-0",onClick:b,children:(0,iN.jsx)(dM.ChevronDownIcon,{className:(0,nQ.cn)("size-3.5 transition-transform",a&&"rotate-180")})}):null]}),description:e.command,status:r,children:a?(0,iN.jsx)("div",{className:"space-y-2",children:d?(0,iN.jsx)("div",{className:"rounded-md border bg-muted/40 p-2 text-muted-foreground text-xs",children:v("messageParts.loadingDetails")}):p?(0,iN.jsx)("div",{className:"rounded-md border bg-muted/40 p-2 text-destructive text-xs",children:p}):c?(0,iN.jsx)(yH,{detail:c,toolName:e.toolName,filePath:e.filePath}):(0,iN.jsx)("div",{className:"rounded-md border bg-muted/40 p-2 text-muted-foreground text-xs",children:v("messageParts.noDetails")})}):null})}function yH({detail:e,toolName:i,filePath:n}){var r,s;let o,a=(0,n0.useTranslations)("chat");if(/^(Bash|Shell|Command)$/i.test(i??"")){let i=function(e){if(!e||"object"!=typeof e)return"string"==typeof e?e:void 0;let i=e.command??e.Command;return"string"==typeof i?i:void 0}(e.input),n="string"==typeof e.output?e.output:JSON.stringify(e.output??"",null,2);return(0,iN.jsx)(yS,{output:i?`$ ${i}
|
|
24
|
+
${n}`:n})}let l=function(e,i,n){if(!e||"object"!=typeof e)return null;let r=yV(e.file_path)??yV(e.path)??n??"edit",s=function(e){if(!e||"object"!=typeof e)return;let i=yV(e.content);if(void 0!==i)return i;let n=e.file;if(n&&"object"==typeof n)return yV(n.content)}(i),o=yV(e.old_string),a=yV(e.new_string);if(void 0!==o&&void 0!==a)return{path:r,oldContent:o,newContent:s??a};let l=Array.isArray(e.edits)?e.edits:[];return l.length>0?{path:r,oldContent:l.map((e,i)=>e&&"object"==typeof e?yV(e.old_string)??`#${i+1}`:`#${i+1}`).join("\n\n"),newContent:s??l.map((e,i)=>e&&"object"==typeof e?yV(e.new_string)??`#${i+1}`:`#${i+1}`).join("\n\n")}:null}(e.input,e.output,n);if(l&&/^(Edit|MultiEdit)$/i.test(i??""))return(0,iN.jsx)("div",{className:"h-80 overflow-hidden rounded-md border bg-background",children:(0,iN.jsx)(gi,{oldContent:l.oldContent,newContent:l.newContent,path:l.path})});let c=(r=e,s=a,o=[],void 0!==r.input&&o.push({title:s("messageParts.input"),value:y$(r.input),language:yU(r.input)?"json":"plaintext",height:180}),void 0!==r.output&&o.push({title:s("messageParts.output"),value:y$(r.output),language:yU(r.output)?"json":"plaintext",height:220}),o);return 0===c.length&&e.raw?(0,iN.jsx)(yD,{title:a("messageParts.raw"),value:e.raw,language:"plaintext"}):(0,iN.jsx)("div",{className:"space-y-2",children:c.map(e=>(0,iN.jsx)(yD,{title:e.title,value:e.value,language:e.language,height:e.height},e.title))})}function y$(e){return"string"==typeof e?e:JSON.stringify(e,null,2)}function yU(e){return"string"!=typeof e}function yV(e){return"string"==typeof e?e:void 0}function yq({attachments:e,isUser:i}){return(0,iN.jsx)(vW,{variant:"inline",className:i?"justify-end":"justify-start",children:e.map((e,i)=>{var n,r;return(0,iN.jsxs)(vH,{data:(n=e,r=i,{id:`${n.path||n.name}-${r}`,type:"file",filename:n.name,mediaType:n.type,url:n.url||n.path}),children:[(0,iN.jsx)(v$,{}),(0,iN.jsx)(vU,{showMediaType:!0})]},`${e.path}-${i}`)})})}function yY({content:e}){return/<[a-z][\s\S]*>/i.test(e)?(0,iN.jsx)("span",{className:"tiptap tiptap-message",dangerouslySetInnerHTML:{__html:e}}):(0,iN.jsx)("span",{className:"whitespace-pre-wrap break-words",children:e})}function yK({message:e,workspaceId:i,onEdit:n,onDelete:r}){let s=(0,n0.useTranslations)("common"),o="user"===e.senderId,a=(0,hD.useAgentStore)(e=>e.agents),l=o?void 0:a.find(i=>i.id===e.senderId),c=o?s("you"):l?.name||e.senderId,h=localStorage.getItem("userAvatarUrl"),d=new Date(e.createdAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),[u,p]=(0,iM.useState)(!1),[f,m]=(0,iM.useState)(!1),g="streaming"===e.status||"pending"===e.status||"waiting_for_user"===e.status,[v,y]=(0,iM.useState)(()=>e.metadata?.duration??0);(0,iM.useEffect)(()=>{if(!g&&e.metadata?.duration!=null)return void y(e.metadata.duration);if(!g)return;let i=new Date(e.createdAt).getTime();y(Date.now()-i);let n=setInterval(()=>y(Date.now()-i),1e3);return()=>clearInterval(n)},[e.metadata?.duration,e.createdAt,g]);let _=!o&&(g||"completed"===e.status||"error"===e.status)&&v>0,b=(0,iM.useCallback)(async()=>{var i;let n=(i=e.content,/<[a-z][\s\S]*>/i.test(i))?e.content.replace(/<[^>]*>/g,""):e.content;await navigator.clipboard.writeText(n),p(!0),setTimeout(()=>p(!1),2e3)},[e.content]);return(0,iN.jsxs)("div",{className:`group flex gap-2 px-3 py-1.5 ${o?"flex-row-reverse":""}`,children:[(0,iN.jsx)(hz.AgentIcon,{agentId:o?void 0:e.senderId,name:c,avatarUrl:o&&h||void 0,onClick:()=>m(!0),className:"size-7 rounded-full"}),(0,iN.jsxs)("div",{className:`flex flex-col min-w-0 w-[80%] ${o?"items-end":"items-start"}`,children:[(0,iN.jsxs)("div",{className:"flex items-center gap-2 mb-0.5",children:[(0,iN.jsx)("span",{className:"text-xs font-medium text-foreground",children:c}),e.senderRole&&(0,iN.jsx)("span",{className:"text-[10px] bg-muted px-1.5 py-0.5 rounded text-muted-foreground",children:e.senderRole}),e.metadata?.model&&(0,iN.jsx)("span",{className:"text-[10px] font-mono text-muted-foreground",children:e.metadata.model}),(0,iN.jsx)(yj,{message:e}),(0,iN.jsx)("span",{className:"text-[10px] text-muted-foreground",children:d})]}),(0,iN.jsxs)("div",{className:`text-sm rounded-lg px-3 py-2 ${o?"bg-primary text-primary-foreground":"bg-muted"}`,children:[(0,iN.jsx)(yL,{message:e,isUser:o,workspaceId:i}),_&&(0,iN.jsxs)("div",{className:"flex items-center justify-end gap-1 mt-1 pt-1 border-t border-border/30",children:[(0,iN.jsx)(dC,{className:"h-3 w-3 text-muted-foreground"}),(0,iN.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:[function(e){let i=Math.floor(e/1e3);if(i<60)return`${i}s`;let n=Math.floor(i/60);if(n<60)return`${n}m ${i%60}s`;let r=Math.floor(n/60);return`${r}h ${n%60}m`}(v),g&&(0,iN.jsx)("span",{className:"animate-pulse ml-0.5",children:"..."})]})]})]}),(0,iN.jsxs)("div",{className:"flex items-center gap-0.5 h-6 opacity-0 group-hover:opacity-100 transition-opacity",children:[(0,iN.jsx)("button",{onClick:b,className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:"复制",children:u?(0,iN.jsx)(hS.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,iN.jsx)(dk.Copy,{className:"h-3.5 w-3.5"})}),o&&(0,iN.jsx)("button",{onClick:()=>n?.(e),className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:"编辑",children:(0,iN.jsx)(rw.Pencil,{className:"h-3.5 w-3.5"})}),(0,iN.jsx)("button",{onClick:()=>r?.(e),className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-destructive transition-colors",title:"删除",children:(0,iN.jsx)(nJ.Trash2,{className:"h-3.5 w-3.5"})})]})]}),(0,iN.jsx)(dE,{open:f,onOpenChange:m,memberName:e.senderId,channelId:e.channelId,workspaceId:i})]})}var yX={outline:{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},filled:{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"currentColor",stroke:"none"}};let yJ=(e,i,n,r)=>{let s=(0,iM.forwardRef)(({color:n="currentColor",size:s=24,stroke:o=2,title:a,className:l,children:c,...h},d)=>(0,iM.createElement)("svg",{ref:d,...yX[e],width:s,height:s,className:["tabler-icon",`tabler-icon-${i}`,l].join(" "),..."filled"===e?{fill:n}:{strokeWidth:o,stroke:n},...h},[a&&(0,iM.createElement)("title",{key:"svg-title"},a),...r.map(([e,i])=>(0,iM.createElement)(e,i)),...Array.isArray(c)?c:[c]]));return s.displayName=`${n}`,s},yG=yJ("outline","chevron-down","ChevronDown",[["path",{d:"M6 9l6 6l6 -6",key:"svg-0"}]]),yZ=yJ("outline","circle-check","CircleCheck",[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0",key:"svg-0"}],["path",{d:"M9 12l2 2l4 -4",key:"svg-1"}]]),yQ=yJ("outline","circle-dashed","CircleDashed",[["path",{d:"M8.56 3.69a9 9 0 0 0 -2.92 1.95",key:"svg-0"}],["path",{d:"M3.69 8.56a9 9 0 0 0 -.69 3.44",key:"svg-1"}],["path",{d:"M3.69 15.44a9 9 0 0 0 1.95 2.92",key:"svg-2"}],["path",{d:"M8.56 20.31a9 9 0 0 0 3.44 .69",key:"svg-3"}],["path",{d:"M15.44 20.31a9 9 0 0 0 2.92 -1.95",key:"svg-4"}],["path",{d:"M20.31 15.44a9 9 0 0 0 .69 -3.44",key:"svg-5"}],["path",{d:"M20.31 8.56a9 9 0 0 0 -1.95 -2.92",key:"svg-6"}],["path",{d:"M15.44 3.69a9 9 0 0 0 -3.44 -.69",key:"svg-7"}]]),y0=yJ("outline","code","Code",[["path",{d:"M7 8l-4 4l4 4",key:"svg-0"}],["path",{d:"M17 8l4 4l-4 4",key:"svg-1"}],["path",{d:"M14 4l-4 16",key:"svg-2"}]]),y1=yJ("outline","file-text","FileText",[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2",key:"svg-1"}],["path",{d:"M9 9l1 0",key:"svg-2"}],["path",{d:"M9 13l6 0",key:"svg-3"}],["path",{d:"M9 17l6 0",key:"svg-4"}]]),y2=yJ("outline","history","History",[["path",{d:"M12 8l0 4l2 2",key:"svg-0"}],["path",{d:"M3.05 11a9 9 0 1 1 .5 4m-.5 5v-5h5",key:"svg-1"}]]),y5=yJ("outline","loader-2","Loader2",[["path",{d:"M12 3a9 9 0 1 0 9 9",key:"svg-0"}]]),y3=yJ("outline","message-circle-plus","MessageCirclePlus",[["path",{d:"M12.007 19.98a9.869 9.869 0 0 1 -4.307 -.98l-4.7 1l1.3 -3.9c-2.324 -3.437 -1.426 -7.872 2.1 -10.374c3.526 -2.501 8.59 -2.296 11.845 .48c1.992 1.7 2.93 4.04 2.747 6.34",key:"svg-0"}],["path",{d:"M16 19h6",key:"svg-1"}],["path",{d:"M19 16v6",key:"svg-2"}]]),y4=yJ("outline","paperclip","Paperclip",[["path",{d:"M15 7l-6.5 6.5a1.5 1.5 0 0 0 3 3l6.5 -6.5a3 3 0 0 0 -6 -6l-6.5 6.5a4.5 4.5 0 0 0 9 9l6.5 -6.5",key:"svg-0"}]]),y6=yJ("outline","pin","Pin",[["path",{d:"M15 4.5l-4 4l-4 1.5l-1.5 1.5l7 7l1.5 -1.5l1.5 -4l4 -4",key:"svg-0"}],["path",{d:"M9 15l-4.5 4.5",key:"svg-1"}],["path",{d:"M14.5 4l5.5 5.5",key:"svg-2"}]]),y8=yJ("filled","pin-filled","PinFilled",[["path",{d:"M15.113 3.21l.094 .083l5.5 5.5a1 1 0 0 1 -1.175 1.59l-3.172 3.171l-1.424 3.797a1 1 0 0 1 -.158 .277l-.07 .08l-1.5 1.5a1 1 0 0 1 -1.32 .082l-.095 -.083l-2.793 -2.792l-3.793 3.792a1 1 0 0 1 -1.497 -1.32l.083 -.094l3.792 -3.793l-2.792 -2.793a1 1 0 0 1 -.083 -1.32l.083 -.094l1.5 -1.5a1 1 0 0 1 .258 -.187l.098 -.042l3.796 -1.425l3.171 -3.17a1 1 0 0 1 1.497 -1.26z",key:"svg-0"}]]),y9=yJ("outline","plug","Plug",[["path",{d:"M9.785 6l8.215 8.215l-2.054 2.054a5.81 5.81 0 1 1 -8.215 -8.215l2.054 -2.054",key:"svg-0"}],["path",{d:"M4 20l3.5 -3.5",key:"svg-1"}],["path",{d:"M15 4l-3.5 3.5",key:"svg-2"}],["path",{d:"M20 9l-3.5 3.5",key:"svg-3"}]]),y7=yJ("outline","plus","Plus",[["path",{d:"M12 5l0 14",key:"svg-0"}],["path",{d:"M5 12l14 0",key:"svg-1"}]]),_e=yJ("outline","puzzle","Puzzle",[["path",{d:"M4 7h3a1 1 0 0 0 1 -1v-1a2 2 0 0 1 4 0v1a1 1 0 0 0 1 1h3a1 1 0 0 1 1 1v3a1 1 0 0 0 1 1h1a2 2 0 0 1 0 4h-1a1 1 0 0 0 -1 1v3a1 1 0 0 1 -1 1h-3a1 1 0 0 1 -1 -1v-1a2 2 0 0 0 -4 0v1a1 1 0 0 1 -1 1h-3a1 1 0 0 1 -1 -1v-3a1 1 0 0 1 1 -1h1a2 2 0 0 0 0 -4h-1a1 1 0 0 1 -1 -1v-3a1 1 0 0 1 1 -1",key:"svg-0"}]]),_t=yJ("outline","tools","Tools",[["path",{d:"M3 21h4l13 -13a1.5 1.5 0 0 0 -4 -4l-13 13v4",key:"svg-0"}],["path",{d:"M14.5 5.5l4 4",key:"svg-1"}],["path",{d:"M12 8l-5 -5l-4 4l5 5",key:"svg-2"}],["path",{d:"M7 8l-1.5 1.5",key:"svg-3"}],["path",{d:"M16 12l5 5l-4 4l-5 -5",key:"svg-4"}],["path",{d:"M16 17l-1.5 1.5",key:"svg-5"}]]),_i=yJ("outline","wand","Wand",[["path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3",key:"svg-0"}],["path",{d:"M15 6l3 3",key:"svg-1"}],["path",{d:"M9 3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2",key:"svg-2"}],["path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2",key:"svg-3"}]]),_n=yJ("outline","world","World",[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0",key:"svg-0"}],["path",{d:"M3.6 9h16.8",key:"svg-1"}],["path",{d:"M3.6 15h16.8",key:"svg-2"}],["path",{d:"M11.5 3a17 17 0 0 0 0 18",key:"svg-3"}],["path",{d:"M12.5 3a17 17 0 0 1 0 18",key:"svg-4"}]]);var _r=iM,_s=e.i(56032);function _o(e){this.content=e}_o.prototype={constructor:_o,find:function(e){for(var i=0;i<this.content.length;i+=2)if(this.content[i]===e)return i;return -1},get:function(e){var i=this.find(e);return -1==i?void 0:this.content[i+1]},update:function(e,i,n){var r=n&&n!=e?this.remove(n):this,s=r.find(e),o=r.content.slice();return -1==s?o.push(n||e,i):(o[s+1]=i,n&&(o[s]=n)),new _o(o)},remove:function(e){var i=this.find(e);if(-1==i)return this;var n=this.content.slice();return n.splice(i,2),new _o(n)},addToStart:function(e,i){return new _o([e,i].concat(this.remove(e).content))},addToEnd:function(e,i){var n=this.remove(e).content.slice();return n.push(e,i),new _o(n)},addBefore:function(e,i,n){var r=this.remove(i),s=r.content.slice(),o=r.find(e);return s.splice(-1==o?s.length:o,0,i,n),new _o(s)},forEach:function(e){for(var i=0;i<this.content.length;i+=2)e(this.content[i],this.content[i+1])},prepend:function(e){return(e=_o.from(e)).size?new _o(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=_o.from(e)).size?new _o(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var i=this;e=_o.from(e);for(var n=0;n<e.content.length;n+=2)i=i.remove(e.content[n]);return i},toObject:function(){var e={};return this.forEach(function(i,n){e[i]=n}),e},get size(){return this.content.length>>1}},_o.from=function(e){if(e instanceof _o)return e;var i=[];if(e)for(var n in e)i.push(n,e[n]);return new _o(i)};class _a{constructor(e,i){if(this.content=e,this.size=i||0,null==i)for(let i=0;i<e.length;i++)this.size+=e[i].nodeSize}nodesBetween(e,i,n,r=0,s){for(let o=0,a=0;a<i;o++){let l=this.content[o],c=a+l.nodeSize;if(c>e&&!1!==n(l,r+a,s||null,o)&&l.content.size){let s=a+1;l.nodesBetween(Math.max(0,e-s),Math.min(l.content.size,i-s),n,r+s)}a=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,i,n,r){let s="",o=!0;return this.nodesBetween(e,i,(a,l)=>{let c=a.isText?a.text.slice(Math.max(e,l)-l,i-l):a.isLeaf?r?"function"==typeof r?r(a):r:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&c||a.isTextblock)&&n&&(o?o=!1:s+=n),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let i=this.lastChild,n=e.firstChild,r=this.content.slice(),s=0;for(i.isText&&i.sameMarkup(n)&&(r[r.length-1]=i.withText(i.text+n.text),s=1);s<e.content.length;s++)r.push(e.content[s]);return new _a(r,this.size+e.size)}cut(e,i=this.size){if(0==e&&i==this.size)return this;let n=[],r=0;if(i>e)for(let s=0,o=0;o<i;s++){let a=this.content[s],l=o+a.nodeSize;l>e&&((o<e||l>i)&&(a=a.isText?a.cut(Math.max(0,e-o),Math.min(a.text.length,i-o)):a.cut(Math.max(0,e-o-1),Math.min(a.content.size,i-o-1))),n.push(a),r+=a.nodeSize),o=l}return new _a(n,r)}cutByIndex(e,i){return e==i?_a.empty:0==e&&i==this.content.length?this:new _a(this.content.slice(e,i))}replaceChild(e,i){let n=this.content[e];if(n==i)return this;let r=this.content.slice(),s=this.size+i.nodeSize-n.nodeSize;return r[e]=i,new _a(r,s)}addToStart(e){return new _a([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new _a(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let i=0;i<this.content.length;i++)if(!this.content[i].eq(e.content[i]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let i=this.content[e];if(!i)throw RangeError("Index "+e+" out of range for "+this);return i}maybeChild(e){return this.content[e]||null}forEach(e){for(let i=0,n=0;i<this.content.length;i++){let r=this.content[i];e(r,n,i),n+=r.nodeSize}}findDiffStart(e,i=0){return function e(i,n,r){for(let s=0;;s++){if(s==i.childCount||s==n.childCount)return i.childCount==n.childCount?null:r;let o=i.child(s),a=n.child(s);if(o==a){r+=o.nodeSize;continue}if(!o.sameMarkup(a))return r;if(o.isText&&o.text!=a.text){for(let e=0;o.text[e]==a.text[e];e++)r++;return r}if(o.content.size||a.content.size){let i=e(o.content,a.content,r+1);if(null!=i)return i}r+=o.nodeSize}}(this,e,i)}findDiffEnd(e,i=this.size,n=e.size){return function e(i,n,r,s){for(let o=i.childCount,a=n.childCount;;){if(0==o||0==a)return o==a?null:{a:r,b:s};let l=i.child(--o),c=n.child(--a),h=l.nodeSize;if(l==c){r-=h,s-=h;continue}if(!l.sameMarkup(c))return{a:r,b:s};if(l.isText&&l.text!=c.text){let e=0,i=Math.min(l.text.length,c.text.length);for(;e<i&&l.text[l.text.length-e-1]==c.text[c.text.length-e-1];)e++,r--,s--;return{a:r,b:s}}if(l.content.size||c.content.size){let i=e(l.content,c.content,r-1,s-1);if(i)return i}r-=h,s-=h}}(this,e,i,n)}findIndex(e){if(0==e)return _c(0,e);if(e==this.size)return _c(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let i=0,n=0;;i++){let r=n+this.child(i).nodeSize;if(r>=e){if(r==e)return _c(i+1,r);return _c(i,n)}n=r}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,i){if(!i)return _a.empty;if(!Array.isArray(i))throw RangeError("Invalid input for Fragment.fromJSON");return new _a(i.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return _a.empty;let i,n=0;for(let r=0;r<e.length;r++){let s=e[r];n+=s.nodeSize,r&&s.isText&&e[r-1].sameMarkup(s)?(i||(i=e.slice(0,r)),i[i.length-1]=s.withText(i[i.length-1].text+s.text)):i&&i.push(s)}return new _a(i||e,n)}static from(e){if(!e)return _a.empty;if(e instanceof _a)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new _a([e],e.nodeSize);throw RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}_a.empty=new _a([],0);let _l={index:0,offset:0};function _c(e,i){return _l.index=e,_l.offset=i,_l}function _h(e,i){if(e===i)return!0;if(!(e&&"object"==typeof e)||!(i&&"object"==typeof i))return!1;let n=Array.isArray(e);if(Array.isArray(i)!=n)return!1;if(n){if(e.length!=i.length)return!1;for(let n=0;n<e.length;n++)if(!_h(e[n],i[n]))return!1}else{for(let n in e)if(!(n in i)||!_h(e[n],i[n]))return!1;for(let n in i)if(!(n in e))return!1}return!0}class _d{constructor(e,i){this.type=e,this.attrs=i}addToSet(e){let i,n=!1;for(let r=0;r<e.length;r++){let s=e[r];if(this.eq(s))return e;if(this.type.excludes(s.type))i||(i=e.slice(0,r));else{if(s.type.excludes(this.type))return e;!n&&s.type.rank>this.type.rank&&(i||(i=e.slice(0,r)),i.push(this),n=!0),i&&i.push(s)}}return i||(i=e.slice()),n||i.push(this),i}removeFromSet(e){for(let i=0;i<e.length;i++)if(this.eq(e[i]))return e.slice(0,i).concat(e.slice(i+1));return e}isInSet(e){for(let i=0;i<e.length;i++)if(this.eq(e[i]))return!0;return!1}eq(e){return this==e||this.type==e.type&&_h(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let i in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,i){if(!i)throw RangeError("Invalid input for Mark.fromJSON");let n=e.marks[i.type];if(!n)throw RangeError(`There is no mark type ${i.type} in this schema`);let r=n.create(i.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,i){if(e==i)return!0;if(e.length!=i.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(i[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&0==e.length)return _d.none;if(e instanceof _d)return[e];let i=e.slice();return i.sort((e,i)=>e.type.rank-i.type.rank),i}}_d.none=[];class _u extends Error{}class _p{constructor(e,i,n){this.content=e,this.openStart=i,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,i){let n=function e(i,n,r,s){let{index:o,offset:a}=i.findIndex(n),l=i.maybeChild(o);if(a==n||l.isText)return s&&!s.canReplace(o,o,r)?null:i.cut(0,n).append(r).append(i.cut(n));let c=e(l.content,n-a-1,r,l);return c&&i.replaceChild(o,l.copy(c))}(this.content,e+this.openStart,i);return n&&new _p(n,this.openStart,this.openEnd)}removeBetween(e,i){return new _p(function e(i,n,r){let{index:s,offset:o}=i.findIndex(n),a=i.maybeChild(s),{index:l,offset:c}=i.findIndex(r);if(o==n||a.isText){if(c!=r&&!i.child(l).isText)throw RangeError("Removing non-flat range");return i.cut(0,n).append(i.cut(r))}if(s!=l)throw RangeError("Removing non-flat range");return i.replaceChild(s,a.copy(e(a.content,n-o-1,r-o-1)))}(this.content,e+this.openStart,i+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,i){if(!i)return _p.empty;let n=i.openStart||0,r=i.openEnd||0;if("number"!=typeof n||"number"!=typeof r)throw RangeError("Invalid input for Slice.fromJSON");return new _p(_a.fromJSON(e,i.content),n,r)}static maxOpen(e,i=!0){let n=0,r=0;for(let r=e.firstChild;r&&!r.isLeaf&&(i||!r.type.spec.isolating);r=r.firstChild)n++;for(let n=e.lastChild;n&&!n.isLeaf&&(i||!n.type.spec.isolating);n=n.lastChild)r++;return new _p(e,n,r)}}function _f(e,i){if(!i.type.compatibleContent(e.type))throw new _u("Cannot join "+i.type.name+" onto "+e.type.name)}function _m(e,i,n){let r=e.node(n);return _f(r,i.node(n)),r}function _g(e,i){let n=i.length-1;n>=0&&e.isText&&e.sameMarkup(i[n])?i[n]=e.withText(i[n].text+e.text):i.push(e)}function _v(e,i,n,r){let s=(i||e).node(n),o=0,a=i?i.index(n):s.childCount;e&&(o=e.index(n),e.depth>n?o++:e.textOffset&&(_g(e.nodeAfter,r),o++));for(let e=o;e<a;e++)_g(s.child(e),r);i&&i.depth==n&&i.textOffset&&_g(i.nodeBefore,r)}function _y(e,i){return e.type.checkContent(i),e.copy(i)}function __(e,i,n){let r=[];return _v(null,e,n,r),e.depth>n&&_g(_y(_m(e,i,n+1),__(e,i,n+1)),r),_v(i,null,n,r),new _a(r)}_p.empty=new _p(_a.empty,0,0);class _b{constructor(e,i,n){this.pos=e,this.path=i,this.parentOffset=n,this.depth=i.length/3-1}resolveDepth(e){return null==e?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[3*this.resolveDepth(e)]}index(e){return this.path[3*this.resolveDepth(e)+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)}start(e){return 0==(e=this.resolveDepth(e))?0:this.path[3*e-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(!(e=this.resolveDepth(e)))throw RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]}after(e){if(!(e=this.resolveDepth(e)))throw RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,i=this.index(this.depth);if(i==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(i);return n?e.child(i).cut(n):r}get nodeBefore(){let e=this.index(this.depth),i=this.pos-this.path[this.path.length-1];return i?this.parent.child(e).cut(0,i):0==e?null:this.parent.child(e-1)}posAtIndex(e,i){i=this.resolveDepth(i);let n=this.path[3*i],r=0==i?0:this.path[3*i-1]+1;for(let i=0;i<e;i++)r+=n.child(i).nodeSize;return r}marks(){let e=this.parent,i=this.index();if(0==e.content.size)return _d.none;if(this.textOffset)return e.child(i).marks;let n=e.maybeChild(i-1),r=e.maybeChild(i);if(!n){let e=n;n=r,r=e}let s=n.marks;for(var o=0;o<s.length;o++)!1!==s[o].type.spec.inclusive||r&&s[o].isInSet(r.marks)||(s=s[o--].removeFromSet(s));return s}marksAcross(e){let i=this.parent.maybeChild(this.index());if(!i||!i.isInline)return null;let n=i.marks,r=e.parent.maybeChild(e.index());for(var s=0;s<n.length;s++)!1!==n[s].type.spec.inclusive||r&&n[s].isInSet(r.marks)||(n=n[s--].removeFromSet(n));return n}sharedDepth(e){for(let i=this.depth;i>0;i--)if(this.start(i)<=e&&this.end(i)>=e)return i;return 0}blockRange(e=this,i){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!i||i(this.node(n))))return new _k(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let i=1;i<=this.depth;i++)e+=(e?"/":"")+this.node(i).type.name+"_"+this.index(i-1);return e+":"+this.parentOffset}static resolve(e,i){if(!(i>=0&&i<=e.content.size))throw RangeError("Position "+i+" out of range");let n=[],r=0,s=i;for(let i=e;;){let{index:e,offset:o}=i.content.findIndex(s),a=s-o;if(n.push(i,e,r+o),!a||(i=i.child(e)).isText)break;s=a-1,r+=o+1}return new _b(i,n,s)}static resolveCached(e,i){let n=_S.get(e);if(n)for(let e=0;e<n.elts.length;e++){let r=n.elts[e];if(r.pos==i)return r}else _S.set(e,n=new _x);let r=n.elts[n.i]=_b.resolve(e,i);return n.i=(n.i+1)%_w,r}}class _x{constructor(){this.elts=[],this.i=0}}let _w=12,_S=new WeakMap;class _k{constructor(e,i,n){this.$from=e,this.$to=i,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}let _C=Object.create(null);class _T{constructor(e,i,n,r=_d.none){this.type=e,this.attrs=i,this.marks=r,this.content=n||_a.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,i,n,r=0){this.content.nodesBetween(e,i,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,i,n,r){return this.content.textBetween(e,i,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,i,n){return this.type==e&&_h(this.attrs,i||e.defaultAttrs||_C)&&_d.sameSet(this.marks,n||_d.none)}copy(e=null){return e==this.content?this:new _T(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new _T(this.type,this.attrs,this.content,e)}cut(e,i=this.content.size){return 0==e&&i==this.content.size?this:this.copy(this.content.cut(e,i))}slice(e,i=this.content.size,n=!1){if(e==i)return _p.empty;let r=this.resolve(e),s=this.resolve(i),o=n?0:r.sharedDepth(i),a=r.start(o);return new _p(r.node(o).content.cut(r.pos-a,s.pos-a),r.depth-o,s.depth-o)}replace(e,i,n){var r=this.resolve(e),s=this.resolve(i);if(n.openStart>r.depth)throw new _u("Inserted content deeper than insertion position");if(r.depth-n.openStart!=s.depth-n.openEnd)throw new _u("Inconsistent open depths");return function e(i,n,r,s){let o=i.index(s),a=i.node(s);if(o==n.index(s)&&s<i.depth-r.openStart){let l=e(i,n,r,s+1);return a.copy(a.content.replaceChild(o,l))}if(!r.content.size)return _y(a,__(i,n,s));if(r.openStart||r.openEnd||i.depth!=s||n.depth!=s){let{start:e,end:o}=function(e,i){let n=i.depth-e.openStart,r=i.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=i.node(e).copy(_a.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}(r,i);return _y(a,function e(i,n,r,s,o){let a=i.depth>o&&_m(i,n,o+1),l=s.depth>o&&_m(r,s,o+1),c=[];return _v(null,i,o,c),a&&l&&n.index(o)==r.index(o)?(_f(a,l),_g(_y(a,e(i,n,r,s,o+1)),c)):(a&&_g(_y(a,__(i,n,o+1)),c),_v(n,r,o,c),l&&_g(_y(l,__(r,s,o+1)),c)),_v(s,null,o,c),new _a(c)}(i,e,o,n,s))}{let e=i.parent,s=e.content;return _y(e,s.cut(0,i.parentOffset).append(r.content).append(s.cut(n.parentOffset)))}}(r,s,n,0)}nodeAt(e){for(let i=this;;){let{index:n,offset:r}=i.content.findIndex(e);if(!(i=i.maybeChild(n)))return null;if(r==e||i.isText)return i;e-=r+1}}childAfter(e){let{index:i,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(i),index:i,offset:n}}childBefore(e){if(0==e)return{node:null,index:0,offset:0};let{index:i,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(i),index:i,offset:n};let r=this.content.child(i-1);return{node:r,index:i-1,offset:n-r.nodeSize}}resolve(e){return _b.resolveCached(this,e)}resolveNoCache(e){return _b.resolve(this,e)}rangeHasMark(e,i,n){let r=!1;return i>e&&this.nodesBetween(e,i,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),_N(this.marks,e)}contentMatchAt(e){let i=this.type.contentMatch.matchFragment(this.content,0,e);if(!i)throw Error("Called contentMatchAt on a node with invalid content");return i}canReplace(e,i,n=_a.empty,r=0,s=n.childCount){let o=this.contentMatchAt(e).matchFragment(n,r,s),a=o&&o.matchFragment(this.content,i);if(!a||!a.validEnd)return!1;for(let e=r;e<s;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,i,n,r){if(r&&!this.type.allowsMarks(r))return!1;let s=this.contentMatchAt(e).matchType(n),o=s&&s.matchFragment(this.content,i);return!!o&&o.validEnd}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=_d.none;for(let i=0;i<this.marks.length;i++){let n=this.marks[i];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!_d.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let i in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,i){let n;if(!i)throw RangeError("Invalid input for Node.fromJSON");if(i.marks){if(!Array.isArray(i.marks))throw RangeError("Invalid mark data for Node.fromJSON");n=i.marks.map(e.markFromJSON)}if("text"==i.type){if("string"!=typeof i.text)throw RangeError("Invalid text node in JSON");return e.text(i.text,n)}let r=_a.fromJSON(e,i.content),s=e.nodeType(i.type).create(i.attrs,r,n);return s.type.checkAttrs(s.attrs),s}}_T.prototype.text=void 0;class _E extends _T{constructor(e,i,n,r){if(super(e,i,null,r),!n)throw RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):_N(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,i){return this.text.slice(e,i)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new _E(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new _E(this.type,this.attrs,e,this.marks)}cut(e=0,i=this.text.length){return 0==e&&i==this.text.length?this:this.withText(this.text.slice(e,i))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function _N(e,i){for(let n=e.length-1;n>=0;n--)i=e[n].type.name+"("+i+")";return i}class _M{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,i){var n;let r,s=new _O(e,i);if(null==s.next)return _M.empty;let o=function e(i){let n=[];do n.push(function(i){let n=[];do n.push(function(i){let n=function(i){if(i.eat("(")){let n=e(i);return i.eat(")")||i.err("Missing closing paren"),n}if(/\W/.test(i.next))i.err("Unexpected token '"+i.next+"'");else{let e=(function(e,i){let n=e.nodeTypes,r=n[i];if(r)return[r];let s=[];for(let e in n){let r=n[e];r.isInGroup(i)&&s.push(r)}return 0==s.length&&e.err("No node type or group '"+i+"' found"),s})(i,i.next).map(e=>(null==i.inline?i.inline=e.isInline:i.inline!=e.isInline&&i.err("Mixing inline and block content"),{type:"name",value:e}));return i.pos++,1==e.length?e[0]:{type:"choice",exprs:e}}}(i);for(;;)if(i.eat("+"))n={type:"plus",expr:n};else if(i.eat("*"))n={type:"star",expr:n};else if(i.eat("?"))n={type:"opt",expr:n};else if(i.eat("{"))n=function(e,i){let n=_A(e),r=n;return e.eat(",")&&(r="}"!=e.next?_A(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:i}}(i,n);else break;return n}(i));while(i.next&&")"!=i.next&&"|"!=i.next)return 1==n.length?n[0]:{type:"seq",exprs:n}}(i));while(i.eat("|"))return 1==n.length?n[0]:{type:"choice",exprs:n}}(s);s.next&&s.err("Unexpected trailing text");let a=(n=function(e){let i=[[]];return s(function e(i,o){if("choice"==i.type)return i.exprs.reduce((i,n)=>i.concat(e(n,o)),[]);if("seq"==i.type)for(let r=0;;r++){let a=e(i.exprs[r],o);if(r==i.exprs.length-1)return a;s(a,o=n())}else if("star"==i.type){let a=n();return r(o,a),s(e(i.expr,a),a),[r(a)]}else if("plus"==i.type){let a=n();return s(e(i.expr,o),a),s(e(i.expr,a),a),[r(a)]}else if("opt"==i.type)return[r(o)].concat(e(i.expr,o));else if("range"==i.type){let a=o;for(let r=0;r<i.min;r++){let r=n();s(e(i.expr,a),r),a=r}if(-1==i.max)s(e(i.expr,a),a);else for(let o=i.min;o<i.max;o++){let o=n();r(a,o),s(e(i.expr,a),o),a=o}return[r(a)]}else if("name"==i.type)return[r(o,void 0,i.value)];else throw Error("Unknown expr type")}(e,0),n()),i;function n(){return i.push([])-1}function r(e,n,r){let s={term:r,to:n};return i[e].push(s),s}function s(e,i){e.forEach(e=>e.to=i)}}(o),r=Object.create(null),function e(i){let s=[];i.forEach(e=>{n[e].forEach(({term:e,to:i})=>{let r;if(e){for(let i=0;i<s.length;i++)s[i][0]==e&&(r=s[i][1]);_D(n,i).forEach(i=>{r||s.push([e,r=[]]),-1==r.indexOf(i)&&r.push(i)})}})});let o=r[i.join(",")]=new _M(i.indexOf(n.length-1)>-1);for(let i=0;i<s.length;i++){let n=s[i][1].sort(_R);o.next.push({type:s[i][0],next:r[n.join(",")]||e(n)})}return o}(_D(n,0)));return function(e,i){for(let n=0,r=[e];n<r.length;n++){let e=r[n],s=!e.validEnd,o=[];for(let i=0;i<e.next.length;i++){let{type:n,next:a}=e.next[i];o.push(n.name),s&&!(n.isText||n.hasRequiredAttrs())&&(s=!1),-1==r.indexOf(a)&&r.push(a)}s&&i.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(a,s),a}matchType(e){for(let i=0;i<this.next.length;i++)if(this.next[i].type==e)return this.next[i].next;return null}matchFragment(e,i=0,n=e.childCount){let r=this;for(let s=i;r&&s<n;s++)r=r.matchType(e.child(s).type);return r}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:i}=this.next[e];if(!(i.isText||i.hasRequiredAttrs()))return i}return null}compatible(e){for(let i=0;i<this.next.length;i++)for(let n=0;n<e.next.length;n++)if(this.next[i].type==e.next[n].type)return!0;return!1}fillBefore(e,i=!1,n=0){let r=[this];return function s(o,a){let l=o.matchFragment(e,n);if(l&&(!i||l.validEnd))return _a.from(a.map(e=>e.createAndFill()));for(let e=0;e<o.next.length;e++){let{type:i,next:n}=o.next[e];if(!(i.isText||i.hasRequiredAttrs())&&-1==r.indexOf(n)){r.push(n);let e=s(n,a.concat(i));if(e)return e}}return null}(this,[])}findWrapping(e){for(let i=0;i<this.wrapCache.length;i+=2)if(this.wrapCache[i]==e)return this.wrapCache[i+1];let i=this.computeWrapping(e);return this.wrapCache.push(e,i),i}computeWrapping(e){let i=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),s=r.match;if(s.matchType(e)){let e=[];for(let i=r;i.type;i=i.via)e.push(i.type);return e.reverse()}for(let e=0;e<s.next.length;e++){let{type:o,next:a}=s.next[e];o.isLeaf||o.hasRequiredAttrs()||o.name in i||r.type&&!a.validEnd||(n.push({match:o.contentMatch,type:o,via:r}),i[o.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];return!function i(n){e.push(n);for(let r=0;r<n.next.length;r++)-1==e.indexOf(n.next[r].next)&&i(n.next[r].next)}(this),e.map((i,n)=>{let r=n+(i.validEnd?"*":" ")+" ";for(let n=0;n<i.next.length;n++)r+=(n?", ":"")+i.next[n].type.name+"->"+e.indexOf(i.next[n].next);return r}).join("\n")}}_M.empty=new _M(!0);class _O{constructor(e,i){this.string=e,this.nodeTypes=i,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+" (in content expression '"+this.string+"')")}}function _A(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let i=Number(e.next);return e.pos++,i}function _R(e,i){return i-e}function _D(e,i){let n=[];return function i(r){let s=e[r];if(1==s.length&&!s[0].term)return i(s[0].to);n.push(r);for(let e=0;e<s.length;e++){let{term:r,to:o}=s[e];r||-1!=n.indexOf(o)||i(o)}}(i),n.sort(_R)}function _L(e){let i=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;i[n]=r.default}return i}function _j(e,i){let n=Object.create(null);for(let r in e){let s=i&&i[r];if(void 0===s){let i=e[r];if(i.hasDefault)s=i.default;else throw RangeError("No value supplied for attribute "+r)}n[r]=s}return n}function _I(e,i,n,r){for(let r in i)if(!(r in e))throw RangeError(`Unsupported attribute ${r} for ${n} of type ${r}`);for(let n in e){let r=e[n];r.validate&&r.validate(i[n])}}function _P(e,i){let n=Object.create(null);if(i)for(let r in i)n[r]=new _z(e,r,i[r]);return n}class _B{constructor(e,i,n){this.name=e,this.schema=i,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=_P(e,n.attrs),this.defaultAttrs=_L(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==e),this.isText="text"==e}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==_M.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:_j(this.attrs,e)}create(e=null,i,n){if(this.isText)throw Error("NodeType.create can't construct text nodes");return new _T(this,this.computeAttrs(e),_a.from(i),_d.setFrom(n))}createChecked(e=null,i,n){return i=_a.from(i),this.checkContent(i),new _T(this,this.computeAttrs(e),i,_d.setFrom(n))}createAndFill(e=null,i,n){if(e=this.computeAttrs(e),(i=_a.from(i)).size){let e=this.contentMatch.fillBefore(i);if(!e)return null;i=e.append(i)}let r=this.contentMatch.matchFragment(i),s=r&&r.fillBefore(_a.empty,!0);return s?new _T(this,e,i.append(s),_d.setFrom(n)):null}validContent(e){let i=this.contentMatch.matchFragment(e);if(!i||!i.validEnd)return!1;for(let i=0;i<e.childCount;i++)if(!this.allowsMarks(e.child(i).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){_I(this.attrs,e,"node",this.name)}allowsMarkType(e){return null==this.markSet||this.markSet.indexOf(e)>-1}allowsMarks(e){if(null==this.markSet)return!0;for(let i=0;i<e.length;i++)if(!this.allowsMarkType(e[i].type))return!1;return!0}allowedMarks(e){let i;if(null==this.markSet)return e;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?i&&i.push(e[n]):i||(i=e.slice(0,n));return i?i.length?i:_d.none:e}static compile(e,i){let n=Object.create(null);e.forEach((e,r)=>n[e]=new _B(e,i,r));let r=i.spec.topNode||"doc";if(!n[r])throw RangeError("Schema is missing its top node type ('"+r+"')");if(!n.text)throw RangeError("Every schema needs a 'text' type");for(let e in n.text.attrs)throw RangeError("The text node type should not have attributes");return n}}class _z{constructor(e,i,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate="string"==typeof n.validate?function(e,i,n){let r=n.split("|");return n=>{let s=null===n?"null":typeof n;if(0>r.indexOf(s))throw RangeError(`Expected value of type ${r} for attribute ${i} on type ${e}, got ${s}`)}}(e,i,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class _F{constructor(e,i,n,r){this.name=e,this.rank=i,this.schema=n,this.spec=r,this.attrs=_P(e,r.attrs),this.excluded=null;let s=_L(this.attrs);this.instance=s?new _d(this,s):null}create(e=null){return!e&&this.instance?this.instance:new _d(this,_j(this.attrs,e))}static compile(e,i){let n=Object.create(null),r=0;return e.forEach((e,s)=>n[e]=new _F(e,r++,i,s)),n}removeFromSet(e){for(var i=0;i<e.length;i++)e[i].type==this&&(e=e.slice(0,i).concat(e.slice(i+1)),i--);return e}isInSet(e){for(let i=0;i<e.length;i++)if(e[i].type==this)return e[i]}checkAttrs(e){_I(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class _W{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let i=this.spec={};for(let n in e)i[n]=e[n];i.nodes=_o.from(e.nodes),i.marks=_o.from(e.marks||{}),this.nodes=_B.compile(this.spec.nodes,this),this.marks=_F.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+" can not be both a node and a mark");let i=this.nodes[e],r=i.spec.content||"",s=i.spec.marks;if(i.contentMatch=n[r]||(n[r]=_M.parse(r,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet="_"==s?null:s?_H(this,s.split(" ")):""!=s&&i.inlineContent?null:[]}for(let e in this.marks){let i=this.marks[e],n=i.spec.excludes;i.excluded=null==n?[i]:""==n?[]:_H(this,n.split(" "))}this.nodeFromJSON=e=>_T.fromJSON(this,e),this.markFromJSON=e=>_d.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,i=null,n,r){if("string"==typeof e)e=this.nodeType(e);else if(e instanceof _B){if(e.schema!=this)throw RangeError("Node type from different schema used ("+e.name+")")}else throw RangeError("Invalid node type: "+e);return e.createChecked(i,n,r)}text(e,i){let n=this.nodes.text;return new _E(n,n.defaultAttrs,e,_d.setFrom(i))}mark(e,i){return"string"==typeof e&&(e=this.marks[e]),e.create(i)}nodeType(e){let i=this.nodes[e];if(!i)throw RangeError("Unknown node type: "+e);return i}}function _H(e,i){let n=[];for(let r=0;r<i.length;r++){let s=i[r],o=e.marks[s],a=o;if(o)n.push(o);else for(let i in e.marks){let r=e.marks[i];("_"==s||r.spec.group&&r.spec.group.split(" ").indexOf(s)>-1)&&n.push(a=r)}if(!a)throw SyntaxError("Unknown mark type: '"+i[r]+"'")}return n}class _${constructor(e,i){this.schema=e,this.rules=i,this.tags=[],this.styles=[];let n=this.matchedStyles=[];i.forEach(e=>{if(null!=e.tag)this.tags.push(e);else if(null!=e.style){let i=/[^=]*/.exec(e.style)[0];0>n.indexOf(i)&&n.push(i),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let n=e.nodes[i.node];return n.contentMatch.matchType(n)})}parse(e,i={}){let n=new _X(this,i,!1);return n.addAll(e,_d.none,i.from,i.to),n.finish()}parseSlice(e,i={}){let n=new _X(this,i,!0);return n.addAll(e,_d.none,i.from,i.to),_p.maxOpen(n.finish())}matchTag(e,i,n){for(let o=n?this.tags.indexOf(n)+1:0;o<this.tags.length;o++){var r,s;let n=this.tags[o];if(r=e,s=n.tag,(r.matches||r.msMatchesSelector||r.webkitMatchesSelector||r.mozMatchesSelector).call(r,s)&&(void 0===n.namespace||e.namespaceURI==n.namespace)&&(!n.context||i.matchesContext(n.context))){if(n.getAttrs){let i=n.getAttrs(e);if(!1===i)continue;n.attrs=i||void 0}return n}}}matchStyle(e,i,n,r){for(let s=r?this.styles.indexOf(r)+1:0;s<this.styles.length;s++){let r=this.styles[s],o=r.style;if(0==o.indexOf(e)&&(!r.context||n.matchesContext(r.context))&&(!(o.length>e.length)||61==o.charCodeAt(e.length)&&o.slice(e.length+1)==i)){if(r.getAttrs){let e=r.getAttrs(i);if(!1===e)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let i=[];function n(e){let n=null==e.priority?50:e.priority,r=0;for(;r<i.length;r++){let e=i[r];if((null==e.priority?50:e.priority)<n)break}i.splice(r,0,e)}for(let i in e.marks){let r=e.marks[i].spec.parseDOM;r&&r.forEach(e=>{n(e=_J(e)),e.mark||e.ignore||e.clearMark||(e.mark=i)})}for(let i in e.nodes){let r=e.nodes[i].spec.parseDOM;r&&r.forEach(e=>{n(e=_J(e)),e.node||e.ignore||e.mark||(e.node=i)})}return i}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new _$(e,_$.schemaRules(e)))}}let _U={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},_V={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},_q={ol:!0,ul:!0};function _Y(e,i,n){return null!=i?!!i|2*("full"===i):e&&"pre"==e.whitespace?3:-5&n}class _K{constructor(e,i,n,r,s,o){this.type=e,this.attrs=i,this.marks=n,this.solid=r,this.options=o,this.content=[],this.activeMarks=_d.none,this.match=s||(4&o?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let i=this.type.contentMatch.fillBefore(_a.from(e));if(i)this.match=this.type.contentMatch.matchFragment(i);else{let i=this.type.contentMatch,n;return(n=i.findWrapping(e.type))?(this.match=i,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(1&this.options)){let e=this.content[this.content.length-1],i;e&&e.isText&&(i=/[ \t\r\n\u000c]+$/.exec(e.text))&&(e.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=e.withText(e.text.slice(0,e.text.length-i[0].length)))}let i=_a.from(this.content);return!e&&this.match&&(i=i.append(this.match.fillBefore(_a.empty,!0))),this.type?this.type.create(this.attrs,i,this.marks):i}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!_U.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class _X{constructor(e,i,n){this.parser=e,this.options=i,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=i.topNode,s,o=_Y(null,i.preserveWhitespace,0)|4*!!n;s=r?new _K(r.type,r.attrs,_d.none,!0,i.topMatch||r.type.contentMatch,o):n?new _K(null,null,_d.none,!0,null,o):new _K(e.schema.topNodeType,null,_d.none,!0,null,o),this.nodes=[s],this.find=i.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,i){3==e.nodeType?this.addTextNode(e,i):1==e.nodeType&&this.addElement(e,i)}addTextNode(e,i){let n=e.nodeValue,r=this.top,s=2&r.options?"full":this.localPreserveWS||(1&r.options)>0,{schema:o}=this.parser;if("full"===s||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(s)if("full"===s)n=n.replace(/\r\n?/g,"\n");else if(o.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(o.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(o.linebreakReplacement.create(),i,!0),e[n]&&this.insertNode(o.text(e[n]),i,!/\S/.test(e[n]));n=""}else n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let i=r.content[r.content.length-1],s=e.previousSibling;(!i||s&&"BR"==s.nodeName||i.isText&&/[ \t\r\n\u000c]$/.test(i.text))&&(n=n.slice(1))}n&&this.insertNode(o.text(n),i,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,i,n){let r=this.localPreserveWS,s=this.top;("PRE"==e.tagName||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),a;_q.hasOwnProperty(o)&&this.parser.normalizeLists&&function(e){for(let i=e.firstChild,n=null;i;i=i.nextSibling){let e=1==i.nodeType?i.nodeName.toLowerCase():null;e&&_q.hasOwnProperty(e)&&n?(n.appendChild(i),i=n):"li"==e?n=i:e&&(n=null)}}(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(a=this.parser.matchTag(e,this,n));e:if(l?l.ignore:_V.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,i);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let n,r=this.needsBlock;if(_U.hasOwnProperty(o))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),n=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,i);break e}let a=l&&l.skip?i:this.readStyles(e,i);a&&this.addAll(e,a),n&&this.sync(s),this.needsBlock=r}else{let n=this.readStyles(e,i);n&&this.addElementByRule(e,l,n,!1===l.consuming?a:void 0)}this.localPreserveWS=r}leafFallback(e,i){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"),i)}ignoreFallback(e,i){"BR"!=e.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),i,!0)}readStyles(e,i){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],s=n.getPropertyValue(r);if(s)for(let e;;){let n=this.parser.matchStyle(r,s,this,e);if(!n)break;if(n.ignore)return null;if(i=n.clearMark?i.filter(e=>!n.clearMark(e)):i.concat(this.parser.schema.marks[n.mark].create(n.attrs)),!1===n.consuming)e=n;else break}}return i}addElementByRule(e,i,n,r){let s,o;if(i.node)if((o=this.parser.schema.nodes[i.node]).isLeaf)this.insertNode(o.create(i.attrs),n,"BR"==e.nodeName)||this.leafFallback(e,n);else{let e=this.enter(o,i.attrs||null,n,i.preserveWhitespace);e&&(s=!0,n=e)}else{let e=this.parser.schema.marks[i.mark];n=n.concat(e.create(i.attrs))}let a=this.top;if(o&&o.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(i.getContent)this.findInside(e),i.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;"string"==typeof i.contentElement?r=e.querySelector(i.contentElement):"function"==typeof i.contentElement?r=i.contentElement(e):i.contentElement&&(r=i.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}s&&this.sync(a)&&this.open--}addAll(e,i,n,r){let s=n||0;for(let o=n?e.childNodes[n]:e.firstChild,a=null==r?null:e.childNodes[r];o!=a;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,i);this.findAtPoint(e,s)}findPlace(e,i,n){let r,s;for(let i=this.open,o=0;i>=0;i--){let a=this.nodes[i],l=a.findWrapping(e);if(l&&(!r||r.length>l.length+o)&&(r=l,s=a,!l.length))break;if(a.solid){if(n)break;o+=2}}if(!r)return null;this.sync(s);for(let e=0;e<r.length;e++)i=this.enterInner(r[e],null,i,!1);return i}insertNode(e,i,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(i=this.enterInner(e,null,i))}let r=this.findPlace(e,i,n);if(r){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let n=_d.none;for(let s of r.concat(e.marks))(i.type?i.type.allowsMarkType(s.type):_G(s.type,e.type))&&(n=s.addToSet(n));return i.content.push(e.mark(n)),!0}return!1}enter(e,i,n,r){let s=this.findPlace(e.create(i),n,!1);return s&&(s=this.enterInner(e,i,n,!0,r)),s}enterInner(e,i,n,r=!1,s){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let a=_Y(e,s,o.options);4&o.options&&0==o.content.length&&(a|=4);let l=_d.none;return n=n.filter(i=>(o.type?!o.type.allowsMarkType(i.type):!_G(i.type,e))||(l=i.addToSet(l),!1)),this.nodes.push(new _K(e,i,l,r,null,a)),this.open++,n}closeExtra(e=!1){let i=this.nodes.length-1;if(i>this.open){for(;i>this.open;i--)this.nodes[i-1].content.push(this.nodes[i].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let i=this.open;i>=0;i--)if(this.nodes[i]==e)return this.open=i,!0;else this.localPreserveWS&&(this.nodes[i].options|=1);return!1}get currentPos(){this.closeExtra();let e=0;for(let i=this.open;i>=0;i--){let n=this.nodes[i].content;for(let i=n.length-1;i>=0;i--)e+=n[i].nodeSize;i&&e++}return e}findAtPoint(e,i){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==i&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let i=0;i<this.find.length;i++)null==this.find[i].pos&&1==e.nodeType&&e.contains(this.find[i].node)&&(this.find[i].pos=this.currentPos)}findAround(e,i,n){if(e!=i&&this.find)for(let r=0;r<this.find.length;r++)null==this.find[r].pos&&1==e.nodeType&&e.contains(this.find[r].node)&&i.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let i=0;i<this.find.length;i++)this.find[i].node==e&&(this.find[i].pos=this.currentPos-(e.nodeValue.length-this.find[i].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let i=e.split("/"),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),s=-(n?n.depth+1:0)+ +!r,o=(e,a)=>{for(;e>=0;e--){let l=i[e];if(""==l){if(e==i.length-1||0==e)continue;for(;a>=s;a--)if(o(e-1,a))return!0;return!1}{let e=a>0||0==a&&r?this.nodes[a].type:n&&a>=s?n.node(a-s).type:null;if(!e||e.name!=l&&!e.isInGroup(l))return!1;a--}}return!0};return o(i.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let i=e.depth;i>=0;i--){let n=e.node(i).contentMatchAt(e.indexAfter(i)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let i=this.parser.schema.nodes[e];if(i.isTextblock&&i.defaultAttrs)return i}}}function _J(e){let i={};for(let n in e)i[n]=e[n];return i}function _G(e,i){let n=i.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(e))continue;let o=[],a=e=>{o.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:s}=e.edge(n);if(r==i||0>o.indexOf(s)&&a(s))return!0}};if(a(s.contentMatch))return!0}}class _Z{constructor(e,i){this.nodes=e,this.marks=i}serializeFragment(e,i={},n){n||(n=_0(i).createDocumentFragment());let r=n,s=[];return e.forEach(e=>{if(s.length||e.marks.length){let n=0,o=0;for(;n<s.length&&o<e.marks.length;){let i=e.marks[o];if(!this.marks[i.type.name]){o++;continue}if(!i.eq(s[n][0])||!1===i.type.spec.spanning)break;n++,o++}for(;n<s.length;)r=s.pop()[1];for(;o<e.marks.length;){let n=e.marks[o++],a=this.serializeMark(n,e.isInline,i);a&&(s.push([n,r]),r.appendChild(a.dom),r=a.contentDOM||a.dom)}}r.appendChild(this.serializeNodeInner(e,i))}),n}serializeNodeInner(e,i){let{dom:n,contentDOM:r}=_2(_0(i),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,i,r)}return n}serializeNode(e,i={}){let n=this.serializeNodeInner(e,i);for(let r=e.marks.length-1;r>=0;r--){let s=this.serializeMark(e.marks[r],e.isInline,i);s&&((s.contentDOM||s.dom).appendChild(n),n=s.dom)}return n}serializeMark(e,i,n={}){let r=this.marks[e.type.name];return r&&_2(_0(n),r(e,i),null,e.attrs)}static renderSpec(e,i,n=null,r){return _2(e,i,n,r)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new _Z(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let i=_Q(e.nodes);return i.text||(i.text=e=>e.text),i}static marksFromSchema(e){return _Q(e.marks)}}function _Q(e){let i={};for(let n in e){let r=e[n].spec.toDOM;r&&(i[n]=r)}return i}function _0(e){return e.document||window.document}let _1=new WeakMap;function _2(e,i,n,r){let s,o,a;if("string"==typeof i)return{dom:e.createTextNode(i)};if(null!=i.nodeType)return{dom:i};if(i.dom&&null!=i.dom.nodeType)return i;let l=i[0],c;if("string"!=typeof l)throw RangeError("Invalid array passed to renderSpec");if(r&&(void 0===(o=_1.get(r))&&_1.set(r,(a=null,!function e(i){if(i&&"object"==typeof i)if(Array.isArray(i))if("string"==typeof i[0])a||(a=[]),a.push(i);else for(let n=0;n<i.length;n++)e(i[n]);else for(let n in i)e(i[n])}(r),o=a)),c=o)&&c.indexOf(i)>-1)throw RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let h=l.indexOf(" ");h>0&&(n=l.slice(0,h),l=l.slice(h+1));let d=n?e.createElementNS(n,l):e.createElement(l),u=i[1],p=1;if(u&&"object"==typeof u&&null==u.nodeType&&!Array.isArray(u)){for(let e in p=2,u)if(null!=u[e]){let i=e.indexOf(" ");i>0?d.setAttributeNS(e.slice(0,i),e.slice(i+1),u[e]):"style"==e&&d.style?d.style.cssText=u[e]:d.setAttribute(e,u[e])}}for(let o=p;o<i.length;o++){let a=i[o];if(0===a){if(o<i.length-1||o>p)throw RangeError("Content hole must be the only child of its parent node");return{dom:d,contentDOM:d}}{let{dom:i,contentDOM:o}=_2(e,a,n,r);if(d.appendChild(i),o){if(s)throw RangeError("Multiple content holes");s=o}}}return{dom:d,contentDOM:s}}class _5{constructor(e,i,n){this.pos=e,this.delInfo=i,this.recover=n}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class _3{constructor(e,i=!1){if(this.ranges=e,this.inverted=i,!e.length&&_3.empty)return _3.empty}recover(e){let i=0,n=65535&e;if(!this.inverted)for(let e=0;e<n;e++)i+=this.ranges[3*e+2]-this.ranges[3*e+1];return this.ranges[3*n]+i+(e-(65535&e))/65536}mapResult(e,i=1){return this._map(e,i,!1)}map(e,i=1){return this._map(e,i,!0)}_map(e,i,n){let r=0,s=this.inverted?2:1,o=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?r:0);if(l>e)break;let c=this.ranges[a+s],h=this.ranges[a+o],d=l+c;if(e<=d){let s=c?e==l?-1:e==d?1:i:i,o=l+r+(s<0?0:h);if(n)return o;let u=e==(i<0?l:d)?null:a/3+(e-l)*65536,p=e==l?2:e==d?1:4;return(i<0?e!=l:e!=d)&&(p|=8),new _5(o,p,u)}r+=h-c}return n?e+r:new _5(e+r,0,null)}touches(e,i){let n=0,r=65535&i,s=this.inverted?2:1,o=this.inverted?1:2;for(let i=0;i<this.ranges.length;i+=3){let a=this.ranges[i]-(this.inverted?n:0);if(a>e)break;let l=this.ranges[i+s];if(e<=a+l&&i==3*r)return!0;n+=this.ranges[i+o]-l}return!1}forEach(e){let i=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,s=0;r<this.ranges.length;r+=3){let o=this.ranges[r],a=o-(this.inverted?s:0),l=o+(this.inverted?0:s),c=this.ranges[r+i],h=this.ranges[r+n];e(a,a+c,l,l+h),s+=h-c}}invert(){return new _3(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return 0==e?_3.empty:new _3(e<0?[0,-e,0]:[0,0,e])}}_3.empty=new _3([]);class _4{constructor(e,i,n=0,r=e?e.length:0){this.mirror=i,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||i)}get maps(){return this._maps}slice(e=0,i=this.maps.length){return new _4(this._maps,this.mirror,e,i)}appendMap(e,i){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),null!=i&&this.setMirror(this._maps.length-1,i)}appendMapping(e){for(let i=0,n=this._maps.length;i<e._maps.length;i++){let r=e.getMirror(i);this.appendMap(e._maps[i],null!=r&&r<i?n+r:void 0)}}getMirror(e){if(this.mirror){for(let i=0;i<this.mirror.length;i++)if(this.mirror[i]==e)return this.mirror[i+(i%2?-1:1)]}}setMirror(e,i){this.mirror||(this.mirror=[]),this.mirror.push(e,i)}appendMappingInverted(e){for(let i=e.maps.length-1,n=this._maps.length+e._maps.length;i>=0;i--){let r=e.getMirror(i);this.appendMap(e._maps[i].invert(),null!=r&&r>i?n-r-1:void 0)}}invert(){let e=new _4;return e.appendMappingInverted(this),e}map(e,i=1){if(this.mirror)return this._map(e,i,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,i);return e}mapResult(e,i=1){return this._map(e,i,!1)}_map(e,i,n){let r=0;for(let n=this.from;n<this.to;n++){let s=this._maps[n].mapResult(e,i);if(null!=s.recover){let i=this.getMirror(n);if(null!=i&&i>n&&i<this.to){n=i,e=this._maps[i].recover(s.recover);continue}}r|=s.delInfo,e=s.pos}return n?e:new _5(e,r,null)}}let _6=Object.create(null);class _8{getMap(){return _3.empty}merge(e){return null}static fromJSON(e,i){if(!i||!i.stepType)throw RangeError("Invalid input for Step.fromJSON");let n=_6[i.stepType];if(!n)throw RangeError(`No step type ${i.stepType} defined`);return n.fromJSON(e,i)}static jsonID(e,i){if(e in _6)throw RangeError("Duplicate use of step JSON ID "+e);return _6[e]=i,i.prototype.jsonID=e,i}}class _9{constructor(e,i){this.doc=e,this.failed=i}static ok(e){return new _9(e,null)}static fail(e){return new _9(null,e)}static fromReplace(e,i,n,r){try{return _9.ok(e.replace(i,n,r))}catch(e){if(e instanceof _u)return _9.fail(e.message);throw e}}}function _7(e,i,n){let r=[];for(let s=0;s<e.childCount;s++){let o=e.child(s);o.content.size&&(o=o.copy(_7(o.content,i,o))),o.isInline&&(o=i(o,n,s)),r.push(o)}return _a.fromArray(r)}class be extends _8{constructor(e,i,n){super(),this.from=e,this.to=i,this.mark=n}apply(e){let i=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),s=new _p(_7(i.content,(e,i)=>e.isAtom&&i.type.allowsMarkType(this.mark.type)?e.mark(this.mark.addToSet(e.marks)):e,r),i.openStart,i.openEnd);return _9.fromReplace(e,this.from,this.to,s)}invert(){return new bt(this.from,this.to,this.mark)}map(e){let i=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return i.deleted&&n.deleted||i.pos>=n.pos?null:new be(i.pos,n.pos,this.mark)}merge(e){return e instanceof be&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new be(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,i){if("number"!=typeof i.from||"number"!=typeof i.to)throw RangeError("Invalid input for AddMarkStep.fromJSON");return new be(i.from,i.to,e.markFromJSON(i.mark))}}_8.jsonID("addMark",be);class bt extends _8{constructor(e,i,n){super(),this.from=e,this.to=i,this.mark=n}apply(e){let i=e.slice(this.from,this.to),n=new _p(_7(i.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),i.openStart,i.openEnd);return _9.fromReplace(e,this.from,this.to,n)}invert(){return new be(this.from,this.to,this.mark)}map(e){let i=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return i.deleted&&n.deleted||i.pos>=n.pos?null:new bt(i.pos,n.pos,this.mark)}merge(e){return e instanceof bt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new bt(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,i){if("number"!=typeof i.from||"number"!=typeof i.to)throw RangeError("Invalid input for RemoveMarkStep.fromJSON");return new bt(i.from,i.to,e.markFromJSON(i.mark))}}_8.jsonID("removeMark",bt);class bi extends _8{constructor(e,i){super(),this.pos=e,this.mark=i}apply(e){let i=e.nodeAt(this.pos);if(!i)return _9.fail("No node at mark step's position");let n=i.type.create(i.attrs,null,this.mark.addToSet(i.marks));return _9.fromReplace(e,this.pos,this.pos+1,new _p(_a.from(n),0,+!i.isLeaf))}invert(e){let i=e.nodeAt(this.pos);if(i){let e=this.mark.addToSet(i.marks);if(e.length==i.marks.length){for(let n=0;n<i.marks.length;n++)if(!i.marks[n].isInSet(e))return new bi(this.pos,i.marks[n]);return new bi(this.pos,this.mark)}}return new bn(this.pos,this.mark)}map(e){let i=e.mapResult(this.pos,1);return i.deletedAfter?null:new bi(i.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,i){if("number"!=typeof i.pos)throw RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new bi(i.pos,e.markFromJSON(i.mark))}}_8.jsonID("addNodeMark",bi);class bn extends _8{constructor(e,i){super(),this.pos=e,this.mark=i}apply(e){let i=e.nodeAt(this.pos);if(!i)return _9.fail("No node at mark step's position");let n=i.type.create(i.attrs,null,this.mark.removeFromSet(i.marks));return _9.fromReplace(e,this.pos,this.pos+1,new _p(_a.from(n),0,+!i.isLeaf))}invert(e){let i=e.nodeAt(this.pos);return i&&this.mark.isInSet(i.marks)?new bi(this.pos,this.mark):this}map(e){let i=e.mapResult(this.pos,1);return i.deletedAfter?null:new bn(i.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,i){if("number"!=typeof i.pos)throw RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new bn(i.pos,e.markFromJSON(i.mark))}}_8.jsonID("removeNodeMark",bn);class br extends _8{constructor(e,i,n,r=!1){super(),this.from=e,this.to=i,this.slice=n,this.structure=r}apply(e){return this.structure&&bo(e,this.from,this.to)?_9.fail("Structure replace would overwrite content"):_9.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new _3([this.from,this.to-this.from,this.slice.size])}invert(e){return new br(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let i=e.mapResult(this.to,-1),n=this.from==this.to&&br.MAP_BIAS<0?i:e.mapResult(this.from,1);return n.deletedAcross&&i.deletedAcross?null:new br(n.pos,Math.max(n.pos,i.pos),this.slice,this.structure)}merge(e){if(!(e instanceof br)||e.structure||this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart)if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;else{let i=this.slice.size+e.slice.size==0?_p.empty:new _p(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new br(e.from,this.to,i,this.structure)}{let i=this.slice.size+e.slice.size==0?_p.empty:new _p(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new br(this.from,this.to+(e.to-e.from),i,this.structure)}}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,i){if("number"!=typeof i.from||"number"!=typeof i.to)throw RangeError("Invalid input for ReplaceStep.fromJSON");return new br(i.from,i.to,_p.fromJSON(e,i.slice),!!i.structure)}}br.MAP_BIAS=1,_8.jsonID("replace",br);class bs extends _8{constructor(e,i,n,r,s,o,a=!1){super(),this.from=e,this.to=i,this.gapFrom=n,this.gapTo=r,this.slice=s,this.insert=o,this.structure=a}apply(e){if(this.structure&&(bo(e,this.from,this.gapFrom)||bo(e,this.gapTo,this.to)))return _9.fail("Structure gap-replace would overwrite content");let i=e.slice(this.gapFrom,this.gapTo);if(i.openStart||i.openEnd)return _9.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,i.content);return n?_9.fromReplace(e,this.from,this.to,n):_9.fail("Content does not fit in gap")}getMap(){return new _3([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let i=this.gapTo-this.gapFrom;return new bs(this.from,this.from+this.slice.size+i,this.from+this.insert,this.from+this.insert+i,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let i=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),r=this.from==this.gapFrom?i.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return i.deletedAcross&&n.deletedAcross||r<i.pos||s>n.pos?null:new bs(i.pos,n.pos,r,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,i){if("number"!=typeof i.from||"number"!=typeof i.to||"number"!=typeof i.gapFrom||"number"!=typeof i.gapTo||"number"!=typeof i.insert)throw RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new bs(i.from,i.to,i.gapFrom,i.gapTo,_p.fromJSON(e,i.slice),i.insert,!!i.structure)}}function bo(e,i,n){let r=e.resolve(i),s=n-i,o=r.depth;for(;s>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,s--;if(s>0){let e=r.node(o).maybeChild(r.indexAfter(o));for(;s>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,s--}}return!1}function ba(e,i,n,r=n.contentMatch,s=!0){let o=e.doc.nodeAt(i),a=[],l=i+1;for(let i=0;i<o.childCount;i++){let c=o.child(i),h=l+c.nodeSize,d=r.matchType(c.type);if(d){r=d;for(let i=0;i<c.marks.length;i++)n.allowsMarkType(c.marks[i].type)||e.step(new bt(l,h,c.marks[i]));if(s&&c.isText&&"pre"!=n.whitespace){let e,i=/\r?\n|\r/g,r;for(;e=i.exec(c.text);)r||(r=new _p(_a.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),a.push(new br(l+e.index,l+e.index+e[0].length,r))}}else a.push(new br(l,h,_p.empty));l=h}if(!r.validEnd){let i=r.fillBefore(_a.empty,!0);e.replace(l,l,new _p(i,0,0))}for(let i=a.length-1;i>=0;i--)e.step(a[i])}function bl(e){let i=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,s=0;;--n){let o=e.$from.node(n),a=e.$from.index(n)+r,l=e.$to.indexAfter(n)-s;if(n<e.depth&&o.canReplace(a,l,i))return n;if(0==n||o.type.spec.isolating||!((0==a||o.canReplace(a,o.childCount))&&(l==o.childCount||o.canReplace(0,l))))break;a&&(r=1),l<o.childCount&&(s=1)}return null}function bc(e,i,n=null,r=e){let s=function(e,i){let{parent:n,startIndex:r,endIndex:s}=e,o=n.contentMatchAt(r).findWrapping(i);if(!o)return null;let a=o.length?o[0]:i;return n.canReplaceWith(r,s,a)?o:null}(e,i),o=s&&function(e,i){let{parent:n,startIndex:r,endIndex:s}=e,o=n.child(r),a=i.contentMatch.findWrapping(o.type);if(!a)return null;let l=(a.length?a[a.length-1]:i).contentMatch;for(let e=r;l&&e<s;e++)l=l.matchType(n.child(e).type);return l&&l.validEnd?a:null}(r,i);return o?s.map(bh).concat({type:i,attrs:n}).concat(o.map(bh)):null}function bh(e){return{type:e,attrs:null}}function bd(e,i,n,r){i.forEach((s,o)=>{if(s.isText){let a,l=/\r?\n|\r/g;for(;a=l.exec(s.text);){let s=e.mapping.slice(r).map(n+1+o+a.index);e.replaceWith(s,s+1,i.type.schema.linebreakReplacement.create())}}})}function bu(e,i,n,r){i.forEach((s,o)=>{if(s.type==s.type.schema.linebreakReplacement){let s=e.mapping.slice(r).map(n+1+o);e.replaceWith(s,s+1,i.type.schema.text("\n"))}})}function bp(e,i,n=1,r){let s=e.resolve(i),o=s.depth-n,a=r&&r[r.length-1]||s.parent;if(o<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!a.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let e=s.depth-1,i=n-2;e>o;e--,i--){let n=s.node(e),o=s.index(e);if(n.type.spec.isolating)return!1;let a=n.content.cutByIndex(o,n.childCount),l=r&&r[i+1];l&&(a=a.replaceChild(0,l.type.create(l.attrs)));let c=r&&r[i]||n;if(!n.canReplace(o+1,n.childCount)||!c.type.validContent(a))return!1}let l=s.indexAfter(o),c=r&&r[0];return s.node(o).canReplaceWith(l,l,c?c.type:s.node(o+1).type)}function bf(e,i){let n=e.resolve(i),r=n.index();return bm(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function bm(e,i){return!!(e&&i&&!e.isLeaf&&function(e,i){i.content.size||e.type.compatibleContent(i.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let s=0;s<i.childCount;s++){let o=i.child(s),a=o.type==r?e.type.schema.nodes.text:o.type;if(!(n=n.matchType(a))||!e.type.allowsMarks(o.marks))return!1}return n.validEnd}(e,i))}function bg(e,i,n=-1){let r=e.resolve(i);for(let e=r.depth;;e--){let s,o,a=r.index(e);if(e==r.depth?(s=r.nodeBefore,o=r.nodeAfter):n>0?(s=r.node(e+1),a++,o=r.node(e).maybeChild(a)):(s=r.node(e).maybeChild(a-1),o=r.node(e+1)),s&&!s.isTextblock&&bm(s,o)&&r.node(e).canReplace(a,a+1))return i;if(0==e)break;i=n<0?r.before(e):r.after(e)}}function bv(e,i,n){let r=e.resolve(i);if(!n.content.size)return i;let s=n.content;for(let e=0;e<n.openStart;e++)s=s.firstChild.content;for(let e=1;e<=(0==n.openStart&&n.size?2:1);e++)for(let i=r.depth;i>=0;i--){let n=i==r.depth?0:r.pos<=(r.start(i+1)+r.end(i+1))/2?-1:1,o=r.index(i)+ +(n>0),a=r.node(i),l=!1;if(1==e)l=a.canReplace(o,o,s);else{let e=a.contentMatchAt(o).findWrapping(s.firstChild.type);l=e&&a.canReplaceWith(o,o,e[0])}if(l)return 0==n?r.pos:n<0?r.before(i+1):r.after(i+1)}return null}function by(e,i,n=i,r=_p.empty){if(i==n&&!r.size)return null;let s=e.resolve(i),o=e.resolve(n);return b_(s,o,r)?new br(i,n,r):new bb(s,o,r).fit()}function b_(e,i,n){return!n.openStart&&!n.openEnd&&e.start()==i.start()&&e.parent.canReplace(e.index(),i.index(),n.content)}_8.jsonID("replaceAround",bs);class bb{constructor(e,i,n){this.$from=e,this.$to=i,this.unplaced=n,this.frontier=[],this.placed=_a.empty;for(let i=0;i<=e.depth;i++){let n=e.node(i);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=_a.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),i=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let s=this.placed,o=n.depth,a=r.depth;for(;o&&a&&1==s.childCount;)s=s.firstChild.content,o--,a--;let l=new _p(s,o,a);return e>-1?new bs(n.pos,e,this.$to.pos,this.$to.end(),l,i):l.size||n.pos!=this.$to.pos?new br(n.pos,r.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let i=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let s=i.firstChild;if(i.childCount>1&&(r=0),s.type.spec.isolating&&r<=n){e=n;break}i=s.content}for(let i=1;i<=2;i++)for(let n=1==i?e:this.unplaced.openStart;n>=0;n--){let e=null,r=(n?(e=bS(this.unplaced.content,n-1).firstChild).content:this.unplaced.content).firstChild;for(let s=this.depth;s>=0;s--){let{type:o,match:a}=this.frontier[s],l,c=null;if(1==i&&(r?a.matchType(r.type)||(c=a.fillBefore(_a.from(r),!1)):e&&o.compatibleContent(e.type)))return{sliceDepth:n,frontierDepth:s,parent:e,inject:c};if(2==i&&r&&(l=a.findWrapping(r.type)))return{sliceDepth:n,frontierDepth:s,parent:e,wrap:l};if(e&&a.matchType(e.type))break}}}openMore(){let{content:e,openStart:i,openEnd:n}=this.unplaced,r=bS(e,i);return!!r.childCount&&!r.firstChild.isLeaf&&(this.unplaced=new _p(e,i+1,Math.max(n,r.size+i>=e.size-n?i+1:0)),!0)}dropNode(){let{content:e,openStart:i,openEnd:n}=this.unplaced,r=bS(e,i);if(r.childCount<=1&&i>0){let s=e.size-i<=i+r.size;this.unplaced=new _p(bx(e,i-1,1),i-1,s?i-1:n)}else this.unplaced=new _p(bx(e,i,1),i,n)}placeNodes({sliceDepth:e,frontierDepth:i,parent:n,inject:r,wrap:s}){for(;this.depth>i;)this.closeFrontierNode();if(s)for(let e=0;e<s.length;e++)this.openFrontierNode(s[e]);let o=this.unplaced,a=n?n.content:o.content,l=o.openStart-e,c=0,h=[],{match:d,type:u}=this.frontier[i];if(r){for(let e=0;e<r.childCount;e++)h.push(r.child(e));d=d.matchFragment(r)}let p=a.size+e-(o.content.size-o.openEnd);for(;c<a.childCount;){let e=a.child(c),i=d.matchType(e.type);if(!i)break;(++c>1||0==l||e.content.size)&&(d=i,h.push(function e(i,n,r){if(n<=0)return i;let s=i.content;return n>1&&(s=s.replaceChild(0,e(s.firstChild,n-1,1==s.childCount?r-1:0))),n>0&&(s=i.type.contentMatch.fillBefore(s).append(s),r<=0&&(s=s.append(i.type.contentMatch.matchFragment(s).fillBefore(_a.empty,!0)))),i.copy(s)}(e.mark(u.allowedMarks(e.marks)),1==c?l:0,c==a.childCount?p:-1)))}let f=c==a.childCount;f||(p=-1),this.placed=bw(this.placed,i,_a.from(h)),this.frontier[i].match=d,f&&p<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,i=a;e<p;e++){let e=i.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),i=e.content}this.unplaced=f?0==e?_p.empty:new _p(bx(o.content,e-1,1),e-1,p<0?o.openEnd:e-1):new _p(bx(o.content,e,c),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return -1;let e=this.frontier[this.depth],i;if(!e.type.isTextblock||!bk(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(i=this.findCloseLevel(this.$to))&&i.depth==this.depth)return -1;let{depth:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){t:for(let i=Math.min(this.depth,e.depth);i>=0;i--){let{match:n,type:r}=this.frontier[i],s=i<e.depth&&e.end(i+1)==e.pos+(e.depth-(i+1)),o=bk(e,i,r,n,s);if(o){for(let n=i-1;n>=0;n--){let{match:i,type:r}=this.frontier[n],s=bk(e,n,r,i,!0);if(!s||s.childCount)continue t}return{depth:i,fit:o,move:s?e.doc.resolve(e.after(i+1)):e}}}}close(e){let i=this.findCloseLevel(e);if(!i)return null;for(;this.depth>i.depth;)this.closeFrontierNode();i.fit.childCount&&(this.placed=bw(this.placed,i.depth,i.fit)),e=i.move;for(let n=i.depth+1;n<=e.depth;n++){let i=e.node(n),r=i.type.contentMatch.fillBefore(i.content,!0,e.index(n));this.openFrontierNode(i.type,i.attrs,r)}return e}openFrontierNode(e,i=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=bw(this.placed,this.depth,_a.from(e.create(i,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(_a.empty,!0);e.childCount&&(this.placed=bw(this.placed,this.frontier.length,e))}}function bx(e,i,n){return 0==i?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(bx(e.firstChild.content,i-1,n)))}function bw(e,i,n){return 0==i?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(bw(e.lastChild.content,i-1,n)))}function bS(e,i){for(let n=0;n<i;n++)e=e.firstChild.content;return e}function bk(e,i,n,r,s){let o=e.node(i),a=s?e.indexAfter(i):e.index(i);if(a==o.childCount&&!n.compatibleContent(o.type))return null;let l=r.fillBefore(o.content,!0,a);return l&&!function(e,i,n){for(let r=n;r<i.childCount;r++)if(!e.allowsMarks(i.child(r).marks))return!0;return!1}(n,o.content,a)?l:null}function bC(e,i){let n=[],r=Math.min(e.depth,i.depth);for(let s=r;s>=0;s--){let r=e.start(s);if(r<e.pos-(e.depth-s)||i.end(s)>i.pos+(i.depth-s)||e.node(s).type.spec.isolating||i.node(s).type.spec.isolating)break;(r==i.start(s)||s==e.depth&&s==i.depth&&e.parent.inlineContent&&i.parent.inlineContent&&s&&i.start(s-1)==r-1)&&n.push(s)}return n}class bT extends _8{constructor(e,i,n){super(),this.pos=e,this.attr=i,this.value=n}apply(e){let i=e.nodeAt(this.pos);if(!i)return _9.fail("No node at attribute step's position");let n=Object.create(null);for(let e in i.attrs)n[e]=i.attrs[e];n[this.attr]=this.value;let r=i.type.create(n,null,i.marks);return _9.fromReplace(e,this.pos,this.pos+1,new _p(_a.from(r),0,+!i.isLeaf))}getMap(){return _3.empty}invert(e){return new bT(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let i=e.mapResult(this.pos,1);return i.deletedAfter?null:new bT(i.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,i){if("number"!=typeof i.pos||"string"!=typeof i.attr)throw RangeError("Invalid input for AttrStep.fromJSON");return new bT(i.pos,i.attr,i.value)}}_8.jsonID("attr",bT);class bE extends _8{constructor(e,i){super(),this.attr=e,this.value=i}apply(e){let i=Object.create(null);for(let n in e.attrs)i[n]=e.attrs[n];i[this.attr]=this.value;let n=e.type.create(i,e.content,e.marks);return _9.ok(n)}getMap(){return _3.empty}invert(e){return new bE(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,i){if("string"!=typeof i.attr)throw RangeError("Invalid input for DocAttrStep.fromJSON");return new bE(i.attr,i.value)}}_8.jsonID("docAttr",bE);let bN=class extends Error{};(bN=function e(i){let n=Error.call(this,i);return n.__proto__=e.prototype,n}).prototype=Object.create(Error.prototype),bN.prototype.constructor=bN,bN.prototype.name="TransformError";class bM{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new _4}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let i=this.maybeStep(e);if(i.failed)throw new bN(i.failed);return this}maybeStep(e){let i=e.apply(this.doc);return i.failed||this.addStep(e,i.doc),i}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,i=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let r=this.mapping.maps[n];n&&(e=r.map(e,1),i=r.map(i,-1)),r.forEach((n,r,s,o)=>{e=Math.min(e,s),i=Math.max(i,o)})}return 1e9==e?null:{from:e,to:i}}addStep(e,i){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=i}replace(e,i=e,n=_p.empty){let r=by(this.doc,e,i,n);return r&&this.step(r),this}replaceWith(e,i,n){return this.replace(e,i,new _p(_a.from(n),0,0))}delete(e,i){return this.replace(e,i,_p.empty)}insert(e,i){return this.replaceWith(e,e,i)}replaceRange(e,i,n){return!function(e,i,n,r){if(!r.size)return e.deleteRange(i,n);let s=e.doc.resolve(i),o=e.doc.resolve(n);if(b_(s,o,r))return e.step(new br(i,n,r));let a=bC(s,o);0==a[a.length-1]&&a.pop();let l=-(s.depth+1);a.unshift(l);for(let e=s.depth,i=s.pos-1;e>0;e--,i--){let n=s.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;a.indexOf(e)>-1?l=e:s.before(e)==i&&a.splice(1,0,-e)}let c=a.indexOf(l),h=[],d=r.openStart;for(let e=r.content,i=0;;i++){let n=e.firstChild;if(h.push(n),i==r.openStart)break;e=n.content}for(let e=d-1;e>=0;e--){var u;let i=h[e],n=(u=i.type).spec.defining||u.spec.definingForContent;if(n&&!i.sameMarkup(s.node(Math.abs(l)-1)))d=e;else if(n||!i.type.isTextblock)break}for(let i=r.openStart;i>=0;i--){let l=(i+d+1)%(r.openStart+1),u=h[l];if(u)for(let i=0;i<a.length;i++){let h=a[(i+c)%a.length],d=!0;h<0&&(d=!1,h=-h);let p=s.node(h-1),f=s.index(h-1);if(p.canReplaceWith(f,f,u.type,u.marks))return e.replace(s.before(h),d?o.after(h):n,new _p(function e(i,n,r,s,o){if(n<r){let o=i.firstChild;i=i.replaceChild(0,o.copy(e(o.content,n+1,r,s,o)))}if(n>s){let e=o.contentMatchAt(0),n=e.fillBefore(i).append(i);i=n.append(e.matchFragment(n).fillBefore(_a.empty,!0))}return i}(r.content,0,r.openStart,l),l,r.openEnd))}}let p=e.steps.length;for(let l=a.length-1;l>=0&&(e.replace(i,n,r),!(e.steps.length>p));l--){let e=a[l];e<0||(i=s.before(e),n=o.after(e))}}(this,e,i,n),this}replaceRangeWith(e,i,n){var r=e,s=i;if(!n.isInline&&r==s&&this.doc.resolve(r).parent.content.size){let e=function(e,i,n){let r=e.resolve(i);if(r.parent.canReplaceWith(r.index(),r.index(),n))return i;if(0==r.parentOffset)for(let e=r.depth-1;e>=0;e--){let i=r.index(e);if(r.node(e).canReplaceWith(i,i,n))return r.before(e+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let i=r.indexAfter(e);if(r.node(e).canReplaceWith(i,i,n))return r.after(e+1);if(i<r.node(e).childCount)break}return null}(this.doc,r,n.type);null!=e&&(r=s=e)}return this.replaceRange(r,s,new _p(_a.from(n),0,0)),this}deleteRange(e,i){return!function(e,i,n){let r=e.doc.resolve(i),s=e.doc.resolve(n);if(r.parent.isTextblock&&s.parent.isTextblock&&r.start()!=s.start()&&0==r.parentOffset&&0==s.parentOffset){let o=r.sharedDepth(n),a=!1;for(let e=r.depth;e>o;e--)r.node(e).type.spec.isolating&&(a=!0);for(let e=s.depth;e>o;e--)s.node(e).type.spec.isolating&&(a=!0);if(!a){for(let e=r.depth;e>0&&i==r.start(e);e--)i=r.before(e);for(let e=s.depth;e>0&&n==s.start(e);e--)n=s.before(e);r=e.doc.resolve(i),s=e.doc.resolve(n)}}let o=bC(r,s);for(let i=0;i<o.length;i++){let n=o[i],a=i==o.length-1;if(a&&0==n||r.node(n).type.contentMatch.validEnd)return e.delete(r.start(n),s.end(n));if(n>0&&(a||r.node(n-1).canReplace(r.index(n-1),s.indexAfter(n-1))))return e.delete(r.before(n),s.after(n))}for(let o=1;o<=r.depth&&o<=s.depth;o++)if(i-r.start(o)==r.depth-o&&n>r.end(o)&&s.end(o)-n!=s.depth-o&&r.start(o-1)==s.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),s.index(o-1)))return e.delete(r.before(o),n);e.delete(i,n)}(this,e,i),this}lift(e,i){return!function(e,i,n){let{$from:r,$to:s,depth:o}=i,a=r.before(o+1),l=s.after(o+1),c=a,h=l,d=_a.empty,u=0;for(let e=o,i=!1;e>n;e--)i||r.index(e)>0?(i=!0,d=_a.from(r.node(e).copy(d)),u++):c--;let p=_a.empty,f=0;for(let e=o,i=!1;e>n;e--)i||s.after(e+1)<s.end(e)?(i=!0,p=_a.from(s.node(e).copy(p)),f++):h++;e.step(new bs(c,h,a,l,new _p(d.append(p),u,f),d.size-u,!0))}(this,e,i),this}join(e,i=1){return!function(e,i,n){let r=null,{linebreakReplacement:s}=e.doc.type.schema,o=e.doc.resolve(i-n),a=o.node().type;if(s&&a.inlineContent){let e="pre"==a.whitespace,i=!!a.contentMatch.matchType(s);e&&!i?r=!1:!e&&i&&(r=!0)}let l=e.steps.length;if(!1===r){let r=e.doc.resolve(i+n);bu(e,r.node(),r.before(),l)}a.inlineContent&&ba(e,i+n-1,a,o.node().contentMatchAt(o.index()),null==r);let c=e.mapping.slice(l),h=c.map(i-n);if(e.step(new br(h,c.map(i+n,-1),_p.empty,!0)),!0===r){let i=e.doc.resolve(h);bd(e,i.node(),i.before(),e.steps.length)}}(this,e,i),this}wrap(e,i){return!function(e,i,n){let r=_a.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let i=n[e].type.contentMatch.matchFragment(r);if(!i||!i.validEnd)throw RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=_a.from(n[e].type.create(n[e].attrs,r))}let s=i.start,o=i.end;e.step(new bs(s,o,s,o,new _p(r,0,0),n.length,!0))}(this,e,i),this}setBlockType(e,i=e,n,r=null){var s=this;if(!n.isTextblock)throw RangeError("Type given to setBlockType should be a textblock");let o=s.steps.length;return s.doc.nodesBetween(e,i,(e,i)=>{var a,l,c;let h,d,u="function"==typeof r?r(e):r;if(e.isTextblock&&!e.hasMarkup(n,u)&&(a=s.doc,l=s.mapping.slice(o).map(i),c=n,d=(h=a.resolve(l)).index(),h.parent.canReplaceWith(d,d+1,c))){let r=null;if(n.schema.linebreakReplacement){let e="pre"==n.whitespace,i=!!n.contentMatch.matchType(n.schema.linebreakReplacement);e&&!i?r=!1:!e&&i&&(r=!0)}!1===r&&bu(s,e,i,o),ba(s,s.mapping.slice(o).map(i,1),n,void 0,null===r);let a=s.mapping.slice(o),l=a.map(i,1),c=a.map(i+e.nodeSize,1);return s.step(new bs(l,c,l+1,c-1,new _p(_a.from(n.create(u,null,e.marks)),0,0),1,!0)),!0===r&&bd(s,e,i,o),!1}}),this}setNodeMarkup(e,i,n=null,r){return!function(e,i,n,r,s){let o=e.doc.nodeAt(i);if(!o)throw RangeError("No node at given position");n||(n=o.type);let a=n.create(r,null,s||o.marks);if(o.isLeaf)return e.replaceWith(i,i+o.nodeSize,a);if(!n.validContent(o.content))throw RangeError("Invalid content for node type "+n.name);e.step(new bs(i,i+o.nodeSize,i+1,i+o.nodeSize-1,new _p(_a.from(a),0,0),1,!0))}(this,e,i,n,r),this}setNodeAttribute(e,i,n){return this.step(new bT(e,i,n)),this}setDocAttribute(e,i){return this.step(new bE(e,i)),this}addNodeMark(e,i){return this.step(new bi(e,i)),this}removeNodeMark(e,i){let n=this.doc.nodeAt(e);if(!n)throw RangeError("No node at position "+e);if(i instanceof _d)i.isInSet(n.marks)&&this.step(new bn(e,i));else{let r=n.marks,s,o=[];for(;s=i.isInSet(r);)o.push(new bn(e,s)),r=s.removeFromSet(r);for(let e=o.length-1;e>=0;e--)this.step(o[e])}return this}split(e,i=1,n){return!function(e,i,n=1,r){let s=e.doc.resolve(i),o=_a.empty,a=_a.empty;for(let e=s.depth,i=s.depth-n,l=n-1;e>i;e--,l--){o=_a.from(s.node(e).copy(o));let i=r&&r[l];a=_a.from(i?i.type.create(i.attrs,a):s.node(e).copy(a))}e.step(new br(i,i,new _p(o.append(a),n,n),!0))}(this,e,i,n),this}addMark(e,i,n){var r;let s,o,a,l;return r=this,a=[],l=[],r.doc.nodesBetween(e,i,(r,c,h)=>{if(!r.isInline)return;let d=r.marks;if(!n.isInSet(d)&&h.type.allowsMarkType(n.type)){let h=Math.max(c,e),u=Math.min(c+r.nodeSize,i),p=n.addToSet(d);for(let e=0;e<d.length;e++)d[e].isInSet(p)||(s&&s.to==h&&s.mark.eq(d[e])?s.to=u:a.push(s=new bt(h,u,d[e])));o&&o.to==h?o.to=u:l.push(o=new be(h,u,n))}}),a.forEach(e=>r.step(e)),l.forEach(e=>r.step(e)),this}removeMark(e,i,n){var r;let s,o;return r=this,s=[],o=0,r.doc.nodesBetween(e,i,(r,a)=>{if(!r.isInline)return;o++;let l=null;if(n instanceof _F){let e=r.marks,i;for(;i=n.isInSet(e);)(l||(l=[])).push(i),e=i.removeFromSet(e)}else n?n.isInSet(r.marks)&&(l=[n]):l=r.marks;if(l&&l.length){let n=Math.min(a+r.nodeSize,i);for(let i=0;i<l.length;i++){let r=l[i],c;for(let e=0;e<s.length;e++){let i=s[e];i.step==o-1&&r.eq(s[e].style)&&(c=i)}c?(c.to=n,c.step=o):s.push({style:r,from:Math.max(a,e),to:n,step:o})}}}),s.forEach(e=>r.step(new bt(e.from,e.to,e.style))),this}clearIncompatible(e,i,n){return ba(this,e,i,n),this}}let bO=Object.create(null);class bA{constructor(e,i,n){this.$anchor=e,this.$head=i,this.ranges=n||[new bR(e.min(i),e.max(i))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let i=0;i<e.length;i++)if(e[i].$from.pos!=e[i].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,i=_p.empty){let n=i.content.lastChild,r=null;for(let e=0;e<i.openEnd;e++)r=n,n=n.lastChild;let s=e.steps.length,o=this.ranges;for(let a=0;a<o.length;a++){let{$from:l,$to:c}=o[a],h=e.mapping.slice(s);e.replaceRange(h.map(l.pos),h.map(c.pos),a?_p.empty:i),0==a&&bH(e,s,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,i){let n=e.steps.length,r=this.ranges;for(let s=0;s<r.length;s++){let{$from:o,$to:a}=r[s],l=e.mapping.slice(n),c=l.map(o.pos),h=l.map(a.pos);s?e.deleteRange(c,h):(e.replaceRangeWith(c,h,i),bH(e,n,i.isInline?-1:1))}}static findFrom(e,i,n=!1){let r=e.parent.inlineContent?new bj(e):bW(e.node(0),e.parent,e.pos,e.index(),i,n);if(r)return r;for(let r=e.depth-1;r>=0;r--){let s=i<0?bW(e.node(0),e.node(r),e.before(r+1),e.index(r),i,n):bW(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,i,n);if(s)return s}return null}static near(e,i=1){return this.findFrom(e,i)||this.findFrom(e,-i)||new bz(e.node(0))}static atStart(e){return bW(e,e,0,0,1)||new bz(e)}static atEnd(e){return bW(e,e,e.content.size,e.childCount,-1)||new bz(e)}static fromJSON(e,i){if(!i||!i.type)throw RangeError("Invalid input for Selection.fromJSON");let n=bO[i.type];if(!n)throw RangeError(`No selection type ${i.type} defined`);return n.fromJSON(e,i)}static jsonID(e,i){if(e in bO)throw RangeError("Duplicate use of selection JSON ID "+e);return bO[e]=i,i.prototype.jsonID=e,i}getBookmark(){return bj.between(this.$anchor,this.$head).getBookmark()}}bA.prototype.visible=!0;class bR{constructor(e,i){this.$from=e,this.$to=i}}let bD=!1;function bL(e){bD||e.parent.inlineContent||(bD=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class bj extends bA{constructor(e,i=e){bL(e),bL(i),super(e,i)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,i){let n=e.resolve(i.map(this.head));if(!n.parent.inlineContent)return bA.near(n);let r=e.resolve(i.map(this.anchor));return new bj(r.parent.inlineContent?r:n,n)}replace(e,i=_p.empty){if(super.replace(e,i),i==_p.empty){let i=this.$from.marksAcross(this.$to);i&&e.ensureMarks(i)}}eq(e){return e instanceof bj&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new bI(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,i){if("number"!=typeof i.anchor||"number"!=typeof i.head)throw RangeError("Invalid input for TextSelection.fromJSON");return new bj(e.resolve(i.anchor),e.resolve(i.head))}static create(e,i,n=i){let r=e.resolve(i);return new this(r,n==i?r:e.resolve(n))}static between(e,i,n){let r=e.pos-i.pos;if((!n||r)&&(n=r>=0?1:-1),!i.parent.inlineContent){let e=bA.findFrom(i,n,!0)||bA.findFrom(i,-n,!0);if(!e)return bA.near(i,n);i=e.$head}return e.parent.inlineContent||(0==r?e=i:(e=(bA.findFrom(e,-n,!0)||bA.findFrom(e,n,!0)).$anchor).pos<i.pos!=r<0&&(e=i)),new bj(e,i)}}bA.jsonID("text",bj);class bI{constructor(e,i){this.anchor=e,this.head=i}map(e){return new bI(e.map(this.anchor),e.map(this.head))}resolve(e){return bj.between(e.resolve(this.anchor),e.resolve(this.head))}}class bP extends bA{constructor(e){let i=e.nodeAfter,n=e.node(0).resolve(e.pos+i.nodeSize);super(e,n),this.node=i}map(e,i){let{deleted:n,pos:r}=i.mapResult(this.anchor),s=e.resolve(r);return n?bA.near(s):new bP(s)}content(){return new _p(_a.from(this.node),0,0)}eq(e){return e instanceof bP&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new bB(this.anchor)}static fromJSON(e,i){if("number"!=typeof i.anchor)throw RangeError("Invalid input for NodeSelection.fromJSON");return new bP(e.resolve(i.anchor))}static create(e,i){return new bP(e.resolve(i))}static isSelectable(e){return!e.isText&&!1!==e.type.spec.selectable}}bP.prototype.visible=!1,bA.jsonID("node",bP);class bB{constructor(e){this.anchor=e}map(e){let{deleted:i,pos:n}=e.mapResult(this.anchor);return i?new bI(n,n):new bB(n)}resolve(e){let i=e.resolve(this.anchor),n=i.nodeAfter;return n&&bP.isSelectable(n)?new bP(i):bA.near(i)}}class bz extends bA{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,i=_p.empty){if(i==_p.empty){e.delete(0,e.doc.content.size);let i=bA.atStart(e.doc);i.eq(e.selection)||e.setSelection(i)}else super.replace(e,i)}toJSON(){return{type:"all"}}static fromJSON(e){return new bz(e)}map(e){return new bz(e)}eq(e){return e instanceof bz}getBookmark(){return bF}}bA.jsonID("all",bz);let bF={map(){return this},resolve:e=>new bz(e)};function bW(e,i,n,r,s,o=!1){if(i.inlineContent)return bj.create(e,n);for(let a=r-(s>0?0:1);s>0?a<i.childCount:a>=0;a+=s){let r=i.child(a);if(r.isAtom){if(!o&&bP.isSelectable(r))return bP.create(e,n-(s<0?r.nodeSize:0))}else{let i=bW(e,r,n+s,s<0?r.childCount:0,s,o);if(i)return i}n+=r.nodeSize*s}return null}function bH(e,i,n){let r,s=e.steps.length-1;if(s<i)return;let o=e.steps[s];(o instanceof br||o instanceof bs)&&(e.mapping.maps[s].forEach((e,i,n,s)=>{null==r&&(r=s)}),e.setSelection(bA.near(e.doc.resolve(r),n)))}class b$ extends bM{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(1|this.updated)&-3,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=2,this}ensureMarks(e){return _d.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(e,i){super.addStep(e,i),this.updated=-3&this.updated,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,i=!0){let n=this.selection;return i&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||_d.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,i,n){let r=this.doc.type.schema;if(null==i)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(null==n&&(n=i),!e)return this.deleteRange(i,n);let s=this.storedMarks;if(!s){let e=this.doc.resolve(i);s=n==i?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(i,n,r.text(e,s)),this.selection.empty||this.selection.to!=i+e.length||this.setSelection(bA.near(this.selection.$to)),this}}setMeta(e,i){return this.meta["string"==typeof e?e:e.key]=i,this}getMeta(e){return this.meta["string"==typeof e?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function bU(e,i){return i&&e?e.bind(i):e}class bV{constructor(e,i,n){this.name=e,this.init=bU(i.init,n),this.apply=bU(i.apply,n)}}let bq=[new bV("doc",{init:e=>e.doc||e.schema.topNodeType.createAndFill(),apply:e=>e.doc}),new bV("selection",{init:(e,i)=>e.selection||bA.atStart(i.doc),apply:e=>e.selection}),new bV("storedMarks",{init:e=>e.storedMarks||null,apply:(e,i,n,r)=>r.selection.$cursor?e.storedMarks:null}),new bV("scrollToSelection",{init:()=>0,apply:(e,i)=>e.scrolledIntoView?i+1:i})];class bY{constructor(e,i){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=bq.slice(),i&&i.forEach(e=>{if(this.pluginsByKey[e.key])throw RangeError("Adding different instances of a keyed plugin ("+e.key+")");this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new bV(e.key,e.spec.state,e))})}}class bK{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,i=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=i){let i=this.config.plugins[n];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let i=[e],n=this.applyInner(e),r=null;for(;;){let s=!1;for(let o=0;o<this.config.plugins.length;o++){let a=this.config.plugins[o];if(a.spec.appendTransaction){let l=r?r[o].n:0,c=r?r[o].state:this,h=l<i.length&&a.spec.appendTransaction.call(a,l?i.slice(l):i,c,n);if(h&&n.filterTransaction(h,o)){if(h.setMeta("appendedTransaction",e),!r){r=[];for(let e=0;e<this.config.plugins.length;e++)r.push(e<o?{state:n,n:i.length}:{state:this,n:0})}i.push(h),n=n.applyInner(h),s=!0}r&&(r[o]={state:n,n:i.length})}}if(!s)return{state:n,transactions:i}}}applyInner(e){if(!e.before.eq(this.doc))throw RangeError("Applying a mismatched transaction");let i=new bK(this.config),n=this.config.fields;for(let r=0;r<n.length;r++){let s=n[r];i[s.name]=s.apply(e,this[s.name],this,i)}return i}get tr(){return new b$(this)}static create(e){let i=new bY(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new bK(i);for(let r=0;r<i.fields.length;r++)n[i.fields[r].name]=i.fields[r].init(e,n);return n}reconfigure(e){let i=new bY(this.schema,e.plugins),n=i.fields,r=new bK(i);for(let i=0;i<n.length;i++){let s=n[i].name;r[s]=this.hasOwnProperty(s)?this[s]:n[i].init(e,r)}return r}toJSON(e){let i={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(i.storedMarks=this.storedMarks.map(e=>e.toJSON())),e&&"object"==typeof e)for(let n in e){if("doc"==n||"selection"==n)throw RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],s=r.spec.state;s&&s.toJSON&&(i[n]=s.toJSON.call(r,this[r.key]))}return i}static fromJSON(e,i,n){if(!i)throw RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw RangeError("Required config field 'schema' missing");let r=new bY(e.schema,e.plugins),s=new bK(r);return r.fields.forEach(r=>{if("doc"==r.name)s.doc=_T.fromJSON(e.schema,i.doc);else if("selection"==r.name)s.selection=bA.fromJSON(s.doc,i.selection);else if("storedMarks"==r.name)i.storedMarks&&(s.storedMarks=i.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let o in n){let a=n[o],l=a.spec.state;if(a.key==r.name&&l&&l.fromJSON&&Object.prototype.hasOwnProperty.call(i,o)){s[r.name]=l.fromJSON.call(a,e,i[o],s);return}}s[r.name]=r.init(e,s)}}),s}}class bX{constructor(e){this.spec=e,this.props={},e.props&&function e(i,n,r){for(let s in i){let o=i[s];o instanceof Function?o=o.bind(n):"handleDOMEvents"==s&&(o=e(o,n,{})),r[s]=o}return r}(e.props,this,this.props),this.key=e.key?e.key.key:bG("plugin")}getState(e){return e[this.key]}}let bJ=Object.create(null);function bG(e){return e in bJ?e+"$"+ ++bJ[e]:(bJ[e]=0,e+"$")}class bZ{constructor(e="key"){this.key=bG(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}let bQ=(e,i)=>!e.selection.empty&&(i&&i(e.tr.deleteSelection().scrollIntoView()),!0);function b0(e,i){let{$cursor:n}=e.selection;return n&&(i?i.endOfTextblock("backward",e):!(n.parentOffset>0))?n:null}let b1=(e,i,n)=>{let r=b0(e,n);if(!r)return!1;let s=b4(r);if(!s){let n=r.blockRange(),s=n&&bl(n);return null!=s&&(i&&i(e.tr.lift(n,s).scrollIntoView()),!0)}let o=s.nodeBefore;if(xs(e,s,i,-1))return!0;if(0==r.parent.content.size&&(b5(o,"end")||bP.isSelectable(o)))for(let n=r.depth;;n--){let a=by(e.doc,r.before(n),r.after(n),_p.empty);if(a&&a.slice.size<a.to-a.from){if(i){let n=e.tr.step(a);n.setSelection(b5(o,"end")?bA.findFrom(n.doc.resolve(n.mapping.map(s.pos,-1)),-1):bP.create(n.doc,s.pos-o.nodeSize)),i(n.scrollIntoView())}return!0}if(1==n||r.node(n-1).childCount>1)break}return!!o.isAtom&&s.depth==r.depth-1&&(i&&i(e.tr.delete(s.pos-o.nodeSize,s.pos).scrollIntoView()),!0)};function b2(e,i,n){let r=i.nodeBefore,s=i.pos-1;for(;!r.isTextblock;s--){if(r.type.spec.isolating)return!1;let e=r.lastChild;if(!e)return!1;r=e}let o=i.nodeAfter,a=i.pos+1;for(;!o.isTextblock;a++){if(o.type.spec.isolating)return!1;let e=o.firstChild;if(!e)return!1;o=e}let l=by(e.doc,s,a,_p.empty);if(!l||l.from!=s||l instanceof br&&l.slice.size>=a-s)return!1;if(n){let i=e.tr.step(l);i.setSelection(bj.create(i.doc,s)),n(i.scrollIntoView())}return!0}function b5(e,i,n=!1){for(let r=e;r;r="start"==i?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&1!=r.childCount)break}return!1}let b3=(e,i,n)=>{let{$head:r,empty:s}=e.selection,o=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):r.parentOffset>0)return!1;o=b4(r)}let a=o&&o.nodeBefore;return!!a&&!!bP.isSelectable(a)&&(i&&i(e.tr.setSelection(bP.create(e.doc,o.pos-a.nodeSize)).scrollIntoView()),!0)};function b4(e){if(!e.parent.type.spec.isolating)for(let i=e.depth-1;i>=0;i--){if(e.index(i)>0)return e.doc.resolve(e.before(i+1));if(e.node(i).type.spec.isolating)break}return null}function b6(e,i){let{$cursor:n}=e.selection;return n&&(i?i.endOfTextblock("forward",e):!(n.parentOffset<n.parent.content.size))?n:null}let b8=(e,i,n)=>{let r=b6(e,n);if(!r)return!1;let s=b7(r);if(!s)return!1;let o=s.nodeAfter;if(xs(e,s,i,1))return!0;if(0==r.parent.content.size&&(b5(o,"start")||bP.isSelectable(o))){let n=by(e.doc,r.before(),r.after(),_p.empty);if(n&&n.slice.size<n.to-n.from){if(i){let r=e.tr.step(n);r.setSelection(b5(o,"start")?bA.findFrom(r.doc.resolve(r.mapping.map(s.pos)),1):bP.create(r.doc,r.mapping.map(s.pos))),i(r.scrollIntoView())}return!0}}return!!o.isAtom&&s.depth==r.depth-1&&(i&&i(e.tr.delete(s.pos,s.pos+o.nodeSize).scrollIntoView()),!0)},b9=(e,i,n)=>{let{$head:r,empty:s}=e.selection,o=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):r.parentOffset<r.parent.content.size)return!1;o=b7(r)}let a=o&&o.nodeAfter;return!!a&&!!bP.isSelectable(a)&&(i&&i(e.tr.setSelection(bP.create(e.doc,o.pos)).scrollIntoView()),!0)};function b7(e){if(!e.parent.type.spec.isolating)for(let i=e.depth-1;i>=0;i--){let n=e.node(i);if(e.index(i)+1<n.childCount)return e.doc.resolve(e.after(i+1));if(n.type.spec.isolating)break}return null}let xe=(e,i)=>{let{$head:n,$anchor:r}=e.selection;return!!n.parent.type.spec.code&&!!n.sameParent(r)&&(i&&i(e.tr.insertText("\n").scrollIntoView()),!0)};function xt(e){for(let i=0;i<e.edgeCount;i++){let{type:n}=e.edge(i);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}let xi=(e,i)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let s=n.node(-1),o=n.indexAfter(-1),a=xt(s.contentMatchAt(o));if(!a||!s.canReplaceWith(o,o,a))return!1;if(i){let r=n.after(),s=e.tr.replaceWith(r,r,a.createAndFill());s.setSelection(bA.near(s.doc.resolve(r),1)),i(s.scrollIntoView())}return!0},xn=(e,i)=>{let n=e.selection,{$from:r,$to:s}=n;if(n instanceof bz||r.parent.inlineContent||s.parent.inlineContent)return!1;let o=xt(s.parent.contentMatchAt(s.indexAfter()));if(!o||!o.isTextblock)return!1;if(i){let n=(!r.parentOffset&&s.index()<s.parent.childCount?r:s).pos,a=e.tr.insert(n,o.createAndFill());a.setSelection(bj.create(a.doc,n+1)),i(a.scrollIntoView())}return!0},xr=(e,i)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(bp(e.doc,r))return i&&i(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),s=r&&bl(r);return null!=s&&(i&&i(e.tr.lift(r,s).scrollIntoView()),!0)};function xs(e,i,n,r){let s,o,a,l=i.nodeBefore,c=i.nodeAfter,h,d,u=l.type.spec.isolating||c.type.spec.isolating;if(!u&&(s=i.nodeBefore,o=i.nodeAfter,a=i.index(),s&&o&&s.type.compatibleContent(o.type)&&(!s.content.size&&i.parent.canReplace(a-1,a)?(n&&n(e.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!!i.parent.canReplace(a,a+1)&&!!(o.isTextblock||bf(e.doc,i.pos))&&(n&&n(e.tr.join(i.pos).scrollIntoView()),!0))))return!0;let p=!u&&i.parent.canReplace(i.index(),i.index()+1);if(p&&(h=(d=l.contentMatchAt(l.childCount)).findWrapping(c.type))&&d.matchType(h[0]||c.type).validEnd){if(n){let r=i.pos+c.nodeSize,s=_a.empty;for(let e=h.length-1;e>=0;e--)s=_a.from(h[e].create(null,s));s=_a.from(l.copy(s));let o=e.tr.step(new bs(i.pos-1,r,i.pos,r,new _p(s,1,0),h.length,!0)),a=o.doc.resolve(r+2*h.length);a.nodeAfter&&a.nodeAfter.type==l.type&&bf(o.doc,a.pos)&&o.join(a.pos),n(o.scrollIntoView())}return!0}let f=c.type.spec.isolating||r>0&&u?null:bA.findFrom(i,1),m=f&&f.$from.blockRange(f.$to),g=m&&bl(m);if(null!=g&&g>=i.depth)return n&&n(e.tr.lift(m,g).scrollIntoView()),!0;if(p&&b5(c,"start",!0)&&b5(l,"end")){let r=l,s=[];for(;s.push(r),!r.isTextblock;)r=r.lastChild;let o=c,a=1;for(;!o.isTextblock;o=o.firstChild)a++;if(r.canReplace(r.childCount,r.childCount,o.content)){if(n){let r=_a.empty;for(let e=s.length-1;e>=0;e--)r=_a.from(s[e].copy(r));n(e.tr.step(new bs(i.pos-s.length,i.pos+c.nodeSize,i.pos+a,i.pos+c.nodeSize-a,new _p(r,s.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function xo(e){return function(i,n){let r=i.selection,s=e<0?r.$from:r.$to,o=s.depth;for(;s.node(o).isInline;){if(!o)return!1;o--}return!!s.node(o).isTextblock&&(n&&n(i.tr.setSelection(bj.create(i.doc,e<0?s.start(o):s.end(o)))),!0)}}let xa=xo(-1),xl=xo(1);function xc(e,i=null){return function(n,r){let s=!1;for(let r=0;r<n.selection.ranges.length&&!s;r++){let{$from:{pos:o},$to:{pos:a}}=n.selection.ranges[r];n.doc.nodesBetween(o,a,(r,o)=>{if(s)return!1;if(!(!r.isTextblock||r.hasMarkup(e,i)))if(r.type==e)s=!0;else{let i=n.doc.resolve(o),r=i.index();s=i.parent.canReplaceWith(r,r+1,e)}})}if(!s)return!1;if(r){let s=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:o},$to:{pos:a}}=n.selection.ranges[r];s.setBlockType(o,a,e,i)}r(s.scrollIntoView())}return!0}}function xh(...e){return function(i,n,r){for(let s=0;s<e.length;s++)if(e[s](i,n,r))return!0;return!1}}let xd=xh(bQ,b1,b3),xu=xh(bQ,b8,b9),xp={Enter:xh(xe,xn,xr,(e,i)=>{let{$from:n,$to:r}=e.selection;if(e.selection instanceof bP&&e.selection.node.isBlock)return!!n.parentOffset&&!!bp(e.doc,n.pos)&&(i&&i(e.tr.split(n.pos).scrollIntoView()),!0);if(!n.depth)return!1;let s=[],o,a,l=!1,c=!1;for(let e=n.depth;;e--){if(n.node(e).isBlock){let i;l=n.end(e)==n.pos+(n.depth-e),c=n.start(e)==n.pos-(n.depth-e),a=xt(n.node(e-1).contentMatchAt(n.indexAfter(e-1)));s.unshift(i||(l&&a?{type:a}:null)),o=e;break}if(1==e)return!1;s.unshift(null)}let h=e.tr;(e.selection instanceof bj||e.selection instanceof bz)&&h.deleteSelection();let d=h.mapping.map(n.pos),u=bp(h.doc,d,s.length,s);if(u||(s[0]=a?{type:a}:null,u=bp(h.doc,d,s.length,s)),!u)return!1;if(h.split(d,s.length,s),!l&&c&&n.node(o).type!=a){let e=h.mapping.map(n.before(o)),i=h.doc.resolve(e);a&&n.node(o-1).canReplaceWith(i.index(),i.index()+1,a)&&h.setNodeMarkup(h.mapping.map(n.before(o)),a)}return i&&i(h.scrollIntoView()),!0}),"Mod-Enter":xi,Backspace:xd,"Mod-Backspace":xd,"Shift-Backspace":xd,Delete:xu,"Mod-Delete":xu,"Mod-a":(e,i)=>(i&&i(e.tr.setSelection(new bz(e.doc))),!0)},xf={"Ctrl-h":xp.Backspace,"Alt-Backspace":xp["Mod-Backspace"],"Ctrl-d":xp.Delete,"Ctrl-Alt-Backspace":xp["Mod-Delete"],"Alt-Delete":xp["Mod-Delete"],"Alt-d":xp["Mod-Delete"],"Ctrl-a":xa,"Ctrl-e":xl};for(let e in xp)xf[e]=xp[e];"u">typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"u">typeof os&&os.platform&&os.platform();let xm=function(e){for(var i=0;;i++)if(!(e=e.previousSibling))return i},xg=function(e){let i=e.assignedSlot||e.parentNode;return i&&11==i.nodeType?i.host:i},xv=null,xy=function(e,i,n){let r=xv||(xv=document.createRange());return r.setEnd(e,null==n?e.nodeValue.length:n),r.setStart(e,i||0),r},x_=function(){xv=null},xb=function(e,i,n,r){return n&&(xw(e,i,n,r,-1)||xw(e,i,n,r,1))},xx=/^(img|br|input|textarea|hr)$/i;function xw(e,i,n,r,s){for(var o;;){if(e==n&&i==r)return!0;if(i==(s<0?0:xS(e))){let n=e.parentNode;if(!n||1!=n.nodeType||xk(e)||xx.test(e.nodeName)||"false"==e.contentEditable)return!1;i=xm(e)+(s<0?0:1),e=n}else{if(1!=e.nodeType)return!1;let n=e.childNodes[i+(s<0?-1:0)];if(1==n.nodeType&&"false"==n.contentEditable)if(null==(o=n.pmViewDesc)||!o.ignoreForSelection)return!1;else i+=s;else e=n,i=s<0?xS(e):0}}}function xS(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function xk(e){let i;for(let n=e;n&&!(i=n.pmViewDesc);n=n.parentNode);return i&&i.node&&i.node.isBlock&&(i.dom==e||i.contentDOM==e)}let xC=function(e){return e.focusNode&&xb(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function xT(e,i){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=i,n}let xE="u">typeof navigator?navigator:null,xN="u">typeof document?document:null,xM=xE&&xE.userAgent||"",xO=/Edge\/(\d+)/.exec(xM),xA=/MSIE \d/.exec(xM),xR=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(xM),xD=!!(xA||xR||xO),xL=xA?document.documentMode:xR?+xR[1]:xO?+xO[1]:0,xj=!xD&&/gecko\/(\d+)/i.test(xM);xj&&(/Firefox\/(\d+)/.exec(xM)||[0,0])[1];let xI=!xD&&/Chrome\/(\d+)/.exec(xM),xP=!!xI,xB=xI?+xI[1]:0,xz=!xD&&!!xE&&/Apple Computer/.test(xE.vendor),xF=xz&&(/Mobile\/\w+/.test(xM)||!!xE&&xE.maxTouchPoints>2),xW=xF||!!xE&&/Mac/.test(xE.platform),xH=!!xE&&/Win/.test(xE.platform),x$=/Android \d/.test(xM),xU=!!xN&&"webkitFontSmoothing"in xN.documentElement.style,xV=xU?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function xq(e,i){return"number"==typeof e?e:e[i]}function xY(e,i,n){let r=e.someProp("scrollThreshold")||0,s=e.someProp("scrollMargin")||5,o=e.dom.ownerDocument;for(let a=n||e.dom;a;){if(1!=a.nodeType){a=xg(a);continue}let e=a,n=e==o.body,l=n?function(e){let i=e.defaultView&&e.defaultView.visualViewport;return i?{left:0,right:i.width,top:0,bottom:i.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}(o):function(e){let i=e.getBoundingClientRect(),n=i.width/e.offsetWidth||1,r=i.height/e.offsetHeight||1;return{left:i.left,right:i.left+e.clientWidth*n,top:i.top,bottom:i.top+e.clientHeight*r}}(e),c=0,h=0;if(i.top<l.top+xq(r,"top")?h=-(l.top-i.top+xq(s,"top")):i.bottom>l.bottom-xq(r,"bottom")&&(h=i.bottom-i.top>l.bottom-l.top?i.top+xq(s,"top")-l.top:i.bottom-l.bottom+xq(s,"bottom")),i.left<l.left+xq(r,"left")?c=-(l.left-i.left+xq(s,"left")):i.right>l.right-xq(r,"right")&&(c=i.right-l.right+xq(s,"right")),c||h)if(n)o.defaultView.scrollBy(c,h);else{let n=e.scrollLeft,r=e.scrollTop;h&&(e.scrollTop+=h),c&&(e.scrollLeft+=c);let s=e.scrollLeft-n,o=e.scrollTop-r;i={left:i.left-s,top:i.top-o,right:i.right-s,bottom:i.bottom-o}}let d=n?"fixed":getComputedStyle(a).position;if(/^(fixed|sticky)$/.test(d))break;a="absolute"==d?a.offsetParent:xg(a)}}function xK(e){let i=[],n=e.ownerDocument;for(let r=e;r&&(i.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=xg(r));return i}function xX(e,i){for(let n=0;n<e.length;n++){let{dom:r,top:s,left:o}=e[n];r.scrollTop!=s+i&&(r.scrollTop=s+i),r.scrollLeft!=o&&(r.scrollLeft=o)}}let xJ=null;function xG(e,i){return e.left>=i.left-1&&e.left<=i.right+1&&e.top>=i.top-1&&e.top<=i.bottom+1}function xZ(e){return e.top<e.bottom||e.left<e.right}function xQ(e,i){let n=e.getClientRects();if(n.length){let e=n[i<0?0:n.length-1];if(xZ(e))return e}return Array.prototype.find.call(n,xZ)||e.getBoundingClientRect()}let x0=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function x1(e,i,n){let{node:r,offset:s,atom:o}=e.docView.domFromPos(i,n<0?-1:1),a=xU||xj;if(3==r.nodeType)if(a&&(x0.test(r.nodeValue)||(n<0?!s:s==r.nodeValue.length))){let e=xQ(xy(r,s,s),n);if(xj&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let i=xQ(xy(r,s-1,s-1),-1);if(i.top==e.top){let n=xQ(xy(r,s,s+1),-1);if(n.top!=e.top)return x2(n,n.left<i.left)}}return e}else{let e=s,i=s,o=n<0?1:-1;return n<0&&!s?(i++,o=-1):n>=0&&s==r.nodeValue.length?(e--,o=1):n<0?e--:i++,x2(xQ(xy(r,e,i),o),o<0)}if(!e.state.doc.resolve(i-(o||0)).parent.inlineContent){if(null==o&&s&&(n<0||s==xS(r))){let e=r.childNodes[s-1];if(1==e.nodeType)return x5(e.getBoundingClientRect(),!1)}if(null==o&&s<xS(r)){let e=r.childNodes[s];if(1==e.nodeType)return x5(e.getBoundingClientRect(),!0)}return x5(r.getBoundingClientRect(),n>=0)}if(null==o&&s&&(n<0||s==xS(r))){let e=r.childNodes[s-1],i=3==e.nodeType?xy(e,xS(e)-!a):1!=e.nodeType||"BR"==e.nodeName&&e.nextSibling?null:e;if(i)return x2(xQ(i,1),!1)}if(null==o&&s<xS(r)){let e=r.childNodes[s];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let i=e?3==e.nodeType?xy(e,0,+!a):1==e.nodeType?e:null:null;if(i)return x2(xQ(i,-1),!0)}return x2(xQ(3==r.nodeType?xy(r):r,-n),n>=0)}function x2(e,i){if(0==e.width)return e;let n=i?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function x5(e,i){if(0==e.height)return e;let n=i?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function x3(e,i,n){let r=e.state,s=e.root.activeElement;r!=i&&e.updateState(i),s!=e.dom&&e.focus();try{return n()}finally{r!=i&&e.updateState(r),s!=e.dom&&s&&s.focus()}}let x4=/[\u0590-\u08ac]/,x6=null,x8=null,x9=!1;class x7{constructor(e,i,n,r){this.parent=e,this.children=i,this.dom=n,this.contentDOM=r,this.dirty=0,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,i,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let i=0;i<this.children.length;i++)e+=this.children[i].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let i=0,n=this.posAtStart;;i++){let r=this.children[i];if(r==e)return n;n+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,i,n){let r;if(this.contentDOM&&this.contentDOM.contains(1==e.nodeType?e:e.parentNode))if(n<0){let n,r;if(e==this.contentDOM)n=e.childNodes[i-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&!((r=n.pmViewDesc)&&r.parent==this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}else{let n,r;if(e==this.contentDOM)n=e.childNodes[i];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&!((r=n.pmViewDesc)&&r.parent==this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}if(e==this.dom&&this.contentDOM)r=i>xm(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==i)for(let i=e;;i=i.parentNode){if(i==this.dom){r=!1;break}if(i.previousSibling)break}if(null==r&&i==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){r=!0;break}if(i.nextSibling)break}}return(null==r?n>0:r)?this.posAtEnd:this.posAtStart}nearestDesc(e,i=!1){for(let n=!0,r=e;r;r=r.parentNode){let s=this.getDesc(r),o;if(s&&(!i||s.node))if(!n||!(o=s.nodeDOM)||(1==o.nodeType?o.contains(1==e.nodeType?e:e.parentNode):o==e))return s;else n=!1}}getDesc(e){let i=e.pmViewDesc;for(let e=i;e;e=e.parent)if(e==this)return i}posFromDOM(e,i,n){for(let r=e;r;r=r.parentNode){let s=this.getDesc(r);if(s)return s.localPosFromDOM(e,i,n)}return -1}descAt(e){for(let i=0,n=0;i<this.children.length;i++){let r=this.children[i],s=n+r.size;if(n==e&&s!=n){for(;!r.border&&r.children.length;)for(let e=0;e<r.children.length;e++){let i=r.children[e];if(i.size){r=i;break}}return r}if(e<s)return r.descAt(e-n-r.border);n=s}}domFromPos(e,i){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,r=0;for(let i=0;n<this.children.length;n++){let s=this.children[n],o=i+s.size;if(o>e||s instanceof wo){r=e-i;break}i=o}if(r)return this.children[n].domFromPos(r-this.children[n].border,i);for(let e;n&&!(e=this.children[n-1]).size&&e instanceof we&&e.side>=0;n--);if(i<=0){let e,r=!0;for(;(e=n?this.children[n-1]:null)&&e.dom.parentNode!=this.contentDOM;n--,r=!1);return e&&i&&r&&!e.border&&!e.domAtom?e.domFromPos(e.size,i):{node:this.contentDOM,offset:e?xm(e.dom)+1:0}}{let e,r=!0;for(;(e=n<this.children.length?this.children[n]:null)&&e.dom.parentNode!=this.contentDOM;n++,r=!1);return e&&r&&!e.border&&!e.domAtom?e.domFromPos(0,i):{node:this.contentDOM,offset:e?xm(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,i,n=0){if(0==this.children.length)return{node:this.contentDOM,from:e,to:i,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,s=-1;for(let o=n,a=0;;a++){let n=this.children[a],l=o+n.size;if(-1==r&&e<=l){let s=o+n.border;if(e>=s&&i<=l-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,i,s);e=o;for(let i=a;i>0;i--){let n=this.children[i-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=xm(n.dom)+1;break}e-=n.size}-1==r&&(r=0)}if(r>-1&&(l>i||a==this.children.length-1)){i=l;for(let e=a+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){s=xm(n.dom);break}i+=n.size}-1==s&&(s=this.contentDOM.childNodes.length);break}o=l}return{node:this.contentDOM,from:e,to:i,fromOffset:r,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let i=this.children[e<0?0:this.children.length-1];return 0==i.size||i.emptyChildAt(e)}domAfterPos(e){let{node:i,offset:n}=this.domFromPos(e,0);if(1!=i.nodeType||n==i.childNodes.length)throw RangeError("No node after pos "+e);return i.childNodes[n]}setSelection(e,i,n,r=!1){let s=Math.min(e,i),o=Math.max(e,i);for(let a=0,l=0;a<this.children.length;a++){let c=this.children[a],h=l+c.size;if(s>l&&o<h)return c.setSelection(e-l-c.border,i-l-c.border,n,r);l=h}let a=this.domFromPos(e,e?-1:1),l=i==e?a:this.domFromPos(i,i?-1:1),c=n.root.getSelection(),h=n.domSelectionRange(),d=!1;if((xj||xz)&&e==i){let{node:e,offset:i}=a;if(3==e.nodeType){if((d=!!(i&&"\n"==e.nodeValue[i-1]))&&i==e.nodeValue.length)for(let i=e,n;i;i=i.parentNode){if(n=i.nextSibling){"BR"==n.nodeName&&(a=l={node:n.parentNode,offset:xm(n)+1});break}let e=i.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[i-1];d=n&&("BR"==n.nodeName||"false"==n.contentEditable)}}if(xj&&h.focusNode&&h.focusNode!=l.node&&1==h.focusNode.nodeType){let e=h.focusNode.childNodes[h.focusOffset];e&&"false"==e.contentEditable&&(r=!0)}if(!(r||d&&xz)&&xb(a.node,a.offset,h.anchorNode,h.anchorOffset)&&xb(l.node,l.offset,h.focusNode,h.focusOffset))return;let u=!1;if((c.extend||e==i)&&!(d&&xj)){c.collapse(a.node,a.offset);try{e!=i&&c.extend(l.node,l.offset),u=!0}catch(e){}}if(!u){if(e>i){let e=a;a=l,l=e}let n=document.createRange();n.setEnd(l.node,l.offset),n.setStart(a.node,a.offset),c.removeAllRanges(),c.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&"selection"!=e.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,i){for(let n=0,r=0;r<this.children.length;r++){let s=this.children[r],o=n+s.size;if(n==o?e<=o&&i>=n:e<o&&i>n){let r=n+s.border,a=o-s.border;if(e>=r&&i<=a){this.dirty=e==n||i==o?2:1,e==r&&i==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=3:s.markDirty(e-r,i-r);return}s.dirty=s.dom!=s.contentDOM||s.dom.parentNode!=this.contentDOM||s.children.length?3:2}n=o}this.dirty=2}markParentsDirty(){let e=1;for(let i=this.parent;i;i=i.parent,e++){let n=1==e?2:1;i.dirty<n&&(i.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class we extends x7{constructor(e,i,n,r){let s,o=i.type.toDOM;if("function"==typeof o&&(o=o(n,()=>s?s.parent?s.parent.posBeforeChild(s):void 0:r)),!i.type.spec.raw){if(1!=o.nodeType){let e=document.createElement("span");e.appendChild(o),o=e}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=i,this.widget=i,s=this}matchesWidget(e){return 0==this.dirty&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let i=this.widget.spec.stopEvent;return!!i&&i(e)}ignoreMutation(e){return"selection"!=e.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class wt extends x7{constructor(e,i,n,r){super(e,[],i,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,i){return e!=this.textDOM?this.posAtStart+(i?this.size:0):this.posAtStart+i}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return"characterData"===e.type&&e.target.nodeValue==e.oldValue}}class wi extends x7{constructor(e,i,n,r,s){super(e,[],n,r),this.mark=i,this.spec=s}static create(e,i,n,r){let s=r.nodeViews[i.type.name],o=s&&s(i,r,n);return o&&o.dom||(o=_Z.renderSpec(document,i.type.spec.toDOM(i,n),null,i.attrs)),new wi(e,i,o.dom,o.contentDOM||o.dom,o)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return 3!=this.dirty&&this.mark.eq(e)}markDirty(e,i){if(super.markDirty(e,i),0!=this.dirty){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=0}}slice(e,i,n){let r=wi.create(this.parent,this.mark,!0,n),s=this.children,o=this.size;i<o&&(s=wv(s,i,o,n)),e>0&&(s=wv(s,0,e,n));for(let e=0;e<s.length;e++)s[e].parent=r;return r.children=s,r}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class wn extends x7{constructor(e,i,n,r,s,o,a,l,c){super(e,[],s,o),this.node=i,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=a}static create(e,i,n,r,s,o){let a=s.nodeViews[i.type.name],l,c=a&&a(i,s,()=>l?l.parent?l.parent.posBeforeChild(l):void 0:o,n,r),h=c&&c.dom,d=c&&c.contentDOM;if(i.isText)if(h){if(3!=h.nodeType)throw RangeError("Text must be rendered as a DOM text node")}else h=document.createTextNode(i.text);else if(!h){let e=_Z.renderSpec(document,i.type.spec.toDOM(i),null,i.attrs);({dom:h,contentDOM:d}=e)}d||i.isText||"BR"==h.nodeName||(h.hasAttribute("contenteditable")||(h.contentEditable="false"),i.type.spec.draggable&&(h.draggable=!0));let u=h;return(h=wu(h,n,i),c)?l=new wa(e,i,n,r,h,d||null,u,c,s,o+1):i.isText?new ws(e,i,n,r,h,u,s):new wn(e,i,n,r,h,d||null,u,s,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(e.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let i=this.children.length-1;i>=0;i--){let n=this.children[i];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>_a.empty)}else e.contentElement=this.contentDOM;else e.getContent=()=>this.node.content;return e}matchesNode(e,i,n){return 0==this.dirty&&e.eq(this.node)&&wp(i,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return+!this.node.isLeaf}updateChildren(e,i){let n=this.node.inlineContent,r=i,s=e.composing?this.localCompositionInfo(e,i):null,o=s&&s.pos>-1?s:null,a=s&&s.pos<0,l=new wm(this,o&&o.node,e);(function(e,i,n,r){let s=i.locals(e),o=0;if(0==s.length){for(let n=0;n<e.childCount;n++){let a=e.child(n);r(a,s,i.forChild(o,a),n),o+=a.nodeSize}return}let a=0,l=[],c=null;for(let h=0;;){let d,u,p,f;for(;a<s.length&&s[a].to==o;){let e=s[a++];e.widget&&(d?(u||(u=[d])).push(e):d=e)}if(d)if(u){u.sort(wg);for(let e=0;e<u.length;e++)n(u[e],h,!!c)}else n(d,h,!!c);if(c)f=-1,p=c,c=null;else if(h<e.childCount)f=h,p=e.child(h++);else break;for(let e=0;e<l.length;e++)l[e].to<=o&&l.splice(e--,1);for(;a<s.length&&s[a].from<=o&&s[a].to>o;)l.push(s[a++]);let m=o+p.nodeSize;if(p.isText){let e=m;a<s.length&&s[a].from<e&&(e=s[a].from);for(let i=0;i<l.length;i++)l[i].to<e&&(e=l[i].to);e<m&&(c=p.cut(e-o),p=p.cut(0,e-o),m=e,f=-1)}else for(;a<s.length&&s[a].to<m;)a++;let g=p.isInline&&!p.isLeaf?l.filter(e=>!e.inline):l.slice();r(p,g,i.forChild(o,p),f),o=m}})(this.node,this.innerDeco,(i,s,o)=>{i.spec.marks?l.syncToMarks(i.spec.marks,n,e,s):i.type.side>=0&&!o&&l.syncToMarks(s==this.node.childCount?_d.none:this.node.child(s).marks,n,e,s),l.placeWidget(i,e,r)},(i,o,c,h)=>{let d;l.syncToMarks(i.marks,n,e,h),l.findNodeMatch(i,o,c,h)||a&&e.state.selection.from>r&&e.state.selection.to<r+i.nodeSize&&(d=l.findIndexWithChild(s.node))>-1&&l.updateNodeAt(i,o,c,d,e)||l.updateNextNode(i,o,c,e,h,r)||l.addNode(i,o,c,e,r),r+=i.nodeSize}),l.syncToMarks([],n,e,0),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||2==this.dirty)&&(o&&this.protectLocalComposition(e,o),function e(i,n,r){let s=i.firstChild,o=!1;for(let a=0;a<n.length;a++){let l=n[a],c=l.dom;if(c.parentNode==i){for(;c!=s;)s=wf(s),o=!0;s=s.nextSibling}else o=!0,i.insertBefore(c,s);if(l instanceof wi){let n=s?s.previousSibling:i.lastChild;e(l.contentDOM,l.children,r),s=n?n.nextSibling:i.firstChild}}for(;s;)s=wf(s),o=!0;o&&r.trackWrites==i&&(r.trackWrites=null)}(this.contentDOM,this.children,e),xF&&function(e){if("UL"==e.nodeName||"OL"==e.nodeName){let i=e.style.cssText;e.style.cssText=i+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=i}}(this.dom))}localCompositionInfo(e,i){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof bj)||n<i||r>i+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(!this.node.inlineContent)return{node:s,pos:-1,text:""};{let e=s.nodeValue,o=function(e,i,n,r){for(let s=0,o=0;s<e.childCount&&o<=r;){let a=e.child(s++),l=o;if(o+=a.nodeSize,!a.isText)continue;let c=a.text;for(;s<e.childCount;){let i=e.child(s++);if(o+=i.nodeSize,!i.isText)break;c+=i.text}if(o>=n){if(o>=r&&c.slice(r-i.length-l,r-l)==i)return r-i.length;let e=l<r?c.lastIndexOf(i,r-l-1):-1;if(e>=0&&e+i.length+l>=n)return l+e;if(n==r&&c.length>=r+i.length-l&&c.slice(r-l,r-l+i.length)==i)return r}}return -1}(this.node.content,e,n-i,r-i);return o<0?null:{node:s,pos:o,text:e}}}protectLocalComposition(e,{node:i,pos:n,text:r}){if(this.getDesc(i))return;let s=i;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let o=new wt(this,s,i,r);e.input.compositionNodes.push(o),this.children=wv(this.children,n,n+r.length,e,o)}update(e,i,n,r){return 3!=this.dirty&&!!e.sameMarkup(this.node)&&(this.updateInner(e,i,n,r),!0)}updateInner(e,i,n,r){this.updateOuterDeco(i),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0}updateOuterDeco(e){if(wp(e,this.outerDeco))return;let i=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=wd(this.dom,this.nodeDOM,wh(this.outerDeco,this.node,i),wh(e,this.node,i)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function wr(e,i,n,r,s){wu(r,i,e);let o=new wn(void 0,e,i,n,r,r,r,s,0);return o.contentDOM&&o.updateChildren(s,0),o}class ws extends wn{constructor(e,i,n,r,s,o,a){super(e,i,n,r,s,null,o,a,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,i,n,r){return 3!=this.dirty&&(0==this.dirty||!!this.inParent())&&!!e.sameMarkup(this.node)&&(this.updateOuterDeco(i),(0!=this.dirty||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=0,!0)}inParent(){let e=this.parent.contentDOM;for(let i=this.nodeDOM;i;i=i.parentNode)if(i==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,i,n){return e==this.nodeDOM?this.posAtStart+Math.min(i,this.node.text.length):super.localPosFromDOM(e,i,n)}ignoreMutation(e){return"characterData"!=e.type&&"selection"!=e.type}slice(e,i,n){let r=this.node.cut(e,i),s=document.createTextNode(r.text);return new ws(this.parent,r,this.outerDeco,this.innerDeco,s,s,n)}markDirty(e,i){super.markDirty(e,i),this.dom!=this.nodeDOM&&(0==e||i==this.nodeDOM.nodeValue.length)&&(this.dirty=3)}get domAtom(){return!1}isText(e){return this.node.text==e}}class wo extends x7{parseRule(){return{ignore:!0}}matchesHack(e){return 0==this.dirty&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class wa extends wn{constructor(e,i,n,r,s,o,a,l,c,h){super(e,i,n,r,s,o,a,c,h),this.spec=l}update(e,i,n,r){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,i,n);return s&&this.updateInner(e,i,n,r),s}return(!!this.contentDOM||!!e.isLeaf)&&super.update(e,i,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,i,n,r){this.spec.setSelection?this.spec.setSelection(e,i,n.root):super.setSelection(e,i,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}let wl=function(e){e&&(this.nodeName=e)};wl.prototype=Object.create(null);let wc=[new wl];function wh(e,i,n){if(0==e.length)return wc;let r=n?wc[0]:new wl,s=[r];for(let o=0;o<e.length;o++){let a=e[o].type.attrs;if(a)for(let e in a.nodeName&&s.push(r=new wl(a.nodeName)),a){let o=a[e];null!=o&&(n&&1==s.length&&s.push(r=new wl(i.isInline?"span":"div")),"class"==e?r.class=(r.class?r.class+" ":"")+o:"style"==e?r.style=(r.style?r.style+";":"")+o:"nodeName"!=e&&(r[e]=o))}}return s}function wd(e,i,n,r){if(n==wc&&r==wc)return i;let s=i;for(let i=0;i<r.length;i++){let o=r[i],a=n[i];if(i){let i;a&&a.nodeName==o.nodeName&&s!=e&&(i=s.parentNode)&&i.nodeName.toLowerCase()==o.nodeName||((i=document.createElement(o.nodeName)).pmIsDeco=!0,i.appendChild(s),a=wc[0]),s=i}!function(e,i,n){for(let r in i)"class"==r||"style"==r||"nodeName"==r||r in n||e.removeAttribute(r);for(let r in n)"class"!=r&&"style"!=r&&"nodeName"!=r&&n[r]!=i[r]&&e.setAttribute(r,n[r]);if(i.class!=n.class){let r=i.class?i.class.split(" ").filter(Boolean):[],s=n.class?n.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)-1==s.indexOf(r[i])&&e.classList.remove(r[i]);for(let i=0;i<s.length;i++)-1==r.indexOf(s[i])&&e.classList.add(s[i]);0==e.classList.length&&e.removeAttribute("class")}if(i.style!=n.style){if(i.style){let n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,r;for(;r=n.exec(i.style);)e.style.removeProperty(r[1])}n.style&&(e.style.cssText+=n.style)}}(s,a||wc[0],o)}return s}function wu(e,i,n){return wd(e,e,wc,wh(i,n,1!=e.nodeType))}function wp(e,i){if(e.length!=i.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(i[n].type))return!1;return!0}function wf(e){let i=e.nextSibling;return e.parentNode.removeChild(e),i}class wm{constructor(e,i,n){this.lock=i,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=function(e,i){let n=i,r=n.children.length,s=e.childCount,o=new Map,a=[];i:for(;s>0;){let l;for(;;)if(r){let e=n.children[r-1];if(e instanceof wi)n=e,r=e.children.length;else{l=e,r--;break}}else if(n==i)break i;else r=n.parent.children.indexOf(n),n=n.parent;let c=l.node;if(c){if(c!=e.child(s-1))break;--s,o.set(l,s),a.push(l)}}return{index:s,matched:o,matches:a.reverse()}}(e.node.content,e)}destroyBetween(e,i){if(e!=i){for(let n=e;n<i;n++)this.top.children[n].destroy();this.top.children.splice(e,i-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,i,n,r){let s=0,o=this.stack.length>>1,a=Math.min(o,e.length);for(;s<a&&(s==o-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&!1!==e[s].type.spec.spanning;)s++;for(;s<o;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let s=-1,a=this.top.children.length;r<this.preMatch.index&&(a=Math.min(this.index+3,a));for(let i=this.index;i<a;i++){let n=this.top.children[i];if(n.matchesMark(e[o])&&!this.isLocked(n.dom)){s=i;break}}if(s>-1)s>this.index&&(this.changed=!0,this.destroyBetween(this.index,s)),this.top=this.top.children[this.index];else{let r=wi.create(this.top,e[o],i,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,o++}}findNodeMatch(e,i,n,r){let s=-1,o;if(r>=this.preMatch.index&&(o=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&o.matchesNode(e,i,n))s=this.top.children.indexOf(o,this.index);else for(let r=this.index,o=Math.min(this.top.children.length,r+5);r<o;r++){let o=this.top.children[r];if(o.matchesNode(e,i,n)&&!this.preMatch.matched.has(o)){s=r;break}}return!(s<0)&&(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,i,n,r,s){let o=this.top.children[r];return 3==o.dirty&&o.dom==o.contentDOM&&(o.dirty=2),!!o.update(e,i,n,s)&&(this.destroyBetween(this.index,r),this.index++,!0)}findIndexWithChild(e){for(;;){let i=e.parentNode;if(!i)return -1;if(i==this.top.contentDOM){let i=e.pmViewDesc;if(i){for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==i)return e}return -1}e=i}}updateNextNode(e,i,n,r,s,o){for(let a=this.index;a<this.top.children.length;a++){let l=this.top.children[a];if(l instanceof wn){let c=this.preMatch.matched.get(l);if(null!=c&&c!=s)return!1;let h=l.dom,d,u=this.isLocked(h)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&3!=l.dirty&&wp(i,l.outerDeco));if(!u&&l.update(e,i,n,r))return this.destroyBetween(this.index,a),l.dom!=h&&(this.changed=!0),this.index++,!0;if(!u&&(d=this.recreateWrapper(l,e,i,n,r,o)))return this.destroyBetween(this.index,a),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=2,d.updateChildren(r,o+1),d.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,i,n,r,s,o){if(e.dirty||i.isAtom||!e.children.length||!e.node.content.eq(i.content)||!wp(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let a=wn.create(this.top,i,n,r,s,o);if(a.contentDOM)for(let i of(a.children=e.children,e.children=[],a.children))i.parent=a;return e.destroy(),a}addNode(e,i,n,r,s){let o=wn.create(this.top,e,i,n,r,s);o.contentDOM&&o.updateChildren(r,s+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,i,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(r&&r.matchesWidget(e)&&(e==r.widget||!r.widget.type.toDOM.parentNode))this.index++;else{let r=new we(this.top,e,i,n);this.top.children.splice(this.index++,0,r),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],i=this.top;for(;e instanceof wi;)e=(i=e).children[i.children.length-1];(!e||!(e instanceof ws)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((xz||xP)&&e&&"false"==e.dom.contentEditable&&this.addHackNode("IMG",i),this.addHackNode("BR",this.top))}addHackNode(e,i){if(i==this.top&&this.index<i.children.length&&i.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);"IMG"==e&&(n.className="ProseMirror-separator",n.alt=""),"BR"==e&&(n.className="ProseMirror-trailingBreak");let r=new wo(this.top,[],n,null);i!=this.top?i.children.push(r):i.children.splice(this.index++,0,r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||1==e.nodeType&&e.contains(this.lock.parentNode))}}function wg(e,i){return e.type.side-i.type.side}function wv(e,i,n,r,s){let o=[];for(let a=0,l=0;a<e.length;a++){let c=e[a],h=l,d=l+=c.size;h>=n||d<=i?o.push(c):(h<i&&o.push(c.slice(0,i-h,r)),s&&(o.push(s),s=void 0),d>n&&o.push(c.slice(n-h,c.size,r)))}return o}function wy(e,i=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let s=e.docView.nearestDesc(n.focusNode),o=s&&0==s.size,a=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(a<0)return null;let l=r.resolve(a),c,h;if(xC(n)){for(c=a;s&&!s.node;)s=s.parent;let e=s.node;if(s&&e.isAtom&&bP.isSelectable(e)&&s.parent&&!(e.isInline&&function(e,i,n){for(let r=0==i,s=i==xS(e);r||s;){if(e==n)return!0;let i=xm(e);if(!(e=e.parentNode))return!1;r=r&&0==i,s=s&&i==xS(e)}}(n.focusNode,n.focusOffset,s.dom))){let e=s.posBefore;h=new bP(a==e?l:r.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let i=a,s=a;for(let r=0;r<n.rangeCount;r++){let o=n.getRangeAt(r);i=Math.min(i,e.docView.posFromDOM(o.startContainer,o.startOffset,1)),s=Math.max(s,e.docView.posFromDOM(o.endContainer,o.endOffset,-1))}if(i<0)return null;[c,a]=s==e.state.selection.anchor?[s,i]:[i,s],l=r.resolve(a)}else c=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null}let d=r.resolve(c);if(!h){let n="pointer"==i||e.state.selection.head<l.pos&&!o?1:-1;h=wE(e,d,l,n)}return h}function w_(e){return e.editable?e.hasFocus():wM(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function wb(e,i=!1){let n=e.state.selection;if(wC(e,n),w_(e)){if(!i&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&xP){let i=e.domSelectionRange(),n=e.domObserver.currentSelection;if(i.anchorNode&&n.anchorNode&&xb(i.anchorNode,i.anchorOffset,n.anchorNode,n.anchorOffset)){e.input.mouseDown.delayedSelectionSync=!0,e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)!function(e){let i=e.domSelection();if(!i)return;let n=e.cursorWrapper.dom,r="IMG"==n.nodeName;r?i.collapse(n.parentNode,xm(n)+1):i.collapse(n,0),!r&&!e.state.selection.visible&&xD&&xL<=11&&(n.disabled=!0,n.disabled=!1)}(e);else{var r;let s,o,a,l,{anchor:c,head:h}=n,d,u;wx&&!(n instanceof bj)&&(n.$from.parent.inlineContent||(d=ww(e,n.from)),n.empty||n.$from.parent.inlineContent||(u=ww(e,n.to))),e.docView.setSelection(c,h,e,i),wx&&(d&&wk(d),u&&wk(u)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&((s=(r=e).dom.ownerDocument).removeEventListener("selectionchange",r.input.hideSelectionGuard),a=(o=r.domSelectionRange()).anchorNode,l=o.anchorOffset,s.addEventListener("selectionchange",r.input.hideSelectionGuard=()=>{(o.anchorNode!=a||o.anchorOffset!=l)&&(s.removeEventListener("selectionchange",r.input.hideSelectionGuard),setTimeout(()=>{(!w_(r)||r.state.selection.visible)&&r.dom.classList.remove("ProseMirror-hideselection")},20))})))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}let wx=xz||xP&&xB<63;function ww(e,i){let{node:n,offset:r}=e.docView.domFromPos(i,0),s=r<n.childNodes.length?n.childNodes[r]:null,o=r?n.childNodes[r-1]:null;if(xz&&s&&"false"==s.contentEditable)return wS(s);if((!s||"false"==s.contentEditable)&&(!o||"false"==o.contentEditable)){if(s)return wS(s);else if(o)return wS(o)}}function wS(e){return e.contentEditable="true",xz&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function wk(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function wC(e,i){if(i instanceof bP){let n=e.docView.descAt(i.from);n!=e.lastSelectedViewDesc&&(wT(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else wT(e)}function wT(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function wE(e,i,n,r){return e.someProp("createSelectionBetween",r=>r(e,i,n))||bj.between(i,n,r)}function wN(e){return(!e.editable||!!e.hasFocus())&&wM(e)}function wM(e){let i=e.domSelectionRange();if(!i.anchorNode)return!1;try{return e.dom.contains(3==i.anchorNode.nodeType?i.anchorNode.parentNode:i.anchorNode)&&(e.editable||e.dom.contains(3==i.focusNode.nodeType?i.focusNode.parentNode:i.focusNode))}catch(e){return!1}}function wO(e,i){let{$anchor:n,$head:r}=e.selection,s=i>0?n.max(r):n.min(r),o=s.parent.inlineContent?s.depth?e.doc.resolve(i>0?s.after():s.before()):null:s;return o&&bA.findFrom(o,i)}function wA(e,i){return e.dispatch(e.state.tr.setSelection(i).scrollIntoView()),!0}function wR(e,i,n){let r=e.state.selection;if(r instanceof bj){if(n.indexOf("s")>-1){let{$head:n}=r,s=n.textOffset?null:i<0?n.nodeBefore:n.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=e.state.doc.resolve(n.pos+s.nodeSize*(i<0?-1:1));return wA(e,new bj(r.$anchor,o))}else if(!r.empty)return!1;else if(e.endOfTextblock(i>0?"forward":"backward")){let n=wO(e.state,i);return!!n&&n instanceof bP&&wA(e,n)}else if(!(xW&&n.indexOf("m")>-1)){let n=r.$head,s=n.textOffset?null:i<0?n.nodeBefore:n.nodeAfter,o;if(!s||s.isText)return!1;let a=i<0?n.pos-s.nodeSize:n.pos;return!!(s.isAtom||(o=e.docView.descAt(a))&&!o.contentDOM)&&(bP.isSelectable(s)?wA(e,new bP(i<0?e.state.doc.resolve(n.pos-s.nodeSize):n)):!!xU&&wA(e,new bj(e.state.doc.resolve(i<0?a:a+s.nodeSize))))}}else{if(r instanceof bP&&r.node.isInline)return wA(e,new bj(i>0?r.$to:r.$from));let n=wO(e.state,i);return!!n&&wA(e,n)}}function wD(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function wL(e,i){let n=e.pmViewDesc;return n&&0==n.size&&(i<0||e.nextSibling||"BR"!=e.nodeName)}function wj(e,i){return i<0?function(e){let i=e.domSelectionRange(),n=i.focusNode,r=i.focusOffset;if(!n)return;let s,o,a=!1;for(xj&&1==n.nodeType&&r<wD(n)&&wL(n.childNodes[r],-1)&&(a=!0);;)if(r>0)if(1!=n.nodeType)break;else{let e=n.childNodes[r-1];if(wL(e,-1))s=n,o=--r;else if(3==e.nodeType)r=(n=e).nodeValue.length;else break}else if(wI(n))break;else{let i=n.previousSibling;for(;i&&wL(i,-1);)s=n.parentNode,o=xm(i),i=i.previousSibling;if(i)r=wD(n=i);else{if((n=n.parentNode)==e.dom)break;r=0}}a?wP(e,n,r):s&&wP(e,s,o)}(e):function(e){let i,n,r=e.domSelectionRange(),s=r.focusNode,o=r.focusOffset;if(!s)return;let a=wD(s);for(;;)if(o<a){if(1!=s.nodeType)break;if(wL(s.childNodes[o],1))i=s,n=++o;else break}else if(wI(s))break;else{let r=s.nextSibling;for(;r&&wL(r,1);)i=r.parentNode,n=xm(r)+1,r=r.nextSibling;if(r)o=0,a=wD(s=r);else{if((s=s.parentNode)==e.dom)break;o=a=0}}i&&wP(e,i,n)}(e)}function wI(e){let i=e.pmViewDesc;return i&&i.node&&i.node.isBlock}function wP(e,i,n){if(3!=i.nodeType){let e,r;(r=function(e,i){for(;e&&i==e.childNodes.length&&!xk(e);)i=xm(e)+1,e=e.parentNode;for(;e&&i<e.childNodes.length;){let n=e.childNodes[i];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;e=n,i=0}}(i,n))?(i=r,n=0):(e=function(e,i){for(;e&&!i&&!xk(e);)i=xm(e),e=e.parentNode;for(;e&&i;){let n=e.childNodes[i-1];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;i=(e=n).childNodes.length}}(i,n))&&(i=e,n=e.nodeValue.length)}let r=e.domSelection();if(!r)return;if(xC(r)){let e=document.createRange();e.setEnd(i,n),e.setStart(i,n),r.removeAllRanges(),r.addRange(e)}else r.extend&&r.extend(i,n);e.domObserver.setCurSelection();let{state:s}=e;setTimeout(()=>{e.state==s&&wb(e)},50)}function wB(e,i){let n=e.state.doc.resolve(i);if(!(xP||xH)&&n.parent.inlineContent){let r=e.coordsAtPos(i);if(i>n.start()){let n=e.coordsAtPos(i-1),s=(n.top+n.bottom)/2;if(s>r.top&&s<r.bottom&&Math.abs(n.left-r.left)>1)return n.left<r.left?"ltr":"rtl"}if(i<n.end()){let n=e.coordsAtPos(i+1),s=(n.top+n.bottom)/2;if(s>r.top&&s<r.bottom&&Math.abs(n.left-r.left)>1)return n.left>r.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(e.dom).direction?"rtl":"ltr"}function wz(e,i,n){let r=e.state.selection;if(r instanceof bj&&!r.empty||n.indexOf("s")>-1||xW&&n.indexOf("m")>-1)return!1;let{$from:s,$to:o}=r;if(!s.parent.inlineContent||e.endOfTextblock(i<0?"up":"down")){let n=wO(e.state,i);if(n&&n instanceof bP)return wA(e,n)}if(!s.parent.inlineContent){let n=i<0?s:o,a=r instanceof bz?bA.near(n,i):bA.findFrom(n,i);return!!a&&wA(e,a)}return!1}function wF(e,i){if(!(e.state.selection instanceof bj))return!0;let{$head:n,$anchor:r,empty:s}=e.state.selection;if(!n.sameParent(r))return!0;if(!s)return!1;if(e.endOfTextblock(i>0?"forward":"backward"))return!0;let o=!n.textOffset&&(i<0?n.nodeBefore:n.nodeAfter);if(o&&!o.isText){let r=e.state.tr;return i<0?r.delete(n.pos-o.nodeSize,n.pos):r.delete(n.pos,n.pos+o.nodeSize),e.dispatch(r),!0}return!1}function wW(e,i,n){e.domObserver.stop(),i.contentEditable=n,e.domObserver.start()}function wH(e,i){e.someProp("transformCopied",n=>{i=n(i,e)});let n=[],{content:r,openStart:s,openEnd:o}=i;for(;s>1&&o>1&&1==r.childCount&&1==r.firstChild.childCount;){s--,o--;let e=r.firstChild;n.push(e.type.name,e.attrs!=e.type.defaultAttrs?e.attrs:null),r=e.content}let a=e.someProp("clipboardSerializer")||_Z.fromSchema(e.state.schema),l=wJ(),c=l.createElement("div");c.appendChild(a.serializeFragment(r,{document:l}));let h=c.firstChild,d,u=0;for(;h&&1==h.nodeType&&(d=wK[h.nodeName.toLowerCase()]);){for(let e=d.length-1;e>=0;e--){let i=l.createElement(d[e]);for(;c.firstChild;)i.appendChild(c.firstChild);c.appendChild(i),u++}h=c.firstChild}return h&&1==h.nodeType&&h.setAttribute("data-pm-slice",`${s} ${o}${u?` -${u}`:""} ${JSON.stringify(n)}`),{dom:c,text:e.someProp("clipboardTextSerializer",n=>n(i,e))||i.content.textBetween(0,i.content.size,"\n\n"),slice:i}}function w$(e,i,n,r,s){let o,a,l=s.parent.type.spec.code;if(!n&&!i)return null;let c=!!i&&(r||l||!n);if(c){if(e.someProp("transformPastedText",n=>{i=n(i,l||r,e)}),l)return a=new _p(_a.from(e.state.schema.text(i.replace(/\r\n?/g,"\n"))),0,0),e.someProp("transformPasted",i=>{a=i(a,e,!0)}),a;let n=e.someProp("clipboardTextParser",n=>n(i,s,r,e));if(n)a=n;else{let n=s.marks(),{schema:r}=e.state,a=_Z.fromSchema(r);o=document.createElement("div"),i.split(/(?:\r\n?|\n)+/).forEach(e=>{let i=o.appendChild(document.createElement("p"));e&&i.appendChild(a.serializeNode(r.text(e,n)))})}}else e.someProp("transformPastedHTML",i=>{n=i(n,e)}),o=function(e){var i;let n,r=/^(\s*<meta [^>]*>)*/.exec(e);r&&(e=e.slice(r[0].length));let s=wJ().createElement("div"),o=/<([a-z][^>\s]+)/i.exec(e),a;if((a=o&&wK[o[1].toLowerCase()])&&(e=a.map(e=>"<"+e+">").join("")+e+a.map(e=>"</"+e+">").reverse().join("")),s.innerHTML=(i=e,(n=window.trustedTypes)?(wG||(wG=n.defaultPolicy||n.createPolicy("ProseMirrorClipboard",{createHTML:e=>e})),wG.createHTML(i)):i),a)for(let e=0;e<a.length;e++)s=s.querySelector(a[e])||s;return s}(n),xU&&function(e){let i=e.querySelectorAll(xP?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<i.length;n++){let r=i[n];1==r.childNodes.length&&" "==r.textContent&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}(o);let h=o&&o.querySelector("[data-pm-slice]"),d=h&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(h.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let e=+d[3];e>0;e--){let e=o.firstChild;for(;e&&1!=e.nodeType;)e=e.nextSibling;if(!e)break;o=e}if(a||(a=(e.someProp("clipboardParser")||e.someProp("domParser")||_$.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||d),context:s,ruleFromNode:e=>"BR"!=e.nodeName||e.nextSibling||!e.parentNode||wU.test(e.parentNode.nodeName)?null:{ignore:!0}})),d)a=function(e,i){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(i)}catch(i){return e}let{content:s,openStart:o,openEnd:a}=e;for(let e=r.length-2;e>=0;e-=2){let i=n.nodes[r[e]];if(!i||i.hasRequiredAttrs())break;s=_a.from(i.create(r[e+1],s)),o++,a++}return new _p(s,o,a)}(wY(a,+d[1],+d[2]),d[4]);else if((a=_p.maxOpen(function(e,i){if(e.childCount<2)return e;for(let n=i.depth;n>=0;n--){let r=i.node(n).contentMatchAt(i.index(n)),s,o=[];if(e.forEach(e=>{if(!o)return;let i=r.findWrapping(e.type),n;if(!i)return o=null;if(n=o.length&&s.length&&function e(i,n,r,s,o){if(o<i.length&&o<n.length&&i[o]==n[o]){let a=e(i,n,r,s.lastChild,o+1);if(a)return s.copy(s.content.replaceChild(s.childCount-1,a));if(s.contentMatchAt(s.childCount).matchType(o==i.length-1?r.type:i[o+1]))return s.copy(s.content.append(_a.from(wV(r,i,o+1))))}}(i,s,e,o[o.length-1],0))o[o.length-1]=n;else{o.length&&(o[o.length-1]=function e(i,n){if(0==n)return i;let r=i.content.replaceChild(i.childCount-1,e(i.lastChild,n-1)),s=i.contentMatchAt(i.childCount).fillBefore(_a.empty,!0);return i.copy(r.append(s))}(o[o.length-1],s.length));let n=wV(e,i);o.push(n),r=r.matchType(n.type),s=i}}),o)return _a.from(o)}return e}(a.content,s),!0)).openStart||a.openEnd){let e=0,i=0;for(let i=a.content.firstChild;e<a.openStart&&!i.type.spec.isolating;e++,i=i.firstChild);for(let e=a.content.lastChild;i<a.openEnd&&!e.type.spec.isolating;i++,e=e.lastChild);a=wY(a,e,i)}return e.someProp("transformPasted",i=>{a=i(a,e,c)}),a}let wU=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function wV(e,i,n=0){for(let r=i.length-1;r>=n;r--)e=i[r].create(null,_a.from(e));return e}function wq(e,i,n,r,s,o){let a=i<0?e.firstChild:e.lastChild,l=a.content;return e.childCount>1&&(o=0),s<r-1&&(l=wq(l,i,n,r,s+1,o)),s>=n&&(l=i<0?a.contentMatchAt(0).fillBefore(l,o<=s).append(l):l.append(a.contentMatchAt(a.childCount).fillBefore(_a.empty,!0))),e.replaceChild(i<0?0:e.childCount-1,a.copy(l))}function wY(e,i,n){return i<e.openStart&&(e=new _p(wq(e.content,-1,i,e.openStart,0,e.openEnd),i,e.openEnd)),n<e.openEnd&&(e=new _p(wq(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}let wK={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},wX=null;function wJ(){return wX||(wX=document.implementation.createHTMLDocument("title"))}let wG=null,wZ={},wQ={},w0={touchstart:!0,touchmove:!0};class w1{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function w2(e,i){e.input.lastSelectionOrigin=i,e.input.lastSelectionTime=Date.now()}function w5(e){e.someProp("handleDOMEvents",i=>{for(let n in i)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=i=>w3(e,i))})}function w3(e,i){return e.someProp("handleDOMEvents",n=>{let r=n[i.type];return!!r&&(r(e,i)||i.defaultPrevented)})}function w4(e){return{left:e.clientX,top:e.clientY}}function w6(e,i,n,r,s){if(-1==r)return!1;let o=e.state.doc.resolve(r);for(let r=o.depth+1;r>0;r--)if(e.someProp(i,i=>r>o.depth?i(e,n,o.nodeAfter,o.before(r),s,!0):i(e,n,o.node(r),o.before(r),s,!1)))return!0;return!1}function w8(e,i,n){if(e.focused||e.focus(),e.state.selection.eq(i))return;let r=e.state.tr.setSelection(i);"pointer"==n&&r.setMeta("pointer",!0),e.dispatch(r)}wQ.keydown=(e,i)=>{if((e.input.shiftKey=16==i.keyCode||i.shiftKey,!Se(e,i))&&(e.input.lastKeyCode=i.keyCode,e.input.lastKeyCodeTime=Date.now(),!x$||!xP||13!=i.keyCode))if(229!=i.keyCode&&e.domObserver.forceFlush(),!xF||13!=i.keyCode||i.ctrlKey||i.altKey||i.metaKey)e.someProp("handleKeyDown",n=>n(e,i))||function(e,i){let n,r=i.keyCode,s=(n="",i.ctrlKey&&(n+="c"),i.metaKey&&(n+="m"),i.altKey&&(n+="a"),i.shiftKey&&(n+="s"),n);if(8==r||xW&&72==r&&"c"==s)return wF(e,-1)||wj(e,-1);if(46==r&&!i.shiftKey||xW&&68==r&&"c"==s)return wF(e,1)||wj(e,1);if(13==r||27==r)return!0;if(37==r||xW&&66==r&&"c"==s){let i=37==r?"ltr"==wB(e,e.state.selection.from)?-1:1:-1;return wR(e,i,s)||wj(e,i)}if(39==r||xW&&70==r&&"c"==s){let i=39==r?"ltr"==wB(e,e.state.selection.from)?1:-1:1;return wR(e,i,s)||wj(e,i)}else if(38==r||xW&&80==r&&"c"==s)return wz(e,-1,s)||wj(e,-1);else if(40==r||xW&&78==r&&"c"==s)return function(e){if(!xz||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:i,focusOffset:n}=e.domSelectionRange();if(i&&1==i.nodeType&&0==n&&i.firstChild&&"false"==i.firstChild.contentEditable){let n=i.firstChild;wW(e,n,"true"),setTimeout(()=>wW(e,n,"false"),20)}return!1}(e)||wz(e,1,s)||wj(e,1);else if(s==(xW?"m":"c")&&(66==r||73==r||89==r||90==r))return!0;return!1}(e,i)?i.preventDefault():w2(e,"key");else{let i=Date.now();e.input.lastIOSEnter=i,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==i&&(e.someProp("handleKeyDown",i=>i(e,xT(13,"Enter"))),e.input.lastIOSEnter=0)},200)}},wQ.keyup=(e,i)=>{16==i.keyCode&&(e.input.shiftKey=!1)},wQ.keypress=(e,i)=>{if(Se(e,i)||!i.charCode||i.ctrlKey&&!i.altKey||xW&&i.metaKey)return;if(e.someProp("handleKeyPress",n=>n(e,i)))return void i.preventDefault();let n=e.state.selection;if(!(n instanceof bj)||!n.$from.sameParent(n.$to)){let r=String.fromCharCode(i.charCode),s=()=>e.state.tr.insertText(r).scrollIntoView();/[\r\n]/.test(r)||e.someProp("handleTextInput",i=>i(e,n.$from.pos,n.$to.pos,r,s))||e.dispatch(s()),i.preventDefault()}};let w9=xW?"metaKey":"ctrlKey";wZ.mousedown=(e,i)=>{var n;let r,s;e.input.shiftKey=i.shiftKey;let o=Sr(e),a=Date.now(),l="singleClick";a-e.input.lastClick.time<500&&(r=(n=e.input.lastClick).x-i.clientX)*r+(s=n.y-i.clientY)*s<100&&!i[w9]&&e.input.lastClick.button==i.button&&("singleClick"==e.input.lastClick.type?l="doubleClick":"doubleClick"==e.input.lastClick.type&&(l="tripleClick")),e.input.lastClick={time:a,x:i.clientX,y:i.clientY,type:l,button:i.button};let c=e.posAtCoords(w4(i));c&&("singleClick"==l?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new w7(e,c,i,!!o)):("doubleClick"==l?function(e,i,n,r){return w6(e,"handleDoubleClickOn",i,n,r)||e.someProp("handleDoubleClick",n=>n(e,i,r))}:function(e,i,n,r){return w6(e,"handleTripleClickOn",i,n,r)||e.someProp("handleTripleClick",n=>n(e,i,r))||function(e,i,n){if(0!=n.button)return!1;let r=e.state.doc;if(-1==i)return!!r.inlineContent&&(w8(e,bj.create(r,0,r.content.size),"pointer"),!0);let s=r.resolve(i);for(let i=s.depth+1;i>0;i--){let n=i>s.depth?s.nodeAfter:s.node(i),o=s.before(i);if(n.inlineContent)w8(e,bj.create(r,o+1,o+1+n.content.size),"pointer");else{if(!bP.isSelectable(n))continue;w8(e,bP.create(r,o),"pointer")}return!0}}(e,n,r)})(e,c.pos,c.inside,i)?i.preventDefault():w2(e,"pointer"))};class w7{constructor(e,i,n,r){let s,o;if(this.view=e,this.pos=i,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[w9],this.allowDefault=n.shiftKey,i.inside>-1)s=e.state.doc.nodeAt(i.inside),o=i.inside;else{let n=e.state.doc.resolve(i.pos);s=n.parent,o=n.depth?n.before():0}const a=r?null:n.target,l=a?e.docView.nearestDesc(a,!0):null;this.target=l&&1==l.nodeDOM.nodeType?l.nodeDOM:null;let{selection:c}=e.state;0==n.button&&(s.type.spec.draggable&&!1!==s.type.spec.selectable||c instanceof bP&&c.from<=o&&c.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&xj&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),w2(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>wb(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let i=this.pos;if(this.view.state.doc!=this.startDoc&&(i=this.view.posAtCoords(w4(e))),this.updateAllowDefault(e),this.allowDefault||!i)w2(this.view,"pointer");else{var n,r,s,o;(n=this.view,r=i.pos,s=i.inside,o=this.selectNode,w6(n,"handleClickOn",r,s,e)||n.someProp("handleClick",i=>i(n,r,e))||(o?function(e,i){if(-1==i)return!1;let n=e.state.selection,r,s;n instanceof bP&&(r=n.node);let o=e.state.doc.resolve(i);for(let e=o.depth+1;e>0;e--){let i=e>o.depth?o.nodeAfter:o.node(e);if(bP.isSelectable(i)){s=r&&n.$from.depth>0&&e>=n.$from.depth&&o.before(n.$from.depth+1)==n.$from.pos?o.before(n.$from.depth):o.before(e);break}}return null!=s&&(w8(e,bP.create(e.state.doc,s),"pointer"),!0)}(n,s):function(e,i){if(-1==i)return!1;let n=e.state.doc.resolve(i),r=n.nodeAfter;return!!(r&&r.isAtom&&bP.isSelectable(r))&&(w8(e,new bP(n),"pointer"),!0)}(n,s)))?e.preventDefault():0==e.button&&(this.flushed||xz&&this.mightDrag&&!this.mightDrag.node.isAtom||xP&&!this.view.state.selection.visible&&2>=Math.min(Math.abs(i.pos-this.view.state.selection.from),Math.abs(i.pos-this.view.state.selection.to)))?(w8(this.view,bA.near(this.view.state.doc.resolve(i.pos)),"pointer"),e.preventDefault()):w2(this.view,"pointer")}}move(e){this.updateAllowDefault(e),w2(this.view,"pointer"),0==e.buttons&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}function Se(e,i){return!!e.composing||!!(xz&&500>Math.abs(i.timeStamp-e.input.compositionEndedAt))&&(e.input.compositionEndedAt=-2e8,!0)}wZ.touchstart=e=>{e.input.lastTouch=Date.now(),Sr(e),w2(e,"pointer")},wZ.touchmove=e=>{e.input.lastTouch=Date.now(),w2(e,"pointer")},wZ.contextmenu=e=>Sr(e);let St=x$?5e3:-1;function Si(e,i){clearTimeout(e.input.composingTimeout),i>-1&&(e.input.composingTimeout=setTimeout(()=>Sr(e),i))}function Sn(e){let i;for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=((i=document.createEvent("Event")).initEvent("event",!0,!0),i.timeStamp));e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function Sr(e,i=!1){if(!x$||!(e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),Sn(e),i||e.docView&&e.docView.dirty){let n=wy(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||i)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}wQ.compositionstart=wQ.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:i}=e,n=i.selection.$to;if(i.selection instanceof bj&&(i.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>!1===e.type.spec.inclusive)||xP&&xH&&function(e){let{focusNode:i,focusOffset:n}=e.domSelectionRange();if(!i||1!=i.nodeType||n>=i.childNodes.length)return!1;let r=i.childNodes[n];return 1==r.nodeType&&"false"==r.contentEditable}(e)))e.markCursor=e.state.storedMarks||n.marks(),Sr(e,!0),e.markCursor=null;else if(Sr(e,!i.selection.empty),xj&&i.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let i=e.domSelectionRange();for(let n=i.focusNode,r=i.focusOffset;n&&1==n.nodeType&&0!=r;){let i=r<0?n.lastChild:n.childNodes[r-1];if(!i)break;if(3==i.nodeType){let n=e.domSelection();n&&n.collapse(i,i.nodeValue.length);break}n=i,r=-1}}e.input.composing=!0}Si(e,St)},wQ.compositionend=(e,i)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=i.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,Si(e,20))};let Ss=xD&&xL<15||xF&&xV<604;function So(e,i,n,r,s){let o=w$(e,i,n,r,e.state.selection.$from);if(e.someProp("handlePaste",i=>i(e,s,o||_p.empty)))return!0;if(!o)return!1;let a=0==o.openStart&&0==o.openEnd&&1==o.content.childCount?o.content.firstChild:null,l=a?e.state.tr.replaceSelectionWith(a,r):e.state.tr.replaceSelection(o);return e.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Sa(e){let i=e.getData("text/plain")||e.getData("Text");if(i)return i;let n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}wZ.copy=wQ.cut=(e,i)=>{let n=e.state.selection,r="cut"==i.type;if(n.empty)return;let s=Ss?null:i.clipboardData,{dom:o,text:a}=wH(e,n.content());s?(i.preventDefault(),s.clearData(),s.setData("text/html",o.innerHTML),s.setData("text/plain",a)):function(e,i){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(i),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(i),e.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}(e,o),r&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},wQ.paste=(e,i)=>{if(e.composing&&!x$)return;let n=Ss?null:i.clipboardData,r=e.input.shiftKey&&45!=e.input.lastKeyCode;n&&So(e,Sa(n),n.getData("text/html"),r,i)?i.preventDefault():function(e,i){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=e.input.shiftKey&&45!=e.input.lastKeyCode;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?So(e,r.value,null,s,i):So(e,r.textContent,r.innerHTML,s,i)},50)}(e,i)};class Sl{constructor(e,i,n){this.slice=e,this.move=i,this.node=n}}let Sc=xW?"altKey":"ctrlKey";function Sh(e,i){let n;return e.someProp("dragCopies",e=>{n=n||e(i)}),null!=n?!n:!i[Sc]}for(let e in wZ.dragstart=(e,i)=>{let n,r=e.input.mouseDown;if(r&&r.done(),!i.dataTransfer)return;let s=e.state.selection,o=s.empty?null:e.posAtCoords(w4(i));if(o&&o.pos>=s.from&&o.pos<=(s instanceof bP?s.to-1:s.to));else if(r&&r.mightDrag)n=bP.create(e.state.doc,r.mightDrag.pos);else if(i.target&&1==i.target.nodeType){let r=e.docView.nearestDesc(i.target,!0);r&&r.node.type.spec.draggable&&r!=e.docView&&(n=bP.create(e.state.doc,r.posBefore))}let a=(n||e.state.selection).content(),{dom:l,text:c,slice:h}=wH(e,a);i.dataTransfer.files.length&&xP&&!(xB>120)||i.dataTransfer.clearData(),i.dataTransfer.setData(Ss?"Text":"text/html",l.innerHTML),i.dataTransfer.effectAllowed="copyMove",Ss||i.dataTransfer.setData("text/plain",c),e.dragging=new Sl(h,Sh(e,i),n)},wZ.dragend=e=>{let i=e.dragging;window.setTimeout(()=>{e.dragging==i&&(e.dragging=null)},50)},wQ.dragover=wQ.dragenter=(e,i)=>i.preventDefault(),wQ.drop=(e,i)=>{try{!function(e,i,n){if(!i.dataTransfer)return;let r=e.posAtCoords(w4(i));if(!r)return;let s=e.state.doc.resolve(r.pos),o=n&&n.slice;o?e.someProp("transformPasted",i=>{o=i(o,e,!1)}):o=w$(e,Sa(i.dataTransfer),Ss?null:i.dataTransfer.getData("text/html"),!1,s);let a=!!(n&&Sh(e,i));if(e.someProp("handleDrop",n=>n(e,i,o||_p.empty,a)))return i.preventDefault();if(!o)return;i.preventDefault();let l=o?bv(e.state.doc,s.pos,o):s.pos;null==l&&(l=s.pos);let c=e.state.tr;if(a){let{node:e}=n;e?e.replace(c):c.deleteSelection()}let h=c.mapping.map(l),d=0==o.openStart&&0==o.openEnd&&1==o.content.childCount,u=c.doc;if(d?c.replaceRangeWith(h,h,o.content.firstChild):c.replaceRange(h,h,o),c.doc.eq(u))return;let p=c.doc.resolve(h);if(d&&bP.isSelectable(o.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new bP(p));else{let i=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach((e,n,r,s)=>i=s),c.setSelection(wE(e,p,c.doc.resolve(i)))}e.focus(),e.dispatch(c.setMeta("uiEvent","drop"))}(e,i,e.dragging)}finally{e.dragging=null}},wZ.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&wb(e)},20))},wZ.blur=(e,i)=>{e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),i.relatedTarget&&e.dom.contains(i.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},wZ.beforeinput=(e,i)=>{if(xP&&x$&&"deleteContentBackward"==i.inputType){e.domObserver.flushSoon();let{domChangeCount:i}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=i||(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",i=>i(e,xT(8,"Backspace")))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}},wQ)wZ[e]=wQ[e];function Sd(e,i){if(e==i)return!0;for(let n in e)if(e[n]!==i[n])return!1;for(let n in i)if(!(n in e))return!1;return!0}class Su{constructor(e,i){this.toDOM=e,this.spec=i||Sv,this.side=this.spec.side||0}map(e,i,n,r){let{pos:s,deleted:o}=e.mapResult(i.from+r,this.side<0?-1:1);return o?null:new Sm(s-n,s-n,this)}valid(){return!0}eq(e){return this==e||e instanceof Su&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Sd(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Sp{constructor(e,i){this.attrs=e,this.spec=i||Sv}map(e,i,n,r){let s=e.map(i.from+r,this.spec.inclusiveStart?-1:1)-n,o=e.map(i.to+r,this.spec.inclusiveEnd?1:-1)-n;return s>=o?null:new Sm(s,o,this)}valid(e,i){return i.from<i.to}eq(e){return this==e||e instanceof Sp&&Sd(this.attrs,e.attrs)&&Sd(this.spec,e.spec)}static is(e){return e.type instanceof Sp}destroy(){}}class Sf{constructor(e,i){this.attrs=e,this.spec=i||Sv}map(e,i,n,r){let s=e.mapResult(i.from+r,1);if(s.deleted)return null;let o=e.mapResult(i.to+r,-1);return o.deleted||o.pos<=s.pos?null:new Sm(s.pos-n,o.pos-n,this)}valid(e,i){let{index:n,offset:r}=e.content.findIndex(i.from),s;return r==i.from&&!(s=e.child(n)).isText&&r+s.nodeSize==i.to}eq(e){return this==e||e instanceof Sf&&Sd(this.attrs,e.attrs)&&Sd(this.spec,e.spec)}destroy(){}}class Sm{constructor(e,i,n){this.from=e,this.to=i,this.type=n}copy(e,i){return new Sm(e,i,this.type)}eq(e,i=0){return this.type.eq(e.type)&&this.from+i==e.from&&this.to+i==e.to}map(e,i,n){return this.type.map(e,this,i,n)}static widget(e,i,n){return new Sm(e,e,new Su(i,n))}static inline(e,i,n,r){return new Sm(e,i,new Sp(n,r))}static node(e,i,n,r){return new Sm(e,i,new Sf(n,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof Sp}get widget(){return this.type instanceof Su}}let Sg=[],Sv={};class Sy{constructor(e,i){this.local=e.length?e:Sg,this.children=i.length?i:Sg}static create(e,i){return i.length?Sk(i,e,0,Sv):S_}find(e,i,n){let r=[];return this.findInner(null==e?0:e,null==i?1e9:i,r,0,n),r}findInner(e,i,n,r,s){for(let o=0;o<this.local.length;o++){let a=this.local[o];a.from<=i&&a.to>=e&&(!s||s(a.spec))&&n.push(a.copy(a.from+r,a.to+r))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<i&&this.children[o+1]>e){let a=this.children[o]+1;this.children[o+2].findInner(e-a,i-a,n,r+a,s)}}map(e,i,n){return this==S_||0==e.maps.length?this:this.mapInner(e,i,0,0,n||Sv)}mapInner(e,i,n,r,s){let o;for(let a=0;a<this.local.length;a++){let l=this.local[a].map(e,n,r);l&&l.type.valid(i,l)?(o||(o=[])).push(l):s.onRemove&&s.onRemove(this.local[a].spec)}return this.children.length?function(e,i,n,r,s,o,a){let l=e.slice();for(let e=0,i=o;e<n.maps.length;e++){let r=0;n.maps[e].forEach((e,n,s,o)=>{let a=o-s-(n-e);for(let s=0;s<l.length;s+=3){let o=l[s+1];if(o<0||e>o+i-r)continue;let c=l[s]+i-r;n>=c?l[s+1]=e<=c?-2:-1:e>=i&&a&&(l[s]+=a,l[s+1]+=a)}r+=a}),i=n.maps[e].map(i,-1)}let c=!1;for(let i=0;i<l.length;i+=3)if(l[i+1]<0){if(-2==l[i+1]){c=!0,l[i+1]=-1;continue}let h=n.map(e[i]+o),d=h-s;if(d<0||d>=r.content.size){c=!0;continue}let u=n.map(e[i+1]+o,-1)-s,{index:p,offset:f}=r.content.findIndex(d),m=r.maybeChild(p);if(m&&f==d&&f+m.nodeSize==u){let r=l[i+2].mapInner(n,m,h+1,e[i]+o+1,a);r!=S_?(l[i]=d,l[i+1]=u,l[i+2]=r):(l[i+1]=-2,c=!0)}else c=!0}if(c){let c=Sk(function(e,i,n,r,s,o,a){for(let l=0;l<e.length;l+=3)-1==e[l+1]&&function e(i,o){for(let e=0;e<i.local.length;e++){let l=i.local[e].map(r,s,o);l?n.push(l):a.onRemove&&a.onRemove(i.local[e].spec)}for(let n=0;n<i.children.length;n+=3)e(i.children[n+2],i.children[n]+o+1)}(e[l+2],i[l]+o+1);return n}(l,e,i,n,s,o,a),r,0,a);i=c.local;for(let e=0;e<l.length;e+=3)l[e+1]<0&&(l.splice(e,3),e-=3);for(let e=0,i=0;e<c.children.length;e+=3){let n=c.children[e];for(;i<l.length&&l[i]<n;)i+=3;l.splice(i,0,c.children[e],c.children[e+1],c.children[e+2])}}return new Sy(i.sort(SC),l)}(this.children,o||[],e,i,n,r,s):o?new Sy(o.sort(SC),Sg):S_}add(e,i){return i.length?this==S_?Sy.create(e,i):this.addInner(e,i,0):this}addInner(e,i,n){let r,s=0;e.forEach((e,o)=>{let a=o+n,l;if(l=Sw(i,e,a)){for(r||(r=this.children.slice());s<r.length&&r[s]<o;)s+=3;r[s]==o?r[s+2]=r[s+2].addInner(e,l,a+1):r.splice(s,0,o,o+e.nodeSize,Sk(l,e,a+1,Sv)),s+=3}});let o=Sx(s?SS(i):i,-n);for(let i=0;i<o.length;i++)o[i].type.valid(e,o[i])||o.splice(i--,1);return new Sy(o.length?this.local.concat(o).sort(SC):this.local,r||this.children)}remove(e){return 0==e.length||this==S_?this:this.removeInner(e,0)}removeInner(e,i){let n=this.children,r=this.local;for(let r=0;r<n.length;r+=3){let s,o=n[r]+i,a=n[r+1]+i;for(let i=0,n;i<e.length;i++)(n=e[i])&&n.from>o&&n.to<a&&(e[i]=null,(s||(s=[])).push(n));if(!s)continue;n==this.children&&(n=this.children.slice());let l=n[r+2].removeInner(s,o+1);l!=S_?n[r+2]=l:(n.splice(r,3),r-=3)}if(r.length){for(let n=0,s;n<e.length;n++)if(s=e[n])for(let e=0;e<r.length;e++)r[e].eq(s,i)&&(r==this.local&&(r=this.local.slice()),r.splice(e--,1))}return n==this.children&&r==this.local?this:r.length||n.length?new Sy(r,n):S_}forChild(e,i){let n,r;if(this==S_)return this;if(i.isLeaf)return Sy.empty;for(let i=0;i<this.children.length;i+=3)if(this.children[i]>=e){this.children[i]==e&&(n=this.children[i+2]);break}let s=e+1,o=s+i.content.size;for(let e=0;e<this.local.length;e++){let i=this.local[e];if(i.from<o&&i.to>s&&i.type instanceof Sp){let e=Math.max(s,i.from)-s,n=Math.min(o,i.to)-s;e<n&&(r||(r=[])).push(i.copy(e,n))}}if(r){let e=new Sy(r.sort(SC),Sg);return n?new Sb([e,n]):e}return n||S_}eq(e){if(this==e)return!0;if(!(e instanceof Sy)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let i=0;i<this.local.length;i++)if(!this.local[i].eq(e.local[i]))return!1;for(let i=0;i<this.children.length;i+=3)if(this.children[i]!=e.children[i]||this.children[i+1]!=e.children[i+1]||!this.children[i+2].eq(e.children[i+2]))return!1;return!0}locals(e){return ST(this.localsInner(e))}localsInner(e){if(this==S_)return Sg;if(e.inlineContent||!this.local.some(Sp.is))return this.local;let i=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof Sp||i.push(this.local[e]);return i}forEachSet(e){e(this)}}Sy.empty=new Sy([],[]),Sy.removeOverlap=ST;let S_=Sy.empty;class Sb{constructor(e){this.members=e}map(e,i){let n=this.members.map(n=>n.map(e,i,Sv));return Sb.from(n)}forChild(e,i){if(i.isLeaf)return Sy.empty;let n=[];for(let r=0;r<this.members.length;r++){let s=this.members[r].forChild(e,i);s!=S_&&(s instanceof Sb?n=n.concat(s.members):n.push(s))}return Sb.from(n)}eq(e){if(!(e instanceof Sb)||e.members.length!=this.members.length)return!1;for(let i=0;i<this.members.length;i++)if(!this.members[i].eq(e.members[i]))return!1;return!0}locals(e){let i,n=!0;for(let r=0;r<this.members.length;r++){let s=this.members[r].localsInner(e);if(s.length)if(i){n&&(i=i.slice(),n=!1);for(let e=0;e<s.length;e++)i.push(s[e])}else i=s}return i?ST(n?i:i.sort(SC)):Sg}static from(e){switch(e.length){case 0:return S_;case 1:return e[0];default:return new Sb(e.every(e=>e instanceof Sy)?e:e.reduce((e,i)=>e.concat(i instanceof Sy?i:i.members),[]))}}forEachSet(e){for(let i=0;i<this.members.length;i++)this.members[i].forEachSet(e)}}function Sx(e,i){if(!i||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let s=e[r];n.push(new Sm(s.from+i,s.to+i,s.type))}return n}function Sw(e,i,n){if(i.isLeaf)return null;let r=n+i.nodeSize,s=null;for(let i=0,o;i<e.length;i++)(o=e[i])&&o.from>n&&o.to<r&&((s||(s=[])).push(o),e[i]=null);return s}function SS(e){let i=[];for(let n=0;n<e.length;n++)null!=e[n]&&i.push(e[n]);return i}function Sk(e,i,n,r){let s=[],o=!1;i.forEach((i,a)=>{let l=Sw(e,i,a+n);if(l){o=!0;let e=Sk(l,i,n+a+1,r);e!=S_&&s.push(a,a+i.nodeSize,e)}});let a=Sx(o?SS(e):e,-n).sort(SC);for(let e=0;e<a.length;e++)a[e].type.valid(i,a[e])||(r.onRemove&&r.onRemove(a[e].spec),a.splice(e--,1));return a.length||s.length?new Sy(a,s):S_}function SC(e,i){return e.from-i.from||e.to-i.to}function ST(e){let i=e;for(let n=0;n<i.length-1;n++){let r=i[n];if(r.from!=r.to)for(let s=n+1;s<i.length;s++){let o=i[s];if(o.from==r.from){o.to!=r.to&&(i==e&&(i=e.slice()),i[s]=o.copy(o.from,r.to),SE(i,s+1,o.copy(r.to,o.to)));continue}o.from<r.to&&(i==e&&(i=e.slice()),i[n]=r.copy(r.from,o.from),SE(i,s,r.copy(o.from,r.to)));break}}return i}function SE(e,i,n){for(;i<e.length&&SC(n,e[i])>0;)i++;e.splice(i,0,n)}function SN(e){let i=[];return e.someProp("decorations",n=>{let r=n(e.state);r&&r!=S_&&i.push(r)}),e.cursorWrapper&&i.push(Sy.create(e.state.doc,[e.cursorWrapper.deco])),Sb.from(i)}let SM={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},SO=xD&&xL<=11;class SA{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class SR{constructor(e,i){this.view=e,this.handleDOMChange=i,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new SA,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(i=>{for(let e=0;e<i.length;e++)this.queue.push(i[e]);xD&&xL<=11&&i.some(e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():xz&&e.composing&&i.some(e=>"childList"==e.type&&"TR"==e.target.nodeName)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),SO&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,SM)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let i=0;i<e.length;i++)this.queue.push(e[i]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(wN(this.view)){if(this.suppressingSelectionUpdates)return wb(this.view);if(xD&&xL<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&xb(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let i=new Set,n;for(let n=e.focusNode;n;n=xg(n))i.add(n);for(let r=e.anchorNode;r;r=xg(r))if(i.has(r)){n=r;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:"selection",target:3==n.nodeType?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){var e;let{view:i}=this;if(!i.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=i.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&wN(i)&&!this.ignoreSelectionChange(r),o=-1,a=-1,l=!1,c=[];if(i.editable)for(let e=0;e<n.length;e++){let i=this.registerMutation(n[e],c);i&&(o=o<0?i.from:Math.min(i.from,o),a=a<0?i.to:Math.max(i.to,a),i.typeOver&&(l=!0))}if(c.some(e=>"BR"==e.nodeName)&&(8==i.input.lastKeyCode||46==i.input.lastKeyCode)){for(let e of c)if("BR"==e.nodeName&&e.parentNode){let i=e.nextSibling;for(;i&&1==i.nodeType;){if("false"==i.contentEditable){e.parentNode.removeChild(e);break}i=i.firstChild}}}else if(xj&&c.length){let e=c.filter(e=>"BR"==e.nodeName);if(2==e.length){let[i,n]=e;i.parentNode&&i.parentNode.parentNode==n.parentNode?n.remove():i.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of e){let e=r.parentNode;e&&"LI"==e.nodeName&&(!n||function(e,i){for(let n=i.parentNode;n&&n!=e.dom;n=n.parentNode){let i=e.docView.nearestDesc(n,!0);if(i&&i.node.isBlock)return n}return null}(i,n)!=e)&&r.remove()}}}let h=null;o<0&&s&&i.input.lastFocus>Date.now()-200&&Math.max(i.input.lastTouch,i.input.lastClick.time)<Date.now()-300&&xC(r)&&(h=wy(i))&&h.eq(bA.near(i.state.doc.resolve(0),1))?(i.input.lastFocus=0,wb(i),this.currentSelection.set(r),i.scrollToSelection()):(o>-1||s)&&(o>-1&&(i.docView.markDirty(o,a),e=i,!SD.has(e)&&(SD.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace))&&(e.requiresGeckoHackNode=xj,SL||(console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),SL=!0))),i.input.badSafariComposition&&(i.input.badSafariComposition=!1,function(e,i){var n;let{focusNode:r,focusOffset:s}=e.domSelectionRange();for(let o of i)if((null==(n=o.parentNode)?void 0:n.nodeName)=="TR"){let i=o.nextSibling;for(;i&&"TD"!=i.nodeName&&"TH"!=i.nodeName;)i=i.nextSibling;if(i){let n=i;for(;;){let e=n.firstChild;if(!e||1!=e.nodeType||"false"==e.contentEditable||/^(BR|IMG)$/.test(e.nodeName))break;n=e}n.insertBefore(o,n.firstChild),r==o&&e.domSelection().collapse(o,s)}else o.parentNode.removeChild(o)}}(i,c)),this.handleDOMChange(o,a,l,c),i.docView&&i.docView.dirty?i.updateState(i.state):this.currentSelection.eq(r)||wb(i),this.currentSelection.set(r))}registerMutation(e,i){if(i.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(n==this.view.docView||"contenteditable"==e.attributeName||"style"==e.attributeName&&!e.oldValue&&!e.target.getAttribute("style"))||!n||n.ignoreMutation(e))return null;if("childList"==e.type){for(let n=0;n<e.addedNodes.length;n++){let r=e.addedNodes[n];i.push(r),3==r.nodeType&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,s=e.nextSibling;if(xD&&xL<=11&&e.addedNodes.length)for(let i=0;i<e.addedNodes.length;i++){let{previousSibling:n,nextSibling:o}=e.addedNodes[i];(!n||0>Array.prototype.indexOf.call(e.addedNodes,n))&&(r=n),(!o||0>Array.prototype.indexOf.call(e.addedNodes,o))&&(s=o)}let o=r&&r.parentNode==e.target?xm(r)+1:0,a=n.localPosFromDOM(e.target,o,-1),l=s&&s.parentNode==e.target?xm(s):e.target.childNodes.length;return{from:a,to:n.localPosFromDOM(e.target,l,1)}}return"attributes"==e.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let SD=new WeakMap,SL=!1;function Sj(e,i){let n=i.startContainer,r=i.startOffset,s=i.endContainer,o=i.endOffset,a=e.domAtPos(e.state.selection.anchor);return xb(a.node,a.offset,s,o)&&([n,r,s,o]=[s,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:o}}function SI(e){let i=e.pmViewDesc;if(i)return i.parseRule();if("BR"==e.nodeName&&e.parentNode){if(xz&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement("div");return e.appendChild(document.createElement("li")),{skip:e}}else if(e.parentNode.lastChild==e||xz&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if("IMG"==e.nodeName&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}let SP=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function SB(e,i,n){return Math.max(n.anchor,n.head)>i.content.size?null:wE(e,i.resolve(n.anchor),i.resolve(n.head))}function Sz(e,i,n){let r=e.depth,s=i?e.end():e.pos;for(;r>0&&(i||e.indexAfter(r)==e.node(r).childCount);)r--,s++,i=!1;if(n){let i=e.node(r).maybeChild(e.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,s++}return s}function SF(e){if(2!=e.length)return!1;let i=e.charCodeAt(0),n=e.charCodeAt(1);return i>=56320&&i<=57343&&n>=55296&&n<=56319}class SW{constructor(e,i){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new w1,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=i,this.state=i.state,this.directPlugins=i.plugins||[],this.directPlugins.forEach(Sq),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):"function"==typeof e?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=SU(this),S$(this),this.nodeViews=SV(this),this.docView=wr(this.state.doc,SH(this),SN(this),this.dom,this),this.domObserver=new SR(this,(e,i,n,r)=>(function(e,i,n,r,s){let o,a,l,c=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,i<0){let i=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=wy(e,i);if(n&&!e.state.selection.eq(n)){if(xP&&x$&&13===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",i=>i(e,xT(13,"Enter"))))return;let r=e.state.tr.setSelection(n);"pointer"==i?r.setMeta("pointer",!0):"key"==i&&r.scrollIntoView(),c&&r.setMeta("composition",c),e.dispatch(r)}return}let h=e.state.doc.resolve(i),d=h.sharedDepth(n);i=h.before(d+1),n=e.state.doc.resolve(n).after(d+1);let u=e.state.selection,p=function(e,i,n){let r,{node:s,fromOffset:o,toOffset:a,from:l,to:c}=e.docView.parseRange(i,n),h=e.domSelectionRange(),d=h.anchorNode;if(d&&e.dom.contains(1==d.nodeType?d:d.parentNode)&&(r=[{node:d,offset:h.anchorOffset}],xC(h)||r.push({node:h.focusNode,offset:h.focusOffset})),xP&&8===e.input.lastKeyCode)for(let e=a;e>o;e--){let i=s.childNodes[e-1],n=i.pmViewDesc;if("BR"==i.nodeName&&!n){a=e;break}if(!n||n.size)break}let u=e.state.doc,p=e.someProp("domParser")||_$.fromSchema(e.state.schema),f=u.resolve(l),m=null,g=p.parse(s,{topNode:f.parent,topMatch:f.parent.contentMatchAt(f.index()),topOpen:!0,from:o,to:a,preserveWhitespace:"pre"!=f.parent.type.whitespace||"full",findPositions:r,ruleFromNode:SI,context:f});if(r&&null!=r[0].pos){let e=r[0].pos,i=r[1]&&r[1].pos;null==i&&(i=e),m={anchor:e+l,head:i+l}}return{doc:g,sel:m,from:l,to:c}}(e,i,n),f=e.state.doc,m=f.slice(p.from,p.to);8===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime?(o=e.state.selection.to,a="end"):(o=e.state.selection.from,a="start"),e.input.lastKeyCode=null;let g=function(e,i,n,r,s){let o=e.findDiffStart(i,n);if(null==o)return null;let{a:a,b:l}=e.findDiffEnd(i,n+e.size,n+i.size);if("end"==s){let e=Math.max(0,o-Math.min(a,l));r-=a+e-o}if(a<o&&e.size<i.size){let e=r<=o&&r>=a?o-r:0;(o-=e)&&o<i.size&&SF(i.textBetween(o-1,o+1))&&(o+=e?1:-1),l=o+(l-a),a=o}else if(l<o){let i=r<=o&&r>=l?o-r:0;(o-=i)&&o<e.size&&SF(e.textBetween(o-1,o+1))&&(o+=i?1:-1),a=o+(a-l),l=o}return{start:o,endA:a,endB:l}}(m.content,p.doc.content,p.from,o,a);if(g&&e.input.domChangeCount++,(xF&&e.input.lastIOSEnter>Date.now()-225||x$)&&s.some(e=>1==e.nodeType&&!SP.test(e.nodeName))&&(!g||g.endA>=g.endB)&&e.someProp("handleKeyDown",i=>i(e,xT(13,"Enter")))){e.input.lastIOSEnter=0;return}if(!g)if(r&&u instanceof bj&&!u.empty&&u.$head.sameParent(u.$anchor)&&!e.composing&&!(p.sel&&p.sel.anchor!=p.sel.head))g={start:u.from,endA:u.to,endB:u.to};else{if(p.sel){let i=SB(e,e.state.doc,p.sel);if(i&&!i.eq(e.state.selection)){let n=e.state.tr.setSelection(i);c&&n.setMeta("composition",c),e.dispatch(n)}}return}e.state.selection.from<e.state.selection.to&&g.start==g.endB&&e.state.selection instanceof bj&&(g.start>e.state.selection.from&&g.start<=e.state.selection.from+2&&e.state.selection.from>=p.from?g.start=e.state.selection.from:g.endA<e.state.selection.to&&g.endA>=e.state.selection.to-2&&e.state.selection.to<=p.to&&(g.endB+=e.state.selection.to-g.endA,g.endA=e.state.selection.to)),xD&&xL<=11&&g.endB==g.start+1&&g.endA==g.start&&g.start>p.from&&" "==p.doc.textBetween(g.start-p.from-1,g.start-p.from+1)&&(g.start--,g.endA--,g.endB--);let v=p.doc.resolveNoCache(g.start-p.from),y=p.doc.resolveNoCache(g.endB-p.from),_=f.resolve(g.start),b=v.sameParent(y)&&v.parent.inlineContent&&_.end()>=g.endA;if((xF&&e.input.lastIOSEnter>Date.now()-225&&(!b||s.some(e=>"DIV"==e.nodeName||"P"==e.nodeName))||!b&&v.pos<p.doc.content.size&&(!v.sameParent(y)||!v.parent.inlineContent)&&v.pos<y.pos&&!/\S/.test(p.doc.textBetween(v.pos,y.pos,"","")))&&e.someProp("handleKeyDown",i=>i(e,xT(13,"Enter")))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>g.start&&function(e,i,n,r,s){if(n-i<=s.pos-r.pos||Sz(r,!0,!1)<s.pos)return!1;let o=e.resolve(i);if(!r.parent.isTextblock){let e=o.nodeAfter;return null!=e&&n==i+e.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let a=e.resolve(Sz(o,!0,!0));return!(!a.parent.isTextblock||a.pos>n||Sz(a,!0,!1)<n)&&r.parent.content.cut(r.parentOffset).eq(a.parent.content)}(f,g.start,g.endA,v,y)&&e.someProp("handleKeyDown",i=>i(e,xT(8,"Backspace")))){x$&&xP&&e.domObserver.suppressSelectionUpdates();return}xP&&g.endB==g.start&&(e.input.lastChromeDelete=Date.now()),x$&&!b&&v.start()!=y.start()&&0==y.parentOffset&&v.depth==y.depth&&p.sel&&p.sel.anchor==p.sel.head&&p.sel.head==g.endA&&(g.endB-=2,y=p.doc.resolveNoCache(g.endB-p.from),setTimeout(()=>{e.someProp("handleKeyDown",function(i){return i(e,xT(13,"Enter"))})},20));let w=g.start,S=g.endA,k=i=>{let n=i||e.state.tr.replace(w,S,p.doc.slice(g.start-p.from,g.endB-p.from));if(p.sel){let i=SB(e,n.doc,p.sel);i&&!(xP&&e.composing&&i.empty&&(g.start!=g.endB||e.input.lastChromeDelete<Date.now()-100)&&(i.head==w||i.head==n.mapping.map(S)-1)||xD&&i.empty&&i.head==w)&&n.setSelection(i)}return c&&n.setMeta("composition",c),n.scrollIntoView()};if(b)if(v.pos==y.pos){xD&&xL<=11&&0==v.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>wb(e),20));let i=k(e.state.tr.delete(w,S)),n=f.resolve(g.start).marksAcross(f.resolve(g.endA));n&&i.ensureMarks(n),e.dispatch(i)}else if(g.endA==g.endB&&(l=function(e,i){let n=e.firstChild.marks,r=i.firstChild.marks,s=n,o=r,a,l,c;for(let e=0;e<r.length;e++)s=r[e].removeFromSet(s);for(let e=0;e<n.length;e++)o=n[e].removeFromSet(o);if(1==s.length&&0==o.length)l=s[0],a="add",c=e=>e.mark(l.addToSet(e.marks));else{if(0!=s.length||1!=o.length)return null;l=o[0],a="remove",c=e=>e.mark(l.removeFromSet(e.marks))}let h=[];for(let e=0;e<i.childCount;e++)h.push(c(i.child(e)));if(_a.from(h).eq(e))return{mark:l,type:a}}(v.parent.content.cut(v.parentOffset,y.parentOffset),_.parent.content.cut(_.parentOffset,g.endA-_.start())))){let i=k(e.state.tr);"add"==l.type?i.addMark(w,S,l.mark):i.removeMark(w,S,l.mark),e.dispatch(i)}else if(v.parent.child(v.index()).isText&&v.index()==y.index()-!y.textOffset){let i=v.parent.textBetween(v.parentOffset,y.parentOffset),n=()=>k(e.state.tr.insertText(i,w,S));e.someProp("handleTextInput",r=>r(e,w,S,i,n))||e.dispatch(n())}else e.dispatch(k());else e.dispatch(k())})(this,e,i,n,r)),this.domObserver.start(),function(e){for(let i in wZ){let n=wZ[i];e.dom.addEventListener(i,e.input.eventHandlers[i]=i=>{!function(e,i){if(!i.bubbles)return!0;if(i.defaultPrevented)return!1;for(let n=i.target;n!=e.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(i))return!1;return!0}(e,i)||w3(e,i)||!e.editable&&i.type in wQ||n(e,i)},w0[i]?{passive:!0}:void 0)}xz&&e.dom.addEventListener("input",()=>null),w5(e)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;for(let i in this._props={},e)this._props[i]=e[i];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&w5(this);let i=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Sq),this.directPlugins=e.plugins),this.updateStateInner(e.state,i)}setProps(e){let i={};for(let e in this._props)i[e]=this._props[e];for(let n in i.state=this.state,e)i[n]=e[n];this.update(i)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,i){var n,r,s;let o=this.state,a=!1,l=!1;e.storedMarks&&this.composing&&(Sn(this),l=!0),this.state=e;let c=o.plugins!=e.plugins||this._props.plugins!=i.plugins;if(c||this._props.plugins!=i.plugins||this._props.nodeViews!=i.nodeViews){let e=SV(this);(function(e,i){let n=0,r=0;for(let r in e){if(e[r]!=i[r])return!0;n++}for(let e in i)r++;return n!=r})(e,this.nodeViews)&&(this.nodeViews=e,a=!0)}(c||i.handleDOMEvents!=this._props.handleDOMEvents)&&w5(this),this.editable=SU(this),S$(this);let h=SN(this),d=SH(this),u=o.plugins==e.plugins||o.doc.eq(e.doc)?e.scrollToSelection>o.scrollToSelection?"to selection":"preserve":"reset",p=a||!this.docView.matchesNode(e.doc,d,h);(p||!e.selection.eq(o.selection))&&(l=!0);let f="preserve"==u&&l&&null==this.dom.style.overflowAnchor&&function(e){let i,n,r=e.dom.getBoundingClientRect(),s=Math.max(0,r.top);for(let o=(r.left+r.right)/2,a=s+1;a<Math.min(innerHeight,r.bottom);a+=5){let r=e.root.elementFromPoint(o,a);if(!r||r==e.dom||!e.dom.contains(r))continue;let l=r.getBoundingClientRect();if(l.top>=s-20){i=r,n=l.top;break}}return{refDOM:i,refTop:n,stack:xK(e.dom)}}(this);if(l){let i,n,l;this.domObserver.stop();let c=p&&(xD||xP)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&(r=o.selection,s=e.selection,l=Math.min(r.$anchor.sharedDepth(r.head),s.$anchor.sharedDepth(s.head)),r.$anchor.start(l)!=s.$anchor.start(l));if(p){let i=xP?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=function(e){let i=e.domSelectionRange();if(!i.focusNode)return null;let n=function(e,i){for(;;){if(3==e.nodeType&&i)return e;if(1==e.nodeType&&i>0){if("false"==e.contentEditable)return null;i=xS(e=e.childNodes[i-1])}else{if(!e.parentNode||xk(e))return null;i=xm(e),e=e.parentNode}}}(i.focusNode,i.focusOffset),r=function(e,i){for(;;){if(3==e.nodeType&&i<e.nodeValue.length)return e;if(1==e.nodeType&&i<e.childNodes.length){if("false"==e.contentEditable)return null;e=e.childNodes[i],i=0}else{if(!e.parentNode||xk(e))return null;i=xm(e)+1,e=e.parentNode}}}(i.focusNode,i.focusOffset);if(n&&r&&n!=r){let i=r.pmViewDesc,s=e.domObserver.lastChangedTextNode;if(n==s||r==s)return s;if(!i||!i.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(!(!e||!e.isText(n.nodeValue)))return r}}return n||r}(this)),(a||!this.docView.update(e.doc,d,h,this))&&(this.docView.updateOuterDeco(d),this.docView.destroy(),this.docView=wr(e.doc,d,h,this.dom,this)),!i||this.trackWrites&&this.dom.contains(this.trackWrites)||(c=!0)}c||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&(i=this.docView.domFromPos(this.state.selection.anchor,0),n=this.domSelectionRange(),xb(i.node,i.offset,n.anchorNode,n.anchorOffset)))?wb(this,c):(wC(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),(null==(n=this.dragging)?void 0:n.node)&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),"reset"==u?this.dom.scrollTop=0:"to selection"==u?this.scrollToSelection():f&&function({refDOM:e,refTop:i,stack:n}){let r=e?e.getBoundingClientRect().top:0;xX(n,0==r?0:r-i)}(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(e&&this.dom.contains(1==e.nodeType?e:e.parentNode))if(this.someProp("handleScrollToSelection",e=>e(this)));else if(this.state.selection instanceof bP){let i=this.docView.domAfterPos(this.state.selection.from);1==i.nodeType&&xY(this,i.getBoundingClientRect(),e)}else xY(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(e&&e.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let i=0;i<this.pluginViews.length;i++){let n=this.pluginViews[i];n.update&&n.update(this,e)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let i=this.directPlugins[e];i.spec.view&&this.pluginViews.push(i.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let i=this.state.plugins[e];i.spec.view&&this.pluginViews.push(i.spec.view(this))}}}updateDraggedNode(e,i){let n=e.node,r=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let e=n.from+(this.state.doc.content.size-i.doc.content.size);(e>0&&e<this.state.doc.content.size&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new Sl(e.slice,e.move,r<0?void 0:bP.create(this.state.doc,r))}someProp(e,i){let n=this._props&&this._props[e],r;if(null!=n&&(r=i?i(n):n))return r;for(let n=0;n<this.directPlugins.length;n++){let s=this.directPlugins[n].props[e];if(null!=s&&(r=i?i(s):s))return r}let s=this.state.plugins;if(s)for(let n=0;n<s.length;n++){let o=s[n].props[e];if(null!=o&&(r=i?i(o):o))return r}}hasFocus(){if(xD){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if("false"==e.contentEditable)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(e){if(e.setActive)return e.setActive();if(xJ)return e.focus(xJ);let i=xK(e);e.focus(null==xJ?{get preventScroll(){return xJ={preventScroll:!0},!0}}:void 0),xJ||(xJ=!1,xX(i,0))}(this.dom),wb(this),this.domObserver.start()}get root(){let e=this._root;if(null==e){for(let e=this.dom.parentNode;e;e=e.parentNode)if(9==e.nodeType||11==e.nodeType&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e}return e||document}updateRoot(){this._root=null}posAtCoords(e){return function(e,i){var n;let r,s,o=e.dom.ownerDocument,a,l=0,c=function(e,i,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(i,n);if(r)return{node:r.offsetNode,offset:Math.min(xS(r.offsetNode),r.offset)}}catch(e){}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(i,n);if(r)return{node:r.startContainer,offset:Math.min(xS(r.startContainer),r.startOffset)}}}(o,i.left,i.top);c&&({node:a,offset:l}=c);let h=(e.root.elementFromPoint?e.root:o).elementFromPoint(i.left,i.top);if(!h||!e.dom.contains(1!=h.nodeType?h.parentNode:h)){let n=e.dom.getBoundingClientRect();if(!xG(i,n)||!(h=function e(i,n,r){let s=i.childNodes.length;if(s&&r.top<r.bottom)for(let o=Math.max(0,Math.min(s-1,Math.floor(s*(n.top-r.top)/(r.bottom-r.top))-2)),a=o;;){let r=i.childNodes[a];if(1==r.nodeType){let i=r.getClientRects();for(let s=0;s<i.length;s++){let o=i[s];if(xG(n,o))return e(r,n,o)}}if((a=(a+1)%s)==o)break}return i}(e.dom,i,n)))return null}if(xz)for(let e=h;a&&e;e=xg(e))e.draggable&&(a=void 0);if(h=(r=(n=h).parentNode)&&/^li$/i.test(r.nodeName)&&i.left<n.getBoundingClientRect().left?r:n,a){let n;if(xj&&1==a.nodeType&&(l=Math.min(l,a.childNodes.length))<a.childNodes.length){let e=a.childNodes[l],n;"IMG"==e.nodeName&&(n=e.getBoundingClientRect()).right<=i.left&&n.bottom>i.top&&l++}xU&&l&&1==a.nodeType&&1==(n=a.childNodes[l-1]).nodeType&&"false"==n.contentEditable&&n.getBoundingClientRect().top>=i.top&&l--,a==e.dom&&l==a.childNodes.length-1&&1==a.lastChild.nodeType&&i.top>a.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:(0==l||1!=a.nodeType||"BR"!=a.childNodes[l-1].nodeName)&&(s=function(e,i,n,r){let s=-1;for(let n=i,o=!1;n!=e.dom;){let i=e.docView.nearestDesc(n,!0),a;if(!i)return null;if(1==i.dom.nodeType&&(i.node.isBlock&&i.parent||!i.contentDOM)&&((a=i.dom.getBoundingClientRect()).width||a.height)&&(i.node.isBlock&&i.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(i.dom.nodeName)&&(!o&&a.left>r.left||a.top>r.top?s=i.posBefore:(!o&&a.right<r.left||a.bottom<r.top)&&(s=i.posAfter),o=!0),!i.contentDOM&&s<0&&!i.node.isText))return(i.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?i.posBefore:i.posAfter;n=i.dom.parentNode}return s>-1?s:e.docView.posFromDOM(i,n,-1)}(e,a,l,i))}null==s&&(s=function(e,i,n){let{node:r,offset:s}=function e(i,n){let r,s,o,a=2e8,l,c=0,h=n.top,d=n.top;for(let e=i.firstChild,u=0;e;e=e.nextSibling,u++){let i;if(1==e.nodeType)i=e.getClientRects();else{if(3!=e.nodeType)continue;i=xy(e).getClientRects()}for(let p=0;p<i.length;p++){let f=i[p];if(f.top<=h&&f.bottom>=d){h=Math.max(f.bottom,h),d=Math.min(f.top,d);let i=f.left>n.left?f.left-n.left:f.right<n.left?n.left-f.right:0;if(i<a){o=e,a=i,l=i&&3==o.nodeType?{left:f.right<n.left?f.right:f.left,top:n.top}:n,1==e.nodeType&&i&&(c=u+ +(n.left>=(f.left+f.right)/2));continue}}else f.top>n.top&&!r&&f.left<=n.left&&f.right>=n.left&&(r=e,s={left:Math.max(f.left,Math.min(f.right,n.left)),top:f.top});!o&&(n.left>=f.right&&n.top>=f.top||n.left>=f.left&&n.top>=f.bottom)&&(c=u+1)}}return(!o&&r&&(o=r,l=s,a=0),o&&3==o.nodeType)?function(e,i){let n=e.nodeValue.length,r=document.createRange(),s;for(let o=0;o<n;o++){r.setEnd(e,o+1),r.setStart(e,o);let n=xQ(r,1);if(n.top!=n.bottom&&xG(i,n)){s={node:e,offset:o+ +(i.left>=(n.left+n.right)/2)};break}}return r.detach(),s||{node:e,offset:0}}(o,l):!o||a&&1==o.nodeType?{node:i,offset:c}:e(o,l)}(i,n),o=-1;if(1==r.nodeType&&!r.firstChild){let e=r.getBoundingClientRect();o=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,s,o)}(e,h,i));let d=e.docView.nearestDesc(h,!0);return{pos:s,inside:d?d.posAtStart-d.border:-1}}(this,e)}coordsAtPos(e,i=1){return x1(this,e,i)}domAtPos(e,i=0){return this.docView.domFromPos(e,i)}nodeDOM(e){let i=this.docView.descAt(e);return i?i.nodeDOM:null}posAtDOM(e,i,n=-1){let r=this.docView.posFromDOM(e,i,n);if(null==r)throw RangeError("DOM position not inside the editor");return r}endOfTextblock(e,i){return function(e,i,n){let r,s;return x6==i&&x8==n?x9:(x6=i,x8=n,x9="up"==n||"down"==n?(r=i.selection,s="up"==n?r.$from:r.$to,x3(e,i,()=>{let{node:i}=e.docView.domFromPos(s.pos,"up"==n?-1:1);for(;;){let n=e.docView.nearestDesc(i,!0);if(!n)break;if(n.node.isBlock){i=n.contentDOM||n.dom;break}i=n.dom.parentNode}let r=x1(e,s.pos,1);for(let e=i.firstChild;e;e=e.nextSibling){let i;if(1==e.nodeType)i=e.getClientRects();else{if(3!=e.nodeType)continue;i=xy(e,0,e.nodeValue.length).getClientRects()}for(let e=0;e<i.length;e++){let s=i[e];if(s.bottom>s.top+1&&("up"==n?r.top-s.top>(s.bottom-r.top)*2:s.bottom-r.bottom>(r.bottom-s.top)*2))return!1}}return!0})):function(e,i,n){let{$head:r}=i.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,o=s==r.parent.content.size,a=e.domSelection();return a?x4.test(r.parent.textContent)&&a.modify?x3(e,i,()=>{let{focusNode:i,focusOffset:s,anchorNode:o,anchorOffset:l}=e.domSelectionRange(),c=a.caretBidiLevel;a.modify("move",n,"character");let h=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:d,focusOffset:u}=e.domSelectionRange(),p=d&&!h.contains(1==d.nodeType?d:d.parentNode)||i==d&&s==u;try{a.collapse(o,l),i&&(i!=o||s!=l)&&a.extend&&a.extend(i,s)}catch(e){}return null!=c&&(a.caretBidiLevel=c),p}):"left"==n||"backward"==n?!s:o:r.pos==r.start()||r.pos==r.end()}(e,i,n))}(this,i||this.state,e)}pasteHTML(e,i){return So(this,"",e,!1,i||new ClipboardEvent("paste"))}pasteText(e,i){return So(this,e,null,!0,i||new ClipboardEvent("paste"))}serializeForClipboard(e){return wH(this,e)}destroy(){if(this.docView){for(let e in this.domObserver.stop(),this.input.eventHandlers)this.dom.removeEventListener(e,this.input.eventHandlers[e]);clearTimeout(this.input.composingTimeout),clearTimeout(this.input.lastIOSEnterFallbackTimeout),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],SN(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,x_()}}get isDestroyed(){return null==this.docView}dispatchEvent(e){!w3(this,e)&&wZ[e.type]&&(this.editable||!(e.type in wQ))&&wZ[e.type](this,e)}domSelectionRange(){let e=this.domSelection();return e?xz&&11===this.root.nodeType&&function(e){let i=e.activeElement;for(;i&&i.shadowRoot;)i=i.shadowRoot.activeElement;return i}(this.dom.ownerDocument)==this.dom&&function(e,i){let n;if(i.getComposedRanges){let n=i.getComposedRanges(e.root)[0];if(n)return Sj(e,n)}function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",r,!0),n?Sj(e,n):null}(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function SH(e){let i=Object.create(null);return i.class="ProseMirror",i.contenteditable=String(e.editable),e.someProp("attributes",n=>{if("function"==typeof n&&(n=n(e.state)),n)for(let e in n)"class"==e?i.class+=" "+n[e]:"style"==e?i.style=(i.style?i.style+";":"")+n[e]:i[e]||"contenteditable"==e||"nodeName"==e||(i[e]=String(n[e]))}),i.translate||(i.translate="no"),[Sm.node(0,e.state.doc.content.size,i)]}function S$(e){if(e.markCursor){let i=document.createElement("img");i.className="ProseMirror-separator",i.setAttribute("mark-placeholder","true"),i.setAttribute("alt",""),e.cursorWrapper={dom:i,deco:Sm.widget(e.state.selection.from,i,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function SU(e){return!e.someProp("editable",i=>!1===i(e.state))}function SV(e){let i=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(i,n)||(i[n]=e[n])}return e.someProp("nodeViews",n),e.someProp("markViews",n),i}function Sq(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw RangeError("Plugins passed directly to the view must not have a state component")}SW.prototype.dispatch=function(e){let i=this._props.dispatchTransaction;i?i.call(this,e):this.updateState(this.state.apply(e))};for(var SY={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},SK={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},SX="u">typeof navigator&&/Mac/.test(navigator.platform),SJ="u">typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),SG=0;SG<10;SG++)SY[48+SG]=SY[96+SG]=String(SG);for(var SG=1;SG<=24;SG++)SY[SG+111]="F"+SG;for(var SG=65;SG<=90;SG++)SY[SG]=String.fromCharCode(SG+32),SK[SG]=String.fromCharCode(SG);for(var SZ in SY)SK.hasOwnProperty(SZ)||(SK[SZ]=SY[SZ]);let SQ="u">typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),S0="u">typeof navigator&&/Win/.test(navigator.platform);function S1(e,i,n=!0){return i.altKey&&(e="Alt-"+e),i.ctrlKey&&(e="Ctrl-"+e),i.metaKey&&(e="Meta-"+e),n&&i.shiftKey&&(e="Shift-"+e),e}function S2(e){let i=function(e){let i=Object.create(null);for(let n in e)i[function(e){let i,n,r,s,o=e.split(/-(?!$)/),a=o[o.length-1];"Space"==a&&(a=" ");for(let e=0;e<o.length-1;e++){let a=o[e];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))i=!0;else if(/^(c|ctrl|control)$/i.test(a))n=!0;else if(/^s(hift)?$/i.test(a))r=!0;else if(/^mod$/i.test(a))SQ?s=!0:n=!0;else throw Error("Unrecognized modifier name: "+a)}return i&&(a="Alt-"+a),n&&(a="Ctrl-"+a),s&&(a="Meta-"+a),r&&(a="Shift-"+a),a}(n)]=e[n];return i}(e);return function(e,n){var r;let s=("Esc"==(r=!(SX&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||SJ&&n.shiftKey&&n.key&&1==n.key.length||"Unidentified"==n.key)&&n.key||(n.shiftKey?SK:SY)[n.keyCode]||n.key||"Unidentified")&&(r="Escape"),"Del"==r&&(r="Delete"),"Left"==r&&(r="ArrowLeft"),"Up"==r&&(r="ArrowUp"),"Right"==r&&(r="ArrowRight"),"Down"==r&&(r="ArrowDown"),r),o,a=i[S1(s,n)];if(a&&a(e.state,e.dispatch,e))return!0;if(1==s.length&&" "!=s){if(n.shiftKey){let r=i[S1(s,n,!1)];if(r&&r(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(S0&&n.ctrlKey&&n.altKey)&&(o=SY[n.keyCode])&&o!=s){let r=i[S1(o,n)];if(r&&r(e.state,e.dispatch,e))return!0}}return!1}}var S5=Object.defineProperty,S3=(e,i)=>{for(var n in i)S5(e,n,{get:i[n],enumerable:!0})};function S4(e){let{state:i,transaction:n}=e,{selection:r}=n,{doc:s}=n,{storedMarks:o}=n;return{...i,apply:i.apply.bind(i),applyTransaction:i.applyTransaction.bind(i),plugins:i.plugins,schema:i.schema,reconfigure:i.reconfigure.bind(i),toJSON:i.toJSON.bind(i),get storedMarks(){return o},get selection(){return r},get doc(){return s},get tr(){return r=n.selection,s=n.doc,o=n.storedMarks,n}}}var S6=class{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:e,editor:i,state:n}=this,{view:r}=i,{tr:s}=n,o=this.buildProps(s);return Object.fromEntries(Object.entries(e).map(([e,i])=>[e,(...e)=>{let n=i(...e)(o);return s.getMeta("preventDispatch")||this.hasCustomState||r.dispatch(s),n}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,i=!0){let{rawCommands:n,editor:r,state:s}=this,{view:o}=r,a=[],l=!!e,c=e||s.tr,h=()=>(l||!i||c.getMeta("preventDispatch")||this.hasCustomState||o.dispatch(c),a.every(e=>!0===e)),d={...Object.fromEntries(Object.entries(n).map(([e,n])=>[e,(...e)=>{let r=this.buildProps(c,i),s=n(...e)(r);return a.push(s),d}])),run:h};return d}createCan(e){let{rawCommands:i,state:n}=this,r=e||n.tr,s=this.buildProps(r,!1);return{...Object.fromEntries(Object.entries(i).map(([e,i])=>[e,(...e)=>i(...e)({...s,dispatch:void 0})])),chain:()=>this.createChain(r,!1)}}buildProps(e,i=!0){let{rawCommands:n,editor:r,state:s}=this,{view:o}=r,a={tr:e,editor:r,view:o,state:S4({state:s,transaction:e}),dispatch:i?()=>void 0:void 0,chain:()=>this.createChain(e,i),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(n).map(([e,i])=>[e,(...e)=>i(...e)(a)]))}};return a}},S8={};S3(S8,{blur:()=>S9,clearContent:()=>S7,clearNodes:()=>ke,command:()=>kt,createParagraphNear:()=>ki,cut:()=>kn,deleteCurrentNode:()=>kr,deleteNode:()=>ko,deleteRange:()=>ka,deleteSelection:()=>kl,enter:()=>kc,exitCode:()=>kh,extendMarkRange:()=>kv,first:()=>ky,focus:()=>kk,forEach:()=>kC,insertContent:()=>kT,insertContentAt:()=>kO,joinBackward:()=>kD,joinDown:()=>kR,joinForward:()=>kL,joinItemBackward:()=>kj,joinItemForward:()=>kI,joinTextblockBackward:()=>kP,joinTextblockForward:()=>kB,joinUp:()=>kA,keyboardShortcut:()=>kF,lift:()=>kH,liftEmptyBlock:()=>k$,liftListItem:()=>kU,newlineInCode:()=>kV,resetAttributes:()=>kK,scrollIntoView:()=>kX,selectAll:()=>kJ,selectNodeBackward:()=>kG,selectNodeForward:()=>kZ,selectParentNode:()=>kQ,selectTextblockEnd:()=>k0,selectTextblockStart:()=>k1,setContent:()=>k5,setMark:()=>CE,setMeta:()=>CN,setNode:()=>CM,setNodeSelection:()=>CO,setTextDirection:()=>CA,setTextSelection:()=>CR,sinkListItem:()=>CD,splitBlock:()=>Cj,splitListItem:()=>CI,toggleList:()=>Cz,toggleMark:()=>CF,toggleNode:()=>CW,toggleWrap:()=>CH,undoInputRule:()=>C$,unsetAllMarks:()=>CU,unsetMark:()=>CV,unsetTextDirection:()=>Cq,updateAttributes:()=>CY,wrapIn:()=>CK,wrapInList:()=>CX});var S9=()=>({editor:e,view:i})=>(requestAnimationFrame(()=>{var n;e.isDestroyed||(i.dom.blur(),null==(n=null==window?void 0:window.getSelection())||n.removeAllRanges())}),!0),S7=(e=!0)=>({commands:i})=>i.setContent("",{emitUpdate:e}),ke=()=>({state:e,tr:i,dispatch:n})=>{let{selection:r}=i,{ranges:s}=r;return!n||(s.forEach(({$from:n,$to:r})=>{e.doc.nodesBetween(n.pos,r.pos,(e,n)=>{if(e.type.isText)return;let{doc:r,mapping:s}=i,o=r.resolve(s.map(n)),a=r.resolve(s.map(n+e.nodeSize)),l=o.blockRange(a);if(!l)return;let c=bl(l);if(e.type.isTextblock){let{defaultType:e}=o.parent.contentMatchAt(o.index());i.setNodeMarkup(l.start,e)}(c||0===c)&&i.lift(l,c)})}),!0)},kt=e=>i=>e(i),ki=()=>({state:e,dispatch:i})=>xn(e,i),kn=(e,i)=>({editor:n,tr:r})=>{let{state:s}=n,o=s.doc.slice(e.from,e.to);r.deleteRange(e.from,e.to);let a=r.mapping.map(i);return r.insert(a,o.content),r.setSelection(new bj(r.doc.resolve(Math.max(a-1,0)))),!0},kr=()=>({tr:e,dispatch:i})=>{let{selection:n}=e,r=n.$anchor.node();if(r.content.size>0)return!1;let s=e.selection.$anchor;for(let n=s.depth;n>0;n-=1)if(s.node(n).type===r.type){if(i){let i=s.before(n),r=s.after(n);e.delete(i,r).scrollIntoView()}return!0}return!1};function ks(e,i){if("string"==typeof e){if(!i.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return i.nodes[e]}return e}var ko=e=>({tr:i,state:n,dispatch:r})=>{let s=ks(e,n.schema),o=i.selection.$anchor;for(let e=o.depth;e>0;e-=1)if(o.node(e).type===s){if(r){let n=o.before(e),r=o.after(e);i.delete(n,r).scrollIntoView()}return!0}return!1},ka=e=>({tr:i,dispatch:n})=>{let{from:r,to:s}=e;return n&&i.delete(r,s),!0},kl=()=>({state:e,dispatch:i})=>bQ(e,i),kc=()=>({commands:e})=>e.keyboardShortcut("Enter"),kh=()=>({state:e,dispatch:i})=>xi(e,i);function kd(e){return"[object RegExp]"===Object.prototype.toString.call(e)}function ku(e,i,n={strict:!0}){let r=Object.keys(i);return!r.length||r.every(r=>n.strict?i[r]===e[r]:kd(i[r])?i[r].test(e[r]):i[r]===e[r])}function kp(e,i,n={}){return e.find(e=>e.type===i&&ku(Object.fromEntries(Object.keys(n).map(i=>[i,e.attrs[i]])),n))}function kf(e,i,n={}){return!!kp(e,i,n)}function km(e,i,n){if(!e||!i)return;let r=e.parent.childAfter(e.parentOffset);if(r.node&&r.node.marks.some(e=>e.type===i)||(r=e.parent.childBefore(e.parentOffset)),!r.node||!r.node.marks.some(e=>e.type===i))return;if(!n){let e=r.node.marks.find(e=>e.type===i);e&&(n=e.attrs)}if(!kp([...r.node.marks],i,n))return;let s=r.index,o=e.start()+r.offset,a=s+1,l=o+r.node.nodeSize;for(;s>0&&kf([...e.parent.child(s-1).marks],i,n);)s-=1,o-=e.parent.child(s).nodeSize;for(;a<e.parent.childCount&&kf([...e.parent.child(a).marks],i,n);)l+=e.parent.child(a).nodeSize,a+=1;return{from:o,to:l}}function kg(e,i){if("string"==typeof e){if(!i.marks[e])throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);return i.marks[e]}return e}var kv=(e,i)=>({tr:n,state:r,dispatch:s})=>{let o=kg(e,r.schema),{doc:a,selection:l}=n,{$from:c,from:h,to:d}=l;if(s){let e=km(c,o,i);if(e&&e.from<=h&&e.to>=d){let i=bj.create(a,e.from,e.to);n.setSelection(i)}}return!0},ky=e=>i=>{let n="function"==typeof e?e(i):e;for(let e=0;e<n.length;e+=1)if(n[e](i))return!0;return!1};function k_(e){return e instanceof bj}function kb(e=0,i=0,n=0){return Math.min(Math.max(e,i),n)}function kx(e,i=null){if(!i)return null;let n=bA.atStart(e),r=bA.atEnd(e);if("start"===i||!0===i)return n;if("end"===i)return r;let s=n.from,o=r.to;return"all"===i?bj.create(e,kb(0,s,o),kb(e.content.size,s,o)):bj.create(e,kb(i,s,o),kb(i,s,o))}function kw(){return"Android"===navigator.platform||/android/i.test(navigator.userAgent)}function kS(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var kk=(e=null,i={})=>({editor:n,view:r,tr:s,dispatch:o})=>{i={scrollIntoView:!0,...i};let a=()=>{(kS()||kw())&&r.dom.focus(),"u">typeof navigator&&/^((?!chrome|android).)*safari/i.test(navigator.userAgent)&&!kS()&&!kw()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{!n.isDestroyed&&(r.focus(),(null==i?void 0:i.scrollIntoView)&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&null===e||!1===e)return!0}catch{return!1}if(o&&null===e&&!k_(n.state.selection))return a(),!0;let l=kx(s.doc,e)||n.state.selection,c=n.state.selection.eq(l);return o&&(c||s.setSelection(l),c&&s.storedMarks&&s.setStoredMarks(s.storedMarks),a()),!0},kC=(e,i)=>n=>e.every((e,r)=>i(e,{...n,index:r})),kT=(e,i)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,i),kE=e=>{let i=e.childNodes;for(let n=i.length-1;n>=0;n-=1){let r=i[n];3===r.nodeType&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?e.removeChild(r):1===r.nodeType&&kE(r)}return e};function kN(e){if("u"<typeof window)throw Error("[tiptap error]: there is no window object available, so this function cannot be used");let i=`<body>${e}</body>`;return kE(new window.DOMParser().parseFromString(i,"text/html").body)}function kM(e,i,n){if(e instanceof _T||e instanceof _a)return e;n={slice:!0,parseOptions:{},...n};let r="object"==typeof e&&null!==e,s="string"==typeof e;if(r)try{if(Array.isArray(e)&&e.length>0)return _a.fromArray(e.map(e=>i.nodeFromJSON(e)));let r=i.nodeFromJSON(e);return n.errorOnInvalidContent&&r.check(),r}catch(r){if(n.errorOnInvalidContent)throw Error("[tiptap error]: Invalid JSON content",{cause:r});return console.warn("[tiptap warn]: Invalid content.","Passed value:",e,"Error:",r),kM("",i,n)}if(s){if(n.errorOnInvalidContent){let r=!1,s="",o=new _W({topNode:i.spec.topNode,marks:i.spec.marks,nodes:i.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:e=>(r=!0,s="string"==typeof e?e:e.outerHTML,null)}]}})});if(n.slice?_$.fromSchema(o).parseSlice(kN(e),n.parseOptions):_$.fromSchema(o).parse(kN(e),n.parseOptions),n.errorOnInvalidContent&&r)throw Error("[tiptap error]: Invalid HTML content",{cause:Error(`Invalid element found: ${s}`)})}let r=_$.fromSchema(i);return n.slice?r.parseSlice(kN(e),n.parseOptions).content:r.parse(kN(e),n.parseOptions)}return kM("",i,n)}var kO=(e,i,n)=>({tr:r,dispatch:s,editor:o})=>{var a;if(s){let s,l;n={parseOptions:o.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let c=e=>{o.emit("contentError",{editor:o,error:e,disableCollaboration:()=>{"collaboration"in o.storage&&"object"==typeof o.storage.collaboration&&o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},h={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{kM(i,o.schema,{parseOptions:h,errorOnInvalidContent:!0})}catch(e){c(e)}try{s=kM(i,o.schema,{parseOptions:h,errorOnInvalidContent:null!=(a=n.errorOnInvalidContent)?a:o.options.enableContentCheck})}catch(e){return c(e),!1}let{from:d,to:u}="number"==typeof e?{from:e,to:e}:{from:e.from,to:e.to},p=!0,f=!0;if((!("type"in s)?s:[s]).forEach(e=>{e.check(),p=!!p&&e.isText&&0===e.marks.length,f=!!f&&e.isBlock}),d===u&&f){let{parent:e}=r.doc.resolve(d);!e.isTextblock||e.type.spec.code||e.childCount||(d-=1,u+=1)}if(p){if(Array.isArray(i))l=i.map(e=>e.text||"").join("");else if(i instanceof _a){let e="";i.forEach(i=>{i.text&&(e+=i.text)}),l=e}else l="object"==typeof i&&i&&i.text?i.text:i;r.insertText(l,d,u)}else{l=s;let e=r.doc.resolve(d),i=e.node(),n=0===e.parentOffset,o=i.isText||i.isTextblock,a=i.content.size>0;n&&o&&a&&f&&(d=Math.max(0,d-1)),r.replaceWith(d,u,l)}n.updateSelection&&function(e,i){let n=e.steps.length-1;if(n<i)return;let r=e.steps[n];if(!(r instanceof br||r instanceof bs))return;let s=e.mapping.maps[n],o=0;s.forEach((e,i,n,r)=>{0===o&&(o=r)}),e.setSelection(bA.near(e.doc.resolve(o),-1))}(r,r.steps.length-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:l}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:l})}return!0},kA=()=>({state:e,dispatch:i})=>((e,i)=>{let n=e.selection,r=n instanceof bP,s;if(r){if(n.node.isTextblock||!bf(e.doc,n.from))return!1;s=n.from}else if(null==(s=bg(e.doc,n.from,-1)))return!1;if(i){let n=e.tr.join(s);r&&n.setSelection(bP.create(n.doc,s-e.doc.resolve(s).nodeBefore.nodeSize)),i(n.scrollIntoView())}return!0})(e,i),kR=()=>({state:e,dispatch:i})=>((e,i)=>{let n=e.selection,r;if(n instanceof bP){if(n.node.isTextblock||!bf(e.doc,n.to))return!1;r=n.to}else if(null==(r=bg(e.doc,n.to,1)))return!1;return i&&i(e.tr.join(r).scrollIntoView()),!0})(e,i),kD=()=>({state:e,dispatch:i})=>b1(e,i),kL=()=>({state:e,dispatch:i})=>b8(e,i),kj=()=>({state:e,dispatch:i,tr:n})=>{try{let r=bg(e.doc,e.selection.$from.pos,-1);if(null==r)return!1;return n.join(r,2),i&&i(n),!0}catch{return!1}},kI=()=>({state:e,dispatch:i,tr:n})=>{try{let r=bg(e.doc,e.selection.$from.pos,1);if(null==r)return!1;return n.join(r,2),i&&i(n),!0}catch{return!1}},kP=()=>({state:e,dispatch:i})=>((e,i,n)=>{let r=b0(e,n);if(!r)return!1;let s=b4(r);return!!s&&b2(e,s,i)})(e,i),kB=()=>({state:e,dispatch:i})=>((e,i,n)=>{let r=b6(e,n);if(!r)return!1;let s=b7(r);return!!s&&b2(e,s,i)})(e,i);function kz(){return"u">typeof navigator&&/Mac/.test(navigator.platform)}var kF=e=>({editor:i,view:n,tr:r,dispatch:s})=>{let o=(function(e){let i,n,r,s,o=e.split(/-(?!$)/),a=o[o.length-1];"Space"===a&&(a=" ");for(let e=0;e<o.length-1;e+=1){let a=o[e];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))i=!0;else if(/^(c|ctrl|control)$/i.test(a))n=!0;else if(/^s(hift)?$/i.test(a))r=!0;else if(/^mod$/i.test(a))kS()||kz()?s=!0:n=!0;else throw Error(`Unrecognized modifier name: ${a}`)}return i&&(a=`Alt-${a}`),n&&(a=`Ctrl-${a}`),s&&(a=`Meta-${a}`),r&&(a=`Shift-${a}`),a})(e).split(/-(?!$)/),a=o.find(e=>!["Alt","Ctrl","Meta","Shift"].includes(e)),l=new KeyboardEvent("keydown",{key:"Space"===a?" ":a,altKey:o.includes("Alt"),ctrlKey:o.includes("Ctrl"),metaKey:o.includes("Meta"),shiftKey:o.includes("Shift"),bubbles:!0,cancelable:!0}),c=i.captureTransaction(()=>{n.someProp("handleKeyDown",e=>e(n,l))});return null==c||c.steps.forEach(e=>{let i=e.map(r.mapping);i&&s&&r.maybeStep(i)}),!0};function kW(e,i,n={}){let{from:r,to:s,empty:o}=e.selection,a=i?ks(i,e.schema):null,l=[];e.doc.nodesBetween(r,s,(e,i)=>{if(e.isText)return;let n=Math.max(r,i),o=Math.min(s,i+e.nodeSize);l.push({node:e,from:n,to:o})});let c=s-r,h=l.filter(e=>!a||a.name===e.node.type.name).filter(e=>ku(e.node.attrs,n,{strict:!1}));return o?!!h.length:h.reduce((e,i)=>e+i.to-i.from,0)>=c}var kH=(e,i={})=>({state:n,dispatch:r})=>{let s=ks(e,n.schema);return!!kW(n,s,i)&&((e,i)=>{let{$from:n,$to:r}=e.selection,s=n.blockRange(r),o=s&&bl(s);return null!=o&&(i&&i(e.tr.lift(s,o).scrollIntoView()),!0)})(n,r)},k$=()=>({state:e,dispatch:i})=>xr(e,i),kU=e=>({state:i,dispatch:n})=>{var r;return(r=ks(e,i.schema),function(e,i){let{$from:n,$to:s}=e.selection,o=n.blockRange(s,e=>e.childCount>0&&e.firstChild.type==r);return!!o&&(!i||(n.node(o.depth-1).type==r?function(e,i,n,r){let s=e.tr,o=r.end,a=r.$to.end(r.depth);o<a&&(s.step(new bs(o-1,a,o,a,new _p(_a.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new _k(s.doc.resolve(r.$from.pos),s.doc.resolve(a),r.depth));let l=bl(r);if(null==l)return!1;s.lift(r,l);let c=s.doc.resolve(s.mapping.map(o,-1)-1);return bf(s.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&s.join(c.pos),i(s.scrollIntoView()),!0}(e,i,r,o):function(e,i,n){let r=e.tr,s=n.parent;for(let e=n.end,i=n.endIndex-1,o=n.startIndex;i>o;i--)e-=s.child(i).nodeSize,r.delete(e-1,e+1);let o=r.doc.resolve(n.start),a=o.nodeAfter;if(r.mapping.map(n.end)!=n.start+o.nodeAfter.nodeSize)return!1;let l=0==n.startIndex,c=n.endIndex==s.childCount,h=o.node(-1),d=o.index(-1);if(!h.canReplace(d+ +!l,d+1,a.content.append(c?_a.empty:_a.from(s))))return!1;let u=o.pos,p=u+a.nodeSize;return r.step(new bs(u-!!l,p+ +!!c,u+1,p-1,new _p((l?_a.empty:_a.from(s.copy(_a.empty))).append(c?_a.empty:_a.from(s.copy(_a.empty))),+!l,+!c),+!l)),i(r.scrollIntoView()),!0}(e,i,o)))})(i,n)},kV=()=>({state:e,dispatch:i})=>xe(e,i);function kq(e,i){return i.nodes[e]?"node":i.marks[e]?"mark":null}function kY(e,i){let n="string"==typeof i?[i]:i;return Object.keys(e).reduce((i,r)=>(n.includes(r)||(i[r]=e[r]),i),{})}var kK=(e,i)=>({tr:n,state:r,dispatch:s})=>{let o=null,a=null,l=kq("string"==typeof e?e:e.name,r.schema);if(!l)return!1;"node"===l&&(o=ks(e,r.schema)),"mark"===l&&(a=kg(e,r.schema));let c=!1;return n.selection.ranges.forEach(e=>{r.doc.nodesBetween(e.$from.pos,e.$to.pos,(e,r)=>{o&&o===e.type&&(c=!0,s&&n.setNodeMarkup(r,void 0,kY(e.attrs,i))),a&&e.marks.length&&e.marks.forEach(o=>{a===o.type&&(c=!0,s&&n.addMark(r,r+e.nodeSize,a.create(kY(o.attrs,i))))})})}),c},kX=()=>({tr:e,dispatch:i})=>(i&&e.scrollIntoView(),!0),kJ=()=>({tr:e,dispatch:i})=>{if(i){let i=new bz(e.doc);e.setSelection(i)}return!0},kG=()=>({state:e,dispatch:i})=>b3(e,i),kZ=()=>({state:e,dispatch:i})=>b9(e,i),kQ=()=>({state:e,dispatch:i})=>((e,i)=>{let{$from:n,to:r}=e.selection,s,o=n.sharedDepth(r);return 0!=o&&(s=n.before(o),i&&i(e.tr.setSelection(bP.create(e.doc,s))),!0)})(e,i),k0=()=>({state:e,dispatch:i})=>xl(e,i),k1=()=>({state:e,dispatch:i})=>xa(e,i);function k2(e,i,n={},r={}){return kM(e,i,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var k5=(e,{errorOnInvalidContent:i,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:s,tr:o,dispatch:a,commands:l})=>{let{doc:c}=o;if("full"!==r.preserveWhitespace){let l=k2(e,s.schema,r,{errorOnInvalidContent:null!=i?i:s.options.enableContentCheck});return a&&o.replaceWith(0,c.content.size,l).setMeta("preventUpdate",!n),!0}return a&&o.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:c.content.size},e,{parseOptions:r,errorOnInvalidContent:null!=i?i:s.options.enableContentCheck})};function k3(e,i){let n=kg(i,e.schema),{from:r,to:s,empty:o}=e.selection,a=[];o?(e.storedMarks&&a.push(...e.storedMarks),a.push(...e.selection.$head.marks())):e.doc.nodesBetween(r,s,e=>{a.push(...e.marks)});let l=a.find(e=>e.type.name===n.name);return l?{...l.attrs}:{}}function k4(e,i){let n=new bM(e);return i.forEach(e=>{e.steps.forEach(e=>{n.step(e)})}),n}function k6(e){return i=>(function(e,i){for(let n=e.depth;n>0;n-=1){let r=e.node(n);if(i(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}})(i.$from,e)}function k8(e,i,n){return void 0===e.config[i]&&e.parent?k8(e.parent,i,n):"function"==typeof e.config[i]?e.config[i].bind({...n,parent:e.parent?k8(e.parent,i,n):null}):e.config[i]}function k9(e){return e.map(e=>{let i={name:e.name,options:e.options,storage:e.storage},n=k8(e,"addExtensions",i);return n?[e,...k9(n())]:e}).flat(10)}function k7(e,i){let n=_Z.fromSchema(i).serializeFragment(e),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(n),r.innerHTML}function Ce(e){return"function"==typeof e}function Ct(e,i,...n){return Ce(e)?i?e.bind(i)(...n):e(...n):e}function Ci(e){let i=e.filter(e=>"extension"===e.type);return{baseExtensions:i,nodeExtensions:e.filter(e=>"node"===e.type),markExtensions:e.filter(e=>"mark"===e.type)}}function Cn(e){let i=[],{nodeExtensions:n,markExtensions:r}=Ci(e),s=[...n,...r],o={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},a=n.filter(e=>"text"!==e.name).map(e=>e.name),l=r.map(e=>e.name),c=[...a,...l];return e.forEach(e=>{let n={name:e.name,options:e.options,storage:e.storage,extensions:s},r=k8(e,"addGlobalAttributes",n);r&&r().forEach(e=>{(Array.isArray(e.types)?e.types:"*"===e.types?c:"nodes"===e.types?a:"marks"===e.types?l:[]).forEach(n=>{Object.entries(e.attributes).forEach(([e,r])=>{i.push({type:n,name:e,attribute:{...o,...r}})})})})}),s.forEach(e=>{let n={name:e.name,options:e.options,storage:e.storage},r=k8(e,"addAttributes",n);r&&Object.entries(r()).forEach(([n,r])=>{let s={...o,...r};"function"==typeof(null==s?void 0:s.default)&&(s.default=s.default()),(null==s?void 0:s.isRequired)&&(null==s?void 0:s.default)===void 0&&delete s.default,i.push({type:e.name,name:n,attribute:s})})}),i}function Cr(e){let i=[],n=function(e){let i=[],n="",r=!1,s=!1,o=0,a=e.length;for(let l=0;l<a;l+=1){let a=e[l];if("'"===a&&!s){r=!r,n+=a;continue}if('"'===a&&!r){s=!s,n+=a;continue}if(!r&&!s){if("("===a){o+=1,n+=a;continue}if(")"===a&&o>0){o-=1,n+=a;continue}if(";"===a&&0===o){i.push(n),n="";continue}}n+=a}return n&&i.push(n),i}(e||""),r=n.length;for(let e=0;e<r;e+=1){let r=n[e],s=r.indexOf(":");if(-1===s)continue;let o=r.slice(0,s).trim(),a=r.slice(s+1).trim();o&&a&&i.push([o,a])}return i}function Cs(...e){return e.filter(e=>!!e).reduce((e,i)=>{let n={...e};return Object.entries(i).forEach(([e,i])=>{if(!n[e]){n[e]=i;return}if("class"===e){let r=i?String(i).split(" "):[],s=n[e]?n[e].split(" "):[],o=r.filter(e=>!s.includes(e));n[e]=[...s,...o].join(" ")}else if("style"===e){let r=new Map([...Cr(n[e]),...Cr(i)]);n[e]=Array.from(r.entries()).map(([e,i])=>`${e}: ${i}`).join("; ")}else n[e]=i}),n},{})}function Co(e,i){return i.filter(i=>i.type===e.type.name).filter(e=>e.attribute.rendered).map(i=>i.attribute.renderHTML?i.attribute.renderHTML(e.attrs)||{}:{[i.name]:e.attrs[i.name]}).reduce((e,i)=>Cs(e,i),{})}function Ca(e,i){return"style"in e?e:{...e,getAttrs:n=>{let r=e.getAttrs?e.getAttrs(n):e.attrs;if(!1===r)return!1;let s=i.reduce((e,i)=>{var r;let s=i.attribute.parseHTML?i.attribute.parseHTML(n):"string"!=typeof(r=n.getAttribute(i.name))?r:r.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(r):"true"===r||"false"!==r&&r;return null==s?e:{...e,[i.name]:s}},{});return{...r,...s}}}}function Cl(e){return Object.fromEntries(Object.entries(e).filter(([e,i])=>!("attrs"===e&&function(e={}){return 0===Object.keys(e).length&&e.constructor===Object}(i))&&null!=i))}function Cc(e){var i,n;let r={};return!(null==(i=null==e?void 0:e.attribute)?void 0:i.isRequired)&&"default"in((null==e?void 0:e.attribute)||{})&&(r.default=e.attribute.default),(null==(n=null==e?void 0:e.attribute)?void 0:n.validate)!==void 0&&(r.validate=e.attribute.validate),[e.name,r]}function Ch(e){return e.sort((e,i)=>{let n=k8(e,"priority")||100,r=k8(i,"priority")||100;return n>r?-1:+(n<r)})}function Cd(e){var i;let n=Ch(k9(e)),r=Array.from(new Set((i=n.map(e=>e.name)).filter((e,n)=>i.indexOf(e)!==n)));return r.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map(e=>`'${e}'`).join(", ")}]. This can lead to issues.`),n}function Cu(e,i,n){let{from:r,to:s}=i,{blockSeparator:o="\n\n",textSerializers:a={}}=n||{},l="";return e.nodesBetween(r,s,(e,n,c,h)=>{var d;e.isBlock&&n>r&&(l+=o);let u=null==a?void 0:a[e.type.name];if(u)return c&&(l+=u({node:e,pos:n,parent:c,index:h,range:i})),!1;e.isText&&(l+=null==(d=null==e?void 0:e.text)?void 0:d.slice(Math.max(r,n)-n,s-n))}),l}function Cp(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,e])=>e.spec.toText).map(([e,i])=>[e,i.spec.toText]))}function Cf(e,i){let n=kq("string"==typeof i?i:i.name,e.schema);return"node"===n?function(e,i){let n=ks(i,e.schema),{from:r,to:s}=e.selection,o=[];e.doc.nodesBetween(r,s,e=>{o.push(e)});let a=o.reverse().find(e=>e.type.name===n.name);return a?{...a.attrs}:{}}(e,i):"mark"===n?k3(e,i):{}}function Cm(e){let i,{mapping:n,steps:r}=e,s=[];return n.maps.forEach((e,i)=>{let o=[];if(e.ranges.length)e.forEach((e,i)=>{o.push({from:e,to:i})});else{let{from:e,to:n}=r[i];if(void 0===e||void 0===n)return;o.push({from:e,to:n})}o.forEach(({from:e,to:r})=>{let o=n.slice(i).map(e,-1),a=n.slice(i).map(r),l=n.invert().map(o,-1),c=n.invert().map(a);s.push({oldRange:{from:l,to:c},newRange:{from:o,to:a}})})}),1===(i=function(e,i=JSON.stringify){let n={};return e.filter(e=>{let r=i(e);return!Object.prototype.hasOwnProperty.call(n,r)&&(n[r]=!0)})}(s)).length?i:i.filter((e,n)=>!i.filter((e,i)=>i!==n).some(i=>e.oldRange.from>=i.oldRange.from&&e.oldRange.to<=i.oldRange.to&&e.newRange.from>=i.newRange.from&&e.newRange.to<=i.newRange.to))}function Cg(e,i,n){let r=[];return e===i?n.resolve(e).marks().forEach(i=>{let s=km(n.resolve(e),i.type);s&&r.push({mark:i,...s})}):n.nodesBetween(e,i,(e,i)=>{e&&(null==e?void 0:e.nodeSize)!==void 0&&r.push(...e.marks.map(n=>({from:i,to:i+e.nodeSize,mark:n})))}),r}function Cv(e,i){return i.nodes[e]||i.marks[e]||null}function Cy(e,i,n){return Object.fromEntries(Object.entries(n).filter(([n])=>{let r=e.find(e=>e.type===i&&e.name===n);return!!r&&r.attribute.keepOnSplit}))}function C_(e,i,n={}){let{empty:r,ranges:s}=e.selection,o=i?kg(i,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(e=>!o||o.name===e.type.name).find(e=>ku(e.attrs,n,{strict:!1}));let a=0,l=[];if(s.forEach(({$from:i,$to:n})=>{let r=i.pos,s=n.pos;e.doc.nodesBetween(r,s,(e,i)=>{if(o&&e.inlineContent&&!e.type.allowsMarkType(o))return!1;if(!e.isText&&!e.marks.length)return;let n=Math.max(r,i),c=Math.min(s,i+e.nodeSize);a+=c-n,l.push(...e.marks.map(e=>({mark:e,from:n,to:c})))})}),0===a)return!1;let c=l.filter(e=>!o||o.name===e.mark.type.name).filter(e=>ku(e.mark.attrs,n,{strict:!1})).reduce((e,i)=>e+i.to-i.from,0),h=l.filter(e=>!o||e.mark.type!==o&&e.mark.type.excludes(o)).reduce((e,i)=>e+i.to-i.from,0);return(c>0?c+h:c)>=a}function Cb(e,i){return Array.isArray(i)?i.some(i=>("string"==typeof i?i:i.name)===e.name):i}function Cx(e,i){let{nodeExtensions:n}=Ci(i),r=n.find(i=>i.name===e);if(!r)return!1;let s={name:r.name,options:r.options,storage:r.storage},o=Ct(k8(r,"group",s));return"string"==typeof o&&o.split(" ").includes("list")}function Cw(e,{checkChildren:i=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if("hardBreak"===e.type.name)return!0;if(e.isText)return!/\S/.test(null!=(r=e.text)?r:"")}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(0===e.content.childCount)return!0;if(i){let r=!0;return e.content.forEach(e=>{!1!==r&&(Cw(e,{ignoreWhitespace:n,checkChildren:i})||(r=!1))}),r}return!1}function CS(e){return e instanceof bP}var Ck=class e{constructor(e){this.position=e}static fromJSON(i){return new e(i.position)}toJSON(){return{position:this.position}}};function CC(e,i){let n=i.mapping.mapResult(e.position);return{position:new Ck(n.pos),mapResult:n}}function CT(e){return new Ck(e)}var CE=(e,i={})=>({tr:n,state:r,dispatch:s})=>{let{selection:o}=n,{empty:a,ranges:l}=o,c=kg(e,r.schema);if(s)if(a){let e=k3(r,c);n.addStoredMark(c.create({...e,...i}))}else l.forEach(e=>{let s=e.$from.pos,o=e.$to.pos;r.doc.nodesBetween(s,o,(e,r)=>{let a=Math.max(r,s),l=Math.min(r+e.nodeSize,o);e.marks.find(e=>e.type===c)?e.marks.forEach(e=>{c===e.type&&n.addMark(a,l,c.create({...e.attrs,...i}))}):n.addMark(a,l,c.create(i))})});return function(e,i,n){var r;let{selection:s}=i,o=null;if(k_(s)&&(o=s.$cursor),o){let i=null!=(r=e.storedMarks)?r:o.marks();return o.parent.type.allowsMarkType(n)&&(!!n.isInSet(i)||!i.some(e=>e.type.excludes(n)))}let{ranges:a}=s;return a.some(({$from:i,$to:r})=>{let s=0===i.depth&&e.doc.inlineContent&&e.doc.type.allowsMarkType(n);return e.doc.nodesBetween(i.pos,r.pos,(e,i,r)=>{if(s)return!1;if(e.isInline){let i=!r||r.type.allowsMarkType(n),o=!!n.isInSet(e.marks)||!e.marks.some(e=>e.type.excludes(n));s=i&&o}return!s}),s})}(r,n,c)},CN=(e,i)=>({tr:n})=>(n.setMeta(e,i),!0),CM=(e,i={})=>({state:n,dispatch:r,chain:s})=>{let o,a=ks(e,n.schema);return(n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),a.isTextblock)?s().command(({commands:e})=>!!xc(a,{...o,...i})(n)||e.clearNodes()).command(({state:e})=>xc(a,{...o,...i})(e,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},CO=e=>({tr:i,dispatch:n})=>{if(n){let{doc:n}=i,r=kb(e,0,n.content.size),s=bP.create(n,r);i.setSelection(s)}return!0},CA=(e,i)=>({tr:n,state:r,dispatch:s})=>{let o,a,{selection:l}=r;return"number"==typeof i?(o=i,a=i):i&&"from"in i&&"to"in i?(o=i.from,a=i.to):(o=l.from,a=l.to),s&&n.doc.nodesBetween(o,a,(i,r)=>{i.isText||n.setNodeMarkup(r,void 0,{...i.attrs,dir:e})}),!0},CR=e=>({tr:i,dispatch:n})=>{if(n){let{doc:n}=i,{from:r,to:s}="number"==typeof e?{from:e,to:e}:e,o=bj.atStart(n).from,a=bj.atEnd(n).to,l=kb(r,o,a),c=kb(s,o,a),h=bj.create(n,l,c);i.setSelection(h)}return!0},CD=e=>({state:i,dispatch:n})=>{var r;return(r=ks(e,i.schema),function(e,i){let{$from:n,$to:s}=e.selection,o=n.blockRange(s,e=>e.childCount>0&&e.firstChild.type==r);if(!o)return!1;let a=o.startIndex;if(0==a)return!1;let l=o.parent,c=l.child(a-1);if(c.type!=r)return!1;if(i){let n=c.lastChild&&c.lastChild.type==l.type,s=_a.from(n?r.create():null),a=new _p(_a.from(r.create(null,_a.from(l.type.create(null,s)))),n?3:1,0),h=o.start,d=o.end;i(e.tr.step(new bs(h-(n?3:1),d,h,d,a,1,!0)).scrollIntoView())}return!0})(i,n)};function CL(e,i){let n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){let r=n.filter(e=>null==i?void 0:i.includes(e.type.name));e.tr.ensureMarks(r)}}var Cj=({keepMarks:e=!0}={})=>({tr:i,state:n,dispatch:r,editor:s})=>{let{selection:o,doc:a}=i,{$from:l,$to:c}=o,h=Cy(s.extensionManager.attributes,l.node().type.name,l.node().attrs);if(o instanceof bP&&o.node.isBlock)return!!l.parentOffset&&!!bp(a,l.pos)&&(r&&(e&&CL(n,s.extensionManager.splittableMarks),i.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;let d=c.parentOffset===c.parent.content.size,u=0===l.depth?void 0:function(e){for(let i=0;i<e.edgeCount;i+=1){let{type:n}=e.edge(i);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}(l.node(-1).contentMatchAt(l.indexAfter(-1))),p=d&&u?[{type:u,attrs:h}]:void 0,f=bp(i.doc,i.mapping.map(l.pos),1,p);if(!p&&!f&&bp(i.doc,i.mapping.map(l.pos),1,u?[{type:u}]:void 0)&&(f=!0,p=u?[{type:u,attrs:h}]:void 0),r){if(f&&(o instanceof bj&&i.deleteSelection(),i.split(i.mapping.map(l.pos),1,p),u&&!d&&!l.parentOffset&&l.parent.type!==u)){let e=i.mapping.map(l.before()),n=i.doc.resolve(e);l.node(-1).canReplaceWith(n.index(),n.index()+1,u)&&i.setNodeMarkup(i.mapping.map(l.before()),u)}e&&CL(n,s.extensionManager.splittableMarks),i.scrollIntoView()}return f},CI=(e,i={})=>({tr:n,state:r,dispatch:s,editor:o})=>{var a;let l=ks(e,r.schema),{$from:c,$to:h}=r.selection,d=r.selection.node;if(d&&d.isBlock||c.depth<2||!c.sameParent(h))return!1;let u=c.node(-1);if(u.type!==l)return!1;let p=o.extensionManager.attributes;if(0===c.parent.content.size&&c.node(-1).childCount===c.indexAfter(-1)){if(2===c.depth||c.node(-3).type!==l||c.index(-2)!==c.node(-2).childCount-1)return!1;if(s){let e=_a.empty,r=c.index(-1)?1:c.index(-2)?2:3;for(let i=c.depth-r;i>=c.depth-3;i-=1)e=_a.from(c.node(i).copy(e));let s=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,o={...Cy(p,c.node().type.name,c.node().attrs),...i},h=(null==(a=l.contentMatch.defaultType)?void 0:a.createAndFill(o))||void 0;e=e.append(_a.from(l.createAndFill(null,h)||void 0));let d=c.before(c.depth-(r-1));n.replace(d,c.after(-s),new _p(e,4-r,0));let u=-1;n.doc.nodesBetween(d,n.doc.content.size,(e,i)=>{if(u>-1)return!1;e.isTextblock&&0===e.content.size&&(u=i+1)}),u>-1&&n.setSelection(bj.near(n.doc.resolve(u))),n.scrollIntoView()}return!0}let f=h.pos===c.end()?u.contentMatchAt(0).defaultType:null,m={...Cy(p,u.type.name,u.attrs),...i},g={...Cy(p,c.node().type.name,c.node().attrs),...i};n.delete(c.pos,h.pos);let v=f?[{type:l,attrs:m},{type:f,attrs:g}]:[{type:l,attrs:m}];if(!bp(n.doc,c.pos,2))return!1;if(s){let{selection:e,storedMarks:i}=r,{splittableMarks:a}=o.extensionManager,l=i||e.$to.parentOffset&&e.$from.marks();if(n.split(c.pos,2,v).scrollIntoView(),!l||!s)return!0;let h=l.filter(e=>a.includes(e.type.name));n.ensureMarks(h)}return!0},CP=(e,i)=>{let n=k6(e=>e.type===i)(e.selection);if(!n)return!0;let r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(void 0===r)return!0;let s=e.doc.nodeAt(r);return!(n.node.type===(null==s?void 0:s.type)&&bf(e.doc,n.pos))||(e.join(n.pos),!0)},CB=(e,i)=>{let n=k6(e=>e.type===i)(e.selection);if(!n)return!0;let r=e.doc.resolve(n.start).after(n.depth);if(void 0===r)return!0;let s=e.doc.nodeAt(r);return!(n.node.type===(null==s?void 0:s.type)&&bf(e.doc,r))||(e.join(r),!0)},Cz=(e,i,n,r={})=>({editor:s,tr:o,state:a,dispatch:l,chain:c,commands:h,can:d})=>{let{extensions:u,splittableMarks:p}=s.extensionManager,f=ks(e,a.schema),m=ks(i,a.schema),{selection:g,storedMarks:v}=a,{$from:y,$to:_}=g,b=y.blockRange(_),w=v||g.$to.parentOffset&&g.$from.marks();if(!b)return!1;let S=k6(e=>Cx(e.type.name,u))(g),k=0===g.from&&g.to===a.doc.content.size,C=a.doc.content.content,T=1===C.length?C[0]:null,E=k&&T&&Cx(T.type.name,u)?{node:T,pos:0,depth:0}:null,N=null!=S?S:E,M=!!S&&b.depth>=1&&b.depth-S.depth<=1,O=!!E;if((M||O)&&N){if(N.node.type===f)return k&&O?c().command(({tr:e,dispatch:i})=>{let n=function(e){let i=e.doc,n=i.firstChild;if(!n)return null;let r=i.resolve(1),s=i.resolve(n.nodeSize-1);return bj.between(r,s)}(e);return!!n&&(e.setSelection(n),i&&i(e),!0)}).liftListItem(m).run():h.liftListItem(m);if(Cx(N.node.type.name,u)&&f.validContent(N.node.content))return c().command(()=>(o.setNodeMarkup(N.pos,f),!0)).command(()=>CP(o,f)).command(()=>CB(o,f)).run()}return n&&w&&l?c().command(()=>{let e=d().wrapInList(f,r),i=w.filter(e=>p.includes(e.type.name));return o.ensureMarks(i),!!e||h.clearNodes()}).wrapInList(f,r).command(()=>CP(o,f)).command(()=>CB(o,f)).run():c().command(()=>!!d().wrapInList(f,r)||h.clearNodes()).wrapInList(f,r).command(()=>CP(o,f)).command(()=>CB(o,f)).run()},CF=(e,i={},n={})=>({state:r,commands:s})=>{let{extendEmptyMarkRange:o=!1}=n,a=kg(e,r.schema);return C_(r,a,i)?s.unsetMark(a,{extendEmptyMarkRange:o}):s.setMark(a,i)},CW=(e,i,n={})=>({state:r,commands:s})=>{let o,a=ks(e,r.schema),l=ks(i,r.schema),c=kW(r,a,n);return(r.selection.$anchor.sameParent(r.selection.$head)&&(o=r.selection.$anchor.parent.attrs),c)?s.setNode(l,o):s.setNode(a,{...o,...n})},CH=(e,i={})=>({state:n,commands:r})=>{let s=ks(e,n.schema);return kW(n,s,i)?r.lift(s):r.wrapIn(s,i)},C$=()=>({state:e,dispatch:i})=>{let n=e.plugins;for(let r=0;r<n.length;r+=1){let s,o=n[r];if(o.spec.isInputRules&&(s=o.getState(e))){if(i){let i=e.tr,n=s.transform;for(let e=n.steps.length-1;e>=0;e-=1)i.step(n.steps[e].invert(n.docs[e]));if(s.text){let n=i.doc.resolve(s.from).marks();i.replaceWith(s.from,s.to,e.schema.text(s.text,n))}else i.delete(s.from,s.to)}return!0}}return!1},CU=()=>({tr:e,dispatch:i})=>{let{selection:n}=e,{empty:r,ranges:s}=n;return!!r||(i&&s.forEach(i=>{e.removeMark(i.$from.pos,i.$to.pos)}),!0)},CV=(e,i={})=>({tr:n,state:r,dispatch:s})=>{var o;let{extendEmptyMarkRange:a=!1}=i,{selection:l}=n,c=kg(e,r.schema),{$from:h,empty:d,ranges:u}=l;if(!s)return!0;if(d&&a){let{from:e,to:i}=l,r=null==(o=h.marks().find(e=>e.type===c))?void 0:o.attrs,s=km(h,c,r);s&&(e=s.from,i=s.to),n.removeMark(e,i,c)}else u.forEach(e=>{n.removeMark(e.$from.pos,e.$to.pos,c)});return n.removeStoredMark(c),!0},Cq=e=>({tr:i,state:n,dispatch:r})=>{let s,o,{selection:a}=n;return"number"==typeof e?(s=e,o=e):e&&"from"in e&&"to"in e?(s=e.from,o=e.to):(s=a.from,o=a.to),r&&i.doc.nodesBetween(s,o,(e,n)=>{if(e.isText)return;let r={...e.attrs};delete r.dir,i.setNodeMarkup(n,void 0,r)}),!0},CY=(e,i={})=>({tr:n,state:r,dispatch:s})=>{let o=null,a=null,l=kq("string"==typeof e?e:e.name,r.schema);if(!l)return!1;"node"===l&&(o=ks(e,r.schema)),"mark"===l&&(a=kg(e,r.schema));let c=!1;return n.selection.ranges.forEach(e=>{let l,h,d,u,p=e.$from.pos,f=e.$to.pos;n.selection.empty?r.doc.nodesBetween(p,f,(e,i)=>{o&&o===e.type&&(c=!0,d=Math.max(i,p),u=Math.min(i+e.nodeSize,f),l=i,h=e)}):r.doc.nodesBetween(p,f,(e,r)=>{r<p&&o&&o===e.type&&(c=!0,d=Math.max(r,p),u=Math.min(r+e.nodeSize,f),l=r,h=e),r>=p&&r<=f&&(o&&o===e.type&&(c=!0,s&&n.setNodeMarkup(r,void 0,{...e.attrs,...i})),a&&e.marks.length&&e.marks.forEach(o=>{if(a===o.type&&(c=!0,s)){let s=Math.max(r,p),l=Math.min(r+e.nodeSize,f);n.addMark(s,l,a.create({...o.attrs,...i}))}}))}),h&&(void 0!==l&&s&&n.setNodeMarkup(l,void 0,{...h.attrs,...i}),a&&h.marks.length&&h.marks.forEach(e=>{a===e.type&&s&&n.addMark(d,u,a.create({...e.attrs,...i}))}))}),c},CK=(e,i={})=>({state:n,dispatch:r})=>(function(e,i=null){return function(n,r){let{$from:s,$to:o}=n.selection,a=s.blockRange(o),l=a&&bc(a,e,i);return!!l&&(r&&r(n.tr.wrap(a,l).scrollIntoView()),!0)}})(ks(e,n.schema),i)(n,r),CX=(e,i={})=>({state:n,dispatch:r})=>(function(e,i=null){return function(n,r){let{$from:s,$to:o}=n.selection,a=s.blockRange(o);if(!a)return!1;let l=r?n.tr:null;return!!function(e,i,n,r=null){let s=!1,o=i,a=i.$from.doc;if(i.depth>=2&&i.$from.node(i.depth-1).type.compatibleContent(n)&&0==i.startIndex){if(0==i.$from.index(i.depth-1))return!1;let e=a.resolve(i.start-2);o=new _k(e,e,i.depth),i.endIndex<i.parent.childCount&&(i=new _k(i.$from,a.resolve(i.$to.end(i.depth)),i.depth)),s=!0}let l=bc(o,n,r,i);return!!l&&(e&&function(e,i,n,r,s){let o=_a.empty;for(let e=n.length-1;e>=0;e--)o=_a.from(n[e].type.create(n[e].attrs,o));e.step(new bs(i.start-2*!!r,i.end,i.start,i.end,new _p(o,0,0),n.length,!0));let a=0;for(let e=0;e<n.length;e++)n[e].type==s&&(a=e+1);let l=n.length-a,c=i.start+n.length-2*!!r,h=i.parent;for(let n=i.startIndex,r=i.endIndex,s=!0;n<r;n++,s=!1)!s&&bp(e.doc,c,l)&&(e.split(c,l),c+=2*l),c+=h.child(n).nodeSize}(e,i,l,s,n),!0)}(l,a,e,i)&&(r&&r(l.scrollIntoView()),!0)}})(ks(e,n.schema),i)(n,r),CJ=class{constructor(){this.callbacks={}}on(e,i){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(i),this}emit(e,...i){let n=this.callbacks[e];return n&&n.forEach(e=>e.apply(this,i)),this}off(e,i){let n=this.callbacks[e];return n&&(i?this.callbacks[e]=n.filter(e=>e!==i):delete this.callbacks[e]),this}once(e,i){let n=(...r)=>{this.off(e,n),i.apply(this,r)};return this.on(e,n)}removeAllListeners(){this.callbacks={}}},CG=class{constructor(e){var i;this.find=e.find,this.handler=e.handler,this.undoable=null==(i=e.undoable)||i}};function CZ(e){var i;let{editor:n,from:r,to:s,text:o,rules:a,plugin:l}=e,{view:c}=n;if(c.composing)return!1;let h=c.state.doc.resolve(r);if(h.parent.type.spec.code||(null==(i=h.nodeBefore||h.nodeAfter)?void 0:i.marks.find(e=>e.type.spec.code)))return!1;let d=!1,u=((e,i=500)=>{let n="",r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-i),r,(e,i,s,o)=>{var a,l;let c=(null==(l=(a=e.type.spec).toText)?void 0:l.call(a,{node:e,pos:i,parent:s,index:o}))||e.textContent||"%leaf%";n+=e.isAtom&&!e.isText?c:c.slice(0,Math.max(0,r-i))}),n})(h)+o;return a.forEach(e=>{if(d)return;let i=((e,i)=>{if(kd(i))return i.exec(e);let n=i(e);if(!n)return null;let r=[n.text];return r.index=n.index,r.input=e,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r})(u,e.find);if(!i)return;let a=c.state.tr,h=S4({state:c.state,transaction:a}),p={from:r-(i[0].length-o.length),to:s},{commands:f,chain:m,can:g}=new S6({editor:n,state:h});null!==e.handler({state:h,range:p,match:i,commands:f,chain:m,can:g})&&a.steps.length&&(e.undoable&&a.setMeta(l,{transform:a,from:r,to:s,text:o}),c.dispatch(a),d=!0)}),d}function CQ(e){return"Object"===Object.prototype.toString.call(e).slice(8,-1)&&e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype}var C0=class{constructor(e={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...e},this.name=this.config.name}get options(){return{...Ct(k8(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Ct(k8(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(e={}){let i=this.extend({...this.config,addOptions:()=>(function e(i,n){let r={...i};return CQ(i)&&CQ(n)&&Object.keys(n).forEach(s=>{CQ(n[s])&&CQ(i[s])?r[s]=e(i[s],n[s]):r[s]=n[s]}),r})(this.options,e)});return i.name=this.name,i.parent=this.parent,i}extend(e={}){let i=new this.constructor({...this.config,...e});return i.parent=this,this.child=i,i.name="name"in e?e.name:i.parent.name,i}},C1=class e extends C0{constructor(){super(...arguments),this.type="mark"}static create(i={}){return new e("function"==typeof i?i():i)}static handleExit({editor:e,mark:i}){let{tr:n}=e.state,r=e.state.selection.$from;if(r.pos===r.end()){let s=r.marks();if(!s.find(e=>(null==e?void 0:e.type.name)===i.name))return!1;let o=s.find(e=>(null==e?void 0:e.type.name)===i.name);return o&&n.removeStoredMark(o),n.insertText(" ",r.pos),e.view.dispatch(n),!0}return!1}configure(e){return super.configure(e)}extend(e){let i="function"==typeof e?e():e;return super.extend(i)}},C2=class{constructor(e){this.find=e.find,this.handler=e.handler}},C5=null,C3=class{constructor(e,i){this.splittableMarks=[],this.editor=i,this.baseExtensions=e,this.extensions=Cd(e),this.schema=function(e,i){var n;let r=Cn(e),{nodeExtensions:s,markExtensions:o}=Ci(e),a=null==(n=s.find(e=>k8(e,"topNode")))?void 0:n.name;return new _W({topNode:a,nodes:Object.fromEntries(s.map(n=>{let s=r.filter(e=>e.type===n.name),o={name:n.name,options:n.options,storage:n.storage,editor:i},a=Cl({...e.reduce((e,i)=>{let r=k8(i,"extendNodeSchema",o);return{...e,...r?r(n):{}}},{}),content:Ct(k8(n,"content",o)),marks:Ct(k8(n,"marks",o)),group:Ct(k8(n,"group",o)),inline:Ct(k8(n,"inline",o)),atom:Ct(k8(n,"atom",o)),selectable:Ct(k8(n,"selectable",o)),draggable:Ct(k8(n,"draggable",o)),code:Ct(k8(n,"code",o)),whitespace:Ct(k8(n,"whitespace",o)),linebreakReplacement:Ct(k8(n,"linebreakReplacement",o)),defining:Ct(k8(n,"defining",o)),isolating:Ct(k8(n,"isolating",o)),attrs:Object.fromEntries(s.map(Cc))}),l=Ct(k8(n,"parseHTML",o));l&&(a.parseDOM=l.map(e=>Ca(e,s)));let c=k8(n,"renderHTML",o);c&&(a.toDOM=e=>c({node:e,HTMLAttributes:Co(e,s)}));let h=k8(n,"renderText",o);return h&&(a.toText=h),[n.name,a]})),marks:Object.fromEntries(o.map(n=>{let s=r.filter(e=>e.type===n.name),o={name:n.name,options:n.options,storage:n.storage,editor:i},a=Cl({...e.reduce((e,i)=>{let r=k8(i,"extendMarkSchema",o);return{...e,...r?r(n):{}}},{}),inclusive:Ct(k8(n,"inclusive",o)),excludes:Ct(k8(n,"excludes",o)),group:Ct(k8(n,"group",o)),spanning:Ct(k8(n,"spanning",o)),code:Ct(k8(n,"code",o)),attrs:Object.fromEntries(s.map(Cc))}),l=Ct(k8(n,"parseHTML",o));l&&(a.parseDOM=l.map(e=>Ca(e,s)));let c=k8(n,"renderHTML",o);return c&&(a.toDOM=e=>c({mark:e,HTMLAttributes:Co(e,s)})),[n.name,a]}))})}(this.extensions,i),this.setupExtensions()}get commands(){return this.extensions.reduce((e,i)=>{let n={name:i.name,options:i.options,storage:this.editor.extensionStorage[i.name],editor:this.editor,type:Cv(i.name,this.schema)},r=k8(i,"addCommands",n);return r?{...e,...r()}:e},{})}get plugins(){let{editor:e}=this;return Ch([...this.extensions].reverse()).flatMap(i=>{let n={name:i.name,options:i.options,storage:this.editor.extensionStorage[i.name],editor:e,type:Cv(i.name,this.schema)},r=[],s=k8(i,"addKeyboardShortcuts",n),o={};if("mark"===i.type&&k8(i,"exitable",n)&&(o.ArrowRight=()=>C1.handleExit({editor:e,mark:i})),s){let i=Object.fromEntries(Object.entries(s()).map(([i,n])=>[i,()=>n({editor:e})]));o={...o,...i}}let a=new bX({props:{handleKeyDown:S2(o)}});r.push(a);let l=k8(i,"addInputRules",n);if(Cb(i,e.options.enableInputRules)&&l){let i=l();if(i&&i.length){let n=function(e){let{editor:i,rules:n}=e,r=new bX({state:{init:()=>null,apply(e,s,o){let a=e.getMeta(r);if(a)return a;let l=e.getMeta("applyInputRules");return l&&setTimeout(()=>{let{text:e}=l;"string"==typeof e||(e=k7(_a.from(e),o.schema));let{from:s}=l,a=s+e.length;CZ({editor:i,from:s,to:a,text:e,rules:n,plugin:r})}),e.selectionSet||e.docChanged?null:s}},props:{handleTextInput:(e,s,o,a)=>CZ({editor:i,from:s,to:o,text:a,rules:n,plugin:r}),handleDOMEvents:{compositionend:e=>(setTimeout(()=>{let{$cursor:s}=e.state.selection;s&&CZ({editor:i,from:s.pos,to:s.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(e,s){if("Enter"!==s.key)return!1;let{$cursor:o}=e.state.selection;return!!o&&CZ({editor:i,from:o.pos,to:o.pos,text:"\n",rules:n,plugin:r})}},isInputRules:!0});return r}({editor:e,rules:i}),s=Array.isArray(n)?n:[n];r.push(...s)}}let c=k8(i,"addPasteRules",n);if(Cb(i,e.options.enablePasteRules)&&c){let i=c();if(i&&i.length){let n=function(e){let i,{editor:n,rules:r}=e,s=null,o=!1,a=!1,l="u">typeof ClipboardEvent?new ClipboardEvent("paste"):null;try{i="u">typeof DragEvent?new DragEvent("drop"):null}catch{i=null}let c=({state:e,from:r,to:s,rule:o,pasteEvt:a})=>{let c=e.tr;if(function(e){let{editor:i,state:n,from:r,to:s,rule:o,pasteEvent:a,dropEvent:l}=e,{commands:c,chain:h,can:d}=new S6({editor:i,state:n}),u=[];return n.doc.nodesBetween(r,s,(e,i)=>{var p,f,m,g,v;if((null==(f=null==(p=e.type)?void 0:p.spec)?void 0:f.code)||!(e.isText||e.isTextblock||e.isInline))return;let y=null!=(v=null!=(g=null==(m=e.content)?void 0:m.size)?g:e.nodeSize)?v:0,_=Math.max(r,i),b=Math.min(s,i+y);_>=b||((e,i,n)=>{if(kd(i))return[...e.matchAll(i)];let r=i(e,n);return r?r.map(i=>{let n=[i.text];return n.index=i.index,n.input=e,n.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),n.push(i.replaceWith)),n}):[]})(e.isText?e.text||"":e.textBetween(_-i,b-i,void 0,""),o.find,a).forEach(e=>{if(void 0===e.index)return;let i=_+e.index+1,r=i+e[0].length,s={from:n.tr.mapping.map(i),to:n.tr.mapping.map(r)},p=o.handler({state:n,range:s,match:e,commands:c,chain:h,can:d,pasteEvent:a,dropEvent:l});u.push(p)})}),u.every(e=>null!==e)}({editor:n,state:S4({state:e,transaction:c}),from:Math.max(r-1,0),to:s.b-1,rule:o,pasteEvent:a,dropEvent:i})&&c.steps.length){try{i="u">typeof DragEvent?new DragEvent("drop"):null}catch{i=null}return l="u">typeof ClipboardEvent?new ClipboardEvent("paste"):null,c}};return r.map(e=>new bX({view(e){let i=i=>{var r;(s=(null==(r=e.dom.parentElement)?void 0:r.contains(i.target))?e.dom.parentElement:null)&&(C5=n)},r=()=>{C5&&(C5=null)};return window.addEventListener("dragstart",i),window.addEventListener("dragend",r),{destroy(){window.removeEventListener("dragstart",i),window.removeEventListener("dragend",r)}}},props:{handleDOMEvents:{drop:(e,n)=>{if(a=s===e.dom.parentElement,i=n,!a){let e=C5;(null==e?void 0:e.isEditable)&&setTimeout(()=>{let i=e.state.selection;i&&e.commands.deleteRange({from:i.from,to:i.to})},10)}return!1},paste:(e,i)=>{var n;let r=null==(n=i.clipboardData)?void 0:n.getData("text/html");return l=i,o=!!(null==r?void 0:r.includes("data-pm-slice")),!1}}},appendTransaction:(i,n,r)=>{let s=i[0],h="paste"===s.getMeta("uiEvent")&&!o,d="drop"===s.getMeta("uiEvent")&&!a,u=s.getMeta("applyPasteRules"),p=!!u;if(!h&&!d&&!p)return;if(p){var f,m;let i,{text:n}=u;"string"==typeof n||(n=k7(_a.from(n),r.schema));let{from:s}=u,o=s+n.length;return c({rule:e,state:r,from:s,to:{b:o},pasteEvt:(f=n,null==(m=(i=new ClipboardEvent("paste",{clipboardData:new DataTransfer})).clipboardData)||m.setData("text/html",f),i)})}let g=n.doc.content.findDiffStart(r.doc.content),v=n.doc.content.findDiffEnd(r.doc.content);if("number"==typeof g&&v&&g!==v.b)return c({rule:e,state:r,from:g,to:v,pasteEvt:l})}}))}({editor:e,rules:i});r.push(...n)}}let h=k8(i,"addProseMirrorPlugins",n);if(h){let e=h();r.push(...e)}return r})}get attributes(){return Cn(this.extensions)}get nodeViews(){let{editor:e}=this,{nodeExtensions:i}=Ci(this.extensions);return Object.fromEntries(i.filter(e=>!!k8(e,"addNodeView")).map(i=>{let n=this.attributes.filter(e=>e.type===i.name),r={name:i.name,options:i.options,storage:this.editor.extensionStorage[i.name],editor:e,type:ks(i.name,this.schema)},s=k8(i,"addNodeView",r);if(!s)return[];let o=s();return o?[i.name,(r,s,a,l,c)=>{let h=Co(r,n);return o({node:r,view:s,getPos:a,decorations:l,innerDecorations:c,editor:e,extension:i,HTMLAttributes:h})}]:[]}))}dispatchTransaction(e){let{editor:i}=this;return Ch([...this.extensions].reverse()).reduceRight((e,n)=>{let r={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:i,type:Cv(n.name,this.schema)},s=k8(n,"dispatchTransaction",r);return s?i=>{s.call(r,{transaction:i,next:e})}:e},e)}transformPastedHTML(e){let{editor:i}=this;return Ch([...this.extensions]).reduce((e,n)=>{let r={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:i,type:Cv(n.name,this.schema)},s=k8(n,"transformPastedHTML",r);return s?(i,n)=>{let o=e(i,n);return s.call(r,o)}:e},e||(e=>e))}get markViews(){let{editor:e}=this,{markExtensions:i}=Ci(this.extensions);return Object.fromEntries(i.filter(e=>!!k8(e,"addMarkView")).map(i=>{let n=this.attributes.filter(e=>e.type===i.name),r={name:i.name,options:i.options,storage:this.editor.extensionStorage[i.name],editor:e,type:kg(i.name,this.schema)},s=k8(i,"addMarkView",r);return s?[i.name,(r,o,a)=>{let l=Co(r,n);return s()({mark:r,view:o,inline:a,editor:e,extension:i,HTMLAttributes:l,updateAttributes:i=>{!function(e,i,n={}){let{state:r}=i,{doc:s,tr:o}=r;s.descendants((i,r)=>{let s=o.mapping.map(r),a=o.mapping.map(r)+i.nodeSize,l=null;if(i.marks.forEach(i=>{if(i!==e)return!1;l=i}),!l)return;let c=!1;if(Object.keys(n).forEach(e=>{n[e]!==l.attrs[e]&&(c=!0)}),c){let i=e.type.create({...e.attrs,...n});o.removeMark(s,a,e.type),o.addMark(s,a,i)}}),o.docChanged&&i.view.dispatch(o)}(r,e,i)}})}]:[]}))}setupExtensions(){let e=this.extensions;this.editor.extensionStorage=Object.fromEntries(e.map(e=>[e.name,e.storage])),e.forEach(e=>{var i;let n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Cv(e.name,this.schema)};"mark"===e.type&&(null==(i=Ct(k8(e,"keepOnSplit",n)))||i)&&this.splittableMarks.push(e.name);let r=k8(e,"onBeforeCreate",n),s=k8(e,"onCreate",n),o=k8(e,"onUpdate",n),a=k8(e,"onSelectionUpdate",n),l=k8(e,"onTransaction",n),c=k8(e,"onFocus",n),h=k8(e,"onBlur",n),d=k8(e,"onDestroy",n);r&&this.editor.on("beforeCreate",r),s&&this.editor.on("create",s),o&&this.editor.on("update",o),a&&this.editor.on("selectionUpdate",a),l&&this.editor.on("transaction",l),c&&this.editor.on("focus",c),h&&this.editor.on("blur",h),d&&this.editor.on("destroy",d)})}};C3.resolve=Cd,C3.sort=Ch,C3.flatten=k9,S3({},{ClipboardTextSerializer:()=>C6,Commands:()=>C8,Delete:()=>C9,Drop:()=>C7,Editable:()=>Te,FocusEvents:()=>Ti,Keymap:()=>Tn,Paste:()=>Tr,Tabindex:()=>Ts,TextDirection:()=>To,focusEventsPluginKey:()=>Tt});var C4=class e extends C0{constructor(){super(...arguments),this.type="extension"}static create(i={}){return new e("function"==typeof i?i():i)}configure(e){return super.configure(e)}extend(e){let i="function"==typeof e?e():e;return super.extend(i)}},C6=C4.create({name:"clipboardTextSerializer",addOptions:()=>({blockSeparator:void 0}),addProseMirrorPlugins(){return[new bX({key:new bZ("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{let{editor:e}=this,{state:i,schema:n}=e,{doc:r,selection:s}=i,{ranges:o}=s,a=Math.min(...o.map(e=>e.$from.pos)),l=Math.max(...o.map(e=>e.$to.pos)),c=Cp(n);return Cu(r,{from:a,to:l},{...void 0!==this.options.blockSeparator?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),C8=C4.create({name:"commands",addCommands:()=>({...S8})}),C9=C4.create({name:"delete",onUpdate({transaction:e,appendedTransactions:i}){var n,r,s;let o=()=>{var n,r,s,o;if(null!=(o=null==(s=null==(r=null==(n=this.editor.options.coreExtensionOptions)?void 0:n.delete)?void 0:r.filterTransaction)?void 0:s.call(r,e))?o:e.getMeta("y-sync$"))return;let a=k4(e.before,[e,...i]);Cm(a).forEach(i=>{a.mapping.mapResult(i.oldRange.from).deletedAfter&&a.mapping.mapResult(i.oldRange.to).deletedBefore&&a.before.nodesBetween(i.oldRange.from,i.oldRange.to,(n,r)=>{let s=r+n.nodeSize-2,o=i.oldRange.from<=r&&s<=i.oldRange.to;this.editor.emit("delete",{type:"node",node:n,from:r,to:s,newFrom:a.mapping.map(r),newTo:a.mapping.map(s),deletedRange:i.oldRange,newRange:i.newRange,partial:!o,editor:this.editor,transaction:e,combinedTransform:a})})});let l=a.mapping;a.steps.forEach((i,n)=>{var r,s;if(i instanceof bt){let o=l.slice(n).map(i.from,-1),c=l.slice(n).map(i.to),h=l.invert().map(o,-1),d=l.invert().map(c),u=o>0&&(null==(r=a.doc.nodeAt(o-1))?void 0:r.marks.some(e=>e.eq(i.mark))),p=null==(s=a.doc.nodeAt(c))?void 0:s.marks.some(e=>e.eq(i.mark));this.editor.emit("delete",{type:"mark",mark:i.mark,from:i.from,to:i.to,deletedRange:{from:h,to:d},newRange:{from:o,to:c},partial:!!(p||u),editor:this.editor,transaction:e,combinedTransform:a})}})};null==(s=null==(r=null==(n=this.editor.options.coreExtensionOptions)?void 0:n.delete)?void 0:r.async)||s?setTimeout(o,0):o()}}),C7=C4.create({name:"drop",addProseMirrorPlugins(){return[new bX({key:new bZ("tiptapDrop"),props:{handleDrop:(e,i,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:i,slice:n,moved:r})}}})]}}),Te=C4.create({name:"editable",addProseMirrorPlugins(){return[new bX({key:new bZ("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Tt=new bZ("focusEvents"),Ti=C4.create({name:"focusEvents",addProseMirrorPlugins(){let{editor:e}=this;return[new bX({key:Tt,props:{handleDOMEvents:{focus:(i,n)=>{e.isFocused=!0;let r=e.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return i.dispatch(r),!1},blur:(i,n)=>{e.isFocused=!1;let r=e.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return i.dispatch(r),!1}}}})]}}),Tn=C4.create({name:"keymap",addKeyboardShortcuts(){let e=()=>this.editor.commands.first(({commands:e})=>[()=>e.undoInputRule(),()=>e.command(({tr:i})=>{let{selection:n,doc:r}=i,{empty:s,$anchor:o}=n,{pos:a,parent:l}=o,c=o.parent.isTextblock&&a>0?i.doc.resolve(a-1):o,h=c.parent.type.spec.isolating,d=o.pos-o.parentOffset,u=h&&1===c.parent.childCount?d===o.pos:bA.atStart(r).from===a;return!!s&&!!l.type.isTextblock&&!l.textContent.length&&!!u&&(!u||"paragraph"!==o.parent.type.name)&&e.clearNodes()}),()=>e.deleteSelection(),()=>e.joinBackward(),()=>e.selectNodeBackward()]),i=()=>this.editor.commands.first(({commands:e})=>[()=>e.deleteSelection(),()=>e.deleteCurrentNode(),()=>e.joinForward(),()=>e.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:e})=>[()=>e.newlineInCode(),()=>e.createParagraphNear(),()=>e.liftEmptyBlock(),()=>e.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:i,"Mod-Delete":i,"Mod-a":()=>this.editor.commands.selectAll()},r={...n},s={...n,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":i,"Ctrl-Alt-Backspace":i,"Alt-Delete":i,"Alt-d":i,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return kS()||kz()?s:r},addProseMirrorPlugins(){return[new bX({key:new bZ("clearDocument"),appendTransaction:(e,i,n)=>{if(e.some(e=>e.getMeta("composition")))return;let r=e.some(e=>e.docChanged)&&!i.doc.eq(n.doc),s=e.some(e=>e.getMeta("preventClearDocument"));if(!r||s)return;let{empty:o,from:a,to:l}=i.selection,c=bA.atStart(i.doc).from,h=bA.atEnd(i.doc).to;if(o||a!==c||l!==h||!Cw(n.doc))return;let d=n.tr,u=S4({state:n,transaction:d}),{commands:p}=new S6({editor:this.editor,state:u});if(p.clearNodes(),d.steps.length)return d}})]}}),Tr=C4.create({name:"paste",addProseMirrorPlugins(){return[new bX({key:new bZ("tiptapPaste"),props:{handlePaste:(e,i,n)=>{this.editor.emit("paste",{editor:this.editor,event:i,slice:n})}}})]}}),Ts=C4.create({name:"tabindex",addProseMirrorPlugins(){return[new bX({key:new bZ("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),To=C4.create({name:"textDirection",addOptions:()=>({direction:void 0}),addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:e}=Ci(this.extensions);return[{types:e.filter(e=>"text"!==e.name).map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{let i=e.getAttribute("dir");return i&&("ltr"===i||"rtl"===i||"auto"===i)?i:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new bX({key:new bZ("textDirection"),props:{attributes:()=>{let e=this.options.direction;return e?{dir:e}:{}}}})]}}),Ta=class e{constructor(e,i,n=!1,r=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=e,this.editor=i,this.currentNode=r}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return null!=(e=this.actualDepth)?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let i=this.from,n=this.to;if(this.isBlock){if(0===this.content.size)return void console.error(`You can\u2019t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);i=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:i,to:n},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+ +!this.node.isText}get parent(){if(0===this.depth)return null;let i=this.resolvedPos.start(this.resolvedPos.depth-1);return new e(this.resolvedPos.doc.resolve(i),this.editor)}get before(){let i=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return i.depth!==this.depth&&(i=this.resolvedPos.doc.resolve(this.from-3)),new e(i,this.editor)}get after(){let i=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return i.depth!==this.depth&&(i=this.resolvedPos.doc.resolve(this.to+3)),new e(i,this.editor)}get children(){let i=[];return this.node.content.forEach((n,r)=>{let s=n.isBlock&&!n.isTextblock,o=n.isAtom&&!n.isText,a=n.isInline,l=this.pos+r+ +!o;if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;let c=this.resolvedPos.doc.resolve(l);if(!s&&!a&&c.depth<=this.depth)return;let h=new e(c,this.editor,s,s||a?n:null);s&&(h.actualDepth=this.depth+1),i.push(h)}),i}get firstChild(){return this.children[0]||null}get lastChild(){let e=this.children;return e[e.length-1]||null}closest(e,i={}){let n=null,r=this.parent;for(;r&&!n;){if(r.node.type.name===e)if(Object.keys(i).length>0){let e=r.node.attrs,n=Object.keys(i);for(let r=0;r<n.length;r+=1){let s=n[r];if(e[s]!==i[s])break}}else n=r;r=r.parent}return n}querySelector(e,i={}){return this.querySelectorAll(e,i,!0)[0]||null}querySelectorAll(e,i={},n=!1){let r=[];if(!this.children||0===this.children.length)return r;let s=Object.keys(i);return this.children.forEach(o=>{n&&r.length>0||(o.node.type.name===e&&s.every(e=>i[e]===o.node.attrs[e])&&r.push(o),n&&r.length>0||(r=r.concat(o.querySelectorAll(e,i,n))))}),r}setAttribute(e){let{tr:i}=this.editor.state;i.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(i)}},Tl=`.ProseMirror {
|
|
25
|
+
position: relative;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.ProseMirror {
|
|
29
|
+
word-wrap: break-word;
|
|
30
|
+
white-space: pre-wrap;
|
|
31
|
+
white-space: break-spaces;
|
|
32
|
+
-webkit-font-variant-ligatures: none;
|
|
33
|
+
font-variant-ligatures: none;
|
|
34
|
+
font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.ProseMirror [contenteditable="false"] {
|
|
38
|
+
white-space: normal;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.ProseMirror [contenteditable="false"] [contenteditable="true"] {
|
|
42
|
+
white-space: pre-wrap;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.ProseMirror pre {
|
|
46
|
+
white-space: pre-wrap;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
img.ProseMirror-separator {
|
|
50
|
+
display: inline !important;
|
|
51
|
+
border: none !important;
|
|
52
|
+
margin: 0 !important;
|
|
53
|
+
width: 0 !important;
|
|
54
|
+
height: 0 !important;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.ProseMirror-gapcursor {
|
|
58
|
+
display: none;
|
|
59
|
+
pointer-events: none;
|
|
60
|
+
position: absolute;
|
|
61
|
+
margin: 0;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.ProseMirror-gapcursor:after {
|
|
65
|
+
content: "";
|
|
66
|
+
display: block;
|
|
67
|
+
position: absolute;
|
|
68
|
+
top: -2px;
|
|
69
|
+
width: 20px;
|
|
70
|
+
border-top: 1px solid black;
|
|
71
|
+
animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@keyframes ProseMirror-cursor-blink {
|
|
75
|
+
to {
|
|
76
|
+
visibility: hidden;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.ProseMirror-hideselection *::selection {
|
|
81
|
+
background: transparent;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.ProseMirror-hideselection *::-moz-selection {
|
|
85
|
+
background: transparent;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.ProseMirror-hideselection * {
|
|
89
|
+
caret-color: transparent;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.ProseMirror-focused .ProseMirror-gapcursor {
|
|
93
|
+
display: block;
|
|
94
|
+
}`,Tc=class extends CJ{constructor(e={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:"u">typeof document?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:e})=>{throw e},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:CC,createMappablePosition:CT},this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:e,slice:i,moved:n})=>this.options.onDrop(e,i,n)),this.on("paste",({event:e,slice:i})=>this.options.onPaste(e,i)),this.on("delete",this.options.onDelete);const i=this.createDoc(),n=kx(i,this.options.autofocus);this.editorState=bK.create({doc:i,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(e){if("u"<typeof document)throw Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(e),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(!1!==this.options.autofocus&&null!==this.options.autofocus&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){let e=this.editorView.dom;(null==e?void 0:e.editor)&&delete e.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{"function"==typeof this.css.remove?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(e){console.warn("Failed to remove CSS element:",e)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&"u">typeof document&&(this.css=function(e,i){let n=document.querySelector("style[data-tiptap-style]");if(null!==n)return n;let r=document.createElement("style");return i&&r.setAttribute("nonce",i),r.setAttribute("data-tiptap-style",""),r.innerHTML=e,document.getElementsByTagName("head")[0].appendChild(r),r}(Tl,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},this.editorView&&this.state&&!this.isDestroyed&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,i=!0){this.setOptions({editable:e}),i&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:e=>{this.editorState=e},dispatch:e=>{this.dispatchTransaction(e)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(e,i)=>{if(this.editorView)return this.editorView[i];if("state"===i)return this.editorState;if(i in e)return Reflect.get(e,i);throw Error(`[tiptap error]: The editor view is not available. Cannot access view['${i}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(e,i){let n=Ce(i)?i(e,[...this.state.plugins]):[...this.state.plugins,e],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(e){if(this.isDestroyed)return;let i=this.state.plugins,n=i;if([].concat(e).forEach(e=>{let i="string"==typeof e?`${e}$`:e.key;n=n.filter(e=>!e.key.startsWith(i))}),i.length===n.length)return;let r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var e,i;let n=[...this.options.enableCoreExtensions?[Te,C6.configure({blockSeparator:null==(i=null==(e=this.options.coreExtensionOptions)?void 0:e.clipboardTextSerializer)?void 0:i.blockSeparator}),C8,Ti,Tn,Ts,C7,Tr,C9,To.configure({direction:this.options.textDirection})].filter(e=>"object"!=typeof this.options.enableCoreExtensions||!1!==this.options.enableCoreExtensions[e.name]):[],...this.options.extensions].filter(e=>["extension","node","mark"].includes(null==e?void 0:e.type));this.extensionManager=new C3(n,this)}createCommandManager(){this.commandManager=new S6({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let e;try{e=k2(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(i){if(!(i instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(i.message))throw i;this.emit("contentError",{editor:this,error:i,disableCollaboration:()=>{"collaboration"in this.storage&&"object"==typeof this.storage.collaboration&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(e=>"collaboration"!==e.name),this.createExtensionManager()}}),e=k2(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return e}createView(e){let{editorProps:i,enableExtensionDispatchTransaction:n}=this.options,r=i.dispatchTransaction||this.dispatchTransaction.bind(this),s=n?this.extensionManager.dispatchTransaction(r):r,o=i.transformPastedHTML,a=this.extensionManager.transformPastedHTML(o);this.editorView=new SW(e,{...i,attributes:{role:"textbox",...null==i?void 0:i.attributes},dispatchTransaction:s,transformPastedHTML:a,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});let l=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(l),this.prependClass(),this.injectCSS(),this.view.dom.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;let i=this.capturedTransaction;return this.capturedTransaction=null,i}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(e=>{var i;return null==(i=this.capturedTransaction)?void 0:i.step(e)});return}let{state:i,transactions:n}=this.state.applyTransaction(e),r=!this.state.selection.eq(i.selection),s=n.includes(e),o=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:e,nextState:i}),!s)return;this.view.updateState(i),this.emit("transaction",{editor:this,transaction:e,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:e});let a=n.findLast(e=>e.getMeta("focus")||e.getMeta("blur")),l=null==a?void 0:a.getMeta("focus"),c=null==a?void 0:a.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:a}),c&&this.emit("blur",{editor:this,event:c.event,transaction:a}),e.getMeta("preventUpdate")||!n.some(e=>e.docChanged)||o.doc.eq(i.doc)||this.emit("update",{editor:this,transaction:e,appendedTransactions:n.slice(1)})}getAttributes(e){return Cf(this.state,e)}isActive(e,i){let n="string"==typeof e?e:null,r="string"==typeof e?i:e;return function(e,i,n={}){if(!i)return kW(e,null,n)||C_(e,null,n);let r=kq(i,e.schema);return"node"===r?kW(e,i,n):"mark"===r&&C_(e,i,n)}(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return k7(this.state.doc.content,this.schema)}getText(e){var i,n;let r,{blockSeparator:s="\n\n",textSerializers:o={}}=e||{};return i=this.state.doc,n={blockSeparator:s,textSerializers:{...Cp(this.schema),...o}},r={from:0,to:i.content.size},Cu(i,r,n)}get isEmpty(){return Cw(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var e,i;return null==(i=null==(e=this.editorView)?void 0:e.isDestroyed)||i}$node(e,i){var n;return(null==(n=this.$doc)?void 0:n.querySelector(e,i))||null}$nodes(e,i){var n;return(null==(n=this.$doc)?void 0:n.querySelectorAll(e,i))||null}$pos(e){return new Ta(this.state.doc.resolve(e),this)}get $doc(){return this.$pos(0)}};function Th(e){return new CG({find:e.find,handler:({state:i,range:n,match:r})=>{let s=Ct(e.getAttributes,void 0,r);if(!1===s||null===s)return null;let{tr:o}=i,a=r[r.length-1],l=r[0];if(a){let r=l.search(/\S/),c=n.from+l.indexOf(a),h=c+a.length;if(Cg(n.from,n.to,i.doc).filter(i=>i.mark.type.excluded.find(n=>n===e.type&&n!==i.mark.type)).filter(e=>e.to>c).length)return null;h<n.to&&o.delete(h,n.to),c>n.from&&o.delete(n.from+r,c);let d=n.from+r+a.length;o.addMark(n.from+r,d,e.type.create(s||{})),o.removeStoredMark(e.type)}},undoable:e.undoable})}function Td(e){return new CG({find:e.find,handler:({state:i,range:n,match:r})=>{let s=i.doc.resolve(n.from),o=Ct(e.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),e.type))return null;i.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,o)},undoable:e.undoable})}function Tu(e){return new CG({find:e.find,handler:({state:i,range:n,match:r,chain:s})=>{let o=Ct(e.getAttributes,void 0,r)||{},a=i.tr.delete(n.from,n.to),l=a.doc.resolve(n.from).blockRange(),c=l&&bc(l,e.type,o);if(!c)return null;if(a.wrap(l,c),e.keepMarks&&e.editor){let{selection:n,storedMarks:r}=i,{splittableMarks:s}=e.editor.extensionManager,o=r||n.$to.parentOffset&&n.$from.marks();if(o){let e=o.filter(e=>s.includes(e.type.name));a.ensureMarks(e)}}if(e.keepAttributes){let i="bulletList"===e.type.name||"orderedList"===e.type.name?"listItem":"taskList";s().updateAttributes(i,o).run()}let h=a.doc.resolve(n.from-1).nodeBefore;h&&h.type===e.type&&bf(a.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,h))&&a.join(n.from-1)},undoable:e.undoable})}function Tp(e){if(!(null==e?void 0:e.trim()))return{};let i={},n=[],r=e.replace(/["']([^"']*)["']/g,e=>(n.push(e),`__QUOTED_${n.length-1}__`)),s=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);s&&(i.class=s.map(e=>e.trim().slice(1)).join(" "));let o=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);o&&(i.id=o[1]),Array.from(r.matchAll(/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g)).forEach(([,e,r])=>{var s;let o=n[parseInt((null==(s=r.match(/__QUOTED_(\d+)__/))?void 0:s[1])||"0",10)];o&&(i[e]=o.slice(1,-1))});let a=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return a&&a.split(/\s+/).filter(Boolean).forEach(e=>{e.match(/^[a-zA-Z][\w-]*$/)&&(i[e]=!0)}),i}function Tf(e){if(!e||0===Object.keys(e).length)return"";let i=[];return e.class&&String(e.class).split(/\s+/).filter(Boolean).forEach(e=>i.push(`.${e}`)),e.id&&i.push(`#${e.id}`),Object.entries(e).forEach(([e,n])=>{"class"!==e&&"id"!==e&&(!0===n?i.push(e):!1!==n&&null!=n&&i.push(`${e}="${String(n)}"`))}),i.join(" ")}function Tm(e){let{nodeName:i,name:n,parseAttributes:r=Tp,serializeAttributes:s=Tf,defaultAttributes:o={},requiredAttributes:a=[],allowedAttributes:l}=e,c=n||i;return{parseMarkdown:(e,n)=>{let r={...o,...e.attributes};return n.createNode(i,r,[])},markdownTokenizer:{name:i,level:"block",start(e){var i;let n=RegExp(`^:::${c}(?:\\s|$)`,"m"),r=null==(i=e.match(n))?void 0:i.index;return void 0!==r?r:-1},tokenize(e,n,s){let o=RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),l=e.match(o);if(!l)return;let h=r(l[1]||"");if(!a.find(e=>!(e in h)))return{type:i,raw:l[0],attributes:h}}},renderMarkdown:e=>{let i=s((e=>{if(!l)return e;let i={};return l.forEach(n=>{n in e&&(i[n]=e[n])}),i})(e.attrs||{})),n=i?` {${i}}`:"";return`:::${c}${n} :::`}}}function Tg(e){let{nodeName:i,name:n,getContent:r,parseAttributes:s=Tp,serializeAttributes:o=Tf,defaultAttributes:a={},content:l="block",allowedAttributes:c}=e,h=n||i;return{parseMarkdown:(e,n)=>{let s;if(r){let i=r(e);s="string"==typeof i?[{type:"text",text:i}]:i}else s="block"===l?n.parseChildren(e.tokens||[]):n.parseInline(e.tokens||[]);let o={...a,...e.attributes};return n.createNode(i,o,s)},markdownTokenizer:{name:i,level:"block",start(e){var i;let n=RegExp(`^:::${h}`,"m"),r=null==(i=e.match(n))?void 0:i.index;return void 0!==r?r:-1},tokenize(e,n,r){var o;let a=RegExp(`^:::${h}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),c=e.match(a);if(!c)return;let[d,u=""]=c,p=s(u),f=1,m=d.length,g="",v=/^:::([\w-]*)(\s.*)?/gm,y=e.slice(m);for(v.lastIndex=0;;){let n=v.exec(y);if(null===n)break;let s=n.index,a=n[1];if(null==(o=n[2])||!o.endsWith(":::")){if(a)f+=1;else if(0==(f-=1)){let o=y.slice(0,s);g=o.trim();let a=e.slice(0,m+s+n[0].length),c=[];if(g)if("block"===l)for((c=r.blockTokens(o)).forEach(e=>{e.text&&(!e.tokens||0===e.tokens.length)&&(e.tokens=r.inlineTokens(e.text))});c.length>0;){let e=c[c.length-1];if("paragraph"!==e.type||e.text&&""!==e.text.trim())break;c.pop()}else c=r.inlineTokens(g);return{type:i,raw:a,attributes:p,content:g,tokens:c}}}}}},renderMarkdown:(e,i)=>{let n=o((e=>{if(!c)return e;let i={};return c.forEach(n=>{n in e&&(i[n]=e[n])}),i})(e.attrs||{})),r=n?` {${n}}`:"",s=i.renderChildren(e.content||[],"\n\n");return`:::${h}${r}
|
|
95
|
+
|
|
96
|
+
${s}
|
|
97
|
+
|
|
98
|
+
:::`}}}function Tv(e){if(!e.trim())return{};let i={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g,r=n.exec(e);for(;null!==r;){let[,s,o,a]=r;i[s]=o||a,r=n.exec(e)}return i}function Ty(e){return Object.entries(e).filter(([,e])=>null!=e).map(([e,i])=>`${e}="${i}"`).join(" ")}function T_(e){let{nodeName:i,name:n,getContent:r,parseAttributes:s=Tv,serializeAttributes:o=Ty,defaultAttributes:a={},selfClosing:l=!1,allowedAttributes:c}=e,h=n||i,d=h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(e,n)=>{let s={...a,...e.attributes};if(l)return n.createNode(i,s);let o=r?r(e):e.content||"";return o?n.createNode(i,s,[n.createTextNode(o)]):n.createNode(i,s,[])},markdownTokenizer:{name:i,level:"inline",start(e){let i=l?RegExp(`\\[${d}\\s*[^\\]]*\\]`):RegExp(`\\[${d}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${d}\\]`),n=e.match(i),r=null==n?void 0:n.index;return void 0!==r?r:-1},tokenize(e,n,r){let o=l?RegExp(`^\\[${d}\\s*([^\\]]*)\\]`):RegExp(`^\\[${d}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${d}\\]`),a=e.match(o);if(!a)return;let c="",h="";if(l){let[,e]=a;h=e}else{let[,e,i]=a;h=e,c=i||""}let u=s(h.trim());return{type:i,raw:a[0],content:c.trim(),attributes:u}}},renderMarkdown:e=>{let i="";r?i=r(e):e.content&&e.content.length>0&&(i=e.content.filter(e=>"text"===e.type).map(e=>e.text).join(""));let n=o((e=>{if(!c)return e;let i={};return c.forEach(n=>{let r="string"==typeof n?n:n.name,s="string"==typeof n?void 0:n.skipIfDefault;if(r in e){let n=e[r];if(void 0!==s&&n===s)return;i[r]=n}}),i})(e.attrs||{})),s=n?` ${n}`:"";return l?`[${h}${s}]`:`[${h}${s}]${i}[/${h}]`}}}function Tb(e,i,n){var r,s,o,a;let l=e.split("\n"),c=[],h="",d=0,u=i.baseIndentSize||2;for(;d<l.length;){let e,p=l[d],f=p.match(i.itemPattern);if(!f)if(c.length>0)break;else{if(""!==p.trim())return;d+=1,h=`${h}${p}
|
|
99
|
+
`;continue}let m=i.extractItemData(f),{indentLevel:g,mainContent:v}=m;h=`${h}${p}
|
|
100
|
+
`;let y=[v];for(d+=1;d<l.length;){let e=l[d];if(""===e.trim()){let i=l.slice(d+1).findIndex(e=>""!==e.trim());if(-1===i)break;if(((null==(s=null==(r=l[d+1+i].match(/^(\s*)/))?void 0:r[1])?void 0:s.length)||0)>g){y.push(e),h=`${h}${e}
|
|
101
|
+
`,d+=1;continue}break}if(((null==(a=null==(o=e.match(/^(\s*)/))?void 0:o[1])?void 0:a.length)||0)>g)y.push(e),h=`${h}${e}
|
|
102
|
+
`,d+=1;else break}let _=y.slice(1);if(_.length>0){let r=_.map(e=>e.slice(g+u)).join("\n");r.trim()&&(e=i.customNestedParser?i.customNestedParser(r):n.blockTokens(r))}let b=i.createToken(m,e);c.push(b)}if(0!==c.length)return{items:c,raw:h}}function Tx(e,i,n,r){if(!e||!Array.isArray(e.content))return"";let s="function"==typeof n?n(r):n,[o,...a]=e.content,l=i.renderChildren([o]),c=`${s}${l}`;return a&&a.length>0&&a.forEach((e,n)=>{var r,s;let o=null!=(s=null==(r=i.renderChild)?void 0:r.call(i,e,n+1))?s:i.renderChildren([e]);if(null!=o){let n=o.split("\n").map(e=>e?i.indent(e):i.indent("")).join("\n");c+="paragraph"===e.type?`
|
|
103
|
+
|
|
104
|
+
${n}`:`
|
|
105
|
+
${n}`}}),c}S3({},{createAtomBlockMarkdownSpec:()=>Tm,createBlockMarkdownSpec:()=>Tg,createInlineMarkdownSpec:()=>T_,parseAttributes:()=>Tp,parseIndentedBlocks:()=>Tb,renderNestedMarkdownContent:()=>Tx,serializeAttributes:()=>Tf});var Tw=class e extends C0{constructor(){super(...arguments),this.type="node"}static create(i={}){return new e("function"==typeof i?i():i)}configure(e){return super.configure(e)}extend(e){let i="function"==typeof e?e():e;return super.extend(i)}};function TS(e){return new C2({find:e.find,handler:({state:i,range:n,match:r,pasteEvent:s})=>{let o=Ct(e.getAttributes,void 0,r,s);if(!1===o||null===o)return null;let{tr:a}=i,l=r[r.length-1],c=r[0],h=n.to;if(l){let s=c.search(/\S/),d=n.from+c.indexOf(l),u=d+l.length;if(Cg(n.from,n.to,i.doc).filter(i=>i.mark.type.excluded.find(n=>n===e.type&&n!==i.mark.type)).filter(e=>e.to>d).length)return null;u<n.to&&a.delete(u,n.to),d>n.from&&a.delete(n.from+s,d),h=n.from+s+l.length,a.addMark(n.from+s,h,e.type.create(o||{})),void 0!==r.index&&void 0!==r.input&&r.index+r[0].length>=r.input.length||a.removeStoredMark(e.type)}}})}let{getOwnPropertyNames:Tk,getOwnPropertySymbols:TC}=Object,{hasOwnProperty:TT}=Object.prototype;function TE(e,i){return function(n,r,s){return e(n,r,s)&&i(n,r,s)}}function TN(e){return function(i,n,r){if(!i||!n||"object"!=typeof i||"object"!=typeof n)return e(i,n,r);let{cache:s}=r,o=s.get(i),a=s.get(n);if(o&&a)return o===n&&a===i;s.set(i,n),s.set(n,i);let l=e(i,n,r);return s.delete(i),s.delete(n),l}}function TM(e){return Tk(e).concat(TC(e))}let TO=Object.hasOwn||((e,i)=>TT.call(e,i));function TA(e,i){return e===i||!e&&!i&&e!=e&&i!=i}let{getOwnPropertyDescriptor:TR,keys:TD}=Object;function TL(e,i){return e.byteLength===i.byteLength&&Tq(new Uint8Array(e),new Uint8Array(i))}function Tj(e,i,n){let r=e.length;if(i.length!==r)return!1;for(;r-- >0;)if(!n.equals(e[r],i[r],r,r,e,i,n))return!1;return!0}function TI(e,i){return e.byteLength===i.byteLength&&Tq(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(i.buffer,i.byteOffset,i.byteLength))}function TP(e,i){return TA(e.getTime(),i.getTime())}function TB(e,i){return e.name===i.name&&e.message===i.message&&e.cause===i.cause&&e.stack===i.stack}function Tz(e,i){return e===i}function TF(e,i,n){let r,s,o=e.size;if(o!==i.size)return!1;if(!o)return!0;let a=Array(o),l=e.entries(),c=0;for(;(r=l.next())&&!r.done;){let o=i.entries(),l=!1,h=0;for(;(s=o.next())&&!s.done;){if(a[h]){h++;continue}let o=r.value,d=s.value;if(n.equals(o[0],d[0],c,h,e,i,n)&&n.equals(o[1],d[1],o[0],d[0],e,i,n)){l=a[h]=!0;break}h++}if(!l)return!1;c++}return!0}function TW(e,i,n){let r=TD(e),s=r.length;if(TD(i).length!==s)return!1;for(;s-- >0;)if(!TK(e,i,n,r[s]))return!1;return!0}function TH(e,i,n){let r,s,o,a=TM(e),l=a.length;if(TM(i).length!==l)return!1;for(;l-- >0;)if(!TK(e,i,n,r=a[l])||(s=TR(e,r),o=TR(i,r),(s||o)&&(!s||!o||s.configurable!==o.configurable||s.enumerable!==o.enumerable||s.writable!==o.writable)))return!1;return!0}function T$(e,i){return TA(e.valueOf(),i.valueOf())}function TU(e,i){return e.source===i.source&&e.flags===i.flags}function TV(e,i,n){let r,s,o=e.size;if(o!==i.size)return!1;if(!o)return!0;let a=Array(o),l=e.values();for(;(r=l.next())&&!r.done;){let o=i.values(),l=!1,c=0;for(;(s=o.next())&&!s.done;){if(!a[c]&&n.equals(r.value,s.value,r.value,s.value,e,i,n)){l=a[c]=!0;break}c++}if(!l)return!1}return!0}function Tq(e,i){let n=e.byteLength;if(i.byteLength!==n||e.byteOffset!==i.byteOffset)return!1;for(;n-- >0;)if(e[n]!==i[n])return!1;return!0}function TY(e,i){return e.hostname===i.hostname&&e.pathname===i.pathname&&e.protocol===i.protocol&&e.port===i.port&&e.hash===i.hash&&e.username===i.username&&e.password===i.password}function TK(e,i,n,r){return("_owner"===r||"__o"===r||"__v"===r)&&(!!e.$$typeof||!!i.$$typeof)||TO(i,r)&&n.equals(e[r],i[r],r,r,e,i,n)}let TX={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},TJ=Object.prototype.toString,TG=TZ();function TZ(e={}){let{circular:i=!1,createInternalComparator:n,createState:r,strict:s=!1}=e,o=function({areArrayBuffersEqual:e,areArraysEqual:i,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:s,areFunctionsEqual:o,areMapsEqual:a,areNumbersEqual:l,areObjectsEqual:c,arePrimitiveWrappersEqual:h,areRegExpsEqual:d,areSetsEqual:u,areTypedArraysEqual:p,areUrlsEqual:f,unknownTagComparators:m}){return function(g,v,y){if(g===v)return!0;if(null==g||null==v)return!1;let _=typeof g;if(_!==typeof v)return!1;if("object"!==_)return"number"===_?l(g,v,y):"function"===_&&o(g,v,y);let b=g.constructor;if(b!==v.constructor)return!1;if(b===Object)return c(g,v,y);if(Array.isArray(g))return i(g,v,y);if(b===Date)return r(g,v,y);if(b===RegExp)return d(g,v,y);if(b===Map)return a(g,v,y);if(b===Set)return u(g,v,y);let w=TJ.call(g);if("[object Date]"===w)return r(g,v,y);if("[object RegExp]"===w)return d(g,v,y);if("[object Map]"===w)return a(g,v,y);if("[object Set]"===w)return u(g,v,y);if("[object Object]"===w)return"function"!=typeof g.then&&"function"!=typeof v.then&&c(g,v,y);if("[object URL]"===w)return f(g,v,y);if("[object Error]"===w)return s(g,v,y);if("[object Arguments]"===w)return c(g,v,y);if(TX[w])return p(g,v,y);if("[object ArrayBuffer]"===w)return e(g,v,y);if("[object DataView]"===w)return n(g,v,y);if("[object Boolean]"===w||"[object Number]"===w||"[object String]"===w)return h(g,v,y);if(m){let e=m[w];if(!e){let i=null!=g?g[Symbol.toStringTag]:void 0;i&&(e=m[i])}if(e)return e(g,v,y)}return!1}}(function({circular:e,createCustomConfig:i,strict:n}){let r={areArrayBuffersEqual:TL,areArraysEqual:n?TH:Tj,areDataViewsEqual:TI,areDatesEqual:TP,areErrorsEqual:TB,areFunctionsEqual:Tz,areMapsEqual:n?TE(TF,TH):TF,areNumbersEqual:TA,areObjectsEqual:n?TH:TW,arePrimitiveWrappersEqual:T$,areRegExpsEqual:TU,areSetsEqual:n?TE(TV,TH):TV,areTypedArraysEqual:n?TE(Tq,TH):Tq,areUrlsEqual:TY,unknownTagComparators:void 0};if(i&&(r=Object.assign({},r,i(r))),e){let e=TN(r.areArraysEqual),i=TN(r.areMapsEqual),n=TN(r.areObjectsEqual),s=TN(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:e,areMapsEqual:i,areObjectsEqual:n,areSetsEqual:s})}return r}(e)),a=n?n(o):function(e,i,n,r,s,a,l){return o(e,i,l)};return function({circular:e,comparator:i,createState:n,equals:r,strict:s}){if(n)return function(o,a){let{cache:l=e?new WeakMap:void 0,meta:c}=n();return i(o,a,{cache:l,equals:r,meta:c,strict:s})};if(e)return function(e,n){return i(e,n,{cache:new WeakMap,equals:r,meta:void 0,strict:s})};let o={cache:void 0,equals:r,meta:void 0,strict:s};return function(e,n){return i(e,n,o)}}({circular:i,comparator:o,createState:r,equals:a,strict:s})}TZ({strict:!0}),TZ({circular:!0}),TZ({circular:!0,strict:!0}),TZ({createInternalComparator:()=>TA}),TZ({strict:!0,createInternalComparator:()=>TA}),TZ({circular:!0,createInternalComparator:()=>TA}),TZ({circular:!0,createInternalComparator:()=>TA,strict:!0});var TQ=e.i(596482),T0=({contentComponent:e})=>{let i=(0,_s.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getServerSnapshot);return(0,iN.jsx)(iN.Fragment,{children:Object.values(i)})},T1=class extends _r.default.Component{constructor(e){super(e),this.editorContentRef=_r.default.createRef()}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var e;let i=this.props.editor;if(i&&!i.isDestroyed&&(null==(e=i.view.dom)?void 0:e.parentNode)){let e,n;if(i.contentComponent)return;let r=this.editorContentRef.current;r.append(...i.view.dom.parentNode.childNodes),i.setOptions({element:r}),e=new Set,n={},i.contentComponent={subscribe:i=>(e.add(i),()=>{e.delete(i)}),getSnapshot:()=>n,getServerSnapshot:()=>n,setRenderer(i,r){n={...n,[i]:iR.default.createPortal(r.reactElement,r.element,i)},e.forEach(e=>e())},removeRenderer(i){let r={...n};delete r[i],n=r,e.forEach(e=>e())}},i.createNodeViews(),i.isEditorContentInitialized=!0,this.forceUpdate()}}componentWillUnmount(){var e;let i=this.props.editor;if(i){i.isEditorContentInitialized=!1,i.isDestroyed||i.view.setProps({nodeViews:{}}),i.contentComponent=null;try{if(!(null==(e=i.view.dom)?void 0:e.parentNode))return;let n=document.createElement("div");n.append(...i.view.dom.parentNode.childNodes),i.setOptions({element:n})}catch{}}}render(){let{editor:e,innerRef:i,...n}=this.props;return(0,iN.jsxs)(iN.Fragment,{children:[(0,iN.jsx)("div",{ref:((...e)=>i=>{e.forEach(e=>{"function"==typeof e?e(i):e&&(e.current=i)})})(i,this.editorContentRef),...n}),(null==e?void 0:e.contentComponent)&&(0,iN.jsx)(T0,{contentComponent:e.contentComponent})]})}},T2=(0,_r.forwardRef)((e,i)=>{let n=_r.default.useMemo(()=>Math.floor(0xffffffff*Math.random()).toString(),[e.editor]);return _r.default.createElement(T1,{key:n,innerRef:i,...e})}),T5=_r.default.memo(T2),T3="u">typeof window?_r.useLayoutEffect:_r.useEffect,T4=class{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber||(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber}),this.lastSnapshot}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){let e=()=>{this.transactionNumber+=1,this.subscribers.forEach(e=>e())},i=this.editor;return i.on("transaction",e),()=>{i.off("transaction",e)}}}};function T6(e){var i;let[n]=(0,_r.useState)(()=>new T4(e.editor)),r=(0,TQ.useSyncExternalStoreWithSelector)(n.subscribe,n.getSnapshot,n.getServerSnapshot,e.selector,null!=(i=e.equalityFn)?i:TG);return T3(()=>n.watch(e.editor),[e.editor,n]),(0,_r.useDebugValue)(r),r}var T8="u"<typeof window,T9=T8||!!("u">typeof window&&window.next),T7=class e{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(e=>e())}getInitialEditor(){return void 0===this.options.current.immediatelyRender?T8||T9?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender)?this.createEditor():null}createEditor(){return new Tc({...this.options.current,onBeforeCreate:(...e)=>{var i,n;return null==(n=(i=this.options.current).onBeforeCreate)?void 0:n.call(i,...e)},onBlur:(...e)=>{var i,n;return null==(n=(i=this.options.current).onBlur)?void 0:n.call(i,...e)},onCreate:(...e)=>{var i,n;return null==(n=(i=this.options.current).onCreate)?void 0:n.call(i,...e)},onDestroy:(...e)=>{var i,n;return null==(n=(i=this.options.current).onDestroy)?void 0:n.call(i,...e)},onFocus:(...e)=>{var i,n;return null==(n=(i=this.options.current).onFocus)?void 0:n.call(i,...e)},onSelectionUpdate:(...e)=>{var i,n;return null==(n=(i=this.options.current).onSelectionUpdate)?void 0:n.call(i,...e)},onTransaction:(...e)=>{var i,n;return null==(n=(i=this.options.current).onTransaction)?void 0:n.call(i,...e)},onUpdate:(...e)=>{var i,n;return null==(n=(i=this.options.current).onUpdate)?void 0:n.call(i,...e)},onContentError:(...e)=>{var i,n;return null==(n=(i=this.options.current).onContentError)?void 0:n.call(i,...e)},onDrop:(...e)=>{var i,n;return null==(n=(i=this.options.current).onDrop)?void 0:n.call(i,...e)},onPaste:(...e)=>{var i,n;return null==(n=(i=this.options.current).onPaste)?void 0:n.call(i,...e)},onDelete:(...e)=>{var i,n;return null==(n=(i=this.options.current).onDelete)?void 0:n.call(i,...e)}})}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,i){return Object.keys(e).every(n=>!!["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(n)||("extensions"===n&&e.extensions&&i.extensions?e.extensions.length===i.extensions.length&&e.extensions.every((e,n)=>{var r;return e===(null==(r=i.extensions)?void 0:r[n])}):e[n]===i[n]))}onRender(i){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&0===i.length?e.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(i),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(null===this.previousDeps){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((i,n)=>i===e[n]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){let e=this.instanceId,i=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){i&&i.setOptions(this.options.current);return}i&&!i.isDestroyed&&(i.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function Ee(e={},i=[]){let n=(0,_r.useRef)(e);n.current=e;let[r]=(0,_r.useState)(()=>new T7(n)),s=(0,_s.useSyncExternalStore)(r.subscribe,r.getEditor,r.getServerSnapshot);return(0,_r.useDebugValue)(s),(0,_r.useEffect)(r.onRender(i)),T6({editor:s,selector:({transactionNumber:i})=>!1===e.shouldRerenderOnTransaction||void 0===e.shouldRerenderOnTransaction?null:e.immediatelyRender&&0===i?0:i+1}),s}var Et=(0,_r.createContext)({editor:null});Et.Consumer;var Ei=(0,_r.createContext)({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}});function En(e){return!!("function"==typeof e&&e.prototype&&e.prototype.isReactComponent)}function Er(e){return!!("object"==typeof e&&e.$$typeof&&("Symbol(react.forward_ref)"===e.$$typeof.toString()||"react.forward_ref"===e.$$typeof.description))}_r.default.forwardRef((e,i)=>{let{onDragStart:n}=(0,_r.useContext)(Ei),r=e.as||"div";return(0,iN.jsx)(r,{...e,ref:i,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...e.style}})});var Es=class{constructor(e,{editor:i,props:n={},as:r="div",className:s=""}){this.ref=null,this.destroyed=!1,this.id=Math.floor(0xffffffff*Math.random()).toString(),this.component=e,this.editor=i,this.props=n,this.element=document.createElement(r),this.element.classList.add("react-renderer"),s&&this.element.classList.add(...s.split(" ")),this.editor.isEditorContentInitialized?(0,iR.flushSync)(()=>{this.render()}):queueMicrotask(()=>{this.destroyed||this.render()})}render(){var e;if(this.destroyed)return;let i=this.component,n=this.props,r=this.editor,s=function(){try{if(_r.version)return parseInt(_r.version.split(".")[0],10)>=19}catch{}return!1}(),o=function(e){if(En(e)||Er(e))return!0;if("object"==typeof e&&e.$$typeof&&("Symbol(react.memo)"===e.$$typeof.toString()||"react.memo"===e.$$typeof.description)){let i=e.type;if(i)return En(i)||Er(i)}return!1}(i),a={...n};a.ref&&!(s||o)&&delete a.ref,!a.ref&&(s||o)&&(a.ref=e=>{this.ref=e}),this.reactElement=(0,iN.jsx)(i,{...a}),null==(e=null==r?void 0:r.contentComponent)||e.setRenderer(this.id,this)}updateProps(e={}){this.destroyed||(this.props={...this.props,...e},this.render())}destroy(){var e;this.destroyed=!0;let i=this.editor;null==(e=null==i?void 0:i.contentComponent)||e.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(e){Object.keys(e).forEach(i=>{this.element.setAttribute(i,e[i])})}};_r.default.createContext({markViewContentRef:()=>{}});var Eo=(0,_r.createContext)({get editor(){throw Error("useTiptap must be used within a <Tiptap> provider")}});function Ea({editor:e,instance:i,children:n}){let r=null!=e?e:i;if(!r)throw Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");let s=(0,_r.useMemo)(()=>({editor:r}),[r]),o=(0,_r.useMemo)(()=>({editor:r}),[r]);return(0,iN.jsx)(Et.Provider,{value:o,children:(0,iN.jsx)(Eo.Provider,{value:s,children:n})})}function El({...e}){let{editor:i}=(0,_r.useContext)(Eo);return(0,iN.jsx)(T5,{editor:i,...e})}Eo.displayName="TiptapContext",Ea.displayName="Tiptap",El.displayName="Tiptap.Content",Object.assign(Ea,{Content:El});var Ec=(e,i)=>{if("slot"===e)return 0;if(e instanceof Function)return e(i);let{children:n,...r}=null!=i?i:{};if("svg"===e)throw Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[e,r,n]},Eh=/^\s*>\s$/,Ed=Tw.create({name:"blockquote",addOptions:()=>({HTMLAttributes:{}}),content:"block+",group:"block",defining:!0,parseHTML:()=>[{tag:"blockquote"}],renderHTML({HTMLAttributes:e}){return Ec("blockquote",{...Cs(this.options.HTMLAttributes,e),children:Ec("slot",{})})},parseMarkdown:(e,i)=>{var n;let r=null!=(n=i.parseBlockChildren)?n:i.parseChildren;return i.createNode("blockquote",void 0,r(e.tokens||[]))},renderMarkdown:(e,i)=>{if(!e.content)return"";let n=[];return e.content.forEach((e,r)=>{var s,o;let a=(null!=(o=null==(s=i.renderChild)?void 0:s.call(i,e,r))?o:i.renderChildren([e])).split("\n").map(e=>""===e.trim()?">":`> ${e}`);n.push(a.join("\n"))}),n.join(`
|
|
106
|
+
>
|
|
107
|
+
`)},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Tu({find:Eh,type:this.type})]}}),Eu=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Ep=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Ef=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Em=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Eg=C1.create({name:"bold",addOptions:()=>({HTMLAttributes:{}}),parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:e=>"normal"!==e.style.fontWeight&&null},{style:"font-weight=400",clearMark:e=>e.type.name===this.name},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return Ec("strong",{...Cs(this.options.HTMLAttributes,e),children:Ec("slot",{})})},markdownTokenName:"strong",parseMarkdown:(e,i)=>i.applyMark("bold",i.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:"<strong>",close:"</strong>"}},renderMarkdown:(e,i)=>`**${i.renderChildren(e)}**`,addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Th({find:Eu,type:this.type}),Th({find:Ef,type:this.type})]},addPasteRules(){return[TS({find:Ep,type:this.type}),TS({find:Em,type:this.type})]}}),Ev=/(^|[^`])`([^`]+)`(?!`)$/,Ey=/(^|[^`])`([^`]+)`(?!`)/g,E_=C1.create({name:"code",addOptions:()=>({HTMLAttributes:{}}),excludes:"_",code:!0,exitable:!0,parseHTML:()=>[{tag:"code"}],renderHTML({HTMLAttributes:e}){return["code",Cs(this.options.HTMLAttributes,e),0]},markdownTokenName:"codespan",parseMarkdown:(e,i)=>i.applyMark("code",[{type:"text",text:e.text||""}]),renderMarkdown:(e,i)=>e.content?`\`${i.renderChildren(e.content)}\``:"",addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Th({find:Ev,type:this.type})]},addPasteRules(){return[TS({find:Ey,type:this.type})]}}),Eb=/^```([a-z]+)?[\s\n]$/,Ex=/^~~~([a-z]+)?[\s\n]$/,Ew=Tw.create({name:"codeBlock",addOptions:()=>({languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:4,HTMLAttributes:{}}),content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{var i;let{languageClassPrefix:n}=this.options;if(!n)return null;let r=[...(null==(i=e.firstElementChild)?void 0:i.classList)||[]].filter(e=>e.startsWith(n)).map(e=>e.replace(n,""))[0];return r||null},rendered:!1}}},parseHTML:()=>[{tag:"pre",preserveWhitespace:"full"}],renderHTML({node:e,HTMLAttributes:i}){return["pre",Cs(this.options.HTMLAttributes,i),["code",{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(e,i)=>{var n,r;return(null==(n=e.raw)?void 0:n.startsWith("```"))===!1&&(null==(r=e.raw)?void 0:r.startsWith("~~~"))===!1&&"indented"!==e.codeBlockStyle?[]:i.createNode("codeBlock",{language:e.lang||null},e.text?[i.createTextNode(e.text)]:[])},renderMarkdown:(e,i)=>{var n;let r=(null==(n=e.attrs)?void 0:n.language)||"";return e.content?[`\`\`\`${r}`,i.renderChildren(e.content),"```"].join("\n"):`\`\`\`${r}
|
|
108
|
+
|
|
109
|
+
\`\`\``},addCommands(){return{setCodeBlock:e=>({commands:i})=>i.setNode(this.name,e),toggleCodeBlock:e=>({commands:i})=>i.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:e,$anchor:i}=this.editor.state.selection,n=1===i.pos;return!!e&&i.parent.type.name===this.name&&(!!n||!i.parent.textContent.length)&&this.editor.commands.clearNodes()},Tab:({editor:e})=>{var i;if(!this.options.enableTabIndentation)return!1;let n=null!=(i=this.options.tabSize)?i:4,{state:r}=e,{selection:s}=r,{$from:o,empty:a}=s;if(o.parent.type!==this.type)return!1;let l=" ".repeat(n);return a?e.commands.insertContent(l):e.commands.command(({tr:e})=>{let{from:i,to:n}=s,o=r.doc.textBetween(i,n,"\n","\n").split("\n").map(e=>l+e).join("\n");return e.replaceWith(i,n,r.schema.text(o)),!0})},"Shift-Tab":({editor:e})=>{var i;if(!this.options.enableTabIndentation)return!1;let n=null!=(i=this.options.tabSize)?i:4,{state:r}=e,{selection:s}=r,{$from:o,empty:a}=s;return o.parent.type===this.type&&(a?e.commands.command(({tr:e})=>{var i;let{pos:s}=o,a=o.start(),l=o.end(),c=r.doc.textBetween(a,l,"\n","\n").split("\n"),h=0,d=0,u=s-a;for(let e=0;e<c.length;e+=1){if(d+c[e].length>=u){h=e;break}d+=c[e].length+1}let p=Math.min(((null==(i=c[h].match(/^ */))?void 0:i[0])||"").length,n);if(0===p)return!0;let f=a;for(let e=0;e<h;e+=1)f+=c[e].length+1;return e.delete(f,f+p),s-f<=p&&e.setSelection(bj.create(e.doc,f)),!0}):e.commands.command(({tr:e})=>{let{from:i,to:o}=s,a=r.doc.textBetween(i,o,"\n","\n").split("\n").map(e=>{var i;let r=Math.min(((null==(i=e.match(/^ */))?void 0:i[0])||"").length,n);return e.slice(r)}).join("\n");return e.replaceWith(i,o,r.schema.text(a)),!0}))},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:i}=e,{selection:n}=i,{$from:r,empty:s}=n;if(!s||r.parent.type!==this.type)return!1;let o=r.parentOffset===r.parent.nodeSize-2,a=r.parent.textContent.endsWith("\n\n");return!!o&&!!a&&e.chain().command(({tr:e})=>(e.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;let{state:i}=e,{selection:n,doc:r}=i,{$from:s,empty:o}=n;if(!o||s.parent.type!==this.type||s.parentOffset!==s.parent.nodeSize-2)return!1;let a=s.after();return void 0!==a&&(r.nodeAt(a)?e.commands.command(({tr:e})=>(e.setSelection(bA.near(r.resolve(a))),!0)):e.commands.exitCode())}}},addInputRules(){return[Td({find:Eb,type:this.type,getAttributes:e=>({language:e[1]})}),Td({find:Ex,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new bX({key:new bZ("codeBlockVSCodeHandler"),props:{handlePaste:(e,i)=>{if(!i.clipboardData||this.editor.isActive(this.type.name))return!1;let n=i.clipboardData.getData("text/plain"),r=i.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,o=null==s?void 0:s.mode;if(!n||!o)return!1;let{tr:a,schema:l}=e.state,c=l.text(n.replace(/\r\n?/g,"\n"));return a.replaceSelectionWith(this.type.create({language:o},c)),a.selection.$from.parent.type!==this.type&&a.setSelection(bj.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta("paste",!0),e.dispatch(a),!0}}})]}}),ES=Tw.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(e,i)=>e.content?i.renderChildren(e.content,"\n\n"):""}),Ek=Tw.create({name:"hardBreak",markdownTokenName:"br",addOptions:()=>({keepMarks:!0,HTMLAttributes:{}}),inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML:()=>[{tag:"br"}],renderHTML({HTMLAttributes:e}){return["br",Cs(this.options.HTMLAttributes,e)]},renderText:()=>"\n",renderMarkdown:()=>`
|
|
110
|
+
`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:e,chain:i,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{let{selection:e,storedMarks:s}=n;if(e.$from.parent.type.spec.isolating)return!1;let{keepMarks:o}=this.options,{splittableMarks:a}=r.extensionManager,l=s||e.$to.parentOffset&&e.$from.marks();return i().insertContent({type:this.name}).command(({tr:e,dispatch:i})=>{if(i&&l&&o){let i=l.filter(e=>a.includes(e.type.name));e.ensureMarks(i)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),EC=Tw.create({name:"heading",addOptions:()=>({levels:[1,2,3,4,5,6],HTMLAttributes:{}}),content:"inline*",group:"block",defining:!0,addAttributes:()=>({level:{default:1,rendered:!1}}),parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:i}){let n=this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0];return[`h${n}`,Cs(this.options.HTMLAttributes,i),0]},parseMarkdown:(e,i)=>i.createNode("heading",{level:e.depth||1},i.parseInline(e.tokens||[])),renderMarkdown:(e,i)=>{var n;let r=(null==(n=e.attrs)?void 0:n.level)?parseInt(e.attrs.level,10):1,s="#".repeat(r);return e.content?`${s} ${i.renderChildren(e.content)}`:""},addCommands(){return{setHeading:e=>({commands:i})=>!!this.options.levels.includes(e.level)&&i.setNode(this.name,e),toggleHeading:e=>({commands:i})=>!!this.options.levels.includes(e.level)&&i.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return this.options.levels.reduce((e,i)=>({...e,...{[`Mod-Alt-${i}`]:()=>this.editor.commands.toggleHeading({level:i})}}),{})},addInputRules(){return this.options.levels.map(e=>Td({find:RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),ET=Tw.create({name:"horizontalRule",addOptions:()=>({HTMLAttributes:{},nextNodeType:"paragraph"}),group:"block",parseHTML:()=>[{tag:"hr"}],renderHTML({HTMLAttributes:e}){return["hr",Cs(this.options.HTMLAttributes,e)]},markdownTokenName:"hr",parseMarkdown:(e,i)=>i.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:e,state:i})=>{if(!function(e,i){let{selection:n}=e,{$from:r}=n;if(n instanceof bP){let e=r.index();return r.parent.canReplaceWith(e,e+1,i)}let s=r.depth;for(;s>=0;){let e=r.index(s);if(r.node(s).contentMatchAt(e).matchType(i))return!0;s-=1}return!1}(i,i.schema.nodes[this.name]))return!1;let{selection:n}=i,{$to:r}=n,s=e();return CS(n)?s.insertContentAt(r.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({state:e,tr:i,dispatch:n})=>{if(n){let{$to:n}=i.selection,r=n.end();if(n.nodeAfter)n.nodeAfter.isTextblock?i.setSelection(bj.create(i.doc,n.pos+1)):n.nodeAfter.isBlock?i.setSelection(bP.create(i.doc,n.pos)):i.setSelection(bj.create(i.doc,n.pos));else{let s=e.schema.nodes[this.options.nextNodeType]||n.parent.type.contentMatch.defaultType,o=null==s?void 0:s.create();o&&(i.insert(r,o),i.setSelection(bj.create(i.doc,r+1)))}i.scrollIntoView()}return!0}).run()}}},addInputRules(){var e;return[new CG({find:(e={find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type}).find,handler:({state:i,range:n,match:r})=>{let s=Ct(e.getAttributes,void 0,r)||{},{tr:o}=i,a=n.from,l=n.to,c=e.type.create(s);if(r[1]){let e=a+r[0].lastIndexOf(r[1]);e>l?e=l:l=e+r[1].length;let i=r[0][r[0].length-1];o.insertText(i,a+r[0].length-1),o.replaceWith(e,l,c)}else if(r[0]){let i=e.type.isInline?a:a-1;o.insert(i,e.type.create(s)).delete(o.mapping.map(a),o.mapping.map(l))}o.scrollIntoView()},undoable:e.undoable})]}}),EE=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,EN=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,EM=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,EO=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,EA=C1.create({name:"italic",addOptions:()=>({HTMLAttributes:{}}),parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:e=>"normal"!==e.style.fontStyle&&null},{style:"font-style=normal",clearMark:e=>e.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:e}){return["em",Cs(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(e,i)=>i.applyMark("italic",i.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:"<em>",close:"</em>"}},renderMarkdown:(e,i)=>`*${i.renderChildren(e)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Th({find:EE,type:this.type}),Th({find:EM,type:this.type})]},addPasteRules(){return[TS({find:EN,type:this.type}),TS({find:EO,type:this.type})]}});let ER="numeric",ED="ascii",EL="alpha",Ej="asciinumeric",EI="alphanumeric",EP="domain",EB="emoji",Ez="whitespace";function EF(e,i,n){for(let r in i[ER]&&(i[Ej]=!0,i[EI]=!0),i[ED]&&(i[Ej]=!0,i[EL]=!0),i[Ej]&&(i[EI]=!0),i[EL]&&(i[EI]=!0),i[EI]&&(i[EP]=!0),i[EB]&&(i[EP]=!0),i){let i=(r in n||(n[r]=[]),n[r]);0>i.indexOf(e)&&i.push(e)}}function EW(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}EW.groups={},EW.prototype={accepts(){return!!this.t},go(e){let i=this.j[e];if(i)return i;for(let i=0;i<this.jr.length;i++){let n=this.jr[i][0],r=this.jr[i][1];if(r&&n.test(e))return r}return this.jd},has(e,i=!1){return i?e in this.j:!!this.go(e)},ta(e,i,n,r){for(let s=0;s<e.length;s++)this.tt(e[s],i,n,r)},tr(e,i,n,r){let s;return r=r||EW.groups,i&&i.j?s=i:(s=new EW(i),n&&r&&EF(i,n,r)),this.jr.push([e,s]),s},ts(e,i,n,r){let s=this,o=e.length;if(!o)return s;for(let i=0;i<o-1;i++)s=s.tt(e[i]);return s.tt(e[o-1],i,n,r)},tt(e,i,n,r){if(r=r||EW.groups,i&&i.j)return this.j[e]=i,i;let s,o=this.go(e);return o?(Object.assign((s=new EW).j,o.j),s.jr.push.apply(s.jr,o.jr),s.jd=o.jd,s.t=o.t):s=new EW,i&&(r&&(s.t&&"string"==typeof s.t?EF(i,Object.assign(function(e,i){let n={};for(let r in i)i[r].indexOf(e)>=0&&(n[r]=!0);return n}(s.t,r),n),r):n&&EF(i,n,r)),s.t=i),this.j[e]=s,s}};let EH=(e,i,n,r,s)=>e.ta(i,n,r,s),E$=(e,i,n,r,s)=>e.tr(i,n,r,s),EU=(e,i,n,r,s)=>e.ts(i,n,r,s),EV=(e,i,n,r,s)=>e.tt(i,n,r,s),Eq="WORD",EY="UWORD",EK="ASCIINUMERICAL",EX="ALPHANUMERICAL",EJ="LOCALHOST",EG="UTLD",EZ="SCHEME",EQ="SLASH_SCHEME",E0="OPENBRACE",E1="CLOSEBRACE",E2="OPENBRACKET",E5="CLOSEBRACKET",E3="OPENPAREN",E4="CLOSEPAREN",E6="OPENANGLEBRACKET",E8="CLOSEANGLEBRACKET",E9="FULLWIDTHLEFTPAREN",E7="FULLWIDTHRIGHTPAREN",Ne="LEFTCORNERBRACKET",Nt="RIGHTCORNERBRACKET",Ni="LEFTWHITECORNERBRACKET",Nn="RIGHTWHITECORNERBRACKET",Nr="FULLWIDTHLESSTHAN",Ns="FULLWIDTHGREATERTHAN",No="AMPERSAND",Na="APOSTROPHE",Nl="ASTERISK",Nc="BACKSLASH",Nh="BACKTICK",Nd="CARET",Nu="COLON",Np="COMMA",Nf="DOLLAR",Nm="EQUALS",Ng="EXCLAMATION",Nv="HYPHEN",Ny="PERCENT",N_="PIPE",Nb="PLUS",Nx="POUND",Nw="QUERY",NS="QUOTE",Nk="FULLWIDTHMIDDLEDOT",NC="SEMI",NT="SLASH",NE="TILDE",NN="UNDERSCORE",NM="EMOJI";var NO=Object.freeze({__proto__:null,ALPHANUMERICAL:EX,AMPERSAND:No,APOSTROPHE:Na,ASCIINUMERICAL:EK,ASTERISK:Nl,AT:"AT",BACKSLASH:Nc,BACKTICK:Nh,CARET:Nd,CLOSEANGLEBRACKET:E8,CLOSEBRACE:E1,CLOSEBRACKET:E5,CLOSEPAREN:E4,COLON:Nu,COMMA:Np,DOLLAR:Nf,DOT:"DOT",EMOJI:NM,EQUALS:Nm,EXCLAMATION:Ng,FULLWIDTHGREATERTHAN:Ns,FULLWIDTHLEFTPAREN:E9,FULLWIDTHLESSTHAN:Nr,FULLWIDTHMIDDLEDOT:Nk,FULLWIDTHRIGHTPAREN:E7,HYPHEN:Nv,LEFTCORNERBRACKET:Ne,LEFTWHITECORNERBRACKET:Ni,LOCALHOST:EJ,NL:"NL",NUM:"NUM",OPENANGLEBRACKET:E6,OPENBRACE:E0,OPENBRACKET:E2,OPENPAREN:E3,PERCENT:Ny,PIPE:N_,PLUS:Nb,POUND:Nx,QUERY:Nw,QUOTE:NS,RIGHTCORNERBRACKET:Nt,RIGHTWHITECORNERBRACKET:Nn,SCHEME:EZ,SEMI:NC,SLASH:NT,SLASH_SCHEME:EQ,SYM:"SYM",TILDE:NE,TLD:"TLD",UNDERSCORE:NN,UTLD:EG,UWORD:EY,WORD:Eq,WS:"WS"});let NA=/[a-z]/,NR=/\p{L}/u,ND=/\p{Emoji}/u,NL=/\d/,Nj=/\s/,NI=null,NP=null;function NB(e,i){let n=function(e){let i=[],n=e.length,r=0;for(;r<n;){let s,o=e.charCodeAt(r),a=o<55296||o>56319||r+1===n||(s=e.charCodeAt(r+1))<56320||s>57343?e[r]:e.slice(r,r+2);i.push(a),r+=a.length}return i}(i.replace(/[A-Z]/g,e=>e.toLowerCase())),r=n.length,s=[],o=0,a=0;for(;a<r;){let l=e,c=null,h=0,d=null,u=-1,p=-1;for(;a<r&&(c=l.go(n[a]));)(l=c).accepts()?(u=0,p=0,d=l):u>=0&&(u+=n[a].length,p++),h+=n[a].length,o+=n[a].length,a++;o-=u,a-=p,h-=u,s.push({t:d.t,v:i.slice(o-h,o),s:o-h,e:o})}return s}function Nz(e,i,n,r,s){let o,a=i.length;for(let n=0;n<a-1;n++){let a=i[n];e.j[a]?o=e.j[a]:((o=new EW(r)).jr=s.slice(),e.j[a]=o),e=o}return(o=new EW(n)).jr=s.slice(),e.j[i[a-1]]=o,o}function NF(e){let i=[],n=[],r=0;for(;r<e.length;){let s=0;for(;"0123456789".indexOf(e[r+s])>=0;)s++;if(s>0){i.push(n.join(""));for(let i=parseInt(e.substring(r,r+s),10);i>0;i--)n.pop();r+=s}else n.push(e[r]),r++}return i}let NW={defaultProtocol:"http",events:null,format:N$,formatHref:N$,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function NH(e,i=null){let n=Object.assign({},NW);e&&(n=Object.assign(n,e instanceof NH?e.o:e));let r=n.ignoreTags,s=[];for(let e=0;e<r.length;e++)s.push(r[e].toUpperCase());this.o=n,i&&(this.defaultRender=i),this.ignoreTags=s}function N$(e){return e}function NU(e,i){this.t="token",this.v=e,this.tk=i}function NV(e,i){class n extends NU{constructor(i,n){super(i,n),this.t=e}}for(let e in i)n.prototype[e]=i[e];return n.t=e,n}NH.prototype={o:NW,ignoreTags:[],defaultRender:e=>e,check(e){return this.get("validate",e.toString(),e)},get(e,i,n){let r=null!=i,s=this.o[e];return s&&("object"==typeof s?"function"==typeof(s=n.t in s?s[n.t]:NW[e])&&r&&(s=s(i,n)):"function"==typeof s&&r&&(s=s(i,n.t,n))),s},getObj(e,i,n){let r=this.o[e];return"function"==typeof r&&null!=i&&(r=r(i,n.t,n)),r},render(e){let i=e.render(this);return(this.get("render",null,e)||this.defaultRender)(i,e.t,e)}},NU.prototype={isLink:!1,toString(){return this.v},toHref(e){return this.toString()},toFormattedString(e){let i=this.toString(),n=e.get("truncate",i,this),r=e.get("format",i,this);return n&&r.length>n?r.substring(0,n)+"…":r},toFormattedHref(e){return e.get("formatHref",this.toHref(e.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(e=NW.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(e),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(e){return{type:this.t,value:this.toFormattedString(e),isLink:this.isLink,href:this.toFormattedHref(e),start:this.startIndex(),end:this.endIndex()}},validate(e){return e.get("validate",this.toString(),this)},render(e){let i=this.toHref(e.get("defaultProtocol")),n=e.get("formatHref",i,this),r=e.get("tagName",i,this),s=this.toFormattedString(e),o={},a=e.get("className",i,this),l=e.get("target",i,this),c=e.get("rel",i,this),h=e.getObj("attributes",i,this),d=e.getObj("events",i,this);return o.href=n,a&&(o.class=a),l&&(o.target=l),c&&(o.rel=c),h&&Object.assign(o,h),{tagName:r,attributes:o,content:s,eventListeners:d}}};let Nq=NV("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),NY=NV("text"),NK=NV("nl"),NX=NV("url",{isLink:!0,toHref(e=NW.defaultProtocol){return this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){let e=this.tk;return e.length>=2&&e[0].t!==EJ&&e[1].t===Nu}}),NJ=e=>new EW(e);function NG(e,i,n){let r=n[0].s,s=n[n.length-1].e;return new e(i.slice(r,s),n)}let NZ="u">typeof console&&console&&console.warn||(()=>{}),NQ={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function N0(e,i=!1){if(NQ.initialized&&NZ(`linkifyjs: already initialized - will not register custom scheme "${e}" until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(e))throw Error(`linkifyjs: incorrect scheme format.
|
|
111
|
+
1. Must only contain digits, lowercase ASCII letters or "-"
|
|
112
|
+
2. Cannot start or end with "-"
|
|
113
|
+
3. "-" cannot repeat`);NQ.customSchemes.push([e,i])}function N1(e){return NQ.initialized||function(){NQ.scanner=function(e=[]){let i={};EW.groups=i;let n=new EW;null==NI&&(NI=NF("aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2")),null==NP&&(NP=NF("ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2")),EV(n,"'",Na),EV(n,"{",E0),EV(n,"}",E1),EV(n,"[",E2),EV(n,"]",E5),EV(n,"(",E3),EV(n,")",E4),EV(n,"<",E6),EV(n,">",E8),EV(n,"(",E9),EV(n,")",E7),EV(n,"「",Ne),EV(n,"」",Nt),EV(n,"『",Ni),EV(n,"』",Nn),EV(n,"<",Nr),EV(n,">",Ns),EV(n,"&",No),EV(n,"*",Nl),EV(n,"@","AT"),EV(n,"`",Nh),EV(n,"^",Nd),EV(n,":",Nu),EV(n,",",Np),EV(n,"$",Nf),EV(n,".","DOT"),EV(n,"=",Nm),EV(n,"!",Ng),EV(n,"-",Nv),EV(n,"%",Ny),EV(n,"|",N_),EV(n,"+",Nb),EV(n,"#",Nx),EV(n,"?",Nw),EV(n,'"',NS),EV(n,"/",NT),EV(n,";",NC),EV(n,"~",NE),EV(n,"_",NN),EV(n,"\\",Nc),EV(n,"・",Nk);let r=E$(n,NL,"NUM",{[ER]:!0});E$(r,NL,r);let s=E$(r,NA,EK,{[Ej]:!0}),o=E$(r,NR,EX,{[EI]:!0}),a=E$(n,NA,Eq,{[ED]:!0});E$(a,NL,s),E$(a,NA,a),E$(s,NL,s),E$(s,NA,s);let l=E$(n,NR,EY,{[EL]:!0});E$(l,NA),E$(l,NL,o),E$(l,NR,l),E$(o,NL,o),E$(o,NA),E$(o,NR,o);let c=EV(n,"\n","NL",{[Ez]:!0}),h=EV(n,"\r","WS",{[Ez]:!0}),d=E$(n,Nj,"WS",{[Ez]:!0});EV(n,"",d),EV(h,"\n",c),EV(h,"",d),E$(h,Nj,d),EV(d,"\r"),EV(d,"\n"),E$(d,Nj,d),EV(d,"",d);let u=E$(n,ND,NM,{[EB]:!0});EV(u,"#"),E$(u,ND,u),EV(u,"️",u);let p=EV(u,"");EV(p,"#"),E$(p,ND,u);let f=[[NA,a],[NL,s]],m=[[NA,null],[NR,l],[NL,o]];for(let e=0;e<NI.length;e++)Nz(n,NI[e],"TLD",Eq,f);for(let e=0;e<NP.length;e++)Nz(n,NP[e],EG,EY,m);EF("TLD",{tld:!0,ascii:!0},i),EF(EG,{utld:!0,alpha:!0},i),Nz(n,"file",EZ,Eq,f),Nz(n,"mailto",EZ,Eq,f),Nz(n,"http",EQ,Eq,f),Nz(n,"https",EQ,Eq,f),Nz(n,"ftp",EQ,Eq,f),Nz(n,"ftps",EQ,Eq,f),EF(EZ,{scheme:!0,ascii:!0},i),EF(EQ,{slashscheme:!0,ascii:!0},i),e=e.sort((e,i)=>e[0]>i[0]?1:-1);for(let i=0;i<e.length;i++){let r=e[i][0],s=e[i][1]?{scheme:!0}:{slashscheme:!0};r.indexOf("-")>=0?s[EP]=!0:NA.test(r)?NL.test(r)?s[Ej]=!0:s[ED]=!0:s[ER]=!0,EU(n,r,r,s)}return EU(n,"localhost",EJ,{ascii:!0}),n.jd=new EW("SYM"),{start:n,tokens:Object.assign({groups:i},NO)}}(NQ.customSchemes);for(let e=0;e<NQ.tokenQueue.length;e++)NQ.tokenQueue[e][1]({scanner:NQ.scanner});NQ.parser=function({groups:e}){let i=e.domain.concat([No,Nl,"AT",Nc,Nh,Nd,Nf,Nm,Nv,"NUM",Ny,N_,Nb,Nx,NT,"SYM",NE,NN]),n=[Na,Nu,Np,"DOT",Ng,Ny,Nw,NS,NC,E6,E8,E0,E1,E5,E2,E3,E4,E9,E7,Ne,Nt,Ni,Nn,Nr,Ns],r=[No,Na,Nl,Nc,Nh,Nd,Nf,Nm,Nv,E0,E1,Ny,N_,Nb,Nx,Nw,NT,"SYM",NE,NN],s=NJ(),o=EV(s,NE);EH(o,r,o),EH(o,e.domain,o);let a=NJ(),l=NJ(),c=NJ();EH(s,e.domain,a),EH(s,e.scheme,l),EH(s,e.slashscheme,c),EH(a,r,o),EH(a,e.domain,a);let h=EV(a,"AT");EV(o,"AT",h),EV(l,"AT",h),EV(c,"AT",h);let d=EV(o,"DOT");EH(d,r,o),EH(d,e.domain,o);let u=NJ();EH(h,e.domain,u),EH(u,e.domain,u);let p=EV(u,"DOT");EH(p,e.domain,u);let f=NJ(Nq);EH(p,e.tld,f),EH(p,e.utld,f),EV(h,EJ,f);let m=EV(u,Nv);EV(m,Nv,m),EH(m,e.domain,u),EH(f,e.domain,u),EV(f,"DOT",p),EV(f,Nv,m),EH(EV(f,Nu),e.numeric,Nq);let g=EV(a,Nv),v=EV(a,"DOT");EV(g,Nv,g),EH(g,e.domain,a),EH(v,r,o),EH(v,e.domain,a);let y=NJ(NX);EH(v,e.tld,y),EH(v,e.utld,y),EH(y,e.domain,a),EH(y,r,o),EV(y,"DOT",v),EV(y,Nv,g),EV(y,"AT",h);let _=EV(y,Nu),b=NJ(NX);EH(_,e.numeric,b);let w=NJ(NX),S=NJ();EH(w,i,w),EH(w,n,S),EH(S,i,w),EH(S,n,S),EV(y,NT,w),EV(b,NT,w);let k=EV(l,Nu),C=EV(c,Nu),T=EV(C,NT),E=EV(T,NT);EH(l,e.domain,a),EV(l,"DOT",v),EV(l,Nv,g),EH(c,e.domain,a),EV(c,"DOT",v),EV(c,Nv,g),EH(k,e.domain,w),EV(k,NT,w),EV(k,Nw,w),EH(E,e.domain,w),EH(E,i,w),EV(E,NT,w);let N=[[E0,E1],[E2,E5],[E3,E4],[E6,E8],[E9,E7],[Ne,Nt],[Ni,Nn],[Nr,Ns]];for(let e=0;e<N.length;e++){let[r,s]=N[e],o=EV(w,r);EV(S,r,o),EV(o,s,w);let a=NJ(NX);EH(o,i,a);let l=NJ();EH(o,n),EH(a,i,a),EH(a,n,l),EH(l,i,a),EH(l,n,l),EV(a,s,w),EV(l,s,w)}return EV(s,EJ,y),EV(s,"NL",NK),{start:s,tokens:NO}}(NQ.scanner.tokens);for(let e=0;e<NQ.pluginQueue.length;e++)NQ.pluginQueue[e][1]({scanner:NQ.scanner,parser:NQ.parser});NQ.initialized=!0}(),function(e,i,n){let r=n.length,s=0,o=[],a=[];for(;s<r;){let l=e,c=null,h=null,d=0,u=null,p=-1;for(;s<r&&!(c=l.go(n[s].t));)a.push(n[s++]);for(;s<r&&(h=c||l.go(n[s].t));)c=null,(l=h).accepts()?(p=0,u=l):p>=0&&p++,s++,d++;if(p<0)(s-=d)<r&&(a.push(n[s]),s++);else{a.length>0&&(o.push(NG(NY,i,a)),a=[]),s-=p,d-=p;let e=u.t,r=n.slice(s-d,s);o.push(NG(e,i,r))}}return a.length>0&&o.push(NG(NY,i,a)),o}(NQ.parser.start,e,NB(NQ.scanner.start,e))}function N2(e,i=null,n=null){if(i&&"object"==typeof i){if(n)throw Error(`linkifyjs: Invalid link type ${i}; must be a string`);n=i,i=null}let r=new NH(n),s=N1(e),o=[];for(let e=0;e<s.length;e++){let n=s[e];n.isLink&&(!i||n.t===i)&&r.check(n)&&o.push(n.toFormattedObject(r))}return o}N1.scan=NB;var N5="[\0- -\u2029 ]",N3=new RegExp(N5),N4=RegExp(`${N5}$`),N6=RegExp(N5,"g");function N8(e,i){let n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return i&&i.forEach(e=>{let i="string"==typeof e?e:e.scheme;i&&n.push(i)}),!e||e.replace(N6,"").match(RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var N9=C1.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(e=>{"string"==typeof e?N0(e):N0(e.scheme,e.optionalSlashes)})},onDestroy(){EW.groups={},NQ.scanner=null,NQ.parser=null,NQ.tokenQueue=[],NQ.pluginQueue=[],NQ.customSchemes=[],NQ.initialized=!1},inclusive(){return this.options.autolink},addOptions:()=>({openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(e,i)=>!!N8(e,i.protocols),validate:e=>!!e,shouldAutoLink:e=>{let i=/^[a-z][a-z0-9+.-]*:\/\//i.test(e),n=/^[a-z][a-z0-9+.-]*:/i.test(e);if(i||n&&!e.includes("@"))return!0;let r=(e.includes("@")?e.split("@").pop():e).split(/[/?#:]/)[0];return!/^\d{1,3}(\.\d{1,3}){3}$/.test(r)&&!!/\./.test(r)}}),addAttributes(){return{href:{default:null,parseHTML:e=>e.getAttribute("href")},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:e=>{let i=e.getAttribute("href");return!!i&&!!this.options.isAllowedUri(i,{defaultValidate:e=>!!N8(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})&&null}}]},renderHTML({HTMLAttributes:e}){return this.options.isAllowedUri(e.href,{defaultValidate:e=>!!N8(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Cs(this.options.HTMLAttributes,e),0]:["a",Cs(this.options.HTMLAttributes,{...e,href:""}),0]},markdownTokenName:"link",parseMarkdown:(e,i)=>i.applyMark("link",i.parseInline(e.tokens||[]),{href:e.href,title:e.title||null}),renderMarkdown:(e,i)=>{var n,r,s,o;let a=null!=(r=null==(n=e.attrs)?void 0:n.href)?r:"",l=null!=(o=null==(s=e.attrs)?void 0:s.title)?o:"",c=i.renderChildren(e);return l?`[${c}](${a} "${l}")`:`[${c}](${a})`},addCommands(){return{setLink:e=>({chain:i})=>{let{href:n}=e;return!!this.options.isAllowedUri(n,{defaultValidate:e=>!!N8(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})&&i().setMark(this.name,e).setMeta("preventAutolink",!0).run()},toggleLink:e=>({chain:i})=>{let{href:n}=e||{};return(!n||!!this.options.isAllowedUri(n,{defaultValidate:e=>!!N8(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}))&&i().toggleMark(this.name,e,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[TS({find:e=>{let i=[];if(e){let{protocols:n,defaultProtocol:r}=this.options,s=N2(e).filter(e=>e.isLink&&this.options.isAllowedUri(e.value,{defaultValidate:e=>!!N8(e,n),protocols:n,defaultProtocol:r}));s.length&&s.forEach(e=>{this.options.shouldAutoLink(e.value)&&i.push({text:e.value,data:{href:e.href},index:e.start})})}return i},type:this.type,getAttributes:e=>{var i;return{href:null==(i=e.data)?void 0:i.href}}})]},addProseMirrorPlugins(){var e,i,n;let r=[],{protocols:s,defaultProtocol:o}=this.options;return this.options.autolink&&r.push((e={type:this.type,defaultProtocol:this.options.defaultProtocol,validate:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!N8(e,s),protocols:s,defaultProtocol:o}),shouldAutoLink:this.options.shouldAutoLink},new bX({key:new bZ("autolink"),appendTransaction:(i,n,r)=>{let s=i.some(e=>e.docChanged)&&!n.doc.eq(r.doc),o=i.some(e=>e.getMeta("preventAutolink"));if(!s||o)return;let{tr:a}=r;if(Cm(k4(n.doc,[...i])).forEach(({newRange:i})=>{var n,s;let o,l,c,h=(n=r.doc,s=e=>e.isTextblock,c=[],n.nodesBetween(i.from,i.to,(e,i)=>{s(e)&&c.push({node:e,pos:i})}),c);if(h.length>1)o=h[0],l=r.doc.textBetween(o.pos,o.pos+o.node.nodeSize,void 0," ");else if(h.length){let e=r.doc.textBetween(i.from,i.to," "," ");if(!N4.test(e))return;o=h[0],l=r.doc.textBetween(o.pos,i.to,void 0," ")}if(o&&l){let i=l.split(N3).filter(Boolean);if(i.length<=0)return!1;let n=i[i.length-1],s=o.pos+l.lastIndexOf(n);if(!n)return!1;let c=N1(n).map(i=>i.toObject(e.defaultProtocol));if(!(1===c.length?c[0].isLink:3===c.length&&!!c[1].isLink&&["()","[]"].includes(c[0].value+c[2].value)))return!1;c.filter(e=>e.isLink).map(e=>({...e,from:s+e.start+1,to:s+e.end+1})).filter(e=>!r.schema.marks.code||!r.doc.rangeHasMark(e.from,e.to,r.schema.marks.code)).filter(i=>e.validate(i.value)).filter(i=>e.shouldAutoLink(i.value)).forEach(i=>{Cg(i.from,i.to,r.doc).some(i=>i.mark.type===e.type)||a.addMark(i.from,i.to,e.type.create({href:i.href}))})}}),a.steps.length)return a}}))),r.push((i={type:this.type,editor:this.editor,openOnClick:"whenNotEditable"===this.options.openOnClick||this.options.openOnClick,enableClickSelection:this.options.enableClickSelection},new bX({key:new bZ("handleClickLink"),props:{handleClick:(e,n,r)=>{var s,o;if(0!==r.button||!e.editable)return!1;let a=null;if(r.target instanceof HTMLAnchorElement)a=r.target;else{let e=r.target;if(!e)return!1;let n=i.editor.view.dom;(a=e.closest("a"))&&!n.contains(a)&&(a=null)}if(!a)return!1;let l=!1;if(i.enableClickSelection&&(l=i.editor.commands.extendMarkRange(i.type.name)),i.openOnClick){let n=Cf(e.state,i.type.name),r=null!=(s=a.href)?s:n.href,c=null!=(o=a.target)?o:n.target;r&&(window.open(r,c),l=!0)}return l}}}))),this.options.linkOnPaste&&r.push((n={editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink},new bX({key:new bZ("handlePasteLink"),props:{handlePaste:(e,i,r)=>{let{shouldAutoLink:s}=n,{state:o}=e,{selection:a}=o,{empty:l}=a;if(l)return!1;let c="";r.content.forEach(e=>{c+=e.textContent});let h=N2(c,{defaultProtocol:n.defaultProtocol}).find(e=>e.isLink&&e.value===c);return!!c&&!!h&&(void 0===s||!!s(h.value))&&n.editor.commands.setMark(n.type,{href:h.href})}}}))),r}}),N7=Object.defineProperty,Me="textStyle",Mt=/^\s*([-+*])\s$/,Mi=Tw.create({name:"bulletList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML:()=>[{tag:"ul"}],renderHTML({HTMLAttributes:e}){return["ul",Cs(this.options.HTMLAttributes,e),0]},markdownTokenName:"list",parseMarkdown:(e,i)=>"list"!==e.type||e.ordered?[]:{type:"bulletList",content:e.items?i.parseChildren(e.items):[]},renderMarkdown:(e,i)=>e.content?i.renderChildren(e.content,"\n"):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:e,chain:i})=>this.options.keepAttributes?i().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes("listItem",this.editor.getAttributes(Me)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=Tu({find:Mt,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=Tu({find:Mt,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Me),editor:this.editor})),[e]}}),Mn=Tw.create({name:"listItem",addOptions:()=>({HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}),content:"paragraph block*",defining:!0,parseHTML:()=>[{tag:"li"}],renderHTML({HTMLAttributes:e}){return["li",Cs(this.options.HTMLAttributes,e),0]},markdownTokenName:"list_item",parseMarkdown:(e,i)=>{var n;if("list_item"!==e.type)return[];let r=null!=(n=i.parseBlockChildren)?n:i.parseChildren,s=[];if(e.tokens&&e.tokens.length>0)if(e.tokens.some(e=>"paragraph"===e.type))s=r(e.tokens);else{let n=e.tokens[0];if(n&&"text"===n.type&&n.tokens&&n.tokens.length>0){if(s=[{type:"paragraph",content:i.parseInline(n.tokens)}],e.tokens.length>1){let i=r(e.tokens.slice(1));s.push(...i)}}else s=r(e.tokens)}return 0===s.length&&(s=[{type:"paragraph",content:[]}]),{type:"listItem",content:s}},renderMarkdown:(e,i,n)=>Tx(e,i,e=>{var i,n;if("bulletList"===e.parentType)return"- ";if("orderedList"===e.parentType){let r=(null==(n=null==(i=e.meta)?void 0:i.parentAttrs)?void 0:n.start)||1;return`${r+e.index}. `}return"- "},n),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Mr={},Ms={findListItemPos:()=>Ma,getNextListDepth:()=>Ml,handleBackspace:()=>Mu,handleDelete:()=>Mm,hasListBefore:()=>Mc,hasListItemAfter:()=>Mg,hasListItemBefore:()=>Mh,listItemHasSubList:()=>Md,nextListIsDeeper:()=>Mp,nextListIsHigher:()=>Mf};for(var Mo in Ms)N7(Mr,Mo,{get:Ms[Mo],enumerable:!0});var Ma=(e,i)=>{let{$from:n}=i.selection,r=ks(e,i.schema),s=n.depth,o=n.pos,a=null;for(;s>0&&null===a;)n.node(s).type===r?a=s:(s-=1,o-=1);return null===a?null:{$pos:i.doc.resolve(o),depth:a}},Ml=(e,i)=>{let n=Ma(e,i);if(!n)return!1;let[,r]=((e,i,n,r=20)=>{let s=e.doc.resolve(n),o=r,a=null;for(;o>0&&null===a;){let e=s.node(o);(null==e?void 0:e.type.name)===i?a=e:o-=1}return[a,o]})(i,e,n.$pos.pos+4);return r},Mc=(e,i,n)=>{let{$anchor:r}=e.selection,s=Math.max(0,r.pos-2),o=e.doc.resolve(s).node();return!!o&&!!n.includes(o.type.name)},Mh=(e,i)=>{var n;let{$anchor:r}=i.selection,s=i.doc.resolve(r.pos-2);return 0!==s.index()&&(null==(n=s.nodeBefore)?void 0:n.type.name)===e},Md=(e,i,n)=>{if(!n)return!1;let r=ks(e,i.schema),s=!1;return n.descendants(e=>{e.type===r&&(s=!0)}),s},Mu=(e,i,n)=>{if(e.commands.undoInputRule())return!0;if(e.state.selection.from!==e.state.selection.to)return!1;if(!kW(e.state,i)&&Mc(e.state,i,n)){let{$anchor:n}=e.state.selection,r=e.state.doc.resolve(n.before()-1),s=[];r.node().descendants((e,n)=>{e.type.name===i&&s.push({node:e,pos:n})});let o=s.at(-1);if(!o)return!1;let a=e.state.doc.resolve(r.start()+o.pos+1);return e.chain().cut({from:n.start()-1,to:n.end()+1},a.end()).joinForward().run()}if(!kW(e.state,i)||!(e=>{let{$from:i,$to:n}=e.selection;return!(i.parentOffset>0)&&i.pos===n.pos})(e.state))return!1;let r=Ma(i,e.state);if(!r)return!1;let s=e.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=Md(i,e.state,s);return Mh(i,e.state)&&!o?e.commands.joinItemBackward():e.chain().liftListItem(i).run()},Mp=(e,i)=>{let n=Ml(e,i),r=Ma(e,i);return!!r&&!!n&&n>r.depth},Mf=(e,i)=>{let n=Ml(e,i),r=Ma(e,i);return!!r&&!!n&&n<r.depth},Mm=(e,i)=>{if(!kW(e.state,i)||!((e,i)=>{let{$from:n,$to:r,$anchor:s}=e.selection;if(i){let n=k6(e=>e.type.name===i)(e.selection);if(!n)return!1;let r=e.doc.resolve(n.pos+1);return s.pos+1===r.end()}return!(r.parentOffset<r.parent.nodeSize-2)&&n.pos===r.pos})(e.state,i))return!1;let{selection:n}=e.state,{$from:r,$to:s}=n;return!(!n.empty&&r.sameParent(s))&&(Mp(i,e.state)?e.chain().focus(e.state.selection.from+4).lift(i).joinBackward().run():Mf(i,e.state)?e.chain().joinForward().joinBackward().run():e.commands.joinItemForward())},Mg=(e,i)=>{var n;let{$anchor:r}=i.selection,s=i.doc.resolve(r.pos-r.parentOffset-2);return s.index()!==s.parent.childCount-1&&(null==(n=s.nodeAfter)?void 0:n.type.name)===e},Mv=C4.create({name:"listKeymap",addOptions:()=>({listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}),addKeyboardShortcuts(){return{Delete:({editor:e})=>{let i=!1;return this.options.listTypes.forEach(({itemName:n})=>{void 0!==e.state.schema.nodes[n]&&Mm(e,n)&&(i=!0)}),i},"Mod-Delete":({editor:e})=>{let i=!1;return this.options.listTypes.forEach(({itemName:n})=>{void 0!==e.state.schema.nodes[n]&&Mm(e,n)&&(i=!0)}),i},Backspace:({editor:e})=>{let i=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{void 0!==e.state.schema.nodes[n]&&Mu(e,n,r)&&(i=!0)}),i},"Mod-Backspace":({editor:e})=>{let i=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{void 0!==e.state.schema.nodes[n]&&Mu(e,n,r)&&(i=!0)}),i}}}}),My=/^(\s*)(\d+)\.\s+(.*)$/,M_=/^\s/,Mb="textStyle",Mx=/^(\d+)\.\s$/,Mw=Tw.create({name:"orderedList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes:()=>({start:{default:1,parseHTML:e=>e.hasAttribute("start")?parseInt(e.getAttribute("start")||"",10):1},type:{default:null,parseHTML:e=>e.getAttribute("type")}}),parseHTML:()=>[{tag:"ol"}],renderHTML({HTMLAttributes:e}){let{start:i,...n}=e;return 1===i?["ol",Cs(this.options.HTMLAttributes,n),0]:["ol",Cs(this.options.HTMLAttributes,e),0]},markdownTokenName:"list",parseMarkdown:(e,i)=>{var n;if("list"!==e.type||!e.ordered)return[];let r=e.start||1,s=e.items?(n=e.items,n.map(e=>{if("list_item"!==e.type)return i.parseChildren([e])[0];let n=[];return e.tokens&&e.tokens.length>0&&e.tokens.forEach(e=>{if("paragraph"===e.type||"list"===e.type||"blockquote"===e.type||"code"===e.type)n.push(...i.parseChildren([e]));else if("text"===e.type&&e.tokens){let r=i.parseChildren([e]);n.push({type:"paragraph",content:r})}else{let r=i.parseChildren([e]);r.length>0&&n.push(...r)}}),{type:"listItem",content:n}})):[];return 1!==r?{type:"orderedList",attrs:{start:r},content:s}:{type:"orderedList",content:s}},renderMarkdown:(e,i)=>e.content?i.renderChildren(e.content,"\n"):"",markdownTokenizer:{name:"orderedList",level:"block",start:e=>{let i=e.match(/^(\s*)(\d+)\.\s+/),n=null==i?void 0:i.index;return void 0!==n?n:-1},tokenize:(e,i,n)=>{var r;let s=e.split("\n"),[o,a]=function(e){let i=[],n=0,r=0;for(;n<e.length;){let s=e[n],o=s.match(My);if(!o)break;let[,a,l,c]=o,h=a.length,d=[c],u=n+1,p=[s],f=!1;for(;u<e.length;){let i=e[u];if(i.match(My))break;if(""===i.trim())p.push(i),d.push(""),f=!0,u+=1;else if(i.match(M_))p.push(i),d.push(i.slice(h+2)),u+=1;else{if(f)break;p.push(i),d.push(i),u+=1}}i.push({indent:h,number:parseInt(l,10),content:d.join("\n").trim(),contentLines:d,raw:p.join("\n")}),r=u,n=u}return[i,r]}(s);if(0===o.length)return;let l=function e(i,n,r){let s=[],o=0;for(;o<i.length;){let a=i[o];if(a.indent===n){let{paragraphLines:l,blockLines:c}=function(e){let i=[],n=[],r=!1;return e.forEach(e=>{let s;if(r)return void n.push(e);if(""===e.trim()||i.length>0&&(s=e.trimStart(),/^[-+*]\s+/.test(s)||/^\d+\.\s+/.test(s)||/^>\s?/.test(s)||/^```/.test(s)||/^~~~/.test(s))){r=!0,n.push(e);return}i.push(e)}),{paragraphLines:i,blockLines:n}}(a.contentLines),h=l.join("\n").trim(),d=[];h&&d.push({type:"paragraph",raw:h,tokens:r.inlineTokens(h)});let u=c.join("\n").trim();if(u){let e=r.blockTokens(u);d.push(...e)}let p=o+1,f=[];for(;p<i.length&&i[p].indent>n;)f.push(i[p]),p+=1;if(f.length>0){let i=Math.min(...f.map(e=>e.indent)),n=e(f,i,r);d.push({type:"list",ordered:!0,start:f[0].number,items:n,raw:f.map(e=>e.raw).join("\n")})}s.push({type:"list_item",raw:a.raw,tokens:d}),o=p}else o+=1}return s}(o,0,n);if(0!==l.length)return{type:"list",ordered:!0,start:(null==(r=o[0])?void 0:r.number)||1,items:l,raw:s.slice(0,a).join("\n")}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:i})=>this.options.keepAttributes?i().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes("listItem",this.editor.getAttributes(Mb)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let e=Tu({find:Mx,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,i)=>i.childCount+i.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(e=Tu({find:Mx,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Mb)}),joinPredicate:(e,i)=>i.childCount+i.attrs.start===+e[1],editor:this.editor})),[e]}}),MS=/^\s*(\[([( |x])?\])\s$/,Mk=Tw.create({name:"taskItem",addOptions:()=>({nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}),content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes:()=>({checked:{default:!1,keepOnSplit:!1,parseHTML:e=>{let i=e.getAttribute("data-checked");return""===i||"true"===i},renderHTML:e=>({"data-checked":e.checked})}}),parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:e,HTMLAttributes:i}){return["li",Cs(this.options.HTMLAttributes,i,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:e.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(e,i)=>{let n=[];if(e.tokens&&e.tokens.length>0?n.push(i.createNode("paragraph",{},i.parseInline(e.tokens))):e.text?n.push(i.createNode("paragraph",{},[i.createNode("text",{text:e.text})])):n.push(i.createNode("paragraph",{},[])),e.nestedTokens&&e.nestedTokens.length>0){let r=i.parseChildren(e.nestedTokens);n.push(...r)}return i.createNode("taskItem",{checked:e.checked||!1},n)},renderMarkdown:(e,i)=>{var n;let r=(null==(n=e.attrs)?void 0:n.checked)?"x":" ";return Tx(e,i,`- [${r}] `)},addKeyboardShortcuts(){let e={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...e,Tab:()=>this.editor.commands.sinkListItem(this.name)}:e},addNodeView(){return({node:e,HTMLAttributes:i,getPos:n,editor:r})=>{let s=document.createElement("li"),o=document.createElement("label"),a=document.createElement("span"),l=document.createElement("input"),c=document.createElement("div"),h=e=>{var i,n;l.ariaLabel=(null==(n=null==(i=this.options.a11y)?void 0:i.checkboxLabel)?void 0:n.call(i,e,l.checked))||`Task item checkbox for ${e.textContent||"empty task item"}`};h(e),o.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",e=>e.preventDefault()),l.addEventListener("change",i=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}let{checked:s}=i.target;r.isEditable&&"function"==typeof n&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:e})=>{let i=n();if("number"!=typeof i)return!1;let r=e.doc.nodeAt(i);return e.setNodeMarkup(i,void 0,{...null==r?void 0:r.attrs,checked:s}),!0}).run(),r.isEditable||!this.options.onReadOnlyChecked||this.options.onReadOnlyChecked(e,s)||(l.checked=!l.checked)}),Object.entries(this.options.HTMLAttributes).forEach(([e,i])=>{s.setAttribute(e,i)}),s.dataset.checked=e.attrs.checked,l.checked=e.attrs.checked,o.append(l,a),s.append(o,c),Object.entries(i).forEach(([e,i])=>{s.setAttribute(e,i)});let d=new Set(Object.keys(i));return{dom:s,contentDOM:c,update:e=>{if(e.type!==this.type)return!1;s.dataset.checked=e.attrs.checked,l.checked=e.attrs.checked,h(e);let i=Co(e,r.extensionManager.attributes),n=new Set(Object.keys(i)),o=this.options.HTMLAttributes;return d.forEach(e=>{n.has(e)||(e in o?s.setAttribute(e,o[e]):s.removeAttribute(e))}),Object.entries(i).forEach(([e,i])=>{null==i?e in o?s.setAttribute(e,o[e]):s.removeAttribute(e):s.setAttribute(e,i)}),d=n,!0}}}},addInputRules(){return[Tu({find:MS,type:this.type,getAttributes:e=>({checked:"x"===e[e.length-1]})})]}}),MC=Tw.create({name:"taskList",addOptions:()=>({itemTypeName:"taskItem",HTMLAttributes:{}}),group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:e}){return["ul",Cs(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},parseMarkdown:(e,i)=>i.createNode("taskList",{},i.parseChildren(e.items||[])),renderMarkdown:(e,i)=>e.content?i.renderChildren(e.content,"\n"):"",markdownTokenizer:{name:"taskList",level:"block",start(e){var i;let n=null==(i=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))?void 0:i.index;return void 0!==n?n:-1},tokenize(e,i,n){let r=e=>{let i=Tb(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:"x"===e[3].toLowerCase()}),createToken:(e,i)=>({type:"taskItem",raw:"",mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:i}),customNestedParser:r},n);return i?[{type:"taskList",raw:i.raw,items:i.items}]:n.blockTokens(e)},s=Tb(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:"x"===e[3].toLowerCase()}),createToken:(e,i)=>({type:"taskItem",raw:"",mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:i}),customNestedParser:r},n);if(s)return{type:"taskList",raw:s.raw,items:s.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});C4.create({name:"listKit",addExtensions(){let e=[];return!1!==this.options.bulletList&&e.push(Mi.configure(this.options.bulletList)),!1!==this.options.listItem&&e.push(Mn.configure(this.options.listItem)),!1!==this.options.listKeymap&&e.push(Mv.configure(this.options.listKeymap)),!1!==this.options.orderedList&&e.push(Mw.configure(this.options.orderedList)),!1!==this.options.taskItem&&e.push(Mk.configure(this.options.taskItem)),!1!==this.options.taskList&&e.push(MC.configure(this.options.taskList)),e}});var MT=" ",ME=Tw.create({name:"paragraph",priority:1e3,addOptions:()=>({HTMLAttributes:{}}),group:"block",content:"inline*",parseHTML:()=>[{tag:"p"}],renderHTML({HTMLAttributes:e}){return["p",Cs(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,i)=>{let n=e.tokens||[];if(1===n.length&&"image"===n[0].type)return i.parseChildren([n[0]]);let r=i.parseInline(n);return 1===n.length&&"text"===n[0].type&&(n[0].raw===MT||n[0].text===MT||" "===n[0].raw||" "===n[0].text)&&1===r.length&&"text"===r[0].type&&(r[0].text===MT||" "===r[0].text)?i.createNode("paragraph",void 0,[]):i.createNode("paragraph",void 0,r)},renderMarkdown:(e,i,n)=>{var r,s;if(!e)return"";let o=Array.isArray(e.content)?e.content:[];if(0===o.length){let e=Array.isArray(null==(r=null==n?void 0:n.previousNode)?void 0:r.content)?n.previousNode.content:[];return(null==(s=null==n?void 0:n.previousNode)?void 0:s.type)==="paragraph"&&0===e.length?MT:""}return i.renderChildren(o)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),MN=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,MM=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,MO=C1.create({name:"strike",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:e=>!!e.includes("line-through")&&{}}],renderHTML({HTMLAttributes:e}){return["s",Cs(this.options.HTMLAttributes,e),0]},markdownTokenName:"del",parseMarkdown:(e,i)=>i.applyMark("strike",i.parseInline(e.tokens||[])),renderMarkdown:(e,i)=>`~~${i.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Th({find:MN,type:this.type})]},addPasteRules(){return[TS({find:MM,type:this.type})]}}),MA=Tw.create({name:"text",group:"inline",parseMarkdown:e=>({type:"text",text:e.text||""}),renderMarkdown:e=>e.text||""}),MR=C1.create({name:"underline",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:e=>!!e.includes("underline")&&{}}],renderHTML({HTMLAttributes:e}){return["u",Cs(this.options.HTMLAttributes,e),0]},parseMarkdown(e,i){return i.applyMark(this.name||"underline",i.parseInline(e.tokens||[]))},renderMarkdown:(e,i)=>`++${i.renderChildren(e)}++`,markdownTokenizer:{name:"underline",level:"inline",start:e=>e.indexOf("++"),tokenize(e,i,n){let r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(e);if(!r)return;let s=r[2].trim();return{type:"underline",raw:r[0],text:s,tokens:n.inlineTokens(s)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});class MD{constructor(e,i){var n;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=null!=(n=i.width)?n:1,this.color=!1===i.color?void 0:i.color||"black",this.class=i.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let n=e=>{this[i](e)};return e.dom.addEventListener(i,n),{name:i,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:i})=>this.editorView.dom.removeEventListener(e,i))}update(e,i){null!=this.cursorPos&&i.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,null==e?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e,i,n=this.editorView.state.doc.resolve(this.cursorPos),r=!n.parent.inlineContent,s,o=this.editorView.dom,a=o.getBoundingClientRect(),l=a.width/o.offsetWidth,c=a.height/o.offsetHeight;if(r){let e=n.nodeBefore,i=n.nodeAfter;if(e||i){let n=this.editorView.nodeDOM(this.cursorPos-(e?e.nodeSize:0));if(n){let r=n.getBoundingClientRect(),o=e?r.bottom:r.top;e&&i&&(o=(o+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let a=this.width/2*c;s={left:r.left,right:r.right,top:o-a,bottom:o+a}}}}if(!s){let e=this.editorView.coordsAtPos(this.cursorPos),i=this.width/2*l;s={left:e.left-i,right:e.left+i,top:e.top,bottom:e.bottom}}let h=this.editorView.dom.offsetParent;if(!this.element&&(this.element=h.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",r),this.element.classList.toggle("prosemirror-dropcursor-inline",!r),h&&(h!=document.body||"static"!=getComputedStyle(h).position)){let n=h.getBoundingClientRect(),r=n.width/h.offsetWidth,s=n.height/h.offsetHeight;e=n.left-h.scrollLeft*r,i=n.top-h.scrollTop*s}else e=-pageXOffset,i=-pageYOffset;this.element.style.left=(s.left-e)/l+"px",this.element.style.top=(s.top-i)/c+"px",this.element.style.width=(s.right-s.left)/l+"px",this.element.style.height=(s.bottom-s.top)/c+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let i=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=i&&i.inside>=0&&this.editorView.state.doc.nodeAt(i.inside),r=n&&n.type.spec.disableDropCursor,s="function"==typeof r?r(this.editorView,i,e):r;if(i&&!s){let e=i.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let i=bv(this.editorView.state.doc,e,this.editorView.dragging.slice);null!=i&&(e=i)}this.setCursor(e),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class ML extends bA{constructor(e){super(e,e)}map(e,i){let n=e.resolve(i.map(this.head));return ML.valid(n)?new ML(n):bA.near(n)}content(){return _p.empty}eq(e){return e instanceof ML&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,i){if("number"!=typeof i.pos)throw RangeError("Invalid input for GapCursor.fromJSON");return new ML(e.resolve(i.pos))}getBookmark(){return new Mj(this.anchor)}static valid(e){let i=e.parent;if(i.inlineContent||!function(e){for(let i=e.depth;i>=0;i--){let n=e.index(i),r=e.node(i);if(0==n){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n-1);;e=e.lastChild){if(0==e.childCount&&!e.inlineContent||MI(e.type))return!0;if(e.inlineContent)return!1}}return!0}(e)||!function(e){for(let i=e.depth;i>=0;i--){let n=e.indexAfter(i),r=e.node(i);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n);;e=e.firstChild){if(0==e.childCount&&!e.inlineContent||MI(e.type))return!0;if(e.inlineContent)return!1}}return!0}(e))return!1;let n=i.type.spec.allowGapCursor;if(null!=n)return n;let r=i.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(e,i,n=!1){n:for(;;){if(!n&&ML.valid(e))return e;let r=e.pos,s=null;for(let n=e.depth;;n--){let o=e.node(n);if(i>0?e.indexAfter(n)<o.childCount:e.index(n)>0){s=o.child(i>0?e.indexAfter(n):e.index(n)-1);break}if(0==n)return null;r+=i;let a=e.doc.resolve(r);if(ML.valid(a))return a}for(;;){let o=i>0?s.firstChild:s.lastChild;if(!o){if(s.isAtom&&!s.isText&&!bP.isSelectable(s)){e=e.doc.resolve(r+s.nodeSize*i),n=!1;continue n}break}s=o,r+=i;let a=e.doc.resolve(r);if(ML.valid(a))return a}return null}}}ML.prototype.visible=!1,ML.findFrom=ML.findGapCursorFrom,bA.jsonID("gapcursor",ML);class Mj{constructor(e){this.pos=e}map(e){return new Mj(e.map(this.pos))}resolve(e){let i=e.resolve(this.pos);return ML.valid(i)?new ML(i):bA.near(i)}}function MI(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}let MP=S2({ArrowLeft:MB("horiz",-1),ArrowRight:MB("horiz",1),ArrowUp:MB("vert",-1),ArrowDown:MB("vert",1)});function MB(e,i){let n="vert"==e?i>0?"down":"up":i>0?"right":"left";return function(e,r,s){let o=e.selection,a=i>0?o.$to:o.$from,l=o.empty;if(o instanceof bj){if(!s.endOfTextblock(n)||0==a.depth)return!1;l=!1,a=e.doc.resolve(i>0?a.after():a.before())}let c=ML.findGapCursorFrom(a,i,l);return!!c&&(r&&r(e.tr.setSelection(new ML(c))),!0)}}function Mz(e,i,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(i);if(!ML.valid(r))return!1;let s=e.posAtCoords({left:n.clientX,top:n.clientY});return!(s&&s.inside>-1&&bP.isSelectable(e.state.doc.nodeAt(s.inside)))&&(e.dispatch(e.state.tr.setSelection(new ML(r))),!0)}function MF(e,i){if("insertCompositionText"!=i.inputType||!(e.state.selection instanceof ML))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let s=_a.empty;for(let e=r.length-1;e>=0;e--)s=_a.from(r[e].createAndFill(null,s));let o=e.state.tr.replace(n.pos,n.pos,new _p(s,0,0));return o.setSelection(bj.near(o.doc.resolve(n.pos+1))),e.dispatch(o),!1}function MW(e){if(!(e.selection instanceof ML))return null;let i=document.createElement("div");return i.className="ProseMirror-gapcursor",Sy.create(e.doc,[Sm.widget(e.selection.head,i,{key:"gapcursor"})])}var MH=function(){};MH.prototype.append=function(e){return e.length?(e=MH.from(e),!this.length&&e||e.length<200&&this.leafAppend(e)||this.length<200&&e.leafPrepend(this)||this.appendInner(e)):this},MH.prototype.prepend=function(e){return e.length?MH.from(e).append(this):this},MH.prototype.appendInner=function(e){return new MU(this,e)},MH.prototype.slice=function(e,i){return(void 0===e&&(e=0),void 0===i&&(i=this.length),e>=i)?MH.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,i))},MH.prototype.get=function(e){if(!(e<0)&&!(e>=this.length))return this.getInner(e)},MH.prototype.forEach=function(e,i,n){void 0===i&&(i=0),void 0===n&&(n=this.length),i<=n?this.forEachInner(e,i,n,0):this.forEachInvertedInner(e,i,n,0)},MH.prototype.map=function(e,i,n){void 0===i&&(i=0),void 0===n&&(n=this.length);var r=[];return this.forEach(function(i,n){return r.push(e(i,n))},i,n),r},MH.from=function(e){return e instanceof MH?e:e&&e.length?new M$(e):MH.empty};var M$=function(e){function i(i){e.call(this),this.values=i}i.__proto__=e,i.prototype=Object.create(e&&e.prototype),i.prototype.constructor=i;var n={length:{configurable:!0},depth:{configurable:!0}};return i.prototype.flatten=function(){return this.values},i.prototype.sliceInner=function(e,n){return 0==e&&n==this.length?this:new i(this.values.slice(e,n))},i.prototype.getInner=function(e){return this.values[e]},i.prototype.forEachInner=function(e,i,n,r){for(var s=i;s<n;s++)if(!1===e(this.values[s],r+s))return!1},i.prototype.forEachInvertedInner=function(e,i,n,r){for(var s=i-1;s>=n;s--)if(!1===e(this.values[s],r+s))return!1},i.prototype.leafAppend=function(e){if(this.length+e.length<=200)return new i(this.values.concat(e.flatten()))},i.prototype.leafPrepend=function(e){if(this.length+e.length<=200)return new i(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(i.prototype,n),i}(MH);MH.empty=new M$([]);var MU=function(e){function i(i,n){e.call(this),this.left=i,this.right=n,this.length=i.length+n.length,this.depth=Math.max(i.depth,n.depth)+1}return i.__proto__=e,i.prototype=Object.create(e&&e.prototype),i.prototype.constructor=i,i.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},i.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},i.prototype.forEachInner=function(e,i,n,r){var s=this.left.length;if(i<s&&!1===this.left.forEachInner(e,i,Math.min(n,s),r)||n>s&&!1===this.right.forEachInner(e,Math.max(i-s,0),Math.min(this.length,n)-s,r+s))return!1},i.prototype.forEachInvertedInner=function(e,i,n,r){var s=this.left.length;if(i>s&&!1===this.right.forEachInvertedInner(e,i-s,Math.max(n,s)-s,r+s)||n<s&&!1===this.left.forEachInvertedInner(e,Math.min(i,s),n,r))return!1},i.prototype.sliceInner=function(e,i){if(0==e&&i==this.length)return this;var n=this.left.length;return i<=n?this.left.slice(e,i):e>=n?this.right.slice(e-n,i-n):this.left.slice(e,n).append(this.right.slice(0,i-n))},i.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new i(this.left,n)},i.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new i(n,this.right)},i.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new i(this.left,new i(this.right,e)):new i(this,e)},i}(MH);class MV{constructor(e,i){this.items=e,this.eventCount=i}popEvent(e,i){let n,r,s,o;if(0==this.eventCount)return null;let a=this.items.length;for(;;a--)if(this.items.get(a-1).selection){--a;break}i&&(r=(n=this.remapping(a,this.items.length)).maps.length);let l=e.tr,c=[],h=[];return this.items.forEach((e,i)=>{if(!e.step){n||(r=(n=this.remapping(a,i+1)).maps.length),r--,h.push(e);return}if(n){h.push(new Mq(e.map));let i=e.step.map(n.slice(r)),s;i&&l.maybeStep(i).doc&&(s=l.mapping.maps[l.mapping.maps.length-1],c.push(new Mq(s,void 0,void 0,c.length+h.length))),r--,s&&n.appendMap(s,r)}else l.maybeStep(e.step);if(e.selection)return s=n?e.selection.map(n.slice(r)):e.selection,o=new MV(this.items.slice(0,a).append(h.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:o,transform:l,selection:s}}addTransform(e,i,n,r){var s,o;let a,l=[],c=this.eventCount,h=this.items,d=!r&&h.length?h.get(h.length-1):null;for(let n=0;n<e.steps.length;n++){let s=e.steps[n].invert(e.docs[n]),o=new Mq(e.mapping.maps[n],s,i),a;(a=d&&d.merge(o))&&(o=a,n?l.pop():h=h.slice(0,h.length-1)),l.push(o),i&&(c++,i=void 0),r||(d=o)}let u=c-n.depth;return u>MK&&(s=h,o=u,s.forEach((e,i)=>{if(e.selection&&0==o--)return a=i,!1}),h=s.slice(a),c-=u),new MV(h.append(l),c)}remapping(e,i){let n=new _4;return this.items.forEach((i,r)=>{let s=null!=i.mirrorOffset&&r-i.mirrorOffset>=e?n.maps.length-i.mirrorOffset:void 0;n.appendMap(i.map,s)},e,i),n}addMaps(e){return 0==this.eventCount?this:new MV(this.items.append(e.map(e=>new Mq(e))),this.eventCount)}rebased(e,i){if(!this.eventCount)return this;let n=[],r=Math.max(0,this.items.length-i),s=e.mapping,o=e.steps.length,a=this.eventCount;this.items.forEach(e=>{e.selection&&a--},r);let l=i;this.items.forEach(i=>{let r=s.getMirror(--l);if(null==r)return;o=Math.min(o,r);let c=s.maps[r];if(i.step){let o=e.steps[r].invert(e.docs[r]),h=i.selection&&i.selection.map(s.slice(l+1,r));h&&a++,n.push(new Mq(c,o,h))}else n.push(new Mq(c))},r);let c=[];for(let e=i;e<o;e++)c.push(new Mq(s.maps[e]));let h=new MV(this.items.slice(0,r).append(c).append(n),a);return h.emptyItemCount()>500&&(h=h.compress(this.items.length-n.length)),h}emptyItemCount(){let e=0;return this.items.forEach(i=>{!i.step&&e++}),e}compress(e=this.items.length){let i=this.remapping(0,e),n=i.maps.length,r=[],s=0;return this.items.forEach((o,a)=>{if(a>=e)r.push(o),o.selection&&s++;else if(o.step){let e=o.step.map(i.slice(n)),a=e&&e.getMap();if(n--,a&&i.appendMap(a,n),e){let l=o.selection&&o.selection.map(i.slice(n));l&&s++;let c=new Mq(a.invert(),e,l),h,d=r.length-1;(h=r.length&&r[d].merge(c))?r[d]=h:r.push(c)}}else o.map&&n--},this.items.length,0),new MV(MH.from(r.reverse()),s)}}MV.empty=new MV(MH.empty,0);class Mq{constructor(e,i,n,r){this.map=e,this.step=i,this.selection=n,this.mirrorOffset=r}merge(e){if(this.step&&e.step&&!e.selection){let i=e.step.merge(this.step);if(i)return new Mq(i.getMap().invert(),i,this.selection)}}}class MY{constructor(e,i,n,r,s){this.done=e,this.undone=i,this.prevRanges=n,this.prevTime=r,this.prevComposition=s}}let MK=20;function MX(e){let i=[];for(let n=e.length-1;n>=0&&0==i.length;n--)e[n].forEach((e,n,r,s)=>i.push(r,s));return i}function MJ(e,i){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let s=i.map(e[r],1),o=i.map(e[r+1],-1);s<=o&&n.push(s,o)}return n}let MG=!1,MZ=null;function MQ(e){let i=e.plugins;if(MZ!=i){MG=!1,MZ=i;for(let e=0;e<i.length;e++)if(i[e].spec.historyPreserveItems){MG=!0;break}}return MG}let M0=new bZ("history"),M1=new bZ("closeHistory");function M2(e,i){return(n,r)=>{let s=M0.getState(n);if(!s||0==(e?s.undone:s.done).eventCount)return!1;if(r){let o=function(e,i,n){let r=MQ(i),s=M0.get(i).spec.config,o=(n?e.undone:e.done).popEvent(i,r);if(!o)return null;let a=o.selection.resolve(o.transform.doc),l=(n?e.done:e.undone).addTransform(o.transform,i.selection.getBookmark(),s,r),c=new MY(n?l:o.remaining,n?o.remaining:l,null,0,-1);return o.transform.setSelection(a).setMeta(M0,{redo:n,historyState:c})}(s,n,e);o&&r(i?o.scrollIntoView():o)}return!0}}let M5=M2(!1,!0),M3=M2(!0,!0);M2(!1,!1),M2(!0,!1),C4.create({name:"characterCount",addOptions:()=>({limit:null,mode:"textSize",textCounter:e=>e.length,wordCounter:e=>e.split(" ").filter(e=>""!==e).length}),addStorage:()=>({characters:()=>0,words:()=>0}),onBeforeCreate(){this.storage.characters=e=>{let i=(null==e?void 0:e.node)||this.editor.state.doc;if("textSize"===((null==e?void 0:e.mode)||this.options.mode)){let e=i.textBetween(0,i.content.size,void 0," ");return this.options.textCounter(e)}return i.nodeSize},this.storage.words=e=>{let i=(null==e?void 0:e.node)||this.editor.state.doc,n=i.textBetween(0,i.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new bX({key:new bZ("characterCount"),appendTransaction:(i,n,r)=>{if(e)return;let s=this.options.limit;if(null==s||0===s){e=!0;return}let o=this.storage.characters({node:r.doc});if(o>s){console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);let i=r.tr.deleteRange(0,o-s);return e=!0,i}e=!0},filterTransaction:(e,i)=>{let n=this.options.limit;if(!e.docChanged||0===n||null==n)return!0;let r=this.storage.characters({node:i.doc}),s=this.storage.characters({node:e.doc});if(s<=n||r>n&&s>n&&s<=r)return!0;if(r>n&&s>n&&s>r||!e.getMeta("paste"))return!1;let o=e.selection.$head.pos;return e.deleteRange(o-(s-n),o),!(this.storage.characters({node:e.doc})>n)}})]}});var M4=C4.create({name:"dropCursor",addOptions:()=>({color:"currentColor",width:1,class:void 0}),addProseMirrorPlugins(){return[function(e={}){return new bX({view:i=>new MD(i,e)})}(this.options)]}});C4.create({name:"focus",addOptions:()=>({className:"has-focus",mode:"all"}),addProseMirrorPlugins(){return[new bX({key:new bZ("focus"),props:{decorations:({doc:e,selection:i})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:s}=i,o=[];if(!n||!r)return Sy.create(e,[]);let a=0;"deepest"===this.options.mode&&e.descendants((e,i)=>{if(!e.isText){if(!(s>=i&&s<=i+e.nodeSize-1))return!1;a+=1}});let l=0;return e.descendants((e,i)=>!e.isText&&!!(s>=i&&s<=i+e.nodeSize-1)&&((l+=1,"deepest"===this.options.mode&&a-l>0||"shallowest"===this.options.mode&&l>1)?"deepest"===this.options.mode:void o.push(Sm.node(i,i+e.nodeSize,{class:this.options.className})))),Sy.create(e,o)}}})]}});var M6=C4.create({name:"gapCursor",addProseMirrorPlugins:()=>[new bX({props:{decorations:MW,createSelectionBetween:(e,i,n)=>i.pos==n.pos&&ML.valid(n)?new ML(n):null,handleClick:Mz,handleKeyDown:MP,handleDOMEvents:{beforeinput:MF}}})],extendNodeSchema(e){var i;let n={name:e.name,options:e.options,storage:e.storage};return{allowGapCursor:null!=(i=Ct(k8(e,"allowGapCursor",n)))?i:null}}}),M8="placeholder",M9=C4.create({name:"placeholder",addOptions:()=>({emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:M8,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}),addProseMirrorPlugins(){let e=this.options.dataAttribute?`data-${this.options.dataAttribute.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}`:`data-${M8}`;return[new bX({key:new bZ("placeholder"),props:{decorations:({doc:i,selection:n})=>{let r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:s}=n,o=[];if(!r)return null;let a=this.editor.isEmpty;return i.descendants((i,n)=>{let r=s>=n&&s<=n+i.nodeSize,l=!i.isLeaf&&Cw(i);if(!i.type.isTextblock)return this.options.includeChildren;if((r||!this.options.showOnlyCurrent)&&l){let s=[this.options.emptyNodeClass];a&&s.push(this.options.emptyEditorClass);let l=Sm.node(n,n+i.nodeSize,{class:s.join(" "),[e]:"function"==typeof this.options.placeholder?this.options.placeholder({editor:this.editor,node:i,pos:n,hasAnchor:r}):this.options.placeholder});o.push(l)}return this.options.includeChildren}),Sy.create(i,o)}}})]}});function M7({types:e,node:i}){return i&&Array.isArray(e)&&e.includes(i.type)||(null==i?void 0:i.type)===e}C4.create({name:"selection",addOptions:()=>({className:"selection"}),addProseMirrorPlugins(){let{editor:e,options:i}=this;return[new bX({key:new bZ("selection"),props:{decorations:n=>n.selection.empty||e.isFocused||!e.isEditable||CS(n.selection)||e.view.dragging?null:Sy.create(n.doc,[Sm.inline(n.selection.from,n.selection.to,{class:i.className})])}})]}});var Oe=C4.create({name:"trailingNode",addOptions:()=>({node:void 0,notAfter:[]}),addProseMirrorPlugins(){var e;let i=new bZ(this.name),n=this.options.node||(null==(e=this.editor.schema.topNodeType.contentMatch.defaultType)?void 0:e.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,e])=>e).filter(e=>(this.options.notAfter||[]).concat(n).includes(e.name));return[new bX({key:i,appendTransaction:(e,r,s)=>{let{doc:o,tr:a,schema:l}=s,c=i.getState(s),h=o.content.size,d=l.nodes[n];if(!e.some(e=>e.getMeta("skipTrailingNode"))&&c)return a.insert(h,d.create())},state:{init:(e,i)=>!M7({node:i.tr.doc.lastChild,types:r}),apply:(e,i)=>!e.docChanged||e.getMeta("__uniqueIDTransaction")?i:!M7({node:e.doc.lastChild,types:r})}})]}}),Ot=C4.create({name:"undoRedo",addOptions:()=>({depth:100,newGroupDelay:500}),addCommands:()=>({undo:()=>({state:e,dispatch:i})=>M5(e,i),redo:()=>({state:e,dispatch:i})=>M3(e,i)}),addProseMirrorPlugins(){return[function(e={}){return new bX({key:M0,state:{init:()=>new MY(MV.empty,MV.empty,null,0,-1),apply:(i,n,r)=>(function(e,i,n,r){let s=n.getMeta(M0),o;if(s)return s.historyState;n.getMeta(M1)&&(e=new MY(e.done,e.undone,null,0,-1));let a=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(a&&a.getMeta(M0))if(a.getMeta(M0).redo)return new MY(e.done.addTransform(n,void 0,r,MQ(i)),e.undone,MX(n.mapping.maps),e.prevTime,e.prevComposition);else return new MY(e.done,e.undone.addTransform(n,void 0,r,MQ(i)),null,e.prevTime,e.prevComposition);if(!1===n.getMeta("addToHistory")||a&&!1===a.getMeta("addToHistory"))if(o=n.getMeta("rebased"))return new MY(e.done.rebased(n,o),e.undone.rebased(n,o),MJ(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);else return new MY(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),MJ(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);{let s=n.getMeta("composition"),o=0==e.prevTime||!a&&e.prevComposition!=s&&(e.prevTime<(n.time||0)-r.newGroupDelay||!function(e,i){if(!i)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let s=0;s<i.length;s+=2)e<=i[s+1]&&r>=i[s]&&(n=!0)}),n}(n,e.prevRanges)),l=a?MJ(e.prevRanges,n.mapping):MX(n.mapping.maps);return new MY(e.done.addTransform(n,o?i.selection.getBookmark():void 0,r,MQ(i)),MV.empty,l,n.time,null==s?e.prevComposition:s)}})(n,r,i,e)},config:e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},props:{handleDOMEvents:{beforeinput(e,i){let n=i.inputType,r="historyUndo"==n?M5:"historyRedo"==n?M3:null;return!!r&&!!e.editable&&(i.preventDefault(),r(e.state,e.dispatch))}}}})}(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),Oi=C4.create({name:"starterKit",addExtensions(){var e,i,n,r;let s=[];return!1!==this.options.bold&&s.push(Eg.configure(this.options.bold)),!1!==this.options.blockquote&&s.push(Ed.configure(this.options.blockquote)),!1!==this.options.bulletList&&s.push(Mi.configure(this.options.bulletList)),!1!==this.options.code&&s.push(E_.configure(this.options.code)),!1!==this.options.codeBlock&&s.push(Ew.configure(this.options.codeBlock)),!1!==this.options.document&&s.push(ES.configure(this.options.document)),!1!==this.options.dropcursor&&s.push(M4.configure(this.options.dropcursor)),!1!==this.options.gapcursor&&s.push(M6.configure(this.options.gapcursor)),!1!==this.options.hardBreak&&s.push(Ek.configure(this.options.hardBreak)),!1!==this.options.heading&&s.push(EC.configure(this.options.heading)),!1!==this.options.undoRedo&&s.push(Ot.configure(this.options.undoRedo)),!1!==this.options.horizontalRule&&s.push(ET.configure(this.options.horizontalRule)),!1!==this.options.italic&&s.push(EA.configure(this.options.italic)),!1!==this.options.listItem&&s.push(Mn.configure(this.options.listItem)),!1!==this.options.listKeymap&&s.push(Mv.configure(null==(e=this.options)?void 0:e.listKeymap)),!1!==this.options.link&&s.push(N9.configure(null==(i=this.options)?void 0:i.link)),!1!==this.options.orderedList&&s.push(Mw.configure(this.options.orderedList)),!1!==this.options.paragraph&&s.push(ME.configure(this.options.paragraph)),!1!==this.options.strike&&s.push(MO.configure(this.options.strike)),!1!==this.options.text&&s.push(MA.configure(this.options.text)),!1!==this.options.underline&&s.push(MR.configure(null==(n=this.options)?void 0:n.underline)),!1!==this.options.trailingNode&&s.push(Oe.configure(null==(r=this.options)?void 0:r.trailingNode)),s}});function On(e){var i;let{char:n,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:o,startOfLine:a,$position:l}=e,c=r&&!s,h=n.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),d=RegExp(`\\s${h}$`),u=a?"^":"",p=s?"":h,f=c?RegExp(`${u}${h}.*?(?=\\s${p}|$)`,"gm"):RegExp(`${u}(?:^)?${h}[^\\s${p}]*`,"gm"),m=(null==(i=l.nodeBefore)?void 0:i.isText)&&l.nodeBefore.text;if(!m)return null;let g=l.pos-m.length,v=Array.from(m.matchAll(f)).pop();if(!v||void 0===v.input||void 0===v.index)return null;let y=v.input.slice(Math.max(0,v.index-1),v.index),_=RegExp(`^[${null==o?void 0:o.join("")}\0]?$`).test(y);if(null!==o&&!_)return null;let b=g+v.index,w=b+v[0].length;return(c&&d.test(m.slice(w-1,w+1))&&(v[0]+=" ",w+=1),b<l.pos&&w>=l.pos)?{range:{from:b,to:w},query:v[0].slice(n.length),text:v[0]}:null}var Or=new bZ("suggestion");function Os({pluginKey:e=Or,editor:i,char:n="@",allowSpaces:r=!1,allowToIncludeChar:s=!1,allowedPrefixes:o=[" "],startOfLine:a=!1,decorationTag:l="span",decorationClass:c="suggestion",decorationContent:h="",decorationEmptyClass:d="is-empty",command:u=()=>null,items:p=()=>[],render:f=()=>({}),allow:m=()=>!0,findSuggestionMatch:g=On,shouldShow:v,shouldResetDismissed:y}){let _,b=null==f?void 0:f(),w=r&&!s,S=()=>{let e=i.state.selection.$anchor.pos,{top:n,right:r,bottom:s,left:o}=i.view.coordsAtPos(e);try{return new DOMRect(o,n,r-o,s-n)}catch{return null}},k=(n,r)=>r?()=>{let r=e.getState(i.state),s=null==r?void 0:r.decorationId,o=n.dom.querySelector(`[data-decoration-id="${s}"]`);return(null==o?void 0:o.getBoundingClientRect())||null}:S,C=new bX({key:e,view(){return{update:async(e,n)=>{var r,s,o,a,l,c,h;let d=null==(r=this.key)?void 0:r.getState(n),f=null==(s=this.key)?void 0:s.getState(e.state),m=d.active&&f.active&&d.range.from!==f.range.from,g=!d.active&&f.active,v=d.active&&!f.active,y=!g&&!v&&d.query!==f.query,w=g||m&&y,S=y||m,C=v||m&&y;if(!w&&!S&&!C)return;let T=C&&!w?d:f,E=e.dom.querySelector(`[data-decoration-id="${T.decorationId}"]`);_={editor:i,range:T.range,query:T.query,text:T.text,items:[],command:e=>u({editor:i,range:T.range,props:e}),decorationNode:E,clientRect:k(e,E)},w&&(null==(o=null==b?void 0:b.onBeforeStart)||o.call(b,_)),S&&(null==(a=null==b?void 0:b.onBeforeUpdate)||a.call(b,_)),(S||w)&&(_.items=await p({editor:i,query:T.query})),C&&(null==(l=null==b?void 0:b.onExit)||l.call(b,_)),S&&(null==(c=null==b?void 0:b.onUpdate)||c.call(b,_)),w&&(null==(h=null==b?void 0:b.onStart)||h.call(b,_))},destroy:()=>{var e;_&&(null==(e=null==b?void 0:b.onExit)||e.call(b,_))}}},state:{init:()=>({active:!1,range:{from:0,to:0},query:null,text:null,composing:!1,dismissedRange:null}),apply(l,c,h,d){let{isEditable:u}=i,{composing:p}=i.view,{selection:f}=l,{empty:_,from:b}=f,S={...c},k=l.getMeta(e);if(k&&k.exit)return S.active=!1,S.decorationId=null,S.range={from:0,to:0},S.query=null,S.text=null,S.dismissedRange=c.active?{...c.range}:c.dismissedRange,S;if(S.composing=p,l.docChanged&&null!==S.dismissedRange&&(S.dismissedRange={from:l.mapping.map(S.dismissedRange.from),to:l.mapping.map(S.dismissedRange.to)}),u&&(_||i.view.composing)){(b<c.range.from||b>c.range.to)&&!p&&!c.composing&&(S.active=!1);let e=g({char:n,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:o,startOfLine:a,$position:f.$from}),h=`id_${Math.floor(0xffffffff*Math.random())}`;e&&m({editor:i,state:d,range:e.range,isActive:c.active})&&(!v||v({editor:i,range:e.range,query:e.query,text:e.text,transaction:l}))?(null===S.dismissedRange||(({match:e,dismissedRange:n,state:r,transaction:s})=>(null==y?!void 0:!y({editor:i,state:r,range:n,match:e,transaction:s,allowSpaces:w}))&&(w?e.range.from===n.from:e.range.from===n.from&&!(s.docChanged&&s.steps.some(e=>{let i=e.slice;if(!(null==i?void 0:i.content))return!1;let n=i.content.textBetween(0,i.content.size,"\n");return/\s/.test(n)}))))({match:e,dismissedRange:S.dismissedRange,state:d,transaction:l})||(S.dismissedRange=null),null===S.dismissedRange?(S.active=!0,S.decorationId=c.decorationId?c.decorationId:h,S.range=e.range,S.query=e.query,S.text=e.text):S.active=!1):(e||(S.dismissedRange=null),S.active=!1)}else S.active=!1;return S.active||(S.decorationId=null,S.range={from:0,to:0},S.query=null,S.text=null),S}},props:{handleKeyDown(n,r){var s,o;let{active:a,range:l}=C.getState(n.state);if(!a)return!1;if("Escape"===r.key||"Esc"===r.key){let o=C.getState(n.state);return null==(s=null==b?void 0:b.onKeyDown)||s.call(b,{view:n,event:r,range:o.range}),!function(n,r){var s;try{let r=e.getState(n.state),o=(null==r?void 0:r.decorationId)?n.dom.querySelector(`[data-decoration-id="${r.decorationId}"]`):null,a={editor:i,range:(null==r?void 0:r.range)||{from:0,to:0},query:(null==r?void 0:r.query)||null,text:(null==r?void 0:r.text)||null,items:[],command:e=>u({editor:i,range:(null==r?void 0:r.range)||{from:0,to:0},props:e}),decorationNode:o,clientRect:k(n,o)};null==(s=null==b?void 0:b.onExit)||s.call(b,a)}catch{}let o=n.state.tr.setMeta(r,{exit:!0});n.dispatch(o)}(n,e),!0}return(null==(o=null==b?void 0:b.onKeyDown)?void 0:o.call(b,{view:n,event:r,range:l}))||!1},decorations(e){let{active:i,range:n,decorationId:r,query:s}=C.getState(e);if(!i)return null;let o=!(null==s?void 0:s.length),a=[c];return o&&a.push(d),Sy.create(e.doc,[Sm.inline(n.from,n.to,{nodeName:l,class:a.join(" "),"data-decoration-id":r,"data-decoration-content":h})])}}});return C}function Oo(e){return(e.options.suggestions.length?e.options.suggestions:[e.options.suggestion]).map(i=>(function({editor:e,overrideSuggestionOptions:i,extensionName:n,char:r="@"}){return{editor:e,char:r,pluginKey:new bZ,command:({editor:e,range:i,props:s})=>{var o,a,l;let c=e.view.state.selection.$to.nodeAfter;(null==(o=null==c?void 0:c.text)?void 0:o.startsWith(" "))&&(i.to+=1),e.chain().focus().insertContentAt(i,[{type:n,attrs:{...s,mentionSuggestionChar:r}},{type:"text",text:" "}]).run(),null==(l=null==(a=e.view.dom.ownerDocument.defaultView)?void 0:a.getSelection())||l.collapseToEnd()},allow:({state:e,range:i})=>{let r=e.doc.resolve(i.from),s=e.schema.nodes[n];return!!r.parent.type.contentMatch.matchType(s)},...i}})({editor:e.editor,overrideSuggestionOptions:i,extensionName:e.name,char:i.char}))}function Oa(e,i){let n=Oo(e),r=n.find(e=>e.char===i);return r||(n.length?n[0]:null)}var Ol=Tw.create({name:"mention",priority:101,addOptions:()=>({HTMLAttributes:{},renderText({node:e,suggestion:i}){var n,r;return`${null!=(n=null==i?void 0:i.char)?n:"@"}${null!=(r=e.attrs.label)?r:e.attrs.id}`},deleteTriggerWithBackspace:!1,renderHTML({options:e,node:i,suggestion:n}){var r,s;return["span",Cs(this.HTMLAttributes,e.HTMLAttributes),`${null!=(r=null==n?void 0:n.char)?r:"@"}${null!=(s=i.attrs.label)?s:i.attrs.id}`]},suggestions:[],suggestion:{}}),group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes:()=>({id:{default:null,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>e.id?{"data-id":e.id}:{}},label:{default:null,parseHTML:e=>e.getAttribute("data-label"),renderHTML:e=>e.label?{"data-label":e.label}:{}},mentionSuggestionChar:{default:"@",parseHTML:e=>e.getAttribute("data-mention-suggestion-char"),renderHTML:e=>({"data-mention-suggestion-char":e.mentionSuggestionChar})}}),parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({node:e,HTMLAttributes:i}){let n=Oa(this,e.attrs.mentionSuggestionChar);if(void 0!==this.options.renderLabel)return console.warn("renderLabel is deprecated use renderText and renderHTML instead"),["span",Cs({"data-type":this.name},this.options.HTMLAttributes,i),this.options.renderLabel({options:this.options,node:e,suggestion:n})];let r={...this.options};r.HTMLAttributes=Cs({"data-type":this.name},this.options.HTMLAttributes,i);let s=this.options.renderHTML({options:r,node:e,suggestion:n});return"string"==typeof s?["span",Cs({"data-type":this.name},this.options.HTMLAttributes,i),s]:s},...T_({nodeName:"mention",name:"@",selfClosing:!0,allowedAttributes:["id","label",{name:"mentionSuggestionChar",skipIfDefault:"@"}],parseAttributes:e=>{let i={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g,r=n.exec(e);for(;null!==r;){let[,s,o,a]=r,l=null!=o?o:a;i["char"===s?"mentionSuggestionChar":s]=l,r=n.exec(e)}return i},serializeAttributes:e=>Object.entries(e).filter(([,e])=>null!=e).map(([e,i])=>`${"mentionSuggestionChar"===e?"char":e}="${i}"`).join(" ")}),renderText({node:e}){let i={options:this.options,node:e,suggestion:Oa(this,e.attrs.mentionSuggestionChar)};return void 0!==this.options.renderLabel?(console.warn("renderLabel is deprecated use renderText and renderHTML instead"),this.options.renderLabel(i)):this.options.renderText(i)},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:e,state:i})=>{let n=!1,{selection:r}=i,{empty:s,anchor:o}=r;if(!s)return!1;let a=new _T,l=0;return i.doc.nodesBetween(o-1,o,(e,i)=>{if(e.type.name===this.name)return n=!0,a=e,l=i,!1}),n&&e.insertText(this.options.deleteTriggerWithBackspace?"":a.attrs.mentionSuggestionChar,l,l+a.nodeSize),n})}},addProseMirrorPlugins(){return Oo(this).map(Os)}}),Oc=e.i(898822);let Oh=(0,nL.default)("send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]),Od=(0,nL.default)("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);function Ou({editor:e,canSubmit:i,onSubmit:n,onStop:r,isProcessing:s=!1,actions:o,className:a,dropzoneProps:l,hiddenInput:c}){return(0,iN.jsx)("div",{className:a,children:(0,iN.jsxs)("div",{className:"bg-background border border-border rounded-2xl overflow-hidden",...l,children:[c,(0,iN.jsx)("div",{className:"px-3 pt-3 pb-2",children:(0,iN.jsx)(T5,{editor:e})}),(0,iN.jsxs)("div",{className:"flex items-center justify-between px-2 pb-2",children:[(0,iN.jsx)("div",{className:"flex items-center gap-1",children:o}),s?(0,iN.jsx)(hv.Button,{onClick:r,className:"size-7 p-0 rounded-full bg-destructive hover:bg-destructive/90 text-destructive-foreground",children:(0,iN.jsx)(Od,{className:"size-3",fill:"currentColor"})}):i?(0,iN.jsx)(hv.Button,{onClick:n,className:"size-7 p-0 rounded-full bg-primary",children:(0,iN.jsx)(Oh,{className:"size-3"})}):null]})]})})}function Op(e){if(null==e)return window;if("[object Window]"!==e.toString()){var i=e.ownerDocument;return i&&i.defaultView||window}return e}function Of(e){var i=Op(e).Element;return e instanceof i||e instanceof Element}function Om(e){var i=Op(e).HTMLElement;return e instanceof i||e instanceof HTMLElement}function Og(e){if("u"<typeof ShadowRoot)return!1;var i=Op(e).ShadowRoot;return e instanceof i||e instanceof ShadowRoot}var Ov=Math.max,Oy=Math.min,O_=Math.round;function Ob(){var e=navigator.userAgentData;return null!=e&&e.brands&&Array.isArray(e.brands)?e.brands.map(function(e){return e.brand+"/"+e.version}).join(" "):navigator.userAgent}function Ox(){return!/^((?!chrome|android).)*safari/i.test(Ob())}function Ow(e,i,n){void 0===i&&(i=!1),void 0===n&&(n=!1);var r=e.getBoundingClientRect(),s=1,o=1;i&&Om(e)&&(s=e.offsetWidth>0&&O_(r.width)/e.offsetWidth||1,o=e.offsetHeight>0&&O_(r.height)/e.offsetHeight||1);var a=(Of(e)?Op(e):window).visualViewport,l=!Ox()&&n,c=(r.left+(l&&a?a.offsetLeft:0))/s,h=(r.top+(l&&a?a.offsetTop:0))/o,d=r.width/s,u=r.height/o;return{width:d,height:u,top:h,right:c+d,bottom:h+u,left:c,x:c,y:h}}function OS(e){var i=Op(e);return{scrollLeft:i.pageXOffset,scrollTop:i.pageYOffset}}function Ok(e){return e?(e.nodeName||"").toLowerCase():null}function OC(e){return((Of(e)?e.ownerDocument:e.document)||window.document).documentElement}function OT(e){return Ow(OC(e)).left+OS(e).scrollLeft}function OE(e){return Op(e).getComputedStyle(e)}function ON(e){var i=OE(e),n=i.overflow,r=i.overflowX,s=i.overflowY;return/auto|scroll|overlay|hidden/.test(n+s+r)}function OM(e){var i=Ow(e),n=e.offsetWidth,r=e.offsetHeight;return 1>=Math.abs(i.width-n)&&(n=i.width),1>=Math.abs(i.height-r)&&(r=i.height),{x:e.offsetLeft,y:e.offsetTop,width:n,height:r}}function OO(e){return"html"===Ok(e)?e:e.assignedSlot||e.parentNode||(Og(e)?e.host:null)||OC(e)}function OA(e,i){void 0===i&&(i=[]);var n,r=function e(i){return["html","body","#document"].indexOf(Ok(i))>=0?i.ownerDocument.body:Om(i)&&ON(i)?i:e(OO(i))}(e),s=r===(null==(n=e.ownerDocument)?void 0:n.body),o=Op(r),a=s?[o].concat(o.visualViewport||[],ON(r)?r:[]):r,l=i.concat(a);return s?l:l.concat(OA(OO(a)))}function OR(e){return Om(e)&&"fixed"!==OE(e).position?e.offsetParent:null}function OD(e){for(var i=Op(e),n=OR(e);n&&["table","td","th"].indexOf(Ok(n))>=0&&"static"===OE(n).position;)n=OR(n);return n&&("html"===Ok(n)||"body"===Ok(n)&&"static"===OE(n).position)?i:n||function(e){var i=/firefox/i.test(Ob());if(/Trident/i.test(Ob())&&Om(e)&&"fixed"===OE(e).position)return null;var n=OO(e);for(Og(n)&&(n=n.host);Om(n)&&0>["html","body"].indexOf(Ok(n));){var r=OE(n);if("none"!==r.transform||"none"!==r.perspective||"paint"===r.contain||-1!==["transform","perspective"].indexOf(r.willChange)||i&&"filter"===r.willChange||i&&r.filter&&"none"!==r.filter)return n;n=n.parentNode}return null}(e)||i}var OL="bottom",Oj="right",OI="left",OP="auto",OB=["top",OL,Oj,OI],Oz="start",OF="viewport",OW="popper",OH=OB.reduce(function(e,i){return e.concat([i+"-"+Oz,i+"-end"])},[]),O$=[].concat(OB,[OP]).reduce(function(e,i){return e.concat([i,i+"-"+Oz,i+"-end"])},[]),OU=["beforeRead","read","afterRead","beforeMain","main","afterMain","beforeWrite","write","afterWrite"];function OV(e,i){var n=i.getRootNode&&i.getRootNode();if(e.contains(i))return!0;if(n&&Og(n)){var r=i;do{if(r&&e.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function Oq(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function OY(e,i,n){var r,s,o,a,l,c,h,d,u,p;return i===OF?Oq(function(e,i){var n=Op(e),r=OC(e),s=n.visualViewport,o=r.clientWidth,a=r.clientHeight,l=0,c=0;if(s){o=s.width,a=s.height;var h=Ox();(h||!h&&"fixed"===i)&&(l=s.offsetLeft,c=s.offsetTop)}return{width:o,height:a,x:l+OT(e),y:c}}(e,n)):Of(i)?((r=Ow(i,!1,"fixed"===n)).top=r.top+i.clientTop,r.left=r.left+i.clientLeft,r.bottom=r.top+i.clientHeight,r.right=r.left+i.clientWidth,r.width=i.clientWidth,r.height=i.clientHeight,r.x=r.left,r.y=r.top,r):Oq((s=OC(e),a=OC(s),l=OS(s),c=null==(o=s.ownerDocument)?void 0:o.body,h=Ov(a.scrollWidth,a.clientWidth,c?c.scrollWidth:0,c?c.clientWidth:0),d=Ov(a.scrollHeight,a.clientHeight,c?c.scrollHeight:0,c?c.clientHeight:0),u=-l.scrollLeft+OT(s),p=-l.scrollTop,"rtl"===OE(c||a).direction&&(u+=Ov(a.clientWidth,c?c.clientWidth:0)-h),{width:h,height:d,x:u,y:p}))}function OK(e){return e.split("-")[0]}function OX(e){return e.split("-")[1]}function OJ(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}function OG(e){var i,n=e.reference,r=e.element,s=e.placement,o=s?OK(s):null,a=s?OX(s):null,l=n.x+n.width/2-r.width/2,c=n.y+n.height/2-r.height/2;switch(o){case"top":i={x:l,y:n.y-r.height};break;case OL:i={x:l,y:n.y+n.height};break;case Oj:i={x:n.x+n.width,y:c};break;case OI:i={x:n.x-r.width,y:c};break;default:i={x:n.x,y:n.y}}var h=o?OJ(o):null;if(null!=h){var d="y"===h?"height":"width";switch(a){case Oz:i[h]=i[h]-(n[d]/2-r[d]/2);break;case"end":i[h]=i[h]+(n[d]/2-r[d]/2)}}return i}function OZ(){return{top:0,right:0,bottom:0,left:0}}function OQ(e){return Object.assign({},OZ(),e)}function O0(e,i){return i.reduce(function(i,n){return i[n]=e,i},{})}function O1(e,i){void 0===i&&(i={});var n,r,s,o,a,l,c,h,d=i,u=d.placement,p=void 0===u?e.placement:u,f=d.strategy,m=void 0===f?e.strategy:f,g=d.boundary,v=d.rootBoundary,y=d.elementContext,_=void 0===y?OW:y,b=d.altBoundary,w=d.padding,S=void 0===w?0:w,k=OQ("number"!=typeof S?S:O0(S,OB)),C=e.rects.popper,T=e.elements[void 0!==b&&b?_===OW?"reference":OW:_],E=(n=Of(T)?T:T.contextElement||OC(e.elements.popper),r=void 0===g?"clippingParents":g,s=void 0===v?OF:v,c=(l=[].concat("clippingParents"===r?(o=OA(OO(n)),!Of(a=["absolute","fixed"].indexOf(OE(n).position)>=0&&Om(n)?OD(n):n)?[]:o.filter(function(e){return Of(e)&&OV(e,a)&&"body"!==Ok(e)})):[].concat(r),[s]))[0],(h=l.reduce(function(e,i){var r=OY(n,i,m);return e.top=Ov(r.top,e.top),e.right=Oy(r.right,e.right),e.bottom=Oy(r.bottom,e.bottom),e.left=Ov(r.left,e.left),e},OY(n,c,m))).width=h.right-h.left,h.height=h.bottom-h.top,h.x=h.left,h.y=h.top,h),N=Ow(e.elements.reference),M=OG({reference:N,element:C,strategy:"absolute",placement:p}),O=Oq(Object.assign({},C,M)),A=_===OW?O:N,R={top:E.top-A.top+k.top,bottom:A.bottom-E.bottom+k.bottom,left:E.left-A.left+k.left,right:A.right-E.right+k.right},D=e.modifiersData.offset;if(_===OW&&D){var L=D[p];Object.keys(R).forEach(function(e){var i=[Oj,OL].indexOf(e)>=0?1:-1,n=["top",OL].indexOf(e)>=0?"y":"x";R[e]+=L[n]*i})}return R}var O2={placement:"bottom",modifiers:[],strategy:"absolute"};function O5(){for(var e=arguments.length,i=Array(e),n=0;n<e;n++)i[n]=arguments[n];return!i.some(function(e){return!(e&&"function"==typeof e.getBoundingClientRect)})}var O3={passive:!0},O4={top:"auto",right:"auto",bottom:"auto",left:"auto"};function O6(e){var i,n,r,s,o,a,l,c=e.popper,h=e.popperRect,d=e.placement,u=e.variation,p=e.offsets,f=e.position,m=e.gpuAcceleration,g=e.adaptive,v=e.roundOffsets,y=e.isFixed,_=p.x,b=void 0===_?0:_,w=p.y,S=void 0===w?0:w,k="function"==typeof v?v({x:b,y:S}):{x:b,y:S};b=k.x,S=k.y;var C=p.hasOwnProperty("x"),T=p.hasOwnProperty("y"),E=OI,N="top",M=window;if(g){var O=OD(c),A="clientHeight",R="clientWidth";O===Op(c)&&"static"!==OE(O=OC(c)).position&&"absolute"===f&&(A="scrollHeight",R="scrollWidth"),("top"===d||(d===OI||d===Oj)&&"end"===u)&&(N=OL,S-=(y&&O===M&&M.visualViewport?M.visualViewport.height:O[A])-h.height,S*=m?1:-1),(d===OI||("top"===d||d===OL)&&"end"===u)&&(E=Oj,b-=(y&&O===M&&M.visualViewport?M.visualViewport.width:O[R])-h.width,b*=m?1:-1)}var D=Object.assign({position:f},g&&O4),L=!0===v?(i={x:b,y:S},n=Op(c),r=i.x,s=i.y,{x:O_(r*(o=n.devicePixelRatio||1))/o||0,y:O_(s*o)/o||0}):{x:b,y:S};return(b=L.x,S=L.y,m)?Object.assign({},D,((l={})[N]=T?"0":"",l[E]=C?"0":"",l.transform=1>=(M.devicePixelRatio||1)?"translate("+b+"px, "+S+"px)":"translate3d("+b+"px, "+S+"px, 0)",l)):Object.assign({},D,((a={})[N]=T?S+"px":"",a[E]=C?b+"px":"",a.transform="",a))}let O8={name:"applyStyles",enabled:!0,phase:"write",fn:function(e){var i=e.state;Object.keys(i.elements).forEach(function(e){var n=i.styles[e]||{},r=i.attributes[e]||{},s=i.elements[e];Om(s)&&Ok(s)&&(Object.assign(s.style,n),Object.keys(r).forEach(function(e){var i=r[e];!1===i?s.removeAttribute(e):s.setAttribute(e,!0===i?"":i)}))})},effect:function(e){var i=e.state,n={popper:{position:i.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(i.elements.popper.style,n.popper),i.styles=n,i.elements.arrow&&Object.assign(i.elements.arrow.style,n.arrow),function(){Object.keys(i.elements).forEach(function(e){var r=i.elements[e],s=i.attributes[e]||{},o=Object.keys(i.styles.hasOwnProperty(e)?i.styles[e]:n[e]).reduce(function(e,i){return e[i]="",e},{});Om(r)&&Ok(r)&&(Object.assign(r.style,o),Object.keys(s).forEach(function(e){r.removeAttribute(e)}))})}},requires:["computeStyles"]};var O9={left:"right",right:"left",bottom:"top",top:"bottom"};function O7(e){return e.replace(/left|right|bottom|top/g,function(e){return O9[e]})}var Ae={start:"end",end:"start"};function At(e){return e.replace(/start|end/g,function(e){return Ae[e]})}function Ai(e,i,n){return Ov(e,Oy(i,n))}function An(e,i,n){return void 0===n&&(n={x:0,y:0}),{top:e.top-i.height-n.y,right:e.right-i.width+n.x,bottom:e.bottom-i.height+n.y,left:e.left-i.width-n.x}}function Ar(e){return["top",Oj,OL,OI].some(function(i){return e[i]>=0})}var As=(Dd=void 0===(Dh=(Dc={defaultModifiers:[{name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:function(e){var i=e.state,n=e.instance,r=e.options,s=r.scroll,o=void 0===s||s,a=r.resize,l=void 0===a||a,c=Op(i.elements.popper),h=[].concat(i.scrollParents.reference,i.scrollParents.popper);return o&&h.forEach(function(e){e.addEventListener("scroll",n.update,O3)}),l&&c.addEventListener("resize",n.update,O3),function(){o&&h.forEach(function(e){e.removeEventListener("scroll",n.update,O3)}),l&&c.removeEventListener("resize",n.update,O3)}},data:{}},{name:"popperOffsets",enabled:!0,phase:"read",fn:function(e){var i=e.state,n=e.name;i.modifiersData[n]=OG({reference:i.rects.reference,element:i.rects.popper,strategy:"absolute",placement:i.placement})},data:{}},{name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:function(e){var i=e.state,n=e.options,r=n.gpuAcceleration,s=n.adaptive,o=n.roundOffsets,a=void 0===o||o,l={placement:OK(i.placement),variation:OX(i.placement),popper:i.elements.popper,popperRect:i.rects.popper,gpuAcceleration:void 0===r||r,isFixed:"fixed"===i.options.strategy};null!=i.modifiersData.popperOffsets&&(i.styles.popper=Object.assign({},i.styles.popper,O6(Object.assign({},l,{offsets:i.modifiersData.popperOffsets,position:i.options.strategy,adaptive:void 0===s||s,roundOffsets:a})))),null!=i.modifiersData.arrow&&(i.styles.arrow=Object.assign({},i.styles.arrow,O6(Object.assign({},l,{offsets:i.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:a})))),i.attributes.popper=Object.assign({},i.attributes.popper,{"data-popper-placement":i.placement})},data:{}},O8,{name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:function(e){var i=e.state,n=e.options,r=e.name,s=n.offset,o=void 0===s?[0,0]:s,a=O$.reduce(function(e,n){var r,s,a,l,c,h;return e[n]=(r=i.rects,a=[OI,"top"].indexOf(s=OK(n))>=0?-1:1,c=(l="function"==typeof o?o(Object.assign({},r,{placement:n})):o)[0],h=l[1],c=c||0,h=(h||0)*a,[OI,Oj].indexOf(s)>=0?{x:h,y:c}:{x:c,y:h}),e},{}),l=a[i.placement],c=l.x,h=l.y;null!=i.modifiersData.popperOffsets&&(i.modifiersData.popperOffsets.x+=c,i.modifiersData.popperOffsets.y+=h),i.modifiersData[r]=a}},{name:"flip",enabled:!0,phase:"main",fn:function(e){var i=e.state,n=e.options,r=e.name;if(!i.modifiersData[r]._skip){for(var s=n.mainAxis,o=void 0===s||s,a=n.altAxis,l=void 0===a||a,c=n.fallbackPlacements,h=n.padding,d=n.boundary,u=n.rootBoundary,p=n.altBoundary,f=n.flipVariations,m=void 0===f||f,g=n.allowedAutoPlacements,v=i.options.placement,y=OK(v)===v,_=c||(y||!m?[O7(v)]:function(e){if(OK(e)===OP)return[];var i=O7(e);return[At(e),i,At(i)]}(v)),b=[v].concat(_).reduce(function(e,n){var r,s,o,a,l,c,p,f,v,y,_,b;return e.concat(OK(n)===OP?(s=(r={placement:n,boundary:d,rootBoundary:u,padding:h,flipVariations:m,allowedAutoPlacements:g}).placement,o=r.boundary,a=r.rootBoundary,l=r.padding,c=r.flipVariations,f=void 0===(p=r.allowedAutoPlacements)?O$:p,0===(_=(y=(v=OX(s))?c?OH:OH.filter(function(e){return OX(e)===v}):OB).filter(function(e){return f.indexOf(e)>=0})).length&&(_=y),Object.keys(b=_.reduce(function(e,n){return e[n]=O1(i,{placement:n,boundary:o,rootBoundary:a,padding:l})[OK(n)],e},{})).sort(function(e,i){return b[e]-b[i]})):n)},[]),w=i.rects.reference,S=i.rects.popper,k=new Map,C=!0,T=b[0],E=0;E<b.length;E++){var N=b[E],M=OK(N),O=OX(N)===Oz,A=["top",OL].indexOf(M)>=0,R=A?"width":"height",D=O1(i,{placement:N,boundary:d,rootBoundary:u,altBoundary:p,padding:h}),L=A?O?Oj:OI:O?OL:"top";w[R]>S[R]&&(L=O7(L));var j=O7(L),I=[];if(o&&I.push(D[M]<=0),l&&I.push(D[L]<=0,D[j]<=0),I.every(function(e){return e})){T=N,C=!1;break}k.set(N,I)}if(C)for(var P=m?3:1,B=function(e){var i=b.find(function(i){var n=k.get(i);if(n)return n.slice(0,e).every(function(e){return e})});if(i)return T=i,"break"},z=P;z>0&&"break"!==B(z);z--);i.placement!==T&&(i.modifiersData[r]._skip=!0,i.placement=T,i.reset=!0)}},requiresIfExists:["offset"],data:{_skip:!1}},{name:"preventOverflow",enabled:!0,phase:"main",fn:function(e){var i=e.state,n=e.options,r=e.name,s=n.mainAxis,o=n.altAxis,a=n.boundary,l=n.rootBoundary,c=n.altBoundary,h=n.padding,d=n.tether,u=void 0===d||d,p=n.tetherOffset,f=void 0===p?0:p,m=O1(i,{boundary:a,rootBoundary:l,padding:h,altBoundary:c}),g=OK(i.placement),v=OX(i.placement),y=!v,_=OJ(g),b="x"===_?"y":"x",w=i.modifiersData.popperOffsets,S=i.rects.reference,k=i.rects.popper,C="function"==typeof f?f(Object.assign({},i.rects,{placement:i.placement})):f,T="number"==typeof C?{mainAxis:C,altAxis:C}:Object.assign({mainAxis:0,altAxis:0},C),E=i.modifiersData.offset?i.modifiersData.offset[i.placement]:null,N={x:0,y:0};if(w){if(void 0===s||s){var M,O="y"===_?"top":OI,A="y"===_?OL:Oj,R="y"===_?"height":"width",D=w[_],L=D+m[O],j=D-m[A],I=u?-k[R]/2:0,P=v===Oz?S[R]:k[R],B=v===Oz?-k[R]:-S[R],z=i.elements.arrow,F=u&&z?OM(z):{width:0,height:0},W=i.modifiersData["arrow#persistent"]?i.modifiersData["arrow#persistent"].padding:OZ(),H=W[O],$=W[A],U=Ai(0,S[R],F[R]),V=y?S[R]/2-I-U-H-T.mainAxis:P-U-H-T.mainAxis,q=y?-S[R]/2+I+U+$+T.mainAxis:B+U+$+T.mainAxis,Y=i.elements.arrow&&OD(i.elements.arrow),K=Y?"y"===_?Y.clientTop||0:Y.clientLeft||0:0,X=null!=(M=null==E?void 0:E[_])?M:0,J=Ai(u?Oy(L,D+V-X-K):L,D,u?Ov(j,D+q-X):j);w[_]=J,N[_]=J-D}if(void 0!==o&&o){var G,Z,Q="x"===_?"top":OI,ee="x"===_?OL:Oj,et=w[b],ei="y"===b?"height":"width",en=et+m[Q],er=et-m[ee],es=-1!==["top",OI].indexOf(g),eo=null!=(Z=null==E?void 0:E[b])?Z:0,ea=es?en:et-S[ei]-k[ei]-eo+T.altAxis,el=es?et+S[ei]+k[ei]-eo-T.altAxis:er,ec=u&&es?(G=Ai(ea,et,el))>el?el:G:Ai(u?ea:en,et,u?el:er);w[b]=ec,N[b]=ec-et}i.modifiersData[r]=N}},requiresIfExists:["offset"]},{name:"arrow",enabled:!0,phase:"main",fn:function(e){var i,n=e.state,r=e.name,s=e.options,o=n.elements.arrow,a=n.modifiersData.popperOffsets,l=OK(n.placement),c=OJ(l),h=[OI,Oj].indexOf(l)>=0?"height":"width";if(o&&a){var d,u=(d=s.padding,OQ("number"!=typeof(d="function"==typeof d?d(Object.assign({},n.rects,{placement:n.placement})):d)?d:O0(d,OB))),p=OM(o),f="y"===c?"top":OI,m="y"===c?OL:Oj,g=n.rects.reference[h]+n.rects.reference[c]-a[c]-n.rects.popper[h],v=a[c]-n.rects.reference[c],y=OD(o),_=y?"y"===c?y.clientHeight||0:y.clientWidth||0:0,b=u[f],w=_-p[h]-u[m],S=_/2-p[h]/2+(g/2-v/2),k=Ai(b,S,w);n.modifiersData[r]=((i={})[c]=k,i.centerOffset=k-S,i)}},effect:function(e){var i=e.state,n=e.options.element,r=void 0===n?"[data-popper-arrow]":n;null==r||("string"!=typeof r||(r=i.elements.popper.querySelector(r)))&&OV(i.elements.popper,r)&&(i.elements.arrow=r)},requires:["popperOffsets"],requiresIfExists:["preventOverflow"]},{name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:function(e){var i=e.state,n=e.name,r=i.rects.reference,s=i.rects.popper,o=i.modifiersData.preventOverflow,a=O1(i,{elementContext:"reference"}),l=O1(i,{altBoundary:!0}),c=An(a,r),h=An(l,s,o),d=Ar(c),u=Ar(h);i.modifiersData[n]={referenceClippingOffsets:c,popperEscapeOffsets:h,isReferenceHidden:d,hasPopperEscaped:u},i.attributes.popper=Object.assign({},i.attributes.popper,{"data-popper-reference-hidden":d,"data-popper-escaped":u})}}]}).defaultModifiers)?[]:Dh,Dp=void 0===(Du=Dc.defaultOptions)?O2:Du,function(e,i,n){void 0===n&&(n=Dp);var r,s,o={placement:"bottom",orderedModifiers:[],options:Object.assign({},O2,Dp),modifiersData:{},elements:{reference:e,popper:i},attributes:{},styles:{}},a=[],l=!1,c={state:o,setOptions:function(n){var r,s,l,d,u,p,f="function"==typeof n?n(o.options):n;h(),o.options=Object.assign({},Dp,o.options,f),o.scrollParents={reference:Of(e)?OA(e):e.contextElement?OA(e.contextElement):[],popper:OA(i)};var m=(s=Object.keys(r=[].concat(Dd,o.options.modifiers).reduce(function(e,i){var n=e[i.name];return e[i.name]=n?Object.assign({},n,i,{options:Object.assign({},n.options,i.options),data:Object.assign({},n.data,i.data)}):i,e},{})).map(function(e){return r[e]}),l=new Map,d=new Set,u=[],s.forEach(function(e){l.set(e.name,e)}),s.forEach(function(e){d.has(e.name)||function e(i){d.add(i.name),[].concat(i.requires||[],i.requiresIfExists||[]).forEach(function(i){if(!d.has(i)){var n=l.get(i);n&&e(n)}}),u.push(i)}(e)}),p=u,OU.reduce(function(e,i){return e.concat(p.filter(function(e){return e.phase===i}))},[]));return o.orderedModifiers=m.filter(function(e){return e.enabled}),o.orderedModifiers.forEach(function(e){var i=e.name,n=e.options,r=e.effect;if("function"==typeof r){var s=r({state:o,name:i,instance:c,options:void 0===n?{}:n});a.push(s||function(){})}}),c.update()},forceUpdate:function(){if(!l){var e=o.elements,i=e.reference,n=e.popper;if(O5(i,n)){o.rects={reference:(r=OD(n),s="fixed"===o.options.strategy,a=Om(r),p=Om(r)&&(d=O_((h=r.getBoundingClientRect()).width)/r.offsetWidth||1,u=O_(h.height)/r.offsetHeight||1,1!==d||1!==u),f=OC(r),m=Ow(i,p,s),g={scrollLeft:0,scrollTop:0},v={x:0,y:0},(a||!a&&!s)&&(("body"!==Ok(r)||ON(f))&&(g=function(e){return e!==Op(e)&&Om(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:OS(e)}(r)),Om(r)?(v=Ow(r,!0),v.x+=r.clientLeft,v.y+=r.clientTop):f&&(v.x=OT(f))),{x:m.left+g.scrollLeft-v.x,y:m.top+g.scrollTop-v.y,width:m.width,height:m.height}),popper:OM(n)},o.reset=!1,o.placement=o.options.placement,o.orderedModifiers.forEach(function(e){return o.modifiersData[e.name]=Object.assign({},e.data)});for(var r,s,a,h,d,u,p,f,m,g,v,y=0;y<o.orderedModifiers.length;y++){if(!0===o.reset){o.reset=!1,y=-1;continue}var _=o.orderedModifiers[y],b=_.fn,w=_.options,S=void 0===w?{}:w,k=_.name;"function"==typeof b&&(o=b({state:o,options:S,name:k,instance:c})||o)}}}},update:(r=function(){return new Promise(function(e){c.forceUpdate(),e(o)})},function(){return s||(s=new Promise(function(e){Promise.resolve().then(function(){s=void 0,e(r())})})),s}),destroy:function(){h(),l=!0}};if(!O5(e,i))return c;function h(){a.forEach(function(e){return e()}),a=[]}return c.setOptions(n).then(function(e){!l&&n.onFirstUpdate&&n.onFirstUpdate(e)}),c}),Ao="tippy-content",Aa="tippy-arrow",Al="tippy-svg-arrow",Ac={passive:!0,capture:!0},Ah=function(){return document.body};function Ad(e,i,n){if(Array.isArray(e)){var r=e[i];return null==r?Array.isArray(n)?n[i]:n:r}return e}function Au(e,i){var n=({}).toString.call(e);return 0===n.indexOf("[object")&&n.indexOf(i+"]")>-1}function Ap(e,i){return"function"==typeof e?e.apply(void 0,i):e}function Af(e,i){var n;return 0===i?e:function(r){clearTimeout(n),n=setTimeout(function(){e(r)},i)}}function Am(e){return[].concat(e)}function Ag(e,i){-1===e.indexOf(i)&&e.push(i)}function Av(e){return[].slice.call(e)}function Ay(e){return Object.keys(e).reduce(function(i,n){return void 0!==e[n]&&(i[n]=e[n]),i},{})}function A_(){return document.createElement("div")}function Ab(e){return["Element","Fragment"].some(function(i){return Au(e,i)})}function Ax(e,i){e.forEach(function(e){e&&(e.style.transitionDuration=i+"ms")})}function Aw(e,i){e.forEach(function(e){e&&e.setAttribute("data-state",i)})}function AS(e,i,n){var r=i+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(i){e[r](i,n)})}function Ak(e,i){for(var n,r=i;r;){if(e.contains(r))return!0;r=null==r.getRootNode||null==(n=r.getRootNode())?void 0:n.host}return!1}var AC={isTouch:!1},AT=0;function AE(){!AC.isTouch&&(AC.isTouch=!0,window.performance&&document.addEventListener("mousemove",AN))}function AN(){var e=performance.now();e-AT<20&&(AC.isTouch=!1,document.removeEventListener("mousemove",AN)),AT=e}function AM(){var e=document.activeElement;if(e&&e._tippy&&e._tippy.reference===e){var i=e._tippy;e.blur&&!i.state.isVisible&&e.blur()}}var AO=!!("u">typeof window&&"u">typeof document)&&!!window.msCrypto,AA=Object.assign({appendTo:Ah,aria:{content:"auto",expanded:"auto"},delay:0,duration:[300,250],getReferenceClientRect:null,hideOnClick:!0,ignoreAttributes:!1,interactive:!1,interactiveBorder:2,interactiveDebounce:0,moveTransition:"",offset:[0,10],onAfterUpdate:function(){},onBeforeUpdate:function(){},onCreate:function(){},onDestroy:function(){},onHidden:function(){},onHide:function(){},onMount:function(){},onShow:function(){},onShown:function(){},onTrigger:function(){},onUntrigger:function(){},onClickOutside:function(){},placement:"top",plugins:[],popperOptions:{},render:null,showOnCreate:!1,touch:!0,trigger:"mouseenter focus",triggerTarget:null},{animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},{allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999}),AR=Object.keys(AA);function AD(e){var i=(e.plugins||[]).reduce(function(i,n){var r,s=n.name,o=n.defaultValue;return s&&(i[s]=void 0!==e[s]?e[s]:null!=(r=AA[s])?r:o),i},{});return Object.assign({},e,i)}function AL(e,i){var n,r=Object.assign({},i,{content:Ap(i.content,[e])},i.ignoreAttributes?{}:((n=i.plugins)?Object.keys(AD(Object.assign({},AA,{plugins:n}))):AR).reduce(function(i,n){var r=(e.getAttribute("data-tippy-"+n)||"").trim();if(!r)return i;if("content"===n)i[n]=r;else try{i[n]=JSON.parse(r)}catch(e){i[n]=r}return i},{}));return r.aria=Object.assign({},AA.aria,r.aria),r.aria={expanded:"auto"===r.aria.expanded?i.interactive:r.aria.expanded,content:"auto"===r.aria.content?i.interactive?null:"describedby":r.aria.content},r}function Aj(e,i){e.innerHTML=i}function AI(e){var i=A_();return!0===e?i.className=Aa:(i.className=Al,Ab(e)?i.appendChild(e):Aj(i,e)),i}function AP(e,i){Ab(i.content)?(Aj(e,""),e.appendChild(i.content)):"function"!=typeof i.content&&(i.allowHTML?Aj(e,i.content):e.textContent=i.content)}function AB(e){var i=e.firstElementChild,n=Av(i.children);return{box:i,content:n.find(function(e){return e.classList.contains(Ao)}),arrow:n.find(function(e){return e.classList.contains(Aa)||e.classList.contains(Al)}),backdrop:n.find(function(e){return e.classList.contains("tippy-backdrop")})}}function Az(e){var i=A_(),n=A_();n.className="tippy-box",n.setAttribute("data-state","hidden"),n.setAttribute("tabindex","-1");var r=A_();function s(n,r){var s=AB(i),o=s.box,a=s.content,l=s.arrow;r.theme?o.setAttribute("data-theme",r.theme):o.removeAttribute("data-theme"),"string"==typeof r.animation?o.setAttribute("data-animation",r.animation):o.removeAttribute("data-animation"),r.inertia?o.setAttribute("data-inertia",""):o.removeAttribute("data-inertia"),o.style.maxWidth="number"==typeof r.maxWidth?r.maxWidth+"px":r.maxWidth,r.role?o.setAttribute("role",r.role):o.removeAttribute("role"),(n.content!==r.content||n.allowHTML!==r.allowHTML)&&AP(a,e.props),r.arrow?l?n.arrow!==r.arrow&&(o.removeChild(l),o.appendChild(AI(r.arrow))):o.appendChild(AI(r.arrow)):l&&o.removeChild(l)}return r.className=Ao,r.setAttribute("data-state","hidden"),AP(r,e.props),i.appendChild(n),n.appendChild(r),s(e.props,e.props),{popper:i,onUpdate:s}}Az.$$tippy=!0;var AF=1,AW=[],AH=[];function A$(e,i){void 0===i&&(i={});var n,r=AA.plugins.concat(i.plugins||[]);document.addEventListener("touchstart",AE,Ac),window.addEventListener("blur",AM);var s=Object.assign({},i,{plugins:r}),o=(Ab(n=e)?[n]:Au(n,"NodeList")?Av(n):Array.isArray(n)?n:Av(document.querySelectorAll(n))).reduce(function(e,i){var n=i&&function(e,i){var n,r,s,o,a,l,c,h,d=AL(e,Object.assign({},AA,AD(Ay(i)))),u=!1,p=!1,f=!1,m=!1,g=[],v=Af(Y,d.interactiveDebounce),y=AF++,_=(n=d.plugins).filter(function(e,i){return n.indexOf(e)===i}),b={id:y,reference:e,popper:A_(),popperInstance:null,props:d,state:{isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},plugins:_,clearDelayTimeouts:function(){clearTimeout(r),clearTimeout(s),cancelAnimationFrame(o)},setProps:function(i){if(!b.state.isDestroyed){D("onBeforeUpdate",[b,i]),V();var n=b.props,r=AL(e,Object.assign({},n,Ay(i),{ignoreAttributes:!0}));b.props=r,U(),n.interactiveDebounce!==r.interactiveDebounce&&(I(),v=Af(Y,r.interactiveDebounce)),n.triggerTarget&&!r.triggerTarget?Am(n.triggerTarget).forEach(function(e){e.removeAttribute("aria-expanded")}):r.triggerTarget&&e.removeAttribute("aria-expanded"),j(),R(),k&&k(n,r),b.popperInstance&&(G(),Q().forEach(function(e){requestAnimationFrame(e._tippy.popperInstance.forceUpdate)})),D("onAfterUpdate",[b,i])}},setContent:function(e){b.setProps({content:e})},show:function(){var i=b.state.isVisible,n=b.state.isDestroyed,r=!b.state.isEnabled,s=AC.isTouch&&!b.props.touch,o=Ad(b.props.duration,0,AA.duration);if(!(i||n||r||s||(h||e).hasAttribute("disabled"))&&(D("onShow",[b],!1),!1!==b.props.onShow(b))){if(b.state.isVisible=!0,M()&&(S.style.visibility="visible"),R(),F(),b.state.isMounted||(S.style.transition="none"),M()){var a,l,d,u=AB(S);Ax([u.box,u.content],0)}c=function(){var e;if(b.state.isVisible&&!m){if(m=!0,S.offsetHeight,S.style.transition=b.props.moveTransition,M()&&b.props.animation){var i=AB(S),n=i.box,r=i.content;Ax([n,r],o),Aw([n,r],"visible")}L(),j(),Ag(AH,b),null==(e=b.popperInstance)||e.forceUpdate(),D("onMount",[b]),b.props.animation&&M()&&H(o,function(){b.state.isShown=!0,D("onShown",[b])})}},l=b.props.appendTo,d=h||e,(a=b.props.interactive&&l===Ah||"parent"===l?d.parentNode:Ap(l,[d])).contains(S)||a.appendChild(S),b.state.isMounted=!0,G()}},hide:function(){var e=!b.state.isVisible,i=b.state.isDestroyed,n=!b.state.isEnabled,r=Ad(b.props.duration,1,AA.duration);if(!e&&!i&&!n&&(D("onHide",[b],!1),!1!==b.props.onHide(b))){if(b.state.isVisible=!1,b.state.isShown=!1,m=!1,u=!1,M()&&(S.style.visibility="hidden"),I(),W(),R(!0),M()){var s,o=AB(S),a=o.box,l=o.content;b.props.animation&&(Ax([a,l],r),Aw([a,l],"hidden"))}(L(),j(),b.props.animation)?M()&&(s=b.unmount,H(r,function(){!b.state.isVisible&&S.parentNode&&S.parentNode.contains(S)&&s()})):b.unmount()}},hideWithInteractivity:function(e){O().addEventListener("mousemove",v),Ag(AW,v),v(e)},enable:function(){b.state.isEnabled=!0},disable:function(){b.hide(),b.state.isEnabled=!1},unmount:function(){b.state.isVisible&&b.hide(),b.state.isMounted&&(Z(),Q().forEach(function(e){e._tippy.unmount()}),S.parentNode&&S.parentNode.removeChild(S),AH=AH.filter(function(e){return e!==b}),b.state.isMounted=!1,D("onHidden",[b]))},destroy:function(){b.state.isDestroyed||(b.clearDelayTimeouts(),b.unmount(),V(),delete e._tippy,b.state.isDestroyed=!0,D("onDestroy",[b]))}};if(!d.render)return b;var w=d.render(b),S=w.popper,k=w.onUpdate;S.setAttribute("data-tippy-root",""),S.id="tippy-"+b.id,b.popper=S,e._tippy=b,S._tippy=b;var C=_.map(function(e){return e.fn(b)}),T=e.hasAttribute("aria-expanded");return U(),j(),R(),D("onCreate",[b]),d.showOnCreate&&ee(),S.addEventListener("mouseenter",function(){b.props.interactive&&b.state.isVisible&&b.clearDelayTimeouts()}),S.addEventListener("mouseleave",function(){b.props.interactive&&b.props.trigger.indexOf("mouseenter")>=0&&O().addEventListener("mousemove",v)}),b;function E(){var e=b.props.touch;return Array.isArray(e)?e:[e,0]}function N(){return"hold"===E()[0]}function M(){var e;return!!(null!=(e=b.props.render)&&e.$$tippy)}function O(){var i,n,r=(h||e).parentNode;return r&&null!=(n=Am(r)[0])&&null!=(i=n.ownerDocument)&&i.body?n.ownerDocument:document}function A(e){return b.state.isMounted&&!b.state.isVisible||AC.isTouch||a&&"focus"===a.type?0:Ad(b.props.delay,+!e,AA.delay)}function R(e){void 0===e&&(e=!1),S.style.pointerEvents=b.props.interactive&&!e?"":"none",S.style.zIndex=""+b.props.zIndex}function D(e,i,n){if(void 0===n&&(n=!0),C.forEach(function(n){n[e]&&n[e].apply(n,i)}),n){var r;(r=b.props)[e].apply(r,i)}}function L(){var i=b.props.aria;if(i.content){var n="aria-"+i.content,r=S.id;Am(b.props.triggerTarget||e).forEach(function(e){var i=e.getAttribute(n);if(b.state.isVisible)e.setAttribute(n,i?i+" "+r:r);else{var s=i&&i.replace(r,"").trim();s?e.setAttribute(n,s):e.removeAttribute(n)}})}}function j(){!T&&b.props.aria.expanded&&Am(b.props.triggerTarget||e).forEach(function(i){b.props.interactive?i.setAttribute("aria-expanded",b.state.isVisible&&i===(h||e)?"true":"false"):i.removeAttribute("aria-expanded")})}function I(){O().removeEventListener("mousemove",v),AW=AW.filter(function(e){return e!==v})}function P(i){if(!AC.isTouch||!f&&"mousedown"!==i.type){var n=i.composedPath&&i.composedPath()[0]||i.target;if(!(b.props.interactive&&Ak(S,n))){if(Am(b.props.triggerTarget||e).some(function(e){return Ak(e,n)})){if(AC.isTouch||b.state.isVisible&&b.props.trigger.indexOf("click")>=0)return}else D("onClickOutside",[b,i]);!0===b.props.hideOnClick&&(b.clearDelayTimeouts(),b.hide(),p=!0,setTimeout(function(){p=!1}),b.state.isMounted||W())}}}function B(){f=!0}function z(){f=!1}function F(){var e=O();e.addEventListener("mousedown",P,!0),e.addEventListener("touchend",P,Ac),e.addEventListener("touchstart",z,Ac),e.addEventListener("touchmove",B,Ac)}function W(){var e=O();e.removeEventListener("mousedown",P,!0),e.removeEventListener("touchend",P,Ac),e.removeEventListener("touchstart",z,Ac),e.removeEventListener("touchmove",B,Ac)}function H(e,i){var n=AB(S).box;function r(e){e.target===n&&(AS(n,"remove",r),i())}if(0===e)return i();AS(n,"remove",l),AS(n,"add",r),l=r}function $(i,n,r){void 0===r&&(r=!1),Am(b.props.triggerTarget||e).forEach(function(e){e.addEventListener(i,n,r),g.push({node:e,eventType:i,handler:n,options:r})})}function U(){N()&&($("touchstart",q,{passive:!0}),$("touchend",K,{passive:!0})),b.props.trigger.split(/\s+/).filter(Boolean).forEach(function(e){if("manual"!==e)switch($(e,q),e){case"mouseenter":$("mouseleave",K);break;case"focus":$(AO?"focusout":"blur",X);break;case"focusin":$("focusout",X)}})}function V(){g.forEach(function(e){var i=e.node,n=e.eventType,r=e.handler,s=e.options;i.removeEventListener(n,r,s)}),g=[]}function q(e){var i,n=!1;if(!(!b.state.isEnabled||J(e))&&!p){var r=(null==(i=a)?void 0:i.type)==="focus";a=e,h=e.currentTarget,j(),!b.state.isVisible&&Au(e,"MouseEvent")&&AW.forEach(function(i){return i(e)}),"click"===e.type&&(0>b.props.trigger.indexOf("mouseenter")||u)&&!1!==b.props.hideOnClick&&b.state.isVisible?n=!0:ee(e),"click"===e.type&&(u=!n),n&&!r&&et(e)}}function Y(i){var n,r,s,o=i.target,a=(h||e).contains(o)||S.contains(o);("mousemove"!==i.type||!a)&&(n=Q().concat(S).map(function(e){var i,n=null==(i=e._tippy.popperInstance)?void 0:i.state;return n?{popperRect:e.getBoundingClientRect(),popperState:n,props:d}:null}).filter(Boolean),r=i.clientX,s=i.clientY,n.every(function(e){var i=e.popperRect,n=e.popperState,o=e.props.interactiveBorder,a=n.placement.split("-")[0],l=n.modifiersData.offset;if(!l)return!0;var c="bottom"===a?l.top.y:0,h="top"===a?l.bottom.y:0,d="right"===a?l.left.x:0,u="left"===a?l.right.x:0,p=i.top-s+c>o,f=s-i.bottom-h>o,m=i.left-r+d>o,g=r-i.right-u>o;return p||f||m||g})&&(I(),et(i)))}function K(e){if(!(J(e)||b.props.trigger.indexOf("click")>=0&&u)){if(b.props.interactive)return void b.hideWithInteractivity(e);et(e)}}function X(i){0>b.props.trigger.indexOf("focusin")&&i.target!==(h||e)||b.props.interactive&&i.relatedTarget&&S.contains(i.relatedTarget)||et(i)}function J(e){return!!AC.isTouch&&N()!==e.type.indexOf("touch")>=0}function G(){Z();var i=b.props,n=i.popperOptions,r=i.placement,s=i.offset,o=i.getReferenceClientRect,a=i.moveTransition,l=M()?AB(S).arrow:null,d=o?{getBoundingClientRect:o,contextElement:o.contextElement||h||e}:e,u=[{name:"offset",options:{offset:s}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!a}},{name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(e){var i=e.state;if(M()){var n=AB(S).box;["placement","reference-hidden","escaped"].forEach(function(e){"placement"===e?n.setAttribute("data-placement",i.placement):i.attributes.popper["data-popper-"+e]?n.setAttribute("data-"+e,""):n.removeAttribute("data-"+e)}),i.attributes.popper={}}}}];M()&&l&&u.push({name:"arrow",options:{element:l,padding:3}}),u.push.apply(u,(null==n?void 0:n.modifiers)||[]),b.popperInstance=As(d,S,Object.assign({},n,{placement:r,onFirstUpdate:c,modifiers:u}))}function Z(){b.popperInstance&&(b.popperInstance.destroy(),b.popperInstance=null)}function Q(){return Av(S.querySelectorAll("[data-tippy-root]"))}function ee(e){b.clearDelayTimeouts(),e&&D("onTrigger",[b,e]),F();var i=A(!0),n=E(),s=n[0],o=n[1];AC.isTouch&&"hold"===s&&o&&(i=o),i?r=setTimeout(function(){b.show()},i):b.show()}function et(e){if(b.clearDelayTimeouts(),D("onUntrigger",[b,e]),!b.state.isVisible)return void W();if(!(b.props.trigger.indexOf("mouseenter")>=0&&b.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(e.type)>=0)||!u){var i=A(!1);i?s=setTimeout(function(){b.state.isVisible&&b.hide()},i):o=requestAnimationFrame(function(){b.hide()})}}}(i,s);return n&&e.push(n),e},[]);return Ab(e)?o[0]:o}function AU(e){return e.description??e.email??""}A$.defaultProps=AA,A$.setDefaultProps=function(e){Object.keys(e).forEach(function(i){AA[i]=e[i]})},A$.currentInput=AC,Object.assign({},O8,{effect:function(e){var i=e.state,n={popper:{position:i.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(i.elements.popper.style,n.popper),i.styles=n,i.elements.arrow&&Object.assign(i.elements.arrow.style,n.arrow)}}),A$.setDefaultProps({render:Az});let AV=(0,iM.forwardRef)(function(e,i){let[n,r]=(0,iM.useState)(0),s=(0,n0.useTranslations)("composer");return((0,iM.useEffect)(()=>{r(0)},[e.items]),(0,iM.useImperativeHandle)(i,()=>({onKeyDown:({event:i})=>{if(!e.items.length)return!1;if("ArrowUp"===i.key)return i.preventDefault(),r(i=>(i+e.items.length-1)%e.items.length),!0;if("ArrowDown"===i.key)return i.preventDefault(),r(i=>(i+1)%e.items.length),!0;if("Enter"===i.key){let r;return i.preventDefault(),(r=e.items[n])&&e.command(r),!0}return!1}}),[e.items,n]),e.items.length)?(0,iN.jsxs)("div",{className:"suggestion-menu",children:[(0,iN.jsx)("div",{className:"suggestion-header",children:s("selectOption")}),(0,iN.jsx)("div",{className:"suggestion-list",children:e.items.map((i,s)=>{let o=s===n;return(0,iN.jsxs)("div",{className:"suggestion-item","data-selected":o?"true":"false",onMouseEnter:()=>r(s),onMouseDown:n=>{n.preventDefault(),e.command(i)},children:[(0,iN.jsx)("div",{className:"suggestion-title",children:i.label??i.name??i.title??i.id}),AU(i)?(0,iN.jsx)("div",{className:"suggestion-desc",children:AU(i)}):null]},i.id)})})]}):(0,iN.jsx)("div",{className:"suggestion-menu",children:(0,iN.jsx)("div",{className:"suggestion-empty",children:s("noMatch")})})});function Aq(){let e=null,i=null;return{onStart(n){e=new Es(AV,{props:n,editor:n.editor}),n.clientRect&&(i=A$("body",{getReferenceClientRect:()=>n.clientRect?.()??new DOMRect,appendTo:()=>document.body,content:e.element,showOnCreate:!0,interactive:!0,trigger:"manual",placement:"bottom-start"}))},onUpdate(n){e?.updateProps(n),i?.[0]&&n.clientRect&&i[0].setProps({getReferenceClientRect:()=>n.clientRect?.()??new DOMRect})},onKeyDown:i=>!!e?.ref&&"object"==typeof e.ref&&"onKeyDown"in e.ref&&e.ref.onKeyDown(i),onExit(){i?.[0]?.destroy(),e?.destroy()}}}let AY=[{id:"heading1",title:"标题 1",description:"切换为一级标题"},{id:"blockquote",title:"引用",description:"切换为引用块"},{id:"divider",title:"分割线",description:"插入一条分割线"},{id:"attach",title:"添加附件",description:"打开文件选择器"}];function AK(e){return C4.create({name:"slashCommand",addOptions:()=>({suggestion:{char:"/",items:({query:e})=>{let i=e.toLowerCase();return AY.filter(e=>`${e.title} ${e.description}`.toLowerCase().includes(i)).map(e=>({id:e.id,title:e.title,description:e.description}))},command:({editor:i,range:n,props:r})=>{switch(i.chain().focus().deleteRange(n).run(),r.id){case"heading1":i.chain().focus().toggleHeading({level:1}).run();break;case"blockquote":i.chain().focus().toggleBlockquote().run();break;case"divider":i.chain().focus().setHorizontalRule().run();break;case"attach":e?.()}},render:()=>Aq()}}),addProseMirrorPlugins(){return[Os({editor:this.editor,...this.options.suggestion})]}})}var AX=e.i(444433);function AJ(e,i){return e.subject||e.title||e.activeForm||e.content||i}let AG=(0,iM.forwardRef)(function({channelName:e,channelId:i,workspaceId:n,channel:r,agents:s,onSend:o,isProcessing:a=!1,onStop:l},c){let h=(0,n0.useTranslations)("chat"),[d,u]=(0,iM.useState)([]),[p,f]=(0,iM.useState)([]),[m,g]=(0,iM.useState)(!1),[v,y]=(0,iM.useState)(!1),_=(0,iM.useRef)(a),b=(0,iM.useRef)(o),w=(0,iM.useRef)(null),S=(0,iM.useRef)(null),k=(0,iM.useRef)(!1),C=(0,iM.useRef)(null),T=(0,iM.useRef)(s),E=(0,iM.useRef)(r),{saveDraft:N,clearDraft:M,updateChannel:O}=hR(),A=r.pinnedMentionId,R=A===d[0]&&!!A,D=(0,iM.useMemo)(()=>{if(0===d.length)return[];let e=new Map(s.map(e=>[e.id,e]));return d.map(i=>e.get(i)).filter(e=>!!e)},[s,d])[0],L=function(e){if(!e)return[];let i=e.mcpServers;return!i||"object"!=typeof i||Array.isArray(i)?[]:Object.keys(i)}(D?.mcps),j=D?.skills??[],I=(0,iM.useMemo)(()=>{let e=new Set(D?.tools??[]);return(AX.BUILT_IN_AGENT_TOOLS??[]).filter(i=>e.has(i.name)).map(e=>{var i;return{...e,icon:"CreateCurrentChannelIssue"===(i=e.name)?y7:"ViewCurrentChannelIssue"===i?y1:"AddCurrentChannelComment"===i?y3:_t}})},[D?.tools]);(0,iM.useEffect)(()=>{_.current=a},[a]),(0,iM.useEffect)(()=>{b.current=o},[o]),(0,iM.useEffect)(()=>{T.current=s},[s]),(0,iM.useEffect)(()=>{E.current=r},[r]);let P=(0,iM.useCallback)(e=>{S.current&&clearTimeout(S.current),S.current=setTimeout(()=>{e.trim()?N(n,i,e):M(n,i)},1e3)},[n,i,N,M]),B=(0,iM.useCallback)(async()=>{let e=w.current;if(!e||_.current||k.current)return;let r=e.getText().trim();if(!r&&0===p.length)return;let s=AQ(e.getJSON());k.current=!0,g(!0),S.current&&(clearTimeout(S.current),S.current=null);try{let o=await Promise.all(p.map(AZ));b.current(r?function(e){if(!e)return e;let i=e.replace(/<\/?p>/g,"");return/<[^>]+>/.test(i)?e:e.replace(/<\/p>\s*<p>/g,"\n").replace(/<\/?p>/g,"")}(e.getHTML()):"",s,o),e.commands.clearContent(),f(e=>(e.forEach(e=>URL.revokeObjectURL(e.preview)),[])),u([]),M(n,i)}finally{k.current=!1,g(!1)}},[p,n,i,M]),{getRootProps:z,getInputProps:F,open:W}=(0,Oc.useDropzone)({noClick:!0,noKeyboard:!0,multiple:!0,accept:{"image/*":[],"application/pdf":[".pdf"],"application/msword":[".doc"],"application/vnd.openxmlformats-officedocument.wordprocessingml.document":[".docx"],"text/*":[".txt",".md",".csv",".json"]},onDrop:e=>{f(i=>[...i,...e.map(e=>({file:e,preview:URL.createObjectURL(e)}))])}});(0,iM.useEffect)(()=>()=>{p.forEach(e=>URL.revokeObjectURL(e.preview))},[p]);let H=(0,iM.useCallback)((e,i)=>{let{tr:n}=e.state,r=!1,s=[];e.state.doc.descendants((e,n)=>{"mention"===e.type.name&&e.attrs?.id!==i&&s.push({pos:n,nodeSize:e.nodeSize})});for(let e=s.length-1;e>=0;e--){let{pos:i,nodeSize:o}=s[e];n.delete(i,i+o),r=!0}r&&e.view.dispatch(n)},[]),$=(0,iM.useMemo)(()=>Ol.configure({HTMLAttributes:{class:"mention"},suggestion:{char:"@",items:({query:e})=>{let i=e.toLowerCase();return T.current.filter(e=>!1!==e.enabled&&`${e.name} ${e.role} ${e.description||""}`.toLowerCase().includes(i)).slice(0,6).map(e=>({id:e.id,label:e.name||e.role,description:`${e.role}${e.description?` \xb7 ${e.description}`:""}`}))},command:({editor:e,range:i,props:n})=>{H(e,n.id),e.chain().focus().insertContentAt(i,[{type:"mention",attrs:n}]).run()},render:()=>Aq()}}),[H]),U=(0,iM.useMemo)(()=>AK(()=>{document.querySelector("[data-chat-file-input]")?.click()}),[]),V=(0,iM.useRef)(B);V.current=B;let q=Ee({immediatelyRender:!1,extensions:[Oi,M9.configure({placeholder:h("input.placeholder",{channel:e})}),$,U],editorProps:{attributes:{class:"tiptap tiptap-chat"},handleKeyDown:(e,i)=>"Enter"===i.key&&!i.shiftKey&&!document.querySelector(".suggestion-menu")&&(i.preventDefault(),V.current(),!0),handlePaste:(e,i)=>{let n,r=i.clipboardData?.getData("text/html");if(r?.includes('data-type="mention"'))return!1;let s=i.clipboardData?.getData("text/plain");if(!s||!/@\S+/.test(s))return!1;let o=T.current;if(0===o.length)return!1;let a=/@(\S+)/g,l=!1;for(;null!==(n=a.exec(s));)if(o.some(e=>e.name===n[1]||e.id===n[1]||e.role===n[1])){l=!0;break}if(!l)return!1;let c=w.current;return!!c&&(c.commands.insertContent(A0(s,o)),!0)}},content:"",onUpdate:({editor:e})=>{let i=AQ(e.getJSON());u(e=>e.length===i.length&&e.every((e,n)=>e===i[n])?e:i),P(e.getHTML())}},[$,U,e]);(0,iM.useEffect)(()=>{w.current=q},[q]),(0,iM.useEffect)(()=>{if(!q||C.current===i)return;C.current=i,S.current&&(clearTimeout(S.current),S.current=null);let e=E.current.draft,n=E.current.pinnedMentionId,r=n?T.current.find(e=>e.id===n):void 0,s=e?.content?e.content:r?[{type:"mention",attrs:{id:r.id,label:r.name||r.role}},{type:"text",text:" "}]:"";q.commands.setContent(s,{emitUpdate:!1}),u(AQ(q.getJSON()))},[q,i]),(0,iM.useImperativeHandle)(c,()=>({setContent:(e,i)=>{if(q){if(e.includes('data-type="mention"'))q.commands.setContent(e,{emitUpdate:!1});else{let n=/<[a-z][\s\S]*>/i.test(e)?e.replace(/<[^>]*>/g,""):e,r=i??T.current;r.length>0&&/@\S+/.test(n)?q.commands.setContent(A0(n,r),{emitUpdate:!1}):q.commands.setContent(n,{emitUpdate:!1})}q.commands.focus("end")}}}),[q]);let Y=(0,iM.useCallback)(()=>{B()},[B]),K=(!!T6({editor:q,selector:e=>!!e.editor?.getText().trim()})||p.length>0)&&!m,X=(0,iM.useCallback)(e=>{f(i=>{let n=[...i],[r]=n.splice(e,1);return r&&URL.revokeObjectURL(r.preview),n})},[]),J=(0,iM.useCallback)(()=>{let e=d[0];e&&O(n,i,{pinnedMentionId:R?void 0:e})},[d,R,n,i,O]),G=(0,iN.jsxs)(iN.Fragment,{children:[(0,iN.jsxs)(rT.DropdownMenu,{children:[(0,iN.jsx)(rT.DropdownMenuTrigger,{render:(0,iN.jsx)(hv.Button,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 rounded-full border border-border hover:bg-accent"}),children:(0,iN.jsx)(y7,{className:"size-3"})}),(0,iN.jsx)(rT.DropdownMenuContent,{align:"start",className:"max-w-xs rounded-2xl p-1.5",children:(0,iN.jsxs)(rT.DropdownMenuGroup,{className:"space-y-1",children:[(0,iN.jsxs)(rT.DropdownMenuItem,{className:"rounded-[calc(1rem-6px)] text-xs",onClick:W,children:[(0,iN.jsx)(y4,{size:16,className:"opacity-60"}),h("input.attachFiles")]}),(0,iN.jsxs)(rT.DropdownMenuItem,{className:"rounded-[calc(1rem-6px)] text-xs",onClick:()=>{},children:[(0,iN.jsx)(y0,{size:16,className:"opacity-60"}),h("input.codeInterpreter")]}),(0,iN.jsxs)(rT.DropdownMenuItem,{className:"rounded-[calc(1rem-6px)] text-xs",onClick:()=>{},children:[(0,iN.jsx)(_n,{size:16,className:"opacity-60"}),h("input.webSearch")]}),(0,iN.jsxs)(rT.DropdownMenuItem,{className:"rounded-[calc(1rem-6px)] text-xs",onClick:()=>{},children:[(0,iN.jsx)(y2,{size:16,className:"opacity-60"}),h("input.chatHistory")]})]})})]}),(0,iN.jsxs)(hv.Button,{variant:"ghost",size:"sm",onClick:()=>y(!v),className:(0,nQ.cn)("h-7 px-2 rounded-full border border-border hover:bg-accent",{"bg-primary/10 text-primary border-primary/30":v,"text-muted-foreground":!v}),children:[(0,iN.jsx)(_i,{className:"size-3"}),(0,iN.jsx)("span",{className:"text-xs",children:h("input.autoMode")})]})]});return(0,iN.jsxs)("div",{className:"border-t px-4 py-2",children:[D&&(0,iN.jsxs)("div",{className:"flex items-center gap-1 mb-1.5",children:[(0,iN.jsxs)("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground bg-muted/50 rounded-full px-2 py-0.5",children:["@",D.name||D.role]}),(0,iN.jsx)("button",{type:"button",onClick:J,className:(0,nQ.cn)("inline-flex items-center justify-center size-5 rounded-full hover:bg-accent transition-colors",R?"text-primary":"text-muted-foreground"),title:R?h("input.unpinAgent"):h("input.pinAgent"),children:R?(0,iN.jsx)(y8,{className:"size-3"}):(0,iN.jsx)(y6,{className:"size-3"})})]}),(0,iN.jsx)(Ou,{editor:q,canSubmit:K,onSubmit:Y,onStop:l,isProcessing:a||m,actions:G,dropzoneProps:z(),hiddenInput:(0,iN.jsx)("input",{...F(),"data-chat-file-input":""})}),p.length>0&&(0,iN.jsx)(vW,{variant:"inline",className:"mt-2 justify-start",children:p.map((e,i)=>{var n;return(0,iN.jsxs)(vH,{data:(n=e,{id:`${n.file.name}-${n.file.lastModified}`,type:"file",filename:n.file.name,mediaType:n.file.type,url:n.preview}),onRemove:()=>X(i),children:[(0,iN.jsx)(v$,{}),(0,iN.jsx)(vU,{}),(0,iN.jsx)(vV,{})]},`${e.file.name}-${e.file.lastModified}-${i}`)})}),(0,iN.jsxs)("div",{className:"flex items-center gap-0 pt-2",children:[(0,iN.jsxs)(rT.DropdownMenu,{children:[(0,iN.jsxs)(rT.DropdownMenuTrigger,{render:(0,iN.jsx)(hv.Button,{variant:"ghost",size:"sm",className:"h-6 px-2 rounded-full border border-transparent hover:bg-accent text-muted-foreground text-xs"}),children:[(0,iN.jsx)(y9,{className:"size-3"}),(0,iN.jsxs)("span",{children:[h("input.mcp"),L.length?` ${L.length}`:""]}),(0,iN.jsx)(yG,{className:"size-3"})]}),(0,iN.jsx)(rT.DropdownMenuContent,{align:"start",className:"max-w-xs rounded-2xl p-1.5 bg-popover border-border",children:(0,iN.jsx)(rT.DropdownMenuGroup,{className:"space-y-1",children:L.length?L.map(e=>(0,iN.jsxs)(rT.DropdownMenuItem,{className:"rounded-[calc(1rem-6px)] text-xs",children:[(0,iN.jsx)(y9,{size:16,className:"opacity-60"}),e]},e)):(0,iN.jsxs)(rT.DropdownMenuItem,{className:"rounded-[calc(1rem-6px)] text-xs text-muted-foreground",children:[(0,iN.jsx)(y9,{size:16,className:"opacity-60"}),h("input.noMcp")]})})})]}),(0,iN.jsxs)(rT.DropdownMenu,{children:[(0,iN.jsxs)(rT.DropdownMenuTrigger,{render:(0,iN.jsx)(hv.Button,{variant:"ghost",size:"sm",className:"h-6 px-2 rounded-full border border-transparent hover:bg-accent text-muted-foreground text-xs"}),children:[(0,iN.jsx)(_e,{className:"size-3"}),(0,iN.jsxs)("span",{children:[h("input.skill"),j.length?` ${j.length}`:""]}),(0,iN.jsx)(yG,{className:"size-3"})]}),(0,iN.jsx)(rT.DropdownMenuContent,{align:"start",className:"max-w-xs rounded-2xl p-1.5 bg-popover border-border",children:(0,iN.jsx)(rT.DropdownMenuGroup,{className:"space-y-1",children:j.length?j.map(e=>(0,iN.jsxs)(rT.DropdownMenuItem,{className:"rounded-[calc(1rem-6px)] text-xs",children:[(0,iN.jsx)(_e,{size:16,className:"opacity-60"}),e]},e)):(0,iN.jsxs)(rT.DropdownMenuItem,{className:"rounded-[calc(1rem-6px)] text-xs text-muted-foreground",children:[(0,iN.jsx)(_e,{size:16,className:"opacity-60"}),h("input.noSkills")]})})})]}),(0,iN.jsxs)(rT.DropdownMenu,{children:[(0,iN.jsxs)(rT.DropdownMenuTrigger,{render:(0,iN.jsx)(hv.Button,{variant:"ghost",size:"sm",className:"h-6 px-2 rounded-full border border-transparent hover:bg-accent text-muted-foreground text-xs"}),children:[(0,iN.jsx)(_t,{className:"size-3"}),(0,iN.jsxs)("span",{children:[h("input.tools"),I.length?` ${I.length}`:""]}),(0,iN.jsx)(yG,{className:"size-3"})]}),(0,iN.jsx)(rT.DropdownMenuContent,{align:"start",className:"max-w-xs rounded-2xl p-1.5 bg-popover border-border",children:(0,iN.jsx)(rT.DropdownMenuGroup,{className:"space-y-1",children:I.length?I.map(({name:e,label:i,icon:n})=>(0,iN.jsxs)(rT.DropdownMenuItem,{className:"rounded-[calc(1rem-6px)] text-xs",children:[(0,iN.jsx)(n,{size:16,className:"opacity-60"}),i]},e)):(0,iN.jsxs)(rT.DropdownMenuItem,{className:"rounded-[calc(1rem-6px)] text-xs text-muted-foreground",children:[(0,iN.jsx)(_t,{size:16,className:"opacity-60"}),h("input.noTools")]})})})]}),r.todos&&r.todos.length>0&&(0,iN.jsxs)(rT.DropdownMenu,{children:[(0,iN.jsxs)(rT.DropdownMenuTrigger,{render:(0,iN.jsx)(hv.Button,{variant:"ghost",size:"sm",className:"h-6 px-2 rounded-full border border-transparent hover:bg-accent text-muted-foreground text-xs"}),children:[(0,iN.jsx)(yZ,{className:"size-3"}),(0,iN.jsxs)("span",{children:[h("input.todos")," ",r.todos.length]}),(0,iN.jsx)(yG,{className:"size-3"})]}),(0,iN.jsx)(rT.DropdownMenuContent,{align:"start",className:"max-w-xs rounded-2xl p-1.5 bg-popover border-border",children:(0,iN.jsx)(rT.DropdownMenuGroup,{className:"space-y-0.5",children:r.todos.map((e,i)=>(0,iN.jsxs)(rT.DropdownMenuItem,{className:"rounded-[calc(1rem-6px)] text-xs gap-2",onSelect:e=>e.preventDefault(),children:["completed"===e.status?(0,iN.jsx)(yZ,{size:14,className:"text-green-500 shrink-0"}):"in_progress"===e.status?(0,iN.jsx)(y5,{size:14,className:"text-blue-500 shrink-0 animate-spin",style:{animationDuration:"3s"}}):(0,iN.jsx)(yQ,{size:14,className:"text-muted-foreground shrink-0"}),(0,iN.jsx)("span",{className:(0,nQ.cn)("truncate","completed"===e.status&&"line-through text-muted-foreground"),children:AJ(e,h("untitledTodo"))})]},e.id||`${AJ(e,h("untitledTodo"))}-${i}`))})})]}),(0,iN.jsx)("div",{className:"flex-1"})]})]})});async function AZ(e){let i=new FormData;i.append("file",e.file);let n=await fetch("/api/upload",{method:"POST",body:i});if(!n.ok)throw Error(`Upload failed: ${e.file.name}`);let r=await n.json();return{name:r.name,path:r.url,url:r.url,type:r.type,size:r.size}}function AQ(e){let i=new Set,n=e=>{if(e&&("mention"===e.type&&"string"==typeof e.attrs?.id&&i.add(e.attrs.id),Array.isArray(e.content)))for(let i of e.content)n(i)};return n(e),[...i]}function A0(e,i){return e?{type:"doc",content:e.split("\n").map(e=>{let n=function(e,i){let n,r=[],s=/@(\S+)/g,o=0;for(;null!==(n=s.exec(e));){n.index>o&&r.push({type:"text",text:e.slice(o,n.index)});let a=n[1],l=i.find(e=>e.name===a||e.id===a||e.role===a);l?r.push({type:"mention",attrs:{id:l.id,label:l.name||l.role}}):r.push({type:"text",text:n[0]}),o=s.lastIndex}return o<e.length&&r.push({type:"text",text:e.slice(o)}),r}(e,i);return{type:"paragraph",content:n.length>0?n:void 0}})}:{type:"doc",content:[{type:"paragraph"}]}}let A1=({className:e,status:i,...n})=>(0,iN.jsx)(hP.Badge,{className:(0,nQ.cn)("flex items-center gap-2","group",i,e),variant:"secondary",...n}),A2=({className:e,...i})=>(0,iN.jsxs)("span",{className:(0,nQ.cn)("relative flex h-2 w-2",e),...i,children:[(0,iN.jsx)("span",{className:(0,nQ.cn)("absolute inline-flex h-full w-full animate-ping rounded-full opacity-75","group-[.online]:bg-emerald-500","group-[.offline]:bg-red-500","group-[.maintenance]:bg-blue-500","group-[.degraded]:bg-amber-500")}),(0,iN.jsx)("span",{className:(0,nQ.cn)("relative inline-flex h-2 w-2 rounded-full","group-[.online]:bg-emerald-500","group-[.offline]:bg-red-500","group-[.maintenance]:bg-blue-500","group-[.degraded]:bg-amber-500")})]}),A5=({className:e,children:i,...n})=>(0,iN.jsx)("span",{className:(0,nQ.cn)("text-muted-foreground",e),...n,children:i??(0,iN.jsxs)(iN.Fragment,{children:[(0,iN.jsx)("span",{className:"hidden group-[.online]:block",children:"Online"}),(0,iN.jsx)("span",{className:"hidden group-[.offline]:block",children:"Offline"}),(0,iN.jsx)("span",{className:"hidden group-[.maintenance]:block",children:"Maintenance"}),(0,iN.jsx)("span",{className:"hidden group-[.degraded]:block",children:"Degraded"})]})});var A3=e.i(767467);let A4=(0,nL.default)("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);var A6=e.i(14452),A8=e.i(191118);e.s([],236634),e.i(236634);let A9=iM.createContext(void 0);function A7(){let e=iM.useContext(A9);if(void 0===e)throw Error((0,gl.default)(64));return e}let Re=((Df={}).activationDirection="data-activation-direction",Df.orientation="data-orientation",Df),Rt={tabActivationDirection:e=>({[Re.activationDirection]:e})},Ri=iM.forwardRef(function(e,i){let{className:n,defaultValue:r=0,onValueChange:s,orientation:o="horizontal",render:a,value:l,style:c,...h}=e,d=Object.hasOwn(e,"defaultValue"),u=iM.useRef([]),[p,f]=iM.useState(()=>new Map),[m,g]=(0,gr.useControlled)({controlled:l,default:r,name:"Tabs",state:"value"}),v=void 0!==l,[y,_]=iM.useState(()=>new Map),b=iM.useCallback(e=>{if(void 0===e)return null;for(let[i,n]of y.entries())if(null!=n&&e===(n.value??n.index))return i;return null},[y]),[w,S]=iM.useState(()=>({previousValue:m,tabActivationDirection:"none"})),{previousValue:k,tabActivationDirection:C}=w,T=C,E=!1;k!==m&&(T=Rn(k,m,o,y),E=null!=k&&null!=m&&null==b(m));let N=E?k:m,M=k!==N||C!==T;(0,gE.useIsoLayoutEffect)(()=>{M&&S({previousValue:N,tabActivationDirection:T})},[N,M,T]);let O=(0,gs.useStableCallback)((e,i)=>{i.activationDirection=Rn(m,e,o,y),s?.(e,i),i.isCanceled||g(e)}),A=(0,gs.useStableCallback)((e,i)=>{f(n=>{if(n.get(e)===i)return n;let r=new Map(n);return r.set(e,i),r})}),R=(0,gs.useStableCallback)((e,i)=>{f(n=>{if(!n.has(e)||n.get(e)!==i)return n;let r=new Map(n);return r.delete(e),r})}),D=iM.useCallback(e=>p.get(e),[p]),L=iM.useCallback(e=>{for(let i of y.values())if(e===i?.value)return i?.id},[y]),j=iM.useMemo(()=>({getTabElementBySelectedValue:b,getTabIdByPanelValue:L,getTabPanelIdByValue:D,onValueChange:O,orientation:o,registerMountedTabPanel:A,setTabMap:_,unregisterMountedTabPanel:R,tabActivationDirection:T,value:m}),[b,L,D,O,o,A,_,R,T,m]),I=iM.useMemo(()=>{for(let e of y.values())if(null!=e&&e.value===m)return e},[y,m]),P=iM.useMemo(()=>{for(let e of y.values())if(null!=e&&!e.disabled)return e.value},[y]);(0,gE.useIsoLayoutEffect)(()=>{if(v||0===y.size)return;let e=I?.disabled,i=null==I&&null!==m;if(d&&e&&m===r||!e&&!i)return;let n=P??null;m!==n&&(g(n),S(e=>"none"===e.tabActivationDirection?e:{...e,tabActivationDirection:"none"}))},[r,P,d,v,I,g,y,m]);let B={orientation:o,tabActivationDirection:T},z=(0,h1.useRenderElement)("div",e,{state:B,ref:i,props:h,stateAttributesMapping:Rt});return(0,iN.jsx)(A9.Provider,{value:j,children:(0,iN.jsx)(go.CompositeList,{elementsRef:u,children:z})})});function Rn(e,i,n,r){if(null==e||null==i)return"none";let s=null,o=null;for(let[n,a]of r.entries()){if(null==a)continue;let r=a.value??a.index;if(e===r&&(s=n),i===r&&(o=n),null!=s&&null!=o)break}if(null==s||null==o)return s!==o&&("number"==typeof e||"string"==typeof e)&&typeof e==typeof i?"horizontal"===n?i>e?"right":"left":i>e?"down":"up":"none";let a=s.getBoundingClientRect(),l=o.getBoundingClientRect();if("horizontal"===n){if(l.left<a.left)return"left";if(l.left>a.left)return"right"}else{if(l.top<a.top)return"up";if(l.top>a.top)return"down"}return"none"}let Rr="data-composite-item-active";var Rs=e.i(530909);let Ro=iM.createContext(void 0);function Ra(){let e=iM.useContext(Ro);if(void 0===e)throw Error((0,gl.default)(65));return e}let Rl=iM.forwardRef(function(e,i){let{className:n,disabled:r=!1,render:s,value:o,id:a,nativeButton:l=!0,style:c,...h}=e,{value:d,getTabPanelIdByValue:u,orientation:p}=A7(),{activateOnFocus:f,highlightedTabIndex:m,onTabActivation:g,registerTabResizeObserverElement:v,setHighlightedTabIndex:y,tabsListElement:_}=Ra(),b=(0,gf.useBaseUiId)(a),w=iM.useMemo(()=>({disabled:r,id:b,value:o}),[r,b,o]),{compositeProps:S,compositeRef:k,index:C}=(0,Rs.useCompositeItem)({metadata:w}),T=o===d,E=iM.useRef(!1),N=iM.useRef(null);iM.useEffect(()=>{let e=N.current;if(e)return v(e)},[v]),(0,gE.useIsoLayoutEffect)(()=>{if(E.current){E.current=!1;return}if(T&&C>-1&&m!==C){if(null!=_){let e=(0,hQ.activeElement)((0,hG.ownerDocument)(_));if(e&&(0,hQ.contains)(_,e))return}r||y(C)}},[T,C,m,y,r,_]);let{getButtonProps:M,buttonRef:O}=(0,gN.useButton)({disabled:r,native:l,focusableWhenDisabled:!0}),A=u(o),R=iM.useRef(!1),D=iM.useRef(!1);return(0,h1.useRenderElement)("button",e,{state:{disabled:r,active:T,orientation:p},ref:[i,O,k,N],props:[S,{role:"tab","aria-controls":A,"aria-selected":T,id:b,onClick:function(e){T||r||g(o,(0,h2.createChangeEventDetails)(h3.REASONS.none,e.nativeEvent,void 0,{activationDirection:"none"}))},onFocus:function(e){T||(C>-1&&!r&&y(C),!r&&f&&(!R.current||R.current&&D.current)&&g(o,(0,h2.createChangeEventDetails)(h3.REASONS.none,e.nativeEvent,void 0,{activationDirection:"none"})))},onPointerDown:function(e){T||r||(R.current=!0,e.button&&0!==e.button||(D.current=!0,(0,hG.ownerDocument)(e.currentTarget).addEventListener("pointerup",function(){R.current=!1,D.current=!1},{once:!0})))},[Rr]:T?"":void 0,onKeyDownCapture(){E.current=!0}},h,M]})});var Rc=e.i(730774),Rh=e.i(517432);let Rd=((Dm={}).activeTabLeft="--active-tab-left",Dm.activeTabRight="--active-tab-right",Dm.activeTabTop="--active-tab-top",Dm.activeTabBottom="--active-tab-bottom",Dm.activeTabWidth="--active-tab-width",Dm.activeTabHeight="--active-tab-height",Dm);var Ru=e.i(394394);let Rp={...Rt,activeTabPosition:()=>null,activeTabSize:()=>null},Rf=iM.forwardRef(function(e,i){let{className:n,render:r,renderBeforeHydration:s=!1,style:o,...a}=e,{nonce:l}=(0,Ru.useCSPContext)(),{getTabElementBySelectedValue:c,orientation:h,tabActivationDirection:d,value:u}=A7(),{tabsListElement:p,registerIndicatorUpdateListener:f}=Ra(),m=(0,Rh.useIsHydrating)(),g=function(){let[,e]=iM.useState({});return iM.useCallback(()=>{e({})},[])}();iM.useEffect(()=>f(g),[f,g]);let v=0,y=0,_=0,b=0,w=0,S=0,k=!1;if(null!=u&&null!=p){let e=c(u);if(k=!0,null!=e){let{width:i,height:n}=(0,Rc.getCssDimensions)(e),{width:r,height:s}=(0,Rc.getCssDimensions)(p),o=e.getBoundingClientRect(),a=p.getBoundingClientRect(),l=r>0?a.width/r:1,c=s>0?a.height/s:1;if(Math.abs(l)>Number.EPSILON&&Math.abs(c)>Number.EPSILON){let e=o.left-a.left,i=o.top-a.top;v=e/l+p.scrollLeft-p.clientLeft,_=i/c+p.scrollTop-p.clientTop}else v=e.offsetLeft,_=e.offsetTop;w=i,S=n,y=p.scrollWidth-v-w,b=p.scrollHeight-_-S}}let C=iM.useMemo(()=>k?{left:v,right:y,top:_,bottom:b}:null,[v,y,_,b,k]),T=iM.useMemo(()=>k?{width:w,height:S}:null,[w,S,k]),E=iM.useMemo(()=>{if(k)return{[Rd.activeTabLeft]:`${v}px`,[Rd.activeTabRight]:`${y}px`,[Rd.activeTabTop]:`${_}px`,[Rd.activeTabBottom]:`${b}px`,[Rd.activeTabWidth]:`${w}px`,[Rd.activeTabHeight]:`${S}px`}},[v,y,_,b,w,S,k]),N=k&&w>0&&S>0,M=(0,h1.useRenderElement)("span",e,{state:{orientation:h,activeTabPosition:C,activeTabSize:T,tabActivationDirection:d},ref:i,props:[{role:"presentation",style:E,hidden:!N},a,{suppressHydrationWarning:!0}],stateAttributesMapping:Rp});return null==u?null:(0,iN.jsxs)(iM.Fragment,{children:[M,m&&s&&(0,iN.jsx)("script",{nonce:l,dangerouslySetInnerHTML:{__html:'!function(){const t=document.currentScript.previousElementSibling;if(!t)return;const e=t.closest(\'[role="tablist"]\');if(!e)return;const i=e.querySelector("[data-active]");if(!i)return;if(0===i.offsetWidth||0===e.offsetWidth)return;let o=0,n=0,h=0,l=0,r=0,f=0;function s(t){const e=getComputedStyle(t);let i=parseFloat(e.width)||0,o=parseFloat(e.height)||0;return(Math.round(i)!==t.offsetWidth||Math.round(o)!==t.offsetHeight)&&(i=t.offsetWidth,o=t.offsetHeight),{width:i,height:o}}if(null!=i&&null!=e){const{width:t,height:c}=s(i),{width:u,height:d}=s(e),a=i.getBoundingClientRect(),g=e.getBoundingClientRect(),p=u>0?g.width/u:1,b=d>0?g.height/d:1;if(Math.abs(p)>Number.EPSILON&&Math.abs(b)>Number.EPSILON){const t=a.left-g.left,i=a.top-g.top;o=t/p+e.scrollLeft-e.clientLeft,h=i/b+e.scrollTop-e.clientTop}else o=i.offsetLeft,h=i.offsetTop;r=t,f=c,n=e.scrollWidth-o-r,l=e.scrollHeight-h-f}function c(e,i){t.style.setProperty(`--active-tab-${e}`,`${i}px`)}c("left",o),c("right",n),c("top",h),c("bottom",l),c("width",r),c("height",f),r>0&&f>0&&t.removeAttribute("hidden")}();'},suppressHydrationWarning:!0})]})});var Rm=e.i(677822),Rg=e.i(254891);let Rv=((Dg={}).index="data-index",Dg.activationDirection="data-activation-direction",Dg.orientation="data-orientation",Dg.hidden="data-hidden",Dg[Dg.startingStyle=gx.TransitionStatusDataAttributes.startingStyle]="startingStyle",Dg[Dg.endingStyle=gx.TransitionStatusDataAttributes.endingStyle]="endingStyle",Dg),Ry={...Rt,...gx.transitionStatusMapping},R_=iM.forwardRef(function(e,i){let{className:n,value:r,render:s,keepMounted:o=!1,style:a,...l}=e,{value:c,getTabIdByPanelValue:h,orientation:d,tabActivationDirection:u,registerMountedTabPanel:p,unregisterMountedTabPanel:f}=A7(),m=(0,gf.useBaseUiId)(),g=iM.useMemo(()=>({id:m,value:r}),[m,r]),{ref:v,index:y}=(0,gv.useCompositeListItem)({metadata:g}),_=r===c,{mounted:b,transitionStatus:w,setMounted:S}=(0,Rg.useTransitionStatus)(_),k=!b,C=h(r),T=iM.useRef(null),E=(0,h1.useRenderElement)("div",e,{state:{hidden:k,orientation:d,tabActivationDirection:u,transitionStatus:w},ref:[i,v,T],props:[{"aria-labelledby":C,hidden:k,id:m,role:"tabpanel",tabIndex:_?0:-1,inert:(0,Rm.inertValue)(!_),[Rv.index]:y},l],stateAttributesMapping:Ry});return((0,gL.useOpenChangeComplete)({open:_,ref:T,onComplete(){_||S(!1)}}),(0,gE.useIsoLayoutEffect)(()=>{if((!k||o)&&null!=m)return p(r,m),()=>{f(r,m)}},[k,o,r,m,p,f]),o||b)?E:null});var Rb=e.i(863728),Rx=e.i(877580);let Rw=[];var RS=e.i(352360);function Rk(e){let{render:i,className:n,style:r,refs:s=Rb.EMPTY_ARRAY,props:o=Rb.EMPTY_ARRAY,state:a=Rb.EMPTY_OBJECT,stateAttributesMapping:l,highlightedIndex:c,onHighlightedIndexChange:h,orientation:d,dense:u,itemSizes:p,loopFocus:f,onLoop:m,cols:g,enableHomeAndEndKeys:v,onMapChange:y,stopEventPropagation:_=!0,rootRef:b,disabledIndices:w,modifierKeys:S,highlightItemOnHover:k=!1,tag:C="div",...T}=e,{props:E,highlightedIndex:N,onHighlightedIndexChange:M,elementsRef:O,onMapChange:A,relayKeyboardEvent:R}=function(e){let{itemSizes:i,cols:n=1,loopFocus:r=!0,onLoop:s,dense:o=!1,orientation:a="both",direction:l,highlightedIndex:c,onHighlightedIndexChange:h,rootRef:d,enableHomeAndEndKeys:u=!1,stopEventPropagation:p=!1,disabledIndices:f,modifierKeys:m=Rw}=e,[g,v]=iM.useState(0),y=n>1,_=iM.useRef(null),b=(0,gp.useMergedRefs)(_,d),w=iM.useRef([]),S=iM.useRef(!1),k=c??g,C=(0,gs.useStableCallback)((e,i=!1)=>{if((h??v)(e),i){let i=w.current[e];(0,gM.scrollIntoViewIfNeeded)(_.current,i,l,a)}}),T=(0,gs.useStableCallback)(e=>{if(0===e.size||S.current)return;S.current=!0;let i=Array.from(e.keys()),n=i.find(e=>e?.hasAttribute(Rr))??null,r=n?i.indexOf(n):-1;-1!==r&&C(r),(0,gM.scrollIntoViewIfNeeded)(_.current,n,l,a)}),E=(0,gs.useStableCallback)((e,i,n)=>s?s?.(e,i,n,w):n),N=iM.useMemo(()=>({"aria-orientation":"both"===a?void 0:a,ref:b,onFocus(e){let i=_.current,n=(0,hQ.getTarget)(e.nativeEvent);i&&null!=n&&(0,gM.isNativeInput)(n)&&n.setSelectionRange(0,n.value.length??0)},onKeyDown(e){let c=u?gM.ALL_KEYS:gM.ARROW_KEYS;if(!c.has(e.key)||function(e,i){for(let n of gM.MODIFIER_KEYS.values())if(!i.includes(n)&&e.getModifierState(n))return!0;return!1}(e,m)||!_.current)return;let h="rtl"===l,d=h?gM.ARROW_LEFT:gM.ARROW_RIGHT,g={horizontal:d,vertical:gM.ARROW_DOWN,both:d}[a],v=h?gM.ARROW_RIGHT:gM.ARROW_LEFT,b={horizontal:v,vertical:gM.ARROW_UP,both:v}[a],S=(0,hQ.getTarget)(e.nativeEvent);if(null!=S&&(0,gM.isNativeInput)(S)&&!gT(S)){let i=S.selectionStart,n=S.selectionEnd,r=S.value??"";if(null==i||e.shiftKey||i!==n||e.key!==b&&i<r.length||e.key!==g&&i>0)return}let T=k,N=(0,Rx.getMinListIndex)(w,f),M=(0,Rx.getMaxListIndex)(w,f);if(y){let s=i||Array.from({length:w.current.length},()=>({width:1,height:1})),l=(0,Rx.createGridCellMap)(s,n,o),c=l.findIndex(e=>null!=e&&!(0,Rx.isListIndexDisabled)(w.current,e,f)),d=l.reduce((e,i,n)=>null==i||(0,Rx.isListIndexDisabled)(w.current,i,f)?e:n,-1);T=l[(0,Rx.getGridNavigatedIndex)(l.map(e=>null!=e?w.current[e]:null),{event:e,orientation:a,loopFocus:r,onLoop:E,cols:n,disabledIndices:(0,Rx.getGridCellIndices)([...f||w.current.map((e,i)=>(0,Rx.isListIndexDisabled)(w.current,i)?i:void 0),void 0],l),minIndex:c,maxIndex:d,prevIndex:(0,Rx.getGridCellIndexOfCorner)(k>M?N:k,s,l,n,e.key===gM.ARROW_DOWN?"bl":e.key===gM.ARROW_RIGHT?"tr":"tl"),rtl:h})]}let O={horizontal:[d],vertical:[gM.ARROW_DOWN],both:[d,gM.ARROW_DOWN]}[a],A={horizontal:[v],vertical:[gM.ARROW_UP],both:[v,gM.ARROW_UP]}[a],R=y?c:({horizontal:u?gM.HORIZONTAL_KEYS_WITH_EXTRA_KEYS:gM.HORIZONTAL_KEYS,vertical:u?gM.VERTICAL_KEYS_WITH_EXTRA_KEYS:gM.VERTICAL_KEYS,both:c})[a];u&&(e.key===gM.HOME?T=N:e.key===gM.END&&(T=M)),T===k&&(O.includes(e.key)||A.includes(e.key))&&(r&&T===M&&O.includes(e.key)?(T=N,s&&(T=s(e,k,T,w))):r&&T===N&&A.includes(e.key)?(T=M,s&&(T=s(e,k,T,w))):T=(0,Rx.findNonDisabledListIndex)(w.current,{startingIndex:T,decrement:A.includes(e.key),disabledIndices:f})),T===k||(0,Rx.isIndexOutOfListBounds)(w.current,T)||(p&&e.stopPropagation(),R.has(e.key)&&e.preventDefault(),C(T,!0),queueMicrotask(()=>{w.current[T]?.focus()}))}}),[n,o,l,f,w,u,k,y,i,r,s,E,b,m,C,a,p]);return iM.useMemo(()=>({props:N,highlightedIndex:k,onHighlightedIndexChange:C,elementsRef:w,disabledIndices:f,onMapChange:T,relayKeyboardEvent:N.onKeyDown}),[N,k,C,w,f,T])}({itemSizes:p,cols:g,loopFocus:f,onLoop:m,dense:u,orientation:d,highlightedIndex:c,onHighlightedIndexChange:h,rootRef:b,stopEventPropagation:_,enableHomeAndEndKeys:v,direction:(0,ga.useDirection)(),disabledIndices:w,modifierKeys:S}),D=(0,h1.useRenderElement)(C,e,{state:a,ref:s,props:[E,...o,T],stateAttributesMapping:l}),L=iM.useMemo(()=>({highlightedIndex:N,onHighlightedIndexChange:M,highlightItemOnHover:k,relayKeyboardEvent:R}),[N,M,k,R]);return(0,iN.jsx)(RS.CompositeRootContext.Provider,{value:L,children:(0,iN.jsx)(go.CompositeList,{elementsRef:O,onMapChange:e=>{y?.(e),A(e)},children:D})})}let RC=iM.forwardRef(function(e,i){let{activateOnFocus:n=!1,className:r,loopFocus:s=!0,render:o,style:a,...l}=e,{onValueChange:c,orientation:h,value:d,setTabMap:u,tabActivationDirection:p}=A7(),[f,m]=iM.useState(0),[g,v]=iM.useState(null),y=iM.useRef(new Set),_=iM.useRef(new Set),b=iM.useRef(null),w=(0,gs.useStableCallback)(()=>{y.current.forEach(e=>{e()})});iM.useEffect(()=>{if("u"<typeof ResizeObserver)return;let e=new ResizeObserver(()=>{y.current.size&&w()});return b.current=e,g&&e.observe(g),_.current.forEach(i=>{e.observe(i)}),()=>{e.disconnect(),b.current=null}},[g,w]);let S=(0,gs.useStableCallback)(e=>(y.current.add(e),()=>{y.current.delete(e)})),k=(0,gs.useStableCallback)(e=>(_.current.add(e),b.current?.observe(e),()=>{_.current.delete(e),b.current?.unobserve(e)})),C=(0,gs.useStableCallback)((e,i)=>{e!==d&&c(e,i)}),T=iM.useMemo(()=>({activateOnFocus:n,highlightedTabIndex:f,registerIndicatorUpdateListener:S,registerTabResizeObserverElement:k,onTabActivation:C,setHighlightedTabIndex:m,tabsListElement:g}),[n,f,S,k,C,m,g]);return(0,iN.jsx)(Ro.Provider,{value:T,children:(0,iN.jsx)(Rk,{render:o,className:r,style:a,state:{orientation:h,tabActivationDirection:p},refs:[i,v],props:[{"aria-orientation":"vertical"===h?"vertical":void 0,role:"tablist"},l],stateAttributesMapping:Rt,highlightedIndex:f,enableHomeAndEndKeys:!0,loopFocus:s,orientation:h,onHighlightedIndexChange:m,onMapChange:u,disabledIndices:Rb.EMPTY_ARRAY})})});e.s(["Indicator",0,Rf,"List",0,RC,"Panel",0,R_,"Root",0,Ri,"Tab",0,Rl],227146);var RT=e.i(227146),RT=RT;function RE({className:e,orientation:i="horizontal",...n}){return(0,iN.jsx)(RT.Root,{"data-slot":"tabs","data-orientation":i,className:(0,nQ.cn)("group/tabs flex gap-2 data-horizontal:flex-col",e),...n})}let RN=(0,e.i(294237).cva)("group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none",{variants:{variant:{default:"bg-muted",line:"gap-1 bg-transparent"}},defaultVariants:{variant:"default"}});function RM({className:e,variant:i="default",...n}){return(0,iN.jsx)(RT.List,{"data-slot":"tabs-list","data-variant":i,className:(0,nQ.cn)(RN({variant:i}),e),...n})}function RO({className:e,...i}){return(0,iN.jsx)(RT.Tab,{"data-slot":"tabs-trigger",className:(0,nQ.cn)("relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent","data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground","after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100",e),...i})}function RA({className:e,...i}){return(0,iN.jsx)(RT.Panel,{"data-slot":"tabs-content",className:(0,nQ.cn)("flex-1 text-sm outline-none",e),...i})}let RR=(0,nL.default)("users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]]),RD=(0,nL.default)("user-plus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);function RL({name:e,agentId:i,description:n,onClick:r}){return(0,iN.jsxs)("button",{type:"button",onClick:r,className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md hover:bg-muted text-left transition-colors",children:[(0,iN.jsx)(hz.AgentIcon,{agentId:i,name:e,className:"size-7 rounded-full"}),(0,iN.jsxs)("span",{className:"min-w-0",children:[(0,iN.jsx)("span",{className:"block text-sm truncate",children:e}),n&&(0,iN.jsx)("span",{className:"block text-xs text-muted-foreground truncate",children:n})]})]})}function Rj({open:e,onOpenChange:i,candidates:n,onAdd:r}){let[s,o]=(0,iM.useState)([]),[a,l]=(0,iM.useState)(0),c=e=>{e||(o([]),l(e=>e+1)),i(e)};return(0,iN.jsx)(rE.Dialog,{open:e,onOpenChange:c,children:(0,iN.jsxs)(rE.DialogContent,{className:"sm:max-w-sm",children:[(0,iN.jsxs)(rE.DialogHeader,{children:[(0,iN.jsx)(rE.DialogTitle,{children:"添加成员"}),(0,iN.jsx)(rE.DialogDescription,{children:"选择要添加到频道的成员"})]}),(0,iN.jsxs)("div",{className:"space-y-3 pt-2",children:[(0,iN.jsx)(hF,{candidates:n,selected:s,onToggle:e=>{o(i=>i.includes(e)?i.filter(i=>i!==e):[...i,e])},searchPlaceholder:"搜索成员...",emptyText:"无可用成员"},a),(0,iN.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[(0,iN.jsx)(hv.Button,{variant:"outline",onClick:()=>c(!1),children:"取消"}),(0,iN.jsxs)(hv.Button,{onClick:()=>{0!==s.length&&(r(s),c(!1))},disabled:0===s.length,children:[(0,iN.jsx)(RD,{className:"size-3.5 mr-1"}),"添加 (",s.length,")"]})]})]})]})})}let RI={general:{status:"online"},issue:{status:"degraded"},agent:{status:"maintenance"}};function RP({workspaceId:e,channel:i,agents:n,allChannels:r}){let s=(0,n0.useTranslations)("chat"),o=(0,n0.useTranslations)("common"),{updateChannel:a,deleteChannel:l}=hR(),[c,h]=(0,iM.useState)(!1),[d,u]=(0,iM.useState)(!1),[p,f]=(0,iM.useState)(""),[m,g]=(0,iM.useState)(!1),[v,y]=(0,iM.useState)(!1);RI[i.type];let _=n.filter(e=>!1!==e.enabled),b=new Set(i.members),w=_.filter(e=>!b.has(e.id)).map(e=>({id:e.id,label:hW(e),description:e.role})),S=async()=>{await l(e,i.id),y(!1)};return(0,iN.jsxs)("div",{className:"flex flex-col h-full",children:[(0,iN.jsx)("div",{className:"flex items-center justify-between px-4 h-12 border-b shrink-0",children:(0,iN.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:["agent"===i.type?(0,iN.jsx)(hL.Bot,{className:"size-4 text-muted-foreground shrink-0"}):"issue"===i.type?(0,iN.jsx)(hI.AlertCircle,{className:"size-4 text-muted-foreground shrink-0"}):(0,iN.jsx)(nj,{className:"size-4 text-muted-foreground shrink-0"}),(0,iN.jsxs)("span",{className:"text-sm font-medium truncate",children:["#",i.name]})]})}),(0,iN.jsxs)(RE,{defaultValue:"info",className:"flex flex-col flex-1 min-h-0",children:[(0,iN.jsxs)(RM,{className:"w-full rounded-none border-b bg-transparent h-9 p-0 shrink-0",children:[(0,iN.jsxs)(RO,{value:"info",className:"flex-1 gap-1.5 data-[state=active]:shadow-none data-[state=active]:border-b-2 data-[state=active]:border-primary rounded-none",children:[(0,iN.jsx)(A4,{className:"size-3.5"}),s("channel.info")]}),(0,iN.jsxs)(RO,{value:"members",className:"flex-1 gap-1.5 data-[state=active]:shadow-none data-[state=active]:border-b-2 data-[state=active]:border-primary rounded-none",children:[(0,iN.jsx)(RR,{className:"size-3.5"}),s("channel.members")]})]}),(0,iN.jsxs)(A8.ScrollArea,{className:"flex-1 min-h-0",children:[(0,iN.jsxs)(RA,{value:"info",className:"p-4 mt-0 space-y-4",children:[(0,iN.jsxs)("div",{className:"flex items-center gap-3",children:[(0,iN.jsx)("div",{className:"flex items-center justify-center size-10 rounded-lg bg-muted",children:"agent"===i.type?(0,iN.jsx)(hL.Bot,{className:"size-5 text-muted-foreground"}):"issue"===i.type?(0,iN.jsx)(hI.AlertCircle,{className:"size-5 text-muted-foreground"}):(0,iN.jsx)(nj,{className:"size-5 text-muted-foreground"})}),(0,iN.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,iN.jsxs)("p",{className:"text-sm font-medium",children:["#",i.name]}),(0,iN.jsxs)("p",{className:"text-xs text-muted-foreground",children:[s("channel.type")," ",s(`channel.${i.type}`)]})]}),(0,iN.jsx)(hv.Button,{variant:"ghost",size:"icon-sm",onClick:()=>h(!0),children:(0,iN.jsx)(rw.Pencil,{className:"size-3.5"})})]}),(0,iN.jsxs)("div",{className:"space-y-2 text-sm",children:[(0,iN.jsxs)("div",{className:"flex justify-between py-1 border-b",children:[(0,iN.jsx)("span",{className:"text-muted-foreground",children:s("channel.channelId")}),(0,iN.jsxs)("span",{className:"font-mono text-xs",children:[i.id.slice(0,8),"..."]})]}),(0,iN.jsxs)("div",{className:"flex justify-between py-1 border-b",children:[(0,iN.jsx)("span",{className:"text-muted-foreground",children:s("channel.memberCount")}),(0,iN.jsx)("span",{children:i.members.length})]}),(0,iN.jsxs)("div",{className:"flex justify-between py-1 border-b",children:[(0,iN.jsx)("span",{className:"text-muted-foreground",children:s("channel.createdAt")}),(0,iN.jsx)("span",{children:new Date(i.createdAt).toLocaleDateString()})]})]})]}),(0,iN.jsxs)(RA,{value:"members",className:"p-4 mt-0 space-y-1",children:[0===i.members.length&&(0,iN.jsx)("p",{className:"text-sm text-muted-foreground py-4 text-center",children:s("channel.noMembers")}),i.members.map(e=>(0,iN.jsx)(RL,{name:h$(_,e),agentId:"user"!==e?e:void 0,description:"user"!==e?e:void 0,onClick:()=>{f(e),u(!0)}},e)),(0,iN.jsxs)(hv.Button,{variant:"ghost",size:"sm",className:"w-full mt-2 text-xs text-muted-foreground",onClick:()=>g(!0),children:[(0,iN.jsx)(RD,{className:"size-3.5 mr-1"}),s("channel.addMember")]})]})]})]}),(0,iN.jsx)("div",{className:"shrink-0 p-3 border-t",children:(0,iN.jsxs)(hv.Button,{variant:"ghost",size:"sm",className:"w-full text-xs text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>y(!0),children:[(0,iN.jsx)(nJ.Trash2,{className:"size-3.5 mr-1"}),s("channel.delete")]})}),(0,iN.jsx)(hV,{open:c,onOpenChange:h,workspaceId:e,channel:i,agents:n,onSubmit:n=>a(e,i.id,{...n,members:hU(_,n.members)})}),(0,iN.jsx)(dE,{open:d,onOpenChange:u,memberName:p,displayName:h$(_,p),channelId:i.id,workspaceId:e,channels:r.filter(e=>e.members.includes(p)).map(e=>e.name)}),(0,iN.jsx)(Rj,{open:m,onOpenChange:g,candidates:w,onAdd:n=>{a(e,i.id,{members:hU(_,[...i.members,...n])})}}),(0,iN.jsx)(rE.Dialog,{open:v,onOpenChange:y,children:(0,iN.jsxs)(rE.DialogContent,{children:[(0,iN.jsxs)(rE.DialogHeader,{children:[(0,iN.jsx)(rE.DialogTitle,{children:s("channel.delete")}),(0,iN.jsx)(rE.DialogDescription,{children:s("channel.deleteConfirm")})]}),(0,iN.jsxs)(rE.DialogFooter,{children:[(0,iN.jsx)(rE.DialogClose,{render:(0,iN.jsx)(hv.Button,{variant:"outline"}),children:o("cancel")}),(0,iN.jsxs)(hv.Button,{variant:"destructive",onClick:S,children:[(0,iN.jsx)(nJ.Trash2,{className:"size-3.5"}),o("delete")]})]})]})})]})}var RB=e.i(249673);function Rz({messages:e}){var i;let n,[r,s]=(0,iM.useState)(null),[o,a]=(0,iM.useState)(!1),[l,c]=(0,iM.useState)(0),h=(0,iM.useRef)(null),d=(0,iM.useCallback)(i=>{s(i);let n=document.getElementById(`msg-${e[i].id}`);n?.scrollIntoView({behavior:"smooth",block:"center"})},[e]),u=(0,iM.useCallback)((e,i)=>{if(!i||!h.current)return;s(e);let n=h.current.getBoundingClientRect(),r=i.getBoundingClientRect();c(r.top-n.top+r.height/2)},[]);return 0===e.length?null:(0,iN.jsxs)("div",{ref:h,className:"absolute right-2 top-1/2 -translate-y-1/2 z-10 flex flex-col items-center",onMouseEnter:()=>a(!0),onMouseLeave:()=>{a(!1),s(null)},children:[(0,iN.jsx)("button",{className:`flex-shrink-0 mb-0.5 flex items-center justify-center size-5 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/80 transition-all ${o?"opacity-100":"opacity-0 pointer-events-none"} ${null===r||r<=0?"invisible":""}`,onClick:()=>{null!==r&&r>0&&d(r-1)},children:(0,iN.jsx)(RB.ChevronUp,{className:"size-3.5"})}),(0,iN.jsx)("div",{className:"flex-1 w-full max-h-[70vh] overflow-y-auto scrollbar-none",children:(0,iN.jsx)("div",{className:"flex flex-col gap-[3px] px-1 py-0.5",children:e.map((e,i)=>(0,iN.jsx)("div",{className:"flex justify-center",children:(0,iN.jsx)("button",{className:`h-[4px] rounded-full transition-all duration-150 ${r===i?"bg-primary w-6":"user"===e.senderId?"bg-primary/30 hover:bg-primary/50 w-5":"bg-muted-foreground/25 hover:bg-muted-foreground/40 w-5"}`,onClick:()=>d(i),onMouseEnter:e=>u(i,e.currentTarget)})},e.id))})}),(0,iN.jsx)("button",{className:`flex-shrink-0 mt-0.5 flex items-center justify-center size-5 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/80 transition-all ${o?"opacity-100":"opacity-0 pointer-events-none"} ${null===r||r>=e.length-1?"invisible":""}`,onClick:()=>{null!==r&&r<e.length-1&&d(r+1)},children:(0,iN.jsx)(r_.ChevronDown,{className:"size-3.5"})}),o&&null!==r&&(0,iN.jsxs)("div",{className:"absolute right-full mr-3 w-56 rounded-lg border bg-popover p-2.5 shadow-lg z-50 animate-in fade-in-0 zoom-in-95 duration-75",style:{top:l,transform:"translateY(-50%)"},children:[(0,iN.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,iN.jsx)("span",{className:"font-medium text-xs",children:"user"===e[r].senderId?"You":(0,hD.findAgentById)(e[r].senderId)?.name??e[r].senderId}),(0,iN.jsx)("span",{className:"text-[10px] text-muted-foreground",children:new Date(e[r].createdAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),(0,iN.jsx)("p",{className:"text-xs text-muted-foreground line-clamp-3 leading-relaxed",children:(i=e[r].content,(n=/<[a-z][\s\S]*>/i.test(i)?i.replace(/<[^>]*>/g,""):i).length>150?n.slice(0,150)+"...":n)})]})]})}var RF=e.i(636288);let RW=(0,re.create)((e,i)=>({tasks:[],loading:!1,loadTasks:async(i,n)=>{e({loading:!0});try{let r=n?`?issueId=${n}`:"",s=await fetch(`/api/workspaces/${i}/tasks${r}`),o=await s.json();e({tasks:o,loading:!1})}catch{e({loading:!1})}},createTask:async(e,n,r,s,o)=>{let a=await fetch(`/api/workspaces/${e}/tasks`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({issueId:n,title:r,description:s,agentConfigId:o})}),l=await a.json();return i().upsertTask(l),l},updateTask:async(e,n,r)=>{let s=await fetch(`/api/workspaces/${e}/tasks/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}),o=await s.json();i().upsertTask(o)},deleteTask:async(i,n)=>{await fetch(`/api/workspaces/${i}/tasks/${n}`,{method:"DELETE"}),e(e=>({tasks:e.tasks.filter(e=>e.id!==n)}))},retryTask:async(e,n)=>{let r=await fetch(`/api/workspaces/${e}/tasks/${n}/retry`,{method:"POST"}),s=await r.json();i().upsertTask(s)},cancelTask:async(e,n)=>{let r=await fetch(`/api/workspaces/${e}/tasks/${n}/cancel`,{method:"POST"}),s=await r.json();i().upsertTask(s)},reorderTasks:async(e,i,n)=>{await fetch(`/api/workspaces/${e}/tasks/reorder`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({issueId:i,taskIds:n})})},upsertTask:i=>{e(e=>{let n=e.tasks.findIndex(e=>e.id===i.id);if(n>=0){let r=[...e.tasks];return r[n]=i,{tasks:r}}return{tasks:[...e.tasks,i]}})}})),RH="agent-spaces:issue:",R$=(0,re.create)((e,i)=>({workspaceId:null,issues:[],activeIssueId:null,issueSelectSeq:0,loading:!1,loadIssues:async i=>{e({loading:!0});try{let n=await fetch(`/api/workspaces/${i}/issues`),r=await n.json(),s=function(e,i){try{let n=localStorage.getItem(RH+e);if(n&&i.some(e=>e.id===n))return n}catch{}return null}(i,r);e({workspaceId:i,issues:r,activeIssueId:s,loading:!1})}catch{e({loading:!1})}},createIssue:async(e,n,r,s,o)=>{let a=await fetch(`/api/workspaces/${e}/issues`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:n,description:r,members:s,workflowId:o})}),l=await a.json();i().upsertIssue(l),i().setActiveIssue(l.id)},setActiveIssue:i=>{let{workspaceId:n}=R$.getState();if(n&&i)try{localStorage.setItem(RH+n,i)}catch{}e(e=>({activeIssueId:i,issueSelectSeq:e.issueSelectSeq+1}))},updateIssue:async(e,n,r)=>{let s=await fetch(`/api/workspaces/${e}/issues/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}),o=await s.json();i().upsertIssue(o)},updateIssueStatus:async(e,i,n)=>{await fetch(`/api/workspaces/${e}/issues/${i}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:n})})},startIssue:async(e,n)=>{let r=await fetch(`/api/workspaces/${e}/issues/${n}/start`,{method:"POST"}),s=await r.json();i().upsertIssue(s)},resumeIssue:async(e,n)=>{let r=await fetch(`/api/workspaces/${e}/issues/${n}/resume`,{method:"POST"}),s=await r.json();i().upsertIssue(s)},deleteIssue:async(e,n)=>{let r=i().issues.find(e=>e.id===n);if(await fetch(`/api/workspaces/${e}/issues/${n}`,{method:"DELETE"}),i().removeIssue(n),r?.channelId){let{removeChannelLocal:e}=hR.getState();e(r.channelId)}let{tasks:s}=RW.getState(),o=s.filter(e=>e.issueId===n);if(o.length>0){let e=new Set(o.map(e=>e.id));RW.setState(i=>({tasks:i.tasks.filter(i=>!e.has(i.id))}))}},upsertIssue:i=>{e(e=>{let n=e.issues.findIndex(e=>e.id===i.id);if(n>=0){let r=[...e.issues];return r[n]=i,{issues:r}}return{issues:[...e.issues,i]}})},removeIssue:i=>{e(e=>({issues:e.issues.filter(e=>e.id!==i),activeIssueId:e.activeIssueId===i?null:e.activeIssueId}))}})),RU=(0,re.create)(e=>({activePanel:"channel-list",setActivePanel:i=>e({activePanel:i})})),RV={general:{status:"online"},issue:{status:"degraded"},agent:{status:"maintenance"}};function Rq({members:e}){let i=e.filter(e=>"user"!==e).slice(0,4),n=e.length-i.length-!!e.includes("user");return(0,iN.jsxs)(RF.AvatarGroup,{className:"ml-1 [&>[data-slot=avatar]]:size-5",children:[i.map(e=>(0,iN.jsx)(hz.AgentIcon,{agentId:e,className:"size-5 rounded-full"},e)),n>0&&(0,iN.jsxs)(RF.AvatarGroupCount,{className:"!size-5 text-[10px]",children:["+",n]})]})}function RY({workspaceId:e}){let i=(0,n0.useTranslations)("chat"),n=(0,n0.useTranslations)("common"),{activeChannelId:r,channels:s,messages:o,loadMessages:a,sendMessage:l,addMessage:c,updateMessage:h,stopProcessingMessages:d,deleteMessage:u,clearMessages:p}=hR(),f=(0,iM.useRef)(null),[m,g]=(0,iM.useState)(!1),[v,y]=(0,iM.useState)(null),[_,b]=(0,iM.useState)(!1),w=(0,iM.useRef)(null),S=(0,hD.useAgentStore)(e=>e.agents),k=(0,hD.useAgentStore)(e=>e.ensure),C=s.find(e=>e.id===r),T=(0,iM.useMemo)(()=>r&&o[r]||[],[r,o]),E=(0,iM.useMemo)(()=>(function(e){for(let i=e.length-1;i>=0;i-=1){let n=e[i];if("waiting_for_user"!==n.status)continue;let r=n.parts?.find(e=>"ask_user_question"===e.type&&"answered"!==e.status);if(r&&"ask_user_question"===r.type)return{messageId:n.id,questionId:r.id,question:r.question,choices:r.choices??[]}}return null})(T),[T]),N=(0,iM.useMemo)(()=>{let e=S.filter(e=>!1!==e.enabled);if(!C)return[];let i=new Set;return C.members.filter(e=>"user"!==e).map(i=>hH(e,i)).filter(e=>!(!e||i.has(e.id))&&(i.add(e.id),!0))},[C,S]);(0,iM.useEffect)(()=>{r&&a(e,r),k()},[r,e,a,k]),(0,iM.useEffect)(()=>{let i=rL(e),n=i.on("channel.message",e=>{e.channelId===r&&c(e.channelId,e)}),s=i.on("channel.message.updated",e=>{e.channelId===r&&h(e.channelId,e)}),o=i.on("channel.message.deleted",e=>{e.channelId===r&&u(e.channelId,e.messageId)}),a=i.on("channel.messages.cleared",e=>{e.channelId===r&&hR.setState(e=>({messages:{...e.messages,[r]:[]}}))}),l=i.on("channel.updated",e=>{e.id===r&&hR.setState(i=>({channels:i.channels.map(i=>i.id===e.id?e:i)}))});return()=>{n(),s(),o(),a(),l()}},[e,r,c,h,u]),(0,iM.useEffect)(()=>{f.current?.scrollIntoView({behavior:"smooth"})},[T.length]),(0,iM.useEffect)(()=>{if(!r||!e)return;let i=T[T.length-1];if(!i||!["pending","streaming","waiting_for_user"].includes(i.status??""))return;let n=setInterval(()=>{a(e,r)},3e3);return()=>clearInterval(n)},[r,e,T.length,T[T.length-1]?.status,a]);let M=(0,iM.useCallback)((i,n,s)=>{r&&l(e,r,i,n,s)},[e,r,l]),O=T.length>0&&["pending","streaming","waiting_for_user"].includes(T[T.length-1].status??""),A=(0,iM.useCallback)(()=>{r&&(d(r),rL(e).send("channel.stop",{channelId:r}))},[e,r,d]),R=(0,iM.useCallback)(e=>{w.current?.setContent(e.content,N)},[N]),D=(0,iM.useCallback)(e=>{y(e)},[]),L=(0,iM.useCallback)(async()=>{v&&(await fetch(`/api/workspaces/${e}/channels/${v.channelId}/messages/${v.id}`,{method:"DELETE"}),y(null))},[e,v]);if(!C)return(0,iN.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:i("emptyState")});let j=(()=>{let e=RV[C.type];if(0===T.length)return{label:i("status.idle"),status:"degraded"};let n=T[T.length-1].status;if("waiting_for_user"===n)return{label:i("status.waitingForUser"),status:"degraded"};if("streaming"===n||"pending"===n)return{label:i("status.running"),status:"maintenance"};if("completed"===n)return{label:i("status.success"),status:"online"};if("error"===n){let e=T.slice(-3);return e.length>=3&&e.every(e=>"error"===e.status)?{label:i("status.error"),status:"offline"}:{label:i("status.running"),status:"degraded"}}return{label:i(`channelType.${C.type}`),status:e.status}})();return(0,iN.jsxs)("div",{className:"flex h-full",children:[(0,iN.jsxs)("div",{className:"flex flex-col flex-1 min-w-0",children:[(0,iN.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2 border-b",children:[(0,iN.jsx)(hv.Button,{variant:"ghost",size:"icon-sm",className:"md:hidden shrink-0",onClick:()=>RU.getState().setActivePanel("channel-list"),children:(0,iN.jsx)(A3.ArrowLeft,{className:"size-4"})}),(0,iN.jsxs)("span",{className:"text-sm font-semibold truncate shrink min-w-0",children:["# ",C.name]}),(0,iN.jsxs)(A1,{status:j.status,children:[(0,iN.jsx)(A2,{}),(0,iN.jsx)(A5,{children:j.label})]}),(0,iN.jsx)(Rq,{members:C.members}),(0,iN.jsx)("div",{className:"flex-1"}),C.issueId&&(0,iN.jsx)(hv.Button,{variant:"ghost",size:"icon-sm",onClick:()=>R$.getState().setActiveIssue(C.issueId),title:i("viewRelatedIssue"),children:(0,iN.jsx)(nG.ExternalLink,{className:"size-4"})}),T.length>0&&(0,iN.jsx)(hv.Button,{variant:"ghost",size:"icon-sm",onClick:()=>b(!0),children:(0,iN.jsx)(nJ.Trash2,{className:"size-4"})}),(0,iN.jsx)(hv.Button,{variant:"ghost",size:"icon-sm",onClick:()=>g(!0),children:(0,iN.jsx)(A4,{className:"size-4"})})]}),(0,iN.jsxs)("div",{className:"flex-1 min-h-0 relative",children:[(0,iN.jsxs)("div",{className:"h-full overflow-y-auto py-2",children:[T.map(i=>(0,iN.jsx)("div",{id:`msg-${i.id}`,children:(0,iN.jsx)(yK,{message:i,workspaceId:e,onEdit:R,onDelete:D})},i.id)),(0,iN.jsx)("div",{ref:f})]}),(0,iN.jsx)(Rz,{messages:T})]}),E?(0,iN.jsx)(RK,{question:E,onAnswer:i=>{rL(e).send("channel.answer_question",{channelId:C.id,messageId:E.messageId,questionId:E.questionId,answer:i})}}):null,(0,iN.jsx)(AG,{ref:w,channelName:C.name,channelId:C.id,workspaceId:e,channel:C,agents:N,onSend:M,isProcessing:O,onStop:A})]}),(0,iN.jsx)(A6.Sheet,{open:m,onOpenChange:g,children:(0,iN.jsxs)(A6.SheetContent,{side:"right",className:"w-80 p-0 gap-0",children:[(0,iN.jsxs)(A6.SheetHeader,{className:"sr-only",children:[(0,iN.jsx)(A6.SheetTitle,{children:C.name}),(0,iN.jsx)(A6.SheetDescription,{children:"Channel info panel"})]}),(0,iN.jsx)(RP,{workspaceId:e,channel:C,agents:S,allChannels:s})]})}),(0,iN.jsx)(rE.Dialog,{open:!!v,onOpenChange:e=>{e||y(null)},children:(0,iN.jsxs)(rE.DialogContent,{children:[(0,iN.jsxs)(rE.DialogHeader,{children:[(0,iN.jsx)(rE.DialogTitle,{children:i("deleteMessage.title")}),(0,iN.jsx)(rE.DialogDescription,{children:i("deleteMessage.description")})]}),(0,iN.jsxs)(rE.DialogFooter,{children:[(0,iN.jsx)(rE.DialogClose,{render:(0,iN.jsx)(hv.Button,{variant:"outline"}),children:n("cancel")}),(0,iN.jsxs)(hv.Button,{variant:"destructive",onClick:L,children:[(0,iN.jsx)(nJ.Trash2,{className:"size-3.5"}),n("delete")]})]})]})}),(0,iN.jsx)(rE.Dialog,{open:_,onOpenChange:b,children:(0,iN.jsxs)(rE.DialogContent,{children:[(0,iN.jsxs)(rE.DialogHeader,{children:[(0,iN.jsx)(rE.DialogTitle,{children:i("clearMessages.title")}),(0,iN.jsx)(rE.DialogDescription,{children:i("clearMessages.description",{channel:C?.name})})]}),(0,iN.jsxs)(rE.DialogFooter,{children:[(0,iN.jsx)(rE.DialogClose,{render:(0,iN.jsx)(hv.Button,{variant:"outline"}),children:n("cancel")}),(0,iN.jsxs)(hv.Button,{variant:"destructive",onClick:async()=>{C&&await p(e,C.id),b(!1)},children:[(0,iN.jsx)(nJ.Trash2,{className:"size-3.5"}),i("clearMessages.confirm")]})]})]})})]})}function RK({question:e,onAnswer:i}){let n=(0,n0.useTranslations)("chat"),[r,s]=(0,iM.useState)(""),[o,a]=(0,iM.useState)(!1),l=e=>{let n=e.trim();n&&!o&&(a(!0),i(n),s(""))};return(0,iN.jsx)("div",{className:"border-t bg-background px-4 py-3",children:(0,iN.jsx)("div",{className:"rounded-md border bg-muted/30 p-3",children:(0,iN.jsxs)("div",{className:"flex items-start gap-2",children:[(0,iN.jsx)(dD,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground"}),(0,iN.jsxs)("div",{className:"min-w-0 flex-1 space-y-3",children:[(0,iN.jsx)("div",{className:"text-sm font-medium",children:e.question}),e.choices.length>0?(0,iN.jsx)("div",{className:"flex flex-wrap gap-2",children:e.choices.map(e=>(0,iN.jsx)(hv.Button,{type:"button",size:"sm",variant:"outline",disabled:o,onClick:()=>l(e),className:"h-8",children:e},e))}):null,(0,iN.jsxs)("form",{className:"flex gap-2",onSubmit:e=>{e.preventDefault(),l(r)},children:[(0,iN.jsx)(hy.Input,{value:r,onChange:e=>s(e.target.value),disabled:o,className:"h-8 text-sm",placeholder:n("pendingQuestion.placeholder")}),(0,iN.jsx)(hv.Button,{type:"submit",size:"icon-sm",disabled:!r.trim()||o,children:(0,iN.jsx)(Oh,{className:"size-3.5"})})]})]})]})})})}let RX=(0,nL.default)("circle-dot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);var RJ=e.i(612505),RJ=RJ,RG=e.i(788010),RZ=e.i(302773);function RQ({open:e,onOpenChange:i,agents:n=[],onSubmit:r}){let[s,o]=(0,iM.useState)(""),[a,l]=(0,iM.useState)(""),[c,h]=(0,iM.useState)([]),[d,u]=(0,iM.useState)(""),{workflows:p,loadWorkflows:f}=(0,RZ.useWorkflowStore)(),m=(0,n0.useTranslations)("issue"),g=(0,n0.useTranslations)("common"),v=n.filter(e=>!1!==e.enabled).map(e=>({id:e.id,label:h$(n,e.id)}));(0,iM.useEffect)(()=>{e&&f()},[e,f]);let y=e=>{e||(o(""),l(""),h([]),u("")),i(e)};return(0,iN.jsx)(rE.Dialog,{open:e,onOpenChange:y,children:(0,iN.jsxs)(rE.DialogContent,{className:"sm:max-w-md",children:[(0,iN.jsxs)(rE.DialogHeader,{children:[(0,iN.jsx)(rE.DialogTitle,{children:m("create.title")}),(0,iN.jsx)(rE.DialogDescription,{children:m("create.description")})]}),(0,iN.jsxs)("div",{className:"space-y-3 pt-2",children:[(0,iN.jsx)(hy.Input,{placeholder:m("create.titlePlaceholder"),value:s,onChange:e=>o(e.target.value),onKeyDown:e=>"Enter"===e.key&&e.preventDefault()}),(0,iN.jsx)(RG.Textarea,{placeholder:m("create.descriptionPlaceholder"),value:a,onChange:e=>l(e.target.value),rows:3}),(0,iN.jsxs)("div",{className:"space-y-1.5",children:[(0,iN.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Workflow Template"}),(0,iN.jsxs)("select",{value:d,onChange:e=>{let i=e.target.value;if(u(i),i){let e=p.find(e=>e.id===i);if(e){let i=e.nodes.map(e=>e.data.agentConfigId);h(e=>Array.from(new Set([...e,...i])))}}},className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",children:[(0,iN.jsx)("option",{value:"",children:"None (use default pipeline)"}),p.map(e=>(0,iN.jsxs)("option",{value:e.id,children:[e.name," (",e.nodes.length," agents)"]},e.id))]})]}),(0,iN.jsx)(hF,{candidates:v,selected:c,onToggle:e=>{h(i=>i.includes(e)?i.filter(i=>i!==e):[...i,e])},label:m("create.membersLabel"),searchPlaceholder:m("create.searchAgent"),emptyText:m("create.noAgents")},String(e)),(0,iN.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,iN.jsx)(hv.Button,{variant:"outline",onClick:()=>y(!1),children:g("cancel")}),(0,iN.jsx)(hv.Button,{onClick:()=>{s.trim()&&(r({title:s.trim(),description:a.trim(),members:c,workflowId:d||void 0}),y(!1))},disabled:!s.trim(),children:m("create.submit")})]})]})]})})}let R0=["draft","planned","in_progress","review_pending","changes_requested","approved","completed","archived"];function R1({issue:e,open:i,onOpenChange:n,agents:r=[],onSave:s}){let[o,a]=(0,iM.useState)(e.title),[l,c]=(0,iM.useState)(e.description),[h,d]=(0,iM.useState)(e.status),[u,p]=(0,iM.useState)(e.members||[]),[f,m]=(0,iM.useState)(""),[g,v]=(0,iM.useState)(!1),[y,_]=(0,iM.useState)(e.workflowId??""),{workflows:b,loadWorkflows:w}=(0,RZ.useWorkflowStore)(),S=(0,n0.useTranslations)("issue"),k=(0,n0.useTranslations)("common");(0,iM.useEffect)(()=>{i&&(a(e.title),c(e.description),d(e.status),p(e.members?.length?[...e.members]:[]),m(""),_(e.workflowId??""))},[i,e]),(0,iM.useEffect)(()=>{i&&w()},[i,w]);let C=e=>{p(i=>i.includes(e)?i.filter(i=>i!==e):[...i,e])},T=async()=>{if(o.trim()){v(!0);try{await s({title:o.trim(),description:l.trim(),status:h,members:u,workflowId:"__none__"===y?null:y||null}),n(!1)}finally{v(!1)}}},E=r.filter(e=>!1!==e.enabled&&`${e.name||""} ${e.role||""}`.toLowerCase().includes(f.toLowerCase()));return(0,iN.jsx)(rE.Dialog,{open:i,onOpenChange:n,children:(0,iN.jsxs)(rE.DialogContent,{className:"sm:max-w-md",children:[(0,iN.jsxs)(rE.DialogHeader,{children:[(0,iN.jsx)(rE.DialogTitle,{children:S("edit.title")}),(0,iN.jsx)(rE.DialogDescription,{children:S("edit.description")})]}),(0,iN.jsxs)("div",{className:"space-y-3",children:[(0,iN.jsx)(hy.Input,{placeholder:S("edit.titlePlaceholder"),value:o,onChange:e=>a(e.target.value),onKeyDown:e=>"Enter"===e.key&&e.preventDefault()}),(0,iN.jsx)(RG.Textarea,{placeholder:S("edit.descriptionPlaceholder"),value:l,onChange:e=>c(e.target.value),rows:3}),(0,iN.jsxs)("div",{className:"space-y-1.5",children:[(0,iN.jsx)("label",{className:"text-sm font-medium text-foreground",children:S("edit.statusLabel")}),(0,iN.jsx)("select",{value:h,onChange:e=>d(e.target.value),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",children:R0.map(e=>(0,iN.jsx)("option",{value:e,children:S(`status.${e}`)},e))})]}),(0,iN.jsxs)("div",{className:"space-y-1.5",children:[(0,iN.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Workflow Template"}),(0,iN.jsxs)("select",{value:y||"__none__",onChange:e=>(e=>{if(_(e),!e)return;let i=b.find(i=>i.id===e);if(!i)return;let n=i.nodes.map(e=>e.data.agentConfigId);p(e=>Array.from(new Set([...e,...n])))})("__none__"===e.target.value?"":e.target.value),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",children:[(0,iN.jsx)("option",{value:"__none__",children:"None (use default pipeline)"}),b.map(e=>(0,iN.jsxs)("option",{value:e.id,children:[e.name," (",e.nodes.length," agents)"]},e.id))]})]}),(0,iN.jsxs)("div",{className:"space-y-2",children:[(0,iN.jsx)("label",{className:"text-sm font-medium",children:S("edit.membersLabel")}),(0,iN.jsx)(hy.Input,{value:f,onChange:e=>m(e.target.value),placeholder:S("edit.searchAgent")}),(0,iN.jsxs)("div",{className:"max-h-36 overflow-y-auto space-y-0.5",children:[0===E.length&&(0,iN.jsx)("p",{className:"text-sm text-muted-foreground py-2 text-center",children:S("edit.noAgents")}),E.map(e=>(0,iN.jsxs)("button",{type:"button",onClick:()=>C(e.id),className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md hover:bg-muted text-left text-sm transition-colors",children:[(0,iN.jsx)(hz.AgentIcon,{agentId:e.id,name:h$(r,e.id),className:"size-5 rounded-full"}),(0,iN.jsx)("span",{className:"flex-1 truncate",children:h$(r,e.id)}),(0,iN.jsx)("div",{className:`flex items-center justify-center size-4 rounded border ${u.includes(e.id)?"bg-primary border-primary text-primary-foreground":"border-input"}`})]},e.id))]}),u.length>0&&(0,iN.jsx)("div",{className:"flex flex-wrap gap-1.5",children:u.map(e=>(0,iN.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-md bg-muted px-2 py-0.5 text-xs",children:["user"===e?k("user"):(0,iN.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,iN.jsx)(hz.AgentIcon,{agentId:e,name:h$(r,e),className:"size-3.5 rounded-full"}),h$(r,e)]}),(0,iN.jsx)("button",{type:"button",onClick:()=>C(e),className:"hover:text-destructive",children:(0,iN.jsx)(ru.X,{className:"size-3"})})]},e))})]}),(0,iN.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,iN.jsx)(hv.Button,{variant:"outline",onClick:()=>n(!1),children:k("cancel")}),(0,iN.jsx)(hv.Button,{onClick:T,disabled:!o.trim()||g,children:g?k("saving"):k("save")})]})]})]})})}let R2={draft:"bg-muted text-muted-foreground",planned:"bg-blue-500/10 text-blue-600 dark:text-blue-400",in_progress:"bg-amber-500/10 text-amber-600 dark:text-amber-400",review_pending:"bg-purple-500/10 text-purple-600 dark:text-purple-400",changes_requested:"bg-orange-500/10 text-orange-600 dark:text-orange-400",approved:"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400",completed:"bg-green-600/10 text-green-600 dark:text-green-400",archived:"bg-muted text-muted-foreground",error:"bg-destructive/10 text-destructive"},R5=["in_progress","review_pending","changes_requested","draft","planned","approved","completed","error","archived"];function R3({workspaceId:e}){let{issues:i,activeIssueId:n,loading:r,loadIssues:s,createIssue:o,updateIssue:a,deleteIssue:l,setActiveIssue:c}=R$(),{agents:h,ensure:d}=(0,hD.useAgentStore)(),[u,p]=(0,iM.useState)(!1),[f,m]=(0,iM.useState)(null),g=(0,n0.useTranslations)("issue"),v=(0,n0.useTranslations)("common");(0,iM.useEffect)(()=>{s(e),d()},[e,s,d]);let y=async i=>{await o(e,i.title,i.description,i.members,i.workflowId)},_=R5.map(e=>({status:e,items:i.filter(i=>i.status===e)})).filter(e=>e.items.length>0);return r?(0,iN.jsx)("div",{className:"p-4 text-sm text-muted-foreground",children:v("loading")}):(0,iN.jsxs)("div",{className:"flex flex-col h-full",children:[(0,iN.jsxs)("div",{className:"flex items-center justify-between px-2 py-1.5 border-b text-xs font-medium text-muted-foreground",children:[(0,iN.jsx)("span",{children:g("list.title")}),(0,iN.jsx)("button",{onClick:()=>p(!0),className:"p-0.5 hover:bg-accent rounded",children:(0,iN.jsx)(ry.Plus,{className:"size-3.5"})})]}),(0,iN.jsxs)(A8.ScrollArea,{className:"flex-1",children:[0===_.length&&(0,iN.jsxs)("div",{className:"flex flex-col items-center justify-center h-full gap-3 px-4 text-center py-12",children:[(0,iN.jsx)("div",{className:"rounded-full bg-muted p-3",children:(0,iN.jsx)(RJ.default,{className:"h-5 w-5 text-muted-foreground"})}),(0,iN.jsxs)("div",{children:[(0,iN.jsx)("p",{className:"text-sm font-medium",children:g("list.emptyTitle")}),(0,iN.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:g("list.emptyDescription")})]}),(0,iN.jsxs)(hv.Button,{size:"sm",variant:"outline",onClick:()=>p(!0),children:[(0,iN.jsx)(ry.Plus,{className:"h-3.5 w-3.5 mr-1"}),g("list.addIssue")]})]}),_.map(i=>(0,iN.jsxs)("div",{children:[(0,iN.jsxs)("div",{className:"px-3 py-1 text-xs font-medium text-muted-foreground uppercase",children:[g(`status.${i.status}`)," (",i.items.length,")"]}),i.items.map(i=>(0,iN.jsxs)(dv,{children:[(0,iN.jsxs)(dy,{onClick:()=>c(i.id),className:`w-full text-left px-3 py-2 hover:bg-accent/50 transition-colors flex items-start gap-2 ${n===i.id?"bg-accent":""}`,children:[(0,iN.jsx)(RX,{className:"h-4 w-4 mt-0.5 shrink-0 text-muted-foreground"}),(0,iN.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,iN.jsx)("div",{className:"text-sm font-medium truncate",children:i.title}),(0,iN.jsx)("div",{className:"text-xs text-muted-foreground",children:g("list.taskCount",{count:i.tasks.length})})]}),(0,iN.jsx)(hP.Badge,{variant:"outline",className:`text-[10px] shrink-0 border-none ${R2[i.status]}`,children:g(`status.${i.status}`)})]}),(0,iN.jsxs)(d_,{children:[(0,iN.jsxs)(db,{onClick:()=>m(i),children:[(0,iN.jsx)(rw.Pencil,{className:"size-4 mr-2"}),v("edit")]}),(0,iN.jsx)(dx,{}),(0,iN.jsxs)(db,{variant:"destructive",onClick:()=>l(e,i.id),children:[(0,iN.jsx)(nJ.Trash2,{className:"size-4 mr-2"}),v("delete")]})]})]},i.id))]},i.status))]}),(0,iN.jsx)(RQ,{open:u,onOpenChange:p,agents:h,onSubmit:y}),f&&(0,iN.jsx)(R1,{issue:f,open:!!f,onOpenChange:e=>{e||m(null)},agents:h,onSave:async i=>{await a(e,f.id,i),m(null)}})]})}let R4=(0,nL.default)("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);var R6=e.i(327962);let R8=(0,nL.default)("messages-square",[["path",{d:"M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z",key:"1n2ejm"}],["path",{d:"M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1",key:"1qfcsi"}]]),R9={draft:"secondary",planned:"outline",in_progress:"default",review_pending:"outline",changes_requested:"destructive",approved:"default",completed:"secondary",archived:"outline",error:"destructive"},R7={pending:"secondary",running:"default",reviewing:"outline",waiting_review:"outline",retrying:"outline",done:"secondary",failed:"destructive",cancelled:"outline"};function De({issue:e,workspaceId:i,t:n,setEditOpen:r,setInfoOpen:s,startIssue:o,resumeIssue:a,members:l,enabledAgents:c}){return(0,iN.jsxs)("div",{className:"shrink-0 p-4 pb-3 border-b",children:[(0,iN.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,iN.jsx)(hv.Button,{variant:"ghost",size:"icon-sm",className:"md:hidden shrink-0",onClick:()=>RU.getState().setActivePanel("issue-list"),children:(0,iN.jsx)(A3.ArrowLeft,{className:"size-4"})}),(0,iN.jsx)("h2",{className:"text-lg font-semibold truncate shrink min-w-0",children:e.title}),(0,iN.jsx)(hP.Badge,{variant:R9[e.status],children:n(`status.${e.status}`)}),(0,iN.jsxs)("div",{className:"ml-auto flex items-center gap-0.5",children:[(0,iN.jsx)(hv.Button,{variant:"ghost",size:"icon-sm",onClick:()=>r(!0),children:(0,iN.jsx)(rw.Pencil,{className:"size-4"})}),(0,iN.jsx)(hv.Button,{variant:"ghost",size:"icon-sm",title:n("detail.openChatChannel"),onClick:()=>{e?.channelId&&hR.getState().setActiveChannel(e.channelId)},children:(0,iN.jsx)(R8,{className:"size-4"})}),(0,iN.jsx)(hv.Button,{variant:"ghost",size:"icon-sm",onClick:()=>s(!0),children:(0,iN.jsx)(A4,{className:"size-4"})})]})]}),(0,iN.jsxs)("div",{className:"flex items-center gap-3 text-[11px] text-muted-foreground",children:[l.length>0&&(0,iN.jsxs)("span",{className:"flex items-center gap-1",children:[(0,iN.jsx)(RF.AvatarGroup,{children:l.slice(0,4).map(e=>(0,iN.jsx)(hz.AgentIcon,{agentId:"user"!==e?e:void 0,name:h$(c,e),className:"size-6 rounded-full"},e))}),(0,iN.jsx)("span",{children:n("detail.memberCount",{count:l.length})})]}),(0,iN.jsxs)("span",{className:"flex items-center gap-1",children:[(0,iN.jsx)(dC,{className:"h-3 w-3"}),n("detail.created")," ",new Date(e.createdAt).toLocaleDateString()]}),(0,iN.jsxs)("span",{className:"flex items-center gap-1",children:[(0,iN.jsx)(dC,{className:"h-3 w-3"}),n("detail.updated")," ",new Date(e.updatedAt).toLocaleDateString()]}),e.branch&&(0,iN.jsxs)("span",{className:"flex items-center gap-1",children:[(0,iN.jsx)(R6.GitBranch,{className:"h-3 w-3"}),e.branch]}),e.prUrl&&(0,iN.jsxs)("span",{children:[n("detail.pr")," ",e.prUrl]})]}),e.description&&(0,iN.jsx)("p",{className:"text-sm text-muted-foreground mt-2",children:e.description}),"draft"===e.status&&(0,iN.jsx)("div",{className:"mt-2",children:(0,iN.jsxs)(hv.Button,{size:"sm",variant:"outline",onClick:()=>o(i,e.id),children:[(0,iN.jsx)(rx,{className:"h-3 w-3 mr-1"}),n("detail.start")]})}),"error"===e.status&&(0,iN.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,iN.jsxs)(hv.Button,{size:"sm",variant:"outline",onClick:()=>a(i,e.id),children:[(0,iN.jsx)(R4,{className:"h-3 w-3 mr-1"}),n("detail.resumeFailed")]}),e.retryPaused&&(0,iN.jsx)("span",{className:"text-[11px] text-muted-foreground",children:n("detail.retryPaused",{failed:e.retryCount,total:e.maxRetries})})]})]})}var Dt=Symbol.for("preact-signals");function Di(){if(D_>1)D_--;else{var e,i=!1,n=DS;for(DS=void 0;void 0!==n;)n.S.v===n.v&&(n.S.i=n.i),n=n.o;for(;void 0!==Dy;){var r=Dy;for(Dy=void 0,Db++;void 0!==r;){var s=r.u;if(r.u=void 0,r.f&=-3,!(8&r.f)&&DN(r))try{r.c()}catch(n){i||(e=n,i=!0)}r=s}}if(Db=0,D_--,i)throw e}}function Dn(e){if(D_>0)return e();Dw=++Dx,D_++;try{return e()}finally{Di()}}var Dr=void 0;function Ds(e){var i=Dr;Dr=void 0;try{return e()}finally{Dr=i}}var Do,Da,Dl,Dc,Dh,Dd,Du,Dp,Df,Dm,Dg,Dv,Dy=void 0,D_=0,Db=0,Dx=0,Dw=0,DS=void 0,Dk=0;function DC(e){if(void 0!==Dr){var i=e.n;if(void 0===i||i.t!==Dr)return i={i:0,S:e,p:Dr.s,n:void 0,t:Dr,e:void 0,x:void 0,r:i},void 0!==Dr.s&&(Dr.s.n=i),Dr.s=i,e.n=i,32&Dr.f&&e.S(i),i;if(-1===i.i)return i.i=0,void 0!==i.n&&(i.n.p=i.p,void 0!==i.p&&(i.p.n=i.n),i.p=Dr.s,i.n=void 0,Dr.s.n=i,Dr.s=i),i}}function DT(e,i){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=null==i?void 0:i.watched,this.Z=null==i?void 0:i.unwatched,this.name=null==i?void 0:i.name}function DE(e,i){return new DT(e,i)}function DN(e){for(var i=e.s;void 0!==i;i=i.n)if(i.S.i!==i.i||!i.S.h()||i.S.i!==i.i)return!0;return!1}function DM(e){for(var i=e.s;void 0!==i;i=i.n){var n=i.S.n;if(void 0!==n&&(i.r=n),i.S.n=i,i.i=-1,void 0===i.n){e.s=i;break}}}function DO(e){for(var i=e.s,n=void 0;void 0!==i;){var r=i.p;-1===i.i?(i.S.U(i),void 0!==r&&(r.n=i.n),void 0!==i.n&&(i.n.p=r)):n=i,i.S.n=i.r,void 0!==i.r&&(i.r=void 0),i=r}e.s=n}function DA(e,i){DT.call(this,void 0),this.x=e,this.s=void 0,this.g=Dk-1,this.f=4,this.W=null==i?void 0:i.watched,this.Z=null==i?void 0:i.unwatched,this.name=null==i?void 0:i.name}function DR(e){var i=e.m;if(e.m=void 0,"function"==typeof i){D_++;var n=Dr;Dr=void 0;try{i()}catch(i){throw e.f&=-2,e.f|=8,DD(e),i}finally{Dr=n,Di()}}}function DD(e){for(var i=e.s;void 0!==i;i=i.n)i.S.U(i);e.x=void 0,e.s=void 0,DR(e)}function DL(e){if(Dr!==this)throw Error("Out-of-order effect");DO(this),Dr=e,this.f&=-2,8&this.f&&DD(this),Di()}function Dj(e,i){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=null==i?void 0:i.name,Dv&&Dv.push(this)}function DI(e,i){var n=new Dj(e,i);try{n.c()}catch(e){throw n.d(),e}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}DT.prototype.brand=Dt,DT.prototype.h=function(){return!0},DT.prototype.S=function(e){var i=this,n=this.t;n!==e&&void 0===e.e&&(e.x=n,this.t=e,void 0!==n?n.e=e:Ds(function(){var e;null==(e=i.W)||e.call(i)}))},DT.prototype.U=function(e){var i=this;if(void 0!==this.t){var n=e.e,r=e.x;void 0!==n&&(n.x=r,e.e=void 0),void 0!==r&&(r.e=n,e.x=void 0),e===this.t&&(this.t=r,void 0===r&&Ds(function(){var e;null==(e=i.Z)||e.call(i)}))}},DT.prototype.subscribe=function(e){var i=this;return DI(function(){var n=i.value,r=Dr;Dr=void 0;try{e(n)}finally{Dr=r}},{name:"sub"})},DT.prototype.valueOf=function(){return this.value},DT.prototype.toString=function(){return this.value+""},DT.prototype.toJSON=function(){return this.value},DT.prototype.peek=function(){var e=Dr;Dr=void 0;try{return this.value}finally{Dr=e}},Object.defineProperty(DT.prototype,"value",{get:function(){var e=DC(this);return void 0!==e&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(Db>100)throw Error("Cycle detected");0!==D_&&0===Db&&this.l!==Dw&&(this.l=Dw,DS={S:this,v:this.v,i:this.i,o:DS}),this.v=e,this.i++,Dk++,D_++;try{for(var i=this.t;void 0!==i;i=i.x)i.t.N()}finally{Di()}}}}),DA.prototype=new DT,DA.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if(32==(36&this.f)||(this.f&=-5,this.g===Dk))return!0;if(this.g=Dk,this.f|=1,this.i>0&&!DN(this))return this.f&=-2,!0;var e=Dr;try{DM(this),Dr=this;var i=this.x();(16&this.f||this.v!==i||0===this.i)&&(this.v=i,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return Dr=e,DO(this),this.f&=-2,!0},DA.prototype.S=function(e){if(void 0===this.t){this.f|=36;for(var i=this.s;void 0!==i;i=i.n)i.S.S(i)}DT.prototype.S.call(this,e)},DA.prototype.U=function(e){if(void 0!==this.t&&(DT.prototype.U.call(this,e),void 0===this.t)){this.f&=-33;for(var i=this.s;void 0!==i;i=i.n)i.S.U(i)}},DA.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;void 0!==e;e=e.x)e.t.N()}},Object.defineProperty(DA.prototype,"value",{get:function(){if(1&this.f)throw Error("Cycle detected");var e=DC(this);if(this.h(),void 0!==e&&(e.i=this.i),16&this.f)throw this.v;return this.v}}),Dj.prototype.c=function(){var e=this.S();try{if(8&this.f||void 0===this.x)return;var i=this.x();"function"==typeof i&&(this.m=i)}finally{e()}},Dj.prototype.S=function(){if(1&this.f)throw Error("Cycle detected");this.f|=1,this.f&=-9,DR(this),DM(this),D_++;var e=Dr;return Dr=this,DL.bind(this,e)},Dj.prototype.N=function(){2&this.f||(this.f|=2,this.u=Dy,Dy=this)},Dj.prototype.d=function(){this.f|=8,1&this.f||DD(this)},Dj.prototype.dispose=function(){this.d()};var DP=Object.create,DB=Object.defineProperty,Dz=Object.defineProperties,DF=Object.getOwnPropertyDescriptor,DW=Object.getOwnPropertyDescriptors,DH=Object.getOwnPropertySymbols,D$=Object.prototype.hasOwnProperty,DU=Object.prototype.propertyIsEnumerable,DV=e=>{throw TypeError(e)},Dq=(e,i,n)=>i in e?DB(e,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[i]=n,DY=(e,i)=>DB(e,"name",{value:i,configurable:!0}),DK=["class","method","getter","setter","accessor","field","value","get","set"],DX=e=>void 0!==e&&"function"!=typeof e?DV("Function expected"):e,DJ=(e,i,n,r,s)=>({kind:DK[e],name:i,metadata:r,addInitializer:e=>n._?DV("Already initialized"):s.push(DX(e||null))}),DG=(e,i)=>{let n,r;return Dq(i,(n="metadata",(r=Symbol[n])?r:Symbol.for("Symbol."+n)),e[3])},DZ=(e,i,n,r)=>{for(var s=0,o=e[i>>1],a=o&&o.length;s<a;s++)1&i?o[s].call(n):r=o[s].call(n,r);return r},DQ=(e,i,n,r,s,o)=>{var a,l,c,h,d,u=7&i,p=!!(8&i),f=!!(16&i),m=u>3?e.length+1:u?p?1:2:0,g=DK[u+5],v=u>3&&(e[m-1]=[]),y=e[m]||(e[m]=[]),_=u&&(f||p||(s=s.prototype),u<5&&(u>3||!f)&&DF(u<4?s:{get[n](){return D2(this,o)},set[n](x){return D3(this,o,x)}},n));u?f&&u<4&&DY(o,(u>2?"set ":u>1?"get ":"")+n):DY(s,n);for(var b=r.length-1;b>=0;b--)h=DJ(u,n,c={},e[3],y),u&&(h.static=p,h.private=f,d=h.access={has:f?e=>D1(s,e):e=>n in e},3^u&&(d.get=f?e=>(1^u?D2:D4)(e,s,4^u?o:_.get):e=>e[n]),u>2&&(d.set=f?(e,i)=>D3(e,s,i,4^u?o:_.set):(e,i)=>e[n]=i)),l=(0,r[b])(u?u<4?f?o:_[g]:u>4?void 0:{get:_.get,set:_.set}:s,h),c._=1,4^u||void 0===l?DX(l)&&(u>4?v.unshift(l):u?f?o=l:_[g]=l:s=l):"object"!=typeof l||null===l?DV("Object expected"):(DX(a=l.get)&&(_.get=a),DX(a=l.set)&&(_.set=a),DX(a=l.init)&&v.unshift(a));return u||DG(e,s),_&&DB(s,n,_),f?4^u?o:_:s},D0=(e,i,n)=>i.has(e)||DV("Cannot "+n),D1=(e,i)=>Object(i)!==i?DV('Cannot use the "in" operator on this value'):e.has(i),D2=(e,i,n)=>(D0(e,i,"read from private field"),n?n.call(e):i.get(e)),D5=(e,i,n)=>i.has(e)?DV("Cannot add the same private member more than once"):i instanceof WeakSet?i.add(e):i.set(e,n),D3=(e,i,n,r)=>(D0(e,i,"write to private field"),r?r.call(e,n):i.set(e,n),n),D4=(e,i,n)=>(D0(e,i,"access private method"),n);function D6(e,i){if(i){let n;return new DA(()=>{let r=e();return r&&n&&i(n,r)?n:(n=r,r)},void 0)}return new DA(e,void 0)}function D8(e,i){if(Object.is(e,i))return!0;if(null===e||null===i)return!1;if("function"==typeof e&&"function"==typeof i)return e===i;if(e instanceof Set&&i instanceof Set){if(e.size!==i.size)return!1;for(let n of e)if(!i.has(n))return!1;return!0}if(Array.isArray(e))return!!Array.isArray(i)&&e.length===i.length&&!e.some((e,n)=>!D8(e,i[n]));if("object"==typeof e&&"object"==typeof i){let n=Object.keys(e),r=Object.keys(i);return n.length===r.length&&!n.some(n=>!D8(e[n],i[n]))}return!1}function D9({get:e},i){return{init:e=>DE(e),get(){return e.call(this).value},set(i){let n=e.call(this);n.peek()!==i&&(n.value=i)}}}function D7(e,i){let n=new WeakMap;return function(){let i=n.get(this);return i||(i=D6(e.bind(this)),n.set(this,i)),i.value}}function Le(e=!0){return function(i,n){n.addInitializer(function(){let i="field"===n.kind||n.static?this:Object.getPrototypeOf(this),r=Object.getOwnPropertyDescriptor(i,n.name);r&&Object.defineProperty(i,n.name,Dz(((e,i)=>{for(var n in i||(i={}))D$.call(i,n)&&Dq(e,n,i[n]);if(DH)for(var n of DH(i))DU.call(i,n)&&Dq(e,n,i[n]);return e})({},r),DW({enumerable:e})))})}}function Lt(...e){let i=e.map(e=>DI(e));return()=>i.forEach(e=>e())}D=[D9],R=[D9],A=[D9],O=[Le()],M=[Le()],N=[Le()];var Li=class{constructor(e,i=Object.is){this.defaultValue=e,this.equals=i,DZ(L,5,this),D5(this,z),D5(this,j,DZ(L,8,this)),DZ(L,11,this),D5(this,F,DZ(L,12,this)),DZ(L,15,this),D5(this,U,DZ(L,16,this)),DZ(L,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return D2(this,z,q)}get initial(){return D2(this,z,P)}get previous(){return D2(this,z,H)}set current(e){let i=Ds(()=>D2(this,z,q));e&&i&&this.equals(i,e)||Dn(()=>{D2(this,z,P)||D3(this,z,e,B),D3(this,z,i,$),D3(this,z,e,Y)})}reset(e=this.defaultValue){Dn(()=>{D3(this,z,void 0,$),D3(this,z,e,B),D3(this,z,e,Y)})}};function Ln(e){return Ds(()=>{let i={};for(let n in e)i[n]=e[n];return i})}L=[,,,DP(null)],j=new WeakMap,z=new WeakSet,F=new WeakMap,U=new WeakMap,P=(I=DQ(L,20,"#initial",D,z,j)).get,B=I.set,H=(W=DQ(L,20,"#previous",R,z,F)).get,$=W.set,q=(V=DQ(L,20,"#current",A,z,U)).get,Y=V.set,DQ(L,2,"current",O,Li),DQ(L,2,"initial",M,Li),DQ(L,2,"previous",N,Li),DG(L,Li);var Lr=class{constructor(){D5(this,K,new WeakMap)}get(e,i){var n;return e?null==(n=D2(this,K).get(e))?void 0:n.get(i):void 0}set(e,i,n){var r;if(e)return D2(this,K).has(e)||D2(this,K).set(e,new Map),null==(r=D2(this,K).get(e))?void 0:r.set(i,n)}clear(e){var i;return e?null==(i=D2(this,K).get(e))?void 0:i.clear():void 0}};K=new WeakMap;var Ls=Object.create,Lo=Object.defineProperty,La=Object.getOwnPropertyDescriptor,Ll=Object.getOwnPropertySymbols,Lc=Object.prototype.hasOwnProperty,Lh=Object.prototype.propertyIsEnumerable,Ld=(e,i)=>(i=Symbol[e])?i:Symbol.for("Symbol."+e),Lu=e=>{throw TypeError(e)},Lp=Math.pow,Lf=(e,i,n)=>i in e?Lo(e,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[i]=n,Lm=(e,i)=>Lo(e,"name",{value:i,configurable:!0}),Lg=["class","method","getter","setter","accessor","field","value","get","set"],Lv=e=>void 0!==e&&"function"!=typeof e?Lu("Function expected"):e,Ly=(e,i,n,r,s)=>({kind:Lg[e],name:i,metadata:r,addInitializer:e=>n._?Lu("Already initialized"):s.push(Lv(e||null))}),L_=(e,i)=>Lf(i,Ld("metadata"),e[3]),Lb=(e,i,n,r,s,o)=>{var a,l,c,h,d,u=7&i,p=!!(8&i),f=!!(16&i),m=u>3?e.length+1:u?p?1:2:0,g=Lg[u+5],v=u>3&&(e[m-1]=[]),y=e[m]||(e[m]=[]),_=u&&(f||p||(s=s.prototype),u<5&&(u>3||!f)&&La(u<4?s:{get[n](){return LS(this,o)},set[n](x){return Lk(this,o,x)}},n));u?f&&u<4&&Lm(o,(u>2?"set ":u>1?"get ":"")+n):Lm(s,n);for(var b=r.length-1;b>=0;b--)h=Ly(u,n,c={},e[3],y),u&&(h.static=p,h.private=f,d=h.access={has:f?e=>Lw(s,e):e=>n in e},3^u&&(d.get=f?e=>(1^u?LS:LC)(e,s,4^u?o:_.get):e=>e[n]),u>2&&(d.set=f?(e,i)=>Lk(e,s,i,4^u?o:_.set):(e,i)=>e[n]=i)),l=(0,r[b])(u?u<4?f?o:_[g]:u>4?void 0:{get:_.get,set:_.set}:s,h),c._=1,4^u||void 0===l?Lv(l)&&(u>4?v.unshift(l):u?f?o=l:_[g]=l:s=l):"object"!=typeof l||null===l?Lu("Object expected"):(Lv(a=l.get)&&(_.get=a),Lv(a=l.set)&&(_.set=a),Lv(a=l.init)&&v.unshift(a));return u||L_(e,s),_&&Lo(s,n,_),f?4^u?o:_:s},Lx=(e,i,n)=>i.has(e)||Lu("Cannot "+n),Lw=(e,i)=>Object(i)!==i?Lu('Cannot use the "in" operator on this value'):e.has(i),LS=(e,i,n)=>(Lx(e,i,"read from private field"),n?n.call(e):i.get(e)),Lk=(e,i,n,r)=>(Lx(e,i,"write to private field"),r?r.call(e,n):i.set(e,n),n),LC=(e,i,n)=>(Lx(e,i,"access private method"),n),LT=class e{constructor(e,i){this.x=e,this.y=i}static delta(i,n){return new e(i.x-n.x,i.y-n.y)}static distance(e,i){return Math.hypot(e.x-i.x,e.y-i.y)}static equals(e,i){return e.x===i.x&&e.y===i.y}static from({x:i,y:n}){return new e(i,n)}},LE=class e{constructor(e,i,n,r){this.left=e,this.top=i,this.width=n,this.height=r,this.scale={x:1,y:1}}get inverseScale(){return{x:1/this.scale.x,y:1/this.scale.y}}translate(i,n){let{top:r,left:s,width:o,height:a,scale:l}=this,c=new e(s+i,r+n,o,a);return c.scale=((e,i)=>{for(var n in i||(i={}))Lc.call(i,n)&&Lf(e,n,i[n]);if(Ll)for(var n of Ll(i))Lh.call(i,n)&&Lf(e,n,i[n]);return e})({},l),c}get boundingRectangle(){let{width:e,height:i,left:n,top:r,right:s,bottom:o}=this;return{width:e,height:i,left:n,top:r,right:s,bottom:o}}get center(){let{left:e,top:i,right:n,bottom:r}=this;return new LT((e+n)/2,(i+r)/2)}get area(){let{width:e,height:i}=this;return e*i}equals(i){if(!(i instanceof e))return!1;let{left:n,top:r,width:s,height:o}=this;return n===i.left&&r===i.top&&s===i.width&&o===i.height}containsPoint(e){let{top:i,left:n,bottom:r,right:s}=this;return i<=e.y&&e.y<=r&&n<=e.x&&e.x<=s}intersectionArea(i){var n,r;let s,o,a,l;return i instanceof e?(n=this,s=Math.max((r=i).top,n.top),o=Math.max(r.left,n.left),a=Math.min(r.left+r.width,n.left+n.width),l=Math.min(r.top+r.height,n.top+n.height),o<a&&s<l?(a-o)*(l-s):0):0}intersectionRatio(e){let{area:i}=this,n=this.intersectionArea(e);return n/(e.area+i-n)}get bottom(){let{top:e,height:i}=this;return e+i}get right(){let{left:e,width:i}=this;return e+i}get aspectRatio(){let{width:e,height:i}=this;return e/i}get corners(){return[{x:this.left,y:this.top},{x:this.right,y:this.top},{x:this.left,y:this.bottom},{x:this.right,y:this.bottom}]}static from({top:i,left:n,width:r,height:s}){return new e(n,i,r,s)}static delta(e,i,n={x:"center",y:"center"}){let r=(e,i)=>{let r=n[i],s="x"===i?e.left:e.top,o="x"===i?e.width:e.height;return"start"==r?s:"end"==r?s+o:s+o/2};return LT.delta({x:r(e,"x"),y:r(e,"y")},{x:r(i,"x"),y:r(i,"y")})}static intersectionRatio(i,n){return e.from(i).intersectionRatio(e.from(n))}},LN=class extends(G=Li,J=[D7],X=[D7],G){constructor(e){super(LT.from(e),(e,i)=>LT.equals(e,i)),((e,i,n,r)=>{for(var s=0,o=e[i>>1],a=o&&o.length;s<a;s++)1&i?o[s].call(n):r=o[s].call(n,r)})(Q,5,this),((e,i,n)=>i.has(e)?Lu("Cannot add the same private member more than once"):i instanceof WeakSet?i.add(e):i.set(e,n))(this,Z,0),this.velocity={x:0,y:0}}get delta(){return LT.delta(this.current,this.initial)}get direction(){let{current:e,previous:i}=this;if(!i)return null;let n={x:e.x-i.x,y:e.y-i.y};return n.x||n.y?Math.abs(n.x)>Math.abs(n.y)?n.x>0?"right":"left":n.y>0?"down":"up":null}get current(){return super.current}set current(e){let{current:i}=this,n=LT.from(e),r={x:n.x-i.x,y:n.y-i.y},s=Date.now(),o=s-LS(this,Z),a=e=>Math.round(e/o*100);Dn(()=>{Lk(this,Z,s),this.velocity={x:a(r.x),y:a(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(LT.from(e)),this.velocity={x:0,y:0}}};function LM({x:e,y:i},n){let r=Math.abs(e),s=Math.abs(i);return"number"==typeof n?Math.sqrt(Lp(r,2)+Lp(s,2))>n:"x"in n&&"y"in n?r>n.x&&s>n.y:"x"in n?r>n.x:"y"in n&&s>n.y}Q=[,,,Ls(null!=(y=null==G?void 0:G[Ld("metadata")])?y:null)],Z=new WeakMap,Lb(Q,2,"delta",J,LN),Lb(Q,2,"direction",X,LN),L_(Q,LN);var LO=((_=LO||{}).Horizontal="x",_.Vertical="y",_),LA=Object.values(LO),LR=Object.create,LD=Object.defineProperty,LL=Object.defineProperties,Lj=Object.getOwnPropertyDescriptor,LI=Object.getOwnPropertyDescriptors,LP=Object.getOwnPropertySymbols,LB=Object.prototype.hasOwnProperty,Lz=Object.prototype.propertyIsEnumerable,LF=(e,i)=>(i=Symbol[e])?i:Symbol.for("Symbol."+e),LW=e=>{throw TypeError(e)},LH=(e,i,n)=>i in e?LD(e,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[i]=n,L$=(e,i)=>{for(var n in i||(i={}))LB.call(i,n)&&LH(e,n,i[n]);if(LP)for(var n of LP(i))Lz.call(i,n)&&LH(e,n,i[n]);return e},LU=(e,i)=>LL(e,LI(i)),LV=(e,i)=>LD(e,"name",{value:i,configurable:!0}),Lq=(e,i)=>{var n={};for(var r in e)LB.call(e,r)&&0>i.indexOf(r)&&(n[r]=e[r]);if(null!=e&&LP)for(var r of LP(e))0>i.indexOf(r)&&Lz.call(e,r)&&(n[r]=e[r]);return n},LY=e=>{var i;return[,,,LR(null!=(i=null==e?void 0:e[LF("metadata")])?i:null)]},LK=["class","method","getter","setter","accessor","field","value","get","set"],LX=e=>void 0!==e&&"function"!=typeof e?LW("Function expected"):e,LJ=(e,i,n,r,s)=>({kind:LK[e],name:i,metadata:r,addInitializer:e=>n._?LW("Already initialized"):s.push(LX(e||null))}),LG=(e,i)=>LH(i,LF("metadata"),e[3]),LZ=(e,i,n,r)=>{for(var s=0,o=e[i>>1],a=o&&o.length;s<a;s++)1&i?o[s].call(n):r=o[s].call(n,r);return r},LQ=(e,i,n,r,s,o)=>{var a,l,c,h,d,u=7&i,p=!!(8&i),f=!!(16&i),m=u>3?e.length+1:u?p?1:2:0,g=LK[u+5],v=u>3&&(e[m-1]=[]),y=e[m]||(e[m]=[]),_=u&&(f||p||(s=s.prototype),u<5&&(u>3||!f)&&Lj(u<4?s:{get[n](){return L2(this,o)},set[n](x){return L3(this,o,x)}},n));u?f&&u<4&&LV(o,(u>2?"set ":u>1?"get ":"")+n):LV(s,n);for(var b=r.length-1;b>=0;b--)h=LJ(u,n,c={},e[3],y),u&&(h.static=p,h.private=f,d=h.access={has:f?e=>L1(s,e):e=>n in e},3^u&&(d.get=f?e=>(1^u?L2:L4)(e,s,4^u?o:_.get):e=>e[n]),u>2&&(d.set=f?(e,i)=>L3(e,s,i,4^u?o:_.set):(e,i)=>e[n]=i)),l=(0,r[b])(u?u<4?f?o:_[g]:u>4?void 0:{get:_.get,set:_.set}:s,h),c._=1,4^u||void 0===l?LX(l)&&(u>4?v.unshift(l):u?f?o=l:_[g]=l:s=l):"object"!=typeof l||null===l?LW("Object expected"):(LX(a=l.get)&&(_.get=a),LX(a=l.set)&&(_.set=a),LX(a=l.init)&&v.unshift(a));return u||LG(e,s),_&&LD(s,n,_),f?4^u?o:_:s},L0=(e,i,n)=>i.has(e)||LW("Cannot "+n),L1=(e,i)=>Object(i)!==i?LW('Cannot use the "in" operator on this value'):e.has(i),L2=(e,i,n)=>(L0(e,i,"read from private field"),n?n.call(e):i.get(e)),L5=(e,i,n)=>i.has(e)?LW("Cannot add the same private member more than once"):i instanceof WeakSet?i.add(e):i.set(e,n),L3=(e,i,n,r)=>(L0(e,i,"write to private field"),r?r.call(e,n):i.set(e,n),n),L4=(e,i,n)=>(L0(e,i,"access private method"),n);function L6(e,i){return{plugin:e,options:i}}function L8(e){return i=>L6(e,i)}function L9(e){return"function"==typeof e?{plugin:e,options:void 0}:e}ee=[D9];var L7=class{constructor(e,i){this.manager=e,this.options=i,L5(this,ei,LZ(et,8,this,!1)),LZ(et,11,this),L5(this,en,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return Ds(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){let i=DI(e.bind(this));return L2(this,en).add(i),i}destroy(){L2(this,en).forEach(e=>e())}static configure(e){return L6(this,e)}};et=LY(null),ei=new WeakMap,en=new WeakMap,LQ(et,4,"disabled",ee,L7,ei),LG(et,L7);var je=class extends L7{},jt=class{constructor(e){this.manager=e,this.instances=new Map,L5(this,er,[])}get values(){return Array.from(this.instances.values())}set values(e){let i=e.map(L9).reduce((e,i)=>{let n=e.find(({plugin:e})=>e===i.plugin);return n?(n.options=i.options,e):[...e,i]},[]),n=i.map(({plugin:e})=>e);for(let e of L2(this,er))if(!n.includes(e)){if(e.prototype instanceof je)continue;this.unregister(e)}for(let{plugin:e,options:n}of i)this.register(e,n);L3(this,er,n)}get(e){return this.instances.get(e)}register(e,i){let n=this.instances.get(e);if(n)return n.options!==i&&(n.options=i),n;let r=new e(this.manager,i);return this.instances.set(e,r),r}unregister(e){let i=this.instances.get(e);i&&(i.destroy(),this.instances.delete(e))}destroy(){for(let e of this.instances.values())e.destroy();this.instances.clear()}};function ji(e,i){return e.priority===i.priority?e.type===i.type?i.value-e.value:i.type-e.type:i.priority-e.priority}er=new WeakMap;var jn=[],jr=class extends L7{constructor(e){super(e),L5(this,es),L5(this,eo),this.computeCollisions=this.computeCollisions.bind(this),L3(this,eo,DE(jn)),this.destroy=Lt(()=>{let e=this.computeCollisions(),i=Ds(()=>this.manager.dragOperation.position.current);if(e!==jn){let e=L2(this,es);if(L3(this,es,i),e&&i.x==e.x&&i.y==e.y)return}else L3(this,es,void 0);L2(this,eo).value=e},()=>{let{dragOperation:e}=this.manager;e.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){Ds(()=>{e?L2(this,eo).value=this.computeCollisions():L3(this,es,void 0)})}computeCollisions(e,i){let{registry:n,dragOperation:r}=this.manager,{source:s,shape:o,status:a}=r;if(!a.initialized||!o)return jn;let l=[],c=[];for(let o of null!=e?e:n.droppables){if(o.disabled||s&&!o.accepts(s))continue;let e=null!=i?i:o.collisionDetector;if(!e)continue;c.push(o),o.shape;let n=Ds(()=>e({droppable:o,dragOperation:r}));n&&(null!=o.collisionPriority&&(n.priority=o.collisionPriority),l.push(n))}return 0===c.length?jn:(l.sort(ji),l)}get collisions(){return L2(this,eo).value}};es=new WeakMap,eo=new WeakMap,ec=[D9],el=[D9],ea=[D9];var js=class e{constructor(e,i){L5(this,ep,LZ(eu,8,this)),LZ(eu,11,this),L5(this,ef),L5(this,em,LZ(eu,12,this)),LZ(eu,15,this),L5(this,eg,LZ(eu,16,this)),LZ(eu,19,this);const{effects:n,id:r,data:s={},disabled:o=!1,register:a=!0}=e;let l=r;L3(this,ef,DE(r)),this.manager=i,this.data=s,this.disabled=o,this.effects=()=>{var e;return[()=>{let{id:e,manager:i}=this;if(e!==l)return l=e,null==i||i.registry.register(this),()=>null==i?void 0:i.registry.unregister(this)},...null!=(e=null==n?void 0:n())?e:[]]},this.register=this.register.bind(this),this.unregister=this.unregister.bind(this),this.destroy=this.destroy.bind(this),i&&a&&queueMicrotask(this.register)}get id(){var i,n;let r=L2(this,ef).value;return null!=(n=null==(i=e.pendingIdChanges)?void 0:i.get(this))?n:r}set id(i){var n,r;i!==(null!=(r=null==(n=e.pendingIdChanges)?void 0:n.get(this))?r:L2(this,ef).peek())&&(e.pendingIdChanges||(e.pendingIdChanges=new Map,queueMicrotask(()=>L4(e,eh,ed).call(e))),e.pendingIdChanges.set(this,i))}register(){var e;return null==(e=this.manager)?void 0:e.registry.register(this)}unregister(){var e;null==(e=this.manager)||e.registry.unregister(this)}destroy(){var e;null==(e=this.manager)||e.registry.unregister(this)}};eu=LY(null),eh=new WeakSet,ed=function(){let e=js.pendingIdChanges;js.pendingIdChanges=null,e&&Dn(()=>{for(let[i,n]of e)L2(i,ef).value=n})},ep=new WeakMap,ef=new WeakMap,em=new WeakMap,eg=new WeakMap,LQ(eu,4,"manager",ec,js,ep),LQ(eu,4,"data",el,js,em),LQ(eu,4,"disabled",ea,js,eg),L5(js,eh),LG(eu,js),js.pendingIdChanges=null;var jo=js,ja=class{constructor(){this.map=DE(new Map),this.cleanupFunctions=new WeakMap,this.register=(e,i)=>{let n=this.map.peek(),r=n.get(e),s=()=>this.unregister(e,i);if(r===i)return s;if(r&&r.id===e){let e=this.cleanupFunctions.get(r);null==e||e(),this.cleanupFunctions.delete(r)}let o=new Map(n);for(let[r,s]of n)if(s===i&&r!==e){o.delete(r);break}o.set(e,i),this.map.value=o;let a=Lt(...i.effects());return this.cleanupFunctions.set(i,a),s},this.unregister=(e,i)=>{let n=this.map.peek();if(n.get(e)!==i)return;let r=this.cleanupFunctions.get(i);null==r||r(),this.cleanupFunctions.delete(i);let s=new Map(n);s.delete(e),this.map.value=s}}[Symbol.iterator](){return this.map.peek().values()}get value(){return this.map.value.values()}has(e){return this.map.value.has(e)}get(e){return this.map.value.get(e)}destroy(){for(let e of this){let i=this.cleanupFunctions.get(e);null==i||i(),e.destroy()}this.map.value=new Map}},jl=class extends(eS=jo,ew=[D9],ex=[D9],eb=[D9],e_=[D7],ey=[D7],ev=[D7],eS){constructor(e,i){var{modifiers:n,type:r,sensors:s,plugins:o,effects:a}=e,l=Lq(e,["modifiers","type","sensors","plugins","effects"]);super(LU(L$({},l),{effects:()=>{var e;return[...null!=(e=null==a?void 0:a())?e:[],()=>{let{manager:e,plugins:i}=this;if(e&&i)for(let n of i){let{plugin:i}=L9(n);e.registry.plugins.register(i)}}]}}),i),LZ(ek,5,this),L5(this,eC,LZ(ek,8,this)),LZ(ek,11,this),L5(this,eT,LZ(ek,12,this)),LZ(ek,15,this),L5(this,eE,LZ(ek,16,this,this.isDragSource?"dragging":"idle")),LZ(ek,19,this),this.type=r,this.sensors=s,this.modifiers=n,this.alignment=l.alignment,this.plugins=o}pluginConfig(e){if(this.plugins)for(let i of this.plugins){let n=L9(i);if(n.plugin===e)return n.options}}get isDropping(){return"dropping"===this.status&&this.isDragSource}get isDragging(){return"dragging"===this.status&&this.isDragSource}get isDragSource(){var e,i;return(null==(i=null==(e=this.manager)?void 0:e.dragOperation.source)?void 0:i.id)===this.id}};ek=LY(eS),eC=new WeakMap,eT=new WeakMap,eE=new WeakMap,LQ(ek,4,"type",ew,jl,eC),LQ(ek,4,"modifiers",ex,jl,eT),LQ(ek,4,"status",eb,jl,eE),LQ(ek,2,"isDropping",e_,jl),LQ(ek,2,"isDragging",ey,jl),LQ(ek,2,"isDragSource",ev,jl),LG(ek,jl);var jc=class extends(eL=jo,eD=[D9],eR=[D9],eA=[D9],eO=[D9],eM=[D9],eN=[D7],eL){constructor(e,i){var{accept:n,collisionDetector:r,collisionPriority:s,type:o}=e;super(Lq(e,["accept","collisionDetector","collisionPriority","type"]),i),LZ(ej,5,this),L5(this,eI,LZ(ej,8,this)),LZ(ej,11,this),L5(this,eP,LZ(ej,12,this)),LZ(ej,15,this),L5(this,eB,LZ(ej,16,this)),LZ(ej,19,this),L5(this,ez,LZ(ej,20,this)),LZ(ej,23,this),L5(this,eF,LZ(ej,24,this)),LZ(ej,27,this),this.accept=n,this.collisionDetector=r,this.collisionPriority=s,this.type=o}accepts(e){let{accept:i}=this;return!i||("function"==typeof i?i(e):!!e.type&&(Array.isArray(i)?i.includes(e.type):e.type===i))}get isDropTarget(){var e,i;return(null==(i=null==(e=this.manager)?void 0:e.dragOperation.target)?void 0:i.id)===this.id}};ej=LY(eL),eI=new WeakMap,eP=new WeakMap,eB=new WeakMap,ez=new WeakMap,eF=new WeakMap,LQ(ej,4,"accept",eD,jc,eI),LQ(ej,4,"type",eR,jc,eP),LQ(ej,4,"collisionDetector",eA,jc,eB),LQ(ej,4,"collisionPriority",eO,jc,ez),LQ(ej,4,"shape",eM,jc,eF),LQ(ej,2,"isDropTarget",eN,jc),LG(ej,jc);var jh=class{constructor(){this.registry=new Map}addEventListener(e,i){let{registry:n}=this,r=new Set(n.get(e));return r.add(i),n.set(e,r),()=>this.removeEventListener(e,i)}removeEventListener(e,i){let{registry:n}=this,r=new Set(n.get(e));r.delete(i),n.set(e,r)}dispatch(e,...i){let{registry:n}=this,r=n.get(e);if(r)for(let e of r)e(...i)}},jd=class extends jh{constructor(e){super(),this.manager=e}dispatch(e,i){let n=[i,this.manager];super.dispatch(e,...n)}};function ju(e,i=!0){let n=!1;return LU(L$({},e),{cancelable:i,get defaultPrevented(){return n},preventDefault(){i&&(n=!0)}})}var jp=class extends je{constructor(e){super(e);let i=[];this.destroy=Lt(()=>{let{dragOperation:n,collisionObserver:r}=e;n.status.initializing&&(i=[],r.enable())},()=>{let n,{collisionObserver:r,monitor:s}=e,{collisions:o}=r;if(r.isDisabled()||jo.pendingIdChanges)return;let a=ju({collisions:o});if(s.dispatch("collision",a),a.defaultPrevented||(n=i,o.map(({id:e})=>e).join("")===n.map(({id:e})=>e).join("")))return;i=o;let[l]=o;Ds(()=>{var i;(null==l?void 0:l.id)!==(null==(i=e.dragOperation.target)?void 0:i.id)&&(r.disable(),e.actions.setDropTarget(null==l?void 0:l.id).then(()=>{r.enable()}))})})}},jf=((b=jf||{})[b.Lowest=0]="Lowest",b[b.Low=1]="Low",b[b.Normal=2]="Normal",b[b.High=3]="High",b[b.Highest=4]="Highest",b),jm=((w=jm||{})[w.Collision=0]="Collision",w[w.ShapeIntersection=1]="ShapeIntersection",w[w.PointerIntersection=2]="PointerIntersection",w);eY=[D9],eq=[D7],eV=[D7],eU=[D7],e$=[D7],eH=[D7],eW=[D7];var jg=class{constructor(){LZ(eK,5,this),L5(this,eX,LZ(eK,8,this,"idle")),LZ(eK,11,this)}get current(){return this.value}get idle(){return"idle"===this.value}get initializing(){return"initializing"===this.value}get initialized(){let{value:e}=this;return"idle"!==e&&"initialization-pending"!==e}get dragging(){return"dragging"===this.value}get dropped(){return"dropped"===this.value}set(e){this.value=e}};eK=LY(null),eX=new WeakMap,LQ(eK,4,"value",eY,jg,eX),LQ(eK,2,"current",eq,jg),LQ(eK,2,"idle",eV,jg),LQ(eK,2,"initializing",eU,jg),LQ(eK,2,"initialized",e$,jg),LQ(eK,2,"dragging",eH,jg),LQ(eK,2,"dropped",eW,jg),LG(eK,jg);var jv=class{constructor(e){this.manager=e}setDragSource(e){let{dragOperation:i}=this.manager;i.sourceIdentifier="string"==typeof e||"number"==typeof e?e:e.id}setDropTarget(e){return Ds(()=>{let{dragOperation:i}=this.manager,n=null!=e?e:null;if(i.targetIdentifier===n)return Promise.resolve(!1);i.targetIdentifier=n;let r=ju({operation:i.snapshot()});return i.status.dragging&&this.manager.monitor.dispatch("dragover",r),this.manager.renderer.rendering.then(()=>r.defaultPrevented)})}start(e){return Ds(()=>{let{dragOperation:i}=this.manager;if(null!=e.source&&this.setDragSource(e.source),!i.source)throw Error("Cannot start a drag operation without a drag source");if(!i.status.idle)throw Error("Cannot start a drag operation while another is active");let n=new AbortController,{event:r,coordinates:s}=e;Dn(()=>{i.status.set("initialization-pending"),i.shape=null,i.canceled=!1,i.activatorEvent=null!=r?r:null,i.position.reset(s)});let o=ju({operation:i.snapshot()});return(this.manager.monitor.dispatch("beforedragstart",o),o.defaultPrevented)?(i.reset(),n.abort()):(i.status.set("initializing"),i.controller=n,this.manager.renderer.rendering.then(()=>{if(n.signal.aborted)return;let{status:e}=i;"initializing"===e.current&&Dn(()=>{i.status.set("dragging"),this.manager.monitor.dispatch("dragstart",{nativeEvent:r,operation:i.snapshot(),cancelable:!1})})})),n})}move(e){return Ds(()=>{var i,n;let{dragOperation:r}=this.manager,{status:s,controller:o}=r;if(!s.dragging||!o||o.signal.aborted)return;let a=ju({nativeEvent:e.event,operation:r.snapshot(),by:e.by,to:e.to},null==(i=e.cancelable)||i);(null==(n=e.propagate)||n)&&this.manager.monitor.dispatch("dragmove",a),queueMicrotask(()=>{var i,n,s,o,l;if(a.defaultPrevented)return;let c=null!=(l=e.to)?l:{x:r.position.current.x+(null!=(n=null==(i=e.by)?void 0:i.x)?n:0),y:r.position.current.y+(null!=(o=null==(s=e.by)?void 0:s.y)?o:0)};r.position.current=c})})}stop(e={}){return Ds(()=>{var i,n;let r,{dragOperation:s}=this.manager,{controller:o}=s;if(!o||o.signal.aborted)return;o.abort();let a=()=>{this.manager.renderer.rendering.then(()=>{s.status.set("dropped");let e=Ds(()=>{var e;return(null==(e=s.source)?void 0:e.status)==="dropping"}),i=()=>{s.controller===o&&(s.controller=void 0),s.reset()};if(e){let{source:e}=s,n=DI(()=>{(null==e?void 0:e.status)==="idle"&&(n(),i())})}else this.manager.renderer.rendering.then(i)})};s.canceled=null!=(i=e.canceled)&&i,this.manager.monitor.dispatch("dragend",{nativeEvent:e.event,operation:s.snapshot(),canceled:null!=(n=e.canceled)&&n,suspend:()=>{let e={resume:()=>{},abort:()=>{}};return r=new Promise((i,n)=>{e.resume=i,e.abort=n}),e}}),r?r.then(a).catch(()=>s.reset()):a()})}},jy=class extends L7{constructor(e,i){super(e,i),this.manager=e,this.options=i}},j_=class extends AbortController{constructor(e,i){for(const n of(super(),this.constraints=e,this.onActivate=i,this.activated=!1,null!=e?e:[]))n.controller=this}onEvent(e){var i;if(!this.activated)if(null==(i=this.constraints)?void 0:i.length)for(let i of this.constraints)i.onEvent(e);else this.activate(e)}activate(e){this.activated||(this.activated=!0,this.onActivate(e))}abort(e){this.activated=!1,super.abort(e)}},jb=class{constructor(e){this.options=e,L5(this,eJ)}set controller(e){L3(this,eJ,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var i;null==(i=L2(this,eJ))||i.activate(e)}};eJ=new WeakMap;var jx=class extends L7{constructor(e,i){super(e,i),this.manager=e,this.options=i}apply(e){return e.transform}},jw=class{constructor(e){this.draggables=new ja,this.droppables=new ja,this.plugins=new jt(e),this.sensors=new jt(e),this.modifiers=new jt(e)}register(e,i){if(e instanceof jl)return this.draggables.register(e.id,e);if(e instanceof jc)return this.droppables.register(e.id,e);if(e.prototype instanceof jx)return this.modifiers.register(e,i);if(e.prototype instanceof jy)return this.sensors.register(e,i);if(e.prototype instanceof L7)return this.plugins.register(e,i);throw Error("Invalid instance type")}unregister(e){if(e instanceof jo)return e instanceof jl?this.draggables.unregister(e.id,e):e instanceof jc?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof jx)return this.modifiers.unregister(e);if(e.prototype instanceof jy)return this.sensors.unregister(e);if(e.prototype instanceof L7)return this.plugins.unregister(e);throw Error("Invalid instance type")}destroy(){this.draggables.destroy(),this.droppables.destroy(),this.plugins.destroy(),this.sensors.destroy(),this.modifiers.destroy()}};e4=[D7],e3=[D9],e5=[D9],e2=[D9],e1=[D9],e0=[D9],eQ=[D7],eZ=[D7],eG=[D7];var jS=class{constructor(e){LZ(e7,5,this),L5(this,e6),L5(this,e8),L5(this,e9,new Li(void 0,(e,i)=>e&&i?e.equals(i):e===i)),this.status=new jg,L5(this,te,LZ(e7,8,this,!1)),LZ(e7,11,this),L5(this,tt,LZ(e7,12,this,null)),LZ(e7,15,this),L5(this,ti,LZ(e7,16,this,null)),LZ(e7,19,this),L5(this,tn,LZ(e7,20,this,null)),LZ(e7,23,this),L5(this,tr,LZ(e7,24,this,[])),LZ(e7,27,this),this.position=new LN({x:0,y:0}),L5(this,ts,{x:0,y:0}),L3(this,e6,e)}get shape(){let{current:e,initial:i,previous:n}=L2(this,e9);return e&&i?{current:e,initial:i,previous:n}:null}set shape(e){e?L2(this,e9).current=e:L2(this,e9).reset()}get source(){var e;let i=this.sourceIdentifier;if(null==i)return null;let n=L2(this,e6).registry.draggables.get(i);return n&&L3(this,e8,n),null!=(e=null!=n?n:L2(this,e8))?e:null}get target(){var e;let i=this.targetIdentifier;return null!=i&&null!=(e=L2(this,e6).registry.droppables.get(i))?e:null}get transform(){let{x:e,y:i}=this.position.delta,n={x:e,y:i};for(let e of this.modifiers)n=e.apply(LU(L$({},this.snapshot()),{transform:n}));return L3(this,ts,n),n}snapshot(){return Ds(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:L2(this,ts),shape:this.shape?Ln(this.shape):null,position:Ln(this.position),status:Ln(this.status),canceled:this.canceled}))}reset(){Dn(()=>{this.status.set("idle"),this.sourceIdentifier=null,this.targetIdentifier=null,L2(this,e9).reset(),this.position.reset({x:0,y:0}),L3(this,ts,{x:0,y:0}),this.modifiers=[]})}};e7=LY(null),e6=new WeakMap,e8=new WeakMap,e9=new WeakMap,te=new WeakMap,tt=new WeakMap,ti=new WeakMap,tn=new WeakMap,tr=new WeakMap,ts=new WeakMap,LQ(e7,2,"shape",e4,jS),LQ(e7,4,"canceled",e3,jS,te),LQ(e7,4,"activatorEvent",e5,jS,tt),LQ(e7,4,"sourceIdentifier",e2,jS,ti),LQ(e7,4,"targetIdentifier",e1,jS,tn),LQ(e7,4,"modifiers",e0,jS,tr),LQ(e7,2,"source",eQ,jS),LQ(e7,2,"target",eZ,jS),LQ(e7,2,"transform",eG,jS),LG(e7,jS);var jk={get rendering(){return Promise.resolve()}};function jC(e,i){return"function"==typeof e?e(i):null!=e?e:i}var jT=class{constructor(e){var i;this.destroy=()=>{this.dragOperation.status.idle||this.actions.stop({canceled:!0}),this.dragOperation.modifiers.forEach(e=>e.destroy()),this.registry.destroy(),this.collisionObserver.destroy()};const n=null!=e?e:{},r=jC(n.plugins,[]),s=jC(n.sensors,[]),o=jC(n.modifiers,[]),a=null!=(i=n.renderer)?i:jk,l=new jd(this),c=new jw(this);this.registry=c,this.monitor=l,this.renderer=a,this.actions=new jv(this),this.dragOperation=new jS(this),this.collisionObserver=new jr(this),this.plugins=[jp,...r],this.modifiers=o,this.sensors=s;const{destroy:h}=this,d=Lt(()=>{var e,i,n;let r=Ds(()=>this.dragOperation.modifiers),s=this.modifiers;for(let e of r)s.includes(e)||e.destroy();this.dragOperation.modifiers=null!=(n=null==(i=null==(e=this.dragOperation.source)?void 0:e.modifiers)?void 0:i.map(e=>{let{plugin:i,options:n}=L9(e);return new i(this,n)}))?n:s});this.destroy=()=>{d(),h()}}get plugins(){return this.registry.plugins.values}set plugins(e){this.registry.plugins.values=e}get modifiers(){return this.registry.modifiers.values}set modifiers(e){this.registry.modifiers.values=e}get sensors(){return this.registry.sensors.values}set sensors(e){this.registry.sensors.values=e}},jE=e=>{throw TypeError(e)},jN=(e,i,n)=>i.has(e)||jE("Cannot "+n),jM=(e,i,n)=>(jN(e,i,"read from private field"),i.get(e)),jO=(e,i,n)=>i.has(e)?jE("Cannot add the same private member more than once"):i instanceof WeakSet?i.add(e):i.set(e,n),jA=(e,i,n,r)=>(jN(e,i,"write to private field"),i.set(e,n),n),jR=(e,i,n)=>(jN(e,i,"access private method"),n);function jD(e){return!!e&&(e instanceof KeyframeEffect||"getKeyframes"in e&&"function"==typeof e.getKeyframes)}function jL(e,i){let n=e.getAnimations(),r=null;for(let e of n){if("running"!==e.playState)continue;let{effect:n}=e,s=(jD(n)?n.getKeyframes():[]).filter(i);s.length>0&&(r=[s[s.length-1],e])}return r}function jj(e){let{width:i,height:n,top:r,left:s,bottom:o,right:a}=e.getBoundingClientRect();return{width:i,height:n,top:r,left:s,bottom:o,right:a}}function jI(e){let i=Object.prototype.toString.call(e);return"[object Window]"===i||"[object global]"===i}function jP(e){return"nodeType"in e}function jB(e){var i,n,r;return e?jI(e)?e:jP(e)?"defaultView"in e?null!=(i=e.defaultView)?i:window:null!=(r=null==(n=e.ownerDocument)?void 0:n.defaultView)?r:window:window:window}function jz(e){let{Document:i}=jB(e);return e instanceof i||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function jF(e){return!(!e||jI(e))&&(e instanceof jB(e).HTMLElement||"namespaceURI"in e&&"string"==typeof e.namespaceURI&&e.namespaceURI.endsWith("html"))}function jW(e){return e instanceof jB(e).SVGElement||"namespaceURI"in e&&"string"==typeof e.namespaceURI&&e.namespaceURI.endsWith("svg")}function jH(e){return e?jI(e)?e.document:jP(e)?jz(e)?e:jF(e)||jW(e)?e.ownerDocument:document:document:document}function j$(e,i=e.getBoundingClientRect(),n=0){var r,s,o,a,l;let c=i,{ownerDocument:h}=e,d=null!=(r=h.defaultView)?r:window,u=e.parentElement;for(;u&&u!==h.documentElement;){if(!function(e){if("DETAILS"===e.tagName&&!1===e.open)return!1;let{overflow:i,overflowX:n,overflowY:r}=getComputedStyle(e);return"visible"===i&&"visible"===n&&"visible"===r}(u)){let e=u.getBoundingClientRect(),i=n*(e.bottom-e.top),r=n*(e.right-e.left),s=n*(e.bottom-e.top),o=n*(e.right-e.left);(c={top:Math.max(c.top,e.top-i),right:Math.min(c.right,e.right+r),bottom:Math.min(c.bottom,e.bottom+s),left:Math.max(c.left,e.left-o),width:0,height:0}).width=c.right-c.left,c.height=c.bottom-c.top}u=u.parentElement}let p=d.visualViewport,f=null!=(s=null==p?void 0:p.offsetTop)?s:0,m=null!=(o=null==p?void 0:p.offsetLeft)?o:0,g=null!=(a=null==p?void 0:p.width)?a:d.innerWidth,v=null!=(l=null==p?void 0:p.height)?l:d.innerHeight,y=n*v,_=n*g;return(c={top:Math.max(c.top,f-y),right:Math.min(c.right,m+g+_),bottom:Math.min(c.bottom,f+v+y),left:Math.max(c.left,m-_),width:0,height:0}).width=c.right-c.left,c.height=c.bottom-c.top,c.width<0&&(c.width=0),c.height<0&&(c.height=0),c}function jU(e){return{x:e.clientX,y:e.clientY}}var jV="u">typeof window&&void 0!==window.document&&void 0!==window.document.createElement;function jq(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function jY(){var e,i;let n=jq()?window.visualViewport:null;return{x:null!=(e=null==n?void 0:n.offsetLeft)?e:0,y:null!=(i=null==n?void 0:n.offsetTop)?i:0}}function jK(e){return!!e&&!!jP(e)&&e instanceof jB(e).ShadowRoot}function jX(e){if(e&&jP(e)){let i=e.getRootNode();if(jK(i)||i instanceof Document)return i}return jH(e)}function jJ(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function jG(e){return"value"in e}function jZ(e){return"CANVAS"===e.tagName}var jQ=new WeakMap,j0=class{constructor(){this.entries=new Set,this.clear=()=>{for(let e of this.entries){let[i,{type:n,listener:r,options:s}]=e;i.removeEventListener(n,r,s)}this.entries.clear()}}bind(e,i){let n=Array.isArray(e)?e:[e],r=Array.isArray(i)?i:[i],s=[];for(let e of n)for(let i of r){let{type:n,listener:r,options:o}=i,a=[e,i];e.addEventListener(n,r,o),this.entries.add(a),s.push(a)}let o=this.entries;return function(){for(let e of s){let[i,{type:n,listener:r,options:s}]=e;i.removeEventListener(n,r,s),o.delete(e)}}}};function j1(e){let i=null==e?void 0:e.ownerDocument.defaultView;if(i&&i.self!==i.parent)return i.frameElement}function j2(e,i){let n,r;return function(...s){let o=this;if(r){let a;null==n||n(),a=setTimeout(()=>{e.apply(o,s),r=performance.now()},i-(performance.now()-r)),n=()=>clearTimeout(a)}else e.apply(o,s),r=performance.now()}}var j5=jV?ResizeObserver:class{observe(){}unobserve(){}disconnect(){}},j3=class extends j5{constructor(e){super(i=>{jM(this,to)?e(i,this):jA(this,to,!0)}),jO(this,to,!1)}};to=new WeakMap;var j4=Array.from({length:100},(e,i)=>i/100),j6=class{constructor(e,i,n={debug:!1,skipInitial:!1}){this.element=e,this.callback=i,jO(this,tm),this.disconnect=()=>{var e,i,n;jA(this,tp,!0),null==(e=jM(this,tc))||e.disconnect(),null==(i=jM(this,th))||i.disconnect(),jM(this,td).disconnect(),null==(n=jM(this,tu))||n.remove()},jO(this,ta,!0),jO(this,tl),jO(this,tc),jO(this,th),jO(this,td),jO(this,tu),jO(this,tp,!1),jO(this,tf,j2(()=>{var e,i,n;let{element:r}=this;if(null==(e=jM(this,th))||e.disconnect(),jM(this,tp)||!jM(this,ta)||!r.isConnected)return;let s=null!=(i=r.ownerDocument)?i:document,{innerHeight:o,innerWidth:a}=null!=(n=s.defaultView)?n:window,l=r.getBoundingClientRect(),{top:c,left:h,bottom:d,right:u}=j$(r,l),p=-Math.floor(c),f=-Math.floor(h),m=-Math.floor(a-u),g=-Math.floor(o-d),v=`${p}px ${m}px ${g}px ${f}px`;this.boundingClientRect=l,jA(this,th,new IntersectionObserver(e=>{let[i]=e,{intersectionRect:n}=i;1!==(1!==i.intersectionRatio?i.intersectionRatio:LE.intersectionRatio(n,j$(r)))&&jM(this,tf).call(this)},{threshold:j4,rootMargin:v,root:s})),jM(this,th).observe(r),jR(this,tm,tg).call(this)},75)),this.boundingClientRect=e.getBoundingClientRect(),jA(this,ta,function(e,i=e.getBoundingClientRect()){let{width:n,height:r}=j$(e,i);return n>0&&r>0}(e,this.boundingClientRect));let r=!0;this.callback=e=>{r&&(r=!1,n.skipInitial)||i(e)};const s=e.ownerDocument;(null==n?void 0:n.debug)&&(jA(this,tu,document.createElement("div")),jM(this,tu).style.background="rgba(0,0,0,0.15)",jM(this,tu).style.position="fixed",jM(this,tu).style.pointerEvents="none",s.body.appendChild(jM(this,tu))),jA(this,td,new IntersectionObserver(i=>{var n,r;let{boundingClientRect:s,isIntersecting:o}=i[i.length-1],{width:a,height:l}=s,c=jM(this,ta);jA(this,ta,o),(a||l)&&(c&&!o?(null==(n=jM(this,th))||n.disconnect(),this.callback(null),null==(r=jM(this,tc))||r.disconnect(),jA(this,tc,void 0),jM(this,tu)&&(jM(this,tu).style.visibility="hidden")):jM(this,tf).call(this),o&&!jM(this,tc)&&(jA(this,tc,new j3(jM(this,tf))),jM(this,tc).observe(e)))},{threshold:j4,root:s})),jM(this,ta)&&!n.skipInitial&&this.callback(this.boundingClientRect),jM(this,td).observe(e)}};ta=new WeakMap,tl=new WeakMap,tc=new WeakMap,th=new WeakMap,td=new WeakMap,tu=new WeakMap,tp=new WeakMap,tf=new WeakMap,tm=new WeakSet,tg=function(){var e,i;!jM(this,tp)&&(jR(this,tm,tv).call(this),(e=this.boundingClientRect)===(i=jM(this,tl))||e&&i&&e.top==i.top&&e.left==i.left&&e.right==i.right&&e.bottom==i.bottom||(this.callback(this.boundingClientRect),jA(this,tl,this.boundingClientRect)))},tv=function(){if(jM(this,tu)){let{top:e,left:i,width:n,height:r}=j$(this.element);jM(this,tu).style.overflow="hidden",jM(this,tu).style.visibility="visible",jM(this,tu).style.top=`${Math.floor(e)}px`,jM(this,tu).style.left=`${Math.floor(i)}px`,jM(this,tu).style.width=`${Math.floor(n)}px`,jM(this,tu).style.height=`${Math.floor(r)}px`}};var j8=new WeakMap,j9=new WeakMap,j7=class{constructor(e,i,n){this.callback=i,jO(this,ty),jO(this,t_,!1),jO(this,tb),jO(this,tx,j2(e=>{if(!jM(this,t_)&&e.target&&"contains"in e.target&&"function"==typeof e.target.contains){for(let i of jM(this,tb))if(e.target.contains(i)){this.callback(jM(this,ty).boundingClientRect);break}}},75));const r=function(e){let i=new Set,n=j1(e);for(;n;)i.add(n),n=j1(n);return i}(e),s=function(e,i){let n=new Set;for(let r of e){let e=function(e,i){let n=j8.get(e);return n||(n={disconnect:new j6(e,i=>{let n=j8.get(e);n&&n.callbacks.forEach(e=>e(i))},{skipInitial:!0}).disconnect,callbacks:new Set}),n.callbacks.add(i),j8.set(e,n),()=>{n.callbacks.delete(i),0===n.callbacks.size&&(j8.delete(e),n.disconnect())}}(r,i);n.add(e)}return()=>n.forEach(e=>e())}(r,i),o=function(e,i){var n;let r=e.ownerDocument;if(!j9.has(r)){let e=new AbortController,i=new Set;document.addEventListener("scroll",e=>i.forEach(i=>i(e)),{capture:!0,passive:!0,signal:e.signal}),j9.set(r,{disconnect:()=>e.abort(),listeners:i})}let{listeners:s,disconnect:o}=null!=(n=j9.get(r))?n:{};return s&&o?(s.add(i),()=>{s.delete(i),0===s.size&&(o(),j9.delete(r))}):()=>{}}(e,jM(this,tx));jA(this,tb,r),jA(this,ty,new j6(e,i,n)),this.disconnect=()=>{jM(this,t_)||(jA(this,t_,!0),s(),o(),jM(this,ty).disconnect())}}};function Ie(e){return"showPopover"in e&&"hidePopover"in e&&"function"==typeof e.showPopover&&"function"==typeof e.hidePopover}function It(e){try{Ie(e)&&e.isConnected&&e.hasAttribute("popover")&&!e.matches(":popover-open")&&e.showPopover()}catch(e){}}function Ii(e){return!!jV&&!!e&&e===jH(e).scrollingElement}function In(e){var i,n;let r=jB(e),s=Ii(e)?function(e){var i,n,r,s;let{documentElement:o}=jH(e),a=jB(e).visualViewport,l=null!=(i=null==a?void 0:a.width)?i:o.clientWidth,c=null!=(n=null==a?void 0:a.height)?n:o.clientHeight,h=null!=(r=null==a?void 0:a.offsetTop)?r:0,d=null!=(s=null==a?void 0:a.offsetLeft)?s:0;return{top:h,left:d,right:d+l,bottom:h+c,width:l,height:c}}(e):jj(e),o=r.visualViewport,a=Ii(e)?{height:null!=(i=null==o?void 0:o.height)?i:r.innerHeight,width:null!=(n=null==o?void 0:o.width)?n:r.innerWidth}:{height:e.clientHeight,width:e.clientWidth},l={current:{x:e.scrollLeft,y:e.scrollTop},max:{x:e.scrollWidth-a.width,y:e.scrollHeight-a.height}},c=l.current.y<=0,h=l.current.x<=0,d=l.current.y>=l.max.y,u=l.current.x>=l.max.x;return{rect:s,position:l,isTop:c,isLeft:h,isBottom:d,isRight:u}}ty=new WeakMap,t_=new WeakMap,tb=new WeakMap,tx=new WeakMap;var Ir=class{constructor(e){this.scheduler=e,this.pending=!1,this.tasks=new Set,this.resolvers=new Set,this.flush=()=>{let{tasks:e,resolvers:i}=this;for(let i of(this.pending=!1,this.tasks=new Set,this.resolvers=new Set,e))i();for(let e of i)e()}}schedule(e){return this.tasks.add(e),this.pending||(this.pending=!0,this.scheduler(this.flush)),new Promise(e=>this.resolvers.add(e))}},Is=new Ir(e=>{"function"==typeof requestAnimationFrame?requestAnimationFrame(e):e()}),Io=new Ir(e=>setTimeout(e,50)),Ia=new Map,Il=Ia.clear.bind(Ia);function Ic(e,i=!1){if(!i)return Ih(e);let n=Ia.get(e);return n||(n=Ih(e),Ia.set(e,n),Io.schedule(Il)),n}function Ih(e){return jB(e).getComputedStyle(e)}var Id={excludeElement:!0,escapeShadowDOM:!0};function Iu(e,i=Id){let{limit:n,excludeElement:r,escapeShadowDOM:s}=i,o=new Set;return e?function i(a){if(null!=n&&o.size>=n||!a)return o;if(jz(a)&&null!=a.scrollingElement&&!o.has(a.scrollingElement))return o.add(a.scrollingElement),o;if(s&&jK(a))return i(a.host);if(!jF(a))return jW(a)?i(a.parentElement):o;if(o.has(a))return o;let l=Ic(a,!0);if(r&&a===e||function(e,i=Ic(e,!0)){let n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(e=>{let r=i[e];return"string"==typeof r&&n.test(r)})}(a,l)&&o.add(a),function(e,i=Ic(e,!0)){return"fixed"===i.position||"sticky"===i.position}(a,l)){let{scrollingElement:e}=a.ownerDocument;return e&&o.add(e),o}return i(a.parentNode)}(e):o}function Ip(e,i=window.frameElement){let n={x:0,y:0,scaleX:1,scaleY:1};if(!e)return n;let r=j1(e);for(;r&&r!==i;){let e=jj(r),{x:i,y:s}=function(e,i=jj(e)){let n=Math.round(i.width),r=Math.round(i.height);if(jF(e))return{x:n/e.offsetWidth,y:r/e.offsetHeight};let s=Ic(e,!0);return{x:(parseFloat(s.width)||n)/n,y:(parseFloat(s.height)||r)/r}}(r,e);n.x=n.x+e.left,n.y=n.y+e.top,n.scaleX=n.scaleX*i,n.scaleY=n.scaleY*s,r=j1(r)}return n}function If(e){if("none"===e)return null;let[i,n,r="0"]=e.split(" "),s={x:parseFloat(i),y:parseFloat(n),z:parseInt(r,10)};return isNaN(s.x)&&isNaN(s.y)?null:{x:isNaN(s.x)?0:s.x,y:isNaN(s.y)?0:s.y,z:isNaN(s.z)?0:s.z}}function Im(e){var i,n,r,s,o,a,l,c,h;let{scale:d,transform:u,translate:p}=e,f=function(e){if("none"===e)return null;let i=e.split(" "),n=parseFloat(i[0]),r=parseFloat(i[1]);return isNaN(n)&&isNaN(r)?null:{x:isNaN(n)?r:n,y:isNaN(r)?n:r}}(d),m=If(p),g=function(e){if(e.startsWith("matrix3d(")){let i=e.slice(9,-1).split(/, /);return{x:+i[12],y:+i[13],scaleX:+i[0],scaleY:+i[5]}}if(e.startsWith("matrix(")){let i=e.slice(7,-1).split(/, /);return{x:+i[4],y:+i[5],scaleX:+i[0],scaleY:+i[3]}}return null}(u);if(!g&&!f&&!m)return null;let v={x:null!=(i=null==f?void 0:f.x)?i:1,y:null!=(n=null==f?void 0:f.y)?n:1},y={x:null!=(r=null==m?void 0:m.x)?r:0,y:null!=(s=null==m?void 0:m.y)?s:0},_={x:null!=(o=null==g?void 0:g.x)?o:0,y:null!=(a=null==g?void 0:g.y)?a:0,scaleX:null!=(l=null==g?void 0:g.scaleX)?l:1,scaleY:null!=(c=null==g?void 0:g.scaleY)?c:1};return{x:y.x+_.x,y:y.y+_.y,z:null!=(h=null==m?void 0:m.z)?h:0,scaleX:v.x*_.scaleX,scaleY:v.y*_.scaleY}}var Ig=((S=Ig||{})[S.Idle=0]="Idle",S[S.Forward=1]="Forward",S[S.Reverse=-1]="Reverse",S),Iv={x:.2,y:.2},Iy={x:10,y:10};function I_(e,{block:i="nearest",inline:n="nearest"}={}){if(!jF(e))return;let r=Iu(e),s=[];for(let o of r){if(!jF(o))continue;let{top:r,left:a}=function(e,i){let n=Ib(e),r=Ib(i);return{top:n.top-r.top-i.clientTop,left:n.left-r.left-i.clientLeft}}(e,o),l=r,c=a;for(let e of s)l-=e.scrollTop,c-=e.scrollLeft;if("none"!==i){let n=l<o.scrollTop;n!==l+e.offsetHeight>o.scrollTop+o.clientHeight&&("center"===i?o.scrollTop=l-o.clientHeight/2+e.offsetHeight/2:n?o.scrollTop=l:o.scrollTop=l+e.offsetHeight-o.clientHeight)}if("none"!==n){let i=c<o.scrollLeft;i!==c+e.offsetWidth>o.scrollLeft+o.clientWidth&&("center"===n?o.scrollLeft=c-o.clientWidth/2+e.offsetWidth/2:i?o.scrollLeft=c:o.scrollLeft=c+e.offsetWidth-o.clientWidth)}s.push(o)}}function Ib(e){let i=0,n=0,r=e;for(;r;){i+=r.offsetTop,n+=r.offsetLeft;let e=r.offsetParent;if(!jF(e))break;i+=e.clientTop,n+=e.clientLeft,r=e}return{top:i,left:n}}function Ix({element:e,keyframes:i,options:n}){return e.animate(i,n).finished}function Iw(e,i=Ic(e).translate,n=!0){if(n){let i=jL(e,e=>"translate"in e);if(i){let{translate:e=""}=i[0];if("string"==typeof e){let i=If(e);if(i)return i}}}if(i){let e=If(i);if(e)return e}return{x:0,y:0,z:0}}var IS=new Ir(e=>setTimeout(e,0)),Ik=new Map,IC=Ik.clear.bind(Ik),IT=class extends LE{constructor(e,i={}){var n,r,s,o;let a;const{frameTransform:l=Ip(e),ignoreTransforms:c,getBoundingClientRect:h=jj}=i,d=function(e,i){let n=(function(e){let i=e.ownerDocument,n=Ik.get(i);if(n)return n;n=i.getAnimations(),Ik.set(i,n),IS.schedule(IC);let r=n.filter(i=>jD(i.effect)&&i.effect.target===e);return Ik.set(e,r),n})(e).filter(e=>{var n,r;if(jD(e.effect)){let{target:s}=e.effect;if(null==(r=s&&(null==(n=i.isValidTarget)?void 0:n.call(i,s)))||r)return e.effect.getKeyframes().some(e=>{for(let n of i.properties)if(e[n])return!0})}}).map(e=>{let{effect:i,currentTime:n}=e,r=null==i?void 0:i.getComputedTiming().duration;if(!e.pending&&"finished"!==e.playState&&"number"==typeof r&&"number"==typeof n&&n<r)return e.currentTime=r,()=>{e.currentTime=n}});if(n.length>0)return()=>n.forEach(e=>null==e?void 0:e())}(e,{properties:["transform","translate","scale","width","height"],isValidTarget:i=>(i!==e||jq())&&i.contains(e)}),u=h(e);let{top:p,left:f,width:m,height:g}=u;const v=Ic(e),y=Im(v),_={x:null!=(n=null==y?void 0:y.scaleX)?n:1,y:null!=(r=null==y?void 0:y.scaleY)?r:1},b=function(e,i){let n,r,s,o=e.getAnimations();if(!o.length)return null;let a=!1;for(let e of o){if("running"!==e.playState)continue;let i=jD(e.effect)?e.effect.getKeyframes():[],o=i[i.length-1];if(!o)continue;let{transform:l,translate:c,scale:h}=o;"string"==typeof l&&l&&(n=l,a=!0),"string"==typeof c&&c&&(r=c,a=!0),"string"==typeof h&&h&&(s=h,a=!0)}return a?Im({transform:null!=n?n:i.transform,translate:null!=r?r:i.translate,scale:null!=s?s:i.scale}):null}(e,v);null==d||d(),y&&(a=function(e,i,n){let{scaleX:r,scaleY:s,x:o,y:a}=i,l=e.left-o-(1-r)*parseFloat(n),c=e.top-a-(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),h=r?e.width/r:e.width,d=s?e.height/s:e.height;return{width:h,height:d,top:c,right:l+h,bottom:c+d,left:l}}(u,y,v.transformOrigin),(c||b)&&(p=a.top,f=a.left,m=a.width,g=a.height));const w={width:null!=(s=null==a?void 0:a.width)?s:m,height:null!=(o=null==a?void 0:a.height)?o:g};if(b&&!c&&a){const e=function(e,i,n){let{scaleX:r,scaleY:s,x:o,y:a}=i,l=e.left+o+(1-r)*parseFloat(n),c=e.top+a+(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),h=r?e.width*r:e.width,d=s?e.height*s:e.height;return{width:h,height:d,top:c,right:l+h,bottom:c+d,left:l}}(a,b,v.transformOrigin);p=e.top,f=e.left,m=e.width,g=e.height,_.x=b.scaleX,_.y=b.scaleY}l&&(c||(f*=l.scaleX,m*=l.scaleX,p*=l.scaleY,g*=l.scaleY),f+=l.x,p+=l.y),super(f,p,m,g),this.scale=_,this.intrinsicWidth=w.width,this.intrinsicHeight=w.height}};function IE(e){return"style"in e&&"object"==typeof e.style&&null!==e.style&&"setProperty"in e.style&&"removeProperty"in e.style&&"function"==typeof e.style.setProperty&&"function"==typeof e.style.removeProperty}var IN=class{constructor(e){this.element=e,this.initial=new Map}set(e,i=""){let{element:n}=this;if(IE(n))for(let[r,s]of Object.entries(e)){let e=`${i}${r}`;this.initial.has(e)||this.initial.set(e,n.style.getPropertyValue(e)),n.style.setProperty(e,"string"==typeof s?s:`${s}px`)}}remove(e,i=""){let{element:n}=this;if(IE(n))for(let r of e){let e=`${i}${r}`;n.style.removeProperty(e)}}reset(){let{element:e}=this;if(IE(e)){for(let[i,n]of this.initial)e.style.setProperty(i,n);""===e.getAttribute("style")&&e.removeAttribute("style")}}};function IM(e){return!!e&&(e instanceof jB(e).Element||jP(e)&&e.nodeType===Node.ELEMENT_NODE)}function IO(e){if(!e)return!1;let{KeyboardEvent:i}=jB(e.target);return e instanceof i}var IA={};function IR(e){let i=null==IA[e]?0:IA[e]+1;return IA[e]=i,`${e}-${i}`}var ID=e=>{var i;return null!=(i=(({dragOperation:e,droppable:i})=>{let n=e.position.current;if(!n)return null;let{id:r}=i;return i.shape&&i.shape.containsPoint(n)?{id:r,value:1/LT.distance(i.shape.center,n),type:jm.PointerIntersection,priority:jf.High}:null})(e))?i:(({dragOperation:e,droppable:i})=>{let{shape:n}=e;if(!i.shape||!(null==n?void 0:n.current))return null;let r=n.current.intersectionArea(i.shape);if(r){let{position:s}=e,o=LT.distance(i.shape.center,s.current),a=r/(n.current.area+i.shape.area-r);return{id:i.id,value:a/o,type:jm.ShapeIntersection,priority:jf.Normal}}return null})(e)},IL=e=>{let{dragOperation:i,droppable:n}=e,{shape:r,position:s}=i;if(!n.shape)return null;let o=r?LE.from(r.current.boundingRectangle).corners:void 0,a=LE.from(n.shape.boundingRectangle).corners.reduce((e,i,n)=>{var r;return e+LT.distance(LT.from(i),null!=(r=null==o?void 0:o[n])?r:s.current)},0);return{id:n.id,value:1/(a/4),type:jm.Collision,priority:jf.Normal}},Ij=Object.create,II=Object.defineProperty,IP=Object.defineProperties,IB=Object.getOwnPropertyDescriptor,Iz=Object.getOwnPropertyDescriptors,IF=Object.getOwnPropertySymbols,IW=Object.prototype.hasOwnProperty,IH=Object.prototype.propertyIsEnumerable,I$=(e,i)=>(i=Symbol[e])?i:Symbol.for("Symbol."+e),IU=e=>{throw TypeError(e)},IV=(e,i,n)=>i in e?II(e,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[i]=n,Iq=(e,i)=>{for(var n in i||(i={}))IW.call(i,n)&&IV(e,n,i[n]);if(IF)for(var n of IF(i))IH.call(i,n)&&IV(e,n,i[n]);return e},IY=(e,i)=>II(e,"name",{value:i,configurable:!0}),IK=(e,i)=>{var n={};for(var r in e)IW.call(e,r)&&0>i.indexOf(r)&&(n[r]=e[r]);if(null!=e&&IF)for(var r of IF(e))0>i.indexOf(r)&&IH.call(e,r)&&(n[r]=e[r]);return n},IX=e=>{var i;return[,,,Ij(null!=(i=null==e?void 0:e[I$("metadata")])?i:null)]},IJ=["class","method","getter","setter","accessor","field","value","get","set"],IG=e=>void 0!==e&&"function"!=typeof e?IU("Function expected"):e,IZ=(e,i,n,r,s)=>({kind:IJ[e],name:i,metadata:r,addInitializer:e=>n._?IU("Already initialized"):s.push(IG(e||null))}),IQ=(e,i)=>IV(i,I$("metadata"),e[3]),I0=(e,i,n,r)=>{for(var s=0,o=e[i>>1],a=o&&o.length;s<a;s++)1&i?o[s].call(n):r=o[s].call(n,r);return r},I1=(e,i,n,r,s,o)=>{var a,l,c,h,d,u=7&i,p=!!(8&i),f=!!(16&i),m=u>3?e.length+1:u?p?1:2:0,g=IJ[u+5],v=u>3&&(e[m-1]=[]),y=e[m]||(e[m]=[]),_=u&&(f||p||(s=s.prototype),u<5&&(u>3||!f)&&IB(u<4?s:{get[n](){return I3(this,o)},set[n](x){return I6(this,o,x)}},n));u?f&&u<4&&IY(o,(u>2?"set ":u>1?"get ":"")+n):IY(s,n);for(var b=r.length-1;b>=0;b--)h=IZ(u,n,c={},e[3],y),u&&(h.static=p,h.private=f,d=h.access={has:f?e=>I5(s,e):e=>n in e},3^u&&(d.get=f?e=>(1^u?I3:I8)(e,s,4^u?o:_.get):e=>e[n]),u>2&&(d.set=f?(e,i)=>I6(e,s,i,4^u?o:_.set):(e,i)=>e[n]=i)),l=(0,r[b])(u?u<4?f?o:_[g]:u>4?void 0:{get:_.get,set:_.set}:s,h),c._=1,4^u||void 0===l?IG(l)&&(u>4?v.unshift(l):u?f?o=l:_[g]=l:s=l):"object"!=typeof l||null===l?IU("Object expected"):(IG(a=l.get)&&(_.get=a),IG(a=l.set)&&(_.set=a),IG(a=l.init)&&v.unshift(a));return u||IQ(e,s),_&&II(s,n,_),f?4^u?o:_:s},I2=(e,i,n)=>i.has(e)||IU("Cannot "+n),I5=(e,i)=>Object(i)!==i?IU('Cannot use the "in" operator on this value'):e.has(i),I3=(e,i,n)=>(I2(e,i,"read from private field"),n?n.call(e):i.get(e)),I4=(e,i,n)=>i.has(e)?IU("Cannot add the same private member more than once"):i instanceof WeakSet?i.add(e):i.set(e,n),I6=(e,i,n,r)=>(I2(e,i,"write to private field"),r?r.call(e,n):i.set(e,n),n),I8=(e,i,n)=>(I2(e,i,"access private method"),n),I9={draggable:"To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item in a given direction. Press space again to drop the item in its new position, or press escape to cancel."},I7={dragstart({operation:{source:e}}){if(e)return`Picked up draggable item ${e.id}.`},dragover({operation:{source:e,target:i}}){if(e&&e.id!==(null==i?void 0:i.id))return i?`Draggable item ${e.id} was moved over droppable target ${i.id}.`:`Draggable item ${e.id} is no longer over a droppable target.`},dragend({operation:{source:e,target:i},canceled:n}){if(e)return n?`Dragging was cancelled. Draggable item ${e.id} was dropped.`:i?`Draggable item ${e.id} was dropped over droppable target ${i.id}`:`Draggable item ${e.id} was dropped.`}},Pe=["dragover","dragmove"],Pt=class extends L7{constructor(e,i){let n,r,s,o;super(e);const{id:a,idPrefix:{description:l="dnd-kit-description",announcement:c="dnd-kit-announcement"}={},announcements:h=I7,screenReaderInstructions:d=I9,debounce:u=500}=null!=i?i:{},p=a?`${l}-${a}`:IR(l),f=a?`${c}-${a}`:IR(c),m=(e=o)=>{s&&e&&(null==s?void 0:s.nodeValue)!==e&&(s.nodeValue=e)},g=()=>Is.schedule(m),v=function(e,i){let n,r=()=>{clearTimeout(n),n=setTimeout(e,i)};return r.cancel=()=>clearTimeout(n),r}(g,u),y=Object.entries(h).map(([e,i])=>this.manager.monitor.addEventListener(e,(n,r)=>{let a=s;if(!a)return;let l=null==i?void 0:i(n,r);l&&a.nodeValue!==l&&(o=l,Pe.includes(e)?v():(g(),v.cancel()))})),_=()=>{var e;let i=[];if(!(null==n?void 0:n.isConnected)){let r;e=d.draggable,(r=document.createElement("div")).id=p,r.style.setProperty("display","none"),r.textContent=e,n=r,i.push(n)}if(!(null==r?void 0:r.isConnected)){let e;(e=document.createElement("div")).id=f,e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),e.style.setProperty("position","fixed"),e.style.setProperty("width","1px"),e.style.setProperty("height","1px"),e.style.setProperty("margin","-1px"),e.style.setProperty("border","0"),e.style.setProperty("padding","0"),e.style.setProperty("overflow","hidden"),e.style.setProperty("clip","rect(0 0 0 0)"),e.style.setProperty("clip-path","inset(100%)"),e.style.setProperty("white-space","nowrap"),r=e,s=document.createTextNode(""),r.appendChild(s),i.push(r)}i.length>0&&document.body.append(...i)},b=new Set;function w(){for(let e of b)e()}this.registerEffect(()=>{var e;for(let i of(b.clear(),this.manager.registry.draggables.value)){let s=null!=(e=i.handle)?e:i.element;if(s){for(let e of(n&&r||b.add(_),(!["input","select","textarea","a","button"].includes(s.tagName.toLowerCase())||jq())&&!s.hasAttribute("tabindex")&&b.add(()=>s.setAttribute("tabindex","0")),s.hasAttribute("role")||"button"===s.tagName.toLowerCase()||b.add(()=>s.setAttribute("role","button")),s.hasAttribute("aria-roledescription")||b.add(()=>s.setAttribute("aria-roledescription","draggable")),s.hasAttribute("aria-describedby")||b.add(()=>s.setAttribute("aria-describedby",p)),["aria-pressed","aria-grabbed"])){let n=String(i.isDragging);s.getAttribute(e)!==n&&b.add(()=>s.setAttribute(e,n))}let e=String(i.disabled);s.getAttribute("aria-disabled")!==e&&b.add(()=>s.setAttribute("aria-disabled",e))}}b.size>0&&Is.schedule(w)}),this.destroy=()=>{super.destroy(),null==n||n.remove(),null==r||r.remove(),y.forEach(e=>e())}}},Pi=new Map,Pn=class extends(tT=je,tC=[D9],tk=[D7],tS=[D7],tw=[D7],tT){constructor(e,i){super(e,i),I0(tN,5,this),I4(this,tO),I4(this,tE,new Set),I4(this,tM,I0(tN,8,this,new Set)),I0(tN,11,this),this.registerEffect(I8(this,tO,tA))}register(e){return I3(this,tE).add(e),()=>{I3(this,tE).delete(e)}}addRoot(e){return Ds(()=>{let i=new Set(this.additionalRoots);i.add(e),this.additionalRoots=i}),()=>{Ds(()=>{let i=new Set(this.additionalRoots);i.delete(e),this.additionalRoots=i})}}get sourceRoot(){var e;let{source:i}=this.manager.dragOperation;return jX(null!=(e=null==i?void 0:i.element)?e:null)}get targetRoot(){var e;let{target:i}=this.manager.dragOperation;return jX(null!=(e=null==i?void 0:i.element)?e:null)}get roots(){let{status:e}=this.manager.dragOperation;return e.initializing||e.initialized?new Set([...[this.sourceRoot,this.targetRoot].filter(e=>null!=e),...this.additionalRoots]):new Set}};tN=IX(tT),tE=new WeakMap,tM=new WeakMap,tO=new WeakSet,tA=function(){let{roots:e}=this,i=[];for(let n of e)for(let e of I3(this,tE))i.push(I8(this,tO,tR).call(this,n,e));return()=>{for(let e of i)e()}},tR=function(e,i){let n=Pi.get(e);n||(n=new Map,Pi.set(e,n));let r=n.get(i);if(!r){let s=jz(e)?I8(this,tO,tD).call(this,e,n,i):I8(this,tO,tL).call(this,e,n,i);if(!s)return()=>{};r=s,n.set(i,r)}r.refCount++;let s=!1;return()=>{s||(s=!0,r.refCount--,0===r.refCount&&r.cleanup())}},tD=function(e,i,n){var r;let s=e.createElement("style"),{nonce:o}=null!=(r=this.options)?r:{};o&&s.setAttribute("nonce",o),s.textContent=n,e.head.prepend(s);let a=new MutationObserver(i=>{for(let n of i)for(let i of Array.from(n.removedNodes))if(i===s)return void e.head.prepend(s)});return a.observe(e.head,{childList:!0}),{refCount:0,cleanup:()=>{a.disconnect(),s.remove(),i.delete(n),0===i.size&&Pi.delete(e)}}},tL=function(e,i,n){"adoptedStyleSheets"in e&&Array.isArray(e.adoptedStyleSheets);let r=e.ownerDocument.defaultView,{CSSStyleSheet:s}=null!=r?r:{};if(!s)return null;let o=new s;return o.replaceSync(n),e.adoptedStyleSheets.push(o),{refCount:0,cleanup:()=>{var r;if(jK(e)&&(null==(r=e.host)?void 0:r.isConnected)){let i=e.adoptedStyleSheets.indexOf(o);-1!==i&&e.adoptedStyleSheets.splice(i,1)}i.delete(n),0===i.size&&Pi.delete(e)}}},I1(tN,4,"additionalRoots",tC,Pn,tM),I1(tN,2,"sourceRoot",tk,Pn),I1(tN,2,"targetRoot",tS,Pn),I1(tN,2,"roots",tw,Pn),IQ(tN,Pn),Pn.configure=L8(Pn);var Pr=class extends L7{constructor(e,i){super(e,i),this.manager=e;const{cursor:n="grabbing"}=null!=i?i:{},r=e.registry.plugins.get(Pn),s=null==r?void 0:r.register(`* { cursor: ${n} !important; }`);if(s){const e=this.destroy.bind(this);this.destroy=()=>{s(),e()}}}},Ps="data-dnd-",Po=`${Ps}dropping`,Pa="--dnd-",Pl=`${Ps}dragging`,Pc=`${Ps}placeholder`,Ph=[Pl,Pc,"popover","aria-pressed","aria-grabbing"],Pd=["view-transition-name"],Pu=`
|
|
114
|
+
:is(:root,:host) [${Pl}] {
|
|
115
|
+
position: fixed !important;
|
|
116
|
+
pointer-events: none !important;
|
|
117
|
+
touch-action: none;
|
|
118
|
+
z-index: calc(infinity);
|
|
119
|
+
will-change: translate;
|
|
120
|
+
top: var(${Pa}top, 0px) !important;
|
|
121
|
+
left: var(${Pa}left, 0px) !important;
|
|
122
|
+
right: unset !important;
|
|
123
|
+
bottom: unset !important;
|
|
124
|
+
width: var(${Pa}width, auto);
|
|
125
|
+
max-width: var(${Pa}width, auto);
|
|
126
|
+
height: var(${Pa}height, auto);
|
|
127
|
+
max-height: var(${Pa}height, auto);
|
|
128
|
+
transform: var(${Pa}transform, none) !important;
|
|
129
|
+
transition: var(${Pa}transition) !important;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
:is(:root,:host) [${Pc}] {
|
|
133
|
+
transition: none;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
:is(:root,:host) [${Pc}='hidden'] {
|
|
137
|
+
visibility: hidden;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
[${Pl}] * {
|
|
141
|
+
pointer-events: none !important;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
[${Pl}]:not([${Po}]) {
|
|
145
|
+
translate: var(${Pa}translate) !important;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
[${Pl}][style*='${Pa}scale'] {
|
|
149
|
+
scale: var(${Pa}scale) !important;
|
|
150
|
+
transform-origin: var(${Pa}transform-origin) !important;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
@layer dnd-kit {
|
|
154
|
+
:where([${Pl}][popover]) {
|
|
155
|
+
overflow: visible;
|
|
156
|
+
background: unset;
|
|
157
|
+
border: unset;
|
|
158
|
+
margin: unset;
|
|
159
|
+
padding: unset;
|
|
160
|
+
color: inherit;
|
|
161
|
+
|
|
162
|
+
&:is(input, button) {
|
|
163
|
+
border: revert;
|
|
164
|
+
background: revert;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
[${Pl}]::backdrop, [${Ps}overlay]:not([${Pl}]) {
|
|
169
|
+
display: none;
|
|
170
|
+
visibility: hidden;
|
|
171
|
+
}
|
|
172
|
+
`.replace(/\n+/g," ").replace(/\s+/g," ").trim();function Pp(e,i){return e===i||j1(e)===j1(i)}function Pf(e){let{target:i}=e;"newState"in e&&"closed"===e.newState&&IM(i)&&i.hasAttribute("popover")&&requestAnimationFrame(()=>It(i))}function Pm(e){return"TR"===e.tagName}var Pg=class extends(tI=L7,tj=[D9],tI){constructor(e,i){super(e,i),I4(this,tz),I4(this,tB,I0(tP,8,this)),I0(tP,11,this),this.state={initial:{},current:{}};const n=e.registry.plugins.get(Pn),r=null==n?void 0:n.register(Pu);if(r){const e=this.destroy.bind(this);this.destroy=()=>{r(),e()}}this.registerEffect(I8(this,tz,tF).bind(this,n)),this.registerEffect(I8(this,tz,tW))}};tP=IX(tI),tB=new WeakMap,tz=new WeakSet,tF=function(e){let{overlay:i}=this;if(!i||!e)return;let n=jX(i);if(n)return e.addRoot(n)},tW=function(){var e,i,n,r,s,o,a,l;let c,h,d,{state:u,manager:p,options:f}=this,{dragOperation:m}=p,{position:g,source:v,status:y}=m;if(y.idle){u.current={},u.initial={};return}if(!v)return;let{element:_}=v,b=v.pluginConfig(Pg),w=null!=(i=null!=(e=null==b?void 0:b.feedback)?e:null==f?void 0:f.feedback)?i:"default",S="function"==typeof w?w(v,p):w;if(!_||"none"===S||!y.initialized||y.initializing)return;let{initial:k}=u,C=null!=(n=this.overlay)?n:_,T=Ip(C),E=Ip(_),N=!Pp(_,C),M=new IT(_,{frameTransform:N?E:null,ignoreTransforms:!N}),O={x:E.scaleX/T.scaleX,y:E.scaleY/T.scaleY},{width:A,height:R,top:D,left:L}=M;N&&(A/=O.x,R/=O.y);let j=new IN(C),I=Ic(_),{transition:P,translate:B,boxSizing:z,paddingBlockStart:F,paddingBlockEnd:W,paddingInlineStart:H,paddingInlineEnd:$,borderInlineStartWidth:U,borderInlineEndWidth:V,borderBlockStartWidth:q,borderBlockEndWidth:Y}=I,K=P.split(",").filter(e=>!/^\s*(transform|translate|scale)\b/.test(e)).join(","),X=Im(I),J=I.transform,G="clone"===S,Z="content-box"===z,Q=Z?parseInt(H)+parseInt($)+parseInt(U)+parseInt(V):0,ee=Z?parseInt(F)+parseInt(W)+parseInt(q)+parseInt(Y):0,et="move"===S||this.overlay?null:function(e,i="hidden"){return Ds(()=>{let n,r,s,{element:o,manager:a}=e;if(!o||!a)return;let l=function(e,i){let n=new Map;for(let r of i)if(r.element&&(e===r.element||e.contains(r.element))){let e=`${Ps}${IR("dom-id")}`;r.element.setAttribute(e,""),n.set(r,e)}return n}(o,a.registry.droppables),c=[],h=(n="input, textarea, select, canvas, [contenteditable]",r=o.cloneNode(!0),s=Array.from(o.querySelectorAll(n)),Array.from(r.querySelectorAll(n)).forEach((e,i)=>{let n=s[i];if(jG(e)&&jG(n)&&("file"!==e.type&&(e.value=n.value),"radio"===e.type&&e.name&&(e.name=`Cloned__${e.name}`)),jZ(e)&&jZ(n)&&n.width>0&&n.height>0){let i=e.getContext("2d");null==i||i.drawImage(n,0,0)}}),r),{remove:d}=h;return function(e,i,n){for(let[r,s]of e){if(!r.element)continue;let e=`[${s}]`,o=i.matches(e)?i:i.querySelector(e);if(r.element.removeAttribute(s),!o)continue;let a=r.element;r.proxy=o,o.removeAttribute(s),jQ.set(a,o),n.push(()=>{jQ.delete(a),r.proxy=void 0})}}(l,h,c),function(e,i="hidden"){e.setAttribute("inert","true"),e.setAttribute("tab-index","-1"),e.setAttribute("aria-hidden","true"),e.setAttribute(Pc,i)}(h,i),h.remove=()=>{c.forEach(e=>e()),d.call(h)},h})}(v,G?"clone":"hidden"),ei=Ds(()=>IO(p.dragOperation.activatorEvent));if(!k.translate){if(this.overlay&&X)k.translate={x:X.x,y:X.y};else if("none"!==B){let e=If(B);e&&(k.translate=e)}}if(!k.transformOrigin){let e=Ds(()=>g.current),i=L+(null!=(r=null==X?void 0:X.x)?r:0),n=D+(null!=(s=null==X?void 0:X.y)?s:0);k.transformOrigin={x:(e.x-i*T.scaleX-T.x)/(A*T.scaleX),y:(e.y-n*T.scaleY-T.y)/(R*T.scaleY)}}let{transformOrigin:en}=k,er=D*T.scaleY+T.y,es=L*T.scaleX+T.x;if(!k.coordinates&&(k.coordinates={x:es,y:er},1!==O.x||1!==O.y)){let{scaleX:e,scaleY:i}=E,{x:n,y:r}=en;k.coordinates.x+=(A*e-A)*n,k.coordinates.y+=(R*i-R)*r}k.dimensions||(k.dimensions={width:A,height:R}),k.frameTransform||(k.frameTransform=T);let eo={x:k.coordinates.x-es,y:k.coordinates.y-er},ea={width:(k.dimensions.width*k.frameTransform.scaleX-A*T.scaleX)*en.x,height:(k.dimensions.height*k.frameTransform.scaleY-R*T.scaleY)*en.y},el={x:eo.x/T.scaleX+ea.width,y:eo.y/T.scaleY+ea.height},ec={left:L+el.x,top:D+el.y};C.setAttribute(Pl,"true");let eh=Ds(()=>m.transform),ed=null!=(o=k.translate)?o:{x:0,y:0},eu=eh.x*T.scaleX+ed.x,ep=eh.y*T.scaleY+ed.y,ef=jY();j.set({width:A-Q,height:R-ee,top:ec.top+ef.y,left:ec.left+ef.x,translate:`${eu}px ${ep}px 0`,transform:this.overlay?"none":J,transition:K?`${K}, translate 0ms linear`:"translate 0ms linear",scale:N?`${O.x} ${O.y}`:"","transform-origin":`${100*en.x}% ${100*en.y}%`},Pa),et&&(_.insertAdjacentElement("afterend",et),(null==f?void 0:f.rootElement)&&("function"==typeof f.rootElement?f.rootElement(v):f.rootElement).appendChild(_)),Ie(C)&&(C.hasAttribute("popover")||C.setAttribute("popover","manual"),It(C),C.addEventListener("beforetoggle",Pf));let em=(l={placeholder:et,element:_,feedbackElement:C,frameTransform:T,transformOrigin:en,width:A,height:R,top:D,left:L,widthOffset:Q,heightOffset:ee,delta:el,styles:j,dragOperation:m,getTranslate:()=>u.current.translate,getElementMutationObserver:()=>c,getSavedCellWidths:()=>d,setSavedCellWidths:e=>{d=e}},new ResizeObserver(()=>{var e,i,n;let r=new IT(l.placeholder,{frameTransform:l.frameTransform,ignoreTransforms:!0}),s=null!=(e=l.transformOrigin)?e:{x:1,y:1},o=(l.width-r.width)*s.x+l.delta.x,a=(l.height-r.height)*s.y+l.delta.y,c=jY();if(l.styles.set({width:r.width-l.widthOffset,height:r.height-l.heightOffset,top:l.top+a+c.y,left:l.left+o+c.x},Pa),null==(i=l.getElementMutationObserver())||i.takeRecords(),Pm(l.element)&&Pm(l.placeholder)){let e=Array.from(l.element.cells),i=Array.from(l.placeholder.cells);for(let[n,r]of(l.getSavedCellWidths()||l.setSavedCellWidths(e.map(e=>e.style.width)),e.entries())){let e=i[n];r.style.width=`${e.getBoundingClientRect().width}px`}}let h=null!=(n=l.getTranslate())?n:{x:0,y:0},d=l.left+o+c.x+h.x,u=l.top+a+c.y+h.y,p=r.width-l.widthOffset,f=r.height-l.heightOffset,m=l.frameTransform;l.dragOperation.shape=new LE(d*m.scaleX+m.x,u*m.scaleY+m.y,p*m.scaleX,f*m.scaleY)})),eg=new IT(C);Ds(()=>m.shape=eg);let ev=jB(C),ey=e=>{this.manager.actions.stop({event:e})},e_=jJ(ev);if(ei&&ev.addEventListener("resize",ey),"idle"===Ds(()=>v.status)&&requestAnimationFrame(()=>v.status="dragging"),et){let e,i;em.observe(et),(e=new MutationObserver(e=>{let i=!1;for(let n of e){if(n.target!==_){i=!0;continue}if("attributes"!==n.type)continue;let e=n.attributeName;if(e.startsWith("aria-")||Ph.includes(e))continue;let r=_.getAttribute(e);if("style"===e){if(IE(_)&&IE(et)){let e=_.style;for(let i of Array.from(et.style))""===e.getPropertyValue(i)&&et.style.removeProperty(i);for(let i of Array.from(e)){if(Pd.includes(i)||i.startsWith(Pa))continue;let n=e.getPropertyValue(i);et.style.setProperty(i,n)}}}else null!==r?et.setAttribute(e,r):et.removeAttribute(e)}i&&G&&et.replaceChildren(..._.cloneNode(!0).childNodes)})).observe(_,{attributes:!0,subtree:!0,childList:!0}),c=e,(i=new MutationObserver(e=>{for(let i of e)if(0!==i.addedNodes.length)for(let e of Array.from(i.addedNodes)){if(e.contains(_)&&_.nextElementSibling!==et){_.insertAdjacentElement("afterend",et),It(C);return}if(e.contains(et)&&et.previousElementSibling!==_){et.insertAdjacentElement("beforebegin",_),It(C);return}}_.isConnected&&et.isConnected&&_.nextElementSibling!==et&&(_.insertAdjacentElement("afterend",et),It(C))})).observe(_.ownerDocument.body,{childList:!0,subtree:!0}),h=i}let eb=null==(a=p.dragOperation.source)?void 0:a.id,ex=()=>{var e;if(!ei||null==eb)return;let i=p.registry.draggables.get(eb),n=null!=(e=null==i?void 0:i.handle)?e:null==i?void 0:i.element;jF(n)&&n.focus()},ew=()=>{var e;if(null==c||c.disconnect(),null==h||h.disconnect(),em.disconnect(),ev.removeEventListener("resize",ey),Ie(C)&&(C.removeEventListener("beforetoggle",Pf),C.removeAttribute("popover")),C.removeAttribute(Pl),j.reset(),d&&Pm(_))for(let[i,n]of Array.from(_.cells).entries())n.style.width=null!=(e=d[i])?e:"";v.status="idle";let i=null!=u.current.translate,n=m.status.dragging;et&&(!n&&i||et.parentElement!==C.parentElement)&&C.isConnected&&et.replaceWith(C),null==et||et.remove()},eS=null==f?void 0:f.dropAnimation,ek=this,eC=Lt(()=>{var e,i,n;let{transform:r,status:s}=m;if((r.x||r.y||u.current.translate)&&s.dragging){let s=null!=(e=k.translate)?e:{x:0,y:0},o={x:r.x/T.scaleX+s.x,y:r.y/T.scaleY+s.y},a=u.current.translate,l=Ds(()=>m.modifiers),h=Ds(()=>{var e;return null==(e=m.shape)?void 0:e.current}),d=null==f?void 0:f.keyboardTransition,p=ei&&!e_&&null!==d?`${null!=(i=null==d?void 0:d.duration)?i:250}ms ${null!=(n=null==d?void 0:d.easing)?n:"cubic-bezier(0.25, 1, 0.5, 1)"}`:"0ms linear";if(j.set({transition:K?`${K}, translate ${p}`:`translate ${p}`,translate:`${o.x}px ${o.y}px 0`},Pa),null==c||c.takeRecords(),h&&h!==eg&&a&&!l.length){let e=LT.delta(o,a);m.shape=LE.from(h.boundingRectangle).translate(e.x*T.scaleX,e.y*T.scaleY)}else m.shape=new IT(C);u.current.translate=o}},function(){if(m.status.dropped){this.dispose(),v.status="dropping";let e=(null==b?void 0:b.dropAnimation)!==void 0?b.dropAnimation:void 0!==ek.dropAnimation?ek.dropAnimation:eS,i=u.current.translate,n=null!=i;if(i||_===C||(i={x:0,y:0}),!i||null===e)return void ew();p.renderer.rendering.then(()=>{!function(e){var i,n,r,s;let{animation:o}=e;if("function"==typeof o)return Promise.resolve(o({source:e.source,element:e.element,feedbackElement:e.feedbackElement,placeholder:e.placeholder,translate:e.translate,moved:e.moved})).then(()=>{e.cleanup(),requestAnimationFrame(e.restoreFocus)});let{duration:a=250,easing:l="ease"}=null!=o?o:{};It(e.feedbackElement);let[,c]=null!=(i=jL(e.feedbackElement,e=>"translate"in e))?i:[];null==c||c.pause();let h=null!=(n=e.placeholder)?n:e.element,d={frameTransform:Pp(e.feedbackElement,h)?null:void 0},u=new IT(e.feedbackElement,d),p=null!=(r=If(Ic(e.feedbackElement).translate))?r:e.translate,f=new IT(h,d),m=LE.delta(u,f,e.alignment),g={x:p.x-m.x,y:p.y-m.y},v=Math.round(u.intrinsicHeight)!==Math.round(f.intrinsicHeight)?{minHeight:[`${u.intrinsicHeight}px`,`${f.intrinsicHeight}px`],maxHeight:[`${u.intrinsicHeight}px`,`${f.intrinsicHeight}px`]}:{},y=Math.round(u.intrinsicWidth)!==Math.round(f.intrinsicWidth)?{minWidth:[`${u.intrinsicWidth}px`,`${f.intrinsicWidth}px`],maxWidth:[`${u.intrinsicWidth}px`,`${f.intrinsicWidth}px`]}:{};e.styles.set({transition:e.transition},Pa),e.feedbackElement.setAttribute(Po,""),null==(s=e.getElementMutationObserver())||s.takeRecords(),Ix({element:e.feedbackElement,keyframes:IP(Iq(Iq({},v),y),Iz({translate:[`${p.x}px ${p.y}px 0`,`${g.x}px ${g.y}px 0`]})),options:{duration:jJ(jB(e.feedbackElement))?0:e.moved||e.feedbackElement!==e.element?a:0,easing:l}}).then(()=>{e.feedbackElement.removeAttribute(Po),null==c||c.finish(),e.cleanup(),requestAnimationFrame(e.restoreFocus)})}({source:v,element:_,feedbackElement:C,placeholder:et,translate:i,moved:n,transition:P,alignment:v.alignment,styles:j,animation:null!=e?e:void 0,getElementMutationObserver:()=>c,cleanup:ew,restoreFocus:ex})})}});return()=>{ew(),eC()}},I1(tP,4,"overlay",tj,Pg,tB),IQ(tP,Pg),Pg.configure=L8(Pg),tU=[D9],tV=Ig.Forward,tH=[D9],t$=Ig.Reverse;var Pv=class{constructor(){I4(this,tY,I0(tq,8,this,!0)),I0(tq,11,this),I4(this,tK,I0(tq,12,this,!0)),I0(tq,15,this)}isLocked(e){return e!==Ig.Idle&&(null==e?!0===this[Ig.Forward]&&!0===this[Ig.Reverse]:!0===this[e])}unlock(e){e!==Ig.Idle&&(this[e]=!1)}};tq=IX(null),tY=new WeakMap,tK=new WeakMap,I1(tq,4,tV,tU,Pv,tY),I1(tq,4,t$,tH,Pv,tK),IQ(tq,Pv);var Py=[Ig.Forward,Ig.Reverse],P_=class{constructor(){this.x=new Pv,this.y=new Pv}isLocked(){return this.x.isLocked()&&this.y.isLocked()}},Pb=class extends L7{constructor(e){super(e);const i=DE(new P_);let n=null;this.signal=i,DI(()=>{let{status:r}=e.dragOperation;if(!r.initialized){n=null,i.value=new P_;return}let{delta:s}=e.dragOperation.position;if(n){let e={x:Px(s.x,n.x),y:Px(s.y,n.y)},r=i.peek();Dn(()=>{for(let i of LA)for(let n of Py)e[i]===n&&r[i].unlock(n);i.value=r})}n=s})}get current(){return this.signal.peek()}};function Px(e,i){return Math.sign(e-i)}var Pw=class extends(tJ=je,tX=[D9],tJ){constructor(e){super(e),I4(this,tZ,I0(tG,8,this,!1)),I0(tG,11,this),I4(this,tQ),I4(this,t0,()=>{if(!I3(this,tQ))return;let{element:e,by:i}=I3(this,tQ);i.y&&(e.scrollTop+=i.y),i.x&&(e.scrollLeft+=i.x)}),this.scroll=(e,i)=>{var n;if(this.disabled)return!1;let r=this.getScrollableElements();if(!r)return I6(this,tQ,void 0),!1;let{position:s}=this.manager.dragOperation,o=null==s?void 0:s.current;if(o){let{by:s}=null!=e?e:{},a=s?{x:PS(s.x),y:PS(s.y)}:void 0,l=a?void 0:this.scrollIntentTracker.current;if(null==l?void 0:l.isLocked())return!1;for(let e of r){let r=function(e,i){let{isTop:n,isBottom:r,isLeft:s,isRight:o,position:a}=In(e),{x:l,y:c}=null!=i?i:{x:0,y:0},h=!n&&a.current.y+c>0,d=!r&&a.current.y+c<a.max.y,u=!s&&a.current.x+l>0,p=!o&&a.current.x+l<a.max.x;return{top:h,bottom:d,left:u,right:p,x:u||p,y:h||d}}(e,s);if(r.x||r.y){let{speed:r,direction:c}=function(e,i,n,r=25,s=Iv,o=Iy){let{x:a,y:l}=i,{rect:c,isTop:h,isBottom:d,isLeft:u,isRight:p}=In(e),f=Ip(e),m=Im(Ic(e,!0)),g=null!==m&&(null==m?void 0:m.scaleX)<0,v=null!==m&&(null==m?void 0:m.scaleY)<0,y=new LE(c.left*f.scaleX+f.x,c.top*f.scaleY+f.y,c.width*f.scaleX,c.height*f.scaleY),_={x:0,y:0},b={x:0,y:0},w={height:y.height*s.y,width:y.width*s.x};return w.height>0&&(!h||v&&!d)&&l<=y.top+w.height&&(null==n?void 0:n.y)!==1&&a>=y.left-o.x&&a<=y.right+o.x?(_.y=v?1:-1,b.y=r*Math.abs((y.top+w.height-l)/w.height)):w.height>0&&(!d||v&&!h)&&l>=y.bottom-w.height&&(null==n?void 0:n.y)!==-1&&a>=y.left-o.x&&a<=y.right+o.x&&(_.y=v?-1:1,b.y=r*Math.abs((y.bottom-w.height-l)/w.height)),w.width>0&&(!p||g&&!u)&&a>=y.right-w.width&&(null==n?void 0:n.x)!==-1&&l>=y.top-o.y&&l<=y.bottom+o.y?(_.x=g?-1:1,b.x=r*Math.abs((y.right-w.width-a)/w.width)):w.width>0&&(!u||g&&!p)&&a<=y.left+w.width&&(null==n?void 0:n.x)!==1&&l>=y.top-o.y&&l<=y.bottom+o.y&&(_.x=g?1:-1,b.x=r*Math.abs((y.left+w.width-a)/w.width)),{direction:_,speed:b}}(e,o,a,null==i?void 0:i.acceleration,null==i?void 0:i.threshold);if(l)for(let e of LA)l[e].isLocked(c[e])&&(r[e]=0,c[e]=0);if(c.x||c.y){let{x:i,y:o}=null!=s?s:c,a=i*r.x,l=o*r.y;if(a||l){let i=null==(n=I3(this,tQ))?void 0:n.by;if(this.autoScrolling&&i&&(i.x&&!a||i.y&&!l))continue;return I6(this,tQ,{element:e,by:{x:a,y:l}}),Is.schedule(I3(this,t0)),!0}}}}}return I6(this,tQ,void 0),!1};let i=null,n=null;const r=D6(()=>{let{position:n,source:r}=e.dragOperation;if(!n)return null;let s=function e(i,{x:n,y:r}){var s;let o=i.elementFromPoint(n,r);if((null==(s=o)?void 0:s.tagName)==="IFRAME"){let{contentDocument:i}=o;if(i){let{left:s,top:a}=o.getBoundingClientRect();return e(i,{x:n-s,y:r-a})}}return o}(jX(null==r?void 0:r.element),n.current);return s&&(i=s),null!=s?s:i}),s=D6(()=>{let i=r.value,{documentElement:s}=jH(i);if(!i||i===s){let{target:i}=e.dragOperation,r=null==i?void 0:i.element;if(r){let e=Iu(r,{excludeElement:!1});return n=e,e}}if(i){let e=Iu(i,{excludeElement:!1});return this.autoScrolling&&n&&e.size<(null==n?void 0:n.size)?n:(n=e,e)}return n=null,null},D8);this.getScrollableElements=()=>s.value,this.scrollIntentTracker=new Pb(e),this.destroy=e.monitor.addEventListener("dragmove",i=>{!this.disabled&&!i.defaultPrevented&&IO(e.dragOperation.activatorEvent)&&i.by&&this.scroll({by:i.by})&&i.preventDefault()})}};function PS(e){return e>0?Ig.Forward:e<0?Ig.Reverse:Ig.Idle}tG=IX(tJ),tZ=new WeakMap,tQ=new WeakMap,t0=new WeakMap,I1(tG,4,"autoScrolling",tX,Pw,tZ),IQ(tG,Pw);var Pk=new class{constructor(e){this.scheduler=e,this.pending=!1,this.tasks=new Set,this.resolvers=new Set,this.flush=()=>{let{tasks:e,resolvers:i}=this;for(let i of(this.pending=!1,this.tasks=new Set,this.resolvers=new Set,e))i();for(let e of i)e()}}schedule(e){return this.tasks.add(e),this.pending||(this.pending=!0,this.scheduler(this.flush)),new Promise(e=>this.resolvers.add(e))}}(e=>{"function"==typeof requestAnimationFrame?requestAnimationFrame(e):e()}),PC=class extends L7{constructor(e,i){super(e,i);const n=e.registry.plugins.get(Pw);if(!n)throw Error("AutoScroller plugin depends on Scroller plugin");this.destroy=DI(()=>{var i,r,s;if(this.disabled)return;let{position:o,status:a}=e.dragOperation;if(a.dragging){let e={acceleration:null==(i=this.options)?void 0:i.acceleration,threshold:"number"==typeof(null==(r=this.options)?void 0:r.threshold)?{x:this.options.threshold,y:this.options.threshold}:null==(s=this.options)?void 0:s.threshold};if(n.scroll(void 0,e)){n.autoScrolling=!0;let i=setInterval(()=>Pk.schedule(()=>n.scroll(void 0,e)),10);return()=>{clearInterval(i)}}n.autoScrolling=!1}})}};PC.configure=L8(PC);var PT={capture:!0,passive:!0},PE=class extends je{constructor(e){super(e),I4(this,t1),this.handleScroll=()=>{null==I3(this,t1)&&I6(this,t1,setTimeout(()=>{this.manager.collisionObserver.forceUpdate(!1),I6(this,t1,void 0)},50))};const{dragOperation:i}=this.manager;this.destroy=DI(()=>{var e,n,r;if(i.status.dragging){let s=null!=(r=null==(n=null==(e=i.source)?void 0:e.element)?void 0:n.ownerDocument)?r:document;return s.addEventListener("scroll",this.handleScroll,PT),()=>{s.removeEventListener("scroll",this.handleScroll,PT)}}})}};t1=new WeakMap;var PN=class extends L7{constructor(e){super(e),this.manager=e;const i=e.registry.plugins.get(Pn),n=null==i?void 0:i.register("* { user-select: none !important; -webkit-user-select: none !important; }");if(this.destroy=DI(()=>{let{dragOperation:e}=this.manager;if(e.status.initialized)return PM(),document.addEventListener("selectionchange",PM,{capture:!0}),()=>{document.removeEventListener("selectionchange",PM,{capture:!0})}}),n){const e=this.destroy.bind(this);this.destroy=()=>{n(),e()}}}};function PM(){var e;null==(e=document.getSelection())||e.removeAllRanges()}var PO=Object.freeze({offset:10,keyboardCodes:{start:["Space","Enter"],cancel:["Escape"],end:["Space","Enter","Tab"],up:["ArrowUp"],down:["ArrowDown"],left:["ArrowLeft"],right:["ArrowRight"]},preventActivation(e,i){var n;let r=null!=(n=i.handle)?n:i.element;return e.target!==r}}),PA=class extends jy{constructor(e,i){super(e),this.manager=e,this.options=i,I4(this,t2,[]),this.listeners=new j0,this.handleSourceKeyDown=(e,i,n)=>{if(this.disabled||e.defaultPrevented||!IM(e.target)||i.disabled)return;let{keyboardCodes:r=PO.keyboardCodes,preventActivation:s=PO.preventActivation}=null!=n?n:{};!r.start.includes(e.code)||!this.manager.dragOperation.status.idle||null!=s&&s(e,i)||this.handleStart(e,i,n)}}bind(e,i=this.options){return DI(()=>{var n;let r=null!=(n=e.handle)?n:e.element,s=n=>{IO(n)&&this.handleSourceKeyDown(n,e,i)};if(r)return r.addEventListener("keydown",s),()=>{r.removeEventListener("keydown",s)}})}handleStart(e,i,n){let{element:r}=i;if(!r)throw Error("Source draggable does not have an associated element");e.preventDefault(),e.stopImmediatePropagation(),I_(r);let{center:s}=new IT(r);if(this.manager.actions.start({event:e,coordinates:{x:s.x,y:s.y},source:i}).signal.aborted)return this.cleanup();this.sideEffects();let o=jH(r),a=[this.listeners.bind(o,[{type:"keydown",listener:e=>this.handleKeyDown(e,i,n),options:{capture:!0}}])];I3(this,t2).push(...a)}handleKeyDown(e,i,n){let{keyboardCodes:r=PO.keyboardCodes}=null!=n?n:{};if(PR(e,[...r.end,...r.cancel])){e.preventDefault();let i=PR(e,r.cancel);this.handleEnd(e,i);return}PR(e,r.up)?this.handleMove("up",e):PR(e,r.down)&&this.handleMove("down",e),PR(e,r.left)?this.handleMove("left",e):PR(e,r.right)&&this.handleMove("right",e)}handleEnd(e,i){this.manager.actions.stop({event:e,canceled:i}),this.cleanup()}handleMove(e,i){var n,r;let{shape:s}=this.manager.dragOperation,o=i.shiftKey?5:1,a={x:0,y:0},l=null!=(r=null==(n=this.options)?void 0:n.offset)?r:PO.offset;if("number"==typeof l&&(l={x:l,y:l}),s){switch(e){case"up":a={x:0,y:-l.y*o};break;case"down":a={x:0,y:l.y*o};break;case"left":a={x:-l.x*o,y:0};break;case"right":a={x:l.x*o,y:0}}(a.x||a.y)&&(i.preventDefault(),this.manager.actions.move({event:i,by:a}))}}sideEffects(){let e=this.manager.registry.plugins.get(PC);(null==e?void 0:e.disabled)===!1&&(e.disable(),I3(this,t2).push(()=>{e.enable()}))}cleanup(){I3(this,t2).forEach(e=>e()),I6(this,t2,[])}destroy(){this.cleanup(),this.listeners.clear()}};function PR(e,i){return i.includes(e.code)}t2=new WeakMap,PA.configure=L8(PA),PA.defaults=PO;var PD=class extends jb{constructor(){super(...arguments),I4(this,t5)}onEvent(e){switch(e.type){case"pointerdown":I6(this,t5,jU(e));break;case"pointermove":if(!I3(this,t5))return;let{x:i,y:n}=jU(e),r={x:i-I3(this,t5).x,y:n-I3(this,t5).y},{tolerance:s}=this.options;if(s&&LM(r,s))return void this.abort();LM(r,this.options.value)&&this.activate(e);break;case"pointerup":this.abort()}}abort(){I6(this,t5,void 0)}};t5=new WeakMap;var PL=class extends jb{constructor(){super(...arguments),I4(this,t3),I4(this,t4)}onEvent(e){switch(e.type){case"pointerdown":I6(this,t4,jU(e)),I6(this,t3,setTimeout(()=>this.activate(e),this.options.value));break;case"pointermove":if(!I3(this,t4))return;let{x:i,y:n}=jU(e);LM({x:i-I3(this,t4).x,y:n-I3(this,t4).y},this.options.tolerance)&&this.abort();break;case"pointerup":this.abort()}}abort(){I3(this,t3)&&(clearTimeout(I3(this,t3)),I6(this,t4,void 0),I6(this,t3,void 0))}};t3=new WeakMap,t4=new WeakMap;var Pj=class{};Pj.Delay=PL,Pj.Distance=PD;var PI=Object.freeze({activationConstraints(e,i){var n;let{pointerType:r,target:s}=e;if(!("mouse"===r&&IM(s)&&(i.handle===s||(null==(n=i.handle)?void 0:n.contains(s)))))return"touch"===r?[new Pj.Delay({value:250,tolerance:5})]:function(e){var i;if(!IM(e))return!1;let{tagName:n}=e;return"INPUT"===n||"TEXTAREA"===n||(i=e).hasAttribute("contenteditable")&&"false"!==i.getAttribute("contenteditable")}(s)&&!e.defaultPrevented?[new Pj.Delay({value:200,tolerance:0})]:[new Pj.Delay({value:200,tolerance:10}),new Pj.Distance({value:5})]},preventActivation(e,i){var n;let{target:r}=e;return!(r===i.element||r===i.handle||!IM(r)||(null==(n=i.handle)?void 0:n.contains(r)))&&!!r.closest(`
|
|
173
|
+
input:not([disabled]),
|
|
174
|
+
select:not([disabled]),
|
|
175
|
+
textarea:not([disabled]),
|
|
176
|
+
button:not([disabled]),
|
|
177
|
+
a[href],
|
|
178
|
+
[contenteditable]:not([contenteditable="false"])
|
|
179
|
+
`)}}),PP=class extends jy{constructor(e,i){super(e),this.manager=e,this.options=i,I4(this,t6,new Set),this.listeners=new j0,this.latest={event:void 0,coordinates:void 0},this.handleMove=()=>{let{event:e,coordinates:i}=this.latest;e&&i&&this.manager.actions.move({event:e,to:i})},this.handleCancel=this.handleCancel.bind(this),this.handlePointerUp=this.handlePointerUp.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this)}activationConstraints(e,i,n=this.options){let{activationConstraints:r=PI.activationConstraints}=null!=n?n:{};return"function"==typeof r?r(e,i):r}bind(e,i=this.options){return DI(()=>{var n,r;let s=new AbortController,{signal:o}=s,a=n=>{(function(e){if(!e)return!1;let{PointerEvent:i}=jB(e.target);return e instanceof i})(n)&&this.handlePointerDown(n,e,i)},l=[null!=(n=e.handle)?n:e.element];for(let n of((null==i?void 0:i.activatorElements)&&(l=Array.isArray(i.activatorElements)?i.activatorElements:i.activatorElements(e)),l)){n&&(!(r=n.ownerDocument.defaultView)||PF.has(r)||(r.addEventListener("touchmove",Pz,{capture:!1,passive:!1}),PF.add(r)),n.addEventListener("pointerdown",a,{signal:o}))}return()=>s.abort()})}handlePointerDown(e,i,n){if(this.disabled||!e.isPrimary||0!==e.button||!IM(e.target)||i.disabled||"sensor"in e||!this.manager.dragOperation.status.idle)return;let{preventActivation:r=PI.preventActivation}=null!=n?n:{};if(null==r?void 0:r(e,i))return;let{target:s}=e,o=jF(s)&&s.draggable&&"true"===s.getAttribute("draggable"),a=Ip(i.element),{x:l,y:c}=jU(e);this.initialCoordinates={x:l*a.scaleX+a.x,y:c*a.scaleY+a.y};let h=this.activationConstraints(e,i,n);e.sensor=this;let d=new j_(h,e=>this.handleStart(i,e));d.signal.onabort=()=>this.handleCancel(e),d.onEvent(e),this.controller=d;let u=function e(i=document,n=new Set){if(n.has(i))return[];n.add(i);let r=[i];for(let s of Array.from(i.querySelectorAll("iframe, frame")))try{let i=s.contentDocument;i&&!n.has(i)&&r.push(...e(i,n))}catch(e){}try{let s=i.defaultView;if(s&&s!==window.top){let o=s.parent;o&&o.document&&o.document!==i&&r.push(...e(o.document,n))}}catch(e){}return r}(),p=this.listeners.bind(u,[{type:"pointermove",listener:e=>this.handlePointerMove(e,i)},{type:"pointerup",listener:this.handlePointerUp,options:{capture:!0}},{type:"pointercancel",listener:this.handleCancel},{type:"dragstart",listener:o?this.handleCancel:PB,options:{capture:!0}}]),f=()=>{p(),this.initialCoordinates=void 0};I3(this,t6).add(f)}handlePointerMove(e,i){var n,r;if((null==(n=this.controller)?void 0:n.activated)===!1){null==(r=this.controller)||r.onEvent(e);return}if(this.manager.dragOperation.status.dragging){let n=jU(e),r=Ip(i.element);n.x=n.x*r.scaleX+r.x,n.y=n.y*r.scaleY+r.y,e.preventDefault(),e.stopPropagation(),this.latest.event=e,this.latest.coordinates=n,Is.schedule(this.handleMove)}}handlePointerUp(e){let{status:i}=this.manager.dragOperation;if(!i.idle){e.preventDefault(),e.stopPropagation();let n=!i.initialized;this.manager.actions.stop({event:e,canceled:n})}this.cleanup()}handleKeyDown(e){"Escape"===e.key&&(e.preventDefault(),this.handleCancel(e))}handleStart(e,i){let{manager:n,initialCoordinates:r}=this;if(!r||!n.dragOperation.status.idle||i.defaultPrevented)return;if(n.actions.start({coordinates:r,event:i,source:e}).signal.aborted)return this.cleanup();i.preventDefault();let s=jH(i.target).body;try{s.setPointerCapture(i.pointerId)}catch(e){this.handleCancel(i);return}let o=IM(i.target)?[i.target,s]:s,a=this.listeners.bind(o,[{type:"touchmove",listener:PB,options:{passive:!1}},{type:"click",listener:PB},{type:"contextmenu",listener:PB},{type:"keydown",listener:this.handleKeyDown}]);I3(this,t6).add(a)}handleCancel(e){let{dragOperation:i}=this.manager;i.status.initialized&&this.manager.actions.stop({event:e,canceled:!0}),this.cleanup()}cleanup(){let{controller:e}=this;this.controller=void 0,e&&!e.signal.aborted&&e.abort(),this.latest={event:void 0,coordinates:void 0},I3(this,t6).forEach(e=>e()),I3(this,t6).clear()}destroy(){this.cleanup(),this.listeners.clear()}};function PB(e){e.preventDefault()}function Pz(){}t6=new WeakMap,PP.configure=L8(PP),PP.defaults=PI;var PF=new WeakSet,PW=[],PH=[Pt,PC,Pr,Pg,PN],P$=[PP,PA],PU=class extends jT{constructor(e={}){const i=jC(e.plugins,PH),n=jC(e.sensors,P$),r=jC(e.modifiers,PW);super(((e,i)=>IP(e,Iz(i)))(Iq({},e),{plugins:[PE,Pw,Pn,...i],sensors:n,modifiers:r}))}},PV=class extends(t7=jl,t9=[D9],t8=[D9],t7){constructor(e,i){var{element:n,effects:r=()=>[],handle:s}=e;super(Iq({effects:()=>[...r(),()=>{var e,i;let{manager:n}=this;if(!n)return;let r=(null!=(i=null==(e=this.sensors)?void 0:e.map(L9))?i:[...n.sensors]).map(e=>{let i=e instanceof jy?e:n.registry.register(e.plugin),r=e instanceof jy?void 0:e.options;return i.bind(this,r)});return function(){r.forEach(e=>e())}}]},IK(e,["element","effects","handle"])),i),I4(this,it,I0(ie,8,this)),I0(ie,11,this),I4(this,ii,I0(ie,12,this)),I0(ie,15,this),this.element=n,this.handle=s}};ie=IX(t7),it=new WeakMap,ii=new WeakMap,I1(ie,4,"handle",t9,PV,it),I1(ie,4,"element",t8,PV,ii),IQ(ie,PV);var Pq=class extends(io=jc,is=[D9],ir=[D9],io){constructor(e,i){var{element:n,effects:r=()=>[]}=e,s=IK(e,["element","effects"]);const{collisionDetector:o=ID}=s,a=e=>{let{manager:i,element:n}=this;if(!n||null===e){this.shape=void 0;return}if(!i)return;let r=new IT(n),s=Ds(()=>this.shape);return r&&(null==s?void 0:s.equals(r))?s:(this.shape=r,r)},l=DE(!1);super(((e,i)=>IP(e,Iz(i)))(Iq({},s),{collisionDetector:o,effects:()=>[...r(),()=>{let{element:e,manager:i}=this;if(!i)return;let{dragOperation:n}=i,{source:r}=n;l.value=!!(r&&n.status.initialized&&e&&!this.disabled&&this.accepts(r))},()=>{let{element:e}=this;if(l.value&&e){let i=new j7(e,a);return()=>{i.disconnect(),this.shape=void 0}}},()=>{var e;if(null==(e=this.manager)?void 0:e.dragOperation.status.initialized)return()=>{this.shape=void 0}}]}),i),I4(this,iu),I4(this,il,I0(ia,8,this)),I0(ia,11,this),I4(this,ip,I0(ia,12,this)),I0(ia,15,this),this.element=n,this.refreshShape=()=>a()}set element(e){I6(this,iu,e,id)}get element(){var e;return null!=(e=this.proxy)?e:I3(this,iu,ih)}};function PY(e){var i;if(null!=e)return null!=e&&"object"==typeof e&&"current"in e?null!=(i=e.current)?i:void 0:e}ia=IX(io),il=new WeakMap,iu=new WeakSet,ip=new WeakMap,ih=(ic=I1(ia,20,"#element",is,iu,il)).get,id=ic.set,I1(ia,4,"proxy",ir,Pq,ip),IQ(ia,Pq);var PK="u">typeof window&&void 0!==window.document&&void 0!==window.document.createElement?iM.useLayoutEffect:iM.useEffect;function PX(e,i){e()}function PJ(e){let i=(0,iM.useRef)(e);return PK(()=>{i.current=e},[e]),i}function PG(e,i,n=iM.useEffect,r=Object.is){let s=(0,iM.useRef)(e);n(()=>{let n=s.current;r(e,n)||(s.current=e,i(e,n))},[i,e])}function PZ(e,i){let n=(0,iM.useRef)(PY(e));PK(()=>{let r=PY(e);r!==n.current&&(n.current=r,i(r))})}var PQ=Object.getOwnPropertySymbols,P0=Object.prototype.hasOwnProperty,P1=Object.prototype.propertyIsEnumerable,P2=new PU,P5=(0,iM.createContext)(P2),P3=(0,iM.memo)((0,iM.forwardRef)(({children:e},i)=>{let[n,r]=(0,iM.useState)(0),s=(0,iM.useRef)(null),o=(0,iM.useRef)(null),a=(0,iM.useMemo)(()=>({renderer:{get rendering(){var e;return null!=(e=s.current)?e:Promise.resolve()}},trackRendering(e){s.current||(s.current=new Promise(e=>{o.current=e})),(0,iM.startTransition)(()=>{e(),r(e=>e+1)})}}),[]);return PK(()=>{var e;null==(e=o.current)||e.call(o),s.current=null},[e,n]),(0,iM.useImperativeHandle)(i,()=>a),null})),P4=[void 0,D8];function P6(e){let i;var n,{children:r,onCollision:s,onBeforeDragStart:o,onDragStart:a,onDragMove:l,onDragOver:c,onDragEnd:h}=e,d=((e,i)=>{var n={};for(var r in e)P0.call(e,r)&&0>i.indexOf(r)&&(n[r]=e[r]);if(null!=e&&PQ)for(var r of PQ(e))0>i.indexOf(r)&&P1.call(e,r)&&(n[r]=e[r]);return n})(e,["children","onCollision","onBeforeDragStart","onDragStart","onDragMove","onDragOver","onDragEnd"]);let u=(0,iM.useRef)(null),{plugins:p,modifiers:f,sensors:m}=d,g=jC(p,PH),v=jC(m,P$),y=jC(f,PW),_=PJ(o),b=PJ(a),w=PJ(c),S=PJ(l),k=PJ(h),C=PJ(s),T=(n=()=>{var e;return null!=(e=d.manager)?e:new PU(d)},(i=(0,iM.useRef)(null)).current||(i.current=n()),(0,iM.useInsertionEffect)(()=>()=>{var e;return null==(e=i.current)?void 0:e.destroy()},[]),i.current);return(0,iM.useEffect)(()=>{if(!u.current)throw Error("Renderer not found");let{renderer:e,trackRendering:i}=u.current,{monitor:n}=T;T.renderer=e;let r=[n.addEventListener("beforedragstart",e=>{let n=_.current;n&&i(()=>n(e,T))}),n.addEventListener("dragstart",e=>{var i;return null==(i=b.current)?void 0:i.call(b,e,T)}),n.addEventListener("dragover",e=>{let n=w.current;n&&i(()=>n(e,T))}),n.addEventListener("dragmove",e=>{let n=S.current;n&&i(()=>n(e,T))}),n.addEventListener("dragend",e=>{let n=k.current;n&&i(()=>n(e,T))}),n.addEventListener("collision",e=>{var i;return null==(i=C.current)?void 0:i.call(C,e,T)})];return()=>r.forEach(e=>e())},[T]),PG(g,()=>T&&(T.plugins=g),...P4),PG(v,()=>T&&(T.sensors=v),...P4),PG(y,()=>T&&(T.modifiers=y),...P4),(0,iN.jsxs)(P5.Provider,{value:T,children:[(0,iN.jsx)(P3,{ref:u,children:r}),r]})}var P8=Object.create,P9=Object.defineProperty,P7=Object.getOwnPropertyDescriptor,Be=(e,i)=>(i=Symbol[e])?i:Symbol.for("Symbol."+e),Bt=e=>{throw TypeError(e)},Bi=["class","method","getter","setter","accessor","field","value","get","set"],Bn=e=>void 0!==e&&"function"!=typeof e?Bt("Function expected"):e,Br=(e,i,n,r,s)=>({kind:Bi[e],name:i,metadata:r,addInitializer:e=>n._?Bt("Already initialized"):s.push(Bn(e||null))}),Bs=(e,i,n,r,s,o)=>{for(var a,l,c,h=7&i,d=Bi[h+5],u=e[2]||(e[2]=[]),p=P7(s=s.prototype,n),f=r.length-1;f>=0;f--)(c=Br(h,n,l={},e[3],u)).static=!1,c.private=!1,(c.access={has:e=>n in e}).get=e=>e[n],a=(0,r[f])(p[d],c),l._=1,Bn(a)&&(p[d]=a);return p&&P9(s,n,p),s},Bo=(e,i,n)=>i.has(e)||Bt("Cannot "+n),Ba=class e{constructor(e,i){this.x=e,this.y=i}static delta(i,n){return new e(i.x-n.x,i.y-n.y)}static distance(e,i){return Math.hypot(e.x-i.x,e.y-i.y)}static equals(e,i){return e.x===i.x&&e.y===i.y}static from({x:i,y:n}){return new e(i,n)}},Bl=class extends(iv=Li,ig=[D7],im=[D7],iv){constructor(e){super(Ba.from(e),(e,i)=>Ba.equals(e,i)),((e,i,n,r)=>{for(var s=0,o=e[i>>1],a=o&&o.length;s<a;s++)o[s].call(n)})(i_,5,this),((e,i,n)=>i.has(e)?Bt("Cannot add the same private member more than once"):i instanceof WeakSet?i.add(e):i.set(e,n))(this,iy,0),this.velocity={x:0,y:0}}get delta(){return Ba.delta(this.current,this.initial)}get direction(){let{current:e,previous:i}=this;if(!i)return null;let n={x:e.x-i.x,y:e.y-i.y};return n.x||n.y?Math.abs(n.x)>Math.abs(n.y)?n.x>0?"right":"left":n.y>0?"down":"up":null}get current(){return super.current}set current(e){let i,{current:n}=this,r=Ba.from(e),s={x:r.x-n.x,y:r.y-n.y},o=Date.now(),a=o-(Bo(this,i=iy,"read from private field"),i.get(this)),l=e=>Math.round(e/a*100);Dn(()=>{let e;Bo(this,e=iy,"write to private field"),e.set(this,o),this.velocity={x:l(s.x),y:l(s.y)},super.current=r})}reset(e=this.defaultValue){super.reset(Ba.from(e)),this.velocity={x:0,y:0}}};i_=[,,,P8(null!=(k=null==iv?void 0:iv[Be("metadata")])?k:null)],iy=new WeakMap,Bs(i_,2,"delta",ig,Bl),Bs(i_,2,"direction",im,Bl),C=i_,f=Be("metadata"),m=C[3],f in Bl?P9(Bl,f,{enumerable:!0,configurable:!0,writable:!0,value:m}):Bl[f]=m;var Bc=((T=Bc||{}).Horizontal="x",T.Vertical="y",T);Object.values(Bc);var Bh=Object.create,Bd=Object.defineProperty,Bu=Object.defineProperties,Bp=Object.getOwnPropertyDescriptor,Bf=Object.getOwnPropertyDescriptors,Bm=Object.getOwnPropertySymbols,Bg=Object.prototype.hasOwnProperty,Bv=Object.prototype.propertyIsEnumerable,By=e=>{throw TypeError(e)},B_=(e,i,n)=>i in e?Bd(e,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[i]=n,Bb=(e,i)=>{for(var n in i||(i={}))Bg.call(i,n)&&B_(e,n,i[n]);if(Bm)for(var n of Bm(i))Bv.call(i,n)&&B_(e,n,i[n]);return e},Bx=["class","method","getter","setter","accessor","field","value","get","set"],Bw=e=>void 0!==e&&"function"!=typeof e?By("Function expected"):e,BS=(e,i,n,r,s)=>({kind:Bx[e],name:i,metadata:r,addInitializer:e=>n._?By("Already initialized"):s.push(Bw(e||null))}),Bk=(e,i,n,r)=>{for(var s=0,o=e[i>>1],a=o&&o.length;s<a;s++)1&i?o[s].call(n):r=o[s].call(n,r);return r},BC=(e,i,n,r,s,o)=>{for(var a,l,c,h,d,u=7&i,p=e.length+1,f=Bx[u+5],m=e[p-1]=[],g=e[p]||(e[p]=[]),v=(s=s.prototype,Bp({get[n](){return BE(this,o)},set[n](x){return BM(this,o,x)}},n)),y=r.length-1;y>=0;y--)(h=BS(u,n,c={},e[3],g)).static=!1,h.private=!1,(d=h.access={has:e=>n in e}).get=e=>e[n],d.set=(e,i)=>e[n]=i,l=(0,r[y])({get:v.get,set:v.set},h),c._=1,void 0===l?Bw(l)&&(v[f]=l):"object"!=typeof l||null===l?By("Object expected"):(Bw(a=l.get)&&(v.get=a),Bw(a=l.set)&&(v.set=a),Bw(a=l.init)&&m.unshift(a));return v&&Bd(s,n,v),s},BT=(e,i,n)=>i.has(e)||By("Cannot "+n),BE=(e,i,n)=>(BT(e,i,"read from private field"),i.get(e)),BN=(e,i,n)=>i.has(e)?By("Cannot add the same private member more than once"):i instanceof WeakSet?i.add(e):i.set(e,n),BM=(e,i,n,r)=>(BT(e,i,"write to private field"),i.set(e,n),n);function BO(e){return e instanceof BG||e instanceof BJ}var BA=class extends L7{constructor(e){super(e);const i=DI(()=>{let{dragOperation:i}=e;if(IO(i.activatorEvent)&&BO(i.source)&&i.status.initialized){let i=e.registry.plugins.get(Pw);if(i)return i.disable(),()=>i.enable()}}),n=e.monitor.addEventListener("dragmove",(e,i)=>{queueMicrotask(()=>{if(this.disabled||e.defaultPrevented||!e.nativeEvent)return;let{dragOperation:n}=i;if(!IO(e.nativeEvent)||!BO(n.source)||!n.shape)return;let{actions:r,collisionObserver:s,registry:o}=i,{by:a}=e;if(!a)return;let l=function(e){let{x:i,y:n}=e;return i>0?"right":i<0?"left":n>0?"down":n<0?"up":void 0}(a),{source:c,target:h}=n,{center:d}=n.shape.current,u=[],p=[];Dn(()=>{for(let e of o.droppables){let{id:i}=e;if(!e.accepts(c)||i===(null==h?void 0:h.id)&&BO(e)||!e.element)continue;let n=e.shape,r=new IT(e.element,{getBoundingClientRect:e=>j$(e,void 0,.2)});r.height&&r.width&&("down"==l&&d.y+10<r.center.y||"up"==l&&d.y-10>r.center.y||"left"==l&&d.x-10>r.center.x||"right"==l&&d.x+10<r.center.x)&&(u.push(e),e.shape=r,p.push(()=>e.shape=n))}}),e.preventDefault(),s.disable();let f=s.computeCollisions(u,IL);Dn(()=>p.forEach(e=>e()));let[m]=f;if(!m)return;let{id:g}=m,{index:v,group:y}=c.sortable;r.setDropTarget(g).then(()=>{let{source:e,target:i,shape:o}=n;if(!e||!BO(e)||!o)return;let{index:a,group:l,target:c}=e.sortable,h=v!==a||y!==l,d=h?c:null==i?void 0:i.element;if(!d)return;I_(d);let u=new IT(d);if(!u)return;let p=LE.delta(u,LE.from(o.current.boundingRectangle),e.alignment);r.move({by:p}),h?r.setDropTarget(e.id).then(()=>s.enable()):s.enable()})})});this.destroy=()=>{n(),i()}}},BR=Object.defineProperty,BD=Object.defineProperties,BL=Object.getOwnPropertyDescriptors,Bj=Object.getOwnPropertySymbols,BI=Object.prototype.hasOwnProperty,BP=Object.prototype.propertyIsEnumerable,BB=(e,i,n)=>i in e?BR(e,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[i]=n,Bz=(e,i)=>{for(var n in i||(i={}))BI.call(i,n)&&BB(e,n,i[n]);if(Bj)for(var n of Bj(i))BP.call(i,n)&&BB(e,n,i[n]);return e};function BF(e,i,n){if(i===n)return e;let r=e.slice();return r.splice(n,0,r.splice(i,1)[0]),r}function BW(e){return"initialIndex"in e&&"number"==typeof e.initialIndex&&"index"in e&&"number"==typeof e.index}var BH="__default__";function B$(e,i,n,r){n.insertAdjacentElement(r<i?"afterend":"beforebegin",e)}function BU(e,i){return e.index-i.index}function BV(e){return Array.from(e).sort(BU)}var Bq=[BA,class extends L7{constructor(e){super(e);const i=()=>{let i=new Map;for(let n of e.registry.droppables)if(n instanceof BG){let{sortable:e}=n,{group:r}=e,s=i.get(r);s||(s=new Set,i.set(r,s)),s.add(e)}for(let[e,n]of i)i.set(e,new Set(BV(n)));return i},n=[e.monitor.addEventListener("dragover",(e,n)=>{if(this.disabled)return;let{dragOperation:r}=n,{source:s,target:o}=r;if(!BO(s)||!BO(o)||s.sortable===o.sortable)return;let a=i(),l=s.sortable.group===o.sortable.group,c=a.get(s.sortable.group),h=l?c:a.get(o.sortable.group);c&&h&&queueMicrotask(()=>{e.defaultPrevented||n.renderer.rendering.then(()=>{var r,d,u;let p=i();for(let[e,i]of a.entries())for(let[n,s]of Array.from(i).entries())if(s.index!==n||s.group!==e||!(null==(r=p.get(e))?void 0:r.has(s)))return;let f=s.sortable.element,m=o.sortable.element;if(!m||!f||!l&&o.id===s.sortable.group)return;let g=BV(c),v=l?g:BV(h),y=null!=(d=s.sortable.group)?d:BH,_=null!=(u=o.sortable.group)?u:BH,b={[y]:g,[_]:v},w=function(e,i,n){var r,s,o;let a,l,{source:c,target:h,canceled:d}=i.operation;if(!c||!h||d)return"preventDefault"in i&&i.preventDefault(),e;let u=(e,i)=>e===i||"object"==typeof e&&"id"in e&&e.id===i;if(Array.isArray(e)){let r=e.findIndex(e=>u(e,c.id)),s=e.findIndex(e=>u(e,h.id));if(-1===r||-1===s){if(BW(c)){let r=c.initialIndex,s=c.index;return r===s||r<0||r>=e.length?("preventDefault"in i&&i.preventDefault(),e):n(e,r,s)}return e}if(!d&&"index"in c&&"number"==typeof c.index){let i=c.index;if(i!==r)return n(e,r,i)}return n(e,r,s)}let p=Object.entries(e),f=-1,m=-1;for(let[e,i]of p)if(-1===f&&-1!==(f=i.findIndex(e=>u(e,c.id)))&&(a=e),-1===m&&-1!==(m=i.findIndex(e=>u(e,h.id)))&&(l=e),-1!==f&&-1!==m)break;if(-1===f&&BW(c)){let r=c.initialGroup,s=c.initialIndex,o=c.group,a=c.index;if(null==r||null==o||!(r in e)||!(o in e)||r===o&&s===a)return"preventDefault"in i&&i.preventDefault(),e;if(r===o)return BD(Bz({},e),BL({[r]:n(e[r],s,a)}));let l=e[r][s];return BD(Bz({},e),BL({[r]:[...e[r].slice(0,s),...e[r].slice(s+1)],[o]:[...e[o].slice(0,a),l,...e[o].slice(a)]}))}if(!c.manager)return e;let{dragOperation:g}=c.manager,v=null!=(s=null==(r=g.shape)?void 0:r.current.center)?s:g.position.current;if(null==l&&h.id in e){let i=h.shape&&v.y>h.shape.center.y?e[h.id].length:0;l=h.id,m=i}if(null==a||null==l||a===l&&f===m){if(null!=a&&a===l&&f===m&&BW(c)){let i=null!=c.group&&c.group!==a,r=c.index!==f;if(i||r){let i=null!=(o=c.group)?o:a;if(i in e){if(a===i)return BD(Bz({},e),BL({[a]:n(e[a],f,c.index)}));let r=e[a][f];return BD(Bz({},e),BL({[a]:[...e[a].slice(0,f),...e[a].slice(f+1)],[i]:[...e[i].slice(0,c.index),r,...e[i].slice(c.index)]}))}}}return"preventDefault"in i&&i.preventDefault(),e}if(a===l)return BD(Bz({},e),BL({[a]:n(e[a],f,m)}));let y=+!!(h.shape&&Math.round(v.y)>Math.round(h.shape.center.y)),_=e[a][f];return BD(Bz({},e),BL({[a]:[...e[a].slice(0,f),...e[a].slice(f+1)],[l]:[...e[l].slice(0,m+y),_,...e[l].slice(m+y)]}))}(b,e,BF);if(b===w)return;let S=w[_].indexOf(s.sortable),k=w[_].indexOf(o.sortable);n.collisionObserver.disable(),B$(f,S,m,k),Dn(()=>{for(let[e,i]of w[y].entries())i.index=e;if(!l)for(let[e,i]of w[_].entries())i.group=o.sortable.group,i.index=e}),n.actions.setDropTarget(s.id).then(()=>n.collisionObserver.enable())})})}),e.monitor.addEventListener("dragend",(e,n)=>{if(!e.canceled)return;let{dragOperation:r}=n,{source:s}=r;BO(s)&&(s.sortable.initialIndex!==s.sortable.index||s.sortable.initialGroup!==s.sortable.group)&&queueMicrotask(()=>{let e=i(),r=e.get(s.sortable.initialGroup);r&&n.renderer.rendering.then(()=>{for(let[i,n]of e.entries())for(let[e,r]of Array.from(n).entries())if(r.index!==e||r.group!==i)return;let i=BV(r),n=s.sortable.element,o=i[s.sortable.initialIndex],a=null==o?void 0:o.element;o&&a&&n&&(B$(n,o.index,a,s.index),Dn(()=>{for(let[i,n]of e.entries())for(let e of Array.from(n).values())e.index=e.initialIndex,e.group=e.initialGroup}))})})})];this.destroy=()=>{for(let e of n)e()}}}],BY={duration:250,easing:"cubic-bezier(0.25, 1, 0.5, 1)",idle:!1},BK=new Lr;ix=[D9],ib=[D9];var BX=class{constructor(e,i){BN(this,iS,Bk(iw,8,this)),Bk(iw,11,this),BN(this,ik),BN(this,iC),BN(this,iT,Bk(iw,12,this)),Bk(iw,15,this),BN(this,iE),this.register=()=>(Dn(()=>{var e,i;null==(e=this.manager)||e.registry.register(this.droppable),null==(i=this.manager)||i.registry.register(this.draggable)}),()=>this.unregister()),this.unregister=()=>{Dn(()=>{var e,i;null==(e=this.manager)||e.registry.unregister(this.droppable),null==(i=this.manager)||i.registry.unregister(this.draggable)})},this.destroy=()=>{Dn(()=>{this.droppable.destroy(),this.draggable.destroy()})};var{effects:n=()=>[],group:r,index:s,sensors:o,type:a,transition:l=BY,plugins:c}=e,h=((e,i)=>{var n={};for(var r in e)Bg.call(e,r)&&0>i.indexOf(r)&&(n[r]=e[r]);if(null!=e&&Bm)for(var r of Bm(e))0>i.indexOf(r)&&Bv.call(e,r)&&(n[r]=e[r]);return n})(e,["effects","group","index","sensors","type","transition","plugins"]);const d=jC(c,Bq);this.droppable=new BG(h,i,this),this.draggable=new BJ(((e,i)=>Bu(e,Bf(i)))(Bb({},h),{plugins:d,effects:()=>[()=>{var e,i,n;let r=null==(e=this.manager)?void 0:e.dragOperation.status;(null==r?void 0:r.initializing)&&this.id===(null==(n=null==(i=this.manager)?void 0:i.dragOperation.source)?void 0:n.id)&&BK.clear(this.manager),(null==r?void 0:r.dragging)&&BK.set(this.manager,this.id,Ds(()=>({initialIndex:this.index,initialGroup:this.group})))},()=>{let{index:e,group:i,manager:n}=this,r=BE(this,iC),s=BE(this,ik);(e!==r||i!==s)&&(BM(this,iC,e),BM(this,ik,i),this.animate())},()=>{var e,i;let{target:n}=this,{isDragSource:r}=this.draggable;"move"===(null!=(i=null==(e=this.draggable.pluginConfig(Pg))?void 0:e.feedback)?i:"default")&&r&&(this.droppable.disabled=!n)},...n()],type:a,sensors:o}),i,this),BM(this,iE,h.element),this.manager=i,this.index=s,BM(this,iC,s),this.group=r,BM(this,ik,r),this.type=a,this.transition=l}get initialIndex(){var e,i;return null!=(i=null==(e=BK.get(this.manager,this.id))?void 0:e.initialIndex)?i:this.index}get initialGroup(){var e,i;return null!=(i=null==(e=BK.get(this.manager,this.id))?void 0:e.initialGroup)?i:this.group}animate(){Ds(()=>{let{manager:e,transition:i}=this,{shape:n}=this.droppable;if(!e)return;let{idle:r}=e.dragOperation.status;n&&i&&(!r||i.idle)&&e.renderer.rendering.then(()=>{let{element:r}=this;if(!r)return;for(let e of r.getAnimations())"transitionProperty"in e&&("transform"===e.transitionProperty||"translate"===e.transitionProperty||"scale"===e.transitionProperty)&&e.cancel();let s=this.refreshShape();if(!s)return;let o={x:n.boundingRectangle.left-s.boundingRectangle.left,y:n.boundingRectangle.top-s.boundingRectangle.top},{translate:a}=Ic(r),l=Iw(r,a,!1),c=Iw(r,a);if(o.x||o.y){let n=jJ(jB(r))?Bu(Bb({},i),Bf({duration:0})):i;Ix({element:r,keyframes:{translate:[`${l.x+o.x}px ${l.y+o.y}px ${l.z}`,`${c.x}px ${c.y}px ${c.z}`]},options:n}).then(()=>{e.dragOperation.status.dragging||(this.droppable.shape=void 0)})}})})}get manager(){return this.draggable.manager}set manager(e){Dn(()=>{this.draggable.manager=e,this.droppable.manager=e})}set element(e){Dn(()=>{let i=BE(this,iE),n=this.droppable.element,r=this.draggable.element;n&&n!==i||(this.droppable.element=e),r&&r!==i||(this.draggable.element=e),BM(this,iE,e)})}get element(){var e,i;let n=BE(this,iE);if(n)return null!=(i=null!=(e=jQ.get(n))?e:n)?i:this.droppable.element}set target(e){this.droppable.element=e}get target(){return this.droppable.element}set source(e){this.draggable.element=e}get source(){return this.draggable.element}get disabled(){return this.draggable.disabled&&this.droppable.disabled}set plugins(e){this.draggable.plugins=jC(e,Bq)}set disabled(e){Dn(()=>{this.droppable.disabled=e,this.draggable.disabled=e})}set data(e){Dn(()=>{this.droppable.data=e,this.draggable.data=e})}set handle(e){this.draggable.handle=e}set id(e){this.droppable.id=e,this.draggable.id=e}get id(){return this.droppable.id}set sensors(e){this.draggable.sensors=e}set modifiers(e){this.draggable.modifiers=e}set collisionPriority(e){this.droppable.collisionPriority=e}set collisionDetector(e){this.droppable.collisionDetector=null!=e?e:ID}set alignment(e){this.draggable.alignment=e}get alignment(){return this.draggable.alignment}set type(e){Dn(()=>{this.droppable.type=e,this.draggable.type=e})}get type(){return this.draggable.type}set accept(e){this.droppable.accept=e}get accept(){return this.droppable.accept}get isDropTarget(){return this.droppable.isDropTarget}get isDragSource(){return this.draggable.isDragSource}get isDragging(){return this.draggable.isDragging}get isDropping(){return this.draggable.isDropping}get status(){return this.draggable.status}refreshShape(){return this.droppable.refreshShape()}accepts(e){return this.droppable.accepts(e)}};iw=[,,,Bh(null)],iS=new WeakMap,ik=new WeakMap,iC=new WeakMap,iT=new WeakMap,iE=new WeakMap,BC(iw,4,"index",ix,BX,iS),BC(iw,4,"group",ib,BX,iT),E=iw,B_(BX,(g="metadata",(v=Symbol[g])?v:Symbol.for("Symbol."+g)),E[3]);var BJ=class extends PV{constructor(e,i,n){super(e,i),this.sortable=n}get index(){return this.sortable.index}get initialIndex(){return this.sortable.initialIndex}get group(){return this.sortable.group}get initialGroup(){return this.sortable.initialGroup}},BG=class extends Pq{constructor(e,i,n){super(e,i),this.sortable=n}get index(){return this.sortable.index}get group(){return this.sortable.group}},BZ=Object.defineProperty,BQ=Object.defineProperties,B0=Object.getOwnPropertyDescriptors,B1=Object.getOwnPropertySymbols,B2=Object.prototype.hasOwnProperty,B5=Object.prototype.propertyIsEnumerable,B3=(e,i,n)=>i in e?BZ(e,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[i]=n,B4=(e,i)=>{for(var n in i||(i={}))B2.call(i,n)&&B3(e,n,i[n]);if(B1)for(var n of B1(i))B5.call(i,n)&&B3(e,n,i[n]);return e};function B6(e,i,n){return"isDragSource"===e&&!n&&!!i}let B8=(0,nL.default)("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);function B9({task:e,index:i,workspaceId:n,onRetry:r,onCancel:s,onEdit:o,onDelete:a,tTask:l}){let c="pending"===e.status,h=c||"running"===e.status||"reviewing"===e.status||"retrying"===e.status,d=c||h,{ref:u,isDragging:p}=function(e){let i,n,r,{accept:s,collisionDetector:o,collisionPriority:a,id:l,data:c,element:h,handle:d,index:u,group:p,disabled:f,modifiers:m,sensors:g,target:v,type:y,plugins:_}=e,b=B4(B4({},BY),e.transition),w=function(e){var i;let n=null!=(i=(0,iM.useContext)(P5))?i:void 0,[r]=(0,iM.useState)(()=>e(n));return r.manager!==n&&(r.manager=n),PK(r.register,[n,r]),r}(i=>new BX(BQ(B4({},e),B0({transition:b,register:!1,handle:PY(d),element:PY(h),target:PY(v)})),i)),S=(i=(0,iM.useRef)(new Map),n=(0,iM.useState)(0)[1],r=(0,iM.useCallback)(()=>{n(e=>e+1)},[n]),PK(()=>w?DI(()=>{var e;let n=!1,s=!1;for(let r of i.current){let[o]=r,a=Ds(()=>r[1]),l=w[o];a!==l&&(n=!0,i.current.set(o,l),s=null!=(e=null==B6?void 0:B6(o,a,l))&&e)}n&&(s?queueMicrotask(()=>(0,iR.flushSync)(r)):r())}):void i.current.clear(),[w]),(0,iM.useMemo)(()=>w?new Proxy(w,{get(e,n){let r=e[n];return i.current.set(n,r),r}}):w,[w]));return PG(l,()=>w.id=l),PK(()=>{Dn(()=>{w.group=p,w.index=u})},[w,p,u]),PG(y,()=>w.type=y),PG(s,()=>w.accept=s,void 0,D8),PG(c,()=>c&&(w.data=c)),PG(u,()=>{var e;(null==(e=w.manager)?void 0:e.dragOperation.status.idle)&&(null==b?void 0:b.idle)&&w.refreshShape()},PX),PZ(d,e=>w.handle=e),PZ(h,e=>w.element=e),PZ(v,e=>w.target=e),PG(f,()=>w.disabled=!0===f),PG(g,()=>w.sensors=g),PG(o,()=>w.collisionDetector=o),PG(a,()=>w.collisionPriority=a),PG(_,()=>w.plugins=_,void 0,D8),PG(b,()=>w.transition=b,void 0,D8),PG(m,()=>w.modifiers=m,void 0,D8),PG(e.alignment,()=>w.alignment=e.alignment),{sortable:S,get isDragging(){return S.isDragging},get isDropping(){return S.isDropping},get isDragSource(){return S.isDragSource},get isDropTarget(){return S.isDropTarget},handleRef:(0,iM.useCallback)(e=>{w.handle=null!=e?e:void 0},[w]),ref:(0,iM.useCallback)(e=>{var i,n;(e||null==(i=w.element)||!i.isConnected||(null==(n=w.manager)?void 0:n.dragOperation.status.idle))&&(w.element=null!=e?e:void 0)},[w]),sourceRef:(0,iM.useCallback)(e=>{var i,n;(e||null==(i=w.source)||!i.isConnected||(null==(n=w.manager)?void 0:n.dragOperation.status.idle))&&(w.source=null!=e?e:void 0)},[w]),targetRef:(0,iM.useCallback)(e=>{var i,n;(e||null==(i=w.target)||!i.isConnected||(null==(n=w.manager)?void 0:n.dragOperation.status.idle))&&(w.target=null!=e?e:void 0)},[w])}}({id:e.id,index:i,disabled:!d});return(0,iN.jsxs)("div",{ref:u,className:["inline-flex items-center gap-2 px-2.5 py-1.5 rounded-lg border bg-card group transition-colors hover:bg-accent/30 min-w-0",p&&"opacity-50 shadow-lg scale-105",!d&&"opacity-70"].filter(Boolean).join(" "),style:{cursor:d?"grab":"default"},children:[(0,iN.jsx)(hz.AgentIcon,{agentId:e.agentConfigId,className:"h-6 w-6 shrink-0 rounded"}),(0,iN.jsx)("span",{className:"text-sm truncate max-w-[160px]",children:e.title}),(0,iN.jsx)(hP.Badge,{variant:R7[e.status],className:"text-[10px] shrink-0",children:l(`status.${e.status}`)}),(0,iN.jsxs)("div",{className:"flex items-center gap-0.5 shrink-0",children:[c&&(0,iN.jsx)(hv.Button,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>o(e),children:(0,iN.jsx)(rw.Pencil,{className:"h-3 w-3"})}),(c||"cancelled"===e.status||"done"===e.status)&&(0,iN.jsx)(hv.Button,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive hover:text-destructive opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>a(n,e.id),children:(0,iN.jsx)(nJ.Trash2,{className:"h-3 w-3"})}),"failed"===e.status&&(0,iN.jsx)(hv.Button,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>r(n,e.id),children:(0,iN.jsx)(R4,{className:"h-3 w-3"})}),h&&(0,iN.jsx)(hv.Button,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>s(n,e.id),children:(0,iN.jsx)(B8,{className:"h-3 w-3"})})]})]})}function B7({issue:e,workspaceId:i,issueTasks:n,agents:r,t:s,tTask:o,tc:a,retryTask:l,cancelTask:c,reorderTasks:h,createTask:d,updateTask:u,deleteTask:p}){let[f,m]=(0,iM.useState)(!1),[g,v]=(0,iM.useState)(null),[y,_]=(0,iM.useState)(""),[b,w]=(0,iM.useState)(""),[S,k]=(0,iM.useState)(""),C=async()=>{y.trim()&&(g?await u(i,g.id,{title:y.trim(),description:b.trim(),agentConfigId:S||void 0}):await d(i,e.id,y.trim(),b.trim(),S||void 0),_(""),w(""),k(""),v(null),m(!1))},T=e=>{v(e),_(e.title),w(e.description),k(e.agentConfigId??""),m(!0)},E=async(e,i)=>{await p(e,i)};return(0,iN.jsxs)("div",{className:"shrink-0 p-4 pb-2 max-h-[180px] overflow-y-auto",children:[(0,iN.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,iN.jsx)("h3",{className:"text-sm font-medium",children:s("detail.tasks",{count:n.length})}),(0,iN.jsxs)(rE.Dialog,{open:f,onOpenChange:e=>{m(e),e||v(null)},children:[(0,iN.jsx)(rE.DialogTrigger,{render:(0,iN.jsx)(hv.Button,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>{v(null),_(""),w(""),k(""),m(!0)}}),children:(0,iN.jsx)(ry.Plus,{className:"h-4 w-4"})}),(0,iN.jsxs)(rE.DialogContent,{children:[(0,iN.jsx)(rE.DialogHeader,{children:(0,iN.jsx)(rE.DialogTitle,{children:s(g?"detail.editTask":"detail.addTask")})}),(0,iN.jsxs)("div",{className:"space-y-3",children:[(0,iN.jsx)(hy.Input,{placeholder:s("detail.taskTitlePlaceholder"),value:y,onChange:e=>_(e.target.value),onKeyDown:e=>"Enter"===e.key&&e.preventDefault()}),(0,iN.jsx)(RG.Textarea,{placeholder:s("detail.taskDescriptionPlaceholder"),value:b,onChange:e=>w(e.target.value),rows:3}),r.length>0&&(0,iN.jsxs)("div",{className:"space-y-1",children:[(0,iN.jsx)("label",{className:"text-xs text-muted-foreground",children:"Agent"}),(0,iN.jsxs)("div",{className:"flex flex-wrap gap-1",children:[(0,iN.jsxs)("button",{type:"button",onClick:()=>k(""),className:(0,nQ.cn)("flex items-center gap-1.5 px-2 py-1 rounded-md text-xs transition-colors border",S?"border-transparent hover:bg-muted":"border-primary bg-primary/10 text-primary"),children:[(0,iN.jsx)("span",{className:"size-4 rounded bg-muted flex items-center justify-center text-[10px]",children:"—"}),s("detail.noAgent")]}),r.map(e=>(0,iN.jsxs)("button",{type:"button",onClick:()=>k(e.id),className:(0,nQ.cn)("flex items-center gap-1.5 px-2 py-1 rounded-md text-xs transition-colors border",S===e.id?"border-primary bg-primary/10 text-primary":"border-transparent hover:bg-muted"),children:[(0,iN.jsx)(hz.AgentIcon,{agentId:e.id,name:e.name,avatarUrl:e.avatarUrl,apiBase:e.apiBase,className:"size-4 rounded-full"}),(0,iN.jsx)("span",{className:"truncate max-w-[80px]",children:e.name}),S===e.id&&(0,iN.jsx)(hS.Check,{className:"size-3 shrink-0"})]},e.id))]})]}),(0,iN.jsx)(hv.Button,{onClick:C,disabled:!y.trim(),size:"sm",children:g?a("save"):s("detail.addTask")})]})]})]})]}),0===n.length?(0,iN.jsx)("div",{className:"text-sm text-muted-foreground",children:s("detail.noTasks")}):(0,iN.jsx)(P6,{onDragEnd:r=>{if(r.canceled)return;let s=r.operation?.source,o=r.operation?.target;if(!s||!o||s.id===o.id)return;let a=n.map(e=>e.id),l=a.indexOf(String(s.id)),c=a.indexOf(String(o.id));if(-1===l||-1===c)return;let d=Array.from(a),[u]=d.splice(l,1);d.splice(c,0,u),h(i,e.id,d)},children:(0,iN.jsx)("div",{className:"flex flex-wrap gap-2",children:n.map((e,n)=>(0,iN.jsx)(B9,{task:e,index:n,workspaceId:i,onRetry:l,onCancel:c,onEdit:T,onDelete:E,tTask:o},e.id))})})]})}var ze=e.i(799773);function zt({comment:e,expanded:i,workspaceId:n,onDelete:r,onUpdate:s,onExpandedChange:o}){let[a,l]=(0,iM.useState)(!1),[c,h]=(0,iM.useState)(e.content),[d,u]=(0,iM.useState)(!1),[p,f]=(0,iM.useState)(!1),m=(0,iM.useRef)(null),g=(0,iM.useRef)(null),v="user"===e.senderId,y=(0,hD.useAgentStore)(e=>e.agents),_=v?void 0:y.find(i=>i.id===e.senderId),b=hR(e=>e.setActiveChannel),w=hR(e=>e.loadMessages),S=e.metadata?.channelId,k=e.metadata?.messageId,C=e.metadata?.phase,T=e.metadata?.taskId,E=(0,n0.useTranslations)("issue"),N=(0,n0.useTranslations)("common");(0,iM.useEffect)(()=>{h(e.content),l(!1)},[e.id,e.content]),(0,iM.useEffect)(()=>{let e=g.current;e&&f(e.scrollHeight>300)},[e.content,i]);let M=v?N("you"):_?.name||e.senderId,O=localStorage.getItem("userAvatarUrl");(0,iM.useEffect)(()=>{a&&m.current&&(m.current.focus(),m.current.setSelectionRange(c.length,c.length))},[a,c.length]);let A=async()=>{await navigator.clipboard.writeText(e.content),u(!0),setTimeout(()=>u(!1),1500)},R=async()=>{S&&k&&(b(S),await w(n,S),window.setTimeout(()=>{document.getElementById(`msg-${k}`)?.scrollIntoView({block:"center",behavior:"smooth"})},80))},D=()=>{let i=c.trim();if(!i||i===e.content){l(!1),h(e.content);return}s(n,e.id,i),l(!1)};return(0,iN.jsx)("div",{className:"py-3 border-b last:border-b-0 group",children:(0,iN.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,iN.jsx)(hz.AgentIcon,{agentId:v?void 0:e.senderId,name:M,avatarUrl:v&&O||void 0,className:"size-7 rounded-full"}),(0,iN.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,iN.jsxs)("div",{className:"flex items-center gap-2 mb-0.5",children:[(0,iN.jsx)("span",{className:"text-xs font-medium",children:M}),e.metadata?.model&&(0,iN.jsx)("span",{className:"text-[10px] font-mono text-muted-foreground",children:e.metadata.model}),(0,iN.jsx)("span",{className:"text-[10px] text-muted-foreground",children:new Date(e.createdAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),(0,iN.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[e.senderRole&&(0,iN.jsx)("span",{className:"text-[10px] bg-muted px-1.5 py-0.5 rounded text-muted-foreground",children:e.senderRole}),C&&(0,iN.jsx)("span",{className:"text-[10px] bg-muted px-1.5 py-0.5 rounded text-muted-foreground",children:C.replace("_"," ")}),T&&(0,iN.jsx)("span",{className:"text-[10px] font-mono text-muted-foreground",children:E("message.task",{taskId:T.slice(0,8)})})]}),(0,iN.jsx)("div",{className:"flex items-center gap-2",children:S&&k?(0,iN.jsxs)(hv.Button,{variant:"ghost",size:"sm",className:"h-5 gap-1 px-1.5 text-[10px] text-muted-foreground",onClick:R,children:[(0,iN.jsx)(nG.ExternalLink,{className:"size-3"}),E("message.openMessage")]}):null}),a?(0,iN.jsx)("textarea",{ref:m,value:c,onChange:e=>h(e.target.value),onKeyDown:i=>{"Enter"!==i.key||i.shiftKey||(i.preventDefault(),D()),"Escape"===i.key&&(l(!1),h(e.content))},onBlur:D,className:"w-full text-sm bg-muted/50 rounded-lg px-3 py-2 resize-none focus:outline-none focus:ring-1 focus:ring-primary min-h-[60px]"}):(0,iN.jsxs)("div",{className:"relative",children:[(0,iN.jsx)("div",{ref:g,className:`text-sm whitespace-pre-wrap break-words ${!i?"max-h-[300px] overflow-hidden":""}`,children:e.content}),p&&!i&&(0,iN.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-16 bg-gradient-to-t from-background to-transparent flex items-end justify-center pb-1",children:(0,iN.jsx)(hv.Button,{variant:"ghost",size:"sm",className:"h-6 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{o?.(e.id,!0)},children:E("message.expandMore")})}),i&&p&&(0,iN.jsx)(hv.Button,{variant:"ghost",size:"sm",className:"h-6 mt-1 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{o?.(e.id,!1)},children:E("message.collapse")})]})]}),!a&&(0,iN.jsxs)("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",children:[(0,iN.jsx)(hv.Button,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>{l(!0),h(e.content)},children:(0,iN.jsx)(rw.Pencil,{className:"h-3 w-3"})}),(0,iN.jsx)(hv.Button,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:A,children:d?(0,iN.jsx)(hS.Check,{className:"h-3 w-3 text-green-500"}):(0,iN.jsx)(dk.Copy,{className:"h-3 w-3"})}),(0,iN.jsx)(hv.Button,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive hover:text-destructive",onClick:()=>r(e.id),children:(0,iN.jsx)(nJ.Trash2,{className:"h-3 w-3"})})]})]})})}function zi({comments:e,onNavigate:i}){let[n,r]=(0,iM.useState)(null),[s,o]=(0,iM.useState)(!1),[a,l]=(0,iM.useState)(0),c=(0,iM.useRef)(null),h=(0,n0.useTranslations)("common"),d=(0,iM.useCallback)(e=>{r(e),i(e)},[i]),u=(0,iM.useCallback)((e,i)=>{if(!i||!c.current)return;r(e);let n=c.current.getBoundingClientRect(),s=i.getBoundingClientRect();l(s.top-n.top+s.height/2)},[]);return 0===e.length?null:(0,iN.jsxs)("div",{ref:c,className:"absolute right-2 top-1/2 -translate-y-1/2 z-10 flex flex-col items-center",onMouseEnter:()=>o(!0),onMouseLeave:()=>{o(!1),r(null)},children:[(0,iN.jsx)("button",{className:`flex-shrink-0 mb-0.5 flex items-center justify-center size-5 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/80 transition-all ${s?"opacity-100":"opacity-0 pointer-events-none"} ${null===n||n<=0?"invisible":""}`,onClick:()=>{null!==n&&n>0&&d(n-1)},children:(0,iN.jsx)(RB.ChevronUp,{className:"size-3.5"})}),(0,iN.jsx)("div",{className:"flex-1 w-full max-h-[50vh] overflow-y-auto scrollbar-none",children:(0,iN.jsx)("div",{className:"flex flex-col gap-[3px] px-1 py-0.5",children:e.map((e,i)=>(0,iN.jsx)("div",{className:"flex justify-center",children:(0,iN.jsx)("button",{className:`h-[4px] rounded-full transition-all duration-150 ${n===i?"bg-primary w-6":"user"===e.senderId?"bg-primary/30 hover:bg-primary/50 w-5":"bg-muted-foreground/25 hover:bg-muted-foreground/40 w-5"}`,onClick:()=>d(i),onMouseEnter:e=>u(i,e.currentTarget)})},e.id))})}),(0,iN.jsx)("button",{className:`flex-shrink-0 mt-0.5 flex items-center justify-center size-5 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/80 transition-all ${s?"opacity-100":"opacity-0 pointer-events-none"} ${null===n||n>=e.length-1?"invisible":""}`,onClick:()=>{null!==n&&n<e.length-1&&d(n+1)},children:(0,iN.jsx)(r_.ChevronDown,{className:"size-3.5"})}),s&&null!==n&&(0,iN.jsxs)("div",{className:"absolute right-full mr-3 w-56 rounded-lg border bg-popover p-2.5 shadow-lg z-50 animate-in fade-in-0 zoom-in-95 duration-75",style:{top:a,transform:"translateY(-50%)"},children:[(0,iN.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,iN.jsx)("span",{className:"font-medium text-xs",children:"user"===e[n].senderId?h("you"):(0,hD.findAgentById)(e[n].senderId)?.name??e[n].senderId}),(0,iN.jsx)("span",{className:"text-[10px] text-muted-foreground",children:new Date(e[n].createdAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),(0,iN.jsxs)("p",{className:"text-xs text-muted-foreground line-clamp-3 leading-relaxed",children:[e[n].content.slice(0,150),e[n].content.length>150?"...":""]})]})]})}function zn({issue:e,workspaceId:i,comments:n,expandedCommentIds:r,commentsViewportRef:s,commentRefs:o,onDeleteComment:a,onUpdateComment:l,onExpandedChange:c,scrollToComment:h,t:d}){return(0,iN.jsxs)("div",{className:"flex-1 min-h-0 flex flex-col border-t",children:[(0,iN.jsx)("div",{className:"shrink-0 px-4 pt-2",children:(0,iN.jsx)("h3",{className:"text-sm font-medium mb-3",children:d("detail.comments",{count:n.length})})}),e.description&&(0,iN.jsx)("div",{className:"shrink-0 px-4 pb-3 border-b",children:(0,iN.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,iN.jsx)("div",{className:"flex items-center justify-center h-7 w-7 rounded-full bg-primary text-primary-foreground shrink-0",children:(0,iN.jsx)(ze.User,{className:"h-3.5 w-3.5"})}),(0,iN.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,iN.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,iN.jsx)("span",{className:"text-xs font-medium",children:d("detail.author")}),(0,iN.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:[d("detail.commented")," ",new Date(e.createdAt).toLocaleDateString()]})]}),(0,iN.jsx)("div",{className:"text-sm bg-muted/50 rounded-lg px-3 py-2 whitespace-pre-wrap",children:e.description})]})]})}),(0,iN.jsx)("div",{className:"flex-1 min-h-0 relative",children:n.length>0?(0,iN.jsxs)(iN.Fragment,{children:[(0,iN.jsxs)("div",{ref:s,className:"h-full overflow-y-auto",children:[n.map(e=>(0,iN.jsx)("div",{ref:i=>{i?o.current.set(e.id,i):o.current.delete(e.id)},className:"px-4",children:(0,iN.jsx)(zt,{comment:e,expanded:r.has(e.id),workspaceId:i,onDelete:a,onUpdate:l,onExpandedChange:c})},e.id)),(0,iN.jsx)("div",{className:"h-20 pointer-events-none"})]}),(0,iN.jsx)(zi,{comments:n,onNavigate:h})]}):null})]})}function zr({issue:e,workspaceId:i,open:n,onOpenChange:r,issueTasks:s,members:o,enabledAgents:a,onAddMembers:l,onDeleteIssue:c,t:h}){let[d,u]=(0,iM.useState)(!1),p=new Set(o),f=a.filter(e=>!p.has(e.id)).map(e=>({id:e.id,label:hW(e),description:e.role}));return(0,iN.jsxs)(A6.Sheet,{open:n,onOpenChange:r,children:[(0,iN.jsxs)(A6.SheetContent,{side:"right",className:"w-80 p-0 gap-0",children:[(0,iN.jsxs)(A6.SheetHeader,{className:"sr-only",children:[(0,iN.jsx)(A6.SheetTitle,{children:h("detail.tabInfo")}),(0,iN.jsx)(A6.SheetDescription,{children:e.title})]}),(0,iN.jsxs)("div",{className:"flex items-center gap-2 px-4 h-12 border-b shrink-0",children:[(0,iN.jsx)(RX,{className:"size-4 text-muted-foreground shrink-0"}),(0,iN.jsx)("span",{className:"text-sm font-medium truncate",children:e.title})]}),(0,iN.jsxs)(RE,{defaultValue:"info",className:"flex flex-col flex-1 min-h-0",children:[(0,iN.jsxs)(RM,{className:"w-full rounded-none border-b bg-transparent h-9 p-0 shrink-0",children:[(0,iN.jsxs)(RO,{value:"info",className:"flex-1 gap-1.5 data-[state=active]:shadow-none data-[state=active]:border-b-2 data-[state=active]:border-primary rounded-none",children:[(0,iN.jsx)(A4,{className:"size-3.5"}),h("detail.tabInfo")]}),(0,iN.jsxs)(RO,{value:"members",className:"flex-1 gap-1.5 data-[state=active]:shadow-none data-[state=active]:border-b-2 data-[state=active]:border-primary rounded-none",children:[(0,iN.jsx)(RR,{className:"size-3.5"}),h("detail.tabMembers")]})]}),(0,iN.jsxs)(A8.ScrollArea,{className:"min-h-0 flex-1",children:[(0,iN.jsxs)(RA,{value:"info",className:"p-4 mt-0 space-y-4",children:[(0,iN.jsxs)("div",{className:"space-y-2 text-sm",children:[(0,iN.jsxs)("div",{className:"flex justify-between py-1 border-b",children:[(0,iN.jsx)("span",{className:"text-muted-foreground",children:h("detail.infoStatus")}),(0,iN.jsx)(hP.Badge,{variant:R9[e.status],className:"text-[10px]",children:h(`status.${e.status}`)})]}),(0,iN.jsxs)("div",{className:"flex justify-between py-1 border-b",children:[(0,iN.jsx)("span",{className:"text-muted-foreground",children:h("detail.infoIssueId")}),(0,iN.jsxs)("span",{className:"font-mono text-xs",children:[e.id.slice(0,8),"..."]})]}),(0,iN.jsxs)("div",{className:"flex justify-between py-1 border-b",children:[(0,iN.jsx)("span",{className:"text-muted-foreground",children:h("detail.infoTaskCount")}),(0,iN.jsx)("span",{children:s.length})]}),(0,iN.jsxs)("div",{className:"flex justify-between py-1 border-b",children:[(0,iN.jsx)("span",{className:"text-muted-foreground",children:h("detail.infoMemberCount")}),(0,iN.jsx)("span",{children:o.length})]}),(0,iN.jsxs)("div",{className:"flex justify-between py-1 border-b",children:[(0,iN.jsx)("span",{className:"text-muted-foreground",children:h("detail.infoCreatedAt")}),(0,iN.jsx)("span",{children:new Date(e.createdAt).toLocaleDateString()})]}),(0,iN.jsxs)("div",{className:"flex justify-between py-1 border-b",children:[(0,iN.jsx)("span",{className:"text-muted-foreground",children:h("detail.infoUpdatedAt")}),(0,iN.jsx)("span",{children:new Date(e.updatedAt).toLocaleDateString()})]}),e.branch&&(0,iN.jsxs)("div",{className:"flex justify-between py-1 border-b",children:[(0,iN.jsx)("span",{className:"text-muted-foreground",children:h("detail.infoBranch")}),(0,iN.jsxs)("span",{className:"font-mono text-xs flex items-center gap-1",children:[(0,iN.jsx)(R6.GitBranch,{className:"h-3 w-3"}),e.branch]})]}),e.prUrl&&(0,iN.jsxs)("div",{className:"flex justify-between py-1 border-b",children:[(0,iN.jsx)("span",{className:"text-muted-foreground",children:h("detail.infoPr")}),(0,iN.jsx)("span",{className:"text-xs truncate max-w-[140px]",children:e.prUrl})]})]}),e.description&&(0,iN.jsxs)("div",{className:"space-y-1",children:[(0,iN.jsx)("span",{className:"text-xs text-muted-foreground",children:h("detail.infoDescription")}),(0,iN.jsx)("p",{className:"text-sm bg-muted/50 rounded-lg px-3 py-2 whitespace-pre-wrap",children:e.description})]})]}),(0,iN.jsxs)(RA,{value:"members",className:"p-4 mt-0 space-y-1",children:[o.map(e=>(0,iN.jsxs)("div",{className:"flex items-center gap-2 py-1.5",children:[(0,iN.jsx)(hz.AgentIcon,{agentId:"user"!==e?e:void 0,name:h$(a,e),className:"size-6 rounded-full"}),(0,iN.jsxs)("div",{className:"min-w-0",children:[(0,iN.jsx)("p",{className:"text-sm truncate",children:h$(a,e)}),(0,iN.jsx)("p",{className:"text-xs text-muted-foreground truncate",children:e})]})]},e)),(0,iN.jsxs)(hv.Button,{variant:"ghost",size:"sm",className:"w-full mt-2 text-xs text-muted-foreground",onClick:()=>u(!0),children:[(0,iN.jsx)(RD,{className:"size-3.5 mr-1"}),h("detail.addMember")]})]})]})]}),(0,iN.jsx)("div",{className:"shrink-0 p-3 border-t",children:(0,iN.jsxs)(hv.Button,{variant:"ghost",size:"sm",className:"w-full text-destructive hover:text-destructive",onClick:c,children:[(0,iN.jsx)(nJ.Trash2,{className:"size-3.5 mr-1.5"}),h("detail.deleteIssue")]})})]}),(0,iN.jsx)(Rj,{open:d,onOpenChange:u,candidates:f,onAdd:l})]})}function zs({workspaceId:e}){let{issues:i,activeIssueId:n,startIssue:r,resumeIssue:s,updateIssue:o,deleteIssue:a}=R$(),{tasks:l,loadTasks:c,retryTask:h,cancelTask:d,createTask:u,updateTask:p,deleteTask:f,reorderTasks:m}=RW(),g=(0,hD.useAgentStore)(e=>e.agents),v=(0,hD.useAgentStore)(e=>e.ensure),[y,_]=(0,iM.useState)(!1),[b,w]=(0,iM.useState)(!1),[S,k]=(0,iM.useState)([]),[C,T]=(0,iM.useState)(()=>new Set),[E,N]=(0,iM.useState)(!1),M=(0,iM.useRef)(null),O=(0,iM.useRef)(new Map),A=(0,n0.useTranslations)("issue"),R=(0,n0.useTranslations)("task"),D=(0,n0.useTranslations)("common"),L=i.find(e=>e.id===n),j=(0,iM.useCallback)(async i=>{let n=await fetch(`/api/workspaces/${e}/issues/${i}/comments`);n.ok&&k(await n.json())},[e]);(0,iM.useEffect)(()=>{L&&(c(e,L.id),Promise.resolve().then(()=>j(L.id)))},[L,e,c,j]),(0,iM.useEffect)(()=>{v()},[v]),(0,iM.useEffect)(()=>{if(!L)return;let i=rL(e),n=L.id,r=i.on("issue.updated",e=>{e.id===n&&j(n)});return()=>{r()}},[L,e,j]);let I=(0,iM.useMemo)(()=>Ol.configure({HTMLAttributes:{class:"mention"},suggestion:{char:"@",items:({query:e})=>{let i=e.toLowerCase();return g.filter(e=>!1!==e.enabled&&`${e.name} ${e.role} ${e.description||""}`.toLowerCase().includes(i)).slice(0,6).map(e=>({id:e.id,label:e.name||e.role,description:`${e.role}${e.description?` \xb7 ${e.description}`:""}`}))},command:({editor:e,range:i,props:n})=>{e.chain().focus().insertContentAt(i,[{type:"mention",attrs:n}]).run()},render:()=>Aq()}}),[g]),P=(0,iM.useMemo)(()=>AK(),[]),B=Ee({immediatelyRender:!1,extensions:[Oi,M9.configure({placeholder:A("detail.commentPlaceholder")}),I,P],editorProps:{attributes:{class:"tiptap tiptap-chat"},handleKeyDown:(e,i)=>"Enter"===i.key&&!i.shiftKey&&!document.querySelector(".suggestion-menu")&&(i.preventDefault(),z(),!0)},content:""}),z=(0,iM.useCallback)(()=>{var i;let n,r;if(!B||!L)return;let s=B.getText().trim();if(!s)return;let o=(i=B.getJSON(),n=new Set,(r=e=>{if(e&&("mention"===e.type&&"string"==typeof e.attrs?.id&&n.add(e.attrs.id),Array.isArray(e.content)))for(let i of e.content)r(i)})(i),[...n]);fetch(`/api/workspaces/${e}/issues/${L.id}/comments`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:s,mentions:o})}).then(async e=>{if(!e.ok)return;let i=await e.json();k(e=>[...e,i]),B.commands.clearContent(),setTimeout(()=>{M.current?.scrollTo({top:M.current.scrollHeight,behavior:"smooth"})},50)})},[B,L,e]),F=!!B?.getText().trim(),W=async i=>{if(!L)return;let n=await fetch(`/api/workspaces/${e}/issues/${L.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({members:hU(K,[...Y,...i])})}),r=await n.json();R$.getState().upsertIssue(r)},H=(0,iM.useCallback)(async i=>{L&&(await fetch(`/api/workspaces/${e}/issues/${L.id}/comments/${i}`,{method:"DELETE"}),k(e=>e.filter(e=>e.id!==i)))},[L,e]),$=(0,iM.useCallback)((e,i)=>{T(n=>{let r=new Set(n);return i?r.add(e):r.delete(e),r})},[]),U=(0,iM.useCallback)(async(e,i,n)=>{if(!L)return;let r=await fetch(`/api/workspaces/${e}/issues/${L.id}/comments/${i}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n})});if(!r.ok)return;let s=await r.json();k(e=>e.map(e=>e.id===s.id?s:e))},[L]),V=(0,iM.useCallback)(e=>{let i=S[e];i&&O.current.get(i.id)?.scrollIntoView({block:"start",behavior:"smooth"})},[S]),q=(0,iM.useMemo)(()=>{if(!L)return[];let e=l.filter(e=>e.issueId===L.id),i=L.tasks??[],n=new Map(i.map((e,i)=>[e,i])),r=i.length;return e.sort((e,i)=>(n.get(e.id)??r)-(n.get(i.id)??r))},[l,L]),Y=L?.members??[],K=g.filter(e=>!1!==e.enabled);return L?(0,iN.jsxs)("div",{className:"flex h-full overflow-hidden",children:[(0,iN.jsxs)("div",{className:"flex flex-col flex-1 min-w-0 overflow-hidden relative",children:[(0,iN.jsx)(De,{issue:L,workspaceId:e,t:A,setEditOpen:w,setInfoOpen:_,startIssue:r,resumeIssue:s,members:Y,enabledAgents:K}),(0,iN.jsx)(B7,{issue:L,workspaceId:e,issueTasks:q,agents:K,t:A,tTask:R,tc:D,retryTask:h,cancelTask:d,reorderTasks:m,createTask:u,updateTask:p,deleteTask:f}),(0,iN.jsx)(zn,{issue:L,workspaceId:e,comments:S,expandedCommentIds:C,commentsViewportRef:M,commentRefs:O,onDeleteComment:H,onUpdateComment:U,onExpandedChange:$,scrollToComment:V,t:A}),E?(0,iN.jsx)("div",{className:"absolute bottom-4 left-4 right-4 z-10 animate-in slide-in-from-bottom-2 duration-200",children:(0,iN.jsxs)("div",{className:"relative",children:[(0,iN.jsx)("button",{onClick:()=>N(!1),className:"absolute -top-2 -right-2 z-20 size-6 rounded-full bg-muted border shadow-sm flex items-center justify-center hover:bg-muted/80 transition-colors",children:(0,iN.jsx)(ru.X,{className:"size-3.5"})}),(0,iN.jsx)(Ou,{editor:B,canSubmit:F,onSubmit:z})]})}):(0,iN.jsxs)("button",{onClick:()=>N(!0),className:"absolute bottom-4 left-1/2 -translate-x-1/2 flex items-center gap-2 px-4 py-2 rounded-full bg-primary text-primary-foreground shadow-lg hover:bg-primary/90 transition-all z-10",children:[(0,iN.jsx)(nz.MessageSquare,{className:"size-4"}),(0,iN.jsx)("span",{className:"text-sm font-medium",children:A("detail.comment")})]})]}),(0,iN.jsx)(zr,{issue:L,workspaceId:e,open:y,onOpenChange:_,issueTasks:q,members:Y,enabledAgents:K,onAddMembers:W,onDeleteIssue:()=>{a(e,L.id)},t:A}),L&&(0,iN.jsx)(R1,{issue:L,open:b,onOpenChange:w,agents:K,onSave:async i=>{await o(e,L.id,i)}})]}):(0,iN.jsx)("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:A("detail.selectIssue")})}let zo=(0,nL.default)("file-code",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]]),za=(0,nL.default)("eye-off",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);var zl=e.i(415360),zc=e.i(129981);let zh=/not a git repository/i;function zd(e){return e instanceof Error&&zh.test(e.message)}let zu=(0,re.create)(e=>({status:null,diffs:[],selectedFile:null,log:[],branches:[],loading:!1,error:null,notGitRepo:!1,loadStatus:async i=>{try{let n=await fetch(`/api/workspaces/${i}/git/status`);if(!n.ok)throw Error(await n.text());let r=await n.json();e({status:r,notGitRepo:!1})}catch(i){e({error:i.message,notGitRepo:zd(i)})}},loadDiffs:async(i,n)=>{e({loading:!0});try{let r=n?`/api/workspaces/${i}/git/diff?path=${encodeURIComponent(n)}`:`/api/workspaces/${i}/git/diff`,s=await fetch(r);if(!s.ok)throw Error(await s.text());let o=await s.json();e({diffs:o,loading:!1,notGitRepo:!1})}catch(i){e({error:i.message,loading:!1,notGitRepo:zd(i)})}},loadLog:async i=>{try{let n=await fetch(`/api/workspaces/${i}/git/log`);if(!n.ok)throw Error(await n.text());let r=await n.json();e({log:r,notGitRepo:!1})}catch(i){e({error:i.message,notGitRepo:zd(i)})}},loadBranches:async i=>{try{let n=await fetch(`/api/workspaces/${i}/git/branches`);if(!n.ok)throw Error(await n.text());let r=await n.json();e({branches:r,notGitRepo:!1})}catch(i){e({error:i.message,notGitRepo:zd(i)})}},initRepo:async i=>{try{let n=await fetch(`/api/workspaces/${i}/git/init`,{method:"POST"});if(!n.ok)throw Error(await n.text());e({error:null,notGitRepo:!1})}catch(i){e({error:i.message})}},commit:async(i,n)=>{try{let e=await fetch(`/api/workspaces/${i}/git/commit`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:n})});if(!e.ok)throw Error(await e.text())}catch(i){e({error:i.message})}},discard:async(i,n)=>{try{let e=await fetch(`/api/workspaces/${i}/git/discard`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n})});if(!e.ok)throw Error(await e.text())}catch(i){e({error:i.message})}},discardAll:async i=>{try{let e=await fetch(`/api/workspaces/${i}/git/discard-all`,{method:"POST"});if(!e.ok)throw Error(await e.text())}catch(i){e({error:i.message})}},checkout:async(i,n)=>{try{let e=await fetch(`/api/workspaces/${i}/git/checkout`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:n})});if(!e.ok)throw Error(await e.text())}catch(i){e({error:i.message})}},push:async e=>{let i=await fetch(`/api/workspaces/${e}/git/push`,{method:"POST"});if(!i.ok)throw Error((await i.json().catch(()=>({error:"Push failed"}))).error)},pull:async e=>{let i=await fetch(`/api/workspaces/${e}/git/pull`,{method:"POST"});if(!i.ok)throw Error((await i.json().catch(()=>({error:"Pull failed"}))).error)},getRemotes:async e=>{let i=await fetch(`/api/workspaces/${e}/git/remotes`);if(!i.ok)throw Error(await i.text());return i.json()},addRemote:async(e,i,n)=>{let r=await fetch(`/api/workspaces/${e}/git/remotes`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:i,url:n})});if(!r.ok)throw Error((await r.json().catch(()=>({error:"Failed to add remote"}))).error)},selectFile:i=>e({selectedFile:i})}));function zp({workspaceId:e,onInitialized:i}){let n=(0,n0.useTranslations)("git.notInitialized"),r=zu(e=>e.initRepo),[s,o]=(0,iM.useState)(!1),a=(0,iM.useCallback)(async()=>{o(!0),await r(e),o(!1),i()},[e,r,i]);return(0,iN.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 p-4",children:[(0,iN.jsx)(R6.GitBranch,{size:32,className:"text-muted-foreground/40"}),(0,iN.jsx)("p",{className:"text-xs text-muted-foreground text-center",children:n("message")}),(0,iN.jsx)("button",{onClick:a,disabled:s,className:"text-xs px-3 py-1.5 rounded bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed",children:n(s?"initializing":"initialize")})]})}function zf({open:e,onOpenChange:i,onSubmit:n}){let r=(0,n0.useTranslations)("git.remote"),s=(0,n0.useTranslations)("common"),[o,a]=(0,iM.useState)("origin"),[l,c]=(0,iM.useState)(""),[h,d]=(0,iM.useState)(!1),u=async()=>{if(o.trim()&&l.trim()){d(!0);try{await n(o.trim(),l.trim()),c(""),i(!1)}finally{d(!1)}}};return(0,iN.jsx)(rE.Dialog,{open:e,onOpenChange:i,children:(0,iN.jsxs)(rE.DialogContent,{className:"sm:max-w-md",children:[(0,iN.jsx)(rE.DialogHeader,{children:(0,iN.jsx)(rE.DialogTitle,{children:r("bindTitle")})}),(0,iN.jsxs)("div",{className:"space-y-3",children:[(0,iN.jsxs)("div",{children:[(0,iN.jsx)("label",{className:"text-xs text-muted-foreground mb-1 block",children:r("nameLabel")}),(0,iN.jsx)(hy.Input,{value:o,onChange:e=>a(e.target.value),placeholder:r("namePlaceholder"),className:"h-8 text-xs"})]}),(0,iN.jsxs)("div",{children:[(0,iN.jsx)("label",{className:"text-xs text-muted-foreground mb-1 block",children:r("urlLabel")}),(0,iN.jsx)(hy.Input,{value:l,onChange:e=>c(e.target.value),placeholder:r("urlPlaceholder"),className:"h-8 text-xs",onKeyDown:e=>"Enter"===e.key&&e.preventDefault()})]})]}),(0,iN.jsxs)(rE.DialogFooter,{children:[(0,iN.jsx)(rE.DialogClose,{render:(0,iN.jsx)(hv.Button,{variant:"outline",size:"sm"}),children:s("cancel")}),(0,iN.jsx)(hv.Button,{size:"sm",onClick:u,disabled:!o.trim()||!l.trim()||h,children:r(h?"adding":"addRemote")})]})]})})}let zm=(0,rd.default)(()=>e.A(863812).then(e=>e.default),{loadableGenerated:{modules:[158480]},ssr:!1,loading:()=>(0,iN.jsx)("div",{className:"flex items-center justify-center h-32 text-muted-foreground text-xs",children:"Loading editor..."})}),zg={modified:"text-yellow-600",added:"text-green-600",deleted:"text-red-600",renamed:"text-blue-600",untracked:"text-gray-500"},zv={modified:"M",added:"A",deleted:"D",renamed:"R",untracked:"U"};function zy({workspaceId:e}){let i,n,r=(0,n0.useTranslations)("git.changes"),s=(0,n0.useTranslations)("common"),{status:o,diffs:a,selectedFile:l,loading:c,notGitRepo:h,branches:d,loadStatus:u,loadDiffs:p,loadBranches:f,commit:m,discard:g,discardAll:v,checkout:y,selectFile:_,push:b,pull:w,getRemotes:S,addRemote:k}=zu(),C=rt(e=>e.openFile),{resolvedTheme:T}=(0,rf.useTheme)(),[E,N]=(0,iM.useState)(""),[M,O]=(0,iM.useState)(!1),[A,R]=(0,iM.useState)(!1),[D,L]=(0,iM.useState)(!1),[j,I]=(0,iM.useState)(!1),[P,B]=(0,iM.useState)(!1),[z,F]=(0,iM.useState)(!1),[W,H]=(0,iM.useState)(""),[$,U]=(0,iM.useState)(!1),[V,q]=(0,iM.useState)(null),Y=(0,iM.useRef)(null),K=(0,gt.useIsMobile)(),X=(0,iM.useRef)(null),[J,G]=(0,iM.useState)(!1),Z=(0,iM.useCallback)(()=>{u(e),p(e)},[e,u,p]);(0,iM.useEffect)(()=>{Z(),f(e)},[e,Z,f]);let Q=(0,iM.useCallback)(e=>{_(e===l?null:e)},[l,_]),ee=(0,iM.useCallback)((i,n)=>{i.stopPropagation(),C(e,n)},[e,C]),et=(0,iM.useCallback)(async(i,n)=>{i.stopPropagation(),await g(e,n),Z()},[e,g,Z]),ei=(0,iM.useCallback)(async()=>{await v(e),Z()},[e,v,Z]),en=(0,iM.useCallback)(async i=>{L(!1),await y(e,i),Z(),f(e)},[e,y,Z,f]),er=(0,iM.useCallback)(async()=>{E.trim()&&(O(!0),_(null),await m(e,E.trim()),N(""),O(!1),Z())},[e,E,m,Z,_]),es=(0,iM.useCallback)(async()=>{if(!A&&!M){R(!0);try{let i=await fetch(`/api/workspaces/${e}/git/generate-commit-message`,{method:"POST"});if(!i.ok){let e=await i.json().catch(()=>({error:"Failed to generate"}));throw Error(e.error)}let n=await i.json();n.message&&N(n.message)}catch(e){rj.toast.error(e.message||r("failedCommitMessage"))}finally{R(!1)}}},[e,A,M]),eo=(0,iM.useCallback)(e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&er()},[er]),ea=(0,iM.useCallback)(async()=>{I(!0);try{if(!(await S(e)).length)return void B(!0);await b(e),await w(e),rj.toast.success(r("syncedSuccessfully")),Z()}catch(e){e.message?.includes("No remote")?B(!0):rj.toast.error(r("syncFailed"),{description:e.message})}finally{I(!1)}},[e,b,w,S,Z]),el=(0,iM.useCallback)(async(i,n)=>{await k(e,i,n),rj.toast.success(r("syncedSuccessfully"));try{await b(e),await w(e),rj.toast.success(r("syncedSuccessfully")),Z()}catch(e){rj.toast.error(r("syncFailed"),{description:e.message})}},[e,k,b,w,Z]),ec=(0,iM.useCallback)(async()=>{try{let i=await fetch(`/api/workspaces/${e}/files/content?path=.gitignore`),n=await i.json();H(n.content??"")}catch{H("")}F(!0)},[e]),eh=(0,iM.useCallback)(async()=>{U(!0);try{await fetch(`/api/workspaces/${e}/files/content`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:".gitignore",content:W})}),F(!1),Z()}finally{U(!1)}},[e,W,Z]),ed=(0,iM.useCallback)(async i=>{q(null);try{let n=await fetch(`/api/workspaces/${e}/files/content?path=.gitignore`),r=(await n.json()).content??"";if(r.split("\n").filter(Boolean).includes(i))return;let s=r&&!r.endsWith("\n")?r+"\n"+i+"\n":r+i+"\n";await fetch(`/api/workspaces/${e}/files/content`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:".gitignore",content:s})}),Z()}catch{}},[e,Z]),eu=(0,iM.useCallback)((e,i)=>{e.preventDefault(),e.stopPropagation(),q({x:e.clientX,y:e.clientY,path:i})},[]);if((0,iM.useEffect)(()=>{if(!V)return;let e=()=>q(null);return document.addEventListener("click",e),()=>document.removeEventListener("click",e)},[V]),(0,iM.useEffect)(()=>{let e=X.current;if(!e)return;let i=new ResizeObserver(e=>{for(let i of e)G(i.contentRect.height<300)});return i.observe(e),()=>i.disconnect()},[]),h)return(0,iN.jsxs)("div",{className:"flex flex-col h-full",children:[(0,iN.jsx)("div",{className:"flex items-center px-2 py-1.5 border-b",children:(0,iN.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:r("title")})}),(0,iN.jsx)(zp,{workspaceId:e,onInitialized:Z})]});let ep=a.find(e=>e.path===l),ef=(o?.files.length??0)>0;return(0,iN.jsxs)("div",{ref:X,className:`flex h-full overflow-hidden rounded-t-xl bg-background ${K?"flex-col":""}`,children:[(0,iN.jsxs)("div",{className:`flex flex-col bg-muted/20 ${K?"w-full border-b max-h-[40%]":J?"w-40 border-r":"w-64 border-r"}`,children:[(0,iN.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b",children:[(0,iN.jsxs)("div",{className:"relative flex-1 min-w-0",children:[(0,iN.jsxs)("button",{onClick:()=>L(!D),className:"flex items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground w-full",children:[(0,iN.jsx)(R6.GitBranch,{size:13,className:"shrink-0"}),(0,iN.jsx)("span",{className:"truncate",children:o?.branch??"..."}),o&&ef&&(0,iN.jsxs)("span",{className:"text-muted-foreground",children:["(",o.files.length,")"]}),(0,iN.jsx)(r_.ChevronDown,{size:12,className:"shrink-0"})]}),D&&(0,iN.jsxs)("div",{className:"absolute left-0 top-full z-50 mt-1 w-48 bg-popover border rounded shadow-md py-0.5 max-h-60 overflow-auto",children:[d.map(e=>(0,iN.jsx)("button",{onClick:()=>en(e.name),className:`w-full text-left px-2 py-1 text-xs hover:bg-accent truncate ${e.current?"font-semibold text-foreground":"text-muted-foreground"}`,children:e.name},e.name)),0===d.length&&(0,iN.jsx)("div",{className:"px-2 py-1 text-xs text-muted-foreground",children:r("noBranches")})]})]}),ef&&(0,iN.jsx)("button",{onClick:ei,className:"p-1 text-muted-foreground hover:text-destructive",title:r("discardAll"),children:(0,iN.jsx)(nJ.Trash2,{size:13})}),(0,iN.jsx)("button",{onClick:Z,className:"p-1 text-muted-foreground hover:text-foreground",title:s("refresh"),children:(0,iN.jsx)(ri.RefreshCw,{size:13})}),(0,iN.jsx)("button",{onClick:ec,className:"p-1 text-muted-foreground hover:text-foreground",title:r("editGitignore"),children:(0,iN.jsx)(nF.FileText,{size:13})})]}),D&&(0,iN.jsx)("div",{className:"fixed inset-0 z-40",onClick:()=>L(!1)}),(0,iN.jsxs)("div",{className:"flex-1 overflow-auto",children:[c&&!o&&(0,iN.jsx)("div",{className:"p-2 text-xs text-muted-foreground",children:s("loading")}),o?.files.map(e=>(0,iN.jsxs)("div",{onClick:()=>Q(e.path),onContextMenu:i=>eu(i,e.path),className:`group w-full text-left px-2 py-1 text-xs font-mono flex items-center gap-1.5 hover:bg-accent cursor-pointer ${l===e.path?"bg-accent":""}`,children:[(0,iN.jsx)("span",{className:`w-4 text-center font-bold shrink-0 ${zg[e.status]}`,children:zv[e.status]}),(0,iN.jsx)("span",{className:"truncate flex-1",children:e.path}),(0,iN.jsxs)("span",{className:"hidden group-hover:flex items-center gap-0.5 shrink-0",children:[(0,iN.jsx)("button",{onClick:i=>ee(i,e.path),className:"p-0.5 rounded hover:bg-accent/80",title:s("open"),children:(0,iN.jsx)(zo,{size:13})}),(0,iN.jsx)("button",{onClick:i=>et(i,e.path),className:"p-0.5 rounded hover:bg-accent/80",title:r("discardAll"),children:(0,iN.jsx)(R4,{size:13})})]})]},e.path)),o?.clean&&(0,iN.jsx)("div",{className:"p-2 text-xs text-muted-foreground",children:r("noChanges")})]}),(!J||K)&&ef&&(0,iN.jsxs)("div",{className:"border-t p-2 space-y-1.5",children:[(0,iN.jsxs)("div",{className:"relative",children:[(0,iN.jsx)("textarea",{value:E,onChange:e=>N(e.target.value),onKeyDown:eo,placeholder:r("commitMessagePlaceholder"),rows:3,className:"w-full resize-none text-xs px-2 pt-1 pr-8 pb-7 border rounded bg-background disabled:opacity-50",disabled:M||A}),(0,iN.jsx)("button",{type:"button",onClick:es,disabled:A||M||!ef,className:"absolute bottom-1.5 right-1.5 p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent disabled:opacity-30 disabled:cursor-not-allowed transition-colors",title:"AI generate commit message",children:A?(0,iN.jsx)(hk.Loader2,{size:14,className:"animate-spin"}):(0,iN.jsx)(zl.Sparkles,{size:14})})]}),(0,iN.jsx)("button",{onClick:er,disabled:!E.trim()||M,className:"w-full text-xs px-2 py-1 rounded bg-primary text-primary-foreground disabled:opacity-50 disabled:cursor-not-allowed",children:M?r("committing"):r("commit")})]}),!ef&&(o?.ahead??0)>0&&(0,iN.jsx)("div",{className:"border-t p-2",children:(0,iN.jsxs)("button",{onClick:ea,disabled:j,className:"w-full text-xs px-2 py-1 rounded bg-primary text-primary-foreground disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-1.5",children:[j?(0,iN.jsx)(hk.Loader2,{size:13,className:"animate-spin"}):(0,iN.jsx)(zc.Upload,{size:13}),j?r("syncing"):r("syncChanges")]})})]}),J&&!K&&ef&&(0,iN.jsxs)("div",{className:"w-52 border-r flex flex-col p-2 space-y-1.5",children:[(0,iN.jsxs)("div",{className:"relative flex-1 flex flex-col",children:[(0,iN.jsx)("textarea",{value:E,onChange:e=>N(e.target.value),onKeyDown:eo,placeholder:r("commitMessagePlaceholder"),className:"w-full flex-1 resize-none text-xs px-2 pt-1 pr-8 pb-1 border rounded bg-background disabled:opacity-50",disabled:M||A}),(0,iN.jsx)("button",{type:"button",onClick:es,disabled:A||M||!ef,className:"absolute top-1.5 right-1.5 p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent disabled:opacity-30 disabled:cursor-not-allowed transition-colors",title:"AI generate commit message",children:A?(0,iN.jsx)(hk.Loader2,{size:14,className:"animate-spin"}):(0,iN.jsx)(zl.Sparkles,{size:14})})]}),(0,iN.jsx)("button",{onClick:er,disabled:!E.trim()||M,className:"w-full text-xs px-2 py-1 rounded bg-primary text-primary-foreground disabled:opacity-50 disabled:cursor-not-allowed",children:M?r("committing"):r("commit")})]}),(0,iN.jsx)("div",{className:`flex-1 ${K?"min-h-0":""}`,children:ep?(0,iN.jsx)(gi,{oldContent:ep.oldContent,newContent:ep.newContent,path:ep.path}):(0,iN.jsx)("div",{className:"flex items-center justify-center h-full text-xs text-muted-foreground",children:ef?r("selectFileDiff"):r("noChangesToShow")})}),(0,iN.jsx)(rE.Dialog,{open:z,onOpenChange:F,children:(0,iN.jsxs)(rE.DialogContent,{className:"sm:max-w-2xl",children:[(0,iN.jsx)(rE.DialogHeader,{children:(0,iN.jsx)(rE.DialogTitle,{children:".gitignore"})}),(0,iN.jsx)("div",{className:"h-80 border rounded overflow-hidden",children:(0,iN.jsx)(zm,{height:"100%",language:"plaintext",value:W,onChange:e=>H(e??""),options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,padding:{top:8},lineNumbers:"on"},theme:"dark"===T?"vs-dark":"vs"})}),(0,iN.jsxs)(rE.DialogFooter,{children:[(0,iN.jsx)(rE.DialogClose,{render:(0,iN.jsx)(hv.Button,{variant:"outline",size:"sm"}),children:s("cancel")}),(0,iN.jsx)(hv.Button,{size:"sm",onClick:eh,disabled:$,children:$?s("saving"):s("save")})]})]})}),V&&(0,iN.jsxs)("div",{ref:Y,className:"fixed z-[100] bg-popover border rounded-lg shadow-md py-1 text-xs min-w-40 ring-1 ring-foreground/10",style:{left:V.x,top:V.y},children:[(0,iN.jsxs)("button",{className:"flex items-center gap-2 w-full px-3 py-1.5 hover:bg-accent text-left",onClick:()=>ed(V.path.split("/").pop()),children:[(0,iN.jsx)(za,{size:13}),(0,iN.jsx)("span",{children:r("ignoreThisFile")}),(0,iN.jsx)("span",{className:"ml-auto text-muted-foreground truncate max-w-24",children:V.path.split("/").pop()})]}),(0,iN.jsxs)("button",{className:"flex items-center gap-2 w-full px-3 py-1.5 hover:bg-accent text-left",onClick:()=>{let e=V.path.lastIndexOf("/"),i=e>=0?V.path.substring(0,e+1):"";i&&ed(i)},children:[(0,iN.jsx)(za,{size:13}),(0,iN.jsx)("span",{children:r("ignoreFilePath",{path:(i=V.path.lastIndexOf("/"))>=0?V.path.substring(0,i+1):V.path})}),(0,iN.jsx)("span",{className:"ml-auto text-muted-foreground truncate max-w-24",children:(n=V.path.lastIndexOf("/"))>=0?V.path.substring(0,n+1):V.path})]})]}),(0,iN.jsx)(zf,{open:P,onOpenChange:B,onSubmit:el})]})}function z_({count:e,kind:i}){return e<=0?null:(0,iN.jsx)("span",{className:"absolute -top-1 -right-1 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-foreground px-1 text-[9px] font-medium leading-none text-background",children:e})}function zb({workspaceId:e}){let i=(0,n0.useTranslations)("git.commits"),n=(0,n0.useTranslations)("common"),{log:r,loading:s,notGitRepo:o,status:a,loadLog:l,loadStatus:c,push:h,pull:d,getRemotes:u,addRemote:p}=zu(),[f,m]=(0,iM.useState)(null),[g,v]=(0,iM.useState)(!1),[y,_]=(0,iM.useState)(null),b=a?.ahead??0,w=a?.behind??0,S=b>0?b:-1,k=(0,iM.useCallback)(()=>{l(e),c(e)},[e,l,c]);(0,iM.useEffect)(()=>{k()},[k]);let C=async n=>{m(n);try{if(!(await u(e)).length){_(n),v(!0);return}await T(n)}catch(e){e.message?.includes("No remote")?(_(n),v(!0)):rj.toast.error("push"===n?i("pushFailed"):i("pullFailed"),{description:e.message})}finally{m(null)}},T=async n=>{"push"===n?(await h(e),rj.toast.success(i("pushedSuccessfully"))):(await d(e),rj.toast.success(i("pulledSuccessfully"))),k()},E=async(n,r)=>{await p(e,n,r),rj.toast.success(i("remoteAdded")),y&&(await T(y),_(null))};return o?(0,iN.jsxs)("div",{className:"flex flex-col h-full overflow-hidden rounded-t-xl bg-background",children:[(0,iN.jsx)("div",{className:"flex items-center px-2 py-1.5 border-b",children:(0,iN.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:i("title")})}),(0,iN.jsx)(zp,{workspaceId:e,onInitialized:k})]}):(0,iN.jsxs)("div",{className:"flex flex-col h-full overflow-hidden rounded-t-xl bg-background",children:[(0,iN.jsxs)("div",{className:"flex items-center justify-between px-2 py-1.5 border-b",children:[(0,iN.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:r.length>0?i("titleWithCount",{count:r.length}):i("title")}),(0,iN.jsxs)("div",{className:"flex items-center gap-1",children:[(0,iN.jsxs)("button",{onClick:()=>C("push"),disabled:null!==f,className:"relative p-1 text-muted-foreground hover:text-foreground disabled:opacity-50",title:b>0?i("pushNCommits",{count:b}):"Push",children:["push"===f?(0,iN.jsx)(hk.Loader2,{size:13,className:"animate-spin"}):(0,iN.jsx)(zc.Upload,{size:13}),(0,iN.jsx)(z_,{count:b,kind:"push"})]}),(0,iN.jsxs)("button",{onClick:()=>C("pull"),disabled:null!==f,className:"relative p-1 text-muted-foreground hover:text-foreground disabled:opacity-50",title:w>0?i("pullNCommits",{count:w}):"Pull",children:["pull"===f?(0,iN.jsx)(hk.Loader2,{size:13,className:"animate-spin"}):(0,iN.jsx)(rk.Download,{size:13}),(0,iN.jsx)(z_,{count:w,kind:"pull"})]}),(0,iN.jsx)("button",{onClick:k,className:"text-muted-foreground hover:text-foreground",children:(0,iN.jsx)(ri.RefreshCw,{size:13})})]})]}),(0,iN.jsxs)("div",{className:"flex-1 overflow-auto",children:[s&&!r.length&&(0,iN.jsx)("div",{className:"p-2 text-xs text-muted-foreground",children:n("loading")}),r.map((e,n)=>{let r=n===S;return(0,iN.jsxs)("div",{className:`px-2 py-1.5 border-b hover:bg-accent cursor-default ${r?"border-l-2 border-l-blue-500":""}`,children:[(0,iN.jsxs)("div",{className:"flex items-center gap-2",children:[r&&(0,iN.jsx)("span",{title:i("remoteTrackingBranch"),children:(0,iN.jsx)(n$,{size:13,className:"shrink-0 text-blue-500"})}),(0,iN.jsx)("code",{className:"text-xs font-mono text-blue-600 shrink-0",children:e.hash.slice(0,7)}),(0,iN.jsx)("span",{className:"text-xs truncate",children:e.message.split("\n")[0]})]}),(0,iN.jsxs)("div",{className:`flex items-center gap-2 mt-0.5 ${r?"pl-[21px]":""}`,children:[(0,iN.jsx)("span",{className:"text-xs text-muted-foreground",children:e.author}),(0,iN.jsx)("span",{className:"text-xs text-muted-foreground",children:new Date(e.date).toLocaleDateString()})]})]},e.hash)}),!s&&!r.length&&(0,iN.jsx)("div",{className:"p-2 text-xs text-muted-foreground",children:i("noCommits")})]}),(0,iN.jsx)(zf,{open:g,onOpenChange:v,onSubmit:E})]})}function zx({workspaceId:e}){let i=(0,n0.useTranslations)("git.graph"),n=(0,n0.useTranslations)("common"),r=(0,n0.useTranslations)("home.time"),{log:s,status:o,notGitRepo:a,loadLog:l,loadStatus:c}=zu(),h=(0,iM.useCallback)(()=>{l(e),c(e)},[e,l,c]);if((0,iM.useEffect)(()=>{h()},[h]),a)return(0,iN.jsxs)("div",{className:"flex flex-col h-full overflow-hidden rounded-t-xl bg-background",children:[(0,iN.jsx)("div",{className:"flex items-center px-2 py-1.5 border-b",children:(0,iN.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:i("title")})}),(0,iN.jsx)(zp,{workspaceId:e,onInitialized:h})]});let d=o?.branch??"—",u=o?.ahead??0,p=o?.behind??0;return(0,iN.jsxs)("div",{className:"flex flex-col h-full overflow-hidden rounded-t-xl bg-background",children:[(0,iN.jsxs)("div",{className:"flex items-center justify-between px-2 py-1.5 border-b",children:[(0,iN.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,iN.jsx)(R6.GitBranch,{size:14}),(0,iN.jsx)("span",{className:"font-mono font-medium",children:d}),u>0&&(0,iN.jsxs)("span",{className:"text-green-600",children:["↑",u]}),p>0&&(0,iN.jsxs)("span",{className:"text-red-500",children:["↓",p]})]}),(0,iN.jsx)("button",{onClick:h,className:"text-muted-foreground hover:text-foreground",children:(0,iN.jsx)(ri.RefreshCw,{size:13})})]}),(0,iN.jsxs)("div",{className:"flex-1 overflow-auto pl-4",children:[s.map((e,i)=>{let n=i===s.length-1;return(0,iN.jsxs)("div",{className:"flex items-start gap-2 py-1",children:[(0,iN.jsxs)("div",{className:"flex flex-col items-center shrink-0 pt-1",children:[(0,iN.jsx)(n$,{size:14,className:"text-blue-500 shrink-0"}),!n&&(0,iN.jsx)("div",{className:"w-px flex-1 bg-border min-h-4"})]}),(0,iN.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,iN.jsx)("div",{className:"text-xs truncate",children:e.message.split("\n")[0]}),(0,iN.jsxs)("div",{className:"flex items-center gap-2 mt-0.5",children:[(0,iN.jsx)("code",{className:"text-xs font-mono text-muted-foreground",children:e.hash.slice(0,7)}),(0,iN.jsx)("span",{className:"text-xs text-muted-foreground",children:e.author}),(0,iN.jsx)("span",{className:"text-xs text-muted-foreground",children:function(e,i){let n=Math.floor((Date.now()-new Date(e).getTime())/6e4);if(n<1)return i("justNow");if(n<60)return i("minutesAgo",{n:n});let r=Math.floor(n/60);if(r<24)return i("hoursAgo",{n:r});let s=Math.floor(r/24);return s<30?i("daysAgo",{n:s}):new Date(e).toLocaleDateString()}(e.date,r)})]})]})]},e.hash)}),!s.length&&(0,iN.jsx)("div",{className:"p-2 text-xs text-muted-foreground",children:n("noData")})]})]})}var zw=e.i(588591),zS=e.i(36539),zS=zS,zk=e.i(92457);let zC=(0,nL.default)("qr-code",[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]]);var zT=e.i(515104);function zE({workspaceId:e}){var i;let n=(0,n0.useTranslations)("projectSettings"),r=(0,n0.useTranslations)("common"),[s,o]=(0,iM.useState)(null),[a,l]=(0,iM.useState)(""),[c,h]=(0,iM.useState)(""),[d,u]=(0,iM.useState)(!0),[p,f]=(0,iM.useState)(!1),[m,g]=(0,iM.useState)(!1),[v,y]=(0,iM.useState)(!1),[_,b]=(0,iM.useState)(!1),[w,S]=(0,iM.useState)(!1),[k,C]=(0,iM.useState)(!1),[T,E]=(0,iM.useState)({status:"idle"}),N=(0,iM.useRef)(!1),[M,O]=(0,iM.useState)(!1),[A,R]=(0,iM.useState)("default"),[D,L]=(0,iM.useState)(zM()),j=hR(e=>e.channels),I=R$(e=>e.issues),P=hR(e=>e.loadChannels),B=R$(e=>e.loadIssues);(0,iM.useEffect)(()=>{Promise.all([fetch(`/api/workspaces/${e}`).then(e=>e.json()),fetch(`/api/workspaces/${e}/prompt`).then(e=>e.json()),P(e),B(e)]).then(([e,i])=>{o(e),l(i.prompt??""),h(i.prompt??""),L(e.notificationSettings??zM()),u(!1),(0,zT.getNotificationPermission)().then(R)}).catch(()=>u(!1))},[e,P,B]);let z=s?.autoProcessIssues!==!1,F=a!==c,W=(0,hD.useAgentStore)(e=>e.agents).filter(e=>"bot"===e.role&&!1!==e.enabled),H=!!(D.wechat?.token&&D.wechat?.accountId);(0,iM.useEffect)(()=>{if(!D.enabled||"wechat"!==D.provider||!["wait","scaned"].includes(T.status))return;let i=window.setInterval(()=>{N.current||(N.current=!0,fetch(`/api/workspaces/${e}/notifications/wechat/qr?poll=1`,{method:"POST"}).then(async e=>{let i=await e.json().catch(()=>null);if(!e.ok)throw Error(i?.error||"Failed to poll WeChat QR status");E({status:i.status??"wait",qrcodeImgContent:i.qrcodeImgContent??T.qrcodeImgContent,accountId:i.accountId,baseUrl:i.baseUrl}),i.workspace&&(o(i.workspace),L(i.workspace.notificationSettings??zM()),rj.toast.success(n("wechat.connectedToast")))}).catch(e=>{rj.toast.error(n("wechat.pollFailed"),{description:e instanceof Error?e.message:void 0})}).finally(()=>{N.current=!1}))},2e3);return()=>window.clearInterval(i)},[D.enabled,D.provider,T.status,T.qrcodeImgContent,e]);let $=async i=>{if(s&&!p){f(!0);try{let n=await fetch(`/api/workspaces/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({autoProcessIssues:i})}),r=await n.json();o(r)}finally{f(!1)}}},U=async()=>{if(!m){g(!0);try{let i=await fetch(`/api/workspaces/${e}/prompt`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:a})});if(!i.ok){let e=await i.json().catch(()=>null);throw Error(e?.error||"Failed to save workspace prompt")}let r=await i.json();l(r.prompt),h(r.prompt),rj.toast.success(n("prompt.saveSuccess"))}catch(e){rj.toast.error(n("prompt.saveFailed"),{description:e instanceof Error?e.message:void 0})}finally{g(!1)}}},V=async i=>{if(!s||v)return null;y(!0);try{let n=await fetch(`/api/workspaces/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({notificationSettings:i})});if(!n.ok){let e=await n.json().catch(()=>null);throw Error(e?.error||"Failed to save notification settings")}let r=await n.json();return o(r),L(r.notificationSettings??zM()),r}catch(e){return rj.toast.error(n("notifications.saveFailed"),{description:e instanceof Error?e.message:void 0}),null}finally{y(!1)}},q=e=>{let i={...D,...e,lark:{...D.lark,...e.lark},wechat:{...D.wechat,...e.wechat}};L(i),V(i)},Y=async()=>{if(!_){b(!0);try{if(!await V(D))throw Error("Failed to save notification settings");let i=await fetch(`/api/workspaces/${e}/notifications/start`,{method:"POST"});if(!i.ok){let e=await i.json().catch(()=>null);throw Error(e?.error||"Failed to start notification service")}let r=await i.json();r.workspace?(o(r.workspace),L(r.workspace.notificationSettings??zM())):L({...D,serviceRunning:!0}),rj.toast.success(n("notifications.startSuccess"))}catch(e){rj.toast.error(n("notifications.startFailed"),{description:e instanceof Error?e.message:void 0})}finally{b(!1)}}},K=async()=>{if(!_){b(!0);try{let i=await fetch(`/api/workspaces/${e}/notifications/stop`,{method:"POST"});if(!i.ok){let e=await i.json().catch(()=>null);throw Error(e?.error||"Failed to stop notification service")}let r=await i.json();r.workspace?(o(r.workspace),L(r.workspace.notificationSettings??zM())):L({...D,serviceRunning:!1}),rj.toast.success(n("notifications.stopSuccess"))}catch(e){rj.toast.error(n("notifications.stopFailed"),{description:e instanceof Error?e.message:void 0})}finally{b(!1)}}},X=async()=>{if(!w){S(!0);try{let i=await fetch(`/api/workspaces/${e}/notifications/test`,{method:"POST"}),r=await i.json().catch(()=>null);if(!i.ok)throw Error(r?.reason||r?.error||"Failed to send test notification");rj.toast.success(n("notifications.testSuccess"))}catch(e){rj.toast.error(n("notifications.testFailed"),{description:e instanceof Error?e.message:void 0})}finally{S(!1)}}},J=async()=>{if(!k){C(!0);try{if(!await V({...D,provider:"wechat"}))throw Error("Failed to save notification settings");let i=await fetch(`/api/workspaces/${e}/notifications/wechat/qr${H?"?refresh=1":""}`,{method:"POST"}),n=await i.json().catch(()=>null);if(!i.ok)throw Error(n?.error||"Failed to get WeChat QR code");E({status:n.status??"wait",qrcodeImgContent:n.qrcodeImgContent,accountId:n.accountId,baseUrl:n.baseUrl}),n.workspace&&(o(n.workspace),L(n.workspace.notificationSettings??zM()))}catch(e){rj.toast.error(n("wechat.getQrFailed"),{description:e instanceof Error?e.message:void 0})}finally{C(!1)}}};return d?(0,iN.jsxs)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:[(0,iN.jsx)(hk.Loader2,{className:"h-4 w-4 animate-spin mr-2"}),n("loading")]}):s?(0,iN.jsxs)(A8.ScrollArea,{className:"h-full",children:[(0,iN.jsx)("div",{className:"flex items-center px-2 py-1.5 border-b text-xs font-medium text-muted-foreground",children:(0,iN.jsx)("span",{children:n("title")})}),(0,iN.jsxs)("div",{className:"p-4 space-y-6",children:[(0,iN.jsxs)("div",{className:"space-y-3",children:[(0,iN.jsx)("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:n("info.title")}),(0,iN.jsx)(zO,{icon:(0,iN.jsx)(nP.FolderOpen,{size:14}),label:n("info.path"),value:s.boundDirs[0]??"-"}),(0,iN.jsx)(zO,{icon:(0,iN.jsx)(nj,{size:14}),label:n("info.channels"),value:String(j.length)}),(0,iN.jsx)(zO,{icon:(0,iN.jsx)(nI,{size:14}),label:n("info.issues"),value:String(I.length)})]}),(0,iN.jsxs)("div",{className:"space-y-3",children:[(0,iN.jsx)("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:n("automation.title")}),(0,iN.jsxs)("div",{className:"flex items-center justify-between rounded-md border px-3 py-2.5",children:[(0,iN.jsxs)("div",{className:"space-y-0.5 pr-4",children:[(0,iN.jsx)(hb.Label,{htmlFor:"auto-process",className:"text-sm font-medium",children:n("automation.autoProcess")}),(0,iN.jsx)("p",{className:"text-xs text-muted-foreground",children:n("automation.autoProcessDescription")})]}),(0,iN.jsxs)("div",{className:"flex items-center gap-2",children:[p&&(0,iN.jsx)(hk.Loader2,{className:"h-3 w-3 animate-spin text-muted-foreground"}),(0,iN.jsx)(h_.Switch,{id:"auto-process",checked:z,onCheckedChange:$,disabled:p})]})]})]}),(0,iN.jsxs)("div",{className:"space-y-3",children:[(0,iN.jsx)("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:n("notifications.title")}),(0,iN.jsxs)("div",{className:"space-y-4 rounded-md border px-3 py-3",children:[(0,iN.jsxs)("div",{className:"flex items-center justify-between",children:[(0,iN.jsxs)("div",{className:"space-y-0.5 pr-4",children:[(0,iN.jsx)(hb.Label,{htmlFor:"message-notifications",className:"text-sm font-medium",children:n("notifications.messageNotifications")}),(0,iN.jsx)("p",{className:"text-xs text-muted-foreground",children:n("notifications.messageNotificationsDescription")})]}),(0,iN.jsxs)("div",{className:"flex items-center gap-2",children:[v&&(0,iN.jsx)(hk.Loader2,{className:"h-3 w-3 animate-spin text-muted-foreground"}),(0,iN.jsx)(h_.Switch,{id:"message-notifications",checked:D.enabled,onCheckedChange:e=>q({enabled:e}),disabled:v})]})]}),D.enabled&&(0,iN.jsxs)("div",{className:"space-y-4",children:[(0,iN.jsxs)(RE,{value:D.provider,onValueChange:e=>q({provider:e}),children:[(0,iN.jsxs)(RM,{className:"grid w-full grid-cols-3",children:[(0,iN.jsx)(RO,{value:"lark",children:n("notifications.lark")}),(0,iN.jsx)(RO,{value:"wechat",children:n("notifications.wechat")}),(0,iN.jsx)(RO,{value:"native",children:n("notifications.native")})]}),(0,iN.jsxs)(RA,{value:"lark",className:"space-y-3 pt-2",children:[(0,iN.jsxs)("div",{className:"grid gap-2",children:[(0,iN.jsx)(hb.Label,{htmlFor:"lark-app-id",className:"text-xs text-muted-foreground",children:n("notifications.appId")}),(0,iN.jsx)(hy.Input,{id:"lark-app-id",value:D.lark?.appId??"",onChange:e=>L({...D,lark:{...D.lark,appId:e.target.value}}),placeholder:"cli_xxx",disabled:_})]}),(0,iN.jsxs)("div",{className:"grid gap-2",children:[(0,iN.jsx)(hb.Label,{htmlFor:"lark-app-secret",className:"text-xs text-muted-foreground",children:n("notifications.appSecret")}),(0,iN.jsx)(hy.Input,{id:"lark-app-secret",type:"password",value:D.lark?.appSecret??"",onChange:e=>L({...D,lark:{...D.lark,appSecret:e.target.value}}),placeholder:"app secret",disabled:_})]}),(0,iN.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,iN.jsxs)(hv.Button,{type:"button",size:"sm",variant:D.serviceRunning?"outline":"default",onClick:D.serviceRunning?K:Y,disabled:_||v||!D.lark?.appId||!D.lark?.appSecret,children:[_?(0,iN.jsx)(hk.Loader2,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):(0,iN.jsx)(Oh,{className:"mr-2 h-3.5 w-3.5"}),D.serviceRunning?n("notifications.stopService"):n("notifications.startService")]}),(0,iN.jsxs)(hv.Button,{type:"button",size:"sm",variant:"outline",onClick:X,disabled:w||v||!D.serviceRunning,children:[w&&(0,iN.jsx)(hk.Loader2,{className:"mr-2 h-3.5 w-3.5 animate-spin"}),n("notifications.testSend")]})]})]}),(0,iN.jsxs)(RA,{value:"wechat",className:"space-y-3 pt-2",children:[(0,iN.jsxs)("div",{className:"flex items-center justify-between gap-3 rounded-md border px-3 py-2.5",children:[(0,iN.jsxs)("div",{className:"min-w-0",children:[(0,iN.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium",children:[H?(0,iN.jsx)(dN,{className:"h-4 w-4 text-emerald-600"}):(0,iN.jsx)(zC,{className:"h-4 w-4"}),n("wechat.robot")]}),(0,iN.jsx)("p",{className:"mt-1 truncate text-xs text-muted-foreground",children:H?n("wechat.connected",{accountId:D.wechat?.accountId??""}):"scaned"===T.status?n("wechat.scanned"):"expired"===T.status?n("wechat.expired"):n("wechat.scanQr")})]}),(0,iN.jsxs)(hv.Button,{type:"button",size:"sm",variant:"outline",onClick:J,disabled:k||v||_,children:[k?(0,iN.jsx)(hk.Loader2,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):(0,iN.jsx)(ri.RefreshCw,{className:"mr-2 h-3.5 w-3.5"}),H?n("wechat.refreshLogin"):n("wechat.getQr")]})]}),T.qrcodeImgContent&&!H&&(0,iN.jsxs)("div",{className:"flex items-center gap-3 rounded-md border border-dashed px-3 py-3",children:[(0,iN.jsx)("img",{src:(i=T.qrcodeImgContent,`https://api.qrserver.com/v1/create-qr-code/?size=180x180&margin=8&data=${encodeURIComponent(i)}`),alt:"WeChat robot login QR code",className:"h-36 w-36 shrink-0 rounded border bg-white p-2"}),(0,iN.jsxs)("div",{className:"min-w-0 space-y-1 text-xs text-muted-foreground",children:[(0,iN.jsx)("p",{children:n("wechat.status",{status:"scaned"===T.status?"scanned":T.status})}),(0,iN.jsx)("p",{className:"break-all",children:n("wechat.loginUrl",{url:T.qrcodeImgContent})})]})]}),(0,iN.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,iN.jsxs)(hv.Button,{type:"button",size:"sm",variant:D.serviceRunning?"outline":"default",onClick:D.serviceRunning?K:Y,disabled:_||v||!H,children:[_?(0,iN.jsx)(hk.Loader2,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):(0,iN.jsx)(Oh,{className:"mr-2 h-3.5 w-3.5"}),D.serviceRunning?n("notifications.stopService"):n("notifications.startService")]}),(0,iN.jsxs)(hv.Button,{type:"button",size:"sm",variant:"outline",onClick:X,disabled:w||v||!D.serviceRunning,children:[w&&(0,iN.jsx)(hk.Loader2,{className:"mr-2 h-3.5 w-3.5 animate-spin"}),n("notifications.testSend")]})]})]}),(0,iN.jsxs)(RA,{value:"native",className:"space-y-3 pt-2",children:[(0,iN.jsx)("p",{className:"text-xs text-muted-foreground",children:n("notifications.nativeDescription")}),(0,iN.jsxs)("div",{className:"flex items-center justify-between gap-3 rounded-md border px-3 py-2.5",children:[(0,iN.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,iN.jsx)(zk.Monitor,{className:"h-4 w-4 text-muted-foreground"}),(0,iN.jsxs)("span",{className:"font-medium",children:["granted"===A&&(0,iN.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,iN.jsx)(dN,{className:"h-4 w-4 text-emerald-600"}),n("notifications.nativePermissionGranted")]}),"denied"===A&&n("notifications.nativePermissionDenied"),"default"===A&&n("notifications.nativePermissionDefault"),"unsupported"===A&&n("notifications.nativePermissionUnsupported")]})]}),"unsupported"!==A&&"granted"!==A&&(0,iN.jsx)(hv.Button,{type:"button",size:"sm",variant:"outline",onClick:async()=>{let e=await (0,zT.requestNotificationPermission)();R(e),"granted"===e?rj.toast.success(n("notifications.nativePermissionGrantedToast")):"denied"===e&&rj.toast.error(n("notifications.nativePermissionDeniedToast"))},disabled:"denied"===A,children:n("notifications.nativeRequestPermission")})]}),(0,iN.jsx)("div",{className:"flex flex-wrap gap-2",children:(0,iN.jsx)(hv.Button,{type:"button",size:"sm",variant:"outline",onClick:async()=>{try{await (0,zT.sendNativeNotification)("Agent Spaces",n("notifications.nativeTestSuccess")),rj.toast.success(n("notifications.nativeTestSuccess"))}catch{rj.toast.error(n("notifications.nativeTestFailed"))}},disabled:"granted"!==A,children:n("notifications.testSend")})})]})]}),(0,iN.jsxs)("div",{className:"space-y-2",children:[(0,iN.jsxs)("div",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground",children:[(0,iN.jsx)(hL.Bot,{className:"h-3.5 w-3.5"}),n("botAgent.title")]}),(0,iN.jsxs)("div",{className:"flex gap-2",children:[(0,iN.jsxs)("select",{value:D.botAgentId??"",onChange:e=>{q({botAgentId:e.target.value||void 0})},disabled:v,className:"h-8 min-w-0 flex-1 rounded-lg border border-input bg-transparent px-2.5 text-sm outline-none focus-visible:border-ring dark:bg-input/30",children:[(0,iN.jsx)("option",{value:"",children:n("botAgent.selectAgent")}),W.map(e=>(0,iN.jsx)("option",{value:e.id,children:e.name},e.id))]}),(0,iN.jsx)(hv.Button,{type:"button",size:"sm",variant:"outline",onClick:()=>O(!0),children:r("manage")})]})]}),(0,iN.jsxs)("div",{className:"space-y-2",children:[(0,iN.jsxs)("div",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground",children:[(0,iN.jsx)(zS.default,{className:"h-3.5 w-3.5"}),n("events.title")]}),(0,iN.jsx)("div",{className:"grid gap-2",children:zN.map(e=>(0,iN.jsxs)("label",{className:"flex items-center gap-2 rounded-md border px-3 py-2 text-sm",children:[(0,iN.jsx)("input",{type:"checkbox",className:"h-4 w-4 accent-primary",checked:D.events.includes(e.value),onChange:i=>{var n,r;let s;return n=e.value,r=i.target.checked,s=new Set(D.events),void(r?s.add(n):s.delete(n),q({events:Array.from(s)}))},disabled:v}),(0,iN.jsx)("span",{children:n(e.labelKey)})]},e.value))})]})]})]})]}),(0,iN.jsxs)("div",{className:"space-y-3",children:[(0,iN.jsx)("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:n("prompt.title")}),(0,iN.jsxs)("div",{className:"space-y-3 rounded-md border px-3 py-3",children:[(0,iN.jsxs)("div",{className:"space-y-0.5",children:[(0,iN.jsx)(hb.Label,{htmlFor:"workspace-prompt",className:"text-sm font-medium",children:n("prompt.workspacePrompt")}),(0,iN.jsx)("p",{className:"text-xs text-muted-foreground",children:n("prompt.description")})]}),(0,iN.jsx)(RG.Textarea,{id:"workspace-prompt",value:a,onChange:e=>l(e.target.value),className:"min-h-36 resize-y text-sm"}),(0,iN.jsx)("div",{className:"flex justify-end",children:(0,iN.jsxs)(hv.Button,{type:"button",size:"sm",onClick:U,disabled:m||!F,children:[m&&(0,iN.jsx)(hk.Loader2,{className:"mr-2 h-3.5 w-3.5 animate-spin"}),n("prompt.savePrompt")]})})]})]})]}),(0,iN.jsx)(zw.AgentDialog,{open:M,onOpenChange:O,roleFilter:"bot"})]}):(0,iN.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:n("workspaceNotFound")})}let zN=[{value:"issue_started",labelKey:"events.issueStarted"},{value:"issue_completed",labelKey:"events.issueCompleted"},{value:"issue_task_completed",labelKey:"events.taskCompleted"}];function zM(){return{enabled:!1,provider:"lark",events:["issue_started","issue_completed","issue_task_completed"],lark:{},wechat:{}}}function zO({icon:e,label:i,value:n}){return(0,iN.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,iN.jsx)("span",{className:"text-muted-foreground",children:e}),(0,iN.jsx)("span",{className:"text-muted-foreground shrink-0",children:i}),(0,iN.jsx)("span",{className:"truncate text-foreground ml-auto",title:n,children:n})]})}let zA={"channel-list":(0,iN.jsx)(nj,{size:16}),"issue-list":(0,iN.jsx)(nI,{size:16}),editor:(0,iN.jsx)(nP.FolderOpen,{size:16}),"code-editor":(0,iN.jsx)(nB,{size:16}),chat:(0,iN.jsx)(nz.MessageSquare,{size:16}),"issue-detail":(0,iN.jsx)(nF.FileText,{size:16}),terminal:(0,iN.jsx)(nW,{size:16}),"git-changes":(0,iN.jsx)(nH,{size:16}),"git-commits":(0,iN.jsx)(n$,{size:16}),"git-graph":(0,iN.jsx)(nU,{size:16}),"project-settings":(0,iN.jsx)(nV.Settings2,{size:16})},zR={"code-editor":"editor",chat:"channel-list","issue-detail":"issue-list"},zD={global:{tabSetEnableTabStrip:!0,borderEnableDrop:!0,tabEnableClose:!1,tabEnableRename:!1,tabSetEnableMaximize:!1},borders:[{type:"border",location:"bottom",children:[{type:"tab",name:"Terminal",component:"terminal"},{type:"tab",name:"Changes",component:"git-changes"},{type:"tab",name:"Commits",component:"git-commits"},{type:"tab",name:"Graph",component:"git-graph"}]}],layout:{type:"row",children:[{type:"tabset",weight:.25,children:[{type:"tab",name:"Settings",component:"project-settings",id:"project-settings"},{type:"tab",name:"Channels",component:"channel-list",id:"channel-list"},{type:"tab",name:"Issues",component:"issue-list",id:"issue-list"},{type:"tab",name:"Editor",component:"editor",id:"editor"}]},{type:"tabset",weight:.75,children:[{type:"tab",name:"Code Editor",component:"code-editor",id:"code-editor"},{type:"tab",name:"Chat",component:"chat",id:"chat"},{type:"tab",name:"Issue Detail",component:"issue-detail",id:"issue-detail"}]}]}};function zL({workspaceId:e,boundDirs:i}){let n=(0,gt.useIsMobile)(),r=R$(),s=RW(),o=R$(e=>e.activeIssueId),a=R$(e=>e.issueSelectSeq),l=rt(e=>e.activeFilePath),c=hR(e=>e.activeChannelId),h=hR(e=>e.channelSelectSeq),d=zu(e=>e.status),{activePanel:u,setActivePanel:p}=RU(),[f]=(0,iM.useState)(()=>{try{let i=localStorage.getItem(`flexlayout-${e}`);if(i)return i9.fromJson(JSON.parse(i))}catch{}return i9.fromJson(zD)});(0,iM.useEffect)(()=>{if(o)if(n)p("issue-detail");else{let e=f.getNodeById("issue-detail");e&&e instanceof iU&&f.doAction(iB.selectTab(e.getId()))}},[a,o,f,n,p]),(0,iM.useEffect)(()=>{if(c)if(n)p("chat");else{let e=f.getNodeById("chat");e&&e instanceof iU&&f.doAction(iB.selectTab(e.getId()))}},[h,c,f,n,p]),(0,iM.useEffect)(()=>{if(l)if(n)p("code-editor");else{let e=f.getNodeById("code-editor");e&&e instanceof iU&&f.doAction(iB.selectTab(e.getId()))}},[l,f,n,p]),(0,iM.useEffect)(()=>{zu.getState().loadStatus(e);let i=setInterval(()=>{zu.getState().loadStatus(e)},3e4);return()=>clearInterval(i)},[e]),(0,iM.useEffect)(()=>{if(!n)return;let i=zu.getState();"git-changes"===u?(i.loadStatus(e),i.loadDiffs(e)):"git-commits"===u?i.loadLog(e):"git-graph"===u&&(i.loadLog(e),i.loadStatus(e))},[u,e,n]),(0,iM.useEffect)(()=>{let i=rL(e),n=[i.on("issue.created",e=>r.upsertIssue(e)),i.on("issue.updated",e=>r.upsertIssue(e)),i.on("issue.status_changed",()=>{r.loadIssues(e)}),i.on("task.created",e=>s.upsertTask(e)),i.on("task.updated",e=>s.upsertTask(e)),i.on("task.status_changed",()=>{let i=R$.getState().activeIssueId;i&&s.loadTasks(e,i)})];return()=>n.forEach(e=>e())},[r,s,e]);let m=(0,iM.useCallback)(n=>{switch(n.getComponent()){case"channel-list":return(0,iN.jsx)(dS,{workspaceId:e});case"issue-list":return(0,iN.jsx)(R3,{workspaceId:e});case"editor":return(0,iN.jsx)(rh,{workspaceId:e});case"code-editor":return(0,iN.jsx)(rv,{workspaceId:e});case"chat":return(0,iN.jsx)(RY,{workspaceId:e});case"issue-detail":return(0,iN.jsx)(zs,{workspaceId:e});case"terminal":return(0,iN.jsx)(hM,{workspaceId:e,boundDirs:i});case"git-changes":return(0,iN.jsx)(zy,{workspaceId:e});case"git-commits":return(0,iN.jsx)(zb,{workspaceId:e});case"git-graph":return(0,iN.jsx)(zx,{workspaceId:e});case"project-settings":return(0,iN.jsx)(zE,{workspaceId:e});default:return(0,iN.jsx)(zI,{name:n.getName()})}},[i,e]),g=(0,iM.useCallback)((e,i)=>{let n=e.getComponent(),r=n?zA[n]:void 0;if(!r)return;let s=null;"git-changes"===n&&d&&!d.clean?s=(0,iN.jsx)("span",{className:"ml-0.5 text-[10px] font-medium text-orange-500 leading-none",children:d.files.length}):"git-commits"===n&&d&&d.ahead>0?s=(0,iN.jsxs)("span",{className:"ml-0.5 text-[10px] font-medium text-blue-500 leading-none",children:["↑",d.ahead]}):"git-graph"===n&&d&&(s=(0,iN.jsx)("span",{className:"ml-0.5 text-[10px] font-medium text-muted-foreground leading-none max-w-[80px] truncate",children:d.branch})),i.content=(0,iN.jsxs)("span",{title:e.getName(),className:"flex items-center justify-center",children:[r,s]})},[d]),v=(0,iM.useCallback)((i,n)=>{if(n.type!==iB.SELECT_TAB)try{localStorage.setItem(`flexlayout-${e}`,JSON.stringify(i.toJson()))}catch{}if(n.type!==iB.SELECT_TAB)return;let r=i.getNodeById(n.data.tabNode);if(!r||!(r instanceof iU))return;let s=r.getComponent(),o=zR[s??""];if(o){let e=i.getNodeById(o);e&&e instanceof iU&&i.doAction(iB.selectTab(e.getId()))}let a=zu.getState();"git-changes"===s?(a.loadStatus(e),a.loadDiffs(e)):"git-commits"===s?a.loadLog(e):"git-graph"===s&&(a.loadLog(e),a.loadStatus(e))},[e]);return n?(0,iN.jsx)("div",{className:"relative h-full w-full",children:(0,iN.jsx)(zj,{panel:u,workspaceId:e,boundDirs:i})}):(0,iN.jsx)("div",{className:"relative h-full w-full",children:(0,iN.jsx)(nD,{model:f,factory:m,onRenderTab:g,onModelChange:v})})}function zj({panel:e,workspaceId:i,boundDirs:n}){switch(e){case"channel-list":default:return(0,iN.jsx)(dS,{workspaceId:i});case"chat":return(0,iN.jsx)(RY,{workspaceId:i});case"issue-list":return(0,iN.jsx)(R3,{workspaceId:i});case"issue-detail":return(0,iN.jsx)(zs,{workspaceId:i});case"editor":return(0,iN.jsx)(rh,{workspaceId:i});case"code-editor":return(0,iN.jsx)(rv,{workspaceId:i});case"terminal":return(0,iN.jsx)(hM,{workspaceId:i,boundDirs:n});case"git-changes":return(0,iN.jsx)(zy,{workspaceId:i});case"git-commits":return(0,iN.jsx)(zb,{workspaceId:i});case"git-graph":return(0,iN.jsx)(zx,{workspaceId:i});case"project-settings":return(0,iN.jsx)(zE,{workspaceId:i})}}function zI({name:e}){return(0,iN.jsxs)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:[e," (coming soon)"]})}let zP=[{id:"channel-list",icon:nj,group:"channel"},{id:"chat",icon:nz.MessageSquare,group:"channel"},{id:"issue-list",icon:nI,group:"issue"},{id:"issue-detail",icon:nH,group:"issue"},{id:"editor",icon:nP.FolderOpen,group:"editor"},{id:"code-editor",icon:nB,group:"editor"},{id:"terminal",icon:nW,group:"tools"},{id:"git-changes",icon:nH,group:"git"},{id:"git-commits",icon:n$,group:"git"},{id:"git-graph",icon:nU,group:"git"},{id:"project-settings",icon:nV.Settings2,group:"settings"}];function zB(){let{activePanel:e,setActivePanel:i}=RU();return(0,iN.jsx)("div",{className:"relative shrink-0 bg-background",children:(0,iN.jsx)("div",{className:"flex items-center h-10 border-b px-1 gap-0.5 shrink-0 overflow-x-auto md:hidden",children:zP.map((n,r)=>{let s=n.icon,o=r>0?zP[r-1].group:null,a=null!==o&&o!==n.group;return(0,iN.jsxs)("div",{className:"flex items-center shrink-0",children:[a&&(0,iN.jsx)("div",{className:"w-px h-4 bg-border mx-0.5"}),(0,iN.jsx)("button",{onClick:()=>i(n.id),className:(0,nQ.cn)("flex items-center justify-center size-8 rounded-md transition-colors",e===n.id?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-accent/50"),children:(0,iN.jsx)(s,{size:16})})]},n.id)})})})}var zz=e.i(361031),zF=e.i(233297);e.s(["WorkspaceClient",0,function(){let e=function(){let e=(0,iO.useSearchParams)().get("workspaceId")||"",[i,n]=(0,iM.useState)("");return(0,iM.useEffect)(()=>{let e=window.location.pathname.match(/\/workspace\/([^/]+)/);n(e?.[1]||"")},[]),(0,iM.useMemo)(()=>e||i,[i,e])}(),i=(0,iO.useRouter)(),[n,r]=(0,iM.useState)(null),[s,o]=(0,iM.useState)(null),a=(0,zz.useWorkspaceStore)(e=>e.upsertWorkspace);return((0,iM.useEffect)(()=>{e&&fetch(`/api/workspaces/${e}`).then(e=>{if(!e.ok)throw Error("Not found");return e.json()}).then(e=>{r(e),a(e)}).catch(e=>o(e.message))},[e,a]),s)?(0,iN.jsxs)("div",{className:"h-full flex flex-col items-center justify-center gap-4",children:[(0,iN.jsx)("p",{className:"text-destructive",children:s}),(0,iN.jsx)("button",{type:"button",onClick:()=>(0,zF.tauriNavigate)(i,"/"),className:"text-sm underline",children:"Back to home"})]}):n?(0,iN.jsxs)("div",{className:"h-full min-h-0 flex flex-col overflow-hidden",children:[(0,iN.jsx)(zB,{}),(0,iN.jsx)("div",{className:"min-h-0 flex-1 overflow-hidden",children:(0,iN.jsx)(zL,{workspaceId:n.id,boundDirs:n.boundDirs})})]}):(0,iN.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:"Loading..."})}],191871)}]);
|