finch-markdown-editor 0.1.8 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/panel.js ADDED
@@ -0,0 +1,43 @@
1
+ "use strict";(()=>{(function(){"use strict";var i=window.finch,qe=/^zh/i.test(navigator.language||""),We={zh:{"meta.title":"\u516C\u4F17\u53F7\u6587\u7AE0\u9884\u89C8","home.title":"\u5199\u5B57","home.tagline.withAssistant":"\u4F60\u4E0E{name}\u4E00\u8D77\u7F16\u6392 Markdown \u6587\u4EF6","home.tagline.default":"\u6253\u5F00\u4E00\u4E2A Markdown \u6587\u4EF6\u5F00\u59CB\u7F16\u8F91\u4E0E\u9884\u89C8\uFF0C\u6216\u65B0\u5EFA\u4E00\u7BC7\u6587\u7AE0\u3002","home.openFile":"\u6253\u5F00\u6587\u4EF6","home.newDoc":"\u65B0\u5EFA\u6587\u6863","home.recentLabel":"\u6700\u8FD1\u7F16\u8F91","home.hintScoped":"\u8FD9\u4E2A\u76EE\u5F55\u91CC\u8FD8\u6CA1\u6709\u7528\u7F16\u8F91\u5668\u6253\u5F00\u8FC7\u7684 Markdown \u6587\u6863\u3002","home.hintDefault":"\u6253\u5F00\u4E00\u4E2A Markdown \u6587\u4EF6\uFF0C\u4E4B\u540E\u8FD9\u91CC\u4F1A\u5217\u51FA\u6700\u8FD1\u7F16\u8F91\u7684\u6587\u6863\u3002","home.untitled":"\u672A\u547D\u540D","home.revealInFileManager":"\u5728\u6587\u4EF6\u7BA1\u7406\u5668\u4E2D\u5B9A\u4F4D","home.emptyDoc":"\uFF08\u7A7A\u6587\u6863\uFF09","home.cwdTitle":"\u5728\u8BBF\u8FBE / \u6587\u4EF6\u8D44\u6E90\u7BA1\u7406\u5668\u4E2D\u6253\u5F00\uFF1A{path}","home.cwdFallback":"homePath\uFF08\u65E0 cwd \u56DE\u9000\uFF09","home.today":"\u4ECA\u5929 {clock}","home.yesterday":"\u6628\u5929 {clock}","appview.library":"\u8D44\u6599\u5E93","appview.libraryHint":"\u6240\u6709\u7A7A\u95F4\u7684\u6700\u8FD1\u6587\u6863","appview.libraryWorkspace":"\u5DE5\u4F5C\u95F4\u6587\u4EF6","appview.libraryOther":"\u5176\u4ED6","appview.rewrite":"\u6539\u5199","appview.focus":"\u4E13\u6CE8","appview.openSession":"\u6253\u5F00\u6539\u5199\u4F1A\u8BDD","appview.rewriting":"\u5DF2\u53D1\u8D77\u6539\u5199\uFF0C\u4F1A\u8BDD\u6B63\u5728\u5904\u7406\u5E76\u5C06\u76F4\u63A5\u5199\u56DE\u6587\u4EF6\u3002","appview.continuing":"\u5DF2\u53D1\u8D77\u7EED\u5199\uFF0C\u4F1A\u8BDD\u6B63\u5728\u5904\u7406\u5E76\u5C06\u76F4\u63A5\u5199\u56DE\u6587\u4EF6\u3002","appview.hintSpace":"\u6309 space\uFF08\u7A7A\u683C\uFF09\u4EE5\u542F\u7528 AI \xB7 \u6309 / \u9009\u62E9\u683C\u5F0F","appview.hintSpaceCode":"\u6309 space\uFF08\u7A7A\u683C\uFF09\u4EE5\u542F\u7528 AI","appview.rewriteDone":"\u6539\u5199\u5DF2\u5B8C\u6210\uFF0C\u6587\u4EF6\u5185\u5BB9\u5DF2\u5237\u65B0\u3002","editor.ariaLabel":"\u5199\u5B57\u7F16\u8F91\u5668","actions.copyToWx":"\u590D\u5236\u5230\u516C\u4F17\u53F7","actions.copyImg":"\u590D\u5236\u56FE\u7247","actions.exportImg":"\u5BFC\u51FA\u56FE\u7247\uFF08\u4E0B\u8F7D\uFF09","actions.exportPdf":"\u5BFC\u51FA PDF","actions.aiStyle":"\u8BA9 AI \u8BBE\u8BA1\u6392\u7248","actions.toggle":"\u5C55\u5F00/\u6536\u8D77","popup.placeholder":"\u8BA9 {name} \u7F16\u8F91","popup.placeholderContinue":"\u8BA9 {name} \u4ECE\u8FD9\u91CC\u7EED\u5199\u2026","popup.send":"\u53D1\u9001","confirm.cancel":"\u53D6\u6D88","confirm.discard":"\u4E0D\u4FDD\u5B58","confirm.save":"\u4FDD\u5B58\u5E76\u8FD4\u56DE","confirm.message":"\u300C{file}\u300D\u8FD8\u6709\u672A\u4FDD\u5B58\u7684\u6539\u52A8\uFF0C\u8981\u4FDD\u5B58\u540E\u518D\u8FD4\u56DE\u9996\u9875\u5417\uFF1F","common.markdownDocDefault":"Markdown \u6587\u6863","common.customStyleDefault":"\u81EA\u5B9A\u4E49\u98CE\u683C","toolbar.home.tooltip":"\u8FD4\u56DE\u9996\u9875","toolbar.open.tooltipDefault":"\u6253\u5F00 Markdown \u6587\u4EF6","toolbar.save.label":"\u4FDD\u5B58","toolbar.save.tooltipDefault":"\u4FDD\u5B58\uFF08\u2318/Ctrl+S\uFF09","toolbar.save.tooltipDirty":"\u6709\u672A\u4FDD\u5B58\u7684\u6539\u52A8\uFF08\u2318/Ctrl+S\uFF09","toolbar.save.labelSaved":"\u5DF2\u4FDD\u5B58","toolbar.save.tooltipSaved":"\u5DF2\u4FDD\u5B58","toolbar.annotate.label":"\u6279\u6CE8","toolbar.annotate.tooltipOn":"\u6279\u6CE8\u5DF2\u5F00\u542F\uFF1A\u9009\u4E2D\u6587\u5B57\u53EF\u53D1\u8D77 AI \u4FEE\u6539","toolbar.annotate.tooltipOff":"\u5F00\u542F\u6279\u6CE8\uFF1A\u9009\u4E2D\u6587\u5B57\u540E\u53EF\u53D1\u8D77 AI \u4FEE\u6539","toolbar.needDoc":"\u8BF7\u5148\u6253\u5F00\u6587\u6863","toolbar.mode.label":"\u9884\u89C8","toolbar.mode.tooltipToPreview":"\u5207\u6362\u5230\u9884\u89C8","toolbar.mode.tooltipToEdit":"\u5207\u6362\u5230\u7F16\u8F91","toolbar.mode.tooltipRendering":"\u6B63\u5728\u6E32\u67D3\u9884\u89C8\u2026","toolbar.style.tooltip":"\u6392\u7248\u98CE\u683C","toolbar.style.tooltipNeedsPreview":"\u8BF7\u5148\u5207\u6362\u5230\u9884\u89C8","toolbar.style.customSlot":"\u81EA\u5B9A\u4E49\u98CE\u683C {n} \xB7 {label}","toolbar.style.customSlotEmpty":"\u81EA\u5B9A\u4E49\u98CE\u683C {n}\uFF08\u7A7A\uFF09","toolbar.fontSize.tooltipPreview":"\u9884\u89C8\u65F6\u4E0D\u53EF\u66F4\u6539\u5B57\u4F53","toolbar.fontSize.tooltipEdit":"\u7F16\u8F91\u5668\u5B57\u4F53\u5927\u5C0F","toolbar.fontSize.small":"\u5C0F","toolbar.fontSize.medium":"\u4E2D","toolbar.fontSize.large":"\u5927","toolbar.fontFamily.default":"\u9ED8\u8BA4\uFF08\u65E0\u886C\u7EBF\uFF09","toolbar.fontFamily.serif":"\u886C\u7EBF\u4F53","toolbar.comfort.read":"\u7D27\u51D1","toolbar.comfort.write":"\u8212\u9002","toolbar.focus.tooltipOn":"\u4E13\u6CE8\u5DF2\u5F00\u542F\uFF1A\u975E\u5F53\u524D\u884C\u534A\u900F\u660E","toolbar.focus.tooltipOff":"\u5F00\u542F\u4E13\u6CE8\uFF1A\u975E\u5F53\u524D\u884C\u534A\u900F\u660E","toolbar.more.reload":"\u91CD\u65B0\u6E32\u67D3","toolbar.more.reveal":"\u5728\u6587\u4EF6\u7BA1\u7406\u5668\u4E2D\u5B9A\u4F4D","toolbar.more.about":"\u5173\u4E8E\u6E32\u67D3","toolbar.more.tooltip":"\u66F4\u591A","annotate.lineUnknown":"\uFF08\u672A\u80FD\u7CBE\u786E\u5B9A\u4F4D\u5BF9\u5E94\u884C\u53F7\uFF0C\u8BF7\u4EE5\u4E0B\u65B9\u5F15\u7528\u6587\u672C\u4E3A\u51C6\uFF09","annotate.lineSingle":"\u7B2C {a} \u884C","annotate.lineRange":"\u7B2C {a}\u2013{b} \u884C","annotate.lineCompactUnknown":"\u672A\u5B9A\u4F4D","annotate.requirementWith":"\u8981\u6C42\uFF1A{comment}","annotate.requirementDefault":"\u8BA9\u8868\u8FBE\u66F4\u6E05\u6670","annotate.pathMissing":"\uFF08\u672A\u5173\u8054\u672C\u5730\u6587\u4EF6\uFF0C\u8BF7\u5148\u7C98\u8D34/\u4FDD\u5B58\u5168\u90E8\u5185\u5BB9\uFF09","annotate.emptyLine":"\uFF08\u7A7A\u884C\uFF1A\u8BF7\u6309\u6279\u6CE8\u8981\u6C42\u5728\u6B64\u5904\u8865\u5145\u6216\u7EED\u5199\u5185\u5BB9\uFF09","annotate.promptText":`\u8BF7\u6539\u5199\u8FD9\u6BB5 Markdown \u5185\u5BB9\uFF08\u4F4D\u7F6E\uFF1A{lineLabel}\uFF09\uFF0C{requirement}\uFF1A
2
+
3
+ {text}
4
+
5
+ \u5148\u7ED9\u51FA\u53EF\u76F4\u63A5\u66FF\u6362\u7684\u7247\u6BB5\uFF1B\u6211\u786E\u8BA4\u540E\uFF0C\u7528\u9488\u5BF9\u8FD9\u4E00\u6BB5\u7684\u5C40\u90E8\u66FF\u6362\u5199\u56DE\u6E90\u6587\u4EF6\uFF08{path}\uFF09\uFF0C\u4E0D\u7528\u91CD\u53D1\u5168\u6587\u3002`,"annotate.reminder":"\u4EC5\u7ED9\u51FA\u6539\u5199\u5EFA\u8BAE\uFF0C\u4E0D\u8981\u5728\u672A\u786E\u8BA4\u524D\u76F4\u63A5\u5199\u5165\u6E90\u6587\u4EF6\u3002\u56DE\u590D\u7528\u81EA\u7136\u7684\u8BF4\u6CD5\uFF08\u5982\u201C\u786E\u8BA4\u540E\u6211\u5C31\u6539\u5230\u6587\u4EF6\u91CC\u201D\uFF09\uFF0C\u4E0D\u8981\u63D0\u5DE5\u5177\u540D\u6216\u52A8\u4F5C\u540D\u3002\u3010\u5F3A\u5236\u8981\u6C42\uFF0C\u4E0D\u53EF\u7701\u7565\u3011\u53EA\u8981\u672C\u56DE\u5408\u7ED9\u51FA\u4E86\u6539\u5199\u5EFA\u8BAE\u5E76\u7B49\u6211\u786E\u8BA4\uFF0C\u5C31\u5FC5\u987B\u5728\u56DE\u590D\u6587\u672C\u4E4B\u540E\u3001\u672C\u56DE\u5408\u7ED3\u675F\u524D\u8C03\u7528\u4E00\u6B21 Session action=suggest\uFF0C\u9644\u4E0A 1\u20133 \u4E2A\u4E00\u952E\u786E\u8BA4\u9009\u9879\uFF08\u5982\u201C\u5C31\u7528\u8FD9\u7248\u201D\u201C\u7528\u66F4\u77ED\u7684\u90A3\u7248\u201D\u201C\u518D\u6362\u4E2A\u8BED\u6C14\u201D\uFF09\u3002\u53EA\u5199\u5B8C\u56DE\u590D\u6587\u5B57\u3001\u4E0D\u8C03\u7528 suggest\uFF0C\u89C6\u4E3A\u4EFB\u52A1\u672A\u5B8C\u6210\u2014\u2014\u201C\u628A\u65B9\u6848\u5199\u7ED9\u7528\u6237\u770B\u201D\u548C\u201C\u8BA9\u7528\u6237\u80FD\u4E00\u952E\u786E\u8BA4\u201D\u662F\u540C\u4E00\u4E2A\u4EFB\u52A1\u7684\u4E24\u534A\uFF0C\u7F3A\u4E00\u4E0D\u53EF\uFF0C\u4E0D\u8981\u56E0\u4E3A\u6587\u5B57\u5DF2\u7ED9\u5B8C\u5C31\u8BA4\u4E3A\u786E\u8BA4\u73AF\u8282\u5DF2\u7ECF\u5904\u7406\u5B8C\u6BD5\u3002","newdoc.needChat":"\u8BF7\u5728 Finch \u5BF9\u8BDD\u4E2D\u4F7F\u7528\u201C\u65B0\u5EFA\u6587\u6863\u201D\u3002","newdoc.label":"\u65B0\u5EFA Markdown \u6587\u6863","newdoc.promptText":"\u6211\u60F3\u65B0\u5EFA\u4E00\u7BC7 Markdown \u6587\u6863\u3002\u8BF7\u5148\u6839\u636E\u6211\u7684\u8981\u6C42\u786E\u5B9A\u6807\u9898\u3001\u5185\u5BB9\u4E0E\u4E00\u4E2A\u5C1A\u4E0D\u5B58\u5728\u7684\u7EDD\u5BF9\u4FDD\u5B58\u8DEF\u5F84\uFF1B\u4FE1\u606F\u4E0D\u8DB3\u65F6\u5148\u95EE\u6211\u3002\u786E\u8BA4\u540E\u628A\u5B8C\u6574\u6B63\u6587\u5199\u5165\u90A3\u4E2A\u8DEF\u5F84\uFF0C\u5E76\u5728\u7F16\u8F91\u5668\u4E2D\u6253\u5F00\u8FD9\u7BC7\u65B0\u6587\u6863\u3002","newdoc.reminder":"\u53EA\u80FD\u65B0\u5EFA\u6587\u4EF6\uFF0C\u4E0D\u8981\u8986\u76D6\u5DF2\u6709\u6587\u4EF6\u3002\u56DE\u590D\u7528\u81EA\u7136\u7684\u8BF4\u6CD5\uFF0C\u4E0D\u8981\u63D0\u5DE5\u5177\u540D\u6216\u52A8\u4F5C\u540D\u3002\u3010\u5F3A\u5236\u8981\u6C42\uFF0C\u4E0D\u53EF\u7701\u7565\u3011\u53EA\u8981\u672C\u56DE\u5408\u9700\u8981\u6211\u786E\u8BA4\u6807\u9898\u3001\u65B9\u5411\u6216\u4FDD\u5B58\u4F4D\u7F6E\uFF0C\u5C31\u5FC5\u987B\u5728\u56DE\u5408\u7ED3\u675F\u524D\u8C03\u7528\u4E00\u6B21 Session action=suggest\uFF0C\u7ED9\u51FA 1\u20133 \u4E2A\u4E00\u952E\u9009\u9879\uFF0C\u4E0D\u8981\u8BA9\u6211\u624B\u6253\u3002\u5149\u5728\u6587\u5B57\u91CC\u95EE\u95EE\u9898\u800C\u4E0D\u8C03 suggest\uFF0C\u89C6\u4E3A\u8FD9\u6B21\u8BE2\u95EE\u6CA1\u5B8C\u6210\u3002","newdoc.added":"\u5DF2\u628A\u65B0\u5EFA\u6587\u6863\u5F15\u5BFC\u52A0\u5165\u8F93\u5165\u6846\u3002","aiStyle.label":"\u6839\u636E {file} \u8BBE\u8BA1\u98CE\u683C","aiStyle.note":"AI \u4E00\u952E\u6392\u7248","aiStyle.baseNoteCustom":"\u5F53\u524D\u57FA\u7840\u98CE\u683C\u662F kami\uFF08\u81EA\u5B9A\u4E49 CSS \u53E0\u52A0\u5176\u4E0A\uFF09","aiStyle.baseNoteOther":"\u5F53\u524D\u57FA\u7840\u98CE\u683C\u662F {style}","aiStyle.pathMissing":"\uFF08\u672A\u5173\u8054\u672C\u5730\u6587\u4EF6\uFF09","aiStyle.promptText":"\u8BF7\u4E3A\u8FD9\u7BC7\u516C\u4F17\u53F7\u6587\u7AE0\u8BBE\u8BA1\u4E00\u5957\u81EA\u5B9A\u4E49\u6392\u7248 CSS\u3002{baseNote}\uFF0C\u4F60\u7684 CSS \u4F1A\u53E0\u52A0\u5728\u57FA\u7840\u98CE\u683C\u4E4B\u4E0A\u3002\u8981\u6C42\uFF1A\u53EA\u5199\u666E\u901A CSS \u89C4\u5219\uFF0C\u9009\u62E9\u5668\u9650\u5B9A\u5728 #bm-md \u4E0B\u7684\u6807\u7B7E/\u7ED3\u6784\uFF08\u5982 #bm-md h1\u3001#bm-md p\u3001#bm-md blockquote\u3001#bm-md pre code\u3001#bm-md a\u3001#bm-md strong\u3001#bm-md table \u7B49\uFF09\uFF0C\u4E0D\u8981\u4F7F\u7528 class\uFF08bm.md \u8F93\u51FA\u6CA1\u6709 class\uFF0C\u53EA\u6709\u5185\u8054\u6837\u5F0F\uFF09\uFF0C\u5FC5\u8981\u65F6\u7528 !important \u8986\u76D6\u57FA\u7840\u98CE\u683C\u3002\u53EF\u53C2\u8003 bm.md \u5185\u7F6E\u98CE\u683C\u7684\u8BBE\u8BA1\u8BED\u8A00\uFF1Akami\uFF08\u6696\u8272\u7EB8\u611F\uFF09\u3001bauhaus\uFF08\u51E0\u4F55\u649E\u8272\uFF09\u3001blueprint\uFF08\u6280\u672F\u84DD\u56FE\u7F51\u683C\uFF09\u3001botanical\uFF08\u6E05\u65B0\u7EFF\u610F\uFF09\u3001newsprint\uFF08\u62A5\u520A\u886C\u7EBF\uFF09\u3001retro\uFF08\u590D\u53E4\u6000\u65E7\uFF09\u3001sketch\uFF08\u624B\u7ED8\u98CE\uFF09\u3001terminal\uFF08\u7B49\u5BBD\u6697\u8272\u7EC8\u7AEF\u98CE\uFF09\u3002\u6587\u7AE0\u8DEF\u5F84\uFF1A{path}\u3002\u52A8\u624B\u751F\u6210 CSS \u524D\uFF0C\u5148\u8BE2\u95EE\u7528\u6237\u8981\u8986\u76D6\u300C\u81EA\u5B9A\u4E49\u98CE\u683C 1\u30012\u30013\u300D\u4E2D\u7684\u54EA\u4E00\u4E2A\u69FD\u4F4D\uFF1B\u7528\u6237\u9009\u62E9\u540E\uFF0C\u518D\u628A\u8BBE\u8BA1\u597D\u7684 CSS \u5E94\u7528\u5230\u90A3\u4E2A\u69FD\u4F4D\uFF08\u9700\u8981 css\u3001\u7B80\u77ED\u6807\u7B7E\u548C\u69FD\u4F4D\u7F16\u53F7 1/2/3\uFF09\u3002\u8FD9\u4F1A\u8986\u76D6\u5E76\u6301\u4E45\u5316\u90A3\u4E2A\u69FD\u4F4D\uFF0C\u540C\u65F6\u7ACB\u5373\u5E94\u7528\u5230\u9884\u89C8\u3002","aiStyle.reminder":"\u5FC5\u987B\u5148\u8BE2\u95EE\u69FD\u4F4D\uFF0C\u4E0D\u80FD\u81EA\u884C\u731C\u6D4B\u6216\u8986\u76D6\uFF1B\u7528\u6237\u660E\u786E\u9009\u5B9A 1/2/3 \u540E\u624D\u5E94\u7528\u3002\u56DE\u590D\u7528\u81EA\u7136\u7684\u8BF4\u6CD5\uFF0C\u4E0D\u8981\u63D0\u5DE5\u5177\u540D\u6216\u52A8\u4F5C\u540D\u3002\u3010\u5F3A\u5236\u8981\u6C42\uFF0C\u4E0D\u53EF\u7701\u7565\u3011\u8BE2\u95EE\u69FD\u4F4D\u65F6\u5FC5\u987B\u5728\u56DE\u5408\u7ED3\u675F\u524D\u8C03\u7528\u4E00\u6B21 Session action=suggest\uFF0C\u7ED9\u51FA\u201C\u7528\u81EA\u5B9A\u4E49\u98CE\u683C 1/2/3\u201D\u4E09\u4E2A\u4E00\u952E\u9009\u9879\uFF0C\u4E0D\u8981\u8BA9\u6211\u624B\u6253\u3002\u53EA\u5728\u6587\u5B57\u91CC\u95EE\u9009\u54EA\u4E2A\u69FD\u4F4D\u3001\u4E0D\u8C03 suggest\uFF0C\u89C6\u4E3A\u8BE2\u95EE\u672A\u5B8C\u6210\u3002","aiStyle.requested":"\u5DF2\u8BF7\u6C42 AI \u8BBE\u8BA1\u81EA\u5B9A\u4E49\u6392\u7248\u3002","status.saved":"\u5DF2\u4FDD\u5B58\u3002","status.savedWithNewChanges":"\u5DF2\u4FDD\u5B58\uFF0C\u7F16\u8F91\u5668\u4E2D\u4ECD\u6709\u65B0\u6539\u52A8\u3002","status.saveFailed":"\u4FDD\u5B58\u5931\u8D25\uFF1A{err}","status.saving":"\u6B63\u5728\u4FDD\u5B58\u2026","status.noSourceFile":"\u672A\u5173\u8054\u672C\u5730\u6587\u4EF6\uFF1A\u70B9\u51FB\u5DE5\u5177\u680F\u300C\u6253\u5F00\u300D\u91CD\u65B0\u9009\u62E9\u4E00\u6B21\u5373\u53EF\u5173\u8054\u5E76\u542F\u7528\u4FDD\u5B58\u3002","status.pickerTimeout":'\u6587\u4EF6\u9009\u62E9\u5668\u957F\u65F6\u95F4\u65E0\u54CD\u5E94\uFF0C\u5DF2\u5207\u6362\u4E3A\u6D4F\u89C8\u5668\u5185\u9009\u62E9\u5668\uFF1A\u8BF7\u91CD\u65B0\u70B9\u51FB"\u6253\u5F00"\u3002',"status.externalUpdateSkipped":"\u68C0\u6D4B\u5230\u6587\u4EF6\u5916\u90E8\u66F4\u65B0\uFF1B\u4E3A\u907F\u514D\u8986\u76D6\u672A\u4FDD\u5B58\u5185\u5BB9\uFF0C\u6682\u672A\u8F7D\u5165\u3002","status.draftRestored":'\u5DF2\u6062\u590D\u4E0A\u6B21\u672A\u4FDD\u5B58\u7684\u7F16\u8F91\u5185\u5BB9\uFF08\u4E0E\u78C1\u76D8\u6587\u4EF6\u4E0D\u540C\uFF09\u3002\u5982\u9700\u653E\u5F03\uFF0C\u70B9\u51FB\u300C\u6253\u5F00\u300D\u91CD\u65B0\u9009\u62E9\u8BE5\u6587\u4EF6\u5E76\u9009\u62E9"\u653E\u5F03"\u3002',"status.draftConflict":"\u68C0\u6D4B\u5230\u672C\u5730\u5B58\u6709\u672A\u4FDD\u5B58\u8349\u7A3F\uFF0C\u4F46\u6587\u4EF6\u5728\u522B\u5904\u5DF2\u88AB\u4FEE\u6539\u4FDD\u5B58\uFF1B\u5DF2\u52A0\u8F7D\u6700\u65B0\u6587\u4EF6\u5185\u5BB9\uFF0C\u8349\u7A3F\u4ECD\u4FDD\u7559\u5728\u672C\u5730\u672A\u4E22\u5F03\u3002","status.sourceMissing":"\u539F\u6587\u4EF6\u5DF2\u88AB\u79FB\u52A8\u6216\u5220\u9664\uFF1B\u5F53\u524D\u5185\u5BB9\u4ECD\u4FDD\u7559\u5728\u7F16\u8F91\u5668\u4E2D\uFF0C\u4FDD\u5B58\u5C06\u5728\u539F\u8DEF\u5F84\u91CD\u65B0\u521B\u5EFA\u6587\u4EF6\u3002","status.externalUpdateApplied":"\u68C0\u6D4B\u5230\u6587\u4EF6\u66F4\u65B0\uFF0C\u5DF2\u5237\u65B0\u3002","status.openingPicker":"\u6B63\u5728\u6253\u5F00\u6587\u4EF6\u9009\u62E9\u5668\u2026","status.opening":"\u6B63\u5728\u6253\u5F00\u2026","status.opened":"\u5DF2\u6253\u5F00 {file}\u3002","status.contentUpdated":"\u5185\u5BB9\u5DF2\u66F4\u65B0\u3002","status.contentUpdatedLine":"\u5DF2\u66F4\u65B0\u7B2C {line} \u884C\u3002","status.contentUpdatedLines":"\u5DF2\u66F4\u65B0\u7B2C {from}\u2013{to} \u884C\u3002","status.contentUpdatedSpots":"\u5DF2\u66F4\u65B0 {count} \u5904\uFF0C\u5171 {lines} \u884C\u3002","status.pasteImageTimeout":"\u7C98\u8D34\u56FE\u7247\u8D85\u65F6","status.pasteImageFailed":"\u7C98\u8D34\u56FE\u7247\u5931\u8D25\uFF1A{msg}","status.clipboardPrepareTimeout":"\u51C6\u5907\u516C\u4F17\u53F7\u56FE\u7247\u8D85\u65F6","status.pleaseOpenArticle":"\u8BF7\u5148\u6253\u5F00\u6587\u7AE0\u3002","status.copiedRich":"\u516C\u4F17\u53F7\u5BCC\u6587\u672C HTML \u5DF2\u590D\u5236\uFF0C\u53EF\u76F4\u63A5\u7C98\u8D34\u5230\u516C\u4F17\u53F7\u7F16\u8F91\u5668\u3002","status.copiedPlainOnly":"\u4EC5\u590D\u5236\u5230\u7EAF\u6587\u672C\uFF0C\u683C\u5F0F\u672A\u80FD\u5E26\u4E0A\uFF0C\u8BF7\u91CD\u8BD5\u4E00\u6B21\u3002","status.copyFailed":"\u590D\u5236\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\u4E00\u6B21\u3002","status.richCopyFailed":"\u5BCC\u6587\u672C\u590D\u5236\u5931\u8D25\uFF1A{err}","status.clipboardUnsupported":"\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u590D\u5236\u56FE\u7247\uFF0C\u8BF7\u6539\u7528\u300C\u5BFC\u51FA\u56FE\u7247\u300D\u3002","status.generatingImage":"\u6B63\u5728\u751F\u6210\u56FE\u7247\u2026","status.previewNotReady":"\u9884\u89C8\u5C1A\u672A\u5C31\u7EEA","status.imageCopied":"\u56FE\u7247\u5DF2\u590D\u5236\u5230\u526A\u8D34\u677F\u3002","status.copyImageFailed":"\u590D\u5236\u56FE\u7247\u5931\u8D25\uFF1A{err}\uFF08\u53EF\u6539\u7528\u300C\u5BFC\u51FA\u56FE\u7247\u300D\uFF09","status.exportImageFailedGeneric":"\u5BFC\u51FA\u56FE\u7247\u5931\u8D25\uFF1A\u9884\u89C8\u5C1A\u672A\u5C31\u7EEA\u3002","status.exportImageFailed":"\u5BFC\u51FA\u56FE\u7247\u5931\u8D25\uFF1A{err}","status.generatingPdf":"\u6B63\u5728\u751F\u6210 PDF\u2026","status.exportPdfFailedGeneric":"\u5BFC\u51FA PDF \u5931\u8D25\uFF1A\u9884\u89C8\u5C1A\u672A\u5C31\u7EEA\u3002","status.exportPdfFailed":"\u5BFC\u51FA PDF \u5931\u8D25\uFF1A{err}","status.exported":"\u5DF2\u5BFC\u51FA\uFF1A{path}","status.annotateOn":"\u6279\u6CE8\u5DF2\u5F00\u542F\uFF1A\u9009\u4E2D\u6587\u5B57\u53EF\u53D1\u8D77 AI \u4FEE\u6539\u3002","status.annotateOff":"\u6279\u6CE8\u5DF2\u5173\u95ED\u3002","status.comfortWrite":"\u5DF2\u5207\u6362\u4E3A\u8212\u9002\u6A21\u5F0F\uFF08\u884C\u8DDD\u52A0\u5BBD\uFF09\u3002","status.comfortRead":"\u5DF2\u5207\u6362\u4E3A\u7D27\u51D1\u6A21\u5F0F\u3002","status.focusOn":"\u4E13\u6CE8\u5DF2\u5F00\u542F\uFF1A\u975E\u5F53\u524D\u884C\u534A\u900F\u660E\u3002","status.focusOff":"\u4E13\u6CE8\u5DF2\u5173\u95ED\u3002","status.saveFailedNoReturn":"\u4FDD\u5B58\u5931\u8D25\uFF0C\u672A\u8FD4\u56DE\u9996\u9875\u3002","status.rendererAboutPrefix":"\u6E32\u67D3\u5668\uFF1A\u672C\u673A bmmd CLI\uFF08","status.rendererAboutSuffix":"\uFF0CLGPL-3.0\uFF09\u3002","status.appliedStyleSlot":"\u5DF2\u5E94\u7528\u300C{label}\u300D\u3002","status.needCustomStyleFirst":"\u8BF7\u5148\u5E94\u7528\u4E00\u4E2A\u81EA\u5B9A\u4E49/AI \u8BBE\u8BA1\u7684\u98CE\u683C\uFF0C\u518D\u4FDD\u5B58\u5230\u69FD\u4F4D\u3002","status.savedToSlot":"\u5DF2\u4FDD\u5B58\u5230\u69FD\u4F4D {slot}\uFF1A{label}","status.serializeFailed":"\u65E0\u6CD5\u5E8F\u5217\u5316\u9884\u89C8\u5185\u5BB9\uFF1A{err}","status.imageConversionFailed":"\u9884\u89C8\u5185\u5BB9\u65E0\u6CD5\u8F6C\u6210\u56FE\u7247\uFF08\u53EF\u80FD\u542B\u6709\u65E0\u6CD5\u8DE8\u57DF\u8BFB\u53D6\u7684\u5916\u90E8\u56FE\u7247\uFF09","status.imageGenFailed":"\u751F\u6210\u56FE\u7247\u6570\u636E\u5931\u8D25","status.clipboardPrepareFailedDefault":"\u51C6\u5907\u516C\u4F17\u53F7\u56FE\u7247\u5931\u8D25","status.pasteImageFailedDefault":"\u7C98\u8D34\u56FE\u7247\u5931\u8D25","status.savedAppliedToSlot":"{labelPrefix}\u5DF2\u4FDD\u5B58\u5E76\u5E94\u7528\u5230\u81EA\u5B9A\u4E49\u98CE\u683C {slot}\u3002"},en:{"meta.title":"Article Preview","home.title":"Writing","home.tagline.withAssistant":"Write Markdown together with {name}","home.tagline.default":"Open a Markdown file to start editing and previewing, or create a new article.","home.openFile":"Open File","home.newDoc":"New Document","home.recentLabel":"Recent","home.hintScoped":"No Markdown documents have been opened from this folder yet.","home.hintDefault":"Open a Markdown file \u2014 recently edited documents will show up here.","home.untitled":"Untitled","home.revealInFileManager":"Show in file manager","home.emptyDoc":"(Empty document)","home.cwdTitle":"Open in Finder / File Explorer: {path}","home.cwdFallback":"homePath (no-cwd fallback)","home.today":"Today {clock}","home.yesterday":"Yesterday {clock}","appview.library":"Library","appview.libraryHint":"Recent documents across all Spaces","appview.libraryWorkspace":"Workspace files","appview.libraryOther":"Other","appview.rewrite":"Rewrite","appview.focus":"Focus","appview.openSession":"Open rewrite session","appview.rewriting":"Rewrite started. The session will apply its revision directly to the file.","appview.continuing":"Continuation started. The session will write the new text directly to the file.","appview.hintSpace":"Press space for AI \xB7 / for formatting","appview.hintSpaceCode":"Press space for AI","appview.rewriteDone":"Rewrite complete. The document has refreshed.","editor.ariaLabel":"Writing editor","actions.copyToWx":"Copy for WeChat","actions.copyImg":"Copy image","actions.exportImg":"Export image (download)","actions.exportPdf":"Export PDF","actions.aiStyle":"Ask AI to design layout","actions.toggle":"Expand/collapse","popup.placeholder":"Let {name} edit","popup.placeholderContinue":"Let {name} continue writing from here\u2026","popup.send":"Send","confirm.cancel":"Cancel","confirm.discard":"Don't save","confirm.save":"Save and return","confirm.message":"\u201C{file}\u201D has unsaved changes. Save before returning to Home?","common.markdownDocDefault":"Markdown document","common.customStyleDefault":"Custom style","toolbar.home.tooltip":"Back to Home","toolbar.open.tooltipDefault":"Open Markdown file","toolbar.save.label":"Save","toolbar.save.tooltipDefault":"Save (\u2318/Ctrl+S)","toolbar.save.tooltipDirty":"Unsaved changes (\u2318/Ctrl+S)","toolbar.save.labelSaved":"Saved","toolbar.save.tooltipSaved":"Saved","toolbar.annotate.label":"Annotate","toolbar.annotate.tooltipOn":"Annotate is on \u2014 select text to ask AI to revise it","toolbar.annotate.tooltipOff":"Turn on Annotate: select text to ask AI to revise it","toolbar.needDoc":"Open a document first","toolbar.mode.label":"Preview","toolbar.mode.tooltipToPreview":"Switch to preview","toolbar.mode.tooltipToEdit":"Switch to edit","toolbar.mode.tooltipRendering":"Rendering preview\u2026","toolbar.style.tooltip":"Layout style","toolbar.style.tooltipNeedsPreview":"Switch to preview first","toolbar.style.customSlot":"Custom style {n} \xB7 {label}","toolbar.style.customSlotEmpty":"Custom style {n} (empty)","toolbar.fontSize.tooltipPreview":"Font can't be changed while previewing","toolbar.fontSize.tooltipEdit":"Editor font size","toolbar.fontSize.small":"Small","toolbar.fontSize.medium":"Medium","toolbar.fontSize.large":"Large","toolbar.fontFamily.default":"Default (sans-serif)","toolbar.fontFamily.serif":"Serif","toolbar.comfort.read":"Compact","toolbar.comfort.write":"Comfortable","toolbar.focus.tooltipOn":"Focus mode is on \u2014 inactive lines are dimmed","toolbar.focus.tooltipOff":"Turn on focus mode: dim inactive lines","toolbar.more.reload":"Re-render","toolbar.more.reveal":"Show in file manager","toolbar.more.about":"About rendering","toolbar.more.tooltip":"More","annotate.lineUnknown":"(Couldn't pinpoint the exact line \u2014 use the quoted text below as reference)","annotate.lineSingle":"Line {a}","annotate.lineRange":"Lines {a}\u2013{b}","annotate.lineCompactUnknown":"Unlocated","annotate.requirementWith":"Requirement: {comment}","annotate.requirementDefault":"make the wording clearer","annotate.pathMissing":"(No local file linked \u2014 ask me to paste/save the full text first)","annotate.emptyLine":"(Blank line \u2014 add or continue content here according to the annotation.)","annotate.promptText":`Please rewrite this Markdown passage (location: {lineLabel}), {requirement}:
6
+
7
+ {text}
8
+
9
+ Give a drop-in replacement snippet first; once I confirm, write it back to the source file ({path}) as a targeted local replacement, not a full resend of the document.`,"annotate.reminder":"Only propose the rewrite \u2014 don't write to the source file before I confirm. Reply in natural language (e.g. \u201CI'll put it into the file once you confirm\u201D); never name the tool or its actions. [MANDATORY, not optional] Whenever this turn proposes a rewrite and is waiting on my confirmation, calling Session action=suggest with 1\u20133 one-tap confirmations (e.g. \u201CUse this one\u201D, \u201CUse the shorter version\u201D, \u201CTry another tone\u201D) is part of completing that same turn \u2014 writing the proposal text is only half the job. Do not treat the turn as done, and do not skip the call, just because the proposal text itself was already sent.","newdoc.needChat":"Use \u201CNew Document\u201D from the Finch chat instead.","newdoc.label":"New Markdown Document","newdoc.promptText":"I want to create a new Markdown document. First work out the title, content, and a not-yet-existing absolute save path from my request \u2014 ask me first if anything is missing. Once confirmed, write the full body to that path and open the new document in the editor.","newdoc.reminder":"Only create a new file; never overwrite an existing one. Reply in natural language and never name the tool or its actions. [MANDATORY, not optional] Whenever this turn ends still waiting on me to confirm a title, an angle, or a save location, it must call Session action=suggest with 1\u20133 one-tap options before the turn ends \u2014 asking the question in plain text is not enough on its own; skipping the call leaves the question unfinished.","newdoc.added":"Added the new-document prompt to the composer.","aiStyle.label":"Design a layout based on {file}","aiStyle.note":"One-click AI layout","aiStyle.baseNoteCustom":"The current base style is kami (your custom CSS layers on top of it)","aiStyle.baseNoteOther":"The current base style is {style}","aiStyle.pathMissing":"(No local file linked)","aiStyle.promptText":"Please design a custom layout CSS for this WeChat article. {baseNote}, and your CSS will layer on top of the base style. Requirements: write plain CSS rules only, with selectors scoped to tags/structure under #bm-md (e.g. #bm-md h1, #bm-md p, #bm-md blockquote, #bm-md pre code, #bm-md a, #bm-md strong, #bm-md table); don\u2019t use classes (bm.md\u2019s output has no classes, only inline styles), and use !important where needed to override the base style. You can draw on bm.md\u2019s built-in style language: kami (warm paper feel), bauhaus (geometric color-blocking), blueprint (technical grid), botanical (fresh green), newsprint (editorial serif), retro (nostalgic), sketch (hand-drawn), terminal (monospace dark). Article path: {path}. Before generating any CSS, ask the user which of \u201CCustom style 1/2/3\u201D slots to overwrite; once they choose, apply the CSS you designed to that slot (it needs the css, a short label, and the slot number 1/2/3). That overwrites and persists the slot and applies it to the preview immediately.","aiStyle.reminder":"Always ask which slot first \u2014 never guess or overwrite on your own; apply it only after the user picks 1/2/3. Reply in natural language and never name the tool or its actions. [MANDATORY, not optional] Asking which slot must always be paired with calling Session action=suggest (\u201CUse custom style 1/2/3\u201D as one-tap options) before the turn ends \u2014 the question is not considered asked until that call happens, not merely the text of the question.","aiStyle.requested":"Asked AI to design a custom layout.","status.saved":"Saved.","status.savedWithNewChanges":"Saved \u2014 but the editor already has newer changes.","status.saveFailed":"Save failed: {err}","status.saving":"Saving\u2026","status.noSourceFile":"Not linked to a local file: click \u201COpen\u201D in the toolbar again to link it and enable saving.","status.pickerTimeout":'The file picker took too long to respond and switched to the in-browser picker \u2014 please click "Open" again.',"status.externalUpdateSkipped":"Detected an external file update; not loaded yet to avoid overwriting unsaved changes.","status.draftRestored":'Restored your last unsaved edits (differs from the file on disk). To discard, click "Open" and pick this file again, then choose "Discard".',"status.draftConflict":"A local unsaved draft exists, but the file was changed and saved elsewhere; loaded the latest file content \u2014 the draft is kept, not discarded.","status.sourceMissing":"The original file was moved or deleted; your content is still here \u2014 saving will recreate the file at its original path.","status.externalUpdateApplied":"Detected a file update and refreshed.","status.openingPicker":"Opening the file picker\u2026","status.opening":"Opening\u2026","status.opened":"Opened {file}.","status.contentUpdated":"Content updated.","status.contentUpdatedLine":"Updated line {line}.","status.contentUpdatedLines":"Updated lines {from}\u2013{to}.","status.contentUpdatedSpots":"Updated {count} spots, {lines} lines in total.","status.pasteImageTimeout":"Paste image timed out","status.pasteImageFailed":"Paste image failed: {msg}","status.clipboardPrepareTimeout":"Preparing WeChat images timed out","status.pleaseOpenArticle":"Open an article first.","status.copiedRich":"Rich HTML copied \u2014 paste it directly into the WeChat editor.","status.copiedPlainOnly":"Only plain text was copied; formatting didn't come through \u2014 please try again.","status.copyFailed":"Copy failed \u2014 please try again.","status.richCopyFailed":"Rich-text copy failed: {err}","status.clipboardUnsupported":"Copying images isn\u2019t supported here \u2014 use \u201CExport Image\u201D instead.","status.generatingImage":"Generating image\u2026","status.previewNotReady":"Preview isn't ready yet","status.imageCopied":"Image copied to the clipboard.","status.copyImageFailed":"Copy image failed: {err} (try \u201CExport Image\u201D instead)","status.exportImageFailedGeneric":"Export image failed: preview isn't ready yet.","status.exportImageFailed":"Export image failed: {err}","status.generatingPdf":"Generating PDF\u2026","status.exportPdfFailedGeneric":"Export PDF failed: preview isn't ready yet.","status.exportPdfFailed":"Export PDF failed: {err}","status.exported":"Exported: {path}","status.annotateOn":"Annotate is on \u2014 select text to ask AI to revise it.","status.annotateOff":"Annotate is off.","status.comfortWrite":"Comfortable mode is on \u2014 roomier line spacing.","status.comfortRead":"Compact mode is on.","status.focusOn":"Focus mode is on \u2014 inactive lines are dimmed.","status.focusOff":"Focus mode is off.","status.saveFailedNoReturn":"Save failed \u2014 staying on this document.","status.rendererAboutPrefix":"Renderer: local bmmd CLI (","status.rendererAboutSuffix":", LGPL-3.0).","status.appliedStyleSlot":"Applied \u201C{label}\u201D.","status.needCustomStyleFirst":"Apply a custom/AI-designed style first before saving it to a slot.","status.savedToSlot":"Saved to slot {slot}: {label}","status.serializeFailed":"Failed to serialize the preview content: {err}","status.imageConversionFailed":"The preview couldn't be converted to an image (it may contain external images that can't be read cross-origin)","status.imageGenFailed":"Failed to generate image data","status.clipboardPrepareFailedDefault":"Failed to prepare WeChat images","status.pasteImageFailedDefault":"Paste image failed","status.savedAppliedToSlot":"{labelPrefix}Saved and applied to custom style {slot}."}};function n(e,t){var a=qe?We.zh:We.en,r=Object.prototype.hasOwnProperty.call(a,e)?a[e]:Object.prototype.hasOwnProperty.call(We.en,e)?We.en[e]:e;if(t)for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(r=r.split("{"+o+"}").join(String(t[o])));return r}function Ht(e){var t=e||document;document.documentElement.lang=qe?"zh-CN":"en",document.title=n("meta.title"),Array.prototype.forEach.call(t.querySelectorAll("[data-i18n]"),function(a){a.textContent=n(a.getAttribute("data-i18n"))}),Array.prototype.forEach.call(t.querySelectorAll("[data-i18n-title]"),function(a){a.title=n(a.getAttribute("data-i18n-title"))}),Array.prototype.forEach.call(t.querySelectorAll("[data-i18n-tooltip]"),function(a){var r=n(a.getAttribute("data-i18n-tooltip"));a.setAttribute("data-tooltip",r),a.setAttribute("aria-label",r)}),Array.prototype.forEach.call(t.querySelectorAll("[data-i18n-aria]"),function(a){a.setAttribute("aria-label",n(a.getAttribute("data-i18n-aria")))})}var it=document.getElementById("empty"),zt=document.getElementById("emptyNew"),Ut=document.getElementById("emptyOpen"),st=document.getElementById("homeRecent"),Q=document.getElementById("homeGrid"),ie=document.getElementById("homeCwd"),He=document.getElementById("homeHint"),jt=document.getElementById("homeTagline"),Ba=document.getElementById("editPane"),lt=document.getElementById("previewPane"),Z=document.getElementById("previewResizer"),se=document.getElementById("editor"),E=document.getElementById("article"),G=document.getElementById("status"),w=document.getElementById("popup"),W=document.getElementById("popupInput"),Yt=document.getElementById("popupSend"),Gt=document.getElementById("popupShortcut"),me=document.getElementById("actions"),Na=document.getElementById("actCopyWx"),qa=document.getElementById("actCopyImg"),Wa=document.getElementById("actSaveImg"),Ha=document.getElementById("actSavePdf"),za=document.getElementById("actAiStyle"),_t=document.getElementById("actToggle"),ge=document.getElementById("confirmOverlay"),Ua=document.getElementById("confirmMessage"),Kt=document.getElementById("confirmCancel"),Xt=document.getElementById("confirmDiscard"),dt=document.getElementById("confirmSave"),Vt=document.getElementById("appToolbar"),Jt=document.getElementById("appHome"),Qt=document.getElementById("appLibrary"),ze=document.getElementById("appOpen"),J=document.getElementById("appSave"),ve=document.getElementById("appPreview"),ut=document.getElementById("appStyle"),Ue=document.getElementById("appStyleMenu"),he=document.getElementById("appFocus"),ct=document.getElementById("appFont"),je=document.getElementById("appFontMenu"),ja=document.getElementById("appMore"),Ye=document.getElementById("appMoreMenu"),Zt=document.getElementById("appDocumentTitle"),$t=document.getElementById("appDocumentPath"),pt=document.getElementById("libraryDrawer"),Ge=document.getElementById("libraryBackdrop"),ea=document.getElementById("libraryClose"),C=document.getElementById("libraryGroups"),ta="md-editor-library-groups-v1",ye=[],_e={},$=null,be=null,O=null,ft=!1,S=!1,we=!0,Ke=0,Se=!1,_=!0,y="edit",R="kami",le="",mt="",K=[null,null,null],Xe={songti:"Songti SC, STSong, SimSun, Noto Serif CJK SC, serif",rounded:"PingFang SC, Microsoft YaHei, Noto Sans CJK SC, sans-serif"},X=14,ee="rounded",H=!1,I=!1;try{var Ve=Number(localStorage.getItem("md-editor-font-size"));(Ve===14||Ve===16||Ve===18)&&(X=Ve);var gt=localStorage.getItem("md-editor-font-family");Xe[gt]?ee=gt:gt&&localStorage.removeItem("md-editor-font-family"),H=localStorage.getItem("md-editor-comfort-writing")==="1",I=localStorage.getItem("md-editor-focus-mode")==="1";var ke=JSON.parse(localStorage.getItem(ta)||"{}");Array.isArray(ke.order)&&(ye=ke.order.filter(function(e){return typeof e=="string"})),ke.collapsed&&typeof ke.collapsed=="object"&&(_e=ke.collapsed)}catch{}_=!I;var m="",xe="",D="",p="",B=null,P="",vt=!1,aa=0,Ee=!1,ra=0,ht={},de={},Ya=0,te={},Ga=0,ae={},Ce=0,z=null,Je=0,ue=0,yt=!1,g={text:"",mode:"replace"},U=0;function s(e,t){U&&(clearTimeout(U),U=0),G.textContent=e||"",G.className="status"+(t?" error":""),e&&(U=setTimeout(function(){U=0,G.textContent="",G.className="status"},5e3))}function _a(){U&&(clearTimeout(U),U=0),G.replaceChildren(document.createTextNode(n("status.rendererAboutPrefix")));var e=document.createElement("a");e.href="https://bm.md/",e.textContent="bm.md",e.title="https://bm.md/",e.addEventListener("click",function(t){t.preventDefault(),i&&i.postMessage&&i.postMessage({type:"openLink",url:"https://bm.md/"})}),G.append(e,document.createTextNode(n("status.rendererAboutSuffix"))),G.className="status",U=setTimeout(function(){U=0,G.textContent="",G.className="status"},5e3)}function V(){return!!m||!!p}zt&&zt.addEventListener("click",async function(){if(!i||!i.composer){s(n("newdoc.needChat"),!0);return}try{await i.composer.addContexts([{type:"annotation",label:n("newdoc.label"),promptText:n("newdoc.promptText"),reminder:n("newdoc.reminder")}]),s(n("newdoc.added"))}catch(e){s(String(e),!0)}}),Ut&&Ut.addEventListener("click",function(){At()});var re="",bt="",wt="",Qe="",Ze=!1,na=!1,Le="",ne="";function k(e){return String(e).replace(/[&<>"]/g,function(t){return t==="&"?"&amp;":t==="<"?"&lt;":t===">"?"&gt;":"&quot;"})}function oa(){jt&&(jt.textContent=Le?n("home.tagline.withAssistant",{name:Le}):n("home.tagline.default"))}function $e(){W&&(W.placeholder=g.mode==="continue"?n("popup.placeholderContinue",{name:Le||"Finch"}):n("popup.placeholder",{name:Le||"Finch"}))}function Ka(e){return e?ne&&e===ne?"~":ne&&(e.indexOf(ne+"/")===0||e.indexOf(ne+"\\")===0)?"~"+e.slice(ne.length):e:""}function Xa(e){var t=46;if(!e||e.length<=t)return e;var a=e.indexOf("/")===-1&&e.indexOf("\\")!==-1?"\\":"/",r=e.slice(-(t-1)),o=r.indexOf(a);return o>0&&o<10&&(r=r.slice(o)),"\u2026"+r}function St(){if(ie){var e=re||Qe;ie.textContent=Xa(Ka(e)),ie.title=e?n("home.cwdTitle",{path:e}):"",ie.hidden=!e}}ie&&ie.addEventListener("click",function(){var e=re||Qe;!e||!i||!i.postMessage||i.postMessage({type:"openPath",path:e})});function ia(e){var t=new Date(e);if(!e||isNaN(t.getTime()))return"";var a=new Date,r=function(d){return d<10?"0"+d:String(d)},o=r(t.getHours())+":"+r(t.getMinutes()),l=t.toDateString()===a.toDateString();if(l)return n("home.today",{clock:o});var u=new Date(a.getTime()-864e5);return t.toDateString()===u.toDateString()?n("home.yesterday",{clock:o}):t.getFullYear()===a.getFullYear()?r(t.getMonth()+1)+"-"+r(t.getDate()):t.getFullYear()+"-"+r(t.getMonth()+1)+"-"+r(t.getDate())}function et(){!i||!i.postMessage||!Ze||(na=!0,i.postMessage({type:"requestRecentDocuments",cwd:re,sessionId:bt,spaceId:wt}))}function sa(e){if(!(!Q||!st||!He)){var t=Array.isArray(e)?e:[];if(t.length===0){st.hidden=!0,He.hidden=!1,He.textContent=n(re?"home.hintScoped":"home.hintDefault");return}for(var a="",r=0;r<t.length;r++){var o=t[r]||{},l=o.relativePath||o.fileName||"";a+='<button class="doc-card" type="button" data-path="'+k(o.path||"")+'" title="'+k(o.path||"")+'"><span class="doc-reveal" data-reveal-path="'+k(o.path||"")+'" role="button" tabindex="0" title="'+k(n("home.revealInFileManager"))+'" aria-label="'+k(n("home.revealInFileManager"))+'"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m6 14 1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"/></svg></span><div class="doc-preview">'+k(o.preview||n("home.emptyDoc"))+'</div><div class="doc-foot"><div class="doc-title">'+k(o.title||o.fileName||n("home.untitled"))+'</div><div class="doc-sub"><span class="doc-path" data-full-path="'+k(l)+'">'+k(l)+'</span><span class="doc-time">'+k(ia(o.modifiedAt))+"</span></div></div></button>"}Q.innerHTML=a,st.hidden=!1,He.hidden=!0,requestAnimationFrame(function(){Va(Q)})}}function Va(e){for(var t="\u2026",a=e.querySelectorAll("[data-full-path]"),r=0;r<a.length;r++){var o=a[r],l=o.getAttribute("data-full-path")||"";if(o.textContent=l,!(!l||o.scrollWidth<=o.clientWidth+1)){for(var u=0,d=l.length,c=0;u<=d;){var f=u+d>>1;o.textContent=f>0?t+l.slice(l.length-f):t,o.scrollWidth<=o.clientWidth+1?(c=f,u=f+1):d=f-1}o.textContent=c>0?t+l.slice(l.length-c):t}}}function la(){try{localStorage.setItem(ta,JSON.stringify({order:ye,collapsed:_e}))}catch{}}function Ja(e){if(C){var t={};(Array.isArray(e)?e:[]).forEach(function(r){var o=r.scopeKind||"external",l=o==="workspace"?n("appview.libraryWorkspace"):o==="external"?n("appview.libraryOther"):r.scopeLabel||r.spaceName||n("appview.libraryOther"),u=o==="space"?"space:"+(r.spaceId||l):o==="workspace"?"workspace":"external";t[u]||(t[u]={id:u,kind:o,label:l,documents:[]}),t[u].documents.push(r)});var a=Object.keys(t).map(function(r){return t[r]}).sort(function(r,o){if(r.kind==="external"||o.kind==="external")return r.kind===o.kind?0:r.kind==="external"?1:-1;var l=ye.indexOf(r.id),u=ye.indexOf(o.id);if(l>=0||u>=0)return(l<0?9999:l)-(u<0?9999:u);var d={space:0,workspace:1},c=d[r.kind]-d[o.kind];return c||r.label.localeCompare(o.label)});C.innerHTML=a.map(function(r){var o=r.documents.map(function(d){var c=d.relativePath||d.fileName||"";return'<button class="library-row" type="button" data-path="'+k(d.path||"")+'"><span class="library-row-main"><strong>'+k(d.title||d.fileName||n("home.untitled"))+'</strong><span class="library-row-meta"><span class="library-row-path" title="'+k(c)+'">'+k(c)+"</span><time>"+k(ia(d.modifiedAt))+"</time></span></span></button>"}).join(""),l=r.kind!=="external",u=!_e[r.id];return'<details class="library-group" data-library-group-id="'+k(r.id)+'"'+(l?' data-draggable="true"':"")+(u?" open":"")+'><summary><span class="library-group-title">'+k(r.label)+'</span><span class="library-group-count">'+r.documents.length+'</span></summary><div class="library-items">'+o+"</div></details>"}).join("")||'<p class="home-hint">'+k(n("home.hintDefault"))+"</p>"}}function tt(e){!pt||!Ge||(pt.classList.toggle("open",!!e),pt.setAttribute("aria-hidden",e?"false":"true"),Ge.hidden=!e,e&&et())}function Qa(){if(!(!$||!C)){$.classList.remove("dragging"),Array.prototype.forEach.call(C.querySelectorAll(".library-group.drag-over"),function(t){t.classList.remove("drag-over")}),ye=Array.prototype.map.call(C.querySelectorAll('.library-group[data-draggable="true"]'),function(t){return t.getAttribute("data-library-group-id")}).filter(Boolean);var e=be||{};Array.prototype.forEach.call(C.querySelectorAll(".library-group"),function(t){var a=t.getAttribute("data-library-group-id");a in e&&(t.open=!!e[a])}),$=null,setTimeout(function(){be=null,la()},0)}}function Za(){O&&O.ghost&&O.ghost.parentNode&&O.ghost.parentNode.removeChild(O.ghost)}function da(e,t){var a=O;!a||!a.ghost||(a.ghost.style.left=e-a.offsetX+"px",a.ghost.style.top=t-a.offsetY+"px")}function $a(e){var t=O;if(!(!t||t.active)){t.active=!0,$=e,be={},Array.prototype.forEach.call(C.querySelectorAll(".library-group"),function(o){var l=o.getAttribute("data-library-group-id");l&&(be[l]=!!o.open),o.open=!1}),e.classList.add("dragging");var a=e.getBoundingClientRect(),r=e.cloneNode(!0);r.classList.add("library-drag-ghost"),r.classList.remove("dragging"),r.style.width=a.width+"px",t.ghost=r,t.offsetX=t.startX-a.left,t.offsetY=t.startY-a.top,document.body.appendChild(r),da(t.startX,t.startY)}}function er(e,t){if($){var a=document.elementFromPoint(e,t),r=a&&a.closest?a.closest('.library-group[data-draggable="true"]'):null;if(Array.prototype.forEach.call(C.querySelectorAll(".library-group.drag-over"),function(l){l.classList.remove("drag-over")}),!(!r||r===$)){r.classList.add("drag-over");var o=t>r.getBoundingClientRect().top+r.offsetHeight/2;C.insertBefore($,o?r.nextSibling:r)}}}function ua(){var e=O;e&&(e.active&&(Za(),Qa(),ft=!0,setTimeout(function(){ft=!1},0)),O=null)}Qt&&Qt.addEventListener("click",function(){tt(!0)}),ea&&ea.addEventListener("click",function(){tt(!1)}),Ge&&Ge.addEventListener("click",function(){tt(!1)}),C&&C.addEventListener("click",function(e){var t=e.target&&e.target.closest?e.target.closest(".library-row"):null,a=t&&t.getAttribute("data-path");!a||!i||!i.postMessage||(tt(!1),Me=!0,s(n("status.opening")),i.postMessage({type:"loadPath",path:a}))}),C&&(C.addEventListener("toggle",function(e){var t=e.target;if(!(!t||!t.matches||!t.matches(".library-group"))&&!be){var a=t.getAttribute("data-library-group-id");a&&(_e[a]=!t.open,la())}},!0),C.addEventListener("click",function(e){if(ft){var t=e.target&&e.target.closest?e.target.closest(".library-group summary"):null;t&&(e.preventDefault(),e.stopPropagation())}},!0),C.addEventListener("pointerdown",function(e){if(e.button===0){var t=e.target&&e.target.closest?e.target.closest(".library-group summary"):null,a=t&&t.closest?t.closest('.library-group[data-draggable="true"]'):null;a&&(O={group:a,startX:e.clientX,startY:e.clientY,active:!1,ghost:null,offsetX:0,offsetY:0})}}),window.addEventListener("pointermove",function(e){var t=O;if(t){if(!t.active){if(Math.abs(e.clientX-t.startX)<4&&Math.abs(e.clientY-t.startY)<4)return;$a(t.group)}e.preventDefault(),da(e.clientX,e.clientY),er(e.clientX,e.clientY)}}),window.addEventListener("pointerup",function(){ua()}),window.addEventListener("pointercancel",function(){ua()}));var Me=!1;Q&&Q.addEventListener("click",function(e){if(!(!i||!i.postMessage)){var t=e.target&&e.target.closest?e.target.closest(".doc-reveal"):null;if(t){e.preventDefault(),e.stopPropagation();var a=t.getAttribute("data-reveal-path")||"";a&&i.postMessage({type:"openPath",path:a});return}var r=e.target&&e.target.closest?e.target.closest(".doc-card"):null;if(r){var o=r.getAttribute("data-path")||"";o&&(Me=!0,s(n("status.opening")),i.postMessage({type:"loadPath",path:o}))}}}),Q&&Q.addEventListener("keydown",function(e){if(!(e.key!=="Enter"&&e.key!==" ")){var t=e.target&&e.target.closest?e.target.closest(".doc-reveal"):null;if(!(!t||!i||!i.postMessage)){e.preventDefault(),e.stopPropagation();var a=t.getAttribute("data-reveal-path")||"";a&&i.postMessage({type:"openPath",path:a})}}});function Ie(){it.hidden=V(),document.body.classList.toggle("has-document",V()),me&&(me.hidden=!P),!it.hidden&&Ze&&et()}function ce(){Ba.classList.toggle("active",S?V():y==="edit"),lt.classList.toggle("active",S?V():y==="preview"),(S||y==="edit")&&h&&requestAnimationFrame(function(){h.layout()})}function ca(e){!i||!i.panel||!i.panel.setTitle||i.panel.setTitle(e||n("home.title")).catch(function(){})}function tr(){for(var e=[{id:"style:kami",label:"Kami"},{id:"style:bauhaus",label:"Bauhaus"},{id:"style:blueprint",label:"Blueprint"},{id:"style:botanical",label:"Botanical"},{id:"style:newsprint",label:"Newsprint"},{id:"style:retro",label:"Retro"},{id:"style:sketch",label:"Sketch"},{id:"style:terminal",label:"Terminal"},{id:"style-sep",label:"",separator:!0}],t=0;t<3;t++){var a=K[t];e.push(a?{id:"style:slot-use:"+t,label:n("toolbar.style.customSlot",{n:t+1,label:a.label})}:{id:"style:slot-use:"+t,label:n("toolbar.style.customSlotEmpty",{n:t+1}),disabled:!0})}return e}function ar(){var e="ext:markdown-editor-icons/save",t=n("toolbar.save.label"),a=n("toolbar.save.tooltipDefault");F?(t=n("toolbar.save.label"),a=n("toolbar.save.tooltipDirty")):pe&&(e="ext:markdown-editor-icons/save-check",t=n("toolbar.save.labelSaved"),a=n("toolbar.save.tooltipSaved"));var r=V();return[{id:"home",icon:"house",tooltip:n("toolbar.home.tooltip")},{id:"open",icon:"ext:markdown-editor-icons/folder-open",tooltip:p||D||n("toolbar.open.tooltipDefault"),disabled:N},{id:"save",icon:e,label:t,tooltip:a,disabled:!F},{type:"separator"},{id:"mode",icon:Ee?"ext:markdown-editor-icons/hourglass":"ext:markdown-editor-icons/swatch-book",label:n("toolbar.mode.label"),tooltip:n(r?Ee?"toolbar.mode.tooltipRendering":y==="edit"?"toolbar.mode.tooltipToPreview":"toolbar.mode.tooltipToEdit":"toolbar.needDoc"),checked:y==="preview",disabled:!r},{type:"menu",id:"style",icon:"palette",tooltip:n(y==="preview"?"toolbar.style.tooltip":"toolbar.style.tooltipNeedsPreview"),disabled:y!=="preview",items:tr()},{type:"spacer"},{id:"focus",icon:"ext:markdown-editor-icons/feather",tooltip:n(r?I?"toolbar.focus.tooltipOn":"toolbar.focus.tooltipOff":"toolbar.needDoc"),checked:I,disabled:!r||y==="preview"},{type:"menu",id:"font-size",icon:"ext:markdown-editor-icons/type",tooltip:n(r?y==="preview"?"toolbar.fontSize.tooltipPreview":"toolbar.fontSize.tooltipEdit":"toolbar.needDoc"),disabled:!r||y==="preview",items:[{id:"comfort:read",label:n("toolbar.comfort.read"),checked:!H},{id:"comfort:write",label:n("toolbar.comfort.write"),checked:H},{id:"font-comfort-sep",label:"",separator:!0},{id:"font-size:14",label:n("toolbar.fontSize.small"),checked:X===14},{id:"font-size:16",label:n("toolbar.fontSize.medium"),checked:X===16},{id:"font-size:18",label:n("toolbar.fontSize.large"),checked:X===18},{id:"font-sep",label:"",separator:!0},{id:"font-family:rounded",label:n("toolbar.fontFamily.default"),checked:ee==="rounded"},{id:"font-family:songti",label:n("toolbar.fontFamily.serif"),checked:ee==="songti"}]},{type:"menu",id:"more",icon:"settings",items:[{id:"reload",label:n("toolbar.more.reload"),disabled:y!=="preview"},{id:"reveal",label:n("toolbar.more.reveal"),disabled:!r},{id:"more-sep",label:"",separator:!0},{id:"about",label:n("toolbar.more.about")}]}]}function A(e,t,a){return'<button type="button" data-app-action="'+e+'"'+(a?' class="checked"':"")+"><span>"+t+"</span>"+(a?"<span>\u2713</span>":"")+"</button>"}function rr(){if(Ue){for(var e=["kami","bauhaus","blueprint","botanical","newsprint","retro","sketch","terminal"],t=e.map(function(o){return A("style:"+o,o[0].toUpperCase()+o.slice(1),R===o)}).join("")+"<hr>",a=0;a<3;a++){var r=K[a];t+=r?A("style:slot-use:"+a,n("toolbar.style.customSlot",{n:a+1,label:r.label}),R==="custom"&&le===r.css):A("style:slot-use:"+a,n("toolbar.style.customSlotEmpty",{n:a+1}),!1)}Ue.innerHTML=t}je&&(je.innerHTML=A("comfort:read",n("toolbar.comfort.read"),!H)+A("comfort:write",n("toolbar.comfort.write"),H)+"<hr>"+A("font-size:14",n("toolbar.fontSize.small"),X===14)+A("font-size:16",n("toolbar.fontSize.medium"),X===16)+A("font-size:18",n("toolbar.fontSize.large"),X===18)+"<hr>"+A("font-family:rounded",n("toolbar.fontFamily.default"),ee==="rounded")+A("font-family:songti",n("toolbar.fontFamily.serif"),ee==="songti")),Ye&&(Ye.innerHTML=A("reload",n("toolbar.more.reload"),!1)+A("reveal",n("toolbar.more.reveal"),!1)+"<hr>"+A("about",n("toolbar.more.about"),!1))}function nr(){if(S){var e=V();if(J){J.disabled=!F,J.classList.toggle("dirty",F);var t=pe?"toolbar.save.tooltipSaved":F?"toolbar.save.tooltipDirty":"toolbar.save.tooltipDefault";J.setAttribute("data-tooltip",n(t));var a=J.querySelector(".ic-save"),r=J.querySelector(".ic-save-check");a&&(a.hidden=pe),r&&(r.hidden=!pe)}he&&(he.disabled=!e,he.classList.toggle("checked",I)),ve&&(ve.disabled=!e,ve.classList.toggle("checked",we)),ze&&(ze.disabled=N),ut&&(ut.disabled=!e),ct&&(ct.disabled=!e),Zt&&(Zt.textContent=D||n("home.title")),$t&&($t.textContent=p||""),rr()}}function v(){S?nr():i&&i.postMessage({type:"setToolbar",toolbar:ar()})}function Ae(e){if(L(),S){y="edit",ce(),j(),v();return}y=e,ce(),v(),y==="preview"&&j()}function or(e){return!i||!i.postMessage?Promise.reject(new Error("No host bridge.")):new Promise(function(t,a){var r=new FileReader;r.onload=function(){var o=typeof r.result=="string"?r.result:"",l=o.indexOf(","),u=l>=0?o.slice(l+1):"";if(!u){a(new Error("Could not read pasted image."));return}var d=++Ya;te[d]={resolve:t,reject:a},setTimeout(function(){te[d]&&(delete te[d],a(new Error(n("status.pasteImageTimeout"))))},15e3),i.postMessage({type:"pasteImage",data:u,mimeType:e.type,requestId:d})},r.onerror=function(){a(new Error("Could not read pasted image."))},r.readAsDataURL(e)})}var h=window.MarkdownCodeMirror.create({parent:se,value:m,onChange:function(e){m=e,L(),Ie(),Fe(!0),Er(),sr()},onOpenLink:function(e){i&&i.postMessage&&i.postMessage({type:"openLink",url:e})},onOpenImage:function(e){if(!(!i||!i.postMessage)){try{var t=new URL(e);if(t.protocol==="finch-file:"&&t.hostname==="local"){var a=t.searchParams.get("path");if(a){i.postMessage({type:"openImage",path:a});return}}}catch{}i.postMessage({type:"openImage",url:e})}},onPasteImage:or,onAiHintTrigger:kr});h.setFontSize(X),h.setFontFamily(Xe[ee]),h.setComfortWriting(H),h.setFocusMode(I),h.scrollDOM.addEventListener("scroll",L);function ir(){return R==="custom"?le:""}function sr(){S&&(Ke&&clearTimeout(Ke),Ke=setTimeout(function(){Ke=0,j()},420))}function j(){if(!(!m||!i)){var e=++aa;Ee=!0,v(),i.postMessage({type:"renderBm",markdown:m,markdownStyle:R==="custom"?"kami":R,customCss:ir(),requestId:e})}}function lr(){var e=E.contentDocument,t=e&&e.scrollingElement;return t?{top:t.scrollTop}:null}function dr(e){var t=E.contentDocument,a=t&&t.scrollingElement;!e||!a||(a.scrollTop=Math.min(e.top,Math.max(0,a.scrollHeight-a.clientHeight)))}function ur(){try{return getComputedStyle(E).backgroundColor||""}catch{return""}}function pa(e){var t=lr(),a=E.contentDocument;P=e;var r=ur();if(vt&&a&&a.body){a.body.innerHTML=P,r&&(a.body.style.background=r),dr(t),ma();return}E.srcdoc='<!doctype html><meta charset="utf-8"><base target="_blank"><style>html,body{margin:0!important;padding:0!important;min-height:100%}body{background:'+(r||"transparent")+"}#bm-md{min-height:100dvh}</style><body>"+P}function fa(e,t,a){return{start:e.slice(0,t).split(`
10
+ `).length,end:e.slice(0,a).split(`
11
+ `).length}}function cr(e,t){for(var a="",r=[],o=0;o<e.length;o++)/\s/.test(e[o])?a&&a[a.length-1]!==" "&&(a+=" ",r.push(t[o])):(a+=e[o],r.push(t[o]));return a.endsWith(" ")&&(a=a.slice(0,-1),r.pop()),{text:a,map:r}}function pr(e){var t="",a=[];function r(q,T){t+=q,a.push(T)}for(var o=0;o<e.length;){var l=o===0||e[o-1]===`
12
+ `;if(l){var u=/^[ \t]*(?:```|~~~)[^\n]*/.exec(e.slice(o));if(u){o+=u[0].length;continue}var d=/^[ \t]*(?:#{1,6}|>+|[-+*]|\d+[.)])[ \t]+/.exec(e.slice(o));if(d){o+=d[0].length;continue}}var c=/^!?\[([^\]]*)\]\((?:\\.|[^)])*\)/.exec(e.slice(o));if(c){for(var f=o+c[0].indexOf("[")+1,b=0;b<c[1].length;b++)/[*_~`]/.test(c[1][b])||r(c[1][b],f+b);o+=c[0].length;continue}var x=/^<[^>]+>/.exec(e.slice(o));if(x){o+=x[0].length;continue}if(e[o]==="\\"&&o+1<e.length){r(e[o+1],o+1),o+=2;continue}if(/[*_~`]/.test(e[o])){o++;continue}r(e[o],o),o++}return cr(t,a)}function fr(e,t){var a=e.indexOf(t);if(a>=0)return{start:a,end:a+t.length};var r=pr(e),o=t.replace(/\s+/g," ").trim(),l=r.text.indexOf(o);if(l>=0)return{start:r.map[l],end:r.map[l+o.length-1]+1};if(o.length>=12){var u=o.slice(0,6),d=o.slice(-6),c=r.text.indexOf(u),f=r.text.indexOf(d,Math.max(0,c+u.length));if(c>=0&&f>=c)return{start:r.map[c],end:r.map[f+d.length-1]+1}}return null}function mr(e){return String(e||"").split(/[\\/]/).pop()||""}function ma(){var e=E.contentDocument;if(!e||e.__bound)return;e.__bound=!0;function t(){if(_){var a=E.contentWindow,r=a.getSelection(),o=r.toString().trim();if(!(!o||!r.rangeCount)){var l=r.getRangeAt(0),u=Array.from(l.getClientRects()),d=E.getBoundingClientRect(),c=u.map(function(T){return{top:d.top+T.top,left:d.left+T.left,width:T.width,height:T.height}}),f=u[0]||l.getBoundingClientRect(),b=u[u.length-1]||f,x=fr(m,o),q=x?fa(m,x.start,x.end):null;ga(o,{startTop:d.top+f.top,startLeft:d.left+f.left,endBottom:d.top+b.bottom,endLeft:d.left+b.left},c,q,"preview")}}}e.addEventListener("mouseup",t),e.addEventListener("mousedown",function(){oe(),L()}),e.addEventListener("keyup",t),e.addEventListener("keydown",function(a){(a.metaKey||a.ctrlKey)&&(a.key==="p"||a.key==="P")&&(a.preventDefault(),Ae("edit"))}),e.addEventListener("scroll",function(){oe(),L()},!0),E.contentWindow.addEventListener("scroll",function(){oe(),L()})}E.onload=function(){vt=!0,ma()};var at=0,kt=[];function ga(e,t,a,r,o){oe(),at=setTimeout(function(){va(e,t,a,r,o)},300)}function oe(){at&&(clearTimeout(at),at=0)}function va(e,t,a,r,o,l){g.text=e,g.lines=r||null,g.origin=o||"",g.mode=l||"replace",$e(),w.classList.remove("hidden"),w.classList.toggle("popup-bar",!!(t&&t.width)),W.value="",vr(a),requestAnimationFrame(function(){gr(t),t&&t.focus&&W.focus()})}function gr(e){var t=8,a=10,r=e||{},o=S?t+48:t;if(w.style.width=r.width?r.width+"px":"",r.width){w.style.left=Math.max(t,r.startLeft||0)+"px",w.style.top=Math.max(o,Math.min(r.startTop||0,window.innerHeight-(w.offsetHeight||44)-t))+"px";return}var l=w.offsetWidth||300,u=w.offsetHeight||44,d=(r.startTop||0)-a-u,c=d>=o,f=c?d:(r.endBottom||0)+a,b=c?r.startLeft||0:r.endLeft!=null?r.endLeft:r.startLeft||0;w.style.left=Math.max(t,Math.min(b,window.innerWidth-l-t))+"px",w.style.top=Math.max(o,Math.min(f,window.innerHeight-u-t))+"px"}function vr(e){ha(),(e||[]).forEach(function(t){var a=document.createElement("div");a.className="fake-sel",a.style.top=t.top+"px",a.style.left=t.left+"px",a.style.width=t.width+"px",a.style.height=t.height+"px",document.body.appendChild(a),kt.push(a)})}function ha(){kt.forEach(function(e){e.remove()}),kt=[]}var hr=navigator.platform||navigator.userAgent||"",xt=/Mac|iPhone|iPod|iPad/.test(hr);function yr(e){return String(e.key).toLowerCase()!=="e"||e.shiftKey?!1:xt?e.metaKey&&e.ctrlKey&&!e.altKey:e.ctrlKey&&e.altKey&&!e.metaKey}(function(){if(Gt){var t=xt?["\u2318","\u2303","E"]:["Ctrl","Alt","E"],a=xt?"":"+";Gt.innerHTML=t.map(function(r){return"<kbd>"+r+"</kbd>"}).join(a?'<span class="popup-shortcut-sep">'+a+"</span>":"")}})();function L(e){var t=e===!0&&g.origin==="editor"&&y==="edit";oe(),w.classList.add("hidden"),w.classList.remove("popup-bar"),w.classList.remove("focused"),w.style.width="",g.text="",g.lines=null,g.origin="",g.mode="replace",ha(),t&&requestAnimationFrame(function(){h.focus()})}Yt.onclick=ya,W.addEventListener("keydown",function(e){e.key==="Enter"&&ya(),e.key==="Escape"&&L(!0)}),W.addEventListener("focus",function(){w.classList.add("focused")}),W.addEventListener("blur",function(){requestAnimationFrame(function(){document.activeElement!==Yt&&w.classList.remove("focused")})}),document.addEventListener("keydown",function(e){e.key==="Escape"&&!w.classList.contains("hidden")&&L(!0)}),document.addEventListener("keydown",function(e){yr(e)&&(w.classList.contains("hidden")||(e.preventDefault(),W.focus(),W.select()))}),document.addEventListener("mousedown",function(e){w.contains(e.target)||(oe(),L())}),window.addEventListener("resize",L);function br(){if(!g.lines)return n("annotate.lineUnknown");var e=g.lines.start,t=g.lines.end;return e===t?n("annotate.lineSingle",{a:e}):n("annotate.lineRange",{a:e,b:t})}function wr(){return g.lines?g.lines.start+"-"+g.lines.end:n("annotate.lineCompactUnknown")}async function ya(){var e=W.value.trim(),t=g.mode==="continue",a=g.mode==="annotate-line";if(!(!g.text&&!t&&!a||!i)){if(F&&p){var r=await Ot();if(!r){s(n("status.saveFailedNoReturn"),!0);return}}if(S){if(!p||!i.postMessage){s(n("status.noSourceFile"),!0);return}i.postMessage({type:"requestRewrite",path:p,selectedText:g.text,requirement:e,startLine:g.lines&&g.lines.start,endLine:g.lines&&g.lines.end,rewriteMode:t?"continue":"replace"}),L(!0),s(n(t?"appview.continuing":"appview.rewriting"));return}if(!i.composer||!g.text&&!a){L(!0);return}try{await i.composer.addContexts([{type:"annotation",label:(D||"Markdown")+":"+wr(),note:e||void 0,promptText:n("annotate.promptText",{lineLabel:br(),requirement:e?n("annotate.requirementWith",{comment:e}):n("annotate.requirementDefault"),text:g.text||n("annotate.emptyLine"),path:p||n("annotate.pathMissing")}),reminder:n("annotate.reminder")}]),L(!0),s(n("annotate.added"))}catch(o){s(String(o),!0)}}}function Sr(){var e=h.getSelection();if(!e)return!1;var t=e.text.trim();if(!t)return!1;var a=fa(h.getValue(),e.start,e.end);return ga(t,{startTop:e.startRect.top,startLeft:e.startRect.left,endBottom:e.rect.bottom,endLeft:e.rect.left},null,a,"editor"),!0}function ba(){_&&Sr()}function kr(e){if(!V()||!e)return!1;oe();var t=se.querySelector(".cm-line")||se.querySelector(".cm-content"),a=(t||se).getBoundingClientRect();return va("",{startTop:e.rect.top,startLeft:a.left,width:Math.max(240,a.width),focus:!0},null,{start:e.line,end:e.line},"editor",S?"continue":"annotate-line"),!0}se.addEventListener("mouseup",ba),se.addEventListener("keyup",function(e){e.shiftKey&&ba()});var F=!1,pe=!1,Et="",Ct=null;function xr(e){Et=e,Ct=m,i.postMessage({type:"saveDraft",path:e,markdown:m,base:B})}function Er(){!p||!i||!i.postMessage||Et===p&&Ct===m||xr(p)}function Lt(){Et="",Ct=null}function wa(e){Lt(),e&&i&&i.postMessage&&i.postMessage({type:"discardDraft",path:e})}function Fe(e,t){F=e,Ce&&(clearTimeout(Ce),Ce=0),pe=!F&&!!t,v(),!F&&t&&(Ce=setTimeout(function(){Ce=0,F||(pe=!1,v())},3e3))}async function Sa(e){if(z&&z.createWritable)try{var t=await z.createWritable();return await t.write(e),await t.close(),Je=(await z.getFile()).lastModified,B=e,Fe(m!==e,m===e),s(n(m===e?"status.saved":"status.savedWithNewChanges")),Lt(),!0}catch(r){return s(n("status.saveFailed",{err:String(r)}),!0),!1}if(p){var a=++ra;return s(n("status.saving")),ht[a]=e,i.postMessage({type:"saveMarkdown",path:p,markdown:e,requestId:a}),new Promise(function(r){de[a]=r})}return s(n("status.noSourceFile"),!0),!1}document.addEventListener("keydown",function(e){var t=e.metaKey||e.ctrlKey;if(t&&(e.key==="s"||e.key==="S")){e.preventDefault(),Tt();return}t&&(e.key==="p"||e.key==="P")&&(e.preventDefault(),Ae(y==="edit"?"preview":"edit"))});function ka(){ue&&(clearInterval(ue),ue=0),z=null}var Mt=null;function It(e,t,a,r,o){if(!r&&F&&B!==null&&e!==B)return s(n("status.externalUpdateSkipped"),!0),!1;var l=B!==null&&(!a||!p||a===p);return l||(_=!0),m=e,xe=t,a&&(p=a),D=mr(a||p)||t||"Markdown",B=typeof o=="string"?o:m,Mt=l?h.applyExternalValue(m):null,Mt||h.setValue(m),Fe(!1),ca(D),Ie(),ce(),(S||y==="preview")&&j(),!0}async function xa(e){xe=e.name,Je=e.lastModified,typeof e.path=="string"&&e.path?(p=e.path,i&&i.postMessage({type:"watchPath",path:p})):p="",It(await e.text(),xe,p,!0)}function Cr(){z&&(ue&&clearInterval(ue),ue=setInterval(async function(){if(!(yt||!z)){yt=!0;try{var e=await z.getFile();if(e.lastModified!==Je){Je=e.lastModified;var t=await e.text();t!==B&&It(t,xe,p)&&s(n("status.externalUpdateApplied"))}}catch{}yt=!1}},800))}var N=!1,De=0;function Pe(){De&&(clearTimeout(De),De=0)}function Lr(){Pe(),De=setTimeout(function(){De=0,N&&(N=!1,Se=!1,v(),s(n("status.pickerTimeout"),!0))},2e4)}async function At(){if(F){var e=await Da(n("confirm.message",{file:D||n("common.markdownDocDefault")}));if(e==="cancel")return;if(e==="save"){var t=await Ot();if(!t){s(n("status.saveFailedNoReturn"),!0);return}}else e==="discard"&&wa(p)}if(ka(),Se&&i&&i.postMessage){if(N){Pe(),Se=!1,N=!1,v(),await Ea();return}N=!0,Lr(),v(),s(n("status.openingPicker")),i.postMessage({type:"requestOpen"});return}await Ea()}async function Ea(){if("showOpenFilePicker"in window)try{var e=await window.showOpenFilePicker({types:[{description:"Markdown",accept:{"text/markdown":[".md",".markdown"]}}],multiple:!1});z=e[0],await xa(await z.getFile()),Cr();return}catch(a){if(a&&a.name==="AbortError")return}var t=document.createElement("input");t.type="file",t.accept=".md,.markdown,text/markdown",t.onchange=function(){var a=t.files&&t.files[0];a&&xa(a).catch(function(r){s(String(r),!0)})},t.click()}function Mr(){window.focus(),document.body.tabIndex=-1;try{document.body.focus({preventScroll:!0})}catch{document.body.focus()}}async function Ir(e){for(var t=0;t<e;t++){if(Mr(),await new Promise(function(a){requestAnimationFrame(function(){requestAnimationFrame(a)})}),document.hasFocus())return!0;await new Promise(function(a){setTimeout(a,40)})}return document.hasFocus()}function Ca(e){var t=Array.from(new Set(e.match(/finch-file:\/\/local\?path=[^\s)"']+/g)||[]));return!t.length||!i||!i.postMessage?Promise.resolve(e):new Promise(function(a,r){var o=++Ga;ae[o]={resolve:a,reject:r,sourceHtml:e},setTimeout(function(){ae[o]&&(delete ae[o],r(new Error(n("status.clipboardPrepareTimeout"))))},15e3),i.postMessage({type:"readClipboardImages",urls:t,requestId:o})})}function Ar(e){var t=new DOMParser().parseFromString(e,"text/html");function a(r){return r&&r.tagName==="P"&&!r.textContent.trim()&&!r.querySelector("img,video,iframe,table")}return Array.from(t.querySelectorAll("figure.figure-image")).forEach(function(r){var o=r.previousElementSibling,l=r.nextElementSibling;a(o)&&o.remove(),a(l)&&l.remove()}),t.body.innerHTML}async function La(e,t){if(document.hasFocus()||await Ir(5),window.ClipboardItem&&navigator.clipboard&&navigator.clipboard.write)try{return await navigator.clipboard.write([new ClipboardItem({"text/html":Promise.resolve(e).then(function(r){return new Blob([r],{type:"text/html"})}),"text/plain":new Blob([t],{type:"text/plain"})})]),"rich"}catch{}var a=await Promise.resolve(e);return Fr(a)?"rich":Dr(t)?"plain":"none"}function Fr(e){var t=document.createElement("div");t.contentEditable="true",t.style.position="fixed",t.style.left="-9999px",t.style.top="0",t.innerHTML=e,document.body.appendChild(t);var a=document.createRange();a.selectNodeContents(t);var r=window.getSelection();r.removeAllRanges(),r.addRange(a);var o=!1;try{o=document.execCommand("copy")}catch{o=!1}return r.removeAllRanges(),t.remove(),o}function Dr(e){var t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-9999px",t.style.top="0",document.body.appendChild(t),t.focus(),t.select();var a=!1;try{a=document.execCommand("copy")}catch{a=!1}return t.remove(),a}async function Pr(){if(!P){s(n("status.pleaseOpenArticle"),!0);return}try{var e=E.contentDocument&&E.contentDocument.body?E.contentDocument.body.innerText:P.replace(/<[^>]+>/g,""),t=await La(Ca(P),e);t==="none"&&(await new Promise(function(a){setTimeout(a,200)}),t=await La(Ca(P),e)),t==="rich"?s(n("status.copiedRich")):s(n(t==="plain"?"status.copiedPlainOnly":"status.copyFailed"),!0)}catch(a){s(n("status.richCopyFailed",{err:String(a)}),!0)}finally{y==="edit"&&requestAnimationFrame(function(){h.focus()})}}function Tr(){if(!vt||!E.contentDocument)return null;var e=E.contentDocument.querySelector("#bm-md");if(!e)return null;var t=e.getBoundingClientRect();return{root:e,width:Math.ceil(t.width||e.scrollWidth),height:Math.ceil(t.height||e.scrollHeight)}}function Ft(){var e=Tr();if(!e||!e.width||!e.height)return Promise.resolve(null);var t=2,a=e.root.cloneNode(!0);a.style.minHeight=e.height+"px",a.style.margin="0",a.style.boxSizing="border-box";var r;try{r=new XMLSerializer().serializeToString(a)}catch(u){return Promise.reject(new Error(n("status.serializeFailed",{err:String(u)})))}var o='<svg xmlns="http://www.w3.org/2000/svg" width="'+e.width+'" height="'+e.height+'"><foreignObject x="0" y="0" width="'+e.width+'" height="'+e.height+'">'+r+"</foreignObject></svg>",l="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(o);return new Promise(function(u,d){var c=new Image;c.decoding="sync",c.onload=function(){try{var f=document.createElement("canvas");f.width=Math.round(e.width*t),f.height=Math.round(e.height*t);var b=f.getContext("2d");b.scale(t,t);var x="";try{x=E.contentWindow.getComputedStyle(e.root).backgroundColor}catch{x=""}x&&x!=="rgba(0, 0, 0, 0)"&&x!=="transparent"&&(b.fillStyle=x,b.fillRect(0,0,e.width,e.height)),b.drawImage(c,0,0,e.width,e.height),u({canvas:f,cssWidth:e.width,cssHeight:e.height})}catch(q){d(q)}},c.onerror=function(){d(new Error(n("status.imageConversionFailed")))},c.src=l})}function Dt(e,t,a){return new Promise(function(r,o){e.toBlob(function(l){l?r(l):o(new Error(n("status.imageGenFailed")))},t,a)})}function Ma(e){for(var t="",a=32768,r=0;r<e.length;r+=a)t+=String.fromCharCode.apply(null,e.subarray(r,r+a));return btoa(t)}async function Or(){if(!P){s(n("status.pleaseOpenArticle"),!0);return}if(!window.ClipboardItem||!navigator.clipboard||!navigator.clipboard.write){s(n("status.clipboardUnsupported"),!0);return}s(n("status.generatingImage"));var e=Ft().then(function(a){if(!a)throw new Error(n("status.previewNotReady"));return Dt(a.canvas,"image/png")});try{await navigator.clipboard.write([new ClipboardItem({"image/png":e})]),s(n("status.imageCopied"));return}catch{try{var t=await e;await navigator.clipboard.write([new ClipboardItem({"image/png":t})]),s(n("status.imageCopied"));return}catch(r){s(n("status.copyImageFailed",{err:r&&r.message?r.message:String(r)}),!0)}}}async function Rr(){if(!P){s(n("status.pleaseOpenArticle"),!0);return}try{s(n("status.generatingImage"));var e=await Ft();if(!e){s(n("status.exportImageFailedGeneric"),!0);return}var t=await Dt(e.canvas,"image/png"),a=await t.arrayBuffer(),r=Ma(new Uint8Array(a));i&&i.postMessage&&i.postMessage({type:"exportFile",data:r,ext:"png",path:p,fileName:D,markdown:m})}catch(o){s(n("status.exportImageFailed",{err:String(o)}),!0)}}function Br(e){for(var t=String(e);t.length<10;)t="0"+t;return t}function Y(e){for(var t=new Uint8Array(e.length),a=0;a<e.length;a++)t[a]=e.charCodeAt(a)&255;return t}function Pt(e){for(var t=0,a=0;a<e.length;a++)t+=e[a].length;for(var r=new Uint8Array(t),o=0,a=0;a<e.length;a++)r.set(e[a],o),o+=e[a].length;return r}function Nr(e,t,a,r,o){var l=Y(`%PDF-1.4
13
+ %\xE2\xE3\xCF\xD3
14
+ `),u=[l],d=[0],c=l.length;function f(M){d.push(c),u.push(M),c+=M.length}f(Y(`1 0 obj
15
+ << /Type /Catalog /Pages 2 0 R >>
16
+ endobj
17
+ `)),f(Y(`2 0 obj
18
+ << /Type /Pages /Kids [3 0 R] /Count 1 >>
19
+ endobj
20
+ `)),f(Y(`3 0 obj
21
+ << /Type /Page /Parent 2 0 R /MediaBox [0 0 `+r.toFixed(2)+" "+o.toFixed(2)+`] /Resources << /XObject << /Im0 4 0 R >> >> /Contents 5 0 R >>
22
+ endobj
23
+ `));var b=Y(`4 0 obj
24
+ << /Type /XObject /Subtype /Image /Width `+t+" /Height "+a+" /ColorSpace /DeviceRGB /BitsPerComponent 8 /Filter /DCTDecode /Length "+e.length+` >>
25
+ stream
26
+ `),x=Y(`
27
+ endstream
28
+ endobj
29
+ `);f(Pt([b,e,x]));var q="q "+r.toFixed(2)+" 0 0 "+o.toFixed(2)+" 0 0 cm /Im0 Do Q",T=Y(q);f(Pt([Y(`5 0 obj
30
+ << /Length `+T.length+` >>
31
+ stream
32
+ `),T,Y(`
33
+ endstream
34
+ endobj
35
+ `)]));for(var nt=c,Re=[`xref
36
+ 0 6
37
+ 0000000000 65535 f
38
+ `],Be=1;Be<=5;Be++)Re.push(Br(d[Be])+` 00000 n
39
+ `);var Wt=`trailer
40
+ << /Size 6 /Root 1 0 R >>
41
+ startxref
42
+ `+nt+`
43
+ %%EOF`;return u.push(Y(Re.join("")+Wt)),Pt(u)}async function qr(){if(!P){s(n("status.pleaseOpenArticle"),!0);return}try{s(n("status.generatingPdf"));var e=await Ft();if(!e){s(n("status.exportPdfFailedGeneric"),!0);return}var t=await Dt(e.canvas,"image/jpeg",.92),a=await t.arrayBuffer(),r=new Uint8Array(a),o=e.cssWidth*.75,l=e.cssHeight*.75,u=Nr(r,e.canvas.width,e.canvas.height,o,l),d=Ma(u);i&&i.postMessage&&i.postMessage({type:"exportFile",data:d,ext:"pdf",path:p,fileName:D,markdown:m})}catch(c){s(n("status.exportPdfFailed",{err:String(c)}),!0)}}function Te(e,t){e&&e.addEventListener("click",function(a){a.preventDefault(),!e.disabled&&(e.disabled=!0,Promise.resolve().then(t).catch(function(r){s(String(r),!0)}).then(function(){e.disabled=!1}))})}Te(Na,Pr),Te(qa,Or),Te(Wa,Rr),Te(Ha,qr),Te(za,Wr);var Ia="md-editor-actions-collapsed";(function(){var t=!1;try{t=localStorage.getItem(Ia)==="1"}catch{}me&&me.classList.toggle("collapsed",t)})(),_t&&_t.addEventListener("click",function(e){e.preventDefault();var t=me.classList.toggle("collapsed");try{localStorage.setItem(Ia,t?"1":"0")}catch{}});function Tt(){Sa(m)}async function Wr(){if(!m||!i||!i.composer){s(n("status.pleaseOpenArticle"),!0);return}var e=R==="custom"?n("aiStyle.baseNoteCustom"):n("aiStyle.baseNoteOther",{style:R});try{await i.composer.addContexts([{type:"annotation",label:n("aiStyle.label",{file:D||n("common.markdownDocDefault")}),note:n("aiStyle.note"),promptText:n("aiStyle.promptText",{baseNote:e,path:p||n("aiStyle.pathMissing")}),reminder:n("aiStyle.reminder")}]),s(n("aiStyle.requested"))}catch(t){s(String(t),!0)}}function Hr(e){R=e,(S||y==="preview")&&j(),v()}function zr(e){if(!(e!==14&&e!==16&&e!==18)){X=e,h.setFontSize(e);try{localStorage.setItem("md-editor-font-size",String(e))}catch{}v()}}function Ur(e){if(Xe[e]){ee=e,h.setFontFamily(Xe[e]);try{localStorage.setItem("md-editor-font-family",e)}catch{}v()}}function Aa(e){H=!!e,h.setComfortWriting(H);try{localStorage.setItem("md-editor-comfort-writing",H?"1":"0")}catch{}v(),s(n(H?"status.comfortWrite":"status.comfortRead"))}function Fa(){I=!I,I&&_?(_=!1,L()):!I&&!_&&(_=!0),h.setFocusMode(I);try{localStorage.setItem("md-editor-focus-mode",I?"1":"0")}catch{}v(),s(n(I?"status.focusOn":"status.focusOff"))}var rt=null;function Oe(e){ge.hidden=!0;var t=rt;rt=null,t&&t(e)}function Da(e){return new Promise(function(t){rt=t,Ua.textContent=e,ge.hidden=!1,dt.focus()})}Kt&&Kt.addEventListener("click",function(){Oe("cancel")}),Xt&&Xt.addEventListener("click",function(){Oe("discard")}),dt&&dt.addEventListener("click",function(){Oe("save")}),ge&&ge.addEventListener("click",function(e){e.target===ge&&Oe("cancel")}),document.addEventListener("keydown",function(e){e.key==="Escape"&&rt&&Oe("cancel")});async function Ot(){return await Sa(m)}function jr(){ka(),Lt(),L(),m="",xe="",D="",p="",B=null,P="",_=!1,y="edit",h&&h.setValue(""),ca(n("home.title")),pa(""),i&&i.postMessage&&i.postMessage({type:"goHome"}),Ie(),ce(),v(),s("")}async function Pa(){if(F){var e=await Da(n("confirm.message",{file:D||n("common.markdownDocDefault")}));if(e==="cancel")return;if(i&&i.postMessage&&i.postMessage({type:"goHome"}),e==="save"){var t=await Ot();if(!t){s(n("status.saveFailedNoReturn"),!0);return}}else e==="discard"&&wa(p)}jr()}function Ta(e){if(i&&i.postMessage&&i.postMessage({type:"clientLog",message:"finch:menu received, itemId="+e}),e==="home"){Pa();return}if(e==="open"){At();return}if(e==="mode"){Ae(y==="edit"?"preview":"edit");return}if(e==="save"){Tt();return}if(e==="reload"){j();return}if(e==="reveal"){p&&i&&i.postMessage&&i.postMessage({type:"openPath",path:p});return}if(e&&e.indexOf("font-size:")===0){zr(Number(e.slice(10)));return}if(e&&e.indexOf("font-family:")===0){Ur(e.slice(12));return}if(e==="comfort:read"){Aa(!1);return}if(e==="comfort:write"){Aa(!0);return}if(e==="focus"){Fa();return}if(e==="about"){_a();return}if(e&&e.indexOf("style:slot-use:")===0){Gr(+e.slice(15));return}if(e&&e.indexOf("style:slot-save:")===0){_r(+e.slice(16));return}if(e&&e.indexOf("style:")===0){Hr(e.slice(6));return}}function Rt(){[Ue,je,Ye].forEach(function(e){e&&(e.hidden=!0)})}function Yr(e){if(e){var t=e.hidden;Rt(),e.hidden=!t}}function Bt(e,t){e&&e.addEventListener("click",function(a){a.stopPropagation(),Yr(t)}),t&&t.addEventListener("click",function(a){var r=a.target&&a.target.closest?a.target.closest("[data-app-action]"):null,o=r&&r.getAttribute("data-app-action");o&&(Ta(o),Rt())})}Jt&&Jt.addEventListener("click",Pa),ze&&ze.addEventListener("click",At),J&&J.addEventListener("click",Tt),he&&he.addEventListener("click",Fa),ve&&ve.addEventListener("click",function(){we=!we,document.body.classList.toggle("preview-hidden",!we),v(),we&&requestAnimationFrame(function(){h.layout(),j()})}),Bt(ut,Ue),Bt(ct,je),Bt(ja,Ye),document.addEventListener("click",Rt);var Nt=370,qt=560,Oa=480;Z&&Z.addEventListener("mousedown",function(e){e.preventDefault();var t=Z.parentElement;if(!t)return;var a=e.clientX,r=lt?lt.getBoundingClientRect().width:Oa;Z.classList.add("active");var o=document.createElement("div");o.style.cssText="position:fixed;inset:0;z-index:9999;cursor:col-resize;",document.body.appendChild(o);function l(c){return Math.max(Nt,Math.min(qt,c))}function u(c){var f=c.clientX-a;t.style.setProperty("--preview-width",l(r-f)+"px")}function d(){Z.classList.remove("active"),o.remove(),window.removeEventListener("mousemove",u),window.removeEventListener("mouseup",d)}window.addEventListener("mousemove",u),window.addEventListener("mouseup",d)}),window.addEventListener("resize",function(){if(S){var e=Z&&Z.parentElement;if(e){var t=parseFloat(getComputedStyle(e).getPropertyValue("--preview-width"))||Oa;(t>qt||t<Nt)&&e.style.setProperty("--preview-width",Math.max(Nt,Math.min(qt,t))+"px")}}});function Gr(e){var t=K[e];t&&(le=t.css,mt=t.label,R="custom",s(n("status.appliedStyleSlot",{label:t.label})),y==="preview"?j():Ae("preview"),v())}function _r(e){if(R!=="custom"||!le){s(n("status.needCustomStyleFirst"),!0);return}var t=mt||n("common.customStyleDefault");i&&i.postMessage&&i.postMessage({type:"saveStyleSlot",slot:e,css:le,label:t})}i&&i.onMessage&&i.onMessage(function(e){if(!(!e||typeof e!="object")){if(e.type==="ready"){if(Se=!!e.pickFileSupported,K=Array.isArray(e.styleSlots)?e.styleSlots:[null,null,null],typeof e.locale=="string"&&e.locale){var t=/^zh/i.test(e.locale);t!==qe&&(qe=t,Ht(),$e())}e.assistantName&&(Le=e.assistantName,$e()),oa(),e.homeDir&&(ne=e.homeDir,St()),v();return}if(e.type==="styleSlots"){K=Array.isArray(e.styleSlots)?e.styleSlots:[null,null,null],typeof e.savedSlot=="number"&&K[e.savedSlot]&&s(n("status.savedToSlot",{slot:e.savedSlot+1,label:K[e.savedSlot].label})),v();return}if(e.type==="clipboardImages"){var a=ae[e.requestId];if(a){delete ae[e.requestId];var r=a.sourceHtml,o=e.images&&typeof e.images=="object"?e.images:{};Object.keys(o).forEach(function(fe){typeof o[fe]=="string"&&(r=r.split(fe).join(o[fe]))}),a.resolve(Ar(r))}return}if(e.type==="clipboardImagesError"){var l=ae[e.requestId];l&&(delete ae[e.requestId],l.reject(new Error(e.message||n("status.clipboardPrepareFailedDefault"))));return}if(e.type==="pastedImage"){var u=te[e.requestId];u&&(delete te[e.requestId],u.resolve(e.url));return}if(e.type==="pasteImageError"){var d=te[e.requestId];d&&(delete te[e.requestId],d.reject(new Error(e.message||n("status.pasteImageFailedDefault")))),s(n("status.pasteImageFailed",{msg:e.message||""}));return}if(e.type==="finch:env"){S=e.view==="appView",document.body.classList.toggle("app-view",S),Vt&&(Vt.hidden=!S),h.setAiHint(n("appview.hintSpace"),n("appview.hintSpaceCode"));var c=e.cwd||"",f=e.sessionId||"",b=e.spaceId||"";(c!==re||f!==bt||b!==wt||!Ze)&&(re=c,bt=f,wt=b,Qe="",Ze=!0,St(),sa([])),ce(),v(),S&&V()&&j(),(!it.hidden||S)&&et();return}if(e.type==="recentDocuments"){if(!e.library&&(e.cwd||"")!==re)return;Qe=e.fallbackCwd||"",St(),sa(e.documents),e.library&&Ja(e.documents);return}if(e.type==="status"){s(e.message);return}if(e.type==="rewriteSessionStarted"){h.setAiWorkingLines(Number(e.startLine)||0,Number(e.endLine)||0),s(e.rewriteMode==="continue"?n("appview.continuing"):n("appview.rewriting"));return}if(e.type==="rewriteSessionFinished"){h.setAiWorkingLines(0,0),s(n("appview.rewriteDone"));return}if(e.type==="rewriteSessionFailed"){h.setAiWorkingLines(0,0),s(e.message||"Rewrite failed.",!0);return}if(e.type!=="lastFileUnavailable"){if(e.type==="finch:menu"){Ta(e.itemId);return}if(e.type==="document"){var x=N;N=!1,Pe();var q=e.markdown||"",T=e.path||"",nt=!!T&&!!p&&T!==p;if(!nt&&q===B){v();return}var Re=B===null,Be=Me;Me=!1;var Wt=It(q,e.title||n("common.markdownDocDefault"),e.path||p,x||Re||nt,e.diskMarkdown);if(!Wt){v();return}if(e.draftRestored)Fe(!0),s(n("status.draftRestored"));else if(e.draftConflict)s(n("status.draftConflict"),!0);else if(Be)s(n("status.opened",{file:D}));else if(!Re){var M=Mt;M&&M.hunks>1?s(n("status.contentUpdatedSpots",{count:M.hunks,lines:M.changedLines})):M&&M.fromLine===M.toLine?s(n("status.contentUpdatedLine",{line:M.fromLine})):s(M?n("status.contentUpdatedLines",{from:M.fromLine,to:M.toLine}):n("status.contentUpdated"))}return}if(e.type==="sourceMissing"){e.path&&e.path===p&&s(n("status.sourceMissing"),!0);return}if(e.type==="bmRendered"){if(e.requestId!==aa)return;pa(e.html||""),Ie(),Ee=!1,v(),s("");return}if(e.type==="savedMarkdown"){var Ne=ht[e.requestId];delete ht[e.requestId];var ot=de[e.requestId];if(delete de[e.requestId],e.requestId!==ra||typeof Ne!="string"){ot&&ot(!1);return}B=Ne,Fe(m!==Ne,m===Ne),s(n(m===Ne?"status.saved":"status.savedWithNewChanges")),ot&&ot(!0);return}if(e.type==="customStyleSet"){le=e.css||"",mt=e.label||n("common.customStyleDefault"),R="custom",K=Array.isArray(e.styleSlots)?e.styleSlots:K,s(n("status.savedAppliedToSlot",{labelPrefix:e.label?e.label+" \xB7 ":"",slot:typeof e.savedSlot=="number"?e.savedSlot+1:""})),y==="preview"?j():Ae("preview"),v();return}if(e.type==="exported"){s(n("status.exported",{path:e.path}));return}if(e.type!=="watchStarted"){if(e.type==="pickCancelled"){N=!1,Pe(),v(),s("");return}if(e.type==="error"){Me=!1,Object.keys(de).forEach(function(fe){var Ra=de[fe];delete de[fe],Ra&&Ra(!1)}),N=!1,Pe(),e.fallback&&(Se=!1),Ee=!1,v(),s(e.message,!0);return}}}}}),i&&i.postMessage&&i.postMessage({type:"panelReady"}),setTimeout(function(){!V()&&i&&i.postMessage&&i.postMessage({type:"requestLastFile"}),na||et()},400),Ht(),oa(),$e(),Ie(),ce()})();})();
package/i18n/en-US.json CHANGED
@@ -2,6 +2,9 @@
2
2
  "name": "Writing",
3
3
  "description": "Write Markdown in Finch and preview it as a WeChat Official Account article — with selection-based AI edits, focus mode, and AI-designed custom styles.",
4
4
  "systemPrompt": "When the user wants to edit or preview a local Markdown file, call markdown_editor_document with action 'open' and its absolute path. Treat requests such as \"write an article\", \"start writing\", \"write a post\", or \"draft something\" as an intent to use Writing even when Markdown is not mentioned. For a new document, guide the user to supply a title/topic and destination when they are missing; once enough information is available, call action 'create' with a new absolute .md path and Markdown content. If the user supplied a writing brief, draft the full Markdown; if they only want to begin, create a minimal titled starter document. The tool writes the file and opens it in Markdown Editor in one step — do not merely return prose in chat when the user wants to begin writing in the editor. Markdown Editor intentionally has no \"new file\" button. When the user asks to revise a passage selected in the editor or preview, propose precise replacement Markdown and, once approved, call action 'apply' with the full updated Markdown. When the user asks for a custom/AI-designed WeChat layout style, write plain CSS scoped under #bm-md (tag/id selectors only, no classes, use !important where needed to override the base style), drawing on bm.md's built-in style languages (kami, bauhaus, blueprint, botanical, newsprint, retro, sketch, terminal), then call action 'set_style' with the css and a short label — it applies immediately to the open preview.",
5
+ "appView": {
6
+ "description": "A full-screen Markdown workspace with a cross-Space library and live WeChat preview."
7
+ },
5
8
  "appPanel": {
6
9
  "title": "Writing",
7
10
  "toolbar": {
package/i18n/zh-CN.json CHANGED
@@ -1,7 +1,10 @@
1
1
  {
2
2
  "name": "写字",
3
3
  "description": "在 Finch 中编辑 Markdown,并可预览为微信公众号文章样式;支持框选文字请求 AI 修改和自定义排版。",
4
- "systemPrompt": "当用户要编辑或预览本地 Markdown 文件时,调用 markdown_editor_document,action 使用 open,并提供绝对路径。用户说“写文章”“开始写作”“写一篇”“写个帖子”或“起草内容”时,即使未提 Markdown,也视为要使用写字。新建文档时,若缺少标题/主题或保存位置,先引导用户补齐;信息足够后,调用 action=create,传入一个尚不存在的绝对 .md 路径和 Markdown 内容。用户提供了写作需求时,直接起草完整 Markdown;用户只想开始写作时,创建带标题的最小起稿文档。该工具会一次性写入文件并在 Markdown 编辑器中打开——用户要在编辑器开始写作时,不要只在聊天中返回一段文字。编辑器界面故意不提供“新建”按钮。当用户要修改编辑器或预览中框选的文字时,给出精确的替换 Markdown,确认后调用 action=apply 并提供完整更新后的 Markdown。当用户要求自定义/AI 设计公众号排版风格时,编写限定在 #bm-md 下的普通 CSS(标签/id 选择器,不用 class,必要时用 !important 覆盖基础风格),可参考 bm.md 内置风格(kami、bauhaus、blueprint、botanical、newsprint、retro、sketch、terminal),然后调用 action=set_style 并提供 css 与简短 label,会立即应用到当前打开的预览。",
4
+ "systemPrompt": "当用户要编辑或预览本地 Markdown 文件时,调用 markdown_editor_document,action 使用 open,并提供绝对路径。用户说“写文章”“开始写作”“写一篇”“写个帖子”或“起草内容”时,即使未提 Markdown,也视为要使用写字。新建文档时,若缺少标题/主题或保存位置,先引导用户补齐;信息足够后,调用 action=create,传入一个尚不存在的绝对 .md 路径和 Markdown 内容。用户提供了写作需求时,直接起草完整 Markdown;用户只想开始写作时,创建带标题的最小起稿文档。该工具会一次性写入文件并在 Markdown 编辑器中打开——用户要在编辑器开始写作时,不要只在聊天中返回一段文字。编辑器界面故意不提供“新建”按钮。当用户要修改编辑器或预览中框选的文字时,给出精确的替换 Markdown,确认后调用 action=apply——改动小的场合传 edits(一组针对文件当前内容的 {old_string, new_string} 局部替换),不要整篇重发;只有真正的全文重写才传完整的 markdown。一旦当前对话已通过写字开始编辑某个 Markdown 文件,后续对同一 .md 文件的所有修改都【必须优先】继续走写字的 apply/edits 路径,即使系统内置 Edit 也能完成同样的文字替换:这样才能让已打开的编辑器刷新并精准高亮改动。只有写字的 apply 实际失败后才退回系统内置 Edit;不能因为 Edit 看起来更短或更方便就切换。当用户要求自定义/AI 设计公众号排版风格时,编写限定在 #bm-md 下的普通 CSS(标签/id 选择器,不用 class,必要时用 !important 覆盖基础风格),可参考 bm.md 内置风格(kami、bauhaus、blueprint、botanical、newsprint、retro、sketch、terminal),然后调用 action=set_style 并提供 css 与简短 label,会立即应用到当前打开的预览。回复用户时,用用户能感知的说法(如“确认后我就改到文件里”“已在编辑器中打开”),不要出现工具名或 action 名——那是内部实现,照搬进回复会像在背 API。凡是给出改写方案、标题/路径或风格槽位后要等用户确认的场合,调用 Session action=suggest 给出 1-3 个可点击的简短确认项(如“就用这版”“用更短的那版”“再换个语气”)是【强制要求,不是可选项】——它和给出方案本身是同一个回合的两个必需部分,不是事后可以补的动作。不要因为方案文字已经写完、读起来像是一个完整的问句或提议,就认为确认这一步已经处理好了;只要没有实际调用 action=suggest,这个回合就还没完成。",
5
+ "appView": {
6
+ "description": "全屏 Markdown 写作工作台,支持跨空间资料库与公众号实时预览。"
7
+ },
5
8
  "appPanel": {
6
9
  "title": "写字",
7
10
  "toolbar": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "finch-markdown-editor",
3
- "version": "0.1.8",
3
+ "version": "0.2.0",
4
4
  "description": "A Markdown editor and WeChat Official Account style preview, with selection-based AI edits and AI-generated custom styles.",
5
5
  "author": {
6
6
  "name": "PuterJam",
@@ -27,7 +27,7 @@
27
27
  "annotation"
28
28
  ],
29
29
  "scripts": {
30
- "build": "esbuild src/index.ts --bundle --platform=node --format=esm --target=node20 --outfile=dist/index.js && esbuild src/codemirror.ts --bundle --platform=browser --format=iife --target=chrome120 --minify --outfile=dist/codemirror.js && node -e \"const fs=require('node:fs');fs.copyFileSync('src/panel.html','dist/panel.html');fs.rmSync('dist/bmmd',{recursive:true,force:true});fs.mkdirSync('dist/bmmd',{recursive:true});fs.cpSync('node_modules/bmmd/bin','dist/bmmd/bin',{recursive:true});fs.copyFileSync('node_modules/bmmd/LICENSE','dist/bmmd/LICENSE')\"",
30
+ "build": "esbuild src/index.ts --bundle --platform=node --format=esm --target=node20 --outfile=dist/index.js && esbuild src/codemirror.ts --bundle --platform=browser --format=iife --target=chrome120 --minify --outfile=dist/codemirror.js && esbuild src/panel.ts --bundle --platform=browser --format=iife --target=chrome120 --minify --outfile=dist/panel.js && node -e \"const fs=require('node:fs');fs.copyFileSync('src/panel.html','dist/panel.html');fs.copyFileSync('src/panel.css','dist/panel.css');fs.rmSync('dist/bmmd',{recursive:true,force:true});fs.mkdirSync('dist/bmmd',{recursive:true});fs.cpSync('node_modules/bmmd/bin','dist/bmmd/bin',{recursive:true});fs.copyFileSync('node_modules/bmmd/LICENSE','dist/bmmd/LICENSE')\"",
31
31
  "typecheck": "tsc --noEmit",
32
32
  "prepublishOnly": "npm run typecheck && npm run build && npx @finchtoys/minitools doctor ."
33
33
  },
@@ -36,7 +36,7 @@
36
36
  "minVersion": "1.6.1",
37
37
  "name": "Writing",
38
38
  "description": "Edit Markdown and preview it as a WeChat Official Account article. Select text for AI edits, or ask AI to design a custom style.",
39
- "systemPrompt": "When the user wants to edit or preview a local Markdown file, call markdown_editor_document with action 'open' and its absolute path. Treat requests such as \"write an article\", \"start writing\", \"write a post\", or \"draft something\" as an intent to use Writing even when Markdown is not mentioned. For a new document, guide the user to supply a title/topic and destination when they are missing; once enough information is available, call action 'create' with a new absolute .md path and Markdown content. If the user supplied a writing brief, draft the full Markdown; if they only want to begin, create a minimal titled starter document. The tool writes the file and opens it in Markdown Editor in one step — do not merely return prose in chat when the user wants to begin writing in the editor. Markdown Editor's own UI intentionally has no 'new file' button. When the user asks to revise a passage selected in Markdown Editor, propose precise replacement Markdown and, once approved, call action 'apply' with the full updated Markdown. When the user asks for a custom/AI-designed WeChat layout style, write plain CSS scoped under #bm-md (tag/id selectors only, use !important where needed to override the base style) inspired by bm.md's built-in styles (kami, bauhaus, blueprint, botanical, newsprint, retro, sketch, terminal), then call action 'set_style' with that css and a short label — it applies immediately in the open preview.",
39
+ "systemPrompt": "When the user wants to edit or preview a local Markdown file, call markdown_editor_document with action 'open' and its absolute path. Treat requests such as \"write an article\", \"start writing\", \"write a post\", or \"draft something\" as an intent to use Writing even when Markdown is not mentioned. For a new document, guide the user to supply a title/topic and destination when they are missing; once enough information is available, call action 'create' with a new absolute .md path and Markdown content. If the user supplied a writing brief, draft the full Markdown; if they only want to begin, create a minimal titled starter document. The tool writes the file and opens it in Markdown Editor in one step — do not merely return prose in chat when the user wants to begin writing in the editor. Markdown Editor's own UI intentionally has no 'new file' button. When the user asks to revise a passage selected in Markdown Editor, propose precise replacement Markdown and, once approved, call action 'apply' for a small change pass edits (an array of {old_string, new_string} targeted replacements matched against the file's current content) instead of resending the whole document; reserve the full markdown parameter for a genuine full rewrite. Once this conversation has started editing a Markdown document through Writing, ALL subsequent changes to that .md file MUST keep using Writing's apply/edits path first, even though the built-in Edit tool can make the same textual replacement: Writing refreshes the open editor and highlights exactly what changed. Use the built-in Edit tool only if Writing's apply actually fails, and do not switch merely because Edit appears shorter or more convenient. When the user asks for a custom/AI-designed WeChat layout style, write plain CSS scoped under #bm-md (tag/id selectors only, use !important where needed to override the base style) inspired by bm.md's built-in styles (kami, bauhaus, blueprint, botanical, newsprint, retro, sketch, terminal), then call action 'set_style' with that css and a short label — it applies immediately in the open preview. In your visible replies, describe this capability the way the user experiences it (\"I'll write it into the file\", \"opened it in the editor\"); never surface the tool name or its action names, which are internal plumbing — quoting them back makes the reply read like a machine reciting an API. Whenever you propose a rewrite, a title/path, or a style slot and then wait for the user's approval, calling Session action=suggest with 1-3 short click-to-send confirmations (e.g. 'Use this one', 'Use the shorter version', 'Try another tone') is MANDATORY, not optional — it is part of the same turn as the proposal, not a separate follow-up. Do not treat sending the proposal text as having finished the confirmation step; the turn is incomplete until action=suggest has actually been called, even if the wording already reads as a complete question or offer.",
40
40
  "main": "dist/index.js",
41
41
  "activationEvents": [
42
42
  "onStartup"
@@ -53,6 +53,14 @@
53
53
  "label": "写字图标"
54
54
  }
55
55
  ],
56
+ "appView": {
57
+ "icon": "newspaper",
58
+ "description": "A full-screen Markdown writing workspace with live WeChat preview.",
59
+ "source": {
60
+ "type": "local",
61
+ "path": "dist/panel.html"
62
+ }
63
+ },
56
64
  "appPanel": {
57
65
  "icon": "newspaper",
58
66
  "viewType": "markdown-editor.document",
@@ -177,7 +185,8 @@
177
185
  "permissions": {
178
186
  "filesystem": "readwrite",
179
187
  "network": true,
180
- "shell": true
188
+ "shell": true,
189
+ "sessions": true
181
190
  }
182
191
  },
183
192
  "devDependencies": {