@wp-playground/components 3.0.22 → 3.0.32

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.
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ export type BinaryFilePreviewProps = {
3
+ filename: string;
4
+ mimeType: string;
5
+ dataUrl: string;
6
+ downloadUrl?: string | null;
7
+ showHeader?: boolean;
8
+ };
9
+ export declare function BinaryFilePreview({ filename, mimeType, dataUrl, downloadUrl, showHeader, }: BinaryFilePreviewProps): React.JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import type { AsyncWritableFilesystem } from '../FilePickerTree';
2
+ import type { AsyncWritableFilesystem } from '../../../storage/src/index.ts';
3
3
  export declare function FilePickerControl({ value, onChange, filesystem, }: {
4
4
  value?: string;
5
5
  onChange: (selectedPath: string) => void;
@@ -1,24 +1,12 @@
1
+ import type { AsyncWritableFilesystem } from '../../../storage/src/index.ts';
1
2
  import React from 'react';
2
- export interface AsyncWritableFilesystem {
3
- isDir: (path: string) => Promise<boolean>;
4
- fileExists: (path: string) => Promise<boolean>;
5
- readFileAsBuffer: (path: string) => Promise<Uint8Array>;
6
- readFileAsText: (path: string) => Promise<string>;
7
- listFiles: (path: string) => Promise<string[]>;
8
- writeFile: (path: string, data: Uint8Array | string) => Promise<void>;
9
- mkdir: (path: string) => Promise<void>;
10
- rmdir: (path: string, options?: {
11
- recursive?: boolean;
12
- }) => Promise<void>;
13
- mv: (source: string, destination: string) => Promise<void>;
14
- unlink: (path: string) => Promise<void>;
15
- }
16
3
  export type FileNode = {
17
4
  name: string;
18
5
  type: 'file' | 'folder';
19
6
  children?: FileNode[];
20
7
  };
21
8
  export type FilePickerTreeProps = {
9
+ withContextMenu?: boolean;
22
10
  filesystem: AsyncWritableFilesystem;
23
11
  root?: string;
24
12
  initialSelectedPath?: string;
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import type { Extension } from '@codemirror/state';
3
+ export type CodeEditorHandle = {
4
+ focus: () => void;
5
+ blur: () => void;
6
+ getCursorPosition: () => number | null;
7
+ setCursorPosition: (pos: number) => void;
8
+ };
9
+ export type CodeEditorProps = {
10
+ code: string;
11
+ onChange: (next: string) => void;
12
+ currentPath: string | null;
13
+ className?: string;
14
+ onSaveShortcut?: () => void;
15
+ readOnly?: boolean;
16
+ additionalExtensions?: Extension[];
17
+ };
18
+ export declare const CodeEditor: React.ForwardRefExoticComponent<CodeEditorProps & React.RefAttributes<CodeEditorHandle>>;
@@ -0,0 +1,13 @@
1
+ import React, { type Dispatch, type SetStateAction } from 'react';
2
+ import type { AsyncWritableFilesystem } from '../../../storage/src/index.ts';
3
+ export type FileExplorerSidebarProps = {
4
+ filesystem: AsyncWritableFilesystem;
5
+ currentPath: string | null;
6
+ selectedDirPath: string | null;
7
+ setSelectedDirPath: Dispatch<SetStateAction<string | null>>;
8
+ onFileOpened: (path: string, content: string, shouldFocus?: boolean) => Promise<void> | void;
9
+ onSelectionCleared: () => Promise<void> | void;
10
+ onShowMessage: (path: string | null, message: string | JSX.Element) => Promise<void> | void;
11
+ documentRoot: string;
12
+ };
13
+ export declare function FileExplorerSidebar({ filesystem, currentPath, selectedDirPath, setSelectedDirPath, onFileOpened, onSelectionCleared, onShowMessage, documentRoot, }: FileExplorerSidebarProps): React.JSX.Element;
@@ -0,0 +1,23 @@
1
+ export declare const MAX_INLINE_FILE_BYTES: number;
2
+ /**
3
+ * Checks if a buffer seems to contain binary data by looking for null bytes
4
+ * in the first 4096 bytes and attempting to decode as UTF-8.
5
+ */
6
+ export declare const seemsLikeBinary: (buffer: Uint8Array) => boolean;
7
+ /**
8
+ * Creates a download URL for a file and returns both the URL and filename.
9
+ * The URL is automatically revoked after 60 seconds.
10
+ */
11
+ export declare const createDownloadUrl: (data: Uint8Array, filename: string) => {
12
+ url: string;
13
+ filename: string;
14
+ };
15
+ /**
16
+ * Gets the MIME type for a filename based on its extension.
17
+ */
18
+ export declare const getMimeType: (filename: string) => string;
19
+ /**
20
+ * Checks if a MIME type represents a binary file that can be previewed
21
+ * (images, videos, audio).
22
+ */
23
+ export declare const isPreviewableBinary: (mimeType: string) => boolean;
@@ -0,0 +1,4 @@
1
+ export { CodeEditor, type CodeEditorHandle, type CodeEditorProps, } from './code-editor';
2
+ export { FileExplorerSidebar, type FileExplorerSidebarProps, } from './file-explorer-sidebar';
3
+ export { PlaygroundFileEditor, type PlaygroundFileEditorProps, } from './playground-file-editor';
4
+ export { MAX_INLINE_FILE_BYTES, seemsLikeBinary, createDownloadUrl, getMimeType, isPreviewableBinary, } from './file-utils';
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import type { AsyncWritableFilesystem } from '../../../storage/src/index.ts';
3
+ export type PlaygroundFileEditorProps = {
4
+ filesystem: AsyncWritableFilesystem | null;
5
+ isVisible?: boolean;
6
+ documentRoot: string;
7
+ initialPath?: string | null;
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>;
15
+ };
16
+ /**
17
+ * A reusable file browser component with a file tree on the left and
18
+ * a code editor on the right. Supports auto-save with debouncing,
19
+ * cursor position preservation, and binary file handling.
20
+ */
21
+ export declare function PlaygroundFileEditor({ filesystem, isVisible, documentRoot, initialPath, placeholderText, onSaveFile, onBeforeFilesystemChange, }: PlaygroundFileEditorProps): React.JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import type { AsyncWritableFilesystem } from '../FilePickerTree';
2
+ import type { AsyncWritableFilesystem } from '../../../storage/src/index.ts';
3
3
  declare global {
4
4
  interface Window {
5
5
  __filePickerHarness?: {
package/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react"),ie=require("@wordpress/components"),mt=require("classnames"),X=require("@php-wasm/util"),Xe=require("@wordpress/element"),Tt=require("clsx"),Pt=l=>i.createElement("svg",{width:"32",height:"32",viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",...l},i.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"}),i.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"}),i.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"})),kt=l=>i.createElement("svg",{width:"16",height:"17",viewBox:"0 0 16 17",fill:"none",xmlns:"http://www.w3.org/2000/svg",...l},i.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"})),St=l=>i.createElement("svg",{width:"20",height:"21",viewBox:"0 0 20 21",fill:"none",xmlns:"http://www.w3.org/2000/svg",...l},i.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"})),yt=i.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"15",height:"14",viewBox:"0 0 15 14",fill:"none"},i.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"})),vt=i.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"},i.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"})),Ot=l=>i.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 14 14",fill:"none",...l},i.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"})),jt=i.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 14 14",fill:"none"},i.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 Dt(l){return`data:${l.mime};base64,${l.data}`}function Ft({size:l=24,sidebarActive:c=!1}){return i.createElement("svg",{width:l,height:l,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},i.createElement("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),c?i.createElement("rect",{x:"3",y:"3",width:"7",height:"18",rx:"2",ry:"2",fill:"currentColor"}):i.createElement("rect",{x:"3",y:"3",width:"8",height:"18",rx:"2",ry:"2",fill:"none",stroke:"currentColor",strokeWidth:"2"}))}const ht=Xe.forwardRef(({icon:l,size:c=24,...E},g)=>Xe.cloneElement(l,{width:c,height:c,...E,ref:g}));var ft={exports:{}},We={};/**
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={};/**
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 pt;function At(){if(pt)return We;pt=1;var l=i,c=Symbol.for("react.element"),E=Symbol.for("react.fragment"),g=Object.prototype.hasOwnProperty,P=l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,R={key:!0,ref:!0,__self:!0,__source:!0};function M(k,S,I){var _,x={},L=null,ee=null;I!==void 0&&(L=""+I),S.key!==void 0&&(L=""+S.key),S.ref!==void 0&&(ee=S.ref);for(_ in S)g.call(S,_)&&!R.hasOwnProperty(_)&&(x[_]=S[_]);if(k&&k.defaultProps)for(_ in S=k.defaultProps,S)x[_]===void 0&&(x[_]=S[_]);return{$$typeof:c,type:k,key:L,ref:ee,props:x,_owner:P.current}}return We.Fragment=E,We.jsx=M,We.jsxs=M,We}var Be={};/**
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={};/**
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 wt;function $t(){return wt||(wt=1,process.env.NODE_ENV!=="production"&&function(){var l=i,c=Symbol.for("react.element"),E=Symbol.for("react.portal"),g=Symbol.for("react.fragment"),P=Symbol.for("react.strict_mode"),R=Symbol.for("react.profiler"),M=Symbol.for("react.provider"),k=Symbol.for("react.context"),S=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),_=Symbol.for("react.suspense_list"),x=Symbol.for("react.memo"),L=Symbol.for("react.lazy"),ee=Symbol.for("react.offscreen"),$=Symbol.iterator,U="@@iterator";function he(e){if(e===null||typeof e!="object")return null;var s=$&&e[$]||e[U];return typeof s=="function"?s:null}var D=l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function T(e){{for(var s=arguments.length,u=new Array(s>1?s-1:0),w=1;w<s;w++)u[w-1]=arguments[w];ue("error",e,u)}}function ue(e,s,u){{var w=D.ReactDebugCurrentFrame,b=w.getStackAddendum();b!==""&&(s+="%s",u=u.concat([b]));var C=u.map(function(v){return String(v)});C.unshift("Warning: "+s),Function.prototype.apply.call(console[e],console,C)}}var pe=!1,ye=!1,Z=!1,B=!1,ve=!1,te;te=Symbol.for("react.module.reference");function m(e){return!!(typeof e=="string"||typeof e=="function"||e===g||e===R||ve||e===P||e===I||e===_||B||e===ee||pe||ye||Z||typeof e=="object"&&e!==null&&(e.$$typeof===L||e.$$typeof===x||e.$$typeof===M||e.$$typeof===k||e.$$typeof===S||e.$$typeof===te||e.getModuleId!==void 0))}function H(e,s,u){var w=e.displayName;if(w)return w;var b=s.displayName||s.name||"";return b!==""?u+"("+b+")":u}function oe(e){return e.displayName||"Context"}function Y(e){if(e==null)return null;if(typeof e.tag=="number"&&T("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 g:return"Fragment";case E:return"Portal";case R:return"Profiler";case P:return"StrictMode";case I:return"Suspense";case _:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case k:var s=e;return oe(s)+".Consumer";case M:var u=e;return oe(u._context)+".Provider";case S:return H(e,e.render,"ForwardRef");case x:var w=e.displayName||null;return w!==null?w:Y(e.type)||"Memo";case L:{var b=e,C=b._payload,v=b._init;try{return Y(v(C))}catch{return null}}}return null}var K=Object.assign,V=0,re,xe,Te,Ee,fe,G,q;function se(){}se.__reactDisabledLog=!0;function le(){{if(V===0){re=console.log,xe=console.info,Te=console.warn,Ee=console.error,fe=console.group,G=console.groupCollapsed,q=console.groupEnd;var e={configurable:!0,enumerable:!0,value:se,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}V++}}function _e(){{if(V--,V===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:K({},e,{value:re}),info:K({},e,{value:xe}),warn:K({},e,{value:Te}),error:K({},e,{value:Ee}),group:K({},e,{value:fe}),groupCollapsed:K({},e,{value:G}),groupEnd:K({},e,{value:q})})}V<0&&T("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var de=D.ReactCurrentDispatcher,we;function W(e,s,u){{if(we===void 0)try{throw Error()}catch(b){var w=b.stack.trim().match(/\n( *(at )?)/);we=w&&w[1]||""}return`
18
- `+we+e}}var j=!1,ne;{var d=typeof WeakMap=="function"?WeakMap:Map;ne=new d}function F(e,s){if(!e||j)return"";{var u=ne.get(e);if(u!==void 0)return u}var w;j=!0;var b=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var C;C=de.current,de.current=null,le();try{if(s){var v=function(){throw Error()};if(Object.defineProperty(v.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(v,[])}catch(J){w=J}Reflect.construct(e,[],v)}else{try{v.call()}catch(J){w=J}e.call(v.prototype)}}else{try{throw Error()}catch(J){w=J}e()}}catch(J){if(J&&w&&typeof J.stack=="string"){for(var y=J.stack.split(`
19
- `),z=w.stack.split(`
20
- `),A=y.length-1,N=z.length-1;A>=1&&N>=0&&y[A]!==z[N];)N--;for(;A>=1&&N>=0;A--,N--)if(y[A]!==z[N]){if(A!==1||N!==1)do if(A--,N--,N<0||y[A]!==z[N]){var ce=`
21
- `+y[A].replace(" at new "," at ");return e.displayName&&ce.includes("<anonymous>")&&(ce=ce.replace("<anonymous>",e.displayName)),typeof e=="function"&&ne.set(e,ce),ce}while(A>=1&&N>=0);break}}}finally{j=!1,de.current=C,_e(),Error.prepareStackTrace=b}var Fe=e?e.displayName||e.name:"",Oe=Fe?W(Fe):"";return typeof e=="function"&&ne.set(e,Oe),Oe}function ae(e,s,u){return F(e,!1)}function be(e){var s=e.prototype;return!!(s&&s.isReactComponent)}function Pe(e,s,u){if(e==null)return"";if(typeof e=="function")return F(e,be(e));if(typeof e=="string")return W(e);switch(e){case I:return W("Suspense");case _:return W("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case S:return ae(e.render);case x:return Pe(e.type,s,u);case L:{var w=e,b=w._payload,C=w._init;try{return Pe(C(b),s,u)}catch{}}}return""}var me=Object.prototype.hasOwnProperty,$e={},Ye=D.ReactDebugCurrentFrame;function Re(e){if(e){var s=e._owner,u=Pe(e.type,e._source,s?s.type:null);Ye.setExtraStackFrame(u)}else Ye.setExtraStackFrame(null)}function Qe(e,s,u,w,b){{var C=Function.call.bind(me);for(var v in e)if(C(e,v)){var y=void 0;try{if(typeof e[v]!="function"){var z=Error((w||"React class")+": "+u+" type `"+v+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[v]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw z.name="Invariant Violation",z}y=e[v](s,v,w,u,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(A){y=A}y&&!(y instanceof Error)&&(Re(b),T("%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).",w||"React class",u,v,typeof y),Re(null)),y instanceof Error&&!(y.message in $e)&&($e[y.message]=!0,Re(b),T("Failed %s type: %s",u,y.message),Re(null))}}}var Ne=Array.isArray;function Me(e){return Ne(e)}function et(e){{var s=typeof Symbol=="function"&&Symbol.toStringTag,u=s&&e[Symbol.toStringTag]||e.constructor.name||"Object";return u}}function tt(e){try{return qe(e),!1}catch{return!0}}function qe(e){return""+e}function ze(e){if(tt(e))return T("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",et(e)),qe(e)}var Ue=D.ReactCurrentOwner,rt={key:!0,ref:!0,__self:!0,__source:!0},ke,Se;function nt(e){if(me.call(e,"ref")){var s=Object.getOwnPropertyDescriptor(e,"ref").get;if(s&&s.isReactWarning)return!1}return e.ref!==void 0}function at(e){if(me.call(e,"key")){var s=Object.getOwnPropertyDescriptor(e,"key").get;if(s&&s.isReactWarning)return!1}return e.key!==void 0}function it(e,s){typeof e.ref=="string"&&Ue.current}function ot(e,s){{var u=function(){ke||(ke=!0,T("%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)",s))};u.isReactWarning=!0,Object.defineProperty(e,"key",{get:u,configurable:!0})}}function st(e,s){{var u=function(){Se||(Se=!0,T("%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)",s))};u.isReactWarning=!0,Object.defineProperty(e,"ref",{get:u,configurable:!0})}}var Ze=function(e,s,u,w,b,C,v){var y={$$typeof:c,type:e,key:s,ref:u,props:v,_owner:C};return y._store={},Object.defineProperty(y._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(y,"_self",{configurable:!1,enumerable:!1,writable:!1,value:w}),Object.defineProperty(y,"_source",{configurable:!1,enumerable:!1,writable:!1,value:b}),Object.freeze&&(Object.freeze(y.props),Object.freeze(y)),y};function Ke(e,s,u,w,b){{var C,v={},y=null,z=null;u!==void 0&&(ze(u),y=""+u),at(s)&&(ze(s.key),y=""+s.key),nt(s)&&(z=s.ref,it(s,b));for(C in s)me.call(s,C)&&!rt.hasOwnProperty(C)&&(v[C]=s[C]);if(e&&e.defaultProps){var A=e.defaultProps;for(C in A)v[C]===void 0&&(v[C]=A[C])}if(y||z){var N=typeof e=="function"?e.displayName||e.name||"Unknown":e;y&&ot(v,N),z&&st(v,N)}return Ze(e,y,z,b,w,Ue.current,v)}}var je=D.ReactCurrentOwner,Ge=D.ReactDebugCurrentFrame;function Ce(e){if(e){var s=e._owner,u=Pe(e.type,e._source,s?s.type:null);Ge.setExtraStackFrame(u)}else Ge.setExtraStackFrame(null)}var Ie;Ie=!1;function Le(e){return typeof e=="object"&&e!==null&&e.$$typeof===c}function Je(){{if(je.current){var e=Y(je.current.type);if(e)return`
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`
22
22
 
23
- Check the render method of \``+e+"`."}return""}}function t(e){return""}var r={};function n(e){{var s=Je();if(!s){var u=typeof e=="string"?e:e.displayName||e.name;u&&(s=`
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=`
24
24
 
25
- Check the top-level render call using <`+u+">.")}return s}}function o(e,s){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var u=n(s);if(r[u])return;r[u]=!0;var w="";e&&e._owner&&e._owner!==je.current&&(w=" It was passed a child from "+Y(e._owner.type)+"."),Ce(e),T('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',u,w),Ce(null)}}function a(e,s){{if(typeof e!="object")return;if(Me(e))for(var u=0;u<e.length;u++){var w=e[u];Le(w)&&o(w,s)}else if(Le(e))e._store&&(e._store.validated=!0);else if(e){var b=he(e);if(typeof b=="function"&&b!==e.entries)for(var C=b.call(e),v;!(v=C.next()).done;)Le(v.value)&&o(v.value,s)}}}function h(e){{var s=e.type;if(s==null||typeof s=="string")return;var u;if(typeof s=="function")u=s.propTypes;else if(typeof s=="object"&&(s.$$typeof===S||s.$$typeof===x))u=s.propTypes;else return;if(u){var w=Y(s);Qe(u,e.props,"prop",w,e)}else if(s.PropTypes!==void 0&&!Ie){Ie=!0;var b=Y(s);T("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",b||"Unknown")}typeof s.getDefaultProps=="function"&&!s.getDefaultProps.isReactClassApproved&&T("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function f(e){{for(var s=Object.keys(e.props),u=0;u<s.length;u++){var w=s[u];if(w!=="children"&&w!=="key"){Ce(e),T("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",w),Ce(null);break}}e.ref!==null&&(Ce(e),T("Invalid attribute `ref` supplied to `React.Fragment`."),Ce(null))}}var p={};function O(e,s,u,w,b,C){{var v=m(e);if(!v){var y="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(y+=" 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 z=t();z?y+=z:y+=Je();var A;e===null?A="null":Me(e)?A="array":e!==void 0&&e.$$typeof===c?(A="<"+(Y(e.type)||"Unknown")+" />",y=" Did you accidentally export a JSX literal instead of a component?"):A=typeof e,T("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",A,y)}var N=Ke(e,s,u,b,C);if(N==null)return N;if(v){var ce=s.children;if(ce!==void 0)if(w)if(Me(ce)){for(var Fe=0;Fe<ce.length;Fe++)a(ce[Fe],e);Object.freeze&&Object.freeze(ce)}else T("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 a(ce,e)}if(me.call(s,"key")){var Oe=Y(e),J=Object.keys(s).filter(function(xt){return xt!=="key"}),lt=J.length>0?"{key: someKey, "+J.join(": ..., ")+": ...}":"{key: someKey}";if(!p[Oe+lt]){var Ct=J.length>0?"{"+J.join(": ..., ")+": ...}":"{}";T(`A props object containing a "key" prop is being spread into JSX:
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:
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} />`,lt,Oe,Ct,Oe),p[Oe+lt]=!0}}return e===g?f(N):h(N),N}}function ge(e,s,u){return O(e,s,u,!0)}function Ve(e,s,u){return O(e,s,u,!1)}var De=Ve,Rt=ge;Be.Fragment=g,Be.jsx=De,Be.jsxs=Rt}()),Be}process.env.NODE_ENV==="production"?ft.exports=At():ft.exports=$t();var He=ft.exports;const Et=l=>Xe.createElement("path",l),dt=Xe.forwardRef(({className:l,isPressed:c,...E},g)=>{const P={...E,className:Tt(l,{"is-pressed":c})||void 0,"aria-hidden":!0,focusable:!1};return He.jsx("svg",{...P,ref:g})});dt.displayName="SVG";const Nt=He.jsx(dt,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:He.jsx(Et,{d:"M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z"})}),Mt=He.jsx(dt,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:He.jsx(Et,{d:"M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z"})}),It="_file-picker-tree_3rwm2_1",Lt="_file-node-button_3rwm2_17",Vt="_selected_3rwm2_53",Wt="_focused_3rwm2_65",Bt="_dropTarget_3rwm2_70",Ht="_dropTargetInvalid_3rwm2_79",Yt="_renaming_3rwm2_88",qt="_renameInput_3rwm2_93",zt="_file-name_3rwm2_108",Q={filePickerTree:It,fileNodeButton:Lt,selected:Vt,focused:Wt,dropTarget:Bt,dropTargetInvalid:Ht,renaming:Yt,renameInput:qt,fileName:zt};function ct(l){if(!l)return[];const c=l.replaceAll(/\\+/g,"/").replace(/\/{2,}/g,"/").replace(/\/$/,"")||l,E=c.startsWith("/"),g=c.split("/").filter(Boolean),P=[];let R=E?"/":"";E&&P.push("/");for(const M of g)!R||R==="/"?R=R==="/"?`/${M}`:M:R=`${R}/${M}`,P.push(R);return P}function Ut(l,c){if(!l||!c||l===c)return!1;const E=l==="/"?"/":l.replace(/\/{2,}/g,"/"),g=c.replace(/\/{2,}/g,"/");return E==="/"?g.startsWith("/")&&g!=="/":g.startsWith(`${E}/`)}function ut(l,c,E){return l&&(l===c?E:l.startsWith(c==="/"?"/":`${c}/`)?E+l.slice(c.length):l)}const _t=i.forwardRef(function({filesystem:c,root:E="/wordpress",initialSelectedPath:g,onSelect:P=()=>{},onDoubleClickFile:R},M){const k=i.useMemo(()=>{let t=(E||"/").replace(/\\+/g,"/");return t.startsWith("/")||(t=`/${t}`),t=t.replace(/\/{2,}/g,"/"),t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),t||"/"},[E]),S=t=>!t||t==="."||t===".."?!1:!/[\\/]/.test(t),[I,_]=i.useState(()=>{if(!g)return{};const t={};for(const r of ct(g))t[r]=!0;return t}),[x,L]=i.useState(()=>g??null),[ee,$]=i.useState(()=>g??null),[U,he]=i.useState({}),[D,T]=i.useState({}),[ue,pe]=i.useState(null),[ye,Z]=i.useState(null),B=i.useRef({}),ve=i.useRef(!1),te=i.useRef(null),m=i.useRef(null),H=i.useRef(D),oe=i.useRef(U),Y=()=>{for(const t of Object.keys(B.current))clearTimeout(B.current[t]),delete B.current[t]},K=t=>{const r=B.current[t];r&&(clearTimeout(r),delete B.current[t])};i.useEffect(()=>{H.current=D},[D]),i.useEffect(()=>{oe.current=U},[U]);const V=t=>{var n;const r=(n=te.current)==null?void 0:n.querySelector(`[data-path="${t}"]`);r&&typeof r.focus=="function"&&(r.focus(),r.scrollIntoView({behavior:"smooth",block:"nearest"}))},re=(t,r="")=>(r?`${r}/${t.name}`:t.name).replaceAll(/\\+/g,"/").replace(/\/{2,}/g,"/"),xe=(t,r)=>t.children?t.children:U[r],Te=async(t,r)=>{const n=await t.listFiles(r),o=[];for(const a of n){const h=r==="/"?`/${a}`:`${r}/${a}`,f=await t.isDir(h);o.push({name:a,type:f?"folder":"file"})}return o.sort((a,h)=>{var ge;if(a.type!==h.type)return a.type==="folder"?-1:1;const f=r==="/"?`/${a.name}`:`${r}/${a.name}`,p=r==="/"?`/${h.name}`:`${r}/${h.name}`,O=(ge=ae.current)==null?void 0:ge.tempPath;if(O){if(f===O)return-1;if(p===O)return 1}return a.name.localeCompare(h.name)}),o},Ee=async t=>await Te(c,t),fe=(t,r)=>{if(r.type!=="folder")return r.children;const n=r.children??oe.current[t];return n||H.current[t]?n:(T(o=>({...o,[t]:!0})),new Promise(o=>{Ee(t).then(a=>{he(h=>({...h,[t]:a??[]})),o(a??[])}).catch(()=>{o([])}).finally(()=>{T(a=>{const h={...a};return delete h[t],h})})}))},G=(t,r)=>{r.type==="folder"&&(typeof window>"u"||B.current[t]||(B.current[t]=window.setTimeout(()=>{_(n=>n[t]?n:{...n,[t]:!0}),fe(t,r),delete B.current[t]},600)))},q=t=>(T(r=>({...r,[t]:!0})),new Promise(r=>{Ee(t).then(n=>{he(o=>({...o,[t]:n??[]})),r(n??[])}).catch(()=>{r([])}).finally(()=>{T(n=>{const o={...n};return delete o[t],o})})})),se=(t,r,n)=>{_(o=>({...o,[t]:n})),n?fe(t,r):he(o=>{if(o[t]===void 0)return o;const a={...o};return delete a[t],a})},le=async t=>{if(!t)return;const r=ct(t);if(r.length===0)return;_(a=>{const h={...a};for(const f of r)h[f]=!0;return h});let n=[{name:k,type:"folder"}],o="";for(const a of r){const h=n==null?void 0:n.find(p=>re(p,o)===a);if(!h||h.type!=="folder"){o=a,n=[];continue}n=await fe(a,h)??oe.current[a],o=a}},_e=(t,r)=>{if(!t||!r||t===r)return;const n=t==="/"?"/":`${t}/`,o=a=>a===t?r:a.startsWith(n)?r+a.slice(t.length):null;_(a=>{let h=!1;const f={...a};for(const p of Object.keys(a)){const O=o(p);O&&O!==p&&(f[O]=a[p],delete f[p],h=!0)}return h?f:a}),he(a=>{let h=!1;const f={...a};for(const p of Object.keys(a)){const O=o(p);O&&O!==p&&(f[O]=a[p],delete f[p],h=!0)}return h?f:a}),L(a=>a&&(o(a)??a)),$(a=>a&&(o(a)??a))},de=()=>{pe(null),Z(null),Y()},we=(t,r=!0)=>{L(t),r&&P(t)},W=i.useMemo(()=>[{name:k,type:"folder"}],[k]),[j,ne]=i.useState(null),[d,F]=i.useState(null),ae=i.useRef(null),be=d;i.useImperativeHandle(M,()=>({focusPath:(t,r={})=>{if(!t)return;const{select:n=!0,domFocus:o=!0,notify:a=!1}=r;n&&we(t,a),$(t),o&&V(t)},selectPath:t=>{t&&(we(t),$(t),V(t))},getSelectedPath:()=>x,expandToPath:async t=>await le(t),refresh:async t=>await q(t),remapPath:_e,createFile:async t=>{await Se(t,"file","untitled.php")},createFolder:async t=>{await Se(t,"folder","New Folder")}}),[x,q,_e,le]);const Pe=i.useRef(!1),me=i.useRef(g??null),$e=i.useRef(g);i.useEffect(()=>{ve.current=!1},[k]),i.useEffect(()=>{g&&g!==$e.current?me.current=g:g||(me.current=null),$e.current=g},[g]),i.useEffect(()=>{if(!g||Pe.current)return;Pe.current=!0;const t=ct(g);_(n=>{const o={...n};for(const a of t)o[a]=!0;return o});const r=t[t.length-1]||g;$(r),L(r),le(g)},[g,le]),i.useEffect(()=>{const t=me.current;!t||W.length===0||(me.current=null,le(t))},[W,le]),i.useEffect(()=>{if(!ee){if(W.length>0){const t=re(W[0]);$(t)}return}be&&be===ee||V(ee)},[W,ee,be]),i.useEffect(()=>{if(W.length===0)return;const t=W[0];if((t==null?void 0:t.type)!=="folder"||ve.current)return;const r=t.name;ve.current=!0,_(n=>n[r]?n:{...n,[r]:!0}),!oe.current[r]&&!H.current[r]&&fe(r,t)},[W,fe,k]),i.useEffect(()=>()=>{m.current&&clearTimeout(m.current),Y()},[]),i.useEffect(()=>{j&&setTimeout(()=>{const t=document.querySelector('[role="menu"] [role="menuitem"]');t&&typeof t.focus=="function"&&t.focus()},0)},[j]);const[Ye,Re]=i.useState(""),Qe=(t,r)=>{if(t.type==="folder")return r;const n=X.dirname(r);return n&&n||"/"},Ne=(t,r,n)=>{const o=Qe(t,r);if(!o)return{allowed:!1,state:"invalid",destination:null};if(n){if(o===n)return{allowed:!1,state:"invalid",destination:null};if(Ut(n,o))return{allowed:!1,state:"invalid",destination:null}}return{allowed:!0,state:"valid",destination:o}},Me=(t,r,n)=>{r.type!=="folder"&&r.type!=="file"||(pe(n),Z(null),t.dataTransfer&&(t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("application/x-wp-playground-path",n),t.dataTransfer.setData("text/plain",n)))},et=()=>{de()},tt=(t,r,n)=>{const o=Ne(r,n,ue);o.allowed&&r.type==="folder"&&G(n,r),Z(a=>(a==null?void 0:a.path)===n&&a.state===o.state?a:{path:n,state:o.state})},qe=(t,r,n)=>{const o=Ne(r,n,ue);o.allowed&&o.destination?(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect=ue?"move":"copy"),r.type==="folder"&&G(n,r),Z(a=>(a==null?void 0:a.path)===n&&a.state===o.state?a:{path:n,state:o.state})):(t.dataTransfer&&(t.dataTransfer.dropEffect="none"),K(n),Z(a=>(a==null?void 0:a.path)===n&&a.state==="invalid"?a:{path:n,state:"invalid"}))},ze=(t,r,n)=>{K(n);const o=t.relatedTarget;o&&t.currentTarget.contains(o)||Z(a=>(a==null?void 0:a.path)===n?null:a)},Ue=async(t,r,n)=>{const o=ue,a=Ne(r,n,o);if(!a.allowed||!a.destination){de();return}t.preventDefault(),t.stopPropagation(),K(n),Z(null);try{o?await it(o,a.destination):await Ge(t,a.destination)}finally{de()}},rt=(t,r,n)=>{t.preventDefault(),t.stopPropagation(),F(null),ne({absPath:n,type:r.type,x:t.clientX,y:t.clientY})},ke=async(t,r)=>{let n=r,o=0;const a=f=>{const p=f.lastIndexOf(".");return p>0?{stem:f.slice(0,p),ext:f.slice(p)}:{stem:f,ext:""}},h=t==="/"?"":t;for(;await(c==null?void 0:c.fileExists(`${h}/${n}`))||await(c==null?void 0:c.isDir(`${h}/${n}`));){o+=1;const{stem:f,ext:p}=a(r);n=`${f} (${o})${p}`}return n},Se=async(t,r,n)=>{if(!c)return;let o=t||x||k;try{await c.isDir(o)||(o=X.dirname(o))}catch{o=X.dirname(o)}const a=o,h=await ke(a,n),f=X.joinPaths(a,h);r==="folder"?await c.mkdir(f):await c.writeFile(f,""),ae.current={type:r,tempPath:f},F(f),await q(a),setTimeout(()=>{$(f),V(f)},0)},nt=async t=>{if(!c)return!1;try{if(await c.fileExists(t))return!0}catch{}try{if(await c.isDir(t))return!0}catch{}return!1},at=async t=>{if(c)try{await c.mkdir(t)}catch(r){if(!await c.isDir(t).catch(()=>!1))throw r}},it=async(t,r)=>{if(!c)return;const n=X.basename(t),o=X.joinPaths(r,n);if(o===t||await nt(o))return;const a=X.dirname(t);try{await c.mv(t,o),_e(t,o);const h=ut(x,t,o);x&&(x===t||x.startsWith(`${t}/`))&&P(h),$(f=>ut(f,t,o)),_(f=>({...f,[r]:!0})),await Promise.all([q(a),q(r)]),L(f=>ut(f,t,o)),V(o)}catch{}},ot=t=>{const r=t;return r.webkitGetAsEntry?r.webkitGetAsEntry():null},st=t=>new Promise((r,n)=>{t.file(r,n)}),Ze=async(t,r)=>{if(!c)return;const n=t.name||"untitled",o=await ke(r,n),a=X.joinPaths(r,o),h=new Uint8Array(await t.arrayBuffer());await c.writeFile(a,h)},Ke=async(t,r)=>{const n=await st(t);await Ze(n,r)},je=async(t,r)=>{const n=await ke(r,t.name||"New Folder"),o=X.joinPaths(r,n);await at(o);const a=t.createReader(),h=()=>new Promise((f,p)=>{a.readEntries(O=>f(Array.from(O)),p)});for(;;){const f=await h();if(!f.length)break;for(const p of f)p.isFile?await Ke(p,o):p.isDirectory&&await je(p,o)}},Ge=async(t,r)=>{var a,h;if(!c)return;const o=((a=t.dataTransfer)!=null&&a.items?Array.from(t.dataTransfer.items):[]).filter(f=>f.kind==="file").map(f=>ot(f)).filter(f=>!!f);if(o.length>0)for(const f of o)f.isFile?await Ke(f,r):f.isDirectory&&await je(f,r);else{const f=(h=t.dataTransfer)!=null&&h.files?Array.from(t.dataTransfer.files):[];for(const p of f)await Ze(p,r)}await q(r),_(f=>({...f,[r]:!0}))},Ce=async(t,r)=>{if(!c)return;const n=t;ne(null);try{r==="folder"?await c.rmdir(n,{recursive:!0}):await c.unlink(n)}catch{}finally{F(null);const o=X.dirname(n);await q(o),x&&(x===n||x.startsWith(`${n}/`))&&P(null)}},Ie=t=>{var r;if(!d)if(t.key.length===1&&t.key.match(/\S/)){const n=Ye+t.key.toLowerCase();if(Re(n),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{Re("")},1e3),!te.current)return;const o=Array.from(te.current.querySelectorAll(".file-node-button")),a=document.activeElement;let h=0;a&&o.includes(a)&&(h=o.indexOf(a));for(let f=0;f<o.length;f++){const p=(h+f)%o.length,O=o[p];if((r=O.textContent)!=null&&r.toLowerCase().trim().startsWith(n)){O.focus();const ge=O.getAttribute("data-path");ge&&$(ge);break}}}else Re(""),m.current&&clearTimeout(m.current)},Le=async(t,r)=>{const n=ae.current,o=(n==null?void 0:n.tempPath)===t,a=X.dirname(t),h=(r||"").trim();if(!S(h)){if(o){try{n.type==="folder"?await c.rmdir(t,{recursive:!0}):await c.unlink(t)}catch{}ae.current=null}F(o?null:t);return}let f=X.joinPaths(a,h),p=f;if(p===t){F(null);const De=o&&(n==null?void 0:n.type)==="file";o&&(ae.current=null),setTimeout(()=>{$(p),V(p),De&&R&&R(p)},0);return}const O=await c.fileExists(p),ge=await c.isDir(p);if((O||ge)&&p!==t)if(o)try{const De=await ke(a==="/"?"/":a,h);f=X.joinPaths(a,De),p=f}catch{}else{F(t);return}let Ve=(n==null?void 0:n.type)==="folder";try{await c.mv(t,f),n||(Ve=await c.isDir(f)),Ve&&_e(t,p),x===t&&P(p),await q(a),$(p),V(p),o&&!Ve&&R&&R(p)}catch{if(o)try{(n==null?void 0:n.type)==="folder"?await c.rmdir(t,{recursive:!0}):await c.unlink(t)}catch{}}finally{ae.current=null,F(null)}},Je=async t=>{const r=ae.current;if(!c||(r==null?void 0:r.tempPath)!==t){F(o=>o===t?null:o);return}try{r.type==="folder"?await c.rmdir(t,{recursive:!0}):await c.unlink(t)}catch{}ae.current=null,F(null);const n=X.dirname(t);await q(n),$(n),V(n)};return i.createElement("div",{onKeyDown:Ie,ref:te},i.createElement(ie.__experimentalTreeGrid,{className:Q.filePickerTree},W.map((t,r)=>i.createElement(bt,{key:t.name,node:t,level:0,position:r+1,setSize:W.length,expandedNodePaths:I,onToggle:se,selectedNode:x,focusPath:n=>$(n),focusedNode:ee,selectPath:we,generatePath:re,getChildren:xe,onContextMenu:rt,renamingPath:be,onRename:Le,onRenameCancel:Je,dropIndicator:ye,onDragStart:Me,onDragEnd:et,onDragEnter:tt,onDragOver:qe,onDragLeave:ze,onDrop:Ue,rootPath:k,onDoubleClickFile:R}))),j&&i.createElement(ie.Popover,{placement:"bottom-start",onClose:()=>ne(null),anchor:{getBoundingClientRect:()=>({x:j.x,y:j.y,width:0,height:0,top:j.y,left:j.x,right:j.x,bottom:j.y,toJSON:()=>({})}),ownerDocument:document},noArrow:!0,resize:!1,focusOnMount:"firstElement"},i.createElement(ie.NavigableMenu,{role:"menu"},j.type==="folder"&&i.createElement(ie.MenuItem,{role:"menuitem",onClick:async()=>{ne(null),await Se(j.absPath,"file","untitled.php")}},"Create file"),j.type==="folder"&&i.createElement(ie.MenuItem,{role:"menuitem",onClick:async()=>{ne(null),await Se(j.absPath,"folder","New Folder")}},"Create directory"),i.createElement(ie.MenuItem,{role:"menuitem",onClick:()=>{ne(null),F(j.absPath)}},"Rename"),i.createElement(ie.MenuItem,{role:"menuitem",onClick:()=>Ce(j.absPath,j.type)},"Delete"))))}),bt=({node:l,level:c,position:E,setSize:g,expandedNodePaths:P,onToggle:R,selectedNode:M,focusPath:k,focusedNode:S,selectPath:I,generatePath:_,getChildren:x,onContextMenu:L,renamingPath:ee,onRename:$,onRenameCancel:U,parentPath:he="",dropIndicator:D,onDragStart:T,onDragEnd:ue,onDragEnter:pe,onDragOver:ye,onDragLeave:Z,onDrop:B,rootPath:ve,onDoubleClickFile:te})=>{const m=_(l,he),H=P[m],oe=ee===m,Y=i.useRef(null),[K,V]=i.useState(l.name),re=i.useRef(!1),xe=(D==null?void 0:D.path)===m,Te=xe&&(D==null?void 0:D.state)==="valid",Ee=xe&&(D==null?void 0:D.state)==="invalid",fe=!oe&&m!==ve,G=i.useRef(null),q={onDragEnter:d=>pe==null?void 0:pe(d,l,m),onDragOver:d=>ye==null?void 0:ye(d,l,m),onDragLeave:d=>Z==null?void 0:Z(d,l,m),onDrop:d=>B==null?void 0:B(d,l,m)},se=x(l,m)??[];i.useEffect(()=>{var d;oe?(V(l.name),re.current=!1,typeof window<"u"&&requestAnimationFrame?requestAnimationFrame(()=>{var F;(F=Y.current)==null||F.select()}):(d=Y.current)==null||d.select()):re.current=!1},[oe,l.name]);const le=()=>{l.type==="folder"&&R(m,l,!H)},_e=d=>{var F,ae;if(d.key==="ArrowLeft")H?le():(F=document.querySelector(`[data-path="${he}"]`))==null||F.focus(),d.preventDefault(),d.stopPropagation();else if(d.key==="ArrowRight"){if(H){if(se!=null&&se.length){const be=_(se[0],m);(ae=document.querySelector(`[data-path="${be}"]`))==null||ae.focus()}}else le();d.preventDefault(),d.stopPropagation()}else d.key===" "||d.key==="Space"||d.key==="Spacebar"?(l.type==="folder"&&R(m,l,!H),d.preventDefault()):d.key==="Enter"&&(l.type==="folder"?R(m,l,!H):(I(m,!1),k(m),te?te(m):I(m,!0)),d.preventDefault())},de=d=>{L==null||L(d,l,m)},we=d=>{d.preventDefault(),re.current=!0,$==null||$(m,K.trim())},W=d=>{if(d.key==="Escape"){d.preventDefault(),d.stopPropagation(),re.current=!0,U==null||U(m);return}(d.key==="ArrowLeft"||d.key==="ArrowRight"||d.key==="ArrowUp"||d.key==="ArrowDown")&&d.stopPropagation()},j=()=>{re.current||U==null||U(m),re.current=!1},ne=()=>{if(l.type==="folder"){le(),I(m),k(m);return}const d=G.current!==null;if(d&&G.current&&clearTimeout(G.current),G.current=null,d){te?te(m):I(m,!0);return}I(m,!1),k(m),I(m,!0),G.current=window.setTimeout(()=>{G.current=null},300)};return i.useEffect(()=>()=>{G.current!==null&&typeof window<"u"&&clearTimeout(G.current)},[]),i.createElement(i.Fragment,null,i.createElement(ie.__experimentalTreeGridRow,{level:c,positionInSet:E,setSize:g},i.createElement(ie.__experimentalTreeGridCell,null,()=>i.createElement(i.Fragment,null,oe?i.createElement("form",{onSubmit:we,className:mt(Q.fileNodeButton,Q.renaming,"file-node-button",{[Q.selected]:M===m,[Q.focused]:S===m,[Q.dropTarget]:Te,[Q.dropTargetInvalid]:Ee}),"data-path":m,onContextMenu:de,...q},i.createElement(gt,{node:l,isOpen:l.type==="folder"&&H,level:c,hideName:!0}),i.createElement("input",{ref:Y,className:Q.renameInput,value:K,onChange:d=>V(d.target.value),onBlur:j,onFocus:()=>k(m),onKeyDown:W})):i.createElement(ie.Button,{...q,draggable:fe,onDragStart:d=>T==null?void 0:T(d,l,m),onDragEnd:d=>ue==null?void 0:ue(d,l,m),onClick:ne,onKeyDown:_e,onFocus:()=>{k(m)},onContextMenu:de,className:mt(Q.fileNodeButton,"file-node-button",{[Q.selected]:M===m,[Q.focused]:S===m,[Q.dropTarget]:Te,[Q.dropTargetInvalid]:Ee}),"data-path":m,"data-expanded":H?"true":"false"},i.createElement(gt,{node:l,isOpen:l.type==="folder"&&H,level:c}))))),H&&se&&se.map((d,F)=>i.createElement(bt,{key:d.name,node:d,level:c+1,position:F+1,setSize:se.length,expandedNodePaths:P,onToggle:R,selectedNode:M,focusPath:k,focusedNode:S,selectPath:I,generatePath:_,getChildren:x,onContextMenu:L,renamingPath:ee,onRename:$,onRenameCancel:U,parentPath:m,dropIndicator:D,onDragStart:T,onDragEnd:ue,onDragEnter:pe,onDragOver:ye,onDragLeave:Z,onDrop:B,rootPath:ve,onDoubleClickFile:te})))},gt=({node:l,level:c,isOpen:E,hideName:g=!1})=>{const P=[];for(let R=0;R<c;R++)P.push("&nbsp;&nbsp;&nbsp;&nbsp;");return i.createElement(i.Fragment,null,i.createElement("span",{"aria-hidden":"true",dangerouslySetInnerHTML:{__html:P.join("")}}),l.type==="folder"?i.createElement(ht,{width:16,icon:E?Nt:Mt}):i.createElement("div",{style:{width:16}}," "),i.createElement(ht,{width:16,icon:l.type==="folder"?yt:vt}),!g&&i.createElement("span",{className:Q.fileName},l.name))},Zt="_control_kp9d9_1",Kt="_browse-label_kp9d9_11",Gt="_path-preview_kp9d9_37",Jt="_modal_kp9d9_43",Xt="_modal-footer_kp9d9_48",Ae={control:Zt,browseLabel:Kt,pathPreview:Gt,modal:Jt,modalFooter:Xt};function Qt({path:l}){if(!l)return i.createElement("div",{className:Ae.pathPreview},i.createElement("i",null,"Select a path"));const c=l.split("/");let E=(c.length>2?"/":"")+c.pop();E.length>10&&(E=E.substring(E.length-10));const g=l.substring(0,l.length-E.length);return i.createElement("div",{className:Ae.pathPreview,"data-content-start":g,"data-content-end":E})}function er({value:l="",onChange:c,filesystem:E}){const[g,P]=i.useState(!1),R=()=>P(!0),M=()=>P(!1),[k,S]=i.useState(l||null);function I(_){_==null||_.preventDefault(),c(k||""),M()}return i.createElement(i.Fragment,null,i.createElement(ie.Button,{variant:"tertiary",className:Ae.control,onClick:R},i.createElement("span",{className:Ae.browseLabel},"Browse"),i.createElement(Qt,{path:l||""})),g&&i.createElement(ie.Modal,{title:"Select a path ",onRequestClose:M,className:Ae.modal},i.createElement("form",{onSubmit:I},i.createElement(_t,{filesystem:E,initialSelectedPath:l,onSelect:S}),i.createElement("div",{className:Ae.modalFooter},i.createElement(ie.Button,{type:"submit",variant:"primary"},"Select Path")))))}exports.ClockIcon=Ot;exports.FilePickerControl=er;exports.FilePickerTree=_t;exports.SiteManagerIcon=Ft;exports.WordPressIcon=St;exports.file=vt;exports.folder=yt;exports.getLogoDataURL=Dt;exports.layout=jt;exports.playgroundLogo=Pt;exports.temporaryStorage=kt;
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;
31
31
  //# sourceMappingURL=index.cjs.map