@richscripts/richtexteditor 2.12.1 → 2.14.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/package.json +1 -1
- package/richtexteditor/all_plugins.js +211 -6
- package/richtexteditor/all_plugins.min.js +47 -47
- package/richtexteditor/plugins/a11yenhance.min.js +1 -0
- package/richtexteditor/plugins/accessibilitychecker.js +168 -0
- package/richtexteditor/plugins/accessibilitychecker.min.js +1 -0
- package/richtexteditor/plugins/aitoolkit.min.js +14 -0
- package/richtexteditor/plugins/all_plugins.js +211 -6
- package/richtexteditor/plugins/all_plugins.min.js +47 -47
- package/richtexteditor/plugins/autocorrect.min.js +1 -0
- package/richtexteditor/plugins/autoembed.min.js +1 -0
- package/richtexteditor/plugins/blocktypes.min.js +2 -0
- package/richtexteditor/plugins/bookmarkcard.min.js +2 -0
- package/richtexteditor/plugins/changecase.min.js +1 -0
- package/richtexteditor/plugins/charlimit.min.js +2 -0
- package/richtexteditor/plugins/comments.min.js +3 -0
- package/richtexteditor/plugins/contentminimap.min.js +1 -0
- package/richtexteditor/plugins/crossreference.min.js +1 -0
- package/richtexteditor/plugins/dialoga11y.min.js +1 -0
- package/richtexteditor/plugins/dictation.min.js +1 -0
- package/richtexteditor/plugins/documentimport.min.js +4 -0
- package/richtexteditor/plugins/documentoutline.js +43 -6
- package/richtexteditor/plugins/documentoutline.min.js +1 -0
- package/richtexteditor/plugins/docxexport.min.js +2 -0
- package/richtexteditor/plugins/draghandle.min.js +1 -0
- package/richtexteditor/plugins/emailtoolkit.min.js +1 -0
- package/richtexteditor/plugins/emojiautocomplete.min.js +1 -0
- package/richtexteditor/plugins/foldheadings.min.js +1 -0
- package/richtexteditor/plugins/footnotes.min.js +1 -0
- package/richtexteditor/plugins/formatpainter.min.js +1 -0
- package/richtexteditor/plugins/formattingmarks.min.js +1 -0
- package/richtexteditor/plugins/gapcursor.min.js +1 -0
- package/richtexteditor/plugins/ghostcomplete.min.js +1 -0
- package/richtexteditor/plugins/html2pdf.min.js +1 -0
- package/richtexteditor/plugins/imageeditor.min.js +1 -0
- package/richtexteditor/plugins/importstyles.min.js +1 -0
- package/richtexteditor/plugins/inlinecode.min.js +1 -0
- package/richtexteditor/plugins/insertcode.min.js +8 -0
- package/richtexteditor/plugins/insertemoji.min.js +1 -0
- package/richtexteditor/plugins/insertgallery.min.js +1 -0
- package/richtexteditor/plugins/inserttemplate.min.js +1 -0
- package/richtexteditor/plugins/keyboarda11y.min.js +1 -0
- package/richtexteditor/plugins/layouttable.min.js +1 -0
- package/richtexteditor/plugins/linenumbers.min.js +1 -0
- package/richtexteditor/plugins/linkchecker.min.js +1 -0
- package/richtexteditor/plugins/localdraft.min.js +1 -0
- package/richtexteditor/plugins/markdownexport.min.js +2 -0
- package/richtexteditor/plugins/mathdialog.min.js +1 -0
- package/richtexteditor/plugins/mentionplugin.min.js +3 -0
- package/richtexteditor/plugins/mergefields.min.js +1 -0
- package/richtexteditor/plugins/mermaiddiagram.min.js +16 -0
- package/richtexteditor/plugins/multilevellist.min.js +1 -0
- package/richtexteditor/plugins/multiroot.min.js +1 -0
- package/richtexteditor/plugins/nodetypes.min.js +1 -0
- package/richtexteditor/plugins/pagination.min.js +1 -0
- package/richtexteditor/plugins/pdfexport.min.js +19 -0
- package/richtexteditor/plugins/permanentpen.min.js +1 -0
- package/richtexteditor/plugins/readabilitystats.min.js +1 -0
- package/richtexteditor/plugins/readaloud.min.js +1 -0
- package/richtexteditor/plugins/restrictedediting.min.js +2 -0
- package/richtexteditor/plugins/revisionhistory.min.js +3 -0
- package/richtexteditor/plugins/rtlui.min.js +2 -0
- package/richtexteditor/plugins/rubyannotation.min.js +1 -0
- package/richtexteditor/plugins/sanitizer.min.js +1 -0
- package/richtexteditor/plugins/shadowdom.min.js +1 -0
- package/richtexteditor/plugins/slashcommand.min.js +2 -0
- package/richtexteditor/plugins/smartchips.min.js +2 -0
- package/richtexteditor/plugins/spellcheck.min.js +2 -0
- package/richtexteditor/plugins/stateinspector.min.js +2 -0
- package/richtexteditor/plugins/structured-content-bridge.js +5178 -0
- package/richtexteditor/plugins/structured-content-bridge.min.js +19 -0
- package/richtexteditor/plugins/tableofcontents.min.js +1 -0
- package/richtexteditor/plugins/tabletools.min.js +1 -0
- package/richtexteditor/plugins/textdirection.min.js +1 -0
- package/richtexteditor/plugins/textpartlanguage.min.js +1 -0
- package/richtexteditor/plugins/todolist.min.js +1 -0
- package/richtexteditor/plugins/trackedchanges.min.js +3 -0
- package/richtexteditor/plugins/typewriter.min.js +1 -0
- package/richtexteditor/plugins/watermark.min.js +1 -0
- package/richtexteditor/plugins/wordexport.min.js +23 -0
- package/richtexteditor/plugins/yjscollab.min.js +2 -0
- package/richtexteditor/plugins/zz_richtextbox_dialog_style.min.js +1 -0
- package/richtexteditor/rte-config.js +2 -0
- package/richtexteditor/rte.js +4 -2
|
@@ -0,0 +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(`
|
|
2
|
+
|
|
3
|
+
`))>=0;){var h=f.slice(0,b);f=f.slice(b+2),g(h)}return p()})}function g(m){for(var b="message",h=[],y=m.split(`
|
|
4
|
+
`),A=0;A<y.length;A++){var K=y[A];K.indexOf("event:")===0?b=K.slice(6).trim():K.indexOf("data:")===0&&h.push(K.slice(5).trim())}if(h.length!==0){var S=h.join(`
|
|
5
|
+
`),q;try{q=JSON.parse(S)}catch{q=S}if(b==="message"){var M=typeof q=="string"?q:"";M&&(a+=M,e.onDelta&&e.onDelta(M,a))}else b==="response"?e.onResponse&&e.onResponse(q):b==="error"&&e.onError&&e.onError(q)}}return p()}).catch(function(n){if(n&&n.name==="AbortError")return a;throw e.onError&&e.onError(n),n})})();return{promise:l,abort:function(){i&&i.abort()}}}function pu(e,t,r){var i=r&&r.fallbackUrl||e.replace(/\/stream$/,"");return new Promise(function(a,l){var n=new XMLHttpRequest;n.open("POST",i,!0),n.setRequestHeader("Content-Type","application/json"),n.onload=function(){if(n.status>=200&&n.status<300){var u;try{u=JSON.parse(n.responseText)}catch{u=n.responseText}var c="";u&&u.operations&&u.operations.length?c=u.operations[0].text||"":u&&u.message&&(c=u.message),r&&r.onDelta&&c&&r.onDelta(c,c),r&&r.onResponse&&u&&typeof u=="object"&&r.onResponse(u),r&&r.onDone&&r.onDone(c),a(c)}else{var f=new Error("AI request failed: HTTP "+n.status);r&&r.onError&&r.onError(f),l(f)}},n.onerror=function(){var u=new Error("AI request network error");r&&r.onError&&r.onError(u),l(u)},n.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 l=new Error("exportDocx: editor content is empty.");return e.onError&&e.onError(l),Promise.reject(l)}if(typeof fetch!="function"){var n=new Error("exportDocx requires fetch + Blob support.");return e.onError&&e.onError(n),Promise.reject(n)}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 c=URL.createObjectURL(u),f=document.createElement("a");return f.href=c,f.download=a,document.body.appendChild(f),f.click(),document.body.removeChild(f),setTimeout(function(){try{URL.revokeObjectURL(c)}catch{}},4e3),a}).catch(function(u){throw e.onError&&e.onError(u),u})}function gu(e){e=e||{};var t=e.url||"/richtextbox/import/docx",r=e.mode==="insert"?"insert":"replace";function i(l){return l&&(l.html||l.content)||""}function a(l){if(typeof fetch!="function"||typeof FormData!="function"){var n=new Error("importDocx requires fetch + FormData support.");return e.onError&&e.onError(n),Promise.reject(n)}var u=new FormData;return u.append("file",l,l.name||"document.docx"),u.append("mode",r),fetch(t,{method:"POST",body:u,credentials:"same-origin"}).then(function(c){if(!c.ok)throw new Error("importDocx failed: HTTP "+c.status);return c.json().then(i)}).then(function(c){if(c)return r==="insert"&&s&&s.insertHTML?s.insertHTML(c):s&&s.setHTMLCode&&s.setHTMLCode(c),c}).catch(function(c){throw e.onError&&e.onError(c),c})}return e.file?a(e.file):new Promise(function(l,n){if(typeof document>"u")return n(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 c=u.files&&u.files[0];if(document.body.removeChild(u),!c)return l(void 0);a(c).then(l,n)},document.body.appendChild(u),u.click()})}function R(e){return(e||"").replace(/\r\n/g,`
|
|
6
|
+
`).replace(/[ \t]+\n/g,`
|
|
7
|
+
`).replace(/\n{3,}/g,`
|
|
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)+`
|
|
10
|
+
|
|
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+`
|
|
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{}}}
|