/*!
 * Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see https://ckeditor.com/legal/ckeditor-oss-license
 */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.CKEditor5=t():(e.CKEditor5=e.CKEditor5||{},e.CKEditor5.disableCollaborationMarkersInCaption=t())}(self,(()=>(()=>{"use strict";var e={d:(t,o)=>{for(var a in o)e.o(o,a)&&!e.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:o[a]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};e.d(t,{default:()=>o});const o={DisableCollaborationMarkersInCaption:class{constructor(e){this.editor=e}afterInit(){const e=this.editor,t=e.commands.get("addCommentThread"),o=e.commands.get("trackChanges");e.set("disabledCommands",!1);const a=e.plugins.has("CommentsRepository"),r=e.plugins.has("TrackChangesEditing"),i=e.plugins.has("DrupalImage");if(!a&&!r||!i)return;if(r){const t=e.plugins.get("TrackChangesEditing");if(!this.editor.commands.get("toggleImageCaption"))try{t.enableCommand("toggleImageCaption",((e,t)=>{e(t)}),{priority:"high"})}catch(e){return}}if(o){const e=this.editor.commands.get("toggleImageCaption");o.on("change:value",((t,o,a)=>{a?e.forceDisabled("drupal-premium-features"):e.clearForceDisabled("drupal-premium-features")}))}let s;e.model.document.on("change",(()=>{!e.disabledCommands&&o&&(s=o.value)}),{priority:"highest"}),e.model.document.on("change",(()=>{"caption"===e.model.document.selection.getFirstRange().getCommonAncestor().name?(t&&t.forceDisabled("drupal-premium-features"),o&&(o.value=!1,o.forceDisabled("drupal-premium-features")),e.set("disabledCommands",!0)):e.disabledCommands&&(t&&t.clearForceDisabled("drupal-premium-features"),o&&o.clearForceDisabled("drupal-premium-features"),e.set("disabledCommands",!1),s&&o&&(o.value=!0))}),{priority:"low"})}}};return t=t.default})()));