mobileboost-cli 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,419 @@
1
+ import{jsxs as D,Fragment as qn,jsx as l}from"react/jsx-runtime";import ee,{useRef as J,useEffect as Ce,useContext as uo,useLayoutEffect as Gi,useState as De,useMemo as Wi,useCallback as po}from"react";import F from"@emotion/styled";import{useMutation as le,mutationOptions as fe,useQuery as ut,queryOptions as pn,useQueryClient as zi}from"@tanstack/react-query";import{CircularProgress as fo,Typography as L,Box as ge,IconButton as B,Divider as Gt,Dialog as Hi,DialogTitle as Ui,DialogContent as ji,TextField as M,DialogActions as qi,Button as Me,Tooltip as on,FormControl as fn,InputLabel as mn,Select as hn,MenuItem as vt,FormControlLabel as xe,Switch as Nr,ToggleButtonGroup as Ki,ToggleButton as Sr,Snackbar as Yi,Alert as Xi,List as mo,FormHelperText as Kn,Checkbox as Re,ListItem as In,InputAdornment as Ji,ListItemIcon as Or,ListItemText as Ar,Collapse as Zi,styled as Je,Paper as Yn,Chip as Ge}from"@mui/material";import{Store as Qi,useStore as we}from"@tanstack/react-store";import ea,{flushSync as ho}from"react-dom";import{bindActionCreators as Pr,createStore as ta,compose as na,applyMiddleware as ra}from"redux";import{connect as go,Provider as oa}from"react-redux";import Rr from"tiny-invariant";import bo from"@babel/runtime/helpers/esm/extends";import{R as C,y as vo,S as ia,m as aa,p as sa,c as la,l as ca,r as da,i as ua,s as pa,I as Tr,j as fa}from"./stores-C1dCcTeV.mjs";import{styled as Et}from"@mui/material/styles";import ma from"@mui/icons-material/Keyboard";import ha from"@mui/icons-material/SwipeVertical";import ga from"@mui/icons-material/Search";import ba from"@mui/icons-material/Link";import va from"@mui/icons-material/SmartToy";import Ze from"@mui/icons-material/PlayArrow";import Qe from"@mui/icons-material/FastForward";import et from"@mui/icons-material/Edit";import Ue from"@mui/icons-material/Delete";import{a as oe,g as ya,T as Da}from"./server.mjs";import{h as xa,d as Ea,l as wa,x as Ca,A as Ia,e as Xn,r as Na}from"./device-8ONaG49P.mjs";import{performTap as Sa,performType as Oa,performScroll as yo,getPageSource as Jn,performDeepLink as Aa,ensureAppiumSession as Pa,performSwipe as Ra}from"./appium-client-D-NjeB35.mjs";import{h as Zn,c as Do,l as Ta,a as Ba,$ as $a,i as _a,m as ka}from"./hierarchy-helpers-DF8QSYE6.mjs";import{f as La,u as Fa,b as Va}from"./adb-client-DwefjXbe.mjs";import{m as Ma,u as Ga}from"./ios-client-1xTZzFD8.mjs";import{i as Wa,n as za}from"./step-CEQtT3SD.mjs";import Br from"node:fs";import Oe from"node:path";import Ha from"node:crypto";import{o as Ua,i as ja,n as qa}from"./cache-D_LOBxSY.mjs";import{j as Ka,E as Ya,x as Xa,I as Ja}from"./ai-client-BtI1TeHN.mjs";import $e from"fs-extra";import{z as U}from"zod";import{useForm as Za}from"@tanstack/react-form";import Qa from"@mui/icons-material/Save";import es from"@mui/icons-material/Close";import ts from"@mui/icons-material/KeyboardArrowUp";import ns from"@mui/icons-material/KeyboardArrowDown";import rs from"@mui/icons-material/CheckCircle";import os from"@mui/icons-material/Info";import xo from"@mui/icons-material/Add";import is from"@mui/icons-material/Refresh";import as from"@mui/icons-material/CreateNewFolder";import ss from"@mui/icons-material/Folder";import ls from"@mui/icons-material/InsertDriveFile";import cs from"@mui/icons-material/ExpandLess";import ds from"@mui/icons-material/ExpandMore";import us from"@mui/icons-material/Check";import ps from"@mui/material/AlertTitle";import"@tanstack/history";import"@tanstack/router-core/ssr/client";import"@tanstack/router-core";import"node:async_hooks";import"@tanstack/router-core/ssr/server";import"../../index.mjs";import"node:http";import"node:stream";import"node:https";import"node:http2";import"node:url";import"seroval";import"@tanstack/react-router/ssr/server";import"@tanstack/react-router";import"webdriverio";import"xml2js";import"node:child_process";import"node:util";import"sharp";var Le=function(t){var n=t.top,r=t.right,o=t.bottom,i=t.left,a=r-i,s=o-n,c={top:n,right:r,bottom:o,left:i,width:a,height:s,x:i,y:n,center:{x:(r+i)/2,y:(o+n)/2}};return c},Qn=function(t,n){return{top:t.top-n.top,left:t.left-n.left,bottom:t.bottom+n.bottom,right:t.right+n.right}},$r=function(t,n){return{top:t.top+n.top,left:t.left+n.left,bottom:t.bottom-n.bottom,right:t.right-n.right}},fs=function(t,n){return{top:t.top+n.y,left:t.left+n.x,bottom:t.bottom+n.y,right:t.right+n.x}},Nn={top:0,right:0,bottom:0,left:0},er=function(t){var n=t.borderBox,r=t.margin,o=r===void 0?Nn:r,i=t.border,a=i===void 0?Nn:i,s=t.padding,c=s===void 0?Nn:s,u=Le(Qn(n,o)),f=Le($r(n,a)),d=Le($r(f,c));return{marginBox:u,borderBox:Le(n),paddingBox:f,contentBox:d,margin:o,border:a,padding:c}},Te=function(t){var n=t.slice(0,-2),r=t.slice(-2);if(r!=="px")return 0;var o=Number(n);return isNaN(o)&&(process.env.NODE_ENV!=="production"?Rr(!1,"Could not parse value [raw: "+t+", without suffix: "+n+"]"):Rr(!1)),o},ms=function(){return{x:window.pageXOffset,y:window.pageYOffset}},an=function(t,n){var r=t.borderBox,o=t.border,i=t.margin,a=t.padding,s=fs(r,n);return er({borderBox:s,border:o,margin:i,padding:a})},sn=function(t,n){return n===void 0&&(n=ms()),an(t,n)},Eo=function(t,n){var r={top:Te(n.marginTop),right:Te(n.marginRight),bottom:Te(n.marginBottom),left:Te(n.marginLeft)},o={top:Te(n.paddingTop),right:Te(n.paddingRight),bottom:Te(n.paddingBottom),left:Te(n.paddingLeft)},i={top:Te(n.borderTopWidth),right:Te(n.borderRightWidth),bottom:Te(n.borderBottomWidth),left:Te(n.borderLeftWidth)};return er({borderBox:t,margin:r,padding:o,border:i})},wo=function(t){var n=t.getBoundingClientRect(),r=window.getComputedStyle(t);return Eo(n,r)},Tt=function(t){var n=[],r=null,o=function(){for(var a=arguments.length,s=new Array(a),c=0;c<a;c++)s[c]=arguments[c];n=s,!r&&(r=requestAnimationFrame(function(){r=null,t.apply(void 0,n)}))};return o.cancel=function(){r&&(cancelAnimationFrame(r),r=null)},o};const hs=process.env.NODE_ENV==="production",gs=/[ \t]{2,}/g,bs=/^[ \t]*/gm,_r=e=>e.replace(gs," ").replace(bs,"").trim(),vs=e=>_r(`
2
+ %c@hello-pangea/dnd
3
+
4
+ %c${_r(e)}
5
+
6
+ %c👷‍ This is a development only message. It will be removed in production builds.
7
+ `),ys=e=>[vs(e),"color: #00C584; font-size: 1.2em; font-weight: bold;","line-height: 1.5","color: #723874;"],Ds="__@hello-pangea/dnd-disable-dev-warnings";function Co(e,t){hs||typeof window<"u"&&window[Ds]||console[e](...ys(t))}const Z=Co.bind(null,"warn"),Vn=Co.bind(null,"error");function Ke(){}function xs(e,t){return{...e,...t}}function Be(e,t,n){const r=t.map(o=>{const i=xs(n,o.options);return e.addEventListener(o.eventName,o.fn,i),function(){e.removeEventListener(o.eventName,o.fn,i)}});return function(){r.forEach(i=>{i()})}}const Es=process.env.NODE_ENV==="production",kr="Invariant failed";class Bt extends Error{}Bt.prototype.toString=function(){return this.message};function h(e,t){throw Es?new Bt(kr):new Bt(`${kr}: ${t||""}`)}class ws extends ee.Component{constructor(...t){super(...t),this.callbacks=null,this.unbind=Ke,this.onWindowError=n=>{const r=this.getCallbacks();r.isDragging()&&(r.tryAbort(),process.env.NODE_ENV!=="production"&&Z(`
8
+ An error was caught by our window 'error' event listener while a drag was occurring.
9
+ The active drag has been aborted.
10
+ `));const o=n.error;o instanceof Bt&&(n.preventDefault(),process.env.NODE_ENV!=="production"&&Vn(o.message))},this.getCallbacks=()=>{if(!this.callbacks)throw new Error("Unable to find AppCallbacks in <ErrorBoundary/>");return this.callbacks},this.setCallbacks=n=>{this.callbacks=n}}componentDidMount(){this.unbind=Be(window,[{eventName:"error",fn:this.onWindowError}])}componentDidCatch(t){if(t instanceof Bt){process.env.NODE_ENV!=="production"&&Vn(t.message),this.setState({});return}throw t}componentWillUnmount(){this.unbind()}render(){return this.props.children(this.setCallbacks)}}const Cs=`
11
+ Press space bar to start a drag.
12
+ When dragging you can use the arrow keys to move the item around and escape to cancel.
13
+ Some screen readers may require you to be in focus mode or to use your pass through key
14
+ `,ln=e=>e+1,Is=e=>`
15
+ You have lifted an item in position ${ln(e.source.index)}
16
+ `,Io=(e,t)=>{const n=e.droppableId===t.droppableId,r=ln(e.index),o=ln(t.index);return n?`
17
+ You have moved the item from position ${r}
18
+ to position ${o}
19
+ `:`
20
+ You have moved the item from position ${r}
21
+ in list ${e.droppableId}
22
+ to list ${t.droppableId}
23
+ in position ${o}
24
+ `},No=(e,t,n)=>t.droppableId===n.droppableId?`
25
+ The item ${e}
26
+ has been combined with ${n.draggableId}`:`
27
+ The item ${e}
28
+ in list ${t.droppableId}
29
+ has been combined with ${n.draggableId}
30
+ in list ${n.droppableId}
31
+ `,Ns=e=>{const t=e.destination;if(t)return Io(e.source,t);const n=e.combine;return n?No(e.draggableId,e.source,n):"You are over an area that cannot be dropped on"},Lr=e=>`
32
+ The item has returned to its starting position
33
+ of ${ln(e.index)}
34
+ `,Ss=e=>{if(e.reason==="CANCEL")return`
35
+ Movement cancelled.
36
+ ${Lr(e.source)}
37
+ `;const t=e.destination,n=e.combine;return t?`
38
+ You have dropped the item.
39
+ ${Io(e.source,t)}
40
+ `:n?`
41
+ You have dropped the item.
42
+ ${No(e.draggableId,e.source,n)}
43
+ `:`
44
+ The item has been dropped while not over a drop area.
45
+ ${Lr(e.source)}
46
+ `},rn={dragHandleUsageInstructions:Cs,onDragStart:Is,onDragUpdate:Ns,onDragEnd:Ss};function Os(e,t){return!!(e===t||Number.isNaN(e)&&Number.isNaN(t))}function So(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Os(e[n],t[n]))return!1;return!0}function k(e,t){const n=De(()=>({inputs:t,result:e()}))[0],r=J(!0),o=J(n),a=r.current||!!(t&&o.current.inputs&&So(t,o.current.inputs))?o.current:{inputs:t,result:e()};return Ce(()=>{r.current=!1,o.current=a},[a]),a.result}function E(e,t){return k(()=>e,t)}const pe={x:0,y:0},he=(e,t)=>({x:e.x+t.x,y:e.y+t.y}),Se=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),Ye=(e,t)=>e.x===t.x&&e.y===t.y,wt=e=>({x:e.x!==0?-e.x:0,y:e.y!==0?-e.y:0}),ft=(e,t,n=0)=>e==="x"?{x:t,y:n}:{x:n,y:t},$t=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),Fr=(e,t)=>Math.min(...t.map(n=>$t(e,n))),Oo=e=>t=>({x:e(t.x),y:e(t.y)});var As=(e,t)=>{const n=Le({top:Math.max(t.top,e.top),right:Math.min(t.right,e.right),bottom:Math.min(t.bottom,e.bottom),left:Math.max(t.left,e.left)});return n.width<=0||n.height<=0?null:n};const Wt=(e,t)=>({top:e.top+t.y,left:e.left+t.x,bottom:e.bottom+t.y,right:e.right+t.x}),Vr=e=>[{x:e.left,y:e.top},{x:e.right,y:e.top},{x:e.left,y:e.bottom},{x:e.right,y:e.bottom}],Ps={top:0,right:0,bottom:0,left:0},Rs=(e,t)=>t?Wt(e,t.scroll.diff.displacement):e,Ts=(e,t,n)=>n&&n.increasedBy?{...e,[t.end]:e[t.end]+n.increasedBy[t.line]}:e,Bs=(e,t)=>t&&t.shouldClipSubject?As(t.pageMarginBox,e):Le(e);var yt=({page:e,withPlaceholder:t,axis:n,frame:r})=>{const o=Rs(e.marginBox,r),i=Ts(o,n,t),a=Bs(i,r);return{page:e,withPlaceholder:t,active:a}},tr=(e,t)=>{e.frame||(process.env.NODE_ENV,h());const n=e.frame,r=Se(t,n.scroll.initial),o=wt(r),i={...n,scroll:{initial:n.scroll.initial,current:t,diff:{value:r,displacement:o},max:n.scroll.max}},a=yt({page:e.subject.page,withPlaceholder:e.subject.withPlaceholder,axis:e.axis,frame:i});return{...e,frame:i,subject:a}};function ue(e,t=So){let n=null;function r(...o){if(n&&n.lastThis===this&&t(o,n.lastArgs))return n.lastResult;const i=e.apply(this,o);return n={lastResult:i,lastArgs:o,lastThis:this},i}return r.clear=function(){n=null},r}const Ao=ue(e=>e.reduce((t,n)=>(t[n.descriptor.id]=n,t),{})),Po=ue(e=>e.reduce((t,n)=>(t[n.descriptor.id]=n,t),{})),gn=ue(e=>Object.values(e)),$s=ue(e=>Object.values(e));var mt=ue((e,t)=>$s(t).filter(r=>e===r.descriptor.droppableId).sort((r,o)=>r.descriptor.index-o.descriptor.index));function nr(e){return e.at&&e.at.type==="REORDER"?e.at.destination:null}function bn(e){return e.at&&e.at.type==="COMBINE"?e.at.combine:null}var vn=ue((e,t)=>t.filter(n=>n.descriptor.id!==e.descriptor.id)),_s=({isMovingForward:e,draggable:t,destination:n,insideDestination:r,previousImpact:o})=>{if(!n.isCombineEnabled||!nr(o))return null;function a(m){const b={type:"COMBINE",combine:{draggableId:m,droppableId:n.descriptor.id}};return{...o,at:b}}const s=o.displaced.all,c=s.length?s[0]:null;if(e)return c?a(c):null;const u=vn(t,r);if(!c){if(!u.length)return null;const m=u[u.length-1];return a(m.descriptor.id)}const f=u.findIndex(m=>m.descriptor.id===c);f===-1&&(process.env.NODE_ENV!=="production"?h(!1,"Could not find displaced item in set"):h());const d=f-1;if(d<0)return null;const p=u[d];return a(p.descriptor.id)},Ct=(e,t)=>e.descriptor.droppableId===t.descriptor.id;const Ro={point:pe,value:0},_t={invisible:{},visible:{},all:[]},ks={displaced:_t,displacedBy:Ro,at:null};var _e=(e,t)=>n=>e<=n&&n<=t,To=e=>{const t=_e(e.top,e.bottom),n=_e(e.left,e.right);return r=>{if(t(r.top)&&t(r.bottom)&&n(r.left)&&n(r.right))return!0;const i=t(r.top)||t(r.bottom),a=n(r.left)||n(r.right);if(i&&a)return!0;const c=r.top<e.top&&r.bottom>e.bottom,u=r.left<e.left&&r.right>e.right;return c&&u?!0:c&&a||u&&i}},Ls=e=>{const t=_e(e.top,e.bottom),n=_e(e.left,e.right);return r=>t(r.top)&&t(r.bottom)&&n(r.left)&&n(r.right)};const rr={direction:"vertical",line:"y",crossAxisLine:"x",start:"top",end:"bottom",size:"height",crossAxisStart:"left",crossAxisEnd:"right",crossAxisSize:"width"},Bo={direction:"horizontal",line:"x",crossAxisLine:"y",start:"left",end:"right",size:"width",crossAxisStart:"top",crossAxisEnd:"bottom",crossAxisSize:"height"};var Fs=e=>t=>{const n=_e(t.top,t.bottom),r=_e(t.left,t.right);return o=>e===rr?n(o.top)&&n(o.bottom):r(o.left)&&r(o.right)};const Vs=(e,t)=>{const n=t.frame?t.frame.scroll.diff.displacement:pe;return Wt(e,n)},Ms=(e,t,n)=>t.subject.active?n(t.subject.active)(e):!1,Gs=(e,t,n)=>n(t)(e),or=({target:e,destination:t,viewport:n,withDroppableDisplacement:r,isVisibleThroughFrameFn:o})=>{const i=r?Vs(e,t):e;return Ms(i,t,o)&&Gs(i,n,o)},Ws=e=>or({...e,isVisibleThroughFrameFn:To}),$o=e=>or({...e,isVisibleThroughFrameFn:Ls}),zs=e=>or({...e,isVisibleThroughFrameFn:Fs(e.destination.axis)}),Hs=(e,t,n)=>{if(typeof n=="boolean")return n;if(!t)return!0;const{invisible:r,visible:o}=t;if(r[e])return!1;const i=o[e];return i?i.shouldAnimate:!0};function Us(e,t){const n=e.page.marginBox,r={top:t.point.y,right:0,bottom:0,left:t.point.x};return Le(Qn(n,r))}function kt({afterDragging:e,destination:t,displacedBy:n,viewport:r,forceShouldAnimate:o,last:i}){return e.reduce(function(s,c){const u=Us(c,n),f=c.descriptor.id;if(s.all.push(f),!Ws({target:u,destination:t,viewport:r,withDroppableDisplacement:!0}))return s.invisible[c.descriptor.id]=!0,s;const p=Hs(f,i,o),m={draggableId:f,shouldAnimate:p};return s.visible[f]=m,s},{all:[],visible:{},invisible:{}})}function js(e,t){if(!e.length)return 0;const n=e[e.length-1].descriptor.index;return t.inHomeList?n:n+1}function Mr({insideDestination:e,inHomeList:t,displacedBy:n,destination:r}){const o=js(e,{inHomeList:t});return{displaced:_t,displacedBy:n,at:{type:"REORDER",destination:{droppableId:r.descriptor.id,index:o}}}}function cn({draggable:e,insideDestination:t,destination:n,viewport:r,displacedBy:o,last:i,index:a,forceShouldAnimate:s}){const c=Ct(e,n);if(a==null)return Mr({insideDestination:t,inHomeList:c,displacedBy:o,destination:n});const u=t.find(b=>b.descriptor.index===a);if(!u)return Mr({insideDestination:t,inHomeList:c,displacedBy:o,destination:n});const f=vn(e,t),d=t.indexOf(u),p=f.slice(d);return{displaced:kt({afterDragging:p,destination:n,displacedBy:o,last:i,viewport:r.frame,forceShouldAnimate:s}),displacedBy:o,at:{type:"REORDER",destination:{droppableId:n.descriptor.id,index:a}}}}function Xe(e,t){return!!t.effected[e]}var qs=({isMovingForward:e,destination:t,draggables:n,combine:r,afterCritical:o})=>{if(!t.isCombineEnabled)return null;const i=r.draggableId,s=n[i].descriptor.index;return Xe(i,o)?e?s:s-1:e?s+1:s},Ks=({isMovingForward:e,isInHomeList:t,insideDestination:n,location:r})=>{if(!n.length)return null;const o=r.index,i=e?o+1:o-1,a=n[0].descriptor.index,s=n[n.length-1].descriptor.index,c=t?s:s+1;return i<a||i>c?null:i},Ys=({isMovingForward:e,isInHomeList:t,draggable:n,draggables:r,destination:o,insideDestination:i,previousImpact:a,viewport:s,afterCritical:c})=>{const u=a.at;if(u||(process.env.NODE_ENV!=="production"?h(!1,"Cannot move in direction without previous impact location"):h()),u.type==="REORDER"){const d=Ks({isMovingForward:e,isInHomeList:t,location:u.destination,insideDestination:i});return d==null?null:cn({draggable:n,insideDestination:i,destination:o,viewport:s,last:a.displaced,displacedBy:a.displacedBy,index:d})}const f=qs({isMovingForward:e,destination:o,displaced:a.displaced,draggables:r,combine:u.combine,afterCritical:c});return f==null?null:cn({draggable:n,insideDestination:i,destination:o,viewport:s,last:a.displaced,displacedBy:a.displacedBy,index:f})},Xs=({displaced:e,afterCritical:t,combineWith:n,displacedBy:r})=>{const o=!!(e.visible[n]||e.invisible[n]);return Xe(n,t)?o?pe:wt(r.point):o?r.point:pe},Js=({afterCritical:e,impact:t,draggables:n})=>{const r=bn(t);r||(process.env.NODE_ENV,h());const o=r.draggableId,i=n[o].page.borderBox.center,a=Xs({displaced:t.displaced,afterCritical:e,combineWith:o,displacedBy:t.displacedBy});return he(i,a)};const _o=(e,t)=>t.margin[e.start]+t.borderBox[e.size]/2,Zs=(e,t)=>t.margin[e.end]+t.borderBox[e.size]/2,ir=(e,t,n)=>t[e.crossAxisStart]+n.margin[e.crossAxisStart]+n.borderBox[e.crossAxisSize]/2,Gr=({axis:e,moveRelativeTo:t,isMoving:n})=>ft(e.line,t.marginBox[e.end]+_o(e,n),ir(e,t.marginBox,n)),Wr=({axis:e,moveRelativeTo:t,isMoving:n})=>ft(e.line,t.marginBox[e.start]-Zs(e,n),ir(e,t.marginBox,n)),Qs=({axis:e,moveInto:t,isMoving:n})=>ft(e.line,t.contentBox[e.start]+_o(e,n),ir(e,t.contentBox,n));var el=({impact:e,draggable:t,draggables:n,droppable:r,afterCritical:o})=>{const i=mt(r.descriptor.id,n),a=t.page,s=r.axis;if(!i.length)return Qs({axis:s,moveInto:r.page,isMoving:a});const{displaced:c,displacedBy:u}=e,f=c.all[0];if(f){const p=n[f];if(Xe(f,o))return Wr({axis:s,moveRelativeTo:p.page,isMoving:a});const m=an(p.page,u.point);return Wr({axis:s,moveRelativeTo:m,isMoving:a})}const d=i[i.length-1];if(d.descriptor.id===t.descriptor.id)return a.borderBox.center;if(Xe(d.descriptor.id,o)){const p=an(d.page,wt(o.displacedBy.point));return Gr({axis:s,moveRelativeTo:p,isMoving:a})}return Gr({axis:s,moveRelativeTo:d.page,isMoving:a})},Mn=(e,t)=>{const n=e.frame;return n?he(t,n.scroll.diff.displacement):t};const tl=({impact:e,draggable:t,droppable:n,draggables:r,afterCritical:o})=>{const i=t.page.borderBox.center,a=e.at;return!n||!a?i:a.type==="REORDER"?el({impact:e,draggable:t,draggables:r,droppable:n,afterCritical:o}):Js({impact:e,draggables:r,afterCritical:o})};var yn=e=>{const t=tl(e),n=e.droppable;return n?Mn(n,t):t},ko=(e,t)=>{const n=Se(t,e.scroll.initial),r=wt(n);return{frame:Le({top:t.y,bottom:t.y+e.frame.height,left:t.x,right:t.x+e.frame.width}),scroll:{initial:e.scroll.initial,max:e.scroll.max,current:t,diff:{value:n,displacement:r}}}};function zr(e,t){return e.map(n=>t[n])}function nl(e,t){for(let n=0;n<t.length;n++){const r=t[n].visible[e];if(r)return r}return null}var rl=({impact:e,viewport:t,destination:n,draggables:r,maxScrollChange:o})=>{const i=ko(t,he(t.scroll.current,o)),a=n.frame?tr(n,he(n.frame.scroll.current,o)):n,s=e.displaced,c=kt({afterDragging:zr(s.all,r),destination:n,displacedBy:e.displacedBy,viewport:i.frame,last:s,forceShouldAnimate:!1}),u=kt({afterDragging:zr(s.all,r),destination:a,displacedBy:e.displacedBy,viewport:t.frame,last:s,forceShouldAnimate:!1}),f={},d={},p=[s,c,u];return s.all.forEach(b=>{const v=nl(b,p);if(v){d[b]=v;return}f[b]=!0}),{...e,displaced:{all:s.all,invisible:f,visible:d}}},ol=(e,t)=>he(e.scroll.diff.displacement,t),ar=({pageBorderBoxCenter:e,draggable:t,viewport:n})=>{const r=ol(n,e),o=Se(r,t.page.borderBox.center);return he(t.client.borderBox.center,o)},Lo=({draggable:e,destination:t,newPageBorderBoxCenter:n,viewport:r,withDroppableDisplacement:o,onlyOnMainAxis:i=!1})=>{const a=Se(n,e.page.borderBox.center),c={target:Wt(e.page.borderBox,a),destination:t,withDroppableDisplacement:o,viewport:r};return i?zs(c):$o(c)},il=({isMovingForward:e,draggable:t,destination:n,draggables:r,previousImpact:o,viewport:i,previousPageBorderBoxCenter:a,previousClientSelection:s,afterCritical:c})=>{if(!n.isEnabled)return null;const u=mt(n.descriptor.id,r),f=Ct(t,n),d=_s({isMovingForward:e,draggable:t,destination:n,insideDestination:u,previousImpact:o})||Ys({isMovingForward:e,isInHomeList:f,draggable:t,draggables:r,destination:n,insideDestination:u,previousImpact:o,viewport:i,afterCritical:c});if(!d)return null;const p=yn({impact:d,draggable:t,droppable:n,draggables:r,afterCritical:c});if(Lo({draggable:t,destination:n,newPageBorderBoxCenter:p,viewport:i.frame,withDroppableDisplacement:!1,onlyOnMainAxis:!0}))return{clientSelection:ar({pageBorderBoxCenter:p,draggable:t,viewport:i}),impact:d,scrollJumpRequest:null};const b=Se(p,a),v=rl({impact:d,viewport:i,destination:n,draggables:r,maxScrollChange:b});return{clientSelection:s,impact:v,scrollJumpRequest:b}};const ye=e=>{const t=e.subject.active;return t||(process.env.NODE_ENV!=="production"?h(!1,"Cannot get clipped area from droppable"):h()),t};var al=({isMovingForward:e,pageBorderBoxCenter:t,source:n,droppables:r,viewport:o})=>{const i=n.subject.active;if(!i)return null;const a=n.axis,s=_e(i[a.start],i[a.end]),c=gn(r).filter(f=>f!==n).filter(f=>f.isEnabled).filter(f=>!!f.subject.active).filter(f=>To(o.frame)(ye(f))).filter(f=>{const d=ye(f);return e?i[a.crossAxisEnd]<d[a.crossAxisEnd]:d[a.crossAxisStart]<i[a.crossAxisStart]}).filter(f=>{const d=ye(f),p=_e(d[a.start],d[a.end]);return s(d[a.start])||s(d[a.end])||p(i[a.start])||p(i[a.end])}).sort((f,d)=>{const p=ye(f)[a.crossAxisStart],m=ye(d)[a.crossAxisStart];return e?p-m:m-p}).filter((f,d,p)=>ye(f)[a.crossAxisStart]===ye(p[0])[a.crossAxisStart]);if(!c.length)return null;if(c.length===1)return c[0];const u=c.filter(f=>_e(ye(f)[a.start],ye(f)[a.end])(t[a.line]));return u.length===1?u[0]:u.length>1?u.sort((f,d)=>ye(f)[a.start]-ye(d)[a.start])[0]:c.sort((f,d)=>{const p=Fr(t,Vr(ye(f))),m=Fr(t,Vr(ye(d)));return p!==m?p-m:ye(f)[a.start]-ye(d)[a.start]})[0]};const Hr=(e,t)=>{const n=e.page.borderBox.center;return Xe(e.descriptor.id,t)?Se(n,t.displacedBy.point):n},sl=(e,t)=>{const n=e.page.borderBox;return Xe(e.descriptor.id,t)?Wt(n,wt(t.displacedBy.point)):n};var ll=({pageBorderBoxCenter:e,viewport:t,destination:n,insideDestination:r,afterCritical:o})=>r.filter(a=>$o({target:sl(a,o),destination:n,viewport:t.frame,withDroppableDisplacement:!0})).sort((a,s)=>{const c=$t(e,Mn(n,Hr(a,o))),u=$t(e,Mn(n,Hr(s,o)));return c<u?-1:u<c?1:a.descriptor.index-s.descriptor.index})[0]||null,zt=ue(function(t,n){const r=n[t.line];return{value:r,point:ft(t.line,r)}});const cl=(e,t,n)=>{const r=e.axis;if(e.descriptor.mode==="virtual")return ft(r.line,t[r.line]);const o=e.subject.page.contentBox[r.size],c=mt(e.descriptor.id,n).reduce((u,f)=>u+f.client.marginBox[r.size],0)+t[r.line]-o;return c<=0?null:ft(r.line,c)},Fo=(e,t)=>({...e,scroll:{...e.scroll,max:t}}),Vo=(e,t,n)=>{const r=e.frame;Ct(t,e)&&(process.env.NODE_ENV!=="production"?h(!1,"Should not add placeholder space to home list"):h()),e.subject.withPlaceholder&&(process.env.NODE_ENV!=="production"?h(!1,"Cannot add placeholder size to a subject when it already has one"):h());const o=zt(e.axis,t.displaceBy).point,i=cl(e,o,n),a={placeholderSize:o,increasedBy:i,oldFrameMaxScroll:e.frame?e.frame.scroll.max:null};if(!r){const f=yt({page:e.subject.page,withPlaceholder:a,axis:e.axis,frame:e.frame});return{...e,subject:f}}const s=i?he(r.scroll.max,i):r.scroll.max,c=Fo(r,s),u=yt({page:e.subject.page,withPlaceholder:a,axis:e.axis,frame:c});return{...e,subject:u,frame:c}},dl=e=>{const t=e.subject.withPlaceholder;t||(process.env.NODE_ENV!=="production"?h(!1,"Cannot remove placeholder form subject when there was none"):h());const n=e.frame;if(!n){const a=yt({page:e.subject.page,axis:e.axis,frame:null,withPlaceholder:null});return{...e,subject:a}}const r=t.oldFrameMaxScroll;r||(process.env.NODE_ENV!=="production"?h(!1,"Expected droppable with frame to have old max frame scroll when removing placeholder"):h());const o=Fo(n,r),i=yt({page:e.subject.page,axis:e.axis,frame:o,withPlaceholder:null});return{...e,subject:i,frame:o}};var ul=({previousPageBorderBoxCenter:e,moveRelativeTo:t,insideDestination:n,draggable:r,draggables:o,destination:i,viewport:a,afterCritical:s})=>{if(!t){if(n.length)return null;const d={displaced:_t,displacedBy:Ro,at:{type:"REORDER",destination:{droppableId:i.descriptor.id,index:0}}},p=yn({impact:d,draggable:r,droppable:i,draggables:o,afterCritical:s}),m=Ct(r,i)?i:Vo(i,r,o);return Lo({draggable:r,destination:m,newPageBorderBoxCenter:p,viewport:a.frame,withDroppableDisplacement:!1,onlyOnMainAxis:!0})?d:null}const c=e[i.axis.line]<=t.page.borderBox.center[i.axis.line],u=(()=>{const d=t.descriptor.index;return t.descriptor.id===r.descriptor.id||c?d:d+1})(),f=zt(i.axis,r.displaceBy);return cn({draggable:r,insideDestination:n,destination:i,viewport:a,displacedBy:f,last:_t,index:u})},pl=({isMovingForward:e,previousPageBorderBoxCenter:t,draggable:n,isOver:r,draggables:o,droppables:i,viewport:a,afterCritical:s})=>{const c=al({isMovingForward:e,pageBorderBoxCenter:t,source:r,droppables:i,viewport:a});if(!c)return null;const u=mt(c.descriptor.id,o),f=ll({pageBorderBoxCenter:t,viewport:a,destination:c,insideDestination:u,afterCritical:s}),d=ul({previousPageBorderBoxCenter:t,destination:c,draggable:n,draggables:o,moveRelativeTo:f,insideDestination:u,viewport:a,afterCritical:s});if(!d)return null;const p=yn({impact:d,draggable:n,droppable:c,draggables:o,afterCritical:s});return{clientSelection:ar({pageBorderBoxCenter:p,draggable:n,viewport:a}),impact:d,scrollJumpRequest:null}},Ae=e=>{const t=e.at;return t?t.type==="REORDER"?t.destination.droppableId:t.combine.droppableId:null};const fl=(e,t)=>{const n=Ae(e);return n?t[n]:null};var ml=({state:e,type:t})=>{const n=fl(e.impact,e.dimensions.droppables),r=!!n,o=e.dimensions.droppables[e.critical.droppable.id],i=n||o,a=i.axis.direction,s=a==="vertical"&&(t==="MOVE_UP"||t==="MOVE_DOWN")||a==="horizontal"&&(t==="MOVE_LEFT"||t==="MOVE_RIGHT");if(s&&!r)return null;const c=t==="MOVE_DOWN"||t==="MOVE_RIGHT",u=e.dimensions.draggables[e.critical.draggable.id],f=e.current.page.borderBoxCenter,{draggables:d,droppables:p}=e.dimensions;return s?il({isMovingForward:c,previousPageBorderBoxCenter:f,draggable:u,destination:i,draggables:d,viewport:e.viewport,previousClientSelection:e.current.client.selection,previousImpact:e.impact,afterCritical:e.afterCritical}):pl({isMovingForward:c,previousPageBorderBoxCenter:f,draggable:u,isOver:i,draggables:d,droppables:p,viewport:e.viewport,afterCritical:e.afterCritical})};function dt(e){return e.phase==="DRAGGING"||e.phase==="COLLECTING"}function Mo(e){const t=_e(e.top,e.bottom),n=_e(e.left,e.right);return function(o){return t(o.y)&&n(o.x)}}function hl(e,t){return e.left<t.right&&e.right>t.left&&e.top<t.bottom&&e.bottom>t.top}function gl({pageBorderBox:e,draggable:t,candidates:n}){const r=t.page.borderBox.center,o=n.map(i=>{const a=i.axis,s=ft(i.axis.line,e.center[a.line],i.page.borderBox.center[a.crossAxisLine]);return{id:i.descriptor.id,distance:$t(r,s)}}).sort((i,a)=>a.distance-i.distance);return o[0]?o[0].id:null}function bl({pageBorderBox:e,draggable:t,droppables:n}){const r=gn(n).filter(o=>{if(!o.isEnabled)return!1;const i=o.subject.active;if(!i||!hl(e,i))return!1;if(Mo(i)(e.center))return!0;const a=o.axis,s=i.center[a.crossAxisLine],c=e[a.crossAxisStart],u=e[a.crossAxisEnd],f=_e(i[a.crossAxisStart],i[a.crossAxisEnd]),d=f(c),p=f(u);return!d&&!p?!0:d?c<s:u>s});return r.length?r.length===1?r[0].descriptor.id:gl({pageBorderBox:e,draggable:t,candidates:r}):null}const Go=(e,t)=>Le(Wt(e,t));var vl=(e,t)=>{const n=e.frame;return n?Go(t,n.scroll.diff.value):t};function Wo({displaced:e,id:t}){return!!(e.visible[t]||e.invisible[t])}function yl({draggable:e,closest:t,inHomeList:n}){return t?n&&t.descriptor.index>e.descriptor.index?t.descriptor.index-1:t.descriptor.index:null}var Dl=({pageBorderBoxWithDroppableScroll:e,draggable:t,destination:n,insideDestination:r,last:o,viewport:i,afterCritical:a})=>{const s=n.axis,c=zt(n.axis,t.displaceBy),u=c.value,f=e[s.start],d=e[s.end],m=vn(t,r).find(v=>{const y=v.descriptor.id,w=v.page.borderBox.center[s.line],N=Xe(y,a),G=Wo({displaced:o,id:y});return N?G?d<=w:f<w-u:G?d<=w+u:f<w})||null,b=yl({draggable:t,closest:m,inHomeList:Ct(t,n)});return cn({draggable:t,insideDestination:r,destination:n,viewport:i,last:o,displacedBy:c,index:b})};const xl=4;var El=({draggable:e,pageBorderBoxWithDroppableScroll:t,previousImpact:n,destination:r,insideDestination:o,afterCritical:i})=>{if(!r.isCombineEnabled)return null;const a=r.axis,s=zt(r.axis,e.displaceBy),c=s.value,u=t[a.start],f=t[a.end],p=vn(e,o).find(b=>{const v=b.descriptor.id,y=b.page.borderBox,N=y[a.size]/xl,G=Xe(v,i),A=Wo({displaced:n.displaced,id:v});return G?A?f>y[a.start]+N&&f<y[a.end]-N:u>y[a.start]-c+N&&u<y[a.end]-c-N:A?f>y[a.start]+c+N&&f<y[a.end]+c-N:u>y[a.start]+N&&u<y[a.end]-N});return p?{displacedBy:s,displaced:n.displaced,at:{type:"COMBINE",combine:{draggableId:p.descriptor.id,droppableId:r.descriptor.id}}}:null},zo=({pageOffset:e,draggable:t,draggables:n,droppables:r,previousImpact:o,viewport:i,afterCritical:a})=>{const s=Go(t.page.borderBox,e),c=bl({pageBorderBox:s,draggable:t,droppables:r});if(!c)return ks;const u=r[c],f=mt(u.descriptor.id,n),d=vl(u,s);return El({pageBorderBoxWithDroppableScroll:d,draggable:t,previousImpact:o,destination:u,insideDestination:f,afterCritical:a})||Dl({pageBorderBoxWithDroppableScroll:d,draggable:t,destination:u,insideDestination:f,last:o.displaced,viewport:i,afterCritical:a})},sr=(e,t)=>({...e,[t.descriptor.id]:t});const wl=({previousImpact:e,impact:t,droppables:n})=>{const r=Ae(e),o=Ae(t);if(!r||r===o)return n;const i=n[r];if(!i.subject.withPlaceholder)return n;const a=dl(i);return sr(n,a)};var Cl=({draggable:e,draggables:t,droppables:n,previousImpact:r,impact:o})=>{const i=wl({previousImpact:r,impact:o,droppables:n}),a=Ae(o);if(!a)return i;const s=n[a];if(Ct(e,s)||s.subject.withPlaceholder)return i;const c=Vo(s,e,t);return sr(i,c)},Pt=({state:e,clientSelection:t,dimensions:n,viewport:r,impact:o,scrollJumpRequest:i})=>{const a=r||e.viewport,s=n||e.dimensions,c=t||e.current.client.selection,u=Se(c,e.initial.client.selection),f={offset:u,selection:c,borderBoxCenter:he(e.initial.client.borderBoxCenter,u)},d={selection:he(f.selection,a.scroll.current),borderBoxCenter:he(f.borderBoxCenter,a.scroll.current),offset:he(f.offset,a.scroll.diff.value)},p={client:f,page:d};if(e.phase==="COLLECTING")return{...e,dimensions:s,viewport:a,current:p};const m=s.draggables[e.critical.draggable.id],b=o||zo({pageOffset:d.offset,draggable:m,draggables:s.draggables,droppables:s.droppables,previousImpact:e.impact,viewport:a,afterCritical:e.afterCritical}),v=Cl({draggable:m,impact:b,previousImpact:e.impact,draggables:s.draggables,droppables:s.droppables});return{...e,current:p,dimensions:{draggables:s.draggables,droppables:v},impact:b,viewport:a,scrollJumpRequest:i||null,forceShouldAnimate:i?!1:null}};function Il(e,t){return e.map(n=>t[n])}var Ho=({impact:e,viewport:t,draggables:n,destination:r,forceShouldAnimate:o})=>{const i=e.displaced,a=Il(i.all,n),s=kt({afterDragging:a,destination:r,displacedBy:e.displacedBy,viewport:t.frame,forceShouldAnimate:o,last:i});return{...e,displaced:s}},Uo=({impact:e,draggable:t,droppable:n,draggables:r,viewport:o,afterCritical:i})=>{const a=yn({impact:e,draggable:t,draggables:r,droppable:n,afterCritical:i});return ar({pageBorderBoxCenter:a,draggable:t,viewport:o})},jo=({state:e,dimensions:t,viewport:n})=>{e.movementMode!=="SNAP"&&(process.env.NODE_ENV,h());const r=e.impact,o=n||e.viewport,i=t||e.dimensions,{draggables:a,droppables:s}=i,c=a[e.critical.draggable.id],u=Ae(r);u||(process.env.NODE_ENV!=="production"?h(!1,"Must be over a destination in SNAP movement mode"):h());const f=s[u],d=Ho({impact:r,viewport:o,destination:f,draggables:a}),p=Uo({impact:d,draggable:c,droppable:f,draggables:a,viewport:o,afterCritical:e.afterCritical});return Pt({impact:d,clientSelection:p,state:e,dimensions:i,viewport:o})},Nl=e=>({index:e.index,droppableId:e.droppableId}),qo=({draggable:e,home:t,draggables:n,viewport:r})=>{const o=zt(t.axis,e.displaceBy),i=mt(t.descriptor.id,n),a=i.indexOf(e);a===-1&&(process.env.NODE_ENV!=="production"?h(!1,"Expected draggable to be inside home list"):h());const s=i.slice(a+1),c=s.reduce((p,m)=>(p[m.descriptor.id]=!0,p),{}),u={inVirtualList:t.descriptor.mode==="virtual",displacedBy:o,effected:c};return{impact:{displaced:kt({afterDragging:s,destination:t,displacedBy:o,last:null,viewport:r.frame,forceShouldAnimate:!1}),displacedBy:o,at:{type:"REORDER",destination:Nl(e.descriptor)}},afterCritical:u}},Sl=(e,t)=>({draggables:e.draggables,droppables:sr(e.droppables,t)});const Ht=e=>{process.env.NODE_ENV},Ut=e=>{process.env.NODE_ENV};var Ol=({draggable:e,offset:t,initialWindowScroll:n})=>{const r=an(e.client,t),o=sn(r,n);return{...e,placeholder:{...e.placeholder,client:r},client:r,page:o}},Al=e=>{const t=e.frame;return t||(process.env.NODE_ENV!=="production"?h(!1,"Expected Droppable to have a frame"):h()),t},Pl=({additions:e,updatedDroppables:t,viewport:n})=>{const r=n.scroll.diff.value;return e.map(o=>{const i=o.descriptor.droppableId,a=t[i],c=Al(a).scroll.diff.value,u=he(r,c);return Ol({draggable:o,offset:u,initialWindowScroll:n.scroll.initial})})},Rl=({state:e,published:t})=>{Ht();const n=t.modified.map(w=>{const N=e.dimensions.droppables[w.droppableId];return tr(N,w.scroll)}),r={...e.dimensions.droppables,...Ao(n)},o=Po(Pl({additions:t.additions,updatedDroppables:r,viewport:e.viewport})),i={...e.dimensions.draggables,...o};t.removals.forEach(w=>{delete i[w]});const a={droppables:r,draggables:i},s=Ae(e.impact),c=s?a.droppables[s]:null,u=a.draggables[e.critical.draggable.id],f=a.droppables[e.critical.droppable.id],{impact:d,afterCritical:p}=qo({draggable:u,home:f,draggables:i,viewport:e.viewport}),m=c&&c.isCombineEnabled?e.impact:d,b=zo({pageOffset:e.current.page.offset,draggable:a.draggables[e.critical.draggable.id],draggables:a.draggables,droppables:a.droppables,previousImpact:m,viewport:e.viewport,afterCritical:p});Ut();const v={...e,phase:"DRAGGING",impact:b,onLiftImpact:d,dimensions:a,afterCritical:p,forceShouldAnimate:!1};return e.phase==="COLLECTING"?v:{...v,phase:"DROP_PENDING",reason:e.reason,isWaiting:!1}};const Gn=e=>e.movementMode==="SNAP",Sn=(e,t,n)=>{const r=Sl(e.dimensions,t);return!Gn(e)||n?Pt({state:e,dimensions:r}):jo({state:e,dimensions:r})};function On(e){return e.isDragging&&e.movementMode==="SNAP"?{...e,scrollJumpRequest:null}:e}const Ur={phase:"IDLE",completed:null,shouldFlush:!1};var Tl=(e=Ur,t)=>{if(t.type==="FLUSH")return{...Ur,shouldFlush:!0};if(t.type==="INITIAL_PUBLISH"){e.phase!=="IDLE"&&(process.env.NODE_ENV!=="production"?h(!1,"INITIAL_PUBLISH must come after a IDLE phase"):h());const{critical:n,clientSelection:r,viewport:o,dimensions:i,movementMode:a}=t.payload,s=i.draggables[n.draggable.id],c=i.droppables[n.droppable.id],u={selection:r,borderBoxCenter:s.client.borderBox.center,offset:pe},f={client:u,page:{selection:he(u.selection,o.scroll.initial),borderBoxCenter:he(u.selection,o.scroll.initial),offset:he(u.selection,o.scroll.diff.value)}},d=gn(i.droppables).every(v=>!v.isFixedOnPage),{impact:p,afterCritical:m}=qo({draggable:s,home:c,draggables:i.draggables,viewport:o});return{phase:"DRAGGING",isDragging:!0,critical:n,movementMode:a,dimensions:i,initial:f,current:f,isWindowScrollAllowed:d,impact:p,afterCritical:m,onLiftImpact:p,viewport:o,scrollJumpRequest:null,forceShouldAnimate:null}}if(t.type==="COLLECTION_STARTING")return e.phase==="COLLECTING"||e.phase==="DROP_PENDING"?e:(e.phase!=="DRAGGING"&&(process.env.NODE_ENV!=="production"?h(!1,`Collection cannot start from phase ${e.phase}`):h()),{...e,phase:"COLLECTING"});if(t.type==="PUBLISH_WHILE_DRAGGING")return e.phase==="COLLECTING"||e.phase==="DROP_PENDING"||(process.env.NODE_ENV!=="production"?h(!1,`Unexpected ${t.type} received in phase ${e.phase}`):h()),Rl({state:e,published:t.payload});if(t.type==="MOVE"){if(e.phase==="DROP_PENDING")return e;dt(e)||(process.env.NODE_ENV!=="production"?h(!1,`${t.type} not permitted in phase ${e.phase}`):h());const{client:n}=t.payload;return Ye(n,e.current.client.selection)?e:Pt({state:e,clientSelection:n,impact:Gn(e)?e.impact:null})}if(t.type==="UPDATE_DROPPABLE_SCROLL"){if(e.phase==="DROP_PENDING"||e.phase==="COLLECTING")return On(e);dt(e)||(process.env.NODE_ENV!=="production"?h(!1,`${t.type} not permitted in phase ${e.phase}`):h());const{id:n,newScroll:r}=t.payload,o=e.dimensions.droppables[n];if(!o)return e;const i=tr(o,r);return Sn(e,i,!1)}if(t.type==="UPDATE_DROPPABLE_IS_ENABLED"){if(e.phase==="DROP_PENDING")return e;dt(e)||(process.env.NODE_ENV!=="production"?h(!1,`Attempting to move in an unsupported phase ${e.phase}`):h());const{id:n,isEnabled:r}=t.payload,o=e.dimensions.droppables[n];o||(process.env.NODE_ENV!=="production"?h(!1,`Cannot find Droppable[id: ${n}] to toggle its enabled state`):h()),o.isEnabled===r&&(process.env.NODE_ENV!=="production"?h(!1,`Trying to set droppable isEnabled to ${String(r)}
47
+ but it is already ${String(o.isEnabled)}`):h());const i={...o,isEnabled:r};return Sn(e,i,!0)}if(t.type==="UPDATE_DROPPABLE_IS_COMBINE_ENABLED"){if(e.phase==="DROP_PENDING")return e;dt(e)||(process.env.NODE_ENV!=="production"?h(!1,`Attempting to move in an unsupported phase ${e.phase}`):h());const{id:n,isCombineEnabled:r}=t.payload,o=e.dimensions.droppables[n];o||(process.env.NODE_ENV!=="production"?h(!1,`Cannot find Droppable[id: ${n}] to toggle its isCombineEnabled state`):h()),o.isCombineEnabled===r&&(process.env.NODE_ENV!=="production"?h(!1,`Trying to set droppable isCombineEnabled to ${String(r)}
48
+ but it is already ${String(o.isCombineEnabled)}`):h());const i={...o,isCombineEnabled:r};return Sn(e,i,!0)}if(t.type==="MOVE_BY_WINDOW_SCROLL"){if(e.phase==="DROP_PENDING"||e.phase==="DROP_ANIMATING")return e;dt(e)||(process.env.NODE_ENV!=="production"?h(!1,`Cannot move by window in phase ${e.phase}`):h()),e.isWindowScrollAllowed||(process.env.NODE_ENV!=="production"?h(!1,"Window scrolling is currently not supported for fixed lists"):h());const n=t.payload.newScroll;if(Ye(e.viewport.scroll.current,n))return On(e);const r=ko(e.viewport,n);return Gn(e)?jo({state:e,viewport:r}):Pt({state:e,viewport:r})}if(t.type==="UPDATE_VIEWPORT_MAX_SCROLL"){if(!dt(e))return e;const n=t.payload.maxScroll;if(Ye(n,e.viewport.scroll.max))return e;const r={...e.viewport,scroll:{...e.viewport.scroll,max:n}};return{...e,viewport:r}}if(t.type==="MOVE_UP"||t.type==="MOVE_DOWN"||t.type==="MOVE_LEFT"||t.type==="MOVE_RIGHT"){if(e.phase==="COLLECTING"||e.phase==="DROP_PENDING")return e;e.phase!=="DRAGGING"&&(process.env.NODE_ENV!=="production"?h(!1,`${t.type} received while not in DRAGGING phase`):h());const n=ml({state:e,type:t.type});return n?Pt({state:e,impact:n.impact,clientSelection:n.clientSelection,scrollJumpRequest:n.scrollJumpRequest}):e}if(t.type==="DROP_PENDING"){const n=t.payload.reason;return e.phase!=="COLLECTING"&&(process.env.NODE_ENV!=="production"?h(!1,"Can only move into the DROP_PENDING phase from the COLLECTING phase"):h()),{...e,phase:"DROP_PENDING",isWaiting:!0,reason:n}}if(t.type==="DROP_ANIMATE"){const{completed:n,dropDuration:r,newHomeClientOffset:o}=t.payload;return e.phase==="DRAGGING"||e.phase==="DROP_PENDING"||(process.env.NODE_ENV!=="production"?h(!1,`Cannot animate drop from phase ${e.phase}`):h()),{phase:"DROP_ANIMATING",completed:n,dropDuration:r,newHomeClientOffset:o,dimensions:e.dimensions}}if(t.type==="DROP_COMPLETE"){const{completed:n}=t.payload;return{phase:"IDLE",completed:n,shouldFlush:!1}}return e};function j(e,t){return e instanceof Object&&"type"in e&&e.type===t}const Bl=e=>({type:"BEFORE_INITIAL_CAPTURE",payload:e}),$l=e=>({type:"LIFT",payload:e}),_l=e=>({type:"INITIAL_PUBLISH",payload:e}),kl=e=>({type:"PUBLISH_WHILE_DRAGGING",payload:e}),Ll=()=>({type:"COLLECTION_STARTING",payload:null}),Fl=e=>({type:"UPDATE_DROPPABLE_SCROLL",payload:e}),Vl=e=>({type:"UPDATE_DROPPABLE_IS_ENABLED",payload:e}),Ml=e=>({type:"UPDATE_DROPPABLE_IS_COMBINE_ENABLED",payload:e}),Ko=e=>({type:"MOVE",payload:e}),Gl=e=>({type:"MOVE_BY_WINDOW_SCROLL",payload:e}),Wl=e=>({type:"UPDATE_VIEWPORT_MAX_SCROLL",payload:e}),zl=()=>({type:"MOVE_UP",payload:null}),Hl=()=>({type:"MOVE_DOWN",payload:null}),Ul=()=>({type:"MOVE_RIGHT",payload:null}),jl=()=>({type:"MOVE_LEFT",payload:null}),lr=()=>({type:"FLUSH",payload:null}),ql=e=>({type:"DROP_ANIMATE",payload:e}),cr=e=>({type:"DROP_COMPLETE",payload:e}),Yo=e=>({type:"DROP",payload:e}),Kl=e=>({type:"DROP_PENDING",payload:e}),Xo=()=>({type:"DROP_ANIMATION_FINISHED",payload:null});function Yl(e){if(e.length<=1)return;const t=e.map(o=>o.descriptor.index),n={};for(let o=1;o<t.length;o++){const i=t[o],a=t[o-1];i!==a+1&&(n[i]=!0)}if(!Object.keys(n).length)return;const r=t.map(o=>!!n[o]?`[🔥${o}]`:`${o}`).join(", ");process.env.NODE_ENV!=="production"&&Z(`
49
+ Detected non-consecutive <Draggable /> indexes.
50
+
51
+ (This can cause unexpected bugs)
52
+
53
+ ${r}
54
+ `)}function Xl(e,t){if(process.env.NODE_ENV!=="production"){const n=mt(e.droppable.id,t.draggables);Yl(n)}}var Jl=e=>({getState:t,dispatch:n})=>r=>o=>{if(!j(o,"LIFT")){r(o);return}const{id:i,clientSelection:a,movementMode:s}=o.payload,c=t();c.phase==="DROP_ANIMATING"&&n(cr({completed:c.completed})),t().phase!=="IDLE"&&(process.env.NODE_ENV!=="production"?h(!1,"Unexpected phase to start a drag"):h()),n(lr()),n(Bl({draggableId:i,movementMode:s}));const f={draggableId:i,scrollOptions:{shouldPublishImmediately:s==="SNAP"}},{critical:d,dimensions:p,viewport:m}=e.startPublishing(f);Xl(d,p),n(_l({critical:d,dimensions:p,clientSelection:a,movementMode:s,viewport:m}))},Zl=e=>()=>t=>n=>{j(n,"INITIAL_PUBLISH")&&e.dragging(),j(n,"DROP_ANIMATE")&&e.dropping(n.payload.completed.result.reason),(j(n,"FLUSH")||j(n,"DROP_COMPLETE"))&&e.resting(),t(n)};const dr={outOfTheWay:"cubic-bezier(0.2, 0, 0, 1)",drop:"cubic-bezier(.2,1,.1,1)"},Lt={opacity:{drop:0,combining:.7},scale:{drop:.75}},Jo={outOfTheWay:.2,minDropTime:.33,maxDropTime:.55},ct=`${Jo.outOfTheWay}s ${dr.outOfTheWay}`,Rt={fluid:`opacity ${ct}`,snap:`transform ${ct}, opacity ${ct}`,drop:e=>{const t=`${e}s ${dr.drop}`;return`transform ${t}, opacity ${t}`},outOfTheWay:`transform ${ct}`,placeholder:`height ${ct}, width ${ct}, margin ${ct}`},jr=e=>Ye(e,pe)?void 0:`translate(${e.x}px, ${e.y}px)`,Wn={moveTo:jr,drop:(e,t)=>{const n=jr(e);if(n)return t?`${n} scale(${Lt.scale.drop})`:n}},{minDropTime:zn,maxDropTime:Zo}=Jo,Ql=Zo-zn,qr=1500,ec=.6;var tc=({current:e,destination:t,reason:n})=>{const r=$t(e,t);if(r<=0)return zn;if(r>=qr)return Zo;const o=r/qr,i=zn+Ql*o,a=n==="CANCEL"?i*ec:i;return Number(a.toFixed(2))},nc=({impact:e,draggable:t,dimensions:n,viewport:r,afterCritical:o})=>{const{draggables:i,droppables:a}=n,s=Ae(e),c=s?a[s]:null,u=a[t.descriptor.droppableId],f=Uo({impact:e,draggable:t,draggables:i,afterCritical:o,droppable:c||u,viewport:r});return Se(f,t.client.borderBox.center)},rc=({draggables:e,reason:t,lastImpact:n,home:r,viewport:o,onLiftImpact:i})=>!n.at||t!=="DROP"?{impact:Ho({draggables:e,impact:i,destination:r,viewport:o,forceShouldAnimate:!0}),didDropInsideDroppable:!1}:n.at.type==="REORDER"?{impact:n,didDropInsideDroppable:!0}:{impact:{...n,displaced:_t},didDropInsideDroppable:!0};const oc=({getState:e,dispatch:t})=>n=>r=>{if(!j(r,"DROP")){n(r);return}const o=e(),i=r.payload.reason;if(o.phase==="COLLECTING"){t(Kl({reason:i}));return}if(o.phase==="IDLE")return;o.phase==="DROP_PENDING"&&o.isWaiting&&(process.env.NODE_ENV!=="production"?h(!1,"A DROP action occurred while DROP_PENDING and still waiting"):h()),o.phase==="DRAGGING"||o.phase==="DROP_PENDING"||(process.env.NODE_ENV!=="production"?h(!1,`Cannot drop in phase: ${o.phase}`):h());const s=o.critical,c=o.dimensions,u=c.draggables[o.critical.draggable.id],{impact:f,didDropInsideDroppable:d}=rc({reason:i,lastImpact:o.impact,afterCritical:o.afterCritical,onLiftImpact:o.onLiftImpact,home:o.dimensions.droppables[o.critical.droppable.id],viewport:o.viewport,draggables:o.dimensions.draggables}),p=d?nr(f):null,m=d?bn(f):null,b={index:s.draggable.index,droppableId:s.droppable.id},v={draggableId:u.descriptor.id,type:u.descriptor.type,source:b,reason:i,mode:o.movementMode,destination:p,combine:m},y=nc({impact:f,draggable:u,dimensions:c,viewport:o.viewport,afterCritical:o.afterCritical}),w={critical:o.critical,afterCritical:o.afterCritical,result:v,impact:f};if(!(!Ye(o.current.client.offset,y)||!!v.combine)){t(cr({completed:w}));return}const G=tc({current:o.current.client.offset,destination:y,reason:i});t(ql({newHomeClientOffset:y,dropDuration:G,completed:w}))};var Qo=()=>({x:window.pageXOffset,y:window.pageYOffset});function ic(e){return{eventName:"scroll",options:{passive:!0,capture:!1},fn:t=>{t.target!==window&&t.target!==window.document||e()}}}function ac({onWindowScroll:e}){function t(){e(Qo())}const n=Tt(t),r=ic(n);let o=Ke;function i(){return o!==Ke}function a(){i()&&(process.env.NODE_ENV!=="production"?h(!1,"Cannot start scroll listener when already active"):h()),o=Be(window,[r])}function s(){i()||(process.env.NODE_ENV!=="production"?h(!1,"Cannot stop scroll listener when not active"):h()),n.cancel(),o(),o=Ke}return{start:a,stop:s,isActive:i}}const sc=e=>j(e,"DROP_COMPLETE")||j(e,"DROP_ANIMATE")||j(e,"FLUSH"),lc=e=>{const t=ac({onWindowScroll:n=>{e.dispatch(Gl({newScroll:n}))}});return n=>r=>{!t.isActive()&&j(r,"INITIAL_PUBLISH")&&t.start(),t.isActive()&&sc(r)&&t.stop(),n(r)}};var cc=e=>{let t=!1,n=!1;const r=setTimeout(()=>{n=!0}),o=i=>{if(t){process.env.NODE_ENV!=="production"&&Z("Announcement already made. Not making a second announcement");return}if(n){process.env.NODE_ENV!=="production"&&Z(`
55
+ Announcements cannot be made asynchronously.
56
+ Default message has already been announced.
57
+ `);return}t=!0,e(i),clearTimeout(r)};return o.wasCalled=()=>t,o},dc=()=>{const e=[],t=o=>{const i=e.findIndex(s=>s.timerId===o);i===-1&&(process.env.NODE_ENV!=="production"?h(!1,"Could not find timer"):h());const[a]=e.splice(i,1);a.callback()};return{add:o=>{const i=setTimeout(()=>t(i)),a={timerId:i,callback:o};e.push(a)},flush:()=>{if(!e.length)return;const o=[...e];e.length=0,o.forEach(i=>{clearTimeout(i.timerId),i.callback()})}}};const uc=(e,t)=>e==null&&t==null?!0:e==null||t==null?!1:e.droppableId===t.droppableId&&e.index===t.index,pc=(e,t)=>e==null&&t==null?!0:e==null||t==null?!1:e.draggableId===t.draggableId&&e.droppableId===t.droppableId,fc=(e,t)=>{if(e===t)return!0;const n=e.draggable.id===t.draggable.id&&e.draggable.droppableId===t.draggable.droppableId&&e.draggable.type===t.draggable.type&&e.draggable.index===t.draggable.index,r=e.droppable.id===t.droppable.id&&e.droppable.type===t.droppable.type;return n&&r},Nt=(e,t)=>{Ht(),t(),Ut()},en=(e,t)=>({draggableId:e.draggable.id,type:e.droppable.type,source:{droppableId:e.droppable.id,index:e.draggable.index},mode:t});function An(e,t,n,r){if(!e){n(r(t));return}const o=cc(n);e(t,{announce:o}),o.wasCalled()||n(r(t))}var mc=(e,t)=>{const n=dc();let r=null;const o=(d,p)=>{r&&(process.env.NODE_ENV!=="production"?h(!1,"Cannot fire onBeforeCapture as a drag start has already been published"):h()),Nt("onBeforeCapture",()=>{const m=e().onBeforeCapture;m&&m({draggableId:d,mode:p})})},i=(d,p)=>{r&&(process.env.NODE_ENV!=="production"?h(!1,"Cannot fire onBeforeDragStart as a drag start has already been published"):h()),Nt("onBeforeDragStart",()=>{const m=e().onBeforeDragStart;m&&m(en(d,p))})},a=(d,p)=>{r&&(process.env.NODE_ENV!=="production"?h(!1,"Cannot fire onBeforeDragStart as a drag start has already been published"):h());const m=en(d,p);r={mode:p,lastCritical:d,lastLocation:m.source,lastCombine:null},n.add(()=>{Nt("onDragStart",()=>An(e().onDragStart,m,t,rn.onDragStart))})},s=(d,p)=>{const m=nr(p),b=bn(p);r||(process.env.NODE_ENV!=="production"?h(!1,"Cannot fire onDragMove when onDragStart has not been called"):h());const v=!fc(d,r.lastCritical);v&&(r.lastCritical=d);const y=!uc(r.lastLocation,m);y&&(r.lastLocation=m);const w=!pc(r.lastCombine,b);if(w&&(r.lastCombine=b),!v&&!y&&!w)return;const N={...en(d,r.mode),combine:b,destination:m};n.add(()=>{Nt("onDragUpdate",()=>An(e().onDragUpdate,N,t,rn.onDragUpdate))})},c=()=>{r||(process.env.NODE_ENV!=="production"?h(!1,"Can only flush responders while dragging"):h()),n.flush()},u=d=>{r||(process.env.NODE_ENV!=="production"?h(!1,"Cannot fire onDragEnd when there is no matching onDragStart"):h()),r=null,Nt("onDragEnd",()=>An(e().onDragEnd,d,t,rn.onDragEnd))};return{beforeCapture:o,beforeStart:i,start:a,update:s,flush:c,drop:u,abort:()=>{if(!r)return;const d={...en(r.lastCritical,r.mode),combine:null,destination:null,reason:"CANCEL"};u(d)}}},hc=(e,t)=>{const n=mc(e,t);return r=>o=>i=>{if(j(i,"BEFORE_INITIAL_CAPTURE")){n.beforeCapture(i.payload.draggableId,i.payload.movementMode);return}if(j(i,"INITIAL_PUBLISH")){const s=i.payload.critical;n.beforeStart(s,i.payload.movementMode),o(i),n.start(s,i.payload.movementMode);return}if(j(i,"DROP_COMPLETE")){const s=i.payload.completed.result;n.flush(),o(i),n.drop(s);return}if(o(i),j(i,"FLUSH")){n.abort();return}const a=r.getState();a.phase==="DRAGGING"&&n.update(a.critical,a.impact)}};const gc=e=>t=>n=>{if(!j(n,"DROP_ANIMATION_FINISHED")){t(n);return}const r=e.getState();r.phase!=="DROP_ANIMATING"&&(process.env.NODE_ENV!=="production"?h(!1,"Cannot finish a drop animating when no drop is occurring"):h()),e.dispatch(cr({completed:r.completed}))},bc=e=>{let t=null,n=null;function r(){n&&(cancelAnimationFrame(n),n=null),t&&(t(),t=null)}return o=>i=>{if((j(i,"FLUSH")||j(i,"DROP_COMPLETE")||j(i,"DROP_ANIMATION_FINISHED"))&&r(),o(i),!j(i,"DROP_ANIMATE"))return;const a={eventName:"scroll",options:{capture:!0,passive:!1,once:!0},fn:function(){e.getState().phase==="DROP_ANIMATING"&&e.dispatch(Xo())}};n=requestAnimationFrame(()=>{n=null,t=Be(window,[a])})}};var vc=e=>()=>t=>n=>{(j(n,"DROP_COMPLETE")||j(n,"FLUSH")||j(n,"DROP_ANIMATE"))&&e.stopPublishing(),t(n)},yc=e=>{let t=!1;return()=>n=>r=>{if(j(r,"INITIAL_PUBLISH")){t=!0,e.tryRecordFocus(r.payload.critical.draggable.id),n(r),e.tryRestoreFocusRecorded();return}if(n(r),!!t){if(j(r,"FLUSH")){t=!1,e.tryRestoreFocusRecorded();return}if(j(r,"DROP_COMPLETE")){t=!1;const o=r.payload.completed.result;o.combine&&e.tryShiftRecord(o.draggableId,o.combine.draggableId),e.tryRestoreFocusRecorded()}}}};const Dc=e=>j(e,"DROP_COMPLETE")||j(e,"DROP_ANIMATE")||j(e,"FLUSH");var xc=e=>t=>n=>r=>{if(Dc(r)){e.stop(),n(r);return}if(j(r,"INITIAL_PUBLISH")){n(r);const o=t.getState();o.phase!=="DRAGGING"&&(process.env.NODE_ENV!=="production"?h(!1,"Expected phase to be DRAGGING after INITIAL_PUBLISH"):h()),e.start(o);return}n(r),e.scroll(t.getState())};const Ec=e=>t=>n=>{if(t(n),!j(n,"PUBLISH_WHILE_DRAGGING"))return;const r=e.getState();r.phase==="DROP_PENDING"&&(r.isWaiting||e.dispatch(Yo({reason:r.reason})))},wc=process.env.NODE_ENV!=="production"&&typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({name:"@hello-pangea/dnd"}):na;var Cc=({dimensionMarshal:e,focusMarshal:t,styleMarshal:n,getResponders:r,announce:o,autoScroller:i})=>ta(Tl,wc(ra(Zl(n),vc(e),Jl(e),oc,gc,bc,Ec,xc(i),lc,yc(t),hc(r,o))));const Pn=()=>({additions:{},removals:{},modified:{}});function Ic({registry:e,callbacks:t}){let n=Pn(),r=null;const o=()=>{r||(t.collectionStarting(),r=requestAnimationFrame(()=>{r=null,Ht();const{additions:c,removals:u,modified:f}=n,d=Object.keys(c).map(b=>e.draggable.getById(b).getDimension(pe)).sort((b,v)=>b.descriptor.index-v.descriptor.index),p=Object.keys(f).map(b=>{const y=e.droppable.getById(b).callbacks.getScrollWhileDragging();return{droppableId:b,scroll:y}}),m={additions:d,removals:Object.keys(u),modified:p};n=Pn(),Ut(),t.publish(m)}))};return{add:c=>{const u=c.descriptor.id;n.additions[u]=c,n.modified[c.descriptor.droppableId]=!0,n.removals[u]&&delete n.removals[u],o()},remove:c=>{const u=c.descriptor;n.removals[u.id]=!0,n.modified[u.droppableId]=!0,n.additions[u.id]&&delete n.additions[u.id],o()},stop:()=>{r&&(cancelAnimationFrame(r),r=null,n=Pn())}}}var ei=({scrollHeight:e,scrollWidth:t,height:n,width:r})=>{const o=Se({x:t,y:e},{x:r,y:n});return{x:Math.max(0,o.x),y:Math.max(0,o.y)}},ti=()=>{const e=document.documentElement;return e||(process.env.NODE_ENV!=="production"?h(!1,"Cannot find document.documentElement"):h()),e},ni=()=>{const e=ti();return ei({scrollHeight:e.scrollHeight,scrollWidth:e.scrollWidth,width:e.clientWidth,height:e.clientHeight})},Nc=()=>{const e=Qo(),t=ni(),n=e.y,r=e.x,o=ti(),i=o.clientWidth,a=o.clientHeight,s=r+i,c=n+a;return{frame:Le({top:n,left:r,right:s,bottom:c}),scroll:{initial:e,current:e,max:t,diff:{value:pe,displacement:pe}}}},Sc=({critical:e,scrollOptions:t,registry:n})=>{Ht();const r=Nc(),o=r.scroll.current,i=e.droppable,a=n.droppable.getAllByType(i.type).map(f=>f.callbacks.getDimensionAndWatchScroll(o,t)),s=n.draggable.getAllByType(e.draggable.type).map(f=>f.getDimension(o)),c={draggables:Po(s),droppables:Ao(a)};return Ut(),{dimensions:c,critical:e,viewport:r}};function Kr(e,t,n){return n.descriptor.id===t.id||n.descriptor.type!==t.type?!1:e.droppable.getById(n.descriptor.droppableId).descriptor.mode!=="virtual"?(process.env.NODE_ENV!=="production"&&Z(`
58
+ You are attempting to add or remove a Draggable [id: ${n.descriptor.id}]
59
+ while a drag is occurring. This is only supported for virtual lists.
60
+
61
+ See https://github.com/hello-pangea/dnd/blob/main/docs/patterns/virtual-lists.md
62
+ `),!1):!0}var Oc=(e,t)=>{let n=null;const r=Ic({callbacks:{publish:t.publishWhileDragging,collectionStarting:t.collectionStarting},registry:e}),o=(p,m)=>{e.droppable.exists(p)||(process.env.NODE_ENV!=="production"?h(!1,`Cannot update is enabled flag of Droppable ${p} as it is not registered`):h()),n&&t.updateDroppableIsEnabled({id:p,isEnabled:m})},i=(p,m)=>{n&&(e.droppable.exists(p)||(process.env.NODE_ENV!=="production"?h(!1,`Cannot update isCombineEnabled flag of Droppable ${p} as it is not registered`):h()),t.updateDroppableIsCombineEnabled({id:p,isCombineEnabled:m}))},a=(p,m)=>{n&&(e.droppable.exists(p)||(process.env.NODE_ENV!=="production"?h(!1,`Cannot update the scroll on Droppable ${p} as it is not registered`):h()),t.updateDroppableScroll({id:p,newScroll:m}))},s=(p,m)=>{n&&e.droppable.getById(p).callbacks.scroll(m)},c=()=>{if(!n)return;r.stop();const p=n.critical.droppable;e.droppable.getAllByType(p.type).forEach(m=>m.callbacks.dragStopped()),n.unsubscribe(),n=null},u=p=>{n||(process.env.NODE_ENV!=="production"?h(!1,"Should only be subscribed when a collection is occurring"):h());const m=n.critical.draggable;p.type==="ADDITION"&&Kr(e,m,p.value)&&r.add(p.value),p.type==="REMOVAL"&&Kr(e,m,p.value)&&r.remove(p.value)};return{updateDroppableIsEnabled:o,updateDroppableIsCombineEnabled:i,scrollDroppable:s,updateDroppableScroll:a,startPublishing:p=>{n&&(process.env.NODE_ENV!=="production"?h(!1,"Cannot start capturing critical dimensions as there is already a collection"):h());const m=e.draggable.getById(p.draggableId),b=e.droppable.getById(m.descriptor.droppableId),v={draggable:m.descriptor,droppable:b.descriptor},y=e.subscribe(u);return n={critical:v,unsubscribe:y},Sc({critical:v,registry:e,scrollOptions:p.scrollOptions})},stopPublishing:c}},ri=(e,t)=>e.phase==="IDLE"?!0:e.phase!=="DROP_ANIMATING"||e.completed.result.draggableId===t?!1:e.completed.result.reason==="DROP",Ac=e=>{window.scrollBy(e.x,e.y)};const Pc=ue(e=>gn(e).filter(t=>!(!t.isEnabled||!t.frame))),Rc=(e,t)=>Pc(t).find(r=>(r.frame||(process.env.NODE_ENV!=="production"?h(!1,"Invalid result"):h()),Mo(r.frame.pageMarginBox)(e)))||null;var Tc=({center:e,destination:t,droppables:n})=>{if(t){const o=n[t];return o.frame?o:null}return Rc(e,n)};const Ft={startFromPercentage:.25,maxScrollAtPercentage:.05,maxPixelScroll:28,ease:e=>e**2,durationDampening:{stopDampeningAt:1200,accelerateAt:360},disabled:!1};var Bc=(e,t,n=()=>Ft)=>{const r=n(),o=e[t.size]*r.startFromPercentage,i=e[t.size]*r.maxScrollAtPercentage;return{startScrollingFrom:o,maxScrollValueAt:i}},oi=({startOfRange:e,endOfRange:t,current:n})=>{const r=t-e;return r===0?(process.env.NODE_ENV!=="production"&&Z(`
63
+ Detected distance range of 0 in the fluid auto scroller
64
+ This is unexpected and would cause a divide by 0 issue.
65
+ Not allowing an auto scroll
66
+ `),0):(n-e)/r},ur=1,$c=(e,t,n=()=>Ft)=>{const r=n();if(e>t.startScrollingFrom)return 0;if(e<=t.maxScrollValueAt)return r.maxPixelScroll;if(e===t.startScrollingFrom)return ur;const i=1-oi({startOfRange:t.maxScrollValueAt,endOfRange:t.startScrollingFrom,current:e}),a=r.maxPixelScroll*r.ease(i);return Math.ceil(a)},_c=(e,t,n)=>{const r=n(),o=r.durationDampening.accelerateAt,i=r.durationDampening.stopDampeningAt,a=t,s=i,u=Date.now()-a;if(u>=i)return e;if(u<o)return ur;const f=oi({startOfRange:o,endOfRange:s,current:u}),d=e*r.ease(f);return Math.ceil(d)},Yr=({distanceToEdge:e,thresholds:t,dragStartTime:n,shouldUseTimeDampening:r,getAutoScrollerOptions:o})=>{const i=$c(e,t,o);return i===0?0:r?Math.max(_c(i,n,o),ur):i},Xr=({container:e,distanceToEdges:t,dragStartTime:n,axis:r,shouldUseTimeDampening:o,getAutoScrollerOptions:i})=>{const a=Bc(e,r,i);return t[r.end]<t[r.start]?Yr({distanceToEdge:t[r.end],thresholds:a,dragStartTime:n,shouldUseTimeDampening:o,getAutoScrollerOptions:i}):-1*Yr({distanceToEdge:t[r.start],thresholds:a,dragStartTime:n,shouldUseTimeDampening:o,getAutoScrollerOptions:i})},kc=({container:e,subject:t,proposedScroll:n})=>{const r=t.height>e.height,o=t.width>e.width;return!o&&!r?n:o&&r?null:{x:o?0:n.x,y:r?0:n.y}};const Lc=Oo(e=>e===0?0:e);var ii=({dragStartTime:e,container:t,subject:n,center:r,shouldUseTimeDampening:o,getAutoScrollerOptions:i})=>{const a={top:r.y-t.top,right:t.right-r.x,bottom:t.bottom-r.y,left:r.x-t.left},s=Xr({container:t,distanceToEdges:a,dragStartTime:e,axis:rr,shouldUseTimeDampening:o,getAutoScrollerOptions:i}),c=Xr({container:t,distanceToEdges:a,dragStartTime:e,axis:Bo,shouldUseTimeDampening:o,getAutoScrollerOptions:i}),u=Lc({x:c,y:s});if(Ye(u,pe))return null;const f=kc({container:t,subject:n,proposedScroll:u});return f?Ye(f,pe)?null:f:null};const Fc=Oo(e=>e===0?0:e>0?1:-1),pr=(()=>{const e=(t,n)=>t<0?t:t>n?t-n:0;return({current:t,max:n,change:r})=>{const o=he(t,r),i={x:e(o.x,n.x),y:e(o.y,n.y)};return Ye(i,pe)?null:i}})(),ai=({max:e,current:t,change:n})=>{const r={x:Math.max(t.x,e.x),y:Math.max(t.y,e.y)},o=Fc(n),i=pr({max:r,current:t,change:o});return!i||o.x!==0&&i.x===0||o.y!==0&&i.y===0},fr=(e,t)=>ai({current:e.scroll.current,max:e.scroll.max,change:t}),Vc=(e,t)=>{if(!fr(e,t))return null;const n=e.scroll.max,r=e.scroll.current;return pr({current:r,max:n,change:t})},mr=(e,t)=>{const n=e.frame;return n?ai({current:n.scroll.current,max:n.scroll.max,change:t}):!1},Mc=(e,t)=>{const n=e.frame;return!n||!mr(e,t)?null:pr({current:n.scroll.current,max:n.scroll.max,change:t})};var Gc=({viewport:e,subject:t,center:n,dragStartTime:r,shouldUseTimeDampening:o,getAutoScrollerOptions:i})=>{const a=ii({dragStartTime:r,container:e.frame,subject:t,center:n,shouldUseTimeDampening:o,getAutoScrollerOptions:i});return a&&fr(e,a)?a:null},Wc=({droppable:e,subject:t,center:n,dragStartTime:r,shouldUseTimeDampening:o,getAutoScrollerOptions:i})=>{const a=e.frame;if(!a)return null;const s=ii({dragStartTime:r,container:a.pageMarginBox,subject:t,center:n,shouldUseTimeDampening:o,getAutoScrollerOptions:i});return s&&mr(e,s)?s:null},Jr=({state:e,dragStartTime:t,shouldUseTimeDampening:n,scrollWindow:r,scrollDroppable:o,getAutoScrollerOptions:i})=>{const a=e.current.page.borderBoxCenter,c=e.dimensions.draggables[e.critical.draggable.id].page.marginBox;if(e.isWindowScrollAllowed){const d=e.viewport,p=Gc({dragStartTime:t,viewport:d,subject:c,center:a,shouldUseTimeDampening:n,getAutoScrollerOptions:i});if(p){r(p);return}}const u=Tc({center:a,destination:Ae(e.impact),droppables:e.dimensions.droppables});if(!u)return;const f=Wc({dragStartTime:t,droppable:u,subject:c,center:a,shouldUseTimeDampening:n,getAutoScrollerOptions:i});f&&o(u.descriptor.id,f)},zc=({scrollWindow:e,scrollDroppable:t,getAutoScrollerOptions:n=()=>Ft})=>{const r=Tt(e),o=Tt(t);let i=null;const a=u=>{i||(process.env.NODE_ENV!=="production"?h(!1,"Cannot fluid scroll if not dragging"):h());const{shouldUseTimeDampening:f,dragStartTime:d}=i;Jr({state:u,scrollWindow:r,scrollDroppable:o,dragStartTime:d,shouldUseTimeDampening:f,getAutoScrollerOptions:n})};return{start:u=>{Ht(),i&&(process.env.NODE_ENV!=="production"?h(!1,"Cannot start auto scrolling when already started"):h());const f=Date.now();let d=!1;const p=()=>{d=!0};Jr({state:u,dragStartTime:0,shouldUseTimeDampening:!1,scrollWindow:p,scrollDroppable:p,getAutoScrollerOptions:n}),i={dragStartTime:f,shouldUseTimeDampening:d},Ut(),d&&a(u)},stop:()=>{i&&(r.cancel(),o.cancel(),i=null)},scroll:a}},Hc=({move:e,scrollDroppable:t,scrollWindow:n})=>{const r=(s,c)=>{const u=he(s.current.client.selection,c);e({client:u})},o=(s,c)=>{if(!mr(s,c))return c;const u=Mc(s,c);if(!u)return t(s.descriptor.id,c),null;const f=Se(c,u);return t(s.descriptor.id,f),Se(c,f)},i=(s,c,u)=>{if(!s||!fr(c,u))return u;const f=Vc(c,u);if(!f)return n(u),null;const d=Se(u,f);return n(d),Se(u,d)};return s=>{const c=s.scrollJumpRequest;if(!c)return;const u=Ae(s.impact);u||(process.env.NODE_ENV!=="production"?h(!1,"Cannot perform a jump scroll when there is no destination"):h());const f=o(s.dimensions.droppables[u],c);if(!f)return;const d=s.viewport,p=i(s.isWindowScrollAllowed,d,f);p&&r(s,p)}},Uc=({scrollDroppable:e,scrollWindow:t,move:n,getAutoScrollerOptions:r})=>{const o=zc({scrollWindow:t,scrollDroppable:e,getAutoScrollerOptions:r}),i=Hc({move:n,scrollWindow:t,scrollDroppable:e});return{scroll:c=>{if(!(r().disabled||c.phase!=="DRAGGING")){if(c.movementMode==="FLUID"){o.scroll(c);return}c.scrollJumpRequest&&i(c)}},start:o.start,stop:o.stop}};const Dt="data-rfd",xt=(()=>{const e=`${Dt}-drag-handle`;return{base:e,draggableId:`${e}-draggable-id`,contextId:`${e}-context-id`}})(),Hn=(()=>{const e=`${Dt}-draggable`;return{base:e,contextId:`${e}-context-id`,id:`${e}-id`}})(),jc=(()=>{const e=`${Dt}-droppable`;return{base:e,contextId:`${e}-context-id`,id:`${e}-id`}})(),Zr={contextId:`${Dt}-scroll-container-context-id`},qc=e=>t=>`[${t}="${e}"]`,St=(e,t)=>e.map(n=>{const r=n.styles[t];return r?`${n.selector} { ${r} }`:""}).join(" "),Kc="pointer-events: none;";var Yc=e=>{const t=qc(e),n=(()=>{const s=`
67
+ cursor: -webkit-grab;
68
+ cursor: grab;
69
+ `;return{selector:t(xt.contextId),styles:{always:`
70
+ -webkit-touch-callout: none;
71
+ -webkit-tap-highlight-color: rgba(0,0,0,0);
72
+ touch-action: manipulation;
73
+ `,resting:s,dragging:Kc,dropAnimating:s}}})(),r=(()=>{const s=`
74
+ transition: ${Rt.outOfTheWay};
75
+ `;return{selector:t(Hn.contextId),styles:{dragging:s,dropAnimating:s,userCancel:s}}})(),o={selector:t(jc.contextId),styles:{always:"overflow-anchor: none;"}},a=[r,n,o,{selector:"body",styles:{dragging:`
76
+ cursor: grabbing;
77
+ cursor: -webkit-grabbing;
78
+ user-select: none;
79
+ -webkit-user-select: none;
80
+ -moz-user-select: none;
81
+ -ms-user-select: none;
82
+ overflow-anchor: none;
83
+ `}}];return{always:St(a,"always"),resting:St(a,"resting"),dragging:St(a,"dragging"),dropAnimating:St(a,"dropAnimating"),userCancel:St(a,"userCancel")}};const Pe=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u"?Gi:Ce,Rn=()=>{const e=document.querySelector("head");return e||(process.env.NODE_ENV!=="production"?h(!1,"Cannot find the head to append a style to"):h()),e},Qr=e=>{const t=document.createElement("style");return e&&t.setAttribute("nonce",e),t.type="text/css",t};function Xc(e,t){const n=k(()=>Yc(e),[e]),r=J(null),o=J(null),i=E(ue(d=>{const p=o.current;p||(process.env.NODE_ENV!=="production"?h(!1,"Cannot set dynamic style element if it is not set"):h()),p.textContent=d}),[]),a=E(d=>{const p=r.current;p||(process.env.NODE_ENV!=="production"?h(!1,"Cannot set dynamic style element if it is not set"):h()),p.textContent=d},[]);Pe(()=>{!r.current&&!o.current||(process.env.NODE_ENV!=="production"?h(!1,"style elements already mounted"):h());const d=Qr(t),p=Qr(t);return r.current=d,o.current=p,d.setAttribute(`${Dt}-always`,e),p.setAttribute(`${Dt}-dynamic`,e),Rn().appendChild(d),Rn().appendChild(p),a(n.always),i(n.resting),()=>{const m=b=>{const v=b.current;v||(process.env.NODE_ENV!=="production"?h(!1,"Cannot unmount ref as it is not set"):h()),Rn().removeChild(v),b.current=null};m(r),m(o)}},[t,a,i,n.always,n.resting,e]);const s=E(()=>i(n.dragging),[i,n.dragging]),c=E(d=>{if(d==="DROP"){i(n.dropAnimating);return}i(n.userCancel)},[i,n.dropAnimating,n.userCancel]),u=E(()=>{o.current&&i(n.resting)},[i,n.resting]);return k(()=>({dragging:s,dropping:c,resting:u}),[s,c,u])}function si(e,t){return Array.from(e.querySelectorAll(t))}var li=e=>e&&e.ownerDocument&&e.ownerDocument.defaultView?e.ownerDocument.defaultView:window;function jt(e){return e instanceof li(e).HTMLElement}function ci(e,t){const n=`[${xt.contextId}="${e}"]`,r=si(document,n);if(!r.length)return process.env.NODE_ENV!=="production"&&Z(`Unable to find any drag handles in the context "${e}"`),null;const o=r.find(i=>i.getAttribute(xt.draggableId)===t);return o?jt(o)?o:(process.env.NODE_ENV!=="production"&&Z("drag handle needs to be a HTMLElement"),null):(process.env.NODE_ENV!=="production"&&Z(`Unable to find drag handle with id "${t}" as no handle with a matching id was found`),null)}function Jc(e){const t=J({}),n=J(null),r=J(null),o=J(!1),i=E(function(p,m){const b={id:p,focus:m};return t.current[p]=b,function(){const y=t.current;y[p]!==b&&delete y[p]}},[]),a=E(function(p){const m=ci(e,p);m&&m!==document.activeElement&&m.focus()},[e]),s=E(function(p,m){n.current===p&&(n.current=m)},[]),c=E(function(){r.current||o.current&&(r.current=requestAnimationFrame(()=>{r.current=null;const p=n.current;p&&a(p)}))},[a]),u=E(function(p){n.current=null;const m=document.activeElement;m&&m.getAttribute(xt.draggableId)===p&&(n.current=p)},[]);return Pe(()=>(o.current=!0,function(){o.current=!1;const p=r.current;p&&cancelAnimationFrame(p)}),[]),k(()=>({register:i,tryRecordFocus:u,tryRestoreFocusRecorded:c,tryShiftRecord:s}),[i,u,c,s])}function Zc(){const e={draggables:{},droppables:{}},t=[];function n(d){return t.push(d),function(){const m=t.indexOf(d);m!==-1&&t.splice(m,1)}}function r(d){t.length&&t.forEach(p=>p(d))}function o(d){return e.draggables[d]||null}function i(d){const p=o(d);return p||(process.env.NODE_ENV!=="production"?h(!1,`Cannot find draggable entry with id [${d}]`):h()),p}const a={register:d=>{e.draggables[d.descriptor.id]=d,r({type:"ADDITION",value:d})},update:(d,p)=>{const m=e.draggables[p.descriptor.id];m&&m.uniqueId===d.uniqueId&&(delete e.draggables[p.descriptor.id],e.draggables[d.descriptor.id]=d)},unregister:d=>{const p=d.descriptor.id,m=o(p);m&&d.uniqueId===m.uniqueId&&(delete e.draggables[p],e.droppables[d.descriptor.droppableId]&&r({type:"REMOVAL",value:d}))},getById:i,findById:o,exists:d=>!!o(d),getAllByType:d=>Object.values(e.draggables).filter(p=>p.descriptor.type===d)};function s(d){return e.droppables[d]||null}function c(d){const p=s(d);return p||(process.env.NODE_ENV!=="production"?h(!1,`Cannot find droppable entry with id [${d}]`):h()),p}const u={register:d=>{e.droppables[d.descriptor.id]=d},unregister:d=>{const p=s(d.descriptor.id);p&&d.uniqueId===p.uniqueId&&delete e.droppables[d.descriptor.id]},getById:c,findById:s,exists:d=>!!s(d),getAllByType:d=>Object.values(e.droppables).filter(p=>p.descriptor.type===d)};function f(){e.draggables={},e.droppables={},t.length=0}return{draggable:a,droppable:u,subscribe:n,clean:f}}function Qc(){const e=k(Zc,[]);return Ce(()=>function(){e.clean()},[e]),e}var hr=ee.createContext(null),Vt=()=>{const e=document.body;return e||(process.env.NODE_ENV!=="production"?h(!1,"Cannot find document.body"):h()),e};const ed={position:"absolute",width:"1px",height:"1px",margin:"-1px",border:"0",padding:"0",overflow:"hidden",clip:"rect(0 0 0 0)","clip-path":"inset(100%)"},td=e=>`rfd-announcement-${e}`;function nd(e){const t=k(()=>td(e),[e]),n=J(null);return Ce(function(){const i=document.createElement("div");return n.current=i,i.id=t,i.setAttribute("aria-live","assertive"),i.setAttribute("aria-atomic","true"),bo(i.style,ed),Vt().appendChild(i),function(){setTimeout(function(){const c=Vt();c.contains(i)&&c.removeChild(i),i===n.current&&(n.current=null)})}},[t]),E(o=>{const i=n.current;if(i){i.textContent=o;return}process.env.NODE_ENV!=="production"&&Z(`
84
+ A screen reader message was trying to be announced but it was unable to do so.
85
+ This can occur if you unmount your <DragDropContext /> in your onDragEnd.
86
+ Consider calling provided.announce() before the unmount so that the instruction will
87
+ not be lost for users relying on a screen reader.
88
+
89
+ Message not passed to screen reader:
90
+
91
+ "${o}"
92
+ `)},[])}const rd={separator:"::"};function gr(e,t=rd){const n=ee.useId();return k(()=>`${e}${t.separator}${n}`,[t.separator,e,n])}function od({contextId:e,uniqueId:t}){return`rfd-hidden-text-${e}-${t}`}function id({contextId:e,text:t}){const n=gr("hidden-text",{separator:"-"}),r=k(()=>od({contextId:e,uniqueId:n}),[n,e]);return Ce(function(){const i=document.createElement("div");return i.id=r,i.textContent=t,i.style.display="none",Vt().appendChild(i),function(){const s=Vt();s.contains(i)&&s.removeChild(i)}},[r,t]),r}var Dn=ee.createContext(null),ad={react:"^18.0.0 || ^19.0.0"};const sd=/(\d+)\.(\d+)\.(\d+)/,eo=e=>{const t=sd.exec(e);t==null&&(process.env.NODE_ENV!=="production"?h(!1,`Unable to parse React version ${e}`):h());const n=Number(t[1]),r=Number(t[2]),o=Number(t[3]);return{major:n,minor:r,patch:o,raw:e}},ld=(e,t)=>t.major>e.major?!0:t.major<e.major?!1:t.minor>e.minor?!0:t.minor<e.minor?!1:t.patch>=e.patch;var cd=(e,t)=>{const n=eo(e),r=eo(t);ld(n,r)||process.env.NODE_ENV!=="production"&&Z(`
93
+ React version: [${r.raw}]
94
+ does not satisfy expected peer dependency version: [${n.raw}]
95
+
96
+ This can result in run time bugs, and even fatal crashes
97
+ `)};const Tn=`
98
+ We expect a html5 doctype: <!doctype html>
99
+ This is to ensure consistent browser layout and measurement
100
+
101
+ More information: https://github.com/hello-pangea/dnd/blob/main/docs/guides/doctype.md
102
+ `;var dd=e=>{const t=e.doctype;if(!t){process.env.NODE_ENV!=="production"&&Z(`
103
+ No <!doctype html> found.
104
+
105
+ ${Tn}
106
+ `);return}t.name.toLowerCase()!=="html"&&process.env.NODE_ENV!=="production"&&Z(`
107
+ Unexpected <!doctype> found: (${t.name})
108
+
109
+ ${Tn}
110
+ `),t.publicId!==""&&process.env.NODE_ENV!=="production"&&Z(`
111
+ Unexpected <!doctype> publicId found: (${t.publicId})
112
+ A html5 doctype does not have a publicId
113
+
114
+ ${Tn}
115
+ `)};function br(e){process.env.NODE_ENV!=="production"&&e()}function qt(e,t){br(()=>{Ce(()=>{try{e()}catch(n){Vn(`
116
+ A setup problem was encountered.
117
+
118
+ > ${n.message}
119
+ `)}},t)})}function ud(){qt(()=>{cd(ad.react,ee.version),dd(document)},[])}function vr(e){const t=J(e);return Ce(()=>{t.current=e}),t}function pd(){let e=null;function t(){return!!e}function n(a){return a===e}function r(a){e&&(process.env.NODE_ENV!=="production"?h(!1,"Cannot claim lock as it is already claimed"):h());const s={abandon:a};return e=s,s}function o(){e||(process.env.NODE_ENV!=="production"?h(!1,"Cannot release lock when there is no lock"):h()),e=null}function i(){e&&(e.abandon(),o())}return{isClaimed:t,isActive:n,claim:r,release:o,tryAbandon:i}}function Mt(e){return e.phase==="IDLE"||e.phase==="DROP_ANIMATING"?!1:e.isDragging}const fd=9,md=13,yr=27,di=32,hd=33,gd=34,bd=35,vd=36,yd=37,Dd=38,xd=39,Ed=40,wd={[md]:!0,[fd]:!0};var ui=e=>{wd[e.keyCode]&&e.preventDefault()};const xn=(()=>{const e="visibilitychange";return typeof document>"u"?e:[e,`ms${e}`,`webkit${e}`,`moz${e}`,`o${e}`].find(r=>`on${r}`in document)||e})(),pi=0,to=5;function Cd(e,t){return Math.abs(t.x-e.x)>=to||Math.abs(t.y-e.y)>=to}const no={type:"IDLE"};function Id({cancel:e,completed:t,getPhase:n,setPhase:r}){return[{eventName:"mousemove",fn:o=>{const{button:i,clientX:a,clientY:s}=o;if(i!==pi)return;const c={x:a,y:s},u=n();if(u.type==="DRAGGING"){o.preventDefault(),u.actions.move(c);return}u.type!=="PENDING"&&(process.env.NODE_ENV!=="production"?h(!1,"Cannot be IDLE"):h());const f=u.point;if(!Cd(f,c))return;o.preventDefault();const d=u.actions.fluidLift(c);r({type:"DRAGGING",actions:d})}},{eventName:"mouseup",fn:o=>{const i=n();if(i.type!=="DRAGGING"){e();return}o.preventDefault(),i.actions.drop({shouldBlockNextClick:!0}),t()}},{eventName:"mousedown",fn:o=>{n().type==="DRAGGING"&&o.preventDefault(),e()}},{eventName:"keydown",fn:o=>{if(n().type==="PENDING"){e();return}if(o.keyCode===yr){o.preventDefault(),e();return}ui(o)}},{eventName:"resize",fn:e},{eventName:"scroll",options:{passive:!0,capture:!1},fn:()=>{n().type==="PENDING"&&e()}},{eventName:"webkitmouseforcedown",fn:o=>{const i=n();if(i.type==="IDLE"&&(process.env.NODE_ENV!=="production"?h(!1,"Unexpected phase"):h()),i.actions.shouldRespectForcePress()){e();return}o.preventDefault()}},{eventName:xn,fn:e}]}function Nd(e){const t=J(no),n=J(Ke),r=k(()=>({eventName:"mousedown",fn:function(d){if(d.defaultPrevented||d.button!==pi||d.ctrlKey||d.metaKey||d.shiftKey||d.altKey)return;const p=e.findClosestDraggableId(d);if(!p)return;const m=e.tryGetLock(p,a,{sourceEvent:d});if(!m)return;d.preventDefault();const b={x:d.clientX,y:d.clientY};n.current(),u(m,b)}}),[e]),o=k(()=>({eventName:"webkitmouseforcewillbegin",fn:f=>{if(f.defaultPrevented)return;const d=e.findClosestDraggableId(f);if(!d)return;const p=e.findOptionsForDraggable(d);p&&(p.shouldRespectForcePress||e.canGetLock(d)&&f.preventDefault())}}),[e]),i=E(function(){const d={passive:!1,capture:!0};n.current=Be(window,[o,r],d)},[o,r]),a=E(()=>{t.current.type!=="IDLE"&&(t.current=no,n.current(),i())},[i]),s=E(()=>{const f=t.current;a(),f.type==="DRAGGING"&&f.actions.cancel({shouldBlockNextClick:!0}),f.type==="PENDING"&&f.actions.abort()},[a]),c=E(function(){const d={capture:!0,passive:!1},p=Id({cancel:s,completed:a,getPhase:()=>t.current,setPhase:m=>{t.current=m}});n.current=Be(window,p,d)},[s,a]),u=E(function(d,p){t.current.type!=="IDLE"&&(process.env.NODE_ENV!=="production"?h(!1,"Expected to move from IDLE to PENDING drag"):h()),t.current={type:"PENDING",point:p,actions:d},c()},[c]);Pe(function(){return i(),function(){n.current()}},[i])}function Sd(){}const Od={[gd]:!0,[hd]:!0,[vd]:!0,[bd]:!0};function Ad(e,t){function n(){t(),e.cancel()}function r(){t(),e.drop()}return[{eventName:"keydown",fn:o=>{if(o.keyCode===yr){o.preventDefault(),n();return}if(o.keyCode===di){o.preventDefault(),r();return}if(o.keyCode===Ed){o.preventDefault(),e.moveDown();return}if(o.keyCode===Dd){o.preventDefault(),e.moveUp();return}if(o.keyCode===xd){o.preventDefault(),e.moveRight();return}if(o.keyCode===yd){o.preventDefault(),e.moveLeft();return}if(Od[o.keyCode]){o.preventDefault();return}ui(o)}},{eventName:"mousedown",fn:n},{eventName:"mouseup",fn:n},{eventName:"click",fn:n},{eventName:"touchstart",fn:n},{eventName:"resize",fn:n},{eventName:"wheel",fn:n,options:{passive:!0}},{eventName:xn,fn:n}]}function Pd(e){const t=J(Sd),n=k(()=>({eventName:"keydown",fn:function(i){if(i.defaultPrevented||i.keyCode!==di)return;const a=e.findClosestDraggableId(i);if(!a)return;const s=e.tryGetLock(a,f,{sourceEvent:i});if(!s)return;i.preventDefault();let c=!0;const u=s.snapLift();t.current();function f(){c||(process.env.NODE_ENV!=="production"?h(!1,"Cannot stop capturing a keyboard drag when not capturing"):h()),c=!1,t.current(),r()}t.current=Be(window,Ad(u,f),{capture:!0,passive:!1})}}),[e]),r=E(function(){const i={passive:!1,capture:!0};t.current=Be(window,[n],i)},[n]);Pe(function(){return r(),function(){t.current()}},[r])}const Bn={type:"IDLE"},Rd=120,Td=.15;function Bd({cancel:e,getPhase:t}){return[{eventName:"orientationchange",fn:e},{eventName:"resize",fn:e},{eventName:"contextmenu",fn:n=>{n.preventDefault()}},{eventName:"keydown",fn:n=>{if(t().type!=="DRAGGING"){e();return}n.keyCode===yr&&n.preventDefault(),e()}},{eventName:xn,fn:e}]}function $d({cancel:e,completed:t,getPhase:n}){return[{eventName:"touchmove",options:{capture:!1},fn:r=>{const o=n();if(o.type!=="DRAGGING"){e();return}o.hasMoved=!0;const{clientX:i,clientY:a}=r.touches[0],s={x:i,y:a};r.preventDefault(),o.actions.move(s)}},{eventName:"touchend",fn:r=>{const o=n();if(o.type!=="DRAGGING"){e();return}r.preventDefault(),o.actions.drop({shouldBlockNextClick:!0}),t()}},{eventName:"touchcancel",fn:r=>{if(n().type!=="DRAGGING"){e();return}r.preventDefault(),e()}},{eventName:"touchforcechange",fn:r=>{const o=n();o.type==="IDLE"&&(process.env.NODE_ENV,h());const i=r.touches[0];if(!i||!(i.force>=Td))return;const s=o.actions.shouldRespectForcePress();if(o.type==="PENDING"){s&&e();return}if(s){if(o.hasMoved){r.preventDefault();return}e();return}r.preventDefault()}},{eventName:xn,fn:e}]}function _d(e){const t=J(Bn),n=J(Ke),r=E(function(){return t.current},[]),o=E(function(m){t.current=m},[]),i=k(()=>({eventName:"touchstart",fn:function(m){if(m.defaultPrevented)return;const b=e.findClosestDraggableId(m);if(!b)return;const v=e.tryGetLock(b,s,{sourceEvent:m});if(!v)return;const y=m.touches[0],{clientX:w,clientY:N}=y,G={x:w,y:N};n.current(),d(v,G)}}),[e]),a=E(function(){const m={capture:!0,passive:!1};n.current=Be(window,[i],m)},[i]),s=E(()=>{const p=t.current;p.type!=="IDLE"&&(p.type==="PENDING"&&clearTimeout(p.longPressTimerId),o(Bn),n.current(),a())},[a,o]),c=E(()=>{const p=t.current;s(),p.type==="DRAGGING"&&p.actions.cancel({shouldBlockNextClick:!0}),p.type==="PENDING"&&p.actions.abort()},[s]),u=E(function(){const m={capture:!0,passive:!1},b={cancel:c,completed:s,getPhase:r},v=Be(window,$d(b),m),y=Be(window,Bd(b),m);n.current=function(){v(),y()}},[c,r,s]),f=E(function(){const m=r();m.type!=="PENDING"&&(process.env.NODE_ENV!=="production"?h(!1,`Cannot start dragging from phase ${m.type}`):h());const b=m.actions.fluidLift(m.point);o({type:"DRAGGING",actions:b,hasMoved:!1})},[r,o]),d=E(function(m,b){r().type!=="IDLE"&&(process.env.NODE_ENV!=="production"?h(!1,"Expected to move from IDLE to PENDING drag"):h());const v=setTimeout(f,Rd);o({type:"PENDING",point:b,actions:m,longPressTimerId:v}),u()},[u,r,o,f]);Pe(function(){return a(),function(){n.current();const b=r();b.type==="PENDING"&&(clearTimeout(b.longPressTimerId),o(Bn))}},[r,a,o]),Pe(function(){return Be(window,[{eventName:"touchmove",fn:()=>{},options:{capture:!1,passive:!1}}])},[])}function kd(e){br(()=>{const t=vr(e);qt(()=>{t.current.length!==e.length&&(process.env.NODE_ENV!=="production"?h(!1,"Cannot change the amount of sensor hooks after mounting"):h(!1))})})}const Ld=["input","button","textarea","select","option","optgroup","video","audio"];function fi(e,t){if(t==null)return!1;if(Ld.includes(t.tagName.toLowerCase()))return!0;const r=t.getAttribute("contenteditable");return r==="true"||r===""?!0:t===e?!1:fi(e,t.parentElement)}function Fd(e,t){const n=t.target;return jt(n)?fi(e,n):!1}var Vd=e=>Le(e.getBoundingClientRect()).center;function Md(e){return e instanceof li(e).Element}const Gd=(()=>{const e="matches";return typeof document>"u"?e:[e,"msMatchesSelector","webkitMatchesSelector"].find(r=>r in Element.prototype)||e})();function mi(e,t){return e==null?null:e[Gd](t)?e:mi(e.parentElement,t)}function Wd(e,t){return e.closest?e.closest(t):mi(e,t)}function zd(e){return`[${xt.contextId}="${e}"]`}function Hd(e,t){const n=t.target;if(!Md(n))return process.env.NODE_ENV!=="production"&&Z("event.target must be a Element"),null;const r=zd(e),o=Wd(n,r);return o?jt(o)?o:(process.env.NODE_ENV!=="production"&&Z("drag handle must be a HTMLElement"),null):null}function Ud(e,t){const n=Hd(e,t);return n?n.getAttribute(xt.draggableId):null}function jd(e,t){const n=`[${Hn.contextId}="${e}"]`,o=si(document,n).find(i=>i.getAttribute(Hn.id)===t);return o?jt(o)?o:(process.env.NODE_ENV!=="production"&&Z("Draggable element is not a HTMLElement"),null):null}function qd(e){e.preventDefault()}function tn({expected:e,phase:t,isLockActive:n,shouldWarn:r}){return n()?e!==t?(r&&process.env.NODE_ENV!=="production"&&Z(`
120
+ Cannot perform action.
121
+ The actions you used belong to an outdated phase
122
+
123
+ Current phase: ${e}
124
+ You called an action from outdated phase: ${t}
125
+
126
+ Tips:
127
+
128
+ - Do not use preDragActions actions after calling preDragActions.lift()
129
+ `),!1):!0:(r&&process.env.NODE_ENV!=="production"&&Z(`
130
+ Cannot perform action.
131
+ The sensor no longer has an action lock.
132
+
133
+ Tips:
134
+
135
+ - Throw away your action handlers when forceStop() is called
136
+ - Check actions.isActive() if you really need to
137
+ `),!1)}function hi({lockAPI:e,store:t,registry:n,draggableId:r}){if(e.isClaimed())return!1;const o=n.draggable.findById(r);return o?!(!o.options.isEnabled||!ri(t.getState(),r)):(process.env.NODE_ENV!=="production"&&Z(`Unable to find draggable with id: ${r}`),!1)}function Kd({lockAPI:e,contextId:t,store:n,registry:r,draggableId:o,forceSensorStop:i,sourceEvent:a}){if(!hi({lockAPI:e,store:n,registry:r,draggableId:o}))return null;const c=r.draggable.getById(o),u=jd(t,c.descriptor.id);if(!u)return process.env.NODE_ENV!=="production"&&Z(`Unable to find draggable element with id: ${o}`),null;if(a&&!c.options.canDragInteractiveElements&&Fd(u,a))return null;const f=e.claim(i||Ke);let d="PRE_DRAG";function p(){return c.options.shouldRespectForcePress}function m(){return e.isActive(f)}function b(R,$){tn({expected:R,phase:d,isLockActive:m,shouldWarn:!0})&&n.dispatch($())}const v=b.bind(null,"DRAGGING");function y(R){function $(){e.release(),d="COMPLETED"}d!=="PRE_DRAG"&&($(),process.env.NODE_ENV!=="production"?h(!1,`Cannot lift in phase ${d}`):h()),n.dispatch($l(R.liftActionArgs)),d="DRAGGING";function O(te,I={shouldBlockNextClick:!1}){if(R.cleanup(),I.shouldBlockNextClick){const S=Be(window,[{eventName:"click",fn:qd,options:{once:!0,passive:!1,capture:!0}}]);setTimeout(S)}$(),n.dispatch(Yo({reason:te}))}return{isActive:()=>tn({expected:"DRAGGING",phase:d,isLockActive:m,shouldWarn:!1}),shouldRespectForcePress:p,drop:te=>O("DROP",te),cancel:te=>O("CANCEL",te),...R.actions}}function w(R){const $=Tt(te=>{v(()=>Ko({client:te}))});return{...y({liftActionArgs:{id:o,clientSelection:R,movementMode:"FLUID"},cleanup:()=>$.cancel(),actions:{move:$}}),move:$}}function N(){const R={moveUp:()=>v(zl),moveRight:()=>v(Ul),moveDown:()=>v(Hl),moveLeft:()=>v(jl)};return y({liftActionArgs:{id:o,clientSelection:Vd(u),movementMode:"SNAP"},cleanup:Ke,actions:R})}function G(){tn({expected:"PRE_DRAG",phase:d,isLockActive:m,shouldWarn:!0})&&e.release()}return{isActive:()=>tn({expected:"PRE_DRAG",phase:d,isLockActive:m,shouldWarn:!1}),shouldRespectForcePress:p,fluidLift:w,snapLift:N,abort:G}}const Yd=[Nd,Pd,_d];function Xd({contextId:e,store:t,registry:n,customSensors:r,enableDefaultSensors:o}){const i=[...o?Yd:[],...r||[]],a=De(()=>pd())[0],s=E(function(y,w){Mt(y)&&!Mt(w)&&a.tryAbandon()},[a]);Pe(function(){let y=t.getState();return t.subscribe(()=>{const N=t.getState();s(y,N),y=N})},[a,t,s]),Pe(()=>a.tryAbandon,[a.tryAbandon]);const c=E(v=>hi({lockAPI:a,registry:n,store:t,draggableId:v}),[a,n,t]),u=E((v,y,w)=>Kd({lockAPI:a,registry:n,contextId:e,store:t,draggableId:v,forceSensorStop:y||null,sourceEvent:w&&w.sourceEvent?w.sourceEvent:null}),[e,a,n,t]),f=E(v=>Ud(e,v),[e]),d=E(v=>{const y=n.draggable.findById(v);return y?y.options:null},[n.draggable]),p=E(function(){a.isClaimed()&&(a.tryAbandon(),t.getState().phase!=="IDLE"&&t.dispatch(lr()))},[a,t]),m=E(()=>a.isClaimed(),[a]),b=k(()=>({canGetLock:c,tryGetLock:u,findClosestDraggableId:f,findOptionsForDraggable:d,tryReleaseLock:p,isLockClaimed:m}),[c,u,f,d,p,m]);kd(i);for(let v=0;v<i.length;v++)i[v](b)}const Jd=e=>({onBeforeCapture:t=>{ho(()=>{e.onBeforeCapture&&e.onBeforeCapture(t)})},onBeforeDragStart:e.onBeforeDragStart,onDragStart:e.onDragStart,onDragEnd:e.onDragEnd,onDragUpdate:e.onDragUpdate}),Zd=e=>({...Ft,...e.autoScrollerOptions,durationDampening:{...Ft.durationDampening,...e.autoScrollerOptions}});function Ot(e){return e.current||(process.env.NODE_ENV!=="production"?h(!1,"Could not find store from lazy ref"):h()),e.current}function Qd(e){const{contextId:t,setCallbacks:n,sensors:r,nonce:o,dragHandleUsageInstructions:i}=e,a=J(null);ud();const s=vr(e),c=E(()=>Jd(s.current),[s]),u=E(()=>Zd(s.current),[s]),f=nd(t),d=id({contextId:t,text:i}),p=Xc(t,o),m=E(S=>{Ot(a).dispatch(S)},[]),b=k(()=>Pr({publishWhileDragging:kl,updateDroppableScroll:Fl,updateDroppableIsEnabled:Vl,updateDroppableIsCombineEnabled:Ml,collectionStarting:Ll},m),[m]),v=Qc(),y=k(()=>Oc(v,b),[v,b]),w=k(()=>Uc({scrollWindow:Ac,scrollDroppable:y.scrollDroppable,getAutoScrollerOptions:u,...Pr({move:Ko},m)}),[y.scrollDroppable,m,u]),N=Jc(t),G=k(()=>Cc({announce:f,autoScroller:w,dimensionMarshal:y,focusMarshal:N,getResponders:c,styleMarshal:p}),[f,w,y,N,c,p]);process.env.NODE_ENV!=="production"&&a.current&&a.current!==G&&process.env.NODE_ENV!=="production"&&Z("unexpected store change"),a.current=G;const A=E(()=>{const S=Ot(a);S.getState().phase!=="IDLE"&&S.dispatch(lr())},[]),R=E(()=>{const S=Ot(a).getState();return S.phase==="DROP_ANIMATING"?!0:S.phase==="IDLE"?!1:S.isDragging},[]),$=k(()=>({isDragging:R,tryAbort:A}),[R,A]);n($);const O=E(S=>ri(Ot(a).getState(),S),[]),te=E(()=>dt(Ot(a).getState()),[]),I=k(()=>({marshal:y,focus:N,contextId:t,canLift:O,isMovementAllowed:te,dragHandleUsageInstructionsId:d,registry:v}),[t,y,d,N,O,te,v]);return Xd({contextId:t,store:G,registry:v,customSensors:r||null,enableDefaultSensors:e.enableDefaultSensors!==!1}),Ce(()=>A,[A]),ee.createElement(Dn.Provider,{value:I},ee.createElement(oa,{context:hr,store:G},e.children))}function eu(){return ee.useId()}function gi(e){const t=eu(),n=e.dragHandleUsageInstructions||rn.dragHandleUsageInstructions;return ee.createElement(ws,null,r=>ee.createElement(Qd,{nonce:e.nonce,contextId:t,setCallbacks:r,dragHandleUsageInstructions:n,enableDefaultSensors:e.enableDefaultSensors,sensors:e.sensors,onBeforeCapture:e.onBeforeCapture,onBeforeDragStart:e.onBeforeDragStart,onDragStart:e.onDragStart,onDragUpdate:e.onDragUpdate,onDragEnd:e.onDragEnd,autoScrollerOptions:e.autoScrollerOptions},e.children))}const ro={dragging:5e3,dropAnimating:4500},tu=(e,t)=>t?Rt.drop(t.duration):e?Rt.snap:Rt.fluid,nu=(e,t)=>{if(e)return t?Lt.opacity.drop:Lt.opacity.combining},ru=e=>e.forceShouldAnimate!=null?e.forceShouldAnimate:e.mode==="SNAP";function ou(e){const n=e.dimension.client,{offset:r,combineWith:o,dropping:i}=e,a=!!o,s=ru(e),c=!!i,u=c?Wn.drop(r,a):Wn.moveTo(r);return{position:"fixed",top:n.marginBox.top,left:n.marginBox.left,boxSizing:"border-box",width:n.borderBox.width,height:n.borderBox.height,transition:tu(s,i),transform:u,opacity:nu(a,c),zIndex:c?ro.dropAnimating:ro.dragging,pointerEvents:"none"}}function iu(e){return{transform:Wn.moveTo(e.offset),transition:e.shouldAnimateDisplacement?void 0:"none"}}function au(e){return e.type==="DRAGGING"?ou(e):iu(e)}function su(e,t,n=pe){const r=window.getComputedStyle(t),o=t.getBoundingClientRect(),i=Eo(o,r),a=sn(i,n),s={client:i,tagName:t.tagName.toLowerCase(),display:r.display},c={x:i.marginBox.width,y:i.marginBox.height};return{descriptor:e,placeholder:s,displaceBy:c,client:i,page:a}}function lu(e){const t=gr("draggable"),{descriptor:n,registry:r,getDraggableRef:o,canDragInteractiveElements:i,shouldRespectForcePress:a,isEnabled:s}=e,c=k(()=>({canDragInteractiveElements:i,shouldRespectForcePress:a,isEnabled:s}),[i,s,a]),u=E(m=>{const b=o();return b||(process.env.NODE_ENV!=="production"?h(!1,"Cannot get dimension when no ref is set"):h()),su(n,b,m)},[n,o]),f=k(()=>({uniqueId:t,descriptor:n,options:c,getDimension:u}),[n,u,c,t]),d=J(f),p=J(!0);Pe(()=>(r.draggable.register(d.current),()=>r.draggable.unregister(d.current)),[r.draggable]),Pe(()=>{if(p.current){p.current=!1;return}const m=d.current;d.current=f,r.draggable.update(f,m)},[f,r.draggable])}var Dr=ee.createContext(null);function bi(e){e&&jt(e)||(process.env.NODE_ENV!=="production"?h(!1,`
138
+ provided.innerRef has not been provided with a HTMLElement.
139
+
140
+ You can find a guide on using the innerRef callback functions at:
141
+ https://github.com/hello-pangea/dnd/blob/main/docs/guides/using-inner-ref.md
142
+ `):h())}function cu(e,t,n){qt(()=>{function r(i){return`Draggable[id: ${i}]: `}const o=e.draggableId;o||(process.env.NODE_ENV!=="production"?h(!1,"Draggable requires a draggableId"):h(!1)),typeof o!="string"&&(process.env.NODE_ENV!=="production"?h(!1,`Draggable requires a [string] draggableId.
143
+ Provided: [type: ${typeof o}] (value: ${o})`):h(!1)),Number.isInteger(e.index)||(process.env.NODE_ENV!=="production"?h(!1,`${r(o)} requires an integer index prop`):h(!1)),e.mapped.type!=="DRAGGING"&&(bi(n()),e.isEnabled&&(ci(t,o)||(process.env.NODE_ENV!=="production"?h(!1,`${r(o)} Unable to find drag handle`):h(!1))))})}function du(e){br(()=>{const t=J(e);qt(()=>{e!==t.current&&(process.env.NODE_ENV!=="production"?h(!1,"Draggable isClone prop value changed during component life"):h(!1))},[e])})}function dn(e){const t=uo(e);return t||(process.env.NODE_ENV!=="production"?h(!1,"Could not find required context"):h()),t}function uu(e){e.preventDefault()}const pu=e=>{const t=J(null),n=E(($=null)=>{t.current=$},[]),r=E(()=>t.current,[]),{contextId:o,dragHandleUsageInstructionsId:i,registry:a}=dn(Dn),{type:s,droppableId:c}=dn(Dr),u=k(()=>({id:e.draggableId,index:e.index,type:s,droppableId:c}),[e.draggableId,e.index,s,c]),{children:f,draggableId:d,isEnabled:p,shouldRespectForcePress:m,canDragInteractiveElements:b,isClone:v,mapped:y,dropAnimationFinished:w}=e;if(cu(e,o,r),du(v),!v){const $=k(()=>({descriptor:u,registry:a,getDraggableRef:r,canDragInteractiveElements:b,shouldRespectForcePress:m,isEnabled:p}),[u,a,r,b,m,p]);lu($)}const N=k(()=>p?{tabIndex:0,role:"button","aria-describedby":i,"data-rfd-drag-handle-draggable-id":d,"data-rfd-drag-handle-context-id":o,draggable:!1,onDragStart:uu}:null,[o,i,d,p]),G=E($=>{y.type==="DRAGGING"&&y.dropping&&$.propertyName==="transform"&&ho(w)},[w,y]),A=k(()=>{const $=au(y),O=y.type==="DRAGGING"&&y.dropping?G:void 0;return{innerRef:n,draggableProps:{"data-rfd-draggable-context-id":o,"data-rfd-draggable-id":d,style:$,onTransitionEnd:O},dragHandleProps:N}},[o,N,d,y,G,n]),R=k(()=>({draggableId:u.id,type:u.type,source:{index:u.index,droppableId:u.droppableId}}),[u.droppableId,u.id,u.index,u.type]);return ee.createElement(ee.Fragment,null,f(A,y.snapshot,R))};var vi=(e,t)=>e===t,yi=e=>{const{combine:t,destination:n}=e;return n?n.droppableId:t?t.droppableId:null};const fu=e=>e.combine?e.combine.draggableId:null,mu=e=>e.at&&e.at.type==="COMBINE"?e.at.combine.draggableId:null;function hu(){const e=ue((o,i)=>({x:o,y:i})),t=ue((o,i,a=null,s=null,c=null)=>({isDragging:!0,isClone:i,isDropAnimating:!!c,dropAnimation:c,mode:o,draggingOver:a,combineWith:s,combineTargetFor:null})),n=ue((o,i,a,s,c=null,u=null,f=null)=>({mapped:{type:"DRAGGING",dropping:null,draggingOver:c,combineWith:u,mode:i,offset:o,dimension:a,forceShouldAnimate:f,snapshot:t(i,s,c,u,null)}}));return(o,i)=>{if(Mt(o)){if(o.critical.draggable.id!==i.draggableId)return null;const a=o.current.client.offset,s=o.dimensions.draggables[i.draggableId],c=Ae(o.impact),u=mu(o.impact),f=o.forceShouldAnimate;return n(e(a.x,a.y),o.movementMode,s,i.isClone,c,u,f)}if(o.phase==="DROP_ANIMATING"){const a=o.completed;if(a.result.draggableId!==i.draggableId)return null;const s=i.isClone,c=o.dimensions.draggables[i.draggableId],u=a.result,f=u.mode,d=yi(u),p=fu(u),b={duration:o.dropDuration,curve:dr.drop,moveTo:o.newHomeClientOffset,opacity:p?Lt.opacity.drop:null,scale:p?Lt.scale.drop:null};return{mapped:{type:"DRAGGING",offset:o.newHomeClientOffset,dimension:c,dropping:b,draggingOver:d,combineWith:p,mode:f,forceShouldAnimate:null,snapshot:t(f,s,d,p,b)}}}return null}}function Di(e=null){return{isDragging:!1,isDropAnimating:!1,isClone:!1,dropAnimation:null,mode:null,draggingOver:null,combineTargetFor:e,combineWith:null}}const gu={mapped:{type:"SECONDARY",offset:pe,combineTargetFor:null,shouldAnimateDisplacement:!0,snapshot:Di(null)}};function bu(){const e=ue((a,s)=>({x:a,y:s})),t=ue(Di),n=ue((a,s=null,c)=>({mapped:{type:"SECONDARY",offset:a,combineTargetFor:s,shouldAnimateDisplacement:c,snapshot:t(s)}})),r=a=>a?n(pe,a,!0):null,o=(a,s,c,u)=>{const f=c.displaced.visible[a],d=!!(u.inVirtualList&&u.effected[a]),p=bn(c),m=p&&p.draggableId===a?s:null;if(!f){if(!d)return r(m);if(c.displaced.invisible[a])return null;const y=wt(u.displacedBy.point),w=e(y.x,y.y);return n(w,m,!0)}if(d)return r(m);const b=c.displacedBy.point,v=e(b.x,b.y);return n(v,m,f.shouldAnimate)};return(a,s)=>{if(Mt(a))return a.critical.draggable.id===s.draggableId?null:o(s.draggableId,a.critical.draggable.id,a.impact,a.afterCritical);if(a.phase==="DROP_ANIMATING"){const c=a.completed;return c.result.draggableId===s.draggableId?null:o(s.draggableId,c.result.draggableId,c.impact,c.afterCritical)}return null}}const vu=()=>{const e=hu(),t=bu();return(r,o)=>e(r,o)||t(r,o)||gu},yu={dropAnimationFinished:Xo},Du=go(vu,yu,null,{context:hr,areStatePropsEqual:vi})(pu);function xi(e){return dn(Dr).isUsingCloneFor===e.draggableId&&!e.isClone?null:ee.createElement(Du,e)}function xr(e){const t=typeof e.isDragDisabled=="boolean"?!e.isDragDisabled:!0,n=!!e.disableInteractiveElementBlocking,r=!!e.shouldRespectForcePress;return ee.createElement(xi,bo({},e,{isClone:!1,isEnabled:t,canDragInteractiveElements:n,shouldRespectForcePress:r}))}const Er=e=>t=>e===t,xu=Er("scroll"),Eu=Er("auto"),wu=Er("visible"),oo=(e,t)=>t(e.overflowX)||t(e.overflowY),Cu=(e,t)=>t(e.overflowX)&&t(e.overflowY),Ei=e=>{const t=window.getComputedStyle(e),n={overflowX:t.overflowX,overflowY:t.overflowY};return oo(n,xu)||oo(n,Eu)},Iu=()=>{if(process.env.NODE_ENV==="production")return!1;const e=Vt(),t=document.documentElement;if(t||(process.env.NODE_ENV,h()),!Ei(e))return!1;const n=window.getComputedStyle(t),r={overflowX:n.overflowX,overflowY:n.overflowY};return Cu(r,wu)||process.env.NODE_ENV!=="production"&&Z(`
144
+ We have detected that your <body> element might be a scroll container.
145
+ We have found no reliable way of detecting whether the <body> element is a scroll container.
146
+ Under most circumstances a <body> scroll bar will be on the <html> element (document.documentElement)
147
+
148
+ Because we cannot determine if the <body> is a scroll container, and generally it is not one,
149
+ we will be treating the <body> as *not* a scroll container
150
+
151
+ More information: https://github.com/hello-pangea/dnd/blob/main/docs/guides/how-we-detect-scroll-containers.md
152
+ `),!1},wr=e=>e==null?null:e===document.body?Iu()?e:null:e===document.documentElement?null:Ei(e)?e:wr(e.parentElement);var Nu=e=>{!e||!wr(e.parentElement)||process.env.NODE_ENV!=="production"&&Z(`
153
+ Droppable: unsupported nested scroll container detected.
154
+ A Droppable can only have one scroll parent (which can be itself)
155
+ Nested scroll containers are currently not supported.
156
+
157
+ We hope to support nested scroll containers soon: https://github.com/atlassian/react-beautiful-dnd/issues/131
158
+ `)},Un=e=>({x:e.scrollLeft,y:e.scrollTop});const wi=e=>e?window.getComputedStyle(e).position==="fixed"?!0:wi(e.parentElement):!1;var Su=e=>{const t=wr(e),n=wi(e);return{closestScrollable:t,isFixedOnPage:n}},Ou=({descriptor:e,isEnabled:t,isCombineEnabled:n,isFixedOnPage:r,direction:o,client:i,page:a,closest:s})=>{const c=(()=>{if(!s)return null;const{scrollSize:p,client:m}=s,b=ei({scrollHeight:p.scrollHeight,scrollWidth:p.scrollWidth,height:m.paddingBox.height,width:m.paddingBox.width});return{pageMarginBox:s.page.marginBox,frameClient:m,scrollSize:p,shouldClipSubject:s.shouldClipSubject,scroll:{initial:s.scroll,current:s.scroll,max:b,diff:{value:pe,displacement:pe}}}})(),u=o==="vertical"?rr:Bo,f=yt({page:a,withPlaceholder:null,axis:u,frame:c});return{descriptor:e,isCombineEnabled:n,isFixedOnPage:r,axis:u,isEnabled:t,client:i,page:a,frame:c,subject:f}};const Au=(e,t)=>{const n=wo(e);if(!t||e!==t)return n;const r=n.paddingBox.top-t.scrollTop,o=n.paddingBox.left-t.scrollLeft,i=r+t.scrollHeight,a=o+t.scrollWidth,c=Qn({top:r,right:a,bottom:i,left:o},n.border);return er({borderBox:c,margin:n.margin,border:n.border,padding:n.padding})};var Pu=({ref:e,descriptor:t,env:n,windowScroll:r,direction:o,isDropDisabled:i,isCombineEnabled:a,shouldClipSubject:s})=>{const c=n.closestScrollable,u=Au(e,c),f=sn(u,r),d=(()=>{if(!c)return null;const m=wo(c),b={scrollHeight:c.scrollHeight,scrollWidth:c.scrollWidth};return{client:m,page:sn(m,r),scroll:Un(c),scrollSize:b,shouldClipSubject:s}})();return Ou({descriptor:t,isEnabled:!i,isCombineEnabled:a,isFixedOnPage:n.isFixedOnPage,direction:o,client:u,page:f,closest:d})};const Ru={passive:!1},Tu={passive:!0};var io=e=>e.shouldPublishImmediately?Ru:Tu;const nn=e=>e&&e.env.closestScrollable||null;function Bu(e){const t=J(null),n=dn(Dn),r=gr("droppable"),{registry:o,marshal:i}=n,a=vr(e),s=k(()=>({id:e.droppableId,type:e.type,mode:e.mode}),[e.droppableId,e.mode,e.type]),c=J(s),u=k(()=>ue((A,R)=>{t.current||(process.env.NODE_ENV!=="production"?h(!1,"Can only update scroll when dragging"):h());const $={x:A,y:R};i.updateDroppableScroll(s.id,$)}),[s.id,i]),f=E(()=>{const A=t.current;return!A||!A.env.closestScrollable?pe:Un(A.env.closestScrollable)},[]),d=E(()=>{const A=f();u(A.x,A.y)},[f,u]),p=k(()=>Tt(d),[d]),m=E(()=>{const A=t.current,R=nn(A);if(A&&R||(process.env.NODE_ENV!=="production"?h(!1,"Could not find scroll options while scrolling"):h()),A.scrollOptions.shouldPublishImmediately){d();return}p()},[p,d]),b=E((A,R)=>{t.current&&(process.env.NODE_ENV!=="production"?h(!1,"Cannot collect a droppable while a drag is occurring"):h());const $=a.current,O=$.getDroppableRef();O||(process.env.NODE_ENV!=="production"?h(!1,"Cannot collect without a droppable ref"):h());const te=Su(O),I={ref:O,descriptor:s,env:te,scrollOptions:R};t.current=I;const S=Pu({ref:O,descriptor:s,env:te,windowScroll:A,direction:$.direction,isDropDisabled:$.isDropDisabled,isCombineEnabled:$.isCombineEnabled,shouldClipSubject:!$.ignoreContainerClipping}),ne=te.closestScrollable;return ne&&(ne.setAttribute(Zr.contextId,n.contextId),ne.addEventListener("scroll",m,io(I.scrollOptions)),process.env.NODE_ENV!=="production"&&Nu(ne)),S},[n.contextId,s,m,a]),v=E(()=>{const A=t.current,R=nn(A);return A&&R||(process.env.NODE_ENV!=="production"?h(!1,"Can only recollect Droppable client for Droppables that have a scroll container"):h()),Un(R)},[]),y=E(()=>{const A=t.current;A||(process.env.NODE_ENV!=="production"?h(!1,"Cannot stop drag when no active drag"):h());const R=nn(A);t.current=null,R&&(p.cancel(),R.removeAttribute(Zr.contextId),R.removeEventListener("scroll",m,io(A.scrollOptions)))},[m,p]),w=E(A=>{const R=t.current;R||(process.env.NODE_ENV!=="production"?h(!1,"Cannot scroll when there is no drag"):h());const $=nn(R);$||(process.env.NODE_ENV!=="production"?h(!1,"Cannot scroll a droppable with no closest scrollable"):h()),$.scrollTop+=A.y,$.scrollLeft+=A.x},[]),N=k(()=>({getDimensionAndWatchScroll:b,getScrollWhileDragging:v,dragStopped:y,scroll:w}),[y,b,v,w]),G=k(()=>({uniqueId:r,descriptor:s,callbacks:N}),[N,s,r]);Pe(()=>(c.current=G.descriptor,o.droppable.register(G),()=>{t.current&&(process.env.NODE_ENV!=="production"&&Z("Unsupported: changing the droppableId or type of a Droppable during a drag"),y()),o.droppable.unregister(G)}),[N,s,y,G,i,o.droppable]),Pe(()=>{t.current&&i.updateDroppableIsEnabled(c.current.id,!e.isDropDisabled)},[e.isDropDisabled,i]),Pe(()=>{t.current&&i.updateDroppableIsCombineEnabled(c.current.id,e.isCombineEnabled)},[e.isCombineEnabled,i])}function $n(){}const ao={width:0,height:0,margin:Ps},$u=({isAnimatingOpenOnMount:e,placeholder:t,animate:n})=>e||n==="close"?ao:{height:t.client.borderBox.height,width:t.client.borderBox.width,margin:t.client.margin},_u=({isAnimatingOpenOnMount:e,placeholder:t,animate:n})=>{const r=$u({isAnimatingOpenOnMount:e,placeholder:t,animate:n});return{display:t.display,boxSizing:"border-box",width:r.width,height:r.height,marginTop:r.margin.top,marginRight:r.margin.right,marginBottom:r.margin.bottom,marginLeft:r.margin.left,flexShrink:"0",flexGrow:"0",pointerEvents:"none",transition:n!=="none"?Rt.placeholder:null}},ku=e=>{const t=J(null),n=E(()=>{t.current&&(clearTimeout(t.current),t.current=null)},[]),{animate:r,onTransitionEnd:o,onClose:i,contextId:a}=e,[s,c]=De(e.animate==="open");Ce(()=>s?r!=="open"?(n(),c(!1),$n):t.current?$n:(t.current=setTimeout(()=>{t.current=null,c(!1)}),n):$n,[r,s,n]);const u=E(d=>{d.propertyName==="height"&&(o(),r==="close"&&i())},[r,i,o]),f=_u({isAnimatingOpenOnMount:s,animate:e.animate,placeholder:e.placeholder});return ee.createElement(e.placeholder.tagName,{style:f,"data-rfd-placeholder-context-id":a,onTransitionEnd:u,ref:e.innerRef})};var Lu=ee.memo(ku);function _n(e){return typeof e=="boolean"}function kn(e,t){t.forEach(n=>n(e))}const Fu=[function({props:t}){t.droppableId||(process.env.NODE_ENV!=="production"?h(!1,"A Droppable requires a droppableId prop"):h()),typeof t.droppableId!="string"&&(process.env.NODE_ENV!=="production"?h(!1,`A Droppable requires a [string] droppableId. Provided: [${typeof t.droppableId}]`):h())},function({props:t}){_n(t.isDropDisabled)||(process.env.NODE_ENV!=="production"?h(!1,"isDropDisabled must be a boolean"):h()),_n(t.isCombineEnabled)||(process.env.NODE_ENV!=="production"?h(!1,"isCombineEnabled must be a boolean"):h()),_n(t.ignoreContainerClipping)||(process.env.NODE_ENV!=="production"?h(!1,"ignoreContainerClipping must be a boolean"):h())},function({getDroppableRef:t}){bi(t())}],Vu=[function({props:t,getPlaceholderRef:n}){!t.placeholder||n()||process.env.NODE_ENV!=="production"&&Z(`
159
+ Droppable setup issue [droppableId: "${t.droppableId}"]:
160
+ DroppableProvided > placeholder could not be found.
161
+
162
+ Please be sure to add the {provided.placeholder} React Node as a child of your Droppable.
163
+ More information: https://github.com/hello-pangea/dnd/blob/main/docs/api/droppable.md
164
+ `)}],Mu=[function({props:t}){t.renderClone||(process.env.NODE_ENV!=="production"?h(!1,"Must provide a clone render function (renderClone) for virtual lists"):h())},function({getPlaceholderRef:t}){t()&&(process.env.NODE_ENV!=="production"?h(!1,"Expected virtual list to not have a placeholder"):h())}];function Gu(e){qt(()=>{kn(e,Fu),e.props.mode==="standard"&&kn(e,Vu),e.props.mode==="virtual"&&kn(e,Mu)})}class Wu extends ee.PureComponent{constructor(...t){super(...t),this.state={isVisible:!!this.props.on,data:this.props.on,animate:this.props.shouldAnimate&&this.props.on?"open":"none"},this.onClose=()=>{this.state.animate==="close"&&this.setState({isVisible:!1})}}static getDerivedStateFromProps(t,n){return t.shouldAnimate?t.on?{isVisible:!0,data:t.on,animate:"open"}:n.isVisible?{isVisible:!0,data:n.data,animate:"close"}:{isVisible:!1,animate:"close",data:null}:{isVisible:!!t.on,data:t.on,animate:"none"}}render(){if(!this.state.isVisible)return null;const t={onClose:this.onClose,data:this.state.data,animate:this.state.animate};return this.props.children(t)}}const zu=e=>{const t=uo(Dn);t||(process.env.NODE_ENV!=="production"?h(!1,"Could not find app context"):h());const{contextId:n,isMovementAllowed:r}=t,o=J(null),i=J(null),{children:a,droppableId:s,type:c,mode:u,direction:f,ignoreContainerClipping:d,isDropDisabled:p,isCombineEnabled:m,snapshot:b,useClone:v,updateViewportMaxScroll:y,getContainerForClone:w}=e,N=E(()=>o.current,[]),G=E((de=null)=>{o.current=de},[]),A=E(()=>i.current,[]),R=E((de=null)=>{i.current=de},[]);Gu({props:e,getDroppableRef:N,getPlaceholderRef:A});const $=E(()=>{r()&&y({maxScroll:ni()})},[r,y]);Bu({droppableId:s,type:c,mode:u,direction:f,isDropDisabled:p,isCombineEnabled:m,ignoreContainerClipping:d,getDroppableRef:N});const O=k(()=>ee.createElement(Wu,{on:e.placeholder,shouldAnimate:e.shouldAnimatePlaceholder},({onClose:de,data:st,animate:Ee})=>ee.createElement(Lu,{placeholder:st,onClose:de,innerRef:R,animate:Ee,contextId:n,onTransitionEnd:$})),[n,$,e.placeholder,e.shouldAnimatePlaceholder,R]),te=k(()=>({innerRef:G,placeholder:O,droppableProps:{"data-rfd-droppable-id":s,"data-rfd-droppable-context-id":n}}),[n,s,O,G]),I=v?v.dragging.draggableId:null,S=k(()=>({droppableId:s,type:c,isUsingCloneFor:I}),[s,I,c]);function ne(){if(!v)return null;const{dragging:de,render:st}=v,Ee=ee.createElement(xi,{draggableId:de.draggableId,index:de.source.index,isClone:!0,isEnabled:!0,shouldRespectForcePress:!1,canDragInteractiveElements:!0},(Ie,je)=>st(Ie,je,de));return ea.createPortal(Ee,w())}return ee.createElement(Dr.Provider,{value:S},a(te,b),ne())};function Hu(){return document.body||(process.env.NODE_ENV!=="production"?h(!1,"document.body is not ready"):h()),document.body}const so={mode:"standard",type:"DEFAULT",direction:"vertical",isDropDisabled:!1,isCombineEnabled:!1,ignoreContainerClipping:!1,renderClone:null,getContainerForClone:Hu},Ci=e=>{let t={...e},n;for(n in so)e[n]===void 0&&(t={...t,[n]:so[n]});return t},Ln=(e,t)=>e===t.droppable.type,lo=(e,t)=>t.draggables[e.draggable.id],Uu=()=>{const e={placeholder:null,shouldAnimatePlaceholder:!0,snapshot:{isDraggingOver:!1,draggingOverWith:null,draggingFromThisWith:null,isUsingPlaceholder:!1},useClone:null},t={...e,shouldAnimatePlaceholder:!1},n=ue(i=>({draggableId:i.id,type:i.type,source:{index:i.index,droppableId:i.droppableId}})),r=ue((i,a,s,c,u,f)=>{const d=u.descriptor.id;if(u.descriptor.droppableId===i){const b=f?{render:f,dragging:n(u.descriptor)}:null,v={isDraggingOver:s,draggingOverWith:s?d:null,draggingFromThisWith:d,isUsingPlaceholder:!0};return{placeholder:u.placeholder,shouldAnimatePlaceholder:!1,snapshot:v,useClone:b}}if(!a)return t;if(!c)return e;const m={isDraggingOver:s,draggingOverWith:d,draggingFromThisWith:null,isUsingPlaceholder:!0};return{placeholder:u.placeholder,shouldAnimatePlaceholder:!0,snapshot:m,useClone:null}});return(i,a)=>{const s=Ci(a),c=s.droppableId,u=s.type,f=!s.isDropDisabled,d=s.renderClone;if(Mt(i)){const p=i.critical;if(!Ln(u,p))return t;const m=lo(p,i.dimensions),b=Ae(i.impact)===c;return r(c,f,b,b,m,d)}if(i.phase==="DROP_ANIMATING"){const p=i.completed;if(!Ln(u,p.critical))return t;const m=lo(p.critical,i.dimensions);return r(c,f,yi(p.result)===c,Ae(p.impact)===c,m,d)}if(i.phase==="IDLE"&&i.completed&&!i.shouldFlush){const p=i.completed;if(!Ln(u,p.critical))return t;const m=Ae(p.impact)===c,b=!!(p.impact.at&&p.impact.at.type==="COMBINE"),v=p.critical.droppable.id===c;return m?b?e:t:v?e:t}return t}},ju={updateViewportMaxScroll:Wl},un=go(Uu,ju,(e,t,n)=>({...Ci(n),...e,...t}),{context:hr,areStatePropsEqual:vi})(zu),En=F.div`
165
+ overflow-block: auto;
166
+ border-radius: 12px;
167
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
168
+ background-color: #fff;
169
+ padding: 1.5rem;
170
+ `,tt=Et(Yn)(({theme:e,$hasOrigin:t})=>({display:"flex",alignItems:"flex-start",padding:e.spacing(2),marginBottom:e.spacing(1),gap:e.spacing(2),animation:"fadeIn 0.3s ease-in",borderLeft:t?`4px solid ${e.palette.info.main}`:void 0,backgroundColor:t?`${e.palette.info.light}22`:void 0,"@keyframes fadeIn":{from:{opacity:0,transform:"translateY(10px)"},to:{opacity:1,transform:"translateY(0)"}}})),nt=Et(L)(({theme:e})=>({fontWeight:"bold",fontSize:"1.2em",color:e.palette.primary.main,minWidth:30})),rt=Et(ge)({flexGrow:1}),ht=({path:e})=>D(L,{variant:"caption",color:"info.main",sx:{display:"block",fontFamily:"monospace"},children:["from ",e]}),ot=Et(L)(({statuscolor:e})=>({fontSize:"0.8em",marginTop:4,color:e||"#666",fontWeight:500})),it=Et(ge)({display:"flex",alignItems:"center",gap:4}),Ii=Et("img")(({theme:e})=>({border:`1px solid ${e.palette.divider}`,borderRadius:4,boxShadow:e.shadows[2],width:60,height:60,objectFit:"cover"})),Q=(e,t)=>{C.setState(n=>({...n,test:{...n.test,steps:n.test.steps.map(r=>r.id===e?{...r,...t}:r)}}))},qu=({step:e,stepNumber:t,onPlay:n,onPlayFromHere:r,onEdit:o,onDelete:i})=>D(tt,{elevation:1,children:[l(nt,{children:t}),D(rt,{children:[l(L,{variant:"body2",color:"text.secondary",fontFamily:"monospace",children:"📄 File Reference"}),l(L,{fontWeight:"bold",children:e.descriptionText||"Add steps from file"}),D(L,{variant:"body2",children:["Path: ",e.path]}),e.overrides&&Object.keys(e.overrides).length>0&&D(ge,{sx:{mt:.5,display:"flex",alignItems:"center",flexWrap:"wrap",gap:.5},children:[l(L,{variant:"caption",color:"text.secondary",children:"Overrides:"}),Object.keys(e.overrides).map(a=>l(Ge,{size:"small",label:`${a}`},a))]}),e.status&&l(ot,{statuscolor:e.statusColor,children:e.status}),l(xe,{control:l(Re,{size:"small",checked:e.optional??!1,onChange:(a,s)=>Q(e.id,{optional:s})}),label:"Optional"}),l(M,{size:"small",label:"File path (relative to tests)",value:e.path??"",onChange:a=>Q(e.id,{path:a.target.value}),fullWidth:!0,margin:"dense"})]}),D(it,{children:[r&&l(B,{onClick:r,size:"small","aria-label":"Play",children:l(Ze,{fontSize:"small"})}),r&&l(B,{onClick:r,size:"small","aria-label":"Play from here",children:l(Qe,{fontSize:"small"})}),o&&l(B,{onClick:o,size:"small","aria-label":"Edit",children:l(et,{fontSize:"small"})}),i&&l(B,{onClick:i,size:"small","aria-label":"Delete",children:l(Ue,{fontSize:"small"})})]})]}),Ku=({step:e,stepNumber:t,onPlay:n,onPlayFromHere:r,onEdit:o,onDelete:i})=>D(tt,{elevation:1,$hasOrigin:!!e.originRef,children:[l(nt,{children:t}),e.cropBase64&&l(Ii,{src:e.cropBase64,alt:"tap target"}),D(rt,{children:[e.originRef?.path&&l(ht,{path:e.originRef?.path}),D(L,{variant:"body2",color:"text.secondary",fontFamily:"monospace",children:["👆 X: ",Math.round(e.x),", Y: ",Math.round(e.y)]}),l(L,{fontWeight:"bold",children:e.descriptionText||"Tap Interaction"}),e.status&&l(ot,{statuscolor:e.statusColor,children:e.status}),l(xe,{control:l(Re,{size:"small",checked:e.optional??!1,onChange:(a,s)=>Q(e.id,{optional:s})}),label:"Optional"}),l(xe,{control:l(Re,{size:"small",checked:e.useLlmOnly??!1,onChange:(a,s)=>Q(e.id,{useLlmOnly:s})}),label:"LLM Only"}),l(M,{size:"small",label:"Element ID",value:e.elementId??"",onChange:a=>Q(e.id,{elementId:a.target.value}),fullWidth:!0,margin:"dense"}),l(M,{size:"small",label:"Timeout (ms)",type:"number",value:e.timeout??"",placeholder:"3000",onChange:a=>Q(e.id,{timeout:a.target.value?parseInt(a.target.value):void 0}),fullWidth:!0,margin:"dense"})]}),D(it,{children:[l(B,{size:"small",onClick:n,title:"Play this step",children:l(Ze,{})}),l(B,{size:"small",onClick:r,title:"Play from here",children:l(Qe,{})}),l(B,{size:"small",onClick:o,title:"Edit",children:l(et,{})}),l(B,{size:"small",onClick:i,title:"Delete",children:l(Ue,{})})]})]}),Yu=({step:e,stepNumber:t,onPlay:n,onPlayFromHere:r,onEdit:o,onDelete:i})=>D(tt,{elevation:1,$hasOrigin:!!e.originRef,children:[l(nt,{children:t}),e.cropBase64&&l(Ii,{src:e.cropBase64,alt:"assert target",sx:{border:2,borderColor:"warning.main"}}),D(rt,{children:[e.originRef?.path&&l(ht,{path:e.originRef?.path}),D(L,{variant:"body2",color:"text.secondary",fontFamily:"monospace",children:["👁️ X: ",Math.round(e.x),", Y: ",Math.round(e.y)]}),l(L,{fontWeight:"bold",children:e.descriptionText||"Assert Element"}),e.status&&l(ot,{statuscolor:e.statusColor,children:e.status}),l(xe,{control:l(Re,{size:"small",checked:e.optional??!1,onChange:(a,s)=>Q(e.id,{optional:s})}),label:"Optional"}),l(xe,{control:l(Re,{size:"small",checked:e.useLlmOnly??!1,onChange:(a,s)=>Q(e.id,{useLlmOnly:s})}),label:"LLM Only"}),l(M,{size:"small",label:"Element ID",value:e.elementId??"",onChange:a=>Q(e.id,{elementId:a.target.value}),fullWidth:!0,margin:"dense"}),l(M,{size:"small",label:"Timeout (ms)",type:"number",value:e.timeout??"",placeholder:"3000",onChange:a=>Q(e.id,{timeout:a.target.value?parseInt(a.target.value):void 0}),fullWidth:!0,margin:"dense"})]}),D(it,{children:[l(B,{size:"small",onClick:n,title:"Play this step",children:l(Ze,{})}),l(B,{size:"small",onClick:r,title:"Play from here",children:l(Qe,{})}),l(B,{size:"small",onClick:o,title:"Edit",children:l(et,{})}),l(B,{size:"small",onClick:i,title:"Delete",children:l(Ue,{})})]})]}),Xu=({step:e,stepNumber:t,onPlay:n,onPlayFromHere:r,onEdit:o,onDelete:i})=>D(tt,{elevation:1,$hasOrigin:!!e.originRef,children:[l(nt,{children:t}),l(Ge,{icon:l(ma,{}),label:"Type",color:"primary",variant:"outlined"}),D(rt,{children:[e.originRef?.path&&l(ht,{path:e.originRef?.path}),l(L,{fontWeight:"bold",children:e.descriptionText||`Type "${e.text}"`}),e.status&&l(ot,{statuscolor:e.statusColor,children:e.status}),l(M,{size:"small",label:"Text to type",value:e.text,onChange:a=>Q(e.id,{text:a.target.value,descriptionText:`Type "${a.target.value}"`}),fullWidth:!0,margin:"dense"}),l(xe,{control:l(Re,{size:"small",checked:e.optional??!1,onChange:(a,s)=>Q(e.id,{optional:s})}),label:"Optional"})]}),D(it,{children:[l(B,{size:"small",onClick:n,title:"Play this step",children:l(Ze,{})}),l(B,{size:"small",onClick:r,title:"Play from here",children:l(Qe,{})}),l(B,{size:"small",onClick:o,title:"Edit",children:l(et,{})}),l(B,{size:"small",onClick:i,title:"Delete",children:l(Ue,{})})]})]}),Ju=({step:e,stepNumber:t,onPlay:n,onPlayFromHere:r,onEdit:o,onDelete:i})=>D(tt,{elevation:1,$hasOrigin:!!e.originRef,children:[l(nt,{children:t}),l(Ge,{icon:l(ha,{}),label:"Scroll",color:"secondary",variant:"outlined"}),D(rt,{children:[e.originRef?.path&&l(ht,{path:e.originRef?.path}),l(L,{fontWeight:"bold",children:e.descriptionText||`Scroll ${e.direction}`}),e.status&&l(ot,{statuscolor:e.statusColor,children:e.status}),D(ge,{display:"flex",gap:1,mt:1,children:[l(Ge,{label:"↑ Up",size:"small",color:e.direction==="up"?"primary":"default",onClick:()=>Q(e.id,{direction:"up",descriptionText:"Scroll up"}),sx:{cursor:"pointer"}}),l(Ge,{label:"↓ Down",size:"small",color:e.direction==="down"?"primary":"default",onClick:()=>Q(e.id,{direction:"down",descriptionText:"Scroll down"}),sx:{cursor:"pointer"}})]}),l(xe,{control:l(Re,{size:"small",checked:e.optional??!1,onChange:(a,s)=>Q(e.id,{optional:s})}),label:"Optional",sx:{display:"block",mt:1}})]}),D(it,{children:[l(B,{size:"small",onClick:n,title:"Play this step",children:l(Ze,{})}),l(B,{size:"small",onClick:r,title:"Play from here",children:l(Qe,{})}),l(B,{size:"small",onClick:o,title:"Edit",children:l(et,{})}),l(B,{size:"small",onClick:i,title:"Delete",children:l(Ue,{})})]})]}),Zu=({step:e,stepNumber:t,onPlay:n,onPlayFromHere:r,onEdit:o,onDelete:i})=>D(tt,{elevation:1,$hasOrigin:!!e.originRef,children:[l(nt,{children:t}),l(Ge,{icon:l(ga,{}),label:"Scroll Until",color:"info",variant:"outlined"}),D(rt,{children:[e.originRef?.path&&l(ht,{path:e.originRef?.path}),l(L,{fontWeight:"bold",children:e.descriptionText||"Scroll Until Found"}),e.status&&l(ot,{statuscolor:e.statusColor,children:e.status}),l(M,{size:"small",label:"Find text",value:e.text??"",onChange:a=>Q(e.id,{text:a.target.value}),fullWidth:!0,margin:"dense"}),l(M,{size:"small",label:"Element ID",value:e.elementId??"",onChange:a=>Q(e.id,{elementId:a.target.value}),fullWidth:!0,margin:"dense"}),D(ge,{display:"flex",gap:1,mt:1,alignItems:"center",children:[l(Ge,{label:"↑ Up",size:"small",color:e.direction==="up"?"primary":"default",onClick:()=>Q(e.id,{direction:"up"}),sx:{cursor:"pointer"}}),l(Ge,{label:"↓ Down",size:"small",color:e.direction==="down"?"primary":"default",onClick:()=>Q(e.id,{direction:"down"}),sx:{cursor:"pointer"}}),l(M,{size:"small",label:"Max Scrolls",type:"number",value:e.maxScrolls,onChange:a=>Q(e.id,{maxScrolls:parseInt(a.target.value)||15}),sx:{width:120}})]}),l(xe,{control:l(Re,{size:"small",checked:e.optional??!1,onChange:(a,s)=>Q(e.id,{optional:s})}),label:"Optional",sx:{display:"block",mt:1}})]}),D(it,{children:[l(B,{size:"small",onClick:n,title:"Play this step",children:l(Ze,{})}),l(B,{size:"small",onClick:r,title:"Play from here",children:l(Qe,{})}),l(B,{size:"small",onClick:o,title:"Edit",children:l(et,{})}),l(B,{size:"small",onClick:i,title:"Delete",children:l(Ue,{})})]})]}),Qu=({step:e,stepNumber:t,onPlay:n,onPlayFromHere:r,onEdit:o,onDelete:i})=>D(tt,{elevation:1,$hasOrigin:!!e.originRef,children:[l(nt,{children:t}),l(Ge,{icon:l(ba,{}),label:"Deeplink",color:"success",variant:"outlined"}),D(rt,{children:[e.originRef?.path&&l(ht,{path:e.originRef?.path}),l(L,{fontWeight:"bold",children:e.descriptionText||"Open Deep Link"}),e.status&&l(ot,{statuscolor:e.statusColor,children:e.status}),l(M,{size:"small",label:"URL",value:e.url,onChange:a=>Q(e.id,{url:a.target.value,descriptionText:`Open Deep Link: ${a.target.value}`}),fullWidth:!0,margin:"dense",placeholder:"myapp://home"}),l(xe,{control:l(Re,{size:"small",checked:e.optional??!1,onChange:(a,s)=>Q(e.id,{optional:s})}),label:"Optional",sx:{display:"block"}})]}),D(it,{children:[l(B,{size:"small",onClick:n,title:"Play this step",children:l(Ze,{})}),l(B,{size:"small",onClick:r,title:"Play from here",children:l(Qe,{})}),l(B,{size:"small",onClick:o,title:"Edit",children:l(et,{})}),l(B,{size:"small",onClick:i,title:"Delete",children:l(Ue,{})})]})]}),ep=({step:e,stepNumber:t,onPlay:n,onPlayFromHere:r,onEdit:o,onDelete:i})=>D(tt,{elevation:1,$hasOrigin:!!e.originRef,children:[l(nt,{children:t}),l(Ge,{icon:l(va,{}),label:"AI",color:"secondary"}),D(rt,{children:[e.originRef?.path&&l(ht,{path:e.originRef?.path}),l(L,{fontWeight:"bold",children:e.descriptionText||"AI Instruction"}),e.status&&l(ot,{statuscolor:e.statusColor,children:e.status}),l(M,{size:"small",label:"Instruction",value:e.instruction,onChange:a=>Q(e.id,{instruction:a.target.value,descriptionText:`AI: ${a.target.value}`}),fullWidth:!0,margin:"dense",multiline:!0,rows:2}),l(xe,{control:l(Re,{size:"small",checked:e.optional??!1,onChange:(a,s)=>Q(e.id,{optional:s})}),label:"Optional",sx:{display:"block"}})]}),D(it,{children:[l(B,{size:"small",onClick:n,title:"Play this step",children:l(Ze,{})}),l(B,{size:"small",onClick:r,title:"Play from here",children:l(Qe,{})}),l(B,{size:"small",onClick:o,title:"Edit",children:l(et,{})}),l(B,{size:"small",onClick:i,title:"Delete",children:l(Ue,{})})]})]}),ie=e=>{const t="/_serverFn/"+e;return Object.assign(async(...n)=>(await ya(e))(...n),{url:t,functionId:e,[Da]:!0})},tp=ie("605c05774def700303f9889c0f8a28fed026e0b5c36a1563cff2835ee01d26b1"),np=oe({method:"POST"}).inputValidator(xa).handler(tp,async({data:e})=>(console.log(`Performing tap at ${e.x}, ${e.y}`),await Sa(e),{success:!0})),Ni=fe({mutationKey:["device","tap"],mutationFn:e=>np({data:e})}),rp=ie("07e23aa87e88d53c6c9e3d8e88de788d27d7b10930150bc4fd510d4447aaf3de"),op=oe({method:"POST"}).inputValidator(Ea).handler(rp,async({data:e})=>(console.log(`Performing type: "${e.text}"`),await Oa(e),{success:!0})),ip=fe({mutationKey:["device","type"],mutationFn:e=>op({data:e})}),ap=ie("5c526b678a7596f28beca76784df0ac58acd292627c5770c0c8029e38e4681ec"),sp=oe({method:"POST"}).inputValidator(wa).handler(ap,async({data:e})=>(console.log(`Performing scroll: ${e.direction}`),await yo(e),{success:!0})),lp=fe({mutationKey:["device","scroll"],mutationFn:e=>sp({data:e})}),cp=ie("2b4a002699960d578addbcf4dd83fedcec62444d7da4bf7c2359be991ed6207e"),dp=oe({method:"POST"}).inputValidator(Na).handler(cp,async({data:e})=>(console.log(`Performing swipe: ${e.x1},${e.y1} -> ${e.x2},${e.y2}`),await Ra(e),{success:!0}));fe({mutationKey:["device","swipe"],mutationFn:e=>dp({data:e})});const up=ie("10b616f4aacf11bb275166e4ae03f441f1d7c9a68a670dfadb03b74e1d012900"),pp=oe({method:"POST"}).inputValidator(Ca).handler(up,async({data:e})=>{console.log(`Performing scroll until: text="${e.text}", id="${e.elementId}", dir=${e.direction}`);for(let t=0;t<(e.maxScrolls??15);t++){console.log(`Scroll Until Loop: ${t+1}/${e.maxScrolls}`);const n=await Jn(),r=await Zn(n);let o=r.hierarchy?.node?.[0];const i=r.hierarchy?.node;if(i){const s=i.find(c=>c.$&&c.$.package!=="com.android.systemui");s&&(o=s)}let a=!1;if(e.elementId&&Do(o,e.elementId)&&(a=!0),!a&&e.text&&Ta(o,e.text)&&(a=!0),a)return console.log("Target found!"),{success:!0,scrolls:t};t<(e.maxScrolls??15)-1&&(await yo({direction:e.direction}),await new Promise(s=>setTimeout(s,1e3)))}return console.log("Target NOT found after max scrolls"),{success:!1}}),fp=fe({mutationKey:["device","scrollUntil"],mutationFn:e=>pp({data:e})}),mp=ie("566ee4344553ab6300f847f5de346e037f92d986cb824ba1c313346e62345fbe"),hp=oe({method:"POST"}).inputValidator(Ia).handler(mp,async({data:e})=>(console.log(`Performing deep link: "${e.url}"`),await Aa(e.url),{success:!0})),gp=fe({mutationKey:["device","deepLink"],mutationFn:e=>hp({data:e})}),bp=ie("eea1073a910f7f023004366aafcef05a8c47a3a1a4a09721f71a2efe311ee70f"),vp=oe({method:"POST"}).handler(bp,async e=>{const{platform:t="android",deviceId:n}=Xn.parse(e.data);return await Pa(t,n),{success:!0}}),yp=fe({mutationKey:["device","appium","start"],mutationFn:e=>vp({data:e})}),Dp=ie("6dbdc2968dc27a948c345034d1e55082b86918953b61da020ea8dd5836c79db3"),xp=oe({method:"GET"}).handler(Dp,async e=>{const{platform:t="android",deviceId:n}=Xn.parse(e.data),{isAppiumConnected:r}=await import("./appium-client-D-NjeB35.mjs");return{connected:r(t,n)}}),Ep=(e={})=>pn({queryKey:["device","appium","status",e],queryFn:()=>xp({data:e}),refetchInterval:2e3}),wp=ie("c5aeaa72b9b3303af5d82ee2fa59e3e90ffef3c3f0fb32707cee49e78ff41066"),Si=oe({method:"GET"}).handler(wp,async e=>{const t=Xn.parse(e.data),{platform:n="android",deviceId:r}=t,o=async()=>({success:!0,base64:`data:image/png;base64,${(await Fa(r)).toString("base64")}`,format:"base64",platform:"android",deviceId:r}),i=async()=>({success:!0,base64:`data:image/jpeg;base64,${(await Ga(r)).toString("base64")}`,format:"base64",platform:"ios",deviceId:r});try{return n==="android"?await o():await i()}catch(a){return console.error(`Screenshot failed for ${n} ${r||""}:`,a),{success:!1,error:a.message}}}),co=(e={})=>pn({queryKey:["device","screenshot",e],queryFn:()=>Si({data:e}),staleTime:0,gcTime:0}),Cp=fe({mutationKey:["device","screenshot_mutation"],mutationFn:e=>Si({data:e})}),Ip=ie("05faf0772038a170c70083fd8de4a8b77a40e4ec46e0bbf6878670f02621b5df"),Np=oe({method:"POST"}).inputValidator(za).handler(Ip,async({data:e})=>{console.log(`Getting element ID at ${e.x}, ${e.y}`);const t=await Jn(),n=(await Zn(t))?.hierarchy?.node?.[0];if(!n)return console.log("No root node found in hierarchy"),{elementId:""};const r=_a(n,e.x,e.y);if(!r)return console.log("No element found at coordinates"),{elementId:""};if(r.$&&r.$["resource-id"]?.trim()){let o=r.$["resource-id"];const i=ka(n,r,o);return i>=0?(o=`${o}[${i}]`,console.log(`Found duplicate IDs, using indexed ID: ${o}`)):console.log("Found unique element ID:",o),{elementId:o}}return console.log("Element found but has no resource-id"),{elementId:""}}),Sp=fe({mutationKey:["device","hierarchy","getElementId"],mutationFn:e=>Np({data:e})}),Op=ie("9bcbf5303827d2a25f347c2054b0121655a82322fa07108653f43246875348f7"),Ap=oe({method:"POST"}).inputValidator(Wa).handler(Op,async({data:e})=>{console.log(`Looking for element with ID: ${e.elementId}`);const t=await Jn(),n=(await Zn(t))?.hierarchy?.node?.[0];if(!n)return{found:!1};let r=e.elementId,o=null;const i=e.elementId.match(/^(.+)\[(\d+)\]$/);i&&(r=i[1],o=parseInt(i[2]),console.log(`Parsed indexed ID: base="${r}", index=${o}`));let a=null;if(o!==null){const s=Ba(n,r);o<s.length&&(a=s[o],console.log(`Found element at index ${o}`))}else a=Do(n,e.elementId);if(a){const s=$a(a);if(s)return console.log(`Found element at center: ${s.x}, ${s.y}`),{found:!0,x:s.x,y:s.y}}return console.log("Element not found or no bounds"),{found:!1}}),Pp=fe({mutationKey:["device","hierarchy","findElementById"],mutationFn:e=>Ap({data:e})}),Rp=ie("9f335634267a450fc9f34b1ab33c55da00cb1efc709604b2e3114602020075a2"),Tp=oe({method:"POST"}).handler(Rp,async()=>(console.log("Disabling Android animations..."),await Va(),{success:!0})),Bp=fe({mutationKey:["device","adb","disableAnimations"],mutationFn:()=>Tp()}),$p=ie("33557b2fcc5cedc5814d20bca9cd9cde2e45318755de1da4d613e8fa84ee38d1"),_p=oe({method:"GET"}).handler($p,async()=>{const[e,t]=await Promise.all([La(),Ma()]);return[...e,...t]}),Oi=pn({queryKey:["devices"],queryFn:()=>_p()}),Ai="https://cache.mobileboost.io";function Pi(){const e=Oe.join(process.cwd(),"mobileboost.config.json");if(!Br.existsSync(e))throw new Error("mobileboost.config.json not found");const t=Br.readFileSync(e,"utf-8");return JSON.parse(t)}function Ri(e,t,n,r,o,i){const a=i?`${i.width}x${i.height}`:"",s=`${e}${t||""}${n}${r}${o||""}${a}`;return Ha.createHash("sha256").update(s).digest("hex")}function kp(e){const t=atob(e.replace(/^data:image\/\w+;base64,/,"")),n=new ArrayBuffer(t.length),r=new Uint8Array(n);for(let o=0;o<t.length;o++)r[o]=t.charCodeAt(o);return new Blob([n],{type:"image/png"})}const Lp=ie("fcbe7e11d05240fa28a1dd79ec8c395f6c03682edbaeb19f469bd78d6399cdde"),Fp=oe({method:"POST"}).inputValidator(e=>qa.parse(e)).handler(Lp,async({data:e})=>{try{const t=Pi().apiKey;if(!t)throw new Error("API Key missing");const n=Ri(t,e.filepath,e.stepNumber,e.stepDescription,e.platform,e.screenResolution),r=e.screenshot.replace(/^data:image\/\w+;base64,/,""),o=`tap on x=${e.interactionCoordinates.x} y=${e.interactionCoordinates.y}`,i=[{screenshot:r,commands:[o]}],a=await fetch(`${Ai}/populate-cache?hash=${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});return a.ok?{success:!0}:(console.error("Failed to populate cache:",await a.text()),{success:!1})}catch(t){return console.error("Error populating cache:",t),{success:!1,error:String(t)}}}),Vp=ie("7d2aacaab26ab11cdc66f03a4ed01b8b38186abf16ab1f9306801ea7769aaa2a"),Mp=oe({method:"POST"}).inputValidator(e=>Ua.parse(e)).handler(Vp,async({data:e})=>{try{const t=Pi().apiKey;if(!t)throw new Error("API Key missing");const n=Ri(t,e.filepath,e.stepNumber,e.stepDescription,e.platform,e.screenResolution),r=new FormData;r.append("hash",n),r.append("screenshot",kp(e.screenshot),"screenshot.png"),e.highest_used_index!==void 0&&e.highest_used_index!==null&&r.append("highest_used_index",String(e.highest_used_index));const o=await fetch(`${Ai}/execute-from-cache`,{method:"POST",body:r});if(!o.ok){const s=await o.text();return console.warn("Cache lookup failed:",s),{found:!1}}const i=await o.json(),a=ja.safeParse(i);return a.success?a.data:(console.error("Invalid cache response:",i),{found:!1})}catch(t){return console.error("Error executing from cache:",t),{found:!1,error:String(t)}}}),Gp={mutationFn:e=>Mp({data:e})},Wp={mutationFn:e=>Fp({data:e})},zp=ie("5918013064f9b88efb265b30a770275d6c9d52bf42318f451bab8a47bc850917"),Hp=oe({method:"POST"}).inputValidator(Ka).handler(zp,async({data:e})=>await Ya(e)),Up=fe({mutationKey:["ai","executeAgentStep"],mutationFn:e=>Hp({data:e})});async function Kt(){const e=Oe.join(process.cwd(),"mobileboost.config.json");let t="./tests";if(await $e.pathExists(e))try{const n=await $e.readJSON(e);n.testDir&&(t=n.testDir)}catch(n){console.error("Error reading config, using default testDir",n)}return Oe.resolve(process.cwd(),t)}async function wn(e){const t=await Kt(),n=Oe.resolve(t,e);if(!n.startsWith(t))throw new Error("Invalid path: must be within test directory");return n}U.object({name:U.string(),type:U.enum(["file","directory"]),path:U.string()});const jp=ie("00fb1fe03e9689cf8c179ba0d5cadc5eeaa6879def224ac38037d70a1a51300d"),qp=oe({method:"GET"}).handler(jp,async()=>{const e=await Kt();await $e.ensureDir(e);async function t(n){let r=[];const o=await $e.readdir(n,{withFileTypes:!0});for(const i of o){const a=Oe.join(n,i.name),s=Oe.relative(e,a);i.isDirectory()?(r.push({name:i.name,type:"directory",path:s}),r=r.concat(await t(a))):r.push({name:i.name,type:"file",path:s})}return r}return{files:await t(e)}}),Cr=pn({queryKey:["files"],queryFn:()=>qp()}),Kp=U.object({name:U.string(),type:U.enum(["file","directory"]),parentPath:U.string().optional()}),Yp=ie("ac7bf7f1d727949cd28713a8f36bb77e7bd8fc0e48854ed8cb1ee93ce80fb6d0"),Xp=oe({method:"POST"}).inputValidator(Kp).handler(Yp,async({data:e})=>{const t=await Kt(),n=e.parentPath?Oe.join(t,e.parentPath):t;if(!Oe.resolve(n).startsWith(t))throw new Error("Invalid parent path");const r=Oe.join(n,e.name);if(e.type==="directory")await $e.ensureDir(r);else{if(await $e.pathExists(r))throw new Error("File already exists");await $e.writeJSON(r,[],{spaces:2})}return{success:!0}}),Jp=fe({mutationKey:["createFile"],mutationFn:e=>Xp({data:e})}),Zp=U.object({path:U.string()}),Qp=ie("b41e844ce533c224e7c720e69d821468deffcbf208fc008a7f5af83cb0596b15"),ef=oe({method:"POST"}).inputValidator(Zp).handler(Qp,async({data:e})=>{const t=await wn(e.path);try{return{content:await $e.readJSON(t),path:e.path}}catch(n){throw console.error("Failed to read file",n),new Error("Failed to read file or invalid format")}}),Ir=fe({mutationKey:["readFile"],mutationFn:e=>ef({data:e})}),tf=U.object({path:U.string(),content:fa}),nf=ie("1b2a0d276d9ce90b2a1d72134c1bf95b9f6b7b049a8f415e8f0da3e6fc5ce4ae"),rf=oe({method:"POST"}).inputValidator(tf).handler(nf,async({data:e})=>{const t=await wn(e.path);return await $e.writeJSON(t,e.content,{spaces:2}),{success:!0}}),of=fe({mutationKey:["saveFile"],mutationFn:e=>rf({data:e})}),af=U.object({oldPath:U.string(),newPath:U.string()}),sf=ie("098d52adf25ea567d43facba347871f887828c6ab804021bbfa0f2759209c0c6"),lf=oe({method:"POST"}).inputValidator(af).handler(sf,async({data:e})=>{const t=await wn(e.oldPath),n=await Kt(),r=Oe.resolve(n,e.newPath);if(!r.startsWith(n))throw new Error("Invalid new path");return await $e.rename(t,r),{success:!0}}),cf=fe({mutationKey:["renameFile"],mutationFn:e=>lf({data:e})}),df=U.object({sourcePath:U.string(),targetPath:U.string()}),uf=ie("efbbc22c41cf491631b07076417c9ec65d5ac71debfcc00b5a7e0d368772104f"),pf=oe({method:"POST"}).inputValidator(df).handler(uf,async({data:e})=>{const t=await wn(e.sourcePath),n=await Kt(),r=Oe.resolve(n,e.targetPath);if(!r.startsWith(n))throw new Error("Invalid target path");await $e.ensureDir(r);const o=Oe.basename(t),i=Oe.join(r,o);return await $e.move(t,i,{overwrite:!1}),{success:!0}});fe({mutationKey:["moveFile"],mutationFn:e=>pf({data:e})});const ff=/\{\{\s*([a-zA-Z0-9_.-]+)\s*\}\}/g,mf=e=>{if(!e)return[];const t=new Set;let n;const r=new RegExp(ff);for(;(n=r.exec(e))!==null;)n[1]&&t.add(n[1]);return Array.from(t)};U.number({invalid_type_error:"Must be a number"});const pt=U.number().min(0,"Must be 0 or greater"),hf=U.string().min(1,"This field is required");U.enum(["up","down","left","right"],{errorMap:()=>({message:"Invalid direction"})});const Ti=U.enum(["up","down"],{errorMap:()=>({message:"Invalid direction"})}),gf=U.string().min(1,"URL is required").regex(/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\/.+$/,"Invalid deeplink format (e.g., myapp://screen)"),be=e=>e?.length?e.map(t=>typeof t=="string"?t:t?.message).filter(Boolean).join(", "):null,bf=({step:e,onSave:t,onCancel:n})=>{const r=po(()=>({id:Date.now(),type:"tap",descriptionText:"",optional:!1,x:0,y:0,timeout:0,useLlmOnly:!1,text:"",elementId:"",maxScrolls:15,direction:"down",url:"",instruction:"",path:""}),[]),{data:o}=ut(Cr),i=new Set((o?.files||[]).filter(s=>s.type==="file").map(s=>s.path)),a=Za({defaultValues:e??r(),onSubmit:({value:s})=>{if(s.type==="fileRef"){const u=(s.path||"").trim();if(!u||o&&!i.has(u)){alert("The specified file does not exist in your tests directory.");return}}let c;switch(s.type){case"tap":c=pa.parse(s);break;case"assert":c=ua.parse(s);break;case"type":c=da.parse(s);break;case"scroll":c=ca.parse(s);break;case"scrollUntil":c=la.parse(s);break;case"deeplink":c=sa.parse(s);break;case"ai":c=aa.parse(s);break;case"fileRef":c=ia.parse(s);break;default:c=vo.parse(s)}if(!e)C.setState(u=>({...u,test:{...u.test,steps:[...u.test.steps,c]}}));else{const u=c.id;C.setState(f=>({...f,test:{...f.test,steps:f.test.steps.map(d=>d.id===u?c:d)}}))}t()}});return D(Sf,{elevation:2,children:[l(L,{variant:"h6",gutterBottom:!0,children:e?"Edit Step":"Add New Step"}),l("form",{onSubmit:s=>{s.preventDefault(),s.stopPropagation(),a.handleSubmit()},children:D(Of,{children:[l(a.Field,{name:"type",validators:{onChange:Tr},children:s=>{const c=s.state.meta.errors?.length>0;return D(fn,{fullWidth:!0,error:c,children:[l(mn,{id:"step-type",children:"Step type"}),l(hn,{labelId:"step-type",id:"step-type",value:s.state.value,label:"Step type",onChange:u=>{const f=u.target.value,d=a.state.values.id;a.reset(),a.setFieldValue("id",d),a.setFieldValue("type",f)},onBlur:s.handleBlur,children:Tr.options.map(u=>l(vt,{value:u,children:u},u))}),c&&l(Kn,{children:be(s.state.meta.errors)})]})}}),l(Gt,{sx:{mb:1}}),D(Af,{children:[l(We,{children:"General Settings"}),l(a.Field,{name:"descriptionText",validators:{onChange:U.string().optional()},children:s=>l(M,{id:"description-text",label:"Description",value:s.state.value??"",onChange:c=>s.handleChange(c.target.value),onBlur:s.handleBlur,placeholder:"Enter a description"})}),l(a.Field,{name:"optional",validators:{onChange:U.boolean().optional()},children:s=>l(xe,{control:l(Re,{checked:s.state.value??!1,onChange:c=>s.handleChange(c.target.checked)}),label:"Optional"})})]}),l(a.Subscribe,{selector:s=>s.values.type,children:s=>{switch(s){case"tap":return l(Df,{form:a});case"assert":return l(xf,{form:a});case"type":return l(Ef,{form:a});case"scroll":return l(wf,{form:a});case"scrollUntil":return l(Cf,{form:a});case"deeplink":return l(If,{form:a});case"ai":return l(Nf,{form:a});case"fileRef":return l(vf,{form:a});default:return null}}}),D(Pf,{children:[l(Me,{startIcon:l(Qa,{}),variant:"contained",type:"submit",children:"Save"}),l(Me,{startIcon:l(es,{}),variant:"outlined",color:"error",onClick:n,children:"Cancel"})]})]})})]})},vf=({form:e})=>{const{data:t,isLoading:n}=ut(Cr),r=new Set((t?.files||[]).filter(o=>o.type==="file").map(o=>o.path));return D(at,{children:[l(We,{children:"File Reference"}),l(e.Field,{name:"path",validators:{onChange:({value:o})=>{const i=String(o??"").trim();if(!i)return"This field is required";if(!n&&t&&!r.has(i))return"File not found in tests directory"}},children:o=>{const i=o.state.meta.errors?.length>0,a=i?be(o.state.meta.errors):n?"Checking files...":"Path is relative to your tests directory";return l(M,{id:"file-path",label:"File path",placeholder:"e.g., test2.json or subfolder/flow.json",value:o.state.value??"",onChange:s=>o.handleChange(s.target.value),onBlur:o.handleBlur,error:i,helperText:a,fullWidth:!0})}}),l(e.Subscribe,{selector:o=>({path:o.values.path,overrides:o.values.overrides}),children:({path:o,overrides:i})=>l(yf,{path:o,overrides:i,onChange:a=>e.setFieldValue("overrides",a),validPaths:r})})]})},yf=({path:e,overrides:t,onChange:n,validPaths:r})=>{const[o,i]=ee.useState(!1),[a,s]=ee.useState({}),c=le(Ir);ee.useEffect(()=>{let p=!1;return(async()=>{if(!e||!r.has(e)){s({});return}i(!0);try{const m=(await c.mutateAsync({path:e}))?.content;Array.isArray(m)?s({}):s(m&&typeof m=="object"?m.params||{}:{})}catch{s({})}finally{p||i(!1)}})(),()=>{p=!0}},[e]);const u=t||{},f=(p,m)=>{const b={...u};m?b[p]=m:delete b[p],n(b)},d=Object.keys(a);return e?D(ge,{sx:{mt:2},children:[l(L,{variant:"subtitle2",children:"Param overrides"}),o?l(L,{variant:"caption",color:"text.secondary",children:"Loading referenced test…"}):d.length===0?l(L,{variant:"caption",color:"text.secondary",children:"Referenced test has no params"}):l(ge,{sx:{display:"flex",flexDirection:"column",gap:1,mt:1},children:d.map(p=>D(ge,{sx:{display:"grid",gridTemplateColumns:"160px 1fr",gap:1,alignItems:"center"},children:[l(M,{size:"small",label:"Key",value:p,disabled:!0}),D(ge,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:1},children:[l(M,{size:"small",label:"Default",value:a[p]??"",disabled:!0}),l(M,{size:"small",label:"Override (optional)",value:u[p]??"",onChange:m=>f(p,m.target.value)})]})]},p))})]}):null},Df=({form:e})=>D(at,{children:[l(We,{children:"Tap Configuration"}),D($i,{children:[l(e.Field,{name:"x",validators:{onChange:pt},children:t=>{const n=t.state.meta.errors?.length>0;return l(M,{sx:{flex:1},type:"number",id:"x",label:"X",value:t.state.value??0,onChange:r=>t.handleChange(parseInt(r.target.value)||0),onBlur:t.handleBlur,placeholder:"X coordinate",error:n,helperText:be(t.state.meta.errors)})}}),l(e.Field,{name:"y",validators:{onChange:pt},children:t=>{const n=t.state.meta.errors?.length>0;return l(M,{sx:{flex:1},type:"number",id:"y",label:"Y",value:t.state.value??0,onChange:r=>t.handleChange(parseInt(r.target.value)||0),onBlur:t.handleBlur,placeholder:"Y coordinate",error:n,helperText:be(t.state.meta.errors)})}})]}),l(e.Field,{name:"timeout",validators:{onChange:pt},children:t=>{const n=t.state.meta.errors?.length>0;return l(M,{type:"number",id:"timeout",label:"Timeout (ms)",value:t.state.value??0,onChange:r=>t.handleChange(parseInt(r.target.value)||0),onBlur:t.handleBlur,placeholder:"Enter timeout",error:n,helperText:be(t.state.meta.errors)})}}),l(e.Field,{name:"useLlmOnly",validators:{onChange:U.boolean().optional()},children:t=>l(xe,{control:l(Re,{checked:t.state.value??!1,onChange:n=>t.handleChange(n.target.checked)}),label:"Use LLM only"})})]}),xf=({form:e})=>D(at,{children:[l(We,{children:"Assert Configuration"}),D($i,{children:[l(e.Field,{name:"x",validators:{onChange:pt},children:t=>{const n=t.state.meta.errors?.length>0;return l(M,{sx:{flex:1},type:"number",id:"x",label:"X",value:t.state.value??0,onChange:r=>t.handleChange(parseInt(r.target.value)||0),onBlur:t.handleBlur,placeholder:"X coordinate",error:n,helperText:be(t.state.meta.errors)})}}),l(e.Field,{name:"y",validators:{onChange:pt},children:t=>{const n=t.state.meta.errors?.length>0;return l(M,{sx:{flex:1},type:"number",id:"y",label:"Y",value:t.state.value??0,onChange:r=>t.handleChange(parseInt(r.target.value)||0),onBlur:t.handleBlur,placeholder:"Y coordinate",error:n,helperText:be(t.state.meta.errors)})}})]}),l(e.Field,{name:"timeout",validators:{onChange:pt},children:t=>{const n=t.state.meta.errors?.length>0;return l(M,{type:"number",id:"timeout",label:"Timeout (ms)",value:t.state.value??0,onChange:r=>t.handleChange(parseInt(r.target.value)||0),onBlur:t.handleBlur,placeholder:"Enter timeout",error:n,helperText:be(t.state.meta.errors)})}}),l(e.Field,{name:"useLlmOnly",validators:{onChange:U.boolean().optional()},children:t=>l(xe,{control:l(Re,{checked:t.state.value??!1,onChange:n=>t.handleChange(n.target.checked)}),label:"Use LLM only"})})]}),Ef=({form:e})=>D(at,{children:[l(We,{children:"Type Configuration"}),l(e.Field,{name:"text",validators:{onChange:({value:t})=>{const n=String(t??"");if(!n||n.trim().length===0)return"This field is required";const r=mf(n);if(r.length===0)return;const o=C.state.test.params||{},i=r.filter(a=>!Object.prototype.hasOwnProperty.call(o,a));if(i.length>0)return`Undefined params: ${i.join(", ")}`}},children:t=>{const n=t.state.meta.errors?.length>0;return l(M,{id:"text",label:"Text to type",value:t.state.value??"",onChange:r=>t.handleChange(r.target.value),onBlur:t.handleBlur,placeholder:"Enter text to type (you can use {{param}})",multiline:!0,rows:3,error:n,helperText:be(t.state.meta.errors)??"Use {{key}} to insert a param value"})}})]}),wf=({form:e})=>D(at,{children:[l(We,{children:"Scroll Configuration"}),l(e.Field,{name:"direction",validators:{onChange:Ti},children:t=>{const n=t.state.meta.errors?.length>0;return D(fn,{fullWidth:!0,error:n,children:[l(mn,{id:"scroll-direction",children:"Direction"}),D(hn,{labelId:"scroll-direction",id:"scroll-direction",value:t.state.value??"down",label:"Direction",onChange:r=>t.handleChange(r.target.value),onBlur:t.handleBlur,children:[l(vt,{value:"up",children:"Up"}),l(vt,{value:"down",children:"Down"})]}),n&&l(Kn,{children:be(t.state.meta.errors)})]})}})]}),Cf=({form:e})=>D(at,{children:[l(We,{children:"Scroll Until Configuration"}),l(e.Field,{name:"direction",validators:{onChange:Ti},children:t=>{const n=t.state.meta.errors?.length>0;return D(fn,{fullWidth:!0,error:n,children:[l(mn,{id:"scroll-until-direction",children:"Direction"}),D(hn,{labelId:"scroll-until-direction",id:"scroll-until-direction",value:t.state.value??"down",label:"Direction",onChange:r=>t.handleChange(r.target.value),onBlur:t.handleBlur,children:[l(vt,{value:"up",children:"Up"}),l(vt,{value:"down",children:"Down"})]}),n&&l(Kn,{children:be(t.state.meta.errors)})]})}}),l(e.Field,{name:"maxScrolls",validators:{onChange:pt},children:t=>{const n=t.state.meta.errors?.length>0;return l(M,{type:"number",id:"max-scrolls",label:"Max Scrolls",value:t.state.value??15,onChange:r=>t.handleChange(parseInt(r.target.value)||15),onBlur:t.handleBlur,placeholder:"Maximum scroll attempts",error:n,helperText:be(t.state.meta.errors)??"Maximum number of scroll attempts (default: 15)"})}}),l(We,{sx:{mt:1},children:"Stop Condition (at least one)"}),l(e.Field,{name:"text",validators:{onChange:U.string().optional()},children:t=>{const n=t.state.meta.errors?.length>0;return l(M,{id:"scroll-until-text",label:"Text to find",value:t.state.value??"",onChange:r=>t.handleChange(r.target.value),onBlur:t.handleBlur,placeholder:"Text content to scroll until visible",error:n,helperText:be(t.state.meta.errors)??"Scroll until this text is visible on screen"})}}),l(e.Field,{name:"elementId",validators:{onChange:U.string().optional()},children:t=>{const n=t.state.meta.errors?.length>0;return l(M,{id:"scroll-until-element-id",label:"Element ID",value:t.state.value??"",onChange:r=>t.handleChange(r.target.value),onBlur:t.handleBlur,placeholder:"Element ID to scroll until visible",error:n,helperText:be(t.state.meta.errors)??"Scroll until element with this ID is visible"})}})]}),If=({form:e})=>D(at,{children:[l(We,{children:"Deeplink Configuration"}),l(e.Field,{name:"url",validators:{onChange:gf},children:t=>{const n=t.state.meta.errors?.length>0;return l(M,{id:"url",label:"URL",value:t.state.value??"",onChange:r=>t.handleChange(r.target.value),onBlur:t.handleBlur,placeholder:"Enter deeplink URL (e.g., myapp://screen)",fullWidth:!0,error:n,helperText:be(t.state.meta.errors)})}})]}),Nf=({form:e})=>D(at,{children:[l(We,{children:"AI Configuration"}),l(e.Field,{name:"instruction",validators:{onChange:hf},children:t=>{const n=t.state.meta.errors?.length>0;return l(M,{id:"instruction",label:"AI Instruction",value:t.state.value??"",onChange:r=>t.handleChange(r.target.value),onBlur:t.handleBlur,placeholder:"Enter instruction for AI to execute",multiline:!0,rows:4,error:n,helperText:be(t.state.meta.errors)})}})]}),Sf=Je(Yn)`
171
+ padding: 1.5rem;
172
+ margin-bottom: 1.5rem;
173
+ border: 1px solid #e0e0e0;
174
+ border-radius: 8px;
175
+ `,Of=Je(ge)`
176
+ display: flex;
177
+ flex-direction: column;
178
+ gap: 1.25rem;
179
+ `,Bi=Je(ge)`
180
+ display: flex;
181
+ flex-direction: column;
182
+ gap: 1rem;
183
+ padding: 1rem;
184
+ border-radius: 6px;
185
+ `,Af=Je(Bi)`
186
+ background-color: #fafafa;
187
+ border: 1px solid #e0e0e0;
188
+ `,at=Je(Bi)`
189
+ background-color: #f5f5f5;
190
+ border: 1px dashed #bdbdbd;
191
+ `,We=Je(L)`
192
+ font-size: 0.75rem;
193
+ color: #757575;
194
+ text-transform: uppercase;
195
+ letter-spacing: 0.5px;
196
+ margin-bottom: 0.5rem;
197
+ `,$i=Je(ge)`
198
+ display: flex;
199
+ gap: 1rem;
200
+ & > * {
201
+ flex: 1;
202
+ min-width: 120px;
203
+ }
204
+ `,Pf=Je(ge)`
205
+ display: flex;
206
+ gap: 0.5rem;
207
+ justify-content: center;
208
+ `,_i=48,Rf=()=>{const[e,t]=De(!1),[n,r]=De(!1),o=we(C,s=>s.executionLog),i=we(C,s=>s.isPlaying);if(o.length===0&&!i)return null;const a=()=>{r(!n)};return D(Tf,{$isMaximized:n,children:[D(Bf,{onClick:a,children:[D(L,{variant:"subtitle2",children:["Execution Log (",o.length," steps)"]}),l(B,{size:"small",onClick:s=>{s.stopPropagation(),a()},children:n?l(ns,{}):l(ts,{})})]}),n&&l($f,{children:l(_f,{children:o.map(s=>D(kf,{children:[l(Lf,{src:s.screenshot,alt:`Step ${s.stepNumber}`}),D(Ff,{children:[D(Vf,{children:["#",s.stepNumber]}),l(Mf,{children:s.cacheHit?l(on,{title:"Cache Hit",children:l(rs,{color:"success",fontSize:"small"})}):l(on,{title:"Cache Miss / Fresh Execution",children:l(os,{color:"info",fontSize:"small"})})})]})]},s.stepId))})})]})},Tf=F(Yn)`
209
+ position: fixed;
210
+ bottom: 0;
211
+ left: 0;
212
+ right: 0;
213
+ z-index: 1300; // High z-index to be on top of everything
214
+ border-top-left-radius: 8px;
215
+ border-top-right-radius: 8px;
216
+ overflow: hidden;
217
+ transition: height 0.3s ease;
218
+ height: ${({$isMaximized:e})=>e?"400px":`${_i}px`};
219
+ display: flex;
220
+ flex-direction: column;
221
+ background-color: ${({theme:e})=>e.palette?.background?.paper||"#fff"};
222
+ box-shadow: 0px -2px 10px rgba(0,0,0,0.1);
223
+ `,Bf=F.div`
224
+ height: ${_i}px;
225
+ padding: 0 16px;
226
+ display: flex;
227
+ align-items: center;
228
+ justify-content: space-between;
229
+ cursor: pointer;
230
+ background-color: rgba(0, 0, 0, 0.05);
231
+ &:hover {
232
+ background-color: rgba(0, 0, 0, 0.08);
233
+ }
234
+ flex-shrink: 0;
235
+ `,$f=F.div`
236
+ flex: 1;
237
+ overflow-x: auto;
238
+ overflow-y: hidden;
239
+ padding: 16px;
240
+ background-color: rgba(0,0,0,0.02);
241
+ `,_f=F.div`
242
+ display: flex;
243
+ gap: 16px;
244
+ height: 100%;
245
+ align-items: center;
246
+ `,kf=F.div`
247
+ position: relative;
248
+ height: 100%;
249
+ aspect-ratio: 9/16; // Assumes mobile portrait roughly, will adjust to image
250
+ border-radius: 8px;
251
+ overflow: hidden;
252
+ box-shadow: 0 4px 6px rgba(0,0,0,0.1);
253
+ background: #000;
254
+ flex-shrink: 0;
255
+ `,Lf=F.img`
256
+ width: 100%;
257
+ height: 100%;
258
+ object-fit: contain;
259
+ `,Ff=F.div`
260
+ position: absolute;
261
+ top: 0;
262
+ left: 0;
263
+ right: 0;
264
+ padding: 4px 8px;
265
+ display: flex;
266
+ justify-content: space-between;
267
+ align-items: start;
268
+ background: linear-gradient(to bottom, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0) 100%);
269
+ `,Vf=F.span`
270
+ color: white;
271
+ font-weight: bold;
272
+ font-size: 14px;
273
+ text-shadow: 0 1px 2px rgba(0,0,0,0.8);
274
+ `,Mf=F.div`
275
+ display: flex;
276
+ align-items: center;
277
+ justify-content: center;
278
+ background: rgba(255,255,255,0.9);
279
+ border-radius: 50%;
280
+ padding: 2px;
281
+ `,Yt=new Qi({open:!1,maintainDisplayed:!1});function Gf(){Yt.setState(e=>({...e,open:!1}))}function ki(e,t){Yt.setState({type:"success",title:t?.title??"Success",description:e,listContent:t?.listContent,open:!0,maintainDisplayed:t?.maintainDisplayed??!1})}function jn(e,t){Yt.setState({type:"error",title:t?.title??"Error",description:e,listContent:t?.listContent,open:!0,maintainDisplayed:t?.maintainDisplayed??!1})}function Wf(e,t){Yt.setState({type:"info",title:t?.title,description:e,listContent:t?.listContent,open:!0,maintainDisplayed:t?.maintainDisplayed??!1})}const zf=/\{\{\s*([a-zA-Z0-9_.-]+)\s*\}\}/g;function Hf(e,t){const n=new Set;return{value:e.replace(zf,(r,o)=>Object.prototype.hasOwnProperty.call(t,o)?t[o]??"":(n.add(o),"")),missing:Array.from(n)}}function At(e,t){const n={...e},r={},o=i=>{const a=n[i];if(typeof a=="string"&&a.includes("{{")){const{value:s,missing:c}=Hf(a,t);n[i]=s,c.length&&(r[i]=c)}};return o("descriptionText"),o("text"),o("url"),o("instruction"),{step:n,missingMap:r}}const Uf=({step:e,index:t,onPlay:n,onPlayFromHere:r,onEdit:o,onDelete:i})=>{const a={stepNumber:t+1,onPlay:n,onPlayFromHere:r,onEdit:o,onDelete:i};switch(e.type){case"tap":return l(Ku,{step:e,...a});case"assert":return l(Yu,{step:e,...a});case"type":return l(Xu,{step:e,...a});case"scroll":return l(Ju,{step:e,...a});case"scrollUntil":return l(Zu,{step:e,...a});case"deeplink":return l(Qu,{step:e,...a});case"ai":return l(ep,{step:e,...a});case"fileRef":return l(qu,{step:e,...a});default:return null}},jf=({onSave:e,canSave:t})=>{const[n,r]=De(!1),[o,i]=De(void 0),a=we(C,g=>g.isRecording),s=we(C,g=>g.test.steps),c=we(C,g=>g.isPlaying),u=we(C,g=>g.selectedPlatform),f=we(C,g=>g.selectedDeviceId),{data:d=[]}=ut(Oi),p=J(null),m=le(Ni),b=le(ip),v=le(lp),y=le(fp),w=le(gp),N=le(Pp),G=le(Cp),A=le(Gp),R=le(Up),$=le(Ir),O=(g,x,P)=>{C.setState(V=>({...V,test:{...V.test,steps:V.test.steps.map(X=>X.id===g?{...X,status:x,statusColor:P}:X)}}))},te=g=>{C.setState(x=>({...x,currentStepId:g}))},I=g=>new Promise(x=>setTimeout(x,g)),S=async()=>{try{const g=await G.mutateAsync({platform:u,deviceId:f});if(!g.success||!g.base64)throw new Error(g.error||"Failed to capture screenshot");return g.base64}catch(g){throw console.error("Screenshot failed:",g),g}},ne=g=>new Promise(x=>{const P=new Image;P.onload=()=>x({width:P.naturalWidth,height:P.naturalHeight}),P.src=g}),de=async(g,x,P,V=[])=>{O(g,"Starting AI Agent Loop...","purple");try{let X=0;const me=5;let z=[...V];for(;X<me;){if(p.current?.signal.aborted)throw new Error("Aborted");const q=await S();C.setState(W=>({...W,executionLog:[...W.executionLog,{stepId:g,stepNumber:x,screenshot:q,cacheHit:!1,timestamp:Date.now()}]})),O(g,`AI Agent Thinking (${X+1})...`,"purple");const H=await R.mutateAsync({base64_screenshot:q.replace(/^data:image\/\w+;base64,/,""),instruction:P,action_history:z});console.log("Agent Response:",H);const ve=H;ve.actionHistory&&(z=ve.actionHistory);const T=ve.gptCommands||[],K=ve.appetizeCommands||[],Y=T.findIndex(W=>W.startsWith("reasoning:"));if(Y!==-1){const W=T.slice(Y),re=W.filter(_=>_.startsWith("remember:"));re.length>0&&V.push(...re),z=[...z,...W]}const ae=T.some(W=>W.toLowerCase().includes("task complete:")),Ne=T.find(W=>W.toLowerCase().includes("error detected:"));if(Ne)throw new Error(`AI reported error: ${Ne}`);if(ae)return O(g,"AI Task Completed","green"),!0;let se=!1;if(K.length>0){for(const W of K){if(p.current?.signal.aborted)throw new Error("Aborted");if(W.match(/^t(ap|ab)On:/)){let re,_;const Ve=W.match(/x=(\d+)/),ze=W.match(/y=(\d+)/);if(Ve&&ze)re=parseInt(Ve[1],10),_=parseInt(ze[1],10);else{const lt=W.split(";");if(lt.length>=3){const He=parseInt(lt[1],10),Qt=parseInt(lt[2],10);!isNaN(He)&&!isNaN(Qt)&&(re=He,_=Qt)}}re!==void 0&&_!==void 0&&(O(g,`Exec: Tap ${re},${_}`,"blue"),await m.mutateAsync({x:re,y:_,platform:u,deviceId:f}),se=!0)}else if(W.startsWith("wait:")){const re=W.match(/wait:\s*(\d+)/);if(re){const _=parseInt(re[1],10);O(g,`Exec: Wait ${_}s`,"blue"),await I(_*1e3),se=!0}}else if(W.startsWith("scroll:")){const re=W.match(/scroll:\s*(up|down)/i);if(re){const _=re[1].toLowerCase();O(g,`Exec: Scroll ${_}`,"blue"),await v.mutateAsync({direction:_,platform:u,deviceId:f}),se=!0}}}await I(3e3)}!se&&!ae&&(O(g,"AI Thinking...","blue"),await I(2e3)),X++}throw new Error("AI Agent loop timeout")}catch(X){throw X}},st=async(g,x,P,V=[])=>{if(P.aborted)return!1;te(g.id),O(g.id,"Executing...","blue");const X={platform:u,deviceId:f},me=Date.now();try{let z,q=!1;const H=()=>C.state.currentScreenshot||void 0;switch(g.type){case"tap":{let T=g.x,K=g.y;const Y=`mobileboost_step_${g.id}_${g.type}`;let ae=!1;const Ne=Date.now(),se=g.timeout??3e3;if(g.cropBase64){console.log(`[Step ${g.id}] Cache check start`);let _;for(;Date.now()-Ne<se;){if(P.aborted)return!1;const Ve=Date.now(),ze=await S();z||(z=ze);const lt=Date.now()-Ve;console.log(`[Step ${g.id}] Screenshot captured in ${lt}ms`);try{const He=Date.now(),{width:Qt,height:Fi}=await ne(ze),It=await A.mutateAsync({stepNumber:x,stepDescription:g.descriptionText||g.type,filepath:void 0,screenshot:ze,platform:u,screenResolution:{width:Qt,height:Fi},highest_used_index:_}),Vi=Date.now()-He;if(console.log(`[Step ${g.id}] Cache endpoint responded in ${Vi}ms`),It.found&&It.interactionCoordinates){T=It.interactionCoordinates.x,K=It.interactionCoordinates.y,ae=!0,q=!0,_=It.cacheIndex;const Mi=Date.now()-Ne;console.log(`[Step ${g.id}] Cache Hit! Total cache loop duration: ${Mi}ms`),O(g.id,`Cache Hit! Executing at ${T},${K}`,"green");break}}catch(He){console.warn("Cache check failed:",He)}await I(500)}}if(ae||z||(z=H()),!ae){const _=Date.now()-Ne;console.log(`[Step ${g.id}] Cache Miss. Duration: ${_}ms`)}if(!ae&&g.cropBase64){if(console.log("Cache miss"),g.descriptionText){O(g.id,"Cache miss, trying AI fallback...","orange");try{return await de(g.id,x,g.descriptionText,V),!0}catch(_){throw new Error(`Cache miss and AI failed: ${_.message}`)}}}else if(g.elementId){O(g.id,"Finding element...","blue");try{const _=await N.mutateAsync({elementId:g.elementId,...X});_.found&&(T=_.x,K=_.y,O(g.id,"Element found, tapping...","blue"))}catch{console.log("Element ID not found, using original coordinates")}}const W=Date.now();await m.mutateAsync({x:T,y:K,screenWidth:g.screenWidth,screenHeight:g.screenHeight,...X});const re=Date.now()-W;console.log(`[Step ${g.id}] Tap executed in ${re}ms`),O(g.id,"Tapped","green");break}case"assert":{if(g.cropBase64){let T=!1,K;const Y=g.timeout??3e3,ae=Date.now(),Ne=`mobileboost_step_${g.id}_${g.type}`;for(;Date.now()-ae<Y;){if(P.aborted)return!1;const se=await S();z||(z=se);try{const{width:W,height:re}=await ne(se),_=await A.mutateAsync({stepNumber:x,stepDescription:g.descriptionText||g.type,filepath:void 0,screenshot:se,platform:u,screenResolution:{width:W,height:re},highest_used_index:K});if(_.found){T=!0,q=!0,K=_.cacheIndex;break}}catch(W){console.warn("Assert cache check failed:",W)}await I(500)}if(T)O(g.id,"Assertion passed (Cache Match)","green");else if(g.descriptionText)await de(g.id,x,`Verify that: ${g.descriptionText}`,V),O(g.id,"Assertion passed (AI)","green");else throw new Error("Assertion failed: Image not found")}if(!z)z=H();else if(g.elementId)if(O(g.id,"Checking element...","blue"),(await N.mutateAsync({elementId:g.elementId,...X})).found)O(g.id,"Assertion passed","green");else throw new Error("Element not found");else O(g.id,"Assertion passed (No conditions)","green");break}case"type":{z=H();const T=C.state.test.params||{},{step:K,missingMap:Y}=At(g,T);if(Object.keys(Y).length){const ae=Object.entries(Y).map(([Ne,se])=>`${Ne}: ${se.join(", ")}`).join("; ");throw new Error(`Missing params for placeholders -> ${ae}`)}await b.mutateAsync({text:K.text,...X}),O(g.id,"Typed","green");break}case"scroll":{z=H(),await v.mutateAsync({direction:g.direction,...X}),O(g.id,"Scrolled","green");break}case"scrollUntil":{z=H();const T=C.state.test.params||{},{step:K,missingMap:Y}=At(g,T);if(Y.text?.length)throw new Error(`Missing params for placeholders -> text: ${Y.text.join(", ")}`);O(g.id,"Scrolling until found...","blue");const ae=await y.mutateAsync({text:K.text,elementId:K.elementId,direction:K.direction,maxScrolls:K.maxScrolls,...X});if(ae.success)O(g.id,`Found after ${ae.scrolls??0} scrolls`,"green");else throw new Error("Target not found after scrolling");break}case"deeplink":{z=H();const T=C.state.test.params||{},{step:K,missingMap:Y}=At(g,T);if(Y.url?.length)throw new Error(`Missing params for placeholders -> url: ${Y.url.join(", ")}`);await w.mutateAsync({url:K.url,...X}),O(g.id,"Opened deeplink","green");break}case"fileRef":{O(g.id,"Loading steps from file...","blue");const T=(await $.mutateAsync({path:g.path}))?.content;let K=[],Y={};if(Array.isArray(T))K=T;else if(T&&Array.isArray(T.steps))K=T.steps,Y=T.params||{};else throw new Error("Referenced file must be an array or an object with steps");const ae={...Y,...g.overrides};console.debug("fileRef params",{refParams:Y,overrides:g.overrides,effectiveParams:ae});const Ne=vo.array().parse(K).map((se,W)=>{const re=typeof se.id=="number"?se.id:Date.now()+W,{step:_,missingMap:Ve}=At(se,ae);if(_.type==="type"&&Ve.text?.length||_.type==="scrollUntil"&&Ve.text?.length||_.type==="deeplink"&&Ve.url?.length||_.type==="ai"&&Ve.instruction?.length){const ze=[];for(const[lt,He]of Object.entries(Ve))He.length&&ze.push(`${lt}: ${He.join(", ")}`);throw new Error(`Referenced step has missing params -> ${ze.join("; ")}`)}return{id:re,..._,originRef:{refId:g.id,path:g.path,descriptionText:g.descriptionText,optional:g.optional,overrides:g.overrides}}});C.setState(se=>{const W=se.test.steps.findIndex(_=>_.id===g.id);if(W===-1)return se;const re=[...se.test.steps];return re.splice(W,1,...Ne),{...se,test:{...se.test,steps:re}}}),O(g.id,"Expanded steps from file","green");break}case"ai":{const T=C.state.test.params||{},{step:K,missingMap:Y}=At(g,T);if(Y.instruction?.length)throw new Error(`Missing params for placeholders -> instruction: ${Y.instruction.join(", ")}`);await de(g.id,x,K.instruction,V);break}}await I(100);const ve=Date.now()-me;return console.log(`[Step ${g.id}] Execution Finished. Total Duration: ${ve}ms`),z&&C.setState(T=>({...T,executionLog:[...T.executionLog,{stepId:g.id,stepNumber:x,screenshot:z,cacheHit:q,timestamp:Date.now()}]})),!0}catch(z){const q=z instanceof Error?z.message:"Unknown error";return g.optional?(O(g.id,`Failed (optional): ${q}`,"orange"),!0):(O(g.id,`Error: ${q}`,"red"),!1)}},Ee=()=>{C.setState(g=>{const x=g.test.steps,P=[],V=new Set,X=new Set;let me=0;for(;me<x.length;){const q=x[me];if(q?.type==="fileRef"){const H=q.path;if(X.has(H)){me++;continue}V.add(q.id),X.add(H),P.push(q),me++;continue}if(q&&q.originRef){const H=q.originRef.refId,ve=q.originRef.path,T=q.originRef.descriptionText,K=q.originRef.optional;let Y=me;for(;Y<x.length&&x[Y]?.originRef?.refId===H;)Y++;if(V.has(H)||X.has(ve)){me=Y;continue}const ae={id:H,type:"fileRef",path:ve,descriptionText:T,optional:K,overrides:q?.originRef?.overrides};P.some(Ne=>Ne.id===ae.id)&&(ae.id=Date.now()),P.push(ae),V.add(ae.id),X.add(ve),me=Y;continue}P.push(q),me++}const z=[];for(const q of P){const H=z[z.length-1];H?.type==="fileRef"&&q?.type==="fileRef"&&H.path===q.path||z.push(q)}return{...g,test:{...g.test,steps:z}}})},Ie=async(g,x)=>{if(C.state.test.steps.length===0){alert("No steps to play!");return}p.current=new AbortController;const P=p.current.signal;C.setState(H=>({...H,isPlaying:!0})),C.setState(H=>({...H,test:{...H.test,steps:H.test.steps.map((ve,T)=>T>=g?{...ve,status:"",statusColor:""}:ve)},executionLog:[]}));let V=g;const X=g+1,me=[];let z=!1,q;for(;!P.aborted;){const H=C.state.test.steps,ve=x?X:H.length;if(V>=ve)break;const T=H[V],K=T.type;if(!await st(T,V+1,P,me)&&!T.optional){z=!0,q=C.state.test.steps.find(Y=>Y.id===T.id)?.status||"Execution failed";break}if(K==="fileRef"){if(x)break;continue}V++}await I(500),Ee(),te(null),C.setState(H=>({...H,isPlaying:!1})),p.current=null,P.aborted||(z?jn(q||"Playback failed",{title:"Execution Failed"}):ki("Playback finished successfully",{title:"Execution Completed"}))},je=()=>Ie(0,!1),gt=g=>{const x=s.findIndex(P=>P.id===g);x!==-1&&Ie(x,!0)},qe=g=>{const x=s.findIndex(P=>P.id===g);x!==-1&&Ie(x,!1)},bt=()=>{p.current?.abort(),Ee(),C.setState(g=>({...g,isPlaying:!1})),te(null),Wf("Playback stopped",{title:"Stopped"})},Fe=g=>{i(g),r(!1)},Xt=()=>{r(!1),i(void 0)},Jt=()=>{r(!1),i(void 0)},Zt=g=>{confirm("Delete this step?")&&C.setState(x=>({...x,test:{...x.test,steps:x.test.steps.filter(P=>P.id!==g)}}))},Cn=()=>{confirm("Are you sure you want to clear all steps?")&&C.setState(g=>({...g,test:{...g.test,steps:[]}}))},ke=c||a,ce=n||!!o;return D(qf,{$hasForm:ce,children:[l(L,{variant:"h5",children:"Recorded Steps"}),l(Gt,{}),D(Kf,{children:[e&&l(Me,{variant:"contained",color:"primary",onClick:e,disabled:!t||c,children:"Save"}),c?l(Me,{variant:"contained",color:"error",onClick:bt,children:"Stop"}):l(Me,{variant:"contained",disabled:a||s.length===0,onClick:je,children:"Play Recording"}),l(Me,{variant:"contained",disabled:ke||ce,onClick:()=>r(!0),children:"+ Add Step"}),l(Me,{variant:"outlined",disabled:ke||s.length===0,onClick:Cn,children:"Clear All"})]}),(o||ce)&&l(Xf,{children:l(bf,{step:o,onSave:Xt,onCancel:Jt})}),l(Yf,{children:s.length===0?l(Jf,{children:l(L,{color:"text.secondary",children:"No steps recorded yet. Enable recording and click on the device screen to add steps."})}):l(gi,{onDragEnd:g=>{const{source:x,destination:P}=g;if(!P||x.index===P.index)return;const V=[...C.state.test.steps],[X]=V.splice(x.index,1);V.splice(P.index,0,X),C.setState(me=>({...me,test:{...me.test,steps:V}}))},children:l(un,{droppableId:"steps-droppable",children:g=>D("div",{ref:g.innerRef,...g.droppableProps,children:[s.map((x,P)=>l(xr,{draggableId:String(x.id),index:P,children:(V,X)=>l("div",{ref:V.innerRef,...V.draggableProps,...V.dragHandleProps,style:{...V.draggableProps.style,opacity:X.isDragging?.9:1},children:l(Uf,{step:x,index:P,onPlay:()=>gt(x.id),onPlayFromHere:()=>qe(x.id),onEdit:()=>Fe(x),onDelete:()=>Zt(x.id)})})},x.id)),g.placeholder]})})})}),l(Rf,{})]})},qf=F(En)`
282
+ display: grid;
283
+ grid-template-areas:
284
+ 'title'
285
+ 'divider'
286
+ 'actions'
287
+ ${({$hasForm:e})=>e?"'form'":""}
288
+ 'steps';
289
+ grid-template-rows: auto auto auto ${({$hasForm:e})=>e?"auto":""} minmax(0, 1fr);
290
+ row-gap: 0.75rem;
291
+ overflow: hidden;
292
+ `,Kf=F.div`
293
+ display: flex;
294
+ gap: 0.5rem;
295
+ flex-wrap: wrap;
296
+ `,Yf=F.div`
297
+ overflow-y: auto;
298
+ padding-right: 0.5rem;
299
+ `,Xf=F.div`
300
+ grid-area: form;
301
+ max-height: 50vh;
302
+ overflow-y: auto;
303
+ `,Jf=F.div`
304
+ display: flex;
305
+ align-items: center;
306
+ justify-content: center;
307
+ height: 100%;
308
+ padding: 2rem;
309
+ text-align: center;
310
+ `,Zf=ie("f8084cb106c8126bb2deaeef7c98992d9ff9475ad3dc85c6ced04f08c3962b6e"),Qf=oe({method:"POST"}).inputValidator(Xa).handler(Zf,async({data:e})=>({description:await Ja(e)})),em=fe({mutationKey:["ai","describe"],mutationFn:e=>Qf({data:e})}),tm=()=>{const e=we(C,I=>I.mode),t=we(C,I=>I.isRecording),n=we(C,I=>I.enableAnimations),r=zi(),o=J(null),{data:i=[]}=ut(Oi),a=we(C,I=>I.selectedDeviceId);we(C,I=>I.selectedPlatform),Ce(()=>{if(!a&&i.length>0){const I=i[0];C.setState(S=>({...S,selectedDeviceId:I.id,selectedPlatform:I.platform}))}},[i,a]);const s=i.find(I=>I.id===a),{data:c,isError:u,isLoading:f}=ut({...co({platform:s?.platform,deviceId:s?.id}),refetchInterval:250,enabled:!!s});Ce(()=>{const I=c?.base64;I&&C.setState(S=>({...S,currentScreenshot:I}))},[c]);const{data:d}=ut({...Ep({platform:s?.platform,deviceId:s?.id}),enabled:!!s,refetchInterval:1e3}),p=le(yp);Ce(()=>{s?.id&&d?.connected===!1&&!p.isPending&&p.mutate({platform:s.platform,deviceId:s.id})},[s,d?.connected]);const m=c?.success??!1,b=d?.connected??!1,v=m&&b,y=c?.base64,w=le(Bp),N=le(Ni),G=le(Sp),A=le(em),R=le(Wp),$=async(I,S)=>{C.setState(ne=>({...ne,enableAnimations:S})),S||await w.mutateAsync()},O=async I=>{const S=o.current;if(!S)return;const ne=S.getBoundingClientRect(),de=S.naturalWidth/ne.width,st=S.naturalHeight/ne.height,Ee=Math.round((I.clientX-ne.left)*de),Ie=Math.round((I.clientY-ne.top)*st),je={platform:s?.platform??"android",deviceId:s?.id,screenWidth:S.naturalWidth,screenHeight:S.naturalHeight},gt=y;let qe=null;if(t){const bt=document.createElement("canvas"),Fe=100;bt.width=Fe,bt.height=Fe;const Xt=bt.getContext("2d");if(Xt){Xt.drawImage(S,Ee-Fe/2,Ie-Fe/2,Fe,Fe,0,0,Fe,Fe);const Jt=bt.toDataURL("image/jpeg",.8);let Zt="";try{Zt=(await G.mutateAsync({x:Ee,y:Ie,...je})).elementId||""}catch(ke){console.error("Failed to get element ID:",ke)}qe=Date.now();const Cn={id:qe,type:e==="assert"?"assert":"tap",x:Ee,y:Ie,cropBase64:Jt,elementId:Zt,descriptionText:"Generating description...",optional:!1,useLlmOnly:!1,...je};C.setState(ke=>({...ke,test:{...ke.test,steps:[...ke.test.steps,Cn]}})),(async()=>{let ke=gt;if(e==="interact"&&(await N.mutateAsync({x:Ee,y:Ie,...je}),await new Promise(ce=>setTimeout(ce,2e3)),s?.id))try{const ce=await r.fetchQuery({...co({platform:s.platform,deviceId:s.id}),staleTime:0});ce?.base64&&(ke=ce.base64)}catch(ce){console.error("Failed to fetch post-action screenshot",ce)}try{const ce=await A.mutateAsync({fullImage:gt??"",croppedImage:Jt,targetImage:ke??"",type:e==="assert"?"assert":"interaction"});C.setState(g=>({...g,test:{...g.test,steps:g.test.steps.map(x=>x.id===qe?{...x,descriptionText:ce.description}:x)}}));try{const g=C.state.test.steps,x=g.findIndex(V=>V.id===qe),P=x!==-1?x+1:g.length;R.mutate({stepNumber:P,stepDescription:ce.description,filepath:void 0,screenshot:gt,interactionCoordinates:{x:Ee,y:Ie,action:"tap"},platform:s?.platform,screenResolution:{width:S.naturalWidth,height:S.naturalHeight}})}catch(g){console.error("Error populating cache:",g)}}catch(ce){console.error("Failed to describe interaction",ce);const g=e==="assert"?"Assert Element":"Tap Interaction";C.setState(x=>({...x,test:{...x.test,steps:x.test.steps.map(P=>P.id===qe?{...P,descriptionText:g}:P)}}))}try{const ce=C.state.test.steps,g=ce.findIndex(V=>V.id===qe),x=g!==-1?g+1:ce.length,P=e==="assert"?"Assert Element":"Tap Interaction";R.mutate({stepNumber:x,stepDescription:P,filepath:void 0,screenshot:gt,interactionCoordinates:{x:Ee,y:Ie,action:"tap"},platform:s?.platform,screenResolution:{width:S.naturalWidth,height:S.naturalHeight}})}catch(ce){console.error("Error populating cache (fallback):",ce)}})()}}else await N.mutateAsync({x:Ee,y:Ie,...je})},te=f?"Connecting...":u?"Error":v?"Connected":m&&!b?"Starting Appium...":"Disconnected";return D(nm,{children:[l(L,{variant:"h5",children:"Device"}),l(Gt,{}),D(rm,{children:[D(fn,{size:"small",sx:{minWidth:150},children:[l(mn,{children:"Device"}),l(hn,{value:a||"",label:"Device",onChange:I=>{const S=I.target.value,ne=i.find(de=>de.id===S);C.setState(de=>({...de,selectedDeviceId:S,selectedPlatform:ne?.platform||"android"}))},children:i.map(I=>D(vt,{value:I.id,children:[I.name," (",I.platform,")"]},I.id))})]}),l(xe,{control:l(Nr,{checked:t}),label:"Recording",onChange:(I,S)=>{C.setState(ne=>({...ne,isRecording:S}))}}),l(xe,{control:l(Nr,{checked:n}),label:"Animations",onChange:$}),D(Ki,{color:"primary",exclusive:!0,value:e,onChange:(I,S)=>{S&&C.setState(ne=>({...ne,mode:S}))},"aria-label":"Mode",children:[l(Sr,{value:"interact",children:"Interact"}),l(Sr,{value:"assert",children:"Assert"})]}),l(om,{connected:v,children:te})]}),l(im,{children:y?l(am,{ref:o,src:y,alt:"Device Screen",draggable:!1,onClick:O,recording:t}):l(sm,{children:i.length===0?l(L,{variant:"body2",color:"text.secondary",children:"No devices found."}):a?D(qn,{children:[l(fo,{}),l(L,{variant:"body2",color:"text.secondary",children:"Connecting to device..."})]}):l(L,{variant:"body2",color:"text.secondary",children:"Select a device."})})})]})},nm=F(En)`
311
+ display: grid;
312
+ grid-template-areas:
313
+ 'title'
314
+ 'divider'
315
+ 'actions'
316
+ 'device';
317
+ grid-template-rows: auto auto auto 1fr;
318
+ row-gap: 0.75rem;
319
+ overflow: hidden;
320
+ `,rm=F.div`
321
+ display: flex;
322
+ gap: 0.5rem;
323
+ flex-wrap: wrap;
324
+ align-items: center;
325
+ `,om=F(L)`
326
+ font-size: 0.875rem;
327
+ color: ${({connected:e})=>e?"#4caf50":"#f44336"};
328
+ margin-left: auto;
329
+ `,im=F.div`
330
+ display: flex;
331
+ justify-content: center;
332
+ align-items: center;
333
+ overflow: hidden;
334
+ flex: 1;
335
+ min-height: 0;
336
+ `,am=F.img`
337
+ max-height: 100%;
338
+ max-width: 100%;
339
+ object-fit: contain;
340
+ border: 2px solid #333;
341
+ border-radius: 8px;
342
+ cursor: crosshair;
343
+ box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
344
+ ${({recording:e})=>e&&`
345
+ border-color: #2196f3;
346
+ box-shadow: 0 0 20px rgba(33, 150, 243, 0.4);
347
+ `}
348
+ `,sm=F(ge)`
349
+ display: flex;
350
+ flex-direction: column;
351
+ align-items: center;
352
+ gap: 1rem;
353
+ `;function lm(e){const t={};return e.forEach(n=>{const r=n.path.split("/");let o=t,i="";r.forEach((a,s)=>{i=i?`${i}/${a}`:a,o[a]||(o[a]={name:a,fullPath:i,type:s===r.length-1?n.type:"directory",children:{}}),s===r.length-1&&(o[a].type=n.type,o[a].fullPath=i),o=o[a].children})}),t}const Li=({item:e,level:t,onSelect:n,selectedFile:r,onRename:o})=>{const[i,a]=De(!1),[s,c]=De(!1),[u,f]=De(e.name),d=()=>{u&&u!==e.name&&o(e.fullPath,u),c(!1)},p=Object.keys(e.children).length>0,m=Object.values(e.children).sort((b,v)=>b.type===v.type?b.name.localeCompare(v.name):b.type==="directory"?-1:1);return s?l(In,{sx:{pl:t*2},children:l(M,{value:u,onChange:b=>f(b.target.value),size:"small",autoFocus:!0,onBlur:d,onKeyDown:b=>{b.key==="Enter"&&d(),b.key==="Escape"&&c(!1)},InputProps:{endAdornment:l(Ji,{position:"end",children:l(B,{size:"small",onMouseDown:d,children:l(us,{fontSize:"small"})})})}})}):D(qn,{children:[e.type==="directory"?l(un,{droppableId:`FOLDER_ROW::${e.fullPath}`,children:(b,v)=>D("div",{ref:b.innerRef,...b.droppableProps,children:[D(In,{button:!0,onClick:y=>{a(!i)},onDoubleClick:()=>{f(e.name),c(!0)},selected:r===e.fullPath,sx:{pl:t*2,bgcolor:v.isDraggingOver?"action.hover":void 0},children:[l(Or,{sx:{minWidth:32},children:l(ss,{fontSize:"small",color:"primary"})}),l(Ar,{primary:e.name,primaryTypographyProps:{variant:"body2",noWrap:!0}}),p&&(i?l(cs,{fontSize:"small"}):l(ds,{fontSize:"small"}))]}),b.placeholder]})}):D(In,{button:!0,onClick:()=>n(e.fullPath),onDoubleClick:()=>{f(e.name),c(!0)},selected:r===e.fullPath,sx:{pl:t*2},children:[l(Or,{sx:{minWidth:32},children:l(ls,{fontSize:"small",color:"action"})}),l(Ar,{primary:e.name,primaryTypographyProps:{variant:"body2",noWrap:!0}})]}),e.type==="directory"&&l(Zi,{in:i,timeout:"auto",unmountOnExit:!0,children:l(un,{droppableId:e.fullPath,children:b=>D(mo,{component:"div",disablePadding:!0,ref:b.innerRef,...b.droppableProps,children:[m.map((v,y)=>l(xr,{draggableId:v.fullPath,index:y,children:(w,N)=>l("div",{ref:w.innerRef,...w.draggableProps,...w.dragHandleProps,style:{...w.draggableProps.style,opacity:N.isDragging?.9:1},children:l(Li,{item:v,level:t+1,onSelect:n,selectedFile:r,onRename:o})})},v.fullPath)),b.placeholder]})})})]})};function cm({files:e,onSelect:t,selectedFile:n,refetch:r}){const o=lm(e),i=Object.values(o).sort((c,u)=>c.type===u.type?c.name.localeCompare(u.name):c.type==="directory"?-1:1),a=le(cf),s=async(c,u)=>{try{const f=c.split("/");f.pop();const d=f.join("/"),p=d?`${d}/${u}`:u;await a.mutateAsync({oldPath:c,newPath:p}),r()}catch(f){alert("Rename failed: "+f.message)}};return l(gi,{onDragEnd:async c=>{const{destination:u,draggableId:f}=c;if(!u)return;const d=u.droppableId;let p="";d==="ROOT"?p="":d.startsWith("FOLDER_ROW::")?p=d.slice(12):p=d;const m=f;if(!m||p&&(m===p||p.startsWith(m+"/")))return;const b=m.lastIndexOf("/"),v=b>=0?m.slice(0,b):"";if((p||"")===v)return;const y=b>=0?m.slice(b+1):m,w=p?`${p}/${y}`:y;try{await a.mutateAsync({oldPath:m,newPath:w}),r()}catch(N){alert("Move failed: "+N.message)}},children:l(un,{droppableId:"ROOT",children:c=>D(mo,{dense:!0,ref:c.innerRef,...c.droppableProps,children:[i.map((u,f)=>l(xr,{draggableId:u.fullPath||u.name,index:f,children:(d,p)=>l("div",{ref:d.innerRef,...d.draggableProps,...d.dragHandleProps,style:{...d.draggableProps.style,opacity:p.isDragging?.9:1},children:l(Li,{item:u,level:1,onSelect:t,selectedFile:n,onRename:s})})},u.fullPath||u.name)),c.placeholder]})})})}function dm({onSelectFile:e,selectedFile:t}){const{data:n,isLoading:r,error:o,refetch:i}=ut({...Cr,refetchInterval:2e3}),[a,s]=De(!1),[c,u]=De("file"),[f,d]=De(""),p=le(Jp),m=async()=>{if(!f)return;let y=f;c==="file"&&!y.endsWith(".json")&&(y+=".json");try{await p.mutateAsync({name:y,type:c}),s(!1),d(""),i()}catch(w){alert("Failed to create: "+w.message)}},b=y=>{u(y),d(""),s(!0)};if(r&&!n)return l(Fn,{children:l(fo,{})});if(o)return l(Fn,{children:l(L,{color:"error",children:"Error loading files"})});const v=n?.files||[];return D(Fn,{children:[D(um,{children:[l(L,{variant:"h6",children:"Tests"}),D(ge,{children:[l(B,{onClick:()=>i(),size:"small",title:"Refresh",children:l(is,{})}),l(B,{onClick:()=>b("directory"),size:"small",title:"New Folder",children:l(as,{})}),l(B,{onClick:()=>b("file"),size:"small",color:"primary",title:"New Test",children:l(xo,{})})]})]}),l(Gt,{}),l(pm,{children:v.length===0?l(L,{variant:"caption",sx:{p:2,display:"block",textAlign:"center",color:"text.secondary"},children:"No tests found"}):l(cm,{files:v,onSelect:e,selectedFile:t,refetch:i})}),D(Hi,{open:a,onClose:()=>s(!1),children:[D(Ui,{children:["Create New ",c==="file"?"Test":"Folder"]}),l(ji,{children:l(M,{autoFocus:!0,margin:"dense",label:"Name",fullWidth:!0,value:f,onChange:y=>d(y.target.value),placeholder:c==="file"?"my-test":"my-folder"})}),D(qi,{children:[l(Me,{onClick:()=>s(!1),children:"Cancel"}),l(Me,{onClick:m,variant:"contained",children:"Create"})]})]})]})}const Fn=F(En)`
354
+ display: flex;
355
+ flex-direction: column;
356
+ padding: 0;
357
+ overflow: hidden;
358
+ height: 100%;
359
+ `,um=F.div`
360
+ padding: 1rem;
361
+ display: flex;
362
+ align-items: center;
363
+ justify-content: space-between;
364
+ `,pm=F.div`
365
+ flex: 1;
366
+ overflow-y: auto;
367
+ padding: 0.5rem 0;
368
+ `;function fm({disabled:e}){const t=we(C,u=>u.test.params),[n,r]=De(()=>Object.entries(t||{}).map(([u,f])=>({key:u,value:f})));Ce(()=>{r(Object.entries(t||{}).map(([u,f])=>({key:u,value:f})))},[t]),Wi(()=>new Set(n.map(u=>u.key)),[n]);const o=u=>{const f={};for(const d of u)d.key&&(f[d.key]=d.value);C.setState(d=>({...d,test:{...d.test,params:f}}))},i=()=>{const u=[...n,{key:"",value:""}];r(u)},a=u=>{const f=n.filter((d,p)=>p!==u);r(f),o(f)},s=(u,f)=>{const d=n.map((p,m)=>m===u?{...p,key:f}:p);r(d),o(d)},c=(u,f)=>{const d=n.map((p,m)=>m===u?{...p,value:f}:p);r(d),o(d)};return D(mm,{children:[D(hm,{children:[l(L,{variant:"subtitle1",children:"Test Params"}),l(on,{title:e?"Select a test to edit params":"Add parameter",children:l("span",{children:l(B,{size:"small",disabled:e,onClick:i,color:"primary",children:l(xo,{})})})})]}),l(Gt,{}),D(gm,{children:[n.length===0&&l(vm,{children:l(L,{variant:"caption",color:"text.secondary",children:e?"No test selected":"No params. Click + to add"})}),n.map((u,f)=>{const d=u.key&&n.some((p,m)=>m!==f&&p.key===u.key);return D(bm,{children:[l(M,{size:"small",label:"Key",value:u.key,onChange:p=>s(f,p.target.value),disabled:e,error:!!d,helperText:d?"Duplicate key":" "}),l(M,{size:"small",label:"Value",value:u.value,onChange:p=>c(f,p.target.value),disabled:e}),l(on,{title:e?"":"Remove",children:l("span",{children:l(B,{size:"small",disabled:e,onClick:()=>a(f),children:l(Ue,{})})})})]},f)})]}),!e&&n.length>0&&l(ge,{sx:{p:1,display:"flex",justifyContent:"flex-end"},children:l(Me,{size:"small",onClick:()=>o(n),children:"Apply"})})]})}const mm=F(En)`
369
+ display: flex;
370
+ flex-direction: column;
371
+ padding: 0;
372
+ height: 100%;
373
+ overflow: hidden;
374
+ `,hm=F.div`
375
+ padding: 0.75rem 1rem;
376
+ display: flex;
377
+ align-items: center;
378
+ justify-content: space-between;
379
+ `,gm=F.div`
380
+ padding: 0.5rem 0.75rem;
381
+ display: flex;
382
+ flex-direction: column;
383
+ gap: 0.5rem;
384
+ overflow: auto;
385
+ `,bm=F.div`
386
+ display: grid;
387
+ grid-template-columns: 1fr 1fr auto;
388
+ gap: 0.5rem;
389
+ align-items: center;
390
+ `,vm=F.div`
391
+ padding: 0.75rem;
392
+ text-align: center;
393
+ `;function ym(){const e=we(Yt,n=>n),t=po(()=>{Gf()},[]);return l(Yi,{open:e.open,onClose:t,className:"absolute z-10",style:{maxWidth:"384px"},anchorOrigin:{vertical:"top",horizontal:"right"},autoHideDuration:e.maintainDisplayed?null:3e3,children:D(Xi,{severity:e.type,onClose:t,children:[e.title!==void 0&&l(ps,{sx:{...e.description==null&&e.listContent==null&&{marginBottom:0}},children:e.title}),e.description!==void 0&&e.description,e.listContent!==void 0&&e.listContent.length>0&&l("ul",{className:"mt-2 ml-2 list-disc list-inside",children:e.listContent.map((n,r)=>l("li",{children:n},r))})]})})}function Wh(){const[e,t]=De(),n=le(Ir),r=le(of);return Ce(()=>{e&&n.mutateAsync({path:e}).then(o=>{const i=o.content;let a=[],s={};Array.isArray(i)?(a=i,s={}):i&&Array.isArray(i.steps)&&(a=i.steps,s=i.params||{});const c=a.map((u,f)=>({...u,id:u.id||Date.now()+f}));C.setState(u=>({...u,test:{name:o.path,steps:c,params:s}}))}).catch(o=>{o instanceof Error?o.message:String(o),jn("Failed to read file",{title:"Read Error"})})},[e]),D(qn,{children:[D(Dm,{children:[l(xm,{children:l(dm,{onSelectFile:t,selectedFile:e})}),l(Em,{children:l(fm,{disabled:!e})}),l(wm,{children:l(jf,{onSave:async()=>{if(e)try{const o=C.state.test.steps.map(({statusDiv:a,element:s,status:c,statusColor:u,originRef:f,...d})=>d),i={...C.state.test,steps:o};await r.mutateAsync({path:e,content:i}),ki("File saved",{title:"Saved"})}catch(o){jn(o?.message?String(o.message):"Failed to save",{title:"Save Error"})}},canSave:!!e})}),l(Cm,{children:l(tm,{})})]}),l(ym,{})]})}const Dm=F.div`
394
+ display: grid;
395
+ grid-template-areas:
396
+ 'files editor simulator'
397
+ 'params editor simulator';
398
+ grid-template-columns: 250px minmax(0, 1fr) 350px;
399
+ grid-template-rows: 1fr minmax(160px, 35%);
400
+ background-color: #f0f2f5;
401
+ height: 100vh;
402
+ padding: 1rem;
403
+ column-gap: 1rem;
404
+ row-gap: 1rem;
405
+ `,xm=F.div`
406
+ grid-area: files;
407
+ min-height: 0; /* allow internal scroll */
408
+ `,Em=F.div`
409
+ grid-area: params;
410
+ min-height: 0;
411
+ `,wm=F.div`
412
+ grid-area: editor;
413
+ min-height: 0;
414
+ height: 100%;
415
+ overflow-y: auto;
416
+ `,Cm=F.div`
417
+ grid-area: simulator;
418
+ min-height: 0;
419
+ `;export{Wh as component};