@wp-playground/components 3.1.44 → 3.1.45

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.
@@ -7,6 +7,8 @@ export type FileNode = {
7
7
  };
8
8
  export type FilePickerTreeProps = {
9
9
  withContextMenu?: boolean;
10
+ /** Disables filesystem mutations while preserving selection and previews. */
11
+ readOnly?: boolean;
10
12
  filesystem: AsyncWritableFilesystem;
11
13
  root?: string;
12
14
  initialSelectedPath?: string;
@@ -26,6 +28,10 @@ export type FilePickerTreeHandle = {
26
28
  remapPath: (from: string, to: string) => void;
27
29
  createFile: (absSelectedPath?: string) => Promise<void>;
28
30
  createFolder: (absSelectedPath?: string) => Promise<void>;
31
+ /** Imports captured file-input entries into an existing tree directory. */
32
+ importFiles: (files: readonly File[], destinationDir: string) => Promise<void>;
33
+ /** Imports a drop payload into an existing tree directory. */
34
+ importDataTransfer: (dataTransfer: DataTransfer, destinationDir: string) => Promise<void>;
29
35
  };
30
36
  export declare const FilePickerTree: React.ForwardRefExoticComponent<FilePickerTreeProps & React.RefAttributes<FilePickerTreeHandle>>;
31
37
  export default FilePickerTree;
@@ -9,5 +9,13 @@ export type FileExplorerSidebarProps = {
9
9
  onSelectionCleared: () => Promise<void> | void;
10
10
  onShowMessage: (path: string | null, message: string | JSX.Element) => Promise<void> | void;
11
11
  documentRoot: string;
12
+ readOnly?: boolean;
13
+ title?: string;
14
+ showBinaryPreviewHeader?: boolean;
15
+ dockPresentation?: boolean;
16
+ useWordPressTooltips?: boolean;
12
17
  };
13
- export declare function FileExplorerSidebar({ filesystem, currentPath, selectedDirPath, setSelectedDirPath, onFileOpened, onSelectionCleared, onShowMessage, documentRoot, }: FileExplorerSidebarProps): React.JSX.Element;
18
+ /**
19
+ * Renders the file explorer and opens selected files in the editor preview area.
20
+ */
21
+ export declare function FileExplorerSidebar({ filesystem, currentPath, selectedDirPath, setSelectedDirPath, onFileOpened, onSelectionCleared, onShowMessage, documentRoot, readOnly, title, showBinaryPreviewHeader, dockPresentation, useWordPressTooltips, }: FileExplorerSidebarProps): React.JSX.Element;
@@ -12,6 +12,25 @@ export declare const createDownloadUrl: (data: Uint8Array, filename: string) =>
12
12
  url: string;
13
13
  filename: string;
14
14
  };
15
+ export type InlineFilePreviewReadResult = {
16
+ type: 'inline';
17
+ data: Uint8Array;
18
+ } | {
19
+ type: 'too-large';
20
+ };
21
+ type BrowserReadableFile = {
22
+ arrayBuffer(): Promise<ArrayBuffer>;
23
+ stream?: () => ReadableStream<Uint8Array>;
24
+ size?: number;
25
+ filesize?: number;
26
+ };
27
+ /**
28
+ * Classifies a file as inline-editable or too large for the editor.
29
+ *
30
+ * Uses known size metadata before reading when it is available. Stream-backed
31
+ * files without a known size are read only until they cross the inline limit.
32
+ */
33
+ export declare function readFileForInlinePreview(file: BrowserReadableFile, maxInlineBytes?: number): Promise<InlineFilePreviewReadResult>;
15
34
  /**
16
35
  * Gets the MIME type for a filename based on its extension.
17
36
  */
@@ -21,3 +40,4 @@ export declare const getMimeType: (filename: string) => string;
21
40
  * (images, videos, audio).
22
41
  */
23
42
  export declare const isPreviewableBinary: (mimeType: string) => boolean;
43
+ export {};
@@ -6,16 +6,11 @@ export type PlaygroundFileEditorProps = {
6
6
  documentRoot: string;
7
7
  initialPath?: string | null;
8
8
  placeholderText?: string;
9
- onSaveFile?: (path: string, content: string) => Promise<void>;
10
- /**
11
- * Called before the filesystem changes, allowing the parent to flush
12
- * any pending saves to the old filesystem.
13
- */
14
- onBeforeFilesystemChange?: (oldFilesystem: AsyncWritableFilesystem) => Promise<void>;
9
+ dockPresentation?: boolean;
15
10
  };
16
11
  /**
17
12
  * A reusable file browser component with a file tree on the left and
18
13
  * a code editor on the right. Supports auto-save with debouncing,
19
14
  * cursor position preservation, and binary file handling.
20
15
  */
21
- export declare function PlaygroundFileEditor({ filesystem, isVisible, documentRoot, initialPath, placeholderText, onSaveFile, onBeforeFilesystemChange, }: PlaygroundFileEditorProps): React.JSX.Element;
16
+ export declare function PlaygroundFileEditor({ filesystem, isVisible, documentRoot, initialPath, placeholderText, dockPresentation, }: PlaygroundFileEditorProps): React.JSX.Element;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ import type { AsyncWritableFilesystem } from '../../../storage/src/index.ts';
3
+ type FilesystemName = 'a' | 'b';
4
+ declare global {
5
+ interface Window {
6
+ __fileEditorHarness?: {
7
+ filesystems: Record<FilesystemName, AsyncWritableFilesystem>;
8
+ readFileAsText: (filesystem: FilesystemName, path: string) => Promise<string>;
9
+ switchFilesystem: (filesystem: FilesystemName) => void;
10
+ mountEditor: () => void;
11
+ unmountEditor: () => void;
12
+ delayNextWrite: () => void;
13
+ releaseDelayedWrite: () => void;
14
+ isWriteDelayed: () => boolean;
15
+ };
16
+ }
17
+ }
18
+ export declare function FileEditorHarness(): React.JSX.Element;
19
+ export {};
@@ -1,5 +1,14 @@
1
1
  import React from 'react';
2
2
  import type { AsyncWritableFilesystem } from '../../../storage/src/index.ts';
3
+ type DirNode = {
4
+ type: 'dir';
5
+ children: Record<string, FsEntry>;
6
+ };
7
+ type FileNodeEntry = {
8
+ type: 'file';
9
+ content: string;
10
+ };
11
+ type FsEntry = DirNode | FileNodeEntry;
3
12
  declare global {
4
13
  interface Window {
5
14
  __filePickerHarness?: {
@@ -10,4 +19,27 @@ declare global {
10
19
  };
11
20
  }
12
21
  }
22
+ declare class InMemoryFilesystem extends EventTarget implements AsyncWritableFilesystem {
23
+ private root;
24
+ constructor(snapshot: DirNode);
25
+ private resolve;
26
+ private resolveDir;
27
+ private resolveParent;
28
+ listFiles(path: string): Promise<string[]>;
29
+ isDir(path: string): Promise<boolean>;
30
+ fileExists(path: string): Promise<boolean>;
31
+ read(path: string): Promise<{
32
+ arrayBuffer(): Promise<ArrayBuffer>;
33
+ }>;
34
+ readFileAsText(path: string): Promise<string>;
35
+ writeFile(path: string, data: Uint8Array | string): Promise<void>;
36
+ mkdir(path: string): Promise<void>;
37
+ rmdir(path: string, options?: {
38
+ recursive?: boolean;
39
+ }): Promise<void>;
40
+ mv(source: string, destination: string): Promise<void>;
41
+ unlink(path: string): Promise<void>;
42
+ }
43
+ export declare const createFilesystem: () => InMemoryFilesystem;
13
44
  export declare function FilePickerTreeHarness(): React.JSX.Element;
45
+ export {};
package/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var Kt=Object.create;var Dt=Object.defineProperty;var Jt=Object.getOwnPropertyDescriptor;var Xt=Object.getOwnPropertyNames;var Qt=Object.getPrototypeOf,er=Object.prototype.hasOwnProperty;var tr=(n,c,l,m)=>{if(c&&typeof c=="object"||typeof c=="function")for(let p of Xt(c))!er.call(n,p)&&p!==l&&Dt(n,p,{get:()=>c[p],enumerable:!(m=Jt(c,p))||m.enumerable});return n};var Ke=(n,c,l)=>(l=n!=null?Kt(Qt(n)):{},tr(c||!n||!n.__esModule?Dt(l,"default",{value:n,enumerable:!0}):l,n));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),se=require("@php-wasm/util"),le=require("@wordpress/components"),Qe=require("classnames"),mt=require("@wordpress/element"),rr=require("clsx"),Oe=require("@codemirror/state"),ve=require("@codemirror/view"),ut=require("@codemirror/commands"),Ot=require("@codemirror/search"),ft=require("@codemirror/autocomplete"),We=require("@codemirror/language"),et=require("@codemirror/lang-php"),At=require("@wp-playground/components"),dt=require("@php-wasm/logger"),Lt=require("@php-wasm/universal/mime-types"),nr=n=>t.createElement("svg",{width:"32",height:"32",viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n},t.createElement("rect",{width:"10.4176",height:"10.4176",rx:"3.86258",transform:"matrix(0.829038 -0.559193 0.838671 0.544639 7.45703 24.1775)",stroke:"white",strokeWidth:"0.965644"}),t.createElement("rect",{width:"13.2346",height:"13.2346",rx:"3.86258",transform:"matrix(0.829038 -0.559193 0.838671 0.544639 5.0918 18.9934)",stroke:"white",strokeWidth:"1.44847"}),t.createElement("rect",{width:"17.451",height:"17.451",rx:"3.86258",transform:"matrix(0.829038 -0.559193 0.838671 0.544639 1.55371 11.6099)",stroke:"white",strokeWidth:"1.93129"})),ar=n=>t.createElement("svg",{width:"16",height:"17",viewBox:"0 0 16 17",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n},t.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 15C4.41015 15 1.5 12.0899 1.5 8.5C1.5 4.91015 4.41015 2 8 2C11.5899 2 14.5 4.91015 14.5 8.5C14.5 12.0899 11.5899 15 8 15ZM0 8.5C0 4.08172 3.58172 0.5 8 0.5C12.4183 0.5 16 4.08172 16 8.5C16 12.9183 12.4183 16.5 8 16.5C3.58172 16.5 0 12.9183 0 8.5ZM9 9.5V4.5H7.5V8H5.5V9.5H9Z",fill:"#949494"})),or=n=>t.createElement("svg",{width:"20",height:"21",viewBox:"0 0 20 21",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n},t.createElement("path",{d:"M20 10.5C20 4.99 15.51 0.5 10 0.5C4.48 0.5 0 4.99 0 10.5C0 16.02 4.48 20.5 10 20.5C15.51 20.5 20 16.02 20 10.5ZM7.78 15.87L4.37 6.72C4.92 6.7 5.54 6.64 5.54 6.64C6.04 6.58 5.98 5.51 5.48 5.53C5.48 5.53 4.03 5.64 3.11 5.64C2.93 5.64 2.74 5.64 2.53 5.63C4.12 3.19 6.87 1.61 10 1.61C12.33 1.61 14.45 2.48 16.05 3.95C15.37 3.84 14.4 4.34 14.4 5.53C14.4 6.27 14.85 6.89 15.3 7.63C15.65 8.24 15.85 8.99 15.85 10.09C15.85 11.58 14.45 15.09 14.45 15.09L11.42 6.72C11.96 6.7 12.24 6.55 12.24 6.55C12.74 6.5 12.68 5.3 12.18 5.33C12.18 5.33 10.74 5.45 9.8 5.45C8.93 5.45 7.47 5.33 7.47 5.33C6.97 5.3 6.91 6.53 7.41 6.55L8.33 6.63L9.59 10.04L7.78 15.87ZM17.41 10.5C17.65 9.86 18.15 8.63 17.84 6.25C18.54 7.54 18.89 8.96 18.89 10.5C18.89 13.79 17.16 16.74 14.49 18.28C15.46 15.69 16.43 13.08 17.41 10.5ZM6.1 18.59C3.12 17.15 1.11 14.03 1.11 10.5C1.11 9.2 1.34 8.02 1.83 6.91C3.25 10.8 4.67 14.7 6.1 18.59ZM10.13 11.96L12.71 18.94C11.85 19.23 10.95 19.39 10 19.39C9.21 19.39 8.43 19.28 7.71 19.06C8.52 16.68 9.33 14.32 10.13 11.96Z",fill:"#ffffff"})),Vt=t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"15",height:"14",viewBox:"0 0 15 14",fill:"none"},t.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.59196 3.59524L6.77745 1.96623C6.70755 1.82641 6.56464 1.7381 6.40832 1.7381H1.65079C1.42287 1.7381 1.2381 1.92287 1.2381 2.15079V11.8492C1.2381 12.0771 1.42287 12.2619 1.65079 12.2619H13.2063C13.4343 12.2619 13.619 12.0771 13.619 11.8492V4.00794C13.619 3.78001 13.4343 3.59524 13.2063 3.59524H7.59196ZM8.35714 2.35714L7.88484 1.41254C7.60521 0.853274 7.0336 0.5 6.40832 0.5H1.65079C0.739085 0.5 0 1.23909 0 2.15079V11.8492C0 12.7609 0.739085 13.5 1.65079 13.5H13.2063C14.1181 13.5 14.8571 12.7609 14.8571 11.8492V4.00794C14.8571 3.09623 14.1181 2.35714 13.2063 2.35714H8.35714Z"})),Bt=t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",fill:"currentColor",className:"bi bi-file-earmark",viewBox:"0 0 16 16"},t.createElement("path",{d:"M14 4.5V14a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2h5.5zm-3 0A1.5 1.5 0 0 1 9.5 3V1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V4.5z"})),ir=n=>t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 14 14",fill:"none",...n},t.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 12.6875C3.85888 12.6875 1.3125 10.1411 1.3125 7C1.3125 3.85888 3.85888 1.3125 7 1.3125C10.1411 1.3125 12.6875 3.85888 12.6875 7C12.6875 10.1411 10.1411 12.6875 7 12.6875ZM0 7C0 3.13401 3.13401 0 7 0C10.866 0 14 3.13401 14 7C14 10.866 10.866 14 7 14C3.13401 14 0 10.866 0 7ZM7.875 7.875V3.5H6.5625V6.5625H4.8125V7.875H7.875Z",fill:"#949494"})),sr=t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 14 14",fill:"none"},t.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.25 1.3125H1.75C1.50838 1.3125 1.3125 1.50838 1.3125 1.75V4.37495H12.6875V1.75C12.6875 1.50837 12.4916 1.3125 12.25 1.3125ZM12.6875 5.68745H5.25003V12.6875H12.25C12.4916 12.6875 12.6875 12.4916 12.6875 12.25V5.68745ZM3.93753 5.68745H1.3125V12.25C1.3125 12.4916 1.50837 12.6875 1.75 12.6875H3.93753L3.93753 5.68745ZM1.75 0H12.25C13.2165 0 14 0.783502 14 1.75V12.25C14 13.2165 13.2165 14 12.25 14H1.75C0.783502 14 0 13.2165 0 12.25V1.75C0 0.783502 0.783502 0 1.75 0Z",fill:"#949494"}));function lr(n){return`data:${n.mime};base64,${n.data}`}function cr({size:n=24,sidebarActive:c=!1}){return t.createElement("svg",{width:n,height:n,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},t.createElement("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),c?t.createElement("rect",{x:"3",y:"3",width:"7",height:"18",rx:"2",ry:"2",fill:"currentColor"}):t.createElement("rect",{x:"3",y:"3",width:"8",height:"18",rx:"2",ry:"2",fill:"none",stroke:"currentColor",strokeWidth:"2"}))}const Ft=mt.forwardRef(({icon:n,size:c=24,...l},m)=>mt.cloneElement(n,{width:c,height:c,...l,ref:m}));var Pt={exports:{}},Je={};/**
1
+ "use strict";var Jt=Object.create;var Ft=Object.defineProperty;var Xt=Object.getOwnPropertyDescriptor;var Qt=Object.getOwnPropertyNames;var er=Object.getPrototypeOf,tr=Object.prototype.hasOwnProperty;var rr=(n,s,d,l)=>{if(s&&typeof s=="object"||typeof s=="function")for(let x of Qt(s))!tr.call(n,x)&&x!==d&&Ft(n,x,{get:()=>s[x],enumerable:!(l=Xt(s,x))||l.enumerable});return n};var et=(n,s,d)=>(d=n!=null?Jt(er(n)):{},rr(s||!n||!n.__esModule?Ft(d,"default",{value:n,enumerable:!0}):d,n));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),G=require("@php-wasm/util"),X=require("@wordpress/components"),Ne=require("classnames"),pt=require("@wordpress/element"),nr=require("clsx"),Me=require("@codemirror/state"),be=require("@codemirror/view"),dt=require("@codemirror/commands"),It=require("@codemirror/search"),mt=require("@codemirror/autocomplete"),Ge=require("@codemirror/language"),nt=require("@codemirror/lang-php"),Lt=require("@wp-playground/components"),Ye=require("@php-wasm/logger"),Mt=require("@php-wasm/universal/mime-types"),ar=n=>e.createElement("svg",{width:"32",height:"32",viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n},e.createElement("rect",{width:"10.4176",height:"10.4176",rx:"3.86258",transform:"matrix(0.829038 -0.559193 0.838671 0.544639 7.45703 24.1775)",stroke:"white",strokeWidth:"0.965644"}),e.createElement("rect",{width:"13.2346",height:"13.2346",rx:"3.86258",transform:"matrix(0.829038 -0.559193 0.838671 0.544639 5.0918 18.9934)",stroke:"white",strokeWidth:"1.44847"}),e.createElement("rect",{width:"17.451",height:"17.451",rx:"3.86258",transform:"matrix(0.829038 -0.559193 0.838671 0.544639 1.55371 11.6099)",stroke:"white",strokeWidth:"1.93129"})),or=n=>e.createElement("svg",{width:"16",height:"17",viewBox:"0 0 16 17",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n},e.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 15C4.41015 15 1.5 12.0899 1.5 8.5C1.5 4.91015 4.41015 2 8 2C11.5899 2 14.5 4.91015 14.5 8.5C14.5 12.0899 11.5899 15 8 15ZM0 8.5C0 4.08172 3.58172 0.5 8 0.5C12.4183 0.5 16 4.08172 16 8.5C16 12.9183 12.4183 16.5 8 16.5C3.58172 16.5 0 12.9183 0 8.5ZM9 9.5V4.5H7.5V8H5.5V9.5H9Z",fill:"#949494"})),ir=n=>e.createElement("svg",{width:"20",height:"21",viewBox:"0 0 20 21",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n},e.createElement("path",{d:"M20 10.5C20 4.99 15.51 0.5 10 0.5C4.48 0.5 0 4.99 0 10.5C0 16.02 4.48 20.5 10 20.5C15.51 20.5 20 16.02 20 10.5ZM7.78 15.87L4.37 6.72C4.92 6.7 5.54 6.64 5.54 6.64C6.04 6.58 5.98 5.51 5.48 5.53C5.48 5.53 4.03 5.64 3.11 5.64C2.93 5.64 2.74 5.64 2.53 5.63C4.12 3.19 6.87 1.61 10 1.61C12.33 1.61 14.45 2.48 16.05 3.95C15.37 3.84 14.4 4.34 14.4 5.53C14.4 6.27 14.85 6.89 15.3 7.63C15.65 8.24 15.85 8.99 15.85 10.09C15.85 11.58 14.45 15.09 14.45 15.09L11.42 6.72C11.96 6.7 12.24 6.55 12.24 6.55C12.74 6.5 12.68 5.3 12.18 5.33C12.18 5.33 10.74 5.45 9.8 5.45C8.93 5.45 7.47 5.33 7.47 5.33C6.97 5.3 6.91 6.53 7.41 6.55L8.33 6.63L9.59 10.04L7.78 15.87ZM17.41 10.5C17.65 9.86 18.15 8.63 17.84 6.25C18.54 7.54 18.89 8.96 18.89 10.5C18.89 13.79 17.16 16.74 14.49 18.28C15.46 15.69 16.43 13.08 17.41 10.5ZM6.1 18.59C3.12 17.15 1.11 14.03 1.11 10.5C1.11 9.2 1.34 8.02 1.83 6.91C3.25 10.8 4.67 14.7 6.1 18.59ZM10.13 11.96L12.71 18.94C11.85 19.23 10.95 19.39 10 19.39C9.21 19.39 8.43 19.28 7.71 19.06C8.52 16.68 9.33 14.32 10.13 11.96Z",fill:"#ffffff"})),$t=e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"15",height:"14",viewBox:"0 0 15 14",fill:"none"},e.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.59196 3.59524L6.77745 1.96623C6.70755 1.82641 6.56464 1.7381 6.40832 1.7381H1.65079C1.42287 1.7381 1.2381 1.92287 1.2381 2.15079V11.8492C1.2381 12.0771 1.42287 12.2619 1.65079 12.2619H13.2063C13.4343 12.2619 13.619 12.0771 13.619 11.8492V4.00794C13.619 3.78001 13.4343 3.59524 13.2063 3.59524H7.59196ZM8.35714 2.35714L7.88484 1.41254C7.60521 0.853274 7.0336 0.5 6.40832 0.5H1.65079C0.739085 0.5 0 1.23909 0 2.15079V11.8492C0 12.7609 0.739085 13.5 1.65079 13.5H13.2063C14.1181 13.5 14.8571 12.7609 14.8571 11.8492V4.00794C14.8571 3.09623 14.1181 2.35714 13.2063 2.35714H8.35714Z"})),Wt=e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",fill:"currentColor",className:"bi bi-file-earmark",viewBox:"0 0 16 16"},e.createElement("path",{d:"M14 4.5V14a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2h5.5zm-3 0A1.5 1.5 0 0 1 9.5 3V1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V4.5z"})),sr=n=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 14 14",fill:"none",...n},e.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 12.6875C3.85888 12.6875 1.3125 10.1411 1.3125 7C1.3125 3.85888 3.85888 1.3125 7 1.3125C10.1411 1.3125 12.6875 3.85888 12.6875 7C12.6875 10.1411 10.1411 12.6875 7 12.6875ZM0 7C0 3.13401 3.13401 0 7 0C10.866 0 14 3.13401 14 7C14 10.866 10.866 14 7 14C3.13401 14 0 10.866 0 7ZM7.875 7.875V3.5H6.5625V6.5625H4.8125V7.875H7.875Z",fill:"#949494"})),lr=e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 14 14",fill:"none"},e.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.25 1.3125H1.75C1.50838 1.3125 1.3125 1.50838 1.3125 1.75V4.37495H12.6875V1.75C12.6875 1.50837 12.4916 1.3125 12.25 1.3125ZM12.6875 5.68745H5.25003V12.6875H12.25C12.4916 12.6875 12.6875 12.4916 12.6875 12.25V5.68745ZM3.93753 5.68745H1.3125V12.25C1.3125 12.4916 1.50837 12.6875 1.75 12.6875H3.93753L3.93753 5.68745ZM1.75 0H12.25C13.2165 0 14 0.783502 14 1.75V12.25C14 13.2165 13.2165 14 12.25 14H1.75C0.783502 14 0 13.2165 0 12.25V1.75C0 0.783502 0.783502 0 1.75 0Z",fill:"#949494"}));function cr(n){return`data:${n.mime};base64,${n.data}`}function ur({size:n=24,sidebarActive:s=!1}){return e.createElement("svg",{width:n,height:n,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),s?e.createElement("rect",{x:"3",y:"3",width:"7",height:"18",rx:"2",ry:"2",fill:"currentColor"}):e.createElement("rect",{x:"3",y:"3",width:"8",height:"18",rx:"2",ry:"2",fill:"none",stroke:"currentColor",strokeWidth:"2"}))}const Bt=pt.forwardRef(({icon:n,size:s=24,...d},l)=>pt.cloneElement(n,{width:s,height:s,...d,ref:l}));var Pt={exports:{}},tt={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var It;function ur(){if(It)return Je;It=1;var n=t,c=Symbol.for("react.element"),l=Symbol.for("react.fragment"),m=Object.prototype.hasOwnProperty,p=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,E={key:!0,ref:!0,__self:!0,__source:!0};function P(j,S,y){var v,N={},T=null,I=null;y!==void 0&&(T=""+y),S.key!==void 0&&(T=""+S.key),S.ref!==void 0&&(I=S.ref);for(v in S)m.call(S,v)&&!E.hasOwnProperty(v)&&(N[v]=S[v]);if(j&&j.defaultProps)for(v in S=j.defaultProps,S)N[v]===void 0&&(N[v]=S[v]);return{$$typeof:c,type:j,key:T,ref:I,props:N,_owner:p.current}}return Je.Fragment=l,Je.jsx=P,Je.jsxs=P,Je}var Xe={};/**
9
+ */var jt;function fr(){if(jt)return tt;jt=1;var n=e,s=Symbol.for("react.element"),d=Symbol.for("react.fragment"),l=Object.prototype.hasOwnProperty,x=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,m={key:!0,ref:!0,__self:!0,__source:!0};function S(N,h,T){var _,k={},P=null,$=null;T!==void 0&&(P=""+T),h.key!==void 0&&(P=""+h.key),h.ref!==void 0&&($=h.ref);for(_ in h)l.call(h,_)&&!m.hasOwnProperty(_)&&(k[_]=h[_]);if(N&&N.defaultProps)for(_ in h=N.defaultProps,h)k[_]===void 0&&(k[_]=h[_]);return{$$typeof:s,type:N,key:P,ref:$,props:k,_owner:x.current}}return tt.Fragment=d,tt.jsx=S,tt.jsxs=S,tt}var rt={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,18 +14,18 @@
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var jt;function fr(){return jt||(jt=1,process.env.NODE_ENV!=="production"&&function(){var n=t,c=Symbol.for("react.element"),l=Symbol.for("react.portal"),m=Symbol.for("react.fragment"),p=Symbol.for("react.strict_mode"),E=Symbol.for("react.profiler"),P=Symbol.for("react.provider"),j=Symbol.for("react.context"),S=Symbol.for("react.forward_ref"),y=Symbol.for("react.suspense"),v=Symbol.for("react.suspense_list"),N=Symbol.for("react.memo"),T=Symbol.for("react.lazy"),I=Symbol.for("react.offscreen"),U=Symbol.iterator,A="@@iterator";function D(e){if(e===null||typeof e!="object")return null;var u=U&&e[U]||e[A];return typeof u=="function"?u:null}var h=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(e){{for(var u=arguments.length,f=new Array(u>1?u-1:0),x=1;x<u;x++)f[x-1]=arguments[x];Z("error",e,f)}}function Z(e,u,f){{var x=h.ReactDebugCurrentFrame,M=x.getStackAddendum();M!==""&&(u+="%s",f=f.concat([M]));var z=f.map(function(F){return String(F)});z.unshift("Warning: "+u),Function.prototype.apply.call(console[e],console,z)}}var V=!1,q=!1,J=!1,B=!1,L=!1,X;X=Symbol.for("react.module.reference");function _(e){return!!(typeof e=="string"||typeof e=="function"||e===m||e===E||L||e===p||e===y||e===v||B||e===I||V||q||J||typeof e=="object"&&e!==null&&(e.$$typeof===T||e.$$typeof===N||e.$$typeof===P||e.$$typeof===j||e.$$typeof===S||e.$$typeof===X||e.getModuleId!==void 0))}function $(e,u,f){var x=e.displayName;if(x)return x;var M=u.displayName||u.name||"";return M!==""?f+"("+M+")":f}function fe(e){return e.displayName||"Context"}function te(e){if(e==null)return null;if(typeof e.tag=="number"&&b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case m:return"Fragment";case l:return"Portal";case E:return"Profiler";case p:return"StrictMode";case y:return"Suspense";case v:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case j:var u=e;return fe(u)+".Consumer";case P:var f=e;return fe(f._context)+".Provider";case S:return $(e,e.render,"ForwardRef");case N:var x=e.displayName||null;return x!==null?x:te(e.type)||"Memo";case T:{var M=e,z=M._payload,F=M._init;try{return te(F(z))}catch{return null}}}return null}var Q=Object.assign,ce=0,re,be,xe,Se,Te,oe,k;function C(){}C.__reactDisabledLog=!0;function G(){{if(ce===0){re=console.log,be=console.info,xe=console.warn,Se=console.error,Te=console.group,oe=console.groupCollapsed,k=console.groupEnd;var e={configurable:!0,enumerable:!0,value:C,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}ce++}}function W(){{if(ce--,ce===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:Q({},e,{value:re}),info:Q({},e,{value:be}),warn:Q({},e,{value:xe}),error:Q({},e,{value:Se}),group:Q({},e,{value:Te}),groupCollapsed:Q({},e,{value:oe}),groupEnd:Q({},e,{value:k})})}ce<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ne=h.ReactCurrentDispatcher,Ee;function we(e,u,f){{if(Ee===void 0)try{throw Error()}catch(M){var x=M.stack.trim().match(/\n( *(at )?)/);Ee=x&&x[1]||""}return`
18
- `+Ee+e}}var ie=!1,H;{var w=typeof WeakMap=="function"?WeakMap:Map;H=new w}function ge(e,u){if(!e||ie)return"";{var f=H.get(e);if(f!==void 0)return f}var x;ie=!0;var M=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var z;z=ne.current,ne.current=null,G();try{if(u){var F=function(){throw Error()};if(Object.defineProperty(F.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(F,[])}catch(pe){x=pe}Reflect.construct(e,[],F)}else{try{F.call()}catch(pe){x=pe}e.call(F.prototype)}}else{try{throw Error()}catch(pe){x=pe}e()}}catch(pe){if(pe&&x&&typeof pe.stack=="string"){for(var O=pe.stack.split(`
19
- `),me=x.stack.split(`
20
- `),ee=O.length-1,ae=me.length-1;ee>=1&&ae>=0&&O[ee]!==me[ae];)ae--;for(;ee>=1&&ae>=0;ee--,ae--)if(O[ee]!==me[ae]){if(ee!==1||ae!==1)do if(ee--,ae--,ae<0||O[ee]!==me[ae]){var _e=`
21
- `+O[ee].replace(" at new "," at ");return e.displayName&&_e.includes("<anonymous>")&&(_e=_e.replace("<anonymous>",e.displayName)),typeof e=="function"&&H.set(e,_e),_e}while(ee>=1&&ae>=0);break}}}finally{ie=!1,ne.current=z,W(),Error.prepareStackTrace=M}var $e=e?e.displayName||e.name:"",Ie=$e?we($e):"";return typeof e=="function"&&H.set(e,Ie),Ie}function de(e,u,f){return ge(e,!1)}function ye(e){var u=e.prototype;return!!(u&&u.isReactComponent)}function Pe(e,u,f){if(e==null)return"";if(typeof e=="function")return ge(e,ye(e));if(typeof e=="string")return we(e);switch(e){case y:return we("Suspense");case v:return we("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case S:return de(e.render);case N:return Pe(e.type,u,f);case T:{var x=e,M=x._payload,z=x._init;try{return Pe(z(M),u,f)}catch{}}}return""}var Ne=Object.prototype.hasOwnProperty,Ae={},ze=h.ReactDebugCurrentFrame;function Me(e){if(e){var u=e._owner,f=Pe(e.type,e._source,u?u.type:null);ze.setExtraStackFrame(f)}else ze.setExtraStackFrame(null)}function Ue(e,u,f,x,M){{var z=Function.call.bind(Ne);for(var F in e)if(z(e,F)){var O=void 0;try{if(typeof e[F]!="function"){var me=Error((x||"React class")+": "+f+" type `"+F+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[F]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw me.name="Invariant Violation",me}O=e[F](u,F,x,f,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(ee){O=ee}O&&!(O instanceof Error)&&(Me(M),b("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",x||"React class",f,F,typeof O),Me(null)),O instanceof Error&&!(O.message in Ae)&&(Ae[O.message]=!0,Me(M),b("Failed %s type: %s",f,O.message),Me(null))}}}var pt=Array.isArray;function Le(e){return pt(e)}function ht(e){{var u=typeof Symbol=="function"&&Symbol.toStringTag,f=u&&e[Symbol.toStringTag]||e.constructor.name||"Object";return f}}function wt(e){try{return nt(e),!1}catch{return!0}}function nt(e){return""+e}function at(e){if(wt(e))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",ht(e)),nt(e)}var ot=h.ReactCurrentOwner,gt={key:!0,ref:!0,__self:!0,__source:!0},it,Fe;function Ve(e){if(Ne.call(e,"ref")){var u=Object.getOwnPropertyDescriptor(e,"ref").get;if(u&&u.isReactWarning)return!1}return e.ref!==void 0}function vt(e){if(Ne.call(e,"key")){var u=Object.getOwnPropertyDescriptor(e,"key").get;if(u&&u.isReactWarning)return!1}return e.key!==void 0}function Et(e,u){typeof e.ref=="string"&&ot.current}function yt(e,u){{var f=function(){it||(it=!0,b("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",u))};f.isReactWarning=!0,Object.defineProperty(e,"key",{get:f,configurable:!0})}}function _t(e,u){{var f=function(){Fe||(Fe=!0,b("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",u))};f.isReactWarning=!0,Object.defineProperty(e,"ref",{get:f,configurable:!0})}}var bt=function(e,u,f,x,M,z,F){var O={$$typeof:c,type:e,key:u,ref:f,props:F,_owner:z};return O._store={},Object.defineProperty(O._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(O,"_self",{configurable:!1,enumerable:!1,writable:!1,value:x}),Object.defineProperty(O,"_source",{configurable:!1,enumerable:!1,writable:!1,value:M}),Object.freeze&&(Object.freeze(O.props),Object.freeze(O)),O};function st(e,u,f,x,M){{var z,F={},O=null,me=null;f!==void 0&&(at(f),O=""+f),vt(u)&&(at(u.key),O=""+u.key),Ve(u)&&(me=u.ref,Et(u,M));for(z in u)Ne.call(u,z)&&!gt.hasOwnProperty(z)&&(F[z]=u[z]);if(e&&e.defaultProps){var ee=e.defaultProps;for(z in ee)F[z]===void 0&&(F[z]=ee[z])}if(O||me){var ae=typeof e=="function"?e.displayName||e.name||"Unknown":e;O&&yt(F,ae),me&&_t(F,ae)}return bt(e,O,me,M,x,ot.current,F)}}var Be=h.ReactCurrentOwner,qe=h.ReactDebugCurrentFrame;function De(e){if(e){var u=e._owner,f=Pe(e.type,e._source,u?u.type:null);qe.setExtraStackFrame(f)}else qe.setExtraStackFrame(null)}var Ye;Ye=!1;function Ze(e){return typeof e=="object"&&e!==null&&e.$$typeof===c}function lt(){{if(Be.current){var e=te(Be.current.type);if(e)return`
17
+ */var Ot;function dr(){return Ot||(Ot=1,process.env.NODE_ENV!=="production"&&function(){var n=e,s=Symbol.for("react.element"),d=Symbol.for("react.portal"),l=Symbol.for("react.fragment"),x=Symbol.for("react.strict_mode"),m=Symbol.for("react.profiler"),S=Symbol.for("react.provider"),N=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),T=Symbol.for("react.suspense"),_=Symbol.for("react.suspense_list"),k=Symbol.for("react.memo"),P=Symbol.for("react.lazy"),$=Symbol.for("react.offscreen"),F=Symbol.iterator,D="@@iterator";function le(t){if(t===null||typeof t!="object")return null;var c=F&&t[F]||t[D];return typeof c=="function"?c:null}var v=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function C(t){{for(var c=arguments.length,p=new Array(c>1?c-1:0),R=1;R<c;R++)p[R-1]=arguments[R];Y("error",t,p)}}function Y(t,c,p){{var R=v.ReactDebugCurrentFrame,W=R.getStackAddendum();W!==""&&(c+="%s",p=p.concat([W]));var q=p.map(function(O){return String(O)});q.unshift("Warning: "+c),Function.prototype.apply.call(console[t],console,q)}}var ee=!1,Z=!1,y=!1,j=!1,I=!1,V;V=Symbol.for("react.module.reference");function g(t){return!!(typeof t=="string"||typeof t=="function"||t===l||t===m||I||t===x||t===T||t===_||j||t===$||ee||Z||y||typeof t=="object"&&t!==null&&(t.$$typeof===P||t.$$typeof===k||t.$$typeof===S||t.$$typeof===N||t.$$typeof===h||t.$$typeof===V||t.getModuleId!==void 0))}function M(t,c,p){var R=t.displayName;if(R)return R;var W=c.displayName||c.name||"";return W!==""?p+"("+W+")":p}function de(t){return t.displayName||"Context"}function A(t){if(t==null)return null;if(typeof t.tag=="number"&&C("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case l:return"Fragment";case d:return"Portal";case m:return"Profiler";case x:return"StrictMode";case T:return"Suspense";case _:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case N:var c=t;return de(c)+".Consumer";case S:var p=t;return de(p._context)+".Provider";case h:return M(t,t.render,"ForwardRef");case k:var R=t.displayName||null;return R!==null?R:A(t.type)||"Memo";case P:{var W=t,q=W._payload,O=W._init;try{return A(O(q))}catch{return null}}}return null}var K=Object.assign,ue=0,J,ie,Te,xe,Ce,ce,Fe;function te(){}te.__reactDisabledLog=!0;function Pe(){{if(ue===0){J=console.log,ie=console.info,Te=console.warn,xe=console.error,Ce=console.group,ce=console.groupCollapsed,Fe=console.groupEnd;var t={configurable:!0,enumerable:!0,value:te,writable:!0};Object.defineProperties(console,{info:t,log:t,warn:t,error:t,group:t,groupCollapsed:t,groupEnd:t})}ue++}}function Re(){{if(ue--,ue===0){var t={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:K({},t,{value:J}),info:K({},t,{value:ie}),warn:K({},t,{value:Te}),error:K({},t,{value:xe}),group:K({},t,{value:Ce}),groupCollapsed:K({},t,{value:ce}),groupEnd:K({},t,{value:Fe})})}ue<0&&C("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Ee=v.ReactCurrentDispatcher,De;function ye(t,c,p){{if(De===void 0)try{throw Error()}catch(W){var R=W.stack.trim().match(/\n( *(at )?)/);De=R&&R[1]||""}return`
18
+ `+De+t}}var ae=!1,z;{var u=typeof WeakMap=="function"?WeakMap:Map;z=new u}function b(t,c){if(!t||ae)return"";{var p=z.get(t);if(p!==void 0)return p}var R;ae=!0;var W=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var q;q=Ee.current,Ee.current=null,Pe();try{if(c){var O=function(){throw Error()};if(Object.defineProperty(O.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(O,[])}catch(ve){R=ve}Reflect.construct(t,[],O)}else{try{O.call()}catch(ve){R=ve}t.call(O.prototype)}}else{try{throw Error()}catch(ve){R=ve}t()}}catch(ve){if(ve&&R&&typeof ve.stack=="string"){for(var L=ve.stack.split(`
19
+ `),me=R.stack.split(`
20
+ `),oe=L.length-1,se=me.length-1;oe>=1&&se>=0&&L[oe]!==me[se];)se--;for(;oe>=1&&se>=0;oe--,se--)if(L[oe]!==me[se]){if(oe!==1||se!==1)do if(oe--,se--,se<0||L[oe]!==me[se]){var Se=`
21
+ `+L[oe].replace(" at new "," at ");return t.displayName&&Se.includes("<anonymous>")&&(Se=Se.replace("<anonymous>",t.displayName)),typeof t=="function"&&z.set(t,Se),Se}while(oe>=1&&se>=0);break}}}finally{ae=!1,Ee.current=q,Re(),Error.prepareStackTrace=W}var qe=t?t.displayName||t.name:"",Ve=qe?ye(qe):"";return typeof t=="function"&&z.set(t,Ve),Ve}function H(t,c,p){return b(t,!1)}function U(t){var c=t.prototype;return!!(c&&c.isReactComponent)}function Q(t,c,p){if(t==null)return"";if(typeof t=="function")return b(t,U(t));if(typeof t=="string")return ye(t);switch(t){case T:return ye("Suspense");case _:return ye("SuspenseList")}if(typeof t=="object")switch(t.$$typeof){case h:return H(t.render);case k:return Q(t.type,c,p);case P:{var R=t,W=R._payload,q=R._init;try{return Q(q(W),c,p)}catch{}}}return""}var fe=Object.prototype.hasOwnProperty,Ae={},_e=v.ReactDebugCurrentFrame;function pe(t){if(t){var c=t._owner,p=Q(t.type,t._source,c?c.type:null);_e.setExtraStackFrame(p)}else _e.setExtraStackFrame(null)}function Be(t,c,p,R,W){{var q=Function.call.bind(fe);for(var O in t)if(q(t,O)){var L=void 0;try{if(typeof t[O]!="function"){var me=Error((R||"React class")+": "+p+" type `"+O+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof t[O]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw me.name="Invariant Violation",me}L=t[O](c,O,R,p,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(oe){L=oe}L&&!(L instanceof Error)&&(pe(W),C("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",R||"React class",p,O,typeof L),pe(null)),L instanceof Error&&!(L.message in Ae)&&(Ae[L.message]=!0,pe(W),C("Failed %s type: %s",p,L.message),pe(null))}}}var Xe=Array.isArray;function je(t){return Xe(t)}function ht(t){{var c=typeof Symbol=="function"&&Symbol.toStringTag,p=c&&t[Symbol.toStringTag]||t.constructor.name||"Object";return p}}function vt(t){try{return at(t),!1}catch{return!0}}function at(t){return""+t}function ot(t){if(vt(t))return C("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",ht(t)),at(t)}var it=v.ReactCurrentOwner,wt={key:!0,ref:!0,__self:!0,__source:!0},st,Oe;function We(t){if(fe.call(t,"ref")){var c=Object.getOwnPropertyDescriptor(t,"ref").get;if(c&&c.isReactWarning)return!1}return t.ref!==void 0}function gt(t){if(fe.call(t,"key")){var c=Object.getOwnPropertyDescriptor(t,"key").get;if(c&&c.isReactWarning)return!1}return t.key!==void 0}function Et(t,c){typeof t.ref=="string"&&it.current}function yt(t,c){{var p=function(){st||(st=!0,C("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",c))};p.isReactWarning=!0,Object.defineProperty(t,"key",{get:p,configurable:!0})}}function _t(t,c){{var p=function(){Oe||(Oe=!0,C("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",c))};p.isReactWarning=!0,Object.defineProperty(t,"ref",{get:p,configurable:!0})}}var bt=function(t,c,p,R,W,q,O){var L={$$typeof:s,type:t,key:c,ref:p,props:O,_owner:q};return L._store={},Object.defineProperty(L._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(L,"_self",{configurable:!1,enumerable:!1,writable:!1,value:R}),Object.defineProperty(L,"_source",{configurable:!1,enumerable:!1,writable:!1,value:W}),Object.freeze&&(Object.freeze(L.props),Object.freeze(L)),L};function lt(t,c,p,R,W){{var q,O={},L=null,me=null;p!==void 0&&(ot(p),L=""+p),gt(c)&&(ot(c.key),L=""+c.key),We(c)&&(me=c.ref,Et(c,W));for(q in c)fe.call(c,q)&&!wt.hasOwnProperty(q)&&(O[q]=c[q]);if(t&&t.defaultProps){var oe=t.defaultProps;for(q in oe)O[q]===void 0&&(O[q]=oe[q])}if(L||me){var se=typeof t=="function"?t.displayName||t.name||"Unknown":t;L&&yt(O,se),me&&_t(O,se)}return bt(t,L,me,W,R,it.current,O)}}var He=v.ReactCurrentOwner,Qe=v.ReactDebugCurrentFrame;function Le(t){if(t){var c=t._owner,p=Q(t.type,t._source,c?c.type:null);Qe.setExtraStackFrame(p)}else Qe.setExtraStackFrame(null)}var Ue;Ue=!1;function ze(t){return typeof t=="object"&&t!==null&&t.$$typeof===s}function ct(){{if(He.current){var t=A(He.current.type);if(t)return`
22
22
 
23
- Check the render method of \``+e+"`."}return""}}function Ct(e){return""}var ct={};function r(e){{var u=lt();if(!u){var f=typeof e=="string"?e:e.displayName||e.name;f&&(u=`
23
+ Check the render method of \``+t+"`."}return""}}function xt(t){return""}var ut={};function Ct(t){{var c=ct();if(!c){var p=typeof t=="string"?t:t.displayName||t.name;p&&(c=`
24
24
 
25
- Check the top-level render call using <`+f+">.")}return u}}function a(e,u){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var f=r(u);if(ct[f])return;ct[f]=!0;var x="";e&&e._owner&&e._owner!==Be.current&&(x=" It was passed a child from "+te(e._owner.type)+"."),De(e),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',f,x),De(null)}}function o(e,u){{if(typeof e!="object")return;if(Le(e))for(var f=0;f<e.length;f++){var x=e[f];Ze(x)&&a(x,u)}else if(Ze(e))e._store&&(e._store.validated=!0);else if(e){var M=D(e);if(typeof M=="function"&&M!==e.entries)for(var z=M.call(e),F;!(F=z.next()).done;)Ze(F.value)&&a(F.value,u)}}}function s(e){{var u=e.type;if(u==null||typeof u=="string")return;var f;if(typeof u=="function")f=u.propTypes;else if(typeof u=="object"&&(u.$$typeof===S||u.$$typeof===N))f=u.propTypes;else return;if(f){var x=te(u);Ue(f,e.props,"prop",x,e)}else if(u.PropTypes!==void 0&&!Ye){Ye=!0;var M=te(u);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",M||"Unknown")}typeof u.getDefaultProps=="function"&&!u.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function i(e){{for(var u=Object.keys(e.props),f=0;f<u.length;f++){var x=u[f];if(x!=="children"&&x!=="key"){De(e),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",x),De(null);break}}e.ref!==null&&(De(e),b("Invalid attribute `ref` supplied to `React.Fragment`."),De(null))}}var g={};function d(e,u,f,x,M,z){{var F=_(e);if(!F){var O="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(O+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var me=Ct();me?O+=me:O+=lt();var ee;e===null?ee="null":Le(e)?ee="array":e!==void 0&&e.$$typeof===c?(ee="<"+(te(e.type)||"Unknown")+" />",O=" Did you accidentally export a JSX literal instead of a component?"):ee=typeof e,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",ee,O)}var ae=st(e,u,f,M,z);if(ae==null)return ae;if(F){var _e=u.children;if(_e!==void 0)if(x)if(Le(_e)){for(var $e=0;$e<_e.length;$e++)o(_e[$e],e);Object.freeze&&Object.freeze(_e)}else b("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else o(_e,e)}if(Ne.call(u,"key")){var Ie=te(e),pe=Object.keys(u).filter(function(Gt){return Gt!=="key"}),Rt=pe.length>0?"{key: someKey, "+pe.join(": ..., ")+": ...}":"{key: someKey}";if(!g[Ie+Rt]){var Zt=pe.length>0?"{"+pe.join(": ..., ")+": ...}":"{}";b(`A props object containing a "key" prop is being spread into JSX:
25
+ Check the top-level render call using <`+p+">.")}return c}}function ft(t,c){{if(!t._store||t._store.validated||t.key!=null)return;t._store.validated=!0;var p=Ct(c);if(ut[p])return;ut[p]=!0;var R="";t&&t._owner&&t._owner!==He.current&&(R=" It was passed a child from "+A(t._owner.type)+"."),Le(t),C('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',p,R),Le(null)}}function r(t,c){{if(typeof t!="object")return;if(je(t))for(var p=0;p<t.length;p++){var R=t[p];ze(R)&&ft(R,c)}else if(ze(t))t._store&&(t._store.validated=!0);else if(t){var W=le(t);if(typeof W=="function"&&W!==t.entries)for(var q=W.call(t),O;!(O=q.next()).done;)ze(O.value)&&ft(O.value,c)}}}function a(t){{var c=t.type;if(c==null||typeof c=="string")return;var p;if(typeof c=="function")p=c.propTypes;else if(typeof c=="object"&&(c.$$typeof===h||c.$$typeof===k))p=c.propTypes;else return;if(p){var R=A(c);Be(p,t.props,"prop",R,t)}else if(c.PropTypes!==void 0&&!Ue){Ue=!0;var W=A(c);C("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",W||"Unknown")}typeof c.getDefaultProps=="function"&&!c.getDefaultProps.isReactClassApproved&&C("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function o(t){{for(var c=Object.keys(t.props),p=0;p<c.length;p++){var R=c[p];if(R!=="children"&&R!=="key"){Le(t),C("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",R),Le(null);break}}t.ref!==null&&(Le(t),C("Invalid attribute `ref` supplied to `React.Fragment`."),Le(null))}}var i={};function f(t,c,p,R,W,q){{var O=g(t);if(!O){var L="";(t===void 0||typeof t=="object"&&t!==null&&Object.keys(t).length===0)&&(L+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var me=xt();me?L+=me:L+=ct();var oe;t===null?oe="null":je(t)?oe="array":t!==void 0&&t.$$typeof===s?(oe="<"+(A(t.type)||"Unknown")+" />",L=" Did you accidentally export a JSX literal instead of a component?"):oe=typeof t,C("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",oe,L)}var se=lt(t,c,p,W,q);if(se==null)return se;if(O){var Se=c.children;if(Se!==void 0)if(R)if(je(Se)){for(var qe=0;qe<Se.length;qe++)r(Se[qe],t);Object.freeze&&Object.freeze(Se)}else C("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else r(Se,t)}if(fe.call(c,"key")){var Ve=A(t),ve=Object.keys(c).filter(function(Kt){return Kt!=="key"}),Rt=ve.length>0?"{key: someKey, "+ve.join(": ..., ")+": ...}":"{key: someKey}";if(!i[Ve+Rt]){var Zt=ve.length>0?"{"+ve.join(": ..., ")+": ...}":"{}";C(`A props object containing a "key" prop is being spread into JSX:
26
26
  let props = %s;
27
27
  <%s {...props} />
28
28
  React keys must be passed directly to JSX without using spread:
29
29
  let props = %s;
30
- <%s key={someKey} {...props} />`,Rt,Ie,Zt,Ie),g[Ie+Rt]=!0}}return e===m?i(ae):s(ae),ae}}function R(e,u,f){return d(e,u,f,!0)}function K(e,u,f){return d(e,u,f,!1)}var ke=K,Ge=R;Xe.Fragment=m,Xe.jsx=ke,Xe.jsxs=Ge}()),Xe}process.env.NODE_ENV==="production"?Pt.exports=ur():Pt.exports=fr();var Re=Pt.exports,tt=n=>mt.createElement("path",n),rt=mt.forwardRef(({className:n,isPressed:c,...l},m)=>{const p={...l,className:rr(n,{"is-pressed":c})||void 0,"aria-hidden":!0,focusable:!1};return Re.jsx("svg",{...p,ref:m})});rt.displayName="SVG";const dr=Re.jsx(rt,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:Re.jsx(tt,{d:"M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z"})}),mr=Re.jsx(rt,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:Re.jsx(tt,{d:"M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z"})}),pr=Re.jsx(rt,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:Re.jsx(tt,{fillRule:"evenodd",clipRule:"evenodd",d:"M12.848 8a1 1 0 0 1-.914-.594l-.723-1.63a.5.5 0 0 0-.447-.276H5a.5.5 0 0 0-.5.5v11.5a.5.5 0 0 0 .5.5h14a.5.5 0 0 0 .5-.5v-9A.5.5 0 0 0 19 8h-6.152Zm.612-1.5a.5.5 0 0 1-.462-.31l-.445-1.084A2 2 0 0 0 10.763 4H5a2 2 0 0 0-2 2v11.5a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-9a2 2 0 0 0-2-2h-5.54Z"})}),hr=Re.jsxs(rt,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:[Re.jsx(tt,{d:"M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z"}),Re.jsx(tt,{d:"M17 4H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2ZM7 5.5h10a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H7a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5Z"})]}),wr="_file-picker-tree_3rwm2_1",gr="_file-node-button_3rwm2_17",vr="_selected_3rwm2_53",Er="_focused_3rwm2_65",yr="_dropTarget_3rwm2_70",_r="_dropTargetInvalid_3rwm2_79",br="_renaming_3rwm2_88",Cr="_renameInput_3rwm2_93",Rr="_file-name_3rwm2_108",he={filePickerTree:wr,fileNodeButton:gr,selected:vr,focused:Er,dropTarget:yr,dropTargetInvalid:_r,renaming:br,renameInput:Cr,fileName:Rr};function xt(n){if(!n)return[];const c=n.replaceAll(/\\+/g,"/").replace(/\/{2,}/g,"/").replace(/\/$/,"")||n,l=c.startsWith("/"),m=c.split("/").filter(Boolean),p=[];let E=l?"/":"";l&&p.push("/");for(const P of m)!E||E==="/"?E=E==="/"?`/${P}`:P:E=`${E}/${P}`,p.push(E);return p}function xr(n,c){if(!n||!c||n===c)return!1;const l=n==="/"?"/":n.replace(/\/{2,}/g,"/"),m=c.replace(/\/{2,}/g,"/");return l==="/"?m.startsWith("/")&&m!=="/":m.startsWith(`${l}/`)}function St(n,c,l){return n&&(n===c?l:n.startsWith(c==="/"?"/":`${c}/`)?l+n.slice(c.length):n)}const $t=t.forwardRef(function({withContextMenu:c=!0,filesystem:l,root:m="/wordpress",initialSelectedPath:p,onSelect:E=()=>{},onDoubleClickFile:P},j){const S=t.useMemo(()=>{let r=(m||"/").replace(/\\+/g,"/");return r.startsWith("/")||(r=`/${r}`),r=r.replace(/\/{2,}/g,"/"),r.length>1&&r.endsWith("/")&&(r=r.slice(0,-1)),r||"/"},[m]),y=r=>!r||r==="."||r===".."?!1:!/[\\/]/.test(r),[v,N]=t.useState(()=>{if(!p)return{};const r={};for(const a of xt(p))r[a]=!0;return r}),[T,I]=t.useState(()=>p??null),[U,A]=t.useState(()=>p??null),[D,h]=t.useState({}),[b,Z]=t.useState({}),[V,q]=t.useState(null),[J,B]=t.useState(null),L=t.useRef({}),X=t.useRef(!1),_=t.useRef(null),$=t.useRef(null),fe=t.useRef(b),te=t.useRef(D),Q=()=>{for(const r of Object.keys(L.current))clearTimeout(L.current[r]),delete L.current[r]},ce=r=>{const a=L.current[r];a&&(clearTimeout(a),delete L.current[r])};t.useEffect(()=>{fe.current=b},[b]),t.useEffect(()=>{te.current=D},[D]);const re=r=>{var o;const a=(o=_.current)==null?void 0:o.querySelector(`[data-path="${r}"]`);a&&typeof a.focus=="function"&&(a.focus(),a.scrollIntoView({behavior:"smooth",block:"nearest"}))},be=(r,a="")=>(a?`${a}/${r.name}`:r.name).replaceAll(/\\+/g,"/").replace(/\/{2,}/g,"/"),xe=(r,a)=>r.children?r.children:D[a],Se=async(r,a)=>{const o=await r.listFiles(a),s=[];for(const i of o){const g=a==="/"?`/${i}`:`${a}/${i}`,d=await r.isDir(g);s.push({name:i,type:d?"folder":"file"})}return s.sort((i,g)=>{var ke;if(i.type!==g.type)return i.type==="folder"?-1:1;const d=a==="/"?`/${i.name}`:`${a}/${i.name}`,R=a==="/"?`/${g.name}`:`${a}/${g.name}`,K=(ke=ye.current)==null?void 0:ke.tempPath;if(K){if(d===K)return-1;if(R===K)return 1}return i.name.localeCompare(g.name)}),s},Te=async r=>await Se(l,r),oe=(r,a)=>{if(a.type!=="folder")return a.children;const o=a.children??te.current[r];return o||fe.current[r]?o:(Z(s=>({...s,[r]:!0})),new Promise(s=>{Te(r).then(i=>{h(g=>({...g,[r]:i??[]})),s(i??[])}).catch(()=>{s([])}).finally(()=>{Z(i=>{const g={...i};return delete g[r],g})})}))},k=(r,a)=>{a.type==="folder"&&(typeof window>"u"||L.current[r]||(L.current[r]=window.setTimeout(()=>{N(o=>o[r]?o:{...o,[r]:!0}),oe(r,a),delete L.current[r]},600)))},C=r=>(Z(a=>({...a,[r]:!0})),new Promise(a=>{Te(r).then(o=>{h(s=>({...s,[r]:o??[]})),a(o??[])}).catch(()=>{a([])}).finally(()=>{Z(o=>{const s={...o};return delete s[r],s})})})),G=(r,a,o)=>{N(s=>({...s,[r]:o})),o?oe(r,a):h(s=>{if(s[r]===void 0)return s;const i={...s};return delete i[r],i})},W=async r=>{if(!r)return;const a=xt(r);if(a.length===0)return;N(i=>{const g={...i};for(const d of a)g[d]=!0;return g});let o=[{name:S,type:"folder"}],s="";for(const i of a){const g=o==null?void 0:o.find(R=>be(R,s)===i);if(!g||g.type!=="folder"){s=i,o=[];continue}o=await oe(i,g)??te.current[i],s=i}},ne=(r,a)=>{if(!r||!a||r===a)return;const o=r==="/"?"/":`${r}/`,s=i=>i===r?a:i.startsWith(o)?a+i.slice(r.length):null;N(i=>{let g=!1;const d={...i};for(const R of Object.keys(i)){const K=s(R);K&&K!==R&&(d[K]=i[R],delete d[R],g=!0)}return g?d:i}),h(i=>{let g=!1;const d={...i};for(const R of Object.keys(i)){const K=s(R);K&&K!==R&&(d[K]=i[R],delete d[R],g=!0)}return g?d:i}),I(i=>i&&(s(i)??i)),A(i=>i&&(s(i)??i))},Ee=()=>{q(null),B(null),Q()},we=(r,a=!0)=>{I(r),a&&E(r)},ie=t.useMemo(()=>[{name:S,type:"folder"}],[S]),[H,w]=t.useState(null),[ge,de]=t.useState(null),ye=t.useRef(null),Pe=ge;t.useImperativeHandle(j,()=>({focusPath:(r,a={})=>{if(!r)return;const{select:o=!0,domFocus:s=!0,notify:i=!1}=a;o&&we(r,i),A(r),s&&re(r)},selectPath:r=>{r&&(we(r),A(r),re(r))},getSelectedPath:()=>T,expandToPath:async r=>await W(r),refresh:async r=>await C(r),remapPath:ne,createFile:async r=>{await Ve(r,"file","untitled.php")},createFolder:async r=>{await Ve(r,"folder","New Folder")}}),[T,C,ne,W]);const Ne=t.useRef(!1),Ae=t.useRef(p??null),ze=t.useRef(p);t.useEffect(()=>{X.current=!1},[S]),t.useEffect(()=>{p&&p!==ze.current?Ae.current=p:p||(Ae.current=null),ze.current=p},[p]),t.useEffect(()=>{if(!p||Ne.current)return;Ne.current=!0;const r=xt(p);N(o=>{const s={...o};for(const i of r)s[i]=!0;return s});const a=r[r.length-1]||p;A(a),I(a),W(p)},[p,W]),t.useEffect(()=>{const r=Ae.current;!r||ie.length===0||(Ae.current=null,W(r))},[ie,W]),t.useEffect(()=>{if(!U){if(ie.length>0){const r=be(ie[0]);A(r)}return}Pe&&Pe===U||re(U)},[ie,U,Pe]),t.useEffect(()=>{if(ie.length===0)return;const r=ie[0];if((r==null?void 0:r.type)!=="folder"||X.current)return;const a=r.name;X.current=!0,N(o=>o[a]?o:{...o,[a]:!0}),!te.current[a]&&!fe.current[a]&&oe(a,r)},[ie,oe,S]),t.useEffect(()=>()=>{$.current&&clearTimeout($.current),Q()},[]),t.useEffect(()=>{H&&setTimeout(()=>{const r=document.querySelector('[role="menu"] [role="menuitem"]');r&&typeof r.focus=="function"&&r.focus()},0)},[H]);const[Me,Ue]=t.useState(""),pt=(r,a)=>{if(r.type==="folder")return a;const o=se.dirname(a);return o&&o||"/"},Le=(r,a,o)=>{const s=pt(r,a);if(!s)return{allowed:!1,state:"invalid",destination:null};if(o){if(s===o)return{allowed:!1,state:"invalid",destination:null};if(xr(o,s))return{allowed:!1,state:"invalid",destination:null}}return{allowed:!0,state:"valid",destination:s}},ht=(r,a,o)=>{a.type!=="folder"&&a.type!=="file"||(q(o),B(null),r.dataTransfer&&(r.dataTransfer.effectAllowed="move",r.dataTransfer.setData("application/x-wp-playground-path",o),r.dataTransfer.setData("text/plain",o)))},wt=()=>{Ee()},nt=(r,a,o)=>{const s=Le(a,o,V);s.allowed&&a.type==="folder"&&k(o,a),B(i=>(i==null?void 0:i.path)===o&&i.state===s.state?i:{path:o,state:s.state})},at=(r,a,o)=>{const s=Le(a,o,V);s.allowed&&s.destination?(r.preventDefault(),r.dataTransfer&&(r.dataTransfer.dropEffect=V?"move":"copy"),a.type==="folder"&&k(o,a),B(i=>(i==null?void 0:i.path)===o&&i.state===s.state?i:{path:o,state:s.state})):(r.dataTransfer&&(r.dataTransfer.dropEffect="none"),ce(o),B(i=>(i==null?void 0:i.path)===o&&i.state==="invalid"?i:{path:o,state:"invalid"}))},ot=(r,a,o)=>{ce(o);const s=r.relatedTarget;s&&r.currentTarget.contains(s)||B(i=>(i==null?void 0:i.path)===o?null:i)},gt=async(r,a,o)=>{const s=V,i=Le(a,o,s);if(!i.allowed||!i.destination){Ee();return}r.preventDefault(),r.stopPropagation(),ce(o),B(null);try{s?await yt(s,i.destination):await De(r,i.destination)}finally{Ee()}},it=(r,a,o)=>{c&&(r.preventDefault(),r.stopPropagation(),de(null),w({absPath:o,type:a.type,x:r.clientX,y:r.clientY}))},Fe=async(r,a)=>{let o=a,s=0;const i=d=>{const R=d.lastIndexOf(".");return R>0?{stem:d.slice(0,R),ext:d.slice(R)}:{stem:d,ext:""}},g=r==="/"?"":r;for(;await(l==null?void 0:l.fileExists(`${g}/${o}`))||await(l==null?void 0:l.isDir(`${g}/${o}`));){s+=1;const{stem:d,ext:R}=i(a);o=`${d} (${s})${R}`}return o},Ve=async(r,a,o)=>{if(!l)return;let s=r||T||S;try{await l.isDir(s)||(s=se.dirname(s))}catch{s=se.dirname(s)}const i=s,g=await Fe(i,o),d=se.joinPaths(i,g);a==="folder"?await l.mkdir(d):await l.writeFile(d,""),ye.current={type:a,tempPath:d},de(d),await C(i),setTimeout(()=>{A(d),re(d)},0)},vt=async r=>{if(!l)return!1;try{if(await l.fileExists(r))return!0}catch{}try{if(await l.isDir(r))return!0}catch{}return!1},Et=async r=>{if(l)try{await l.mkdir(r)}catch(a){if(!await l.isDir(r).catch(()=>!1))throw a}},yt=async(r,a)=>{if(!l)return;const o=se.basename(r),s=se.joinPaths(a,o);if(s===r||await vt(s))return;const i=se.dirname(r);try{await l.mv(r,s),ne(r,s);const g=St(T,r,s);T&&(T===r||T.startsWith(`${r}/`))&&E(g),A(d=>St(d,r,s)),N(d=>({...d,[a]:!0})),await Promise.all([C(i),C(a)]),I(d=>St(d,r,s)),re(s)}catch{}},_t=r=>{const a=r;return a.webkitGetAsEntry?a.webkitGetAsEntry():null},bt=r=>new Promise((a,o)=>{r.file(a,o)}),st=async(r,a)=>{if(!l)return;const o=r.name||"untitled",s=await Fe(a,o),i=se.joinPaths(a,s),g=new Uint8Array(await r.arrayBuffer());await l.writeFile(i,g)},Be=async(r,a)=>{const o=await bt(r);await st(o,a)},qe=async(r,a)=>{const o=await Fe(a,r.name||"New Folder"),s=se.joinPaths(a,o);await Et(s);const i=r.createReader(),g=()=>new Promise((d,R)=>{i.readEntries(K=>d(Array.from(K)),R)});for(;;){const d=await g();if(!d.length)break;for(const R of d)R.isFile?await Be(R,s):R.isDirectory&&await qe(R,s)}},De=async(r,a)=>{var i,g;if(!l)return;const s=((i=r.dataTransfer)!=null&&i.items?Array.from(r.dataTransfer.items):[]).filter(d=>d.kind==="file").map(d=>_t(d)).filter(d=>!!d);if(s.length>0)for(const d of s)d.isFile?await Be(d,a):d.isDirectory&&await qe(d,a);else{const d=(g=r.dataTransfer)!=null&&g.files?Array.from(r.dataTransfer.files):[];for(const R of d)await st(R,a)}await C(a),N(d=>({...d,[a]:!0}))},Ye=async(r,a)=>{if(!l)return;const o=r;w(null);try{a==="folder"?await l.rmdir(o,{recursive:!0}):await l.unlink(o)}catch{}finally{de(null);const s=se.dirname(o);await C(s),T&&(T===o||T.startsWith(`${o}/`))&&E(null)}},Ze=async r=>{if(l)try{const o=await(await l.read(r)).arrayBuffer(),s=new Blob([o]),i=URL.createObjectURL(s),g=document.createElement("a");g.href=i,g.download=se.basename(r)||"download",document.body.appendChild(g),g.click(),document.body.removeChild(g),setTimeout(()=>URL.revokeObjectURL(i),6e4)}catch(a){console.error("Failed to download file",a)}},lt=r=>{var a;if(!ge)if(r.key.length===1&&r.key.match(/\S/)){const o=Me+r.key.toLowerCase();if(Ue(o),$.current&&clearTimeout($.current),$.current=setTimeout(()=>{Ue("")},1e3),!_.current)return;const s=Array.from(_.current.querySelectorAll(".file-node-button")),i=document.activeElement;let g=0;i&&s.includes(i)&&(g=s.indexOf(i));for(let d=0;d<s.length;d++){const R=(g+d)%s.length,K=s[R];if((a=K.textContent)!=null&&a.toLowerCase().trim().startsWith(o)){K.focus();const ke=K.getAttribute("data-path");ke&&A(ke);break}}}else Ue(""),$.current&&clearTimeout($.current)},Ct=async(r,a)=>{const o=ye.current,s=(o==null?void 0:o.tempPath)===r,i=se.dirname(r),g=(a||"").trim();if(!y(g)){if(s){try{o.type==="folder"?await l.rmdir(r,{recursive:!0}):await l.unlink(r)}catch{}ye.current=null}de(s?null:r);return}let d=se.joinPaths(i,g),R=d;if(R===r){de(null);const e=s&&(o==null?void 0:o.type)==="file";s&&(ye.current=null),setTimeout(()=>{A(R),re(R),e&&P&&P(R)},0);return}const K=await l.fileExists(R),ke=await l.isDir(R);if((K||ke)&&R!==r)if(s)try{const e=await Fe(i==="/"?"/":i,g);d=se.joinPaths(i,e),R=d}catch{}else{de(r);return}let Ge=(o==null?void 0:o.type)==="folder";try{await l.mv(r,d),o||(Ge=await l.isDir(d)),Ge&&ne(r,R),T===r&&E(R),await C(i),A(R),re(R),s&&!Ge&&P&&P(R)}catch{if(s)try{(o==null?void 0:o.type)==="folder"?await l.rmdir(r,{recursive:!0}):await l.unlink(r)}catch{}}finally{ye.current=null,de(null)}},ct=async r=>{const a=ye.current;if(!l||(a==null?void 0:a.tempPath)!==r){de(s=>s===r?null:s);return}try{a.type==="folder"?await l.rmdir(r,{recursive:!0}):await l.unlink(r)}catch{}ye.current=null,de(null);const o=se.dirname(r);await C(o),A(o),re(o)};return t.createElement("div",{onKeyDown:lt,ref:_},t.createElement(le.__experimentalTreeGrid,{className:he.filePickerTree},ie.map((r,a)=>t.createElement(Wt,{key:r.name,node:r,level:0,position:a+1,setSize:ie.length,expandedNodePaths:v,onToggle:G,selectedNode:T,focusPath:o=>A(o),focusedNode:U,selectPath:we,generatePath:be,getChildren:xe,onContextMenu:it,renamingPath:Pe,onRename:Ct,onRenameCancel:ct,dropIndicator:J,onDragStart:ht,onDragEnd:wt,onDragEnter:nt,onDragOver:at,onDragLeave:ot,onDrop:gt,rootPath:S,onDoubleClickFile:P}))),H&&t.createElement(le.Popover,{placement:"bottom-start",onClose:()=>w(null),anchor:{getBoundingClientRect:()=>({x:H.x,y:H.y,width:0,height:0,top:H.y,left:H.x,right:H.x,bottom:H.y,toJSON:()=>({})}),ownerDocument:document},noArrow:!0,resize:!1,focusOnMount:"firstElement"},t.createElement(le.NavigableMenu,{role:"menu"},H.type==="folder"&&t.createElement(le.MenuItem,{role:"menuitem",onClick:async()=>{w(null),await Ve(H.absPath,"file","untitled.php")}},"Create file"),H.type==="folder"&&t.createElement(le.MenuItem,{role:"menuitem",onClick:async()=>{w(null),await Ve(H.absPath,"folder","New Folder")}},"Create directory"),t.createElement(le.MenuItem,{role:"menuitem",onClick:()=>{w(null),de(H.absPath)}},"Rename"),H.type==="file"&&t.createElement(le.MenuItem,{role:"menuitem",onClick:async()=>{w(null),await Ze(H.absPath)}},"Download"),t.createElement(le.MenuItem,{role:"menuitem",onClick:()=>Ye(H.absPath,H.type)},"Delete"))))}),Wt=({node:n,level:c,position:l,setSize:m,expandedNodePaths:p,onToggle:E,selectedNode:P,focusPath:j,focusedNode:S,selectPath:y,generatePath:v,getChildren:N,onContextMenu:T,renamingPath:I,onRename:U,onRenameCancel:A,parentPath:D="",dropIndicator:h,onDragStart:b,onDragEnd:Z,onDragEnter:V,onDragOver:q,onDragLeave:J,onDrop:B,rootPath:L,onDoubleClickFile:X})=>{const _=v(n,D),$=p[_],fe=I===_,te=t.useRef(null),[Q,ce]=t.useState(n.name),re=t.useRef(!1),be=(h==null?void 0:h.path)===_,xe=be&&(h==null?void 0:h.state)==="valid",Se=be&&(h==null?void 0:h.state)==="invalid",Te=!fe&&_!==L,oe=t.useRef(null),k={onDragEnter:w=>V==null?void 0:V(w,n,_),onDragOver:w=>q==null?void 0:q(w,n,_),onDragLeave:w=>J==null?void 0:J(w,n,_),onDrop:w=>B==null?void 0:B(w,n,_)},C=N(n,_)??[];t.useEffect(()=>{var w;fe?(ce(n.name),re.current=!1,typeof window<"u"&&requestAnimationFrame?requestAnimationFrame(()=>{var ge;(ge=te.current)==null||ge.select()}):(w=te.current)==null||w.select()):re.current=!1},[fe,n.name]);const G=()=>{n.type==="folder"&&E(_,n,!$)},W=w=>{var ge,de;if(w.key==="ArrowLeft")$?G():(ge=document.querySelector(`[data-path="${D}"]`))==null||ge.focus(),w.preventDefault(),w.stopPropagation();else if(w.key==="ArrowRight"){if($){if(C!=null&&C.length){const ye=v(C[0],_);(de=document.querySelector(`[data-path="${ye}"]`))==null||de.focus()}}else G();w.preventDefault(),w.stopPropagation()}else w.key===" "||w.key==="Space"||w.key==="Spacebar"?(n.type==="folder"&&E(_,n,!$),w.preventDefault()):w.key==="Enter"&&(n.type==="folder"?E(_,n,!$):(y(_,!1),j(_),X?X(_):y(_,!0)),w.preventDefault())},ne=w=>{T==null||T(w,n,_)},Ee=w=>{w.preventDefault(),re.current=!0,U==null||U(_,Q.trim())},we=w=>{if(w.key==="Escape"){w.preventDefault(),w.stopPropagation(),re.current=!0,A==null||A(_);return}(w.key==="ArrowLeft"||w.key==="ArrowRight"||w.key==="ArrowUp"||w.key==="ArrowDown")&&w.stopPropagation()},ie=()=>{re.current||A==null||A(_),re.current=!1},H=()=>{if(n.type==="folder"){G(),y(_),j(_);return}const w=oe.current!==null;if(w&&oe.current&&clearTimeout(oe.current),oe.current=null,w){X?X(_):y(_,!0);return}y(_,!1),j(_),y(_,!0),oe.current=window.setTimeout(()=>{oe.current=null},300)};return t.useEffect(()=>()=>{oe.current!==null&&typeof window<"u"&&clearTimeout(oe.current)},[]),t.createElement(t.Fragment,null,t.createElement(le.__experimentalTreeGridRow,{level:c,positionInSet:l,setSize:m},t.createElement(le.__experimentalTreeGridCell,null,()=>t.createElement(t.Fragment,null,fe?t.createElement("form",{onSubmit:Ee,className:Qe(he.fileNodeButton,he.renaming,"file-node-button",{[he.selected]:P===_,[he.focused]:S===_,[he.dropTarget]:xe,[he.dropTargetInvalid]:Se}),"data-path":_,onContextMenu:ne,...k},t.createElement(Mt,{node:n,isOpen:n.type==="folder"&&$,level:c,hideName:!0}),t.createElement("input",{ref:te,className:he.renameInput,value:Q,onChange:w=>ce(w.target.value),onBlur:ie,onFocus:()=>j(_),onKeyDown:we})):t.createElement(le.Button,{...k,draggable:Te,onDragStart:w=>b==null?void 0:b(w,n,_),onDragEnd:w=>Z==null?void 0:Z(w,n,_),onClick:H,onKeyDown:W,onFocus:()=>{j(_)},onContextMenu:ne,className:Qe(he.fileNodeButton,"file-node-button",{[he.selected]:P===_,[he.focused]:S===_,[he.dropTarget]:xe,[he.dropTargetInvalid]:Se}),"data-path":_,"data-expanded":$?"true":"false"},t.createElement(Mt,{node:n,isOpen:n.type==="folder"&&$,level:c}))))),$&&C&&C.map((w,ge)=>t.createElement(Wt,{key:w.name,node:w,level:c+1,position:ge+1,setSize:C.length,expandedNodePaths:p,onToggle:E,selectedNode:P,focusPath:j,focusedNode:S,selectPath:y,generatePath:v,getChildren:N,onContextMenu:T,renamingPath:I,onRename:U,onRenameCancel:A,parentPath:_,dropIndicator:h,onDragStart:b,onDragEnd:Z,onDragEnter:V,onDragOver:q,onDragLeave:J,onDrop:B,rootPath:L,onDoubleClickFile:X})))},Mt=({node:n,level:c,isOpen:l,hideName:m=!1})=>{const p=[];for(let E=0;E<c;E++)p.push("&nbsp;&nbsp;&nbsp;&nbsp;");return t.createElement(t.Fragment,null,t.createElement("span",{"aria-hidden":"true",dangerouslySetInnerHTML:{__html:p.join("")}}),n.type==="folder"?t.createElement(Ft,{width:16,icon:l?dr:mr}):t.createElement("div",{style:{width:16}}," "),t.createElement(Ft,{width:16,icon:n.type==="folder"?Vt:Bt}),!m&&t.createElement("span",{className:he.fileName},n.name))},Sr="_control_kp9d9_1",Tr="_browse-label_kp9d9_11",Pr="_path-preview_kp9d9_37",kr="_modal_kp9d9_43",Nr="_modal-footer_kp9d9_48",He={control:Sr,browseLabel:Tr,pathPreview:Pr,modal:kr,modalFooter:Nr};function Dr({path:n}){if(!n)return t.createElement("div",{className:He.pathPreview},t.createElement("i",null,"Select a path"));const c=n.split("/");let l=(c.length>2?"/":"")+c.pop();l.length>10&&(l=l.substring(l.length-10));const m=n.substring(0,n.length-l.length);return t.createElement("div",{className:He.pathPreview,"data-content-start":m,"data-content-end":l})}function Or({value:n="",onChange:c,filesystem:l}){const[m,p]=t.useState(!1),E=()=>p(!0),P=()=>p(!1),[j,S]=t.useState(n||null);function y(v){v==null||v.preventDefault(),c(j||""),P()}return t.createElement(t.Fragment,null,t.createElement(le.Button,{variant:"tertiary",className:He.control,onClick:E},t.createElement("span",{className:He.browseLabel},"Browse"),t.createElement(Dr,{path:n||""})),m&&t.createElement(le.Modal,{title:"Select a path ",onRequestClose:P,className:He.modal},t.createElement("form",{onSubmit:y},t.createElement($t,{filesystem:l,initialSelectedPath:n,onSelect:S}),t.createElement("div",{className:He.modalFooter},t.createElement(le.Button,{type:"submit",variant:"primary"},"Select Path")))))}const Ar="_container_1h0az_1",Lr="_header_1h0az_9",Fr="_filename_1h0az_18",Ir="_downloadLink_1h0az_26",jr="_previewArea_1h0az_38",Mr="_imagePreview_1h0az_51",Vr="_videoPreview_1h0az_57",Br="_audioPreview_1h0az_64",$r="_unsupportedMessage_1h0az_68",Wr="_actions_1h0az_74",Ce={container:Ar,header:Lr,filename:Fr,downloadLink:Ir,previewArea:jr,imagePreview:Mr,videoPreview:Vr,audioPreview:Br,unsupportedMessage:$r,actions:Wr},Hr=n=>{if(!n)return{isImage:!1,isVideo:!1,isAudio:!1};const c=n.toLowerCase();return{isImage:c.startsWith("image/"),isVideo:c.startsWith("video/"),isAudio:c.startsWith("audio/")}};function zr({filename:n,mimeType:c,dataUrl:l,downloadUrl:m,showHeader:p=!0}){const{isImage:E,isVideo:P,isAudio:j}=Hr(c),S=p!==!1,y=!!(m&&n),v=()=>y?t.createElement("a",{className:Ce.downloadLink,href:m,download:n},"Download"):null,N=()=>E?t.createElement("img",{className:Ce.imagePreview,src:l,alt:n||"Preview"}):P?t.createElement("video",{className:Ce.videoPreview,controls:!0,preload:"metadata"},t.createElement("source",{src:l,type:c}),"Your browser does not support the video tag."):j?t.createElement("audio",{className:Ce.audioPreview,controls:!0},t.createElement("source",{src:l,type:c}),"Your browser does not support the audio tag."):t.createElement("div",{className:Ce.unsupportedMessage},t.createElement("p",null,"Preview unavailable for this file type."),y?t.createElement("p",null,v()):t.createElement("p",null,"Download the file to inspect its contents."));return t.createElement("div",{className:Ce.container},S&&t.createElement("div",{className:Ce.header},t.createElement("span",{className:Ce.filename,title:n},n),v()),t.createElement("div",{className:Ce.previewArea},N()),!S&&y&&t.createElement("div",{className:Ce.actions},v()))}const Tt=new Map,Ur=async n=>{var p;if(!n)return et.php();const c=(p=n.split(".").pop())==null?void 0:p.toLowerCase();if(!c||c==="php")return et.php();const l=n;if(Tt.has(l))return Tt.get(l);let m;switch(c){case"css":m=await import("@codemirror/lang-css").then(E=>E.css());break;case"js":case"jsx":case"ts":case"tsx":m=await import("@codemirror/lang-javascript").then(E=>E.javascript({jsx:c==="jsx"||c==="tsx",typescript:c==="ts"||c==="tsx"}));break;case"json":m=await import("@codemirror/lang-json").then(E=>E.json());break;case"html":case"htm":m=await import("@codemirror/lang-html").then(E=>E.html());break;case"md":case"markdown":m=await import("@codemirror/lang-markdown").then(E=>E.markdown());break;default:m=et.php()}return Tt.set(l,m),m};class qr{constructor(c){this.view=c,this.handleClick=this.handleClick.bind(this),this.view.dom.addEventListener("mousedown",this.handleClick)}handleClick(c){const l=c.target;if((l.classList.contains("cm-scroller")||l.classList.contains("cm-content"))&&this.view.posAtCoords({x:c.clientX,y:c.clientY})===null){const p=this.view.state.doc.length,E=Oe.EditorSelection.create([Oe.EditorSelection.range(p,p)]);this.view.dispatch({selection:E,effects:ve.EditorView.scrollIntoView(p,{y:"center"})}),this.view.focus(),c.preventDefault()}}destroy(){this.view.dom.removeEventListener("mousedown",this.handleClick)}}const Yr=ve.ViewPlugin.define(n=>new qr(n)),Nt=t.forwardRef(function({code:c,onChange:l,currentPath:m,className:p,onSaveShortcut:E,readOnly:P=!1,additionalExtensions:j},S){const y=t.useRef(null),v=t.useRef(null),N=t.useRef(new Oe.Compartment),T=t.useRef(new Oe.Compartment),I=t.useRef(new Oe.Compartment),U=t.useRef(c),A=t.useRef(l),D=t.useRef(!1);return t.useImperativeHandle(S,()=>({focus:()=>{var h;(h=v.current)==null||h.focus()},blur:()=>{const h=v.current;h&&h.contentDOM.blur()},getCursorPosition:()=>v.current?v.current.state.selection.main.anchor:null,setCursorPosition:h=>{if(!v.current)return;const b=Math.min(h,v.current.state.doc.length),Z=Oe.EditorSelection.create([Oe.EditorSelection.range(b,b)]);v.current.dispatch({selection:Z,scrollIntoView:!0})}})),t.useEffect(()=>{U.current=c},[c]),t.useEffect(()=>{A.current=l},[l]),t.useEffect(()=>{if(v.current)return;const h=y.current;if(!h)return;const b=Oe.EditorState.create({doc:c,extensions:[I.current.of(j??[]),ve.lineNumbers(),ve.highlightActiveLineGutter(),ve.highlightActiveLine(),We.foldGutter(),ve.dropCursor(),ve.rectangularSelection(),ve.crosshairCursor(),Yr,N.current.of(et.php()),T.current.of(ve.EditorView.editable.of(!P)),We.syntaxHighlighting(We.defaultHighlightStyle),We.indentOnInput(),We.bracketMatching(),ft.closeBrackets(),ut.history(),Ot.highlightSelectionMatches(),ft.autocompletion(),ve.EditorView.updateListener.of(V=>{if(!V.docChanged)return;const q=V.state.doc.toString();q!==U.current&&(U.current=q,A.current(q))}),ve.keymap.of([{key:"Mod-s",preventDefault:!0,run:()=>(E==null||E(),!0)},...ft.closeBracketsKeymap,...ft.completionKeymap,...We.foldKeymap,...Ot.searchKeymap,...ut.historyKeymap,...ut.defaultKeymap,ut.indentWithTab])]}),Z=new ve.EditorView({state:b,parent:h});return v.current=Z,()=>{Z.destroy(),v.current=null}},[]),t.useEffect(()=>{const h=v.current;h&&h.dispatch({effects:I.current.reconfigure(j??[])})},[j]),t.useEffect(()=>{const h=v.current;if(!h)return;const b=h.state.doc.toString();c!==b&&h.dispatch({changes:{from:0,to:h.state.doc.length,insert:c}})},[c]),t.useEffect(()=>{var q;const h=v.current;if(!h)return;const b=(q=m==null?void 0:m.split(".").pop())==null?void 0:q.toLowerCase();(!b||b==="php")&&h.dispatch({effects:N.current.reconfigure(et.php())});let V=!1;return Ur(m).then(J=>{V||!v.current||v.current.dispatch({effects:N.current.reconfigure(J)})}),()=>{V=!0}},[m]),t.useEffect(()=>{const h=v.current;h&&(h.hasFocus&&(D.current=!0),h.dispatch({effects:T.current.reconfigure(ve.EditorView.editable.of(!P))}))},[P]),t.useLayoutEffect(()=>{const h=v.current;h&&D.current&&!h.hasFocus&&(h.focus(),D.current=!1)},[m,P]),t.createElement("div",{ref:y,className:p})});Nt.displayName="CodeEditor";const Zr="_fileExplorerContainer_1m4t6_1",Gr="_fileExplorerHeader_1m4t6_14",Kr="_fileExplorerTitle_1m4t6_23",Jr="_fileExplorerActions_1m4t6_31",Xr="_fileExplorerButton_1m4t6_37",Qr="_fileExplorerTree_1m4t6_84",je={fileExplorerContainer:Zr,fileExplorerHeader:Gr,fileExplorerTitle:Kr,fileExplorerActions:Jr,fileExplorerButton:Xr,fileExplorerTree:Qr},Ht=1024*1024,zt=n=>{const c=n.byteLength;for(let l=0;l<Math.min(c,4096);l++)if(n[l]===0)return!0;try{return new TextDecoder("utf-8",{fatal:!0}).decode(n),!1}catch{return!0}},kt=(n,c)=>{const l=new Blob([n]),m=URL.createObjectURL(l);return setTimeout(()=>URL.revokeObjectURL(m),6e4),{url:m,filename:c}},Ut=n=>{const c=n.split(".").pop();return Lt[c]||Lt._default},qt=n=>n.startsWith("image/")||n.startsWith("video/")||n.startsWith("audio/");function Yt({filesystem:n,currentPath:c,selectedDirPath:l,setSelectedDirPath:m,onFileOpened:p,onSelectionCleared:E,onShowMessage:P,documentRoot:j}){const S=t.useRef(null),y=t.useMemo(()=>se.normalizePath(c?se.dirname(se.normalizePath(c)):l??j),[c,j]),[v,N]=t.useState(null),T=async(I,U)=>{try{const A=await n.read(I),D=new Uint8Array(await A.arrayBuffer()),h=D.byteLength,b=I.split("/").pop()||"download";if(h>Ht){const{url:V,filename:q}=kt(D,b);await P(I,t.createElement(t.Fragment,null,t.createElement("p",null,"File too large to open (>1MB)."),t.createElement("p",null,t.createElement("a",{href:V,download:q},"Download ",q))));return}if(zt(D)){const V=Ut(b),{url:q,filename:J}=kt(D,b);if(qt(V)){const B=new Blob([D],{type:V}),L=URL.createObjectURL(B);await P(I,t.createElement(At.BinaryFilePreview,{filename:J,mimeType:V,dataUrl:L,downloadUrl:q}));return}await P(I,t.createElement(t.Fragment,null,t.createElement("p",null,"Binary file. Cannot be edited."),t.createElement("p",null,t.createElement("a",{href:q,download:J},"Download ",J))));return}const Z=new TextDecoder("utf-8").decode(D);await p(I,Z,U)}catch(A){dt.logger.error("Could not open file",A),await P(null,"Could not open file.")}};return t.createElement("div",{className:je.fileExplorerContainer},t.createElement("div",{className:je.fileExplorerHeader},t.createElement("span",{className:je.fileExplorerTitle},"Files"),t.createElement("div",{className:je.fileExplorerActions},t.createElement("button",{className:je.fileExplorerButton,type:"button",onClick:()=>{S.current&&S.current.createFile(v??void 0)},title:"Create new file"},t.createElement(le.Icon,{icon:hr,size:16}),"New File"),t.createElement("button",{className:je.fileExplorerButton,type:"button",onClick:()=>{S.current&&S.current.createFolder(v??void 0)},title:"Create new folder"},t.createElement(le.Icon,{icon:pr,size:16}),"New Folder"))),t.createElement("div",{className:je.fileExplorerTree},t.createElement(At.FilePickerTree,{ref:S,filesystem:n,root:j,initialSelectedPath:y,onSelect:async I=>{if(N(I),!I){await E();return}try{if(await n.isDir(I)){m(I);return}}catch{}await T(I,!1)},onDoubleClickFile:async I=>{await T(I,!0)}})))}const en="_container_15o5h_1",tn="_content_15o5h_9",rn="_sidebarWrapper_15o5h_17",nn="_editorWrapper_15o5h_28",an="_editorHeader_15o5h_37",on="_editorPath_15o5h_49",sn="_editorPathPlaceholder_15o5h_60",ln="_saveStatus_15o5h_71",cn="_saveStatusSaving_15o5h_78",un="_saveStatusPending_15o5h_79",fn="_saveStatusError_15o5h_83",dn="_editor_15o5h_28",mn="_placeholder_15o5h_105",pn="_messageArea_15o5h_116",hn="_mobileToggle_15o5h_152",wn="_mobileOverlay_15o5h_156",gn="_sidebarOpen_15o5h_171",ue={container:en,content:tn,sidebarWrapper:rn,editorWrapper:nn,editorHeader:an,editorPath:on,editorPathPlaceholder:sn,saveStatus:ln,saveStatusSaving:cn,saveStatusPending:un,saveStatusError:fn,editor:dn,placeholder:mn,messageArea:pn,mobileToggle:hn,mobileOverlay:wn,sidebarOpen:gn},vn=1500,Y={IDLE:"idle",PENDING:"pending",SAVING:"saving",SAVED:"saved",ERROR:"error"};function En({filesystem:n,isVisible:c=!0,documentRoot:l,initialPath:m=null,placeholderText:p="Select a file to view or edit its contents.",onSaveFile:E,onBeforeFilesystemChange:P}){const[j,S]=t.useState(l),[y,v]=t.useState(null),[N,T]=t.useState(""),[I,U]=t.useState(!0),[A,D]=t.useState(Y.IDLE),[h,b]=t.useState(null),[Z,V]=t.useState(!1),[q,J]=t.useState(null),B=t.useRef(null),L=t.useRef(null),X=t.useRef(!1),_=t.useRef(N),$=t.useRef(y),fe=t.useRef(n),te=t.useRef(null),Q=t.useRef(new Map),ce=t.useRef(!1);t.useEffect(()=>{_.current=N},[N]),t.useEffect(()=>{$.current=y},[y]),t.useEffect(()=>{fe.current=n},[n]),t.useEffect(()=>{const k=te.current;k&&k!==n&&P&&P(k),te.current=n},[n,P]),t.useEffect(()=>{n||(X.current=!0,T(""),v(null),U(!0),D(Y.IDLE),b(null),V(!1),J(null),ce.current=!1)},[n]),t.useEffect(()=>{if(!n||!m||ce.current)return;(async()=>{try{if(await n.fileExists(m)){const G=await n.readFileAsText(m);X.current=!0,v(m),T(G),U(!1),D(Y.IDLE),b(null),setTimeout(()=>{var W;(W=B.current)==null||W.focus()},100)}}catch(C){dt.logger.debug("Could not auto-open initial path:",C)}finally{ce.current=!0}})()},[n,m]),t.useEffect(()=>{S(l),v(null),T(""),U(!0),D(Y.IDLE),b(null),X.current=!0,J(null),ce.current=!1},[l]),t.useEffect(()=>()=>{L.current!==null&&(window.clearTimeout(L.current),L.current=null)},[]),t.useEffect(()=>{const k=fe.current;if(!k||!y){L.current!==null&&(window.clearTimeout(L.current),L.current=null),y||D(Y.IDLE);return}if(X.current){X.current=!1;return}L.current!==null&&(window.clearTimeout(L.current),L.current=null),D(Y.PENDING);const C=window.setTimeout(async()=>{L.current=null,D(Y.SAVING);try{const G=$.current,W=_.current;E?await E(G,W):await k.writeFile(G,W),D(Y.SAVED),b(null)}catch(G){dt.logger.error("Failed to save file",G),D(Y.ERROR),b("Could not save changes. Try again.")}},vn);return L.current=C,()=>{L.current===C&&(window.clearTimeout(C),L.current=null)}},[N,y,E]),t.useEffect(()=>{if(A!==Y.SAVED)return;const k=window.setTimeout(()=>{D(C=>C===Y.SAVED?Y.IDLE:C)},2e3);return()=>window.clearTimeout(k)},[A]);const re=t.useCallback(async(k,C,G=!0)=>{var ne;const W=(ne=B.current)==null?void 0:ne.getCursorPosition();W!=null&&$.current&&Q.current.set($.current,W),X.current=!0,v(k),T(C),J(null),U(!1),D(Y.IDLE),b(null),V(!1),setTimeout(()=>{var we,ie,H;const Ee=Q.current.get(k);Ee!==void 0&&((we=B.current)==null||we.setCursorPosition(Ee)),G?(ie=B.current)==null||ie.focus():(H=B.current)==null||H.blur()},50)},[]);t.useEffect(()=>{var G;if(!y)return;const k=setInterval(()=>{var ne;const W=(ne=B.current)==null?void 0:ne.getCursorPosition();W!=null&&Q.current.set(y,W)},1e3),C=(G=B.current)==null?void 0:G.getCursorPosition();return C!=null&&Q.current.set(y,C),()=>{var ne;clearInterval(k);const W=(ne=B.current)==null?void 0:ne.getCursorPosition();W!=null&&Q.current.set(y,W)}},[y]),t.useEffect(()=>{if(!c||!y)return;const k=setTimeout(()=>{var G;const C=Q.current.get(y);C!==void 0&&((G=B.current)==null||G.setCursorPosition(C))},100);return()=>clearTimeout(k)},[c,y]);const be=t.useCallback(async()=>{var C;const k=(C=B.current)==null?void 0:C.getCursorPosition();k!=null&&$.current&&Q.current.set($.current,k),X.current=!0,v(null),T(""),J(null),U(!0),D(Y.IDLE),b(null)},[]),xe=t.useCallback(async(k,C)=>{X.current=!0,v(null),typeof C=="string"?(T(C),J(null)):(T(""),J(C)),U(!0),D(Y.IDLE),b(null),V(!1)},[]),Se=t.useCallback(async()=>{if(L.current!==null){if(!fe.current||!$.current){window.clearTimeout(L.current),L.current=null;return}window.clearTimeout(L.current),L.current=null,D(Y.SAVING);try{const k=$.current,C=_.current;E?await E(k,C):await fe.current.writeFile(k,C),D(Y.SAVED),b(null)}catch(k){dt.logger.error("Failed to save file",k),D(Y.ERROR),b("Could not save changes. Try again.")}}},[E]),Te=yn(A,h),oe=_n(A,ue);return n?t.createElement("div",{className:ue.container},t.createElement("div",{className:Qe(ue.content,{[ue.sidebarOpen]:Z})},t.createElement("div",{className:ue.mobileOverlay,onClick:()=>V(!1)}),t.createElement("aside",{className:ue.sidebarWrapper},t.createElement(Yt,{filesystem:n,currentPath:y,selectedDirPath:j,setSelectedDirPath:S,onFileOpened:re,onSelectionCleared:be,onShowMessage:xe,documentRoot:l})),t.createElement("section",{className:ue.editorWrapper},t.createElement("div",{className:ue.editorHeader},t.createElement(le.Button,{className:ue.mobileToggle,variant:"secondary",onClick:()=>V(k=>!k)},Z?"Hide files":"Browse files"),t.createElement("div",{className:Qe(ue.editorPath,{[ue.editorPathPlaceholder]:!(y!=null&&y.length)})},y!=null&&y.length?y:`Browse files under ${l}`),t.createElement("div",{className:Qe(ue.saveStatus,oe)},Te)),h?t.createElement("div",{style:{padding:"8px 16px"}},t.createElement(le.Notice,{status:"error",isDismissible:!1},h)):null,y||N||q?q?t.createElement("div",{className:ue.messageArea},q):t.createElement(Nt,{ref:B,code:N,onChange:T,currentPath:y,className:ue.editor,onSaveShortcut:Se,readOnly:I}):t.createElement("div",{className:ue.placeholder},p)))):t.createElement("div",{className:ue.container},t.createElement("div",{className:ue.placeholder},p))}function yn(n,c){switch(n){case Y.PENDING:case Y.SAVING:return"Saving…";case Y.SAVED:return"Saved";case Y.ERROR:return c??"Save failed";default:return""}}function _n(n,c){switch(n){case Y.PENDING:return c.saveStatusPending;case Y.SAVING:return c.saveStatusSaving;case Y.ERROR:return c.saveStatusError;default:return}}exports.BinaryFilePreview=zr;exports.ClockIcon=ir;exports.CodeEditor=Nt;exports.FileExplorerSidebar=Yt;exports.FilePickerControl=Or;exports.FilePickerTree=$t;exports.MAX_INLINE_FILE_BYTES=Ht;exports.PlaygroundFileEditor=En;exports.SiteManagerIcon=cr;exports.WordPressIcon=or;exports.createDownloadUrl=kt;exports.file=Bt;exports.folder=Vt;exports.getLogoDataURL=lr;exports.getMimeType=Ut;exports.isPreviewableBinary=qt;exports.layout=sr;exports.playgroundLogo=nr;exports.seemsLikeBinary=zt;exports.temporaryStorage=ar;
30
+ <%s key={someKey} {...props} />`,Rt,Ve,Zt,Ve),i[Ve+Rt]=!0}}return t===l?o(se):a(se),se}}function w(t,c,p){return f(t,c,p,!0)}function E(t,c,p){return f(t,c,p,!1)}var re=E,he=w;rt.Fragment=l,rt.jsx=re,rt.jsxs=he}()),rt}process.env.NODE_ENV==="production"?Pt.exports=fr():Pt.exports=dr();var ke=Pt.exports,Ke=n=>pt.createElement("path",n),Je=pt.forwardRef(({className:n,isPressed:s,...d},l)=>{const x={...d,className:nr(n,{"is-pressed":s})||void 0,"aria-hidden":!0,focusable:!1};return ke.jsx("svg",{...x,ref:l})});Je.displayName="SVG";const mr=ke.jsx(Je,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:ke.jsx(Ke,{d:"M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z"})}),pr=ke.jsx(Je,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:ke.jsx(Ke,{d:"M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z"})}),hr=ke.jsx(Je,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:ke.jsx(Ke,{fillRule:"evenodd",clipRule:"evenodd",d:"M12.848 8a1 1 0 0 1-.914-.594l-.723-1.63a.5.5 0 0 0-.447-.276H5a.5.5 0 0 0-.5.5v11.5a.5.5 0 0 0 .5.5h14a.5.5 0 0 0 .5-.5v-9A.5.5 0 0 0 19 8h-6.152Zm.612-1.5a.5.5 0 0 1-.462-.31l-.445-1.084A2 2 0 0 0 10.763 4H5a2 2 0 0 0-2 2v11.5a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-9a2 2 0 0 0-2-2h-5.54Z"})}),vr=ke.jsxs(Je,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:[ke.jsx(Ke,{d:"M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z"}),ke.jsx(Ke,{d:"M17 4H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2ZM7 5.5h10a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H7a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5Z"})]}),wr=ke.jsx(Je,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:ke.jsx(Ke,{d:"M18.5 15v3.5H13V6.7l4.5 4.1 1-1.1-6.2-5.8-5.8 5.8 1 1.1 4-4v11.7h-6V15H4v5h16v-5z"})}),gr="_file-picker-tree_ad9od_1",Er="_file-node-button_ad9od_17",yr="_selected_ad9od_56",_r="_focused_ad9od_75",br="_dropTarget_ad9od_83",xr="_dropTargetInvalid_ad9od_95",Cr="_renaming_ad9od_104",Rr="_renameInput_ad9od_109",Sr="_file-name_ad9od_124",ge={filePickerTree:gr,fileNodeButton:Er,selected:yr,focused:_r,dropTarget:br,dropTargetInvalid:xr,renaming:Cr,renameInput:Rr,fileName:Sr};function St(n){if(!n)return[];const s=G.normalizePath(n),d=s.startsWith("/"),l=s.split("/").filter(Boolean),x=[];let m=d?"/":"";d&&x.push("/");for(const S of l)!m||m==="/"?m=m==="/"?`/${S}`:S:m=`${m}/${S}`,x.push(m);return x}function $e(n,s,d){return n&&(n===s?d:n.startsWith(s==="/"?"/":`${s}/`)?d+n.slice(s.length):n)}const Ht=e.forwardRef(function({withContextMenu:s=!0,readOnly:d=!1,filesystem:l,root:x="/wordpress",initialSelectedPath:m,onSelect:S=()=>{},onDoubleClickFile:N},h){const T=e.useMemo(()=>G.joinPaths("/",x||"/"),[x]),[_,k]=e.useState(()=>{if(!m)return{};const r={};for(const a of St(m))r[a]=!0;return r}),[P,$]=e.useState(()=>m??null),[F,D]=e.useState(()=>m??null),[le,v]=e.useState({}),[C,Y]=e.useState({}),[ee,Z]=e.useState(null),[y,j]=e.useState(null),I=e.useRef({}),V=e.useRef(!1),g=e.useRef(null),M=e.useRef(null),de=e.useRef(C),A=e.useRef(le),K=()=>{for(const r of Object.keys(I.current))clearTimeout(I.current[r]),delete I.current[r]},ue=r=>{const a=I.current[r];a&&(clearTimeout(a),delete I.current[r])};e.useEffect(()=>{de.current=C},[C]),e.useEffect(()=>{A.current=le},[le]);const J=r=>{var o;const a=(o=g.current)==null?void 0:o.querySelector(`[data-path="${CSS.escape(r)}"]`);a&&typeof a.focus=="function"&&(a.focus(),a.scrollIntoView({behavior:"smooth",block:"nearest"}))},ie=(r,a="")=>a?G.joinPaths(a,r.name):G.joinPaths("/",r.name),Te=(r,a)=>r.children?r.children:le[a],xe=async(r,a)=>{const o=await r.listFiles(a),i=[];for(const f of o){const w=a==="/"?`/${f}`:`${a}/${f}`,E=await r.isDir(w);i.push({name:f,type:E?"folder":"file"})}return i.sort((f,w)=>{var t;if(f.type!==w.type)return f.type==="folder"?-1:1;const E=a==="/"?`/${f.name}`:`${a}/${f.name}`,re=a==="/"?`/${w.name}`:`${a}/${w.name}`,he=(t=U.current)==null?void 0:t.tempPath;if(he){if(E===he)return-1;if(re===he)return 1}return f.name.localeCompare(w.name)}),i},Ce=async r=>await xe(l,r),ce=(r,a)=>{if(a.type!=="folder")return a.children;const o=a.children??A.current[r];return o||de.current[r]?o:(Y(i=>({...i,[r]:!0})),new Promise(i=>{Ce(r).then(f=>{v(w=>({...w,[r]:f??[]})),i(f??[])}).catch(()=>{i([])}).finally(()=>{Y(f=>{const w={...f};return delete w[r],w})})}))},Fe=(r,a)=>{a.type==="folder"&&(typeof window>"u"||I.current[r]||(I.current[r]=window.setTimeout(()=>{k(o=>o[r]?o:{...o,[r]:!0}),ce(r,a),delete I.current[r]},600)))},te=r=>(Y(a=>({...a,[r]:!0})),new Promise(a=>{Ce(r).then(o=>{v(i=>({...i,[r]:o??[]})),a(o??[])}).catch(()=>{a([])}).finally(()=>{Y(o=>{const i={...o};return delete i[r],i})})})),Pe=(r,a,o)=>{k(i=>({...i,[r]:o})),o?ce(r,a):v(i=>{if(i[r]===void 0)return i;const f={...i};return delete f[r],f})},Re=async r=>{if(!r)return;const a=St(r);if(a.length===0)return;k(f=>{const w={...f};for(const E of a)w[E]=!0;return w});let o=[{name:T,type:"folder"}],i="";for(const f of a){const w=o==null?void 0:o.find(re=>ie(re,i)===f);if(!w||w.type!=="folder"){i=f,o=[];continue}o=await ce(f,w)??A.current[f],i=f}},Ee=(r,a)=>{!r||!a||r===a||(k(o=>{let i=!1;const f={...o};for(const w of Object.keys(o)){const E=$e(w,r,a);E&&E!==w&&(f[E]=o[w],delete f[w],i=!0)}return i?f:o}),v(o=>{let i=!1;const f={...o};for(const w of Object.keys(o)){const E=$e(w,r,a);E&&E!==w&&(f[E]=o[w],delete f[w],i=!0)}return i?f:o}),$(o=>$e(o,r,a)),D(o=>$e(o,r,a)))},De=()=>{Z(null),j(null),K()},ye=(r,a=!0)=>{$(r),a&&S(r)},ae=e.useMemo(()=>[{name:T,type:"folder"}],[T]),[z,u]=e.useState(null),[b,H]=e.useState(null),U=e.useRef(null),Q=d?null:b;e.useImperativeHandle(h,()=>({focusPath:(r,a={})=>{if(!r)return;const{select:o=!0,domFocus:i=!0,notify:f=!1}=a;o&&ye(r,f),D(r),i&&J(r)},selectPath:r=>{r&&(ye(r),D(r),J(r))},getSelectedPath:()=>P,expandToPath:async r=>await Re(r),refresh:async r=>await te(r),remapPath:Ee,createFile:async r=>{d||await We(r,"file","untitled.php")},createFolder:async r=>{d||await We(r,"folder","New Folder")},importFiles:async(r,a)=>{d||await Le(r,a)},importDataTransfer:async(r,a)=>{d||await Ue(r,a)}}),[P,te,Ee,Re,d]);const fe=e.useRef(!1),Ae=e.useRef(m??null),_e=e.useRef(m);e.useEffect(()=>{V.current=!1},[T]),e.useEffect(()=>{m&&m!==_e.current?Ae.current=m:m||(Ae.current=null),_e.current=m},[m]),e.useEffect(()=>{if(!m||fe.current)return;fe.current=!0;const r=St(m);k(o=>{const i={...o};for(const f of r)i[f]=!0;return i});const a=r[r.length-1]||m;D(a),$(a),Re(m)},[m,Re]),e.useEffect(()=>{const r=Ae.current;!r||ae.length===0||(Ae.current=null,Re(r))},[ae,Re]),e.useEffect(()=>{if(!F){if(ae.length>0){const r=ie(ae[0]);D(r)}return}Q&&Q===F||J(F)},[ae,F,Q]),e.useEffect(()=>{if(ae.length===0)return;const r=ae[0];if((r==null?void 0:r.type)!=="folder"||V.current)return;const a=r.name;V.current=!0,k(o=>o[a]?o:{...o,[a]:!0}),!A.current[a]&&!de.current[a]&&ce(a,r)},[ae,ce,T]),e.useEffect(()=>()=>{M.current&&clearTimeout(M.current),K()},[]),e.useEffect(()=>{z&&setTimeout(()=>{const r=document.querySelector('[role="menu"] [role="menuitem"]');r&&typeof r.focus=="function"&&r.focus()},0)},[z]);const[pe,Be]=e.useState(""),Xe=(r,a)=>{if(r.type==="folder")return a;const o=G.dirname(a);return o&&o||"/"},je=(r,a,o)=>{const i=Xe(r,a);return i?o&&G.isParentOf(o,i)?{allowed:!1,state:"invalid",destination:null}:{allowed:!0,state:"valid",destination:i}:{allowed:!1,state:"invalid",destination:null}},ht=(r,a,o)=>{a.type!=="folder"&&a.type!=="file"||(Z(o),j(null),r.dataTransfer&&(r.dataTransfer.effectAllowed="move",r.dataTransfer.setData("application/x-wp-playground-path",o),r.dataTransfer.setData("text/plain",o)))},vt=()=>{De()},at=(r,a,o)=>{const i=je(a,o,ee);i.allowed&&a.type==="folder"&&Fe(o,a),j(f=>(f==null?void 0:f.path)===o&&f.state===i.state?f:{path:o,state:i.state})},ot=(r,a,o)=>{const i=je(a,o,ee);i.allowed&&i.destination?(r.preventDefault(),r.dataTransfer&&(r.dataTransfer.dropEffect=ee?"move":"copy"),a.type==="folder"&&Fe(o,a),j(f=>(f==null?void 0:f.path)===o&&f.state===i.state?f:{path:o,state:i.state})):(r.dataTransfer&&(r.dataTransfer.dropEffect="none"),ue(o),j(f=>(f==null?void 0:f.path)===o&&f.state==="invalid"?f:{path:o,state:"invalid"}))},it=(r,a,o)=>{ue(o);const i=r.relatedTarget;i&&r.currentTarget.contains(i)||j(f=>(f==null?void 0:f.path)===o?null:f)},wt=async(r,a,o)=>{const i=ee,f=je(a,o,i);if(!f.allowed||!f.destination){De();return}r.preventDefault(),r.stopPropagation(),ue(o),j(null);try{i?await yt(i,f.destination):await Ue(r.dataTransfer,f.destination)}finally{De()}},st=(r,a,o)=>{s&&(r.preventDefault(),r.stopPropagation(),H(null),u({absPath:o,type:a.type,x:r.clientX,y:r.clientY}))},Oe=async(r,a)=>{let o=a,i=0;const f=E=>{const re=E.lastIndexOf(".");return re>0?{stem:E.slice(0,re),ext:E.slice(re)}:{stem:E,ext:""}},w=r==="/"?"":r;for(;await(l==null?void 0:l.fileExists(`${w}/${o}`))||await(l==null?void 0:l.isDir(`${w}/${o}`));){i+=1;const{stem:E,ext:re}=f(a);o=`${E} (${i})${re}`}return o},We=async(r,a,o)=>{if(!l)return;let i=r||P||T;try{await l.isDir(i)||(i=G.dirname(i))}catch{i=G.dirname(i)}const f=i,w=await Oe(f,o),E=G.joinPaths(f,w);a==="folder"?await l.mkdir(E):await l.writeFile(E,""),U.current={type:a,tempPath:E},H(E),await te(f),setTimeout(()=>{D(E),J(E)},0)},gt=async r=>{if(!l)return!1;try{if(await l.fileExists(r))return!0}catch{}try{if(await l.isDir(r))return!0}catch{}return!1},Et=async r=>{if(l)try{await l.mkdir(r)}catch(a){if(!await l.isDir(r).catch(()=>!1))throw a}},yt=async(r,a)=>{if(!l)return;const o=G.basename(r),i=G.joinPaths(a,o);if(i===r||await gt(i))return;const f=G.dirname(r);try{await l.mv(r,i),Ee(r,i);const w=$e(P,r,i);P&&(P===r||P.startsWith(`${r}/`))&&S(w),D(E=>$e(E,r,i)),k(E=>({...E,[a]:!0})),await Promise.all([te(f),te(a)]),$(E=>$e(E,r,i)),J(i)}catch{}},_t=r=>{const a=r;return a.webkitGetAsEntry?a.webkitGetAsEntry():null},bt=r=>new Promise((a,o)=>{r.file(a,o)}),lt=async(r,a)=>{if(!l)return;const o=r.name||"untitled",i=await Oe(a,o),f=G.joinPaths(a,i),w=new Uint8Array(await r.arrayBuffer());await l.writeFile(f,w)},He=async(r,a)=>{const o=await bt(r);await lt(o,a)},Qe=async(r,a)=>{const o=await Oe(a,r.name||"New Folder"),i=G.joinPaths(a,o);await Et(i);const f=r.createReader(),w=()=>new Promise((E,re)=>{f.readEntries(he=>E(Array.from(he)),re)});for(;;){const E=await w();if(!E.length)break;for(const re of E)re.isFile?await He(re,i):re.isDirectory&&await Qe(re,i)}},Le=(r,a)=>ze([],r,a),Ue=(r,a)=>{const i=Array.from(r.items).filter(w=>w.kind==="file").map(w=>_t(w)).filter(w=>!!w),f=Array.from(r.files);return ze(i,f,a)},ze=async(r,a,o)=>{if(l){if(r.length>0)for(const i of r)i.isFile?await He(i,o):i.isDirectory&&await Qe(i,o);else for(const i of a)await lt(i,o);await te(o),k(i=>({...i,[o]:!0}))}},ct=async(r,a)=>{if(!l)return;const o=r;u(null);try{a==="folder"?await l.rmdir(o,{recursive:!0}):await l.unlink(o)}catch{}finally{H(null);const i=G.dirname(o);await te(i),P&&(P===o||P.startsWith(`${o}/`))&&S(null)}},xt=async r=>{if(l)try{const o=await(await l.read(r)).arrayBuffer(),i=new Blob([o]),f=URL.createObjectURL(i),w=document.createElement("a");w.href=f,w.download=G.basename(r)||"download",document.body.appendChild(w),w.click(),document.body.removeChild(w),setTimeout(()=>URL.revokeObjectURL(f),6e4)}catch(a){console.error("Failed to download file",a)}},ut=r=>{var a;if(!b)if(r.key.length===1&&r.key.match(/\S/)){const o=pe+r.key.toLowerCase();if(Be(o),M.current&&clearTimeout(M.current),M.current=setTimeout(()=>{Be("")},1e3),!g.current)return;const i=Array.from(g.current.querySelectorAll(".file-node-button")),f=document.activeElement;let w=0;f&&i.includes(f)&&(w=i.indexOf(f));for(let E=0;E<i.length;E++){const re=(w+E)%i.length,he=i[re];if((a=he.textContent)!=null&&a.toLowerCase().trim().startsWith(o)){he.focus();const t=he.getAttribute("data-path");t&&D(t);break}}}else Be(""),M.current&&clearTimeout(M.current)},Ct=async(r,a)=>{if(d)return;const o=U.current,i=(o==null?void 0:o.tempPath)===r,f=G.dirname(r);if(!a||a==="."||a===".."||G.basename(a)!==a){if(i){try{o.type==="folder"?await l.rmdir(r,{recursive:!0}):await l.unlink(r)}catch{}U.current=null}H(i?null:r);return}let w=G.joinPaths(f,a),E=w;if(E===r){H(null);const c=i&&(o==null?void 0:o.type)==="file";i&&(U.current=null),setTimeout(()=>{D(E),J(E),c&&N&&N(E)},0);return}const re=await l.fileExists(E),he=await l.isDir(E);if((re||he)&&E!==r)if(i)try{const c=await Oe(f==="/"?"/":f,a);w=G.joinPaths(f,c),E=w}catch{}else{H(r);return}let t=(o==null?void 0:o.type)==="folder";try{await l.mv(r,w),o||(t=await l.isDir(w)),t&&Ee(r,E),P===r&&S(E),await te(f),D(E),J(E),i&&!t&&N&&N(E)}catch{if(i)try{(o==null?void 0:o.type)==="folder"?await l.rmdir(r,{recursive:!0}):await l.unlink(r)}catch{}}finally{U.current=null,H(null)}},ft=async r=>{const a=U.current;if(!l||(a==null?void 0:a.tempPath)!==r){H(i=>i===r?null:i);return}try{a.type==="folder"?await l.rmdir(r,{recursive:!0}):await l.unlink(r)}catch{}U.current=null,H(null);const o=G.dirname(r);await te(o),D(o),J(o)};return e.createElement("div",{onKeyDown:ut,ref:g},e.createElement(X.__experimentalTreeGrid,{className:ge.filePickerTree},ae.map((r,a)=>e.createElement(Ut,{key:r.name,node:r,level:0,position:a+1,setSize:ae.length,expandedNodePaths:_,onToggle:Pe,selectedNode:P,focusPath:o=>D(o),focusedNode:F,selectPath:ye,generatePath:ie,getChildren:Te,onContextMenu:d?void 0:st,renamingPath:Q,onRename:Ct,onRenameCancel:ft,dropIndicator:y,onDragStart:d?void 0:ht,onDragEnd:d?void 0:vt,onDragEnter:d?void 0:at,onDragOver:d?void 0:ot,onDragLeave:d?void 0:it,onDrop:d?void 0:wt,rootPath:T,onDoubleClickFile:N}))),!d&&z&&e.createElement(X.Popover,{placement:"bottom-start",onClose:()=>u(null),anchor:{getBoundingClientRect:()=>({x:z.x,y:z.y,width:0,height:0,top:z.y,left:z.x,right:z.x,bottom:z.y,toJSON:()=>({})}),ownerDocument:document},noArrow:!0,resize:!1,focusOnMount:"firstElement"},e.createElement(X.NavigableMenu,{role:"menu"},z.type==="folder"&&e.createElement(X.MenuItem,{role:"menuitem",onClick:async()=>{u(null),await We(z.absPath,"file","untitled.php")}},"Create file"),z.type==="folder"&&e.createElement(X.MenuItem,{role:"menuitem",onClick:async()=>{u(null),await We(z.absPath,"folder","New Folder")}},"Create directory"),e.createElement(X.MenuItem,{role:"menuitem",onClick:()=>{u(null),H(z.absPath)}},"Rename"),z.type==="file"&&e.createElement(X.MenuItem,{role:"menuitem",onClick:async()=>{u(null),await xt(z.absPath)}},"Download"),e.createElement(X.MenuItem,{role:"menuitem",onClick:()=>ct(z.absPath,z.type)},"Delete"))))}),Ut=({node:n,level:s,position:d,setSize:l,expandedNodePaths:x,onToggle:m,selectedNode:S,focusPath:N,focusedNode:h,selectPath:T,generatePath:_,getChildren:k,onContextMenu:P,renamingPath:$,onRename:F,onRenameCancel:D,parentPath:le="",dropIndicator:v,onDragStart:C,onDragEnd:Y,onDragEnter:ee,onDragOver:Z,onDragLeave:y,onDrop:j,rootPath:I,onDoubleClickFile:V})=>{const g=_(n,le),M=x[g],de=$===g,A=e.useRef(null),[K,ue]=e.useState(n.name),J=e.useRef(!1),ie=(v==null?void 0:v.path)===g,Te=ie&&(v==null?void 0:v.state)==="valid",xe=ie&&(v==null?void 0:v.state)==="invalid",Ce=!!C&&!de&&g!==I,ce=e.useRef(null),Fe={onDragEnter:u=>ee==null?void 0:ee(u,n,g),onDragOver:u=>Z==null?void 0:Z(u,n,g),onDragLeave:u=>y==null?void 0:y(u,n,g),onDrop:u=>j==null?void 0:j(u,n,g)},te=k(n,g)??[];e.useEffect(()=>{var u;de?(ue(n.name),J.current=!1,typeof window<"u"&&requestAnimationFrame?requestAnimationFrame(()=>{var b;(b=A.current)==null||b.select()}):(u=A.current)==null||u.select()):J.current=!1},[de,n.name]);const Pe=()=>{n.type==="folder"&&m(g,n,!M)},Re=u=>{var b,H;if(u.key==="ArrowLeft")M?Pe():(b=document.querySelector(`[data-path="${CSS.escape(le)}"]`))==null||b.focus(),u.preventDefault(),u.stopPropagation();else if(u.key==="ArrowRight"){if(M){if(te!=null&&te.length){const U=_(te[0],g);(H=document.querySelector(`[data-path="${CSS.escape(U)}"]`))==null||H.focus()}}else Pe();u.preventDefault(),u.stopPropagation()}else u.key===" "||u.key==="Space"||u.key==="Spacebar"?(n.type==="folder"&&m(g,n,!M),u.preventDefault()):u.key==="Enter"&&(n.type==="folder"?m(g,n,!M):(T(g,!1),N(g),V?V(g):T(g,!0)),u.preventDefault())},Ee=u=>{P==null||P(u,n,g)},De=u=>{u.preventDefault(),J.current=!0,F==null||F(g,K)},ye=u=>{if(u.key==="Escape"){u.preventDefault(),u.stopPropagation(),J.current=!0,D==null||D(g);return}(u.key==="ArrowLeft"||u.key==="ArrowRight"||u.key==="ArrowUp"||u.key==="ArrowDown")&&u.stopPropagation()},ae=()=>{J.current||D==null||D(g),J.current=!1},z=()=>{if(n.type==="folder"){Pe(),T(g),N(g);return}const u=ce.current!==null;if(u&&ce.current&&clearTimeout(ce.current),ce.current=null,u){V?V(g):T(g,!0);return}T(g,!1),N(g),T(g,!0),ce.current=window.setTimeout(()=>{ce.current=null},300)};return e.useEffect(()=>()=>{ce.current!==null&&typeof window<"u"&&clearTimeout(ce.current)},[]),e.createElement(e.Fragment,null,e.createElement(X.__experimentalTreeGridRow,{level:s,positionInSet:d,setSize:l},e.createElement(X.__experimentalTreeGridCell,null,()=>e.createElement(e.Fragment,null,de?e.createElement("form",{onSubmit:De,className:Ne(ge.fileNodeButton,ge.renaming,"file-node-button",{[ge.selected]:S===g,[ge.focused]:h===g,[ge.dropTarget]:Te,[ge.dropTargetInvalid]:xe}),"data-path":g,onContextMenu:Ee,...Fe},e.createElement(Vt,{node:n,isOpen:n.type==="folder"&&M,level:s,hideName:!0}),e.createElement("input",{ref:A,className:ge.renameInput,value:K,onChange:u=>ue(u.target.value),onBlur:ae,onFocus:()=>N(g),onKeyDown:ye})):e.createElement(X.Button,{...Fe,draggable:Ce,onDragStart:u=>C==null?void 0:C(u,n,g),onDragEnd:u=>Y==null?void 0:Y(u,n,g),onClick:z,onKeyDown:Re,onFocus:()=>{N(g)},onContextMenu:Ee,className:Ne(ge.fileNodeButton,"file-node-button",{[ge.selected]:S===g,[ge.focused]:h===g,[ge.dropTarget]:Te,[ge.dropTargetInvalid]:xe}),"data-path":g,"data-expanded":M?"true":"false"},e.createElement(Vt,{node:n,isOpen:n.type==="folder"&&M,level:s}))))),M&&te&&te.map((u,b)=>e.createElement(Ut,{key:u.name,node:u,level:s+1,position:b+1,setSize:te.length,expandedNodePaths:x,onToggle:m,selectedNode:S,focusPath:N,focusedNode:h,selectPath:T,generatePath:_,getChildren:k,onContextMenu:P,renamingPath:$,onRename:F,onRenameCancel:D,parentPath:g,dropIndicator:v,onDragStart:C,onDragEnd:Y,onDragEnter:ee,onDragOver:Z,onDragLeave:y,onDrop:j,rootPath:I,onDoubleClickFile:V})))},Vt=({node:n,level:s,isOpen:d,hideName:l=!1})=>{const x=[];for(let m=0;m<s;m++)x.push("&nbsp;&nbsp;&nbsp;&nbsp;");return e.createElement(e.Fragment,null,e.createElement("span",{"aria-hidden":"true",dangerouslySetInnerHTML:{__html:x.join("")}}),n.type==="folder"?e.createElement(Bt,{width:16,icon:d?mr:pr}):e.createElement("div",{style:{width:16}}," "),e.createElement(Bt,{width:16,icon:n.type==="folder"?$t:Wt}),!l&&e.createElement("span",{className:ge.fileName},n.name))},kr="_control_kp9d9_1",Tr="_browse-label_kp9d9_11",Pr="_path-preview_kp9d9_37",Dr="_modal_kp9d9_43",Ar="_modal-footer_kp9d9_48",Ze={control:kr,browseLabel:Tr,pathPreview:Pr,modal:Dr,modalFooter:Ar};function Nr({path:n}){if(!n)return e.createElement("div",{className:Ze.pathPreview},e.createElement("i",null,"Select a path"));const s=n.split("/");let d=(s.length>2?"/":"")+s.pop();d.length>10&&(d=d.substring(d.length-10));const l=n.substring(0,n.length-d.length);return e.createElement("div",{className:Ze.pathPreview,"data-content-start":l,"data-content-end":d})}function Fr({value:n="",onChange:s,filesystem:d}){const[l,x]=e.useState(!1),m=()=>x(!0),S=()=>x(!1),[N,h]=e.useState(n||null);function T(_){_==null||_.preventDefault(),s(N||""),S()}return e.createElement(e.Fragment,null,e.createElement(X.Button,{variant:"tertiary",className:Ze.control,onClick:m},e.createElement("span",{className:Ze.browseLabel},"Browse"),e.createElement(Nr,{path:n||""})),l&&e.createElement(X.Modal,{title:"Select a path ",onRequestClose:S,className:Ze.modal},e.createElement("form",{onSubmit:T},e.createElement(Ht,{filesystem:d,initialSelectedPath:n,onSelect:h}),e.createElement("div",{className:Ze.modalFooter},e.createElement(X.Button,{type:"submit",variant:"primary"},"Select Path")))))}const Ir="_container_1h0az_1",Lr="_header_1h0az_9",Mr="_filename_1h0az_18",Br="_downloadLink_1h0az_26",jr="_previewArea_1h0az_38",Or="_imagePreview_1h0az_51",Vr="_videoPreview_1h0az_57",$r="_audioPreview_1h0az_64",Wr="_unsupportedMessage_1h0az_68",Hr="_actions_1h0az_74",Ie={container:Ir,header:Lr,filename:Mr,downloadLink:Br,previewArea:jr,imagePreview:Or,videoPreview:Vr,audioPreview:$r,unsupportedMessage:Wr,actions:Hr},Ur=n=>{if(!n)return{isImage:!1,isVideo:!1,isAudio:!1};const s=n.toLowerCase();return{isImage:s.startsWith("image/"),isVideo:s.startsWith("video/"),isAudio:s.startsWith("audio/")}};function zr({filename:n,mimeType:s,dataUrl:d,downloadUrl:l,showHeader:x=!0}){const{isImage:m,isVideo:S,isAudio:N}=Ur(s),h=x!==!1,T=!!(l&&n),_=()=>T?e.createElement("a",{className:Ie.downloadLink,href:l,download:n},"Download"):null,k=()=>m?e.createElement("img",{className:Ie.imagePreview,src:d,alt:n||"Preview"}):S?e.createElement("video",{className:Ie.videoPreview,controls:!0,preload:"metadata"},e.createElement("source",{src:d,type:s}),"Your browser does not support the video tag."):N?e.createElement("audio",{className:Ie.audioPreview,controls:!0},e.createElement("source",{src:d,type:s}),"Your browser does not support the audio tag."):e.createElement("div",{className:Ie.unsupportedMessage},e.createElement("p",null,"Preview unavailable for this file type."),T?e.createElement("p",null,_()):e.createElement("p",null,"Download the file to inspect its contents."));return e.createElement("div",{className:Ie.container},h&&e.createElement("div",{className:Ie.header},e.createElement("span",{className:Ie.filename,title:n},n),_()),e.createElement("div",{className:Ie.previewArea},k()),!h&&T&&e.createElement("div",{className:Ie.actions},_()))}const kt=new Map,qr=async n=>{var x;if(!n)return nt.php();const s=(x=n.split(".").pop())==null?void 0:x.toLowerCase();if(!s||s==="php")return nt.php();const d=n;if(kt.has(d))return kt.get(d);let l;switch(s){case"css":l=await import("@codemirror/lang-css").then(m=>m.css());break;case"js":case"jsx":case"ts":case"tsx":l=await import("@codemirror/lang-javascript").then(m=>m.javascript({jsx:s==="jsx"||s==="tsx",typescript:s==="ts"||s==="tsx"}));break;case"json":l=await import("@codemirror/lang-json").then(m=>m.json());break;case"html":case"htm":l=await import("@codemirror/lang-html").then(m=>m.html());break;case"md":case"markdown":l=await import("@codemirror/lang-markdown").then(m=>m.markdown());break;default:l=nt.php()}return kt.set(d,l),l};class Gr{constructor(s){this.view=s,this.handleClick=this.handleClick.bind(this),this.view.dom.addEventListener("mousedown",this.handleClick)}handleClick(s){const d=s.target;if((d.classList.contains("cm-scroller")||d.classList.contains("cm-content"))&&this.view.posAtCoords({x:s.clientX,y:s.clientY})===null){const x=this.view.state.doc.length,m=Me.EditorSelection.create([Me.EditorSelection.range(x,x)]);this.view.dispatch({selection:m,effects:be.EditorView.scrollIntoView(x,{y:"center"})}),this.view.focus(),s.preventDefault()}}destroy(){this.view.dom.removeEventListener("mousedown",this.handleClick)}}const Yr=be.ViewPlugin.define(n=>new Gr(n)),At=e.forwardRef(function({code:s,onChange:d,currentPath:l,className:x,onSaveShortcut:m,readOnly:S=!1,additionalExtensions:N},h){const T=e.useRef(null),_=e.useRef(null),k=e.useRef(new Me.Compartment),P=e.useRef(new Me.Compartment),$=e.useRef(new Me.Compartment),F=e.useRef(s),D=e.useRef(d),le=e.useRef(!1);return e.useImperativeHandle(h,()=>({focus:()=>{var v;(v=_.current)==null||v.focus()},blur:()=>{const v=_.current;v&&v.contentDOM.blur()},getCursorPosition:()=>_.current?_.current.state.selection.main.anchor:null,setCursorPosition:v=>{if(!_.current)return;const C=Math.min(v,_.current.state.doc.length),Y=Me.EditorSelection.create([Me.EditorSelection.range(C,C)]);_.current.dispatch({selection:Y,scrollIntoView:!0})}})),e.useEffect(()=>{F.current=s},[s]),e.useEffect(()=>{D.current=d},[d]),e.useEffect(()=>{if(_.current)return;const v=T.current;if(!v)return;const C=Me.EditorState.create({doc:s,extensions:[$.current.of(N??[]),be.lineNumbers(),be.highlightActiveLineGutter(),be.highlightActiveLine(),Ge.foldGutter(),be.dropCursor(),be.rectangularSelection(),be.crosshairCursor(),Yr,k.current.of(nt.php()),P.current.of(be.EditorView.editable.of(!S)),Ge.syntaxHighlighting(Ge.defaultHighlightStyle),Ge.indentOnInput(),Ge.bracketMatching(),mt.closeBrackets(),dt.history(),It.highlightSelectionMatches(),mt.autocompletion(),be.EditorView.updateListener.of(ee=>{if(!ee.docChanged)return;const Z=ee.state.doc.toString();Z!==F.current&&(F.current=Z,D.current(Z))}),be.keymap.of([{key:"Mod-s",preventDefault:!0,run:()=>(m==null||m(),!0)},...mt.closeBracketsKeymap,...mt.completionKeymap,...Ge.foldKeymap,...It.searchKeymap,...dt.historyKeymap,...dt.defaultKeymap,dt.indentWithTab])]}),Y=new be.EditorView({state:C,parent:v});return _.current=Y,()=>{Y.destroy(),_.current=null}},[]),e.useEffect(()=>{const v=_.current;v&&v.dispatch({effects:$.current.reconfigure(N??[])})},[N]),e.useEffect(()=>{const v=_.current;if(!v)return;const C=v.state.doc.toString();s!==C&&v.dispatch({changes:{from:0,to:v.state.doc.length,insert:s}})},[s]),e.useEffect(()=>{var Z;const v=_.current;if(!v)return;const C=(Z=l==null?void 0:l.split(".").pop())==null?void 0:Z.toLowerCase();(!C||C==="php")&&v.dispatch({effects:k.current.reconfigure(nt.php())});let ee=!1;return qr(l).then(y=>{ee||!_.current||_.current.dispatch({effects:k.current.reconfigure(y)})}),()=>{ee=!0}},[l]),e.useEffect(()=>{const v=_.current;v&&(v.hasFocus&&(le.current=!0),v.dispatch({effects:P.current.reconfigure(be.EditorView.editable.of(!S))}))},[S]),e.useLayoutEffect(()=>{const v=_.current;v&&le.current&&!v.hasFocus&&(v.focus(),le.current=!1)},[l,S]),e.createElement("div",{ref:T,className:x})});At.displayName="CodeEditor";const Zr="_fileExplorerContainer_8eol9_1",Kr="_dropActive_8eol9_9",Jr="_fileExplorerHeader_8eol9_14",Xr="_fileExplorerTitle_8eol9_23",Qr="_fileExplorerActions_8eol9_31",en="_fileExplorerButton_8eol9_37",tn="_fileExplorerIconButton_8eol9_67",rn="_fileExplorerTree_8eol9_79",nn="_dockPresentation_8eol9_88",an="_fileExplorerUploadButton_8eol9_148",we={fileExplorerContainer:Zr,dropActive:Kr,fileExplorerHeader:Jr,fileExplorerTitle:Xr,fileExplorerActions:Qr,fileExplorerButton:en,fileExplorerIconButton:tn,fileExplorerTree:rn,dockPresentation:nn,fileExplorerUploadButton:an},Nt=1024*1024,zt=n=>{const s=n.byteLength;for(let d=0;d<Math.min(s,4096);d++)if(n[d]===0)return!0;try{return new TextDecoder("utf-8",{fatal:!0}).decode(n),!1}catch{return!0}},Dt=(n,s)=>{const d=new Blob([n]),l=URL.createObjectURL(d);return setTimeout(()=>URL.revokeObjectURL(l),6e4),{url:l,filename:s}};async function on(n,s=Nt){const d=sn(n);if(d!==void 0&&d>s)return{type:"too-large"};if(typeof n.stream=="function")return ln(n,s);const l=new Uint8Array(await n.arrayBuffer());return l.byteLength>s?{type:"too-large"}:{type:"inline",data:l}}function sn(n){if(typeof n.filesize=="number")return n.filesize;if(typeof n.size=="number")return n.size}async function ln(n,s){const d=n.stream().getReader(),l=[];let x=0;try{for(;;){const{done:m,value:S}=await d.read();if(m)return{type:"inline",data:G.concatUint8Arrays(l)};if(S){if(x+=S.byteLength,x>s)return await d.cancel().catch(()=>{}),{type:"too-large"};l.push(S)}}}finally{d.releaseLock()}}const qt=n=>{const s=n.split(".").pop();return Mt[s]||Mt._default},Gt=n=>n.startsWith("image/")||n.startsWith("video/")||n.startsWith("audio/");function Yt({filesystem:n,currentPath:s,selectedDirPath:d,setSelectedDirPath:l,onFileOpened:x,onSelectionCleared:m,onShowMessage:S,documentRoot:N,readOnly:h=!1,title:T="Files",showBinaryPreviewHeader:_=!0,dockPresentation:k=!1,useWordPressTooltips:P=!1}){const $=e.useRef(null),F=e.useRef(null),D=e.useMemo(()=>s?G.dirname(s):d??N,[s,N]),[le,v]=e.useState(!1);e.useEffect(()=>{!s||!$.current||(l(G.dirname(s)),$.current.focusPath(s,{select:!0,domFocus:!1,notify:!1}),$.current.expandToPath(s))},[s,l]);const C=async(y,j)=>{try{const I=await n.read(y),V=await on(I);if(V.type==="too-large"){const A=Nt/1024/1024;if(!k){await S(y,e.createElement(e.Fragment,null,e.createElement("p",null,`File too large to open (>${A}MB).`),e.createElement("p",null,"Open or download it outside the in-browser editor.")));return}const K=G.basename(y)||"download";await S(y,e.createElement(e.Fragment,null,e.createElement("p",null,`File too large to open (>${A}MB).`),e.createElement("p",null,e.createElement(X.Button,{type:"button",variant:"link",onClick:()=>{Y(y,K)}},"Download ",K))));return}const g=V.data,M=G.basename(y)||"download";if(zt(g)){const A=qt(M),{url:K,filename:ue}=Dt(g,M);if(Gt(A)){const J=new Blob([g],{type:A}),ie=URL.createObjectURL(J);await S(y,e.createElement(Lt.BinaryFilePreview,{filename:ue,mimeType:A,dataUrl:ie,downloadUrl:K,showHeader:_}));return}await S(y,e.createElement(e.Fragment,null,e.createElement("p",null,"Binary file. Cannot be edited."),e.createElement("p",null,e.createElement("a",{href:K,download:ue},"Download ",ue))));return}const de=new TextDecoder("utf-8").decode(g);await x(y,de,j)}catch(I){Ye.logger.error("Could not open file",I),await S(null,"Could not open file.")}},Y=async(y,j)=>{try{const I=await n.read(y),V=new Uint8Array(await I.arrayBuffer()),{url:g}=Dt(V,j),M=document.createElement("a");M.href=g,M.download=j,document.body.appendChild(M),M.click(),document.body.removeChild(M)}catch(I){Ye.logger.error("Could not download file",I),await S(y,"Could not download file.")}},ee=y=>{var I;const j=Array.from(y.target.files??[]);y.target.value="",j.length!==0&&((I=$.current)==null||I.importFiles(j,d??N).catch(V=>Ye.logger.error("Failed to import files",V)))},Z=y=>{var j;y.dataTransfer.types.includes("application/x-wp-playground-path")||(y.preventDefault(),!h&&((j=$.current)==null||j.importDataTransfer(y.dataTransfer,d??N).catch(I=>Ye.logger.error("Failed to import dropped files",I))))};return e.createElement("div",{className:Ne(we.fileExplorerContainer,{[we.dropActive]:le,[we.dockPresentation]:k}),onDragEnter:y=>{y.dataTransfer.types.includes("application/x-wp-playground-path")||(y.preventDefault(),h||v(!0))},onDragOver:y=>{y.dataTransfer.types.includes("application/x-wp-playground-path")||(y.preventDefault(),y.dataTransfer.dropEffect=h?"none":"copy")},onDragLeave:y=>{const j=y.relatedTarget;(!j||!y.currentTarget.contains(j))&&v(!1)},onDropCapture:()=>v(!1),onDrop:Z},e.createElement("div",{className:we.fileExplorerHeader},e.createElement("span",{className:we.fileExplorerTitle},T),h?null:e.createElement("div",{className:we.fileExplorerActions},e.createElement(Tt,{label:"Create new file",useWordPressTooltip:P},e.createElement("button",{className:Ne(we.fileExplorerButton,we.fileExplorerIconButton),type:"button",onClick:()=>{$.current&&$.current.createFile()},"aria-label":"Create new file",title:P?void 0:"Create new file"},k?e.createElement(cn,null):e.createElement(X.Icon,{icon:vr,size:20}))),e.createElement(Tt,{label:"Create new folder",useWordPressTooltip:P},e.createElement("button",{className:Ne(we.fileExplorerButton,we.fileExplorerIconButton),type:"button",onClick:()=>{$.current&&$.current.createFolder()},"aria-label":"Create new folder",title:P?void 0:"Create new folder"},k?e.createElement(un,null):e.createElement(X.Icon,{icon:hr,size:20}))),e.createElement(Tt,{label:"Upload files",useWordPressTooltip:P},e.createElement("button",{className:Ne(we.fileExplorerButton,we.fileExplorerIconButton,we.fileExplorerUploadButton),type:"button",onClick:()=>{var y;return(y=F.current)==null?void 0:y.click()},"aria-label":"Upload files",title:P?void 0:"Upload files"},e.createElement(X.Icon,{icon:wr,size:k?16:20}))),e.createElement("input",{ref:F,type:"file",multiple:!0,style:{display:"none"},onChange:ee}))),e.createElement("div",{className:we.fileExplorerTree},e.createElement(Lt.FilePickerTree,{ref:$,readOnly:h,filesystem:n,root:N,initialSelectedPath:D,onSelect:async y=>{if(!y){l(N),await m();return}try{if(await n.isDir(y)){l(y);return}}catch{}l(G.dirname(y)),await C(y,!1)},onDoubleClickFile:async y=>{await C(y,!0)}})))}function Tt({label:n,useWordPressTooltip:s,children:d}){return s?e.createElement(X.Tooltip,{text:n,delay:0,placement:"top"},d):d}const cn=()=>e.createElement("svg",{viewBox:"0 0 32 32",width:"24",height:"24","aria-hidden":"true"},e.createElement("path",{d:"M11 6h7l5 5v12a2 2 0 0 1-2 2H11a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2z",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round"}),e.createElement("path",{d:"M18 6v5h5",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round"}),e.createElement("g",{transform:"translate(19 19)"},e.createElement("circle",{cx:"5",cy:"5",r:"8",fill:"var(--paper-2, #fff)"}),e.createElement("path",{d:"M5 1.5v7M1.5 5h7",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}))),un=()=>e.createElement("svg",{viewBox:"0 0 32 32",width:"24",height:"24","aria-hidden":"true"},e.createElement("path",{d:"M6 9h7l3 3h10v11a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2V9z",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round"}),e.createElement("path",{d:"M6 9V8a2 2 0 0 1 2-2h5l3 3",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round"}),e.createElement("g",{transform:"translate(19 19)"},e.createElement("circle",{cx:"5",cy:"5",r:"8",fill:"var(--paper-2, #fff)"}),e.createElement("path",{d:"M5 1.5v7M1.5 5h7",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}))),fn="_container_xer29_1",dn="_content_xer29_9",mn="_sidebarWrapper_xer29_17",pn="_editorWrapper_xer29_28",hn="_editorHeader_xer29_37",vn="_editorPath_xer29_49",wn="_editorPathPlaceholder_xer29_60",gn="_editorHeaderActions_xer29_64",En="_saveStatus_xer29_71",yn="_saveStatusSaving_xer29_78",_n="_saveStatusPending_xer29_79",bn="_saveStatusError_xer29_83",xn="_editor_xer29_28",Cn="_placeholder_xer29_105",Rn="_messageArea_xer29_116",Sn="_mobileToggle_xer29_152",kn="_mobileOverlay_xer29_156",Tn="_dockPresentation_xer29_162",Pn="_dockDirtyIndicator_xer29_186",Dn="_dockSaveButton_xer29_195",An="_sidebarOpen_xer29_250",ne={container:fn,content:dn,sidebarWrapper:mn,editorWrapper:pn,editorHeader:hn,editorPath:vn,editorPathPlaceholder:wn,editorHeaderActions:gn,saveStatus:En,saveStatusSaving:yn,saveStatusPending:_n,saveStatusError:bn,editor:xn,placeholder:Cn,messageArea:Rn,mobileToggle:Sn,mobileOverlay:kn,dockPresentation:Tn,dockDirtyIndicator:Pn,dockSaveButton:Dn,sidebarOpen:An},Nn=1500,Fn=700,In=1e3,B={IDLE:"idle",PENDING:"pending",SAVING:"saving",SAVED:"saved",ERROR:"error"};function Ln({filesystem:n,isVisible:s=!0,documentRoot:d,initialPath:l=null,placeholderText:x="Select a file to view or edit its contents.",dockPresentation:m=!1}){const[S,N]=e.useState(d),[h,T]=e.useState(null),[_,k]=e.useState(""),[P,$]=e.useState(!0),[F,D]=e.useState(B.IDLE),[le,v]=e.useState(null),[C,Y]=e.useState("idle"),[ee,Z]=e.useState(!1),[y,j]=e.useState(null),I=e.useRef(null),V=e.useRef(null),g=e.useRef(!1),M=e.useRef(h),de=e.useRef(n),A=e.useRef(null),K=e.useRef(null),ue=e.useRef(new WeakMap),J=e.useRef(!0),ie=e.useRef(new Map),Te=e.useRef(!1);de.current=n,e.useEffect(()=>{M.current=h},[h]);const xe=e.useCallback(async u=>{const{filesystem:b,path:H,content:U}=u,Q=K.current===u,fe=ue.current,_e=(fe.get(b)??Promise.resolve()).catch(()=>{}).then(()=>b.writeFile(H,U));fe.set(b,_e);let pe=!1;try{await _e}catch(Xe){pe=!0,Ye.logger.error("Failed to save file",Xe)}const Be=J.current&&fe.get(b)===_e&&de.current===b&&M.current===H&&A.current===null;fe.get(b)===_e&&fe.delete(b),K.current===u&&(K.current=null),Be&&(D(pe?B.ERROR:B.SAVED),v(pe?"Could not save changes. Try again.":null),Q&&Y(pe?"idle":"saved"))},[]),Ce=e.useCallback(()=>{const u=A.current;u&&(V.current!==null&&(window.clearTimeout(V.current),V.current=null),A.current=null,xe(u))},[xe]);e.useEffect(()=>(J.current=!0,()=>{J.current=!1}),[]),e.useEffect(()=>()=>{var u;((u=A.current)==null?void 0:u.filesystem)===n&&Ce()},[d,n,Ce]),e.useEffect(()=>{g.current=!0,N(d),k(""),T(null),$(!0),D(B.IDLE),v(null),Z(!1),j(null),ie.current.clear(),Te.current=!1},[d,n]),e.useEffect(()=>{if(!n||!l||Te.current)return;let u=!1;return(async()=>{try{if(await n.fileExists(l)&&!u){const U=await n.readFileAsText(l);if(u)return;g.current=!0,T(l),k(U),$(!1),D(B.IDLE),v(null),setTimeout(()=>{var Q;(Q=I.current)==null||Q.focus()},100)}}catch(H){Ye.logger.debug("Could not auto-open initial path:",H)}finally{u||(Te.current=!0)}})(),()=>{u=!0}},[n,l]),e.useEffect(()=>{if(!n||!h){V.current!==null&&(window.clearTimeout(V.current),V.current=null),A.current=null,h||D(B.IDLE);return}if(g.current){g.current=!1,A.current=null;return}V.current!==null&&(window.clearTimeout(V.current),V.current=null),D(B.PENDING);const u={filesystem:n,path:h,content:_};A.current=u;const b=window.setTimeout(()=>{A.current===u&&(V.current=null,A.current=null,D(B.SAVING),xe(u))},Nn);return V.current=b,()=>{V.current===b&&(window.clearTimeout(b),V.current=null)}},[_,h,n,xe]),e.useEffect(()=>{if(F!==B.SAVED)return;const u=window.setTimeout(()=>{D(b=>b===B.SAVED?B.IDLE:b)},2e3);return()=>window.clearTimeout(u)},[F]),e.useEffect(()=>{C==="idle"||F===B.SAVING||F===B.SAVED||Y("idle")},[C,F]),e.useEffect(()=>{if(C!=="saved")return;const u=window.setTimeout(()=>Y("idle"),In);return()=>window.clearTimeout(u)},[C]),e.useEffect(()=>{if(C!=="waiting")return;const u=window.setTimeout(()=>Y(b=>b==="waiting"?"saving":b),Fn);return()=>window.clearTimeout(u)},[C]);const ce=e.useCallback(async(u,b,H=!0)=>{var Q;const U=(Q=I.current)==null?void 0:Q.getCursorPosition();U!=null&&M.current&&ie.current.set(M.current,U),g.current=!0,T(u),k(b),j(null),$(!1),D(B.IDLE),v(null),Z(!1),setTimeout(()=>{var Ae,_e,pe;const fe=ie.current.get(u);fe!==void 0&&((Ae=I.current)==null||Ae.setCursorPosition(fe)),H?(_e=I.current)==null||_e.focus():(pe=I.current)==null||pe.blur()},50)},[]);e.useEffect(()=>{var H;if(!h)return;const u=setInterval(()=>{var Q;const U=(Q=I.current)==null?void 0:Q.getCursorPosition();U!=null&&ie.current.set(h,U)},1e3),b=(H=I.current)==null?void 0:H.getCursorPosition();return b!=null&&ie.current.set(h,b),()=>{var Q;clearInterval(u);const U=(Q=I.current)==null?void 0:Q.getCursorPosition();U!=null&&ie.current.set(h,U)}},[h]),e.useEffect(()=>{if(!s||!h)return;const u=setTimeout(()=>{var H;const b=ie.current.get(h);b!==void 0&&((H=I.current)==null||H.setCursorPosition(b))},100);return()=>clearTimeout(u)},[s,h]);const Fe=e.useCallback(async()=>{var b;const u=(b=I.current)==null?void 0:b.getCursorPosition();u!=null&&M.current&&ie.current.set(M.current,u),g.current=!0,T(null),k(""),j(null),$(!0),D(B.IDLE),v(null)},[]),te=e.useCallback(async(u,b)=>{g.current=!0,T(null),typeof b=="string"?(k(b),j(null)):(k(""),j(b)),$(!0),D(B.IDLE),v(null),Z(!1)},[]),Pe=e.useCallback(()=>{A.current&&(K.current=A.current,Y("waiting"),D(B.SAVING),Ce())},[Ce]),Re=e.useCallback(()=>{!A.current&&F===B.ERROR&&n&&h&&(A.current={filesystem:n,path:h,content:_}),A.current&&(v(null),Pe())},[_,h,n,Pe,F]),Ee=Mn(F,le),De=Bn(F,ne),ye=jn(F);let ae="Save";F===B.ERROR?ae="Retry":F===B.SAVED&&C==="saved"?ae="Saved":F===B.SAVING&&C==="saving"&&(ae="Saving…");const z=F===B.PENDING||F===B.SAVING||F===B.ERROR;return n?e.createElement("div",{className:Ne(ne.container,{[ne.dockPresentation]:m})},e.createElement("div",{className:Ne(ne.content,{[ne.sidebarOpen]:ee})},e.createElement("div",{className:ne.mobileOverlay,onClick:()=>Z(!1)}),e.createElement("aside",{className:ne.sidebarWrapper},e.createElement(Yt,{filesystem:n,currentPath:h,selectedDirPath:S,setSelectedDirPath:N,onFileOpened:ce,onSelectionCleared:Fe,onShowMessage:te,documentRoot:d,dockPresentation:m,useWordPressTooltips:m})),e.createElement("section",{className:ne.editorWrapper},e.createElement("div",{className:ne.editorHeader},e.createElement(X.Button,{className:ne.mobileToggle,variant:"secondary",onClick:()=>Z(u=>!u)},ee?"Hide files":"Browse files"),e.createElement("div",{className:Ne(ne.editorPath,{[ne.editorPathPlaceholder]:!(h!=null&&h.length)}),title:h??void 0},h!=null&&h.length?h:`Browse files under ${d}`),m&&!P&&h?e.createElement("div",{className:ne.editorHeaderActions},z?e.createElement("span",{className:ne.dockDirtyIndicator,"aria-hidden":"true"}):null,e.createElement(X.Tooltip,{text:ye,placement:"top"},e.createElement(X.Button,{variant:"secondary",className:ne.dockSaveButton,isDestructive:F===B.ERROR,onClick:Re},ae))):m?null:e.createElement("div",{className:Ne(ne.saveStatus,De)},Ee),m&&!P&&h?e.createElement(X.VisuallyHidden,{role:"status","aria-live":"polite"},ye):null),le?e.createElement("div",{style:{padding:"8px 16px"}},e.createElement(X.Notice,{status:"error",isDismissible:!1},le)):null,h||_||y?y?e.createElement("div",{className:ne.messageArea},y):e.createElement(At,{ref:I,code:_,onChange:k,currentPath:h,className:ne.editor,onSaveShortcut:Pe,readOnly:P}):e.createElement("div",{className:ne.placeholder},x)))):e.createElement("div",{className:Ne(ne.container,{[ne.dockPresentation]:m})},e.createElement("div",{className:ne.placeholder},x))}function Mn(n,s){switch(n){case B.PENDING:case B.SAVING:return"Saving…";case B.SAVED:return"Saved";case B.ERROR:return s??"Save failed";default:return""}}function Bn(n,s){switch(n){case B.PENDING:return s.saveStatusPending;case B.SAVING:return s.saveStatusSaving;case B.ERROR:return s.saveStatusError;default:return}}function jn(n){switch(n){case B.PENDING:return"Unsaved changes. Click to save now.";case B.SAVING:return"Saving changes…";case B.ERROR:return"Saving failed. Click to retry.";default:return"All changes saved."}}exports.BinaryFilePreview=zr;exports.ClockIcon=sr;exports.CodeEditor=At;exports.FileExplorerSidebar=Yt;exports.FilePickerControl=Fr;exports.FilePickerTree=Ht;exports.MAX_INLINE_FILE_BYTES=Nt;exports.PlaygroundFileEditor=Ln;exports.SiteManagerIcon=ur;exports.WordPressIcon=ir;exports.createDownloadUrl=Dt;exports.file=Wt;exports.folder=$t;exports.getLogoDataURL=cr;exports.getMimeType=qt;exports.isPreviewableBinary=Gt;exports.layout=lr;exports.playgroundLogo=ar;exports.seemsLikeBinary=zt;exports.temporaryStorage=or;
31
31
  //# sourceMappingURL=index.cjs.map