rumine-web/static/wagtailadmin/js/comments.js

1 line
52 KiB
JavaScript
Raw Normal View History

2024-03-13 07:49:06 +01:00
(()=>{"use strict";var e,t={3244:(e,t,n)=>{var o=n(9408),r=n(7647),i=n.n(r),s=n(3416),c=n.n(s);function a(e){return"Minified Redux error #"+e+"; visit https://redux.js.org/Errors?code="+e+" for the full message or use the non-minified dev environment for full errors. "}var l="function"==typeof Symbol&&Symbol.observable||"@@observable",m=function(){return Math.random().toString(36).substring(7).split("").join(".")},u={INIT:"@@redux/INIT"+m(),REPLACE:"@@redux/REPLACE"+m(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+m()}};function d(e,t,n){var o;if("function"==typeof t&&"function"==typeof n||"function"==typeof n&&"function"==typeof arguments[3])throw new Error(a(0));if("function"==typeof t&&void 0===n&&(n=t,t=void 0),void 0!==n){if("function"!=typeof n)throw new Error(a(1));return n(d)(e,t)}if("function"!=typeof e)throw new Error(a(2));var r=e,i=t,s=[],c=s,m=!1;function p(){c===s&&(c=s.slice())}function f(){if(m)throw new Error(a(3));return i}function h(e){if("function"!=typeof e)throw new Error(a(4));if(m)throw new Error(a(5));var t=!0;return p(),c.push(e),function(){if(t){if(m)throw new Error(a(6));t=!1,p();var n=c.indexOf(e);c.splice(n,1),s=null}}}function y(e){if(!function(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}(e))throw new Error(a(7));if(void 0===e.type)throw new Error(a(8));if(m)throw new Error(a(9));try{m=!0,i=r(i,e)}finally{m=!1}for(var t=s=c,n=0;n<t.length;n++)(0,t[n])();return e}return y({type:u.INIT}),(o={dispatch:y,subscribe:h,getState:f,replaceReducer:function(e){if("function"!=typeof e)throw new Error(a(10));r=e,y({type:u.REPLACE})}})[l]=function(){var e,t=h;return(e={subscribe:function(e){if("object"!=typeof e||null===e)throw new Error(a(11));function n(){e.next&&e.next(f())}return n(),{unsubscribe:t(n)}}})[l]=function(){return this},e},o}function p(e,t,n){const o=e.get(t);return void 0===o?n:o}class f{commentElements=new Map;commentAnnotations=new Map;commentTabs=new Map;commentDesiredPositions=new Map;commentHeights=new Map;pinnedComment=null;commentCalculatedPositions=new Map;isDirty=!1;setCommentElement(e,t){null!==t?this.commentElements.set(e,t):this.commentElements.delete(e),this.isDirty=!0}setCommentAnnotation(e,t){this.commentAnnotations.set(e,t),this.commentTabs.set(e,t.getTab()||null),this.updateDesiredPosition(e),this.isDirty=!0}setCommentHeight(e,t){this.commentHeights.get(e)!==t&&(this.commentHeights.set(e,t),this.isDirty=!0)}setPinnedComment(e){this.pinnedComment=e,this.isDirty=!0}updateDesiredPosition(e){const t=this.commentAnnotations.get(e);if(!t)return;const n=t.getAnchorNode(e===this.pinnedComment);let o=n.getBoundingClientRect().top,r=n.parentElement;for(;r;)o+=r.scrollTop,r=r.parentElement;this.commentDesiredPositions.set(e,0!==o?o+-50:0)}refreshDesiredPositions(e=null){const t=new Map(this.commentDesiredPositions);this.commentAnnotations.forEach(((t,n)=>{this.getCommentTabVisible(e,n)&&this.updateDesiredPosition(n)})),this.commentDesiredPositions!==t&&(this.isDirty=!0)}refreshLayout(){if(!this.isDirty)return!1;const e=Array.from(this.commentElements.keys()).map((e=>({tab:p(this.commentTabs,e,null),position:p(this.commentDesiredPositions,e,0),height:p(this.commentHeights,e,0),comments:[e],containsPinnedComment:null!==this.pinnedComment&&e===this.pinnedComment,pinnedCommentPosition:0}))),t=new Map;e.forEach((e=>{const n=t.get(e.tab)||[];n.push(e),t.set(e.tab,n)}));const n=this.pinnedComment?this.commentDesiredPositions.get(this.pinnedComment):void 0,o=this.pinnedComment?this.commentTabs.get(this.pinnedComment):void 0;return Array.from(t.entries()).forEach((([e,t])=>{const r=this.pinnedComment&&o===e;t.sort(((e,t)=>e.position-t.position));let i=t,s=!0;for(;s;){s=!1;const e=[];let t=null;for(const o of i)t&&t.position+t.height+20>o.position?(s=!0,t.comments.push(...o.comments),o.containsPinnedComment&&(t.containsPinnedComment=!0,t.pinnedCommentPosition=o.pinnedCommentPosition+t.height),t.height+=o.height,!r&&t.position<50&&(t.position=100+t.height- -50),