/*!
 * 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.realtimeRevisionHistoryAdapter=t())}(self,(()=>(()=>{"use strict";var e={d:(t,i)=>{for(var r in i)e.o(i,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:i[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};e.d(t,{default:()=>r});const i=class{constructor(e){this.editor=e,this.elementId=this.editor.sourceElement.dataset.ckeditor5PremiumElementId}processCollaborationCommandDisable(e){if(!this.isCollaborationDisabled())return!1;const t=this.editor.commands._commands.get(e);return void 0===t||t.forceDisabled("premium-features-module"),!0}processRevisionDisable(){return!!this.isCollaborationDisabled()&&(this.editor.plugins.has("RevisionTracker")&&(this.editor.plugins.get("RevisionTracker").isEnabled=!1),!0)}isCollaborationDisabled(){return void 0!==drupalSettings.ckeditor5Premium&&void 0!==drupalSettings.ckeditor5Premium.disableCollaboration&&!0===drupalSettings.ckeditor5Premium.disableCollaboration}getEditorParentContainer(e){let t=document.getElementById(e);for(;t&&void 0!==t&&void 0!==t.classList&&!t.classList.contains("ck-editor-container");)t=t.parentElement;return t&&void 0!==t?t.parentElement:null}getSourceDataSelector(e){return{trackChanges:".track-changes",comments:".comments",revisionHistory:".revision-history",revisionHistoryContainer:".revision-history-container",resolvedSuggestionsComments:".resolved-suggestions-comments"}[e]+"-data"+`[data-ckeditor5-premium-element-id="${this.elementId}"]`}};const r={RealtimeRevisionHistoryAdapter:class{constructor(e){this.editor=e,this.storage=new i(e)}static get pluginName(){return"RealtimeRevisionHistoryAdapter"}static get requires(){return["RevisionTracker"]}afterInit(){this.elementId=this.editor.sourceElement.dataset.ckeditor5PremiumElementId;const e=this.editor.config._config.revisionHistory;e.viewerContainer=document.querySelector(`.revision-history-container-data[data-ckeditor5-premium-element-id="${this.elementId}"]`),e.viewerEditorElement=e.viewerContainer.querySelector(".revision-viewer-editor"),e.viewerSidebarContainer=e.viewerContainer.querySelector(".revision-viewer-sidebar"),e.editorContainer=e.viewerContainer.parentElement.querySelector(".ck-editor-premium-wrapper").parentElement;const t=this.editor.plugins.get("RevisionHistory"),i=this.editor.plugins.get("RevisionTracker");this.editor.sourceElement.closest("form").addEventListener("submit",(e=>{this.updateStorage(t,i)})),this.storage.processRevisionDisable(),this.handleRevisionHistoryActiveClass(e)}async updateStorage(e,t){await t.update(),await t.saveRevision({name:"Entity save"})}handleRevisionHistoryActiveClass(e){new IntersectionObserver((function(t){0==t[0].intersectionRatio?e.editorContainer.parentElement.classList.add("revision-history-active"):e.editorContainer.parentElement.classList.remove("revision-history-active")}),{root:document.documentElement}).observe(e.editorContainer)}}};return t=t.default})()));