@richscripts/richtexteditor 2.14.0 → 2.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +173 -10
- package/angular/build-manifest.json +23 -0
- package/angular/index.d.ts +71 -76
- package/angular/index.mjs +2 -0
- package/angular/package.json +4 -0
- package/headless/index.d.ts +3 -1
- package/headless/index.js +72 -16
- package/index.d.ts +33 -54
- package/integrations/initialization-scope.js +27 -0
- package/integrations/native-mount.js +30 -0
- package/integrations/shared.d.ts +23 -1
- package/integrations/shared.js +58 -22
- package/package.json +25 -3
- package/react/index.js +118 -37
- package/react/index.mjs +29 -0
- package/richtexteditor/all_plugins.js +7113 -1111
- package/richtexteditor/all_plugins.min.js +62 -59
- package/richtexteditor/lang/emoji/LICENSE-CLDR.txt +41 -0
- package/richtexteditor/lang/emoji/rte-emoji-de.js +3 -0
- package/richtexteditor/lang/emoji/rte-emoji-es.js +3 -0
- package/richtexteditor/lang/emoji/rte-emoji-fr.js +3 -0
- package/richtexteditor/lang/emoji/rte-emoji-it.js +3 -0
- package/richtexteditor/lang/emoji/rte-emoji-ja.js +3 -0
- package/richtexteditor/lang/emoji/rte-emoji-ko.js +3 -0
- package/richtexteditor/lang/emoji/rte-emoji-nl.js +3 -0
- package/richtexteditor/lang/emoji/rte-emoji-pt-pt.js +3 -0
- package/richtexteditor/lang/emoji/rte-emoji-pt.js +3 -0
- package/richtexteditor/lang/emoji/rte-emoji-ru.js +3 -0
- package/richtexteditor/lang/emoji/rte-emoji-zh-Hans.js +3 -0
- package/richtexteditor/lang/emoji/rte-emoji-zh-Hant.js +3 -0
- package/richtexteditor/lang/rte-lang-af.js +1 -0
- package/richtexteditor/lang/rte-lang-ar.js +1 -0
- package/richtexteditor/lang/rte-lang-bg.js +1 -0
- package/richtexteditor/lang/rte-lang-bn.js +1 -0
- package/richtexteditor/lang/rte-lang-bs.js +1 -0
- package/richtexteditor/lang/rte-lang-ca.js +1 -0
- package/richtexteditor/lang/rte-lang-cs.js +1 -0
- package/richtexteditor/lang/rte-lang-cy.js +1 -0
- package/richtexteditor/lang/rte-lang-da.js +1 -0
- package/richtexteditor/lang/rte-lang-de.js +1017 -2
- package/richtexteditor/lang/rte-lang-el.js +1 -0
- package/richtexteditor/lang/rte-lang-en.js +1 -0
- package/richtexteditor/lang/rte-lang-es.js +1023 -2
- package/richtexteditor/lang/rte-lang-et.js +1 -0
- package/richtexteditor/lang/rte-lang-fa.js +1 -0
- package/richtexteditor/lang/rte-lang-fi.js +1 -0
- package/richtexteditor/lang/rte-lang-fil.js +1 -0
- package/richtexteditor/lang/rte-lang-fj.js +1 -0
- package/richtexteditor/lang/rte-lang-fr.js +1023 -2
- package/richtexteditor/lang/rte-lang-ga.js +1 -0
- package/richtexteditor/lang/rte-lang-gu.js +1 -0
- package/richtexteditor/lang/rte-lang-he.js +1 -0
- package/richtexteditor/lang/rte-lang-hi.js +1 -0
- package/richtexteditor/lang/rte-lang-hr.js +1 -0
- package/richtexteditor/lang/rte-lang-ht.js +1 -0
- package/richtexteditor/lang/rte-lang-hu.js +1 -0
- package/richtexteditor/lang/rte-lang-id.js +1 -0
- package/richtexteditor/lang/rte-lang-is.js +1 -0
- package/richtexteditor/lang/rte-lang-it.js +1023 -2
- package/richtexteditor/lang/rte-lang-ja.js +1023 -2
- package/richtexteditor/lang/rte-lang-kn.js +1 -0
- package/richtexteditor/lang/rte-lang-ko.js +1023 -2
- package/richtexteditor/lang/rte-lang-lt.js +1 -0
- package/richtexteditor/lang/rte-lang-lv.js +1 -0
- package/richtexteditor/lang/rte-lang-mg.js +1 -0
- package/richtexteditor/lang/rte-lang-mi.js +1 -0
- package/richtexteditor/lang/rte-lang-ml.js +1 -0
- package/richtexteditor/lang/rte-lang-mr.js +1 -0
- package/richtexteditor/lang/rte-lang-ms.js +1 -0
- package/richtexteditor/lang/rte-lang-mt.js +1 -0
- package/richtexteditor/lang/rte-lang-mww.js +1 -0
- package/richtexteditor/lang/rte-lang-nb.js +1 -0
- package/richtexteditor/lang/rte-lang-nl.js +1023 -2
- package/richtexteditor/lang/rte-lang-otq.js +1 -0
- package/richtexteditor/lang/rte-lang-pa.js +1 -0
- package/richtexteditor/lang/rte-lang-pl.js +1 -0
- package/richtexteditor/lang/rte-lang-pt-pt.js +1023 -2
- package/richtexteditor/lang/rte-lang-pt.js +1023 -2
- package/richtexteditor/lang/rte-lang-ro.js +1 -0
- package/richtexteditor/lang/rte-lang-ru.js +1023 -2
- package/richtexteditor/lang/rte-lang-sk.js +1 -0
- package/richtexteditor/lang/rte-lang-sl.js +1 -0
- package/richtexteditor/lang/rte-lang-sm.js +1 -0
- package/richtexteditor/lang/rte-lang-sr-Cyrl.js +1 -0
- package/richtexteditor/lang/rte-lang-sr-Latn.js +1 -0
- package/richtexteditor/lang/rte-lang-sv.js +1 -0
- package/richtexteditor/lang/rte-lang-sw.js +1 -0
- package/richtexteditor/lang/rte-lang-ta.js +1 -0
- package/richtexteditor/lang/rte-lang-te.js +1 -0
- package/richtexteditor/lang/rte-lang-th.js +1 -0
- package/richtexteditor/lang/rte-lang-tlh-Latn.js +1 -0
- package/richtexteditor/lang/rte-lang-tlh-Piqd.js +1 -0
- package/richtexteditor/lang/rte-lang-to.js +1 -0
- package/richtexteditor/lang/rte-lang-tr.js +1 -0
- package/richtexteditor/lang/rte-lang-ty.js +1 -0
- package/richtexteditor/lang/rte-lang-uk.js +1 -0
- package/richtexteditor/lang/rte-lang-ur.js +1 -0
- package/richtexteditor/lang/rte-lang-vi.js +1 -0
- package/richtexteditor/lang/rte-lang-yua.js +1 -0
- package/richtexteditor/lang/rte-lang-zh-Hans.js +1017 -2
- package/richtexteditor/lang/rte-lang-zh-Hant.js +1017 -2
- package/richtexteditor/plugins/a11yenhance.js +2 -1
- package/richtexteditor/plugins/a11yenhance.min.js +1 -1
- package/richtexteditor/plugins/accessibilitychecker.js +252 -60
- package/richtexteditor/plugins/accessibilitychecker.min.js +1 -1
- package/richtexteditor/plugins/aitoolkit.js +966 -303
- package/richtexteditor/plugins/aitoolkit.min.js +7 -7
- package/richtexteditor/plugins/all_plugins.js +7113 -1111
- package/richtexteditor/plugins/all_plugins.min.js +62 -59
- package/richtexteditor/plugins/autocorrect.js +66 -31
- package/richtexteditor/plugins/autocorrect.min.js +1 -1
- package/richtexteditor/plugins/autoembed.js +17 -0
- package/richtexteditor/plugins/autoembed.min.js +1 -1
- package/richtexteditor/plugins/blocktypes.js +18 -9
- package/richtexteditor/plugins/blocktypes.min.js +1 -1
- package/richtexteditor/plugins/bookmarkcard.js +12 -5
- package/richtexteditor/plugins/bookmarkcard.min.js +2 -2
- package/richtexteditor/plugins/changecase.js +72 -19
- package/richtexteditor/plugins/changecase.min.js +1 -1
- package/richtexteditor/plugins/charlimit.js +62 -2
- package/richtexteditor/plugins/charlimit.min.js +2 -2
- package/richtexteditor/plugins/comments.js +458 -59
- package/richtexteditor/plugins/comments.min.js +4 -3
- package/richtexteditor/plugins/contentminimap.js +25 -6
- package/richtexteditor/plugins/contentminimap.min.js +1 -1
- package/richtexteditor/plugins/crossreference.js +1 -1
- package/richtexteditor/plugins/crossreference.min.js +1 -1
- package/richtexteditor/plugins/dialoga11y.js +26 -4
- package/richtexteditor/plugins/dialoga11y.min.js +1 -1
- package/richtexteditor/plugins/dictation.js +1 -1
- package/richtexteditor/plugins/documentimport.js +220 -51
- package/richtexteditor/plugins/documentimport.min.js +4 -4
- package/richtexteditor/plugins/documentoutline.js +88 -38
- package/richtexteditor/plugins/documentoutline.min.js +1 -1
- package/richtexteditor/plugins/docxexport.js +204 -32
- package/richtexteditor/plugins/docxexport.min.js +2 -2
- package/richtexteditor/plugins/draghandle.js +267 -3
- package/richtexteditor/plugins/draghandle.min.js +1 -1
- package/richtexteditor/plugins/emailtoolkit.js +28 -14
- package/richtexteditor/plugins/emailtoolkit.min.js +1 -1
- package/richtexteditor/plugins/emojiautocomplete.js +110 -56
- package/richtexteditor/plugins/emojiautocomplete.min.js +1 -1
- package/richtexteditor/plugins/footnotes.js +65 -11
- package/richtexteditor/plugins/footnotes.min.js +1 -1
- package/richtexteditor/plugins/formatpainter.js +10 -0
- package/richtexteditor/plugins/formatpainter.min.js +1 -1
- package/richtexteditor/plugins/formattingmarks.js +53 -8
- package/richtexteditor/plugins/formattingmarks.min.js +1 -1
- package/richtexteditor/plugins/gapcursor.js +60 -0
- package/richtexteditor/plugins/gapcursor.min.js +1 -1
- package/richtexteditor/plugins/ghostcomplete.js +1 -1
- package/richtexteditor/plugins/html2pdf.js +1 -1
- package/richtexteditor/plugins/html2pdf.min.js +1 -1
- package/richtexteditor/plugins/imageeditor.js +12 -6
- package/richtexteditor/plugins/imageeditor.min.js +1 -1
- package/richtexteditor/plugins/importstyles.js +1 -1
- package/richtexteditor/plugins/inlinecode.js +25 -0
- package/richtexteditor/plugins/inlinecode.min.js +1 -1
- package/richtexteditor/plugins/insertcode.js +21 -3
- package/richtexteditor/plugins/insertcode.min.js +4 -4
- package/richtexteditor/plugins/insertemoji.js +112 -15
- package/richtexteditor/plugins/insertemoji.min.js +1 -1
- package/richtexteditor/plugins/insertgallery.js +42 -36
- package/richtexteditor/plugins/insertgallery.min.js +1 -1
- package/richtexteditor/plugins/inserttemplate.js +33 -17
- package/richtexteditor/plugins/inserttemplate.min.js +1 -1
- package/richtexteditor/plugins/keyboarda11y.js +66 -3
- package/richtexteditor/plugins/keyboarda11y.min.js +1 -1
- package/richtexteditor/plugins/layouttable.js +20 -0
- package/richtexteditor/plugins/layouttable.min.js +1 -1
- package/richtexteditor/plugins/linkchecker.js +29 -9
- package/richtexteditor/plugins/linkchecker.min.js +1 -1
- package/richtexteditor/plugins/localdraft.js +51 -7
- package/richtexteditor/plugins/localdraft.min.js +1 -1
- package/richtexteditor/plugins/markdownexport.js +159 -0
- package/richtexteditor/plugins/markdownexport.min.js +2 -2
- package/richtexteditor/plugins/mathdialog.js +11 -5
- package/richtexteditor/plugins/mathdialog.min.js +1 -1
- package/richtexteditor/plugins/mentionplugin.js +88 -25
- package/richtexteditor/plugins/mentionplugin.min.js +1 -1
- package/richtexteditor/plugins/mermaiddiagram.js +9 -3
- package/richtexteditor/plugins/mermaiddiagram.min.js +2 -2
- package/richtexteditor/plugins/multilevellist.js +4 -0
- package/richtexteditor/plugins/multilevellist.min.js +1 -1
- package/richtexteditor/plugins/pdfexport.js +235 -35
- package/richtexteditor/plugins/pdfexport.min.js +12 -12
- package/richtexteditor/plugins/permanentpen.js +3 -3
- package/richtexteditor/plugins/permanentpen.min.js +1 -1
- package/richtexteditor/plugins/readabilitystats.js +25 -11
- package/richtexteditor/plugins/readabilitystats.min.js +1 -1
- package/richtexteditor/plugins/readaloud.js +29 -15
- package/richtexteditor/plugins/readaloud.min.js +1 -1
- package/richtexteditor/plugins/restrictedediting.js +166 -0
- package/richtexteditor/plugins/restrictedediting.min.js +2 -2
- package/richtexteditor/plugins/revisionhistory.js +169 -37
- package/richtexteditor/plugins/revisionhistory.min.js +3 -3
- package/richtexteditor/plugins/rubyannotation.js +19 -9
- package/richtexteditor/plugins/rubyannotation.min.js +1 -1
- package/richtexteditor/plugins/sanitizer.js +86 -4
- package/richtexteditor/plugins/sanitizer.min.js +1 -1
- package/richtexteditor/plugins/slashcommand.js +30 -16
- package/richtexteditor/plugins/slashcommand.min.js +2 -2
- package/richtexteditor/plugins/smartchips.js +36 -22
- package/richtexteditor/plugins/smartchips.min.js +2 -2
- package/richtexteditor/plugins/spellcheck.js +17 -8
- package/richtexteditor/plugins/spellcheck.min.js +2 -2
- package/richtexteditor/plugins/stateinspector.js +19 -9
- package/richtexteditor/plugins/stateinspector.min.js +2 -2
- package/richtexteditor/plugins/structured-content-bridge.js +56 -24
- package/richtexteditor/plugins/structured-content-bridge.min.js +7 -7
- package/richtexteditor/plugins/tableofcontents.js +5 -2
- package/richtexteditor/plugins/tableofcontents.min.js +1 -1
- package/richtexteditor/plugins/tabletools.js +388 -3
- package/richtexteditor/plugins/tabletools.min.js +1 -1
- package/richtexteditor/plugins/textdirection.js +18 -5
- package/richtexteditor/plugins/textdirection.min.js +1 -1
- package/richtexteditor/plugins/textpartlanguage.js +161 -32
- package/richtexteditor/plugins/textpartlanguage.min.js +1 -1
- package/richtexteditor/plugins/todolist.js +90 -6
- package/richtexteditor/plugins/todolist.min.js +1 -1
- package/richtexteditor/plugins/trackedchanges.js +1812 -25
- package/richtexteditor/plugins/trackedchanges.min.js +5 -3
- package/richtexteditor/plugins/wordexport.js +2 -2
- package/richtexteditor/plugins/yjscollab.js +9 -4
- package/richtexteditor/plugins/yjscollab.min.js +1 -1
- package/richtexteditor/plugins/zz_richtextbox_dialog_style.js +22 -13
- package/richtexteditor/plugins/zz_richtextbox_dialog_style.min.js +1 -1
- package/richtexteditor/rte-config.js +131 -50
- package/richtexteditor/rte-headless.js +19 -4
- package/richtexteditor/rte-webcomponent.js +89 -16
- package/richtexteditor/rte.js +133 -52
- package/richtexteditor/runtime/colorpicker_more_ns.htm +93 -16
- package/scripts/build-angular.mjs +97 -0
- package/svelte/index.d.ts +2 -1
- package/svelte/index.js +80 -9
- package/vue/index.js +130 -34
- package/angular/component.ts +0 -297
- package/angular/index.ts +0 -24
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
window.RTE_DefaultConfig||(window.RTE_DefaultConfig={}),(function(){if(typeof document>"u"||window.RTE_DefaultConfig&&window.RTE_DefaultConfig.aitoolkit_skip_auto_css)return;for(var k=document.querySelectorAll("link[rel=stylesheet]"),s=0;s<k.length;s++){var Fn=k[s].getAttribute("href")||"";if(/(?:^|\/)aitoolkit(?:\.min)?\.css(?:\?.*)?$/i.test(Fn))return}for(var Di=null,Oi=document.getElementsByTagName("script"),Gr=Oi.length-1;Gr>=0;Gr--){var Kn=Oi[Gr].getAttribute("src")||"";if(/(?:^|\/)(?:aitoolkit|all_plugins)\.js(?:\?.*)?$/i.test(Kn)){Di=Oi[Gr];break}}var o=Di?Di.getAttribute("src"):"";function _r(Si){return o?o.replace(/[^/]+$/,Si):(window.RTE_DefaultConfig&&window.RTE_DefaultConfig.url_base||"/richtexteditor")+"/plugins/"+Si}function $a(Si){return Si.indexOf("?")<0?Si+"?v=20260830a":Si}var Ur=document.createElement("link");Ur.rel="stylesheet",Ur.href=$a(_r("aitoolkit.min.css")),Ur.setAttribute("data-rte-auto-injected","aitoolkit"),Ur.onerror=function(){Ur.getAttribute("data-rte-css-fallback")||(Ur.setAttribute("data-rte-css-fallback","1"),Ur.href=$a(_r("aitoolkit.css")))},(document.head||document.documentElement).appendChild(Ur)})(),RTE_DefaultConfig.svgCode_aiassist||(RTE_DefaultConfig.svgCode_aiassist='<svg viewBox="0 0 24 24" width="20" height="20" fill="none" aria-hidden="true"><defs><linearGradient id="rte-ai-robot-shell" x1="5" y1="6" x2="19" y2="18" gradientUnits="userSpaceOnUse"><stop stop-color="#1fb6ff"/><stop offset=".52" stop-color="#2563eb"/><stop offset="1" stop-color="#7c3aed"/></linearGradient><linearGradient id="rte-ai-robot-glow" x1="8" y1="10" x2="16" y2="15" gradientUnits="userSpaceOnUse"><stop stop-color="#fef9c3"/><stop offset="1" stop-color="#fde68a"/></linearGradient></defs><path d="M12 2.4v2.4" stroke="#f59e0b" stroke-width="1.7" stroke-linecap="round"/><circle cx="12" cy="2.4" r="1" fill="#fbbf24"/><rect x="5.1" y="6.1" width="13.8" height="11.2" rx="3.4" fill="url(#rte-ai-robot-shell)" stroke="#1e40af" stroke-width="1.2"/><path d="M8.2 6.1V5.8A1.8 1.8 0 0110 4h4a1.8 1.8 0 011.8 1.8v.3" stroke="#93c5fd" stroke-width="1.2" stroke-linecap="round"/><rect x="7.7" y="9.2" width="8.6" height="4.8" rx="2.4" fill="#0f172a" opacity=".26"/><circle cx="10" cy="11.6" r="1.15" fill="url(#rte-ai-robot-glow)"/><circle cx="14" cy="11.6" r="1.15" fill="url(#rte-ai-robot-glow)"/><path d="M9.4 14.9c.8.55 1.66.83 2.6.83s1.8-.28 2.6-.83" stroke="#ffffff" stroke-width="1.45" stroke-linecap="round"/><path d="M8.1 19.2l1-2.1M15.9 19.2l-1-2.1" stroke="#2563eb" stroke-width="1.5" stroke-linecap="round"/><path d="M18.8 6.4l.55-1.25.55 1.25 1.25.55-1.25.55-.55 1.25-.55-1.25-1.25-.55z" fill="#fef08a"/></svg>',RTE_DefaultConfig.svgCode_aiassist='<svg viewBox="1.78 0.3 21.8 21.8" width="20" height="20" fill="none" aria-hidden="true"><defs><linearGradient id="rte-ai-bot-v5-shell" x1="3" y1="5" x2="21" y2="20" gradientUnits="userSpaceOnUse"><stop stop-color="#22d3ee"/><stop offset=".52" stop-color="#2563eb"/><stop offset="1" stop-color="#4338ca"/></linearGradient><linearGradient id="rte-ai-bot-v5-visor" x1="7" y1="8" x2="17" y2="15" gradientUnits="userSpaceOnUse"><stop stop-color="#f8fafc"/><stop offset="1" stop-color="#bfdbfe"/></linearGradient></defs><rect x="2.6" y="5.2" width="16.4" height="16" rx="4.8" fill="url(#rte-ai-bot-v5-shell)" stroke="#1e40af" stroke-width="1.6"/><rect x="5.9" y="9.1" width="9.8" height="6.8" rx="3.4" fill="url(#rte-ai-bot-v5-visor)"/><circle cx="8.6" cy="12.5" r="1.35" fill="#0f172a"/><circle cx="13" cy="12.5" r="1.35" fill="#0f172a"/><path d="M8.3 18.2c.9.7 1.8 1 2.5 1s1.6-.3 2.5-1" stroke="#eff6ff" stroke-width="1.7" stroke-linecap="round"/><path d="M19.6 .4l1.25 2.7 2.7 1.25-2.7 1.25-1.25 2.7-1.25-2.7-2.7-1.25 2.7-1.25z" fill="#fbbf24"/></svg>'),RTE_DefaultConfig.svgCode_aiassist_open_dialog||(RTE_DefaultConfig.svgCode_aiassist_open_dialog=RTE_DefaultConfig.svgCode_aiassist),RTE_DefaultConfig.svgCode_aiassist_review||(RTE_DefaultConfig.svgCode_aiassist_review='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5.5 6.5h13"/><path d="M5.5 11.5h8"/><path d="M5.5 16.5h6"/><path d="M16.5 14.2l1.8 1.8 3.2-4.2"/></svg>'),RTE_DefaultConfig.svgCode_aiassist_chat||(RTE_DefaultConfig.svgCode_aiassist_chat=RTE_DefaultConfig.svgCode_aiassist),RTE_DefaultConfig.svgCode_aiassist_proofread||(RTE_DefaultConfig.svgCode_aiassist_proofread='<svg viewBox="0 0 24 24" fill="none" stroke="#5F6368" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="10.5" cy="10.5" r="4.5"/><path d="M14 14l5 5"/><path d="M8.8 10.5l1.2 1.3 2.3-2.5"/></svg>'),RTE_DefaultConfig.svgCode_aiassist_rewrite||(RTE_DefaultConfig.svgCode_aiassist_rewrite='<svg viewBox="0 0 24 24" fill="none" stroke="#5F6368" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 7h11"/><path d="M4 12h8"/><path d="M4 17h11"/><path d="M16 5l4 4-6.5 6.5H9.5v-4z"/></svg>'),RTE_DefaultConfig.svgCode_aiassist_translate||(RTE_DefaultConfig.svgCode_aiassist_translate='<svg viewBox="0 0 24 24" fill="none" stroke="#5F6368" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4.5 6.5h10"/><path d="M8 4v2.5"/><path d="M11 6.5c-.6 2.9-2.2 5.3-4.7 7.1"/><path d="M6.5 10.5c1.2.9 2.5 1.6 3.9 2.1"/><path d="M14.5 9.5h5"/><path d="M17 7v2.5"/><path d="M15 19l2-4.5 2 4.5"/><path d="M15.8 17.2h2.4"/></svg>'),RTE_DefaultConfig.svgCode_aiassist_comment||(RTE_DefaultConfig.svgCode_aiassist_comment='<svg viewBox="0 0 24 24" fill="none" stroke="#5F6368" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 7.5A3.5 3.5 0 019.5 4h8A3.5 3.5 0 0121 7.5v5a3.5 3.5 0 01-3.5 3.5H12l-4.5 3v-3H6A3.5 3.5 0 012.5 12.5v-5A3.5 3.5 0 016 4"/><path d="M8 9h8"/><path d="M8 12h5"/></svg>'),RTE_DefaultConfig.svgCode_aiassist_paragraph||(RTE_DefaultConfig.svgCode_aiassist_paragraph='<svg viewBox="0 0 24 24" fill="none" stroke="#5F6368" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 7h8"/><path d="M5 12h14"/><path d="M5 17h10"/><path d="M18 5v6"/><path d="M15 8h6"/></svg>'),RTE_DefaultConfig.svgCode_aiassist_justify||(RTE_DefaultConfig.svgCode_aiassist_justify='<svg viewBox="0 0 24 24" fill="none" stroke="#5F6368" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 7h14"/><path d="M5 11h14"/><path d="M5 15h9"/><path d="M16 14l2 2 3-4"/></svg>'),RTE_DefaultConfig.plugin_aitoolkit=RTE_Plugin_AIToolkit;function RTE_Plugin_AIToolkit(){var Wa=this,k,s;Wa.PluginName="AIToolkit",Wa.InitConfig=function(e){k=e,k.aiToolkitEnabled!==!1&&(k.text_aiassist=k.text_aiassist||"Ask AI",k.text_aireview=k.text_aireview||"AI Review",k.text_aichat=k.text_aichat||"AI Chat",k.aiToolkitTranslateLanguages=k.aiToolkitTranslateLanguages||[{value:"spanish",label:"Spanish"},{value:"french",label:"French"},{value:"german",label:"German"},{value:"italian",label:"Italian"},{value:"portuguese",label:"Portuguese"},{value:"japanese",label:"Japanese"}],k.aiToolkitActions=k.aiToolkitActions||[{id:"chat-panel",section:"Start",icon:"chat",title:"Chat",description:"Ask follow-up questions about this document.",target:"chat-panel"},{id:"open-dialog",section:"Start",icon:"open_dialog",title:"Draft",description:"Generate, rewrite, translate, or summarize before applying.",target:"dialog"},{id:"review-panel",section:"Start",icon:"review",title:"Review",description:"Accept or reject prepared AI edits.",target:"review-panel"},{id:"proofread",section:"Quick edit",icon:"proofread",title:"Proofread",description:"Check grammar, spacing, and clarity.",resolverMode:"proofread",target:"selection-preview"},{id:"rewrite",section:"Quick edit",icon:"rewrite",title:"Rewrite",description:"Improve clarity without changing intent.",resolverMode:"rewrite",target:"selection-preview"},{id:"translate",section:"Quick edit",icon:"translate",title:"Translate",description:"Choose a language and preview the result.",resolverMode:"translate",target:"dialog",autoRun:!1},{id:"justify",section:"Quick edit",icon:"justify",title:"Explain",description:"Rewrite and show why it changed.",resolverMode:"justify",target:"dialog",autoRun:!1},{id:"comment",section:"Insert",icon:"comment",title:"Add note",description:"Insert a short comment near the selection.",resolverMode:"comment",target:"comment"},{id:"paragraph",section:"Insert",icon:"paragraph",title:"Add paragraph",description:"Draft a supporting paragraph below.",resolverMode:"paragraph",target:"insert"}],k.aiToolkitChatPrompts=k.aiToolkitChatPrompts||[{id:"summarize",label:"Summarize",prompt:"Summarize the current content and suggest the clearest next edit."},{id:"proofread",label:"Proofread",prompt:"Proofread the current content and prepare a cleaner version I can review."},{id:"translate",label:"Translate",prompt:"Translate the current content into Spanish and prepare a reviewable version."},{id:"headings",label:"Headings",prompt:"Suggest better section titles and subheadings for this content."},{id:"expand",label:"Expand",prompt:"Add a short supporting paragraph that strengthens this content."}],k.aiToolkitDialogModes=k.aiToolkitDialogModes||[{id:"proofread",title:"Proofread",description:"Fix grammar & clarity."},{id:"rewrite",title:"Rewrite",description:"Rewrite for clarity."},{id:"translate",title:"Translate",description:"Translate to a language."},{id:"justify",title:"Explain rewrite",description:"Rewrite and explain why."},{id:"shorten",title:"Shorten",description:"Compress to be shorter."},{id:"expand",title:"Expand",description:"Add supporting detail."},{id:"summarize",title:"Summarize",description:"Summarize the source."}],k.aiToolkitResolver=k.aiToolkitResolver||null,k.aiToolkitOperationHandlers=k.aiToolkitOperationHandlers||{},k.aiToolkitPersistenceKey=k.aiToolkitPersistenceKey||"",k.aiToolkitReviewSyncInterval=k.aiToolkitReviewSyncInterval||15e3,k.aiToolkitSuggestionLedgerUrl=k.aiToolkitSuggestionLedgerUrl||"",k.aiToolkitReviewLogUrl=k.aiToolkitReviewLogUrl||"",k.aiToolkitAutoToolbarButtons=k.aiToolkitAutoToolbarButtons!==!1,k.aiToolkitUiVersion=k.aiToolkitUiVersion||"v20260520k",Gr("toolbar_default","#{aiassist}"),Gr("toolbar_basic","#{aiassist}"),Gr("toolbar_full","#{aiassist}"),Gr("toolbar_mobile","#{aiassist}"),Kn("controltoolbar_TEXT","|{aiassist}"),k.toolbarfactory_aiassist=function(t,r,i){var a=this;return a.createToolbarItemDropDownPanel(t,function(l){Ac(l)})})},Wa.InitEditor=function(e){s=e,s.aiToolkit={normalizeText:R,ensureSentence:ur,buildDemoResult:Dt,getTranslateLanguages:fa,getTranslateLanguageLabel:lt,getOperationContract:Zl,getActionDefinitions:zn,registerAction:_u,removeAction:Lu,getDialogModes:Jn,registerDialogMode:Ru,removeDialogMode:Tu,resolveAction:function(n,u){return Ya(n,u)},loadSelectionText:function(){var n=st();return n.text||n.wholeText},loadDocumentText:function(){return R(s.getText?s.getText():"")},textToHtml:function(n){return en(n)},previewInlineSuggestion:function(n,u){return js(n,u)},applyResult:function(n,u){return hn(n,u)},executeOperations:function(n,u){return Sa(n,u)},executeResolvedAction:function(n,u){return dr(n,u)},registerOperationHandler:ku,unregisterOperationHandler:Cu,getSuggestions:function(){return Ue().slice()},clearSuggestions:function(){return ec()},getReviewLogEntries:function(){return Ui().slice()},setResolver:function(n){k.aiToolkitResolver=typeof n=="function"?n:null},openChatPanel:function(n){Yi(n)},closeChatPanel:function(){Xi({restoreFocus:!0})},toggleChatPanel:function(n){Zc(n)},getChatSessions:function(n){return Kc(n)},loadChatSession:function(n,u){return Nc(n,u)},clearChatSessions:function(n){return Qc(n)},openReviewPanel:function(n){qn(n)},closeReviewPanel:function(){Br()},toggleReviewPanel:function(n){uf(n)},saveSuggestionLedger:function(){return wt()},loadSuggestionLedger:function(){return gs()},loadRemoteSuggestionLedger:function(n,u){return hs(n,u)},loadReviewLogEntries:function(n,u){return ss(n,u)},refreshRemoteReviewState:function(n,u){return ni(n,u)},openDialog:function(n){na(n)},runQuickAction:function(n,u){return Ds(n,u)},setAgent:function(n){k.aiToolkitAgent=typeof n=="function"?n:null},runAgent:function(n,u){return Sc(n,u)},streamRequest:function(n){return vu(n)},exportDocx:function(n){return hu(n)},importDocx:function(n){return gu(n)}},Ho(),s.reviewLedger={add:function(n){var u=Uu(n);if(!u)return null;for(var c=Ue(),f=0;f<c.length;f++)if(c[f].id===u.id){c[f]=u;break}return f===c.length&&c.push(u),wt(),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&pe(!1),u},update:function(n,u){for(var c=Ue(),f=0;f<c.length;f++)if(c[f].id===n){for(var p in u)Object.prototype.hasOwnProperty.call(u,p)&&(c[f][p]=u[p]);return wt(),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&pe(!1),c[f]}return null},remove:function(n){for(var u=Ue(),c=0;c<u.length;c++)if(u[c].id===n)return u.splice(c,1),wt(),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&pe(!1),!0;return!1},get:function(n){for(var u=Ue(),c=0;c<u.length;c++)if(u[c].id===n)return u[c];return null},list:function(n){var u=Ue().slice();return n?u.filter(function(c){return!(n.author&&c.author&&c.author.id!==n.author||n.status&&c.status!==n.status||n.changeType&&c.changeType!==n.changeType)}):u},refreshPanel:function(){s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&pe(!1)}},s.attachEvent("exec_command_aiassist",function(n){n.returnValue=!0,n.stopBubble=!0,na()}),s.attachEvent("exec_command_aichat",function(n){n.returnValue=!0,n.stopBubble=!0,Yi({focusComposer:!0})});var t=s.getEditable(),r=t&&t.ownerDocument?t.ownerDocument:document;function i(n){if(!n.__rteAiInlinePreviewClickHandled){var u=n.target&&n.target.closest?n.target.closest("[data-rte-ai-suggestion-id]"):null;if(u){var c=u.getAttribute("data-rte-ai-suggestion-id");if(!(!c||!he(c))){n.__rteAiInlinePreviewClickHandled=!0;var f=n.target&&n.target.closest?n.target.closest("[data-rte-ai-action]"):null;if(!f){var p=F(),g=u.ownerDocument?u.ownerDocument.activeElement:null;if(g&&g.getAttribute&&s.getEditable().contains(g)&&(p=g.getAttribute("data-rte-ai-action")||p),s.__aiReviewEmptyPreviewSuggestionId&&c===s.__aiReviewEmptyPreviewSuggestionId){At(c,{focusPanel:!0,focusAction:p||F(),openedQueue:!0});return}if($e(c),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&pe(!1),fn(c,p))return;ma(u);return}n.preventDefault(),n.stopPropagation();var m=f.getAttribute("data-rte-ai-action"),b="",h=s.__aiActiveSuggestionId===c;(m==="accept"||m==="reject")&&h&&(b=ra(c)),m==="accept"?xa(c)&&(b?qt(b,{focusInlineAction:m}):h&&He(gn("Accepted",c))):m==="reject"?_a(c)&&(b?qt(b,{focusInlineAction:m}):h&&He(gn("Rejected",c))):m==="review"?At(c,{focusPanel:!0}):m==="previous"?Go(c,{focusInlineAction:m})||He(Yt(c,"previous")):m==="next"?Uo(c,{focusInlineAction:m})||He(Yt(c,"next")):m==="shared-seen"?(Yn(),Qi(),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&pe(!1),He("Shared AI review updates cleared for the current item."),ma(u)):m==="undo"?Tr({focusInlineAction:"undo"}):m==="redo"&&zr({focusInlineAction:"redo"})}}}}function a(){t=s.getEditable?s.getEditable():null,r=t&&t.ownerDocument?t.ownerDocument:document,t&&s.__aiInlinePreviewEventEditable!==t&&(t.addEventListener("click",i),t.addEventListener("keydown",l),s.__aiInlinePreviewEventEditable=t),r&&s.__aiInlinePreviewEventDocument!==r&&(r.addEventListener("click",i,!0),r.addEventListener("keydown",l,!0),s.__aiInlinePreviewEventDocument=r)}function l(n){if(!n.__rteAiInlinePreviewKeydownHandled){var u=n.target&&n.target.closest?n.target.closest(".rte-ai-inline-preview"):n.target&&n.target.classList&&n.target.classList.contains("rte-ai-inline-preview")?n.target:null;if(u){var c=n.target&&n.target.closest?n.target.closest("[data-rte-ai-action]"):null,f=u.getAttribute("data-rte-ai-suggestion-id");if(!(!f||!he(f)||n.ctrlKey||n.metaKey||n.altKey)){n.__rteAiInlinePreviewKeydownHandled=!0;var p=(n.key||"").toLowerCase(),g=c&&c.getAttribute&&c.getAttribute("data-rte-ai-action")||"",m=g||al(he(f)),b=!!(s.__aiReviewEmptyPreviewSuggestionId&&f===s.__aiReviewEmptyPreviewSuggestionId);if(b){(p==="enter"||p===" ")&&(n.preventDefault(),At(f,{focusPanel:!0,focusAction:g||F(),openedQueue:!0}));return}if(p==="arrowleft"||p==="k")n.preventDefault(),Go(f,{focusInlineAction:g})||He(Yt(f,"previous"));else if(p==="arrowright"||p==="j")n.preventDefault(),Uo(f,{focusInlineAction:g})||He(Yt(f,"next"));else if(p==="home")n.preventDefault(),Fd(f,{focusInlineAction:g})||He(Yt(f,"first"));else if(p==="end")n.preventDefault(),Kd(f,{focusInlineAction:g})||He(Yt(f,"last"));else if(p==="a"){n.preventDefault();var h=ra(f);xa(f)&&(h?qt(h,{focusInlineAction:g}):He(gn("Accepted",f)))}else if(p==="r"){n.preventDefault();var y=ra(f);_a(f)&&(y?qt(y,{focusInlineAction:g}):He(gn("Rejected",f)))}else if(p==="u"&&!n.shiftKey&&tr())n.preventDefault(),Tr({focusInlineAction:m||"accept"});else if(p==="u"&&n.shiftKey){var A=Rr();A&&A.suggestion&&A.suggestion.id===f&&(n.preventDefault(),zr({focusInlineAction:m||"accept"}))}else if(p==="g")Qt(f)&&(n.preventDefault(),Yn(),Qi(),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&pe(!1),He("Shared AI review updates cleared for the current item."),ma(u));else if(p==="enter"||p===" "){if(c)return;n.preventDefault(),fn(f,g||F())}}}}}s.__aiBindInlinePreviewEventHandlers=a,a(),gs(),ni(!1),Zu(),Yu()};var Fn={toolbar_default:"{bold,italic,underline,forecolor,backcolor}|{justifyleft,justifycenter,justifyright,justifyfull}|{insertorderedlist,insertunorderedlist,indent,outdent,insertblockquote,insertemoji}|{aiassist}#{toggleborder,fullscreenenter,fullscreenexit,undo,redo,togglemore}",toolbar_mobile:"{bold,italic,underline|fontname:toggle,fontsize:toggle,menu_paragraphop|forecolor,backcolor}{insertlink,insertemoji,inserttable,insertimage,removeformat}|{aiassist}#{toggleborder,fullscreenenter,fullscreenexit,undo,redo,togglemore}",toolbar_basic:"{bold,italic,underline}|{fontname,fontsize}|{insertlink,insertemoji,insertimage,insertvideo}|removeformat|code#{toggleborder,fullscreenenter,fullscreenexit,undo,redo,togglemore}",toolbar_full:"{bold,italic,underline,forecolor,backcolor}|{justifyleft,justifycenter,justifyright,justifyfull}|{insertorderedlist,insertunorderedlist,indent,outdent}{superscript,subscript}|{insertlink,insertimage,insertvideo,inserttable,insertemoji,find,code,html2pdf}|{aiassist_chat,aiassist_review}|{insertcomment,trackchanges}#{insertmergefield,insertfootnote,inserttoc,insertpagebreak,revisionhistory,newdoc,save,toggleborder,fullscreenenter,fullscreenexit,undo,redo,togglemore}",controltoolbar_TEXT:"removeformat | {bold,italic,underline,forecolor,backcolor}|{fontname:toggle,fontsize:toggle}|{insertlink}"};function Di(e){return String(e||"").replace(/\s+/g,"")}function Oi(e){if(k.aiToolkitAutoToolbarButtons===!1)return!1;var t=k[e];if(!t)return!0;var r=Fn[e];return r?Di(t)===Di(r):!0}function Gr(e,t){var r=k[e]||"";r.indexOf("aiassist")===-1&&Oi(e)&&(k[e]=r?r+" "+t:t)}function Kn(e,t){var r=k[e]||"";r.indexOf("aiassist")===-1&&Oi(e)&&(k[e]=r?r+t:t)}function o(e,t,r,i,a){var l=e.ownerDocument.createElement(t);return r&&(l.style.cssText=r),i&&(l.className=i),typeof a<"u"&&(l.innerText=a),e.appendChild(l),l}function _r(e,t,r){var i=o(e,"div","",t,r);return i.setAttribute("aria-hidden","true"),i}function $a(){return"data:image/svg+xml;utf8,"+encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 240" role="img" aria-label="Editorial workspace photo"><defs><linearGradient id="ai-photo-sky" x1="0" y1="0" x2="1" y2="1"><stop offset="0%" stop-color="#e0f2fe"/><stop offset="52%" stop-color="#bfdbfe"/><stop offset="100%" stop-color="#ddd6fe"/></linearGradient><linearGradient id="ai-photo-desk" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#fef3c7"/><stop offset="100%" stop-color="#fdba74"/></linearGradient><filter id="ai-photo-blur" x="-20%" y="-20%" width="140%" height="140%"><feGaussianBlur stdDeviation="14"/></filter></defs><rect width="320" height="240" rx="28" fill="url(#ai-photo-sky)"/><circle cx="248" cy="52" r="40" fill="#ffffff" opacity=".55"/><circle cx="76" cy="44" r="34" fill="#fdf2f8" opacity=".65"/><path d="M0 174C37 155 68 151 99 162c24 9 47 23 75 17 20-4 31-17 51-23 28-7 54 6 95 18v66H0z" fill="#86efac" opacity=".92"/><path d="M0 188c34-24 66-27 100-15 32 12 63 26 95 17 23-6 44-24 66-26 22-2 39 7 59 18v48H0z" fill="#60a5fa" opacity=".3"/><g filter="url(#ai-photo-blur)" opacity=".34"><circle cx="248" cy="154" r="54" fill="#1d4ed8"/><circle cx="92" cy="134" r="48" fill="#7c3aed"/></g><rect x="74" y="72" width="172" height="110" rx="14" fill="#f8fafc" opacity=".95"/><rect x="88" y="86" width="144" height="14" rx="7" fill="#cbd5e1"/><rect x="88" y="110" width="118" height="10" rx="5" fill="#dbeafe"/><rect x="88" y="128" width="128" height="10" rx="5" fill="#dbeafe"/><rect x="88" y="146" width="82" height="10" rx="5" fill="#e9d5ff"/><rect x="198" y="138" width="34" height="28" rx="10" fill="url(#ai-photo-desk)"/><rect x="54" y="183" width="212" height="32" rx="16" fill="#ffffff" opacity=".68"/></svg>')}function Ur(){return'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 140" role="img" aria-hidden="true" focusable="false"><defs><linearGradient id="ai-illus-doc" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#ffffff"/><stop offset="100%" stop-color="#f1f5fb"/></linearGradient><linearGradient id="ai-illus-bubble" x1="0" y1="0" x2="1" y2="1"><stop offset="0%" stop-color="#3b82f6"/><stop offset="100%" stop-color="#6366f1"/></linearGradient><linearGradient id="ai-illus-sparkle" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#fbbf24"/><stop offset="100%" stop-color="#f59e0b"/></linearGradient></defs><ellipse cx="100" cy="118" rx="68" ry="8" fill="#0f172a" opacity="0.08"/><rect x="44" y="34" width="92" height="78" rx="10" fill="#cbd5e1" opacity="0.45" transform="translate(2,3)"/><rect x="44" y="34" width="92" height="78" rx="10" fill="url(#ai-illus-doc)" stroke="#cbd5e1" stroke-width="1"/><rect x="56" y="54" width="60" height="6" rx="3" fill="#dbeafe"/><rect x="56" y="66" width="68" height="5" rx="2.5" fill="#e2e8f0"/><rect x="56" y="76" width="52" height="5" rx="2.5" fill="#e2e8f0"/><rect x="56" y="90" width="44" height="5" rx="2.5" fill="#ede9fe"/><g><path d="M118 22 H162 a10 10 0 0 1 10 10 v22 a10 10 0 0 1 -10 10 H140 l-9 8 v-8 H118 a10 10 0 0 1 -10 -10 V32 a10 10 0 0 1 10 -10 z" fill="url(#ai-illus-bubble)"/><circle cx="128" cy="42" r="2.6" fill="#ffffff"/><circle cx="140" cy="42" r="2.6" fill="#ffffff"/><circle cx="152" cy="42" r="2.6" fill="#ffffff"/></g><g fill="url(#ai-illus-sparkle)"><path d="M36 28 l2 6 6 2 -6 2 -2 6 -2 -6 -6 -2 6 -2 z"/><path d="M168 88 l1.6 4.8 4.8 1.6 -4.8 1.6 -1.6 4.8 -1.6 -4.8 -4.8 -1.6 4.8 -1.6 z"/><path d="M30 92 l1.2 3.6 3.6 1.2 -3.6 1.2 -1.2 3.6 -1.2 -3.6 -3.6 -1.2 3.6 -1.2 z"/></g></svg>'}function Si(e,t){var r=o(e,"div","","rte-ai-hero"+(t?" is-"+t:"")),i=o(r,"div","","rte-ai-hero-media"),a=o(i,"img","","rte-ai-hero-image");a.alt="Styled editorial workspace preview",a.src=$a(),a.loading="eager",a.decoding="async";var l=o(r,"div","","rte-ai-hero-body");return o(l,"div","","rte-ai-hero-kicker",t==="dialog"?"Guided AI flow":"Beautiful drafting"),o(l,"div","","rte-ai-hero-title",t==="dialog"?"Review the change before it lands":"Shape the document with a calmer AI workspace"),o(l,"div","","rte-ai-hero-copy",t==="dialog"?"Load source text, compare the result, and apply only the version that improves the draft.":"Keep context visible, ask for help in smaller steps, and make each suggestion feel intentional."),r}function Nn(e,t,r){var i=o(e,"div","",t);return r&&i.setAttribute("data-rte-ai-review-group-label",r),o(i,"div","","rte-ai-review-control-group-body")}function xi(e,t,r){var i=o(e,"div","",t);return r&&o(i,"div","","rte-ai-review-header-group-label",r),o(i,"div","","rte-ai-review-header-group-body")}function fu(e){if(!e)return k.svgCode_aiassist||"";var t=e.icon||e.id||"open_dialog";return k["svgCode_aiassist_"+t]||k.svgCode_aiassist||""}function vu(e){e=e||{};var t=e.url||"/richtextbox/ai/stream",r=e.body||{},i=typeof AbortController<"u"?new AbortController:null,a="",l=(function(){return typeof fetch!="function"||typeof ReadableStream>"u"?pu(t,r,e):fetch(t,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify(r),signal:i?i.signal:void 0,credentials:"same-origin"}).then(function(n){if(!n.ok)throw new Error("AI stream failed: HTTP "+n.status);if(!n.body||typeof n.body.getReader!="function")return n.text().then(function(m){return e.onDelta&&e.onDelta(m),a=m,e.onDone&&e.onDone(a),a});var u=n.body.getReader(),c=new TextDecoder("utf-8"),f="";function p(){return u.read().then(function(m){if(m.done)return e.onDone&&e.onDone(a),a;f+=c.decode(m.value,{stream:!0});for(var b;(b=f.indexOf(`
|
|
1
|
+
window.RTE_DefaultConfig||(window.RTE_DefaultConfig={}),(function(){if(typeof document>"u"||window.RTE_DefaultConfig&&window.RTE_DefaultConfig.aitoolkit_skip_auto_css)return;for(var L=document.querySelectorAll("link[rel=stylesheet]"),s=0;s<L.length;s++){var Jn=L[s].getAttribute("href")||"";if(/(?:^|\/)aitoolkit(?:\.min)?\.css(?:\?.*)?$/i.test(Jn))return}for(var Ui=null,Fi=document.getElementsByTagName("script"),Ur=Fi.length-1;Ur>=0;Ur--){var Vn=Fi[Ur].getAttribute("src")||"";if(/(?:^|\/)(?:aitoolkit|all_plugins)(?:\.min)?\.js(?:[?#].*)?$/i.test(Vn)){Ui=Fi[Ur];break}}var pa=Ui?Ui.getAttribute("src"):"";function ha(si){if(pa)return pa.replace(/[?#].*$/,"").replace(/[^/]+$/,si);var is=typeof RichTextEditor<"u"&&RichTextEditor.__scriptBase||window.RTE_DefaultConfig&&window.RTE_DefaultConfig.url_base||"/richtexteditor";return is+"/plugins/"+si}function o(si){return si.indexOf("?")<0?si+"?v=20261018a":si}var Et=document.createElement("link");Et.rel="stylesheet",Et.href=o(ha("aitoolkit.min.css")),Et.setAttribute("data-rte-auto-injected","aitoolkit"),Et.onerror=function(){Et.getAttribute("data-rte-css-fallback")||(Et.setAttribute("data-rte-css-fallback","1"),Et.href=o(ha("aitoolkit.css")))},(document.head||document.documentElement).appendChild(Et)})(),RTE_DefaultConfig.svgCode_aiassist||(RTE_DefaultConfig.svgCode_aiassist='<svg viewBox="0 0 24 24" width="20" height="20" fill="none" aria-hidden="true"><defs><linearGradient id="rte-ai-robot-shell" x1="5" y1="6" x2="19" y2="18" gradientUnits="userSpaceOnUse"><stop stop-color="#1fb6ff"/><stop offset=".52" stop-color="#2563eb"/><stop offset="1" stop-color="#7c3aed"/></linearGradient><linearGradient id="rte-ai-robot-glow" x1="8" y1="10" x2="16" y2="15" gradientUnits="userSpaceOnUse"><stop stop-color="#fef9c3"/><stop offset="1" stop-color="#fde68a"/></linearGradient></defs><path d="M12 2.4v2.4" stroke="#f59e0b" stroke-width="1.7" stroke-linecap="round"/><circle cx="12" cy="2.4" r="1" fill="#fbbf24"/><rect x="5.1" y="6.1" width="13.8" height="11.2" rx="3.4" fill="url(#rte-ai-robot-shell)" stroke="#1e40af" stroke-width="1.2"/><path d="M8.2 6.1V5.8A1.8 1.8 0 0110 4h4a1.8 1.8 0 011.8 1.8v.3" stroke="#93c5fd" stroke-width="1.2" stroke-linecap="round"/><rect x="7.7" y="9.2" width="8.6" height="4.8" rx="2.4" fill="#0f172a" opacity=".26"/><circle cx="10" cy="11.6" r="1.15" fill="url(#rte-ai-robot-glow)"/><circle cx="14" cy="11.6" r="1.15" fill="url(#rte-ai-robot-glow)"/><path d="M9.4 14.9c.8.55 1.66.83 2.6.83s1.8-.28 2.6-.83" stroke="#ffffff" stroke-width="1.45" stroke-linecap="round"/><path d="M8.1 19.2l1-2.1M15.9 19.2l-1-2.1" stroke="#2563eb" stroke-width="1.5" stroke-linecap="round"/><path d="M18.8 6.4l.55-1.25.55 1.25 1.25.55-1.25.55-.55 1.25-.55-1.25-1.25-.55z" fill="#fef08a"/></svg>',RTE_DefaultConfig.svgCode_aiassist='<svg viewBox="1.78 0.3 21.8 21.8" width="20" height="20" fill="none" aria-hidden="true"><defs><linearGradient id="rte-ai-bot-v5-shell" x1="3" y1="5" x2="21" y2="20" gradientUnits="userSpaceOnUse"><stop stop-color="#22d3ee"/><stop offset=".52" stop-color="#2563eb"/><stop offset="1" stop-color="#4338ca"/></linearGradient><linearGradient id="rte-ai-bot-v5-visor" x1="7" y1="8" x2="17" y2="15" gradientUnits="userSpaceOnUse"><stop stop-color="#f8fafc"/><stop offset="1" stop-color="#bfdbfe"/></linearGradient></defs><rect x="2.6" y="5.2" width="16.4" height="16" rx="4.8" fill="url(#rte-ai-bot-v5-shell)" stroke="#1e40af" stroke-width="1.6"/><rect x="5.9" y="9.1" width="9.8" height="6.8" rx="3.4" fill="url(#rte-ai-bot-v5-visor)"/><circle cx="8.6" cy="12.5" r="1.35" fill="#0f172a"/><circle cx="13" cy="12.5" r="1.35" fill="#0f172a"/><path d="M8.3 18.2c.9.7 1.8 1 2.5 1s1.6-.3 2.5-1" stroke="#eff6ff" stroke-width="1.7" stroke-linecap="round"/><path d="M19.6 .4l1.25 2.7 2.7 1.25-2.7 1.25-1.25 2.7-1.25-2.7-2.7-1.25 2.7-1.25z" fill="#fbbf24"/></svg>'),RTE_DefaultConfig.svgCode_aiassist_open_dialog||(RTE_DefaultConfig.svgCode_aiassist_open_dialog=RTE_DefaultConfig.svgCode_aiassist),RTE_DefaultConfig.svgCode_aiassist_review||(RTE_DefaultConfig.svgCode_aiassist_review='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5.5 6.5h13"/><path d="M5.5 11.5h8"/><path d="M5.5 16.5h6"/><path d="M16.5 14.2l1.8 1.8 3.2-4.2"/></svg>'),RTE_DefaultConfig.svgCode_aiassist_chat||(RTE_DefaultConfig.svgCode_aiassist_chat=RTE_DefaultConfig.svgCode_aiassist),RTE_DefaultConfig.svgCode_aiassist_proofread||(RTE_DefaultConfig.svgCode_aiassist_proofread='<svg viewBox="0 0 24 24" fill="none" stroke="#5F6368" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="10.5" cy="10.5" r="4.5"/><path d="M14 14l5 5"/><path d="M8.8 10.5l1.2 1.3 2.3-2.5"/></svg>'),RTE_DefaultConfig.svgCode_aiassist_rewrite||(RTE_DefaultConfig.svgCode_aiassist_rewrite='<svg viewBox="0 0 24 24" fill="none" stroke="#5F6368" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 7h11"/><path d="M4 12h8"/><path d="M4 17h11"/><path d="M16 5l4 4-6.5 6.5H9.5v-4z"/></svg>'),RTE_DefaultConfig.svgCode_aiassist_translate||(RTE_DefaultConfig.svgCode_aiassist_translate='<svg viewBox="0 0 24 24" fill="none" stroke="#5F6368" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4.5 6.5h10"/><path d="M8 4v2.5"/><path d="M11 6.5c-.6 2.9-2.2 5.3-4.7 7.1"/><path d="M6.5 10.5c1.2.9 2.5 1.6 3.9 2.1"/><path d="M14.5 9.5h5"/><path d="M17 7v2.5"/><path d="M15 19l2-4.5 2 4.5"/><path d="M15.8 17.2h2.4"/></svg>'),RTE_DefaultConfig.svgCode_aiassist_comment||(RTE_DefaultConfig.svgCode_aiassist_comment='<svg viewBox="0 0 24 24" fill="none" stroke="#5F6368" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 7.5A3.5 3.5 0 019.5 4h8A3.5 3.5 0 0121 7.5v5a3.5 3.5 0 01-3.5 3.5H12l-4.5 3v-3H6A3.5 3.5 0 012.5 12.5v-5A3.5 3.5 0 016 4"/><path d="M8 9h8"/><path d="M8 12h5"/></svg>'),RTE_DefaultConfig.svgCode_aiassist_paragraph||(RTE_DefaultConfig.svgCode_aiassist_paragraph='<svg viewBox="0 0 24 24" fill="none" stroke="#5F6368" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 7h8"/><path d="M5 12h14"/><path d="M5 17h10"/><path d="M18 5v6"/><path d="M15 8h6"/></svg>'),RTE_DefaultConfig.svgCode_aiassist_justify||(RTE_DefaultConfig.svgCode_aiassist_justify='<svg viewBox="0 0 24 24" fill="none" stroke="#5F6368" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 7h14"/><path d="M5 11h14"/><path d="M5 15h9"/><path d="M16 14l2 2 3-4"/></svg>'),RTE_DefaultConfig.plugin_aitoolkit=RTE_Plugin_AIToolkit;function RTE_Plugin_AIToolkit(){var c=this,L,s;c.PluginName="AIToolkit",c.InitConfig=function(e){if(L=e,L.aiToolkitEnabled===!1)return;L.text_aiassist=L.text_aiassist||"Ask AI",L.text_aireview=L.text_aireview||"AI Review",L.text_aichat=L.text_aichat||"AI Chat",L.aiToolkitTranslateLanguages=L.aiToolkitTranslateLanguages||[{value:"spanish",label:"Spanish"},{value:"french",label:"French"},{value:"german",label:"German"},{value:"italian",label:"Italian"},{value:"portuguese",label:"Portuguese"},{value:"japanese",label:"Japanese"}],L.aiToolkitActions=L.aiToolkitActions||[{id:"chat-panel",section:t("aia_sec_start","Start"),icon:"chat",title:t("aia_chat_panel_t","Chat"),description:t("aia_chat_panel_d","Ask follow-up questions about this document."),target:"chat-panel"},{id:"open-dialog",section:t("aia_sec_start","Start"),icon:"open_dialog",title:t("aia_open_dialog_t","Draft"),description:t("aia_open_dialog_d","Generate, rewrite, translate, or summarize before applying."),target:"dialog"},{id:"review-panel",section:t("aia_sec_start","Start"),icon:"review",title:t("aia_review_panel_t","Review"),description:t("aia_review_panel_d","Accept or reject prepared AI edits."),target:"review-panel"},{id:"proofread",section:t("aia_sec_quick","Quick edit"),icon:"proofread",title:t("aia_proofread_t","Proofread"),description:t("aia_proofread_d","Check grammar, spacing, and clarity."),resolverMode:"proofread",target:"selection-preview"},{id:"rewrite",section:t("aia_sec_quick","Quick edit"),icon:"rewrite",title:t("aia_rewrite_t","Rewrite"),description:t("aia_rewrite_d","Improve clarity without changing intent."),resolverMode:"rewrite",target:"selection-preview"},{id:"translate",section:t("aia_sec_quick","Quick edit"),icon:"translate",title:t("aia_translate_t","Translate"),description:t("aia_translate_d","Choose a language and preview the result."),resolverMode:"translate",target:"dialog",autoRun:!1},{id:"justify",section:t("aia_sec_quick","Quick edit"),icon:"justify",title:t("aia_justify_t","Explain"),description:t("aia_justify_d","Rewrite and show why it changed."),resolverMode:"justify",target:"dialog",autoRun:!1},{id:"comment",section:t("aia_sec_insert","Insert"),icon:"comment",title:t("aia_comment_t","Add note"),description:t("aia_comment_d","Insert a short comment near the selection."),resolverMode:"comment",target:"comment"},{id:"paragraph",section:t("aia_sec_insert","Insert"),icon:"paragraph",title:t("aia_paragraph_t","Add paragraph"),description:t("aia_paragraph_d","Draft a supporting paragraph below."),resolverMode:"paragraph",target:"insert"}],L.aiToolkitChatPrompts=L.aiToolkitChatPrompts||[{id:"summarize",label:t("aip_summarize","Summarize"),prompt:"Summarize the current content and suggest the clearest next edit."},{id:"proofread",label:t("aip_proofread","Proofread"),prompt:"Proofread the current content and prepare a cleaner version I can review."},{id:"translate",label:t("aip_translate","Translate"),prompt:"Translate the current content into Spanish and prepare a reviewable version."},{id:"headings",label:t("aip_headings","Headings"),prompt:"Suggest better section titles and subheadings for this content."},{id:"expand",label:t("aip_expand","Expand"),prompt:"Add a short supporting paragraph that strengthens this content."}];function t(r,i,a){var n=L&&L["text_"+r]||i;return a===void 0?n:n.split("{0}").join(String(a))}c.__aiT=t,L.aiToolkitDialogModes=L.aiToolkitDialogModes||[{id:"proofread",title:t("aim_proofread_t","Proofread"),description:t("aim_proofread_d","Fix grammar & clarity.")},{id:"rewrite",title:t("aim_rewrite_t","Rewrite"),description:t("aim_rewrite_d","Rewrite for clarity.")},{id:"translate",title:t("aim_translate_t","Translate"),description:t("aim_translate_d","Translate to a language.")},{id:"justify",title:t("aim_justify_t","Explain rewrite"),description:t("aim_justify_d","Rewrite and explain why.")},{id:"shorten",title:t("aim_shorten_t","Shorten"),description:t("aim_shorten_d","Compress to be shorter.")},{id:"expand",title:t("aim_expand_t","Expand"),description:t("aim_expand_d","Add supporting detail.")},{id:"summarize",title:t("aim_summarize_t","Summarize"),description:t("aim_summarize_d","Summarize the source.")}],L.aiToolkitResolver=L.aiToolkitResolver||null,L.aiToolkitImageResolver=L.aiToolkitImageResolver||null,L.aiToolkitOperationHandlers=L.aiToolkitOperationHandlers||{},L.aiToolkitPersistenceKey=L.aiToolkitPersistenceKey||"",L.aiToolkitReviewSyncInterval=L.aiToolkitReviewSyncInterval||15e3,L.aiToolkitSuggestionLedgerUrl=L.aiToolkitSuggestionLedgerUrl||"",L.aiToolkitReviewLogUrl=L.aiToolkitReviewLogUrl||"",L.aiToolkitAutoToolbarButtons=L.aiToolkitAutoToolbarButtons!==!1,L.aiToolkitUiVersion=L.aiToolkitUiVersion||"v20260520k",Ur("toolbar_default","#{aiassist}"),Ur("toolbar_basic","#{aiassist}"),Ur("toolbar_full","#{aiassist}"),Ur("toolbar_mobile","#{aiassist}"),Vn("controltoolbar_TEXT","|{aiassist}"),L.toolbarfactory_aiassist=function(r,i,a){var n=this;return n.createToolbarItemDropDownPanel(r,function(l){Jc(l)})}},c.InitEditor=function(e){s=e;var t=6e6;function r(v){var h=typeof v=="string"?v.replace(/^\s+|\s+$/g,""):"";if(!h)throw new Error("The image generator returned no image.");if(h.length>t)throw new Error("The generated image is too large to insert.");if(/^data:image\/(png|jpe?g|webp|gif);base64,[A-Za-z0-9+\/=]+$/i.test(h)||/^https:\/\/[^\s"'<>]+$/i.test(h))return h;throw new Error("The image generator returned something that is not an image address.")}function i(v){var h=String(v||"").replace(/^\s+|\s+$/g,"");if(!h)return Promise.reject(new Error("Describe the image first."));var _=L.aiToolkitImageResolver;return typeof _!="function"?Promise.reject(new Error("No image generator is configured (config.aiToolkitImageResolver).")):Promise.resolve().then(function(){return _(h)}).then(r)}function a(v,h){s.insertHTML('<img src="'+Qr(v)+'" alt="'+Qr(h||"")+'">');try{typeof s.fireChange=="function"&&s.fireChange()}catch{}}var n=null;function l(){var v=!1;try{v=!!(n&&n.contains(n.ownerDocument.activeElement))}catch{}if(n&&n.parentNode&&n.parentNode.removeChild(n),n=null,v)try{s.focus()}catch{}}function u(){l();var v=s.iframe;if(!(!v||!v.ownerDocument)){var h=v.ownerDocument,_=h.createElement("div");_.className="rte-image-gen",_.setAttribute("role","dialog"),_.setAttribute("aria-label",c.__aiT?c.__aiT("aig_title","Generate an image"):"Generate an image");var b=_.style;b.position="fixed",b.zIndex="2147483000",b.width="320px",b.padding="12px",b.background="#fff",b.border="1px solid rgba(0,0,0,.15)",b.borderRadius="8px",b.boxShadow="0 8px 24px rgba(15,23,42,.18)",b.font="13px/1.4 system-ui, sans-serif",b.color="#1f2937";var H=v.getBoundingClientRect();b.left=Math.round(H.left+16)+"px",b.top=Math.round(H.top+16)+"px";var x=h.createElement("label");x.textContent=c.__aiT?c.__aiT("aig_describe","Describe the image"):"Describe the image",x.style.display="block",x.style.marginBottom="6px";var R=h.createElement("textarea");R.rows=3,R.setAttribute("aria-label",c.__aiT?c.__aiT("aig_describe","Describe the image"):"Describe the image"),R.style.width="100%",R.style.boxSizing="border-box",R.style.font="inherit";var C=h.createElement("div");C.className="rte-image-gen-status",C.setAttribute("aria-live","polite"),C.style.minHeight="18px",C.style.margin="6px 0",C.style.color="#b91c1c";var P=h.createElement("div");P.style.textAlign="right";var T=h.createElement("button");T.type="button",T.className="rte-image-gen-cancel",T.textContent=c.__aiT?c.__aiT("aig_cancel","Cancel"):"Cancel",T.style.marginRight="6px";var D=h.createElement("button");D.type="button",D.className="rte-image-gen-go",D.textContent=c.__aiT?c.__aiT("aig_generate","Generate"):"Generate",D.style.background="#1d67ba",D.style.color="#fff",D.style.border="0",D.style.borderRadius="4px",D.style.padding="4px 12px",D.addEventListener("click",function(){var F=R.value.replace(/^\s+|\s+$/g,"");if(!F){C.textContent=c.__aiT?c.__aiT("aig_describefirst","Describe the image first."):"Describe the image first.";return}D.disabled=!0,C.style.color="#475569",C.textContent=c.__aiT?c.__aiT("aig_generating","Generating..."):"Generating...",i(F).then(function(M){a(M,F),l();try{s.focus()}catch{}},function(M){D.disabled=!1,C.style.color="#b91c1c",C.textContent=M&&M.message||(c.__aiT?c.__aiT("aig_failed","The image could not be generated."):"The image could not be generated.")})}),T.addEventListener("click",l),_.addEventListener("keydown",function(F){(F.key==="Escape"||F.key==="Esc")&&(F.preventDefault(),l())}),P.appendChild(T),P.appendChild(D),_.appendChild(x),_.appendChild(R),_.appendChild(C),_.appendChild(P),h.body.appendChild(_),n=_;try{R.focus()}catch{}}}s.generateImage=function(v){return i(v).then(function(h){return a(h,v),!0})},s.openImageGenerator=function(){u()},s.aiToolkit={generateImage:i,setImageResolver:function(v){L.aiToolkitImageResolver=typeof v=="function"?v:null},normalizeText:E,ensureSentence:Fr,buildDemoResult:Ut,isDemoMode:pa,getTranslateLanguages:ga,getTranslateLanguageLabel:ot,getOperationContract:ms,getActionDefinitions:tl,registerAction:Wu,removeAction:Bu,getDialogModes:rl,registerDialogMode:Xu,removeDialogMode:Yu,resolveAction:function(v,h){return an(v,h)},loadSelectionText:function(){var v=ut();return v.text||v.wholeText},loadDocumentText:function(){return E(s.getText?s.getText():"")},textToHtml:function(v){return ln(v)},previewInlineSuggestion:function(v,h){return eo(v,h)},applyResult:function(v,h){return An(v,h)},executeOperations:function(v,h){return La(v,h)},executeResolvedAction:function(v,h){return vr(v,h)},registerOperationHandler:Zu,unregisterOperationHandler:ec,getSuggestions:function(){return Ne().slice()},clearSuggestions:function(){return Tc()},getReviewLogEntries:function(){return Ni().slice()},setResolver:function(v){L.aiToolkitResolver=typeof v=="function"?v:null},openChatPanel:function(v){ea(v)},closeChatPanel:function(){Zi({restoreFocus:!0})},toggleChatPanel:function(v){Td(v)},getChatSessions:function(v){return pd(v)},loadChatSession:function(v,h){return hd(v,h)},clearChatSessions:function(v){return gd(v)},openReviewPanel:function(v){Gn(v)},closeReviewPanel:function(){Yr()},toggleReviewPanel:function(v){Hf(v)},saveSuggestionLedger:function(){return yt()},loadSuggestionLedger:function(){return Ms()},loadRemoteSuggestionLedger:function(v,h){return Is(v,h)},loadReviewLogEntries:function(v,h){return Ts(v,h)},refreshRemoteReviewState:function(v,h){return ui(v,h)},openDialog:function(v){sa(v)},runQuickAction:function(v,h){return to(v,h)},setAgent:function(v){L.aiToolkitAgent=typeof v=="function"?v:null},runAgent:function(v,h){return Vc(v,h)},streamRequest:function(v){return Iu(v)},exportDocx:function(v){return Hu(v)},importDocx:function(v){return Du(v)}},tu(),s.reviewLedger={add:function(v){var h=dc(v);if(!h)return null;for(var _=Ne(),b=0;b<_.length;b++)if(_[b].id===h.id){_[b]=h;break}return b===_.length&&_.push(h),yt(),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&ge(!1),h},update:function(v,h){for(var _=Ne(),b=0;b<_.length;b++)if(_[b].id===v){for(var H in h)Object.prototype.hasOwnProperty.call(h,H)&&(_[b][H]=h[H]);return yt(),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&ge(!1),_[b]}return null},remove:function(v){for(var h=Ne(),_=0;_<h.length;_++)if(h[_].id===v)return h.splice(_,1),yt(),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&ge(!1),!0;return!1},get:function(v){for(var h=Ne(),_=0;_<h.length;_++)if(h[_].id===v)return h[_];return null},list:function(v){var h=Ne().slice();return v?h.filter(function(_){return!(v.author&&_.author&&_.author.id!==v.author||v.status&&_.status!==v.status||v.changeType&&_.changeType!==v.changeType)}):h},refreshPanel:function(){s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&ge(!1)}},s.attachEvent("exec_command_aiassist",function(v){v.returnValue=!0,v.stopBubble=!0,sa()}),s.attachEvent("exec_command_aichat",function(v){v.returnValue=!0,v.stopBubble=!0,ea({focusComposer:!0})});var d=s.getEditable(),p=d&&d.ownerDocument?d.ownerDocument:document;function m(v){if(!v.__rteAiInlinePreviewClickHandled){var h=v.target&&v.target.closest?v.target.closest("[data-rte-ai-suggestion-id]"):null;if(h){var _=h.getAttribute("data-rte-ai-suggestion-id");if(!(!_||!me(_))){v.__rteAiInlinePreviewClickHandled=!0;var b=v.target&&v.target.closest?v.target.closest("[data-rte-ai-action]"):null;if(!b){var H=z(),x=h.ownerDocument?h.ownerDocument.activeElement:null;if(x&&x.getAttribute&&s.getEditable().contains(x)&&(H=x.getAttribute("data-rte-ai-action")||H),s.__aiReviewEmptyPreviewSuggestionId&&_===s.__aiReviewEmptyPreviewSuggestionId){xt(_,{focusPanel:!0,focusAction:H||z(),openedQueue:!0});return}if(Xe(_),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&ge(!1),bn(_,H))return;ya(h);return}v.preventDefault(),v.stopPropagation();var R=b.getAttribute("data-rte-ai-action"),C="",P=s.__aiActiveSuggestionId===_;(R==="accept"||R==="reject")&&P&&(C=aa(_)),R==="accept"?Ra(_)&&(C?Dt(C,{focusInlineAction:R}):P&&He(xn("Accepted",_))):R==="reject"?Ca(_)&&(C?Dt(C,{focusInlineAction:R}):P&&He(xn("Rejected",_))):R==="review"?xt(_,{focusPanel:!0}):R==="previous"?nu(_,{focusInlineAction:R})||He(tr(_,"previous")):R==="next"?lu(_,{focusInlineAction:R})||He(tr(_,"next")):R==="shared-seen"?(ul(),$i(),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&ge(!1),He("Shared AI review updates cleared for the current item."),ya(h)):R==="undo"?Cr({focusInlineAction:"undo"}):R==="redo"&&Jr({focusInlineAction:"redo"})}}}}function w(){d=s.getEditable?s.getEditable():null,p=d&&d.ownerDocument?d.ownerDocument:document,d&&s.__aiInlinePreviewEventEditable!==d&&(d.addEventListener("click",m),d.addEventListener("keydown",y),s.__aiInlinePreviewEventEditable=d),p&&s.__aiInlinePreviewEventDocument!==p&&(p.addEventListener("click",m,!0),p.addEventListener("keydown",y,!0),s.__aiInlinePreviewEventDocument=p)}function y(v){if(!v.__rteAiInlinePreviewKeydownHandled){var h=v.target&&v.target.closest?v.target.closest(".rte-ai-inline-preview"):v.target&&v.target.classList&&v.target.classList.contains("rte-ai-inline-preview")?v.target:null;if(h){var _=v.target&&v.target.closest?v.target.closest("[data-rte-ai-action]"):null,b=h.getAttribute("data-rte-ai-suggestion-id");if(!(!b||!me(b)||v.ctrlKey||v.metaKey||v.altKey)){v.__rteAiInlinePreviewKeydownHandled=!0;var H=(v.key||"").toLowerCase(),x=_&&_.getAttribute&&_.getAttribute("data-rte-ai-action")||"",R=x||hl(me(b)),C=!!(s.__aiReviewEmptyPreviewSuggestionId&&b===s.__aiReviewEmptyPreviewSuggestionId);if(C){(H==="enter"||H===" ")&&(v.preventDefault(),xt(b,{focusPanel:!0,focusAction:x||z(),openedQueue:!0}));return}if(H==="arrowleft"||H==="k")v.preventDefault(),nu(b,{focusInlineAction:x})||He(tr(b,"previous"));else if(H==="arrowright"||H==="j")v.preventDefault(),lu(b,{focusInlineAction:x})||He(tr(b,"next"));else if(H==="home")v.preventDefault(),pf(b,{focusInlineAction:x})||He(tr(b,"first"));else if(H==="end")v.preventDefault(),hf(b,{focusInlineAction:x})||He(tr(b,"last"));else if(H==="a"){v.preventDefault();var P=aa(b);Ra(b)&&(P?Dt(P,{focusInlineAction:x}):He(xn("Accepted",b)))}else if(H==="r"){v.preventDefault();var T=aa(b);Ca(b)&&(T?Dt(T,{focusInlineAction:x}):He(xn("Rejected",b)))}else if(H==="u"&&!v.shiftKey&&ar())v.preventDefault(),Cr({focusInlineAction:R||"accept"});else if(H==="u"&&v.shiftKey){var D=Rr();D&&D.suggestion&&D.suggestion.id===b&&(v.preventDefault(),Jr({focusInlineAction:R||"accept"}))}else if(H==="g")Jt(b)&&(v.preventDefault(),ul(),$i(),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&ge(!1),He("Shared AI review updates cleared for the current item."),ya(h));else if(H==="enter"||H===" "){if(_)return;v.preventDefault(),bn(b,x||z())}}}}}s.__aiBindInlinePreviewEventHandlers=w,w(),Ms(),ui(!1),Sc(),xc()};var Jn={toolbar_default:"{bold,italic,underline,forecolor,backcolor}|{justifyleft,justifycenter,justifyright,justifyfull}|{insertorderedlist,insertunorderedlist,indent,outdent,insertblockquote,insertemoji}|{aiassist}#{toggleborder,fullscreenenter,fullscreenexit,undo,redo,togglemore}",toolbar_mobile:"{bold,italic,underline|fontname:toggle,fontsize:toggle,menu_paragraphop|forecolor,backcolor}{insertlink,insertemoji,inserttable,insertimage,removeformat}|{aiassist}#{toggleborder,fullscreenenter,fullscreenexit,undo,redo,togglemore}",toolbar_basic:"{bold,italic,underline}|{fontname,fontsize}|{insertlink,insertemoji,insertimage,insertvideo}|removeformat|code#{toggleborder,fullscreenenter,fullscreenexit,undo,redo,togglemore}",toolbar_full:"{bold,italic,underline,forecolor,backcolor}|{justifyleft,justifycenter,justifyright,justifyfull}|{insertorderedlist,insertunorderedlist,indent,outdent}{superscript,subscript}|{insertlink,insertimage,insertvideo,inserttable,insertemoji,find,code,html2pdf}|{aiassist_chat,aiassist_review}|{insertcomment,trackchanges}#{insertmergefield,insertfootnote,inserttoc,insertpagebreak,revisionhistory,newdoc,save,toggleborder,fullscreenenter,fullscreenexit,undo,redo,togglemore}",controltoolbar_TEXT:"removeformat | {bold,italic,underline,forecolor,backcolor}|{fontname:toggle,fontsize:toggle}|{insertlink}"};function Ui(e){return String(e||"").replace(/\s+/g,"")}function Fi(e){if(L.aiToolkitAutoToolbarButtons===!1)return!1;var t=L[e];if(!t)return!0;var r=Jn[e];return r?Ui(t)===Ui(r):!0}function Ur(e,t){var r=L[e]||"";r.indexOf("aiassist")===-1&&Fi(e)&&(L[e]=r?r+" "+t:t)}function Vn(e,t){var r=L[e]||"";r.indexOf("aiassist")===-1&&Fi(e)&&(L[e]=r?r+t:t)}function pa(){return typeof L.aiToolkitResolver!="function"}function ha(e){if(!pa())return null;var t=o(e,"div","","rte-ai-demo-notice",L.text_aitoolkitdemonotice||"Demo mode: these are built-in sample results, not a real AI model. Connect an AI provider with the aiToolkitResolver setting to get real suggestions.");return t.setAttribute("role","note"),t}function o(e,t,r,i,a){var n=e.ownerDocument.createElement(t);return r&&(n.style.cssText=r),i&&(n.className=i),typeof a<"u"&&(n.innerText=a),e.appendChild(n),n}function Et(e,t,r){var i=o(e,"div","",t,r);return i.setAttribute("aria-hidden","true"),i}function si(){return"data:image/svg+xml;utf8,"+encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 240" role="img" aria-label="Editorial workspace photo"><defs><linearGradient id="ai-photo-sky" x1="0" y1="0" x2="1" y2="1"><stop offset="0%" stop-color="#e0f2fe"/><stop offset="52%" stop-color="#bfdbfe"/><stop offset="100%" stop-color="#ddd6fe"/></linearGradient><linearGradient id="ai-photo-desk" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#fef3c7"/><stop offset="100%" stop-color="#fdba74"/></linearGradient><filter id="ai-photo-blur" x="-20%" y="-20%" width="140%" height="140%"><feGaussianBlur stdDeviation="14"/></filter></defs><rect width="320" height="240" rx="28" fill="url(#ai-photo-sky)"/><circle cx="248" cy="52" r="40" fill="#ffffff" opacity=".55"/><circle cx="76" cy="44" r="34" fill="#fdf2f8" opacity=".65"/><path d="M0 174C37 155 68 151 99 162c24 9 47 23 75 17 20-4 31-17 51-23 28-7 54 6 95 18v66H0z" fill="#86efac" opacity=".92"/><path d="M0 188c34-24 66-27 100-15 32 12 63 26 95 17 23-6 44-24 66-26 22-2 39 7 59 18v48H0z" fill="#60a5fa" opacity=".3"/><g filter="url(#ai-photo-blur)" opacity=".34"><circle cx="248" cy="154" r="54" fill="#1d4ed8"/><circle cx="92" cy="134" r="48" fill="#7c3aed"/></g><rect x="74" y="72" width="172" height="110" rx="14" fill="#f8fafc" opacity=".95"/><rect x="88" y="86" width="144" height="14" rx="7" fill="#cbd5e1"/><rect x="88" y="110" width="118" height="10" rx="5" fill="#dbeafe"/><rect x="88" y="128" width="128" height="10" rx="5" fill="#dbeafe"/><rect x="88" y="146" width="82" height="10" rx="5" fill="#e9d5ff"/><rect x="198" y="138" width="34" height="28" rx="10" fill="url(#ai-photo-desk)"/><rect x="54" y="183" width="212" height="32" rx="16" fill="#ffffff" opacity=".68"/></svg>')}function is(){return'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 140" role="img" aria-hidden="true" focusable="false"><defs><linearGradient id="ai-illus-doc" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#ffffff"/><stop offset="100%" stop-color="#f1f5fb"/></linearGradient><linearGradient id="ai-illus-bubble" x1="0" y1="0" x2="1" y2="1"><stop offset="0%" stop-color="#3b82f6"/><stop offset="100%" stop-color="#6366f1"/></linearGradient><linearGradient id="ai-illus-sparkle" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#fbbf24"/><stop offset="100%" stop-color="#f59e0b"/></linearGradient></defs><ellipse cx="100" cy="118" rx="68" ry="8" fill="#0f172a" opacity="0.08"/><rect x="44" y="34" width="92" height="78" rx="10" fill="#cbd5e1" opacity="0.45" transform="translate(2,3)"/><rect x="44" y="34" width="92" height="78" rx="10" fill="url(#ai-illus-doc)" stroke="#cbd5e1" stroke-width="1"/><rect x="56" y="54" width="60" height="6" rx="3" fill="#dbeafe"/><rect x="56" y="66" width="68" height="5" rx="2.5" fill="#e2e8f0"/><rect x="56" y="76" width="52" height="5" rx="2.5" fill="#e2e8f0"/><rect x="56" y="90" width="44" height="5" rx="2.5" fill="#ede9fe"/><g><path d="M118 22 H162 a10 10 0 0 1 10 10 v22 a10 10 0 0 1 -10 10 H140 l-9 8 v-8 H118 a10 10 0 0 1 -10 -10 V32 a10 10 0 0 1 10 -10 z" fill="url(#ai-illus-bubble)"/><circle cx="128" cy="42" r="2.6" fill="#ffffff"/><circle cx="140" cy="42" r="2.6" fill="#ffffff"/><circle cx="152" cy="42" r="2.6" fill="#ffffff"/></g><g fill="url(#ai-illus-sparkle)"><path d="M36 28 l2 6 6 2 -6 2 -2 6 -2 -6 -6 -2 6 -2 z"/><path d="M168 88 l1.6 4.8 4.8 1.6 -4.8 1.6 -1.6 4.8 -1.6 -4.8 -4.8 -1.6 4.8 -1.6 z"/><path d="M30 92 l1.2 3.6 3.6 1.2 -3.6 1.2 -1.2 3.6 -1.2 -3.6 -3.6 -1.2 3.6 -1.2 z"/></g></svg>'}function zf(e,t){var r=o(e,"div","","rte-ai-hero"+(t?" is-"+t:"")),i=o(r,"div","","rte-ai-hero-media"),a=o(i,"img","","rte-ai-hero-image");a.alt="Styled editorial workspace preview",a.src=si(),a.loading="eager",a.decoding="async";var n=o(r,"div","","rte-ai-hero-body");return o(n,"div","","rte-ai-hero-kicker",t==="dialog"?"Guided AI flow":"Beautiful drafting"),o(n,"div","","rte-ai-hero-title",t==="dialog"?"Review the change before it lands":"Shape the document with a calmer AI workspace"),o(n,"div","","rte-ai-hero-copy",t==="dialog"?"Load source text, compare the result, and apply only the version that improves the draft.":"Keep context visible, ask for help in smaller steps, and make each suggestion feel intentional."),r}function Wn(e,t,r){var i=o(e,"div","",t);return r&&i.setAttribute("data-rte-ai-review-group-label",r),o(i,"div","","rte-ai-review-control-group-body")}function Li(e,t,r){var i=o(e,"div","",t);return r&&o(i,"div","","rte-ai-review-header-group-label",r),o(i,"div","","rte-ai-review-header-group-body")}function qu(e){if(!e)return L.svgCode_aiassist||"";var t=e.icon||e.id||"open_dialog";return L["svgCode_aiassist_"+t]||L.svgCode_aiassist||""}function Iu(e){e=e||{};var t=e.url||"/richtextbox/ai/stream",r=e.body||{},i=typeof AbortController<"u"?new AbortController:null,a="",n=(function(){return typeof fetch!="function"||typeof ReadableStream>"u"?Mu(t,r,e):fetch(t,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify(r),signal:i?i.signal:void 0,credentials:"same-origin"}).then(function(l){if(!l.ok)throw new Error("AI stream failed: HTTP "+l.status);if(!l.body||typeof l.body.getReader!="function")return l.text().then(function(y){return e.onDelta&&e.onDelta(y),a=y,e.onDone&&e.onDone(a),a});var u=l.body.getReader(),d=new TextDecoder("utf-8"),p="";function m(){return u.read().then(function(y){if(y.done)return e.onDone&&e.onDone(a),a;p+=d.decode(y.value,{stream:!0});for(var v;(v=p.indexOf(`
|
|
2
2
|
|
|
3
|
-
`))>=0;){var h=
|
|
4
|
-
`),
|
|
5
|
-
`),
|
|
3
|
+
`))>=0;){var h=p.slice(0,v);p=p.slice(v+2),w(h)}return m()})}function w(y){for(var v="message",h=[],_=y.split(`
|
|
4
|
+
`),b=0;b<_.length;b++){var H=_[b];H.indexOf("event:")===0?v=H.slice(6).trim():H.indexOf("data:")===0&&h.push(H.slice(5).trim())}if(h.length!==0){var x=h.join(`
|
|
5
|
+
`),R;try{R=JSON.parse(x)}catch{R=x}if(v==="message"){var C=typeof R=="string"?R:"";C&&(a+=C,e.onDelta&&e.onDelta(C,a))}else v==="response"?e.onResponse&&e.onResponse(R):v==="error"&&e.onError&&e.onError(R)}}return m()}).catch(function(l){if(l&&l.name==="AbortError")return a;throw e.onError&&e.onError(l),l})})();return{promise:n,abort:function(){i&&i.abort()}}}function Mu(e,t,r){var i=r&&r.fallbackUrl||e.replace(/\/stream$/,"");return new Promise(function(a,n){var l=new XMLHttpRequest;l.open("POST",i,!0),l.setRequestHeader("Content-Type","application/json"),l.onload=function(){if(l.status>=200&&l.status<300){var u;try{u=JSON.parse(l.responseText)}catch{u=l.responseText}var d="";u&&u.operations&&u.operations.length?d=u.operations[0].text||"":u&&u.message&&(d=u.message),r&&r.onDelta&&d&&r.onDelta(d,d),r&&r.onResponse&&u&&typeof u=="object"&&r.onResponse(u),r&&r.onDone&&r.onDone(d),a(d)}else{var p=new Error("AI request failed: HTTP "+l.status);r&&r.onError&&r.onError(p),n(p)}},l.onerror=function(){var u=new Error("AI request network error");r&&r.onError&&r.onError(u),n(u)},l.send(JSON.stringify(t))})}function Hu(e){e=e||{};var t=e.url||"/richtextbox/export/docx",r=typeof e.html=="string"?e.html:s&&s.getHTMLCode?s.getHTMLCode():"",i=e.title||(typeof document<"u"?document.title:"")||"document",a=e.fileName||(String(i).replace(/[\\\/\:\*\?"<>\|]/g,"").trim()||"document")+".docx";if(!r){var n=new Error("exportDocx: editor content is empty.");return e.onError&&e.onError(n),Promise.reject(n)}if(typeof fetch!="function"){var l=new Error("exportDocx requires fetch + Blob support.");return e.onError&&e.onError(l),Promise.reject(l)}return fetch(t,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"},body:JSON.stringify({html:r,title:i,fileName:a}),credentials:"same-origin"}).then(function(u){if(!u.ok)throw new Error("exportDocx failed: HTTP "+u.status);return u.blob()}).then(function(u){if(typeof window<"u"&&window.navigator&&window.navigator.msSaveOrOpenBlob)return window.navigator.msSaveOrOpenBlob(u,a),a;var d=URL.createObjectURL(u),p=document.createElement("a");return p.href=d,p.download=a,document.body.appendChild(p),p.click(),document.body.removeChild(p),setTimeout(function(){try{URL.revokeObjectURL(d)}catch{}},4e3),a}).catch(function(u){throw e.onError&&e.onError(u),u})}function Du(e){e=e||{};var t=e.url||"/richtextbox/import/docx",r=e.mode==="insert"?"insert":"replace";function i(n){return n&&(n.html||n.content)||""}function a(n){if(typeof fetch!="function"||typeof FormData!="function"){var l=new Error("importDocx requires fetch + FormData support.");return e.onError&&e.onError(l),Promise.reject(l)}var u=new FormData;return u.append("file",n,n.name||"document.docx"),u.append("mode",r),fetch(t,{method:"POST",body:u,credentials:"same-origin"}).then(function(d){if(!d.ok)throw new Error("importDocx failed: HTTP "+d.status);return d.json().then(i)}).then(function(d){if(d)return r==="insert"&&s&&s.insertHTML?s.insertHTML(d):s&&s.setHTMLCode&&s.setHTMLCode(d,{undoable:!0}),d}).catch(function(d){throw e.onError&&e.onError(d),d})}return e.file?a(e.file):new Promise(function(n,l){if(typeof document>"u")return l(new Error("importDocx: no document"));var u=document.createElement("input");u.type="file",u.accept=".docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document",u.style.display="none",u.onchange=function(){var d=u.files&&u.files[0];if(document.body.removeChild(u),!d)return n(void 0);a(d).then(n,l)},document.body.appendChild(u),u.click()})}function E(e){return(e||"").replace(/\r\n/g,`
|
|
6
6
|
`).replace(/[ \t]+\n/g,`
|
|
7
7
|
`).replace(/\n{3,}/g,`
|
|
8
8
|
|
|
9
|
-
`).trim()}function ur(e){var t=R(e);return t&&(t=t.charAt(0).toUpperCase()+t.substring(1),/[.!?]$/.test(t)||(t+="."),t)}function fa(){return(k.aiToolkitTranslateLanguages||[]).slice()}function Gi(e){return R(e||"").toLowerCase().replace(/[^a-z0-9]+/g,"")}function lt(e){for(var t=Gi(e),r=fa(),i=0;i<r.length;i++)if(Gi(r[i].value)===t||Gi(r[i].label)===t)return r[i].label||r[i].value;return e?ur(String(e)).replace(/[.!?]$/,""):"Spanish"}function mu(e){for(var t=Gi(e),r=fa(),i=0;i<r.length;i++)if(Gi(r[i].value)===t||Gi(r[i].label)===t)return r[i].value||r[i].label;return t||"spanish"}function We(e){var t=R(e||"").toLowerCase();return t||"other"}function Pe(e){switch(We(e)){case"proofread":return"Proofread";case"rewrite":return"Rewrite";case"translate":return"Translate";case"justify":return"Justify";case"summarize":return"Summarize";case"shorten":return"Shorten";case"expand":return"Expand";case"comment":return"Comment";case"paragraph":return"Paragraph";case"chat":return"Chat";default:return"Other"}}function Fr(e){if(!e)return"";if(e.snapshot&&e.snapshot.hasSelection||e.scope==="selection")return"Selection";if(e.sourceLabel){if(/selection/i.test(e.sourceLabel))return"Selection";if(/document/i.test(e.sourceLabel))return"Document"}return"Document"}function Jl(e){var t=va(e),r=t===1?"1 pending":t+" pending",i=e&&e.suggestionType?Pe(e.suggestionType):"AI";return!i||i==="Other"?"Open queue ("+r+")":"Open "+i+" queue ("+r+")"}function Vl(e){var t=va(e),r=t===1?"1 pending item":t+" pending items",i=e&&e.suggestionType?Pe(e.suggestionType):"AI",a=je(e,F());return!i||i==="Other"?"Click or press Enter to open this AI review queue"+(a?" and focus "+a:"")+". "+r+".":"Click or press Enter to open the "+i+" AI review queue"+(a?" and focus "+a:"")+". "+r+"."}function Ba(e){var t=va(e),r=t===1?"1 pending":t+" pending",i=e&&e.suggestionType?Pe(e.suggestionType):"AI",a=je(e,F());return!i||i==="Other"?"Click or Enter opens queue ("+r+")"+(a?", focus "+a:""):"Click or Enter opens "+i+" queue ("+r+")"+(a?", focus "+a:"")}function va(e){if(!e)return 0;var t=We(e.suggestionType||""),r=t==="other"?"all":t;return Je(r).length}function bu(e){var t=va(e),r=t===1?"1 pending item":t+" pending items",i=e&&e.suggestionType?Pe(e.suggestionType):"AI",a=je(e,F());return!i||i==="Other"?"Opens AI review queue."+(a?" Focuses "+a+".":"")+" "+r:"Opens "+i+" AI review queue."+(a?" Focuses "+a+".":"")+" "+r}function Qn(e,t){t=t||{};var r=["AI suggestion preview"],i=!0;t.isPreviewTarget?(r.push("Next review queue target"),r.push(bu(e)),i=!1):t.isCurrent&&r.push("Current review item"),t.queueOpened&&r.push("Queue opened"),i&&e&&e.suggestionType&&We(e.suggestionType)!=="other"&&r.push(Pe(e.suggestionType)),e&&e.language&&r.push(lt(e.language));var a=Fr(e);if(a&&r.push(a),t.glanceLabels&&t.glanceLabels.length)for(var l=0;l<t.glanceLabels.length;l++)t.glanceLabels[l]&&r.push(t.glanceLabels[l]);return t.glanceDetail&&r.push(t.glanceDetail),t.compareLabel&&r.push(t.compareLabel),t.reasonText&&r.push("Why this suggestion: "+t.reasonText),t.queueRoleLabel&&!t.isPreviewTarget&&r.push(t.queueRoleLabel),t.queueRoleDetail&&!t.isPreviewTarget&&r.push(t.queueRoleDetail),t.focusLabel&&!t.isPreviewTarget&&r.push("Enter focuses "+t.focusLabel),t.positionLabel&&r.push(t.positionLabel),t.transitionLabel&&r.push(t.transitionLabel),t.followupLabel&&r.push(t.followupLabel),t.remoteUpdateCount&&r.push(t.remoteUpdateCount>1?t.remoteUpdateCount+" shared updates":"Shared update"),t.undoLabel&&r.push(t.undoLabel),t.undoNextLabel&&r.push(t.undoNextLabel),t.redoLabel&&r.push(t.redoLabel),t.redoNextLabel&&r.push(t.redoNextLabel),r.join(". ")}function Wl(e,t,r,i){var a=i==="selection"?"Selection":i==="document"?"Document":t&&t.hasSelection?"Selection":"Document",l=Pe(e);return We(e)==="translate"&&r?l+" - "+a+" - "+lt(r):l+" - "+a}function wu(e,t){var r=R(e);if(!r)return"";var i=mu(t),a=lt(i),l={spanish:"Version en espa\xF1ol",french:"Version fran\xE7aise",german:"Deutsche Fassung",italian:"Versione italiana",portuguese:"Vers\xE3o em portugu\xEAs",japanese:"Japanese draft"},n=l[i]||a+" version";return ur(n+": "+r)}function Dt(e,t,r){r=r||{};var i=R(t);if(!i)return"";var a=i.split(/\s+/);switch(e){case"proofread":var l=i.replace(/\s{2,}/g," ").replace(/\s+([,.;:!?])/g,"$1").replace(/([,.;:!?])([^\s"'\)\]])/g,"$1 $2").replace(/\.{2,}(?!\.)/g,".").replace(/^(.)/,function(n){return n.toUpperCase()});return ur(l);case"rewrite":return ur(i.replace(/\bvery\s+/gi,"").replace(/\breally\s+/gi,"").replace(/\bjust\s+/gi,"").replace(/\bin order to\b/gi,"to").replace(/\bdue to the fact that\b/gi,"because").replace(/\s{2,}/g," "));case"translate":return wu(i,r.language);case"shorten":return ur(a.slice(0,Math.max(8,Math.ceil(a.length*.6))).join(" "));case"expand":return ur(i)+`
|
|
9
|
+
`).trim()}function fe(e){for(var t="",r=0;r<e.length;r++){var i=String(e[r]==null?"":e[r]).replace(/[ \t\r\n]+$/,"");i&&(t+=t?(/[.?!\u2026\u3002\uff01\uff1f]$/.test(t)?" ":". ")+i:i)}return t}var Za=[["air_accept","Accept"],["air_reject","Reject"],["air_current","Current"],["air_suggested","Suggested"],["air_why","Why"],["air_scope_sel","Selection"],["air_scope_doc","Document"],["air_type_proofread","Proofread"],["air_type_rewrite","Rewrite"],["air_type_translate","Translate"],["air_type_comment","Comment"],["air_type_paragraph","Paragraph"],["air_type_summarize","Summarize"],["air_type_expand","Expand"],["air_type_shorten","Shorten"],["aip_headings","Headings"],["aichat","AI Chat"],["aic_newchat","Start a fresh chat"],["aic_closechat","Close AI chat"],["aic_close","Close"],["aic_usesel","Use selection"],["aic_usedoc","Use document"],["aic_copymsg","Copy message text"],["aic_copy","Copy"],["aic_regen","Regenerate response"],["aid_regenerate","Regenerate"],["aic_actions","AI chat actions"],["aic_send","Send"],["aic_starttitle","Start with AI Chat"],["aic_pill_doc","Document context"],["aic_pill_sel","Selection context"],["aic_compose_doc","Compose next AI request for the current document"],["aic_compose_sel","Compose next AI request for the current selection"],["aic_emptytitle_doc","Type a prompt or load a starter for the current document first"],["aic_emptytitle_sel","Type a prompt or load a starter for the current selection first"],["aic_empty_doc","Ask anything about the current document"],["aic_empty_sel","Ask anything about the current selection"],["air_focusaria","Focus the current AI review item"],["aiq_preview","AI suggestion preview"],["aiq_proposed","Proposed edit"],["aiq_curandsug","Current and suggested text"],["aiq_curtext","Current text"],["aiq_sugtext","Suggested text"],["aiq_ready","Ready to review"],["aiq_curfocus","Current focus"],["aiq_seldraft","Selection draft"],["aiq_docdraft","Document draft"],["aiq_prepdraft","Prepared draft"],["aiq_customdraft","Custom draft"],["aiq_draftready","Draft ready"],["aiq_glance","Change at a glance"],["aiq_surface","Surface edit"],["aiq_textrewrite","Text rewrite"],["aiq_textchange","Text change"],["aiq_langchange","Language change"],["aiq_reviewchange","Reviewable change"],["aiq_acceptedchange","Accepted change"],["aiq_rejectedchange","Rejected change"],["aiq_lowimpact","Low impact"],["aiq_medimpact","Medium impact"],["aiq_highimpact","High impact"],["aiq_whatnext","What happens next"],["aiq_qcomplete","Queue complete"],["aiq_qopened","Queue opened"],["aiq_qhandoff","Queue handoff"],["aiq_qstate","Queue state"],["aiq_recready","Recovery ready"],["aiq_recavail","Recovery available"],["aiq_finalitem","Accepting or rejecting this final pending item finishes the current review run"],["aiq_moveson","Accepting or rejecting this item moves review straight to the next pending suggestion"],["aiq_nolater","No later pending items remain in this queue"],["aiq_thenrec","Then recovery and next queues appear"],["aiq_thencomplete","Then queue complete"],["aiq_undolast","Undo the last decision or open another queue"],["aiq_afterfinal","After reviewing the final pending item, recovery and next queues appear"],["aiq_afterdec","After this decision"],["aiq_handoff","Action handoff"],["aiq_decidelane","Decide lane"],["aiq_curlane","Current lane"],["aiq_curactionlane","Current action lane"],["aiq_kblane","Keyboard lane"],["aiq_curenter","Current Enter target"],["aiq_spaceact","Enter or Space activates this action"],["aiq_acceptfinish","Accept & finish"],["aiq_rejectfinish","Reject & finish"],["aiq_acceptnext","Accept & next"],["aiq_rejectnext","Reject & next"],["aiq_accfinishdesc","Accept & finish this AI change and finish the current review queue"],["aiq_rejfinishdesc","Reject & finish this AI change and finish the current review queue"],["aiq_open","Open"],["aiq_review","Review"],["aiq_move","Move"],["aiq_previous","Previous"],["aiq_next","Next"],["aiq_decide","Decide"],["aiq_recover","Recover"],["aiq_actions","AI suggestion actions"],["aiq_openactions","Open actions"],["aiq_moveactions","Move actions"],["aiq_decideactions","Decide actions"],["aiq_recoveractions","Recover actions"],["aiq_whysug","Why this suggestion"],["aiq_upnext","Up next"],["aiq_upnextcur","Up next becomes current"],["aiq_follows","This follows after the current decision"],["aiq_nextitem","Next item"],["aiq_reviewnow","Review this item now"],["aiq_reopen","Reopen this suggestion in the current review lane"],["aiq_jump","Jump earlier or later in this queue before deciding"],["aiq_previtem","Previous AI review item"],["aiq_nextitemai","Next AI review item"],["aiq_noprev","No previous AI review item in the current queue"],["aiq_nonext","No next AI review item in the current queue"],["aiq_shortcuts","Inline AI review shortcuts"],["aiq_kbguide","Keyboard guide"],["aiq_move_l","move"],["aiq_jump_l","jump"],["aiq_enter","Enter"],["aiq_custom","Custom"],["aiq_reason_proof","Normalizes spacing, punctuation, and capitalization while keeping the original meaning intact"],["aiq_reason_rewrite","Tightens the wording by removing filler phrases so the point comes through faster"],["aiq_c_ready","Ready"],["aiq_c_docfocus","Document focus"],["aiq_c_selfocus","Selection focus"],["aiq_c_inplace","Ask, rewrite, or review the current document in place"],["aiq_c_docthread","Document thread"],["aiq_c_selthread","Selection thread"],["aiq_c_newask","Ready for a new ask"],["aiq_c_latest","Latest reply is ready"],["aiq_c_context","Context"],["aiq_c_docactive","Document active"],["aiq_c_selactive","Selection active"],["aiq_c_nosel","No current selection"],["aiq_c_selready","Selection ready"],["aiq_c_wholedoc","Using the whole document as the active source"],["aiq_c_narrow","Select text any time to narrow the ask"],["aiq_c_snapshot","Document snapshot"],["aiq_c_scopeswitch","Context scope switch"],["aiq_c_unavail","Unavailable until text is selected"],["aiq_c_activescope","Active scope"],["aiq_c_usingwhole","AI Chat is using the whole document"],["aiq_c_quickstarts","Quick starts"],["aiq_c_readychoose","Ready to choose"],["aiq_c_choosestarter","Choose a starter for the current document or keep typing your own prompt in Compose"],["aiq_c_starterbtns","Starter buttons for the current document"],["aiq_c_loadsstarter","Loads this starter into Compose for the current document"],["aiq_c_summarystarter","Summary starter"],["aiq_c_reviewstarter","Review starter"],["aiq_c_langstarter","Language starter"],["aiq_c_structstarter","Structure starter"],["aiq_c_expandstarter","Expand starter"],["aiq_c_starterready","Starter ready"],["aiq_c_p_summarize","Summarize the current content and suggest the clearest next edit"],["aiq_c_p_proofread","Proofread the current content and prepare a cleaner version I can review"],["aiq_c_p_translate","Translate the current content into Spanish and prepare a reviewable version"],["aiq_c_p_headings","Suggest better section titles and subheadings for this content"],["aiq_c_p_expand","Add a short supporting paragraph that strengthens this content"],["aiq_c_conversation","Conversation"],["aiq_c_firstex","First exchange"],["aiq_c_waitfirst","Waiting for first ask"],["aiq_c_firstanswer","Your first answer, draft, or reviewable change for the current document will appear here"],["aiq_c_askexplore","Ask and explore"],["aiq_c_getanswers","Get answers, summaries, headings, or rewrite direction grounded in the current context"],["aiq_c_prepedits","Prepare reviewable edits"],["aiq_c_previewinline","Preview inline changes, apply structured plans, or turn responses into review-ready suggestions"],["aiq_c_usestarters","Use starters or type your own"],["aiq_c_choosecurated","Choose one of the curated quick starts above or write a custom prompt in the composer below"],["aiq_c_compose","Compose"],["aiq_c_readyask","Ready to ask about the current document"],["aiq_c_entersends","Enter sends"],["aiq_c_composeactions","Compose actions"],["aiq_c_openask","Open Ask AI"],["aiq_c_senddisabled","Send disabled"],["aiq_c_responseready","AI response ready"],["aiq_c_replyready","Reply ready"],["aiq_c_textchange","This is a text change"],["aiq_c_exchange","AI chat exchange"],["aiq_c_customex","Custom exchange"],["aiq_c_request","Request"],["aiq_c_curexchange","Current exchange"],["aiq_c_you","You"],["aiq_c_prompt","Prompt"],["aiq_c_promptsent","Prompt sent"],["aiq_c_waitingai","Waiting on AI for the current document context"],["aiq_c_whatyouasked","What you asked"],["aiq_c_usingdoc","Using current document"],["aiq_c_response","Response"],["aiq_c_answer","Answer"],["aiq_c_answerready","Answer ready"],["aiq_c_readanswer","Read the answer grounded in the current document context"],["aiq_c_copyonly","Copy only"],["aiq_c_copyonlygroup","Copy only group"],["aiq_c_copyprep","Copy this prepared reply without changing the document"],["aiq_c_copyprepai","Copy this prepared AI reply without changing the document"],["aiq_c_copytext","Copy text"],["aiq_c_actions","Actions"],["aiq_c_ai","AI"]],Bn=[["aiq_p_queue",new RegExp("^Queue (\\d+) of (\\d+)$")],["aiq_p_step",new RegExp("^(\\d+) steps?$")],["aiq_p_keeps",new RegExp("^Keeps (\\d+) words? across (\\d+) sentences?$")],["aiq_p_queuein",new RegExp("^It is queue (\\d+) of (\\d+) in this view$")],["aiq_p_enterfocuses",new RegExp("^Enter focuses (.+)$")],["aiq_p_entercolon",new RegExp("^Enter: (.+)$")],["aiq_p_focus",new RegExp("^[Ff]ocus (.+)$")],["aiq_p_reviewopens",new RegExp("^Review opens on (.+)$")],["aiq_p_openfocus",new RegExp("^Open this AI suggestion in review and focus (.+)$")],["aiq_p_auses",new RegExp("^A uses (.+)$")],["aiq_p_ruses",new RegExp("^R uses (.+)$")],["aiq_p_exchanges",new RegExp("^(\\d+) exchanges?$")],["aiq_p_messages",new RegExp("^(\\d+) messages?$")],["aiq_p_words",new RegExp("^(\\d+) words?$")],["aid_chars",new RegExp("^(\\d+) chars?$")],["aiq_p_paragraphs",new RegExp("^(\\d+) paragraphs?$")],["aic_pill_starters",new RegExp("^(\\d+) starters?$")],["aic_pill_words",new RegExp("^(\\d+) words in scope$")],["aiq_p_exchangen",new RegExp("^Exchange (\\d+)$")],["aiq_p_turn",new RegExp("^Turn (\\d+)$")],["aiq_p_convdoc",new RegExp("^(\\d+) exchanges?, (\\d+) messages? in this conversation for the current document$")],["aiq_p_convsel",new RegExp("^(\\d+) exchanges?, (\\d+) messages? in this conversation for the current selection$")],["aiq_p_threaddoc",new RegExp("^(\\d+) exchanges?, (\\d+) messages? in this document thread$")],["aiq_p_threadsel",new RegExp("^(\\d+) exchanges?, (\\d+) messages? in this selection thread$")],["aiq_p_responding",new RegExp("^Responding to (.+) request$")],["aiq_p_actions",new RegExp("^Actions: (.+)$")]],oi=null;function Xn(){var e=L&&L.text_uilocale;return e&&!/^en(-|$)/i.test(e)?e:""}function Yn(){return/^(zh|ja)/i.test(Xn())}function ju(e){if(!oi){oi={};for(var t=0;t<Za.length;t++){var r=Za[t][1];oi["="+r]||(oi["="+r]=Za[t][0]),oi["~"+r.toLowerCase()]||(oi["~"+r.toLowerCase()]=Za[t][0])}}var i=oi["="+e]||oi["~"+e.toLowerCase()];return i&&L["text_"+i]||null}function as(e){var t=ju(e);if(t)return t;for(var r=0;r<Bn.length;r++){var i=Bn[r][1].exec(e);if(i){var a=L["text_"+Bn[r][0]];if(!a)return null;for(var n=a,l=1;l<i.length;l++){var u=i[l],d=/^[0-9]+$/.test(u)?u:as(u);if(d==null)return null;n=n.split("{"+(l-1)+"}").join(d)}return n}}return null}function ns(e){var t=e,r="",i=t.charAt(t.length-1);(i==="."||i===":")&&(r=i,t=t.substring(0,t.length-1));var a=as(t);if(a==null)return null;if(r){var n=a.charAt(a.length-1),l=".:!?".indexOf(n)>=0||n==="\u3002"||n==="\uFF1A";l||(a+=Yn()?String.fromCharCode(r===":"?65306:12290):r)}return a}function en(e){var t=String(e??"").replace(/^\s+|\s+$/g,"");if(!t||!/[A-Za-z]/.test(t))return null;var r=ns(t);if(r!=null)return r;var i=t.indexOf(" - ");if(i>0){var a=en(t.substring(0,i)),n=en(t.substring(i+3));if(a!=null||n!=null)return(a??t.substring(0,i))+" - "+(n??t.substring(i+3))}var l=t.match(/[^.:!?]+[.:!?]*/g);if(!l||l.length<2)return null;for(var u="",d=!1,p=!1,m=0;m<l.length;m++){var w=l[m].replace(/^\s+|\s+$/g,"");if(w){var y=ns(w);y!=null&&(p=!0);var v=y!=null||!/[A-Za-z]/.test(w),h=y??w;u+=u?(v&&d&&Yn()?"":" ")+h:h,d=v}}return p?u:null}var Zn=null,ls=null;function ss(e){if(e==null||!Yn())return e;if(!Zn){var t="\u4E00-\u9FFF\u3040-\u30FF\u201D\u300D";Zn=new RegExp("(["+t+"])\\.","g"),ls=new RegExp("([\u3002\uFF1A])\\s+(?=[^A-Za-z0-9\\s])","g")}return e.replace(Zn,"$1\u3002").replace(ls,"$1")}var Ou=".rte-ai-inline-preview-compare-text, .rte-ai-chat-message-text, .rte-ai-chat-message-request-body, textarea, input, script, style, svg";function os(e){if(!(!e||!Xn()))for(var t=[e];t.length;){var r=t.pop();if(r.nodeType===1&&!(r!==e&&r.matches&&r.matches(Ou))){for(var i=0;i<3;i++){var a=i===0?"aria-label":i===1?"title":"placeholder",n=r.getAttribute(a);if(n){var l=ss(en(n)||n);l!==n&&r.setAttribute(a,l)}}for(var u=r.firstChild;u;u=u.nextSibling)if(u.nodeType===1)t.push(u);else if(u.nodeType===3&&/[A-Za-z.]/.test(u.data)){var d=ss(en(u.data)||u.data.replace(/^\s+|\s+$/g,""));if(d){var p=/^\s*/.exec(u.data)[0],m=/\s*$/.exec(u.data)[0];p+d+m!==u.data&&(u.data=p+d+m)}}}}}function us(e,t){if(!(!e||!Xn()||e.__aiqWatched)){e.__aiqWatched=!0;var r=function(){if(!t){os(e);return}for(var l=e.querySelectorAll(t),u=0;u<l.length;u++)os(l[u])};r();var i=e.ownerDocument&&e.ownerDocument.defaultView,a=i&&i.MutationObserver;if(a){var n=!1;new a(function(){n||(n=!0,i.setTimeout(function(){n=!1,r()},0))}).observe(e,{subtree:!0,childList:!0,characterData:!0,attributes:!0,attributeFilter:["aria-label","title","placeholder"]})}}}function Gu(){var e=s.getEditable?s.getEditable():null;e&&us(e,".rte-ai-inline-preview")}function Fr(e){var t=E(e);return t&&(t=t.charAt(0).toUpperCase()+t.substring(1),/[.!?]$/.test(t)||(t+="."),t)}function ga(){return(L.aiToolkitTranslateLanguages||[]).slice()}function Ri(e){return E(e||"").toLowerCase().replace(/[^a-z0-9]+/g,"")}var Uu={spanish:["es","Spanish"],french:["fr","French"],german:["de","German"],italian:["it","Italian"],portuguese:["pt","Portuguese"],japanese:["ja","Japanese"]};function Fu(e){var t=e.label||e.value,r=Uu[Ri(e.value)],i=L&&L.text_uilocale;if(!r||t!==r[1]||!i||/^en(-|$)/i.test(i))return t;try{if(typeof Intl<"u"&&Intl.DisplayNames){var a=new Intl.DisplayNames([i],{type:"language"}).of(r[0]);if(a&&a!==r[0])return a}}catch{}return t}function ot(e){for(var t=Ri(e),r=ga(),i=0;i<r.length;i++)if(Ri(r[i].value)===t||Ri(r[i].label)===t)return r[i].label||r[i].value;return e?Fr(String(e)).replace(/[.!?]$/,""):"Spanish"}function Nu(e){for(var t=Ri(e),r=ga(),i=0;i<r.length;i++)if(Ri(r[i].value)===t||Ri(r[i].label)===t)return r[i].value||r[i].label;return t||"spanish"}function Be(e){var t=E(e||"").toLowerCase();return t||"other"}function Me(e){switch(Be(e)){case"proofread":return c.__aiT?c.__aiT("air_type_proofread","Proofread"):"Proofread";case"rewrite":return c.__aiT?c.__aiT("air_type_rewrite","Rewrite"):"Rewrite";case"translate":return c.__aiT?c.__aiT("air_type_translate","Translate"):"Translate";case"justify":return c.__aiT?c.__aiT("air_type_justify","Justify"):"Justify";case"summarize":return c.__aiT?c.__aiT("air_type_summarize","Summarize"):"Summarize";case"shorten":return c.__aiT?c.__aiT("air_type_shorten","Shorten"):"Shorten";case"expand":return c.__aiT?c.__aiT("air_type_expand","Expand"):"Expand";case"comment":return c.__aiT?c.__aiT("air_type_comment","Comment"):"Comment";case"paragraph":return c.__aiT?c.__aiT("air_type_paragraph","Paragraph"):"Paragraph";case"chat":return c.__aiT?c.__aiT("air_type_chat","Chat"):"Chat";default:return c.__aiT?c.__aiT("air_type_other","Other"):"Other"}}function Nr(e){if(!e)return"";if(e.snapshot&&e.snapshot.hasSelection||e.scope==="selection")return"Selection";if(e.sourceLabel){if(/selection/i.test(e.sourceLabel))return"Selection";if(/document/i.test(e.sourceLabel))return"Document"}return"Document"}function cs(e){var t=ma(e),r=t===1?"1 pending":t+" pending",i=e&&e.suggestionType?Me(e.suggestionType):"AI";return!i||i==="Other"?"Open queue ("+r+")":"Open "+i+" queue ("+r+")"}function ds(e){var t=ma(e),r=t===1?"1 pending item":t+" pending items",i=e&&e.suggestionType?Me(e.suggestionType):"AI",a=Ge(e,z());return!i||i==="Other"?"Click or press Enter to open this AI review queue"+(a?" and focus "+a:"")+". "+r+".":"Click or press Enter to open the "+i+" AI review queue"+(a?" and focus "+a:"")+". "+r+"."}function tn(e){var t=ma(e),r=t===1?"1 pending":t+" pending",i=e&&e.suggestionType?Me(e.suggestionType):"AI",a=Ge(e,z());return!i||i==="Other"?"Click or Enter opens queue ("+r+")"+(a?", focus "+a:""):"Click or Enter opens "+i+" queue ("+r+")"+(a?", focus "+a:"")}function ma(e){if(!e)return 0;var t=Be(e.suggestionType||""),r=t==="other"?"all":t;return Ve(r).length}function Ku(e){var t=ma(e),r=t===1?"1 pending item":t+" pending items",i=e&&e.suggestionType?Me(e.suggestionType):"AI",a=Ge(e,z());return!i||i==="Other"?"Opens AI review queue."+(a?" Focuses "+a+".":"")+" "+r:"Opens "+i+" AI review queue."+(a?" Focuses "+a+".":"")+" "+r}function el(e,t){t=t||{};var r=["AI suggestion preview"],i=!0;t.isPreviewTarget?(r.push("Next review queue target"),r.push(Ku(e)),i=!1):t.isCurrent&&r.push("Current review item"),t.queueOpened&&r.push("Queue opened"),i&&e&&e.suggestionType&&Be(e.suggestionType)!=="other"&&r.push(Me(e.suggestionType)),e&&e.language&&r.push(ot(e.language));var a=Nr(e);if(a&&r.push(a),t.glanceLabels&&t.glanceLabels.length)for(var n=0;n<t.glanceLabels.length;n++)t.glanceLabels[n]&&r.push(t.glanceLabels[n]);return t.glanceDetail&&r.push(t.glanceDetail),t.compareLabel&&r.push(t.compareLabel),t.reasonText&&r.push("Why this suggestion: "+t.reasonText),t.queueRoleLabel&&!t.isPreviewTarget&&r.push(t.queueRoleLabel),t.queueRoleDetail&&!t.isPreviewTarget&&r.push(t.queueRoleDetail),t.focusLabel&&!t.isPreviewTarget&&r.push("Enter focuses "+t.focusLabel),t.positionLabel&&r.push(t.positionLabel),t.transitionLabel&&r.push(t.transitionLabel),t.followupLabel&&r.push(t.followupLabel),t.remoteUpdateCount&&r.push(t.remoteUpdateCount>1?t.remoteUpdateCount+" shared updates":"Shared update"),t.undoLabel&&r.push(t.undoLabel),t.undoNextLabel&&r.push(t.undoNextLabel),t.redoLabel&&r.push(t.redoLabel),t.redoNextLabel&&r.push(t.redoNextLabel),fe(r)}function fs(e,t,r,i){var a=i==="selection"?"Selection":i==="document"?"Document":t&&t.hasSelection?"Selection":"Document",n=Me(e);return Be(e)==="translate"&&r?n+" - "+a+" - "+ot(r):n+" - "+a}function zu(e,t){var r=E(e);if(!r)return"";var i=Nu(t),a=ot(i),n={spanish:"Version en espa\xF1ol",french:"Version fran\xE7aise",german:"Deutsche Fassung",italian:"Versione italiana",portuguese:"Vers\xE3o em portugu\xEAs",japanese:"Japanese draft"},l=n[i]||a+" version";return Fr(l+": "+r)}function Ut(e,t,r){r=r||{};var i=E(t);if(!i)return"";var a=i.split(/\s+/);function n(u){var d=E(u);return d&&(r.midStart||(d=d.charAt(0).toUpperCase()+d.substring(1)),!r.midEnd&&!/[.!?]$/.test(d)&&(d+="."),d)}switch(e){case"proofread":var l=i.replace(/\s{2,}/g," ").replace(/\s+([,.;:!?])/g,"$1").replace(/([,.;:!?])([^\s"'\)\]])/g,"$1 $2").replace(/\.{2,}(?!\.)/g,".");return n(l);case"rewrite":return n(i.replace(/\bvery\b\s*/gi,"").replace(/\breally\b\s*/gi,"").replace(/\bjust\b\s*/gi,"").replace(/\bin order to\b/gi,"to").replace(/\bdue to the fact that\b/gi,"because").replace(/\s{2,}/g," "));case"translate":return zu(i,r.language);case"shorten":return Fr(a.slice(0,Math.max(8,Math.ceil(a.length*.6))).join(" "));case"expand":return Fr(i)+`
|
|
10
10
|
|
|
11
11
|
To add context: this extended version unpacks the idea with an additional sentence so readers can follow the reasoning without extra background.`;case"summarize":return`Summary:
|
|
12
|
-
- `+ur(a.slice(0,Math.max(10,Math.ceil(a.length*.45))).join(" "));default:return ur(i)}}function $l(e){var t=R(e);return t?ur('AI note: Consider clarifying this passage and tightening the wording around "'+t.split(/\s+/).slice(0,6).join(" ")+'"'):"AI note: Consider tightening this wording for clarity and reader confidence."}function yu(e){var t=R(e);return t?ur("Additional paragraph: This section adds a concise supporting explanation that reinforces "+t.split(/\s+/).slice(0,10).join(" ")+" for the reader."):"Additional paragraph: This section adds a concise supporting explanation so the reader gets more context without losing momentum."}function Xa(e,t){var r=R(e);return!r||r.length<=t?r:r.substring(0,Math.max(0,t-3)).replace(/\s+\S*$/,"").trim()+"..."}function Au(e,t){var r=Xa(t,160)||"the current document";return/\b(headings?|titles?)\b/.test(e)?"You could tighten the structure by using shorter headings that mirror the main claims in "+r+". Ask me to draft heading options and I can turn them into reviewable suggestions.":/\b(translate|translation)\b/.test(e)?"I can translate the current selection or whole document into Spanish, French, German, Italian, Portuguese, or Japanese and keep it reviewable in the editor before you accept it.":/\bwhy\b|\bhow\b|\bwhat\b|\?/.test(e)?"Based on "+r+", I would focus on clarity, stronger section framing, and cleaner transitions. If you want, ask me to rewrite or summarize a specific passage and I can prepare an in-editor suggestion.":"I reviewed "+r+". Ask me to rewrite, summarize, proofread, translate, comment on, or expand the current content and I can prepare editor-ready changes."}function Su(e){var t=R(e).toLowerCase();if(!t)return"";for(var r=fa(),i=0;i<r.length;i++){var a=(r[i].label||"").toLowerCase(),l=(r[i].value||"").toLowerCase();if(a&&t.indexOf(a)>=0||l&&t.indexOf(l)>=0)return r[i].value||r[i].label}return""}function xu(e){var t=R(e.prompt||""),r=R(e.source||e.selectionText||e.documentText||""),i=t.toLowerCase(),a=e.language||Su(t),l=e.scope==="selection",n=l?"selection-preview":"document",u="",c="",f=n;if(!t)return{message:"Ask a question, request a rewrite, or tell the AI to summarize, proofread, translate, or expand the current content.",operations:[]};if(/\b(translate|translation|localize|localise)\b/.test(i)){var p=lt(a||"spanish");return c=Dt("translate",r,{language:a}),u="This prepares a translated "+p+" draft while keeping the original text nearby until you review and accept the change.",{message:"I prepared a "+p+" translation you can review before applying.",result:c,reason:u,operations:[vt(n,c,{reason:u},e,e.action)]}}return/\b(comment|note|feedback)\b/.test(i)?(c=$l(r),u="This AI note highlights a place that could use clarification or stronger editorial guidance.",{message:"I prepared an AI comment you can add next to the current content.",result:c,reason:u,operations:[{type:"add-comment",text:c,reason:u}]}):/\b(expand|add|insert|paragraph|develop)\b/.test(i)?(c=Dt("expand",r),u="This adds supporting detail without changing the original point, so it works well as an inserted follow-up paragraph.",f="insert",{message:"I drafted a supporting paragraph you can insert below the current content.",result:c,reason:u,operations:[vt(f,c,{reason:u},e,e.action)]}):/\b(summarize|summary|recap)\b|\bexecutive summary\b/.test(i)?(c=Dt("summarize",r),u="This compresses the current content into a shorter, clearer version that is easier to scan or reuse.",f=l?"selection-preview":"document",{message:"I prepared a condensed version of the current content for review.",result:c,reason:u,operations:[vt(f,c,{reason:u},e,e.action)]}):/\b(proofread|grammar|fix|correct)\b|\bclean up\b/.test(i)?(c=Dt("proofread",r),u="This pass improves grammar, punctuation, and readability while keeping the original meaning intact.",{message:"I prepared a proofread version you can preview inline and accept if it looks right.",result:c,reason:u,operations:[vt(n,c,{reason:u},e,e.action)]}):/\b(rewrite|adjust|clarify|improve|polish|tone)\b/.test(i)?(c=Dt("rewrite",r),u="This rewrite removes filler language and tightens the wording so the idea is easier to review and accept.",{message:"I drafted a clearer rewrite of the current content.",result:c,reason:u,operations:[vt(n,c,{reason:u},e,e.action)]}):{message:Au(i,r),operations:[]}}function Bl(e){for(var t=zn(),r=0;r<t.length;r++)if(t[r].id===e)return t[r];return null}function zn(){return(k.aiToolkitActions||[]).slice()}function Jn(){return(k.aiToolkitDialogModes||[]).slice()}function Xl(e,t){if(!t||!t.id)return!1;for(var r=0;r<e.length;r++)if(e[r].id===t.id)return e[r]=t,!0;return e.push(t),!0}function Yl(e,t){for(var r=e.length-1;r>=0;r--)if(e[r].id===t)return e.splice(r,1),!0;return!1}function _u(e){return k.aiToolkitActions=k.aiToolkitActions||[],Xl(k.aiToolkitActions,e),e}function Lu(e){return k.aiToolkitActions=k.aiToolkitActions||[],Yl(k.aiToolkitActions,e)}function Ru(e){return k.aiToolkitDialogModes=k.aiToolkitDialogModes||[],Xl(k.aiToolkitDialogModes,e),e}function Tu(e){return k.aiToolkitDialogModes=k.aiToolkitDialogModes||[],Yl(k.aiToolkitDialogModes,e)}function ku(e,t){return e?typeof t=="function"?(k.aiToolkitOperationHandlers[e]=t,!0):(delete k.aiToolkitOperationHandlers[e],!1):!1}function Cu(e){return e&&k.aiToolkitOperationHandlers&&k.aiToolkitOperationHandlers[e]?(delete k.aiToolkitOperationHandlers[e],!0):!1}function Zl(){return{version:"2026-04-18",operations:[{type:"open-chat-panel",description:"Open the docked AI chat panel."},{type:"open-review-panel",description:"Open the persistent AI review drawer."},{type:"open-dialog",description:"Open the Ask AI review dialog."},{type:"preview-suggestion",description:"Preview a reviewable inline suggestion for the current selection.",requiresText:!0,requiresSelection:!0},{type:"replace-selection",description:"Replace the current selection with new text.",requiresText:!0,requiresSelection:!0},{type:"replace-document",description:"Replace the whole editor document with new text.",requiresText:!0},{type:"insert-below",description:"Insert new text below the current selection or caret.",requiresText:!0},{type:"add-comment",description:"Insert an AI comment marker near the current selection or caret.",requiresText:!0}]}}function vt(e,t,r,i,a){var l=e||a&&a.target||"document",n={mode:i&&i.mode?i.mode:a&&a.resolverMode?a.resolverMode:"",language:i&&i.language?i.language:"",sourceLabel:Wl(i&&i.mode?i.mode:a&&a.resolverMode?a.resolverMode:"",i&&i.snapshot?i.snapshot:null,i&&i.language?i.language:"",i&&i.scope?i.scope:"")};switch(l){case"chat-panel":return{type:"open-chat-panel"};case"review-panel":return{type:"open-review-panel"};case"dialog":return{type:"open-dialog",presetMode:r&&r.presetMode?r.presetMode:i&&i.mode?i.mode:"",useDocument:r&&typeof r.useDocument=="boolean"?r.useDocument:!1,autoRun:r&&typeof r.autoRun=="boolean"?r.autoRun:a&&typeof a.autoRun=="boolean"?a.autoRun:!1};case"selection-preview":case"preview":return{type:"preview-suggestion",text:t,meta:n};case"comment":return{type:"add-comment",text:t,meta:n};case"insert":return{type:"insert-below",text:t,meta:n};case"selection":return{type:"replace-selection",text:t,meta:n};default:return{type:"replace-document",text:t,meta:n}}}function Eu(e,t,r,i,a){if(e==null)return null;if(typeof e=="string")return vt(t,e,r,i,a);var l=e.type||e.op||e.name||"";return l?{type:l,text:R(e.text||e.result||e.content||e.note||""),html:e.html||"",reason:e.reason||r&&r.reason||"",presetMode:e.presetMode||r&&r.presetMode||i&&i.mode||"",useDocument:typeof e.useDocument=="boolean"?e.useDocument:r&&typeof r.useDocument=="boolean"?r.useDocument:!1,autoRun:typeof e.autoRun=="boolean"?e.autoRun:r&&typeof r.autoRun=="boolean"?r.autoRun:a&&typeof a.autoRun=="boolean"?a.autoRun:!1,target:e.target||t||"",meta:e.meta||null}:vt(e.target||t,e.text||e.result||e.content||e.note||"",e,i,a)}function Pu(e,t,r,i){var a=[];e&&e.operations?a=e.operations:e&&e.operation?a=[e.operation]:a=[vt(t,e&&(e.result||e.text||""),e,r,i)];for(var l=[],n=0;n<a.length;n++){var u=Eu(a[n],t,e,r,i);u&&l.push(u)}return l}function Nt(e){if(!e)return"";if(e.result)return R(e.result);for(var t=e.operations||[],r=0;r<t.length;r++)if(t[r]&&t[r].text)return R(t[r].text);return""}function pa(e){if(!e)return"";if(e.reason)return R(e.reason);for(var t=e.operations||[],r=0;r<t.length;r++)if(t[r]&&t[r].reason)return R(t[r].reason);return""}function es(e){if(!e||!e.type)return{title:"Unknown step",copy:"This AI step does not expose a known editor action yet."};switch(e.type){case"open-chat-panel":return{title:"Open AI chat",copy:"Opens the docked AI chat panel for multi-turn document help."};case"open-review-panel":return{title:"Open AI review",copy:"Opens the persistent AI suggestion queue for the current editor."};case"open-dialog":return{title:"Open review dialog",copy:"Launches the Ask AI review dialog for a guided follow-up."};case"preview-suggestion":return{title:"Preview inline suggestion",copy:"Shows a reviewable inline diff in the editor before anything is committed."};case"replace-selection":return{title:"Replace selection",copy:"Updates the current selection with the generated text."};case"replace-document":return{title:"Replace document",copy:"Swaps the full editor content with the generated text."};case"insert-below":return{title:"Insert below",copy:"Adds generated content beneath the current selection or caret."};case"add-comment":return{title:"Add AI comment",copy:"Drops a non-destructive AI comment marker into the document."};default:return{title:e.type,copy:"Custom AI operation returned by the current resolver."}}}function ts(e){var t=e&&e.operations?e.operations:[];if(!t.length)return"Apply";if(t.length>1)return"Apply "+t.length+" steps";switch(t[0].type){case"preview-suggestion":return"Preview";case"open-review-panel":return"Open AI review";case"replace-selection":return"Replace selection";case"replace-document":return"Replace document";case"insert-below":return"Insert below";case"add-comment":return"Add AI comment";case"open-chat-panel":return"Open AI chat";case"open-dialog":return"Open review dialog";default:return"Apply"}}function Mu(e){return ts({operations:[e]})}function rs(e){var t=e||[];if(!t.length)return"Select text to continue";if(t.length>1)return"Select text to apply plan";switch(t[0].type){case"preview-suggestion":return"Select text to preview";case"replace-selection":return"Select text to apply to selection";default:return"Select text to continue"}}function qu(e,t){if(!e||!e.type)return"Run this prepared AI step in the editor.";switch(e.type){case"preview-suggestion":return t&&t.hasSelection?"Show the prepared inline diff in the editor before deciding it.":"Select text to preview this prepared inline diff in the editor.";case"replace-selection":return t&&t.hasSelection?"Replace the current selection with this prepared draft.":"Select text before replacing it with this prepared draft.";case"replace-document":return"Replace the full document with this prepared draft.";case"insert-below":return t&&t.hasSelection?"Insert this prepared draft below the current selection.":"Insert this prepared draft below the current content.";case"add-comment":return"Add this prepared AI comment without rewriting the document body.";default:return"Run this prepared AI step in the editor."}}function is(e,t,r,i){if(e){var a=[t||"Action"];r&&a.push(r),i&&a.push(i),e.setAttribute("aria-label",a.join(". ")),e.title=r?(t||"Action")+" - "+r+(i?" "+i:""):(t||"Action")+(i?" - "+i:"")}}function Kr(e,t,r,i,a){return Vn({operations:[vt(t,e,r,i,a)],presetMode:r&&r.presetMode?r.presetMode:i&&i.mode?i.mode:"",useDocument:r&&typeof r.useDocument=="boolean"?r.useDocument:!1,autoRun:r&&typeof r.autoRun=="boolean"?r.autoRun:!1},a,i)}function as(e){switch(e.mode){case"proofread":var t="Normalizes spacing, punctuation, and capitalization while keeping the original meaning intact.";return{operations:[vt(e.action&&e.action.target?e.action.target:"selection-preview",Dt("proofread",e.source),{reason:t},e,e.action)],reason:t};case"rewrite":var r="Tightens the wording by removing filler phrases so the point comes through faster.";return{operations:[vt(e.action&&e.action.target?e.action.target:"selection-preview",Dt("rewrite",e.source),{reason:r},e,e.action)],reason:r};case"translate":var i=e.action&&e.action.target&&e.action.target!=="dialog"?e.action.target:e.scope==="selection"?"selection-preview":"document";return{operations:[vt(i,Dt("translate",e.source,{language:e.language}),{reason:"This prepares a translated "+lt(e.language||"spanish")+" draft while keeping the original text available for review."},e,e.action)],reason:"This prepares a translated "+lt(e.language||"spanish")+" draft while keeping the original text available for review."};case"justify":return{operations:[{type:"preview-suggestion",text:Dt("rewrite",e.source),reason:"This rewrite reduces filler language, clarifies the main point, and makes the sentence easier to review before accepting."}],reason:"This rewrite reduces filler language, clarifies the main point, and makes the sentence easier to review before accepting."};case"shorten":var a="Trims the passage to its core idea while keeping the original phrasing.";return{operations:[vt(e.action&&e.action.target?e.action.target:"document",Dt("shorten",e.source),{reason:a},e,e.action)],reason:a};case"expand":var l="Adds a supporting sentence that reinforces the original point without changing its direction.",n=e.action&&e.action.target&&e.action.id!==e.mode?e.action.target:"insert";return{operations:[vt(n,Dt("expand",e.source),{reason:l},e,e.action)],reason:l};case"summarize":var u="Condenses the content into a scannable summary that works as a recap or abstract.";return{operations:[vt(e.action&&e.action.target?e.action.target:"document",Dt("summarize",e.source),{reason:u},e,e.action)],reason:u};case"comment":return{operations:[{type:"add-comment",text:$l(e.source)}]};case"paragraph":return{operations:[{type:"insert-below",text:yu(e.source)}]};case"chat":return xu(e);default:return{operations:[vt(e.action&&e.action.target?e.action.target:"document",Dt(e.mode||"rewrite",e.source),null,e,e.action)]}}}function Vn(e,t,r){var i=t&&t.target?t.target:"document";if(e==null)return{result:"",target:i,operations:[],message:"",action:t,request:r};typeof e=="string"&&(e={operations:[vt(i,e,null,r,t)]});var a=Pu(e,e.target||e.mode||i,r,t),l=a.length?a[0].target||e.target||e.mode||i:e.target||e.mode||i;return{result:R(e.result||e.text||Nt({operations:a})||""),target:l,operations:a,message:R(e.message||e.reply||""),reason:R(e.reason||pa({operations:a})||""),autoRun:typeof e.autoRun=="boolean"?e.autoRun:t&&typeof t.autoRun=="boolean"?t.autoRun:!1,useDocument:typeof e.useDocument=="boolean"?e.useDocument:!1,presetMode:e.presetMode||r.mode||"",action:t,request:r}}function Ya(e,t){t=t||{};var r=Bl(e)||{id:e,title:e,target:"document"},i=t.snapshot||st(),a={actionId:e,action:r,mode:t.mode||r.resolverMode||e,source:t.source||i.text||i.wholeText,prompt:t.prompt||"",language:t.language||"",scope:t.scope||(i.hasSelection?"selection":"document"),selectionText:i.text||"",documentText:i.wholeText||"",snapshot:i,editor:s,contract:Zl()};if(typeof k.aiToolkitResolver=="function")try{return Promise.resolve(k.aiToolkitResolver.call(s,a)).then(function(l){return(l===null||typeof l>"u")&&(l=as(a)),Vn(l,r,a)})}catch(l){return Promise.reject(l)}return Promise.resolve(Vn(as(a),r,a))}function st(){var e=s.getSelection?s.getSelection():null,t={text:R(s.getSelectedText?s.getSelectedText():""),html:s.getSelectedHTML?s.getSelectedHTML():"",wholeText:R(s.getText?s.getText():""),range:null};if(t.hasSelection=!!t.text,e&&e.rangeCount)try{t.range=e.getRangeAt(0).cloneRange()}catch{t.range=null}return t}function Wn(e){if(!e||!e.startContainer||!e.endContainer)return!1;var t=s.getEditable?s.getEditable():null;if(!t)return!1;var r=e.startContainer.nodeType===3?e.startContainer.parentNode:e.startContainer,i=e.endContainer.nodeType===3?e.endContainer.parentNode:e.endContainer;return!!(r&&i&&t.contains(r)&&t.contains(i))}function $n(e,t){if(!e&&!t)return!0;if(!Wn(e)||!Wn(t))return!1;try{return e.compareBoundaryPoints(e.START_TO_START,t)===0&&e.compareBoundaryPoints(e.END_TO_END,t)===0}catch{return!1}}function Za(e,t){if(!e||!e.range||!Wn(e.range))return!1;var r=e.range.cloneRange();t&&r.collapse(!1),s.focus();var i=s.getSelection?s.getSelection():null;return i?(i.removeAllRanges?i.removeAllRanges():i.empty&&i.empty(),i.addRange(r),!0):!1}function en(e){var t=R(e);if(!t)return"";for(var r=t.split(/\n{2,}/),i=[],a=0;a<r.length;a++)i.push("<p>"+s.htmlEncode(r[a]).replace(/\n/g,"<br/>")+"</p>");return i.join("")}function Nr(e){var t=R(e);return t?s.htmlEncode(t).replace(/\n/g,"<br/>"):""}function fe(e){return s.htmlEncode(e||"")}function _i(e){return s.htmlEncode(e||"").replace(/\n/g," ")}function Iu(e){return/<(p|div|h1|h2|h3|h4|h5|h6|ul|ol|li|table|thead|tbody|tr|td|th|blockquote|pre|section|article)\b/i.test(e||"")}function Ue(){return s.__aiSuggestions||(s.__aiSuggestions=[]),s.__aiSuggestions}function Ui(){return s.__aiReviewLogEntries||(s.__aiReviewLogEntries=[]),s.__aiReviewLogEntries}function tn(){return k.aiToolkitPersistenceKey?"RTE.AIToolkit."+k.aiToolkitPersistenceKey:""}function rn(){return k.aiToolkitPersistenceKey||""}function ns(e){return e?{id:e.id||"log-"+new Date().getTime()+"-"+Math.floor(Math.random()*1e3),documentKey:e.documentKey||rn(),eventType:e.eventType||"suggestion-updated",suggestionId:e.suggestionId||"",status:e.status||"",suggestionType:We(e.suggestionType||""),language:e.language||"",sourceLabel:e.sourceLabel||"",originalText:R(e.originalText||""),resultText:R(e.resultText||""),reason:R(e.reason||""),timestamp:e.timestamp||new Date().getTime()}:null}function ls(e){switch(e.eventType){case"suggestion-created":return"Created";case"suggestion-accepted":return"Accepted";case"suggestion-rejected":return"Rejected";case"suggestion-reopened":return"Reopened";case"suggestion-stale":return"Marked stale";default:return"Updated"}}function Hu(e){if(!e)return"updated";switch(e.eventType){case"suggestion-created":return"created";case"suggestion-accepted":return"accepted";case"suggestion-rejected":return"rejected";case"suggestion-reopened":return"reopened";case"suggestion-stale":return"stale";default:return"updated"}}function ju(e){return e?ls(e)+" - "+(e.sourceLabel||"AI review"):""}function Du(e,t){return ns({id:"log-"+t.id+"-"+e+"-"+new Date().getTime(),documentKey:rn(),eventType:e,suggestionId:t.id,status:t.status||"",suggestionType:t.suggestionType||"",language:t.language||"",sourceLabel:t.sourceLabel||(t.snapshot&&t.snapshot.hasSelection?"Selection suggestion":"Document suggestion"),originalText:t.originalText||"",resultText:t.resultText||"",reason:t.reason||"",timestamp:new Date().getTime()})}function Ou(e){if(e){var t=Ui();t.unshift(e),t.length>30&&(t.length=30)}}function an(e,t,r,i){if(!t||!window.XMLHttpRequest)return typeof i=="function"&&i(null),!1;try{var a=new XMLHttpRequest;return a.open(e,t,!0),a.setRequestHeader("X-Requested-With","XMLHttpRequest"),r&&a.setRequestHeader("Content-Type","application/json; charset=utf-8"),a.onreadystatechange=function(){a.readyState===4&&typeof i=="function"&&i(a)},a.send(r||null),!0}catch{return typeof i=="function"&&i(null),!1}}function Fi(e,t){var r=k.aiToolkitReviewLogUrl||"";if(!r||!t||!rn())return!1;var i=Du(e,t);return Ou(i),an("POST",r,JSON.stringify(i),function(a){(!a||a.status<200||a.status>=300)&&console.warn("AI review log request failed")}),!0}function ss(e,t){var r=k.aiToolkitReviewLogUrl||"",i=rn();return!r||!i?(typeof t=="function"&&t(Ui().slice(),!1),!1):!e&&s.__aiReviewLogLoaded?(typeof t=="function"&&t(Ui().slice(),!0),!0):(an("GET",r+"?key="+encodeURIComponent(i),null,function(a){var l=[],n=!!(a&&a.status>=200&&a.status<300);if(n)try{for(var u=JSON.parse(a.responseText||"{}"),c=u&&u.entries?u.entries:[],f=0;f<c.length;f++){var p=ns(c[f]);p&&l.push(p)}}catch{}s.__aiReviewLogEntries=l,s.__aiReviewLogLoaded=n,typeof t=="function"&&t(l.slice(),n)}),!0)}function Gu(e){return{id:e.id,changeType:e.changeType||"ai-preview",author:e.author?{id:e.author.id||"ai",name:e.author.name||"AI",color:e.author.color||"#8b5cf6"}:{id:"ai",name:"AI",color:"#8b5cf6"},originalHtml:e.originalHtml||"",originalText:e.originalText||"",resultText:e.resultText||"",resultHtml:e.resultHtml||"",reason:e.reason||"",suggestionType:e.suggestionType||"",language:e.language||"",isBlock:!!e.isBlock,status:e.status||"pending",createdAt:e.createdAt||new Date().getTime(),decidedAt:e.decidedAt||0,sourceLabel:e.sourceLabel||"",scope:e.snapshot&&e.snapshot.hasSelection?"selection":"document",text:e.text||"",blockPath:e.blockPath||"",replies:Array.isArray(e.replies)?e.replies:[]}}function nn(e){if(!e)return"";e=String(e),typeof s.sanitizeHtml=="function"&&(e=s.sanitizeHtml(e));for(var t=new DOMParser().parseFromString("<body>"+e+"</body>","text/html"),r=t.body.querySelectorAll("[style]"),i=0;i<r.length;i++){var a=r[i].style;/^(fixed|sticky)$/i.test(a.position)&&(a.removeProperty("position"),a.removeProperty("z-index"),r[i].getAttribute("style")||r[i].removeAttribute("style"))}return t.body.innerHTML}function Uu(e){if(!e||!e.id)return null;var t=e.changeType||"ai-preview",r=e.author&&typeof e.author=="object"?e.author:null;return r||(r=t==="ai-preview"?{id:"ai",name:"AI",color:"#8b5cf6"}:{id:"user",name:"User",color:"#2563eb"}),{id:e.id,changeType:t,author:{id:r.id||"user",name:r.name||r.id||"User",color:r.color||"#2563eb"},originalHtml:nn(e.originalHtml),originalText:e.originalText||"",resultText:e.resultText||"",resultHtml:nn(e.resultHtml),reason:e.reason||"",suggestionType:e.suggestionType||"",language:e.language||"",isBlock:!!e.isBlock,status:e.status||"pending",createdAt:e.createdAt||new Date().getTime(),decidedAt:e.decidedAt||0,sourceLabel:e.sourceLabel||"",snapshot:e.snapshot||{hasSelection:e.scope==="selection"},text:e.text||"",blockPath:e.blockPath||"",replies:Array.isArray(e.replies)?e.replies:[]}}function os(e){if(!e||!e.id)return null;var t=e.changeType||"ai-preview",r=e.author&&typeof e.author=="object"?e.author:null;return r||(r=t==="ai-preview"?{id:"ai",name:"AI",color:"#8b5cf6"}:{id:"user",name:"User",color:"#2563eb"}),{id:e.id,changeType:t,author:{id:r.id||"user",name:r.name||r.id||"User",color:r.color||"#2563eb"},originalHtml:nn(e.originalHtml)||Nr(e.originalText||""),originalText:R(e.originalText||""),resultText:R(e.resultText||""),resultHtml:nn(e.resultHtml)||Nr(e.resultText||""),reason:R(e.reason||""),suggestionType:We(e.suggestionType||""),language:e.language||"",isBlock:!!e.isBlock,status:e.status==="accepted"||e.status==="rejected"||e.status==="stale"?e.status:"stale",createdAt:e.createdAt||new Date().getTime(),decidedAt:e.decidedAt||0,sourceLabel:e.sourceLabel||(e.scope==="selection"?"Selection suggestion":"Document suggestion"),snapshot:{hasSelection:e.scope==="selection"},text:e.text||"",blockPath:e.blockPath||"",replies:Array.isArray(e.replies)?e.replies:[]}}function Bn(){return k.aiToolkitPersistenceKey||""}function Fu(){return{version:"2026-04-18",documentKey:Bn(),savedAt:new Date().getTime(),suggestions:Ue().map(Gu)}}function us(e){switch(e){case"pending":return 4;case"accepted":return 3;case"rejected":return 2;case"stale":return 1;default:return 0}}function Ki(e){return Math.max(e&&e.decidedAt||0,e&&e.createdAt||0)}function Xn(e){return e?{id:e.id,originalHtml:e.originalHtml||"",originalText:e.originalText||"",resultText:e.resultText||"",resultHtml:e.resultHtml||"",reason:e.reason||"",suggestionType:e.suggestionType||"",language:e.language||"",isBlock:!!e.isBlock,status:e.status||"stale",createdAt:e.createdAt||0,decidedAt:e.decidedAt||0,sourceLabel:e.sourceLabel||"",snapshot:{hasSelection:!!(e.snapshot&&e.snapshot.hasSelection)}}:null}function Ku(e,t){if(!e)return Xn(t);if(!t)return e;var r=Ki(e),i=Ki(t);return i>r?Xn(t):i<r?e:us(t.status)>us(e.status)?Xn(t):e}function Nu(e,t){var r={},i=[],a;function l(u){!u||!u.id||(r[u.id]||i.push(u.id),r[u.id]=Ku(r[u.id],u))}for(a=0;a<e.length;a++)l(e[a]);for(a=0;a<t.length;a++)l(t[a]);var n=[];for(a=0;a<i.length;a++)r[i[a]]&&n.push(r[i[a]]);return n.sort(function(u,c){return Ki(c)-Ki(u)}),n}function Qu(){var e=tn(),t="";if(e&&window.localStorage)try{t=window.localStorage.getItem(e)||""}catch{}if(!t){var r=Ri();r&&r.getAttribute&&(t=r.getAttribute("data-rte-ai-ledger")||"")}return t}function cs(e,t){var r=k.aiToolkitSuggestionLedgerUrl||"";return!r||!e||!e.documentKey?(typeof t=="function"&&t(null),!1):an("POST",r,JSON.stringify(e),t)}function zu(){var e=parseInt(k.aiToolkitReviewSyncInterval,10);return e>=5e3?e:15e3}function Ju(){return s.__aiReviewLastSyncedAt||0}function Vu(e){s.__aiReviewLastSyncedAt=e||new Date().getTime()}function ds(){return s.__aiReviewSyncState||(s.__aiReviewSyncState={phase:Li()?"idle":"local",message:""}),s.__aiReviewSyncState}function fs(){if(!Li())return{subtitle:"Queued AI suggestions for this session.",badge:"Local",badgeClass:"is-local",buttonText:"Sync now",buttonDisabled:!0,syncing:!1};var e=ds();if(e.phase==="syncing")return{subtitle:e.message||"Syncing shared AI review...",badge:"Syncing",badgeClass:"is-syncing",buttonText:"Syncing...",buttonDisabled:!0,syncing:!0};if(e.phase==="error")return{subtitle:e.message||"Shared AI review sync failed. Try again.",badge:"Retry",badgeClass:"is-error",buttonText:"Retry sync",buttonDisabled:!1,syncing:!1};var t=Ju();if(!t)return{subtitle:"Shared AI review sync is ready.",badge:"Shared",badgeClass:"is-shared",buttonText:"Sync now",buttonDisabled:!1,syncing:!1};var r=Math.max(0,Math.round((new Date().getTime()-t)/1e3));return r<5?{subtitle:"Shared AI review synced just now.",badge:"Live",badgeClass:"is-live",buttonText:"Sync now",buttonDisabled:!1,syncing:!1}:r<60?{subtitle:"Shared AI review synced "+r+"s ago.",badge:"Live",badgeClass:"is-live",buttonText:"Sync now",buttonDisabled:!1,syncing:!1}:{subtitle:"Shared AI review synced "+Math.round(r/60)+"m ago.",badge:"Live",badgeClass:"is-live",buttonText:"Sync now",buttonDisabled:!1,syncing:!1}}function ln(e,t){var r=ds();r.phase=e||(Li()?"idle":"local"),r.message=t||"",vs()}function Li(){return!!(k.aiToolkitSuggestionLedgerUrl||k.aiToolkitReviewLogUrl)}function Wu(){return fs().subtitle}function vs(){if(!s.__aiReviewPanel||!s.__aiReviewPanel.isConnected)return!1;var e=fs();return s.__aiReviewSubtitleNode&&(s.__aiReviewSubtitleNode.textContent=e.subtitle),s.__aiReviewSyncBadgeNode&&(s.__aiReviewSyncBadgeNode.className="rte-ai-review-sync-badge "+e.badgeClass,s.__aiReviewSyncBadgeNode.textContent=e.badge),s.__aiReviewSyncButton&&(s.__aiReviewSyncButton.textContent=e.buttonText,s.__aiReviewSyncButton.disabled=!!e.buttonDisabled,e.syncing?s.__aiReviewSyncButton.setAttribute("aria-busy","true"):s.__aiReviewSyncButton.removeAttribute("aria-busy")),!0}function $u(e,t){var r={},i=[],a;for(a=0;a<e.length;a++)e[a]&&e[a].id&&(r[e[a].id]=!0);for(a=0;a<t.length;a++)t[a]&&t[a].id&&!r[t[a].id]&&i.push(t[a]);return i}function Bu(e){if(!e||!e.length)return!1;var t=Mt();t.unseenRemoteActivityCount+=e.length,t.latestRemoteActivity=e[0],t.latestRemoteSuggestionId=e[0]&&e[0].suggestionId?e[0].suggestionId:t.latestRemoteSuggestionId;for(var r=0;r<e.length;r++)e[r]&&e[r].suggestionId&&tc(e[r].suggestionId);return!0}function ps(e){return(e||[]).slice().sort(function(t,r){var i=Qt(t.id),a=Qt(r.id);if(i!==a)return a-i;if(s.__aiActiveSuggestionId){if(t.id===s.__aiActiveSuggestionId)return-1;if(r.id===s.__aiActiveSuggestionId)return 1}return Ki(r)-Ki(t)})}function Xu(){for(var e=Ue().slice(),t=!1,r=0;r<e.length;r++){var i=e[r],a=Lr(i.id),l=Zn(i.id);if(i.status==="pending"){l&&(l.outerHTML=hl(i),t=!0);continue}if(i.status==="accepted"||i.status==="rejected"||i.status==="stale"){var n=sn(i,i.status);a?(a.outerHTML=n,t=!0):l&&((l.getAttribute("data-rte-ai-resolved-status")||"")!==i.status||l.innerHTML!==(i.status==="accepted"?i.resultHtml||Nr(i.resultText||""):i.originalHtml||Nr(i.originalText||"")))&&(l.outerHTML=n,t=!0)}}return cr(),t}function ni(e,t){if(!Li())return typeof t=="function"&&t(Ue().slice()),!1;if(s.__aiReviewSyncInFlight)return typeof t=="function"&&(s.__aiReviewSyncCallbacks||(s.__aiReviewSyncCallbacks=[]),s.__aiReviewSyncCallbacks.push(t)),e&&(s.__aiReviewSyncPending=!0),ln("syncing","Syncing shared AI review..."),!0;s.__aiReviewSyncInFlight=!0,s.__aiReviewSyncPending=!1,s.__aiReviewSyncCallbacks=typeof t=="function"?[t]:[],ln("syncing","Syncing shared AI review...");var r=0,i=Ue().slice(),a=!1,l=Ui().slice(),n=!!s.__aiReviewLogLoaded;function u(){if(r--,!(r>0)){s.__aiReviewSyncInFlight=!1,a?ln("error","Shared AI review sync failed. Showing the last known state."):(Vu(new Date().getTime()),ln("idle")),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&pe(!1);var c=s.__aiReviewSyncCallbacks?s.__aiReviewSyncCallbacks.slice():[];s.__aiReviewSyncCallbacks=[];for(var f=0;f<c.length;f++)c[f](i.slice());s.__aiReviewSyncPending&&(s.__aiReviewSyncPending=!1,ni(!0))}}return k.aiToolkitSuggestionLedgerUrl&&(r++,hs(e,function(c,f){i=c||Ue().slice(),f||(a=!0),Xu(),u()})),k.aiToolkitReviewLogUrl&&(r++,ss(e,function(c,f){f?n&&Bu($u(l,c||[])):a=!0,u()})),r>0}function hs(e,t){var r=k.aiToolkitSuggestionLedgerUrl||"",i=Bn();return!r||!i?(typeof t=="function"&&t(Ue().slice(),!1),!1):!e&&s.__aiSuggestionLedgerLoaded?(typeof t=="function"&&t(Ue().slice(),!0),!0):(an("GET",r+"?key="+encodeURIComponent(i),null,function(a){var l=[],n=!!(a&&a.status>=200&&a.status<300);if(n)try{for(var u=JSON.parse(a.responseText||"{}"),c=u&&u.suggestions?u.suggestions:[],f=0;f<c.length;f++){var p=os(c[f]);p&&l.push(p)}}catch{}var g=Nu(Ue(),l);s.__aiSuggestions=g,s.__aiSuggestionLedgerLoaded=n,wt({skipRemote:!0}),typeof t=="function"&&t(g.slice(),n)}),!0)}function bf(){s.__aiReviewSyncTimer&&(window.clearInterval(s.__aiReviewSyncTimer),s.__aiReviewSyncTimer=null)}function Yu(){return!Li()||s.__aiReviewSyncTimer||!window.setInterval?!1:(s.__aiReviewSyncTimer=window.setInterval(function(){document&&document.hidden||ni(!0)},zu()),!0)}function Zu(){s.__aiReviewSyncEventsBound||(s.__aiReviewSyncEventsBound=!0,document&&document.addEventListener&&document.addEventListener("visibilitychange",function(){document.hidden||ni(!0)}),window&&window.addEventListener&&window.addEventListener("focus",function(){ni(!0)}))}function wt(e){e=e||{};var t=Fu(),r=JSON.stringify(t),i=Ri();i&&i.setAttribute&&i.setAttribute("data-rte-ai-ledger",r);var a=tn();if(a&&window.localStorage)try{window.localStorage.setItem(a,r)}catch{}return e.skipRemote||cs(t,function(l){(!l||l.status<200||l.status>=300)&&console.warn("AI suggestion ledger request failed")}),r}function gs(){var e=Qu();if(!e)return s.__aiSuggestions=[],un(),$e(null),[];try{for(var t=JSON.parse(e),r=t&&t.suggestions?t.suggestions:[],i=[],a=0;a<r.length;a++){var l=os(r[a]);l&&i.push(l)}return s.__aiSuggestions=i,ac(),$e(null),i.slice()}catch{return s.__aiSuggestions=[],un(),$e(null),[]}}function ec(){s.__aiSuggestions=[],un(),$e(null);var e=Ri();e&&e.removeAttribute&&e.removeAttribute("data-rte-ai-ledger");var t=tn();if(t&&window.localStorage)try{window.localStorage.removeItem(t)}catch{}return s.__aiSuggestionLedgerLoaded=!1,cs({version:"2026-04-18",documentKey:Bn(),savedAt:new Date().getTime(),suggestions:[]},function(){}),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&pe(!1),!0}function Mt(){return s.__aiReviewState||(s.__aiReviewState={showResolved:!1,typeFilter:"all",unseenRemoteActivityCount:0,latestRemoteActivity:null,latestRemoteSuggestionId:"",remoteSuggestionIds:{}}),s.__aiReviewState}function Yn(){var e=Mt();e.unseenRemoteActivityCount=0,e.latestRemoteActivity=null,e.latestRemoteSuggestionId="",e.remoteSuggestionIds={}}function tc(e){if(!e)return!1;var t=Mt();return t.remoteSuggestionIds[e]=(t.remoteSuggestionIds[e]||0)+1,!0}function ha(e){var t=Mt();return e&&t.remoteSuggestionIds[e]?(delete t.remoteSuggestionIds[e],!0):!1}function Qt(e){var t=Mt();return e&&t.remoteSuggestionIds[e]||0}function rc(){return Mt().latestRemoteSuggestionId||""}function ic(){var e=Mt();if(!e.unseenRemoteActivityCount)return null;var t=e.latestRemoteActivity,r=e.unseenRemoteActivityCount;return{count:r,title:r===1?"1 shared review update just arrived.":r+" shared review updates just arrived.",detail:t?ju(t):"Shared AI review activity is newer than your local view."}}function he(e){for(var t=Ue(),r=0;r<t.length;r++)if(t[r].id===e)return t[r];return null}function Lr(e){var t=s.getEditable?s.getEditable():null;return t?t.querySelector('[data-rte-ai-suggestion-id="'+e+'"]'):null}function Zn(e){var t=s.getEditable?s.getEditable():null;return t?t.querySelector('[data-rte-ai-resolved-id="'+e+'"]'):null}function sn(e,t){if(!e)return"";var r=t||e.status||"accepted",i=e.isBlock?"div":"span",a=r==="accepted"?e.resultHtml||Nr(e.resultText||""):e.originalHtml||Nr(e.originalText||"");return"<"+i+' class="rte-ai-resolved-suggestion is-'+_i(r)+(e.isBlock?" is-block":" is-inline")+'" data-rte-ai-resolved-id="'+_i(e.id)+'" data-rte-ai-resolved-status="'+_i(r)+'">'+a+"</"+i+">"}function Ni(){return s.__aiReviewDecisionHistory||(s.__aiReviewDecisionHistory=[]),s.__aiReviewDecisionHistory}function ac(){for(var e=Ni(),t=e.length-1;t>=0;t--){var r=e[t],i=r&&r.suggestionId?he(r.suggestionId):null;(!i||i.status!==r.status)&&e.splice(t,1)}return e}function wf(){var e=Ni();return e.length?e[e.length-1]:null}function el(e,t,r){if(r=r||{},!e||!e.id||!t)return un(),null;r.clearRedo!==!1&&ws();var i=Ni();return i.push({suggestionId:e.id,status:t,timestamp:new Date().getTime()}),i.length>12&&i.splice(0,i.length-12),i[i.length-1]}function ms(){var e=Ni();return e.length?e.pop():null}function on(){return s.__aiReviewRedoHistory||(s.__aiReviewRedoHistory=[]),s.__aiReviewRedoHistory}function nc(e,t){if(!e||!e.id||!t)return null;var r=on();return r.push({suggestionId:e.id,status:t,timestamp:new Date().getTime()}),r.length>12&&r.splice(0,r.length-12),r[r.length-1]}function bs(){var e=on();return e.length?e.pop():null}function ws(){s.__aiReviewRedoHistory=[]}function un(){s.__aiReviewDecisionHistory=[],ws()}function li(){for(var e=Ni();e.length;){var t=e[e.length-1];if(!t||!t.suggestionId){e.pop();continue}var r=he(t.suggestionId),i=Zn(t.suggestionId);if(!r||!i||r.status!==t.status){e.pop();continue}return{suggestion:r,wrapper:i,status:t.status,timestamp:t.timestamp||0,historyCount:e.length,remainingCount:e.length-1}}return null}function Rr(){for(var e=on();e.length;){var t=e[e.length-1];if(!t||!t.suggestionId){e.pop();continue}var r=he(t.suggestionId),i=Lr(t.suggestionId);if(!r||!i||r.status!=="pending"){e.pop();continue}return{suggestion:r,wrapper:i,status:t.status,timestamp:t.timestamp||0,historyCount:e.length,remainingCount:e.length-1}}return null}function kt(e){if(e=e||li(),!e||!e.suggestion)return{actionLabel:"Undo last",shortcutLabel:"undo last",decisionLabel:"last",typeLabel:"",detailLabel:"last suggestion",summaryText:""};var t=e.suggestion,r=e.status==="rejected"?"rejected":e.status==="accepted"?"accepted":"resolved",i=t.suggestionType&&t.suggestionType!=="other"?Pe(t.suggestionType).toLowerCase():"";return{actionLabel:"Undo "+r+(i?" "+i:"")+(e.remainingCount?" ("+e.remainingCount+" more)":""),shortcutLabel:"undo "+r,decisionLabel:r,typeLabel:i,detailLabel:r+" "+(i?i+" ":"")+"suggestion",summaryText:Be(t.originalText||t.resultText||"suggestion",72),remainingCount:e.remainingCount||0}}function ga(e){var t=kt(e);return!e||!e.suggestion?"":"Undo target: "+t.detailLabel+(t.summaryText?" - "+t.summaryText:"")+(t.remainingCount?". "+t.remainingCount+" earlier undo"+(t.remainingCount===1?" remains.":"s remain."):"")}function cn(e){var t=Ct(e);return!e||!e.suggestion?"":"Redo target: "+t.detailLabel+(t.summaryText?" - "+t.summaryText:"")+(t.remainingCount?". "+t.remainingCount+" earlier redo"+(t.remainingCount===1?" remains.":"s remain."):"")}function Ct(e){if(e=e||Rr(),!e||!e.suggestion)return{actionLabel:"Redo last",shortcutLabel:"redo last",decisionLabel:"last",detailLabel:"last suggestion",summaryText:"",remainingCount:0};var t=e.suggestion,r=e.status==="rejected"?"rejected":e.status==="accepted"?"accepted":"resolved",i=t.suggestionType&&t.suggestionType!=="other"?Pe(t.suggestionType).toLowerCase():"";return{actionLabel:"Redo "+r+(i?" "+i:"")+(e.remainingCount?" ("+e.remainingCount+" more)":""),shortcutLabel:"redo "+r,decisionLabel:r,detailLabel:r+" "+(i?i+" ":"")+"suggestion",summaryText:Be(t.originalText||t.resultText||"suggestion",72),remainingCount:e.remainingCount||0}}function tl(e){for(var t=Ni(),r=[],i=typeof e=="number"?e:3,a=t.length-2;a>=0&&r.length<i;a--){var l=t[a];if(!(!l||!l.suggestionId)){var n=he(l.suggestionId),u=Zn(l.suggestionId);if(!(!n||!u||n.status!==l.status)){var c={suggestion:n,wrapper:u,status:l.status,timestamp:l.timestamp||0,historyCount:a+1,remainingCount:a},f=kt(c);r.push({label:f.actionLabel,detail:ga(c)})}}}return r}function rl(e){for(var t=on(),r=[],i=typeof e=="number"?e:3,a=t.length-2;a>=0&&r.length<i;a--){var l=t[a];if(!(!l||!l.suggestionId)){var n=he(l.suggestionId),u=Lr(l.suggestionId);if(!(!n||!u||n.status!=="pending")){var c={suggestion:n,wrapper:u,status:l.status,timestamp:l.timestamp||0,historyCount:a+1,remainingCount:a},f=Ct(c);r.push({label:f.actionLabel,detail:f.detailLabel+(f.summaryText?" - "+f.summaryText:"")})}}}return r}function ys(e,t,r){if(!e||!t||!t.length)return null;var i=o(e,"div","","rte-ai-review-item-history"+(r?" is-"+r:""));o(i,"div","","rte-ai-review-item-history-title","Then");for(var a=0;a<t.length;a++){var l=t[a],n=o(i,"div","","rte-ai-review-item-history-item");o(n,"div","","rte-ai-review-item-history-label",l.label),o(n,"div","","rte-ai-review-item-history-detail",l.detail)}return i}function dn(e,t,r){if(!e||!e.setAttribute)return"";if(e.id)return e.id;var i=String(r||"item").replace(/[^A-Za-z0-9\-_:.]/g,"-");return e.id="rte-ai-review-"+t+"-"+i,e.id}function ma(e){if(!e||!e.focus)return!1;try{return e.focus({preventScroll:!0}),!0}catch{try{return e.focus(),!0}catch{return!1}}}function il(e,t){if(!e||!t||!e.querySelector)return!1;var r=e.querySelector('[data-rte-ai-action="'+t+'"]');if(r&&!r.disabled&&r.focus)try{return r.focus({preventScroll:!0}),!0}catch{try{return r.focus(),!0}catch{}}return!1}function lc(e,t){if(!e)return!1;var r=Lr(e);return r?il(r,t)?!0:ma(r):!1}function al(e){if(!e)return"";var t=Rr();return e.status==="pending"&&t&&t.suggestion&&t.suggestion.id===e.id?"redo":e.status==="pending"?"accept":"review"}function fn(e,t){var r=he(e);if(!r)return!1;var i=Lr(e),a=al(r),l=t||a;if(i&&(il(i,l)||a&&a!==l&&il(i,a)))return!0;var n=a&&a!==l?a:l;return gi(e,{focusPanel:!0,focusAction:n==="review"?"":n})}function As(e,t,r,i){if(!e)return null;if(!r)return t&&t.parentNode&&t.parentNode.removeChild(t),null;t||(t=document.createElement("span"),t.className="rte-ai-inline-preview-remote"),t.textContent=r>1?r+" shared updates":"Shared update",t.setAttribute("aria-label","Shared AI review updates");var a=i&&i.parentNode===e?i:e.querySelector?e.querySelector(".rte-ai-inline-preview-actions"):null;return a&&a.parentNode===e?a.nextSibling!==t&&(a.nextSibling?e.insertBefore(t,a.nextSibling):e.appendChild(t)):t.parentNode!==e&&e.appendChild(t),t}function Qi(){s.__aiBindInlinePreviewEventHandlers&&s.__aiBindInlinePreviewEventHandlers();var e=s.getEditable?s.getEditable():null;if(!e||!e.querySelectorAll)return!1;for(var t=e.querySelectorAll("[data-rte-ai-suggestion-id]"),r=li(),i=Rr(),a=0;a<t.length;a++){var l=t[a].getAttribute("data-rte-ai-suggestion-id")||"",n=he(l),u=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-current"):null,c=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-opened"):null,f=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-type"):null,p=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-language"):null,g=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-scope"):null,m=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-remote"):null,b=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-queue"):null,h=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-transition"):null,y=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-followup"):null,A=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-glance"):null,K=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-reason"):null,S=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-plan"):null,q=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-undo"):null,M=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-undo-next"):null,P=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-redo"):null,L=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-redo-next"):null,D=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-shortcuts"):null,J=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-launch"):null,E=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-focus"):null,W=t[a].querySelector?t[a].querySelector('[data-rte-ai-action="review"]'):null,de=t[a].querySelector?t[a].querySelector('[data-rte-ai-action="previous"]'):null,$=t[a].querySelector?t[a].querySelector('[data-rte-ai-action="next"]'):null,I=t[a].querySelector?t[a].querySelector('[data-rte-ai-action="accept"]'):null,le=t[a].querySelector?t[a].querySelector('[data-rte-ai-action="reject"]'):null,Z=t[a].querySelector?t[a].querySelector('[data-rte-ai-action="undo"]'):null,se=t[a].querySelector?t[a].querySelector('[data-rte-ai-action="redo"]'):null,B=t[a].querySelector?t[a].querySelector('[data-rte-ai-action="shared-seen"]'):null,j=Qt(l),G=!!(s.__aiReviewEmptyPreviewSuggestionId&&l===s.__aiReviewEmptyPreviewSuggestionId),xe=!!(!G&&s.__aiRecentlyOpenedQueueSuggestionId&&l===s.__aiRecentlyOpenedQueueSuggestionId),ue=!G&&r?kt(r):null,X=!G&&r?ga(r):"",De=G?[]:tl(1),Re=De.length?De[0]:null,we=!!(!G&&i&&i.suggestion&&i.suggestion.id===l&&n&&n.status==="pending"),Te=we?Ct(i):null,Xe=we?cn(i):"",pt=we?rl(1):[],Me=pt.length?pt[0]:null,Ke=G?je(n,F()):"",ge=je(n,F())||je(n,""),z=G?"Open this AI review queue"+(ge?" and focus "+ge:""):"Open this AI suggestion in review"+(ge?" and focus "+ge:""),Q=Gt(l),qe=G?{index:0,total:0}:kn(Q,l),Ye=G?[]:Je(Q),V=G?null:La(Ye,s.__aiActiveSuggestionId,n),U=G?null:fi(Ye,s.__aiActiveSuggestionId,n),ae=G?null:Wi(n),ye=G?null:Aa(ae),C=vi(n),me=G?"":Oo(l),N=G?"":ra(l),ee=me?"Previous AI review item":"No previous AI review item in the current queue",Ae=N?"Next AI review item":"No next AI review item in the current queue";if(s.__aiActiveSuggestionId&&l===s.__aiActiveSuggestionId){t[a].classList.add("is-review-active"),t[a].classList.toggle("is-review-preview",G),t[a].classList.toggle("is-queue-opened",xe),G?(t[a].setAttribute("role","button"),t[a].removeAttribute("aria-current"),t[a].setAttribute("aria-keyshortcuts","Enter Space"),t[a].setAttribute("tabindex","0"),t[a].title=Vl(n)):(t[a].setAttribute("role","group"),t[a].setAttribute("aria-current","step"),t[a].setAttribute("aria-keyshortcuts",(j?"ArrowLeft ArrowRight Home End J K A R G Enter Space":"ArrowLeft ArrowRight Home End J K A R Enter Space")+(ue?" U":"")+(we?" Shift+U":"")),t[a].setAttribute("tabindex","0"),t[a].title=uc({suggestion:n,sharedUpdateCount:j,undoInlineContext:ue,redoInlineContext:Te}));var Se=hi(n,"accept",Q)||{text:"Accept",label:"Accept this AI change"},_e=hi(n,"reject",Q)||{text:"Reject",label:"Reject this AI change"},Oe=Se.label,oe=_e.label,xt=X||"Undo the last AI review decision",Ne=Xe||"Redo the last AI review decision",_t={isPreviewTarget:G,sharedUpdateCount:j,undoInlineContext:ue,redoInlineContext:Te};Qr(W,G?"Open queue":"Review",z),ba(de,!me,ee),ba($,!N,Ae),Qr(I,Se.text,Oe),Qr(le,_e.text,oe),ui(W,z,_t),ui(de,ee,_t),ui($,Ae,_t),ui(I,Oe,_t),ui(le,oe,_t);var tt=sl(t[a],"recovery");if(ue?(Z||(Z=document.createElement("button"),Z.type="button",Z.className="rte-ai-inline-preview-button is-undo",Z.setAttribute("data-rte-ai-action","undo"),tt&&tt.appendChild(Z)),Qr(Z,ue.actionLabel,xt),ui(Z,xt,_t)):Z&&Z.parentNode&&(Z.parentNode.removeChild(Z),Z=null),we&&Te?(se||(se=document.createElement("button"),se.type="button",se.className="rte-ai-inline-preview-button is-redo",se.setAttribute("data-rte-ai-action","redo"),tt&&tt.appendChild(se)),Qr(se,Te.actionLabel,Ne),ui(se,Ne,_t)):se&&se.parentNode&&(se.parentNode.removeChild(se),se=null),!u){u=document.createElement("span"),u.className="rte-ai-inline-preview-current";var vr=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-actions"):null;vr&&vr.nextSibling?t[a].insertBefore(u,vr.nextSibling):t[a].appendChild(u)}if(u.classList.toggle("is-preview-target",G),u.textContent=G?"Next queue":"Current",u.setAttribute("aria-label",G?"Next AI review queue target":"Current AI review item"),xe?(c||(c=document.createElement("span"),c.className="rte-ai-inline-preview-opened",u&&u.nextSibling?t[a].insertBefore(c,u.nextSibling):t[a].appendChild(c)),c.textContent="Queue opened",c.setAttribute("aria-label","AI review queue opened")):c&&c.parentNode&&c.parentNode.removeChild(c),G)if(J||(J=document.createElement("span"),J.className="rte-ai-inline-preview-launch",u&&u.nextSibling?t[a].insertBefore(J,u.nextSibling):t[a].appendChild(J)),J.textContent=Jl(n),J.setAttribute("aria-hidden","true"),Ke){if(!E){E=document.createElement("span"),E.className="rte-ai-inline-preview-focus";var ir=J||u;ir&&ir.nextSibling?t[a].insertBefore(E,ir.nextSibling):t[a].appendChild(E)}E.textContent="Focus "+Ke,E.setAttribute("aria-label","Queue opens on "+Ke)}else E&&E.parentNode&&E.parentNode.removeChild(E);else J&&J.parentNode&&J.parentNode.removeChild(J),E&&E.parentNode&&E.parentNode.removeChild(E);if(n&&n.suggestionType&&We(n.suggestionType)!=="other"?(f||(f=document.createElement("span"),f.className="rte-ai-inline-preview-type",u&&u.nextSibling?t[a].insertBefore(f,u.nextSibling):t[a].appendChild(f)),f.textContent=Pe(n.suggestionType),f.setAttribute("aria-label","AI suggestion type")):f&&f.parentNode&&f.parentNode.removeChild(f),n&&n.language){if(!p){p=document.createElement("span"),p.className="rte-ai-inline-preview-language";var ht=f||u;ht&&ht.nextSibling?t[a].insertBefore(p,ht.nextSibling):t[a].appendChild(p)}p.textContent=lt(n.language),p.setAttribute("aria-label","AI suggestion language")}else p&&p.parentNode&&p.parentNode.removeChild(p);var ke=Fr(n);if(ke){if(!g){g=document.createElement("span"),g.className="rte-ai-inline-preview-scope";var Ce=p||f||u;Ce&&Ce.nextSibling?t[a].insertBefore(g,Ce.nextSibling):t[a].appendChild(g)}g.textContent=ke,g.setAttribute("aria-label","AI suggestion scope")}else g&&g.parentNode&&g.parentNode.removeChild(g);m=As(t[a],m,j,g||p||f||u||(t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-actions"):null));var zt=sl(t[a],"recovery");if(j?(B||(B=document.createElement("button"),B.type="button",B.className="rte-ai-inline-preview-button is-shared",B.setAttribute("data-rte-ai-action","shared-seen"),zt&&zt.appendChild(B)),B.textContent="Got it",B.setAttribute("aria-label","Clear shared AI review update notice"),B.title="Clear shared AI review update notice",ui(B,"Clear shared AI review update notice",_t)):B&&B.parentNode&&(B.parentNode.removeChild(B),B=null),_s(t[a],"recovery",!!(ue||we&&Te||j)),ul(t[a],{suggestion:n,isPreviewTarget:G,sharedUpdateCount:j,undoInlineContext:ue,redoInlineContext:Te,queueTransitionData:U,undoInlineSummaryText:X,redoInlineSummaryText:Xe}),cl(t[a],{suggestion:n,isPreviewTarget:G,sharedUpdateCount:j,undoInlineContext:ue,redoInlineContext:Te,queueTransitionData:U,undoInlineSummaryText:X,redoInlineSummaryText:Xe}),Cs(t[a],{suggestion:n,isPreviewTarget:G,sharedUpdateCount:j,undoInlineContext:ue,redoInlineContext:Te}),qe.total&&qe.index){if(!b){b=document.createElement("span"),b.className="rte-ai-inline-preview-queue";var gt=m||g||p||f||u||(t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-current"):null);if(gt&>.nextSibling)t[a].insertBefore(b,gt.nextSibling);else if(gt)t[a].appendChild(b);else{var mt=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-actions"):null;mt&&mt.nextSibling?t[a].insertBefore(b,mt.nextSibling):t[a].appendChild(b)}}b.textContent="Item "+qe.index+" of "+qe.total,b.setAttribute("aria-label","Current AI review queue position")}else b&&b.parentNode&&b.parentNode.removeChild(b);if(U){if(!h){h=document.createElement("span"),h.className="rte-ai-inline-preview-transition";var qi=b||m||g||p||f||u;qi&&qi.nextSibling?t[a].insertBefore(h,qi.nextSibling):t[a].appendChild(h)}if(h.textContent=U.statusLabel+" - "+U.queueLabel,h.setAttribute("aria-label",U.title+". "+U.detail+" "+Vr(U)),U.followupTitle){if(!y){y=document.createElement("span"),y.className="rte-ai-inline-preview-followup";var ar=h||b||m||g||p||f||u;ar&&ar.nextSibling?t[a].insertBefore(y,ar.nextSibling):t[a].appendChild(y)}y.textContent=U.followupTitle,y.setAttribute("aria-label",U.followupTitle+". "+U.followupDetail)}else y&&y.parentNode&&y.parentNode.removeChild(y)}else h&&h.parentNode&&h.parentNode.removeChild(h),y&&y.parentNode&&y.parentNode.removeChild(y);if(ue){if(!q){q=document.createElement("span"),q.className="rte-ai-inline-preview-undo";var Xr=y||h||b||m||g||p||f||u;Xr&&Xr.nextSibling?t[a].insertBefore(q,Xr.nextSibling):t[a].appendChild(q)}q.textContent=ue.actionLabel,q.setAttribute("aria-label",X)}else q&&q.parentNode&&q.parentNode.removeChild(q);if(Re){if(!M){M=document.createElement("span"),M.className="rte-ai-inline-preview-undo-next";var Fe=q||b||m||g||p||f||u;Fe&&Fe.nextSibling?t[a].insertBefore(M,Fe.nextSibling):t[a].appendChild(M)}M.textContent="Then "+Re.label,M.setAttribute("aria-label","Undo after this: "+Re.detail)}else M&&M.parentNode&&M.parentNode.removeChild(M);if(we&&Te){if(!P){P=document.createElement("span"),P.className="rte-ai-inline-preview-redo";var Cr=M||q||b||m||g||p||f||u;Cr&&Cr.nextSibling?t[a].insertBefore(P,Cr.nextSibling):t[a].appendChild(P)}P.textContent=Te.actionLabel,P.setAttribute("aria-label",Xe)}else P&&P.parentNode&&P.parentNode.removeChild(P);if(Me){if(!L){L=document.createElement("span"),L.className="rte-ai-inline-preview-redo-next";var Jt=P||M||q||b||m||g||p||f||u;Jt&&Jt.nextSibling?t[a].insertBefore(L,Jt.nextSibling):t[a].appendChild(L)}L.textContent="Then "+Me.label,L.setAttribute("aria-label","Redo after this: "+Me.detail)}else L&&L.parentNode&&L.parentNode.removeChild(L);if(G){if(!D){D=document.createElement("span"),D.className="rte-ai-inline-preview-shortcuts";var nr=L||P||M||q||b||m||g||p||f||u;nr&&nr.nextSibling?t[a].insertBefore(D,nr.nextSibling):t[a].appendChild(D)}D.textContent=Ba(n),D.setAttribute("aria-label","Inline queue preview shortcut")}else if(!D){D=document.createElement("span"),D.className="rte-ai-inline-preview-shortcuts";var Yr=L||P||M||q||b||m||g||p||f||u;Yr&&Yr.nextSibling?t[a].insertBefore(D,Yr.nextSibling):t[a].appendChild(D)}var rt={isPreviewTarget:G,sharedUpdateCount:j,undoInlineContext:ue,redoInlineContext:Te,suggestion:n},It=zi(rt);D.id=fc(t[a]),Ji(D,G?"preview":"wrapper",rt),vc(t[a],D,rt),si(W,t[a],D,"review",rt),si(de,t[a],D,"previous",rt),si($,t[a],D,"next",rt),si(I,t[a],D,"accept",rt),si(le,t[a],D,"reject",rt),si(Z,t[a],D,"undo",rt),si(se,t[a],D,"redo",rt),si(B,t[a],D,"shared-seen",rt);var pr=t[a].ownerDocument?t[a].ownerDocument.activeElement:null,mi=pr&&t[a].contains(pr)&&pr.getAttribute&&pr.getAttribute("data-rte-ai-action")||"";Ji(D,G?"preview":mi||"wrapper",rt),qs(t[a],n),vl(t[a],n),pl(t[a],ye),K=dl(t[a],K,n),S=Es(t[a],S,n),D=fl(t[a],D),t[a].setAttribute("aria-label",Qn(n,{isCurrent:!G,isPreviewTarget:G,queueOpened:xe,glanceLabels:ae?ae.pills.map(function(wr){return wr.text}):[],glanceDetail:ae?ae.detail:"",compareLabel:"Proposed edit. Current and suggested text.",reasonText:C,focusLabel:It,positionLabel:qe.total&&qe.index?"Item "+qe.index+" of "+qe.total:"",transitionLabel:U?U.statusLabel+". "+U.queueLabel+". "+Vr(U):"",followupLabel:U&&U.followupTitle?U.followupTitle+". "+U.followupDetail:"",remoteUpdateCount:j,undoLabel:X,undoNextLabel:Re?"Undo after this: "+Re.detail:"",redoLabel:Xe,redoNextLabel:Me?"Redo after this: "+Me.detail:""}))}else{t[a].classList.remove("is-review-active"),t[a].classList.remove("is-review-preview"),t[a].classList.remove("is-queue-opened"),t[a].setAttribute("role","group"),t[a].removeAttribute("aria-current"),t[a].removeAttribute("aria-keyshortcuts"),t[a].setAttribute("tabindex","-1"),t[a].removeAttribute("title"),t[a].onfocus=null,t[a].onfocusout=null,xs(t[a]),vl(t[a],n),pl(t[a],ye),K=dl(t[a],K,n),S=Es(t[a],S,n),t[a].setAttribute("aria-label",Qn(n,{remoteUpdateCount:j,glanceLabels:ae?ae.pills.map(function(wr){return wr.text}):[],glanceDetail:ae?ae.detail:"",compareLabel:"Proposed edit. Current and suggested text.",reasonText:C,focusLabel:ge,queueRoleLabel:V?V.roleLabel:"",queueRoleDetail:V?V.detail:"",transitionLabel:U?U.title+". "+U.statusLabel+". "+U.queueLabel+". "+Vr(U):"",followupLabel:U&&U.followupTitle?U.followupTitle+". "+U.followupDetail:""}));var hr=Gt(l),Pt=hi(n,"accept",hr)||{text:"Accept",label:"Accept this AI change"},Zr=hi(n,"reject",hr)||{text:"Reject",label:"Reject this AI change"};if(Qr(W,"Review",z),ba(de,!me,ee),ba($,!N,Ae),U&&/queue state/i.test(U.previewLabel||"")&&ba($,!0,"No next AI review item in the current queue"),Qr(I,Pt.text,Pt.label),Qr(le,Zr.text,Zr.label),ci(W),ci(de),ci($),ci(I),ci(le),ci(Z),ci(se),ci(B),oi(W),oi(de),oi($),oi(I),oi(le),oi(Z),oi(se),oi(B),Z&&Z.parentNode&&Z.parentNode.removeChild(Z),se&&se.parentNode&&se.parentNode.removeChild(se),B&&B.parentNode&&B.parentNode.removeChild(B),_s(t[a],"recovery",!1),ul(t[a],{suggestion:n,isPreviewTarget:G,sharedUpdateCount:j,queueTransitionData:U}),cl(t[a],{suggestion:n,isPreviewTarget:G,sharedUpdateCount:j,queueTransitionData:U}),Cs(t[a],{suggestion:n,isPreviewTarget:G,sharedUpdateCount:j}),u&&u.parentNode&&u.parentNode.removeChild(u),c&&c.parentNode&&c.parentNode.removeChild(c),J&&J.parentNode&&J.parentNode.removeChild(J),f&&f.parentNode&&f.parentNode.removeChild(f),p&&p.parentNode&&p.parentNode.removeChild(p),g&&g.parentNode&&g.parentNode.removeChild(g),m=As(t[a],m,j,t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-actions"):null),!G&&ge){if(!E){E=document.createElement("span"),E.className="rte-ai-inline-preview-focus";var Er=m||g||p||f||u;Er&&Er.nextSibling?t[a].insertBefore(E,Er.nextSibling):t[a].appendChild(E)}E.textContent="Focus "+ge,E.setAttribute("aria-label","Review opens on "+ge)}else E&&E.parentNode&&(E.parentNode.removeChild(E),E=null);if(!G&&ae&&ae.pills&&ae.pills.length){if(!A){A=document.createElement("span"),A.className="rte-ai-inline-preview-glance";var Pr=g||f||u;Pr&&Pr.nextSibling?t[a].insertBefore(A,Pr.nextSibling):t[a].appendChild(A)}for(;A.firstChild;)A.removeChild(A.firstChild);for(var Ht=0;Ht<ae.pills.length;Ht++){var ot=ae.pills[Ht];!ot||!ot.text||ot.kind==="scope"||o(A,"span","","rte-ai-review-item-glance-pill is-"+ot.kind,ot.text)}!A.childNodes.length&&A.parentNode&&(A.parentNode.removeChild(A),A=null)}else A&&A.parentNode&&(A.parentNode.removeChild(A),A=null);if(!G&&V&&V.role!=="current"){if(!b){b=document.createElement("span"),b.className="rte-ai-inline-preview-queue";var Vt=E||m||A||g||p||f||u;Vt&&Vt.nextSibling?t[a].insertBefore(b,Vt.nextSibling):t[a].appendChild(b)}b.textContent=V.roleLabel+" - "+V.queueLabel,b.setAttribute("aria-label",V.detail)}else b&&b.parentNode&&(b.parentNode.removeChild(b),b=null);if(!G&&U){if(!h){h=document.createElement("span"),h.className="rte-ai-inline-preview-transition";var ei=b||E||m||A||g||p||f||u;ei&&ei.nextSibling?t[a].insertBefore(h,ei.nextSibling):t[a].appendChild(h)}if(h.textContent=U.statusLabel,h.setAttribute("aria-label",U.title+". "+U.detail+" "+Vr(U)),U.followupTitle){if(!y){y=document.createElement("span"),y.className="rte-ai-inline-preview-followup";var lr=h||b||E||m||g||p||f||u;lr&&lr.nextSibling?t[a].insertBefore(y,lr.nextSibling):t[a].appendChild(y)}y.textContent=U.followupTitle,y.setAttribute("aria-label",U.followupTitle+". "+U.followupDetail)}else y&&y.parentNode&&(y.parentNode.removeChild(y),y=null)}else h&&h.parentNode&&(h.parentNode.removeChild(h),h=null),y&&y.parentNode&&(y.parentNode.removeChild(y),y=null);q&&q.parentNode&&q.parentNode.removeChild(q),M&&M.parentNode&&M.parentNode.removeChild(M),P&&P.parentNode&&P.parentNode.removeChild(P),L&&L.parentNode&&L.parentNode.removeChild(L),D&&D.parentNode&&D.parentNode.removeChild(D)}s.__aiActiveSuggestionId!==l&&!G&&((!D||!D.parentNode)&&(D=document.createElement("span"),D.className="rte-ai-inline-preview-shortcuts",t[a].appendChild(D)),Ji(D,"wrapper",{suggestion:n,isPreviewTarget:G,sharedUpdateCount:j}),D=fl(t[a],D));var ut=!0,gr=[f,g,b,h,y,A,E,m];G&&gr.push(u,c,J);for(var Mr=0;Mr<gr.length;Mr++)gr[Mr]&&gr[Mr].style&&(gr[Mr].style.display=ut?"none":"");var mr=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-compare"):null,br=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-actions"):null;t[a].style&&(t[a].style.display=ut?"flex":"",t[a].style.flexDirection=ut?"column":"",t[a].style.cursor=G?"pointer":""),mr&&mr.style&&(mr.style.order=ut?"1":""),br&&br.style&&(br.style.order=ut?"2":"",br.style.display=G?"none":"")}return!0}function Qr(e,t,r){return e?(typeof t=="string"&&t.length&&(e.textContent=t),r&&(e.setAttribute("aria-label",r),e.title=r),!0):!1}function sc(e,t){if(t=t||{},t.isPreviewTarget)return"Enter Space";switch(e){case"previous":return"Enter Space K ArrowLeft";case"next":return"Enter Space J ArrowRight";case"accept":return"Enter Space A";case"reject":return"Enter Space R";case"undo":return t.undoInlineContext?"Enter Space U":"Enter Space";case"redo":return t.redoInlineContext?"Enter Space Shift+U":"Enter Space";case"shared-seen":return t.sharedUpdateCount?"Enter Space G":"Enter Space";default:return"Enter Space"}}function oc(e,t,r){r=r||{};var i=t||"";if(!i)return i;if(i=i.replace(/\.$/,""),r.isPreviewTarget)return i+". Enter or Space activates this action.";var a=Ut(r.suggestion);switch(i+=". Enter or Space activates this action.",e){case"previous":i+=" K or Left moves to the previous review item.";break;case"next":i+=" J or Right moves to the next review item.";break;case"accept":i+=" A uses "+a.acceptLabel+".";break;case"reject":i+=" R uses "+a.rejectLabel+".";break;case"undo":r.undoInlineContext&&(i+=" U "+r.undoInlineContext.shortcutLabel+".");break;case"redo":r.redoInlineContext&&(i+=" Shift+U "+r.redoInlineContext.shortcutLabel+".");break;case"shared-seen":r.sharedUpdateCount&&(i+=" G clears shared.");break}return i}function Ss(e){if(e=e||{},e.isPreviewTarget)return Ba(e.suggestion);var t=Ut(e.suggestion),r=zi(e),i="Enter focus "+r+" - A "+t.acceptHint+" - R "+t.rejectHint+" - J/K move - Home/End jump";return e.sharedUpdateCount&&(i+=" - G clear shared"),e.undoInlineContext&&(i+=" - U "+e.undoInlineContext.shortcutLabel),e.redoInlineContext&&(i+=" - Shift+U "+e.redoInlineContext.shortcutLabel),i}function uc(e){if(e=e||{},e.isPreviewTarget)return Vl(e.suggestion);var t=Ut(e.suggestion),r=zi(e),i="Shortcuts: J or Right next, K or Left previous, Home/End jump, Enter focus "+r+", A "+t.acceptHint+", R "+t.rejectHint;return e.sharedUpdateCount&&(i+=", G clear shared"),e.undoInlineContext&&(i+=", U "+e.undoInlineContext.shortcutLabel),e.redoInlineContext&&(i+=", Shift+U "+e.redoInlineContext.shortcutLabel),i}function nl(e){if(e=e||{},e.isPreviewTarget)return"review";var t=e.suggestion;if(!t)return"";var r=e.preferredAction||F();if((r==="accept"||r==="reject")&&t.status==="pending")return r;if(r==="undo"&&e.undoInlineContext)return"undo";if(r==="redo"&&e.redoInlineContext)return"redo";if(r==="review")return"review";if(r==="shared-seen"&&e.sharedUpdateCount)return"shared-seen";var i=e.defaultActionName||al(t);return i==="redo"&&e.redoInlineContext?"redo":i==="accept"?"accept":"review"}function cc(e){switch(e){case"accept":case"reject":return"decision";case"undo":case"redo":case"shared-seen":return"recovery";case"review":return"review";default:return""}}function zi(e){e=e||{};var t=e.suggestion;if(!t)return"Review";if(e.isPreviewTarget)return"Open queue";var r=Ut(t),i=nl(e);return i==="accept"?r.acceptLabel:i==="reject"?r.rejectLabel:i==="undo"&&e.undoInlineContext?e.undoInlineContext.actionLabel||"Undo":i==="redo"&&e.redoInlineContext?e.redoInlineContext.actionLabel||"Redo":i==="review"?"Review":i==="shared-seen"&&e.sharedUpdateCount?"Clear shared":"Review"}function dc(e,t){if(t=t||{},t.isPreviewTarget)return Ba(t.suggestion);var r="",i=Ut(t.suggestion),a=i.acceptLabel,l=i.rejectLabel,n=t.reviewFocusLabel||je(t.suggestion,F())||je(t.suggestion,"");switch(e){case"review":r="Enter focus "+(n||"Review")+" - J/K move - Home/End jump - A "+i.acceptHint+" - R "+i.rejectHint;break;case"previous":r="Enter previous - J/K move - Home/End jump - A "+i.acceptHint+" - R "+i.rejectHint;break;case"next":r="Enter next - J/K move - Home/End jump - A "+i.acceptHint+" - R "+i.rejectHint;break;case"accept":r="Enter "+a+" - R "+i.rejectHint+" - J/K move - Home/End jump";break;case"reject":r="Enter "+l+" - A "+i.acceptHint+" - J/K move - Home/End jump";break;case"undo":r="Enter undo - A "+i.acceptHint+" - R "+i.rejectHint+" - J/K move - Home/End jump";break;case"redo":r="Enter redo - A "+i.acceptHint+" - R "+i.rejectHint+" - J/K move - Home/End jump";break;case"shared-seen":r="Enter clear shared - A "+i.acceptHint+" - R "+i.rejectHint+" - J/K move - Home/End jump";break;default:return Ss(t)}return t.undoInlineContext&&(r+=" - U "+t.undoInlineContext.shortcutLabel),t.sharedUpdateCount&&e!=="shared-seen"&&(r+=" - G clear shared"),t.redoInlineContext&&(r+=" - Shift+U "+t.redoInlineContext.shortcutLabel),r}function fc(e){return e?(e.__rteAiInlineShortcutDisplayId||(e.__rteAiInlineShortcutDisplayId="rte-ai-inline-shortcuts-"+String(Math.floor(Math.random()*1e9))),e.__rteAiInlineShortcutDisplayId):""}function vn(e,t){if(!e||!e.setAttribute||!t)return!1;var r=t.id||"";return r?(e.setAttribute("aria-describedby",r),!0):!1}function xs(e){return!e||!e.removeAttribute?!1:(e.removeAttribute("aria-describedby"),!0)}function ll(e,t,r){if(!e)return!1;for(;e.firstChild;)e.removeChild(e.firstChild);if(!t&&!r)return!0;var i=e.ownerDocument||document;if(t){var a=i.createElement("span");a.className="rte-ai-inline-preview-shortcuts-title",a.innerText=t,e.appendChild(a)}if(!r)return!0;var l=i.createElement("span");l.className="rte-ai-inline-preview-shortcuts-body",e.appendChild(l);for(var n=String(r||"").split(/(\s+·\s+|\s+-\s+)/),u=0;u<n.length;u++){var c=n[u];if(c){if(/^\s+[·-]\s+$/.test(c)){var f=i.createElement("span");f.className="rte-ai-inline-preview-shortcuts-separator",f.innerText=c.replace(/^\s+|\s+$/g,""),l.appendChild(f);continue}var p=i.createElement("span");p.className="rte-ai-inline-preview-shortcuts-segment";var g=c.replace(/^\s+|\s+$/g,""),m=g.indexOf(" ");if(m>0){var b=i.createElement("span");b.className="rte-ai-inline-preview-shortcuts-key",b.innerText=g.substring(0,m),p.appendChild(b),p.appendChild(i.createTextNode(" "));var h=i.createElement("span");h.className="rte-ai-inline-preview-shortcuts-copy",h.innerText=g.substring(m+1),p.appendChild(h)}else p.innerText=g;l.appendChild(p)}}return!0}function Ji(e,t,r){return e?(r=r||{},e.classList.remove("is-action"),e.classList.toggle("is-preview",t==="preview"),t==="preview"?(ll(e,"Queue shortcut",Ba(r.suggestion)),e.setAttribute("aria-label","Inline queue preview shortcut"),!0):t&&t!=="wrapper"?(e.classList.add("is-action"),ll(e,"Keyboard guide",dc(t,r)),e.setAttribute("aria-label","Inline AI review action shortcuts"),!0):(ll(e,"Keyboard guide",Ss(r)),e.setAttribute("aria-label","Inline AI review shortcuts"),!0)):!1}function vc(e,t,r){return e?(vn(e,t),e.onfocus=function(){vn(e,t),Ji(t,r&&r.isPreviewTarget?"preview":"wrapper",r)},e.onfocusout=function(){var i=e,a=t,l=r||{};window.setTimeout(function(){var n=i.ownerDocument||document;i.contains(n.activeElement)||Ji(a,l.isPreviewTarget?"preview":"wrapper",l)},0)},!0):!1}function si(e,t,r,i,a){return e?(vn(e,r),e.onfocus=function(){vn(e,r),Ji(r,i,a)},!0):!1}function oi(e){return e?(e.onfocus=null,xs(e),!0):!1}function ui(e,t,r){if(!e)return!1;var i=e.getAttribute&&e.getAttribute("data-rte-ai-action")||"";return e.setAttribute("aria-keyshortcuts",sc(i,r)),e.title=oc(i,t,r),!0}function ci(e){return e?(e.removeAttribute("aria-keyshortcuts"),!0):!1}function ba(e,t,r){return e?(e.disabled=!!t,e.setAttribute("aria-disabled",t?"true":"false"),r&&(e.setAttribute("aria-label",r),e.title=r),t?e.classList.add("is-disabled"):e.classList.remove("is-disabled"),!0):!1}function $e(e,t){t=t||{},s.__aiActiveSuggestionId=e||null,s.__aiPreviewState=e?he(e):null,t.preserveEmptyPreview?s.__aiReviewEmptyPreviewSuggestionId=s.__aiActiveSuggestionId:s.__aiReviewEmptyPreviewSuggestionId=null,Qi()}function di(){return s.__aiActiveSuggestionId?he(s.__aiActiveSuggestionId):s.__aiPreviewState||null}function wa(){for(var e=Ue(),t=!1,r=!1,i=0;i<e.length;i++)e[i].status==="pending"&&!Lr(e[i].id)&&(e[i].status="stale",e[i].decidedAt=e[i].decidedAt||new Date().getTime(),Fi("suggestion-stale",e[i]),r=!0),s.__aiActiveSuggestionId&&e[i].id===s.__aiActiveSuggestionId&&e[i].status==="pending"&&(t=!0);t||$e(null),r&&wt()}function cr(){wa()}function Be(e,t){var r=R(e),i=t||90;return r.length<=i?r:r.substring(0,Math.max(0,i-3)).replace(/\s+\S*$/,"")+"..."}function ya(e){switch(e){case"accepted":return"Accepted";case"rejected":return"Rejected";case"stale":return"Needs refresh";default:return"Pending"}}function pn(e,t,r){var i=!r&&e==="recovery"?' style="display:none"':"";return'<span class="rte-ai-inline-preview-action-group is-'+e+'" data-rte-ai-inline-action-group="'+e+'" data-rte-ai-inline-action-group-label="'+fe(t)+'" data-rte-ai-inline-action-group-current="false"'+i+' role="group" aria-label="'+fe(t)+' actions"><span class="rte-ai-inline-preview-action-group-header"><span class="rte-ai-inline-preview-action-group-title">'+fe(t)+'</span><span class="rte-ai-inline-preview-action-group-badge" style="display:none"></span></span><span class="rte-ai-inline-preview-action-group-detail"></span><span class="rte-ai-inline-preview-action-group-body">'+(r||"")+"</span></span>"}function sl(e,t){if(!e||!e.querySelector)return null;if(t){var r=e.querySelector(".rte-ai-inline-preview-action-group.is-"+t+" .rte-ai-inline-preview-action-group-body");if(r)return r}return e.querySelector(".rte-ai-inline-preview-actions")}function _s(e,t,r){if(!(!e||!e.querySelector||!t)){var i=e.querySelector(".rte-ai-inline-preview-action-group.is-"+t);i&&(i.style.display=r?"":"none")}}function Ls(e){if(e=e||{},e.isPreviewTarget)return"review";var t=e.suggestion;return t?cc(nl(e)):""}function pc(e){switch(e){case"review":return"Open";case"move":return"Move";case"decision":return"Decide";case"recovery":return"Recover";default:return""}}function Rs(e,t){var r=["review","move","decision","recovery"],i=r.indexOf(e);if(i===-1)return r.length+1;var a=r.indexOf(t);if(a===-1)return i+1;if(e===t)return 1;for(var l=2,n=0;n<r.length;n++)if(r[n]!==t){if(r[n]===e)return l;l++}return i+1}function Ts(e,t,r){var i;switch(e){case"review":i=["review"];break;case"move":i=["previous","next"];break;case"decision":i=["accept","reject"];break;case"recovery":i=["shared-seen","undo","redo"];break;default:i=[];break}var a=i.indexOf(t);if(a===-1)return i.length+1;if(!r)return a+1;var l=i.indexOf(r);if(l===-1)return a+1;if(t===r)return 1;for(var n=2,u=0;u<i.length;u++)if(i[u]!==r){if(i[u]===t)return n;n++}return a+1}function hc(e,t){if(t=t||{},t.isPreviewTarget)return e==="review"?"Open the next review queue from this handoff surface.":"";var r=t.suggestion;if(!r)return"";var i=t.queueTransitionData||null;if(!i&&r){var a=Gt(r.id);i=fi(Je(a),s.__aiActiveSuggestionId,r)}switch(e){case"review":return"Reopen this suggestion in the current review lane.";case"move":return"Jump earlier or later in this queue before deciding.";case"decision":return i&&i.detail?i.detail:"Apply or dismiss this AI change.";case"recovery":return t.redoInlineContext&&t.redoInlineSummaryText?t.redoInlineSummaryText:t.undoInlineContext&&t.undoInlineSummaryText?t.undoInlineSummaryText:t.sharedUpdateCount?"Clear collaboration updates and keep reviewing this suggestion.":"";default:return""}}function ks(e){if(e=e||{},e.isPreviewTarget)return null;var t=e.suggestion;if(!t)return null;var r=Ls(e),i=zi(e),a=pc(r);if(!r||!i||!a)return null;var l=e.queueTransitionData||null;if(!l&&t.id){var n=Gt(t.id),u=Je(n);l=fi(u,s.__aiActiveSuggestionId,t)}var c="";return r==="decision"&&l?c=l.statusLabel+". "+l.detail:r==="recovery"?e.preferredAction==="undo"&&e.undoInlineSummaryText?c=e.undoInlineSummaryText:e.preferredAction==="redo"&&e.redoInlineSummaryText?c=e.redoInlineSummaryText:e.sharedUpdateCount?c="Clear the shared update notice and continue reviewing this suggestion.":c="Recover from a recent AI review action without leaving this suggestion.":r==="review"?c="Open this suggestion in review and keep the current inline lane ready.":r==="move"&&(c="Move through the current queue before choosing a decision."),{title:"Action handoff",pills:[a+" lane","Enter focuses "+i],detail:c}}function ol(e){if(!e)return"";var t=[];if(e.title&&t.push(e.title),e.pills&&e.pills.length)for(var r=0;r<e.pills.length;r++)e.pills[r]&&t.push(e.pills[r]);return e.detail&&t.push(e.detail),t.join(". ")}function gc(e){var t=ks({suggestion:e});if(!t)return"";var r='<span class="rte-ai-inline-preview-action-summary" aria-label="'+fe(ol(t))+'"><span class="rte-ai-inline-preview-action-summary-title">'+fe(t.title)+"</span>";if(t.pills&&t.pills.length){r+='<span class="rte-ai-inline-preview-action-summary-pills">';for(var i=0;i<t.pills.length;i++)t.pills[i]&&(r+='<span class="rte-ai-inline-preview-action-summary-pill">'+fe(t.pills[i])+"</span>");r+="</span>"}return t.detail&&(r+='<span class="rte-ai-inline-preview-action-summary-detail">'+fe(t.detail)+"</span>"),r+="</span>",r}function ul(e,t){if(!e||!e.querySelector)return null;var r=e.querySelector(".rte-ai-inline-preview-actions"),i=ks(t),a=r&&r.querySelector?r.querySelector(".rte-ai-inline-preview-action-summary"):null;if(!r||!i)return a&&a.parentNode&&a.parentNode.removeChild(a),r&&r.setAttribute("aria-label","AI suggestion actions"),null;var l=r.ownerDocument||document;for(a?r.firstChild!==a&&r.insertBefore(a,r.firstChild):(a=l.createElement("span"),a.className="rte-ai-inline-preview-action-summary",r.firstChild?r.insertBefore(a,r.firstChild):r.appendChild(a));a.firstChild;)a.removeChild(a.firstChild);if(a.setAttribute("aria-label",ol(i)),o(a,"span","","rte-ai-inline-preview-action-summary-title",i.title),i.pills&&i.pills.length)for(var n=o(a,"span","","rte-ai-inline-preview-action-summary-pills"),u=0;u<i.pills.length;u++)i.pills[u]&&o(n,"span","","rte-ai-inline-preview-action-summary-pill",i.pills[u]);return i.detail&&o(a,"span","","rte-ai-inline-preview-action-summary-detail",i.detail),r.setAttribute("aria-label","AI suggestion actions. "+ol(i)),a}function cl(e,t){if(!e||!e.querySelectorAll)return!1;t=t||{};for(var r=e.ownerDocument||document,i=e.querySelector?e.querySelector(".rte-ai-inline-preview-actions"):null,a=Ls(t),l=t.isPreviewTarget?"Open queue":zi(t),n=l?"Enter: "+l:"",u=e.querySelectorAll(".rte-ai-inline-preview-action-group"),c=[],f=0;f<u.length;f++){var p=u[f];if(p){c.push(p);var g=p.getAttribute("data-rte-ai-inline-action-group")||"",m=p.getAttribute("data-rte-ai-inline-action-group-label")||"",b=p.querySelector?p.querySelector(".rte-ai-inline-preview-action-group-header"):null;b||(b=r.createElement("span"),b.className="rte-ai-inline-preview-action-group-header",p.firstChild?p.insertBefore(b,p.firstChild):p.appendChild(b));var h=b.querySelector?b.querySelector(".rte-ai-inline-preview-action-group-title"):null;h||(h=r.createElement("span"),h.className="rte-ai-inline-preview-action-group-title",b.appendChild(h)),h.textContent=m;var y=b.querySelector?b.querySelector(".rte-ai-inline-preview-action-group-badge"):null;y||(y=r.createElement("span"),y.className="rte-ai-inline-preview-action-group-badge",b.appendChild(y));var A=p.querySelector?p.querySelector(".rte-ai-inline-preview-action-group-detail"):null;if(!A){A=r.createElement("span"),A.className="rte-ai-inline-preview-action-group-detail";var K=p.querySelector?p.querySelector(".rte-ai-inline-preview-action-group-body"):null;K?p.insertBefore(A,K):p.appendChild(A)}var S=!!n&&!!a&&a===g,q=hc(g,t);p.style.removeProperty("order"),p.setAttribute("data-rte-ai-inline-action-group-current",S?"true":"false"),p.classList.toggle("is-current-lane",S),S?(y.textContent=n,y.style.display="",y.setAttribute("aria-label","Current action lane. "+n)):(y.textContent="",y.style.display="none",y.removeAttribute("aria-label")),q?(A.textContent=q,A.style.display=""):(A.textContent="",A.style.display="none");var M=m?m+" actions":"AI suggestion actions";q&&(M+=". "+q),S&&n&&(M+=". Current lane. "+n),p.setAttribute("aria-label",M)}}if(i&&c.length){c.sort(function(L,D){var J=L.getAttribute("data-rte-ai-inline-action-group")||"",E=D.getAttribute("data-rte-ai-inline-action-group")||"";return Rs(J,a)-Rs(E,a)});for(var P=0;P<c.length;P++)i.appendChild(c[P])}return!0}function Cs(e,t){if(!e||!e.querySelectorAll)return!1;t=t||{};for(var r=nl(t),i={},a=e.querySelectorAll(".rte-ai-inline-preview-button[data-rte-ai-action]"),l=0;l<a.length;l++){var n=a[l];if(!(!n||!n.getAttribute)){var u=n.getAttribute("data-rte-ai-action")||"",c=n.closest?n.closest(".rte-ai-inline-preview-action-group"):null,f=c&&c.getAttribute&&c.getAttribute("data-rte-ai-inline-action-group")||"";f&&(i[f]||(i[f]=[]),i[f].push(n));var p=!!r&&u===r&&!n.disabled,g=(n.getAttribute("aria-label")||n.textContent||"").replace(/\.\s*Current Enter target\.$/i,""),m=(n.getAttribute("title")||g).replace(/\.\s*Current Enter target\.$/i,"");if(n.setAttribute("data-rte-ai-enter-target",p?"true":"false"),n.classList.toggle("is-enter-target",p),p){var b=u==="accept"?"A":u==="reject"?"R":"";n.setAttribute("aria-keyshortcuts",b?"Enter Space "+b:"Enter Space"),n.setAttribute("data-rte-ai-enter-target-label","Enter"),g&&!/current enter target/i.test(g)&&n.setAttribute("aria-label",g+". Current Enter target."),m&&!/enter or space activates this action/i.test(m)&&(m+=". Enter or Space activates this action",b&&(m+=". "+b+" uses "+(n.textContent||u)+".")),m&&!/current enter target/i.test(m)&&(n.title=m+". Current Enter target.")}else n.removeAttribute("data-rte-ai-enter-target-label"),g&&n.setAttribute("aria-label",g),m&&(n.title=m)}}for(var f in i)if(i.hasOwnProperty(f)){var h=sl(e,f),y=i[f];if(!(!h||!y||!y.length)){y.sort(function(S,q){var M=S.getAttribute("data-rte-ai-action")||"",P=q.getAttribute("data-rte-ai-action")||"";return Ts(f,M,r)-Ts(f,P,r)});for(var A=0;A<y.length;A++)h.appendChild(y[A])}}return!0}function dl(e,t,r){if(!e)return null;var i=e.querySelector?e.querySelector(".rte-ai-inline-preview-compare"):null,a=vi(r);if(!i||!a)return t&&t.parentNode&&t.parentNode.removeChild(t),null;if(!t||t.parentNode!==i){t&&t.parentNode&&t.parentNode.removeChild(t),t=document.createElement("span"),t.className="rte-ai-inline-preview-reason";var l=i.querySelector?i.querySelector(".rte-ai-inline-preview-old"):null,n=!l&&i.querySelector?i.querySelector(".rte-ai-inline-preview-new"):null,u=l||n;u?i.insertBefore(t,u):i.appendChild(t)}var c=t.querySelector?t.querySelector(".rte-ai-inline-preview-reason-label"):null,f=t.querySelector?t.querySelector(".rte-ai-inline-preview-reason-copy"):null;if(!c||!f){for(;t.firstChild;)t.removeChild(t.firstChild);c=null,f=null}return c||(c=document.createElement("span"),c.className="rte-ai-inline-preview-reason-label",t.appendChild(c)),c.textContent="Why",f||(f=document.createElement("span"),f.className="rte-ai-inline-preview-reason-copy",t.appendChild(f)),f.textContent=a,t.setAttribute("aria-label","Why this suggestion: "+a),t.title=a,t}function Es(e,t,r){if(!e)return null;var i=e.querySelector?e.querySelector(".rte-ai-inline-preview-compare"):null,a=Hs(r);if(!i||!a)return t&&t.parentNode&&t.parentNode.removeChild(t),null;for((!t||t.parentNode!==i)&&(t&&t.parentNode&&t.parentNode.removeChild(t),t=document.createElement("span"),t.className="rte-ai-inline-preview-plan",i.appendChild(t));t.firstChild;)t.removeChild(t.firstChild);o(t,"span","","rte-ai-inline-preview-plan-title",a.title);for(var l=o(t,"span","","rte-ai-inline-preview-plan-items"),n=0;n<a.items.length;n++)a.items[n]&&o(l,"span","","rte-ai-inline-preview-plan-item",a.items[n]);if(a.detail&&o(t,"span","","rte-ai-inline-preview-plan-detail",a.detail),mc(t,a),a.followupTitle||a.followupDetail){var u=o(t,"span","","rte-ai-inline-preview-plan-followup");a.followupTitle&&o(u,"span","","rte-ai-inline-preview-plan-followup-title",a.followupTitle),a.followupDetail&&o(u,"span","","rte-ai-inline-preview-plan-followup-detail",a.followupDetail)}return t}function fl(e,t){if(!e||!t)return t;var r=e.querySelector?e.querySelector(".rte-ai-inline-preview-compare"):null;if(!r)return t;var i=r.querySelector?r.querySelector(".rte-ai-inline-preview-plan"):null;return i&&i.parentNode===r?(i.nextSibling!==t&&(i.nextSibling?r.insertBefore(t,i.nextSibling):r.appendChild(t)),t):(r.lastChild!==t&&r.appendChild(t),t)}function vl(e,t){if(!e)return null;var r=e.querySelector?e.querySelector(".rte-ai-inline-preview-compare"):null;if(!r)return null;var i=Is(t),a=r.querySelector?r.querySelector(".rte-ai-inline-preview-compare-meta"):null;if(!i)return a&&a.parentNode&&a.parentNode.removeChild(a),null;if(!a){a=document.createElement("span"),a.className="rte-ai-inline-preview-compare-meta";var l=r.querySelector?r.querySelector(".rte-ai-inline-preview-compare-header"):null;l&&l.nextSibling?r.insertBefore(a,l.nextSibling):r.appendChild(a)}for(;a.firstChild;)a.removeChild(a.firstChild);return o(a,"span","","rte-ai-inline-preview-compare-pill is-status",i.statusLabel),i.openedLabel&&o(a,"span","","rte-ai-inline-preview-compare-pill is-opened",i.openedLabel),i.remoteLabel&&o(a,"span","","rte-ai-inline-preview-compare-pill is-remote",i.remoteLabel),i.entryLabel&&o(a,"span","","rte-ai-inline-preview-compare-pill is-entry",i.entryLabel),i.queueRoleLabel&&o(a,"span","","rte-ai-inline-preview-compare-pill is-queue",i.queueRoleLabel),i.queueLabel&&o(a,"span","","rte-ai-inline-preview-compare-pill is-position",i.queueLabel),i.typeLabel&&o(a,"span","","rte-ai-inline-preview-compare-pill is-type",i.typeLabel),i.languageLabel&&o(a,"span","","rte-ai-inline-preview-compare-pill is-language",i.languageLabel),o(a,"span","","rte-ai-inline-preview-compare-pill is-scope",i.scopeLabel),o(a,"span","","rte-ai-inline-preview-compare-pill is-steps",i.stepLabel),i.targetLabel&&o(a,"span","","rte-ai-inline-preview-compare-pill is-target",i.targetLabel),a}function Aa(e){var t=e&&e.pills?e:Wi(e);if(!t)return null;var r=[];if(t.pills&&t.pills.length)for(var i=0;i<t.pills.length;i++){var a=t.pills[i];!a||!a.text||a.kind==="scope"||r.push(a)}return!r.length&&!t.detail?null:{title:t.title||"Change at a glance",pills:r,detail:t.detail||""}}function pl(e,t){if(!e)return null;var r=e.querySelector?e.querySelector(".rte-ai-inline-preview-compare"):null,i=Aa(t),a=r&&r.querySelector?r.querySelector(".rte-ai-inline-preview-compare-glance"):null;if(!r||!i)return a&&a.parentNode&&a.parentNode.removeChild(a),null;if(!a){a=document.createElement("span"),a.className="rte-ai-inline-preview-compare-glance";var l=r.querySelector?r.querySelector(".rte-ai-inline-preview-old"):null;l?r.insertBefore(a,l):r.appendChild(a)}for(;a.firstChild;)a.removeChild(a.firstChild);if(o(a,"span","","rte-ai-inline-preview-compare-glance-title",i.title),i.pills&&i.pills.length)for(var n=o(a,"span","","rte-ai-inline-preview-compare-glance-pills"),u=0;u<i.pills.length;u++){var c=i.pills[u];!c||!c.text||o(n,"span","","rte-ai-review-item-glance-pill is-"+(c.kind||"other"),c.text)}return i.detail&&o(a,"span","","rte-ai-inline-preview-compare-glance-detail",i.detail),a}function Ps(e,t,r,i){var a=e||"span";return"<"+a+' class="'+t+'" aria-label="'+fe(r)+' text"><span class="rte-ai-inline-preview-compare-label">'+fe(r)+"</span><"+a+' class="rte-ai-inline-preview-compare-text">'+i+"</"+a+"></"+a+">"}function Ms(e){var t=!!(e&&e.id&&s.__aiReviewEmptyPreviewSuggestionId===e.id);return t?{title:"Queue handoff",detail:"Open the next review queue"}:{title:"Proposed edit",detail:"Current and suggested text"}}function qs(e,t){if(!e)return null;var r=e.querySelector?e.querySelector(".rte-ai-inline-preview-compare"):null;if(!r)return null;var i=Ms(t),a=r.querySelector?r.querySelector(".rte-ai-inline-preview-compare-header"):null;a||(a=document.createElement("span"),a.className="rte-ai-inline-preview-compare-header",r.firstChild?r.insertBefore(a,r.firstChild):r.appendChild(a));var l=a.querySelector?a.querySelector(".rte-ai-inline-preview-compare-title"):null,n=a.querySelector?a.querySelector(".rte-ai-inline-preview-compare-detail"):null;return l||(l=document.createElement("span"),l.className="rte-ai-inline-preview-compare-title",a.appendChild(l)),n||(n=document.createElement("span"),n.className="rte-ai-inline-preview-compare-detail",a.appendChild(n)),l.textContent=i.title,n.textContent=i.detail,r.setAttribute("aria-label",i.title+". "+i.detail),a}function Is(e){if(!e)return null;var t=!!(e.id&&s.__aiReviewEmptyPreviewSuggestionId===e.id),r=e.id?Gt(e.id):"",i=e.id?Je(r):[],a=e.id?La(i,s.__aiActiveSuggestionId,e):null,l=e.id?Qt(e.id):0,n=t?je(e,F())||je(e,""):zi({suggestion:e}),u=e.suggestionType&&We(e.suggestionType)!=="other"?Pe(e.suggestionType):"",c=e.language?lt(e.language):"";return{statusLabel:t?"Queue handoff":"Ready to review",openedLabel:s.__aiRecentlyOpenedQueueSuggestionId===e.id?"Queue opened":"",remoteLabel:l>1?l+" shared updates":l?"Shared update":"",queueRoleLabel:t?"Next queue":a?a.roleLabel:"",queueLabel:!t&&a?a.queueLabel:"",typeLabel:u,languageLabel:c,scopeLabel:(Fr(e)||"Selection")+" draft",stepLabel:"1 step",entryLabel:t?Jl(e):"",targetLabel:n?"Focus "+n:""}}function Hs(e){if(!e||!e.id)return null;var t=Gt(e.id),r=Je(t),i=fi(r,s.__aiActiveSuggestionId,e);if(!i)return null;var a=[i.statusLabel,i.queueLabel];return i.followupStatusLabel&&a.push(i.followupStatusLabel),{title:"What happens next",items:a,detail:i.detail||"",previewLabel:i.previewLabel||"",previewText:i.previewText||"",preview:Vr(i),followupTitle:i.followupTitle||"",followupDetail:i.followupDetail||""}}function mc(e,t){if(!e||!t||!t.preview&&!t.previewLabel&&!t.previewText)return null;var r=o(e,"span","","rte-ai-inline-preview-plan-preview");return t.previewLabel&&o(r,"span","","rte-ai-inline-preview-plan-preview-label",t.previewLabel+":"),t.previewText&&o(r,"span","","rte-ai-inline-preview-plan-preview-text",t.previewText),!t.previewLabel&&!t.previewText&&t.preview&&(r.textContent=t.preview),r}function bc(e){if(!e||!e.preview&&!e.previewLabel&&!e.previewText)return"";var t='<span class="rte-ai-inline-preview-plan-preview">';return e.previewLabel&&(t+='<span class="rte-ai-inline-preview-plan-preview-label">'+fe(e.previewLabel)+":</span>"),e.previewText&&(t+='<span class="rte-ai-inline-preview-plan-preview-text">'+fe(e.previewText)+"</span>"),!e.previewLabel&&!e.previewText&&e.preview&&(t+=fe(e.preview)),t+="</span>",t}function wc(e,t,r,i){var a=e||"span",l=Ms(i),n=Is(i),u=Aa(i),c=vi(i),f=Hs(i),p=n?'<span class="rte-ai-inline-preview-compare-meta"><span class="rte-ai-inline-preview-compare-pill is-status">'+fe(n.statusLabel)+"</span>"+(n.openedLabel?'<span class="rte-ai-inline-preview-compare-pill is-opened">'+fe(n.openedLabel)+"</span>":"")+(n.remoteLabel?'<span class="rte-ai-inline-preview-compare-pill is-remote">'+fe(n.remoteLabel)+"</span>":"")+(n.entryLabel?'<span class="rte-ai-inline-preview-compare-pill is-entry">'+fe(n.entryLabel)+"</span>":"")+(n.queueRoleLabel?'<span class="rte-ai-inline-preview-compare-pill is-queue">'+fe(n.queueRoleLabel)+"</span>":"")+(n.queueLabel?'<span class="rte-ai-inline-preview-compare-pill is-position">'+fe(n.queueLabel)+"</span>":"")+(n.typeLabel?'<span class="rte-ai-inline-preview-compare-pill is-type">'+fe(n.typeLabel)+"</span>":"")+(n.languageLabel?'<span class="rte-ai-inline-preview-compare-pill is-language">'+fe(n.languageLabel)+"</span>":"")+'<span class="rte-ai-inline-preview-compare-pill is-scope">'+fe(n.scopeLabel)+'</span><span class="rte-ai-inline-preview-compare-pill is-steps">'+fe(n.stepLabel)+"</span>"+(n.targetLabel?'<span class="rte-ai-inline-preview-compare-pill is-target">'+fe(n.targetLabel)+"</span>":"")+"</span>":"",g="";if(u){if(g='<span class="rte-ai-inline-preview-compare-glance"><span class="rte-ai-inline-preview-compare-glance-title">'+fe(u.title)+"</span>",u.pills&&u.pills.length){g+='<span class="rte-ai-inline-preview-compare-glance-pills">';for(var m=0;m<u.pills.length;m++){var b=u.pills[m];!b||!b.text||(g+='<span class="rte-ai-review-item-glance-pill is-'+fe(b.kind||"other")+'">'+fe(b.text)+"</span>")}g+="</span>"}u.detail&&(g+='<span class="rte-ai-inline-preview-compare-glance-detail">'+fe(u.detail)+"</span>"),g+="</span>"}var h=c?'<span class="rte-ai-inline-preview-reason" aria-label="Why this suggestion: '+fe(c)+'" title="'+fe(c)+'"><span class="rte-ai-inline-preview-reason-label">Why</span><span class="rte-ai-inline-preview-reason-copy">'+fe(c)+"</span></span>":"",y="";if(f){y='<span class="rte-ai-inline-preview-plan"><span class="rte-ai-inline-preview-plan-title">'+fe(f.title)+'</span><span class="rte-ai-inline-preview-plan-items">';for(var A=0;A<f.items.length;A++)f.items[A]&&(y+='<span class="rte-ai-inline-preview-plan-item">'+fe(f.items[A])+"</span>");y+="</span>",f.detail&&(y+='<span class="rte-ai-inline-preview-plan-detail">'+fe(f.detail)+"</span>"),y+=bc(f),(f.followupTitle||f.followupDetail)&&(y+='<span class="rte-ai-inline-preview-plan-followup">',f.followupTitle&&(y+='<span class="rte-ai-inline-preview-plan-followup-title">'+fe(f.followupTitle)+"</span>"),f.followupDetail&&(y+='<span class="rte-ai-inline-preview-plan-followup-detail">'+fe(f.followupDetail)+"</span>"),y+="</span>"),y+="</span>"}return"<"+a+' class="rte-ai-inline-preview-compare" aria-label="'+fe(l.title+". "+l.detail)+'"><span class="rte-ai-inline-preview-compare-header"><span class="rte-ai-inline-preview-compare-title">'+fe(l.title)+'</span><span class="rte-ai-inline-preview-compare-detail">'+fe(l.detail)+"</span></span>"+p+g+h+Ps(a,"rte-ai-inline-preview-old","Current",t)+Ps(a,"rte-ai-inline-preview-new","Suggested",r)+y+"</"+a+">"}function hl(e){var t=!!e.isBlock,r=t?"div":"span",i=t?"div":"span",a=e.originalHtml||Nr(e.originalText||""),l=e.resultHtml||Nr(e.resultText||""),n=pn("review","Open",'<button type="button" class="rte-ai-inline-preview-button is-review" data-rte-ai-action="review">Review</button>'),u=pn("move","Move",'<button type="button" class="rte-ai-inline-preview-button is-previous" data-rte-ai-action="previous">Previous</button><button type="button" class="rte-ai-inline-preview-button is-next" data-rte-ai-action="next">Next</button>'),c=pn("decision","Decide",'<button type="button" class="rte-ai-inline-preview-button is-accept" data-rte-ai-action="accept">Accept</button><button type="button" class="rte-ai-inline-preview-button is-reject" data-rte-ai-action="reject">Reject</button>'),f=pn("recovery","Recover",""),p=gc(e);return"<"+r+' class="rte-ai-inline-preview is-review-surface'+(t?" is-block":" is-inline")+'" contenteditable="false" tabindex="-1" role="group" aria-label="AI suggestion preview" data-rte-ai-preview-id="'+e.id+'" data-rte-ai-suggestion-id="'+e.id+'">'+wc(i,a,l,e)+'<span class="rte-ai-inline-preview-actions" role="group" aria-label="AI suggestion actions">'+p+n+u+c+f+"</span></"+r+">"}function js(e,t){var r=R(e);if(!r)return!1;t=t||{};var i=t.snapshot||st();if(!i||!i.hasSelection)return!1;cr();var a=Iu(i.html),l={id:"ai-preview-"+new Date().getTime(),snapshot:i,originalHtml:i.html,originalText:i.text,resultText:r,resultHtml:a?en(r):Nr(r),reason:t.reason||"",suggestionType:We(t.suggestionType||""),language:t.language||"",isBlock:a,status:"pending",createdAt:new Date().getTime(),sourceLabel:t.sourceLabel||Wl(t.suggestionType||"",i,t.language||"")};if(Ue().push(l),$e(l.id),!Za(i,!1)){var n=Ue();return n.splice(n.length-1,1),$e(null),!1}return s.__aiBindInlinePreviewEventHandlers&&s.__aiBindInlinePreviewEventHandlers(),s.insertHTML(hl(l)),wt(),Fi("suggestion-created",l),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&pe(!1),s.focus(),!0}function yc(e,t){var r=R(e);if(!r)return!1;t=t||{};var i=t.snapshot||st();return cr(),Za(i,!0)||s.focus(),s.insertHTML('<span class="rte-comment-marker" data-comment="'+_i(r)+'" data-rte-comment="'+_i(r)+'" contenteditable="false" style="background:#fff9c4;border:1px solid #f9a825;border-radius:3px;padding:1px 6px;font-size:11px;color:#f57f17;cursor:pointer;" title="'+_i(r)+'" aria-label="'+_i(r)+'">💬 AI Comment</span>'),wa(),wt(),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&pe(!1),s.focus(),!0}function Ac(e){e.classList.add("rte-panel-aiassist-menu");var t=document.createElement("div");t.className="rte-ai-menu-info is-minimal is-detached";var r=o(t,"div","","rte-ai-menu-title-row"),i=o(r,"span","","rte-ai-menu-title-icon");i.innerHTML=k.svgCode_aiassist||"",o(r,"div","","rte-ai-menu-title",k.text_aiassist||"Ask AI");var a=o(e,"div","","rte-ai-menu-search-row"),l=o(a,"span","","rte-ai-menu-search-icon");l.setAttribute("aria-hidden","true"),l.innerHTML='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="10.5" cy="10.5" r="6"/><path d="M19 19l-3.4-3.4"/></svg>';var n=e.ownerDocument.createElement("input");n.type="text",n.className="rte-ai-menu-search-input",n.placeholder="Filter actions\u2026",n.setAttribute("aria-label","Filter AI actions"),n.setAttribute("autocomplete","off"),n.setAttribute("spellcheck","false"),a.appendChild(n);for(var u=zn(),c="",f=[],p=0;p<u.length;p++)(function(h){if(h.section&&h.section!==c){var y=document.createElement("div");y.className="rte-ai-menu-section is-detached",y.textContent=h.section,c=h.section}var A=o(e,"button","","rte-ai-menu-item");A.type="button",h.section&&A.setAttribute("data-section",h.section),h.description&&(A.title=h.description,A.setAttribute("aria-label",(h.title||h.id)+" \u2014 "+h.description));var K=o(A,"span","","rte-ai-menu-item-icon");K.innerHTML=fu(h);var S=o(A,"span","","rte-ai-menu-item-body");o(S,"span","","rte-ai-menu-item-title",h.title||h.id),o(S,"span","","rte-ai-menu-item-copy",h.description||""),A.onclick=function(q){q&&q.preventDefault&&q.preventDefault(),q&&q.stopPropagation&&q.stopPropagation(),s.closeCurrentPopup&&s.closeCurrentPopup(),Ds(h.id)},A.addEventListener("mouseenter",function(){g(A)}),f.push({button:A,action:h})})(u[p]);function g(h){for(var y=0;y<f.length;y++){var A=f[y],K=A.button===h;K?A.button.classList.add("is-active"):A.button.classList.remove("is-active")}if(h&&typeof h.scrollIntoView=="function")try{h.scrollIntoView({block:"nearest"})}catch{h.scrollIntoView()}}function m(){for(var h=[],y=0;y<f.length;y++)f[y].button.hidden||h.push(f[y].button);return h}function b(h){for(var y=(h||"").trim().toLowerCase(),A=null,K=0;K<f.length;K++){var S=f[K],q=((S.action.title||"")+" "+(S.action.description||"")+" "+(S.action.id||"")).toLowerCase(),M=!y||q.indexOf(y)!==-1;S.button.hidden=!M,M&&!A&&(A=S.button)}if(A)a.__aiEmptyHint&&(a.__aiEmptyHint.hidden=!0);else{if(!a.__aiEmptyHint){var P=e.ownerDocument.createElement("div");P.className="rte-ai-menu-empty-hint",P.textContent="No actions match.",e.appendChild(P),a.__aiEmptyHint=P}a.__aiEmptyHint.hidden=!1}g(A)}n.addEventListener("input",function(){b(n.value)}),n.addEventListener("keydown",function(h){if(h.key==="ArrowDown"||h.key==="ArrowUp"){h.preventDefault();var y=m();if(!y.length)return;for(var A=-1,K=0;K<y.length;K++)if(y[K].classList.contains("is-active")){A=K;break}var S;h.key==="ArrowDown"?S=A<0?0:(A+1)%y.length:S=A<=0?y.length-1:A-1,g(y[S])}else if(h.key==="Enter"){h.preventDefault();for(var q=m(),M=null,P=0;P<q.length;P++)if(q[P].classList.contains("is-active")){M=q[P];break}M||(M=q[0]),M&&M.click()}else h.key==="Escape"&&n.value&&(h.preventDefault(),n.value="",b(""))}),b(""),setTimeout(function(){if(n&&typeof n.focus=="function"&&n.isConnected!==!1)try{n.focus({preventScroll:!0})}catch{try{n.focus()}catch{}}},30)}function Sc(e,t){t=t||{};var r=t.agent||k.aiToolkitAgent;if(typeof r!="function"){var i=new Error("AI Toolkit: no agent registered. Call editor.aiToolkit.setAgent(fn) first.");return console.warn(i.message),Promise.reject(i)}var a=Math.max(1,t.maxSteps|0||6),l=t.tools||{},n=t.snapshot||st(),u=[],c=[];function f(p,g){if(p>=a)return Promise.resolve({done:!0,reason:"maxSteps",transcript:u,executedOps:c,lastResult:g});var m={step:p,prompt:e,snapshot:n,tools:Object.keys(l),transcript:u.slice(),lastResult:g},b;try{b=r(e,m)}catch(h){return Promise.reject(h)}return Promise.resolve(b).then(function(h){if(u.push({step:p,result:h}),!h||h.done===!0)return{done:!0,reason:"agent",transcript:u,executedOps:c,lastResult:h};var y=Promise.resolve(h);return h.toolCalls&&h.toolCalls.length&&(y=Promise.all(h.toolCalls.map(function(A){var K=l[A&&A.name];if(typeof K!="function")return{name:A&&A.name,error:"unknown tool"};try{return Promise.resolve(K(A.args||{},{snapshot:n})).then(function(S){return{name:A.name,output:S}})}catch(S){return{name:A.name,error:String(S&&S.message||S)}}})).then(function(A){return h.toolResults=A,u[u.length-1].toolResults=A,h})),y.then(function(A){if(A.operations&&A.operations.length){var K=Sa(A.operations,{snapshot:n,resolved:A});c.push({step:p,handled:K,count:A.operations.length})}return A.done===!0?{done:!0,reason:"agent",transcript:u,executedOps:c,lastResult:A}:f(p+1,A)})})}return f(0,null)}function Ds(e,t){t=t||{};var r=t.snapshot||st(),i=Bl(e)||{id:e,target:"document"};return i.target==="chat-panel"&&!t.forceResolve?(Yi({focusComposer:!0}),Promise.resolve(!0)):i.target==="review-panel"&&!t.forceResolve?(qn({focusPanel:!0}),Promise.resolve(!0)):i.target==="dialog"&&!t.forceResolve?(na({presetMode:i.resolverMode||"",useDocument:t.useDocument===!0||!r.hasSelection,autoRun:!!i.autoRun}),Promise.resolve(!0)):Ya(e,{snapshot:r,source:t.source,prompt:t.prompt,scope:t.scope}).then(function(a){return dr(a,{snapshot:r,fallbackAction:i})}).catch(function(a){return console.error("AI Toolkit action failed",a),!1})}function dr(e,t){t=t||{};var r=t.snapshot||st();return e&&e.operations&&e.operations.length?Sa(e.operations,{snapshot:r,resolved:e}):Sa([vt(e&&e.target?e.target:"document",e&&e.result?e.result:"",e,e?e.request:null,e?e.action:null)],{snapshot:r,resolved:e})}function Sa(e,t){t=t||{};for(var r=t.snapshot||st(),i=t.resolved||null,a=!1,l=e||[],n=0;n<l.length;n++)xc(l[n],{snapshot:r,resolved:i})&&(a=!0);return a}function xc(e,t){if(!e||!e.type)return!1;t=t||{};var r=t.snapshot||st(),i=t.resolved||{},a=k.aiToolkitOperationHandlers&&k.aiToolkitOperationHandlers[e.type];if(typeof a=="function")return!!a.call(s,e,{snapshot:r,resolved:i,request:i.request||null,action:i.action||null,editor:s});switch(e.type){case"open-chat-panel":return Yi({focusComposer:!0}),!0;case"open-review-panel":return qn({focusPanel:!0}),!0;case"open-dialog":return na({presetMode:e.presetMode||i.presetMode||(i.request?i.request.mode:""),useDocument:e.useDocument===!0||i.useDocument===!0||!r.hasSelection,autoRun:!!(e.autoRun||i.autoRun)}),!0;case"preview-suggestion":return r.hasSelection?js(e.text,{snapshot:r,reason:e.reason||i&&i.reason||"",sourceLabel:e.meta&&e.meta.sourceLabel?e.meta.sourceLabel:"",suggestionType:e.meta&&e.meta.mode?e.meta.mode:i&&i.request?i.request.mode:"",language:e.meta&&e.meta.language?e.meta.language:i&&i.request?i.request.language:""}):(na({presetMode:e.presetMode||i.presetMode||(i.request?i.request.mode:""),useDocument:!0,autoRun:!0}),!0);case"add-comment":return yc(e.text,{snapshot:r});case"insert-below":return hn(e.text,{mode:"insert",snapshot:r});case"replace-selection":return hn(e.text,{mode:"selection",snapshot:r});case"replace-document":return hn(e.text,{mode:"document",snapshot:r});default:return!1}}function xa(){cr();var e=arguments.length?he(arguments[0]):di();if(!e)return!1;var t=Lr(e.id);return t?(t.outerHTML=sn(e,"accepted"),e.status="accepted",e.decidedAt=new Date().getTime(),el(e,"accepted"),ha(e.id),s.__aiRecentlyOpenedQueueSuggestionId===e.id&&Vi({skipUpdate:!0,skipRender:!0}),$e(null),He(Jr(e,"Accepted")),wt(),Fi("suggestion-accepted",e),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&pe(!1),s.focus(),!0):(e.status="stale",e.decidedAt=e.decidedAt||new Date().getTime(),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&pe(!1),$e(null),wt(),!1)}function _a(){cr();var e=arguments.length?he(arguments[0]):di();if(!e)return!1;var t=Lr(e.id);return t?(t.outerHTML=sn(e,"rejected"),e.status="rejected",e.decidedAt=new Date().getTime(),el(e,"rejected"),ha(e.id),s.__aiRecentlyOpenedQueueSuggestionId===e.id&&Vi({skipUpdate:!0,skipRender:!0}),$e(null),He(Jr(e,"Rejected")),wt(),Fi("suggestion-rejected",e),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&pe(!1),s.focus(),!0):(e.status="stale",e.decidedAt=e.decidedAt||new Date().getTime(),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&pe(!1),$e(null),wt(),!1)}function Tr(e){e=e||{},cr();var t=li();if(!t)return!1;var r=t.suggestion,i=t.wrapper;if(!i||!i.parentNode)return ms(),!1;r.status="pending",r.decidedAt=0,i.outerHTML=hl(r),Mt().showResolved=!1,nc(r,t.status),ms(),$e(r.id),He(Jr(r,"Reopened")),wt(),Fi("suggestion-reopened",r),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&pe(!!e.focusPanel,{focusAction:e.focusAction||""});var a=!1;return e.focusInlineAction&&(a=fn(r.id,e.focusInlineAction)),!e.focusPanel&&!a&&s.focus(),!0}function zr(e){e=e||{},cr();var t=Rr();if(!t)return!1;var r=t.suggestion,i=t.wrapper,a=s.__aiActiveSuggestionId===r.id?ra(r.id):"";if(!i||!i.parentNode)return bs(),!1;if(i.outerHTML=sn(r,t.status),r.status=t.status,r.decidedAt=new Date().getTime(),Mt().showResolved=!1,bs(),el(r,t.status,{clearRedo:!1}),ha(r.id),s.__aiRecentlyOpenedQueueSuggestionId===r.id&&Vi({skipUpdate:!0,skipRender:!0}),$e(null),He(Jr(r,t.status==="accepted"?"Accepted again":"Rejected again")),wt(),Fi(t.status==="accepted"?"suggestion-accepted":"suggestion-rejected",r),a){var l=gi(a,{focusPanel:!!e.focusPanel,focusAction:e.focusAction||"accept"});return l&&e.focusInlineAction&&fn(a,e.focusInlineAction),l}return s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&pe(!!e.focusPanel,{focusAction:e.focusAction||"accept"}),e.focusPanel||s.focus(),!0}function hn(e,t){var r=R(e);if(!r)return!1;cr(),t=t||{};var i=t.mode||"document",a=t.snapshot||st();return i==="document"?(s.setHTMLCode(en(r)),wa(),wt(),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&pe(!1),s.focus(),!0):i==="selection"?(Za(a,!1)||s.focus(),s.insertText(r),wa(),wt(),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&pe(!1),s.focus(),!0):(Za(a,!0)||s.focus(),s.insertHTML("<p><br/></p>"+en(r)),wa(),wt(),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&pe(!1),s.focus(),!0)}function gl(e){for(;e;){if(e.nodeType===1){var t=typeof e.className=="string"?e.className:"";if(t.indexOf("richtexteditor")!==-1)return e}e=e.parentNode}return null}function Ri(){var e=s.getEditable?s.getEditable():null,t=gl(e);if(t)return t;var r=e&&e.ownerDocument&&e.ownerDocument.defaultView?e.ownerDocument.defaultView.frameElement:null;if(t=gl(r),t)return t;if(s.iframe){if(t=gl(s.iframe),t)return t;if(s.iframe.parentNode)return s.iframe.parentNode}return e&&e.parentNode?e.parentNode:null}function _c(){var e=Ri();if(!e)return null;if(s.__aiReviewStatusNode&&s.__aiReviewStatusNode.isConnected)return s.__aiReviewStatusNode;var t=e.querySelector?e.querySelector(".rte-ai-review-live-region"):null;if(t)return s.__aiReviewStatusNode=t,t;var r=o(e,"div","","rte-ai-review-live-region");return r.setAttribute("role","status"),r.setAttribute("aria-live","polite"),r.setAttribute("aria-atomic","true"),s.__aiReviewStatusNode=r,r}function Jr(e,t,r){if(!e)return t||"";r=r||{};var i=[],a=We(e.suggestionType||"")!=="other"?Pe(e.suggestionType):"AI suggestion";i.push(a);var l=Fr(e);l&&i.push(l),e.language&&i.push(lt(e.language));var n=t?t+" "+i.join(", "):i.join(", ");return r.positionLabel?n+=". "+r.positionLabel+".":n+=".",r.remoteUpdateCount&&(n+=" "+(r.remoteUpdateCount>1?r.remoteUpdateCount+" shared updates.":"Shared update.")),n}function Os(e,t){if(!e)return"Opened AI review queue.";t=t||{};var r=va(e),i=r===1?"1 pending item":r+" pending items",a=We(e.suggestionType||"")!=="other"?Pe(e.suggestionType):"AI",l=je(e,t.focusAction||F()),n=a&&a!=="AI"?"Opened "+a+" AI review queue. "+i+".":"Opened AI review queue. "+i+".";return l&&(n+=" Focus "+l+"."),n+" "+Jr(e,"Reviewing",t)}function Lc(e,t){if(!e)return"AI review item";t=t||{};var r=[];t.isCurrent&&r.push("Current review item"),t.queueOpened&&r.push("Queue opened"),t.queueRoleLabel&&r.push(t.queueRoleLabel),t.queuePositionLabel&&r.push(t.queuePositionLabel),t.transitionLabel&&r.push(t.transitionLabel),t.changeSummary&&r.push(t.changeSummary),r.push(ya(e.status)),e.suggestionType&&We(e.suggestionType)!=="other"?r.push(Pe(e.suggestionType)):r.push("AI suggestion");var i=Fr(e);i&&r.push(i),e.language&&r.push(lt(e.language)),t.remoteUpdateCount&&r.push(t.remoteUpdateCount>1?t.remoteUpdateCount+" shared updates":"Shared update");var a=Be(e.originalText||e.resultText||"AI suggestion",80);return a&&r.push("Preview: "+a),t.undoLabel&&r.push(t.undoLabel),t.undoNextLabel&&r.push(t.undoNextLabel),t.redoLabel&&r.push(t.redoLabel),t.redoNextLabel&&r.push(t.redoNextLabel),r.join(". ")}function La(e,t,r){if(!r||r.status!=="pending"||!e||!e.length)return null;for(var i=[],a=0;a<e.length;a++)e[a]&&e[a].status==="pending"&&i.push(e[a]);if(!i.length)return null;for(var l=-1,n=-1,u=0;u<i.length;u++)i[u].id===r.id&&(l=u),i[u].id===t&&(n=u);if(l===-1)return null;n===-1&&(n=0);var c="later";l===n?c="current":l===n+1?c="next":l<n&&(c="earlier");var f="Queue "+(l+1)+" of "+i.length,p="",g="";return c==="current"?(g="Current focus",p="Review this item now. It is "+f.toLowerCase()+" in this view."):c==="next"?(g="Up next",p="This follows after the current decision. It is "+f.toLowerCase()+" in this view."):c==="earlier"?(g="Earlier item",p="You moved past this item. Use Previous or K to return. It is "+f.toLowerCase()+" in this view."):(g="Later in queue",p="This comes later in the current review run. It is "+f.toLowerCase()+" in this view."),{role:c,roleLabel:g,queueLabel:f,detail:p}}function Rc(e,t,r,i){if(!r||!e||!e.length)return null;if(r.status!=="pending"){for(var a=0,l=0;l<e.length;l++)e[l]&&e[l].status!=="pending"&&a++;return a?{key:"resolved",label:"Resolved items",detail:"Accepted, rejected, or stale suggestions from this review run.",countLabel:yt(a,"item")}:null}for(var n=[],u=0;u<e.length;u++)e[u]&&e[u].status==="pending"&&n.push(e[u]);if(!n.length)return null;for(var c=-1,f=0;f<n.length;f++)if(n[f].id===t){c=f;break}c===-1&&(c=0);var p=i&&i.role?i.role:"";return p==="current"?{key:"current",label:"Current focus",detail:"Review this suggestion now.",countLabel:"1 item"}:p==="next"?{key:"next",label:"Up next",detail:"Becomes current after this decision.",countLabel:"1 item"}:p==="later"?{key:"later",label:"Later in queue",detail:"Pending suggestions after the immediate next step.",countLabel:yt(Math.max(1,n.length-c-2),"item")}:p==="earlier"?{key:"earlier",label:"Earlier in queue",detail:"Pending suggestions before the current focus.",countLabel:yt(Math.max(1,c),"item")}:{key:"pending",label:"Pending items",detail:"Remaining AI suggestions in this queue.",countLabel:yt(n.length,"item")}}function fi(e,t,r){if(!r||r.status!=="pending"||!e||!e.length)return null;for(var i=[],a=0;a<e.length;a++)e[a]&&e[a].status==="pending"&&i.push(e[a]);if(!i.length)return null;for(var l=-1,n=-1,u=0;u<i.length;u++)i[u].id===t&&(l=u),i[u].id===r.id&&(n=u);if(n===-1)return null;var c=n===i.length-1;if(!c&&r.id!==t)return null;if(c)return{title:"After this decision",statusLabel:"Queue complete",queueLabel:"Queue "+(n+1)+" of "+i.length,typeLabel:"",scopeLabel:"",detail:"Accepting or rejecting this final pending item finishes the current review run.",previewLabel:"Queue state",previewText:"No later pending items remain in this queue.",followupTitle:"Then recovery and next queues appear",followupStatusLabel:"Recovery ready",followupDetail:"Undo the last decision or open another queue."};if(l===-1||l>=i.length-1)return null;var f=i[l+1];return f?{title:"After this decision",statusLabel:"Up next becomes current",queueLabel:"Queue "+(l+2)+" of "+i.length,typeLabel:f.suggestionType&&We(f.suggestionType)!=="other"?Pe(f.suggestionType):"",scopeLabel:Fr(f),detail:"Accepting or rejecting this item moves review straight to the next pending suggestion.",previewLabel:"Next item",previewText:Be(f.originalText||f.resultText||"Next review item",84),followupTitle:l+1===i.length-1?"Then queue complete":"",followupStatusLabel:l+1===i.length-1?"Queue complete":"",followupDetail:l+1===i.length-1?"After reviewing the final pending item, recovery and next queues appear.":""}:null}function Vr(e){if(!e)return"";var t=e.previewLabel||"",r=e.previewText||"";return t&&r?t+": "+r:r||t}function Gs(e,t,r){if(!e||!t||!r)return null;var i=Vr(r);if(!i)return null;var a=o(e,"div","",t);return r.previewLabel&&o(a,"span","",t+"-label",r.previewLabel+":"),r.previewText&&o(a,"span","",t+"-text"," "+r.previewText),!r.previewLabel&&!r.previewText&&(a.textContent=i),a}function Us(e){return s.__aiQueueOpenedTimer&&(clearTimeout(s.__aiQueueOpenedTimer),s.__aiQueueOpenedTimer=null),s.__aiRecentlyOpenedQueueSuggestionId=e||null,Qi(),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&pe(!1),e?(s.__aiQueueOpenedTimer=setTimeout(function(){s.__aiRecentlyOpenedQueueSuggestionId===e&&(s.__aiRecentlyOpenedQueueSuggestionId=null,Qi(),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&pe(!1)),s.__aiQueueOpenedTimer=null},1800),!0):!1}function Vi(e){e=e||{};var t=!!s.__aiRecentlyOpenedQueueSuggestionId;return s.__aiQueueOpenedTimer&&(clearTimeout(s.__aiQueueOpenedTimer),s.__aiQueueOpenedTimer=null),s.__aiRecentlyOpenedQueueSuggestionId=null,t?(e.skipUpdate||Qi(),!e.skipRender&&s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&pe(!1),!0):!1}function Yt(e,t){var r=he(e),i=Gt(e),a=i&&i!=="all"?Pe(i)+" review queue":"AI review queue",l=t==="previous"||t==="first"?"Already at the first pending item in the "+a+".":"Already at the last pending item in the "+a+".";return r?l+" "+Jr(r,"Still reviewing"):l}function gn(e,t){var r=he(t),i=r?Jr(r,e):(e||"Updated")+" AI suggestion.";return i+" Review queue complete."}function vi(e){return!e||!e.reason?"":Be(e.reason,110)}function Tc(e){if(!e)return"";var t=Be(e.resultText||"",96),r=Be(e.originalText||"",96);return!t||t===r?"":t}function Fs(e){if(!e)return"";switch(We(e.suggestionType)){case"proofread":return"Surface edit";case"rewrite":return"Text rewrite";case"translate":return"Language change";case"summarize":case"shorten":return"Condensed draft";case"expand":return"Expanded draft"}var t=R(e.originalText||"").toLowerCase().replace(/[^a-z0-9\s]/g,"").replace(/\s+/g," ").trim(),r=R(e.resultText||"").toLowerCase().replace(/[^a-z0-9\s]/g,"").replace(/\s+/g," ").trim();return t&&r&&t===r?"Surface edit":"Text change"}function Ks(e){if(!e)return"";var t=We(e.suggestionType),r=R(e.originalText||"").toLowerCase().replace(/[^a-z0-9\s]/g,"").replace(/\s+/g," ").trim(),i=R(e.resultText||"").toLowerCase().replace(/[^a-z0-9\s]/g,"").replace(/\s+/g," ").trim();if(!r||!i)return"";if(r===i||t==="proofread")return"Low impact";if(t==="translate"||t==="summarize"||t==="shorten"||t==="expand")return"High impact";if(t==="rewrite"||r.indexOf(i)>=0||i.indexOf(r)>=0)return"Medium impact";for(var a=r.split(/\s+/),l=i.split(/\s+/),n={},u=0,c=0;c<a.length;c++)n[a[c]]=(n[a[c]]||0)+1;for(var f=0;f<l.length;f++){var p=l[f];n[p]&&(n[p]--,u++)}var g=u/Math.max(a.length,l.length,1);return g>=.45?"Medium impact":"High impact"}function Ns(e){var t=R(e||"");return t?t.split(/\s+/).length:0}function Qs(e){var t=R(e||"");if(!t)return 0;var r=t.match(/[^.!?]+[.!?]+|[^.!?]+$/g);return r&&r.length?r.length:1}function yt(e,t){return e+" "+t+(e===1?"":"s")}function Wi(e){if(!e)return null;var t=[],r=Fs(e),i=Ks(e),a=Fr(e);r&&t.push({kind:"change",text:r}),i&&t.push({kind:"impact",text:i}),a&&t.push({kind:"scope",text:a});var l=Ns(e.originalText||""),n=Ns(e.resultText||""),u=Qs(e.originalText||""),c=Qs(e.resultText||""),f="";return l&&n&&u&&c?l===n&&u===c?f="Keeps "+yt(n,"word")+" across "+yt(c,"sentence")+".":u===c?f="Moves from "+yt(l,"word")+" to "+yt(n,"word")+" across "+yt(c,"sentence")+".":f="Moves from "+yt(l,"word")+" across "+yt(u,"sentence")+" to "+yt(n,"word")+" across "+yt(c,"sentence")+".":l&&n?f="Moves from "+yt(l,"word")+" to "+yt(n,"word")+".":u&&c&&(f="Moves from "+yt(u,"sentence")+" to "+yt(c,"sentence")+"."),!t.length&&!f?null:{title:"Change at a glance",pills:t,detail:f}}function mn(e,t){var r=R(e||""),i=R(t||"");if(!r||!i||r===i)return null;for(var a=0,l=Math.min(r.length,i.length);a<l&&r.charAt(a)===i.charAt(a);)a++;for(var n=0,u=r.length-a,c=i.length-a;n<u&&n<c&&r.charAt(r.length-1-n)===i.charAt(i.length-1-n);)n++;return{currentLead:r.substring(0,a),currentChange:r.substring(a,r.length-n),currentTrail:n?r.substring(r.length-n):"",resultLead:i.substring(0,a),resultChange:i.substring(a,i.length-n),resultTrail:n?i.substring(i.length-n):""}}function zs(e,t,r,i){var a=t==="result"?"Suggested":"Current",l=o(e,"div","","rte-ai-review-empty-preview-line is-"+t);o(l,"span","","rte-ai-review-empty-preview-line-label",a+":");var n=o(l,"span","","rte-ai-review-empty-preview-line-text");if(!r)return l;if(!i)return n.innerText=r,l;var u=t==="result"?i.resultLead:i.currentLead,c=t==="result"?i.resultChange:i.currentChange,f=t==="result"?i.resultTrail:i.currentTrail;return u&&o(n,"span","","rte-ai-review-empty-preview-segment",u),c&&o(n,"span","","rte-ai-review-empty-preview-delta is-"+t,c),f&&o(n,"span","","rte-ai-review-empty-preview-segment",f),!u&&!c&&!f&&(n.innerText=r),l}function bn(e,t,r,i){var a=o(e,"div","","rte-ai-review-item-compare-text"),l=r||"";if(!l)return a.innerText=t==="result"?"Suggested text unavailable.":"Original selection unavailable.",a;if(!i)return a.innerText=l,a;var n=t==="result"?i.resultLead:i.currentLead,u=t==="result"?i.resultChange:i.currentChange,c=t==="result"?i.resultTrail:i.currentTrail;return n&&o(a,"span","","rte-ai-review-item-compare-segment",n),u&&o(a,"span","","rte-ai-review-item-compare-delta is-"+t,u),c&&o(a,"span","","rte-ai-review-item-compare-segment",c),!n&&!u&&!c&&(a.innerText=l),a}function wn(e,t,r){if(!(!e||!t)){var i=e.closest?e.closest(".rte-ai-review-item"):null,a=e.querySelector(".rte-ai-review-item-condensed-open-pill"),l=e.querySelector(".rte-ai-review-item-condensed-entry-detail");if(a){var n=je(t,F(r))||je(t,"")||"Locate";a.innerText=n,l&&(l.innerText="Press Enter to reopen this suggestion and land on "+n+"."),i&&i.setAttribute&&i.setAttribute("data-rte-ai-review-open-action-label",n)}}}function Js(e,t,r){if(!(!e||!t)){var i=e.querySelector?e.querySelector(".rte-ai-review-item-condensed-shortcuts"):null,a=Qo(t,F(r));if(!a){i&&i.parentNode&&i.parentNode.removeChild(i);return}i||(i=o(e,"div","","rte-ai-review-item-condensed-shortcuts"));var l=i.querySelector?i.querySelector(".rte-ai-review-item-condensed-shortcuts-title"):null;l||(l=o(i,"span","","rte-ai-review-item-condensed-shortcuts-title")),l.textContent="More keys";var n=i.querySelector?i.querySelector(".rte-ai-review-item-condensed-shortcuts-body"):null;n||(n=o(i,"div","","rte-ai-review-shortcuts rte-ai-review-item-condensed-shortcuts-body")),Pl(n,a),Ml(n,"card"),i.setAttribute("aria-label","More keys. "+(n.textContent||""))}}function kc(e,t){if(!e||!t)return null;var r=o(e,"div","","rte-ai-review-item-condensed-queue is-"+(t.role||""));o(r,"div","","rte-ai-review-item-condensed-queue-title",t.roleLabel);var i=o(r,"div","","rte-ai-review-item-condensed-queue-meta");return o(i,"span","","rte-ai-review-item-queue-pill is-role",t.roleLabel),o(i,"span","","rte-ai-review-item-queue-pill is-position",t.queueLabel),o(r,"div","","rte-ai-review-item-condensed-queue-detail",t.detail),r}function Cc(e,t){if(!e||!t)return null;var r=o(e,"div","","rte-ai-review-item-condensed-transition");o(r,"div","","rte-ai-review-item-condensed-transition-title",t.title);var i=o(r,"div","","rte-ai-review-item-condensed-transition-meta");if(o(i,"span","","rte-ai-review-item-transition-pill is-status",t.statusLabel),o(i,"span","","rte-ai-review-item-transition-pill is-position",t.queueLabel),t.typeLabel&&o(i,"span","","rte-ai-review-item-transition-pill is-type",t.typeLabel),t.scopeLabel&&o(i,"span","","rte-ai-review-item-transition-pill is-scope",t.scopeLabel),o(r,"div","","rte-ai-review-item-condensed-transition-detail",t.detail),Gs(r,"rte-ai-review-item-condensed-transition-preview",t),t.followupTitle){var a=o(r,"div","","rte-ai-review-item-condensed-transition-followup");o(a,"div","","rte-ai-review-item-condensed-transition-followup-title",t.followupTitle);var l=o(a,"div","","rte-ai-review-item-condensed-transition-followup-meta");t.followupStatusLabel&&o(l,"span","","rte-ai-review-item-transition-pill is-followup",t.followupStatusLabel),o(a,"div","","rte-ai-review-item-condensed-transition-followup-detail",t.followupDetail)}return r}function ml(e,t){if(!e)return[];t=t||{};var r=t.sharedUpdateCount||0,i=[];i.push({kind:"status",text:e.status==="pending"?"Ready to review":ya(e.status)}),r&&i.push({kind:"remote",text:r>1?r+" shared updates":"Shared update"}),e.suggestionType&&We(e.suggestionType)!=="other"&&i.push({kind:"type",text:Pe(e.suggestionType)}),e.language&&i.push({kind:"language",text:lt(e.language)});var a=Fr(e);return a&&i.push({kind:"scope",text:e.status==="pending"?a+" draft":a}),e.status==="pending"&&i.push({kind:"steps",text:"1 step"}),i}function Ec(e,t){if(!e)return"";t=t||{};var r=["Proposed edit","Current and suggested text"],i=t.originalText||Be(e.originalText||"",72)||"Original selection unavailable.",a=t.resultText||Be(e.resultText||"",72)||"Suggested text unavailable.",l=t.previewMetaData||ml(e,t);if(l&&l.length)for(var n=0;n<l.length;n++)l[n]&&l[n].text&&r.push(l[n].text);r.push("Current"),r.push(i),r.push("Suggested"),r.push(a);var u=t.reasonText||vi(e);if(u&&(r.push("Why"),r.push(u)),t.changeGlance){if(r.push(t.changeGlance.title),t.changeGlance.pills&&t.changeGlance.pills.length)for(var c=0;c<t.changeGlance.pills.length;c++)t.changeGlance.pills[c]&&t.changeGlance.pills[c].text&&r.push(t.changeGlance.pills[c].text);t.changeGlance.detail&&r.push(t.changeGlance.detail)}t.queuePositionData&&(r.push(t.queuePositionData.roleLabel),r.push(t.queuePositionData.queueLabel),r.push(t.queuePositionData.detail)),r.push("Review handoff");var f=je(e,t.preferredAction||F(t.panel))||je(e,"")||"Locate";r.push("Enter target "+f),r.push("Press Enter to reopen this suggestion and land on "+f);var p=Qo(e,t.preferredAction||F(t.panel));return p&&(r.push("More keys"),r.push(p)),t.queueTransitionData&&(r.push(t.queueTransitionData.title),r.push(t.queueTransitionData.statusLabel),r.push(t.queueTransitionData.queueLabel),t.queueTransitionData.typeLabel&&r.push(t.queueTransitionData.typeLabel),t.queueTransitionData.scopeLabel&&r.push(t.queueTransitionData.scopeLabel),r.push(t.queueTransitionData.detail),r.push(Vr(t.queueTransitionData)),t.queueTransitionData.followupTitle&&r.push(t.queueTransitionData.followupTitle),t.queueTransitionData.followupDetail&&r.push(t.queueTransitionData.followupDetail)),r.join(". ")}function Vs(e,t,r){if(!(!e||!t||!e.setAttribute)){var i=F(r),a=Cl(t),l=Je(a);!l.length&&a!=="all"&&(l=Je("all"));var n=La(l,s.__aiActiveSuggestionId,t),u=fi(l,s.__aiActiveSuggestionId,t),c=Wi(t),f=Qt(t.id),p=Be(t.originalText||"",72)||"Original selection unavailable.",g=Be(t.resultText||"",72)||"Suggested text unavailable.",m=Ec(t,{panel:r,preferredAction:i,previewMetaData:ml(t,{sharedUpdateCount:f}),queuePositionData:n,queueTransitionData:u,changeGlance:c,originalText:p,resultText:g,reasonText:vi(t)});e.setAttribute("data-rte-ai-review-base-aria-label",m),e.setAttribute("aria-label",m)}}function yn(e){var t=e&&e.isConnected?e:s.__aiReviewPanel&&s.__aiReviewPanel.isConnected?s.__aiReviewPanel:null;if(t)for(var r=F(t),i=t.querySelectorAll(".rte-ai-review-item.is-condensed"),a=0;a<i.length;a++){var l=i[a],n=l.getAttribute("data-rte-ai-review-id")||"";if(n){var u=he(n);Vs(l,u,t),wn(l,u,t),Js(l,u,t),l.title=El(u,r)}}}function An(){var e=s.getEditable?s.getEditable():null;if(!(!e||!e.querySelectorAll))for(var t=e.querySelectorAll(".rte-ai-inline-preview"),r=0;r<t.length;r++){var i=t[r];if(!(!i||i.classList.contains("is-review-active"))){var a=i.getAttribute("data-rte-ai-suggestion-id")||"";if(!(!a||s.__aiReviewEmptyPreviewSuggestionId&&a===s.__aiReviewEmptyPreviewSuggestionId)){var l=he(a);if(l){var n=Gt(a),u=Je(n),c=La(u,s.__aiActiveSuggestionId,l),f=fi(u,s.__aiActiveSuggestionId,l),p=je(l,F())||je(l,""),g="Open this AI suggestion in review"+(p?" and focus "+p:""),m=vi(l),b=i.querySelector?i.querySelector('[data-rte-ai-action="review"]'):null;b&&Qr(b,"Review",g);var h=Wi(l),y=Aa(h),A=i.querySelector?i.querySelector(".rte-ai-inline-preview-focus"):null,K=i.querySelector?i.querySelector(".rte-ai-inline-preview-current"):null,S=i.querySelector?i.querySelector(".rte-ai-inline-preview-type"):null,q=i.querySelector?i.querySelector(".rte-ai-inline-preview-language"):null,M=i.querySelector?i.querySelector(".rte-ai-inline-preview-scope"):null,P=i.querySelector?i.querySelector(".rte-ai-inline-preview-remote"):null,L=i.querySelector?i.querySelector(".rte-ai-inline-preview-glance"):null,D=i.querySelector?i.querySelector(".rte-ai-inline-preview-reason"):null,J=i.querySelector?i.querySelector(".rte-ai-inline-preview-shortcuts"):null;if(p){if(!A){A=document.createElement("span"),A.className="rte-ai-inline-preview-focus";var E=P||M||q||S||K;E&&E.nextSibling?i.insertBefore(A,E.nextSibling):i.appendChild(A)}A.textContent="Focus "+p,A.setAttribute("aria-label","Review opens on "+p)}else A&&A.parentNode&&A.parentNode.removeChild(A);if(h&&h.pills&&h.pills.length){if(!L){L=document.createElement("span"),L.className="rte-ai-inline-preview-glance";var W=M||S||K;W&&W.nextSibling?i.insertBefore(L,W.nextSibling):i.appendChild(L)}for(;L.firstChild;)L.removeChild(L.firstChild);for(var de=0;de<h.pills.length;de++){var $=h.pills[de];!$||!$.text||$.kind==="scope"||o(L,"span","","rte-ai-review-item-glance-pill is-"+$.kind,$.text)}!L.childNodes.length&&L.parentNode&&(L.parentNode.removeChild(L),L=null)}else L&&L.parentNode&&L.parentNode.removeChild(L);qs(i,l),vl(i,l),pl(i,y),D=dl(i,D,l),J=fl(i,J),ul(i,{suggestion:l,sharedUpdateCount:Qt(a),queueTransitionData:f}),cl(i,{suggestion:l,sharedUpdateCount:Qt(a)}),i.setAttribute("aria-label",Qn(l,{remoteUpdateCount:Qt(a),glanceLabels:h?h.pills.map(function(I){return I.text}):[],glanceDetail:h?h.detail:"",compareLabel:"Proposed edit. Current and suggested text.",reasonText:m,focusLabel:p,queueRoleLabel:c?c.roleLabel:"",queueRoleDetail:c?c.detail:"",transitionLabel:f?f.title+". "+f.statusLabel+". "+f.queueLabel+". "+Vr(f):"",followupLabel:f&&f.followupTitle?f.followupTitle+". "+f.followupDetail:""}))}}}}}function Pc(e,t,r,i){if(!e||!t)return null;i=i||{};var a=i.queuePositionData||null,l=i.queueTransitionData||null,n=ml(t,i),u=Wi(t),c=Be(t.originalText||"",72)||"Original selection unavailable.",f=Be(t.resultText||"",72)||"Suggested text unavailable.",p=vi(t),g=mn(c,f),m=o(e,"div","","rte-ai-review-item-condensed-preview"),b=o(m,"div","","rte-ai-review-item-condensed-preview-header");if(o(b,"div","","rte-ai-review-item-condensed-preview-title","Proposed edit"),o(b,"div","","rte-ai-review-item-condensed-preview-detail","Current and suggested text"),n&&n.length)for(var h=o(m,"div","","rte-ai-review-item-condensed-preview-meta"),y=0;y<n.length;y++){var A=n[y];!A||!A.text||o(h,"span","","rte-ai-review-item-condensed-preview-pill is-"+(A.kind||"other"),A.text)}var K=o(m,"div","","rte-ai-review-item-condensed-preview-line is-current");o(K,"span","","rte-ai-review-item-condensed-preview-label","Current"),bn(K,"current",c,g);var S=o(m,"div","","rte-ai-review-item-condensed-preview-line is-result");if(o(S,"span","","rte-ai-review-item-condensed-preview-label","Suggested"),bn(S,"result",f,g),p){var q=o(m,"div","","rte-ai-review-item-condensed-reason");o(q,"span","","rte-ai-review-item-condensed-reason-label","Why"),o(q,"div","","rte-ai-review-item-condensed-reason-copy",p)}if(u&&u.pills&&u.pills.length){var M=o(m,"div","","rte-ai-review-item-condensed-glance");o(M,"div","","rte-ai-review-item-condensed-glance-title","Change at a glance");for(var P=o(M,"div","","rte-ai-review-item-condensed-glance-meta"),L=0;L<u.pills.length;L++){var D=u.pills[L];o(P,"span","","rte-ai-review-item-glance-pill is-"+D.kind,D.text)}u.detail&&o(M,"div","","rte-ai-review-item-condensed-glance-detail",u.detail)}kc(m,a);var J=o(m,"div","","rte-ai-review-item-condensed-entry");o(J,"div","","rte-ai-review-item-condensed-entry-title","Review handoff");var E=o(J,"div","","rte-ai-review-item-condensed-open");return o(E,"span","","rte-ai-review-item-condensed-open-label","Enter target"),o(E,"span","","rte-ai-review-item-condensed-open-pill"),o(J,"div","","rte-ai-review-item-condensed-entry-detail"),wn(J,t,r),Js(J,t,r),Cc(m,l),m}function Mc(e,t,r,i,a,l,n){var u=!!(e.accepted||e.rejected||e.stale),c=F(),f=li(),p=kt(f),g=f?{id:"undo-last",label:p.actionLabel,focusActionLabel:Yd(f,c)}:null;if(r!=="all"&&!t){for(var m=[],b=[],h=[],y=n||[],A=l||{},K=0;K<y.length;K++){var S=y[K];if(!(!S||S.value==="all"||S.value===r)){var q=A[S.value]||0;if(q){var M=er(S.value,""),P=M?he(M):null,L=P?Be(P.originalText||P.resultText||"",84):"",D=Tc(P),J=Fs(P),E=Ks(P),W=P?Fr(P):"",de=P&&P.language?lt(P.language):"",$=vi(P);h.push(S.label+" ("+q+")"),m.push({id:"go-type",label:"Go to "+S.label+" ("+q+")",typeValue:S.value,suggestionId:M,focusAction:c,focusActionLabel:je(P,c)}),L&&b.push({label:S.label+" next",text:L,typeValue:S.value,suggestionId:M,actionLabel:"Go to "+S.label+" ("+q+")",focusAction:c,pendingCountLabel:q+" pending",changeLabel:J,impactLabel:E,focusActionLabel:je(P,c),scopeLabel:W,languageLabel:de,resultText:D,reasonText:$})}}}var I=Pe(r);return{title:I+" queue complete",detail:e.pending?"No pending "+I.toLowerCase()+" suggestions remain. Continue into another AI queue, switch back to all types, or review resolved items.":"No pending "+I.toLowerCase()+" suggestions remain, and the overall AI review queue is complete.",announceMessage:e.pending?h.length===1?I+" queue complete. Next queue: "+h[0]+".":h.length>1?I+" queue complete. Next queues available: "+h.join(", ")+".":I+" queue complete. Pending AI review remains in other queues.":I+" queue complete. Overall AI review queue complete.",previewItems:b,actions:m.concat([e.pending&&a?{id:"next-overall",label:"Next pending overall",suggestionId:a,focusAction:c,focusActionLabel:je(he(a),c)}:null,g,{id:"all-types",label:"All types"},u&&!i?{id:"show-resolved",label:"Show resolved"}:null,{id:"open-chat",label:"AI Chat"}])}}return e.pending?{title:"No suggestions in this view",detail:"Suggestions from Ask AI or the chat panel stay here until you accept or reject them.",announceMessage:"",actions:[g,r!=="all"?{id:"all-types",label:"All types"}:null,u&&!i?{id:"show-resolved",label:"Show resolved"}:null,{id:"open-chat",label:"AI Chat"}]}:{title:"Review queue complete",detail:u?"All AI suggestions have been reviewed. You can inspect resolved items or open AI Chat to generate more suggestions.":"There are no pending AI suggestions right now. Open AI Chat to create a new review pass.",announceMessage:u?"Review queue complete. All AI suggestions have been reviewed.":"Review queue complete. No pending AI suggestions remain.",actions:[g,u&&!i?{id:"show-resolved",label:"Show resolved"}:null,{id:"open-chat",label:"AI Chat"}]}}function Ws(e,t,r){return!e||!e.total?"No suggestions":r!=="all"&&t>0?Pe(r)+" queue":e.pending>0?"Reviewing":e.stale>0?"Needs refresh":"Queue complete"}function qc(e,t,r,i){return!e||!e.total?"Ask AI to create a review queue.":i&&i.total&&i.index?"Item "+i.index+" of "+i.total+" is active now.":r!=="all"&&t>0?t+" "+Pe(r).toLowerCase()+" item"+(t===1?"":"s")+" ready to review.":e.pending>0?e.pending+" pending item"+(e.pending===1?"":"s")+" ready for review.":"Everything in this queue has been reviewed for now."}function Ic(e,t,r,i){if(!e||!e.total)return"Use Ask AI, AI Chat, or inline review actions to generate reviewable changes.";var a=[];return r!=="all"?a.push("Showing only "+Pe(r).toLowerCase()+" suggestions."):a.push("Showing every AI suggestion in this editor."),i&&i.count?a.push(i.count+" shared update"+(i.count===1?"":"s")+" waiting."):e.stale>0?a.push(e.stale+" suggestion"+(e.stale===1?"":"s")+" may need refresh."):e.pending>0&&r!=="all"&&t!==e.pending&&a.push(e.pending+" total pending across all queues."),a.join(" ")}function Hc(e,t,r){return e?e.status==="pending"&&r?"Opened from queue switcher":e.status==="pending"&&t?"Ready to review now":e.status==="accepted"?"Accepted change":e.status==="rejected"?"Rejected change":e.status==="stale"?"Needs refresh":ya(e.status):"AI suggestion"}function jc(e,t,r,i){if(!e)return"";var a=[];e.status==="pending"&&t?a.push("This is the active item in the current queue."):e.status==="pending"&&r?a.push("This item was opened from the queue-complete handoff."):e.status==="stale"?a.push("Review the latest editor text before deciding."):(e.status==="accepted"||e.status==="rejected")&&a.push("This decision stays in history until you reopen it.");var l=e.sourceLabel||(e.snapshot&&e.snapshot.hasSelection?"Selection suggestion":"Document suggestion");return l&&a.push(l+"."),i&&a.push(i>1?i+" shared updates are waiting.":"A shared update is waiting."),a.join(" ")}function Dc(e,t){var r="";e?r=t?"Press Enter to "+e+". J/K or Left/Right switch queues. Home/End jump queues. Tab for more actions.":"Press Enter to "+e+". Tab for more actions.":r="Press Tab for available actions.";var i=kt(),a=Ct();return tr()?r.replace(/\.$/,"")+". Press U to "+i.shortcutLabel+"."+(rr()?" Press Shift+U to "+a.shortcutLabel+".":""):rr()?r.replace(/\.$/,"")+". Press Shift+U to "+a.shortcutLabel+".":r}function Oc(e,t){t=t||{};var r=kt(),i=Ct();if(!e){var a=[];return tr()&&a.push("U "+r.shortcutLabel),rr()&&a.push("Shift+U "+i.shortcutLabel),a.push("Esc close"),"Shortcuts: "+a.join(", ")}var l=["Enter "+e];return t.queueSwitcher&&(l.push("J/K or Left/Right switch queues"),l.push("Home/End jump queues")),tr()&&l.push("U "+r.shortcutLabel),rr()&&l.push("Shift+U "+i.shortcutLabel),l.push("Tab more actions"),l.push("Esc close"),"Shortcuts: "+l.join(", ")}function $s(e,t){t=t||{};var r=["Enter activates "+(e||"this action")+(t.focusLabel?" and focuses "+t.focusLabel:"")+"."];t.queueSwitcher&&r.push("J/K or Left/Right switch queues. Home/End jump queues."),r.push("Tab moves to more actions.");var i=kt(),a=Ct(),l=r.join(" ");return tr()&&(l=l.replace(/\.$/,"")+" U undoes "+i.decisionLabel+" decision."),rr()&&(l=l.replace(/\.$/,"")+" Shift+U redoes "+a.decisionLabel+" decision."),l}function Bs(e){e=e||{};var t=e.queueSwitcher?"Enter Space J K ArrowLeft ArrowRight Home End":"Enter Space";return Pn(t)}function He(e){var t=_c(),r=R(e||"");return!t||!r?!1:(s.__aiReviewStatusTimer&&clearTimeout(s.__aiReviewStatusTimer),t.textContent="",s.__aiReviewStatusTimer=setTimeout(function(){t&&(t.textContent=r)},30),!0)}function bl(){return"chat-"+new Date().getTime().toString(36)+"-"+Math.random().toString(36).slice(2,8)}function wl(){var e=tn();return e?e+".ChatSessions":""}function Gc(e){if(!e)return null;var t={role:e.role||"assistant",text:R(e.text||""),scope:e.scope==="selection"?"selection":"document",timestamp:e.timestamp||0,isError:!!e.isError};if(e.snapshot&&(t.snapshot={hasSelection:!!e.snapshot.hasSelection}),e.resolved)try{t.resolved=JSON.parse(JSON.stringify(e.resolved))}catch{}return t}function Uc(e){return e?{role:e.role||"assistant",text:R(e.text||""),scope:e.scope==="selection"?"selection":"document",resolved:e.resolved||null,snapshot:e.snapshot?{hasSelection:!!e.snapshot.hasSelection}:null,timestamp:e.timestamp||0,isError:!!e.isError}:null}function Xs(e){for(var t=[],r=e||[],i=Math.max(0,r.length-24),a=i;a<r.length;a++){var l=Gc(r[a]);l&&t.push(l)}return t}function Ys(e){for(var t=[],r=e||[],i=0;i<r.length;i++){var a=Uc(r[i]);a&&t.push(a)}return t}function Fc(e){for(var t=e||[],r=0;r<t.length;r++)if(t[r]&&t[r].role==="user"&&R(t[r].text||""))return Xa(R(t[r].text||""),34);for(var i=0;i<t.length;i++)if(t[i]&&R(t[i].text||""))return Xa(R(t[i].text||""),34);return"New chat"}function yl(e){return!e||!e.id?null:{id:e.id,title:R(e.title||""),scope:e.scope==="selection"?"selection":"document",updatedAt:e.updatedAt||0,messageCount:e.messageCount||0,exchangeCount:e.exchangeCount||0,messages:Xs(e.messages||[])}}function Zs(e){return!e||!e.sessionId||!e.messages||!e.messages.length?null:{id:e.sessionId,title:Fc(e.messages),scope:e.scope==="selection"?"selection":"document",updatedAt:new Date().getTime(),messageCount:e.messages.length,exchangeCount:Ci(e.messages),messages:Xs(e.messages)}}function Al(e){for(var t={version:"2026-05-31",activeSessionId:e&&e.activeSessionId?e.activeSessionId:"",sessions:[]},r=e&&e.sessions?e.sessions:[],i=0;i<r.length;i++){var a=yl(r[i]);a&&t.sessions.push(a)}return t.sessions.sort(function(l,n){return(n.updatedAt||0)-(l.updatedAt||0)}),t.sessions.length>6&&(t.sessions=t.sessions.slice(0,6)),t}function $i(){if(!s.__aiChatSessionStore){var e=null,t=wl();if(t&&window.localStorage)try{e=JSON.parse(window.localStorage.getItem(t)||"null")}catch{}s.__aiChatSessionStore=Al(e||{})}return s.__aiChatSessionStore}function eo(){var e=wl();if(s.__aiChatSessionStore=Al($i()),e&&window.localStorage)try{window.localStorage.setItem(e,JSON.stringify(s.__aiChatSessionStore))}catch{}return s.__aiChatSessionStore}function Bi(e){if(!e)return!1;var t=$i(),r=[],i=Zs(e);i&&r.push(i);for(var a=0;a<t.sessions.length;a++){var l=t.sessions[a];!l||l.id===e.sessionId||r.push(l)}return t.activeSessionId=e.sessionId||t.activeSessionId||"",t.sessions=r,eo(),!0}function Kc(e){e=e||{};for(var t=parseInt(e.maxCount,10),r=to(Zt(),t>0?t:6),i=[],a=0;a<r.length;a++){var l=yl(r[a]);l&&(l.active=l.id===Zt().sessionId,e.includeMessages!==!0&&delete l.messages,i.push(l))}return i}function Nc(e,t){t=t||{};var r=ro(Zt(),e,t.statusText||"Loaded a recent AI chat.");return r&&Ta()&&Et(t.focusComposer!==!1),r}function Qc(e){e=e||{};var t=wl();if(s.__aiChatSessionStore=Al({}),t&&window.localStorage)try{window.localStorage.removeItem(t)}catch{}var r=Zt();return r.messages=[],r.draft="",r.busy=!1,r.status=e.statusText||"Cleared AI chat history.",r.sessionVersion=(r.sessionVersion||0)+1,r.sessionId=bl(),$i().activeSessionId=r.sessionId,eo(),Ta()&&Et(e.focusComposer===!0),!0}function to(e,t){var r=$i(),i=r.sessions.slice(),a=Zs(e),l={},n=[],u=t||4;a&&(n.push(a),l[a.id]=!0);for(var c=0;c<i.length&&n.length<u;c++)!i[c]||l[i[c].id]||(n.push(yl(i[c])),l[i[c].id]=!0);return n}function ro(e,t,r){if(!e||!t)return!1;for(var i=$i(),a=null,l=0;l<i.sessions.length;l++)if(i.sessions[l]&&i.sessions[l].id===t){a=i.sessions[l];break}return a?(e.sessionId=a.id,e.messages=Ys(a.messages||[]),e.draft="",e.scope=a.scope==="selection"?"selection":"document",e.busy=!1,e.status=r||"Loaded a recent AI chat.",e.sessionVersion=(e.sessionVersion||0)+1,Bi(e),!0):!1}function Zt(){if(!s.__aiChatState){for(var e=st(),t=$i(),r=null,i=0;i<t.sessions.length;i++)if(t.sessions[i]&&t.sessions[i].id===t.activeSessionId){r=t.sessions[i];break}!r&&t.activeSessionId?s.__aiChatState={messages:[],draft:"",scope:e.hasSelection?"selection":"document",busy:!1,status:"",sessionVersion:0,sessionId:t.activeSessionId}:!r&&t.sessions.length&&(r=t.sessions[0]),s.__aiChatState||(s.__aiChatState=r?{messages:Ys(r.messages||[]),draft:"",scope:r.scope==="selection"?"selection":"document",busy:!1,status:"",sessionVersion:0,sessionId:r.id}:{messages:[],draft:"",scope:e.hasSelection?"selection":"document",busy:!1,status:"",sessionVersion:0,sessionId:bl()})}return s.__aiChatState}function zc(e,t){e&&(e.messages=[],e.draft="",e.busy=!1,e.status=t||"",e.sessionVersion=(e.sessionVersion||0)+1,e.sessionId=bl(),Bi(e))}function Ra(){var e=Zt(),t=st(),r=e.scope==="selection"&&t.hasSelection?"selection":"document",i=r==="selection"&&t.text||t.wholeText;return{scope:r,snapshot:t,source:i,summary:Xa(i,180)||"The document is currently empty."}}function Jc(){var e=document.activeElement;!e||e===document.body||e===document.documentElement||s.__aiChatPanel&&s.__aiChatPanel.contains&&s.__aiChatPanel.contains(e)||typeof e.focus=="function"&&(s.__aiChatReturnFocusNode=e)}function Vc(e){if(e&&e.isConnected!==!1&&typeof e.focus=="function"&&!e.disabled){try{e.focus({preventScroll:!0})}catch{try{e.focus()}catch{}}if(document.activeElement===e)return!0}if(s&&typeof s.focus=="function")try{return s.focus(),!0}catch{}return!1}function Xi(e){e=e||{};var t=s.__aiChatReturnFocusNode||null;s.__aiChatPanel&&s.__aiChatPanel.parentNode&&s.__aiChatPanel.parentNode.removeChild(s.__aiChatPanel),s.__aiChatShell&&s.__aiChatShell.classList&&s.__aiChatShell.classList.remove("rte-ai-chat-host"),s.__aiChatShell&&s.__aiChatShell.style&&(s.__aiChatShell.style.minHeight=typeof s.__aiChatOriginalMinHeight=="string"?s.__aiChatOriginalMinHeight:""),s.__aiChatPanel=null,s.__aiChatShell=null,s.__aiChatOriginalMinHeight=null,e.preserveReturnFocus||(s.__aiChatReturnFocusNode=null),e.restoreFocus&&Vc(t)}function Wc(e){if(!e||!e.contains||!document.activeElement||!e.contains(document.activeElement))return null;var t=document.activeElement;if(t.classList&&t.classList.contains("rte-ai-chat-input"))return{kind:"composer"};var r=t.getAttribute("data-rte-ai-chat-header-action");if(r)return{kind:"header-action",value:r};var i=t.getAttribute("data-rte-ai-chat-scope-target");if(i)return{kind:"scope",value:i};var a=t.getAttribute("data-rte-ai-chat-prompt-id");if(a)return{kind:"quick",value:a};var l=t.getAttribute("data-rte-ai-chat-session-id");if(l)return{kind:"session",value:l};var n=t.getAttribute("data-rte-ai-chat-action");if(n){if(t.closest&&t.closest(".rte-ai-chat-composer-actions"))return{kind:"composer-action",value:n};var u=t.closest?t.closest(".rte-ai-chat-message"):null;if(u)return{kind:"message-action",value:n,exchangeIndex:u.getAttribute("data-rte-ai-chat-exchange-index")||"",threadRole:u.getAttribute("data-rte-ai-chat-thread-role")||""}}return t===e?{kind:"panel"}:null}function $c(e,t){if(!e||!t||!t.kind)return null;var r=0,i;switch(t.kind){case"composer":return e.querySelector(".rte-ai-chat-input");case"panel":return e;case"header-action":for(i=e.querySelectorAll("[data-rte-ai-chat-header-action]"),r=0;r<i.length;r++)if((i[r].getAttribute("data-rte-ai-chat-header-action")||"")===t.value)return i[r];return null;case"scope":for(i=e.querySelectorAll("[data-rte-ai-chat-scope-target]"),r=0;r<i.length;r++)if((i[r].getAttribute("data-rte-ai-chat-scope-target")||"")===t.value)return i[r];return null;case"quick":for(i=e.querySelectorAll("[data-rte-ai-chat-prompt-id]"),r=0;r<i.length;r++)if((i[r].getAttribute("data-rte-ai-chat-prompt-id")||"")===t.value)return i[r];return null;case"session":for(i=e.querySelectorAll("[data-rte-ai-chat-session-id]"),r=0;r<i.length;r++)if((i[r].getAttribute("data-rte-ai-chat-session-id")||"")===t.value)return i[r];return null;case"composer-action":for(i=e.querySelectorAll(".rte-ai-chat-composer-actions [data-rte-ai-chat-action]"),r=0;r<i.length;r++)if((i[r].getAttribute("data-rte-ai-chat-action")||"")===t.value)return i[r];return null;case"message-action":for(i=e.querySelectorAll(".rte-ai-chat-message [data-rte-ai-chat-action]"),r=0;r<i.length;r++){var a=i[r].closest?i[r].closest(".rte-ai-chat-message"):null;if(a&&(i[r].getAttribute("data-rte-ai-chat-action")||"")===t.value&&(a.getAttribute("data-rte-ai-chat-exchange-index")||"")===(t.exchangeIndex||"")&&(a.getAttribute("data-rte-ai-chat-thread-role")||"")===(t.threadRole||""))return i[r]}return null;default:return null}}function Bc(e,t){var r=$c(e,t);if(!r||r.disabled)return!1;try{r.focus({preventScroll:!0})}catch{try{r.focus()}catch{return!1}}return document.activeElement===r}function Xc(e){if(!e||!e.querySelector)return null;var t=e.querySelector(".rte-ai-chat-feed");if(!t||typeof t.scrollTop>"u")return null;var r=Math.max(0,(t.scrollHeight||0)-(t.clientHeight||0)),i=Math.max(0,t.scrollTop||0);return{scrollTop:i,stickToBottom:r<=0||r-i<=24}}function Yc(e,t){if(!e||!t||typeof e.scrollTop>"u")return!1;if(t.stickToBottom)return e.scrollTop=e.scrollHeight,!0;var r=Math.max(0,(e.scrollHeight||0)-(e.clientHeight||0));return e.scrollTop=Math.max(0,Math.min(t.scrollTop||0,r)),!0}function Ta(){return!!(s.__aiChatPanel&&s.__aiChatPanel.isConnected)}function Yi(e){return e=e||{},Br(),Ta()||Jc(),Et(!!e.focusComposer)}function Zc(e){return s.__aiChatPanel&&s.__aiChatPanel.isConnected?(Xi({restoreFocus:!0}),!1):Yi(e)}function Sl(e){var t=Zt(),r=R(e||t.draft);if(!r||t.busy)return!1;var i=Ra();t.scope=i.scope,t.draft="",t.busy=!0,t.status=i.scope==="selection"?"Thinking about the current selection...":"Thinking about the current document...";var a=t.sessionVersion||0;return t.messages.push({role:"user",text:r,scope:i.scope,snapshot:i.snapshot,timestamp:new Date().getTime()}),Bi(t),Et(!1),Ya("chat-panel",{snapshot:i.snapshot,source:i.source,prompt:r,mode:"chat",scope:i.scope}).then(function(l){(t.sessionVersion||0)===a&&(t.busy=!1,t.status=l&&l.operations&&l.operations.length?"AI response ready. Preview or apply the suggested change from the chat.":"AI response ready.",t.messages.push({role:"assistant",text:l&&(l.message||l.result)?l.message||l.result:"No response returned.",scope:i.scope,resolved:l,snapshot:i.snapshot,timestamp:new Date().getTime()}),Bi(t),Ta()&&Et(!1))}).catch(function(l){console.error("AI chat failed",l),(t.sessionVersion||0)===a&&(t.busy=!1,t.status="AI chat failed.",t.messages.push({role:"assistant",text:"I could not finish that request. Try again or shorten the prompt.",scope:i.scope,isError:!0,timestamp:new Date().getTime()}),Bi(t),Ta()&&Et(!1))}),!0}function ka(e,t){if(!e||!e.resolved)return!1;var r=st(),i=e.resolved,a=Nt(i),l=!1,n={preview:!0,selection:!0};if(n[t]&&!r.hasSelection)return Zt().status=t==="preview"?"Select text before previewing this chat suggestion inline.":"Select text before replacing selection from chat.",Et(!1),!1;if(t==="plan"&&i&&i.operations&&i.operations.length)for(var u=0;u<i.operations.length;u++){var c=i.operations[u];if(c&&(c.type==="preview-suggestion"||c.type==="replace-selection")&&!r.hasSelection)return Zt().status="Select text before applying this selection-based chat suggestion.",Et(!1),!1}if(t==="plan")l=dr(i,{snapshot:r});else if(a)if(t==="preview"){var f=Kr(a,"selection-preview",i,i.request||null,i.action||null);f&&f.operations&&f.operations[0]&&!f.operations[0].reason&&(f.operations[0].reason=pa(i)),l=dr(f,{snapshot:r})}else t==="selection"?l=dr(Kr(a,"selection",i,i.request||null,i.action||null),{snapshot:r}):t==="insert"?l=dr(Kr(a,"insert",i,i.request||null,i.action||null),{snapshot:r}):t==="document"&&(l=dr(Kr(a,"document",i,i.request||null,i.action||null),{snapshot:r}));return l&&(Zt().status=t==="preview"?"Previewed the AI suggestion inline from chat.":"Applied the AI chat suggestion.",Et(!1)),l}function io(e){var t=R(e||"");return t?navigator.clipboard&&navigator.clipboard.writeText?navigator.clipboard.writeText(t).then(function(){return!0}).catch(function(){return ao(t)}):Promise.resolve(ao(t)):Promise.resolve(!1)}function ao(e){if(!document||!document.body||!document.createElement)return!1;var t=document.activeElement&&document.activeElement!==document.body?document.activeElement:null,r=null,i=null;t&&typeof t.selectionStart=="number"&&typeof t.selectionEnd=="number"&&(r=t.selectionStart,i=t.selectionEnd);var a=document.createElement("textarea");a.value=e,a.setAttribute("readonly","readonly"),a.style.position="fixed",a.style.opacity="0",a.style.pointerEvents="none",a.style.left="-9999px",a.style.top="0",document.body.appendChild(a),a.focus(),a.select();var l=!1;try{l=!!document.execCommand("copy")}catch{l=!1}if(document.body.removeChild(a),t&&t.focus&&t.isConnected!==!1){try{t.focus({preventScroll:!0})}catch{try{t.focus()}catch{}}if(r!==null&&i!==null&&t.setSelectionRange)try{t.setSelectionRange(r,i)}catch{}}return l}function ed(e){return io(e&&e.text?e.text:"").then(function(t){var r=Zt();return r.status=t?"Copied the AI response.":"Could not copy the AI response.",Et(!1),t})}function no(e){return e&&e.isError?"Issue":e&&e.role==="user"?"You":"AI"}function td(e){return e==="request"?"Request":e==="response"?"Response":""}function Ti(e){return e&&e.scope==="selection"?"Selection":"Document"}function rd(e){if(!e)return"";if(e.isError)return"Needs retry";if(e.role==="user")return"Prompt";var t=e.resolved||null,r=t&&t.operations?t.operations:[],i=t?Nt(t):"";return r.length?"Reviewable change":i?"Draft":"Answer"}function yf(e){if(!e)return"";var t=Ti(e).toLowerCase();if(e.isError)return"This request hit an issue. Try again or adjust the prompt.";if(e.role==="user")return"Sent with "+t+" context.";var r=e.resolved||null,i=r&&r.operations?r.operations:[],a=r?Nt(r):"";return i.length?"Ready for preview, apply, or insert from the "+t+" context.":a?"Drafted from the "+t+" context.":"Response grounded in the "+t+" context."}function id(e){if(!e||e.isError||!e.snapshot)return null;var t=e.scope==="selection"?e.snapshot.text||e.snapshot.wholeText||"":e.snapshot.wholeText||"";if(t=R(t||""),!t)return null;var r=ho(t);return{title:e.scope==="selection"?"Using current selection":"Using current document",scopeLabel:e.scope==="selection"?"Selection context":"Document context",wordLabel:Rn(t)+" words",paragraphLabel:r>1?r+" paragraphs":"",copy:Be(t,180)}}function Af(e){if(!e)return"";var t=[];return e.title&&t.push(e.title),e.scopeLabel&&t.push(e.scopeLabel),e.wordLabel&&t.push(e.wordLabel),e.paragraphLabel&&t.push(e.paragraphLabel),e.copy&&t.push(e.copy),t.join(". ")}function lo(e){if(!e)return"";if(e.isError)return"Reply needs retry";if(e.role==="user")return"Prompt sent";var t=e.resolved||null,r=t&&t.operations?t.operations:[],i=t?Nt(t):"";return r.length?"Reviewable change prepared":i?"Draft prepared":"Answer ready"}function xl(e){if(!e)return"";var t=Ti(e).toLowerCase();if(e.isError)return"This "+t+" request hit an issue. Adjust the prompt or try again.";if(e.role==="user")return"Waiting on AI for the current "+t+" context.";var r=e.resolved||null,i=r&&r.operations?r.operations:[],a=r?Nt(r):"";return i.length?"Preview, replace, or insert this "+t+" change from the latest reply.":a?"Reuse or adapt this drafted "+t+" response.":"Read the answer grounded in the current "+t+" context."}function Zi(e,t){for(var r=e&&e.resolved?e.resolved:null,i=r&&r.operations?r.operations:[],a=r?Nt(r):"",l=t&&typeof t.hasSelection=="boolean"?!!t.hasSelection:!!(e&&e.snapshot&&e.snapshot.hasSelection),n=!1,u=0;u<i.length;u++){var c=i[u];if(c&&(c.type==="preview-suggestion"||c.type==="replace-selection")){n=!0;break}}return{operations:i,resultText:a,hasSelection:l,selectionDependentPlan:n,canApplyPlan:!!i.length&&(!n||l),canPreview:!!a&&l,canReplaceSelection:!!a&&l,canInsert:!!a,canReplaceDocument:!!a&&!l}}function Ca(e,t){if(!e||!e.resolved)return null;var r=Zi(e,t);return r.operations.length&&r.canPreview?{title:"Best next step: Preview",detail:"Check the inline diff first, then replace the selection or apply the prepared plan if it looks right."}:r.operations.length&&r.canApplyPlan?{title:"Best next step: Apply the prepared plan",detail:"Run the structured change directly or use the insert and document actions below if you want a different handoff."}:r.operations.length&&r.canInsert?{title:"Best next step: Insert below",detail:"Select text to preview or replace this change inline, or insert the prepared draft below the current content."}:r.resultText&&r.canReplaceSelection?{title:"Best next step: Replace or preview",detail:"Use the prepared draft to preview inline, replace the selection, or insert a follow-up below."}:r.resultText?{title:"Best next step: Reuse this draft",detail:"Insert the draft below or replace the full document, depending on how broad the change should be."}:null}function ea(e,t){if(!e||!e.resolved)return"";var r=Zi(e,t);return r.operations.length&&r.canPreview?"preview":r.operations.length&&r.canApplyPlan?"apply":r.operations.length&&r.canInsert?"insert":r.resultText&&r.canReplaceSelection?"selection":r.resultText&&r.canInsert?"insert":""}function Wr(e){return e==="preview"?"Preview":e==="apply"?"Apply":e==="selection"?"Replace selection":e==="insert"?"Insert below":e==="document"?"Replace document":""}function ad(e){return e==="copy"?"Copy text":Wr(e)}function so(e,t,r){var i=Zi(t,r);return e==="copy"?"Copy this prepared AI reply without changing the document.":e==="apply"?"Run the prepared plan directly in the editor.":e==="preview"?i.hasSelection?"Show this change inline in the editor before deciding it.":"Select text to preview this change inline in the editor.":e==="selection"?i.hasSelection?"Replace the current selection with this prepared draft.":"Select text before replacing selection with this prepared draft.":e==="insert"?i.hasSelection?"Insert this prepared draft below the current selection.":"Insert this prepared draft below the current content.":e==="document"?"Replace the full document with this prepared draft.":""}function ta(e,t,r,i,a){if(e){var l=ad(t)||(e.innerText||e.textContent||"").replace(/\s+/g," ").trim()||"Action",n=so(t,r,a),u=!!(t&&i&&t===i),c=[l];n&&c.push(n),u&&c.push("Recommended next step."),e.setAttribute("aria-label",c.join(". ")),e.title=n?l+" - "+n+(u?" Recommended next step.":""):l+(u?" - Recommended next step.":"")}}function Sn(e){return e==="apply"||e==="preview"||e==="selection"?"primary":e==="insert"||e==="document"?"secondary":""}function nd(e,t,r,i){if(e==="utility")return"Copy this prepared reply without changing the document.";if(!t||!t.resolved)return"";var a=Zi(t,i);if(e==="primary")return r==="preview"?"Check the inline diff first, then apply or replace the selection from this group.":r==="apply"?"Run the prepared plan directly, or switch to the document handoff actions below if you want a different outcome.":r==="selection"?"Replace the selection first, or preview the inline diff before writing this change back.":a.operations.length?"Run the prepared plan directly from this group.":a.resultText&&a.hasSelection?"Preview the draft or write it back into the current selection from this group.":"Use this group to preview or apply the prepared change.";if(e==="secondary"){if(a.resultText&&a.hasSelection)return"Insert this prepared draft below the selection when you want a follow-up instead of a replacement.";if(r==="insert")return"Insert this draft below first, or replace the full document if the whole page should change.";if(r==="document")return"Replace the full document, or insert this draft below if you want a lighter handoff.";if(a.resultText)return"Insert this prepared draft below or replace the full document without opening inline review."}return""}function ld(e,t,r){var i=Sn(r);if(i&&e===i)return"Recommended next step";if(e==="utility")return"Copy only";if(!t||!t.resolved)return e==="primary"?"Preview and apply":e==="secondary"?"Other ways to use":"";var a=t.resolved||null,l=a&&a.operations?a.operations:[],n=a?Nt(a):"";if(e==="primary")return l.length?"Apply in editor":n?"Use this draft":"Preview and apply";if(e==="secondary"){if(l.length)return"Other ways to apply";if(n)return"Other ways to use this draft"}return""}function xn(e,t,r,i){var a={title:"",badge:"",recommended:!1,detail:""};a.title=ld(e,r,t);var l=Sn(t);return l&&e===l&&(a.badge=Wr(t),a.recommended=!!a.badge),a.detail=nd(e,r,t,i),a}function _l(e,t,r){if(!e||!t||!e.getElementsByTagName("button").length)return null;e.setAttribute("data-rte-ai-chat-group-key",r||""),t.recommended&&e.setAttribute("data-rte-ai-chat-group-recommended","true");var i="rte-ai-chat-message-action-group-header";t.recommended&&(i+=" is-recommended");var a=o(e,"div","",i);if(o(a,"div","","rte-ai-chat-message-action-group-title",t.title||""),t.badge&&o(a,"span","","rte-ai-chat-message-action-group-badge",t.badge),e.firstChild!==a&&e.insertBefore(a,e.firstChild),t.detail){var l=o(e,"div","","rte-ai-chat-message-action-group-detail",t.detail);a.nextSibling!==l&&e.insertBefore(l,a.nextSibling)}return a}function sd(e,t){if(!(!e||!e.querySelectorAll)){var r=Sn(t),i=e.querySelectorAll(".rte-ai-chat-message-action-group");if(!(!i||!i.length)){for(var a={},l=0;l<i.length;l++){var n=i[l],u=n.getAttribute("data-rte-ai-chat-group-key")||"";u&&(a[u]=n)}var c=[];r&&c.push(r);for(var f=["primary","secondary","utility"],p=0;p<f.length;p++)c.indexOf(f[p])===-1&&c.push(f[p]);for(var g=0;g<c.length;g++)a[c[g]]&&e.appendChild(a[c[g]])}}}function od(e,t){if(!(!e||!t||!e.querySelector)){var r=Sn(t);if(r){var i=e.querySelector('.rte-ai-chat-message-action-group[data-rte-ai-chat-group-key="'+r+'"]');if(!(!i||!i.querySelector)){var a=i.querySelector('.rte-ai-chat-action-button[data-rte-ai-chat-action="'+t+'"]');if(a){var l=i.querySelector(".rte-ai-chat-message-action-group-header"),n=i.querySelector(".rte-ai-chat-action-button");if(!(!n||n===a)){if(l&&l.nextSibling){i.insertBefore(a,l.nextSibling);return}i.insertBefore(a,n)}}}}}}function ud(e,t){if(!e)return"";var r=[];t&&t.title&&r.push(t.title+" group"),t&&t.recommended&&t.badge&&r.push(t.badge+" recommended"),t&&t.detail&&r.push(t.detail);for(var i=e.querySelectorAll?e.querySelectorAll(".rte-ai-chat-action-button"):[],a=[],l=0;l<i.length;l++){var n=(i[l].innerText||i[l].textContent||"").replace(/\s+/g," ").trim();n&&a.push(n)}return a.length&&r.push("Actions: "+a.join(", ")),r.join(". ")}function cd(e,t,r,i){if(!(!e||!e.querySelectorAll)){var a=Wr(t);e.setAttribute("role","group"),e.setAttribute("aria-label",a?"AI chat actions. Recommended next step: "+a+".":"AI chat actions");for(var l=e.querySelectorAll(".rte-ai-chat-message-action-group"),n=0;n<l.length;n++){var u=l[n],c=u.getAttribute("data-rte-ai-chat-group-key")||"",f=u.querySelector?u.querySelector(".rte-ai-chat-action-button"):null,p=xn(c,t,r,i);if(!f){u.removeAttribute("role"),u.removeAttribute("aria-label");continue}u.setAttribute("role","group");var g=ud(u,p);g?u.setAttribute("aria-label",g):u.removeAttribute("aria-label")}}}function oo(e){return!e||!e.snapshot?"":e.scope==="selection"?e.snapshot.text||e.snapshot.wholeText||"":e.snapshot.wholeText||""}function dd(e){return Be(oo(e),120)}function Ea(e){if(!e||!e.resolved)return null;var t=e.resolved.request&&e.resolved.request.mode?We(e.resolved.request.mode):"";return Aa({originalText:oo(e),resultText:Nt(e.resolved),suggestionType:t,snapshot:e.snapshot||null,scope:e.scope||""})}function fd(e,t){if(!e||!e.resolved)return null;var r=Be(Nt(e.resolved),120);if(!r)return null;var i=dd(e),a=e.resolved.operations||[],l=a.length?es(a[0]):null,n=a.length,u=l&&l.title?l.title:e.scope==="selection"?"Selection draft":"Document draft",c=ea(e,t),f=Ca(e,t),p=hd(e,c,t),g=Ea(e);return{title:l&&l.title?l.title:"Prepared draft",sourceText:i,resultText:r,reasonText:Be(pa(e.resolved),110),statusLabel:n?"Ready to review":"Draft ready",scopeLabel:e.scope==="selection"?"Selection draft":"Document draft",stepLabel:(n||1)+" step"+((n||1)===1?"":"s"),targetLabel:u,diffParts:i&&i!==r?mn(i,r):null,changeGlance:g,planLeadTitle:f?"Best next step":"",planLeadLabel:c?Wr(c):"",planLeadDetail:f?f.detail:"",planItems:p.slice(0,3),planFollowupTitle:vd(e,p),hiddenPlanCount:Math.max(0,p.length-3)}}function vd(e,t){if(!t||!t.length)return"";var r=e&&e.resolved?e.resolved:null,i=r&&r.operations?r.operations:[];return i.length?"Other ways to apply this change":"Other ways to use this draft"}function pd(e,t,r){if(!t)return null;var i=Wr(t);return i?{label:i,detail:so(t,e,r)}:null}function Sf(e){if(!e)return"";var t=[];return e.label&&t.push(e.label),e.detail&&t.push(e.detail),t.join(". ")}function hd(e,t,r){if(!e||!e.resolved)return[];var i=Zi(e,r),a=[];i.canApplyPlan&&a.push("apply"),i.canPreview&&a.push("preview"),i.canReplaceSelection&&a.push("selection"),i.canInsert&&a.push("insert"),i.canReplaceDocument&&a.push("document");for(var l=[],n=0;n<a.length;n++){var u=a[n];if(!(!u||u===t)){var c=pd(e,u,r);if(!(!c||!c.label)){for(var f=!1,p=0;p<l.length;p++)if(l[p]&&l[p].label===c.label){f=!0;break}f||l.push(c)}}}return l}function xf(e){if(!e)return"";var t=[];if(e.title&&t.push(e.title),e.statusLabel&&t.push(e.statusLabel),e.scopeLabel&&t.push(e.scopeLabel),e.stepLabel&&t.push(e.stepLabel),e.targetLabel&&t.push(e.targetLabel),t.push("Proposed edit"),t.push("Current and suggested text"),e.sourceText&&e.sourceText!==e.resultText&&(t.push("Current"),t.push(e.sourceText)),t.push("Suggested"),t.push(e.resultText),e.reasonText&&(t.push("Why this change"),t.push(e.reasonText)),e.changeGlance){if(e.changeGlance.title&&t.push(e.changeGlance.title),e.changeGlance.pills&&e.changeGlance.pills.length)for(var r=0;r<e.changeGlance.pills.length;r++)e.changeGlance.pills[r]&&e.changeGlance.pills[r].text&&t.push(e.changeGlance.pills[r].text);e.changeGlance.detail&&t.push(e.changeGlance.detail)}if(e.planLeadTitle||e.planLeadLabel||e.planLeadDetail||e.planItems&&e.planItems.length){if(t.push("What happens next"),e.planLeadTitle&&t.push(e.planLeadTitle),e.planLeadLabel&&t.push(e.planLeadLabel),e.planLeadDetail&&t.push(e.planLeadDetail),e.planFollowupTitle&&t.push(e.planFollowupTitle),e.planItems&&e.planItems.length)for(var i=0;i<e.planItems.length;i++){var a=e.planItems[i];a&&(a.label&&t.push(a.label),a.detail&&t.push(a.detail))}e.hiddenPlanCount&&t.push("+"+e.hiddenPlanCount+" more")}return t.join(". ")}function _n(e){var t=R(e||"");return t?t.length<=92?t:t.substring(0,89).replace(/\s+\S*$/,"")+"...":""}function Ll(e){var t=e&&e.id?String(e.id).toLowerCase():"",r=e&&e.label?String(e.label).toLowerCase():"",i=e&&e.prompt?String(e.prompt).toLowerCase():"",a=t+" "+r+" "+i;return/translate|spanish|french|german|italian|portuguese|japanese/.test(a)?"Language":/proofread|review|cleaner|grammar/.test(a)?"Review":/heading|title|subheading|structure/.test(a)?"Structure":/expand|supporting paragraph|detail/.test(a)?"Expand":/summarize|summary/.test(a)?"Summary":"Starter"}function gd(e){var t=Ll(e).toLowerCase().replace(/[^a-z0-9]+/g,"-");return t||"starter"}function uo(e){if(!e||!e.text)return"Custom";var t=Ll({prompt:e.text||""});return t==="Starter"?"Custom":t}function co(e){return uo(e)+" request"}function md(e,t){if(!e||!e.length||typeof t!="number")return null;for(var r=t-1;r>=0;r--)if(e[r]&&e[r].role==="user"&&!e[r].isError)return e[r];return null}function bd(e,t){var r=md(e,t);return r?{title:"Responding to "+co(r),scopeLabel:Ti(r),detail:"Latest user turn",promptText:r.text||""}:null}function _f(e,t,r){if(!e||e.isError||e.role!=="user")return"";var i=["What you asked"],a=co(e);a&&i.push(a);var l=Ti(e);l&&i.push(l);var n=Ma(t,r);return n&&i.push(n),e.text&&i.push(e.text),i.join(". ")}function Lf(e,t){if(!e)return"";var r=[];return e.title&&r.push(e.title),e.scopeLabel&&r.push(e.scopeLabel),e.detail&&r.push(e.detail),t&&r.push(t),e.promptText&&r.push(e.promptText),r.join(". ")}function wd(e,t,r){if(!e||typeof t!="number"||!e[t])return"";var i=e[t],a=[],l=no(i),n=td(ki(e,t)),u=Ti(i),c=rd(i),f=Ma(e,t),p=lo(i),g=xl(i);if(l&&a.push(l),a.push("Turn "+(t+1)),n&&a.push(n),u&&a.push(u),c&&a.push(c),f&&a.push(f),Ln(e,t)&&a.push("Current exchange"),p&&a.push(p),g&&a.push(g),i.role==="user"&&!i.isError){a.push("What you asked"),i.text&&a.push(_n(i.text)||i.text);var m=id(i);m&&(m.title&&a.push(m.title),m.wordLabel&&a.push(m.wordLabel),m.paragraphLabel&&a.push(m.paragraphLabel))}else if(i.role==="assistant"&&!i.isError){var b=bd(e,t);b&&b.title&&a.push(b.title),b&&b.promptText&&a.push(_n(b.promptText)||b.promptText);var h=Ca(i,r);h&&h.title&&a.push(h.title)}return a.join(". ")}function Rf(e){if(!e)return"";var t=[],r=e.isError?"Conversation issue":e.role==="user"?"User prompt":"Assistant response",i=lo(e),a=xl(e);return r&&t.push(r),i&&t.push(i),a&&t.push(a),t.join(". ")}function ki(e,t){if(!e||typeof t!="number"||!e[t])return"";var r=e[t];if(r.isError)return"";if(r.role==="user"){var i=e[t+1];if(i&&i.role==="assistant"&&!i.isError)return"request"}if(r.role==="assistant"){var a=e[t-1];if(a&&a.role==="user"&&!a.isError)return"response"}return""}function Pa(e,t){if(!e||typeof t!="number"||t<0)return 0;for(var r=0,i=0;i<=t;i++)e[i]&&e[i].role==="user"&&!e[i].isError&&r++;return r}function Ma(e,t){var r=Pa(e,t);return r?"Exchange "+r:""}function Ln(e,t){var r=Pa(e,t),i=Ci(e);return!!r&&r===i}function fo(e,t){if(!e||!e.length||typeof t!="number"||!e[t])return-1;var r=e[t];if(r.isError||r.role!=="user"||ki(e,t)!=="request")return-1;for(var i=Pa(e,t),a=t+1;a<e.length;a++)if(!(!e[a]||e[a].isError)){if(e[a].role==="user")break;if(e[a].role==="assistant"&&ki(e,a)==="response"&&Pa(e,a)===i)return a}return-1}function vo(e,t,r){if(!e||typeof t!="number"||!e[t])return null;var i=e[t];if(i.isError||i.role!=="user"||ki(e,t)!=="request")return null;var a=fo(e,t),l=a>=0?e[a]:null,n=uo(i),u="",c=null,f=[];if(l&&l.role==="assistant"&&!l.isError){var p=ea(l,r);u=Wr(p),c=Ea(l),u&&f.push(u+" is the recommended next step."),c&&c.detail&&f.push(c.detail)}return{title:(n==="Custom"?"Custom":n)+" exchange",exchangeLabel:Ma(e,t),scopeLabel:Ti(i),statusLabel:l&&l.role==="assistant"&&!l.isError?"Reply linked":"Waiting on reply",actionLabel:u,changeGlance:c,detail:f.join(" "),isCurrent:Ln(e,t)}}function Tf(e){if(!e)return"";var t=[];if(e.title&&t.push(e.title),e.exchangeLabel&&t.push(e.exchangeLabel),e.scopeLabel&&t.push(e.scopeLabel),e.statusLabel&&t.push(e.statusLabel),e.actionLabel&&(t.push("Best next step"),t.push(e.actionLabel)),e.changeGlance){if(t.push(e.changeGlance.title||"Change at a glance"),e.changeGlance.pills&&e.changeGlance.pills.length)for(var r=0;r<e.changeGlance.pills.length;r++)e.changeGlance.pills[r]&&e.changeGlance.pills[r].text&&t.push(e.changeGlance.pills[r].text);e.changeGlance.detail&&t.push(e.changeGlance.detail)}return e.isCurrent&&t.push("Current exchange"),e.detail&&t.push(e.detail),t.join(". ")}function yd(e,t,r){if(!e||typeof t!="number"||!e[t])return"";var i=e[t];if(i.isError||i.role!=="user"||ki(e,t)!=="request")return"";var a=vo(e,t,r),l=fo(e,t),n=l>=0?po(e,l,r):null,u=["AI chat exchange"];if(a&&a.exchangeLabel&&u.push(a.exchangeLabel),a&&a.title&&u.push(a.title),a&&a.scopeLabel&&u.push(a.scopeLabel+" thread"),i.text&&(u.push("Request"),u.push(_n(i.text))),n){if(n.statusLabel&&u.push(n.statusLabel),n.actionLabel&&(u.push("Best next step"),u.push(n.actionLabel)),n.changeGlance){if(u.push(n.changeGlance.title||"Change at a glance"),n.changeGlance.pills&&n.changeGlance.pills.length)for(var c=0;c<n.changeGlance.pills.length;c++)n.changeGlance.pills[c]&&n.changeGlance.pills[c].text&&u.push(n.changeGlance.pills[c].text);n.changeGlance.detail&&u.push(n.changeGlance.detail)}}else a&&a.statusLabel&&u.push(a.statusLabel);return a&&a.isCurrent&&u.push("Current exchange"),u.join(". ")}function po(e,t,r){if(!e||typeof t!="number"||!e[t])return null;var i=e[t];if(i.isError||i.role!=="assistant"||ki(e,t)!=="response")return null;var a=i.resolved||null,l=a&&a.operations?a.operations:[],n=a?Nt(a):"",u=ea(i,r),c=l.length?l.length:n?1:0,f=Ea(i),p=[];f&&f.detail&&p.push(f.detail);var g=(Ca(i,r)||{}).detail||xl(i);g&&p.push(g);var m="Reply ready";return l.length?m="Ready to review":n&&(m="Draft ready"),{title:"Exchange outcome",detail:p.join(" "),exchangeLabel:Ma(e,t),scopeLabel:Ti(i),statusLabel:m,stepLabel:c?c+" step"+(c===1?"":"s"):"",actionLabel:Wr(u),changeGlance:f,isCurrent:Ln(e,t)}}function kf(e){if(!e)return"";var t=[];if(e.title&&t.push(e.title),e.exchangeLabel&&t.push(e.exchangeLabel),e.statusLabel&&t.push(e.statusLabel),e.scopeLabel&&t.push(e.scopeLabel),e.stepLabel&&t.push(e.stepLabel),e.actionLabel&&t.push(e.actionLabel),e.changeGlance&&(t.push(e.changeGlance.title||"Change at a glance"),e.changeGlance.pills&&e.changeGlance.pills.length))for(var r=0;r<e.changeGlance.pills.length;r++)e.changeGlance.pills[r]&&e.changeGlance.pills[r].text&&t.push(e.changeGlance.pills[r].text);return e.isCurrent&&t.push("Current exchange"),e.detail&&t.push(e.detail),t.join(". ")}function Rn(e){var t=R(e||"");return t?t.split(/\s+/).length:0}function ho(e){var t=R(e||"");return t?t.split(/\n+/).filter(function(r){return!!r}).length:0}function Ad(e){return e&&e.scope==="selection"?"Selected passage":"Document snapshot"}function Rl(e,t){var r=R(e&&e.draft?e.draft:"");if(!r||!t||!t.length)return null;for(var i=0;i<t.length;i++){var a=t[i];if(a&&R(a.prompt||"")===r)return a}return null}function go(e,t){var r=R(e&&e.status?e.status:"");if(!r)return"";var i=t&&t.scope==="selection"?"selection":"document";return/^select text first to use selection scope\.?$/i.test(r)?i==="selection"?"Chat will use the current selection.":"Select text to switch AI Chat back to selection scope.":/^chat will use the current selection\.?$/i.test(r)?i==="selection"?"Chat will use the current selection.":"Selection scope is unavailable right now. Chat will use the whole document until you select text again.":/^chat will use the whole document\.?$/i.test(r)?"Chat will use the whole document.":e.status}function mo(e,t){if(e&&e.busy)return"busy";var r=R(go(e,t)).toLowerCase();return r?/could not|issue|error|select text first/.test(r)?"error":/started|loaded|ready|will use|copied|previewed|applied/.test(r)?"ready":"idle":"idle"}function Sd(e,t,r){if(e&&e.busy)return"Thinking through the current "+(t&&t.scope==="selection"?"selection":"document")+"...";var i=go(e,t);if(i)return i;var a=t&&t.scope==="selection"?"selection":"document";return r&&r.label?"Ready to run the "+r.label+" starter on the current "+a+".":R(e&&e.draft?e.draft:"")?"Custom prompt ready for the current "+a+".":"Ready to ask about the current "+a+"."}function xd(e,t,r){var i=[],a=Ci(e&&e.messages?e.messages:[]),l=e&&e.messages?e.messages.length:0;return Ot(i,t&&t.scope==="selection"?"Selection context":"Document context","is-scope"),Ot(i,a+" exchange"+(a===1?"":"s"),"is-exchanges"),Ot(i,l+" message"+(l===1?"":"s"),"is-messages"),Ot(i,"Enter sends","is-send"),r?Ot(i,"Starter: "+(r.label||r.id||"Prompt"),"is-starter"):R(e&&e.draft?e.draft:"")?Ot(i,"Custom prompt","is-custom"):Ot(i,"Ready for a new ask","is-prompt"),Ot(i,String(R(e&&e.draft?e.draft:"").length)+" chars","is-count"),i}function bo(e,t,r){var i=mo(e,t);return{title:"Compose",statusTone:i,statusLabel:i==="busy"?"Working":i==="error"?"Needs attention":i==="ready"?"Ready":"Compose",statusText:Sd(e,t,r),metaPills:xd(e,t,r)}}function wo(e){if(!e)return"";var t=[];if(e.title&&t.push(e.title),e.statusLabel&&t.push(e.statusLabel),e.statusText&&t.push(e.statusText),e.metaPills&&e.metaPills.length)for(var r=0;r<e.metaPills.length;r++)e.metaPills[r]&&e.metaPills[r].text&&t.push(e.metaPills[r].text);return t.join(". ")}function Tl(e,t,r){var i=t&&t.scope==="selection"?"selection":"document",a=!!R(e&&e.draft?e.draft:"");return e&&e.busy?{text:"Thinking...",disabled:!0,ariaLabel:"Send disabled while AI Chat is thinking about the current "+i+".",title:"AI Chat is thinking about the current "+i+"."}:r&&r.label?{text:"Send starter",disabled:!1,ariaLabel:"Send starter. Send the "+r.label+" starter for the current "+i+".",title:"Send the "+r.label+" starter for the current "+i+"."}:a?{text:"Send prompt",disabled:!1,ariaLabel:"Send prompt. Send the custom prompt for the current "+i+".",title:"Send the custom prompt for the current "+i+"."}:{text:"Send",disabled:!0,ariaLabel:"Send disabled. Type a prompt or load a starter for the current "+i+" first.",title:"Type a prompt or load a starter for the current "+i+" first."}}function yo(e){return"Compose actions. Open Ask AI. "+(e&&e.ariaLabel?e.ariaLabel:"Send.")}function _d(e){return!e||!e.messages||!e.messages.length?null:e.messages[e.messages.length-1]||null}function Ci(e){if(!e||!e.length)return 0;for(var t=0,r=0;r<e.length;r++)e[r]&&e[r].role==="user"&&!e[r].isError&&t++;return t}function Ao(e,t,r){if(!(!e||!t)){for(var i=0;i<e.length;i++)if(e[i]&&e[i].text===t)return;e.push({text:t,className:r||""})}}function Ld(e){if(!e)return"";for(var t=e.pills||[],r="",i="",a=0;a<t.length;a++){var l=t[a];!l||!l.text||(!r&&l.kind==="change"?r=l.text:!i&&l.kind==="impact"&&(i=l.text))}var n=[];return r&&i?n.push("This is a "+i.toLowerCase()+" "+r.toLowerCase()+"."):r?n.push("This is a "+r.toLowerCase()+"."):i&&n.push("This is "+i.toLowerCase()+"."),e.detail&&n.push(e.detail),n.join(" ")}function qa(e,t){var r=_d(e);if(!r)return null;var i=t&&t.snapshot?t.snapshot:null,a=t&&t.scope==="selection"?"selection":"document",l=a==="selection"?"Selection thread":"Document thread",n=e&&e.messages?e.messages.length:0,u=Ci(e&&e.messages?e.messages:[]),c=u+" exchange"+(u===1?"":"s"),f=n+" message"+(n===1?"":"s"),p=u?c+", "+f:f,g="Prompt sent to AI",m="Conversation live",b=[],h=[];if(e&&e.busy)g="Working on your latest request",m="Working",b.push(p+" in this "+a+" thread."),b.push("The assistant is preparing the next reply.");else if(r.isError)g="Latest reply needs attention",m="Needs attention",b.push(p+" in this "+a+" thread."),b.push("Adjust the prompt or try again.");else if(r.role==="assistant"){var y=r.resolved||null,A=y&&y.operations?y.operations:[],K=y?Nt(y):"",S=ea(r,i),q=Wr(S),M=Ea(r),P=Ld(M),L=Ca(r,i);if(b.push(p+" in this "+a+" thread."),A.length?(g="Latest review exchange is ready",m="Ready to review"):K?(g="Latest draft exchange is ready",m="Draft ready"):(g="Latest reply is ready",m="Reply ready"),q&&(b.push(q+" is the recommended next step."),Ao(h,q,"is-action")),M&&M.pills&&M.pills.length)for(var D=0;D<M.pills.length;D++){var J=M.pills[D];!J||!J.text||Ao(h,J.text,J.kind?"is-"+J.kind:"")}P?b.push(P):L&&L.detail&&b.push(L.detail)}else b.push(p+" in this "+a+" thread.");return h.unshift({text:f,className:"is-count"}),h.unshift({text:c,className:"is-exchanges"}),h.unshift({text:l,className:"is-scope"}),h.unshift({text:m,className:"is-status"}),{title:g,detail:b.join(" "),statusLabel:m,scopeLabel:l,exchangeLabel:c,messageLabel:f,actionLabel:r.role==="assistant"?Wr(ea(r,i)):"",changeGlance:r.role==="assistant"?Ea(r):null,pills:h}}function Cf(e){if(!e)return"";var t=["AI chat feed summary"];if(e.title&&t.push(e.title),e.statusLabel&&t.push(e.statusLabel),e.scopeLabel&&t.push(e.scopeLabel),e.exchangeLabel&&t.push(e.exchangeLabel),e.messageLabel&&t.push(e.messageLabel),e.actionLabel&&(t.push("Best next step"),t.push(e.actionLabel)),e.changeGlance){t.push(e.changeGlance.title||"Change at a glance");for(var r=e.changeGlance.pills||[],i=0;i<r.length;i++)r[i]&&r[i].text&&t.push(r[i].text);e.changeGlance.detail&&t.push(e.changeGlance.detail)}return t.join(". ")}function So(e,t,r){var i=t&&t.scope==="selection"?"selection":"document",a=Ci(e&&e.messages?e.messages:[]),l=e&&e.messages?e.messages.length:0,n=!!R(e&&e.draft?e.draft:""),u="Your first answer, draft, or reviewable change for the current "+i+" will appear here.",c=[{text:"Waiting for first ask",className:"is-status"}];return r&&r.label?(c[0]={text:"Starter ready",className:"is-status"},c.push({text:r.label+" starter",className:"is-starter"}),u="Press Enter to send the "+r.label+" starter for the current "+i+", or edit it in Compose first."):n&&(c[0]={text:"Draft ready",className:"is-status"},c.push({text:"Custom prompt",className:"is-custom"}),u="Press Enter to send your custom prompt for the current "+i+", or keep editing it in Compose."),c.push({text:a+" exchange"+(a===1?"":"s"),className:"is-exchanges"},{text:l+" message"+(l===1?"":"s"),className:"is-count"}),{title:"First exchange",detail:u,metaPills:c}}function Rd(e){if(!e)return"";var t=[];if(e.title&&t.push(e.title),e.metaPills&&e.metaPills.length)for(var r=0;r<e.metaPills.length;r++)e.metaPills[r]&&e.metaPills[r].text&&t.push(e.metaPills[r].text);return e.detail&&t.push(e.detail),t.join(". ")}function xo(e,t,r){var i=["Conversation"];if(e&&e.messages&&e.messages.length){var a=qa(e,t);return a&&a.title&&i.push(a.title),a&&a.statusLabel&&i.push(a.statusLabel),a&&a.scopeLabel&&i.push(a.scopeLabel),a&&a.exchangeLabel&&i.push(a.exchangeLabel),a&&a.messageLabel&&i.push(a.messageLabel),a&&a.actionLabel&&(i.push("Best next step"),i.push(a.actionLabel)),a&&a.detail&&i.push(a.detail),i.join(". ")}var l=So(e,t,r);if(l.title&&i.push(l.title),l.metaPills&&l.metaPills.length)for(var n=0;n<l.metaPills.length;n++)l.metaPills[n]&&l.metaPills[n].text&&i.push(l.metaPills[n].text);return l.detail&&i.push(l.detail),i.join(". ")}function Td(e,t){var r=qa(e,t);return r?r.title:""}function Ef(e,t){var r=qa(e,t);return r?r.detail:""}function Pf(e,t){var r=qa(e,t);return r?r.statusLabel:""}function kd(e,t){var r=mo(e,t);return r==="busy"?"Working":r==="error"?"Needs attention":"Ready"}function Cd(e,t,r){var i=t&&t.scope==="selection"?"selection":"document",a=e&&e.messages?e.messages.length:0,l=Ci(e&&e.messages?e.messages:[]),n=l?l+" exchange"+(l===1?"":"s")+", "+a+" message"+(a===1?"":"s"):a+" message"+(a===1?"":"s");return e&&e.busy?a?n+" in this conversation for the current "+i+". Preparing the next reply.":"Preparing help for the current "+i+".":r&&r.label?r.label+" starter is loaded for the current "+i+".":!a&&R(e&&e.draft?e.draft:"")?"Custom prompt is ready for the current "+i+".":a?n+" in this conversation for the current "+i+". "+Td(e)+".":"Ask, rewrite, or review the current "+i+" in place."}function Ot(e,t,r){if(!(!e||!t)){for(var i=0;i<e.length;i++)if(e[i]&&e[i].text===t)return;e.push({text:t,className:r||""})}}function Ed(e,t,r){var i=[],a=t&&t.scope==="selection"?"Selection thread":"Document thread",l=e&&e.messages?e.messages.length:0,n=Ci(e&&e.messages?e.messages:[]),u=qa(e,t);return Ot(i,a,"is-scope"),Ot(i,n+" exchange"+(n===1?"":"s"),"is-exchanges"),Ot(i,l+" message"+(l===1?"":"s"),"is-messages"),Ot(i,Rn(t&&t.source?t.source:"")+" words","is-words"),u&&u.actionLabel?Ot(i,u.actionLabel,"is-action"):Ot(i,r&&r.label?r.label+" starter":R(e&&e.draft?e.draft:"")?"Custom draft":"Ready for a new ask","is-prompt"),i}function _o(e,t,r){return{statusLabel:kd(e,t),scopeFocusLabel:t&&t.scope==="selection"?"Selection focus":"Document focus",subtitle:Cd(e,t,r),metaPills:Ed(e,t,r)}}function Lo(e,t){var r=[];if(e&&r.push(e),!t)return r.join(". ");if(t.statusLabel&&r.push(t.statusLabel),t.scopeFocusLabel&&r.push(t.scopeFocusLabel),t.subtitle&&r.push(t.subtitle),t.metaPills&&t.metaPills.length)for(var i=0;i<t.metaPills.length;i++)t.metaPills[i]&&t.metaPills[i].text&&r.push(t.metaPills[i].text);return r.join(". ")}function Ro(e){var t=e&&e.scope==="selection",r=!!(e&&e.snapshot&&e.snapshot.hasSelection),i=e&&e.source?e.source:"",a=[{text:Rn(i)+" words",className:"is-words"},{text:R(i).length+" chars",className:"is-chars"}],l=ho(i);return l>1&&a.push({text:l+" paragraphs",className:"is-paragraphs"}),{title:"Context",detail:t?"Using the selected passage as the active source. Switch to document to widen the ask.":r?"Using the whole document as the active source. Switch to selection to narrow the ask.":"Using the whole document as the active source. Select text any time to narrow the ask.",summaryPills:[{text:t?"Selection active":"Document active",className:t?"is-selection":"is-document"},{text:r?"Selection available":"No current selection",className:r?"is-available":"is-empty"}],previewTitle:Ad(e),previewMetaPills:a,previewSummary:e&&e.summary?e.summary:"The document is currently empty.",scopeIsSelection:t,hasSelection:r}}function To(e){if(!e)return"";var t=[];if(e.title&&t.push(e.title),e.summaryPills&&e.summaryPills.length)for(var r=0;r<e.summaryPills.length;r++)e.summaryPills[r]&&e.summaryPills[r].text&&t.push(e.summaryPills[r].text);if(e.detail&&t.push(e.detail),e.previewTitle&&t.push(e.previewTitle),e.previewMetaPills&&e.previewMetaPills.length)for(var i=0;i<e.previewMetaPills.length;i++)e.previewMetaPills[i]&&e.previewMetaPills[i].text&&t.push(e.previewMetaPills[i].text);return e.previewSummary&&t.push(e.previewSummary),t.join(". ")}function ko(e){if(!e)return"";var t=["Context scope switch"];if(e.summaryPills&&e.summaryPills.length)for(var r=0;r<e.summaryPills.length;r++)e.summaryPills[r]&&e.summaryPills[r].text&&t.push(e.summaryPills[r].text);return t.join(". ")}function Tn(e,t){var r=e==="selection";return r?!t||!t.hasSelection?"Use selection. Unavailable until text is selected.":t.scopeIsSelection?"Use selection. Active scope. AI Chat is using the current selection.":"Use selection. Available scope. Switch AI Chat to the current selection.":t&&t.scopeIsSelection?"Use document. Available scope. Switch AI Chat to the whole document.":"Use document. Active scope. AI Chat is using the whole document."}function Pd(e){if(!e)return"";var t=[];if(e.previewTitle&&t.push(e.previewTitle),e.previewMetaPills&&e.previewMetaPills.length)for(var r=0;r<e.previewMetaPills.length;r++)e.previewMetaPills[r]&&e.previewMetaPills[r].text&&t.push(e.previewMetaPills[r].text);return e.previewSummary&&t.push(e.previewSummary),t.join(". ")}function Co(e,t,r,i){var a=t&&t.length?t.length:0,l=!!R(e&&e.draft?e.draft:""),n=i&&i.scope==="selection"?"selection":"document",u=r?(r.label||r.id||"Prompt")+" starter":l?"Custom prompt":"Ready to choose",c=r?"Press Enter in Compose to send the loaded starter for the current "+n+", or edit it first.":l?"Keep writing your prompt for the current "+n+", or switch to a starter before you send.":"Choose a starter for the current "+n+" or keep typing your own prompt in Compose.";return{title:"Quick starts",detail:c,metaPills:[{text:n==="selection"?"Selection context":"Document context",className:"is-scope"},{text:a+" starters",className:"is-count"},{text:u,className:r?"is-active":l?"is-custom":"is-ready"}]}}function Eo(e){if(!e)return"";var t=[];if(e.title&&t.push(e.title),e.metaPills&&e.metaPills.length)for(var r=0;r<e.metaPills.length;r++)e.metaPills[r]&&e.metaPills[r].text&&t.push(e.metaPills[r].text);return e.detail&&t.push(e.detail),t.join(". ")}function Po(e,t,r){var i=[],a=e&&(e.label||e.id)?e.label||e.id:"Prompt",l=r&&r.scope==="selection"?"selection":"document";i.push(a);var n=Ll(e);n&&i.push(n+" starter");var u=_n(e&&e.prompt?e.prompt:"");return u&&i.push(u),i.push(t?"Current starter loaded in Compose for the current "+l:"Loads this starter into Compose for the current "+l),i.join(". ")}function Mo(e){return"Starter buttons for the current "+(e&&e.scope==="selection"?"selection":"document")}function qo(e,t){var r=[{title:"Ask and explore",copy:"Get answers, summaries, headings, or rewrite direction grounded in the current context."},{title:"Prepare reviewable edits",copy:"Preview inline changes, apply structured plans, or turn responses into review-ready suggestions."},{title:"Use starters or type your own",copy:"Choose one of the curated quick starts above or write a custom prompt in the composer below."}];return{title:"Start with AI Chat",detail:e.scope==="selection"?"Ask anything about the current selection.":"Ask anything about the current document.",metaPills:[{text:e.scope==="selection"?"Selection context":"Document context",className:"is-scope"},{text:(t&&t.length?t.length:0)+" starters",className:"is-prompts"},{text:Rn(e.source)+" words in scope",className:"is-size"}],capabilityCards:r}}function Md(e){if(!e)return"";var t=[];return e.title&&t.push(e.title),e.copy&&t.push(e.copy),t.join(". ")}function Io(e){if(!e)return"";var t=[];if(e.title&&t.push(e.title),e.detail&&t.push(e.detail),e.metaPills&&e.metaPills.length)for(var r=0;r<e.metaPills.length;r++)e.metaPills[r]&&e.metaPills[r].text&&t.push(e.metaPills[r].text);if(e.capabilityCards&&e.capabilityCards.length)for(var i=0;i<e.capabilityCards.length;i++)t.push(Md(e.capabilityCards[i]));return t.join(". ")}function qd(e){if(e)for(;e.firstChild;)e.removeChild(e.firstChild)}function Ei(e,t,r){if(e){qd(e);for(var i=t||[],a=0;a<i.length;a++)!i[a]||!i[a].text||o(e,"span","",r+(i[a].className?" "+i[a].className:""),i[a].text)}}function kl(e,t,r,i){if(e){var a=Rl(t,i),l=Ro(r),n=_o(t,r,a),u=t.messages.length?null:qo(r,i),c=bo(t,r,a),f=Co(t,i,a,r),p=t.messages.length?null:So(t,r,a),g=Tl(t,r,a),m=e.querySelector(".rte-ai-chat-header");m&&m.setAttribute("aria-label",Lo(k.text_aichat||"AI Chat",n));var b=e.querySelector(".rte-ai-chat-header-status.is-status");b&&(b.innerHTML="",b.innerText=n.statusLabel);var h=e.querySelector(".rte-ai-chat-header-status.is-scope");h&&(h.innerHTML="",h.innerText=n.scopeFocusLabel);var y=e.querySelector(".rte-ai-chat-subtitle");y&&(y.innerHTML="",y.innerText=n.subtitle),Ei(e.querySelector(".rte-ai-chat-header-meta"),n.metaPills,"rte-ai-chat-header-meta-pill");var A=e.querySelector(".rte-ai-chat-context-shell");A&&(A.setAttribute("aria-label",To(l)),A.classList.toggle("is-no-selection-actionable",!l.hasSelection));var K=e.querySelector(".rte-ai-chat-context-bar");K&&K.setAttribute("aria-label",ko(l));var S=e.querySelectorAll(".rte-ai-chat-scope-button");S.length>0&&(S[0].disabled=!l.hasSelection,S[0].setAttribute("aria-label",Tn("selection",l)),l.scopeIsSelection?S[0].classList.add("is-active"):S[0].classList.remove("is-active")),S.length>1&&(S[1].setAttribute("aria-label",Tn("document",l)),l.scopeIsSelection?S[1].classList.remove("is-active"):S[1].classList.add("is-active")),Ei(e.querySelector(".rte-ai-chat-context-summary-meta"),l.summaryPills,"rte-ai-chat-context-summary-pill");var q=e.querySelector(".rte-ai-chat-context-summary-text");q&&(q.innerHTML="",q.innerText=l.detail);var M=e.querySelector(".rte-ai-chat-context-preview");M&&(M.className="rte-ai-chat-context-preview is-"+(r&&r.scope==="selection"?"selection":"document"),M.setAttribute("aria-label",Pd(l)));var P=e.querySelector(".rte-ai-chat-context-preview-title");P&&(P.innerHTML="",P.innerText=l.previewTitle),Ei(e.querySelector(".rte-ai-chat-context-preview-meta"),l.previewMetaPills,"rte-ai-chat-context-preview-pill");var L=e.querySelector(".rte-ai-chat-context-preview-copy");L&&(L.innerHTML="",L.innerText=l.previewSummary);var D=e.querySelector(".rte-ai-chat-quick-shell");D&&D.setAttribute("aria-label",Eo(f));var J=e.querySelector(".rte-ai-chat-quick-row");J&&J.setAttribute("aria-label",Mo(r));for(var E=e.querySelectorAll(".rte-ai-chat-quick-button"),W=0;W<E.length&&W<i.length;W++){var de=i[W],$=!!(t.draft&&de&&de.prompt&&R(t.draft)===R(de.prompt));$?E[W].classList.add("is-active"):E[W].classList.remove("is-active"),E[W].setAttribute("aria-label",Po(de,$,r))}Ei(e.querySelector(".rte-ai-chat-quick-summary-meta"),f.metaPills,"rte-ai-chat-quick-summary-pill");var I=e.querySelector(".rte-ai-chat-quick-summary-text");I&&(I.innerHTML="",I.innerText=f.detail);var le=e.querySelector(".rte-ai-chat-compose-shell");le&&le.setAttribute("aria-label",wo(c));var Z=e.querySelector(".rte-ai-chat-input");Z&&Z.setAttribute("aria-label","Compose next AI request for the current "+(r&&r.scope==="selection"?"selection":"document"));var se=e.querySelector(".rte-ai-chat-composer-meta");se&&se.setAttribute("aria-label",(c.metaPills||[]).map(function(Me){return Me&&Me.text?Me.text:""}).filter(function(Me){return!!Me}).join(". ")),Ei(se,c.metaPills,"rte-ai-chat-composer-pill");var B=e.querySelector(".rte-ai-chat-status");B&&(B.className="rte-ai-chat-status is-"+c.statusTone,B.setAttribute("aria-label",c.statusLabel+". "+c.statusText));var j=e.querySelector(".rte-ai-chat-status-pill");j&&(j.className="rte-ai-chat-status-pill is-"+c.statusTone,j.innerHTML="",j.innerText=c.statusLabel);var G=e.querySelector(".rte-ai-chat-status-text");G&&(G.innerHTML="",G.innerText=c.statusText);var xe=e.querySelector(".rte-ai-chat-composer-actions");xe&&xe.setAttribute("aria-label",yo(g));var ue=e.querySelector(".rte-ai-chat-send-button");if(ue&&(ue.disabled=!!g.disabled,ue.setAttribute("aria-label",g.ariaLabel),ue.title=g.title,ue.classList.toggle("is-busy",!!t.busy),ve(ue,t.busy?"spinner":"send",g.text)),!t.messages.length&&p){var X=e.querySelector(".rte-ai-chat-feed-shell");X&&X.setAttribute("aria-label",xo(t,r,a));var De=e.querySelector(".rte-ai-chat-feed-intro");De&&De.setAttribute("aria-label",Rd(p));var Re=e.querySelector(".rte-ai-chat-feed-intro-title");Re&&(Re.innerHTML="",Re.innerText=p.title);var we=e.querySelector(".rte-ai-chat-feed-intro-detail");we&&(we.innerHTML="",we.innerText=p.detail),Ei(e.querySelector(".rte-ai-chat-feed-intro-meta"),p.metaPills,"rte-ai-chat-feed-intro-pill");var Te=e.querySelector(".rte-ai-chat-empty");Te&&u&&Te.setAttribute("aria-label",Io(u));var Xe=e.querySelector(".rte-ai-chat-empty-title");Xe&&u&&(Xe.innerHTML="",Xe.innerText=u.title);var pt=e.querySelector(".rte-ai-chat-empty-detail");pt&&u&&(pt.innerHTML="",pt.innerText=u.detail),Ei(e.querySelector(".rte-ai-chat-empty-meta"),u?u.metaPills:[],"rte-ai-chat-empty-pill")}}}function Id(){if(!(!s||!s.__aiChatPanel||!s.__aiChatPanel.isConnected)){var e=Zt();if(e&&e.messages&&e.messages.length){Et(!1);return}kl(s.__aiChatPanel,e,Ra(),k.aiToolkitChatPrompts||[])}}function Hd(){s&&(s.__aiChatSyncTimer&&clearTimeout(s.__aiChatSyncTimer),s.__aiChatSyncTimer=setTimeout(function(){s.__aiChatSyncTimer=0,Id()},0))}function Ho(){if(!(!s||!s.getEditable)){var e=s.getEditable?s.getEditable():null,t=s.__aiToolkitLiveSyncHandler||(s.__aiToolkitLiveSyncHandler=function(){Hd(),Dd()});e&&e.addEventListener&&s.__aiToolkitLiveSyncEditable!==e&&(e.addEventListener("input",t),e.addEventListener("keyup",t),e.addEventListener("mouseup",t),e.addEventListener("focus",t),s.__aiToolkitLiveSyncEditable=e);var r=e&&e.ownerDocument?e.ownerDocument:null;r&&r.addEventListener&&s.__aiToolkitLiveSyncDocument!==r&&(r.addEventListener("selectionchange",t),s.__aiToolkitLiveSyncDocument=r)}}function jd(){!s||!s.__aiDialog||!s.__aiDialog.isConnected||typeof s.__aiDialog.__aiSyncFromEditor!="function"||s.__aiDialog.__aiSyncFromEditor()}function Dd(){s&&(s.__aiDialogSyncTimer&&clearTimeout(s.__aiDialogSyncTimer),s.__aiDialogSyncTimer=setTimeout(function(){s.__aiDialogSyncTimer=0,jd()},0))}function Et(e){var t=Ri();if(!t)return!1;var r=e?null:Wc(s.__aiChatPanel),i=e?null:Xc(s.__aiChatPanel),a=Zt(),l=Ra(),n=k.aiToolkitChatPrompts||[],u=Rl(a,n);if(Xi({preserveReturnFocus:!0}),s.__aiChatOriginalMinHeight=t.style&&t.style.minHeight||"",t.classList.add("rte-ai-chat-host"),t.style){var c=window.innerWidth<=900?260:280;t.style.minHeight=Math.max(t.offsetHeight||0,c)+"px"}s.__aiChatShell=t;var f=o(t,"div","","rte-ai-chat-panel");f.setAttribute("role","complementary"),f.setAttribute("aria-label",k.text_aichat||"AI Chat"),f.tabIndex=-1,s.__aiChatPanel=f,f.onkeydown=function(C){C.key==="Escape"&&(C.preventDefault(),Xi({restoreFocus:!0}))};var p=_o(a,l,u),g=k.text_aichat||"AI Chat",m=o(f,"div","","rte-ai-chat-header is-minimal");m.setAttribute("role","group"),m.setAttribute("aria-label",Lo(g,p));var b=o(m,"div","","rte-ai-chat-header-copy"),h=o(b,"div","","rte-ai-chat-title-row"),y=o(h,"span","","rte-ai-chat-title-icon");y.innerHTML=k.svgCode_aiassist_chat||k.svgCode_aiassist||"",o(h,"div","","rte-ai-chat-title",g);var A=o(m,"div","","rte-ai-chat-header-actions"),K=o(A,"button","","secondary rte-ai-chat-header-button is-icon-only");K.type="button",K.setAttribute("data-rte-ai-chat-header-action","new-chat"),K.title="Start a fresh chat",K.setAttribute("aria-label","Start a fresh chat"),ve(K,"refresh",""),K.onclick=function(){zc(a,"Started a fresh AI chat."),Et(!0)};var S=o(A,"button","","rte-ai-panel-close-button");S.type="button",S.setAttribute("data-rte-ai-chat-header-action","close"),S.setAttribute("aria-label","Close AI chat"),S.title="Close",S.innerHTML='<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 6l12 12"/><path d="M18 6L6 18"/></svg>',S.onclick=function(){Xi({restoreFocus:!0})};var q=Ro(l),M=o(f,"div","","rte-ai-chat-stack rte-ai-chat-context-shell is-minimal"+(l.snapshot.hasSelection?"":" is-no-selection-actionable"));M.setAttribute("role","group"),M.setAttribute("aria-label",To(q));var P=o(M,"div","","rte-ai-chat-context-bar");P.setAttribute("role","group"),P.setAttribute("aria-label",ko(q));var L=o(P,"button","","rte-ai-chat-scope-button is-icon-only"+(q.scopeIsSelection?" is-active":""));L.type="button",L.disabled=!l.snapshot.hasSelection,L.setAttribute("data-rte-ai-chat-scope-target","selection"),L.setAttribute("aria-label",Tn("selection",q)),L.title="Use selection",ve(L,"cursorText",""),L.onclick=function(){var C=st();a.scope="selection",a.status=C.hasSelection?"Chat will use the current selection.":"Select text first to use selection scope.",Et(!0)};var D=o(P,"button","","rte-ai-chat-scope-button is-icon-only"+(q.scopeIsSelection?"":" is-active"));D.type="button",D.setAttribute("data-rte-ai-chat-scope-target","document"),D.setAttribute("aria-label",Tn("document",q)),D.title="Use document",ve(D,"document",""),D.onclick=function(){a.scope="document",a.status="Chat will use the whole document.",Et(!0)};var J=Co(a,n,u,l),E=o(f,"div","","rte-ai-chat-stack rte-ai-chat-quick-shell is-minimal"+(a.messages.length?" is-conversation":""));E.setAttribute("role","group"),E.setAttribute("aria-label",Eo(J));var W=o(E,"div","","rte-ai-chat-quick-row");W.setAttribute("role","group"),W.setAttribute("aria-label",Mo(l));for(var de=0;de<n.length;de++)(function(C){var me=!!(a.draft&&C.prompt&&R(a.draft)===R(C.prompt)),N=o(W,"button","","rte-ai-chat-quick-button is-chip"+(me?" is-active":""));N.type="button",N.setAttribute("data-rte-ai-chat-prompt-tone",gd(C)),N.setAttribute("data-rte-ai-chat-prompt-id",C.id||C.label||String(de)),N.title=C.prompt||"",N.setAttribute("aria-label",Po(C,me,l)),ve(N,cf(C),C.label||C.id||"Prompt"),N.onclick=function(){a.draft=C.prompt||"",a.status="Loaded the "+(C.label||C.id||"starter prompt")+" quick start.",Et(!0)}})(n[de]);var $=to(a,4);if($.length>1){var I=o(f,"div","","rte-ai-chat-stack rte-ai-chat-history-shell is-minimal");I.setAttribute("role","group"),I.setAttribute("aria-label","Recent AI chats");for(var le=o(I,"div","","rte-ai-chat-quick-row rte-ai-chat-history-row"),Z=0;Z<$.length;Z++)(function(C,me){var N=C.id===a.sessionId,ee=o(le,"button","","rte-ai-chat-quick-button is-chip"+(N?" is-active":""));ee.type="button",ee.setAttribute("data-rte-ai-chat-session-id",C.id),ee.title=(C.title||"Recent chat")+" - "+(C.exchangeCount||0)+" exchange"+((C.exchangeCount||0)===1?"":"s"),ee.setAttribute("aria-label",(N?"Current chat. ":"Open recent chat. ")+(C.title||"Recent chat")+". "+(C.messageCount||0)+" message"+((C.messageCount||0)===1?"":"s")+"."),ve(ee,N?"history":"chat",(me===0&&N?"Current":"Recent")+": "+(C.title||"Chat")),ee.onclick=function(){N||ro(a,C.id,"Loaded a recent AI chat.")&&Et(!0)}})($[Z],Z)}var se=o(f,"div","","rte-ai-chat-stack rte-ai-chat-feed-shell is-minimal");se.setAttribute("role","group"),se.setAttribute("aria-label",xo(a,l,u));var B=o(se,"div","","rte-ai-chat-feed");if(!a.messages.length){var j=qo(l,n),G=o(B,"div","","rte-ai-chat-empty is-minimal is-flat");G.setAttribute("role","group"),G.setAttribute("aria-label",Io(j));var xe=document.createElement("div");xe.className="rte-ai-chat-empty-art is-detached",xe.setAttribute("aria-hidden","true");var ue=!!(n&&n.length),X=l.scope==="selection"?"Ask anything about the current selection":"Ask anything about the current document";o(G,"div","","rte-ai-chat-empty-detail",ue?X+" \u2014 or tap a quick start above.":X+".")}for(var De=null,Re=0,we=0;we<a.messages.length;we++){if(0){var Te,Xe,pt,Me;for(var Ke;Ke<Me.length;Ke++)var ge}(function(C,me){var N=ki(a.messages,me),ee=Pa(a.messages,me),Ae=Ma(a.messages,me),Se=Ln(a.messages,me),_e=B;N==="request"?(De=o(B,"div","","rte-ai-chat-exchange-group"),Ae&&De.setAttribute("data-rte-ai-chat-exchange-index",Ae),Se&&De.setAttribute("data-rte-ai-chat-current-exchange","true"),De.setAttribute("role","group"),De.setAttribute("aria-label",yd(a.messages,me,l.snapshot)),Re=ee,_e=De):N==="response"&&De&&Re===ee?_e=De:(De=null,Re=0);var Oe=vo(a.messages,me,l.snapshot);if(0){var oe,xt;if(Oe.changeGlance&&Oe.changeGlance.pills&&Oe.changeGlance.pills.length)for(var Ne;Ne<Oe.changeGlance.pills.length;Ne++)var _t}var tt=o(_e,"div","","rte-ai-chat-message is-"+C.role+" is-minimal"+(C.isError?" is-error":""));tt.setAttribute("role","group"),tt.setAttribute("aria-label",wd(a.messages,me,l.snapshot)),N&&(tt.setAttribute("data-rte-ai-chat-thread-role",N),tt.setAttribute("data-rte-ai-chat-exchange-index",String(ee)),Se&&tt.setAttribute("data-rte-ai-chat-current-exchange","true"));var vr=o(tt,"div","","rte-ai-chat-message-header is-minimal"),ir=C.isError?"error":C.role,ht=o(vr,"span","","rte-ai-chat-message-avatar is-"+ir);if(ht.setAttribute("aria-hidden","true"),ht.innerHTML=ir==="user"?'<svg viewBox="0 0 16 16" width="16" height="16" fill="currentColor" aria-hidden="true"><circle cx="8" cy="5.5" r="2.8"/><path d="M8 9.4c-2.8 0-5.2 1.5-5.2 3.4 0 .4.3.7.7.7h9c.4 0 .7-.3.7-.7 0-1.9-2.4-3.4-5.2-3.4z"/></svg>':ir==="error"?'<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><circle cx="8" cy="8" r="6.5"/><path d="M8 5v3.5M8 11.2v.1"/></svg>':'<svg viewBox="0 0 16 16" width="16" height="16" fill="currentColor" aria-hidden="true"><rect x="3" y="5" width="10" height="8" rx="2"/><circle cx="8" cy="3" r="0.9"/><line x1="8" y1="3.9" x2="8" y2="5" stroke="currentColor" stroke-width="1"/><circle cx="6" cy="9" r="1.1" fill="#ffffff"/><circle cx="10" cy="9" r="1.1" fill="#ffffff"/></svg>',o(vr,"span","","rte-ai-chat-message-role is-"+(C.isError?"error":C.role),no(C)),o(tt,"div","","rte-ai-chat-message-text",C.text||""),C.role==="assistant"&&!C.isError&&C.text){var ke=o(tt,"div","","rte-ai-chat-message-actions-row"),Ce=o(ke,"button","","rte-ai-chat-message-action is-copy");Ce.type="button",Ce.title="Copy message text",ve(Ce,"checkAll","Copy"),Ce.onclick=(function(O,Ze){return function(Le){Le&&Le.stopPropagation&&Le.stopPropagation();var Rt=window.navigator,jt=!1;try{Rt&&Rt.clipboard&&Rt.clipboard.writeText&&(Rt.clipboard.writeText(O),jt=!0)}catch{}if(!jt){var $t=document.createElement("textarea");$t.value=O,$t.style.position="fixed",$t.style.left="-9999px",document.body.appendChild($t),$t.select();try{document.execCommand("copy"),jt=!0}catch{}document.body.removeChild($t)}jt&&(Ze.classList.add("is-just-copied"),ve(Ze,"check","Copied"),setTimeout(function(){Ze.classList.remove("is-just-copied"),ve(Ze,"checkAll","Copy")},1400))}})(C.text||"",Ce);for(var zt="",gt=me-1;gt>=0;gt--)if(a.messages[gt]&&a.messages[gt].role==="user"&&!a.messages[gt].isError){zt=a.messages[gt].text||"";break}if(zt){var mt=o(ke,"button","","rte-ai-chat-message-action is-regen");mt.type="button",mt.title="Regenerate response",ve(mt,"refresh","Regenerate"),mt.onclick=(function(O){return function(Ze){Ze&&Ze.stopPropagation&&Ze.stopPropagation(),a.draft=O,Sl(O)}})(zt)}}if(0){var qi;if(qi)var ar,Xr,Fe}if(0){var Cr;if(Cr)var Jt,nr,Yr,rt}if(C.role==="assistant"&&C.resolved){var It=fd(C,l.snapshot);if(0){var pr,mi,hr,Pt,Zr;if(It.reasonText)var Er;if(It.changeGlance){var Pr;if(It.changeGlance.pills&&It.changeGlance.pills.length){var Ht;for(var ot;ot<It.changeGlance.pills.length;ot++)var Vt}}if(It.planLeadTitle||It.planLeadLabel||It.planLeadDetail||It.planItems&&It.planItems.length){var ei;if(It.planLeadTitle||It.planLeadLabel||It.planLeadDetail){var lr;if(It.planLeadLabel)var ut}if(It.planItems&&It.planItems.length){var gr;for(var Mr;Mr<It.planItems.length;Mr++)var mr,br,wr}}}var yr=o(tt,"div","","rte-ai-chat-message-actions"),Ga=Ca(C,l.snapshot),qr=It&&(It.planLeadTitle||It.planLeadLabel||It.planLeadDetail||It.planItems&&It.planItems.length);if(0)var Qe;var Ve=ea(C,l.snapshot),ti=o(yr,"div","","rte-ai-chat-message-action-group is-utility"),ze=o(yr,"div","","rte-ai-chat-message-action-group is-primary"),Ir=o(yr,"div","","rte-ai-chat-message-action-group is-secondary"),Lt=Zi(C,l.snapshot),Ar=function(O,Ze){!O||!Ze||Ze!==Ve||(O.className+=" is-recommended",O.setAttribute("data-rte-ai-chat-recommended","true"))},Ft=o(ti,"button","","secondary rte-ai-chat-action-button is-copy","Copy text");if(Ft.type="button",Ft.setAttribute("data-rte-ai-chat-action","copy"),Ft.onclick=function(){ed(C)},ta(Ft,"copy",C,Ve,l.snapshot),Lt.canApplyPlan){var Hr=o(ze,"button","","secondary rte-ai-chat-action-button is-apply","Apply");Hr.type="button",Hr.setAttribute("data-rte-ai-chat-action","apply"),Hr.onclick=function(){ka(C,"plan")},Ar(Hr,"apply"),ta(Hr,"apply",C,Ve,l.snapshot)}if(Lt.canPreview){var it=o(ze,"button","","secondary rte-ai-chat-action-button is-preview","Preview");it.type="button",it.setAttribute("data-rte-ai-chat-action","preview"),it.onclick=function(){ka(C,"preview")},Ar(it,"preview"),ta(it,"preview",C,Ve,l.snapshot)}if(Lt.canReplaceSelection){var at=o(ze,"button","","secondary rte-ai-chat-action-button is-selection","Replace selection");at.type="button",at.setAttribute("data-rte-ai-chat-action","selection"),at.onclick=function(){ka(C,"selection")},Ar(at,"selection"),ta(at,"selection",C,Ve,l.snapshot)}if(Lt.canInsert){var Kt=o(Ir,"button","","secondary rte-ai-chat-action-button is-insert","Insert below");if(Kt.type="button",Kt.setAttribute("data-rte-ai-chat-action","insert"),Kt.onclick=function(){ka(C,"insert")},Ar(Kt,"insert"),ta(Kt,"insert",C,Ve,l.snapshot),Lt.canReplaceDocument){var Sr=o(Ir,"button","","secondary rte-ai-chat-action-button is-document","Replace document");Sr.type="button",Sr.setAttribute("data-rte-ai-chat-action","document"),Sr.onclick=function(){ka(C,"document")},Ar(Sr,"document"),ta(Sr,"document",C,Ve,l.snapshot)}}_l(ti,xn("utility",Ve,C,l.snapshot),"utility"),_l(ze,xn("primary",Ve,C,l.snapshot),"primary"),_l(Ir,xn("secondary",Ve,C,l.snapshot),"secondary"),sd(yr,Ve),od(yr,Ve),cd(yr,Ve,C,l.snapshot);var jr=!!(Lt.canPreview||Lt.canInsert||Lt.canReplaceDocument);if(jr){var bi=ze.children.length?ze:Ir.children.length?Ir:ti,Wt=o(bi,"button","","secondary rte-ai-chat-action-button rte-ai-chat-message-action-toggle-more");Wt.type="button",Wt.setAttribute("data-rte-ai-chat-action","more"),Wt.setAttribute("aria-expanded","false"),Wt.title="More apply options",ve(Wt,"more","More"),Wt.onclick=(function(O){return function(Ze){Ze&&Ze.stopPropagation&&Ze.stopPropagation();var Le=O.classList.toggle("is-show-more");Wt.setAttribute("aria-expanded",Le?"true":"false")}})(tt)}}if(C.role==="assistant"&&!C.isError){var In=po(a.messages,me,l.snapshot);if(0){var Ua,la,Ii;if(In.changeGlance&&In.changeGlance.pills&&In.changeGlance.pills.length)for(var Ne;Ne<In.changeGlance.pills.length;Ne++)var _t}}})(a.messages[we],we)}var z=bo(a,l,u),Q=Tl(a,l,u),qe=o(f,"div","","rte-ai-chat-stack rte-ai-chat-compose-shell");qe.setAttribute("role","group"),qe.setAttribute("aria-label",wo(z));var Ye=o(qe,"div","","rte-ai-chat-composer"),V=o(Ye,"textarea","","rte-ai-chat-input");V.rows=1,V.placeholder="Ask anything\u2026",V.setAttribute("aria-label","Compose next AI request for the current "+(l.scope==="selection"?"selection":"document")),V.value=a.draft||"",V.disabled=!!a.busy,V.oninput=function(){a.draft=V.value,a.busy||(a.status=""),kl(f,a,Ra(),n)},V.onkeydown=function(C){if(C.key==="Enter"&&!C.shiftKey){C.preventDefault();var me=Ra(),N=Rl(a,n),ee=Tl(a,me,N);if(ee.disabled){a.status=ee.title,kl(f,a,me,n);return}Sl(V.value)}};var U=o(Ye,"div","","rte-ai-chat-composer-actions");U.setAttribute("role","group"),U.setAttribute("aria-label",yo(Q));var ae=document.createElement("button");ae.type="button",ae.className="secondary rte-ai-chat-action-button is-open-dialog is-detached",ae.setAttribute("data-rte-ai-chat-action","open-dialog"),ve(ae,"external","Open Ask AI"),ae.onclick=function(){na({useDocument:a.scope!=="selection",presetMode:"rewrite"})};var ye=o(U,"button","","rte-ai-chat-send-button"+(a.busy?" is-busy":""));if(ye.type="button",ye.setAttribute("data-rte-ai-chat-action","send"),ye.disabled=!!Q.disabled,ye.setAttribute("aria-label",Q.ariaLabel),ye.title=Q.title,ve(ye,a.busy?"spinner":"send",Q.text),ye.onclick=function(){Sl(V.value)},e&&setTimeout(function(){if(V&&V.focus){V.focus();try{V.selectionStart=V.selectionEnd=V.value.length}catch{}}},0),Bi(a),B&&typeof B.scrollTop<"u"&&(!i||!Yc(B,i))&&(B.scrollTop=B.scrollHeight),!e&&r&&!Bc(f,r)&&f&&f.focus)try{f.focus({preventScroll:!0})}catch{try{f.focus()}catch{}}return!0}function jo(){for(var e={total:0,pending:0,accepted:0,rejected:0,stale:0},t=Ue(),r=0;r<t.length;r++)e.total++,e.hasOwnProperty(t[r].status)&&e[t[r].status]++;return e}function kr(e,t){return!t||t==="all"?!0:We(e&&e.suggestionType||"")===t}function Do(e){for(var t={all:"All types"},r=0;r<e.length;r++){var i=We(e[r]&&e[r].suggestionType||"");t[i]||(t[i]=Pe(i))}var a=[{value:"all",label:t.all}],l=[];for(var n in t)t.hasOwnProperty(n)&&n!=="all"&&l.push(n);l.sort();for(var u=0;u<l.length;u++)a.push({value:l[u],label:t[l[u]]});return a}function Od(e){for(var t={all:0},r=0;r<e.length;r++)if(e[r].status==="pending"){t.all++;var i=We(e[r].suggestionType||"");t[i]=(t[i]||0)+1}return t}function Je(e){for(var t=Ue().slice(),r=[],i=0;i<t.length;i++)t[i].status==="pending"&&kr(t[i],e)&&r.push(t[i]);return ps(r)}function er(e,t){var r=Je(e);if(!r.length)return"";if(!t)return r[0].id;for(var i=0;i<r.length;i++)if(r[i].id===t)return r[i+1]?r[i+1].id:r.length>1?r[0].id:"";return r[0].id}function pi(e,t){var r=Je(e);if(!r.length)return"";if(!t)return r[0].id;for(var i=0;i<r.length;i++)if(r[i].id===t)return r[i-1]?r[i-1].id:r.length>1?r[r.length-1].id:"";return r[0].id}function Mf(e,t){var r=er(e,t);return r?qt(r):!1}function qf(e,t){var r=pi(e,t);return r?qt(r):!1}function If(e,t,r){var i=er(e,t);return i?gi(i,r||{}):!1}function Hf(e,t,r){var i=pi(e,t);return i?gi(i,r||{}):!1}function Gt(e){var t=Mt(),r=t.typeFilter||"all",i=he(e);return i&&r!=="all"&&!kr(i,r)&&(r=We(i.suggestionType||"")),r||"all"}function ra(e){var t=Gt(e),r=er(t,e);return!r&&t!=="all"&&(r=er("all",e)),r}function Oo(e){var t=Gt(e),r=pi(t,e);return!r&&t!=="all"&&(r=pi("all",e)),r}function Gd(e){var t=Gt(e),r=Je(t);return!r.length&&t!=="all"&&(r=Je("all")),r.length?r[0].id:""}function Ud(e){var t=Gt(e),r=Je(t);return!r.length&&t!=="all"&&(r=Je("all")),r.length?r[r.length-1].id:""}function Go(e,t){var r=Oo(e);return r?qt(r,t):!1}function Uo(e,t){var r=ra(e);return r?qt(r,t):!1}function Fd(e,t){var r=Gd(e);return r?qt(r,t):!1}function Kd(e,t){var r=Ud(e);return r?qt(r,t):!1}function fr(e){var t=di();return t&&t.status==="pending"&&kr(t,e)?t.id:er(e,"")}function kn(e,t){var r=Je(e),i={id:t||"",index:0,total:r.length};if(!t||!r.length)return i;for(var a=0;a<r.length;a++)if(r[a].id===t)return i.index=a+1,i;return i}function Cl(e){var t=Mt(),r=t.typeFilter||"all";return e&&r!=="all"&&!kr(e,r)&&(r=We(e.suggestionType||"")),r||"all"}function hi(e,t,r){if(!e||e.status!=="pending"||t!=="accept"&&t!=="reject")return null;r=r||Cl(e);var i=Je(r);!i.length&&r!=="all"&&(i=Je("all"));for(var a=-1,l=0;l<i.length;l++)if(i[l]&&i[l].id===e.id){a=l;break}var n=t==="accept"?"Accept":"Reject";return a===-1||!i.length?{text:n,label:n+" this AI change"}:a===i.length-1?{text:n+" & finish",label:n+" & finish this AI change and finish the current review queue"}:{text:n+" & next",label:n+" & next this AI change and move to the next review item"}}function Ut(e){var t=je(e,"accept")||"Accept",r=je(e,"reject")||"Reject";return{acceptLabel:t,rejectLabel:r,acceptHint:t.replace(/^([A-Z])/,function(i){return i.toLowerCase()}),rejectHint:r.replace(/^([A-Z])/,function(i){return i.toLowerCase()})}}function Pi(e,t,r){if(r=r||{},!e)return!1;var i=!1;return t==="accept"?i=xa(e):t==="reject"&&(i=_a(e)),i&&pe(!0,{focusAction:r.focusAction||""}),i}function Cn(e,t,r){var i=fr(e);return i?Pi(i,t,r):!1}function Nd(){for(var e=Ue().slice(),t=!1,r=0;r<e.length;r++)e[r].status==="pending"&&xa(e[r].id)&&(t=!0);return t}function Fo(e){if(!e||e==="all")return Nd();for(var t=Ue().slice(),r=!1,i=0;i<t.length;i++)t[i].status==="pending"&&kr(t[i],e)&&xa(t[i].id)&&(r=!0);return r}function Qd(){for(var e=Ue().slice(),t=!1,r=0;r<e.length;r++)e[r].status==="pending"&&_a(e[r].id)&&(t=!0);return t}function Ko(e){if(!e||e==="all")return Qd();for(var t=Ue().slice(),r=!1,i=0;i<t.length;i++)t[i].status==="pending"&&kr(t[i],e)&&_a(t[i].id)&&(r=!0);return r}function qt(e,t){t=t||{},cr();var r=he(e),i=r?Lr(r.id):null;if(!r||!i)return r&&r.status==="pending"&&(r.status="stale",r.decidedAt=r.decidedAt||new Date().getTime()),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&pe(!1),!1;!t.openedQueue&&s.__aiRecentlyOpenedQueueSuggestionId&&s.__aiRecentlyOpenedQueueSuggestionId!==r.id&&Vi({skipUpdate:!0,skipRender:!0}),$e(r.id),ha(r.id),t.openedQueue&&Us(r.id);var a=kn(Gt(r.id),r.id),l={positionLabel:a.total?"Item "+a.index+" of "+a.total:"",remoteUpdateCount:Qt(r.id)};He(t.openedQueue?Os(r,l):Jr(r,"Reviewing",l)),i.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"}),i.classList.add("is-focused"),setTimeout(function(){i&&i.classList&&i.classList.remove("is-focused")},1400),s.focus();var n=!!(t.focusInlineAction&&lc(r.id,t.focusInlineAction));return n||ma(i),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&pe(!1),!0}function gi(e,t){t=t||{};var r=he(e);if(!r)return!1;if(!t.openedQueue&&s.__aiRecentlyOpenedQueueSuggestionId&&s.__aiRecentlyOpenedQueueSuggestionId!==r.id&&Vi({skipUpdate:!0,skipRender:!0}),$e(r.id),ha(r.id),t.openedQueue&&Us(r.id),t.locate)return qt(r.id,{openedQueue:!!t.openedQueue});var i=kn(Gt(r.id),r.id),a={positionLabel:i.total?"Item "+i.index+" of "+i.total:"",remoteUpdateCount:Qt(r.id)};return He(t.openedQueue?Os(r,a):Jr(r,"Reviewing",a)),pe(!!t.focusPanel,{focusAction:t.focusAction||""}),!0}function zd(e,t,r){if(!e||!s.__aiActiveSuggestionId||!e.querySelector)return null;var i=e.querySelector('[data-rte-ai-review-id="'+s.__aiActiveSuggestionId+'"]');if(!i||!i.scrollIntoView)return null;if(i.scrollIntoView({block:"nearest",inline:"nearest"}),t){var a=i;if(r&&i.querySelector){var l=i.querySelector('[data-rte-ai-review-action="'+r+'"]');(!l||l.disabled||!l.focus)&&(l=i.querySelector(".rte-ai-review-action-button.is-primary:not([disabled])")||i.querySelector('[data-rte-ai-review-action="locate"]:not([disabled])')||i.querySelector("[data-rte-ai-review-action]:not([disabled])")),l&&!l.disabled&&l.focus&&(a=l)}a&&a.focus&&a.focus()}return i}function Jd(e,t){var r=s.__aiReviewPanel&&s.__aiReviewPanel.isConnected?s.__aiReviewPanel:null;if(!r||!r.querySelector||!e)return!1;var i=r.querySelector('[data-rte-ai-review-id="'+e+'"]');if(!i)return!1;var a=he(e),l=[];t?l.push(t):l.push(Mn(a)),a&&a.status==="pending"&&(l.push("accept"),l.push("reject")),l.push("locate");for(var n={},u=0;u<l.length;u++){var c=l[u];if(!(!c||n[c])){n[c]=!0;var f=i.querySelector('[data-rte-ai-review-action="'+c+'"]');if(f&&!f.disabled&&f.focus)return f.focus(),!0}}return i.focus?(i.focus(),!0):!1}function No(e,t){var r=he(e);if(!r)return!1;var i=t||Mn(r);return s.__aiActiveSuggestionId===r.id&&Jd(r.id,i)?!0:gi(r.id,{focusPanel:!0,focusAction:i||""})}function F(e){var t=e&&e.isConnected?e:s.__aiReviewPanel&&s.__aiReviewPanel.isConnected?s.__aiReviewPanel:null,r=document.activeElement;return t&&r&&r.getAttribute&&t.contains(r)?r.getAttribute("data-rte-ai-review-action")||"":s.__aiLastReviewActionFocus||""}function At(e,t){t=t||{};var r=he(e);if(!r)return!1;var i=t.focusAction||F();return gi(r.id,{focusPanel:!!t.focusPanel,focusAction:i||Mn(r),openedQueue:!!t.openedQueue,locate:!!t.locate})}function En(e,t,r,i){var a="";if(i==="next")a=er(e,t);else if(i==="previous")a=pi(e,t);else if(i==="first")a=fr(e);else if(i==="last"){var l=Je(e);a=l.length?l[l.length-1].id:""}return a?gi(a,{focusPanel:!0,focusAction:r||""}):!1}function tr(){return!!li()}function rr(){return!!Rr()}function $r(e){var t=kt(),r=Ct(),i=e;return tr()&&(i=i.replace(/\.$/,"")+". U undoes "+t.decisionLabel+" decision."),rr()&&(i=i.replace(/\.$/,"")+". Shift+U redoes "+r.decisionLabel+" decision."),i}function St(e){var t=kt(),r=e;return tr()&&(r+=" | U "+t.shortcutLabel),rr()&&(r+=" | Shift+U "+Ct().shortcutLabel),r}function Pn(e){var t=e;return tr()&&(t+=" U"),rr()&&(t+=" Shift+U"),t}function Vd(e){switch(e){case"accept":return"Enter Space A";case"reject":return"Enter Space R";case"undo":return"Enter Space U";case"redo":return"Enter Space Shift+U";case"locate":return"Enter Space";default:return"Enter Space"}}function Wd(e,t,r){var i=kt(),a=Ct(),l=Ut(t),n=(r||"").replace(/\.$/,"");return n||(n=e==="locate"?"Locate":"Review action"),e==="accept"?n+". Enter or Space activates this action. A uses "+l.acceptLabel+".":e==="reject"?n+". Enter or Space activates this action. R uses "+l.rejectLabel+".":e==="undo"?n+". Enter or Space activates this action."+(i?" U "+i.shortcutLabel+".":""):e==="redo"?n+". Enter or Space activates this action."+(a?" Shift+U "+a.shortcutLabel+".":""):n+". Enter or Space activates this action."}function $d(e,t){var r=kt(),i=Ct(),a=Ut(t);return St(e==="accept"?"Shortcuts: Enter "+a.acceptHint+" | R "+a.rejectHint+" | J/K move | Home/End jump":e==="reject"?"Shortcuts: Enter "+a.rejectHint+" | A "+a.acceptHint+" | J/K move | Home/End jump":e==="undo"?"Shortcuts: Enter "+r.shortcutLabel+" | A "+a.acceptHint+" | R "+a.rejectHint+" | J/K move | Home/End jump":e==="redo"?"Shortcuts: Enter "+i.shortcutLabel+" | A "+a.acceptHint+" | R "+a.rejectHint+" | J/K move | Home/End jump":e==="locate"?"Shortcuts: Enter locate | A "+a.acceptHint+" | R "+a.rejectHint+" | J/K move | Home/End jump":"Shortcuts: J/K move | Enter focus action | A "+a.acceptHint+" | R "+a.rejectHint+" | Home/End jump")}function El(e,t){var r=Ut(e);if(!e||e.status!=="pending")return $r("Enter focuses Locate. J/K move items. Home/End jump.");var i=je(e,t)||r.acceptLabel;return $r("Enter focuses "+i+". A uses "+r.acceptLabel+". R uses "+r.rejectLabel+". J/K move items. Home/End jump.")}function Bd(e,t){var r=Ut(e);if(!e||e.status!=="pending")return St("Shortcuts: Enter focus Locate | J/K move | Home/End jump");var i=je(e,t)||r.acceptLabel;return St("Shortcuts: Enter focus "+i+" | A "+r.acceptHint+" | R "+r.rejectHint+" | J/K move | Home/End jump")}function Qo(e,t){var r=Ut(e);return!e||e.status!=="pending"?St("Shortcuts: J/K move | Home/End jump"):St("Shortcuts: A "+r.acceptHint+" | R "+r.rejectHint+" | J/K move | Home/End jump")}function Ia(e,t){if(!e)return"";var r=Rr(),i=li(),a=[];t&&a.push(t),a.push(Mn(e)),e.status==="pending"&&(a.push("accept"),a.push("reject"),i&&a.push("undo"),r&&r.suggestion&&r.suggestion.id===e.id&&a.push("redo")),a.push("locate");for(var l={},n=0;n<a.length;n++){var u=a[n];if(!(!u||l[u])&&(l[u]=!0,(u==="accept"||u==="reject")&&e.status==="pending"||u==="undo"&&e.status==="pending"&&i||u==="redo"&&e.status==="pending"&&r&&r.suggestion&&r.suggestion.id===e.id||u==="locate"&&(e.status==="pending"||e.status==="stale")))return u}return""}function je(e,t){var r=Ia(e,t);return r==="undo"?kt().actionLabel||"Undo":r==="redo"?Ct().actionLabel||"Redo":r==="reject"?(hi(e,"reject")||{}).text||"Reject":r==="accept"?(hi(e,"accept")||{}).text||"Accept":r==="locate"?"Locate":""}function zo(e){switch(e){case"accept":case"reject":return"decision";case"undo":case"redo":return"recovery";case"locate":return"locate";default:return""}}function Jo(e,t,r){var i;switch(e){case"locate":i=["locate"];break;case"decision":i=["accept","reject"];break;case"recovery":i=["undo","redo"];break;default:i=[];break}var a=i.indexOf(t);if(a===-1)return i.length+1;if(!r)return a+1;var l=i.indexOf(r);if(l===-1)return a+1;if(t===r)return 1;for(var n=2,u=0;u<i.length;u++)if(i[u]!==r){if(i[u]===t)return n;n++}return a+1}function Vo(e){switch(e){case"locate":return"Locate";case"decision":return"Decide";case"recovery":return"Recover";default:return""}}function Wo(e,t){var r=["locate","decision","recovery"],i=r.indexOf(e);if(i===-1)return r.length+1;if(!t)return i+1;var a=r.indexOf(t);if(a===-1)return i+1;if(e===t)return 1;for(var l=2,n=0;n<r.length;n++)if(r[n]!==t){if(r[n]===e)return l;l++}return i+1}function $o(e,t){t=t||{};var r=t.queueTransitionData||null;return e==="decision"?r?r.statusLabel+". "+r.detail:"Accept or reject this AI change from the current review queue.":e==="locate"?"Find this suggestion in the editor without deciding it yet.":e==="recovery"?t.targetActionName==="undo"&&t.undoSummaryText?t.undoSummaryText:t.targetActionName==="redo"&&t.redoSummaryText?t.redoSummaryText:t.undoSummaryText||t.redoSummaryText?"Undo or redo a recent AI review decision without leaving this card.":"Recover from a recent AI review action without leaving this card.":""}function Xd(e){e=e||{};var t=e.suggestion||null;if(!t)return null;var r=e.targetActionName||"",i=zo(r),a=je(t,r),l=Vo(i);return!i||!a||!l?null:{title:"Action handoff",pills:[l+" lane","Enter focuses "+a],detail:$o(i,e)}}function Bo(e){if(!e)return"";var t=[];if(e.title&&t.push(e.title),e.pills&&e.pills.length)for(var r=0;r<e.pills.length;r++)e.pills[r]&&t.push(e.pills[r]);return e.detail&&t.push(e.detail),t.join(". ")}function Ha(e){var t=s.__aiReviewPanel&&s.__aiReviewPanel.isConnected?s.__aiReviewPanel:null;if(!t||!t.querySelector)return!1;var r=t.querySelector(".rte-ai-review-item.is-active"),i=di(),a=r&&r.querySelector?r.querySelector(".rte-ai-review-item-actions"):null;if(!r||!i||!a)return!1;var l=Ia(i,e||F(t)),n=zo(l),u=Cl(i),c=Je(u);!c.length&&u!=="all"&&(c=Je("all"));var f=fi(c,s.__aiActiveSuggestionId,i),p=i.status==="pending"?li():null,g=Rr(),m=!!(g&&g.suggestion&&g.suggestion.id===i.id&&i.status==="pending"),b={suggestion:i,targetActionName:l,queueTransitionData:f,undoSummaryText:p?ga(p):"",redoSummaryText:m?cn(g):""},h=Xd(b),y=a.querySelector?a.querySelector(".rte-ai-review-item-action-summary"):null;if(h){for(y||(y=document.createElement("span"),y.className="rte-ai-review-item-action-summary");y.firstChild;)y.removeChild(y.firstChild);if(y.setAttribute("aria-label",Bo(h)),o(y,"span","","rte-ai-review-item-action-summary-title",h.title),h.pills&&h.pills.length)for(var A=o(y,"span","","rte-ai-review-item-action-summary-pills"),K=0;K<h.pills.length;K++)h.pills[K]&&o(A,"span","","rte-ai-review-item-action-summary-pill",h.pills[K]);h.detail&&o(y,"span","","rte-ai-review-item-action-summary-detail",h.detail),a.firstChild!==y&&a.insertBefore(y,a.firstChild),a.setAttribute("aria-label","AI review actions. "+Bo(h))}else y&&y.parentNode&&y.parentNode.removeChild(y),a.setAttribute("aria-label","AI review actions");for(var S=je(i,l),q=a.querySelectorAll(".rte-ai-review-item-action-group"),M=[],P=0;P<q.length;P++){var L=q[P];if(L){var D=L.getAttribute("data-rte-ai-review-action-group")||(L.classList.contains("is-decision")?"decision":L.classList.contains("is-recovery")?"recovery":L.classList.contains("is-locate")?"locate":"");if(D){var J=L.querySelector?L.querySelector(".rte-ai-review-action-button"):null;if(!J){var E=L.querySelector?L.querySelector(".rte-ai-review-item-action-group-header"):null,W=L.querySelector?L.querySelector(".rte-ai-review-item-action-group-detail"):null;E&&E.parentNode&&E.parentNode.removeChild(E),W&&W.parentNode&&W.parentNode.removeChild(W),L.setAttribute("data-rte-ai-review-action-group-current","false"),L.classList.remove("is-current-lane"),L.removeAttribute("aria-label");continue}M.push(L);var de=Vo(D),$=L.querySelector?L.querySelector(".rte-ai-review-item-action-group-header"):null;$||($=document.createElement("span"),$.className="rte-ai-review-item-action-group-header",L.firstChild?L.insertBefore($,L.firstChild):L.appendChild($));var I=$.querySelector?$.querySelector(".rte-ai-review-item-action-group-title"):null;I||(I=document.createElement("span"),I.className="rte-ai-review-item-action-group-title",$.appendChild(I)),I.textContent=de;var le=$.querySelector?$.querySelector(".rte-ai-review-item-action-group-badge"):null;le||(le=document.createElement("span"),le.className="rte-ai-review-item-action-group-badge",$.appendChild(le));var Z=L.querySelector?L.querySelector(".rte-ai-review-item-action-group-detail"):null;Z||(Z=document.createElement("span"),Z.className="rte-ai-review-item-action-group-detail",J?L.insertBefore(Z,J):L.appendChild(Z));var se=!!n&&D===n,B=$o(D,b);if(L.style.removeProperty("order"),L.setAttribute("data-rte-ai-review-action-group-current",se?"true":"false"),L.classList.toggle("is-current-lane",se),se&&S){var j="Enter: "+S;le.textContent=j,le.style.display="",le.setAttribute("aria-label","Current action lane. "+j)}else le.textContent="",le.style.display="none",le.removeAttribute("aria-label");B?(Z.textContent=B,Z.style.display=""):(Z.textContent="",Z.style.display="none");var G=de?de+" lane":"";se&&S&&(G+=(G?". ":"")+"Current action lane. Enter focuses "+S),B&&(G+=(G?". ":"")+B),G?L.setAttribute("aria-label",G):L.removeAttribute("aria-label")}}}M.sort(function(ue,X){var De=ue.getAttribute("data-rte-ai-review-action-group")||(ue.classList.contains("is-decision")?"decision":ue.classList.contains("is-recovery")?"recovery":ue.classList.contains("is-locate")?"locate":""),Re=X.getAttribute("data-rte-ai-review-action-group")||(X.classList.contains("is-decision")?"decision":X.classList.contains("is-recovery")?"recovery":X.classList.contains("is-locate")?"locate":"");return Wo(De,n)-Wo(Re,n)});for(var xe=0;xe<M.length;xe++)a.appendChild(M[xe]);return!0}function ja(e){var t=s.__aiReviewPanel&&s.__aiReviewPanel.isConnected?s.__aiReviewPanel:null;if(!t||!t.querySelectorAll)return!1;for(var r=t.querySelector(".rte-ai-review-item.is-active"),i=di(),a=Ia(i,e||F(t)),l={},n=t.querySelectorAll(".rte-ai-review-action-button[data-rte-ai-review-action]"),u=0;u<n.length;u++){var c=n[u];if(!(!c||!c.getAttribute)){var f=c.getAttribute("data-rte-ai-review-action")||"",p=!!r&&r.contains(c)&&!!a&&f===a&&!c.disabled,g=c.closest?c.closest(".rte-ai-review-item-action-group"):null,m=g&&g.classList?g.classList.contains("is-decision")?"decision":g.classList.contains("is-recovery")?"recovery":g.classList.contains("is-locate")?"locate":"":"";p&&g&&m?(l[m]||(l[m]=[]),l[m].push(c)):g&&m&&r&&r.contains(c)&&(l[m]||(l[m]=[]),l[m].push(c));var b=(c.getAttribute("aria-label")||c.textContent||"").replace(/\.\s*Current Enter target\.$/i,""),h=(c.getAttribute("title")||b).replace(/\.\s*Current Enter target\.$/i,"");c.setAttribute("data-rte-ai-review-enter-target",p?"true":"false"),c.classList.toggle("is-enter-target",p),p?(c.setAttribute("data-rte-ai-review-enter-target-label","Enter"),b&&!/current enter target/i.test(b)&&c.setAttribute("aria-label",b+". Current Enter target."),h&&!/current enter target/i.test(h)&&(c.title=h+". Current Enter target.")):(c.removeAttribute("data-rte-ai-review-enter-target-label"),b&&c.setAttribute("aria-label",b),h&&(c.title=h))}}if(!r)return!1;for(var m in l)if(l.hasOwnProperty(m)){var g=r.querySelector(".rte-ai-review-item-action-group.is-"+m),y=l[m];if(!(!g||!y||!y.length)){y.sort(function(q,M){var P=q.getAttribute("data-rte-ai-review-action")||"",L=M.getAttribute("data-rte-ai-review-action")||"";return Jo(m,P,a)-Jo(m,L,a)});for(var A=0;A<y.length;A++)g.appendChild(y[A])}}return!0}function Yd(e,t){if(!e||!e.suggestion)return"";var r={};for(var i in e.suggestion)Object.prototype.hasOwnProperty.call(e.suggestion,i)&&(r[i]=e.suggestion[i]);return r.status="pending",je(r,t)}function Zd(e,t){var r=kt(),i=Ct(),a=Ut(t);return St(e==="accept"?"Shortcuts: Enter focus "+a.acceptLabel+" | A "+a.acceptHint+" | R "+a.rejectHint+" | J/K move | Home/End jump":e==="reject"?"Shortcuts: Enter focus "+a.rejectLabel+" | A "+a.acceptHint+" | R "+a.rejectHint+" | J/K move | Home/End jump":e==="undo"?"Shortcuts: Enter focus "+r.actionLabel+" | A "+a.acceptHint+" | R "+a.rejectHint+" | J/K move | Home/End jump":e==="redo"?"Shortcuts: Enter focus "+i.actionLabel+" | A "+a.acceptHint+" | R "+a.rejectHint+" | J/K move | Home/End jump":e==="locate"?"Shortcuts: Enter focus Locate | J/K move | Home/End jump":"Shortcuts: J/K move | Enter focus action | A "+a.acceptHint+" | R "+a.rejectHint+" | Home/End jump")}function ef(e,t){var r=kt(),i=Ct(),a=Ut(t);return $r(e==="accept"?"Enter focuses "+a.acceptLabel+". A uses "+a.acceptLabel+". R uses "+a.rejectLabel+". J/K move items. Home/End jump.":e==="reject"?"Enter focuses "+a.rejectLabel+". A uses "+a.acceptLabel+". R uses "+a.rejectLabel+". J/K move items. Home/End jump.":e==="undo"?"Enter focuses "+r.actionLabel+". A uses "+a.acceptLabel+". R uses "+a.rejectLabel+". J/K move items. Home/End jump.":e==="redo"?"Enter focuses "+i.actionLabel+". A uses "+a.acceptLabel+". R uses "+a.rejectLabel+". J/K move items. Home/End jump.":e==="locate"?"Enter focuses Locate. J/K move items. Home/End jump.":"Enter focuses action. A uses "+a.acceptLabel+". R uses "+a.rejectLabel+". J/K move items. Home/End jump.")}function tf(e,t){return Zd(Ia(e,t),e)}function Xo(e,t){return ef(Ia(e,t),e)}function Yo(e){if(!e||!e.getAttribute)return"this control";var t=e.getAttribute("data-rte-ai-review-shortcut-label")||e.getAttribute("aria-label")||e.innerText||e.textContent||e.title||e.getAttribute("data-rte-ai-review-focus-key")||"this control";return String(t||"this control").replace(/\s+/g," ").replace(/^\s+|\s+$/g,"")||"this control"}function rf(e){var t=Ut(di());return $r("Enter activates "+Yo(e)+". A uses "+t.acceptLabel+". R uses "+t.rejectLabel+". J/K move items. Home/End jump.")}function af(e){var t=Ut(di());return St("Shortcuts: Enter "+Yo(e)+" | A "+t.acceptHint+" | R "+t.rejectHint+" | J/K move | Home/End jump")}function Mn(e){if(!e)return"";var t=Rr();return e.status==="pending"&&t&&t.suggestion&&t.suggestion.id===e.id?"redo":e.status==="pending"?"accept":"locate"}function Pl(e,t){if(e){for(;e.firstChild;)e.removeChild(e.firstChild);if(t){var r=String(t||""),i=r.match(/^Shortcuts:\s*/i),a=e.ownerDocument||document,l=i?r.substring(i[0].length):r;if(i){var n=a.createElement("span");n.className="rte-ai-review-shortcuts-label",n.innerText="Shortcuts:",e.appendChild(n),e.appendChild(a.createTextNode(" "))}for(var u=l.split(/(\s+\|\s+|\s+-\s+)/),c=0;c<u.length;c++){var f=u[c];if(f){if(/^\s+[\|\-]\s+$/.test(f)){var p=a.createElement("span");p.className="rte-ai-review-shortcuts-separator",p.innerText=f.replace(/^\s+|\s+$/g,""),e.appendChild(p);continue}var g=a.createElement("span");g.className="rte-ai-review-shortcuts-segment";var m=f.replace(/^\s+|\s+$/g,""),b=m.indexOf(" ");if(b>0){var h=a.createElement("span");h.className="rte-ai-review-shortcuts-key",h.innerText=m.substring(0,b),g.appendChild(h),g.appendChild(a.createTextNode(" "));var y=a.createElement("span");y.className="rte-ai-review-shortcuts-copy",y.innerText=m.substring(b+1),g.appendChild(y)}else g.innerText=m;e.appendChild(g)}}}}}function Ml(e,t){if(e){var r=t||"";r?e.setAttribute("data-rte-ai-review-shortcut-action",r):e.removeAttribute("data-rte-ai-review-shortcut-action"),e.classList.remove("is-action-focused"),e.classList.remove("is-card-focused"),e.classList.remove("is-panel-focused"),e.classList.remove("is-control-focused"),r==="card"?e.classList.add("is-card-focused"):r==="panel"?e.classList.add("is-panel-focused"):r==="control"?e.classList.add("is-control-focused"):r&&e.classList.add("is-action-focused")}}function nf(e,t){var r=s.__aiReviewPanel&&s.__aiReviewPanel.isConnected?s.__aiReviewPanel:null;if(!r||!r.querySelector)return!1;var i=r.querySelector(".rte-ai-review-item.is-active"),a=i&&i.querySelector?i.querySelector(".rte-ai-review-item-actions"):null,l=a&&a.querySelector?a.querySelector(".rte-ai-review-item-shortcuts"):null;if(!i||!a||!e)return l&&l.parentNode&&l.parentNode.removeChild(l),!1;l||(l=document.createElement("div"),l.className="rte-ai-review-item-shortcuts");var n=l.querySelector?l.querySelector(".rte-ai-review-item-shortcuts-title"):null;n||(n=document.createElement("span"),n.className="rte-ai-review-item-shortcuts-title",l.appendChild(n)),n.textContent="Keyboard guide";var u=l.querySelector?l.querySelector(".rte-ai-review-item-shortcuts-body"):null;u||(u=document.createElement("div"),u.className="rte-ai-review-shortcuts rte-ai-review-item-shortcuts-body",l.appendChild(u)),Pl(u,e||""),Ml(u,t);var c=String(e||"").replace(/^Shortcuts:\s*/i,"");l.setAttribute("aria-label",c?"Keyboard guide. "+c:"Keyboard guide");var f=a.querySelector?a.querySelector(".rte-ai-review-item-action-summary"):null;return f&&f.parentNode===a?f.nextSibling!==l&&(f.nextSibling?a.insertBefore(l,f.nextSibling):a.appendChild(l)):a.firstChild!==l&&(a.firstChild?a.insertBefore(l,a.firstChild):a.appendChild(l)),!0}function Da(e,t){var r=s.__aiReviewShortcutDisplayNode;r&&(Pl(r,e||""),Ml(r,t),nf(e||"",t))}function Zo(e){var t=e||"";Da($d(t,di()),t),Ha(t),ja(t),yn(),An()}function eu(e){var t=F();Da(Bd(e,t),"card"),Ha(t),ja(t),yn(),An()}function ql(e,t){var r=t||F();Da(tf(e,r),"panel"),Ha(r),ja(r),yn(),An()}function lf(e){Da(af(e),"control"),Ha(F()),ja(F()),yn(),An()}function tu(){return s.__aiReviewShortcutDisplayId||(s.__aiReviewShortcutDisplayId="rte-ai-review-shortcuts-"+String(Math.floor(Math.random()*1e9))),s.__aiReviewShortcutDisplayId}function ia(e){if(!(!e||!e.setAttribute)){var t=[tu()],r=e.getAttribute("data-rte-ai-review-extra-describedby")||"";if(r)for(var i=r.split(/\s+/),a=0;a<i.length;a++)i[a]&&t.indexOf(i[a])<0&&t.push(i[a]);e.setAttribute("aria-describedby",t.join(" "))}}function sf(e,t){if(e){var r=e.tagName?e.tagName.toUpperCase():"",i=r==="BUTTON"||e.getAttribute("role")==="button";i&&(e.setAttribute("aria-keyshortcuts",Pn("Enter Space A R J K Home End")),e.title=rf(e));var a=e.onfocus;e.onfocus=function(l){ia(e),i?lf(e):ql(),a&&a.call(this,l)},i&&(e.onkeydown=function(l){var n=(l.key||"").toLowerCase(),u=!1,c="";if(n==="a")u=Cn(t,"accept",{focusAction:F()});else if(n==="r")u=Cn(t,"reject",{focusAction:F()});else if(n==="u"&&l.shiftKey&&rr())u=zr({focusPanel:!0,focusAction:F()});else if(n==="u"&&tr())u=Tr({focusPanel:!0,focusAction:F()});else if(l.key==="ArrowDown"||n==="j"){c="next";var f=er(t,s.__aiActiveSuggestionId);u=!!(f&&At(f,{focusPanel:!0,focusAction:F()}))}else if(l.key==="ArrowUp"||n==="k"){c="previous";var p=pi(t,s.__aiActiveSuggestionId);u=!!(p&&At(p,{focusPanel:!0,focusAction:F()}))}else if(l.key==="Home"){c="first";var g=fr(t);u=!!(g&&At(g,{focusPanel:!0,focusAction:F()}))}else if(l.key==="End"){c="last";var m=Je(t),b=m.length?m[m.length-1].id:"";u=!!(b&&At(b,{focusPanel:!0,focusAction:F()}))}(u||c)&&(l.preventDefault(),l.stopPropagation()),!u&&c&&He(Yt(s.__aiActiveSuggestionId,c))})}}function Oa(e,t,r,i){e&&(e.setAttribute("aria-keyshortcuts",Vd(i)),e.title=Wd(i,he(r),e.getAttribute("aria-label")||e.textContent||""),e.onfocus=function(){s.__aiLastReviewActionFocus=i||"",ia(e),Zo(i)},e.onkeydown=function(a){var l=(a.key||"").toLowerCase(),n=!1,u="";l==="a"?n=Pi(r,"accept",{focusAction:F()}):l==="r"?n=Pi(r,"reject",{focusAction:F()}):l==="u"&&a.shiftKey&&rr()?n=zr({focusPanel:!0,focusAction:F()}):l==="u"&&tr()?n=Tr({focusPanel:!0,focusAction:F()}):a.key==="ArrowDown"||l==="j"?(u="next",n=En(t,r,i,"next")):a.key==="ArrowUp"||l==="k"?(u="previous",n=En(t,r,i,"previous")):a.key==="Home"?(u="first",n=En(t,r,i,"first")):a.key==="End"&&(u="last",n=En(t,r,i,"last")),(n||u)&&(a.preventDefault(),a.stopPropagation()),!n&&u&&He(Yt(r,u))})}function ru(e){cr();var t=e?he(e):null,r=t?Lr(t.id):null;return!t||t.status!=="pending"||!r?!1:($e(t.id,{preserveEmptyPreview:!0}),r.scrollIntoView&&r.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"}),r.classList.add("is-focused"),s.__aiReviewEmptyPreviewTimer&&clearTimeout(s.__aiReviewEmptyPreviewTimer),s.__aiReviewEmptyPreviewTimer=setTimeout(function(){r&&r.classList&&r.classList.remove("is-focused")},1200),!0)}function of(e){if(!document||!document.querySelectorAll||!window)return 0;var t;try{t=document.querySelectorAll("header, nav, [data-rte-ai-sticky-offset], [data-rte-sticky-offset], .topbar, .topnav, .site-header, .navbar, [class*='SiteHeader'], [class*='site-header']")}catch{return 0}for(var r=Math.min(window.innerHeight||900,320),i=0,a=0;a<t.length;a++){var l=t[a];if(!(!l||l===e||e&&e.contains&&e.contains(l))){var n=l.getBoundingClientRect?l.getBoundingClientRect():null;if(!(!n||n.height<8||n.width<80)&&!(n.top>24||n.bottom<=0||n.bottom>r)){var u=window.getComputedStyle?window.getComputedStyle(l):null;u&&(u.display==="none"||u.visibility==="hidden"||parseFloat(u.opacity||"1")<=.01)||(i=Math.max(i,n.bottom))}}}return Math.max(0,Math.ceil(i))}function iu(e){if(!(!e||!e.style)){var t=of(e);t>0?e.style.setProperty("--rte-ai-detected-top-chrome",t+"px"):e.style.removeProperty("--rte-ai-detected-top-chrome")}}function Br(){s.__aiReviewPanel&&s.__aiReviewPanel.parentNode&&s.__aiReviewPanel.parentNode.removeChild(s.__aiReviewPanel),s.__aiReviewShell&&s.__aiReviewShell.classList&&s.__aiReviewShell.classList.remove("rte-ai-review-host"),s.__aiReviewShell&&s.__aiReviewShell.style&&(s.__aiReviewShell.style.minHeight=typeof s.__aiReviewOriginalMinHeight=="string"?s.__aiReviewOriginalMinHeight:"",s.__aiReviewShell.style.removeProperty("--rte-ai-detected-top-chrome")),s.__aiReviewPanel=null,s.__aiReviewSubtitleNode=null,s.__aiReviewSyncBadgeNode=null,s.__aiReviewSyncButton=null,s.__aiLastReviewActionFocus="",s.__aiReviewShell=null,s.__aiReviewOriginalMinHeight=null,s.__aiLastReviewEmptyAnnouncement="",s.__aiReviewEmptyPreviewTimer&&(clearTimeout(s.__aiReviewEmptyPreviewTimer),s.__aiReviewEmptyPreviewTimer=null),Vi({skipUpdate:!0,skipRender:!0}),s.__aiReviewEmptyPreviewSuggestionId&&$e(null),s.__aiReviewPrimaryEmptyAction=null,s.__aiReviewMoveEmptyPreviewFocus=null}function qn(e){return e=e||{},Xi(),ni(!0),pe(!!e.focusPanel)}function uf(e){return s.__aiReviewPanel&&s.__aiReviewPanel.isConnected?(Br(),!1):qn(e)}var aa={eyeOn:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7z"/><circle cx="12" cy="12" r="3"/></svg>',eyeOff:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9.88 9.88a3 3 0 1 0 4.24 4.24"/><path d="M10.73 5.08A10.43 10.43 0 0 1 12 5c6.5 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"/><path d="M6.61 6.61A13.526 13.526 0 0 0 2 12s3.5 7 10 7a9.74 9.74 0 0 0 5.39-1.61"/><line x1="2" y1="2" x2="22" y2="22"/></svg>',checkAll:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2 13l4 4L14 8"/><path d="M10 13l4 4L22 8"/></svg>',check:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="4 12 10 18 20 6"/></svg>',x:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="6" y1="6" x2="18" y2="18"/><line x1="6" y1="18" x2="18" y2="6"/></svg>',target:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="9"/><circle cx="12" cy="12" r="5"/><circle cx="12" cy="12" r="1.5" fill="currentColor"/></svg>',bulb:'<svg viewBox="0 0 24 24" width="11" height="11" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 18h6"/><path d="M10 22h4"/><path d="M12 2a7 7 0 0 0-4 12.7c.6.5 1 1.2 1 2v.3h6v-.3c0-.8.4-1.5 1-2A7 7 0 0 0 12 2z"/></svg>',arrowRight:'<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="5" y1="12" x2="19" y2="12"/><polyline points="13 6 19 12 13 18"/></svg>',send:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="22" y1="2" x2="11" y2="13"/><polygon points="22 2 15 22 11 13 2 9 22 2" fill="currentColor"/></svg>',sparkles:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 3v3M12 18v3M3 12h3M18 12h3M5.6 5.6l2.1 2.1M16.3 16.3l2.1 2.1M5.6 18.4l2.1-2.1M16.3 7.7l2.1-2.1"/><path d="M12 8 13.4 10.6 16 12l-2.6 1.4L12 16l-1.4-2.6L8 12l2.6-1.4L12 8z" fill="currentColor"/></svg>',refresh:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="1 4 1 10 7 10"/><path d="M3.5 15a9 9 0 1 0 2.1-9.4L1 10"/></svg>',external:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>',trash:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="3 6 5 6 21 6"/><path d="M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"/><path d="M10 11v6M14 11v6"/><path d="M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"/></svg>',cursorText:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 4h2a3 3 0 0 1 3 3v0a3 3 0 0 0 3 3h0M9 20h2a3 3 0 0 0 3-3v0a3 3 0 0 1 3-3h0"/><line x1="11" y1="4" x2="11" y2="20"/></svg>',document:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="8" y1="13" x2="16" y2="13"/><line x1="8" y1="17" x2="13" y2="17"/></svg>',inbox:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="22 12 16 12 14 15 10 15 8 12 2 12"/><path d="M5.45 5.11L2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"/></svg>',history:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><polyline points="3 3 3 8 8 8"/><polyline points="12 7 12 12 15 14"/></svg>',filter:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polygon points="22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"/></svg>',bot:'<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="4" y="8" width="16" height="12" rx="3"/><circle cx="9" cy="14" r="1.3" fill="currentColor"/><circle cx="15" cy="14" r="1.3" fill="currentColor"/><line x1="12" y1="4" x2="12" y2="8"/><circle cx="12" cy="3" r="1.2" fill="currentColor"/><line x1="4" y1="13" x2="2" y2="13"/><line x1="22" y1="13" x2="20" y2="13"/></svg>',chat:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>',wand:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M15 4V2M15 14v-2M8 9h2M20 9h2M17.8 11.8L19 13M15 9h0M17.8 6.2L19 5M3 21l9-9M12.2 6.2L11 5"/></svg>',list:'<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="8" y1="6" x2="21" y2="6"/><line x1="8" y1="12" x2="21" y2="12"/><line x1="8" y1="18" x2="21" y2="18"/><line x1="3" y1="6" x2="3.01" y2="6"/><line x1="3" y1="12" x2="3.01" y2="12"/><line x1="3" y1="18" x2="3.01" y2="18"/></svg>',globe:'<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><line x1="2" y1="12" x2="22" y2="12"/><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"/></svg>',heading:'<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 4v16M18 4v16M6 12h12"/></svg>',plus:'<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>',pencil:'<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"/></svg>',spinner:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true" class="rte-ai-spinner-svg"><path d="M12 3a9 9 0 1 0 9 9" /></svg>',more:'<svg viewBox="0 0 24 24" width="13" height="13" fill="currentColor" aria-hidden="true"><circle cx="6" cy="12" r="1.6"/><circle cx="12" cy="12" r="1.6"/><circle cx="18" cy="12" r="1.6"/></svg>',clipboard:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="8" y="3" width="8" height="3" rx="1"/><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"/></svg>',shrink:'<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="4 14 10 14 10 20"/><polyline points="20 10 14 10 14 4"/><line x1="14" y1="10" x2="21" y2="3"/><line x1="3" y1="21" x2="10" y2="14"/></svg>',expand:'<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><line x1="21" y1="3" x2="14" y2="10"/><line x1="3" y1="21" x2="10" y2="14"/></svg>',info:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="9"/><line x1="12" y1="11" x2="12" y2="16"/><circle cx="12" cy="8" r="1" fill="currentColor"/></svg>'};function cf(e){if(!e)return"wand";var t=(e.tone||e.intent||e.id||"").toLowerCase();return t.indexOf("summar")!==-1?"list":t.indexOf("proofread")!==-1||t.indexOf("review")!==-1?"pencil":t.indexOf("translate")!==-1||t.indexOf("language")!==-1?"globe":t.indexOf("heading")!==-1||t.indexOf("structure")!==-1||t.indexOf("outline")!==-1?"heading":t.indexOf("expand")!==-1||t.indexOf("support")!==-1||t.indexOf("add")!==-1?"plus":"wand"}function ve(e,t,r){if(e){if(e.textContent="",t&&aa[t]){var i=e.ownerDocument.createElement("span");i.className="rte-ai-review-v2-action-icon",i.setAttribute("aria-hidden","true"),i.innerHTML=aa[t],e.appendChild(i)}if(r){var a=e.ownerDocument.createElement("span");a.className="rte-ai-review-v2-action-label",a.textContent=r,e.appendChild(a)}}}function Mi(e){var t=Ri();if(!t)return!1;for(var r=Mt(),i=Ue().slice(),a=jo(),l=Do(i),n=r.typeFilter||"all",u=!1,c=0;c<l.length;c++)if(l[c].value===n){u=!0;break}u||(n="all",r.typeFilter="all");var f=a.pending>0||a.stale>0,p=r.activeTab||"pending";p!=="pending"&&p!=="resolved"&&p!=="all"&&(p="pending"),p==="pending"&&!f&&a.total>0&&(p="resolved",r.activeTab="resolved");var g=a.pending+a.stale,m=a.accepted+a.rejected;if(Br(),s.__aiReviewOriginalMinHeight=t.style&&t.style.minHeight||"",t.classList.add("rte-ai-review-host"),iu(t),t.style){var b=window.innerWidth<=900?460:520;t.style.minHeight=Math.max(t.offsetHeight||0,b)+"px"}s.__aiReviewShell=t;var h=o(t,"div","","rte-ai-review-panel rte-ai-review-v2");h.setAttribute("role","complementary"),h.setAttribute("aria-label",k.text_aireview||"AI Review"),h.tabIndex=-1,s.__aiReviewPanel=h,h.onkeydown=function(z){z.key==="Escape"&&(z.preventDefault(),Br(),s.focus())};var y=o(h,"div","","rte-ai-review-v2-header"),A=o(y,"span","","rte-ai-review-v2-icon");A.innerHTML=k.svgCode_aiassist_review||k.svgCode_aiassist||"",o(y,"div","","rte-ai-review-v2-title",k.text_aireview||"AI Review");var K=o(y,"button","","rte-ai-review-v2-close");K.type="button",K.setAttribute("aria-label","Close AI review"),K.title="Close",K.innerHTML='<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 6l12 12"/><path d="M18 6L6 18"/></svg>',K.onclick=function(){Br(),s.focus()};var S=o(h,"div","","rte-ai-review-v2-tabs");S.setAttribute("role","tablist");function q(z,Q,qe,Ye){var V=o(S,"button","","rte-ai-review-v2-tab"+(p===z?" is-active":""));if(V.type="button",V.setAttribute("role","tab"),V.setAttribute("aria-selected",p===z?"true":"false"),V.setAttribute("data-rte-ai-review-tab",z),Q&&aa[Q]){var U=V.ownerDocument.createElement("span");U.className="rte-ai-review-v2-tab-icon",U.setAttribute("aria-hidden","true"),U.innerHTML=aa[Q],V.appendChild(U)}var ae=V.ownerDocument.createElement("span");if(ae.className="rte-ai-review-v2-tab-label",ae.textContent=qe,V.appendChild(ae),typeof Ye=="number"){var ye=V.ownerDocument.createElement("span");ye.className="rte-ai-review-v2-tab-count"+(Ye>0?" is-active":""),ye.textContent=String(Ye),V.appendChild(ye)}return V.onclick=function(){p!==z&&(Mt().activeTab=z,Mi(!0))},V}q("pending","inbox","To review",g),q("resolved","history","History",m),q("all","filter","All",a.total);var M=o(h,"div","","rte-ai-review-v2-toolbar");if(l.length>1){for(var P=o(M,"select","","rte-ai-review-v2-select"),L=0;L<l.length;L++){var D=o(P,"option","","",l[L].label);D.value=l[L].value}P.value=n,P.onchange=function(){Mt().typeFilter=P.value||"all",Mi(!0)}}for(var J=0,E=0;E<i.length;E++)i[E].status==="pending"&&kr(i[E],n)&&J++;if(p==="pending"){o(M,"div","","rte-ai-review-v2-toolbar-spacer");var W=o(M,"button","","rte-ai-review-v2-batch is-accept");W.type="button",W.disabled=!J,ve(W,"checkAll","Accept all"),W.onclick=function(){Fo(n)&&Mi(!0)};var de=o(M,"button","","rte-ai-review-v2-batch is-reject");de.type="button",de.disabled=!J,ve(de,"x","Reject all"),de.onclick=function(){Ko(n)&&Mi(!0)}}for(var $=o(h,"div","","rte-ai-review-v2-body"),I=[],le=0;le<i.length;le++)if(!(i[le].changeType&&i[le].changeType!=="ai-preview")&&kr(i[le],n)){var Z=i[le].status,se=Z==="pending"||Z==="stale";p==="pending"&&!se||p==="resolved"&&se||I.push(i[le])}I.sort(function(z,Q){var qe=z.status==="pending"||z.status==="stale",Ye=Q.status==="pending"||Q.status==="stale";return qe!==Ye?qe?-1:1:(Q.timestamp||0)-(z.timestamp||0)});for(var B=s.__aiActiveSuggestionId||"",j=!1,G=0;G<I.length;G++)if(I[G].id===B){j=!0;break}if(!j){for(var xe=0;xe<I.length;xe++)if(I[xe].status==="pending"||I[xe].status==="stale"){$e(I[xe].id),B=I[xe].id;break}}var ue=he(B),X=a.total?Math.max(0,Math.min(100,Math.round(m/a.total*100))):0,De=n==="all"?"All types":Pe(n),Re=o(h,"div","","rte-ai-review-v2-center");h.insertBefore(Re,$),Re.setAttribute("role","group"),Re.setAttribute("aria-label","AI review summary");function we(z,Q,qe,Ye){var V=o(Re,"div","","rte-ai-review-v2-center-tile "+z);return o(V,"span","","rte-ai-review-v2-center-label",Q),o(V,"span","","rte-ai-review-v2-center-value",qe),o(V,"span","","rte-ai-review-v2-center-detail",Ye),V}we("is-queue","Queue",J+" pending",De+(p==="pending"?" to review":" filter")),we("is-progress","Progress",X+"% done",m+" resolved of "+a.total);var Te=ue?ue.status==="pending"||ue.status==="stale"?"Review current":"Inspect item":J?"Pick an item":a.total?"All caught up":"Start with Ask AI",Xe=ue?Be(ue.originalText||ue.resultText||"AI suggestion",72):J?"Select a card below to compare the change.":a.total?"History keeps accepted and rejected changes.":"AI suggestions will appear here.",pt=we("is-next","Next step",Te,Xe);if(ue){var Me=o(pt,"button","","rte-ai-review-v2-center-action","Focus");Me.type="button",Me.setAttribute("aria-label","Focus the current AI review item"),Me.onclick=function(){$e(B),Mi(!0)}}if(I.length)for(var ge=0;ge<I.length;ge++)(function(z){var Q=o($,"div","","rte-ai-review-v2-item is-"+z.status+(z.id===B?" is-active":""));Q.setAttribute("data-rte-ai-review-id",z.id),Q.setAttribute("role","group");var qe=o(Q,"div","","rte-ai-review-v2-item-head");o(qe,"span","","rte-ai-review-v2-item-status is-"+z.status,ya(z.status)),z.suggestionType&&z.suggestionType!=="other"&&o(qe,"span","","rte-ai-review-v2-item-type",Pe(z.suggestionType)),z.snapshot&&z.snapshot.hasSelection?o(qe,"span","","rte-ai-review-v2-item-scope","Selection"):o(qe,"span","","rte-ai-review-v2-item-scope","Document");var Ye=Be(z.originalText||z.resultText||"AI suggestion",120);if(o(Q,"div","","rte-ai-review-v2-item-title",Ye),z.id===B){if(z.originalText&&z.resultText&&R(z.originalText)!==R(z.resultText)){var V=o(Q,"div","","rte-ai-review-v2-compare"),U=o(V,"div","","rte-ai-review-v2-before");o(U,"span","","rte-ai-review-v2-compare-label","Current"),o(U,"div","","rte-ai-review-v2-compare-text",R(z.originalText));var ae=o(V,"span","","rte-ai-review-v2-compare-arrow");ae.setAttribute("aria-hidden","true"),ae.innerHTML=aa.arrowRight;var ye=o(V,"div","","rte-ai-review-v2-after");o(ye,"span","","rte-ai-review-v2-compare-label","Suggested"),o(ye,"div","","rte-ai-review-v2-compare-text",R(z.resultText))}if(z.reason){var C=o(Q,"div","","rte-ai-review-v2-reason"),me=o(C,"span","","rte-ai-review-v2-reason-label"),N=C.ownerDocument.createElement("span");N.className="rte-ai-review-v2-reason-icon",N.setAttribute("aria-hidden","true"),N.innerHTML=aa.bulb,me.appendChild(N);var ee=C.ownerDocument.createElement("span");ee.textContent="Why",me.appendChild(ee),o(C,"span","","rte-ai-review-v2-reason-text",z.reason)}var Ae=o(Q,"div","","rte-ai-review-v2-actions"),Se=o(Ae,"button","","rte-ai-review-v2-action is-locate");if(Se.type="button",ve(Se,"target","Locate"),Se.onclick=function(oe){oe&&oe.stopPropagation&&oe.stopPropagation(),qt(z.id)},z.status==="pending"||z.status==="stale"){var _e=o(Ae,"button","","rte-ai-review-v2-action is-accept");_e.type="button",ve(_e,"check","Accept"),_e.onclick=function(oe){oe&&oe.stopPropagation&&oe.stopPropagation(),Pi(z.id,"accept",{focusAction:"accept"})};var Oe=o(Ae,"button","","rte-ai-review-v2-action is-reject");Oe.type="button",ve(Oe,"x","Reject"),Oe.onclick=function(oe){oe&&oe.stopPropagation&&oe.stopPropagation(),Pi(z.id,"reject",{focusAction:"reject"})}}}Q.onclick=function(oe){oe&&oe.target&&oe.target.closest&&oe.target.closest(".rte-ai-review-v2-action")||z.id!==B&&($e(z.id),Mi(!0))}})(I[ge]);else{var Ke=o($,"div","","rte-ai-review-v2-empty");a.total===0?(o(Ke,"div","","rte-ai-review-v2-empty-art is-prompt"),o(Ke,"div","","rte-ai-review-v2-empty-title","No AI suggestions yet"),o(Ke,"div","","rte-ai-review-v2-empty-detail","Ask AI or AI Chat will drop suggestions here for you to accept or reject.")):p==="pending"?(o(Ke,"div","","rte-ai-review-v2-empty-art is-clear"),o(Ke,"div","","rte-ai-review-v2-empty-title","Nothing to review"),o(Ke,"div","","rte-ai-review-v2-empty-detail","You're all caught up. Switch to History to see past decisions.")):p==="resolved"?(o(Ke,"div","","rte-ai-review-v2-empty-title","No history yet"),o(Ke,"div","","rte-ai-review-v2-empty-detail","Decisions you make on the To review tab will show up here.")):(o(Ke,"div","","rte-ai-review-v2-empty-title","No suggestions match this filter"),o(Ke,"div","","rte-ai-review-v2-empty-detail","Try a different type, or pick a different tab."))}if(e)try{h.focus({preventScroll:!0})}catch{try{h.focus()}catch{}}return!0}function pe(e,t){if(k.aiToolkitReviewLegacyLayout!==!0)return Mi(e);t=t||{},cr();var r=Ri();if(!r)return!1;for(var i=s.__aiReviewPanel&&s.__aiReviewPanel.isConnected?s.__aiReviewPanel:null,a=document.activeElement,l=i&&a&&a.closest?a.closest("[data-rte-ai-review-id]"):null,n=!e&&i&&a&&a.getAttribute&&a.getAttribute("data-rte-ai-review-focus-key")&&i.contains(a)&&a.getAttribute("data-rte-ai-review-focus-key")||"",u=!!(!e&&i&&l&&l.getAttribute&&l.getAttribute("data-rte-ai-review-id")===s.__aiActiveSuggestionId&&i.contains(a)),c=u&&a&&a!==l&&a.getAttribute&&a.getAttribute("data-rte-ai-review-action")||"",f=t.focusAction||"",p=Mt(),g=Ue().slice(),m=jo(),b=ic(),h=m.pending>0||m.stale>0,y=p.showResolved||!h&&m.total>0||!!b,A=Do(g),K=Od(g),S=p.typeFilter||"all",q=!1,M=0;M<A.length;M++)if(A[M].value===S){q=!0;break}q||(S="all",p.typeFilter="all");for(var P=[],L=0;L<g.length;L++)if(!(g[L].changeType&&g[L].changeType!=="ai-preview")){var D=y||g[L].status==="pending"||g[L].status==="stale",J=Qt(g[L].id)>0;D&&(kr(g[L],S)||J)&&P.push(g[L])}P=ps(P);for(var E=0,W=0;W<P.length;W++)P[W].status==="pending"&&kr(P[W],S)&&E++;var de=er("all",""),$=fr(S),I=li(),le=Rr();$e($||null);var Z=kn(S,$),se=er(S,$);if(Br(),s.__aiReviewOriginalMinHeight=r.style&&r.style.minHeight||"",r.classList.add("rte-ai-review-host"),iu(r),r.style){var B=window.innerWidth<=900?460:520;r.style.minHeight=Math.max(r.offsetHeight||0,B)+"px"}s.__aiReviewShell=r;var j=o(r,"div","","rte-ai-review-panel");j.setAttribute("role","complementary"),j.setAttribute("aria-label",k.text_aireview||"AI Review"),j.setAttribute("aria-keyshortcuts",Pn("Enter Space A R J K Home End")),j.tabIndex=-1,s.__aiReviewPanel=j,s.__aiReviewPrimaryEmptyAction=null,j.onkeydown=function(_){var te=(_.key||"").toLowerCase(),Ee=_.target&&_.target.tagName?_.target.tagName.toUpperCase():"";if(_.key==="Escape"){_.preventDefault(),Br(),s.focus();return}if(!(_.ctrlKey||_.metaKey||_.altKey||Ee==="INPUT"||Ee==="TEXTAREA"||Ee==="SELECT"||Ee==="BUTTON"))if(!fr(S)&&s.__aiReviewMoveEmptyPreviewFocus&&(te==="arrowdown"||te==="j"||te==="arrowup"||te==="k"||te==="arrowright"||te==="arrowleft"||te==="home"||te==="end"))_.preventDefault(),te==="arrowdown"||te==="j"||te==="arrowright"?s.__aiReviewMoveEmptyPreviewFocus("next"):te==="arrowup"||te==="k"||te==="arrowleft"?s.__aiReviewMoveEmptyPreviewFocus("previous"):te==="home"?s.__aiReviewMoveEmptyPreviewFocus("first"):te==="end"&&s.__aiReviewMoveEmptyPreviewFocus("last");else if(te==="arrowdown"||te==="j"){_.preventDefault();var et=er(S,s.__aiActiveSuggestionId);et?At(et,{focusPanel:!0,focusAction:F(j)}):s.__aiActiveSuggestionId&&He(Yt(s.__aiActiveSuggestionId,"next"))}else if(te==="arrowup"||te==="k"){_.preventDefault();var ft=pi(S,s.__aiActiveSuggestionId);ft?At(ft,{focusPanel:!0,focusAction:F(j)}):s.__aiActiveSuggestionId&&He(Yt(s.__aiActiveSuggestionId,"previous"))}else if(te==="home"){_.preventDefault();var bt=fr(S);bt&&bt!==s.__aiActiveSuggestionId?At(bt,{focusPanel:!0,focusAction:F(j)}):s.__aiActiveSuggestionId&&He(Yt(s.__aiActiveSuggestionId,"first"))}else if(te==="end"){_.preventDefault();var Bt=Je(S),x=Bt.length?Bt[Bt.length-1].id:"";x&&x!==s.__aiActiveSuggestionId?At(x,{focusPanel:!0,focusAction:F(j)}):s.__aiActiveSuggestionId&&He(Yt(s.__aiActiveSuggestionId,"last"))}else if(te==="enter"||te===" "){_.preventDefault();var re=fr(S);re?No(re,F(j)):s.__aiReviewPrimaryEmptyAction&&s.__aiReviewPrimaryEmptyAction.isConnected&&!s.__aiReviewPrimaryEmptyAction.disabled&&s.__aiReviewPrimaryEmptyAction.click()}else te==="a"?(_.preventDefault(),Cn(S,"accept",{focusAction:F(j)})):te==="r"?(_.preventDefault(),Cn(S,"reject",{focusAction:F(j)})):te==="u"&&_.shiftKey&&le?(_.preventDefault(),zr({focusPanel:!0,focusAction:F(j)})):te==="u"&&I&&(_.preventDefault(),Tr({focusPanel:!0,focusAction:F(j)}))};var G=o(j,"div","","rte-ai-review-header"),xe=o(G,"div","","rte-ai-review-header-copy"),ue=o(xe,"div","","rte-ai-review-header-eyebrow");o(ue,"span","","rte-ai-review-header-kicker","Review workspace"),o(ue,"span","","rte-ai-review-header-status is-status",Ws(m,E,S)),S!=="all"&&o(ue,"span","","rte-ai-review-header-status is-filter",Pe(S)+" queue"),b&&b.count&&o(ue,"span","","rte-ai-review-header-status is-remote",b.count+" shared");var X=o(xe,"div","","rte-ai-review-title-row"),De=o(X,"span","","rte-ai-review-title-icon");De.innerHTML=k.svgCode_aiassist_review||k.svgCode_aiassist||"",o(X,"div","","rte-ai-review-title",k.text_aireview||"AI Review"),Li()&&(s.__aiReviewSyncBadgeNode=o(X,"span","","rte-ai-review-sync-badge","")),s.__aiReviewSubtitleNode=o(xe,"div","","rte-ai-review-subtitle",Wu());var Re=o(xe,"div","","rte-ai-review-header-meta");Z.total&&Z.index&&o(Re,"span","","rte-ai-review-header-meta-pill is-current","Item "+Z.index+" of "+Z.total),m.pending>0?o(Re,"span","","rte-ai-review-header-meta-pill is-pending",(S!=="all"?E:m.pending)+(S!=="all"?" in this view":" pending now")):m.stale>0?o(Re,"span","","rte-ai-review-header-meta-pill is-stale",m.stale+" need refresh"):o(Re,"span","","rte-ai-review-header-meta-pill is-complete","Queue complete"),S!=="all"&&m.pending>0&&E!==m.pending&&o(Re,"span","","rte-ai-review-header-meta-pill is-total",m.pending+" total pending");var we=o(G,"div","","rte-ai-review-header-actions"),Te=null,Xe=null,pt=null,Me=o(we,"div","","rte-ai-review-header-utility");if(Li()){Te=Te||xi(we,"rte-ai-review-header-group is-context","Context");var Ke=o(Te,"button","","secondary rte-ai-review-header-button is-sync","Sync now");Ke.type="button",Ke.setAttribute("data-rte-ai-review-focus-key","sync-now"),Ke.onclick=function(){ni(!0)},s.__aiReviewSyncButton=Ke}var ge=rc();if(ge&&he(ge)){Te=Te||xi(we,"rte-ai-review-header-group is-context","Context");var z=o(Te,"button","","secondary rte-ai-review-header-button is-shared","Newest shared");z.type="button",z.setAttribute("data-rte-ai-review-focus-key","newest-shared"),z.setAttribute("aria-label","Jump to the newest shared AI review update"),z.onclick=function(){qt(ge)}}if($){Te=Te||xi(we,"rte-ai-review-header-group is-context","Context");var Q=o(Te,"button","","secondary rte-ai-review-header-button is-locate-current","Locate current");Q.type="button",Q.setAttribute("data-rte-ai-review-focus-key","locate-current"),Q.setAttribute("aria-label","Locate the current active AI review item in the editor"),Q.onclick=function(){qt($)}}var qe=pi(S,$);if(qe){Xe=Xe||xi(we,"rte-ai-review-header-group is-move","Navigate");var Ye=o(Xe,"button","","secondary rte-ai-review-header-button is-nav","Previous");Ye.type="button",Ye.setAttribute("data-rte-ai-review-focus-key","previous-pending"),Ye.setAttribute("aria-label","Jump to the previous pending AI review item in the current filter"),Ye.onclick=function(){At(qe,{focusPanel:!0})}}if(se){Xe=Xe||xi(we,"rte-ai-review-header-group is-move","Navigate");var V=o(Xe,"button","","secondary rte-ai-review-header-button is-nav","Next pending");V.type="button",V.setAttribute("data-rte-ai-review-focus-key","next-pending"),V.setAttribute("aria-label","Jump to the next pending AI review item in the current filter"),V.onclick=function(){At(se,{focusPanel:!0})}}if(I){var U=kt(I);pt=pt||xi(we,"rte-ai-review-header-group is-recover","Recover");var ae=o(pt,"button","","secondary rte-ai-review-header-button is-undo",U.actionLabel);ae.type="button",ae.setAttribute("data-rte-ai-review-focus-key","undo-last"),ae.setAttribute("data-rte-ai-review-shortcut-label",U.shortcutLabel),ae.setAttribute("aria-label","Undo the "+U.detailLabel+(U.summaryText?' for "'+U.summaryText+'"':"")+" and reopen it in AI Review"),ae.onclick=function(){Tr({focusPanel:!0,focusAction:F()})}}if(le){var ye=Ct(le);pt=pt||xi(we,"rte-ai-review-header-group is-recover","Recover");var C=o(pt,"button","","secondary rte-ai-review-header-button is-redo",ye.actionLabel);C.type="button",C.setAttribute("data-rte-ai-review-focus-key","redo-last"),C.setAttribute("data-rte-ai-review-shortcut-label",ye.shortcutLabel),C.setAttribute("aria-label","Redo the "+ye.detailLabel+(ye.summaryText?' for "'+ye.summaryText+'"':"")+" in AI Review"),C.onclick=function(){zr({focusPanel:!0,focusAction:F()})}}var me=o(Me,"button","","rte-ai-panel-close-button is-review-close");me.type="button",me.setAttribute("data-rte-ai-review-focus-key","close-review"),me.setAttribute("aria-label","Close AI review"),me.title="Close",me.innerHTML='<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 6l12 12"/><path d="M18 6L6 18"/></svg>',me.onclick=function(){Br()},vs();var N=o(j,"div","","rte-ai-review-stack rte-ai-review-overview");_r(N,"rte-ai-review-section-label is-overview","Queue overview");var ee=m.accepted+m.rejected+m.stale,Ae=m.total?Math.max(0,Math.min(100,Math.round(ee/m.total*100))):0,Se=o(N,"div","","rte-ai-review-overview-hero"),_e=o(Se,"div","","rte-ai-review-overview-status-row");o(_e,"span","","rte-ai-review-overview-pill is-status",Ws(m,E,S)),o(_e,"span","","rte-ai-review-overview-pill is-progress",ee+" of "+m.total+" reviewed"),S!=="all"&&o(_e,"span","","rte-ai-review-overview-pill is-filter",Pe(S)+" focus"),b&&b.count&&o(_e,"span","","rte-ai-review-overview-pill is-remote",b.count+" shared"),o(Se,"div","","rte-ai-review-overview-title",qc(m,E,S,Z)),o(Se,"div","","rte-ai-review-overview-detail",Ic(m,E,S,b));var Oe=o(Se,"div","","rte-ai-review-overview-progress"),oe=o(Oe,"div","","rte-ai-review-overview-progress-bar"),xt=o(oe,"span","","rte-ai-review-overview-progress-fill");xt.style.width=Ae+"%",o(Oe,"span","","rte-ai-review-overview-progress-label",Ae+"% complete");var Ne=o(N,"div","","rte-ai-review-summary");o(Ne,"span","","rte-ai-review-summary-pill is-pending",m.pending+" pending"),o(Ne,"span","","rte-ai-review-summary-pill is-accepted",m.accepted+" accepted"),o(Ne,"span","","rte-ai-review-summary-pill is-rejected",m.rejected+" rejected"),m.stale&&o(Ne,"span","","rte-ai-review-summary-pill is-stale",m.stale+" stale"),Z.total&&Z.index&&o(Ne,"span","","rte-ai-review-summary-pill is-current","Item "+Z.index+" of "+Z.total),S!=="all"&&o(Ne,"span","","rte-ai-review-summary-pill is-filtered",Pe(S)+" filter - "+E+" pending"),b&&o(Ne,"span","","rte-ai-review-summary-pill is-remote",b.count+" new shared");var _t=he($),tt=S==="all"?"All queues":Pe(S),vr=S==="all"?m.pending:E,ir=_t?je(_t,F(j))||"Review item":de?"Open next queue":m.pending?"Choose queue":"All clear",ht=_t?Z&&Z.total&&Z.index?"Item "+Z.index+" of "+Z.total+" in "+tt.toLowerCase()+".":"Current suggestion is ready.":de?"There are pending suggestions outside this filter.":m.pending?"Pick a queue filter to continue.":"No pending AI suggestions remain.",ke=o(N,"div","","rte-ai-review-center");ke.setAttribute("role","group"),ke.setAttribute("aria-label","AI review center summary");function Ce(_,te,Ee,et){var ft=o(ke,"div","","rte-ai-review-center-tile "+_);return o(ft,"div","","rte-ai-review-center-label",te),o(ft,"div","","rte-ai-review-center-value",Ee),o(ft,"div","","rte-ai-review-center-detail",et),ft}Ce("is-queue","Queue",vr+" pending",tt+(S!=="all"&&m.pending!==E?" - "+m.pending+" total pending":"")),Ce("is-progress","Progress",Ae+"% done",ee+" reviewed of "+m.total+" total");var zt=Ce("is-next","Next step",ir,ht);if($||de){var gt=o(zt,"button","","rte-ai-review-center-action",$?"Focus":"Open");gt.type="button",gt.setAttribute("data-rte-ai-review-focus-key",$?"center-focus-current":"center-open-next"),gt.setAttribute("aria-label",$?"Focus the current AI review item":"Open the next pending AI review queue"),gt.onclick=function(){$?At($,{focusPanel:!0,focusAction:F()}):de&&(p.typeFilter="all",At(de,{focusPanel:!0,focusAction:F(),openedQueue:!0}))}}var mt=cn(le);if(mt){var qi=Ct(le);o(N,"div","","rte-ai-review-summary-detail is-redo",mt+" Press Shift+U to "+qi.shortcutLabel+".");var ar=rl(2);if(ar.length){var Xr=o(N,"div","","rte-ai-review-summary-history is-redo");o(Xr,"div","","rte-ai-review-summary-history-title","Then");for(var Fe=0;Fe<ar.length;Fe++){var Cr=ar[Fe],Jt=o(Xr,"div","","rte-ai-review-summary-history-item");o(Jt,"div","","rte-ai-review-summary-history-label",Cr.label),o(Jt,"div","","rte-ai-review-summary-history-detail",Cr.detail)}}}if(b){var nr=o(N,"div","","rte-ai-review-activity-card"),Yr=o(nr,"div","","rte-ai-review-activity-copy");o(Yr,"div","","rte-ai-review-activity-title",b.title),o(Yr,"div","","rte-ai-review-activity-detail",b.detail);var rt=o(nr,"button","","secondary rte-ai-review-activity-button","Got it");rt.type="button",rt.setAttribute("data-rte-ai-review-focus-key","dismiss-activity"),rt.setAttribute("aria-label","Dismiss shared AI review update notice"),rt.onclick=function(){Yn(),pe(!0)}}var It=o(j,"div","","rte-ai-review-stack rte-ai-review-navigation");_r(It,"rte-ai-review-section-label is-controls","Filter and batch");var pr=o(It,"div","","rte-ai-review-controls"),mi=null;if(A.length>1){mi=Nn(pr,"rte-ai-review-control-group is-scope","Queue scope");var hr=o(mi,"select","","rte-ai-review-filter-select");hr.setAttribute("data-rte-ai-review-focus-key","type-filter");for(var Pt=0;Pt<A.length;Pt++){var Zr=o(hr,"option","","",A[Pt].label);Zr.value=A[Pt].value}hr.value=S,hr.onchange=function(){p.typeFilter=hr.value||"all",pe(!0)}}var Er=Nn(pr,"rte-ai-review-control-group is-visibility","Visibility"),Pr=o(Er,"button","","secondary rte-ai-review-control-button is-toggle-resolved",y?"Pending only":"Show resolved");Pr.type="button",Pr.setAttribute("data-rte-ai-review-focus-key","toggle-resolved"),Pr.onclick=function(){p.showResolved=!y,pe(!0)};var Ht=Nn(pr,"rte-ai-review-control-group is-batch","Batch review"),ot=o(Ht,"button","","secondary rte-ai-review-control-button is-accept-batch","Accept all");ot.type="button",ot.setAttribute("data-rte-ai-review-focus-key","accept-all"),ot.disabled=S==="all"?!m.pending:!E,S!=="all"&&(ot.innerText="Accept filtered"),ot.onclick=function(){Fo(S)&&pe(!0)};var Vt=o(Ht,"button","","secondary rte-ai-review-control-button is-reject-batch","Reject all");if(Vt.type="button",Vt.setAttribute("data-rte-ai-review-focus-key","reject-all"),Vt.disabled=S==="all"?!m.pending:!E,S!=="all"&&(Vt.innerText="Reject filtered"),Vt.onclick=function(){Ko(S)&&pe(!0)},A.length>1)for(var ei=o(mi||pr,"div","","rte-ai-review-type-chips"),lr=0;lr<A.length;lr++){var ut=A[lr],gr=K[ut.value]||0;if(!(ut.value!=="all"&&gr===0&&ut.value!==S)){var Mr=ut.label+" ("+gr+")",mr=o(ei,"button","","rte-ai-review-type-chip"+(ut.value===S?" is-active":""),Mr);mr.type="button",mr.setAttribute("data-rte-ai-review-focus-key","type-chip-"+ut.value),mr.setAttribute("aria-pressed",ut.value===S?"true":"false"),mr.onclick=(function(_){return function(){p.typeFilter=_,pe(!0)}})(ut.value)}}_r(It,"rte-ai-review-section-label is-shortcuts","Keyboard lane");var br=o(It,"div","","rte-ai-review-shortcuts","");if(br.id=tu(),s.__aiReviewShortcutDisplayNode=br,j.onfocus=function(){ia(j),j.title=Xo(he(fr(S)),F(j)),ql(he(fr(S)),F(j))},j.querySelectorAll)for(var wr=j.querySelectorAll("[data-rte-ai-review-focus-key]"),yr=0;yr<wr.length;yr++)sf(wr[yr],S);f||c?Zo(f||c):$?eu(he($)):(j.title=Xo(he(fr(S)),F(j)),ql(he(fr(S)),F(j)));var Ga=o(j,"div","","rte-ai-review-stack rte-ai-review-content");_r(Ga,"rte-ai-review-section-label is-feed",P.length?"Review items":"Recovery and next queues");var qr=o(Ga,"div","","rte-ai-review-feed");if(P.length)s.__aiLastReviewEmptyAnnouncement="",s.__aiReviewPrimaryEmptyAction=null,s.__aiReviewMoveEmptyPreviewFocus=null;else{let _=function(x,re){var Ie=[re||""];if(x&&x.getAttribute){var Y=x.getAttribute("data-rte-ai-empty-focus-label")||"",be=x.getAttribute("data-rte-ai-preview-change-label")||"",Or=x.getAttribute("data-rte-ai-preview-impact-label")||"";Y&&Ie.push("focus "+Y),be&&Ie.push(be),Or&&Ie.push(Or)}return Ie.filter(function(ai){return!!ai}).join(", ")},te=function(x){var re=ze.length;if(!x||!re)return{index:0,total:re};for(var Ie=0;Ie<re;Ie++)if(ze[Ie]===x)return{index:Ie+1,total:re};return{index:0,total:re}},Ee=function(x){var re=ze.length>1;ti&&(ti.innerText=Dc(x,re)),Da(Oc(x,{queueSwitcher:re}),"")},et=function(x){var re=x&&x.id?x.id:"";return re==="go-type"||re==="next-overall"||re==="all-types"?{key:"queue",label:"Next queues"}:re==="undo-last"?{key:"recovery",label:"Recover"}:{key:"utility",label:"More"}},ft=function(x,re,Ie){Ie=Ie||{};for(var Y=0;Y<ze.length;Y++){var be=ze[Y];be.removeAttribute("data-rte-ai-primary-empty"),be.removeAttribute("aria-current"),be.setAttribute("aria-pressed","false"),be.tabIndex=-1,be.classList&&be.classList.contains("is-primary-target")&&be.classList.remove("is-primary-target"),be.__aiCurrentBadge&&be.__aiCurrentBadge.parentNode&&be.__aiCurrentBadge.parentNode.removeChild(be.__aiCurrentBadge),be.__aiCurrentBadge=null,be.__aiQueueBadge&&be.__aiQueueBadge.parentNode&&be.__aiQueueBadge.parentNode.removeChild(be.__aiQueueBadge),be.__aiQueueBadge=null}if(s.__aiReviewPrimaryEmptyAction&&s.__aiReviewPrimaryEmptyAction!==x&&(s.__aiReviewPrimaryEmptyAction.removeAttribute("data-rte-ai-primary-empty"),s.__aiReviewPrimaryEmptyAction.classList&&s.__aiReviewPrimaryEmptyAction.classList.contains("is-primary-target")&&s.__aiReviewPrimaryEmptyAction.classList.remove("is-primary-target")),s.__aiReviewPrimaryEmptyAction=x||null,x&&(x.setAttribute("data-rte-ai-primary-empty","true"),x.setAttribute("aria-pressed","true"),x.tabIndex=0,x.classList&&x.classList.contains("rte-ai-review-empty-preview"))){x.classList.add("is-primary-target"),x.setAttribute("aria-current","true");var Or=x.__aiPreviewMetaNode||(x.querySelector?x.querySelector(".rte-ai-review-empty-preview-meta"):null);if(Or){x.__aiCurrentBadge=o(Or,"span","","rte-ai-review-empty-preview-pill is-current","Current");var ai=te(x);ai.total>1&&(x.__aiQueueBadge=o(Or,"span","","rte-ai-review-empty-preview-pill is-queue","Queue "+ai.index+" of "+ai.total))}}var Hn=Ve;Ve=_(x,re||""),x&&x.getAttribute&&ru(x.getAttribute("data-rte-ai-preview-suggestion-id")||""),Ee(Ve),Ie.announce&&Ve&&Ve!==Hn&&He("Completion handoff moved to "+Ve+".")},bt=function(x){if(ze.length<2)return!1;for(var re=0,Ie=0;Ie<ze.length;Ie++)if(ze[Ie]===document.activeElement||ze[Ie]===s.__aiReviewPrimaryEmptyAction){re=Ie;break}var Y=re;return x==="next"?Y=Math.min(ze.length-1,re+1):x==="previous"?Y=Math.max(0,re-1):x==="first"?Y=0:x==="last"&&(Y=ze.length-1),Y===re||!ze[Y]?(x==="next"||x==="last"?He("Already at the last available completion queue."):(x==="previous"||x==="first")&&He("Already at the first available completion queue."),!1):(ze[Y].focus(),!0)},Bt=function(x){if(x)if(x.id==="show-resolved")p.showResolved=!0,pe(!0);else if(x.id==="go-type"){p.typeFilter=x.typeValue||"all";var re=x.suggestionId||er(p.typeFilter,"");re?At(re,{focusPanel:!0,focusAction:x.focusAction||F(),openedQueue:!0}):pe(!0)}else x.id==="next-overall"?(p.typeFilter="all",x.suggestionId?At(x.suggestionId,{focusPanel:!0,focusAction:x.focusAction||F(),openedQueue:!0}):pe(!0)):x.id==="all-types"?(p.typeFilter="all",pe(!0)):x.id==="undo-last"?Tr({focusPanel:!0,focusAction:F()}):x.id==="open-chat"&&Yi({focusComposer:!0})};var xr=_,dt=te,ri=Ee,Ai=et,Tt=ft,Dr=bt,ii=Bt,Qe=Mc(m,E,S,y,de,K,A),Ve="",ti=null,ze=[];s.__aiReviewMoveEmptyPreviewFocus=bt;var Ir=Qe.title+"|"+Qe.detail+"|"+Qe.actions.map(function(x){return x?x.label:""}).join("|");Qe.announceMessage&&s.__aiLastReviewEmptyAnnouncement!==Ir&&(He(Qe.announceMessage),s.__aiLastReviewEmptyAnnouncement=Ir);var Lt=o(qr,"div","","rte-ai-review-empty"),Ar=ga(I),Ft=!!(Qe.previewItems&&Qe.previewItems.length),Hr=!!Ar;Lt.classList.toggle("is-queue-complete",Ft),Lt.classList.toggle("is-recoverable",Hr);var it=o(Lt,"div","","rte-ai-review-empty-hero"),at=o(it,"div","","rte-ai-review-empty-status-row");if(o(at,"span","","rte-ai-review-empty-status-pill "+(Ft?"is-ready":Hr?"is-recovery":"is-clear"),Ft?"Queue complete":Hr?"Recovery available":"All clear"),Ft&&o(at,"span","","rte-ai-review-empty-status-pill is-count",Qe.previewItems.length===1?"1 next queue":Qe.previewItems.length+" next queues"),o(it,"div","","rte-ai-review-empty-title",Qe.title),o(it,"div","","rte-ai-review-empty-detail",Qe.detail),ti=o(it,"div","","rte-ai-review-empty-hint",""),Ar){var Kt=o(Lt,"div","","rte-ai-review-empty-zone is-recovery");_r(Kt,"rte-ai-review-section-label is-recovery","Recovery"),o(Kt,"div","","rte-ai-review-empty-detail rte-ai-review-empty-undo-detail",Ar);var Sr=tl(3);if(Sr.length){var jr=o(Kt,"div","","rte-ai-review-empty-undo-history");o(jr,"div","","rte-ai-review-empty-undo-history-title","Then");for(var bi=0;bi<Sr.length;bi++){var Wt=Sr[bi],In=o(jr,"div","","rte-ai-review-empty-undo-history-item");o(In,"div","","rte-ai-review-empty-undo-history-label",Wt.label),o(In,"div","","rte-ai-review-empty-undo-history-detail",Wt.detail)}}}if(Qe.previewItems&&Qe.previewItems.length){var Ua=o(Lt,"div","","rte-ai-review-empty-zone is-next");_r(Ua,"rte-ai-review-section-label is-feed",Qe.previewItems.length>1?"Next queues":"Next queue");var la=o(Ua,"div","","rte-ai-review-empty-previews");la.setAttribute("role","toolbar"),la.setAttribute("aria-label","Next review queues");for(var Ii=0;Ii<Qe.previewItems.length;Ii++){var O=Qe.previewItems[Ii],Ze=O.typeValue?"button":"div",Le=o(la,Ze,"","rte-ai-review-empty-preview"+(O.typeValue?" is-actionable":""));if(Ze==="button"){Le.type="button",Le.tabIndex=-1,Le.setAttribute("aria-pressed","false"),Le.setAttribute("aria-setsize",String(Qe.previewItems.length)),Le.setAttribute("aria-posinset",String(Ii+1)),Le.setAttribute("aria-keyshortcuts",Bs({queueSwitcher:Qe.previewItems.length>1})),Le.title=$s(O.actionLabel||O.label||"Open next queue",{focusLabel:O.focusActionLabel,queueSwitcher:Qe.previewItems.length>1});var Rt=[O.actionLabel||O.label||"Open next queue"];O.focusActionLabel&&Rt.push("Focus "+O.focusActionLabel),O.pendingCountLabel&&Rt.push(O.pendingCountLabel),O.changeLabel&&Rt.push(O.changeLabel),O.impactLabel&&Rt.push(O.impactLabel),O.scopeLabel&&Rt.push(O.scopeLabel),O.languageLabel&&Rt.push(O.languageLabel),O.text&&Rt.push("Current: "+O.text),O.resultText&&Rt.push("Suggested: "+O.resultText),O.reasonText&&Rt.push("Why this next: "+O.reasonText),Le.setAttribute("aria-label",Rt.join(". ")),Le.setAttribute("data-rte-ai-primary-label",O.actionLabel||O.label||"Open next queue"),O.focusActionLabel&&Le.setAttribute("data-rte-ai-empty-focus-label",O.focusActionLabel),O.changeLabel&&Le.setAttribute("data-rte-ai-preview-change-label",O.changeLabel),O.impactLabel&&Le.setAttribute("data-rte-ai-preview-impact-label",O.impactLabel),O.suggestionId&&Le.setAttribute("data-rte-ai-preview-suggestion-id",O.suggestionId),Le.onclick=(function(x){return function(){Bt({id:"go-type",typeValue:x.typeValue,suggestionId:x.suggestionId,focusAction:x.focusAction||""})}})(O),Le.onfocus=function(){ia(this),ft(this,this.getAttribute("data-rte-ai-primary-label")||this.innerText||"",{announce:ze.length>1})},Le.onkeydown=function(x){var re=(x.key||"").toLowerCase();re==="u"&&x.shiftKey&&rr()?(x.preventDefault(),x.stopPropagation(),zr({focusPanel:!0,focusAction:F()})):re==="u"&&tr()?(x.preventDefault(),x.stopPropagation(),Tr({focusPanel:!0,focusAction:F()})):x.key==="ArrowRight"||x.key==="ArrowDown"||re==="j"?(x.preventDefault(),bt("next")):x.key==="ArrowLeft"||x.key==="ArrowUp"||re==="k"?(x.preventDefault(),bt("previous")):x.key==="Home"?(x.preventDefault(),bt("first")):x.key==="End"&&(x.preventDefault(),bt("last"))},ze.push(Le),s.__aiReviewPrimaryEmptyAction||ft(Le,O.actionLabel||O.label||"")}o(Le,"div","","rte-ai-review-empty-preview-label",O.label||"Next queue");var jt=o(Le,"div","","rte-ai-review-empty-preview-meta");Le.__aiPreviewMetaNode=jt,O.pendingCountLabel&&o(jt,"span","","rte-ai-review-empty-preview-pill",O.pendingCountLabel),O.focusActionLabel&&o(jt,"span","","rte-ai-review-empty-preview-pill is-focus","Focus "+O.focusActionLabel),O.changeLabel&&o(jt,"span","","rte-ai-review-empty-preview-pill is-change",O.changeLabel),O.impactLabel&&o(jt,"span","","rte-ai-review-empty-preview-pill is-impact",O.impactLabel),O.scopeLabel&&o(jt,"span","","rte-ai-review-empty-preview-pill",O.scopeLabel),O.languageLabel&&o(jt,"span","","rte-ai-review-empty-preview-pill",O.languageLabel);var $t=mn(O.text,O.resultText);zs(Le,"current",O.text||"",$t),O.resultText&&zs(Le,"result",O.resultText,$t),O.reasonText&&o(Le,"div","","rte-ai-review-empty-preview-reason","Why this next: "+O.reasonText)}}for(var sr=[],wi=0;wi<Qe.actions.length;wi++)Qe.actions[wi]&&sr.push(Qe.actions[wi]);if(sr.length){var or=o(Lt,"div","","rte-ai-review-empty-zone is-actions");_r(or,"rte-ai-review-section-label is-controls","Actions");for(var Il=o(or,"div","","rte-ai-review-empty-actions"),yi={},Hi=0;Hi<sr.length;Hi++)(function(x){var re=et(x);yi[re.key]||(yi[re.key]=o(Il,"div","","rte-ai-review-empty-action-group is-"+re.key),yi[re.key].setAttribute("data-rte-ai-empty-group-label",re.label));var Ie=Hi===0,Y=o(yi[re.key],"button","",Ie&&!s.__aiReviewPrimaryEmptyAction?"rte-ai-review-control-button is-primary":"secondary rte-ai-review-control-button","");o(Y,"span","","rte-ai-review-empty-action-label",x.label),x.focusActionLabel&&o(Y,"span","","rte-ai-review-empty-action-pill is-focus","Focus "+x.focusActionLabel),Y.type="button",x.id&&Y.setAttribute("data-rte-ai-empty-action-id",x.id),Y.setAttribute("aria-keyshortcuts",Bs()),Y.title=$s(x.label||"",{focusLabel:x.focusActionLabel}),x.focusActionLabel&&Y.setAttribute("data-rte-ai-empty-focus-label",x.focusActionLabel),x.suggestionId&&Y.setAttribute("data-rte-ai-preview-suggestion-id",x.suggestionId),Ie&&Y.setAttribute("data-rte-ai-primary-button","true"),Ie&&!s.__aiReviewPrimaryEmptyAction&&ft(Y,x.label||""),Y.onfocus=function(){ia(Y),(x.id==="go-type"||x.id==="next-overall")&&ru(x.suggestionId||""),Ee(_(Y,x.label||""))},Y.onkeydown=function(be){(be.key||"").toLowerCase()==="u"&&be.shiftKey&&rr()?(be.preventDefault(),be.stopPropagation(),zr({focusPanel:!0,focusAction:F()})):(be.key||"").toLowerCase()==="u"&&tr()&&(be.preventDefault(),be.stopPropagation(),Tr({focusPanel:!0,focusAction:F()}))},Y.onclick=function(){Bt(x)}})(sr[Hi])}var Fa=Ve||(sr[0]?sr[0].label:"");Ee(Fa)}for(var d="",v=0;v<P.length;v++)(function(_){var te=s.__aiRecentlyOpenedQueueSuggestionId===_.id,Ee=La(P,s.__aiActiveSuggestionId,_),et=Rc(P,s.__aiActiveSuggestionId,_,Ee);if(et&&et.key!==d){var ft=o(qr,"div","","rte-ai-review-feed-section is-"+et.key),bt=o(ft,"div","","rte-ai-review-feed-section-meta"),Bt=o(bt,"div","","rte-ai-review-feed-section-title",et.label);Bt.setAttribute("role","heading"),Bt.setAttribute("aria-level","3"),et.countLabel&&o(bt,"span","","rte-ai-review-feed-section-pill",et.countLabel),et.detail&&o(ft,"div","","rte-ai-review-feed-section-detail",et.detail),d=et.key}var x=fi(P,s.__aiActiveSuggestionId,_),re=s.__aiActiveSuggestionId===_.id,Ie=!re&&!te,Y=o(qr,"div","","rte-ai-review-item is-"+_.status+(re?" is-active":"")+(te?" is-opened":"")+(Ie?" is-condensed":""));Y.setAttribute("data-rte-ai-review-id",_.id),Y.setAttribute("data-rte-ai-review-density",Ie?"condensed":"expanded"),Ee&&Ee.role&&Y.setAttribute("data-rte-ai-review-queue-role",Ee.role),Y.setAttribute("role","button"),Y.tabIndex=s.__aiActiveSuggestionId===_.id?0:-1,Y.setAttribute("aria-keyshortcuts",Pn(_.status==="pending"?"Enter Space A R J K Home End":"Enter Space J K Home End")),Y.title=El(_,F(j));var be=Qt(_.id);s.__aiActiveSuggestionId===_.id&&Y.setAttribute("aria-current","true"),Y.onclick=function(da){if(!(da&&da.target&&da.target.closest&&da.target.closest(".rte-ai-review-item-actions"))){var zl=F(j),Un=document.activeElement;Un&&Un.getAttribute&&j.contains(Un)&&(zl=Un.getAttribute("data-rte-ai-review-action")||zl),!No(_.id,zl)&&gi(_.id,{focusPanel:!0})}},Y.onfocus=function(){ia(Y),Y.title=El(_,F(j)),eu(_),Ie&&wn(Y,_,j)};var Or=o(Y,"div","","rte-ai-review-item-state is-"+_.status+(re?" is-current":"")+(te?" is-opened":""));if(o(Or,"div","","rte-ai-review-item-state-kicker",_.status==="pending"?"Review item":"Review history"),o(Or,"div","","rte-ai-review-item-state-title",Hc(_,re,te)),o(Or,"div","","rte-ai-review-item-state-detail",jc(_,re,te,be)),Ee){var ai=o(Y,"div","","rte-ai-review-item-queue-card is-"+Ee.role);o(ai,"div","","rte-ai-review-item-queue-title",Ee.roleLabel);var Hn=o(ai,"div","","rte-ai-review-item-queue-meta");o(Hn,"span","","rte-ai-review-item-queue-pill is-role",Ee.roleLabel),o(Hn,"span","","rte-ai-review-item-queue-pill is-position",Ee.queueLabel),o(ai,"div","","rte-ai-review-item-queue-detail",Ee.detail)}if(x){var Ka=o(Y,"div","","rte-ai-review-item-transition-card");o(Ka,"div","","rte-ai-review-item-transition-title",x.title);var jn=o(Ka,"div","","rte-ai-review-item-transition-meta");if(o(jn,"span","","rte-ai-review-item-transition-pill is-status",x.statusLabel),o(jn,"span","","rte-ai-review-item-transition-pill is-position",x.queueLabel),x.typeLabel&&o(jn,"span","","rte-ai-review-item-transition-pill is-type",x.typeLabel),x.scopeLabel&&o(jn,"span","","rte-ai-review-item-transition-pill is-scope",x.scopeLabel),o(Ka,"div","","rte-ai-review-item-transition-detail",x.detail),Gs(Ka,"rte-ai-review-item-transition-preview",x),x.followupTitle){var Hl=o(Ka,"div","","rte-ai-review-item-transition-followup");o(Hl,"div","","rte-ai-review-item-transition-followup-title",x.followupTitle);var df=o(Hl,"div","","rte-ai-review-item-transition-followup-meta");x.followupStatusLabel&&o(df,"span","","rte-ai-review-item-transition-pill is-followup",x.followupStatusLabel),o(Hl,"div","","rte-ai-review-item-transition-followup-detail",x.followupDetail)}}var ji=o(Y,"div","","rte-ai-review-item-meta");o(ji,"span","","rte-ai-review-item-status is-"+_.status,ya(_.status)),o(ji,"span","","rte-ai-review-item-stamp",_.sourceLabel||(_.snapshot&&_.snapshot.hasSelection?"Selection suggestion":"Document suggestion")),re&&o(ji,"span","","rte-ai-review-item-stamp is-current","Current"),te&&o(ji,"span","","rte-ai-review-item-stamp is-opened","Queue opened"),_.suggestionType&&_.suggestionType!=="other"&&o(ji,"span","","rte-ai-review-item-stamp is-type",Pe(_.suggestionType)),_.language&&o(ji,"span","","rte-ai-review-item-stamp is-language",lt(_.language)),be&&o(ji,"span","","rte-ai-review-item-stamp is-remote",be>1?be+" shared updates":"Shared update");var Dn=o(Y,"div","","rte-ai-review-item-summary");o(Dn,"div","","rte-ai-review-item-title",Be(_.originalText||_.resultText||"AI suggestion",80)),Ie&&Pc(Dn,_,j,{queuePositionData:Ee,queueTransitionData:x,sharedUpdateCount:be});var Xt=Wi(_);if(Xt){var jl=o(Dn,"div","","rte-ai-review-item-glance-card");if(o(jl,"div","","rte-ai-review-item-glance-title",Xt.title),Xt.pills&&Xt.pills.length)for(var ff=o(jl,"div","","rte-ai-review-item-glance-meta"),Dl=0;Dl<Xt.pills.length;Dl++){var au=Xt.pills[Dl];o(ff,"span","","rte-ai-review-item-glance-pill is-"+au.kind,au.text)}Xt.detail&&o(jl,"div","","rte-ai-review-item-glance-detail",Xt.detail)}if(_.reason){var nu=o(Dn,"div","","rte-ai-review-item-reason-card");o(nu,"div","","rte-ai-review-item-reason-label","Why AI suggested this"),o(nu,"div","","rte-ai-review-item-reason",_.reason)}var Ol=o(Y,"div","","rte-ai-review-item-compare"),lu=o(Ol,"div","","rte-ai-review-item-compare-header");o(lu,"div","","rte-ai-review-item-compare-title","Compare change"),o(lu,"div","","rte-ai-review-item-compare-detail","Original and suggested text");var su=mn(_.originalText||"",_.resultText||""),vf=o(Ol,"div","","rte-ai-review-item-before");bn(vf,"current",R(_.originalText||""),su);var pf=o(Ol,"div","","rte-ai-review-item-after");bn(pf,"result",R(_.resultText||""),su);var sa=re&&_.status==="pending"&&I?kt(I):null,ou=sa?ga(I):"",On=sa?tl(1):[];if(sa)var hf=o(Y,"div","","rte-ai-review-item-undo-note",ou+" Press U to "+sa.shortcutLabel+"."),uu=dn(hf,"undo-note",_.id);var Na=null;On.length&&(Na=ys(Y,On,"undo"),dn(Na,"undo-history",_.id));var gf=!!(le&&le.suggestion&&le.suggestion.id===_.id&&_.status==="pending"),oa=gf?Ct(le):null,cu=oa?cn(le):"",Gl="";if(oa){var mf=o(Y,"div","","rte-ai-review-item-redo-note",cu+" Press Shift+U to "+oa.shortcutLabel+".");Gl=dn(mf,"redo-note",_.id)}var Qa=null,Gn=oa?rl(1):[];Gn.length&&(Qa=ys(Y,Gn,"redo"),dn(Qa,"redo-history",_.id)),Y.setAttribute("aria-label",Lc(_,{isCurrent:s.__aiActiveSuggestionId===_.id,queueOpened:te,queueRoleLabel:Ee?Ee.roleLabel:"",queuePositionLabel:Ee?Ee.queueLabel:"",transitionLabel:x?x.title+". "+x.statusLabel+". "+x.queueLabel+". "+Vr(x)+(x.followupTitle?". "+x.followupTitle+". "+x.followupDetail:""):"",changeSummary:Xt?Xt.title+". "+(Xt.pills||[]).map(function(da){return da.text}).join(". ")+(Xt.detail?". "+Xt.detail:""):"",remoteUpdateCount:be,undoLabel:ou,undoNextLabel:On.length?"Undo after this: "+On[0].detail:"",redoLabel:cu,redoNextLabel:Gn.length?"Redo after this: "+Gn[0].detail:""})),Y.setAttribute("data-rte-ai-review-base-aria-label",Y.getAttribute("aria-label")||""),Ie&&(Vs(Y,_,j),wn(Y,_,j));var Ul=o(Y,"div","","rte-ai-review-item-actions"),du=o(Ul,"div","","rte-ai-review-item-action-group is-locate");du.setAttribute("data-rte-ai-review-action-group","locate");var Fl=o(Ul,"div","","rte-ai-review-item-action-group is-decision");Fl.setAttribute("data-rte-ai-review-action-group","decision");var Kl=o(Ul,"div","","rte-ai-review-item-action-group is-recovery");Kl.setAttribute("data-rte-ai-review-action-group","recovery");var za=o(du,"button","","secondary rte-ai-review-action-button is-locate","Locate");if(za.type="button",za.setAttribute("data-rte-ai-review-action","locate"),za.disabled=_.status!=="pending"&&_.status!=="stale",za.onclick=function(){qt(_.id)},Oa(za,S,_.id,"locate"),_.status==="pending"){var Nl=hi(_,"accept",S)||{text:"Accept",label:"Accept this AI change"},ua=o(Fl,"button","","rte-ai-review-action-button is-primary is-accept",Nl.text);ua.type="button",ua.setAttribute("data-rte-ai-review-action","accept"),ua.setAttribute("aria-label",Nl.label),ua.title=Nl.label,ua.onclick=function(){Pi(_.id,"accept",{focusAction:"accept"})},Oa(ua,S,_.id,"accept");var Ql=hi(_,"reject",S)||{text:"Reject",label:"Reject this AI change"},ca=o(Fl,"button","","secondary rte-ai-review-action-button is-reject",Ql.text);if(ca.type="button",ca.setAttribute("data-rte-ai-review-action","reject"),ca.setAttribute("aria-label",Ql.label),ca.title=Ql.label,ca.onclick=function(){Pi(_.id,"reject",{focusAction:"reject"})},Oa(ca,S,_.id,"reject"),sa){var Ja=o(Kl,"button","","secondary rte-ai-review-action-button is-undo",sa.actionLabel);Ja.type="button",Ja.setAttribute("data-rte-ai-review-action","undo"),uu&&Ja.setAttribute("data-rte-ai-review-extra-describedby",uu+(Na&&Na.id?" "+Na.id:"")),Ja.onclick=function(){Tr({focusPanel:!0,focusAction:"undo"})},Oa(Ja,S,_.id,"undo")}if(oa){var Va=o(Kl,"button","","secondary rte-ai-review-action-button is-redo",oa.actionLabel);Va.type="button",Va.setAttribute("data-rte-ai-review-action","redo"),Gl&&Va.setAttribute("data-rte-ai-review-extra-describedby",Gl+(Qa&&Qa.id?" "+Qa.id:"")),Va.onclick=function(){zr({focusPanel:!0,focusAction:"redo"})},Oa(Va,S,_.id,"redo")}}})(P[v]);var w=!!e||u||!!f,T=zd(qr,w,f||c);Ha(f||c||F(j)),ja(f||c||F(j));var H=Ui().slice(0,6);if(H.length){o(qr,"div","","rte-ai-review-history-title","Recent activity");for(var ne=0;ne<H.length;ne++){var ce=H[ne],ie=Hu(ce),Ge=o(qr,"div","","rte-ai-review-history-entry is-"+ie);Ge.setAttribute("data-rte-ai-review-event",ce.eventType||"suggestion-updated");var nt=o(Ge,"div","","rte-ai-review-history-header");o(nt,"span","","rte-ai-review-history-event is-"+ie,ls(ce));var ct=[];ce.sourceLabel&&ct.push(ce.sourceLabel),ce.suggestionType&&ce.suggestionType!=="other"&&ct.push(Pe(ce.suggestionType)),ce.language&&ct.push(lt(ce.language)),o(nt,"div","","rte-ai-review-history-meta",ct.join(" - ")||"AI review"),o(Ge,"div","","rte-ai-review-history-text",Be(ce.resultText||ce.originalText||"AI review event",120))}}return w&&setTimeout(function(){var _=null;n&&j&&j.querySelector&&(_=j.querySelector('[data-rte-ai-review-focus-key="'+n+'"]'),_&&_.disabled&&(_=null),_&&_.focus&&_.focus()),!_&&s.__aiReviewPrimaryEmptyAction&&s.__aiReviewPrimaryEmptyAction.isConnected&&!s.__aiReviewPrimaryEmptyAction.disabled&&s.__aiReviewPrimaryEmptyAction.focus?s.__aiReviewPrimaryEmptyAction.focus():!_&&!T&&j&&j.focus&&j.focus()},0),!0}function na(e){e=e||{},s.__aiDialog&&s.__aiDialog.isConnected&&s.__aiDialog.close();var t=st(),r=s.createDialog(k.text_aiassist||"Ask AI","rte-panel-aiassist");r.__aiSnapshot=t,s.__aiDialog=r,r.__aiOperationStates={},r.__aiPlanStale=!1,r.__aiPlanStaleReason="",r.__aiPlanStaleAction="",r._onclose=function(){s.__aiDialog===r&&(s.__aiDialog=null)};var i=document.createElement("span");i.className="rte-ai-dialog-mode-chip is-detached",i.setAttribute("aria-hidden","true");var a=o(r,"div","","demo-ai-dialog-grid"),l=String(Date.now())+"-"+String(Math.floor(Math.random()*1e6)),n="rte-ai-mode-help-"+l,u="rte-ai-source-help-"+l,c="rte-ai-result-help-"+l,f="rte-ai-apply-guidance-"+l,p="rte-ai-dialog-status-"+l;a.setAttribute("role","form"),a.setAttribute("aria-label","Ask AI controls");var g=o(a,"div","","demo-ai-compact-controls");g.setAttribute("role","group"),g.setAttribute("aria-label","Ask AI setup");var m=o(g,"div","","demo-ai-field demo-ai-action-field"),b=o(m,"select");b.setAttribute("aria-label","AI action");var h=document.createElement("div");h.className="demo-ai-mode-caption is-detached",h.id=n;var y=o(g,"div","","demo-ai-field demo-ai-language-field"),A=o(y,"select");if(A.setAttribute("aria-label","Translation target language"),Yr(),e.presetMode){for(var K=!1,S=0;S<b.options.length;S++)if(b.options[S].value===e.presetMode){K=!0;break}K&&(b.value=e.presetMode)}b.options.length&&b.selectedIndex<0&&(b.selectedIndex=0),Pt(),b.setAttribute("aria-describedby",n);var q=o(g,"div","","demo-ai-field demo-ai-scope-field"),M=o(q,"select","","demo-ai-scope-select");M.setAttribute("aria-label","Source for Ask AI"),M.setAttribute("data-rte-ai-dialog-action","scope");var P=o(M,"option","","","Selection");P.value="selection";var L=o(M,"option","","","Document");L.value="document";var D=o(q,"span","","demo-ai-scope-caption");D.setAttribute("aria-hidden","true");var J=q.ownerDocument.createElement("div");J.className="demo-actions-row demo-ai-scope-row is-detached",J.setAttribute("role","group"),J.setAttribute("aria-label","Source scope");var E=q.ownerDocument.createElement("button");E.type="button",E.className="is-icon-only",E.setAttribute("data-rte-ai-dialog-action","load-selection"),E.title="Use selection",E.setAttribute("aria-label","Use selection"),ve(E,"cursorText",""),J.appendChild(E);var W=q.ownerDocument.createElement("button");W.type="button",W.className="secondary is-icon-only",W.setAttribute("data-rte-ai-dialog-action","load-document"),W.title="Use document",W.setAttribute("aria-label","Use document"),ve(W,"document",""),J.appendChild(W),q.appendChild(J);var de=o(g,"div","","demo-ai-field demo-ai-run-field"),$=o(de,"div","","demo-actions-row demo-ai-run-row");$.setAttribute("role","group"),$.setAttribute("aria-label","Ask AI run actions");var I=o($,"button","","is-primary");I.type="button",I.setAttribute("data-rte-ai-dialog-action","run"),ve(I,"sparkles","Generate"),I.title="Generate AI suggestion (Ctrl+Enter)",I.setAttribute("aria-keyshortcuts","Control+Enter");var le=/Mac|iPad|iPhone|iPod/i.test((navigator.platform||"")+" "+(navigator.userAgent||"")),Z=le?"\u2318\u23CE":"Ctrl \u23CE";function se(){if(I){var d=I.querySelector(".demo-ai-kbd-hint");d&&d.parentNode.removeChild(d);var v=I.ownerDocument.createElement("span");v.className="demo-ai-kbd-hint",v.setAttribute("aria-hidden","true"),v.textContent=Z,I.appendChild(v)}}se();var B=o($,"button","","secondary is-icon-only");B.type="button",B.title="Copy result into source",B.setAttribute("aria-label","Copy result into source"),B.setAttribute("data-rte-ai-dialog-action","copy-to-source"),ve(B,"checkAll","");var j=document.createElement("span");a.appendChild(h);var G=o(a,"div","","demo-ai-text-grid");G.setAttribute("role","group"),G.setAttribute("aria-label","Ask AI source and result");var xe=o(G,"div","","demo-ai-field demo-ai-source-field");o(xe,"span","","demo-ai-text-label-inline is-detached","Source");var ue=o(xe,"span","","demo-ai-field-help is-detached","Edit the source text or prompt that Ask AI will use.");ue.id=u;var X=o(xe,"textarea");X.setAttribute("aria-label","Source text for Ask AI"),X.setAttribute("aria-describedby",u+" "+n),xe.appendChild($),X.rows=1,X.placeholder="Type or paste text\u2026";var De=o(xe,"span","","demo-ai-source-counter");De.setAttribute("aria-hidden","true");function Re(){if(De){var d=X.value||"",v=d.length;if(!v){De.textContent="",De.classList.remove("is-visible");return}var w=v>999?Math.round(v/100)/10+"K chars":v+(v===1?" char":" chars");De.textContent=w,De.classList.add("is-visible")}}xe.style.order="2";var we=o(G,"div","","demo-ai-field demo-ai-result-field");we.style.order="1";var Te=o(we,"div","","demo-ai-result-head"),Xe=document.createElement("span");Xe.className="demo-ai-text-label-inline is-detached",Xe.innerText="Result";var pt=o(we,"span","","demo-ai-field-help is-detached","Review the generated AI suggestion before applying it.");pt.id=c;var Me=o(Te,"button","","demo-ai-clipboard-toggle");Me.type="button",Me.setAttribute("data-rte-ai-dialog-action","copy-clipboard"),Me.title="Copy AI output to clipboard",Me.setAttribute("aria-label","Copy AI output to clipboard"),ve(Me,"clipboard","Copy");var Ke=null;Me.onclick=function(d){d&&d.stopPropagation&&d.stopPropagation(),R(Q.value)&&io(Q.value).then(function(v){v&&(Me.classList.add("is-copied"),ve(Me,"check","Copied"),Ke&&clearTimeout(Ke),Ke=setTimeout(function(){Me.classList.remove("is-copied"),ve(Me,"clipboard","Copy"),Ke=null},1400))})};var ge=o(Te,"button","","demo-ai-clipboard-toggle demo-ai-why-toggle");ge.type="button",ge.setAttribute("data-rte-ai-dialog-action","why"),ge.title="Why this AI suggestion?",ge.setAttribute("aria-label","Show why this AI suggestion was generated"),ge.setAttribute("aria-expanded","false"),ve(ge,"info","");var z=o(Te,"button","","demo-ai-source-toggle");z.type="button",z.setAttribute("aria-expanded","false"),z.setAttribute("aria-controls","rte-ai-source-"+Date.now()),z.title="Edit the prompt and retry",z.setAttribute("aria-label","Edit the prompt and retry"),z.innerText="Edit",xe.id=z.getAttribute("aria-controls"),z.onclick=function(d){d&&d.stopPropagation&&d.stopPropagation();var v=a.classList.toggle("is-source-expanded");z.setAttribute("aria-expanded",v?"true":"false"),v&&X.focus()};var Q=o(we,"textarea");Q.readOnly=!0,Q.setAttribute("aria-label","AI suggestion result"),Q.setAttribute("aria-describedby",c+" "+p),Q.rows=1,Q.placeholder="Output appears here.";var qe=document.createElement("pre"),Ye=document.createElement("pre"),V=document.createElement("div");V.className="demo-ai-refine-row is-detached",V.setAttribute("role","group"),V.setAttribute("aria-label","Refine AI suggestion"),a.appendChild(V);var U=o(V,"button","","secondary demo-ai-refine-chip");U.type="button",U.title="Re-run with the same prompt",U.setAttribute("data-rte-ai-dialog-action","refine-retry"),ve(U,"refresh","Try again");var ae=o(V,"button","","secondary demo-ai-refine-chip");ae.type="button",ae.title="Make the suggestion shorter",ae.setAttribute("data-rte-ai-dialog-action","refine-shorter"),ve(ae,"shrink","Shorter");var ye=o(V,"button","","secondary demo-ai-refine-chip");ye.type="button",ye.title="Expand the suggestion with more detail",ye.setAttribute("data-rte-ai-dialog-action","refine-longer"),ve(ye,"expand","Longer");var C=document.createElement("button");C.type="button",C.className="secondary demo-ai-refine-chip demo-ai-refine-why-chip is-detached",C.innerText="Why",C.title="Show why this AI suggestion was generated",C.setAttribute("data-rte-ai-dialog-action","refine-why"),C.setAttribute("aria-expanded","false");function me(d){R(Q.value)&&(X.value=d+`
|
|
12
|
+
- `+Fr(a.slice(0,Math.max(10,Math.ceil(a.length*.45))).join(" "));default:return Fr(i)}}function vs(e){var t=E(e);return t?Fr('AI note: Consider clarifying this passage and tightening the wording around "'+t.split(/\s+/).slice(0,6).join(" ")+'"'):"AI note: Consider tightening this wording for clarity and reader confidence."}function Qu(e){var t=E(e);return t?Fr("Additional paragraph: This section adds a concise supporting explanation that reinforces "+t.split(/\s+/).slice(0,10).join(" ").replace(/[.!?;:,]+$/,"")+" for the reader."):"Additional paragraph: This section adds a concise supporting explanation so the reader gets more context without losing momentum."}function rn(e,t){var r=E(e);return!r||r.length<=t?r:r.substring(0,Math.max(0,t-3)).replace(/\s+\S*$/,"").trim()+"..."}function $u(e,t){var r=String(rn(t,160)||"").replace(/[ \t\r\n.!?;:,]+$/,"")||"the current document";return/\b(headings?|titles?)\b/.test(e)?"You could tighten the structure by using shorter headings that mirror the main claims in "+r+". Ask me to draft heading options and I can turn them into reviewable suggestions.":/\b(translate|translation)\b/.test(e)?"I can translate the current selection or whole document into Spanish, French, German, Italian, Portuguese, or Japanese and keep it reviewable in the editor before you accept it.":/\bwhy\b|\bhow\b|\bwhat\b|\?/.test(e)?"Based on "+r+", I would focus on clarity, stronger section framing, and cleaner transitions. If you want, ask me to rewrite or summarize a specific passage and I can prepare an in-editor suggestion.":"I reviewed "+r+". Ask me to rewrite, summarize, proofread, translate, comment on, or expand the current content and I can prepare editor-ready changes."}function Ju(e){var t=E(e).toLowerCase();if(!t)return"";for(var r=ga(),i=0;i<r.length;i++){var a=(r[i].label||"").toLowerCase(),n=(r[i].value||"").toLowerCase();if(a&&t.indexOf(a)>=0||n&&t.indexOf(n)>=0)return r[i].value||r[i].label}return""}function Vu(e){var t=E(e.prompt||""),r=E(e.source||e.selectionText||e.documentText||""),i=t.toLowerCase(),a=e.language||Ju(t),n=e.scope==="selection",l=n?"selection-preview":"document",u="",d="",p=l;if(!t)return{message:"Ask a question, request a rewrite, or tell the AI to summarize, proofread, translate, or expand the current content.",operations:[]};if(/\b(translate|translation|localize|localise)\b/.test(i)){var m=ot(a||"spanish");return d=Ut("translate",r,{language:a}),u="This prepares a translated "+m+" draft while keeping the original text nearby until you review and accept the change.",{message:"I prepared a "+m+" translation you can review before applying.",result:d,reason:u,operations:[ht(l,d,{reason:u},e,e.action)]}}return/\b(comment|note|feedback)\b/.test(i)?(d=vs(r),u="This AI note highlights a place that could use clarification or stronger editorial guidance.",{message:"I prepared an AI comment you can add next to the current content.",result:d,reason:u,operations:[{type:"add-comment",text:d,reason:u}]}):/\b(expand|add|insert|paragraph|develop)\b/.test(i)?(d=Ut("expand",r),u="This adds supporting detail without changing the original point, so it works well as an inserted follow-up paragraph.",p="insert",{message:"I drafted a supporting paragraph you can insert below the current content.",result:d,reason:u,operations:[ht(p,d,{reason:u},e,e.action)]}):/\b(summarize|summary|recap)\b|\bexecutive summary\b/.test(i)?(d=Ut("summarize",r),u="This compresses the current content into a shorter, clearer version that is easier to scan or reuse.",p=n?"selection-preview":"document",{message:"I prepared a condensed version of the current content for review.",result:d,reason:u,operations:[ht(p,d,{reason:u},e,e.action)]}):/\b(proofread|grammar|fix|correct)\b|\bclean up\b/.test(i)?(d=Ut("proofread",r),u="This pass improves grammar, punctuation, and readability while keeping the original meaning intact.",{message:"I prepared a proofread version you can preview inline and accept if it looks right.",result:d,reason:u,operations:[ht(l,d,{reason:u},e,e.action)]}):/\b(rewrite|adjust|clarify|improve|polish|tone)\b/.test(i)?(d=Ut("rewrite",r),u="This rewrite removes filler language and tightens the wording so the idea is easier to review and accept.",{message:"I drafted a clearer rewrite of the current content.",result:d,reason:u,operations:[ht(l,d,{reason:u},e,e.action)]}):{message:$u(i,r),operations:[]}}function ps(e){for(var t=tl(),r=0;r<t.length;r++)if(t[r].id===e)return t[r];return null}function tl(){return(L.aiToolkitActions||[]).slice()}function rl(){return(L.aiToolkitDialogModes||[]).slice()}function hs(e,t){if(!t||!t.id)return!1;for(var r=0;r<e.length;r++)if(e[r].id===t.id)return e[r]=t,!0;return e.push(t),!0}function gs(e,t){for(var r=e.length-1;r>=0;r--)if(e[r].id===t)return e.splice(r,1),!0;return!1}function Wu(e){return L.aiToolkitActions=L.aiToolkitActions||[],hs(L.aiToolkitActions,e),e}function Bu(e){return L.aiToolkitActions=L.aiToolkitActions||[],gs(L.aiToolkitActions,e)}function Xu(e){return L.aiToolkitDialogModes=L.aiToolkitDialogModes||[],hs(L.aiToolkitDialogModes,e),e}function Yu(e){return L.aiToolkitDialogModes=L.aiToolkitDialogModes||[],gs(L.aiToolkitDialogModes,e)}function Zu(e,t){return e?typeof t=="function"?(L.aiToolkitOperationHandlers[e]=t,!0):(delete L.aiToolkitOperationHandlers[e],!1):!1}function ec(e){return e&&L.aiToolkitOperationHandlers&&L.aiToolkitOperationHandlers[e]?(delete L.aiToolkitOperationHandlers[e],!0):!1}function ms(){return{version:"2026-04-18",operations:[{type:"open-chat-panel",description:"Open the docked AI chat panel."},{type:"open-review-panel",description:"Open the persistent AI review drawer."},{type:"open-dialog",description:"Open the Ask AI review dialog."},{type:"preview-suggestion",description:"Preview a reviewable inline suggestion for the current selection.",requiresText:!0,requiresSelection:!0},{type:"replace-selection",description:"Replace the current selection with new text.",requiresText:!0,requiresSelection:!0},{type:"replace-document",description:"Replace the whole editor document with new text.",requiresText:!0},{type:"insert-below",description:"Insert new text below the current selection or caret.",requiresText:!0},{type:"add-comment",description:"Insert an AI comment marker near the current selection or caret.",requiresText:!0}]}}function ht(e,t,r,i,a){var n=e||a&&a.target||"document",l={mode:i&&i.mode?i.mode:a&&a.resolverMode?a.resolverMode:"",language:i&&i.language?i.language:"",sourceLabel:fs(i&&i.mode?i.mode:a&&a.resolverMode?a.resolverMode:"",i&&i.snapshot?i.snapshot:null,i&&i.language?i.language:"",i&&i.scope?i.scope:"")};switch(n){case"chat-panel":return{type:"open-chat-panel"};case"review-panel":return{type:"open-review-panel"};case"dialog":return{type:"open-dialog",presetMode:r&&r.presetMode?r.presetMode:i&&i.mode?i.mode:"",useDocument:r&&typeof r.useDocument=="boolean"?r.useDocument:!1,autoRun:r&&typeof r.autoRun=="boolean"?r.autoRun:a&&typeof a.autoRun=="boolean"?a.autoRun:!1};case"selection-preview":case"preview":return{type:"preview-suggestion",text:t,meta:l};case"comment":return{type:"add-comment",text:t,meta:l};case"insert":return{type:"insert-below",text:t,meta:l};case"selection":return{type:"replace-selection",text:t,meta:l};default:return{type:"replace-document",text:t,meta:l}}}function tc(e,t,r,i,a){if(e==null)return null;if(typeof e=="string")return ht(t,e,r,i,a);var n=e.type||e.op||e.name||"";return n?{type:n,text:E(e.text||e.result||e.content||e.note||""),html:e.html||"",reason:e.reason||r&&r.reason||"",presetMode:e.presetMode||r&&r.presetMode||i&&i.mode||"",useDocument:typeof e.useDocument=="boolean"?e.useDocument:r&&typeof r.useDocument=="boolean"?r.useDocument:!1,autoRun:typeof e.autoRun=="boolean"?e.autoRun:r&&typeof r.autoRun=="boolean"?r.autoRun:a&&typeof a.autoRun=="boolean"?a.autoRun:!1,target:e.target||t||"",meta:e.meta||null}:ht(e.target||t,e.text||e.result||e.content||e.note||"",e,i,a)}function rc(e,t,r,i){var a=[];e&&e.operations?a=e.operations:e&&e.operation?a=[e.operation]:a=[ht(t,e&&(e.result||e.text||""),e,r,i)];for(var n=[],l=0;l<a.length;l++){var u=tc(a[l],t,e,r,i);u&&n.push(u)}return n}function $t(e){if(!e)return"";if(e.result)return E(e.result);for(var t=e.operations||[],r=0;r<t.length;r++)if(t[r]&&t[r].text)return E(t[r].text);return""}function _a(e){if(!e)return"";if(e.reason)return E(e.reason);for(var t=e.operations||[],r=0;r<t.length;r++)if(t[r]&&t[r].reason)return E(t[r].reason);return""}function _s(e){if(!e||!e.type)return{title:"Unknown step",copy:"This AI step does not expose a known editor action yet."};switch(e.type){case"open-chat-panel":return{title:"Open AI chat",copy:"Opens the docked AI chat panel for multi-turn document help."};case"open-review-panel":return{title:"Open AI review",copy:"Opens the persistent AI suggestion queue for the current editor."};case"open-dialog":return{title:"Open review dialog",copy:"Launches the Ask AI review dialog for a guided follow-up."};case"preview-suggestion":return{title:"Preview inline suggestion",copy:"Shows a reviewable inline diff in the editor before anything is committed."};case"replace-selection":return{title:"Replace selection",copy:"Updates the current selection with the generated text."};case"replace-document":return{title:"Replace document",copy:"Swaps the full editor content with the generated text."};case"insert-below":return{title:"Insert below",copy:"Adds generated content beneath the current selection or caret."};case"add-comment":return{title:"Add AI comment",copy:"Drops a non-destructive AI comment marker into the document."};default:return{title:e.type,copy:"Custom AI operation returned by the current resolver."}}}function bs(e){var t=e&&e.operations?e.operations:[];if(!t.length)return"Apply";if(t.length>1)return"Apply "+t.length+" steps";switch(t[0].type){case"preview-suggestion":return"Preview";case"open-review-panel":return"Open AI review";case"replace-selection":return"Replace selection";case"replace-document":return"Replace document";case"insert-below":return"Insert below";case"add-comment":return"Add AI comment";case"open-chat-panel":return"Open AI chat";case"open-dialog":return"Open review dialog";default:return"Apply"}}function ic(e){return bs({operations:[e]})}function ws(e){var t=e||[];if(!t.length)return"Select text to continue";if(t.length>1)return"Select text to apply plan";switch(t[0].type){case"preview-suggestion":return"Select text to preview";case"replace-selection":return"Select text to apply to selection";default:return"Select text to continue"}}function ac(e,t){if(!e||!e.type)return"Run this prepared AI step in the editor.";switch(e.type){case"preview-suggestion":return t&&t.hasSelection?"Show the prepared inline diff in the editor before deciding it.":"Select text to preview this prepared inline diff in the editor.";case"replace-selection":return t&&t.hasSelection?"Replace the current selection with this prepared draft.":"Select text before replacing it with this prepared draft.";case"replace-document":return"Replace the full document with this prepared draft.";case"insert-below":return t&&t.hasSelection?"Insert this prepared draft below the current selection.":"Insert this prepared draft below the current content.";case"add-comment":return"Add this prepared AI comment without rewriting the document body.";default:return"Run this prepared AI step in the editor."}}function ys(e,t,r,i){if(e){var a=[t||"Action"];r&&a.push(r),i&&a.push(i),e.setAttribute("aria-label",fe(a)),e.title=r?(t||"Action")+" - "+r+(i?" "+i:""):(t||"Action")+(i?" - "+i:"")}}function Kr(e,t,r,i,a){return al({operations:[ht(t,e,r,i,a)],presetMode:r&&r.presetMode?r.presetMode:i&&i.mode?i.mode:"",useDocument:r&&typeof r.useDocument=="boolean"?r.useDocument:!1,autoRun:r&&typeof r.autoRun=="boolean"?r.autoRun:!1},a,i)}function il(e){var t={midStart:!1,midEnd:!1};try{var r=e&&e.snapshot,i=r&&r.hasSelection&&e.scope!=="document"?r.range:null;if(!i)return t;var a=i.startContainer.ownerDocument,n=function(w){for(var y=w&&w.nodeType===1?w:w&&w.parentNode;y&&y.nodeType===1&&!/^(P|LI|TD|TH|H[1-6]|DIV|BLOCKQUOTE|PRE|BODY)$/.test(y.nodeName);)y=y.parentNode;return y&&y.nodeType===1?y:null},l=n(i.startContainer),u=n(i.endContainer);if(l){var d=a.createRange();d.selectNodeContents(l),d.setEnd(i.startContainer,i.startOffset);var p=d.toString();t.midStart=/\S/.test(p)&&!/[.!?]["'\u201d)\]]*\s*$/.test(p)}if(u){var m=a.createRange();m.selectNodeContents(u),m.setStart(i.endContainer,i.endOffset),t.midEnd=/\S/.test(m.toString())}}catch{}return t}function As(e){switch(e.mode){case"proofread":var t="Normalizes spacing, punctuation, and capitalization while keeping the original meaning intact.";return{operations:[ht(e.action&&e.action.target?e.action.target:"selection-preview",Ut("proofread",e.source,il(e)),{reason:t},e,e.action)],reason:t};case"rewrite":var r="Tightens the wording by removing filler phrases so the point comes through faster.";return{operations:[ht(e.action&&e.action.target?e.action.target:"selection-preview",Ut("rewrite",e.source,il(e)),{reason:r},e,e.action)],reason:r};case"translate":var i=e.action&&e.action.target&&e.action.target!=="dialog"?e.action.target:e.scope==="selection"?"selection-preview":"document";return{operations:[ht(i,Ut("translate",e.source,{language:e.language}),{reason:"This prepares a translated "+ot(e.language||"spanish")+" draft while keeping the original text available for review."},e,e.action)],reason:"This prepares a translated "+ot(e.language||"spanish")+" draft while keeping the original text available for review."};case"justify":return{operations:[{type:"preview-suggestion",text:Ut("rewrite",e.source,il(e)),reason:"This rewrite reduces filler language, clarifies the main point, and makes the sentence easier to review before accepting."}],reason:"This rewrite reduces filler language, clarifies the main point, and makes the sentence easier to review before accepting."};case"shorten":var a="Trims the passage to its core idea while keeping the original phrasing.";return{operations:[ht(e.action&&e.action.target?e.action.target:"document",Ut("shorten",e.source),{reason:a},e,e.action)],reason:a};case"expand":var n="Adds a supporting sentence that reinforces the original point without changing its direction.",l=e.action&&e.action.target&&e.action.id!==e.mode?e.action.target:"insert";return{operations:[ht(l,Ut("expand",e.source),{reason:n},e,e.action)],reason:n};case"summarize":var u="Condenses the content into a scannable summary that works as a recap or abstract.";return{operations:[ht(e.action&&e.action.target?e.action.target:"document",Ut("summarize",e.source),{reason:u},e,e.action)],reason:u};case"comment":return{operations:[{type:"add-comment",text:vs(e.source)}]};case"paragraph":return{operations:[{type:"insert-below",text:Qu(e.source)}]};case"chat":return Vu(e);default:return{operations:[ht(e.action&&e.action.target?e.action.target:"document",Ut(e.mode||"rewrite",e.source),null,e,e.action)]}}}function al(e,t,r){var i=t&&t.target?t.target:"document";if(e==null)return{result:"",target:i,operations:[],message:"",action:t,request:r};typeof e=="string"&&(e={operations:[ht(i,e,null,r,t)]});var a=rc(e,e.target||e.mode||i,r,t),n=a.length?a[0].target||e.target||e.mode||i:e.target||e.mode||i;return{result:E(e.result||e.text||$t({operations:a})||""),target:n,operations:a,message:E(e.message||e.reply||""),reason:E(e.reason||_a({operations:a})||""),autoRun:typeof e.autoRun=="boolean"?e.autoRun:t&&typeof t.autoRun=="boolean"?t.autoRun:!1,useDocument:typeof e.useDocument=="boolean"?e.useDocument:!1,presetMode:e.presetMode||r.mode||"",action:t,request:r}}function an(e,t){t=t||{};var r=ps(e)||{id:e,title:e,target:"document"},i=t.snapshot||ut(),a={actionId:e,action:r,mode:t.mode||r.resolverMode||e,source:t.source||i.text||i.wholeText,prompt:t.prompt||"",language:t.language||"",scope:t.scope||(i.hasSelection?"selection":"document"),selectionText:i.text||"",documentText:i.wholeText||"",snapshot:i,editor:s,contract:ms()};if(typeof L.aiToolkitResolver=="function")try{return Promise.resolve(L.aiToolkitResolver.call(s,a)).then(function(n){return(n===null||typeof n>"u")&&(n=As(a)),al(n,r,a)})}catch(n){return Promise.reject(n)}return Promise.resolve(al(As(a),r,a))}function ut(){var e=s.getSelection?s.getSelection():null,t={text:E(s.getSelectedText?s.getSelectedText():""),html:s.getSelectedHTML?s.getSelectedHTML():"",wholeText:E(s.getText?s.getText():""),range:null};if(t.hasSelection=!!t.text,e&&e.rangeCount)try{t.range=e.getRangeAt(0).cloneRange()}catch{t.range=null}return t}function nl(e){if(!e||!e.startContainer||!e.endContainer)return!1;var t=s.getEditable?s.getEditable():null;if(!t)return!1;var r=e.startContainer.nodeType===3?e.startContainer.parentNode:e.startContainer,i=e.endContainer.nodeType===3?e.endContainer.parentNode:e.endContainer;return!!(r&&i&&t.contains(r)&&t.contains(i))}function ll(e,t){if(!e&&!t)return!0;if(!nl(e)||!nl(t))return!1;try{return e.compareBoundaryPoints(e.START_TO_START,t)===0&&e.compareBoundaryPoints(e.END_TO_END,t)===0}catch{return!1}}function nn(e,t){if(!e||!e.range||!nl(e.range))return!1;var r=e.range.cloneRange();t&&r.collapse(!1),s.focus();var i=s.getSelection?s.getSelection():null;return i?(i.removeAllRanges?i.removeAllRanges():i.empty&&i.empty(),i.addRange(r),!0):!1}function ln(e){var t=E(e);if(!t)return"";for(var r=t.split(/\n{2,}/),i=[],a=0;a<r.length;a++)i.push("<p>"+s.htmlEncode(r[a]).replace(/\n/g,"<br/>")+"</p>");return i.join("")}function zr(e){var t=E(e);return t?s.htmlEncode(t).replace(/\n/g,"<br/>"):""}function pe(e){return s.htmlEncode(e||"")}function Qr(e){return s.htmlEncode(e||"").replace(/\n/g," ")}function nc(e){return/<(p|div|h1|h2|h3|h4|h5|h6|ul|ol|li|table|thead|tbody|tr|td|th|blockquote|pre|section|article)\b/i.test(e||"")}function Ne(){return s.__aiSuggestions||(s.__aiSuggestions=[]),s.__aiSuggestions}function Ni(){return s.__aiReviewLogEntries||(s.__aiReviewLogEntries=[]),s.__aiReviewLogEntries}function sn(){return L.aiToolkitPersistenceKey?"RTE.AIToolkit."+L.aiToolkitPersistenceKey:""}function on(){return L.aiToolkitPersistenceKey||""}function xs(e){return e?{id:e.id||"log-"+new Date().getTime()+"-"+Math.floor(Math.random()*1e3),documentKey:e.documentKey||on(),eventType:e.eventType||"suggestion-updated",suggestionId:e.suggestionId||"",status:e.status||"",suggestionType:Be(e.suggestionType||""),language:e.language||"",sourceLabel:e.sourceLabel||"",originalText:E(e.originalText||""),resultText:E(e.resultText||""),reason:E(e.reason||""),timestamp:e.timestamp||new Date().getTime()}:null}function Ss(e){switch(e.eventType){case"suggestion-created":return"Created";case"suggestion-accepted":return"Accepted";case"suggestion-rejected":return"Rejected";case"suggestion-reopened":return"Reopened";case"suggestion-stale":return"Marked stale";default:return"Updated"}}function lc(e){if(!e)return"updated";switch(e.eventType){case"suggestion-created":return"created";case"suggestion-accepted":return"accepted";case"suggestion-rejected":return"rejected";case"suggestion-reopened":return"reopened";case"suggestion-stale":return"stale";default:return"updated"}}function sc(e){return e?Ss(e)+" - "+(e.sourceLabel||"AI review"):""}function oc(e,t){return xs({id:"log-"+t.id+"-"+e+"-"+new Date().getTime(),documentKey:on(),eventType:e,suggestionId:t.id,status:t.status||"",suggestionType:t.suggestionType||"",language:t.language||"",sourceLabel:t.sourceLabel||(t.snapshot&&t.snapshot.hasSelection?"Selection suggestion":"Document suggestion"),originalText:t.originalText||"",resultText:t.resultText||"",reason:t.reason||"",timestamp:new Date().getTime()})}function uc(e){if(e){var t=Ni();t.unshift(e),t.length>30&&(t.length=30)}}function un(e,t,r,i){if(!t||!window.XMLHttpRequest)return typeof i=="function"&&i(null),!1;try{var a=new XMLHttpRequest;return a.open(e,t,!0),a.setRequestHeader("X-Requested-With","XMLHttpRequest"),r&&a.setRequestHeader("Content-Type","application/json; charset=utf-8"),a.onreadystatechange=function(){a.readyState===4&&typeof i=="function"&&i(a)},a.send(r||null),!0}catch{return typeof i=="function"&&i(null),!1}}function Ki(e,t){var r=L.aiToolkitReviewLogUrl||"";if(!r||!t||!on())return!1;var i=oc(e,t);return uc(i),un("POST",r,JSON.stringify(i),function(a){(!a||a.status<200||a.status>=300)&&console.warn("AI review log request failed")}),!0}function Ts(e,t){var r=L.aiToolkitReviewLogUrl||"",i=on();return!r||!i?(typeof t=="function"&&t(Ni().slice(),!1),!1):!e&&s.__aiReviewLogLoaded?(typeof t=="function"&&t(Ni().slice(),!0),!0):(un("GET",r+"?key="+encodeURIComponent(i),null,function(a){var n=[],l=!!(a&&a.status>=200&&a.status<300);if(l)try{for(var u=JSON.parse(a.responseText||"{}"),d=u&&u.entries?u.entries:[],p=0;p<d.length;p++){var m=xs(d[p]);m&&n.push(m)}}catch{}s.__aiReviewLogEntries=n,s.__aiReviewLogLoaded=l,typeof t=="function"&&t(n.slice(),l)}),!0)}function cc(e){return{id:e.id,changeType:e.changeType||"ai-preview",author:e.author?{id:e.author.id||"ai",name:e.author.name||"AI",color:e.author.color||"#8b5cf6"}:{id:"ai",name:"AI",color:"#8b5cf6"},originalHtml:e.originalHtml||"",originalText:e.originalText||"",resultText:e.resultText||"",resultHtml:e.resultHtml||"",reason:e.reason||"",suggestionType:e.suggestionType||"",language:e.language||"",isBlock:!!e.isBlock,status:e.status||"pending",createdAt:e.createdAt||new Date().getTime(),decidedAt:e.decidedAt||0,sourceLabel:e.sourceLabel||"",scope:e.snapshot&&e.snapshot.hasSelection?"selection":"document",text:e.text||"",blockPath:e.blockPath||"",mentions:dn(e.mentions),reactions:fn(e.reactions),replies:Array.isArray(e.replies)?e.replies:[]}}function cn(e){if(!e)return"";e=String(e),typeof s.sanitizeHtml=="function"&&(e=s.sanitizeHtml(e));for(var t=new DOMParser().parseFromString("<body>"+e+"</body>","text/html"),r=t.body.querySelectorAll("[style]"),i=0;i<r.length;i++){var a=r[i].style;/^(fixed|sticky)$/i.test(a.position)&&(a.removeProperty("position"),a.removeProperty("z-index"),r[i].getAttribute("style")||r[i].removeAttribute("style"))}return t.body.innerHTML}function dn(e){var t=[];if(!Array.isArray(e))return t;for(var r=0;r<e.length;r++){var i=e[r];i&&i.id!=null&&i.name&&t.push({id:String(i.id),name:String(i.name)})}return t}function fn(e){var t=[];if(!Array.isArray(e))return t;for(var r=0;r<e.length&&t.length<20;r++){var i=e[r];if(!(!i||typeof i.emoji!="string"||!i.emoji||i.emoji.length>8||!Array.isArray(i.users))){for(var a=[],n=0;n<i.users.length;n++){var l=i.users[n]==null?"":String(i.users[n]);l&&a.indexOf(l)<0&&a.push(l)}a.length&&t.push({emoji:i.emoji,users:a})}}return t}function dc(e){if(!e||!e.id)return null;var t=e.changeType||"ai-preview",r=e.author&&typeof e.author=="object"?e.author:null;return r||(r=t==="ai-preview"?{id:"ai",name:"AI",color:"#8b5cf6"}:{id:"user",name:"User",color:"#2563eb"}),{id:e.id,changeType:t,author:{id:r.id||"user",name:r.name||r.id||"User",color:r.color||"#2563eb"},originalHtml:cn(e.originalHtml),originalText:e.originalText||"",resultText:e.resultText||"",resultHtml:cn(e.resultHtml),reason:e.reason||"",suggestionType:e.suggestionType||"",language:e.language||"",isBlock:!!e.isBlock,status:e.status||"pending",createdAt:e.createdAt||new Date().getTime(),decidedAt:e.decidedAt||0,sourceLabel:e.sourceLabel||"",snapshot:e.snapshot||{hasSelection:e.scope==="selection"},text:e.text||"",mentions:dn(e.mentions),reactions:fn(e.reactions),blockPath:e.blockPath||"",replies:Array.isArray(e.replies)?e.replies:[]}}function Ls(e){if(!e||!e.id)return null;var t=e.changeType||"ai-preview",r=e.author&&typeof e.author=="object"?e.author:null;return r||(r=t==="ai-preview"?{id:"ai",name:"AI",color:"#8b5cf6"}:{id:"user",name:"User",color:"#2563eb"}),{id:e.id,changeType:t,author:{id:r.id||"user",name:r.name||r.id||"User",color:r.color||"#2563eb"},originalHtml:cn(e.originalHtml)||zr(e.originalText||""),originalText:E(e.originalText||""),resultText:E(e.resultText||""),resultHtml:cn(e.resultHtml)||zr(e.resultText||""),reason:E(e.reason||""),suggestionType:Be(e.suggestionType||""),language:e.language||"",isBlock:!!e.isBlock,status:e.status==="accepted"||e.status==="rejected"||e.status==="stale"?e.status:"stale",createdAt:e.createdAt||new Date().getTime(),decidedAt:e.decidedAt||0,sourceLabel:e.sourceLabel||(e.scope==="selection"?"Selection suggestion":"Document suggestion"),snapshot:{hasSelection:e.scope==="selection"},text:e.text||"",mentions:dn(e.mentions),reactions:fn(e.reactions),blockPath:e.blockPath||"",replies:Array.isArray(e.replies)?e.replies:[]}}function sl(){return L.aiToolkitPersistenceKey||""}function fc(){return{version:"2026-04-18",documentKey:sl(),savedAt:new Date().getTime(),suggestions:Ne().map(cc)}}function Rs(e){switch(e){case"pending":return 4;case"accepted":return 3;case"rejected":return 2;case"stale":return 1;default:return 0}}function zi(e){return Math.max(e&&e.decidedAt||0,e&&e.createdAt||0)}function ol(e){return e?{id:e.id,originalHtml:e.originalHtml||"",originalText:e.originalText||"",resultText:e.resultText||"",resultHtml:e.resultHtml||"",reason:e.reason||"",suggestionType:e.suggestionType||"",language:e.language||"",isBlock:!!e.isBlock,status:e.status||"stale",createdAt:e.createdAt||0,decidedAt:e.decidedAt||0,sourceLabel:e.sourceLabel||"",mentions:dn(e.mentions),reactions:fn(e.reactions),snapshot:{hasSelection:!!(e.snapshot&&e.snapshot.hasSelection)}}:null}function vc(e,t){if(!e)return ol(t);if(!t)return e;var r=zi(e),i=zi(t);return i>r?ol(t):i<r?e:Rs(t.status)>Rs(e.status)?ol(t):e}function pc(e,t){var r={},i=[],a;function n(u){!u||!u.id||(r[u.id]||i.push(u.id),r[u.id]=vc(r[u.id],u))}for(a=0;a<e.length;a++)n(e[a]);for(a=0;a<t.length;a++)n(t[a]);var l=[];for(a=0;a<i.length;a++)r[i[a]]&&l.push(r[i[a]]);return l.sort(function(u,d){return zi(d)-zi(u)}),l}function hc(){var e=sn(),t="";if(e&&window.localStorage)try{t=window.localStorage.getItem(e)||""}catch{}if(!t){var r=ki();r&&r.getAttribute&&(t=r.getAttribute("data-rte-ai-ledger")||"")}return t}function Cs(e,t){var r=L.aiToolkitSuggestionLedgerUrl||"";return!r||!e||!e.documentKey?(typeof t=="function"&&t(null),!1):un("POST",r,JSON.stringify(e),t)}function gc(){var e=parseInt(L.aiToolkitReviewSyncInterval,10);return e>=5e3?e:15e3}function mc(){return s.__aiReviewLastSyncedAt||0}function _c(e){s.__aiReviewLastSyncedAt=e||new Date().getTime()}function ks(){return s.__aiReviewSyncState||(s.__aiReviewSyncState={phase:Ci()?"idle":"local",message:""}),s.__aiReviewSyncState}function Es(){if(!Ci())return{subtitle:"Queued AI suggestions for this session.",badge:"Local",badgeClass:"is-local",buttonText:"Sync now",buttonDisabled:!0,syncing:!1};var e=ks();if(e.phase==="syncing")return{subtitle:e.message||"Syncing shared AI review...",badge:"Syncing",badgeClass:"is-syncing",buttonText:"Syncing...",buttonDisabled:!0,syncing:!0};if(e.phase==="error")return{subtitle:e.message||"Shared AI review sync failed. Try again.",badge:"Retry",badgeClass:"is-error",buttonText:"Retry sync",buttonDisabled:!1,syncing:!1};var t=mc();if(!t)return{subtitle:"Shared AI review sync is ready.",badge:"Shared",badgeClass:"is-shared",buttonText:"Sync now",buttonDisabled:!1,syncing:!1};var r=Math.max(0,Math.round((new Date().getTime()-t)/1e3));return r<5?{subtitle:"Shared AI review synced just now.",badge:"Live",badgeClass:"is-live",buttonText:"Sync now",buttonDisabled:!1,syncing:!1}:r<60?{subtitle:"Shared AI review synced "+r+"s ago.",badge:"Live",badgeClass:"is-live",buttonText:"Sync now",buttonDisabled:!1,syncing:!1}:{subtitle:"Shared AI review synced "+Math.round(r/60)+"m ago.",badge:"Live",badgeClass:"is-live",buttonText:"Sync now",buttonDisabled:!1,syncing:!1}}function vn(e,t){var r=ks();r.phase=e||(Ci()?"idle":"local"),r.message=t||"",Ps()}function Ci(){return!!(L.aiToolkitSuggestionLedgerUrl||L.aiToolkitReviewLogUrl)}function bc(){return Es().subtitle}function Ps(){if(!s.__aiReviewPanel||!s.__aiReviewPanel.isConnected)return!1;var e=Es();return s.__aiReviewSubtitleNode&&(s.__aiReviewSubtitleNode.textContent=e.subtitle),s.__aiReviewSyncBadgeNode&&(s.__aiReviewSyncBadgeNode.className="rte-ai-review-sync-badge "+e.badgeClass,s.__aiReviewSyncBadgeNode.textContent=e.badge),s.__aiReviewSyncButton&&(s.__aiReviewSyncButton.textContent=e.buttonText,s.__aiReviewSyncButton.disabled=!!e.buttonDisabled,e.syncing?s.__aiReviewSyncButton.setAttribute("aria-busy","true"):s.__aiReviewSyncButton.removeAttribute("aria-busy")),!0}function wc(e,t){var r={},i=[],a;for(a=0;a<e.length;a++)e[a]&&e[a].id&&(r[e[a].id]=!0);for(a=0;a<t.length;a++)t[a]&&t[a].id&&!r[t[a].id]&&i.push(t[a]);return i}function yc(e){if(!e||!e.length)return!1;var t=Ht();t.unseenRemoteActivityCount+=e.length,t.latestRemoteActivity=e[0],t.latestRemoteSuggestionId=e[0]&&e[0].suggestionId?e[0].suggestionId:t.latestRemoteSuggestionId;for(var r=0;r<e.length;r++)e[r]&&e[r].suggestionId&&Lc(e[r].suggestionId);return!0}function qs(e){return(e||[]).slice().sort(function(t,r){var i=Jt(t.id),a=Jt(r.id);if(i!==a)return a-i;if(s.__aiActiveSuggestionId){if(t.id===s.__aiActiveSuggestionId)return-1;if(r.id===s.__aiActiveSuggestionId)return 1}return zi(r)-zi(t)})}function Ac(){for(var e=Ne().slice(),t=!1,r=0;r<e.length;r++){var i=e[r],a=Lr(i.id),n=cl(i.id);if(i.status==="pending"){n&&(n.outerHTML=Ll(i),t=!0);continue}if(i.status==="accepted"||i.status==="rejected"||i.status==="stale"){var l=pn(i,i.status);a?(a.outerHTML=l,t=!0):n&&((n.getAttribute("data-rte-ai-resolved-status")||"")!==i.status||n.innerHTML!==(i.status==="accepted"?i.resultHtml||zr(i.resultText||""):i.originalHtml||zr(i.originalText||"")))&&(n.outerHTML=l,t=!0)}}return fr(),t}function ui(e,t){if(!Ci())return typeof t=="function"&&t(Ne().slice()),!1;if(s.__aiReviewSyncInFlight)return typeof t=="function"&&(s.__aiReviewSyncCallbacks||(s.__aiReviewSyncCallbacks=[]),s.__aiReviewSyncCallbacks.push(t)),e&&(s.__aiReviewSyncPending=!0),vn("syncing","Syncing shared AI review..."),!0;s.__aiReviewSyncInFlight=!0,s.__aiReviewSyncPending=!1,s.__aiReviewSyncCallbacks=typeof t=="function"?[t]:[],vn("syncing","Syncing shared AI review...");var r=0,i=Ne().slice(),a=!1,n=Ni().slice(),l=!!s.__aiReviewLogLoaded;function u(){if(r--,!(r>0)){s.__aiReviewSyncInFlight=!1,a?vn("error","Shared AI review sync failed. Showing the last known state."):(_c(new Date().getTime()),vn("idle")),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&ge(!1);var d=s.__aiReviewSyncCallbacks?s.__aiReviewSyncCallbacks.slice():[];s.__aiReviewSyncCallbacks=[];for(var p=0;p<d.length;p++)d[p](i.slice());s.__aiReviewSyncPending&&(s.__aiReviewSyncPending=!1,ui(!0))}}return L.aiToolkitSuggestionLedgerUrl&&(r++,Is(e,function(d,p){i=d||Ne().slice(),p||(a=!0),Ac(),u()})),L.aiToolkitReviewLogUrl&&(r++,Ts(e,function(d,p){p?l&&yc(wc(n,d||[])):a=!0,u()})),r>0}function Is(e,t){var r=L.aiToolkitSuggestionLedgerUrl||"",i=sl();return!r||!i?(typeof t=="function"&&t(Ne().slice(),!1),!1):!e&&s.__aiSuggestionLedgerLoaded?(typeof t=="function"&&t(Ne().slice(),!0),!0):(un("GET",r+"?key="+encodeURIComponent(i),null,function(a){var n=[],l=!!(a&&a.status>=200&&a.status<300);if(l)try{for(var u=JSON.parse(a.responseText||"{}"),d=u&&u.suggestions?u.suggestions:[],p=0;p<d.length;p++){var m=Ls(d[p]);m&&n.push(m)}}catch{}var w=pc(Ne(),n);s.__aiSuggestions=w,s.__aiSuggestionLedgerLoaded=l,yt({skipRemote:!0}),typeof t=="function"&&t(w.slice(),l)}),!0)}function Qf(){s.__aiReviewSyncTimer&&(window.clearInterval(s.__aiReviewSyncTimer),s.__aiReviewSyncTimer=null)}function xc(){return!Ci()||s.__aiReviewSyncTimer||!window.setInterval?!1:(s.__aiReviewSyncTimer=window.setInterval(function(){document&&document.hidden||ui(!0)},gc()),!0)}function Sc(){s.__aiReviewSyncEventsBound||(s.__aiReviewSyncEventsBound=!0,document&&document.addEventListener&&document.addEventListener("visibilitychange",function(){document.hidden||ui(!0)}),window&&window.addEventListener&&window.addEventListener("focus",function(){ui(!0)}))}function yt(e){e=e||{};var t=fc(),r=JSON.stringify(t),i=ki();i&&i.setAttribute&&i.setAttribute("data-rte-ai-ledger",r);var a=sn();if(a&&window.localStorage)try{window.localStorage.setItem(a,r)}catch{}return e.skipRemote||Cs(t,function(n){(!n||n.status<200||n.status>=300)&&console.warn("AI suggestion ledger request failed")}),r}function Ms(){var e=hc();if(!e)return s.__aiSuggestions=[],gn(),Xe(null),[];try{for(var t=JSON.parse(e),r=t&&t.suggestions?t.suggestions:[],i=[],a=0;a<r.length;a++){var n=Ls(r[a]);n&&i.push(n)}return s.__aiSuggestions=i,kc(),Xe(null),i.slice()}catch{return s.__aiSuggestions=[],gn(),Xe(null),[]}}function Tc(){s.__aiSuggestions=[],gn(),Xe(null);var e=ki();e&&e.removeAttribute&&e.removeAttribute("data-rte-ai-ledger");var t=sn();if(t&&window.localStorage)try{window.localStorage.removeItem(t)}catch{}return s.__aiSuggestionLedgerLoaded=!1,Cs({version:"2026-04-18",documentKey:sl(),savedAt:new Date().getTime(),suggestions:[]},function(){}),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&ge(!1),!0}function Ht(){return s.__aiReviewState||(s.__aiReviewState={showResolved:!1,typeFilter:"all",unseenRemoteActivityCount:0,latestRemoteActivity:null,latestRemoteSuggestionId:"",remoteSuggestionIds:{}}),s.__aiReviewState}function ul(){var e=Ht();e.unseenRemoteActivityCount=0,e.latestRemoteActivity=null,e.latestRemoteSuggestionId="",e.remoteSuggestionIds={}}function Lc(e){if(!e)return!1;var t=Ht();return t.remoteSuggestionIds[e]=(t.remoteSuggestionIds[e]||0)+1,!0}function ba(e){var t=Ht();return e&&t.remoteSuggestionIds[e]?(delete t.remoteSuggestionIds[e],!0):!1}function Jt(e){var t=Ht();return e&&t.remoteSuggestionIds[e]||0}function Rc(){return Ht().latestRemoteSuggestionId||""}function Cc(){var e=Ht();if(!e.unseenRemoteActivityCount)return null;var t=e.latestRemoteActivity,r=e.unseenRemoteActivityCount;return{count:r,title:r===1?"1 shared review update just arrived.":r+" shared review updates just arrived.",detail:t?sc(t):"Shared AI review activity is newer than your local view."}}function me(e){for(var t=Ne(),r=0;r<t.length;r++)if(t[r].id===e)return t[r];return null}function Lr(e){var t=s.getEditable?s.getEditable():null;return t?t.querySelector('[data-rte-ai-suggestion-id="'+e+'"]'):null}function cl(e){var t=s.getEditable?s.getEditable():null;return t?t.querySelector('[data-rte-ai-resolved-id="'+e+'"]'):null}function pn(e,t){if(!e)return"";var r=t||e.status||"accepted",i=e.isBlock?"div":"span",a=r==="accepted"?e.resultHtml||zr(e.resultText||""):e.originalHtml||zr(e.originalText||"");return"<"+i+' class="rte-ai-resolved-suggestion is-'+Qr(r)+(e.isBlock?" is-block":" is-inline")+'" data-rte-ai-resolved-id="'+Qr(e.id)+'" data-rte-ai-resolved-status="'+Qr(r)+'">'+a+"</"+i+">"}function Qi(){return s.__aiReviewDecisionHistory||(s.__aiReviewDecisionHistory=[]),s.__aiReviewDecisionHistory}function kc(){for(var e=Qi(),t=e.length-1;t>=0;t--){var r=e[t],i=r&&r.suggestionId?me(r.suggestionId):null;(!i||i.status!==r.status)&&e.splice(t,1)}return e}function $f(){var e=Qi();return e.length?e[e.length-1]:null}function dl(e,t,r){if(r=r||{},!e||!e.id||!t)return gn(),null;r.clearRedo!==!1&&js();var i=Qi();return i.push({suggestionId:e.id,status:t,timestamp:new Date().getTime()}),i.length>12&&i.splice(0,i.length-12),i[i.length-1]}function Hs(){var e=Qi();return e.length?e.pop():null}function hn(){return s.__aiReviewRedoHistory||(s.__aiReviewRedoHistory=[]),s.__aiReviewRedoHistory}function Ec(e,t){if(!e||!e.id||!t)return null;var r=hn();return r.push({suggestionId:e.id,status:t,timestamp:new Date().getTime()}),r.length>12&&r.splice(0,r.length-12),r[r.length-1]}function Ds(){var e=hn();return e.length?e.pop():null}function js(){s.__aiReviewRedoHistory=[]}function gn(){s.__aiReviewDecisionHistory=[],js()}function ci(){for(var e=Qi();e.length;){var t=e[e.length-1];if(!t||!t.suggestionId){e.pop();continue}var r=me(t.suggestionId),i=cl(t.suggestionId);if(!r||!i||r.status!==t.status){e.pop();continue}return{suggestion:r,wrapper:i,status:t.status,timestamp:t.timestamp||0,historyCount:e.length,remainingCount:e.length-1}}return null}function Rr(){for(var e=hn();e.length;){var t=e[e.length-1];if(!t||!t.suggestionId){e.pop();continue}var r=me(t.suggestionId),i=Lr(t.suggestionId);if(!r||!i||r.status!=="pending"){e.pop();continue}return{suggestion:r,wrapper:i,status:t.status,timestamp:t.timestamp||0,historyCount:e.length,remainingCount:e.length-1}}return null}function Pt(e){if(e=e||ci(),!e||!e.suggestion)return{actionLabel:"Undo last",shortcutLabel:"undo last",decisionLabel:"last",typeLabel:"",detailLabel:"last suggestion",summaryText:""};var t=e.suggestion,r=e.status==="rejected"?"rejected":e.status==="accepted"?"accepted":"resolved",i=t.suggestionType&&t.suggestionType!=="other"?Me(t.suggestionType).toLowerCase():"";return{actionLabel:"Undo "+r+(i?" "+i:"")+(e.remainingCount?" ("+e.remainingCount+" more)":""),shortcutLabel:"undo "+r,decisionLabel:r,typeLabel:i,detailLabel:r+" "+(i?i+" ":"")+"suggestion",summaryText:Ye(t.originalText||t.resultText||"suggestion",72),remainingCount:e.remainingCount||0}}function wa(e){var t=Pt(e);return!e||!e.suggestion?"":"Undo target: "+t.detailLabel+(t.summaryText?" - "+t.summaryText:"")+(t.remainingCount?". "+t.remainingCount+" earlier undo"+(t.remainingCount===1?" remains.":"s remain."):"")}function mn(e){var t=qt(e);return!e||!e.suggestion?"":"Redo target: "+t.detailLabel+(t.summaryText?" - "+t.summaryText:"")+(t.remainingCount?". "+t.remainingCount+" earlier redo"+(t.remainingCount===1?" remains.":"s remain."):"")}function qt(e){if(e=e||Rr(),!e||!e.suggestion)return{actionLabel:"Redo last",shortcutLabel:"redo last",decisionLabel:"last",detailLabel:"last suggestion",summaryText:"",remainingCount:0};var t=e.suggestion,r=e.status==="rejected"?"rejected":e.status==="accepted"?"accepted":"resolved",i=t.suggestionType&&t.suggestionType!=="other"?Me(t.suggestionType).toLowerCase():"";return{actionLabel:"Redo "+r+(i?" "+i:"")+(e.remainingCount?" ("+e.remainingCount+" more)":""),shortcutLabel:"redo "+r,decisionLabel:r,detailLabel:r+" "+(i?i+" ":"")+"suggestion",summaryText:Ye(t.originalText||t.resultText||"suggestion",72),remainingCount:e.remainingCount||0}}function fl(e){for(var t=Qi(),r=[],i=typeof e=="number"?e:3,a=t.length-2;a>=0&&r.length<i;a--){var n=t[a];if(!(!n||!n.suggestionId)){var l=me(n.suggestionId),u=cl(n.suggestionId);if(!(!l||!u||l.status!==n.status)){var d={suggestion:l,wrapper:u,status:n.status,timestamp:n.timestamp||0,historyCount:a+1,remainingCount:a},p=Pt(d);r.push({label:p.actionLabel,detail:wa(d)})}}}return r}function vl(e){for(var t=hn(),r=[],i=typeof e=="number"?e:3,a=t.length-2;a>=0&&r.length<i;a--){var n=t[a];if(!(!n||!n.suggestionId)){var l=me(n.suggestionId),u=Lr(n.suggestionId);if(!(!l||!u||l.status!=="pending")){var d={suggestion:l,wrapper:u,status:n.status,timestamp:n.timestamp||0,historyCount:a+1,remainingCount:a},p=qt(d);r.push({label:p.actionLabel,detail:p.detailLabel+(p.summaryText?" - "+p.summaryText:"")})}}}return r}function Os(e,t,r){if(!e||!t||!t.length)return null;var i=o(e,"div","","rte-ai-review-item-history"+(r?" is-"+r:""));o(i,"div","","rte-ai-review-item-history-title","Then");for(var a=0;a<t.length;a++){var n=t[a],l=o(i,"div","","rte-ai-review-item-history-item");o(l,"div","","rte-ai-review-item-history-label",n.label),o(l,"div","","rte-ai-review-item-history-detail",n.detail)}return i}function _n(e,t,r){if(!e||!e.setAttribute)return"";if(e.id)return e.id;var i=String(r||"item").replace(/[^A-Za-z0-9\-_:.]/g,"-");return e.id="rte-ai-review-"+t+"-"+i,e.id}function ya(e){if(!e||!e.focus)return!1;try{return e.focus({preventScroll:!0}),!0}catch{try{return e.focus(),!0}catch{return!1}}}function pl(e,t){if(!e||!t||!e.querySelector)return!1;var r=e.querySelector('[data-rte-ai-action="'+t+'"]');if(r&&!r.disabled&&r.focus)try{return r.focus({preventScroll:!0}),!0}catch{try{return r.focus(),!0}catch{}}return!1}function Pc(e,t){if(!e)return!1;var r=Lr(e);return r?pl(r,t)?!0:ya(r):!1}function hl(e){if(!e)return"";var t=Rr();return e.status==="pending"&&t&&t.suggestion&&t.suggestion.id===e.id?"redo":e.status==="pending"?"accept":"review"}function bn(e,t){var r=me(e);if(!r)return!1;var i=Lr(e),a=hl(r),n=t||a;if(i&&(pl(i,n)||a&&a!==n&&pl(i,a)))return!0;var l=a&&a!==n?a:n;return wi(e,{focusPanel:!0,focusAction:l==="review"?"":l})}function Gs(e,t,r,i){if(!e)return null;if(!r)return t&&t.parentNode&&t.parentNode.removeChild(t),null;t||(t=document.createElement("span"),t.className="rte-ai-inline-preview-remote"),t.textContent=r>1?r+" shared updates":"Shared update",t.setAttribute("aria-label","Shared AI review updates");var a=i&&i.parentNode===e?i:e.querySelector?e.querySelector(".rte-ai-inline-preview-actions"):null;return a&&a.parentNode===e?a.nextSibling!==t&&(a.nextSibling?e.insertBefore(t,a.nextSibling):e.appendChild(t)):t.parentNode!==e&&e.appendChild(t),t}function $i(){s.__aiBindInlinePreviewEventHandlers&&s.__aiBindInlinePreviewEventHandlers();var e=s.getEditable?s.getEditable():null;if(!e||!e.querySelectorAll)return!1;for(var t=e.querySelectorAll("[data-rte-ai-suggestion-id]"),r=ci(),i=Rr(),a=0;a<t.length;a++){var n=t[a].getAttribute("data-rte-ai-suggestion-id")||"",l=me(n),u=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-current"):null,d=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-opened"):null,p=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-type"):null,m=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-language"):null,w=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-scope"):null,y=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-remote"):null,v=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-queue"):null,h=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-transition"):null,_=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-followup"):null,b=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-glance"):null,H=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-reason"):null,x=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-plan"):null,R=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-undo"):null,C=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-undo-next"):null,P=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-redo"):null,T=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-redo-next"):null,D=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-shortcuts"):null,F=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-launch"):null,M=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-focus"):null,V=t[a].querySelector?t[a].querySelector('[data-rte-ai-action="review"]'):null,ve=t[a].querySelector?t[a].querySelector('[data-rte-ai-action="previous"]'):null,X=t[a].querySelector?t[a].querySelector('[data-rte-ai-action="next"]'):null,j=t[a].querySelector?t[a].querySelector('[data-rte-ai-action="accept"]'):null,se=t[a].querySelector?t[a].querySelector('[data-rte-ai-action="reject"]'):null,ee=t[a].querySelector?t[a].querySelector('[data-rte-ai-action="undo"]'):null,oe=t[a].querySelector?t[a].querySelector('[data-rte-ai-action="redo"]'):null,Y=t[a].querySelector?t[a].querySelector('[data-rte-ai-action="shared-seen"]'):null,G=Jt(n),N=!!(s.__aiReviewEmptyPreviewSuggestionId&&n===s.__aiReviewEmptyPreviewSuggestionId),Te=!!(!N&&s.__aiRecentlyOpenedQueueSuggestionId&&n===s.__aiRecentlyOpenedQueueSuggestionId),ce=!N&&r?Pt(r):null,W=!N&&r?wa(r):"",Ce=N?[]:fl(1),ke=Ce.length?Ce[0]:null,ye=!!(!N&&i&&i.suggestion&&i.suggestion.id===n&&l&&l.status==="pending"),Ee=ye?qt(i):null,Ze=ye?mn(i):"",gt=ye?vl(1):[],De=gt.length?gt[0]:null,ze=N?Ge(l,z()):"",_e=Ge(l,z())||Ge(l,""),J=N?"Open this AI review queue"+(_e?" and focus "+_e:""):"Open this AI suggestion in review"+(_e?" and focus "+_e:""),$=Nt(n),je=N?{index:0,total:0}:Mn($,n),et=N?[]:Ve($),B=N?null:ka(et,s.__aiActiveSuggestionId,l),K=N?null:gi(et,s.__aiActiveSuggestionId,l),ne=N?null:Bi(l),Ae=N?null:Ta(ne),I=mi(l),be=N?"":au(n),Q=N?"":aa(n),te=be?"Previous AI review item":"No previous AI review item in the current queue",xe=Q?"Next AI review item":"No next AI review item in the current queue";if(s.__aiActiveSuggestionId&&n===s.__aiActiveSuggestionId){t[a].classList.add("is-review-active"),t[a].classList.toggle("is-review-preview",N),t[a].classList.toggle("is-queue-opened",Te),N?(t[a].setAttribute("role","button"),t[a].removeAttribute("aria-current"),t[a].setAttribute("aria-keyshortcuts","Enter Space"),t[a].setAttribute("tabindex","0"),t[a].title=ds(l)):(t[a].setAttribute("role","group"),t[a].setAttribute("aria-current","step"),t[a].setAttribute("aria-keyshortcuts",(G?"ArrowLeft ArrowRight Home End J K A R G Enter Space":"ArrowLeft ArrowRight Home End J K A R Enter Space")+(ce?" U":"")+(ye?" Shift+U":"")),t[a].setAttribute("tabindex","0"),t[a].title=Mc({suggestion:l,sharedUpdateCount:G,undoInlineContext:ce,redoInlineContext:Ee}));var Se=bi(l,"accept",$)||{text:"Accept",label:"Accept this AI change"},Le=bi(l,"reject",$)||{text:"Reject",label:"Reject this AI change"},Ue=Se.label,ue=Le.label,Tt=W||"Undo the last AI review decision",Qe=Ze||"Redo the last AI review decision",Lt={isPreviewTarget:N,sharedUpdateCount:G,undoInlineContext:ce,redoInlineContext:Ee};$r(V,N?"Open queue":"Review",J),Aa(ve,!be,te),Aa(X,!Q,xe),$r(j,Se.text,Ue),$r(se,Le.text,ue),vi(V,J,Lt),vi(ve,te,Lt),vi(X,xe,Lt),vi(j,Ue,Lt),vi(se,ue,Lt);var it=_l(t[a],"recovery");if(ce?(ee||(ee=document.createElement("button"),ee.type="button",ee.className="rte-ai-inline-preview-button is-undo",ee.setAttribute("data-rte-ai-action","undo"),it&&it.appendChild(ee)),$r(ee,ce.actionLabel,Tt),vi(ee,Tt,Lt)):ee&&ee.parentNode&&(ee.parentNode.removeChild(ee),ee=null),ye&&Ee?(oe||(oe=document.createElement("button"),oe.type="button",oe.className="rte-ai-inline-preview-button is-redo",oe.setAttribute("data-rte-ai-action","redo"),it&&it.appendChild(oe)),$r(oe,Ee.actionLabel,Qe),vi(oe,Qe,Lt)):oe&&oe.parentNode&&(oe.parentNode.removeChild(oe),oe=null),!u){u=document.createElement("span"),u.className="rte-ai-inline-preview-current";var hr=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-actions"):null;hr&&hr.nextSibling?t[a].insertBefore(u,hr.nextSibling):t[a].appendChild(u)}if(u.classList.toggle("is-preview-target",N),u.textContent=N?"Next queue":"Current",u.setAttribute("aria-label",N?"Next AI review queue target":"Current AI review item"),Te?(d||(d=document.createElement("span"),d.className="rte-ai-inline-preview-opened",u&&u.nextSibling?t[a].insertBefore(d,u.nextSibling):t[a].appendChild(d)),d.textContent="Queue opened",d.setAttribute("aria-label","AI review queue opened")):d&&d.parentNode&&d.parentNode.removeChild(d),N)if(F||(F=document.createElement("span"),F.className="rte-ai-inline-preview-launch",u&&u.nextSibling?t[a].insertBefore(F,u.nextSibling):t[a].appendChild(F)),F.textContent=cs(l),F.setAttribute("aria-hidden","true"),ze){if(!M){M=document.createElement("span"),M.className="rte-ai-inline-preview-focus";var lr=F||u;lr&&lr.nextSibling?t[a].insertBefore(M,lr.nextSibling):t[a].appendChild(M)}M.textContent="Focus "+ze,M.setAttribute("aria-label","Queue opens on "+ze)}else M&&M.parentNode&&M.parentNode.removeChild(M);else F&&F.parentNode&&F.parentNode.removeChild(F),M&&M.parentNode&&M.parentNode.removeChild(M);if(l&&l.suggestionType&&Be(l.suggestionType)!=="other"?(p||(p=document.createElement("span"),p.className="rte-ai-inline-preview-type",u&&u.nextSibling?t[a].insertBefore(p,u.nextSibling):t[a].appendChild(p)),p.textContent=Me(l.suggestionType),p.setAttribute("aria-label","AI suggestion type")):p&&p.parentNode&&p.parentNode.removeChild(p),l&&l.language){if(!m){m=document.createElement("span"),m.className="rte-ai-inline-preview-language";var mt=p||u;mt&&mt.nextSibling?t[a].insertBefore(m,mt.nextSibling):t[a].appendChild(m)}m.textContent=ot(l.language),m.setAttribute("aria-label","AI suggestion language")}else m&&m.parentNode&&m.parentNode.removeChild(m);var Pe=Nr(l);if(Pe){if(!w){w=document.createElement("span"),w.className="rte-ai-inline-preview-scope";var qe=m||p||u;qe&&qe.nextSibling?t[a].insertBefore(w,qe.nextSibling):t[a].appendChild(w)}w.textContent=Pe,w.setAttribute("aria-label","AI suggestion scope")}else w&&w.parentNode&&w.parentNode.removeChild(w);y=Gs(t[a],y,G,w||m||p||u||(t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-actions"):null));var Vt=_l(t[a],"recovery");if(G?(Y||(Y=document.createElement("button"),Y.type="button",Y.className="rte-ai-inline-preview-button is-shared",Y.setAttribute("data-rte-ai-action","shared-seen"),Vt&&Vt.appendChild(Y)),Y.textContent="Got it",Y.setAttribute("aria-label","Clear shared AI review update notice"),Y.title="Clear shared AI review update notice",vi(Y,"Clear shared AI review update notice",Lt)):Y&&Y.parentNode&&(Y.parentNode.removeChild(Y),Y=null),Ns(t[a],"recovery",!!(ce||ye&&Ee||G)),wl(t[a],{suggestion:l,isPreviewTarget:N,sharedUpdateCount:G,undoInlineContext:ce,redoInlineContext:Ee,queueTransitionData:K,undoInlineSummaryText:W,redoInlineSummaryText:Ze}),yl(t[a],{suggestion:l,isPreviewTarget:N,sharedUpdateCount:G,undoInlineContext:ce,redoInlineContext:Ee,queueTransitionData:K,undoInlineSummaryText:W,redoInlineSummaryText:Ze}),Js(t[a],{suggestion:l,isPreviewTarget:N,sharedUpdateCount:G,undoInlineContext:ce,redoInlineContext:Ee}),je.total&&je.index){if(!v){v=document.createElement("span"),v.className="rte-ai-inline-preview-queue";var _t=y||w||m||p||u||(t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-current"):null);if(_t&&_t.nextSibling)t[a].insertBefore(v,_t.nextSibling);else if(_t)t[a].appendChild(v);else{var bt=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-actions"):null;bt&&bt.nextSibling?t[a].insertBefore(v,bt.nextSibling):t[a].appendChild(v)}}v.textContent="Item "+je.index+" of "+je.total,v.setAttribute("aria-label","Current AI review queue position")}else v&&v.parentNode&&v.parentNode.removeChild(v);if(K){if(!h){h=document.createElement("span"),h.className="rte-ai-inline-preview-transition";var Di=v||y||w||m||p||u;Di&&Di.nextSibling?t[a].insertBefore(h,Di.nextSibling):t[a].appendChild(h)}if(h.textContent=K.statusLabel+" - "+K.queueLabel,h.setAttribute("aria-label",K.title+". "+K.detail+" "+Wr(K)),K.followupTitle){if(!_){_=document.createElement("span"),_.className="rte-ai-inline-preview-followup";var sr=h||v||y||w||m||p||u;sr&&sr.nextSibling?t[a].insertBefore(_,sr.nextSibling):t[a].appendChild(_)}_.textContent=K.followupTitle,_.setAttribute("aria-label",K.followupTitle+". "+K.followupDetail)}else _&&_.parentNode&&_.parentNode.removeChild(_)}else h&&h.parentNode&&h.parentNode.removeChild(h),_&&_.parentNode&&_.parentNode.removeChild(_);if(ce){if(!R){R=document.createElement("span"),R.className="rte-ai-inline-preview-undo";var Zr=_||h||v||y||w||m||p||u;Zr&&Zr.nextSibling?t[a].insertBefore(R,Zr.nextSibling):t[a].appendChild(R)}R.textContent=ce.actionLabel,R.setAttribute("aria-label",W)}else R&&R.parentNode&&R.parentNode.removeChild(R);if(ke){if(!C){C=document.createElement("span"),C.className="rte-ai-inline-preview-undo-next";var Ke=R||v||y||w||m||p||u;Ke&&Ke.nextSibling?t[a].insertBefore(C,Ke.nextSibling):t[a].appendChild(C)}C.textContent="Then "+ke.label,C.setAttribute("aria-label","Undo after this: "+ke.detail)}else C&&C.parentNode&&C.parentNode.removeChild(C);if(ye&&Ee){if(!P){P=document.createElement("span"),P.className="rte-ai-inline-preview-redo";var Er=C||R||v||y||w||m||p||u;Er&&Er.nextSibling?t[a].insertBefore(P,Er.nextSibling):t[a].appendChild(P)}P.textContent=Ee.actionLabel,P.setAttribute("aria-label",Ze)}else P&&P.parentNode&&P.parentNode.removeChild(P);if(De){if(!T){T=document.createElement("span"),T.className="rte-ai-inline-preview-redo-next";var Wt=P||C||R||v||y||w||m||p||u;Wt&&Wt.nextSibling?t[a].insertBefore(T,Wt.nextSibling):t[a].appendChild(T)}T.textContent="Then "+De.label,T.setAttribute("aria-label","Redo after this: "+De.detail)}else T&&T.parentNode&&T.parentNode.removeChild(T);if(N){if(!D){D=document.createElement("span"),D.className="rte-ai-inline-preview-shortcuts";var or=T||P||C||R||v||y||w||m||p||u;or&&or.nextSibling?t[a].insertBefore(D,or.nextSibling):t[a].appendChild(D)}D.textContent=tn(l),D.setAttribute("aria-label","Inline queue preview shortcut")}else if(!D){D=document.createElement("span"),D.className="rte-ai-inline-preview-shortcuts";var ei=T||P||C||R||v||y||w||m||p||u;ei&&ei.nextSibling?t[a].insertBefore(D,ei.nextSibling):t[a].appendChild(D)}var at={isPreviewTarget:N,sharedUpdateCount:G,undoInlineContext:ce,redoInlineContext:Ee,suggestion:l},jt=Ji(at);D.id=jc(t[a]),Vi(D,N?"preview":"wrapper",at),Oc(t[a],D,at),di(V,t[a],D,"review",at),di(ve,t[a],D,"previous",at),di(X,t[a],D,"next",at),di(j,t[a],D,"accept",at),di(se,t[a],D,"reject",at),di(ee,t[a],D,"undo",at),di(oe,t[a],D,"redo",at),di(Y,t[a],D,"shared-seen",at);var gr=t[a].ownerDocument?t[a].ownerDocument.activeElement:null,yi=gr&&t[a].contains(gr)&&gr.getAttribute&&gr.getAttribute("data-rte-ai-action")||"";Vi(D,N?"preview":yi||"wrapper",at),Xs(t[a],l),Sl(t[a],l),Tl(t[a],Ae),H=Al(t[a],H,l),x=Vs(t[a],x,l),D=xl(t[a],D),t[a].setAttribute("aria-label",el(l,{isCurrent:!N,isPreviewTarget:N,queueOpened:Te,glanceLabels:ne?ne.pills.map(function(yr){return yr.text}):[],glanceDetail:ne?ne.detail:"",compareLabel:"Proposed edit. Current and suggested text.",reasonText:I,focusLabel:jt,positionLabel:je.total&&je.index?"Item "+je.index+" of "+je.total:"",transitionLabel:K?K.statusLabel+". "+K.queueLabel+". "+Wr(K):"",followupLabel:K&&K.followupTitle?K.followupTitle+". "+K.followupDetail:"",remoteUpdateCount:G,undoLabel:W,undoNextLabel:ke?"Undo after this: "+ke.detail:"",redoLabel:Ze,redoNextLabel:De?"Redo after this: "+De.detail:""}))}else{t[a].classList.remove("is-review-active"),t[a].classList.remove("is-review-preview"),t[a].classList.remove("is-queue-opened"),t[a].setAttribute("role","group"),t[a].removeAttribute("aria-current"),t[a].removeAttribute("aria-keyshortcuts"),t[a].setAttribute("tabindex","-1"),t[a].removeAttribute("title"),t[a].onfocus=null,t[a].onfocusout=null,Fs(t[a]),Sl(t[a],l),Tl(t[a],Ae),H=Al(t[a],H,l),x=Vs(t[a],x,l),t[a].setAttribute("aria-label",el(l,{remoteUpdateCount:G,glanceLabels:ne?ne.pills.map(function(yr){return yr.text}):[],glanceDetail:ne?ne.detail:"",compareLabel:"Proposed edit. Current and suggested text.",reasonText:I,focusLabel:_e,queueRoleLabel:B?B.roleLabel:"",queueRoleDetail:B?B.detail:"",transitionLabel:K?K.title+". "+K.statusLabel+". "+K.queueLabel+". "+Wr(K):"",followupLabel:K&&K.followupTitle?K.followupTitle+". "+K.followupDetail:""}));var mr=Nt(n),Mt=bi(l,"accept",mr)||{text:"Accept",label:"Accept this AI change"},ti=bi(l,"reject",mr)||{text:"Reject",label:"Reject this AI change"};if($r(V,"Review",J),Aa(ve,!be,te),Aa(X,!Q,xe),K&&/queue state/i.test(K.previewLabel||"")&&Aa(X,!0,"No next AI review item in the current queue"),$r(j,Mt.text,Mt.label),$r(se,ti.text,ti.label),pi(V),pi(ve),pi(X),pi(j),pi(se),pi(ee),pi(oe),pi(Y),fi(V),fi(ve),fi(X),fi(j),fi(se),fi(ee),fi(oe),fi(Y),ee&&ee.parentNode&&ee.parentNode.removeChild(ee),oe&&oe.parentNode&&oe.parentNode.removeChild(oe),Y&&Y.parentNode&&Y.parentNode.removeChild(Y),Ns(t[a],"recovery",!1),wl(t[a],{suggestion:l,isPreviewTarget:N,sharedUpdateCount:G,queueTransitionData:K}),yl(t[a],{suggestion:l,isPreviewTarget:N,sharedUpdateCount:G,queueTransitionData:K}),Js(t[a],{suggestion:l,isPreviewTarget:N,sharedUpdateCount:G}),u&&u.parentNode&&u.parentNode.removeChild(u),d&&d.parentNode&&d.parentNode.removeChild(d),F&&F.parentNode&&F.parentNode.removeChild(F),p&&p.parentNode&&p.parentNode.removeChild(p),m&&m.parentNode&&m.parentNode.removeChild(m),w&&w.parentNode&&w.parentNode.removeChild(w),y=Gs(t[a],y,G,t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-actions"):null),!N&&_e){if(!M){M=document.createElement("span"),M.className="rte-ai-inline-preview-focus";var Pr=y||w||m||p||u;Pr&&Pr.nextSibling?t[a].insertBefore(M,Pr.nextSibling):t[a].appendChild(M)}M.textContent="Focus "+_e,M.setAttribute("aria-label","Review opens on "+_e)}else M&&M.parentNode&&(M.parentNode.removeChild(M),M=null);if(!N&&ne&&ne.pills&&ne.pills.length){if(!b){b=document.createElement("span"),b.className="rte-ai-inline-preview-glance";var qr=w||p||u;qr&&qr.nextSibling?t[a].insertBefore(b,qr.nextSibling):t[a].appendChild(b)}for(;b.firstChild;)b.removeChild(b.firstChild);for(var Ot=0;Ot<ne.pills.length;Ot++){var ct=ne.pills[Ot];!ct||!ct.text||ct.kind==="scope"||o(b,"span","","rte-ai-review-item-glance-pill is-"+ct.kind,ct.text)}!b.childNodes.length&&b.parentNode&&(b.parentNode.removeChild(b),b=null)}else b&&b.parentNode&&(b.parentNode.removeChild(b),b=null);if(!N&&B&&B.role!=="current"){if(!v){v=document.createElement("span"),v.className="rte-ai-inline-preview-queue";var Bt=M||y||b||w||m||p||u;Bt&&Bt.nextSibling?t[a].insertBefore(v,Bt.nextSibling):t[a].appendChild(v)}v.textContent=B.roleLabel+" - "+B.queueLabel,v.setAttribute("aria-label",B.detail)}else v&&v.parentNode&&(v.parentNode.removeChild(v),v=null);if(!N&&K){if(!h){h=document.createElement("span"),h.className="rte-ai-inline-preview-transition";var ri=v||M||y||b||w||m||p||u;ri&&ri.nextSibling?t[a].insertBefore(h,ri.nextSibling):t[a].appendChild(h)}if(h.textContent=K.statusLabel,h.setAttribute("aria-label",K.title+". "+K.detail+" "+Wr(K)),K.followupTitle){if(!_){_=document.createElement("span"),_.className="rte-ai-inline-preview-followup";var ur=h||v||M||y||w||m||p||u;ur&&ur.nextSibling?t[a].insertBefore(_,ur.nextSibling):t[a].appendChild(_)}_.textContent=K.followupTitle,_.setAttribute("aria-label",K.followupTitle+". "+K.followupDetail)}else _&&_.parentNode&&(_.parentNode.removeChild(_),_=null)}else h&&h.parentNode&&(h.parentNode.removeChild(h),h=null),_&&_.parentNode&&(_.parentNode.removeChild(_),_=null);R&&R.parentNode&&R.parentNode.removeChild(R),C&&C.parentNode&&C.parentNode.removeChild(C),P&&P.parentNode&&P.parentNode.removeChild(P),T&&T.parentNode&&T.parentNode.removeChild(T),D&&D.parentNode&&D.parentNode.removeChild(D)}s.__aiActiveSuggestionId!==n&&!N&&((!D||!D.parentNode)&&(D=document.createElement("span"),D.className="rte-ai-inline-preview-shortcuts",t[a].appendChild(D)),Vi(D,"wrapper",{suggestion:l,isPreviewTarget:N,sharedUpdateCount:G}),D=xl(t[a],D));var dt=!0,_r=[p,w,v,h,_,b,M,y];N&&_r.push(u,d,F);for(var Ir=0;Ir<_r.length;Ir++)_r[Ir]&&_r[Ir].style&&(_r[Ir].style.display=dt?"none":"");var br=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-compare"):null,wr=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-actions"):null;t[a].style&&(t[a].style.display=dt?"flex":"",t[a].style.flexDirection=dt?"column":"",t[a].style.cursor=N?"pointer":""),br&&br.style&&(br.style.order=dt?"1":""),wr&&wr.style&&(wr.style.order=dt?"2":"",wr.style.display=N?"none":"")}return!0}function $r(e,t,r){return e?(typeof t=="string"&&t.length&&(e.textContent=t),r&&(e.setAttribute("aria-label",r),e.title=r),!0):!1}function qc(e,t){if(t=t||{},t.isPreviewTarget)return"Enter Space";switch(e){case"previous":return"Enter Space K ArrowLeft";case"next":return"Enter Space J ArrowRight";case"accept":return"Enter Space A";case"reject":return"Enter Space R";case"undo":return t.undoInlineContext?"Enter Space U":"Enter Space";case"redo":return t.redoInlineContext?"Enter Space Shift+U":"Enter Space";case"shared-seen":return t.sharedUpdateCount?"Enter Space G":"Enter Space";default:return"Enter Space"}}function Ic(e,t,r){r=r||{};var i=t||"";if(!i)return i;if(i=i.replace(/\.$/,""),r.isPreviewTarget)return i+". Enter or Space activates this action.";var a=Kt(r.suggestion);switch(i+=". Enter or Space activates this action.",e){case"previous":i+=" K or Left moves to the previous review item.";break;case"next":i+=" J or Right moves to the next review item.";break;case"accept":i+=" A uses "+a.acceptLabel+".";break;case"reject":i+=" R uses "+a.rejectLabel+".";break;case"undo":r.undoInlineContext&&(i+=" U "+r.undoInlineContext.shortcutLabel+".");break;case"redo":r.redoInlineContext&&(i+=" Shift+U "+r.redoInlineContext.shortcutLabel+".");break;case"shared-seen":r.sharedUpdateCount&&(i+=" G clears shared.");break}return i}function Us(e){if(e=e||{},e.isPreviewTarget)return tn(e.suggestion);var t=Kt(e.suggestion),r=Ji(e),i="Enter focus "+r+" - A "+t.acceptHint+" - R "+t.rejectHint+" - J/K move - Home/End jump";return e.sharedUpdateCount&&(i+=" - G clear shared"),e.undoInlineContext&&(i+=" - U "+e.undoInlineContext.shortcutLabel),e.redoInlineContext&&(i+=" - Shift+U "+e.redoInlineContext.shortcutLabel),i}function Mc(e){if(e=e||{},e.isPreviewTarget)return ds(e.suggestion);var t=Kt(e.suggestion),r=Ji(e),i="Shortcuts: J or Right next, K or Left previous, Home/End jump, Enter focus "+r+", A "+t.acceptHint+", R "+t.rejectHint;return e.sharedUpdateCount&&(i+=", G clear shared"),e.undoInlineContext&&(i+=", U "+e.undoInlineContext.shortcutLabel),e.redoInlineContext&&(i+=", Shift+U "+e.redoInlineContext.shortcutLabel),i}function gl(e){if(e=e||{},e.isPreviewTarget)return"review";var t=e.suggestion;if(!t)return"";var r=e.preferredAction||z();if((r==="accept"||r==="reject")&&t.status==="pending")return r;if(r==="undo"&&e.undoInlineContext)return"undo";if(r==="redo"&&e.redoInlineContext)return"redo";if(r==="review")return"review";if(r==="shared-seen"&&e.sharedUpdateCount)return"shared-seen";var i=e.defaultActionName||hl(t);return i==="redo"&&e.redoInlineContext?"redo":i==="accept"?"accept":"review"}function Hc(e){switch(e){case"accept":case"reject":return"decision";case"undo":case"redo":case"shared-seen":return"recovery";case"review":return"review";default:return""}}function Ji(e){e=e||{};var t=e.suggestion;if(!t)return"Review";if(e.isPreviewTarget)return"Open queue";var r=Kt(t),i=gl(e);return i==="accept"?r.acceptLabel:i==="reject"?r.rejectLabel:i==="undo"&&e.undoInlineContext?e.undoInlineContext.actionLabel||"Undo":i==="redo"&&e.redoInlineContext?e.redoInlineContext.actionLabel||"Redo":i==="review"?"Review":i==="shared-seen"&&e.sharedUpdateCount?"Clear shared":"Review"}function Dc(e,t){if(t=t||{},t.isPreviewTarget)return tn(t.suggestion);var r="",i=Kt(t.suggestion),a=i.acceptLabel,n=i.rejectLabel,l=t.reviewFocusLabel||Ge(t.suggestion,z())||Ge(t.suggestion,"");switch(e){case"review":r="Enter focus "+(l||"Review")+" - J/K move - Home/End jump - A "+i.acceptHint+" - R "+i.rejectHint;break;case"previous":r="Enter previous - J/K move - Home/End jump - A "+i.acceptHint+" - R "+i.rejectHint;break;case"next":r="Enter next - J/K move - Home/End jump - A "+i.acceptHint+" - R "+i.rejectHint;break;case"accept":r="Enter "+a+" - R "+i.rejectHint+" - J/K move - Home/End jump";break;case"reject":r="Enter "+n+" - A "+i.acceptHint+" - J/K move - Home/End jump";break;case"undo":r="Enter undo - A "+i.acceptHint+" - R "+i.rejectHint+" - J/K move - Home/End jump";break;case"redo":r="Enter redo - A "+i.acceptHint+" - R "+i.rejectHint+" - J/K move - Home/End jump";break;case"shared-seen":r="Enter clear shared - A "+i.acceptHint+" - R "+i.rejectHint+" - J/K move - Home/End jump";break;default:return Us(t)}return t.undoInlineContext&&(r+=" - U "+t.undoInlineContext.shortcutLabel),t.sharedUpdateCount&&e!=="shared-seen"&&(r+=" - G clear shared"),t.redoInlineContext&&(r+=" - Shift+U "+t.redoInlineContext.shortcutLabel),r}function jc(e){return e?(e.__rteAiInlineShortcutDisplayId||(e.__rteAiInlineShortcutDisplayId="rte-ai-inline-shortcuts-"+String(Math.floor(Math.random()*1e9))),e.__rteAiInlineShortcutDisplayId):""}function wn(e,t){if(!e||!e.setAttribute||!t)return!1;var r=t.id||"";return r?(e.setAttribute("aria-describedby",r),!0):!1}function Fs(e){return!e||!e.removeAttribute?!1:(e.removeAttribute("aria-describedby"),!0)}function ml(e,t,r){if(!e)return!1;for(;e.firstChild;)e.removeChild(e.firstChild);if(!t&&!r)return!0;var i=e.ownerDocument||document;if(t){var a=i.createElement("span");a.className="rte-ai-inline-preview-shortcuts-title",a.innerText=t,e.appendChild(a)}if(!r)return!0;var n=i.createElement("span");n.className="rte-ai-inline-preview-shortcuts-body",e.appendChild(n);for(var l=String(r||"").split(/(\s+\xb7\s+|\s+-\s+)/),u=0;u<l.length;u++){var d=l[u];if(d){if(/^\s+[\xb7-]\s+$/.test(d)){var p=i.createElement("span");p.className="rte-ai-inline-preview-shortcuts-separator",p.innerText=d.replace(/^\s+|\s+$/g,""),n.appendChild(p);continue}var m=i.createElement("span");m.className="rte-ai-inline-preview-shortcuts-segment";var w=d.replace(/^\s+|\s+$/g,""),y=w.indexOf(" ");if(y>0){var v=i.createElement("span");v.className="rte-ai-inline-preview-shortcuts-key",v.innerText=w.substring(0,y),m.appendChild(v),m.appendChild(i.createTextNode(" "));var h=i.createElement("span");h.className="rte-ai-inline-preview-shortcuts-copy",h.innerText=w.substring(y+1),m.appendChild(h)}else m.innerText=w;n.appendChild(m)}}return!0}function Vi(e,t,r){return e?(r=r||{},e.classList.remove("is-action"),e.classList.toggle("is-preview",t==="preview"),t==="preview"?(ml(e,"Queue shortcut",tn(r.suggestion)),e.setAttribute("aria-label","Inline queue preview shortcut"),!0):t&&t!=="wrapper"?(e.classList.add("is-action"),ml(e,"Keyboard guide",Dc(t,r)),e.setAttribute("aria-label","Inline AI review action shortcuts"),!0):(ml(e,"Keyboard guide",Us(r)),e.setAttribute("aria-label","Inline AI review shortcuts"),!0)):!1}function Oc(e,t,r){return e?(wn(e,t),e.onfocus=function(){wn(e,t),Vi(t,r&&r.isPreviewTarget?"preview":"wrapper",r)},e.onfocusout=function(){var i=e,a=t,n=r||{};window.setTimeout(function(){var l=i.ownerDocument||document;i.contains(l.activeElement)||Vi(a,n.isPreviewTarget?"preview":"wrapper",n)},0)},!0):!1}function di(e,t,r,i,a){return e?(wn(e,r),e.onfocus=function(){wn(e,r),Vi(r,i,a)},!0):!1}function fi(e){return e?(e.onfocus=null,Fs(e),!0):!1}function vi(e,t,r){if(!e)return!1;var i=e.getAttribute&&e.getAttribute("data-rte-ai-action")||"";return e.setAttribute("aria-keyshortcuts",qc(i,r)),e.title=Ic(i,t,r),!0}function pi(e){return e?(e.removeAttribute("aria-keyshortcuts"),!0):!1}function Aa(e,t,r){return e?(e.disabled=!!t,e.setAttribute("aria-disabled",t?"true":"false"),r&&(e.setAttribute("aria-label",r),e.title=r),t?e.classList.add("is-disabled"):e.classList.remove("is-disabled"),!0):!1}function Xe(e,t){t=t||{},s.__aiActiveSuggestionId=e||null,s.__aiPreviewState=e?me(e):null,t.preserveEmptyPreview?s.__aiReviewEmptyPreviewSuggestionId=s.__aiActiveSuggestionId:s.__aiReviewEmptyPreviewSuggestionId=null,$i()}function hi(){return s.__aiActiveSuggestionId?me(s.__aiActiveSuggestionId):s.__aiPreviewState||null}function xa(){for(var e=Ne(),t=!1,r=!1,i=0;i<e.length;i++)e[i].status==="pending"&&!Lr(e[i].id)&&(e[i].status="stale",e[i].decidedAt=e[i].decidedAt||new Date().getTime(),Ki("suggestion-stale",e[i]),r=!0),s.__aiActiveSuggestionId&&e[i].id===s.__aiActiveSuggestionId&&e[i].status==="pending"&&(t=!0);t||Xe(null),r&&yt()}function fr(){xa()}function Ye(e,t){var r=E(e),i=t||90;return r.length<=i?r:r.substring(0,Math.max(0,i-3)).replace(/\s+\S*$/,"")+"..."}function Sa(e){switch(e){case"accepted":return c.__aiT?c.__aiT("air_status_accepted","Accepted"):"Accepted";case"rejected":return c.__aiT?c.__aiT("air_status_rejected","Rejected"):"Rejected";case"stale":return c.__aiT?c.__aiT("air_status_stale","Needs refresh"):"Needs refresh";default:return c.__aiT?c.__aiT("air_status_pending","Pending"):"Pending"}}function yn(e,t,r){var i=!r&&e==="recovery"?' style="display:none"':"";return'<span class="rte-ai-inline-preview-action-group is-'+e+'" data-rte-ai-inline-action-group="'+e+'" data-rte-ai-inline-action-group-label="'+pe(t)+'" data-rte-ai-inline-action-group-current="false"'+i+' role="group" aria-label="'+pe(t)+' actions"><span class="rte-ai-inline-preview-action-group-header"><span class="rte-ai-inline-preview-action-group-title">'+pe(t)+'</span><span class="rte-ai-inline-preview-action-group-badge" style="display:none"></span></span><span class="rte-ai-inline-preview-action-group-detail"></span><span class="rte-ai-inline-preview-action-group-body">'+(r||"")+"</span></span>"}function _l(e,t){if(!e||!e.querySelector)return null;if(t){var r=e.querySelector(".rte-ai-inline-preview-action-group.is-"+t+" .rte-ai-inline-preview-action-group-body");if(r)return r}return e.querySelector(".rte-ai-inline-preview-actions")}function Ns(e,t,r){if(!(!e||!e.querySelector||!t)){var i=e.querySelector(".rte-ai-inline-preview-action-group.is-"+t);i&&(i.style.display=r?"":"none")}}function Ks(e){if(e=e||{},e.isPreviewTarget)return"review";var t=e.suggestion;return t?Hc(gl(e)):""}function Gc(e){switch(e){case"review":return"Open";case"move":return"Move";case"decision":return"Decide";case"recovery":return"Recover";default:return""}}function zs(e,t){var r=["review","move","decision","recovery"],i=r.indexOf(e);if(i===-1)return r.length+1;var a=r.indexOf(t);if(a===-1)return i+1;if(e===t)return 1;for(var n=2,l=0;l<r.length;l++)if(r[l]!==t){if(r[l]===e)return n;n++}return i+1}function Qs(e,t,r){var i;switch(e){case"review":i=["review"];break;case"move":i=["previous","next"];break;case"decision":i=["accept","reject"];break;case"recovery":i=["shared-seen","undo","redo"];break;default:i=[];break}var a=i.indexOf(t);if(a===-1)return i.length+1;if(!r)return a+1;var n=i.indexOf(r);if(n===-1)return a+1;if(t===r)return 1;for(var l=2,u=0;u<i.length;u++)if(i[u]!==r){if(i[u]===t)return l;l++}return a+1}function Uc(e,t){if(t=t||{},t.isPreviewTarget)return e==="review"?"Open the next review queue from this handoff surface.":"";var r=t.suggestion;if(!r)return"";var i=t.queueTransitionData||null;if(!i&&r){var a=Nt(r.id);i=gi(Ve(a),s.__aiActiveSuggestionId,r)}switch(e){case"review":return"Reopen this suggestion in the current review lane.";case"move":return"Jump earlier or later in this queue before deciding.";case"decision":return i&&i.detail?i.detail:"Apply or dismiss this AI change.";case"recovery":return t.redoInlineContext&&t.redoInlineSummaryText?t.redoInlineSummaryText:t.undoInlineContext&&t.undoInlineSummaryText?t.undoInlineSummaryText:t.sharedUpdateCount?"Clear collaboration updates and keep reviewing this suggestion.":"";default:return""}}function $s(e){if(e=e||{},e.isPreviewTarget)return null;var t=e.suggestion;if(!t)return null;var r=Ks(e),i=Ji(e),a=Gc(r);if(!r||!i||!a)return null;var n=e.queueTransitionData||null;if(!n&&t.id){var l=Nt(t.id),u=Ve(l);n=gi(u,s.__aiActiveSuggestionId,t)}var d="";return r==="decision"&&n?d=n.statusLabel+". "+n.detail:r==="recovery"?e.preferredAction==="undo"&&e.undoInlineSummaryText?d=e.undoInlineSummaryText:e.preferredAction==="redo"&&e.redoInlineSummaryText?d=e.redoInlineSummaryText:e.sharedUpdateCount?d="Clear the shared update notice and continue reviewing this suggestion.":d="Recover from a recent AI review action without leaving this suggestion.":r==="review"?d="Open this suggestion in review and keep the current inline lane ready.":r==="move"&&(d="Move through the current queue before choosing a decision."),{title:"Action handoff",pills:[a+" lane","Enter focuses "+i],detail:d}}function bl(e){if(!e)return"";var t=[];if(e.title&&t.push(e.title),e.pills&&e.pills.length)for(var r=0;r<e.pills.length;r++)e.pills[r]&&t.push(e.pills[r]);return e.detail&&t.push(e.detail),fe(t)}function Fc(e){var t=$s({suggestion:e});if(!t)return"";var r='<span class="rte-ai-inline-preview-action-summary" aria-label="'+pe(bl(t))+'"><span class="rte-ai-inline-preview-action-summary-title">'+pe(t.title)+"</span>";if(t.pills&&t.pills.length){r+='<span class="rte-ai-inline-preview-action-summary-pills">';for(var i=0;i<t.pills.length;i++)t.pills[i]&&(r+='<span class="rte-ai-inline-preview-action-summary-pill">'+pe(t.pills[i])+"</span>");r+="</span>"}return t.detail&&(r+='<span class="rte-ai-inline-preview-action-summary-detail">'+pe(t.detail)+"</span>"),r+="</span>",r}function wl(e,t){if(!e||!e.querySelector)return null;var r=e.querySelector(".rte-ai-inline-preview-actions"),i=$s(t),a=r&&r.querySelector?r.querySelector(".rte-ai-inline-preview-action-summary"):null;if(!r||!i)return a&&a.parentNode&&a.parentNode.removeChild(a),r&&r.setAttribute("aria-label","AI suggestion actions"),null;var n=r.ownerDocument||document;for(a?r.firstChild!==a&&r.insertBefore(a,r.firstChild):(a=n.createElement("span"),a.className="rte-ai-inline-preview-action-summary",r.firstChild?r.insertBefore(a,r.firstChild):r.appendChild(a));a.firstChild;)a.removeChild(a.firstChild);if(a.setAttribute("aria-label",bl(i)),o(a,"span","","rte-ai-inline-preview-action-summary-title",i.title),i.pills&&i.pills.length)for(var l=o(a,"span","","rte-ai-inline-preview-action-summary-pills"),u=0;u<i.pills.length;u++)i.pills[u]&&o(l,"span","","rte-ai-inline-preview-action-summary-pill",i.pills[u]);return i.detail&&o(a,"span","","rte-ai-inline-preview-action-summary-detail",i.detail),r.setAttribute("aria-label","AI suggestion actions. "+bl(i)),a}function yl(e,t){if(!e||!e.querySelectorAll)return!1;t=t||{};for(var r=e.ownerDocument||document,i=e.querySelector?e.querySelector(".rte-ai-inline-preview-actions"):null,a=Ks(t),n=t.isPreviewTarget?"Open queue":Ji(t),l=n?"Enter: "+n:"",u=e.querySelectorAll(".rte-ai-inline-preview-action-group"),d=[],p=0;p<u.length;p++){var m=u[p];if(m){d.push(m);var w=m.getAttribute("data-rte-ai-inline-action-group")||"",y=m.getAttribute("data-rte-ai-inline-action-group-label")||"",v=m.querySelector?m.querySelector(".rte-ai-inline-preview-action-group-header"):null;v||(v=r.createElement("span"),v.className="rte-ai-inline-preview-action-group-header",m.firstChild?m.insertBefore(v,m.firstChild):m.appendChild(v));var h=v.querySelector?v.querySelector(".rte-ai-inline-preview-action-group-title"):null;h||(h=r.createElement("span"),h.className="rte-ai-inline-preview-action-group-title",v.appendChild(h)),h.textContent=y;var _=v.querySelector?v.querySelector(".rte-ai-inline-preview-action-group-badge"):null;_||(_=r.createElement("span"),_.className="rte-ai-inline-preview-action-group-badge",v.appendChild(_));var b=m.querySelector?m.querySelector(".rte-ai-inline-preview-action-group-detail"):null;if(!b){b=r.createElement("span"),b.className="rte-ai-inline-preview-action-group-detail";var H=m.querySelector?m.querySelector(".rte-ai-inline-preview-action-group-body"):null;H?m.insertBefore(b,H):m.appendChild(b)}var x=!!l&&!!a&&a===w,R=Uc(w,t);m.style.removeProperty("order"),m.setAttribute("data-rte-ai-inline-action-group-current",x?"true":"false"),m.classList.toggle("is-current-lane",x),x?(_.textContent=l,_.style.display="",_.setAttribute("aria-label","Current action lane. "+l)):(_.textContent="",_.style.display="none",_.removeAttribute("aria-label")),R?(b.textContent=R,b.style.display=""):(b.textContent="",b.style.display="none");var C=y?y+" actions":"AI suggestion actions";R&&(C=fe([C,R])),x&&l&&(C=fe([C,"Current lane",l])),m.setAttribute("aria-label",C)}}if(i&&d.length){d.sort(function(T,D){var F=T.getAttribute("data-rte-ai-inline-action-group")||"",M=D.getAttribute("data-rte-ai-inline-action-group")||"";return zs(F,a)-zs(M,a)});for(var P=0;P<d.length;P++)i.appendChild(d[P])}return!0}function Js(e,t){if(!e||!e.querySelectorAll)return!1;t=t||{};for(var r=gl(t),i={},a=e.querySelectorAll(".rte-ai-inline-preview-button[data-rte-ai-action]"),n=0;n<a.length;n++){var l=a[n];if(!(!l||!l.getAttribute)){var u=l.getAttribute("data-rte-ai-action")||"",d=l.closest?l.closest(".rte-ai-inline-preview-action-group"):null,p=d&&d.getAttribute&&d.getAttribute("data-rte-ai-inline-action-group")||"";p&&(i[p]||(i[p]=[]),i[p].push(l));var m=!!r&&u===r&&!l.disabled,w=(l.getAttribute("aria-label")||l.textContent||"").replace(/\.\s*Current Enter target\.$/i,""),y=(l.getAttribute("title")||w).replace(/\.\s*Current Enter target\.$/i,"");if(l.setAttribute("data-rte-ai-enter-target",m?"true":"false"),l.classList.toggle("is-enter-target",m),m){var v=u==="accept"?"A":u==="reject"?"R":"";l.setAttribute("aria-keyshortcuts",v?"Enter Space "+v:"Enter Space"),l.setAttribute("data-rte-ai-enter-target-label","Enter"),w&&!/current enter target/i.test(w)&&l.setAttribute("aria-label",fe([w,"Current Enter target."])),y&&!/enter or space activates this action/i.test(y)&&(y+=". Enter or Space activates this action",v&&(y+=". "+v+" uses "+(l.textContent||u)+".")),y&&!/current enter target/i.test(y)&&(l.title=fe([y,"Current Enter target."]))}else l.removeAttribute("data-rte-ai-enter-target-label"),w&&l.setAttribute("aria-label",w),y&&(l.title=y)}}for(var p in i)if(i.hasOwnProperty(p)){var h=_l(e,p),_=i[p];if(!(!h||!_||!_.length)){_.sort(function(x,R){var C=x.getAttribute("data-rte-ai-action")||"",P=R.getAttribute("data-rte-ai-action")||"";return Qs(p,C,r)-Qs(p,P,r)});for(var b=0;b<_.length;b++)h.appendChild(_[b])}}return!0}function Al(e,t,r){if(!e)return null;var i=e.querySelector?e.querySelector(".rte-ai-inline-preview-compare"):null,a=mi(r);if(!i||!a)return t&&t.parentNode&&t.parentNode.removeChild(t),null;if(!t||t.parentNode!==i){t&&t.parentNode&&t.parentNode.removeChild(t),t=document.createElement("span"),t.className="rte-ai-inline-preview-reason";var n=i.querySelector?i.querySelector(".rte-ai-inline-preview-old"):null,l=!n&&i.querySelector?i.querySelector(".rte-ai-inline-preview-new"):null,u=n||l;u?i.insertBefore(t,u):i.appendChild(t)}var d=t.querySelector?t.querySelector(".rte-ai-inline-preview-reason-label"):null,p=t.querySelector?t.querySelector(".rte-ai-inline-preview-reason-copy"):null;if(!d||!p){for(;t.firstChild;)t.removeChild(t.firstChild);d=null,p=null}return d||(d=document.createElement("span"),d.className="rte-ai-inline-preview-reason-label",t.appendChild(d)),d.textContent="Why",p||(p=document.createElement("span"),p.className="rte-ai-inline-preview-reason-copy",t.appendChild(p)),p.textContent=a,t.setAttribute("aria-label","Why this suggestion: "+a),t.title=a,t}function Vs(e,t,r){if(!e)return null;var i=e.querySelector?e.querySelector(".rte-ai-inline-preview-compare"):null,a=Zs(r);if(!i||!a)return t&&t.parentNode&&t.parentNode.removeChild(t),null;for((!t||t.parentNode!==i)&&(t&&t.parentNode&&t.parentNode.removeChild(t),t=document.createElement("span"),t.className="rte-ai-inline-preview-plan",i.appendChild(t));t.firstChild;)t.removeChild(t.firstChild);o(t,"span","","rte-ai-inline-preview-plan-title",a.title);for(var n=o(t,"span","","rte-ai-inline-preview-plan-items"),l=0;l<a.items.length;l++)a.items[l]&&o(n,"span","","rte-ai-inline-preview-plan-item",a.items[l]);if(a.detail&&o(t,"span","","rte-ai-inline-preview-plan-detail",a.detail),Nc(t,a),a.followupTitle||a.followupDetail){var u=o(t,"span","","rte-ai-inline-preview-plan-followup");a.followupTitle&&o(u,"span","","rte-ai-inline-preview-plan-followup-title",a.followupTitle),a.followupDetail&&o(u,"span","","rte-ai-inline-preview-plan-followup-detail",a.followupDetail)}return t}function xl(e,t){if(!e||!t)return t;var r=e.querySelector?e.querySelector(".rte-ai-inline-preview-compare"):null;if(!r)return t;var i=r.querySelector?r.querySelector(".rte-ai-inline-preview-plan"):null;return i&&i.parentNode===r?(i.nextSibling!==t&&(i.nextSibling?r.insertBefore(t,i.nextSibling):r.appendChild(t)),t):(r.lastChild!==t&&r.appendChild(t),t)}function Sl(e,t){if(!e)return null;var r=e.querySelector?e.querySelector(".rte-ai-inline-preview-compare"):null;if(!r)return null;var i=Ys(t),a=r.querySelector?r.querySelector(".rte-ai-inline-preview-compare-meta"):null;if(!i)return a&&a.parentNode&&a.parentNode.removeChild(a),null;if(!a){a=document.createElement("span"),a.className="rte-ai-inline-preview-compare-meta";var n=r.querySelector?r.querySelector(".rte-ai-inline-preview-compare-header"):null;n&&n.nextSibling?r.insertBefore(a,n.nextSibling):r.appendChild(a)}for(;a.firstChild;)a.removeChild(a.firstChild);return o(a,"span","","rte-ai-inline-preview-compare-pill is-status",i.statusLabel),i.openedLabel&&o(a,"span","","rte-ai-inline-preview-compare-pill is-opened",i.openedLabel),i.remoteLabel&&o(a,"span","","rte-ai-inline-preview-compare-pill is-remote",i.remoteLabel),i.entryLabel&&o(a,"span","","rte-ai-inline-preview-compare-pill is-entry",i.entryLabel),i.queueRoleLabel&&o(a,"span","","rte-ai-inline-preview-compare-pill is-queue",i.queueRoleLabel),i.queueLabel&&o(a,"span","","rte-ai-inline-preview-compare-pill is-position",i.queueLabel),i.typeLabel&&o(a,"span","","rte-ai-inline-preview-compare-pill is-type",i.typeLabel),i.languageLabel&&o(a,"span","","rte-ai-inline-preview-compare-pill is-language",i.languageLabel),o(a,"span","","rte-ai-inline-preview-compare-pill is-scope",i.scopeLabel),o(a,"span","","rte-ai-inline-preview-compare-pill is-steps",i.stepLabel),i.targetLabel&&o(a,"span","","rte-ai-inline-preview-compare-pill is-target",i.targetLabel),a}function Ta(e){var t=e&&e.pills?e:Bi(e);if(!t)return null;var r=[];if(t.pills&&t.pills.length)for(var i=0;i<t.pills.length;i++){var a=t.pills[i];!a||!a.text||a.kind==="scope"||r.push(a)}return!r.length&&!t.detail?null:{title:t.title||"Change at a glance",pills:r,detail:t.detail||""}}function Tl(e,t){if(!e)return null;var r=e.querySelector?e.querySelector(".rte-ai-inline-preview-compare"):null,i=Ta(t),a=r&&r.querySelector?r.querySelector(".rte-ai-inline-preview-compare-glance"):null;if(!r||!i)return a&&a.parentNode&&a.parentNode.removeChild(a),null;if(!a){a=document.createElement("span"),a.className="rte-ai-inline-preview-compare-glance";var n=r.querySelector?r.querySelector(".rte-ai-inline-preview-old"):null;n?r.insertBefore(a,n):r.appendChild(a)}for(;a.firstChild;)a.removeChild(a.firstChild);if(o(a,"span","","rte-ai-inline-preview-compare-glance-title",i.title),i.pills&&i.pills.length)for(var l=o(a,"span","","rte-ai-inline-preview-compare-glance-pills"),u=0;u<i.pills.length;u++){var d=i.pills[u];!d||!d.text||o(l,"span","","rte-ai-review-item-glance-pill is-"+(d.kind||"other"),d.text)}return i.detail&&o(a,"span","","rte-ai-inline-preview-compare-glance-detail",i.detail),a}function Ws(e,t,r,i){var a=e||"span";return"<"+a+' class="'+t+'" aria-label="'+pe(r)+' text"><span class="rte-ai-inline-preview-compare-label">'+pe(r)+"</span><"+a+' class="rte-ai-inline-preview-compare-text">'+i+"</"+a+"></"+a+">"}function Bs(e){var t=!!(e&&e.id&&s.__aiReviewEmptyPreviewSuggestionId===e.id);return t?{title:"Queue handoff",detail:"Open the next review queue"}:{title:"Proposed edit",detail:"Current and suggested text"}}function Xs(e,t){if(!e)return null;var r=e.querySelector?e.querySelector(".rte-ai-inline-preview-compare"):null;if(!r)return null;var i=Bs(t),a=r.querySelector?r.querySelector(".rte-ai-inline-preview-compare-header"):null;a||(a=document.createElement("span"),a.className="rte-ai-inline-preview-compare-header",r.firstChild?r.insertBefore(a,r.firstChild):r.appendChild(a));var n=a.querySelector?a.querySelector(".rte-ai-inline-preview-compare-title"):null,l=a.querySelector?a.querySelector(".rte-ai-inline-preview-compare-detail"):null;return n||(n=document.createElement("span"),n.className="rte-ai-inline-preview-compare-title",a.appendChild(n)),l||(l=document.createElement("span"),l.className="rte-ai-inline-preview-compare-detail",a.appendChild(l)),n.textContent=i.title,l.textContent=i.detail,r.setAttribute("aria-label",i.title+". "+i.detail),a}function Ys(e){if(!e)return null;var t=!!(e.id&&s.__aiReviewEmptyPreviewSuggestionId===e.id),r=e.id?Nt(e.id):"",i=e.id?Ve(r):[],a=e.id?ka(i,s.__aiActiveSuggestionId,e):null,n=e.id?Jt(e.id):0,l=t?Ge(e,z())||Ge(e,""):Ji({suggestion:e}),u=e.suggestionType&&Be(e.suggestionType)!=="other"?Me(e.suggestionType):"",d=e.language?ot(e.language):"";return{statusLabel:t?"Queue handoff":"Ready to review",openedLabel:s.__aiRecentlyOpenedQueueSuggestionId===e.id?"Queue opened":"",remoteLabel:n>1?n+" shared updates":n?"Shared update":"",queueRoleLabel:t?"Next queue":a?a.roleLabel:"",queueLabel:!t&&a?a.queueLabel:"",typeLabel:u,languageLabel:d,scopeLabel:(Nr(e)||"Selection")+" draft",stepLabel:"1 step",entryLabel:t?cs(e):"",targetLabel:l?"Focus "+l:""}}function Zs(e){if(!e||!e.id)return null;var t=Nt(e.id),r=Ve(t),i=gi(r,s.__aiActiveSuggestionId,e);if(!i)return null;var a=[i.statusLabel,i.queueLabel];return i.followupStatusLabel&&a.push(i.followupStatusLabel),{title:"What happens next",items:a,detail:i.detail||"",previewLabel:i.previewLabel||"",previewText:i.previewText||"",preview:Wr(i),followupTitle:i.followupTitle||"",followupDetail:i.followupDetail||""}}function Nc(e,t){if(!e||!t||!t.preview&&!t.previewLabel&&!t.previewText)return null;var r=o(e,"span","","rte-ai-inline-preview-plan-preview");return t.previewLabel&&o(r,"span","","rte-ai-inline-preview-plan-preview-label",t.previewLabel+":"),t.previewText&&o(r,"span","","rte-ai-inline-preview-plan-preview-text",t.previewText),!t.previewLabel&&!t.previewText&&t.preview&&(r.textContent=t.preview),r}function Kc(e){if(!e||!e.preview&&!e.previewLabel&&!e.previewText)return"";var t='<span class="rte-ai-inline-preview-plan-preview">';return e.previewLabel&&(t+='<span class="rte-ai-inline-preview-plan-preview-label">'+pe(e.previewLabel)+":</span>"),e.previewText&&(t+='<span class="rte-ai-inline-preview-plan-preview-text">'+pe(e.previewText)+"</span>"),!e.previewLabel&&!e.previewText&&e.preview&&(t+=pe(e.preview)),t+="</span>",t}function zc(e,t,r,i){var a=e||"span",n=Bs(i),l=Ys(i),u=Ta(i),d=mi(i),p=Zs(i),m=l?'<span class="rte-ai-inline-preview-compare-meta"><span class="rte-ai-inline-preview-compare-pill is-status">'+pe(l.statusLabel)+"</span>"+(l.openedLabel?'<span class="rte-ai-inline-preview-compare-pill is-opened">'+pe(l.openedLabel)+"</span>":"")+(l.remoteLabel?'<span class="rte-ai-inline-preview-compare-pill is-remote">'+pe(l.remoteLabel)+"</span>":"")+(l.entryLabel?'<span class="rte-ai-inline-preview-compare-pill is-entry">'+pe(l.entryLabel)+"</span>":"")+(l.queueRoleLabel?'<span class="rte-ai-inline-preview-compare-pill is-queue">'+pe(l.queueRoleLabel)+"</span>":"")+(l.queueLabel?'<span class="rte-ai-inline-preview-compare-pill is-position">'+pe(l.queueLabel)+"</span>":"")+(l.typeLabel?'<span class="rte-ai-inline-preview-compare-pill is-type">'+pe(l.typeLabel)+"</span>":"")+(l.languageLabel?'<span class="rte-ai-inline-preview-compare-pill is-language">'+pe(l.languageLabel)+"</span>":"")+'<span class="rte-ai-inline-preview-compare-pill is-scope">'+pe(l.scopeLabel)+'</span><span class="rte-ai-inline-preview-compare-pill is-steps">'+pe(l.stepLabel)+"</span>"+(l.targetLabel?'<span class="rte-ai-inline-preview-compare-pill is-target">'+pe(l.targetLabel)+"</span>":"")+"</span>":"",w="";if(u){if(w='<span class="rte-ai-inline-preview-compare-glance"><span class="rte-ai-inline-preview-compare-glance-title">'+pe(u.title)+"</span>",u.pills&&u.pills.length){w+='<span class="rte-ai-inline-preview-compare-glance-pills">';for(var y=0;y<u.pills.length;y++){var v=u.pills[y];!v||!v.text||(w+='<span class="rte-ai-review-item-glance-pill is-'+pe(v.kind||"other")+'">'+pe(v.text)+"</span>")}w+="</span>"}u.detail&&(w+='<span class="rte-ai-inline-preview-compare-glance-detail">'+pe(u.detail)+"</span>"),w+="</span>"}var h=d?'<span class="rte-ai-inline-preview-reason" aria-label="Why this suggestion: '+pe(d)+'" title="'+pe(d)+'"><span class="rte-ai-inline-preview-reason-label">Why</span><span class="rte-ai-inline-preview-reason-copy">'+pe(d)+"</span></span>":"",_="";if(p){_='<span class="rte-ai-inline-preview-plan"><span class="rte-ai-inline-preview-plan-title">'+pe(p.title)+'</span><span class="rte-ai-inline-preview-plan-items">';for(var b=0;b<p.items.length;b++)p.items[b]&&(_+='<span class="rte-ai-inline-preview-plan-item">'+pe(p.items[b])+"</span>");_+="</span>",p.detail&&(_+='<span class="rte-ai-inline-preview-plan-detail">'+pe(p.detail)+"</span>"),_+=Kc(p),(p.followupTitle||p.followupDetail)&&(_+='<span class="rte-ai-inline-preview-plan-followup">',p.followupTitle&&(_+='<span class="rte-ai-inline-preview-plan-followup-title">'+pe(p.followupTitle)+"</span>"),p.followupDetail&&(_+='<span class="rte-ai-inline-preview-plan-followup-detail">'+pe(p.followupDetail)+"</span>"),_+="</span>"),_+="</span>"}return"<"+a+' class="rte-ai-inline-preview-compare" aria-label="'+pe(n.title+". "+n.detail)+'"><span class="rte-ai-inline-preview-compare-header"><span class="rte-ai-inline-preview-compare-title">'+pe(n.title)+'</span><span class="rte-ai-inline-preview-compare-detail">'+pe(n.detail)+"</span></span>"+m+w+h+Ws(a,"rte-ai-inline-preview-old","Current",t)+Ws(a,"rte-ai-inline-preview-new","Suggested",r)+_+"</"+a+">"}function Qc(){try{var e=s.getEditable?s.getEditable():null,t=e&&e.ownerDocument;if(!t||t===document||t.querySelector("link[data-rte-ai-card-css]"))return;var r=document.querySelector("link[data-rte-auto-injected=aitoolkit]");if(!r){for(var i=document.querySelectorAll("link[rel=stylesheet]"),a=0;a<i.length;a++)if(/(?:^|\/)aitoolkit(?:\.min)?\.css(?:[?#].*)?$/i.test(i[a].getAttribute("href")||"")){r=i[a];break}}if(!r||!r.href)return;var n=t.createElement("link");n.rel="stylesheet",n.href=r.href,n.setAttribute("data-rte-ai-card-css","1"),(t.head||t.documentElement).appendChild(n)}catch{}}function Ll(e){Qc();var t=!!e.isBlock,r=t?"div":"span",i=t?"div":"span",a=e.originalHtml||zr(e.originalText||""),n=e.resultHtml||zr(e.resultText||""),l=yn("review","Open",'<button type="button" class="rte-ai-inline-preview-button is-review" data-rte-ai-action="review">Review</button>'),u=yn("move","Move",'<button type="button" class="rte-ai-inline-preview-button is-previous" data-rte-ai-action="previous">Previous</button><button type="button" class="rte-ai-inline-preview-button is-next" data-rte-ai-action="next">Next</button>'),d=yn("decision","Decide",'<button type="button" class="rte-ai-inline-preview-button is-accept" data-rte-ai-action="accept">Accept</button><button type="button" class="rte-ai-inline-preview-button is-reject" data-rte-ai-action="reject">Reject</button>'),p=yn("recovery","Recover",""),m=Fc(e);return"<"+r+' class="rte-ai-inline-preview is-review-surface'+(t?" is-block":" is-inline")+'" contenteditable="false" tabindex="-1" role="group" aria-label="AI suggestion preview" data-rte-ai-preview-id="'+e.id+'" data-rte-ai-suggestion-id="'+e.id+'">'+zc(i,a,n,e)+'<span class="rte-ai-inline-preview-actions" role="group" aria-label="AI suggestion actions">'+m+l+u+d+p+"</span></"+r+">"}function eo(e,t){var r=E(e);if(!r)return!1;t=t||{};var i=t.snapshot||ut();if(!i||!i.hasSelection)return!1;fr();var a=nc(i.html),n={id:"ai-preview-"+new Date().getTime(),snapshot:i,originalHtml:i.html,originalText:i.text,resultText:r,resultHtml:a?ln(r):zr(r),reason:t.reason||"",suggestionType:Be(t.suggestionType||""),language:t.language||"",isBlock:a,status:"pending",createdAt:new Date().getTime(),sourceLabel:t.sourceLabel||fs(t.suggestionType||"",i,t.language||"")};if(Ne().push(n),Xe(n.id),!nn(i,!1)){var l=Ne();return l.splice(l.length-1,1),Xe(null),!1}return s.__aiBindInlinePreviewEventHandlers&&s.__aiBindInlinePreviewEventHandlers(),s.insertHTML(Ll(n)),Gu(),yt(),Ki("suggestion-created",n),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&ge(!1),s.focus(),!0}function $c(e,t){var r=E(e);if(!r)return!1;t=t||{};var i=t.snapshot||ut();return fr(),nn(i,!0)||s.focus(),s.insertHTML('<span class="rte-comment-marker" data-comment="'+Qr(r)+'" data-rte-comment="'+Qr(r)+'" contenteditable="false" style="background:#fff9c4;border:1px solid #f9a825;border-radius:3px;padding:1px 6px;font-size:11px;color:#f57f17;cursor:pointer;" title="'+Qr(r)+'" aria-label="'+Qr(r)+'">💬 AI Comment</span>'),xa(),yt(),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&ge(!1),s.focus(),!0}function Jc(e){e.classList.add("rte-panel-aiassist-menu");var t=document.createElement("div");t.className="rte-ai-menu-info is-minimal is-detached";var r=o(t,"div","","rte-ai-menu-title-row"),i=o(r,"span","","rte-ai-menu-title-icon");i.innerHTML=L.svgCode_aiassist||"",o(r,"div","","rte-ai-menu-title",L.text_aiassist||"Ask AI");var a=o(e,"div","","rte-ai-menu-search-row"),n=o(a,"span","","rte-ai-menu-search-icon");n.setAttribute("aria-hidden","true"),n.innerHTML='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="10.5" cy="10.5" r="6"/><path d="M19 19l-3.4-3.4"/></svg>';var l=e.ownerDocument.createElement("input");l.type="text",l.className="rte-ai-menu-search-input",l.placeholder=c.__aiT?c.__aiT("aia_filter","Filter actions\u2026"):"Filter actions\u2026",l.setAttribute("aria-label",c.__aiT?c.__aiT("aia_filteraria","Filter AI actions"):"Filter AI actions"),l.setAttribute("autocomplete","off"),l.setAttribute("spellcheck","false"),a.appendChild(l);for(var u=tl(),d="",p=[],m=0;m<u.length;m++)(function(h){if(h.section&&h.section!==d){var _=document.createElement("div");_.className="rte-ai-menu-section is-detached",_.textContent=h.section,d=h.section}var b=o(e,"button","","rte-ai-menu-item");b.type="button",h.section&&b.setAttribute("data-section",h.section),h.description&&(b.title=h.description,b.setAttribute("aria-label",(h.title||h.id)+" \u2014 "+h.description));var H=o(b,"span","","rte-ai-menu-item-icon");H.innerHTML=qu(h);var x=o(b,"span","","rte-ai-menu-item-body");o(x,"span","","rte-ai-menu-item-title",h.title||h.id),o(x,"span","","rte-ai-menu-item-copy",h.description||""),b.onclick=function(R){R&&R.preventDefault&&R.preventDefault(),R&&R.stopPropagation&&R.stopPropagation(),s.closeCurrentPopup&&s.closeCurrentPopup(),to(h.id)},b.addEventListener("mouseenter",function(){w(b)}),p.push({button:b,action:h})})(u[m]);function w(h){for(var _=0;_<p.length;_++){var b=p[_],H=b.button===h;H?b.button.classList.add("is-active"):b.button.classList.remove("is-active")}if(h&&typeof h.scrollIntoView=="function")try{h.scrollIntoView({block:"nearest"})}catch{h.scrollIntoView()}}function y(){for(var h=[],_=0;_<p.length;_++)p[_].button.hidden||h.push(p[_].button);return h}function v(h){for(var _=(h||"").trim().toLowerCase(),b=null,H=0;H<p.length;H++){var x=p[H],R=((x.action.title||"")+" "+(x.action.description||"")+" "+(x.action.id||"")).toLowerCase(),C=!_||R.indexOf(_)!==-1;x.button.hidden=!C,C&&!b&&(b=x.button)}if(b)a.__aiEmptyHint&&(a.__aiEmptyHint.hidden=!0);else{if(!a.__aiEmptyHint){var P=e.ownerDocument.createElement("div");P.className="rte-ai-menu-empty-hint",P.textContent=c.__aiT?c.__aiT("aia_nomatch","No actions match."):"No actions match.",e.appendChild(P),a.__aiEmptyHint=P}a.__aiEmptyHint.hidden=!1}w(b)}l.addEventListener("input",function(){v(l.value)}),l.addEventListener("keydown",function(h){if(h.key==="ArrowDown"||h.key==="ArrowUp"){h.preventDefault();var _=y();if(!_.length)return;for(var b=-1,H=0;H<_.length;H++)if(_[H].classList.contains("is-active")){b=H;break}var x;h.key==="ArrowDown"?x=b<0?0:(b+1)%_.length:x=b<=0?_.length-1:b-1,w(_[x])}else if(h.key==="Enter"){h.preventDefault();for(var R=y(),C=null,P=0;P<R.length;P++)if(R[P].classList.contains("is-active")){C=R[P];break}C||(C=R[0]),C&&C.click()}else h.key==="Escape"&&l.value&&(h.preventDefault(),l.value="",v(""))}),v(""),setTimeout(function(){if(l&&typeof l.focus=="function"&&l.isConnected!==!1)try{l.focus({preventScroll:!0})}catch{try{l.focus()}catch{}}},30)}function Vc(e,t){t=t||{};var r=t.agent||L.aiToolkitAgent;if(typeof r!="function"){var i=new Error("AI Toolkit: no agent registered. Call editor.aiToolkit.setAgent(fn) first.");return console.warn(i.message),Promise.reject(i)}var a=Math.max(1,t.maxSteps|0||6),n=t.tools||{},l=t.snapshot||ut(),u=[],d=[];function p(m,w){if(m>=a)return Promise.resolve({done:!0,reason:"maxSteps",transcript:u,executedOps:d,lastResult:w});var y={step:m,prompt:e,snapshot:l,tools:Object.keys(n),transcript:u.slice(),lastResult:w},v;try{v=r(e,y)}catch(h){return Promise.reject(h)}return Promise.resolve(v).then(function(h){if(u.push({step:m,result:h}),!h||h.done===!0)return{done:!0,reason:"agent",transcript:u,executedOps:d,lastResult:h};var _=Promise.resolve(h);return h.toolCalls&&h.toolCalls.length&&(_=Promise.all(h.toolCalls.map(function(b){var H=n[b&&b.name];if(typeof H!="function")return{name:b&&b.name,error:"unknown tool"};try{return Promise.resolve(H(b.args||{},{snapshot:l})).then(function(x){return{name:b.name,output:x}})}catch(x){return{name:b.name,error:String(x&&x.message||x)}}})).then(function(b){return h.toolResults=b,u[u.length-1].toolResults=b,h})),_.then(function(b){if(b.operations&&b.operations.length){var H=La(b.operations,{snapshot:l,resolved:b});d.push({step:m,handled:H,count:b.operations.length})}return b.done===!0?{done:!0,reason:"agent",transcript:u,executedOps:d,lastResult:b}:p(m+1,b)})})}return p(0,null)}function to(e,t){t=t||{};var r=t.snapshot||ut(),i=ps(e)||{id:e,target:"document"};return i.target==="chat-panel"&&!t.forceResolve?(ea({focusComposer:!0}),Promise.resolve(!0)):i.target==="review-panel"&&!t.forceResolve?(Gn({focusPanel:!0}),Promise.resolve(!0)):i.target==="dialog"&&!t.forceResolve?(sa({presetMode:i.resolverMode||"",useDocument:t.useDocument===!0||!r.hasSelection,autoRun:!!i.autoRun}),Promise.resolve(!0)):an(e,{snapshot:r,source:t.source,prompt:t.prompt,scope:t.scope}).then(function(a){return vr(a,{snapshot:r,fallbackAction:i})}).catch(function(a){return console.error("AI Toolkit action failed",a),!1})}function vr(e,t){t=t||{};var r=t.snapshot||ut();return e&&e.operations&&e.operations.length?La(e.operations,{snapshot:r,resolved:e}):La([ht(e&&e.target?e.target:"document",e&&e.result?e.result:"",e,e?e.request:null,e?e.action:null)],{snapshot:r,resolved:e})}function ro(){try{return!!(s.getReadOnly&&s.getReadOnly()||s.getCommentsOnly&&s.getCommentsOnly())}catch{return!1}}function io(){return He(L.text_aitoolkitlocked||"This document is read-only, so the AI result was not applied."),!1}function La(e,t){t=t||{};for(var r=t.snapshot||ut(),i=t.resolved||null,a=!1,n=e||[],l=0;l<n.length;l++)Wc(n[l],{snapshot:r,resolved:i})&&(a=!0);return a}function Wc(e,t){if(!e||!e.type)return!1;t=t||{};var r=t.snapshot||ut(),i=t.resolved||{},a=L.aiToolkitOperationHandlers&&L.aiToolkitOperationHandlers[e.type];if(typeof a=="function")return!!a.call(s,e,{snapshot:r,resolved:i,request:i.request||null,action:i.action||null,editor:s});if(ro()&&!/^open-|comment/i.test(String(e.type)))return io();switch(e.type){case"open-chat-panel":return ea({focusComposer:!0}),!0;case"open-review-panel":return Gn({focusPanel:!0}),!0;case"open-dialog":return sa({presetMode:e.presetMode||i.presetMode||(i.request?i.request.mode:""),useDocument:e.useDocument===!0||i.useDocument===!0||!r.hasSelection,autoRun:!!(e.autoRun||i.autoRun)}),!0;case"preview-suggestion":return r.hasSelection?eo(e.text,{snapshot:r,reason:e.reason||i&&i.reason||"",sourceLabel:e.meta&&e.meta.sourceLabel?e.meta.sourceLabel:"",suggestionType:e.meta&&e.meta.mode?e.meta.mode:i&&i.request?i.request.mode:"",language:e.meta&&e.meta.language?e.meta.language:i&&i.request?i.request.language:""}):(sa({presetMode:e.presetMode||i.presetMode||(i.request?i.request.mode:""),useDocument:!0,autoRun:!0}),!0);case"add-comment":return $c(e.text,{snapshot:r});case"insert-below":return An(e.text,{mode:"insert",snapshot:r});case"replace-selection":return An(e.text,{mode:"selection",snapshot:r});case"replace-document":return An(e.text,{mode:"document",snapshot:r});default:return!1}}function Ra(){fr();var e=arguments.length?me(arguments[0]):hi();if(!e)return!1;var t=Lr(e.id);return t?(t.outerHTML=pn(e,"accepted"),e.status="accepted",e.decidedAt=new Date().getTime(),dl(e,"accepted"),ba(e.id),s.__aiRecentlyOpenedQueueSuggestionId===e.id&&Wi({skipUpdate:!0,skipRender:!0}),Xe(null),He(Vr(e,"Accepted")),yt(),Ki("suggestion-accepted",e),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&ge(!1),s.focus(),!0):(e.status="stale",e.decidedAt=e.decidedAt||new Date().getTime(),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&ge(!1),Xe(null),yt(),!1)}function Ca(){fr();var e=arguments.length?me(arguments[0]):hi();if(!e)return!1;var t=Lr(e.id);return t?(t.outerHTML=pn(e,"rejected"),e.status="rejected",e.decidedAt=new Date().getTime(),dl(e,"rejected"),ba(e.id),s.__aiRecentlyOpenedQueueSuggestionId===e.id&&Wi({skipUpdate:!0,skipRender:!0}),Xe(null),He(Vr(e,"Rejected")),yt(),Ki("suggestion-rejected",e),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&ge(!1),s.focus(),!0):(e.status="stale",e.decidedAt=e.decidedAt||new Date().getTime(),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&ge(!1),Xe(null),yt(),!1)}function Cr(e){e=e||{},fr();var t=ci();if(!t)return!1;var r=t.suggestion,i=t.wrapper;if(!i||!i.parentNode)return Hs(),!1;r.status="pending",r.decidedAt=0,i.outerHTML=Ll(r),Ht().showResolved=!1,Ec(r,t.status),Hs(),Xe(r.id),He(Vr(r,"Reopened")),yt(),Ki("suggestion-reopened",r),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&ge(!!e.focusPanel,{focusAction:e.focusAction||""});var a=!1;return e.focusInlineAction&&(a=bn(r.id,e.focusInlineAction)),!e.focusPanel&&!a&&s.focus(),!0}function Jr(e){e=e||{},fr();var t=Rr();if(!t)return!1;var r=t.suggestion,i=t.wrapper,a=s.__aiActiveSuggestionId===r.id?aa(r.id):"";if(!i||!i.parentNode)return Ds(),!1;if(i.outerHTML=pn(r,t.status),r.status=t.status,r.decidedAt=new Date().getTime(),Ht().showResolved=!1,Ds(),dl(r,t.status,{clearRedo:!1}),ba(r.id),s.__aiRecentlyOpenedQueueSuggestionId===r.id&&Wi({skipUpdate:!0,skipRender:!0}),Xe(null),He(Vr(r,t.status==="accepted"?"Accepted again":"Rejected again")),yt(),Ki(t.status==="accepted"?"suggestion-accepted":"suggestion-rejected",r),a){var n=wi(a,{focusPanel:!!e.focusPanel,focusAction:e.focusAction||"accept"});return n&&e.focusInlineAction&&bn(a,e.focusInlineAction),n}return s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&ge(!!e.focusPanel,{focusAction:e.focusAction||"accept"}),e.focusPanel||s.focus(),!0}function An(e,t){if(ro())return io();var r=E(e);if(!r)return!1;fr(),t=t||{};var i=t.mode||"document",a=t.snapshot||ut();return i==="document"?(s.setHTMLCode(ln(r),{undoable:!0}),xa(),yt(),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&ge(!1),s.focus(),!0):i==="selection"?(nn(a,!1)||s.focus(),s.insertText(r),xa(),yt(),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&ge(!1),s.focus(),!0):(nn(a,!0)||s.focus(),s.insertHTML("<p><br/></p>"+ln(r)),xa(),yt(),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&ge(!1),s.focus(),!0)}function Rl(e){for(;e;){if(e.nodeType===1){var t=typeof e.className=="string"?e.className:"";if(t.indexOf("richtexteditor")!==-1)return e}e=e.parentNode}return null}function ki(){var e=s.getEditable?s.getEditable():null,t=Rl(e);if(t)return t;var r=e&&e.ownerDocument&&e.ownerDocument.defaultView?e.ownerDocument.defaultView.frameElement:null;if(t=Rl(r),t)return t;if(s.iframe){if(t=Rl(s.iframe),t)return t;if(s.iframe.parentNode)return s.iframe.parentNode}return e&&e.parentNode?e.parentNode:null}function Bc(){var e=ki();if(!e)return null;if(s.__aiReviewStatusNode&&s.__aiReviewStatusNode.isConnected)return s.__aiReviewStatusNode;var t=e.querySelector?e.querySelector(".rte-ai-review-live-region"):null;if(t)return s.__aiReviewStatusNode=t,t;var r=o(e,"div","","rte-ai-review-live-region");return r.setAttribute("role","status"),r.setAttribute("aria-live","polite"),r.setAttribute("aria-atomic","true"),s.__aiReviewStatusNode=r,r}function Vr(e,t,r){if(!e)return t||"";r=r||{};var i=[],a=Be(e.suggestionType||"")!=="other"?Me(e.suggestionType):"AI suggestion";i.push(a);var n=Nr(e);n&&i.push(n),e.language&&i.push(ot(e.language));var l=t?t+" "+i.join(", "):i.join(", ");return r.positionLabel?l+=". "+r.positionLabel+".":l+=".",r.remoteUpdateCount&&(l+=" "+(r.remoteUpdateCount>1?r.remoteUpdateCount+" shared updates.":"Shared update.")),l}function ao(e,t){if(!e)return"Opened AI review queue.";t=t||{};var r=ma(e),i=r===1?"1 pending item":r+" pending items",a=Be(e.suggestionType||"")!=="other"?Me(e.suggestionType):"AI",n=Ge(e,t.focusAction||z()),l=a&&a!=="AI"?"Opened "+a+" AI review queue. "+i+".":"Opened AI review queue. "+i+".";return n&&(l+=" Focus "+n+"."),l+" "+Vr(e,"Reviewing",t)}function Xc(e,t){if(!e)return"AI review item";t=t||{};var r=[];t.isCurrent&&r.push("Current review item"),t.queueOpened&&r.push("Queue opened"),t.queueRoleLabel&&r.push(t.queueRoleLabel),t.queuePositionLabel&&r.push(t.queuePositionLabel),t.transitionLabel&&r.push(t.transitionLabel),t.changeSummary&&r.push(t.changeSummary),r.push(Sa(e.status)),e.suggestionType&&Be(e.suggestionType)!=="other"?r.push(Me(e.suggestionType)):r.push("AI suggestion");var i=Nr(e);i&&r.push(i),e.language&&r.push(ot(e.language)),t.remoteUpdateCount&&r.push(t.remoteUpdateCount>1?t.remoteUpdateCount+" shared updates":"Shared update");var a=Ye(e.originalText||e.resultText||"AI suggestion",80);return a&&r.push("Preview: "+a),t.undoLabel&&r.push(t.undoLabel),t.undoNextLabel&&r.push(t.undoNextLabel),t.redoLabel&&r.push(t.redoLabel),t.redoNextLabel&&r.push(t.redoNextLabel),fe(r)}function ka(e,t,r){if(!r||r.status!=="pending"||!e||!e.length)return null;for(var i=[],a=0;a<e.length;a++)e[a]&&e[a].status==="pending"&&i.push(e[a]);if(!i.length)return null;for(var n=-1,l=-1,u=0;u<i.length;u++)i[u].id===r.id&&(n=u),i[u].id===t&&(l=u);if(n===-1)return null;l===-1&&(l=0);var d="later";n===l?d="current":n===l+1?d="next":n<l&&(d="earlier");var p="Queue "+(n+1)+" of "+i.length,m="",w="";return d==="current"?(w="Current focus",m="Review this item now. It is "+p.toLowerCase()+" in this view."):d==="next"?(w="Up next",m="This follows after the current decision. It is "+p.toLowerCase()+" in this view."):d==="earlier"?(w="Earlier item",m="You moved past this item. Use Previous or K to return. It is "+p.toLowerCase()+" in this view."):(w="Later in queue",m="This comes later in the current review run. It is "+p.toLowerCase()+" in this view."),{role:d,roleLabel:w,queueLabel:p,detail:m}}function Yc(e,t,r,i){if(!r||!e||!e.length)return null;if(r.status!=="pending"){for(var a=0,n=0;n<e.length;n++)e[n]&&e[n].status!=="pending"&&a++;return a?{key:"resolved",label:"Resolved items",detail:"Accepted, rejected, or stale suggestions from this review run.",countLabel:At(a,"item")}:null}for(var l=[],u=0;u<e.length;u++)e[u]&&e[u].status==="pending"&&l.push(e[u]);if(!l.length)return null;for(var d=-1,p=0;p<l.length;p++)if(l[p].id===t){d=p;break}d===-1&&(d=0);var m=i&&i.role?i.role:"";return m==="current"?{key:"current",label:"Current focus",detail:"Review this suggestion now.",countLabel:"1 item"}:m==="next"?{key:"next",label:"Up next",detail:"Becomes current after this decision.",countLabel:"1 item"}:m==="later"?{key:"later",label:"Later in queue",detail:"Pending suggestions after the immediate next step.",countLabel:At(Math.max(1,l.length-d-2),"item")}:m==="earlier"?{key:"earlier",label:"Earlier in queue",detail:"Pending suggestions before the current focus.",countLabel:At(Math.max(1,d),"item")}:{key:"pending",label:"Pending items",detail:"Remaining AI suggestions in this queue.",countLabel:At(l.length,"item")}}function gi(e,t,r){if(!r||r.status!=="pending"||!e||!e.length)return null;for(var i=[],a=0;a<e.length;a++)e[a]&&e[a].status==="pending"&&i.push(e[a]);if(!i.length)return null;for(var n=-1,l=-1,u=0;u<i.length;u++)i[u].id===t&&(n=u),i[u].id===r.id&&(l=u);if(l===-1)return null;var d=l===i.length-1;if(!d&&r.id!==t)return null;if(d)return{title:"After this decision",statusLabel:"Queue complete",queueLabel:"Queue "+(l+1)+" of "+i.length,typeLabel:"",scopeLabel:"",detail:"Accepting or rejecting this final pending item finishes the current review run.",previewLabel:"Queue state",previewText:"No later pending items remain in this queue.",followupTitle:"Then recovery and next queues appear",followupStatusLabel:"Recovery ready",followupDetail:"Undo the last decision or open another queue."};if(n===-1||n>=i.length-1)return null;var p=i[n+1];return p?{title:"After this decision",statusLabel:"Up next becomes current",queueLabel:"Queue "+(n+2)+" of "+i.length,typeLabel:p.suggestionType&&Be(p.suggestionType)!=="other"?Me(p.suggestionType):"",scopeLabel:Nr(p),detail:"Accepting or rejecting this item moves review straight to the next pending suggestion.",previewLabel:"Next item",previewText:Ye(p.originalText||p.resultText||"Next review item",84),followupTitle:n+1===i.length-1?"Then queue complete":"",followupStatusLabel:n+1===i.length-1?"Queue complete":"",followupDetail:n+1===i.length-1?"After reviewing the final pending item, recovery and next queues appear.":""}:null}function Wr(e){if(!e)return"";var t=e.previewLabel||"",r=e.previewText||"";return t&&r?t+": "+r:r||t}function no(e,t,r){if(!e||!t||!r)return null;var i=Wr(r);if(!i)return null;var a=o(e,"div","",t);return r.previewLabel&&o(a,"span","",t+"-label",r.previewLabel+":"),r.previewText&&o(a,"span","",t+"-text"," "+r.previewText),!r.previewLabel&&!r.previewText&&(a.textContent=i),a}function lo(e){return s.__aiQueueOpenedTimer&&(clearTimeout(s.__aiQueueOpenedTimer),s.__aiQueueOpenedTimer=null),s.__aiRecentlyOpenedQueueSuggestionId=e||null,$i(),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&ge(!1),e?(s.__aiQueueOpenedTimer=setTimeout(function(){s.__aiRecentlyOpenedQueueSuggestionId===e&&(s.__aiRecentlyOpenedQueueSuggestionId=null,$i(),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&ge(!1)),s.__aiQueueOpenedTimer=null},1800),!0):!1}function Wi(e){e=e||{};var t=!!s.__aiRecentlyOpenedQueueSuggestionId;return s.__aiQueueOpenedTimer&&(clearTimeout(s.__aiQueueOpenedTimer),s.__aiQueueOpenedTimer=null),s.__aiRecentlyOpenedQueueSuggestionId=null,t?(e.skipUpdate||$i(),!e.skipRender&&s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&ge(!1),!0):!1}function tr(e,t){var r=me(e),i=Nt(e),a=i&&i!=="all"?Me(i)+" review queue":"AI review queue",n=t==="previous"||t==="first"?"Already at the first pending item in the "+a+".":"Already at the last pending item in the "+a+".";return r?n+" "+Vr(r,"Still reviewing"):n}function xn(e,t){var r=me(t),i=r?Vr(r,e):(e||"Updated")+" AI suggestion.";return i+" Review queue complete."}function mi(e){return!e||!e.reason?"":Ye(e.reason,110)}function Zc(e){if(!e)return"";var t=Ye(e.resultText||"",96),r=Ye(e.originalText||"",96);return!t||t===r?"":t}function so(e){if(!e)return"";switch(Be(e.suggestionType)){case"proofread":return"Surface edit";case"rewrite":return"Text rewrite";case"translate":return"Language change";case"summarize":case"shorten":return"Condensed draft";case"expand":return"Expanded draft"}var t=E(e.originalText||"").toLowerCase().replace(/[^a-z0-9\s]/g,"").replace(/\s+/g," ").trim(),r=E(e.resultText||"").toLowerCase().replace(/[^a-z0-9\s]/g,"").replace(/\s+/g," ").trim();return t&&r&&t===r?"Surface edit":"Text change"}function oo(e){if(!e)return"";var t=Be(e.suggestionType),r=E(e.originalText||"").toLowerCase().replace(/[^a-z0-9\s]/g,"").replace(/\s+/g," ").trim(),i=E(e.resultText||"").toLowerCase().replace(/[^a-z0-9\s]/g,"").replace(/\s+/g," ").trim();if(!r||!i)return"";if(r===i||t==="proofread")return"Low impact";if(t==="translate"||t==="summarize"||t==="shorten"||t==="expand")return"High impact";if(t==="rewrite"||r.indexOf(i)>=0||i.indexOf(r)>=0)return"Medium impact";for(var a=r.split(/\s+/),n=i.split(/\s+/),l={},u=0,d=0;d<a.length;d++)l[a[d]]=(l[a[d]]||0)+1;for(var p=0;p<n.length;p++){var m=n[p];l[m]&&(l[m]--,u++)}var w=u/Math.max(a.length,n.length,1);return w>=.45?"Medium impact":"High impact"}function uo(e){var t=E(e||"");return t?t.split(/\s+/).length:0}function co(e){var t=E(e||"");if(!t)return 0;var r=t.match(/[^.!?]+[.!?]+|[^.!?]+$/g);return r&&r.length?r.length:1}function At(e,t){return e+" "+t+(e===1?"":"s")}function Bi(e){if(!e)return null;var t=[],r=so(e),i=oo(e),a=Nr(e);r&&t.push({kind:"change",text:r}),i&&t.push({kind:"impact",text:i}),a&&t.push({kind:"scope",text:a});var n=uo(e.originalText||""),l=uo(e.resultText||""),u=co(e.originalText||""),d=co(e.resultText||""),p="";return n&&l&&u&&d?n===l&&u===d?p="Keeps "+At(l,"word")+" across "+At(d,"sentence")+".":u===d?p="Moves from "+At(n,"word")+" to "+At(l,"word")+" across "+At(d,"sentence")+".":p="Moves from "+At(n,"word")+" across "+At(u,"sentence")+" to "+At(l,"word")+" across "+At(d,"sentence")+".":n&&l?p="Moves from "+At(n,"word")+" to "+At(l,"word")+".":u&&d&&(p="Moves from "+At(u,"sentence")+" to "+At(d,"sentence")+"."),!t.length&&!p?null:{title:"Change at a glance",pills:t,detail:p}}function Sn(e,t){var r=E(e||""),i=E(t||"");if(!r||!i||r===i)return null;for(var a=0,n=Math.min(r.length,i.length);a<n&&r.charAt(a)===i.charAt(a);)a++;for(var l=0,u=r.length-a,d=i.length-a;l<u&&l<d&&r.charAt(r.length-1-l)===i.charAt(i.length-1-l);)l++;return{currentLead:r.substring(0,a),currentChange:r.substring(a,r.length-l),currentTrail:l?r.substring(r.length-l):"",resultLead:i.substring(0,a),resultChange:i.substring(a,i.length-l),resultTrail:l?i.substring(i.length-l):""}}function fo(e,t,r,i){var a=t==="result"?"Suggested":"Current",n=o(e,"div","","rte-ai-review-empty-preview-line is-"+t);o(n,"span","","rte-ai-review-empty-preview-line-label",a+":");var l=o(n,"span","","rte-ai-review-empty-preview-line-text");if(!r)return n;if(!i)return l.innerText=r,n;var u=t==="result"?i.resultLead:i.currentLead,d=t==="result"?i.resultChange:i.currentChange,p=t==="result"?i.resultTrail:i.currentTrail;return u&&o(l,"span","","rte-ai-review-empty-preview-segment",u),d&&o(l,"span","","rte-ai-review-empty-preview-delta is-"+t,d),p&&o(l,"span","","rte-ai-review-empty-preview-segment",p),!u&&!d&&!p&&(l.innerText=r),n}function Tn(e,t,r,i){var a=o(e,"div","","rte-ai-review-item-compare-text"),n=r||"";if(!n)return a.innerText=t==="result"?"Suggested text unavailable.":"Original selection unavailable.",a;if(!i)return a.innerText=n,a;var l=t==="result"?i.resultLead:i.currentLead,u=t==="result"?i.resultChange:i.currentChange,d=t==="result"?i.resultTrail:i.currentTrail;return l&&o(a,"span","","rte-ai-review-item-compare-segment",l),u&&o(a,"span","","rte-ai-review-item-compare-delta is-"+t,u),d&&o(a,"span","","rte-ai-review-item-compare-segment",d),!l&&!u&&!d&&(a.innerText=n),a}function Ln(e,t,r){if(!(!e||!t)){var i=e.closest?e.closest(".rte-ai-review-item"):null,a=e.querySelector(".rte-ai-review-item-condensed-open-pill"),n=e.querySelector(".rte-ai-review-item-condensed-entry-detail");if(a){var l=Ge(t,z(r))||Ge(t,"")||"Locate";a.innerText=l,n&&(n.innerText="Press Enter to reopen this suggestion and land on "+l+"."),i&&i.setAttribute&&i.setAttribute("data-rte-ai-review-open-action-label",l)}}}function vo(e,t,r){if(!(!e||!t)){var i=e.querySelector?e.querySelector(".rte-ai-review-item-condensed-shortcuts"):null,a=cu(t,z(r));if(!a){i&&i.parentNode&&i.parentNode.removeChild(i);return}i||(i=o(e,"div","","rte-ai-review-item-condensed-shortcuts"));var n=i.querySelector?i.querySelector(".rte-ai-review-item-condensed-shortcuts-title"):null;n||(n=o(i,"span","","rte-ai-review-item-condensed-shortcuts-title")),n.textContent="More keys";var l=i.querySelector?i.querySelector(".rte-ai-review-item-condensed-shortcuts-body"):null;l||(l=o(i,"div","","rte-ai-review-shortcuts rte-ai-review-item-condensed-shortcuts-body")),Nl(l,a),Kl(l,"card"),i.setAttribute("aria-label","More keys. "+(l.textContent||""))}}function ed(e,t){if(!e||!t)return null;var r=o(e,"div","","rte-ai-review-item-condensed-queue is-"+(t.role||""));o(r,"div","","rte-ai-review-item-condensed-queue-title",t.roleLabel);var i=o(r,"div","","rte-ai-review-item-condensed-queue-meta");return o(i,"span","","rte-ai-review-item-queue-pill is-role",t.roleLabel),o(i,"span","","rte-ai-review-item-queue-pill is-position",t.queueLabel),o(r,"div","","rte-ai-review-item-condensed-queue-detail",t.detail),r}function td(e,t){if(!e||!t)return null;var r=o(e,"div","","rte-ai-review-item-condensed-transition");o(r,"div","","rte-ai-review-item-condensed-transition-title",t.title);var i=o(r,"div","","rte-ai-review-item-condensed-transition-meta");if(o(i,"span","","rte-ai-review-item-transition-pill is-status",t.statusLabel),o(i,"span","","rte-ai-review-item-transition-pill is-position",t.queueLabel),t.typeLabel&&o(i,"span","","rte-ai-review-item-transition-pill is-type",t.typeLabel),t.scopeLabel&&o(i,"span","","rte-ai-review-item-transition-pill is-scope",t.scopeLabel),o(r,"div","","rte-ai-review-item-condensed-transition-detail",t.detail),no(r,"rte-ai-review-item-condensed-transition-preview",t),t.followupTitle){var a=o(r,"div","","rte-ai-review-item-condensed-transition-followup");o(a,"div","","rte-ai-review-item-condensed-transition-followup-title",t.followupTitle);var n=o(a,"div","","rte-ai-review-item-condensed-transition-followup-meta");t.followupStatusLabel&&o(n,"span","","rte-ai-review-item-transition-pill is-followup",t.followupStatusLabel),o(a,"div","","rte-ai-review-item-condensed-transition-followup-detail",t.followupDetail)}return r}function Cl(e,t){if(!e)return[];t=t||{};var r=t.sharedUpdateCount||0,i=[];i.push({kind:"status",text:e.status==="pending"?"Ready to review":Sa(e.status)}),r&&i.push({kind:"remote",text:r>1?r+" shared updates":"Shared update"}),e.suggestionType&&Be(e.suggestionType)!=="other"&&i.push({kind:"type",text:Me(e.suggestionType)}),e.language&&i.push({kind:"language",text:ot(e.language)});var a=Nr(e);return a&&i.push({kind:"scope",text:e.status==="pending"?a+" draft":a}),e.status==="pending"&&i.push({kind:"steps",text:"1 step"}),i}function rd(e,t){if(!e)return"";t=t||{};var r=["Proposed edit","Current and suggested text"],i=t.originalText||Ye(e.originalText||"",72)||"Original selection unavailable.",a=t.resultText||Ye(e.resultText||"",72)||"Suggested text unavailable.",n=t.previewMetaData||Cl(e,t);if(n&&n.length)for(var l=0;l<n.length;l++)n[l]&&n[l].text&&r.push(n[l].text);r.push("Current"),r.push(i),r.push("Suggested"),r.push(a);var u=t.reasonText||mi(e);if(u&&(r.push("Why"),r.push(u)),t.changeGlance){if(r.push(t.changeGlance.title),t.changeGlance.pills&&t.changeGlance.pills.length)for(var d=0;d<t.changeGlance.pills.length;d++)t.changeGlance.pills[d]&&t.changeGlance.pills[d].text&&r.push(t.changeGlance.pills[d].text);t.changeGlance.detail&&r.push(t.changeGlance.detail)}t.queuePositionData&&(r.push(t.queuePositionData.roleLabel),r.push(t.queuePositionData.queueLabel),r.push(t.queuePositionData.detail)),r.push("Review handoff");var p=Ge(e,t.preferredAction||z(t.panel))||Ge(e,"")||"Locate";r.push("Enter target "+p),r.push("Press Enter to reopen this suggestion and land on "+p);var m=cu(e,t.preferredAction||z(t.panel));return m&&(r.push("More keys"),r.push(m)),t.queueTransitionData&&(r.push(t.queueTransitionData.title),r.push(t.queueTransitionData.statusLabel),r.push(t.queueTransitionData.queueLabel),t.queueTransitionData.typeLabel&&r.push(t.queueTransitionData.typeLabel),t.queueTransitionData.scopeLabel&&r.push(t.queueTransitionData.scopeLabel),r.push(t.queueTransitionData.detail),r.push(Wr(t.queueTransitionData)),t.queueTransitionData.followupTitle&&r.push(t.queueTransitionData.followupTitle),t.queueTransitionData.followupDetail&&r.push(t.queueTransitionData.followupDetail)),fe(r)}function po(e,t,r){if(!(!e||!t||!e.setAttribute)){var i=z(r),a=Ul(t),n=Ve(a);!n.length&&a!=="all"&&(n=Ve("all"));var l=ka(n,s.__aiActiveSuggestionId,t),u=gi(n,s.__aiActiveSuggestionId,t),d=Bi(t),p=Jt(t.id),m=Ye(t.originalText||"",72)||"Original selection unavailable.",w=Ye(t.resultText||"",72)||"Suggested text unavailable.",y=rd(t,{panel:r,preferredAction:i,previewMetaData:Cl(t,{sharedUpdateCount:p}),queuePositionData:l,queueTransitionData:u,changeGlance:d,originalText:m,resultText:w,reasonText:mi(t)});e.setAttribute("data-rte-ai-review-base-aria-label",y),e.setAttribute("aria-label",y)}}function Rn(e){var t=e&&e.isConnected?e:s.__aiReviewPanel&&s.__aiReviewPanel.isConnected?s.__aiReviewPanel:null;if(t)for(var r=z(t),i=t.querySelectorAll(".rte-ai-review-item.is-condensed"),a=0;a<i.length;a++){var n=i[a],l=n.getAttribute("data-rte-ai-review-id")||"";if(l){var u=me(l);po(n,u,t),Ln(n,u,t),vo(n,u,t),n.title=Fl(u,r)}}}function Cn(){var e=s.getEditable?s.getEditable():null;if(!(!e||!e.querySelectorAll))for(var t=e.querySelectorAll(".rte-ai-inline-preview"),r=0;r<t.length;r++){var i=t[r];if(!(!i||i.classList.contains("is-review-active"))){var a=i.getAttribute("data-rte-ai-suggestion-id")||"";if(!(!a||s.__aiReviewEmptyPreviewSuggestionId&&a===s.__aiReviewEmptyPreviewSuggestionId)){var n=me(a);if(n){var l=Nt(a),u=Ve(l),d=ka(u,s.__aiActiveSuggestionId,n),p=gi(u,s.__aiActiveSuggestionId,n),m=Ge(n,z())||Ge(n,""),w="Open this AI suggestion in review"+(m?" and focus "+m:""),y=mi(n),v=i.querySelector?i.querySelector('[data-rte-ai-action="review"]'):null;v&&$r(v,"Review",w);var h=Bi(n),_=Ta(h),b=i.querySelector?i.querySelector(".rte-ai-inline-preview-focus"):null,H=i.querySelector?i.querySelector(".rte-ai-inline-preview-current"):null,x=i.querySelector?i.querySelector(".rte-ai-inline-preview-type"):null,R=i.querySelector?i.querySelector(".rte-ai-inline-preview-language"):null,C=i.querySelector?i.querySelector(".rte-ai-inline-preview-scope"):null,P=i.querySelector?i.querySelector(".rte-ai-inline-preview-remote"):null,T=i.querySelector?i.querySelector(".rte-ai-inline-preview-glance"):null,D=i.querySelector?i.querySelector(".rte-ai-inline-preview-reason"):null,F=i.querySelector?i.querySelector(".rte-ai-inline-preview-shortcuts"):null;if(m){if(!b){b=document.createElement("span"),b.className="rte-ai-inline-preview-focus";var M=P||C||R||x||H;M&&M.nextSibling?i.insertBefore(b,M.nextSibling):i.appendChild(b)}b.textContent="Focus "+m,b.setAttribute("aria-label","Review opens on "+m)}else b&&b.parentNode&&b.parentNode.removeChild(b);if(h&&h.pills&&h.pills.length){if(!T){T=document.createElement("span"),T.className="rte-ai-inline-preview-glance";var V=C||x||H;V&&V.nextSibling?i.insertBefore(T,V.nextSibling):i.appendChild(T)}for(;T.firstChild;)T.removeChild(T.firstChild);for(var ve=0;ve<h.pills.length;ve++){var X=h.pills[ve];!X||!X.text||X.kind==="scope"||o(T,"span","","rte-ai-review-item-glance-pill is-"+X.kind,X.text)}!T.childNodes.length&&T.parentNode&&(T.parentNode.removeChild(T),T=null)}else T&&T.parentNode&&T.parentNode.removeChild(T);Xs(i,n),Sl(i,n),Tl(i,_),D=Al(i,D,n),F=xl(i,F),wl(i,{suggestion:n,sharedUpdateCount:Jt(a),queueTransitionData:p}),yl(i,{suggestion:n,sharedUpdateCount:Jt(a)}),i.setAttribute("aria-label",el(n,{remoteUpdateCount:Jt(a),glanceLabels:h?h.pills.map(function(j){return j.text}):[],glanceDetail:h?h.detail:"",compareLabel:"Proposed edit. Current and suggested text.",reasonText:y,focusLabel:m,queueRoleLabel:d?d.roleLabel:"",queueRoleDetail:d?d.detail:"",transitionLabel:p?p.title+". "+p.statusLabel+". "+p.queueLabel+". "+Wr(p):"",followupLabel:p&&p.followupTitle?p.followupTitle+". "+p.followupDetail:""}))}}}}}function id(e,t,r,i){if(!e||!t)return null;i=i||{};var a=i.queuePositionData||null,n=i.queueTransitionData||null,l=Cl(t,i),u=Bi(t),d=Ye(t.originalText||"",72)||"Original selection unavailable.",p=Ye(t.resultText||"",72)||"Suggested text unavailable.",m=mi(t),w=Sn(d,p),y=o(e,"div","","rte-ai-review-item-condensed-preview"),v=o(y,"div","","rte-ai-review-item-condensed-preview-header");if(o(v,"div","","rte-ai-review-item-condensed-preview-title","Proposed edit"),o(v,"div","","rte-ai-review-item-condensed-preview-detail","Current and suggested text"),l&&l.length)for(var h=o(y,"div","","rte-ai-review-item-condensed-preview-meta"),_=0;_<l.length;_++){var b=l[_];!b||!b.text||o(h,"span","","rte-ai-review-item-condensed-preview-pill is-"+(b.kind||"other"),b.text)}var H=o(y,"div","","rte-ai-review-item-condensed-preview-line is-current");o(H,"span","","rte-ai-review-item-condensed-preview-label","Current"),Tn(H,"current",d,w);var x=o(y,"div","","rte-ai-review-item-condensed-preview-line is-result");if(o(x,"span","","rte-ai-review-item-condensed-preview-label","Suggested"),Tn(x,"result",p,w),m){var R=o(y,"div","","rte-ai-review-item-condensed-reason");o(R,"span","","rte-ai-review-item-condensed-reason-label","Why"),o(R,"div","","rte-ai-review-item-condensed-reason-copy",m)}if(u&&u.pills&&u.pills.length){var C=o(y,"div","","rte-ai-review-item-condensed-glance");o(C,"div","","rte-ai-review-item-condensed-glance-title","Change at a glance");for(var P=o(C,"div","","rte-ai-review-item-condensed-glance-meta"),T=0;T<u.pills.length;T++){var D=u.pills[T];o(P,"span","","rte-ai-review-item-glance-pill is-"+D.kind,D.text)}u.detail&&o(C,"div","","rte-ai-review-item-condensed-glance-detail",u.detail)}ed(y,a);var F=o(y,"div","","rte-ai-review-item-condensed-entry");o(F,"div","","rte-ai-review-item-condensed-entry-title","Review handoff");var M=o(F,"div","","rte-ai-review-item-condensed-open");return o(M,"span","","rte-ai-review-item-condensed-open-label","Enter target"),o(M,"span","","rte-ai-review-item-condensed-open-pill"),o(F,"div","","rte-ai-review-item-condensed-entry-detail"),Ln(F,t,r),vo(F,t,r),td(y,n),y}function ad(e,t,r,i,a,n,l){var u=!!(e.accepted||e.rejected||e.stale),d=z(),p=ci(),m=Pt(p),w=p?{id:"undo-last",label:m.actionLabel,focusActionLabel:Tf(p,d)}:null;if(r!=="all"&&!t){for(var y=[],v=[],h=[],_=l||[],b=n||{},H=0;H<_.length;H++){var x=_[H];if(!(!x||x.value==="all"||x.value===r)){var R=b[x.value]||0;if(R){var C=ir(x.value,""),P=C?me(C):null,T=P?Ye(P.originalText||P.resultText||"",84):"",D=Zc(P),F=so(P),M=oo(P),V=P?Nr(P):"",ve=P&&P.language?ot(P.language):"",X=mi(P);h.push(x.label+" ("+R+")"),y.push({id:"go-type",label:"Go to "+x.label+" ("+R+")",typeValue:x.value,suggestionId:C,focusAction:d,focusActionLabel:Ge(P,d)}),T&&v.push({label:x.label+" next",text:T,typeValue:x.value,suggestionId:C,actionLabel:"Go to "+x.label+" ("+R+")",focusAction:d,pendingCountLabel:R+" pending",changeLabel:F,impactLabel:M,focusActionLabel:Ge(P,d),scopeLabel:V,languageLabel:ve,resultText:D,reasonText:X})}}}var j=Me(r);return{title:j+" queue complete",detail:e.pending?"No pending "+j.toLowerCase()+" suggestions remain. Continue into another AI queue, switch back to all types, or review resolved items.":"No pending "+j.toLowerCase()+" suggestions remain, and the overall AI review queue is complete.",announceMessage:e.pending?h.length===1?j+" queue complete. Next queue: "+h[0]+".":h.length>1?j+" queue complete. Next queues available: "+h.join(", ")+".":j+" queue complete. Pending AI review remains in other queues.":j+" queue complete. Overall AI review queue complete.",previewItems:v,actions:y.concat([e.pending&&a?{id:"next-overall",label:"Next pending overall",suggestionId:a,focusAction:d,focusActionLabel:Ge(me(a),d)}:null,w,{id:"all-types",label:c.__aiT?c.__aiT("air_alltypes","All types"):"All types"},u&&!i?{id:"show-resolved",label:"Show resolved"}:null,{id:"open-chat",label:"AI Chat"}])}}return e.pending?{title:"No suggestions in this view",detail:"Suggestions from Ask AI or the chat panel stay here until you accept or reject them.",announceMessage:"",actions:[w,r!=="all"?{id:"all-types",label:c.__aiT?c.__aiT("air_alltypes","All types"):"All types"}:null,u&&!i?{id:"show-resolved",label:"Show resolved"}:null,{id:"open-chat",label:"AI Chat"}]}:{title:"Review queue complete",detail:u?"All AI suggestions have been reviewed. You can inspect resolved items or open AI Chat to generate more suggestions.":"There are no pending AI suggestions right now. Open AI Chat to create a new review pass.",announceMessage:u?"Review queue complete. All AI suggestions have been reviewed.":"Review queue complete. No pending AI suggestions remain.",actions:[w,u&&!i?{id:"show-resolved",label:"Show resolved"}:null,{id:"open-chat",label:"AI Chat"}]}}function ho(e,t,r){return!e||!e.total?"No suggestions":r!=="all"&&t>0?Me(r)+" queue":e.pending>0?"Reviewing":e.stale>0?"Needs refresh":"Queue complete"}function nd(e,t,r,i){return!e||!e.total?"Ask AI to create a review queue.":i&&i.total&&i.index?"Item "+i.index+" of "+i.total+" is active now.":r!=="all"&&t>0?t+" "+Me(r).toLowerCase()+" item"+(t===1?"":"s")+" ready to review.":e.pending>0?e.pending+" pending item"+(e.pending===1?"":"s")+" ready for review.":"Everything in this queue has been reviewed for now."}function ld(e,t,r,i){if(!e||!e.total)return"Use Ask AI, AI Chat, or inline review actions to generate reviewable changes.";var a=[];return r!=="all"?a.push("Showing only "+Me(r).toLowerCase()+" suggestions."):a.push("Showing every AI suggestion in this editor."),i&&i.count?a.push(i.count+" shared update"+(i.count===1?"":"s")+" waiting."):e.stale>0?a.push(e.stale+" suggestion"+(e.stale===1?"":"s")+" may need refresh."):e.pending>0&&r!=="all"&&t!==e.pending&&a.push(e.pending+" total pending across all queues."),a.join(" ")}function sd(e,t,r){return e?e.status==="pending"&&r?"Opened from queue switcher":e.status==="pending"&&t?"Ready to review now":e.status==="accepted"?"Accepted change":e.status==="rejected"?"Rejected change":e.status==="stale"?"Needs refresh":Sa(e.status):"AI suggestion"}function od(e,t,r,i){if(!e)return"";var a=[];e.status==="pending"&&t?a.push("This is the active item in the current queue."):e.status==="pending"&&r?a.push("This item was opened from the queue-complete handoff."):e.status==="stale"?a.push("Review the latest editor text before deciding."):(e.status==="accepted"||e.status==="rejected")&&a.push("This decision stays in history until you reopen it.");var n=e.sourceLabel||(e.snapshot&&e.snapshot.hasSelection?"Selection suggestion":"Document suggestion");return n&&a.push(n+"."),i&&a.push(i>1?i+" shared updates are waiting.":"A shared update is waiting."),a.join(" ")}function ud(e,t){var r="";e?r=t?"Press Enter to "+e+". J/K or Left/Right switch queues. Home/End jump queues. Tab for more actions.":"Press Enter to "+e+". Tab for more actions.":r="Press Tab for available actions.";var i=Pt(),a=qt();return ar()?r.replace(/\.$/,"")+". Press U to "+i.shortcutLabel+"."+(nr()?" Press Shift+U to "+a.shortcutLabel+".":""):nr()?r.replace(/\.$/,"")+". Press Shift+U to "+a.shortcutLabel+".":r}function cd(e,t){t=t||{};var r=Pt(),i=qt();if(!e){var a=[];return ar()&&a.push("U "+r.shortcutLabel),nr()&&a.push("Shift+U "+i.shortcutLabel),a.push("Esc close"),"Shortcuts: "+a.join(", ")}var n=["Enter "+e];return t.queueSwitcher&&(n.push("J/K or Left/Right switch queues"),n.push("Home/End jump queues")),ar()&&n.push("U "+r.shortcutLabel),nr()&&n.push("Shift+U "+i.shortcutLabel),n.push("Tab more actions"),n.push("Esc close"),"Shortcuts: "+n.join(", ")}function go(e,t){t=t||{};var r=["Enter activates "+(e||"this action")+(t.focusLabel?" and focuses "+t.focusLabel:"")+"."];t.queueSwitcher&&r.push("J/K or Left/Right switch queues. Home/End jump queues."),r.push("Tab moves to more actions.");var i=Pt(),a=qt(),n=r.join(" ");return ar()&&(n=n.replace(/\.$/,"")+" U undoes "+i.decisionLabel+" decision."),nr()&&(n=n.replace(/\.$/,"")+" Shift+U redoes "+a.decisionLabel+" decision."),n}function mo(e){e=e||{};var t=e.queueSwitcher?"Enter Space J K ArrowLeft ArrowRight Home End":"Enter Space";return jn(t)}function He(e){var t=Bc(),r=E(e||"");return!t||!r?!1:(s.__aiReviewStatusTimer&&clearTimeout(s.__aiReviewStatusTimer),t.textContent="",s.__aiReviewStatusTimer=setTimeout(function(){t&&(t.textContent=r)},30),!0)}function kl(){return"chat-"+new Date().getTime().toString(36)+"-"+Math.random().toString(36).slice(2,8)}function El(){var e=sn();return e?e+".ChatSessions":""}function dd(e){if(!e)return null;var t={role:e.role||"assistant",text:E(e.text||""),scope:e.scope==="selection"?"selection":"document",timestamp:e.timestamp||0,isError:!!e.isError};if(e.snapshot&&(t.snapshot={hasSelection:!!e.snapshot.hasSelection}),e.resolved)try{t.resolved=JSON.parse(JSON.stringify(e.resolved))}catch{}return t}function fd(e){return e?{role:e.role||"assistant",text:E(e.text||""),scope:e.scope==="selection"?"selection":"document",resolved:e.resolved||null,snapshot:e.snapshot?{hasSelection:!!e.snapshot.hasSelection}:null,timestamp:e.timestamp||0,isError:!!e.isError}:null}function _o(e){for(var t=[],r=e||[],i=Math.max(0,r.length-24),a=i;a<r.length;a++){var n=dd(r[a]);n&&t.push(n)}return t}function bo(e){for(var t=[],r=e||[],i=0;i<r.length;i++){var a=fd(r[i]);a&&t.push(a)}return t}function vd(e){for(var t=e||[],r=0;r<t.length;r++)if(t[r]&&t[r].role==="user"&&E(t[r].text||""))return rn(E(t[r].text||""),34);for(var i=0;i<t.length;i++)if(t[i]&&E(t[i].text||""))return rn(E(t[i].text||""),34);return"New chat"}function Pl(e){return!e||!e.id?null:{id:e.id,title:E(e.title||""),scope:e.scope==="selection"?"selection":"document",updatedAt:e.updatedAt||0,messageCount:e.messageCount||0,exchangeCount:e.exchangeCount||0,messages:_o(e.messages||[])}}function wo(e){return!e||!e.sessionId||!e.messages||!e.messages.length?null:{id:e.sessionId,title:vd(e.messages),scope:e.scope==="selection"?"selection":"document",updatedAt:new Date().getTime(),messageCount:e.messages.length,exchangeCount:qi(e.messages),messages:_o(e.messages)}}function ql(e){for(var t={version:"2026-05-31",activeSessionId:e&&e.activeSessionId?e.activeSessionId:"",sessions:[]},r=e&&e.sessions?e.sessions:[],i=0;i<r.length;i++){var a=Pl(r[i]);a&&t.sessions.push(a)}return t.sessions.sort(function(n,l){return(l.updatedAt||0)-(n.updatedAt||0)}),t.sessions.length>6&&(t.sessions=t.sessions.slice(0,6)),t}function Xi(){if(!s.__aiChatSessionStore){var e=null,t=El();if(t&&window.localStorage)try{e=JSON.parse(window.localStorage.getItem(t)||"null")}catch{}s.__aiChatSessionStore=ql(e||{})}return s.__aiChatSessionStore}function yo(){var e=El();if(s.__aiChatSessionStore=ql(Xi()),e&&window.localStorage)try{window.localStorage.setItem(e,JSON.stringify(s.__aiChatSessionStore))}catch{}return s.__aiChatSessionStore}function Yi(e){if(!e)return!1;var t=Xi(),r=[],i=wo(e);i&&r.push(i);for(var a=0;a<t.sessions.length;a++){var n=t.sessions[a];!n||n.id===e.sessionId||r.push(n)}return t.activeSessionId=e.sessionId||t.activeSessionId||"",t.sessions=r,yo(),!0}function pd(e){e=e||{};for(var t=parseInt(e.maxCount,10),r=Ao(rr(),t>0?t:6),i=[],a=0;a<r.length;a++){var n=Pl(r[a]);n&&(n.active=n.id===rr().sessionId,e.includeMessages!==!0&&delete n.messages,i.push(n))}return i}function hd(e,t){t=t||{};var r=xo(rr(),e,t.statusText||"Loaded a recent AI chat.");return r&&Pa()&&It(t.focusComposer!==!1),r}function gd(e){e=e||{};var t=El();if(s.__aiChatSessionStore=ql({}),t&&window.localStorage)try{window.localStorage.removeItem(t)}catch{}var r=rr();return r.messages=[],r.draft="",r.busy=!1,r.status=e.statusText||"Cleared AI chat history.",r.sessionVersion=(r.sessionVersion||0)+1,r.sessionId=kl(),Xi().activeSessionId=r.sessionId,yo(),Pa()&&It(e.focusComposer===!0),!0}function Ao(e,t){var r=Xi(),i=r.sessions.slice(),a=wo(e),n={},l=[],u=t||4;a&&(l.push(a),n[a.id]=!0);for(var d=0;d<i.length&&l.length<u;d++)!i[d]||n[i[d].id]||(l.push(Pl(i[d])),n[i[d].id]=!0);return l}function xo(e,t,r){if(!e||!t)return!1;for(var i=Xi(),a=null,n=0;n<i.sessions.length;n++)if(i.sessions[n]&&i.sessions[n].id===t){a=i.sessions[n];break}return a?(e.sessionId=a.id,e.messages=bo(a.messages||[]),e.draft="",e.scope=a.scope==="selection"?"selection":"document",e.busy=!1,e.status=r||"Loaded a recent AI chat.",e.sessionVersion=(e.sessionVersion||0)+1,Yi(e),!0):!1}function rr(){if(!s.__aiChatState){for(var e=ut(),t=Xi(),r=null,i=0;i<t.sessions.length;i++)if(t.sessions[i]&&t.sessions[i].id===t.activeSessionId){r=t.sessions[i];break}!r&&t.activeSessionId?s.__aiChatState={messages:[],draft:"",scope:e.hasSelection?"selection":"document",busy:!1,status:"",sessionVersion:0,sessionId:t.activeSessionId}:!r&&t.sessions.length&&(r=t.sessions[0]),s.__aiChatState||(s.__aiChatState=r?{messages:bo(r.messages||[]),draft:"",scope:r.scope==="selection"?"selection":"document",busy:!1,status:"",sessionVersion:0,sessionId:r.id}:{messages:[],draft:"",scope:e.hasSelection?"selection":"document",busy:!1,status:"",sessionVersion:0,sessionId:kl()})}return s.__aiChatState}function md(e,t){e&&(e.messages=[],e.draft="",e.busy=!1,e.status=t||"",e.sessionVersion=(e.sessionVersion||0)+1,e.sessionId=kl(),Yi(e))}function Ea(){var e=rr(),t=ut(),r=e.scope==="selection"&&t.hasSelection?"selection":"document",i=r==="selection"&&t.text||t.wholeText;return{scope:r,snapshot:t,source:i,summary:rn(i,180)||"The document is currently empty."}}function _d(){var e=document.activeElement;!e||e===document.body||e===document.documentElement||s.__aiChatPanel&&s.__aiChatPanel.contains&&s.__aiChatPanel.contains(e)||typeof e.focus=="function"&&(s.__aiChatReturnFocusNode=e)}function bd(e){if(e&&e.isConnected!==!1&&typeof e.focus=="function"&&!e.disabled){try{e.focus({preventScroll:!0})}catch{try{e.focus()}catch{}}if(document.activeElement===e)return!0}if(s&&typeof s.focus=="function")try{return s.focus(),!0}catch{}return!1}function Zi(e){e=e||{};var t=s.__aiChatReturnFocusNode||null;s.__aiChatPanel&&s.__aiChatPanel.parentNode&&s.__aiChatPanel.parentNode.removeChild(s.__aiChatPanel),s.__aiChatShell&&s.__aiChatShell.classList&&s.__aiChatShell.classList.remove("rte-ai-chat-host"),s.__aiChatShell&&s.__aiChatShell.style&&(s.__aiChatShell.style.minHeight=typeof s.__aiChatOriginalMinHeight=="string"?s.__aiChatOriginalMinHeight:""),s.__aiChatPanel=null,s.__aiChatShell=null,s.__aiChatOriginalMinHeight=null,e.preserveReturnFocus||(s.__aiChatReturnFocusNode=null),e.restoreFocus&&bd(t)}function wd(e){if(!e||!e.contains||!document.activeElement||!e.contains(document.activeElement))return null;var t=document.activeElement;if(t.classList&&t.classList.contains("rte-ai-chat-input"))return{kind:"composer"};var r=t.getAttribute("data-rte-ai-chat-header-action");if(r)return{kind:"header-action",value:r};var i=t.getAttribute("data-rte-ai-chat-scope-target");if(i)return{kind:"scope",value:i};var a=t.getAttribute("data-rte-ai-chat-prompt-id");if(a)return{kind:"quick",value:a};var n=t.getAttribute("data-rte-ai-chat-session-id");if(n)return{kind:"session",value:n};var l=t.getAttribute("data-rte-ai-chat-action");if(l){if(t.closest&&t.closest(".rte-ai-chat-composer-actions"))return{kind:"composer-action",value:l};var u=t.closest?t.closest(".rte-ai-chat-message"):null;if(u)return{kind:"message-action",value:l,exchangeIndex:u.getAttribute("data-rte-ai-chat-exchange-index")||"",threadRole:u.getAttribute("data-rte-ai-chat-thread-role")||""}}return t===e?{kind:"panel"}:null}function yd(e,t){if(!e||!t||!t.kind)return null;var r=0,i;switch(t.kind){case"composer":return e.querySelector(".rte-ai-chat-input");case"panel":return e;case"header-action":for(i=e.querySelectorAll("[data-rte-ai-chat-header-action]"),r=0;r<i.length;r++)if((i[r].getAttribute("data-rte-ai-chat-header-action")||"")===t.value)return i[r];return null;case"scope":for(i=e.querySelectorAll("[data-rte-ai-chat-scope-target]"),r=0;r<i.length;r++)if((i[r].getAttribute("data-rte-ai-chat-scope-target")||"")===t.value)return i[r];return null;case"quick":for(i=e.querySelectorAll("[data-rte-ai-chat-prompt-id]"),r=0;r<i.length;r++)if((i[r].getAttribute("data-rte-ai-chat-prompt-id")||"")===t.value)return i[r];return null;case"session":for(i=e.querySelectorAll("[data-rte-ai-chat-session-id]"),r=0;r<i.length;r++)if((i[r].getAttribute("data-rte-ai-chat-session-id")||"")===t.value)return i[r];return null;case"composer-action":for(i=e.querySelectorAll(".rte-ai-chat-composer-actions [data-rte-ai-chat-action]"),r=0;r<i.length;r++)if((i[r].getAttribute("data-rte-ai-chat-action")||"")===t.value)return i[r];return null;case"message-action":for(i=e.querySelectorAll(".rte-ai-chat-message [data-rte-ai-chat-action]"),r=0;r<i.length;r++){var a=i[r].closest?i[r].closest(".rte-ai-chat-message"):null;if(a&&(i[r].getAttribute("data-rte-ai-chat-action")||"")===t.value&&(a.getAttribute("data-rte-ai-chat-exchange-index")||"")===(t.exchangeIndex||"")&&(a.getAttribute("data-rte-ai-chat-thread-role")||"")===(t.threadRole||""))return i[r]}return null;default:return null}}function Ad(e,t){var r=yd(e,t);if(!r||r.disabled)return!1;try{r.focus({preventScroll:!0})}catch{try{r.focus()}catch{return!1}}return document.activeElement===r}function xd(e){if(!e||!e.querySelector)return null;var t=e.querySelector(".rte-ai-chat-feed");if(!t||typeof t.scrollTop>"u")return null;var r=Math.max(0,(t.scrollHeight||0)-(t.clientHeight||0)),i=Math.max(0,t.scrollTop||0);return{scrollTop:i,stickToBottom:r<=0||r-i<=24}}function Sd(e,t){if(!e||!t||typeof e.scrollTop>"u")return!1;if(t.stickToBottom)return e.scrollTop=e.scrollHeight,!0;var r=Math.max(0,(e.scrollHeight||0)-(e.clientHeight||0));return e.scrollTop=Math.max(0,Math.min(t.scrollTop||0,r)),!0}function Pa(){return!!(s.__aiChatPanel&&s.__aiChatPanel.isConnected)}function ea(e){return e=e||{},Yr(),Pa()||_d(),It(!!e.focusComposer)}function Td(e){return s.__aiChatPanel&&s.__aiChatPanel.isConnected?(Zi({restoreFocus:!0}),!1):ea(e)}function Il(e){var t=rr(),r=E(e||t.draft);if(!r||t.busy)return!1;var i=Ea();t.scope=i.scope,t.draft="",t.busy=!0,t.status=i.scope==="selection"?"Thinking about the current selection...":"Thinking about the current document...";var a=t.sessionVersion||0;return t.messages.push({role:"user",text:r,scope:i.scope,snapshot:i.snapshot,timestamp:new Date().getTime()}),Yi(t),It(!1),an("chat-panel",{snapshot:i.snapshot,source:i.source,prompt:r,mode:"chat",scope:i.scope}).then(function(n){(t.sessionVersion||0)===a&&(t.busy=!1,t.status=n&&n.operations&&n.operations.length?"AI response ready. Preview or apply the suggested change from the chat.":"AI response ready.",t.messages.push({role:"assistant",text:n&&(n.message||n.result)?n.message||n.result:"No response returned.",scope:i.scope,resolved:n,snapshot:i.snapshot,timestamp:new Date().getTime()}),Yi(t),Pa()&&It(!1))}).catch(function(n){console.error("AI chat failed",n),(t.sessionVersion||0)===a&&(t.busy=!1,t.status="AI chat failed.",t.messages.push({role:"assistant",text:"I could not finish that request. Try again or shorten the prompt.",scope:i.scope,isError:!0,timestamp:new Date().getTime()}),Yi(t),Pa()&&It(!1))}),!0}function qa(e,t){if(!e||!e.resolved)return!1;var r=ut(),i=e.resolved,a=$t(i),n=!1,l={preview:!0,selection:!0};if(l[t]&&!r.hasSelection)return rr().status=t==="preview"?"Select text before previewing this chat suggestion inline.":"Select text before replacing selection from chat.",It(!1),!1;if(t==="plan"&&i&&i.operations&&i.operations.length)for(var u=0;u<i.operations.length;u++){var d=i.operations[u];if(d&&(d.type==="preview-suggestion"||d.type==="replace-selection")&&!r.hasSelection)return rr().status="Select text before applying this selection-based chat suggestion.",It(!1),!1}if(t==="plan")n=vr(i,{snapshot:r});else if(a)if(t==="preview"){var p=Kr(a,"selection-preview",i,i.request||null,i.action||null);p&&p.operations&&p.operations[0]&&!p.operations[0].reason&&(p.operations[0].reason=_a(i)),n=vr(p,{snapshot:r})}else t==="selection"?n=vr(Kr(a,"selection",i,i.request||null,i.action||null),{snapshot:r}):t==="insert"?n=vr(Kr(a,"insert",i,i.request||null,i.action||null),{snapshot:r}):t==="document"&&(n=vr(Kr(a,"document",i,i.request||null,i.action||null),{snapshot:r}));return n&&(rr().status=t==="preview"?"Previewed the AI suggestion inline from chat.":"Applied the AI chat suggestion.",It(!1)),n}function So(e){var t=E(e||"");return t?navigator.clipboard&&navigator.clipboard.writeText?navigator.clipboard.writeText(t).then(function(){return!0}).catch(function(){return To(t)}):Promise.resolve(To(t)):Promise.resolve(!1)}function To(e){if(!document||!document.body||!document.createElement)return!1;var t=document.activeElement&&document.activeElement!==document.body?document.activeElement:null,r=null,i=null;t&&typeof t.selectionStart=="number"&&typeof t.selectionEnd=="number"&&(r=t.selectionStart,i=t.selectionEnd);var a=document.createElement("textarea");a.value=e,a.setAttribute("readonly","readonly"),a.style.position="fixed",a.style.opacity="0",a.style.pointerEvents="none",a.style.left="-9999px",a.style.top="0",document.body.appendChild(a),a.focus(),a.select();var n=!1;try{n=!!document.execCommand("copy")}catch{n=!1}if(document.body.removeChild(a),t&&t.focus&&t.isConnected!==!1){try{t.focus({preventScroll:!0})}catch{try{t.focus()}catch{}}if(r!==null&&i!==null&&t.setSelectionRange)try{t.setSelectionRange(r,i)}catch{}}return n}function Ld(e){return So(e&&e.text?e.text:"").then(function(t){var r=rr();return r.status=t?"Copied the AI response.":"Could not copy the AI response.",It(!1),t})}function Lo(e){return e&&e.isError?"Issue":e&&e.role==="user"?"You":"AI"}function Rd(e){return e==="request"?"Request":e==="response"?"Response":""}function Ei(e){return e&&e.scope==="selection"?"Selection":"Document"}function Cd(e){if(!e)return"";if(e.isError)return"Needs retry";if(e.role==="user")return"Prompt";var t=e.resolved||null,r=t&&t.operations?t.operations:[],i=t?$t(t):"";return r.length?"Reviewable change":i?"Draft":"Answer"}function Jf(e){if(!e)return"";var t=Ei(e).toLowerCase();if(e.isError)return"This request hit an issue. Try again or adjust the prompt.";if(e.role==="user")return"Sent with "+t+" context.";var r=e.resolved||null,i=r&&r.operations?r.operations:[],a=r?$t(r):"";return i.length?"Ready for preview, apply, or insert from the "+t+" context.":a?"Drafted from the "+t+" context.":"Response grounded in the "+t+" context."}function kd(e){if(!e||e.isError||!e.snapshot)return null;var t=e.scope==="selection"?e.snapshot.text||e.snapshot.wholeText||"":e.snapshot.wholeText||"";if(t=E(t||""),!t)return null;var r=Ho(t);return{title:e.scope==="selection"?"Using current selection":"Using current document",scopeLabel:e.scope==="selection"?"Selection context":"Document context",wordLabel:ja(t)+" words",paragraphLabel:r>1?r+" paragraphs":"",copy:Ye(t,180)}}function Vf(e){if(!e)return"";var t=[];return e.title&&t.push(e.title),e.scopeLabel&&t.push(e.scopeLabel),e.wordLabel&&t.push(e.wordLabel),e.paragraphLabel&&t.push(e.paragraphLabel),e.copy&&t.push(e.copy),fe(t)}function Ro(e){if(!e)return"";if(e.isError)return"Reply needs retry";if(e.role==="user")return"Prompt sent";var t=e.resolved||null,r=t&&t.operations?t.operations:[],i=t?$t(t):"";return r.length?"Reviewable change prepared":i?"Draft prepared":"Answer ready"}function Ml(e){if(!e)return"";var t=Ei(e).toLowerCase();if(e.isError)return"This "+t+" request hit an issue. Adjust the prompt or try again.";if(e.role==="user")return"Waiting on AI for the current "+t+" context.";var r=e.resolved||null,i=r&&r.operations?r.operations:[],a=r?$t(r):"";return i.length?"Preview, replace, or insert this "+t+" change from the latest reply.":a?"Reuse or adapt this drafted "+t+" response.":"Read the answer grounded in the current "+t+" context."}function ta(e,t){for(var r=e&&e.resolved?e.resolved:null,i=r&&r.operations?r.operations:[],a=r?$t(r):"",n=t&&typeof t.hasSelection=="boolean"?!!t.hasSelection:!!(e&&e.snapshot&&e.snapshot.hasSelection),l=!1,u=0;u<i.length;u++){var d=i[u];if(d&&(d.type==="preview-suggestion"||d.type==="replace-selection")){l=!0;break}}return{operations:i,resultText:a,hasSelection:n,selectionDependentPlan:l,canApplyPlan:!!i.length&&(!l||n),canPreview:!!a&&n,canReplaceSelection:!!a&&n,canInsert:!!a,canReplaceDocument:!!a&&!n}}function Ia(e,t){if(!e||!e.resolved)return null;var r=ta(e,t);return r.operations.length&&r.canPreview?{title:"Best next step: Preview",detail:"Check the inline diff first, then replace the selection or apply the prepared plan if it looks right."}:r.operations.length&&r.canApplyPlan?{title:"Best next step: Apply the prepared plan",detail:"Run the structured change directly or use the insert and document actions below if you want a different handoff."}:r.operations.length&&r.canInsert?{title:"Best next step: Insert below",detail:"Select text to preview or replace this change inline, or insert the prepared draft below the current content."}:r.resultText&&r.canReplaceSelection?{title:"Best next step: Replace or preview",detail:"Use the prepared draft to preview inline, replace the selection, or insert a follow-up below."}:r.resultText?{title:"Best next step: Reuse this draft",detail:"Insert the draft below or replace the full document, depending on how broad the change should be."}:null}function ra(e,t){if(!e||!e.resolved)return"";var r=ta(e,t);return r.operations.length&&r.canPreview?"preview":r.operations.length&&r.canApplyPlan?"apply":r.operations.length&&r.canInsert?"insert":r.resultText&&r.canReplaceSelection?"selection":r.resultText&&r.canInsert?"insert":""}function Br(e){return e==="preview"?"Preview":e==="apply"?"Apply":e==="selection"?"Replace selection":e==="insert"?"Insert below":e==="document"?"Replace document":""}function Ed(e){return e==="copy"?"Copy text":Br(e)}function Co(e,t,r){var i=ta(t,r);return e==="copy"?"Copy this prepared AI reply without changing the document.":e==="apply"?"Run the prepared plan directly in the editor.":e==="preview"?i.hasSelection?"Show this change inline in the editor before deciding it.":"Select text to preview this change inline in the editor.":e==="selection"?i.hasSelection?"Replace the current selection with this prepared draft.":"Select text before replacing selection with this prepared draft.":e==="insert"?i.hasSelection?"Insert this prepared draft below the current selection.":"Insert this prepared draft below the current content.":e==="document"?"Replace the full document with this prepared draft.":""}function ia(e,t,r,i,a){if(e){var n=Ed(t)||(e.innerText||e.textContent||"").replace(/\s+/g," ").trim()||"Action",l=Co(t,r,a),u=!!(t&&i&&t===i),d=[n];l&&d.push(l),u&&d.push("Recommended next step."),e.setAttribute("aria-label",fe(d)),e.title=l?n+" - "+l+(u?" Recommended next step.":""):n+(u?" - Recommended next step.":"")}}function kn(e){return e==="apply"||e==="preview"||e==="selection"?"primary":e==="insert"||e==="document"?"secondary":""}function Pd(e,t,r,i){if(e==="utility")return"Copy this prepared reply without changing the document.";if(!t||!t.resolved)return"";var a=ta(t,i);if(e==="primary")return r==="preview"?"Check the inline diff first, then apply or replace the selection from this group.":r==="apply"?"Run the prepared plan directly, or switch to the document handoff actions below if you want a different outcome.":r==="selection"?"Replace the selection first, or preview the inline diff before writing this change back.":a.operations.length?"Run the prepared plan directly from this group.":a.resultText&&a.hasSelection?"Preview the draft or write it back into the current selection from this group.":"Use this group to preview or apply the prepared change.";if(e==="secondary"){if(a.resultText&&a.hasSelection)return"Insert this prepared draft below the selection when you want a follow-up instead of a replacement.";if(r==="insert")return"Insert this draft below first, or replace the full document if the whole page should change.";if(r==="document")return"Replace the full document, or insert this draft below if you want a lighter handoff.";if(a.resultText)return"Insert this prepared draft below or replace the full document without opening inline review."}return""}function qd(e,t,r){var i=kn(r);if(i&&e===i)return"Recommended next step";if(e==="utility")return"Copy only";if(!t||!t.resolved)return e==="primary"?"Preview and apply":e==="secondary"?"Other ways to use":"";var a=t.resolved||null,n=a&&a.operations?a.operations:[],l=a?$t(a):"";if(e==="primary")return n.length?"Apply in editor":l?"Use this draft":"Preview and apply";if(e==="secondary"){if(n.length)return"Other ways to apply";if(l)return"Other ways to use this draft"}return""}function En(e,t,r,i){var a={title:"",badge:"",recommended:!1,detail:""};a.title=qd(e,r,t);var n=kn(t);return n&&e===n&&(a.badge=Br(t),a.recommended=!!a.badge),a.detail=Pd(e,r,t,i),a}function Hl(e,t,r){if(!e||!t||!e.getElementsByTagName("button").length)return null;e.setAttribute("data-rte-ai-chat-group-key",r||""),t.recommended&&e.setAttribute("data-rte-ai-chat-group-recommended","true");var i="rte-ai-chat-message-action-group-header";t.recommended&&(i+=" is-recommended");var a=o(e,"div","",i);if(o(a,"div","","rte-ai-chat-message-action-group-title",t.title||""),t.badge&&o(a,"span","","rte-ai-chat-message-action-group-badge",t.badge),e.firstChild!==a&&e.insertBefore(a,e.firstChild),t.detail){var n=o(e,"div","","rte-ai-chat-message-action-group-detail",t.detail);a.nextSibling!==n&&e.insertBefore(n,a.nextSibling)}return a}function Id(e,t){if(!(!e||!e.querySelectorAll)){var r=kn(t),i=e.querySelectorAll(".rte-ai-chat-message-action-group");if(!(!i||!i.length)){for(var a={},n=0;n<i.length;n++){var l=i[n],u=l.getAttribute("data-rte-ai-chat-group-key")||"";u&&(a[u]=l)}var d=[];r&&d.push(r);for(var p=["primary","secondary","utility"],m=0;m<p.length;m++)d.indexOf(p[m])===-1&&d.push(p[m]);for(var w=0;w<d.length;w++)a[d[w]]&&e.appendChild(a[d[w]])}}}function Md(e,t){if(!(!e||!t||!e.querySelector)){var r=kn(t);if(r){var i=e.querySelector('.rte-ai-chat-message-action-group[data-rte-ai-chat-group-key="'+r+'"]');if(!(!i||!i.querySelector)){var a=i.querySelector('.rte-ai-chat-action-button[data-rte-ai-chat-action="'+t+'"]');if(a){var n=i.querySelector(".rte-ai-chat-message-action-group-header"),l=i.querySelector(".rte-ai-chat-action-button");if(!(!l||l===a)){if(n&&n.nextSibling){i.insertBefore(a,n.nextSibling);return}i.insertBefore(a,l)}}}}}}function Hd(e,t){if(!e)return"";var r=[];t&&t.title&&r.push(t.title+" group"),t&&t.recommended&&t.badge&&r.push(t.badge+" recommended"),t&&t.detail&&r.push(t.detail);for(var i=e.querySelectorAll?e.querySelectorAll(".rte-ai-chat-action-button"):[],a=[],n=0;n<i.length;n++){var l=(i[n].innerText||i[n].textContent||"").replace(/\s+/g," ").trim();l&&a.push(l)}return a.length&&r.push("Actions: "+a.join(", ")),fe(r)}function Dd(e,t,r,i){if(!(!e||!e.querySelectorAll)){var a=Br(t);e.setAttribute("role","group"),e.setAttribute("aria-label",a?c.__aiT?c.__aiT("aic_actionsrec","AI chat actions. Recommended next step: {0}.",a):"AI chat actions. Recommended next step: "+a+".":c.__aiT?c.__aiT("aic_actions","AI chat actions"):"AI chat actions");for(var n=e.querySelectorAll(".rte-ai-chat-message-action-group"),l=0;l<n.length;l++){var u=n[l],d=u.getAttribute("data-rte-ai-chat-group-key")||"",p=u.querySelector?u.querySelector(".rte-ai-chat-action-button"):null,m=En(d,t,r,i);if(!p){u.removeAttribute("role"),u.removeAttribute("aria-label");continue}u.setAttribute("role","group");var w=Hd(u,m);w?u.setAttribute("aria-label",w):u.removeAttribute("aria-label")}}}function ko(e){return!e||!e.snapshot?"":e.scope==="selection"?e.snapshot.text||e.snapshot.wholeText||"":e.snapshot.wholeText||""}function jd(e){return Ye(ko(e),120)}function Ma(e){if(!e||!e.resolved)return null;var t=e.resolved.request&&e.resolved.request.mode?Be(e.resolved.request.mode):"";return Ta({originalText:ko(e),resultText:$t(e.resolved),suggestionType:t,snapshot:e.snapshot||null,scope:e.scope||""})}function Od(e,t){if(!e||!e.resolved)return null;var r=Ye($t(e.resolved),120);if(!r)return null;var i=jd(e),a=e.resolved.operations||[],n=a.length?_s(a[0]):null,l=a.length,u=n&&n.title?n.title:e.scope==="selection"?"Selection draft":"Document draft",d=ra(e,t),p=Ia(e,t),m=Fd(e,d,t),w=Ma(e);return{title:n&&n.title?n.title:"Prepared draft",sourceText:i,resultText:r,reasonText:Ye(_a(e.resolved),110),statusLabel:l?"Ready to review":"Draft ready",scopeLabel:e.scope==="selection"?"Selection draft":"Document draft",stepLabel:(l||1)+" step"+((l||1)===1?"":"s"),targetLabel:u,diffParts:i&&i!==r?Sn(i,r):null,changeGlance:w,planLeadTitle:p?"Best next step":"",planLeadLabel:d?Br(d):"",planLeadDetail:p?p.detail:"",planItems:m.slice(0,3),planFollowupTitle:Gd(e,m),hiddenPlanCount:Math.max(0,m.length-3)}}function Gd(e,t){if(!t||!t.length)return"";var r=e&&e.resolved?e.resolved:null,i=r&&r.operations?r.operations:[];return i.length?"Other ways to apply this change":"Other ways to use this draft"}function Ud(e,t,r){if(!t)return null;var i=Br(t);return i?{label:i,detail:Co(t,e,r)}:null}function Wf(e){if(!e)return"";var t=[];return e.label&&t.push(e.label),e.detail&&t.push(e.detail),fe(t)}function Fd(e,t,r){if(!e||!e.resolved)return[];var i=ta(e,r),a=[];i.canApplyPlan&&a.push("apply"),i.canPreview&&a.push("preview"),i.canReplaceSelection&&a.push("selection"),i.canInsert&&a.push("insert"),i.canReplaceDocument&&a.push("document");for(var n=[],l=0;l<a.length;l++){var u=a[l];if(!(!u||u===t)){var d=Ud(e,u,r);if(!(!d||!d.label)){for(var p=!1,m=0;m<n.length;m++)if(n[m]&&n[m].label===d.label){p=!0;break}p||n.push(d)}}}return n}function Bf(e){if(!e)return"";var t=[];if(e.title&&t.push(e.title),e.statusLabel&&t.push(e.statusLabel),e.scopeLabel&&t.push(e.scopeLabel),e.stepLabel&&t.push(e.stepLabel),e.targetLabel&&t.push(e.targetLabel),t.push("Proposed edit"),t.push("Current and suggested text"),e.sourceText&&e.sourceText!==e.resultText&&(t.push("Current"),t.push(e.sourceText)),t.push("Suggested"),t.push(e.resultText),e.reasonText&&(t.push("Why this change"),t.push(e.reasonText)),e.changeGlance){if(e.changeGlance.title&&t.push(e.changeGlance.title),e.changeGlance.pills&&e.changeGlance.pills.length)for(var r=0;r<e.changeGlance.pills.length;r++)e.changeGlance.pills[r]&&e.changeGlance.pills[r].text&&t.push(e.changeGlance.pills[r].text);e.changeGlance.detail&&t.push(e.changeGlance.detail)}if(e.planLeadTitle||e.planLeadLabel||e.planLeadDetail||e.planItems&&e.planItems.length){if(t.push("What happens next"),e.planLeadTitle&&t.push(e.planLeadTitle),e.planLeadLabel&&t.push(e.planLeadLabel),e.planLeadDetail&&t.push(e.planLeadDetail),e.planFollowupTitle&&t.push(e.planFollowupTitle),e.planItems&&e.planItems.length)for(var i=0;i<e.planItems.length;i++){var a=e.planItems[i];a&&(a.label&&t.push(a.label),a.detail&&t.push(a.detail))}e.hiddenPlanCount&&t.push("+"+e.hiddenPlanCount+" more")}return fe(t)}function Pn(e){var t=E(e||"");return t?t.length<=92?t:t.substring(0,89).replace(/\s+\S*$/,"")+"...":""}function Dl(e){var t=e&&e.id?String(e.id).toLowerCase():"",r=e&&e.label?String(e.label).toLowerCase():"",i=e&&e.prompt?String(e.prompt).toLowerCase():"",a=t+" "+r+" "+i;return/translate|spanish|french|german|italian|portuguese|japanese/.test(a)?"Language":/proofread|review|cleaner|grammar/.test(a)?"Review":/heading|title|subheading|structure/.test(a)?"Structure":/expand|supporting paragraph|detail/.test(a)?"Expand":/summarize|summary/.test(a)?"Summary":"Starter"}function Nd(e){var t=Dl(e).toLowerCase().replace(/[^a-z0-9]+/g,"-");return t||"starter"}function Eo(e){if(!e||!e.text)return"Custom";var t=Dl({prompt:e.text||""});return t==="Starter"?"Custom":t}function Po(e){return Eo(e)+" request"}function Kd(e,t){if(!e||!e.length||typeof t!="number")return null;for(var r=t-1;r>=0;r--)if(e[r]&&e[r].role==="user"&&!e[r].isError)return e[r];return null}function zd(e,t){var r=Kd(e,t);return r?{title:"Responding to "+Po(r),scopeLabel:Ei(r),detail:"Latest user turn",promptText:r.text||""}:null}function Xf(e,t,r){if(!e||e.isError||e.role!=="user")return"";var i=["What you asked"],a=Po(e);a&&i.push(a);var n=Ei(e);n&&i.push(n);var l=Da(t,r);return l&&i.push(l),e.text&&i.push(e.text),fe(i)}function Yf(e,t){if(!e)return"";var r=[];return e.title&&r.push(e.title),e.scopeLabel&&r.push(e.scopeLabel),e.detail&&r.push(e.detail),t&&r.push(t),e.promptText&&r.push(e.promptText),fe(r)}function Qd(e,t,r){if(!e||typeof t!="number"||!e[t])return"";var i=e[t],a=[],n=Lo(i),l=Rd(Pi(e,t)),u=Ei(i),d=Cd(i),p=Da(e,t),m=Ro(i),w=Ml(i);if(n&&a.push(n),a.push("Turn "+(t+1)),l&&a.push(l),u&&a.push(u),d&&a.push(d),p&&a.push(p),qn(e,t)&&a.push("Current exchange"),m&&a.push(m),w&&a.push(w),i.role==="user"&&!i.isError){a.push("What you asked"),i.text&&a.push(Pn(i.text)||i.text);var y=kd(i);y&&(y.title&&a.push(y.title),y.wordLabel&&a.push(y.wordLabel),y.paragraphLabel&&a.push(y.paragraphLabel))}else if(i.role==="assistant"&&!i.isError){var v=zd(e,t);v&&v.title&&a.push(v.title),v&&v.promptText&&a.push(Pn(v.promptText)||v.promptText);var h=Ia(i,r);h&&h.title&&a.push(h.title)}return fe(a)}function Zf(e){if(!e)return"";var t=[],r=e.isError?"Conversation issue":e.role==="user"?"User prompt":"Assistant response",i=Ro(e),a=Ml(e);return r&&t.push(r),i&&t.push(i),a&&t.push(a),fe(t)}function Pi(e,t){if(!e||typeof t!="number"||!e[t])return"";var r=e[t];if(r.isError)return"";if(r.role==="user"){var i=e[t+1];if(i&&i.role==="assistant"&&!i.isError)return"request"}if(r.role==="assistant"){var a=e[t-1];if(a&&a.role==="user"&&!a.isError)return"response"}return""}function Ha(e,t){if(!e||typeof t!="number"||t<0)return 0;for(var r=0,i=0;i<=t;i++)e[i]&&e[i].role==="user"&&!e[i].isError&&r++;return r}function Da(e,t){var r=Ha(e,t);return r?"Exchange "+r:""}function qn(e,t){var r=Ha(e,t),i=qi(e);return!!r&&r===i}function qo(e,t){if(!e||!e.length||typeof t!="number"||!e[t])return-1;var r=e[t];if(r.isError||r.role!=="user"||Pi(e,t)!=="request")return-1;for(var i=Ha(e,t),a=t+1;a<e.length;a++)if(!(!e[a]||e[a].isError)){if(e[a].role==="user")break;if(e[a].role==="assistant"&&Pi(e,a)==="response"&&Ha(e,a)===i)return a}return-1}function Io(e,t,r){if(!e||typeof t!="number"||!e[t])return null;var i=e[t];if(i.isError||i.role!=="user"||Pi(e,t)!=="request")return null;var a=qo(e,t),n=a>=0?e[a]:null,l=Eo(i),u="",d=null,p=[];if(n&&n.role==="assistant"&&!n.isError){var m=ra(n,r);u=Br(m),d=Ma(n),u&&p.push(u+" is the recommended next step."),d&&d.detail&&p.push(d.detail)}return{title:(l==="Custom"?"Custom":l)+" exchange",exchangeLabel:Da(e,t),scopeLabel:Ei(i),statusLabel:n&&n.role==="assistant"&&!n.isError?"Reply linked":"Waiting on reply",actionLabel:u,changeGlance:d,detail:p.join(" "),isCurrent:qn(e,t)}}function ev(e){if(!e)return"";var t=[];if(e.title&&t.push(e.title),e.exchangeLabel&&t.push(e.exchangeLabel),e.scopeLabel&&t.push(e.scopeLabel),e.statusLabel&&t.push(e.statusLabel),e.actionLabel&&(t.push("Best next step"),t.push(e.actionLabel)),e.changeGlance){if(t.push(e.changeGlance.title||"Change at a glance"),e.changeGlance.pills&&e.changeGlance.pills.length)for(var r=0;r<e.changeGlance.pills.length;r++)e.changeGlance.pills[r]&&e.changeGlance.pills[r].text&&t.push(e.changeGlance.pills[r].text);e.changeGlance.detail&&t.push(e.changeGlance.detail)}return e.isCurrent&&t.push("Current exchange"),e.detail&&t.push(e.detail),fe(t)}function $d(e,t,r){if(!e||typeof t!="number"||!e[t])return"";var i=e[t];if(i.isError||i.role!=="user"||Pi(e,t)!=="request")return"";var a=Io(e,t,r),n=qo(e,t),l=n>=0?Mo(e,n,r):null,u=["AI chat exchange"];if(a&&a.exchangeLabel&&u.push(a.exchangeLabel),a&&a.title&&u.push(a.title),a&&a.scopeLabel&&u.push(a.scopeLabel+" thread"),i.text&&(u.push("Request"),u.push(Pn(i.text))),l){if(l.statusLabel&&u.push(l.statusLabel),l.actionLabel&&(u.push("Best next step"),u.push(l.actionLabel)),l.changeGlance){if(u.push(l.changeGlance.title||"Change at a glance"),l.changeGlance.pills&&l.changeGlance.pills.length)for(var d=0;d<l.changeGlance.pills.length;d++)l.changeGlance.pills[d]&&l.changeGlance.pills[d].text&&u.push(l.changeGlance.pills[d].text);l.changeGlance.detail&&u.push(l.changeGlance.detail)}}else a&&a.statusLabel&&u.push(a.statusLabel);return a&&a.isCurrent&&u.push("Current exchange"),fe(u)}function Mo(e,t,r){if(!e||typeof t!="number"||!e[t])return null;var i=e[t];if(i.isError||i.role!=="assistant"||Pi(e,t)!=="response")return null;var a=i.resolved||null,n=a&&a.operations?a.operations:[],l=a?$t(a):"",u=ra(i,r),d=n.length?n.length:l?1:0,p=Ma(i),m=[];p&&p.detail&&m.push(p.detail);var w=(Ia(i,r)||{}).detail||Ml(i);w&&m.push(w);var y="Reply ready";return n.length?y="Ready to review":l&&(y="Draft ready"),{title:"Exchange outcome",detail:m.join(" "),exchangeLabel:Da(e,t),scopeLabel:Ei(i),statusLabel:y,stepLabel:d?d+" step"+(d===1?"":"s"):"",actionLabel:Br(u),changeGlance:p,isCurrent:qn(e,t)}}function tv(e){if(!e)return"";var t=[];if(e.title&&t.push(e.title),e.exchangeLabel&&t.push(e.exchangeLabel),e.statusLabel&&t.push(e.statusLabel),e.scopeLabel&&t.push(e.scopeLabel),e.stepLabel&&t.push(e.stepLabel),e.actionLabel&&t.push(e.actionLabel),e.changeGlance&&(t.push(e.changeGlance.title||"Change at a glance"),e.changeGlance.pills&&e.changeGlance.pills.length))for(var r=0;r<e.changeGlance.pills.length;r++)e.changeGlance.pills[r]&&e.changeGlance.pills[r].text&&t.push(e.changeGlance.pills[r].text);return e.isCurrent&&t.push("Current exchange"),e.detail&&t.push(e.detail),fe(t)}function ja(e){var t=E(e||"");return t?t.split(/\s+/).length:0}function Ho(e){var t=E(e||"");return t?t.split(/\n+/).filter(function(r){return!!r}).length:0}function Jd(e){return e&&e.scope==="selection"?"Selected passage":"Document snapshot"}function jl(e,t){var r=E(e&&e.draft?e.draft:"");if(!r||!t||!t.length)return null;for(var i=0;i<t.length;i++){var a=t[i];if(a&&E(a.prompt||"")===r)return a}return null}function Do(e,t){var r=E(e&&e.status?e.status:"");if(!r)return"";var i=t&&t.scope==="selection"?"selection":"document";return/^select text first to use selection scope\.?$/i.test(r)?i==="selection"?"Chat will use the current selection.":"Select text to switch AI Chat back to selection scope.":/^chat will use the current selection\.?$/i.test(r)?i==="selection"?"Chat will use the current selection.":"Selection scope is unavailable right now. Chat will use the whole document until you select text again.":/^chat will use the whole document\.?$/i.test(r)?"Chat will use the whole document.":e.status}function jo(e,t){if(e&&e.busy)return"busy";var r=E(Do(e,t)).toLowerCase();return r?/could not|issue|error|select text first/.test(r)?"error":/started|loaded|ready|will use|copied|previewed|applied/.test(r)?"ready":"idle":"idle"}function Vd(e,t,r){if(e&&e.busy)return"Thinking through the current "+(t&&t.scope==="selection"?"selection":"document")+"...";var i=Do(e,t);if(i)return i;var a=t&&t.scope==="selection"?"selection":"document";return r&&r.label?"Ready to run the "+r.label+" starter on the current "+a+".":E(e&&e.draft?e.draft:"")?"Custom prompt ready for the current "+a+".":"Ready to ask about the current "+a+"."}function Wd(e,t,r){var i=[],a=qi(e&&e.messages?e.messages:[]),n=e&&e.messages?e.messages.length:0;return Ft(i,t&&t.scope==="selection"?"Selection context":"Document context","is-scope"),Ft(i,a+" exchange"+(a===1?"":"s"),"is-exchanges"),Ft(i,n+" message"+(n===1?"":"s"),"is-messages"),Ft(i,"Enter sends","is-send"),r?Ft(i,"Starter: "+(r.label||r.id||"Prompt"),"is-starter"):E(e&&e.draft?e.draft:"")?Ft(i,"Custom prompt","is-custom"):Ft(i,"Ready for a new ask","is-prompt"),Ft(i,String(E(e&&e.draft?e.draft:"").length)+" chars","is-count"),i}function Oo(e,t,r){var i=jo(e,t);return{title:"Compose",statusTone:i,statusLabel:i==="busy"?"Working":i==="error"?"Needs attention":i==="ready"?"Ready":"Compose",statusText:Vd(e,t,r),metaPills:Wd(e,t,r)}}function Go(e){if(!e)return"";var t=[];if(e.title&&t.push(e.title),e.statusLabel&&t.push(e.statusLabel),e.statusText&&t.push(e.statusText),e.metaPills&&e.metaPills.length)for(var r=0;r<e.metaPills.length;r++)e.metaPills[r]&&e.metaPills[r].text&&t.push(e.metaPills[r].text);return fe(t)}function Ol(e,t,r){var i=t&&t.scope==="selection"?"selection":"document",a=i==="selection"?"sel":"doc",n=function(d,p,m){var w=c.__aiT?c.__aiT(d,p):p;return m===void 0?w:w.split("{0}").join(String(m))},l=function(d,p,m,w){return n(d+"_"+a,a==="sel"?p:m,w)},u=!!E(e&&e.draft?e.draft:"");return e&&e.busy?{text:n("aic_thinking","Thinking..."),disabled:!0,ariaLabel:l("aic_busyaria","Send disabled while AI Chat is thinking about the current selection.","Send disabled while AI Chat is thinking about the current document."),title:l("aic_busytitle","AI Chat is thinking about the current selection.","AI Chat is thinking about the current document.")}:r&&r.label?{text:n("aic_sendstarter","Send starter"),disabled:!1,ariaLabel:l("aic_starteraria","Send starter. Send the {0} starter for the current selection.","Send starter. Send the {0} starter for the current document.",r.label),title:l("aic_startertitle","Send the {0} starter for the current selection.","Send the {0} starter for the current document.",r.label)}:u?{text:n("aic_sendprompt","Send prompt"),disabled:!1,ariaLabel:l("aic_promptaria","Send prompt. Send the custom prompt for the current selection.","Send prompt. Send the custom prompt for the current document."),title:l("aic_prompttitle","Send the custom prompt for the current selection.","Send the custom prompt for the current document.")}:{text:n("aic_send","Send"),disabled:!0,ariaLabel:l("aic_emptyaria","Send disabled. Type a prompt or load a starter for the current selection first.","Send disabled. Type a prompt or load a starter for the current document first."),title:l("aic_emptytitle","Type a prompt or load a starter for the current selection first.","Type a prompt or load a starter for the current document first.")}}function Uo(e){return(c.__aiT?c.__aiT("aic_composeactions","Compose actions. Open Ask AI."):"Compose actions. Open Ask AI.")+" "+(e&&e.ariaLabel?e.ariaLabel:c.__aiT?c.__aiT("aic_sendp","Send."):"Send.")}function Bd(e){return!e||!e.messages||!e.messages.length?null:e.messages[e.messages.length-1]||null}function qi(e){if(!e||!e.length)return 0;for(var t=0,r=0;r<e.length;r++)e[r]&&e[r].role==="user"&&!e[r].isError&&t++;return t}function Fo(e,t,r){if(!(!e||!t)){for(var i=0;i<e.length;i++)if(e[i]&&e[i].text===t)return;e.push({text:t,className:r||""})}}function Xd(e){if(!e)return"";for(var t=e.pills||[],r="",i="",a=0;a<t.length;a++){var n=t[a];!n||!n.text||(!r&&n.kind==="change"?r=n.text:!i&&n.kind==="impact"&&(i=n.text))}var l=[];return r&&i?l.push("This is a "+i.toLowerCase()+" "+r.toLowerCase()+"."):r?l.push("This is a "+r.toLowerCase()+"."):i&&l.push("This is "+i.toLowerCase()+"."),e.detail&&l.push(e.detail),l.join(" ")}function Oa(e,t){var r=Bd(e);if(!r)return null;var i=t&&t.snapshot?t.snapshot:null,a=t&&t.scope==="selection"?"selection":"document",n=a==="selection"?"Selection thread":"Document thread",l=e&&e.messages?e.messages.length:0,u=qi(e&&e.messages?e.messages:[]),d=u+" exchange"+(u===1?"":"s"),p=l+" message"+(l===1?"":"s"),m=u?d+", "+p:p,w="Prompt sent to AI",y="Conversation live",v=[],h=[];if(e&&e.busy)w="Working on your latest request",y="Working",v.push(m+" in this "+a+" thread."),v.push("The assistant is preparing the next reply.");else if(r.isError)w="Latest reply needs attention",y="Needs attention",v.push(m+" in this "+a+" thread."),v.push("Adjust the prompt or try again.");else if(r.role==="assistant"){var _=r.resolved||null,b=_&&_.operations?_.operations:[],H=_?$t(_):"",x=ra(r,i),R=Br(x),C=Ma(r),P=Xd(C),T=Ia(r,i);if(v.push(m+" in this "+a+" thread."),b.length?(w="Latest review exchange is ready",y="Ready to review"):H?(w="Latest draft exchange is ready",y="Draft ready"):(w="Latest reply is ready",y="Reply ready"),R&&(v.push(R+" is the recommended next step."),Fo(h,R,"is-action")),C&&C.pills&&C.pills.length)for(var D=0;D<C.pills.length;D++){var F=C.pills[D];!F||!F.text||Fo(h,F.text,F.kind?"is-"+F.kind:"")}P?v.push(P):T&&T.detail&&v.push(T.detail)}else v.push(m+" in this "+a+" thread.");return h.unshift({text:p,className:"is-count"}),h.unshift({text:d,className:"is-exchanges"}),h.unshift({text:n,className:"is-scope"}),h.unshift({text:y,className:"is-status"}),{title:w,detail:v.join(" "),statusLabel:y,scopeLabel:n,exchangeLabel:d,messageLabel:p,actionLabel:r.role==="assistant"?Br(ra(r,i)):"",changeGlance:r.role==="assistant"?Ma(r):null,pills:h}}function rv(e){if(!e)return"";var t=["AI chat feed summary"];if(e.title&&t.push(e.title),e.statusLabel&&t.push(e.statusLabel),e.scopeLabel&&t.push(e.scopeLabel),e.exchangeLabel&&t.push(e.exchangeLabel),e.messageLabel&&t.push(e.messageLabel),e.actionLabel&&(t.push("Best next step"),t.push(e.actionLabel)),e.changeGlance){t.push(e.changeGlance.title||"Change at a glance");for(var r=e.changeGlance.pills||[],i=0;i<r.length;i++)r[i]&&r[i].text&&t.push(r[i].text);e.changeGlance.detail&&t.push(e.changeGlance.detail)}return fe(t)}function No(e,t,r){var i=t&&t.scope==="selection"?"selection":"document",a=qi(e&&e.messages?e.messages:[]),n=e&&e.messages?e.messages.length:0,l=!!E(e&&e.draft?e.draft:""),u="Your first answer, draft, or reviewable change for the current "+i+" will appear here.",d=[{text:"Waiting for first ask",className:"is-status"}];return r&&r.label?(d[0]={text:"Starter ready",className:"is-status"},d.push({text:r.label+" starter",className:"is-starter"}),u="Press Enter to send the "+r.label+" starter for the current "+i+", or edit it in Compose first."):l&&(d[0]={text:"Draft ready",className:"is-status"},d.push({text:"Custom prompt",className:"is-custom"}),u="Press Enter to send your custom prompt for the current "+i+", or keep editing it in Compose."),d.push({text:a+" exchange"+(a===1?"":"s"),className:"is-exchanges"},{text:n+" message"+(n===1?"":"s"),className:"is-count"}),{title:"First exchange",detail:u,metaPills:d}}function Yd(e){if(!e)return"";var t=[];if(e.title&&t.push(e.title),e.metaPills&&e.metaPills.length)for(var r=0;r<e.metaPills.length;r++)e.metaPills[r]&&e.metaPills[r].text&&t.push(e.metaPills[r].text);return e.detail&&t.push(e.detail),fe(t)}function Ko(e,t,r){var i=["Conversation"];if(e&&e.messages&&e.messages.length){var a=Oa(e,t);return a&&a.title&&i.push(a.title),a&&a.statusLabel&&i.push(a.statusLabel),a&&a.scopeLabel&&i.push(a.scopeLabel),a&&a.exchangeLabel&&i.push(a.exchangeLabel),a&&a.messageLabel&&i.push(a.messageLabel),a&&a.actionLabel&&(i.push("Best next step"),i.push(a.actionLabel)),a&&a.detail&&i.push(a.detail),fe(i)}var n=No(e,t,r);if(n.title&&i.push(n.title),n.metaPills&&n.metaPills.length)for(var l=0;l<n.metaPills.length;l++)n.metaPills[l]&&n.metaPills[l].text&&i.push(n.metaPills[l].text);return n.detail&&i.push(n.detail),fe(i)}function Zd(e,t){var r=Oa(e,t);return r?r.title:""}function iv(e,t){var r=Oa(e,t);return r?r.detail:""}function av(e,t){var r=Oa(e,t);return r?r.statusLabel:""}function ef(e,t){var r=jo(e,t);return r==="busy"?"Working":r==="error"?"Needs attention":"Ready"}function tf(e,t,r){var i=t&&t.scope==="selection"?"selection":"document",a=e&&e.messages?e.messages.length:0,n=qi(e&&e.messages?e.messages:[]),l=n?n+" exchange"+(n===1?"":"s")+", "+a+" message"+(a===1?"":"s"):a+" message"+(a===1?"":"s");return e&&e.busy?a?l+" in this conversation for the current "+i+". Preparing the next reply.":"Preparing help for the current "+i+".":r&&r.label?r.label+" starter is loaded for the current "+i+".":!a&&E(e&&e.draft?e.draft:"")?"Custom prompt is ready for the current "+i+".":a?l+" in this conversation for the current "+i+". "+Zd(e)+".":"Ask, rewrite, or review the current "+i+" in place."}function Ft(e,t,r){if(!(!e||!t)){for(var i=0;i<e.length;i++)if(e[i]&&e[i].text===t)return;e.push({text:t,className:r||""})}}function rf(e,t,r){var i=[],a=t&&t.scope==="selection"?"Selection thread":"Document thread",n=e&&e.messages?e.messages.length:0,l=qi(e&&e.messages?e.messages:[]),u=Oa(e,t);return Ft(i,a,"is-scope"),Ft(i,l+" exchange"+(l===1?"":"s"),"is-exchanges"),Ft(i,n+" message"+(n===1?"":"s"),"is-messages"),Ft(i,ja(t&&t.source?t.source:"")+" words","is-words"),u&&u.actionLabel?Ft(i,u.actionLabel,"is-action"):Ft(i,r&&r.label?r.label+" starter":E(e&&e.draft?e.draft:"")?"Custom draft":"Ready for a new ask","is-prompt"),i}function zo(e,t,r){return{statusLabel:ef(e,t),scopeFocusLabel:t&&t.scope==="selection"?"Selection focus":"Document focus",subtitle:tf(e,t,r),metaPills:rf(e,t,r)}}function Qo(e,t){var r=[];if(e&&r.push(e),!t)return fe(r);if(t.statusLabel&&r.push(t.statusLabel),t.scopeFocusLabel&&r.push(t.scopeFocusLabel),t.subtitle&&r.push(t.subtitle),t.metaPills&&t.metaPills.length)for(var i=0;i<t.metaPills.length;i++)t.metaPills[i]&&t.metaPills[i].text&&r.push(t.metaPills[i].text);return fe(r)}function $o(e){var t=e&&e.scope==="selection",r=!!(e&&e.snapshot&&e.snapshot.hasSelection),i=e&&e.source?e.source:"",a=[{text:ja(i)+" words",className:"is-words"},{text:E(i).length+" chars",className:"is-chars"}],n=Ho(i);return n>1&&a.push({text:n+" paragraphs",className:"is-paragraphs"}),{title:"Context",detail:t?"Using the selected passage as the active source. Switch to document to widen the ask.":r?"Using the whole document as the active source. Switch to selection to narrow the ask.":"Using the whole document as the active source. Select text any time to narrow the ask.",summaryPills:[{text:t?"Selection active":"Document active",className:t?"is-selection":"is-document"},{text:r?"Selection available":"No current selection",className:r?"is-available":"is-empty"}],previewTitle:Jd(e),previewMetaPills:a,previewSummary:e&&e.summary?e.summary:"The document is currently empty.",scopeIsSelection:t,hasSelection:r}}function Jo(e){if(!e)return"";var t=[];if(e.title&&t.push(e.title),e.summaryPills&&e.summaryPills.length)for(var r=0;r<e.summaryPills.length;r++)e.summaryPills[r]&&e.summaryPills[r].text&&t.push(e.summaryPills[r].text);if(e.detail&&t.push(e.detail),e.previewTitle&&t.push(e.previewTitle),e.previewMetaPills&&e.previewMetaPills.length)for(var i=0;i<e.previewMetaPills.length;i++)e.previewMetaPills[i]&&e.previewMetaPills[i].text&&t.push(e.previewMetaPills[i].text);return e.previewSummary&&t.push(e.previewSummary),fe(t)}function Vo(e){if(!e)return"";var t=["Context scope switch"];if(e.summaryPills&&e.summaryPills.length)for(var r=0;r<e.summaryPills.length;r++)e.summaryPills[r]&&e.summaryPills[r].text&&t.push(e.summaryPills[r].text);return fe(t)}function In(e,t){var r=e==="selection";return r?!t||!t.hasSelection?"Use selection. Unavailable until text is selected.":t.scopeIsSelection?"Use selection. Active scope. AI Chat is using the current selection.":"Use selection. Available scope. Switch AI Chat to the current selection.":t&&t.scopeIsSelection?"Use document. Available scope. Switch AI Chat to the whole document.":"Use document. Active scope. AI Chat is using the whole document."}function af(e){if(!e)return"";var t=[];if(e.previewTitle&&t.push(e.previewTitle),e.previewMetaPills&&e.previewMetaPills.length)for(var r=0;r<e.previewMetaPills.length;r++)e.previewMetaPills[r]&&e.previewMetaPills[r].text&&t.push(e.previewMetaPills[r].text);return e.previewSummary&&t.push(e.previewSummary),fe(t)}function Wo(e,t,r,i){var a=t&&t.length?t.length:0,n=!!E(e&&e.draft?e.draft:""),l=i&&i.scope==="selection"?"selection":"document",u=r?(r.label||r.id||"Prompt")+" starter":n?"Custom prompt":"Ready to choose",d=r?"Press Enter in Compose to send the loaded starter for the current "+l+", or edit it first.":n?"Keep writing your prompt for the current "+l+", or switch to a starter before you send.":"Choose a starter for the current "+l+" or keep typing your own prompt in Compose.";return{title:"Quick starts",detail:d,metaPills:[{text:l==="selection"?"Selection context":"Document context",className:"is-scope"},{text:a+" starters",className:"is-count"},{text:u,className:r?"is-active":n?"is-custom":"is-ready"}]}}function Bo(e){if(!e)return"";var t=[];if(e.title&&t.push(e.title),e.metaPills&&e.metaPills.length)for(var r=0;r<e.metaPills.length;r++)e.metaPills[r]&&e.metaPills[r].text&&t.push(e.metaPills[r].text);return e.detail&&t.push(e.detail),fe(t)}function Xo(e,t,r){var i=[],a=e&&(e.label||e.id)?e.label||e.id:"Prompt",n=r&&r.scope==="selection"?"selection":"document";i.push(a);var l=Dl(e);l&&i.push(l+" starter");var u=Pn(e&&e.prompt?e.prompt:"");return u&&i.push(u),i.push(t?"Current starter loaded in Compose for the current "+n:"Loads this starter into Compose for the current "+n),fe(i)}function Yo(e){return"Starter buttons for the current "+(e&&e.scope==="selection"?"selection":"document")}function Zo(e,t){var r=[{title:"Ask and explore",copy:"Get answers, summaries, headings, or rewrite direction grounded in the current context."},{title:"Prepare reviewable edits",copy:"Preview inline changes, apply structured plans, or turn responses into review-ready suggestions."},{title:"Use starters or type your own",copy:"Choose one of the curated quick starts above or write a custom prompt in the composer below."}];return{title:c.__aiT?c.__aiT("aic_starttitle","Start with AI Chat"):"Start with AI Chat",detail:(e.scope==="selection"?c.__aiT?c.__aiT("aic_empty_sel","Ask anything about the current selection"):"Ask anything about the current selection":c.__aiT?c.__aiT("aic_empty_doc","Ask anything about the current document"):"Ask anything about the current document")+".",metaPills:[{text:e.scope==="selection"?c.__aiT?c.__aiT("aic_pill_sel","Selection context"):"Selection context":c.__aiT?c.__aiT("aic_pill_doc","Document context"):"Document context",className:"is-scope"},{text:c.__aiT?c.__aiT("aic_pill_starters","{0} starters",t&&t.length?t.length:0):(t&&t.length?t.length:0)+" starters",className:"is-prompts"},{text:c.__aiT?c.__aiT("aic_pill_words","{0} words in scope",ja(e.source)):ja(e.source)+" words in scope",className:"is-size"}],capabilityCards:r}}function nf(e){if(!e)return"";var t=[];return e.title&&t.push(e.title),e.copy&&t.push(e.copy),fe(t)}function eu(e){if(!e)return"";var t=[];if(e.title&&t.push(e.title),e.detail&&t.push(e.detail),e.metaPills&&e.metaPills.length)for(var r=0;r<e.metaPills.length;r++)e.metaPills[r]&&e.metaPills[r].text&&t.push(e.metaPills[r].text);if(e.capabilityCards&&e.capabilityCards.length)for(var i=0;i<e.capabilityCards.length;i++)t.push(nf(e.capabilityCards[i]));return fe(t)}function lf(e){if(e)for(;e.firstChild;)e.removeChild(e.firstChild)}function Ii(e,t,r){if(e){lf(e);for(var i=t||[],a=0;a<i.length;a++)!i[a]||!i[a].text||o(e,"span","",r+(i[a].className?" "+i[a].className:""),i[a].text)}}function Gl(e,t,r,i){if(e){var a=jl(t,i),n=$o(r),l=zo(t,r,a),u=t.messages.length?null:Zo(r,i),d=Oo(t,r,a),p=Wo(t,i,a,r),m=t.messages.length?null:No(t,r,a),w=Ol(t,r,a),y=e.querySelector(".rte-ai-chat-header");y&&y.setAttribute("aria-label",Qo(L.text_aichat||"AI Chat",l));var v=e.querySelector(".rte-ai-chat-header-status.is-status");v&&(v.innerHTML="",v.innerText=l.statusLabel);var h=e.querySelector(".rte-ai-chat-header-status.is-scope");h&&(h.innerHTML="",h.innerText=l.scopeFocusLabel);var _=e.querySelector(".rte-ai-chat-subtitle");_&&(_.innerHTML="",_.innerText=l.subtitle),Ii(e.querySelector(".rte-ai-chat-header-meta"),l.metaPills,"rte-ai-chat-header-meta-pill");var b=e.querySelector(".rte-ai-chat-context-shell");b&&(b.setAttribute("aria-label",Jo(n)),b.classList.toggle("is-no-selection-actionable",!n.hasSelection));var H=e.querySelector(".rte-ai-chat-context-bar");H&&H.setAttribute("aria-label",Vo(n));var x=e.querySelectorAll(".rte-ai-chat-scope-button");x.length>0&&(x[0].disabled=!n.hasSelection,x[0].setAttribute("aria-label",In("selection",n)),n.scopeIsSelection?x[0].classList.add("is-active"):x[0].classList.remove("is-active")),x.length>1&&(x[1].setAttribute("aria-label",In("document",n)),n.scopeIsSelection?x[1].classList.remove("is-active"):x[1].classList.add("is-active")),Ii(e.querySelector(".rte-ai-chat-context-summary-meta"),n.summaryPills,"rte-ai-chat-context-summary-pill");var R=e.querySelector(".rte-ai-chat-context-summary-text");R&&(R.innerHTML="",R.innerText=n.detail);var C=e.querySelector(".rte-ai-chat-context-preview");C&&(C.className="rte-ai-chat-context-preview is-"+(r&&r.scope==="selection"?"selection":"document"),C.setAttribute("aria-label",af(n)));var P=e.querySelector(".rte-ai-chat-context-preview-title");P&&(P.innerHTML="",P.innerText=n.previewTitle),Ii(e.querySelector(".rte-ai-chat-context-preview-meta"),n.previewMetaPills,"rte-ai-chat-context-preview-pill");var T=e.querySelector(".rte-ai-chat-context-preview-copy");T&&(T.innerHTML="",T.innerText=n.previewSummary);var D=e.querySelector(".rte-ai-chat-quick-shell");D&&D.setAttribute("aria-label",Bo(p));var F=e.querySelector(".rte-ai-chat-quick-row");F&&F.setAttribute("aria-label",Yo(r));for(var M=e.querySelectorAll(".rte-ai-chat-quick-button"),V=0;V<M.length&&V<i.length;V++){var ve=i[V],X=!!(t.draft&&ve&&ve.prompt&&E(t.draft)===E(ve.prompt));X?M[V].classList.add("is-active"):M[V].classList.remove("is-active"),M[V].setAttribute("aria-label",Xo(ve,X,r))}Ii(e.querySelector(".rte-ai-chat-quick-summary-meta"),p.metaPills,"rte-ai-chat-quick-summary-pill");var j=e.querySelector(".rte-ai-chat-quick-summary-text");j&&(j.innerHTML="",j.innerText=p.detail);var se=e.querySelector(".rte-ai-chat-compose-shell");se&&se.setAttribute("aria-label",Go(d));var ee=e.querySelector(".rte-ai-chat-input");ee&&ee.setAttribute("aria-label","Compose next AI request for the current "+(r&&r.scope==="selection"?"selection":"document"));var oe=e.querySelector(".rte-ai-chat-composer-meta");oe&&oe.setAttribute("aria-label",(d.metaPills||[]).map(function(De){return De&&De.text?De.text:""}).filter(function(De){return!!De}).join(". ")),Ii(oe,d.metaPills,"rte-ai-chat-composer-pill");var Y=e.querySelector(".rte-ai-chat-status");Y&&(Y.className="rte-ai-chat-status is-"+d.statusTone,Y.setAttribute("aria-label",d.statusLabel+". "+d.statusText));var G=e.querySelector(".rte-ai-chat-status-pill");G&&(G.className="rte-ai-chat-status-pill is-"+d.statusTone,G.innerHTML="",G.innerText=d.statusLabel);var N=e.querySelector(".rte-ai-chat-status-text");N&&(N.innerHTML="",N.innerText=d.statusText);var Te=e.querySelector(".rte-ai-chat-composer-actions");Te&&Te.setAttribute("aria-label",Uo(w));var ce=e.querySelector(".rte-ai-chat-send-button");if(ce&&(ce.disabled=!!w.disabled,ce.setAttribute("aria-label",w.ariaLabel),ce.title=w.title,ce.classList.toggle("is-busy",!!t.busy),he(ce,t.busy?"spinner":"send",w.text)),!t.messages.length&&m){var W=e.querySelector(".rte-ai-chat-feed-shell");W&&W.setAttribute("aria-label",Ko(t,r,a));var Ce=e.querySelector(".rte-ai-chat-feed-intro");Ce&&Ce.setAttribute("aria-label",Yd(m));var ke=e.querySelector(".rte-ai-chat-feed-intro-title");ke&&(ke.innerHTML="",ke.innerText=m.title);var ye=e.querySelector(".rte-ai-chat-feed-intro-detail");ye&&(ye.innerHTML="",ye.innerText=m.detail),Ii(e.querySelector(".rte-ai-chat-feed-intro-meta"),m.metaPills,"rte-ai-chat-feed-intro-pill");var Ee=e.querySelector(".rte-ai-chat-empty");Ee&&u&&Ee.setAttribute("aria-label",eu(u));var Ze=e.querySelector(".rte-ai-chat-empty-title");Ze&&u&&(Ze.innerHTML="",Ze.innerText=u.title);var gt=e.querySelector(".rte-ai-chat-empty-detail");gt&&u&&(gt.innerHTML="",gt.innerText=u.detail),Ii(e.querySelector(".rte-ai-chat-empty-meta"),u?u.metaPills:[],"rte-ai-chat-empty-pill")}}}function sf(){if(!(!s||!s.__aiChatPanel||!s.__aiChatPanel.isConnected)){var e=rr();if(e&&e.messages&&e.messages.length){It(!1);return}Gl(s.__aiChatPanel,e,Ea(),L.aiToolkitChatPrompts||[])}}function of(){s&&(s.__aiChatSyncTimer&&clearTimeout(s.__aiChatSyncTimer),s.__aiChatSyncTimer=setTimeout(function(){s.__aiChatSyncTimer=0,sf()},0))}function tu(){if(!(!s||!s.getEditable)){var e=s.getEditable?s.getEditable():null,t=s.__aiToolkitLiveSyncHandler||(s.__aiToolkitLiveSyncHandler=function(){of(),cf()});e&&e.addEventListener&&s.__aiToolkitLiveSyncEditable!==e&&(e.addEventListener("input",t),e.addEventListener("keyup",t),e.addEventListener("mouseup",t),e.addEventListener("focus",t),s.__aiToolkitLiveSyncEditable=e);var r=e&&e.ownerDocument?e.ownerDocument:null;r&&r.addEventListener&&s.__aiToolkitLiveSyncDocument!==r&&(r.addEventListener("selectionchange",t),s.__aiToolkitLiveSyncDocument=r)}}function uf(){!s||!s.__aiDialog||!s.__aiDialog.isConnected||typeof s.__aiDialog.__aiSyncFromEditor!="function"||s.__aiDialog.__aiSyncFromEditor()}function cf(){s&&(s.__aiDialogSyncTimer&&clearTimeout(s.__aiDialogSyncTimer),s.__aiDialogSyncTimer=setTimeout(function(){s.__aiDialogSyncTimer=0,uf()},0))}function It(e){var t=ki();if(!t)return!1;var r=e?null:wd(s.__aiChatPanel),i=e?null:xd(s.__aiChatPanel),a=rr(),n=Ea(),l=L.aiToolkitChatPrompts||[],u=jl(a,l);if(Zi({preserveReturnFocus:!0}),s.__aiChatOriginalMinHeight=t.style&&t.style.minHeight||"",t.classList.add("rte-ai-chat-host"),t.style){var d=window.innerWidth<=900?260:280;t.style.minHeight=Math.max(t.offsetHeight||0,d)+"px"}s.__aiChatShell=t;var p=o(t,"div","","rte-ai-chat-panel");p.setAttribute("role","complementary"),p.setAttribute("aria-label",L.text_aichat||"AI Chat"),p.tabIndex=-1,s.__aiChatPanel=p,us(p),ha(p),p.onkeydown=function(I){I.key==="Escape"&&(I.preventDefault(),Zi({restoreFocus:!0}))};var m=zo(a,n,u),w=L.text_aichat||"AI Chat",y=o(p,"div","","rte-ai-chat-header is-minimal");y.setAttribute("role","group"),y.setAttribute("aria-label",Qo(w,m));var v=o(y,"div","","rte-ai-chat-header-copy"),h=o(v,"div","","rte-ai-chat-title-row"),_=o(h,"span","","rte-ai-chat-title-icon");_.innerHTML=L.svgCode_aiassist_chat||L.svgCode_aiassist||"",o(h,"div","","rte-ai-chat-title",w);var b=o(y,"div","","rte-ai-chat-header-actions"),H=o(b,"button","","secondary rte-ai-chat-header-button is-icon-only");H.type="button",H.setAttribute("data-rte-ai-chat-header-action","new-chat"),H.title=c.__aiT?c.__aiT("aic_newchat","Start a fresh chat"):"Start a fresh chat",H.setAttribute("aria-label",c.__aiT?c.__aiT("aic_newchat","Start a fresh chat"):"Start a fresh chat"),he(H,"refresh",""),H.onclick=function(){md(a,"Started a fresh AI chat."),It(!0)};var x=o(b,"button","","rte-ai-panel-close-button");x.type="button",x.setAttribute("data-rte-ai-chat-header-action","close"),x.setAttribute("aria-label",c.__aiT?c.__aiT("aic_closechat","Close AI chat"):"Close AI chat"),x.title=c.__aiT?c.__aiT("aic_close","Close"):"Close",x.innerHTML='<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 6l12 12"/><path d="M18 6L6 18"/></svg>',x.onclick=function(){Zi({restoreFocus:!0})};var R=$o(n),C=o(p,"div","","rte-ai-chat-stack rte-ai-chat-context-shell is-minimal"+(n.snapshot.hasSelection?"":" is-no-selection-actionable"));C.setAttribute("role","group"),C.setAttribute("aria-label",Jo(R));var P=o(C,"div","","rte-ai-chat-context-bar");P.setAttribute("role","group"),P.setAttribute("aria-label",Vo(R));var T=o(P,"button","","rte-ai-chat-scope-button is-icon-only"+(R.scopeIsSelection?" is-active":""));T.type="button",T.disabled=!n.snapshot.hasSelection,T.setAttribute("data-rte-ai-chat-scope-target","selection"),T.setAttribute("aria-label",In("selection",R)),T.title=c.__aiT?c.__aiT("aic_usesel","Use selection"):"Use selection",he(T,"cursorText",""),T.onclick=function(){var I=ut();a.scope="selection",a.status=I.hasSelection?"Chat will use the current selection.":"Select text first to use selection scope.",It(!0)};var D=o(P,"button","","rte-ai-chat-scope-button is-icon-only"+(R.scopeIsSelection?"":" is-active"));D.type="button",D.setAttribute("data-rte-ai-chat-scope-target","document"),D.setAttribute("aria-label",In("document",R)),D.title=c.__aiT?c.__aiT("aic_usedoc","Use document"):"Use document",he(D,"document",""),D.onclick=function(){a.scope="document",a.status="Chat will use the whole document.",It(!0)};var F=Wo(a,l,u,n),M=o(p,"div","","rte-ai-chat-stack rte-ai-chat-quick-shell is-minimal"+(a.messages.length?" is-conversation":""));M.setAttribute("role","group"),M.setAttribute("aria-label",Bo(F));var V=o(M,"div","","rte-ai-chat-quick-row");V.setAttribute("role","group"),V.setAttribute("aria-label",Yo(n));for(var ve=0;ve<l.length;ve++)(function(I){var be=!!(a.draft&&I.prompt&&E(a.draft)===E(I.prompt)),Q=o(V,"button","","rte-ai-chat-quick-button is-chip"+(be?" is-active":""));Q.type="button",Q.setAttribute("data-rte-ai-chat-prompt-tone",Nd(I)),Q.setAttribute("data-rte-ai-chat-prompt-id",I.id||I.label||String(ve)),Q.title=I.prompt||"",Q.setAttribute("aria-label",Xo(I,be,n)),he(Q,Df(I),I.label||I.id||"Prompt"),Q.onclick=function(){a.draft=I.prompt||"",a.status="Loaded the "+(I.label||I.id||"starter prompt")+" quick start.",It(!0)}})(l[ve]);var X=Ao(a,4);if(X.length>1){var j=o(p,"div","","rte-ai-chat-stack rte-ai-chat-history-shell is-minimal");j.setAttribute("role","group"),j.setAttribute("aria-label",c.__aiT?c.__aiT("aic_recent","Recent AI chats"):"Recent AI chats");for(var se=o(j,"div","","rte-ai-chat-quick-row rte-ai-chat-history-row"),ee=0;ee<X.length;ee++)(function(I,be){var Q=I.id===a.sessionId,te=o(se,"button","","rte-ai-chat-quick-button is-chip"+(Q?" is-active":""));te.type="button",te.setAttribute("data-rte-ai-chat-session-id",I.id),te.title=(I.title||"Recent chat")+" - "+(I.exchangeCount||0)+" exchange"+((I.exchangeCount||0)===1?"":"s"),te.setAttribute("aria-label",(Q?"Current chat. ":"Open recent chat. ")+(I.title||"Recent chat")+". "+(I.messageCount||0)+" message"+((I.messageCount||0)===1?"":"s")+"."),he(te,Q?"history":"chat",(be===0&&Q?"Current":"Recent")+": "+(I.title||"Chat")),te.onclick=function(){Q||xo(a,I.id,"Loaded a recent AI chat.")&&It(!0)}})(X[ee],ee)}var oe=o(p,"div","","rte-ai-chat-stack rte-ai-chat-feed-shell is-minimal");oe.setAttribute("role","group"),oe.setAttribute("aria-label",Ko(a,n,u));var Y=o(oe,"div","","rte-ai-chat-feed");if(!a.messages.length){var G=Zo(n,l),N=o(Y,"div","","rte-ai-chat-empty is-minimal is-flat");N.setAttribute("role","group"),N.setAttribute("aria-label",eu(G));var Te=document.createElement("div");Te.className="rte-ai-chat-empty-art is-detached",Te.setAttribute("aria-hidden","true");var ce=!!(l&&l.length),W=n.scope==="selection"?c.__aiT?c.__aiT("aic_empty_sel","Ask anything about the current selection"):"Ask anything about the current selection":c.__aiT?c.__aiT("aic_empty_doc","Ask anything about the current document"):"Ask anything about the current document";o(N,"div","","rte-ai-chat-empty-detail",ce?W+(c.__aiT?c.__aiT("aic_orquick"," \u2014 or tap a quick start above."):" \u2014 or tap a quick start above."):W+".")}for(var Ce=null,ke=0,ye=0;ye<a.messages.length;ye++){if(0){var Ee,Ze,gt,De;for(var ze;ze<De.length;ze++)var _e}(function(I,be){var Q=Pi(a.messages,be),te=Ha(a.messages,be),xe=Da(a.messages,be),Se=qn(a.messages,be),Le=Y;Q==="request"?(Ce=o(Y,"div","","rte-ai-chat-exchange-group"),xe&&Ce.setAttribute("data-rte-ai-chat-exchange-index",xe),Se&&Ce.setAttribute("data-rte-ai-chat-current-exchange","true"),Ce.setAttribute("role","group"),Ce.setAttribute("aria-label",$d(a.messages,be,n.snapshot)),ke=te,Le=Ce):Q==="response"&&Ce&&ke===te?Le=Ce:(Ce=null,ke=0);var Ue=Io(a.messages,be,n.snapshot);if(0){var ue,Tt;if(Ue.changeGlance&&Ue.changeGlance.pills&&Ue.changeGlance.pills.length)for(var Qe;Qe<Ue.changeGlance.pills.length;Qe++)var Lt}var it=o(Le,"div","","rte-ai-chat-message is-"+I.role+" is-minimal"+(I.isError?" is-error":""));it.setAttribute("role","group"),it.setAttribute("aria-label",Qd(a.messages,be,n.snapshot)),Q&&(it.setAttribute("data-rte-ai-chat-thread-role",Q),it.setAttribute("data-rte-ai-chat-exchange-index",String(te)),Se&&it.setAttribute("data-rte-ai-chat-current-exchange","true"));var hr=o(it,"div","","rte-ai-chat-message-header is-minimal"),lr=I.isError?"error":I.role,mt=o(hr,"span","","rte-ai-chat-message-avatar is-"+lr);if(mt.setAttribute("aria-hidden","true"),mt.innerHTML=lr==="user"?'<svg viewBox="0 0 16 16" width="16" height="16" fill="currentColor" aria-hidden="true"><circle cx="8" cy="5.5" r="2.8"/><path d="M8 9.4c-2.8 0-5.2 1.5-5.2 3.4 0 .4.3.7.7.7h9c.4 0 .7-.3.7-.7 0-1.9-2.4-3.4-5.2-3.4z"/></svg>':lr==="error"?'<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><circle cx="8" cy="8" r="6.5"/><path d="M8 5v3.5M8 11.2v.1"/></svg>':'<svg viewBox="0 0 16 16" width="16" height="16" fill="currentColor" aria-hidden="true"><rect x="3" y="5" width="10" height="8" rx="2"/><circle cx="8" cy="3" r="0.9"/><line x1="8" y1="3.9" x2="8" y2="5" stroke="currentColor" stroke-width="1"/><circle cx="6" cy="9" r="1.1" fill="#ffffff"/><circle cx="10" cy="9" r="1.1" fill="#ffffff"/></svg>',o(hr,"span","","rte-ai-chat-message-role is-"+(I.isError?"error":I.role),Lo(I)),o(it,"div","","rte-ai-chat-message-text",I.text||""),I.role==="assistant"&&!I.isError&&I.text){var Pe=o(it,"div","","rte-ai-chat-message-actions-row"),qe=o(Pe,"button","","rte-ai-chat-message-action is-copy");qe.type="button",qe.title=c.__aiT?c.__aiT("aic_copymsg","Copy message text"):"Copy message text",he(qe,"checkAll",c.__aiT?c.__aiT("aic_copy","Copy"):"Copy"),qe.onclick=(function(U,tt){return function(Re){Re&&Re.stopPropagation&&Re.stopPropagation();var Ct=window.navigator,Gt=!1;try{Ct&&Ct.clipboard&&Ct.clipboard.writeText&&(Ct.clipboard.writeText(U),Gt=!0)}catch{}if(!Gt){var Yt=document.createElement("textarea");Yt.value=U,Yt.style.position="fixed",Yt.style.left="-9999px",document.body.appendChild(Yt),Yt.select();try{document.execCommand("copy"),Gt=!0}catch{}document.body.removeChild(Yt)}Gt&&(tt.classList.add("is-just-copied"),he(tt,"check",c.__aiT?c.__aiT("aic_copied","Copied"):"Copied"),setTimeout(function(){tt.classList.remove("is-just-copied"),he(tt,"checkAll",c.__aiT?c.__aiT("aic_copy","Copy"):"Copy")},1400))}})(I.text||"",qe);for(var Vt="",_t=be-1;_t>=0;_t--)if(a.messages[_t]&&a.messages[_t].role==="user"&&!a.messages[_t].isError){Vt=a.messages[_t].text||"";break}if(Vt){var bt=o(Pe,"button","","rte-ai-chat-message-action is-regen");bt.type="button",bt.title=c.__aiT?c.__aiT("aic_regen","Regenerate response"):"Regenerate response",he(bt,"refresh",c.__aiT?c.__aiT("aid_regenerate","Regenerate"):"Regenerate"),bt.onclick=(function(U){return function(tt){tt&&tt.stopPropagation&&tt.stopPropagation(),a.draft=U,Il(U)}})(Vt)}}if(0){var Di;if(Di)var sr,Zr,Ke}if(0){var Er;if(Er)var Wt,or,ei,at}if(I.role==="assistant"&&I.resolved){var jt=Od(I,n.snapshot);if(0){var gr,yi,mr,Mt,ti;if(jt.reasonText)var Pr;if(jt.changeGlance){var qr;if(jt.changeGlance.pills&&jt.changeGlance.pills.length){var Ot;for(var ct;ct<jt.changeGlance.pills.length;ct++)var Bt}}if(jt.planLeadTitle||jt.planLeadLabel||jt.planLeadDetail||jt.planItems&&jt.planItems.length){var ri;if(jt.planLeadTitle||jt.planLeadLabel||jt.planLeadDetail){var ur;if(jt.planLeadLabel)var dt}if(jt.planItems&&jt.planItems.length){var _r;for(var Ir;Ir<jt.planItems.length;Ir++)var br,wr,yr}}}var Ar=o(it,"div","","rte-ai-chat-message-actions"),za=Ia(I,n.snapshot),Mr=jt&&(jt.planLeadTitle||jt.planLeadLabel||jt.planLeadDetail||jt.planItems&&jt.planItems.length);if(0)var $e;var We=ra(I,n.snapshot),ii=o(Ar,"div","","rte-ai-chat-message-action-group is-utility"),Je=o(Ar,"div","","rte-ai-chat-message-action-group is-primary"),Hr=o(Ar,"div","","rte-ai-chat-message-action-group is-secondary"),Rt=ta(I,n.snapshot),xr=function(U,tt){!U||!tt||tt!==We||(U.className+=" is-recommended",U.setAttribute("data-rte-ai-chat-recommended","true"))},zt=o(ii,"button","","secondary rte-ai-chat-action-button is-copy","Copy text");if(zt.type="button",zt.setAttribute("data-rte-ai-chat-action","copy"),zt.onclick=function(){Ld(I)},ia(zt,"copy",I,We,n.snapshot),Rt.canApplyPlan){var Dr=o(Je,"button","","secondary rte-ai-chat-action-button is-apply","Apply");Dr.type="button",Dr.setAttribute("data-rte-ai-chat-action","apply"),Dr.onclick=function(){qa(I,"plan")},xr(Dr,"apply"),ia(Dr,"apply",I,We,n.snapshot)}if(Rt.canPreview){var nt=o(Je,"button","","secondary rte-ai-chat-action-button is-preview","Preview");nt.type="button",nt.setAttribute("data-rte-ai-chat-action","preview"),nt.onclick=function(){qa(I,"preview")},xr(nt,"preview"),ia(nt,"preview",I,We,n.snapshot)}if(Rt.canReplaceSelection){var lt=o(Je,"button","","secondary rte-ai-chat-action-button is-selection","Replace selection");lt.type="button",lt.setAttribute("data-rte-ai-chat-action","selection"),lt.onclick=function(){qa(I,"selection")},xr(lt,"selection"),ia(lt,"selection",I,We,n.snapshot)}if(Rt.canInsert){var Qt=o(Hr,"button","","secondary rte-ai-chat-action-button is-insert","Insert below");if(Qt.type="button",Qt.setAttribute("data-rte-ai-chat-action","insert"),Qt.onclick=function(){qa(I,"insert")},xr(Qt,"insert"),ia(Qt,"insert",I,We,n.snapshot),Rt.canReplaceDocument){var Sr=o(Hr,"button","","secondary rte-ai-chat-action-button is-document","Replace document");Sr.type="button",Sr.setAttribute("data-rte-ai-chat-action","document"),Sr.onclick=function(){qa(I,"document")},xr(Sr,"document"),ia(Sr,"document",I,We,n.snapshot)}}Hl(ii,En("utility",We,I,n.snapshot),"utility"),Hl(Je,En("primary",We,I,n.snapshot),"primary"),Hl(Hr,En("secondary",We,I,n.snapshot),"secondary"),Id(Ar,We),Md(Ar,We),Dd(Ar,We,I,n.snapshot);var jr=!!(Rt.canPreview||Rt.canInsert||Rt.canReplaceDocument);if(jr){var Ai=Je.children.length?Je:Hr.children.length?Hr:ii,Xt=o(Ai,"button","","secondary rte-ai-chat-action-button rte-ai-chat-message-action-toggle-more");Xt.type="button",Xt.setAttribute("data-rte-ai-chat-action","more"),Xt.setAttribute("aria-expanded","false"),Xt.title=c.__aiT?c.__aiT("ai2_moreopts","More apply options"):"More apply options",he(Xt,"more","More"),Xt.onclick=(function(U){return function(tt){tt&&tt.stopPropagation&&tt.stopPropagation();var Re=U.classList.toggle("is-show-more");Xt.setAttribute("aria-expanded",Re?"true":"false")}})(it)}}if(I.role==="assistant"&&!I.isError){var Un=Mo(a.messages,be,n.snapshot);if(0){var Qa,oa,ji;if(Un.changeGlance&&Un.changeGlance.pills&&Un.changeGlance.pills.length)for(var Qe;Qe<Un.changeGlance.pills.length;Qe++)var Lt}}})(a.messages[ye],ye)}var J=Oo(a,n,u),$=Ol(a,n,u),je=o(p,"div","","rte-ai-chat-stack rte-ai-chat-compose-shell");je.setAttribute("role","group"),je.setAttribute("aria-label",Go(J));var et=o(je,"div","","rte-ai-chat-composer"),B=o(et,"textarea","","rte-ai-chat-input");B.rows=1,B.placeholder=c.__aiT?c.__aiT("aic_askanything","Ask anything\u2026"):"Ask anything\u2026",B.setAttribute("aria-label",n.scope==="selection"?c.__aiT?c.__aiT("aic_compose_sel","Compose next AI request for the current selection"):"Compose next AI request for the current selection":c.__aiT?c.__aiT("aic_compose_doc","Compose next AI request for the current document"):"Compose next AI request for the current document"),B.value=a.draft||"",B.disabled=!!a.busy,B.oninput=function(){a.draft=B.value,a.busy||(a.status=""),Gl(p,a,Ea(),l)},B.onkeydown=function(I){if(I.key==="Enter"&&!I.shiftKey){I.preventDefault();var be=Ea(),Q=jl(a,l),te=Ol(a,be,Q);if(te.disabled){a.status=te.title,Gl(p,a,be,l);return}Il(B.value)}};var K=o(et,"div","","rte-ai-chat-composer-actions");K.setAttribute("role","group"),K.setAttribute("aria-label",Uo($));var ne=document.createElement("button");ne.type="button",ne.className="secondary rte-ai-chat-action-button is-open-dialog is-detached",ne.setAttribute("data-rte-ai-chat-action","open-dialog"),he(ne,"external","Open Ask AI"),ne.onclick=function(){sa({useDocument:a.scope!=="selection",presetMode:"rewrite"})};var Ae=o(K,"button","","rte-ai-chat-send-button"+(a.busy?" is-busy":""));if(Ae.type="button",Ae.setAttribute("data-rte-ai-chat-action","send"),Ae.disabled=!!$.disabled,Ae.setAttribute("aria-label",$.ariaLabel),Ae.title=$.title,he(Ae,a.busy?"spinner":"send",$.text),Ae.onclick=function(){Il(B.value)},e&&setTimeout(function(){if(B&&B.focus){B.focus();try{B.selectionStart=B.selectionEnd=B.value.length}catch{}}},0),Yi(a),Y&&typeof Y.scrollTop<"u"&&(!i||!Sd(Y,i))&&(Y.scrollTop=Y.scrollHeight),!e&&r&&!Ad(p,r)&&p&&p.focus)try{p.focus({preventScroll:!0})}catch{try{p.focus()}catch{}}return!0}function ru(){for(var e={total:0,pending:0,accepted:0,rejected:0,stale:0},t=Ne(),r=0;r<t.length;r++)e.total++,e.hasOwnProperty(t[r].status)&&e[t[r].status]++;return e}function kr(e,t){return!t||t==="all"?!0:Be(e&&e.suggestionType||"")===t}function iu(e){for(var t={all:c.__aiT?c.__aiT("air_alltypes","All types"):"All types"},r=0;r<e.length;r++){var i=Be(e[r]&&e[r].suggestionType||"");t[i]||(t[i]=Me(i))}var a=[{value:"all",label:t.all}],n=[];for(var l in t)t.hasOwnProperty(l)&&l!=="all"&&n.push(l);n.sort();for(var u=0;u<n.length;u++)a.push({value:n[u],label:t[n[u]]});return a}function df(e){for(var t={all:0},r=0;r<e.length;r++)if(e[r].status==="pending"){t.all++;var i=Be(e[r].suggestionType||"");t[i]=(t[i]||0)+1}return t}function Ve(e){for(var t=Ne().slice(),r=[],i=0;i<t.length;i++)t[i].status==="pending"&&kr(t[i],e)&&r.push(t[i]);return qs(r)}function ir(e,t){var r=Ve(e);if(!r.length)return"";if(!t)return r[0].id;for(var i=0;i<r.length;i++)if(r[i].id===t)return r[i+1]?r[i+1].id:r.length>1?r[0].id:"";return r[0].id}function _i(e,t){var r=Ve(e);if(!r.length)return"";if(!t)return r[0].id;for(var i=0;i<r.length;i++)if(r[i].id===t)return r[i-1]?r[i-1].id:r.length>1?r[r.length-1].id:"";return r[0].id}function nv(e,t){var r=ir(e,t);return r?Dt(r):!1}function lv(e,t){var r=_i(e,t);return r?Dt(r):!1}function sv(e,t,r){var i=ir(e,t);return i?wi(i,r||{}):!1}function ov(e,t,r){var i=_i(e,t);return i?wi(i,r||{}):!1}function Nt(e){var t=Ht(),r=t.typeFilter||"all",i=me(e);return i&&r!=="all"&&!kr(i,r)&&(r=Be(i.suggestionType||"")),r||"all"}function aa(e){var t=Nt(e),r=ir(t,e);return!r&&t!=="all"&&(r=ir("all",e)),r}function au(e){var t=Nt(e),r=_i(t,e);return!r&&t!=="all"&&(r=_i("all",e)),r}function ff(e){var t=Nt(e),r=Ve(t);return!r.length&&t!=="all"&&(r=Ve("all")),r.length?r[0].id:""}function vf(e){var t=Nt(e),r=Ve(t);return!r.length&&t!=="all"&&(r=Ve("all")),r.length?r[r.length-1].id:""}function nu(e,t){var r=au(e);return r?Dt(r,t):!1}function lu(e,t){var r=aa(e);return r?Dt(r,t):!1}function pf(e,t){var r=ff(e);return r?Dt(r,t):!1}function hf(e,t){var r=vf(e);return r?Dt(r,t):!1}function pr(e){var t=hi();return t&&t.status==="pending"&&kr(t,e)?t.id:ir(e,"")}function Mn(e,t){var r=Ve(e),i={id:t||"",index:0,total:r.length};if(!t||!r.length)return i;for(var a=0;a<r.length;a++)if(r[a].id===t)return i.index=a+1,i;return i}function Ul(e){var t=Ht(),r=t.typeFilter||"all";return e&&r!=="all"&&!kr(e,r)&&(r=Be(e.suggestionType||"")),r||"all"}function bi(e,t,r){if(!e||e.status!=="pending"||t!=="accept"&&t!=="reject")return null;r=r||Ul(e);var i=Ve(r);!i.length&&r!=="all"&&(i=Ve("all"));for(var a=-1,n=0;n<i.length;n++)if(i[n]&&i[n].id===e.id){a=n;break}var l=t==="accept"?"Accept":"Reject";return a===-1||!i.length?{text:l,label:l+" this AI change"}:a===i.length-1?{text:l+" & finish",label:l+" & finish this AI change and finish the current review queue"}:{text:l+" & next",label:l+" & next this AI change and move to the next review item"}}function Kt(e){var t=Ge(e,"accept")||"Accept",r=Ge(e,"reject")||"Reject";return{acceptLabel:t,rejectLabel:r,acceptHint:t.replace(/^([A-Z])/,function(i){return i.toLowerCase()}),rejectHint:r.replace(/^([A-Z])/,function(i){return i.toLowerCase()})}}function Mi(e,t,r){if(r=r||{},!e)return!1;var i=!1;return t==="accept"?i=Ra(e):t==="reject"&&(i=Ca(e)),i&&ge(!0,{focusAction:r.focusAction||""}),i}function Hn(e,t,r){var i=pr(e);return i?Mi(i,t,r):!1}function gf(){for(var e=Ne().slice(),t=!1,r=0;r<e.length;r++)e[r].status==="pending"&&Ra(e[r].id)&&(t=!0);return t}function su(e){if(!e||e==="all")return gf();for(var t=Ne().slice(),r=!1,i=0;i<t.length;i++)t[i].status==="pending"&&kr(t[i],e)&&Ra(t[i].id)&&(r=!0);return r}function mf(){for(var e=Ne().slice(),t=!1,r=0;r<e.length;r++)e[r].status==="pending"&&Ca(e[r].id)&&(t=!0);return t}function ou(e){if(!e||e==="all")return mf();for(var t=Ne().slice(),r=!1,i=0;i<t.length;i++)t[i].status==="pending"&&kr(t[i],e)&&Ca(t[i].id)&&(r=!0);return r}function Dt(e,t){t=t||{},fr();var r=me(e),i=r?Lr(r.id):null;if(!r||!i)return r&&r.status==="pending"&&(r.status="stale",r.decidedAt=r.decidedAt||new Date().getTime()),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&ge(!1),!1;!t.openedQueue&&s.__aiRecentlyOpenedQueueSuggestionId&&s.__aiRecentlyOpenedQueueSuggestionId!==r.id&&Wi({skipUpdate:!0,skipRender:!0}),Xe(r.id),ba(r.id),t.openedQueue&&lo(r.id);var a=Mn(Nt(r.id),r.id),n={positionLabel:a.total?"Item "+a.index+" of "+a.total:"",remoteUpdateCount:Jt(r.id)};He(t.openedQueue?ao(r,n):Vr(r,"Reviewing",n)),i.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"}),i.classList.add("is-focused"),setTimeout(function(){i&&i.classList&&i.classList.remove("is-focused")},1400),s.focus();var l=!!(t.focusInlineAction&&Pc(r.id,t.focusInlineAction));return l||ya(i),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&ge(!1),!0}function wi(e,t){t=t||{};var r=me(e);if(!r)return!1;if(!t.openedQueue&&s.__aiRecentlyOpenedQueueSuggestionId&&s.__aiRecentlyOpenedQueueSuggestionId!==r.id&&Wi({skipUpdate:!0,skipRender:!0}),Xe(r.id),ba(r.id),t.openedQueue&&lo(r.id),t.locate)return Dt(r.id,{openedQueue:!!t.openedQueue});var i=Mn(Nt(r.id),r.id),a={positionLabel:i.total?"Item "+i.index+" of "+i.total:"",remoteUpdateCount:Jt(r.id)};return He(t.openedQueue?ao(r,a):Vr(r,"Reviewing",a)),ge(!!t.focusPanel,{focusAction:t.focusAction||""}),!0}function _f(e,t,r){if(!e||!s.__aiActiveSuggestionId||!e.querySelector)return null;var i=e.querySelector('[data-rte-ai-review-id="'+s.__aiActiveSuggestionId+'"]');if(!i||!i.scrollIntoView)return null;if(i.scrollIntoView({block:"nearest",inline:"nearest"}),t){var a=i;if(r&&i.querySelector){var n=i.querySelector('[data-rte-ai-review-action="'+r+'"]');(!n||n.disabled||!n.focus)&&(n=i.querySelector(".rte-ai-review-action-button.is-primary:not([disabled])")||i.querySelector('[data-rte-ai-review-action="locate"]:not([disabled])')||i.querySelector("[data-rte-ai-review-action]:not([disabled])")),n&&!n.disabled&&n.focus&&(a=n)}a&&a.focus&&a.focus()}return i}function bf(e,t){var r=s.__aiReviewPanel&&s.__aiReviewPanel.isConnected?s.__aiReviewPanel:null;if(!r||!r.querySelector||!e)return!1;var i=r.querySelector('[data-rte-ai-review-id="'+e+'"]');if(!i)return!1;var a=me(e),n=[];t?n.push(t):n.push(On(a)),a&&a.status==="pending"&&(n.push("accept"),n.push("reject")),n.push("locate");for(var l={},u=0;u<n.length;u++){var d=n[u];if(!(!d||l[d])){l[d]=!0;var p=i.querySelector('[data-rte-ai-review-action="'+d+'"]');if(p&&!p.disabled&&p.focus)return p.focus(),!0}}return i.focus?(i.focus(),!0):!1}function uu(e,t){var r=me(e);if(!r)return!1;var i=t||On(r);return s.__aiActiveSuggestionId===r.id&&bf(r.id,i)?!0:wi(r.id,{focusPanel:!0,focusAction:i||""})}function z(e){var t=e&&e.isConnected?e:s.__aiReviewPanel&&s.__aiReviewPanel.isConnected?s.__aiReviewPanel:null,r=document.activeElement;return t&&r&&r.getAttribute&&t.contains(r)?r.getAttribute("data-rte-ai-review-action")||"":s.__aiLastReviewActionFocus||""}function xt(e,t){t=t||{};var r=me(e);if(!r)return!1;var i=t.focusAction||z();return wi(r.id,{focusPanel:!!t.focusPanel,focusAction:i||On(r),openedQueue:!!t.openedQueue,locate:!!t.locate})}function Dn(e,t,r,i){var a="";if(i==="next")a=ir(e,t);else if(i==="previous")a=_i(e,t);else if(i==="first")a=pr(e);else if(i==="last"){var n=Ve(e);a=n.length?n[n.length-1].id:""}return a?wi(a,{focusPanel:!0,focusAction:r||""}):!1}function ar(){return!!ci()}function nr(){return!!Rr()}function Xr(e){var t=Pt(),r=qt(),i=e;return ar()&&(i=i.replace(/\.$/,"")+". U undoes "+t.decisionLabel+" decision."),nr()&&(i=i.replace(/\.$/,"")+". Shift+U redoes "+r.decisionLabel+" decision."),i}function St(e){var t=Pt(),r=e;return ar()&&(r+=" | U "+t.shortcutLabel),nr()&&(r+=" | Shift+U "+qt().shortcutLabel),r}function jn(e){var t=e;return ar()&&(t+=" U"),nr()&&(t+=" Shift+U"),t}function wf(e){switch(e){case"accept":return"Enter Space A";case"reject":return"Enter Space R";case"undo":return"Enter Space U";case"redo":return"Enter Space Shift+U";case"locate":return"Enter Space";default:return"Enter Space"}}function yf(e,t,r){var i=Pt(),a=qt(),n=Kt(t),l=(r||"").replace(/\.$/,"");return l||(l=e==="locate"?"Locate":"Review action"),e==="accept"?l+". Enter or Space activates this action. A uses "+n.acceptLabel+".":e==="reject"?l+". Enter or Space activates this action. R uses "+n.rejectLabel+".":e==="undo"?l+". Enter or Space activates this action."+(i?" U "+i.shortcutLabel+".":""):e==="redo"?l+". Enter or Space activates this action."+(a?" Shift+U "+a.shortcutLabel+".":""):l+". Enter or Space activates this action."}function Af(e,t){var r=Pt(),i=qt(),a=Kt(t);return St(e==="accept"?"Shortcuts: Enter "+a.acceptHint+" | R "+a.rejectHint+" | J/K move | Home/End jump":e==="reject"?"Shortcuts: Enter "+a.rejectHint+" | A "+a.acceptHint+" | J/K move | Home/End jump":e==="undo"?"Shortcuts: Enter "+r.shortcutLabel+" | A "+a.acceptHint+" | R "+a.rejectHint+" | J/K move | Home/End jump":e==="redo"?"Shortcuts: Enter "+i.shortcutLabel+" | A "+a.acceptHint+" | R "+a.rejectHint+" | J/K move | Home/End jump":e==="locate"?"Shortcuts: Enter locate | A "+a.acceptHint+" | R "+a.rejectHint+" | J/K move | Home/End jump":"Shortcuts: J/K move | Enter focus action | A "+a.acceptHint+" | R "+a.rejectHint+" | Home/End jump")}function Fl(e,t){var r=Kt(e);if(!e||e.status!=="pending")return Xr("Enter focuses Locate. J/K move items. Home/End jump.");var i=Ge(e,t)||r.acceptLabel;return Xr("Enter focuses "+i+". A uses "+r.acceptLabel+". R uses "+r.rejectLabel+". J/K move items. Home/End jump.")}function xf(e,t){var r=Kt(e);if(!e||e.status!=="pending")return St("Shortcuts: Enter focus Locate | J/K move | Home/End jump");var i=Ge(e,t)||r.acceptLabel;return St("Shortcuts: Enter focus "+i+" | A "+r.acceptHint+" | R "+r.rejectHint+" | J/K move | Home/End jump")}function cu(e,t){var r=Kt(e);return!e||e.status!=="pending"?St("Shortcuts: J/K move | Home/End jump"):St("Shortcuts: A "+r.acceptHint+" | R "+r.rejectHint+" | J/K move | Home/End jump")}function Ga(e,t){if(!e)return"";var r=Rr(),i=ci(),a=[];t&&a.push(t),a.push(On(e)),e.status==="pending"&&(a.push("accept"),a.push("reject"),i&&a.push("undo"),r&&r.suggestion&&r.suggestion.id===e.id&&a.push("redo")),a.push("locate");for(var n={},l=0;l<a.length;l++){var u=a[l];if(!(!u||n[u])&&(n[u]=!0,(u==="accept"||u==="reject")&&e.status==="pending"||u==="undo"&&e.status==="pending"&&i||u==="redo"&&e.status==="pending"&&r&&r.suggestion&&r.suggestion.id===e.id||u==="locate"&&(e.status==="pending"||e.status==="stale")))return u}return""}function Ge(e,t){var r=Ga(e,t);return r==="undo"?Pt().actionLabel||"Undo":r==="redo"?qt().actionLabel||"Redo":r==="reject"?(bi(e,"reject")||{}).text||"Reject":r==="accept"?(bi(e,"accept")||{}).text||"Accept":r==="locate"?"Locate":""}function du(e){switch(e){case"accept":case"reject":return"decision";case"undo":case"redo":return"recovery";case"locate":return"locate";default:return""}}function fu(e,t,r){var i;switch(e){case"locate":i=["locate"];break;case"decision":i=["accept","reject"];break;case"recovery":i=["undo","redo"];break;default:i=[];break}var a=i.indexOf(t);if(a===-1)return i.length+1;if(!r)return a+1;var n=i.indexOf(r);if(n===-1)return a+1;if(t===r)return 1;for(var l=2,u=0;u<i.length;u++)if(i[u]!==r){if(i[u]===t)return l;l++}return a+1}function vu(e){switch(e){case"locate":return"Locate";case"decision":return"Decide";case"recovery":return"Recover";default:return""}}function pu(e,t){var r=["locate","decision","recovery"],i=r.indexOf(e);if(i===-1)return r.length+1;if(!t)return i+1;var a=r.indexOf(t);if(a===-1)return i+1;if(e===t)return 1;for(var n=2,l=0;l<r.length;l++)if(r[l]!==t){if(r[l]===e)return n;n++}return i+1}function hu(e,t){t=t||{};var r=t.queueTransitionData||null;return e==="decision"?r?r.statusLabel+". "+r.detail:"Accept or reject this AI change from the current review queue.":e==="locate"?"Find this suggestion in the editor without deciding it yet.":e==="recovery"?t.targetActionName==="undo"&&t.undoSummaryText?t.undoSummaryText:t.targetActionName==="redo"&&t.redoSummaryText?t.redoSummaryText:t.undoSummaryText||t.redoSummaryText?"Undo or redo a recent AI review decision without leaving this card.":"Recover from a recent AI review action without leaving this card.":""}function Sf(e){e=e||{};var t=e.suggestion||null;if(!t)return null;var r=e.targetActionName||"",i=du(r),a=Ge(t,r),n=vu(i);return!i||!a||!n?null:{title:"Action handoff",pills:[n+" lane","Enter focuses "+a],detail:hu(i,e)}}function gu(e){if(!e)return"";var t=[];if(e.title&&t.push(e.title),e.pills&&e.pills.length)for(var r=0;r<e.pills.length;r++)e.pills[r]&&t.push(e.pills[r]);return e.detail&&t.push(e.detail),fe(t)}function Ua(e){var t=s.__aiReviewPanel&&s.__aiReviewPanel.isConnected?s.__aiReviewPanel:null;if(!t||!t.querySelector)return!1;var r=t.querySelector(".rte-ai-review-item.is-active"),i=hi(),a=r&&r.querySelector?r.querySelector(".rte-ai-review-item-actions"):null;if(!r||!i||!a)return!1;var n=Ga(i,e||z(t)),l=du(n),u=Ul(i),d=Ve(u);!d.length&&u!=="all"&&(d=Ve("all"));var p=gi(d,s.__aiActiveSuggestionId,i),m=i.status==="pending"?ci():null,w=Rr(),y=!!(w&&w.suggestion&&w.suggestion.id===i.id&&i.status==="pending"),v={suggestion:i,targetActionName:n,queueTransitionData:p,undoSummaryText:m?wa(m):"",redoSummaryText:y?mn(w):""},h=Sf(v),_=a.querySelector?a.querySelector(".rte-ai-review-item-action-summary"):null;if(h){for(_||(_=document.createElement("span"),_.className="rte-ai-review-item-action-summary");_.firstChild;)_.removeChild(_.firstChild);if(_.setAttribute("aria-label",gu(h)),o(_,"span","","rte-ai-review-item-action-summary-title",h.title),h.pills&&h.pills.length)for(var b=o(_,"span","","rte-ai-review-item-action-summary-pills"),H=0;H<h.pills.length;H++)h.pills[H]&&o(b,"span","","rte-ai-review-item-action-summary-pill",h.pills[H]);h.detail&&o(_,"span","","rte-ai-review-item-action-summary-detail",h.detail),a.firstChild!==_&&a.insertBefore(_,a.firstChild),a.setAttribute("aria-label","AI review actions. "+gu(h))}else _&&_.parentNode&&_.parentNode.removeChild(_),a.setAttribute("aria-label","AI review actions");for(var x=Ge(i,n),R=a.querySelectorAll(".rte-ai-review-item-action-group"),C=[],P=0;P<R.length;P++){var T=R[P];if(T){var D=T.getAttribute("data-rte-ai-review-action-group")||(T.classList.contains("is-decision")?"decision":T.classList.contains("is-recovery")?"recovery":T.classList.contains("is-locate")?"locate":"");if(D){var F=T.querySelector?T.querySelector(".rte-ai-review-action-button"):null;if(!F){var M=T.querySelector?T.querySelector(".rte-ai-review-item-action-group-header"):null,V=T.querySelector?T.querySelector(".rte-ai-review-item-action-group-detail"):null;M&&M.parentNode&&M.parentNode.removeChild(M),V&&V.parentNode&&V.parentNode.removeChild(V),T.setAttribute("data-rte-ai-review-action-group-current","false"),T.classList.remove("is-current-lane"),T.removeAttribute("aria-label");continue}C.push(T);var ve=vu(D),X=T.querySelector?T.querySelector(".rte-ai-review-item-action-group-header"):null;X||(X=document.createElement("span"),X.className="rte-ai-review-item-action-group-header",T.firstChild?T.insertBefore(X,T.firstChild):T.appendChild(X));var j=X.querySelector?X.querySelector(".rte-ai-review-item-action-group-title"):null;j||(j=document.createElement("span"),j.className="rte-ai-review-item-action-group-title",X.appendChild(j)),j.textContent=ve;var se=X.querySelector?X.querySelector(".rte-ai-review-item-action-group-badge"):null;se||(se=document.createElement("span"),se.className="rte-ai-review-item-action-group-badge",X.appendChild(se));var ee=T.querySelector?T.querySelector(".rte-ai-review-item-action-group-detail"):null;ee||(ee=document.createElement("span"),ee.className="rte-ai-review-item-action-group-detail",F?T.insertBefore(ee,F):T.appendChild(ee));var oe=!!l&&D===l,Y=hu(D,v);if(T.style.removeProperty("order"),T.setAttribute("data-rte-ai-review-action-group-current",oe?"true":"false"),T.classList.toggle("is-current-lane",oe),oe&&x){var G="Enter: "+x;se.textContent=G,se.style.display="",se.setAttribute("aria-label","Current action lane. "+G)}else se.textContent="",se.style.display="none",se.removeAttribute("aria-label");Y?(ee.textContent=Y,ee.style.display=""):(ee.textContent="",ee.style.display="none");var N=ve?ve+" lane":"";oe&&x&&(N+=(N?". ":"")+"Current action lane. Enter focuses "+x),Y&&(N+=(N?". ":"")+Y),N?T.setAttribute("aria-label",N):T.removeAttribute("aria-label")}}}C.sort(function(ce,W){var Ce=ce.getAttribute("data-rte-ai-review-action-group")||(ce.classList.contains("is-decision")?"decision":ce.classList.contains("is-recovery")?"recovery":ce.classList.contains("is-locate")?"locate":""),ke=W.getAttribute("data-rte-ai-review-action-group")||(W.classList.contains("is-decision")?"decision":W.classList.contains("is-recovery")?"recovery":W.classList.contains("is-locate")?"locate":"");return pu(Ce,l)-pu(ke,l)});for(var Te=0;Te<C.length;Te++)a.appendChild(C[Te]);return!0}function Fa(e){var t=s.__aiReviewPanel&&s.__aiReviewPanel.isConnected?s.__aiReviewPanel:null;if(!t||!t.querySelectorAll)return!1;for(var r=t.querySelector(".rte-ai-review-item.is-active"),i=hi(),a=Ga(i,e||z(t)),n={},l=t.querySelectorAll(".rte-ai-review-action-button[data-rte-ai-review-action]"),u=0;u<l.length;u++){var d=l[u];if(!(!d||!d.getAttribute)){var p=d.getAttribute("data-rte-ai-review-action")||"",m=!!r&&r.contains(d)&&!!a&&p===a&&!d.disabled,w=d.closest?d.closest(".rte-ai-review-item-action-group"):null,y=w&&w.classList?w.classList.contains("is-decision")?"decision":w.classList.contains("is-recovery")?"recovery":w.classList.contains("is-locate")?"locate":"":"";m&&w&&y?(n[y]||(n[y]=[]),n[y].push(d)):w&&y&&r&&r.contains(d)&&(n[y]||(n[y]=[]),n[y].push(d));var v=(d.getAttribute("aria-label")||d.textContent||"").replace(/\.\s*Current Enter target\.$/i,""),h=(d.getAttribute("title")||v).replace(/\.\s*Current Enter target\.$/i,"");d.setAttribute("data-rte-ai-review-enter-target",m?"true":"false"),d.classList.toggle("is-enter-target",m),m?(d.setAttribute("data-rte-ai-review-enter-target-label","Enter"),v&&!/current enter target/i.test(v)&&d.setAttribute("aria-label",fe([v,"Current Enter target."])),h&&!/current enter target/i.test(h)&&(d.title=fe([h,"Current Enter target."]))):(d.removeAttribute("data-rte-ai-review-enter-target-label"),v&&d.setAttribute("aria-label",v),h&&(d.title=h))}}if(!r)return!1;for(var y in n)if(n.hasOwnProperty(y)){var w=r.querySelector(".rte-ai-review-item-action-group.is-"+y),_=n[y];if(!(!w||!_||!_.length)){_.sort(function(R,C){var P=R.getAttribute("data-rte-ai-review-action")||"",T=C.getAttribute("data-rte-ai-review-action")||"";return fu(y,P,a)-fu(y,T,a)});for(var b=0;b<_.length;b++)w.appendChild(_[b])}}return!0}function Tf(e,t){if(!e||!e.suggestion)return"";var r={};for(var i in e.suggestion)Object.prototype.hasOwnProperty.call(e.suggestion,i)&&(r[i]=e.suggestion[i]);return r.status="pending",Ge(r,t)}function Lf(e,t){var r=Pt(),i=qt(),a=Kt(t);return St(e==="accept"?"Shortcuts: Enter focus "+a.acceptLabel+" | A "+a.acceptHint+" | R "+a.rejectHint+" | J/K move | Home/End jump":e==="reject"?"Shortcuts: Enter focus "+a.rejectLabel+" | A "+a.acceptHint+" | R "+a.rejectHint+" | J/K move | Home/End jump":e==="undo"?"Shortcuts: Enter focus "+r.actionLabel+" | A "+a.acceptHint+" | R "+a.rejectHint+" | J/K move | Home/End jump":e==="redo"?"Shortcuts: Enter focus "+i.actionLabel+" | A "+a.acceptHint+" | R "+a.rejectHint+" | J/K move | Home/End jump":e==="locate"?"Shortcuts: Enter focus Locate | J/K move | Home/End jump":"Shortcuts: J/K move | Enter focus action | A "+a.acceptHint+" | R "+a.rejectHint+" | Home/End jump")}function Rf(e,t){var r=Pt(),i=qt(),a=Kt(t);return Xr(e==="accept"?"Enter focuses "+a.acceptLabel+". A uses "+a.acceptLabel+". R uses "+a.rejectLabel+". J/K move items. Home/End jump.":e==="reject"?"Enter focuses "+a.rejectLabel+". A uses "+a.acceptLabel+". R uses "+a.rejectLabel+". J/K move items. Home/End jump.":e==="undo"?"Enter focuses "+r.actionLabel+". A uses "+a.acceptLabel+". R uses "+a.rejectLabel+". J/K move items. Home/End jump.":e==="redo"?"Enter focuses "+i.actionLabel+". A uses "+a.acceptLabel+". R uses "+a.rejectLabel+". J/K move items. Home/End jump.":e==="locate"?"Enter focuses Locate. J/K move items. Home/End jump.":"Enter focuses action. A uses "+a.acceptLabel+". R uses "+a.rejectLabel+". J/K move items. Home/End jump.")}function Cf(e,t){return Lf(Ga(e,t),e)}function mu(e,t){return Rf(Ga(e,t),e)}function _u(e){if(!e||!e.getAttribute)return"this control";var t=e.getAttribute("data-rte-ai-review-shortcut-label")||e.getAttribute("aria-label")||e.innerText||e.textContent||e.title||e.getAttribute("data-rte-ai-review-focus-key")||"this control";return String(t||"this control").replace(/\s+/g," ").replace(/^\s+|\s+$/g,"")||"this control"}function kf(e){var t=Kt(hi());return Xr("Enter activates "+_u(e)+". A uses "+t.acceptLabel+". R uses "+t.rejectLabel+". J/K move items. Home/End jump.")}function Ef(e){var t=Kt(hi());return St("Shortcuts: Enter "+_u(e)+" | A "+t.acceptHint+" | R "+t.rejectHint+" | J/K move | Home/End jump")}function On(e){if(!e)return"";var t=Rr();return e.status==="pending"&&t&&t.suggestion&&t.suggestion.id===e.id?"redo":e.status==="pending"?"accept":"locate"}function Nl(e,t){if(e){for(;e.firstChild;)e.removeChild(e.firstChild);if(t){var r=String(t||""),i=r.match(/^Shortcuts:\s*/i),a=e.ownerDocument||document,n=i?r.substring(i[0].length):r;if(i){var l=a.createElement("span");l.className="rte-ai-review-shortcuts-label",l.innerText="Shortcuts:",e.appendChild(l),e.appendChild(a.createTextNode(" "))}for(var u=n.split(/(\s+\|\s+|\s+-\s+)/),d=0;d<u.length;d++){var p=u[d];if(p){if(/^\s+[\|\-]\s+$/.test(p)){var m=a.createElement("span");m.className="rte-ai-review-shortcuts-separator",m.innerText=p.replace(/^\s+|\s+$/g,""),e.appendChild(m);continue}var w=a.createElement("span");w.className="rte-ai-review-shortcuts-segment";var y=p.replace(/^\s+|\s+$/g,""),v=y.indexOf(" ");if(v>0){var h=a.createElement("span");h.className="rte-ai-review-shortcuts-key",h.innerText=y.substring(0,v),w.appendChild(h),w.appendChild(a.createTextNode(" "));var _=a.createElement("span");_.className="rte-ai-review-shortcuts-copy",_.innerText=y.substring(v+1),w.appendChild(_)}else w.innerText=y;e.appendChild(w)}}}}}function Kl(e,t){if(e){var r=t||"";r?e.setAttribute("data-rte-ai-review-shortcut-action",r):e.removeAttribute("data-rte-ai-review-shortcut-action"),e.classList.remove("is-action-focused"),e.classList.remove("is-card-focused"),e.classList.remove("is-panel-focused"),e.classList.remove("is-control-focused"),r==="card"?e.classList.add("is-card-focused"):r==="panel"?e.classList.add("is-panel-focused"):r==="control"?e.classList.add("is-control-focused"):r&&e.classList.add("is-action-focused")}}function Pf(e,t){var r=s.__aiReviewPanel&&s.__aiReviewPanel.isConnected?s.__aiReviewPanel:null;if(!r||!r.querySelector)return!1;var i=r.querySelector(".rte-ai-review-item.is-active"),a=i&&i.querySelector?i.querySelector(".rte-ai-review-item-actions"):null,n=a&&a.querySelector?a.querySelector(".rte-ai-review-item-shortcuts"):null;if(!i||!a||!e)return n&&n.parentNode&&n.parentNode.removeChild(n),!1;n||(n=document.createElement("div"),n.className="rte-ai-review-item-shortcuts");var l=n.querySelector?n.querySelector(".rte-ai-review-item-shortcuts-title"):null;l||(l=document.createElement("span"),l.className="rte-ai-review-item-shortcuts-title",n.appendChild(l)),l.textContent="Keyboard guide";var u=n.querySelector?n.querySelector(".rte-ai-review-item-shortcuts-body"):null;u||(u=document.createElement("div"),u.className="rte-ai-review-shortcuts rte-ai-review-item-shortcuts-body",n.appendChild(u)),Nl(u,e||""),Kl(u,t);var d=String(e||"").replace(/^Shortcuts:\s*/i,"");n.setAttribute("aria-label",d?"Keyboard guide. "+d:"Keyboard guide");var p=a.querySelector?a.querySelector(".rte-ai-review-item-action-summary"):null;return p&&p.parentNode===a?p.nextSibling!==n&&(p.nextSibling?a.insertBefore(n,p.nextSibling):a.appendChild(n)):a.firstChild!==n&&(a.firstChild?a.insertBefore(n,a.firstChild):a.appendChild(n)),!0}function Na(e,t){var r=s.__aiReviewShortcutDisplayNode;r&&(Nl(r,e||""),Kl(r,t),Pf(e||"",t))}function bu(e){var t=e||"";Na(Af(t,hi()),t),Ua(t),Fa(t),Rn(),Cn()}function wu(e){var t=z();Na(xf(e,t),"card"),Ua(t),Fa(t),Rn(),Cn()}function zl(e,t){var r=t||z();Na(Cf(e,r),"panel"),Ua(r),Fa(r),Rn(),Cn()}function qf(e){Na(Ef(e),"control"),Ua(z()),Fa(z()),Rn(),Cn()}function yu(){return s.__aiReviewShortcutDisplayId||(s.__aiReviewShortcutDisplayId="rte-ai-review-shortcuts-"+String(Math.floor(Math.random()*1e9))),s.__aiReviewShortcutDisplayId}function na(e){if(!(!e||!e.setAttribute)){var t=[yu()],r=e.getAttribute("data-rte-ai-review-extra-describedby")||"";if(r)for(var i=r.split(/\s+/),a=0;a<i.length;a++)i[a]&&t.indexOf(i[a])<0&&t.push(i[a]);e.setAttribute("aria-describedby",t.join(" "))}}function If(e,t){if(e){var r=e.tagName?e.tagName.toUpperCase():"",i=r==="BUTTON"||e.getAttribute("role")==="button";i&&(e.setAttribute("aria-keyshortcuts",jn("Enter Space A R J K Home End")),e.title=kf(e));var a=e.onfocus;e.onfocus=function(n){na(e),i?qf(e):zl(),a&&a.call(this,n)},i&&(e.onkeydown=function(n){var l=(n.key||"").toLowerCase(),u=!1,d="";if(l==="a")u=Hn(t,"accept",{focusAction:z()});else if(l==="r")u=Hn(t,"reject",{focusAction:z()});else if(l==="u"&&n.shiftKey&&nr())u=Jr({focusPanel:!0,focusAction:z()});else if(l==="u"&&ar())u=Cr({focusPanel:!0,focusAction:z()});else if(n.key==="ArrowDown"||l==="j"){d="next";var p=ir(t,s.__aiActiveSuggestionId);u=!!(p&&xt(p,{focusPanel:!0,focusAction:z()}))}else if(n.key==="ArrowUp"||l==="k"){d="previous";var m=_i(t,s.__aiActiveSuggestionId);u=!!(m&&xt(m,{focusPanel:!0,focusAction:z()}))}else if(n.key==="Home"){d="first";var w=pr(t);u=!!(w&&xt(w,{focusPanel:!0,focusAction:z()}))}else if(n.key==="End"){d="last";var y=Ve(t),v=y.length?y[y.length-1].id:"";u=!!(v&&xt(v,{focusPanel:!0,focusAction:z()}))}(u||d)&&(n.preventDefault(),n.stopPropagation()),!u&&d&&He(tr(s.__aiActiveSuggestionId,d))})}}function Ka(e,t,r,i){e&&(e.setAttribute("aria-keyshortcuts",wf(i)),e.title=yf(i,me(r),e.getAttribute("aria-label")||e.textContent||""),e.onfocus=function(){s.__aiLastReviewActionFocus=i||"",na(e),bu(i)},e.onkeydown=function(a){var n=(a.key||"").toLowerCase(),l=!1,u="";n==="a"?l=Mi(r,"accept",{focusAction:z()}):n==="r"?l=Mi(r,"reject",{focusAction:z()}):n==="u"&&a.shiftKey&&nr()?l=Jr({focusPanel:!0,focusAction:z()}):n==="u"&&ar()?l=Cr({focusPanel:!0,focusAction:z()}):a.key==="ArrowDown"||n==="j"?(u="next",l=Dn(t,r,i,"next")):a.key==="ArrowUp"||n==="k"?(u="previous",l=Dn(t,r,i,"previous")):a.key==="Home"?(u="first",l=Dn(t,r,i,"first")):a.key==="End"&&(u="last",l=Dn(t,r,i,"last")),(l||u)&&(a.preventDefault(),a.stopPropagation()),!l&&u&&He(tr(r,u))})}function Au(e){fr();var t=e?me(e):null,r=t?Lr(t.id):null;return!t||t.status!=="pending"||!r?!1:(Xe(t.id,{preserveEmptyPreview:!0}),r.scrollIntoView&&r.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"}),r.classList.add("is-focused"),s.__aiReviewEmptyPreviewTimer&&clearTimeout(s.__aiReviewEmptyPreviewTimer),s.__aiReviewEmptyPreviewTimer=setTimeout(function(){r&&r.classList&&r.classList.remove("is-focused")},1200),!0)}function Mf(e){if(!document||!document.querySelectorAll||!window)return 0;var t;try{t=document.querySelectorAll("header, nav, [data-rte-ai-sticky-offset], [data-rte-sticky-offset], .topbar, .topnav, .site-header, .navbar, [class*='SiteHeader'], [class*='site-header']")}catch{return 0}for(var r=Math.min(window.innerHeight||900,320),i=0,a=0;a<t.length;a++){var n=t[a];if(!(!n||n===e||e&&e.contains&&e.contains(n))){var l=n.getBoundingClientRect?n.getBoundingClientRect():null;if(!(!l||l.height<8||l.width<80)&&!(l.top>24||l.bottom<=0||l.bottom>r)){var u=window.getComputedStyle?window.getComputedStyle(n):null;u&&(u.display==="none"||u.visibility==="hidden"||parseFloat(u.opacity||"1")<=.01)||(i=Math.max(i,l.bottom))}}}return Math.max(0,Math.ceil(i))}function xu(e){if(!(!e||!e.style)){var t=Mf(e);t>0?e.style.setProperty("--rte-ai-detected-top-chrome",t+"px"):e.style.removeProperty("--rte-ai-detected-top-chrome")}}function Yr(){s.__aiReviewPanel&&s.__aiReviewPanel.parentNode&&s.__aiReviewPanel.parentNode.removeChild(s.__aiReviewPanel),s.__aiReviewShell&&s.__aiReviewShell.classList&&s.__aiReviewShell.classList.remove("rte-ai-review-host"),s.__aiReviewShell&&s.__aiReviewShell.style&&(s.__aiReviewShell.style.minHeight=typeof s.__aiReviewOriginalMinHeight=="string"?s.__aiReviewOriginalMinHeight:"",s.__aiReviewShell.style.removeProperty("--rte-ai-detected-top-chrome")),s.__aiReviewPanel=null,s.__aiReviewSubtitleNode=null,s.__aiReviewSyncBadgeNode=null,s.__aiReviewSyncButton=null,s.__aiLastReviewActionFocus="",s.__aiReviewShell=null,s.__aiReviewOriginalMinHeight=null,s.__aiLastReviewEmptyAnnouncement="",s.__aiReviewEmptyPreviewTimer&&(clearTimeout(s.__aiReviewEmptyPreviewTimer),s.__aiReviewEmptyPreviewTimer=null),Wi({skipUpdate:!0,skipRender:!0}),s.__aiReviewEmptyPreviewSuggestionId&&Xe(null),s.__aiReviewPrimaryEmptyAction=null,s.__aiReviewMoveEmptyPreviewFocus=null}function Gn(e){return e=e||{},Zi(),ui(!0),ge(!!e.focusPanel)}function Hf(e){return s.__aiReviewPanel&&s.__aiReviewPanel.isConnected?(Yr(),!1):Gn(e)}var la={eyeOn:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7z"/><circle cx="12" cy="12" r="3"/></svg>',eyeOff:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9.88 9.88a3 3 0 1 0 4.24 4.24"/><path d="M10.73 5.08A10.43 10.43 0 0 1 12 5c6.5 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"/><path d="M6.61 6.61A13.526 13.526 0 0 0 2 12s3.5 7 10 7a9.74 9.74 0 0 0 5.39-1.61"/><line x1="2" y1="2" x2="22" y2="22"/></svg>',checkAll:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2 13l4 4L14 8"/><path d="M10 13l4 4L22 8"/></svg>',check:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="4 12 10 18 20 6"/></svg>',x:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="6" y1="6" x2="18" y2="18"/><line x1="6" y1="18" x2="18" y2="6"/></svg>',target:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="9"/><circle cx="12" cy="12" r="5"/><circle cx="12" cy="12" r="1.5" fill="currentColor"/></svg>',bulb:'<svg viewBox="0 0 24 24" width="11" height="11" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 18h6"/><path d="M10 22h4"/><path d="M12 2a7 7 0 0 0-4 12.7c.6.5 1 1.2 1 2v.3h6v-.3c0-.8.4-1.5 1-2A7 7 0 0 0 12 2z"/></svg>',arrowRight:'<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="5" y1="12" x2="19" y2="12"/><polyline points="13 6 19 12 13 18"/></svg>',send:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="22" y1="2" x2="11" y2="13"/><polygon points="22 2 15 22 11 13 2 9 22 2" fill="currentColor"/></svg>',sparkles:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 3v3M12 18v3M3 12h3M18 12h3M5.6 5.6l2.1 2.1M16.3 16.3l2.1 2.1M5.6 18.4l2.1-2.1M16.3 7.7l2.1-2.1"/><path d="M12 8 13.4 10.6 16 12l-2.6 1.4L12 16l-1.4-2.6L8 12l2.6-1.4L12 8z" fill="currentColor"/></svg>',refresh:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="1 4 1 10 7 10"/><path d="M3.5 15a9 9 0 1 0 2.1-9.4L1 10"/></svg>',external:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>',trash:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="3 6 5 6 21 6"/><path d="M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"/><path d="M10 11v6M14 11v6"/><path d="M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"/></svg>',cursorText:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 4h2a3 3 0 0 1 3 3v0a3 3 0 0 0 3 3h0M9 20h2a3 3 0 0 0 3-3v0a3 3 0 0 1 3-3h0"/><line x1="11" y1="4" x2="11" y2="20"/></svg>',document:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="8" y1="13" x2="16" y2="13"/><line x1="8" y1="17" x2="13" y2="17"/></svg>',inbox:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="22 12 16 12 14 15 10 15 8 12 2 12"/><path d="M5.45 5.11L2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"/></svg>',history:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><polyline points="3 3 3 8 8 8"/><polyline points="12 7 12 12 15 14"/></svg>',filter:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polygon points="22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"/></svg>',bot:'<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="4" y="8" width="16" height="12" rx="3"/><circle cx="9" cy="14" r="1.3" fill="currentColor"/><circle cx="15" cy="14" r="1.3" fill="currentColor"/><line x1="12" y1="4" x2="12" y2="8"/><circle cx="12" cy="3" r="1.2" fill="currentColor"/><line x1="4" y1="13" x2="2" y2="13"/><line x1="22" y1="13" x2="20" y2="13"/></svg>',chat:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>',wand:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M15 4V2M15 14v-2M8 9h2M20 9h2M17.8 11.8L19 13M15 9h0M17.8 6.2L19 5M3 21l9-9M12.2 6.2L11 5"/></svg>',list:'<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="8" y1="6" x2="21" y2="6"/><line x1="8" y1="12" x2="21" y2="12"/><line x1="8" y1="18" x2="21" y2="18"/><line x1="3" y1="6" x2="3.01" y2="6"/><line x1="3" y1="12" x2="3.01" y2="12"/><line x1="3" y1="18" x2="3.01" y2="18"/></svg>',globe:'<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><line x1="2" y1="12" x2="22" y2="12"/><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"/></svg>',heading:'<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 4v16M18 4v16M6 12h12"/></svg>',plus:'<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>',pencil:'<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"/></svg>',spinner:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true" class="rte-ai-spinner-svg"><path d="M12 3a9 9 0 1 0 9 9" /></svg>',more:'<svg viewBox="0 0 24 24" width="13" height="13" fill="currentColor" aria-hidden="true"><circle cx="6" cy="12" r="1.6"/><circle cx="12" cy="12" r="1.6"/><circle cx="18" cy="12" r="1.6"/></svg>',clipboard:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="8" y="3" width="8" height="3" rx="1"/><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"/></svg>',shrink:'<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="4 14 10 14 10 20"/><polyline points="20 10 14 10 14 4"/><line x1="14" y1="10" x2="21" y2="3"/><line x1="3" y1="21" x2="10" y2="14"/></svg>',expand:'<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><line x1="21" y1="3" x2="14" y2="10"/><line x1="3" y1="21" x2="10" y2="14"/></svg>',info:'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="9"/><line x1="12" y1="11" x2="12" y2="16"/><circle cx="12" cy="8" r="1" fill="currentColor"/></svg>'};function Df(e){if(!e)return"wand";var t=(e.tone||e.intent||e.id||"").toLowerCase();return t.indexOf("summar")!==-1?"list":t.indexOf("proofread")!==-1||t.indexOf("review")!==-1?"pencil":t.indexOf("translate")!==-1||t.indexOf("language")!==-1?"globe":t.indexOf("heading")!==-1||t.indexOf("structure")!==-1||t.indexOf("outline")!==-1?"heading":t.indexOf("expand")!==-1||t.indexOf("support")!==-1||t.indexOf("add")!==-1?"plus":"wand"}function he(e,t,r){if(e){if(e.textContent="",t&&la[t]){var i=e.ownerDocument.createElement("span");i.className="rte-ai-review-v2-action-icon",i.setAttribute("aria-hidden","true"),i.innerHTML=la[t],e.appendChild(i)}if(r){var a=e.ownerDocument.createElement("span");a.className="rte-ai-review-v2-action-label",a.textContent=r,e.appendChild(a)}}}function Hi(e){var t=ki();if(!t)return!1;for(var r=Ht(),i=Ne().slice(),a=ru(),n=iu(i),l=r.typeFilter||"all",u=!1,d=0;d<n.length;d++)if(n[d].value===l){u=!0;break}u||(l="all",r.typeFilter="all");var p=a.pending>0||a.stale>0,m=r.activeTab||"pending";m!=="pending"&&m!=="resolved"&&m!=="all"&&(m="pending"),m==="pending"&&!p&&a.total>0&&(m="resolved",r.activeTab="resolved");var w=a.pending+a.stale,y=a.accepted+a.rejected;if(Yr(),s.__aiReviewOriginalMinHeight=t.style&&t.style.minHeight||"",t.classList.add("rte-ai-review-host"),xu(t),t.style){var v=window.innerWidth<=900?460:520;t.style.minHeight=Math.max(t.offsetHeight||0,v)+"px"}s.__aiReviewShell=t;var h=o(t,"div","","rte-ai-review-panel rte-ai-review-v2");h.setAttribute("role","complementary"),h.setAttribute("aria-label",L.text_aireview||"AI Review"),h.tabIndex=-1,s.__aiReviewPanel=h,h.onkeydown=function(J){J.key==="Escape"&&(J.preventDefault(),Yr(),s.focus())};var _=o(h,"div","","rte-ai-review-v2-header"),b=o(_,"span","","rte-ai-review-v2-icon");b.innerHTML=L.svgCode_aiassist_review||L.svgCode_aiassist||"",o(_,"div","","rte-ai-review-v2-title",L.text_aireview||"AI Review");var H=o(_,"button","","rte-ai-review-v2-close");H.type="button",H.setAttribute("aria-label",c.__aiT?c.__aiT("air_closearia","Close AI review"):"Close AI review"),H.title=c.__aiT?c.__aiT("air_close","Close"):"Close",H.innerHTML='<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 6l12 12"/><path d="M18 6L6 18"/></svg>',H.onclick=function(){Yr(),s.focus()};var x=o(h,"div","","rte-ai-review-v2-tabs");x.setAttribute("role","tablist");function R(J,$,je,et){var B=o(x,"button","","rte-ai-review-v2-tab"+(m===J?" is-active":""));if(B.type="button",B.setAttribute("role","tab"),B.setAttribute("aria-selected",m===J?"true":"false"),B.setAttribute("data-rte-ai-review-tab",J),$&&la[$]){var K=B.ownerDocument.createElement("span");K.className="rte-ai-review-v2-tab-icon",K.setAttribute("aria-hidden","true"),K.innerHTML=la[$],B.appendChild(K)}var ne=B.ownerDocument.createElement("span");if(ne.className="rte-ai-review-v2-tab-label",ne.textContent=je,B.appendChild(ne),typeof et=="number"){var Ae=B.ownerDocument.createElement("span");Ae.className="rte-ai-review-v2-tab-count"+(et>0?" is-active":""),Ae.textContent=String(et),B.appendChild(Ae)}return B.onclick=function(){m!==J&&(Ht().activeTab=J,Hi(!0))},B}R("pending","inbox",c.__aiT?c.__aiT("air_tab_pending","To review"):"To review",w),R("resolved","history",c.__aiT?c.__aiT("air_tab_history","History"):"History",y),R("all","filter",c.__aiT?c.__aiT("air_tab_all","All"):"All",a.total);var C=o(h,"div","","rte-ai-review-v2-toolbar");if(n.length>1){for(var P=o(C,"select","","rte-ai-review-v2-select"),T=0;T<n.length;T++){var D=o(P,"option","","",n[T].label);D.value=n[T].value}P.value=l,P.onchange=function(){Ht().typeFilter=P.value||"all",Hi(!0)}}for(var F=0,M=0;M<i.length;M++)i[M].status==="pending"&&kr(i[M],l)&&F++;if(m==="pending"){o(C,"div","","rte-ai-review-v2-toolbar-spacer");var V=o(C,"button","","rte-ai-review-v2-batch is-accept");V.type="button",V.disabled=!F,he(V,"checkAll",c.__aiT?c.__aiT("air_acceptall","Accept all"):"Accept all"),V.onclick=function(){su(l)&&Hi(!0)};var ve=o(C,"button","","rte-ai-review-v2-batch is-reject");ve.type="button",ve.disabled=!F,he(ve,"x",c.__aiT?c.__aiT("air_rejectall","Reject all"):"Reject all"),ve.onclick=function(){ou(l)&&Hi(!0)}}for(var X=o(h,"div","","rte-ai-review-v2-body"),j=[],se=0;se<i.length;se++)if(!(i[se].changeType&&i[se].changeType!=="ai-preview")&&kr(i[se],l)){var ee=i[se].status,oe=ee==="pending"||ee==="stale";m==="pending"&&!oe||m==="resolved"&&oe||j.push(i[se])}j.sort(function(J,$){var je=J.status==="pending"||J.status==="stale",et=$.status==="pending"||$.status==="stale";return je!==et?je?-1:1:($.timestamp||0)-(J.timestamp||0)});for(var Y=s.__aiActiveSuggestionId||"",G=!1,N=0;N<j.length;N++)if(j[N].id===Y){G=!0;break}if(!G){for(var Te=0;Te<j.length;Te++)if(j[Te].status==="pending"||j[Te].status==="stale"){Xe(j[Te].id),Y=j[Te].id;break}}var ce=me(Y),W=a.total?Math.max(0,Math.min(100,Math.round(y/a.total*100))):0,Ce=l==="all"?c.__aiT?c.__aiT("air_alltypes","All types"):"All types":Me(l),ke=o(h,"div","","rte-ai-review-v2-center");h.insertBefore(ke,X),ke.setAttribute("role","group"),ke.setAttribute("aria-label",c.__aiT?c.__aiT("air_summary","AI review summary"):"AI review summary");function ye(J,$,je,et){var B=o(ke,"div","","rte-ai-review-v2-center-tile "+J);return o(B,"span","","rte-ai-review-v2-center-label",$),o(B,"span","","rte-ai-review-v2-center-value",je),o(B,"span","","rte-ai-review-v2-center-detail",et),B}ye("is-queue",c.__aiT?c.__aiT("air_queue","Queue"):"Queue",c.__aiT?c.__aiT("air_npending","{0} pending",F):F+" pending",m==="pending"?c.__aiT?c.__aiT("air_toreview","{0} to review",Ce):Ce+" to review":c.__aiT?c.__aiT("air_filter","{0} filter",Ce):Ce+" filter"),ye("is-progress",c.__aiT?c.__aiT("air_progress","Progress"):"Progress",c.__aiT?c.__aiT("air_pctdone","{0}% done",W):W+"% done",c.__aiT?c.__aiT("air_resolvedof","{0} resolved of {1}").split("{0}").join(String(y)).split("{1}").join(String(a.total)):y+" resolved of "+a.total);var Ee=ce?ce.status==="pending"||ce.status==="stale"?c.__aiT?c.__aiT("air_reviewcurrent","Review current"):"Review current":c.__aiT?c.__aiT("air_inspect","Inspect item"):"Inspect item":F?c.__aiT?c.__aiT("air_pick","Pick an item"):"Pick an item":a.total?c.__aiT?c.__aiT("air_caughtup","All caught up"):"All caught up":c.__aiT?c.__aiT("air_startask","Start with Ask AI"):"Start with Ask AI",Ze=ce?Ye(ce.originalText||ce.resultText||"AI suggestion",72):F?c.__aiT?c.__aiT("air_d_pick","Select a card below to compare the change."):"Select a card below to compare the change.":a.total?c.__aiT?c.__aiT("air_d_history","History keeps accepted and rejected changes."):"History keeps accepted and rejected changes.":c.__aiT?c.__aiT("air_d_empty","AI suggestions will appear here."):"AI suggestions will appear here.",gt=ye("is-next",c.__aiT?c.__aiT("air_next","Next step"):"Next step",Ee,Ze);if(ce){var De=o(gt,"button","","rte-ai-review-v2-center-action",c.__aiT?c.__aiT("air_focus","Focus"):"Focus");De.type="button",De.setAttribute("aria-label",c.__aiT?c.__aiT("air_focusaria","Focus the current AI review item"):"Focus the current AI review item"),De.onclick=function(){Xe(Y),Hi(!0)}}if(j.length)for(var _e=0;_e<j.length;_e++)(function(J){var $=o(X,"div","","rte-ai-review-v2-item is-"+J.status+(J.id===Y?" is-active":""));$.setAttribute("data-rte-ai-review-id",J.id),$.setAttribute("role","group");var je=o($,"div","","rte-ai-review-v2-item-head");o(je,"span","","rte-ai-review-v2-item-status is-"+J.status,Sa(J.status)),J.suggestionType&&J.suggestionType!=="other"&&o(je,"span","","rte-ai-review-v2-item-type",Me(J.suggestionType)),J.snapshot&&J.snapshot.hasSelection?o(je,"span","","rte-ai-review-v2-item-scope",c.__aiT?c.__aiT("air_scope_sel","Selection"):"Selection"):o(je,"span","","rte-ai-review-v2-item-scope",c.__aiT?c.__aiT("air_scope_doc","Document"):"Document");var et=Ye(J.originalText||J.resultText||"AI suggestion",120);if(o($,"div","","rte-ai-review-v2-item-title",et),J.id===Y){if(J.originalText&&J.resultText&&E(J.originalText)!==E(J.resultText)){var B=o($,"div","","rte-ai-review-v2-compare"),K=o(B,"div","","rte-ai-review-v2-before");o(K,"span","","rte-ai-review-v2-compare-label",c.__aiT?c.__aiT("air_current","Current"):"Current"),o(K,"div","","rte-ai-review-v2-compare-text",E(J.originalText));var ne=o(B,"span","","rte-ai-review-v2-compare-arrow");ne.setAttribute("aria-hidden","true"),ne.innerHTML=la.arrowRight;var Ae=o(B,"div","","rte-ai-review-v2-after");o(Ae,"span","","rte-ai-review-v2-compare-label",c.__aiT?c.__aiT("air_suggested","Suggested"):"Suggested"),o(Ae,"div","","rte-ai-review-v2-compare-text",E(J.resultText))}if(J.reason){var I=o($,"div","","rte-ai-review-v2-reason"),be=o(I,"span","","rte-ai-review-v2-reason-label"),Q=I.ownerDocument.createElement("span");Q.className="rte-ai-review-v2-reason-icon",Q.setAttribute("aria-hidden","true"),Q.innerHTML=la.bulb,be.appendChild(Q);var te=I.ownerDocument.createElement("span");te.textContent=c.__aiT?c.__aiT("air_why","Why"):"Why",be.appendChild(te),o(I,"span","","rte-ai-review-v2-reason-text",J.reason)}var xe=o($,"div","","rte-ai-review-v2-actions"),Se=o(xe,"button","","rte-ai-review-v2-action is-locate");if(Se.type="button",he(Se,"target",c.__aiT?c.__aiT("air_locate","Locate"):"Locate"),Se.onclick=function(ue){ue&&ue.stopPropagation&&ue.stopPropagation(),Dt(J.id)},J.status==="pending"||J.status==="stale"){var Le=o(xe,"button","","rte-ai-review-v2-action is-accept");Le.type="button",he(Le,"check",c.__aiT?c.__aiT("air_accept","Accept"):"Accept"),Le.onclick=function(ue){ue&&ue.stopPropagation&&ue.stopPropagation(),Mi(J.id,"accept",{focusAction:"accept"})};var Ue=o(xe,"button","","rte-ai-review-v2-action is-reject");Ue.type="button",he(Ue,"x",c.__aiT?c.__aiT("air_reject","Reject"):"Reject"),Ue.onclick=function(ue){ue&&ue.stopPropagation&&ue.stopPropagation(),Mi(J.id,"reject",{focusAction:"reject"})}}}$.onclick=function(ue){ue&&ue.target&&ue.target.closest&&ue.target.closest(".rte-ai-review-v2-action")||J.id!==Y&&(Xe(J.id),Hi(!0))}})(j[_e]);else{var ze=o(X,"div","","rte-ai-review-v2-empty");a.total===0?(o(ze,"div","","rte-ai-review-v2-empty-art is-prompt"),o(ze,"div","","rte-ai-review-v2-empty-title",c.__aiT?c.__aiT("air_e_none_t","No AI suggestions yet"):"No AI suggestions yet"),o(ze,"div","","rte-ai-review-v2-empty-detail",c.__aiT?c.__aiT("air_e_none_d","Ask AI or AI Chat will drop suggestions here for you to accept or reject."):"Ask AI or AI Chat will drop suggestions here for you to accept or reject.")):m==="pending"?(o(ze,"div","","rte-ai-review-v2-empty-art is-clear"),o(ze,"div","","rte-ai-review-v2-empty-title",c.__aiT?c.__aiT("air_e_done_t","Nothing to review"):"Nothing to review"),o(ze,"div","","rte-ai-review-v2-empty-detail",c.__aiT?c.__aiT("air_e_done_d","You're all caught up. Switch to History to see past decisions."):"You're all caught up. Switch to History to see past decisions.")):m==="resolved"?(o(ze,"div","","rte-ai-review-v2-empty-title",c.__aiT?c.__aiT("air_e_nohist_t","No history yet"):"No history yet"),o(ze,"div","","rte-ai-review-v2-empty-detail",c.__aiT?c.__aiT("air_e_nohist_d","Decisions you make on the To review tab will show up here."):"Decisions you make on the To review tab will show up here.")):(o(ze,"div","","rte-ai-review-v2-empty-title",c.__aiT?c.__aiT("air_e_nomatch_t","No suggestions match this filter"):"No suggestions match this filter"),o(ze,"div","","rte-ai-review-v2-empty-detail",c.__aiT?c.__aiT("air_e_nomatch_d","Try a different type, or pick a different tab."):"Try a different type, or pick a different tab."))}if(e)try{h.focus({preventScroll:!0})}catch{try{h.focus()}catch{}}return!0}function ge(e,t){if(L.aiToolkitReviewLegacyLayout!==!0)return Hi(e);t=t||{},fr();var r=ki();if(!r)return!1;for(var i=s.__aiReviewPanel&&s.__aiReviewPanel.isConnected?s.__aiReviewPanel:null,a=document.activeElement,n=i&&a&&a.closest?a.closest("[data-rte-ai-review-id]"):null,l=!e&&i&&a&&a.getAttribute&&a.getAttribute("data-rte-ai-review-focus-key")&&i.contains(a)&&a.getAttribute("data-rte-ai-review-focus-key")||"",u=!!(!e&&i&&n&&n.getAttribute&&n.getAttribute("data-rte-ai-review-id")===s.__aiActiveSuggestionId&&i.contains(a)),d=u&&a&&a!==n&&a.getAttribute&&a.getAttribute("data-rte-ai-review-action")||"",p=t.focusAction||"",m=Ht(),w=Ne().slice(),y=ru(),v=Cc(),h=y.pending>0||y.stale>0,_=m.showResolved||!h&&y.total>0||!!v,b=iu(w),H=df(w),x=m.typeFilter||"all",R=!1,C=0;C<b.length;C++)if(b[C].value===x){R=!0;break}R||(x="all",m.typeFilter="all");for(var P=[],T=0;T<w.length;T++)if(!(w[T].changeType&&w[T].changeType!=="ai-preview")){var D=_||w[T].status==="pending"||w[T].status==="stale",F=Jt(w[T].id)>0;D&&(kr(w[T],x)||F)&&P.push(w[T])}P=qs(P);for(var M=0,V=0;V<P.length;V++)P[V].status==="pending"&&kr(P[V],x)&&M++;var ve=ir("all",""),X=pr(x),j=ci(),se=Rr();Xe(X||null);var ee=Mn(x,X),oe=ir(x,X);if(Yr(),s.__aiReviewOriginalMinHeight=r.style&&r.style.minHeight||"",r.classList.add("rte-ai-review-host"),xu(r),r.style){var Y=window.innerWidth<=900?460:520;r.style.minHeight=Math.max(r.offsetHeight||0,Y)+"px"}s.__aiReviewShell=r;var G=o(r,"div","","rte-ai-review-panel");G.setAttribute("role","complementary"),G.setAttribute("aria-label",L.text_aireview||"AI Review"),G.setAttribute("aria-keyshortcuts",jn("Enter Space A R J K Home End")),G.tabIndex=-1,s.__aiReviewPanel=G,s.__aiReviewPrimaryEmptyAction=null,G.onkeydown=function(k){var re=(k.key||"").toLowerCase(),Ie=k.target&&k.target.tagName?k.target.tagName.toUpperCase():"";if(k.key==="Escape"){k.preventDefault(),Yr(),s.focus();return}if(!(k.ctrlKey||k.metaKey||k.altKey||Ie==="INPUT"||Ie==="TEXTAREA"||Ie==="SELECT"||Ie==="BUTTON"))if(!pr(x)&&s.__aiReviewMoveEmptyPreviewFocus&&(re==="arrowdown"||re==="j"||re==="arrowup"||re==="k"||re==="arrowright"||re==="arrowleft"||re==="home"||re==="end"))k.preventDefault(),re==="arrowdown"||re==="j"||re==="arrowright"?s.__aiReviewMoveEmptyPreviewFocus("next"):re==="arrowup"||re==="k"||re==="arrowleft"?s.__aiReviewMoveEmptyPreviewFocus("previous"):re==="home"?s.__aiReviewMoveEmptyPreviewFocus("first"):re==="end"&&s.__aiReviewMoveEmptyPreviewFocus("last");else if(re==="arrowdown"||re==="j"){k.preventDefault();var rt=ir(x,s.__aiActiveSuggestionId);rt?xt(rt,{focusPanel:!0,focusAction:z(G)}):s.__aiActiveSuggestionId&&He(tr(s.__aiActiveSuggestionId,"next"))}else if(re==="arrowup"||re==="k"){k.preventDefault();var pt=_i(x,s.__aiActiveSuggestionId);pt?xt(pt,{focusPanel:!0,focusAction:z(G)}):s.__aiActiveSuggestionId&&He(tr(s.__aiActiveSuggestionId,"previous"))}else if(re==="home"){k.preventDefault();var wt=pr(x);wt&&wt!==s.__aiActiveSuggestionId?xt(wt,{focusPanel:!0,focusAction:z(G)}):s.__aiActiveSuggestionId&&He(tr(s.__aiActiveSuggestionId,"first"))}else if(re==="end"){k.preventDefault();var Zt=Ve(x),S=Zt.length?Zt[Zt.length-1].id:"";S&&S!==s.__aiActiveSuggestionId?xt(S,{focusPanel:!0,focusAction:z(G)}):s.__aiActiveSuggestionId&&He(tr(s.__aiActiveSuggestionId,"last"))}else if(re==="enter"||re===" "){k.preventDefault();var ie=pr(x);ie?uu(ie,z(G)):s.__aiReviewPrimaryEmptyAction&&s.__aiReviewPrimaryEmptyAction.isConnected&&!s.__aiReviewPrimaryEmptyAction.disabled&&s.__aiReviewPrimaryEmptyAction.click()}else re==="a"?(k.preventDefault(),Hn(x,"accept",{focusAction:z(G)})):re==="r"?(k.preventDefault(),Hn(x,"reject",{focusAction:z(G)})):re==="u"&&k.shiftKey&&se?(k.preventDefault(),Jr({focusPanel:!0,focusAction:z(G)})):re==="u"&&j&&(k.preventDefault(),Cr({focusPanel:!0,focusAction:z(G)}))};var N=o(G,"div","","rte-ai-review-header"),Te=o(N,"div","","rte-ai-review-header-copy"),ce=o(Te,"div","","rte-ai-review-header-eyebrow");o(ce,"span","","rte-ai-review-header-kicker","Review workspace"),o(ce,"span","","rte-ai-review-header-status is-status",ho(y,M,x)),x!=="all"&&o(ce,"span","","rte-ai-review-header-status is-filter",Me(x)+" queue"),v&&v.count&&o(ce,"span","","rte-ai-review-header-status is-remote",v.count+" shared");var W=o(Te,"div","","rte-ai-review-title-row"),Ce=o(W,"span","","rte-ai-review-title-icon");Ce.innerHTML=L.svgCode_aiassist_review||L.svgCode_aiassist||"",o(W,"div","","rte-ai-review-title",L.text_aireview||"AI Review"),Ci()&&(s.__aiReviewSyncBadgeNode=o(W,"span","","rte-ai-review-sync-badge","")),s.__aiReviewSubtitleNode=o(Te,"div","","rte-ai-review-subtitle",bc());var ke=o(Te,"div","","rte-ai-review-header-meta");ee.total&&ee.index&&o(ke,"span","","rte-ai-review-header-meta-pill is-current","Item "+ee.index+" of "+ee.total),y.pending>0?o(ke,"span","","rte-ai-review-header-meta-pill is-pending",(x!=="all"?M:y.pending)+(x!=="all"?" in this view":" pending now")):y.stale>0?o(ke,"span","","rte-ai-review-header-meta-pill is-stale",y.stale+" need refresh"):o(ke,"span","","rte-ai-review-header-meta-pill is-complete","Queue complete"),x!=="all"&&y.pending>0&&M!==y.pending&&o(ke,"span","","rte-ai-review-header-meta-pill is-total",y.pending+" total pending");var ye=o(N,"div","","rte-ai-review-header-actions"),Ee=null,Ze=null,gt=null,De=o(ye,"div","","rte-ai-review-header-utility");if(Ci()){Ee=Ee||Li(ye,"rte-ai-review-header-group is-context","Context");var ze=o(Ee,"button","","secondary rte-ai-review-header-button is-sync","Sync now");ze.type="button",ze.setAttribute("data-rte-ai-review-focus-key","sync-now"),ze.onclick=function(){ui(!0)},s.__aiReviewSyncButton=ze}var _e=Rc();if(_e&&me(_e)){Ee=Ee||Li(ye,"rte-ai-review-header-group is-context","Context");var J=o(Ee,"button","","secondary rte-ai-review-header-button is-shared","Newest shared");J.type="button",J.setAttribute("data-rte-ai-review-focus-key","newest-shared"),J.setAttribute("aria-label","Jump to the newest shared AI review update"),J.onclick=function(){Dt(_e)}}if(X){Ee=Ee||Li(ye,"rte-ai-review-header-group is-context","Context");var $=o(Ee,"button","","secondary rte-ai-review-header-button is-locate-current","Locate current");$.type="button",$.setAttribute("data-rte-ai-review-focus-key","locate-current"),$.setAttribute("aria-label","Locate the current active AI review item in the editor"),$.onclick=function(){Dt(X)}}var je=_i(x,X);if(je){Ze=Ze||Li(ye,"rte-ai-review-header-group is-move","Navigate");var et=o(Ze,"button","","secondary rte-ai-review-header-button is-nav","Previous");et.type="button",et.setAttribute("data-rte-ai-review-focus-key","previous-pending"),et.setAttribute("aria-label","Jump to the previous pending AI review item in the current filter"),et.onclick=function(){xt(je,{focusPanel:!0})}}if(oe){Ze=Ze||Li(ye,"rte-ai-review-header-group is-move","Navigate");var B=o(Ze,"button","","secondary rte-ai-review-header-button is-nav","Next pending");B.type="button",B.setAttribute("data-rte-ai-review-focus-key","next-pending"),B.setAttribute("aria-label","Jump to the next pending AI review item in the current filter"),B.onclick=function(){xt(oe,{focusPanel:!0})}}if(j){var K=Pt(j);gt=gt||Li(ye,"rte-ai-review-header-group is-recover","Recover");var ne=o(gt,"button","","secondary rte-ai-review-header-button is-undo",K.actionLabel);ne.type="button",ne.setAttribute("data-rte-ai-review-focus-key","undo-last"),ne.setAttribute("data-rte-ai-review-shortcut-label",K.shortcutLabel),ne.setAttribute("aria-label","Undo the "+K.detailLabel+(K.summaryText?' for "'+K.summaryText+'"':"")+" and reopen it in AI Review"),ne.onclick=function(){Cr({focusPanel:!0,focusAction:z()})}}if(se){var Ae=qt(se);gt=gt||Li(ye,"rte-ai-review-header-group is-recover","Recover");var I=o(gt,"button","","secondary rte-ai-review-header-button is-redo",Ae.actionLabel);I.type="button",I.setAttribute("data-rte-ai-review-focus-key","redo-last"),I.setAttribute("data-rte-ai-review-shortcut-label",Ae.shortcutLabel),I.setAttribute("aria-label","Redo the "+Ae.detailLabel+(Ae.summaryText?' for "'+Ae.summaryText+'"':"")+" in AI Review"),I.onclick=function(){Jr({focusPanel:!0,focusAction:z()})}}var be=o(De,"button","","rte-ai-panel-close-button is-review-close");be.type="button",be.setAttribute("data-rte-ai-review-focus-key","close-review"),be.setAttribute("aria-label","Close AI review"),be.title="Close",be.innerHTML='<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 6l12 12"/><path d="M18 6L6 18"/></svg>',be.onclick=function(){Yr()},Ps();var Q=o(G,"div","","rte-ai-review-stack rte-ai-review-overview");Et(Q,"rte-ai-review-section-label is-overview","Queue overview");var te=y.accepted+y.rejected+y.stale,xe=y.total?Math.max(0,Math.min(100,Math.round(te/y.total*100))):0,Se=o(Q,"div","","rte-ai-review-overview-hero"),Le=o(Se,"div","","rte-ai-review-overview-status-row");o(Le,"span","","rte-ai-review-overview-pill is-status",ho(y,M,x)),o(Le,"span","","rte-ai-review-overview-pill is-progress",te+" of "+y.total+" reviewed"),x!=="all"&&o(Le,"span","","rte-ai-review-overview-pill is-filter",Me(x)+" focus"),v&&v.count&&o(Le,"span","","rte-ai-review-overview-pill is-remote",v.count+" shared"),o(Se,"div","","rte-ai-review-overview-title",nd(y,M,x,ee)),o(Se,"div","","rte-ai-review-overview-detail",ld(y,M,x,v));var Ue=o(Se,"div","","rte-ai-review-overview-progress"),ue=o(Ue,"div","","rte-ai-review-overview-progress-bar"),Tt=o(ue,"span","","rte-ai-review-overview-progress-fill");Tt.style.width=xe+"%",o(Ue,"span","","rte-ai-review-overview-progress-label",xe+"% complete");var Qe=o(Q,"div","","rte-ai-review-summary");o(Qe,"span","","rte-ai-review-summary-pill is-pending",y.pending+" pending"),o(Qe,"span","","rte-ai-review-summary-pill is-accepted",y.accepted+" accepted"),o(Qe,"span","","rte-ai-review-summary-pill is-rejected",y.rejected+" rejected"),y.stale&&o(Qe,"span","","rte-ai-review-summary-pill is-stale",y.stale+" stale"),ee.total&&ee.index&&o(Qe,"span","","rte-ai-review-summary-pill is-current","Item "+ee.index+" of "+ee.total),x!=="all"&&o(Qe,"span","","rte-ai-review-summary-pill is-filtered",Me(x)+" filter - "+M+" pending"),v&&o(Qe,"span","","rte-ai-review-summary-pill is-remote",v.count+" new shared");var Lt=me(X),it=x==="all"?"All queues":Me(x),hr=x==="all"?y.pending:M,lr=Lt?Ge(Lt,z(G))||"Review item":ve?"Open next queue":y.pending?"Choose queue":"All clear",mt=Lt?ee&&ee.total&&ee.index?"Item "+ee.index+" of "+ee.total+" in "+it.toLowerCase()+".":"Current suggestion is ready.":ve?"There are pending suggestions outside this filter.":y.pending?"Pick a queue filter to continue.":"No pending AI suggestions remain.",Pe=o(Q,"div","","rte-ai-review-center");Pe.setAttribute("role","group"),Pe.setAttribute("aria-label","AI review center summary");function qe(k,re,Ie,rt){var pt=o(Pe,"div","","rte-ai-review-center-tile "+k);return o(pt,"div","","rte-ai-review-center-label",re),o(pt,"div","","rte-ai-review-center-value",Ie),o(pt,"div","","rte-ai-review-center-detail",rt),pt}qe("is-queue","Queue",hr+" pending",it+(x!=="all"&&y.pending!==M?" - "+y.pending+" total pending":"")),qe("is-progress","Progress",xe+"% done",te+" reviewed of "+y.total+" total");var Vt=qe("is-next","Next step",lr,mt);if(X||ve){var _t=o(Vt,"button","","rte-ai-review-center-action",X?"Focus":"Open");_t.type="button",_t.setAttribute("data-rte-ai-review-focus-key",X?"center-focus-current":"center-open-next"),_t.setAttribute("aria-label",X?"Focus the current AI review item":"Open the next pending AI review queue"),_t.onclick=function(){X?xt(X,{focusPanel:!0,focusAction:z()}):ve&&(m.typeFilter="all",xt(ve,{focusPanel:!0,focusAction:z(),openedQueue:!0}))}}var bt=mn(se);if(bt){var Di=qt(se);o(Q,"div","","rte-ai-review-summary-detail is-redo",bt+" Press Shift+U to "+Di.shortcutLabel+".");var sr=vl(2);if(sr.length){var Zr=o(Q,"div","","rte-ai-review-summary-history is-redo");o(Zr,"div","","rte-ai-review-summary-history-title","Then");for(var Ke=0;Ke<sr.length;Ke++){var Er=sr[Ke],Wt=o(Zr,"div","","rte-ai-review-summary-history-item");o(Wt,"div","","rte-ai-review-summary-history-label",Er.label),o(Wt,"div","","rte-ai-review-summary-history-detail",Er.detail)}}}if(v){var or=o(Q,"div","","rte-ai-review-activity-card"),ei=o(or,"div","","rte-ai-review-activity-copy");o(ei,"div","","rte-ai-review-activity-title",v.title),o(ei,"div","","rte-ai-review-activity-detail",v.detail);var at=o(or,"button","","secondary rte-ai-review-activity-button","Got it");at.type="button",at.setAttribute("data-rte-ai-review-focus-key","dismiss-activity"),at.setAttribute("aria-label","Dismiss shared AI review update notice"),at.onclick=function(){ul(),ge(!0)}}var jt=o(G,"div","","rte-ai-review-stack rte-ai-review-navigation");Et(jt,"rte-ai-review-section-label is-controls","Filter and batch");var gr=o(jt,"div","","rte-ai-review-controls"),yi=null;if(b.length>1){yi=Wn(gr,"rte-ai-review-control-group is-scope","Queue scope");var mr=o(yi,"select","","rte-ai-review-filter-select");mr.setAttribute("data-rte-ai-review-focus-key","type-filter");for(var Mt=0;Mt<b.length;Mt++){var ti=o(mr,"option","","",b[Mt].label);ti.value=b[Mt].value}mr.value=x,mr.onchange=function(){m.typeFilter=mr.value||"all",ge(!0)}}var Pr=Wn(gr,"rte-ai-review-control-group is-visibility","Visibility"),qr=o(Pr,"button","","secondary rte-ai-review-control-button is-toggle-resolved",_?"Pending only":"Show resolved");qr.type="button",qr.setAttribute("data-rte-ai-review-focus-key","toggle-resolved"),qr.onclick=function(){m.showResolved=!_,ge(!0)};var Ot=Wn(gr,"rte-ai-review-control-group is-batch","Batch review"),ct=o(Ot,"button","","secondary rte-ai-review-control-button is-accept-batch","Accept all");ct.type="button",ct.setAttribute("data-rte-ai-review-focus-key","accept-all"),ct.disabled=x==="all"?!y.pending:!M,x!=="all"&&(ct.innerText="Accept filtered"),ct.onclick=function(){su(x)&&ge(!0)};var Bt=o(Ot,"button","","secondary rte-ai-review-control-button is-reject-batch","Reject all");if(Bt.type="button",Bt.setAttribute("data-rte-ai-review-focus-key","reject-all"),Bt.disabled=x==="all"?!y.pending:!M,x!=="all"&&(Bt.innerText="Reject filtered"),Bt.onclick=function(){ou(x)&&ge(!0)},b.length>1)for(var ri=o(yi||gr,"div","","rte-ai-review-type-chips"),ur=0;ur<b.length;ur++){var dt=b[ur],_r=H[dt.value]||0;if(!(dt.value!=="all"&&_r===0&&dt.value!==x)){var Ir=dt.label+" ("+_r+")",br=o(ri,"button","","rte-ai-review-type-chip"+(dt.value===x?" is-active":""),Ir);br.type="button",br.setAttribute("data-rte-ai-review-focus-key","type-chip-"+dt.value),br.setAttribute("aria-pressed",dt.value===x?"true":"false"),br.onclick=(function(k){return function(){m.typeFilter=k,ge(!0)}})(dt.value)}}Et(jt,"rte-ai-review-section-label is-shortcuts","Keyboard lane");var wr=o(jt,"div","","rte-ai-review-shortcuts","");if(wr.id=yu(),s.__aiReviewShortcutDisplayNode=wr,G.onfocus=function(){na(G),G.title=mu(me(pr(x)),z(G)),zl(me(pr(x)),z(G))},G.querySelectorAll)for(var yr=G.querySelectorAll("[data-rte-ai-review-focus-key]"),Ar=0;Ar<yr.length;Ar++)If(yr[Ar],x);p||d?bu(p||d):X?wu(me(X)):(G.title=mu(me(pr(x)),z(G)),zl(me(pr(x)),z(G)));var za=o(G,"div","","rte-ai-review-stack rte-ai-review-content");Et(za,"rte-ai-review-section-label is-feed",P.length?"Review items":"Recovery and next queues");var Mr=o(za,"div","","rte-ai-review-feed");if(P.length)s.__aiLastReviewEmptyAnnouncement="",s.__aiReviewPrimaryEmptyAction=null,s.__aiReviewMoveEmptyPreviewFocus=null;else{let k=function(S,ie){var Oe=[ie||""];if(S&&S.getAttribute){var Z=S.getAttribute("data-rte-ai-empty-focus-label")||"",we=S.getAttribute("data-rte-ai-preview-change-label")||"",Gr=S.getAttribute("data-rte-ai-preview-impact-label")||"";Z&&Oe.push("focus "+Z),we&&Oe.push(we),Gr&&Oe.push(Gr)}return Oe.filter(function(li){return!!li}).join(", ")},re=function(S){var ie=Je.length;if(!S||!ie)return{index:0,total:ie};for(var Oe=0;Oe<ie;Oe++)if(Je[Oe]===S)return{index:Oe+1,total:ie};return{index:0,total:ie}},Ie=function(S){var ie=Je.length>1;ii&&(ii.innerText=ud(S,ie)),Na(cd(S,{queueSwitcher:ie}),"")},rt=function(S){var ie=S&&S.id?S.id:"";return ie==="go-type"||ie==="next-overall"||ie==="all-types"?{key:"queue",label:"Next queues"}:ie==="undo-last"?{key:"recovery",label:"Recover"}:{key:"utility",label:"More"}},pt=function(S,ie,Oe){Oe=Oe||{};for(var Z=0;Z<Je.length;Z++){var we=Je[Z];we.removeAttribute("data-rte-ai-primary-empty"),we.removeAttribute("aria-current"),we.setAttribute("aria-pressed","false"),we.tabIndex=-1,we.classList&&we.classList.contains("is-primary-target")&&we.classList.remove("is-primary-target"),we.__aiCurrentBadge&&we.__aiCurrentBadge.parentNode&&we.__aiCurrentBadge.parentNode.removeChild(we.__aiCurrentBadge),we.__aiCurrentBadge=null,we.__aiQueueBadge&&we.__aiQueueBadge.parentNode&&we.__aiQueueBadge.parentNode.removeChild(we.__aiQueueBadge),we.__aiQueueBadge=null}if(s.__aiReviewPrimaryEmptyAction&&s.__aiReviewPrimaryEmptyAction!==S&&(s.__aiReviewPrimaryEmptyAction.removeAttribute("data-rte-ai-primary-empty"),s.__aiReviewPrimaryEmptyAction.classList&&s.__aiReviewPrimaryEmptyAction.classList.contains("is-primary-target")&&s.__aiReviewPrimaryEmptyAction.classList.remove("is-primary-target")),s.__aiReviewPrimaryEmptyAction=S||null,S&&(S.setAttribute("data-rte-ai-primary-empty","true"),S.setAttribute("aria-pressed","true"),S.tabIndex=0,S.classList&&S.classList.contains("rte-ai-review-empty-preview"))){S.classList.add("is-primary-target"),S.setAttribute("aria-current","true");var Gr=S.__aiPreviewMetaNode||(S.querySelector?S.querySelector(".rte-ai-review-empty-preview-meta"):null);if(Gr){S.__aiCurrentBadge=o(Gr,"span","","rte-ai-review-empty-preview-pill is-current","Current");var li=re(S);li.total>1&&(S.__aiQueueBadge=o(Gr,"span","","rte-ai-review-empty-preview-pill is-queue","Queue "+li.index+" of "+li.total))}}var Fn=We;We=k(S,ie||""),S&&S.getAttribute&&Au(S.getAttribute("data-rte-ai-preview-suggestion-id")||""),Ie(We),Oe.announce&&We&&We!==Fn&&He("Completion handoff moved to "+We+".")},wt=function(S){if(Je.length<2)return!1;for(var ie=0,Oe=0;Oe<Je.length;Oe++)if(Je[Oe]===document.activeElement||Je[Oe]===s.__aiReviewPrimaryEmptyAction){ie=Oe;break}var Z=ie;return S==="next"?Z=Math.min(Je.length-1,ie+1):S==="previous"?Z=Math.max(0,ie-1):S==="first"?Z=0:S==="last"&&(Z=Je.length-1),Z===ie||!Je[Z]?(S==="next"||S==="last"?He("Already at the last available completion queue."):(S==="previous"||S==="first")&&He("Already at the first available completion queue."),!1):(Je[Z].focus(),!0)},Zt=function(S){if(S)if(S.id==="show-resolved")m.showResolved=!0,ge(!0);else if(S.id==="go-type"){m.typeFilter=S.typeValue||"all";var ie=S.suggestionId||ir(m.typeFilter,"");ie?xt(ie,{focusPanel:!0,focusAction:S.focusAction||z(),openedQueue:!0}):ge(!0)}else S.id==="next-overall"?(m.typeFilter="all",S.suggestionId?xt(S.suggestionId,{focusPanel:!0,focusAction:S.focusAction||z(),openedQueue:!0}):ge(!0)):S.id==="all-types"?(m.typeFilter="all",ge(!0)):S.id==="undo-last"?Cr({focusPanel:!0,focusAction:z()}):S.id==="open-chat"&&ea({focusComposer:!0})};var Tr=k,vt=re,ai=Ie,Ti=rt,kt=pt,Or=wt,ni=Zt,$e=ad(y,M,x,_,ve,H,b),We="",ii=null,Je=[];s.__aiReviewMoveEmptyPreviewFocus=wt;var Hr=$e.title+"|"+$e.detail+"|"+$e.actions.map(function(S){return S?S.label:""}).join("|");$e.announceMessage&&s.__aiLastReviewEmptyAnnouncement!==Hr&&(He($e.announceMessage),s.__aiLastReviewEmptyAnnouncement=Hr);var Rt=o(Mr,"div","","rte-ai-review-empty"),xr=wa(j),zt=!!($e.previewItems&&$e.previewItems.length),Dr=!!xr;Rt.classList.toggle("is-queue-complete",zt),Rt.classList.toggle("is-recoverable",Dr);var nt=o(Rt,"div","","rte-ai-review-empty-hero"),lt=o(nt,"div","","rte-ai-review-empty-status-row");if(o(lt,"span","","rte-ai-review-empty-status-pill "+(zt?"is-ready":Dr?"is-recovery":"is-clear"),zt?"Queue complete":Dr?"Recovery available":"All clear"),zt&&o(lt,"span","","rte-ai-review-empty-status-pill is-count",$e.previewItems.length===1?"1 next queue":$e.previewItems.length+" next queues"),o(nt,"div","","rte-ai-review-empty-title",$e.title),o(nt,"div","","rte-ai-review-empty-detail",$e.detail),ii=o(nt,"div","","rte-ai-review-empty-hint",""),xr){var Qt=o(Rt,"div","","rte-ai-review-empty-zone is-recovery");Et(Qt,"rte-ai-review-section-label is-recovery","Recovery"),o(Qt,"div","","rte-ai-review-empty-detail rte-ai-review-empty-undo-detail",xr);var Sr=fl(3);if(Sr.length){var jr=o(Qt,"div","","rte-ai-review-empty-undo-history");o(jr,"div","","rte-ai-review-empty-undo-history-title","Then");for(var Ai=0;Ai<Sr.length;Ai++){var Xt=Sr[Ai],Un=o(jr,"div","","rte-ai-review-empty-undo-history-item");o(Un,"div","","rte-ai-review-empty-undo-history-label",Xt.label),o(Un,"div","","rte-ai-review-empty-undo-history-detail",Xt.detail)}}}if($e.previewItems&&$e.previewItems.length){var Qa=o(Rt,"div","","rte-ai-review-empty-zone is-next");Et(Qa,"rte-ai-review-section-label is-feed",$e.previewItems.length>1?"Next queues":"Next queue");var oa=o(Qa,"div","","rte-ai-review-empty-previews");oa.setAttribute("role","toolbar"),oa.setAttribute("aria-label","Next review queues");for(var ji=0;ji<$e.previewItems.length;ji++){var U=$e.previewItems[ji],tt=U.typeValue?"button":"div",Re=o(oa,tt,"","rte-ai-review-empty-preview"+(U.typeValue?" is-actionable":""));if(tt==="button"){Re.type="button",Re.tabIndex=-1,Re.setAttribute("aria-pressed","false"),Re.setAttribute("aria-setsize",String($e.previewItems.length)),Re.setAttribute("aria-posinset",String(ji+1)),Re.setAttribute("aria-keyshortcuts",mo({queueSwitcher:$e.previewItems.length>1})),Re.title=go(U.actionLabel||U.label||"Open next queue",{focusLabel:U.focusActionLabel,queueSwitcher:$e.previewItems.length>1});var Ct=[U.actionLabel||U.label||"Open next queue"];U.focusActionLabel&&Ct.push("Focus "+U.focusActionLabel),U.pendingCountLabel&&Ct.push(U.pendingCountLabel),U.changeLabel&&Ct.push(U.changeLabel),U.impactLabel&&Ct.push(U.impactLabel),U.scopeLabel&&Ct.push(U.scopeLabel),U.languageLabel&&Ct.push(U.languageLabel),U.text&&Ct.push("Current: "+U.text),U.resultText&&Ct.push("Suggested: "+U.resultText),U.reasonText&&Ct.push("Why this next: "+U.reasonText),Re.setAttribute("aria-label",fe(Ct)),Re.setAttribute("data-rte-ai-primary-label",U.actionLabel||U.label||"Open next queue"),U.focusActionLabel&&Re.setAttribute("data-rte-ai-empty-focus-label",U.focusActionLabel),U.changeLabel&&Re.setAttribute("data-rte-ai-preview-change-label",U.changeLabel),U.impactLabel&&Re.setAttribute("data-rte-ai-preview-impact-label",U.impactLabel),U.suggestionId&&Re.setAttribute("data-rte-ai-preview-suggestion-id",U.suggestionId),Re.onclick=(function(S){return function(){Zt({id:"go-type",typeValue:S.typeValue,suggestionId:S.suggestionId,focusAction:S.focusAction||""})}})(U),Re.onfocus=function(){na(this),pt(this,this.getAttribute("data-rte-ai-primary-label")||this.innerText||"",{announce:Je.length>1})},Re.onkeydown=function(S){var ie=(S.key||"").toLowerCase();ie==="u"&&S.shiftKey&&nr()?(S.preventDefault(),S.stopPropagation(),Jr({focusPanel:!0,focusAction:z()})):ie==="u"&&ar()?(S.preventDefault(),S.stopPropagation(),Cr({focusPanel:!0,focusAction:z()})):S.key==="ArrowRight"||S.key==="ArrowDown"||ie==="j"?(S.preventDefault(),wt("next")):S.key==="ArrowLeft"||S.key==="ArrowUp"||ie==="k"?(S.preventDefault(),wt("previous")):S.key==="Home"?(S.preventDefault(),wt("first")):S.key==="End"&&(S.preventDefault(),wt("last"))},Je.push(Re),s.__aiReviewPrimaryEmptyAction||pt(Re,U.actionLabel||U.label||"")}o(Re,"div","","rte-ai-review-empty-preview-label",U.label||"Next queue");var Gt=o(Re,"div","","rte-ai-review-empty-preview-meta");Re.__aiPreviewMetaNode=Gt,U.pendingCountLabel&&o(Gt,"span","","rte-ai-review-empty-preview-pill",U.pendingCountLabel),U.focusActionLabel&&o(Gt,"span","","rte-ai-review-empty-preview-pill is-focus","Focus "+U.focusActionLabel),U.changeLabel&&o(Gt,"span","","rte-ai-review-empty-preview-pill is-change",U.changeLabel),U.impactLabel&&o(Gt,"span","","rte-ai-review-empty-preview-pill is-impact",U.impactLabel),U.scopeLabel&&o(Gt,"span","","rte-ai-review-empty-preview-pill",U.scopeLabel),U.languageLabel&&o(Gt,"span","","rte-ai-review-empty-preview-pill",U.languageLabel);var Yt=Sn(U.text,U.resultText);fo(Re,"current",U.text||"",Yt),U.resultText&&fo(Re,"result",U.resultText,Yt),U.reasonText&&o(Re,"div","","rte-ai-review-empty-preview-reason","Why this next: "+U.reasonText)}}for(var cr=[],xi=0;xi<$e.actions.length;xi++)$e.actions[xi]&&cr.push($e.actions[xi]);if(cr.length){var dr=o(Rt,"div","","rte-ai-review-empty-zone is-actions");Et(dr,"rte-ai-review-section-label is-controls","Actions");for(var Ql=o(dr,"div","","rte-ai-review-empty-actions"),Si={},Oi=0;Oi<cr.length;Oi++)(function(S){var ie=rt(S);Si[ie.key]||(Si[ie.key]=o(Ql,"div","","rte-ai-review-empty-action-group is-"+ie.key),Si[ie.key].setAttribute("data-rte-ai-empty-group-label",ie.label));var Oe=Oi===0,Z=o(Si[ie.key],"button","",Oe&&!s.__aiReviewPrimaryEmptyAction?"rte-ai-review-control-button is-primary":"secondary rte-ai-review-control-button","");o(Z,"span","","rte-ai-review-empty-action-label",S.label),S.focusActionLabel&&o(Z,"span","","rte-ai-review-empty-action-pill is-focus","Focus "+S.focusActionLabel),Z.type="button",S.id&&Z.setAttribute("data-rte-ai-empty-action-id",S.id),Z.setAttribute("aria-keyshortcuts",mo()),Z.title=go(S.label||"",{focusLabel:S.focusActionLabel}),S.focusActionLabel&&Z.setAttribute("data-rte-ai-empty-focus-label",S.focusActionLabel),S.suggestionId&&Z.setAttribute("data-rte-ai-preview-suggestion-id",S.suggestionId),Oe&&Z.setAttribute("data-rte-ai-primary-button","true"),Oe&&!s.__aiReviewPrimaryEmptyAction&&pt(Z,S.label||""),Z.onfocus=function(){na(Z),(S.id==="go-type"||S.id==="next-overall")&&Au(S.suggestionId||""),Ie(k(Z,S.label||""))},Z.onkeydown=function(we){(we.key||"").toLowerCase()==="u"&&we.shiftKey&&nr()?(we.preventDefault(),we.stopPropagation(),Jr({focusPanel:!0,focusAction:z()})):(we.key||"").toLowerCase()==="u"&&ar()&&(we.preventDefault(),we.stopPropagation(),Cr({focusPanel:!0,focusAction:z()}))},Z.onclick=function(){Zt(S)}})(cr[Oi])}var $a=We||(cr[0]?cr[0].label:"");Ie($a)}for(var f="",g=0;g<P.length;g++)(function(k){var re=s.__aiRecentlyOpenedQueueSuggestionId===k.id,Ie=ka(P,s.__aiActiveSuggestionId,k),rt=Yc(P,s.__aiActiveSuggestionId,k,Ie);if(rt&&rt.key!==f){var pt=o(Mr,"div","","rte-ai-review-feed-section is-"+rt.key),wt=o(pt,"div","","rte-ai-review-feed-section-meta"),Zt=o(wt,"div","","rte-ai-review-feed-section-title",rt.label);Zt.setAttribute("role","heading"),Zt.setAttribute("aria-level","3"),rt.countLabel&&o(wt,"span","","rte-ai-review-feed-section-pill",rt.countLabel),rt.detail&&o(pt,"div","","rte-ai-review-feed-section-detail",rt.detail),f=rt.key}var S=gi(P,s.__aiActiveSuggestionId,k),ie=s.__aiActiveSuggestionId===k.id,Oe=!ie&&!re,Z=o(Mr,"div","","rte-ai-review-item is-"+k.status+(ie?" is-active":"")+(re?" is-opened":"")+(Oe?" is-condensed":""));Z.setAttribute("data-rte-ai-review-id",k.id),Z.setAttribute("data-rte-ai-review-density",Oe?"condensed":"expanded"),Ie&&Ie.role&&Z.setAttribute("data-rte-ai-review-queue-role",Ie.role),Z.setAttribute("role","button"),Z.tabIndex=s.__aiActiveSuggestionId===k.id?0:-1,Z.setAttribute("aria-keyshortcuts",jn(k.status==="pending"?"Enter Space A R J K Home End":"Enter Space J K Home End")),Z.title=Fl(k,z(G));var we=Jt(k.id);s.__aiActiveSuggestionId===k.id&&Z.setAttribute("aria-current","true"),Z.onclick=function(va){if(!(va&&va.target&&va.target.closest&&va.target.closest(".rte-ai-review-item-actions"))){var rs=z(G),$n=document.activeElement;$n&&$n.getAttribute&&G.contains($n)&&(rs=$n.getAttribute("data-rte-ai-review-action")||rs),!uu(k.id,rs)&&wi(k.id,{focusPanel:!0})}},Z.onfocus=function(){na(Z),Z.title=Fl(k,z(G)),wu(k),Oe&&Ln(Z,k,G)};var Gr=o(Z,"div","","rte-ai-review-item-state is-"+k.status+(ie?" is-current":"")+(re?" is-opened":""));if(o(Gr,"div","","rte-ai-review-item-state-kicker",k.status==="pending"?"Review item":"Review history"),o(Gr,"div","","rte-ai-review-item-state-title",sd(k,ie,re)),o(Gr,"div","","rte-ai-review-item-state-detail",od(k,ie,re,we)),Ie){var li=o(Z,"div","","rte-ai-review-item-queue-card is-"+Ie.role);o(li,"div","","rte-ai-review-item-queue-title",Ie.roleLabel);var Fn=o(li,"div","","rte-ai-review-item-queue-meta");o(Fn,"span","","rte-ai-review-item-queue-pill is-role",Ie.roleLabel),o(Fn,"span","","rte-ai-review-item-queue-pill is-position",Ie.queueLabel),o(li,"div","","rte-ai-review-item-queue-detail",Ie.detail)}if(S){var Ja=o(Z,"div","","rte-ai-review-item-transition-card");o(Ja,"div","","rte-ai-review-item-transition-title",S.title);var Nn=o(Ja,"div","","rte-ai-review-item-transition-meta");if(o(Nn,"span","","rte-ai-review-item-transition-pill is-status",S.statusLabel),o(Nn,"span","","rte-ai-review-item-transition-pill is-position",S.queueLabel),S.typeLabel&&o(Nn,"span","","rte-ai-review-item-transition-pill is-type",S.typeLabel),S.scopeLabel&&o(Nn,"span","","rte-ai-review-item-transition-pill is-scope",S.scopeLabel),o(Ja,"div","","rte-ai-review-item-transition-detail",S.detail),no(Ja,"rte-ai-review-item-transition-preview",S),S.followupTitle){var $l=o(Ja,"div","","rte-ai-review-item-transition-followup");o($l,"div","","rte-ai-review-item-transition-followup-title",S.followupTitle);var jf=o($l,"div","","rte-ai-review-item-transition-followup-meta");S.followupStatusLabel&&o(jf,"span","","rte-ai-review-item-transition-pill is-followup",S.followupStatusLabel),o($l,"div","","rte-ai-review-item-transition-followup-detail",S.followupDetail)}}var Gi=o(Z,"div","","rte-ai-review-item-meta");o(Gi,"span","","rte-ai-review-item-status is-"+k.status,Sa(k.status)),o(Gi,"span","","rte-ai-review-item-stamp",k.sourceLabel||(k.snapshot&&k.snapshot.hasSelection?"Selection suggestion":"Document suggestion")),ie&&o(Gi,"span","","rte-ai-review-item-stamp is-current","Current"),re&&o(Gi,"span","","rte-ai-review-item-stamp is-opened","Queue opened"),k.suggestionType&&k.suggestionType!=="other"&&o(Gi,"span","","rte-ai-review-item-stamp is-type",Me(k.suggestionType)),k.language&&o(Gi,"span","","rte-ai-review-item-stamp is-language",ot(k.language)),we&&o(Gi,"span","","rte-ai-review-item-stamp is-remote",we>1?we+" shared updates":"Shared update");var Kn=o(Z,"div","","rte-ai-review-item-summary");o(Kn,"div","","rte-ai-review-item-title",Ye(k.originalText||k.resultText||"AI suggestion",80)),Oe&&id(Kn,k,G,{queuePositionData:Ie,queueTransitionData:S,sharedUpdateCount:we});var er=Bi(k);if(er){var Jl=o(Kn,"div","","rte-ai-review-item-glance-card");if(o(Jl,"div","","rte-ai-review-item-glance-title",er.title),er.pills&&er.pills.length)for(var Of=o(Jl,"div","","rte-ai-review-item-glance-meta"),Vl=0;Vl<er.pills.length;Vl++){var Su=er.pills[Vl];o(Of,"span","","rte-ai-review-item-glance-pill is-"+Su.kind,Su.text)}er.detail&&o(Jl,"div","","rte-ai-review-item-glance-detail",er.detail)}if(k.reason){var Tu=o(Kn,"div","","rte-ai-review-item-reason-card");o(Tu,"div","","rte-ai-review-item-reason-label","Why AI suggested this"),o(Tu,"div","","rte-ai-review-item-reason",k.reason)}var Wl=o(Z,"div","","rte-ai-review-item-compare"),Lu=o(Wl,"div","","rte-ai-review-item-compare-header");o(Lu,"div","","rte-ai-review-item-compare-title","Compare change"),o(Lu,"div","","rte-ai-review-item-compare-detail","Original and suggested text");var Ru=Sn(k.originalText||"",k.resultText||""),Gf=o(Wl,"div","","rte-ai-review-item-before");Tn(Gf,"current",E(k.originalText||""),Ru);var Uf=o(Wl,"div","","rte-ai-review-item-after");Tn(Uf,"result",E(k.resultText||""),Ru);var ua=ie&&k.status==="pending"&&j?Pt(j):null,Cu=ua?wa(j):"",zn=ua?fl(1):[];if(ua)var Ff=o(Z,"div","","rte-ai-review-item-undo-note",Cu+" Press U to "+ua.shortcutLabel+"."),ku=_n(Ff,"undo-note",k.id);var Va=null;zn.length&&(Va=Os(Z,zn,"undo"),_n(Va,"undo-history",k.id));var Nf=!!(se&&se.suggestion&&se.suggestion.id===k.id&&k.status==="pending"),ca=Nf?qt(se):null,Eu=ca?mn(se):"",Bl="";if(ca){var Kf=o(Z,"div","","rte-ai-review-item-redo-note",Eu+" Press Shift+U to "+ca.shortcutLabel+".");Bl=_n(Kf,"redo-note",k.id)}var Wa=null,Qn=ca?vl(1):[];Qn.length&&(Wa=Os(Z,Qn,"redo"),_n(Wa,"redo-history",k.id)),Z.setAttribute("aria-label",Xc(k,{isCurrent:s.__aiActiveSuggestionId===k.id,queueOpened:re,queueRoleLabel:Ie?Ie.roleLabel:"",queuePositionLabel:Ie?Ie.queueLabel:"",transitionLabel:S?S.title+". "+S.statusLabel+". "+S.queueLabel+". "+Wr(S)+(S.followupTitle?". "+S.followupTitle+". "+S.followupDetail:""):"",changeSummary:er?er.title+". "+(er.pills||[]).map(function(va){return va.text}).join(". ")+(er.detail?". "+er.detail:""):"",remoteUpdateCount:we,undoLabel:Cu,undoNextLabel:zn.length?"Undo after this: "+zn[0].detail:"",redoLabel:Eu,redoNextLabel:Qn.length?"Redo after this: "+Qn[0].detail:""})),Z.setAttribute("data-rte-ai-review-base-aria-label",Z.getAttribute("aria-label")||""),Oe&&(po(Z,k,G),Ln(Z,k,G));var Xl=o(Z,"div","","rte-ai-review-item-actions"),Pu=o(Xl,"div","","rte-ai-review-item-action-group is-locate");Pu.setAttribute("data-rte-ai-review-action-group","locate");var Yl=o(Xl,"div","","rte-ai-review-item-action-group is-decision");Yl.setAttribute("data-rte-ai-review-action-group","decision");var Zl=o(Xl,"div","","rte-ai-review-item-action-group is-recovery");Zl.setAttribute("data-rte-ai-review-action-group","recovery");var Ba=o(Pu,"button","","secondary rte-ai-review-action-button is-locate","Locate");if(Ba.type="button",Ba.setAttribute("data-rte-ai-review-action","locate"),Ba.disabled=k.status!=="pending"&&k.status!=="stale",Ba.onclick=function(){Dt(k.id)},Ka(Ba,x,k.id,"locate"),k.status==="pending"){var es=bi(k,"accept",x)||{text:"Accept",label:"Accept this AI change"},da=o(Yl,"button","","rte-ai-review-action-button is-primary is-accept",es.text);da.type="button",da.setAttribute("data-rte-ai-review-action","accept"),da.setAttribute("aria-label",es.label),da.title=es.label,da.onclick=function(){Mi(k.id,"accept",{focusAction:"accept"})},Ka(da,x,k.id,"accept");var ts=bi(k,"reject",x)||{text:"Reject",label:"Reject this AI change"},fa=o(Yl,"button","","secondary rte-ai-review-action-button is-reject",ts.text);if(fa.type="button",fa.setAttribute("data-rte-ai-review-action","reject"),fa.setAttribute("aria-label",ts.label),fa.title=ts.label,fa.onclick=function(){Mi(k.id,"reject",{focusAction:"reject"})},Ka(fa,x,k.id,"reject"),ua){var Xa=o(Zl,"button","","secondary rte-ai-review-action-button is-undo",ua.actionLabel);Xa.type="button",Xa.setAttribute("data-rte-ai-review-action","undo"),ku&&Xa.setAttribute("data-rte-ai-review-extra-describedby",ku+(Va&&Va.id?" "+Va.id:"")),Xa.onclick=function(){Cr({focusPanel:!0,focusAction:"undo"})},Ka(Xa,x,k.id,"undo")}if(ca){var Ya=o(Zl,"button","","secondary rte-ai-review-action-button is-redo",ca.actionLabel);Ya.type="button",Ya.setAttribute("data-rte-ai-review-action","redo"),Bl&&Ya.setAttribute("data-rte-ai-review-extra-describedby",Bl+(Wa&&Wa.id?" "+Wa.id:"")),Ya.onclick=function(){Jr({focusPanel:!0,focusAction:"redo"})},Ka(Ya,x,k.id,"redo")}}})(P[g]);var A=!!e||u||!!p,q=_f(Mr,A,p||d);Ua(p||d||z(G)),Fa(p||d||z(G));var O=Ni().slice(0,6);if(O.length){o(Mr,"div","","rte-ai-review-history-title","Recent activity");for(var le=0;le<O.length;le++){var de=O[le],ae=lc(de),Fe=o(Mr,"div","","rte-ai-review-history-entry is-"+ae);Fe.setAttribute("data-rte-ai-review-event",de.eventType||"suggestion-updated");var st=o(Fe,"div","","rte-ai-review-history-header");o(st,"span","","rte-ai-review-history-event is-"+ae,Ss(de));var ft=[];de.sourceLabel&&ft.push(de.sourceLabel),de.suggestionType&&de.suggestionType!=="other"&&ft.push(Me(de.suggestionType)),de.language&&ft.push(ot(de.language)),o(st,"div","","rte-ai-review-history-meta",ft.join(" - ")||"AI review"),o(Fe,"div","","rte-ai-review-history-text",Ye(de.resultText||de.originalText||"AI review event",120))}}return A&&setTimeout(function(){var k=null;l&&G&&G.querySelector&&(k=G.querySelector('[data-rte-ai-review-focus-key="'+l+'"]'),k&&k.disabled&&(k=null),k&&k.focus&&k.focus()),!k&&s.__aiReviewPrimaryEmptyAction&&s.__aiReviewPrimaryEmptyAction.isConnected&&!s.__aiReviewPrimaryEmptyAction.disabled&&s.__aiReviewPrimaryEmptyAction.focus?s.__aiReviewPrimaryEmptyAction.focus():!k&&!q&&G&&G.focus&&G.focus()},0),!0}function sa(e){e=e||{},s.__aiDialog&&s.__aiDialog.isConnected&&s.__aiDialog.close();var t=ut(),r=s.createDialog(L.text_aiassist||"Ask AI","rte-panel-aiassist");r.__aiSnapshot=t,s.__aiDialog=r,r.__aiOperationStates={},r.__aiPlanStale=!1,r.__aiPlanStaleReason="",r.__aiPlanStaleAction="",r._onclose=function(){s.__aiDialog===r&&(s.__aiDialog=null)};var i=document.createElement("span");i.className="rte-ai-dialog-mode-chip is-detached",i.setAttribute("aria-hidden","true"),ha(r);var a=o(r,"div","","demo-ai-dialog-grid"),n=String(Date.now())+"-"+String(Math.floor(Math.random()*1e6)),l="rte-ai-mode-help-"+n,u="rte-ai-source-help-"+n,d="rte-ai-result-help-"+n,p="rte-ai-apply-guidance-"+n,m="rte-ai-dialog-status-"+n;a.setAttribute("role","form"),a.setAttribute("aria-label",c.__aiT?c.__aiT("aid_controls","Ask AI controls"):"Ask AI controls");var w=o(a,"div","","demo-ai-compact-controls");w.setAttribute("role","group"),w.setAttribute("aria-label",c.__aiT?c.__aiT("aid_setup","Ask AI setup"):"Ask AI setup");var y=o(w,"div","","demo-ai-field demo-ai-action-field"),v=o(y,"select");v.setAttribute("aria-label",c.__aiT?c.__aiT("aid_action","AI action"):"AI action");var h=document.createElement("div");h.className="demo-ai-mode-caption is-detached",h.id=l;var _=o(w,"div","","demo-ai-field demo-ai-language-field"),b=o(_,"select");if(b.setAttribute("aria-label",c.__aiT?c.__aiT("aid_targetlang","Translation target language"):"Translation target language"),ei(),e.presetMode){for(var H=!1,x=0;x<v.options.length;x++)if(v.options[x].value===e.presetMode){H=!0;break}H&&(v.value=e.presetMode)}v.options.length&&v.selectedIndex<0&&(v.selectedIndex=0),Mt(),v.setAttribute("aria-describedby",l);var R=o(w,"div","","demo-ai-field demo-ai-scope-field"),C=o(R,"select","","demo-ai-scope-select");C.setAttribute("aria-label",c.__aiT?c.__aiT("aid_source","Source for Ask AI"):"Source for Ask AI"),C.setAttribute("data-rte-ai-dialog-action","scope");var P=o(C,"option","","",c.__aiT?c.__aiT("aid_selection","Selection"):"Selection");P.value="selection";var T=o(C,"option","","",c.__aiT?c.__aiT("aid_document","Document"):"Document");T.value="document";var D=o(R,"span","","demo-ai-scope-caption");D.setAttribute("aria-hidden","true");var F=R.ownerDocument.createElement("div");F.className="demo-actions-row demo-ai-scope-row is-detached",F.setAttribute("role","group"),F.setAttribute("aria-label",c.__aiT?c.__aiT("aid_scope","Source scope"):"Source scope");var M=R.ownerDocument.createElement("button");M.type="button",M.className="is-icon-only",M.setAttribute("data-rte-ai-dialog-action","load-selection"),M.title=c.__aiT?c.__aiT("aid_usesel","Use selection"):"Use selection",M.setAttribute("aria-label",c.__aiT?c.__aiT("aid_usesel","Use selection"):"Use selection"),he(M,"cursorText",""),F.appendChild(M);var V=R.ownerDocument.createElement("button");V.type="button",V.className="secondary is-icon-only",V.setAttribute("data-rte-ai-dialog-action","load-document"),V.title=c.__aiT?c.__aiT("aid_usedoc","Use document"):"Use document",V.setAttribute("aria-label",c.__aiT?c.__aiT("aid_usedoc","Use document"):"Use document"),he(V,"document",""),F.appendChild(V),R.appendChild(F);var ve=o(w,"div","","demo-ai-field demo-ai-run-field"),X=o(ve,"div","","demo-actions-row demo-ai-run-row");X.setAttribute("role","group"),X.setAttribute("aria-label",c.__aiT?c.__aiT("aid_run","Ask AI run actions"):"Ask AI run actions");var j=o(X,"button","","is-primary");j.type="button",j.setAttribute("data-rte-ai-dialog-action","run"),he(j,"sparkles",c.__aiT?c.__aiT("aid_generate","Generate"):"Generate"),j.title=c.__aiT?c.__aiT("ai2_gentitle","Generate AI suggestion (Ctrl+Enter)"):"Generate AI suggestion (Ctrl+Enter)",j.setAttribute("aria-keyshortcuts","Control+Enter");var se=/Mac|iPad|iPhone|iPod/i.test((navigator.platform||"")+" "+(navigator.userAgent||"")),ee=se?"\u2318\u23CE":"Ctrl \u23CE";function oe(){if(j){var f=j.querySelector(".demo-ai-kbd-hint");f&&f.parentNode.removeChild(f);var g=j.ownerDocument.createElement("span");g.className="demo-ai-kbd-hint",g.setAttribute("aria-hidden","true"),g.textContent=ee,j.appendChild(g)}}oe();var Y=o(X,"button","","secondary is-icon-only");Y.type="button",Y.title="Copy result into source",Y.setAttribute("aria-label","Copy result into source"),Y.setAttribute("data-rte-ai-dialog-action","copy-to-source"),he(Y,"checkAll","");var G=document.createElement("span");a.appendChild(h);var N=o(a,"div","","demo-ai-text-grid");N.setAttribute("role","group"),N.setAttribute("aria-label",c.__aiT?c.__aiT("aid_srcresult","Ask AI source and result"):"Ask AI source and result");var Te=o(N,"div","","demo-ai-field demo-ai-source-field");o(Te,"span","","demo-ai-text-label-inline is-detached","Source");var ce=o(Te,"span","","demo-ai-field-help is-detached","Edit the source text or prompt that Ask AI will use.");ce.id=u;var W=o(Te,"textarea");W.setAttribute("aria-label",c.__aiT?c.__aiT("aid_srctext","Source text for Ask AI"):"Source text for Ask AI"),W.setAttribute("aria-describedby",u+" "+l),Te.appendChild(X),W.rows=1,W.placeholder=c.__aiT?c.__aiT("aid_typeorpaste","Type or paste text\u2026"):"Type or paste text\u2026";var Ce=o(Te,"span","","demo-ai-source-counter");Ce.setAttribute("aria-hidden","true");function ke(){if(Ce){var f=W.value||"",g=f.length;if(!g){Ce.textContent="",Ce.classList.remove("is-visible");return}var A=g>999?c.__aiT?c.__aiT("aid_kchars","{0}K chars",Math.round(g/100)/10):Math.round(g/100)/10+"K chars":g===1?c.__aiT?c.__aiT("aid_char","1 char"):"1 char":c.__aiT?c.__aiT("aid_chars","{0} chars",g):g+" chars";Ce.textContent=A,Ce.classList.add("is-visible")}}Te.style.order="2";var ye=o(N,"div","","demo-ai-field demo-ai-result-field");ye.style.order="1";var Ee=o(ye,"div","","demo-ai-result-head"),Ze=document.createElement("span");Ze.className="demo-ai-text-label-inline is-detached",Ze.innerText="Result";var gt=o(ye,"span","","demo-ai-field-help is-detached","Review the generated AI suggestion before applying it.");gt.id=d;var De=o(Ee,"button","","demo-ai-clipboard-toggle");De.type="button",De.setAttribute("data-rte-ai-dialog-action","copy-clipboard"),De.title=c.__aiT?c.__aiT("ai2_copyclip","Copy AI output to clipboard"):"Copy AI output to clipboard",De.setAttribute("aria-label",c.__aiT?c.__aiT("ai2_copyclip","Copy AI output to clipboard"):"Copy AI output to clipboard"),he(De,"clipboard",c.__aiT?c.__aiT("ai2_copy","Copy"):"Copy");var ze=null;De.onclick=function(f){f&&f.stopPropagation&&f.stopPropagation(),E($.value)&&So($.value).then(function(g){g&&(De.classList.add("is-copied"),he(De,"check",c.__aiT?c.__aiT("aic_copied","Copied"):"Copied"),ze&&clearTimeout(ze),ze=setTimeout(function(){De.classList.remove("is-copied"),he(De,"clipboard",c.__aiT?c.__aiT("ai2_copy","Copy"):"Copy"),ze=null},1400))})};var _e=o(Ee,"button","","demo-ai-clipboard-toggle demo-ai-why-toggle");_e.type="button",_e.setAttribute("data-rte-ai-dialog-action","why"),_e.title=c.__aiT?c.__aiT("ai2_whytitle","Why this AI suggestion?"):"Why this AI suggestion?",_e.setAttribute("aria-label",c.__aiT?c.__aiT("ai2_whyaria","Show why this AI suggestion was generated"):"Show why this AI suggestion was generated"),_e.setAttribute("aria-expanded","false"),he(_e,"info","");var J=o(Ee,"button","","demo-ai-source-toggle");J.type="button",J.setAttribute("aria-expanded","false"),J.setAttribute("aria-controls","rte-ai-source-"+Date.now()),J.title=c.__aiT?c.__aiT("ai2_editretry","Edit the prompt and retry"):"Edit the prompt and retry",J.setAttribute("aria-label",c.__aiT?c.__aiT("ai2_editretry","Edit the prompt and retry"):"Edit the prompt and retry"),J.innerText=c.__aiT?c.__aiT("ai2_edit","Edit"):"Edit",Te.id=J.getAttribute("aria-controls"),J.onclick=function(f){f&&f.stopPropagation&&f.stopPropagation();var g=a.classList.toggle("is-source-expanded");J.setAttribute("aria-expanded",g?"true":"false"),g&&W.focus()};var $=o(ye,"textarea");$.readOnly=!0,$.setAttribute("aria-label",c.__aiT?c.__aiT("ai2_result","AI suggestion result"):"AI suggestion result"),$.setAttribute("aria-describedby",d+" "+m),$.rows=1,$.placeholder=c.__aiT?c.__aiT("ai2_outputph","Output appears here."):"Output appears here.";var je=document.createElement("pre"),et=document.createElement("pre"),B=document.createElement("div");B.className="demo-ai-refine-row is-detached",B.setAttribute("role","group"),B.setAttribute("aria-label","Refine AI suggestion"),a.appendChild(B);var K=o(B,"button","","secondary demo-ai-refine-chip");K.type="button",K.title=c.__aiT?c.__aiT("ai2_retrytitle","Re-run with the same prompt"):"Re-run with the same prompt",K.setAttribute("data-rte-ai-dialog-action","refine-retry"),he(K,"refresh",c.__aiT?c.__aiT("ai2_tryagain","Try again"):"Try again");var ne=o(B,"button","","secondary demo-ai-refine-chip");ne.type="button",ne.title=c.__aiT?c.__aiT("ai2_shortertitle","Make the suggestion shorter"):"Make the suggestion shorter",ne.setAttribute("data-rte-ai-dialog-action","refine-shorter"),he(ne,"shrink",c.__aiT?c.__aiT("ai2_shorter","Shorter"):"Shorter");var Ae=o(B,"button","","secondary demo-ai-refine-chip");Ae.type="button",Ae.title=c.__aiT?c.__aiT("ai2_longertitle","Expand the suggestion with more detail"):"Expand the suggestion with more detail",Ae.setAttribute("data-rte-ai-dialog-action","refine-longer"),he(Ae,"expand",c.__aiT?c.__aiT("ai2_longer","Longer"):"Longer");var I=document.createElement("button");I.type="button",I.className="secondary demo-ai-refine-chip demo-ai-refine-why-chip is-detached",I.innerText="Why",I.title=c.__aiT?c.__aiT("ai2_whyaria","Show why this AI suggestion was generated"):"Show why this AI suggestion was generated",I.setAttribute("data-rte-ai-dialog-action","refine-why"),I.setAttribute("aria-expanded","false");function be(f){E($.value)&&(W.value=f+`
|
|
13
13
|
|
|
14
|
-
`+Q.value,yi(),I&&!I.disabled&&I.onclick&&I.onclick())}U.onclick=function(){I&&!I.disabled&&I.onclick&&I.onclick()},ae.onclick=function(){me("Rewrite to be noticeably shorter and more concise while keeping the meaning intact.")},ye.onclick=function(){me("Expand with more supporting detail, examples, and depth while keeping the same voice.")},C.onclick=function(d){d&&d.stopPropagation&&d.stopPropagation();var v=Ce.classList.toggle("is-collapsed"),w=!v;C.setAttribute("aria-expanded",w?"true":"false"),ge&&ge.setAttribute&&(ge.setAttribute("aria-expanded",w?"true":"false"),ge.classList.toggle("is-active",w)),ke&&ke.setAttribute&&ke.setAttribute("aria-expanded",w?"true":"false")},ge.onclick=function(d){d&&d.stopPropagation&&d.stopPropagation();var v=Ce.classList.toggle("is-collapsed"),w=!v;ge.setAttribute("aria-expanded",w?"true":"false"),ge.classList.toggle("is-active",w),C&&C.setAttribute&&C.setAttribute("aria-expanded",w?"true":"false"),ke&&ke.setAttribute&&ke.setAttribute("aria-expanded",w?"true":"false")};var N=o(a,"div","","demo-actions-row demo-ai-apply-row");N.setAttribute("role","group"),N.setAttribute("aria-label","Ask AI apply actions");var ee=o(N,"button","","is-primary");ee.type="button",ee.disabled=!0,ee.setAttribute("data-rte-ai-dialog-action","apply"),ee.title="Apply AI suggestion (Ctrl+Enter)",ee.setAttribute("aria-keyshortcuts","Control+Enter"),ve(ee,"check","Apply");var Ae=o(N,"button","","");Ae.type="button",Ae.disabled=!t.hasSelection,Ae.setAttribute("data-rte-ai-dialog-action","selection"),ve(Ae,"check","Replace selection");var Se=o(N,"button","","secondary");Se.type="button",Se.disabled=!t.hasSelection,Se.setAttribute("data-rte-ai-dialog-action","preview"),ve(Se,"eyeOn","Preview");var _e=o(N,"button","","secondary");_e.type="button",_e.setAttribute("data-rte-ai-dialog-action","insert"),ve(_e,"arrowRight","Insert below");var Oe=o(N,"button","","secondary");Oe.type="button",Oe.setAttribute("data-rte-ai-dialog-action","document"),ve(Oe,"checkAll","Replace document");var oe=o(N,"button","","secondary demo-ai-apply-more-toggle is-icon-only");oe.type="button",oe.setAttribute("data-rte-ai-dialog-action","more"),oe.setAttribute("aria-expanded","false"),oe.title="More apply options",oe.setAttribute("aria-label","More apply options"),ve(oe,"more",""),oe.onclick=function(d){d&&d.stopPropagation&&d.stopPropagation();var v=N.classList.toggle("is-show-more");oe.setAttribute("aria-expanded",v?"true":"false")},N.insertBefore(U,oe),N.insertBefore(ae,oe),N.insertBefore(ye,oe);var xt=document.createElement("button");xt.type="button",xt.className="secondary is-detached",xt.setAttribute("data-rte-ai-dialog-action","reject"),ve(xt,"trash","Discard");var Ne=document.createElement("div");Ne.id=f,Ne.className="demo-ai-apply-guidance",Ne.style.display="none",Ne.setAttribute("role","group"),Ne.setAttribute("aria-label","Best next step");var _t=o(Ne,"div","","demo-ai-apply-guidance-header"),tt=o(_t,"span","","demo-ai-apply-guidance-title","Next"),vr=o(_t,"span","","demo-ai-apply-guidance-badge"),ir=o(Ne,"div","","demo-ai-apply-guidance-detail");a.appendChild(Ne);var ht=o(a,"div","","demo-ai-dialog-status");ht.id=p,ht.setAttribute("role","status"),ht.setAttribute("aria-live","polite"),ht.setAttribute("aria-atomic","true");var ke=o(a,"button","","demo-ai-details-toggle","Details");ke.type="button",ke.setAttribute("aria-expanded","false"),ke.setAttribute("aria-controls","rte-ai-details-"+l),ke.title="Show why and the operation plan";var Ce=o(a,"div","","demo-ai-insight-grid is-collapsed");Ce.id=ke.getAttribute("aria-controls"),C&&C.setAttribute&&C.setAttribute("aria-controls",Ce.id),ge&&ge.setAttribute&&ge.setAttribute("aria-controls",Ce.id),a.insertBefore(ke,N),a.insertBefore(Ce,N),ke.onclick=function(){var d=Ce.classList.toggle("is-collapsed");ke.setAttribute("aria-expanded",d?"false":"true")};var zt=o(Ce,"div","","demo-ai-reason-panel");zt.setAttribute("role","group"),zt.setAttribute("aria-label","AI rationale"),o(zt,"label","","","Why");var gt=o(zt,"div","","demo-ai-reason-copy","The reason will appear here once a suggestion is generated."),mt=o(Ce,"div","","demo-ai-plan-panel");mt.setAttribute("role","group"),mt.setAttribute("aria-label","AI operation plan"),o(mt,"label","","","Plan");var qi=document.createElement("div"),ar=o(mt,"div","","demo-ai-plan-status"),Xr=o(ar,"span","","demo-ai-plan-status-message"),Fe=o(ar,"button","","secondary demo-ai-plan-status-action","Re-run");Fe.type="button",Fe.style.display="none",Fe.setAttribute("data-rte-ai-dialog-action","rerun");var Cr=o(mt,"div","","demo-ai-plan-summary"),Jt=o(mt,"ul","","demo-ai-plan-list");function nr(d){var v=r.__aiResolved;return v&&v.operations&&v.operations.length?v:Kr(Q.value,d,v||null,v?v.request:null,v?v.action:null)}function Yr(){var d=Jn();b.innerHTML="";for(var v={proofread:"Edit text",rewrite:"Edit text",shorten:"Edit text",expand:"Edit text",translate:"Transform",summarize:"Transform",justify:"Transform"},w=["Edit text","Transform"],T={},H=[],ne=0;ne<d.length;ne++){var ce=d[ne],ie=ce.group||v[ce.id]||"";if(!ie){H.push(ce);continue}T[ie]||(T[ie]=[],w.indexOf(ie)===-1&&w.push(ie)),T[ie].push(ce)}function Ge(Ai,Tt){var Dr=o(Ai,"option","","",Tt.title||Tt.id);Dr.value=Tt.id,Tt.description&&(Dr.title=Tt.description)}for(var nt=0;nt<w.length;nt++){var ct=T[w[nt]];if(!(!ct||!ct.length)){var xr=o(b,"optgroup");xr.label=w[nt];for(var dt=0;dt<ct.length;dt++)Ge(xr,ct[dt])}}for(var ri=0;ri<H.length;ri++)Ge(b,H[ri]);b.options.length&&b.selectedIndex<0&&(b.selectedIndex=0),rt(),Pt()}function rt(){var d=fa();A.innerHTML="";for(var v=0;v<d.length;v++){var w=o(A,"option","","",d[v].label||d[v].value);w.value=d[v].value||d[v].label}e.presetLanguage&&(A.value=e.presetLanguage),!A.value&&d.length&&(A.value=d[0].value||d[0].label)}function It(){var d=b.value==="translate";y.style.display=d?"":"none",g&&g.classList&&g.classList.toggle("is-no-language",!d)}function pr(){if(!X)return"";var d=r.__aiSourceScope==="selection"?"selection":"document",v=r.__aiSnapshot,w=X.value||"",T=d,H=0;if(w)H=w.length,r.__aiSourceLinkedToEditor||(T="typed");else if(v){var ne=d==="selection"?v.text||"":v.wholeText||"";H=ne.length,d==="selection"&&!v.hasSelection&&(T="document",H=(v.wholeText||"").length)}if(!H)return"";var ce=H>999?Math.round(H/100)/10+"K":String(H),ie;return T==="typed"?ie="Typed prompt":T==="selection"?ie="Selection":ie="Document",ie+" \xB7 "+ce+" chars"}function mi(){if(!r||!r.querySelector)return null;var d=r.querySelector("rte-dialog-header");if(!d)return null;var v=d.querySelector(".rte-ai-dialog-header-caption");if(v)return v;v=r.ownerDocument.createElement("span"),v.className="rte-ai-dialog-header-caption",v.setAttribute("aria-hidden","true");var w=d.querySelector("rte-dialog-header-text");return w&&w.parentNode===d?(w.style&&(w.style.flex="0 0 auto",w.style.whiteSpace="nowrap"),w.nextSibling?d.insertBefore(v,w.nextSibling):d.appendChild(v)):d.appendChild(v),v}function hr(d){if(!(!r||!r.querySelector)){var v=r.querySelector("rte-dialog-header rte-dialog-header-text")||r.querySelector("rte-dialog-header-text");if(v){var w=k.text_aiassist||"Ask AI",T=d||"";T&&b.value==="translate"&&(T=T+" ("+lt(A.value||"spanish")+")"),v.innerText=T||w,r.setAttribute&&r.setAttribute("aria-label",T?w+" \xB7 "+T:w)}}}function Pt(){for(var d=Jn(),v="Run this AI mode against the current source text.",w="",T=0;T<d.length;T++)if(d[T].id===b.value){w=d[T].title||d[T].id,d[T].id==="translate"?v=(d[T].description||"Prepare a translated draft in the selected language.")+" Current target: "+lt(A.value||"spanish")+".":v=d[T].description||"Run this AI mode against the current source text.";break}h.innerText=v,b&&b.setAttribute&&b.setAttribute("title",v);var H=mi();if(H&&(H.innerText=v||""),hr(w),X&&!X.value){var ne=b.value||"",ce={proofread:"Paste text to proofread\u2026",rewrite:"Paste text to rewrite\u2026",shorten:"Paste text to shorten\u2026",expand:"Paste text to expand\u2026",summarize:"Paste text to summarize\u2026",translate:"Paste text to translate\u2026",justify:"Paste text to rewrite + explain\u2026",explain:"Paste text to explain\u2026"};X.placeholder=ce[ne]||"Type or paste text\u2026"}if(i){var ie=w||"";w&&b.value==="translate"&&(ie=w+" \xB7 "+lt(A.value||"spanish")),i.innerText=ie,i.style.display=ie?"":"none"}It()}function Zr(d){return r.__aiOperationStates&&r.__aiOperationStates["step-"+d]?r.__aiOperationStates["step-"+d]:""}function Er(d,v){r.__aiOperationStates=r.__aiOperationStates||{},r.__aiOperationStates["step-"+d]=v||""}function Pr(){Ce&&Ce.classList&&Ce.classList.contains("is-collapsed")&&(Ce.classList.remove("is-collapsed"),ke&&ke.setAttribute&&ke.setAttribute("aria-expanded","true"))}function Ht(d,v){r.__aiPlanStale=!0,r.__aiPlanStaleReason=d||"Editor changed. Re-run to refresh.",r.__aiPlanStaleAction=v==="source"?"source":"editor",ht.innerText=r.__aiPlanStaleReason,$t(r.__aiResolved),or(),Pr()}function ot(d,v){return d?v==="selection"?d.text||d.wholeText||"":d.wholeText||"":""}function Vt(d,v){return v==="selection"&&(!d||!d.hasSelection)&&!r.__aiSourceLinkedToEditor&&!!R(X.value)}function ei(d,v){return v==="selection"?d&&d.hasSelection?"Selection ready":Vt(d,v)?"Selection source loaded - select text to apply inline":"No selection - using whole document":d&&d.hasSelection?"Whole document loaded - selection available":"Whole document loaded"}function lr(d,v){return v==="selection"&&d&&d.hasSelection?"selection":"document"}function ut(d){return!!d&&(d.type==="preview-suggestion"||d.type==="replace-selection")}function gr(d,v){var w=v&&v.length?v:null;if(!w){for(var T=0;T<d.length;T++)if(ut(d[T]))return!0;return!1}for(var H=0;H<w.length;H++)if(ut(d[w[H]]))return!0;return!1}function Mr(d){var v=r.__aiSourceScope==="selection"?"selection":"document";return r.__aiSourceLinkedToEditor?lr(d,v):v}function mr(d,v,w){return r.__aiPlanStale?r.__aiSourceLinkedToEditor?w:v:d&&d.request?d.request.scope==="selection"?"selection":"document":r.__aiSourceLinkedToEditor?w:v}function br(d,v,w,T){var H=d==="selection";return H?T?"Use selection. Active scope. Ask AI is keeping the current selection-based source. Select text to apply or reload it again.":!v||!v.hasSelection?"Use selection. Unavailable until text is selected.":w==="selection"?"Use selection. Active scope. Ask AI is using the current selection.":"Use selection. Available scope. Switch Ask AI to the current selection.":w==="selection"?"Use document. Available scope. Switch Ask AI to the whole document.":"Use document. Active scope. Ask AI is using the whole document."}function wr(){var d=r.__aiSourceScope==="selection"?"selection":"document",v=lr(r.__aiSnapshot,d),w=Vt(r.__aiSnapshot,d),T=w?"selection":v;if(j&&(j.innerText=ei(r.__aiSnapshot,d)),E&&(E.disabled=!r.__aiSnapshot||!r.__aiSnapshot.hasSelection),E&&E.setAttribute&&(E.setAttribute("aria-pressed",T==="selection"?"true":"false"),E.setAttribute("aria-label",br("selection",r.__aiSnapshot,T,w))),W&&W.setAttribute&&(W.setAttribute("aria-pressed",T==="document"?"true":"false"),W.setAttribute("aria-label",br("document",r.__aiSnapshot,T,w))),M){var H=r.__aiSnapshot,ne=!!(H&&H.hasSelection),ce=H?(H.wholeText||"").length:0;P.disabled=!ne,P.text=ne?"Selection":"Selection (none)",L.text="Document",M.value=T==="selection"?"selection":"document",M.setAttribute("title",ei(H,d)),D&&(D.innerText="Document"),g&&g.classList&&(ne?g.classList.remove("is-scope-implicit"):g.classList.add("is-scope-implicit"))}}function yr(d){return d?d>999?Math.round(d/100)/10+"K chars":d+" chars":"0"}function Ga(){r.__aiSourceLinkedToEditor=!1}function qr(d,v){return R(d&&d.text?d.text:"")!==R(v&&v.text?v.text:"")}function Qe(d,v,w){return d==="selection"?w&&w.hasSelection&&v&&!v.hasSelection?"Selection cleared. Re-run to refresh.":w&&v&&w.hasSelection&&v.hasSelection&&$n(w.range,v.range)&&qr(w,v)?"Selection text changed. Re-run to refresh.":"Selection changed. Re-run to refresh.":"Document changed. Re-run to refresh."}function Ve(d){return R(d)?"Source changed. Re-run to refresh.":"Source cleared. Reload from the editor or type source text before re-running."}function ti(){return"Mode changed. Re-run to refresh."}function ze(d){return"Language \u2192 "+lt(d||"spanish")+". Re-run to refresh."}function Ir(d){return"Scope \u2192 "+(d==="selection"?"selection":"document")+". Re-run to refresh."}function Lt(d){return"Reloaded from "+(d==="selection"?"selection":"document")+". Re-run to refresh."}function Ar(d,v,w){return d==="selection"?w&&w.hasSelection&&v&&!v.hasSelection?"Selection cleared. Re-run to refresh.":w&&v&&w.hasSelection&&v.hasSelection&&$n(w.range,v.range)&&qr(w,v)?"Selection text changed. Re-run to refresh.":"Selection changed. Re-run to refresh.":"Document changed. Re-run to refresh."}function Ft(d){for(var v=[],w=0;w<d.length;w++)Zr(w)!=="done"&&Zr(w)!=="skipped"&&v.push(w);return v}function Hr(){var d=r.__aiResolved&&r.__aiResolved.operations?r.__aiResolved.operations:[],v=Ft(d);if(v.length!==1)return"";var w=d[v[0]];return w&&w.type?w.type:""}function it(){var d=r.__aiResolved||null,v=d&&d.operations?d.operations:[],w=Ft(v),T=r.__aiSourceScope==="selection"?"selection":"document",H=lr(r.__aiSnapshot,T),ne=!!(r.__aiSnapshot&&r.__aiSnapshot.hasSelection),ce=!!R(Q.value),ie=mr(d,T,H),Ge=gr(v,w);return{hasSource:!!R(X.value),hasResult:ce,hasSelection:ne,isStale:!!r.__aiPlanStale,requestedScope:T,scope:H,actionScope:ie,staleAction:r.__aiPlanStaleAction==="source"?"source":"editor",operations:v,pendingIndexes:w,pendingSelectionDependent:Ge,canApplyPlan:!!w.length&&(!Ge||ne),canPreview:ce&&ie==="selection"&&ne,canReplaceSelection:ce&&ie==="selection"&&ne,canInsert:ce,canReplaceDocument:ce&&ie==="document",pendingOperationType:w.length===1&&v[w[0]]&&v[w[0]].type?v[w[0]].type:""}}function at(d,v){if(v=v||it(),d==="load-selection")return v.hasSelection?"Reload the current editor selection into Ask AI.":"Select text in the editor, then reload it into Ask AI.";if(d==="load-document")return"Reload the current editor document into Ask AI.";if(d==="run")return v.hasSource?"Generate a new AI suggestion from the current source text using the selected mode.":"Load or type source text, then run Ask AI to generate a suggestion.";if(d==="rerun")return v.staleAction==="source"?"Refresh this suggestion from the current dialog source before applying it.":"Refresh this suggestion from the current editor state before applying it.";if(d==="copy-to-source")return v.hasResult?"Copy the current AI result back into the source field before rerunning it.":"Run Ask AI first, then copy the generated result back into the source field.";if(d==="apply"){if(v.pendingIndexes.length>1)return v.pendingSelectionDependent&&!v.hasSelection?"Select text before applying this selection-based AI plan.":"Run the remaining "+v.pendingIndexes.length+"-step AI plan directly in the editor.";switch(v.pendingOperationType){case"preview-suggestion":return v.hasSelection?"Show the prepared inline diff in the editor before deciding it.":"Select text before previewing this prepared inline diff in the editor.";case"replace-selection":return v.hasSelection?"Replace the current selection with this prepared draft.":"Select text before replacing it with this prepared draft.";case"replace-document":return"Replace the full document with this prepared draft.";case"insert-below":return v.hasSelection?"Insert this prepared draft below the current selection.":"Insert this prepared draft below the current content.";case"add-comment":return"Add this prepared AI comment without rewriting the document body.";default:return"Run the prepared AI plan directly in the editor."}}return d==="selection"?v.hasSelection?"Replace the current selection with this prepared draft.":"Select text before replacing it with this prepared draft.":d==="preview"?v.hasSelection?"Show this change inline in the editor before deciding it.":"Select text to preview this change inline in the editor.":d==="insert"?v.hasSelection?"Insert this prepared draft below the current selection.":"Insert this prepared draft below the current content.":d==="document"?"Replace the full document with this prepared draft.":d==="reject"?"Dismiss this prepared suggestion without changing the document.":""}function Kt(d,v){return v=v||it(),d==="load-selection"?"Use selection":d==="load-document"?"Whole document":d==="selection"?v.hasSelection?"Replace selection":"Select text to replace":d==="preview"?v.hasSelection?"Preview":"Select text to preview":""}function Sr(d,v){var w={};if(!v||!v.actionId)return w;if(v.actionId==="apply"){switch(d.pendingOperationType){case"preview-suggestion":w.preview=!0;break;case"replace-selection":w.selection=!0;break;case"replace-document":w.document=!0;break;case"insert-below":w.insert=!0;break}return w}return w[v.actionId]=!0,w}function jr(d,v,w,T){if(!(!T||v[w])){for(var H=0;H<d.length;H++)if((d[H]||"").toLowerCase()===T.toLowerCase())return;d.push(T)}}function bi(d){return!d||!d.length?"":d.length===1?d[0]:d.length===2?d[0]+" or "+d[1]:d.slice(0,d.length-1).join(", ")+", or "+d[d.length-1]}function Wt(d,v){if(d=d||it(),!d.hasResult||d.isStale)return[];if(d.actionScope==="selection"&&!d.hasSelection)return["select text to apply inline"];var w=[],T=Sr(d,v),H=d.pendingOperationType||"";return d.actionScope==="selection"?(d.hasSelection&&H!=="preview-suggestion"&&jr(w,T,"preview","preview inline"),d.hasSelection&&H!=="replace-selection"&&jr(w,T,"selection","replace the selection"),d.canInsert&&H!=="insert-below"&&jr(w,T,"insert","insert below"),w):(d.actionScope==="document"&&(d.canReplaceDocument&&H!=="replace-document"&&jr(w,T,"document","replace the document"),d.canInsert&&H!=="insert-below"&&jr(w,T,"insert","insert below")),w)}function In(d){d=d||it();var v=O(d),w=v&&v.label?(v.label||"").replace(/\s+/g," ").trim():"";return w?"Ready \xB7 "+w:d.actionScope==="selection"&&!d.hasSelection?"Ready \xB7 Insert below":"Ready"}function Ua(d,v){d=d||it(),v=v||O(d);var w=v&&v.detail?(v.detail||"").replace(/\s+/g," ").trim():"",T=bi(Wt(d,v));return T&&(w+=(w?" ":"")+"Other available actions: "+T+"."),w}function la(d){if(!(!N||!N.appendChild)){var v=[ee,Ae,Se,_e,Oe,U,ae,ye,C,oe,xt];if(d&&d.button&&d.button.parentNode===N){v=[d.button];for(var w=[ee,Ae,Se,_e,Oe,U,ae,ye,C,oe,xt],T=0;T<w.length;T++)w[T]!==d.button&&v.push(w[T])}for(var H=0;H<v.length;H++)v[H]&&v[H].parentNode===N&&N.appendChild(v[H])}}function Ii(d,v,w,T){if(d){var H=(d.innerText||d.textContent||"").replace(/\s+/g," ").trim()||Kt(v,w)||"Action",ne=at(v,w),ce=T?{actionId:v,label:H,detail:ne}:null,ie=ce?bi(Wt(w,ce)):"",Ge=[H];ne&&Ge.push(ne),ie&&Ge.push("Other available actions: "+ie+"."),T?(Ge.push("Recommended next step."),d.setAttribute("data-rte-ai-dialog-recommended","true")):d.removeAttribute("data-rte-ai-dialog-recommended"),d.setAttribute("aria-label",Ge.join(". "));var nt=[H];ne&&nt.push(ne),ie&&nt.push("Other available actions: "+ie+"."),T&&nt.push("Recommended next step.");var ct=d.getAttribute&&d.getAttribute("aria-keyshortcuts");if(ct){var xr=ct.replace(/Control\+/gi,"Ctrl+").replace(/Meta\+/gi,"Cmd+");nt.push("("+xr+")")}d.title=nt.join(" - ")}}function O(d){d=d||it();var v=!!R(ot(r.__aiSnapshot,"selection"))&&!!(r.__aiSnapshot&&r.__aiSnapshot.hasSelection),w=!!R(ot(r.__aiSnapshot,"document"));if(!d.hasSource){var T=d.scope==="selection"?E:W,H=d.scope==="selection"?"load-selection":"load-document",ne=H==="load-selection"?v:w;if(ne&&T&&!T.disabled)return{actionId:H,button:T,label:Kt(H,d)||"Load source",detail:at(H,d)};if(w&&W&&!W.disabled)return{actionId:"load-document",button:W,label:(W.innerText||W.textContent||"").replace(/\s+/g," ").trim()||"Whole document",detail:at("load-document",d)};if(v&&E&&!E.disabled)return{actionId:"load-selection",button:E,label:(E.innerText||E.textContent||"").replace(/\s+/g," ").trim()||"Use selection",detail:at("load-selection",d)}}return d.isStale&&Fe&&Fe.style.display!=="none"&&!Fe.disabled?{actionId:"rerun",button:Fe,label:(Fe.innerText||Fe.textContent||"").replace(/\s+/g," ").trim()||(d.staleAction==="source"?"Re-run from source":"Re-run from editor"),detail:at("rerun",d)}:!d.hasResult&&I&&!I.disabled&&R(X.value)?{actionId:"run",button:I,label:"Ask AI",detail:at("run",d)}:d.pendingIndexes.length&&ee&&!ee.disabled?{actionId:"apply",button:ee,label:(ee.innerText||ee.textContent||"").replace(/\s+/g," ").trim()||"Apply",detail:at("apply",d)}:Se&&Se.style.display!=="none"&&!Se.disabled?{actionId:"preview",button:Se,label:(Se.innerText||Se.textContent||"").replace(/\s+/g," ").trim()||"Preview",detail:at("preview",d)}:Ae&&Ae.style.display!=="none"&&!Ae.disabled?{actionId:"selection",button:Ae,label:(Ae.innerText||Ae.textContent||"").replace(/\s+/g," ").trim()||"Replace selection",detail:at("selection",d)}:Oe&&Oe.style.display!=="none"&&!Oe.disabled?{actionId:"document",button:Oe,label:(Oe.innerText||Oe.textContent||"").replace(/\s+/g," ").trim()||"Replace document",detail:at("document",d)}:_e&&_e.style.display!=="none"&&!_e.disabled?{actionId:"insert",button:_e,label:(_e.innerText||_e.textContent||"").replace(/\s+/g," ").trim()||"Insert below",detail:at("insert",d)}:null}function Ze(d){d=d||it();var v=O(d);la(v);for(var w=[E,W,I,B,Fe,ee,Ae,Se,_e,Oe,xt],T=0;T<w.length;T++){var H=w[T],ne=H&&H.getAttribute?H.getAttribute("data-rte-ai-dialog-action")||(H===Fe?"rerun":""):"";Ii(H,ne,d,!!(v&&H===v.button))}if(N&&N.classList){var ce=!!(v&&v.actionId&&v.actionId!=="apply"&&v.button&&v.button.parentNode===N&&ee&&ee.disabled);N.classList.toggle("is-alt-recommended",ce)}if(!v){Ne.style.display="none",vr.innerText="",ir.innerText="",Ne.setAttribute("aria-label","No recommended Ask AI follow-up action yet.");return}Ne.style.display="",tt.innerText="Best next step",vr.innerText=v.label||"";var ie=Ua(d,v);ir.innerText=ie||"",Ne.setAttribute("aria-label","Best next step: "+(v.label||"Action")+"."+(ie?" "+ie:""))}function Le(){var d=r.__aiSourceScope||(r.__aiSnapshot&&r.__aiSnapshot.hasSelection?"selection":"document");wi(d),I.onclick()}function Rt(){I.onclick()}function jt(d,v){if(!d||!d.length)return!1;var w=Sa(d,{snapshot:r.__aiSnapshot,resolved:r.__aiResolved});return w&&(ht.innerText=v||"Applied the selected AI step."),w}function $t(d){var v=d&&d.operations?d.operations:[],w=it();Jt.innerHTML="",Xr.innerText=r.__aiPlanStale?r.__aiPlanStaleReason||"Editor changed. Re-run to refresh.":"";var T=r.__aiPlanStaleAction==="source"&&!R(X.value);if(Fe.innerText=r.__aiPlanStaleAction==="source"?"Re-run from source":"Re-run from editor",Fe.style.display=r.__aiPlanStale&&!T?"":"none",Fe.disabled=T,ar.className=r.__aiPlanStale?"demo-ai-plan-status is-stale":"demo-ai-plan-status",!v.length){var H=o(Jt,"li","","demo-ai-plan-item is-empty");o(H,"span","","demo-ai-plan-type","No plan yet"),o(H,"span","","demo-ai-plan-copy","Run Ask AI to see the steps the editor will apply."),Cr.innerText="",Fe.style.display="none",ee.disabled=!0,ee.innerText="Apply";return}for(var ne=0,ce=0,ie=0;ie<v.length;ie++){var Ge=v[ie],nt=es(Ge),ct=o(Jt,"li","","demo-ai-plan-item"),xr=o(ct,"div","","demo-ai-plan-header");o(xr,"span","","demo-ai-plan-type",nt.title);var dt=Zr(ie);dt&&(o(xr,"span","","demo-ai-plan-state is-"+dt,dt==="done"?"Applied":"Skipped"),dt==="done"?ne++:dt==="skipped"&&ce++);var ri=nt.copy;Ge.reason&&(ri+=" Reason: "+Ge.reason),o(ct,"span","","demo-ai-plan-copy",ri);var Ai=o(ct,"div","","demo-ai-plan-actions");if(dt!=="done"){var Tt=ut(Ge)&&!w.hasSelection,Dr=Tt?rs([Ge]):Mu(Ge),ii=o(Ai,"button","","secondary demo-ai-plan-button",Dr);ii.type="button",ii.disabled=!!r.__aiPlanStale||Tt,is(ii,Dr,qu(Ge,w),r.__aiPlanStale?"Currently unavailable until Ask AI is rerun.":Tt?"Currently unavailable until text is selected in the editor.":""),ii.onclick=(function(ft,bt,Bt){return function(){jt([bt],'Applied "'+Bt+'".')&&(Er(ft,"done"),Ht('Applied "'+Bt+'". Re-run to refresh the remaining plan.',"editor"))}})(ie,Ge,nt.title)}if(dt!=="done"){var _=o(Ai,"button","","secondary demo-ai-plan-button",dt==="skipped"?"Include step":"Skip step");_.type="button",_.disabled=!!r.__aiPlanStale,is(_,_.innerText||_.textContent||"Skip step",dt==="skipped"?"Add this step back into the pending AI plan.":"Skip this step from the pending AI plan.",r.__aiPlanStale?"Currently unavailable until Ask AI is rerun.":""),_.onclick=(function(ft,bt){return function(){Er(ft,bt?"":"skipped"),ht.innerText=bt?"Included the step back into the pending AI plan.":"Skipped this step from the pending AI plan.",$t(r.__aiResolved)}})(ie,dt==="skipped")}}for(var te=Ft(v),Ee=[],et=0;et<te.length;et++)Ee.push(v[te[et]]);Cr.innerText=te.length+" pending \u2022 "+ne+" applied \u2022 "+ce+" skipped",ee.disabled=!te.length||!!r.__aiPlanStale||!w.canApplyPlan,r.__aiPlanStale?ee.innerText="Re-run to refresh plan":te.length?w.pendingSelectionDependent&&!w.hasSelection?ee.innerText=rs(Ee):te.length===v.length?ee.innerText=ts(d):ee.innerText="Apply "+te.length+" pending steps":ee.innerText="No pending steps"}function sr(d,v){var w=v||"";I.disabled=!!d||!R(X.value),B.disabled=!!d||!R(Q.value),E.disabled=!!d||!r.__aiSnapshot||!r.__aiSnapshot.hasSelection,W.disabled=!!d,M&&(M.disabled=!!d),b.disabled=!!d,X.readOnly=!!d,Fe.disabled=!!d,ee.disabled=!!d||ee.disabled,Ae.disabled=!!d||Ae.disabled,Se.disabled=!!d||Se.disabled,_e.disabled=!!d||_e.disabled,Oe.disabled=!!d||Oe.disabled,xt.disabled=!!d||xt.disabled;for(var T=Jt.querySelectorAll?Jt.querySelectorAll(".demo-ai-plan-button"):[],H=0;H<T.length;H++)T[H].disabled=!!d;U&&(U.disabled=!!d||!R(Q.value)),ae&&(ae.disabled=!!d||!R(Q.value)),ye&&(ye.disabled=!!d||!R(Q.value)),C&&(C.disabled=!!d),ge&&(ge.disabled=!!d),d?(I.classList.add("is-busy"),ve(I,"spinner","Thinking...")):I.classList.remove("is-busy"),ht.innerText=w,Ze()}function wi(d){r.__aiSourceScope=d==="selection"?"selection":"document",r.__aiSourceLinkedToEditor=!0,r.__aiSnapshot=st(),X.value=ot(r.__aiSnapshot,r.__aiSourceScope),r.__aiLastLinkedSourceText=X.value,Re(),wr(),or(),Pt()}function or(){var d=it(),v=d.hasResult,w=d.hasSource,T=d.isStale;a&&a.classList&&(v||T?a.classList.remove("is-pre-result"):a.classList.add("is-pre-result"));var H=r&&r.parentNode;H&&H.classList&&(v||T?H.classList.remove("is-pre-result"):H.classList.add("is-pre-result"));var ne=d.pendingOperationType,ce=v||T?d.actionScope:d.scope,ie=ce==="selection"&&ne!=="replace-selection",Ge=ce==="selection"&&ne!=="preview-suggestion",nt=d.canInsert&&ne!=="insert-below",ct=d.canReplaceDocument&&ne!=="replace-document";qe.innerText=R(X.value)||"Load text from the editor to start a preview.",Ye.innerText=v?Q.value:"Run Ask AI to generate a suggestion preview.";var xr=pa(r.__aiResolved)||"";if(gt.innerText=xr||"This suggestion does not include an explicit AI rationale yet.",$t(r.__aiResolved),ke&&ke.style){var dt=r.__aiResolved,ri=dt&&dt.operations?dt.operations.length:0,Ai=!!xr||ri>1;ke.style.display=v&&Ai?"":"none",!Ai&&Ce&&Ce.classList&&!Ce.classList.contains("is-collapsed")&&(Ce.classList.add("is-collapsed"),ke.setAttribute("aria-expanded","false"))}if(Ae.innerText=Kt("selection",d)||"Replace selection",Se.innerText=Kt("preview",d)||"Preview",Ae.style.display=ie?"":"none",Se.style.display=Ge?"":"none",_e.style.display=nt?"":"none",Oe.style.display=ct?"":"none",oe){var Tt=[];ie&&Tt.push("Replace selection"),Ge&&Tt.push("Preview"),nt&&Tt.push("Insert below"),ct&&Tt.push("Replace document");var Dr=Tt.length,ii=Dr>0;if(oe.style.display=ii?"":"none",ii){var _="More apply options ("+Dr+"): "+Tt.join(", ");oe.title=_,oe.setAttribute("aria-label",_),oe.setAttribute("data-rte-ai-more-count",String(Dr))}!ii&&N.classList.contains("is-show-more")&&(N.classList.remove("is-show-more"),oe.setAttribute("aria-expanded","false"))}Ae.disabled=T||!d.canReplaceSelection,Se.disabled=T||!d.canPreview,_e.disabled=T||!d.canInsert,Oe.disabled=T||!d.canReplaceDocument,I.disabled=!w,B.disabled=!v,xt.disabled=!v;var te=v||T?"Regenerate":"Generate";ve(I,"sparkles",te),se(),Ze(d)}function Il(){if(!(!r.isConnected||s.__aiDialog!==r)){var d=r.__aiSourceScope==="selection"?"selection":"document",v=!!r.__aiSourceLinkedToEditor,w=r.__aiSnapshot||st(),T=st(),H=ot(w,d),ne=ot(T,d),ce=d==="selection"&&(!!w.hasSelection!=!!T.hasSelection||!$n(w.range,T.range)||H!==ne),ie=d==="document"?(w.wholeText||"")!==(T.wholeText||""):ce,Ge=ie||!!w.hasSelection!=!!T.hasSelection;if(r.__aiSnapshot=T,v&&(r.__aiLastLinkedSourceText=ne),!!Ge){if(wr(),v){if(X.value=ne,Re(),ie&&R(Q.value)&&!r.__aiPlanStale){Ht(Qe(d,T,w),"editor");return}}else if(ie&&R(Q.value)&&!r.__aiPlanStale){Ht(Ar(d,T,w),"source");return}or(),Pt()}}}function yi(){if(Ga(),Re(),R(Q.value)){Ht(Ve(X.value),"source");return}or(),Pt()}function Hi(d){if(R(Q.value)){Ht(d,"source");return}or()}function Fa(d){var v=d==="selection"?"selection":"document",w=r.__aiSourceScope==="selection"?"selection":"document",T=R(X.value),H=!!r.__aiSourceLinkedToEditor;if(wi(v),!!R(Q.value)){var ne=R(X.value);if(w!==v){Ht(Ir(v),"editor");return}(!H||T!==ne)&&Ht(Lt(v),"editor")}}E.onclick=function(){Fa("selection")},W.onclick=function(){Fa("document")},M&&(M.onchange=function(){Fa(M.value)}),Fe.onclick=function(){if(r.__aiPlanStaleAction==="source"){Rt();return}Le()},b.onchange=function(){Pt(),Hi(ti())},A.onchange=function(){Pt(),Hi(ze(A.value))},I.onclick=function(){var d=st();if(r.__aiSnapshot=d,r.__aiSourceLinkedToEditor&&(X.value=ot(d,r.__aiSourceScope),r.__aiLastLinkedSourceText=X.value,Re()),wr(),!R(X.value)){ht.innerText="Load or type source text before running Ask AI.",or();return}sr(!0,""),Ya(b.value,{snapshot:d,source:X.value,scope:Mr(d),mode:b.value,language:A.value}).then(function(v){r.__aiResolved=v,r.__aiOperationStates={},r.__aiPlanStale=!1,r.__aiPlanStaleReason="",r.__aiPlanStaleAction="",Q.value=Nt(v)||"",or(),sr(!1,Q.value?"":"No suggestion returned.")}).catch(function(v){console.error("AI Toolkit dialog run failed",v),r.__aiResolved=null,r.__aiOperationStates={},r.__aiPlanStale=!1,r.__aiPlanStaleReason="",r.__aiPlanStaleAction="",Q.value="",or(),sr(!1,"AI suggestion failed.")})},B.onclick=function(){R(Q.value)&&(X.value=Q.value,yi())},X.oninput=function(){yi()},X.onkeydown=function(d){d&&(d.ctrlKey||d.metaKey)&&d.keyCode===13&&(d.preventDefault(),I&&!I.disabled&&I.onclick&&I.onclick())},ee.onclick=function(){for(var d=r.__aiResolved&&r.__aiResolved.operations?r.__aiResolved.operations:[],v=Ft(d),w=[],T=0;T<v.length;T++)w.push(d[v[T]]);if(w.length&&jt(w,"Applied the pending AI plan.")){for(var H=0;H<v.length;H++)Er(v[H],"done");r.close()}},Ae.onclick=function(){dr(Kr(Q.value,"selection",nr("selection"),r.__aiResolved?r.__aiResolved.request:null,r.__aiResolved?r.__aiResolved.action:null),{snapshot:r.__aiSnapshot})&&r.close()},Se.onclick=function(){var d=Kr(Q.value,"selection-preview",nr("selection-preview"),r.__aiResolved?r.__aiResolved.request:null,r.__aiResolved?r.__aiResolved.action:null);d&&d.operations&&d.operations[0]&&!d.operations[0].reason&&(d.operations[0].reason=pa(r.__aiResolved)),dr(d,{snapshot:r.__aiSnapshot})&&r.close()},_e.onclick=function(){dr(Kr(Q.value,"insert",nr("insert"),r.__aiResolved?r.__aiResolved.request:null,r.__aiResolved?r.__aiResolved.action:null),{snapshot:r.__aiSnapshot})&&r.close()},Oe.onclick=function(){dr(Kr(Q.value,"document",nr("document"),r.__aiResolved?r.__aiResolved.request:null,r.__aiResolved?r.__aiResolved.action:null),{snapshot:r.__aiSnapshot})&&r.close()},xt.onclick=function(){r.close()},r.addEventListener("keydown",function(d){if(d&&(d.ctrlKey||d.metaKey)&&d.keyCode===13){var v=d.target;if(v!==X){var w=null;if(ee&&!ee.disabled&&ee.offsetParent!==null)w=ee;else if(N&&N.classList&&N.classList.contains("is-alt-recommended")){var T=N.querySelector('[data-rte-ai-dialog-recommended="true"]:not([disabled])');T&&T.offsetParent!==null&&(w=T)}w&&typeof w.onclick=="function"&&(d.preventDefault(),w.onclick())}}}),r.__aiSourceLinkedToEditor=!0,r.__aiLastLinkedSourceText="",r.__aiSyncFromEditor=Il,Ho(),wi(e.useDocument?"document":t.hasSelection?"selection":"document"),or(),e.autoRun&&I.onclick();try{setTimeout(function(){try{R(X.value)&&I&&!I.disabled&&I.focus?I.focus():X&&X.focus?X.focus():b&&b.focus&&b.focus()}catch{}},0)}catch{}}}
|
|
14
|
+
`+$.value,Si(),j&&!j.disabled&&j.onclick&&j.onclick())}K.onclick=function(){j&&!j.disabled&&j.onclick&&j.onclick()},ne.onclick=function(){be("Rewrite to be noticeably shorter and more concise while keeping the meaning intact.")},Ae.onclick=function(){be("Expand with more supporting detail, examples, and depth while keeping the same voice.")},I.onclick=function(f){f&&f.stopPropagation&&f.stopPropagation();var g=qe.classList.toggle("is-collapsed"),A=!g;I.setAttribute("aria-expanded",A?"true":"false"),_e&&_e.setAttribute&&(_e.setAttribute("aria-expanded",A?"true":"false"),_e.classList.toggle("is-active",A)),Pe&&Pe.setAttribute&&Pe.setAttribute("aria-expanded",A?"true":"false")},_e.onclick=function(f){f&&f.stopPropagation&&f.stopPropagation();var g=qe.classList.toggle("is-collapsed"),A=!g;_e.setAttribute("aria-expanded",A?"true":"false"),_e.classList.toggle("is-active",A),I&&I.setAttribute&&I.setAttribute("aria-expanded",A?"true":"false"),Pe&&Pe.setAttribute&&Pe.setAttribute("aria-expanded",A?"true":"false")};var Q=o(a,"div","","demo-actions-row demo-ai-apply-row");Q.setAttribute("role","group"),Q.setAttribute("aria-label",c.__aiT?c.__aiT("ai2_applyrow","Ask AI apply actions"):"Ask AI apply actions");var te=o(Q,"button","","is-primary");te.type="button",te.disabled=!0,te.setAttribute("data-rte-ai-dialog-action","apply"),te.title=c.__aiT?c.__aiT("ai2_applytitle","Apply AI suggestion (Ctrl+Enter)"):"Apply AI suggestion (Ctrl+Enter)",te.setAttribute("aria-keyshortcuts","Control+Enter"),he(te,"check",c.__aiT?c.__aiT("ai2_apply","Apply"):"Apply");var xe=o(Q,"button","","");xe.type="button",xe.disabled=!t.hasSelection,xe.setAttribute("data-rte-ai-dialog-action","selection"),he(xe,"check",c.__aiT?c.__aiT("ai2_replsel","Replace selection"):"Replace selection");var Se=o(Q,"button","","secondary");Se.type="button",Se.disabled=!t.hasSelection,Se.setAttribute("data-rte-ai-dialog-action","preview"),he(Se,"eyeOn",c.__aiT?c.__aiT("ai2_preview","Preview"):"Preview");var Le=o(Q,"button","","secondary");Le.type="button",Le.setAttribute("data-rte-ai-dialog-action","insert"),he(Le,"arrowRight",c.__aiT?c.__aiT("ai2_insbelow","Insert below"):"Insert below");var Ue=o(Q,"button","","secondary");Ue.type="button",Ue.setAttribute("data-rte-ai-dialog-action","document"),he(Ue,"checkAll",c.__aiT?c.__aiT("ai2_repldoc","Replace document"):"Replace document");var ue=o(Q,"button","","secondary demo-ai-apply-more-toggle is-icon-only");ue.type="button",ue.setAttribute("data-rte-ai-dialog-action","more"),ue.setAttribute("aria-expanded","false"),ue.title=c.__aiT?c.__aiT("ai2_moreopts","More apply options"):"More apply options",ue.setAttribute("aria-label",c.__aiT?c.__aiT("ai2_moreopts","More apply options"):"More apply options"),he(ue,"more",""),ue.onclick=function(f){f&&f.stopPropagation&&f.stopPropagation();var g=Q.classList.toggle("is-show-more");ue.setAttribute("aria-expanded",g?"true":"false")},Q.insertBefore(K,ue),Q.insertBefore(ne,ue),Q.insertBefore(Ae,ue);var Tt=document.createElement("button");Tt.type="button",Tt.className="secondary is-detached",Tt.setAttribute("data-rte-ai-dialog-action","reject"),he(Tt,"trash","Discard");var Qe=document.createElement("div");Qe.id=p,Qe.className="demo-ai-apply-guidance",Qe.style.display="none",Qe.setAttribute("role","group"),Qe.setAttribute("aria-label",c.__aiT?c.__aiT("aid_bestnext","Best next step"):"Best next step");var Lt=o(Qe,"div","","demo-ai-apply-guidance-header"),it=o(Lt,"span","","demo-ai-apply-guidance-title","Next"),hr=o(Lt,"span","","demo-ai-apply-guidance-badge"),lr=o(Qe,"div","","demo-ai-apply-guidance-detail");a.appendChild(Qe);var mt=o(a,"div","","demo-ai-dialog-status");mt.id=m,mt.setAttribute("role","status"),mt.setAttribute("aria-live","polite"),mt.setAttribute("aria-atomic","true");var Pe=o(a,"button","","demo-ai-details-toggle","Details");Pe.type="button",Pe.setAttribute("aria-expanded","false"),Pe.setAttribute("aria-controls","rte-ai-details-"+n),Pe.title="Show why and the operation plan";var qe=o(a,"div","","demo-ai-insight-grid is-collapsed");qe.id=Pe.getAttribute("aria-controls"),I&&I.setAttribute&&I.setAttribute("aria-controls",qe.id),_e&&_e.setAttribute&&_e.setAttribute("aria-controls",qe.id),a.insertBefore(Pe,Q),a.insertBefore(qe,Q),Pe.onclick=function(){var f=qe.classList.toggle("is-collapsed");Pe.setAttribute("aria-expanded",f?"false":"true")};var Vt=o(qe,"div","","demo-ai-reason-panel");Vt.setAttribute("role","group"),Vt.setAttribute("aria-label","AI rationale"),o(Vt,"label","","","Why");var _t=o(Vt,"div","","demo-ai-reason-copy","The reason will appear here once a suggestion is generated."),bt=o(qe,"div","","demo-ai-plan-panel");bt.setAttribute("role","group"),bt.setAttribute("aria-label","AI operation plan"),o(bt,"label","","","Plan");var Di=document.createElement("div"),sr=o(bt,"div","","demo-ai-plan-status"),Zr=o(sr,"span","","demo-ai-plan-status-message"),Ke=o(sr,"button","","secondary demo-ai-plan-status-action","Re-run");Ke.type="button",Ke.style.display="none",Ke.setAttribute("data-rte-ai-dialog-action","rerun");var Er=o(bt,"div","","demo-ai-plan-summary"),Wt=o(bt,"ul","","demo-ai-plan-list");function or(f){var g=r.__aiResolved;return g&&g.operations&&g.operations.length?g:Kr($.value,f,g||null,g?g.request:null,g?g.action:null)}function ei(){var f=rl();v.innerHTML="";for(var g={proofread:"Edit text",rewrite:"Edit text",shorten:"Edit text",expand:"Edit text",translate:"Transform",summarize:"Transform",justify:"Transform"},A=["Edit text","Transform"],q={},O=[],le=0;le<f.length;le++){var de=f[le],ae=de.group||g[de.id]||"";if(!ae){O.push(de);continue}q[ae]||(q[ae]=[],A.indexOf(ae)===-1&&A.push(ae)),q[ae].push(de)}function Fe(Ti,kt){var Or=o(Ti,"option","","",kt.title||kt.id);Or.value=kt.id,kt.description&&(Or.title=kt.description)}for(var st=0;st<A.length;st++){var ft=q[A[st]];if(!(!ft||!ft.length)){var Tr=o(v,"optgroup");Tr.label=A[st];for(var vt=0;vt<ft.length;vt++)Fe(Tr,ft[vt])}}for(var ai=0;ai<O.length;ai++)Fe(v,O[ai]);v.options.length&&v.selectedIndex<0&&(v.selectedIndex=0),at(),Mt()}function at(){var f=ga();b.innerHTML="";for(var g=0;g<f.length;g++){var A=o(b,"option","","",Fu(f[g]));A.value=f[g].value||f[g].label}e.presetLanguage&&(b.value=e.presetLanguage),!b.value&&f.length&&(b.value=f[0].value||f[0].label)}function jt(){var f=v.value==="translate";_.style.display=f?"":"none",w&&w.classList&&w.classList.toggle("is-no-language",!f)}function gr(){if(!W)return"";var f=r.__aiSourceScope==="selection"?"selection":"document",g=r.__aiSnapshot,A=W.value||"",q=f,O=0;if(A)O=A.length,r.__aiSourceLinkedToEditor||(q="typed");else if(g){var le=f==="selection"?g.text||"":g.wholeText||"";O=le.length,f==="selection"&&!g.hasSelection&&(q="document",O=(g.wholeText||"").length)}if(!O)return"";var de=O>999?Math.round(O/100)/10+"K":String(O),ae;return q==="typed"?ae="Typed prompt":q==="selection"?ae="Selection":ae="Document",ae+" \xB7 "+de+" chars"}function yi(){if(!r||!r.querySelector)return null;var f=r.querySelector("rte-dialog-header");if(!f)return null;var g=f.querySelector(".rte-ai-dialog-header-caption");if(g)return g;g=r.ownerDocument.createElement("span"),g.className="rte-ai-dialog-header-caption",g.setAttribute("aria-hidden","true");var A=f.querySelector("rte-dialog-header-text");return A&&A.parentNode===f?(A.style&&(A.style.flex="0 0 auto",A.style.whiteSpace="nowrap"),A.nextSibling?f.insertBefore(g,A.nextSibling):f.appendChild(g)):f.appendChild(g),g}function mr(f){if(!(!r||!r.querySelector)){var g=r.querySelector("rte-dialog-header rte-dialog-header-text")||r.querySelector("rte-dialog-header-text");if(g){var A=L.text_aiassist||"Ask AI",q=f||"";q&&v.value==="translate"&&(q=q+" ("+ot(b.value||"spanish")+")"),g.innerText=q||A,r.setAttribute&&r.setAttribute("aria-label",q?A+" \xB7 "+q:A)}}}function Mt(){for(var f=rl(),g="Run this AI mode against the current source text.",A="",q=0;q<f.length;q++)if(f[q].id===v.value){A=f[q].title||f[q].id,f[q].id==="translate"?g=(f[q].description||"Prepare a translated draft in the selected language.")+" Current target: "+ot(b.value||"spanish")+".":g=f[q].description||"Run this AI mode against the current source text.";break}h.innerText=g,v&&v.setAttribute&&v.setAttribute("title",g);var O=yi();if(O&&(O.innerText=g||""),mr(A),W&&!W.value){var le=v.value||"",de={proofread:"Paste text to proofread\u2026",rewrite:"Paste text to rewrite\u2026",shorten:"Paste text to shorten\u2026",expand:"Paste text to expand\u2026",summarize:"Paste text to summarize\u2026",translate:"Paste text to translate\u2026",justify:"Paste text to rewrite + explain\u2026",explain:"Paste text to explain\u2026"};W.placeholder=de[le]||"Type or paste text\u2026"}if(i){var ae=A||"";A&&v.value==="translate"&&(ae=A+" \xB7 "+ot(b.value||"spanish")),i.innerText=ae,i.style.display=ae?"":"none"}jt()}function ti(f){return r.__aiOperationStates&&r.__aiOperationStates["step-"+f]?r.__aiOperationStates["step-"+f]:""}function Pr(f,g){r.__aiOperationStates=r.__aiOperationStates||{},r.__aiOperationStates["step-"+f]=g||""}function qr(){qe&&qe.classList&&qe.classList.contains("is-collapsed")&&(qe.classList.remove("is-collapsed"),Pe&&Pe.setAttribute&&Pe.setAttribute("aria-expanded","true"))}function Ot(f,g){r.__aiPlanStale=!0,r.__aiPlanStaleReason=f||"Editor changed. Re-run to refresh.",r.__aiPlanStaleAction=g==="source"?"source":"editor",mt.innerText=r.__aiPlanStaleReason,Yt(r.__aiResolved),dr(),qr()}function ct(f,g){return f?g==="selection"?f.text||f.wholeText||"":f.wholeText||"":""}function Bt(f,g){return g==="selection"&&(!f||!f.hasSelection)&&!r.__aiSourceLinkedToEditor&&!!E(W.value)}function ri(f,g){return g==="selection"?f&&f.hasSelection?"Selection ready":Bt(f,g)?"Selection source loaded - select text to apply inline":"No selection - using whole document":f&&f.hasSelection?"Whole document loaded - selection available":"Whole document loaded"}function ur(f,g){return g==="selection"&&f&&f.hasSelection?"selection":"document"}function dt(f){return!!f&&(f.type==="preview-suggestion"||f.type==="replace-selection")}function _r(f,g){var A=g&&g.length?g:null;if(!A){for(var q=0;q<f.length;q++)if(dt(f[q]))return!0;return!1}for(var O=0;O<A.length;O++)if(dt(f[A[O]]))return!0;return!1}function Ir(f){var g=r.__aiSourceScope==="selection"?"selection":"document";return r.__aiSourceLinkedToEditor?ur(f,g):g}function br(f,g,A){return r.__aiPlanStale?r.__aiSourceLinkedToEditor?A:g:f&&f.request?f.request.scope==="selection"?"selection":"document":r.__aiSourceLinkedToEditor?A:g}function wr(f,g,A,q){var O=f==="selection";return O?q?"Use selection. Active scope. Ask AI is keeping the current selection-based source. Select text to apply or reload it again.":!g||!g.hasSelection?"Use selection. Unavailable until text is selected.":A==="selection"?"Use selection. Active scope. Ask AI is using the current selection.":"Use selection. Available scope. Switch Ask AI to the current selection.":A==="selection"?"Use document. Available scope. Switch Ask AI to the whole document.":"Use document. Active scope. Ask AI is using the whole document."}function yr(){var f=r.__aiSourceScope==="selection"?"selection":"document",g=ur(r.__aiSnapshot,f),A=Bt(r.__aiSnapshot,f),q=A?"selection":g;if(G&&(G.innerText=ri(r.__aiSnapshot,f)),M&&(M.disabled=!r.__aiSnapshot||!r.__aiSnapshot.hasSelection),M&&M.setAttribute&&(M.setAttribute("aria-pressed",q==="selection"?"true":"false"),M.setAttribute("aria-label",wr("selection",r.__aiSnapshot,q,A))),V&&V.setAttribute&&(V.setAttribute("aria-pressed",q==="document"?"true":"false"),V.setAttribute("aria-label",wr("document",r.__aiSnapshot,q,A))),C){var O=r.__aiSnapshot,le=!!(O&&O.hasSelection),de=O?(O.wholeText||"").length:0;P.disabled=!le,P.text=le?c.__aiT?c.__aiT("aid_selection","Selection"):"Selection":c.__aiT?c.__aiT("aid_selectionnone","Selection (none)"):"Selection (none)",T.text=c.__aiT?c.__aiT("aid_document","Document"):"Document",C.value=q==="selection"?"selection":"document",C.setAttribute("title",ri(O,f)),D&&(D.innerText=c.__aiT?c.__aiT("aid_document","Document"):"Document"),w&&w.classList&&(le?w.classList.remove("is-scope-implicit"):w.classList.add("is-scope-implicit"))}}function Ar(f){return f?f>999?c.__aiT?c.__aiT("aid_kchars","{0}K chars",Math.round(f/100)/10):Math.round(f/100)/10+"K chars":c.__aiT?c.__aiT("aid_chars","{0} chars",f):f+" chars":"0"}function za(){r.__aiSourceLinkedToEditor=!1}function Mr(f,g){return E(f&&f.text?f.text:"")!==E(g&&g.text?g.text:"")}function $e(f,g,A){return f==="selection"?A&&A.hasSelection&&g&&!g.hasSelection?"Selection cleared. Re-run to refresh.":A&&g&&A.hasSelection&&g.hasSelection&&ll(A.range,g.range)&&Mr(A,g)?"Selection text changed. Re-run to refresh.":"Selection changed. Re-run to refresh.":"Document changed. Re-run to refresh."}function We(f){return E(f)?"Source changed. Re-run to refresh.":"Source cleared. Reload from the editor or type source text before re-running."}function ii(){return"Mode changed. Re-run to refresh."}function Je(f){return"Language \u2192 "+ot(f||"spanish")+". Re-run to refresh."}function Hr(f){return"Scope \u2192 "+(f==="selection"?"selection":"document")+". Re-run to refresh."}function Rt(f){return"Reloaded from "+(f==="selection"?"selection":"document")+". Re-run to refresh."}function xr(f,g,A){return f==="selection"?A&&A.hasSelection&&g&&!g.hasSelection?"Selection cleared. Re-run to refresh.":A&&g&&A.hasSelection&&g.hasSelection&&ll(A.range,g.range)&&Mr(A,g)?"Selection text changed. Re-run to refresh.":"Selection changed. Re-run to refresh.":"Document changed. Re-run to refresh."}function zt(f){for(var g=[],A=0;A<f.length;A++)ti(A)!=="done"&&ti(A)!=="skipped"&&g.push(A);return g}function Dr(){var f=r.__aiResolved&&r.__aiResolved.operations?r.__aiResolved.operations:[],g=zt(f);if(g.length!==1)return"";var A=f[g[0]];return A&&A.type?A.type:""}function nt(){var f=r.__aiResolved||null,g=f&&f.operations?f.operations:[],A=zt(g),q=r.__aiSourceScope==="selection"?"selection":"document",O=ur(r.__aiSnapshot,q),le=!!(r.__aiSnapshot&&r.__aiSnapshot.hasSelection),de=!!E($.value),ae=br(f,q,O),Fe=_r(g,A);return{hasSource:!!E(W.value),hasResult:de,hasSelection:le,isStale:!!r.__aiPlanStale,requestedScope:q,scope:O,actionScope:ae,staleAction:r.__aiPlanStaleAction==="source"?"source":"editor",operations:g,pendingIndexes:A,pendingSelectionDependent:Fe,canApplyPlan:!!A.length&&(!Fe||le),canPreview:de&&ae==="selection"&&le,canReplaceSelection:de&&ae==="selection"&&le,canInsert:de,canReplaceDocument:de&&ae==="document",pendingOperationType:A.length===1&&g[A[0]]&&g[A[0]].type?g[A[0]].type:""}}function lt(f,g){if(g=g||nt(),f==="load-selection")return g.hasSelection?"Reload the current editor selection into Ask AI.":"Select text in the editor, then reload it into Ask AI.";if(f==="load-document")return c.__aiT?c.__aiT("aid_reloaddesc","Reload the current editor document into Ask AI."):"Reload the current editor document into Ask AI.";if(f==="run")return g.hasSource?c.__aiT?c.__aiT("aid_gendesc","Generate a new AI suggestion from the current source text using the selected mode."):"Generate a new AI suggestion from the current source text using the selected mode.":c.__aiT?c.__aiT("aid_loaddesc","Load or type source text, then run Ask AI to generate a suggestion."):"Load or type source text, then run Ask AI to generate a suggestion.";if(f==="rerun")return g.staleAction==="source"?c.__aiT?c.__aiT("ai2_d_refreshsrc","Refresh this suggestion from the current dialog source before applying it."):"Refresh this suggestion from the current dialog source before applying it.":c.__aiT?c.__aiT("ai2_d_refreshed","Refresh this suggestion from the current editor state before applying it."):"Refresh this suggestion from the current editor state before applying it.";if(f==="copy-to-source")return g.hasResult?c.__aiT?c.__aiT("ai2_d_copyback","Copy the current AI result back into the source field before rerunning it."):"Copy the current AI result back into the source field before rerunning it.":c.__aiT?c.__aiT("ai2_d_copyfirst","Run Ask AI first, then copy the generated result back into the source field."):"Run Ask AI first, then copy the generated result back into the source field.";if(f==="apply"){if(g.pendingIndexes.length>1)return g.pendingSelectionDependent&&!g.hasSelection?c.__aiT?c.__aiT("ai2_d_selectplan","Select text before applying this selection-based AI plan."):"Select text before applying this selection-based AI plan.":c.__aiT?c.__aiT("ai2_d_steps","Run the remaining {0}-step AI plan directly in the editor.",g.pendingIndexes.length):"Run the remaining "+g.pendingIndexes.length+"-step AI plan directly in the editor.";switch(g.pendingOperationType){case"preview-suggestion":return g.hasSelection?c.__aiT?c.__aiT("ai2_d_showdiff","Show the prepared inline diff in the editor before deciding it."):"Show the prepared inline diff in the editor before deciding it.":c.__aiT?c.__aiT("ai2_d_selectdiff","Select text before previewing this prepared inline diff in the editor."):"Select text before previewing this prepared inline diff in the editor.";case"replace-selection":return g.hasSelection?c.__aiT?c.__aiT("ai2_d_replsel","Replace the current selection with this prepared draft."):"Replace the current selection with this prepared draft.":c.__aiT?c.__aiT("ai2_d_selectrepl","Select text before replacing it with this prepared draft."):"Select text before replacing it with this prepared draft.";case"replace-document":return c.__aiT?c.__aiT("ai2_d_repldoc","Replace the full document with this prepared draft."):"Replace the full document with this prepared draft.";case"insert-below":return g.hasSelection?c.__aiT?c.__aiT("ai2_d_insbelowsel","Insert this prepared draft below the current selection."):"Insert this prepared draft below the current selection.":c.__aiT?c.__aiT("ai2_d_insbelow","Insert this prepared draft below the current content."):"Insert this prepared draft below the current content.";case"add-comment":return c.__aiT?c.__aiT("ai2_d_comment","Add this prepared AI comment without rewriting the document body."):"Add this prepared AI comment without rewriting the document body.";default:return c.__aiT?c.__aiT("ai2_d_runplan","Run the prepared AI plan directly in the editor."):"Run the prepared AI plan directly in the editor."}}return f==="selection"?g.hasSelection?c.__aiT?c.__aiT("ai2_d_replsel","Replace the current selection with this prepared draft."):"Replace the current selection with this prepared draft.":c.__aiT?c.__aiT("ai2_d_selectrepl","Select text before replacing it with this prepared draft."):"Select text before replacing it with this prepared draft.":f==="preview"?g.hasSelection?c.__aiT?c.__aiT("ai2_d_previewsel","Show this change inline in the editor before deciding it."):"Show this change inline in the editor before deciding it.":c.__aiT?c.__aiT("ai2_d_previewselect","Select text to preview this change inline in the editor."):"Select text to preview this change inline in the editor.":f==="insert"?g.hasSelection?c.__aiT?c.__aiT("ai2_d_insbelowsel","Insert this prepared draft below the current selection."):"Insert this prepared draft below the current selection.":c.__aiT?c.__aiT("ai2_d_insbelow","Insert this prepared draft below the current content."):"Insert this prepared draft below the current content.":f==="document"?c.__aiT?c.__aiT("ai2_d_repldoc","Replace the full document with this prepared draft."):"Replace the full document with this prepared draft.":f==="reject"?c.__aiT?c.__aiT("ai2_d_dismiss","Dismiss this prepared suggestion without changing the document."):"Dismiss this prepared suggestion without changing the document.":""}function Qt(f,g){return g=g||nt(),f==="load-selection"?"Use selection":f==="load-document"?"Whole document":f==="selection"?g.hasSelection?"Replace selection":"Select text to replace":f==="preview"?g.hasSelection?"Preview":"Select text to preview":""}function Sr(f,g){var A={};if(!g||!g.actionId)return A;if(g.actionId==="apply"){switch(f.pendingOperationType){case"preview-suggestion":A.preview=!0;break;case"replace-selection":A.selection=!0;break;case"replace-document":A.document=!0;break;case"insert-below":A.insert=!0;break}return A}return A[g.actionId]=!0,A}function jr(f,g,A,q){if(!(!q||g[A])){for(var O=0;O<f.length;O++)if((f[O]||"").toLowerCase()===q.toLowerCase())return;f.push(q)}}function Ai(f){return!f||!f.length?"":f.length===1?f[0]:f.length===2?f[0]+" or "+f[1]:f.slice(0,f.length-1).join(", ")+", or "+f[f.length-1]}function Xt(f,g){if(f=f||nt(),!f.hasResult||f.isStale)return[];if(f.actionScope==="selection"&&!f.hasSelection)return["select text to apply inline"];var A=[],q=Sr(f,g),O=f.pendingOperationType||"";return f.actionScope==="selection"?(f.hasSelection&&O!=="preview-suggestion"&&jr(A,q,"preview",c.__aiT?c.__aiT("ai2_alt_preview","preview inline"):"preview inline"),f.hasSelection&&O!=="replace-selection"&&jr(A,q,"selection",c.__aiT?c.__aiT("ai2_alt_selection","replace the selection"):"replace the selection"),f.canInsert&&O!=="insert-below"&&jr(A,q,"insert",c.__aiT?c.__aiT("ai2_alt_insert","insert below"):"insert below"),A):(f.actionScope==="document"&&(f.canReplaceDocument&&O!=="replace-document"&&jr(A,q,"document",c.__aiT?c.__aiT("ai2_alt_document","replace the document"):"replace the document"),f.canInsert&&O!=="insert-below"&&jr(A,q,"insert",c.__aiT?c.__aiT("ai2_alt_insert","insert below"):"insert below")),A)}function Un(f){f=f||nt();var g=U(f),A=g&&g.label?(g.label||"").replace(/\s+/g," ").trim():"";return A?"Ready \xB7 "+A:f.actionScope==="selection"&&!f.hasSelection?"Ready \xB7 Insert below":"Ready"}function Qa(f,g){f=f||nt(),g=g||U(f);var A=g&&g.detail?(g.detail||"").replace(/\s+/g," ").trim():"",q=Ai(Xt(f,g));return q&&(A+=(A?" ":"")+"Other available actions: "+q+"."),A}function oa(f){if(!(!Q||!Q.appendChild)){var g=[te,xe,Se,Le,Ue,K,ne,Ae,I,ue,Tt];if(f&&f.button&&f.button.parentNode===Q){g=[f.button];for(var A=[te,xe,Se,Le,Ue,K,ne,Ae,I,ue,Tt],q=0;q<A.length;q++)A[q]!==f.button&&g.push(A[q])}for(var O=0;O<g.length;O++)g[O]&&g[O].parentNode===Q&&Q.appendChild(g[O])}}function ji(f,g,A,q){if(f){var O=(f.innerText||f.textContent||"").replace(/\s+/g," ").trim()||Qt(g,A)||"Action",le=lt(g,A),de=q?{actionId:g,label:O,detail:le}:null,ae=de?Ai(Xt(A,de)):"",Fe=[O];le&&Fe.push(le),ae&&Fe.push(c.__aiT?c.__aiT("aid_otheractions","Other available actions: {0}.",ae):"Other available actions: "+ae+"."),q?(Fe.push(c.__aiT?c.__aiT("aid_recommended","Recommended next step."):"Recommended next step."),f.setAttribute("data-rte-ai-dialog-recommended","true")):f.removeAttribute("data-rte-ai-dialog-recommended"),f.setAttribute("aria-label",fe(Fe));var st=[O];le&&st.push(le),ae&&st.push(c.__aiT?c.__aiT("aid_otheractions","Other available actions: {0}.",ae):"Other available actions: "+ae+"."),q&&st.push(c.__aiT?c.__aiT("aid_recommended","Recommended next step."):"Recommended next step.");var ft=f.getAttribute&&f.getAttribute("aria-keyshortcuts");if(ft){var Tr=ft.replace(/Control\+/gi,"Ctrl+").replace(/Meta\+/gi,"Cmd+");st.push("("+Tr+")")}f.title=st.join(" - ")}}function U(f){f=f||nt();var g=!!E(ct(r.__aiSnapshot,"selection"))&&!!(r.__aiSnapshot&&r.__aiSnapshot.hasSelection),A=!!E(ct(r.__aiSnapshot,"document"));if(!f.hasSource){var q=f.scope==="selection"?M:V,O=f.scope==="selection"?"load-selection":"load-document",le=O==="load-selection"?g:A;if(le&&q&&!q.disabled)return{actionId:O,button:q,label:Qt(O,f)||"Load source",detail:lt(O,f)};if(A&&V&&!V.disabled)return{actionId:"load-document",button:V,label:(V.innerText||V.textContent||"").replace(/\s+/g," ").trim()||"Whole document",detail:lt("load-document",f)};if(g&&M&&!M.disabled)return{actionId:"load-selection",button:M,label:(M.innerText||M.textContent||"").replace(/\s+/g," ").trim()||"Use selection",detail:lt("load-selection",f)}}return f.isStale&&Ke&&Ke.style.display!=="none"&&!Ke.disabled?{actionId:"rerun",button:Ke,label:(Ke.innerText||Ke.textContent||"").replace(/\s+/g," ").trim()||(f.staleAction==="source"?"Re-run from source":"Re-run from editor"),detail:lt("rerun",f)}:!f.hasResult&&j&&!j.disabled&&E(W.value)?{actionId:"run",button:j,label:c.__aiT?c.__aiT("aiassist","Ask AI"):"Ask AI",detail:lt("run",f)}:f.pendingIndexes.length&&te&&!te.disabled?{actionId:"apply",button:te,label:(te.innerText||te.textContent||"").replace(/\s+/g," ").trim()||"Apply",detail:lt("apply",f)}:Se&&Se.style.display!=="none"&&!Se.disabled?{actionId:"preview",button:Se,label:(Se.innerText||Se.textContent||"").replace(/\s+/g," ").trim()||"Preview",detail:lt("preview",f)}:xe&&xe.style.display!=="none"&&!xe.disabled?{actionId:"selection",button:xe,label:(xe.innerText||xe.textContent||"").replace(/\s+/g," ").trim()||"Replace selection",detail:lt("selection",f)}:Ue&&Ue.style.display!=="none"&&!Ue.disabled?{actionId:"document",button:Ue,label:(Ue.innerText||Ue.textContent||"").replace(/\s+/g," ").trim()||(c.__aiT?c.__aiT("ai2_repldoc","Replace document"):"Replace document"),detail:lt("document",f)}:Le&&Le.style.display!=="none"&&!Le.disabled?{actionId:"insert",button:Le,label:(Le.innerText||Le.textContent||"").replace(/\s+/g," ").trim()||"Insert below",detail:lt("insert",f)}:null}function tt(f){f=f||nt();var g=U(f);oa(g);for(var A=[M,V,j,Y,Ke,te,xe,Se,Le,Ue,Tt],q=0;q<A.length;q++){var O=A[q],le=O&&O.getAttribute?O.getAttribute("data-rte-ai-dialog-action")||(O===Ke?"rerun":""):"";ji(O,le,f,!!(g&&O===g.button))}if(Q&&Q.classList){var de=!!(g&&g.actionId&&g.actionId!=="apply"&&g.button&&g.button.parentNode===Q&&te&&te.disabled);Q.classList.toggle("is-alt-recommended",de)}if(!g){Qe.style.display="none",hr.innerText="",lr.innerText="",Qe.setAttribute("aria-label","No recommended Ask AI follow-up action yet.");return}Qe.style.display="",it.innerText=c.__aiT?c.__aiT("aid_bestnext","Best next step"):"Best next step",hr.innerText=g.label||"";var ae=Qa(f,g);lr.innerText=ae||"",Qe.setAttribute("aria-label",(c.__aiT?c.__aiT("aid_bestnextaria","Best next step: {0}.",g.label||"Action"):"Best next step: "+(g.label||"Action")+".")+(ae?" "+ae:""))}function Re(){var f=r.__aiSourceScope||(r.__aiSnapshot&&r.__aiSnapshot.hasSelection?"selection":"document");xi(f),j.onclick()}function Ct(){j.onclick()}function Gt(f,g){if(!f||!f.length)return!1;var A=La(f,{snapshot:r.__aiSnapshot,resolved:r.__aiResolved});return A&&(mt.innerText=g||"Applied the selected AI step."),A}function Yt(f){var g=f&&f.operations?f.operations:[],A=nt();Wt.innerHTML="",Zr.innerText=r.__aiPlanStale?r.__aiPlanStaleReason||"Editor changed. Re-run to refresh.":"";var q=r.__aiPlanStaleAction==="source"&&!E(W.value);if(Ke.innerText=r.__aiPlanStaleAction==="source"?"Re-run from source":"Re-run from editor",Ke.style.display=r.__aiPlanStale&&!q?"":"none",Ke.disabled=q,sr.className=r.__aiPlanStale?"demo-ai-plan-status is-stale":"demo-ai-plan-status",!g.length){var O=o(Wt,"li","","demo-ai-plan-item is-empty");o(O,"span","","demo-ai-plan-type","No plan yet"),o(O,"span","","demo-ai-plan-copy","Run Ask AI to see the steps the editor will apply."),Er.innerText="",Ke.style.display="none",te.disabled=!0,te.innerText="Apply";return}for(var le=0,de=0,ae=0;ae<g.length;ae++){var Fe=g[ae],st=_s(Fe),ft=o(Wt,"li","","demo-ai-plan-item"),Tr=o(ft,"div","","demo-ai-plan-header");o(Tr,"span","","demo-ai-plan-type",st.title);var vt=ti(ae);vt&&(o(Tr,"span","","demo-ai-plan-state is-"+vt,vt==="done"?"Applied":"Skipped"),vt==="done"?le++:vt==="skipped"&&de++);var ai=st.copy;Fe.reason&&(ai+=" Reason: "+Fe.reason),o(ft,"span","","demo-ai-plan-copy",ai);var Ti=o(ft,"div","","demo-ai-plan-actions");if(vt!=="done"){var kt=dt(Fe)&&!A.hasSelection,Or=kt?ws([Fe]):ic(Fe),ni=o(Ti,"button","","secondary demo-ai-plan-button",Or);ni.type="button",ni.disabled=!!r.__aiPlanStale||kt,ys(ni,Or,ac(Fe,A),r.__aiPlanStale?"Currently unavailable until Ask AI is rerun.":kt?"Currently unavailable until text is selected in the editor.":""),ni.onclick=(function(pt,wt,Zt){return function(){Gt([wt],'Applied "'+Zt+'".')&&(Pr(pt,"done"),Ot('Applied "'+Zt+'". Re-run to refresh the remaining plan.',"editor"))}})(ae,Fe,st.title)}if(vt!=="done"){var k=o(Ti,"button","","secondary demo-ai-plan-button",vt==="skipped"?"Include step":"Skip step");k.type="button",k.disabled=!!r.__aiPlanStale,ys(k,k.innerText||k.textContent||"Skip step",vt==="skipped"?"Add this step back into the pending AI plan.":"Skip this step from the pending AI plan.",r.__aiPlanStale?"Currently unavailable until Ask AI is rerun.":""),k.onclick=(function(pt,wt){return function(){Pr(pt,wt?"":"skipped"),mt.innerText=wt?"Included the step back into the pending AI plan.":"Skipped this step from the pending AI plan.",Yt(r.__aiResolved)}})(ae,vt==="skipped")}}for(var re=zt(g),Ie=[],rt=0;rt<re.length;rt++)Ie.push(g[re[rt]]);Er.innerText=re.length+" pending \u2022 "+le+" applied \u2022 "+de+" skipped",te.disabled=!re.length||!!r.__aiPlanStale||!A.canApplyPlan,r.__aiPlanStale?te.innerText="Re-run to refresh plan":re.length?A.pendingSelectionDependent&&!A.hasSelection?te.innerText=ws(Ie):re.length===g.length?te.innerText=bs(f):te.innerText="Apply "+re.length+" pending steps":te.innerText="No pending steps"}function cr(f,g){var A=g||"";j.disabled=!!f||!E(W.value),Y.disabled=!!f||!E($.value),M.disabled=!!f||!r.__aiSnapshot||!r.__aiSnapshot.hasSelection,V.disabled=!!f,C&&(C.disabled=!!f),v.disabled=!!f,W.readOnly=!!f,Ke.disabled=!!f,te.disabled=!!f||te.disabled,xe.disabled=!!f||xe.disabled,Se.disabled=!!f||Se.disabled,Le.disabled=!!f||Le.disabled,Ue.disabled=!!f||Ue.disabled,Tt.disabled=!!f||Tt.disabled;for(var q=Wt.querySelectorAll?Wt.querySelectorAll(".demo-ai-plan-button"):[],O=0;O<q.length;O++)q[O].disabled=!!f;K&&(K.disabled=!!f||!E($.value)),ne&&(ne.disabled=!!f||!E($.value)),Ae&&(Ae.disabled=!!f||!E($.value)),I&&(I.disabled=!!f),_e&&(_e.disabled=!!f),f?(j.classList.add("is-busy"),he(j,"spinner",c.__aiT?c.__aiT("aic_thinking","Thinking..."):"Thinking...")):j.classList.remove("is-busy"),mt.innerText=A,tt()}function xi(f){r.__aiSourceScope=f==="selection"?"selection":"document",r.__aiSourceLinkedToEditor=!0,r.__aiSnapshot=ut(),W.value=ct(r.__aiSnapshot,r.__aiSourceScope),r.__aiLastLinkedSourceText=W.value,ke(),yr(),dr(),Mt()}function dr(){var f=nt(),g=f.hasResult,A=f.hasSource,q=f.isStale;a&&a.classList&&(g||q?a.classList.remove("is-pre-result"):a.classList.add("is-pre-result"));var O=r&&r.parentNode;O&&O.classList&&(g||q?O.classList.remove("is-pre-result"):O.classList.add("is-pre-result"));var le=f.pendingOperationType,de=g||q?f.actionScope:f.scope,ae=de==="selection"&&le!=="replace-selection",Fe=de==="selection"&&le!=="preview-suggestion",st=f.canInsert&&le!=="insert-below",ft=f.canReplaceDocument&&le!=="replace-document";je.innerText=E(W.value)||"Load text from the editor to start a preview.",et.innerText=g?$.value:"Run Ask AI to generate a suggestion preview.";var Tr=_a(r.__aiResolved)||"";if(_t.innerText=Tr||"This suggestion does not include an explicit AI rationale yet.",Yt(r.__aiResolved),Pe&&Pe.style){var vt=r.__aiResolved,ai=vt&&vt.operations?vt.operations.length:0,Ti=!!Tr||ai>1;Pe.style.display=g&&Ti?"":"none",!Ti&&qe&&qe.classList&&!qe.classList.contains("is-collapsed")&&(qe.classList.add("is-collapsed"),Pe.setAttribute("aria-expanded","false"))}if(xe.innerText=Qt("selection",f)||"Replace selection",Se.innerText=Qt("preview",f)||"Preview",xe.style.display=ae?"":"none",Se.style.display=Fe?"":"none",Le.style.display=st?"":"none",Ue.style.display=ft?"":"none",ue){var kt=[];ae&&kt.push("Replace selection"),Fe&&kt.push("Preview"),st&&kt.push("Insert below"),ft&&kt.push(c.__aiT?c.__aiT("ai2_repldoc","Replace document"):"Replace document");var Or=kt.length,ni=Or>0;if(ue.style.display=ni?"":"none",ni){var k="More apply options ("+Or+"): "+kt.join(", ");ue.title=k,ue.setAttribute("aria-label",k),ue.setAttribute("data-rte-ai-more-count",String(Or))}!ni&&Q.classList.contains("is-show-more")&&(Q.classList.remove("is-show-more"),ue.setAttribute("aria-expanded","false"))}xe.disabled=q||!f.canReplaceSelection,Se.disabled=q||!f.canPreview,Le.disabled=q||!f.canInsert,Ue.disabled=q||!f.canReplaceDocument,j.disabled=!A,Y.disabled=!g,Tt.disabled=!g;var re=g||q?c.__aiT?c.__aiT("aid_regenerate","Regenerate"):"Regenerate":c.__aiT?c.__aiT("aid_generate","Generate"):"Generate";he(j,"sparkles",re),oe(),tt(f)}function Ql(){if(!(!r.isConnected||s.__aiDialog!==r)){var f=r.__aiSourceScope==="selection"?"selection":"document",g=!!r.__aiSourceLinkedToEditor,A=r.__aiSnapshot||ut(),q=ut(),O=ct(A,f),le=ct(q,f),de=f==="selection"&&(!!A.hasSelection!=!!q.hasSelection||!ll(A.range,q.range)||O!==le),ae=f==="document"?(A.wholeText||"")!==(q.wholeText||""):de,Fe=ae||!!A.hasSelection!=!!q.hasSelection;if(r.__aiSnapshot=q,g&&(r.__aiLastLinkedSourceText=le),!!Fe){if(yr(),g){if(W.value=le,ke(),ae&&E($.value)&&!r.__aiPlanStale){Ot($e(f,q,A),"editor");return}}else if(ae&&E($.value)&&!r.__aiPlanStale){Ot(xr(f,q,A),"source");return}dr(),Mt()}}}function Si(){if(za(),ke(),E($.value)){Ot(We(W.value),"source");return}dr(),Mt()}function Oi(f){if(E($.value)){Ot(f,"source");return}dr()}function $a(f){var g=f==="selection"?"selection":"document",A=r.__aiSourceScope==="selection"?"selection":"document",q=E(W.value),O=!!r.__aiSourceLinkedToEditor;if(xi(g),!!E($.value)){var le=E(W.value);if(A!==g){Ot(Hr(g),"editor");return}(!O||q!==le)&&Ot(Rt(g),"editor")}}M.onclick=function(){$a("selection")},V.onclick=function(){$a("document")},C&&(C.onchange=function(){$a(C.value)}),Ke.onclick=function(){if(r.__aiPlanStaleAction==="source"){Ct();return}Re()},v.onchange=function(){Mt(),Oi(ii())},b.onchange=function(){Mt(),Oi(Je(b.value))},j.onclick=function(){var f=ut();if(r.__aiSnapshot=f,r.__aiSourceLinkedToEditor&&(W.value=ct(f,r.__aiSourceScope),r.__aiLastLinkedSourceText=W.value,ke()),yr(),!E(W.value)){mt.innerText="Load or type source text before running Ask AI.",dr();return}cr(!0,""),an(v.value,{snapshot:f,source:W.value,scope:Ir(f),mode:v.value,language:b.value}).then(function(g){r.__aiResolved=g,r.__aiOperationStates={},r.__aiPlanStale=!1,r.__aiPlanStaleReason="",r.__aiPlanStaleAction="",$.value=$t(g)||"",dr(),cr(!1,$.value?"":"No suggestion returned.")}).catch(function(g){console.error("AI Toolkit dialog run failed",g),r.__aiResolved=null,r.__aiOperationStates={},r.__aiPlanStale=!1,r.__aiPlanStaleReason="",r.__aiPlanStaleAction="",$.value="",dr(),cr(!1,"AI suggestion failed.")})},Y.onclick=function(){E($.value)&&(W.value=$.value,Si())},W.oninput=function(){Si()},W.onkeydown=function(f){f&&(f.ctrlKey||f.metaKey)&&f.keyCode===13&&(f.preventDefault(),j&&!j.disabled&&j.onclick&&j.onclick())},te.onclick=function(){for(var f=r.__aiResolved&&r.__aiResolved.operations?r.__aiResolved.operations:[],g=zt(f),A=[],q=0;q<g.length;q++)A.push(f[g[q]]);if(A.length&&Gt(A,"Applied the pending AI plan.")){for(var O=0;O<g.length;O++)Pr(g[O],"done");r.close()}},xe.onclick=function(){vr(Kr($.value,"selection",or("selection"),r.__aiResolved?r.__aiResolved.request:null,r.__aiResolved?r.__aiResolved.action:null),{snapshot:r.__aiSnapshot})&&r.close()},Se.onclick=function(){var f=Kr($.value,"selection-preview",or("selection-preview"),r.__aiResolved?r.__aiResolved.request:null,r.__aiResolved?r.__aiResolved.action:null);f&&f.operations&&f.operations[0]&&!f.operations[0].reason&&(f.operations[0].reason=_a(r.__aiResolved)),vr(f,{snapshot:r.__aiSnapshot})&&r.close()},Le.onclick=function(){vr(Kr($.value,"insert",or("insert"),r.__aiResolved?r.__aiResolved.request:null,r.__aiResolved?r.__aiResolved.action:null),{snapshot:r.__aiSnapshot})&&r.close()},Ue.onclick=function(){vr(Kr($.value,"document",or("document"),r.__aiResolved?r.__aiResolved.request:null,r.__aiResolved?r.__aiResolved.action:null),{snapshot:r.__aiSnapshot})&&r.close()},Tt.onclick=function(){r.close()},r.addEventListener("keydown",function(f){if(f&&(f.ctrlKey||f.metaKey)&&f.keyCode===13){var g=f.target;if(g!==W){var A=null;if(te&&!te.disabled&&te.offsetParent!==null)A=te;else if(Q&&Q.classList&&Q.classList.contains("is-alt-recommended")){var q=Q.querySelector('[data-rte-ai-dialog-recommended="true"]:not([disabled])');q&&q.offsetParent!==null&&(A=q)}A&&typeof A.onclick=="function"&&(f.preventDefault(),A.onclick())}}}),r.__aiSourceLinkedToEditor=!0,r.__aiLastLinkedSourceText="",r.__aiSyncFromEditor=Ql,tu(),xi(e.useDocument?"document":t.hasSelection?"selection":"document"),dr(),e.autoRun&&j.onclick();try{setTimeout(function(){try{E(W.value)&&j&&!j.disabled&&j.focus?j.focus():W&&W.focus?W.focus():v&&v.focus&&v.focus()}catch{}},0)}catch{}}}
|