diff --git a/Build/Sources/TypeScript/backend/context-menu.ts b/Build/Sources/TypeScript/backend/context-menu.ts
index 7c1839d880b81954361eade1ad125eced37c87f5..65dd7108ad0cd5b6c8bda757ed768f5a4fe21e7e 100644
--- a/Build/Sources/TypeScript/backend/context-menu.ts
+++ b/Build/Sources/TypeScript/backend/context-menu.ts
@@ -16,7 +16,6 @@ import AjaxRequest from '@typo3/core/ajax/ajax-request';
 import ContextMenuActions from './context-menu-actions';
 import DebounceEvent from '@typo3/core/event/debounce-event';
 import RegularEvent from '@typo3/core/event/regular-event';
-import ThrottleEvent from '@typo3/core/event/throttle-event';
 import { selector } from '@typo3/core/literals';
 
 interface MousePosition {
@@ -59,9 +58,6 @@ class ContextMenu {
     document.addEventListener('contextmenu', (event: PointerEvent) => {
       this.handleTriggerEvent(event);
     });
-
-    // register mouse movement inside the document
-    new ThrottleEvent('mousemove', this.storeMousePositionEvent.bind(this), 50).bindTo(document);
   }
 
   /**
@@ -114,8 +110,17 @@ class ContextMenu {
    * @param {string} unusedParam1
    * @param {string} unusedParam2
    * @param {HTMLElement} eventSource Source Element
+   * @param {Event} originalEvent
    */
-  public show(table: string, uid: number|string, context: string, unusedParam1: string, unusedParam2: string, eventSource: HTMLElement = null): void {
+  public show(
+    table: string,
+    uid: number|string,
+    context: string,
+    unusedParam1: string,
+    unusedParam2: string,
+    eventSource: HTMLElement = null,
+    originalEvent: PointerEvent = null
+  ): void {
     this.hideAll();
 
     this.record = { table: table, uid: uid };
@@ -137,7 +142,12 @@ class ContextMenu {
       parameters.set('context', context);
     }
 
-    this.fetch(parameters.toString());
+    let position: MousePosition = null;
+    if (originalEvent !== null) {
+      this.storeMousePosition(originalEvent);
+      position = this.mousePos;
+    }
+    this.fetch(parameters.toString(), position);
   }
 
   /**
@@ -161,7 +171,7 @@ class ContextMenu {
       document.querySelectorAll('.context-menu').forEach((contextMenu: Element): void => {
         // Explicitly update cursor position if element is entered to avoid timing issues
         new RegularEvent('mouseenter', (event: MouseEvent): void => {
-          this.storeMousePositionEvent(event);
+          this.storeMousePosition(event);
         }).bindTo(contextMenu);
 
         new DebounceEvent('mouseleave', (event: MouseEvent) => {
@@ -217,7 +227,8 @@ class ContextMenu {
         element.dataset.contextmenuContext ?? '',
         '',
         '',
-        element
+        element,
+        event
       );
     }
   }
@@ -227,12 +238,12 @@ class ContextMenu {
    *
    * @param {string} parameters Parameters sent to the server
    */
-  private fetch(parameters: string): void {
+  private fetch(parameters: string, position: MousePosition): void {
     const url = TYPO3.settings.ajaxUrls.contextmenu;
     (new AjaxRequest(url)).withQueryArguments(parameters).get().then(async (response: AjaxResponse): Promise<void> => {
       const data: MenuItems = await response.resolve();
       if (typeof response !== 'undefined' && Object.keys(response).length > 0) {
-        this.populateData(data, 0);
+        this.populateData(data, 0, position);
       }
     });
   }
@@ -243,8 +254,9 @@ class ContextMenu {
    *
    * @param {MenuItems} items The data that will be put in the menu
    * @param {number} level The depth of the context menu
+   * @param {MousPosition}
    */
-  private populateData(items: MenuItems, level: number): void {
+  private populateData(items: MenuItems, level: number, position: MousePosition): void {
     this.initializeContextMenuContainer();
 
     const contentMenuCurrent = document.querySelector('#contentMenu' + level) as HTMLElement;
@@ -260,9 +272,11 @@ class ContextMenu {
       contentMenuCurrent.innerHTML = '';
       contentMenuCurrent.appendChild(menuGroup);
       contentMenuCurrent.style.display = null;
-      const position = this.getPosition(contentMenuCurrent);
-      contentMenuCurrent.style.top = position.top;
-      contentMenuCurrent.style.insetInlineStart = position.start;
+      position ??= this.getPosition(contentMenuCurrent);
+      const coordinates = this.toPixel(position);
+
+      contentMenuCurrent.style.top = coordinates.top;
+      contentMenuCurrent.style.insetInlineStart = coordinates.start;
       (contentMenuCurrent.querySelector('.context-menu-item[tabindex="-1"]') as HTMLElement).focus();
       this.initializeEvents(contentMenuCurrent, level);
     }
@@ -270,7 +284,7 @@ class ContextMenu {
 
   private initializeEvents(contentMenu: HTMLElement, level: number) {
     contentMenu.querySelectorAll('li.context-menu-item').forEach((element: HTMLElement) => {
-      // clock
+      // click
       element.addEventListener('click', (event: PointerEvent): void => {
         event.preventDefault();
         const target = event.currentTarget as HTMLElement;
@@ -407,7 +421,7 @@ class ContextMenu {
     contentMenu.appendChild(item.nextElementSibling.querySelector('.context-menu-group').cloneNode(true));
     contentMenu.style.display = null;
 
-    const position = this.getPosition(contentMenu);
+    const position = this.toPixel(this.getPosition(contentMenu));
     contentMenu.style.top = position.top;
     contentMenu.style.insetInlineStart = position.start;
     (contentMenu.querySelector('.context-menu-item[tabindex="-1"]') as HTMLElement).focus();
@@ -415,7 +429,11 @@ class ContextMenu {
     this.initializeEvents(contentMenu, level);
   }
 
-  private getPosition(element: HTMLElement): { start: string; top: string; } {
+  private toPixel(position: MousePosition): { start: string; top: string; } {
+    return { start: Math.round(position.X) + 'px', top: Math.round(position.Y) + 'px' };
+  }
+
+  private getPosition(element: HTMLElement): MousePosition {
 
     const space = 10;
     const offset = 5;
@@ -465,7 +483,7 @@ class ContextMenu {
       start += offset;
     }
 
-    return { start: Math.round(start) + 'px', top: Math.round(top) + 'px' };
+    return { X: start, Y: top };
   }
 
   /**
@@ -521,13 +539,9 @@ class ContextMenu {
     return elements;
   }
 
-  /**
-   * event handler function that saves the actual position of the
-   * mouse in the context menu object
-   */
-  private readonly storeMousePositionEvent = (event: MouseEvent): void => {
+  private storeMousePosition(event: MouseEvent): void {
     this.mousePos = { X: event.pageX, Y: event.pageY };
-  };
+  }
 
   private hide(element: HTMLElement|null): void {
     if (element === null) {
diff --git a/Build/Sources/TypeScript/backend/tree/file-storage-tree-container.ts b/Build/Sources/TypeScript/backend/tree/file-storage-tree-container.ts
index 470f416d2690cdcb05496fc1152abd2426442a1c..2cf5a6d8133eb418953abf2ad91368a0a15bf702 100644
--- a/Build/Sources/TypeScript/backend/tree/file-storage-tree-container.ts
+++ b/Build/Sources/TypeScript/backend/tree/file-storage-tree-container.ts
@@ -356,7 +356,8 @@ export class FileStorageTreeNavigationComponent extends LitElement {
       'tree',
       '',
       '',
-      this.tree.getElementFromNode(node)
+      this.tree.getElementFromNode(node),
+      evt.detail.originalEvent as PointerEvent
     );
   };
 
diff --git a/Build/Sources/TypeScript/backend/tree/page-tree-element.ts b/Build/Sources/TypeScript/backend/tree/page-tree-element.ts
index 57c16d5df6248869907e2405c7f302bf992cce31..16dd4640c80195729b0053af6a1fbb4e6e6ce1bf 100644
--- a/Build/Sources/TypeScript/backend/tree/page-tree-element.ts
+++ b/Build/Sources/TypeScript/backend/tree/page-tree-element.ts
@@ -456,7 +456,8 @@ export class PageTreeNavigationComponent extends LitElement {
       'tree',
       '',
       '',
-      this.tree.getElementFromNode(node)
+      this.tree.getElementFromNode(node),
+      evt.detail.originalEvent as PointerEvent
     );
   };
 
diff --git a/Build/Sources/TypeScript/backend/tree/tree.ts b/Build/Sources/TypeScript/backend/tree/tree.ts
index 05ee45c52796382dee894be9b98b9666f414ad00..74b43bcecfa6e30cda7273fa1664fc518428c5fb 100644
--- a/Build/Sources/TypeScript/backend/tree/tree.ts
+++ b/Build/Sources/TypeScript/backend/tree/tree.ts
@@ -615,7 +615,7 @@ export class Tree extends LitElement {
             @dblclick="${(event: PointerEvent) => { this.handleNodeDoubleClick(event, node); }}"
             @focusin="${() => { this.focusedNode = node; }}"
             @focusout="${() => { if (this.focusedNode === node) { this.focusedNode = null; } }}"
-            @contextmenu="${(event: MouseEvent) => { event.preventDefault(); event.stopPropagation(); this.dispatchEvent(new CustomEvent('typo3:tree:node-context', { detail: { node: node } })); }}"
+            @contextmenu="${(event: MouseEvent) => { event.preventDefault(); event.stopPropagation(); this.dispatchEvent(new CustomEvent('typo3:tree:node-context', { detail: { node, originalEvent: event } })); }}"
           >
             ${this.createNodeLabel(node)}
             ${this.createNodeGuides(node)}
@@ -1005,7 +1005,7 @@ export class Tree extends LitElement {
     return this.settings.showIcons
       ? html`
         <span class="node-icon"
-          @click="${(event: PointerEvent) => { event.preventDefault(); event.stopImmediatePropagation(); this.dispatchEvent(new CustomEvent('typo3:tree:node-context', { detail: { node: node } })) }}"
+          @click="${(event: PointerEvent) => { event.preventDefault(); event.stopImmediatePropagation(); this.dispatchEvent(new CustomEvent('typo3:tree:node-context', { detail: { node: node, originalEvent: event } })) }}"
           @dblclick="${(event: PointerEvent) => { event.preventDefault(); event.stopImmediatePropagation(); }}"
         >
           <typo3-backend-icon
diff --git a/Build/Sources/TypeScript/filelist/file-list.ts b/Build/Sources/TypeScript/filelist/file-list.ts
index 994333a2f76370ff5191dae71e5134f10c3d285c..898d0ceb0145d2ddb1ca1b862f98abb3929d536a 100644
--- a/Build/Sources/TypeScript/filelist/file-list.ts
+++ b/Build/Sources/TypeScript/filelist/file-list.ts
@@ -110,7 +110,7 @@ export default class Filelist {
     new RegularEvent(FileListActionEvent.primaryContextmenu, (event: CustomEvent): void => {
       const detail: FileListActionDetail = event.detail;
       const resource = detail.resources[0];
-      ContextMenu.show('sys_file', resource.identifier, '', '', '', detail.trigger);
+      ContextMenu.show('sys_file', resource.identifier, '', '', '', detail.trigger, detail.event as PointerEvent);
     }).bindTo(document);
 
     new RegularEvent(FileListActionEvent.show, (event: CustomEvent): void => {
diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/context-menu.js b/typo3/sysext/backend/Resources/Public/JavaScript/context-menu.js
index 4f58992f1dfc34480b6faabcefaab3c279f89820..33f13dbce778a49a22161e355ffd815fbb8fb1bd 100644
--- a/typo3/sysext/backend/Resources/Public/JavaScript/context-menu.js
+++ b/typo3/sysext/backend/Resources/Public/JavaScript/context-menu.js
@@ -10,4 +10,4 @@
  *
  * The TYPO3 project - inspiring people to share!
  */
-import AjaxRequest from"@typo3/core/ajax/ajax-request.js";import ContextMenuActions from"@typo3/backend/context-menu-actions.js";import DebounceEvent from"@typo3/core/event/debounce-event.js";import RegularEvent from"@typo3/core/event/regular-event.js";import ThrottleEvent from"@typo3/core/event/throttle-event.js";import{selector}from"@typo3/core/literals.js";class ContextMenu{constructor(){this.mousePos={X:null,Y:null},this.record={uid:null,table:null},this.eventSources=[],this.storeMousePositionEvent=e=>{this.mousePos={X:e.pageX,Y:e.pageY}},document.addEventListener("click",(e=>{this.handleTriggerEvent(e)})),document.addEventListener("contextmenu",(e=>{this.handleTriggerEvent(e)})),new ThrottleEvent("mousemove",this.storeMousePositionEvent.bind(this),50).bindTo(document)}static drawActionItem(e){const t=document.createElement("li");t.role="menuitem",t.classList.add("context-menu-item"),t.dataset.callbackAction=e.callbackAction,t.tabIndex=-1;const n=e.additionalAttributes||{};for(const e of Object.entries(n)){const[n,o]=e;t.setAttribute(n,o)}const o=document.createElement("span");o.classList.add("context-menu-item-icon"),o.innerHTML=e.icon;const s=document.createElement("span");return s.classList.add("context-menu-item-label"),s.innerHTML=e.label,t.append(o),t.append(s),t}static within(e,t,n){const o=e.getBoundingClientRect(),s=window.pageXOffset||document.documentElement.scrollLeft,i=window.pageYOffset||document.documentElement.scrollTop,c=t>=o.left+s&&t<=o.left+s+o.width,r=n>=o.top+i&&n<=o.top+i+o.height;return c&&r}show(e,t,n,o,s,i=null){this.hideAll(),this.record={table:e,uid:t};const c=i.matches('a, button, [tabindex]:not([tabindex="-1"])')?i:i.closest('a, button, [tabindex]:not([tabindex="-1"])');!1===this.eventSources.includes(c)&&this.eventSources.push(c);const r=new URLSearchParams;void 0!==e&&r.set("table",e),void 0!==t&&r.set("uid",t.toString()),void 0!==n&&r.set("context",n),this.fetch(r.toString())}initializeContextMenuContainer(){if(null===document.querySelector("#contentMenu0")){const e=document.createElement("div");e.classList.add("context-menu"),e.id="contentMenu0",e.style.display="none",document.querySelector("body").append(e);const t=document.createElement("div");t.classList.add("context-menu"),t.id="contentMenu1",t.style.display="none",t.dataset.parent="#contentMenu0",document.querySelector("body").append(t),document.querySelectorAll(".context-menu").forEach((e=>{new RegularEvent("mouseenter",(e=>{this.storeMousePositionEvent(e)})).bindTo(e),new DebounceEvent("mouseleave",(e=>{const t=e.target,n=document.querySelector(selector`[data-parent="#${t.id}"]`);if(!ContextMenu.within(t,this.mousePos.X,this.mousePos.Y)&&(null===n||null===n.offsetParent)){let e;this.hide(t),void 0!==t.dataset.parent&&null!==(e=document.querySelector(t.dataset.parent))&&(ContextMenu.within(e,this.mousePos.X,this.mousePos.Y)||this.hide(document.querySelector(t.dataset.parent)))}}),500).bindTo(e)}))}}handleTriggerEvent(e){if(!(e.target instanceof Element))return;const t=e.target.closest("[data-contextmenu-trigger]");if(t instanceof HTMLElement)return void this.handleContextMenuEvent(e,t);e.target.closest(".context-menu")||this.hideAll()}handleContextMenuEvent(e,t){const n=t.dataset.contextmenuTrigger;"click"!==n&&n!==e.type||(e.preventDefault(),this.show(t.dataset.contextmenuTable??"",t.dataset.contextmenuUid??"",t.dataset.contextmenuContext??"","","",t))}fetch(e){const t=TYPO3.settings.ajaxUrls.contextmenu;new AjaxRequest(t).withQueryArguments(e).get().then((async e=>{const t=await e.resolve();void 0!==e&&Object.keys(e).length>0&&this.populateData(t,0)}))}populateData(e,t){this.initializeContextMenuContainer();const n=document.querySelector("#contentMenu"+t),o=document.querySelector("#contentMenu"+(t-1));if(null!==n&&null!==o?.offsetParent){const o=document.createElement("ul");o.classList.add("context-menu-group"),o.role="menu",this.drawMenu(e,t).forEach((e=>{o.appendChild(e)})),n.innerHTML="",n.appendChild(o),n.style.display=null;const s=this.getPosition(n);n.style.top=s.top,n.style.insetInlineStart=s.start,n.querySelector('.context-menu-item[tabindex="-1"]').focus(),this.initializeEvents(n,t)}}initializeEvents(e,t){e.querySelectorAll("li.context-menu-item").forEach((e=>{e.addEventListener("click",(e=>{e.preventDefault();const n=e.currentTarget;if(n.classList.contains("context-menu-item-submenu"))return void this.openSubmenu(t,n);const{callbackAction:o,callbackModule:s,...i}=n.dataset;n.dataset.callbackModule?import(s+".js").then((({default:e})=>{e[o](this.record.table,this.record.uid,i)})):ContextMenuActions&&"function"==typeof ContextMenuActions[o]?ContextMenuActions[o](this.record.table,this.record.uid,i):console.error("action: "+o+" not found"),this.hideAll()})),e.addEventListener("keydown",(e=>{e.preventDefault();const n=e.target;switch(e.key){case"Down":case"ArrowDown":this.setFocusToNextItem(n);break;case"Up":case"ArrowUp":this.setFocusToPreviousItem(n);break;case"Right":case"ArrowRight":if(!n.classList.contains("context-menu-item-submenu"))return;this.openSubmenu(t,n);break;case"Home":this.setFocusToFirstItem(n);break;case"End":this.setFocusToLastItem(n);break;case"Enter":case"Space":n.click();break;case"Esc":case"Escape":case"Left":case"ArrowLeft":this.hide(n.closest(".context-menu"));break;case"Tab":this.hideAll();break;default:return}}))}))}setFocusToPreviousItem(e){let t=this.getItemBackward(e.previousElementSibling);t||(t=this.getLastItem(e)),t.focus()}setFocusToNextItem(e){let t=this.getItemForward(e.nextElementSibling);t||(t=this.getFirstItem(e)),t.focus()}setFocusToFirstItem(e){const t=this.getFirstItem(e);t&&t.focus()}setFocusToLastItem(e){const t=this.getLastItem(e);t&&t.focus()}getItemBackward(e){for(;e&&(!e.classList.contains("context-menu-item")||"-1"!==e.getAttribute("tabindex"));)e=e.previousElementSibling;return e}getItemForward(e){for(;e&&(!e.classList.contains("context-menu-item")||"-1"!==e.getAttribute("tabindex"));)e=e.nextElementSibling;return e}getFirstItem(e){return this.getItemForward(e.parentElement.firstElementChild)}getLastItem(e){return this.getItemBackward(e.parentElement.lastElementChild)}openSubmenu(e,t){!1===this.eventSources.includes(t)&&this.eventSources.push(t);const n=document.querySelector("#contentMenu"+(e+1));n.innerHTML="",n.appendChild(t.nextElementSibling.querySelector(".context-menu-group").cloneNode(!0)),n.style.display=null;const o=this.getPosition(n);n.style.top=o.top,n.style.insetInlineStart=o.start,n.querySelector('.context-menu-item[tabindex="-1"]').focus(),this.initializeEvents(n,e)}getPosition(e){const t="rtl"===document.querySelector("html").dir?"rtl":"ltr",n=this.eventSources?.[this.eventSources.length-1],o=e.offsetWidth,s=e.offsetHeight,i=window.innerWidth,c=window.innerHeight;let r=0,a=0;if(null!=n){const e=n.getBoundingClientRect();a=e.y,r="ltr"===t?e.x+e.width:i-e.x,n.classList.contains("context-menu-item-submenu")&&(a-=8)}else a=this.mousePos.Y,r="ltr"===t?this.mousePos.X:i-this.mousePos.X;return a+s+10+5<c?a+=5:a=c-s-10,r+o+10+5<i?r+=5:r=i-o-10,{start:Math.round(r)+"px",top:Math.round(a)+"px"}}drawMenu(e,t){const n=[];for(const o of Object.values(e))if("item"===o.type)n.push(ContextMenu.drawActionItem(o));else if("divider"===o.type){const e=document.createElement("li");e.role="separator",e.classList.add("context-menu-divider"),n.push(e)}else if("submenu"===o.type||o.childItems){const e=document.createElement("li");e.role="menuitem",e.ariaHasPopup="true",e.classList.add("context-menu-item","context-menu-item-submenu"),e.tabIndex=-1;const s=document.createElement("span");s.classList.add("context-menu-item-icon"),s.innerHTML=o.icon,e.appendChild(s);const i=document.createElement("span");i.classList.add("context-menu-item-label"),i.innerHTML=o.label,e.appendChild(i);const c=document.createElement("span");c.classList.add("context-menu-item-indicator"),c.innerHTML='<typo3-backend-icon identifier="actions-chevron-'+("rtl"===document.querySelector("html").dir?"left":"right")+'" size="small"></typo3-backend-icon>',e.appendChild(c),n.push(e);const r=document.createElement("div");r.classList.add("context-menu","contentMenu"+(t+1)),r.style.display="none";const a=document.createElement("ul");a.role="menu",a.classList.add("context-menu-group"),this.drawMenu(o.childItems,1).forEach((e=>{a.appendChild(e)})),r.appendChild(a),n.push(r)}return n}hide(e){if(null===e)return;e.style.top=null,e.style.insetInlineStart=null,e.style.display="none";const t=this.eventSources.pop();t&&t.focus()}hideAll(){this.hide(document.querySelector("#contentMenu0")),this.hide(document.querySelector("#contentMenu1"))}}export default new ContextMenu;
\ No newline at end of file
+import AjaxRequest from"@typo3/core/ajax/ajax-request.js";import ContextMenuActions from"@typo3/backend/context-menu-actions.js";import DebounceEvent from"@typo3/core/event/debounce-event.js";import RegularEvent from"@typo3/core/event/regular-event.js";import{selector}from"@typo3/core/literals.js";class ContextMenu{constructor(){this.mousePos={X:null,Y:null},this.record={uid:null,table:null},this.eventSources=[],document.addEventListener("click",(e=>{this.handleTriggerEvent(e)})),document.addEventListener("contextmenu",(e=>{this.handleTriggerEvent(e)}))}static drawActionItem(e){const t=document.createElement("li");t.role="menuitem",t.classList.add("context-menu-item"),t.dataset.callbackAction=e.callbackAction,t.tabIndex=-1;const n=e.additionalAttributes||{};for(const e of Object.entries(n)){const[n,o]=e;t.setAttribute(n,o)}const o=document.createElement("span");o.classList.add("context-menu-item-icon"),o.innerHTML=e.icon;const s=document.createElement("span");return s.classList.add("context-menu-item-label"),s.innerHTML=e.label,t.append(o),t.append(s),t}static within(e,t,n){const o=e.getBoundingClientRect(),s=window.pageXOffset||document.documentElement.scrollLeft,i=window.pageYOffset||document.documentElement.scrollTop,c=t>=o.left+s&&t<=o.left+s+o.width,a=n>=o.top+i&&n<=o.top+i+o.height;return c&&a}show(e,t,n,o,s,i=null,c=null){this.hideAll(),this.record={table:e,uid:t};const a=i.matches('a, button, [tabindex]:not([tabindex="-1"])')?i:i.closest('a, button, [tabindex]:not([tabindex="-1"])');!1===this.eventSources.includes(a)&&this.eventSources.push(a);const r=new URLSearchParams;void 0!==e&&r.set("table",e),void 0!==t&&r.set("uid",t.toString()),void 0!==n&&r.set("context",n);let l=null;null!==c&&(this.storeMousePosition(c),l=this.mousePos),this.fetch(r.toString(),l)}initializeContextMenuContainer(){if(null===document.querySelector("#contentMenu0")){const e=document.createElement("div");e.classList.add("context-menu"),e.id="contentMenu0",e.style.display="none",document.querySelector("body").append(e);const t=document.createElement("div");t.classList.add("context-menu"),t.id="contentMenu1",t.style.display="none",t.dataset.parent="#contentMenu0",document.querySelector("body").append(t),document.querySelectorAll(".context-menu").forEach((e=>{new RegularEvent("mouseenter",(e=>{this.storeMousePosition(e)})).bindTo(e),new DebounceEvent("mouseleave",(e=>{const t=e.target,n=document.querySelector(selector`[data-parent="#${t.id}"]`);if(!ContextMenu.within(t,this.mousePos.X,this.mousePos.Y)&&(null===n||null===n.offsetParent)){let e;this.hide(t),void 0!==t.dataset.parent&&null!==(e=document.querySelector(t.dataset.parent))&&(ContextMenu.within(e,this.mousePos.X,this.mousePos.Y)||this.hide(document.querySelector(t.dataset.parent)))}}),500).bindTo(e)}))}}handleTriggerEvent(e){if(!(e.target instanceof Element))return;const t=e.target.closest("[data-contextmenu-trigger]");if(t instanceof HTMLElement)return void this.handleContextMenuEvent(e,t);e.target.closest(".context-menu")||this.hideAll()}handleContextMenuEvent(e,t){const n=t.dataset.contextmenuTrigger;"click"!==n&&n!==e.type||(e.preventDefault(),this.show(t.dataset.contextmenuTable??"",t.dataset.contextmenuUid??"",t.dataset.contextmenuContext??"","","",t,e))}fetch(e,t){const n=TYPO3.settings.ajaxUrls.contextmenu;new AjaxRequest(n).withQueryArguments(e).get().then((async e=>{const n=await e.resolve();void 0!==e&&Object.keys(e).length>0&&this.populateData(n,0,t)}))}populateData(e,t,n){this.initializeContextMenuContainer();const o=document.querySelector("#contentMenu"+t),s=document.querySelector("#contentMenu"+(t-1));if(null!==o&&null!==s?.offsetParent){const s=document.createElement("ul");s.classList.add("context-menu-group"),s.role="menu",this.drawMenu(e,t).forEach((e=>{s.appendChild(e)})),o.innerHTML="",o.appendChild(s),o.style.display=null,n??(n=this.getPosition(o));const i=this.toPixel(n);o.style.top=i.top,o.style.insetInlineStart=i.start,o.querySelector('.context-menu-item[tabindex="-1"]').focus(),this.initializeEvents(o,t)}}initializeEvents(e,t){e.querySelectorAll("li.context-menu-item").forEach((e=>{e.addEventListener("click",(e=>{e.preventDefault();const n=e.currentTarget;if(n.classList.contains("context-menu-item-submenu"))return void this.openSubmenu(t,n);const{callbackAction:o,callbackModule:s,...i}=n.dataset;n.dataset.callbackModule?import(s+".js").then((({default:e})=>{e[o](this.record.table,this.record.uid,i)})):ContextMenuActions&&"function"==typeof ContextMenuActions[o]?ContextMenuActions[o](this.record.table,this.record.uid,i):console.error("action: "+o+" not found"),this.hideAll()})),e.addEventListener("keydown",(e=>{e.preventDefault();const n=e.target;switch(e.key){case"Down":case"ArrowDown":this.setFocusToNextItem(n);break;case"Up":case"ArrowUp":this.setFocusToPreviousItem(n);break;case"Right":case"ArrowRight":if(!n.classList.contains("context-menu-item-submenu"))return;this.openSubmenu(t,n);break;case"Home":this.setFocusToFirstItem(n);break;case"End":this.setFocusToLastItem(n);break;case"Enter":case"Space":n.click();break;case"Esc":case"Escape":case"Left":case"ArrowLeft":this.hide(n.closest(".context-menu"));break;case"Tab":this.hideAll();break;default:return}}))}))}setFocusToPreviousItem(e){let t=this.getItemBackward(e.previousElementSibling);t||(t=this.getLastItem(e)),t.focus()}setFocusToNextItem(e){let t=this.getItemForward(e.nextElementSibling);t||(t=this.getFirstItem(e)),t.focus()}setFocusToFirstItem(e){const t=this.getFirstItem(e);t&&t.focus()}setFocusToLastItem(e){const t=this.getLastItem(e);t&&t.focus()}getItemBackward(e){for(;e&&(!e.classList.contains("context-menu-item")||"-1"!==e.getAttribute("tabindex"));)e=e.previousElementSibling;return e}getItemForward(e){for(;e&&(!e.classList.contains("context-menu-item")||"-1"!==e.getAttribute("tabindex"));)e=e.nextElementSibling;return e}getFirstItem(e){return this.getItemForward(e.parentElement.firstElementChild)}getLastItem(e){return this.getItemBackward(e.parentElement.lastElementChild)}openSubmenu(e,t){!1===this.eventSources.includes(t)&&this.eventSources.push(t);const n=document.querySelector("#contentMenu"+(e+1));n.innerHTML="",n.appendChild(t.nextElementSibling.querySelector(".context-menu-group").cloneNode(!0)),n.style.display=null;const o=this.toPixel(this.getPosition(n));n.style.top=o.top,n.style.insetInlineStart=o.start,n.querySelector('.context-menu-item[tabindex="-1"]').focus(),this.initializeEvents(n,e)}toPixel(e){return{start:Math.round(e.X)+"px",top:Math.round(e.Y)+"px"}}getPosition(e){const t="rtl"===document.querySelector("html").dir?"rtl":"ltr",n=this.eventSources?.[this.eventSources.length-1],o=e.offsetWidth,s=e.offsetHeight,i=window.innerWidth,c=window.innerHeight;let a=0,r=0;if(null!=n){const e=n.getBoundingClientRect();r=e.y,a="ltr"===t?e.x+e.width:i-e.x,n.classList.contains("context-menu-item-submenu")&&(r-=8)}else r=this.mousePos.Y,a="ltr"===t?this.mousePos.X:i-this.mousePos.X;return r+s+10+5<c?r+=5:r=c-s-10,a+o+10+5<i?a+=5:a=i-o-10,{X:a,Y:r}}drawMenu(e,t){const n=[];for(const o of Object.values(e))if("item"===o.type)n.push(ContextMenu.drawActionItem(o));else if("divider"===o.type){const e=document.createElement("li");e.role="separator",e.classList.add("context-menu-divider"),n.push(e)}else if("submenu"===o.type||o.childItems){const e=document.createElement("li");e.role="menuitem",e.ariaHasPopup="true",e.classList.add("context-menu-item","context-menu-item-submenu"),e.tabIndex=-1;const s=document.createElement("span");s.classList.add("context-menu-item-icon"),s.innerHTML=o.icon,e.appendChild(s);const i=document.createElement("span");i.classList.add("context-menu-item-label"),i.innerHTML=o.label,e.appendChild(i);const c=document.createElement("span");c.classList.add("context-menu-item-indicator"),c.innerHTML='<typo3-backend-icon identifier="actions-chevron-'+("rtl"===document.querySelector("html").dir?"left":"right")+'" size="small"></typo3-backend-icon>',e.appendChild(c),n.push(e);const a=document.createElement("div");a.classList.add("context-menu","contentMenu"+(t+1)),a.style.display="none";const r=document.createElement("ul");r.role="menu",r.classList.add("context-menu-group"),this.drawMenu(o.childItems,1).forEach((e=>{r.appendChild(e)})),a.appendChild(r),n.push(a)}return n}storeMousePosition(e){this.mousePos={X:e.pageX,Y:e.pageY}}hide(e){if(null===e)return;e.style.top=null,e.style.insetInlineStart=null,e.style.display="none";const t=this.eventSources.pop();t&&t.focus()}hideAll(){this.hide(document.querySelector("#contentMenu0")),this.hide(document.querySelector("#contentMenu1"))}}export default new ContextMenu;
\ No newline at end of file
diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/tree/file-storage-tree-container.js b/typo3/sysext/backend/Resources/Public/JavaScript/tree/file-storage-tree-container.js
index c1d8d4f178e2b8254c860a7a522763f3c6883909..7a00119ba440bd4da0cb66fd93881328456b6444 100644
--- a/typo3/sysext/backend/Resources/Public/JavaScript/tree/file-storage-tree-container.js
+++ b/typo3/sysext/backend/Resources/Public/JavaScript/tree/file-storage-tree-container.js
@@ -10,7 +10,7 @@
  *
  * The TYPO3 project - inspiring people to share!
  */
-var __decorate=function(e,t,o,r){var i,n=arguments.length,s=n<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,o,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(n<3?i(s):n>3?i(t,o,s):i(t,o))||s);return n>3&&s&&Object.defineProperty(t,o,s),s};import{html,LitElement}from"lit";import{customElement,query}from"lit/decorators.js";import"@typo3/backend/element/icon-element.js";import{SeverityEnum}from"@typo3/backend/enum/severity.js";import"@typo3/backend/tree/tree-toolbar.js";import{TreeNodePositionEnum}from"@typo3/backend/tree/tree-node.js";import{FileStorageTree}from"@typo3/backend/tree/file-storage-tree.js";import ContextMenu from"@typo3/backend/context-menu.js";import Notification from"@typo3/backend/notification.js";import{ModuleStateStorage}from"@typo3/backend/storage/module-state-storage.js";import{ModuleUtility}from"@typo3/backend/module.js";import{FileListDragDropEvent}from"@typo3/filelist/file-list-dragdrop.js";import{Resource}from"@typo3/backend/resource/resource.js";import{DataTransferTypes}from"@typo3/backend/enum/data-transfer-types.js";export const navigationComponentName="typo3-backend-navigation-component-filestoragetree";let EditableFileStorageTree=class extends FileStorageTree{constructor(){super(...arguments),this.allowNodeDrag=!0}handleNodeMove(e,t,o){if(!this.isDropAllowed(t,e))return;const r=this.getDropCommandDetails(t,e,o);if(null===r)return;const i=FileOperationCollection.fromNodePositionOptions(r),n=i.getConflictingOperationsForTreeNode(r.target);n.length>0?n.forEach((e=>{Notification.showMessage(TYPO3.lang["drop.conflict"],TYPO3.lang["mess.drop.conflict"].replace("%s",e.resource.name).replace("%s",decodeURIComponent(r.target.identifier)),SeverityEnum.error)})):this.initiateDropAction(i)}createDataTransferItemsFromNode(e){return[{type:DataTransferTypes.treenode,data:this.getNodeTreeIdentifier(e)},{type:DataTransferTypes.falResources,data:JSON.stringify([FileResource.fromTreeNode(e)])}]}handleNodeDragOver(e){if(super.handleNodeDragOver(e))return!0;if(e.dataTransfer.types.includes(DataTransferTypes.falResources)){const t=this.getNodeFromDragEvent(e);if(null===t)return!1;this.cleanDrag();return this.getElementFromNode(t).classList.add("node-hover"),t.hasChildren&&!t.expanded?this.openNodeTimeout.targetNode!=t&&(this.openNodeTimeout.targetNode=t,clearTimeout(this.openNodeTimeout.timeout),this.openNodeTimeout.timeout=setTimeout((()=>{this.showChildren(this.openNodeTimeout.targetNode),this.openNodeTimeout.targetNode=null,this.openNodeTimeout.timeout=null}),1e3)):(clearTimeout(this.openNodeTimeout.timeout),this.openNodeTimeout.targetNode=null,this.openNodeTimeout.timeout=null),e.preventDefault(),!0}return!1}getTooltipDescription(e){return decodeURIComponent(e.identifier)}handleNodeDrop(e){if(super.handleNodeDrop(e))return!0;if(e.dataTransfer.types.includes(DataTransferTypes.falResources)){const t=this.getNodeFromDragEvent(e);if(null===t)return!1;if(t){const o=FileResource.fromTreeNode(t),r=FileOperationCollection.fromDataTransfer(e.dataTransfer,o),i=r.getConflictingOperationsForTreeNode(t);return i.length>0?(i.forEach((e=>{Notification.showMessage(TYPO3.lang["drop.conflict"],TYPO3.lang["mess.drop.conflict"].replace("%s",e.resource.name).replace("%s",decodeURIComponent(t.identifier)),SeverityEnum.error)})),!1):(e.preventDefault(),this.initiateDropAction(r),!0)}}return!1}getDropCommandDetails(e,t,o){const r=this.nodes,i=t.identifier;let n=e;if(i===n.identifier)return null;if(o===TreeNodePositionEnum.BEFORE){const t=r.indexOf(e),i=this.setNodePositionAndTarget(t);if(null===i)return null;o=i.position,n=i.target}return{node:t,identifier:i,target:n,position:o}}setNodePositionAndTarget(e){const t=this.nodes,o=t[e].depth;e>0&&e--;const r=t[e].depth,i=this.nodes[e];if(r===o)return{position:TreeNodePositionEnum.AFTER,target:i};if(r<o)return{position:TreeNodePositionEnum.INSIDE,target:i};for(let r=e;r>=0;r--){if(t[r].depth===o)return{position:TreeNodePositionEnum.AFTER,target:this.nodes[r]};if(t[r].depth<o)return{position:TreeNodePositionEnum.AFTER,target:t[r]}}return null}isDropAllowed(e,t){return e!==t&&!!this.isOverRoot}initiateDropAction(e){const t={action:"transfer",resources:e.getResources(),target:e.target};top.document.dispatchEvent(new CustomEvent(FileListDragDropEvent.transfer,{detail:t}))}};EditableFileStorageTree=__decorate([customElement("typo3-backend-navigation-component-filestorage-tree")],EditableFileStorageTree);export{EditableFileStorageTree};let FileStorageTreeNavigationComponent=class extends LitElement{constructor(){super(...arguments),this.refresh=()=>{this.tree.refreshOrFilterTree()},this.selectFirstNode=()=>{const e=this.tree.nodes[0];e&&this.tree.selectNode(e,!0)},this.treeUpdateRequested=e=>{const t=encodeURIComponent(e.detail.payload.identifier),o=this.tree.nodes.filter((e=>e.identifier===t))[0];o&&0===this.tree.getSelectedNodes().filter((e=>e.identifier===o.identifier)).length&&this.tree.selectNode(o,!1)},this.loadContent=e=>{const t=e.detail.node;if(!t?.checked)return;if(ModuleStateStorage.update("media",t.identifier,!0),!1===e.detail.propagate)return;const o=top.TYPO3.ModuleMenu.App;let r=ModuleUtility.getFromName(o.getCurrentModule()).link;r+=r.includes("?")?"&":"?",top.TYPO3.Backend.ContentContainer.setUrl(r+"id="+t.identifier)},this.showContextMenu=e=>{const t=e.detail.node;t&&ContextMenu.show(t.recordType,decodeURIComponent(t.identifier),"tree","","",this.tree.getElementFromNode(t))},this.selectActiveNode=e=>{const t=ModuleStateStorage.current("file").selection,o=e.detail.nodes;e.detail.nodes=o.map((e=>(e.identifier===t&&(e.checked=!0),e)))}}connectedCallback(){super.connectedCallback(),document.addEventListener("typo3:filestoragetree:refresh",this.refresh),document.addEventListener("typo3:filestoragetree:selectFirstNode",this.selectFirstNode),document.addEventListener("typo3:filelist:treeUpdateRequested",this.treeUpdateRequested)}disconnectedCallback(){document.removeEventListener("typo3:filestoragetree:refresh",this.refresh),document.removeEventListener("typo3:filestoragetree:selectFirstNode",this.selectFirstNode),document.removeEventListener("typo3:filelist:treeUpdateRequested",this.treeUpdateRequested),super.disconnectedCallback()}createRenderRoot(){return this}render(){const e={dataUrl:top.TYPO3.settings.ajaxUrls.filestorage_tree_data,filterUrl:top.TYPO3.settings.ajaxUrls.filestorage_tree_filter,showIcons:!0};return html`
+var __decorate=function(e,t,o,r){var i,n=arguments.length,s=n<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,o,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(n<3?i(s):n>3?i(t,o,s):i(t,o))||s);return n>3&&s&&Object.defineProperty(t,o,s),s};import{html,LitElement}from"lit";import{customElement,query}from"lit/decorators.js";import"@typo3/backend/element/icon-element.js";import{SeverityEnum}from"@typo3/backend/enum/severity.js";import"@typo3/backend/tree/tree-toolbar.js";import{TreeNodePositionEnum}from"@typo3/backend/tree/tree-node.js";import{FileStorageTree}from"@typo3/backend/tree/file-storage-tree.js";import ContextMenu from"@typo3/backend/context-menu.js";import Notification from"@typo3/backend/notification.js";import{ModuleStateStorage}from"@typo3/backend/storage/module-state-storage.js";import{ModuleUtility}from"@typo3/backend/module.js";import{FileListDragDropEvent}from"@typo3/filelist/file-list-dragdrop.js";import{Resource}from"@typo3/backend/resource/resource.js";import{DataTransferTypes}from"@typo3/backend/enum/data-transfer-types.js";export const navigationComponentName="typo3-backend-navigation-component-filestoragetree";let EditableFileStorageTree=class extends FileStorageTree{constructor(){super(...arguments),this.allowNodeDrag=!0}handleNodeMove(e,t,o){if(!this.isDropAllowed(t,e))return;const r=this.getDropCommandDetails(t,e,o);if(null===r)return;const i=FileOperationCollection.fromNodePositionOptions(r),n=i.getConflictingOperationsForTreeNode(r.target);n.length>0?n.forEach((e=>{Notification.showMessage(TYPO3.lang["drop.conflict"],TYPO3.lang["mess.drop.conflict"].replace("%s",e.resource.name).replace("%s",decodeURIComponent(r.target.identifier)),SeverityEnum.error)})):this.initiateDropAction(i)}createDataTransferItemsFromNode(e){return[{type:DataTransferTypes.treenode,data:this.getNodeTreeIdentifier(e)},{type:DataTransferTypes.falResources,data:JSON.stringify([FileResource.fromTreeNode(e)])}]}handleNodeDragOver(e){if(super.handleNodeDragOver(e))return!0;if(e.dataTransfer.types.includes(DataTransferTypes.falResources)){const t=this.getNodeFromDragEvent(e);if(null===t)return!1;this.cleanDrag();return this.getElementFromNode(t).classList.add("node-hover"),t.hasChildren&&!t.expanded?this.openNodeTimeout.targetNode!=t&&(this.openNodeTimeout.targetNode=t,clearTimeout(this.openNodeTimeout.timeout),this.openNodeTimeout.timeout=setTimeout((()=>{this.showChildren(this.openNodeTimeout.targetNode),this.openNodeTimeout.targetNode=null,this.openNodeTimeout.timeout=null}),1e3)):(clearTimeout(this.openNodeTimeout.timeout),this.openNodeTimeout.targetNode=null,this.openNodeTimeout.timeout=null),e.preventDefault(),!0}return!1}getTooltipDescription(e){return decodeURIComponent(e.identifier)}handleNodeDrop(e){if(super.handleNodeDrop(e))return!0;if(e.dataTransfer.types.includes(DataTransferTypes.falResources)){const t=this.getNodeFromDragEvent(e);if(null===t)return!1;if(t){const o=FileResource.fromTreeNode(t),r=FileOperationCollection.fromDataTransfer(e.dataTransfer,o),i=r.getConflictingOperationsForTreeNode(t);return i.length>0?(i.forEach((e=>{Notification.showMessage(TYPO3.lang["drop.conflict"],TYPO3.lang["mess.drop.conflict"].replace("%s",e.resource.name).replace("%s",decodeURIComponent(t.identifier)),SeverityEnum.error)})),!1):(e.preventDefault(),this.initiateDropAction(r),!0)}}return!1}getDropCommandDetails(e,t,o){const r=this.nodes,i=t.identifier;let n=e;if(i===n.identifier)return null;if(o===TreeNodePositionEnum.BEFORE){const t=r.indexOf(e),i=this.setNodePositionAndTarget(t);if(null===i)return null;o=i.position,n=i.target}return{node:t,identifier:i,target:n,position:o}}setNodePositionAndTarget(e){const t=this.nodes,o=t[e].depth;e>0&&e--;const r=t[e].depth,i=this.nodes[e];if(r===o)return{position:TreeNodePositionEnum.AFTER,target:i};if(r<o)return{position:TreeNodePositionEnum.INSIDE,target:i};for(let r=e;r>=0;r--){if(t[r].depth===o)return{position:TreeNodePositionEnum.AFTER,target:this.nodes[r]};if(t[r].depth<o)return{position:TreeNodePositionEnum.AFTER,target:t[r]}}return null}isDropAllowed(e,t){return e!==t&&!!this.isOverRoot}initiateDropAction(e){const t={action:"transfer",resources:e.getResources(),target:e.target};top.document.dispatchEvent(new CustomEvent(FileListDragDropEvent.transfer,{detail:t}))}};EditableFileStorageTree=__decorate([customElement("typo3-backend-navigation-component-filestorage-tree")],EditableFileStorageTree);export{EditableFileStorageTree};let FileStorageTreeNavigationComponent=class extends LitElement{constructor(){super(...arguments),this.refresh=()=>{this.tree.refreshOrFilterTree()},this.selectFirstNode=()=>{const e=this.tree.nodes[0];e&&this.tree.selectNode(e,!0)},this.treeUpdateRequested=e=>{const t=encodeURIComponent(e.detail.payload.identifier),o=this.tree.nodes.filter((e=>e.identifier===t))[0];o&&0===this.tree.getSelectedNodes().filter((e=>e.identifier===o.identifier)).length&&this.tree.selectNode(o,!1)},this.loadContent=e=>{const t=e.detail.node;if(!t?.checked)return;if(ModuleStateStorage.update("media",t.identifier,!0),!1===e.detail.propagate)return;const o=top.TYPO3.ModuleMenu.App;let r=ModuleUtility.getFromName(o.getCurrentModule()).link;r+=r.includes("?")?"&":"?",top.TYPO3.Backend.ContentContainer.setUrl(r+"id="+t.identifier)},this.showContextMenu=e=>{const t=e.detail.node;t&&ContextMenu.show(t.recordType,decodeURIComponent(t.identifier),"tree","","",this.tree.getElementFromNode(t),e.detail.originalEvent)},this.selectActiveNode=e=>{const t=ModuleStateStorage.current("file").selection,o=e.detail.nodes;e.detail.nodes=o.map((e=>(e.identifier===t&&(e.checked=!0),e)))}}connectedCallback(){super.connectedCallback(),document.addEventListener("typo3:filestoragetree:refresh",this.refresh),document.addEventListener("typo3:filestoragetree:selectFirstNode",this.selectFirstNode),document.addEventListener("typo3:filelist:treeUpdateRequested",this.treeUpdateRequested)}disconnectedCallback(){document.removeEventListener("typo3:filestoragetree:refresh",this.refresh),document.removeEventListener("typo3:filestoragetree:selectFirstNode",this.selectFirstNode),document.removeEventListener("typo3:filelist:treeUpdateRequested",this.treeUpdateRequested),super.disconnectedCallback()}createRenderRoot(){return this}render(){const e={dataUrl:top.TYPO3.settings.ajaxUrls.filestorage_tree_data,filterUrl:top.TYPO3.settings.ajaxUrls.filestorage_tree_filter,showIcons:!0};return html`
       <div id="typo3-filestoragetree" class="tree">
         <typo3-backend-tree-toolbar .tree="${this.tree}" id="filestoragetree-toolbar"></typo3-backend-tree-toolbar>
         <div class="navigation-tree-container">
diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/tree/page-tree-element.js b/typo3/sysext/backend/Resources/Public/JavaScript/tree/page-tree-element.js
index f399fbf820c894a679d4f4c3c067377c7888a18d..e24d66356a89708f04d86ab12d6fd67c57ed7a2b 100644
--- a/typo3/sysext/backend/Resources/Public/JavaScript/tree/page-tree-element.js
+++ b/typo3/sysext/backend/Resources/Public/JavaScript/tree/page-tree-element.js
@@ -10,7 +10,7 @@
  *
  * The TYPO3 project - inspiring people to share!
  */
-var __decorate=function(e,t,o,n){var a,r=arguments.length,i=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,o,n);else for(var s=e.length-1;s>=0;s--)(a=e[s])&&(i=(r<3?a(i):r>3?a(t,o,i):a(t,o))||i);return r>3&&i&&Object.defineProperty(t,o,i),i};import{html,LitElement,nothing}from"lit";import{customElement,property,query}from"lit/decorators.js";import{until}from"lit/directives/until.js";import{lll}from"@typo3/core/lit-helper.js";import AjaxRequest from"@typo3/core/ajax/ajax-request.js";import Persistent from"@typo3/backend/storage/persistent.js";import{ModuleUtility}from"@typo3/backend/module.js";import ContextMenu from"@typo3/backend/context-menu.js";import{PageTree}from"@typo3/backend/tree/page-tree.js";import{TreeNodeCommandEnum,TreeNodePositionEnum}from"@typo3/backend/tree/tree-node.js";import{TreeToolbar}from"@typo3/backend/tree/tree-toolbar.js";import Modal from"@typo3/backend/modal.js";import Severity from"@typo3/backend/severity.js";import{ModuleStateStorage}from"@typo3/backend/storage/module-state-storage.js";import{DataTransferTypes}from"@typo3/backend/enum/data-transfer-types.js";export const navigationComponentName="typo3-backend-navigation-component-pagetree";let EditablePageTree=class extends PageTree{constructor(){super(...arguments),this.allowNodeEdit=!0,this.allowNodeDrag=!0,this.allowNodeSorting=!0}sendChangeCommand(e){let t="",o="0";if(e.target)if(o=e.target.identifier,e.position===TreeNodePositionEnum.BEFORE){const t=this.getPreviousNode(e.target);o=(t.depth===e.target.depth?"-":"")+t.identifier}else e.position===TreeNodePositionEnum.AFTER&&(o="-"+o);if(e.command===TreeNodeCommandEnum.NEW){const n=e;t="&data[pages]["+e.node.identifier+"][pid]="+encodeURIComponent(o)+"&data[pages]["+e.node.identifier+"][title]="+encodeURIComponent(n.title)+"&data[pages]["+e.node.identifier+"][doktype]="+encodeURIComponent(n.doktype)}else if(e.command===TreeNodeCommandEnum.EDIT)t="&data[pages]["+e.node.identifier+"][title]="+encodeURIComponent(e.title);else if(e.command===TreeNodeCommandEnum.DELETE){const o=ModuleStateStorage.current("web");e.node.identifier===o.identifier&&this.selectFirstNode(),t="&cmd[pages]["+e.node.identifier+"][delete]=1"}else t="cmd[pages]["+e.node.identifier+"]["+e.command+"]="+o;this.requestTreeUpdate(t).then((t=>{if(t&&t.hasErrors)this.errorNotification(t.messages);else if(e.command===TreeNodeCommandEnum.NEW){const t=this.getParentNode(e.node);t.loaded=!1,this.loadChildren(t)}else this.refreshOrFilterTree()}))}initializeDragForNode(){throw new Error("unused")}async handleNodeEdit(e,t){if(e.__loading=!0,e.identifier.startsWith("NEW")){const o=this.getPreviousNode(e),n=e.depth===o.depth?TreeNodePositionEnum.AFTER:TreeNodePositionEnum.INSIDE,a={command:TreeNodeCommandEnum.NEW,node:e,title:t,position:n,target:o,doktype:e.doktype};await this.sendChangeCommand(a)}else{const o={command:TreeNodeCommandEnum.EDIT,node:e,title:t};await this.sendChangeCommand(o)}e.__loading=!1}createDataTransferItemsFromNode(e){return[{type:DataTransferTypes.treenode,data:this.getNodeTreeIdentifier(e)},{type:DataTransferTypes.pages,data:JSON.stringify({records:[{identifier:e.identifier,tablename:"pages"}]})}]}async handleNodeAdd(e,t,o){this.updateComplete.then((()=>{this.editNode(e)}))}handleNodeDelete(e){const t={node:e,command:TreeNodeCommandEnum.DELETE};if(this.settings.displayDeleteConfirmation){Modal.confirm(TYPO3.lang["mess.delete.title"],TYPO3.lang["mess.delete"].replace("%s",t.node.name),Severity.warning,[{text:TYPO3.lang["labels.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:TYPO3.lang.delete||"Delete",btnClass:"btn-warning",name:"delete"}]).addEventListener("button.clicked",(e=>{"delete"===e.target.name&&this.sendChangeCommand(t),Modal.dismiss()}))}else this.sendChangeCommand(t)}handleNodeMove(e,t,o){const n={node:e,target:t,position:o,command:TreeNodeCommandEnum.MOVE};let a="";switch(o){case TreeNodePositionEnum.BEFORE:a=TYPO3.lang["mess.move_before"];break;case TreeNodePositionEnum.AFTER:a=TYPO3.lang["mess.move_after"];break;default:a=TYPO3.lang["mess.move_into"]}a=a.replace("%s",e.name).replace("%s",t.name);const r=Modal.confirm(TYPO3.lang.move_page,a,Severity.warning,[{text:TYPO3.lang["labels.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:TYPO3.lang["cm.copy"]||"Copy",btnClass:"btn-warning",name:"copy"},{text:TYPO3.lang["labels.move"]||"Move",btnClass:"btn-warning",name:"move"}]);r.addEventListener("button.clicked",(e=>{const t=e.target;"move"===t.name?(n.command=TreeNodeCommandEnum.MOVE,this.sendChangeCommand(n)):"copy"===t.name&&(n.command=TreeNodeCommandEnum.COPY,this.sendChangeCommand(n)),r.hideModal()}))}requestTreeUpdate(e){return new AjaxRequest(top.TYPO3.settings.ajaxUrls.record_process).post(e,{headers:{"Content-Type":"application/x-www-form-urlencoded","X-Requested-With":"XMLHttpRequest"}}).then((e=>e.resolve())).catch((e=>{this.errorNotification(e),this.loadData()}))}};EditablePageTree=__decorate([customElement("typo3-backend-navigation-component-pagetree-tree")],EditablePageTree);export{EditablePageTree};let PageTreeNavigationComponent=class extends LitElement{constructor(){super(...arguments),this.mountPointPath=null,this.configuration=null,this.refresh=()=>{this.tree.refreshOrFilterTree()},this.setMountPoint=e=>{this.setTemporaryMountPoint(e.detail.pageId)},this.selectFirstNode=()=>{this.tree.selectFirstNode()},this.loadContent=e=>{const t=e.detail.node;if(!t?.checked)return;if(ModuleStateStorage.update("web",t.__treeIdentifier,!0,t.__treeParents[0]??"0"),!1===e.detail.propagate)return;const o=top.TYPO3.ModuleMenu.App;let n=ModuleUtility.getFromName(o.getCurrentModule()).link;n+=n.includes("?")?"&":"?",top.TYPO3.Backend.ContentContainer.setUrl(n+"id="+t.identifier)},this.showContextMenu=e=>{const t=e.detail.node;t&&ContextMenu.show(t.recordType,parseInt(t.identifier,10),"tree","","",this.tree.getElementFromNode(t))},this.selectActiveNode=e=>{const t=ModuleStateStorage.current("web").selection,o=e.detail.nodes;e.detail.nodes=o.map((e=>(e.__treeIdentifier===t&&(e.checked=!0),e)))}}connectedCallback(){super.connectedCallback(),document.addEventListener("typo3:pagetree:refresh",this.refresh),document.addEventListener("typo3:pagetree:mountPoint",this.setMountPoint),document.addEventListener("typo3:pagetree:selectFirstNode",this.selectFirstNode)}disconnectedCallback(){document.removeEventListener("typo3:pagetree:refresh",this.refresh),document.removeEventListener("typo3:pagetree:mountPoint",this.setMountPoint),document.removeEventListener("typo3:pagetree:selectFirstNode",this.selectFirstNode),super.disconnectedCallback()}createRenderRoot(){return this}render(){return html`
+var __decorate=function(e,t,o,n){var a,r=arguments.length,i=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,o,n);else for(var s=e.length-1;s>=0;s--)(a=e[s])&&(i=(r<3?a(i):r>3?a(t,o,i):a(t,o))||i);return r>3&&i&&Object.defineProperty(t,o,i),i};import{html,LitElement,nothing}from"lit";import{customElement,property,query}from"lit/decorators.js";import{until}from"lit/directives/until.js";import{lll}from"@typo3/core/lit-helper.js";import AjaxRequest from"@typo3/core/ajax/ajax-request.js";import Persistent from"@typo3/backend/storage/persistent.js";import{ModuleUtility}from"@typo3/backend/module.js";import ContextMenu from"@typo3/backend/context-menu.js";import{PageTree}from"@typo3/backend/tree/page-tree.js";import{TreeNodeCommandEnum,TreeNodePositionEnum}from"@typo3/backend/tree/tree-node.js";import{TreeToolbar}from"@typo3/backend/tree/tree-toolbar.js";import Modal from"@typo3/backend/modal.js";import Severity from"@typo3/backend/severity.js";import{ModuleStateStorage}from"@typo3/backend/storage/module-state-storage.js";import{DataTransferTypes}from"@typo3/backend/enum/data-transfer-types.js";export const navigationComponentName="typo3-backend-navigation-component-pagetree";let EditablePageTree=class extends PageTree{constructor(){super(...arguments),this.allowNodeEdit=!0,this.allowNodeDrag=!0,this.allowNodeSorting=!0}sendChangeCommand(e){let t="",o="0";if(e.target)if(o=e.target.identifier,e.position===TreeNodePositionEnum.BEFORE){const t=this.getPreviousNode(e.target);o=(t.depth===e.target.depth?"-":"")+t.identifier}else e.position===TreeNodePositionEnum.AFTER&&(o="-"+o);if(e.command===TreeNodeCommandEnum.NEW){const n=e;t="&data[pages]["+e.node.identifier+"][pid]="+encodeURIComponent(o)+"&data[pages]["+e.node.identifier+"][title]="+encodeURIComponent(n.title)+"&data[pages]["+e.node.identifier+"][doktype]="+encodeURIComponent(n.doktype)}else if(e.command===TreeNodeCommandEnum.EDIT)t="&data[pages]["+e.node.identifier+"][title]="+encodeURIComponent(e.title);else if(e.command===TreeNodeCommandEnum.DELETE){const o=ModuleStateStorage.current("web");e.node.identifier===o.identifier&&this.selectFirstNode(),t="&cmd[pages]["+e.node.identifier+"][delete]=1"}else t="cmd[pages]["+e.node.identifier+"]["+e.command+"]="+o;this.requestTreeUpdate(t).then((t=>{if(t&&t.hasErrors)this.errorNotification(t.messages);else if(e.command===TreeNodeCommandEnum.NEW){const t=this.getParentNode(e.node);t.loaded=!1,this.loadChildren(t)}else this.refreshOrFilterTree()}))}initializeDragForNode(){throw new Error("unused")}async handleNodeEdit(e,t){if(e.__loading=!0,e.identifier.startsWith("NEW")){const o=this.getPreviousNode(e),n=e.depth===o.depth?TreeNodePositionEnum.AFTER:TreeNodePositionEnum.INSIDE,a={command:TreeNodeCommandEnum.NEW,node:e,title:t,position:n,target:o,doktype:e.doktype};await this.sendChangeCommand(a)}else{const o={command:TreeNodeCommandEnum.EDIT,node:e,title:t};await this.sendChangeCommand(o)}e.__loading=!1}createDataTransferItemsFromNode(e){return[{type:DataTransferTypes.treenode,data:this.getNodeTreeIdentifier(e)},{type:DataTransferTypes.pages,data:JSON.stringify({records:[{identifier:e.identifier,tablename:"pages"}]})}]}async handleNodeAdd(e,t,o){this.updateComplete.then((()=>{this.editNode(e)}))}handleNodeDelete(e){const t={node:e,command:TreeNodeCommandEnum.DELETE};if(this.settings.displayDeleteConfirmation){Modal.confirm(TYPO3.lang["mess.delete.title"],TYPO3.lang["mess.delete"].replace("%s",t.node.name),Severity.warning,[{text:TYPO3.lang["labels.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:TYPO3.lang.delete||"Delete",btnClass:"btn-warning",name:"delete"}]).addEventListener("button.clicked",(e=>{"delete"===e.target.name&&this.sendChangeCommand(t),Modal.dismiss()}))}else this.sendChangeCommand(t)}handleNodeMove(e,t,o){const n={node:e,target:t,position:o,command:TreeNodeCommandEnum.MOVE};let a="";switch(o){case TreeNodePositionEnum.BEFORE:a=TYPO3.lang["mess.move_before"];break;case TreeNodePositionEnum.AFTER:a=TYPO3.lang["mess.move_after"];break;default:a=TYPO3.lang["mess.move_into"]}a=a.replace("%s",e.name).replace("%s",t.name);const r=Modal.confirm(TYPO3.lang.move_page,a,Severity.warning,[{text:TYPO3.lang["labels.cancel"]||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:TYPO3.lang["cm.copy"]||"Copy",btnClass:"btn-warning",name:"copy"},{text:TYPO3.lang["labels.move"]||"Move",btnClass:"btn-warning",name:"move"}]);r.addEventListener("button.clicked",(e=>{const t=e.target;"move"===t.name?(n.command=TreeNodeCommandEnum.MOVE,this.sendChangeCommand(n)):"copy"===t.name&&(n.command=TreeNodeCommandEnum.COPY,this.sendChangeCommand(n)),r.hideModal()}))}requestTreeUpdate(e){return new AjaxRequest(top.TYPO3.settings.ajaxUrls.record_process).post(e,{headers:{"Content-Type":"application/x-www-form-urlencoded","X-Requested-With":"XMLHttpRequest"}}).then((e=>e.resolve())).catch((e=>{this.errorNotification(e),this.loadData()}))}};EditablePageTree=__decorate([customElement("typo3-backend-navigation-component-pagetree-tree")],EditablePageTree);export{EditablePageTree};let PageTreeNavigationComponent=class extends LitElement{constructor(){super(...arguments),this.mountPointPath=null,this.configuration=null,this.refresh=()=>{this.tree.refreshOrFilterTree()},this.setMountPoint=e=>{this.setTemporaryMountPoint(e.detail.pageId)},this.selectFirstNode=()=>{this.tree.selectFirstNode()},this.loadContent=e=>{const t=e.detail.node;if(!t?.checked)return;if(ModuleStateStorage.update("web",t.__treeIdentifier,!0,t.__treeParents[0]??"0"),!1===e.detail.propagate)return;const o=top.TYPO3.ModuleMenu.App;let n=ModuleUtility.getFromName(o.getCurrentModule()).link;n+=n.includes("?")?"&":"?",top.TYPO3.Backend.ContentContainer.setUrl(n+"id="+t.identifier)},this.showContextMenu=e=>{const t=e.detail.node;t&&ContextMenu.show(t.recordType,parseInt(t.identifier,10),"tree","","",this.tree.getElementFromNode(t),e.detail.originalEvent)},this.selectActiveNode=e=>{const t=ModuleStateStorage.current("web").selection,o=e.detail.nodes;e.detail.nodes=o.map((e=>(e.__treeIdentifier===t&&(e.checked=!0),e)))}}connectedCallback(){super.connectedCallback(),document.addEventListener("typo3:pagetree:refresh",this.refresh),document.addEventListener("typo3:pagetree:mountPoint",this.setMountPoint),document.addEventListener("typo3:pagetree:selectFirstNode",this.selectFirstNode)}disconnectedCallback(){document.removeEventListener("typo3:pagetree:refresh",this.refresh),document.removeEventListener("typo3:pagetree:mountPoint",this.setMountPoint),document.removeEventListener("typo3:pagetree:selectFirstNode",this.selectFirstNode),super.disconnectedCallback()}createRenderRoot(){return this}render(){return html`
       <div id="typo3-pagetree" class="tree">
       ${until(this.renderTree(),"")}
       </div>
diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/tree/tree.js b/typo3/sysext/backend/Resources/Public/JavaScript/tree/tree.js
index 2b6cc293060f8e2763fe436e3fa0f604a51bbd63..f7b589278cf932bc3a4273fdb1161a6c93caebcf 100644
--- a/typo3/sysext/backend/Resources/Public/JavaScript/tree/tree.js
+++ b/typo3/sysext/backend/Resources/Public/JavaScript/tree/tree.js
@@ -56,7 +56,7 @@ var __decorate=function(e,t,i,o){var n,s=arguments.length,r=s<3?t:null===o?o=Obj
             @dblclick="${t=>{this.handleNodeDoubleClick(t,e)}}"
             @focusin="${()=>{this.focusedNode=e}}"
             @focusout="${()=>{this.focusedNode===e&&(this.focusedNode=null)}}"
-            @contextmenu="${t=>{t.preventDefault(),t.stopPropagation(),this.dispatchEvent(new CustomEvent("typo3:tree:node-context",{detail:{node:e}}))}}"
+            @contextmenu="${t=>{t.preventDefault(),t.stopPropagation(),this.dispatchEvent(new CustomEvent("typo3:tree:node-context",{detail:{node:e,originalEvent:t}}))}}"
           >
             ${this.createNodeLabel(e)}
             ${this.createNodeGuides(e)}
@@ -99,7 +99,7 @@ var __decorate=function(e,t,i,o){var n,s=arguments.length,r=s<3?t:null===o?o=Obj
       </span>
     `}createNodeContentIcon(e){return this.settings.showIcons?html`
         <span class="node-icon"
-          @click="${t=>{t.preventDefault(),t.stopImmediatePropagation(),this.dispatchEvent(new CustomEvent("typo3:tree:node-context",{detail:{node:e}}))}}"
+          @click="${t=>{t.preventDefault(),t.stopImmediatePropagation(),this.dispatchEvent(new CustomEvent("typo3:tree:node-context",{detail:{node:e,originalEvent:t}}))}}"
           @dblclick="${e=>{e.preventDefault(),e.stopImmediatePropagation()}}"
         >
           <typo3-backend-icon
diff --git a/typo3/sysext/filelist/Resources/Public/JavaScript/file-list.js b/typo3/sysext/filelist/Resources/Public/JavaScript/file-list.js
index a5d55b1b861285f8c9970a10ed1f5fd760b01dff..f0b5c5a376d12b6fb876961d93110c6a77d91015 100644
--- a/typo3/sysext/filelist/Resources/Public/JavaScript/file-list.js
+++ b/typo3/sysext/filelist/Resources/Public/JavaScript/file-list.js
@@ -10,4 +10,4 @@
  *
  * The TYPO3 project - inspiring people to share!
  */
-import{lll}from"@typo3/core/lit-helper.js";import DocumentService from"@typo3/core/document-service.js";import Notification from"@typo3/backend/notification.js";import InfoWindow from"@typo3/backend/info-window.js";import{BroadcastMessage}from"@typo3/backend/broadcast-message.js";import broadcastService from"@typo3/backend/broadcast-service.js";import{FileListActionEvent,FileListActionSelector,FileListActionUtility}from"@typo3/filelist/file-list-actions.js";import NProgress from"nprogress";import Icons from"@typo3/backend/icons.js";import AjaxRequest from"@typo3/core/ajax/ajax-request.js";import RegularEvent from"@typo3/core/event/regular-event.js";import{ModuleStateStorage}from"@typo3/backend/storage/module-state-storage.js";import{default as Modal}from"@typo3/backend/modal.js";import{SeverityEnum}from"@typo3/backend/enum/severity.js";import Severity from"@typo3/backend/severity.js";import{MultiRecordSelectionSelectors}from"@typo3/backend/multi-record-selection.js";import ContextMenu from"@typo3/backend/context-menu.js";var Selectors;!function(e){e.fileListFormSelector='form[name="fileListForm"]',e.commandSelector='input[name="cmd"]',e.searchFieldSelector='input[name="searchTerm"]',e.pointerFieldSelector='input[name="pointer"]'}(Selectors||(Selectors={}));export const fileListOpenElementBrowser="typo3:filelist:openElementBrowser";export default class Filelist{constructor(){this.downloadFilesAndFolders=e=>{e.preventDefault();const t=e.target,o=e.detail,i=o.configuration,n=[];o.checkboxes.forEach((e=>{if(e.checked){const t=e.closest(FileListActionSelector.elementSelector),o=FileListActionUtility.getResourceForElement(t);n.unshift(o.identifier)}})),n.length?this.triggerDownload(n,i.downloadUrl,t):Notification.warning(lll("file_download.invalidSelection"))},Filelist.processTriggers(),new RegularEvent(fileListOpenElementBrowser,(e=>{const t=new URL(e.detail.actionUrl,window.location.origin);t.searchParams.set("expandFolder",e.detail.identifier),t.searchParams.set("mode",e.detail.mode);Modal.advanced({type:Modal.types.iframe,content:t.toString(),size:Modal.sizes.large}).addEventListener("typo3-modal-hidden",(()=>{top.list_frame.document.location.reload()}))})).bindTo(document),new RegularEvent(FileListActionEvent.primary,(e=>{const t=e.detail.resources[0];if("file"===t.type&&(window.location.href=top.TYPO3.settings.FormEngine.moduleUrl+"&edit[sys_file_metadata]["+t.metaUid+"]=edit&returnUrl="+Filelist.getReturnUrl("")),"folder"===t.type){const e=Filelist.parseQueryParameters(document.location);e.id=t.identifier;let o="";Object.keys(e).forEach((t=>{""!==e[t]&&(o=o+"&"+t+"="+e[t])})),window.location.href=window.location.pathname+"?"+o.substring(1)}})).bindTo(document),new RegularEvent(FileListActionEvent.primaryContextmenu,(e=>{const t=e.detail,o=t.resources[0];ContextMenu.show("sys_file",o.identifier,"","","",t.trigger)})).bindTo(document),new RegularEvent(FileListActionEvent.show,(e=>{const t=e.detail.resources[0];Filelist.openInfoPopup("_"+t.type.toUpperCase(),t.identifier)})).bindTo(document),new RegularEvent(FileListActionEvent.download,(e=>{const t=e.detail,o=t.resources[0];this.triggerDownload([o.identifier],t.url,t.trigger)})).bindTo(document),new RegularEvent(FileListActionEvent.updateOnlineMedia,(e=>{const t=e.detail,o=t.resources[0];this.updateOnlineMedia(o,t.url)})).bindTo(document),DocumentService.ready().then((()=>{new RegularEvent("click",((e,t)=>{e.preventDefault(),document.dispatchEvent(new CustomEvent(fileListOpenElementBrowser,{detail:{actionUrl:t.href,identifier:t.dataset.identifier,mode:t.dataset.mode}}))})).delegateTo(document,".t3js-element-browser")})),new RegularEvent("multiRecordSelection:action:edit",this.editFileMetadata).bindTo(document),new RegularEvent("multiRecordSelection:action:delete",this.deleteMultiple).bindTo(document),new RegularEvent("multiRecordSelection:action:download",this.downloadFilesAndFolders).bindTo(document),new RegularEvent("multiRecordSelection:action:copyMarked",(e=>{Filelist.submitClipboardFormWithCommand("copyMarked",e.target)})).bindTo(document),new RegularEvent("multiRecordSelection:action:removeMarked",(e=>{Filelist.submitClipboardFormWithCommand("removeMarked",e.target)})).bindTo(document);const e=""!==document.querySelector([Selectors.fileListFormSelector,Selectors.searchFieldSelector].join(" "))?.value;new RegularEvent("search",(t=>{const o=t.target;""===o.value&&e&&o.closest(Selectors.fileListFormSelector)?.submit()})).delegateTo(document,Selectors.searchFieldSelector)}static submitClipboardFormWithCommand(e,t){const o=t.closest(Selectors.fileListFormSelector);if(!o)return;const i=o.querySelector(Selectors.commandSelector);if(i){if(i.value=e,"copyMarked"===e||"removeMarked"===e){const e=o.querySelector(Selectors.pointerFieldSelector),t=Filelist.parseQueryParameters(document.location).pointer;e&&t&&(e.value=t)}o.submit()}}static openInfoPopup(e,t){InfoWindow.showItem(e,t)}static processTriggers(){const e=document.querySelector(".filelist-main");if(null===e)return;const t=encodeURIComponent(e.dataset.filelistCurrentIdentifier);ModuleStateStorage.update("media",t,!0,void 0),Filelist.emitTreeUpdateRequest(e.dataset.filelistCurrentIdentifier)}static emitTreeUpdateRequest(e){const t=new BroadcastMessage("filelist","treeUpdateRequested",{type:"folder",identifier:e});broadcastService.post(t)}static parseQueryParameters(e){const t={};if(e&&Object.prototype.hasOwnProperty.call(e,"search")){const o=e.search.substr(1).split("&");for(let e=0;e<o.length;e++){const i=o[e].split("=");t[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}}return t}static getReturnUrl(e){return""===e&&(e=top.list_frame.document.location.pathname+top.list_frame.document.location.search),encodeURIComponent(e)}deleteMultiple(e){e.preventDefault();const t=e.detail.configuration;Modal.advanced({title:t.title||"Delete",content:t.content||"Are you sure you want to delete those files and folders?",severity:SeverityEnum.warning,buttons:[{text:TYPO3.lang["button.close"]||"Close",active:!0,btnClass:"btn-default",trigger:(e,t)=>t.hideModal()},{text:t.ok||TYPO3.lang["button.ok"]||"OK",btnClass:"btn-"+Severity.getCssClass(SeverityEnum.warning),trigger:(t,o)=>{Filelist.submitClipboardFormWithCommand("delete",e.target),o.hideModal()}}]})}editFileMetadata(e){e.preventDefault();const t=e.detail,o=t.configuration;if(!o||!o.idField||!o.table)return;const i=[];t.checkboxes.forEach((e=>{const t=e.closest(MultiRecordSelectionSelectors.elementSelector);null!==t&&t.dataset[o.idField]&&i.push(t.dataset[o.idField])})),i.length?window.location.href=top.TYPO3.settings.FormEngine.moduleUrl+"&edit["+o.table+"]["+i.join(",")+"]=edit&returnUrl="+Filelist.getReturnUrl(o.returnUrl||""):Notification.warning("The selected elements can not be edited.")}triggerDownload(e,t,o){Notification.info(lll("file_download.prepare"),"",2);const i=o?.innerHTML;o&&(o.setAttribute("disabled","disabled"),Icons.getIcon("spinner-circle",Icons.sizes.small).then((e=>{o.innerHTML=e}))),NProgress.configure({parent:"#typo3-filelist",showSpinner:!1}).start(),new AjaxRequest(t).post({items:e}).then((async e=>{let t=e.response.headers.get("Content-Disposition");if(!t){const t=await e.resolve();return void(!1===t.success&&t.status?Notification.warning(lll("file_download."+t.status),lll("file_download."+t.status+".message"),10):Notification.error(lll("file_download.error")))}t=t.substring(t.indexOf(" filename=")+10);const o=await e.raw().arrayBuffer(),i=new Blob([o],{type:e.raw().headers.get("Content-Type")}),n=URL.createObjectURL(i),r=document.createElement("a");r.href=n,r.download=t,document.body.appendChild(r),r.click(),URL.revokeObjectURL(n),document.body.removeChild(r),Notification.success(lll("file_download.success"),"",2)})).catch((()=>{Notification.error(lll("file_download.error"))})).finally((()=>{NProgress.done(),o&&(o.removeAttribute("disabled"),o.innerHTML=i)}))}updateOnlineMedia(e,t){t&&e.uid&&"file"===e.type&&(NProgress.configure({parent:"#typo3-filelist",showSpinner:!1}).start(),new AjaxRequest(t).post({resource:e}).then((()=>{Notification.success(lll("online_media.update.success"))})).catch((()=>{Notification.error(lll("online_media.update.error"))})).finally((()=>{NProgress.done(),window.location.reload()})))}}
\ No newline at end of file
+import{lll}from"@typo3/core/lit-helper.js";import DocumentService from"@typo3/core/document-service.js";import Notification from"@typo3/backend/notification.js";import InfoWindow from"@typo3/backend/info-window.js";import{BroadcastMessage}from"@typo3/backend/broadcast-message.js";import broadcastService from"@typo3/backend/broadcast-service.js";import{FileListActionEvent,FileListActionSelector,FileListActionUtility}from"@typo3/filelist/file-list-actions.js";import NProgress from"nprogress";import Icons from"@typo3/backend/icons.js";import AjaxRequest from"@typo3/core/ajax/ajax-request.js";import RegularEvent from"@typo3/core/event/regular-event.js";import{ModuleStateStorage}from"@typo3/backend/storage/module-state-storage.js";import{default as Modal}from"@typo3/backend/modal.js";import{SeverityEnum}from"@typo3/backend/enum/severity.js";import Severity from"@typo3/backend/severity.js";import{MultiRecordSelectionSelectors}from"@typo3/backend/multi-record-selection.js";import ContextMenu from"@typo3/backend/context-menu.js";var Selectors;!function(e){e.fileListFormSelector='form[name="fileListForm"]',e.commandSelector='input[name="cmd"]',e.searchFieldSelector='input[name="searchTerm"]',e.pointerFieldSelector='input[name="pointer"]'}(Selectors||(Selectors={}));export const fileListOpenElementBrowser="typo3:filelist:openElementBrowser";export default class Filelist{constructor(){this.downloadFilesAndFolders=e=>{e.preventDefault();const t=e.target,o=e.detail,i=o.configuration,n=[];o.checkboxes.forEach((e=>{if(e.checked){const t=e.closest(FileListActionSelector.elementSelector),o=FileListActionUtility.getResourceForElement(t);n.unshift(o.identifier)}})),n.length?this.triggerDownload(n,i.downloadUrl,t):Notification.warning(lll("file_download.invalidSelection"))},Filelist.processTriggers(),new RegularEvent(fileListOpenElementBrowser,(e=>{const t=new URL(e.detail.actionUrl,window.location.origin);t.searchParams.set("expandFolder",e.detail.identifier),t.searchParams.set("mode",e.detail.mode);Modal.advanced({type:Modal.types.iframe,content:t.toString(),size:Modal.sizes.large}).addEventListener("typo3-modal-hidden",(()=>{top.list_frame.document.location.reload()}))})).bindTo(document),new RegularEvent(FileListActionEvent.primary,(e=>{const t=e.detail.resources[0];if("file"===t.type&&(window.location.href=top.TYPO3.settings.FormEngine.moduleUrl+"&edit[sys_file_metadata]["+t.metaUid+"]=edit&returnUrl="+Filelist.getReturnUrl("")),"folder"===t.type){const e=Filelist.parseQueryParameters(document.location);e.id=t.identifier;let o="";Object.keys(e).forEach((t=>{""!==e[t]&&(o=o+"&"+t+"="+e[t])})),window.location.href=window.location.pathname+"?"+o.substring(1)}})).bindTo(document),new RegularEvent(FileListActionEvent.primaryContextmenu,(e=>{const t=e.detail,o=t.resources[0];ContextMenu.show("sys_file",o.identifier,"","","",t.trigger,t.event)})).bindTo(document),new RegularEvent(FileListActionEvent.show,(e=>{const t=e.detail.resources[0];Filelist.openInfoPopup("_"+t.type.toUpperCase(),t.identifier)})).bindTo(document),new RegularEvent(FileListActionEvent.download,(e=>{const t=e.detail,o=t.resources[0];this.triggerDownload([o.identifier],t.url,t.trigger)})).bindTo(document),new RegularEvent(FileListActionEvent.updateOnlineMedia,(e=>{const t=e.detail,o=t.resources[0];this.updateOnlineMedia(o,t.url)})).bindTo(document),DocumentService.ready().then((()=>{new RegularEvent("click",((e,t)=>{e.preventDefault(),document.dispatchEvent(new CustomEvent(fileListOpenElementBrowser,{detail:{actionUrl:t.href,identifier:t.dataset.identifier,mode:t.dataset.mode}}))})).delegateTo(document,".t3js-element-browser")})),new RegularEvent("multiRecordSelection:action:edit",this.editFileMetadata).bindTo(document),new RegularEvent("multiRecordSelection:action:delete",this.deleteMultiple).bindTo(document),new RegularEvent("multiRecordSelection:action:download",this.downloadFilesAndFolders).bindTo(document),new RegularEvent("multiRecordSelection:action:copyMarked",(e=>{Filelist.submitClipboardFormWithCommand("copyMarked",e.target)})).bindTo(document),new RegularEvent("multiRecordSelection:action:removeMarked",(e=>{Filelist.submitClipboardFormWithCommand("removeMarked",e.target)})).bindTo(document);const e=""!==document.querySelector([Selectors.fileListFormSelector,Selectors.searchFieldSelector].join(" "))?.value;new RegularEvent("search",(t=>{const o=t.target;""===o.value&&e&&o.closest(Selectors.fileListFormSelector)?.submit()})).delegateTo(document,Selectors.searchFieldSelector)}static submitClipboardFormWithCommand(e,t){const o=t.closest(Selectors.fileListFormSelector);if(!o)return;const i=o.querySelector(Selectors.commandSelector);if(i){if(i.value=e,"copyMarked"===e||"removeMarked"===e){const e=o.querySelector(Selectors.pointerFieldSelector),t=Filelist.parseQueryParameters(document.location).pointer;e&&t&&(e.value=t)}o.submit()}}static openInfoPopup(e,t){InfoWindow.showItem(e,t)}static processTriggers(){const e=document.querySelector(".filelist-main");if(null===e)return;const t=encodeURIComponent(e.dataset.filelistCurrentIdentifier);ModuleStateStorage.update("media",t,!0,void 0),Filelist.emitTreeUpdateRequest(e.dataset.filelistCurrentIdentifier)}static emitTreeUpdateRequest(e){const t=new BroadcastMessage("filelist","treeUpdateRequested",{type:"folder",identifier:e});broadcastService.post(t)}static parseQueryParameters(e){const t={};if(e&&Object.prototype.hasOwnProperty.call(e,"search")){const o=e.search.substr(1).split("&");for(let e=0;e<o.length;e++){const i=o[e].split("=");t[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}}return t}static getReturnUrl(e){return""===e&&(e=top.list_frame.document.location.pathname+top.list_frame.document.location.search),encodeURIComponent(e)}deleteMultiple(e){e.preventDefault();const t=e.detail.configuration;Modal.advanced({title:t.title||"Delete",content:t.content||"Are you sure you want to delete those files and folders?",severity:SeverityEnum.warning,buttons:[{text:TYPO3.lang["button.close"]||"Close",active:!0,btnClass:"btn-default",trigger:(e,t)=>t.hideModal()},{text:t.ok||TYPO3.lang["button.ok"]||"OK",btnClass:"btn-"+Severity.getCssClass(SeverityEnum.warning),trigger:(t,o)=>{Filelist.submitClipboardFormWithCommand("delete",e.target),o.hideModal()}}]})}editFileMetadata(e){e.preventDefault();const t=e.detail,o=t.configuration;if(!o||!o.idField||!o.table)return;const i=[];t.checkboxes.forEach((e=>{const t=e.closest(MultiRecordSelectionSelectors.elementSelector);null!==t&&t.dataset[o.idField]&&i.push(t.dataset[o.idField])})),i.length?window.location.href=top.TYPO3.settings.FormEngine.moduleUrl+"&edit["+o.table+"]["+i.join(",")+"]=edit&returnUrl="+Filelist.getReturnUrl(o.returnUrl||""):Notification.warning("The selected elements can not be edited.")}triggerDownload(e,t,o){Notification.info(lll("file_download.prepare"),"",2);const i=o?.innerHTML;o&&(o.setAttribute("disabled","disabled"),Icons.getIcon("spinner-circle",Icons.sizes.small).then((e=>{o.innerHTML=e}))),NProgress.configure({parent:"#typo3-filelist",showSpinner:!1}).start(),new AjaxRequest(t).post({items:e}).then((async e=>{let t=e.response.headers.get("Content-Disposition");if(!t){const t=await e.resolve();return void(!1===t.success&&t.status?Notification.warning(lll("file_download."+t.status),lll("file_download."+t.status+".message"),10):Notification.error(lll("file_download.error")))}t=t.substring(t.indexOf(" filename=")+10);const o=await e.raw().arrayBuffer(),i=new Blob([o],{type:e.raw().headers.get("Content-Type")}),n=URL.createObjectURL(i),r=document.createElement("a");r.href=n,r.download=t,document.body.appendChild(r),r.click(),URL.revokeObjectURL(n),document.body.removeChild(r),Notification.success(lll("file_download.success"),"",2)})).catch((()=>{Notification.error(lll("file_download.error"))})).finally((()=>{NProgress.done(),o&&(o.removeAttribute("disabled"),o.innerHTML=i)}))}updateOnlineMedia(e,t){t&&e.uid&&"file"===e.type&&(NProgress.configure({parent:"#typo3-filelist",showSpinner:!1}).start(),new AjaxRequest(t).post({resource:e}).then((()=>{Notification.success(lll("online_media.update.success"))})).catch((()=>{Notification.error(lll("online_media.update.error"))})).finally((()=>{NProgress.done(),window.location.reload()})))}}
\ No newline at end of file