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