@rainmanhhh/pi-web 0.16.0 → 0.16.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.
Files changed (92) hide show
  1. package/dist/server.mjs +1 -1
  2. package/dist/static/assets/{CodeMirrorEditor-BG47ddrp.js → CodeMirrorEditor-Dvi7r7a_.js} +1 -1
  3. package/dist/static/assets/{abnfDiagram-VCTEODGH-ZgtH3MsG.js → abnfDiagram-VCTEODGH-CTJ21Zqj.js} +1 -1
  4. package/dist/static/assets/architecture-7GRP2DOG-DPCDMCMS.js +1 -0
  5. package/dist/static/assets/{architectureDiagram-5GKGNRK7-B31Z-Zi4.js → architectureDiagram-5GKGNRK7-BoAblDft.js} +1 -1
  6. package/dist/static/assets/{blockDiagram-I7D4REHJ-B2wWhike.js → blockDiagram-I7D4REHJ-DA7n5RdY.js} +1 -1
  7. package/dist/static/assets/{c4Diagram-7LVT6UL2-5sj4ak86.js → c4Diagram-7LVT6UL2-Q4A0JRtM.js} +1 -1
  8. package/dist/static/assets/channel-B1LUvZIL.js +1 -0
  9. package/dist/static/assets/{chunk-4HAMMTFA-ClE9HgfI.js → chunk-4HAMMTFA-D1jhwXf_.js} +1 -1
  10. package/dist/static/assets/{chunk-75Z2AOVW-40g1I2zS.js → chunk-75Z2AOVW-CD2AiGBA.js} +1 -1
  11. package/dist/static/assets/{chunk-DU6HZSFF-FA2D2oY1.js → chunk-DU6HZSFF-B-M8csoA.js} +1 -1
  12. package/dist/static/assets/{chunk-F27PBJKO-NYCq3-ye.js → chunk-F27PBJKO-78BwbQZ4.js} +1 -1
  13. package/dist/static/assets/{chunk-GMAD6QVW-DQqlciiu.js → chunk-GMAD6QVW-COlH9i9b.js} +1 -1
  14. package/dist/static/assets/{chunk-GVQU2GXP-By7kz-qv.js → chunk-GVQU2GXP-CXuCuNPZ.js} +1 -1
  15. package/dist/static/assets/{chunk-IMKFNOWR-C_8ecALV.js → chunk-IMKFNOWR-DDEWkuG2.js} +1 -1
  16. package/dist/static/assets/{chunk-L3NEJ4N5-Cpwk6bS2.js → chunk-L3NEJ4N5-UabNXwkE.js} +1 -1
  17. package/dist/static/assets/{chunk-OSK3NFVY-shh7VoCf.js → chunk-OSK3NFVY-CzE_8nog.js} +1 -1
  18. package/dist/static/assets/{chunk-P2QGCYS3-Bsq9ScJ5.js → chunk-P2QGCYS3-BzFN0t4E.js} +1 -1
  19. package/dist/static/assets/{chunk-POPQ4Y6H-DP9Hqfnm.js → chunk-POPQ4Y6H-LdfGLCYg.js} +1 -1
  20. package/dist/static/assets/{chunk-PWAF6VOD-DD6ZNAOV.js → chunk-PWAF6VOD-CPBPOich.js} +1 -1
  21. package/dist/static/assets/{chunk-SHT3W25Y-CiOqEmzn.js → chunk-SHT3W25Y-D8ECgh_t.js} +1 -1
  22. package/dist/static/assets/{chunk-SVP7TREG-CKmQB0kw.js → chunk-SVP7TREG-CDjQfSFm.js} +1 -1
  23. package/dist/static/assets/{chunk-TICWLB2K-DBVSoCni.js → chunk-TICWLB2K-CVYoyAw2.js} +1 -1
  24. package/dist/static/assets/classDiagram-ZZMXUADV-DJiAWanF.js +1 -0
  25. package/dist/static/assets/classDiagram-v2-VYDZK3BY-DJiAWanF.js +1 -0
  26. package/dist/static/assets/{cynefin-OW5HDTMX-g3grh2Ah.js → cynefin-OW5HDTMX-sNCWt8Uo.js} +1 -1
  27. package/dist/static/assets/{cynefinDiagram-5FMLGOSQ-DUTw9svv.js → cynefinDiagram-5FMLGOSQ-BOax7X7h.js} +1 -1
  28. package/dist/static/assets/{dagre-GXQ25YYZ-1Vlh7ENa.js → dagre-GXQ25YYZ-Dil_tquy.js} +1 -1
  29. package/dist/static/assets/{diagram-S7CK7UJ4-B4vKX4f4.js → diagram-S7CK7UJ4-D8jGXpVT.js} +1 -1
  30. package/dist/static/assets/{diagram-UQ7AKVKN-BJMkvpws.js → diagram-UQ7AKVKN-CQW2XfKk.js} +1 -1
  31. package/dist/static/assets/{diagram-VSXAHHWV-CKLKE6Go.js → diagram-VSXAHHWV-D7B2HVnH.js} +1 -1
  32. package/dist/static/assets/{diagram-VX7I27RA-BKp-8v3V.js → diagram-VX7I27RA-BvF6BDH-.js} +1 -1
  33. package/dist/static/assets/{diagram-Z3DM3KII-dfd9AAWD.js → diagram-Z3DM3KII-BoN-e6Ni.js} +1 -1
  34. package/dist/static/assets/{ebnfDiagram-PWID7BFC-CK_LPNLr.js → ebnfDiagram-PWID7BFC-CemqIwt_.js} +1 -1
  35. package/dist/static/assets/{erDiagram-RLTQ6QDP-CuvQt6Mp.js → erDiagram-RLTQ6QDP-DsrbsSVa.js} +1 -1
  36. package/dist/static/assets/eventmodeling-NTZA5JFV-C4aR0MVV.js +1 -0
  37. package/dist/static/assets/flowDiagram-HODETNUW-DXnMUTIr.js +1 -0
  38. package/dist/static/assets/{ganttDiagram-EL5Y4UJY-CU5BKVpu.js → ganttDiagram-EL5Y4UJY-CWvvbyy4.js} +1 -1
  39. package/dist/static/assets/{gitGraph-4MIJSDKK-Db_nf9VP.js → gitGraph-4MIJSDKK-BwXUPPUz.js} +1 -1
  40. package/dist/static/assets/{gitGraphDiagram-WWUBYQGX-Dnu5urx2.js → gitGraphDiagram-WWUBYQGX-DOCJP9_n.js} +1 -1
  41. package/dist/static/assets/{highlighted-body-KPVGNVTW-DlUBMdQx.js → highlighted-body-KPVGNVTW-Di5T_zxw.js} +1 -1
  42. package/dist/static/assets/index-HvNgrSMz.js +498 -0
  43. package/dist/static/assets/{info-A6RAGUB7-CXMUahmD.js → info-A6RAGUB7-DZS90kmO.js} +1 -1
  44. package/dist/static/assets/{infoDiagram-27XIBGKW-C97MUpw0.js → infoDiagram-27XIBGKW-Boe5hF8X.js} +1 -1
  45. package/dist/static/assets/{ishikawaDiagram-5VMMS53U-plnvWbFc.js → ishikawaDiagram-5VMMS53U-_neOKvDx.js} +1 -1
  46. package/dist/static/assets/{journeyDiagram-3NMN7TZE-DT1EsG9v.js → journeyDiagram-3NMN7TZE-ZzKFPyhs.js} +1 -1
  47. package/dist/static/assets/{kanban-definition-UXKFOSKX-BEL9oCbh.js → kanban-definition-UXKFOSKX-CMKT7LI5.js} +1 -1
  48. package/dist/static/assets/{line-CdhJr9OI.js → line-jaoNfrSf.js} +1 -1
  49. package/dist/static/assets/mermaid-HWGCJPDP-DfW4V_BR.js +1 -0
  50. package/dist/static/assets/{mermaid-parser.core-BGvTV5pP.js → mermaid-parser.core-CYYXlPrD.js} +3 -3
  51. package/dist/static/assets/{mermaid.core-GxUCFU4e.js → mermaid.core-DNKCSJO6.js} +4 -4
  52. package/dist/static/assets/{mindmap-definition-YA3MSWOX-BgbYCLeM.js → mindmap-definition-YA3MSWOX-BClvw_4-.js} +1 -1
  53. package/dist/static/assets/{packet-AYTQ26CC-C4Qw6sn3.js → packet-AYTQ26CC-CkTErPNg.js} +1 -1
  54. package/dist/static/assets/{pegDiagram-XKGWAZYB-DxU5vc1m.js → pegDiagram-XKGWAZYB-rn-n9p-4.js} +1 -1
  55. package/dist/static/assets/{pie-WAS4IAKB-B7JMjpbq.js → pie-WAS4IAKB-CXpnRWGl.js} +1 -1
  56. package/dist/static/assets/{pieDiagram-E7YTZNPT-DlcAVEct.js → pieDiagram-E7YTZNPT-ClsCe7P8.js} +1 -1
  57. package/dist/static/assets/{quadrantDiagram-AXDQQJYC-CcQmUnmh.js → quadrantDiagram-AXDQQJYC-B5HgsQ6J.js} +1 -1
  58. package/dist/static/assets/{radar-RG4KPBEZ-BhltfAqG.js → radar-RG4KPBEZ-BnOwXhlJ.js} +1 -1
  59. package/dist/static/assets/{railroad-74A4TZTK-CQteMutN.js → railroad-74A4TZTK-D_lGZItY.js} +1 -1
  60. package/dist/static/assets/railroad-abnf-HS5TGJTU-BQCxFVXE.js +1 -0
  61. package/dist/static/assets/railroad-ebnf-LZEXJU2U-Dp9FbcRF.js +1 -0
  62. package/dist/static/assets/railroad-peg-WCYAUIDC-DE6PVgzw.js +1 -0
  63. package/dist/static/assets/{railroadDiagram-O6MQD6OU-loZihjOv.js → railroadDiagram-O6MQD6OU-D13RaD_q.js} +1 -1
  64. package/dist/static/assets/{requirementDiagram-BXWQKSXE-fkSs2Xmm.js → requirementDiagram-BXWQKSXE-Dmpcwvrn.js} +1 -1
  65. package/dist/static/assets/{sankeyDiagram-P5KCCOFB-BKC8J00I.js → sankeyDiagram-P5KCCOFB-DUfELpLw.js} +1 -1
  66. package/dist/static/assets/{sequenceDiagram-WJ2MYXX4-BmGRt-Sy.js → sequenceDiagram-WJ2MYXX4-vga_pXj7.js} +1 -1
  67. package/dist/static/assets/{stateDiagram-D77RDMKH-DhOH7CF7.js → stateDiagram-D77RDMKH-DpPBJ_GK.js} +1 -1
  68. package/dist/static/assets/stateDiagram-v2-MP3YSRHH-C3gX1_aA.js +1 -0
  69. package/dist/static/assets/{swimlanes-42K2YHIH--7TO5oK2.js → swimlanes-42K2YHIH-DrAOzJ1i.js} +1 -1
  70. package/dist/static/assets/swimlanesDiagram-VR7AAH4N-jrQ7_dLu.js +8 -0
  71. package/dist/static/assets/{timeline-definition-24CTP7MA-BogVzb_C.js → timeline-definition-24CTP7MA-cRKqjrdd.js} +1 -1
  72. package/dist/static/assets/{treeView-Q6P3EWNA-DLTT0Dcu.js → treeView-Q6P3EWNA-C0EWELTT.js} +1 -1
  73. package/dist/static/assets/{treemap-WGGIJYW6-gPwb-cRt.js → treemap-WGGIJYW6-CVFGTbCR.js} +1 -1
  74. package/dist/static/assets/{vennDiagram-4TSXK5OY-D6lu0bDy.js → vennDiagram-4TSXK5OY-CNJf4prA.js} +1 -1
  75. package/dist/static/assets/{wardley-WFR3VGLG-C8TvdkVa.js → wardley-WFR3VGLG-pimpa09L.js} +1 -1
  76. package/dist/static/assets/{wardleyDiagram-VM6X3IG4-BVVNKnxr.js → wardleyDiagram-VM6X3IG4-B9fb4LZT.js} +1 -1
  77. package/dist/static/assets/{xychartDiagram-S5SC5T6Z-BbCvnzJk.js → xychartDiagram-S5SC5T6Z-BrkKGncO.js} +1 -1
  78. package/dist/static/index.html +1 -1
  79. package/package.json +1 -1
  80. package/dist/static/assets/architecture-7GRP2DOG-DtI-8QsN.js +0 -1
  81. package/dist/static/assets/channel-CZ_9UM16.js +0 -1
  82. package/dist/static/assets/classDiagram-ZZMXUADV-XaLRtlDN.js +0 -1
  83. package/dist/static/assets/classDiagram-v2-VYDZK3BY-XaLRtlDN.js +0 -1
  84. package/dist/static/assets/eventmodeling-NTZA5JFV-Bf80F7Vq.js +0 -1
  85. package/dist/static/assets/flowDiagram-HODETNUW-CSoNLwlm.js +0 -1
  86. package/dist/static/assets/index-COqRaKwN.js +0 -498
  87. package/dist/static/assets/mermaid-HWGCJPDP-ysOkCxQf.js +0 -1
  88. package/dist/static/assets/railroad-abnf-HS5TGJTU-DGm68MeU.js +0 -1
  89. package/dist/static/assets/railroad-ebnf-LZEXJU2U-FQ9JWpSg.js +0 -1
  90. package/dist/static/assets/railroad-peg-WCYAUIDC-Dg1JM5tD.js +0 -1
  91. package/dist/static/assets/stateDiagram-v2-MP3YSRHH-vdFHYcZw.js +0 -1
  92. package/dist/static/assets/swimlanesDiagram-VR7AAH4N-DAGW3R0F.js +0 -8
package/dist/server.mjs CHANGED
@@ -256,7 +256,7 @@ Expecting one of '${n.join("', '")}'`);if(this._lifeCycleHooks[e])this._lifeCycl
256
256
  `),this.outputHelp({error:!0});let n=t||{},r=n.exitCode||1,i=n.code||"commander.error";this._exit(r,i,e)}_parseOptionsEnv(){this.options.forEach((e)=>{if(e.envVar&&e.envVar in ge.env){let t=e.attributeName();if(this.getOptionValue(t)===void 0||["default","config","env"].includes(this.getOptionValueSource(t)))if(e.required||e.optional)this.emit(`optionEnv:${e.name()}`,ge.env[e.envVar]);else this.emit(`optionEnv:${e.name()}`)}})}_parseOptionsImplied(){let e=new Bh(this.options),t=(n)=>this.getOptionValue(n)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(n));this.options.filter((n)=>n.implied!==void 0&&t(n.attributeName())&&e.valueFromOption(this.getOptionValue(n.attributeName()),n)).forEach((n)=>{Object.keys(n.implied).filter((r)=>!t(r)).forEach((r)=>{this.setOptionValueWithSource(r,n.implied[r],"implied")})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){let n=(o)=>{let s=o.attributeName(),a=this.getOptionValue(s),c=this.options.find((d)=>d.negate&&s===d.attributeName()),u=this.options.find((d)=>!d.negate&&s===d.attributeName());if(c&&(c.presetArg===void 0&&a===!1||c.presetArg!==void 0&&a===c.presetArg))return c;return u||o},r=(o)=>{let s=n(o),a=s.attributeName();if(this.getOptionValueSource(a)==="env")return`environment variable '${s.envVar}'`;return`option '${s.flags}'`},i=`error: ${r(e)} cannot be used with ${r(t)}`;this.error(i,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let r=[],i=this;do{let o=i.createHelp().visibleOptions(i).filter((s)=>s.long).map((s)=>s.long);r=r.concat(o),i=i.parent}while(i&&!i._enablePositionalOptions);t=Nh(e,r)}let n=`error: unknown option '${e}'${t}`;this.error(n,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,n=t===1?"":"s",r=e.length,i=this.parent?` for '${this.name()}'`:"",o=e.join(", "),s=`error: too many arguments${i}. Expected ${t} argument${n} but got ${r}: ${o}.`;this.error(s,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let r=[];this.createHelp().visibleCommands(this).forEach((i)=>{if(r.push(i.name()),i.alias())r.push(i.alias())}),t=Nh(e,r)}let n=`error: unknown command '${e}'${t}`;this.error(n,{code:"commander.unknownCommand"})}version(e,t,n){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",n=n||"output the version number";let r=this.createOption(t,n);return this._versionOptionName=r.attributeName(),this._registerOption(r),this.on("option:"+r.name(),()=>{this._outputConfiguration.writeOut(`${e}
257
257
  `),this._exit(0,"commander.version",e)}),this}description(e,t){if(e===void 0&&t===void 0)return this._description;if(this._description=e,t)this._argsDescription=t;return this}summary(e){if(e===void 0)return this._summary;return this._summary=e,this}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)t=this.commands[this.commands.length-1];if(e===t._name)throw Error("Command alias can't be the same as its name");let n=this.parent?._findCommand(e);if(n){let r=[n.name()].concat(n.aliases()).join("|");throw Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${r}'`)}return t._aliases.push(e),this}aliases(e){if(e===void 0)return this._aliases;return e.forEach((t)=>this.alias(t)),this}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map((n)=>yu(n));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=e,this}name(e){if(e===void 0)return this._name;return this._name=e,this}helpGroup(e){if(e===void 0)return this._helpGroupHeading??"";return this._helpGroupHeading=e,this}commandsGroup(e){if(e===void 0)return this._defaultCommandGroup??"";return this._defaultCommandGroup=e,this}optionsGroup(e){if(e===void 0)return this._defaultOptionGroup??"";return this._defaultOptionGroup=e,this}_initOptionGroup(e){if(this._defaultOptionGroup&&!e.helpGroupHeading)e.helpGroup(this._defaultOptionGroup)}_initCommandGroup(e){if(this._defaultCommandGroup&&!e.helpGroup())e.helpGroup(this._defaultCommandGroup)}nameFromFilename(e){return this._name=Gn.basename(e,Gn.extname(e)),this}executableDir(e){if(e===void 0)return this._executableDir;return this._executableDir=e,this}helpInformation(e){let t=this.createHelp(),n=this._getOutputContext(e);t.prepareContext({error:n.error,helpWidth:n.helpWidth,outputHasColors:n.hasColors});let r=t.formatHelp(this,t);if(n.hasColors)return r;return this._outputConfiguration.stripColor(r)}_getOutputContext(e){e=e||{};let t=!!e.error,n,r,i;if(t)n=(s)=>this._outputConfiguration.writeErr(s),r=this._outputConfiguration.getErrHasColors(),i=this._outputConfiguration.getErrHelpWidth();else n=(s)=>this._outputConfiguration.writeOut(s),r=this._outputConfiguration.getOutHasColors(),i=this._outputConfiguration.getOutHelpWidth();return{error:t,write:(s)=>{if(!r)s=this._outputConfiguration.stripColor(s);return n(s)},hasColors:r,helpWidth:i}}outputHelp(e){let t;if(typeof e==="function")t=e,e=void 0;let n=this._getOutputContext(e),r={error:n.error,write:n.write,command:this};this._getCommandAndAncestors().reverse().forEach((o)=>o.emit("beforeAllHelp",r)),this.emit("beforeHelp",r);let i=this.helpInformation({error:n.error});if(t){if(i=t(i),typeof i!=="string"&&!Buffer.isBuffer(i))throw Error("outputHelp callback must return a string or a Buffer")}if(n.write(i),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",r),this._getCommandAndAncestors().forEach((o)=>o.emit("afterAllHelp",r))}helpOption(e,t){if(typeof e==="boolean"){if(e){if(this._helpOption===null)this._helpOption=void 0;if(this._defaultOptionGroup)this._initOptionGroup(this._getHelpOption())}else this._helpOption=null;return this}if(this._helpOption=this.createOption(e??"-h, --help",t??"display help for command"),e||t)this._initOptionGroup(this._helpOption);return this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption(e){return this._helpOption=e,this._initOptionGroup(e),this}help(e){this.outputHelp(e);let t=Number(ge.exitCode??0);if(t===0&&e&&typeof e!=="function"&&e.error)t=1;this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let n=["beforeAll","before","after","afterAll"];if(!n.includes(e))throw Error(`Unexpected value for position to addHelpText.
258
258
  Expecting one of '${n.join("', '")}'`);let r=`${e}Help`;return this.on(r,(i)=>{let o;if(typeof t==="function")o=t({error:i.error,command:i.command});else o=t;if(o)i.write(`${o}
259
- `)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();if(t&&e.find((r)=>t.is(r)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function U2(e){return e.map((t)=>{if(!t.startsWith("--inspect"))return t;let n,r="127.0.0.1",i="9229",o;if((o=t.match(/^(--inspect(-brk)?)$/))!==null)n=o[1];else if((o=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(n=o[1],/^\d+$/.test(o[3]))i=o[3];else r=o[3];else if((o=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)n=o[1],r=o[3],i=o[4];if(n&&i!=="0")return`${n}=${r}:${parseInt(i)+1}`;return t})}function k2(){if(ge.env.NO_COLOR||ge.env.FORCE_COLOR==="0"||ge.env.FORCE_COLOR==="false")return!1;if(ge.env.FORCE_COLOR||ge.env.CLICOLOR_FORCE!==void 0)return!0;return}var bhe=new so;var Xs={name:"@rainmanhhh/pi-web",version:"0.16.0",description:"Web UI for the pi coding agent (fork of @agegr/pi-web)",homepage:"https://gitee.com/dsxbygzzl/pi-web#readme",repository:{type:"git",url:"git+https://gitee.com/dsxbygzzl/pi-web.git"},bugs:{url:"https://gitee.com/dsxbygzzl/pi-web/issues"},author:"rainmanhhh",license:"MIT",publishConfig:{access:"public",registry:"https://registry.npmjs.org"},engines:{node:">=24.0.0"},files:["dist","public","extensions","package.json"],bin:{"pi-web":"dist/server.mjs"},scripts:{dev:"vite","dev:lan":"vite --host 0.0.0.0",mb:"bun run --env-file=.env.manual api",mf:"bun run --env-file=.env.manual dev -- --port 3001",api:"bun run server/main.ts","api:node":"bun run build:server && node dist/server.mjs","build:server":'bun build server/main.ts --target node --outfile dist/server.mjs --minify --external "@earendil-works/*" --define "process.env.PI_WEB_PACKAGED=1"',"e2e:stop":"bun run scripts/e2e-stop.mjs",build:"vite build && bun run scripts/prune-fonts.mjs","build:analyze":"vite build --config scripts/analyze-bundle.config.ts && bun run scripts/prune-fonts.mjs",lint:"oxlint --fix",fta:"bun scripts/fta-gate.mjs . --output-limit 15",jscpd:"jscpd --config .jscpd.json",check:"tsc --noEmit",format:"biome check --write .",prepublishOnly:"bun run check && bun run build && bun run build:server","test:e2e":"cross-env CODEBUDDY_SAFE_DELETE_ENABLED=0 playwright test","test:unit":"vitest run","test:unit:bun":"bun --bun run test:unit",prepare:"husky || true"},dependencies:{"@codemirror/commands":"^6.11.0","@codemirror/lang-css":"^6.3.1","@codemirror/lang-html":"^6.4.12","@codemirror/lang-javascript":"^6.2.5","@codemirror/lang-json":"^6.0.2","@codemirror/lang-markdown":"^6.5.2","@codemirror/lang-yaml":"^6.1.3","@codemirror/language":"^6.12.4","@codemirror/state":"^6.7.1","@codemirror/theme-one-dark":"^6.1.3","@codemirror/view":"^6.43.9","@earendil-works/pi-agent-core":"0.87.0","@earendil-works/pi-ai":"0.87.0","@earendil-works/pi-coding-agent":"0.87.0","@earendil-works/pi-tui":"0.87.0","@hono/node-server":"^2.1.1","class-variance-authority":"^0.7.1",clsx:"^2.1.1",codemirror:"^6.0.2",hono:"^4.13.5","lucide-react":"^1.37.0","p-defer":"^4.0.1",pointrix:"^1.1.0","proper-lockfile":"4.1.2","radix-ui":"^1.6.7",react:"^19.2.8","react-dom":"^19.2.8",shadcn:"^4.19.0",streamdown:"2.6.0","tailwind-merge":"^3.6.0","tw-animate-css":"^1.4.0",virtua:"^0.50.6",ws:"^8.21.3"},devDependencies:{"@biomejs/biome":"^2.5.13","@lobehub/icons":"^5.16.0","@playwright/test":"^1.62.1","@tailwindcss/postcss":"^4.3.3","@testing-library/dom":"^10.4.1","@testing-library/react":"^16.3.3","@types/node":"^25.9.5","@types/proper-lockfile":"4.1.4","@types/react":"^19.2.18","@types/react-dom":"^19.2.5","@types/react-resizable":"^4.0.0","@types/react-syntax-highlighter":"^15.5.13","@types/ws":"^8.18.1","@vitejs/plugin-react":"^6.1.1",commander:"^15.0.0","cross-env":"^10.1.0","fta-cli":"^3.0.1",husky:"^9.1.7",jiti:"^2.7.0",jscpd:"^5.1.0",jsdom:"^30.0.1",katex:"^0.18.4","lint-staged":"^17.4.1",mammoth:"^1.12.2",mermaid:"^11.17.2",oxlint:"^1.80.0",postcss:"^8.5.26","react-markdown":"^10.1.0","react-syntax-highlighter":"^16.1.1","rehype-katex":"^7.0.1","rehype-raw":"^7.0.0","rehype-sanitize":"^6.0.0","remark-gfm":"^4.0.1","remark-math":"^6.0.0",tailwindcss:"^4.3.3",typescript:"^7.0.2",vite:"^8.2.2","vite-plugin-remove-console":"^2.2.0","vite-plugin-svgr":"^5.2.0",vitest:"^4.1.11"},type:"module",overrides:{katex:"^0.18.4"}};var Wh=!1,R2=performance.now();function F2(e){if(Wh=e,R2=performance.now(),Wh)Nt("boot","debug log enabled")}function ct(e){return(t,n)=>Nt(e,t,n)}function Nt(e,t,n){if(!Wh)return;let r=performance.now()-R2,i=new Date,o=(a,c=2)=>String(a).padStart(c,"0"),s=`${o(i.getHours())}:${o(i.getMinutes())}:${o(i.getSeconds())}.${o(i.getMilliseconds(),3)}`;console.debug(`[debug][${e}][${s}][+${r.toFixed(1)}ms] ${t}${n?` — ${n}`:""}`)}import{existsSync as c5,mkdirSync as u5,readFileSync as z2,writeFileSync as l5}from"node:fs";import{dirname as d5,join as V2}from"node:path";import{getAgentDir as X2}from"@earendil-works/pi-coding-agent";var I2=[{label:{en:"Explore project","zh-CN":"阅读项目"},message:{en:"Explore the current project and summarize the overall directory structure and responsibilities of core modules.","zh-CN":"阅读当前项目,总结整体目录结构与核心模块的职责。"}},{label:{en:"Review workspace changes","zh-CN":"审查工作区改动"},message:{en:"Review all changes in the current workspace, point out potential issues and improvements.","zh-CN":"审查当前工作区的所有改动,指出潜在问题与改进点。"}},{label:{en:"Find and fix bugs","zh-CN":"寻找并修复bug"},message:{en:"Inspect the current codebase, find and fix existing bugs.","zh-CN":"检查当前代码,寻找并修复其中存在的 bug。"}}];var M2=I2;import{readFileSync as L2,writeFileSync as o5}from"node:fs";import{join as s5}from"node:path";import{getAgentDir as a5}from"@earendil-works/pi-coding-agent";var xu=["off","minimal","low","medium","high","xhigh","max"];function wu(e){return e==="en"||e==="zh-CN"?e:void 0}function Hh(e){return e==="dark"||e==="light"?e:void 0}function _u(e){return typeof e==="string"&&xu.includes(e)?e:void 0}function $h(e){if(typeof e!=="object"||e===null)return;let t=e;if(typeof t.enabled!=="boolean")return;if(typeof t.reserveTokens!=="number"||!Number.isInteger(t.reserveTokens)||t.reserveTokens<=0)return;if(typeof t.keepRecentTokens!=="number"||!Number.isInteger(t.keepRecentTokens)||t.keepRecentTokens<=0)return;return{enabled:t.enabled,reserveTokens:t.reserveTokens,keepRecentTokens:t.keepRecentTokens}}function i5(e){if(typeof e!=="object"||e===null)return;let t=e,n={};if(typeof t.timeoutMs==="number"&&Number.isInteger(t.timeoutMs)&&t.timeoutMs>0)n.timeoutMs=t.timeoutMs;if(typeof t.maxRetries==="number"&&Number.isInteger(t.maxRetries)&&t.maxRetries>0)n.maxRetries=t.maxRetries;if(typeof t.maxRetryDelayMs==="number"&&Number.isInteger(t.maxRetryDelayMs)&&t.maxRetryDelayMs>0)n.maxRetryDelayMs=t.maxRetryDelayMs;return Object.keys(n).length>0?n:void 0}function Gh(e){if(typeof e!=="object"||e===null)return;let t=e;if(typeof t.maxRetries!=="number"||!Number.isInteger(t.maxRetries)||t.maxRetries<=0)return;if(typeof t.baseDelayMs!=="number"||!Number.isInteger(t.baseDelayMs)||t.baseDelayMs<=0)return;let n={maxRetries:t.maxRetries,baseDelayMs:t.baseDelayMs};if(typeof t.enabled==="boolean")n.enabled=t.enabled;let r=i5(t.provider);if(r!==void 0)n.provider=r;return n}function Du(e){if(e==="ask"||e==="always"||e==="never")return e;if(e==="trust")return"always";if(e==="deny")return"never";return}function Eu(e){if(typeof e!=="object"||e===null)return;let t=e,n={};if(typeof t.defaultModel==="string"&&t.defaultModel.trim()!=="")n.defaultModel=t.defaultModel;let r=_u(t.defaultThinking);if(r!==void 0)n.defaultThinking=r;return Object.keys(n).length>0?n:void 0}function Su(e){return typeof e==="number"&&Number.isFinite(e)&&e>=0.85&&e<=1.3?e:void 0}var Ks=(e)=>typeof e==="boolean"?e:void 0,qh=(e)=>typeof e==="number"&&Number.isInteger(e)&&e>0?e:void 0,B2=(e)=>typeof e==="string"&&e.trim()!==""?e:void 0;function N2(e,t){if(typeof e!=="object"||e===null)return;let n=e,r={};for(let[i,o]of Object.entries(t)){let s=o(n[i]);if(s!==void 0)r[i]=s}return Object.keys(r).length>0?r:void 0}var zh=[{key:"httpProxy",validate:B2},{key:"httpIdleTimeoutMs",validate:qh},{key:"websocketConnectTimeoutMs",validate:qh},{key:"enableAnalytics",validate:Ks},{key:"enableInstallTelemetry",validate:Ks},{key:"trackingId",validate:B2},{key:"branchSummary",validate:(e)=>N2(e,{reserveTokens:qh,skipPrompt:Ks})},{key:"images",validate:(e)=>N2(e,{autoResize:Ks,blockImages:Ks})}];function Vh(e){return $h(ao("compaction",e))}function W2(e,t){let n=$h(e);if(!n)return Vh(t);return Zs("compaction",n,t),n}function Xh(e){return Gh(ao("retry",e))}function j2(e,t){let n=Gh(e);if(!n)return Xh(t);return Zs("retry",n,t),n}function Kh(e){return Eu(ao("subagents",e))}function q2(e,t){let n=Eu(e);if(n===void 0)return;let r=ao("subagents",t),i=typeof r==="object"&&r!==null?{...r}:{};if(n.defaultModel!==void 0)i.defaultModel=n.defaultModel;else delete i.defaultModel;if(n.defaultThinking!==void 0)i.defaultThinking=n.defaultThinking;else delete i.defaultThinking;return Zs("subagents",i,t),Eu(i)}function ao(e,t){try{return JSON.parse(L2(H2(t),"utf8"))[e]}catch{return}}function Zs(e,t,n){try{let r=H2(n),i={};try{i=JSON.parse(L2(r,"utf8"))}catch{i={}}i[e]=t,o5(r,JSON.stringify(i,null,2),"utf8")}catch{}}function co(e,t){let n=ao(e,t);return typeof n==="string"?n:void 0}function Tu(e,t,n){if(t===void 0)return co(e,n);return Zs(e,t,n),t}function H2(e){return s5(e??a5(),"settings.json")}function Ys(e){return Hh(co("theme",e))??"light"}function $2(e,t){let n=Hh(e);if(!n)return Ys(t);return Tu("theme",n,t),n}function Cu(e){let t={};for(let{key:n,validate:r}of zh){let i=r(ao(n,e));if(i!==void 0)t[n]=i}return Object.keys(t).length>0?t:void 0}function G2(e,t){for(let{key:n,validate:r}of zh){if(!(n in e))continue;let i=r(e[n]);if(i===void 0)continue;Zs(n,i,t)}return Cu(t)}var Au=new Map;function Zh(e){return V2(e??X2(),"pi-web","config.json")}function f5(e){return V2(e??X2(),"pi-web-preferences.json")}function Yh(e){try{if(c5(Zh(e)))return;let t=JSON.parse(z2(f5(e),"utf8"));Jh({firstPaint:{locale:wu(t.firstPaint?.locale),fontScale:Su(t.firstPaint?.fontScale)},preferences:t.preferences??{}},e)}catch{}}function h5(e){let t=_u(co("defaultThinkingLevel",e)),n=Vh(e),r=Xh(e),i=Du(co("defaultProjectTrust",e)),o=Kh(e),s=Cu(e);return{theme:Ys(e),...t!==void 0?{defaultThinkingLevel:t}:{},...n!==void 0?{compaction:n}:{},...r!==void 0?{retry:r}:{},...i!==void 0?{defaultProjectTrust:i}:{},...o!==void 0?{subagents:o}:{},...s!==void 0?{piSettings:s}:{}}}function zn(e){let t=e===void 0,n=e??"",r=t?Au.get(n):void 0;if(!t||r===void 0||r===null)try{let i=z2(Zh(e),"utf8"),o=JSON.parse(i);r={firstPaint:{locale:wu(o.firstPaint?.locale),fontScale:Su(o.firstPaint?.fontScale)},preferences:o.preferences??{},theme:Ys(e)},Au.set(n,r)}catch{if(r={firstPaint:{},preferences:{},theme:Ys(e)},t)Au.set(n,r)}return{...r,...h5(e)}}function Jh(e,t){try{let n=Zh(t);u5(d5(n),{recursive:!0});let r={firstPaint:e.firstPaint,preferences:e.preferences};if(l5(n,JSON.stringify(r,null,2),"utf8"),t===void 0)Au.set("",e)}catch{}}function p5(e,t){return{...e,...t.locale!==void 0?{locale:wu(t.locale)??e.locale}:{},...t.fontScale!==void 0?{fontScale:Su(t.fontScale)??e.fontScale}:{}}}function g5(e,t){if(e===void 0)return Du(co("defaultProjectTrust",t));let n=Du(e);if(n===void 0)return;return Tu("defaultProjectTrust",n,t),n}function Qh(e,t){let n=zn(t),r=p5(n.firstPaint,e),i=n.theme;if(e.theme!==void 0)i=$2(e.theme,t);let o=Tu("defaultThinkingLevel",_u(e.defaultThinkingLevel),t),s=W2(e.compaction,t),a=j2(e.retry,t),c=g5(e.defaultProjectTrust,t),u=e.subagents===void 0?Kh(t):q2(e.subagents,t),d=e.piSettings===void 0?Cu(t):G2(e.piSettings,t),f={firstPaint:r,preferences:n.preferences,theme:i,defaultThinkingLevel:o,...s!==void 0?{compaction:s}:{},...a!==void 0?{retry:a}:{},...c!==void 0?{defaultProjectTrust:c}:{},...u!==void 0?{subagents:u}:{},...d!==void 0?{piSettings:d}:{}};return Jh(f,t),f}function Uu(e,t){let n=zn(t),r={firstPaint:n.firstPaint,preferences:{...n.preferences,...e},theme:n.theme};return Jh(r,t),r}function ep(e){let{preferences:t}=zn(e);if(t.startScreenMessages!==void 0)return;Uu({startScreenMessages:M2},e)}import{DefaultResourceLoader as U5,getAgentDir as t1}from"@earendil-works/pi-coding-agent";import{hasTrustRequiringProjectResources as m5,ProjectTrustStore as tp}from"@earendil-works/pi-coding-agent";function ut(e,t){if(!(Boolean(e)&&m5(e)))return{requiresTrust:!1,trusted:!0};return{requiresTrust:!0,trusted:new tp(t).get(e)===!0}}function K2(e,t){let n=ut(e,t);if(!n.requiresTrust)return n;return new tp(t).set(e,!0),{requiresTrust:!0,trusted:!0}}function uo(e,t){if(!ut(e,t).requiresTrust)return;let r=new tp(t);return{resolveProjectTrust:async()=>r.get(e)===!0}}import{existsSync as y5,readFileSync as b5}from"node:fs";import{homedir as v5}from"node:os";import{isAbsolute as x5,join as Js,relative as w5,resolve as Z2,sep as _5}from"node:path";function D5({homeDir:e=v5(),xdgStateHome:t=process.env.XDG_STATE_HOME}={}){return t?Js(t,"skills",".skill-lock.json"):Js(e,".agents",".skill-lock.json")}function Y2(e){try{let t=JSON.parse(b5(e,"utf8"));return t.skills&&typeof t.skills==="object"?t.skills:{}}catch{return{}}}function J2(e,t){let n=w5(Z2(t),Z2(e));return n!==""&&n!==".."&&!n.startsWith(`..${_5}`)&&!x5(n)}function E5(e,t){if(e[t])return e[t];let n=t.toLowerCase(),r=Object.keys(e).find((i)=>i.toLowerCase()===n);return r?e[r]:void 0}function S5(e,t){if(t!=="github")return e.replace(/\/$/,"");return e.replace(/^git\+/,"").replace(/^https?:\/\/github\.com\//,"").replace(/^git@github\.com:/,"").replace(/\.git$/,"").replace(/\/$/,"")}function T5(e,t){if(!e||e.includes("://")||e.startsWith("git@"))return;let n=e.split("/").filter(Boolean).map(encodeURIComponent).join("/");if(!n)return;return`https://skills.sh/${n}/${encodeURIComponent(t)}`}function C5(e,t){let n=typeof e.sourceType==="string"?e.sourceType:void 0,r=S5(e.source.trim(),n),i=typeof e.skillPath==="string"?e.skillPath:void 0,o=typeof e.ref==="string"?e.ref:void 0,s=t==="global"?e.skillFolderHash:e.computedHash;return{sourceType:n,source:r,skillPath:i,ref:o,versionHash:typeof s==="string"&&s?s:void 0}}function A5(e,t){let{sourceType:n,source:r,skillPath:i,versionHash:o,ref:s}=e,a=n==="github"&&/^[\w.-]+\/[\w.-]+$/.test(r);return Boolean(a&&i&&o&&(t==="global"||!s))}function Q2(e,t,n){let r=E5(e,t);if(!r||typeof r.source!=="string"||!r.source.trim())return;let{sourceType:i,source:o,skillPath:s,ref:a,versionHash:c}=C5(r,n);if(!o)return;return{package:`${o}@${t}`,scope:n,source:o,sourceType:i,skillsShUrl:i==="local"?void 0:T5(o,t),...s&&{skillPath:s},...a&&{ref:a},...c&&{versionHash:c},canCheckForUpdates:A5({sourceType:i,source:o,skillPath:s,versionHash:c,ref:a},n)}}function e1(e,{cwd:t,agentDir:n,globalLockPath:r=D5(),projectLockPath:i=Js(t,"skills-lock.json")}){let o=Y2(r),s=Y2(i),a=Js(n,"skills"),c=Js(t,".pi","skills");return e.map((u)=>{if(!y5(u.filePath))return u;let d=J2(u.filePath,a)?Q2(o,u.name,"global"):J2(u.filePath,c)?Q2(s,u.name,"project"):void 0;return d?{...u,install:d}:u})}var k5=32,hi=new Map,np=new Map;async function an(e,t){let n=t?.forceFresh??!1,r=e===""?t1():e;if(!n){let s=hi.get(e);if(s)return{skills:[...s.skills.values()],diagnostics:s.diagnostics,projectResourcesLoaded:s.projectResourcesLoaded}}let i=np.get(e);if(i)return i;let o=R5(r,e);np.set(e,o);try{return await o}finally{np.delete(e)}}async function R5(e,t){let n=t1(),r=new U5({cwd:e,agentDir:n});await r.reload(uo(e,n));let{skills:i,diagnostics:o}=r.getSkills(),s={skills:e1(i,{cwd:e,agentDir:n}),diagnostics:o,projectResourcesLoaded:ut(e,n).trusted},a=new Map;for(let c of s.skills)a.set(c.filePath,c);return hi.set(t,{skills:a,diagnostics:s.diagnostics,projectResourcesLoaded:s.projectResourcesLoaded,loadedAt:Date.now()}),F5(),s}function F5(){while(hi.size>k5){let e=null,t=1/0;for(let[n,r]of hi){if(n==="")continue;if(r.loadedAt<t)t=r.loadedAt,e=n}if(e===null)break;hi.delete(e)}}function n1(e,t,n){let r=hi.get(e);if(!r)return;let i=r.skills.get(t);if(!i){hi.delete(e);return}if(n.disableModelInvocation!==void 0)i.disableModelInvocation=n.disableModelInvocation}var ku=null;function r1(e){if(ku)return;let t=(async()=>{for(let n of e)await Promise.allSettled([n()])})();ku=t,t.then(()=>{ku=null})}function wn(){return ku??Promise.resolve()}var i1={port:31415};import{getAgentDir as Ale}from"@earendil-works/pi-coding-agent";var rp=(e,t,n)=>(r,i)=>{let o=-1;return s(0);async function s(a){if(a<=o)throw Error("next() called multiple times");o=a;let c,u=!1,d;if(e[a])d=e[a][0][0],r.req.routeIndex=a;else d=a===e.length&&i||void 0;if(d)try{c=await d(r,()=>s(a+1))}catch(f){if(f instanceof Error&&t)r.error=f,c=await t(f,r),u=!0;else throw f}else if(r.finalized===!1&&n)c=await n(r);if(c&&(r.finalized===!1||u))r.res=c;return r}};var o1=Symbol();var s1=(e,t)=>new Response(e,{headers:{"Content-Type":t.replace(/^[^;]+/,(r)=>r.toLowerCase())}}).formData();var a1=32,P5=1e4,Ru=(e)=>("headers"in e),l1=async(e,t=Object.create(null))=>{let{all:n=!1,dot:r=!1}=t,s=(Ru(e)?e.headers:e.raw.headers).get("Content-Type")?.split(";")[0].trim().toLowerCase();if(s==="multipart/form-data"||s==="application/x-www-form-urlencoded")return O5(e,{all:n,dot:r});return{}};async function O5(e,t){if(!Ru(e)&&e.bodyCache.formData)return c1(await e.bodyCache.formData,t);let n=Ru(e)?e.headers:e.raw.headers,r=await e.arrayBuffer(),i=s1(r,n.get("Content-Type")||"");if(!Ru(e))e.bodyCache.formData=i;let o=await i;if(o)return c1(o,t);return{}}function c1(e,t){let n=Object.create(null),r={count:0};if(e.forEach((i,o)=>{if(!(t.all||o.endsWith("[]")))n[o]=i;else I5(n,o,i)}),t.dot)Object.entries(n).forEach(([i,o])=>{if(i.includes("."))M5(n,i,o,r),delete n[i]});return n}var I5=(e,t,n)=>{if(e[t]!==void 0)if(Array.isArray(e[t]))e[t].push(n);else e[t]=[e[t],n];else if(!t.endsWith("[]"))e[t]=n;else e[t]=[n]},M5=(e,t,n,r)=>{if(/(?:^|\.)__proto__\./.test(t))return;let i=e,o=t.split(".",a1+2);if(o.length>a1+1)u1();o.forEach((s,a)=>{if(a===o.length-1)i[s]=n;else{if(!i[s]||typeof i[s]!=="object"||Array.isArray(i[s])||i[s]instanceof File){if(r.count++>=P5)u1();i[s]=Object.create(null)}i=i[s]}})},u1=()=>{throw Error("Nesting limit exceeded")};pi();var b1=class{raw;#e;#t;routeIndex=0;path;bodyCache={};constructor(e,t="/",n=[[]]){this.raw=e,this.path=t,this.#t=n}param(e){return e?this.#n(e):this.#o()}#n(e){let t=this.#t[0][this.routeIndex]?.[1][e],n=this.#i(t);return n&&Ou(n)}#o(){let e={},t=Object.keys(this.#t[0][this.routeIndex]?.[1]??{});for(let n of t){let r=this.#i(this.#t[0][this.routeIndex][1][n]);if(r!==void 0)e[n]=Ou(r)}return e}#i(e){return this.#t[1]?this.#t[1][e]:e}query(e){return m1(this.url,e)}queries(e){return y1(this.url,e)}header(e){if(e)return this.raw.headers.get(e)??void 0;let t=Object.create(null);return this.raw.headers.forEach((n,r)=>{t[r]=n}),t}async parseBody(e){return l1(this,e)}#r=(e)=>{let{bodyCache:t,raw:n}=this,r=t[e];if(r)return r;for(let i in t)return t[i].then((o)=>{if(i==="json")o=JSON.stringify(o);return new Response(o)[e]()});return t[e]=n[e]()};json(){return this.#r("text").then((e)=>JSON.parse(e))}text(){return this.#r("text")}arrayBuffer(){return this.#r("arrayBuffer")}bytes(){return this.#r("arrayBuffer").then((e)=>new Uint8Array(e))}blob(){return this.#r("blob")}formData(){return this.#r("formData")}addValidatedData(e,t){(this.#e??={})[e]=t}valid(e){return this.#e?.[e]}get url(){return this.raw.url}get method(){return this.raw.method}get[o1](){return this.#t}get matchedRoutes(){return this.#t[0].map(([[,e]])=>e)}get routePath(){return this.#t[0].map(([[,e]])=>e)[this.routeIndex].path}};up();var W5="text/plain; charset=UTF-8",lp=(e,t)=>({"Content-Type":e,...t}),Qs=(e,t)=>new Response(e,t),dp=class{#e;#t;env={};#n;finalized=!1;error;#o;#i;#r;#c;#s;#a;#l;#d;#f;constructor(e,t){if(this.#e=e,t)this.#i=t.executionCtx,this.env=t.env,this.#a=t.notFoundHandler,this.#f=t.path,this.#d=t.matchResult}get req(){return this.#t??=new b1(this.#e,this.#f,this.#d),this.#t}get event(){if(this.#i&&"respondWith"in this.#i)return this.#i;else throw Error("This context has no FetchEvent")}get executionCtx(){if(this.#i)return this.#i;else throw Error("This context has no ExecutionContext")}get res(){return this.#r||=Qs(null,{headers:this.#l??=new Headers})}set res(e){if(this.#r&&e){e=Qs(e.body,e);for(let[t,n]of this.#r.headers.entries()){if(t==="content-type")continue;if(t==="set-cookie"){let r=this.#r.headers.getSetCookie();e.headers.delete("set-cookie");for(let i of r)e.headers.append("set-cookie",i)}else e.headers.set(t,n)}}this.#r=e,this.finalized=!0}render=(...e)=>(this.#s??=(t)=>this.html(t),this.#s(...e));setLayout=(e)=>this.#c=e;getLayout=()=>this.#c;setRenderer=(e)=>{this.#s=e};header=(e,t,n)=>{if(this.finalized)this.#r=Qs(this.#r.body,this.#r);let r=this.#r?this.#r.headers:this.#l??=new Headers;if(t===void 0)r.delete(e);else if(n?.append)r.append(e,t);else r.set(e,t)};status=(e)=>{this.#o=e};set=(e,t)=>{this.#n??=new Map,this.#n.set(e,t)};get=(e)=>this.#n?this.#n.get(e):void 0;get var(){if(!this.#n)return{};return Object.fromEntries(this.#n)}#u(e,t,n){let r=this.#r?new Headers(this.#r.headers):this.#l;if(typeof t==="object"&&t.headers){r??=new Headers;for(let[o,s]of new Headers(t.headers))if(o==="set-cookie")r.append(o,s);else r.set(o,s)}if(n){if(!r){let o=0;for(let s in n)if(++o>1||typeof n[s]!=="string"){r=new Headers;break}}if(r)for(let o in n){let s=n[o];if(typeof s==="string")r.set(o,s);else{r.delete(o);for(let a of s)r.append(o,a)}}}let i=typeof t==="number"?t:t?.status??this.#o;return Qs(e,{status:i,headers:r??n})}newResponse=(...e)=>this.#u(...e);body=(e,t,n)=>this.#u(e,t,n);text=(e,t,n)=>!this.#l&&!this.#o&&!t&&!n&&!this.finalized?new Response(e):this.#u(e,t,lp(W5,n));json=(e,t,n)=>this.#u(JSON.stringify(e),t,lp("application/json",n));html=(e,t,n)=>{let r=(i)=>this.#u(i,t,lp("text/html; charset=UTF-8",n));return typeof e==="object"?cp(e,v1.Stringify,!1,{}).then(r):r(e)};redirect=(e,t)=>{let n=String(e);return this.header("Location",!/[^\x00-\xFF]/.test(n)?n:encodeURI(n)),this.newResponse(null,t??302)};notFound=()=>(this.#a??=()=>Qs(),this.#a(this))};Dr();fp();pi();var j5=(e)=>e.text("404 Not Found",404),D1=(e,t)=>{if("getResponse"in e){let n=e.getResponse();return t.newResponse(n.body,n)}return console.error(e),t.text("Internal Server Error",500)},E1=class e{get;post;put;delete;options;patch;query;all;on;use;router;getPath;_basePath="/";#e="/";routes=[];constructor(t={}){[..._1,w1].forEach((o)=>{this[o]=(s,...a)=>{if(typeof s==="string")this.#e=s;else this.#o(o,this.#e,s);return a.forEach((c)=>{this.#o(o,this.#e,c)}),this}}),this.on=(o,s,...a)=>{for(let c of[s].flat()){this.#e=c;for(let u of[o].flat())a.map((d)=>{this.#o(u.toUpperCase(),this.#e,d)})}return this},this.use=(o,...s)=>{if(typeof o==="string")this.#e=o;else this.#e="*",s.unshift(o);return s.forEach((a)=>{this.#o($e,this.#e,a)}),this};let{strict:r,...i}=t;Object.assign(this,i),this.getPath=r??!0?t.getPath??ap:p1}#t(){let t=new e({router:this.router,getPath:this.getPath});return t.errorHandler=this.errorHandler,t.#n=this.#n,t.routes=this.routes,t}#n=j5;errorHandler=D1;route(t,n){let r=this.basePath(t);return n.routes.map((i)=>{let o;if(n.errorHandler===D1)o=i.handler;else o=async(s,a)=>(await rp([],n.errorHandler)(s,()=>i.handler(s,a))).res,o[ea]=i.handler;r.#o(i.method,i.path,o,i.basePath)}),this}basePath(t){let n=this.#t();return n._basePath=_r(this._basePath,t),n}onError=(t)=>(this.errorHandler=t,this);notFound=(t)=>(this.#n=t,this);mount(t,n,r){let i,o;if(r)if(typeof r==="function")o=r;else if(o=r.optionHandler,r.replaceRequest===!1)i=(c)=>c;else i=r.replaceRequest;let s=o?(c)=>{let u=o(c);return Array.isArray(u)?u:[u]}:(c)=>{let u=void 0;try{u=c.executionCtx}catch{}return[c.env,u]};i||=(()=>{let c=_r(this._basePath,t),u=c==="/"?0:c.length;return(d)=>{let f=new URL(d.url);return f.pathname=this.getPath(d).slice(u)||"/",new Request(f,d)}})();let a=async(c,u)=>{let d=await n(i(c.req.raw),...s(c));if(d)return d;await u()};return this.#o($e,_r(t,"*"),a),this}#o(t,n,r,i){t=t.toUpperCase(),n=_r(this._basePath,n);let o={basePath:i!==void 0?_r(this._basePath,i):this._basePath,path:n,method:t,handler:r};this.router.add(t,n,[r,o]),this.routes.push(o)}#i(t,n){if(t instanceof Error)return this.errorHandler(t,n);throw t}#r(t,n,r,i){if(i==="HEAD")return(async()=>new Response(null,await this.#r(t,n,r,"GET")))();let o=this.getPath(t,{env:r}),s=this.router.match(i,o),a=new dp(t,{path:o,matchResult:s,env:r,executionCtx:n,notFoundHandler:this.#n});if(s[0].length===1){let u;try{u=s[0][0][0][0](a,async()=>{a.res=await this.#n(a)})}catch(d){return this.#i(d,a)}return u instanceof Promise?u.then((d)=>d||(a.finalized?a.res:this.#n(a))).catch((d)=>this.#i(d,a)):u??this.#n(a)}let c=rp(s[0],this.errorHandler,this.#n);return(async()=>{try{let u=await c(a);if(!u.finalized)throw Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return u.res}catch(u){return this.#i(u,a)}})()}fetch=(t,...n)=>this.#r(t,n[1],n[0],t.method);request=(t,n,r,i)=>{if(t instanceof Request)return this.fetch(n?new Request(t,n):t,r,i);return t=t.toString(),this.fetch(new Request(/^https?:\/\//.test(t)?t:`http://localhost${_r("/",t)}`,n),r,i)};fire=()=>{addEventListener("fetch",(t)=>{t.respondWith(this.#r(t.request,t,void 0,t.request.method))})}};Dr();pi();var Ke=()=>Object.create(null);Dr();var Bu=[];function hp(e,t){let n=this.buildAllMatchers(),r=(i,o)=>{let s=n[i]||n[$e],a=s[2][o];if(a)return a;let c=o.match(s[0]);if(!c)return[[],Bu];let u=c.indexOf("",1);return[s[1][u],c]};return this.match=r,r(e,t)}var lo="[^/]+",Sr=".*",Vn="(?:|/.*)",Er=Symbol(),S1=new Set(".\\+*[^]$()");function q5(e,t){if(e.length===1)return t.length===1?e<t?-1:1:-1;if(t.length===1)return 1;if(e===Sr||e===Vn)return t===Vn?-1:1;else if(t===Sr||t===Vn)return-1;if(e===lo)return 1;else if(t===lo)return-1;return e.length===t.length?e<t?-1:1:t.length-e.length}var T1=class e{#e;#t;#n=Ke();insert(t,n,r,i,o){let s=this;for(let a=0,c=t.length;a<c;a++){let u=t[a],d=u.length===1?u==="*"?a===c-1?["","",Sr]:["","",lo]:null:u==="/*"?["","",Vn]:u.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/),f;if(d){let h=d[1],p=d[2]||lo;if(h&&d[2]){if(p===".*")throw Er;if(p=p.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(p))throw Er;if(p.length===1&&S1.has(p))throw Er}if(f=s.#n[p],!f){if(p!==Sr&&p!==Vn){for(let g in s.#n)if((p.length>1||g.length>1)&&g!==Sr&&g!==Vn)throw Er}f=s.#n[p]=new e}if(h!=="")f.#t??=i.varIndex++,r.push([h,f.#t])}else if(f=s.#n[u],!f){for(let h in s.#n)if(h.length>1&&h!==Sr&&h!==Vn)throw Er;f=s.#n[u]=new e}s=f}if(s.#e!==void 0)throw Er;s.#e=o?-1:n}buildRegExpStr(){let n=Object.keys(this.#n).sort(q5).map((r)=>{let i=this.#n[r],o=i.buildRegExpStr();return o===""?"":(typeof i.#t==="number"?`(${r})@${i.#t}`:S1.has(r)?`\\${r}`:r)+o}).filter(Boolean);if(typeof this.#e==="number"&&this.#e!==-1)n.unshift(`#${this.#e}`);if(n.length===0)return"";if(n.length===1)return n[0];return"(?:"+n.join("|")+")"}};var pp=class{#e={varIndex:0};#t=new T1;#n=0;paths=Ke();insert(e,t){if(t){this.#t.insert(e.split(""),0,[],this.#e,!0);return}let n=[],r=[],i=e;for(let s=0;;){let a=!1;if(i=i.replace(/\{[^}]+\}/g,(c)=>{let u=`@\\${s}`;return r[s]=[u,c],s++,a=!0,u}),!a)break}let o=i.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let s=r.length-1;s>=0;s--){let[a]=r[s];for(let c=o.length-1;c>=0;c--)if(o[c].indexOf(a)!==-1){o[c]=o[c].replace(a,r[s][1]);break}}this.#t.insert(o,this.#n,n,this.#e,!1),this.paths[e]=[this.#n++,n]}buildRegExp(){let e=this.#t.buildRegExpStr();if(e==="")return[/^$/,[],[]];let t=0,n=[],r=[];return e=e.replace(/#(\d+)|@(\d+)|\.\*\$/g,(i,o,s)=>{if(o!==void 0)return n[++t]=Number(o),"$()";if(s!==void 0)return r[Number(s)]=++t,"";return""}),[new RegExp(`^${e}`),n,r]}};var C1=Ke();function A1(e){return C1[e]??=new RegExp(`^${e.replace(/\/:[^/{}]+(?:\{\[\^\/]\+})?(?=[/{]|$)|\/?\*$|([.\\+*[^\]$()?{}|])/g,(t,n)=>n?`\\${n}`:t==="/*"?Vn:t==="*"?Sr:`/:${lo}`)}$`)}function Nu(e,t){for(let n of Object.keys(e).sort((r,i)=>i.length-r.length))if(A1(n).test(t))return[...e[n]];return}var Lu=class{name="RegExpRouter";#e;#t;#n;constructor(){this.#e={[$e]:Ke()},this.#t={[$e]:Ke()},this.#n={[$e]:new pp}}#o(e,t){try{this.#n[e].insert(t,!/\*|\/:/.test(t))}catch(n){throw n===Er?new Mu(t):n}}add(e,t,n){let r=this.#e,i=this.#t;if(!r)throw Error(Iu);if(!r[e]){this.#n[e]=new pp;for(let a of[r,i]){a[e]=Ke();for(let c in a[$e])a[e][c]=[...a[$e][c]],this.#o(e,c)}}if(t==="/*")t="*";let o=e===$e?Object.keys(r):[e];if(/\*$/.test(t)){let a=A1(t);for(let c of o)if(!r[c][t])this.#o(c,t),r[c][t]=Nu(r[c],t)||Nu(r[$e],t)||[];for(let c of[r,i])for(let u of o)for(let d in c[u])a.test(d)&&c[u][d].push([n,t]);return}let s=Pu(t)||[t];for(let a of s)for(let c of o){if(!i[c][a])this.#o(c,a),i[c][a]=Nu(r[c],a)||Nu(r[$e],a)||[];i[c][a].push([n,a])}}match=hp;buildAllMatchers(){let e=Ke();for(let t of Object.keys(this.#t))e[t]=this.#i(t);return this.#e=this.#t=this.#n=void 0,C1=Ke(),e}#i(e){let t=this.#e[e],n=this.#t[e],r=this.#n[e],i=Ke(),o=[],[s,a,c]=r.buildRegExp();for(let u of[t,n])for(let d in u){let f=u[d],h=r.paths[d];if(!h){i[d]=[f.map(([p])=>[p,Ke()]),Bu];continue}o[h[0]]=f.map(([p,g])=>[p,r.paths[g][1].reduceRight((b,[v],y)=>(b[v]=c[h[1][y][1]],b),Ke())])}return[s,a.map((u)=>o[u]),i]}};Dr();Dr();var gp=class{name="SmartRouter";#e=[];#t=[];constructor(e){this.#e=e.routers}add(e,t,n){if(!this.#t)throw Error(Iu);this.#t.push([e,t,n])}match(e,t){if(!this.#t)throw Error("Fatal error");let n=this.#e,r=this.#t,i=n.length,o=0,s;for(;o<i;o++){let a=n[o];try{for(let c=0,u=r.length;c<u;c++)a.add(...r[c]);s=a.match(e,t)}catch(c){if(c instanceof Mu)continue;throw c}this.match=a.match.bind(a),this.#e=[a],this.#t=void 0;break}if(o===i)throw Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,s}get activeRouter(){if(this.#t||this.#e.length!==1)throw Error("No active router has been determined yet.");return this.#e[0]}};pi();Dr();pi();var mp=Ke(),H5=0,U1=class e{#e=[];#t=Ke();#n=[];#o;#i=mp;insert(t,n,r){let i=this,o=d1(n),s=new Set,a=0;for(let c of o){let u=o[++a],d=f1(c,u)||(u===void 0&&c&&c.indexOf("*")===c.length-1?c:null),f=Array.isArray(d),h=f?d[0]:d||c,p=i.#t[h]||=new e;if(d&&!p.#o)p.#o=d,i.#n.push(p);if(i=p,f)s.add(d[1])}i.#e.push({[t]:{handler:r,possibleKeys:[...s],score:++H5}})}#r(t,n,r,i,o){for(let s=0,a=n.#e.length;s<a;s++){let c=n.#e[s],u=c[r]||c[$e];if(u){u.params=Ke(),t.push(u);for(let d=0,f=u.possibleKeys.length;d<f;d++){let h=u.possibleKeys[d];u.params[h]=o?.[h]&&!d?o[h]:i[h]??o?.[h]}}}}search(t,n){let r=[];this.#i=mp;let o=[this],s=op(n),a=[],c=s.length,u=null;for(let d=0;d<c;d++){let f=s[d],h=d===c-1,p=[];for(let b=0,v=o.length;b<v;b++){let y=o[b],x=y.#t[f];if(x)if(x.#i=y.#i,h){if(x.#t["*"])this.#r(r,x.#t["*"],t,y.#i);this.#r(r,x,t,y.#i)}else p.push(x);for(let m of y.#n){let w=m.#o,D=y.#i===mp?{}:{...y.#i};if(typeof w==="string"){if(w==="*"||f.startsWith(w.slice(0,-1))){if(this.#r(r,m,t,y.#i),w==="*")m.#i=D,p.push(m)}continue}let[,C,_]=w;if(!f&&_===!0)continue;if(_!==!0){if(!u){u=[];let B=n[0]==="/"?1:0;for(let F=0;F<c;F++)u[F]=B,B+=s[F].length+1}let A=n.slice(u[d]),S=_.exec(A);if(S){if(D[C]=S[0],this.#r(r,m,t,y.#i,D),S[0].length===A.length&&m.#t["*"])this.#r(r,m.#t["*"],t,y.#i,D);for(let B in m.#t){m.#i=D;let F=S[0].match(/\//g)?.length??0;(a[F]||=[]).push(m);break}continue}}if(_===!0||_.test(f))if(D[C]=f,h){if(this.#r(r,m,t,D,y.#i),m.#t["*"])this.#r(r,m.#t["*"],t,D,y.#i)}else m.#i=D,p.push(m)}}let g=a.shift();o=g?p.concat(g):p}if(r[1])r.sort((d,f)=>d.score-f.score);return[r.map(({handler:d,params:f})=>[d,f])]}};var yp=class{name="TrieRouter";#e=new U1;add(e,t,n){for(let r of Pu(t)||[t])this.#e.insert(e,r,n)}match(e,t){return this.#e.search(e,t)}};var bp=class extends E1{constructor(e={}){super(e);this.router=e.router??new gp({routers:[new Lu,new yp]})}};function vp(){let e={};return e.promise=new Promise((t,n)=>{e.resolve=t,e.reject=n}),e}import{execFile as $5}from"node:child_process";import fo from"node:path";import{promisify as G5}from"node:util";var ta=G5($5),Wu=1e4,k1=120000,na=8388608;async function vt(e,t,n=na,r=Wu){let{stdout:i}=await ta("git",["-C",e,...t],{timeout:r,maxBuffer:n,env:{...process.env,LC_ALL:"C"}});return i}async function Ct(e){try{return(await vt(e,["rev-parse","--show-toplevel"])).trim()||null}catch{return null}}function gi(e,t){let n=fo.relative(fo.resolve(e),fo.resolve(t));return n===""||!n.startsWith(`..${fo.sep}`)&&n!==".."&&!fo.isAbsolute(n)}function Tr(e){return e.split(fo.sep).join("/")}function ju(e){return e.includes(0)}import{lstat as tB,readFile as nB}from"node:fs/promises";import M1 from"node:path";var mi=262144,R1=10485760,F1=10485760,z5={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",bmp:"image/bmp",ico:"image/x-icon",avif:"image/avif"},V5={mp3:"audio/mpeg",wav:"audio/wav",ogg:"audio/ogg",oga:"audio/ogg",opus:"audio/ogg",m4a:"audio/mp4",aac:"audio/aac",flac:"audio/flac",weba:"audio/webm",webm:"audio/webm"},X5={pdf:"application/pdf",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"};function K5(e){return e.replace(/\\/g,"/").split("/").pop()??""}function ho(e){return K5(e).toLowerCase().split(".").pop()??""}function qu(e){return z5[ho(e)]??null}function Hu(e){return V5[ho(e)]??null}function $u(e){return X5[ho(e)]??null}function P1(e){let t=ho(e);if(t==="pdf"||t==="docx")return t;return null}function Z5(e,t){return e==="R"||e==="C"||t==="R"||t==="C"}function O1(e){let t=e.split("\x00"),n=[];for(let r=0;r<t.length;r++){let i=t[r];if(!i||i.length<4||i[2]!==" ")continue;let o=i[0],s=i[1],a={path:i.slice(3),indexStatus:o,worktreeStatus:s};if(Z5(o,s))a.originalPath=t[++r]||void 0;n.push(a)}return n}var Y5=new Set(["DD","AU","UD","UA","DU","AA","UU"]);function Gu(e){let t=`${e.indexStatus}${e.worktreeStatus}`;if(t==="??")return{status:"untracked",code:"U"};if(Y5.has(t)||t.includes("U"))return{status:"conflict",code:"C"};if(t.includes("D"))return{status:"deleted",code:"D"};if(t.includes("R")||t.includes("C"))return{status:"renamed",code:"R"};if(t.includes("A"))return{status:"added",code:"A"};return{status:"modified",code:"M"}}import{lstat as J5,readFile as Q5}from"node:fs/promises";import xp from"node:path";async function wp(e){let t=await vt(e,["status","--porcelain=v1","-z","--untracked-files=all"]);return O1(t)}async function I1(e,t,n){let i=Tr(xp.relative(e,t))||".";try{let o=await vt(e,["diff","--no-color","--no-ext-diff","--numstat",...n,"--",i]),s=new Map;for(let a of o.split(/\r?\n/)){if(!a)continue;let[c,u,...d]=a.split("\t");if(d.length===0)continue;let f=Number(c),h=Number(u);if(!Number.isInteger(f)||!Number.isInteger(h))continue;let p=d.join("\t"),g=p.indexOf(" => ");if(g!==-1)p=p.slice(g+4);s.set(Tr(p.trim()),{additions:f,deletions:h})}return s}catch{return new Map}}async function eB(e){try{let t=await J5(e);if(!t.isFile()||t.size>mi)return 0;let n=await Q5(e);if(ju(n)||n.length===0)return 0;let r=n.toString("utf8");return r.endsWith(`
259
+ `)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();if(t&&e.find((r)=>t.is(r)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function U2(e){return e.map((t)=>{if(!t.startsWith("--inspect"))return t;let n,r="127.0.0.1",i="9229",o;if((o=t.match(/^(--inspect(-brk)?)$/))!==null)n=o[1];else if((o=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(n=o[1],/^\d+$/.test(o[3]))i=o[3];else r=o[3];else if((o=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)n=o[1],r=o[3],i=o[4];if(n&&i!=="0")return`${n}=${r}:${parseInt(i)+1}`;return t})}function k2(){if(ge.env.NO_COLOR||ge.env.FORCE_COLOR==="0"||ge.env.FORCE_COLOR==="false")return!1;if(ge.env.FORCE_COLOR||ge.env.CLICOLOR_FORCE!==void 0)return!0;return}var bhe=new so;var Xs={name:"@rainmanhhh/pi-web",version:"0.16.1",description:"Web UI for the pi coding agent (fork of @agegr/pi-web)",homepage:"https://gitee.com/dsxbygzzl/pi-web#readme",repository:{type:"git",url:"git+https://gitee.com/dsxbygzzl/pi-web.git"},bugs:{url:"https://gitee.com/dsxbygzzl/pi-web/issues"},author:"rainmanhhh",license:"MIT",publishConfig:{access:"public",registry:"https://registry.npmjs.org"},engines:{node:">=24.0.0"},files:["dist","public","extensions","package.json"],bin:{"pi-web":"dist/server.mjs"},scripts:{dev:"vite","dev:lan":"vite --host 0.0.0.0",mb:"bun run --env-file=.env.manual api",mf:"bun run --env-file=.env.manual dev -- --port 3001",api:"bun run server/main.ts","api:node":"bun run build:server && node dist/server.mjs","build:server":'bun build server/main.ts --target node --outfile dist/server.mjs --minify --external "@earendil-works/*" --define "process.env.PI_WEB_PACKAGED=1"',"e2e:stop":"bun run scripts/e2e-stop.mjs",build:"vite build && bun run scripts/prune-fonts.mjs","build:analyze":"vite build --config scripts/analyze-bundle.config.ts && bun run scripts/prune-fonts.mjs",lint:"oxlint --fix",fta:"bun scripts/fta-gate.mjs . --output-limit 15",jscpd:"jscpd --config .jscpd.json",check:"tsc --noEmit",format:"biome check --write .",prepublishOnly:"bun run check && bun run build && bun run build:server","test:e2e":"cross-env CODEBUDDY_SAFE_DELETE_ENABLED=0 playwright test","test:unit":"vitest run","test:unit:bun":"bun --bun run test:unit",prepare:"husky || true"},dependencies:{"@codemirror/commands":"^6.11.0","@codemirror/lang-css":"^6.3.1","@codemirror/lang-html":"^6.4.12","@codemirror/lang-javascript":"^6.2.5","@codemirror/lang-json":"^6.0.2","@codemirror/lang-markdown":"^6.5.2","@codemirror/lang-yaml":"^6.1.3","@codemirror/language":"^6.12.4","@codemirror/state":"^6.7.1","@codemirror/theme-one-dark":"^6.1.3","@codemirror/view":"^6.43.9","@earendil-works/pi-agent-core":"0.87.0","@earendil-works/pi-ai":"0.87.0","@earendil-works/pi-coding-agent":"0.87.0","@earendil-works/pi-tui":"0.87.0","@hono/node-server":"^2.1.1","class-variance-authority":"^0.7.1",clsx:"^2.1.1",codemirror:"^6.0.2",hono:"^4.13.5","lucide-react":"^1.37.0","p-defer":"^4.0.1",pointrix:"^1.1.0","proper-lockfile":"4.1.2","radix-ui":"^1.6.7",react:"^19.2.8","react-dom":"^19.2.8",shadcn:"^4.19.0",streamdown:"2.6.0","tailwind-merge":"^3.6.0","tw-animate-css":"^1.4.0",virtua:"^0.50.6",ws:"^8.21.3"},devDependencies:{"@biomejs/biome":"^2.5.13","@lobehub/icons":"^5.16.0","@playwright/test":"^1.62.1","@tailwindcss/postcss":"^4.3.3","@testing-library/dom":"^10.4.1","@testing-library/react":"^16.3.3","@types/node":"^25.9.5","@types/proper-lockfile":"4.1.4","@types/react":"^19.2.18","@types/react-dom":"^19.2.5","@types/react-resizable":"^4.0.0","@types/react-syntax-highlighter":"^15.5.13","@types/ws":"^8.18.1","@vitejs/plugin-react":"^6.1.1",commander:"^15.0.0","cross-env":"^10.1.0","fta-cli":"^3.0.1",husky:"^9.1.7",jiti:"^2.7.0",jscpd:"^5.1.0",jsdom:"^30.0.1",katex:"^0.18.4","lint-staged":"^17.4.1",mammoth:"^1.12.2",mermaid:"^11.17.2",oxlint:"^1.80.0",postcss:"^8.5.26","react-markdown":"^10.1.0","react-syntax-highlighter":"^16.1.1","rehype-katex":"^7.0.1","rehype-raw":"^7.0.0","rehype-sanitize":"^6.0.0","remark-gfm":"^4.0.1","remark-math":"^6.0.0",tailwindcss:"^4.3.3",typescript:"^7.0.2",vite:"^8.2.2","vite-plugin-remove-console":"^2.2.0","vite-plugin-svgr":"^5.2.0",vitest:"^4.1.11"},type:"module",overrides:{katex:"^0.18.4"}};var Wh=!1,R2=performance.now();function F2(e){if(Wh=e,R2=performance.now(),Wh)Nt("boot","debug log enabled")}function ct(e){return(t,n)=>Nt(e,t,n)}function Nt(e,t,n){if(!Wh)return;let r=performance.now()-R2,i=new Date,o=(a,c=2)=>String(a).padStart(c,"0"),s=`${o(i.getHours())}:${o(i.getMinutes())}:${o(i.getSeconds())}.${o(i.getMilliseconds(),3)}`;console.debug(`[debug][${e}][${s}][+${r.toFixed(1)}ms] ${t}${n?` — ${n}`:""}`)}import{existsSync as c5,mkdirSync as u5,readFileSync as z2,writeFileSync as l5}from"node:fs";import{dirname as d5,join as V2}from"node:path";import{getAgentDir as X2}from"@earendil-works/pi-coding-agent";var I2=[{label:{en:"Explore project","zh-CN":"阅读项目"},message:{en:"Explore the current project and summarize the overall directory structure and responsibilities of core modules.","zh-CN":"阅读当前项目,总结整体目录结构与核心模块的职责。"}},{label:{en:"Review workspace changes","zh-CN":"审查工作区改动"},message:{en:"Review all changes in the current workspace, point out potential issues and improvements.","zh-CN":"审查当前工作区的所有改动,指出潜在问题与改进点。"}},{label:{en:"Find and fix bugs","zh-CN":"寻找并修复bug"},message:{en:"Inspect the current codebase, find and fix existing bugs.","zh-CN":"检查当前代码,寻找并修复其中存在的 bug。"}}];var M2=I2;import{readFileSync as L2,writeFileSync as o5}from"node:fs";import{join as s5}from"node:path";import{getAgentDir as a5}from"@earendil-works/pi-coding-agent";var xu=["off","minimal","low","medium","high","xhigh","max"];function wu(e){return e==="en"||e==="zh-CN"?e:void 0}function Hh(e){return e==="dark"||e==="light"?e:void 0}function _u(e){return typeof e==="string"&&xu.includes(e)?e:void 0}function $h(e){if(typeof e!=="object"||e===null)return;let t=e;if(typeof t.enabled!=="boolean")return;if(typeof t.reserveTokens!=="number"||!Number.isInteger(t.reserveTokens)||t.reserveTokens<=0)return;if(typeof t.keepRecentTokens!=="number"||!Number.isInteger(t.keepRecentTokens)||t.keepRecentTokens<=0)return;return{enabled:t.enabled,reserveTokens:t.reserveTokens,keepRecentTokens:t.keepRecentTokens}}function i5(e){if(typeof e!=="object"||e===null)return;let t=e,n={};if(typeof t.timeoutMs==="number"&&Number.isInteger(t.timeoutMs)&&t.timeoutMs>0)n.timeoutMs=t.timeoutMs;if(typeof t.maxRetries==="number"&&Number.isInteger(t.maxRetries)&&t.maxRetries>0)n.maxRetries=t.maxRetries;if(typeof t.maxRetryDelayMs==="number"&&Number.isInteger(t.maxRetryDelayMs)&&t.maxRetryDelayMs>0)n.maxRetryDelayMs=t.maxRetryDelayMs;return Object.keys(n).length>0?n:void 0}function Gh(e){if(typeof e!=="object"||e===null)return;let t=e;if(typeof t.maxRetries!=="number"||!Number.isInteger(t.maxRetries)||t.maxRetries<=0)return;if(typeof t.baseDelayMs!=="number"||!Number.isInteger(t.baseDelayMs)||t.baseDelayMs<=0)return;let n={maxRetries:t.maxRetries,baseDelayMs:t.baseDelayMs};if(typeof t.enabled==="boolean")n.enabled=t.enabled;let r=i5(t.provider);if(r!==void 0)n.provider=r;return n}function Du(e){if(e==="ask"||e==="always"||e==="never")return e;if(e==="trust")return"always";if(e==="deny")return"never";return}function Eu(e){if(typeof e!=="object"||e===null)return;let t=e,n={};if(typeof t.defaultModel==="string"&&t.defaultModel.trim()!=="")n.defaultModel=t.defaultModel;let r=_u(t.defaultThinking);if(r!==void 0)n.defaultThinking=r;return Object.keys(n).length>0?n:void 0}function Su(e){return typeof e==="number"&&Number.isFinite(e)&&e>=0.85&&e<=1.3?e:void 0}var Ks=(e)=>typeof e==="boolean"?e:void 0,qh=(e)=>typeof e==="number"&&Number.isInteger(e)&&e>0?e:void 0,B2=(e)=>typeof e==="string"&&e.trim()!==""?e:void 0;function N2(e,t){if(typeof e!=="object"||e===null)return;let n=e,r={};for(let[i,o]of Object.entries(t)){let s=o(n[i]);if(s!==void 0)r[i]=s}return Object.keys(r).length>0?r:void 0}var zh=[{key:"httpProxy",validate:B2},{key:"httpIdleTimeoutMs",validate:qh},{key:"websocketConnectTimeoutMs",validate:qh},{key:"enableAnalytics",validate:Ks},{key:"enableInstallTelemetry",validate:Ks},{key:"trackingId",validate:B2},{key:"branchSummary",validate:(e)=>N2(e,{reserveTokens:qh,skipPrompt:Ks})},{key:"images",validate:(e)=>N2(e,{autoResize:Ks,blockImages:Ks})}];function Vh(e){return $h(ao("compaction",e))}function W2(e,t){let n=$h(e);if(!n)return Vh(t);return Zs("compaction",n,t),n}function Xh(e){return Gh(ao("retry",e))}function j2(e,t){let n=Gh(e);if(!n)return Xh(t);return Zs("retry",n,t),n}function Kh(e){return Eu(ao("subagents",e))}function q2(e,t){let n=Eu(e);if(n===void 0)return;let r=ao("subagents",t),i=typeof r==="object"&&r!==null?{...r}:{};if(n.defaultModel!==void 0)i.defaultModel=n.defaultModel;else delete i.defaultModel;if(n.defaultThinking!==void 0)i.defaultThinking=n.defaultThinking;else delete i.defaultThinking;return Zs("subagents",i,t),Eu(i)}function ao(e,t){try{return JSON.parse(L2(H2(t),"utf8"))[e]}catch{return}}function Zs(e,t,n){try{let r=H2(n),i={};try{i=JSON.parse(L2(r,"utf8"))}catch{i={}}i[e]=t,o5(r,JSON.stringify(i,null,2),"utf8")}catch{}}function co(e,t){let n=ao(e,t);return typeof n==="string"?n:void 0}function Tu(e,t,n){if(t===void 0)return co(e,n);return Zs(e,t,n),t}function H2(e){return s5(e??a5(),"settings.json")}function Ys(e){return Hh(co("theme",e))??"light"}function $2(e,t){let n=Hh(e);if(!n)return Ys(t);return Tu("theme",n,t),n}function Cu(e){let t={};for(let{key:n,validate:r}of zh){let i=r(ao(n,e));if(i!==void 0)t[n]=i}return Object.keys(t).length>0?t:void 0}function G2(e,t){for(let{key:n,validate:r}of zh){if(!(n in e))continue;let i=r(e[n]);if(i===void 0)continue;Zs(n,i,t)}return Cu(t)}var Au=new Map;function Zh(e){return V2(e??X2(),"pi-web","config.json")}function f5(e){return V2(e??X2(),"pi-web-preferences.json")}function Yh(e){try{if(c5(Zh(e)))return;let t=JSON.parse(z2(f5(e),"utf8"));Jh({firstPaint:{locale:wu(t.firstPaint?.locale),fontScale:Su(t.firstPaint?.fontScale)},preferences:t.preferences??{}},e)}catch{}}function h5(e){let t=_u(co("defaultThinkingLevel",e)),n=Vh(e),r=Xh(e),i=Du(co("defaultProjectTrust",e)),o=Kh(e),s=Cu(e);return{theme:Ys(e),...t!==void 0?{defaultThinkingLevel:t}:{},...n!==void 0?{compaction:n}:{},...r!==void 0?{retry:r}:{},...i!==void 0?{defaultProjectTrust:i}:{},...o!==void 0?{subagents:o}:{},...s!==void 0?{piSettings:s}:{}}}function zn(e){let t=e===void 0,n=e??"",r=t?Au.get(n):void 0;if(!t||r===void 0||r===null)try{let i=z2(Zh(e),"utf8"),o=JSON.parse(i);r={firstPaint:{locale:wu(o.firstPaint?.locale),fontScale:Su(o.firstPaint?.fontScale)},preferences:o.preferences??{},theme:Ys(e)},Au.set(n,r)}catch{if(r={firstPaint:{},preferences:{},theme:Ys(e)},t)Au.set(n,r)}return{...r,...h5(e)}}function Jh(e,t){try{let n=Zh(t);u5(d5(n),{recursive:!0});let r={firstPaint:e.firstPaint,preferences:e.preferences};if(l5(n,JSON.stringify(r,null,2),"utf8"),t===void 0)Au.set("",e)}catch{}}function p5(e,t){return{...e,...t.locale!==void 0?{locale:wu(t.locale)??e.locale}:{},...t.fontScale!==void 0?{fontScale:Su(t.fontScale)??e.fontScale}:{}}}function g5(e,t){if(e===void 0)return Du(co("defaultProjectTrust",t));let n=Du(e);if(n===void 0)return;return Tu("defaultProjectTrust",n,t),n}function Qh(e,t){let n=zn(t),r=p5(n.firstPaint,e),i=n.theme;if(e.theme!==void 0)i=$2(e.theme,t);let o=Tu("defaultThinkingLevel",_u(e.defaultThinkingLevel),t),s=W2(e.compaction,t),a=j2(e.retry,t),c=g5(e.defaultProjectTrust,t),u=e.subagents===void 0?Kh(t):q2(e.subagents,t),d=e.piSettings===void 0?Cu(t):G2(e.piSettings,t),f={firstPaint:r,preferences:n.preferences,theme:i,defaultThinkingLevel:o,...s!==void 0?{compaction:s}:{},...a!==void 0?{retry:a}:{},...c!==void 0?{defaultProjectTrust:c}:{},...u!==void 0?{subagents:u}:{},...d!==void 0?{piSettings:d}:{}};return Jh(f,t),f}function Uu(e,t){let n=zn(t),r={firstPaint:n.firstPaint,preferences:{...n.preferences,...e},theme:n.theme};return Jh(r,t),r}function ep(e){let{preferences:t}=zn(e);if(t.startScreenMessages!==void 0)return;Uu({startScreenMessages:M2},e)}import{DefaultResourceLoader as U5,getAgentDir as t1}from"@earendil-works/pi-coding-agent";import{hasTrustRequiringProjectResources as m5,ProjectTrustStore as tp}from"@earendil-works/pi-coding-agent";function ut(e,t){if(!(Boolean(e)&&m5(e)))return{requiresTrust:!1,trusted:!0};return{requiresTrust:!0,trusted:new tp(t).get(e)===!0}}function K2(e,t){let n=ut(e,t);if(!n.requiresTrust)return n;return new tp(t).set(e,!0),{requiresTrust:!0,trusted:!0}}function uo(e,t){if(!ut(e,t).requiresTrust)return;let r=new tp(t);return{resolveProjectTrust:async()=>r.get(e)===!0}}import{existsSync as y5,readFileSync as b5}from"node:fs";import{homedir as v5}from"node:os";import{isAbsolute as x5,join as Js,relative as w5,resolve as Z2,sep as _5}from"node:path";function D5({homeDir:e=v5(),xdgStateHome:t=process.env.XDG_STATE_HOME}={}){return t?Js(t,"skills",".skill-lock.json"):Js(e,".agents",".skill-lock.json")}function Y2(e){try{let t=JSON.parse(b5(e,"utf8"));return t.skills&&typeof t.skills==="object"?t.skills:{}}catch{return{}}}function J2(e,t){let n=w5(Z2(t),Z2(e));return n!==""&&n!==".."&&!n.startsWith(`..${_5}`)&&!x5(n)}function E5(e,t){if(e[t])return e[t];let n=t.toLowerCase(),r=Object.keys(e).find((i)=>i.toLowerCase()===n);return r?e[r]:void 0}function S5(e,t){if(t!=="github")return e.replace(/\/$/,"");return e.replace(/^git\+/,"").replace(/^https?:\/\/github\.com\//,"").replace(/^git@github\.com:/,"").replace(/\.git$/,"").replace(/\/$/,"")}function T5(e,t){if(!e||e.includes("://")||e.startsWith("git@"))return;let n=e.split("/").filter(Boolean).map(encodeURIComponent).join("/");if(!n)return;return`https://skills.sh/${n}/${encodeURIComponent(t)}`}function C5(e,t){let n=typeof e.sourceType==="string"?e.sourceType:void 0,r=S5(e.source.trim(),n),i=typeof e.skillPath==="string"?e.skillPath:void 0,o=typeof e.ref==="string"?e.ref:void 0,s=t==="global"?e.skillFolderHash:e.computedHash;return{sourceType:n,source:r,skillPath:i,ref:o,versionHash:typeof s==="string"&&s?s:void 0}}function A5(e,t){let{sourceType:n,source:r,skillPath:i,versionHash:o,ref:s}=e,a=n==="github"&&/^[\w.-]+\/[\w.-]+$/.test(r);return Boolean(a&&i&&o&&(t==="global"||!s))}function Q2(e,t,n){let r=E5(e,t);if(!r||typeof r.source!=="string"||!r.source.trim())return;let{sourceType:i,source:o,skillPath:s,ref:a,versionHash:c}=C5(r,n);if(!o)return;return{package:`${o}@${t}`,scope:n,source:o,sourceType:i,skillsShUrl:i==="local"?void 0:T5(o,t),...s&&{skillPath:s},...a&&{ref:a},...c&&{versionHash:c},canCheckForUpdates:A5({sourceType:i,source:o,skillPath:s,versionHash:c,ref:a},n)}}function e1(e,{cwd:t,agentDir:n,globalLockPath:r=D5(),projectLockPath:i=Js(t,"skills-lock.json")}){let o=Y2(r),s=Y2(i),a=Js(n,"skills"),c=Js(t,".pi","skills");return e.map((u)=>{if(!y5(u.filePath))return u;let d=J2(u.filePath,a)?Q2(o,u.name,"global"):J2(u.filePath,c)?Q2(s,u.name,"project"):void 0;return d?{...u,install:d}:u})}var k5=32,hi=new Map,np=new Map;async function an(e,t){let n=t?.forceFresh??!1,r=e===""?t1():e;if(!n){let s=hi.get(e);if(s)return{skills:[...s.skills.values()],diagnostics:s.diagnostics,projectResourcesLoaded:s.projectResourcesLoaded}}let i=np.get(e);if(i)return i;let o=R5(r,e);np.set(e,o);try{return await o}finally{np.delete(e)}}async function R5(e,t){let n=t1(),r=new U5({cwd:e,agentDir:n});await r.reload(uo(e,n));let{skills:i,diagnostics:o}=r.getSkills(),s={skills:e1(i,{cwd:e,agentDir:n}),diagnostics:o,projectResourcesLoaded:ut(e,n).trusted},a=new Map;for(let c of s.skills)a.set(c.filePath,c);return hi.set(t,{skills:a,diagnostics:s.diagnostics,projectResourcesLoaded:s.projectResourcesLoaded,loadedAt:Date.now()}),F5(),s}function F5(){while(hi.size>k5){let e=null,t=1/0;for(let[n,r]of hi){if(n==="")continue;if(r.loadedAt<t)t=r.loadedAt,e=n}if(e===null)break;hi.delete(e)}}function n1(e,t,n){let r=hi.get(e);if(!r)return;let i=r.skills.get(t);if(!i){hi.delete(e);return}if(n.disableModelInvocation!==void 0)i.disableModelInvocation=n.disableModelInvocation}var ku=null;function r1(e){if(ku)return;let t=(async()=>{for(let n of e)await Promise.allSettled([n()])})();ku=t,t.then(()=>{ku=null})}function wn(){return ku??Promise.resolve()}var i1={port:31415};import{getAgentDir as Ale}from"@earendil-works/pi-coding-agent";var rp=(e,t,n)=>(r,i)=>{let o=-1;return s(0);async function s(a){if(a<=o)throw Error("next() called multiple times");o=a;let c,u=!1,d;if(e[a])d=e[a][0][0],r.req.routeIndex=a;else d=a===e.length&&i||void 0;if(d)try{c=await d(r,()=>s(a+1))}catch(f){if(f instanceof Error&&t)r.error=f,c=await t(f,r),u=!0;else throw f}else if(r.finalized===!1&&n)c=await n(r);if(c&&(r.finalized===!1||u))r.res=c;return r}};var o1=Symbol();var s1=(e,t)=>new Response(e,{headers:{"Content-Type":t.replace(/^[^;]+/,(r)=>r.toLowerCase())}}).formData();var a1=32,P5=1e4,Ru=(e)=>("headers"in e),l1=async(e,t=Object.create(null))=>{let{all:n=!1,dot:r=!1}=t,s=(Ru(e)?e.headers:e.raw.headers).get("Content-Type")?.split(";")[0].trim().toLowerCase();if(s==="multipart/form-data"||s==="application/x-www-form-urlencoded")return O5(e,{all:n,dot:r});return{}};async function O5(e,t){if(!Ru(e)&&e.bodyCache.formData)return c1(await e.bodyCache.formData,t);let n=Ru(e)?e.headers:e.raw.headers,r=await e.arrayBuffer(),i=s1(r,n.get("Content-Type")||"");if(!Ru(e))e.bodyCache.formData=i;let o=await i;if(o)return c1(o,t);return{}}function c1(e,t){let n=Object.create(null),r={count:0};if(e.forEach((i,o)=>{if(!(t.all||o.endsWith("[]")))n[o]=i;else I5(n,o,i)}),t.dot)Object.entries(n).forEach(([i,o])=>{if(i.includes("."))M5(n,i,o,r),delete n[i]});return n}var I5=(e,t,n)=>{if(e[t]!==void 0)if(Array.isArray(e[t]))e[t].push(n);else e[t]=[e[t],n];else if(!t.endsWith("[]"))e[t]=n;else e[t]=[n]},M5=(e,t,n,r)=>{if(/(?:^|\.)__proto__\./.test(t))return;let i=e,o=t.split(".",a1+2);if(o.length>a1+1)u1();o.forEach((s,a)=>{if(a===o.length-1)i[s]=n;else{if(!i[s]||typeof i[s]!=="object"||Array.isArray(i[s])||i[s]instanceof File){if(r.count++>=P5)u1();i[s]=Object.create(null)}i=i[s]}})},u1=()=>{throw Error("Nesting limit exceeded")};pi();var b1=class{raw;#e;#t;routeIndex=0;path;bodyCache={};constructor(e,t="/",n=[[]]){this.raw=e,this.path=t,this.#t=n}param(e){return e?this.#n(e):this.#o()}#n(e){let t=this.#t[0][this.routeIndex]?.[1][e],n=this.#i(t);return n&&Ou(n)}#o(){let e={},t=Object.keys(this.#t[0][this.routeIndex]?.[1]??{});for(let n of t){let r=this.#i(this.#t[0][this.routeIndex][1][n]);if(r!==void 0)e[n]=Ou(r)}return e}#i(e){return this.#t[1]?this.#t[1][e]:e}query(e){return m1(this.url,e)}queries(e){return y1(this.url,e)}header(e){if(e)return this.raw.headers.get(e)??void 0;let t=Object.create(null);return this.raw.headers.forEach((n,r)=>{t[r]=n}),t}async parseBody(e){return l1(this,e)}#r=(e)=>{let{bodyCache:t,raw:n}=this,r=t[e];if(r)return r;for(let i in t)return t[i].then((o)=>{if(i==="json")o=JSON.stringify(o);return new Response(o)[e]()});return t[e]=n[e]()};json(){return this.#r("text").then((e)=>JSON.parse(e))}text(){return this.#r("text")}arrayBuffer(){return this.#r("arrayBuffer")}bytes(){return this.#r("arrayBuffer").then((e)=>new Uint8Array(e))}blob(){return this.#r("blob")}formData(){return this.#r("formData")}addValidatedData(e,t){(this.#e??={})[e]=t}valid(e){return this.#e?.[e]}get url(){return this.raw.url}get method(){return this.raw.method}get[o1](){return this.#t}get matchedRoutes(){return this.#t[0].map(([[,e]])=>e)}get routePath(){return this.#t[0].map(([[,e]])=>e)[this.routeIndex].path}};up();var W5="text/plain; charset=UTF-8",lp=(e,t)=>({"Content-Type":e,...t}),Qs=(e,t)=>new Response(e,t),dp=class{#e;#t;env={};#n;finalized=!1;error;#o;#i;#r;#c;#s;#a;#l;#d;#f;constructor(e,t){if(this.#e=e,t)this.#i=t.executionCtx,this.env=t.env,this.#a=t.notFoundHandler,this.#f=t.path,this.#d=t.matchResult}get req(){return this.#t??=new b1(this.#e,this.#f,this.#d),this.#t}get event(){if(this.#i&&"respondWith"in this.#i)return this.#i;else throw Error("This context has no FetchEvent")}get executionCtx(){if(this.#i)return this.#i;else throw Error("This context has no ExecutionContext")}get res(){return this.#r||=Qs(null,{headers:this.#l??=new Headers})}set res(e){if(this.#r&&e){e=Qs(e.body,e);for(let[t,n]of this.#r.headers.entries()){if(t==="content-type")continue;if(t==="set-cookie"){let r=this.#r.headers.getSetCookie();e.headers.delete("set-cookie");for(let i of r)e.headers.append("set-cookie",i)}else e.headers.set(t,n)}}this.#r=e,this.finalized=!0}render=(...e)=>(this.#s??=(t)=>this.html(t),this.#s(...e));setLayout=(e)=>this.#c=e;getLayout=()=>this.#c;setRenderer=(e)=>{this.#s=e};header=(e,t,n)=>{if(this.finalized)this.#r=Qs(this.#r.body,this.#r);let r=this.#r?this.#r.headers:this.#l??=new Headers;if(t===void 0)r.delete(e);else if(n?.append)r.append(e,t);else r.set(e,t)};status=(e)=>{this.#o=e};set=(e,t)=>{this.#n??=new Map,this.#n.set(e,t)};get=(e)=>this.#n?this.#n.get(e):void 0;get var(){if(!this.#n)return{};return Object.fromEntries(this.#n)}#u(e,t,n){let r=this.#r?new Headers(this.#r.headers):this.#l;if(typeof t==="object"&&t.headers){r??=new Headers;for(let[o,s]of new Headers(t.headers))if(o==="set-cookie")r.append(o,s);else r.set(o,s)}if(n){if(!r){let o=0;for(let s in n)if(++o>1||typeof n[s]!=="string"){r=new Headers;break}}if(r)for(let o in n){let s=n[o];if(typeof s==="string")r.set(o,s);else{r.delete(o);for(let a of s)r.append(o,a)}}}let i=typeof t==="number"?t:t?.status??this.#o;return Qs(e,{status:i,headers:r??n})}newResponse=(...e)=>this.#u(...e);body=(e,t,n)=>this.#u(e,t,n);text=(e,t,n)=>!this.#l&&!this.#o&&!t&&!n&&!this.finalized?new Response(e):this.#u(e,t,lp(W5,n));json=(e,t,n)=>this.#u(JSON.stringify(e),t,lp("application/json",n));html=(e,t,n)=>{let r=(i)=>this.#u(i,t,lp("text/html; charset=UTF-8",n));return typeof e==="object"?cp(e,v1.Stringify,!1,{}).then(r):r(e)};redirect=(e,t)=>{let n=String(e);return this.header("Location",!/[^\x00-\xFF]/.test(n)?n:encodeURI(n)),this.newResponse(null,t??302)};notFound=()=>(this.#a??=()=>Qs(),this.#a(this))};Dr();fp();pi();var j5=(e)=>e.text("404 Not Found",404),D1=(e,t)=>{if("getResponse"in e){let n=e.getResponse();return t.newResponse(n.body,n)}return console.error(e),t.text("Internal Server Error",500)},E1=class e{get;post;put;delete;options;patch;query;all;on;use;router;getPath;_basePath="/";#e="/";routes=[];constructor(t={}){[..._1,w1].forEach((o)=>{this[o]=(s,...a)=>{if(typeof s==="string")this.#e=s;else this.#o(o,this.#e,s);return a.forEach((c)=>{this.#o(o,this.#e,c)}),this}}),this.on=(o,s,...a)=>{for(let c of[s].flat()){this.#e=c;for(let u of[o].flat())a.map((d)=>{this.#o(u.toUpperCase(),this.#e,d)})}return this},this.use=(o,...s)=>{if(typeof o==="string")this.#e=o;else this.#e="*",s.unshift(o);return s.forEach((a)=>{this.#o($e,this.#e,a)}),this};let{strict:r,...i}=t;Object.assign(this,i),this.getPath=r??!0?t.getPath??ap:p1}#t(){let t=new e({router:this.router,getPath:this.getPath});return t.errorHandler=this.errorHandler,t.#n=this.#n,t.routes=this.routes,t}#n=j5;errorHandler=D1;route(t,n){let r=this.basePath(t);return n.routes.map((i)=>{let o;if(n.errorHandler===D1)o=i.handler;else o=async(s,a)=>(await rp([],n.errorHandler)(s,()=>i.handler(s,a))).res,o[ea]=i.handler;r.#o(i.method,i.path,o,i.basePath)}),this}basePath(t){let n=this.#t();return n._basePath=_r(this._basePath,t),n}onError=(t)=>(this.errorHandler=t,this);notFound=(t)=>(this.#n=t,this);mount(t,n,r){let i,o;if(r)if(typeof r==="function")o=r;else if(o=r.optionHandler,r.replaceRequest===!1)i=(c)=>c;else i=r.replaceRequest;let s=o?(c)=>{let u=o(c);return Array.isArray(u)?u:[u]}:(c)=>{let u=void 0;try{u=c.executionCtx}catch{}return[c.env,u]};i||=(()=>{let c=_r(this._basePath,t),u=c==="/"?0:c.length;return(d)=>{let f=new URL(d.url);return f.pathname=this.getPath(d).slice(u)||"/",new Request(f,d)}})();let a=async(c,u)=>{let d=await n(i(c.req.raw),...s(c));if(d)return d;await u()};return this.#o($e,_r(t,"*"),a),this}#o(t,n,r,i){t=t.toUpperCase(),n=_r(this._basePath,n);let o={basePath:i!==void 0?_r(this._basePath,i):this._basePath,path:n,method:t,handler:r};this.router.add(t,n,[r,o]),this.routes.push(o)}#i(t,n){if(t instanceof Error)return this.errorHandler(t,n);throw t}#r(t,n,r,i){if(i==="HEAD")return(async()=>new Response(null,await this.#r(t,n,r,"GET")))();let o=this.getPath(t,{env:r}),s=this.router.match(i,o),a=new dp(t,{path:o,matchResult:s,env:r,executionCtx:n,notFoundHandler:this.#n});if(s[0].length===1){let u;try{u=s[0][0][0][0](a,async()=>{a.res=await this.#n(a)})}catch(d){return this.#i(d,a)}return u instanceof Promise?u.then((d)=>d||(a.finalized?a.res:this.#n(a))).catch((d)=>this.#i(d,a)):u??this.#n(a)}let c=rp(s[0],this.errorHandler,this.#n);return(async()=>{try{let u=await c(a);if(!u.finalized)throw Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return u.res}catch(u){return this.#i(u,a)}})()}fetch=(t,...n)=>this.#r(t,n[1],n[0],t.method);request=(t,n,r,i)=>{if(t instanceof Request)return this.fetch(n?new Request(t,n):t,r,i);return t=t.toString(),this.fetch(new Request(/^https?:\/\//.test(t)?t:`http://localhost${_r("/",t)}`,n),r,i)};fire=()=>{addEventListener("fetch",(t)=>{t.respondWith(this.#r(t.request,t,void 0,t.request.method))})}};Dr();pi();var Ke=()=>Object.create(null);Dr();var Bu=[];function hp(e,t){let n=this.buildAllMatchers(),r=(i,o)=>{let s=n[i]||n[$e],a=s[2][o];if(a)return a;let c=o.match(s[0]);if(!c)return[[],Bu];let u=c.indexOf("",1);return[s[1][u],c]};return this.match=r,r(e,t)}var lo="[^/]+",Sr=".*",Vn="(?:|/.*)",Er=Symbol(),S1=new Set(".\\+*[^]$()");function q5(e,t){if(e.length===1)return t.length===1?e<t?-1:1:-1;if(t.length===1)return 1;if(e===Sr||e===Vn)return t===Vn?-1:1;else if(t===Sr||t===Vn)return-1;if(e===lo)return 1;else if(t===lo)return-1;return e.length===t.length?e<t?-1:1:t.length-e.length}var T1=class e{#e;#t;#n=Ke();insert(t,n,r,i,o){let s=this;for(let a=0,c=t.length;a<c;a++){let u=t[a],d=u.length===1?u==="*"?a===c-1?["","",Sr]:["","",lo]:null:u==="/*"?["","",Vn]:u.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/),f;if(d){let h=d[1],p=d[2]||lo;if(h&&d[2]){if(p===".*")throw Er;if(p=p.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(p))throw Er;if(p.length===1&&S1.has(p))throw Er}if(f=s.#n[p],!f){if(p!==Sr&&p!==Vn){for(let g in s.#n)if((p.length>1||g.length>1)&&g!==Sr&&g!==Vn)throw Er}f=s.#n[p]=new e}if(h!=="")f.#t??=i.varIndex++,r.push([h,f.#t])}else if(f=s.#n[u],!f){for(let h in s.#n)if(h.length>1&&h!==Sr&&h!==Vn)throw Er;f=s.#n[u]=new e}s=f}if(s.#e!==void 0)throw Er;s.#e=o?-1:n}buildRegExpStr(){let n=Object.keys(this.#n).sort(q5).map((r)=>{let i=this.#n[r],o=i.buildRegExpStr();return o===""?"":(typeof i.#t==="number"?`(${r})@${i.#t}`:S1.has(r)?`\\${r}`:r)+o}).filter(Boolean);if(typeof this.#e==="number"&&this.#e!==-1)n.unshift(`#${this.#e}`);if(n.length===0)return"";if(n.length===1)return n[0];return"(?:"+n.join("|")+")"}};var pp=class{#e={varIndex:0};#t=new T1;#n=0;paths=Ke();insert(e,t){if(t){this.#t.insert(e.split(""),0,[],this.#e,!0);return}let n=[],r=[],i=e;for(let s=0;;){let a=!1;if(i=i.replace(/\{[^}]+\}/g,(c)=>{let u=`@\\${s}`;return r[s]=[u,c],s++,a=!0,u}),!a)break}let o=i.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let s=r.length-1;s>=0;s--){let[a]=r[s];for(let c=o.length-1;c>=0;c--)if(o[c].indexOf(a)!==-1){o[c]=o[c].replace(a,r[s][1]);break}}this.#t.insert(o,this.#n,n,this.#e,!1),this.paths[e]=[this.#n++,n]}buildRegExp(){let e=this.#t.buildRegExpStr();if(e==="")return[/^$/,[],[]];let t=0,n=[],r=[];return e=e.replace(/#(\d+)|@(\d+)|\.\*\$/g,(i,o,s)=>{if(o!==void 0)return n[++t]=Number(o),"$()";if(s!==void 0)return r[Number(s)]=++t,"";return""}),[new RegExp(`^${e}`),n,r]}};var C1=Ke();function A1(e){return C1[e]??=new RegExp(`^${e.replace(/\/:[^/{}]+(?:\{\[\^\/]\+})?(?=[/{]|$)|\/?\*$|([.\\+*[^\]$()?{}|])/g,(t,n)=>n?`\\${n}`:t==="/*"?Vn:t==="*"?Sr:`/:${lo}`)}$`)}function Nu(e,t){for(let n of Object.keys(e).sort((r,i)=>i.length-r.length))if(A1(n).test(t))return[...e[n]];return}var Lu=class{name="RegExpRouter";#e;#t;#n;constructor(){this.#e={[$e]:Ke()},this.#t={[$e]:Ke()},this.#n={[$e]:new pp}}#o(e,t){try{this.#n[e].insert(t,!/\*|\/:/.test(t))}catch(n){throw n===Er?new Mu(t):n}}add(e,t,n){let r=this.#e,i=this.#t;if(!r)throw Error(Iu);if(!r[e]){this.#n[e]=new pp;for(let a of[r,i]){a[e]=Ke();for(let c in a[$e])a[e][c]=[...a[$e][c]],this.#o(e,c)}}if(t==="/*")t="*";let o=e===$e?Object.keys(r):[e];if(/\*$/.test(t)){let a=A1(t);for(let c of o)if(!r[c][t])this.#o(c,t),r[c][t]=Nu(r[c],t)||Nu(r[$e],t)||[];for(let c of[r,i])for(let u of o)for(let d in c[u])a.test(d)&&c[u][d].push([n,t]);return}let s=Pu(t)||[t];for(let a of s)for(let c of o){if(!i[c][a])this.#o(c,a),i[c][a]=Nu(r[c],a)||Nu(r[$e],a)||[];i[c][a].push([n,a])}}match=hp;buildAllMatchers(){let e=Ke();for(let t of Object.keys(this.#t))e[t]=this.#i(t);return this.#e=this.#t=this.#n=void 0,C1=Ke(),e}#i(e){let t=this.#e[e],n=this.#t[e],r=this.#n[e],i=Ke(),o=[],[s,a,c]=r.buildRegExp();for(let u of[t,n])for(let d in u){let f=u[d],h=r.paths[d];if(!h){i[d]=[f.map(([p])=>[p,Ke()]),Bu];continue}o[h[0]]=f.map(([p,g])=>[p,r.paths[g][1].reduceRight((b,[v],y)=>(b[v]=c[h[1][y][1]],b),Ke())])}return[s,a.map((u)=>o[u]),i]}};Dr();Dr();var gp=class{name="SmartRouter";#e=[];#t=[];constructor(e){this.#e=e.routers}add(e,t,n){if(!this.#t)throw Error(Iu);this.#t.push([e,t,n])}match(e,t){if(!this.#t)throw Error("Fatal error");let n=this.#e,r=this.#t,i=n.length,o=0,s;for(;o<i;o++){let a=n[o];try{for(let c=0,u=r.length;c<u;c++)a.add(...r[c]);s=a.match(e,t)}catch(c){if(c instanceof Mu)continue;throw c}this.match=a.match.bind(a),this.#e=[a],this.#t=void 0;break}if(o===i)throw Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,s}get activeRouter(){if(this.#t||this.#e.length!==1)throw Error("No active router has been determined yet.");return this.#e[0]}};pi();Dr();pi();var mp=Ke(),H5=0,U1=class e{#e=[];#t=Ke();#n=[];#o;#i=mp;insert(t,n,r){let i=this,o=d1(n),s=new Set,a=0;for(let c of o){let u=o[++a],d=f1(c,u)||(u===void 0&&c&&c.indexOf("*")===c.length-1?c:null),f=Array.isArray(d),h=f?d[0]:d||c,p=i.#t[h]||=new e;if(d&&!p.#o)p.#o=d,i.#n.push(p);if(i=p,f)s.add(d[1])}i.#e.push({[t]:{handler:r,possibleKeys:[...s],score:++H5}})}#r(t,n,r,i,o){for(let s=0,a=n.#e.length;s<a;s++){let c=n.#e[s],u=c[r]||c[$e];if(u){u.params=Ke(),t.push(u);for(let d=0,f=u.possibleKeys.length;d<f;d++){let h=u.possibleKeys[d];u.params[h]=o?.[h]&&!d?o[h]:i[h]??o?.[h]}}}}search(t,n){let r=[];this.#i=mp;let o=[this],s=op(n),a=[],c=s.length,u=null;for(let d=0;d<c;d++){let f=s[d],h=d===c-1,p=[];for(let b=0,v=o.length;b<v;b++){let y=o[b],x=y.#t[f];if(x)if(x.#i=y.#i,h){if(x.#t["*"])this.#r(r,x.#t["*"],t,y.#i);this.#r(r,x,t,y.#i)}else p.push(x);for(let m of y.#n){let w=m.#o,D=y.#i===mp?{}:{...y.#i};if(typeof w==="string"){if(w==="*"||f.startsWith(w.slice(0,-1))){if(this.#r(r,m,t,y.#i),w==="*")m.#i=D,p.push(m)}continue}let[,C,_]=w;if(!f&&_===!0)continue;if(_!==!0){if(!u){u=[];let B=n[0]==="/"?1:0;for(let F=0;F<c;F++)u[F]=B,B+=s[F].length+1}let A=n.slice(u[d]),S=_.exec(A);if(S){if(D[C]=S[0],this.#r(r,m,t,y.#i,D),S[0].length===A.length&&m.#t["*"])this.#r(r,m.#t["*"],t,y.#i,D);for(let B in m.#t){m.#i=D;let F=S[0].match(/\//g)?.length??0;(a[F]||=[]).push(m);break}continue}}if(_===!0||_.test(f))if(D[C]=f,h){if(this.#r(r,m,t,D,y.#i),m.#t["*"])this.#r(r,m.#t["*"],t,D,y.#i)}else m.#i=D,p.push(m)}}let g=a.shift();o=g?p.concat(g):p}if(r[1])r.sort((d,f)=>d.score-f.score);return[r.map(({handler:d,params:f})=>[d,f])]}};var yp=class{name="TrieRouter";#e=new U1;add(e,t,n){for(let r of Pu(t)||[t])this.#e.insert(e,r,n)}match(e,t){return this.#e.search(e,t)}};var bp=class extends E1{constructor(e={}){super(e);this.router=e.router??new gp({routers:[new Lu,new yp]})}};function vp(){let e={};return e.promise=new Promise((t,n)=>{e.resolve=t,e.reject=n}),e}import{execFile as $5}from"node:child_process";import fo from"node:path";import{promisify as G5}from"node:util";var ta=G5($5),Wu=1e4,k1=120000,na=8388608;async function vt(e,t,n=na,r=Wu){let{stdout:i}=await ta("git",["-C",e,...t],{timeout:r,maxBuffer:n,env:{...process.env,LC_ALL:"C"}});return i}async function Ct(e){try{return(await vt(e,["rev-parse","--show-toplevel"])).trim()||null}catch{return null}}function gi(e,t){let n=fo.relative(fo.resolve(e),fo.resolve(t));return n===""||!n.startsWith(`..${fo.sep}`)&&n!==".."&&!fo.isAbsolute(n)}function Tr(e){return e.split(fo.sep).join("/")}function ju(e){return e.includes(0)}import{lstat as tB,readFile as nB}from"node:fs/promises";import M1 from"node:path";var mi=262144,R1=10485760,F1=10485760,z5={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",bmp:"image/bmp",ico:"image/x-icon",avif:"image/avif"},V5={mp3:"audio/mpeg",wav:"audio/wav",ogg:"audio/ogg",oga:"audio/ogg",opus:"audio/ogg",m4a:"audio/mp4",aac:"audio/aac",flac:"audio/flac",weba:"audio/webm",webm:"audio/webm"},X5={pdf:"application/pdf",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"};function K5(e){return e.replace(/\\/g,"/").split("/").pop()??""}function ho(e){return K5(e).toLowerCase().split(".").pop()??""}function qu(e){return z5[ho(e)]??null}function Hu(e){return V5[ho(e)]??null}function $u(e){return X5[ho(e)]??null}function P1(e){let t=ho(e);if(t==="pdf"||t==="docx")return t;return null}function Z5(e,t){return e==="R"||e==="C"||t==="R"||t==="C"}function O1(e){let t=e.split("\x00"),n=[];for(let r=0;r<t.length;r++){let i=t[r];if(!i||i.length<4||i[2]!==" ")continue;let o=i[0],s=i[1],a={path:i.slice(3),indexStatus:o,worktreeStatus:s};if(Z5(o,s))a.originalPath=t[++r]||void 0;n.push(a)}return n}var Y5=new Set(["DD","AU","UD","UA","DU","AA","UU"]);function Gu(e){let t=`${e.indexStatus}${e.worktreeStatus}`;if(t==="??")return{status:"untracked",code:"U"};if(Y5.has(t)||t.includes("U"))return{status:"conflict",code:"C"};if(t.includes("D"))return{status:"deleted",code:"D"};if(t.includes("R")||t.includes("C"))return{status:"renamed",code:"R"};if(t.includes("A"))return{status:"added",code:"A"};return{status:"modified",code:"M"}}import{lstat as J5,readFile as Q5}from"node:fs/promises";import xp from"node:path";async function wp(e){let t=await vt(e,["status","--porcelain=v1","-z","--untracked-files=all"]);return O1(t)}async function I1(e,t,n){let i=Tr(xp.relative(e,t))||".";try{let o=await vt(e,["diff","--no-color","--no-ext-diff","--numstat",...n,"--",i]),s=new Map;for(let a of o.split(/\r?\n/)){if(!a)continue;let[c,u,...d]=a.split("\t");if(d.length===0)continue;let f=Number(c),h=Number(u);if(!Number.isInteger(f)||!Number.isInteger(h))continue;let p=d.join("\t"),g=p.indexOf(" => ");if(g!==-1)p=p.slice(g+4);s.set(Tr(p.trim()),{additions:f,deletions:h})}return s}catch{return new Map}}async function eB(e){try{let t=await J5(e);if(!t.isFile()||t.size>mi)return 0;let n=await Q5(e);if(ju(n)||n.length===0)return 0;let r=n.toString("utf8");return r.endsWith(`
260
260
  `)?r.split(`
261
261
  `).length-1:r.split(`
262
262
  `).length}catch{return 0}}async function zu(e){try{let n=(await vt(e,["rev-parse","--abbrev-ref","HEAD"])).trim()||null;if(!n||n==="HEAD")return{branch:n,upstream:null,ahead:0,behind:0,hasUpstream:!1};let r=null,i=!1;try{r=(await vt(e,["rev-parse","--abbrev-ref","--symbolic-full-name","@{u}"])).trim()||null,i=!!r}catch{return{branch:n,upstream:null,ahead:0,behind:0,hasUpstream:!1}}if(!i||!r)return{branch:n,upstream:null,ahead:0,behind:0,hasUpstream:!1};try{let s=(await vt(e,["rev-list","--left-right","--count","HEAD...@{u}"])).trim().split(/\s+/).map((u)=>Number(u)),a=Number.isInteger(s[0])?s[0]:0,c=Number.isInteger(s[1])?s[1]:0;return{branch:n,upstream:r,ahead:a,behind:c,hasUpstream:!0}}catch{return{branch:n,upstream:r,ahead:0,behind:0,hasUpstream:!0}}}catch{return{branch:null,upstream:null,ahead:0,behind:0,hasUpstream:!1}}}async function _p(e){let t=await Ct(e);if(!t)return{isGitRepository:!1,repositoryRoot:null,files:[],additions:0,deletions:0,stagedFiles:[],stagedAdditions:0,stagedDeletions:0,branch:null,upstream:null,ahead:0,behind:0,hasUpstream:!1};let[n,r,i,o]=await Promise.all([wp(t),I1(t,e,[]),I1(t,e,["--cached"]),zu(t)]),s=[],a=[];for(let g of n){let b=xp.resolve(t,g.path);if(!gi(e,b))continue;let v=Gu(g),y={filePath:b,...v,indexStatus:g.indexStatus,worktreeStatus:g.worktreeStatus},x=g.indexStatus!==" "&&g.indexStatus!=="?",m=g.worktreeStatus!==" ";if(x)a.push({...y,lineStats:i.get(g.path)});if(m)s.push({...y,lineStats:r.get(g.path)})}let c=await Promise.all(s.map(async(g)=>g.status==="untracked"?{filePath:g.filePath,additions:await eB(g.filePath)}:{filePath:g.filePath,additions:0})),u=new Map(c.map((g)=>[g.filePath,g.additions])),d=[...u.values()].reduce((g,b)=>g+b,0);for(let g of s){if(g.status!=="untracked")continue;let b=u.get(g.filePath)??0;if(b>0)g.lineStats={additions:b,deletions:0}}let f=(g)=>{let b=0,v=0;for(let y of g.values())b+=y.additions,v+=y.deletions;return{additions:b,deletions:v}},h=f(r),p=f(i);return{isGitRepository:!0,repositoryRoot:t,files:s,additions:h.additions+d,deletions:h.deletions,stagedFiles:a,stagedAdditions:p.additions,stagedDeletions:p.deletions,...o}}function B1(e,t){let n=t.endsWith(`
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{o as t,s as n}from"./index-COqRaKwN.js";var r=[],i=[];(()=>{let e=`lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5`.split(`,`).map(e=>e?parseInt(e,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?i:r).push(n+=e[t])})();function a(e){if(e<768)return!1;for(let t=0,n=r.length;;){let a=t+n>>1;if(e<r[a])n=a;else if(e>=i[a])t=a+1;else return!0;if(t==n)return!1}}function o(e){return e>=127462&&e<=127487}var s=8205;function c(e,t,n=!0,r=!0){return(n?l:u)(e,t,r)}function l(e,t,n){if(t==e.length)return t;t&&f(e.charCodeAt(t))&&p(e.charCodeAt(t-1))&&t--;let r=d(e,t);for(t+=m(r);t<e.length;){let i=d(e,t);if(r==s||i==s||n&&a(i))t+=m(i),r=i;else if(o(i)){let n=0,r=t-2;for(;r>=0&&o(d(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function u(e,t,n){for(;t>1;){let r=l(e,t-2,n);if(r<t)return r;t--}return 0}function d(e,t){let n=e.charCodeAt(t);if(!p(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return f(r)?(n-55296<<10)+(r-56320)+65536:n}function f(e){return e>=56320&&e<57344}function p(e){return e>=55296&&e<56320}function m(e){return e<65536?1:2}var h=class e{lineAt(e){if(e<0||e>this.length)throw RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=ie(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),_.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=ie(this,e,t);let n=[];return this.decompose(e,t,n,0),_.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new b(this),i=new b(e);for(let e=t,a=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(a+=r.value.length,r.done||a>=n)return!0}}iter(e=1){return new b(this,e)}iterRange(e,t=this.length){return new te(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t??=this.lines+1;let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new ne(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(t){if(t.length==0)throw RangeError(`A document must have at least one line`);return t.length==1&&!t[0]?e.empty:t.length<=32?new g(t):_.from(g.split(t,[]))}},g=class e extends h{constructor(e,t=v(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.text[i],o=r+a.length;if((t?n:o)>=e)return new re(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(ee(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=y(a.text,t.text.slice(),0,a.length);if(n.length<=32)r.push(new e(n,t.length+a.length));else{let t=n.length>>1;r.push(new e(n.slice(0,t)),new e(n.slice(t)))}}else r.push(a)}replace(t,n,r){if(!(r instanceof e))return super.replace(t,n,r);[t,n]=ie(this,t,n);let i=y(this.text,y(r.text,ee(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):_.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=`
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{o as t,s as n}from"./index-HvNgrSMz.js";var r=[],i=[];(()=>{let e=`lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5`.split(`,`).map(e=>e?parseInt(e,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?i:r).push(n+=e[t])})();function a(e){if(e<768)return!1;for(let t=0,n=r.length;;){let a=t+n>>1;if(e<r[a])n=a;else if(e>=i[a])t=a+1;else return!0;if(t==n)return!1}}function o(e){return e>=127462&&e<=127487}var s=8205;function c(e,t,n=!0,r=!0){return(n?l:u)(e,t,r)}function l(e,t,n){if(t==e.length)return t;t&&f(e.charCodeAt(t))&&p(e.charCodeAt(t-1))&&t--;let r=d(e,t);for(t+=m(r);t<e.length;){let i=d(e,t);if(r==s||i==s||n&&a(i))t+=m(i),r=i;else if(o(i)){let n=0,r=t-2;for(;r>=0&&o(d(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function u(e,t,n){for(;t>1;){let r=l(e,t-2,n);if(r<t)return r;t--}return 0}function d(e,t){let n=e.charCodeAt(t);if(!p(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return f(r)?(n-55296<<10)+(r-56320)+65536:n}function f(e){return e>=56320&&e<57344}function p(e){return e>=55296&&e<56320}function m(e){return e<65536?1:2}var h=class e{lineAt(e){if(e<0||e>this.length)throw RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=ie(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),_.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=ie(this,e,t);let n=[];return this.decompose(e,t,n,0),_.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new b(this),i=new b(e);for(let e=t,a=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(a+=r.value.length,r.done||a>=n)return!0}}iter(e=1){return new b(this,e)}iterRange(e,t=this.length){return new te(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t??=this.lines+1;let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new ne(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(t){if(t.length==0)throw RangeError(`A document must have at least one line`);return t.length==1&&!t[0]?e.empty:t.length<=32?new g(t):_.from(g.split(t,[]))}},g=class e extends h{constructor(e,t=v(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.text[i],o=r+a.length;if((t?n:o)>=e)return new re(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(ee(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=y(a.text,t.text.slice(),0,a.length);if(n.length<=32)r.push(new e(n,t.length+a.length));else{let t=n.length>>1;r.push(new e(n.slice(0,t)),new e(n.slice(t)))}}else r.push(a)}replace(t,n,r){if(!(r instanceof e))return super.replace(t,n,r);[t,n]=ie(this,t,n);let i=y(this.text,y(r.text,ee(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):_.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=`
2
2
  `){[e,t]=ie(this,e,t);let r=``;for(let i=0,a=0;i<=t&&a<this.text.length;a++){let o=this.text[a],s=i+o.length;i>e&&a&&(r+=n),e<s&&t>i&&(r+=o.slice(Math.max(0,e-i),t-i)),i=s+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(t,n){let r=[],i=-1;for(let a of t)r.push(a),i+=a.length+1,r.length==32&&(n.push(new e(r,i)),r=[],i=-1);return i>-1&&n.push(new e(r,i)),n}},_=class e extends h{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.children[i],o=r+a.length,s=n+a.lines-1;if((t?s:o)>=e)return a.lineInner(e,t,n,r);r=o+1,n=s+1}}decompose(e,t,n,r){for(let i=0,a=0;a<=t&&i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(e<=s&&t>=a){let i=r&(a<=e|(s>=t?2:0));a>=e&&s<=t&&!i?n.push(o):o.decompose(e-a,t-a,n,i)}a=s+1}}replace(t,n,r){if([t,n]=ie(this,t,n),r.lines<this.lines)for(let i=0,a=0;i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(t>=a&&n<=s){let c=o.replace(t-a,n-a,r),l=this.lines-o.lines+c.lines;if(c.lines<l>>4&&c.lines>l>>6){let a=this.children.slice();return a[i]=c,new e(a,this.length-(n-t)+r.length)}return super.replace(a,s,c)}a=s+1}return super.replace(t,n,r)}sliceString(e,t=this.length,n=`
3
3
  `){[e,t]=ie(this,e,t);let r=``;for(let i=0,a=0;i<this.children.length&&a<=t;i++){let o=this.children[i],s=a+o.length;a>e&&i&&(r+=n),e<s&&t>a&&(r+=o.sliceString(e-a,t-a,n)),a=s+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(t,n){if(!(t instanceof e))return 0;let r=0,[i,a,o,s]=n>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;i+=n,a+=n){if(i==o||a==s)return r;let e=this.children[i],c=t.children[a];if(e!=c)return r+e.scanIdentical(c,n);r+=e.length+1}}static from(t,n=t.reduce((e,t)=>e+t.length+1,-1)){let r=0;for(let e of t)r+=e.lines;if(r<32){let e=[];for(let n of t)n.flatten(e);return new g(e,n)}let i=Math.max(32,r>>5),a=i<<1,o=i>>1,s=[],c=0,l=-1,u=[];function d(t){let n;if(t.lines>a&&t instanceof e)for(let e of t.children)d(e);else t.lines>o&&(c>o||!c)?(f(),s.push(t)):t instanceof g&&c&&(n=u[u.length-1])instanceof g&&t.lines+n.lines<=32?(c+=t.lines,l+=t.length+1,u[u.length-1]=new g(n.text.concat(t.text),n.length+1+t.length)):(c+t.lines>i&&f(),c+=t.lines,l+=t.length+1,u.push(t))}function f(){c!=0&&(s.push(u.length==1?u[0]:e.from(u,l)),l=-1,c=u.length=0)}for(let e of t)d(e);return f(),s.length==1?s[0]:new e(s,n)}};h.empty=new g([``],0);function v(e){let t=-1;for(let n of e)t+=n.length+1;return t}function y(e,t,n=0,r=1e9){for(let i=0,a=0,o=!0;a<e.length&&i<=r;a++){let s=e[a],c=i+s.length;c>=n&&(c>r&&(s=s.slice(0,r-i)),i<n&&(s=s.slice(n-i)),o?(t[t.length-1]+=s,o=!1):t.push(s)),i=c+1}return t}function ee(e,t,n){return y(e,[``],t,n)}var b=class{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value=``,this.nodes=[e],this.offsets=[t>0?1:(e instanceof g?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],i=this.offsets[n],a=i>>1,o=r instanceof g?r.text.length:r.children.length;if(a==(t>0?o:0)){if(n==0)return this.done=!0,this.value=``,this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((i&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=`
4
4
  `,this;e--}else if(r instanceof g){let i=r.text[a+(t<0?-1:0)];if(this.offsets[n]+=t,i.length>Math.max(0,e))return this.value=e==0?i:t>0?i.slice(e):i.slice(0,i.length-e),this;e-=i.length}else{let i=r.children[a+(t<0?-1:0)];e>i.length?(e-=i.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(i),this.offsets.push(t>0?1:(i instanceof g?i.text.length:i.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},te=class{constructor(e,t,n){this.value=``,this.done=!1,this.cursor=new b(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value=``,this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=``}},ne=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value=``,this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value=``,this.afterBreak=!1):t?(this.done=!0,this.value=``):n?this.afterBreak?this.value=``:(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<`u`&&(h.prototype[Symbol.iterator]=function(){return this.iter()},b.prototype[Symbol.iterator]=te.prototype[Symbol.iterator]=ne.prototype[Symbol.iterator]=function(){return this});var re=class{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}};function ie(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function x(e,t,n=!0,r=!0){return c(e,t,n,r)}function ae(e){return e>=56320&&e<57344}function oe(e){return e>=55296&&e<56320}function S(e,t){let n=e.charCodeAt(t);if(!oe(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return ae(r)?(n-55296<<10)+(r-56320)+65536:n}function se(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}function ce(e){return e<65536?1:2}var le=/\r\n?|\n/,C=(function(e){return e[e.Simple=0]=`Simple`,e[e.TrackDel=1]=`TrackDel`,e[e.TrackBefore=2]=`TrackBefore`,e[e.TrackAfter=3]=`TrackAfter`,e})(C||={}),ue=class e{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,r=0;t<this.sections.length;){let i=this.sections[t++],a=this.sections[t++];a<0?(e(n,r,i),r+=i):r+=a,n+=i}}iterChangedRanges(e,t=!1){pe(this,e,t)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let n=this.sections[e++],r=this.sections[e++];r<0?t.push(n,r):t.push(r,n)}return new e(t)}composeDesc(e){return this.empty?e:e.empty?this:he(this,e)}mapDesc(e,t=!1){return e.empty?this:me(this,e,t)}mapPos(e,t=-1,n=C.Simple){let r=0,i=0;for(let a=0;a<this.sections.length;){let o=this.sections[a++],s=this.sections[a++],c=r+o;if(s<0){if(c>e)return i+(e-r);i+=o}else{if(n!=C.Simple&&c>=e&&(n==C.TrackDel&&r<e&&c>e||n==C.TrackBefore&&r<e||n==C.TrackAfter&&c>e))return null;if(c>e||c==e&&t<0&&!o)return e==r||t<0?i:i+s;i+=s}r=c}if(e>r)throw RangeError(`Position ${e} is out of range for changeset of length ${r}`);return i}touchesRange(e,t=e){for(let n=0,r=0;n<this.sections.length&&r<=t;){let i=this.sections[n++],a=this.sections[n++],o=r+i;if(a>=0&&r<=t&&o>=e)return r<e&&o>t?`cover`:!0;r=o}return!1}toString(){let e=``;for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];e+=(e?` `:``)+n+(r>=0?`:`+r:``)}return e}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(e=>typeof e!=`number`))throw RangeError(`Invalid JSON representation of ChangeDesc`);return new e(t)}static create(t){return new e(t)}},de=class e extends ue{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw RangeError(`Applying change set to a document with the wrong length`);return pe(this,(t,n,r,i,a)=>e=e.replace(r,r+(n-t),a),!1),e}mapDesc(e,t=!1){return me(this,e,t,!0)}invert(t){let n=this.sections.slice(),r=[];for(let e=0,i=0;e<n.length;e+=2){let a=n[e],o=n[e+1];if(o>=0){n[e]=o,n[e+1]=a;let s=e>>1;for(;r.length<s;)r.push(h.empty);r.push(a?t.slice(i,i+a):h.empty)}i+=a}return new e(n,r)}compose(e){return this.empty?e:e.empty?this:he(this,e,!0)}map(e,t=!1){return e.empty?this:me(this,e,t,!0)}iterChanges(e,t=!1){pe(this,e,t)}get desc(){return ue.create(this.sections)}filter(t){let n=[],r=[],i=[],a=new ge(this);done:for(let e=0,o=0;;){let s=e==t.length?1e9:t[e++];for(;o<s||o==s&&a.len==0;){if(a.done)break done;let e=Math.min(a.len,s-o);w(i,e,-1);let t=a.ins==-1?-1:a.off==0?a.ins:0;w(n,e,t),t>0&&fe(r,n,a.text),a.forward(e),o+=e}let c=t[e++];for(;o<c;){if(a.done)break done;let e=Math.min(a.len,c-o);w(n,e,-1),w(i,e,a.ins==-1?-1:a.off==0?a.ins:0),a.forward(e),o+=e}}return{changes:new e(n,r),filtered:ue.create(i)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],r=this.sections[t+1];r<0?e.push(n):r==0?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(t,n,r){let i=[],a=[],o=0,s=null;function c(t=!1){if(!t&&!i.length)return;o<n&&w(i,n-o,-1);let r=new e(i,a);s=s?s.compose(r.map(s)):r,i=[],a=[],o=0}function l(t){if(Array.isArray(t))for(let e of t)l(e);else if(t instanceof e){if(t.length!=n)throw RangeError(`Mismatched change set length (got ${t.length}, expected ${n})`);c(),s=s?s.compose(t.map(s)):t}else{let{from:e,to:s=e,insert:l}=t;if(e>s||e<0||s>n)throw RangeError(`Invalid change range ${e} to ${s} (in doc of length ${n})`);let u=l?typeof l==`string`?h.of(l.split(r||le)):l:h.empty,d=u.length;if(e==s&&d==0)return;e<o&&c(),e>o&&w(i,e-o,-1),w(i,s-e,d),fe(a,i,u),o=s}}return l(t),c(!s),s}static empty(t){return new e(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw RangeError(`Invalid JSON representation of ChangeSet`);let n=[],r=[];for(let e=0;e<t.length;e++){let i=t[e];if(typeof i==`number`)n.push(i,-1);else if(!Array.isArray(i)||typeof i[0]!=`number`||i.some((e,t)=>t&&typeof e!=`string`))throw RangeError(`Invalid JSON representation of ChangeSet`);else if(i.length==1)n.push(i[0],0);else{for(;r.length<e;)r.push(h.empty);r[e]=h.of(i.slice(1)),n.push(i[0],r[e].length)}}return new e(n,r)}static createSet(t,n){return new e(t,n)}};function w(e,t,n,r=!1){if(t==0&&n<=0)return;let i=e.length-2;i>=0&&n<=0&&n==e[i+1]?e[i]+=t:i>=0&&t==0&&e[i]==0?e[i+1]+=n:r?(e[i]+=t,e[i+1]+=n):e.push(t,n)}function fe(e,t,n){if(n.length==0)return;let r=t.length-2>>1;if(r<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<r;)e.push(h.empty);e.push(n)}}function pe(e,t,n){let r=e.inserted;for(let i=0,a=0,o=0;o<e.sections.length;){let s=e.sections[o++],c=e.sections[o++];if(c<0)i+=s,a+=s;else{let l=i,u=a,d=h.empty;for(;l+=s,u+=c,c&&r&&(d=d.append(r[o-2>>1])),!(n||o==e.sections.length||e.sections[o+1]<0);)s=e.sections[o++],c=e.sections[o++];t(i,l,a,u,d),i=l,a=u}}}function me(e,t,n,r=!1){let i=[],a=r?[]:null,o=new ge(e),s=new ge(t);for(let e=-1;;)if(o.done&&s.len||s.done&&o.len)throw Error(`Mismatched change set lengths`);else if(o.ins==-1&&s.ins==-1){let e=Math.min(o.len,s.len);w(i,e,-1),o.forward(e),s.forward(e)}else if(s.ins>=0&&(o.ins<0||e==o.i||o.off==0&&(s.len<o.len||s.len==o.len&&!n))){let t=s.len;for(w(i,s.ins,-1);t;){let n=Math.min(o.len,t);o.ins>=0&&e<o.i&&o.len<=n&&(w(i,0,o.ins),a&&fe(a,i,o.text),e=o.i),o.forward(n),t-=n}s.next()}else if(o.ins>=0){let t=0,n=o.len;for(;n;)if(s.ins==-1){let e=Math.min(n,s.len);t+=e,n-=e,s.forward(e)}else if(s.ins==0&&s.len<n)n-=s.len,s.next();else break;w(i,t,e<o.i?o.ins:0),a&&e<o.i&&fe(a,i,o.text),e=o.i,o.forward(o.len-n)}else if(o.done&&s.done)return a?de.createSet(i,a):ue.create(i);else throw Error(`Mismatched change set lengths`)}function he(e,t,n=!1){let r=[],i=n?[]:null,a=new ge(e),o=new ge(t);for(let e=!1;;)if(a.done&&o.done)return i?de.createSet(r,i):ue.create(r);else if(a.ins==0)w(r,a.len,0,e),a.next();else if(o.len==0&&!o.done)w(r,0,o.ins,e),i&&fe(i,r,o.text),o.next();else if(a.done||o.done)throw Error(`Mismatched change set lengths`);else{let t=Math.min(a.len2,o.len),n=r.length;if(a.ins==-1){let n=o.ins==-1?-1:o.off?0:o.ins;w(r,t,n,e),i&&n&&fe(i,r,o.text)}else o.ins==-1?(w(r,a.off?0:a.len,t,e),i&&fe(i,r,a.textBit(t))):(w(r,a.off?0:a.len,o.off?0:o.ins,e),i&&!o.off&&fe(i,r,o.text));e=(a.ins>t||o.ins>=0&&o.len>t)&&(e||r.length>n),a.forward2(t),o.forward(t)}}var ge=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?h.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?h.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},_e=class e{constructor(e,t,n,r){this.from=e,this.to=t,this.flags=n,this.goalColumn=r}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(t,n=-1){let r,i;return this.empty?r=i=t.mapPos(this.from,n):(r=t.mapPos(this.from,1),i=t.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new e(r,i,this.flags,this.goalColumn)}extend(e,t=e,n=0){if(e<=this.anchor&&t>=this.anchor)return T.range(e,t,void 0,void 0,n);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return T.range(this.anchor,r,void 0,void 0,n)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!=`number`||typeof e.head!=`number`)throw RangeError(`Invalid JSON representation for SelectionRange`);return T.range(e.anchor,e.head)}static create(t,n,r,i){return new e(t,n,r,i)}},T=class e{constructor(e,t){this.ranges=e,this.mainIndex=t}map(t,n=-1){return t.empty?this:e.create(this.ranges.map(e=>e.map(t,n)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new e([this.main],0)}addRange(t,n=!0){return e.create([t].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(t,n=this.mainIndex){let r=this.ranges.slice();return r[n]=t,e.create(r,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||typeof t.main!=`number`||t.main>=t.ranges.length)throw RangeError(`Invalid JSON representation for EditorSelection`);return new e(t.ranges.map(e=>_e.fromJSON(e)),t.main)}static single(t,n=t){return new e([e.range(t,n)],0)}static create(t,n=0){if(t.length==0)throw RangeError(`A selection needs at least one range`);for(let r=0,i=0;i<t.length;i++){let a=t[i];if(a.empty?a.from<=r:a.from<r)return e.normalized(t.slice(),n);r=a.to}return new e(t,n)}static cursor(e,t=0,n,r){return _e.create(e,e,(t==0?0:t<0?8:16)|(n==null?7:Math.min(6,n)),r)}static range(e,t,n,r,i){let a=r==null?7:Math.min(6,r);return!i&&e!=t&&(i=t<e?1:-1),i&&(a|=i<0?8:16),t<e?_e.create(t,e,a|32,n):_e.create(e,t,a,n)}static undirectionalRange(e,t){return _e.create(e,t,64,void 0)}static normalized(t,n=0){let r=t[n];t.sort((e,t)=>e.from-t.from),n=t.indexOf(r);for(let r=1;r<t.length;r++){let i=t[r],a=t[r-1];if(i.empty?i.from<=a.to:i.from<a.to){let o=a.from,s=Math.max(i.to,a.to);r<=n&&n--,t.splice(--r,2,i.anchor>i.head?e.range(s,o):e.range(o,s))}}return new e(t,n)}};function ve(e,t){for(let n of e.ranges)if(n.to>t)throw RangeError(`Selection points outside of document`)}var ye=0,E=class e{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=ye++,this.default=e([]),this.extensions=typeof i==`function`?i(this):i}get reader(){return this}static define(t={}){return new e(t.combine||(e=>e),t.compareInput||((e,t)=>e===t),t.compare||(t.combine?(e,t)=>e===t:be),!!t.static,t.enables)}of(e){return new xe([],this,0,e)}compute(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new xe(e,this,1,t)}computeN(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new xe(e,this,2,t)}from(e,t){return t||=e=>e,this.compute([e],n=>t(n.field(e)))}};function be(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}var xe=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=ye++}dynamicSlot(e){let t=this.value,n=this.facet.compareInput,r=this.id,i=e[r]>>1,a=this.type==2,o=!1,s=!1,c=[];for(let t of this.dependencies)t==`doc`?o=!0:t==`selection`?s=!0:(e[t.id]??1)&1||c.push(e[t.id]);return{create(e){return e.values[i]=t(e),1},update(e,r){if(o&&r.docChanged||s&&(r.docChanged||r.selection)||Ce(e,c)){let r=t(e);if(a?!Se(r,e.values[i],n):!n(r,e.values[i]))return e.values[i]=r,1}return 0},reconfigure:(e,o)=>{let s,c=o.config.address[r];if(c!=null){let r=Ie(o,c);if(this.dependencies.every(t=>t instanceof E?o.facet(t)===e.facet(t):t instanceof Ee?o.field(t,!1)==e.field(t,!1):!0)||(a?Se(s=t(e),r,n):n(s=t(e),r)))return e.values[i]=r,0}else s=t(e);return e.values[i]=s,1}}}get extension(){return this}};function Se(e,t,n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!n(e[r],t[r]))return!1;return!0}function Ce(e,t){let n=!1;for(let r of t)Fe(e,r)&1&&(n=!0);return n}function we(e,t,n){let r=n.map(t=>e[t.id]),i=n.map(e=>e.type),a=r.filter(e=>!(e&1)),o=e[t.id]>>1;function s(e){let n=[];for(let t=0;t<r.length;t++){let a=Ie(e,r[t]);if(i[t]==2)for(let e of a)n.push(e);else n.push(a)}return t.combine(n)}return{create(e){for(let t of r)Fe(e,t);return e.values[o]=s(e),1},update(e,n){if(!Ce(e,a))return 0;let r=s(e);return t.compare(r,e.values[o])?0:(e.values[o]=r,1)},reconfigure(e,i){let a=Ce(e,r),c=i.config.facets[t.id],l=i.facet(t);if(c&&!a&&be(n,c))return e.values[o]=l,0;let u=s(e);return t.compare(u,l)?(e.values[o]=l,0):(e.values[o]=u,1)}}}var Te=E.define({static:!0}),Ee=class e{constructor(e,t,n,r,i){this.id=e,this.createF=t,this.updateF=n,this.compareF=r,this.spec=i,this.provides=void 0}static define(t){let n=new e(ye++,t.create,t.update,t.compare||((e,t)=>e===t),t);return t.provide&&(n.provides=t.provide(n)),n}create(e){return(e.facet(Te).find(e=>e.field==this)?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let r=e.values[t],i=this.updateF(r,n);return this.compareF(r,i)?0:(e.values[t]=i,1)},reconfigure:(e,n)=>{let r=e.facet(Te),i=n.facet(Te),a;return(a=r.find(e=>e.field==this))&&a!=i.find(e=>e.field==this)?(e.values[t]=a.create(e),1):n.config.address[this.id]==null?(e.values[t]=this.create(e),1):(e.values[t]=n.field(this),0)}}}init(e){return[this,Te.of({field:this,create:e})]}get extension(){return this}},De={lowest:4,low:3,default:2,high:1,highest:0};function Oe(e){return t=>new Ae(t,e)}var ke={highest:Oe(De.highest),high:Oe(De.high),default:Oe(De.default),low:Oe(De.low),lowest:Oe(De.lowest)},Ae=class{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}},je=class e{of(e){return new Me(this,e)}reconfigure(t){return e.reconfigure.of({compartment:this,extension:t})}get(e){return e.config.compartments.get(this)}},Me=class{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}},Ne=class e{constructor(e,t,n,r,i,a){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=i,this.facets=a,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(t,n,r){let i=[],a=Object.create(null),o=new Map;for(let e of Pe(t,n,o))e instanceof Ee?i.push(e):(a[e.facet.id]||(a[e.facet.id]=[])).push(e);let s=Object.create(null),c=[],l=[];for(let e of i)s[e.id]=l.length<<1,l.push(t=>e.slot(t));let u=r?.config.facets;for(let e in a){let t=a[e],n=t[0].facet,i=u&&u[e]||[];if(t.every(e=>e.type==0)){if(s[n.id]=c.length<<1|1,be(i,t))c.push(r.facet(n));else{let e=n.combine(t.map(e=>e.value));c.push(r&&n.compare(e,r.facet(n))?r.facet(n):e)}}else{for(let e of t)e.type==0?(s[e.id]=c.length<<1|1,c.push(e.value)):(s[e.id]=l.length<<1,l.push(t=>e.dynamicSlot(t)));s[n.id]=l.length<<1,l.push(e=>we(e,n,t))}}let d=l.map(e=>e(s));return new e(t,o,d,s,c,a)}};function Pe(e,t,n){let r=[[],[],[],[],[]],i=new Map;function a(e,o){let s=i.get(e);if(s!=null){if(s<=o)return;let t=r[s].indexOf(e);t>-1&&r[s].splice(t,1),e instanceof Me&&n.delete(e.compartment)}if(i.set(e,o),Array.isArray(e))for(let t of e)a(t,o);else if(e instanceof Me){if(n.has(e.compartment))throw RangeError(`Duplicate use of compartment in extensions`);let r=t.get(e.compartment)||e.inner;n.set(e.compartment,r),a(r,o)}else if(e instanceof Ae)a(e.inner,e.prec);else if(e instanceof Ee)r[o].push(e),e.provides&&a(e.provides,o);else if(e instanceof xe)r[o].push(e),e.facet.extensions&&a(e.facet.extensions,De.default);else{let t=e.extension;if(!t)throw Error(`Unrecognized extension value in extension set (${e}).`);if(t==e)throw Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(t,o)}}return a(e,De.default),r.reduce((e,t)=>e.concat(t))}function Fe(e,t){if(t&1)return 2;let n=t>>1,r=e.status[n];if(r==4)throw Error(`Cyclic dependency between fields and/or facets`);if(r&2)return r;e.status[n]=4;let i=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|i}function Ie(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}var Le=E.define(),Re=E.define({combine:e=>e.some(e=>e),static:!0}),ze=E.define({combine:e=>e.length?e[0]:void 0,static:!0}),Be=E.define(),Ve=E.define(),He=E.define(),Ue=E.define({combine:e=>e.length?e[0]:!1}),We=class{constructor(e,t){this.type=e,this.value=t}static define(){return new Ge}},Ge=class{of(e){return new We(this,e)}},Ke=class{constructor(e){this.map=e}of(e){return new D(this,e)}},D=class e{constructor(e,t){this.type=e,this.value=t}map(t){let n=this.type.map(this.value,t);return n===void 0?void 0:n==this.value?this:new e(this.type,n)}is(e){return this.type==e}static define(e={}){return new Ke(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let e=r.map(t);e&&n.push(e)}return n}};D.reconfigure=D.define(),D.appendConfig=D.define();var qe=class e{constructor(t,n,r,i,a,o){this.startState=t,this.changes=n,this.selection=r,this.effects=i,this.annotations=a,this.scrollIntoView=o,this._doc=null,this._state=null,r&&ve(r,n.newLength),a.some(t=>t.type==e.time)||(this.annotations=a.concat(e.time.of(Date.now())))}static create(t,n,r,i,a,o){return new e(t,n,r,i,a,o)}get newDoc(){return this._doc||=this.changes.apply(this.startState.doc)}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let n=this.annotation(e.userEvent);return!!(n&&(n==t||n.length>t.length&&n.slice(0,t.length)==t&&n[t.length]==`.`))}};qe.time=We.define(),qe.userEvent=We.define(),qe.addToHistory=We.define(),qe.remote=We.define();function Je(e,t){let n=[];for(let r=0,i=0;;){let a,o;if(r<e.length&&(i==t.length||t[i]>=e[r]))a=e[r++],o=e[r++];else if(i<t.length)a=t[i++],o=t[i++];else return n;!n.length||n[n.length-1]<a?n.push(a,o):n[n.length-1]<o&&(n[n.length-1]=o)}}function Ye(e,t,n){let r,i,a;return n?(r=t.changes,i=de.empty(t.changes.length),a=e.changes.compose(t.changes)):(r=t.changes.map(e.changes),i=e.changes.mapDesc(t.changes,!0),a=e.changes.compose(r)),{changes:a,selection:t.selection?t.selection.map(i):e.selection?.map(r),effects:D.mapEffects(e.effects,r).concat(D.mapEffects(t.effects,i)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function Xe(e,t,n){let r=t.selection,i=tt(t.annotations);return t.userEvent&&(i=i.concat(qe.userEvent.of(t.userEvent))),{changes:t.changes instanceof de?t.changes:de.of(t.changes||[],n,e.facet(ze)),selection:r&&(r instanceof T?r:T.single(r.anchor,r.head)),effects:tt(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function Ze(e,t,n){let r=Xe(e,t.length?t[0]:{},e.doc.length);t.length&&t[0].filter===!1&&(n=!1);for(let i=1;i<t.length;i++){t[i].filter===!1&&(n=!1);let a=!!t[i].sequential;r=Ye(r,Xe(e,t[i],a?r.changes.newLength:e.doc.length),a)}let i=qe.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return $e(n?Qe(i):i)}function Qe(e){let t=e.startState,n=!0;for(let r of t.facet(Be)){let t=r(e);if(t===!1){n=!1;break}Array.isArray(t)&&(n=n===!0?t:Je(n,t))}if(n!==!0){let r,i;if(n===!1)i=e.changes.invertedDesc,r=de.empty(t.doc.length);else{let t=e.changes.filter(n);r=t.changes,i=t.filtered.mapDesc(t.changes).invertedDesc}e=qe.create(t,r,e.selection&&e.selection.map(i),D.mapEffects(e.effects,i),e.annotations,e.scrollIntoView)}let r=t.facet(Ve);for(let n=r.length-1;n>=0;n--){let i=r[n](e);e=i instanceof qe?i:Array.isArray(i)&&i.length==1&&i[0]instanceof qe?i[0]:Ze(t,tt(i),!1)}return e}function $e(e){let t=e.startState,n=t.facet(He),r=e;for(let i=n.length-1;i>=0;i--){let a=n[i](e);a&&Object.keys(a).length&&(r=Ye(r,Xe(t,a,e.changes.newLength),!0))}return r==e?e:qe.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}var et=[];function tt(e){return e==null?et:Array.isArray(e)?e:[e]}var O=(function(e){return e[e.Word=0]=`Word`,e[e.Space=1]=`Space`,e[e.Other=2]=`Other`,e})(O||={}),nt=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,rt;try{rt=RegExp(`[\\p{Alphabetic}\\p{Number}_]`,`u`)}catch{}function it(e){if(rt)return rt.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>`€`&&(n.toUpperCase()!=n.toLowerCase()||nt.test(n)))return!0}return!1}function at(e){return t=>{if(!/\S/.test(t))return O.Space;if(it(t))return O.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return O.Word;return O.Other}}var k=class e{constructor(e,t,n,r,i,a){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=i,a&&(a._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)Fe(this,e<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(n==null){if(t)throw RangeError(`Field is not present in this state`);return}return Fe(this,n),Ie(this,n)}update(...e){return Ze(this,e,!0)}applyTransaction(t){let n=this.config,{base:r,compartments:i}=n;for(let e of t.effects)e.is(je.reconfigure)?(n&&=(i=new Map,n.compartments.forEach((e,t)=>i.set(t,e)),null),i.set(e.value.compartment,e.value.extension)):e.is(D.reconfigure)?(n=null,r=e.value):e.is(D.appendConfig)&&(n=null,r=tt(r).concat(e.value));let a;n?a=t.startState.values.slice():(n=Ne.resolve(r,i,this),a=new e(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null).values);let o=t.startState.facet(Re)?t.newSelection:t.newSelection.asSingle();new e(n,t.newDoc,o,a,(e,n)=>n.update(e,t),t)}replaceSelection(e){return typeof e==`string`&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:T.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),i=[n.range],a=tt(n.effects);for(let n=1;n<t.ranges.length;n++){let o=e(t.ranges[n]),s=this.changes(o.changes),c=s.map(r);for(let e=0;e<n;e++)i[e]=i[e].map(c);let l=r.mapDesc(s,!0);i.push(o.range.map(l)),r=r.compose(c),a=D.mapEffects(a,c).concat(D.mapEffects(tt(o.effects),l))}return{changes:r,selection:T.create(i,t.mainIndex),effects:a}}changes(t=[]){return t instanceof de?t:de.of(t,this.doc.length,this.facet(e.lineSeparator))}toText(t){return h.of(t.split(this.facet(e.lineSeparator)||le))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(Fe(this,t),Ie(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let r=e[n];r instanceof Ee&&this.config.address[r.id]!=null&&(t[n]=r.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(t,n={},r){if(!t||typeof t.doc!=`string`)throw RangeError(`Invalid JSON representation for EditorState`);let i=[];if(r){for(let e in r)if(Object.prototype.hasOwnProperty.call(t,e)){let n=r[e],a=t[e];i.push(n.init(e=>n.spec.fromJSON(a,e)))}}return e.create({doc:t.doc,selection:T.fromJSON(t.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(t={}){let n=Ne.resolve(t.extensions||[],new Map),r=t.doc instanceof h?t.doc:h.of((t.doc||``).split(n.staticFacet(e.lineSeparator)||le)),i=t.selection?t.selection instanceof T?t.selection:T.single(t.selection.anchor,t.selection.head):T.single(0);return ve(i,r.length),n.staticFacet(Re)||(i=i.asSingle()),new e(n,r,i,n.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(e.tabSize)}get lineBreak(){return this.facet(e.lineSeparator)||`
@@ -1 +1 @@
1
- import{m as e,t}from"./mermaid-parser.core-BGvTV5pP.js";import{n}from"./chunk-Y2CYZVJY-DsF7k-Jl.js";import{m as r}from"./src-B6xuSHsQ.js";import"./chunk-DU6HZSFF-FA2D2oY1.js";import{n as i,r as a,t as o}from"./chunk-SVP7TREG-CKmQB0kw.js";import{t as s}from"./chunk-JWPE2WC7-DVXcaiue.js";import"./mermaid.core-GxUCFU4e.js";var c=e().RailroadAbnf.parser.LangiumParser,l=n(e=>{let t=e.alternatives.map(u);return t.length===1?t[0]:{type:`choice`,alternatives:t}},`transformAlternation`),u=n(e=>{let t=e.elements.map(f);return t.length===1?t[0]:{type:`sequence`,elements:t}},`transformConcatenation`),d=n(e=>{if(e.includes(`*`)){let[t,n]=e.split(`*`);return{min:t?parseInt(t,10):0,max:n?parseInt(n,10):1/0}}let t=parseInt(e,10);return{min:t,max:t}},`parseRepeat`),f=n(e=>{let t=p(e.primary);if(!e.repeat)return t;let{min:n,max:r}=d(e.repeat);return n===0&&r===1?{type:`optional`,element:t}:{type:`repetition`,element:t,min:n,max:r}},`transformElement`),p=n(e=>{switch(e.$type){case`AbnfStringLiteral`:return{type:`terminal`,value:e.value};case`AbnfNumVal`:return{type:`terminal`,value:e.value};case`AbnfRuleName`:return{type:`nonterminal`,name:e.name};case`AbnfGroup`:return l(e.element);case`AbnfOptionalGroup`:return{type:`optional`,element:l(e.element)};default:throw Error(`Unsupported ABNF primary node: ${e.$type}`)}},`transformPrimary`),m=n(e=>({name:e.name,definition:l(e.definition)}),`transformRule`),h=n(e=>{s(e,o),e.title&&o.setTitle(e.title),e.rules.map(e=>o.addRule(m(e)))},`populateDb`),g={parser:{parse:n(e=>{o.clear(),r.debug(`[ABNF Parser] Starting Langium parse`);let n=c.parse(e);if(n.lexerErrors.length>0||n.parserErrors.length>0)throw new t(n);let i=n.value;r.debug(`[ABNF Parser] Parsed rules:`,i.rules.length),h(i),r.debug(`[ABNF Parser] Parse complete`)},`parse`),parser:{yy:o}},db:o,renderer:a,styles:i};export{g as diagram};
1
+ import{m as e,t}from"./mermaid-parser.core-CYYXlPrD.js";import{n}from"./chunk-Y2CYZVJY-DsF7k-Jl.js";import{m as r}from"./src-B6xuSHsQ.js";import"./chunk-DU6HZSFF-B-M8csoA.js";import{n as i,r as a,t as o}from"./chunk-SVP7TREG-CDjQfSFm.js";import{t as s}from"./chunk-JWPE2WC7-DVXcaiue.js";import"./mermaid.core-DNKCSJO6.js";var c=e().RailroadAbnf.parser.LangiumParser,l=n(e=>{let t=e.alternatives.map(u);return t.length===1?t[0]:{type:`choice`,alternatives:t}},`transformAlternation`),u=n(e=>{let t=e.elements.map(f);return t.length===1?t[0]:{type:`sequence`,elements:t}},`transformConcatenation`),d=n(e=>{if(e.includes(`*`)){let[t,n]=e.split(`*`);return{min:t?parseInt(t,10):0,max:n?parseInt(n,10):1/0}}let t=parseInt(e,10);return{min:t,max:t}},`parseRepeat`),f=n(e=>{let t=p(e.primary);if(!e.repeat)return t;let{min:n,max:r}=d(e.repeat);return n===0&&r===1?{type:`optional`,element:t}:{type:`repetition`,element:t,min:n,max:r}},`transformElement`),p=n(e=>{switch(e.$type){case`AbnfStringLiteral`:return{type:`terminal`,value:e.value};case`AbnfNumVal`:return{type:`terminal`,value:e.value};case`AbnfRuleName`:return{type:`nonterminal`,name:e.name};case`AbnfGroup`:return l(e.element);case`AbnfOptionalGroup`:return{type:`optional`,element:l(e.element)};default:throw Error(`Unsupported ABNF primary node: ${e.$type}`)}},`transformPrimary`),m=n(e=>({name:e.name,definition:l(e.definition)}),`transformRule`),h=n(e=>{s(e,o),e.title&&o.setTitle(e.title),e.rules.map(e=>o.addRule(m(e)))},`populateDb`),g={parser:{parse:n(e=>{o.clear(),r.debug(`[ABNF Parser] Starting Langium parse`);let n=c.parse(e);if(n.lexerErrors.length>0||n.parserErrors.length>0)throw new t(n);let i=n.value;r.debug(`[ABNF Parser] Parsed rules:`,i.rules.length),h(i),r.debug(`[ABNF Parser] Parse complete`)},`parse`),parser:{yy:o}},db:o,renderer:a,styles:i};export{g as diagram};
@@ -0,0 +1 @@
1
+ import"./chunk-FOHPRMQF-DHwB1DNv.js";import{M as e}from"./mermaid-parser.core-CYYXlPrD.js";export{e as createArchitectureServices};