@richscripts/richtexteditor 2.14.1 → 2.16.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 +182 -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 +40 -52
- 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 +68 -22
- package/package.json +25 -3
- package/react/index.js +118 -37
- package/react/index.mjs +29 -0
- package/richtexteditor/all_plugins.js +8816 -2373
- package/richtexteditor/all_plugins.min.js +77 -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 +1050 -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 +1056 -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 +1056 -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 +1056 -2
- package/richtexteditor/lang/rte-lang-ja.js +1056 -2
- package/richtexteditor/lang/rte-lang-kn.js +1 -0
- package/richtexteditor/lang/rte-lang-ko.js +1056 -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 +1056 -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 +1056 -2
- package/richtexteditor/lang/rte-lang-pt.js +1056 -2
- package/richtexteditor/lang/rte-lang-ro.js +1 -0
- package/richtexteditor/lang/rte-lang-ru.js +1056 -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 +1050 -2
- package/richtexteditor/lang/rte-lang-zh-Hant.js +1050 -2
- package/richtexteditor/plugins/a11yenhance.js +4 -1
- package/richtexteditor/plugins/a11yenhance.min.js +1 -1
- package/richtexteditor/plugins/accessibilitychecker.js +256 -64
- package/richtexteditor/plugins/accessibilitychecker.min.js +1 -1
- package/richtexteditor/plugins/aitoolkit.js +1057 -386
- package/richtexteditor/plugins/aitoolkit.min.js +7 -7
- package/richtexteditor/plugins/all_plugins.js +8816 -2373
- package/richtexteditor/plugins/all_plugins.min.js +77 -59
- package/richtexteditor/plugins/autocorrect.js +66 -31
- package/richtexteditor/plugins/autocorrect.min.js +1 -1
- package/richtexteditor/plugins/autoembed.js +18 -1
- 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 +460 -61
- package/richtexteditor/plugins/comments.min.js +4 -3
- package/richtexteditor/plugins/contentminimap.js +28 -9
- package/richtexteditor/plugins/contentminimap.min.js +1 -1
- package/richtexteditor/plugins/crdt-engine.js +27 -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 +250 -59
- package/richtexteditor/plugins/documentimport.min.js +4 -4
- package/richtexteditor/plugins/documentoutline.js +47 -8
- package/richtexteditor/plugins/documentoutline.min.js +1 -1
- package/richtexteditor/plugins/docxexport.js +233 -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 +111 -57
- 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 +6 -6
- 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 +8 -8
- package/richtexteditor/plugins/html2pdf.min.js +1 -1
- package/richtexteditor/plugins/imageeditor.js +31 -12
- 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 +29 -11
- package/richtexteditor/plugins/insertcode.min.js +6 -6
- package/richtexteditor/plugins/insertemoji.js +113 -16
- package/richtexteditor/plugins/insertemoji.min.js +1 -1
- package/richtexteditor/plugins/insertgallery.js +46 -40
- package/richtexteditor/plugins/insertgallery.min.js +1 -1
- package/richtexteditor/plugins/inserttemplate.js +43 -19
- 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 +90 -27
- package/richtexteditor/plugins/mentionplugin.min.js +1 -1
- package/richtexteditor/plugins/mermaiddiagram.js +14 -8
- 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/nodetypes.js +1 -1
- package/richtexteditor/plugins/nodetypes.min.js +1 -1
- package/richtexteditor/plugins/pagination.js +2 -2
- package/richtexteditor/plugins/pagination.min.js +1 -1
- package/richtexteditor/plugins/pdfexport.js +1752 -1167
- package/richtexteditor/plugins/pdfexport.min.js +28 -13
- 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 +30 -16
- 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 +173 -41
- package/richtexteditor/plugins/revisionhistory.min.js +3 -3
- package/richtexteditor/plugins/rubyannotation.js +21 -11
- package/richtexteditor/plugins/rubyannotation.min.js +1 -1
- package/richtexteditor/plugins/sanitizer.js +119 -7
- package/richtexteditor/plugins/sanitizer.min.js +1 -1
- package/richtexteditor/plugins/slashcommand.js +32 -18
- package/richtexteditor/plugins/slashcommand.min.js +2 -2
- package/richtexteditor/plugins/smartchips.js +39 -25
- package/richtexteditor/plugins/smartchips.min.js +2 -2
- package/richtexteditor/plugins/spellcheck.js +20 -11
- package/richtexteditor/plugins/spellcheck.min.js +2 -2
- package/richtexteditor/plugins/stateinspector.js +21 -11
- package/richtexteditor/plugins/stateinspector.min.js +2 -2
- package/richtexteditor/plugins/structured-content-bridge.js +90 -32
- package/richtexteditor/plugins/structured-content-bridge.min.js +8 -8
- 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 +19 -6
- 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 +11 -6
- 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 +144 -86
- package/richtexteditor/rte-headless.js +19 -4
- package/richtexteditor/rte-watchdog.js +3 -1
- package/richtexteditor/rte-webcomponent.js +91 -16
- package/richtexteditor/rte.js +146 -88
- package/richtexteditor/runtime/colorpicker_more_ns.htm +3 -1
- 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 ne=L[s].getAttribute("href")||"";if(/(?:^|\/)aitoolkit(?:\.min)?\.css(?:\?.*)?$/i.test(ne))return}for(var ha=null,Fi=document.getElementsByTagName("script"),Li=Fi.length-1;Li>=0;Li--){var Ni=Fi[Li].getAttribute("src")||"";if(/(?:^|\/)(?:aitoolkit|all_plugins)(?:\.min)?\.js(?:[?#].*)?$/i.test(Ni)){ha=Fi[Li];break}}var tn=ha?ha.getAttribute("src"):"";function ga(Ut){if(tn)return tn.replace(/[?#].*$/,"").replace(/[^/]+$/,Ut);var Wn=typeof RichTextEditor<"u"&&RichTextEditor.__scriptBase||window.RTE_DefaultConfig&&window.RTE_DefaultConfig.url_base||"/richtexteditor";return Wn+"/plugins/"+Ut}function ma(Ut){return Ut.indexOf("?")<0?Ut+"?v=20261018a":Ut}var o=document.createElement("link");o.rel="stylesheet",o.href=ma(ga("aitoolkit.min.css")),o.setAttribute("data-rte-auto-injected","aitoolkit"),o.onerror=function(){o.getAttribute("data-rte-css-fallback")||(o.setAttribute("data-rte-css-fallback","1"),o.href=ma(ga("aitoolkit.css")))},(document.head||document.documentElement).appendChild(o)})(),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;function ne(e,t,r,i){var a=L&&L["text_"+e]||t;return r!==void 0&&(a=a.split("{0}").join(String(r))),i!==void 0&&(a=a.split("{1}").join(String(i))),a}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,Ni("toolbar_default","#{aiassist}"),Ni("toolbar_basic","#{aiassist}"),Ni("toolbar_full","#{aiassist}"),Ni("toolbar_mobile","#{aiassist}"),tn("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="'+$r(v)+'" alt="'+$r(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 S=h.createElement("button");S.type="button",S.className="rte-image-gen-cancel",S.textContent=c.__aiT?c.__aiT("aig_cancel","Cancel"):"Cancel",S.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.")})}),S.addEventListener("click",l),_.addEventListener("keydown",function(F){(F.key==="Escape"||F.key==="Esc")&&(F.preventDefault(),l())}),P.appendChild(S),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:Nr,buildDemoResult:Ft,isDemoMode:ga,getTranslateLanguages:_a,getTranslateLanguageLabel:ut,getOperationContract:ms,getActionDefinitions:rl,registerAction:Wu,removeAction:Bu,getDialogModes:il,registerDialogMode:Xu,removeDialogMode:Yu,resolveAction:function(v,h){return ln(v,h)},loadSelectionText:function(){var v=ct();return v.text||v.wholeText},loadDocumentText:function(){return E(s.getText?s.getText():"")},textToHtml:function(v){return on(v)},previewInlineSuggestion:function(v,h){return eo(v,h)},applyResult:function(v,h){return Tn(v,h)},executeOperations:function(v,h){return Ca(v,h)},executeResolvedAction:function(v,h){return pr(v,h)},registerOperationHandler:Zu,unregisterOperationHandler:ec,getSuggestions:function(){return Ke().slice()},clearSuggestions:function(){return Sc()},getReviewLogEntries:function(){return Ki().slice()},setResolver:function(v){L.aiToolkitResolver=typeof v=="function"?v:null},openChatPanel:function(v){ta(v)},closeChatPanel:function(){ea({restoreFocus:!0})},toggleChatPanel:function(v){Sd(v)},getChatSessions:function(v){return pd(v)},loadChatSession:function(v,h){return hd(v,h)},clearChatSessions:function(v){return gd(v)},openReviewPanel:function(v){Fn(v)},closeReviewPanel:function(){Zr()},toggleReviewPanel:function(v){Hf(v)},saveSuggestionLedger:function(){return At()},loadSuggestionLedger:function(){return Ms()},loadRemoteSuggestionLedger:function(v,h){return Is(v,h)},loadReviewLogEntries:function(v,h){return Ss(v,h)},refreshRemoteReviewState:function(v,h){return ui(v,h)},openDialog:function(v){oa(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 _=Ke(),b=0;b<_.length;b++)if(_[b].id===h.id){_[b]=h;break}return b===_.length&&_.push(h),At(),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&me(!1),h},update:function(v,h){for(var _=Ke(),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 At(),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&me(!1),_[b]}return null},remove:function(v){for(var h=Ke(),_=0;_<h.length;_++)if(h[_].id===v)return h.splice(_,1),At(),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&me(!1),!0;return!1},get:function(v){for(var h=Ke(),_=0;_<h.length;_++)if(h[_].id===v)return h[_];return null},list:function(v){var h=Ke().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&&me(!1)}},s.attachEvent("exec_command_aiassist",function(v){v.returnValue=!0,v.stopBubble=!0,oa()}),s.attachEvent("exec_command_aichat",function(v){v.returnValue=!0,v.stopBubble=!0,ta({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(!(!_||!be(_))){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){Tt(_,{focusPanel:!0,focusAction:H||z(),openedQueue:!0});return}if(Ye(_),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&me(!1),yn(_,H))return;xa(h);return}v.preventDefault(),v.stopPropagation();var R=b.getAttribute("data-rte-ai-action"),C="",P=s.__aiActiveSuggestionId===_;(R==="accept"||R==="reject")&&P&&(C=na(_)),R==="accept"?ka(_)&&(C?Dt(C,{focusInlineAction:R}):P&&je(Sn("Accepted",_))):R==="reject"?Ea(_)&&(C?Dt(C,{focusInlineAction:R}):P&&je(Sn("Rejected",_))):R==="review"?Tt(_,{focusPanel:!0}):R==="previous"?nu(_,{focusInlineAction:R})||je(rr(_,"previous")):R==="next"?lu(_,{focusInlineAction:R})||je(rr(_,"next")):R==="shared-seen"?(cl(),Ji(),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&me(!1),je("Shared AI review updates cleared for the current item."),xa(h)):R==="undo"?Er({focusInlineAction:"undo"}):R==="redo"&&Vr({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||!be(b)||v.ctrlKey||v.metaKey||v.altKey)){v.__rteAiInlinePreviewKeydownHandled=!0;var H=(v.key||"").toLowerCase(),x=_&&_.getAttribute&&_.getAttribute("data-rte-ai-action")||"",R=x||gl(be(b)),C=!!(s.__aiReviewEmptyPreviewSuggestionId&&b===s.__aiReviewEmptyPreviewSuggestionId);if(C){(H==="enter"||H===" ")&&(v.preventDefault(),Tt(b,{focusPanel:!0,focusAction:x||z(),openedQueue:!0}));return}if(H==="arrowleft"||H==="k")v.preventDefault(),nu(b,{focusInlineAction:x})||je(rr(b,"previous"));else if(H==="arrowright"||H==="j")v.preventDefault(),lu(b,{focusInlineAction:x})||je(rr(b,"next"));else if(H==="home")v.preventDefault(),pf(b,{focusInlineAction:x})||je(rr(b,"first"));else if(H==="end")v.preventDefault(),hf(b,{focusInlineAction:x})||je(rr(b,"last"));else if(H==="a"){v.preventDefault();var P=na(b);ka(b)&&(P?Dt(P,{focusInlineAction:x}):je(Sn("Accepted",b)))}else if(H==="r"){v.preventDefault();var S=na(b);Ea(b)&&(S?Dt(S,{focusInlineAction:x}):je(Sn("Rejected",b)))}else if(H==="u"&&!v.shiftKey&&nr())v.preventDefault(),Er({focusInlineAction:R||"accept"});else if(H==="u"&&v.shiftKey){var D=kr();D&&D.suggestion&&D.suggestion.id===b&&(v.preventDefault(),Vr({focusInlineAction:R||"accept"}))}else if(H==="g")Vt(b)&&(v.preventDefault(),cl(),Ji(),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&me(!1),je("Shared AI review updates cleared for the current item."),xa(h));else if(H==="enter"||H===" "){if(_)return;v.preventDefault(),yn(b,x||z())}}}}}s.__aiBindInlinePreviewEventHandlers=w,w(),Ms(),ui(!1),Tc(),xc()};var ha={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 Fi(e){return String(e||"").replace(/\s+/g,"")}function Li(e){if(L.aiToolkitAutoToolbarButtons===!1)return!1;var t=L[e];if(!t)return!0;var r=ha[e];return r?Fi(t)===Fi(r):!0}function Ni(e,t){var r=L[e]||"";r.indexOf("aiassist")===-1&&Li(e)&&(L[e]=r?r+" "+t:t)}function tn(e,t){var r=L[e]||"";r.indexOf("aiassist")===-1&&Li(e)&&(L[e]=r?r+t:t)}function ga(){return typeof L.aiToolkitResolver!="function"}function ma(e){if(!ga())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 Ut(e,t,r){var i=o(e,"div","",t,r);return i.setAttribute("aria-hidden","true"),i}function Wn(){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 zf(){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 Qf(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=Wn(),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 Bn(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 Ri(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 ve(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 rn=[["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"]],Xn=[["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 Yn(){var e=L&&L.text_uilocale;return e&&!/^en(-|$)/i.test(e)?e:""}function Zn(){return/^(zh|ja)/i.test(Yn())}function ju(e){if(!oi){oi={};for(var t=0;t<rn.length;t++){var r=rn[t][1];oi["="+r]||(oi["="+r]=rn[t][0]),oi["~"+r.toLowerCase()]||(oi["~"+r.toLowerCase()]=rn[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<Xn.length;r++){var i=Xn[r][1].exec(e);if(i){var a=L["text_"+Xn[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+=Zn()?String.fromCharCode(r===":"?65306:12290):r)}return a}function Rr(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=Rr(t.substring(0,i)),n=Rr(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&&Zn()?"":" ")+h:h,d=v}}return p?u:null}var el=null,ls=null;function ss(e){if(e==null||!Zn())return e;if(!el){var t="\u4E00-\u9FFF\u3040-\u30FF\u201D\u300D";el=new RegExp("(["+t+"])\\.","g"),ls=new RegExp("([\u3002\uFF1A])\\s+(?=[^A-Za-z0-9\\s])","g")}return e.replace(el,"$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||!Yn()))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(Rr(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(Rr(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||!Yn()||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 Nr(e){var t=E(e);return t&&(t=t.charAt(0).toUpperCase()+t.substring(1),/[.!?]$/.test(t)||(t+="."),t)}function _a(){return(L.aiToolkitTranslateLanguages||[]).slice()}function Ci(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[Ci(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 ut(e){for(var t=Ci(e),r=_a(),i=0;i<r.length;i++)if(Ci(r[i].value)===t||Ci(r[i].label)===t)return r[i].label||r[i].value;return e?Nr(String(e)).replace(/[.!?]$/,""):"Spanish"}function Nu(e){for(var t=Ci(e),r=_a(),i=0;i<r.length;i++)if(Ci(r[i].value)===t||Ci(r[i].label)===t)return r[i].value||r[i].label;return t||"spanish"}function Xe(e){var t=E(e||"").toLowerCase();return t||"other"}function De(e){switch(Xe(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 Kr(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=ba(e),r=t===1?"1 pending":t+" pending",i=e&&e.suggestionType?De(e.suggestionType):"AI";return!i||i==="Other"?"Open queue ("+r+")":"Open "+i+" queue ("+r+")"}function ds(e){var t=ba(e),r=t===1?"1 pending item":t+" pending items",i=e&&e.suggestionType?De(e.suggestionType):"AI",a=Ue(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 an(e){var t=ba(e),r=t===1?"1 pending":t+" pending",i=e&&e.suggestionType?De(e.suggestionType):"AI",a=Ue(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 ba(e){if(!e)return 0;var t=Xe(e.suggestionType||""),r=t==="other"?"all":t;return We(r).length}function Ku(e){var t=ba(e),r=t===1?"1 pending item":t+" pending items",i=e&&e.suggestionType?De(e.suggestionType):"AI",a=Ue(e,z());return!i||i==="Other"?"Opens AI review queue."+(a?" Focuses "+a+".":"")+" "+r:"Opens "+i+" AI review queue."+(a?" Focuses "+a+".":"")+" "+r}function tl(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&&Xe(e.suggestionType)!=="other"&&r.push(De(e.suggestionType)),e&&e.language&&r.push(ut(e.language));var a=Kr(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),ve(r)}function fs(e,t,r,i){var a=i==="selection"?"Selection":i==="document"?"Document":t&&t.hasSelection?"Selection":"Document",n=De(e);return Xe(e)==="translate"&&r?n+" - "+a+" - "+ut(r):n+" - "+a}function zu(e,t){var r=E(e);if(!r)return"";var i=Nu(t),a=ut(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 Nr(l+": "+r)}function Ft(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 Nr(a.slice(0,Math.max(8,Math.ceil(a.length*.6))).join(" "));case"expand":return Nr(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
|
+
- `+Nr(a.slice(0,Math.max(10,Math.ceil(a.length*.45))).join(" "));default:return Nr(i)}}function vs(e){var t=E(e);return t?Nr('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?Nr("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 nn(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(nn(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=_a(),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=ut(a||"spanish");return d=Ft("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:[gt(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=Ft("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:[gt(p,d,{reason:u},e,e.action)]}):/\b(summarize|summary|recap)\b|\bexecutive summary\b/.test(i)?(d=Ft("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:[gt(p,d,{reason:u},e,e.action)]}):/\b(proofread|grammar|fix|correct)\b|\bclean up\b/.test(i)?(d=Ft("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:[gt(l,d,{reason:u},e,e.action)]}):/\b(rewrite|adjust|clarify|improve|polish|tone)\b/.test(i)?(d=Ft("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:[gt(l,d,{reason:u},e,e.action)]}):{message:$u(i,r),operations:[]}}function ps(e){for(var t=rl(),r=0;r<t.length;r++)if(t[r].id===e)return t[r];return null}function rl(){return(L.aiToolkitActions||[]).slice()}function il(){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 gt(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 gt(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}:gt(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=[gt(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 Jt(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 wa(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",ve(a)),e.title=r?(t||"Action")+" - "+r+(i?" "+i:""):(t||"Action")+(i?" - "+i:"")}}function zr(e,t,r,i,a){return nl({operations:[gt(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 al(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:[gt(e.action&&e.action.target?e.action.target:"selection-preview",Ft("proofread",e.source,al(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:[gt(e.action&&e.action.target?e.action.target:"selection-preview",Ft("rewrite",e.source,al(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:[gt(i,Ft("translate",e.source,{language:e.language}),{reason:"This prepares a translated "+ut(e.language||"spanish")+" draft while keeping the original text available for review."},e,e.action)],reason:"This prepares a translated "+ut(e.language||"spanish")+" draft while keeping the original text available for review."};case"justify":return{operations:[{type:"preview-suggestion",text:Ft("rewrite",e.source,al(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:[gt(e.action&&e.action.target?e.action.target:"document",Ft("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:[gt(l,Ft("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:[gt(e.action&&e.action.target?e.action.target:"document",Ft("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:[gt(e.action&&e.action.target?e.action.target:"document",Ft(e.mode||"rewrite",e.source),null,e,e.action)]}}}function nl(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:[gt(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||Jt({operations:a})||""),target:n,operations:a,message:E(e.message||e.reply||""),reason:E(e.reason||wa({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 ln(e,t){t=t||{};var r=ps(e)||{id:e,title:e,target:"document"},i=t.snapshot||ct(),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)),nl(n,r,a)})}catch(n){return Promise.reject(n)}return Promise.resolve(nl(As(a),r,a))}function ct(){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 ll(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 sl(e,t){if(!e&&!t)return!0;if(!ll(e)||!ll(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 sn(e,t){if(!e||!e.range||!ll(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 on(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 Qr(e){var t=E(e);return t?s.htmlEncode(t).replace(/\n/g,"<br/>"):""}function he(e){return s.htmlEncode(e||"")}function $r(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 Ke(){return s.__aiSuggestions||(s.__aiSuggestions=[]),s.__aiSuggestions}function Ki(){return s.__aiReviewLogEntries||(s.__aiReviewLogEntries=[]),s.__aiReviewLogEntries}function un(){return L.aiToolkitPersistenceKey?"RTE.AIToolkit."+L.aiToolkitPersistenceKey:""}function cn(){return L.aiToolkitPersistenceKey||""}function xs(e){return e?{id:e.id||"log-"+new Date().getTime()+"-"+Math.floor(Math.random()*1e3),documentKey:e.documentKey||cn(),eventType:e.eventType||"suggestion-updated",suggestionId:e.suggestionId||"",status:e.status||"",suggestionType:Xe(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 Ts(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?Ts(e)+" - "+(e.sourceLabel||"AI review"):""}function oc(e,t){return xs({id:"log-"+t.id+"-"+e+"-"+new Date().getTime(),documentKey:cn(),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=Ki();t.unshift(e),t.length>30&&(t.length=30)}}function dn(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 zi(e,t){var r=L.aiToolkitReviewLogUrl||"";if(!r||!t||!cn())return!1;var i=oc(e,t);return uc(i),dn("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=L.aiToolkitReviewLogUrl||"",i=cn();return!r||!i?(typeof t=="function"&&t(Ki().slice(),!1),!1):!e&&s.__aiReviewLogLoaded?(typeof t=="function"&&t(Ki().slice(),!0),!0):(dn("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:vn(e.mentions),reactions:pn(e.reactions),replies:Array.isArray(e.replies)?e.replies:[]}}function fn(e){if(!e)return"";e=String(e),typeof s.sanitizeHtml=="function"&&(e=s.sanitizeHtml(e));for(var t=new DOMParser().parseFromString(__RTE_TT("<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 vn(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 pn(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:fn(e.originalHtml),originalText:e.originalText||"",resultText:e.resultText||"",resultHtml:fn(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:vn(e.mentions),reactions:pn(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:fn(e.originalHtml)||Qr(e.originalText||""),originalText:E(e.originalText||""),resultText:E(e.resultText||""),resultHtml:fn(e.resultHtml)||Qr(e.resultText||""),reason:E(e.reason||""),suggestionType:Xe(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:vn(e.mentions),reactions:pn(e.reactions),blockPath:e.blockPath||"",replies:Array.isArray(e.replies)?e.replies:[]}}function ol(){return L.aiToolkitPersistenceKey||""}function fc(){return{version:"2026-04-18",documentKey:ol(),savedAt:new Date().getTime(),suggestions:Ke().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 Qi(e){return Math.max(e&&e.decidedAt||0,e&&e.createdAt||0)}function ul(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:vn(e.mentions),reactions:pn(e.reactions),snapshot:{hasSelection:!!(e.snapshot&&e.snapshot.hasSelection)}}:null}function vc(e,t){if(!e)return ul(t);if(!t)return e;var r=Qi(e),i=Qi(t);return i>r?ul(t):i<r?e:Rs(t.status)>Rs(e.status)?ul(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 Qi(d)-Qi(u)}),l}function hc(){var e=un(),t="";if(e&&window.localStorage)try{t=window.localStorage.getItem(e)||""}catch{}if(!t){var r=Ei();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):dn("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:ki()?"idle":"local",message:""}),s.__aiReviewSyncState}function Es(){if(!ki())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 hn(e,t){var r=ks();r.phase=e||(ki()?"idle":"local"),r.message=t||"",Ps()}function ki(){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=Vt(t.id),a=Vt(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 Qi(r)-Qi(t)})}function Ac(){for(var e=Ke().slice(),t=!1,r=0;r<e.length;r++){var i=e[r],a=Cr(i.id),n=dl(i.id);if(i.status==="pending"){n&&(n.outerHTML=__RTE_TT(Rl(i)),t=!0);continue}if(i.status==="accepted"||i.status==="rejected"||i.status==="stale"){var l=gn(i,i.status);a?(a.outerHTML=__RTE_TT(l),t=!0):n&&((n.getAttribute("data-rte-ai-resolved-status")||"")!==i.status||n.innerHTML!==(i.status==="accepted"?i.resultHtml||Qr(i.resultText||""):i.originalHtml||Qr(i.originalText||"")))&&(n.outerHTML=__RTE_TT(l),t=!0)}}return vr(),t}function ui(e,t){if(!ki())return typeof t=="function"&&t(Ke().slice()),!1;if(s.__aiReviewSyncInFlight)return typeof t=="function"&&(s.__aiReviewSyncCallbacks||(s.__aiReviewSyncCallbacks=[]),s.__aiReviewSyncCallbacks.push(t)),e&&(s.__aiReviewSyncPending=!0),hn("syncing","Syncing shared AI review..."),!0;s.__aiReviewSyncInFlight=!0,s.__aiReviewSyncPending=!1,s.__aiReviewSyncCallbacks=typeof t=="function"?[t]:[],hn("syncing","Syncing shared AI review...");var r=0,i=Ke().slice(),a=!1,n=Ki().slice(),l=!!s.__aiReviewLogLoaded;function u(){if(r--,!(r>0)){s.__aiReviewSyncInFlight=!1,a?hn("error","Shared AI review sync failed. Showing the last known state."):(_c(new Date().getTime()),hn("idle")),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&me(!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||Ke().slice(),p||(a=!0),Ac(),u()})),L.aiToolkitReviewLogUrl&&(r++,Ss(e,function(d,p){p?l&&yc(wc(n,d||[])):a=!0,u()})),r>0}function Is(e,t){var r=L.aiToolkitSuggestionLedgerUrl||"",i=ol();return!r||!i?(typeof t=="function"&&t(Ke().slice(),!1),!1):!e&&s.__aiSuggestionLedgerLoaded?(typeof t=="function"&&t(Ke().slice(),!0),!0):(dn("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(Ke(),n);s.__aiSuggestions=w,s.__aiSuggestionLedgerLoaded=l,At({skipRemote:!0}),typeof t=="function"&&t(w.slice(),l)}),!0)}function $f(){s.__aiReviewSyncTimer&&(window.clearInterval(s.__aiReviewSyncTimer),s.__aiReviewSyncTimer=null)}function xc(){return!ki()||s.__aiReviewSyncTimer||!window.setInterval?!1:(s.__aiReviewSyncTimer=window.setInterval(function(){document&&document.hidden||ui(!0)},gc()),!0)}function Tc(){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 At(e){e=e||{};var t=fc(),r=JSON.stringify(t),i=Ei();i&&i.setAttribute&&i.setAttribute("data-rte-ai-ledger",r);var a=un();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=[],_n(),Ye(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(),Ye(null),i.slice()}catch{return s.__aiSuggestions=[],_n(),Ye(null),[]}}function Sc(){s.__aiSuggestions=[],_n(),Ye(null);var e=Ei();e&&e.removeAttribute&&e.removeAttribute("data-rte-ai-ledger");var t=un();if(t&&window.localStorage)try{window.localStorage.removeItem(t)}catch{}return s.__aiSuggestionLedgerLoaded=!1,Cs({version:"2026-04-18",documentKey:ol(),savedAt:new Date().getTime(),suggestions:[]},function(){}),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&me(!1),!0}function Ht(){return s.__aiReviewState||(s.__aiReviewState={showResolved:!1,typeFilter:"all",unseenRemoteActivityCount:0,latestRemoteActivity:null,latestRemoteSuggestionId:"",remoteSuggestionIds:{}}),s.__aiReviewState}function cl(){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 ya(e){var t=Ht();return e&&t.remoteSuggestionIds[e]?(delete t.remoteSuggestionIds[e],!0):!1}function Vt(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 be(e){for(var t=Ke(),r=0;r<t.length;r++)if(t[r].id===e)return t[r];return null}function Cr(e){var t=s.getEditable?s.getEditable():null;return t?t.querySelector('[data-rte-ai-suggestion-id="'+e+'"]'):null}function dl(e){var t=s.getEditable?s.getEditable():null;return t?t.querySelector('[data-rte-ai-resolved-id="'+e+'"]'):null}function gn(e,t){if(!e)return"";var r=t||e.status||"accepted",i=e.isBlock?"div":"span",a=r==="accepted"?e.resultHtml||Qr(e.resultText||""):e.originalHtml||Qr(e.originalText||"");return"<"+i+' class="rte-ai-resolved-suggestion is-'+$r(r)+(e.isBlock?" is-block":" is-inline")+'" data-rte-ai-resolved-id="'+$r(e.id)+'" data-rte-ai-resolved-status="'+$r(r)+'">'+a+"</"+i+">"}function $i(){return s.__aiReviewDecisionHistory||(s.__aiReviewDecisionHistory=[]),s.__aiReviewDecisionHistory}function kc(){for(var e=$i(),t=e.length-1;t>=0;t--){var r=e[t],i=r&&r.suggestionId?be(r.suggestionId):null;(!i||i.status!==r.status)&&e.splice(t,1)}return e}function Jf(){var e=$i();return e.length?e[e.length-1]:null}function fl(e,t,r){if(r=r||{},!e||!e.id||!t)return _n(),null;r.clearRedo!==!1&&js();var i=$i();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=$i();return e.length?e.pop():null}function mn(){return s.__aiReviewRedoHistory||(s.__aiReviewRedoHistory=[]),s.__aiReviewRedoHistory}function Ec(e,t){if(!e||!e.id||!t)return null;var r=mn();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=mn();return e.length?e.pop():null}function js(){s.__aiReviewRedoHistory=[]}function _n(){s.__aiReviewDecisionHistory=[],js()}function ci(){for(var e=$i();e.length;){var t=e[e.length-1];if(!t||!t.suggestionId){e.pop();continue}var r=be(t.suggestionId),i=dl(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 kr(){for(var e=mn();e.length;){var t=e[e.length-1];if(!t||!t.suggestionId){e.pop();continue}var r=be(t.suggestionId),i=Cr(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"?De(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:Ze(t.originalText||t.resultText||"suggestion",72),remainingCount:e.remainingCount||0}}function Aa(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 bn(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||kr(),!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"?De(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:Ze(t.originalText||t.resultText||"suggestion",72),remainingCount:e.remainingCount||0}}function vl(e){for(var t=$i(),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=be(n.suggestionId),u=dl(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:Aa(d)})}}}return r}function pl(e){for(var t=mn(),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=be(n.suggestionId),u=Cr(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 wn(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 xa(e){if(!e||!e.focus)return!1;try{return e.focus({preventScroll:!0}),!0}catch{try{return e.focus(),!0}catch{return!1}}}function hl(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=Cr(e);return r?hl(r,t)?!0:xa(r):!1}function gl(e){if(!e)return"";var t=kr();return e.status==="pending"&&t&&t.suggestion&&t.suggestion.id===e.id?"redo":e.status==="pending"?"accept":"review"}function yn(e,t){var r=be(e);if(!r)return!1;var i=Cr(e),a=gl(r),n=t||a;if(i&&(hl(i,n)||a&&a!==n&&hl(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",ne("aiu_sharedupdates","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 Ji(){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=kr(),a=0;a<t.length;a++){var n=t[a].getAttribute("data-rte-ai-suggestion-id")||"",l=be(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,S=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,pe=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,oe=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,ue=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=Vt(n),N=!!(s.__aiReviewEmptyPreviewSuggestionId&&n===s.__aiReviewEmptyPreviewSuggestionId),Le=!!(!N&&s.__aiRecentlyOpenedQueueSuggestionId&&n===s.__aiRecentlyOpenedQueueSuggestionId),de=!N&&r?Pt(r):null,W=!N&&r?Aa(r):"",Ee=N?[]:vl(1),Ce=Ee.length?Ee[0]:null,Ae=!!(!N&&i&&i.suggestion&&i.suggestion.id===n&&l&&l.status==="pending"),Pe=Ae?qt(i):null,et=Ae?bn(i):"",mt=Ae?pl(1):[],Me=mt.length?mt[0]:null,ze=N?Ue(l,z()):"",_e=Ue(l,z())||Ue(l,""),J=N?"Open this AI review queue"+(_e?" and focus "+_e:""):"Open this AI suggestion in review"+(_e?" and focus "+_e:""),$=Kt(n),Oe=N?{index:0,total:0}:Dn($,n),tt=N?[]:We($),B=N?null:Pa(tt,s.__aiActiveSuggestionId,l),K=N?null:gi(tt,s.__aiActiveSuggestionId,l),le=N?null:Xi(l),xe=N?null:Ra(le),I=mi(l),we=N?"":au(n),Q=N?"":na(n),te=we?"Previous AI review item":"No previous AI review item in the current queue",Te=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",Le),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")+(de?" U":"")+(Ae?" Shift+U":"")),t[a].setAttribute("tabindex","0"),t[a].title=Mc({suggestion:l,sharedUpdateCount:G,undoInlineContext:de,redoInlineContext:Pe}));var Se=bi(l,"accept",$)||{text:"Accept",label:"Accept this AI change"},Re=bi(l,"reject",$)||{text:"Reject",label:"Reject this AI change"},Fe=Se.label,ce=Re.label,Lt=W||"Undo the last AI review decision",$e=et||"Redo the last AI review decision",Rt={isPreviewTarget:N,sharedUpdateCount:G,undoInlineContext:de,redoInlineContext:Pe};Jr(V,N?"Open queue":"Review",J),Ta(pe,!we,te),Ta(X,!Q,Te),Jr(j,Se.text,Fe),Jr(oe,Re.text,ce),vi(V,J,Rt),vi(pe,te,Rt),vi(X,Te,Rt),vi(j,Fe,Rt),vi(oe,ce,Rt);var at=bl(t[a],"recovery");if(de?(ee||(ee=document.createElement("button"),ee.type="button",ee.className="rte-ai-inline-preview-button is-undo",ee.setAttribute("data-rte-ai-action","undo"),at&&at.appendChild(ee)),Jr(ee,de.actionLabel,Lt),vi(ee,Lt,Rt)):ee&&ee.parentNode&&(ee.parentNode.removeChild(ee),ee=null),Ae&&Pe?(ue||(ue=document.createElement("button"),ue.type="button",ue.className="rte-ai-inline-preview-button is-redo",ue.setAttribute("data-rte-ai-action","redo"),at&&at.appendChild(ue)),Jr(ue,Pe.actionLabel,$e),vi(ue,$e,Rt)):ue&&ue.parentNode&&(ue.parentNode.removeChild(ue),ue=null),!u){u=document.createElement("span"),u.className="rte-ai-inline-preview-current";var gr=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-actions"):null;gr&&gr.nextSibling?t[a].insertBefore(u,gr.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"),Le?(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=ne("aiu_queueopened","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 sr=F||u;sr&&sr.nextSibling?t[a].insertBefore(M,sr.nextSibling):t[a].appendChild(M)}M.textContent=ne("aiu_focus","Focus {0}",Rr(ze)||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&&Xe(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=De(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 _t=p||u;_t&&_t.nextSibling?t[a].insertBefore(m,_t.nextSibling):t[a].appendChild(m)}m.textContent=ut(l.language),m.setAttribute("aria-label","AI suggestion language")}else m&&m.parentNode&&m.parentNode.removeChild(m);var qe=Kr(l);if(qe){if(!w){w=document.createElement("span"),w.className="rte-ai-inline-preview-scope";var Ie=m||p||u;Ie&&Ie.nextSibling?t[a].insertBefore(w,Ie.nextSibling):t[a].appendChild(w)}w.textContent=qe,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 Wt=bl(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"),Wt&&Wt.appendChild(Y)),Y.textContent=ne("aiu_gotit","Got it"),Y.setAttribute("aria-label",ne("aiu_clearshared","Clear shared AI review update notice")),Y.title=ne("aiu_clearshared","Clear shared AI review update notice"),vi(Y,"Clear shared AI review update notice",Rt)):Y&&Y.parentNode&&(Y.parentNode.removeChild(Y),Y=null),Ns(t[a],"recovery",!!(de||Ae&&Pe||G)),yl(t[a],{suggestion:l,isPreviewTarget:N,sharedUpdateCount:G,undoInlineContext:de,redoInlineContext:Pe,queueTransitionData:K,undoInlineSummaryText:W,redoInlineSummaryText:et}),Al(t[a],{suggestion:l,isPreviewTarget:N,sharedUpdateCount:G,undoInlineContext:de,redoInlineContext:Pe,queueTransitionData:K,undoInlineSummaryText:W,redoInlineSummaryText:et}),Js(t[a],{suggestion:l,isPreviewTarget:N,sharedUpdateCount:G,undoInlineContext:de,redoInlineContext:Pe}),Oe.total&&Oe.index){if(!v){v=document.createElement("span"),v.className="rte-ai-inline-preview-queue";var bt=y||w||m||p||u||(t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-current"):null);if(bt&&bt.nextSibling)t[a].insertBefore(v,bt.nextSibling);else if(bt)t[a].appendChild(v);else{var wt=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-actions"):null;wt&&wt.nextSibling?t[a].insertBefore(v,wt.nextSibling):t[a].appendChild(v)}}v.textContent=ne("aiu_itemof","Item {0} of {1}",Oe.index,Oe.total),v.setAttribute("aria-label",ne("aiu_queuepos","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 ji=v||y||w||m||p||u;ji&&ji.nextSibling?t[a].insertBefore(h,ji.nextSibling):t[a].appendChild(h)}if(h.textContent=K.statusLabel+" - "+K.queueLabel,h.setAttribute("aria-label",K.title+". "+K.detail+" "+Br(K)),K.followupTitle){if(!_){_=document.createElement("span"),_.className="rte-ai-inline-preview-followup";var or=h||v||y||w||m||p||u;or&&or.nextSibling?t[a].insertBefore(_,or.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(de){if(!R){R=document.createElement("span"),R.className="rte-ai-inline-preview-undo";var ei=_||h||v||y||w||m||p||u;ei&&ei.nextSibling?t[a].insertBefore(R,ei.nextSibling):t[a].appendChild(R)}R.textContent=de.actionLabel,R.setAttribute("aria-label",W)}else R&&R.parentNode&&R.parentNode.removeChild(R);if(Ce){if(!C){C=document.createElement("span"),C.className="rte-ai-inline-preview-undo-next";var Qe=R||v||y||w||m||p||u;Qe&&Qe.nextSibling?t[a].insertBefore(C,Qe.nextSibling):t[a].appendChild(C)}C.textContent=ne("aiu_then","Then {0}",Rr(Ce.label)||Ce.label),C.setAttribute("aria-label","Undo after this: "+Ce.detail)}else C&&C.parentNode&&C.parentNode.removeChild(C);if(Ae&&Pe){if(!P){P=document.createElement("span"),P.className="rte-ai-inline-preview-redo";var qr=C||R||v||y||w||m||p||u;qr&&qr.nextSibling?t[a].insertBefore(P,qr.nextSibling):t[a].appendChild(P)}P.textContent=Pe.actionLabel,P.setAttribute("aria-label",et)}else P&&P.parentNode&&P.parentNode.removeChild(P);if(Me){if(!S){S=document.createElement("span"),S.className="rte-ai-inline-preview-redo-next";var Bt=P||C||R||v||y||w||m||p||u;Bt&&Bt.nextSibling?t[a].insertBefore(S,Bt.nextSibling):t[a].appendChild(S)}S.textContent=ne("aiu_then","Then {0}",Rr(Me.label)||Me.label),S.setAttribute("aria-label","Redo after this: "+Me.detail)}else S&&S.parentNode&&S.parentNode.removeChild(S);if(N){if(!D){D=document.createElement("span"),D.className="rte-ai-inline-preview-shortcuts";var ur=S||P||C||R||v||y||w||m||p||u;ur&&ur.nextSibling?t[a].insertBefore(D,ur.nextSibling):t[a].appendChild(D)}D.textContent=an(l),D.setAttribute("aria-label",ne("aiu_previewshortcut","Inline queue preview shortcut"))}else if(!D){D=document.createElement("span"),D.className="rte-ai-inline-preview-shortcuts";var ti=S||P||C||R||v||y||w||m||p||u;ti&&ti.nextSibling?t[a].insertBefore(D,ti.nextSibling):t[a].appendChild(D)}var nt={isPreviewTarget:N,sharedUpdateCount:G,undoInlineContext:de,redoInlineContext:Pe,suggestion:l},jt=Vi(nt);D.id=jc(t[a]),Wi(D,N?"preview":"wrapper",nt),Oc(t[a],D,nt),di(V,t[a],D,"review",nt),di(pe,t[a],D,"previous",nt),di(X,t[a],D,"next",nt),di(j,t[a],D,"accept",nt),di(oe,t[a],D,"reject",nt),di(ee,t[a],D,"undo",nt),di(ue,t[a],D,"redo",nt),di(Y,t[a],D,"shared-seen",nt);var mr=t[a].ownerDocument?t[a].ownerDocument.activeElement:null,yi=mr&&t[a].contains(mr)&&mr.getAttribute&&mr.getAttribute("data-rte-ai-action")||"";Wi(D,N?"preview":yi||"wrapper",nt),Xs(t[a],l),Sl(t[a],l),Ll(t[a],xe),H=xl(t[a],H,l),x=Vs(t[a],x,l),D=Tl(t[a],D),t[a].setAttribute("aria-label",tl(l,{isCurrent:!N,isPreviewTarget:N,queueOpened:Le,glanceLabels:le?le.pills.map(function(Ar){return Ar.text}):[],glanceDetail:le?le.detail:"",compareLabel:"Proposed edit. Current and suggested text.",reasonText:I,focusLabel:jt,positionLabel:Oe.total&&Oe.index?"Item "+Oe.index+" of "+Oe.total:"",transitionLabel:K?K.statusLabel+". "+K.queueLabel+". "+Br(K):"",followupLabel:K&&K.followupTitle?K.followupTitle+". "+K.followupDetail:"",remoteUpdateCount:G,undoLabel:W,undoNextLabel:Ce?"Undo after this: "+Ce.detail:"",redoLabel:et,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,Fs(t[a]),Sl(t[a],l),Ll(t[a],xe),H=xl(t[a],H,l),x=Vs(t[a],x,l),t[a].setAttribute("aria-label",tl(l,{remoteUpdateCount:G,glanceLabels:le?le.pills.map(function(Ar){return Ar.text}):[],glanceDetail:le?le.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+". "+Br(K):"",followupLabel:K&&K.followupTitle?K.followupTitle+". "+K.followupDetail:""}));var _r=Kt(n),Mt=bi(l,"accept",_r)||{text:"Accept",label:"Accept this AI change"},ri=bi(l,"reject",_r)||{text:"Reject",label:"Reject this AI change"};if(Jr(V,"Review",J),Ta(pe,!we,te),Ta(X,!Q,Te),K&&/queue state/i.test(K.previewLabel||"")&&Ta(X,!0,"No next AI review item in the current queue"),Jr(j,Mt.text,Mt.label),Jr(oe,ri.text,ri.label),pi(V),pi(pe),pi(X),pi(j),pi(oe),pi(ee),pi(ue),pi(Y),fi(V),fi(pe),fi(X),fi(j),fi(oe),fi(ee),fi(ue),fi(Y),ee&&ee.parentNode&&ee.parentNode.removeChild(ee),ue&&ue.parentNode&&ue.parentNode.removeChild(ue),Y&&Y.parentNode&&Y.parentNode.removeChild(Y),Ns(t[a],"recovery",!1),yl(t[a],{suggestion:l,isPreviewTarget:N,sharedUpdateCount:G,queueTransitionData:K}),Al(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 Ir=y||w||m||p||u;Ir&&Ir.nextSibling?t[a].insertBefore(M,Ir.nextSibling):t[a].appendChild(M)}M.textContent=ne("aiu_focus","Focus {0}",Rr(_e)||_e),M.setAttribute("aria-label","Review opens on "+_e)}else M&&M.parentNode&&(M.parentNode.removeChild(M),M=null);if(!N&&le&&le.pills&&le.pills.length){if(!b){b=document.createElement("span"),b.className="rte-ai-inline-preview-glance";var Mr=w||p||u;Mr&&Mr.nextSibling?t[a].insertBefore(b,Mr.nextSibling):t[a].appendChild(b)}for(;b.firstChild;)b.removeChild(b.firstChild);for(var Ot=0;Ot<le.pills.length;Ot++){var dt=le.pills[Ot];!dt||!dt.text||dt.kind==="scope"||o(b,"span","","rte-ai-review-item-glance-pill is-"+dt.kind,dt.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 Xt=M||y||b||w||m||p||u;Xt&&Xt.nextSibling?t[a].insertBefore(v,Xt.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 ii=v||M||y||b||w||m||p||u;ii&&ii.nextSibling?t[a].insertBefore(h,ii.nextSibling):t[a].appendChild(h)}if(h.textContent=K.statusLabel,h.setAttribute("aria-label",K.title+". "+K.detail+" "+Br(K)),K.followupTitle){if(!_){_=document.createElement("span"),_.className="rte-ai-inline-preview-followup";var cr=h||v||M||y||w||m||p||u;cr&&cr.nextSibling?t[a].insertBefore(_,cr.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),S&&S.parentNode&&S.parentNode.removeChild(S),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)),Wi(D,"wrapper",{suggestion:l,isPreviewTarget:N,sharedUpdateCount:G}),D=Tl(t[a],D));var ft=!0,br=[p,w,v,h,_,b,M,y];N&&br.push(u,d,F);for(var Hr=0;Hr<br.length;Hr++)br[Hr]&&br[Hr].style&&(br[Hr].style.display=ft?"none":"");var wr=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-compare"):null,yr=t[a].querySelector?t[a].querySelector(".rte-ai-inline-preview-actions"):null;t[a].style&&(t[a].style.display=ft?"flex":"",t[a].style.flexDirection=ft?"column":"",t[a].style.cursor=N?"pointer":""),wr&&wr.style&&(wr.style.order=ft?"1":""),yr&&yr.style&&(yr.style.order=ft?"2":"",yr.style.display=N?"none":"")}return!0}function Jr(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=zt(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 an(e.suggestion);var t=zt(e.suggestion),r=Vi(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=zt(e.suggestion),r=Vi(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 ml(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||gl(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 Vi(e){e=e||{};var t=e.suggestion;if(!t)return"Review";if(e.isPreviewTarget)return"Open queue";var r=zt(t),i=ml(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 an(t.suggestion);var r="",i=zt(t.suggestion),a=i.acceptLabel,n=i.rejectLabel,l=t.reviewFocusLabel||Ue(t.suggestion,z())||Ue(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 An(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 _l(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 Wi(e,t,r){return e?(r=r||{},e.classList.remove("is-action"),e.classList.toggle("is-preview",t==="preview"),t==="preview"?(_l(e,"Queue shortcut",an(r.suggestion)),e.setAttribute("aria-label",ne("aiu_previewshortcut","Inline queue preview shortcut")),!0):t&&t!=="wrapper"?(e.classList.add("is-action"),_l(e,"Keyboard guide",Dc(t,r)),e.setAttribute("aria-label",ne("aiu_actionshortcuts","Inline AI review action shortcuts")),!0):(_l(e,"Keyboard guide",Us(r)),e.setAttribute("aria-label",ne("aiu_reviewshortcuts","Inline AI review shortcuts")),!0)):!1}function Oc(e,t,r){return e?(An(e,t),e.onfocus=function(){An(e,t),Wi(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)||Wi(a,n.isPreviewTarget?"preview":"wrapper",n)},0)},!0):!1}function di(e,t,r,i,a){return e?(An(e,r),e.onfocus=function(){An(e,r),Wi(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 Ta(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 Ye(e,t){t=t||{},s.__aiActiveSuggestionId=e||null,s.__aiPreviewState=e?be(e):null,t.preserveEmptyPreview?s.__aiReviewEmptyPreviewSuggestionId=s.__aiActiveSuggestionId:s.__aiReviewEmptyPreviewSuggestionId=null,Ji()}function hi(){return s.__aiActiveSuggestionId?be(s.__aiActiveSuggestionId):s.__aiPreviewState||null}function Sa(){for(var e=Ke(),t=!1,r=!1,i=0;i<e.length;i++)e[i].status==="pending"&&!Cr(e[i].id)&&(e[i].status="stale",e[i].decidedAt=e[i].decidedAt||new Date().getTime(),zi("suggestion-stale",e[i]),r=!0),s.__aiActiveSuggestionId&&e[i].id===s.__aiActiveSuggestionId&&e[i].status==="pending"&&(t=!0);t||Ye(null),r&&At()}function vr(){Sa()}function Ze(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 La(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 xn(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="'+he(t)+'" data-rte-ai-inline-action-group-current="false"'+i+' role="group" aria-label="'+he(t)+' actions"><span class="rte-ai-inline-preview-action-group-header"><span class="rte-ai-inline-preview-action-group-title">'+he(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 bl(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(ml(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=Kt(r.id);i=gi(We(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=Vi(e),a=Gc(r);if(!r||!i||!a)return null;var n=e.queueTransitionData||null;if(!n&&t.id){var l=Kt(t.id),u=We(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 wl(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),ve(t)}function Fc(e){var t=$s({suggestion:e});if(!t)return"";var r='<span class="rte-ai-inline-preview-action-summary" aria-label="'+he(wl(t))+'"><span class="rte-ai-inline-preview-action-summary-title">'+he(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">'+he(t.pills[i])+"</span>");r+="</span>"}return t.detail&&(r+='<span class="rte-ai-inline-preview-action-summary-detail">'+he(t.detail)+"</span>"),r+="</span>",r}function yl(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",wl(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. "+wl(i)),a}function Al(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":Vi(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=ve([C,R])),x&&l&&(C=ve([C,"Current lane",l])),m.setAttribute("aria-label",C)}}if(i&&d.length){d.sort(function(S,D){var F=S.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=ml(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",ve([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=ve([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=bl(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 xl(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=ne("air_why","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 Tl(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 Ra(e){var t=e&&e.pills?e:Xi(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 Ll(e,t){if(!e)return null;var r=e.querySelector?e.querySelector(".rte-ai-inline-preview-compare"):null,i=Ra(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="'+he(r)+' text"><span class="rte-ai-inline-preview-compare-label">'+he(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?Kt(e.id):"",i=e.id?We(r):[],a=e.id?Pa(i,s.__aiActiveSuggestionId,e):null,n=e.id?Vt(e.id):0,l=t?Ue(e,z())||Ue(e,""):Vi({suggestion:e}),u=e.suggestionType&&Xe(e.suggestionType)!=="other"?De(e.suggestionType):"",d=e.language?ut(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:(Kr(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=Kt(e.id),r=We(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:Br(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">'+he(e.previewLabel)+":</span>"),e.previewText&&(t+='<span class="rte-ai-inline-preview-plan-preview-text">'+he(e.previewText)+"</span>"),!e.previewLabel&&!e.previewText&&e.preview&&(t+=he(e.preview)),t+="</span>",t}function zc(e,t,r,i){var a=e||"span",n=Bs(i),l=Ys(i),u=Ra(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">'+he(l.statusLabel)+"</span>"+(l.openedLabel?'<span class="rte-ai-inline-preview-compare-pill is-opened">'+he(l.openedLabel)+"</span>":"")+(l.remoteLabel?'<span class="rte-ai-inline-preview-compare-pill is-remote">'+he(l.remoteLabel)+"</span>":"")+(l.entryLabel?'<span class="rte-ai-inline-preview-compare-pill is-entry">'+he(l.entryLabel)+"</span>":"")+(l.queueRoleLabel?'<span class="rte-ai-inline-preview-compare-pill is-queue">'+he(l.queueRoleLabel)+"</span>":"")+(l.queueLabel?'<span class="rte-ai-inline-preview-compare-pill is-position">'+he(l.queueLabel)+"</span>":"")+(l.typeLabel?'<span class="rte-ai-inline-preview-compare-pill is-type">'+he(l.typeLabel)+"</span>":"")+(l.languageLabel?'<span class="rte-ai-inline-preview-compare-pill is-language">'+he(l.languageLabel)+"</span>":"")+'<span class="rte-ai-inline-preview-compare-pill is-scope">'+he(l.scopeLabel)+'</span><span class="rte-ai-inline-preview-compare-pill is-steps">'+he(l.stepLabel)+"</span>"+(l.targetLabel?'<span class="rte-ai-inline-preview-compare-pill is-target">'+he(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">'+he(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-'+he(v.kind||"other")+'">'+he(v.text)+"</span>")}w+="</span>"}u.detail&&(w+='<span class="rte-ai-inline-preview-compare-glance-detail">'+he(u.detail)+"</span>"),w+="</span>"}var h=d?'<span class="rte-ai-inline-preview-reason" aria-label="Why this suggestion: '+he(d)+'" title="'+he(d)+'"><span class="rte-ai-inline-preview-reason-label">Why</span><span class="rte-ai-inline-preview-reason-copy">'+he(d)+"</span></span>":"",_="";if(p){_='<span class="rte-ai-inline-preview-plan"><span class="rte-ai-inline-preview-plan-title">'+he(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">'+he(p.items[b])+"</span>");_+="</span>",p.detail&&(_+='<span class="rte-ai-inline-preview-plan-detail">'+he(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">'+he(p.followupTitle)+"</span>"),p.followupDetail&&(_+='<span class="rte-ai-inline-preview-plan-followup-detail">'+he(p.followupDetail)+"</span>"),_+="</span>"),_+="</span>"}return"<"+a+' class="rte-ai-inline-preview-compare" aria-label="'+he(n.title+". "+n.detail)+'"><span class="rte-ai-inline-preview-compare-header"><span class="rte-ai-inline-preview-compare-title">'+he(n.title)+'</span><span class="rte-ai-inline-preview-compare-detail">'+he(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 Rl(e){Qc();var t=!!e.isBlock,r=t?"div":"span",i=t?"div":"span",a=e.originalHtml||Qr(e.originalText||""),n=e.resultHtml||Qr(e.resultText||""),l=xn("review","Open",'<button type="button" class="rte-ai-inline-preview-button is-review" data-rte-ai-action="review">Review</button>'),u=xn("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=xn("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=xn("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||ct();if(!i||!i.hasSelection)return!1;vr();var a=nc(i.html),n={id:"ai-preview-"+new Date().getTime(),snapshot:i,originalHtml:i.html,originalText:i.text,resultText:r,resultHtml:a?on(r):Qr(r),reason:t.reason||"",suggestionType:Xe(t.suggestionType||""),language:t.language||"",isBlock:a,status:"pending",createdAt:new Date().getTime(),sourceLabel:t.sourceLabel||fs(t.suggestionType||"",i,t.language||"")};if(Ke().push(n),Ye(n.id),!sn(i,!1)){var l=Ke();return l.splice(l.length-1,1),Ye(null),!1}return s.__aiBindInlinePreviewEventHandlers&&s.__aiBindInlinePreviewEventHandlers(),s.insertHTML(Rl(n)),Gu(),At(),zi("suggestion-created",n),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&me(!1),s.focus(),!0}function $c(e,t){var r=E(e);if(!r)return!1;t=t||{};var i=t.snapshot||ct();return vr(),sn(i,!0)||s.focus(),s.insertHTML('<span class="rte-comment-marker" data-comment="'+$r(r)+'" data-rte-comment="'+$r(r)+'" contenteditable="false" style="background:#fff9c4;border:1px solid #f9a825;border-radius:3px;padding:1px 6px;font-size:11px;color:#f57f17;cursor:pointer;" title="'+$r(r)+'" aria-label="'+$r(r)+'">💬 AI Comment</span>'),Sa(),At(),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&me(!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=__RTE_TT(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=__RTE_TT('<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=rl(),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=__RTE_TT(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||ct(),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=Ca(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||ct(),i=ps(e)||{id:e,target:"document"};return i.target==="chat-panel"&&!t.forceResolve?(ta({focusComposer:!0}),Promise.resolve(!0)):i.target==="review-panel"&&!t.forceResolve?(Fn({focusPanel:!0}),Promise.resolve(!0)):i.target==="dialog"&&!t.forceResolve?(oa({presetMode:i.resolverMode||"",useDocument:t.useDocument===!0||!r.hasSelection,autoRun:!!i.autoRun}),Promise.resolve(!0)):ln(e,{snapshot:r,source:t.source,prompt:t.prompt,scope:t.scope}).then(function(a){return pr(a,{snapshot:r,fallbackAction:i})}).catch(function(a){return console.error("AI Toolkit action failed",a),!1})}function pr(e,t){t=t||{};var r=t.snapshot||ct();return e&&e.operations&&e.operations.length?Ca(e.operations,{snapshot:r,resolved:e}):Ca([gt(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 je(L.text_aitoolkitlocked||"This document is read-only, so the AI result was not applied."),!1}function Ca(e,t){t=t||{};for(var r=t.snapshot||ct(),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||ct(),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 ta({focusComposer:!0}),!0;case"open-review-panel":return Fn({focusPanel:!0}),!0;case"open-dialog":return oa({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:""}):(oa({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 Tn(e.text,{mode:"insert",snapshot:r});case"replace-selection":return Tn(e.text,{mode:"selection",snapshot:r});case"replace-document":return Tn(e.text,{mode:"document",snapshot:r});default:return!1}}function ka(){vr();var e=arguments.length?be(arguments[0]):hi();if(!e)return!1;var t=Cr(e.id);return t?(t.outerHTML=__RTE_TT(gn(e,"accepted")),e.status="accepted",e.decidedAt=new Date().getTime(),fl(e,"accepted"),ya(e.id),s.__aiRecentlyOpenedQueueSuggestionId===e.id&&Bi({skipUpdate:!0,skipRender:!0}),Ye(null),je(Wr(e,"Accepted")),At(),zi("suggestion-accepted",e),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&me(!1),s.focus(),!0):(e.status="stale",e.decidedAt=e.decidedAt||new Date().getTime(),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&me(!1),Ye(null),At(),!1)}function Ea(){vr();var e=arguments.length?be(arguments[0]):hi();if(!e)return!1;var t=Cr(e.id);return t?(t.outerHTML=__RTE_TT(gn(e,"rejected")),e.status="rejected",e.decidedAt=new Date().getTime(),fl(e,"rejected"),ya(e.id),s.__aiRecentlyOpenedQueueSuggestionId===e.id&&Bi({skipUpdate:!0,skipRender:!0}),Ye(null),je(Wr(e,"Rejected")),At(),zi("suggestion-rejected",e),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&me(!1),s.focus(),!0):(e.status="stale",e.decidedAt=e.decidedAt||new Date().getTime(),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&me(!1),Ye(null),At(),!1)}function Er(e){e=e||{},vr();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=__RTE_TT(Rl(r)),Ht().showResolved=!1,Ec(r,t.status),Hs(),Ye(r.id),je(Wr(r,"Reopened")),At(),zi("suggestion-reopened",r),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&me(!!e.focusPanel,{focusAction:e.focusAction||""});var a=!1;return e.focusInlineAction&&(a=yn(r.id,e.focusInlineAction)),!e.focusPanel&&!a&&s.focus(),!0}function Vr(e){e=e||{},vr();var t=kr();if(!t)return!1;var r=t.suggestion,i=t.wrapper,a=s.__aiActiveSuggestionId===r.id?na(r.id):"";if(!i||!i.parentNode)return Ds(),!1;if(i.outerHTML=__RTE_TT(gn(r,t.status)),r.status=t.status,r.decidedAt=new Date().getTime(),Ht().showResolved=!1,Ds(),fl(r,t.status,{clearRedo:!1}),ya(r.id),s.__aiRecentlyOpenedQueueSuggestionId===r.id&&Bi({skipUpdate:!0,skipRender:!0}),Ye(null),je(Wr(r,t.status==="accepted"?"Accepted again":"Rejected again")),At(),zi(t.status==="accepted"?"suggestion-accepted":"suggestion-rejected",r),a){var n=wi(a,{focusPanel:!!e.focusPanel,focusAction:e.focusAction||"accept"});return n&&e.focusInlineAction&&yn(a,e.focusInlineAction),n}return s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&me(!!e.focusPanel,{focusAction:e.focusAction||"accept"}),e.focusPanel||s.focus(),!0}function Tn(e,t){if(ro())return io();var r=E(e);if(!r)return!1;vr(),t=t||{};var i=t.mode||"document",a=t.snapshot||ct();return i==="document"?(s.setHTMLCode(on(r),{undoable:!0}),Sa(),At(),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&me(!1),s.focus(),!0):i==="selection"?(sn(a,!1)||s.focus(),s.insertText(r),Sa(),At(),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&me(!1),s.focus(),!0):(sn(a,!0)||s.focus(),s.insertHTML("<p><br/></p>"+on(r)),Sa(),At(),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&me(!1),s.focus(),!0)}function Cl(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 Ei(){var e=s.getEditable?s.getEditable():null,t=Cl(e);if(t)return t;var r=e&&e.ownerDocument&&e.ownerDocument.defaultView?e.ownerDocument.defaultView.frameElement:null;if(t=Cl(r),t)return t;if(s.iframe){if(t=Cl(s.iframe),t)return t;if(s.iframe.parentNode)return s.iframe.parentNode}return e&&e.parentNode?e.parentNode:null}function Bc(){var e=Ei();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 Wr(e,t,r){if(!e)return t||"";r=r||{};var i=[],a=Xe(e.suggestionType||"")!=="other"?De(e.suggestionType):"AI suggestion";i.push(a);var n=Kr(e);n&&i.push(n),e.language&&i.push(ut(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=ba(e),i=r===1?"1 pending item":r+" pending items",a=Xe(e.suggestionType||"")!=="other"?De(e.suggestionType):"AI",n=Ue(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+" "+Wr(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(La(e.status)),e.suggestionType&&Xe(e.suggestionType)!=="other"?r.push(De(e.suggestionType)):r.push("AI suggestion");var i=Kr(e);i&&r.push(i),e.language&&r.push(ut(e.language)),t.remoteUpdateCount&&r.push(t.remoteUpdateCount>1?t.remoteUpdateCount+" shared updates":"Shared update");var a=Ze(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),ve(r)}function Pa(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:xt(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:xt(Math.max(1,l.length-d-2),"item")}:m==="earlier"?{key:"earlier",label:"Earlier in queue",detail:"Pending suggestions before the current focus.",countLabel:xt(Math.max(1,d),"item")}:{key:"pending",label:"Pending items",detail:"Remaining AI suggestions in this queue.",countLabel:xt(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&&Xe(p.suggestionType)!=="other"?De(p.suggestionType):"",scopeLabel:Kr(p),detail:"Accepting or rejecting this item moves review straight to the next pending suggestion.",previewLabel:"Next item",previewText:Ze(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 Br(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=Br(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,Ji(),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&me(!1),e?(s.__aiQueueOpenedTimer=setTimeout(function(){s.__aiRecentlyOpenedQueueSuggestionId===e&&(s.__aiRecentlyOpenedQueueSuggestionId=null,Ji(),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&me(!1)),s.__aiQueueOpenedTimer=null},1800),!0):!1}function Bi(e){e=e||{};var t=!!s.__aiRecentlyOpenedQueueSuggestionId;return s.__aiQueueOpenedTimer&&(clearTimeout(s.__aiQueueOpenedTimer),s.__aiQueueOpenedTimer=null),s.__aiRecentlyOpenedQueueSuggestionId=null,t?(e.skipUpdate||Ji(),!e.skipRender&&s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&me(!1),!0):!1}function rr(e,t){var r=be(e),i=Kt(e),a=i&&i!=="all"?De(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+" "+Wr(r,"Still reviewing"):n}function Sn(e,t){var r=be(t),i=r?Wr(r,e):(e||"Updated")+" AI suggestion.";return i+" Review queue complete."}function mi(e){return!e||!e.reason?"":Ze(e.reason,110)}function Zc(e){if(!e)return"";var t=Ze(e.resultText||"",96),r=Ze(e.originalText||"",96);return!t||t===r?"":t}function so(e){if(!e)return"";switch(Xe(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=Xe(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 xt(e,t){return e+" "+t+(e===1?"":"s")}function Xi(e){if(!e)return null;var t=[],r=so(e),i=oo(e),a=Kr(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 "+xt(l,"word")+" across "+xt(d,"sentence")+".":u===d?p="Moves from "+xt(n,"word")+" to "+xt(l,"word")+" across "+xt(d,"sentence")+".":p="Moves from "+xt(n,"word")+" across "+xt(u,"sentence")+" to "+xt(l,"word")+" across "+xt(d,"sentence")+".":n&&l?p="Moves from "+xt(n,"word")+" to "+xt(l,"word")+".":u&&d&&(p="Moves from "+xt(u,"sentence")+" to "+xt(d,"sentence")+"."),!t.length&&!p?null:{title:"Change at a glance",pills:t,detail:p}}function Ln(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 Rn(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 Cn(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=Ue(t,z(r))||Ue(t,"")||"Locate";a.innerText=l,n&&(n.innerText=ne("aiu_reopenhint","Press Enter to reopen this suggestion and land on {0}.",Rr(l)||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=ne("aiu_morekeys","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")),Kl(l,a),zl(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 kl(e,t){if(!e)return[];t=t||{};var r=t.sharedUpdateCount||0,i=[];i.push({kind:"status",text:e.status==="pending"?"Ready to review":La(e.status)}),r&&i.push({kind:"remote",text:r>1?r+" shared updates":"Shared update"}),e.suggestionType&&Xe(e.suggestionType)!=="other"&&i.push({kind:"type",text:De(e.suggestionType)}),e.language&&i.push({kind:"language",text:ut(e.language)});var a=Kr(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||Ze(e.originalText||"",72)||"Original selection unavailable.",a=t.resultText||Ze(e.resultText||"",72)||"Suggested text unavailable.",n=t.previewMetaData||kl(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=Ue(e,t.preferredAction||z(t.panel))||Ue(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(Br(t.queueTransitionData)),t.queueTransitionData.followupTitle&&r.push(t.queueTransitionData.followupTitle),t.queueTransitionData.followupDetail&&r.push(t.queueTransitionData.followupDetail)),ve(r)}function po(e,t,r){if(!(!e||!t||!e.setAttribute)){var i=z(r),a=Fl(t),n=We(a);!n.length&&a!=="all"&&(n=We("all"));var l=Pa(n,s.__aiActiveSuggestionId,t),u=gi(n,s.__aiActiveSuggestionId,t),d=Xi(t),p=Vt(t.id),m=Ze(t.originalText||"",72)||"Original selection unavailable.",w=Ze(t.resultText||"",72)||"Suggested text unavailable.",y=rd(t,{panel:r,preferredAction:i,previewMetaData:kl(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 kn(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=be(l);po(n,u,t),Cn(n,u,t),vo(n,u,t),n.title=Nl(u,r)}}}function En(){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=be(a);if(n){var l=Kt(a),u=We(l),d=Pa(u,s.__aiActiveSuggestionId,n),p=gi(u,s.__aiActiveSuggestionId,n),m=Ue(n,z())||Ue(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&&Jr(v,"Review",w);var h=Xi(n),_=Ra(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,S=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=ne("aiu_focus","Focus {0}",Rr(m)||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(!S){S=document.createElement("span"),S.className="rte-ai-inline-preview-glance";var V=C||x||H;V&&V.nextSibling?i.insertBefore(S,V.nextSibling):i.appendChild(S)}for(;S.firstChild;)S.removeChild(S.firstChild);for(var pe=0;pe<h.pills.length;pe++){var X=h.pills[pe];!X||!X.text||X.kind==="scope"||o(S,"span","","rte-ai-review-item-glance-pill is-"+X.kind,X.text)}!S.childNodes.length&&S.parentNode&&(S.parentNode.removeChild(S),S=null)}else S&&S.parentNode&&S.parentNode.removeChild(S);Xs(i,n),Sl(i,n),Ll(i,_),D=xl(i,D,n),F=Tl(i,F),yl(i,{suggestion:n,sharedUpdateCount:Vt(a),queueTransitionData:p}),Al(i,{suggestion:n,sharedUpdateCount:Vt(a)}),i.setAttribute("aria-label",tl(n,{remoteUpdateCount:Vt(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+". "+Br(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=kl(t,i),u=Xi(t),d=Ze(t.originalText||"",72)||"Original selection unavailable.",p=Ze(t.resultText||"",72)||"Suggested text unavailable.",m=mi(t),w=Ln(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"),Rn(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"),Rn(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"),S=0;S<u.pills.length;S++){var D=u.pills[S];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"),Cn(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:Sf(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=ar(x.value,""),P=C?be(C):null,S=P?Ze(P.originalText||P.resultText||"",84):"",D=Zc(P),F=so(P),M=oo(P),V=P?Kr(P):"",pe=P&&P.language?ut(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:Ue(P,d)}),S&&v.push({label:x.label+" next",text:S,typeValue:x.value,suggestionId:C,actionLabel:"Go to "+x.label+" ("+R+")",focusAction:d,pendingCountLabel:R+" pending",changeLabel:F,impactLabel:M,focusActionLabel:Ue(P,d),scopeLabel:V,languageLabel:pe,resultText:D,reasonText:X})}}}var j=De(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:Ue(be(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?De(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+" "+De(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 "+De(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":La(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 nr()?r.replace(/\.$/,"")+". Press U to "+i.shortcutLabel+"."+(lr()?" Press Shift+U to "+a.shortcutLabel+".":""):lr()?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 nr()&&a.push("U "+r.shortcutLabel),lr()&&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")),nr()&&n.push("U "+r.shortcutLabel),lr()&&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 nr()&&(n=n.replace(/\.$/,"")+" U undoes "+i.decisionLabel+" decision."),lr()&&(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 Gn(t)}function je(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 El(){return"chat-"+new Date().getTime().toString(36)+"-"+Math.random().toString(36).slice(2,8)}function Pl(){var e=un();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 nn(E(t[r].text||""),34);for(var i=0;i<t.length;i++)if(t[i]&&E(t[i].text||""))return nn(E(t[i].text||""),34);return"New chat"}function ql(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:Ii(e.messages),messages:_o(e.messages)}}function Il(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=ql(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 Yi(){if(!s.__aiChatSessionStore){var e=null,t=Pl();if(t&&window.localStorage)try{e=JSON.parse(window.localStorage.getItem(t)||"null")}catch{}s.__aiChatSessionStore=Il(e||{})}return s.__aiChatSessionStore}function yo(){var e=Pl();if(s.__aiChatSessionStore=Il(Yi()),e&&window.localStorage)try{window.localStorage.setItem(e,JSON.stringify(s.__aiChatSessionStore))}catch{}return s.__aiChatSessionStore}function Zi(e){if(!e)return!1;var t=Yi(),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(ir(),t>0?t:6),i=[],a=0;a<r.length;a++){var n=ql(r[a]);n&&(n.active=n.id===ir().sessionId,e.includeMessages!==!0&&delete n.messages,i.push(n))}return i}function hd(e,t){t=t||{};var r=xo(ir(),e,t.statusText||"Loaded a recent AI chat.");return r&&Ia()&&It(t.focusComposer!==!1),r}function gd(e){e=e||{};var t=Pl();if(s.__aiChatSessionStore=Il({}),t&&window.localStorage)try{window.localStorage.removeItem(t)}catch{}var r=ir();return r.messages=[],r.draft="",r.busy=!1,r.status=e.statusText||"Cleared AI chat history.",r.sessionVersion=(r.sessionVersion||0)+1,r.sessionId=El(),Yi().activeSessionId=r.sessionId,yo(),Ia()&&It(e.focusComposer===!0),!0}function Ao(e,t){var r=Yi(),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(ql(i[d])),n[i[d].id]=!0);return l}function xo(e,t,r){if(!e||!t)return!1;for(var i=Yi(),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,Zi(e),!0):!1}function ir(){if(!s.__aiChatState){for(var e=ct(),t=Yi(),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:El()})}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=El(),Zi(e))}function qa(){var e=ir(),t=ct(),r=e.scope==="selection"&&t.hasSelection?"selection":"document",i=r==="selection"&&t.text||t.wholeText;return{scope:r,snapshot:t,source:i,summary:nn(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 ea(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 Td(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 Ia(){return!!(s.__aiChatPanel&&s.__aiChatPanel.isConnected)}function ta(e){return e=e||{},Zr(),Ia()||_d(),It(!!e.focusComposer)}function Sd(e){return s.__aiChatPanel&&s.__aiChatPanel.isConnected?(ea({restoreFocus:!0}),!1):ta(e)}function Ml(e){var t=ir(),r=E(e||t.draft);if(!r||t.busy)return!1;var i=qa();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()}),Zi(t),It(!1),ln("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()}),Zi(t),Ia()&&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()}),Zi(t),Ia()&&It(!1))}),!0}function Ma(e,t){if(!e||!e.resolved)return!1;var r=ct(),i=e.resolved,a=Jt(i),n=!1,l={preview:!0,selection:!0};if(l[t]&&!r.hasSelection)return ir().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 ir().status="Select text before applying this selection-based chat suggestion.",It(!1),!1}if(t==="plan")n=pr(i,{snapshot:r});else if(a)if(t==="preview"){var p=zr(a,"selection-preview",i,i.request||null,i.action||null);p&&p.operations&&p.operations[0]&&!p.operations[0].reason&&(p.operations[0].reason=wa(i)),n=pr(p,{snapshot:r})}else t==="selection"?n=pr(zr(a,"selection",i,i.request||null,i.action||null),{snapshot:r}):t==="insert"?n=pr(zr(a,"insert",i,i.request||null,i.action||null),{snapshot:r}):t==="document"&&(n=pr(zr(a,"document",i,i.request||null,i.action||null),{snapshot:r}));return n&&(ir().status=t==="preview"?"Previewed the AI suggestion inline from chat.":"Applied the AI chat suggestion.",It(!1)),n}function To(e){var t=E(e||"");return t?navigator.clipboard&&navigator.clipboard.writeText?navigator.clipboard.writeText(t).then(function(){return!0}).catch(function(){return So(t)}):Promise.resolve(So(t)):Promise.resolve(!1)}function So(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 To(e&&e.text?e.text:"").then(function(t){var r=ir();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 Pi(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?Jt(t):"";return r.length?"Reviewable change":i?"Draft":"Answer"}function Vf(e){if(!e)return"";var t=Pi(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?Jt(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:Ga(t)+" words",paragraphLabel:r>1?r+" paragraphs":"",copy:Ze(t,180)}}function Wf(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),ve(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?Jt(t):"";return r.length?"Reviewable change prepared":i?"Draft prepared":"Answer ready"}function Hl(e){if(!e)return"";var t=Pi(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?Jt(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 ra(e,t){for(var r=e&&e.resolved?e.resolved:null,i=r&&r.operations?r.operations:[],a=r?Jt(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 Ha(e,t){if(!e||!e.resolved)return null;var r=ra(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 ia(e,t){if(!e||!e.resolved)return"";var r=ra(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 Xr(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":Xr(e)}function Co(e,t,r){var i=ra(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 aa(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",ve(d)),e.title=l?n+" - "+l+(u?" Recommended next step.":""):n+(u?" - Recommended next step.":"")}}function Pn(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=ra(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=Pn(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?Jt(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 qn(e,t,r,i){var a={title:"",badge:"",recommended:!1,detail:""};a.title=qd(e,r,t);var n=Pn(t);return n&&e===n&&(a.badge=Xr(t),a.recommended=!!a.badge),a.detail=Pd(e,r,t,i),a}function Dl(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=Pn(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=Pn(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(", ")),ve(r)}function Dd(e,t,r,i){if(!(!e||!e.querySelectorAll)){var a=Xr(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=qn(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 Ze(ko(e),120)}function Da(e){if(!e||!e.resolved)return null;var t=e.resolved.request&&e.resolved.request.mode?Xe(e.resolved.request.mode):"";return Ra({originalText:ko(e),resultText:Jt(e.resolved),suggestionType:t,snapshot:e.snapshot||null,scope:e.scope||""})}function Od(e,t){if(!e||!e.resolved)return null;var r=Ze(Jt(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=ia(e,t),p=Ha(e,t),m=Fd(e,d,t),w=Da(e);return{title:n&&n.title?n.title:"Prepared draft",sourceText:i,resultText:r,reasonText:Ze(wa(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?Ln(i,r):null,changeGlance:w,planLeadTitle:p?"Best next step":"",planLeadLabel:d?Xr(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=Xr(t);return i?{label:i,detail:Co(t,e,r)}:null}function Bf(e){if(!e)return"";var t=[];return e.label&&t.push(e.label),e.detail&&t.push(e.detail),ve(t)}function Fd(e,t,r){if(!e||!e.resolved)return[];var i=ra(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 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 ve(t)}function In(e){var t=E(e||"");return t?t.length<=92?t:t.substring(0,89).replace(/\s+\S*$/,"")+"...":""}function jl(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=jl(e).toLowerCase().replace(/[^a-z0-9]+/g,"-");return t||"starter"}function Eo(e){if(!e||!e.text)return"Custom";var t=jl({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:Pi(r),detail:"Latest user turn",promptText:r.text||""}:null}function Yf(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=Pi(e);n&&i.push(n);var l=Oa(t,r);return l&&i.push(l),e.text&&i.push(e.text),ve(i)}function Zf(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),ve(r)}function Qd(e,t,r){if(!e||typeof t!="number"||!e[t])return"";var i=e[t],a=[],n=Lo(i),l=Rd(qi(e,t)),u=Pi(i),d=Cd(i),p=Oa(e,t),m=Ro(i),w=Hl(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),Mn(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(In(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(In(v.promptText)||v.promptText);var h=Ha(i,r);h&&h.title&&a.push(h.title)}return ve(a)}function ev(e){if(!e)return"";var t=[],r=e.isError?"Conversation issue":e.role==="user"?"User prompt":"Assistant response",i=Ro(e),a=Hl(e);return r&&t.push(r),i&&t.push(i),a&&t.push(a),ve(t)}function qi(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 ja(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 Oa(e,t){var r=ja(e,t);return r?"Exchange "+r:""}function Mn(e,t){var r=ja(e,t),i=Ii(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"||qi(e,t)!=="request")return-1;for(var i=ja(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"&&qi(e,a)==="response"&&ja(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"||qi(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=ia(n,r);u=Xr(m),d=Da(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:Oa(e,t),scopeLabel:Pi(i),statusLabel:n&&n.role==="assistant"&&!n.isError?"Reply linked":"Waiting on reply",actionLabel:u,changeGlance:d,detail:p.join(" "),isCurrent:Mn(e,t)}}function tv(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),ve(t)}function $d(e,t,r){if(!e||typeof t!="number"||!e[t])return"";var i=e[t];if(i.isError||i.role!=="user"||qi(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(In(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"),ve(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"||qi(e,t)!=="response")return null;var a=i.resolved||null,n=a&&a.operations?a.operations:[],l=a?Jt(a):"",u=ia(i,r),d=n.length?n.length:l?1:0,p=Da(i),m=[];p&&p.detail&&m.push(p.detail);var w=(Ha(i,r)||{}).detail||Hl(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:Oa(e,t),scopeLabel:Pi(i),statusLabel:y,stepLabel:d?d+" step"+(d===1?"":"s"):"",actionLabel:Xr(u),changeGlance:p,isCurrent:Mn(e,t)}}function rv(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),ve(t)}function Ga(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 Ol(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=Ii(e&&e.messages?e.messages:[]),n=e&&e.messages?e.messages.length:0;return Nt(i,t&&t.scope==="selection"?"Selection context":"Document context","is-scope"),Nt(i,a+" exchange"+(a===1?"":"s"),"is-exchanges"),Nt(i,n+" message"+(n===1?"":"s"),"is-messages"),Nt(i,"Enter sends","is-send"),r?Nt(i,"Starter: "+(r.label||r.id||"Prompt"),"is-starter"):E(e&&e.draft?e.draft:"")?Nt(i,"Custom prompt","is-custom"):Nt(i,"Ready for a new ask","is-prompt"),Nt(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 ve(t)}function Gl(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 Ii(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 Ua(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=Ii(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=_?Jt(_):"",x=ia(r,i),R=Xr(x),C=Da(r),P=Xd(C),S=Ha(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):S&&S.detail&&v.push(S.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"?Xr(ia(r,i)):"",changeGlance:r.role==="assistant"?Da(r):null,pills:h}}function iv(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 ve(t)}function No(e,t,r){var i=t&&t.scope==="selection"?"selection":"document",a=Ii(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),ve(t)}function Ko(e,t,r){var i=["Conversation"];if(e&&e.messages&&e.messages.length){var a=Ua(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),ve(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),ve(i)}function Zd(e,t){var r=Ua(e,t);return r?r.title:""}function av(e,t){var r=Ua(e,t);return r?r.detail:""}function nv(e,t){var r=Ua(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=Ii(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 Nt(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=Ii(e&&e.messages?e.messages:[]),u=Ua(e,t);return Nt(i,a,"is-scope"),Nt(i,l+" exchange"+(l===1?"":"s"),"is-exchanges"),Nt(i,n+" message"+(n===1?"":"s"),"is-messages"),Nt(i,Ga(t&&t.source?t.source:"")+" words","is-words"),u&&u.actionLabel?Nt(i,u.actionLabel,"is-action"):Nt(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 ve(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 ve(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:Ga(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),ve(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 ve(t)}function Hn(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),ve(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),ve(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=jl(e);l&&i.push(l+" starter");var u=In(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),ve(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",Ga(e.source)):Ga(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),ve(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 ve(t)}function lf(e){if(e)for(;e.firstChild;)e.removeChild(e.firstChild)}function Mi(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 Ul(e,t,r,i){if(e){var a=Ol(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=Gl(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=__RTE_TT(""),v.innerText=l.statusLabel);var h=e.querySelector(".rte-ai-chat-header-status.is-scope");h&&(h.innerHTML=__RTE_TT(""),h.innerText=l.scopeFocusLabel);var _=e.querySelector(".rte-ai-chat-subtitle");_&&(_.innerHTML=__RTE_TT(""),_.innerText=l.subtitle),Mi(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",Hn("selection",n)),n.scopeIsSelection?x[0].classList.add("is-active"):x[0].classList.remove("is-active")),x.length>1&&(x[1].setAttribute("aria-label",Hn("document",n)),n.scopeIsSelection?x[1].classList.remove("is-active"):x[1].classList.add("is-active")),Mi(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=__RTE_TT(""),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=__RTE_TT(""),P.innerText=n.previewTitle),Mi(e.querySelector(".rte-ai-chat-context-preview-meta"),n.previewMetaPills,"rte-ai-chat-context-preview-pill");var S=e.querySelector(".rte-ai-chat-context-preview-copy");S&&(S.innerHTML=__RTE_TT(""),S.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 pe=i[V],X=!!(t.draft&&pe&&pe.prompt&&E(t.draft)===E(pe.prompt));X?M[V].classList.add("is-active"):M[V].classList.remove("is-active"),M[V].setAttribute("aria-label",Xo(pe,X,r))}Mi(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=__RTE_TT(""),j.innerText=p.detail);var oe=e.querySelector(".rte-ai-chat-compose-shell");oe&&oe.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 ue=e.querySelector(".rte-ai-chat-composer-meta");ue&&ue.setAttribute("aria-label",(d.metaPills||[]).map(function(Me){return Me&&Me.text?Me.text:""}).filter(function(Me){return!!Me}).join(". ")),Mi(ue,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=__RTE_TT(""),G.innerText=d.statusLabel);var N=e.querySelector(".rte-ai-chat-status-text");N&&(N.innerHTML=__RTE_TT(""),N.innerText=d.statusText);var Le=e.querySelector(".rte-ai-chat-composer-actions");Le&&Le.setAttribute("aria-label",Uo(w));var de=e.querySelector(".rte-ai-chat-send-button");if(de&&(de.disabled=!!w.disabled,de.setAttribute("aria-label",w.ariaLabel),de.title=w.title,de.classList.toggle("is-busy",!!t.busy),ge(de,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 Ee=e.querySelector(".rte-ai-chat-feed-intro");Ee&&Ee.setAttribute("aria-label",Yd(m));var Ce=e.querySelector(".rte-ai-chat-feed-intro-title");Ce&&(Ce.innerHTML=__RTE_TT(""),Ce.innerText=m.title);var Ae=e.querySelector(".rte-ai-chat-feed-intro-detail");Ae&&(Ae.innerHTML=__RTE_TT(""),Ae.innerText=m.detail),Mi(e.querySelector(".rte-ai-chat-feed-intro-meta"),m.metaPills,"rte-ai-chat-feed-intro-pill");var Pe=e.querySelector(".rte-ai-chat-empty");Pe&&u&&Pe.setAttribute("aria-label",eu(u));var et=e.querySelector(".rte-ai-chat-empty-title");et&&u&&(et.innerHTML=__RTE_TT(""),et.innerText=u.title);var mt=e.querySelector(".rte-ai-chat-empty-detail");mt&&u&&(mt.innerHTML=__RTE_TT(""),mt.innerText=u.detail),Mi(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=ir();if(e&&e.messages&&e.messages.length){It(!1);return}Ul(s.__aiChatPanel,e,qa(),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=Ei();if(!t)return!1;var r=e?null:wd(s.__aiChatPanel),i=e?null:xd(s.__aiChatPanel),a=ir(),n=qa(),l=L.aiToolkitChatPrompts||[],u=Ol(a,l);if(ea({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),ma(p),p.onkeydown=function(I){I.key==="Escape"&&(I.preventDefault(),ea({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=__RTE_TT(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"),ge(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=__RTE_TT('<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(){ea({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 S=o(P,"button","","rte-ai-chat-scope-button is-icon-only"+(R.scopeIsSelection?" is-active":""));S.type="button",S.disabled=!n.snapshot.hasSelection,S.setAttribute("data-rte-ai-chat-scope-target","selection"),S.setAttribute("aria-label",Hn("selection",R)),S.title=c.__aiT?c.__aiT("aic_usesel","Use selection"):"Use selection",ge(S,"cursorText",""),S.onclick=function(){var I=ct();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",Hn("document",R)),D.title=c.__aiT?c.__aiT("aic_usedoc","Use document"):"Use document",ge(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 pe=0;pe<l.length;pe++)(function(I){var we=!!(a.draft&&I.prompt&&E(a.draft)===E(I.prompt)),Q=o(V,"button","","rte-ai-chat-quick-button is-chip"+(we?" 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(pe)),Q.title=I.prompt||"",Q.setAttribute("aria-label",Xo(I,we,n)),ge(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[pe]);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 oe=o(j,"div","","rte-ai-chat-quick-row rte-ai-chat-history-row"),ee=0;ee<X.length;ee++)(function(I,we){var Q=I.id===a.sessionId,te=o(oe,"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")+"."),ge(te,Q?"history":"chat",(we===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 ue=o(p,"div","","rte-ai-chat-stack rte-ai-chat-feed-shell is-minimal");ue.setAttribute("role","group"),ue.setAttribute("aria-label",Ko(a,n,u));var Y=o(ue,"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 Le=document.createElement("div");Le.className="rte-ai-chat-empty-art is-detached",Le.setAttribute("aria-hidden","true");var de=!!(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",de?W+(c.__aiT?c.__aiT("aic_orquick"," \u2014 or tap a quick start above."):" \u2014 or tap a quick start above."):W+".")}for(var Ee=null,Ce=0,Ae=0;Ae<a.messages.length;Ae++){if(0){var Pe,et,mt,Me;for(var ze;ze<Me.length;ze++)var _e}(function(I,we){var Q=qi(a.messages,we),te=ja(a.messages,we),Te=Oa(a.messages,we),Se=Mn(a.messages,we),Re=Y;Q==="request"?(Ee=o(Y,"div","","rte-ai-chat-exchange-group"),Te&&Ee.setAttribute("data-rte-ai-chat-exchange-index",Te),Se&&Ee.setAttribute("data-rte-ai-chat-current-exchange","true"),Ee.setAttribute("role","group"),Ee.setAttribute("aria-label",$d(a.messages,we,n.snapshot)),Ce=te,Re=Ee):Q==="response"&&Ee&&Ce===te?Re=Ee:(Ee=null,Ce=0);var Fe=Io(a.messages,we,n.snapshot);if(0){var ce,Lt;if(Fe.changeGlance&&Fe.changeGlance.pills&&Fe.changeGlance.pills.length)for(var $e;$e<Fe.changeGlance.pills.length;$e++)var Rt}var at=o(Re,"div","","rte-ai-chat-message is-"+I.role+" is-minimal"+(I.isError?" is-error":""));at.setAttribute("role","group"),at.setAttribute("aria-label",Qd(a.messages,we,n.snapshot)),Q&&(at.setAttribute("data-rte-ai-chat-thread-role",Q),at.setAttribute("data-rte-ai-chat-exchange-index",String(te)),Se&&at.setAttribute("data-rte-ai-chat-current-exchange","true"));var gr=o(at,"div","","rte-ai-chat-message-header is-minimal"),sr=I.isError?"error":I.role,_t=o(gr,"span","","rte-ai-chat-message-avatar is-"+sr);if(_t.setAttribute("aria-hidden","true"),_t.innerHTML=__RTE_TT(sr==="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>':sr==="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(gr,"span","","rte-ai-chat-message-role is-"+(I.isError?"error":I.role),Lo(I)),o(at,"div","","rte-ai-chat-message-text",I.text||""),I.role==="assistant"&&!I.isError&&I.text){var qe=o(at,"div","","rte-ai-chat-message-actions-row"),Ie=o(qe,"button","","rte-ai-chat-message-action is-copy");Ie.type="button",Ie.title=c.__aiT?c.__aiT("aic_copymsg","Copy message text"):"Copy message text",ge(Ie,"checkAll",c.__aiT?c.__aiT("aic_copy","Copy"):"Copy"),Ie.onclick=(function(U,rt){return function(ke){ke&&ke.stopPropagation&&ke.stopPropagation();var kt=window.navigator,Gt=!1;try{kt&&kt.clipboard&&kt.clipboard.writeText&&(kt.clipboard.writeText(U),Gt=!0)}catch{}if(!Gt){var Zt=document.createElement("textarea");Zt.value=U,Zt.style.position="fixed",Zt.style.left="-9999px",document.body.appendChild(Zt),Zt.select();try{document.execCommand("copy"),Gt=!0}catch{}document.body.removeChild(Zt)}Gt&&(rt.classList.add("is-just-copied"),ge(rt,"check",c.__aiT?c.__aiT("aic_copied","Copied"):"Copied"),setTimeout(function(){rt.classList.remove("is-just-copied"),ge(rt,"checkAll",c.__aiT?c.__aiT("aic_copy","Copy"):"Copy")},1400))}})(I.text||"",Ie);for(var Wt="",bt=we-1;bt>=0;bt--)if(a.messages[bt]&&a.messages[bt].role==="user"&&!a.messages[bt].isError){Wt=a.messages[bt].text||"";break}if(Wt){var wt=o(qe,"button","","rte-ai-chat-message-action is-regen");wt.type="button",wt.title=c.__aiT?c.__aiT("aic_regen","Regenerate response"):"Regenerate response",ge(wt,"refresh",c.__aiT?c.__aiT("aid_regenerate","Regenerate"):"Regenerate"),wt.onclick=(function(U){return function(rt){rt&&rt.stopPropagation&&rt.stopPropagation(),a.draft=U,Ml(U)}})(Wt)}}if(0){var ji;if(ji)var or,ei,Qe}if(0){var qr;if(qr)var Bt,ur,ti,nt}if(I.role==="assistant"&&I.resolved){var jt=Od(I,n.snapshot);if(0){var mr,yi,_r,Mt,ri;if(jt.reasonText)var Ir;if(jt.changeGlance){var Mr;if(jt.changeGlance.pills&&jt.changeGlance.pills.length){var Ot;for(var dt;dt<jt.changeGlance.pills.length;dt++)var Xt}}if(jt.planLeadTitle||jt.planLeadLabel||jt.planLeadDetail||jt.planItems&&jt.planItems.length){var ii;if(jt.planLeadTitle||jt.planLeadLabel||jt.planLeadDetail){var cr;if(jt.planLeadLabel)var ft}if(jt.planItems&&jt.planItems.length){var br;for(var Hr;Hr<jt.planItems.length;Hr++)var wr,yr,Ar}}}var xr=o(at,"div","","rte-ai-chat-message-actions"),$a=Ha(I,n.snapshot),Dr=jt&&(jt.planLeadTitle||jt.planLeadLabel||jt.planLeadDetail||jt.planItems&&jt.planItems.length);if(0)var Je;var Be=ia(I,n.snapshot),ai=o(xr,"div","","rte-ai-chat-message-action-group is-utility"),Ve=o(xr,"div","","rte-ai-chat-message-action-group is-primary"),jr=o(xr,"div","","rte-ai-chat-message-action-group is-secondary"),Ct=ra(I,n.snapshot),Tr=function(U,rt){!U||!rt||rt!==Be||(U.className+=" is-recommended",U.setAttribute("data-rte-ai-chat-recommended","true"))},Qt=o(ai,"button","","secondary rte-ai-chat-action-button is-copy","Copy text");if(Qt.type="button",Qt.setAttribute("data-rte-ai-chat-action","copy"),Qt.onclick=function(){Ld(I)},aa(Qt,"copy",I,Be,n.snapshot),Ct.canApplyPlan){var Or=o(Ve,"button","","secondary rte-ai-chat-action-button is-apply","Apply");Or.type="button",Or.setAttribute("data-rte-ai-chat-action","apply"),Or.onclick=function(){Ma(I,"plan")},Tr(Or,"apply"),aa(Or,"apply",I,Be,n.snapshot)}if(Ct.canPreview){var lt=o(Ve,"button","","secondary rte-ai-chat-action-button is-preview","Preview");lt.type="button",lt.setAttribute("data-rte-ai-chat-action","preview"),lt.onclick=function(){Ma(I,"preview")},Tr(lt,"preview"),aa(lt,"preview",I,Be,n.snapshot)}if(Ct.canReplaceSelection){var st=o(Ve,"button","","secondary rte-ai-chat-action-button is-selection","Replace selection");st.type="button",st.setAttribute("data-rte-ai-chat-action","selection"),st.onclick=function(){Ma(I,"selection")},Tr(st,"selection"),aa(st,"selection",I,Be,n.snapshot)}if(Ct.canInsert){var $t=o(jr,"button","","secondary rte-ai-chat-action-button is-insert","Insert below");if($t.type="button",$t.setAttribute("data-rte-ai-chat-action","insert"),$t.onclick=function(){Ma(I,"insert")},Tr($t,"insert"),aa($t,"insert",I,Be,n.snapshot),Ct.canReplaceDocument){var Sr=o(jr,"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(){Ma(I,"document")},Tr(Sr,"document"),aa(Sr,"document",I,Be,n.snapshot)}}Dl(ai,qn("utility",Be,I,n.snapshot),"utility"),Dl(Ve,qn("primary",Be,I,n.snapshot),"primary"),Dl(jr,qn("secondary",Be,I,n.snapshot),"secondary"),Id(xr,Be),Md(xr,Be),Dd(xr,Be,I,n.snapshot);var Gr=!!(Ct.canPreview||Ct.canInsert||Ct.canReplaceDocument);if(Gr){var Ai=Ve.children.length?Ve:jr.children.length?jr:ai,Yt=o(Ai,"button","","secondary rte-ai-chat-action-button rte-ai-chat-message-action-toggle-more");Yt.type="button",Yt.setAttribute("data-rte-ai-chat-action","more"),Yt.setAttribute("aria-expanded","false"),Yt.title=c.__aiT?c.__aiT("ai2_moreopts","More apply options"):"More apply options",ge(Yt,"more","More"),Yt.onclick=(function(U){return function(rt){rt&&rt.stopPropagation&&rt.stopPropagation();var ke=U.classList.toggle("is-show-more");Yt.setAttribute("aria-expanded",ke?"true":"false")}})(at)}}if(I.role==="assistant"&&!I.isError){var Nn=Mo(a.messages,we,n.snapshot);if(0){var Ja,ua,Oi;if(Nn.changeGlance&&Nn.changeGlance.pills&&Nn.changeGlance.pills.length)for(var $e;$e<Nn.changeGlance.pills.length;$e++)var Rt}}})(a.messages[Ae],Ae)}var J=Oo(a,n,u),$=Gl(a,n,u),Oe=o(p,"div","","rte-ai-chat-stack rte-ai-chat-compose-shell");Oe.setAttribute("role","group"),Oe.setAttribute("aria-label",Go(J));var tt=o(Oe,"div","","rte-ai-chat-composer"),B=o(tt,"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=""),Ul(p,a,qa(),l)},B.onkeydown=function(I){if(I.key==="Enter"&&!I.shiftKey){I.preventDefault();var we=qa(),Q=Ol(a,l),te=Gl(a,we,Q);if(te.disabled){a.status=te.title,Ul(p,a,we,l);return}Ml(B.value)}};var K=o(tt,"div","","rte-ai-chat-composer-actions");K.setAttribute("role","group"),K.setAttribute("aria-label",Uo($));var le=document.createElement("button");le.type="button",le.className="secondary rte-ai-chat-action-button is-open-dialog is-detached",le.setAttribute("data-rte-ai-chat-action","open-dialog"),ge(le,"external","Open Ask AI"),le.onclick=function(){oa({useDocument:a.scope!=="selection",presetMode:"rewrite"})};var xe=o(K,"button","","rte-ai-chat-send-button"+(a.busy?" is-busy":""));if(xe.type="button",xe.setAttribute("data-rte-ai-chat-action","send"),xe.disabled=!!$.disabled,xe.setAttribute("aria-label",$.ariaLabel),xe.title=$.title,ge(xe,a.busy?"spinner":"send",$.text),xe.onclick=function(){Ml(B.value)},e&&setTimeout(function(){if(B&&B.focus){B.focus();try{B.selectionStart=B.selectionEnd=B.value.length}catch{}}},0),Zi(a),Y&&typeof Y.scrollTop<"u"&&(!i||!Td(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=Ke(),r=0;r<t.length;r++)e.total++,e.hasOwnProperty(t[r].status)&&e[t[r].status]++;return e}function Pr(e,t){return!t||t==="all"?!0:Xe(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=Xe(e[r]&&e[r].suggestionType||"");t[i]||(t[i]=De(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=Xe(e[r].suggestionType||"");t[i]=(t[i]||0)+1}return t}function We(e){for(var t=Ke().slice(),r=[],i=0;i<t.length;i++)t[i].status==="pending"&&Pr(t[i],e)&&r.push(t[i]);return qs(r)}function ar(e,t){var r=We(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=We(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 lv(e,t){var r=ar(e,t);return r?Dt(r):!1}function sv(e,t){var r=_i(e,t);return r?Dt(r):!1}function ov(e,t,r){var i=ar(e,t);return i?wi(i,r||{}):!1}function uv(e,t,r){var i=_i(e,t);return i?wi(i,r||{}):!1}function Kt(e){var t=Ht(),r=t.typeFilter||"all",i=be(e);return i&&r!=="all"&&!Pr(i,r)&&(r=Xe(i.suggestionType||"")),r||"all"}function na(e){var t=Kt(e),r=ar(t,e);return!r&&t!=="all"&&(r=ar("all",e)),r}function au(e){var t=Kt(e),r=_i(t,e);return!r&&t!=="all"&&(r=_i("all",e)),r}function ff(e){var t=Kt(e),r=We(t);return!r.length&&t!=="all"&&(r=We("all")),r.length?r[0].id:""}function vf(e){var t=Kt(e),r=We(t);return!r.length&&t!=="all"&&(r=We("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=na(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 hr(e){var t=hi();return t&&t.status==="pending"&&Pr(t,e)?t.id:ar(e,"")}function Dn(e,t){var r=We(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 Fl(e){var t=Ht(),r=t.typeFilter||"all";return e&&r!=="all"&&!Pr(e,r)&&(r=Xe(e.suggestionType||"")),r||"all"}function bi(e,t,r){if(!e||e.status!=="pending"||t!=="accept"&&t!=="reject")return null;r=r||Fl(e);var i=We(r);!i.length&&r!=="all"&&(i=We("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 zt(e){var t=Ue(e,"accept")||"Accept",r=Ue(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 Hi(e,t,r){if(r=r||{},!e)return!1;var i=!1;return t==="accept"?i=ka(e):t==="reject"&&(i=Ea(e)),i&&me(!0,{focusAction:r.focusAction||""}),i}function jn(e,t,r){var i=hr(e);return i?Hi(i,t,r):!1}function gf(){for(var e=Ke().slice(),t=!1,r=0;r<e.length;r++)e[r].status==="pending"&&ka(e[r].id)&&(t=!0);return t}function su(e){if(!e||e==="all")return gf();for(var t=Ke().slice(),r=!1,i=0;i<t.length;i++)t[i].status==="pending"&&Pr(t[i],e)&&ka(t[i].id)&&(r=!0);return r}function mf(){for(var e=Ke().slice(),t=!1,r=0;r<e.length;r++)e[r].status==="pending"&&Ea(e[r].id)&&(t=!0);return t}function ou(e){if(!e||e==="all")return mf();for(var t=Ke().slice(),r=!1,i=0;i<t.length;i++)t[i].status==="pending"&&Pr(t[i],e)&&Ea(t[i].id)&&(r=!0);return r}function Dt(e,t){t=t||{},vr();var r=be(e),i=r?Cr(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&&me(!1),!1;!t.openedQueue&&s.__aiRecentlyOpenedQueueSuggestionId&&s.__aiRecentlyOpenedQueueSuggestionId!==r.id&&Bi({skipUpdate:!0,skipRender:!0}),Ye(r.id),ya(r.id),t.openedQueue&&lo(r.id);var a=Dn(Kt(r.id),r.id),n={positionLabel:a.total?"Item "+a.index+" of "+a.total:"",remoteUpdateCount:Vt(r.id)};je(t.openedQueue?ao(r,n):Wr(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||xa(i),s.__aiReviewPanel&&s.__aiReviewPanel.isConnected&&me(!1),!0}function wi(e,t){t=t||{};var r=be(e);if(!r)return!1;if(!t.openedQueue&&s.__aiRecentlyOpenedQueueSuggestionId&&s.__aiRecentlyOpenedQueueSuggestionId!==r.id&&Bi({skipUpdate:!0,skipRender:!0}),Ye(r.id),ya(r.id),t.openedQueue&&lo(r.id),t.locate)return Dt(r.id,{openedQueue:!!t.openedQueue});var i=Dn(Kt(r.id),r.id),a={positionLabel:i.total?"Item "+i.index+" of "+i.total:"",remoteUpdateCount:Vt(r.id)};return je(t.openedQueue?ao(r,a):Wr(r,"Reviewing",a)),me(!!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=be(e),n=[];t?n.push(t):n.push(Un(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=be(e);if(!r)return!1;var i=t||Un(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 Tt(e,t){t=t||{};var r=be(e);if(!r)return!1;var i=t.focusAction||z();return wi(r.id,{focusPanel:!!t.focusPanel,focusAction:i||Un(r),openedQueue:!!t.openedQueue,locate:!!t.locate})}function On(e,t,r,i){var a="";if(i==="next")a=ar(e,t);else if(i==="previous")a=_i(e,t);else if(i==="first")a=hr(e);else if(i==="last"){var n=We(e);a=n.length?n[n.length-1].id:""}return a?wi(a,{focusPanel:!0,focusAction:r||""}):!1}function nr(){return!!ci()}function lr(){return!!kr()}function Yr(e){var t=Pt(),r=qt(),i=e;return nr()&&(i=i.replace(/\.$/,"")+". U undoes "+t.decisionLabel+" decision."),lr()&&(i=i.replace(/\.$/,"")+". Shift+U redoes "+r.decisionLabel+" decision."),i}function St(e){var t=Pt(),r=e;return nr()&&(r+=" | U "+t.shortcutLabel),lr()&&(r+=" | Shift+U "+qt().shortcutLabel),r}function Gn(e){var t=e;return nr()&&(t+=" U"),lr()&&(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=zt(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=zt(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 Nl(e,t){var r=zt(e);if(!e||e.status!=="pending")return Yr("Enter focuses Locate. J/K move items. Home/End jump.");var i=Ue(e,t)||r.acceptLabel;return Yr("Enter focuses "+i+". A uses "+r.acceptLabel+". R uses "+r.rejectLabel+". J/K move items. Home/End jump.")}function xf(e,t){var r=zt(e);if(!e||e.status!=="pending")return St("Shortcuts: Enter focus Locate | J/K move | Home/End jump");var i=Ue(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=zt(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 Fa(e,t){if(!e)return"";var r=kr(),i=ci(),a=[];t&&a.push(t),a.push(Un(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 Ue(e,t){var r=Fa(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 Tf(e){e=e||{};var t=e.suggestion||null;if(!t)return null;var r=e.targetActionName||"",i=du(r),a=Ue(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),ve(t)}function Na(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=Fa(i,e||z(t)),l=du(n),u=Fl(i),d=We(u);!d.length&&u!=="all"&&(d=We("all"));var p=gi(d,s.__aiActiveSuggestionId,i),m=i.status==="pending"?ci():null,w=kr(),y=!!(w&&w.suggestion&&w.suggestion.id===i.id&&i.status==="pending"),v={suggestion:i,targetActionName:n,queueTransitionData:p,undoSummaryText:m?Aa(m):"",redoSummaryText:y?bn(w):""},h=Tf(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=Ue(i,n),R=a.querySelectorAll(".rte-ai-review-item-action-group"),C=[],P=0;P<R.length;P++){var S=R[P];if(S){var D=S.getAttribute("data-rte-ai-review-action-group")||(S.classList.contains("is-decision")?"decision":S.classList.contains("is-recovery")?"recovery":S.classList.contains("is-locate")?"locate":"");if(D){var F=S.querySelector?S.querySelector(".rte-ai-review-action-button"):null;if(!F){var M=S.querySelector?S.querySelector(".rte-ai-review-item-action-group-header"):null,V=S.querySelector?S.querySelector(".rte-ai-review-item-action-group-detail"):null;M&&M.parentNode&&M.parentNode.removeChild(M),V&&V.parentNode&&V.parentNode.removeChild(V),S.setAttribute("data-rte-ai-review-action-group-current","false"),S.classList.remove("is-current-lane"),S.removeAttribute("aria-label");continue}C.push(S);var pe=vu(D),X=S.querySelector?S.querySelector(".rte-ai-review-item-action-group-header"):null;X||(X=document.createElement("span"),X.className="rte-ai-review-item-action-group-header",S.firstChild?S.insertBefore(X,S.firstChild):S.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=pe;var oe=X.querySelector?X.querySelector(".rte-ai-review-item-action-group-badge"):null;oe||(oe=document.createElement("span"),oe.className="rte-ai-review-item-action-group-badge",X.appendChild(oe));var ee=S.querySelector?S.querySelector(".rte-ai-review-item-action-group-detail"):null;ee||(ee=document.createElement("span"),ee.className="rte-ai-review-item-action-group-detail",F?S.insertBefore(ee,F):S.appendChild(ee));var ue=!!l&&D===l,Y=hu(D,v);if(S.style.removeProperty("order"),S.setAttribute("data-rte-ai-review-action-group-current",ue?"true":"false"),S.classList.toggle("is-current-lane",ue),ue&&x){var G="Enter: "+x;oe.textContent=G,oe.style.display="",oe.setAttribute("aria-label","Current action lane. "+G)}else oe.textContent="",oe.style.display="none",oe.removeAttribute("aria-label");Y?(ee.textContent=Y,ee.style.display=""):(ee.textContent="",ee.style.display="none");var N=pe?pe+" lane":"";ue&&x&&(N+=(N?". ":"")+"Current action lane. Enter focuses "+x),Y&&(N+=(N?". ":"")+Y),N?S.setAttribute("aria-label",N):S.removeAttribute("aria-label")}}}C.sort(function(de,W){var Ee=de.getAttribute("data-rte-ai-review-action-group")||(de.classList.contains("is-decision")?"decision":de.classList.contains("is-recovery")?"recovery":de.classList.contains("is-locate")?"locate":""),Ce=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(Ee,l)-pu(Ce,l)});for(var Le=0;Le<C.length;Le++)a.appendChild(C[Le]);return!0}function Ka(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=Fa(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",ve([v,"Current Enter target."])),h&&!/current enter target/i.test(h)&&(d.title=ve([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")||"",S=C.getAttribute("data-rte-ai-review-action")||"";return fu(y,P,a)-fu(y,S,a)});for(var b=0;b<_.length;b++)w.appendChild(_[b])}}return!0}function Sf(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",Ue(r,t)}function Lf(e,t){var r=Pt(),i=qt(),a=zt(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=zt(t);return Yr(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(Fa(e,t),e)}function mu(e,t){return Rf(Fa(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=zt(hi());return Yr("Enter activates "+_u(e)+". A uses "+t.acceptLabel+". R uses "+t.rejectLabel+". J/K move items. Home/End jump.")}function Ef(e){var t=zt(hi());return St("Shortcuts: Enter "+_u(e)+" | A "+t.acceptHint+" | R "+t.rejectHint+" | J/K move | Home/End jump")}function Un(e){if(!e)return"";var t=kr();return e.status==="pending"&&t&&t.suggestion&&t.suggestion.id===e.id?"redo":e.status==="pending"?"accept":"locate"}function Kl(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=ne("aiu_shortcuts","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 zl(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=ne("aiq_kbguide","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)),Kl(u,e||""),zl(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 za(e,t){var r=s.__aiReviewShortcutDisplayNode;r&&(Kl(r,e||""),zl(r,t),Pf(e||"",t))}function bu(e){var t=e||"";za(Af(t,hi()),t),Na(t),Ka(t),kn(),En()}function wu(e){var t=z();za(xf(e,t),"card"),Na(t),Ka(t),kn(),En()}function Ql(e,t){var r=t||z();za(Cf(e,r),"panel"),Na(r),Ka(r),kn(),En()}function qf(e){za(Ef(e),"control"),Na(z()),Ka(z()),kn(),En()}function yu(){return s.__aiReviewShortcutDisplayId||(s.__aiReviewShortcutDisplayId="rte-ai-review-shortcuts-"+String(Math.floor(Math.random()*1e9))),s.__aiReviewShortcutDisplayId}function la(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",Gn("Enter Space A R J K Home End")),e.title=kf(e));var a=e.onfocus;e.onfocus=function(n){la(e),i?qf(e):Ql(),a&&a.call(this,n)},i&&(e.onkeydown=function(n){var l=(n.key||"").toLowerCase(),u=!1,d="";if(l==="a")u=jn(t,"accept",{focusAction:z()});else if(l==="r")u=jn(t,"reject",{focusAction:z()});else if(l==="u"&&n.shiftKey&&lr())u=Vr({focusPanel:!0,focusAction:z()});else if(l==="u"&&nr())u=Er({focusPanel:!0,focusAction:z()});else if(n.key==="ArrowDown"||l==="j"){d="next";var p=ar(t,s.__aiActiveSuggestionId);u=!!(p&&Tt(p,{focusPanel:!0,focusAction:z()}))}else if(n.key==="ArrowUp"||l==="k"){d="previous";var m=_i(t,s.__aiActiveSuggestionId);u=!!(m&&Tt(m,{focusPanel:!0,focusAction:z()}))}else if(n.key==="Home"){d="first";var w=hr(t);u=!!(w&&Tt(w,{focusPanel:!0,focusAction:z()}))}else if(n.key==="End"){d="last";var y=We(t),v=y.length?y[y.length-1].id:"";u=!!(v&&Tt(v,{focusPanel:!0,focusAction:z()}))}(u||d)&&(n.preventDefault(),n.stopPropagation()),!u&&d&&je(rr(s.__aiActiveSuggestionId,d))})}}function Qa(e,t,r,i){e&&(e.setAttribute("aria-keyshortcuts",wf(i)),e.title=yf(i,be(r),e.getAttribute("aria-label")||e.textContent||""),e.onfocus=function(){s.__aiLastReviewActionFocus=i||"",la(e),bu(i)},e.onkeydown=function(a){var n=(a.key||"").toLowerCase(),l=!1,u="";n==="a"?l=Hi(r,"accept",{focusAction:z()}):n==="r"?l=Hi(r,"reject",{focusAction:z()}):n==="u"&&a.shiftKey&&lr()?l=Vr({focusPanel:!0,focusAction:z()}):n==="u"&&nr()?l=Er({focusPanel:!0,focusAction:z()}):a.key==="ArrowDown"||n==="j"?(u="next",l=On(t,r,i,"next")):a.key==="ArrowUp"||n==="k"?(u="previous",l=On(t,r,i,"previous")):a.key==="Home"?(u="first",l=On(t,r,i,"first")):a.key==="End"&&(u="last",l=On(t,r,i,"last")),(l||u)&&(a.preventDefault(),a.stopPropagation()),!l&&u&&je(rr(r,u))})}function Au(e){vr();var t=e?be(e):null,r=t?Cr(t.id):null;return!t||t.status!=="pending"||!r?!1:(Ye(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 Zr(){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),Bi({skipUpdate:!0,skipRender:!0}),s.__aiReviewEmptyPreviewSuggestionId&&Ye(null),s.__aiReviewPrimaryEmptyAction=null,s.__aiReviewMoveEmptyPreviewFocus=null}function Fn(e){return e=e||{},ea(),ui(!0),me(!!e.focusPanel)}function Hf(e){return s.__aiReviewPanel&&s.__aiReviewPanel.isConnected?(Zr(),!1):Fn(e)}var sa={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 ge(e,t,r){if(e){if(e.textContent="",t&&sa[t]){var i=e.ownerDocument.createElement("span");i.className="rte-ai-review-v2-action-icon",i.setAttribute("aria-hidden","true"),i.innerHTML=__RTE_TT(sa[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 Di(e){var t=Ei();if(!t)return!1;for(var r=Ht(),i=Ke().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(Zr(),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(),Zr(),s.focus())};var _=o(h,"div","","rte-ai-review-v2-header"),b=o(_,"span","","rte-ai-review-v2-icon");b.innerHTML=__RTE_TT(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=__RTE_TT('<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(){Zr(),s.focus()};var x=o(h,"div","","rte-ai-review-v2-tabs");x.setAttribute("role","tablist");function R(J,$,Oe,tt){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),$&&sa[$]){var K=B.ownerDocument.createElement("span");K.className="rte-ai-review-v2-tab-icon",K.setAttribute("aria-hidden","true"),K.innerHTML=__RTE_TT(sa[$]),B.appendChild(K)}var le=B.ownerDocument.createElement("span");if(le.className="rte-ai-review-v2-tab-label",le.textContent=Oe,B.appendChild(le),typeof tt=="number"){var xe=B.ownerDocument.createElement("span");xe.className="rte-ai-review-v2-tab-count"+(tt>0?" is-active":""),xe.textContent=String(tt),B.appendChild(xe)}return B.onclick=function(){m!==J&&(Ht().activeTab=J,Di(!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"),S=0;S<n.length;S++){var D=o(P,"option","","",n[S].label);D.value=n[S].value}P.value=l,P.onchange=function(){Ht().typeFilter=P.value||"all",Di(!0)}}for(var F=0,M=0;M<i.length;M++)i[M].status==="pending"&&Pr(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,ge(V,"checkAll",c.__aiT?c.__aiT("air_acceptall","Accept all"):"Accept all"),V.onclick=function(){su(l)&&Di(!0)};var pe=o(C,"button","","rte-ai-review-v2-batch is-reject");pe.type="button",pe.disabled=!F,ge(pe,"x",c.__aiT?c.__aiT("air_rejectall","Reject all"):"Reject all"),pe.onclick=function(){ou(l)&&Di(!0)}}for(var X=o(h,"div","","rte-ai-review-v2-body"),j=[],oe=0;oe<i.length;oe++)if(!(i[oe].changeType&&i[oe].changeType!=="ai-preview")&&Pr(i[oe],l)){var ee=i[oe].status,ue=ee==="pending"||ee==="stale";m==="pending"&&!ue||m==="resolved"&&ue||j.push(i[oe])}j.sort(function(J,$){var Oe=J.status==="pending"||J.status==="stale",tt=$.status==="pending"||$.status==="stale";return Oe!==tt?Oe?-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 Le=0;Le<j.length;Le++)if(j[Le].status==="pending"||j[Le].status==="stale"){Ye(j[Le].id),Y=j[Le].id;break}}var de=be(Y),W=a.total?Math.max(0,Math.min(100,Math.round(y/a.total*100))):0,Ee=l==="all"?c.__aiT?c.__aiT("air_alltypes","All types"):"All types":De(l),Ce=o(h,"div","","rte-ai-review-v2-center");h.insertBefore(Ce,X),Ce.setAttribute("role","group"),Ce.setAttribute("aria-label",c.__aiT?c.__aiT("air_summary","AI review summary"):"AI review summary");function Ae(J,$,Oe,tt){var B=o(Ce,"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",Oe),o(B,"span","","rte-ai-review-v2-center-detail",tt),B}Ae("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",Ee):Ee+" to review":c.__aiT?c.__aiT("air_filter","{0} filter",Ee):Ee+" filter"),Ae("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 Pe=de?de.status==="pending"||de.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",et=de?Ze(de.originalText||de.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.",mt=Ae("is-next",c.__aiT?c.__aiT("air_next","Next step"):"Next step",Pe,et);if(de){var Me=o(mt,"button","","rte-ai-review-v2-center-action",c.__aiT?c.__aiT("air_focus","Focus"):"Focus");Me.type="button",Me.setAttribute("aria-label",c.__aiT?c.__aiT("air_focusaria","Focus the current AI review item"):"Focus the current AI review item"),Me.onclick=function(){Ye(Y),Di(!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 Oe=o($,"div","","rte-ai-review-v2-item-head");o(Oe,"span","","rte-ai-review-v2-item-status is-"+J.status,La(J.status)),J.suggestionType&&J.suggestionType!=="other"&&o(Oe,"span","","rte-ai-review-v2-item-type",De(J.suggestionType)),J.snapshot&&J.snapshot.hasSelection?o(Oe,"span","","rte-ai-review-v2-item-scope",c.__aiT?c.__aiT("air_scope_sel","Selection"):"Selection"):o(Oe,"span","","rte-ai-review-v2-item-scope",c.__aiT?c.__aiT("air_scope_doc","Document"):"Document");var tt=Ze(J.originalText||J.resultText||"AI suggestion",120);if(o($,"div","","rte-ai-review-v2-item-title",tt),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 le=o(B,"span","","rte-ai-review-v2-compare-arrow");le.setAttribute("aria-hidden","true"),le.innerHTML=__RTE_TT(sa.arrowRight);var xe=o(B,"div","","rte-ai-review-v2-after");o(xe,"span","","rte-ai-review-v2-compare-label",c.__aiT?c.__aiT("air_suggested","Suggested"):"Suggested"),o(xe,"div","","rte-ai-review-v2-compare-text",E(J.resultText))}if(J.reason){var I=o($,"div","","rte-ai-review-v2-reason"),we=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=__RTE_TT(sa.bulb),we.appendChild(Q);var te=I.ownerDocument.createElement("span");te.textContent=c.__aiT?c.__aiT("air_why","Why"):"Why",we.appendChild(te),o(I,"span","","rte-ai-review-v2-reason-text",J.reason)}var Te=o($,"div","","rte-ai-review-v2-actions"),Se=o(Te,"button","","rte-ai-review-v2-action is-locate");if(Se.type="button",ge(Se,"target",c.__aiT?c.__aiT("air_locate","Locate"):"Locate"),Se.onclick=function(ce){ce&&ce.stopPropagation&&ce.stopPropagation(),Dt(J.id)},J.status==="pending"||J.status==="stale"){var Re=o(Te,"button","","rte-ai-review-v2-action is-accept");Re.type="button",ge(Re,"check",c.__aiT?c.__aiT("air_accept","Accept"):"Accept"),Re.onclick=function(ce){ce&&ce.stopPropagation&&ce.stopPropagation(),Hi(J.id,"accept",{focusAction:"accept"})};var Fe=o(Te,"button","","rte-ai-review-v2-action is-reject");Fe.type="button",ge(Fe,"x",c.__aiT?c.__aiT("air_reject","Reject"):"Reject"),Fe.onclick=function(ce){ce&&ce.stopPropagation&&ce.stopPropagation(),Hi(J.id,"reject",{focusAction:"reject"})}}}$.onclick=function(ce){ce&&ce.target&&ce.target.closest&&ce.target.closest(".rte-ai-review-v2-action")||J.id!==Y&&(Ye(J.id),Di(!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 me(e,t){if(L.aiToolkitReviewLegacyLayout!==!0)return Di(e);t=t||{},vr();var r=Ei();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=Ke().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=[],S=0;S<w.length;S++)if(!(w[S].changeType&&w[S].changeType!=="ai-preview")){var D=_||w[S].status==="pending"||w[S].status==="stale",F=Vt(w[S].id)>0;D&&(Pr(w[S],x)||F)&&P.push(w[S])}P=qs(P);for(var M=0,V=0;V<P.length;V++)P[V].status==="pending"&&Pr(P[V],x)&&M++;var pe=ar("all",""),X=hr(x),j=ci(),oe=kr();Ye(X||null);var ee=Dn(x,X),ue=ar(x,X);if(Zr(),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",Gn("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(),He=k.target&&k.target.tagName?k.target.tagName.toUpperCase():"";if(k.key==="Escape"){k.preventDefault(),Zr(),s.focus();return}if(!(k.ctrlKey||k.metaKey||k.altKey||He==="INPUT"||He==="TEXTAREA"||He==="SELECT"||He==="BUTTON"))if(!hr(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 it=ar(x,s.__aiActiveSuggestionId);it?Tt(it,{focusPanel:!0,focusAction:z(G)}):s.__aiActiveSuggestionId&&je(rr(s.__aiActiveSuggestionId,"next"))}else if(re==="arrowup"||re==="k"){k.preventDefault();var ht=_i(x,s.__aiActiveSuggestionId);ht?Tt(ht,{focusPanel:!0,focusAction:z(G)}):s.__aiActiveSuggestionId&&je(rr(s.__aiActiveSuggestionId,"previous"))}else if(re==="home"){k.preventDefault();var yt=hr(x);yt&&yt!==s.__aiActiveSuggestionId?Tt(yt,{focusPanel:!0,focusAction:z(G)}):s.__aiActiveSuggestionId&&je(rr(s.__aiActiveSuggestionId,"first"))}else if(re==="end"){k.preventDefault();var er=We(x),T=er.length?er[er.length-1].id:"";T&&T!==s.__aiActiveSuggestionId?Tt(T,{focusPanel:!0,focusAction:z(G)}):s.__aiActiveSuggestionId&&je(rr(s.__aiActiveSuggestionId,"last"))}else if(re==="enter"||re===" "){k.preventDefault();var ie=hr(x);ie?uu(ie,z(G)):s.__aiReviewPrimaryEmptyAction&&s.__aiReviewPrimaryEmptyAction.isConnected&&!s.__aiReviewPrimaryEmptyAction.disabled&&s.__aiReviewPrimaryEmptyAction.click()}else re==="a"?(k.preventDefault(),jn(x,"accept",{focusAction:z(G)})):re==="r"?(k.preventDefault(),jn(x,"reject",{focusAction:z(G)})):re==="u"&&k.shiftKey&&oe?(k.preventDefault(),Vr({focusPanel:!0,focusAction:z(G)})):re==="u"&&j&&(k.preventDefault(),Er({focusPanel:!0,focusAction:z(G)}))};var N=o(G,"div","","rte-ai-review-header"),Le=o(N,"div","","rte-ai-review-header-copy"),de=o(Le,"div","","rte-ai-review-header-eyebrow");o(de,"span","","rte-ai-review-header-kicker","Review workspace"),o(de,"span","","rte-ai-review-header-status is-status",ho(y,M,x)),x!=="all"&&o(de,"span","","rte-ai-review-header-status is-filter",De(x)+" queue"),v&&v.count&&o(de,"span","","rte-ai-review-header-status is-remote",v.count+" shared");var W=o(Le,"div","","rte-ai-review-title-row"),Ee=o(W,"span","","rte-ai-review-title-icon");Ee.innerHTML=__RTE_TT(L.svgCode_aiassist_review||L.svgCode_aiassist||""),o(W,"div","","rte-ai-review-title",L.text_aireview||"AI Review"),ki()&&(s.__aiReviewSyncBadgeNode=o(W,"span","","rte-ai-review-sync-badge","")),s.__aiReviewSubtitleNode=o(Le,"div","","rte-ai-review-subtitle",bc());var Ce=o(Le,"div","","rte-ai-review-header-meta");ee.total&&ee.index&&o(Ce,"span","","rte-ai-review-header-meta-pill is-current","Item "+ee.index+" of "+ee.total),y.pending>0?o(Ce,"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(Ce,"span","","rte-ai-review-header-meta-pill is-stale",y.stale+" need refresh"):o(Ce,"span","","rte-ai-review-header-meta-pill is-complete","Queue complete"),x!=="all"&&y.pending>0&&M!==y.pending&&o(Ce,"span","","rte-ai-review-header-meta-pill is-total",y.pending+" total pending");var Ae=o(N,"div","","rte-ai-review-header-actions"),Pe=null,et=null,mt=null,Me=o(Ae,"div","","rte-ai-review-header-utility");if(ki()){Pe=Pe||Ri(Ae,"rte-ai-review-header-group is-context","Context");var ze=o(Pe,"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&&be(_e)){Pe=Pe||Ri(Ae,"rte-ai-review-header-group is-context","Context");var J=o(Pe,"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",ne("aiu_jumpnewest","Jump to the newest shared AI review update")),J.onclick=function(){Dt(_e)}}if(X){Pe=Pe||Ri(Ae,"rte-ai-review-header-group is-context","Context");var $=o(Pe,"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",ne("aiu_locatecurrent","Locate the current active AI review item in the editor")),$.onclick=function(){Dt(X)}}var Oe=_i(x,X);if(Oe){et=et||Ri(Ae,"rte-ai-review-header-group is-move","Navigate");var tt=o(et,"button","","secondary rte-ai-review-header-button is-nav","Previous");tt.type="button",tt.setAttribute("data-rte-ai-review-focus-key","previous-pending"),tt.setAttribute("aria-label",ne("aiu_jumpprev","Jump to the previous pending AI review item in the current filter")),tt.onclick=function(){Tt(Oe,{focusPanel:!0})}}if(ue){et=et||Ri(Ae,"rte-ai-review-header-group is-move","Navigate");var B=o(et,"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",ne("aiu_jumpnext","Jump to the next pending AI review item in the current filter")),B.onclick=function(){Tt(ue,{focusPanel:!0})}}if(j){var K=Pt(j);mt=mt||Ri(Ae,"rte-ai-review-header-group is-recover","Recover");var le=o(mt,"button","","secondary rte-ai-review-header-button is-undo",K.actionLabel);le.type="button",le.setAttribute("data-rte-ai-review-focus-key","undo-last"),le.setAttribute("data-rte-ai-review-shortcut-label",K.shortcutLabel),le.setAttribute("aria-label","Undo the "+K.detailLabel+(K.summaryText?' for "'+K.summaryText+'"':"")+" and reopen it in AI Review"),le.onclick=function(){Er({focusPanel:!0,focusAction:z()})}}if(oe){var xe=qt(oe);mt=mt||Ri(Ae,"rte-ai-review-header-group is-recover","Recover");var I=o(mt,"button","","secondary rte-ai-review-header-button is-redo",xe.actionLabel);I.type="button",I.setAttribute("data-rte-ai-review-focus-key","redo-last"),I.setAttribute("data-rte-ai-review-shortcut-label",xe.shortcutLabel),I.setAttribute("aria-label","Redo the "+xe.detailLabel+(xe.summaryText?' for "'+xe.summaryText+'"':"")+" in AI Review"),I.onclick=function(){Vr({focusPanel:!0,focusAction:z()})}}var we=o(Me,"button","","rte-ai-panel-close-button is-review-close");we.type="button",we.setAttribute("data-rte-ai-review-focus-key","close-review"),we.setAttribute("aria-label",ne("air_closearia","Close AI review")),we.title=ne("air_close","Close"),we.innerHTML=__RTE_TT('<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>'),we.onclick=function(){Zr()},Ps();var Q=o(G,"div","","rte-ai-review-stack rte-ai-review-overview");Ut(Q,"rte-ai-review-section-label is-overview","Queue overview");var te=y.accepted+y.rejected+y.stale,Te=y.total?Math.max(0,Math.min(100,Math.round(te/y.total*100))):0,Se=o(Q,"div","","rte-ai-review-overview-hero"),Re=o(Se,"div","","rte-ai-review-overview-status-row");o(Re,"span","","rte-ai-review-overview-pill is-status",ho(y,M,x)),o(Re,"span","","rte-ai-review-overview-pill is-progress",te+" of "+y.total+" reviewed"),x!=="all"&&o(Re,"span","","rte-ai-review-overview-pill is-filter",De(x)+" focus"),v&&v.count&&o(Re,"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 Fe=o(Se,"div","","rte-ai-review-overview-progress"),ce=o(Fe,"div","","rte-ai-review-overview-progress-bar"),Lt=o(ce,"span","","rte-ai-review-overview-progress-fill");Lt.style.width=Te+"%",o(Fe,"span","","rte-ai-review-overview-progress-label",Te+"% complete");var $e=o(Q,"div","","rte-ai-review-summary");o($e,"span","","rte-ai-review-summary-pill is-pending",y.pending+" pending"),o($e,"span","","rte-ai-review-summary-pill is-accepted",y.accepted+" accepted"),o($e,"span","","rte-ai-review-summary-pill is-rejected",y.rejected+" rejected"),y.stale&&o($e,"span","","rte-ai-review-summary-pill is-stale",y.stale+" stale"),ee.total&&ee.index&&o($e,"span","","rte-ai-review-summary-pill is-current","Item "+ee.index+" of "+ee.total),x!=="all"&&o($e,"span","","rte-ai-review-summary-pill is-filtered",De(x)+" filter - "+M+" pending"),v&&o($e,"span","","rte-ai-review-summary-pill is-remote",v.count+" new shared");var Rt=be(X),at=x==="all"?"All queues":De(x),gr=x==="all"?y.pending:M,sr=Rt?Ue(Rt,z(G))||"Review item":pe?"Open next queue":y.pending?"Choose queue":"All clear",_t=Rt?ee&&ee.total&&ee.index?"Item "+ee.index+" of "+ee.total+" in "+at.toLowerCase()+".":"Current suggestion is ready.":pe?"There are pending suggestions outside this filter.":y.pending?"Pick a queue filter to continue.":"No pending AI suggestions remain.",qe=o(Q,"div","","rte-ai-review-center");qe.setAttribute("role","group"),qe.setAttribute("aria-label","AI review center summary");function Ie(k,re,He,it){var ht=o(qe,"div","","rte-ai-review-center-tile "+k);return o(ht,"div","","rte-ai-review-center-label",re),o(ht,"div","","rte-ai-review-center-value",He),o(ht,"div","","rte-ai-review-center-detail",it),ht}Ie("is-queue","Queue",gr+" pending",at+(x!=="all"&&y.pending!==M?" - "+y.pending+" total pending":"")),Ie("is-progress","Progress",Te+"% done",te+" reviewed of "+y.total+" total");var Wt=Ie("is-next","Next step",sr,_t);if(X||pe){var bt=o(Wt,"button","","rte-ai-review-center-action",X?"Focus":"Open");bt.type="button",bt.setAttribute("data-rte-ai-review-focus-key",X?"center-focus-current":"center-open-next"),bt.setAttribute("aria-label",X?"Focus the current AI review item":"Open the next pending AI review queue"),bt.onclick=function(){X?Tt(X,{focusPanel:!0,focusAction:z()}):pe&&(m.typeFilter="all",Tt(pe,{focusPanel:!0,focusAction:z(),openedQueue:!0}))}}var wt=bn(oe);if(wt){var ji=qt(oe);o(Q,"div","","rte-ai-review-summary-detail is-redo",wt+" Press Shift+U to "+ji.shortcutLabel+".");var or=pl(2);if(or.length){var ei=o(Q,"div","","rte-ai-review-summary-history is-redo");o(ei,"div","","rte-ai-review-summary-history-title","Then");for(var Qe=0;Qe<or.length;Qe++){var qr=or[Qe],Bt=o(ei,"div","","rte-ai-review-summary-history-item");o(Bt,"div","","rte-ai-review-summary-history-label",qr.label),o(Bt,"div","","rte-ai-review-summary-history-detail",qr.detail)}}}if(v){var ur=o(Q,"div","","rte-ai-review-activity-card"),ti=o(ur,"div","","rte-ai-review-activity-copy");o(ti,"div","","rte-ai-review-activity-title",v.title),o(ti,"div","","rte-ai-review-activity-detail",v.detail);var nt=o(ur,"button","","secondary rte-ai-review-activity-button","Got it");nt.type="button",nt.setAttribute("data-rte-ai-review-focus-key","dismiss-activity"),nt.setAttribute("aria-label",ne("aiu_dismissshared","Dismiss shared AI review update notice")),nt.onclick=function(){cl(),me(!0)}}var jt=o(G,"div","","rte-ai-review-stack rte-ai-review-navigation");Ut(jt,"rte-ai-review-section-label is-controls","Filter and batch");var mr=o(jt,"div","","rte-ai-review-controls"),yi=null;if(b.length>1){yi=Bn(mr,"rte-ai-review-control-group is-scope","Queue scope");var _r=o(yi,"select","","rte-ai-review-filter-select");_r.setAttribute("data-rte-ai-review-focus-key","type-filter");for(var Mt=0;Mt<b.length;Mt++){var ri=o(_r,"option","","",b[Mt].label);ri.value=b[Mt].value}_r.value=x,_r.onchange=function(){m.typeFilter=_r.value||"all",me(!0)}}var Ir=Bn(mr,"rte-ai-review-control-group is-visibility","Visibility"),Mr=o(Ir,"button","","secondary rte-ai-review-control-button is-toggle-resolved",_?"Pending only":"Show resolved");Mr.type="button",Mr.setAttribute("data-rte-ai-review-focus-key","toggle-resolved"),Mr.onclick=function(){m.showResolved=!_,me(!0)};var Ot=Bn(mr,"rte-ai-review-control-group is-batch","Batch review"),dt=o(Ot,"button","","secondary rte-ai-review-control-button is-accept-batch","Accept all");dt.type="button",dt.setAttribute("data-rte-ai-review-focus-key","accept-all"),dt.disabled=x==="all"?!y.pending:!M,x!=="all"&&(dt.innerText=ne("aiu_acceptfiltered","Accept filtered")),dt.onclick=function(){su(x)&&me(!0)};var Xt=o(Ot,"button","","secondary rte-ai-review-control-button is-reject-batch","Reject all");if(Xt.type="button",Xt.setAttribute("data-rte-ai-review-focus-key","reject-all"),Xt.disabled=x==="all"?!y.pending:!M,x!=="all"&&(Xt.innerText=ne("aiu_rejectfiltered","Reject filtered")),Xt.onclick=function(){ou(x)&&me(!0)},b.length>1)for(var ii=o(yi||mr,"div","","rte-ai-review-type-chips"),cr=0;cr<b.length;cr++){var ft=b[cr],br=H[ft.value]||0;if(!(ft.value!=="all"&&br===0&&ft.value!==x)){var Hr=ft.label+" ("+br+")",wr=o(ii,"button","","rte-ai-review-type-chip"+(ft.value===x?" is-active":""),Hr);wr.type="button",wr.setAttribute("data-rte-ai-review-focus-key","type-chip-"+ft.value),wr.setAttribute("aria-pressed",ft.value===x?"true":"false"),wr.onclick=(function(k){return function(){m.typeFilter=k,me(!0)}})(ft.value)}}Ut(jt,"rte-ai-review-section-label is-shortcuts","Keyboard lane");var yr=o(jt,"div","","rte-ai-review-shortcuts","");if(yr.id=yu(),s.__aiReviewShortcutDisplayNode=yr,G.onfocus=function(){la(G),G.title=mu(be(hr(x)),z(G)),Ql(be(hr(x)),z(G))},G.querySelectorAll)for(var Ar=G.querySelectorAll("[data-rte-ai-review-focus-key]"),xr=0;xr<Ar.length;xr++)If(Ar[xr],x);p||d?bu(p||d):X?wu(be(X)):(G.title=mu(be(hr(x)),z(G)),Ql(be(hr(x)),z(G)));var $a=o(G,"div","","rte-ai-review-stack rte-ai-review-content");Ut($a,"rte-ai-review-section-label is-feed",P.length?"Review items":"Recovery and next queues");var Dr=o($a,"div","","rte-ai-review-feed");if(P.length)s.__aiLastReviewEmptyAnnouncement="",s.__aiReviewPrimaryEmptyAction=null,s.__aiReviewMoveEmptyPreviewFocus=null;else{let k=function(T,ie){var Ge=[ie||""];if(T&&T.getAttribute){var Z=T.getAttribute("data-rte-ai-empty-focus-label")||"",ye=T.getAttribute("data-rte-ai-preview-change-label")||"",Fr=T.getAttribute("data-rte-ai-preview-impact-label")||"";Z&&Ge.push("focus "+Z),ye&&Ge.push(ye),Fr&&Ge.push(Fr)}return Ge.filter(function(si){return!!si}).join(", ")},re=function(T){var ie=Ve.length;if(!T||!ie)return{index:0,total:ie};for(var Ge=0;Ge<ie;Ge++)if(Ve[Ge]===T)return{index:Ge+1,total:ie};return{index:0,total:ie}},He=function(T){var ie=Ve.length>1;ai&&(ai.innerText=ud(T,ie)),za(cd(T,{queueSwitcher:ie}),"")},it=function(T){var ie=T&&T.id?T.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"}},ht=function(T,ie,Ge){Ge=Ge||{};for(var Z=0;Z<Ve.length;Z++){var ye=Ve[Z];ye.removeAttribute("data-rte-ai-primary-empty"),ye.removeAttribute("aria-current"),ye.setAttribute("aria-pressed","false"),ye.tabIndex=-1,ye.classList&&ye.classList.contains("is-primary-target")&&ye.classList.remove("is-primary-target"),ye.__aiCurrentBadge&&ye.__aiCurrentBadge.parentNode&&ye.__aiCurrentBadge.parentNode.removeChild(ye.__aiCurrentBadge),ye.__aiCurrentBadge=null,ye.__aiQueueBadge&&ye.__aiQueueBadge.parentNode&&ye.__aiQueueBadge.parentNode.removeChild(ye.__aiQueueBadge),ye.__aiQueueBadge=null}if(s.__aiReviewPrimaryEmptyAction&&s.__aiReviewPrimaryEmptyAction!==T&&(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=T||null,T&&(T.setAttribute("data-rte-ai-primary-empty","true"),T.setAttribute("aria-pressed","true"),T.tabIndex=0,T.classList&&T.classList.contains("rte-ai-review-empty-preview"))){T.classList.add("is-primary-target"),T.setAttribute("aria-current","true");var Fr=T.__aiPreviewMetaNode||(T.querySelector?T.querySelector(".rte-ai-review-empty-preview-meta"):null);if(Fr){T.__aiCurrentBadge=o(Fr,"span","","rte-ai-review-empty-preview-pill is-current","Current");var si=re(T);si.total>1&&(T.__aiQueueBadge=o(Fr,"span","","rte-ai-review-empty-preview-pill is-queue","Queue "+si.index+" of "+si.total))}}var Kn=Be;Be=k(T,ie||""),T&&T.getAttribute&&Au(T.getAttribute("data-rte-ai-preview-suggestion-id")||""),He(Be),Ge.announce&&Be&&Be!==Kn&&je("Completion handoff moved to "+Be+".")},yt=function(T){if(Ve.length<2)return!1;for(var ie=0,Ge=0;Ge<Ve.length;Ge++)if(Ve[Ge]===document.activeElement||Ve[Ge]===s.__aiReviewPrimaryEmptyAction){ie=Ge;break}var Z=ie;return T==="next"?Z=Math.min(Ve.length-1,ie+1):T==="previous"?Z=Math.max(0,ie-1):T==="first"?Z=0:T==="last"&&(Z=Ve.length-1),Z===ie||!Ve[Z]?(T==="next"||T==="last"?je("Already at the last available completion queue."):(T==="previous"||T==="first")&&je("Already at the first available completion queue."),!1):(Ve[Z].focus(),!0)},er=function(T){if(T)if(T.id==="show-resolved")m.showResolved=!0,me(!0);else if(T.id==="go-type"){m.typeFilter=T.typeValue||"all";var ie=T.suggestionId||ar(m.typeFilter,"");ie?Tt(ie,{focusPanel:!0,focusAction:T.focusAction||z(),openedQueue:!0}):me(!0)}else T.id==="next-overall"?(m.typeFilter="all",T.suggestionId?Tt(T.suggestionId,{focusPanel:!0,focusAction:T.focusAction||z(),openedQueue:!0}):me(!0)):T.id==="all-types"?(m.typeFilter="all",me(!0)):T.id==="undo-last"?Er({focusPanel:!0,focusAction:z()}):T.id==="open-chat"&&ta({focusComposer:!0})};var Lr=k,pt=re,ni=He,Si=it,Et=ht,Ur=yt,li=er,Je=ad(y,M,x,_,pe,H,b),Be="",ai=null,Ve=[];s.__aiReviewMoveEmptyPreviewFocus=yt;var jr=Je.title+"|"+Je.detail+"|"+Je.actions.map(function(T){return T?T.label:""}).join("|");Je.announceMessage&&s.__aiLastReviewEmptyAnnouncement!==jr&&(je(Je.announceMessage),s.__aiLastReviewEmptyAnnouncement=jr);var Ct=o(Dr,"div","","rte-ai-review-empty"),Tr=Aa(j),Qt=!!(Je.previewItems&&Je.previewItems.length),Or=!!Tr;Ct.classList.toggle("is-queue-complete",Qt),Ct.classList.toggle("is-recoverable",Or);var lt=o(Ct,"div","","rte-ai-review-empty-hero"),st=o(lt,"div","","rte-ai-review-empty-status-row");if(o(st,"span","","rte-ai-review-empty-status-pill "+(Qt?"is-ready":Or?"is-recovery":"is-clear"),Qt?"Queue complete":Or?"Recovery available":"All clear"),Qt&&o(st,"span","","rte-ai-review-empty-status-pill is-count",Je.previewItems.length===1?"1 next queue":Je.previewItems.length+" next queues"),o(lt,"div","","rte-ai-review-empty-title",Je.title),o(lt,"div","","rte-ai-review-empty-detail",Je.detail),ai=o(lt,"div","","rte-ai-review-empty-hint",""),Tr){var $t=o(Ct,"div","","rte-ai-review-empty-zone is-recovery");Ut($t,"rte-ai-review-section-label is-recovery","Recovery"),o($t,"div","","rte-ai-review-empty-detail rte-ai-review-empty-undo-detail",Tr);var Sr=vl(3);if(Sr.length){var Gr=o($t,"div","","rte-ai-review-empty-undo-history");o(Gr,"div","","rte-ai-review-empty-undo-history-title","Then");for(var Ai=0;Ai<Sr.length;Ai++){var Yt=Sr[Ai],Nn=o(Gr,"div","","rte-ai-review-empty-undo-history-item");o(Nn,"div","","rte-ai-review-empty-undo-history-label",Yt.label),o(Nn,"div","","rte-ai-review-empty-undo-history-detail",Yt.detail)}}}if(Je.previewItems&&Je.previewItems.length){var Ja=o(Ct,"div","","rte-ai-review-empty-zone is-next");Ut(Ja,"rte-ai-review-section-label is-feed",Je.previewItems.length>1?"Next queues":"Next queue");var ua=o(Ja,"div","","rte-ai-review-empty-previews");ua.setAttribute("role","toolbar"),ua.setAttribute("aria-label",ne("aiu_nextqueues","Next review queues"));for(var Oi=0;Oi<Je.previewItems.length;Oi++){var U=Je.previewItems[Oi],rt=U.typeValue?"button":"div",ke=o(ua,rt,"","rte-ai-review-empty-preview"+(U.typeValue?" is-actionable":""));if(rt==="button"){ke.type="button",ke.tabIndex=-1,ke.setAttribute("aria-pressed","false"),ke.setAttribute("aria-setsize",String(Je.previewItems.length)),ke.setAttribute("aria-posinset",String(Oi+1)),ke.setAttribute("aria-keyshortcuts",mo({queueSwitcher:Je.previewItems.length>1})),ke.title=go(U.actionLabel||U.label||"Open next queue",{focusLabel:U.focusActionLabel,queueSwitcher:Je.previewItems.length>1});var kt=[U.actionLabel||U.label||"Open next queue"];U.focusActionLabel&&kt.push("Focus "+U.focusActionLabel),U.pendingCountLabel&&kt.push(U.pendingCountLabel),U.changeLabel&&kt.push(U.changeLabel),U.impactLabel&&kt.push(U.impactLabel),U.scopeLabel&&kt.push(U.scopeLabel),U.languageLabel&&kt.push(U.languageLabel),U.text&&kt.push("Current: "+U.text),U.resultText&&kt.push("Suggested: "+U.resultText),U.reasonText&&kt.push("Why this next: "+U.reasonText),ke.setAttribute("aria-label",ve(kt)),ke.setAttribute("data-rte-ai-primary-label",U.actionLabel||U.label||"Open next queue"),U.focusActionLabel&&ke.setAttribute("data-rte-ai-empty-focus-label",U.focusActionLabel),U.changeLabel&&ke.setAttribute("data-rte-ai-preview-change-label",U.changeLabel),U.impactLabel&&ke.setAttribute("data-rte-ai-preview-impact-label",U.impactLabel),U.suggestionId&&ke.setAttribute("data-rte-ai-preview-suggestion-id",U.suggestionId),ke.onclick=(function(T){return function(){er({id:"go-type",typeValue:T.typeValue,suggestionId:T.suggestionId,focusAction:T.focusAction||""})}})(U),ke.onfocus=function(){la(this),ht(this,this.getAttribute("data-rte-ai-primary-label")||this.innerText||"",{announce:Ve.length>1})},ke.onkeydown=function(T){var ie=(T.key||"").toLowerCase();ie==="u"&&T.shiftKey&&lr()?(T.preventDefault(),T.stopPropagation(),Vr({focusPanel:!0,focusAction:z()})):ie==="u"&&nr()?(T.preventDefault(),T.stopPropagation(),Er({focusPanel:!0,focusAction:z()})):T.key==="ArrowRight"||T.key==="ArrowDown"||ie==="j"?(T.preventDefault(),yt("next")):T.key==="ArrowLeft"||T.key==="ArrowUp"||ie==="k"?(T.preventDefault(),yt("previous")):T.key==="Home"?(T.preventDefault(),yt("first")):T.key==="End"&&(T.preventDefault(),yt("last"))},Ve.push(ke),s.__aiReviewPrimaryEmptyAction||ht(ke,U.actionLabel||U.label||"")}o(ke,"div","","rte-ai-review-empty-preview-label",U.label||"Next queue");var Gt=o(ke,"div","","rte-ai-review-empty-preview-meta");ke.__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 Zt=Ln(U.text,U.resultText);fo(ke,"current",U.text||"",Zt),U.resultText&&fo(ke,"result",U.resultText,Zt),U.reasonText&&o(ke,"div","","rte-ai-review-empty-preview-reason","Why this next: "+U.reasonText)}}for(var dr=[],xi=0;xi<Je.actions.length;xi++)Je.actions[xi]&&dr.push(Je.actions[xi]);if(dr.length){var fr=o(Ct,"div","","rte-ai-review-empty-zone is-actions");Ut(fr,"rte-ai-review-section-label is-controls","Actions");for(var $l=o(fr,"div","","rte-ai-review-empty-actions"),Ti={},Gi=0;Gi<dr.length;Gi++)(function(T){var ie=it(T);Ti[ie.key]||(Ti[ie.key]=o($l,"div","","rte-ai-review-empty-action-group is-"+ie.key),Ti[ie.key].setAttribute("data-rte-ai-empty-group-label",ie.label));var Ge=Gi===0,Z=o(Ti[ie.key],"button","",Ge&&!s.__aiReviewPrimaryEmptyAction?"rte-ai-review-control-button is-primary":"secondary rte-ai-review-control-button","");o(Z,"span","","rte-ai-review-empty-action-label",T.label),T.focusActionLabel&&o(Z,"span","","rte-ai-review-empty-action-pill is-focus","Focus "+T.focusActionLabel),Z.type="button",T.id&&Z.setAttribute("data-rte-ai-empty-action-id",T.id),Z.setAttribute("aria-keyshortcuts",mo()),Z.title=go(T.label||"",{focusLabel:T.focusActionLabel}),T.focusActionLabel&&Z.setAttribute("data-rte-ai-empty-focus-label",T.focusActionLabel),T.suggestionId&&Z.setAttribute("data-rte-ai-preview-suggestion-id",T.suggestionId),Ge&&Z.setAttribute("data-rte-ai-primary-button","true"),Ge&&!s.__aiReviewPrimaryEmptyAction&&ht(Z,T.label||""),Z.onfocus=function(){la(Z),(T.id==="go-type"||T.id==="next-overall")&&Au(T.suggestionId||""),He(k(Z,T.label||""))},Z.onkeydown=function(ye){(ye.key||"").toLowerCase()==="u"&&ye.shiftKey&&lr()?(ye.preventDefault(),ye.stopPropagation(),Vr({focusPanel:!0,focusAction:z()})):(ye.key||"").toLowerCase()==="u"&&nr()&&(ye.preventDefault(),ye.stopPropagation(),Er({focusPanel:!0,focusAction:z()}))},Z.onclick=function(){er(T)}})(dr[Gi])}var Va=Be||(dr[0]?dr[0].label:"");He(Va)}for(var f="",g=0;g<P.length;g++)(function(k){var re=s.__aiRecentlyOpenedQueueSuggestionId===k.id,He=Pa(P,s.__aiActiveSuggestionId,k),it=Yc(P,s.__aiActiveSuggestionId,k,He);if(it&&it.key!==f){var ht=o(Dr,"div","","rte-ai-review-feed-section is-"+it.key),yt=o(ht,"div","","rte-ai-review-feed-section-meta"),er=o(yt,"div","","rte-ai-review-feed-section-title",it.label);er.setAttribute("role","heading"),er.setAttribute("aria-level","3"),it.countLabel&&o(yt,"span","","rte-ai-review-feed-section-pill",it.countLabel),it.detail&&o(ht,"div","","rte-ai-review-feed-section-detail",it.detail),f=it.key}var T=gi(P,s.__aiActiveSuggestionId,k),ie=s.__aiActiveSuggestionId===k.id,Ge=!ie&&!re,Z=o(Dr,"div","","rte-ai-review-item is-"+k.status+(ie?" is-active":"")+(re?" is-opened":"")+(Ge?" is-condensed":""));Z.setAttribute("data-rte-ai-review-id",k.id),Z.setAttribute("data-rte-ai-review-density",Ge?"condensed":"expanded"),He&&He.role&&Z.setAttribute("data-rte-ai-review-queue-role",He.role),Z.setAttribute("role","button"),Z.tabIndex=s.__aiActiveSuggestionId===k.id?0:-1,Z.setAttribute("aria-keyshortcuts",Gn(k.status==="pending"?"Enter Space A R J K Home End":"Enter Space J K Home End")),Z.title=Nl(k,z(G));var ye=Vt(k.id);s.__aiActiveSuggestionId===k.id&&Z.setAttribute("aria-current","true"),Z.onclick=function(pa){if(!(pa&&pa.target&&pa.target.closest&&pa.target.closest(".rte-ai-review-item-actions"))){var is=z(G),Vn=document.activeElement;Vn&&Vn.getAttribute&&G.contains(Vn)&&(is=Vn.getAttribute("data-rte-ai-review-action")||is),!uu(k.id,is)&&wi(k.id,{focusPanel:!0})}},Z.onfocus=function(){la(Z),Z.title=Nl(k,z(G)),wu(k),Ge&&Cn(Z,k,G)};var Fr=o(Z,"div","","rte-ai-review-item-state is-"+k.status+(ie?" is-current":"")+(re?" is-opened":""));if(o(Fr,"div","","rte-ai-review-item-state-kicker",k.status==="pending"?"Review item":"Review history"),o(Fr,"div","","rte-ai-review-item-state-title",sd(k,ie,re)),o(Fr,"div","","rte-ai-review-item-state-detail",od(k,ie,re,ye)),He){var si=o(Z,"div","","rte-ai-review-item-queue-card is-"+He.role);o(si,"div","","rte-ai-review-item-queue-title",He.roleLabel);var Kn=o(si,"div","","rte-ai-review-item-queue-meta");o(Kn,"span","","rte-ai-review-item-queue-pill is-role",He.roleLabel),o(Kn,"span","","rte-ai-review-item-queue-pill is-position",He.queueLabel),o(si,"div","","rte-ai-review-item-queue-detail",He.detail)}if(T){var Wa=o(Z,"div","","rte-ai-review-item-transition-card");o(Wa,"div","","rte-ai-review-item-transition-title",T.title);var zn=o(Wa,"div","","rte-ai-review-item-transition-meta");if(o(zn,"span","","rte-ai-review-item-transition-pill is-status",T.statusLabel),o(zn,"span","","rte-ai-review-item-transition-pill is-position",T.queueLabel),T.typeLabel&&o(zn,"span","","rte-ai-review-item-transition-pill is-type",T.typeLabel),T.scopeLabel&&o(zn,"span","","rte-ai-review-item-transition-pill is-scope",T.scopeLabel),o(Wa,"div","","rte-ai-review-item-transition-detail",T.detail),no(Wa,"rte-ai-review-item-transition-preview",T),T.followupTitle){var Jl=o(Wa,"div","","rte-ai-review-item-transition-followup");o(Jl,"div","","rte-ai-review-item-transition-followup-title",T.followupTitle);var jf=o(Jl,"div","","rte-ai-review-item-transition-followup-meta");T.followupStatusLabel&&o(jf,"span","","rte-ai-review-item-transition-pill is-followup",T.followupStatusLabel),o(Jl,"div","","rte-ai-review-item-transition-followup-detail",T.followupDetail)}}var Ui=o(Z,"div","","rte-ai-review-item-meta");o(Ui,"span","","rte-ai-review-item-status is-"+k.status,La(k.status)),o(Ui,"span","","rte-ai-review-item-stamp",k.sourceLabel||(k.snapshot&&k.snapshot.hasSelection?"Selection suggestion":"Document suggestion")),ie&&o(Ui,"span","","rte-ai-review-item-stamp is-current","Current"),re&&o(Ui,"span","","rte-ai-review-item-stamp is-opened","Queue opened"),k.suggestionType&&k.suggestionType!=="other"&&o(Ui,"span","","rte-ai-review-item-stamp is-type",De(k.suggestionType)),k.language&&o(Ui,"span","","rte-ai-review-item-stamp is-language",ut(k.language)),ye&&o(Ui,"span","","rte-ai-review-item-stamp is-remote",ye>1?ye+" shared updates":"Shared update");var Qn=o(Z,"div","","rte-ai-review-item-summary");o(Qn,"div","","rte-ai-review-item-title",Ze(k.originalText||k.resultText||"AI suggestion",80)),Ge&&id(Qn,k,G,{queuePositionData:He,queueTransitionData:T,sharedUpdateCount:ye});var tr=Xi(k);if(tr){var Vl=o(Qn,"div","","rte-ai-review-item-glance-card");if(o(Vl,"div","","rte-ai-review-item-glance-title",tr.title),tr.pills&&tr.pills.length)for(var Of=o(Vl,"div","","rte-ai-review-item-glance-meta"),Wl=0;Wl<tr.pills.length;Wl++){var Tu=tr.pills[Wl];o(Of,"span","","rte-ai-review-item-glance-pill is-"+Tu.kind,Tu.text)}tr.detail&&o(Vl,"div","","rte-ai-review-item-glance-detail",tr.detail)}if(k.reason){var Su=o(Qn,"div","","rte-ai-review-item-reason-card");o(Su,"div","","rte-ai-review-item-reason-label","Why AI suggested this"),o(Su,"div","","rte-ai-review-item-reason",k.reason)}var Bl=o(Z,"div","","rte-ai-review-item-compare"),Lu=o(Bl,"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=Ln(k.originalText||"",k.resultText||""),Gf=o(Bl,"div","","rte-ai-review-item-before");Rn(Gf,"current",E(k.originalText||""),Ru);var Uf=o(Bl,"div","","rte-ai-review-item-after");Rn(Uf,"result",E(k.resultText||""),Ru);var ca=ie&&k.status==="pending"&&j?Pt(j):null,Cu=ca?Aa(j):"",$n=ca?vl(1):[];if(ca)var Ff=o(Z,"div","","rte-ai-review-item-undo-note",Cu+" Press U to "+ca.shortcutLabel+"."),ku=wn(Ff,"undo-note",k.id);var Ba=null;$n.length&&(Ba=Os(Z,$n,"undo"),wn(Ba,"undo-history",k.id));var Nf=!!(oe&&oe.suggestion&&oe.suggestion.id===k.id&&k.status==="pending"),da=Nf?qt(oe):null,Eu=da?bn(oe):"",Xl="";if(da){var Kf=o(Z,"div","","rte-ai-review-item-redo-note",Eu+" Press Shift+U to "+da.shortcutLabel+".");Xl=wn(Kf,"redo-note",k.id)}var Xa=null,Jn=da?pl(1):[];Jn.length&&(Xa=Os(Z,Jn,"redo"),wn(Xa,"redo-history",k.id)),Z.setAttribute("aria-label",Xc(k,{isCurrent:s.__aiActiveSuggestionId===k.id,queueOpened:re,queueRoleLabel:He?He.roleLabel:"",queuePositionLabel:He?He.queueLabel:"",transitionLabel:T?T.title+". "+T.statusLabel+". "+T.queueLabel+". "+Br(T)+(T.followupTitle?". "+T.followupTitle+". "+T.followupDetail:""):"",changeSummary:tr?tr.title+". "+(tr.pills||[]).map(function(pa){return pa.text}).join(". ")+(tr.detail?". "+tr.detail:""):"",remoteUpdateCount:ye,undoLabel:Cu,undoNextLabel:$n.length?"Undo after this: "+$n[0].detail:"",redoLabel:Eu,redoNextLabel:Jn.length?"Redo after this: "+Jn[0].detail:""})),Z.setAttribute("data-rte-ai-review-base-aria-label",Z.getAttribute("aria-label")||""),Ge&&(po(Z,k,G),Cn(Z,k,G));var Yl=o(Z,"div","","rte-ai-review-item-actions"),Pu=o(Yl,"div","","rte-ai-review-item-action-group is-locate");Pu.setAttribute("data-rte-ai-review-action-group","locate");var Zl=o(Yl,"div","","rte-ai-review-item-action-group is-decision");Zl.setAttribute("data-rte-ai-review-action-group","decision");var es=o(Yl,"div","","rte-ai-review-item-action-group is-recovery");es.setAttribute("data-rte-ai-review-action-group","recovery");var Ya=o(Pu,"button","","secondary rte-ai-review-action-button is-locate","Locate");if(Ya.type="button",Ya.setAttribute("data-rte-ai-review-action","locate"),Ya.disabled=k.status!=="pending"&&k.status!=="stale",Ya.onclick=function(){Dt(k.id)},Qa(Ya,x,k.id,"locate"),k.status==="pending"){var ts=bi(k,"accept",x)||{text:"Accept",label:"Accept this AI change"},fa=o(Zl,"button","","rte-ai-review-action-button is-primary is-accept",ts.text);fa.type="button",fa.setAttribute("data-rte-ai-review-action","accept"),fa.setAttribute("aria-label",ts.label),fa.title=ts.label,fa.onclick=function(){Hi(k.id,"accept",{focusAction:"accept"})},Qa(fa,x,k.id,"accept");var rs=bi(k,"reject",x)||{text:"Reject",label:"Reject this AI change"},va=o(Zl,"button","","secondary rte-ai-review-action-button is-reject",rs.text);if(va.type="button",va.setAttribute("data-rte-ai-review-action","reject"),va.setAttribute("aria-label",rs.label),va.title=rs.label,va.onclick=function(){Hi(k.id,"reject",{focusAction:"reject"})},Qa(va,x,k.id,"reject"),ca){var Za=o(es,"button","","secondary rte-ai-review-action-button is-undo",ca.actionLabel);Za.type="button",Za.setAttribute("data-rte-ai-review-action","undo"),ku&&Za.setAttribute("data-rte-ai-review-extra-describedby",ku+(Ba&&Ba.id?" "+Ba.id:"")),Za.onclick=function(){Er({focusPanel:!0,focusAction:"undo"})},Qa(Za,x,k.id,"undo")}if(da){var en=o(es,"button","","secondary rte-ai-review-action-button is-redo",da.actionLabel);en.type="button",en.setAttribute("data-rte-ai-review-action","redo"),Xl&&en.setAttribute("data-rte-ai-review-extra-describedby",Xl+(Xa&&Xa.id?" "+Xa.id:"")),en.onclick=function(){Vr({focusPanel:!0,focusAction:"redo"})},Qa(en,x,k.id,"redo")}}})(P[g]);var A=!!e||u||!!p,q=_f(Dr,A,p||d);Na(p||d||z(G)),Ka(p||d||z(G));var O=Ki().slice(0,6);if(O.length){o(Dr,"div","","rte-ai-review-history-title","Recent activity");for(var se=0;se<O.length;se++){var fe=O[se],ae=lc(fe),Ne=o(Dr,"div","","rte-ai-review-history-entry is-"+ae);Ne.setAttribute("data-rte-ai-review-event",fe.eventType||"suggestion-updated");var ot=o(Ne,"div","","rte-ai-review-history-header");o(ot,"span","","rte-ai-review-history-event is-"+ae,Ts(fe));var vt=[];fe.sourceLabel&&vt.push(fe.sourceLabel),fe.suggestionType&&fe.suggestionType!=="other"&&vt.push(De(fe.suggestionType)),fe.language&&vt.push(ut(fe.language)),o(ot,"div","","rte-ai-review-history-meta",vt.join(" - ")||"AI review"),o(Ne,"div","","rte-ai-review-history-text",Ze(fe.resultText||fe.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 oa(e){e=e||{},s.__aiDialog&&s.__aiDialog.isConnected&&s.__aiDialog.close();var t=ct(),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"),ma(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"),ti(),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 S=o(C,"option","","",c.__aiT?c.__aiT("aid_document","Document"):"Document");S.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"),ge(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"),ge(V,"document",""),F.appendChild(V),R.appendChild(F);var pe=o(w,"div","","demo-ai-field demo-ai-run-field"),X=o(pe,"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"),ge(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 oe=/Mac|iPad|iPhone|iPod/i.test((navigator.platform||"")+" "+(navigator.userAgent||"")),ee=oe?"\u2318\u23CE":"Ctrl \u23CE";function ue(){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)}}ue();var Y=o(X,"button","","secondary is-icon-only");Y.type="button",Y.title=ne("aiu_copytosource","Copy result into source"),Y.setAttribute("aria-label",ne("aiu_copytosource","Copy result into source")),Y.setAttribute("data-rte-ai-dialog-action","copy-to-source"),ge(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 Le=o(N,"div","","demo-ai-field demo-ai-source-field");o(Le,"span","","demo-ai-text-label-inline is-detached","Source");var de=o(Le,"span","","demo-ai-field-help is-detached","Edit the source text or prompt that Ask AI will use.");de.id=u;var W=o(Le,"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),Le.appendChild(X),W.rows=1,W.placeholder=c.__aiT?c.__aiT("aid_typeorpaste","Type or paste text\u2026"):"Type or paste text\u2026";var Ee=o(Le,"span","","demo-ai-source-counter");Ee.setAttribute("aria-hidden","true");function Ce(){if(Ee){var f=W.value||"",g=f.length;if(!g){Ee.textContent="",Ee.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";Ee.textContent=A,Ee.classList.add("is-visible")}}Le.style.order="2";var Ae=o(N,"div","","demo-ai-field demo-ai-result-field");Ae.style.order="1";var Pe=o(Ae,"div","","demo-ai-result-head"),et=document.createElement("span");et.className="demo-ai-text-label-inline is-detached",et.innerText=ne("aiu_result","Result");var mt=o(Ae,"span","","demo-ai-field-help is-detached","Review the generated AI suggestion before applying it.");mt.id=d;var Me=o(Pe,"button","","demo-ai-clipboard-toggle");Me.type="button",Me.setAttribute("data-rte-ai-dialog-action","copy-clipboard"),Me.title=c.__aiT?c.__aiT("ai2_copyclip","Copy AI output to clipboard"):"Copy AI output to clipboard",Me.setAttribute("aria-label",c.__aiT?c.__aiT("ai2_copyclip","Copy AI output to clipboard"):"Copy AI output to clipboard"),ge(Me,"clipboard",c.__aiT?c.__aiT("ai2_copy","Copy"):"Copy");var ze=null;Me.onclick=function(f){f&&f.stopPropagation&&f.stopPropagation(),E($.value)&&To($.value).then(function(g){g&&(Me.classList.add("is-copied"),ge(Me,"check",c.__aiT?c.__aiT("aic_copied","Copied"):"Copied"),ze&&clearTimeout(ze),ze=setTimeout(function(){Me.classList.remove("is-copied"),ge(Me,"clipboard",c.__aiT?c.__aiT("ai2_copy","Copy"):"Copy"),ze=null},1400))})};var _e=o(Pe,"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"),ge(_e,"info","");var J=o(Pe,"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",Le.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(Ae,"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 Oe=document.createElement("pre"),tt=document.createElement("pre"),B=document.createElement("div");B.className="demo-ai-refine-row is-detached",B.setAttribute("role","group"),B.setAttribute("aria-label",ne("aiu_refine","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"),ge(K,"refresh",c.__aiT?c.__aiT("ai2_tryagain","Try again"):"Try again");var le=o(B,"button","","secondary demo-ai-refine-chip");le.type="button",le.title=c.__aiT?c.__aiT("ai2_shortertitle","Make the suggestion shorter"):"Make the suggestion shorter",le.setAttribute("data-rte-ai-dialog-action","refine-shorter"),ge(le,"shrink",c.__aiT?c.__aiT("ai2_shorter","Shorter"):"Shorter");var xe=o(B,"button","","secondary demo-ai-refine-chip");xe.type="button",xe.title=c.__aiT?c.__aiT("ai2_longertitle","Expand the suggestion with more detail"):"Expand the suggestion with more detail",xe.setAttribute("data-rte-ai-dialog-action","refine-longer"),ge(xe,"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=ne("air_why","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 we(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,Ti(),j&&!j.disabled&&j.onclick&&j.onclick())}K.onclick=function(){j&&!j.disabled&&j.onclick&&j.onclick()},le.onclick=function(){we("Rewrite to be noticeably shorter and more concise while keeping the meaning intact.")},xe.onclick=function(){we("Expand with more supporting detail, examples, and depth while keeping the same voice.")},I.onclick=function(f){f&&f.stopPropagation&&f.stopPropagation();var g=Ie.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)),qe&&qe.setAttribute&&qe.setAttribute("aria-expanded",A?"true":"false")},_e.onclick=function(f){f&&f.stopPropagation&&f.stopPropagation();var g=Ie.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"),qe&&qe.setAttribute&&qe.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"),ge(te,"check",c.__aiT?c.__aiT("ai2_apply","Apply"):"Apply");var Te=o(Q,"button","","");Te.type="button",Te.disabled=!t.hasSelection,Te.setAttribute("data-rte-ai-dialog-action","selection"),ge(Te,"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"),ge(Se,"eyeOn",c.__aiT?c.__aiT("ai2_preview","Preview"):"Preview");var Re=o(Q,"button","","secondary");Re.type="button",Re.setAttribute("data-rte-ai-dialog-action","insert"),ge(Re,"arrowRight",c.__aiT?c.__aiT("ai2_insbelow","Insert below"):"Insert below");var Fe=o(Q,"button","","secondary");Fe.type="button",Fe.setAttribute("data-rte-ai-dialog-action","document"),ge(Fe,"checkAll",c.__aiT?c.__aiT("ai2_repldoc","Replace document"):"Replace document");var ce=o(Q,"button","","secondary demo-ai-apply-more-toggle is-icon-only");ce.type="button",ce.setAttribute("data-rte-ai-dialog-action","more"),ce.setAttribute("aria-expanded","false"),ce.title=c.__aiT?c.__aiT("ai2_moreopts","More apply options"):"More apply options",ce.setAttribute("aria-label",c.__aiT?c.__aiT("ai2_moreopts","More apply options"):"More apply options"),ge(ce,"more",""),ce.onclick=function(f){f&&f.stopPropagation&&f.stopPropagation();var g=Q.classList.toggle("is-show-more");ce.setAttribute("aria-expanded",g?"true":"false")},Q.insertBefore(K,ce),Q.insertBefore(le,ce),Q.insertBefore(xe,ce);var Lt=document.createElement("button");Lt.type="button",Lt.className="secondary is-detached",Lt.setAttribute("data-rte-ai-dialog-action","reject"),ge(Lt,"trash","Discard");var $e=document.createElement("div");$e.id=p,$e.className="demo-ai-apply-guidance",$e.style.display="none",$e.setAttribute("role","group"),$e.setAttribute("aria-label",c.__aiT?c.__aiT("aid_bestnext","Best next step"):"Best next step");var Rt=o($e,"div","","demo-ai-apply-guidance-header"),at=o(Rt,"span","","demo-ai-apply-guidance-title","Next"),gr=o(Rt,"span","","demo-ai-apply-guidance-badge"),sr=o($e,"div","","demo-ai-apply-guidance-detail");a.appendChild($e);var _t=o(a,"div","","demo-ai-dialog-status");_t.id=m,_t.setAttribute("role","status"),_t.setAttribute("aria-live","polite"),_t.setAttribute("aria-atomic","true");var qe=o(a,"button","","demo-ai-details-toggle","Details");qe.type="button",qe.setAttribute("aria-expanded","false"),qe.setAttribute("aria-controls","rte-ai-details-"+n),qe.title=ne("aiu_showwhy","Show why and the operation plan");var Ie=o(a,"div","","demo-ai-insight-grid is-collapsed");Ie.id=qe.getAttribute("aria-controls"),I&&I.setAttribute&&I.setAttribute("aria-controls",Ie.id),_e&&_e.setAttribute&&_e.setAttribute("aria-controls",Ie.id),a.insertBefore(qe,Q),a.insertBefore(Ie,Q),qe.onclick=function(){var f=Ie.classList.toggle("is-collapsed");qe.setAttribute("aria-expanded",f?"false":"true")};var Wt=o(Ie,"div","","demo-ai-reason-panel");Wt.setAttribute("role","group"),Wt.setAttribute("aria-label","AI rationale"),o(Wt,"label","","","Why");var bt=o(Wt,"div","","demo-ai-reason-copy","The reason will appear here once a suggestion is generated."),wt=o(Ie,"div","","demo-ai-plan-panel");wt.setAttribute("role","group"),wt.setAttribute("aria-label","AI operation plan"),o(wt,"label","","","Plan");var ji=document.createElement("div"),or=o(wt,"div","","demo-ai-plan-status"),ei=o(or,"span","","demo-ai-plan-status-message"),Qe=o(or,"button","","secondary demo-ai-plan-status-action","Re-run");Qe.type="button",Qe.style.display="none",Qe.setAttribute("data-rte-ai-dialog-action","rerun");var qr=o(wt,"div","","demo-ai-plan-summary"),Bt=o(wt,"ul","","demo-ai-plan-list");function ur(f){var g=r.__aiResolved;return g&&g.operations&&g.operations.length?g:zr($.value,f,g||null,g?g.request:null,g?g.action:null)}function ti(){var f=il();v.innerHTML=__RTE_TT("");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=[],se=0;se<f.length;se++){var fe=f[se],ae=fe.group||g[fe.id]||"";if(!ae){O.push(fe);continue}q[ae]||(q[ae]=[],A.indexOf(ae)===-1&&A.push(ae)),q[ae].push(fe)}function Ne(Si,Et){var Ur=o(Si,"option","","",Et.title||Et.id);Ur.value=Et.id,Et.description&&(Ur.title=Et.description)}for(var ot=0;ot<A.length;ot++){var vt=q[A[ot]];if(!(!vt||!vt.length)){var Lr=o(v,"optgroup");Lr.label=A[ot];for(var pt=0;pt<vt.length;pt++)Ne(Lr,vt[pt])}}for(var ni=0;ni<O.length;ni++)Ne(v,O[ni]);v.options.length&&v.selectedIndex<0&&(v.selectedIndex=0),nt(),Mt()}function nt(){var f=_a();b.innerHTML=__RTE_TT("");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 mr(){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 se=f==="selection"?g.text||"":g.wholeText||"";O=se.length,f==="selection"&&!g.hasSelection&&(q="document",O=(g.wholeText||"").length)}if(!O)return"";var fe=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 "+fe+" 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 _r(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+" ("+ut(b.value||"spanish")+")"),g.innerText=q||A,r.setAttribute&&r.setAttribute("aria-label",q?A+" \xB7 "+q:A)}}}function Mt(){for(var f=il(),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: "+ut(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||""),_r(A),W&&!W.value){var se=v.value||"",fe={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=fe[se]||"Type or paste text\u2026"}if(i){var ae=A||"";A&&v.value==="translate"&&(ae=A+" \xB7 "+ut(b.value||"spanish")),i.innerText=ae,i.style.display=ae?"":"none"}jt()}function ri(f){return r.__aiOperationStates&&r.__aiOperationStates["step-"+f]?r.__aiOperationStates["step-"+f]:""}function Ir(f,g){r.__aiOperationStates=r.__aiOperationStates||{},r.__aiOperationStates["step-"+f]=g||""}function Mr(){Ie&&Ie.classList&&Ie.classList.contains("is-collapsed")&&(Ie.classList.remove("is-collapsed"),qe&&qe.setAttribute&&qe.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",_t.innerText=r.__aiPlanStaleReason,Zt(r.__aiResolved),fr(),Mr()}function dt(f,g){return f?g==="selection"?f.text||f.wholeText||"":f.wholeText||"":""}function Xt(f,g){return g==="selection"&&(!f||!f.hasSelection)&&!r.__aiSourceLinkedToEditor&&!!E(W.value)}function ii(f,g){return g==="selection"?f&&f.hasSelection?"Selection ready":Xt(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 cr(f,g){return g==="selection"&&f&&f.hasSelection?"selection":"document"}function ft(f){return!!f&&(f.type==="preview-suggestion"||f.type==="replace-selection")}function br(f,g){var A=g&&g.length?g:null;if(!A){for(var q=0;q<f.length;q++)if(ft(f[q]))return!0;return!1}for(var O=0;O<A.length;O++)if(ft(f[A[O]]))return!0;return!1}function Hr(f){var g=r.__aiSourceScope==="selection"?"selection":"document";return r.__aiSourceLinkedToEditor?cr(f,g):g}function wr(f,g,A){return r.__aiPlanStale?r.__aiSourceLinkedToEditor?A:g:f&&f.request?f.request.scope==="selection"?"selection":"document":r.__aiSourceLinkedToEditor?A:g}function yr(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 Ar(){var f=r.__aiSourceScope==="selection"?"selection":"document",g=cr(r.__aiSnapshot,f),A=Xt(r.__aiSnapshot,f),q=A?"selection":g;if(G&&(G.innerText=ii(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",yr("selection",r.__aiSnapshot,q,A))),V&&V.setAttribute&&(V.setAttribute("aria-pressed",q==="document"?"true":"false"),V.setAttribute("aria-label",yr("document",r.__aiSnapshot,q,A))),C){var O=r.__aiSnapshot,se=!!(O&&O.hasSelection),fe=O?(O.wholeText||"").length:0;P.disabled=!se,P.text=se?c.__aiT?c.__aiT("aid_selection","Selection"):"Selection":c.__aiT?c.__aiT("aid_selectionnone","Selection (none)"):"Selection (none)",S.text=c.__aiT?c.__aiT("aid_document","Document"):"Document",C.value=q==="selection"?"selection":"document",C.setAttribute("title",ii(O,f)),D&&(D.innerText=c.__aiT?c.__aiT("aid_document","Document"):"Document"),w&&w.classList&&(se?w.classList.remove("is-scope-implicit"):w.classList.add("is-scope-implicit"))}}function xr(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 $a(){r.__aiSourceLinkedToEditor=!1}function Dr(f,g){return E(f&&f.text?f.text:"")!==E(g&&g.text?g.text:"")}function Je(f,g,A){return f==="selection"?A&&A.hasSelection&&g&&!g.hasSelection?"Selection cleared. Re-run to refresh.":A&&g&&A.hasSelection&&g.hasSelection&&sl(A.range,g.range)&&Dr(A,g)?"Selection text changed. Re-run to refresh.":"Selection changed. Re-run to refresh.":"Document changed. Re-run to refresh."}function Be(f){return E(f)?"Source changed. Re-run to refresh.":"Source cleared. Reload from the editor or type source text before re-running."}function ai(){return"Mode changed. Re-run to refresh."}function Ve(f){return"Language \u2192 "+ut(f||"spanish")+". Re-run to refresh."}function jr(f){return"Scope \u2192 "+(f==="selection"?"selection":"document")+". Re-run to refresh."}function Ct(f){return"Reloaded from "+(f==="selection"?"selection":"document")+". Re-run to refresh."}function Tr(f,g,A){return f==="selection"?A&&A.hasSelection&&g&&!g.hasSelection?"Selection cleared. Re-run to refresh.":A&&g&&A.hasSelection&&g.hasSelection&&sl(A.range,g.range)&&Dr(A,g)?"Selection text changed. Re-run to refresh.":"Selection changed. Re-run to refresh.":"Document changed. Re-run to refresh."}function Qt(f){for(var g=[],A=0;A<f.length;A++)ri(A)!=="done"&&ri(A)!=="skipped"&&g.push(A);return g}function Or(){var f=r.__aiResolved&&r.__aiResolved.operations?r.__aiResolved.operations:[],g=Qt(f);if(g.length!==1)return"";var A=f[g[0]];return A&&A.type?A.type:""}function lt(){var f=r.__aiResolved||null,g=f&&f.operations?f.operations:[],A=Qt(g),q=r.__aiSourceScope==="selection"?"selection":"document",O=cr(r.__aiSnapshot,q),se=!!(r.__aiSnapshot&&r.__aiSnapshot.hasSelection),fe=!!E($.value),ae=wr(f,q,O),Ne=br(g,A);return{hasSource:!!E(W.value),hasResult:fe,hasSelection:se,isStale:!!r.__aiPlanStale,requestedScope:q,scope:O,actionScope:ae,staleAction:r.__aiPlanStaleAction==="source"?"source":"editor",operations:g,pendingIndexes:A,pendingSelectionDependent:Ne,canApplyPlan:!!A.length&&(!Ne||se),canPreview:fe&&ae==="selection"&&se,canReplaceSelection:fe&&ae==="selection"&&se,canInsert:fe,canReplaceDocument:fe&&ae==="document",pendingOperationType:A.length===1&&g[A[0]]&&g[A[0]].type?g[A[0]].type:""}}function st(f,g){if(g=g||lt(),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 $t(f,g){return g=g||lt(),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 Gr(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 Yt(f,g){if(f=f||lt(),!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"&&Gr(A,q,"preview",c.__aiT?c.__aiT("ai2_alt_preview","preview inline"):"preview inline"),f.hasSelection&&O!=="replace-selection"&&Gr(A,q,"selection",c.__aiT?c.__aiT("ai2_alt_selection","replace the selection"):"replace the selection"),f.canInsert&&O!=="insert-below"&&Gr(A,q,"insert",c.__aiT?c.__aiT("ai2_alt_insert","insert below"):"insert below"),A):(f.actionScope==="document"&&(f.canReplaceDocument&&O!=="replace-document"&&Gr(A,q,"document",c.__aiT?c.__aiT("ai2_alt_document","replace the document"):"replace the document"),f.canInsert&&O!=="insert-below"&&Gr(A,q,"insert",c.__aiT?c.__aiT("ai2_alt_insert","insert below"):"insert below")),A)}function Nn(f){f=f||lt();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 Ja(f,g){f=f||lt(),g=g||U(f);var A=g&&g.detail?(g.detail||"").replace(/\s+/g," ").trim():"",q=Ai(Yt(f,g));return q&&(A+=(A?" ":"")+"Other available actions: "+q+"."),A}function ua(f){if(!(!Q||!Q.appendChild)){var g=[te,Te,Se,Re,Fe,K,le,xe,I,ce,Lt];if(f&&f.button&&f.button.parentNode===Q){g=[f.button];for(var A=[te,Te,Se,Re,Fe,K,le,xe,I,ce,Lt],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 Oi(f,g,A,q){if(f){var O=(f.innerText||f.textContent||"").replace(/\s+/g," ").trim()||$t(g,A)||"Action",se=st(g,A),fe=q?{actionId:g,label:O,detail:se}:null,ae=fe?Ai(Yt(A,fe)):"",Ne=[O];se&&Ne.push(se),ae&&Ne.push(c.__aiT?c.__aiT("aid_otheractions","Other available actions: {0}.",ae):"Other available actions: "+ae+"."),q?(Ne.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",ve(Ne));var ot=[O];se&&ot.push(se),ae&&ot.push(c.__aiT?c.__aiT("aid_otheractions","Other available actions: {0}.",ae):"Other available actions: "+ae+"."),q&&ot.push(c.__aiT?c.__aiT("aid_recommended","Recommended next step."):"Recommended next step.");var vt=f.getAttribute&&f.getAttribute("aria-keyshortcuts");if(vt){var Lr=vt.replace(/Control\+/gi,"Ctrl+").replace(/Meta\+/gi,"Cmd+");ot.push("("+Lr+")")}f.title=ot.join(" - ")}}function U(f){f=f||lt();var g=!!E(dt(r.__aiSnapshot,"selection"))&&!!(r.__aiSnapshot&&r.__aiSnapshot.hasSelection),A=!!E(dt(r.__aiSnapshot,"document"));if(!f.hasSource){var q=f.scope==="selection"?M:V,O=f.scope==="selection"?"load-selection":"load-document",se=O==="load-selection"?g:A;if(se&&q&&!q.disabled)return{actionId:O,button:q,label:$t(O,f)||"Load source",detail:st(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:st("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:st("load-selection",f)}}return f.isStale&&Qe&&Qe.style.display!=="none"&&!Qe.disabled?{actionId:"rerun",button:Qe,label:(Qe.innerText||Qe.textContent||"").replace(/\s+/g," ").trim()||(f.staleAction==="source"?"Re-run from source":"Re-run from editor"),detail:st("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:st("run",f)}:f.pendingIndexes.length&&te&&!te.disabled?{actionId:"apply",button:te,label:(te.innerText||te.textContent||"").replace(/\s+/g," ").trim()||"Apply",detail:st("apply",f)}:Se&&Se.style.display!=="none"&&!Se.disabled?{actionId:"preview",button:Se,label:(Se.innerText||Se.textContent||"").replace(/\s+/g," ").trim()||"Preview",detail:st("preview",f)}:Te&&Te.style.display!=="none"&&!Te.disabled?{actionId:"selection",button:Te,label:(Te.innerText||Te.textContent||"").replace(/\s+/g," ").trim()||"Replace selection",detail:st("selection",f)}:Fe&&Fe.style.display!=="none"&&!Fe.disabled?{actionId:"document",button:Fe,label:(Fe.innerText||Fe.textContent||"").replace(/\s+/g," ").trim()||(c.__aiT?c.__aiT("ai2_repldoc","Replace document"):"Replace document"),detail:st("document",f)}:Re&&Re.style.display!=="none"&&!Re.disabled?{actionId:"insert",button:Re,label:(Re.innerText||Re.textContent||"").replace(/\s+/g," ").trim()||"Insert below",detail:st("insert",f)}:null}function rt(f){f=f||lt();var g=U(f);ua(g);for(var A=[M,V,j,Y,Qe,te,Te,Se,Re,Fe,Lt],q=0;q<A.length;q++){var O=A[q],se=O&&O.getAttribute?O.getAttribute("data-rte-ai-dialog-action")||(O===Qe?"rerun":""):"";Oi(O,se,f,!!(g&&O===g.button))}if(Q&&Q.classList){var fe=!!(g&&g.actionId&&g.actionId!=="apply"&&g.button&&g.button.parentNode===Q&&te&&te.disabled);Q.classList.toggle("is-alt-recommended",fe)}if(!g){$e.style.display="none",gr.innerText="",sr.innerText="",$e.setAttribute("aria-label",ne("aiu_norecommended","No recommended Ask AI follow-up action yet."));return}$e.style.display="",at.innerText=c.__aiT?c.__aiT("aid_bestnext","Best next step"):"Best next step",gr.innerText=g.label||"";var ae=Ja(f,g);sr.innerText=ae||"",$e.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 ke(){var f=r.__aiSourceScope||(r.__aiSnapshot&&r.__aiSnapshot.hasSelection?"selection":"document");xi(f),j.onclick()}function kt(){j.onclick()}function Gt(f,g){if(!f||!f.length)return!1;var A=Ca(f,{snapshot:r.__aiSnapshot,resolved:r.__aiResolved});return A&&(_t.innerText=g||"Applied the selected AI step."),A}function Zt(f){var g=f&&f.operations?f.operations:[],A=lt();Bt.innerHTML=__RTE_TT(""),ei.innerText=r.__aiPlanStale?r.__aiPlanStaleReason||"Editor changed. Re-run to refresh.":"";var q=r.__aiPlanStaleAction==="source"&&!E(W.value);if(Qe.innerText=r.__aiPlanStaleAction==="source"?"Re-run from source":"Re-run from editor",Qe.style.display=r.__aiPlanStale&&!q?"":"none",Qe.disabled=q,or.className=r.__aiPlanStale?"demo-ai-plan-status is-stale":"demo-ai-plan-status",!g.length){var O=o(Bt,"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."),qr.innerText="",Qe.style.display="none",te.disabled=!0,te.innerText=ne("aiu_apply","Apply");return}for(var se=0,fe=0,ae=0;ae<g.length;ae++){var Ne=g[ae],ot=_s(Ne),vt=o(Bt,"li","","demo-ai-plan-item"),Lr=o(vt,"div","","demo-ai-plan-header");o(Lr,"span","","demo-ai-plan-type",ot.title);var pt=ri(ae);pt&&(o(Lr,"span","","demo-ai-plan-state is-"+pt,pt==="done"?"Applied":"Skipped"),pt==="done"?se++:pt==="skipped"&&fe++);var ni=ot.copy;Ne.reason&&(ni+=" Reason: "+Ne.reason),o(vt,"span","","demo-ai-plan-copy",ni);var Si=o(vt,"div","","demo-ai-plan-actions");if(pt!=="done"){var Et=ft(Ne)&&!A.hasSelection,Ur=Et?ws([Ne]):ic(Ne),li=o(Si,"button","","secondary demo-ai-plan-button",Ur);li.type="button",li.disabled=!!r.__aiPlanStale||Et,ys(li,Ur,ac(Ne,A),r.__aiPlanStale?"Currently unavailable until Ask AI is rerun.":Et?"Currently unavailable until text is selected in the editor.":""),li.onclick=(function(ht,yt,er){return function(){Gt([yt],'Applied "'+er+'".')&&(Ir(ht,"done"),Ot('Applied "'+er+'". Re-run to refresh the remaining plan.',"editor"))}})(ae,Ne,ot.title)}if(pt!=="done"){var k=o(Si,"button","","secondary demo-ai-plan-button",pt==="skipped"?"Include step":"Skip step");k.type="button",k.disabled=!!r.__aiPlanStale,ys(k,k.innerText||k.textContent||"Skip step",pt==="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(ht,yt){return function(){Ir(ht,yt?"":"skipped"),_t.innerText=yt?"Included the step back into the pending AI plan.":"Skipped this step from the pending AI plan.",Zt(r.__aiResolved)}})(ae,pt==="skipped")}}for(var re=Qt(g),He=[],it=0;it<re.length;it++)He.push(g[re[it]]);qr.innerText=re.length+" pending \u2022 "+se+" applied \u2022 "+fe+" skipped",te.disabled=!re.length||!!r.__aiPlanStale||!A.canApplyPlan,r.__aiPlanStale?te.innerText=ne("aiu_rerunplan","Re-run to refresh plan"):re.length?A.pendingSelectionDependent&&!A.hasSelection?te.innerText=ws(He):re.length===g.length?te.innerText=bs(f):te.innerText=ne("aiu_applypending","Apply {0} pending steps",re.length):te.innerText=ne("aiu_nopending","No pending steps")}function dr(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,Qe.disabled=!!f,te.disabled=!!f||te.disabled,Te.disabled=!!f||Te.disabled,Se.disabled=!!f||Se.disabled,Re.disabled=!!f||Re.disabled,Fe.disabled=!!f||Fe.disabled,Lt.disabled=!!f||Lt.disabled;for(var q=Bt.querySelectorAll?Bt.querySelectorAll(".demo-ai-plan-button"):[],O=0;O<q.length;O++)q[O].disabled=!!f;K&&(K.disabled=!!f||!E($.value)),le&&(le.disabled=!!f||!E($.value)),xe&&(xe.disabled=!!f||!E($.value)),I&&(I.disabled=!!f),_e&&(_e.disabled=!!f),f?(j.classList.add("is-busy"),ge(j,"spinner",c.__aiT?c.__aiT("aic_thinking","Thinking..."):"Thinking...")):j.classList.remove("is-busy"),_t.innerText=A,rt()}function xi(f){r.__aiSourceScope=f==="selection"?"selection":"document",r.__aiSourceLinkedToEditor=!0,r.__aiSnapshot=ct(),W.value=dt(r.__aiSnapshot,r.__aiSourceScope),r.__aiLastLinkedSourceText=W.value,Ce(),Ar(),fr(),Mt()}function fr(){var f=lt(),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 se=f.pendingOperationType,fe=g||q?f.actionScope:f.scope,ae=fe==="selection"&&se!=="replace-selection",Ne=fe==="selection"&&se!=="preview-suggestion",ot=f.canInsert&&se!=="insert-below",vt=f.canReplaceDocument&&se!=="replace-document";Oe.innerText=E(W.value)||"Load text from the editor to start a preview.",tt.innerText=g?$.value:"Run Ask AI to generate a suggestion preview.";var Lr=wa(r.__aiResolved)||"";if(bt.innerText=Lr||"This suggestion does not include an explicit AI rationale yet.",Zt(r.__aiResolved),qe&&qe.style){var pt=r.__aiResolved,ni=pt&&pt.operations?pt.operations.length:0,Si=!!Lr||ni>1;qe.style.display=g&&Si?"":"none",!Si&&Ie&&Ie.classList&&!Ie.classList.contains("is-collapsed")&&(Ie.classList.add("is-collapsed"),qe.setAttribute("aria-expanded","false"))}if(Te.innerText=$t("selection",f)||"Replace selection",Se.innerText=$t("preview",f)||"Preview",Te.style.display=ae?"":"none",Se.style.display=Ne?"":"none",Re.style.display=ot?"":"none",Fe.style.display=vt?"":"none",ce){var Et=[];ae&&Et.push("Replace selection"),Ne&&Et.push("Preview"),ot&&Et.push("Insert below"),vt&&Et.push(c.__aiT?c.__aiT("ai2_repldoc","Replace document"):"Replace document");var Ur=Et.length,li=Ur>0;if(ce.style.display=li?"":"none",li){var k="More apply options ("+Ur+"): "+Et.join(", ");ce.title=k,ce.setAttribute("aria-label",k),ce.setAttribute("data-rte-ai-more-count",String(Ur))}!li&&Q.classList.contains("is-show-more")&&(Q.classList.remove("is-show-more"),ce.setAttribute("aria-expanded","false"))}Te.disabled=q||!f.canReplaceSelection,Se.disabled=q||!f.canPreview,Re.disabled=q||!f.canInsert,Fe.disabled=q||!f.canReplaceDocument,j.disabled=!A,Y.disabled=!g,Lt.disabled=!g;var re=g||q?c.__aiT?c.__aiT("aid_regenerate","Regenerate"):"Regenerate":c.__aiT?c.__aiT("aid_generate","Generate"):"Generate";ge(j,"sparkles",re),ue(),rt(f)}function $l(){if(!(!r.isConnected||s.__aiDialog!==r)){var f=r.__aiSourceScope==="selection"?"selection":"document",g=!!r.__aiSourceLinkedToEditor,A=r.__aiSnapshot||ct(),q=ct(),O=dt(A,f),se=dt(q,f),fe=f==="selection"&&(!!A.hasSelection!=!!q.hasSelection||!sl(A.range,q.range)||O!==se),ae=f==="document"?(A.wholeText||"")!==(q.wholeText||""):fe,Ne=ae||!!A.hasSelection!=!!q.hasSelection;if(r.__aiSnapshot=q,g&&(r.__aiLastLinkedSourceText=se),!!Ne){if(Ar(),g){if(W.value=se,Ce(),ae&&E($.value)&&!r.__aiPlanStale){Ot(Je(f,q,A),"editor");return}}else if(ae&&E($.value)&&!r.__aiPlanStale){Ot(Tr(f,q,A),"source");return}fr(),Mt()}}}function Ti(){if($a(),Ce(),E($.value)){Ot(Be(W.value),"source");return}fr(),Mt()}function Gi(f){if(E($.value)){Ot(f,"source");return}fr()}function Va(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 se=E(W.value);if(A!==g){Ot(jr(g),"editor");return}(!O||q!==se)&&Ot(Ct(g),"editor")}}M.onclick=function(){Va("selection")},V.onclick=function(){Va("document")},C&&(C.onchange=function(){Va(C.value)}),Qe.onclick=function(){if(r.__aiPlanStaleAction==="source"){kt();return}ke()},v.onchange=function(){Mt(),Gi(ai())},b.onchange=function(){Mt(),Gi(Ve(b.value))},j.onclick=function(){var f=ct();if(r.__aiSnapshot=f,r.__aiSourceLinkedToEditor&&(W.value=dt(f,r.__aiSourceScope),r.__aiLastLinkedSourceText=W.value,Ce()),Ar(),!E(W.value)){_t.innerText=ne("aiu_loadsource","Load or type source text before running Ask AI."),fr();return}dr(!0,""),ln(v.value,{snapshot:f,source:W.value,scope:Hr(f),mode:v.value,language:b.value}).then(function(g){r.__aiResolved=g,r.__aiOperationStates={},r.__aiPlanStale=!1,r.__aiPlanStaleReason="",r.__aiPlanStaleAction="",$.value=Jt(g)||"",fr(),dr(!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="",fr(),dr(!1,"AI suggestion failed.")})},Y.onclick=function(){E($.value)&&(W.value=$.value,Ti())},W.oninput=function(){Ti()},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=Qt(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++)Ir(g[O],"done");r.close()}},Te.onclick=function(){pr(zr($.value,"selection",ur("selection"),r.__aiResolved?r.__aiResolved.request:null,r.__aiResolved?r.__aiResolved.action:null),{snapshot:r.__aiSnapshot})&&r.close()},Se.onclick=function(){var f=zr($.value,"selection-preview",ur("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=wa(r.__aiResolved)),pr(f,{snapshot:r.__aiSnapshot})&&r.close()},Re.onclick=function(){pr(zr($.value,"insert",ur("insert"),r.__aiResolved?r.__aiResolved.request:null,r.__aiResolved?r.__aiResolved.action:null),{snapshot:r.__aiSnapshot})&&r.close()},Fe.onclick=function(){pr(zr($.value,"document",ur("document"),r.__aiResolved?r.__aiResolved.request:null,r.__aiResolved?r.__aiResolved.action:null),{snapshot:r.__aiSnapshot})&&r.close()},Lt.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=$l,tu(),xi(e.useDocument?"document":t.hasSelection?"selection":"document"),fr(),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{}}}
|