@fgbg/mdocs 0.8.16 → 0.8.19

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 (107) hide show
  1. package/README.md +114 -76
  2. package/agent-skills/changelog/SKILL.md +21 -1
  3. package/agent-skills/index/SKILL.md +1 -1
  4. package/agent-skills/index.json +4 -4
  5. package/agent-skills/usage-agent-dev-loop/SKILL.md +7 -7
  6. package/agent-skills/usage-onboarding-ai/SKILL.md +98 -29
  7. package/agent-skills/usage-settings/SKILL.md +4 -4
  8. package/dist/server/agent/Agent/almost-empty.js +15 -0
  9. package/dist/server/agent/Agent/almost-empty.js.map +1 -0
  10. package/dist/server/agent/Agent/almost-empty.test.js +20 -0
  11. package/dist/server/agent/Agent/almost-empty.test.js.map +1 -0
  12. package/dist/server/agent/Agent/choice-pending.js +71 -0
  13. package/dist/server/agent/Agent/choice-pending.js.map +1 -0
  14. package/dist/server/agent/Agent/choice-pending.test.js +58 -0
  15. package/dist/server/agent/Agent/choice-pending.test.js.map +1 -0
  16. package/dist/server/agent/Agent/run.js +49 -3
  17. package/dist/server/agent/Agent/run.js.map +1 -1
  18. package/dist/server/agent/Agent/system-prompt.js +6 -5
  19. package/dist/server/agent/Agent/system-prompt.js.map +1 -1
  20. package/dist/server/agent/Agent/tools-account.js +16 -3
  21. package/dist/server/agent/Agent/tools-account.js.map +1 -1
  22. package/dist/server/agent/Agent/tools-choice.js +70 -0
  23. package/dist/server/agent/Agent/tools-choice.js.map +1 -0
  24. package/dist/server/agent/Agent/tools-coding.js +6 -3
  25. package/dist/server/agent/Agent/tools-coding.js.map +1 -1
  26. package/dist/server/agent/Agent/tools-overwrite.js +158 -0
  27. package/dist/server/agent/Agent/tools-overwrite.js.map +1 -0
  28. package/dist/server/routes/agent.routes.js +54 -0
  29. package/dist/server/routes/agent.routes.js.map +1 -1
  30. package/dist/server/search/document-index-manager.js +11 -8
  31. package/dist/server/search/document-index-manager.js.map +1 -1
  32. package/dist/web/assets/AgentChatPanel-CLKeiDeR.js +1 -0
  33. package/dist/web/assets/AiWriteWorkbench-Ecp214S5.js +6 -0
  34. package/dist/web/assets/DiagramEditor-BTRe45TX-DzJEhM4C.js +2 -0
  35. package/dist/web/assets/DocumentEditor-NPbbAape.js +21 -0
  36. package/dist/web/assets/{MergeView-BqQuuHxp.js → MergeView-BnWbq08U.js} +2 -2
  37. package/dist/web/assets/PlaygroundPage-BSGipUkC.js +8 -0
  38. package/dist/web/assets/SettingsPage-OklrFCx7.js +1 -0
  39. package/dist/web/assets/Toolbar-DjPuWk5G.js +126 -0
  40. package/dist/web/assets/VisitorPickerModal-BUS-cOq0.js +1 -0
  41. package/dist/web/assets/copy-hWOco_4c.js +11 -0
  42. package/dist/web/assets/diagram-gfUK8OHx.js +3016 -0
  43. package/dist/web/assets/editor-ONzd_YnO.js +16 -0
  44. package/dist/web/assets/history-AMIEbyMc.js +6 -0
  45. package/dist/web/assets/index-BksNm27A.css +1 -0
  46. package/dist/web/assets/index-C46BU1-j.js +185 -0
  47. package/dist/web/assets/meta2d-C8Z4cn-d.js +110 -0
  48. package/dist/web/assets/meta2dEngine-BD2XbzaV-D7hJ1H1g.js +1 -0
  49. package/dist/web/assets/motion-C4pN8CfU.js +8 -0
  50. package/dist/web/assets/plus-CnKbiP8x.js +6 -0
  51. package/dist/web/assets/react-B7vrA7AR.js +2126 -0
  52. package/dist/web/assets/react-vendor-BNpqFP9B.js +242 -0
  53. package/dist/web/assets/ui-DxdLi_28.js +3126 -0
  54. package/dist/web/index.html +28 -3
  55. package/package.json +2 -2
  56. package/dist/web/assets/_baseUniq-CTLDRefi.js +0 -1
  57. package/dist/web/assets/arc-C6HVu_cL.js +0 -1
  58. package/dist/web/assets/architectureDiagram-Q4EWVU46-BGZyIwfI.js +0 -36
  59. package/dist/web/assets/blockDiagram-DXYQGD6D-BnmQmYk5.js +0 -132
  60. package/dist/web/assets/c4Diagram-AHTNJAMY-D5ZSFyGW.js +0 -10
  61. package/dist/web/assets/channel-ComR_5wI.js +0 -1
  62. package/dist/web/assets/chunk-4BX2VUAB-bB7dqglW.js +0 -1
  63. package/dist/web/assets/chunk-4TB4RGXK-DLOuFWAV.js +0 -206
  64. package/dist/web/assets/chunk-55IACEB6-F-vn8P_5.js +0 -1
  65. package/dist/web/assets/chunk-EDXVE4YY-DJggdpTr.js +0 -1
  66. package/dist/web/assets/chunk-FMBD7UC4-CGFWLCLP.js +0 -15
  67. package/dist/web/assets/chunk-OYMX7WX6-nDiR5vU7.js +0 -231
  68. package/dist/web/assets/chunk-QZHKN3VN-D29FhQRL.js +0 -1
  69. package/dist/web/assets/chunk-YZCP3GAM-BmFALtIq.js +0 -1
  70. package/dist/web/assets/classDiagram-6PBFFD2Q-CxGT_r56.js +0 -1
  71. package/dist/web/assets/classDiagram-v2-HSJHXN6E-CxGT_r56.js +0 -1
  72. package/dist/web/assets/clone-J85LHgdR.js +0 -1
  73. package/dist/web/assets/cose-bilkent-S5V4N54A-J4Iar7P4.js +0 -1
  74. package/dist/web/assets/cytoscape.esm-BiciSPf8.js +0 -331
  75. package/dist/web/assets/dagre-KV5264BT-Cg07vwKD.js +0 -4
  76. package/dist/web/assets/defaultLocale-DX6XiGOO.js +0 -1
  77. package/dist/web/assets/diagram-5BDNPKRD-D0FP-ifV.js +0 -10
  78. package/dist/web/assets/diagram-G4DWMVQ6-CNejTsu2.js +0 -24
  79. package/dist/web/assets/diagram-MMDJMWI5-DEQjM6f7.js +0 -43
  80. package/dist/web/assets/diagram-TYMM5635-CRGZl6sR.js +0 -24
  81. package/dist/web/assets/erDiagram-SMLLAGMA-BGOATwuq.js +0 -85
  82. package/dist/web/assets/flowDiagram-DWJPFMVM-DVHizH8q.js +0 -162
  83. package/dist/web/assets/ganttDiagram-T4ZO3ILL-dLF_Rbaw.js +0 -292
  84. package/dist/web/assets/gitGraphDiagram-UUTBAWPF-BNMxCpkL.js +0 -106
  85. package/dist/web/assets/graph-p7_cO2pv.js +0 -1
  86. package/dist/web/assets/index-5eJ_7IuO.css +0 -1
  87. package/dist/web/assets/index-DoJ58x_f.js +0 -6291
  88. package/dist/web/assets/infoDiagram-42DDH7IO-BDffsV8g.js +0 -2
  89. package/dist/web/assets/ishikawaDiagram-UXIWVN3A-C7fw-Hwt.js +0 -70
  90. package/dist/web/assets/journeyDiagram-VCZTEJTY-CuEYHG93.js +0 -139
  91. package/dist/web/assets/kanban-definition-6JOO6SKY-iodYb2rc.js +0 -89
  92. package/dist/web/assets/layout-Dblo7Nv4.js +0 -1
  93. package/dist/web/assets/linear-Dj7ICVZv.js +0 -1
  94. package/dist/web/assets/min-BC0MiAVU.js +0 -1
  95. package/dist/web/assets/mindmap-definition-QFDTVHPH-Bi8kR-nH.js +0 -96
  96. package/dist/web/assets/pieDiagram-DEJITSTG-DFXNJaaz.js +0 -30
  97. package/dist/web/assets/quadrantDiagram-34T5L4WZ-eG750Sg7.js +0 -7
  98. package/dist/web/assets/requirementDiagram-MS252O5E-BOS23lbk.js +0 -84
  99. package/dist/web/assets/sankeyDiagram-XADWPNL6-iuLPdF16.js +0 -10
  100. package/dist/web/assets/sequenceDiagram-FGHM5R23-9dOhL1F_.js +0 -157
  101. package/dist/web/assets/stateDiagram-FHFEXIEX-DiYubp3u.js +0 -1
  102. package/dist/web/assets/stateDiagram-v2-QKLJ7IA2-C0u2afgY.js +0 -1
  103. package/dist/web/assets/timeline-definition-GMOUNBTQ-B7K2SCHF.js +0 -120
  104. package/dist/web/assets/vennDiagram-DHZGUBPP-DwsDXISO.js +0 -34
  105. package/dist/web/assets/wardley-RL74JXVD-DOtyNPcb.js +0 -162
  106. package/dist/web/assets/wardleyDiagram-NUSXRM2D-IO3BUkVB.js +0 -20
  107. package/dist/web/assets/xychartDiagram-5P7HB3ND-B_eC9Ig0.js +0 -7
@@ -1,4 +1,4 @@
1
- import{aR as E,aS as W,aT as sa,aU as ra,aV as io,aW as js,aX as oa,aY as la,aZ as aa}from"./index-DoJ58x_f.js";function hn({lexicalJson:s,onMarkdown:e,onError:t}){const[i,n]=E.useState(null),r=E.useRef(!1);return E.useEffect(()=>{r.current=!1},[s]),E.useEffect(()=>{if(!(!i||r.current))try{i.setDocument("json",s);const o=i.getDocument("markdown");typeof o=="string"&&(r.current=!0,e(o))}catch{t==null||t()}},[i,s,e,t]),W.jsx("div",{className:"mdocs-lexical-md-bridge","aria-hidden":!0,children:W.jsx(sa,{content:s,type:"json",editable:!1,onInit:n,plugins:[ra]})})}let Ln=[],no=[];(()=>{let s="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e<s.length;e++)(e%2?no:Ln).push(t=t+s[e])})();function ha(s){if(s<768)return!1;for(let e=0,t=Ln.length;;){let i=e+t>>1;if(s<Ln[i])t=i;else if(s>=no[i])e=i+1;else return!0;if(e==t)return!1}}function Ks(s){return s>=127462&&s<=127487}const qs=8205;function ca(s,e,t=!0,i=!0){return(t?so:fa)(s,e,i)}function so(s,e,t){if(e==s.length)return e;e&&ro(s.charCodeAt(e))&&oo(s.charCodeAt(e-1))&&e--;let i=cn(s,e);for(e+=$s(i);e<s.length;){let n=cn(s,e);if(i==qs||n==qs||t&&ha(n))e+=$s(n),i=n;else if(Ks(n)){let r=0,o=e-2;for(;o>=0&&Ks(cn(s,o));)r++,o-=2;if(r%2==0)break;e+=2}else break}return e}function fa(s,e,t){for(;e>0;){let i=so(s,e-2,t);if(i<e)return i;e--}return 0}function cn(s,e){let t=s.charCodeAt(e);if(!oo(t)||e+1==s.length)return t;let i=s.charCodeAt(e+1);return ro(i)?(t-55296<<10)+(i-56320)+65536:t}function ro(s){return s>=56320&&s<57344}function oo(s){return s>=55296&&s<56320}function $s(s){return s<65536?1:2}class I{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=Bt(this,e,t);let n=[];return this.decompose(0,e,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(t,this.length,n,1),Pe.from(n,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Bt(this,e,t);let i=[];return this.decompose(e,t,i,0),Pe.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),n=new qt(this),r=new qt(e);for(let o=t,l=t;;){if(n.next(o),r.next(o),o=0,n.lineBreak!=r.lineBreak||n.done!=r.done||n.value!=r.value)return!1;if(l+=n.value.length,n.done||l>=i)return!0}}iter(e=1){return new qt(this,e)}iterRange(e,t=this.length){return new lo(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let n=this.line(e).from;i=this.iterRange(n,Math.max(n,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new ao(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?I.empty:e.length<=32?new _(e):Pe.from(_.split(e,[]))}}class _ extends I{constructor(e,t=ua(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,n){for(let r=0;;r++){let o=this.text[r],l=n+o.length;if((t?i:l)>=e)return new da(n,l,i,o);n=l+1,i++}}decompose(e,t,i,n){let r=e<=0&&t>=this.length?this:new _(Us(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(n&1){let o=i.pop(),l=Mi(r.text,o.text.slice(),0,r.length);if(l.length<=32)i.push(new _(l,o.length+r.length));else{let a=l.length>>1;i.push(new _(l.slice(0,a)),new _(l.slice(a)))}}else i.push(r)}replace(e,t,i){if(!(i instanceof _))return super.replace(e,t,i);[e,t]=Bt(this,e,t);let n=Mi(this.text,Mi(i.text,Us(this.text,0,e)),t),r=this.length+i.length-(t-e);return n.length<=32?new _(n,r):Pe.from(_.split(n,[]),r)}sliceString(e,t=this.length,i=`
1
+ import{r as E,j as W}from"./react-vendor-BNpqFP9B.js";import{b as io,ah as js,ai as sa,aj as ra,ak as oa}from"./index-C46BU1-j.js";import{E as la,B as aa}from"./react-B7vrA7AR.js";import"./ui-DxdLi_28.js";import"./motion-C4pN8CfU.js";import"./editor-ONzd_YnO.js";import"./diagram-gfUK8OHx.js";import"./plus-CnKbiP8x.js";import"./copy-hWOco_4c.js";function hn({lexicalJson:s,onMarkdown:e,onError:t}){const[i,n]=E.useState(null),r=E.useRef(!1);return E.useEffect(()=>{r.current=!1},[s]),E.useEffect(()=>{if(!(!i||r.current))try{i.setDocument("json",s);const o=i.getDocument("markdown");typeof o=="string"&&(r.current=!0,e(o))}catch{t==null||t()}},[i,s,e,t]),W.jsx("div",{className:"mdocs-lexical-md-bridge","aria-hidden":!0,children:W.jsx(la,{content:s,type:"json",editable:!1,onInit:n,plugins:[aa]})})}let Ln=[],no=[];(()=>{let s="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e<s.length;e++)(e%2?no:Ln).push(t=t+s[e])})();function ha(s){if(s<768)return!1;for(let e=0,t=Ln.length;;){let i=e+t>>1;if(s<Ln[i])t=i;else if(s>=no[i])e=i+1;else return!0;if(e==t)return!1}}function Ks(s){return s>=127462&&s<=127487}const qs=8205;function ca(s,e,t=!0,i=!0){return(t?so:fa)(s,e,i)}function so(s,e,t){if(e==s.length)return e;e&&ro(s.charCodeAt(e))&&oo(s.charCodeAt(e-1))&&e--;let i=cn(s,e);for(e+=$s(i);e<s.length;){let n=cn(s,e);if(i==qs||n==qs||t&&ha(n))e+=$s(n),i=n;else if(Ks(n)){let r=0,o=e-2;for(;o>=0&&Ks(cn(s,o));)r++,o-=2;if(r%2==0)break;e+=2}else break}return e}function fa(s,e,t){for(;e>0;){let i=so(s,e-2,t);if(i<e)return i;e--}return 0}function cn(s,e){let t=s.charCodeAt(e);if(!oo(t)||e+1==s.length)return t;let i=s.charCodeAt(e+1);return ro(i)?(t-55296<<10)+(i-56320)+65536:t}function ro(s){return s>=56320&&s<57344}function oo(s){return s>=55296&&s<56320}function $s(s){return s<65536?1:2}class I{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=Bt(this,e,t);let n=[];return this.decompose(0,e,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(t,this.length,n,1),Pe.from(n,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Bt(this,e,t);let i=[];return this.decompose(e,t,i,0),Pe.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),n=new qt(this),r=new qt(e);for(let o=t,l=t;;){if(n.next(o),r.next(o),o=0,n.lineBreak!=r.lineBreak||n.done!=r.done||n.value!=r.value)return!1;if(l+=n.value.length,n.done||l>=i)return!0}}iter(e=1){return new qt(this,e)}iterRange(e,t=this.length){return new lo(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let n=this.line(e).from;i=this.iterRange(n,Math.max(n,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new ao(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?I.empty:e.length<=32?new _(e):Pe.from(_.split(e,[]))}}class _ extends I{constructor(e,t=ua(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,n){for(let r=0;;r++){let o=this.text[r],l=n+o.length;if((t?i:l)>=e)return new da(n,l,i,o);n=l+1,i++}}decompose(e,t,i,n){let r=e<=0&&t>=this.length?this:new _(Us(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(n&1){let o=i.pop(),l=Mi(r.text,o.text.slice(),0,r.length);if(l.length<=32)i.push(new _(l,o.length+r.length));else{let a=l.length>>1;i.push(new _(l.slice(0,a)),new _(l.slice(a)))}}else i.push(r)}replace(e,t,i){if(!(i instanceof _))return super.replace(e,t,i);[e,t]=Bt(this,e,t);let n=Mi(this.text,Mi(i.text,Us(this.text,0,e)),t),r=this.length+i.length-(t-e);return n.length<=32?new _(n,r):Pe.from(_.split(n,[]),r)}sliceString(e,t=this.length,i=`
2
2
  `){[e,t]=Bt(this,e,t);let n="";for(let r=0,o=0;r<=t&&o<this.text.length;o++){let l=this.text[o],a=r+l.length;r>e&&o&&(n+=i),e<a&&t>r&&(n+=l.slice(Math.max(0,e-r),t-r)),r=a+1}return n}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],n=-1;for(let r of e)i.push(r),n+=r.length+1,i.length==32&&(t.push(new _(i,n)),i=[],n=-1);return n>-1&&t.push(new _(i,n)),t}}class Pe extends I{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,n){for(let r=0;;r++){let o=this.children[r],l=n+o.length,a=i+o.lines-1;if((t?a:l)>=e)return o.lineInner(e,t,i,n);n=l+1,i=a+1}}decompose(e,t,i,n){for(let r=0,o=0;o<=t&&r<this.children.length;r++){let l=this.children[r],a=o+l.length;if(e<=a&&t>=o){let h=n&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!h?i.push(l):l.decompose(e-o,t-o,i,h)}o=a+1}}replace(e,t,i){if([e,t]=Bt(this,e,t),i.lines<this.lines)for(let n=0,r=0;n<this.children.length;n++){let o=this.children[n],l=r+o.length;if(e>=r&&t<=l){let a=o.replace(e-r,t-r,i),h=this.lines-o.lines+a.lines;if(a.lines<h>>4&&a.lines>h>>6){let c=this.children.slice();return c[n]=a,new Pe(c,this.length-(t-e)+i.length)}return super.replace(r,l,a)}r=l+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=`
3
3
  `){[e,t]=Bt(this,e,t);let n="";for(let r=0,o=0;r<this.children.length&&o<=t;r++){let l=this.children[r],a=o+l.length;o>e&&r&&(n+=i),e<a&&t>o&&(n+=l.sliceString(e-o,t-o,i)),o=a+1}return n}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof Pe))return 0;let i=0,[n,r,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;n+=t,r+=t){if(n==o||r==l)return i;let a=this.children[n],h=e.children[r];if(a!=h)return i+a.scanIdentical(h,t);i+=a.length+1}}static from(e,t=e.reduce((i,n)=>i+n.length+1,-1)){let i=0;for(let d of e)i+=d.lines;if(i<32){let d=[];for(let g of e)g.flatten(d);return new _(d,t)}let n=Math.max(32,i>>5),r=n<<1,o=n>>1,l=[],a=0,h=-1,c=[];function f(d){let g;if(d.lines>r&&d instanceof Pe)for(let p of d.children)f(p);else d.lines>o&&(a>o||!a)?(u(),l.push(d)):d instanceof _&&a&&(g=c[c.length-1])instanceof _&&d.lines+g.lines<=32?(a+=d.lines,h+=d.length+1,c[c.length-1]=new _(g.text.concat(d.text),g.length+1+d.length)):(a+d.lines>n&&u(),a+=d.lines,h+=d.length+1,c.push(d))}function u(){a!=0&&(l.push(c.length==1?c[0]:Pe.from(c,h)),h=-1,a=c.length=0)}for(let d of e)f(d);return u(),l.length==1?l[0]:new Pe(l,t)}}I.empty=new _([""],0);function ua(s){let e=-1;for(let t of s)e+=t.length+1;return e}function Mi(s,e,t=0,i=1e9){for(let n=0,r=0,o=!0;r<s.length&&n<=i;r++){let l=s[r],a=n+l.length;a>=t&&(a>i&&(l=l.slice(0,i-n)),n<t&&(l=l.slice(t-n)),o?(e[e.length-1]+=l,o=!1):e.push(l)),n=a+1}return e}function Us(s,e,t){return Mi(s,[""],e,t)}class qt{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 _?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],r=this.offsets[i],o=r>>1,l=n instanceof _?n.text.length:n.children.length;if(o==(t>0?l:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((r&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=`
4
4
  `,this;e--}else if(n instanceof _){let a=n.text[o+(t<0?-1:0)];if(this.offsets[i]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=n.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof _?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class lo{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new qt(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:n}=this.cursor.next(e);return this.pos+=(n.length+e)*t,this.value=n.length<=i?n:t<0?n.slice(n.length-i):n.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class ao{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:n}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(I.prototype[Symbol.iterator]=function(){return this.iter()},qt.prototype[Symbol.iterator]=lo.prototype[Symbol.iterator]=ao.prototype[Symbol.iterator]=function(){return this});class da{constructor(e,t,i,n){this.from=e,this.to=t,this.number=i,this.text=n}get length(){return this.to-this.from}}function Bt(s,e,t){return e=Math.max(0,Math.min(s.length,e)),[e,Math.max(e,Math.min(s.length,t))]}function le(s,e,t=!0,i=!0){return ca(s,e,t,i)}function ga(s){return s>=56320&&s<57344}function pa(s){return s>=55296&&s<56320}function ma(s,e){let t=s.charCodeAt(e);if(!pa(t)||e+1==s.length)return t;let i=s.charCodeAt(e+1);return ga(i)?(t-55296<<10)+(i-56320)+65536:t}function ya(s){return s<65536?1:2}const En=/\r\n?|\n/;var me=function(s){return s[s.Simple=0]="Simple",s[s.TrackDel=1]="TrackDel",s[s.TrackBefore=2]="TrackBefore",s[s.TrackAfter=3]="TrackAfter",s}(me||(me={}));class Ve{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t+1];e+=i<0?this.sections[t]:i}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,i=0,n=0;t<this.sections.length;){let r=this.sections[t++],o=this.sections[t++];o<0?(e(i,n,r),n+=r):n+=o,i+=r}}iterChangedRanges(e,t=!1){Rn(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let i=this.sections[t++],n=this.sections[t++];n<0?e.push(i,n):e.push(n,i)}return new Ve(e)}composeDesc(e){return this.empty?e:e.empty?this:ho(this,e)}mapDesc(e,t=!1){return e.empty?this:In(this,e,t)}mapPos(e,t=-1,i=me.Simple){let n=0,r=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],h=n+l;if(a<0){if(h>e)return r+(e-n);r+=l}else{if(i!=me.Simple&&h>=e&&(i==me.TrackDel&&n<e&&h>e||i==me.TrackBefore&&n<e||i==me.TrackAfter&&h>e))return null;if(h>e||h==e&&t<0&&!l)return e==n||t<0?r:r+a;r+=a}n=h}if(e>n)throw new RangeError(`Position ${e} is out of range for changeset of length ${n}`);return r}touchesRange(e,t=e){for(let i=0,n=0;i<this.sections.length&&n<=t;){let r=this.sections[i++],o=this.sections[i++],l=n+r;if(o>=0&&n<=t&&l>=e)return n<e&&l>t?"cover":!0;n=l}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let i=this.sections[t++],n=this.sections[t++];e+=(e?" ":"")+i+(n>=0?":"+n:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Ve(e)}static create(e){return new Ve(e)}}class Q extends Ve{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Rn(this,(t,i,n,r,o)=>e=e.replace(n,n+(i-t),o),!1),e}mapDesc(e,t=!1){return In(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let n=0,r=0;n<t.length;n+=2){let o=t[n],l=t[n+1];if(l>=0){t[n]=l,t[n+1]=o;let a=n>>1;for(;i.length<a;)i.push(I.empty);i.push(o?e.slice(r,r+o):I.empty)}r+=o}return new Q(t,i)}compose(e){return this.empty?e:e.empty?this:ho(this,e,!0)}map(e,t=!1){return e.empty?this:In(this,e,t,!0)}iterChanges(e,t=!1){Rn(this,e,t)}get desc(){return Ve.create(this.sections)}filter(e){let t=[],i=[],n=[],r=new Yt(this);e:for(let o=0,l=0;;){let a=o==e.length?1e9:e[o++];for(;l<a||l==a&&r.len==0;){if(r.done)break e;let c=Math.min(r.len,a-l);oe(n,c,-1);let f=r.ins==-1?-1:r.off==0?r.ins:0;oe(t,c,f),f>0&&Xe(i,t,r.text),r.forward(c),l+=c}let h=e[o++];for(;l<h;){if(r.done)break e;let c=Math.min(r.len,h-l);oe(t,c,-1),oe(n,c,r.ins==-1?-1:r.off==0?r.ins:0),r.forward(c),l+=c}}return{changes:new Q(t,i),filtered:Ve.create(n)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t],n=this.sections[t+1];n<0?e.push(i):n==0?e.push([i]):e.push([i].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,i){let n=[],r=[],o=0,l=null;function a(c=!1){if(!c&&!n.length)return;o<t&&oe(n,t-o,-1);let f=new Q(n,r);l=l?l.compose(f.map(l)):f,n=[],r=[],o=0}function h(c){if(Array.isArray(c))for(let f of c)h(f);else if(c instanceof Q){if(c.length!=t)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${t})`);a(),l=l?l.compose(c.map(l)):c}else{let{from:f,to:u=f,insert:d}=c;if(f>u||f<0||u>t)throw new RangeError(`Invalid change range ${f} to ${u} (in doc of length ${t})`);let g=d?typeof d=="string"?I.of(d.split(i||En)):d:I.empty,p=g.length;if(f==u&&p==0)return;f<o&&a(),f>o&&oe(n,f-o,-1),oe(n,u-f,p),Xe(r,n,g),o=u}}return h(e),a(!l),l}static empty(e){return new Q(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let n=0;n<e.length;n++){let r=e[n];if(typeof r=="number")t.push(r,-1);else{if(!Array.isArray(r)||typeof r[0]!="number"||r.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(r.length==1)t.push(r[0],0);else{for(;i.length<n;)i.push(I.empty);i[n]=I.of(r.slice(1)),t.push(r[0],i[n].length)}}}return new Q(t,i)}static createSet(e,t){return new Q(e,t)}}function oe(s,e,t,i=!1){if(e==0&&t<=0)return;let n=s.length-2;n>=0&&t<=0&&t==s[n+1]?s[n]+=e:n>=0&&e==0&&s[n]==0?s[n+1]+=t:i?(s[n]+=e,s[n+1]+=t):s.push(e,t)}function Xe(s,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i<s.length)s[s.length-1]=s[s.length-1].append(t);else{for(;s.length<i;)s.push(I.empty);s.push(t)}}function Rn(s,e,t){let i=s.inserted;for(let n=0,r=0,o=0;o<s.sections.length;){let l=s.sections[o++],a=s.sections[o++];if(a<0)n+=l,r+=l;else{let h=n,c=r,f=I.empty;for(;h+=l,c+=a,a&&i&&(f=f.append(i[o-2>>1])),!(t||o==s.sections.length||s.sections[o+1]<0);)l=s.sections[o++],a=s.sections[o++];e(n,h,r,c,f),n=h,r=c}}}function In(s,e,t,i=!1){let n=[],r=i?[]:null,o=new Yt(s),l=new Yt(e);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let h=Math.min(o.len,l.len);oe(n,h,-1),o.forward(h),l.forward(h)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!t))){let h=l.len;for(oe(n,l.ins,-1);h;){let c=Math.min(o.len,h);o.ins>=0&&a<o.i&&o.len<=c&&(oe(n,0,o.ins),r&&Xe(r,n,o.text),a=o.i),o.forward(c),h-=c}l.next()}else if(o.ins>=0){let h=0,c=o.len;for(;c;)if(l.ins==-1){let f=Math.min(c,l.len);h+=f,c-=f,l.forward(f)}else if(l.ins==0&&l.len<c)c-=l.len,l.next();else break;oe(n,h,a<o.i?o.ins:0),r&&a<o.i&&Xe(r,n,o.text),a=o.i,o.forward(o.len-c)}else{if(o.done&&l.done)return r?Q.createSet(n,r):Ve.create(n);throw new Error("Mismatched change set lengths")}}}function ho(s,e,t=!1){let i=[],n=t?[]:null,r=new Yt(s),o=new Yt(e);for(let l=!1;;){if(r.done&&o.done)return n?Q.createSet(i,n):Ve.create(i);if(r.ins==0)oe(i,r.len,0,l),r.next();else if(o.len==0&&!o.done)oe(i,0,o.ins,l),n&&Xe(n,i,o.text),o.next();else{if(r.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(r.len2,o.len),h=i.length;if(r.ins==-1){let c=o.ins==-1?-1:o.off?0:o.ins;oe(i,a,c,l),n&&c&&Xe(n,i,o.text)}else o.ins==-1?(oe(i,r.off?0:r.len,a,l),n&&Xe(n,i,r.textBit(a))):(oe(i,r.off?0:r.len,o.off?0:o.ins,l),n&&!o.off&&Xe(n,i,o.text));l=(r.ins>a||o.ins>=0&&o.len>a)&&(l||i.length>h),r.forward2(a),o.forward(a)}}}}class Yt{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?I.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?I.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class ct{constructor(e,t,i){this.from=e,this.to=t,this.flags=i}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 bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,t=-1){let i,n;return this.empty?i=n=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),n=e.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new ct(i,n,this.flags)}extend(e,t=e,i=0){if(e<=this.anchor&&t>=this.anchor)return b.range(e,t,void 0,void 0,i);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return b.range(this.anchor,n,void 0,void 0,i)}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 new RangeError("Invalid JSON representation for SelectionRange");return b.range(e.anchor,e.head)}static create(e,t,i){return new ct(e,t,i)}}class b{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:b.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(e.ranges[i],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new b([this.main],0)}addRange(e,t=!0){return b.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let i=this.ranges.slice();return i[t]=e,b.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new b(e.ranges.map(t=>ct.fromJSON(t)),e.main)}static single(e,t=e){return new b([b.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,n=0;n<e.length;n++){let r=e[n];if(r.empty?r.from<=i:r.from<i)return b.normalized(e.slice(),t);i=r.to}return new b(e,t)}static cursor(e,t=0,i,n){return ct.create(e,e,(t==0?0:t<0?8:16)|(i==null?7:Math.min(6,i))|(n??16777215)<<6)}static range(e,t,i,n,r){let o=(i??16777215)<<6|(n==null?7:Math.min(6,n));return!r&&e!=t&&(r=t<e?1:-1),t<e?ct.create(t,e,48|o):ct.create(e,t,(r?r<0?8:16:0)|o)}static normalized(e,t=0){let i=e[t];e.sort((n,r)=>n.from-r.from),t=e.indexOf(i);for(let n=1;n<e.length;n++){let r=e[n],o=e[n-1];if(r.empty?r.from<=o.to:r.from<o.to){let l=o.from,a=Math.max(r.to,o.to);n<=t&&t--,e.splice(--n,2,r.anchor>r.head?b.range(a,l):b.range(l,a))}}return new b(e,t)}}function co(s,e){for(let t of s.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let bs=0;class M{constructor(e,t,i,n,r){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=n,this.id=bs++,this.default=e([]),this.extensions=typeof r=="function"?r(this):r}get reader(){return this}static define(e={}){return new M(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:xs),!!e.static,e.enables)}of(e){return new Di([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Di(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Di(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}}function xs(s,e){return s==e||s.length==e.length&&s.every((t,i)=>t===e[i])}class Di{constructor(e,t,i,n){this.dependencies=e,this.facet=t,this.type=i,this.value=n,this.id=bs++}dynamicSlot(e){var t;let i=this.value,n=this.facet.compareInput,r=this.id,o=e[r]>>1,l=this.type==2,a=!1,h=!1,c=[];for(let f of this.dependencies)f=="doc"?a=!0:f=="selection"?h=!0:((t=e[f.id])!==null&&t!==void 0?t:1)&1||c.push(e[f.id]);return{create(f){return f.values[o]=i(f),1},update(f,u){if(a&&u.docChanged||h&&(u.docChanged||u.selection)||Pn(f,c)){let d=i(f);if(l?!Gs(d,f.values[o],n):!n(d,f.values[o]))return f.values[o]=d,1}return 0},reconfigure:(f,u)=>{let d,g=u.config.address[r];if(g!=null){let p=Ri(u,g);if(this.dependencies.every(m=>m instanceof M?u.facet(m)===f.facet(m):m instanceof ze?u.field(m,!1)==f.field(m,!1):!0)||(l?Gs(d=i(f),p,n):n(d=i(f),p)))return f.values[o]=p,0}else d=i(f);return f.values[o]=d,1}}}}function Gs(s,e,t){if(s.length!=e.length)return!1;for(let i=0;i<s.length;i++)if(!t(s[i],e[i]))return!1;return!0}function Pn(s,e){let t=!1;for(let i of e)$t(s,i)&1&&(t=!0);return t}function ba(s,e,t){let i=t.map(a=>s[a.id]),n=t.map(a=>a.type),r=i.filter(a=>!(a&1)),o=s[e.id]>>1;function l(a){let h=[];for(let c=0;c<i.length;c++){let f=Ri(a,i[c]);if(n[c]==2)for(let u of f)h.push(u);else h.push(f)}return e.combine(h)}return{create(a){for(let h of i)$t(a,h);return a.values[o]=l(a),1},update(a,h){if(!Pn(a,r))return 0;let c=l(a);return e.compare(c,a.values[o])?0:(a.values[o]=c,1)},reconfigure(a,h){let c=Pn(a,i),f=h.config.facets[e.id],u=h.facet(e);if(f&&!c&&xs(t,f))return a.values[o]=u,0;let d=l(a);return e.compare(d,u)?(a.values[o]=u,0):(a.values[o]=d,1)}}}const hi=M.define({static:!0});class ze{constructor(e,t,i,n,r){this.id=e,this.createF=t,this.updateF=i,this.compareF=n,this.spec=r,this.provides=void 0}static define(e){let t=new ze(bs++,e.create,e.update,e.compare||((i,n)=>i===n),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(hi).find(i=>i.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,n)=>{let r=i.values[t],o=this.updateF(r,n);return this.compareF(r,o)?0:(i.values[t]=o,1)},reconfigure:(i,n)=>{let r=i.facet(hi),o=n.facet(hi),l;return(l=r.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(i.values[t]=l.create(i),1):n.config.address[this.id]!=null?(i.values[t]=n.field(this),0):(i.values[t]=this.create(i),1)}}}init(e){return[this,hi.of({field:this,create:e})]}get extension(){return this}}const ht={lowest:4,low:3,default:2,high:1,highest:0};function Wt(s){return e=>new uo(e,s)}const fo={highest:Wt(ht.highest),high:Wt(ht.high),default:Wt(ht.default),low:Wt(ht.low),lowest:Wt(ht.lowest)};class uo{constructor(e,t){this.inner=e,this.prec=t}}class Yi{of(e){return new Nn(this,e)}reconfigure(e){return Yi.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Nn{constructor(e,t){this.compartment=e,this.inner=t}}class Ei{constructor(e,t,i,n,r,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=n,this.staticValues=r,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,i){let n=[],r=Object.create(null),o=new Map;for(let u of xa(e,t,o))u instanceof ze?n.push(u):(r[u.facet.id]||(r[u.facet.id]=[])).push(u);let l=Object.create(null),a=[],h=[];for(let u of n)l[u.id]=h.length<<1,h.push(d=>u.slot(d));let c=i==null?void 0:i.config.facets;for(let u in r){let d=r[u],g=d[0].facet,p=c&&c[u]||[];if(d.every(m=>m.type==0))if(l[g.id]=a.length<<1|1,xs(p,d))a.push(i.facet(g));else{let m=g.combine(d.map(y=>y.value));a.push(i&&g.compare(m,i.facet(g))?i.facet(g):m)}else{for(let m of d)m.type==0?(l[m.id]=a.length<<1|1,a.push(m.value)):(l[m.id]=h.length<<1,h.push(y=>m.dynamicSlot(y)));l[g.id]=h.length<<1,h.push(m=>ba(m,g,d))}}let f=h.map(u=>u(l));return new Ei(e,o,f,l,a,r)}}function xa(s,e,t){let i=[[],[],[],[],[]],n=new Map;function r(o,l){let a=n.get(o);if(a!=null){if(a<=l)return;let h=i[a].indexOf(o);h>-1&&i[a].splice(h,1),o instanceof Nn&&t.delete(o.compartment)}if(n.set(o,l),Array.isArray(o))for(let h of o)r(h,l);else if(o instanceof Nn){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(o.compartment)||o.inner;t.set(o.compartment,h),r(h,l)}else if(o instanceof uo)r(o.inner,o.prec);else if(o instanceof ze)i[l].push(o),o.provides&&r(o.provides,l);else if(o instanceof Di)i[l].push(o),o.facet.extensions&&r(o.facet.extensions,ht.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(h,l)}}return r(s,ht.default),i.reduce((o,l)=>o.concat(l))}function $t(s,e){if(e&1)return 2;let t=e>>1,i=s.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;s.status[t]=4;let n=s.computeSlot(s,s.config.dynamicSlots[t]);return s.status[t]=2|n}function Ri(s,e){return e&1?s.config.staticValues[e>>1]:s.values[e>>1]}const go=M.define(),Wn=M.define({combine:s=>s.some(e=>e),static:!0}),po=M.define({combine:s=>s.length?s[0]:void 0,static:!0}),mo=M.define(),yo=M.define(),bo=M.define(),xo=M.define({combine:s=>s.length?s[0]:!1});class nt{constructor(e,t){this.type=e,this.value=t}static define(){return new wa}}class wa{of(e){return new nt(this,e)}}class ka{constructor(e){this.map=e}of(e){return new G(this,e)}}class G{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new G(this.type,t)}is(e){return this.type==e}static define(e={}){return new ka(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let n of e){let r=n.map(t);r&&i.push(r)}return i}}G.reconfigure=G.define();G.appendConfig=G.define();class Z{constructor(e,t,i,n,r,o){this.startState=e,this.changes=t,this.selection=i,this.effects=n,this.annotations=r,this.scrollIntoView=o,this._doc=null,this._state=null,i&&co(i,t.newLength),r.some(l=>l.type==Z.time)||(this.annotations=r.concat(Z.time.of(Date.now())))}static create(e,t,i,n,r,o){return new Z(e,t,i,n,r,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(Z.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}Z.time=nt.define();Z.userEvent=nt.define();Z.addToHistory=nt.define();Z.remote=nt.define();function Sa(s,e){let t=[];for(let i=0,n=0;;){let r,o;if(i<s.length&&(n==e.length||e[n]>=s[i]))r=s[i++],o=s[i++];else if(n<e.length)r=e[n++],o=e[n++];else return t;!t.length||t[t.length-1]<r?t.push(r,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function wo(s,e,t){var i;let n,r,o;return t?(n=e.changes,r=Q.empty(e.changes.length),o=s.changes.compose(e.changes)):(n=e.changes.map(s.changes),r=s.changes.mapDesc(e.changes,!0),o=s.changes.compose(n)),{changes:o,selection:e.selection?e.selection.map(r):(i=s.selection)===null||i===void 0?void 0:i.map(n),effects:G.mapEffects(s.effects,n).concat(G.mapEffects(e.effects,r)),annotations:s.annotations.length?s.annotations.concat(e.annotations):e.annotations,scrollIntoView:s.scrollIntoView||e.scrollIntoView}}function Hn(s,e,t){let i=e.selection,n=Ct(e.annotations);return e.userEvent&&(n=n.concat(Z.userEvent.of(e.userEvent))),{changes:e.changes instanceof Q?e.changes:Q.of(e.changes||[],t,s.facet(po)),selection:i&&(i instanceof b?i:b.single(i.anchor,i.head)),effects:Ct(e.effects),annotations:n,scrollIntoView:!!e.scrollIntoView}}function ko(s,e,t){let i=Hn(s,e.length?e[0]:{},s.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let r=1;r<e.length;r++){e[r].filter===!1&&(t=!1);let o=!!e[r].sequential;i=wo(i,Hn(s,e[r],o?i.changes.newLength:s.doc.length),o)}let n=Z.create(s,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return Ca(t?va(n):n)}function va(s){let e=s.startState,t=!0;for(let n of e.facet(mo)){let r=n(s);if(r===!1){t=!1;break}Array.isArray(r)&&(t=t===!0?r:Sa(t,r))}if(t!==!0){let n,r;if(t===!1)r=s.changes.invertedDesc,n=Q.empty(e.doc.length);else{let o=s.changes.filter(t);n=o.changes,r=o.filtered.mapDesc(o.changes).invertedDesc}s=Z.create(e,n,s.selection&&s.selection.map(r),G.mapEffects(s.effects,r),s.annotations,s.scrollIntoView)}let i=e.facet(yo);for(let n=i.length-1;n>=0;n--){let r=i[n](s);r instanceof Z?s=r:Array.isArray(r)&&r.length==1&&r[0]instanceof Z?s=r[0]:s=ko(e,Ct(r),!1)}return s}function Ca(s){let e=s.startState,t=e.facet(bo),i=s;for(let n=t.length-1;n>=0;n--){let r=t[n](s);r&&Object.keys(r).length&&(i=wo(i,Hn(e,r,s.changes.newLength),!0))}return i==s?s:Z.create(e,s.changes,s.selection,i.effects,i.annotations,i.scrollIntoView)}const Aa=[];function Ct(s){return s==null?Aa:Array.isArray(s)?s:[s]}var Ke=function(s){return s[s.Word=0]="Word",s[s.Space=1]="Space",s[s.Other=2]="Other",s}(Ke||(Ke={}));const Ma=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Fn;try{Fn=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function Da(s){if(Fn)return Fn.test(s);for(let e=0;e<s.length;e++){let t=s[e];if(/\w/.test(t)||t>"€"&&(t.toUpperCase()!=t.toLowerCase()||Ma.test(t)))return!0}return!1}function Ta(s){return e=>{if(!/\S/.test(e))return Ke.Space;if(Da(e))return Ke.Word;for(let t=0;t<s.length;t++)if(e.indexOf(s[t])>-1)return Ke.Word;return Ke.Other}}class N{constructor(e,t,i,n,r,o){this.config=e,this.doc=t,this.selection=i,this.values=n,this.status=e.statusTemplate.slice(),this.computeSlot=r,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)$t(this,l<<1);this.computeSlot=null}field(e,t=!0){let i=this.config.address[e.id];if(i==null){if(t)throw new RangeError("Field is not present in this state");return}return $t(this,i),Ri(this,i)}update(...e){return ko(this,e,!0)}applyTransaction(e){let t=this.config,{base:i,compartments:n}=t;for(let l of e.effects)l.is(Yi.reconfigure)?(t&&(n=new Map,t.compartments.forEach((a,h)=>n.set(h,a)),t=null),n.set(l.value.compartment,l.value.extension)):l.is(G.reconfigure)?(t=null,i=l.value):l.is(G.appendConfig)&&(t=null,i=Ct(i).concat(l.value));let r;t?r=e.startState.values.slice():(t=Ei.resolve(i,n,this),r=new N(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,h)=>h.reconfigure(a,this),null).values);let o=e.startState.facet(Wn)?e.newSelection:e.newSelection.asSingle();new N(t,e.newDoc,o,r,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:b.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),n=this.changes(i.changes),r=[i.range],o=Ct(i.effects);for(let l=1;l<t.ranges.length;l++){let a=e(t.ranges[l]),h=this.changes(a.changes),c=h.map(n);for(let u=0;u<l;u++)r[u]=r[u].map(c);let f=n.mapDesc(h,!0);r.push(a.range.map(f)),n=n.compose(c),o=G.mapEffects(o,c).concat(G.mapEffects(Ct(a.effects),f))}return{changes:n,selection:b.create(r,t.mainIndex),effects:o}}changes(e=[]){return e instanceof Q?e:Q.of(e,this.doc.length,this.facet(N.lineSeparator))}toText(e){return I.of(e.split(this.facet(N.lineSeparator)||En))}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:($t(this,t),Ri(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let n=e[i];n instanceof ze&&this.config.address[n.id]!=null&&(t[i]=n.spec.toJSON(this.field(e[i]),this))}return t}static fromJSON(e,t={},i){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let n=[];if(i){for(let r in i)if(Object.prototype.hasOwnProperty.call(e,r)){let o=i[r],l=e[r];n.push(o.init(a=>o.spec.fromJSON(l,a)))}}return N.create({doc:e.doc,selection:b.fromJSON(e.selection),extensions:t.extensions?n.concat([t.extensions]):n})}static create(e={}){let t=Ei.resolve(e.extensions||[],new Map),i=e.doc instanceof I?e.doc:I.of((e.doc||"").split(t.staticFacet(N.lineSeparator)||En)),n=e.selection?e.selection instanceof b?e.selection:b.single(e.selection.anchor,e.selection.head):b.single(0);return co(n,i.length),t.staticFacet(Wn)||(n=n.asSingle()),new N(t,i,n,t.dynamicSlots.map(()=>null),(r,o)=>o.create(r),null)}get tabSize(){return this.facet(N.tabSize)}get lineBreak(){return this.facet(N.lineSeparator)||`
@@ -19,4 +19,4 @@ import{aR as E,aS as W,aT as sa,aU as ra,aV as io,aW as js,aX as oa,aY as la,aZ
19
19
  `)}function ju(s,e,t,i){return s.map(n=>n.kind!=="conflict"||n.id!==e?n:{...n,resolution:t,manualLines:t==="manual"?i??n.manualLines??[]:void 0})}const Vs=G.define(),ys=ze.define({create:()=>({segments:[],labels:{paneLocal:"",paneRemote:"",paneBase:"",acceptLocal:"",acceptRemote:"",acceptBoth:"",acceptManual:""},onResolve:()=>{}}),update(s,e){for(const t of e.effects)if(t.is(Vs))return t.value;return s}});class Ku extends ni{constructor(e,t,i){super(),this.conflict=e,this.labels=t,this.onResolve=i}eq(e){return e.conflict.id===this.conflict.id&&e.conflict.resolution===this.conflict.resolution}get block(){return!0}get estimatedHeight(){return 88+Math.max(this.conflict.baseLines.length,this.conflict.localLines.length,this.conflict.remoteLines.length,1)*20}toDOM(e){const t=document.createElement("div");t.className="mdocs-merge-inline-conflict";const i=document.createElement("div");i.className="mdocs-merge-inline-chunks";const n=document.createElement("div");n.className="mdocs-merge-chunk mdocs-merge-chunk-base",n.innerHTML=`<div class="mdocs-merge-chunk-label">${this.labels.paneBase}</div><pre class="mdocs-merge-chunk-body">${On(this.conflict.baseLines.join(`
20
20
  `)||" ")}</pre>`;const r=document.createElement("div");r.className="mdocs-merge-chunk mdocs-merge-chunk-local",r.innerHTML=`<div class="mdocs-merge-chunk-label">${this.labels.paneLocal}</div><pre class="mdocs-merge-chunk-body">${On(this.conflict.localLines.join(`
21
21
  `)||" ")}</pre>`;const o=document.createElement("div");o.className="mdocs-merge-chunk mdocs-merge-chunk-remote",o.innerHTML=`<div class="mdocs-merge-chunk-label">${this.labels.paneRemote}</div><pre class="mdocs-merge-chunk-body">${On(this.conflict.remoteLines.join(`
22
- `)||" ")}</pre>`,i.append(n,r,o);const l=document.createElement("div");l.className="mdocs-merge-inline-actions";const a=(h,c,f,u)=>{const d=document.createElement("button");return d.type="button",d.textContent=h,f&&(d.className="active"),d.addEventListener("mousedown",g=>g.preventDefault()),d.addEventListener("click",g=>{g.preventDefault(),g.stopPropagation(),this.onResolve(this.conflict.id,c,u)}),d};return l.append(a(this.labels.acceptLocal,"local",this.conflict.resolution==="local"),a(this.labels.acceptRemote,"remote",this.conflict.resolution==="remote"),a(this.labels.acceptBoth,"both",this.conflict.resolution==="both"),a(this.labels.acceptManual,"manual",this.conflict.resolution==="manual",[...this.conflict.localLines,...this.conflict.remoteLines])),t.append(i,l),e&&queueMicrotask(()=>e.requestMeasure()),t}ignoreEvent(){return!1}}function On(s){return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function eo(s,e){const t=[],i=s.segments.filter(n=>n.kind==="conflict");for(let n=1;n<=e.lines;n+=1){const r=e.line(n),o=ia(r.text);if(!o)continue;const l=i.find(a=>a.id===o);!l||l.resolution!=="unresolved"||t.push(te.replace({widget:new Ku(l,s.labels,s.onResolve),block:!0}).range(r.from,r.to))}return te.set(t,!0)}const qu=ze.define({create(s){return eo(s.field(ys),s.doc)},update(s,e){return e.docChanged||e.effects.some(t=>t.is(Vs))?eo(e.state.field(ys),e.state.doc):s.map(e.changes)},provide:s=>D.decorations.from(s)}),$u=D.theme({"&":{height:"100%"},".cm-scroller":{fontFamily:"ui-monospace, monospace",fontSize:"13px"},".cm-line":{lineHeight:"1.5",padding:"0 2px"},".cm-gutterElement":{lineHeight:"1.5"},".cm-activeLine":{backgroundColor:"transparent"},".cm-line:has(.mdocs-merge-inline-conflict)":{padding:0,lineHeight:"normal"}});function to(s,e,t){const i=[Vs.of(e)];if(t!==void 0){const n=s.state.doc.toString();if(n!==t){s.dispatch({changes:{from:0,to:n.length,insert:t},effects:i});return}}s.dispatch({effects:i})}function Uu(s){const{t:e}=io(),t=E.useRef(null),i=E.useRef(null),n=E.useRef(s.onResolve);n.current=s.onResolve;const r={paneLocal:e("mergeLocal"),paneRemote:e("mergeRemote"),paneBase:e("mergeBase"),acceptLocal:e("mergeAcceptLocal"),acceptRemote:e("mergeAcceptRemote"),acceptBoth:e("mergeAcceptBoth"),acceptManual:e("mergeAcceptManual")},o=na(s.segments);return E.useEffect(()=>{const l=t.current;if(!l)return;const a={segments:s.segments,labels:r,onResolve:(c,f,u)=>n.current(c,f,u)},h=new D({parent:l,state:N.create({doc:o,extensions:[bl(),Af(),$u,ys,ml.of([...Bu,...If]),qu,D.updateListener.of(c=>{var f;c.docChanged&&((f=s.onDocumentEdited)==null||f.call(s))})]})});return i.current=h,s.getTextRef&&(s.getTextRef.current=()=>h.state.doc.toString()),to(h,a),()=>{s.getTextRef&&(s.getTextRef.current=null),h.destroy(),i.current=null}},[]),E.useEffect(()=>{const l=i.current;if(!l)return;const a={segments:s.segments,labels:r,onResolve:(h,c,f)=>n.current(h,c,f)};to(l,a,o)},[o,s.segments,r]),W.jsx("div",{ref:t,className:"mdocs-merge-cm-host mdocs-merge-result-cm"})}function Yu(s){const{t:e}=io(),[t,i]=E.useState(""),[n,r]=E.useState(""),[o,l]=E.useState(null),[a,h]=E.useState(!1),[c,f]=E.useState(!1),[u,d]=E.useState(null),[g,p]=E.useState(""),[m,y]=E.useState(null),[x,C]=E.useState(!1),[B,A]=E.useState(!1),[k,S]=E.useState(!0),H=E.useRef(null);E.useEffect(()=>{let K=!1;return S(!0),d(null),p(""),y(null),C(!1),(async()=>{try{const ye=await js(s.documentId);if(K)return;d(ye.content)}catch{K||s.onError(e("mergeLoadRemoteFailed")),K||S(!1)}})(),()=>{K=!0}},[s.documentId,s.onError,e]),E.useEffect(()=>{let K=!1;return l(null),r(""),h(!1),f(!1),(async()=>{try{const ye=await oa(s.documentId,s.conflict.localBaseCommitId,s.conflict.remoteCommitId);if(K)return;if(ye.mode==="three_way"&&ye.mergeBaseContent){l(ye.mergeBaseContent);return}h(!0),f(!0)}catch{if(K)return;h(!0),f(!0)}})(),()=>{K=!0}},[s.documentId,s.conflict.localBaseCommitId,s.conflict.remoteCommitId]);const F=E.useCallback(K=>{p(K),S(!1)},[]),$=E.useCallback(K=>{i(K)},[]),L=E.useCallback(K=>{r(K),f(!0)},[]),T=E.useCallback(()=>{h(!0),r(""),f(!0)},[]);E.useEffect(()=>{!t||!g||k||!c||(y(Pu(t,n,g)),C(!1))},[t,g,n,c,k,s.conflict.remoteCommitId]);const j=E.useMemo(()=>m?na(m):"",[m]),V=m?Hu(m):0,U=m?Fu(m):0;function Be(K,ye,ie){y(ee=>ee&&ju(ee,K,ye,ie)),C(!1)}async function rt(){if(U>0){s.onError(e("mergeConflictsUnresolved",{count:String(U)}));return}const K=x&&H.current?H.current():j,ye=zu(K);A(!0);try{const{content:ie}=await la({content:ye,from:"markdown",to:"lexical"});await aa(s.documentId,{content:ie,displayName:s.displayName,version:{localBaseCommitId:s.conflict.localBaseCommitId,merge:{remoteCommitId:s.conflict.remoteCommitId,localSnapshotContent:s.conflict.localSnapshotContent}}});const ee=await js(s.documentId);s.onSuccess(ee)}catch(ie){s.onError(ie instanceof Error?ie.message:String(ie))}finally{A(!1)}}const Ge=!!(t&&g&&m&&!k&&c);return W.jsxs("div",{className:"mdocs-merge-overlay",children:[W.jsx(hn,{lexicalJson:s.conflict.localSnapshotContent,onMarkdown:$,onError:()=>s.onError(e("mergeLoadLocalFailed"))}),o?W.jsx(hn,{lexicalJson:o,onMarkdown:L,onError:T}):null,u?W.jsx(hn,{lexicalJson:u,onMarkdown:F,onError:()=>{S(!1),s.onError(e("mergeLoadRemoteFailed"))}}):null,W.jsxs("header",{className:"mdocs-merge-toolbar",children:[W.jsxs("div",{className:"mdocs-merge-toolbar-title",children:[W.jsx("h2",{children:e("mergeTitle")}),Ge&&V>0?W.jsx("span",{className:`mdocs-merge-conflict-pill ${U>0?"pending":"resolved"}`,children:U>0?e("mergeConflictsPending",{unresolved:String(U),total:String(V)}):e("mergeConflictsResolved",{total:String(V)})}):null,a?W.jsx("span",{className:"mdocs-merge-base-warning",children:e("mergeBaseMissing")}):null]}),W.jsxs("div",{className:"mdocs-merge-toolbar-actions",children:[W.jsx("button",{type:"button",className:"secondary",disabled:B,onClick:s.onClose,children:e("cancel")}),W.jsx("button",{type:"button",className:"primary",disabled:B||!Ge||U>0,onClick:()=>void rt(),children:e(B?"publishing":"mergeComplete")})]})]}),W.jsxs("div",{className:"mdocs-merge-body",children:[W.jsxs("aside",{className:"mdocs-merge-side",children:[W.jsx("header",{className:"mdocs-merge-pane-header mdocs-merge-pane-header-static",children:e("mergeLocal")}),W.jsx(Rr,{doc:t,readOnly:!0,className:"mdocs-merge-cm-side"})]}),W.jsx("main",{className:"mdocs-merge-center",children:Ge?W.jsxs(W.Fragment,{children:[W.jsxs("header",{className:"mdocs-merge-result-header",children:[W.jsx("h3",{children:e("mergeResult")}),W.jsx("span",{className:"mdocs-merge-result-hint",children:e("mergeResultInlineHint")})]}),W.jsx(Uu,{segments:m,onResolve:Be,getTextRef:H,onDocumentEdited:()=>C(!0)})]}):W.jsx("p",{className:"mdocs-merge-loading",children:e("mergeLoadingRemote")})}),W.jsxs("aside",{className:"mdocs-merge-side",children:[W.jsx("header",{className:"mdocs-merge-pane-header mdocs-merge-pane-header-static",children:e(k?"mergeLoadingRemote":"mergeRemote")}),W.jsx(Rr,{doc:g,readOnly:!0,className:"mdocs-merge-cm-side"})]})]})]})}export{Yu as MergeView};
22
+ `)||" ")}</pre>`,i.append(n,r,o);const l=document.createElement("div");l.className="mdocs-merge-inline-actions";const a=(h,c,f,u)=>{const d=document.createElement("button");return d.type="button",d.textContent=h,f&&(d.className="active"),d.addEventListener("mousedown",g=>g.preventDefault()),d.addEventListener("click",g=>{g.preventDefault(),g.stopPropagation(),this.onResolve(this.conflict.id,c,u)}),d};return l.append(a(this.labels.acceptLocal,"local",this.conflict.resolution==="local"),a(this.labels.acceptRemote,"remote",this.conflict.resolution==="remote"),a(this.labels.acceptBoth,"both",this.conflict.resolution==="both"),a(this.labels.acceptManual,"manual",this.conflict.resolution==="manual",[...this.conflict.localLines,...this.conflict.remoteLines])),t.append(i,l),e&&queueMicrotask(()=>e.requestMeasure()),t}ignoreEvent(){return!1}}function On(s){return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function eo(s,e){const t=[],i=s.segments.filter(n=>n.kind==="conflict");for(let n=1;n<=e.lines;n+=1){const r=e.line(n),o=ia(r.text);if(!o)continue;const l=i.find(a=>a.id===o);!l||l.resolution!=="unresolved"||t.push(te.replace({widget:new Ku(l,s.labels,s.onResolve),block:!0}).range(r.from,r.to))}return te.set(t,!0)}const qu=ze.define({create(s){return eo(s.field(ys),s.doc)},update(s,e){return e.docChanged||e.effects.some(t=>t.is(Vs))?eo(e.state.field(ys),e.state.doc):s.map(e.changes)},provide:s=>D.decorations.from(s)}),$u=D.theme({"&":{height:"100%"},".cm-scroller":{fontFamily:"ui-monospace, monospace",fontSize:"13px"},".cm-line":{lineHeight:"1.5",padding:"0 2px"},".cm-gutterElement":{lineHeight:"1.5"},".cm-activeLine":{backgroundColor:"transparent"},".cm-line:has(.mdocs-merge-inline-conflict)":{padding:0,lineHeight:"normal"}});function to(s,e,t){const i=[Vs.of(e)];if(t!==void 0){const n=s.state.doc.toString();if(n!==t){s.dispatch({changes:{from:0,to:n.length,insert:t},effects:i});return}}s.dispatch({effects:i})}function Uu(s){const{t:e}=io(),t=E.useRef(null),i=E.useRef(null),n=E.useRef(s.onResolve);n.current=s.onResolve;const r={paneLocal:e("mergeLocal"),paneRemote:e("mergeRemote"),paneBase:e("mergeBase"),acceptLocal:e("mergeAcceptLocal"),acceptRemote:e("mergeAcceptRemote"),acceptBoth:e("mergeAcceptBoth"),acceptManual:e("mergeAcceptManual")},o=na(s.segments);return E.useEffect(()=>{const l=t.current;if(!l)return;const a={segments:s.segments,labels:r,onResolve:(c,f,u)=>n.current(c,f,u)},h=new D({parent:l,state:N.create({doc:o,extensions:[bl(),Af(),$u,ys,ml.of([...Bu,...If]),qu,D.updateListener.of(c=>{var f;c.docChanged&&((f=s.onDocumentEdited)==null||f.call(s))})]})});return i.current=h,s.getTextRef&&(s.getTextRef.current=()=>h.state.doc.toString()),to(h,a),()=>{s.getTextRef&&(s.getTextRef.current=null),h.destroy(),i.current=null}},[]),E.useEffect(()=>{const l=i.current;if(!l)return;const a={segments:s.segments,labels:r,onResolve:(h,c,f)=>n.current(h,c,f)};to(l,a,o)},[o,s.segments,r]),W.jsx("div",{ref:t,className:"mdocs-merge-cm-host mdocs-merge-result-cm"})}function sd(s){const{t:e}=io(),[t,i]=E.useState(""),[n,r]=E.useState(""),[o,l]=E.useState(null),[a,h]=E.useState(!1),[c,f]=E.useState(!1),[u,d]=E.useState(null),[g,p]=E.useState(""),[m,y]=E.useState(null),[x,C]=E.useState(!1),[B,A]=E.useState(!1),[k,S]=E.useState(!0),H=E.useRef(null);E.useEffect(()=>{let K=!1;return S(!0),d(null),p(""),y(null),C(!1),(async()=>{try{const ye=await js(s.documentId);if(K)return;d(ye.content)}catch{K||s.onError(e("mergeLoadRemoteFailed")),K||S(!1)}})(),()=>{K=!0}},[s.documentId,s.onError,e]),E.useEffect(()=>{let K=!1;return l(null),r(""),h(!1),f(!1),(async()=>{try{const ye=await sa(s.documentId,s.conflict.localBaseCommitId,s.conflict.remoteCommitId);if(K)return;if(ye.mode==="three_way"&&ye.mergeBaseContent){l(ye.mergeBaseContent);return}h(!0),f(!0)}catch{if(K)return;h(!0),f(!0)}})(),()=>{K=!0}},[s.documentId,s.conflict.localBaseCommitId,s.conflict.remoteCommitId]);const F=E.useCallback(K=>{p(K),S(!1)},[]),$=E.useCallback(K=>{i(K)},[]),L=E.useCallback(K=>{r(K),f(!0)},[]),T=E.useCallback(()=>{h(!0),r(""),f(!0)},[]);E.useEffect(()=>{!t||!g||k||!c||(y(Pu(t,n,g)),C(!1))},[t,g,n,c,k,s.conflict.remoteCommitId]);const j=E.useMemo(()=>m?na(m):"",[m]),V=m?Hu(m):0,U=m?Fu(m):0;function Be(K,ye,ie){y(ee=>ee&&ju(ee,K,ye,ie)),C(!1)}async function rt(){if(U>0){s.onError(e("mergeConflictsUnresolved",{count:String(U)}));return}const K=x&&H.current?H.current():j,ye=zu(K);A(!0);try{const{content:ie}=await ra({content:ye,from:"markdown",to:"lexical"});await oa(s.documentId,{content:ie,displayName:s.displayName,version:{localBaseCommitId:s.conflict.localBaseCommitId,merge:{remoteCommitId:s.conflict.remoteCommitId,localSnapshotContent:s.conflict.localSnapshotContent}}});const ee=await js(s.documentId);s.onSuccess(ee)}catch(ie){s.onError(ie instanceof Error?ie.message:String(ie))}finally{A(!1)}}const Ge=!!(t&&g&&m&&!k&&c);return W.jsxs("div",{className:"mdocs-merge-overlay",children:[W.jsx(hn,{lexicalJson:s.conflict.localSnapshotContent,onMarkdown:$,onError:()=>s.onError(e("mergeLoadLocalFailed"))}),o?W.jsx(hn,{lexicalJson:o,onMarkdown:L,onError:T}):null,u?W.jsx(hn,{lexicalJson:u,onMarkdown:F,onError:()=>{S(!1),s.onError(e("mergeLoadRemoteFailed"))}}):null,W.jsxs("header",{className:"mdocs-merge-toolbar",children:[W.jsxs("div",{className:"mdocs-merge-toolbar-title",children:[W.jsx("h2",{children:e("mergeTitle")}),Ge&&V>0?W.jsx("span",{className:`mdocs-merge-conflict-pill ${U>0?"pending":"resolved"}`,children:U>0?e("mergeConflictsPending",{unresolved:String(U),total:String(V)}):e("mergeConflictsResolved",{total:String(V)})}):null,a?W.jsx("span",{className:"mdocs-merge-base-warning",children:e("mergeBaseMissing")}):null]}),W.jsxs("div",{className:"mdocs-merge-toolbar-actions",children:[W.jsx("button",{type:"button",className:"secondary",disabled:B,onClick:s.onClose,children:e("cancel")}),W.jsx("button",{type:"button",className:"primary",disabled:B||!Ge||U>0,onClick:()=>void rt(),children:e(B?"publishing":"mergeComplete")})]})]}),W.jsxs("div",{className:"mdocs-merge-body",children:[W.jsxs("aside",{className:"mdocs-merge-side",children:[W.jsx("header",{className:"mdocs-merge-pane-header mdocs-merge-pane-header-static",children:e("mergeLocal")}),W.jsx(Rr,{doc:t,readOnly:!0,className:"mdocs-merge-cm-side"})]}),W.jsx("main",{className:"mdocs-merge-center",children:Ge?W.jsxs(W.Fragment,{children:[W.jsxs("header",{className:"mdocs-merge-result-header",children:[W.jsx("h3",{children:e("mergeResult")}),W.jsx("span",{className:"mdocs-merge-result-hint",children:e("mergeResultInlineHint")})]}),W.jsx(Uu,{segments:m,onResolve:Be,getTextRef:H,onDocumentEdited:()=>C(!0)})]}):W.jsx("p",{className:"mdocs-merge-loading",children:e("mergeLoadingRemote")})}),W.jsxs("aside",{className:"mdocs-merge-side",children:[W.jsx("header",{className:"mdocs-merge-pane-header mdocs-merge-pane-header-static",children:e(k?"mergeLoadingRemote":"mergeRemote")}),W.jsx(Rr,{doc:g,readOnly:!0,className:"mdocs-merge-cm-side"})]})]})]})}export{sd as MergeView};
@@ -0,0 +1,8 @@
1
+ import{r as n,j as o,ae as C}from"./react-vendor-BNpqFP9B.js";import{u as N,E as T,R as I,a as E,b as M,c as j,d as O,e as P,f as A,g as _,h as D,i as H,w as g,j as L,k as F,l as q,I as U,m as b,n as V,o as J,p as W,q as z,r as B,s as $,t as K,v as Y,x as G,y as Z}from"./react-B7vrA7AR.js";import{m as Q,n as X,H as ee,o as te,A as k,p as oe}from"./ui-DxdLi_28.js";import{H as re,a as ae,b as ne,M as le,T as ie,S as se,W as de,N as ce,c as R,o as me}from"./Toolbar-DjPuWk5G.js";import"./editor-ONzd_YnO.js";import"./diagram-gfUK8OHx.js";import"./index-C46BU1-j.js";import"./motion-C4pN8CfU.js";import"./plus-CnKbiP8x.js";import"./copy-hWOco_4c.js";const ue=({children:h,json:r,markdown:a,collapsible:m=!1,defaultActiveKey:y=["editor","text","json"],onJSONChange:p})=>{const[f,c]=n.useState(r),s=n.useRef(r);n.useEffect(()=>{r!==s.current&&(c(r),s.current=r)},[r]);const x=n.useCallback(d=>{s.current=d,c(d)},[]);return o.jsxs(o.Fragment,{children:[o.jsx(Q,{}),o.jsx(X,{collapsible:m,defaultActiveKey:y,items:[{children:h,key:"editor",label:"Playground"},{children:o.jsx(ee,{language:"markdown",style:{fontSize:12,padding:16},variant:"borderless",children:a}),key:"text",label:"Text Output"},{children:o.jsx(te,{language:"json",onBlur:()=>{if(r!==s.current)try{const d=JSON.parse(s.current||"");p==null||p(d)}catch(d){console.error("Invalid JSON:",d)}},onValueChange:x,value:f,variant:"borderless"}),key:"json",label:"JSON Output"}],padding:{body:0},style:{border:"none",borderRadius:0,width:"100%"},variant:"outlined"})]})},he={children:[{children:[{detail:0,format:0,mode:"normal",style:"",text:"Welcome to the Lobe Editor Demo!",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"heading",version:1,tag:"h1"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"In case you were wondering what the black box at the bottom is – it's the debug view, showing the current state of the editor. You can disable it by pressing on the settings control in the bottom-left of your screen and toggling the debug view setting.",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"quote",version:1},{children:[{detail:0,format:0,mode:"normal",style:"",text:"The playground is a demo environment built with ",type:"text",version:1},{children:[{detail:0,format:0,mode:"normal",style:"",text:"\uFEFF",type:"cursor",version:1},{detail:0,format:0,mode:"normal",style:"",text:"\uFEFF",type:"cursor",version:1},{detail:0,format:0,mode:"normal",style:"",text:"\uFEFF",type:"cursor",version:1},{detail:0,format:0,mode:"normal",style:"",text:"@lobehub/editor",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"codeInline",version:1},{detail:0,format:0,mode:"normal",style:"",text:"\uFEFF",type:"cursor",version:1},{detail:0,format:0,mode:"normal",style:"",text:". Try typing in ",type:"text",version:1},{detail:0,format:1,mode:"normal",style:"",text:"some text",type:"text",version:1},{detail:0,format:0,mode:"normal",style:"",text:" with ",type:"text",version:1},{detail:0,format:2,mode:"normal",style:"",text:"different formats",type:"text",version:1},{detail:0,format:0,mode:"normal",style:"",text:".",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"paragraph",version:1,textFormat:0,textStyle:""},{children:[{children:[{detail:0,format:0,mode:"normal",style:"",text:"Visit the ",type:"text",version:1},{children:[{detail:0,format:0,mode:"normal",style:"",text:"Lobe Editor website",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"link",version:1,rel:"noreferrer",target:null,title:null,url:"https://editor.lobehub.com"},{detail:0,format:0,mode:"normal",style:"",text:" for documentation and more information.",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"listitem",version:1,value:1},{children:[{detail:0,format:0,mode:"normal",style:"",text:"Check out the code on our ",type:"text",version:1},{children:[{detail:0,format:0,mode:"normal",style:"",text:"GitHub repository",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"link",version:1,rel:null,target:null,title:"https://github.com/lobehub/lobe-editor",url:"https://github.com/lobehub/lobe-editor"},{detail:0,format:0,mode:"normal",style:"",text:".",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"listitem",version:1,value:2},{children:[{detail:0,format:0,mode:"normal",style:"",text:"Playground code ",type:"text",version:1},{children:[{detail:0,format:0,mode:"normal",style:"",text:"Playground code",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"link",version:1,rel:"noreferrer",target:null,title:null,url:"https://github.com/lobehub/lobe-editor/blob/master/src/react/Editor/demos/index.tsx"},{detail:0,format:0,mode:"normal",style:"",text:" can be found here.",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"listitem",version:1,value:3},{children:[{detail:0,format:0,mode:"normal",style:"",text:"Join our ",type:"text",version:1},{children:[{detail:0,format:0,mode:"normal",style:"",text:"Discover Server",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"link",version:1,rel:null,target:null,title:"https://discord.gg/AYFPHvv2jT",url:"https://discord.gg/AYFPHvv2jT"},{detail:0,format:0,mode:"normal",style:"",text:" and chat with the team.",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"listitem",version:1,value:4}],direction:"ltr",format:"",indent:0,type:"list",version:1,listType:"bullet",start:1,tag:"ul"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"Lastly, we're constantly adding cool new features to this playground. So make sure you check back here when you next get a chance 🙂.",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"paragraph",version:1,textFormat:0,textStyle:""},{children:[{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-info);",text:"import",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-text);",text:" ",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-info);",text:"{",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-error);",text:" ",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-text);",text:"Editor",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-error);",text:" ",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-info);",text:"}",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-text);",text:" ",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-info);",text:"from",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-text);",text:" ",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-info);",text:"'",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-success);",text:"@lobehub/editor",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-info);",text:"'",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-info);",text:";",type:"code-highlight",version:1}],direction:null,format:"",indent:0,type:"code",version:1,language:"typescript",theme:"lobe-theme"},{children:[],direction:null,format:"",indent:0,type:"paragraph",version:1,textFormat:0,textStyle:""}],direction:"ltr",format:"",indent:0,type:"root",version:1},ye={root:he};function S(h,r){let a;const m=(...y)=>{a!==void 0&&clearTimeout(a),a=setTimeout(()=>h(...y),r)};return m.cancel=()=>{a!==void 0&&(clearTimeout(a),a=void 0)},m}window.__scrollIntoView=Z;const pe=h=>{const r=N(),a=n.useRef([]),[m,y]=n.useState(""),[p,f]=n.useState(""),c=n.useMemo(()=>S(t=>{const e=t.getDocument("markdown"),l=t.getDocument("json");f(e||""),y(JSON.stringify(l||{},null,2))},200),[]),s=n.useMemo(()=>S(t=>{r&&(console.info("handleJSONChange",t),r.setDocument("json",t))},200),[r]),x=t=>{window.editor=t,c(t)};n.useEffect(()=>()=>{for(const t of a.current)URL.revokeObjectURL(t);a.current=[],c.cancel(),s.cancel(),delete window.editor,delete window.__scrollIntoView},[c,s]);const d=n.useMemo(()=>[{icon:o.jsx(k,{avatar:"💻",size:24}),key:"bot1",label:"前端研发专家",metadata:{id:"bot1"}},{icon:o.jsx(k,{avatar:"🌍",size:24}),key:"bot2",label:"中英文互译助手",metadata:{id:"bot2"}},{icon:o.jsx(k,{avatar:"📖",size:24}),key:"bot3",label:"学术写作增强专家",metadata:{id:"bot3"}}],[]),w=n.useMemo(()=>[{icon:re,key:"h1",label:"Heading 1",onSelect:e=>{e.dispatchCommand(b,{tag:"h1"})}},{icon:ae,key:"h2",label:"Heading 2",onSelect:e=>{e.dispatchCommand(b,{tag:"h2"})}},{icon:ne,key:"h3",label:"Heading 3",onSelect:e=>{e.dispatchCommand(b,{tag:"h3"})}},{type:"divider"},{icon:le,key:"hr",label:"Hr",onSelect:e=>{e.dispatchCommand(V,{})}},{icon:ie,key:"table",label:"Table",onSelect:e=>{e.dispatchCommand(J,{columns:"3",rows:"3"})}},{icon:se,key:"tex",label:"Tex",onSelect:e=>{e.dispatchCommand(W,{code:"x^2 + y^2 = z^2"}),queueMicrotask(()=>{e.focus()})}},{type:"divider"},{key:"file",label:"File",onSelect:e=>{me(l=>{for(const u of l)e.dispatchCommand(z,{file:u})})}},{key:"set-text-content",label:"SetTextContent",onSelect:e=>{e.setDocument("text",`123
2
+ 123`),queueMicrotask(()=>{e.focus()})}},{key:"insert-link",label:"InsertLink",onSelect:e=>{e.dispatchCommand(B,{url:"https://example.com"}),queueMicrotask(()=>{e.focus()})}},{key:"insert-codeInline",label:"InsertCodeInline",onSelect:e=>{e.dispatchCommand($,void 0),queueMicrotask(()=>{e.focus()})}},{key:"insert-codeBlock",label:"InsertCodeBlock",onSelect:e=>{e.dispatchCommand(K,void 0),queueMicrotask(()=>{e.focus()})}},{icon:de,key:"meta2d",label:"Meta2d",onSelect:e=>{e.dispatchCommand(Y,void 0),queueMicrotask(()=>{e.focus()})}},{icon:ce,key:"markmap",label:"Markmap",onSelect:e=>{e.dispatchCommand(G,void 0),queueMicrotask(()=>{e.focus()})}}].map(e=>e.type==="divider"?e:{...e,extra:o.jsx(oe,{code:!0,fontSize:12,type:"secondary",children:e.key})}),[]);return o.jsxs(ue,{json:m,markdown:p,onJSONChange:s,...h,children:[o.jsx(R,{editor:r}),o.jsx(T,{className:"mdocs-playground-editor",content:ye,editor:r,lineEmptyPlaceholder:"Start typing here...",mentionOption:{items:d,markdownWriter:t=>{var e;return`
3
+ <mention>${t.label}[${((e=t.metadata)==null?void 0:e.id)||t.label}]</mention>
4
+ `},onSelect:(t,e)=>{t.dispatchCommand(U,{label:String(e.label),metadata:{id:e.key}})},searchKeys:["label"]},onInit:x,onTextChange:c,pasteVSCodeAsCodeBlock:!0,placeholder:"Type something...",plugins:[I,E,M,j,O,P,A,_,D,H,g(L,{children:o.jsx(R,{editor:r,floating:!0})}),g(F,{delay:1e3,onAutoComplete:async({input:t,afterText:e,selectionType:l,abortSignal:u})=>{console.log("Auto-complete triggered:",{afterText:e,input:t,selectionType:l});try{const v=await fetch(`${location.origin}/nodeserver/completion`,{body:JSON.stringify({prompt:`Please complete the following text:
5
+
6
+ ${t}`}),headers:{"Content-Type":"application/json"},method:"POST",signal:u});if(u.aborted)return console.log("Auto-complete aborted"),null;const i=await v.json();if(i)return typeof i.content=="string"&&i.content.startsWith(t)?i.content.replace(t,""):i.content}catch{}return null}}),g(M,{defaultBlockImage:!0,handleRehost:async t=>{const l=await(await fetch(t)).blob();return await new Promise((u,v)=>{const i=new FileReader;i.onloadend=()=>u({url:i.result}),i.onerror=v,i.readAsDataURL(l)})},needRehost:t=>(console.debug("needRehost",t),t.startsWith("blob:"))}),g(q,{handleUpload:async t=>(console.debug("Files uploaded:",t),new Promise(e=>{setTimeout(()=>{const l=URL.createObjectURL(t);a.current.push(l),e({url:l})},1e3)})),markdownWriter:t=>`
7
+ <file>${t.fileUrl}</file>
8
+ `})],slashOption:{items:w}})]})};function Ce(){return o.jsxs("div",{className:"mdocs-playground-page",children:[o.jsx("header",{className:"mdocs-playground-header",children:o.jsx(C,{className:"mdocs-playground-back",to:"/",children:"← mdocs"})}),o.jsx(pe,{})]})}export{Ce as PlaygroundPage};
@@ -0,0 +1 @@
1
+ import{r as a,j as e}from"./react-vendor-BNpqFP9B.js";import{b as Z,q as $e,s as We,D as Ue,l as ie,t as _e,v as He,w as _,x as ce,y as qe,z as Ge,A as Ze,a as Je,d as je,B as be,C as ve,E as Qe,G as Xe,H as Ye,I as es,J as ss,K as ke,L as ne,N as ts,O as as,P as ns,Q as is,R as cs,f as ls,T as os,U as rs,V as ds,W as ms,X as us,i as hs,Y as ps,Z as gs,_ as fs,$ as xs,a0 as js,a1 as ys,a2 as Ns,a3 as bs,a4 as vs,r as ks,j as ws,a5 as Ss,n as Cs,o as Ds}from"./index-C46BU1-j.js";import{V as we,a as Is,M as Ts}from"./VisitorPickerModal-BUS-cOq0.js";import"./ui-DxdLi_28.js";import"./motion-C4pN8CfU.js";function As({draft:t,onClose:s,onSuccess:y}){const{t:u,lang:m}=Z(),[E,p]=a.useState([]),[k,N]=a.useState(t.domainId??""),[C,i]=a.useState([]),[v,g]=a.useState(""),[o,x]=a.useState(`${t.displayName||"untitled"}_recovered.md`),[h,V]=a.useState(!1),[I,z]=a.useState(null),D=a.useRef(null),M=a.useRef(!0);a.useEffect(()=>(M.current=!0,()=>{M.current=!1}),[]),a.useEffect(()=>{$e().then(f=>{M.current&&p(f)})},[]),a.useEffect(()=>{k&&(i([]),g(""),We(k).then(f=>{M.current&&i(f)}).catch(()=>{M.current&&i([])}))},[k]),a.useEffect(()=>{const f=window.setTimeout(()=>{var A;return(A=D.current)==null?void 0:A.focus()},0);return()=>window.clearTimeout(f)},[]),a.useEffect(()=>{const f=A=>{A.key==="Escape"&&s()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[s]);function F(f,A){for(const w of f){if(w.type==="folder"&&w.path===A)return w.documentId;if(w.type==="folder"){const S=F(w.children,A);if(S)return S}}return null}async function L(f){f.preventDefault(),V(!0),z(null);const A=o.replace(/\s+/g,"_").replace(/[^a-zA-Z0-9_\-.]/g,""),w=A.endsWith(".md")?A:A+".md",S=w.replace(/\.md$/i,"");try{const P=v?`${v}/${w}`:w,c=v?F(C,v)??void 0:void 0;await He({fileName:w,displayName:S,content:t.content,domainId:k,parentId:c}),y()}catch(P){z(_(u,P))}finally{V(!1)}}return e.jsx("div",{className:"mdocs-dialog-backdrop",role:"presentation",onMouseDown:f=>{f.target===f.currentTarget&&!h&&s()},children:e.jsxs("div",{className:"mdocs-dialog card mdocs-recovery-dialog",role:"dialog","aria-modal":"true",children:[e.jsx("h1",{children:u("recoverDraft")}),e.jsx("p",{className:"muted",children:u("recoverDraftDesc",{name:t.displayName||u("unknownTitle")})}),e.jsxs("form",{onSubmit:L,className:"mdocs-dialog-form",children:[e.jsxs("label",{className:"mdocs-dialog-label",children:[u("domainLabel"),E.length>0&&e.jsx(Ue,{domains:E,value:k,onChange:N,onDomainsChange:p,ariaLabel:u("domainLabel"),localizeName:f=>ie(f,m,u)})]}),e.jsxs("label",{className:"mdocs-dialog-label mdocs-recovery-tree-label",children:[u("recoverTargetFolder"),e.jsx("div",{className:"mdocs-recovery-tree",children:e.jsx(_e,{nodes:C,activeDocumentId:null,selectedParentPath:v,onOpen:()=>{},onOpenFolder:f=>g(f),onContextMenu:()=>{},onDeselect:()=>g("")})})]}),e.jsxs("label",{className:"mdocs-dialog-label",children:[u("fileNameLabel"),e.jsx("input",{ref:D,value:o,onChange:f=>x(f.target.value),placeholder:"recovered.md",maxLength:200,disabled:h})]}),I&&e.jsx("div",{className:"mdocs-dialog-error",children:I}),e.jsxs("div",{className:"mdocs-dialog-actions",children:[e.jsx("button",{type:"button",onClick:()=>!h&&s(),disabled:h,children:u("cancel")}),e.jsx("button",{type:"submit",className:"primary",disabled:h,children:u(h?"creating":"create")})]})]})]})})}function Ps({onPublish:t,onClose:s,onCountChange:y,onRecover:u}){const{t:m}=Z(),[E,p]=a.useState([]),[k,N]=a.useState(new Set),[C,i]=a.useState(!1),[v,g]=a.useState(null),[o,x]=a.useState(null),[h,V]=a.useState(null),I=a.useRef(null),z=a.useRef(!0);a.useEffect(()=>(z.current=!0,ce().then(c=>{if(!z.current)return;const d=c.filter(j=>!j.published);p(d),y==null||y(d.length)}),()=>{z.current=!1,I.current&&(clearTimeout(I.current),I.current=null)}),[]),a.useEffect(()=>{const c=d=>{d.key==="Escape"&&s()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[s]);const D=a.useCallback((c,d)=>{V({message:c,type:d}),I.current&&clearTimeout(I.current),I.current=setTimeout(()=>V(null),3e3)},[]);async function M(c){await Ge(c),N(d=>new Set(d).add(c));try{await t(c),p(d=>{const j=d.filter(R=>R.documentId!==c);return y==null||y(j.length),j}),D(m("published"),"success")}catch(d){d instanceof Ze||D(m("publishFailed"),"error");const j=await Je(c);j&&p(R=>R.map(O=>O.documentId===c?j:O))}finally{N(d=>{const j=new Set(d);return j.delete(c),j})}}async function F(c){g(null),await je(c),p(d=>{const j=d.filter(R=>R.documentId!==c);return y==null||y(j.length),j}),D(m("draftDeleted"),"success")}function L(c){const d=E.find(j=>j.documentId===c);d&&x(d)}function f(c){x(null),je(c),p(d=>{const j=d.filter(R=>R.documentId!==c);return y==null||y(j.length),j}),u==null||u(E.find(d=>d.documentId===c)),D(m("published"),"success")}async function A(){i(!0);let c=0,d=0;for(const O of E)try{await t(O.documentId),c++}catch{d++}const R=(await ce()).filter(O=>!O.published);p(R),y==null||y(R.length),d===0?D(m("publishAll"),"success"):D(`${c} published, ${d} failed`,"error"),i(!1)}const w=c=>new Date(c).toLocaleString(void 0,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),S=c=>qe(m,c,c.publishError??"UNKNOWN"),P=E;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mdocs-drawer-overlay",onClick:s}),e.jsxs("div",{className:"mdocs-drawer",role:"dialog","aria-modal":"true",children:[e.jsxs("header",{className:"mdocs-drawer-header",children:[e.jsxs("div",{className:"mdocs-drawer-header-text",children:[e.jsxs("h2",{className:"mdocs-drawer-title",children:[m("unpublishedDrafts"),P.length>0&&e.jsx("span",{className:"mdocs-drawer-count-badge",children:P.length})]}),e.jsx("span",{className:"mdocs-drawer-subtitle",children:m("draftCount",{count:String(P.length)})})]}),e.jsx("button",{type:"button",className:"mdocs-drawer-close-btn",onClick:s,"aria-label":m("close"),children:"×"})]}),e.jsx("div",{className:"mdocs-drawer-body",children:P.length===0?e.jsxs("div",{className:"mdocs-drawer-empty",children:[e.jsx("div",{className:"mdocs-drawer-empty-icon","aria-hidden":"true",children:"✓"}),e.jsx("p",{className:"mdocs-drawer-empty-text",children:m("draftsEmptyState")})]}):e.jsx("div",{className:"mdocs-drawer-items",children:P.map(c=>{const d=!!c.publishError;return e.jsxs("div",{className:d?"mdocs-drawer-item mdocs-drawer-item-failed":"mdocs-drawer-item",children:[e.jsx("div",{className:"mdocs-drawer-item-icon","aria-hidden":"true",children:"📄"}),e.jsxs("div",{className:"mdocs-drawer-item-info",children:[e.jsx("span",{className:"mdocs-drawer-item-name",children:c.displayName||m("unknownTitle")}),d?e.jsxs("span",{className:"mdocs-drawer-item-error",children:[w(c.publishErrorAt)," · ",S(c)]}):e.jsxs("span",{className:"mdocs-drawer-item-meta",children:[w(c.updatedAt)," · ",m("localSnapshot")]})]}),e.jsxs("div",{className:"mdocs-drawer-item-actions",children:[d?e.jsx("button",{type:"button",className:"mdocs-btn-ghost mdocs-btn-ghost-primary",disabled:C,onClick:()=>L(c.documentId),children:m("recoverDraft")}):e.jsx("button",{type:"button",className:"mdocs-btn-ghost mdocs-btn-ghost-primary",disabled:k.has(c.documentId)||C,onClick:()=>void M(c.documentId),children:k.has(c.documentId)?m("publishing"):m("publish")}),e.jsx("button",{type:"button",className:"mdocs-btn-ghost mdocs-btn-ghost-danger",disabled:C,onClick:()=>g(c.documentId),children:m("delete")})]})]},c.documentId)})})}),e.jsxs("footer",{className:"mdocs-drawer-footer",children:[e.jsx("button",{type:"button",onClick:s,children:m("close")}),e.jsx("button",{type:"button",className:"primary",disabled:P.length===0||C,onClick:()=>void A(),children:C?m("publishing"):`${m("publishAll")} (${P.length})`})]}),h&&e.jsx("div",{className:"mdocs-drawer-toast mdocs-drawer-toast--"+h.type,role:"status",children:h.message})]}),v&&e.jsx("div",{className:"mdocs-dialog-backdrop",role:"presentation",onMouseDown:c=>{c.target===c.currentTarget&&g(null)},children:e.jsxs("div",{className:"mdocs-dialog card",role:"dialog","aria-modal":"true",children:[e.jsx("h1",{children:m("delete")}),e.jsx("p",{className:"muted",children:m("confirmDeleteDraft")}),e.jsxs("div",{className:"mdocs-dialog-actions",children:[e.jsx("button",{type:"button",onClick:()=>g(null),children:m("cancel")}),e.jsx("button",{type:"button",className:"danger",onClick:()=>void F(v),children:m("delete")})]})]})}),o&&e.jsx(As,{draft:o,onClose:()=>x(null),onSuccess:()=>f(o.documentId)})]})}function Ms(){const{t,lang:s}=Z(),y=be(),u=a.useRef(!1),[m,E]=a.useState([]),[p,k]=a.useState(!1),[N,C]=a.useState(""),[i,v]=a.useState("restricted"),[g,o]=a.useState(!1),[x,h]=a.useState(null),[V,I]=a.useState(null),[z,D]=a.useState(""),[M,F]=a.useState(""),[L,f]=a.useState("all"),[A,w]=a.useState(null);a.useEffect(()=>(u.current=!0,()=>{u.current=!1}),[]);const S=a.useCallback(async()=>{k(!0),h(null);try{const r=await ve();if(!u.current)return;E(r)}catch(r){if(!u.current)return;h(_(t,r))}finally{u.current&&k(!1)}},[t]);a.useEffect(()=>{S()},[S]);async function P(r){if(r.preventDefault(),!N.trim()){h(t("domainNameRequired"));return}o(!0),h(null);try{if(await ss({domainName:N.trim(),permission:i}),!u.current)return;C(""),v("restricted"),await S()}catch(K){if(!u.current)return;h(_(t,K))}finally{u.current&&o(!1)}}async function c(r){if(z.trim()){h(null);try{if(await es(r,z.trim()),!u.current)return;I(null),w(null),await S()}catch(K){if(!u.current)return;h(_(t,K))}}}function d(r){I(r.domainId),D(r.domainName),w(null)}function j(){I(null),w(null)}async function R(r,K){h(null);try{if(await Ye(r,K),!u.current)return;w(null),await S()}catch($){if(!u.current)return;h(_(t,$))}}async function O(r){if(window.confirm(t("deleteDomainConfirmDetail",{name:r.domainName,count:String(r.docCount)}))){h(null);try{if(await Xe(r.domainId),!u.current)return;await S()}catch(K){if(!u.current)return;h(_(t,K))}}}const H=a.useCallback(r=>Qe(r,t),[t]),q=a.useCallback(r=>ie(r.domainName,s,t),[s,t]),G=a.useMemo(()=>{const r=M.trim().toLowerCase();return m.filter(K=>L!=="all"&&K.permission!==L?!1:r?ie(K.domainName,s,t).toLowerCase().includes(r)||K.domainName.toLowerCase().includes(r):!0)},[m,M,L,s,t]),b=a.useCallback((r,K)=>{const $=H(r.permission);return K?`${$} ${t("domainTypeBuiltinSuffix")}`:$},[H,t]);return{domains:m,loadingDomains:p,domainError:x,newDomainName:N,setNewDomainName:C,newDomainPermission:i,setNewDomainPermission:v,creating:g,handleCreateDomain:P,renamingId:V,setRenamingId:I,renameDraft:z,setRenameDraft:D,startRename:d,cancelRename:j,handleRename:c,changeTypeForId:A,setChangeTypeForId:w,handlePermissionChange:R,handleDelete:O,domainSearch:M,setDomainSearch:F,domainFilter:L,setDomainFilter:f,filteredDomains:G,visitorId:y,plabel:H,localizeDomain:q,domainTypeLabel:b}}function Es(){const{t}=Z(),s=Ms(),[y,u]=a.useState([]),[m,E]=a.useState(null),[p,k]=a.useState(null),N=a.useCallback(async()=>{try{const i=await ke();u(i)}catch{u([])}},[]);a.useEffect(()=>{N()},[N]);async function C(i){E(null);try{const v=await cs(i.domainId);k({domainId:i.domainId,creatorVisitorId:i.creatorVisitorId,initialIds:v.map(g=>g.visitorId),memberRows:v})}catch(v){E({kind:"err",text:_(t,v)})}}return e.jsxs("div",{className:"mdocs-settings",children:[e.jsx("div",{className:"mdocs-settings-header",children:e.jsx("h2",{className:"mdocs-settings-title",children:t("domainManagement")})}),e.jsx("p",{className:"mdocs-domain-mgmt-restricted-hint",children:t("domainMgmtRestrictedMemberHint")}),e.jsxs("div",{className:"mdocs-settings-cards",children:[e.jsxs("div",{className:"mdocs-settings-card mdocs-domain-mgmt-create",children:[e.jsx("div",{className:"mdocs-settings-card-title",children:t("createDomain")}),e.jsxs("form",{onSubmit:s.handleCreateDomain,className:"mdocs-domain-mgmt-create-form",children:[e.jsxs("label",{className:"mdocs-domain-mgmt-field",children:[e.jsx("span",{className:"mdocs-domain-mgmt-label",children:t("domainName")}),e.jsx("input",{value:s.newDomainName,onChange:i=>s.setNewDomainName(i.target.value),placeholder:t("domainName"),maxLength:100,disabled:s.creating,className:"mdocs-domain-name-input"})]}),e.jsxs("fieldset",{className:"mdocs-domain-mgmt-fieldset",children:[e.jsx("legend",{className:"mdocs-domain-mgmt-label",children:t("domainPermission")}),e.jsx("div",{className:"mdocs-domain-mgmt-type-radios",children:ne.map(i=>e.jsxs("label",{className:"mdocs-domain-mgmt-radio",children:[e.jsx("input",{type:"radio",name:"newDomainPermission",checked:s.newDomainPermission===i,onChange:()=>s.setNewDomainPermission(i),disabled:s.creating}),e.jsx("span",{children:s.plabel(i)})]},i))})]}),e.jsx("button",{type:"submit",className:"primary mdocs-domain-mgmt-submit",disabled:s.creating,children:s.creating?t("creating"):t("create")})]})]}),m&&e.jsx("div",{className:"mdocs-settings-card",style:{color:m.kind==="ok"?"var(--mdocs-success, #0a7)":"var(--mdocs-danger)"},children:e.jsx("span",{className:"mdocs-settings-item-desc",children:m.text})}),s.domainError&&e.jsx("div",{className:"mdocs-settings-card mdocs-domain-error",children:e.jsx("span",{className:"mdocs-settings-item-desc",style:{color:"var(--mdocs-danger)"},children:s.domainError})}),e.jsxs("div",{className:"mdocs-settings-card mdocs-domain-mgmt-toolbar",children:[e.jsx("input",{type:"search",value:s.domainSearch,onChange:i=>s.setDomainSearch(i.target.value),placeholder:t("domainSearchPlaceholder"),className:"mdocs-domain-mgmt-search","aria-label":t("domainSearchPlaceholder")}),e.jsx("div",{className:"mdocs-domain-mgmt-filters",role:"group","aria-label":t("domainPermission"),children:["all",...ne].map(i=>e.jsx("button",{type:"button",className:"mdocs-domain-mgmt-filter"+(s.domainFilter===i?" active":""),"aria-pressed":s.domainFilter===i,onClick:()=>s.setDomainFilter(i),children:i==="all"?t("domainFilterAll"):s.plabel(i)},i))})]}),s.loadingDomains?e.jsx("div",{className:"mdocs-settings-card",children:e.jsx("span",{className:"mdocs-settings-item-desc",children:t("loading")})}):s.domains.length===0?e.jsx("div",{className:"mdocs-settings-card mdocs-settings-draft-empty",children:e.jsx("span",{className:"mdocs-settings-item-desc",children:t("noDomains")})}):s.filteredDomains.length===0?e.jsx("div",{className:"mdocs-settings-card mdocs-settings-draft-empty",children:e.jsx("span",{className:"mdocs-settings-item-desc",children:t("domainNoMatch")})}):e.jsx("div",{className:"mdocs-settings-card mdocs-domain-table-wrap",children:e.jsxs("table",{className:"mdocs-domain-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:t("domainColName")}),e.jsx("th",{scope:"col",children:t("domainColType")}),e.jsx("th",{scope:"col",className:"mdocs-domain-table-num",children:t("domainColDocCount")}),e.jsx("th",{scope:"col",children:t("domainColActions")})]})}),e.jsx("tbody",{children:s.filteredDomains.map(i=>{const v=ts(i,s.visitorId),g=as(i.domainId),o=ns(i),x=o?t("domainTooltipTypeLocked",{count:String(i.docCount)}):void 0;return e.jsxs("tr",{className:g?"mdocs-domain-table-row-builtin":void 0,children:[e.jsx("td",{children:s.renamingId===i.domainId?e.jsxs("div",{className:"mdocs-domain-table-rename",children:[e.jsx("input",{value:s.renameDraft,onChange:h=>s.setRenameDraft(h.target.value),maxLength:100,autoFocus:!0,className:"mdocs-domain-name-input"}),e.jsx("button",{type:"button",className:"primary",onClick:()=>void s.handleRename(i.domainId),children:t("save")}),e.jsx("button",{type:"button",onClick:s.cancelRename,children:t("cancel")})]}):e.jsxs("div",{className:"mdocs-domain-table-name-cell",children:[e.jsx("span",{className:"mdocs-domain-table-name",children:s.localizeDomain(i)}),g&&e.jsx("span",{className:"mdocs-domain-badge-builtin",children:t("domainBuiltIn")}),!v&&!g&&e.jsx("span",{className:"mdocs-domain-badge-shared",children:t("shared")})]})}),e.jsx("td",{children:e.jsxs("span",{className:"mdocs-domain-table-type",title:x,children:[e.jsx("span",{className:"mdocs-domain-permission-badge","data-permission":i.permission,children:s.domainTypeLabel(i,g)}),o&&!g&&e.jsx("span",{className:"mdocs-domain-type-lock","aria-hidden":"true",children:"🔒"})]})}),e.jsx("td",{className:"mdocs-domain-table-num",children:i.docCount}),e.jsxs("td",{className:"mdocs-domain-table-actions",children:[g&&e.jsx("span",{className:"mdocs-domain-not-modifiable",children:t("domainNotModifiable")}),!g&&!v&&e.jsx("span",{className:"mdocs-domain-not-creator-inline",children:t("domainNotCreator")}),!g&&v&&s.changeTypeForId===i.domainId&&e.jsxs("div",{className:"mdocs-domain-change-type-panel",children:[e.jsx("div",{className:"mdocs-domain-permission-select",children:ne.map(h=>e.jsx("button",{type:"button",className:i.permission===h?"active":"",onClick:()=>void s.handlePermissionChange(i.domainId,h),children:s.plabel(h)},h))}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>s.setChangeTypeForId(null),children:t("cancel")})]}),!g&&v&&s.renamingId!==i.domainId&&s.changeTypeForId!==i.domainId&&e.jsxs("div",{className:"mdocs-domain-action-buttons",children:[e.jsx("button",{type:"button",className:"secondary",title:o?t("domainLocked"):void 0,onClick:()=>{s.setChangeTypeForId(null),s.startRename(i)},disabled:o,children:t("rename")}),e.jsx("button",{type:"button",className:"secondary",title:o?x:void 0,onClick:()=>{s.setRenamingId(null),s.setChangeTypeForId(i.domainId)},disabled:o,children:t("domainChangeType")}),e.jsx("button",{type:"button",className:"secondary",title:o?t("domainLocked"):void 0,onClick:()=>void s.handleDelete(i),disabled:o,children:t("deleteDomain")}),i.permission==="restricted"&&!g&&e.jsx("button",{type:"button",className:"secondary",onClick:()=>void C(i),children:t("domainMembersManageButton")})]})]})]},i.domainId)})})]})})]}),e.jsx(we,{open:p!==null,title:t("domainMembersPickerTitle"),initialSelectedIds:(p==null?void 0:p.initialIds)??[],lockedIds:p?[p.creatorVisitorId]:[],seedMembers:p==null?void 0:p.memberRows,templates:y,onClose:()=>k(null),onConfirm:async i=>{p&&(await is(p.domainId,i),E({kind:"ok",text:t("domainMembersSaved",{count:String(i.length)})}))}})]})}function ye(t){return t.length<=6?t:`${t.slice(0,6)}…`}function Ls(){const{t}=Z(),s=a.useRef(!0),[y,u]=a.useState([]),[m,E]=a.useState(!0),[p,k]=a.useState(null),[N,C]=a.useState(1),[i,v]=a.useState(null),[g,o]=a.useState(""),[x,h]=a.useState([]),[V,I]=a.useState(!1),[z,D]=a.useState(null),[M,F]=a.useState(!1),L=be(),[f,A]=a.useState([]),[w,S]=a.useState("idle"),[P,c]=a.useState("");a.useEffect(()=>(s.current=!0,()=>{s.current=!1}),[]),a.useEffect(()=>{S("loading"),ls().then(l=>{s.current&&(A(l),S("ok"))}).catch(()=>{s.current&&S("err")})},[]);const d=a.useMemo(()=>{const l=new Map;for(const T of f)l.set(T.visitorId,T.visitorName);return l},[f]),j=a.useCallback(async()=>{E(!0),D(null);try{const l=await ke();s.current&&u(l)}catch(l){s.current&&D(_(t,l))}finally{s.current&&E(!1)}},[t]);a.useEffect(()=>{j()},[j]);const R=a.useMemo(()=>x.map(l=>{const T=f.find(W=>W.visitorId===l);return{visitorId:l,name:T?T.visitorName:t("visitorPickerUnknownVisitor"),muted:!T}}),[x,f,t]);function O(l){h(T=>T.includes(l)?T.filter(W=>W!==l):[...T,l])}const H=N===1?g.trim().length>0:N===2?x.length>0:!0;function q(){if(!(N>=3)){if(!H){F(!0);return}F(!1),C(N+1),c("")}}function G(){N<=1||(F(!1),C(N-1))}function b(){k(null),v(null),o(""),h(L?[L]:[]),D(null),C(1),c(""),F(!1)}function r(l){k(null),v(l.id),o(l.displayName);const T=L&&!l.visitorIds.includes(L)?[...l.visitorIds,L]:[...l.visitorIds];h(T),D(null),C(1),c(""),F(!1)}async function K(){if(!(!g.trim()||x.length===0)){I(!0),D(null);try{if(i===null?await os({displayName:g.trim(),visitorIds:x}):await rs(i,{displayName:g.trim(),visitorIds:x}),!s.current)return;b(),await j()}catch(l){if(!s.current)return;D(_(t,l))}finally{s.current&&I(!1)}}}async function $(l){I(!0),D(null);try{if(await ds(l),!s.current)return;k(null),i===l&&b(),await j()}catch(T){if(!s.current)return;D(_(t,T))}finally{s.current&&I(!1)}}const Q=[{key:1,label:t("memberTemplateStepName")},{key:2,label:t("memberTemplateStepMembers")},{key:3,label:t("memberTemplateStepSave")}],ee=`${(N-1)/2*100}%`;return e.jsxs("div",{className:"mdocs-settings",children:[e.jsxs("div",{className:"mdocs-settings-header",children:[e.jsx("h2",{className:"mdocs-settings-title",children:t(i!==null?"memberTemplateUpdate":"memberTemplateFormNew")}),i!==null&&e.jsx("button",{type:"button",className:"secondary",onClick:b,style:{fontSize:12},children:t("memberTemplateCancelEdit")})]}),e.jsxs("div",{className:"mdocs-wizard-progress",children:[e.jsx("div",{className:"mdocs-wizard-progress-track",children:e.jsx("div",{className:"mdocs-wizard-progress-fill",style:{width:ee}})}),e.jsx("div",{className:"mdocs-wizard-progress-steps",children:Q.map(l=>{const T=N===l.key,W=N>l.key;return e.jsxs("div",{className:"mdocs-wizard-step-indicator",children:[e.jsx("div",{className:`mdocs-wizard-step-circle${T?" current":""}${W?" done":""}`,children:W?"✓":l.key}),e.jsx("span",{className:`mdocs-wizard-step-label${T?" current":""}${W?" done":""}`,children:l.label})]},l.key)})})]}),z&&e.jsx("div",{className:"mdocs-settings-item-desc",style:{color:"var(--mdocs-danger)",marginBottom:12,marginTop:12},children:z}),e.jsxs("div",{className:"mdocs-settings-cards",children:[e.jsxs("div",{className:"mdocs-settings-card mdocs-wizard-card",children:[N===1&&e.jsxs("div",{className:"mdocs-wizard-step-content",children:[e.jsx("input",{className:"mdocs-wizard-name-input",value:g,onChange:l=>o(l.target.value),placeholder:t("memberTemplateNamePlaceholder"),maxLength:200,disabled:V,autoFocus:!0,"aria-invalid":M&&!g.trim()}),M&&!g.trim()&&e.jsx("p",{className:"mdocs-wizard-hint",style:{color:"var(--mdocs-danger)"},children:t("domainNameRequired")})]}),N===2&&e.jsxs("div",{className:"mdocs-wizard-step-content",children:[e.jsx(Is,{visitors:f,loadState:w,searchFilter:P,onSearchChange:c,selectedIds:new Set(x),onToggle:O,selectedRows:R,myVisitorId:L}),e.jsx("p",{className:`mdocs-wizard-hint${M&&x.length===0?" danger":""}`,children:"💡 "+t("memberTemplateStep2Hint")})]}),N===3&&e.jsx("div",{className:"mdocs-wizard-step-content",children:e.jsxs("div",{className:"mdocs-wizard-preview-card",children:[e.jsxs("div",{className:"mdocs-wizard-preview-row",children:[e.jsx("span",{className:"mdocs-wizard-preview-label",children:t("memberTemplateNameLabel")}),e.jsx("span",{className:"mdocs-wizard-preview-value",children:g})]}),e.jsxs("div",{className:"mdocs-wizard-preview-row",children:[e.jsx("span",{className:"mdocs-wizard-preview-label",children:t("memberTemplateIdsLabel")}),e.jsx("span",{className:"mdocs-wizard-preview-value",children:t("memberTemplateSelectedSummary",{count:String(x.length)})})]}),x.length>0&&e.jsxs("div",{className:"mdocs-wizard-preview-tags",children:[x.slice(0,15).map(l=>e.jsx("span",{className:"mdocs-wizard-preview-tag",children:ye(l)},l)),x.length>15&&e.jsxs("span",{className:"mdocs-wizard-preview-tag mdocs-wizard-preview-tag-more",children:["+",x.length-15]})]})]})}),e.jsxs("div",{className:"mdocs-wizard-footer",children:[e.jsxs("button",{type:"button",className:"secondary",onClick:G,children:["← ",t("memberTemplateWizardBack")]}),N<3?e.jsxs("button",{type:"button",className:"primary",onClick:q,children:[t("memberTemplateWizardNext")," →"]}):e.jsx("button",{type:"button",className:"primary",onClick:()=>void K(),children:t(V?"saving":i===null?"memberTemplateCreate":"memberTemplateUpdate")})]})]}),e.jsxs("div",{className:"mdocs-settings-card",children:[e.jsx("div",{className:"mdocs-settings-card-title",children:t("memberTemplateSavedList")}),m?e.jsx("span",{className:"mdocs-settings-item-desc",children:t("loading")}):y.length===0?e.jsxs("div",{className:"mdocs-member-template-empty",children:[e.jsx("span",{className:"mdocs-settings-item-desc",children:t("memberTemplateEmpty")}),i===null&&e.jsx("button",{type:"button",className:"primary",onClick:b,children:t("memberTemplateEmptyAction")})]}):e.jsx("ul",{className:"mdocs-member-template-list",children:y.map(l=>e.jsx("li",{className:"mdocs-member-template-row",children:p===l.id?e.jsxs("div",{className:"mdocs-member-template-confirm-row",children:[e.jsx("span",{className:"mdocs-member-template-confirm-text",children:t("memberTemplateConfirmDeleteDesc",{name:l.displayName})}),e.jsxs("div",{className:"mdocs-member-template-confirm-actions",children:[e.jsx("button",{type:"button",className:"secondary",style:{color:"var(--mdocs-danger)"},onClick:()=>void $(l.id),children:t(V?"saving":"memberTemplateConfirmDeleteSubmit")}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>k(null),children:t("memberTemplateConfirmDeleteCancel")})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mdocs-member-template-row-head",children:[e.jsx("strong",{children:l.displayName}),e.jsx("span",{className:"mdocs-settings-item-desc",children:t("memberTemplateCount",{count:String(l.visitorIds.length)})}),l.visitorIds.length>0&&e.jsx("div",{className:"mdocs-member-template-tags mdocs-member-template-tags-scroll",children:l.visitorIds.map(T=>e.jsx("span",{className:"mdocs-member-template-tag",children:d.get(T)??ye(T)},T))})]}),e.jsxs("div",{className:"mdocs-member-template-row-actions",children:[e.jsx("button",{type:"button",className:"secondary",onClick:()=>r(l),children:t("edit")}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>k(l.id),children:t("memberTemplateDelete")})]})]})},l.id))})]})]})]})}const Rs=[{value:"deepseek-v4-flash",label:"deepseek-v4-flash"},{value:"deepseek-v4-pro",label:"deepseek-v4-pro"}];function Bs(){const{t}=Z(),s=a.useRef(!0),[y,u]=a.useState(""),[m,E]=a.useState(null),[p,k]=a.useState(""),[N,C]=a.useState("deepseek-v4-flash"),[i,v]=a.useState(128e3),[g,o]=a.useState(""),[x,h]=a.useState(!1),[V,I]=a.useState(null),[z,D]=a.useState(!0),[M,F]=a.useState(!1),[L,f]=a.useState(null),[A,w]=a.useState(!1),[S,P]=a.useState(!1),[c,d]=a.useState(!1),[j,R]=a.useState(null);a.useEffect(()=>(s.current=!0,()=>{s.current=!1}),[]),a.useEffect(()=>{(async()=>{try{const[b,r]=await Promise.all([ms(),us()]);if(!s.current)return;u(b.visitorName),r?(E(r.id),k(r.name),C(r.modelId),v(r.contextWindow||128e3),h(r.hasApiKey),I(r.apiKeyMasked),P(!1)):P(!0)}catch(b){if(!s.current)return;f(b instanceof Error?b.message:String(b)),P(!0)}finally{s.current&&D(!1)}})()},[]);function O(){R({name:p,modelId:N,contextWindow:i}),o(""),d(!1),w(!1),f(null),P(!0)}function H(){j&&(k(j.name),C(j.modelId),v(j.contextWindow)),o(""),d(!1),f(null),w(!1),P(!1),R(null)}async function q(){F(!0),f(null),w(!1);try{const b={modelId:N,name:p,contextWindow:i};g.trim()&&(b.apiKey=g.trim());const r=await ps(b);if(!s.current)return;E(r.id),k(r.name),C(r.modelId),v(r.contextWindow||128e3),h(r.hasApiKey),I(r.apiKeyMasked),o(""),d(!1),w(!0),P(!1),R(null)}catch(b){if(!s.current)return;f(b instanceof Error?b.message:String(b))}finally{s.current&&F(!1)}}const G=t("agentConfigNameDefault").replace("{{name}}",y||"…");return e.jsxs("div",{className:"mdocs-settings",children:[e.jsxs("div",{className:"mdocs-settings-header",children:[e.jsxs("h2",{className:"mdocs-settings-title mdocs-agent-config-title",children:[e.jsx("img",{src:hs,alt:"DeepSeek",className:"mdocs-agent-config-logo"}),t("agentConfig")]}),!z&&m&&!S?e.jsx("button",{type:"button",className:"secondary",onClick:O,children:t("edit")}):null]}),e.jsx("div",{className:"mdocs-settings-cards",children:e.jsxs("div",{className:"mdocs-settings-card",children:[e.jsx("p",{className:"mdocs-settings-item-desc",style:{marginBottom:12},children:t("agentConfigDesc")}),z?e.jsx("p",{children:t("loading")}):e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"mdocs-settings-item",style:{display:"block",marginBottom:12},children:[e.jsx("span",{className:"mdocs-settings-card-title",children:t("agentConfigName")}),e.jsx("input",{type:"text",value:p,onChange:b=>k(b.target.value),placeholder:G,disabled:!S,style:{width:"100%",marginTop:6}})]}),e.jsxs("div",{className:"mdocs-settings-item mdocs-agent-config-field",style:{marginBottom:12},children:[e.jsx("span",{className:"mdocs-settings-card-title",children:t("agentConfigModel")}),S?e.jsx("div",{className:"mdocs-agent-config-select",children:e.jsx(Ts,{options:Rs,value:N,onChange:b=>C(b)})}):e.jsx("p",{className:"mdocs-agent-config-readonly",children:N})]}),e.jsxs("label",{className:"mdocs-settings-item",style:{display:"block",marginBottom:12},children:[e.jsx("span",{className:"mdocs-settings-card-title",children:t("agentConfigContextWindow")}),e.jsx("p",{className:"mdocs-settings-item-desc",style:{margin:"4px 0 6px"},children:t("agentConfigContextWindowDesc")}),S?e.jsx("input",{type:"number",min:1e3,max:2e6,step:1e3,value:i,onChange:b=>v(Number(b.target.value)||128e3),style:{width:"100%"}}):e.jsx("p",{className:"mdocs-agent-config-readonly",children:i})]}),e.jsxs("div",{className:"mdocs-settings-item mdocs-agent-config-field",style:{marginBottom:12},children:[e.jsx("span",{className:"mdocs-settings-card-title",children:t("agentConfigApiKey")}),S?e.jsxs("div",{className:"mdocs-agent-config-apikey",children:[e.jsx("input",{type:c?"text":"password",value:g,onChange:b=>o(b.target.value),placeholder:x?t("agentConfigApiKeyConfigured").replace("{{masked}}",V??"…"):t("agentConfigApiKeyPlaceholder"),autoComplete:"off"}),e.jsx("button",{type:"button",className:"mdocs-agent-config-eye","aria-label":t(c?"agentConfigHideKey":"agentConfigShowKey"),onClick:()=>d(b=>!b),children:c?e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":!0,children:[e.jsx("path",{d:"M3 3l18 18"}),e.jsx("path",{d:"M10.6 10.6a2 2 0 002.8 2.8"}),e.jsx("path",{d:"M9.9 5.1A10.5 10.5 0 0121 12c-.6 1.1-1.4 2.1-2.4 2.9"}),e.jsx("path",{d:"M6.1 6.1C4.5 7.4 3.2 9.1 2.5 12c1.5 3.5 5 7 9.5 7 1.4 0 2.7-.3 3.9-.8"})]}):e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":!0,children:[e.jsx("path",{d:"M2.5 12C4 8.5 7.5 5 12 5s8 3.5 9.5 7c-1.5 3.5-5 7-9.5 7s-8-3.5-9.5-7z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]})})]}):e.jsx("p",{className:"mdocs-agent-config-readonly",children:x?V??"…":t("agentConfigApiKeyPlaceholder")})]}),m?e.jsxs("p",{className:"mdocs-settings-item-desc",style:{marginBottom:12},children:[t("agentConfigId"),": ",m]}):null,L?e.jsx("p",{style:{color:"var(--mdocs-danger, #c00)",marginBottom:12},children:L}):null,A&&!S?e.jsx("p",{className:"mdocs-settings-item-desc",style:{marginBottom:12},children:t("saved")}):null,S?e.jsxs("div",{className:"mdocs-agent-config-actions",children:[e.jsx("button",{type:"button",onClick:()=>void q(),disabled:M,children:t(M?"saving":"save")}),m?e.jsx("button",{type:"button",className:"secondary",onClick:H,disabled:M,children:t("cancel")}):null]}):null]})]})})]})}function Ne(t,s){const y=localStorage.getItem(t);return y===null?s:y==="true"}function $s(t){const{t:s,lang:y,setLang:u}=Z(),{onBack:m,onPublishDraft:E}=t,p=a.useRef(!0);a.useEffect(()=>(p.current=!0,()=>{p.current=!1}),[]);const[k,N]=a.useState(()=>Ne("mdocs.autoPublish",!1)),[C,i]=a.useState(()=>Ne("mdocs.autoEdit",!0)),[v,g]=a.useState(!1),[o,x]=a.useState("general"),[h,V]=a.useState([]),[I,z]=a.useState(!0),[D,M]=a.useState(null),[F,L]=a.useState(!1),[f,A]=a.useState(!1),[w,S]=a.useState(!1),[P,c]=a.useState(!1),[d,j]=a.useState(null),[R,O]=a.useState(!1),[H,q]=a.useState(!1),[G,b]=a.useState(!1),[r,K]=a.useState(""),[$,Q]=a.useState(!1),[ee,l]=a.useState(!1),[T,W]=a.useState(0),[Se,le]=a.useState([]),[Ce,oe]=a.useState(!1),[X,De]=a.useState(""),[Ie,Te]=a.useState([]),[Ae,re]=a.useState(!1),[Y,Pe]=a.useState(""),[Me,Ee]=a.useState([]),[Le,se]=a.useState(!1),[te,de]=a.useState(null),[ae,me]=a.useState(new Map);a.useEffect(()=>{localStorage.setItem("mdocs.autoPublish",String(k))},[k]),a.useEffect(()=>{localStorage.setItem("mdocs.autoEdit",String(C))},[C]),a.useEffect(()=>{o==="savePublish"&&ce().then(n=>{p.current&&W(n.filter(B=>!B.published).length)})},[o]),a.useEffect(()=>{o==="bookmarks"&&Re(),o==="myDocuments"&&pe()},[o]),a.useEffect(()=>{he()},[]),a.useEffect(()=>{ve().then(n=>{p.current&&Ee(n)}).catch(()=>{})},[]);const ue=new Map(Me.map(n=>[n.domainId,n.domainName]));async function he(){try{z(!0);const n=await gs();if(!p.current)return;V(n)}catch{}finally{p.current&&z(!1)}}async function Re(){try{oe(!0);const n=await fs();if(!p.current)return;le(n)}catch{}finally{p.current&&oe(!1)}}async function pe(){try{re(!0);const n=await xs();if(!p.current)return;Te(n)}catch{}finally{p.current&&re(!1)}}async function Be(n){try{await ks(n),le(B=>B.filter(J=>J.documentId!==n))}catch{}}function ze(){if(h.some(B=>!B.revoked)){A(!0);return}ge()}async function ge(){try{L(!0);const n=await Ss();M({token:n.token,name:n.name}),await he()}finally{L(!1)}}async function Fe(){try{b(!0);const n=await bs();j(n.recoveryCode)}finally{b(!1)}}async function Ke(n){n.preventDefault();const B=r.trim();if(!(B&&B.length<4))try{Q(!0),await vs(B),K(""),l(!0),setTimeout(()=>l(!1),3e3)}finally{Q(!1)}}async function Ve(n){de(n);try{const B=await ws(n),J=new Map;B.forEach(U=>{J.set(U.visitorId,U.permission)}),me(J)}catch{me(new Map)}se(!0)}async function Oe(n){if(te)try{const B=new Set(n.map(U=>U.visitorId)),J=new Set(ae.keys());for(const U of J)B.has(U)||await Cs(te,U);for(const U of n)await Ds(te,U.visitorId,U.permission);await pe()}finally{se(!1),de(null)}}const fe=Se.filter(n=>{if(!X.trim())return!0;const B=X.toLowerCase();return(n.displayName||n.relativePath||"").toLowerCase().includes(B)||(n.ownerVisitorName||"").toLowerCase().includes(B)||(n.domainId||"").toLowerCase().includes(B)}),xe=Ie.filter(n=>{if(!Y.trim())return!0;const B=Y.toLowerCase();return(n.displayName||n.relativePath||"").toLowerCase().includes(B)||(n.domainId||"").toLowerCase().includes(B)});return e.jsxs(e.Fragment,{children:[e.jsxs("aside",{className:"mdocs-sidebar",children:[e.jsx("header",{className:"mdocs-sidebar-header",children:e.jsxs("div",{className:"mdocs-brand",children:[e.jsx("img",{src:js,alt:s("brand"),className:"mdocs-brand-logo"}),e.jsx("span",{children:s("brand")})]})}),e.jsxs("nav",{className:"mdocs-config-tree",children:[e.jsx("div",{className:"mdocs-config-item"+(o==="general"?" active":""),onClick:()=>x("general"),children:s("general")}),e.jsx("div",{className:"mdocs-config-item"+(o==="bookmarks"?" active":""),onClick:()=>x("bookmarks"),children:s("bookmarkTitle")}),e.jsx("div",{className:"mdocs-config-item"+(o==="myDocuments"?" active":""),onClick:()=>x("myDocuments"),children:s("myDocuments")}),e.jsx("div",{className:"mdocs-config-item"+(o==="domainManagement"?" active":""),onClick:()=>x("domainManagement"),children:s("domainManagement")}),e.jsx("div",{className:"mdocs-config-item"+(o==="memberTemplates"?" active":""),onClick:()=>x("memberTemplates"),children:s("memberTemplates")}),e.jsx("div",{className:"mdocs-config-item"+(o==="agentConfig"?" active":""),onClick:()=>x("agentConfig"),children:s("agentConfig")}),e.jsx("div",{className:"mdocs-config-item"+(o==="savePublish"?" active":""),onClick:()=>x("savePublish"),children:s("saveAndPublish")})]}),e.jsx("footer",{className:"mdocs-settings-sidebar-footer",onClick:m,children:s("backToDocs")})]}),e.jsxs("main",{className:"mdocs-main",children:[ys(),o==="general"?e.jsxs("div",{className:"mdocs-settings",children:[e.jsx("div",{className:"mdocs-settings-header",children:e.jsx("h2",{className:"mdocs-settings-title",children:s("general")})}),e.jsxs("div",{className:"mdocs-settings-cards",children:[e.jsx("div",{className:"mdocs-settings-card",children:e.jsxs("label",{className:"mdocs-settings-item",children:[e.jsx("span",{className:"mdocs-settings-item-info",children:e.jsx("span",{className:"mdocs-settings-card-title",children:s("language")})}),e.jsxs("span",{className:"mdocs-settings-lang",children:[e.jsx("button",{type:"button",className:y==="en"?"active":"",onClick:()=>u("en"),children:"EN"}),e.jsx("span",{children:"/"}),e.jsx("button",{type:"button",className:y==="zh"?"active":"",onClick:()=>u("zh"),children:"中"})]})]})}),e.jsx("div",{className:"mdocs-settings-card",children:e.jsxs("label",{className:"mdocs-settings-item",children:[e.jsxs("span",{className:"mdocs-settings-item-info",children:[e.jsx("span",{className:"mdocs-settings-card-title",children:s("autoEdit")}),e.jsx("span",{className:"mdocs-settings-item-desc",children:s("autoEditDesc")})]}),e.jsx("button",{type:"button",className:"mdocs-toggle"+(C?" active":""),role:"switch","aria-checked":C,onClick:()=>i(n=>!n),children:e.jsx("span",{className:"mdocs-toggle-knob"})})]})}),e.jsxs("div",{className:"mdocs-settings-card",children:[e.jsxs("div",{className:"mdocs-settings-item",children:[e.jsxs("span",{className:"mdocs-settings-item-info",children:[e.jsx("span",{className:"mdocs-settings-card-title",children:s("cliToken")}),e.jsx("span",{className:"mdocs-settings-item-desc",children:s("cliTokenDesc")}),!I&&h.length>0&&e.jsx("span",{className:"mdocs-settings-item-desc",style:{marginTop:8,fontSize:"0.85em",opacity:.8},children:h.map(n=>e.jsxs("span",{style:{display:"block"},children:[n.name," — ",new Date(n.createdAt).toLocaleString()," ",n.revoked?`(${s("cliTokenRevoked")})`:`(${s("cliTokenActive")})`]},n.tokenId))})]}),e.jsx("button",{type:"button",className:"secondary",onClick:ze,disabled:F||I,children:F?"…":h.some(n=>!n.revoked)?s("cliTokenReset"):s("cliTokenCreate")})]}),D&&e.jsxs("div",{className:"mdocs-settings-secret-result mdocs-settings-secret-result--ok",children:[e.jsxs("div",{className:"mdocs-settings-secret-result-head",children:[e.jsx("span",{className:"mdocs-settings-card-title",children:s("cliTokenGenerated")}),e.jsx("span",{className:"mdocs-settings-secret-value",children:D.token})]}),e.jsxs("div",{className:"mdocs-settings-secret-result-actions",children:[e.jsx("button",{type:"button",className:"secondary",onClick:()=>{(async()=>{try{await navigator.clipboard.writeText(D.token),c(!1),S(!0),window.setTimeout(()=>S(!1),2e3)}catch{S(!1),c(!0),window.setTimeout(()=>c(!1),3e3)}})()},children:s(w?"cliTokenCopied":"cliTokenCopy")}),e.jsx("button",{type:"button",onClick:()=>M(null),children:s("close")})]}),w&&e.jsxs("div",{className:"mdocs-settings-copy-feedback mdocs-settings-copy-feedback--ok",role:"status",children:["✓ ",s("cliTokenCopied")]}),P&&e.jsx("div",{className:"mdocs-settings-copy-feedback mdocs-settings-copy-feedback--err",role:"status",children:s("cliTokenCopyFailed")})]})]}),e.jsxs("div",{className:"mdocs-settings-card",children:[e.jsxs("div",{className:"mdocs-settings-item",children:[e.jsxs("span",{className:"mdocs-settings-item-info",children:[e.jsx("span",{className:"mdocs-settings-card-title",children:"🔑 恢复码"}),e.jsx("span",{className:"mdocs-settings-item-desc",children:"当 Token 丢失时,可用恢复码找回身份。生成后请立即保存,仅显示一次。"})]}),e.jsx("button",{type:"button",className:"secondary",onClick:Fe,disabled:G,children:G?"…":"生成恢复码"})]}),d&&e.jsxs("div",{className:"mdocs-settings-secret-result mdocs-settings-secret-result--warn",children:[e.jsxs("div",{className:"mdocs-settings-secret-result-head",children:[e.jsx("span",{className:"mdocs-settings-card-title",children:"🔑 你的恢复码"}),e.jsx("span",{className:"mdocs-settings-item-desc",style:{marginTop:8},children:"请立即复制保存,关闭后不可再查看。"}),e.jsx("div",{className:"mdocs-settings-secret-code",children:d})]}),e.jsxs("div",{className:"mdocs-settings-secret-result-actions",children:[e.jsx("button",{type:"button",className:"primary",onClick:()=>{(async()=>{try{await navigator.clipboard.writeText(d),q(!1),O(!0),window.setTimeout(()=>O(!1),2e3)}catch{O(!1),q(!0),window.setTimeout(()=>q(!1),3e3)}})()},children:R?"已复制":"复制恢复码"}),e.jsx("button",{type:"button",onClick:()=>j(null),children:s("close")})]}),R&&e.jsx("div",{className:"mdocs-settings-copy-feedback mdocs-settings-copy-feedback--ok",role:"status",children:"✓ 已复制到剪贴板"}),H&&e.jsx("div",{className:"mdocs-settings-copy-feedback mdocs-settings-copy-feedback--err",role:"status",children:"复制失败,请手动选中上方内容复制"})]})]}),e.jsxs("div",{className:"mdocs-settings-card",children:[e.jsx("div",{className:"mdocs-settings-item",children:e.jsxs("span",{className:"mdocs-settings-item-info",children:[e.jsx("span",{className:"mdocs-settings-card-title",children:"🔐 登录密码"}),e.jsx("span",{className:"mdocs-settings-item-desc",children:"设置密码后,可在其他浏览器或设备用「用户名+密码」登录。"})]})}),e.jsxs("form",{onSubmit:Ke,style:{marginTop:12},children:[e.jsx("input",{type:"password",placeholder:"输入新密码(至少 4 位,留空则清除密码)",value:r,onChange:n=>K(n.target.value),minLength:0,style:{marginBottom:8}}),ee&&e.jsx("div",{style:{color:"#4caf50",marginBottom:8,fontSize:"0.875rem"},children:"✓ 密码设置成功"}),e.jsx("button",{type:"submit",className:"secondary",disabled:$,children:$?"设置中…":"保存密码"})]})]})]})]}):o==="bookmarks"?e.jsxs("div",{className:"mdocs-settings",children:[e.jsx("div",{className:"mdocs-settings-header",children:e.jsx("h2",{className:"mdocs-settings-title",children:s("bookmarkTitle")})}),e.jsxs("div",{className:"mdocs-settings-card",children:[e.jsx("input",{type:"text",className:"mdocs-settings-search",placeholder:s("bookmarkSearch"),value:X,onChange:n=>De(n.target.value)}),Ce?e.jsx("div",{style:{textAlign:"center",padding:"40px 0"},children:s("loading")}):e.jsx(e.Fragment,{children:fe.length===0?e.jsx("div",{style:{textAlign:"center",padding:"40px 0",opacity:.6},children:s(X?"bookmarkNoMatch":"bookmarkEmpty")}):e.jsxs("table",{className:"mdocs-settings-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:s("bookmarkColTitle")}),e.jsx("th",{children:s("bookmarkColDomain")}),e.jsx("th",{children:s("bookmarkColAuthor")}),e.jsx("th",{children:s("bookmarkColTime")}),e.jsx("th",{style:{textAlign:"right"}})]})}),e.jsx("tbody",{children:fe.map(n=>e.jsxs("tr",{children:[e.jsx("td",{style:{cursor:"pointer",fontWeight:500},onClick:()=>t.onOpenDocument(n.documentId),children:n.displayName||n.relativePath||"Untitled"}),e.jsx("td",{children:n.isDeleted?e.jsx("span",{style:{opacity:.5,fontStyle:"italic"},children:"已删除"}):ue.get(n.domainId||"")||n.domainId||"—"}),e.jsx("td",{children:n.ownerVisitorName||"—"}),e.jsx("td",{children:new Date(n.bookmarkedAt).toLocaleDateString()}),e.jsx("td",{style:{textAlign:"right"},children:e.jsx("button",{type:"button",className:"secondary small",onClick:()=>Be(n.documentId),children:s("bookmarkRemove")})})]},n.documentId))})]})})]})]}):o==="myDocuments"?e.jsxs("div",{className:"mdocs-settings",children:[e.jsx("div",{className:"mdocs-settings-header",children:e.jsx("h2",{className:"mdocs-settings-title",children:s("myDocuments")})}),e.jsxs("div",{className:"mdocs-settings-card",children:[e.jsx("input",{type:"text",className:"mdocs-settings-search",placeholder:"搜索文章…",value:Y,onChange:n=>Pe(n.target.value)}),Ae?e.jsx("div",{style:{textAlign:"center",padding:"40px 0"},children:s("loading")}):e.jsx(e.Fragment,{children:xe.length===0?e.jsx("div",{style:{textAlign:"center",padding:"40px 0",opacity:.6},children:s(Y?"myDocumentsNoMatch":"myDocumentsEmpty")}):e.jsxs("table",{className:"mdocs-settings-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:s("myDocumentsColTitle")}),e.jsx("th",{children:s("myDocumentsColDomain")}),e.jsx("th",{children:s("myDocumentsColUpdated")}),e.jsx("th",{children:s("myDocumentsColCreated")}),e.jsx("th",{colSpan:2})]})}),e.jsx("tbody",{children:xe.map(n=>e.jsxs("tr",{children:[e.jsx("td",{style:{cursor:"pointer",fontWeight:500},onClick:()=>t.onOpenDocument(n.documentId),children:n.displayName||n.relativePath||"Untitled"}),e.jsx("td",{children:ue.get(n.domainId||"")||n.domainId||"—"}),e.jsx("td",{children:new Date(n.updatedAt).toLocaleDateString()}),e.jsx("td",{children:new Date(n.createdAt).toLocaleDateString()}),e.jsx("td",{style:{textAlign:"right"},children:e.jsx("button",{type:"button",className:"secondary small",onClick:()=>Ve(n.documentId),children:s("docInfoInviteMember")})}),e.jsx("td",{style:{textAlign:"right",paddingLeft:0},children:e.jsx("button",{type:"button",className:"primary small",onClick:()=>t.onOpenDocument(n.documentId),children:s("bookmarkOpen")})})]},n.documentId))})]})})]})]}):o==="domainManagement"?e.jsx(Es,{}):o==="memberTemplates"?e.jsx(Ls,{}):o==="agentConfig"?e.jsx(Bs,{}):e.jsxs("div",{className:"mdocs-settings",children:[e.jsxs("div",{className:"mdocs-settings-header",children:[e.jsx("h2",{className:"mdocs-settings-title",children:s("saveAndPublish")}),e.jsx("button",{type:"button",className:"secondary",onClick:m,children:s("backToDocs")})]}),e.jsxs("div",{className:"mdocs-settings-cards",children:[e.jsx("div",{className:"mdocs-settings-card",children:e.jsxs("label",{className:"mdocs-settings-item",children:[e.jsxs("span",{className:"mdocs-settings-item-info",children:[e.jsx("span",{className:"mdocs-settings-card-title",children:s("autoSave")}),e.jsx("span",{className:"mdocs-settings-item-desc",children:s("autoSaveAlwaysOnDesc")})]}),e.jsx("span",{className:"mdocs-toggle active",role:"switch","aria-checked":"true","aria-disabled":"true",style:{opacity:.6,cursor:"not-allowed"},children:e.jsx("span",{className:"mdocs-toggle-knob"})})]})}),e.jsx("div",{className:"mdocs-settings-card",children:e.jsxs("label",{className:"mdocs-settings-item",children:[e.jsxs("span",{className:"mdocs-settings-item-info",children:[e.jsx("span",{className:"mdocs-settings-card-title",children:s("autoPublish")}),e.jsx("span",{className:"mdocs-settings-item-desc",children:s("autoPublishDesc")})]}),e.jsx("button",{type:"button",className:"mdocs-toggle"+(k?" active":""),role:"switch","aria-checked":k,onClick:()=>N(n=>!n),children:e.jsx("span",{className:"mdocs-toggle-knob"})})]})}),T>0?e.jsxs("button",{className:"mdocs-settings-card mdocs-settings-draft-link",onClick:()=>g(!0),children:[e.jsxs("span",{className:"mdocs-settings-draft-link-text",children:["📄 ",s("viewDrafts")," (",T,")"]}),e.jsx("span",{className:"mdocs-settings-draft-arrow","aria-hidden":"true",children:"›"})]}):e.jsx("div",{className:"mdocs-settings-card mdocs-settings-draft-empty",children:e.jsx("span",{className:"mdocs-settings-item-desc",children:s("noDrafts")})})]})]}),v&&e.jsx(Ps,{onPublish:E,onClose:()=>g(!1),onCountChange:W,onRecover:t.onRecoverDraft})]}),f&&e.jsx(Ns,{title:s("cliToken"),message:s("cliTokenResetConfirm"),confirmLabel:s("cliTokenReset"),cancelLabel:s("cancel"),busy:F,onConfirm:()=>{A(!1),ge()},onCancel:()=>A(!1)}),e.jsx(we,{open:Le,title:s("docInfoInviteMember"),initialSelectedIds:[...ae.keys()],initialPermissions:ae,templates:[],showPermissionSelect:!0,permissionOptions:[{value:"read",label:s("invitePermissionRead")},{value:"edit",label:s("invitePermissionEdit")}],onClose:()=>se(!1),onConfirm:n=>{Oe(n)}})]})}export{$s as SettingsPage};
@@ -0,0 +1,126 @@
1
+ import{c as o}from"./index-C46BU1-j.js";import{r as u,j as r}from"./react-vendor-BNpqFP9B.js";import{F as _,G as C,L as v,H as c,J as l,K as N,M as L,q as j,N as z,P as w}from"./react-B7vrA7AR.js";import{z as g,V as b}from"./editor-ONzd_YnO.js";/**
2
+ * @license lucide-react v0.562.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const $=[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]],H=o("arrow-down-to-line",$);/**
7
+ * @license lucide-react v0.562.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const q=[["path",{d:"M5 3h14",key:"7usisc"}],["path",{d:"m18 13-6-6-6 6",key:"1kf1n9"}],["path",{d:"M12 7v14",key:"1akyts"}]],V=o("arrow-up-to-line",q);/**
12
+ * @license lucide-react v0.562.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const I=[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]],B=o("bold",I);/**
17
+ * @license lucide-react v0.562.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const T=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],A=o("code-xml",T);/**
22
+ * @license lucide-react v0.562.0 - ISC
23
+ *
24
+ * This source code is licensed under the ISC license.
25
+ * See the LICENSE file in the root directory of this source tree.
26
+ */const P=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"m15 15-3-3-3 3",key:"15xj92"}]],E=o("file-up",P);/**
27
+ * @license lucide-react v0.562.0 - ISC
28
+ *
29
+ * This source code is licensed under the ISC license.
30
+ * See the LICENSE file in the root directory of this source tree.
31
+ */const U=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]],Ne=o("heading-1",U);/**
32
+ * @license lucide-react v0.562.0 - ISC
33
+ *
34
+ * This source code is licensed under the ISC license.
35
+ * See the LICENSE file in the root directory of this source tree.
36
+ */const F=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]],Le=o("heading-2",F);/**
37
+ * @license lucide-react v0.562.0 - ISC
38
+ *
39
+ * This source code is licensed under the ISC license.
40
+ * See the LICENSE file in the root directory of this source tree.
41
+ */const R=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2",key:"68ncm8"}],["path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2",key:"1ejuhz"}]],je=o("heading-3",R);/**
42
+ * @license lucide-react v0.562.0 - ISC
43
+ *
44
+ * This source code is licensed under the ISC license.
45
+ * See the LICENSE file in the root directory of this source tree.
46
+ */const S=[["path",{d:"m9 11-6 6v3h9l3-3",key:"1a3l36"}],["path",{d:"m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4",key:"14a9rk"}]],D=o("highlighter",S);/**
47
+ * @license lucide-react v0.562.0 - ISC
48
+ *
49
+ * This source code is licensed under the ISC license.
50
+ * See the LICENSE file in the root directory of this source tree.
51
+ */const O=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],G=o("image",O);/**
52
+ * @license lucide-react v0.562.0 - ISC
53
+ *
54
+ * This source code is licensed under the ISC license.
55
+ * See the LICENSE file in the root directory of this source tree.
56
+ */const W=[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]],X=o("italic",W);/**
57
+ * @license lucide-react v0.562.0 - ISC
58
+ *
59
+ * This source code is licensed under the ISC license.
60
+ * See the LICENSE file in the root directory of this source tree.
61
+ */const J=[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]],K=o("list-ordered",J);/**
62
+ * @license lucide-react v0.562.0 - ISC
63
+ *
64
+ * This source code is licensed under the ISC license.
65
+ * See the LICENSE file in the root directory of this source tree.
66
+ */const Q=[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]],Y=o("list-todo",Q);/**
67
+ * @license lucide-react v0.562.0 - ISC
68
+ *
69
+ * This source code is licensed under the ISC license.
70
+ * See the LICENSE file in the root directory of this source tree.
71
+ */const Z=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],ee=o("list",Z);/**
72
+ * @license lucide-react v0.562.0 - ISC
73
+ *
74
+ * This source code is licensed under the ISC license.
75
+ * See the LICENSE file in the root directory of this source tree.
76
+ */const oe=[["path",{d:"M14 14a2 2 0 0 0 2-2V8h-2",key:"1r06pg"}],["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M8 14a2 2 0 0 0 2-2V8H8",key:"1jzu5j"}]],te=o("message-square-quote",oe);/**
77
+ * @license lucide-react v0.562.0 - ISC
78
+ *
79
+ * This source code is licensed under the ISC license.
80
+ * See the LICENSE file in the root directory of this source tree.
81
+ */const ae=[["path",{d:"M5 12h14",key:"1ays0h"}]],ze=o("minus",ae);/**
82
+ * @license lucide-react v0.562.0 - ISC
83
+ *
84
+ * This source code is licensed under the ISC license.
85
+ * See the LICENSE file in the root directory of this source tree.
86
+ */const ne=[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]],we=o("network",ne);/**
87
+ * @license lucide-react v0.562.0 - ISC
88
+ *
89
+ * This source code is licensed under the ISC license.
90
+ * See the LICENSE file in the root directory of this source tree.
91
+ */const ie=[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]],ce=o("redo-2",ie);/**
92
+ * @license lucide-react v0.562.0 - ISC
93
+ *
94
+ * This source code is licensed under the ISC license.
95
+ * See the LICENSE file in the root directory of this source tree.
96
+ */const le=[["path",{d:"M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2",key:"wuwx1p"}]],se=o("sigma",le);/**
97
+ * @license lucide-react v0.562.0 - ISC
98
+ *
99
+ * This source code is licensed under the ISC license.
100
+ * See the LICENSE file in the root directory of this source tree.
101
+ */const de=[["path",{d:"M10 9.5 8 12l2 2.5",key:"3mjy60"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"m14 9.5 2 2.5-2 2.5",key:"1bir2l"}],["path",{d:"M5 21a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2",key:"as5y1o"}],["path",{d:"M9 21h1",key:"15o7lz"}]],he=o("square-dashed-bottom-code",de);/**
102
+ * @license lucide-react v0.562.0 - ISC
103
+ *
104
+ * This source code is licensed under the ISC license.
105
+ * See the LICENSE file in the root directory of this source tree.
106
+ */const ke=[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]],ye=o("strikethrough",ke);/**
107
+ * @license lucide-react v0.562.0 - ISC
108
+ *
109
+ * This source code is licensed under the ISC license.
110
+ * See the LICENSE file in the root directory of this source tree.
111
+ */const re=[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]],$e=o("table-2",re);/**
112
+ * @license lucide-react v0.562.0 - ISC
113
+ *
114
+ * This source code is licensed under the ISC license.
115
+ * See the LICENSE file in the root directory of this source tree.
116
+ */const pe=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],ue=o("underline",pe);/**
117
+ * @license lucide-react v0.562.0 - ISC
118
+ *
119
+ * This source code is licensed under the ISC license.
120
+ * See the LICENSE file in the root directory of this source tree.
121
+ */const me=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],Me=o("undo-2",me);/**
122
+ * @license lucide-react v0.562.0 - ISC
123
+ *
124
+ * This source code is licensed under the ISC license.
125
+ * See the LICENSE file in the root directory of this source tree.
126
+ */const ge=[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]],He=o("workflow",ge);function m(e,n="*/*"){if(typeof document>"u")return;const a=document.createElement("input");a.type="file",a.accept=n,a.multiple=!1;const i=setTimeout(()=>a.remove(),5e3);a.onchange=s=>{var y;clearTimeout(i);const k=(y=s.target)==null?void 0:y.files;k&&k.length>0&&e(k),a.remove()},a.oncancel=()=>{clearTimeout(i),a.remove()},a.click()}function be(e){const n=e.getLexicalEditor();n&&(n.update(()=>{const a=g(),i=b(),s=a.getFirstChild();s?s.insertBefore(i):a.append(i),i.selectStart()}),e.focus())}function fe(e){const n=e.getLexicalEditor();n&&(n.update(()=>{const a=g(),i=b();a.append(i),i.selectStart()}),e.focus())}function M(e,n){return[{active:e.isBold,icon:B,key:"bold",label:"Bold",onClick:e.bold,tooltipProps:{hotkey:c(l.Bold).keys}},{active:e.isItalic,icon:X,key:"italic",label:"Italic",onClick:e.italic,tooltipProps:{hotkey:c(l.Italic).keys}},{active:e.isUnderline,icon:ue,key:"underline",label:"Underline",onClick:e.underline,tooltipProps:{hotkey:c(l.Underline).keys}},{active:e.isStrikethrough,icon:ye,key:"strikethrough",label:"Strikethrough",onClick:e.strikethrough,tooltipProps:{hotkey:c(l.Strikethrough).keys}},{type:"divider"},{active:!!e.textColor,editor:n,key:"textColor",label:"Text Color",onChange:e.setTextColor,type:"colorPicker",value:e.textColor},{active:!!e.bgColor,defaultColor:"#ffffff",editor:n,icon:D,key:"bgColor",label:"Background Color",onChange:e.setBgColor,type:"colorPicker",value:e.bgColor}]}const qe=({editor:e,floating:n,outlineCollapseTitle:a,outlineExpandTitle:i,outlineToggle:s,style:k,className:y})=>{const t=_(e),d=C({collapseTitle:a,expandTitle:i}),f=u.useMemo(()=>[{disabled:!t.canUndo,icon:Me,key:"undo",label:"Undo",onClick:t.undo,tooltipProps:{hotkey:c(l.Undo).keys}},{disabled:!t.canRedo,icon:ce,key:"redo",label:"Redo",onClick:t.redo,tooltipProps:{hotkey:c(l.Redo).keys}},{icon:V,key:"insertLineTop",label:"Insert line at top",onClick:()=>be(e)},{icon:H,key:"insertLineBottom",label:"Insert line at end",onClick:()=>fe(e)},{type:"divider"},...M(t,e),{type:"divider"},{icon:ee,key:"bulletList",label:"Bullet List",onClick:t.bulletList,tooltipProps:{hotkey:c(l.BulletList).keys}},{icon:K,key:"numberlist",label:"Number list",onClick:t.numberList,tooltipProps:{hotkey:c(l.NumberList).keys}},{icon:Y,key:"tasklist",label:"Task list",onClick:t.checkList},{type:"divider"},{active:t.isBlockquote,icon:te,key:"blockquote",label:"Blockquote",onClick:t.blockquote},{icon:v,key:"link",label:"Link",onClick:t.insertLink,tooltipProps:{hotkey:c(l.Link).keys}},{icon:se,key:"math",label:"TeX",onClick:t.insertMath},{type:"divider"},{active:t.isCode,icon:A,key:"code",label:"Code",onClick:t.code,tooltipProps:{hotkey:c(l.CodeInline).keys}},{active:t.isCodeblock,icon:he,key:"codeblock",label:"Codeblock",onClick:t.codeblock},t.isCodeblock&&{children:r.jsx(N,{onSelect:h=>{console.log(h),t.updateCodeblockLang(h)},value:t.codeblockLang}),disabled:!t.isCodeblock,key:"codeblockLang"},{type:"divider"},{icon:G,key:"image",label:"Image",onClick:()=>{m(h=>{for(const p of h)e.dispatchCommand(L,{file:p})},"image/*")}},{icon:E,key:"file",label:"File",onClick:()=>{m(h=>{for(const p of h)e.dispatchCommand(j,{file:p})})}},...s&&d?[{type:"divider"},d]:[]].filter(Boolean),[e,t,d,s]),x=u.useMemo(()=>[...M(t,e),...s&&d?[{type:"divider"},d]:[]],[e,t,d,s]);return n?r.jsx(z,{items:x}):r.jsx("div",{className:["mdocs-toolbar",y].filter(Boolean).join(" "),style:k,children:r.jsx(w,{items:f})})};export{Ne as H,ze as M,we as N,se as S,$e as T,He as W,Le as a,je as b,qe as c,m as o};
@@ -0,0 +1 @@
1
+ import{r,j as e}from"./react-vendor-BNpqFP9B.js";import{b as G,B as ee,f as se,w as z}from"./index-C46BU1-j.js";function ie({options:v,value:a,onChange:b}){const[d,f]=r.useState(!1),y=r.useRef(null),x=r.useRef(null),p=v.find(o=>o.value===a);r.useEffect(()=>{if(!d)return;const o=u=>{var N,k;!((N=y.current)!=null&&N.contains(u.target))&&!((k=x.current)!=null&&k.contains(u.target))&&f(!1)};return document.addEventListener("mousedown",o),()=>document.removeEventListener("mousedown",o)},[d]),r.useEffect(()=>{if(!d)return;const o=u=>{var N;u.key==="Escape"&&(f(!1),(N=y.current)==null||N.focus())};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[d]);function j(o){b(o),f(!1)}return e.jsxs("div",{className:"mdocs-mini-select",style:{position:"relative"},children:[e.jsxs("button",{ref:y,type:"button",className:"mdocs-mini-select-trigger","aria-expanded":d,"aria-haspopup":"listbox",onClick:()=>f(o=>!o),children:[e.jsx("span",{children:p==null?void 0:p.label}),e.jsx("svg",{className:"mdocs-mini-select-chevron"+(d?" open":""),width:"10",height:"6",viewBox:"0 0 10 6",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{d:"M1 1l4 4 4-4"})})]}),d&&e.jsx("div",{ref:x,className:"mdocs-mini-select-menu card",role:"listbox",children:v.map(o=>e.jsx("button",{type:"button",className:"mdocs-mini-select-option"+(o.value===a?" active":""),role:"option","aria-selected":o.value===a,onClick:()=>j(o.value),children:o.label},o.value))})]})}function te(v){return v.length<=6?v:`${v.slice(0,6)}…`}function re(v){const{visitors:a,loadState:b,searchFilter:d,onSearchChange:f,selectedIds:y,onToggle:x,selectedRows:p,lockedIds:j=new Set,myVisitorId:o,showPermissionSelect:u=!1,permissionOptions:N=[],onPermissionChange:k}=v,{t:i}=G(),w=r.useMemo(()=>{const t=d.trim().toLowerCase();let g=t?a.filter(m=>m.visitorName.toLowerCase().includes(t)||m.visitorId.toLowerCase().includes(t)):a;return o&&(g=[...g].sort((m,R)=>m.visitorId===o?-1:R.visitorId===o?1:0)),g},[a,d,o]);return e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"search",className:"mdocs-visitor-picker-search",placeholder:i("visitorPickerSearchPlaceholder"),value:d,onChange:t=>f(t.target.value),disabled:b!=="ok"}),b==="loading"&&e.jsx("div",{className:"mdocs-visitor-picker-loading",children:i("loading")}),b==="err"&&e.jsx("div",{className:"mdocs-visitor-picker-error",children:i("visitorPickerLoadError")}),b==="ok"&&e.jsxs("div",{className:"mdocs-visitor-picker-columns",children:[e.jsxs("div",{className:"mdocs-visitor-picker-col",children:[e.jsx("h3",{className:"mdocs-visitor-picker-col-title",children:i("visitorPickerColumnAll")}),e.jsx("div",{className:"mdocs-visitor-picker-table-wrap",children:e.jsxs("table",{className:"mdocs-visitor-picker-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:i("visitorPickerColIdShort")}),e.jsx("th",{scope:"col",children:i("visitorPickerColName")}),e.jsx("th",{scope:"col",className:"mdocs-visitor-picker-check-col",children:i("visitorPickerColPick")})]})}),e.jsx("tbody",{children:w.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:3,className:"mdocs-visitor-picker-empty-cell",children:a.length===0?i("visitorPickerEmptyDirectory"):i("domainNoMatch")})}):w.map(t=>{const g=j.has(t.visitorId),m=y.has(t.visitorId);return e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("code",{className:"mdocs-visitor-picker-id-short",children:te(t.visitorId)})}),e.jsxs("td",{children:[t.visitorName,t.visitorId===o&&e.jsx("span",{className:"mdocs-visitor-picker-self-marker",children:i("visitorPickerSelfMarker")})]}),e.jsx("td",{className:"mdocs-visitor-picker-check-col",children:e.jsx("input",{type:"checkbox",checked:m,disabled:g,onChange:()=>x(t.visitorId),"aria-label":t.visitorName})})]},t.visitorId)})})]})})]}),e.jsxs("div",{className:"mdocs-visitor-picker-col",children:[e.jsx("h3",{className:"mdocs-visitor-picker-col-title",children:i("visitorPickerColumnSelected")}),e.jsx("div",{className:"mdocs-visitor-picker-table-wrap",children:e.jsxs("table",{className:"mdocs-visitor-picker-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:i("visitorPickerColIdFull")}),e.jsx("th",{scope:"col",children:i("visitorPickerColName")}),u&&e.jsx("th",{scope:"col",children:i("permissionLabel")}),e.jsx("th",{scope:"col",className:"mdocs-visitor-picker-check-col"})]})}),e.jsx("tbody",{children:p.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:u?4:3,className:"mdocs-visitor-picker-empty-cell",children:i("visitorPickerNoSelection")})}):p.map(t=>{const g=j.has(t.visitorId);return e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("code",{className:"mdocs-visitor-picker-id-full",children:t.visitorId})}),e.jsx("td",{className:t.muted?"mdocs-visitor-picker-name-muted":void 0,children:t.name}),u&&e.jsx("td",{children:e.jsx(ie,{options:N,value:t.permission??"read",onChange:m=>k==null?void 0:k(t.visitorId,m)})}),e.jsx("td",{className:"mdocs-visitor-picker-check-col",children:g?e.jsx("span",{className:"mdocs-visitor-picker-locked",title:i("visitorPickerLockedHint"),children:"—"}):e.jsx("button",{type:"button",className:"mdocs-visitor-picker-remove",onClick:()=>x(t.visitorId),"aria-label":i("visitorPickerRemove"),children:"×"})})]},t.visitorId)})})]})})]})]})]})}function ne(v){var U;const{open:a,title:b,initialSelectedIds:d,lockedIds:f=[],seedMembers:y,excludeTemplateId:x,templates:p,onClose:j,onConfirm:o,showPermissionSelect:u=!1,permissionOptions:N=[],initialPermissions:k}=v,{t:i}=G(),w=r.useRef(i);w.current=i;const t=r.useMemo(()=>new Set(f),[f]),g=ee(),[m,R]=r.useState([]),[E,T]=r.useState("idle"),[P,V]=r.useState(()=>new Set),[O,L]=r.useState(()=>new Map),[J,F]=r.useState(""),[C,A]=r.useState(""),[M,B]=r.useState(!1),$=r.useRef(null),[K,W]=r.useState(!1),[q,I]=r.useState(null),D=r.useMemo(()=>p.filter(s=>x==null||s.id!==x),[p,x]),H=r.useMemo(()=>new Map((y??[]).map(s=>[s.visitorId,s])),[y]);r.useEffect(()=>{a&&(V(new Set(d)),L(k?new Map(k):new Map),F(""),A(""),I(null))},[a,d,k]),r.useEffect(()=>{if(!a)return;let s=!1;return T("loading"),se().then(n=>{s||(R(n),T("ok"))}).catch(n=>{s||(T("err"),I(z(w.current,n)))}),()=>{s=!0}},[a]),r.useEffect(()=>{if(!M)return;const s=n=>{var c;(c=$.current)!=null&&c.contains(n.target)||B(!1)};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[M]);const Q=r.useMemo(()=>{const s=new Map(m.map(c=>[c.visitorId,c])),n=[];for(const c of P){const l=O.get(c),h=s.get(c);if(h){n.push({visitorId:c,name:h.visitorName,muted:!1,permission:l});continue}const S=H.get(c);if(S){S.missing?n.push({visitorId:c,name:i("visitorPickerMemberMissing"),muted:!0,permission:l}):S.disabled?n.push({visitorId:c,name:`${S.visitorName} · ${i("visitorPickerDisabledTag")}`,muted:!0,permission:l}):n.push({visitorId:c,name:S.visitorName,muted:!1,permission:l});continue}n.push({visitorId:c,name:i("visitorPickerUnknownVisitor"),muted:!0,permission:l})}return n.sort((c,l)=>c.name.localeCompare(l.name,void 0,{sensitivity:"base"})),n},[m,P,H,O,i]),X=r.useCallback(s=>{t.has(s)||V(n=>{const c=new Set(n);return c.has(s)?(c.delete(s),L(l=>{const h=new Map(l);return h.delete(s),h})):(c.add(s),L(l=>{const h=new Map(l);return h.set(s,"read"),h})),c})},[t]),Y=r.useCallback((s,n)=>{L(c=>{const l=new Map(c);return l.set(s,n),l})},[]),Z=r.useCallback(()=>{const s=Number(C);if(!Number.isInteger(s)||s<1)return;const n=p.find(l=>l.id===s);if(!n)return;const c=new Set(m.map(l=>l.visitorId));V(l=>{const h=new Set(l);for(const S of n.visitorIds)c.has(S)&&h.add(S);return h})},[C,p,m]);async function _(){I(null),W(!0);try{if(u){const s=[...P].sort().map(n=>({visitorId:n,permission:O.get(n)??"read"}));await o(s)}else{const s=[...P].sort();await o(s)}j()}catch(s){I(z(i,s))}finally{W(!1)}}return a?e.jsx("div",{className:"mdocs-visitor-picker-overlay",role:"presentation",onMouseDown:s=>s.target===s.currentTarget&&j(),children:e.jsxs("div",{className:"mdocs-visitor-picker-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"mdocs-visitor-picker-title",children:[e.jsxs("header",{className:"mdocs-visitor-picker-header",children:[e.jsx("h2",{id:"mdocs-visitor-picker-title",className:"mdocs-visitor-picker-title",children:b}),e.jsx("button",{type:"button",className:"mdocs-visitor-picker-close",onClick:j,"aria-label":i("close"),children:"×"})]}),D.length>0&&e.jsx("div",{className:"mdocs-visitor-picker-toolbar",children:e.jsxs("div",{className:"mdocs-visitor-picker-template-bar",children:[e.jsxs("div",{ref:$,className:"mdocs-template-picker",children:[e.jsxs("button",{type:"button",className:"mdocs-template-picker-trigger",onClick:()=>B(s=>!s),disabled:E!=="ok","aria-haspopup":"listbox","aria-expanded":M,children:[e.jsx("span",{className:"mdocs-template-picker-text",children:C?(U=D.find(s=>String(s.id)===C))==null?void 0:U.displayName:i("visitorPickerPickTemplate")}),e.jsx("svg",{className:"mdocs-template-picker-chevron"+(M?" open":""),width:"10",height:"6",viewBox:"0 0 10 6",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{d:"M1 1l4 4 4-4"})})]}),M&&e.jsx("div",{className:"mdocs-template-picker-menu card",role:"listbox",children:D.map(s=>e.jsx("button",{type:"button",className:"mdocs-template-picker-option"+(String(s.id)===C?" active":""),role:"option","aria-selected":String(s.id)===C,onClick:()=>{A(String(s.id)),B(!1)},children:s.displayName},s.id))})]}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>{if(E!=="ok"){I(i("loading"));return}if(!C){I(i("visitorPickerPickTemplate"));return}Z()},children:i("visitorPickerApplyTemplate")})]})}),q&&e.jsx("div",{className:"mdocs-visitor-picker-error",role:"alert",children:q}),e.jsx("div",{style:{padding:"8px 18px 12px"},children:e.jsx(re,{visitors:m,loadState:E,searchFilter:J,onSearchChange:F,selectedIds:P,onToggle:X,selectedRows:Q,lockedIds:t,myVisitorId:g,showPermissionSelect:u,permissionOptions:N,onPermissionChange:Y})}),e.jsxs("footer",{className:"mdocs-visitor-picker-footer",children:[e.jsx("button",{type:"button",className:"secondary",onClick:j,children:i("cancel")}),e.jsx("button",{type:"button",className:"primary",onClick:()=>{if(E!=="ok"){I(i("loading"));return}_()},children:i(K?"saving":"visitorPickerConfirm")})]})]})}):null}export{ie as M,ne as V,re as a};
@@ -0,0 +1,11 @@
1
+ import{c}from"./index-C46BU1-j.js";/**
2
+ * @license lucide-react v0.562.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const e=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],a=c("check",e);/**
7
+ * @license lucide-react v0.562.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const o=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],h=c("copy",o);export{a as C,h as a};