@wangtaizong/components 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import { _ as L, e as w, c as u, f as O, d as S, S as I, g as k, n as x, h as m, a as g, b as y, j as _ } from "./index-ab265236.js";
2
- import { S as R } from "./base-80a1f760-bfbf5d12.js";
1
+ import { _ as L, e as w, c as u, f as O, d as S, S as I, g as k, n as x, h as m, a as g, b as y, j as _ } from "./index-6afdc2ce.js";
2
+ import { S as R } from "./base-80a1f760-4106f070.js";
3
3
  import "react";
4
4
  var j = (
5
5
  /** @class */
@@ -10,9 +10,9 @@ var k = (e, r, t) => (T(e, r, "read from private field"), t ? t.call(e) : r.get(
10
10
  r instanceof WeakSet ? r.add(e) : r.set(e, t);
11
11
  }, V = (e, r, t, n) => (T(e, r, "write to private field"), n ? n.call(e, t) : r.set(e, t), t);
12
12
  var F = (e, r, t) => (T(e, r, "access private method"), t);
13
- import { _ as se, a as E, b as P, c as A, d as K, n as N } from "./index-ab265236.js";
14
- import { S as oe } from "./base-80a1f760-bfbf5d12.js";
15
- import { c as ae, g as z, r as U, f as ce, w as W, a as de, b as le, E as ue } from "./consoleHook-59e792cb-4a29d8de.js";
13
+ import { _ as se, a as E, b as P, c as A, d as K, n as N } from "./index-6afdc2ce.js";
14
+ import { S as oe } from "./base-80a1f760-4106f070.js";
15
+ import { c as ae, g as z, r as U, f as ce, w as W, a as de, b as le, E as ue } from "./consoleHook-59e792cb-38408587.js";
16
16
  import "react";
17
17
  var he = Object.create, q = Object.defineProperty, fe = Object.getOwnPropertyDescriptor, X = Object.getOwnPropertyNames, pe = Object.getPrototypeOf, me = Object.prototype.hasOwnProperty, ve = (e, r, t) => r in e ? q(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t, b = (e, r) => function() {
18
18
  return r || (0, e[X(e)[0]])((r = { exports: {} }).exports, r), r.exports;
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import Editor from "./components/editor/Editor";
2
- export { Editor };
1
+ import WEditor from "./components/editor/WEditor";
2
+ export { WEditor };
package/dist/index.es.js CHANGED
@@ -1,5 +1,5 @@
1
- import { M as i } from "./index-ab265236.js";
1
+ import { W as i } from "./index-6afdc2ce.js";
2
2
  import "react";
3
3
  export {
4
- i as Editor
4
+ i as WEditor
5
5
  };
package/dist/index.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(xe,P){typeof exports=="object"&&typeof module<"u"?P(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],P):(xe=typeof globalThis<"u"?globalThis:xe||self,P(xe["yodao-ui"]={},xe.React))})(this,function(xe,P){"use strict";var PL=Object.defineProperty;var kL=(xe,P,Ne)=>P in xe?PL(xe,P,{enumerable:!0,configurable:!0,writable:!0,value:Ne}):xe[P]=Ne;var Ze=(xe,P,Ne)=>(kL(xe,typeof P!="symbol"?P+"":P,Ne),Ne),cf=(xe,P,Ne)=>{if(!P.has(xe))throw TypeError("Cannot "+Ne)};var co=(xe,P,Ne)=>(cf(xe,P,"read from private field"),Ne?Ne.call(xe):P.get(xe)),uf=(xe,P,Ne)=>{if(P.has(xe))throw TypeError("Cannot add the same private member more than once");P instanceof WeakSet?P.add(xe):P.set(xe,Ne)},e1=(xe,P,Ne,U)=>(cf(xe,P,"write to private field"),U?U.call(xe,Ne):P.set(xe,Ne),Ne);var Nl=(xe,P,Ne)=>(cf(xe,P,"access private method"),Ne);function Ne(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const U=Ne(P);function uo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Xl={exports:{}},Lr={};/**
1
+ (function(xe,P){typeof exports=="object"&&typeof module<"u"?P(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],P):(xe=typeof globalThis<"u"?globalThis:xe||self,P(xe.wtz={},xe.React))})(this,function(xe,P){"use strict";var PL=Object.defineProperty;var kL=(xe,P,Ne)=>P in xe?PL(xe,P,{enumerable:!0,configurable:!0,writable:!0,value:Ne}):xe[P]=Ne;var Ze=(xe,P,Ne)=>(kL(xe,typeof P!="symbol"?P+"":P,Ne),Ne),cf=(xe,P,Ne)=>{if(!P.has(xe))throw TypeError("Cannot "+Ne)};var co=(xe,P,Ne)=>(cf(xe,P,"read from private field"),Ne?Ne.call(xe):P.get(xe)),uf=(xe,P,Ne)=>{if(P.has(xe))throw TypeError("Cannot add the same private member more than once");P instanceof WeakSet?P.add(xe):P.set(xe,Ne)},e1=(xe,P,Ne,U)=>(cf(xe,P,"write to private field"),U?U.call(xe,Ne):P.set(xe,Ne),Ne);var Nl=(xe,P,Ne)=>(cf(xe,P,"access private method"),Ne);function Ne(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const U=Ne(P);function uo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Xl={exports:{}},Lr={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -757,7 +757,7 @@ declare module "*.vue" {
757
757
  This might be unsupported in the future, please specify 'id' explicitely for every backend.`);else throw new Error("You must specify an 'id' property in your Backend entry: ".concat(JSON.stringify(o),`
758
758
  see this guide: https://github.com/louisbrunner/dnd-multi-backend/tree/master/packages/react-dnd-multi-backend#migrating-from-5xx`));if(ae(this,Wt)[u])throw new Error(`You must specify a unique 'id' property in your Backend entry:
759
759
  `.concat(JSON.stringify(o)," (conflicts with: ").concat(JSON.stringify(ae(this,Wt)[u]),")"));return{id:u,instance:c,preview:(a=o.preview)!==null&&a!==void 0?a:!1,transition:o.transition,skipDispatchOnTransition:(l=o.skipDispatchOnTransition)!==null&&l!==void 0?l:!1}}}),Qn(this,"setup",()=>{if(!(typeof window>"u")){if(Mr.isSetUp)throw new Error("Cannot have two MultiBackends at the same time.");Mr.isSetUp=!0,ae(this,iw).call(this,window),ae(this,Wt)[ae(this,Vt)].instance.setup()}}),Qn(this,"teardown",()=>{typeof window>"u"||(Mr.isSetUp=!1,ae(this,rw).call(this,window),ae(this,Wt)[ae(this,Vt)].instance.teardown())}),Qn(this,"connectDragSource",(r,s,o)=>ae(this,Ql).call(this,"connectDragSource",r,s,o)),Qn(this,"connectDragPreview",(r,s,o)=>ae(this,Ql).call(this,"connectDragPreview",r,s,o)),Qn(this,"connectDropTarget",(r,s,o)=>ae(this,Ql).call(this,"connectDropTarget",r,s,o)),Qn(this,"profile",()=>ae(this,Wt)[ae(this,Vt)].instance.profile()),Qn(this,"previewEnabled",()=>ae(this,Wt)[ae(this,Vt)].preview),Qn(this,"previewsList",()=>ae(this,Tl)),Qn(this,"backendsList",()=>ae(this,mi)),sn(this,iw,{writable:!0,value:r=>{ae(this,mi).forEach(s=>{s.transition&&r.addEventListener(s.transition.event,ae(this,Wp))})}}),sn(this,rw,{writable:!0,value:r=>{ae(this,mi).forEach(s=>{s.transition&&r.removeEventListener(s.transition.event,ae(this,Wp))})}}),sn(this,Wp,{writable:!0,value:r=>{const s=ae(this,Vt);if(ae(this,mi).some(a=>a.id!==ae(this,Vt)&&a.transition&&a.transition.check(r)?(Dr(this,Vt,a.id),!0):!1),ae(this,Vt)!==s){var o;ae(this,Wt)[s].instance.teardown(),Object.keys(ae(this,Bi)).forEach(u=>{const d=ae(this,Bi)[u];d.unsubscribe(),d.unsubscribe=ae(this,qp).call(this,d.func,...d.args)}),ae(this,Tl).backendChanged(this);const a=ae(this,Wt)[ae(this,Vt)];if(a.instance.setup(),a.skipDispatchOnTransition)return;const l=r.constructor,c=new l(r.type,r);(o=r.target)===null||o===void 0||o.dispatchEvent(c)}}}),sn(this,qp,{writable:!0,value:(r,s,o,a)=>ae(this,Wt)[ae(this,Vt)].instance[r](s,o,a)}),sn(this,Ql,{writable:!0,value:(r,s,o,a)=>{const l="".concat(r,"_").concat(s),c=ae(this,qp).call(this,r,s,o,a);return ae(this,Bi)[l]={func:r,args:[s,o,a],unsubscribe:c},()=>{ae(this,Bi)[l].unsubscribe(),delete ae(this,Bi)[l]}}}),!i||!i.backends||i.backends.length<1)throw new Error(`You must specify at least one Backend, if you are coming from 2.x.x (or don't understand this error)
760
- see this guide: https://github.com/louisbrunner/dnd-multi-backend/tree/master/packages/react-dnd-multi-backend#migrating-from-2xx`);Dr(this,Tl,new XI),Dr(this,Wt,{}),Dr(this,mi,[]),i.backends.forEach(r=>{const s=ae(this,nw).call(this,e,n,r);ae(this,Wt)[s.id]=s,ae(this,mi).push(s)}),Dr(this,Vt,ae(this,mi)[0].id),Dr(this,Bi,{})}}Qn(Mr,"isSetUp",!1);const zI=(t,e,n)=>new Mr(t,e,n),sw=(t,e)=>({event:t,check:e}),YI=sw("touchstart",t=>{const e=t;return e.touches!==null&&e.touches!==void 0}),BI=sw("pointerdown",t=>t.pointerType=="mouse");var gi;(function(t){t.mouse="mouse",t.touch="touch",t.keyboard="keyboard"})(gi||(gi={}));class UI{get delay(){var e;return(e=this.args.delay)!==null&&e!==void 0?e:0}get scrollAngleRanges(){return this.args.scrollAngleRanges}get getDropTargetElementsAtPoint(){return this.args.getDropTargetElementsAtPoint}get ignoreContextMenu(){var e;return(e=this.args.ignoreContextMenu)!==null&&e!==void 0?e:!1}get enableHoverOutsideTarget(){var e;return(e=this.args.enableHoverOutsideTarget)!==null&&e!==void 0?e:!1}get enableKeyboardEvents(){var e;return(e=this.args.enableKeyboardEvents)!==null&&e!==void 0?e:!1}get enableMouseEvents(){var e;return(e=this.args.enableMouseEvents)!==null&&e!==void 0?e:!1}get enableTouchEvents(){var e;return(e=this.args.enableTouchEvents)!==null&&e!==void 0?e:!0}get touchSlop(){return this.args.touchSlop||0}get delayTouchStart(){var e,n,i,r;return(r=(i=(e=this.args)===null||e===void 0?void 0:e.delayTouchStart)!==null&&i!==void 0?i:(n=this.args)===null||n===void 0?void 0:n.delay)!==null&&r!==void 0?r:0}get delayMouseStart(){var e,n,i,r;return(r=(i=(e=this.args)===null||e===void 0?void 0:e.delayMouseStart)!==null&&i!==void 0?i:(n=this.args)===null||n===void 0?void 0:n.delay)!==null&&r!==void 0?r:0}get window(){if(this.context&&this.context.window)return this.context.window;if(typeof window<"u")return window}get document(){var e;if(!((e=this.context)===null||e===void 0)&&e.document)return this.context.document;if(this.window)return this.window.document}get rootElement(){var e;return((e=this.args)===null||e===void 0?void 0:e.rootElement)||this.document}constructor(e,n){this.args=e,this.context=n}}function FI(t,e,n,i){return Math.sqrt(Math.pow(Math.abs(n-t),2)+Math.pow(Math.abs(i-e),2))}function GI(t,e,n,i,r){if(!r)return!1;const s=Math.atan2(i-e,n-t)*180/Math.PI+180;for(let o=0;o<r.length;++o){const a=r[o];if(a&&(a.start==null||s>=a.start)&&(a.end==null||s<=a.end))return!0}return!1}const HI={Left:1,Right:2,Center:4},JI={Left:0,Center:1,Right:2};function zp(t){return t.button===void 0||t.button===JI.Left}function KI(t){return t.buttons===void 0||(t.buttons&HI.Left)===0}function ow(t){return!!t.targetTouches}const eZ=1;function tZ(t){const e=t.nodeType===eZ?t:t.parentElement;if(!e)return;const{top:n,left:i}=e.getBoundingClientRect();return{x:i,y:n}}function nZ(t,e){if(t.targetTouches.length===1)return Cl(t.targetTouches[0]);if(e&&t.touches.length===1&&t.touches[0].target===e.target)return Cl(t.touches[0])}function Cl(t,e){return ow(t)?nZ(t,e):{x:t.clientX,y:t.clientY}}const aw=(()=>{let t=!1;try{addEventListener("test",()=>{},Object.defineProperty({},"passive",{get(){return t=!0,!0}}))}catch{}return t})(),io={[gi.mouse]:{start:"mousedown",move:"mousemove",end:"mouseup",contextmenu:"contextmenu"},[gi.touch]:{start:"touchstart",move:"touchmove",end:"touchend"},[gi.keyboard]:{keydown:"keydown"}};class ro{profile(){var e;return{sourceNodes:this.sourceNodes.size,sourcePreviewNodes:this.sourcePreviewNodes.size,sourcePreviewNodeOptions:this.sourcePreviewNodeOptions.size,targetNodes:this.targetNodes.size,dragOverTargetIds:((e=this.dragOverTargetIds)===null||e===void 0?void 0:e.length)||0}}get document(){return this.options.document}setup(){const e=this.options.rootElement;e&&(oe(!ro.isSetUp,"Cannot have two Touch backends at the same time."),ro.isSetUp=!0,this.addEventListener(e,"start",this.getTopMoveStartHandler()),this.addEventListener(e,"start",this.handleTopMoveStartCapture,!0),this.addEventListener(e,"move",this.handleTopMove),this.addEventListener(e,"move",this.handleTopMoveCapture,!0),this.addEventListener(e,"end",this.handleTopMoveEndCapture,!0),this.options.enableMouseEvents&&!this.options.ignoreContextMenu&&this.addEventListener(e,"contextmenu",this.handleTopMoveEndCapture),this.options.enableKeyboardEvents&&this.addEventListener(e,"keydown",this.handleCancelOnEscape,!0))}teardown(){const e=this.options.rootElement;e&&(ro.isSetUp=!1,this._mouseClientOffset={},this.removeEventListener(e,"start",this.handleTopMoveStartCapture,!0),this.removeEventListener(e,"start",this.handleTopMoveStart),this.removeEventListener(e,"move",this.handleTopMoveCapture,!0),this.removeEventListener(e,"move",this.handleTopMove),this.removeEventListener(e,"end",this.handleTopMoveEndCapture,!0),this.options.enableMouseEvents&&!this.options.ignoreContextMenu&&this.removeEventListener(e,"contextmenu",this.handleTopMoveEndCapture),this.options.enableKeyboardEvents&&this.removeEventListener(e,"keydown",this.handleCancelOnEscape,!0),this.uninstallSourceNodeRemovalObserver())}addEventListener(e,n,i,r=!1){const s=aw?{capture:r,passive:!1}:r;this.listenerTypes.forEach(function(o){const a=io[o][n];a&&e.addEventListener(a,i,s)})}removeEventListener(e,n,i,r=!1){const s=aw?{capture:r,passive:!1}:r;this.listenerTypes.forEach(function(o){const a=io[o][n];a&&e.removeEventListener(a,i,s)})}connectDragSource(e,n){const i=this.handleMoveStart.bind(this,e);return this.sourceNodes.set(e,n),this.addEventListener(n,"start",i),()=>{this.sourceNodes.delete(e),this.removeEventListener(n,"start",i)}}connectDragPreview(e,n,i){return this.sourcePreviewNodeOptions.set(e,i),this.sourcePreviewNodes.set(e,n),()=>{this.sourcePreviewNodes.delete(e),this.sourcePreviewNodeOptions.delete(e)}}connectDropTarget(e,n){const i=this.options.rootElement;if(!this.document||!i)return()=>{};const r=s=>{if(!this.document||!i||!this.monitor.isDragging())return;let o;switch(s.type){case io.mouse.move:o={x:s.clientX,y:s.clientY};break;case io.touch.move:var a,l;o={x:((a=s.touches[0])===null||a===void 0?void 0:a.clientX)||0,y:((l=s.touches[0])===null||l===void 0?void 0:l.clientY)||0};break}const c=o!=null?this.document.elementFromPoint(o.x,o.y):void 0,u=c&&n.contains(c);if(c===n||u)return this.handleMove(s,e)};return this.addEventListener(this.document.body,"move",r),this.targetNodes.set(e,n),()=>{this.document&&(this.targetNodes.delete(e),this.removeEventListener(this.document.body,"move",r))}}getTopMoveStartHandler(){return!this.options.delayTouchStart&&!this.options.delayMouseStart?this.handleTopMoveStart:this.handleTopMoveStartDelay}installSourceNodeRemovalObserver(e){this.uninstallSourceNodeRemovalObserver(),this.draggedSourceNode=e,this.draggedSourceNodeRemovalObserver=new MutationObserver(()=>{e&&!e.parentElement&&(this.resurrectSourceNode(),this.uninstallSourceNodeRemovalObserver())}),!(!e||!e.parentElement)&&this.draggedSourceNodeRemovalObserver.observe(e.parentElement,{childList:!0})}resurrectSourceNode(){this.document&&this.draggedSourceNode&&(this.draggedSourceNode.style.display="none",this.draggedSourceNode.removeAttribute("data-reactid"),this.document.body.appendChild(this.draggedSourceNode))}uninstallSourceNodeRemovalObserver(){this.draggedSourceNodeRemovalObserver&&this.draggedSourceNodeRemovalObserver.disconnect(),this.draggedSourceNodeRemovalObserver=void 0,this.draggedSourceNode=void 0}constructor(e,n,i){this.getSourceClientOffset=r=>{const s=this.sourceNodes.get(r);return s&&tZ(s)},this.handleTopMoveStartCapture=r=>{zp(r)&&(this.moveStartSourceIds=[])},this.handleMoveStart=r=>{Array.isArray(this.moveStartSourceIds)&&this.moveStartSourceIds.unshift(r)},this.handleTopMoveStart=r=>{if(!zp(r))return;const s=Cl(r);s&&(ow(r)&&(this.lastTargetTouchFallback=r.targetTouches[0]),this._mouseClientOffset=s),this.waitingForDelay=!1},this.handleTopMoveStartDelay=r=>{if(!zp(r))return;const s=r.type===io.touch.start?this.options.delayTouchStart:this.options.delayMouseStart;this.timeout=setTimeout(this.handleTopMoveStart.bind(this,r),s),this.waitingForDelay=!0},this.handleTopMoveCapture=()=>{this.dragOverTargetIds=[]},this.handleMove=(r,s)=>{this.dragOverTargetIds&&this.dragOverTargetIds.unshift(s)},this.handleTopMove=r=>{if(this.timeout&&clearTimeout(this.timeout),!this.document||this.waitingForDelay)return;const{moveStartSourceIds:s,dragOverTargetIds:o}=this,a=this.options.enableHoverOutsideTarget,l=Cl(r,this.lastTargetTouchFallback);if(!l)return;if(this._isScrolling||!this.monitor.isDragging()&&GI(this._mouseClientOffset.x||0,this._mouseClientOffset.y||0,l.x,l.y,this.options.scrollAngleRanges)){this._isScrolling=!0;return}if(!this.monitor.isDragging()&&this._mouseClientOffset.hasOwnProperty("x")&&s&&FI(this._mouseClientOffset.x||0,this._mouseClientOffset.y||0,l.x,l.y)>(this.options.touchSlop?this.options.touchSlop:0)&&(this.moveStartSourceIds=void 0,this.actions.beginDrag(s,{clientOffset:this._mouseClientOffset,getSourceClientOffset:this.getSourceClientOffset,publishSource:!1})),!this.monitor.isDragging())return;const c=this.sourceNodes.get(this.monitor.getSourceId());this.installSourceNodeRemovalObserver(c),this.actions.publishDragSource(),r.cancelable&&r.preventDefault();const u=(o||[]).map(h=>this.targetNodes.get(h)).filter(h=>!!h),d=this.options.getDropTargetElementsAtPoint?this.options.getDropTargetElementsAtPoint(l.x,l.y,u):this.document.elementsFromPoint(l.x,l.y),p=[];for(const h in d){if(!d.hasOwnProperty(h))continue;let m=d[h];for(m!=null&&p.push(m);m;)m=m.parentElement,m&&p.indexOf(m)===-1&&p.push(m)}const f=p.filter(h=>u.indexOf(h)>-1).map(h=>this._getDropTargetId(h)).filter(h=>!!h).filter((h,m,g)=>g.indexOf(h)===m);if(a)for(const h in this.targetNodes){const m=this.targetNodes.get(h);if(c&&m&&m.contains(c)&&f.indexOf(h)===-1){f.unshift(h);break}}f.reverse(),this.actions.hover(f,{clientOffset:l})},this._getDropTargetId=r=>{const s=this.targetNodes.keys();let o=s.next();for(;o.done===!1;){const a=o.value;if(r===this.targetNodes.get(a))return a;o=s.next()}},this.handleTopMoveEndCapture=r=>{if(this._isScrolling=!1,this.lastTargetTouchFallback=void 0,!!KI(r)){if(!this.monitor.isDragging()||this.monitor.didDrop()){this.moveStartSourceIds=void 0;return}r.cancelable&&r.preventDefault(),this._mouseClientOffset={},this.uninstallSourceNodeRemovalObserver(),this.actions.drop(),this.actions.endDrag()}},this.handleCancelOnEscape=r=>{r.key==="Escape"&&this.monitor.isDragging()&&(this._mouseClientOffset={},this.uninstallSourceNodeRemovalObserver(),this.actions.endDrag())},this.options=new UI(i,n),this.actions=e.getActions(),this.monitor=e.getMonitor(),this.sourceNodes=new Map,this.sourcePreviewNodes=new Map,this.sourcePreviewNodeOptions=new Map,this.targetNodes=new Map,this.listenerTypes=[],this._mouseClientOffset={},this._isScrolling=!1,this.options.enableMouseEvents&&this.listenerTypes.push(gi.mouse),this.options.enableTouchEvents&&this.listenerTypes.push(gi.touch),this.options.enableKeyboardEvents&&this.listenerTypes.push(gi.keyboard)}}const iZ=function(e,n={},i={}){return new ro(e,n,i)};var qt=function(){return qt=Object.assign||function(e){for(var n,i=1,r=arguments.length;i<r;i++){n=arguments[i];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},qt.apply(this,arguments)};function ht(t,e,n){if(n||arguments.length===2)for(var i=0,r=e.length,s;i<r;i++)(s||!(i in e))&&(s||(s=Array.prototype.slice.call(e,0,i)),s[i]=e[i]);return t.concat(s||Array.prototype.slice.call(e))}function rZ(t){var e=t.isVisible,n=t.ease,i=n===void 0?"easeIn":n,r=t.duration,s=t.variants,o=s===void 0?{open:{opacity:1,height:"auto"},close:{opacity:0,height:0}}:s,a=t.children,l=D_({polyfill:nD}),c=l[0],u=l[1].height,d=P.useState(e),p=d[0],f=d[1],h=P.useState(e),m=h[0],g=h[1],O=P.useState(!1),v=O[0],x=O[1],b=function(){x(!1),e||f(!1)};return P.useEffect(function(){x(!0),e?f(!0):g(!1)},[e]),P.useEffect(function(){p&&g(!0)},[u]),P.createElement(j_.div,{style:v?{overflow:"hidden"}:void 0,onAnimationComplete:b,initial:m?"open":"close",animate:m?"open":"close",inherit:!1,variants:o,transition:{ease:i,duration:sZ(u,r)}},P.createElement("div",{ref:c},p&&a))}function sZ(t,e){if(e)return e;if(!t)return 0;var n=t/36;return Math.round((4+10*Math.pow(n,.25)+n/5)*10)/1500}var oZ=function(t,e){return t.text>e.text?1:t.text<e.text?-1:0},so=function(t,e){return t.find(function(n){return n.id===e})},lw=function(t,e,n){if(n===0)return!1;var i=t.find(function(r){return r.id===n});return i===void 0?!1:i.parent===e?!0:lw(t,e,i.parent)},Yp=function(t){return t.id!==void 0&&t.parent!==void 0&&t.text!==void 0},vi=function(t,e,n){var i=n.tree,r=n.rootId,s=n.canDrop;if(t===null){if(e===r)return!0;var o=i.find(function(u){return u.id===e});return!!(o&&o.droppable)}else{var a=Yp(t)?t.id:null;if(s){var l=s(a,e);if(l!==void 0)return l}if(a===e)return!1;var c=i.find(function(d){return d.id===a}),o=i.find(function(d){return d.id===e});return c===void 0||a===null?e===r||!!(o!=null&&o.droppable):o===void 0?c.parent!==0:c.parent===e||!o.droppable?!1:!lw(i,a,e)}},aZ=function(t,e,n){return t.map(function(i){return i.id===e?qt(qt({},i),{parent:n}):i})},cw=function(t,e,n){if(n===0)return 0;var i=t.filter(function(r){return r.parent===e});return i[n]?t.findIndex(function(r){return r.id===i[n].id}):t.findIndex(function(r){return r.id===i[n-1].id})+1},lZ=function(t,e){return t.findIndex(function(n){return n.id===e})},uw=function(t,e,n,i){var r=lZ(t,e),s=cw(t,n,i);return s=s>r?s-1:s,[r,s]},cZ=function(t,e,n){var i=e<0?t.length+e:e;if(i>=0&&i<t.length){var r=n<0?t.length+n:n,s=t.splice(e,1)[0];t.splice(r,0,s)}},uZ=function(t,e,n,i){var r=uw(t,e,n,i),s=r[0],o=r[1],a=ht([],t,!0);return cZ(a,s,o),a.map(function(l){return l.id===e?qt(qt({},l),{parent:n}):l})},dZ=function(t,e){var n=t.getBoundingClientRect(),i=n.top+n.height/2;return e>i?"down":"up"},Bp=function(t,e){var n="",i=0;return t.forEach(function(r,s){var o,a=dZ(r,((o=e.getClientOffset())===null||o===void 0?void 0:o.y)||0);n===""?n=a:n!==a&&(n=a,i=s),s===t.length-1&&a==="down"&&(i=s+1)}),i},dw=function(t,e,n){var i=e.closest('[role="list"]'),r=i==null?void 0:i.querySelectorAll(':scope > [role="listitem"]');return r?Bp(r,n):null},pZ=function(t,e,n){var i=t.getBoundingClientRect(),r=n.dropTargetOffset,s=i.top+r,o=i.bottom-r;return e>o?"lower":e<s?"upper":"middle"},Up=function(t,e,n,i){var r;if(!e)return null;if(t===null){var s=e.querySelectorAll(':scope > [role="listitem"]');return{id:i.rootId,index:Bp(s,n)}}var o=n.getItem(),a=e.querySelector('[role="list"]'),l=pZ(e,((r=n.getClientOffset())===null||r===void 0?void 0:r.y)||0,i);if(a){if(l==="upper")if(vi(o,t.parent,i)){var c=dw(t,e,n);return c===null?null:{id:t.parent,index:c}}else return{id:t.id,index:0};var s=a.querySelectorAll(':scope > [role="listitem"]');return{id:t.id,index:Bp(s,n)}}else{if(l==="middle")return{id:t.id,index:0};if(vi(o,t.parent,i)){var c=dw(t,e,n);return c===null?null:{id:t.parent,index:c}}return null}},fZ=function(t){return t===void 0&&(t={}),{backends:[{id:"html5",backend:RA,options:t.html5,transition:BI},{id:"touch",backend:iZ,options:t.touch||{enableMouseEvents:!0},preview:!0,transition:YI}]}},El=function(t,e){return t.some(function(n){return n.parent===e})},pw=P.createContext({}),hZ=function(t){var e=SZ(t.tree,t.initialOpen),n=e[0],i=e[1],r=i.handleToggle,s=i.handleCloseAll,o=i.handleOpenAll,a=i.handleOpen,l=i.handleClose;P.useImperativeHandle(t.treeRef,function(){return{open:function(f){return a(f,t.onChangeOpen)},close:function(f){return l(f,t.onChangeOpen)},openAll:function(){return o(t.onChangeOpen)},closeAll:function(){return s(t.onChangeOpen)}}});var c=Vn().getMonitor(),u=t.canDrop,d=t.canDrag,p=qt(qt({extraAcceptTypes:[],listComponent:"ul",listItemComponent:"li",placeholderComponent:"li",sort:!0,insertDroppableFirst:!0,enableAnimateExpand:!1,dropTargetOffset:0,initialOpen:!1},t),{openIds:n,onDrop:function(f,h,m){if(f){var g={dragSourceId:f.id,dropTargetId:h,dragSource:f,dropTarget:so(t.tree,h),monitor:c},O=t.tree;if(so(O,f.id)||(O=ht(ht([],O,!0),[f],!1)),t.sort===!1){var v=uw(O,f.id,h,m),x=v[1];g.destinationIndex=x,g.relativeIndex=m,t.onDrop(uZ(O,f.id,h,m),g);return}t.onDrop(aZ(O,f.id,h),g)}else{var g={dropTargetId:h,dropTarget:so(t.tree,h),monitor:c};t.sort===!1&&(g.destinationIndex=cw(t.tree,h,m),g.relativeIndex=m),t.onDrop(t.tree,g)}},canDrop:u?function(f,h){return u(t.tree,{dragSourceId:f??void 0,dropTargetId:h,dragSource:c.getItem(),dropTarget:so(t.tree,h),monitor:c})}:void 0,canDrag:d?function(f){return d(so(t.tree,f))}:void 0,onToggle:function(f){return r(f,t.onChangeOpen)}});return P.createElement(pw.Provider,{value:p},t.children)},fw=P.createContext({}),mZ={isLock:!1},gZ=function(t){var e=P.useState(mZ.isLock),n=e[0],i=e[1];return P.createElement(fw.Provider,{value:{isLock:n,lock:function(){return i(!0)},unlock:function(){return i(!1)}}},t.children)},oo=P.createContext({}),jl={dropTargetId:void 0,index:void 0},vZ=function(t){var e=P.useState(jl.dropTargetId),n=e[0],i=e[1],r=P.useState(jl.index),s=r[0],o=r[1],a=function(c,u){i(c),o(u)},l=function(){i(jl.dropTargetId),o(jl.index)};return P.createElement(oo.Provider,{value:{dropTargetId:n,index:s,showPlaceholder:a,hidePlaceholder:l}},t.children)},OZ=function(t){return P.createElement(hZ,qt({},t),P.createElement(gZ,null,P.createElement(vZ,null,t.children)))},xZ=function(t){var e=P.useContext(fw);P.useEffect(function(){if(t.current){var n=t.current,i=function(u){var d=u.target;(d instanceof HTMLInputElement||d instanceof HTMLTextAreaElement)&&e.lock()},r=function(u){var d=u.target;(d instanceof HTMLInputElement||d instanceof HTMLTextAreaElement)&&e.unlock()},s=function(u){return i(u)},o=function(u){return r(u)},a=function(u){return i(u)},l=function(u){return r(u)},c=new MutationObserver(function(){document.activeElement===document.body&&e.unlock()});return c.observe(n,{subtree:!0,childList:!0}),n.addEventListener("mouseover",s),n.addEventListener("mouseout",o),n.addEventListener("focusin",a),n.addEventListener("focusout",l),function(){c.disconnect(),n.removeEventListener("mouseover",s),n.removeEventListener("mouseout",o),n.removeEventListener("focusin",a),n.removeEventListener("focusout",l)}}},[t,e]),P.useEffect(function(){var n;(n=t.current)===null||n===void 0||n.setAttribute("draggable",e.isLock?"false":"true")},[t,e.isLock])},Al={TREE_ITEM:Symbol()},hw=null,mw=function(t){var e=t.target;if(e instanceof HTMLElement){var n=e.closest('[role="listitem"]');t.currentTarget===n&&(hw=n)}},gw=function(t){return mw(t)},vw=function(t){return mw(t)},bZ=function(t,e){var n=Oi();P.useEffect(function(){var a=e.current;return a==null||a.addEventListener("dragstart",gw),a==null||a.addEventListener("touchstart",vw,{passive:!0}),function(){a==null||a.removeEventListener("dragstart",gw),a==null||a.removeEventListener("touchstart",vw)}},[e]);var i=TI({type:Al.TREE_ITEM,item:function(a){var l=qt({ref:e},t);return n.onDragStart&&n.onDragStart(l,a),l},end:function(a,l){var c=a;n.onDragEnd&&n.onDragEnd(c,l)},canDrag:function(){var a=n.canDrag;return hw!==e.current?!1:a?a(t.id):!0},collect:function(a){return{isDragging:a.isDragging()}}}),r=i[0].isDragging,s=i[1],o=i[2];return[r,s,o]},yZ=function(t){var e=Oi(),n=P.useContext(oo),i=Ky({accept:ht([Al.TREE_ITEM],e.extraAcceptTypes,!0),drop:function(l,c){var u=e.rootId,d=e.onDrop,p=n.dropTargetId,f=n.index;c.isOver({shallow:!0})&&p!==void 0&&f!==void 0&&d(Yp(l)?l:null,u,f),n.hidePlaceholder()},canDrop:function(l,c){var u=e.rootId;return c.isOver({shallow:!0})?l===void 0?!1:vi(l,u,e):!1},hover:function(l,c){if(c.isOver({shallow:!0})){var u=e.rootId,d=n.dropTargetId,p=n.index,f=n.showPlaceholder,h=n.hidePlaceholder,m=Up(null,t.current,c,e);if(m===null||!vi(l,u,e)){h();return}(m.id!==d||m.index!==p)&&f(m.id,m.index)}},collect:function(l){var c=l.getItem();return{isOver:l.isOver({shallow:!0})&&l.canDrop(),dragSource:c}}}),r=i[0],s=r.isOver,o=r.dragSource,a=i[1];return[s,o,a]},wZ=function(t,e){var n=Oi(),i=P.useContext(oo),r=Ky({accept:ht([Al.TREE_ITEM],n.extraAcceptTypes,!0),drop:function(c,u){var d=i.dropTargetId,p=i.index;u.isOver({shallow:!0})&&d!==void 0&&p!==void 0&&n.onDrop(Yp(c)?c:null,d,p),i.hidePlaceholder()},canDrop:function(c,u){if(u.isOver({shallow:!0})){var d=Up(t,e.current,u,n);return d===null?!1:vi(c,d.id,n)}return!1},hover:function(c,u){if(u.isOver({shallow:!0})){var d=i.dropTargetId,p=i.index,f=i.showPlaceholder,h=i.hidePlaceholder,m=Up(t,e.current,u,n);if(m===null||!vi(c,m.id,n)){h();return}(m.id!==d||m.index!==p)&&f(m.id,m.index)}},collect:function(c){var u=c.getItem();return{isOver:c.isOver({shallow:!0})&&c.canDrop(),dragSource:u}}}),s=r[0],o=s.isOver,a=s.dragSource,l=r[1];return[o,a,l]},SZ=function(t,e){var n=P.useMemo(function(){return e===!0?t.filter(function(d){return El(t,d.id)}).map(function(d){return d.id}):Array.isArray(e)?e:[]},[e]),i=P.useState(n),r=i[0],s=i[1];P.useEffect(function(){return s(n)},[e]);var o=function(d,p){var f=r.includes(d)?r.filter(function(h){return h!==d}):ht(ht([],r,!0),[d],!1);s(f),p&&p(f)},a=function(d){s([]),d&&d([])},l=function(d){var p=t.filter(function(f){return El(t,f.id)}).map(function(f){return f.id});s(p),d&&d(p)},c=function(d,p){var f=[];if(Array.isArray(d)){var h=t.filter(function(m){return d.includes(m.id)&&El(t,m.id)});f=ht(ht([],r,!0),h.map(function(m){return m.id}),!0).filter(function(m,g,O){return O.indexOf(m)===g})}else f=r.includes(d)?r:ht(ht([],r,!0),[d],!1);s(f),p&&p(f)},u=function(d,p){var f=r.filter(function(h){return Array.isArray(d)?!d.includes(h):h!==d});s(f),p&&p(f)};return[r,{handleToggle:o,handleCloseAll:a,handleOpenAll:l,handleOpen:c,handleClose:u}]},PZ=function(){return QI(function(t){var e=t.getItemType();return{item:t.getItem(),clientOffset:t.getClientOffset(),isDragging:t.isDragging()&&e===Al.TREE_ITEM}})},Oi=function(){var t=P.useContext(pw);if(!t)throw new Error("useTreeContext must be used under TreeProvider");return t},kZ=function(t,e){var n=Oi(),i=n.rootId,r=n.rootProps,s=n.classes,o=(s==null?void 0:s.container)||"";return e&&(s!=null&&s.dropTarget)&&(o="".concat(o," ").concat(s.dropTarget)),t===i&&(s!=null&&s.root)&&(o="".concat(o," ").concat(s.root)),t===i&&(r!=null&&r.className)&&(o="".concat(o," ").concat(r.className)),o=o.trim(),o},$Z=function(t,e,n){e.current?n(e):n(t),P.useEffect(function(){e.current?n(e):n(t)},[e.current])},TZ=function(t){var e=Oi(),n=P.useContext(oo),i=P.useRef(null),r=P.useRef(null),s=e.tree.find(function(T){return T.id===t.id}),o=e.openIds,a=e.classes,l=e.enableAnimateExpand,c=o.includes(t.id),u=bZ(s,i),d=u[0],p=u[1],f=u[2],h=wZ(s,i),m=h[0],g=h[1],O=h[2];$Z(i,r,p),vi(g,t.id,e)&&O(i),P.useEffect(function(){e.dragPreviewRender?f(MA(),{captureDraggingState:!0}):r.current&&f(i)},[f,e.dragPreviewRender]),xZ(i);var v=function(){return e.onToggle(s.id)},x=e.listItemComponent,b=(a==null?void 0:a.listItem)||"";m&&(a!=null&&a.dropTarget)&&(b="".concat(b," ").concat(a.dropTarget)),d&&(a!=null&&a.draggingSource)&&(b="".concat(b," ").concat(a.draggingSource));var w=e.canDrag?e.canDrag(t.id):!0,y=n.dropTargetId===t.id,k={depth:t.depth,isOpen:c,isDragging:d,isDropTarget:y,draggable:w,hasChild:El(e.tree,t.id),containerRef:i,handleRef:r,onToggle:v};return P.createElement(x,{ref:i,className:b,role:"listitem"},e.render(s,k),l&&k.hasChild&&P.createElement(rZ,{isVisible:c},P.createElement(Fp,{parentId:t.id,depth:t.depth+1})),!l&&k.hasChild&&c&&P.createElement(Fp,{parentId:t.id,depth:t.depth+1}))},Ow=function(t){var e=Oi(),n=e.placeholderRender,i=e.placeholderComponent,r=e.classes,s=P.useContext(oo),o=Vn(),a=o.getMonitor(),l=a.getItem();if(!n||!l)return null;var c=t.dropTargetId===s.dropTargetId&&(t.index===s.index||t.index===void 0&&t.listCount===s.index);return c?P.createElement(i,{className:(r==null?void 0:r.placeholder)||""},n(l,{depth:t.depth})):null},Fp=function(t){var e=Oi(),n=P.useRef(null),i=e.tree.filter(function(m){return m.parent===t.parentId}),r=i,s=typeof e.sort=="function"?e.sort:oZ;if(e.insertDroppableFirst){var o=i.filter(function(m){return m.droppable}),a=i.filter(function(m){return!m.droppable});e.sort===!1?r=ht(ht([],o,!0),a,!0):(o=o.sort(s),a=a.sort(s),r=ht(ht([],o,!0),a,!0))}else e.sort!==!1&&(r=i.sort(s));var l=yZ(n),c=l[0],u=l[1],d=l[2];t.parentId===e.rootId&&vi(u,e.rootId,e)&&d(n);var p=kZ(t.parentId,c),f=e.rootProps||{},h=e.listComponent;return P.createElement(h,qt({ref:n,role:"list"},f,{className:p}),r.map(function(m,g){return P.createElement(P.Fragment,{key:m.id},P.createElement(Ow,{depth:t.depth,listCount:r.length,dropTargetId:t.parentId,index:g}),P.createElement(TZ,{id:m.id,depth:t.depth}))}),P.createElement(Ow,{depth:t.depth,listCount:r.length,dropTargetId:t.parentId}))},QZ={height:"100%",left:0,pointerEvents:"none",position:"fixed",top:0,width:"100%",zIndex:100},CZ=function(t){var e=t.clientOffset;if(!e)return{};var n=e.x,i=e.y,r="translate(".concat(n,"px, ").concat(i,"px)");return{pointerEvents:"none",transform:r}},EZ=function(){var t=Oi(),e=PZ(),n=e.isDragging,i=e.clientOffset;return!n||!i?null:P.createElement("div",{style:QZ},P.createElement("div",{style:CZ(e)},t.dragPreviewRender&&t.dragPreviewRender(e)))};function jZ(t,e){return P.createElement(OZ,qt({},t,{treeRef:e}),t.dragPreviewRender&&P.createElement(EZ,null),P.createElement(Fp,{parentId:t.rootId,depth:0}))}var AZ=P.forwardRef(jZ);const DZ=({onSubmit:t,onBlur:e,isDirectory:n,files:i,currentPath:r="/"})=>{const[s,o]=P.useState(""),a=P.useRef(null),[l,c]=P.useState(!1);P.useEffect(()=>{s&&(i[`${r}/${s}`]||i[`${r}/${s}/`])?c(!0):c(!1)},[s]);const u=f=>{f.preventDefault()},d=()=>{if(s){let f=s;n&&!s.endsWith("/")?f=`${s}/`:s.endsWith("/")&&(f=s.substring(0,-1)),t(f),o("")}else e()},p=f=>{if(l)return;let h=s;n&&!s.endsWith("/")?h=`${s}/`:s.endsWith("/")&&(h=s.substring(0,-1)),f.key==="Enter"&&(f.preventDefault(),t(h),o("")),f.key==="Escape"&&(f.preventDefault(),d())};return S.jsxs("form",{ref:a,onSubmit:u,children:[S.jsx("label",{children:S.jsx("input",{style:{maxWidth:"100%",border:`1px solid ${l?"red":"inherit"}`},onBlur:d,maxLength:35,autoFocus:!0,placeholder:`${n?"Directory name":"File name"}`,name:"name",type:"text",value:s,onChange:f=>o(f.target.value),onKeyDown:p})}),l?S.jsx("span",{style:{display:"block",maxWidth:"100%",background:"var(--sp-colors-errorSurface)",color:"var(--sp-colors-error)",borderRadius:"3px"},children:"File or Directory already exists"}):null]})},xw=({dir:t})=>{const{sandpack:e}=Ce(),{addFile:n}=yx();return S.jsx("span",{style:{cursor:"pointer"},onClick:()=>{const i=e.activeFile.split("/").slice(0,-1).join("/");n({[`${i}/${t?"addDir":"addFile"}`]:{code:".emptyDir",hidden:!0}})},children:t?S.jsx(ZO,{}):S.jsx(NO,{})})},MZ=()=>{const{treeData:t,addFile:e,deleteFile:n,onFileMoved:i,setTreeData:r,openDirs:s,setOpenDirs:o}=yx(),{sandpack:a}=Ce(),l=["/package.json"],c=async(d,p)=>{var m,g,O,v;const f=Ox(a.files),h=`/${Ni({parent:p.dropTargetId,text:((m=p==null?void 0:p.dragSource)==null?void 0:m.text)||p.dragSourceId},d)}`;a.files[h],!([...l,f].includes(((O=(g=p==null?void 0:p.dragSource)==null?void 0:g.data)==null?void 0:O.path)||"")||((v=p.dragSource)==null?void 0:v.parent)===p.dropTargetId||a.files[h])&&(await i({newTree:d,node:p}),r(d))},u=Ox(a.files);return S.jsx(S.Fragment,{children:S.jsx(rI,{backend:zI,options:fZ(),children:S.jsxs("div",{style:{minHeight:"100%",maxHeight:"100%",height:"var(--sp-layout-height)",minWidth:"200px",overflowY:"auto",overflowX:"hidden",position:"relative",display:"flex",flexDirection:"column",padding:"var(--sp-space-1) var(--sp-space-3)",backgroundColor:"var(--sp-colors-surface1, #011627)"},children:[S.jsxs("div",{style:{width:"100%",display:"flex",justifyContent:"space-between",alignItems:"center",minHeight:"40px"},children:[S.jsx("span",{children:"Files"}),S.jsxs("div",{style:{display:"flex"},children:[S.jsx(xw,{}),S.jsx(xw,{dir:!0})]})]}),S.jsx(AZ,{tree:t.filter(({text:d})=>!!d),rootId:"/",onDrop:c,rootProps:{style:{listStyle:"none",padding:"0",height:"100%"}},classes:{root:"test"},enableAnimateExpand:!0,insertDroppableFirst:!0,sort:!0,initialOpen:s,render:(d,{depth:p,isOpen:f})=>{var h,m,g,O;return d.text?S.jsxs("div",{style:{marginLeft:p*10,display:"flex",justifyContent:"space-between",maxWidth:"300px",overflow:"hidden",padding:"var(--sp-space-1) 0",transition:"color var(--sp-transitions-default), background var(--sp-transitions-default)"},children:[d.text.includes("addFile")||d.text.includes("addDir")?S.jsx(DZ,{files:a.files,onBlur:()=>{var v;return n(`${(v=d==null?void 0:d.data)==null?void 0:v.path}`)},isDirectory:d.text.includes("addDir"),currentPath:(h=d==null?void 0:d.data)==null?void 0:h.path.split("/").slice(0,-1).join("/"),onSubmit:async v=>{var w;const b=`${(w=d==null?void 0:d.data)==null?void 0:w.path.split("/").slice(0,-1).join("/")}/${v}`;await e({[b]:{code:d.text.includes("addDir")?".emptyDir":`// ${v}`,hidden:d.text.includes("addDir")}})}}):null,d.text&&!d.text.includes("addFile")&&!d.text.includes("addDir")?S.jsxs(S.Fragment,{children:[d.droppable?S.jsxs("span",{style:{color:"var(--sp-colors-clickable)",display:"flex",cursor:"pointer"},onClick:()=>{o(f?v=>v.filter(x=>x!==d.id):v=>[...v,d.id])},children:[f?S.jsx(ZO,{}):S.jsx(f2,{}),d.text,f?"[-] ":"[+] "]}):S.jsxs("span",{style:{display:"flex"},children:[S.jsx("span",{style:{minWidth:"16px",minHeight:"16px"},children:S.jsx(NO,{})}),S.jsx("span",{style:{textOverflow:"ellipsis",maxWidth:"200px",overflow:"hidden",cursor:"pointer",color:`${((m=d==null?void 0:d.data)==null?void 0:m.path)===a.activeFile?"var(--sp-colors-accent)":"var(--sp-colors-clickable)"}`,display:"flex"},onClick:()=>{var v;return a.openFile((v=d==null?void 0:d.data)==null?void 0:v.path)},children:d.text})]}),[u,"/package.json"].includes(((g=d==null?void 0:d.data)==null?void 0:g.path)??"")?S.jsx("span",{style:{color:"var(--sp-colors-warning)"},children:((O=d==null?void 0:d.data)==null?void 0:O.path)===u?"entry":""}):S.jsx("button",{style:{background:"none",border:"none",cursor:"pointer"},onClick:async()=>{var v;await n(`${(v=d==null?void 0:d.data)==null?void 0:v.path}${d.droppable?"/":""}`)},children:S.jsx(LO,{})})]}):null]},d.id):S.jsx(S.Fragment,{})}})]})})})},RZ=()=>S.jsx("div",{style:{minWidth:150,maxWidth:"300px",overflow:"hidden"},children:S.jsx(MZ,{})}),_Z=t=>S.jsx(bA,{...t,children:S.jsx(RZ,{})}),IZ=({type:t="react",children:e,showConsole:n=!0,files:i,className:r,style:s,...o})=>{const a=P.useRef();return S.jsxs("div",{className:r,style:s,...o,children:[e,S.jsx("button",{onClick:()=>{console.log(a.current)},children:"点击"}),S.jsx(ej,{template:t,theme:"dark",files:i,children:S.jsx(zO,{children:S.jsxs(xj,{children:[S.jsx(_Z,{}),S.jsx(vA,{editorFiles:a}),S.jsxs("div",{children:[S.jsx(eA,{style:{height:n?"60vh":"100vh"},showOpenInCodeSandbox:!1}),n?S.jsx(mA,{style:{height:"40vh",width:"40vw"}}):""]})]})})})]})};var ZZ=Object.create,Gp=Object.defineProperty,NZ=Object.getOwnPropertyDescriptor,bw=Object.getOwnPropertyNames,LZ=Object.getPrototypeOf,XZ=Object.prototype.hasOwnProperty,VZ=(t,e,n)=>e in t?Gp(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Cn=(t,e)=>function(){return e||(0,t[bw(t)[0]])((e={exports:{}}).exports,e),e.exports},WZ=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of bw(e))!XZ.call(t,r)&&r!==n&&Gp(t,r,{get:()=>e[r],enumerable:!(i=NZ(e,r))||i.enumerable});return t},Rr=(t,e,n)=>(n=t!=null?ZZ(LZ(t)):{},WZ(e||!t||!t.__esModule?Gp(n,"default",{value:t,enumerable:!0}):n,t)),qZ=(t,e,n)=>(VZ(t,typeof e!="symbol"?e+"":e,n),n),Hp=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)},zt=(t,e,n)=>(Hp(t,e,"read from private field"),n?n.call(t):e.get(t)),Ui=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},ao=(t,e,n,i)=>(Hp(t,e,"write to private field"),i?i.call(t,n):e.set(t,n),n),on=(t,e,n)=>(Hp(t,e,"access private method"),n),yw=Cn({"../../node_modules/.pnpm/cuid@2.1.8/node_modules/cuid/lib/pad.js"(t,e){e.exports=function(i,r){var s="000000000"+i;return s.substr(s.length-r)}}}),zZ=Cn({"../../node_modules/.pnpm/cuid@2.1.8/node_modules/cuid/lib/fingerprint.browser.js"(t,e){var n=yw(),i=typeof window=="object"?window:self,r=Object.keys(i).length,s=navigator.mimeTypes?navigator.mimeTypes.length:0,o=n((s+navigator.userAgent.length).toString(36)+r.toString(36),4);e.exports=function(){return o}}}),YZ=Cn({"../../node_modules/.pnpm/cuid@2.1.8/node_modules/cuid/lib/getRandomValue.browser.js"(t,e){var n,i=typeof window<"u"&&(window.crypto||window.msCrypto)||typeof self<"u"&&self.crypto;i?(r=Math.pow(2,32)-1,n=function(){return Math.abs(i.getRandomValues(new Uint32Array(1))[0]/r)}):n=Math.random;var r;e.exports=n}}),ww=Cn({"../../node_modules/.pnpm/cuid@2.1.8/node_modules/cuid/index.js"(t,e){var n=zZ(),i=yw(),r=YZ(),s=0,o=4,a=36,l=Math.pow(a,o);function c(){return i((r()*l<<0).toString(a),o)}function u(){return s=s<l?s:0,s++,s-1}function d(){var p="c",f=new Date().getTime().toString(a),h=i(u().toString(a),o),m=n(),g=c()+c();return p+f+h+m+g}d.slug=function(){var f=new Date().getTime().toString(36),h=u().toString(36).slice(-4),m=n().slice(0,1)+n().slice(-1),g=c().slice(-2);return f.slice(-2)+h+m+g},d.isCuid=function(f){return typeof f!="string"?!1:!!f.startsWith("c")},d.isSlug=function(f){if(typeof f!="string")return!1;var h=f.length;return h>=7&&h<=10},d.fingerprint=n,e.exports=d}}),Sw=Cn({"../../node_modules/.pnpm/@open-draft+deferred-promise@2.1.0/node_modules/@open-draft/deferred-promise/build/createDeferredExecutor.js"(t){Object.defineProperty(t,"__esModule",{value:!0}),t.createDeferredExecutor=void 0;function e(){const n=(i,r)=>{n.state="pending",n.resolve=s=>{if(n.state!=="pending")return;n.result=s;const o=a=>(n.state="fulfilled",a);return i(s instanceof Promise?s:Promise.resolve(s).then(o))},n.reject=s=>{if(n.state==="pending")return queueMicrotask(()=>{n.state="rejected"}),r(n.rejectionReason=s)}};return n}t.createDeferredExecutor=e}}),BZ=Cn({"../../node_modules/.pnpm/@open-draft+deferred-promise@2.1.0/node_modules/@open-draft/deferred-promise/build/DeferredPromise.js"(t){var i,r,Ll,o;Object.defineProperty(t,"__esModule",{value:!0}),t.DeferredPromise=void 0;var e=Sw(),n=(o=class extends Promise{constructor(l=null){const c=(0,e.createDeferredExecutor)();super((u,d)=>{c(u,d),l==null||l(c.resolve,c.reject)});uf(this,r);uf(this,i,void 0);Ze(this,"resolve");Ze(this,"reject");e1(this,i,c),this.resolve=co(this,i).resolve,this.reject=co(this,i).reject}get state(){return co(this,i).state}get rejectionReason(){return co(this,i).rejectionReason}then(l,c){return Nl(this,r,Ll).call(this,super.then(l,c))}catch(l){return Nl(this,r,Ll).call(this,super.catch(l))}finally(l){return Nl(this,r,Ll).call(this,super.finally(l))}},i=new WeakMap,r=new WeakSet,Ll=function(l){return Object.defineProperties(l,{resolve:{configurable:!0,value:this.resolve},reject:{configurable:!0,value:this.reject}})},o);t.DeferredPromise=n}}),Jp=Cn({"../../node_modules/.pnpm/@open-draft+deferred-promise@2.1.0/node_modules/@open-draft/deferred-promise/build/index.js"(t){var e=t&&t.__createBinding||(Object.create?function(i,r,s,o){o===void 0&&(o=s);var a=Object.getOwnPropertyDescriptor(r,s);(!a||("get"in a?!r.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return r[s]}}),Object.defineProperty(i,o,a)}:function(i,r,s,o){o===void 0&&(o=s),i[o]=r[s]}),n=t&&t.__exportStar||function(i,r){for(var s in i)s!=="default"&&!Object.prototype.hasOwnProperty.call(r,s)&&e(r,i,s)};Object.defineProperty(t,"__esModule",{value:!0}),n(Sw(),t),n(BZ(),t)}}),Pw=Cn({"../../node_modules/.pnpm/strict-event-emitter@0.4.3/node_modules/strict-event-emitter/lib/MemoryLeakError.js"(t){Object.defineProperty(t,"__esModule",{value:!0}),t.MemoryLeakError=void 0;var e=class extends Error{constructor(i,r,s){super(`Possible EventEmitter memory leak detected. ${s} ${r.toString()} listeners added. Use emitter.setMaxListeners() to increase limit`);Ze(this,"emitter");Ze(this,"type");Ze(this,"count");this.emitter=i,this.type=r,this.count=s,this.name="MaxListenersExceededWarning"}};t.MemoryLeakError=e}}),UZ=Cn({"../../node_modules/.pnpm/strict-event-emitter@0.4.3/node_modules/strict-event-emitter/lib/Emitter.js"(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Emitter=void 0;var e=Pw(),n,i,r,s,o,a,l,c,u,d,p,f=class{constructor(){Ui(this,s),Ui(this,a),Ui(this,c),Ui(this,d),Ui(this,n,void 0),Ui(this,i,void 0),Ui(this,r,void 0),ao(this,n,new Map),ao(this,i,f.defaultMaxListeners),ao(this,r,!1)}static listenerCount(m,g){return m.listenerCount(g)}setMaxListeners(m){return ao(this,i,m),this}getMaxListeners(){return zt(this,i)}eventNames(){return Array.from(zt(this,n).keys())}emit(m,...g){const O=on(this,s,o).call(this,m);return O.forEach(v=>{v.apply(this,g)}),O.length>0}addListener(m,g){on(this,d,p).call(this,"newListener",m,g);const O=on(this,s,o).call(this,m).concat(g);if(zt(this,n).set(m,O),zt(this,i)>0&&this.listenerCount(m)>zt(this,i)&&!zt(this,r)){ao(this,r,!0);const v=new e.MemoryLeakError(this,m,this.listenerCount(m));console.warn(v)}return this}on(m,g){return this.addListener(m,g)}once(m,g){return this.addListener(m,on(this,c,u).call(this,m,g))}prependListener(m,g){const O=on(this,s,o).call(this,m);if(O.length>0){const v=[g].concat(O);zt(this,n).set(m,v)}else zt(this,n).set(m,O.concat(g));return this}prependOnceListener(m,g){return this.prependListener(m,on(this,c,u).call(this,m,g))}removeListener(m,g){const O=on(this,s,o).call(this,m);return O.length>0&&(on(this,a,l).call(this,O,g),zt(this,n).set(m,O),on(this,d,p).call(this,"removeListener",m,g)),this}off(m,g){return this.removeListener(m,g)}removeAllListeners(m){return m?zt(this,n).delete(m):zt(this,n).clear(),this}listeners(m){return Array.from(on(this,s,o).call(this,m))}listenerCount(m){return on(this,s,o).call(this,m).length}rawListeners(m){return this.listeners(m)}},h=f;n=new WeakMap,i=new WeakMap,r=new WeakMap,s=new WeakSet,o=function(m){return zt(this,n).get(m)||[]},a=new WeakSet,l=function(m,g){const O=m.indexOf(g);return O>-1&&m.splice(O,1),[]},c=new WeakSet,u=function(m,g){const O=(...v)=>{this.removeListener(m,O),g.apply(this,v)};return O},d=new WeakSet,p=function(m,g,O){this.emit(m,g,O)},qZ(h,"defaultMaxListeners",10),t.Emitter=h}}),FZ=Cn({"../../node_modules/.pnpm/strict-event-emitter@0.4.3/node_modules/strict-event-emitter/lib/index.js"(t){var e=t&&t.__createBinding||(Object.create?function(i,r,s,o){o===void 0&&(o=s);var a=Object.getOwnPropertyDescriptor(r,s);(!a||("get"in a?!r.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return r[s]}}),Object.defineProperty(i,o,a)}:function(i,r,s,o){o===void 0&&(o=s),i[o]=r[s]}),n=t&&t.__exportStar||function(i,r){for(var s in i)s!=="default"&&!Object.prototype.hasOwnProperty.call(r,s)&&e(r,i,s)};Object.defineProperty(t,"__esModule",{value:!0}),n(UZ(),t),n(Pw(),t)}}),GZ=Rr(ww()),HZ=/(%?)(%([sdjo]))/g;function JZ(t,e){switch(e){case"s":return t;case"d":case"i":return Number(t);case"j":return JSON.stringify(t);case"o":{if(typeof t=="string")return t;const n=JSON.stringify(t);return n==="{}"||n==="[]"||/^\[object .+?\]$/.test(n)?t:n}}}function Ct(t,...e){if(e.length===0)return t;let n=0,i=t.replace(HZ,(r,s,o,a)=>{const l=e[n],c=JZ(l,a);return s?r:(n++,c)});return n<e.length&&(i+=` ${e.slice(n).join(" ")}`),i=i.replace(/%{2,2}/g,"%"),i}var KZ=2;function eN(t){if(!t.stack)return;const e=t.stack.split(`
760
+ see this guide: https://github.com/louisbrunner/dnd-multi-backend/tree/master/packages/react-dnd-multi-backend#migrating-from-2xx`);Dr(this,Tl,new XI),Dr(this,Wt,{}),Dr(this,mi,[]),i.backends.forEach(r=>{const s=ae(this,nw).call(this,e,n,r);ae(this,Wt)[s.id]=s,ae(this,mi).push(s)}),Dr(this,Vt,ae(this,mi)[0].id),Dr(this,Bi,{})}}Qn(Mr,"isSetUp",!1);const zI=(t,e,n)=>new Mr(t,e,n),sw=(t,e)=>({event:t,check:e}),YI=sw("touchstart",t=>{const e=t;return e.touches!==null&&e.touches!==void 0}),BI=sw("pointerdown",t=>t.pointerType=="mouse");var gi;(function(t){t.mouse="mouse",t.touch="touch",t.keyboard="keyboard"})(gi||(gi={}));class UI{get delay(){var e;return(e=this.args.delay)!==null&&e!==void 0?e:0}get scrollAngleRanges(){return this.args.scrollAngleRanges}get getDropTargetElementsAtPoint(){return this.args.getDropTargetElementsAtPoint}get ignoreContextMenu(){var e;return(e=this.args.ignoreContextMenu)!==null&&e!==void 0?e:!1}get enableHoverOutsideTarget(){var e;return(e=this.args.enableHoverOutsideTarget)!==null&&e!==void 0?e:!1}get enableKeyboardEvents(){var e;return(e=this.args.enableKeyboardEvents)!==null&&e!==void 0?e:!1}get enableMouseEvents(){var e;return(e=this.args.enableMouseEvents)!==null&&e!==void 0?e:!1}get enableTouchEvents(){var e;return(e=this.args.enableTouchEvents)!==null&&e!==void 0?e:!0}get touchSlop(){return this.args.touchSlop||0}get delayTouchStart(){var e,n,i,r;return(r=(i=(e=this.args)===null||e===void 0?void 0:e.delayTouchStart)!==null&&i!==void 0?i:(n=this.args)===null||n===void 0?void 0:n.delay)!==null&&r!==void 0?r:0}get delayMouseStart(){var e,n,i,r;return(r=(i=(e=this.args)===null||e===void 0?void 0:e.delayMouseStart)!==null&&i!==void 0?i:(n=this.args)===null||n===void 0?void 0:n.delay)!==null&&r!==void 0?r:0}get window(){if(this.context&&this.context.window)return this.context.window;if(typeof window<"u")return window}get document(){var e;if(!((e=this.context)===null||e===void 0)&&e.document)return this.context.document;if(this.window)return this.window.document}get rootElement(){var e;return((e=this.args)===null||e===void 0?void 0:e.rootElement)||this.document}constructor(e,n){this.args=e,this.context=n}}function FI(t,e,n,i){return Math.sqrt(Math.pow(Math.abs(n-t),2)+Math.pow(Math.abs(i-e),2))}function GI(t,e,n,i,r){if(!r)return!1;const s=Math.atan2(i-e,n-t)*180/Math.PI+180;for(let o=0;o<r.length;++o){const a=r[o];if(a&&(a.start==null||s>=a.start)&&(a.end==null||s<=a.end))return!0}return!1}const HI={Left:1,Right:2,Center:4},JI={Left:0,Center:1,Right:2};function zp(t){return t.button===void 0||t.button===JI.Left}function KI(t){return t.buttons===void 0||(t.buttons&HI.Left)===0}function ow(t){return!!t.targetTouches}const eZ=1;function tZ(t){const e=t.nodeType===eZ?t:t.parentElement;if(!e)return;const{top:n,left:i}=e.getBoundingClientRect();return{x:i,y:n}}function nZ(t,e){if(t.targetTouches.length===1)return Cl(t.targetTouches[0]);if(e&&t.touches.length===1&&t.touches[0].target===e.target)return Cl(t.touches[0])}function Cl(t,e){return ow(t)?nZ(t,e):{x:t.clientX,y:t.clientY}}const aw=(()=>{let t=!1;try{addEventListener("test",()=>{},Object.defineProperty({},"passive",{get(){return t=!0,!0}}))}catch{}return t})(),io={[gi.mouse]:{start:"mousedown",move:"mousemove",end:"mouseup",contextmenu:"contextmenu"},[gi.touch]:{start:"touchstart",move:"touchmove",end:"touchend"},[gi.keyboard]:{keydown:"keydown"}};class ro{profile(){var e;return{sourceNodes:this.sourceNodes.size,sourcePreviewNodes:this.sourcePreviewNodes.size,sourcePreviewNodeOptions:this.sourcePreviewNodeOptions.size,targetNodes:this.targetNodes.size,dragOverTargetIds:((e=this.dragOverTargetIds)===null||e===void 0?void 0:e.length)||0}}get document(){return this.options.document}setup(){const e=this.options.rootElement;e&&(oe(!ro.isSetUp,"Cannot have two Touch backends at the same time."),ro.isSetUp=!0,this.addEventListener(e,"start",this.getTopMoveStartHandler()),this.addEventListener(e,"start",this.handleTopMoveStartCapture,!0),this.addEventListener(e,"move",this.handleTopMove),this.addEventListener(e,"move",this.handleTopMoveCapture,!0),this.addEventListener(e,"end",this.handleTopMoveEndCapture,!0),this.options.enableMouseEvents&&!this.options.ignoreContextMenu&&this.addEventListener(e,"contextmenu",this.handleTopMoveEndCapture),this.options.enableKeyboardEvents&&this.addEventListener(e,"keydown",this.handleCancelOnEscape,!0))}teardown(){const e=this.options.rootElement;e&&(ro.isSetUp=!1,this._mouseClientOffset={},this.removeEventListener(e,"start",this.handleTopMoveStartCapture,!0),this.removeEventListener(e,"start",this.handleTopMoveStart),this.removeEventListener(e,"move",this.handleTopMoveCapture,!0),this.removeEventListener(e,"move",this.handleTopMove),this.removeEventListener(e,"end",this.handleTopMoveEndCapture,!0),this.options.enableMouseEvents&&!this.options.ignoreContextMenu&&this.removeEventListener(e,"contextmenu",this.handleTopMoveEndCapture),this.options.enableKeyboardEvents&&this.removeEventListener(e,"keydown",this.handleCancelOnEscape,!0),this.uninstallSourceNodeRemovalObserver())}addEventListener(e,n,i,r=!1){const s=aw?{capture:r,passive:!1}:r;this.listenerTypes.forEach(function(o){const a=io[o][n];a&&e.addEventListener(a,i,s)})}removeEventListener(e,n,i,r=!1){const s=aw?{capture:r,passive:!1}:r;this.listenerTypes.forEach(function(o){const a=io[o][n];a&&e.removeEventListener(a,i,s)})}connectDragSource(e,n){const i=this.handleMoveStart.bind(this,e);return this.sourceNodes.set(e,n),this.addEventListener(n,"start",i),()=>{this.sourceNodes.delete(e),this.removeEventListener(n,"start",i)}}connectDragPreview(e,n,i){return this.sourcePreviewNodeOptions.set(e,i),this.sourcePreviewNodes.set(e,n),()=>{this.sourcePreviewNodes.delete(e),this.sourcePreviewNodeOptions.delete(e)}}connectDropTarget(e,n){const i=this.options.rootElement;if(!this.document||!i)return()=>{};const r=s=>{if(!this.document||!i||!this.monitor.isDragging())return;let o;switch(s.type){case io.mouse.move:o={x:s.clientX,y:s.clientY};break;case io.touch.move:var a,l;o={x:((a=s.touches[0])===null||a===void 0?void 0:a.clientX)||0,y:((l=s.touches[0])===null||l===void 0?void 0:l.clientY)||0};break}const c=o!=null?this.document.elementFromPoint(o.x,o.y):void 0,u=c&&n.contains(c);if(c===n||u)return this.handleMove(s,e)};return this.addEventListener(this.document.body,"move",r),this.targetNodes.set(e,n),()=>{this.document&&(this.targetNodes.delete(e),this.removeEventListener(this.document.body,"move",r))}}getTopMoveStartHandler(){return!this.options.delayTouchStart&&!this.options.delayMouseStart?this.handleTopMoveStart:this.handleTopMoveStartDelay}installSourceNodeRemovalObserver(e){this.uninstallSourceNodeRemovalObserver(),this.draggedSourceNode=e,this.draggedSourceNodeRemovalObserver=new MutationObserver(()=>{e&&!e.parentElement&&(this.resurrectSourceNode(),this.uninstallSourceNodeRemovalObserver())}),!(!e||!e.parentElement)&&this.draggedSourceNodeRemovalObserver.observe(e.parentElement,{childList:!0})}resurrectSourceNode(){this.document&&this.draggedSourceNode&&(this.draggedSourceNode.style.display="none",this.draggedSourceNode.removeAttribute("data-reactid"),this.document.body.appendChild(this.draggedSourceNode))}uninstallSourceNodeRemovalObserver(){this.draggedSourceNodeRemovalObserver&&this.draggedSourceNodeRemovalObserver.disconnect(),this.draggedSourceNodeRemovalObserver=void 0,this.draggedSourceNode=void 0}constructor(e,n,i){this.getSourceClientOffset=r=>{const s=this.sourceNodes.get(r);return s&&tZ(s)},this.handleTopMoveStartCapture=r=>{zp(r)&&(this.moveStartSourceIds=[])},this.handleMoveStart=r=>{Array.isArray(this.moveStartSourceIds)&&this.moveStartSourceIds.unshift(r)},this.handleTopMoveStart=r=>{if(!zp(r))return;const s=Cl(r);s&&(ow(r)&&(this.lastTargetTouchFallback=r.targetTouches[0]),this._mouseClientOffset=s),this.waitingForDelay=!1},this.handleTopMoveStartDelay=r=>{if(!zp(r))return;const s=r.type===io.touch.start?this.options.delayTouchStart:this.options.delayMouseStart;this.timeout=setTimeout(this.handleTopMoveStart.bind(this,r),s),this.waitingForDelay=!0},this.handleTopMoveCapture=()=>{this.dragOverTargetIds=[]},this.handleMove=(r,s)=>{this.dragOverTargetIds&&this.dragOverTargetIds.unshift(s)},this.handleTopMove=r=>{if(this.timeout&&clearTimeout(this.timeout),!this.document||this.waitingForDelay)return;const{moveStartSourceIds:s,dragOverTargetIds:o}=this,a=this.options.enableHoverOutsideTarget,l=Cl(r,this.lastTargetTouchFallback);if(!l)return;if(this._isScrolling||!this.monitor.isDragging()&&GI(this._mouseClientOffset.x||0,this._mouseClientOffset.y||0,l.x,l.y,this.options.scrollAngleRanges)){this._isScrolling=!0;return}if(!this.monitor.isDragging()&&this._mouseClientOffset.hasOwnProperty("x")&&s&&FI(this._mouseClientOffset.x||0,this._mouseClientOffset.y||0,l.x,l.y)>(this.options.touchSlop?this.options.touchSlop:0)&&(this.moveStartSourceIds=void 0,this.actions.beginDrag(s,{clientOffset:this._mouseClientOffset,getSourceClientOffset:this.getSourceClientOffset,publishSource:!1})),!this.monitor.isDragging())return;const c=this.sourceNodes.get(this.monitor.getSourceId());this.installSourceNodeRemovalObserver(c),this.actions.publishDragSource(),r.cancelable&&r.preventDefault();const u=(o||[]).map(h=>this.targetNodes.get(h)).filter(h=>!!h),d=this.options.getDropTargetElementsAtPoint?this.options.getDropTargetElementsAtPoint(l.x,l.y,u):this.document.elementsFromPoint(l.x,l.y),p=[];for(const h in d){if(!d.hasOwnProperty(h))continue;let m=d[h];for(m!=null&&p.push(m);m;)m=m.parentElement,m&&p.indexOf(m)===-1&&p.push(m)}const f=p.filter(h=>u.indexOf(h)>-1).map(h=>this._getDropTargetId(h)).filter(h=>!!h).filter((h,m,g)=>g.indexOf(h)===m);if(a)for(const h in this.targetNodes){const m=this.targetNodes.get(h);if(c&&m&&m.contains(c)&&f.indexOf(h)===-1){f.unshift(h);break}}f.reverse(),this.actions.hover(f,{clientOffset:l})},this._getDropTargetId=r=>{const s=this.targetNodes.keys();let o=s.next();for(;o.done===!1;){const a=o.value;if(r===this.targetNodes.get(a))return a;o=s.next()}},this.handleTopMoveEndCapture=r=>{if(this._isScrolling=!1,this.lastTargetTouchFallback=void 0,!!KI(r)){if(!this.monitor.isDragging()||this.monitor.didDrop()){this.moveStartSourceIds=void 0;return}r.cancelable&&r.preventDefault(),this._mouseClientOffset={},this.uninstallSourceNodeRemovalObserver(),this.actions.drop(),this.actions.endDrag()}},this.handleCancelOnEscape=r=>{r.key==="Escape"&&this.monitor.isDragging()&&(this._mouseClientOffset={},this.uninstallSourceNodeRemovalObserver(),this.actions.endDrag())},this.options=new UI(i,n),this.actions=e.getActions(),this.monitor=e.getMonitor(),this.sourceNodes=new Map,this.sourcePreviewNodes=new Map,this.sourcePreviewNodeOptions=new Map,this.targetNodes=new Map,this.listenerTypes=[],this._mouseClientOffset={},this._isScrolling=!1,this.options.enableMouseEvents&&this.listenerTypes.push(gi.mouse),this.options.enableTouchEvents&&this.listenerTypes.push(gi.touch),this.options.enableKeyboardEvents&&this.listenerTypes.push(gi.keyboard)}}const iZ=function(e,n={},i={}){return new ro(e,n,i)};var qt=function(){return qt=Object.assign||function(e){for(var n,i=1,r=arguments.length;i<r;i++){n=arguments[i];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},qt.apply(this,arguments)};function ht(t,e,n){if(n||arguments.length===2)for(var i=0,r=e.length,s;i<r;i++)(s||!(i in e))&&(s||(s=Array.prototype.slice.call(e,0,i)),s[i]=e[i]);return t.concat(s||Array.prototype.slice.call(e))}function rZ(t){var e=t.isVisible,n=t.ease,i=n===void 0?"easeIn":n,r=t.duration,s=t.variants,o=s===void 0?{open:{opacity:1,height:"auto"},close:{opacity:0,height:0}}:s,a=t.children,l=D_({polyfill:nD}),c=l[0],u=l[1].height,d=P.useState(e),p=d[0],f=d[1],h=P.useState(e),m=h[0],g=h[1],O=P.useState(!1),v=O[0],x=O[1],b=function(){x(!1),e||f(!1)};return P.useEffect(function(){x(!0),e?f(!0):g(!1)},[e]),P.useEffect(function(){p&&g(!0)},[u]),P.createElement(j_.div,{style:v?{overflow:"hidden"}:void 0,onAnimationComplete:b,initial:m?"open":"close",animate:m?"open":"close",inherit:!1,variants:o,transition:{ease:i,duration:sZ(u,r)}},P.createElement("div",{ref:c},p&&a))}function sZ(t,e){if(e)return e;if(!t)return 0;var n=t/36;return Math.round((4+10*Math.pow(n,.25)+n/5)*10)/1500}var oZ=function(t,e){return t.text>e.text?1:t.text<e.text?-1:0},so=function(t,e){return t.find(function(n){return n.id===e})},lw=function(t,e,n){if(n===0)return!1;var i=t.find(function(r){return r.id===n});return i===void 0?!1:i.parent===e?!0:lw(t,e,i.parent)},Yp=function(t){return t.id!==void 0&&t.parent!==void 0&&t.text!==void 0},vi=function(t,e,n){var i=n.tree,r=n.rootId,s=n.canDrop;if(t===null){if(e===r)return!0;var o=i.find(function(u){return u.id===e});return!!(o&&o.droppable)}else{var a=Yp(t)?t.id:null;if(s){var l=s(a,e);if(l!==void 0)return l}if(a===e)return!1;var c=i.find(function(d){return d.id===a}),o=i.find(function(d){return d.id===e});return c===void 0||a===null?e===r||!!(o!=null&&o.droppable):o===void 0?c.parent!==0:c.parent===e||!o.droppable?!1:!lw(i,a,e)}},aZ=function(t,e,n){return t.map(function(i){return i.id===e?qt(qt({},i),{parent:n}):i})},cw=function(t,e,n){if(n===0)return 0;var i=t.filter(function(r){return r.parent===e});return i[n]?t.findIndex(function(r){return r.id===i[n].id}):t.findIndex(function(r){return r.id===i[n-1].id})+1},lZ=function(t,e){return t.findIndex(function(n){return n.id===e})},uw=function(t,e,n,i){var r=lZ(t,e),s=cw(t,n,i);return s=s>r?s-1:s,[r,s]},cZ=function(t,e,n){var i=e<0?t.length+e:e;if(i>=0&&i<t.length){var r=n<0?t.length+n:n,s=t.splice(e,1)[0];t.splice(r,0,s)}},uZ=function(t,e,n,i){var r=uw(t,e,n,i),s=r[0],o=r[1],a=ht([],t,!0);return cZ(a,s,o),a.map(function(l){return l.id===e?qt(qt({},l),{parent:n}):l})},dZ=function(t,e){var n=t.getBoundingClientRect(),i=n.top+n.height/2;return e>i?"down":"up"},Bp=function(t,e){var n="",i=0;return t.forEach(function(r,s){var o,a=dZ(r,((o=e.getClientOffset())===null||o===void 0?void 0:o.y)||0);n===""?n=a:n!==a&&(n=a,i=s),s===t.length-1&&a==="down"&&(i=s+1)}),i},dw=function(t,e,n){var i=e.closest('[role="list"]'),r=i==null?void 0:i.querySelectorAll(':scope > [role="listitem"]');return r?Bp(r,n):null},pZ=function(t,e,n){var i=t.getBoundingClientRect(),r=n.dropTargetOffset,s=i.top+r,o=i.bottom-r;return e>o?"lower":e<s?"upper":"middle"},Up=function(t,e,n,i){var r;if(!e)return null;if(t===null){var s=e.querySelectorAll(':scope > [role="listitem"]');return{id:i.rootId,index:Bp(s,n)}}var o=n.getItem(),a=e.querySelector('[role="list"]'),l=pZ(e,((r=n.getClientOffset())===null||r===void 0?void 0:r.y)||0,i);if(a){if(l==="upper")if(vi(o,t.parent,i)){var c=dw(t,e,n);return c===null?null:{id:t.parent,index:c}}else return{id:t.id,index:0};var s=a.querySelectorAll(':scope > [role="listitem"]');return{id:t.id,index:Bp(s,n)}}else{if(l==="middle")return{id:t.id,index:0};if(vi(o,t.parent,i)){var c=dw(t,e,n);return c===null?null:{id:t.parent,index:c}}return null}},fZ=function(t){return t===void 0&&(t={}),{backends:[{id:"html5",backend:RA,options:t.html5,transition:BI},{id:"touch",backend:iZ,options:t.touch||{enableMouseEvents:!0},preview:!0,transition:YI}]}},El=function(t,e){return t.some(function(n){return n.parent===e})},pw=P.createContext({}),hZ=function(t){var e=SZ(t.tree,t.initialOpen),n=e[0],i=e[1],r=i.handleToggle,s=i.handleCloseAll,o=i.handleOpenAll,a=i.handleOpen,l=i.handleClose;P.useImperativeHandle(t.treeRef,function(){return{open:function(f){return a(f,t.onChangeOpen)},close:function(f){return l(f,t.onChangeOpen)},openAll:function(){return o(t.onChangeOpen)},closeAll:function(){return s(t.onChangeOpen)}}});var c=Vn().getMonitor(),u=t.canDrop,d=t.canDrag,p=qt(qt({extraAcceptTypes:[],listComponent:"ul",listItemComponent:"li",placeholderComponent:"li",sort:!0,insertDroppableFirst:!0,enableAnimateExpand:!1,dropTargetOffset:0,initialOpen:!1},t),{openIds:n,onDrop:function(f,h,m){if(f){var g={dragSourceId:f.id,dropTargetId:h,dragSource:f,dropTarget:so(t.tree,h),monitor:c},O=t.tree;if(so(O,f.id)||(O=ht(ht([],O,!0),[f],!1)),t.sort===!1){var v=uw(O,f.id,h,m),x=v[1];g.destinationIndex=x,g.relativeIndex=m,t.onDrop(uZ(O,f.id,h,m),g);return}t.onDrop(aZ(O,f.id,h),g)}else{var g={dropTargetId:h,dropTarget:so(t.tree,h),monitor:c};t.sort===!1&&(g.destinationIndex=cw(t.tree,h,m),g.relativeIndex=m),t.onDrop(t.tree,g)}},canDrop:u?function(f,h){return u(t.tree,{dragSourceId:f??void 0,dropTargetId:h,dragSource:c.getItem(),dropTarget:so(t.tree,h),monitor:c})}:void 0,canDrag:d?function(f){return d(so(t.tree,f))}:void 0,onToggle:function(f){return r(f,t.onChangeOpen)}});return P.createElement(pw.Provider,{value:p},t.children)},fw=P.createContext({}),mZ={isLock:!1},gZ=function(t){var e=P.useState(mZ.isLock),n=e[0],i=e[1];return P.createElement(fw.Provider,{value:{isLock:n,lock:function(){return i(!0)},unlock:function(){return i(!1)}}},t.children)},oo=P.createContext({}),jl={dropTargetId:void 0,index:void 0},vZ=function(t){var e=P.useState(jl.dropTargetId),n=e[0],i=e[1],r=P.useState(jl.index),s=r[0],o=r[1],a=function(c,u){i(c),o(u)},l=function(){i(jl.dropTargetId),o(jl.index)};return P.createElement(oo.Provider,{value:{dropTargetId:n,index:s,showPlaceholder:a,hidePlaceholder:l}},t.children)},OZ=function(t){return P.createElement(hZ,qt({},t),P.createElement(gZ,null,P.createElement(vZ,null,t.children)))},xZ=function(t){var e=P.useContext(fw);P.useEffect(function(){if(t.current){var n=t.current,i=function(u){var d=u.target;(d instanceof HTMLInputElement||d instanceof HTMLTextAreaElement)&&e.lock()},r=function(u){var d=u.target;(d instanceof HTMLInputElement||d instanceof HTMLTextAreaElement)&&e.unlock()},s=function(u){return i(u)},o=function(u){return r(u)},a=function(u){return i(u)},l=function(u){return r(u)},c=new MutationObserver(function(){document.activeElement===document.body&&e.unlock()});return c.observe(n,{subtree:!0,childList:!0}),n.addEventListener("mouseover",s),n.addEventListener("mouseout",o),n.addEventListener("focusin",a),n.addEventListener("focusout",l),function(){c.disconnect(),n.removeEventListener("mouseover",s),n.removeEventListener("mouseout",o),n.removeEventListener("focusin",a),n.removeEventListener("focusout",l)}}},[t,e]),P.useEffect(function(){var n;(n=t.current)===null||n===void 0||n.setAttribute("draggable",e.isLock?"false":"true")},[t,e.isLock])},Al={TREE_ITEM:Symbol()},hw=null,mw=function(t){var e=t.target;if(e instanceof HTMLElement){var n=e.closest('[role="listitem"]');t.currentTarget===n&&(hw=n)}},gw=function(t){return mw(t)},vw=function(t){return mw(t)},bZ=function(t,e){var n=Oi();P.useEffect(function(){var a=e.current;return a==null||a.addEventListener("dragstart",gw),a==null||a.addEventListener("touchstart",vw,{passive:!0}),function(){a==null||a.removeEventListener("dragstart",gw),a==null||a.removeEventListener("touchstart",vw)}},[e]);var i=TI({type:Al.TREE_ITEM,item:function(a){var l=qt({ref:e},t);return n.onDragStart&&n.onDragStart(l,a),l},end:function(a,l){var c=a;n.onDragEnd&&n.onDragEnd(c,l)},canDrag:function(){var a=n.canDrag;return hw!==e.current?!1:a?a(t.id):!0},collect:function(a){return{isDragging:a.isDragging()}}}),r=i[0].isDragging,s=i[1],o=i[2];return[r,s,o]},yZ=function(t){var e=Oi(),n=P.useContext(oo),i=Ky({accept:ht([Al.TREE_ITEM],e.extraAcceptTypes,!0),drop:function(l,c){var u=e.rootId,d=e.onDrop,p=n.dropTargetId,f=n.index;c.isOver({shallow:!0})&&p!==void 0&&f!==void 0&&d(Yp(l)?l:null,u,f),n.hidePlaceholder()},canDrop:function(l,c){var u=e.rootId;return c.isOver({shallow:!0})?l===void 0?!1:vi(l,u,e):!1},hover:function(l,c){if(c.isOver({shallow:!0})){var u=e.rootId,d=n.dropTargetId,p=n.index,f=n.showPlaceholder,h=n.hidePlaceholder,m=Up(null,t.current,c,e);if(m===null||!vi(l,u,e)){h();return}(m.id!==d||m.index!==p)&&f(m.id,m.index)}},collect:function(l){var c=l.getItem();return{isOver:l.isOver({shallow:!0})&&l.canDrop(),dragSource:c}}}),r=i[0],s=r.isOver,o=r.dragSource,a=i[1];return[s,o,a]},wZ=function(t,e){var n=Oi(),i=P.useContext(oo),r=Ky({accept:ht([Al.TREE_ITEM],n.extraAcceptTypes,!0),drop:function(c,u){var d=i.dropTargetId,p=i.index;u.isOver({shallow:!0})&&d!==void 0&&p!==void 0&&n.onDrop(Yp(c)?c:null,d,p),i.hidePlaceholder()},canDrop:function(c,u){if(u.isOver({shallow:!0})){var d=Up(t,e.current,u,n);return d===null?!1:vi(c,d.id,n)}return!1},hover:function(c,u){if(u.isOver({shallow:!0})){var d=i.dropTargetId,p=i.index,f=i.showPlaceholder,h=i.hidePlaceholder,m=Up(t,e.current,u,n);if(m===null||!vi(c,m.id,n)){h();return}(m.id!==d||m.index!==p)&&f(m.id,m.index)}},collect:function(c){var u=c.getItem();return{isOver:c.isOver({shallow:!0})&&c.canDrop(),dragSource:u}}}),s=r[0],o=s.isOver,a=s.dragSource,l=r[1];return[o,a,l]},SZ=function(t,e){var n=P.useMemo(function(){return e===!0?t.filter(function(d){return El(t,d.id)}).map(function(d){return d.id}):Array.isArray(e)?e:[]},[e]),i=P.useState(n),r=i[0],s=i[1];P.useEffect(function(){return s(n)},[e]);var o=function(d,p){var f=r.includes(d)?r.filter(function(h){return h!==d}):ht(ht([],r,!0),[d],!1);s(f),p&&p(f)},a=function(d){s([]),d&&d([])},l=function(d){var p=t.filter(function(f){return El(t,f.id)}).map(function(f){return f.id});s(p),d&&d(p)},c=function(d,p){var f=[];if(Array.isArray(d)){var h=t.filter(function(m){return d.includes(m.id)&&El(t,m.id)});f=ht(ht([],r,!0),h.map(function(m){return m.id}),!0).filter(function(m,g,O){return O.indexOf(m)===g})}else f=r.includes(d)?r:ht(ht([],r,!0),[d],!1);s(f),p&&p(f)},u=function(d,p){var f=r.filter(function(h){return Array.isArray(d)?!d.includes(h):h!==d});s(f),p&&p(f)};return[r,{handleToggle:o,handleCloseAll:a,handleOpenAll:l,handleOpen:c,handleClose:u}]},PZ=function(){return QI(function(t){var e=t.getItemType();return{item:t.getItem(),clientOffset:t.getClientOffset(),isDragging:t.isDragging()&&e===Al.TREE_ITEM}})},Oi=function(){var t=P.useContext(pw);if(!t)throw new Error("useTreeContext must be used under TreeProvider");return t},kZ=function(t,e){var n=Oi(),i=n.rootId,r=n.rootProps,s=n.classes,o=(s==null?void 0:s.container)||"";return e&&(s!=null&&s.dropTarget)&&(o="".concat(o," ").concat(s.dropTarget)),t===i&&(s!=null&&s.root)&&(o="".concat(o," ").concat(s.root)),t===i&&(r!=null&&r.className)&&(o="".concat(o," ").concat(r.className)),o=o.trim(),o},$Z=function(t,e,n){e.current?n(e):n(t),P.useEffect(function(){e.current?n(e):n(t)},[e.current])},TZ=function(t){var e=Oi(),n=P.useContext(oo),i=P.useRef(null),r=P.useRef(null),s=e.tree.find(function(T){return T.id===t.id}),o=e.openIds,a=e.classes,l=e.enableAnimateExpand,c=o.includes(t.id),u=bZ(s,i),d=u[0],p=u[1],f=u[2],h=wZ(s,i),m=h[0],g=h[1],O=h[2];$Z(i,r,p),vi(g,t.id,e)&&O(i),P.useEffect(function(){e.dragPreviewRender?f(MA(),{captureDraggingState:!0}):r.current&&f(i)},[f,e.dragPreviewRender]),xZ(i);var v=function(){return e.onToggle(s.id)},x=e.listItemComponent,b=(a==null?void 0:a.listItem)||"";m&&(a!=null&&a.dropTarget)&&(b="".concat(b," ").concat(a.dropTarget)),d&&(a!=null&&a.draggingSource)&&(b="".concat(b," ").concat(a.draggingSource));var w=e.canDrag?e.canDrag(t.id):!0,y=n.dropTargetId===t.id,k={depth:t.depth,isOpen:c,isDragging:d,isDropTarget:y,draggable:w,hasChild:El(e.tree,t.id),containerRef:i,handleRef:r,onToggle:v};return P.createElement(x,{ref:i,className:b,role:"listitem"},e.render(s,k),l&&k.hasChild&&P.createElement(rZ,{isVisible:c},P.createElement(Fp,{parentId:t.id,depth:t.depth+1})),!l&&k.hasChild&&c&&P.createElement(Fp,{parentId:t.id,depth:t.depth+1}))},Ow=function(t){var e=Oi(),n=e.placeholderRender,i=e.placeholderComponent,r=e.classes,s=P.useContext(oo),o=Vn(),a=o.getMonitor(),l=a.getItem();if(!n||!l)return null;var c=t.dropTargetId===s.dropTargetId&&(t.index===s.index||t.index===void 0&&t.listCount===s.index);return c?P.createElement(i,{className:(r==null?void 0:r.placeholder)||""},n(l,{depth:t.depth})):null},Fp=function(t){var e=Oi(),n=P.useRef(null),i=e.tree.filter(function(m){return m.parent===t.parentId}),r=i,s=typeof e.sort=="function"?e.sort:oZ;if(e.insertDroppableFirst){var o=i.filter(function(m){return m.droppable}),a=i.filter(function(m){return!m.droppable});e.sort===!1?r=ht(ht([],o,!0),a,!0):(o=o.sort(s),a=a.sort(s),r=ht(ht([],o,!0),a,!0))}else e.sort!==!1&&(r=i.sort(s));var l=yZ(n),c=l[0],u=l[1],d=l[2];t.parentId===e.rootId&&vi(u,e.rootId,e)&&d(n);var p=kZ(t.parentId,c),f=e.rootProps||{},h=e.listComponent;return P.createElement(h,qt({ref:n,role:"list"},f,{className:p}),r.map(function(m,g){return P.createElement(P.Fragment,{key:m.id},P.createElement(Ow,{depth:t.depth,listCount:r.length,dropTargetId:t.parentId,index:g}),P.createElement(TZ,{id:m.id,depth:t.depth}))}),P.createElement(Ow,{depth:t.depth,listCount:r.length,dropTargetId:t.parentId}))},QZ={height:"100%",left:0,pointerEvents:"none",position:"fixed",top:0,width:"100%",zIndex:100},CZ=function(t){var e=t.clientOffset;if(!e)return{};var n=e.x,i=e.y,r="translate(".concat(n,"px, ").concat(i,"px)");return{pointerEvents:"none",transform:r}},EZ=function(){var t=Oi(),e=PZ(),n=e.isDragging,i=e.clientOffset;return!n||!i?null:P.createElement("div",{style:QZ},P.createElement("div",{style:CZ(e)},t.dragPreviewRender&&t.dragPreviewRender(e)))};function jZ(t,e){return P.createElement(OZ,qt({},t,{treeRef:e}),t.dragPreviewRender&&P.createElement(EZ,null),P.createElement(Fp,{parentId:t.rootId,depth:0}))}var AZ=P.forwardRef(jZ);const DZ=({onSubmit:t,onBlur:e,isDirectory:n,files:i,currentPath:r="/"})=>{const[s,o]=P.useState(""),a=P.useRef(null),[l,c]=P.useState(!1);P.useEffect(()=>{s&&(i[`${r}/${s}`]||i[`${r}/${s}/`])?c(!0):c(!1)},[s]);const u=f=>{f.preventDefault()},d=()=>{if(s){let f=s;n&&!s.endsWith("/")?f=`${s}/`:s.endsWith("/")&&(f=s.substring(0,-1)),t(f),o("")}else e()},p=f=>{if(l)return;let h=s;n&&!s.endsWith("/")?h=`${s}/`:s.endsWith("/")&&(h=s.substring(0,-1)),f.key==="Enter"&&(f.preventDefault(),t(h),o("")),f.key==="Escape"&&(f.preventDefault(),d())};return S.jsxs("form",{ref:a,onSubmit:u,children:[S.jsx("label",{children:S.jsx("input",{style:{maxWidth:"100%",border:`1px solid ${l?"red":"inherit"}`},onBlur:d,maxLength:35,autoFocus:!0,placeholder:`${n?"Directory name":"File name"}`,name:"name",type:"text",value:s,onChange:f=>o(f.target.value),onKeyDown:p})}),l?S.jsx("span",{style:{display:"block",maxWidth:"100%",background:"var(--sp-colors-errorSurface)",color:"var(--sp-colors-error)",borderRadius:"3px"},children:"File or Directory already exists"}):null]})},xw=({dir:t})=>{const{sandpack:e}=Ce(),{addFile:n}=yx();return S.jsx("span",{style:{cursor:"pointer"},onClick:()=>{const i=e.activeFile.split("/").slice(0,-1).join("/");n({[`${i}/${t?"addDir":"addFile"}`]:{code:".emptyDir",hidden:!0}})},children:t?S.jsx(ZO,{}):S.jsx(NO,{})})},MZ=()=>{const{treeData:t,addFile:e,deleteFile:n,onFileMoved:i,setTreeData:r,openDirs:s,setOpenDirs:o}=yx(),{sandpack:a}=Ce(),l=["/package.json"],c=async(d,p)=>{var m,g,O,v;const f=Ox(a.files),h=`/${Ni({parent:p.dropTargetId,text:((m=p==null?void 0:p.dragSource)==null?void 0:m.text)||p.dragSourceId},d)}`;a.files[h],!([...l,f].includes(((O=(g=p==null?void 0:p.dragSource)==null?void 0:g.data)==null?void 0:O.path)||"")||((v=p.dragSource)==null?void 0:v.parent)===p.dropTargetId||a.files[h])&&(await i({newTree:d,node:p}),r(d))},u=Ox(a.files);return S.jsx(S.Fragment,{children:S.jsx(rI,{backend:zI,options:fZ(),children:S.jsxs("div",{style:{minHeight:"100%",maxHeight:"100%",height:"var(--sp-layout-height)",minWidth:"200px",overflowY:"auto",overflowX:"hidden",position:"relative",display:"flex",flexDirection:"column",padding:"var(--sp-space-1) var(--sp-space-3)",backgroundColor:"var(--sp-colors-surface1, #011627)"},children:[S.jsxs("div",{style:{width:"100%",display:"flex",justifyContent:"space-between",alignItems:"center",minHeight:"40px"},children:[S.jsx("span",{children:"Files"}),S.jsxs("div",{style:{display:"flex"},children:[S.jsx(xw,{}),S.jsx(xw,{dir:!0})]})]}),S.jsx(AZ,{tree:t.filter(({text:d})=>!!d),rootId:"/",onDrop:c,rootProps:{style:{listStyle:"none",padding:"0",height:"100%"}},classes:{root:"test"},enableAnimateExpand:!0,insertDroppableFirst:!0,sort:!0,initialOpen:s,render:(d,{depth:p,isOpen:f})=>{var h,m,g,O;return d.text?S.jsxs("div",{style:{marginLeft:p*10,display:"flex",justifyContent:"space-between",maxWidth:"300px",overflow:"hidden",padding:"var(--sp-space-1) 0",transition:"color var(--sp-transitions-default), background var(--sp-transitions-default)"},children:[d.text.includes("addFile")||d.text.includes("addDir")?S.jsx(DZ,{files:a.files,onBlur:()=>{var v;return n(`${(v=d==null?void 0:d.data)==null?void 0:v.path}`)},isDirectory:d.text.includes("addDir"),currentPath:(h=d==null?void 0:d.data)==null?void 0:h.path.split("/").slice(0,-1).join("/"),onSubmit:async v=>{var w;const b=`${(w=d==null?void 0:d.data)==null?void 0:w.path.split("/").slice(0,-1).join("/")}/${v}`;await e({[b]:{code:d.text.includes("addDir")?".emptyDir":`// ${v}`,hidden:d.text.includes("addDir")}})}}):null,d.text&&!d.text.includes("addFile")&&!d.text.includes("addDir")?S.jsxs(S.Fragment,{children:[d.droppable?S.jsxs("span",{style:{color:"var(--sp-colors-clickable)",display:"flex",cursor:"pointer"},onClick:()=>{o(f?v=>v.filter(x=>x!==d.id):v=>[...v,d.id])},children:[f?S.jsx(ZO,{}):S.jsx(f2,{}),d.text,f?"[-] ":"[+] "]}):S.jsxs("span",{style:{display:"flex"},children:[S.jsx("span",{style:{minWidth:"16px",minHeight:"16px"},children:S.jsx(NO,{})}),S.jsx("span",{style:{textOverflow:"ellipsis",maxWidth:"200px",overflow:"hidden",cursor:"pointer",color:`${((m=d==null?void 0:d.data)==null?void 0:m.path)===a.activeFile?"var(--sp-colors-accent)":"var(--sp-colors-clickable)"}`,display:"flex"},onClick:()=>{var v;return a.openFile((v=d==null?void 0:d.data)==null?void 0:v.path)},children:d.text})]}),[u,"/package.json"].includes(((g=d==null?void 0:d.data)==null?void 0:g.path)??"")?S.jsx("span",{style:{color:"var(--sp-colors-warning)"},children:((O=d==null?void 0:d.data)==null?void 0:O.path)===u?"entry":""}):S.jsx("button",{style:{background:"none",border:"none",cursor:"pointer"},onClick:async()=>{var v;await n(`${(v=d==null?void 0:d.data)==null?void 0:v.path}${d.droppable?"/":""}`)},children:S.jsx(LO,{})})]}):null]},d.id):S.jsx(S.Fragment,{})}})]})})})},RZ=()=>S.jsx("div",{style:{minWidth:150,maxWidth:"300px",overflow:"hidden"},children:S.jsx(MZ,{})}),_Z=t=>S.jsx(bA,{...t,children:S.jsx(RZ,{})}),IZ=({type:t="react",children:e,showConsole:n=!0,files:i,className:r,style:s,...o})=>{const a=P.useRef(),l=e?P.cloneElement(e,{ref:a}):null;return S.jsxs("div",{className:r,style:s,...o,children:[l,S.jsx(ej,{template:t,theme:"dark",files:i,children:S.jsx(zO,{children:S.jsxs(xj,{children:[S.jsx(_Z,{}),S.jsx(vA,{editorFiles:a}),S.jsxs("div",{children:[S.jsx(eA,{style:{height:n?"60vh":"100vh"},showOpenInCodeSandbox:!1}),n?S.jsx(mA,{style:{height:"40vh",width:"40vw"}}):""]})]})})})]})};var ZZ=Object.create,Gp=Object.defineProperty,NZ=Object.getOwnPropertyDescriptor,bw=Object.getOwnPropertyNames,LZ=Object.getPrototypeOf,XZ=Object.prototype.hasOwnProperty,VZ=(t,e,n)=>e in t?Gp(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Cn=(t,e)=>function(){return e||(0,t[bw(t)[0]])((e={exports:{}}).exports,e),e.exports},WZ=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of bw(e))!XZ.call(t,r)&&r!==n&&Gp(t,r,{get:()=>e[r],enumerable:!(i=NZ(e,r))||i.enumerable});return t},Rr=(t,e,n)=>(n=t!=null?ZZ(LZ(t)):{},WZ(e||!t||!t.__esModule?Gp(n,"default",{value:t,enumerable:!0}):n,t)),qZ=(t,e,n)=>(VZ(t,typeof e!="symbol"?e+"":e,n),n),Hp=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)},zt=(t,e,n)=>(Hp(t,e,"read from private field"),n?n.call(t):e.get(t)),Ui=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},ao=(t,e,n,i)=>(Hp(t,e,"write to private field"),i?i.call(t,n):e.set(t,n),n),on=(t,e,n)=>(Hp(t,e,"access private method"),n),yw=Cn({"../../node_modules/.pnpm/cuid@2.1.8/node_modules/cuid/lib/pad.js"(t,e){e.exports=function(i,r){var s="000000000"+i;return s.substr(s.length-r)}}}),zZ=Cn({"../../node_modules/.pnpm/cuid@2.1.8/node_modules/cuid/lib/fingerprint.browser.js"(t,e){var n=yw(),i=typeof window=="object"?window:self,r=Object.keys(i).length,s=navigator.mimeTypes?navigator.mimeTypes.length:0,o=n((s+navigator.userAgent.length).toString(36)+r.toString(36),4);e.exports=function(){return o}}}),YZ=Cn({"../../node_modules/.pnpm/cuid@2.1.8/node_modules/cuid/lib/getRandomValue.browser.js"(t,e){var n,i=typeof window<"u"&&(window.crypto||window.msCrypto)||typeof self<"u"&&self.crypto;i?(r=Math.pow(2,32)-1,n=function(){return Math.abs(i.getRandomValues(new Uint32Array(1))[0]/r)}):n=Math.random;var r;e.exports=n}}),ww=Cn({"../../node_modules/.pnpm/cuid@2.1.8/node_modules/cuid/index.js"(t,e){var n=zZ(),i=yw(),r=YZ(),s=0,o=4,a=36,l=Math.pow(a,o);function c(){return i((r()*l<<0).toString(a),o)}function u(){return s=s<l?s:0,s++,s-1}function d(){var p="c",f=new Date().getTime().toString(a),h=i(u().toString(a),o),m=n(),g=c()+c();return p+f+h+m+g}d.slug=function(){var f=new Date().getTime().toString(36),h=u().toString(36).slice(-4),m=n().slice(0,1)+n().slice(-1),g=c().slice(-2);return f.slice(-2)+h+m+g},d.isCuid=function(f){return typeof f!="string"?!1:!!f.startsWith("c")},d.isSlug=function(f){if(typeof f!="string")return!1;var h=f.length;return h>=7&&h<=10},d.fingerprint=n,e.exports=d}}),Sw=Cn({"../../node_modules/.pnpm/@open-draft+deferred-promise@2.1.0/node_modules/@open-draft/deferred-promise/build/createDeferredExecutor.js"(t){Object.defineProperty(t,"__esModule",{value:!0}),t.createDeferredExecutor=void 0;function e(){const n=(i,r)=>{n.state="pending",n.resolve=s=>{if(n.state!=="pending")return;n.result=s;const o=a=>(n.state="fulfilled",a);return i(s instanceof Promise?s:Promise.resolve(s).then(o))},n.reject=s=>{if(n.state==="pending")return queueMicrotask(()=>{n.state="rejected"}),r(n.rejectionReason=s)}};return n}t.createDeferredExecutor=e}}),BZ=Cn({"../../node_modules/.pnpm/@open-draft+deferred-promise@2.1.0/node_modules/@open-draft/deferred-promise/build/DeferredPromise.js"(t){var i,r,Ll,o;Object.defineProperty(t,"__esModule",{value:!0}),t.DeferredPromise=void 0;var e=Sw(),n=(o=class extends Promise{constructor(l=null){const c=(0,e.createDeferredExecutor)();super((u,d)=>{c(u,d),l==null||l(c.resolve,c.reject)});uf(this,r);uf(this,i,void 0);Ze(this,"resolve");Ze(this,"reject");e1(this,i,c),this.resolve=co(this,i).resolve,this.reject=co(this,i).reject}get state(){return co(this,i).state}get rejectionReason(){return co(this,i).rejectionReason}then(l,c){return Nl(this,r,Ll).call(this,super.then(l,c))}catch(l){return Nl(this,r,Ll).call(this,super.catch(l))}finally(l){return Nl(this,r,Ll).call(this,super.finally(l))}},i=new WeakMap,r=new WeakSet,Ll=function(l){return Object.defineProperties(l,{resolve:{configurable:!0,value:this.resolve},reject:{configurable:!0,value:this.reject}})},o);t.DeferredPromise=n}}),Jp=Cn({"../../node_modules/.pnpm/@open-draft+deferred-promise@2.1.0/node_modules/@open-draft/deferred-promise/build/index.js"(t){var e=t&&t.__createBinding||(Object.create?function(i,r,s,o){o===void 0&&(o=s);var a=Object.getOwnPropertyDescriptor(r,s);(!a||("get"in a?!r.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return r[s]}}),Object.defineProperty(i,o,a)}:function(i,r,s,o){o===void 0&&(o=s),i[o]=r[s]}),n=t&&t.__exportStar||function(i,r){for(var s in i)s!=="default"&&!Object.prototype.hasOwnProperty.call(r,s)&&e(r,i,s)};Object.defineProperty(t,"__esModule",{value:!0}),n(Sw(),t),n(BZ(),t)}}),Pw=Cn({"../../node_modules/.pnpm/strict-event-emitter@0.4.3/node_modules/strict-event-emitter/lib/MemoryLeakError.js"(t){Object.defineProperty(t,"__esModule",{value:!0}),t.MemoryLeakError=void 0;var e=class extends Error{constructor(i,r,s){super(`Possible EventEmitter memory leak detected. ${s} ${r.toString()} listeners added. Use emitter.setMaxListeners() to increase limit`);Ze(this,"emitter");Ze(this,"type");Ze(this,"count");this.emitter=i,this.type=r,this.count=s,this.name="MaxListenersExceededWarning"}};t.MemoryLeakError=e}}),UZ=Cn({"../../node_modules/.pnpm/strict-event-emitter@0.4.3/node_modules/strict-event-emitter/lib/Emitter.js"(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Emitter=void 0;var e=Pw(),n,i,r,s,o,a,l,c,u,d,p,f=class{constructor(){Ui(this,s),Ui(this,a),Ui(this,c),Ui(this,d),Ui(this,n,void 0),Ui(this,i,void 0),Ui(this,r,void 0),ao(this,n,new Map),ao(this,i,f.defaultMaxListeners),ao(this,r,!1)}static listenerCount(m,g){return m.listenerCount(g)}setMaxListeners(m){return ao(this,i,m),this}getMaxListeners(){return zt(this,i)}eventNames(){return Array.from(zt(this,n).keys())}emit(m,...g){const O=on(this,s,o).call(this,m);return O.forEach(v=>{v.apply(this,g)}),O.length>0}addListener(m,g){on(this,d,p).call(this,"newListener",m,g);const O=on(this,s,o).call(this,m).concat(g);if(zt(this,n).set(m,O),zt(this,i)>0&&this.listenerCount(m)>zt(this,i)&&!zt(this,r)){ao(this,r,!0);const v=new e.MemoryLeakError(this,m,this.listenerCount(m));console.warn(v)}return this}on(m,g){return this.addListener(m,g)}once(m,g){return this.addListener(m,on(this,c,u).call(this,m,g))}prependListener(m,g){const O=on(this,s,o).call(this,m);if(O.length>0){const v=[g].concat(O);zt(this,n).set(m,v)}else zt(this,n).set(m,O.concat(g));return this}prependOnceListener(m,g){return this.prependListener(m,on(this,c,u).call(this,m,g))}removeListener(m,g){const O=on(this,s,o).call(this,m);return O.length>0&&(on(this,a,l).call(this,O,g),zt(this,n).set(m,O),on(this,d,p).call(this,"removeListener",m,g)),this}off(m,g){return this.removeListener(m,g)}removeAllListeners(m){return m?zt(this,n).delete(m):zt(this,n).clear(),this}listeners(m){return Array.from(on(this,s,o).call(this,m))}listenerCount(m){return on(this,s,o).call(this,m).length}rawListeners(m){return this.listeners(m)}},h=f;n=new WeakMap,i=new WeakMap,r=new WeakMap,s=new WeakSet,o=function(m){return zt(this,n).get(m)||[]},a=new WeakSet,l=function(m,g){const O=m.indexOf(g);return O>-1&&m.splice(O,1),[]},c=new WeakSet,u=function(m,g){const O=(...v)=>{this.removeListener(m,O),g.apply(this,v)};return O},d=new WeakSet,p=function(m,g,O){this.emit(m,g,O)},qZ(h,"defaultMaxListeners",10),t.Emitter=h}}),FZ=Cn({"../../node_modules/.pnpm/strict-event-emitter@0.4.3/node_modules/strict-event-emitter/lib/index.js"(t){var e=t&&t.__createBinding||(Object.create?function(i,r,s,o){o===void 0&&(o=s);var a=Object.getOwnPropertyDescriptor(r,s);(!a||("get"in a?!r.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return r[s]}}),Object.defineProperty(i,o,a)}:function(i,r,s,o){o===void 0&&(o=s),i[o]=r[s]}),n=t&&t.__exportStar||function(i,r){for(var s in i)s!=="default"&&!Object.prototype.hasOwnProperty.call(r,s)&&e(r,i,s)};Object.defineProperty(t,"__esModule",{value:!0}),n(UZ(),t),n(Pw(),t)}}),GZ=Rr(ww()),HZ=/(%?)(%([sdjo]))/g;function JZ(t,e){switch(e){case"s":return t;case"d":case"i":return Number(t);case"j":return JSON.stringify(t);case"o":{if(typeof t=="string")return t;const n=JSON.stringify(t);return n==="{}"||n==="[]"||/^\[object .+?\]$/.test(n)?t:n}}}function Ct(t,...e){if(e.length===0)return t;let n=0,i=t.replace(HZ,(r,s,o,a)=>{const l=e[n],c=JZ(l,a);return s?r:(n++,c)});return n<e.length&&(i+=` ${e.slice(n).join(" ")}`),i=i.replace(/%{2,2}/g,"%"),i}var KZ=2;function eN(t){if(!t.stack)return;const e=t.stack.split(`
761
761
  `);e.splice(1,KZ),t.stack=e.join(`
762
762
  `)}var tN=class extends Error{constructor(t,...e){super(t),this.message=t,this.name="Invariant Violation",this.message=Ct(t,...e),eN(this)}},Wn=(t,e,...n)=>{if(!t)throw new tN(e,...n)};Wn.as=(t,e,n,...i)=>{if(!e)throw t.prototype.name!=null?new t(Ct(n,i)):t(Ct(n,i))};var Kp=Rr(Jp()),nN=window.localStorage.CSB_EMULATOR_DEBUG,iN="\x1B[0m",rN="\x1B[32;1m",sN="\x1B[31m",oN="\x1B[34m",aN="\x1B[33;1m",lN="\x1B[35;1m",kw="\x1B[36;1m",cN={preview:aN,emulator:lN,runtime:kw,bridge:oN,"runtime:worker":kw};function $w(t){return function(n,...i){if(nN==="true"){const r=()=>n.includes("sender")?`${rN}sender`:n.includes("receiver")?`${sN}receiver`:"",s=n.replace(/\[.+\]:/,"");console.debug(`${cN[t]}${t}:${r()}${iN}:${s}`,...i)}}}var xi=$w("emulator"),uN=class{constructor(t){Ze(this,"emitter");Ze(this,"channel");Ze(this,"receiverPort");Ze(this,"receiverReadyPromise");this.target=t,this.emitter=new EventTarget,this.channel=new MessageChannel,this.receiverPort=this.channel.port1;const e=new Kp.DeferredPromise,n=i=>{i.data.type==="internal/ready"&&(xi("[message-sender]: runtime is ready"),e.resolve())};window.addEventListener("message",n),e.then(()=>{window.removeEventListener("message",n)}),this.receiverReadyPromise=e,this.receiverPort.onmessage=i=>{const r=i.data;r.type!=null&&(xi('[message-sender]: emitting "%s" event...',r.type,r.payload),this.emitter.dispatchEvent(new MessageEvent(r.type,{data:r.payload})))}}async handshake(){const t=new Kp.DeferredPromise;await this.receiverReadyPromise,xi("[message-sender]: sending handshake"),this.target.postMessage({type:"internal/handshake"},"*",[this.channel.port2]),this.on("internal/handshake/done",()=>{t.resolve(),clearTimeout(e)});const e=setTimeout(()=>{t.reject(new Error("MessageSender: Handshake timeout"))},5e3);return t}on(t,e,n){xi('[message-sender]: add listener "%s"',t),this.emitter.addEventListener(t,i=>{i instanceof MessageEvent&&e(i)},n)}off(t,e,n){this.emitter.removeEventListener(t,e,n)}async send(t,...e){const n=new Kp.DeferredPromise,i=(0,GZ.default)(),r=e[0]||{};xi('[message-sender]: send "%s" (%s)',t,i,r),this.receiverPort.postMessage({type:t,payload:{operationId:i,payload:r}}),xi('[message-sender]: adding done listener for "%s" (%s)',t,i);const s=a=>{const{data:l}=a;if(l.operationId===i){const c=l.listenerPayload||{};xi('[message-sender]: resolving "%s (%s) promise!',t,i),n.resolve({...c,operationId:l.operationId})}},o=a=>{const{data:l}=a;l.operationId===i&&(xi('[message-sender]: rejecting "%s (%s) promise!',t,i),n.reject(l.error))};return this.on("internal/operation/done",s),this.on("internal/operation/failed",o),n.finally(()=>{this.emitter.removeEventListener("internal/operation/done",s),this.emitter.removeEventListener("internal/operation/failed",o)})}},Tw=Rr(Jp()),dN=Rr(ww()),pN=class{constructor(t){this.channel=t}async init(t){await this.channel.send("fs/init",{files:t})}async readFile(t,e){const n=await this.channel.send("fs/readFile",{path:t,encoding:e}).catch(i=>{throw new Error(Ct('Failed to read file at path "%s"',t),{cause:i})});if(!n)throw new Error("File not found");return n.data}async writeFile(t,e,n){let i,r=!1;typeof n=="object"?(i=n.encoding,r=!!n.recursive):typeof n=="string"&&(i=n),await this.channel.send("fs/writeFile",{path:t,content:e,encoding:i,recursive:r}).catch(s=>{throw new Error(Ct('Failed to write file at path "%s"',t),{cause:s})})}async readdir(t){const e=await this.channel.send("fs/readdir",{path:t}).catch(n=>{throw new Error(Ct('Failed to read directory at path "%s"',t),{cause:n})});if(!e)throw new Error("Directory not found");return e.data}async mkdir(t,e){const n=!!(e!=null&&e.recursive);await this.channel.send("fs/mkdir",{path:t,recursive:n}).catch(i=>{throw new Error(Ct('Failed to make directory at path "%s"',t),{cause:i})})}async stat(t){const e=await this.channel.send("fs/stat",{path:t}).catch(n=>{throw new Error(Ct('Failed to stat file at path "%s"',t),{cause:n})});if(!e)throw new Error("File not found");return e.data}async rm(t,e){const{force:n,recursive:i}=e||{};await this.channel.send("fs/rm",{path:t,force:n,recursive:i}).catch(r=>{throw new Error(Ct('Failed to remove file at path "%s"',t),{cause:r})})}async watch(t,e,n){const i=(0,dN.default)();return await this.channel.send("fs/watch",{watcherId:i,includes:t,excludes:e}),this.channel.on("fs/watch-event",({data:r})=>{if(r.watcherId===i&&n){const s={...r};delete s.watcherId,n(s)}}),{dispose:()=>this.channel.send("fs/unwatch",{watcherId:i})}}},Qw=Rr(FZ()),fN=class{constructor(t){this.channel=t}create(){return new hN(this.channel)}},hN=class{constructor(t){Ze(this,"id");Ze(this,"state");Ze(this,"stdout");Ze(this,"stderr");Ze(this,"stdin");this.channel=t,this.state="running",this.stdout=new Qw.Emitter,this.stderr=new Qw.Emitter,this.stdin={write:e=>{if(!this.id)throw new Error("Failed to write to stdin, no process is currently running");return this.channel.send("shell/stdin",{data:e,workerId:this.id})}},this.forwardStdEvents()}forwardStdEvents(){this.channel.on("worker/tty",t=>{const{data:e}=t;if(e.workerId===this.id)switch(e.payload.type){case"out":{this.stdout.emit("data",e.payload.data);break}case"err":{this.stderr.emit("data",e.payload.data);break}}})}async runCommand(t,e,n={}){Wn(!this.id,'Failed to run "runCommand" on a ShellProcess: there is already a process running.');const i=await this.channel.send("shell/runCommand",{command:t,args:e,options:n});return Wn(i,'Failed to run "runCommand" on a ShellProcess: was not able to retrieve a running process.'),this.id=i.id,this.state="running",i}async on(t,e){switch(t){case"progress":{this.channel.on("worker/progress",({data:n})=>{e(n.status)});return}case"exit":{this.channel.on("worker/exit",({data:n})=>{n.workerId===this.id&&e(n.exitCode,n.error)});return}}}async kill(){Wn(this.id,'Failed to run "kill" on a ShellProcess: there is no process running. Did you forget to run it?'),this.state="idle",await this.channel.send("shell/exit",{id:this.id}).catch(t=>{throw new Error(Ct('Failed to kill shell with ID "%s"',this.id),{cause:t})}),this.id=void 0}},mN=Rr(Jp()),gN=2e4,vN=class{constructor(t){this.channel=t}async waitFor(t,e,n=gN){const i=new mN.DeferredPromise,r=setTimeout(()=>{i.reject()},n),s=await this.channel.send("preview/get/info",t).catch(a=>{i.reject(new Error(Ct('Failed to look up preview information for shell ID "%s" (port: %d)',t.sourceShellId,t.port)))}),o=s&&e(s);return o&&i.resolve({url:s.url,port:s.port,sourceShellId:s.sourceShellId}),this.channel.on("preview/port/ready",({data:a})=>{!o&&e(a)&&i.resolve({url:a.url,port:a.port,sourceShellId:a.sourceShellId})}),i.finally(()=>{clearTimeout(r)})}async getByShellId(t,e){return this.waitFor({sourceShellId:t},n=>n.sourceShellId===t,e).catch(n=>{throw new Error(Ct('Failed to get shell by ID "%s"',t),{cause:n})})}async waitForPort(t,e){return this.waitFor({port:t},n=>n.port===t,e).catch(n=>{throw new Error(Ct("Failed to await port %d",t),{cause:n})})}},ON="https://nodebox-runtime.codesandbox.io",Dl=$w("emulator"),xN=class{constructor(t){Ze(this,"channel",null);Ze(this,"isConnected");Ze(this,"url");Ze(this,"fileSystemApi",null);Ze(this,"shellApi",null);Ze(this,"previewApi",null);this.options=t,Wn(this.options.iframe,'Failed to create a Nodebox: expected "iframe" argument to be a reference to an <iframe> element but got %j',this.options.iframe),this.url=this.options.runtimeUrl||ON,this.isConnected=!1}async connect(){const{iframe:t,cdnUrl:e}=this.options;Dl("[message-sender]: Connecting to node emulator...");const n=new Tw.DeferredPromise;this.url||n.reject(new Error("Nodebox URL is missing. Did you forget to provide it when creating this Nodebox instance?")),Wn(t.contentWindow,"Failed to create a MessageChannel with the Nodebox iframe: no content window found"),this.channel=new uN(t.contentWindow);const i=new Tw.DeferredPromise;return t.setAttribute("src",this.url),t.addEventListener("load",()=>{i.resolve()},{once:!0}),t.addEventListener("error",r=>{i.reject(r.error)},{once:!0}),await i,Dl("[message-sender]: IFrame loaded..."),await this.channel.handshake(),Dl("[message-sender]: Handshake completed..."),this.channel.send("connect",{cdnUrl:e}),this.channel.on("runtime/ready",()=>{n.resolve()}),n.then(()=>{Dl("[message-sender]: Connected to runtime..."),this.isConnected=!0})}get fs(){return Wn(this.isConnected,'Failed to access the File System API: consumer is not connected. Did you forget to run "connect()"?'),this.fileSystemApi?this.fileSystemApi:(this.fileSystemApi=new pN(this.channel),this.fileSystemApi)}get shell(){return Wn(this.isConnected,'Failed to access the Shell API: consumer is not connected. Did you forget to run "connect()"?'),this.shellApi?this.shellApi:(this.shellApi=new fN(this.channel),this.shellApi)}get preview(){return Wn(this.isConnected,'Failed to access the Preview API: consumer is not connected. Did you forget to run "connect()"?'),this.previewApi?this.previewApi:(this.previewApi=new vN(this.channel),this.previewApi)}},bN="INJECT_AND_INVOKE",yN="PREVIEW_LOADED",ef=function(){function t(e,n,i){i===void 0&&(i={}),this.status="idle",this.options=i,this.sandboxSetup=n,this.iframeSelector=e}return t.prototype.updateOptions=function(e){Pi(this.options,e)||(this.options=e,this.updateSandbox())},t.prototype.updateSandbox=function(e,n){throw e===void 0&&(e=this.sandboxSetup),Error("Method not implemented")},t.prototype.destroy=function(){throw Error("Method not implemented")},t.prototype.dispatch=function(e){throw Error("Method not implemented")},t.prototype.listen=function(e){throw Error("Method not implemented")},t}(),Cw=function(){function t(){this.listeners={},this.listenersCount=0,this.channelId=Math.floor(Math.random()*1e6),this.listeners=[]}return t.prototype.cleanup=function(){this.listeners={},this.listenersCount=0},t.prototype.dispatch=function(e){Object.values(this.listeners).forEach(function(n){return n(e)})},t.prototype.listener=function(e){var n=this;if(typeof e!="function")return function(){};var i=this.listenersCount;return this.listeners[i]=e,this.listenersCount++,function(){delete n.listeners[i]}},t}();function Ew(t){return/[a-zA-Z.]/.test(t)}function jw(t){return/[a-zA-Z]/.test(t)}function wN(t){return/\s/.test(t)}function Aw(t){return/[&|]/.test(t)}function Dw(t){return/-/.test(t)}function SN(t){return/["']/.test(t)}function Mw(t){return jw(t)&&t===t.toUpperCase()}var yt;(function(t){t.OR="OR",t.AND="AND",t.PIPE="PIPE",t.Command="Command",t.Argument="Argument",t.String="String",t.EnvVar="EnvVar"})(yt||(yt={}));var PN=new Map([["&&",{type:yt.AND}],["||",{type:yt.OR}],["|",{type:yt.PIPE}],["-",{type:yt.Argument}]]);function kN(t){var e=0,n=[];function i(){for(var c="";Ew(t[e])&&e<t.length;)c+=t[e],e++;return{type:yt.Command,value:c}}function r(){for(var c="";Aw(t[e])&&e<t.length;)c+=t[e],e++;return PN.get(c)}function s(){for(var c="";(Dw(t[e])||jw(t[e]))&&e<t.length;)c+=t[e],e++;return{type:yt.Argument,value:c}}function o(){var c=t[e],u=t[e];for(e++;t[e]!==c&&e<t.length;)u+=t[e],e++;return u+=t[e],e++,{type:yt.String,value:u}}function a(){for(var c={},u=function(){for(var d="",p="";t[e]!=="="&&e<t.length;)d+=t[e],e++;for(t[e]==="="&&e++;t[e]!==" "&&e<t.length;)p+=t[e],e++;c[d]=p};Mw(t[e])&&e<t.length;)u(),e++;return{type:yt.EnvVar,value:c}}for(;e<t.length;){var l=t[e];if(wN(l)){e++;continue}switch(!0){case Mw(l):n.push(a());break;case Ew(l):n.push(i());break;case Aw(l):n.push(r());break;case Dw(l):n.push(s());break;case SN(l):n.push(o());break;default:throw new Error("Unknown character: ".concat(l))}}return n}var $N=0;function Rw(){var t=Date.now(),e=Math.round(Math.random()*1e4),n=$N+=1;return(+"".concat(t).concat(e).concat(n)).toString(16)}var Ml=function(t){return typeof t=="string"?new TextEncoder().encode(t):t},tf=function(t){return typeof t=="string"?t:new TextDecoder().decode(t)},_w=function(t){return Object.entries(t).reduce(function(e,n){var i=n[0],r=n[1];return e[i]=Ml(r.code),e},{})},TN=function(t){var e={},n=["dev","start"];try{e=JSON.parse(t).scripts}catch(o){throw ki("Could not parse package.json file: "+o.message)}Fl(e,"Failed to start. Please provide a `start` or `dev` script on the package.json");for(var i=function(o){if(n[o]in e){var a=n[o],l=e[a],c={},u="",d=[];return kN(l).forEach(function(p){var f=u==="";p.type===yt.EnvVar&&(c=p.value),p.type===yt.Command&&f&&(u=p.value),(p.type===yt.Argument||!f&&p.type===yt.Command)&&d.push(p.value)}),{value:[u,d,{env:c}]}}},r=0;r<n.length;r++){var s=i(r);if(typeof s=="object")return s.value}throw ki("Failed to start. Please provide a `start` or `dev` script on the package.json")},Iw=function(t){return typeof t=="string"?t:typeof t=="object"&&"message"in t?t.message:ki("The server could not be reached. Make sure that the node script is running and that a port has been started.")},Zw=`var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};function r(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var e={},n={};!function(t){t.__esModule=!0,t.default=["log","debug","info","warn","error","table","clear","time","timeEnd","count","assert","command","result"]}(n);var a,o={},i={};(a=i).__esModule=!0,a.default=function(){var t=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};return t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+"-"+Date.now()};var u={},s={__esModule:!0};s.update=s.state=void 0,s.update=function(t){s.state=t};var f={},c={};!function(r){var e=t&&t.__assign||function(){return e=Object.assign||function(t){for(var r,e=1,n=arguments.length;e<n;e++)for(var a in r=arguments[e])Object.prototype.hasOwnProperty.call(r,a)&&(t[a]=r[a]);return t},e.apply(this,arguments)};r.__esModule=!0,r.initialState=void 0,r.initialState={timings:{},count:{}};var n=function(){return"undefined"!=typeof performance&&performance.now?performance.now():Date.now()};r.default=function(t,a){var o,i,u;switch(void 0===t&&(t=r.initialState),a.type){case"COUNT":var s=t.count[a.name]||0;return e(e({},t),{count:e(e({},t.count),(o={},o[a.name]=s+1,o))});case"TIME_START":return e(e({},t),{timings:e(e({},t.timings),(i={},i[a.name]={start:n()},i))});case"TIME_END":var f=t.timings[a.name],c=n(),l=c-f.start;return e(e({},t),{timings:e(e({},t.timings),(u={},u[a.name]=e(e({},f),{end:c,time:l}),u))});default:return t}}}(c),function(r){var e=t&&t.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};r.__esModule=!0;var n=e(c),a=s;r.default=function(t){a.update(n.default(a.state,t))}}(f);var l={__esModule:!0};l.timeEnd=l.timeStart=l.count=void 0,l.count=function(t){return{type:"COUNT",name:t}},l.timeStart=function(t){return{type:"TIME_START",name:t}},l.timeEnd=function(t){return{type:"TIME_END",name:t}};var d=t&&t.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};u.__esModule=!0,u.stop=u.start=void 0;var p=s,h=d(f),m=l;u.start=function(t){h.default(m.timeStart(t))},u.stop=function(t){var r=null===p.state||void 0===p.state?void 0:p.state.timings[t];return r&&!r.end?(h.default(m.timeEnd(t)),{method:"log",data:[t+": "+p.state.timings[t].time+"ms"]}):{method:"warn",data:["Timer '"+t+"' does not exist"]}};var y={},v=t&&t.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};y.__esModule=!0,y.increment=void 0;var _=s,b=v(f),g=l;y.increment=function(t){return b.default(g.count(t)),{method:"log",data:[t+": "+_.state.count[t]]}};var M={},T=t&&t.__spreadArrays||function(){for(var t=0,r=0,e=arguments.length;r<e;r++)t+=arguments[r].length;var n=Array(t),a=0;for(r=0;r<e;r++)for(var o=arguments[r],i=0,u=o.length;i<u;i++,a++)n[a]=o[i];return n};M.__esModule=!0,M.test=void 0,M.test=function(t){for(var r=[],e=1;e<arguments.length;e++)r[e-1]=arguments[e];return!t&&(0===r.length&&r.push("console.assert"),{method:"error",data:T(["Assertion failed:"],r)})},function(r){var e=t&&t.__assign||function(){return e=Object.assign||function(t){for(var r,e=1,n=arguments.length;e<n;e++)for(var a in r=arguments[e])Object.prototype.hasOwnProperty.call(r,a)&&(t[a]=r[a]);return t},e.apply(this,arguments)},n=t&&t.__createBinding||(Object.create?function(t,r,e,n){void 0===n&&(n=e),Object.defineProperty(t,n,{enumerable:!0,get:function(){return r[e]}})}:function(t,r,e,n){void 0===n&&(n=e),t[n]=r[e]}),a=t&&t.__setModuleDefault||(Object.create?function(t,r){Object.defineProperty(t,"default",{enumerable:!0,value:r})}:function(t,r){t.default=r}),o=t&&t.__importStar||function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var e in t)"default"!==e&&Object.prototype.hasOwnProperty.call(t,e)&&n(r,t,e);return a(r,t),r},s=t&&t.__spreadArrays||function(){for(var t=0,r=0,e=arguments.length;r<e;r++)t+=arguments[r].length;var n=Array(t),a=0;for(r=0;r<e;r++)for(var o=arguments[r],i=0,u=o.length;i<u;i++,a++)n[a]=o[i];return n},f=t&&t.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};r.__esModule=!0;var c=f(i),l=o(u),d=o(y),p=o(M);r.default=function(t,r,n){var a=n||c.default();switch(t){case"clear":return{method:t,id:a};case"count":return!!(o="string"==typeof r[0]?r[0]:"default")&&e(e({},d.increment(o)),{id:a});case"time":case"timeEnd":var o;return!!(o="string"==typeof r[0]?r[0]:"default")&&("time"===t?(l.start(o),!1):e(e({},l.stop(o)),{id:a}));case"assert":if(0!==r.length){var i=p.test.apply(p,s([r[0]],r.slice(1)));if(i)return e(e({},i),{id:a})}return!1;case"error":return{method:t,id:a,data:r.map((function(t){try{return t.stack||t}catch(r){return t}}))};default:return{method:t,id:a,data:r}}}}(o);var S={},O={};!function(t){var r;t.__esModule=!0,function(t){t[t.infinity=0]="infinity",t[t.minusInfinity=1]="minusInfinity",t[t.minusZero=2]="minusZero"}(r||(r={})),t.default={type:"Arithmetic",lookup:Number,shouldTransform:function(t,r){return"number"===t&&(r===1/0||r===-1/0||function(t){return 1/t==-1/0}(r))},toSerializable:function(t){return t===1/0?r.infinity:t===-1/0?r.minusInfinity:r.minusZero},fromSerializable:function(t){return t===r.infinity?1/0:t===r.minusInfinity?-1/0:t===r.minusZero?-0:t}}}(O);var w={};!function(t){t.__esModule=!0,t.default={type:"Function",lookup:Function,shouldTransform:function(t,r){return"function"==typeof r},toSerializable:function(t){var r="";try{r=t.toString().substring(r.indexOf("{")+1,r.lastIndexOf("}"))}catch(t){}return{name:t.name,body:r,proto:Object.getPrototypeOf(t).constructor.name}},fromSerializable:function(t){try{var r=function(){};return"string"==typeof t.name&&Object.defineProperty(r,"name",{value:t.name,writable:!1}),"string"==typeof t.body&&Object.defineProperty(r,"body",{value:t.body,writable:!1}),"string"==typeof t.proto&&(r.constructor={name:t.proto}),r}catch(r){return t}}}}(w);var A={};!function(t){var r;function e(t){for(var r={},e=0,n=t.attributes;e<n.length;e++){var a=n[e];r[a.name]=a.value}return r}t.__esModule=!0,t.default={type:"HTMLElement",shouldTransform:function(t,r){return r&&r.children&&"string"==typeof r.innerHTML&&"string"==typeof r.tagName},toSerializable:function(t){return{tagName:t.tagName.toLowerCase(),attributes:e(t),innerHTML:t.innerHTML}},fromSerializable:function(t){try{var e=(r||(r=document.implementation.createHTMLDocument("sandbox"))).createElement(t.tagName);e.innerHTML=t.innerHTML;for(var n=0,a=Object.keys(t.attributes);n<a.length;n++){var o=a[n];try{e.setAttribute(o,t.attributes[o])}catch(t){}}return e}catch(r){return t}}}}(A);var j={};!function(r){var e=t&&t.__assign||function(){return e=Object.assign||function(t){for(var r,e=1,n=arguments.length;e<n;e++)for(var a in r=arguments[e])Object.prototype.hasOwnProperty.call(r,a)&&(t[a]=r[a]);return t},e.apply(this,arguments)};r.__esModule=!0,r.default={type:"Map",shouldTransform:function(t,r){return r&&r.constructor&&"Map"===r.constructor.name},toSerializable:function(t){var r={};return t.forEach((function(t,e){var n="object"==typeof e?JSON.stringify(e):e;r[n]=t})),{name:"Map",body:r,proto:Object.getPrototypeOf(t).constructor.name}},fromSerializable:function(t){var r=t.body,n=e({},r);return"string"==typeof t.proto&&(n.constructor={name:t.proto}),n}}}(j);var z={};!function(t){t.__esModule=!0;var r="@t",e=/^#*@(t|r)$/,n=(0,eval)("this"),a="function"==typeof ArrayBuffer,o="function"==typeof Map,i="function"==typeof Set,u=["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array"],s=Array.prototype.slice,f={serialize:function(t){return JSON.stringify(t)},deserialize:function(t){return JSON.parse(t)}},c=function(){function t(t,r){this.references=t,this.transforms=r,this.transformsMap=this._makeTransformsMap(),this.circularCandidates=[],this.circularCandidatesDescrs=[],this.circularRefCount=0}return t._createRefMark=function(t){var r=Object.create(null);return r["@r"]=t,r},t.prototype._createCircularCandidate=function(t,r,e){this.circularCandidates.push(t),this.circularCandidatesDescrs.push({parent:r,key:e,refIdx:-1})},t.prototype._applyTransform=function(t,e,n,a){var o=Object.create(null),i=a.toSerializable(t);return"object"==typeof i&&this._createCircularCandidate(t,e,n),o[r]=a.type,o.data=this._handleValue((function(){return i}),e,n),o},t.prototype._handleArray=function(t){for(var r=[],e=function(e){r[e]=n._handleValue((function(){return t[e]}),r,e)},n=this,a=0;a<t.length;a++)e(a);return r},t.prototype._handlePlainObject=function(t){var r,n,a=Object.create(null),o=function(r){if(Reflect.has(t,r)){var n=e.test(r)?"#"+r:r;a[n]=i._handleValue((function(){return t[r]}),a,n)}},i=this;for(var u in t)o(u);var s=null===(n=null===(r=null==t?void 0:t.__proto__)||void 0===r?void 0:r.constructor)||void 0===n?void 0:n.name;return s&&"Object"!==s&&(a.constructor={name:s}),a},t.prototype._handleObject=function(t,r,e){return this._createCircularCandidate(t,r,e),Array.isArray(t)?this._handleArray(t):this._handlePlainObject(t)},t.prototype._ensureCircularReference=function(r){var e=this.circularCandidates.indexOf(r);if(e>-1){var n=this.circularCandidatesDescrs[e];return-1===n.refIdx&&(n.refIdx=n.parent?++this.circularRefCount:0),t._createRefMark(n.refIdx)}return null},t.prototype._handleValue=function(t,r,e){try{var n=t(),a=typeof n,o="object"===a&&null!==n;if(o){var i=this._ensureCircularReference(n);if(i)return i}var u=this._findTransform(a,n);return u?this._applyTransform(n,r,e,u):o?this._handleObject(n,r,e):n}catch(t){try{return this._handleValue((function(){return t instanceof Error?t:new Error(t)}),r,e)}catch(t){return null}}},t.prototype._makeTransformsMap=function(){if(o){var t=new Map;return this.transforms.forEach((function(r){r.lookup&&t.set(r.lookup,r)})),t}},t.prototype._findTransform=function(t,r){if(o&&r&&r.constructor&&(null==(a=this.transformsMap.get(r.constructor))?void 0:a.shouldTransform(t,r)))return a;for(var e=0,n=this.transforms;e<n.length;e++){var a;if((a=n[e]).shouldTransform(t,r))return a}},t.prototype.transform=function(){for(var r=this,e=[this._handleValue((function(){return r.references}),null,null)],n=0,a=this.circularCandidatesDescrs;n<a.length;n++){var o=a[n];o.refIdx>0&&(e[o.refIdx]=o.parent[o.key],o.parent[o.key]=t._createRefMark(o.refIdx))}return e},t}(),l=function(){function t(t,r){this.activeTransformsStack=[],this.visitedRefs=Object.create(null),this.references=t,this.transformMap=r}return t.prototype._handlePlainObject=function(t){var r=Object.create(null);for(var n in"constructor"in t&&(t.constructor&&"string"==typeof t.constructor.name||(t.constructor={name:"Object"})),t)t.hasOwnProperty(n)&&(this._handleValue(t[n],t,n),e.test(n)&&(r[n.substring(1)]=t[n],delete t[n]));for(var a in r)t[a]=r[a]},t.prototype._handleTransformedObject=function(t,e,n){var a=t[r],o=this.transformMap[a];if(!o)throw new Error("Can't find transform for \\""+a+'" type.');this.activeTransformsStack.push(t),this._handleValue(t.data,t,"data"),this.activeTransformsStack.pop(),e[n]=o.fromSerializable(t.data)},t.prototype._handleCircularSelfRefDuringTransform=function(t,r,e){var n=this.references;Object.defineProperty(r,e,{val:void 0,configurable:!0,enumerable:!0,get:function(){return void 0===this.val&&(this.val=n[t]),this.val},set:function(t){this.val=t}})},t.prototype._handleCircularRef=function(t,r,e){this.activeTransformsStack.includes(this.references[t])?this._handleCircularSelfRefDuringTransform(t,r,e):(this.visitedRefs[t]||(this.visitedRefs[t]=!0,this._handleValue(this.references[t],this.references,t)),r[e]=this.references[t])},t.prototype._handleValue=function(t,e,n){if("object"==typeof t&&null!==t){var a=t["@r"];if(void 0!==a)this._handleCircularRef(a,e,n);else if(t[r])this._handleTransformedObject(t,e,n);else if(Array.isArray(t))for(var o=0;o<t.length;o++)this._handleValue(t[o],t,o);else this._handlePlainObject(t)}},t.prototype.transform=function(){return this.visitedRefs[0]=!0,this._handleValue(this.references[0],this.references,0),this.references[0]},t}(),d=[{type:"[[NaN]]",shouldTransform:function(t,r){return"number"===t&&isNaN(r)},toSerializable:function(){return""},fromSerializable:function(){return NaN}},{type:"[[undefined]]",shouldTransform:function(t){return"undefined"===t},toSerializable:function(){return""},fromSerializable:function(){}},{type:"[[Date]]",lookup:Date,shouldTransform:function(t,r){return r instanceof Date},toSerializable:function(t){return t.getTime()},fromSerializable:function(t){var r=new Date;return r.setTime(t),r}},{type:"[[RegExp]]",lookup:RegExp,shouldTransform:function(t,r){return r instanceof RegExp},toSerializable:function(t){var r={src:t.source,flags:""};return t.globalThis&&(r.flags+="g"),t.ignoreCase&&(r.flags+="i"),t.multiline&&(r.flags+="m"),r},fromSerializable:function(t){return new RegExp(t.src,t.flags)}},{type:"[[Error]]",lookup:Error,shouldTransform:function(t,r){return r instanceof Error},toSerializable:function(t){var r,e;return t.stack||null===(e=(r=Error).captureStackTrace)||void 0===e||e.call(r,t),{name:t.name,message:t.message,stack:t.stack}},fromSerializable:function(t){var r=new(n[t.name]||Error)(t.message);return r.stack=t.stack,r}},{type:"[[ArrayBuffer]]",lookup:a&&ArrayBuffer,shouldTransform:function(t,r){return a&&r instanceof ArrayBuffer},toSerializable:function(t){var r=new Int8Array(t);return s.call(r)},fromSerializable:function(t){if(a){var r=new ArrayBuffer(t.length);return new Int8Array(r).set(t),r}return t}},{type:"[[TypedArray]]",shouldTransform:function(t,r){if(a)return ArrayBuffer.isView(r)&&!(r instanceof DataView);for(var e=0,o=u;e<o.length;e++){var i=o[e];if("function"==typeof n[i]&&r instanceof n[i])return!0}return!1},toSerializable:function(t){return{ctorName:t.constructor.name,arr:s.call(t)}},fromSerializable:function(t){return"function"==typeof n[t.ctorName]?new n[t.ctorName](t.arr):t.arr}},{type:"[[Map]]",lookup:o&&Map,shouldTransform:function(t,r){return o&&r instanceof Map},toSerializable:function(t){var r=[];return t.forEach((function(t,e){r.push(e),r.push(t)})),r},fromSerializable:function(t){if(o){for(var r=new Map,e=0;e<t.length;e+=2)r.set(t[e],t[e+1]);return r}for(var n=[],a=0;a<t.length;a+=2)n.push([t[e],t[e+1]]);return n}},{type:"[[Set]]",lookup:i&&Set,shouldTransform:function(t,r){return i&&r instanceof Set},toSerializable:function(t){var r=[];return t.forEach((function(t){r.push(t)})),r},fromSerializable:function(t){if(i){for(var r=new Set,e=0;e<t.length;e++)r.add(t[e]);return r}return t}}],p=function(){function t(t){this.transforms=[],this.transformsMap=Object.create(null),this.serializer=t||f,this.addTransforms(d)}return t.prototype.addTransforms=function(t){for(var r=0,e=t=Array.isArray(t)?t:[t];r<e.length;r++){var n=e[r];if(this.transformsMap[n.type])throw new Error('Transform with type "'+n.type+'" was already added.');this.transforms.push(n),this.transformsMap[n.type]=n}return this},t.prototype.removeTransforms=function(t){for(var r=0,e=t=Array.isArray(t)?t:[t];r<e.length;r++){var n=e[r],a=this.transforms.indexOf(n);a>-1&&this.transforms.splice(a,1),delete this.transformsMap[n.type]}return this},t.prototype.encode=function(t){var r=new c(t,this.transforms).transform();return this.serializer.serialize(r)},t.prototype.decode=function(t){var r=this.serializer.deserialize(t);return new l(r,this.transformsMap).transform()},t}();t.default=p}(z);var E=t&&t.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};S.__esModule=!0,S.Decode=P=S.Encode=void 0;var k=E(O),C=E(w),D=E(A),I=E(j),N=E(z),R=[D.default,C.default,k.default,I.default],x=new N.default;x.addTransforms(R);var P=S.Encode=function(t){return JSON.parse(x.encode(t))};S.Decode=function(t){return x.decode(JSON.stringify(t))},function(r){var e=t&&t.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};r.__esModule=!0;var a=e(n),i=e(o),u=S;r.default=function(t,r,e){void 0===e&&(e=!0);for(var n=t,o={pointers:{},src:{npm:"https://npmjs.com/package/console-feed",github:"https://github.com/samdenty99/console-feed"}},s=function(t){var a=n[t];n[t]=function(){a.apply(this,arguments);var n=[].slice.call(arguments);setTimeout((function(){var a=i.default(t,n);if(a){var o=a;e&&(o=u.Encode(a)),r(o,a)}}))},o.pointers[t]=a},f=0,c=a.default;f<c.length;f++)s(c[f]);return n.feed=o,n}}(e),r(e)(window.console,(function(t){var r=P(t);parent.postMessage({type:"console",codesandbox:!0,log:Array.isArray(r)?r[0]:r,channelId:scope.channelId},"*")}));
763
763
  `;function QN(t,e){return gt(this,void 0,void 0,function(){var n,i,r,s,o;return vt(this,function(a){return n=t.contentWindow,Fn(n,"Failed to await preview iframe: no content window found"),i=9e4,r=20,s=0,[2,new Promise(function(l,c){var u=function(){var d=function(){clearTimeout(o),s=r,l(),t.removeEventListener("load",d)};if(s>=r){c(ki("Could not able to connect to preview."));return}t.setAttribute("src",e),o=setTimeout(function(){u(),t.removeEventListener("load",d)},i),s=s+1,t.addEventListener("load",d)};t.addEventListener("error",function(){return c(new Error("Iframe error"))}),t.addEventListener("abort",function(){return c(new Error("Aborted"))}),u()})]})})}var CN=function(t,e){t.style.border="0",t.style.width=e.width||"100%",t.style.height=e.height||"100%",t.style.overflow="hidden",t.allow="cross-origin-isolated"};function EN(t){var e=t.scope,n=window.history.__proto__,i=[],r=0,s=function(l){parent.postMessage({type:"urlchange",url:l,back:r>0,forward:r<i.length-1,channelId:e.channelId},"*")};function o(l,c){i.splice(r+1),i.push({url:l,state:c}),r=i.length-1}Object.assign(window.history,{go:function(l){var c=r+l;if(c>=0&&c<=i.length-1){r=c;var u=i[r],d=u.url,p=u.state;n.replaceState.call(window.history,p,"",d);var f=document.location.href;s(f),window.dispatchEvent(new PopStateEvent("popstate",{state:p}))}},back:function(){window.history.go(-1)},forward:function(){window.history.go(1)},pushState:function(l,c,u){n.replaceState.call(window.history,l,c,u),o(u,l),s(document.location.href)},replaceState:function(l,c,u){n.replaceState.call(window.history,l,c,u),i[r]={state:l,url:u},s(document.location.href)}});function a(l){var c=l.data;c.type==="urlback"?history.back():c.type==="urlforward"?history.forward():c.type==="refresh"&&document.location.reload()}window.addEventListener("message",a)}function jN(t){var e=t.scope,n=0;function i(){if(typeof window>"u")return 0;var a=document.body,l=document.documentElement;return Math.max(a.scrollHeight,a.offsetHeight,l.offsetHeight)}function r(){var a=i();n!==a&&window.parent.postMessage({type:"resize",height:a,codesandbox:!0,channelId:e.channelId},"*"),n=a}r();var s,o=new MutationObserver(function(){s===void 0&&(r(),s=setTimeout(function(){s=void 0},300))});o.observe(document,{attributes:!0,childList:!0,subtree:!0}),setInterval(r,300)}var AN=[{code:EN.toString(),id:"historyListener"},{code:"function consoleHook({ scope }) {"+Zw+`
@@ -776,4 +776,4 @@ declare module "*.vue" {
776
776
  const scope = `.concat(JSON.stringify(o),`;
777
777
  `).concat(r,`
778
778
  <\/script>
779
- `).trim();return this.injectContentIntoHead(n,a)},e.prototype.updateSandbox=function(n,i){n===void 0&&(n=this.sandboxSetup);var r=_w(n.files);this.dispatch({codesandbox:!0,modules:r,template:n.template,type:"compile"})},e.prototype.compile=function(n){return gt(this,void 0,void 0,function(){var i;return vt(this,function(r){switch(r.label){case 0:return this.files=new Map(Object.entries(n)),[4,this.previewController.initPreview()];case 1:return i=r.sent(),this.iframe.setAttribute("src",i),this.status="done",this.dispatch({type:"done",compilatonError:!1}),this.dispatch({type:"urlchange",url:i,back:!1,forward:!1}),[2]}})})},e.prototype.eventListener=function(n){if(n.source===this.iframe.contentWindow){var i=n.data;i.codesandbox&&this.dispatch(i)}},e.prototype.dispatch=function(n){var i;switch(n.type){case"compile":this.compile(n.modules);break;default:(i=this.iframe.contentWindow)===null||i===void 0||i.postMessage(n,"*"),this.emitter.dispatch(n)}},e.prototype.listen=function(n){return this.emitter.listener(n)},e.prototype.destroy=function(){this.emitter.cleanup(),typeof window<"u"&&window.removeEventListener("message",this.eventListener)},e}(ef);const tL=Object.freeze(Object.defineProperty({__proto__:null,SandpackStatic:eL},Symbol.toStringTag,{value:"Module"}));var nL=function(){function t(e,n,i){var r=this;this.type=e,this.handleMessage=n,this.protocol=i,this._disposeMessageListener=this.protocol.channelListen(function(s){return gt(r,void 0,void 0,function(){var o,a,c,l,c;return vt(this,function(u){switch(u.label){case 0:if(!(s.type===this.getTypeId()&&s.method))return[3,4];o=s,u.label=1;case 1:return u.trys.push([1,3,,4]),[4,this.handleMessage(o)];case 2:return a=u.sent(),c={type:this.getTypeId(),msgId:o.msgId,result:a},this.protocol.dispatch(c),[3,4];case 3:return l=u.sent(),c={type:this.getTypeId(),msgId:o.msgId,error:{message:l.message}},this.protocol.dispatch(c),[3,4];case 4:return[2]}})})})}return t.prototype.getTypeId=function(){return"protocol-".concat(this.type)},t.prototype.dispose=function(){this._disposeMessageListener()},t}(),iL=function(){function t(e,n){this.globalListeners={},this.globalListenersCount=0,this.channelListeners={},this.channelListenersCount=0,this.channelId=Math.floor(Math.random()*1e6),this.frameWindow=e.contentWindow,this.origin=n,this.globalListeners=[],this.channelListeners=[],this.eventListener=this.eventListener.bind(this),typeof window<"u"&&window.addEventListener("message",this.eventListener)}return t.prototype.cleanup=function(){window.removeEventListener("message",this.eventListener),this.globalListeners={},this.channelListeners={},this.globalListenersCount=0,this.channelListenersCount=0},t.prototype.register=function(){this.frameWindow&&this.frameWindow.postMessage({type:"register-frame",origin:document.location.origin,id:this.channelId},this.origin)},t.prototype.dispatch=function(e){this.frameWindow&&this.frameWindow.postMessage(Me({$id:this.channelId,codesandbox:!0},e),this.origin)},t.prototype.globalListen=function(e){var n=this;if(typeof e!="function")return function(){};var i=this.globalListenersCount;return this.globalListeners[i]=e,this.globalListenersCount++,function(){delete n.globalListeners[i]}},t.prototype.channelListen=function(e){var n=this;if(typeof e!="function")return function(){};var i=this.channelListenersCount;return this.channelListeners[i]=e,this.channelListenersCount++,function(){delete n.channelListeners[i]}},t.prototype.eventListener=function(e){if(e.source===this.frameWindow){var n=e.data;n.codesandbox&&(Object.values(this.globalListeners).forEach(function(i){return i(n)}),n.$id===this.channelId&&Object.values(this.channelListeners).forEach(function(i){return i(n)}))}},t}(),rL=50;function sL(t,e){if(!t)return"static";var n=t.dependencies,i=n===void 0?{}:n,r=t.devDependencies,s=r===void 0?{}:r,o=vo(vo([],Object.keys(i),!0),Object.keys(s),!0),a=Object.keys(e),l=["@adonisjs/framework","@adonisjs/core"];if(o.some(function(h){return l.indexOf(h)>-1}))return"adonis";var c=["nuxt","nuxt-edge","nuxt-ts","nuxt-ts-edge","nuxt3"];if(o.some(function(h){return c.indexOf(h)>-1}))return"nuxt";if(o.indexOf("next")>-1)return"next";var u=["apollo-server","apollo-server-express","apollo-server-hapi","apollo-server-koa","apollo-server-lambda","apollo-server-micro"];if(o.some(function(h){return u.indexOf(h)>-1}))return"apollo";if(o.indexOf("mdx-deck")>-1)return"mdx-deck";if(o.indexOf("gridsome")>-1)return"gridsome";if(o.indexOf("vuepress")>-1)return"vuepress";if(o.indexOf("ember-cli")>-1)return"ember";if(o.indexOf("sapper")>-1)return"sapper";if(o.indexOf("gatsby")>-1)return"gatsby";if(o.indexOf("quasar")>-1)return"quasar";if(o.indexOf("@docusaurus/core")>-1)return"docusaurus";if(o.indexOf("remix")>-1)return"remix";if(o.indexOf("astro")>-1)return"node";if(a.some(function(h){return h.endsWith(".re")}))return"reason";var d=["parcel-bundler","parcel"];if(o.some(function(h){return d.indexOf(h)>-1}))return"parcel";var p=["@dojo/core","@dojo/framework"];if(o.some(function(h){return p.indexOf(h)>-1}))return"@dojo/cli-create-app";if(o.indexOf("@nestjs/core")>-1||o.indexOf("@nestjs/common")>-1)return"nest";if(o.indexOf("react-styleguidist")>-1)return"styleguidist";if(o.indexOf("react-scripts")>-1)return"create-react-app";if(o.indexOf("react-scripts-ts")>-1)return"create-react-app-typescript";if(o.indexOf("@angular/core")>-1)return"angular-cli";if(o.indexOf("preact-cli")>-1)return"preact-cli";if(o.indexOf("@sveltech/routify")>-1||o.indexOf("@roxi/routify")>-1||o.indexOf("vite")>-1||o.indexOf("@frontity/core")>-1)return"node";if(o.indexOf("svelte")>-1)return"svelte";if(o.indexOf("vue")>-1)return"vue-cli";if(o.indexOf("cx")>-1)return"cxjs";var f=["express","koa","nodemon","ts-node","@tensorflow/tfjs-node","webpack-dev-server","snowpack"];if(o.some(function(h){return f.indexOf(h)>-1})||Object.keys(i).length>=rL)return"node"}var rf,oL="https://".concat((rf="2.13.8")===null||rf===void 0?void 0:rf.replace(/\./g,"-"),"-sandpack.codesandbox.io/"),aL=function(t){Hl(e,t);function e(n,i,r){r===void 0&&(r={});var s=t.call(this,n,i,r)||this;if(s.getTranspilerContext=function(){return new Promise(function(a){var l=s.listen(function(c){c.type==="transpiler-context"&&(a(c.data),l())});s.dispatch({type:"get-transpiler-context"})})},s.bundlerURL=r.bundlerURL||oL,r.teamId&&(s.bundlerURL=s.bundlerURL.replace("https://","https://"+r.teamId+"-")+"?cache=".concat(Date.now())),s.bundlerState=void 0,s.errors=[],s.status="initializing",typeof n=="string"){s.selector=n;var o=document.querySelector(n);Fn(o,"The element '".concat(n,"' was not found")),s.element=o,s.iframe=document.createElement("iframe"),s.initializeElement()}else s.element=n,s.iframe=n;return s.iframe.getAttribute("sandbox")||(s.iframe.setAttribute("sandbox","allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts allow-downloads allow-pointer-lock"),s.iframe.setAttribute("allow","accelerometer; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; clipboard-write;")),s.setLocationURLIntoIFrame(),s.iframeProtocol=new iL(s.iframe,s.bundlerURL),s.unsubscribeGlobalListener=s.iframeProtocol.globalListen(function(a){a.type!=="initialized"||!s.iframe.contentWindow||(s.iframeProtocol.register(),s.options.fileResolver&&(s.fileResolverProtocol=new nL("fs",function(l){return gt(s,void 0,void 0,function(){return vt(this,function(c){if(l.method==="isFile")return[2,this.options.fileResolver.isFile(l.params[0])];if(l.method==="readFile")return[2,this.options.fileResolver.readFile(l.params[0])];throw new Error("Method not supported")})})},s.iframeProtocol)),s.updateSandbox(s.sandboxSetup,!0))}),s.unsubscribeChannelListener=s.iframeProtocol.channelListen(function(a){switch(a.type){case"start":{s.errors=[];break}case"status":{s.status=a.status;break}case"action":{a.action==="show-error"&&(s.errors=vo(vo([],s.errors,!0),[Nf(a)],!1));break}case"done":{s.status="done";break}case"state":{s.bundlerState=a.state;break}}}),s}return e.prototype.setLocationURLIntoIFrame=function(){var n,i=this.options.startRoute?new URL(this.options.startRoute,this.bundlerURL).toString():this.bundlerURL;(n=this.iframe.contentWindow)===null||n===void 0||n.location.replace(i),this.iframe.src=i},e.prototype.destroy=function(){this.unsubscribeChannelListener(),this.unsubscribeGlobalListener(),this.iframeProtocol.cleanup()},e.prototype.updateOptions=function(n){Pi(this.options,n)||(this.options=n,this.updateSandbox())},e.prototype.updateSandbox=function(n,i){var r,s,o,a;n===void 0&&(n=this.sandboxSetup),this.sandboxSetup=Me(Me({},this.sandboxSetup),n);var l=this.getFiles(),c=Object.keys(l).reduce(function(p,f){var h;return Me(Me({},p),(h={},h[f]={code:l[f].code,path:f},h))},{}),u=JSON.parse(If(this.sandboxSetup.dependencies,this.sandboxSetup.devDependencies,this.sandboxSetup.entry));try{u=JSON.parse(l["/package.json"].code)}catch(p){console.error(ki("could not parse package.json file: "+p.message))}var d=Object.keys(l).reduce(function(p,f){var h;return Me(Me({},p),(h={},h[f]={content:l[f].code,path:f},h))},{});this.dispatch(Me(Me({},this.options),{type:"compile",codesandbox:!0,version:3,isInitializationCompile:i,modules:c,reactDevTools:this.options.reactDevTools,externalResources:this.options.externalResources||[],hasFileResolver:!!this.options.fileResolver,disableDependencyPreprocessing:this.sandboxSetup.disableDependencyPreprocessing,template:this.sandboxSetup.template||sL(u,d),showOpenInCodeSandbox:(r=this.options.showOpenInCodeSandbox)!==null&&r!==void 0?r:!0,showErrorScreen:(s=this.options.showErrorScreen)!==null&&s!==void 0?s:!0,showLoadingScreen:(o=this.options.showLoadingScreen)!==null&&o!==void 0?o:!1,skipEval:this.options.skipEval||!1,clearConsoleDisabled:!this.options.clearConsoleOnFirstCompile,logLevel:(a=this.options.logLevel)!==null&&a!==void 0?a:Jl.Info,customNpmRegistries:this.options.customNpmRegistries,teamId:this.options.teamId,sandboxId:this.options.sandboxId}))},e.prototype.dispatch=function(n){n.type==="refresh"&&this.setLocationURLIntoIFrame(),this.iframeProtocol.dispatch(n)},e.prototype.listen=function(n){return this.iframeProtocol.channelListen(n)},e.prototype.getCodeSandboxURL=function(){var n=this.getFiles(),i=Object.keys(n).reduce(function(r,s){var o;return Me(Me({},r),(o={},o[s.replace("/","")]={content:n[s].code,isBinary:!1},o))},{});return fetch("https://codesandbox.io/api/v1/sandboxes/define?json=1",{method:"POST",body:JSON.stringify({files:i}),headers:{Accept:"application/json","Content-Type":"application/json"}}).then(function(r){return r.json()}).then(function(r){return{sandboxId:r.sandbox_id,editorUrl:"https://codesandbox.io/s/".concat(r.sandbox_id),embedUrl:"https://codesandbox.io/embed/".concat(r.sandbox_id)}})},e.prototype.getFiles=function(){var n=this.sandboxSetup;return n.files["/package.json"]===void 0?Zf(n.files,n.dependencies,n.devDependencies,n.entry):this.sandboxSetup.files},e.prototype.initializeElement=function(){this.iframe.style.border="0",this.iframe.style.width=this.options.width||"100%",this.iframe.style.height=this.options.height||"100%",this.iframe.style.overflow="hidden",Fn(this.element.parentNode,"The given iframe does not have a parent."),this.element.parentNode.replaceChild(this.iframe,this.element)},e}(ef);const lL=Object.freeze(Object.defineProperty({__proto__:null,SandpackRuntime:aL},Symbol.toStringTag,{value:"Module"}));xe.Editor=IZ,Object.defineProperty(xe,Symbol.toStringTag,{value:"Module"})});
779
+ `).trim();return this.injectContentIntoHead(n,a)},e.prototype.updateSandbox=function(n,i){n===void 0&&(n=this.sandboxSetup);var r=_w(n.files);this.dispatch({codesandbox:!0,modules:r,template:n.template,type:"compile"})},e.prototype.compile=function(n){return gt(this,void 0,void 0,function(){var i;return vt(this,function(r){switch(r.label){case 0:return this.files=new Map(Object.entries(n)),[4,this.previewController.initPreview()];case 1:return i=r.sent(),this.iframe.setAttribute("src",i),this.status="done",this.dispatch({type:"done",compilatonError:!1}),this.dispatch({type:"urlchange",url:i,back:!1,forward:!1}),[2]}})})},e.prototype.eventListener=function(n){if(n.source===this.iframe.contentWindow){var i=n.data;i.codesandbox&&this.dispatch(i)}},e.prototype.dispatch=function(n){var i;switch(n.type){case"compile":this.compile(n.modules);break;default:(i=this.iframe.contentWindow)===null||i===void 0||i.postMessage(n,"*"),this.emitter.dispatch(n)}},e.prototype.listen=function(n){return this.emitter.listener(n)},e.prototype.destroy=function(){this.emitter.cleanup(),typeof window<"u"&&window.removeEventListener("message",this.eventListener)},e}(ef);const tL=Object.freeze(Object.defineProperty({__proto__:null,SandpackStatic:eL},Symbol.toStringTag,{value:"Module"}));var nL=function(){function t(e,n,i){var r=this;this.type=e,this.handleMessage=n,this.protocol=i,this._disposeMessageListener=this.protocol.channelListen(function(s){return gt(r,void 0,void 0,function(){var o,a,c,l,c;return vt(this,function(u){switch(u.label){case 0:if(!(s.type===this.getTypeId()&&s.method))return[3,4];o=s,u.label=1;case 1:return u.trys.push([1,3,,4]),[4,this.handleMessage(o)];case 2:return a=u.sent(),c={type:this.getTypeId(),msgId:o.msgId,result:a},this.protocol.dispatch(c),[3,4];case 3:return l=u.sent(),c={type:this.getTypeId(),msgId:o.msgId,error:{message:l.message}},this.protocol.dispatch(c),[3,4];case 4:return[2]}})})})}return t.prototype.getTypeId=function(){return"protocol-".concat(this.type)},t.prototype.dispose=function(){this._disposeMessageListener()},t}(),iL=function(){function t(e,n){this.globalListeners={},this.globalListenersCount=0,this.channelListeners={},this.channelListenersCount=0,this.channelId=Math.floor(Math.random()*1e6),this.frameWindow=e.contentWindow,this.origin=n,this.globalListeners=[],this.channelListeners=[],this.eventListener=this.eventListener.bind(this),typeof window<"u"&&window.addEventListener("message",this.eventListener)}return t.prototype.cleanup=function(){window.removeEventListener("message",this.eventListener),this.globalListeners={},this.channelListeners={},this.globalListenersCount=0,this.channelListenersCount=0},t.prototype.register=function(){this.frameWindow&&this.frameWindow.postMessage({type:"register-frame",origin:document.location.origin,id:this.channelId},this.origin)},t.prototype.dispatch=function(e){this.frameWindow&&this.frameWindow.postMessage(Me({$id:this.channelId,codesandbox:!0},e),this.origin)},t.prototype.globalListen=function(e){var n=this;if(typeof e!="function")return function(){};var i=this.globalListenersCount;return this.globalListeners[i]=e,this.globalListenersCount++,function(){delete n.globalListeners[i]}},t.prototype.channelListen=function(e){var n=this;if(typeof e!="function")return function(){};var i=this.channelListenersCount;return this.channelListeners[i]=e,this.channelListenersCount++,function(){delete n.channelListeners[i]}},t.prototype.eventListener=function(e){if(e.source===this.frameWindow){var n=e.data;n.codesandbox&&(Object.values(this.globalListeners).forEach(function(i){return i(n)}),n.$id===this.channelId&&Object.values(this.channelListeners).forEach(function(i){return i(n)}))}},t}(),rL=50;function sL(t,e){if(!t)return"static";var n=t.dependencies,i=n===void 0?{}:n,r=t.devDependencies,s=r===void 0?{}:r,o=vo(vo([],Object.keys(i),!0),Object.keys(s),!0),a=Object.keys(e),l=["@adonisjs/framework","@adonisjs/core"];if(o.some(function(h){return l.indexOf(h)>-1}))return"adonis";var c=["nuxt","nuxt-edge","nuxt-ts","nuxt-ts-edge","nuxt3"];if(o.some(function(h){return c.indexOf(h)>-1}))return"nuxt";if(o.indexOf("next")>-1)return"next";var u=["apollo-server","apollo-server-express","apollo-server-hapi","apollo-server-koa","apollo-server-lambda","apollo-server-micro"];if(o.some(function(h){return u.indexOf(h)>-1}))return"apollo";if(o.indexOf("mdx-deck")>-1)return"mdx-deck";if(o.indexOf("gridsome")>-1)return"gridsome";if(o.indexOf("vuepress")>-1)return"vuepress";if(o.indexOf("ember-cli")>-1)return"ember";if(o.indexOf("sapper")>-1)return"sapper";if(o.indexOf("gatsby")>-1)return"gatsby";if(o.indexOf("quasar")>-1)return"quasar";if(o.indexOf("@docusaurus/core")>-1)return"docusaurus";if(o.indexOf("remix")>-1)return"remix";if(o.indexOf("astro")>-1)return"node";if(a.some(function(h){return h.endsWith(".re")}))return"reason";var d=["parcel-bundler","parcel"];if(o.some(function(h){return d.indexOf(h)>-1}))return"parcel";var p=["@dojo/core","@dojo/framework"];if(o.some(function(h){return p.indexOf(h)>-1}))return"@dojo/cli-create-app";if(o.indexOf("@nestjs/core")>-1||o.indexOf("@nestjs/common")>-1)return"nest";if(o.indexOf("react-styleguidist")>-1)return"styleguidist";if(o.indexOf("react-scripts")>-1)return"create-react-app";if(o.indexOf("react-scripts-ts")>-1)return"create-react-app-typescript";if(o.indexOf("@angular/core")>-1)return"angular-cli";if(o.indexOf("preact-cli")>-1)return"preact-cli";if(o.indexOf("@sveltech/routify")>-1||o.indexOf("@roxi/routify")>-1||o.indexOf("vite")>-1||o.indexOf("@frontity/core")>-1)return"node";if(o.indexOf("svelte")>-1)return"svelte";if(o.indexOf("vue")>-1)return"vue-cli";if(o.indexOf("cx")>-1)return"cxjs";var f=["express","koa","nodemon","ts-node","@tensorflow/tfjs-node","webpack-dev-server","snowpack"];if(o.some(function(h){return f.indexOf(h)>-1})||Object.keys(i).length>=rL)return"node"}var rf,oL="https://".concat((rf="2.13.8")===null||rf===void 0?void 0:rf.replace(/\./g,"-"),"-sandpack.codesandbox.io/"),aL=function(t){Hl(e,t);function e(n,i,r){r===void 0&&(r={});var s=t.call(this,n,i,r)||this;if(s.getTranspilerContext=function(){return new Promise(function(a){var l=s.listen(function(c){c.type==="transpiler-context"&&(a(c.data),l())});s.dispatch({type:"get-transpiler-context"})})},s.bundlerURL=r.bundlerURL||oL,r.teamId&&(s.bundlerURL=s.bundlerURL.replace("https://","https://"+r.teamId+"-")+"?cache=".concat(Date.now())),s.bundlerState=void 0,s.errors=[],s.status="initializing",typeof n=="string"){s.selector=n;var o=document.querySelector(n);Fn(o,"The element '".concat(n,"' was not found")),s.element=o,s.iframe=document.createElement("iframe"),s.initializeElement()}else s.element=n,s.iframe=n;return s.iframe.getAttribute("sandbox")||(s.iframe.setAttribute("sandbox","allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts allow-downloads allow-pointer-lock"),s.iframe.setAttribute("allow","accelerometer; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; clipboard-write;")),s.setLocationURLIntoIFrame(),s.iframeProtocol=new iL(s.iframe,s.bundlerURL),s.unsubscribeGlobalListener=s.iframeProtocol.globalListen(function(a){a.type!=="initialized"||!s.iframe.contentWindow||(s.iframeProtocol.register(),s.options.fileResolver&&(s.fileResolverProtocol=new nL("fs",function(l){return gt(s,void 0,void 0,function(){return vt(this,function(c){if(l.method==="isFile")return[2,this.options.fileResolver.isFile(l.params[0])];if(l.method==="readFile")return[2,this.options.fileResolver.readFile(l.params[0])];throw new Error("Method not supported")})})},s.iframeProtocol)),s.updateSandbox(s.sandboxSetup,!0))}),s.unsubscribeChannelListener=s.iframeProtocol.channelListen(function(a){switch(a.type){case"start":{s.errors=[];break}case"status":{s.status=a.status;break}case"action":{a.action==="show-error"&&(s.errors=vo(vo([],s.errors,!0),[Nf(a)],!1));break}case"done":{s.status="done";break}case"state":{s.bundlerState=a.state;break}}}),s}return e.prototype.setLocationURLIntoIFrame=function(){var n,i=this.options.startRoute?new URL(this.options.startRoute,this.bundlerURL).toString():this.bundlerURL;(n=this.iframe.contentWindow)===null||n===void 0||n.location.replace(i),this.iframe.src=i},e.prototype.destroy=function(){this.unsubscribeChannelListener(),this.unsubscribeGlobalListener(),this.iframeProtocol.cleanup()},e.prototype.updateOptions=function(n){Pi(this.options,n)||(this.options=n,this.updateSandbox())},e.prototype.updateSandbox=function(n,i){var r,s,o,a;n===void 0&&(n=this.sandboxSetup),this.sandboxSetup=Me(Me({},this.sandboxSetup),n);var l=this.getFiles(),c=Object.keys(l).reduce(function(p,f){var h;return Me(Me({},p),(h={},h[f]={code:l[f].code,path:f},h))},{}),u=JSON.parse(If(this.sandboxSetup.dependencies,this.sandboxSetup.devDependencies,this.sandboxSetup.entry));try{u=JSON.parse(l["/package.json"].code)}catch(p){console.error(ki("could not parse package.json file: "+p.message))}var d=Object.keys(l).reduce(function(p,f){var h;return Me(Me({},p),(h={},h[f]={content:l[f].code,path:f},h))},{});this.dispatch(Me(Me({},this.options),{type:"compile",codesandbox:!0,version:3,isInitializationCompile:i,modules:c,reactDevTools:this.options.reactDevTools,externalResources:this.options.externalResources||[],hasFileResolver:!!this.options.fileResolver,disableDependencyPreprocessing:this.sandboxSetup.disableDependencyPreprocessing,template:this.sandboxSetup.template||sL(u,d),showOpenInCodeSandbox:(r=this.options.showOpenInCodeSandbox)!==null&&r!==void 0?r:!0,showErrorScreen:(s=this.options.showErrorScreen)!==null&&s!==void 0?s:!0,showLoadingScreen:(o=this.options.showLoadingScreen)!==null&&o!==void 0?o:!1,skipEval:this.options.skipEval||!1,clearConsoleDisabled:!this.options.clearConsoleOnFirstCompile,logLevel:(a=this.options.logLevel)!==null&&a!==void 0?a:Jl.Info,customNpmRegistries:this.options.customNpmRegistries,teamId:this.options.teamId,sandboxId:this.options.sandboxId}))},e.prototype.dispatch=function(n){n.type==="refresh"&&this.setLocationURLIntoIFrame(),this.iframeProtocol.dispatch(n)},e.prototype.listen=function(n){return this.iframeProtocol.channelListen(n)},e.prototype.getCodeSandboxURL=function(){var n=this.getFiles(),i=Object.keys(n).reduce(function(r,s){var o;return Me(Me({},r),(o={},o[s.replace("/","")]={content:n[s].code,isBinary:!1},o))},{});return fetch("https://codesandbox.io/api/v1/sandboxes/define?json=1",{method:"POST",body:JSON.stringify({files:i}),headers:{Accept:"application/json","Content-Type":"application/json"}}).then(function(r){return r.json()}).then(function(r){return{sandboxId:r.sandbox_id,editorUrl:"https://codesandbox.io/s/".concat(r.sandbox_id),embedUrl:"https://codesandbox.io/embed/".concat(r.sandbox_id)}})},e.prototype.getFiles=function(){var n=this.sandboxSetup;return n.files["/package.json"]===void 0?Zf(n.files,n.dependencies,n.devDependencies,n.entry):this.sandboxSetup.files},e.prototype.initializeElement=function(){this.iframe.style.border="0",this.iframe.style.width=this.options.width||"100%",this.iframe.style.height=this.options.height||"100%",this.iframe.style.overflow="hidden",Fn(this.element.parentNode,"The given iframe does not have a parent."),this.element.parentNode.replaceChild(this.iframe,this.element)},e}(ef);const lL=Object.freeze(Object.defineProperty({__proto__:null,SandpackRuntime:aL},Symbol.toStringTag,{value:"Module"}));xe.WEditor=IZ,Object.defineProperty(xe,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wangtaizong/components",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "publishConfig": {