jodit-pro 4.13.38 → 4.13.44
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/es2015/jodit.css +1 -1
- package/es2015/jodit.fat.min.css +1 -1
- package/es2015/jodit.fat.min.js +28 -28
- package/es2015/jodit.js +83 -190
- package/es2015/jodit.min.css +1 -1
- package/es2015/jodit.min.js +2 -2
- package/es2015/plugins/ai-assistant-pro/ai-assistant-pro.css +1 -1
- package/es2015/plugins/ai-assistant-pro/ai-assistant-pro.js +306 -168
- package/es2015/plugins/ai-assistant-pro/ai-assistant-pro.min.js +29 -29
- package/es2015/plugins/autocomplete/autocomplete.css +1 -1
- package/es2015/plugins/autocomplete/autocomplete.js +1 -1
- package/es2015/plugins/autocomplete/autocomplete.min.js +1 -1
- package/es2015/plugins/backup/backup.css +1 -1
- package/es2015/plugins/backup/backup.js +1 -1
- package/es2015/plugins/backup/backup.min.js +1 -1
- package/es2015/plugins/button-generator/button-generator.css +1 -1
- package/es2015/plugins/button-generator/button-generator.js +1 -1
- package/es2015/plugins/button-generator/button-generator.min.js +1 -1
- package/es2015/plugins/change-case/change-case.js +1 -1
- package/es2015/plugins/change-case/change-case.min.js +1 -1
- package/es2015/plugins/color-picker/color-picker.css +1 -1
- package/es2015/plugins/color-picker/color-picker.js +1 -1
- package/es2015/plugins/color-picker/color-picker.min.js +1 -1
- package/es2015/plugins/emoji/emoji.css +1 -1
- package/es2015/plugins/emoji/emoji.js +1 -1
- package/es2015/plugins/emoji/emoji.min.js +1 -1
- package/es2015/plugins/export-docs/export-docs.js +1 -1
- package/es2015/plugins/export-docs/export-docs.min.js +1 -1
- package/es2015/plugins/finder/finder.css +1 -1
- package/es2015/plugins/finder/finder.js +1 -1
- package/es2015/plugins/finder/finder.min.css +1 -1
- package/es2015/plugins/finder/finder.min.js +1 -1
- package/es2015/plugins/google-maps/google-maps.css +1 -1
- package/es2015/plugins/google-maps/google-maps.js +241 -72
- package/es2015/plugins/google-maps/google-maps.min.js +4 -4
- package/es2015/plugins/google-search/google-search.js +1 -1
- package/es2015/plugins/google-search/google-search.min.js +1 -1
- package/es2015/plugins/highlight-signature/highlight-signature.js +1 -1
- package/es2015/plugins/highlight-signature/highlight-signature.min.js +1 -1
- package/es2015/plugins/iframe-editor/iframe-editor.css +1 -1
- package/es2015/plugins/iframe-editor/iframe-editor.js +1 -1
- package/es2015/plugins/iframe-editor/iframe-editor.min.js +1 -1
- package/es2015/plugins/image-editor-pro/image-editor-pro.css +1 -1
- package/es2015/plugins/image-editor-pro/image-editor-pro.js +6 -12
- package/es2015/plugins/image-editor-pro/image-editor-pro.min.js +1 -1
- package/es2015/plugins/keyboard/keyboard.css +1 -1
- package/es2015/plugins/keyboard/keyboard.js +1 -1
- package/es2015/plugins/keyboard/keyboard.min.js +1 -1
- package/es2015/plugins/mobile-view/mobile-view.js +1 -1
- package/es2015/plugins/mobile-view/mobile-view.min.js +1 -1
- package/es2015/plugins/page-break/page-break.js +1 -1
- package/es2015/plugins/page-break/page-break.min.js +1 -1
- package/es2015/plugins/paste-code/paste-code.css +1 -1
- package/es2015/plugins/paste-code/paste-code.js +1 -1
- package/es2015/plugins/paste-code/paste-code.min.js +1 -1
- package/es2015/plugins/paste-from-word/paste-from-word.js +1 -1
- package/es2015/plugins/paste-from-word/paste-from-word.min.js +1 -1
- package/es2015/plugins/show-blocks/show-blocks.js +1 -1
- package/es2015/plugins/show-blocks/show-blocks.min.js +1 -1
- package/es2015/plugins/style/style.css +1 -1
- package/es2015/plugins/style/style.js +1 -1
- package/es2015/plugins/style/style.min.js +1 -1
- package/es2015/plugins/templates/templates.css +1 -1
- package/es2015/plugins/templates/templates.js +1 -1
- package/es2015/plugins/templates/templates.min.js +1 -1
- package/es2015/plugins/todo-list/todo-list.css +1 -1
- package/es2015/plugins/todo-list/todo-list.js +1 -1
- package/es2015/plugins/todo-list/todo-list.min.js +1 -1
- package/es2015/plugins/translate/translate.css +1 -1
- package/es2015/plugins/translate/translate.js +1 -1
- package/es2015/plugins/translate/translate.min.js +1 -1
- package/es2015/plugins/tune-block/tune-block.css +1 -1
- package/es2015/plugins/tune-block/tune-block.js +1 -1
- package/es2015/plugins/tune-block/tune-block.min.js +1 -1
- package/es2018/jodit.fat.min.css +1 -1
- package/es2018/jodit.fat.min.js +19 -19
- package/es2018/jodit.min.css +1 -1
- package/es2018/jodit.min.js +2 -2
- package/es2018/plugins/ai-assistant-pro/ai-assistant-pro.min.js +15 -15
- package/es2018/plugins/autocomplete/autocomplete.min.js +1 -1
- package/es2018/plugins/backup/backup.min.js +1 -1
- package/es2018/plugins/button-generator/button-generator.min.js +1 -1
- package/es2018/plugins/change-case/change-case.min.js +1 -1
- package/es2018/plugins/color-picker/color-picker.min.js +1 -1
- package/es2018/plugins/emoji/emoji.min.js +1 -1
- package/es2018/plugins/export-docs/export-docs.min.js +1 -1
- package/es2018/plugins/finder/finder.min.css +1 -1
- package/es2018/plugins/finder/finder.min.js +1 -1
- package/es2018/plugins/google-maps/google-maps.min.js +7 -7
- package/es2018/plugins/google-search/google-search.min.js +1 -1
- package/es2018/plugins/highlight-signature/highlight-signature.min.js +1 -1
- package/es2018/plugins/iframe-editor/iframe-editor.min.js +1 -1
- package/es2018/plugins/image-editor-pro/image-editor-pro.min.js +1 -1
- package/es2018/plugins/keyboard/keyboard.min.js +1 -1
- package/es2018/plugins/mobile-view/mobile-view.min.js +1 -1
- package/es2018/plugins/page-break/page-break.min.js +1 -1
- package/es2018/plugins/paste-code/paste-code.min.js +1 -1
- package/es2018/plugins/paste-from-word/paste-from-word.min.js +1 -1
- package/es2018/plugins/show-blocks/show-blocks.min.js +1 -1
- package/es2018/plugins/style/style.min.js +1 -1
- package/es2018/plugins/templates/templates.min.js +1 -1
- package/es2018/plugins/todo-list/todo-list.min.js +1 -1
- package/es2018/plugins/translate/translate.min.js +1 -1
- package/es2018/plugins/tune-block/tune-block.min.js +1 -1
- package/es2021/jodit.css +1 -1
- package/es2021/jodit.fat.min.css +1 -1
- package/es2021/jodit.fat.min.js +19 -19
- package/es2021/jodit.js +2 -2
- package/es2021/jodit.min.css +1 -1
- package/es2021/jodit.min.js +2 -2
- package/es2021/plugins/ai-assistant-pro/ai-assistant-pro.css +1 -1
- package/es2021/plugins/ai-assistant-pro/ai-assistant-pro.js +204 -162
- package/es2021/plugins/ai-assistant-pro/ai-assistant-pro.min.js +15 -15
- package/es2021/plugins/autocomplete/autocomplete.css +1 -1
- package/es2021/plugins/autocomplete/autocomplete.js +1 -1
- package/es2021/plugins/autocomplete/autocomplete.min.js +1 -1
- package/es2021/plugins/backup/backup.css +1 -1
- package/es2021/plugins/backup/backup.js +1 -1
- package/es2021/plugins/backup/backup.min.js +1 -1
- package/es2021/plugins/button-generator/button-generator.css +1 -1
- package/es2021/plugins/button-generator/button-generator.js +1 -1
- package/es2021/plugins/button-generator/button-generator.min.js +1 -1
- package/es2021/plugins/change-case/change-case.js +1 -1
- package/es2021/plugins/change-case/change-case.min.js +1 -1
- package/es2021/plugins/color-picker/color-picker.css +1 -1
- package/es2021/plugins/color-picker/color-picker.js +1 -1
- package/es2021/plugins/color-picker/color-picker.min.js +1 -1
- package/es2021/plugins/emoji/emoji.css +1 -1
- package/es2021/plugins/emoji/emoji.js +1 -1
- package/es2021/plugins/emoji/emoji.min.js +1 -1
- package/es2021/plugins/export-docs/export-docs.js +1 -1
- package/es2021/plugins/export-docs/export-docs.min.js +1 -1
- package/es2021/plugins/finder/finder.css +1 -1
- package/es2021/plugins/finder/finder.js +1 -1
- package/es2021/plugins/finder/finder.min.css +1 -1
- package/es2021/plugins/finder/finder.min.js +1 -1
- package/es2021/plugins/google-maps/google-maps.css +1 -1
- package/es2021/plugins/google-maps/google-maps.js +236 -75
- package/es2021/plugins/google-maps/google-maps.min.js +9 -9
- package/es2021/plugins/google-search/google-search.js +1 -1
- package/es2021/plugins/google-search/google-search.min.js +1 -1
- package/es2021/plugins/highlight-signature/highlight-signature.js +1 -1
- package/es2021/plugins/highlight-signature/highlight-signature.min.js +1 -1
- package/es2021/plugins/iframe-editor/iframe-editor.css +1 -1
- package/es2021/plugins/iframe-editor/iframe-editor.js +1 -1
- package/es2021/plugins/iframe-editor/iframe-editor.min.js +1 -1
- package/es2021/plugins/image-editor-pro/image-editor-pro.css +1 -1
- package/es2021/plugins/image-editor-pro/image-editor-pro.js +2 -4
- package/es2021/plugins/image-editor-pro/image-editor-pro.min.js +1 -1
- package/es2021/plugins/keyboard/keyboard.css +1 -1
- package/es2021/plugins/keyboard/keyboard.js +1 -1
- package/es2021/plugins/keyboard/keyboard.min.js +1 -1
- package/es2021/plugins/mobile-view/mobile-view.js +1 -1
- package/es2021/plugins/mobile-view/mobile-view.min.js +1 -1
- package/es2021/plugins/page-break/page-break.js +1 -1
- package/es2021/plugins/page-break/page-break.min.js +1 -1
- package/es2021/plugins/paste-code/paste-code.css +1 -1
- package/es2021/plugins/paste-code/paste-code.js +1 -1
- package/es2021/plugins/paste-code/paste-code.min.js +1 -1
- package/es2021/plugins/paste-from-word/paste-from-word.js +1 -1
- package/es2021/plugins/paste-from-word/paste-from-word.min.js +1 -1
- package/es2021/plugins/show-blocks/show-blocks.js +1 -1
- package/es2021/plugins/show-blocks/show-blocks.min.js +1 -1
- package/es2021/plugins/style/style.css +1 -1
- package/es2021/plugins/style/style.js +1 -1
- package/es2021/plugins/style/style.min.js +1 -1
- package/es2021/plugins/templates/templates.css +1 -1
- package/es2021/plugins/templates/templates.js +1 -1
- package/es2021/plugins/templates/templates.min.js +1 -1
- package/es2021/plugins/todo-list/todo-list.css +1 -1
- package/es2021/plugins/todo-list/todo-list.js +1 -1
- package/es2021/plugins/todo-list/todo-list.min.js +1 -1
- package/es2021/plugins/translate/translate.css +1 -1
- package/es2021/plugins/translate/translate.js +1 -1
- package/es2021/plugins/translate/translate.min.js +1 -1
- package/es2021/plugins/tune-block/tune-block.css +1 -1
- package/es2021/plugins/tune-block/tune-block.js +1 -1
- package/es2021/plugins/tune-block/tune-block.min.js +1 -1
- package/es2021.en/jodit.css +1 -1
- package/es2021.en/jodit.fat.min.css +1 -1
- package/es2021.en/jodit.fat.min.js +19 -19
- package/es2021.en/jodit.js +2 -2
- package/es2021.en/jodit.min.css +1 -1
- package/es2021.en/jodit.min.js +2 -2
- package/es2021.en/plugins/ai-assistant-pro/ai-assistant-pro.css +1 -1
- package/es2021.en/plugins/ai-assistant-pro/ai-assistant-pro.js +204 -162
- package/es2021.en/plugins/ai-assistant-pro/ai-assistant-pro.min.js +15 -15
- package/es2021.en/plugins/autocomplete/autocomplete.css +1 -1
- package/es2021.en/plugins/autocomplete/autocomplete.js +1 -1
- package/es2021.en/plugins/autocomplete/autocomplete.min.js +1 -1
- package/es2021.en/plugins/backup/backup.css +1 -1
- package/es2021.en/plugins/backup/backup.js +1 -1
- package/es2021.en/plugins/backup/backup.min.js +1 -1
- package/es2021.en/plugins/button-generator/button-generator.css +1 -1
- package/es2021.en/plugins/button-generator/button-generator.js +1 -1
- package/es2021.en/plugins/button-generator/button-generator.min.js +1 -1
- package/es2021.en/plugins/change-case/change-case.js +1 -1
- package/es2021.en/plugins/change-case/change-case.min.js +1 -1
- package/es2021.en/plugins/color-picker/color-picker.css +1 -1
- package/es2021.en/plugins/color-picker/color-picker.js +1 -1
- package/es2021.en/plugins/color-picker/color-picker.min.js +1 -1
- package/es2021.en/plugins/emoji/emoji.css +1 -1
- package/es2021.en/plugins/emoji/emoji.js +1 -1
- package/es2021.en/plugins/emoji/emoji.min.js +1 -1
- package/es2021.en/plugins/export-docs/export-docs.js +1 -1
- package/es2021.en/plugins/export-docs/export-docs.min.js +1 -1
- package/es2021.en/plugins/finder/finder.css +1 -1
- package/es2021.en/plugins/finder/finder.js +1 -1
- package/es2021.en/plugins/finder/finder.min.css +1 -1
- package/es2021.en/plugins/finder/finder.min.js +1 -1
- package/es2021.en/plugins/google-maps/google-maps.css +1 -1
- package/es2021.en/plugins/google-maps/google-maps.js +236 -75
- package/es2021.en/plugins/google-maps/google-maps.min.js +9 -9
- package/es2021.en/plugins/google-search/google-search.js +1 -1
- package/es2021.en/plugins/google-search/google-search.min.js +1 -1
- package/es2021.en/plugins/highlight-signature/highlight-signature.js +1 -1
- package/es2021.en/plugins/highlight-signature/highlight-signature.min.js +1 -1
- package/es2021.en/plugins/iframe-editor/iframe-editor.css +1 -1
- package/es2021.en/plugins/iframe-editor/iframe-editor.js +1 -1
- package/es2021.en/plugins/iframe-editor/iframe-editor.min.js +1 -1
- package/es2021.en/plugins/image-editor-pro/image-editor-pro.css +1 -1
- package/es2021.en/plugins/image-editor-pro/image-editor-pro.js +2 -4
- package/es2021.en/plugins/image-editor-pro/image-editor-pro.min.js +1 -1
- package/es2021.en/plugins/keyboard/keyboard.css +1 -1
- package/es2021.en/plugins/keyboard/keyboard.js +1 -1
- package/es2021.en/plugins/keyboard/keyboard.min.js +1 -1
- package/es2021.en/plugins/mobile-view/mobile-view.js +1 -1
- package/es2021.en/plugins/mobile-view/mobile-view.min.js +1 -1
- package/es2021.en/plugins/page-break/page-break.js +1 -1
- package/es2021.en/plugins/page-break/page-break.min.js +1 -1
- package/es2021.en/plugins/paste-code/paste-code.css +1 -1
- package/es2021.en/plugins/paste-code/paste-code.js +1 -1
- package/es2021.en/plugins/paste-code/paste-code.min.js +1 -1
- package/es2021.en/plugins/paste-from-word/paste-from-word.js +1 -1
- package/es2021.en/plugins/paste-from-word/paste-from-word.min.js +1 -1
- package/es2021.en/plugins/show-blocks/show-blocks.js +1 -1
- package/es2021.en/plugins/show-blocks/show-blocks.min.js +1 -1
- package/es2021.en/plugins/style/style.css +1 -1
- package/es2021.en/plugins/style/style.js +1 -1
- package/es2021.en/plugins/style/style.min.js +1 -1
- package/es2021.en/plugins/templates/templates.css +1 -1
- package/es2021.en/plugins/templates/templates.js +1 -1
- package/es2021.en/plugins/templates/templates.min.js +1 -1
- package/es2021.en/plugins/todo-list/todo-list.css +1 -1
- package/es2021.en/plugins/todo-list/todo-list.js +1 -1
- package/es2021.en/plugins/todo-list/todo-list.min.js +1 -1
- package/es2021.en/plugins/translate/translate.css +1 -1
- package/es2021.en/plugins/translate/translate.js +1 -1
- package/es2021.en/plugins/translate/translate.min.js +1 -1
- package/es2021.en/plugins/tune-block/tune-block.css +1 -1
- package/es2021.en/plugins/tune-block/tune-block.js +1 -1
- package/es2021.en/plugins/tune-block/tune-block.min.js +1 -1
- package/es5/jodit.css +2 -2
- package/es5/jodit.fat.min.css +1 -1
- package/es5/jodit.fat.min.js +2 -2
- package/es5/jodit.js +1788 -2701
- package/es5/jodit.min.css +3 -3
- package/es5/jodit.min.js +2 -2
- package/es5/plugins/ai-assistant-pro/ai-assistant-pro.css +1 -1
- package/es5/plugins/ai-assistant-pro/ai-assistant-pro.js +406 -275
- package/es5/plugins/ai-assistant-pro/ai-assistant-pro.min.js +2 -2
- package/es5/plugins/autocomplete/autocomplete.css +1 -1
- package/es5/plugins/autocomplete/autocomplete.js +1 -1
- package/es5/plugins/autocomplete/autocomplete.min.js +1 -1
- package/es5/plugins/backup/backup.css +1 -1
- package/es5/plugins/backup/backup.js +9 -9
- package/es5/plugins/backup/backup.min.js +2 -2
- package/es5/plugins/button-generator/button-generator.css +1 -1
- package/es5/plugins/button-generator/button-generator.js +11 -18
- package/es5/plugins/button-generator/button-generator.min.js +2 -2
- package/es5/plugins/change-case/change-case.js +1 -1
- package/es5/plugins/change-case/change-case.min.js +1 -1
- package/es5/plugins/color-picker/color-picker.css +1 -1
- package/es5/plugins/color-picker/color-picker.js +10 -17
- package/es5/plugins/color-picker/color-picker.min.js +2 -2
- package/es5/plugins/emoji/emoji.css +1 -1
- package/es5/plugins/emoji/emoji.js +7 -7
- package/es5/plugins/emoji/emoji.min.js +2 -2
- package/es5/plugins/export-docs/export-docs.js +11 -11
- package/es5/plugins/export-docs/export-docs.min.js +2 -2
- package/es5/plugins/finder/finder.css +1 -1
- package/es5/plugins/finder/finder.js +4 -10
- package/es5/plugins/finder/finder.min.css +1 -1
- package/es5/plugins/finder/finder.min.js +2 -2
- package/es5/plugins/google-maps/google-maps.css +1 -1
- package/es5/plugins/google-maps/google-maps.js +334 -114
- package/es5/plugins/google-maps/google-maps.min.js +2 -2
- package/es5/plugins/google-search/google-search.js +1 -1
- package/es5/plugins/google-search/google-search.min.js +1 -1
- package/es5/plugins/highlight-signature/highlight-signature.js +6 -6
- package/es5/plugins/highlight-signature/highlight-signature.min.js +2 -2
- package/es5/plugins/iframe-editor/iframe-editor.css +1 -1
- package/es5/plugins/iframe-editor/iframe-editor.js +6 -6
- package/es5/plugins/iframe-editor/iframe-editor.min.js +2 -2
- package/es5/plugins/image-editor-pro/image-editor-pro.css +1 -1
- package/es5/plugins/image-editor-pro/image-editor-pro.js +29 -42
- package/es5/plugins/image-editor-pro/image-editor-pro.min.js +2 -2
- package/es5/plugins/keyboard/keyboard.css +1 -1
- package/es5/plugins/keyboard/keyboard.js +6 -6
- package/es5/plugins/keyboard/keyboard.min.js +2 -2
- package/es5/plugins/mobile-view/mobile-view.js +6 -6
- package/es5/plugins/mobile-view/mobile-view.min.js +2 -2
- package/es5/plugins/page-break/page-break.js +6 -6
- package/es5/plugins/page-break/page-break.min.js +2 -2
- package/es5/plugins/paste-code/paste-code.css +1 -1
- package/es5/plugins/paste-code/paste-code.js +13 -13
- package/es5/plugins/paste-code/paste-code.min.js +2 -2
- package/es5/plugins/paste-from-word/paste-from-word.js +1 -1
- package/es5/plugins/paste-from-word/paste-from-word.min.js +1 -1
- package/es5/plugins/show-blocks/show-blocks.js +8 -8
- package/es5/plugins/show-blocks/show-blocks.min.js +2 -2
- package/es5/plugins/style/style.css +1 -1
- package/es5/plugins/style/style.js +1 -1
- package/es5/plugins/style/style.min.js +1 -1
- package/es5/plugins/templates/templates.css +1 -1
- package/es5/plugins/templates/templates.js +1 -1
- package/es5/plugins/templates/templates.min.js +1 -1
- package/es5/plugins/todo-list/todo-list.css +1 -1
- package/es5/plugins/todo-list/todo-list.js +18 -18
- package/es5/plugins/todo-list/todo-list.min.js +2 -2
- package/es5/plugins/translate/translate.css +1 -1
- package/es5/plugins/translate/translate.js +7 -7
- package/es5/plugins/translate/translate.min.js +2 -2
- package/es5/plugins/tune-block/tune-block.css +1 -1
- package/es5/plugins/tune-block/tune-block.js +7 -7
- package/es5/plugins/tune-block/tune-block.min.js +2 -2
- package/es5/polyfills.fat.min.js +2 -2
- package/es5/polyfills.js +225 -105
- package/es5/polyfills.min.js +2 -2
- package/esm/plugins/ai-assistant-pro/core/sanitize-utils.d.ts +18 -0
- package/esm/plugins/ai-assistant-pro/core/sanitize-utils.js +1 -0
- package/esm/plugins/ai-assistant-pro/tools/add-html/executor.js +1 -1
- package/esm/plugins/ai-assistant-pro/tools/replace-block/executor.js +1 -1
- package/esm/plugins/ai-assistant-pro/tools/replace-in-document/executor.js +1 -1
- package/esm/plugins/google-maps/config.js +1 -1
- package/esm/plugins/google-maps/ui/map/map.d.ts +3 -2
- package/esm/plugins/google-maps/ui/map/map.js +2 -2
- package/esm/plugins/google-maps/ui/map/modules/drawing-controller.d.ts +42 -0
- package/esm/plugins/google-maps/ui/map/modules/drawing-controller.js +1 -0
- package/package.json +1 -1
- package/types/plugins/ai-assistant-pro/core/sanitize-utils.d.ts +18 -0
- package/types/plugins/google-maps/ui/map/map.d.ts +3 -2
- package/types/plugins/google-maps/ui/map/modules/drawing-controller.d.ts +42 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* jodit-pro - PRO Version of Jodit Editor
|
|
3
3
|
* Author: Chupurnov Valerii <chupurnov@gmail.com>
|
|
4
|
-
* Version: v4.13.
|
|
4
|
+
* Version: v4.13.44
|
|
5
5
|
* Url: https://xdsoft.net/jodit/pro/
|
|
6
6
|
* License(s): SEE LICENSE IN LICENSE.md
|
|
7
7
|
*/
|
|
8
8
|
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var s=t();for(var i in s)("object"==typeof exports?exports:e)[i]=s[i]}}(self,function(){return(self.webpackChunkjodit_pro=self.webpackChunkjodit_pro||[]).push([[830],{94668:function(e){e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"> \x3c!-- Plus icon with document/context --\x3e <path d="M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 14h-3v3h-2v-3H8v-2h3v-3h2v3h3v2zm-3-7V3.5L18.5 9H13z"/> </svg>'},86428:function(e){e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"> \x3c!-- Background rounded rect --\x3e <rect x="1" y="1" width="22" height="22" rx="3"/> \x3c!-- Letter A - outer shape --\x3e <polygon points="8,5 2,19 5,19 6.5,16 11.5,16 13,19 16,19 10,5" fill="white"/> \x3c!-- Letter A - inner triangle (hole) --\x3e <polygon points="9,9 7.5,13 10.5,13" fill="currentColor"/> \x3c!-- Letter I --\x3e <rect x="17" y="5" width="3" height="14" fill="white"/> </svg>'},75966:function(e){e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"> \x3c!-- Wand handle - diagonal line --\x3e <rect x="12" y="10" width="13" height="3.5" rx="0.5" transform="rotate(45 12 12)"/> \x3c!-- Wand tip - diamond --\x3e <rect x="3" y="3" width="6" height="6" rx="1" transform="rotate(45 6 6)"/> \x3c!-- Large sparkle - top --\x3e <polygon points="15,0 16,4 15,8 14,4"/> <polygon points="11,4 15,5 19,4 15,3"/> \x3c!-- Medium sparkle - left --\x3e <polygon points="1,11 2,14 1,17 0,14"/> <polygon points="-2,14 1,15 4,14 1,13"/> \x3c!-- Small sparkle - middle --\x3e <polygon points="8,14 8.5,16 8,18 7.5,16"/> <polygon points="6,16 8,16.5 10,16 8,15.5"/> </svg>'},83207:function(e){e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path d="M9 18l6-6-6-6"/> </svg>'},99293:function(e){e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <rect x="9" y="2" width="6" height="12" rx="3"></rect> <path d="M5 10v1a7 7 0 0 0 14 0v-1" fill="none"></path> <line x1="12" y1="18" x2="12" y2="22"></line> <line x1="8" y1="22" x2="16" y2="22"></line> </svg>'},99219:function(e){e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <line x1="22" y1="2" x2="11" y2="13"></line> <polygon points="22 2 15 22 11 13 2 9 22 2"></polygon> </svg>'},63674:function(e){e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/> </svg>'},4133:function(e){e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path d="M13 2L4 14h6l-1 8 9-12h-6z"/> </svg>'},62357:function(e,t,s){"use strict";s.d(t,{UIRange:function(){return l}});var i=s(82749),n=s(31635),r=s(65478),a=s(21537),o=s(67510);class l extends o.UIInput{className(){return"UIRange"}appendUIRange(){let e=this.j.create.div(this.getFullElName("slider"));this.container.appendChild(e);let t=this.j.create.div(this.getFullElName("handle"));e.appendChild(t);let s=this.j.create.div(this.getFullElName("log")),i=this.getElm("label");i&&i.appendChild(s)}onDragStart(e){this.startValue=parseFloat(this.value)||0,this.startX=e.clientX;let t=this.getElm("slider");(0,a.assert)(null!=t,"slider element does not exists"),this.width=t.offsetWidth,this.j.e.on(this.j.ow,"mousemove",this.onDrag)}onDrag(e){let{min:t,max:s,step:i=1}=this.state,n=(e.clientX-this.startX)/this.width*(this.state.max-this.state.min),r=this.startValue+n;r<t&&(r=t),r>s&&(r=s),r=Math.round(r/i)*i,this.value=r.toFixed(10)}onDragEnd(){this.j.e.off(this.j.ow,"mousemove",this.onDrag)}onChangeSelfValue(){let e=this.getElm("handle"),t=parseFloat(this.value)||0;(0,a.assert)(null!=e,"Handle element does not exist"),(0,a.css)(e,{left:(t-this.state.min)/(this.state.max-this.state.min)*100+"%"});let s=this.getElm("log");(0,a.assert)(null!=s,"log element does not exist"),s.innerText=t.toString()}destruct(){return this.onDragEnd(),super.destruct()}constructor(e,t){super(e,{...t,type:"hidden"}),(0,i._)(this,"state",{...o.UIInput.defaultState,min:0,max:100,step:1}),(0,i._)(this,"startValue",0),(0,i._)(this,"startX",0),(0,i._)(this,"width",100),Object.assign(this.state,t),this.appendUIRange(),this.onChangeSelfValue()}}(0,n.__decorate)([(0,r.watch)(["handle:mousedown","handle:touchstart"])],l.prototype,"onDragStart",null),(0,n.__decorate)([r.autobind],l.prototype,"onDrag",null),(0,n.__decorate)([(0,r.watch)(["j.ow:mouseup","j.ow:touchend"])],l.prototype,"onDragEnd",null),(0,n.__decorate)([(0,r.watch)(":change")],l.prototype,"onChangeSelfValue",null),l=(0,n.__decorate)([r.component],l)},41810:function(e,t,s){"use strict";s.r(t),s.d(t,{aiAssistantPro:function(){return y}});var i=s(82749),n=s(31635);s(66645);var r=s(86449),a=s(21020),o=s(46166),l=s(62895),c=s(55487),h=s(27769),u=s(58579),d=s(63805),p=s(82758),g=s(65478),m=s(580),f=s(21537),v=s(50911),w=s(2692),x=s(18549),C=s(54747);class y extends v.Plugin{get state(){return this.stateManager.state}get toolRegistry(){return new c.ToolRegistry(this.j)}get permissionManager(){return new a.PermissionManager(this.j,this.toolRegistry)}get apiClient(){return new r.APIClient(this.j,this.toolRegistry)}get storage(){let{storage:e,storageKey:t,maxConversations:s}=this.j.o.aiAssistantPro;if("string"==typeof e){let i=(0,l.createStorageProvider)(e,t);return new l.WebStorageConversationStorage(i,s)}return e}get stateManager(){return new o.StateManager(this.j)}get mainPanel(){return new h.UIMainPanel(this.j,this.stateManager.state,this.j.o.aiAssistantPro,e=>{let t=this.stateManager.getCurrentConversation();t&&this.stateManager.setCurrentConversation({...t,...e})})}get dialog(){let e=this.j.dlg({resizable:this.j.o.aiAssistantPro.resizable,eventEmmiter:this.j.e});return e.e.on(e,"afterClose",()=>{this.j.e.fire("closeAIAssistantPro.ai-assistant-pro")}),e}setupTextAutocomplete(){let{textAutocompleteEnabled:e,textAutocompleteApiRequest:t,textAutocompleteMinQueryLength:s,textAutocompleteMaxSuggestions:i,textAutocompleteDebounceMs:n,textAutocompleteCacheTTL:r,textAutocompleteCacheMaxSize:a}=this.j.o.aiAssistantPro;if(!e||!t)return;this.j.o.autocomplete={...this.j.o.autocomplete,displayMode:"inline"};let o=this.textAutocompleteCache,l=null;this.textAutocompleteSource=e=>{if(e.length<s)return[];let c=`${e}:${i}`;if(r>0){let e=o.get(c);if(e&&Date.now()-e.ts<r)return e.data.map(e=>({value:e,title:e}))}l&&clearTimeout(l);let h=new AbortController;return new Promise(s=>{l=setTimeout(async()=>{try{let n=await t(e,i,h.signal);if(Array.isArray(n)){let e=n.slice(0,i);if(r>0){if(o.size>=a){let e=o.keys().next().value;null!=e&&o.delete(e)}o.set(c,{ts:Date.now(),data:e})}s(e.map(e=>({value:e,title:e})));return}s([])}catch{s([])}},n)})},this.j.e.fire("registerAutocompleteSource",this.textAutocompleteSource)}afterInit(){(0,m.extendLang)(d),this.setupEventListeners(),this.setupTextAutocomplete(),this.j.async.promise(e=>{let{initiallyOpened:t,persistOpenState:s}=this.j.o.aiAssistantPro,i=t;s?this.storage.getGlobalSettings().then(e=>{if(e?.isOpen!=null&&(i=e.isOpen),i)return this.openAssistant()}).catch(()=>null).finally(()=>e(void 0)):e(void 0)}).catch(()=>null)}__loadData(){return this.__initedPromise?this.__initedPromise:this.isDestructed?Promise.reject():(this.__initedPromise=this.j.async.promise(e=>{this.loadInitialData().then(e)}).catch(()=>null),this.__initedPromise)}async loadInitialData(){this.mainPanel.setMod("ready",!0),await (0,u.loadInitialData)(this.j,this.storage,this.stateManager),await this.restorePendingToolCalls()}async restorePendingToolCalls(){let e=this.stateManager.getCurrentConversation();if(!e)return;let t=(0,u.findMessagesWithPendingToolCalls)(e);if(0!==t.length)for(let e of t)await this.handleToolCalls(e.id)}setupEventListeners(){this.j.e.on("selectConversation.ai-assistant-pro",async e=>{try{await this.__loadData(),await (0,u.handleConversationSelect)(e,this.storage,this.stateManager)}catch(e){p.IS_PROD}}),this.j.e.on("newConversation.ai-assistant-pro",async()=>{await this.__loadData();let e=(0,u.createNewConversation)(this.j,this.state.defaultModel,this.state.defaultTemperature);this.stateManager.setCurrentConversation(e)}),this.j.e.on("deleteConversation.ai-assistant-pro",async e=>{await this.__loadData(),await this.deleteConversation(e)}),this.j.e.on("renameConversation.ai-assistant-pro",async(e,t)=>{await this.__loadData(),await this.renameConversation(e,t)}),this.j.e.on("backToList.ai-assistant-pro",async()=>{await this.__loadData(),await (0,u.handleBackToList)(this.storage,this.stateManager)}),this.j.e.on("removeContext.ai-assistant-pro",async e=>{await this.__loadData(),this.stateManager.removeSelectionContext(e)}),this.j.e.on("approveToolCall.ai-assistant-pro",async(e,t)=>{try{await this.__loadData();let s=await (0,u.handleToolApproval)(e,t,this.stateManager,this.permissionManager,this.storage);if(s){let e=this.stateManager.getCurrentConversation();if(!e)return;let t=e.messages.find(e=>e.toolCalls?.some(e=>e.id===s.id));if(!t)return;await this.executeToolCall(t.id,s)}}catch(e){if((0,f.isAbortError)(e))return;this.stateManager.setError(e instanceof Error?e.message:e+"")}}),this.j.e.on("denyToolCall.ai-assistant-pro",async e=>{await this.__loadData(),await (0,u.handleToolDenial)(this.j,e,this.stateManager,this.storage)}),this.j.e.on("abortRequest.ai-assistant-pro",async()=>{await this.__loadData(),this.apiClient.abort(),this.stateManager.setLoading(!1)})}__applyTheme(){(0,u.applyTheme)(this.j,this.stateManager.state.theme,this.stateManager.state.displayMode,this.mainPanel.container,this.dialog)}async openAssistant(){if(this.stateManager.isOpen()){this.stateManager.close(),await this.__closeInContainer();return}await this.__loadData(),this.isDestructed||(this.stateManager.open(),await this.__openInContainer(),this.j.o.aiAssistantPro.includeSelectionByDefault&&!this.j.s.isCollapsed()&&this.addCurrentSelectionToContext())}async __openInContainer(){let{resizable:e,allowClose:t,flightPanelHeight:s}=this.j.o.aiAssistantPro,{displayMode:i="right",panelWidth:n,panelHeight:r}=this.stateManager.state;switch(this.__applyTheme(),this.mainPanel.setMod("displayMode",i),this.mainPanel.setMod("allowClose",t),this.mainPanel.setParentView("dialog"===i||"flight"===i?this.dialog:this.j),this.__openedMode=i,i){case"dialog":this.dialog.setSize(n,r).open().setContent(this.mainPanel.container);break;case"flight":x.UIFlightPosition.install(this.mainPanel,this.j.container,{panelHeight:s,containerClassName:this.getFullElName("flight-container")});break;default:e&&(C.UIResize.remove(this.mainPanel),C.UIResize.install(this.mainPanel,(0,u.invertMode)(i),{handleClassName:this.getFullElName("ai-assistent-resize-handle"),onResize:({newSize:e})=>{let t="left"===i||"right"===i?e:n,s="top"===i||"bottom"===i?e:r;return this.stateManager.state.panelWidth=t,this.stateManager.state.panelHeight=s,!0}})),this.j.currentPlace.slots[i].appendChild(this.mainPanel.container),(0,u.resizeInPanelView)(this.j,i,n,r)}}__onResizeInPanelView(){let{displayMode:e,panelWidth:t,panelHeight:s}=this.stateManager.state;(0,u.resizeInPanelView)(this.j,e,t,s)}async __closeInContainer(){let{displayMode:e}=await this.stateManager.state;switch(this.__openedMode!==e&&"dialog"===this.__openedMode&&this.dialog.close(),this.__openedMode!==e&&"flight"===this.__openedMode&&this.__closeFlightMode(),e){case"dialog":this.dialog.close();break;case"flight":this.__closeFlightMode();break;default:this.mainPanel.container.remove()}}__closeFlightMode(){x.UIFlightPosition.remove(this.mainPanel)}__onSavedStateChange(){let e=this.stateManager.state;return this.storage.saveGlobalSettings({displayMode:e.displayMode,panelWidth:e.panelWidth,panelHeight:e.panelHeight,theme:e.theme,defaultModel:e.defaultModel,defaultTemperature:e.defaultTemperature,currentConversationId:e.currentConversation?.id,...this.j.o.aiAssistantPro.persistOpenState?{isOpen:e.isOpen}:{}})}async closeAssistant(){this.stateManager.isOpen()&&(await this.__loadData(),this.stateManager.close(),this.__closeInContainer())}async addCurrentSelectionToContext(){await this.__loadData();let e=(0,u.getCurrentSelectionContext)(this.j);e&&this.stateManager.addSelectionContext(e)}async executeQuickCommand(e){let t,{quickCommandsSilentMode:s,quickCommandsDisplayMode:i}=this.j.o.aiAssistantPro,n=this.j.o.aiAssistant;if(n&&n[e]&&(0,f.isString)(n[e])&&(t=n[e]),!t)return void this.j.e.fire("error","Command not found: "+e);let r=this.j.s.isCollapsed()?this.j.value:this.j.s.html;if(!r)return;let a=n?.aiCommonPrefixPrompt||"",o=n?.aiCommonSuffixPrompt||"",l=`${a}${t}${o}
|
|
9
9
|
|
|
10
|
-
${r}`.trim();s?await this.__executeQuickCommandSilent(l,r):await this.__executeQuickCommandWithPanel(l,i)}async __executeQuickCommandSilent(e,t){await this.__loadData(),this.j.progressbar.show().progress(100);try{let t=(0,u.createUserMessage)(e),s=(0,u.createNewConversation)(this.j,this.state.defaultModel,this.state.defaultTemperature,[t]),i=await this.apiClient.sendRequest(s.id,s.messages,null,[],s.options);if("final"===i.mode){let e=i.response.content;e&&this.j.s.insertHTML(e)}}catch(e){(0,f.isAbortError)(e)||this.j.e.fire("error",e)}finally{this.j.progressbar.hide()}}async __executeQuickCommandWithPanel(e,t){await this.__loadData();let s=this.stateManager.state.displayMode;this.stateManager.state.displayMode=t;let i=(0,u.getCurrentSelectionContext)(this.j);i&&this.stateManager.addSelectionContext(i),this.stateManager.isOpen()||await this.openAssistant(),await this.sendMessage(e),this.stateManager.state.displayMode=s}async sendMessage(e){await this.__loadData();let t=this.stateManager.getCurrentConversation(),s=this.stateManager.getEditingMessageId();if(s&&t){let e=t.messages.findIndex(e=>e.id===s);if(-1!==e){let s=t.messages.slice(0,e),i={...t,messages:s,updatedAt:Date.now()};this.stateManager.setCurrentConversation(i),await this.storage.save(i),this.stateManager.clearEditingMessage(),t=i}}t||(t=(0,u.createNewConversation)(this.j,this.state.defaultModel,this.state.defaultTemperature),this.stateManager.setCurrentConversation(t));let i=null;e.trim()&&(i=(0,u.createUserMessage)(e),t.title||(t={...t,title:e}),t={...t,updated:Date.now(),messages:[...t.messages,i]}),this.stateManager.setCurrentConversation({...t}),i&&this.j.e.fire("messageSent.ai-assistant-pro",i),this.stateManager.setLoading(!0),this.stateManager.clearError();try{await this.sendRequestToAI(0),this.stateManager.clearSelectionContexts()}catch(e){if((0,f.isAbortError)(e))return;this.stateManager.setError(e instanceof Error?e.message:e+"")}finally{this.stateManager.setLoading(!1)}}async sendRequestToAI(e=0){let t,s,i=this.j.o.aiAssistantPro.maxRecursionToolCallDepth;if(e>=i)throw Error(`Max recursion depth ${i} reached for tool calls`);let n=this.stateManager.getCurrentConversation();if(!n)return;let r=(0,u.findParentMessageId)(n),[a]=await Promise.all([this.apiClient.sendRequest(n.id,n.messages,r,this.stateManager.getSelectionContexts(),n.options),this.storage.save(n)]);if("stream"===a.mode){let e=await (0,u.processStreamingResponse)(this.stateManager,a,n);t=e.aiMessage,s=e.index,n=e.conversation}else{let e=(0,u.processFinalResponse)(a,n);t=e.aiMessage,s=e.index,n=e.conversation}n=await (0,u.processArtifacts)(this.j,t,n,s),this.j.e.fire("messageReceived.ai-assistant-pro",t),this.stateManager.setCurrentConversation({...n}),await this.storage.save(n),await this.handleToolCalls(t.id,e)}async deleteConversation(e){await this.__loadData(),await (0,u.deleteConversationWithCleanup)(this.j,e,this.storage,this.stateManager,this.permissionManager)}async renameConversation(e,t){let s=await this.storage.get(e);if(!s)return;let i={...s,title:t,updated:Date.now()};await this.storage.save(i),this.state.currentConversation?.id===e&&this.stateManager.setCurrentConversation(i);let n=await this.storage.list();this.stateManager.setConversations(n)}async searchConversations(e){await this.__loadData(),await (0,u.handleConversationSearch)(e,this.storage,this.stateManager)}async handleToolCalls(e,t=0){let s=this.stateManager.getCurrentConversation();if(!s)return;let i=s.messages.find(t=>t.id===e);if(!i)return;let n=i.toolCalls;if(!n||0===n.length)return;let r=n.filter(e=>!(0,u.isTerminalToolCallStatus)(e.status));if(0===r.length)return;let{approved:a,needsPermission:o}=this.permissionManager.filterToolCalls(r,s.permissions);for(let s of(this.stateManager.setPendingToolCalls(o),a))await this.executeToolCall(e,s,t)}async executeToolCall(e,t,s=0){let i=this.stateManager.getCurrentConversation();if(!i)return;let n=await (0,u.executeToolCall)(this.j,t,this.toolRegistry),r=i.messages.findIndex(t=>t.id===e);if(-1===r)return;let a=i.messages[r],o=i.messages.slice();o[r]=(0,u.updateToolCallInMessage)(a,n),i={...i,messages:o,updated:Date.now()},this.stateManager.setCurrentConversation(i),(0,u.areAllToolCallsExecuted)(i)&&await this.sendRequestToAI(s+1)}async copyMessage(e){let t=this.stateManager.getCurrentConversation();if(!t)return;let s=t.messages.find(t=>t.id===e);if(s)try{await navigator.clipboard.writeText(s.content),this.j.message.success("Message copied to clipboard")}catch(e){this.j.e.fire("error",Error("Failed to copy message"))}}async restartFromMessage(e){let t=this.stateManager.getCurrentConversation();if(!t)return;let s=t.messages.findIndex(t=>t.id===e);if(-1===s)return;let i=t.messages[s];if("user"!==i.role)return;await this.__loadData();let n=t.messages.slice(0,s),r={...t,messages:n,updatedAt:Date.now()};this.stateManager.setCurrentConversation(r),await this.storage.save(r),await this.sendMessage(i.content)}async editMessage(e){let t=this.stateManager.getCurrentConversation();if(!t)return;let s=t.messages.find(t=>t.id===e);s&&"user"===s.role&&(this.stateManager.setEditingMessageId(e),this.mainPanel.inputArea.setValue(s.content),this.mainPanel.inputArea.focus())}cancelEditMessage(){this.stateManager.isEditingMessage()&&(this.stateManager.clearEditingMessage(),this.mainPanel.inputArea.setValue(""))}async deleteMessage(e){await this.__loadData();let t=this.stateManager.getCurrentConversation();if(!t||-1===t.messages.findIndex(t=>t.id===e))return;let s=t.messages.filter(t=>t.id!==e),i={...t,messages:s,updatedAt:Date.now()};this.stateManager.setCurrentConversation(i),await this.storage.save(i)}beforeDestruct(){this.textAutocompleteSource&&(this.j.e.fire("unregisterAutocompleteSource",this.textAutocompleteSource),this.textAutocompleteSource=null),this.textAutocompleteCache.clear(),this.__closeFlightMode(),(0,g.cached)(this,"toolRegistry")?.destruct(),(0,g.cached)(this,"permissionManager")?.destruct(),(0,g.cached)(this,"apiClient")?.destruct(),(0,g.cached)(this,"stateManager")?.destruct(),(0,g.cached)(this,"mainPanel")?.destruct(),(0,g.cached)(this,"dialog")?.destruct(),(0,g.cached)(this,"storage")?.close?.()}constructor(...e){super(...e),(0,i._)(this,"buttons",[{name:"aiAssistantPro",group:"insert"},{name:"aiCommandsPro",group:"insert"}]),(0,i._)(this,"textAutocompleteSource",null),(0,i._)(this,"textAutocompleteCache",new Map),(0,i._)(this,"__initedPromise",null),(0,i._)(this,"__openedMode",null)}}(0,i._)(y,"requires",["license","autocomplete"]),(0,n.__decorate)([g.cache],y.prototype,"toolRegistry",null),(0,n.__decorate)([g.cache],y.prototype,"permissionManager",null),(0,n.__decorate)([g.cache],y.prototype,"apiClient",null),(0,n.__decorate)([g.cache],y.prototype,"storage",null),(0,n.__decorate)([g.cache],y.prototype,"stateManager",null),(0,n.__decorate)([g.cache],y.prototype,"mainPanel",null),(0,n.__decorate)([g.cache],y.prototype,"dialog",null),(0,n.__decorate)([(0,g.watch)("state.theme")],y.prototype,"__applyTheme",null),(0,n.__decorate)([(0,g.watch)(":openAIAssistantPro.ai-assistant-pro")],y.prototype,"openAssistant",null),(0,n.__decorate)([(0,g.watch)([":resize","state.panelWidth","state.panelHeight"])],y.prototype,"__onResizeInPanelView",null),(0,n.__decorate)([(0,g.watch)(["state.isOpen","state.displayMode","state.panelWidth","state.panelHeight","state.theme","state.defaultModel","state.defaultTemperature","state.currentConversation"]),(0,g.debounce)()],y.prototype,"__onSavedStateChange",null),(0,n.__decorate)([(0,g.watch)(":closeAIAssistantPro.ai-assistant-pro")],y.prototype,"closeAssistant",null),(0,n.__decorate)([(0,g.watch)(":addContextToAIAssistant.ai-assistant-pro")],y.prototype,"addCurrentSelectionToContext",null),(0,n.__decorate)([(0,g.watch)(":executeQuickCommand.ai-assistant-pro")],y.prototype,"executeQuickCommand",null),(0,n.__decorate)([(0,g.watch)(":sendMessage.ai-assistant-pro")],y.prototype,"sendMessage",null),(0,n.__decorate)([(0,g.watch)(":searchConversations.ai-assistant-pro")],y.prototype,"searchConversations",null),(0,n.__decorate)([(0,g.watch)(":copyMessage.ai-assistant-pro")],y.prototype,"copyMessage",null),(0,n.__decorate)([(0,g.watch)(":restartFromMessage.ai-assistant-pro")],y.prototype,"restartFromMessage",null),(0,n.__decorate)([(0,g.watch)(":editMessage.ai-assistant-pro")],y.prototype,"editMessage",null),(0,n.__decorate)([(0,g.watch)(":cancelEditMessage.ai-assistant-pro")],y.prototype,"cancelEditMessage",null),(0,n.__decorate)([(0,g.watch)(":deleteMessage.ai-assistant-pro")],y.prototype,"deleteMessage",null),y=(0,n.__decorate)([g.component],y),w.JoditPro.plugins.add("aiAssistantPro",y)},66645:function(e,t,s){"use strict";var i=s(47373),n=s(94668),r=s.n(n),a=s(86428),o=s.n(a),l=s(75966),c=s.n(l),h=s(83207),u=s.n(h),d=s(99293),p=s.n(d),g=s(99219),m=s.n(g),f=s(63674),v=s.n(f),w=s(4133),x=s.n(w),C=s(94454),y=s(53835),b=s(6441),k=s(12153),_=s(31974),S=s(72573);k.Icon.set("ai-assistant-pro",o()).set("ai-commands-pro",c()).set("ai-add-context",r()).set("send",m()).set("microphone",p()).set("tool-bolt",x()).set("chevron-right",u()).set("shield",v()),b.Config.prototype.aiAssistantPro={displayMode:"right",panelWidth:400,panelHeight:500,flightPanelHeight:250,dialogFullSize:!1,resizable:!0,apiMode:"incremental",apiRequest:null,maxRetries:3,requestTimeout:3e5,retryDelay:1e3,maxRecursionToolCallDepth:1e3,enabledTools:(0,y.getToolNames)(),customTools:[],toolPermissions:{},autoApproveTools:["readDocument","readBlocks","readSelection","insertHTML","addHTML"],alwaysDenyTools:[],defaultPermissionScope:"conversation",storage:"indexedDB",maxConversations:50,storageKey:"jodit-ai-assistant-pro",showConversationList:!0,enableMarkdown:!0,enableCodeHighlight:!0,maxMessageHeight:400,placeholderText:"Ask AI assistant...",sendShortcut:"Ctrl+Enter",showTimestamps:!0,formatTimestamp(e,t){let s=new Date(e),i=new Date().getTime()-s.getTime();return i<6e4?t("Just now"):i<36e5?t("%dm ago",Math.floor(i/6e4)):i<864e5?t("%dh ago",Math.floor(i/36e5)):s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})},formatMessageContent:(e,t)=>S.marked.parse(e,{breaks:!0,gfm:!0}),showAvatars:!0,showTypingIndicator:!0,includeSelectionByDefault:!0,maxContextRanges:5,showContextPreview:!0,sendOnEnter:!0,instructions:void 0,includeEditorMetadata:!1,autoOpen:!0,rememberLastConversation:!0,autoFocusInput:!0,voiceInputEnabled:!1,closeAfterInsert:!1,enableSoundNotifications:!1,debug:!1,textAutocompleteEnabled:!1,textAutocompleteApiRequest:null,textAutocompleteMinQueryLength:3,textAutocompleteMaxSuggestions:3,textAutocompleteDebounceMs:500,textAutocompleteCacheTTL:3e4,textAutocompleteCacheMaxSize:50,quickCommandsSilentMode:!1,quickCommandsDisplayMode:"flight",showCopyMessageAction:!0,showRestartMessageAction:!0,showEditMessageAction:!0,showDeleteMessageAction:!0,dialogSettings:{},allowEditDialogSettings:!1,allowEditDisplayMode:!0,allowEditPanelWidth:!0,initiallyOpened:!1,allowClose:!0,persistOpenState:!0,theme:"parent",allowEditTheme:!0,async uploadBase64Artifact(e,t){if("image"===e.type&&e.data&&"base64"===e.data.kind)try{let s=(0,i.base64ToFile)(e.data.base64,e.id,e.mimeType),n=await t.uploader.upload([s]);return{...e,data:{kind:"url",url:n.baseurl+n.files[0]},metadata:{...e.metadata,filename:n.files[0]}}}catch(e){t.e.fire("error",e)}return e},getAIProviderOptions:(e,t)=>(0,C.getAIProviderOptions)(e,t),registerAIProvider(e,t){(0,C.registerAIProvider)(e,t)}},b.Config.prototype.controls.aiAssistantPro={icon:"ai-assistant-pro",tooltip:"AI Assistant",hotkeys:["ctrl+shift+a","cmd+shift+a"],exec(e){e.e.fire("openAIAssistantPro.ai-assistant-pro")},isDisabled:e=>!e.o.aiAssistantPro.apiRequest,getLabel:e=>e.o.aiAssistantPro.apiRequest?"AI Assistant":"AI Assistant (not configured)"},b.Config.prototype.controls.aiAddContext={icon:"ai-add-context",tooltip:"Add to AI Context",exec(e){e.e.fire("addContextToAIAssistant")},isDisabled:e=>!e.o.aiAssistantPro.apiRequest||e.s.isCollapsed()},b.Config.prototype.controls.aiCommandsPro={icon:"ai-commands-pro",tooltip:"AI Commands",isDisabled:e=>!e.o.aiAssistantPro.apiRequest,list:_.aiAssitentCommands,exec(e,t,{control:s}){e.e.fire("executeQuickCommand.ai-assistant-pro",s.name)}};let A=b.Config.prototype.tuneBlock?.popup||{},M={};["p","h1","h2","h3","h4","h5","h6","div","section","article","pre","blockquote","ul","ol","li","table","tr","td","th","img","figure"].forEach(e=>{let t=A[e]||["tune.up","tune.remove","tune.down"];M[e]=[...t,"|","aiAddContext"]}),b.Config.prototype.tuneBlock&&(b.Config.prototype.tuneBlock.popup={...A,...M})},6689:function(e,t,s){"use strict";s.d(t,{throwIfAborted:function(){return n}});var i=s(93661);function n(e){if(e.aborted)throw(0,i.abort)()}},61872:function(e,t,s){"use strict";s.d(t,{processArtifacts:function(){return a},processFinalResponse:function(){return r},processStreamingResponse:function(){return n}});var i=s(61558);async function n(e,t,s){let n=(0,i.createAIMessage)(),r=-1;for await(let a of t.stream){switch(a.type){case"created":n={...n,id:a.response.responseId,content:""},r=s.messages.length;break;case"text-delta":n={...n,content:n.content+a.delta};break;case"completed":n={...n,id:a.response.responseId,toolCalls:a.response.toolCalls||[],artifacts:a.response.artifacts||[]};break;case"error":{let e=(0,i.createErrorMessage)(a.error);n={...n,id:e.id,content:e.content}}}if(n.id){let t=s.messages.slice();t[r>=0?r:s.messages.length]=n,s={...s,messages:t,updated:Date.now()},e.setCurrentConversation(s)}}return{aiMessage:n,index:r,conversation:s}}function r(e,t){let s={...(0,i.createAIMessage)(),id:e.response.responseId,content:e.response.content,toolCalls:e.response.toolCalls||[],artifacts:e.response.artifacts||[]},n=t.messages.slice();return n.push(s),{aiMessage:s,index:(t={...t,messages:n,updated:Date.now()}).messages.length-1,conversation:t}}async function a(e,t,s,n){if(t.artifacts&&t.artifacts.length>0){let r=s.messages.slice();return r[n]={...r[n],artifacts:await (0,i.uploadArtifacts)(e,t.artifacts)},{...s,messages:r,updated:Date.now()}}return s}},49459:function(e,t,s){"use strict";function i(e,t,s={}){let n=e[t];if("string"!=typeof n||!s.allowEmpty&&""===n)throw Error(`Parameter "${t}" is required and must be a${s.allowEmpty?"":" non-empty"} string`);return n}s.d(t,{requireString:function(){return i}})},44526:function(e,t,s){"use strict";s.d(t,{resolveBlock:function(){return n}});var i=s(22732);function n(e,{selector:t,index:s,requireExactlyOne:r=!1}={}){let a=null!=t&&""!==t.trim(),o=null!=s;if(r&&a===o)throw Error("Either index or selector must be provided, but not both");if(!a&&!o)throw Error("Block identifier is required");if(a){if("string"!=typeof t)throw Error("Selector must be a string");let s=e.editor.querySelector(t);if(!s)throw Error(`No element found matching selector "${t}"`);if(!i.Dom.isElement(s))throw Error(`Selector "${t}" does not point to an element node`);return{element:s,identifier:`with selector "${t}"`}}if("number"!=typeof s)throw Error("Block index must be a number");let l=Array.from(e.editor.children);if(s<0||s>=l.length)throw Error(`Block index ${s} is out of range. Document has ${l.length} blocks`);let c=l[s];if(!i.Dom.isElement(c))throw Error(`Block at index ${s} is not a valid element`);return{element:c,identifier:"at index "+s}}},70308:function(e,t,s){"use strict";s.d(t,{areAllToolCallsExecuted:function(){return l},createNewConversation:function(){return n},findMessagesWithPendingToolCalls:function(){return c},findParentMessageId:function(){return r},isTerminalToolCallStatus:function(){return o}});var i=s(21064);function n(e,t,s,r=[]){let a=e.o.aiAssistantPro,o={id:(0,i.generateConversationId)(),created:Date.now(),updated:Date.now(),messages:r,permissions:[],options:{model:t??a.defaultModel,temperature:s??a.defaultTemperature}};return e.e.fire("conversationCreated.ai-assistant-pro",o),o}function r(e){for(let t=e.messages.length-1;t>=0;t--){let s=e.messages[t];if("assistant"===s.role&&!s.id.startsWith("error_"))return s.id}return null}let a=new Set(["executed","denied","error"]);function o(e){return a.has(e)}function l(e){let t=e.messages[e.messages.length-1];return!!t?.toolCalls&&t.toolCalls.every(e=>o(e.status))}function c(e){return e.messages.filter(e=>e.toolCalls&&e.toolCalls.length>0&&e.toolCalls.some(e=>!o(e.status)))}},473:function(e,t,s){"use strict";s.d(t,{handleBackToList:function(){return l},handleConversationSearch:function(){return c},handleConversationSelect:function(){return o},handleToolApproval:function(){return r},handleToolDenial:function(){return a}});var i=s(79078),n=s(82758);async function r(e,t,s,i,n){let r=s.getPendingToolCalls().find(t=>t.id===e);if(!r)return null;let a=i.grantPermission(r.name,t),o=s.getCurrentConversation();return o&&(o.permissions.push(a),await n.save(o)),s.removePendingToolCall(e),{...r,status:"approved"}}async function a(e,t,s,n){let r=s.getPendingToolCalls().find(e=>e.id===t);if(!r)return;let a=s.getCurrentConversation();if(!a)return;let o=a.messages.findIndex(e=>e.toolCalls?.find(e=>e.id===t));if(-1===o)return;let l=a.messages[o],c={...r,result:{error:"Tool call denied by user."},status:"denied"},h=(0,i.updateToolCallInMessage)(l,c),u=[...a.messages];u[o]=h,a={...a,messages:u,updated:Date.now()},s.setCurrentConversation(a),await n.save(a),e.e.fire("toolCallDenied.ai-assistant-pro",r),s.removePendingToolCall(t)}async function o(e,t,s){try{s.setLoading(!0);let i=await t.get(e);if(!i)throw Error("Conversation not found: "+e);s.setCurrentConversation({...i})}catch(e){n.IS_PROD}finally{s.setLoading(!1)}}async function l(e,t){t.setView("conversationList");try{t.setLoading(!0);let s=await e.list().catch(()=>[]);t.setConversations(s)}finally{t.setLoading(!1)}}async function c(e,t,s){s.setLoading(!0);try{let i=await t.list(e||void 0);s.setConversations(i),s.setView("conversationList")}finally{s.setLoading(!1)}}},58579:function(e,t,s){"use strict";s.d(t,{applyTheme:function(){return h.applyTheme},areAllToolCallsExecuted:function(){return n.areAllToolCallsExecuted},createNewConversation:function(){return n.createNewConversation},createUserMessage:function(){return a.createUserMessage},deleteConversationWithCleanup:function(){return c.deleteConversationWithCleanup},executeToolCall:function(){return u.executeToolCall},findMessagesWithPendingToolCalls:function(){return n.findMessagesWithPendingToolCalls},findParentMessageId:function(){return n.findParentMessageId},getCurrentSelectionContext:function(){return l.getCurrentSelectionContext},handleBackToList:function(){return r.handleBackToList},handleConversationSearch:function(){return r.handleConversationSearch},handleConversationSelect:function(){return r.handleConversationSelect},handleToolApproval:function(){return r.handleToolApproval},handleToolDenial:function(){return r.handleToolDenial},invertMode:function(){return o.invertMode},isTerminalToolCallStatus:function(){return n.isTerminalToolCallStatus},loadInitialData:function(){return c.loadInitialData},processArtifacts:function(){return i.processArtifacts},processFinalResponse:function(){return i.processFinalResponse},processStreamingResponse:function(){return i.processStreamingResponse},resizeInPanelView:function(){return o.resizeInPanelView},updateToolCallInMessage:function(){return u.updateToolCallInMessage}});var i=s(61872),n=s(70308),r=s(473),a=s(61558),o=s(71050),l=s(15927),c=s(56110),h=s(53014),u=s(79078)},61558:function(e,t,s){"use strict";s.d(t,{createAIMessage:function(){return r},createErrorMessage:function(){return a},createUserMessage:function(){return n},uploadArtifacts:function(){return o}});var i=s(21064);function n(e){return{id:(0,i.generateMessageId)(),role:"user",content:e,timestamp:Date.now()}}function r(){return{id:"",role:"assistant",content:"",artifacts:[],timestamp:Date.now(),toolCalls:[]}}function a(e){return{id:"error_"+(0,i.generateMessageId)(),role:"assistant",content:"❌ Error: "+e.message,timestamp:Date.now(),toolCalls:[],artifacts:[]}}async function o(e,t){if(!t||0===t.length)return t;let s=e.o.aiAssistantPro.uploadBase64Artifact;return s?Promise.all(t.map(async t=>s(t,e)??t)):t}},71050:function(e,t,s){"use strict";s.d(t,{invertMode:function(){return n},resizeInPanelView:function(){return r}});var i=s(41180);function n(e){switch(e){case"left":return"right";case"right":return"left";case"top":return"bottom";case"bottom":return"top"}}function r(e,t,s,r){if("dialog"===t||"flight"===t)return;("left"===t||"right"===t)&&(e.currentPlace.slots[n(t)]?.style.setProperty(`--jd-slot-${n(t)}-width`,"auto"),e.currentPlace.slots[t]?.style.setProperty(`--jd-slot-${t}-width`,`${s}px`));let a=(0,i.css)(e.currentPlace.workplace,"height")??0;e.currentPlace.slots[t]?.style.setProperty("min-height",`${Math.min(a,r)}px`)}},15927:function(e,t,s){"use strict";function i(e){if(e.s.isCollapsed())return null;let t=e.s.html,s=e.s.range;return{html:t,rangeInfo:{startContainer:s.startContainer.nodeName,startOffset:s.startOffset,endContainer:s.endContainer.nodeName,endOffset:s.endOffset}}}s.d(t,{getCurrentSelectionContext:function(){return i}})},56110:function(e,t,s){"use strict";s.d(t,{deleteConversationWithCleanup:function(){return n},loadInitialData:function(){return r}});var i=s(82758);async function n(e,t,s,i,n){try{i.setLoading(!0),await s.delete(t),i.removeConversation(t),n.clearConversationPermissions(t);let r=i.getCurrentConversation();r?.id===t&&i.setCurrentConversation(null);let a=await s.list();i.setConversations(a),i.setView(0===a.length?"welcome":"conversationList"),e.e.fire("conversationDeleted.ai-assistant-pro",t)}catch(t){e.alert(e.i18n("Failed to delete conversation")+": "+(t?.message||"Unknown error"))}finally{i.setLoading(!1)}}async function r(e,t,s){s.setLoading(!0);try{let[i,n]=await Promise.all([t.list().catch(()=>[]),t.getGlobalSettings().catch(()=>null)]);if(s.setConversations(i),n&&s.setSavedState(n),0===i.length)s.setView("welcome");else if(e.o.aiAssistantPro.rememberLastConversation&&n?.currentConversationId){let e=i.find(e=>e.id===n.currentConversationId)??i[0],r=await t.get(e.id);r?s.setCurrentConversation(r):s.setView("conversationList")}else s.setView("conversationList")}catch(e){i.IS_PROD,s.setView("welcome")}finally{s.setLoading(!1)}}},53014:function(e,t,s){"use strict";s.d(t,{applyTheme:function(){return r}});let i=["jodit_theme_dark","jodit-ai-assistant-pro_theme_dark","jodit-dialog_theme_dark"],n=["jodit_theme_light","jodit-ai-assistant-pro_theme_light","jodit-dialog_theme_light"];function r(e,t,s,r,a){let o;if(r?.classList.remove(...i),r?.classList.remove(...n),"dialog"===s){let e=a?.container;e?.classList.remove(...i),e?.classList.remove(...n)}if(o="dark"===t?i:n,r?.classList.add(...o),"dialog"===s){let e=a?.container;e?.classList.add(...o)}}},79078:function(e,t,s){"use strict";async function i(e,t,s){let i;try{let e=new AbortController().signal,n=await s.executeTool(t.name,t.arguments,e);i={...t,result:{result:n},status:"executed"}}catch(s){i={...t,result:{error:s instanceof Error?s.message:s+""},status:"error"},e.e.fire("toolCallFailed.ai-assistant-pro",i)}return e.e.fire("toolCallExecuted.ai-assistant-pro",i,{toolCallId:i.id,result:i.result}),i}function n(e,t){let s=e.toolCalls?.findIndex(e=>e.id===t.id);if(null==s||-1===s)return e;let i=[...e?.toolCalls??[]];return i[s]=t,{...e,toolCalls:i}}s.d(t,{executeToolCall:function(){return i},updateToolCallInMessage:function(){return n}})},86449:function(e,t,s){"use strict";s.d(t,{APIClient:function(){return a}});var i=s(82749),n=s(82758),r=s(21537);class a{async sendRequest(e,t,s,i,a){let{apiRequest:o,requestTimeout:l,maxRetries:c}=this.jodit.o.aiAssistantPro;if(!o)throw Error("AI Assistant Pro callback is not configured");let h=new AbortController;this.abortControllers.add(h);try{let u=this.buildRequestContext(e,t,s,i,a),d=null;for(let e=0;c>=e;e++)try{if(h.signal.aborted)throw(0,r.abort)();let e=setTimeout(()=>{h.abort()},l);try{let t=await o(u,h.signal);return clearTimeout(e),this.validateResponse(t),t}catch(t){throw clearTimeout(e),t}}catch(t){if(d=t,n.IS_PROD,c>e){let t=this.calculateRetryDelay(e);await this.sleep(t)}else throw t}throw d||Error("API request failed after all retries")}finally{this.abortControllers.delete(h)}}abort(){this.abortControllers.forEach(e=>{e.abort()}),this.abortControllers.clear()}isInProgress(){return this.abortControllers.size>0}buildRequestContext(e,t,s,i,n){let r,{apiMode:a,instructions:o}=this.jodit.o.aiAssistantPro,l={mode:a,conversationId:e,tools:this.toolRegistry.getAllTools(),selectionContexts:i,conversationOptions:n,instructions:o};if("full"===a)r=t;else if(s){let e=t.findIndex(e=>e.id===s);r=-1!==e?t.slice(e+1):t,l={...l,parentMessageId:s}}else r=t;return{...l,messages:this.expandToolMessages(r,t.find(e=>e.id===s))}}expandToolMessages(e,t){let s=[];for(let t of e)s.push(t),this.expandToolResultsMessage(t,s);return t&&this.expandToolResultsMessage(t,s),s}expandToolResultsMessage(e,t){if(e.toolCalls&&e.toolCalls.length>0)for(let s of e.toolCalls){let i=s.result??{error:"result not found"};if(t.find(e=>e.id===`${s.id}-result`))continue;let n={id:`${s.id}-result`,role:"tool",content:i.error?"Error: "+i.error:JSON.stringify(i.result),timestamp:e.timestamp,toolResults:[{toolCallId:s.id,result:i}]};t.push(n)}}validateResponse(e){if("final"!==e.mode)return;let t=e.response;if(!t)throw Error("API returned empty response");if(!t.responseId)throw Error("API response missing responseId");if(void 0===t.content)throw Error("API response missing content");if(void 0===t.finished)throw Error("API response missing finished flag");if(t.toolCalls){if(!Array.isArray(t.toolCalls))throw Error("API response toolCalls must be an array");t.toolCalls.forEach((e,t)=>{if(!e.id)throw Error(`Tool call at index ${t} is missing id`);if(!e.name)throw Error(`Tool call at index ${t} is missing name`);if(!e.arguments||"object"!=typeof e.arguments)throw Error(`Tool call at index ${t} has invalid arguments`)})}}calculateRetryDelay(e){let{retryDelay:t}=this.jodit.o.aiAssistantPro;return t*Math.pow(2,e)+Math.random()*t}sleep(e){return new Promise(t=>setTimeout(t,e))}destruct(){this.abort()}constructor(e,t){(0,i._)(this,"jodit",void 0),(0,i._)(this,"toolRegistry",void 0),(0,i._)(this,"abortControllers",void 0),this.jodit=e,this.toolRegistry=t,this.abortControllers=new Set}}},47373:function(e,t,s){"use strict";function i(e,t,s="image/png"){let n=atob(e),r=n.length,a=new Uint8Array(r);for(let e=0;r>e;e++)a[e]=n.charCodeAt(e);return new File([new Blob([a],{type:s})],t,{type:s})}s.d(t,{base64ToFile:function(){return i}})},21020:function(e,t,s){"use strict";s.d(t,{PermissionManager:function(){return n}});var i=s(82749);class n{requiresPermission(e){let{autoApproveTools:t,alwaysDenyTools:s}=this.jodit.o.aiAssistantPro;if(s.includes(e))return!0;if(t.includes(e))return!1;let i=this.toolRegistry.getTool(e);return!i||i.requiresPermission}isAutoDenied(e){let{alwaysDenyTools:t}=this.jodit.o.aiAssistantPro;return t.includes(e)}isAutoApproved(e){let{autoApproveTools:t}=this.jodit.o.aiAssistantPro;return t.includes(e)}checkPermission(e,t){if(this.isAutoApproved(e))return{toolName:e,granted:!0,grantedAt:Date.now(),scope:"once"};if(this.isAutoDenied(e))return null;let s=this.permanentPermissions.get(e);return s&&s.granted?s:t.find(t=>t.toolName===e&&t.granted)||null}grantPermission(e,t){let s={toolName:e,granted:!0,grantedAt:Date.now(),scope:t};return"forever"===t&&(this.permanentPermissions.set(e,s),this.savePermanentPermissions()),s}denyPermission(e){return{toolName:e,granted:!1,grantedAt:Date.now(),scope:"once"}}filterToolCalls(e,t){let s=[],i=[],n=[];for(let r of e){if(this.isAutoDenied(r.name)){n.push({...r,status:"denied"});continue}if(this.isAutoApproved(r.name)){s.push({...r,status:"approved"});continue}let e=this.checkPermission(r.name,t);e&&e.granted?s.push({...r,status:"approved"}):this.requiresPermission(r.name)?(this.jodit.e.fire("permissionRequested.ai-assistant-pro",r.name),i.push({...r,status:"pending"})):s.push({...r,status:"approved"})}return{approved:s,needsPermission:i,denied:n}}clearConversationPermissions(e){}loadPermanentPermissions(){try{let e=localStorage.getItem(this.PERMANENT_PERMISSIONS_KEY);e&&JSON.parse(e).forEach(e=>{"forever"===e.scope&&e.granted&&this.permanentPermissions.set(e.toolName,e)})}catch(e){}}savePermanentPermissions(){try{let e=Array.from(this.permanentPermissions.values());localStorage.setItem(this.PERMANENT_PERMISSIONS_KEY,JSON.stringify(e))}catch(e){}}clearPermanentPermissions(){this.permanentPermissions.clear(),localStorage.removeItem(this.PERMANENT_PERMISSIONS_KEY)}getPermanentPermissions(){return Array.from(this.permanentPermissions.values())}revokePermanentPermission(e){this.permanentPermissions.delete(e),this.savePermanentPermissions()}destruct(){this.permanentPermissions.clear()}constructor(e,t){(0,i._)(this,"jodit",void 0),(0,i._)(this,"toolRegistry",void 0),(0,i._)(this,"permanentPermissions",void 0),(0,i._)(this,"PERMANENT_PERMISSIONS_KEY",void 0),this.jodit=e,this.toolRegistry=t,this.permanentPermissions=new Map,this.PERMANENT_PERMISSIONS_KEY="jodit-permissions.ai-assistant-pro",this.loadPermanentPermissions()}}},46166:function(e,t,s){"use strict";s.d(t,{StateManager:function(){return n}});var i=s(82749);class n{createInitialState(){return{isOpen:!1,currentView:"welcome",currentConversation:null,conversations:[],isLoading:!1,error:null,pendingToolCalls:[],selectionContexts:[],abortController:null,editingMessageId:null,theme:this.jodit.o.aiAssistantPro.theme||"parent",displayMode:this.jodit.o.aiAssistantPro.displayMode,panelWidth:this.jodit.o.aiAssistantPro.panelWidth,panelHeight:this.jodit.o.aiAssistantPro.panelHeight,defaultModel:this.jodit.o.aiAssistantPro.defaultModel,defaultTemperature:this.jodit.o.aiAssistantPro.defaultTemperature}}open(){this.state.isOpen=!0,this.jodit.e.fire("open.ai-assistant-pro",this.state.currentConversation)}close(){this.state.isOpen=!1,this.jodit.e.fire("close.ai-assistant-pro")}isOpen(){return this.state.isOpen}setView(e){this.state.currentView=e,this.jodit.e.fire("viewChanged.ai-assistant-pro",e)}getView(){return this.state.currentView}setConversations(e){this.state.conversations=e}setSavedState(e){e.theme&&(this.state.theme=e.theme),e.displayMode&&(this.state.displayMode=e.displayMode),e.panelWidth&&(this.state.panelWidth=e.panelWidth),e.panelHeight&&(this.state.panelHeight=e.panelHeight),e.defaultModel&&(this.state.defaultModel=e.defaultModel),e.defaultTemperature&&(this.state.defaultTemperature=e.defaultTemperature)}getConversations(){return this.state.conversations}setCurrentConversation(e){if(this.state.currentConversation===e)throw Error("Conversation is already current");this.state.currentConversation=e||null,e&&(this.setView("conversation"),this.jodit.e.fire("conversationSwitched.ai-assistant-pro",e))}getCurrentConversation(){return this.state.currentConversation}removeConversation(e){let t=this.state.conversations.filter(t=>t.id!==e);this.setConversations(t)}setLoading(e){this.state.isLoading=e}isLoading(){return this.state.isLoading}setError(e){this.state.error=e,e&&this.jodit.e.fire("error.ai-assistant-pro",Error(e))}getError(){return this.state.error}clearError(){this.setError(null)}setPendingToolCalls(e){this.state.pendingToolCalls=e}getPendingToolCalls(){return this.state.pendingToolCalls}addPendingToolCall(e){let t=[...this.state.pendingToolCalls,e];this.setPendingToolCalls(t)}removePendingToolCall(e){let t=this.state.pendingToolCalls.filter(t=>t.id!==e);this.setPendingToolCalls(t)}updateToolCallStatus(e,t){let s=this.state.pendingToolCalls.map(s=>s.id===e?{...s,status:t}:s);this.setPendingToolCalls(s)}setSelectionContexts(e){this.state.selectionContexts=e}getSelectionContexts(){return this.state.selectionContexts}addSelectionContext(e){let{maxContextRanges:t}=this.jodit.o.aiAssistantPro,s=[...this.state.selectionContexts,e];s.length>t&&(s=s.slice(-t)),this.setSelectionContexts(s),this.jodit.e.fire("contextAdded.ai-assistant-pro",e)}removeSelectionContext(e){let t=this.state.selectionContexts.filter((t,s)=>s!==e);this.setSelectionContexts(t),this.jodit.e.fire("contextRemoved.ai-assistant-pro",e)}clearSelectionContexts(){this.setSelectionContexts([])}setAbortController(e){this.state.abortController=e}getAbortController(){return this.state.abortController}setEditingMessageId(e){this.state.editingMessageId=e}getEditingMessageId(){return this.state.editingMessageId}isEditingMessage(){return null!=this.state.editingMessageId}clearEditingMessage(){this.setEditingMessageId(null)}reset(){this.state=this.createInitialState()}destruct(){this.state.abortController&&this.state.abortController.abort(),this.reset()}constructor(e){(0,i._)(this,"jodit",void 0),(0,i._)(this,"state",void 0),this.jodit=e,this.state=this.createInitialState()}}},62895:function(e,t,s){"use strict";s.d(t,{WebStorageConversationStorage:function(){return i.WebStorageConversationStorage},createStorageProvider:function(){return i.createStorageProvider}});var i=s(21064)},21064:function(e,t,s){"use strict";s.d(t,{WebStorageConversationStorage:function(){return r},createStorageProvider:function(){return a},generateConversationId:function(){return o},generateMessageId:function(){return l}});var i=s(82749),n=s(97333);class r{close(){return this.storage.close()}getConversationKey(e){return"conv:"+e}async getAllKeys(){let e=await this.storage.get("__conversation_index__");return e&&Array.isArray(e)?e:[]}async updateIndex(e){await this.storage.set("__conversation_index__",e)}async addToIndex(e){let t=await this.getAllKeys();t.includes(e)||(t.push(e),await this.updateIndex(t))}async removeFromIndex(e){let t=(await this.getAllKeys()).filter(t=>t!==e);await this.updateIndex(t)}async list(e){try{let t=await this.getAllKeys(),s=[],i=e?.toLowerCase().trim();for(let e of t){let t=await this.get(e);if(t){if(i){let e=t.title?.toLowerCase().includes(i),s=!e&&t.messages.some(e=>e.content.toLowerCase().includes(i));if(!e&&!s)continue}s.push({id:t.id,title:t.title??"",created:t.created,updated:t.updated,messageCount:t.messages.length})}}return s.sort((e,t)=>t.updated-e.updated),s}catch(e){return[]}}async get(e){try{let t=this.getConversationKey(e);return await this.storage.get(t)||null}catch(e){return null}}async save(e){try{if(0===e.messages.length)throw Error("Conversation must have at least one message.");let t=await this.getAllKeys();t.length>=this.maxConversations&&!t.includes(e.id)&&await this.evictOldest();let s=this.getConversationKey(e.id);await this.storage.set(s,e),await this.addToIndex(e.id)}catch(t){if(t?.name==="QuotaExceededError"||t?.code===22||t?.code===1014){await this.evictOldest();try{let t=this.getConversationKey(e.id);await this.storage.set(t,e),await this.addToIndex(e.id)}catch{throw Error("Storage quota exceeded. Please delete some conversations.")}}else throw Error("Failed to save conversation: "+(t?.message||"Unknown error"))}}async delete(e){try{let t=this.getConversationKey(e);await this.storage.delete(t),await this.removeFromIndex(e)}catch(e){}}async clear(){try{for(let e of(await this.getAllKeys())){let t=this.getConversationKey(e);await this.storage.delete(t)}await this.updateIndex([])}catch(e){}}async evictOldest(){try{let e=await this.list();if(0===e.length)return;e.sort((e,t)=>e.updated-t.updated);let t=e[0];await this.delete(t.id)}catch(e){}}async getGlobalSettings(){try{return await this.storage.get("global-settings")||null}catch(e){return null}}async saveGlobalSettings(e){try{let t={...await this.getGlobalSettings(),...e};await this.storage.set("global-settings",t)}catch{throw Error("Failed to save global settings")}}constructor(e,t){(0,i._)(this,"storage",void 0),(0,i._)(this,"maxConversations",void 0),this.storage=e,this.maxConversations=t}}function a(e,t){return n.AsyncStorage.makeStorage(e,t)}function o(){return`conv_${Date.now()}_${Math.random().toString(36).substring(2,11)}`}function l(){return`msg_${Date.now()}_${Math.random().toString(36).substring(2,11)}`}},55487:function(e,t,s){"use strict";s.d(t,{ToolRegistry:function(){return r}});var i=s(82749),n=s(53835);class r{registerBuiltInTools(e){e.forEach(e=>{let t=n.BUILT_IN_TOOLS[e];t&&this.tools.set(e,t)})}registerCustomTools(e){e.forEach(e=>{this.validateToolDefinition(e),this.tools.set(e.name,e)})}validateToolDefinition(e){if(!e.name||"string"!=typeof e.name)throw Error("Tool must have a valid name");if(!e.description||"string"!=typeof e.description)throw Error(`Tool "${e.name}" must have a description`);if(!Array.isArray(e.parameters))throw Error(`Tool "${e.name}" must have a parameters array`);if("function"!=typeof e.execute)throw Error(`Tool "${e.name}" must have an execute function`);e.parameters.forEach(t=>{if(!t.name||"string"!=typeof t.name)throw Error(`Tool "${e.name}" has a parameter without a valid name`);if(!t.type)throw Error(`Tool "${e.name}" parameter "${t.name}" must have a type`);if("boolean"!=typeof t.required)throw Error(`Tool "${e.name}" parameter "${t.name}" must specify if it's required`)})}getAllTools(){return Array.from(this.tools.values())}getTool(e){return this.tools.get(e)}hasTool(e){return this.tools.has(e)}getToolNames(){return Array.from(this.tools.keys())}async executeTool(e,t,s){let i=this.getTool(e);if(!i)throw Error(`Tool "${e}" not found`);let n=this.applyDefaults(i,t);this.validateArguments(i,n);try{return await i.execute(this.jodit,n,s)}catch(e){if(e?.name==="AbortError"||s.aborted)throw Error("Tool execution was aborted");throw e}}validateArguments(e,t){let s=Object.keys(t);for(let t of e.parameters.filter(e=>e.required).map(e=>e.name))if(!s.includes(t))throw Error(`Tool "${e.name}" requires parameter "${t}"`);for(let[s,i]of Object.entries(t)){let t=e.parameters.find(e=>e.name===s);if(!t){this.jodit.o.aiAssistantPro.debug;continue}let n=Array.isArray(i)?"array":"object"==typeof i&&null!=i?"object":typeof i;if(t.type!==n&&!("number"===t.type&&"string"===n&&!isNaN(Number(i))))throw Error(`Tool "${e.name}" parameter "${s}" expects type "${t.type}" but got "${n}"`);if(t.enum&&t.enum.length>0&&!t.enum.includes(i))throw Error(`Tool "${e.name}" parameter "${s}" must be one of: ${t.enum.join(", ")}`)}}applyDefaults(e,t){let s={...t};for(let t of e.parameters)void 0===s[t.name]&&void 0!==t.default&&(s[t.name]=t.default);return s}destruct(){this.tools.clear()}constructor(e){(0,i._)(this,"jodit",void 0),(0,i._)(this,"tools",void 0),this.jodit=e,this.tools=new Map,this.registerBuiltInTools(e.o.aiAssistantPro.enabledTools||[]),this.registerCustomTools(e.o.aiAssistantPro.customTools||[])}}},26612:function(e){e.exports={"AI Assistant":"AI Assistant","AI Assistant Pro":"AI Assistant Pro","Welcome to AI Assistant":"Welcome to AI Assistant","Start your first conversation":"Start your first conversation","Tip: Select text in editor to add context":"Tip: Select text in editor to add context","New Chat":"New Chat","Search conversations...":"Search conversations...","No conversations yet":"No conversations yet","Ask me anything...":"Ask me anything...","Ask a follow-up...":"Ask a follow-up...","Reply...":"Reply...","Type your message...":"Type your message...",Send:"Send",Cancel:"Cancel",Retry:"Retry",Insert:"Insert",Copy:"Copy",Edit:"Edit",Delete:"Delete",New:"New",Back:"Back","Permission Required":"Permission Required",Approve:"Approve",Deny:"Deny",Once:"Once","This conversation":"This conversation",Always:"Always","The AI wants to execute:":"The AI wants to execute:","This will modify your document content.":"This will modify your document content.","Executing...":"Executing...","Completed successfully":"Completed successfully",Failed:"Failed","Pending approval":"Pending approval","Denied by user":"Denied by user","Tool Result":"Tool Result","Tool Execution Error":"Tool Execution Error",Context:"Context",Contexts:"Contexts","Add to AI Context":"Add to AI Context",Remove:"Remove","Clear all":"Clear all","An error occurred":"An error occurred","Request failed":"Request failed","Connection error":"Connection error","AI Assistant is not configured":"AI Assistant is not configured","Thinking...":"Thinking...","Generating response...":"Generating response...",insertHTML:"Insert HTML",readDocument:"Read Document",readBlock:"Read Block",replaceInDocument:"Replace in Document",replaceInBlock:"Replace in Block",getSelection:"Get Selection","Just now":"Just now",Conversation:"Conversation","New Conversation":"New Conversation",Yesterday:"Yesterday","Delete conversation":"Delete conversation","Are you sure you want to delete this conversation?":"Are you sure you want to delete this conversation?","Failed to delete conversation":"Failed to delete conversation"}},63805:function(e,t,s){"use strict";s.r(t),s.d(t,{en:function(){return n.a},ru:function(){return a.a}});var i=s(26612),n=s.n(i),r=s(41324),a=s.n(r)},94454:function(e,t,s){"use strict";s.d(t,{getAIProviderOptions:function(){return i.getAIProviderOptions},registerAIProvider:function(){return i.registerAIProvider}}),s(82923);var i=s(58211)},82923:function(e,t,s){"use strict";var i=s(58211),n=s(54079);(0,i.registerAIProvider)("jodit-ai-adapter",e=>{let t=e.url.replace(/\/+$/,""),s=e.provider??"openai",i=!1!==e.stream;return{apiMode:"incremental",maxRetries:0,voiceInputEnabled:!0,voiceInputUrl:`${t.replace(/^http/,"ws")}/v1/ai/transcribe`,voiceInputApiKey:e.apiKey,textAutocompleteEnabled:!0,async textAutocompleteApiRequest(i,r,a){let o=new n.Ajax({url:`${t}/ai/autocomplete?query=${encodeURIComponent(i)}&key=${encodeURIComponent(e.apiKey)}`,method:"POST",contentType:"application/json",data:{provider:s,context:{maxSuggestions:r}}});a.addEventListener("abort",()=>o.abort(),{once:!0});let l=await o.send(),c=await l.json();return c.success&&c.result?.suggestions?c.result.suggestions:[]},async apiRequest(r,a){let o=new n.Ajax({url:`${t}/ai/request?key=${encodeURIComponent(e.apiKey)}`,method:"POST",contentType:"application/json",data:{provider:s,context:i?{...r,metadata:{...r.metadata,stream:!0}}:r}});if(a&&a.addEventListener("abort",()=>o.abort(),{once:!0}),!i){let e=await o.send();return{mode:"final",response:(await e.json()).result}}let l=o.stream();return{mode:"stream",stream:async function*(){for await(let e of l)yield JSON.parse(e)}()}}}})},58211:function(e,t,s){"use strict";s.d(t,{getAIProviderOptions:function(){return n},registerAIProvider:function(){return r}});let i=new Map;function n(e,t){let s=i.get(e);if(!s)throw Error(`AI provider "${e}" is not registered. Available providers: `+[...i.keys()].join(", "));return s(t)}function r(e,t){i.set(e,t)}},65374:function(e,t,s){"use strict";s.r(t),s.d(t,{description:function(){return n},name:function(){return i},parameters:function(){return r},requiresPermission:function(){return a}});let i="addHTML",n="Add HTML content to the beginning or end of the document",r=[{name:"html",type:"string",description:"HTML content to add",required:!0},{name:"position",type:"string",description:'Where to add: "start" adds at the beginning of the document, "end" appends to the end',required:!1,default:"end"}],a=!0},686:function(e,t,s){"use strict";s.d(t,{execute:function(){return a}});var i=s(6689),n=s(49459),r=s(22732);async function a(e,t,s){let a=(0,n.requireString)(t,"html",{allowEmpty:!0}),{position:o="end"}=t;if(!a.trim())return{success:!0,message:"Nothing to add: HTML is empty"};(0,i.throwIfAborted)(s);try{let t=e.createInside.fragment(),s=e.createInside.div();for(s.innerHTML=a;s.firstChild;)t.appendChild(s.firstChild);return"start"===o?r.Dom.prepend(e.editor,t):r.Dom.append(e.editor,t),e.synchronizeValues(),{success:!0,message:`Added ${a.length} characters of HTML at the ${"start"===o?"beginning":"end"} of the document`}}catch(e){throw Error("Failed to add HTML: "+(e?.message||"Unknown error"))}}},78907:function(e,t,s){"use strict";var i=s(65374),n=s(686);t.default={...i,execute:n.execute}},73943:function(e,t,s){"use strict";s.r(t),s.d(t,{description:function(){return n},name:function(){return i},parameters:function(){return r},requiresPermission:function(){return a}});let i="applyFormat",n="Apply or remove inline formatting to the current selection (bold, italic, underline, etc.) or to a specific block",r=[{name:"element",type:"string",description:'HTML element to wrap selection (e.g., "strong", "em", "u", "span")',required:!1},{name:"attributes",type:"object",description:'Attributes to apply (e.g., {"className": "highlight"}, {"style": {"color": "red"}})',required:!1},{name:"remove",type:"boolean",description:"If true, remove the formatting instead of applying it",required:!1,default:!1},{name:"blockIndex",type:"number",description:"Zero-based index of the block to format (if not using current selection)",required:!1},{name:"selector",type:"string",description:"CSS selector to find the block to format (if not using current selection)",required:!1}],a=!0},19127:function(e,t,s){"use strict";s.d(t,{execute:function(){return r}});var i=s(6689),n=s(44526);async function r(e,t,s){let{element:r,attributes:a,remove:o,blockIndex:l,selector:c}=t;if((0,i.throwIfAborted)(s),!r&&!a)throw Error('Either "element" or "attributes" must be provided');if(e.s.restore(),void 0!==l||c){let{element:t}=(0,n.resolveBlock)(e,{selector:c,index:l});e.s.select(t)}if(e.s.isCollapsed())throw Error("No selection found. Please select text to format");try{let t={};return r&&(t.element=r),a&&(t.attributes=a),o?e.s.commitStyle({...t,mode:"remove"}):e.s.commitStyle(t),e.synchronizeValues(),{success:!0,message:o?"Formatting removed successfully":"Formatting applied successfully"}}catch(e){throw Error(`Failed to ${o?"remove":"apply"} formatting: ${e.message}`)}}},39296:function(e,t,s){"use strict";var i=s(73943),n=s(19127);t.default={...i,execute:n.execute}},53835:function(e,t,s){"use strict";s.d(t,{BUILT_IN_TOOLS:function(){return p},getToolNames:function(){return g}});var i=s(78907),n=s(39296),r=s(16745),a=s(78717),o=s(5618),l=s(90991),c=s(2020),h=s(12570),u=s(95323),d=s(97603);let p={readDocument:o.default,readBlocks:a.default,readSelection:l.default,writeDocument:d.default,replaceSelection:u.default,replaceBlock:c.default,replaceInDocument:h.default,insertHTML:r.default,addHTML:i.default,applyFormat:n.default};function g(){return Object.keys(p)}},56732:function(e,t,s){"use strict";s.r(t),s.d(t,{description:function(){return n},name:function(){return i},parameters:function(){return r},requiresPermission:function(){return a}});let i="insertHTML",n="Insert or replace HTML content at the current cursor position in the editor",r=[{name:"html",type:"string",description:"HTML content to insert",required:!0},{name:"replace",type:"boolean",description:"If true, replaces current selection. If false, inserts at cursor",required:!1,default:!1}],a=!0},39592:function(e,t,s){"use strict";s.d(t,{execute:function(){return r}});var i=s(6689),n=s(49459);async function r(e,t,s){let r=(0,n.requireString)(t,"html",{allowEmpty:!0}),{replace:a}=t;if(!r.trim())return{success:!0,message:"Nothing to insert: HTML is empty"};(0,i.throwIfAborted)(s);try{return e.s.focus(),a&&!e.s.isCollapsed()&&e.s.remove(),e.s.insertHTML(r),e.synchronizeValues(),{success:!0,message:`Inserted ${r.length} characters of HTML`}}catch(e){throw Error("Failed to insert HTML: "+(e?.message||"Unknown error"))}}},16745:function(e,t,s){"use strict";var i=s(56732),n=s(39592);t.default={...i,execute:n.execute}},75352:function(e,t,s){"use strict";s.r(t),s.d(t,{description:function(){return n},name:function(){return i},parameters:function(){return r},requiresPermission:function(){return a}});let i="readBlocks",n="Read blocks from the editor with optional filtering and pagination",r=[{name:"offset",type:"number",description:"Number of blocks to skip from the beginning (default: 0)",required:!1,default:0},{name:"limit",type:"number",description:"Maximum number of blocks to return (default: all)",required:!1},{name:"query",type:"string",description:"Filter blocks by text content",required:!1}],a=!1},91140:function(e,t,s){"use strict";s.d(t,{execute:function(){return r}});var i=s(6689),n=s(22732);async function r(e,t,s){let{offset:r,limit:a,query:o}=t;(0,i.throwIfAborted)(s);let l=[];Array.from(e.editor.children).forEach((e,t)=>{n.Dom.isElement(e)&&l.push({blockIndex:t,tagName:e.tagName.toLowerCase(),content:e.innerHTML,textContent:e.textContent||"",classList:Array.from(e.classList)})});let c=l;if(o&&"string"==typeof o){let e=o.toLowerCase();c=l.filter(t=>t.textContent.toLowerCase().includes(e)||t.tagName.includes(e)||t.content.toLowerCase().includes(e))}let h=Math.max(0,Math.min("number"==typeof r?r:0,c.length)),u=void 0!==a?Math.min(h+a,c.length):c.length;return{blocks:c.slice(h,u),total:l.length,offset:h,limit:void 0!==a?a:void 0}}},78717:function(e,t,s){"use strict";var i=s(75352),n=s(91140);t.default={...i,execute:n.execute}},93809:function(e,t,s){"use strict";s.r(t),s.d(t,{description:function(){return n},name:function(){return i},parameters:function(){return r},requiresPermission:function(){return a}});let i="readDocument",n="Read the entire content of the editor document in HTML format",r=[{name:"start",type:"number",description:"Start character position (default: 0)",required:!1,default:0},{name:"end",type:"number",description:"End character position (default: length of document)",required:!1},{name:"aroundSelection",type:"boolean",description:"If true, return only the maximum block around the current selection",required:!1,default:!1}],a=!1},28157:function(e,t,s){"use strict";s.d(t,{execute:function(){return r}});var i=s(6689),n=s(22732);async function r(e,t,s){let{start:r,end:a,aroundSelection:o}=t;(0,i.throwIfAborted)(s);let l=e.value,c=l.length;if(o&&!e.s.isCollapsed()){let t=e.s.range.commonAncestorContainer;for(;t&&t!==e.editor;){if(n.Dom.isElement(t)&&t.parentNode===e.editor){l=t.outerHTML;break}t=t.parentNode}return{html:l,length:c}}let h=void 0!==a?Math.min(a,c):c,u=Math.max(0,Math.min("number"==typeof r?r:0,c));return(u>0||c>h)&&(l=l.substring(u,h)),{html:l,length:c,start:u,end:h}}},5618:function(e,t,s){"use strict";var i=s(93809),n=s(28157);t.default={...i,execute:n.execute}},52826:function(e,t,s){"use strict";s.r(t),s.d(t,{description:function(){return n},name:function(){return i},parameters:function(){return r},requiresPermission:function(){return a}});let i="readSelection",n="Get information about the current selection including HTML content and optional context",r=[{name:"contextCharsBefore",type:"number",description:"Number of characters to include before the selection",required:!1,default:0},{name:"contextCharsAfter",type:"number",description:"Number of characters to include after the selection",required:!1,default:0}],a=!1},85130:function(e,t,s){"use strict";s.d(t,{execute:function(){return n}});var i=s(6689);async function n(e,t,s){let{contextCharsBefore:n,contextCharsAfter:r}=t;if((0,i.throwIfAborted)(s),e.s.restore(),e.s.isCollapsed())return{hasSelection:!1};let a=e.s.html,o=e.s.range,l=o.toString(),c={hasSelection:!0,html:a,text:l,startContainer:o.startContainer.nodeName,endContainer:o.endContainer.nodeName};if(n>0||r>0){let t=e.editor.textContent||"",s=t.substring(0,t.indexOf(l)),i=t.substring(t.indexOf(l)+l.length);n>0&&(c.contextBefore=s.slice(-n)),r>0&&(c.contextAfter=i.slice(0,r))}return c}},90991:function(e,t,s){"use strict";var i=s(52826),n=s(85130);t.default={...i,execute:n.execute}},96675:function(e,t,s){"use strict";s.r(t),s.d(t,{description:function(){return n},name:function(){return i},parameters:function(){return r},requiresPermission:function(){return a}});let i="replaceBlock",n="Replace a specific block in the document by its index or CSS selector with new HTML content",r=[{name:"index",type:"number",description:"Zero-based index of the block to replace (use either index or selector, not both)",required:!1},{name:"selector",type:"string",description:'CSS selector to find the block to replace (e.g., "h1", ".my-class", "#my-id"). Use either selector or index, not both',required:!1},{name:"html",type:"string",description:"HTML content for the new block",required:!0}],a=!0},3091:function(e,t,s){"use strict";s.d(t,{execute:function(){return o}});var i=s(6689),n=s(49459),r=s(44526),a=s(22732);async function o(e,t,s){let{index:o,selector:l}=t,c=(0,n.requireString)(t,"html");if((0,i.throwIfAborted)(s),void 0===o&&!l||void 0!==o&&l)throw Error("Either index or selector must be provided, but not both");let{element:h,identifier:u}=(0,r.resolveBlock)(e,{selector:l,index:o,requireExactlyOne:!0});try{let t=e.createInside.div();t.innerHTML=c;let s=t.firstChild;if(!s||!a.Dom.isElement(s))throw Error("Invalid HTML: must contain at least one element");return h.parentNode?.replaceChild(s,h),e.synchronizeValues(),{success:!0,message:`Block ${u} replaced successfully`}}catch(e){throw Error(`Failed to replace block ${u}: ${e.message}`)}}},2020:function(e,t,s){"use strict";var i=s(96675),n=s(3091);t.default={...i,execute:n.execute}},62553:function(e,t,s){"use strict";s.r(t),s.d(t,{description:function(){return n},name:function(){return i},parameters:function(){return r},requiresPermission:function(){return a}});let i="replaceInDocument",n="Find and replace text or HTML patterns throughout the entire document",r=[{name:"search",type:"string",description:"Text or pattern to search for",required:!0},{name:"replace",type:"string",description:"Replacement text or HTML",required:!0},{name:"useRegex",type:"boolean",description:"If true, treats search as a regular expression",required:!1,default:!1},{name:"useSelector",type:"string",description:"CSS selector to narrow down the search scope to specific elements",required:!1}],a=!0},56293:function(e,t,s){"use strict";s.d(t,{execute:function(){return r}});var i=s(6689),n=s(49459);async function r(e,t,s){let r=(0,n.requireString)(t,"search"),a=(0,n.requireString)(t,"replace",{allowEmpty:!0}),{useRegex:o,useSelector:l}=t;(0,i.throwIfAborted)(s);try{let t;e.s.focus(),e.s.save();let n=0;if(l){let c=function(e,t,s,n,r,a){let o=e.editor.querySelectorAll(r);if(0===o.length)return{replacements:0,message:`No elements found matching selector "${r}"`};let l=0;return o.forEach(e=>{(0,i.throwIfAborted)(a);let r=e.innerHTML,o=r;if(n)try{let e=RegExp(t,"g");r=r.replace(e,()=>(l++,s))}catch(e){throw Error("Invalid regex pattern: "+(e?.message||"Unknown error"))}else{let e=t.length,n=0;for(;-1!==(n=r.indexOf(t,n));)(0,i.throwIfAborted)(a),r=r.substring(0,n)+s+r.substring(n+e),n+=s.length,l++}r!==o&&(e.innerHTML=r)}),l>0&&(e.synchronizeValues(),e.s.restore()),{replacements:l}}(e,r,a,o,l,s);n=c.replacements,t=c.message}else n=function(e,t,s,n,r,a){let o=0,l=t;if(r)try{let e=RegExp(s,"g");l=l.replace(e,()=>(o++,n))}catch(e){throw Error("Invalid regex pattern: "+(e?.message||"Unknown error"))}else{let e=s.length,t=0;for(;-1!==(t=l.indexOf(s,t));)(0,i.throwIfAborted)(a),l=l.substring(0,t)+n+l.substring(t+e),t+=n.length,o++}return o>0&&(e.value=l,e.s.restore(),e.synchronizeValues()),o}(e,e.value,r,a,o,s);return{replacements:n,message:t||(n>0?`Replaced ${n} occurrence(s)`:"No matches found")}}catch(t){throw e.s.restore(),Error("Failed to replace in document: "+(t?.message||"Unknown error"))}}},12570:function(e,t,s){"use strict";var i=s(62553),n=s(56293);t.default={...i,execute:n.execute}},70750:function(e,t,s){"use strict";s.r(t),s.d(t,{description:function(){return n},name:function(){return i},parameters:function(){return r},requiresPermission:function(){return a}});let i="replaceSelection",n="Replace the current selection with new HTML content",r=[{name:"html",type:"string",description:"HTML content to insert in place of the selection",required:!0},{name:"collapseToEnd",type:"boolean",description:"Move cursor to the end of the inserted content",required:!1,default:!0}],a=!0},36142:function(e,t,s){"use strict";s.d(t,{execute:function(){return r}});var i=s(6689),n=s(49459);async function r(e,t,s){let r=(0,n.requireString)(t,"html"),{collapseToEnd:a}=t;(0,i.throwIfAborted)(s);try{if(e.s.restore(),e.s.insertHTML(r),a){let t=e.s.range;t.collapse(!1),e.s.selectRange(t)}return e.e.fire("change"),{success:!0,message:"Selection replaced successfully"}}catch(e){throw Error("Failed to replace selection: "+e.message)}}},95323:function(e,t,s){"use strict";var i=s(70750),n=s(36142);t.default={...i,execute:n.execute}},90022:function(e,t,s){"use strict";s.r(t),s.d(t,{description:function(){return n},name:function(){return i},parameters:function(){return r},requiresPermission:function(){return a}});let i="writeDocument",n="Write (replace) the entire document content with new HTML",r=[{name:"html",type:"string",description:"HTML content to set as the document",required:!0}],a=!0},79766:function(e,t,s){"use strict";s.d(t,{execute:function(){return r}});var i=s(6689),n=s(49459);async function r(e,t,s){let r=(0,n.requireString)(t,"html",{allowEmpty:!0});(0,i.throwIfAborted)(s);try{return e.s.focus(),e.value=r,e.synchronizeValues(),{success:!0,message:`Document content was replaced with provided HTML(${r.length} characters)`}}catch(e){throw Error("Failed to replace HTML: "+(e?.message||"Unknown error"))}}},97603:function(e,t,s){"use strict";var i=s(90022),n=s(79766);t.default={...i,execute:n.execute}},80453:function(e,t,s){"use strict";s.d(t,{UIConversationListItem:function(){return c}});var i=s(82749),n=s(31635),r=s(65478),a=s(67510),o=s(62843),l=s(80870);class c extends a.UIElement{className(){return"UIConversationListItem"}render(){return'<div class="jodit-ui-conversation-list__item"></div>'}setActive(e){this.isActive=e,this.updateContent()}updateContent(){let e=this.container;e.innerHTML="",e.setAttribute("data-id",this.conversation.id),this.isActive?e.classList.add("jodit-ui-conversation-list__item_active"):e.classList.remove("jodit-ui-conversation-list__item_active");let t=this.j.c.div("jodit-ui-conversation-list__item-avatar");t.textContent="AI",e.appendChild(t);let s=this.j.c.div("jodit-ui-conversation-list__item-wrapper"),i=this.j.c.div("jodit-ui-conversation-list__item-content"),n=this.j.c.div("jodit-ui-conversation-list__item-title");if(n.textContent=this.conversation.title,this.titleElement=n,i.appendChild(n),this.opts.showTimestamps){let e=this.j.c.div("jodit-ui-conversation-list__item-meta");e.textContent=this.opts.formatTimestamp(this.conversation.updated,this.j.i18n.bind(this.j)),i.appendChild(e)}if(s.appendChild(i),this.conversation.messageCount>0){let e=this.j.c.div("jodit-ui-conversation-list__item-badge");e.textContent=this.conversation.messageCount+"",s.appendChild(e)}e.appendChild(s),this.actionsButton||(this.actionsButton=new o.UIButton(this.j,{icon:{name:"dots"},tooltip:"Actions",name:"conversationActions",size:"tiny"}),this.actionsButton.container.classList.add("jodit-ui-conversation-list__item-actions"),this.actionsButton.onAction(e=>{e.stopPropagation(),this.showActionsMenu(e)})),e.appendChild(this.actionsButton.container)}onClick(){this.isRenaming||this.j.e.fire("selectConversation.ai-assistant-pro",this.conversation.id)}showActionsMenu(e){if(!this.contextMenu||!this.actionsButton)return;let t=this.actionsButton.container.getBoundingClientRect();this.contextMenu.show(t.left,t.bottom,[{title:"Rename",icon:"pencil",exec:()=>{this.startInlineRename()}},{title:"Delete",icon:"bin",exec:()=>{this.onDelete()}}]),e.stopPropagation()}startInlineRename(){if(this.isRenaming||!this.titleElement)return;this.isRenaming=!0;let e=this.titleElement,t=this.conversation.title,s=this.j.c.element("input");s.type="text",s.value=t,s.className="jodit-ui-conversation-list__item-title-input",e.textContent="",e.appendChild(s),s.focus(),s.select();let i=()=>{if(!this.isRenaming)return;let i=s.value.trim();this.isRenaming=!1,i&&i!==t?(e.textContent=i,this.j.e.fire("renameConversation.ai-assistant-pro",this.conversation.id,i)):e.textContent=t};this.j.e.on(s,"blur",i),this.j.e.on(s,"keydown",i=>{"Enter"===i.key&&(i.preventDefault(),s.blur()),"Escape"===i.key&&(this.isRenaming=!1,e.textContent=t)}),this.j.e.on(s,"click",e=>{e.stopPropagation()})}onDelete(){this.j.e.fire("deleteConversation.ai-assistant-pro",this.conversation.id)}destruct(){this.actionsButton?.destruct(),this.contextMenu?.destruct(),super.destruct()}constructor(e,t,s=!1,n){super(e),(0,i._)(this,"opts",void 0),(0,i._)(this,"conversation",void 0),(0,i._)(this,"isActive",void 0),(0,i._)(this,"actionsButton",void 0),(0,i._)(this,"contextMenu",void 0),(0,i._)(this,"titleElement",void 0),(0,i._)(this,"isRenaming",void 0),this.opts=n,this.actionsButton=null,this.contextMenu=null,this.titleElement=null,this.isRenaming=!1,this.conversation=t,this.isActive=s,this.contextMenu=new l.ContextMenu(this.j),this.updateContent()}}(0,n.__decorate)([(0,r.watch)("container:click")],c.prototype,"onClick",null),(0,n.__decorate)([r.autobind],c.prototype,"showActionsMenu",null),(0,n.__decorate)([r.autobind],c.prototype,"startInlineRename",null),(0,n.__decorate)([r.autobind],c.prototype,"onDelete",null),c=(0,n.__decorate)([r.component],c)},68365:function(e,t,s){"use strict";s.d(t,{UIConversationList:function(){return h}});var i=s(82749),n=s(31635),r=s(31356),a=s(80453),o=s(65478),l=s(80256),c=s(62405);class h extends c.UIGroup{className(){return"UIConversationList"}render(){return`<div class="&__container">
|
|
10
|
+
${r}`.trim();s?await this.__executeQuickCommandSilent(l,r):await this.__executeQuickCommandWithPanel(l,i)}async __executeQuickCommandSilent(e,t){await this.__loadData(),this.j.progressbar.show().progress(100);try{let t=(0,u.createUserMessage)(e),s=(0,u.createNewConversation)(this.j,this.state.defaultModel,this.state.defaultTemperature,[t]),i=await this.apiClient.sendRequest(s.id,s.messages,null,[],s.options);if("final"===i.mode){let e=i.response.content;e&&this.j.s.insertHTML(e)}}catch(e){(0,f.isAbortError)(e)||this.j.e.fire("error",e)}finally{this.j.progressbar.hide()}}async __executeQuickCommandWithPanel(e,t){await this.__loadData();let s=this.stateManager.state.displayMode;this.stateManager.state.displayMode=t;let i=(0,u.getCurrentSelectionContext)(this.j);i&&this.stateManager.addSelectionContext(i),this.stateManager.isOpen()||await this.openAssistant(),await this.sendMessage(e),this.stateManager.state.displayMode=s}async sendMessage(e){await this.__loadData();let t=this.stateManager.getCurrentConversation(),s=this.stateManager.getEditingMessageId();if(s&&t){let e=t.messages.findIndex(e=>e.id===s);if(-1!==e){let s=t.messages.slice(0,e),i={...t,messages:s,updatedAt:Date.now()};this.stateManager.setCurrentConversation(i),await this.storage.save(i),this.stateManager.clearEditingMessage(),t=i}}t||(t=(0,u.createNewConversation)(this.j,this.state.defaultModel,this.state.defaultTemperature),this.stateManager.setCurrentConversation(t));let i=null;e.trim()&&(i=(0,u.createUserMessage)(e),t.title||(t={...t,title:e}),t={...t,updated:Date.now(),messages:[...t.messages,i]}),this.stateManager.setCurrentConversation({...t}),i&&this.j.e.fire("messageSent.ai-assistant-pro",i),this.stateManager.setLoading(!0),this.stateManager.clearError();try{await this.sendRequestToAI(0),this.stateManager.clearSelectionContexts()}catch(e){if((0,f.isAbortError)(e))return;this.stateManager.setError(e instanceof Error?e.message:e+"")}finally{this.stateManager.setLoading(!1)}}async sendRequestToAI(e=0){let t,s,i=this.j.o.aiAssistantPro.maxRecursionToolCallDepth;if(e>=i)throw Error(`Max recursion depth ${i} reached for tool calls`);let n=this.stateManager.getCurrentConversation();if(!n)return;let r=(0,u.findParentMessageId)(n),[a]=await Promise.all([this.apiClient.sendRequest(n.id,n.messages,r,this.stateManager.getSelectionContexts(),n.options),this.storage.save(n)]);if("stream"===a.mode){let e=await (0,u.processStreamingResponse)(this.stateManager,a,n);t=e.aiMessage,s=e.index,n=e.conversation}else{let e=(0,u.processFinalResponse)(a,n);t=e.aiMessage,s=e.index,n=e.conversation}n=await (0,u.processArtifacts)(this.j,t,n,s),this.j.e.fire("messageReceived.ai-assistant-pro",t),this.stateManager.setCurrentConversation({...n}),await this.storage.save(n),await this.handleToolCalls(t.id,e)}async deleteConversation(e){await this.__loadData(),await (0,u.deleteConversationWithCleanup)(this.j,e,this.storage,this.stateManager,this.permissionManager)}async renameConversation(e,t){let s=await this.storage.get(e);if(!s)return;let i={...s,title:t,updated:Date.now()};await this.storage.save(i),this.state.currentConversation?.id===e&&this.stateManager.setCurrentConversation(i);let n=await this.storage.list();this.stateManager.setConversations(n)}async searchConversations(e){await this.__loadData(),await (0,u.handleConversationSearch)(e,this.storage,this.stateManager)}async handleToolCalls(e,t=0){let s=this.stateManager.getCurrentConversation();if(!s)return;let i=s.messages.find(t=>t.id===e);if(!i)return;let n=i.toolCalls;if(!n||0===n.length)return;let r=n.filter(e=>!(0,u.isTerminalToolCallStatus)(e.status));if(0===r.length)return;let{approved:a,needsPermission:o}=this.permissionManager.filterToolCalls(r,s.permissions);for(let s of(this.stateManager.setPendingToolCalls(o),a))await this.executeToolCall(e,s,t)}async executeToolCall(e,t,s=0){let i=this.stateManager.getCurrentConversation();if(!i)return;let n=await (0,u.executeToolCall)(this.j,t,this.toolRegistry),r=i.messages.findIndex(t=>t.id===e);if(-1===r)return;let a=i.messages[r],o=i.messages.slice();o[r]=(0,u.updateToolCallInMessage)(a,n),i={...i,messages:o,updated:Date.now()},this.stateManager.setCurrentConversation(i),(0,u.areAllToolCallsExecuted)(i)&&await this.sendRequestToAI(s+1)}async copyMessage(e){let t=this.stateManager.getCurrentConversation();if(!t)return;let s=t.messages.find(t=>t.id===e);if(s)try{await navigator.clipboard.writeText(s.content),this.j.message.success("Message copied to clipboard")}catch(e){this.j.e.fire("error",Error("Failed to copy message"))}}async restartFromMessage(e){let t=this.stateManager.getCurrentConversation();if(!t)return;let s=t.messages.findIndex(t=>t.id===e);if(-1===s)return;let i=t.messages[s];if("user"!==i.role)return;await this.__loadData();let n=t.messages.slice(0,s),r={...t,messages:n,updatedAt:Date.now()};this.stateManager.setCurrentConversation(r),await this.storage.save(r),await this.sendMessage(i.content)}async editMessage(e){let t=this.stateManager.getCurrentConversation();if(!t)return;let s=t.messages.find(t=>t.id===e);s&&"user"===s.role&&(this.stateManager.setEditingMessageId(e),this.mainPanel.inputArea.setValue(s.content),this.mainPanel.inputArea.focus())}cancelEditMessage(){this.stateManager.isEditingMessage()&&(this.stateManager.clearEditingMessage(),this.mainPanel.inputArea.setValue(""))}async deleteMessage(e){await this.__loadData();let t=this.stateManager.getCurrentConversation();if(!t||-1===t.messages.findIndex(t=>t.id===e))return;let s=t.messages.filter(t=>t.id!==e),i={...t,messages:s,updatedAt:Date.now()};this.stateManager.setCurrentConversation(i),await this.storage.save(i)}beforeDestruct(){this.textAutocompleteSource&&(this.j.e.fire("unregisterAutocompleteSource",this.textAutocompleteSource),this.textAutocompleteSource=null),this.textAutocompleteCache.clear(),this.__closeFlightMode(),(0,g.cached)(this,"toolRegistry")?.destruct(),(0,g.cached)(this,"permissionManager")?.destruct(),(0,g.cached)(this,"apiClient")?.destruct(),(0,g.cached)(this,"stateManager")?.destruct(),(0,g.cached)(this,"mainPanel")?.destruct(),(0,g.cached)(this,"dialog")?.destruct(),(0,g.cached)(this,"storage")?.close?.()}constructor(...e){super(...e),(0,i._)(this,"buttons",[{name:"aiAssistantPro",group:"insert"},{name:"aiCommandsPro",group:"insert"}]),(0,i._)(this,"textAutocompleteSource",null),(0,i._)(this,"textAutocompleteCache",new Map),(0,i._)(this,"__initedPromise",null),(0,i._)(this,"__openedMode",null)}}(0,i._)(y,"requires",["license","autocomplete"]),(0,n.__decorate)([g.cache],y.prototype,"toolRegistry",null),(0,n.__decorate)([g.cache],y.prototype,"permissionManager",null),(0,n.__decorate)([g.cache],y.prototype,"apiClient",null),(0,n.__decorate)([g.cache],y.prototype,"storage",null),(0,n.__decorate)([g.cache],y.prototype,"stateManager",null),(0,n.__decorate)([g.cache],y.prototype,"mainPanel",null),(0,n.__decorate)([g.cache],y.prototype,"dialog",null),(0,n.__decorate)([(0,g.watch)("state.theme")],y.prototype,"__applyTheme",null),(0,n.__decorate)([(0,g.watch)(":openAIAssistantPro.ai-assistant-pro")],y.prototype,"openAssistant",null),(0,n.__decorate)([(0,g.watch)([":resize","state.panelWidth","state.panelHeight"])],y.prototype,"__onResizeInPanelView",null),(0,n.__decorate)([(0,g.watch)(["state.isOpen","state.displayMode","state.panelWidth","state.panelHeight","state.theme","state.defaultModel","state.defaultTemperature","state.currentConversation"]),(0,g.debounce)()],y.prototype,"__onSavedStateChange",null),(0,n.__decorate)([(0,g.watch)(":closeAIAssistantPro.ai-assistant-pro")],y.prototype,"closeAssistant",null),(0,n.__decorate)([(0,g.watch)(":addContextToAIAssistant.ai-assistant-pro")],y.prototype,"addCurrentSelectionToContext",null),(0,n.__decorate)([(0,g.watch)(":executeQuickCommand.ai-assistant-pro")],y.prototype,"executeQuickCommand",null),(0,n.__decorate)([(0,g.watch)(":sendMessage.ai-assistant-pro")],y.prototype,"sendMessage",null),(0,n.__decorate)([(0,g.watch)(":searchConversations.ai-assistant-pro")],y.prototype,"searchConversations",null),(0,n.__decorate)([(0,g.watch)(":copyMessage.ai-assistant-pro")],y.prototype,"copyMessage",null),(0,n.__decorate)([(0,g.watch)(":restartFromMessage.ai-assistant-pro")],y.prototype,"restartFromMessage",null),(0,n.__decorate)([(0,g.watch)(":editMessage.ai-assistant-pro")],y.prototype,"editMessage",null),(0,n.__decorate)([(0,g.watch)(":cancelEditMessage.ai-assistant-pro")],y.prototype,"cancelEditMessage",null),(0,n.__decorate)([(0,g.watch)(":deleteMessage.ai-assistant-pro")],y.prototype,"deleteMessage",null),y=(0,n.__decorate)([g.component],y),w.JoditPro.plugins.add("aiAssistantPro",y)},66645:function(e,t,s){"use strict";var i=s(47373),n=s(94668),r=s.n(n),a=s(86428),o=s.n(a),l=s(75966),c=s.n(l),h=s(83207),u=s.n(h),d=s(99293),p=s.n(d),g=s(99219),m=s.n(g),f=s(63674),v=s.n(f),w=s(4133),x=s.n(w),C=s(94454),y=s(53835),b=s(6441),k=s(12153),_=s(31974),S=s(72573);k.Icon.set("ai-assistant-pro",o()).set("ai-commands-pro",c()).set("ai-add-context",r()).set("send",m()).set("microphone",p()).set("tool-bolt",x()).set("chevron-right",u()).set("shield",v()),b.Config.prototype.aiAssistantPro={displayMode:"right",panelWidth:400,panelHeight:500,flightPanelHeight:250,dialogFullSize:!1,resizable:!0,apiMode:"incremental",apiRequest:null,maxRetries:3,requestTimeout:3e5,retryDelay:1e3,maxRecursionToolCallDepth:1e3,enabledTools:(0,y.getToolNames)(),customTools:[],toolPermissions:{},autoApproveTools:["readDocument","readBlocks","readSelection","insertHTML","addHTML"],alwaysDenyTools:[],defaultPermissionScope:"conversation",storage:"indexedDB",maxConversations:50,storageKey:"jodit-ai-assistant-pro",showConversationList:!0,enableMarkdown:!0,enableCodeHighlight:!0,maxMessageHeight:400,placeholderText:"Ask AI assistant...",sendShortcut:"Ctrl+Enter",showTimestamps:!0,formatTimestamp(e,t){let s=new Date(e),i=new Date().getTime()-s.getTime();return i<6e4?t("Just now"):i<36e5?t("%dm ago",Math.floor(i/6e4)):i<864e5?t("%dh ago",Math.floor(i/36e5)):s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})},formatMessageContent:(e,t)=>S.marked.parse(e,{breaks:!0,gfm:!0}),showAvatars:!0,showTypingIndicator:!0,includeSelectionByDefault:!0,maxContextRanges:5,showContextPreview:!0,sendOnEnter:!0,instructions:void 0,includeEditorMetadata:!1,autoOpen:!0,rememberLastConversation:!0,autoFocusInput:!0,voiceInputEnabled:!1,closeAfterInsert:!1,enableSoundNotifications:!1,debug:!1,textAutocompleteEnabled:!1,textAutocompleteApiRequest:null,textAutocompleteMinQueryLength:3,textAutocompleteMaxSuggestions:3,textAutocompleteDebounceMs:500,textAutocompleteCacheTTL:3e4,textAutocompleteCacheMaxSize:50,quickCommandsSilentMode:!1,quickCommandsDisplayMode:"flight",showCopyMessageAction:!0,showRestartMessageAction:!0,showEditMessageAction:!0,showDeleteMessageAction:!0,dialogSettings:{},allowEditDialogSettings:!1,allowEditDisplayMode:!0,allowEditPanelWidth:!0,initiallyOpened:!1,allowClose:!0,persistOpenState:!0,theme:"parent",allowEditTheme:!0,async uploadBase64Artifact(e,t){if("image"===e.type&&e.data&&"base64"===e.data.kind)try{let s=(0,i.base64ToFile)(e.data.base64,e.id,e.mimeType),n=await t.uploader.upload([s]);return{...e,data:{kind:"url",url:n.baseurl+n.files[0]},metadata:{...e.metadata,filename:n.files[0]}}}catch(e){t.e.fire("error",e)}return e},getAIProviderOptions:(e,t)=>(0,C.getAIProviderOptions)(e,t),registerAIProvider(e,t){(0,C.registerAIProvider)(e,t)}},b.Config.prototype.controls.aiAssistantPro={icon:"ai-assistant-pro",tooltip:"AI Assistant",hotkeys:["ctrl+shift+a","cmd+shift+a"],exec(e){e.e.fire("openAIAssistantPro.ai-assistant-pro")},isDisabled:e=>!e.o.aiAssistantPro.apiRequest,getLabel:e=>e.o.aiAssistantPro.apiRequest?"AI Assistant":"AI Assistant (not configured)"},b.Config.prototype.controls.aiAddContext={icon:"ai-add-context",tooltip:"Add to AI Context",exec(e){e.e.fire("addContextToAIAssistant")},isDisabled:e=>!e.o.aiAssistantPro.apiRequest||e.s.isCollapsed()},b.Config.prototype.controls.aiCommandsPro={icon:"ai-commands-pro",tooltip:"AI Commands",isDisabled:e=>!e.o.aiAssistantPro.apiRequest,list:_.aiAssitentCommands,exec(e,t,{control:s}){e.e.fire("executeQuickCommand.ai-assistant-pro",s.name)}};let A=b.Config.prototype.tuneBlock?.popup||{},M={};["p","h1","h2","h3","h4","h5","h6","div","section","article","pre","blockquote","ul","ol","li","table","tr","td","th","img","figure"].forEach(e=>{let t=A[e]||["tune.up","tune.remove","tune.down"];M[e]=[...t,"|","aiAddContext"]}),b.Config.prototype.tuneBlock&&(b.Config.prototype.tuneBlock.popup={...A,...M})},6689:function(e,t,s){"use strict";s.d(t,{throwIfAborted:function(){return n}});var i=s(93661);function n(e){if(e.aborted)throw(0,i.abort)()}},61872:function(e,t,s){"use strict";s.d(t,{processArtifacts:function(){return a},processFinalResponse:function(){return r},processStreamingResponse:function(){return n}});var i=s(61558);async function n(e,t,s){let n=(0,i.createAIMessage)(),r=-1;for await(let a of t.stream){switch(a.type){case"created":n={...n,id:a.response.responseId,content:""},r=s.messages.length;break;case"text-delta":n={...n,content:n.content+a.delta};break;case"completed":n={...n,id:a.response.responseId,toolCalls:a.response.toolCalls||[],artifacts:a.response.artifacts||[]};break;case"error":{let e=(0,i.createErrorMessage)(a.error);n={...n,id:e.id,content:e.content}}}if(n.id){let t=s.messages.slice();t[r>=0?r:s.messages.length]=n,s={...s,messages:t,updated:Date.now()},e.setCurrentConversation(s)}}return{aiMessage:n,index:r,conversation:s}}function r(e,t){let s={...(0,i.createAIMessage)(),id:e.response.responseId,content:e.response.content,toolCalls:e.response.toolCalls||[],artifacts:e.response.artifacts||[]},n=t.messages.slice();return n.push(s),{aiMessage:s,index:(t={...t,messages:n,updated:Date.now()}).messages.length-1,conversation:t}}async function a(e,t,s,n){if(t.artifacts&&t.artifacts.length>0){let r=s.messages.slice();return r[n]={...r[n],artifacts:await (0,i.uploadArtifacts)(e,t.artifacts)},{...s,messages:r,updated:Date.now()}}return s}},49459:function(e,t,s){"use strict";function i(e,t,s={}){let n=e[t];if("string"!=typeof n||!s.allowEmpty&&""===n)throw Error(`Parameter "${t}" is required and must be a${s.allowEmpty?"":" non-empty"} string`);return n}s.d(t,{requireString:function(){return i}})},44526:function(e,t,s){"use strict";s.d(t,{resolveBlock:function(){return n}});var i=s(22732);function n(e,{selector:t,index:s,requireExactlyOne:r=!1}={}){let a=null!=t&&""!==t.trim(),o=null!=s;if(r&&a===o)throw Error("Either index or selector must be provided, but not both");if(!a&&!o)throw Error("Block identifier is required");if(a){if("string"!=typeof t)throw Error("Selector must be a string");let s=e.editor.querySelector(t);if(!s)throw Error(`No element found matching selector "${t}"`);if(!i.Dom.isElement(s))throw Error(`Selector "${t}" does not point to an element node`);return{element:s,identifier:`with selector "${t}"`}}if("number"!=typeof s)throw Error("Block index must be a number");let l=Array.from(e.editor.children);if(s<0||s>=l.length)throw Error(`Block index ${s} is out of range. Document has ${l.length} blocks`);let c=l[s];if(!i.Dom.isElement(c))throw Error(`Block at index ${s} is not a valid element`);return{element:c,identifier:"at index "+s}}},70308:function(e,t,s){"use strict";s.d(t,{areAllToolCallsExecuted:function(){return l},createNewConversation:function(){return n},findMessagesWithPendingToolCalls:function(){return c},findParentMessageId:function(){return r},isTerminalToolCallStatus:function(){return o}});var i=s(21064);function n(e,t,s,r=[]){let a=e.o.aiAssistantPro,o={id:(0,i.generateConversationId)(),created:Date.now(),updated:Date.now(),messages:r,permissions:[],options:{model:t??a.defaultModel,temperature:s??a.defaultTemperature}};return e.e.fire("conversationCreated.ai-assistant-pro",o),o}function r(e){for(let t=e.messages.length-1;t>=0;t--){let s=e.messages[t];if("assistant"===s.role&&!s.id.startsWith("error_"))return s.id}return null}let a=new Set(["executed","denied","error"]);function o(e){return a.has(e)}function l(e){let t=e.messages[e.messages.length-1];return!!t?.toolCalls&&t.toolCalls.every(e=>o(e.status))}function c(e){return e.messages.filter(e=>e.toolCalls&&e.toolCalls.length>0&&e.toolCalls.some(e=>!o(e.status)))}},473:function(e,t,s){"use strict";s.d(t,{handleBackToList:function(){return l},handleConversationSearch:function(){return c},handleConversationSelect:function(){return o},handleToolApproval:function(){return r},handleToolDenial:function(){return a}});var i=s(79078),n=s(82758);async function r(e,t,s,i,n){let r=s.getPendingToolCalls().find(t=>t.id===e);if(!r)return null;let a=i.grantPermission(r.name,t),o=s.getCurrentConversation();return o&&(o.permissions.push(a),await n.save(o)),s.removePendingToolCall(e),{...r,status:"approved"}}async function a(e,t,s,n){let r=s.getPendingToolCalls().find(e=>e.id===t);if(!r)return;let a=s.getCurrentConversation();if(!a)return;let o=a.messages.findIndex(e=>e.toolCalls?.find(e=>e.id===t));if(-1===o)return;let l=a.messages[o],c={...r,result:{error:"Tool call denied by user."},status:"denied"},h=(0,i.updateToolCallInMessage)(l,c),u=[...a.messages];u[o]=h,a={...a,messages:u,updated:Date.now()},s.setCurrentConversation(a),await n.save(a),e.e.fire("toolCallDenied.ai-assistant-pro",r),s.removePendingToolCall(t)}async function o(e,t,s){try{s.setLoading(!0);let i=await t.get(e);if(!i)throw Error("Conversation not found: "+e);s.setCurrentConversation({...i})}catch(e){n.IS_PROD}finally{s.setLoading(!1)}}async function l(e,t){t.setView("conversationList");try{t.setLoading(!0);let s=await e.list().catch(()=>[]);t.setConversations(s)}finally{t.setLoading(!1)}}async function c(e,t,s){s.setLoading(!0);try{let i=await t.list(e||void 0);s.setConversations(i),s.setView("conversationList")}finally{s.setLoading(!1)}}},58579:function(e,t,s){"use strict";s.d(t,{applyTheme:function(){return h.applyTheme},areAllToolCallsExecuted:function(){return n.areAllToolCallsExecuted},createNewConversation:function(){return n.createNewConversation},createUserMessage:function(){return a.createUserMessage},deleteConversationWithCleanup:function(){return c.deleteConversationWithCleanup},executeToolCall:function(){return u.executeToolCall},findMessagesWithPendingToolCalls:function(){return n.findMessagesWithPendingToolCalls},findParentMessageId:function(){return n.findParentMessageId},getCurrentSelectionContext:function(){return l.getCurrentSelectionContext},handleBackToList:function(){return r.handleBackToList},handleConversationSearch:function(){return r.handleConversationSearch},handleConversationSelect:function(){return r.handleConversationSelect},handleToolApproval:function(){return r.handleToolApproval},handleToolDenial:function(){return r.handleToolDenial},invertMode:function(){return o.invertMode},isTerminalToolCallStatus:function(){return n.isTerminalToolCallStatus},loadInitialData:function(){return c.loadInitialData},processArtifacts:function(){return i.processArtifacts},processFinalResponse:function(){return i.processFinalResponse},processStreamingResponse:function(){return i.processStreamingResponse},resizeInPanelView:function(){return o.resizeInPanelView},updateToolCallInMessage:function(){return u.updateToolCallInMessage}});var i=s(61872),n=s(70308),r=s(473),a=s(61558),o=s(71050),l=s(15927),c=s(56110),h=s(53014),u=s(79078)},61558:function(e,t,s){"use strict";s.d(t,{createAIMessage:function(){return r},createErrorMessage:function(){return a},createUserMessage:function(){return n},uploadArtifacts:function(){return o}});var i=s(21064);function n(e){return{id:(0,i.generateMessageId)(),role:"user",content:e,timestamp:Date.now()}}function r(){return{id:"",role:"assistant",content:"",artifacts:[],timestamp:Date.now(),toolCalls:[]}}function a(e){return{id:"error_"+(0,i.generateMessageId)(),role:"assistant",content:"❌ Error: "+e.message,timestamp:Date.now(),toolCalls:[],artifacts:[]}}async function o(e,t){if(!t||0===t.length)return t;let s=e.o.aiAssistantPro.uploadBase64Artifact;return s?Promise.all(t.map(async t=>s(t,e)??t)):t}},71050:function(e,t,s){"use strict";s.d(t,{invertMode:function(){return n},resizeInPanelView:function(){return r}});var i=s(41180);function n(e){switch(e){case"left":return"right";case"right":return"left";case"top":return"bottom";case"bottom":return"top"}}function r(e,t,s,r){if("dialog"===t||"flight"===t)return;("left"===t||"right"===t)&&(e.currentPlace.slots[n(t)]?.style.setProperty(`--jd-slot-${n(t)}-width`,"auto"),e.currentPlace.slots[t]?.style.setProperty(`--jd-slot-${t}-width`,`${s}px`));let a=(0,i.css)(e.currentPlace.workplace,"height")??0;e.currentPlace.slots[t]?.style.setProperty("min-height",`${Math.min(a,r)}px`)}},85696:function(e,t,s){"use strict";function i(e,t){let s=e.createInside.div();return s.innerHTML=t,n(e,s),s}function n(e,t){e.e.fire("safeHTML",t)}s.d(t,{createSanitizedContainer:function(){return i},sanitizeElement:function(){return n}})},15927:function(e,t,s){"use strict";function i(e){if(e.s.isCollapsed())return null;let t=e.s.html,s=e.s.range;return{html:t,rangeInfo:{startContainer:s.startContainer.nodeName,startOffset:s.startOffset,endContainer:s.endContainer.nodeName,endOffset:s.endOffset}}}s.d(t,{getCurrentSelectionContext:function(){return i}})},56110:function(e,t,s){"use strict";s.d(t,{deleteConversationWithCleanup:function(){return n},loadInitialData:function(){return r}});var i=s(82758);async function n(e,t,s,i,n){try{i.setLoading(!0),await s.delete(t),i.removeConversation(t),n.clearConversationPermissions(t);let r=i.getCurrentConversation();r?.id===t&&i.setCurrentConversation(null);let a=await s.list();i.setConversations(a),i.setView(0===a.length?"welcome":"conversationList"),e.e.fire("conversationDeleted.ai-assistant-pro",t)}catch(t){e.alert(e.i18n("Failed to delete conversation")+": "+(t?.message||"Unknown error"))}finally{i.setLoading(!1)}}async function r(e,t,s){s.setLoading(!0);try{let[i,n]=await Promise.all([t.list().catch(()=>[]),t.getGlobalSettings().catch(()=>null)]);if(s.setConversations(i),n&&s.setSavedState(n),0===i.length)s.setView("welcome");else if(e.o.aiAssistantPro.rememberLastConversation&&n?.currentConversationId){let e=i.find(e=>e.id===n.currentConversationId)??i[0],r=await t.get(e.id);r?s.setCurrentConversation(r):s.setView("conversationList")}else s.setView("conversationList")}catch(e){i.IS_PROD,s.setView("welcome")}finally{s.setLoading(!1)}}},53014:function(e,t,s){"use strict";s.d(t,{applyTheme:function(){return r}});let i=["jodit_theme_dark","jodit-ai-assistant-pro_theme_dark","jodit-dialog_theme_dark"],n=["jodit_theme_light","jodit-ai-assistant-pro_theme_light","jodit-dialog_theme_light"];function r(e,t,s,r,a){let o;if(r?.classList.remove(...i),r?.classList.remove(...n),"dialog"===s){let e=a?.container;e?.classList.remove(...i),e?.classList.remove(...n)}if(o="dark"===t?i:n,r?.classList.add(...o),"dialog"===s){let e=a?.container;e?.classList.add(...o)}}},79078:function(e,t,s){"use strict";async function i(e,t,s){let i;try{let e=new AbortController().signal,n=await s.executeTool(t.name,t.arguments,e);i={...t,result:{result:n},status:"executed"}}catch(s){i={...t,result:{error:s instanceof Error?s.message:s+""},status:"error"},e.e.fire("toolCallFailed.ai-assistant-pro",i)}return e.e.fire("toolCallExecuted.ai-assistant-pro",i,{toolCallId:i.id,result:i.result}),i}function n(e,t){let s=e.toolCalls?.findIndex(e=>e.id===t.id);if(null==s||-1===s)return e;let i=[...e?.toolCalls??[]];return i[s]=t,{...e,toolCalls:i}}s.d(t,{executeToolCall:function(){return i},updateToolCallInMessage:function(){return n}})},86449:function(e,t,s){"use strict";s.d(t,{APIClient:function(){return a}});var i=s(82749),n=s(82758),r=s(21537);class a{async sendRequest(e,t,s,i,a){let{apiRequest:o,requestTimeout:l,maxRetries:c}=this.jodit.o.aiAssistantPro;if(!o)throw Error("AI Assistant Pro callback is not configured");let h=new AbortController;this.abortControllers.add(h);try{let u=this.buildRequestContext(e,t,s,i,a),d=null;for(let e=0;c>=e;e++)try{if(h.signal.aborted)throw(0,r.abort)();let e=setTimeout(()=>{h.abort()},l);try{let t=await o(u,h.signal);return clearTimeout(e),this.validateResponse(t),t}catch(t){throw clearTimeout(e),t}}catch(t){if(d=t,n.IS_PROD,c>e){let t=this.calculateRetryDelay(e);await this.sleep(t)}else throw t}throw d||Error("API request failed after all retries")}finally{this.abortControllers.delete(h)}}abort(){this.abortControllers.forEach(e=>{e.abort()}),this.abortControllers.clear()}isInProgress(){return this.abortControllers.size>0}buildRequestContext(e,t,s,i,n){let r,{apiMode:a,instructions:o}=this.jodit.o.aiAssistantPro,l={mode:a,conversationId:e,tools:this.toolRegistry.getAllTools(),selectionContexts:i,conversationOptions:n,instructions:o};if("full"===a)r=t;else if(s){let e=t.findIndex(e=>e.id===s);r=-1!==e?t.slice(e+1):t,l={...l,parentMessageId:s}}else r=t;return{...l,messages:this.expandToolMessages(r,t.find(e=>e.id===s))}}expandToolMessages(e,t){let s=[];for(let t of e)s.push(t),this.expandToolResultsMessage(t,s);return t&&this.expandToolResultsMessage(t,s),s}expandToolResultsMessage(e,t){if(e.toolCalls&&e.toolCalls.length>0)for(let s of e.toolCalls){let i=s.result??{error:"result not found"};if(t.find(e=>e.id===`${s.id}-result`))continue;let n={id:`${s.id}-result`,role:"tool",content:i.error?"Error: "+i.error:JSON.stringify(i.result),timestamp:e.timestamp,toolResults:[{toolCallId:s.id,result:i}]};t.push(n)}}validateResponse(e){if("final"!==e.mode)return;let t=e.response;if(!t)throw Error("API returned empty response");if(!t.responseId)throw Error("API response missing responseId");if(void 0===t.content)throw Error("API response missing content");if(void 0===t.finished)throw Error("API response missing finished flag");if(t.toolCalls){if(!Array.isArray(t.toolCalls))throw Error("API response toolCalls must be an array");t.toolCalls.forEach((e,t)=>{if(!e.id)throw Error(`Tool call at index ${t} is missing id`);if(!e.name)throw Error(`Tool call at index ${t} is missing name`);if(!e.arguments||"object"!=typeof e.arguments)throw Error(`Tool call at index ${t} has invalid arguments`)})}}calculateRetryDelay(e){let{retryDelay:t}=this.jodit.o.aiAssistantPro;return t*Math.pow(2,e)+Math.random()*t}sleep(e){return new Promise(t=>setTimeout(t,e))}destruct(){this.abort()}constructor(e,t){(0,i._)(this,"jodit",void 0),(0,i._)(this,"toolRegistry",void 0),(0,i._)(this,"abortControllers",void 0),this.jodit=e,this.toolRegistry=t,this.abortControllers=new Set}}},47373:function(e,t,s){"use strict";function i(e,t,s="image/png"){let n=atob(e),r=n.length,a=new Uint8Array(r);for(let e=0;r>e;e++)a[e]=n.charCodeAt(e);return new File([new Blob([a],{type:s})],t,{type:s})}s.d(t,{base64ToFile:function(){return i}})},21020:function(e,t,s){"use strict";s.d(t,{PermissionManager:function(){return n}});var i=s(82749);class n{requiresPermission(e){let{autoApproveTools:t,alwaysDenyTools:s}=this.jodit.o.aiAssistantPro;if(s.includes(e))return!0;if(t.includes(e))return!1;let i=this.toolRegistry.getTool(e);return!i||i.requiresPermission}isAutoDenied(e){let{alwaysDenyTools:t}=this.jodit.o.aiAssistantPro;return t.includes(e)}isAutoApproved(e){let{autoApproveTools:t}=this.jodit.o.aiAssistantPro;return t.includes(e)}checkPermission(e,t){if(this.isAutoApproved(e))return{toolName:e,granted:!0,grantedAt:Date.now(),scope:"once"};if(this.isAutoDenied(e))return null;let s=this.permanentPermissions.get(e);return s&&s.granted?s:t.find(t=>t.toolName===e&&t.granted)||null}grantPermission(e,t){let s={toolName:e,granted:!0,grantedAt:Date.now(),scope:t};return"forever"===t&&(this.permanentPermissions.set(e,s),this.savePermanentPermissions()),s}denyPermission(e){return{toolName:e,granted:!1,grantedAt:Date.now(),scope:"once"}}filterToolCalls(e,t){let s=[],i=[],n=[];for(let r of e){if(this.isAutoDenied(r.name)){n.push({...r,status:"denied"});continue}if(this.isAutoApproved(r.name)){s.push({...r,status:"approved"});continue}let e=this.checkPermission(r.name,t);e&&e.granted?s.push({...r,status:"approved"}):this.requiresPermission(r.name)?(this.jodit.e.fire("permissionRequested.ai-assistant-pro",r.name),i.push({...r,status:"pending"})):s.push({...r,status:"approved"})}return{approved:s,needsPermission:i,denied:n}}clearConversationPermissions(e){}loadPermanentPermissions(){try{let e=localStorage.getItem(this.PERMANENT_PERMISSIONS_KEY);e&&JSON.parse(e).forEach(e=>{"forever"===e.scope&&e.granted&&this.permanentPermissions.set(e.toolName,e)})}catch(e){}}savePermanentPermissions(){try{let e=Array.from(this.permanentPermissions.values());localStorage.setItem(this.PERMANENT_PERMISSIONS_KEY,JSON.stringify(e))}catch(e){}}clearPermanentPermissions(){this.permanentPermissions.clear(),localStorage.removeItem(this.PERMANENT_PERMISSIONS_KEY)}getPermanentPermissions(){return Array.from(this.permanentPermissions.values())}revokePermanentPermission(e){this.permanentPermissions.delete(e),this.savePermanentPermissions()}destruct(){this.permanentPermissions.clear()}constructor(e,t){(0,i._)(this,"jodit",void 0),(0,i._)(this,"toolRegistry",void 0),(0,i._)(this,"permanentPermissions",void 0),(0,i._)(this,"PERMANENT_PERMISSIONS_KEY",void 0),this.jodit=e,this.toolRegistry=t,this.permanentPermissions=new Map,this.PERMANENT_PERMISSIONS_KEY="jodit-permissions.ai-assistant-pro",this.loadPermanentPermissions()}}},46166:function(e,t,s){"use strict";s.d(t,{StateManager:function(){return n}});var i=s(82749);class n{createInitialState(){return{isOpen:!1,currentView:"welcome",currentConversation:null,conversations:[],isLoading:!1,error:null,pendingToolCalls:[],selectionContexts:[],abortController:null,editingMessageId:null,theme:this.jodit.o.aiAssistantPro.theme||"parent",displayMode:this.jodit.o.aiAssistantPro.displayMode,panelWidth:this.jodit.o.aiAssistantPro.panelWidth,panelHeight:this.jodit.o.aiAssistantPro.panelHeight,defaultModel:this.jodit.o.aiAssistantPro.defaultModel,defaultTemperature:this.jodit.o.aiAssistantPro.defaultTemperature}}open(){this.state.isOpen=!0,this.jodit.e.fire("open.ai-assistant-pro",this.state.currentConversation)}close(){this.state.isOpen=!1,this.jodit.e.fire("close.ai-assistant-pro")}isOpen(){return this.state.isOpen}setView(e){this.state.currentView=e,this.jodit.e.fire("viewChanged.ai-assistant-pro",e)}getView(){return this.state.currentView}setConversations(e){this.state.conversations=e}setSavedState(e){e.theme&&(this.state.theme=e.theme),e.displayMode&&(this.state.displayMode=e.displayMode),e.panelWidth&&(this.state.panelWidth=e.panelWidth),e.panelHeight&&(this.state.panelHeight=e.panelHeight),e.defaultModel&&(this.state.defaultModel=e.defaultModel),e.defaultTemperature&&(this.state.defaultTemperature=e.defaultTemperature)}getConversations(){return this.state.conversations}setCurrentConversation(e){if(this.state.currentConversation===e)throw Error("Conversation is already current");this.state.currentConversation=e||null,e&&(this.setView("conversation"),this.jodit.e.fire("conversationSwitched.ai-assistant-pro",e))}getCurrentConversation(){return this.state.currentConversation}removeConversation(e){let t=this.state.conversations.filter(t=>t.id!==e);this.setConversations(t)}setLoading(e){this.state.isLoading=e}isLoading(){return this.state.isLoading}setError(e){this.state.error=e,e&&this.jodit.e.fire("error.ai-assistant-pro",Error(e))}getError(){return this.state.error}clearError(){this.setError(null)}setPendingToolCalls(e){this.state.pendingToolCalls=e}getPendingToolCalls(){return this.state.pendingToolCalls}addPendingToolCall(e){let t=[...this.state.pendingToolCalls,e];this.setPendingToolCalls(t)}removePendingToolCall(e){let t=this.state.pendingToolCalls.filter(t=>t.id!==e);this.setPendingToolCalls(t)}updateToolCallStatus(e,t){let s=this.state.pendingToolCalls.map(s=>s.id===e?{...s,status:t}:s);this.setPendingToolCalls(s)}setSelectionContexts(e){this.state.selectionContexts=e}getSelectionContexts(){return this.state.selectionContexts}addSelectionContext(e){let{maxContextRanges:t}=this.jodit.o.aiAssistantPro,s=[...this.state.selectionContexts,e];s.length>t&&(s=s.slice(-t)),this.setSelectionContexts(s),this.jodit.e.fire("contextAdded.ai-assistant-pro",e)}removeSelectionContext(e){let t=this.state.selectionContexts.filter((t,s)=>s!==e);this.setSelectionContexts(t),this.jodit.e.fire("contextRemoved.ai-assistant-pro",e)}clearSelectionContexts(){this.setSelectionContexts([])}setAbortController(e){this.state.abortController=e}getAbortController(){return this.state.abortController}setEditingMessageId(e){this.state.editingMessageId=e}getEditingMessageId(){return this.state.editingMessageId}isEditingMessage(){return null!=this.state.editingMessageId}clearEditingMessage(){this.setEditingMessageId(null)}reset(){this.state=this.createInitialState()}destruct(){this.state.abortController&&this.state.abortController.abort(),this.reset()}constructor(e){(0,i._)(this,"jodit",void 0),(0,i._)(this,"state",void 0),this.jodit=e,this.state=this.createInitialState()}}},62895:function(e,t,s){"use strict";s.d(t,{WebStorageConversationStorage:function(){return i.WebStorageConversationStorage},createStorageProvider:function(){return i.createStorageProvider}});var i=s(21064)},21064:function(e,t,s){"use strict";s.d(t,{WebStorageConversationStorage:function(){return r},createStorageProvider:function(){return a},generateConversationId:function(){return o},generateMessageId:function(){return l}});var i=s(82749),n=s(97333);class r{close(){return this.storage.close()}getConversationKey(e){return"conv:"+e}async getAllKeys(){let e=await this.storage.get("__conversation_index__");return e&&Array.isArray(e)?e:[]}async updateIndex(e){await this.storage.set("__conversation_index__",e)}async addToIndex(e){let t=await this.getAllKeys();t.includes(e)||(t.push(e),await this.updateIndex(t))}async removeFromIndex(e){let t=(await this.getAllKeys()).filter(t=>t!==e);await this.updateIndex(t)}async list(e){try{let t=await this.getAllKeys(),s=[],i=e?.toLowerCase().trim();for(let e of t){let t=await this.get(e);if(t){if(i){let e=t.title?.toLowerCase().includes(i),s=!e&&t.messages.some(e=>e.content.toLowerCase().includes(i));if(!e&&!s)continue}s.push({id:t.id,title:t.title??"",created:t.created,updated:t.updated,messageCount:t.messages.length})}}return s.sort((e,t)=>t.updated-e.updated),s}catch(e){return[]}}async get(e){try{let t=this.getConversationKey(e);return await this.storage.get(t)||null}catch(e){return null}}async save(e){try{if(0===e.messages.length)throw Error("Conversation must have at least one message.");let t=await this.getAllKeys();t.length>=this.maxConversations&&!t.includes(e.id)&&await this.evictOldest();let s=this.getConversationKey(e.id);await this.storage.set(s,e),await this.addToIndex(e.id)}catch(t){if(t?.name==="QuotaExceededError"||t?.code===22||t?.code===1014){await this.evictOldest();try{let t=this.getConversationKey(e.id);await this.storage.set(t,e),await this.addToIndex(e.id)}catch{throw Error("Storage quota exceeded. Please delete some conversations.")}}else throw Error("Failed to save conversation: "+(t?.message||"Unknown error"))}}async delete(e){try{let t=this.getConversationKey(e);await this.storage.delete(t),await this.removeFromIndex(e)}catch(e){}}async clear(){try{for(let e of(await this.getAllKeys())){let t=this.getConversationKey(e);await this.storage.delete(t)}await this.updateIndex([])}catch(e){}}async evictOldest(){try{let e=await this.list();if(0===e.length)return;e.sort((e,t)=>e.updated-t.updated);let t=e[0];await this.delete(t.id)}catch(e){}}async getGlobalSettings(){try{return await this.storage.get("global-settings")||null}catch(e){return null}}async saveGlobalSettings(e){try{let t={...await this.getGlobalSettings(),...e};await this.storage.set("global-settings",t)}catch{throw Error("Failed to save global settings")}}constructor(e,t){(0,i._)(this,"storage",void 0),(0,i._)(this,"maxConversations",void 0),this.storage=e,this.maxConversations=t}}function a(e,t){return n.AsyncStorage.makeStorage(e,t)}function o(){return`conv_${Date.now()}_${Math.random().toString(36).substring(2,11)}`}function l(){return`msg_${Date.now()}_${Math.random().toString(36).substring(2,11)}`}},55487:function(e,t,s){"use strict";s.d(t,{ToolRegistry:function(){return r}});var i=s(82749),n=s(53835);class r{registerBuiltInTools(e){e.forEach(e=>{let t=n.BUILT_IN_TOOLS[e];t&&this.tools.set(e,t)})}registerCustomTools(e){e.forEach(e=>{this.validateToolDefinition(e),this.tools.set(e.name,e)})}validateToolDefinition(e){if(!e.name||"string"!=typeof e.name)throw Error("Tool must have a valid name");if(!e.description||"string"!=typeof e.description)throw Error(`Tool "${e.name}" must have a description`);if(!Array.isArray(e.parameters))throw Error(`Tool "${e.name}" must have a parameters array`);if("function"!=typeof e.execute)throw Error(`Tool "${e.name}" must have an execute function`);e.parameters.forEach(t=>{if(!t.name||"string"!=typeof t.name)throw Error(`Tool "${e.name}" has a parameter without a valid name`);if(!t.type)throw Error(`Tool "${e.name}" parameter "${t.name}" must have a type`);if("boolean"!=typeof t.required)throw Error(`Tool "${e.name}" parameter "${t.name}" must specify if it's required`)})}getAllTools(){return Array.from(this.tools.values())}getTool(e){return this.tools.get(e)}hasTool(e){return this.tools.has(e)}getToolNames(){return Array.from(this.tools.keys())}async executeTool(e,t,s){let i=this.getTool(e);if(!i)throw Error(`Tool "${e}" not found`);let n=this.applyDefaults(i,t);this.validateArguments(i,n);try{return await i.execute(this.jodit,n,s)}catch(e){if(e?.name==="AbortError"||s.aborted)throw Error("Tool execution was aborted");throw e}}validateArguments(e,t){let s=Object.keys(t);for(let t of e.parameters.filter(e=>e.required).map(e=>e.name))if(!s.includes(t))throw Error(`Tool "${e.name}" requires parameter "${t}"`);for(let[s,i]of Object.entries(t)){let t=e.parameters.find(e=>e.name===s);if(!t){this.jodit.o.aiAssistantPro.debug;continue}let n=Array.isArray(i)?"array":"object"==typeof i&&null!=i?"object":typeof i;if(t.type!==n&&!("number"===t.type&&"string"===n&&!isNaN(Number(i))))throw Error(`Tool "${e.name}" parameter "${s}" expects type "${t.type}" but got "${n}"`);if(t.enum&&t.enum.length>0&&!t.enum.includes(i))throw Error(`Tool "${e.name}" parameter "${s}" must be one of: ${t.enum.join(", ")}`)}}applyDefaults(e,t){let s={...t};for(let t of e.parameters)void 0===s[t.name]&&void 0!==t.default&&(s[t.name]=t.default);return s}destruct(){this.tools.clear()}constructor(e){(0,i._)(this,"jodit",void 0),(0,i._)(this,"tools",void 0),this.jodit=e,this.tools=new Map,this.registerBuiltInTools(e.o.aiAssistantPro.enabledTools||[]),this.registerCustomTools(e.o.aiAssistantPro.customTools||[])}}},26612:function(e){e.exports={"AI Assistant":"AI Assistant","AI Assistant Pro":"AI Assistant Pro","Welcome to AI Assistant":"Welcome to AI Assistant","Start your first conversation":"Start your first conversation","Tip: Select text in editor to add context":"Tip: Select text in editor to add context","New Chat":"New Chat","Search conversations...":"Search conversations...","No conversations yet":"No conversations yet","Ask me anything...":"Ask me anything...","Ask a follow-up...":"Ask a follow-up...","Reply...":"Reply...","Type your message...":"Type your message...",Send:"Send",Cancel:"Cancel",Retry:"Retry",Insert:"Insert",Copy:"Copy",Edit:"Edit",Delete:"Delete",New:"New",Back:"Back","Permission Required":"Permission Required",Approve:"Approve",Deny:"Deny",Once:"Once","This conversation":"This conversation",Always:"Always","The AI wants to execute:":"The AI wants to execute:","This will modify your document content.":"This will modify your document content.","Executing...":"Executing...","Completed successfully":"Completed successfully",Failed:"Failed","Pending approval":"Pending approval","Denied by user":"Denied by user","Tool Result":"Tool Result","Tool Execution Error":"Tool Execution Error",Context:"Context",Contexts:"Contexts","Add to AI Context":"Add to AI Context",Remove:"Remove","Clear all":"Clear all","An error occurred":"An error occurred","Request failed":"Request failed","Connection error":"Connection error","AI Assistant is not configured":"AI Assistant is not configured","Thinking...":"Thinking...","Generating response...":"Generating response...",insertHTML:"Insert HTML",readDocument:"Read Document",readBlock:"Read Block",replaceInDocument:"Replace in Document",replaceInBlock:"Replace in Block",getSelection:"Get Selection","Just now":"Just now",Conversation:"Conversation","New Conversation":"New Conversation",Yesterday:"Yesterday","Delete conversation":"Delete conversation","Are you sure you want to delete this conversation?":"Are you sure you want to delete this conversation?","Failed to delete conversation":"Failed to delete conversation"}},63805:function(e,t,s){"use strict";s.r(t),s.d(t,{en:function(){return n.a},ru:function(){return a.a}});var i=s(26612),n=s.n(i),r=s(41324),a=s.n(r)},94454:function(e,t,s){"use strict";s.d(t,{getAIProviderOptions:function(){return i.getAIProviderOptions},registerAIProvider:function(){return i.registerAIProvider}}),s(82923);var i=s(58211)},82923:function(e,t,s){"use strict";var i=s(58211),n=s(54079);(0,i.registerAIProvider)("jodit-ai-adapter",e=>{let t=e.url.replace(/\/+$/,""),s=e.provider??"openai",i=!1!==e.stream;return{apiMode:"incremental",maxRetries:0,voiceInputEnabled:!0,voiceInputUrl:`${t.replace(/^http/,"ws")}/v1/ai/transcribe`,voiceInputApiKey:e.apiKey,textAutocompleteEnabled:!0,async textAutocompleteApiRequest(i,r,a){let o=new n.Ajax({url:`${t}/ai/autocomplete?query=${encodeURIComponent(i)}&key=${encodeURIComponent(e.apiKey)}`,method:"POST",contentType:"application/json",data:{provider:s,context:{maxSuggestions:r}}});a.addEventListener("abort",()=>o.abort(),{once:!0});let l=await o.send(),c=await l.json();return c.success&&c.result?.suggestions?c.result.suggestions:[]},async apiRequest(r,a){let o=new n.Ajax({url:`${t}/ai/request?key=${encodeURIComponent(e.apiKey)}`,method:"POST",contentType:"application/json",data:{provider:s,context:i?{...r,metadata:{...r.metadata,stream:!0}}:r}});if(a&&a.addEventListener("abort",()=>o.abort(),{once:!0}),!i){let e=await o.send();return{mode:"final",response:(await e.json()).result}}let l=o.stream();return{mode:"stream",stream:async function*(){for await(let e of l)yield JSON.parse(e)}()}}}})},58211:function(e,t,s){"use strict";s.d(t,{getAIProviderOptions:function(){return n},registerAIProvider:function(){return r}});let i=new Map;function n(e,t){let s=i.get(e);if(!s)throw Error(`AI provider "${e}" is not registered. Available providers: `+[...i.keys()].join(", "));return s(t)}function r(e,t){i.set(e,t)}},65374:function(e,t,s){"use strict";s.r(t),s.d(t,{description:function(){return n},name:function(){return i},parameters:function(){return r},requiresPermission:function(){return a}});let i="addHTML",n="Add HTML content to the beginning or end of the document",r=[{name:"html",type:"string",description:"HTML content to add",required:!0},{name:"position",type:"string",description:'Where to add: "start" adds at the beginning of the document, "end" appends to the end',required:!1,default:"end"}],a=!0},686:function(e,t,s){"use strict";s.d(t,{execute:function(){return o}});var i=s(6689),n=s(49459),r=s(85696),a=s(22732);async function o(e,t,s){let o=(0,n.requireString)(t,"html",{allowEmpty:!0}),{position:l="end"}=t;if(!o.trim())return{success:!0,message:"Nothing to add: HTML is empty"};(0,i.throwIfAborted)(s);try{let t=e.createInside.fragment(),s=(0,r.createSanitizedContainer)(e,o);for(;s.firstChild;)t.appendChild(s.firstChild);return"start"===l?a.Dom.prepend(e.editor,t):a.Dom.append(e.editor,t),e.synchronizeValues(),{success:!0,message:`Added ${o.length} characters of HTML at the ${"start"===l?"beginning":"end"} of the document`}}catch(e){throw Error("Failed to add HTML: "+(e?.message||"Unknown error"))}}},78907:function(e,t,s){"use strict";var i=s(65374),n=s(686);t.default={...i,execute:n.execute}},73943:function(e,t,s){"use strict";s.r(t),s.d(t,{description:function(){return n},name:function(){return i},parameters:function(){return r},requiresPermission:function(){return a}});let i="applyFormat",n="Apply or remove inline formatting to the current selection (bold, italic, underline, etc.) or to a specific block",r=[{name:"element",type:"string",description:'HTML element to wrap selection (e.g., "strong", "em", "u", "span")',required:!1},{name:"attributes",type:"object",description:'Attributes to apply (e.g., {"className": "highlight"}, {"style": {"color": "red"}})',required:!1},{name:"remove",type:"boolean",description:"If true, remove the formatting instead of applying it",required:!1,default:!1},{name:"blockIndex",type:"number",description:"Zero-based index of the block to format (if not using current selection)",required:!1},{name:"selector",type:"string",description:"CSS selector to find the block to format (if not using current selection)",required:!1}],a=!0},19127:function(e,t,s){"use strict";s.d(t,{execute:function(){return r}});var i=s(6689),n=s(44526);async function r(e,t,s){let{element:r,attributes:a,remove:o,blockIndex:l,selector:c}=t;if((0,i.throwIfAborted)(s),!r&&!a)throw Error('Either "element" or "attributes" must be provided');if(e.s.restore(),void 0!==l||c){let{element:t}=(0,n.resolveBlock)(e,{selector:c,index:l});e.s.select(t)}if(e.s.isCollapsed())throw Error("No selection found. Please select text to format");try{let t={};return r&&(t.element=r),a&&(t.attributes=a),o?e.s.commitStyle({...t,mode:"remove"}):e.s.commitStyle(t),e.synchronizeValues(),{success:!0,message:o?"Formatting removed successfully":"Formatting applied successfully"}}catch(e){throw Error(`Failed to ${o?"remove":"apply"} formatting: ${e.message}`)}}},39296:function(e,t,s){"use strict";var i=s(73943),n=s(19127);t.default={...i,execute:n.execute}},53835:function(e,t,s){"use strict";s.d(t,{BUILT_IN_TOOLS:function(){return p},getToolNames:function(){return g}});var i=s(78907),n=s(39296),r=s(16745),a=s(78717),o=s(5618),l=s(90991),c=s(2020),h=s(12570),u=s(95323),d=s(97603);let p={readDocument:o.default,readBlocks:a.default,readSelection:l.default,writeDocument:d.default,replaceSelection:u.default,replaceBlock:c.default,replaceInDocument:h.default,insertHTML:r.default,addHTML:i.default,applyFormat:n.default};function g(){return Object.keys(p)}},56732:function(e,t,s){"use strict";s.r(t),s.d(t,{description:function(){return n},name:function(){return i},parameters:function(){return r},requiresPermission:function(){return a}});let i="insertHTML",n="Insert or replace HTML content at the current cursor position in the editor",r=[{name:"html",type:"string",description:"HTML content to insert",required:!0},{name:"replace",type:"boolean",description:"If true, replaces current selection. If false, inserts at cursor",required:!1,default:!1}],a=!0},39592:function(e,t,s){"use strict";s.d(t,{execute:function(){return r}});var i=s(6689),n=s(49459);async function r(e,t,s){let r=(0,n.requireString)(t,"html",{allowEmpty:!0}),{replace:a}=t;if(!r.trim())return{success:!0,message:"Nothing to insert: HTML is empty"};(0,i.throwIfAborted)(s);try{return e.s.focus(),a&&!e.s.isCollapsed()&&e.s.remove(),e.s.insertHTML(r),e.synchronizeValues(),{success:!0,message:`Inserted ${r.length} characters of HTML`}}catch(e){throw Error("Failed to insert HTML: "+(e?.message||"Unknown error"))}}},16745:function(e,t,s){"use strict";var i=s(56732),n=s(39592);t.default={...i,execute:n.execute}},75352:function(e,t,s){"use strict";s.r(t),s.d(t,{description:function(){return n},name:function(){return i},parameters:function(){return r},requiresPermission:function(){return a}});let i="readBlocks",n="Read blocks from the editor with optional filtering and pagination",r=[{name:"offset",type:"number",description:"Number of blocks to skip from the beginning (default: 0)",required:!1,default:0},{name:"limit",type:"number",description:"Maximum number of blocks to return (default: all)",required:!1},{name:"query",type:"string",description:"Filter blocks by text content",required:!1}],a=!1},91140:function(e,t,s){"use strict";s.d(t,{execute:function(){return r}});var i=s(6689),n=s(22732);async function r(e,t,s){let{offset:r,limit:a,query:o}=t;(0,i.throwIfAborted)(s);let l=[];Array.from(e.editor.children).forEach((e,t)=>{n.Dom.isElement(e)&&l.push({blockIndex:t,tagName:e.tagName.toLowerCase(),content:e.innerHTML,textContent:e.textContent||"",classList:Array.from(e.classList)})});let c=l;if(o&&"string"==typeof o){let e=o.toLowerCase();c=l.filter(t=>t.textContent.toLowerCase().includes(e)||t.tagName.includes(e)||t.content.toLowerCase().includes(e))}let h=Math.max(0,Math.min("number"==typeof r?r:0,c.length)),u=void 0!==a?Math.min(h+a,c.length):c.length;return{blocks:c.slice(h,u),total:l.length,offset:h,limit:void 0!==a?a:void 0}}},78717:function(e,t,s){"use strict";var i=s(75352),n=s(91140);t.default={...i,execute:n.execute}},93809:function(e,t,s){"use strict";s.r(t),s.d(t,{description:function(){return n},name:function(){return i},parameters:function(){return r},requiresPermission:function(){return a}});let i="readDocument",n="Read the entire content of the editor document in HTML format",r=[{name:"start",type:"number",description:"Start character position (default: 0)",required:!1,default:0},{name:"end",type:"number",description:"End character position (default: length of document)",required:!1},{name:"aroundSelection",type:"boolean",description:"If true, return only the maximum block around the current selection",required:!1,default:!1}],a=!1},28157:function(e,t,s){"use strict";s.d(t,{execute:function(){return r}});var i=s(6689),n=s(22732);async function r(e,t,s){let{start:r,end:a,aroundSelection:o}=t;(0,i.throwIfAborted)(s);let l=e.value,c=l.length;if(o&&!e.s.isCollapsed()){let t=e.s.range.commonAncestorContainer;for(;t&&t!==e.editor;){if(n.Dom.isElement(t)&&t.parentNode===e.editor){l=t.outerHTML;break}t=t.parentNode}return{html:l,length:c}}let h=void 0!==a?Math.min(a,c):c,u=Math.max(0,Math.min("number"==typeof r?r:0,c));return(u>0||c>h)&&(l=l.substring(u,h)),{html:l,length:c,start:u,end:h}}},5618:function(e,t,s){"use strict";var i=s(93809),n=s(28157);t.default={...i,execute:n.execute}},52826:function(e,t,s){"use strict";s.r(t),s.d(t,{description:function(){return n},name:function(){return i},parameters:function(){return r},requiresPermission:function(){return a}});let i="readSelection",n="Get information about the current selection including HTML content and optional context",r=[{name:"contextCharsBefore",type:"number",description:"Number of characters to include before the selection",required:!1,default:0},{name:"contextCharsAfter",type:"number",description:"Number of characters to include after the selection",required:!1,default:0}],a=!1},85130:function(e,t,s){"use strict";s.d(t,{execute:function(){return n}});var i=s(6689);async function n(e,t,s){let{contextCharsBefore:n,contextCharsAfter:r}=t;if((0,i.throwIfAborted)(s),e.s.restore(),e.s.isCollapsed())return{hasSelection:!1};let a=e.s.html,o=e.s.range,l=o.toString(),c={hasSelection:!0,html:a,text:l,startContainer:o.startContainer.nodeName,endContainer:o.endContainer.nodeName};if(n>0||r>0){let t=e.editor.textContent||"",s=t.substring(0,t.indexOf(l)),i=t.substring(t.indexOf(l)+l.length);n>0&&(c.contextBefore=s.slice(-n)),r>0&&(c.contextAfter=i.slice(0,r))}return c}},90991:function(e,t,s){"use strict";var i=s(52826),n=s(85130);t.default={...i,execute:n.execute}},96675:function(e,t,s){"use strict";s.r(t),s.d(t,{description:function(){return n},name:function(){return i},parameters:function(){return r},requiresPermission:function(){return a}});let i="replaceBlock",n="Replace a specific block in the document by its index or CSS selector with new HTML content",r=[{name:"index",type:"number",description:"Zero-based index of the block to replace (use either index or selector, not both)",required:!1},{name:"selector",type:"string",description:'CSS selector to find the block to replace (e.g., "h1", ".my-class", "#my-id"). Use either selector or index, not both',required:!1},{name:"html",type:"string",description:"HTML content for the new block",required:!0}],a=!0},3091:function(e,t,s){"use strict";s.d(t,{execute:function(){return l}});var i=s(6689),n=s(49459),r=s(44526),a=s(85696),o=s(22732);async function l(e,t,s){let{index:l,selector:c}=t,h=(0,n.requireString)(t,"html");if((0,i.throwIfAborted)(s),void 0===l&&!c||void 0!==l&&c)throw Error("Either index or selector must be provided, but not both");let{element:u,identifier:d}=(0,r.resolveBlock)(e,{selector:c,index:l,requireExactlyOne:!0});try{let t=(0,a.createSanitizedContainer)(e,h).firstChild;if(!t||!o.Dom.isElement(t))throw Error("Invalid HTML: must contain at least one element");return u.parentNode?.replaceChild(t,u),e.synchronizeValues(),{success:!0,message:`Block ${d} replaced successfully`}}catch(e){throw Error(`Failed to replace block ${d}: ${e.message}`)}}},2020:function(e,t,s){"use strict";var i=s(96675),n=s(3091);t.default={...i,execute:n.execute}},62553:function(e,t,s){"use strict";s.r(t),s.d(t,{description:function(){return n},name:function(){return i},parameters:function(){return r},requiresPermission:function(){return a}});let i="replaceInDocument",n="Find and replace text or HTML patterns throughout the entire document",r=[{name:"search",type:"string",description:"Text or pattern to search for",required:!0},{name:"replace",type:"string",description:"Replacement text or HTML",required:!0},{name:"useRegex",type:"boolean",description:"If true, treats search as a regular expression",required:!1,default:!1},{name:"useSelector",type:"string",description:"CSS selector to narrow down the search scope to specific elements",required:!1}],a=!0},56293:function(e,t,s){"use strict";s.d(t,{execute:function(){return a}});var i=s(6689),n=s(49459),r=s(85696);async function a(e,t,s){let a=(0,n.requireString)(t,"search"),o=(0,n.requireString)(t,"replace",{allowEmpty:!0}),{useRegex:l,useSelector:c}=t;(0,i.throwIfAborted)(s);try{let t;e.s.focus(),e.s.save();let n=0;if(c){let h=function(e,t,s,n,a,o){let l=e.editor.querySelectorAll(a);if(0===l.length)return{replacements:0,message:`No elements found matching selector "${a}"`};let c=0;return l.forEach(a=>{(0,i.throwIfAborted)(o);let l=a.innerHTML,h=l;if(n)try{let e=RegExp(t,"g");l=l.replace(e,()=>(c++,s))}catch(e){throw Error("Invalid regex pattern: "+(e?.message||"Unknown error"))}else{let e=t.length,n=0;for(;-1!==(n=l.indexOf(t,n));)(0,i.throwIfAborted)(o),l=l.substring(0,n)+s+l.substring(n+e),n+=s.length,c++}l!==h&&(a.innerHTML=l,(0,r.sanitizeElement)(e,a))}),c>0&&(e.synchronizeValues(),e.s.restore()),{replacements:c}}(e,a,o,l,c,s);n=h.replacements,t=h.message}else n=function(e,t,s,n,r,a){let o=0,l=t;if(r)try{let e=RegExp(s,"g");l=l.replace(e,()=>(o++,n))}catch(e){throw Error("Invalid regex pattern: "+(e?.message||"Unknown error"))}else{let e=s.length,t=0;for(;-1!==(t=l.indexOf(s,t));)(0,i.throwIfAborted)(a),l=l.substring(0,t)+n+l.substring(t+e),t+=n.length,o++}return o>0&&(e.value=l,e.s.restore(),e.synchronizeValues()),o}(e,e.value,a,o,l,s);return{replacements:n,message:t||(n>0?`Replaced ${n} occurrence(s)`:"No matches found")}}catch(t){throw e.s.restore(),Error("Failed to replace in document: "+(t?.message||"Unknown error"))}}},12570:function(e,t,s){"use strict";var i=s(62553),n=s(56293);t.default={...i,execute:n.execute}},70750:function(e,t,s){"use strict";s.r(t),s.d(t,{description:function(){return n},name:function(){return i},parameters:function(){return r},requiresPermission:function(){return a}});let i="replaceSelection",n="Replace the current selection with new HTML content",r=[{name:"html",type:"string",description:"HTML content to insert in place of the selection",required:!0},{name:"collapseToEnd",type:"boolean",description:"Move cursor to the end of the inserted content",required:!1,default:!0}],a=!0},36142:function(e,t,s){"use strict";s.d(t,{execute:function(){return r}});var i=s(6689),n=s(49459);async function r(e,t,s){let r=(0,n.requireString)(t,"html"),{collapseToEnd:a}=t;(0,i.throwIfAborted)(s);try{if(e.s.restore(),e.s.insertHTML(r),a){let t=e.s.range;t.collapse(!1),e.s.selectRange(t)}return e.e.fire("change"),{success:!0,message:"Selection replaced successfully"}}catch(e){throw Error("Failed to replace selection: "+e.message)}}},95323:function(e,t,s){"use strict";var i=s(70750),n=s(36142);t.default={...i,execute:n.execute}},90022:function(e,t,s){"use strict";s.r(t),s.d(t,{description:function(){return n},name:function(){return i},parameters:function(){return r},requiresPermission:function(){return a}});let i="writeDocument",n="Write (replace) the entire document content with new HTML",r=[{name:"html",type:"string",description:"HTML content to set as the document",required:!0}],a=!0},79766:function(e,t,s){"use strict";s.d(t,{execute:function(){return r}});var i=s(6689),n=s(49459);async function r(e,t,s){let r=(0,n.requireString)(t,"html",{allowEmpty:!0});(0,i.throwIfAborted)(s);try{return e.s.focus(),e.value=r,e.synchronizeValues(),{success:!0,message:`Document content was replaced with provided HTML(${r.length} characters)`}}catch(e){throw Error("Failed to replace HTML: "+(e?.message||"Unknown error"))}}},97603:function(e,t,s){"use strict";var i=s(90022),n=s(79766);t.default={...i,execute:n.execute}},80453:function(e,t,s){"use strict";s.d(t,{UIConversationListItem:function(){return c}});var i=s(82749),n=s(31635),r=s(65478),a=s(67510),o=s(62843),l=s(80870);class c extends a.UIElement{className(){return"UIConversationListItem"}render(){return'<div class="jodit-ui-conversation-list__item"></div>'}setActive(e){this.isActive=e,this.updateContent()}updateContent(){let e=this.container;e.innerHTML="",e.setAttribute("data-id",this.conversation.id),this.isActive?e.classList.add("jodit-ui-conversation-list__item_active"):e.classList.remove("jodit-ui-conversation-list__item_active");let t=this.j.c.div("jodit-ui-conversation-list__item-avatar");t.textContent="AI",e.appendChild(t);let s=this.j.c.div("jodit-ui-conversation-list__item-wrapper"),i=this.j.c.div("jodit-ui-conversation-list__item-content"),n=this.j.c.div("jodit-ui-conversation-list__item-title");if(n.textContent=this.conversation.title,this.titleElement=n,i.appendChild(n),this.opts.showTimestamps){let e=this.j.c.div("jodit-ui-conversation-list__item-meta");e.textContent=this.opts.formatTimestamp(this.conversation.updated,this.j.i18n.bind(this.j)),i.appendChild(e)}if(s.appendChild(i),this.conversation.messageCount>0){let e=this.j.c.div("jodit-ui-conversation-list__item-badge");e.textContent=this.conversation.messageCount+"",s.appendChild(e)}e.appendChild(s),this.actionsButton||(this.actionsButton=new o.UIButton(this.j,{icon:{name:"dots"},tooltip:"Actions",name:"conversationActions",size:"tiny"}),this.actionsButton.container.classList.add("jodit-ui-conversation-list__item-actions"),this.actionsButton.onAction(e=>{e.stopPropagation(),this.showActionsMenu(e)})),e.appendChild(this.actionsButton.container)}onClick(){this.isRenaming||this.j.e.fire("selectConversation.ai-assistant-pro",this.conversation.id)}showActionsMenu(e){if(!this.contextMenu||!this.actionsButton)return;let t=this.actionsButton.container.getBoundingClientRect();this.contextMenu.show(t.left,t.bottom,[{title:"Rename",icon:"pencil",exec:()=>{this.startInlineRename()}},{title:"Delete",icon:"bin",exec:()=>{this.onDelete()}}]),e.stopPropagation()}startInlineRename(){if(this.isRenaming||!this.titleElement)return;this.isRenaming=!0;let e=this.titleElement,t=this.conversation.title,s=this.j.c.element("input");s.type="text",s.value=t,s.className="jodit-ui-conversation-list__item-title-input",e.textContent="",e.appendChild(s),s.focus(),s.select();let i=()=>{if(!this.isRenaming)return;let i=s.value.trim();this.isRenaming=!1,i&&i!==t?(e.textContent=i,this.j.e.fire("renameConversation.ai-assistant-pro",this.conversation.id,i)):e.textContent=t};this.j.e.on(s,"blur",i),this.j.e.on(s,"keydown",i=>{"Enter"===i.key&&(i.preventDefault(),s.blur()),"Escape"===i.key&&(this.isRenaming=!1,e.textContent=t)}),this.j.e.on(s,"click",e=>{e.stopPropagation()})}onDelete(){this.j.e.fire("deleteConversation.ai-assistant-pro",this.conversation.id)}destruct(){this.actionsButton?.destruct(),this.contextMenu?.destruct(),super.destruct()}constructor(e,t,s=!1,n){super(e),(0,i._)(this,"opts",void 0),(0,i._)(this,"conversation",void 0),(0,i._)(this,"isActive",void 0),(0,i._)(this,"actionsButton",void 0),(0,i._)(this,"contextMenu",void 0),(0,i._)(this,"titleElement",void 0),(0,i._)(this,"isRenaming",void 0),this.opts=n,this.actionsButton=null,this.contextMenu=null,this.titleElement=null,this.isRenaming=!1,this.conversation=t,this.isActive=s,this.contextMenu=new l.ContextMenu(this.j),this.updateContent()}}(0,n.__decorate)([(0,r.watch)("container:click")],c.prototype,"onClick",null),(0,n.__decorate)([r.autobind],c.prototype,"showActionsMenu",null),(0,n.__decorate)([r.autobind],c.prototype,"startInlineRename",null),(0,n.__decorate)([r.autobind],c.prototype,"onDelete",null),c=(0,n.__decorate)([r.component],c)},68365:function(e,t,s){"use strict";s.d(t,{UIConversationList:function(){return h}});var i=s(82749),n=s(31635),r=s(31356),a=s(80453),o=s(65478),l=s(80256),c=s(62405);class h extends c.UIGroup{className(){return"UIConversationList"}render(){return`<div class="&__container">
|
|
11
11
|
<div class="&__header"></div>
|
|
12
12
|
<div class="&__search">
|
|
13
13
|
<div class="&__search-loader"></div>
|
|
@@ -59,12 +59,12 @@ ${r}`.trim();s?await this.__executeQuickCommandSilent(l,r):await this.__executeQ
|
|
|
59
59
|
<div class="&__title">~Welcome to AI Assistant~</div>
|
|
60
60
|
<div class="&__subtitle">~Start your first conversation~</div>
|
|
61
61
|
<div class="&__tip">~Tip: Select text in editor to add context~</div>
|
|
62
|
-
</div>`}}a=(0,i.__decorate)([n.component],a)},88710:function(e,t,s){"use strict";s.d(t,{MicrophoneStreamer:function(){return n}});var i=s(82749);class n{async start(){if(this.running=!0,this.stream=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0}}),!this.running)return void this.stopTracks();let e=new AudioContext;if("suspended"===e.state&&await e.resume(),!this.running)return void e.close();let t=e.createMediaStreamSource(this.stream),s=e.createScriptProcessor(4096,1,1),i=e.createGain();i.gain.value=0,s.onaudioprocess=e=>{if(!this.running)return;let t=function(e){let t=new Int16Array(e.length);for(let s=0;s<e.length;s++){let i=Math.max(-1,Math.min(1,e[s]));t[s]=i<0?32768*i:32767*i}return t}(function(e,t){if(24e3>=t)return e;let s=t/24e3,i=Math.round(e.length/s),n=new Float32Array(i);for(let t=0;i>t;t++)n[t]=e[Math.min(Math.round(t*s),e.length-1)];return n}(e.inputBuffer.getChannelData(0),e.inputBuffer.sampleRate));this.onFrame(t)},t.connect(s),s.connect(i),i.connect(e.destination),this.audioCtx=e,this.source=t,this.processor=s,this.zeroGain=i}stop(){this.running=!1,this.processor&&(this.processor.onaudioprocess=null,this.processor.disconnect(),this.processor=null),this.zeroGain?.disconnect(),this.source?.disconnect(),this.zeroGain=null,this.source=null,this.audioCtx&&(this.audioCtx.close(),this.audioCtx=null),this.stopTracks()}stopTracks(){this.stream?.getTracks().forEach(e=>e.stop()),this.stream=null}constructor(e){(0,i._)(this,"onFrame",void 0),(0,i._)(this,"stream",void 0),(0,i._)(this,"audioCtx",void 0),(0,i._)(this,"processor",void 0),(0,i._)(this,"source",void 0),(0,i._)(this,"zeroGain",void 0),(0,i._)(this,"running",void 0),this.onFrame=e,this.stream=null,this.audioCtx=null,this.processor=null,this.source=null,this.zeroGain=null,this.running=!1}}},66330:function(e,t,s){"use strict";s.d(t,{VoiceInputButton:function(){return a}});var i=s(82749),n=s(20466),r=s(62843);class a{get container(){return this.button.container}setParentView(e){this.button.setParentView(e)}start(){let e,t={onInterim:e=>{this.clearAutoSend(),this.insertPhrase(e)},onFinal:e=>{this.insertPhrase(e),this.phraseActive=!1,this.scheduleAutoSend()},onError:()=>this.reset(),onEnd:()=>this.reset()};if(this.config.api)e=this.config.api(t);else{let{url:s,apiKey:i}=this.config;if(!s||!i)return;e=new n.VoiceTranscriber({url:s,apiKey:i,model:this.config.defaultModel,language:this.config.language,silenceMs:this.config.silenceTimeoutMs,...t})}this.phraseActive=!1,this.engine=e,this.listening=!0,this.setActive(!0),e.start()}reset(){this.clearAutoSend(),this.setActive(!1),this.phraseActive=!1,this.listening=!1,this.engine=null,this.io.focus()}scheduleAutoSend(){this.clearAutoSend();let e=this.config.autoSendSilenceMs;null!=e&&(this.autoSendTimer=this.jodit.async.setTimeout(()=>{this.autoSendTimer=0,this.io.send()},e))}clearAutoSend(){this.autoSendTimer&&(this.jodit.async.clearTimeout(this.autoSendTimer),this.autoSendTimer=0)}setActive(e){this.button.container.classList.toggle("jodit-ai-voice-active",e)}insertPhrase(e){if(!this.phraseActive){this.phraseActive=!0;let{start:e,end:t}=this.io.getSelection(),s=this.io.getValue();this.before=s.slice(0,e),this.after=s.slice(t)}let t=(this.before.length>0&&!/\s$/.test(this.before)?" ":"")+e,s=this.before.length+t.length;this.io.setValue(this.before+t+this.after,s)}destruct(){this.clearAutoSend(),this.jodit.e.off("sendMessage.ai-assistant-pro",this.onPromptSent),this.engine?.stop(),this.engine=null,this.button.destruct()}constructor(e,t,s){(0,i._)(this,"jodit",void 0),(0,i._)(this,"config",void 0),(0,i._)(this,"io",void 0),(0,i._)(this,"button",void 0),(0,i._)(this,"engine",void 0),(0,i._)(this,"listening",void 0),(0,i._)(this,"phraseActive",void 0),(0,i._)(this,"before",void 0),(0,i._)(this,"after",void 0),(0,i._)(this,"autoSendTimer",void 0),(0,i._)(this,"onPromptSent",void 0),(0,i._)(this,"toggle",void 0),this.jodit=e,this.config=t,this.io=s,this.engine=null,this.listening=!1,this.phraseActive=!1,this.before="",this.after="",this.autoSendTimer=0,this.onPromptSent=()=>{this.phraseActive=!1},this.toggle=()=>{if(this.listening){this.engine?.stop(),this.reset();return}this.start()},this.button=new r.UIButton(e,{name:"voice-input",icon:{name:"microphone"},variant:"initial",size:"middle"}),this.button.container.setAttribute("title","Dictate"),this.button.container.setAttribute("data-ref","voiceInputButton"),this.jodit.e.on(this.button,"click",this.toggle),this.jodit.e.on("sendMessage.ai-assistant-pro",this.onPromptSent)}}},20466:function(e,t,s){"use strict";s.d(t,{VoiceTranscriber:function(){return r}});var i=s(82749),n=s(88710);class r{get isActive(){return this.running}start(){let e;if(this.running)return;this.running=!0;try{let t=new URL(this.options.url);t.searchParams.set("key",this.options.apiKey),this.options.model&&t.searchParams.set("model",this.options.model),this.options.language&&t.searchParams.set("language",this.options.language),void 0!==this.options.silenceMs&&t.searchParams.set("silence",this.options.silenceMs+""),e=t.toString()}catch{this.fail("Invalid transcription URL");return}let t=new WebSocket(e);t.binaryType="arraybuffer",this.ws=t,t.addEventListener("message",e=>this.onMessage(e)),t.addEventListener("error",()=>this.fail("Transcription connection error")),t.addEventListener("close",()=>this.finish())}stop(){this.running&&(this.running=!1,this.streamer?.stop(),this.streamer=null,this.ws&&(this.ws.readyState===WebSocket.OPEN||this.ws.readyState===WebSocket.CONNECTING)&&this.ws.close())}onMessage(e){let t;if("string"==typeof e.data){try{t=JSON.parse(e.data)}catch{return}switch(t.type){case"ready":this.options.onReady?.(),this.startAudio();break;case"delta":t.text&&this.options.onInterim?.(t.text);break;case"final":t.text&&this.options.onFinal?.(t.text);break;case"error":this.fail(t.message??"Transcription error")}}}startAudio(){if(!this.running||this.streamer)return;let e=new n.MicrophoneStreamer(e=>{this.ws?.readyState===WebSocket.OPEN&&this.ws.send(e)});this.streamer=e,e.start().catch(()=>{this.fail("Microphone access denied")})}fail(e){this.options.onError?.(e),this.stop()}finish(){let e=this.running;this.running=!1,this.streamer?.stop(),this.streamer=null,e&&this.options.onEnd?.()}constructor(e){(0,i._)(this,"options",void 0),(0,i._)(this,"ws",void 0),(0,i._)(this,"streamer",void 0),(0,i._)(this,"running",void 0),this.options=e,this.ws=null,this.streamer=null,this.running=!1}}},18549:function(e,t,s){"use strict";s.d(t,{UIFlightPosition:function(){return r}});var i=s(2748);let n=new WeakMap;class r{static install(e,t,s={}){this.remove(e);let{panelHeight:i=250,containerClassName:r,toolbarSelector:a=".jodit-toolbar__box",gap:o=16}=s,l=e.j.c.div("jodit-flight-position");r&&l.classList.add(r),l.style.setProperty("--flight-panel-height",`${i}px`),l.appendChild(e.container),document.body.appendChild(l);let c={toolbarSelector:a,gap:o},h=()=>{this.updatePosition(l,t,c)},u=new ResizeObserver(h);u.observe(t),window.addEventListener("scroll",h,{passive:!0}),window.addEventListener("resize",h,{passive:!0}),n.set(e,{container:l,anchor:t,onScroll:h,resizeObserver:u,options:c}),this.updatePosition(l,t,c)}static updatePosition(e,t,s){let{toolbarSelector:i,gap:n}=s,r=t.getBoundingClientRect(),a=window.innerHeight,o=e.offsetHeight||250;e.style.left=`${r.left}px`,e.style.width=`${r.width}px`;let l=t.querySelector(i),c=l?l.getBoundingClientRect().bottom:r.top,h=r.bottom-c,u=r.bottom<=a;o<=h?u?(e.style.top="auto",e.style.bottom=`${a-r.bottom+n}px`):(e.style.top="auto",e.style.bottom=`${n}px`):(e.style.bottom="auto",e.style.top=`${c}px`)}static remove(e){let t=n.get(e);t&&(window.removeEventListener("scroll",t.onScroll),window.removeEventListener("resize",t.onScroll),t.resizeObserver.disconnect(),e.container.parentNode===t.container&&t.container.parentNode?.insertBefore(e.container,t.container),i.Dom.safeRemove(t.container),n.delete(e))}static isInstalled(e){return n.has(e)}static setPanelHeight(e,t){let s=n.get(e);s&&s.container.style.setProperty("--flight-panel-height",`${t}px`)}static refresh(e){let t=n.get(e);t&&this.updatePosition(t.container,t.anchor,t.options)}}},54747:function(e,t,s){"use strict";s.d(t,{UIResize:function(){return r}});var i=s(2748),n=s(41180);class r{static remove(e){e.container.classList.remove("jodit-ui-resize"),i.Dom.safeRemove(e.container.querySelector(".jodit-ui-resize__handle"))}static install(e,t,s={}){e.container.classList.add("jodit-ui-resize"),"static"===(0,n.css)(e.container,"position")&&(0,n.css)(e.container,"position","relative");let i=e.j.c.div("jodit-ui-resize__handle");i.classList.add("jodit-ui-resize__handle_type_"+t),s.handleClassName&&i.classList.add(s.handleClassName),e.container.appendChild(i),e.j.e.on(i,"mousedown touchstart",this.onStartResize.bind(this,e,t,s.onResize??(()=>void 0)))}static onStartResize(e,t,s,i){let n={x:i.clientX,y:i.clientY,w:e.container.offsetWidth,h:e.container.offsetHeight,direction:t},r=e.j.async.throttle(this.onResize.bind(this,e,n,s),e.j.defaultTimeout/10);e.j.lock(),e.j.e.on(e.j.ow,"mousemove touchmove",r).one(e.j.ow,"mouseup touchend",this.onEndResize.bind(this,e,r))}static onResize(e,t,s,i){let r,a=["left","right"].includes(t.direction),o=e.container.parentElement;o&&(r=a?t.w+(i.clientX-t.x)*("right"===t.direction?1:-1):t.h+(i.clientY-t.y)*("top"===t.direction?-1:1),!0!==s?.({newSize:r})&&(0,n.css)(e.container,a?"width":"height",r/(a?o.offsetWidth:o.offsetHeight)*100+"%"))}static onEndResize(e,t,s){e.j.e.off(e.j.ow,"mousemove touchmove",t),e.j.unlock()}}},72573:function(e,t,s){"use strict";function i(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function n(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}s.d(t,{marked:function(){return ey}});var r,a=n(),o={exec:()=>null};function l(e,t=""){let s="string"==typeof e?e:e.source,i={replace(e,t){let n="string"==typeof t?t:t.source;return n=n.replace(h.caret,"$1"),s=s.replace(e,n),i},getRegex:()=>new RegExp(s,t)};return i}var c=(()=>{try{return!!RegExp("(?<=1)(?<!1)")}catch{return!1}})(),h={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}>`)},u=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,d=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,p=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,g=l(p).replace(/bull/g,d).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),m=l(p).replace(/bull/g,d).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),f=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,v=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,w=l(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",v).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),x=l(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,d).getRegex(),C="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",y=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,b=l("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",y).replace("tag",C).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),k=l(f).replace("hr",u).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",C).getRegex(),_={blockquote:l(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",k).getRegex(),code:/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,def:w,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:u,html:b,lheading:g,list:x,newline:/^(?:[ \t]*(?:\n|$))+/,paragraph:k,table:o,text:/^[^\n]+/},S=l("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",u).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",C).getRegex(),A={..._,lheading:m,table:S,paragraph:l(f).replace("hr",u).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",S).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",C).getRegex()},M={..._,html:l("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",y).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:o,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:l(f).replace("hr",u).replace("heading",` *#{1,6} *[^
|
|
63
|
-
]`).replace("lheading",g).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},I=/^( {2,}|\\)\n(?!\s*$)/,T=/[\p{P}\p{S}]/u,P=/[\s\p{P}\p{S}]/u,E=/[^\s\p{P}\p{S}]/u,j=l(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,P).getRegex(),R=/(?!~)[\p{P}\p{S}]/u,L
|
|
62
|
+
</div>`}}a=(0,i.__decorate)([n.component],a)},88710:function(e,t,s){"use strict";s.d(t,{MicrophoneStreamer:function(){return n}});var i=s(82749);class n{async start(){if(this.running=!0,this.stream=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0}}),!this.running)return void this.stopTracks();let e=new AudioContext;if("suspended"===e.state&&await e.resume(),!this.running)return void e.close();let t=e.createMediaStreamSource(this.stream),s=e.createScriptProcessor(4096,1,1),i=e.createGain();i.gain.value=0,s.onaudioprocess=e=>{if(!this.running)return;let t=function(e){let t=new Int16Array(e.length);for(let s=0;s<e.length;s++){let i=Math.max(-1,Math.min(1,e[s]));t[s]=i<0?32768*i:32767*i}return t}(function(e,t){if(24e3>=t)return e;let s=t/24e3,i=Math.round(e.length/s),n=new Float32Array(i);for(let t=0;i>t;t++)n[t]=e[Math.min(Math.round(t*s),e.length-1)];return n}(e.inputBuffer.getChannelData(0),e.inputBuffer.sampleRate));this.onFrame(t)},t.connect(s),s.connect(i),i.connect(e.destination),this.audioCtx=e,this.source=t,this.processor=s,this.zeroGain=i}stop(){this.running=!1,this.processor&&(this.processor.onaudioprocess=null,this.processor.disconnect(),this.processor=null),this.zeroGain?.disconnect(),this.source?.disconnect(),this.zeroGain=null,this.source=null,this.audioCtx&&(this.audioCtx.close(),this.audioCtx=null),this.stopTracks()}stopTracks(){this.stream?.getTracks().forEach(e=>e.stop()),this.stream=null}constructor(e){(0,i._)(this,"onFrame",void 0),(0,i._)(this,"stream",void 0),(0,i._)(this,"audioCtx",void 0),(0,i._)(this,"processor",void 0),(0,i._)(this,"source",void 0),(0,i._)(this,"zeroGain",void 0),(0,i._)(this,"running",void 0),this.onFrame=e,this.stream=null,this.audioCtx=null,this.processor=null,this.source=null,this.zeroGain=null,this.running=!1}}},66330:function(e,t,s){"use strict";s.d(t,{VoiceInputButton:function(){return a}});var i=s(82749),n=s(20466),r=s(62843);class a{get container(){return this.button.container}setParentView(e){this.button.setParentView(e)}start(){let e,t={onInterim:e=>{this.clearAutoSend(),this.insertPhrase(e)},onFinal:e=>{this.insertPhrase(e),this.phraseActive=!1,this.scheduleAutoSend()},onError:()=>this.reset(),onEnd:()=>this.reset()};if(this.config.api)e=this.config.api(t);else{let{url:s,apiKey:i}=this.config;if(!s||!i)return;e=new n.VoiceTranscriber({url:s,apiKey:i,model:this.config.defaultModel,language:this.config.language,silenceMs:this.config.silenceTimeoutMs,...t})}this.phraseActive=!1,this.engine=e,this.listening=!0,this.setActive(!0),e.start()}reset(){this.clearAutoSend(),this.setActive(!1),this.phraseActive=!1,this.listening=!1,this.engine=null,this.io.focus()}scheduleAutoSend(){this.clearAutoSend();let e=this.config.autoSendSilenceMs;null!=e&&(this.autoSendTimer=this.jodit.async.setTimeout(()=>{this.autoSendTimer=0,this.io.send()},e))}clearAutoSend(){this.autoSendTimer&&(this.jodit.async.clearTimeout(this.autoSendTimer),this.autoSendTimer=0)}setActive(e){this.button.container.classList.toggle("jodit-ai-voice-active",e)}insertPhrase(e){if(!this.phraseActive){this.phraseActive=!0;let{start:e,end:t}=this.io.getSelection(),s=this.io.getValue();this.before=s.slice(0,e),this.after=s.slice(t)}let t=(this.before.length>0&&!/\s$/.test(this.before)?" ":"")+e,s=this.before.length+t.length;this.io.setValue(this.before+t+this.after,s)}destruct(){this.clearAutoSend(),this.jodit.e.off("sendMessage.ai-assistant-pro",this.onPromptSent),this.engine?.stop(),this.engine=null,this.button.destruct()}constructor(e,t,s){(0,i._)(this,"jodit",void 0),(0,i._)(this,"config",void 0),(0,i._)(this,"io",void 0),(0,i._)(this,"button",void 0),(0,i._)(this,"engine",void 0),(0,i._)(this,"listening",void 0),(0,i._)(this,"phraseActive",void 0),(0,i._)(this,"before",void 0),(0,i._)(this,"after",void 0),(0,i._)(this,"autoSendTimer",void 0),(0,i._)(this,"onPromptSent",void 0),(0,i._)(this,"toggle",void 0),this.jodit=e,this.config=t,this.io=s,this.engine=null,this.listening=!1,this.phraseActive=!1,this.before="",this.after="",this.autoSendTimer=0,this.onPromptSent=()=>{this.phraseActive=!1},this.toggle=()=>{if(this.listening){this.engine?.stop(),this.reset();return}this.start()},this.button=new r.UIButton(e,{name:"voice-input",icon:{name:"microphone"},variant:"initial",size:"middle"}),this.button.container.setAttribute("title","Dictate"),this.button.container.setAttribute("data-ref","voiceInputButton"),this.jodit.e.on(this.button,"click",this.toggle),this.jodit.e.on("sendMessage.ai-assistant-pro",this.onPromptSent)}}},20466:function(e,t,s){"use strict";s.d(t,{VoiceTranscriber:function(){return r}});var i=s(82749),n=s(88710);class r{get isActive(){return this.running}start(){let e;if(this.running)return;this.running=!0;try{let t=new URL(this.options.url);t.searchParams.set("key",this.options.apiKey),this.options.model&&t.searchParams.set("model",this.options.model),this.options.language&&t.searchParams.set("language",this.options.language),void 0!==this.options.silenceMs&&t.searchParams.set("silence",this.options.silenceMs+""),e=t.toString()}catch{this.fail("Invalid transcription URL");return}let t=new WebSocket(e);t.binaryType="arraybuffer",this.ws=t,t.addEventListener("message",e=>this.onMessage(e)),t.addEventListener("error",()=>this.fail("Transcription connection error")),t.addEventListener("close",()=>this.finish())}stop(){this.running&&(this.running=!1,this.streamer?.stop(),this.streamer=null,this.ws&&(this.ws.readyState===WebSocket.OPEN||this.ws.readyState===WebSocket.CONNECTING)&&this.ws.close())}onMessage(e){let t;if("string"==typeof e.data){try{t=JSON.parse(e.data)}catch{return}switch(t.type){case"ready":this.options.onReady?.(),this.startAudio();break;case"delta":t.text&&this.options.onInterim?.(t.text);break;case"final":t.text&&this.options.onFinal?.(t.text);break;case"error":this.fail(t.message??"Transcription error")}}}startAudio(){if(!this.running||this.streamer)return;let e=new n.MicrophoneStreamer(e=>{this.ws?.readyState===WebSocket.OPEN&&this.ws.send(e)});this.streamer=e,e.start().catch(()=>{this.fail("Microphone access denied")})}fail(e){this.options.onError?.(e),this.stop()}finish(){let e=this.running;this.running=!1,this.streamer?.stop(),this.streamer=null,e&&this.options.onEnd?.()}constructor(e){(0,i._)(this,"options",void 0),(0,i._)(this,"ws",void 0),(0,i._)(this,"streamer",void 0),(0,i._)(this,"running",void 0),this.options=e,this.ws=null,this.streamer=null,this.running=!1}}},18549:function(e,t,s){"use strict";s.d(t,{UIFlightPosition:function(){return r}});var i=s(2748);let n=new WeakMap;class r{static install(e,t,s={}){this.remove(e);let{panelHeight:i=250,containerClassName:r,toolbarSelector:a=".jodit-toolbar__box",gap:o=16}=s,l=e.j.c.div("jodit-flight-position");r&&l.classList.add(r),l.style.setProperty("--flight-panel-height",`${i}px`),l.appendChild(e.container),document.body.appendChild(l);let c={toolbarSelector:a,gap:o},h=()=>{this.updatePosition(l,t,c)},u=new ResizeObserver(h);u.observe(t),window.addEventListener("scroll",h,{passive:!0}),window.addEventListener("resize",h,{passive:!0}),n.set(e,{container:l,anchor:t,onScroll:h,resizeObserver:u,options:c}),this.updatePosition(l,t,c)}static updatePosition(e,t,s){let{toolbarSelector:i,gap:n}=s,r=t.getBoundingClientRect(),a=window.innerHeight,o=e.offsetHeight||250;e.style.left=`${r.left}px`,e.style.width=`${r.width}px`;let l=t.querySelector(i),c=l?l.getBoundingClientRect().bottom:r.top,h=r.bottom-c,u=r.bottom<=a;o<=h?u?(e.style.top="auto",e.style.bottom=`${a-r.bottom+n}px`):(e.style.top="auto",e.style.bottom=`${n}px`):(e.style.bottom="auto",e.style.top=`${c}px`)}static remove(e){let t=n.get(e);t&&(window.removeEventListener("scroll",t.onScroll),window.removeEventListener("resize",t.onScroll),t.resizeObserver.disconnect(),e.container.parentNode===t.container&&t.container.parentNode?.insertBefore(e.container,t.container),i.Dom.safeRemove(t.container),n.delete(e))}static isInstalled(e){return n.has(e)}static setPanelHeight(e,t){let s=n.get(e);s&&s.container.style.setProperty("--flight-panel-height",`${t}px`)}static refresh(e){let t=n.get(e);t&&this.updatePosition(t.container,t.anchor,t.options)}}},54747:function(e,t,s){"use strict";s.d(t,{UIResize:function(){return r}});var i=s(2748),n=s(41180);class r{static remove(e){e.container.classList.remove("jodit-ui-resize"),i.Dom.safeRemove(e.container.querySelector(".jodit-ui-resize__handle"))}static install(e,t,s={}){e.container.classList.add("jodit-ui-resize"),"static"===(0,n.css)(e.container,"position")&&(0,n.css)(e.container,"position","relative");let i=e.j.c.div("jodit-ui-resize__handle");i.classList.add("jodit-ui-resize__handle_type_"+t),s.handleClassName&&i.classList.add(s.handleClassName),e.container.appendChild(i),e.j.e.on(i,"mousedown touchstart",this.onStartResize.bind(this,e,t,s.onResize??(()=>void 0)))}static onStartResize(e,t,s,i){let n={x:i.clientX,y:i.clientY,w:e.container.offsetWidth,h:e.container.offsetHeight,direction:t},r=e.j.async.throttle(this.onResize.bind(this,e,n,s),e.j.defaultTimeout/10);e.j.lock(),e.j.e.on(e.j.ow,"mousemove touchmove",r).one(e.j.ow,"mouseup touchend",this.onEndResize.bind(this,e,r))}static onResize(e,t,s,i){let r,a=["left","right"].includes(t.direction),o=e.container.parentElement;o&&(r=a?t.w+(i.clientX-t.x)*("right"===t.direction?1:-1):t.h+(i.clientY-t.y)*("top"===t.direction?-1:1),!0!==s?.({newSize:r})&&(0,n.css)(e.container,a?"width":"height",r/(a?o.offsetWidth:o.offsetHeight)*100+"%"))}static onEndResize(e,t,s){e.j.e.off(e.j.ow,"mousemove touchmove",t),e.j.unlock()}}},72573:function(e,t,s){"use strict";function i(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function n(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}s.d(t,{marked:function(){return eC}});var r,a=n(),o={exec:()=>null};function l(e,t=""){let s="string"==typeof e?e:e.source,i={replace(e,t){let n="string"==typeof t?t:t.source;return n=n.replace(h.caret,"$1"),s=s.replace(e,n),i},getRegex:()=>new RegExp(s,t)};return i}var c=(()=>{try{return!!RegExp("(?<=1)(?<!1)")}catch{return!1}})(),h={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}>`)},u=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,d=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,p=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,g=l(p).replace(/bull/g,d).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),m=l(p).replace(/bull/g,d).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),f=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,v=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,w=l(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",v).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),x=l(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,d).getRegex(),C="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",y=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,b=l("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",y).replace("tag",C).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),k=l(f).replace("hr",u).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",C).getRegex(),_={blockquote:l(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",k).getRegex(),code:/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,def:w,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:u,html:b,lheading:g,list:x,newline:/^(?:[ \t]*(?:\n|$))+/,paragraph:k,table:o,text:/^[^\n]+/},S=l("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",u).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",C).getRegex(),A={..._,lheading:m,table:S,paragraph:l(f).replace("hr",u).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",S).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",C).getRegex()},M={..._,html:l("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",y).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:o,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:l(f).replace("hr",u).replace("heading",` *#{1,6} *[^
|
|
63
|
+
]`).replace("lheading",g).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},I=/^( {2,}|\\)\n(?!\s*$)/,T=/[\p{P}\p{S}]/u,P=/[\s\p{P}\p{S}]/u,E=/[^\s\p{P}\p{S}]/u,j=l(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,P).getRegex(),R=/(?!~)[\p{P}\p{S}]/u,L=l(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",c?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),B=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,$=l(B,"u").replace(/punct/g,T).getRegex(),D=l(B,"u").replace(/punct/g,R).getRegex(),N="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",z=l(N,"gu").replace(/notPunctSpace/g,E).replace(/punctSpace/g,P).replace(/punct/g,T).getRegex(),q=l(N,"gu").replace(/notPunctSpace/g,/(?:[^\s\p{P}\p{S}]|~)/u).replace(/punctSpace/g,/(?!~)[\s\p{P}\p{S}]/u).replace(/punct/g,R).getRegex(),F=l("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,E).replace(/punctSpace/g,P).replace(/punct/g,T).getRegex(),U=l(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,T).getRegex(),O=l("^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)","gu").replace(/notPunctSpace/g,E).replace(/punctSpace/g,P).replace(/punct/g,T).getRegex(),V=l(/\\(punct)/,"gu").replace(/punct/g,T).getRegex(),H=l(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),W=l(y).replace("(?:--\x3e|$)","--\x3e").getRegex(),G=l("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",W).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),K=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Q=l(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",K).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Z=l(/^!?\[(label)\]\[(ref)\]/).replace("label",K).replace("ref",v).getRegex(),J=l(/^!?\[(ref)\](?:\[\])?/).replace("ref",v).getRegex(),X=l("reflink|nolink(?!\\()","g").replace("reflink",Z).replace("nolink",J).getRegex(),Y=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,ee={_backpedal:o,anyPunctuation:V,autolink:H,blockSkip:L,br:I,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:o,delLDelim:o,delRDelim:o,emStrongLDelim:$,emStrongRDelimAst:z,emStrongRDelimUnd:F,escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,link:Q,nolink:J,punctuation:j,reflink:Z,reflinkSearch:X,tag:G,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:o},et={...ee,link:l(/^!?\[(label)\]\((.*?)\)/).replace("label",K).getRegex(),reflink:l(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",K).getRegex()},es={...ee,emStrongRDelimAst:q,emStrongLDelim:D,delLDelim:U,delRDelim:O,url:l(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Y).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:l(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Y).getRegex()},ei={...es,br:l(I).replace("{2,}","*").getRegex(),text:l(es.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},en={normal:_,gfm:A,pedantic:M},er={normal:ee,gfm:es,breaks:ei,pedantic:et},ea={"&":"&","<":"<",">":">",'"':""","'":"'"},eo=e=>ea[e];function el(e,t){if(t){if(h.escapeTest.test(e))return e.replace(h.escapeReplace,eo)}else if(h.escapeTestNoEncode.test(e))return e.replace(h.escapeReplaceNoEncode,eo);return e}function ec(e){try{e=encodeURI(e).replace(h.percentDecode,"%")}catch{return null}return e}function eh(e,t){let s=e.replace(h.findPipe,(e,t,s)=>{let i=!1,n=t;for(;--n>=0&&"\\"===s[n];)i=!i;return i?"|":" |"}).split(h.splitPipe),i=0;if(s[0].trim()||s.shift(),s.length>0&&!s.at(-1)?.trim()&&s.pop(),t)if(s.length>t)s.splice(t);else for(;s.length<t;)s.push("");for(;i<s.length;i++)s[i]=s[i].trim().replace(h.slashPipe,"|");return s}function eu(e,t,s){let i=e.length;if(0===i)return"";let n=0;for(;n<i;){let r=e.charAt(i-n-1);if(r!==t||s)if(r!==t&&s)n++;else break;else n++}return e.slice(0,i-n)}function ed(e,t,s,i,n){let r=t.href,a=t.title||null,o=e[1].replace(n.other.outputLinkReplace,"$1");i.state.inLink=!0;let l={type:"!"===e[0].charAt(0)?"image":"link",raw:s,href:r,title:a,text:o,tokens:i.inlineTokens(o)};return i.state.inLink=!1,l}var ep=class{space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:eu(e,`
|
|
64
64
|
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],s=function(e,t,s){let i=e.match(s.other.indentCodeCompensation);if(null===i)return t;let n=i[1];return t.split(`
|
|
65
65
|
`).map(e=>{let t=e.match(s.other.beginningSpace);if(null===t)return e;let[i]=t;return i.length>=n.length?e.slice(n.length):e}).join(`
|
|
66
|
-
`)}(e,t[3]||"",this.rules);return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:s}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=
|
|
67
|
-
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=
|
|
66
|
+
`)}(e,t[3]||"",this.rules);return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:s}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=eu(e,"#");(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:eu(t[0],`
|
|
67
|
+
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=eu(t[0],`
|
|
68
68
|
`).split(`
|
|
69
69
|
`),s="",i="",n=[];for(;e.length>0;){let t=!1,r=[],a;for(a=0;a<e.length;a++)if(this.rules.other.blockquoteStart.test(e[a]))r.push(e[a]),t=!0;else if(t)break;else r.push(e[a]);e=e.slice(a);let o=r.join(`
|
|
70
70
|
`),l=o.replace(this.rules.other.blockquoteSetextReplace,`
|
|
@@ -82,10 +82,10 @@ ${l}`:l;let c=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
|
|
|
82
82
|
`,1)[0],g;if(c=p,g=this.options.pedantic?c=c.replace(this.rules.other.listReplaceNesting," "):c.replace(this.rules.other.tabCharGlobal," "),n.test(c)||r.test(c)||a.test(c)||d.test(c)||t.test(c)||s.test(c))break;if(g.search(this.rules.other.nonSpaceChar)>=u||!c.trim())o+=`
|
|
83
83
|
`+g.slice(u);else{if(h||l.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||n.test(l)||r.test(l)||s.test(l))break;o+=`
|
|
84
84
|
`+c}h=!c.trim(),i+=p+`
|
|
85
|
-
`,e=e.substring(p.length+1),l=g.slice(u)}}n.loose||(a?n.loose=!0:this.rules.other.doubleBlankLine.test(i)&&(a=!0)),n.items.push({type:"list_item",raw:i,task:!!this.options.gfm&&this.rules.other.listIsTask.test(o),loose:!1,text:o,tokens:[]}),n.raw+=i}let o=n.items.at(-1);if(!o)return;for(let e of(o.raw=o.raw.trimEnd(),o.text=o.text.trimEnd(),n.raw=n.raw.trimEnd(),n.items)){if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),e.task){if(e.text=e.text.replace(this.rules.other.listReplaceTask,""),e.tokens[0]?.type==="text"||e.tokens[0]?.type==="paragraph"){e.tokens[0].raw=e.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),e.tokens[0].text=e.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,"");break}}let t=this.rules.other.listTaskCheckbox.exec(e.raw);if(t){let s={type:"checkbox",raw:t[0]+" ",checked:"[ ]"!==t[0]};e.checked=s.checked,n.loose?e.tokens[0]&&["paragraph","text"].includes(e.tokens[0].type)&&"tokens"in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=s.raw+e.tokens[0].raw,e.tokens[0].text=s.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(s)):e.tokens.unshift({type:"paragraph",raw:s.raw,text:s.raw,tokens:[s]}):e.tokens.unshift(s)}}if(!n.loose){let t=e.tokens.filter(e=>"space"===e.type);n.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}}if(n.loose)for(let e of n.items)for(let t of(e.loose=!0,e.tokens))"text"===t.type&&(t.type="paragraph");return n}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:"pre"===t[1]||"script"===t[1]||"style"===t[1],text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),s=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:s,title:i}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let s=
|
|
86
|
-
`):[],r={type:"table",raw:t[0],header:[],align:[],rows:[]};if(s.length===i.length){for(let e of i)this.rules.other.tableAlignRight.test(e)?r.align.push("right"):this.rules.other.tableAlignCenter.test(e)?r.align.push("center"):this.rules.other.tableAlignLeft.test(e)?r.align.push("left"):r.align.push(null);for(let e=0;e<s.length;e++)r.header.push({text:s[e],tokens:this.lexer.inline(s[e]),header:!0,align:r.align[e]});for(let e of n)r.rows.push(
|
|
87
|
-
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=
|
|
88
|
-
`),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],s=!1){for(this.options.pedantic&&(e=e.replace(h.tabCharGlobal," ").replace(h.spaceLine,""));e;){let i;if(this.options.extensions?.block?.some(s=>!!(i=s.call({lexer:this},e,t))&&(e=e.substring(i.raw.length),t.push(i),!0)))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);let s=t.at(-1);1===i.raw.length&&void 0!==s?s.raw+=`
|
|
85
|
+
`,e=e.substring(p.length+1),l=g.slice(u)}}n.loose||(a?n.loose=!0:this.rules.other.doubleBlankLine.test(i)&&(a=!0)),n.items.push({type:"list_item",raw:i,task:!!this.options.gfm&&this.rules.other.listIsTask.test(o),loose:!1,text:o,tokens:[]}),n.raw+=i}let o=n.items.at(-1);if(!o)return;for(let e of(o.raw=o.raw.trimEnd(),o.text=o.text.trimEnd(),n.raw=n.raw.trimEnd(),n.items)){if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),e.task){if(e.text=e.text.replace(this.rules.other.listReplaceTask,""),e.tokens[0]?.type==="text"||e.tokens[0]?.type==="paragraph"){e.tokens[0].raw=e.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),e.tokens[0].text=e.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,"");break}}let t=this.rules.other.listTaskCheckbox.exec(e.raw);if(t){let s={type:"checkbox",raw:t[0]+" ",checked:"[ ]"!==t[0]};e.checked=s.checked,n.loose?e.tokens[0]&&["paragraph","text"].includes(e.tokens[0].type)&&"tokens"in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=s.raw+e.tokens[0].raw,e.tokens[0].text=s.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(s)):e.tokens.unshift({type:"paragraph",raw:s.raw,text:s.raw,tokens:[s]}):e.tokens.unshift(s)}}if(!n.loose){let t=e.tokens.filter(e=>"space"===e.type);n.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}}if(n.loose)for(let e of n.items)for(let t of(e.loose=!0,e.tokens))"text"===t.type&&(t.type="paragraph");return n}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:"pre"===t[1]||"script"===t[1]||"style"===t[1],text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),s=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:s,title:i}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let s=eh(t[1]),i=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),n=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
86
|
+
`):[],r={type:"table",raw:t[0],header:[],align:[],rows:[]};if(s.length===i.length){for(let e of i)this.rules.other.tableAlignRight.test(e)?r.align.push("right"):this.rules.other.tableAlignCenter.test(e)?r.align.push("center"):this.rules.other.tableAlignLeft.test(e)?r.align.push("left"):r.align.push(null);for(let e=0;e<s.length;e++)r.header.push({text:s[e],tokens:this.lexer.inline(s[e]),header:!0,align:r.align[e]});for(let e of n)r.rows.push(eh(e,r.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:r.align[t]})));return r}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let e=t[1].trim();return{type:"heading",raw:t[0],depth:"="===t[2].charAt(0)?1:2,text:e,tokens:this.lexer.inline(e)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
|
|
87
|
+
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=eu(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{let e=function(e){if(-1===e.indexOf(")"))return -1;let t=0;for(let s=0;s<e.length;s++)if("\\"===e[s])s++;else if("("===e[s])t++;else if(")"===e[s]&&--t<0)return s;return t>0?-2:-1}(t[2]);if(-2===e)return;if(e>-1){let s=(0===t[0].indexOf("!")?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,s).trim(),t[3]=""}}let s=t[2],i="";if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(s);e&&(s=e[1],i=e[3])}else i=t[3]?t[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(s=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?s.slice(1):s.slice(1,-1)),ed(t,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let s;if((s=this.rules.inline.reflink.exec(e))||(s=this.rules.inline.nolink.exec(e))){let e=t[(s[2]||s[1]).replace(this.rules.other.multipleSpaceGlobal," ").toLowerCase()];if(!e){let e=s[0].charAt(0);return{type:"text",raw:e,text:e}}return ed(s,e,s[0],this.lexer,this.rules)}}emStrong(e,t,s=""){let i=this.rules.inline.emStrongLDelim.exec(e);if(!(!i||!i[1]&&!i[2]&&!i[3]&&!i[4]||i[4]&&s.match(this.rules.other.unicodeAlphaNumeric))&&(!(i[1]||i[3])||!s||this.rules.inline.punctuation.exec(s))){let s=[...i[0]].length-1,n,r,a=s,o=0,l="*"===i[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(l.lastIndex=0,t=t.slice(-1*e.length+s);null!==(i=l.exec(t));){if(!(n=i[1]||i[2]||i[3]||i[4]||i[5]||i[6]))continue;if(r=[...n].length,i[3]||i[4]){a+=r;continue}if((i[5]||i[6])&&s%3&&!((s+r)%3)){o+=r;continue}if((a-=r)>0)continue;r=Math.min(r,r+a+o);let t=[...i[0]][0].length,l=e.slice(0,s+i.index+t+r);if(Math.min(s,r)%2){let e=l.slice(1,-1);return{type:"em",raw:l,text:e,tokens:this.lexer.inlineTokens(e)}}let c=l.slice(2,-2);return{type:"strong",raw:l,text:c,tokens:this.lexer.inlineTokens(c)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal," "),s=this.rules.other.nonSpaceChar.test(e),i=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return s&&i&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,s=""){let i=this.rules.inline.delLDelim.exec(e);if(i&&(!i[1]||!s||this.rules.inline.punctuation.exec(s))){let s=[...i[0]].length-1,n,r,a=s,o=this.rules.inline.delRDelim;for(o.lastIndex=0,t=t.slice(-1*e.length+s);null!==(i=o.exec(t));){if(!(n=i[1]||i[2]||i[3]||i[4]||i[5]||i[6])||(r=[...n].length)!==s)continue;if(i[3]||i[4]){a+=r;continue}if((a-=r)>0)continue;r=Math.min(r,r+a);let t=[...i[0]][0].length,o=e.slice(0,s+i.index+t+r),l=o.slice(s,-s);return{type:"del",raw:o,text:l,tokens:this.lexer.inlineTokens(l)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,s;return s="@"===t[2]?"mailto:"+(e=t[1]):e=t[1],{type:"link",raw:t[0],text:e,href:s,tokens:[{type:"text",raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,s;if("@"===t[2])s="mailto:"+(e=t[0]);else{let i;do i=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(i!==t[0])e=t[0],s="www."===t[1]?"http://"+t[0]:t[0]}return{type:"link",raw:t[0],text:e,href:s,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:e}}}constructor(e){i(this,"options",void 0),i(this,"rules",void 0),i(this,"lexer",void 0),this.options=e||a}},eg=class e{static get rules(){return{block:en,inline:er}}static lex(t,s){return new e(s).lex(t)}static lexInline(t,s){return new e(s).inlineTokens(t)}lex(e){e=e.replace(h.carriageReturn,`
|
|
88
|
+
`),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],s=!1){for(this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(h.tabCharGlobal," ").replace(h.spaceLine,""));e;){let i;if(this.options.extensions?.block?.some(s=>!!(i=s.call({lexer:this},e,t))&&(e=e.substring(i.raw.length),t.push(i),!0)))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);let s=t.at(-1);1===i.raw.length&&void 0!==s?s.raw+=`
|
|
89
89
|
`:t.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length);let s=t.at(-1);s?.type==="paragraph"||s?.type==="text"?(s.raw+=(s.raw.endsWith(`
|
|
90
90
|
`)?"":`
|
|
91
91
|
`)+i.raw,s.text+=`
|
|
@@ -98,9 +98,9 @@ ${l}`:l;let c=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
|
|
|
98
98
|
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(i),s=n.length!==e.length,e=e.substring(i.raw.length);continue}if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);let s=t.at(-1);s?.type==="text"?(s.raw+=(s.raw.endsWith(`
|
|
99
99
|
`)?"":`
|
|
100
100
|
`)+i.raw,s.text+=`
|
|
101
|
-
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):t.push(i);continue}if(e){let t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent)break;throw Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let s
|
|
102
|
-
`;return i?'<pre><code class="language-'+
|
|
103
|
-
`:"<pre><code>"+(s?n:
|
|
101
|
+
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):t.push(i);continue}if(e){let t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent)break;throw Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let s;this.tokenizer.lexer=this;let i=e,n=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;null!==(n=this.tokenizer.rules.inline.reflinkSearch.exec(i));)e.includes(n[0].slice(n[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,n.index)+"["+"a".repeat(n[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!==(n=this.tokenizer.rules.inline.anyPunctuation.exec(i));)i=i.slice(0,n.index)+"++"+i.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;null!==(n=this.tokenizer.rules.inline.blockSkip.exec(i));)s=n[2]?n[2].length:0,i=i.slice(0,n.index+s)+"["+"a".repeat(n[0].length-s-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);i=this.options.hooks?.emStrongMask?.call({lexer:this},i)??i;let r=!1,a="";for(;e;){let s;if(r||(a=""),r=!1,this.options.extensions?.inline?.some(i=>!!(s=i.call({lexer:this},e,t))&&(e=e.substring(s.raw.length),t.push(s),!0)))continue;if((s=this.tokenizer.escape(e))||(s=this.tokenizer.tag(e))||(s=this.tokenizer.link(e))){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(s.raw.length);let i=t.at(-1);"text"===s.type&&i?.type==="text"?(i.raw+=s.raw,i.text+=s.text):t.push(s);continue}if((s=this.tokenizer.emStrong(e,i,a))||(s=this.tokenizer.codespan(e))||(s=this.tokenizer.br(e))||(s=this.tokenizer.del(e,i,a))||(s=this.tokenizer.autolink(e))||!this.state.inLink&&(s=this.tokenizer.url(e))){e=e.substring(s.raw.length),t.push(s);continue}let n=e;if(this.options.extensions?.startInline){let t=1/0,s=e.slice(1),i;this.options.extensions.startInline.forEach(e=>{"number"==typeof(i=e.call({lexer:this},s))&&i>=0&&(t=Math.min(t,i))}),t<1/0&&t>=0&&(n=e.substring(0,t+1))}if(s=this.tokenizer.inlineText(n)){e=e.substring(s.raw.length),"_"!==s.raw.slice(-1)&&(a=s.raw.slice(-1)),r=!0;let i=t.at(-1);i?.type==="text"?(i.raw+=s.raw,i.text+=s.text):t.push(s);continue}if(e){let t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent)break;throw Error(t)}}return t}constructor(e){i(this,"tokens",void 0),i(this,"options",void 0),i(this,"state",void 0),i(this,"inlineQueue",void 0),i(this,"tokenizer",void 0),this.tokens=[],this.tokens.links=Object.create(null),this.options=e||a,this.options.tokenizer=this.options.tokenizer||new ep,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:h,block:en.normal,inline:er.normal};this.options.pedantic?(t.block=en.pedantic,t.inline=er.pedantic):this.options.gfm&&(t.block=en.gfm,this.options.breaks?t.inline=er.breaks:t.inline=er.gfm),this.tokenizer.rules=t}},em=class{space(e){return""}code({text:e,lang:t,escaped:s}){let i=(t||"").match(h.notSpaceStart)?.[0],n=e.replace(h.endingNewline,"")+`
|
|
102
|
+
`;return i?'<pre><code class="language-'+el(i)+'">'+(s?n:el(n,!0))+`</code></pre>
|
|
103
|
+
`:"<pre><code>"+(s?n:el(n,!0))+`</code></pre>
|
|
104
104
|
`}blockquote({tokens:e}){return`<blockquote>
|
|
105
105
|
${this.parser.parse(e)}</blockquote>
|
|
106
106
|
`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
@@ -116,5 +116,5 @@ ${this.parser.parse(e)}</blockquote>
|
|
|
116
116
|
`}tablerow({text:e}){return`<tr>
|
|
117
117
|
${e}</tr>
|
|
118
118
|
`}tablecell(e){let t=this.parser.parseInline(e.tokens),s=e.header?"th":"td";return(e.align?`<${s} align="${e.align}">`:`<${s}>`)+t+`</${s}>
|
|
119
|
-
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${
|
|
120
|
-
Please report this to https://github.com/markedjs/marked.`,e){let e="<p>An error occurred:</p><pre>"+
|
|
119
|
+
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${el(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:s}){let i=this.parser.parseInline(s),n=ec(e);if(null===n)return i;let r='<a href="'+(e=n)+'"';return t&&(r+=' title="'+el(t)+'"'),r+=">"+i+"</a>"}image({href:e,title:t,text:s,tokens:i}){i&&(s=this.parser.parseInline(i,this.parser.textRenderer));let n=ec(e);if(null===n)return el(s);e=n;let r=`<img src="${e}" alt="${el(s)}"`;return t&&(r+=` title="${el(t)}"`),r+=">"}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:el(e.text)}constructor(e){i(this,"options",void 0),i(this,"parser",void 0),this.options=e||a}},ef=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},ev=class e{static parse(t,s){return new e(s).parse(t)}static parseInline(t,s){return new e(s).parseInline(t)}parse(e){this.renderer.parser=this;let t="";for(let s=0;s<e.length;s++){let i=e[s];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(!1!==e||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(i.type)){t+=e||"";continue}}switch(i.type){case"space":t+=this.renderer.space(i);break;case"hr":t+=this.renderer.hr(i);break;case"heading":t+=this.renderer.heading(i);break;case"code":t+=this.renderer.code(i);break;case"table":t+=this.renderer.table(i);break;case"blockquote":t+=this.renderer.blockquote(i);break;case"list":t+=this.renderer.list(i);break;case"checkbox":t+=this.renderer.checkbox(i);break;case"html":t+=this.renderer.html(i);break;case"def":t+=this.renderer.def(i);break;case"paragraph":t+=this.renderer.paragraph(i);break;case"text":t+=this.renderer.text(i);break;default:{let e='Token with "'+i.type+'" type was not found.';if(this.options.silent)return"";throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let s="";for(let i=0;i<e.length;i++){let n=e[i];if(this.options.extensions?.renderers?.[n.type]){let e=this.options.extensions.renderers[n.type].call({parser:this},n);if(!1!==e||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(n.type)){s+=e||"";continue}}switch(n.type){case"escape":case"text":s+=t.text(n);break;case"html":s+=t.html(n);break;case"link":s+=t.link(n);break;case"image":s+=t.image(n);break;case"checkbox":s+=t.checkbox(n);break;case"strong":s+=t.strong(n);break;case"em":s+=t.em(n);break;case"codespan":s+=t.codespan(n);break;case"br":s+=t.br(n);break;case"del":s+=t.del(n);break;default:{let e='Token with "'+n.type+'" type was not found.';if(this.options.silent)return"";throw Error(e)}}}return s}constructor(e){i(this,"options",void 0),i(this,"renderer",void 0),i(this,"textRenderer",void 0),this.options=e||a,this.options.renderer=this.options.renderer||new em,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new ef}},ew=(r=class{preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?eg.lex:eg.lexInline}provideParser(e=this.block){return e?ev.parse:ev.parseInline}constructor(e){i(this,"options",void 0),i(this,"block",void 0),this.options=e||a}},i(r,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),i(r,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),r),ex=new class{walkTokens(e,t){let s=[];for(let i of e)switch(s=s.concat(t.call(this,i)),i.type){case"table":for(let e of i.header)s=s.concat(this.walkTokens(e.tokens,t));for(let e of i.rows)for(let i of e)s=s.concat(this.walkTokens(i.tokens,t));break;case"list":s=s.concat(this.walkTokens(i.items,t));break;default:{let e=i;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(i=>{let n=e[i].flat(1/0);s=s.concat(this.walkTokens(n,t))}):e.tokens&&(s=s.concat(this.walkTokens(e.tokens,t)))}}return s}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let s={...e};if(s.async=this.defaults.async||s.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error("extension name required");if("renderer"in e){let s=t.renderers[e.name];s?t.renderers[e.name]=function(...t){let i=e.renderer.apply(this,t);return!1===i&&(i=s.apply(this,t)),i}:t.renderers[e.name]=e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw Error("extension level must be 'block' or 'inline'");let s=t[e.level];s?s.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),s.extensions=t),e.renderer){let t=this.defaults.renderer||new em(this.defaults);for(let s in e.renderer){if(!(s in t))throw Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let i=e.renderer[s],n=t[s];t[s]=(...e)=>{let s=i.apply(t,e);return!1===s&&(s=n.apply(t,e)),s||""}}s.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new ep(this.defaults);for(let s in e.tokenizer){if(!(s in t))throw Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let i=e.tokenizer[s],n=t[s];t[s]=(...e)=>{let s=i.apply(t,e);return!1===s&&(s=n.apply(t,e)),s}}s.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new ew;for(let s in e.hooks){if(!(s in t))throw Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let i=e.hooks[s],n=t[s];ew.passThroughHooks.has(s)?t[s]=e=>{if(this.defaults.async&&ew.passThroughHooksRespectAsync.has(s))return(async()=>{let s=await i.call(t,e);return n.call(t,s)})();let r=i.call(t,e);return n.call(t,r)}:t[s]=(...e)=>{if(this.defaults.async)return(async()=>{let s=await i.apply(t,e);return!1===s&&(s=await n.apply(t,e)),s})();let s=i.apply(t,e);return!1===s&&(s=n.apply(t,e)),s}}s.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,i=e.walkTokens;s.walkTokens=function(e){let s=[];return s.push(i.call(this,e)),t&&(s=s.concat(t.call(this,e))),s}}this.defaults={...this.defaults,...s}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return eg.lex(e,t??this.defaults)}parser(e,t){return ev.parse(e,t??this.defaults)}parseMarkdown(e){return(t,s)=>{let i={...s},n={...this.defaults,...i},r=this.onError(!!n.silent,!!n.async);if(!0===this.defaults.async&&!1===i.async)return r(Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||null===t)return r(Error("marked(): input parameter is undefined or null"));if("string"!=typeof t)return r(Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(n.hooks&&(n.hooks.options=n,n.hooks.block=e),n.async)return(async()=>{let s=n.hooks?await n.hooks.preprocess(t):t,i=await (n.hooks?await n.hooks.provideLexer(e):e?eg.lex:eg.lexInline)(s,n),r=n.hooks?await n.hooks.processAllTokens(i):i;n.walkTokens&&await Promise.all(this.walkTokens(r,n.walkTokens));let a=await (n.hooks?await n.hooks.provideParser(e):e?ev.parse:ev.parseInline)(r,n);return n.hooks?await n.hooks.postprocess(a):a})().catch(r);try{n.hooks&&(t=n.hooks.preprocess(t));let s=(n.hooks?n.hooks.provideLexer(e):e?eg.lex:eg.lexInline)(t,n);n.hooks&&(s=n.hooks.processAllTokens(s)),n.walkTokens&&this.walkTokens(s,n.walkTokens);let i=(n.hooks?n.hooks.provideParser(e):e?ev.parse:ev.parseInline)(s,n);return n.hooks&&(i=n.hooks.postprocess(i)),i}catch(e){return r(e)}}}onError(e,t){return s=>{if(s.message+=`
|
|
120
|
+
Please report this to https://github.com/markedjs/marked.`,e){let e="<p>An error occurred:</p><pre>"+el(s.message+"",!0)+"</pre>";return t?Promise.resolve(e):e}if(t)return Promise.reject(s);throw s}}constructor(...e){i(this,"defaults",n()),i(this,"options",this.setOptions),i(this,"parse",this.parseMarkdown(!0)),i(this,"parseInline",this.parseMarkdown(!1)),i(this,"Parser",ev),i(this,"Renderer",em),i(this,"TextRenderer",ef),i(this,"Lexer",eg),i(this,"Tokenizer",ep),i(this,"Hooks",ew),this.use(...e)}};function eC(e,t){return ex.parse(e,t)}eC.options=eC.setOptions=function(e){return ex.setOptions(e),eC.defaults=ex.defaults,a=eC.defaults,eC},eC.getDefaults=n,eC.defaults=a,eC.use=function(...e){return ex.use(...e),eC.defaults=ex.defaults,a=eC.defaults,eC},eC.walkTokens=function(e,t){return ex.walkTokens(e,t)},eC.parseInline=ex.parseInline,eC.Parser=ev,eC.parser=ev.parse,eC.Renderer=em,eC.TextRenderer=ef,eC.Lexer=eg,eC.lexer=eg.lex,eC.Tokenizer=ep,eC.Hooks=ew,eC.parse=eC,eC.options,eC.setOptions,eC.use,eC.walkTokens,eC.parseInline,ev.parse,eg.lex}},function(e){return e(e.s=41810)}])});
|