@wp-playground/components 3.0.5 → 3.0.8

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.
@@ -1,9 +1,7 @@
1
1
  import React from 'react';
2
- import type { FileNode } from '../FilePickerTree';
3
- export declare function FilePickerControl({ value, onChange, files, isLoading, error, }: {
2
+ import type { AsyncWritableFilesystem } from '../FilePickerTree';
3
+ export declare function FilePickerControl({ value, onChange, filesystem, }: {
4
4
  value?: string;
5
5
  onChange: (selectedPath: string) => void;
6
- files?: FileNode[];
7
- isLoading?: boolean;
8
- error?: string;
6
+ filesystem: AsyncWritableFilesystem;
9
7
  }): React.JSX.Element;
@@ -1,15 +1,42 @@
1
1
  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
+ }
2
16
  export type FileNode = {
3
17
  name: string;
4
18
  type: 'file' | 'folder';
5
19
  children?: FileNode[];
6
20
  };
7
- export type FilePickerControlProps = {
8
- files: FileNode[];
9
- initialPath?: string;
10
- onSelect?: (path: string) => void;
11
- isLoading?: boolean;
12
- error?: string;
21
+ export type FilePickerTreeProps = {
22
+ filesystem: AsyncWritableFilesystem;
23
+ root?: string;
24
+ initialSelectedPath?: string;
25
+ onSelect?: (path: string | null) => void;
13
26
  };
14
- declare const FilePickerTree: React.FC<FilePickerControlProps>;
27
+ export type FilePickerTreeHandle = {
28
+ focusPath: (path: string, options?: {
29
+ select?: boolean;
30
+ domFocus?: boolean;
31
+ notify?: boolean;
32
+ }) => void;
33
+ selectPath: (path: string) => void;
34
+ getSelectedPath: () => string | null;
35
+ expandToPath: (path: string) => Promise<void>;
36
+ refresh: (path: string) => Promise<FileNode[] | undefined>;
37
+ remapPath: (from: string, to: string) => void;
38
+ createFile: (absSelectedPath?: string) => Promise<void>;
39
+ createFolder: (absSelectedPath?: string) => Promise<void>;
40
+ };
41
+ export declare const FilePickerTree: React.ForwardRefExoticComponent<FilePickerTreeProps & React.RefAttributes<FilePickerTreeHandle>>;
15
42
  export default FilePickerTree;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import type { AsyncWritableFilesystem } from '../FilePickerTree';
3
+ declare global {
4
+ interface Window {
5
+ __filePickerHarness?: {
6
+ filesystem: AsyncWritableFilesystem;
7
+ reload: () => void;
8
+ };
9
+ }
10
+ }
11
+ export declare function FilePickerTreeHarness(): React.JSX.Element;
package/index.cjs CHANGED
@@ -1,2 +1,31 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),C=t=>e.createElement("svg",{width:"32",height:"32",viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},e.createElement("rect",{width:"10.4176",height:"10.4176",rx:"3.86258",transform:"matrix(0.829038 -0.559193 0.838671 0.544639 7.45703 24.1775)",stroke:"white",strokeWidth:"0.965644"}),e.createElement("rect",{width:"13.2346",height:"13.2346",rx:"3.86258",transform:"matrix(0.829038 -0.559193 0.838671 0.544639 5.0918 18.9934)",stroke:"white",strokeWidth:"1.44847"}),e.createElement("rect",{width:"17.451",height:"17.451",rx:"3.86258",transform:"matrix(0.829038 -0.559193 0.838671 0.544639 1.55371 11.6099)",stroke:"white",strokeWidth:"1.93129"})),l=t=>e.createElement("svg",{width:"16",height:"17",viewBox:"0 0 16 17",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},e.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 15C4.41015 15 1.5 12.0899 1.5 8.5C1.5 4.91015 4.41015 2 8 2C11.5899 2 14.5 4.91015 14.5 8.5C14.5 12.0899 11.5899 15 8 15ZM0 8.5C0 4.08172 3.58172 0.5 8 0.5C12.4183 0.5 16 4.08172 16 8.5C16 12.9183 12.4183 16.5 8 16.5C3.58172 16.5 0 12.9183 0 8.5ZM9 9.5V4.5H7.5V8H5.5V9.5H9Z",fill:"#949494"})),o=t=>e.createElement("svg",{width:"20",height:"21",viewBox:"0 0 20 21",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},e.createElement("path",{d:"M20 10.5C20 4.99 15.51 0.5 10 0.5C4.48 0.5 0 4.99 0 10.5C0 16.02 4.48 20.5 10 20.5C15.51 20.5 20 16.02 20 10.5ZM7.78 15.87L4.37 6.72C4.92 6.7 5.54 6.64 5.54 6.64C6.04 6.58 5.98 5.51 5.48 5.53C5.48 5.53 4.03 5.64 3.11 5.64C2.93 5.64 2.74 5.64 2.53 5.63C4.12 3.19 6.87 1.61 10 1.61C12.33 1.61 14.45 2.48 16.05 3.95C15.37 3.84 14.4 4.34 14.4 5.53C14.4 6.27 14.85 6.89 15.3 7.63C15.65 8.24 15.85 8.99 15.85 10.09C15.85 11.58 14.45 15.09 14.45 15.09L11.42 6.72C11.96 6.7 12.24 6.55 12.24 6.55C12.74 6.5 12.68 5.3 12.18 5.33C12.18 5.33 10.74 5.45 9.8 5.45C8.93 5.45 7.47 5.33 7.47 5.33C6.97 5.3 6.91 6.53 7.41 6.55L8.33 6.63L9.59 10.04L7.78 15.87ZM17.41 10.5C17.65 9.86 18.15 8.63 17.84 6.25C18.54 7.54 18.89 8.96 18.89 10.5C18.89 13.79 17.16 16.74 14.49 18.28C15.46 15.69 16.43 13.08 17.41 10.5ZM6.1 18.59C3.12 17.15 1.11 14.03 1.11 10.5C1.11 9.2 1.34 8.02 1.83 6.91C3.25 10.8 4.67 14.7 6.1 18.59ZM10.13 11.96L12.71 18.94C11.85 19.23 10.95 19.39 10 19.39C9.21 19.39 8.43 19.28 7.71 19.06C8.52 16.68 9.33 14.32 10.13 11.96Z",fill:"#ffffff"})),r=e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"15",height:"14",viewBox:"0 0 15 14",fill:"none"},e.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.59196 3.59524L6.77745 1.96623C6.70755 1.82641 6.56464 1.7381 6.40832 1.7381H1.65079C1.42287 1.7381 1.2381 1.92287 1.2381 2.15079V11.8492C1.2381 12.0771 1.42287 12.2619 1.65079 12.2619H13.2063C13.4343 12.2619 13.619 12.0771 13.619 11.8492V4.00794C13.619 3.78001 13.4343 3.59524 13.2063 3.59524H7.59196ZM8.35714 2.35714L7.88484 1.41254C7.60521 0.853274 7.0336 0.5 6.40832 0.5H1.65079C0.739085 0.5 0 1.23909 0 2.15079V11.8492C0 12.7609 0.739085 13.5 1.65079 13.5H13.2063C14.1181 13.5 14.8571 12.7609 14.8571 11.8492V4.00794C14.8571 3.09623 14.1181 2.35714 13.2063 2.35714H8.35714Z"})),n=e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",fill:"currentColor",className:"bi bi-file-earmark",viewBox:"0 0 16 16"},e.createElement("path",{d:"M14 4.5V14a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2h5.5zm-3 0A1.5 1.5 0 0 1 9.5 3V1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V4.5z"})),i=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 14 14",fill:"none",...t},e.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 12.6875C3.85888 12.6875 1.3125 10.1411 1.3125 7C1.3125 3.85888 3.85888 1.3125 7 1.3125C10.1411 1.3125 12.6875 3.85888 12.6875 7C12.6875 10.1411 10.1411 12.6875 7 12.6875ZM0 7C0 3.13401 3.13401 0 7 0C10.866 0 14 3.13401 14 7C14 10.866 10.866 14 7 14C3.13401 14 0 10.866 0 7ZM7.875 7.875V3.5H6.5625V6.5625H4.8125V7.875H7.875Z",fill:"#949494"})),a=e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 14 14",fill:"none"},e.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.25 1.3125H1.75C1.50838 1.3125 1.3125 1.50838 1.3125 1.75V4.37495H12.6875V1.75C12.6875 1.50837 12.4916 1.3125 12.25 1.3125ZM12.6875 5.68745H5.25003V12.6875H12.25C12.4916 12.6875 12.6875 12.4916 12.6875 12.25V5.68745ZM3.93753 5.68745H1.3125V12.25C1.3125 12.4916 1.50837 12.6875 1.75 12.6875H3.93753L3.93753 5.68745ZM1.75 0H12.25C13.2165 0 14 0.783502 14 1.75V12.25C14 13.2165 13.2165 14 12.25 14H1.75C0.783502 14 0 13.2165 0 12.25V1.75C0 0.783502 0.783502 0 1.75 0Z",fill:"#949494"}));function h(t){return`data:${t.mime};base64,${t.data}`}function w(){return e.createElement("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M1.99967 1.58301H4.49967C4.72979 1.58301 4.91634 1.76956 4.91634 1.99967V4.49967C4.91634 4.72979 4.72979 4.91634 4.49967 4.91634H1.99967C1.76956 4.91634 1.58301 4.72979 1.58301 4.49967V1.99967C1.58301 1.76956 1.76956 1.58301 1.99967 1.58301ZM0.333008 1.99967C0.333008 1.0792 1.0792 0.333008 1.99967 0.333008H4.49967C5.42015 0.333008 6.16634 1.0792 6.16634 1.99967V4.49967C6.16634 5.42015 5.42015 6.16634 4.49967 6.16634H1.99967C1.0792 6.16634 0.333008 5.42015 0.333008 4.49967V1.99967ZM9.49967 1.58301H11.9997C12.2298 1.58301 12.4163 1.76956 12.4163 1.99967V4.49967C12.4163 4.72979 12.2298 4.91634 11.9997 4.91634H9.49967C9.26956 4.91634 9.08301 4.72979 9.08301 4.49967V1.99967C9.08301 1.76956 9.26956 1.58301 9.49967 1.58301ZM7.83301 1.99967C7.83301 1.0792 8.5792 0.333008 9.49967 0.333008H11.9997C12.9201 0.333008 13.6663 1.0792 13.6663 1.99967V4.49967C13.6663 5.42015 12.9201 6.16634 11.9997 6.16634H9.49967C8.5792 6.16634 7.83301 5.42015 7.83301 4.49967V1.99967ZM11.9997 9.08301H9.49967C9.26956 9.08301 9.08301 9.26956 9.08301 9.49967V11.9997C9.08301 12.2298 9.26956 12.4163 9.49967 12.4163H11.9997C12.2298 12.4163 12.4163 12.2298 12.4163 11.9997V9.49967C12.4163 9.26956 12.2298 9.08301 11.9997 9.08301ZM9.49967 7.83301C8.5792 7.83301 7.83301 8.5792 7.83301 9.49967V11.9997C7.83301 12.9201 8.5792 13.6663 9.49967 13.6663H11.9997C12.9201 13.6663 13.6663 12.9201 13.6663 11.9997V9.49967C13.6663 8.5792 12.9201 7.83301 11.9997 7.83301H9.49967ZM1.99967 9.08301H4.49967C4.72979 9.08301 4.91634 9.26956 4.91634 9.49967V11.9997C4.91634 12.2298 4.72979 12.4163 4.49967 12.4163H1.99967C1.76956 12.4163 1.58301 12.2298 1.58301 11.9997V9.49967C1.58301 9.26956 1.76956 9.08301 1.99967 9.08301ZM0.333008 9.49967C0.333008 8.5792 1.0792 7.83301 1.99967 7.83301H4.49967C5.42015 7.83301 6.16634 8.5792 6.16634 9.49967V11.9997C6.16634 12.9201 5.42015 13.6663 4.49967 13.6663H1.99967C1.0792 13.6663 0.333008 12.9201 0.333008 11.9997V9.49967Z",fill:"white"}))}exports.ClockIcon=i;exports.SiteManagerIcon=w;exports.WordPressIcon=o;exports.file=n;exports.folder=r;exports.getLogoDataURL=h;exports.layout=a;exports.playgroundLogo=C;exports.temporaryStorage=l;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react"),ee=require("@wordpress/components"),dt=require("classnames"),X=require("@php-wasm/util"),Qe=require("@wordpress/element"),Tt=require("clsx"),Pt=l=>o.createElement("svg",{width:"32",height:"32",viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",...l},o.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"}),o.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"}),o.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=>o.createElement("svg",{width:"16",height:"17",viewBox:"0 0 16 17",fill:"none",xmlns:"http://www.w3.org/2000/svg",...l},o.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=>o.createElement("svg",{width:"20",height:"21",viewBox:"0 0 20 21",fill:"none",xmlns:"http://www.w3.org/2000/svg",...l},o.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"})),gt=o.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"15",height:"14",viewBox:"0 0 15 14",fill:"none"},o.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=o.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"},o.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=>o.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 14 14",fill:"none",...l},o.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"})),Dt=o.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 14 14",fill:"none"},o.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 Ft(l){return`data:${l.mime};base64,${l.data}`}function jt(){return o.createElement("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg"},o.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M1.99967 1.58301H4.49967C4.72979 1.58301 4.91634 1.76956 4.91634 1.99967V4.49967C4.91634 4.72979 4.72979 4.91634 4.49967 4.91634H1.99967C1.76956 4.91634 1.58301 4.72979 1.58301 4.49967V1.99967C1.58301 1.76956 1.76956 1.58301 1.99967 1.58301ZM0.333008 1.99967C0.333008 1.0792 1.0792 0.333008 1.99967 0.333008H4.49967C5.42015 0.333008 6.16634 1.0792 6.16634 1.99967V4.49967C6.16634 5.42015 5.42015 6.16634 4.49967 6.16634H1.99967C1.0792 6.16634 0.333008 5.42015 0.333008 4.49967V1.99967ZM9.49967 1.58301H11.9997C12.2298 1.58301 12.4163 1.76956 12.4163 1.99967V4.49967C12.4163 4.72979 12.2298 4.91634 11.9997 4.91634H9.49967C9.26956 4.91634 9.08301 4.72979 9.08301 4.49967V1.99967C9.08301 1.76956 9.26956 1.58301 9.49967 1.58301ZM7.83301 1.99967C7.83301 1.0792 8.5792 0.333008 9.49967 0.333008H11.9997C12.9201 0.333008 13.6663 1.0792 13.6663 1.99967V4.49967C13.6663 5.42015 12.9201 6.16634 11.9997 6.16634H9.49967C8.5792 6.16634 7.83301 5.42015 7.83301 4.49967V1.99967ZM11.9997 9.08301H9.49967C9.26956 9.08301 9.08301 9.26956 9.08301 9.49967V11.9997C9.08301 12.2298 9.26956 12.4163 9.49967 12.4163H11.9997C12.2298 12.4163 12.4163 12.2298 12.4163 11.9997V9.49967C12.4163 9.26956 12.2298 9.08301 11.9997 9.08301ZM9.49967 7.83301C8.5792 7.83301 7.83301 8.5792 7.83301 9.49967V11.9997C7.83301 12.9201 8.5792 13.6663 9.49967 13.6663H11.9997C12.9201 13.6663 13.6663 12.9201 13.6663 11.9997V9.49967C13.6663 8.5792 12.9201 7.83301 11.9997 7.83301H9.49967ZM1.99967 9.08301H4.49967C4.72979 9.08301 4.91634 9.26956 4.91634 9.49967V11.9997C4.91634 12.2298 4.72979 12.4163 4.49967 12.4163H1.99967C1.76956 12.4163 1.58301 12.2298 1.58301 11.9997V9.49967C1.58301 9.26956 1.76956 9.08301 1.99967 9.08301ZM0.333008 9.49967C0.333008 8.5792 1.0792 7.83301 1.99967 7.83301H4.49967C5.42015 7.83301 6.16634 8.5792 6.16634 9.49967V11.9997C6.16634 12.9201 5.42015 13.6663 4.49967 13.6663H1.99967C1.0792 13.6663 0.333008 12.9201 0.333008 11.9997V9.49967Z",fill:"white"}))}const mt=Qe.forwardRef(({icon:l,size:c=24,...C},p)=>Qe.cloneElement(l,{width:c,height:c,...C,ref:p}));var ut={exports:{}},$e={};/**
2
+ * @license React
3
+ * react-jsx-runtime.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var ht;function At(){if(ht)return $e;ht=1;var l=o,c=Symbol.for("react.element"),C=Symbol.for("react.fragment"),p=Object.prototype.hasOwnProperty,x=l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,P={key:!0,ref:!0,__self:!0,__source:!0};function T(I,k,O){var y,H={},N=null,F=null;O!==void 0&&(N=""+O),k.key!==void 0&&(N=""+k.key),k.ref!==void 0&&(F=k.ref);for(y in k)p.call(k,y)&&!P.hasOwnProperty(y)&&(H[y]=k[y]);if(I&&I.defaultProps)for(y in k=I.defaultProps,k)H[y]===void 0&&(H[y]=k[y]);return{$$typeof:c,type:I,key:N,ref:F,props:H,_owner:x.current}}return $e.Fragment=C,$e.jsx=T,$e.jsxs=T,$e}var Ie={};/**
10
+ * @license React
11
+ * react-jsx-runtime.development.js
12
+ *
13
+ * Copyright (c) Facebook, Inc. and its affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var pt;function Mt(){return pt||(pt=1,process.env.NODE_ENV!=="production"&&function(){var l=o,c=Symbol.for("react.element"),C=Symbol.for("react.portal"),p=Symbol.for("react.fragment"),x=Symbol.for("react.strict_mode"),P=Symbol.for("react.profiler"),T=Symbol.for("react.provider"),I=Symbol.for("react.context"),k=Symbol.for("react.forward_ref"),O=Symbol.for("react.suspense"),y=Symbol.for("react.suspense_list"),H=Symbol.for("react.memo"),N=Symbol.for("react.lazy"),F=Symbol.for("react.offscreen"),te=Symbol.iterator,U="@@iterator";function he(e){if(e===null||typeof e!="object")return null;var s=te&&e[te]||e[U];return typeof s=="function"?s:null}var S=l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function R(e){{for(var s=arguments.length,u=new Array(s>1?s-1:0),h=1;h<s;h++)u[h-1]=arguments[h];se("error",e,u)}}function se(e,s,u){{var h=S.ReactDebugCurrentFrame,b=h.getStackAddendum();b!==""&&(s+="%s",u=u.concat([b]));var _=u.map(function(E){return String(E)});_.unshift("Warning: "+s),Function.prototype.apply.call(console[e],console,_)}}var pe=!1,K=!1,W=!1,ie=!1,le=!1,w;w=Symbol.for("react.module.reference");function G(e){return!!(typeof e=="string"||typeof e=="function"||e===p||e===P||le||e===x||e===O||e===y||ie||e===F||pe||K||W||typeof e=="object"&&e!==null&&(e.$$typeof===N||e.$$typeof===H||e.$$typeof===T||e.$$typeof===I||e.$$typeof===k||e.$$typeof===w||e.getModuleId!==void 0))}function ne(e,s,u){var h=e.displayName;if(h)return h;var b=s.displayName||s.name||"";return b!==""?u+"("+b+")":u}function ce(e){return e.displayName||"Context"}function Z(e){if(e==null)return null;if(typeof e.tag=="number"&&R("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 p:return"Fragment";case C:return"Portal";case P:return"Profiler";case x:return"StrictMode";case O:return"Suspense";case y:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case I:var s=e;return ce(s)+".Consumer";case T:var u=e;return ce(u._context)+".Provider";case k:return ne(e,e.render,"ForwardRef");case H:var h=e.displayName||null;return h!==null?h:Z(e.type)||"Memo";case N:{var b=e,_=b._payload,E=b._init;try{return Z(E(_))}catch{return null}}}return null}var j=Object.assign,L=0,Ce,be,we,oe,ge,A,ve;function ae(){}ae.__reactDisabledLog=!0;function ue(){{if(L===0){Ce=console.log,be=console.info,we=console.warn,oe=console.error,ge=console.group,A=console.groupCollapsed,ve=console.groupEnd;var e={configurable:!0,enumerable:!0,value:ae,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}L++}}function _e(){{if(L--,L===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:j({},e,{value:Ce}),info:j({},e,{value:be}),warn:j({},e,{value:we}),error:j({},e,{value:oe}),group:j({},e,{value:ge}),groupCollapsed:j({},e,{value:A}),groupEnd:j({},e,{value:ve})})}L<0&&R("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var fe=S.ReactCurrentDispatcher,B;function f(e,s,u){{if(B===void 0)try{throw Error()}catch(b){var h=b.stack.trim().match(/\n( *(at )?)/);B=h&&h[1]||""}return`
18
+ `+B+e}}var $=!1,de;{var Y=typeof WeakMap=="function"?WeakMap:Map;de=new Y}function z(e,s){if(!e||$)return"";{var u=de.get(e);if(u!==void 0)return u}var h;$=!0;var b=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var _;_=fe.current,fe.current=null,ue();try{if(s){var E=function(){throw Error()};if(Object.defineProperty(E.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(E,[])}catch(J){h=J}Reflect.construct(e,[],E)}else{try{E.call()}catch(J){h=J}e.call(E.prototype)}}else{try{throw Error()}catch(J){h=J}e()}}catch(J){if(J&&h&&typeof J.stack=="string"){for(var v=J.stack.split(`
19
+ `),q=h.stack.split(`
20
+ `),D=v.length-1,M=q.length-1;D>=1&&M>=0&&v[D]!==q[M];)M--;for(;D>=1&&M>=0;D--,M--)if(v[D]!==q[M]){if(D!==1||M!==1)do if(D--,M--,M<0||v[D]!==q[M]){var re=`
21
+ `+v[D].replace(" at new "," at ");return e.displayName&&re.includes("<anonymous>")&&(re=re.replace("<anonymous>",e.displayName)),typeof e=="function"&&de.set(e,re),re}while(D>=1&&M>=0);break}}}finally{$=!1,fe.current=_,_e(),Error.prepareStackTrace=b}var De=e?e.displayName||e.name:"",Te=De?f(De):"";return typeof e=="function"&&de.set(e,Te),Te}function Pe(e,s,u){return z(e,!1)}function Le(e){var s=e.prototype;return!!(s&&s.isReactComponent)}function me(e,s,u){if(e==null)return"";if(typeof e=="function")return z(e,Le(e));if(typeof e=="string")return f(e);switch(e){case O:return f("Suspense");case y:return f("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case k:return Pe(e.render);case H:return me(e.type,s,u);case N:{var h=e,b=h._payload,_=h._init;try{return me(_(b),s,u)}catch{}}}return""}var ye=Object.prototype.hasOwnProperty,Be={},ke=S.ReactDebugCurrentFrame;function Se(e){if(e){var s=e._owner,u=me(e.type,e._source,s?s.type:null);ke.setExtraStackFrame(u)}else ke.setExtraStackFrame(null)}function je(e,s,u,h,b){{var _=Function.call.bind(ye);for(var E in e)if(_(e,E)){var v=void 0;try{if(typeof e[E]!="function"){var q=Error((h||"React class")+": "+u+" type `"+E+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[E]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw q.name="Invariant Violation",q}v=e[E](s,E,h,u,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(D){v=D}v&&!(v instanceof Error)&&(Se(b),R("%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).",h||"React class",u,E,typeof v),Se(null)),v instanceof Error&&!(v.message in Be)&&(Be[v.message]=!0,Se(b),R("Failed %s type: %s",u,v.message),Se(null))}}}var et=Array.isArray;function Ae(e){return et(e)}function tt(e){{var s=typeof Symbol=="function"&&Symbol.toStringTag,u=s&&e[Symbol.toStringTag]||e.constructor.name||"Object";return u}}function rt(e){try{return We(e),!1}catch{return!0}}function We(e){return""+e}function Ze(e){if(rt(e))return R("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",tt(e)),We(e)}var Ye=S.ReactCurrentOwner,Oe={key:!0,ref:!0,__self:!0,__source:!0},Re,ze;function nt(e){if(ye.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(ye.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"&&Ye.current}function ot(e,s){{var u=function(){Re||(Re=!0,R("%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 qe(e,s){{var u=function(){ze||(ze=!0,R("%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 Ue=function(e,s,u,h,b,_,E){var v={$$typeof:c,type:e,key:s,ref:u,props:E,_owner:_};return v._store={},Object.defineProperty(v._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(v,"_self",{configurable:!1,enumerable:!1,writable:!1,value:h}),Object.defineProperty(v,"_source",{configurable:!1,enumerable:!1,writable:!1,value:b}),Object.freeze&&(Object.freeze(v.props),Object.freeze(v)),v};function Ke(e,s,u,h,b){{var _,E={},v=null,q=null;u!==void 0&&(Ze(u),v=""+u),at(s)&&(Ze(s.key),v=""+s.key),nt(s)&&(q=s.ref,it(s,b));for(_ in s)ye.call(s,_)&&!Oe.hasOwnProperty(_)&&(E[_]=s[_]);if(e&&e.defaultProps){var D=e.defaultProps;for(_ in D)E[_]===void 0&&(E[_]=D[_])}if(v||q){var M=typeof e=="function"?e.displayName||e.name||"Unknown":e;v&&ot(E,M),q&&qe(E,M)}return Ue(e,v,q,b,h,Ye.current,E)}}var Me=S.ReactCurrentOwner,Ge=S.ReactDebugCurrentFrame;function Ee(e){if(e){var s=e._owner,u=me(e.type,e._source,s?s.type:null);Ge.setExtraStackFrame(u)}else Ge.setExtraStackFrame(null)}var Ve;Ve=!1;function Ne(e){return typeof e=="object"&&e!==null&&e.$$typeof===c}function t(){{if(Me.current){var e=Z(Me.current.type);if(e)return`
22
+
23
+ Check the render method of \``+e+"`."}return""}}function r(e){return""}var n={};function i(e){{var s=t();if(!s){var u=typeof e=="string"?e:e.displayName||e.name;u&&(s=`
24
+
25
+ Check the top-level render call using <`+u+">.")}return s}}function a(e,s){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var u=i(s);if(n[u])return;n[u]=!0;var h="";e&&e._owner&&e._owner!==Me.current&&(h=" It was passed a child from "+Z(e._owner.type)+"."),Ee(e),R('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',u,h),Ee(null)}}function m(e,s){{if(typeof e!="object")return;if(Ae(e))for(var u=0;u<e.length;u++){var h=e[u];Ne(h)&&a(h,s)}else if(Ne(e))e._store&&(e._store.validated=!0);else if(e){var b=he(e);if(typeof b=="function"&&b!==e.entries)for(var _=b.call(e),E;!(E=_.next()).done;)Ne(E.value)&&a(E.value,s)}}}function d(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===k||s.$$typeof===H))u=s.propTypes;else return;if(u){var h=Z(s);je(u,e.props,"prop",h,e)}else if(s.PropTypes!==void 0&&!Ve){Ve=!0;var b=Z(s);R("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",b||"Unknown")}typeof s.getDefaultProps=="function"&&!s.getDefaultProps.isReactClassApproved&&R("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function g(e){{for(var s=Object.keys(e.props),u=0;u<s.length;u++){var h=s[u];if(h!=="children"&&h!=="key"){Ee(e),R("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",h),Ee(null);break}}e.ref!==null&&(Ee(e),R("Invalid attribute `ref` supplied to `React.Fragment`."),Ee(null))}}var V={};function xe(e,s,u,h,b,_){{var E=G(e);if(!E){var v="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(v+=" 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 q=r();q?v+=q:v+=t();var D;e===null?D="null":Ae(e)?D="array":e!==void 0&&e.$$typeof===c?(D="<"+(Z(e.type)||"Unknown")+" />",v=" Did you accidentally export a JSX literal instead of a component?"):D=typeof e,R("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",D,v)}var M=Ke(e,s,u,b,_);if(M==null)return M;if(E){var re=s.children;if(re!==void 0)if(h)if(Ae(re)){for(var De=0;De<re.length;De++)m(re[De],e);Object.freeze&&Object.freeze(re)}else R("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 m(re,e)}if(ye.call(s,"key")){var Te=Z(e),J=Object.keys(s).filter(function(xt){return xt!=="key"}),st=J.length>0?"{key: someKey, "+J.join(": ..., ")+": ...}":"{key: someKey}";if(!V[Te+st]){var Rt=J.length>0?"{"+J.join(": ..., ")+": ...}":"{}";R(`A props object containing a "key" prop is being spread into JSX:
26
+ let props = %s;
27
+ <%s {...props} />
28
+ React keys must be passed directly to JSX without using spread:
29
+ let props = %s;
30
+ <%s key={someKey} {...props} />`,st,Te,Rt,Te),V[Te+st]=!0}}return e===p?g(M):d(M),M}}function Je(e,s,u){return xe(e,s,u,!0)}function Xe(e,s,u){return xe(e,s,u,!1)}var bt=Xe,_t=Je;Ie.Fragment=p,Ie.jsx=bt,Ie.jsxs=_t}()),Ie}process.env.NODE_ENV==="production"?ut.exports=At():ut.exports=Mt();var He=ut.exports;const yt=l=>Qe.createElement("path",l),ft=Qe.forwardRef(({className:l,isPressed:c,...C},p)=>{const x={...C,className:Tt(l,{"is-pressed":c})||void 0,"aria-hidden":!0,focusable:!1};return He.jsx("svg",{...x,ref:p})});ft.displayName="SVG";const Vt=He.jsx(ft,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:He.jsx(yt,{d:"M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z"})}),Nt=He.jsx(ft,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:He.jsx(yt,{d:"M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z"})}),$t="_file-picker-tree_3rwm2_1",It="_file-node-button_3rwm2_17",Ht="_selected_3rwm2_53",Lt="_focused_3rwm2_65",Bt="_dropTarget_3rwm2_70",Wt="_dropTargetInvalid_3rwm2_79",Zt="_renaming_3rwm2_88",Yt="_renameInput_3rwm2_93",zt="_file-name_3rwm2_108",Q={filePickerTree:$t,fileNodeButton:It,selected:Ht,focused:Lt,dropTarget:Bt,dropTargetInvalid:Wt,renaming:Zt,renameInput:Yt,fileName:zt};function lt(l){if(!l)return[];const c=l.replaceAll(/\\+/g,"/").replace(/\/{2,}/g,"/").replace(/\/$/,"")||l,C=c.startsWith("/"),p=c.split("/").filter(Boolean),x=[];let P=C?"/":"";C&&x.push("/");for(const T of p)!P||P==="/"?P=P==="/"?`/${T}`:T:P=`${P}/${T}`,x.push(P);return x}function qt(l,c){if(!l||!c||l===c)return!1;const C=l==="/"?"/":l.replace(/\/{2,}/g,"/"),p=c.replace(/\/{2,}/g,"/");return C==="/"?p.startsWith("/")&&p!=="/":p.startsWith(`${C}/`)}function ct(l,c,C){return l&&(l===c?C:l.startsWith(c==="/"?"/":`${c}/`)?C+l.slice(c.length):l)}const Et=o.forwardRef(function({filesystem:c,root:C="/wordpress",initialSelectedPath:p,onSelect:x=()=>{}},P){const T=o.useMemo(()=>{let t=(C||"/").replace(/\\+/g,"/");return t.startsWith("/")||(t=`/${t}`),t=t.replace(/\/{2,}/g,"/"),t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),t||"/"},[C]),I=t=>!t||t==="."||t===".."?!1:!/[\\/]/.test(t),[k,O]=o.useState(()=>{if(!p)return{};const t={};for(const r of lt(p))t[r]=!0;return t}),[y,H]=o.useState(()=>p??null),[N,F]=o.useState(()=>p??null),[te,U]=o.useState({}),[he,S]=o.useState({}),[R,se]=o.useState(null),[pe,K]=o.useState(null),W=o.useRef({}),ie=o.useRef(!1),le=o.useRef(null),w=o.useRef(null),G=o.useRef(he),ne=o.useRef(te),ce=()=>{for(const t of Object.keys(W.current))clearTimeout(W.current[t]),delete W.current[t]},Z=t=>{const r=W.current[t];r&&(clearTimeout(r),delete W.current[t])};o.useEffect(()=>{G.current=he},[he]),o.useEffect(()=>{ne.current=te},[te]);const j=t=>{var n;const r=(n=le.current)==null?void 0:n.querySelector(`[data-path="${t}"]`);r&&typeof r.focus=="function"&&r.focus()},L=(t,r="")=>(r?`${r}/${t.name}`:t.name).replaceAll(/\\+/g,"/").replace(/\/{2,}/g,"/"),Ce=(t,r)=>t.children?t.children:te[r],be=async(t,r)=>{const n=await t.listFiles(r),i=[];for(const a of n){const m=r==="/"?`/${a}`:`${r}/${a}`,d=await t.isDir(m);i.push({name:a,type:d?"folder":"file"})}return i.sort((a,m)=>a.type!==m.type?a.type==="folder"?-1:1:a.name.localeCompare(m.name)),i},we=async t=>await be(c,t),oe=(t,r)=>{if(r.type!=="folder")return r.children;const n=r.children??ne.current[t];return n||G.current[t]?n:(S(i=>({...i,[t]:!0})),new Promise(i=>{we(t).then(a=>{U(m=>({...m,[t]:a??[]})),i(a??[])}).catch(()=>{i([])}).finally(()=>{S(a=>{const m={...a};return delete m[t],m})})}))},ge=(t,r)=>{r.type==="folder"&&(typeof window>"u"||W.current[t]||(W.current[t]=window.setTimeout(()=>{O(n=>n[t]?n:{...n,[t]:!0}),oe(t,r),delete W.current[t]},600)))},A=t=>(S(r=>({...r,[t]:!0})),new Promise(r=>{we(t).then(n=>{U(i=>({...i,[t]:n??[]})),r(n??[])}).catch(()=>{r([])}).finally(()=>{S(n=>{const i={...n};return delete i[t],i})})})),ve=(t,r,n)=>{O(i=>({...i,[t]:n})),n?oe(t,r):U(i=>{if(i[t]===void 0)return i;const a={...i};return delete a[t],a})},ae=async t=>{if(!t)return;const r=lt(t);if(r.length===0)return;O(a=>{const m={...a};for(const d of r)m[d]=!0;return m});let n=[{name:T,type:"folder"}],i="";for(const a of r){const m=n==null?void 0:n.find(g=>L(g,i)===a);if(!m||m.type!=="folder"){i=a,n=[];continue}n=await oe(a,m)??ne.current[a],i=a}},ue=(t,r)=>{if(!t||!r||t===r)return;const n=t==="/"?"/":`${t}/`,i=a=>a===t?r:a.startsWith(n)?r+a.slice(t.length):null;O(a=>{let m=!1;const d={...a};for(const g of Object.keys(a)){const V=i(g);V&&V!==g&&(d[V]=a[g],delete d[g],m=!0)}return m?d:a}),U(a=>{let m=!1;const d={...a};for(const g of Object.keys(a)){const V=i(g);V&&V!==g&&(d[V]=a[g],delete d[g],m=!0)}return m?d:a}),H(a=>a&&(i(a)??a)),F(a=>a&&(i(a)??a))},_e=()=>{se(null),K(null),ce()},fe=(t,r=!0)=>{H(t),r&&x(t)},B=o.useMemo(()=>[{name:T,type:"folder"}],[T]),[f,$]=o.useState(null),[de,Y]=o.useState(null),z=o.useRef(null),Pe=de;o.useImperativeHandle(P,()=>({focusPath:(t,r={})=>{if(!t)return;const{select:n=!0,domFocus:i=!0,notify:a=!1}=r;n&&fe(t,a),F(t),i&&j(t)},selectPath:t=>{t&&(fe(t),F(t),j(t))},getSelectedPath:()=>y,expandToPath:async t=>await ae(t),refresh:async t=>await A(t),remapPath:ue,createFile:async t=>{await Re(t,"file","untitled.php")},createFolder:async t=>{await Re(t,"folder","New Folder")}}),[y,A,ue,ae]);const Le=o.useRef(!1),me=o.useRef(p??null),ye=o.useRef(p);o.useEffect(()=>{ie.current=!1},[T]),o.useEffect(()=>{p&&p!==ye.current?me.current=p:p||(me.current=null),ye.current=p},[p]),o.useEffect(()=>{if(!p||Le.current)return;Le.current=!0;const t=lt(p);O(n=>{const i={...n};for(const a of t)i[a]=!0;return i});const r=t[t.length-1]||p;F(r),H(r),ae(p)},[p,ae]),o.useEffect(()=>{const t=me.current;!t||B.length===0||(me.current=null,ae(t))},[B,ae]),o.useEffect(()=>{if(!N){if(B.length>0){const t=L(B[0]);F(t)}return}Pe&&Pe===N||j(N)},[B,N,L,Pe,j]),o.useEffect(()=>{if(B.length===0)return;const t=B[0];if((t==null?void 0:t.type)!=="folder"||ie.current)return;const r=t.name;ie.current=!0,O(n=>n[r]?n:{...n,[r]:!0}),!ne.current[r]&&!G.current[r]&&oe(r,t)},[B,oe,T]),o.useEffect(()=>()=>{w.current&&clearTimeout(w.current),ce()},[]);const[Be,ke]=o.useState(""),Se=(t,r)=>{if(t.type==="folder")return r;const n=X.dirname(r);return n&&n||"/"},je=(t,r,n)=>{const i=Se(t,r);if(!i)return{allowed:!1,state:"invalid",destination:null};if(n){if(i===n)return{allowed:!1,state:"invalid",destination:null};if(qt(n,i))return{allowed:!1,state:"invalid",destination:null}}return{allowed:!0,state:"valid",destination:i}},et=(t,r,n)=>{r.type!=="folder"&&r.type!=="file"||(se(n),K(null),t.dataTransfer&&(t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("application/x-wp-playground-path",n),t.dataTransfer.setData("text/plain",n)))},Ae=()=>{_e()},tt=(t,r,n)=>{const i=je(r,n,R);i.allowed&&r.type==="folder"&&ge(n,r),K(a=>(a==null?void 0:a.path)===n&&a.state===i.state?a:{path:n,state:i.state})},rt=(t,r,n)=>{const i=je(r,n,R);i.allowed&&i.destination?(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect=R?"move":"copy"),r.type==="folder"&&ge(n,r),K(a=>(a==null?void 0:a.path)===n&&a.state===i.state?a:{path:n,state:i.state})):(t.dataTransfer&&(t.dataTransfer.dropEffect="none"),Z(n),K(a=>(a==null?void 0:a.path)===n&&a.state==="invalid"?a:{path:n,state:"invalid"}))},We=(t,r,n)=>{Z(n);const i=t.relatedTarget;i&&t.currentTarget.contains(i)||K(a=>(a==null?void 0:a.path)===n?null:a)},Ze=async(t,r,n)=>{const i=R,a=je(r,n,i);if(!a.allowed||!a.destination){_e();return}t.preventDefault(),t.stopPropagation(),Z(n),K(null);try{i?await at(i,a.destination):await Me(t,a.destination)}finally{_e()}},Ye=(t,r,n)=>{t.preventDefault(),t.stopPropagation(),Y(null),$({absPath:n,type:r.type,x:t.clientX,y:t.clientY})},Oe=async(t,r)=>{let n=r,i=0;const a=d=>{const g=d.lastIndexOf(".");return g>0?{stem:d.slice(0,g),ext:d.slice(g)}:{stem:d,ext:""}},m=t==="/"?"":t;for(;await(c==null?void 0:c.fileExists(`${m}/${n}`))||await(c==null?void 0:c.isDir(`${m}/${n}`));){i+=1;const{stem:d,ext:g}=a(r);n=`${d} (${i})${g}`}return n},Re=async(t,r,n)=>{if(!c)return;let i=t||y||T;try{await c.isDir(i)||(i=X.dirname(i))}catch{i=X.dirname(i)}const a=i,m=await Oe(a,n),d=X.joinPaths(a,m);r==="folder"?await c.mkdir(d):await c.writeFile(d,""),z.current={type:r,tempPath:d},Y(d),await A(a),setTimeout(()=>{F(d),j(d)},0)},ze=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},nt=async t=>{if(c)try{await c.mkdir(t)}catch(r){if(!await c.isDir(t).catch(()=>!1))throw r}},at=async(t,r)=>{if(!c)return;const n=X.basename(t),i=X.joinPaths(r,n);if(i===t||await ze(i))return;const a=X.dirname(t);try{await c.mv(t,i),ue(t,i);const m=ct(y,t,i);y&&(y===t||y.startsWith(`${t}/`))&&x(m),F(d=>ct(d,t,i)),O(d=>({...d,[r]:!0})),await Promise.all([A(a),A(r)]),H(d=>ct(d,t,i)),j(i)}catch{}},it=t=>{const r=t;return r.webkitGetAsEntry?r.webkitGetAsEntry():null},ot=t=>new Promise((r,n)=>{t.file(r,n)}),qe=async(t,r)=>{if(!c)return;const n=t.name||"untitled",i=await Oe(r,n),a=X.joinPaths(r,i),m=new Uint8Array(await t.arrayBuffer());await c.writeFile(a,m)},Ue=async(t,r)=>{const n=await ot(t);await qe(n,r)},Ke=async(t,r)=>{const n=await Oe(r,t.name||"New Folder"),i=X.joinPaths(r,n);await nt(i);const a=t.createReader(),m=()=>new Promise((d,g)=>{a.readEntries(V=>d(Array.from(V)),g)});for(;;){const d=await m();if(!d.length)break;for(const g of d)g.isFile?await Ue(g,i):g.isDirectory&&await Ke(g,i)}},Me=async(t,r)=>{var a,m;if(!c)return;const i=((a=t.dataTransfer)!=null&&a.items?Array.from(t.dataTransfer.items):[]).filter(d=>d.kind==="file").map(d=>it(d)).filter(d=>!!d);if(i.length>0)for(const d of i)d.isFile?await Ue(d,r):d.isDirectory&&await Ke(d,r);else{const d=(m=t.dataTransfer)!=null&&m.files?Array.from(t.dataTransfer.files):[];for(const g of d)await qe(g,r)}await A(r),O(d=>({...d,[r]:!0}))},Ge=async(t,r)=>{if(!c)return;const n=t;$(null);try{r==="folder"?await c.rmdir(n,{recursive:!0}):await c.unlink(n)}catch{}finally{Y(null);const i=X.dirname(n);await A(i),y&&(y===n||y.startsWith(`${n}/`))&&x(null)}},Ee=t=>{var r;if(t.key.length===1&&t.key.match(/\S/)){const n=Be+t.key.toLowerCase();if(ke(n),w.current&&clearTimeout(w.current),w.current=setTimeout(()=>{ke("")},1e3),!le.current)return;const i=Array.from(le.current.querySelectorAll(".file-node-button")),a=document.activeElement;let m=0;a&&i.includes(a)&&(m=i.indexOf(a));for(let d=0;d<i.length;d++){const g=(m+d)%i.length,V=i[g];if((r=V.textContent)!=null&&r.toLowerCase().trim().startsWith(n)){V.focus();const xe=V.getAttribute("data-path");xe&&F(xe);break}}}else ke(""),w.current&&clearTimeout(w.current)},Ve=async(t,r)=>{const n=z.current,i=(n==null?void 0:n.tempPath)===t,a=X.dirname(t),m=(r||"").trim();if(!I(m)){if(i){try{n.type==="folder"?await c.rmdir(t,{recursive:!0}):await c.unlink(t)}catch{}z.current=null}Y(i?null:t);return}let d=X.joinPaths(a,m),g=d;if(g===t){Y(null),i&&(z.current=null),setTimeout(()=>{F(g),j(g)},0);return}const V=await c.fileExists(g),xe=await c.isDir(g);if((V||xe)&&g!==t)if(i)try{const Xe=await Oe(a==="/"?"/":a,m);d=X.joinPaths(a,Xe),g=d}catch{}else{Y(t);return}let Je=(n==null?void 0:n.type)==="folder";try{await c.mv(t,d),n||(Je=await c.isDir(d)),Je&&ue(t,g),y===t&&x(g),await A(a),F(g),j(g)}catch{if(i)try{(n==null?void 0:n.type)==="folder"?await c.rmdir(t,{recursive:!0}):await c.unlink(t)}catch{}}finally{z.current=null,Y(null)}},Ne=async t=>{const r=z.current;if(!c||(r==null?void 0:r.tempPath)!==t){Y(i=>i===t?null:i);return}try{r.type==="folder"?await c.rmdir(t,{recursive:!0}):await c.unlink(t)}catch{}z.current=null,Y(null);const n=X.dirname(t);await A(n),F(n),j(n)};return o.createElement("div",{onKeyDown:Ee,ref:le},o.createElement(ee.__experimentalTreeGrid,{className:Q.filePickerTree},B.map((t,r)=>o.createElement(Ct,{key:t.name,node:t,level:0,position:r+1,setSize:B.length,expandedNodePaths:k,onToggle:ve,selectedNode:y,focusPath:n=>F(n),focusedNode:N,selectPath:fe,generatePath:L,getChildren:Ce,onContextMenu:Ye,renamingPath:Pe,onRename:Ve,onRenameCancel:Ne,dropIndicator:pe,onDragStart:et,onDragEnd:Ae,onDragEnter:tt,onDragOver:rt,onDragLeave:We,onDrop:Ze,rootPath:T}))),f&&o.createElement(ee.Popover,{placement:"bottom-start",onClose:()=>$(null),anchor:{getBoundingClientRect:()=>({x:f.x,y:f.y,width:0,height:0,top:f.y,left:f.x,right:f.x,bottom:f.y,toJSON:()=>({})}),ownerDocument:document},noArrow:!0,resize:!1,focusOnMount:"firstElement"},o.createElement(ee.NavigableMenu,{role:"menu"},f.type==="folder"&&o.createElement(ee.MenuItem,{role:"menuitem",onClick:async()=>{$(null),await Re(f.absPath,"file","untitled.php")}},"Create file"),f.type==="folder"&&o.createElement(ee.MenuItem,{role:"menuitem",onClick:async()=>{$(null),await Re(f.absPath,"folder","New Folder")}},"Create directory"),o.createElement(ee.MenuItem,{role:"menuitem",onClick:()=>{$(null),Y(f.absPath)}},"Rename"),o.createElement(ee.MenuItem,{role:"menuitem",onClick:()=>Ge(f.absPath,f.type)},"Delete"))))}),Ct=({node:l,level:c,position:C,setSize:p,expandedNodePaths:x,onToggle:P,selectedNode:T,focusPath:I,focusedNode:k,selectPath:O,generatePath:y,getChildren:H,onContextMenu:N,renamingPath:F,onRename:te,onRenameCancel:U,parentPath:he="",dropIndicator:S,onDragStart:R,onDragEnd:se,onDragEnter:pe,onDragOver:K,onDragLeave:W,onDrop:ie,rootPath:le})=>{const w=y(l,he),G=x[w],ne=F===w,ce=o.useRef(null),[Z,j]=o.useState(l.name),L=o.useRef(!1),Ce=(S==null?void 0:S.path)===w,be=Ce&&(S==null?void 0:S.state)==="valid",we=Ce&&(S==null?void 0:S.state)==="invalid",oe=!ne&&w!==le,ge={onDragEnter:f=>pe==null?void 0:pe(f,l,w),onDragOver:f=>K==null?void 0:K(f,l,w),onDragLeave:f=>W==null?void 0:W(f,l,w),onDrop:f=>ie==null?void 0:ie(f,l,w)},A=H(l,w)??[];o.useEffect(()=>{var f;ne?(j(l.name),L.current=!1,typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame(()=>{var $;($=ce.current)==null||$.select()}):(f=ce.current)==null||f.select()):L.current=!1},[ne,l.name]);const ve=()=>{l.type==="folder"&&P(w,l,!G)},ae=f=>{var $,de,Y;if(f.key==="ArrowLeft")G?ve():($=document.querySelector(`[data-path="${he}"]`))==null||$.focus(),f.preventDefault(),f.stopPropagation();else if(f.key==="ArrowRight"){if(G){if(A!=null&&A.length){const z=y(A[0],w);(de=document.querySelector(`[data-path="${z}"]`))==null||de.focus()}}else ve();f.preventDefault(),f.stopPropagation()}else if(f.key===" "||f.key==="Space"||f.key==="Spacebar")l.type==="folder"&&P(w,l,!G),f.preventDefault();else if(f.key==="Enter"){O(w),I(w);const z=(Y=f.currentTarget)==null?void 0:Y.closest("form");z&&setTimeout(()=>{z.dispatchEvent(new Event("submit",{bubbles:!0}))})}},ue=f=>{N==null||N(f,l,w)},_e=f=>{f.preventDefault(),L.current=!0,te==null||te(w,Z.trim())},fe=f=>{if(f.key==="Escape"){f.preventDefault(),f.stopPropagation(),L.current=!0,U==null||U(w);return}(f.key==="ArrowLeft"||f.key==="ArrowRight"||f.key==="ArrowUp"||f.key==="ArrowDown")&&f.stopPropagation()},B=()=>{L.current||U==null||U(w),L.current=!1};return o.createElement(o.Fragment,null,o.createElement(ee.__experimentalTreeGridRow,{level:c,positionInSet:C,setSize:p},o.createElement(ee.__experimentalTreeGridCell,null,()=>o.createElement(o.Fragment,null,ne?o.createElement("form",{onSubmit:_e,className:dt(Q.fileNodeButton,Q.renaming,"file-node-button",{[Q.selected]:T===w,[Q.focused]:k===w,[Q.dropTarget]:be,[Q.dropTargetInvalid]:we}),"data-path":w,onContextMenu:ue,...ge},o.createElement(wt,{node:l,isOpen:l.type==="folder"&&G,level:c,hideName:!0}),o.createElement("input",{ref:ce,className:Q.renameInput,value:Z,onChange:f=>j(f.target.value),onBlur:B,onFocus:()=>I(w),onKeyDown:fe})):o.createElement(ee.Button,{...ge,draggable:oe,onDragStart:f=>R==null?void 0:R(f,l,w),onDragEnd:f=>se==null?void 0:se(f,l,w),onClick:()=>{l.type==="folder"&&ve(),O(w),I(w)},onKeyDown:ae,onFocus:()=>{I(w)},onContextMenu:ue,className:dt(Q.fileNodeButton,{[Q.selected]:T===w,[Q.focused]:k===w,[Q.dropTarget]:be,[Q.dropTargetInvalid]:we}),"data-path":w,"data-expanded":G?"true":"false"},o.createElement(wt,{node:l,isOpen:l.type==="folder"&&G,level:c}))))),G&&A&&A.map((f,$)=>o.createElement(Ct,{key:f.name,node:f,level:c+1,position:$+1,setSize:A.length,expandedNodePaths:x,onToggle:P,selectedNode:T,focusPath:I,focusedNode:k,selectPath:O,generatePath:y,getChildren:H,onContextMenu:N,renamingPath:F,onRename:te,onRenameCancel:U,parentPath:w,dropIndicator:S,onDragStart:R,onDragEnd:se,onDragEnter:pe,onDragOver:K,onDragLeave:W,onDrop:ie,rootPath:le})))},wt=({node:l,level:c,isOpen:C,hideName:p=!1})=>{const x=[];for(let P=0;P<c;P++)x.push("&nbsp;&nbsp;&nbsp;&nbsp;");return o.createElement(o.Fragment,null,o.createElement("span",{"aria-hidden":"true",dangerouslySetInnerHTML:{__html:x.join("")}}),l.type==="folder"?o.createElement(mt,{width:16,icon:C?Vt:Nt}):o.createElement("div",{style:{width:16}}," "),o.createElement(mt,{width:16,icon:l.type==="folder"?gt:vt}),!p&&o.createElement("span",{className:Q.fileName},l.name))},Ut="_control_kp9d9_1",Kt="_browse-label_kp9d9_11",Gt="_path-preview_kp9d9_37",Jt="_modal_kp9d9_43",Xt="_modal-footer_kp9d9_48",Fe={control:Ut,browseLabel:Kt,pathPreview:Gt,modal:Jt,modalFooter:Xt};function Qt({path:l}){if(!l)return o.createElement("div",{className:Fe.pathPreview},o.createElement("i",null,"Select a path"));const c=l.split("/");let C=(c.length>2?"/":"")+c.pop();C.length>10&&(C=C.substring(C.length-10));const p=l.substring(0,l.length-C.length);return o.createElement("div",{className:Fe.pathPreview,"data-content-start":p,"data-content-end":C})}function er({value:l="",onChange:c,filesystem:C}){const[p,x]=o.useState(!1),P=()=>x(!0),T=()=>x(!1),[I,k]=o.useState(l||null);function O(y){y==null||y.preventDefault(),c(I||""),T()}return o.createElement(o.Fragment,null,o.createElement(ee.Button,{variant:"tertiary",className:Fe.control,onClick:P},o.createElement("span",{className:Fe.browseLabel},"Browse"),o.createElement(Qt,{path:l||""})),p&&o.createElement(ee.Modal,{title:"Select a path ",onRequestClose:T,className:Fe.modal},o.createElement("form",{onSubmit:O},o.createElement(Et,{filesystem:C,initialSelectedPath:l,onSelect:k}),o.createElement("div",{className:Fe.modalFooter},o.createElement(ee.Button,{type:"submit",variant:"primary"},"Select Path")))))}exports.ClockIcon=Ot;exports.FilePickerControl=er;exports.FilePickerTree=Et;exports.SiteManagerIcon=jt;exports.WordPressIcon=St;exports.file=vt;exports.folder=gt;exports.getLogoDataURL=Ft;exports.layout=Dt;exports.playgroundLogo=Pt;exports.temporaryStorage=kt;
2
31
  //# sourceMappingURL=index.cjs.map