mobileboost-cli 0.2.0 → 0.2.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.
- package/.output/nitro.json +1 -1
- package/.output/public/assets/{index-B9xOUxIH.js → index-D7JF4301.js} +65 -65
- package/.output/public/assets/{main-Dc24NDnw.js → main-BbUrvuLL.js} +1 -1
- package/.output/server/chunks/_/{_tanstack-start-manifest_v-DWF0_Gj8.mjs → _tanstack-start-manifest_v-CCgm5JAL.mjs} +1 -1
- package/.output/server/chunks/_/{actions-AXnOoTLJ.mjs → actions-CvabQsJo.mjs} +1 -1
- package/.output/server/chunks/_/ai-client-waGeh-P8.mjs +1 -1
- package/.output/server/chunks/_/{appium-C-D6h2jM.mjs → appium-CMKpXGap.mjs} +1 -1
- package/.output/server/chunks/_/appium-client-DiTTrl8p.mjs +1 -0
- package/.output/server/chunks/_/client-CM5hUS2d.mjs +1 -1
- package/.output/server/chunks/_/{files-hj9HVaKT.mjs → files-CB9WpUb0.mjs} +1 -1
- package/.output/server/chunks/_/{hierarchy-D3NdBpb6.mjs → hierarchy-DfPTUh7F.mjs} +1 -1
- package/.output/server/chunks/_/index-BZ9EyYaV.mjs +474 -0
- package/.output/server/chunks/_/{router-CnslKYM2.mjs → router-DYcFhNaL.mjs} +1 -1
- package/.output/server/chunks/_/server.mjs +2 -2
- package/.output/server/chunks/_/stores-2rWNmXVj.mjs +1 -0
- package/.output/server/index.mjs +3 -3
- package/package.json +3 -2
- package/.output/server/chunks/_/appium-client-Dxm_q6FS.mjs +0 -1
- package/.output/server/chunks/_/index-CLteVPoM.mjs +0 -474
- package/.output/server/chunks/_/stores-03HL60eP.mjs +0 -1
|
@@ -0,0 +1,474 @@
|
|
|
1
|
+
import{jsxs as v,Fragment as Nn,jsx as s}from"react/jsx-runtime";import oe,{useRef as W,useEffect as Ce,useContext as $o,useLayoutEffect as ma,useState as fe,useMemo as lr,useCallback as vn}from"react";import F from"@emotion/styled";import{useMutation as G,mutationOptions as ge,useQueryClient as Sn,useQuery as Je,queryOptions as Rt}from"@tanstack/react-query";import{useStore as ye,Store as ha}from"@tanstack/react-store";import{CircularProgress as Bo,Typography as U,Box as ne,IconButton as O,Divider as nn,Dialog as cr,DialogTitle as ko,DialogContent as dr,TextField as me,DialogActions as Fo,Button as Be,Tooltip as ft,FormControl as Tt,InputLabel as rn,Select as on,MenuItem as gt,ToggleButtonGroup as ga,ToggleButton as Yr,Snackbar as ba,Alert as ya,List as _o,FormHelperText as On,FormControlLabel as Pn,Checkbox as ur,RadioGroup as va,Radio as xa,ListItem as Vn,InputAdornment as Da,ListItemIcon as Jr,ListItemText as Xr,Collapse as Ea,styled as It,Chip as V,Paper as Lo}from"@mui/material";import{Stop as Vo,CameraAlt as wa,PlayArrow as Ia,FiberManualRecord as Ca,Layers as Na,Animation as Sa}from"@mui/icons-material";import Oa,{flushSync as Mo}from"react-dom";import{bindActionCreators as Zr,createStore as Pa,compose as Aa,applyMiddleware as Ra}from"redux";import{connect as Go,Provider as Ta}from"react-redux";import Qr from"tiny-invariant";import Wo from"@babel/runtime/helpers/esm/extends";import{L as I,w as Mn,D as zo,h as $a,d as Ba,u as ka,S as Fa,c as _a,l as La,i as Va,r as Ma,A as eo,B as Ga}from"./stores-2rWNmXVj.mjs";import{styled as $t}from"@mui/material/styles";import Wa from"@mui/icons-material/Keyboard";import Ho from"@mui/icons-material/SwipeVertical";import za from"@mui/icons-material/ZoomInMap";import Ha from"@mui/icons-material/Search";import Ua from"@mui/icons-material/Link";import ja from"@mui/icons-material/SmartToy";import Xe from"@mui/icons-material/PlayArrow";import Ze from"@mui/icons-material/FastForward";import Qe from"@mui/icons-material/Edit";import je from"@mui/icons-material/Delete";import{a as ae,g as qa,T as Ka}from"./server.mjs";import{S as Ya,d as Ja,r as Xa,u as Za,x as Qa,b as es,l as ts,a as pr}from"./device-CWFVkH1s.mjs";import{performTap as ns,performType as rs,performScroll as Uo,getPageSource as An,performDeepLink as os,performZoom as is,performSwipe as as,ensureAppiumSession as ss,getPlatform as ls,getDeviceSize as cs}from"./appium-client-DiTTrl8p.mjs";import{V as fr,N as jo,X as ds,H as us,K as ps,j as fs,Y as ms,_ as hs,z as gs,L as bs,q as ys}from"./hierarchy-helpers-BaGN7WBn.mjs";import{f as vs,u as xs,b as Ds}from"./adb-client-DwefjXbe.mjs";import{m as Es,u as ws}from"./ios-client-1xTZzFD8.mjs";import{s as Is,n as Cs}from"./step-D2WQqd4J.mjs";import to from"node:fs";import Ae from"node:path";import Ns from"node:crypto";import Ht from"sharp";import{a as Ss,i as Os,o as Ps}from"./cache-CtBF0d8x.mjs";import{R as pt}from"./constants-Dh9o88yr.mjs";import{F as As,W as Rs,P as Ts,K as $s}from"./ai-client-waGeh-P8.mjs";import{readFile as Bs}from"node:fs/promises";import Re from"fs-extra";import{z as L}from"zod";import ks from"dotenv";import{useForm as Fs}from"@tanstack/react-form";import _s from"@mui/icons-material/Save";import Ls from"@mui/icons-material/Close";import Vs from"@mui/icons-material/KeyboardArrowUp";import Ms from"@mui/icons-material/KeyboardArrowDown";import Gs from"@mui/icons-material/CheckCircle";import Ws from"@mui/icons-material/Info";import qo from"@react-hook/mouse-position";import Ko from"@mui/icons-material/Add";import zs from"@mui/icons-material/Refresh";import Hs from"@mui/icons-material/CreateNewFolder";import Us from"@mui/icons-material/Folder";import js from"@mui/icons-material/InsertDriveFile";import qs from"@mui/icons-material/ExpandLess";import Ks from"@mui/icons-material/ExpandMore";import Ys from"@mui/icons-material/Check";import Js 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"linkedom";import"node:child_process";import"node:util";var He=function(t){var n=t.top,r=t.right,o=t.bottom,i=t.left,a=r-i,l=o-n,u={top:n,right:r,bottom:o,left:i,width:a,height:l,x:i,y:n,center:{x:(r+i)/2,y:(o+n)/2}};return u},mr=function(t,n){return{top:t.top-n.top,left:t.left-n.left,bottom:t.bottom+n.bottom,right:t.right+n.right}},no=function(t,n){return{top:t.top+n.top,left:t.left+n.left,bottom:t.bottom-n.bottom,right:t.right-n.right}},Xs=function(t,n){return{top:t.top+n.y,left:t.left+n.x,bottom:t.bottom+n.y,right:t.right+n.x}},Gn={top:0,right:0,bottom:0,left:0},hr=function(t){var n=t.borderBox,r=t.margin,o=r===void 0?Gn:r,i=t.border,a=i===void 0?Gn:i,l=t.padding,u=l===void 0?Gn:l,c=He(mr(n,o)),f=He(no(n,a)),p=He(no(f,u));return{marginBox:c,borderBox:He(n),paddingBox:f,contentBox:p,margin:o,border:a,padding:u}},Ve=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"?Qr(!1,"Could not parse value [raw: "+t+", without suffix: "+n+"]"):Qr(!1)),o},Zs=function(){return{x:window.pageXOffset,y:window.pageYOffset}},xn=function(t,n){var r=t.borderBox,o=t.border,i=t.margin,a=t.padding,l=Xs(r,n);return hr({borderBox:l,border:o,margin:i,padding:a})},Dn=function(t,n){return n===void 0&&(n=Zs()),xn(t,n)},Yo=function(t,n){var r={top:Ve(n.marginTop),right:Ve(n.marginRight),bottom:Ve(n.marginBottom),left:Ve(n.marginLeft)},o={top:Ve(n.paddingTop),right:Ve(n.paddingRight),bottom:Ve(n.paddingBottom),left:Ve(n.paddingLeft)},i={top:Ve(n.borderTopWidth),right:Ve(n.borderRightWidth),bottom:Ve(n.borderBottomWidth),left:Ve(n.borderLeftWidth)};return hr({borderBox:t,margin:r,padding:o,border:i})},Jo=function(t){var n=t.getBoundingClientRect(),r=window.getComputedStyle(t);return Yo(n,r)},qt=function(t){var n=[],r=null,o=function(){for(var a=arguments.length,l=new Array(a),u=0;u<a;u++)l[u]=arguments[u];n=l,!r&&(r=requestAnimationFrame(function(){r=null,t.apply(void 0,n)}))};return o.cancel=function(){r&&(cancelAnimationFrame(r),r=null)},o};const Qs=process.env.NODE_ENV==="production",el=/[ \t]{2,}/g,tl=/^[ \t]*/gm,ro=e=>e.replace(el," ").replace(tl,"").trim(),nl=e=>ro(`
|
|
2
|
+
%c@hello-pangea/dnd
|
|
3
|
+
|
|
4
|
+
%c${ro(e)}
|
|
5
|
+
|
|
6
|
+
%c👷 This is a development only message. It will be removed in production builds.
|
|
7
|
+
`),rl=e=>[nl(e),"color: #00C584; font-size: 1.2em; font-weight: bold;","line-height: 1.5","color: #723874;"],ol="__@hello-pangea/dnd-disable-dev-warnings";function Xo(e,t){Qs||typeof window<"u"&&window[ol]||console[e](...rl(t))}const ie=Xo.bind(null,"warn"),er=Xo.bind(null,"error");function mt(){}function il(e,t){return{...e,...t}}function Me(e,t,n){const r=t.map(o=>{const i=il(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 al=process.env.NODE_ENV==="production",oo="Invariant failed";class Kt extends Error{}Kt.prototype.toString=function(){return this.message};function h(e,t){throw al?new Kt(oo):new Kt(`${oo}: ${t||""}`)}class sl extends oe.Component{constructor(...t){super(...t),this.callbacks=null,this.unbind=mt,this.onWindowError=n=>{const r=this.getCallbacks();r.isDragging()&&(r.tryAbort(),process.env.NODE_ENV!=="production"&&ie(`
|
|
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 Kt&&(n.preventDefault(),process.env.NODE_ENV!=="production"&&er(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=Me(window,[{eventName:"error",fn:this.onWindowError}])}componentDidCatch(t){if(t instanceof Kt){process.env.NODE_ENV!=="production"&&er(t.message),this.setState({});return}throw t}componentWillUnmount(){this.unbind()}render(){return this.props.children(this.setCallbacks)}}const ll=`
|
|
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
|
+
`,En=e=>e+1,cl=e=>`
|
|
15
|
+
You have lifted an item in position ${En(e.source.index)}
|
|
16
|
+
`,Zo=(e,t)=>{const n=e.droppableId===t.droppableId,r=En(e.index),o=En(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
|
+
`},Qo=(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
|
+
`,dl=e=>{const t=e.destination;if(t)return Zo(e.source,t);const n=e.combine;return n?Qo(e.draggableId,e.source,n):"You are over an area that cannot be dropped on"},io=e=>`
|
|
32
|
+
The item has returned to its starting position
|
|
33
|
+
of ${En(e.index)}
|
|
34
|
+
`,ul=e=>{if(e.reason==="CANCEL")return`
|
|
35
|
+
Movement cancelled.
|
|
36
|
+
${io(e.source)}
|
|
37
|
+
`;const t=e.destination,n=e.combine;return t?`
|
|
38
|
+
You have dropped the item.
|
|
39
|
+
${Zo(e.source,t)}
|
|
40
|
+
`:n?`
|
|
41
|
+
You have dropped the item.
|
|
42
|
+
${Qo(e.draggableId,e.source,n)}
|
|
43
|
+
`:`
|
|
44
|
+
The item has been dropped while not over a drop area.
|
|
45
|
+
${io(e.source)}
|
|
46
|
+
`},yn={dragHandleUsageInstructions:ll,onDragStart:cl,onDragUpdate:dl,onDragEnd:ul};function pl(e,t){return!!(e===t||Number.isNaN(e)&&Number.isNaN(t))}function ei(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!pl(e[n],t[n]))return!1;return!0}function z(e,t){const n=fe(()=>({inputs:t,result:e()}))[0],r=W(!0),o=W(n),a=r.current||!!(t&&o.current.inputs&&ei(t,o.current.inputs))?o.current:{inputs:t,result:e()};return Ce(()=>{r.current=!1,o.current=a},[a]),a.result}function S(e,t){return z(()=>e,t)}const xe={x:0,y:0},De=(e,t)=>({x:e.x+t.x,y:e.y+t.y}),ke=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),ht=(e,t)=>e.x===t.x&&e.y===t.y,Bt=e=>({x:e.x!==0?-e.x:0,y:e.y!==0?-e.y:0}),Et=(e,t,n=0)=>e==="x"?{x:t,y:n}:{x:n,y:t},Yt=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),ao=(e,t)=>Math.min(...t.map(n=>Yt(e,n))),ti=e=>t=>({x:e(t.x),y:e(t.y)});var fl=(e,t)=>{const n=He({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 an=(e,t)=>({top:e.top+t.y,left:e.left+t.x,bottom:e.bottom+t.y,right:e.right+t.x}),so=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}],ml={top:0,right:0,bottom:0,left:0},hl=(e,t)=>t?an(e,t.scroll.diff.displacement):e,gl=(e,t,n)=>n&&n.increasedBy?{...e,[t.end]:e[t.end]+n.increasedBy[t.line]}:e,bl=(e,t)=>t&&t.shouldClipSubject?fl(t.pageMarginBox,e):He(e);var Ot=({page:e,withPlaceholder:t,axis:n,frame:r})=>{const o=hl(e.marginBox,r),i=gl(o,n,t),a=bl(i,r);return{page:e,withPlaceholder:t,active:a}},gr=(e,t)=>{e.frame||(process.env.NODE_ENV,h());const n=e.frame,r=ke(t,n.scroll.initial),o=Bt(r),i={...n,scroll:{initial:n.scroll.initial,current:t,diff:{value:r,displacement:o},max:n.scroll.max}},a=Ot({page:e.subject.page,withPlaceholder:e.subject.withPlaceholder,axis:e.axis,frame:i});return{...e,frame:i,subject:a}};function ve(e,t=ei){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 ni=ve(e=>e.reduce((t,n)=>(t[n.descriptor.id]=n,t),{})),ri=ve(e=>e.reduce((t,n)=>(t[n.descriptor.id]=n,t),{})),Rn=ve(e=>Object.values(e)),yl=ve(e=>Object.values(e));var Ct=ve((e,t)=>yl(t).filter(r=>e===r.descriptor.droppableId).sort((r,o)=>r.descriptor.index-o.descriptor.index));function br(e){return e.at&&e.at.type==="REORDER"?e.at.destination:null}function Tn(e){return e.at&&e.at.type==="COMBINE"?e.at.combine:null}var $n=ve((e,t)=>t.filter(n=>n.descriptor.id!==e.descriptor.id)),vl=({isMovingForward:e,draggable:t,destination:n,insideDestination:r,previousImpact:o})=>{if(!n.isCombineEnabled||!br(o))return null;function a(m){const g={type:"COMBINE",combine:{draggableId:m,droppableId:n.descriptor.id}};return{...o,at:g}}const l=o.displaced.all,u=l.length?l[0]:null;if(e)return u?a(u):null;const c=$n(t,r);if(!u){if(!c.length)return null;const m=c[c.length-1];return a(m.descriptor.id)}const f=c.findIndex(m=>m.descriptor.id===u);f===-1&&(process.env.NODE_ENV!=="production"?h(!1,"Could not find displaced item in set"):h());const p=f-1;if(p<0)return null;const d=c[p];return a(d.descriptor.id)},kt=(e,t)=>e.descriptor.droppableId===t.descriptor.id;const oi={point:xe,value:0},Jt={invisible:{},visible:{},all:[]},xl={displaced:Jt,displacedBy:oi,at:null};var Ge=(e,t)=>n=>e<=n&&n<=t,ii=e=>{const t=Ge(e.top,e.bottom),n=Ge(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 u=r.top<e.top&&r.bottom>e.bottom,c=r.left<e.left&&r.right>e.right;return u&&c?!0:u&&a||c&&i}},Dl=e=>{const t=Ge(e.top,e.bottom),n=Ge(e.left,e.right);return r=>t(r.top)&&t(r.bottom)&&n(r.left)&&n(r.right)};const yr={direction:"vertical",line:"y",crossAxisLine:"x",start:"top",end:"bottom",size:"height",crossAxisStart:"left",crossAxisEnd:"right",crossAxisSize:"width"},ai={direction:"horizontal",line:"x",crossAxisLine:"y",start:"left",end:"right",size:"width",crossAxisStart:"top",crossAxisEnd:"bottom",crossAxisSize:"height"};var El=e=>t=>{const n=Ge(t.top,t.bottom),r=Ge(t.left,t.right);return o=>e===yr?n(o.top)&&n(o.bottom):r(o.left)&&r(o.right)};const wl=(e,t)=>{const n=t.frame?t.frame.scroll.diff.displacement:xe;return an(e,n)},Il=(e,t,n)=>t.subject.active?n(t.subject.active)(e):!1,Cl=(e,t,n)=>n(t)(e),vr=({target:e,destination:t,viewport:n,withDroppableDisplacement:r,isVisibleThroughFrameFn:o})=>{const i=r?wl(e,t):e;return Il(i,t,o)&&Cl(i,n,o)},Nl=e=>vr({...e,isVisibleThroughFrameFn:ii}),si=e=>vr({...e,isVisibleThroughFrameFn:Dl}),Sl=e=>vr({...e,isVisibleThroughFrameFn:El(e.destination.axis)}),Ol=(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 Pl(e,t){const n=e.page.marginBox,r={top:t.point.y,right:0,bottom:0,left:t.point.x};return He(mr(n,r))}function Xt({afterDragging:e,destination:t,displacedBy:n,viewport:r,forceShouldAnimate:o,last:i}){return e.reduce(function(l,u){const c=Pl(u,n),f=u.descriptor.id;if(l.all.push(f),!Nl({target:c,destination:t,viewport:r,withDroppableDisplacement:!0}))return l.invisible[u.descriptor.id]=!0,l;const d=Ol(f,i,o),m={draggableId:f,shouldAnimate:d};return l.visible[f]=m,l},{all:[],visible:{},invisible:{}})}function Al(e,t){if(!e.length)return 0;const n=e[e.length-1].descriptor.index;return t.inHomeList?n:n+1}function lo({insideDestination:e,inHomeList:t,displacedBy:n,destination:r}){const o=Al(e,{inHomeList:t});return{displaced:Jt,displacedBy:n,at:{type:"REORDER",destination:{droppableId:r.descriptor.id,index:o}}}}function wn({draggable:e,insideDestination:t,destination:n,viewport:r,displacedBy:o,last:i,index:a,forceShouldAnimate:l}){const u=kt(e,n);if(a==null)return lo({insideDestination:t,inHomeList:u,displacedBy:o,destination:n});const c=t.find(g=>g.descriptor.index===a);if(!c)return lo({insideDestination:t,inHomeList:u,displacedBy:o,destination:n});const f=$n(e,t),p=t.indexOf(c),d=f.slice(p);return{displaced:Xt({afterDragging:d,destination:n,displacedBy:o,last:i,viewport:r.frame,forceShouldAnimate:l}),displacedBy:o,at:{type:"REORDER",destination:{droppableId:n.descriptor.id,index:a}}}}function bt(e,t){return!!t.effected[e]}var Rl=({isMovingForward:e,destination:t,draggables:n,combine:r,afterCritical:o})=>{if(!t.isCombineEnabled)return null;const i=r.draggableId,l=n[i].descriptor.index;return bt(i,o)?e?l:l-1:e?l+1:l},Tl=({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,l=n[n.length-1].descriptor.index,u=t?l:l+1;return i<a||i>u?null:i},$l=({isMovingForward:e,isInHomeList:t,draggable:n,draggables:r,destination:o,insideDestination:i,previousImpact:a,viewport:l,afterCritical:u})=>{const c=a.at;if(c||(process.env.NODE_ENV!=="production"?h(!1,"Cannot move in direction without previous impact location"):h()),c.type==="REORDER"){const p=Tl({isMovingForward:e,isInHomeList:t,location:c.destination,insideDestination:i});return p==null?null:wn({draggable:n,insideDestination:i,destination:o,viewport:l,last:a.displaced,displacedBy:a.displacedBy,index:p})}const f=Rl({isMovingForward:e,destination:o,displaced:a.displaced,draggables:r,combine:c.combine,afterCritical:u});return f==null?null:wn({draggable:n,insideDestination:i,destination:o,viewport:l,last:a.displaced,displacedBy:a.displacedBy,index:f})},Bl=({displaced:e,afterCritical:t,combineWith:n,displacedBy:r})=>{const o=!!(e.visible[n]||e.invisible[n]);return bt(n,t)?o?xe:Bt(r.point):o?r.point:xe},kl=({afterCritical:e,impact:t,draggables:n})=>{const r=Tn(t);r||(process.env.NODE_ENV,h());const o=r.draggableId,i=n[o].page.borderBox.center,a=Bl({displaced:t.displaced,afterCritical:e,combineWith:o,displacedBy:t.displacedBy});return De(i,a)};const li=(e,t)=>t.margin[e.start]+t.borderBox[e.size]/2,Fl=(e,t)=>t.margin[e.end]+t.borderBox[e.size]/2,xr=(e,t,n)=>t[e.crossAxisStart]+n.margin[e.crossAxisStart]+n.borderBox[e.crossAxisSize]/2,co=({axis:e,moveRelativeTo:t,isMoving:n})=>Et(e.line,t.marginBox[e.end]+li(e,n),xr(e,t.marginBox,n)),uo=({axis:e,moveRelativeTo:t,isMoving:n})=>Et(e.line,t.marginBox[e.start]-Fl(e,n),xr(e,t.marginBox,n)),_l=({axis:e,moveInto:t,isMoving:n})=>Et(e.line,t.contentBox[e.start]+li(e,n),xr(e,t.contentBox,n));var Ll=({impact:e,draggable:t,draggables:n,droppable:r,afterCritical:o})=>{const i=Ct(r.descriptor.id,n),a=t.page,l=r.axis;if(!i.length)return _l({axis:l,moveInto:r.page,isMoving:a});const{displaced:u,displacedBy:c}=e,f=u.all[0];if(f){const d=n[f];if(bt(f,o))return uo({axis:l,moveRelativeTo:d.page,isMoving:a});const m=xn(d.page,c.point);return uo({axis:l,moveRelativeTo:m,isMoving:a})}const p=i[i.length-1];if(p.descriptor.id===t.descriptor.id)return a.borderBox.center;if(bt(p.descriptor.id,o)){const d=xn(p.page,Bt(o.displacedBy.point));return co({axis:l,moveRelativeTo:d,isMoving:a})}return co({axis:l,moveRelativeTo:p.page,isMoving:a})},tr=(e,t)=>{const n=e.frame;return n?De(t,n.scroll.diff.displacement):t};const Vl=({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"?Ll({impact:e,draggable:t,draggables:r,droppable:n,afterCritical:o}):kl({impact:e,draggables:r,afterCritical:o})};var Bn=e=>{const t=Vl(e),n=e.droppable;return n?tr(n,t):t},ci=(e,t)=>{const n=ke(t,e.scroll.initial),r=Bt(n);return{frame:He({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 po(e,t){return e.map(n=>t[n])}function Ml(e,t){for(let n=0;n<t.length;n++){const r=t[n].visible[e];if(r)return r}return null}var Gl=({impact:e,viewport:t,destination:n,draggables:r,maxScrollChange:o})=>{const i=ci(t,De(t.scroll.current,o)),a=n.frame?gr(n,De(n.frame.scroll.current,o)):n,l=e.displaced,u=Xt({afterDragging:po(l.all,r),destination:n,displacedBy:e.displacedBy,viewport:i.frame,last:l,forceShouldAnimate:!1}),c=Xt({afterDragging:po(l.all,r),destination:a,displacedBy:e.displacedBy,viewport:t.frame,last:l,forceShouldAnimate:!1}),f={},p={},d=[l,u,c];return l.all.forEach(g=>{const y=Ml(g,d);if(y){p[g]=y;return}f[g]=!0}),{...e,displaced:{all:l.all,invisible:f,visible:p}}},Wl=(e,t)=>De(e.scroll.diff.displacement,t),Dr=({pageBorderBoxCenter:e,draggable:t,viewport:n})=>{const r=Wl(n,e),o=ke(r,t.page.borderBox.center);return De(t.client.borderBox.center,o)},di=({draggable:e,destination:t,newPageBorderBoxCenter:n,viewport:r,withDroppableDisplacement:o,onlyOnMainAxis:i=!1})=>{const a=ke(n,e.page.borderBox.center),u={target:an(e.page.borderBox,a),destination:t,withDroppableDisplacement:o,viewport:r};return i?Sl(u):si(u)},zl=({isMovingForward:e,draggable:t,destination:n,draggables:r,previousImpact:o,viewport:i,previousPageBorderBoxCenter:a,previousClientSelection:l,afterCritical:u})=>{if(!n.isEnabled)return null;const c=Ct(n.descriptor.id,r),f=kt(t,n),p=vl({isMovingForward:e,draggable:t,destination:n,insideDestination:c,previousImpact:o})||$l({isMovingForward:e,isInHomeList:f,draggable:t,draggables:r,destination:n,insideDestination:c,previousImpact:o,viewport:i,afterCritical:u});if(!p)return null;const d=Bn({impact:p,draggable:t,droppable:n,draggables:r,afterCritical:u});if(di({draggable:t,destination:n,newPageBorderBoxCenter:d,viewport:i.frame,withDroppableDisplacement:!1,onlyOnMainAxis:!0}))return{clientSelection:Dr({pageBorderBoxCenter:d,draggable:t,viewport:i}),impact:p,scrollJumpRequest:null};const g=ke(d,a),y=Gl({impact:p,viewport:i,destination:n,draggables:r,maxScrollChange:g});return{clientSelection:l,impact:y,scrollJumpRequest:g}};const Pe=e=>{const t=e.subject.active;return t||(process.env.NODE_ENV!=="production"?h(!1,"Cannot get clipped area from droppable"):h()),t};var Hl=({isMovingForward:e,pageBorderBoxCenter:t,source:n,droppables:r,viewport:o})=>{const i=n.subject.active;if(!i)return null;const a=n.axis,l=Ge(i[a.start],i[a.end]),u=Rn(r).filter(f=>f!==n).filter(f=>f.isEnabled).filter(f=>!!f.subject.active).filter(f=>ii(o.frame)(Pe(f))).filter(f=>{const p=Pe(f);return e?i[a.crossAxisEnd]<p[a.crossAxisEnd]:p[a.crossAxisStart]<i[a.crossAxisStart]}).filter(f=>{const p=Pe(f),d=Ge(p[a.start],p[a.end]);return l(p[a.start])||l(p[a.end])||d(i[a.start])||d(i[a.end])}).sort((f,p)=>{const d=Pe(f)[a.crossAxisStart],m=Pe(p)[a.crossAxisStart];return e?d-m:m-d}).filter((f,p,d)=>Pe(f)[a.crossAxisStart]===Pe(d[0])[a.crossAxisStart]);if(!u.length)return null;if(u.length===1)return u[0];const c=u.filter(f=>Ge(Pe(f)[a.start],Pe(f)[a.end])(t[a.line]));return c.length===1?c[0]:c.length>1?c.sort((f,p)=>Pe(f)[a.start]-Pe(p)[a.start])[0]:u.sort((f,p)=>{const d=ao(t,so(Pe(f))),m=ao(t,so(Pe(p)));return d!==m?d-m:Pe(f)[a.start]-Pe(p)[a.start]})[0]};const fo=(e,t)=>{const n=e.page.borderBox.center;return bt(e.descriptor.id,t)?ke(n,t.displacedBy.point):n},Ul=(e,t)=>{const n=e.page.borderBox;return bt(e.descriptor.id,t)?an(n,Bt(t.displacedBy.point)):n};var jl=({pageBorderBoxCenter:e,viewport:t,destination:n,insideDestination:r,afterCritical:o})=>r.filter(a=>si({target:Ul(a,o),destination:n,viewport:t.frame,withDroppableDisplacement:!0})).sort((a,l)=>{const u=Yt(e,tr(n,fo(a,o))),c=Yt(e,tr(n,fo(l,o)));return u<c?-1:c<u?1:a.descriptor.index-l.descriptor.index})[0]||null,sn=ve(function(t,n){const r=n[t.line];return{value:r,point:Et(t.line,r)}});const ql=(e,t,n)=>{const r=e.axis;if(e.descriptor.mode==="virtual")return Et(r.line,t[r.line]);const o=e.subject.page.contentBox[r.size],u=Ct(e.descriptor.id,n).reduce((c,f)=>c+f.client.marginBox[r.size],0)+t[r.line]-o;return u<=0?null:Et(r.line,u)},ui=(e,t)=>({...e,scroll:{...e.scroll,max:t}}),pi=(e,t,n)=>{const r=e.frame;kt(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=sn(e.axis,t.displaceBy).point,i=ql(e,o,n),a={placeholderSize:o,increasedBy:i,oldFrameMaxScroll:e.frame?e.frame.scroll.max:null};if(!r){const f=Ot({page:e.subject.page,withPlaceholder:a,axis:e.axis,frame:e.frame});return{...e,subject:f}}const l=i?De(r.scroll.max,i):r.scroll.max,u=ui(r,l),c=Ot({page:e.subject.page,withPlaceholder:a,axis:e.axis,frame:u});return{...e,subject:c,frame:u}},Kl=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=Ot({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=ui(n,r),i=Ot({page:e.subject.page,axis:e.axis,frame:o,withPlaceholder:null});return{...e,subject:i,frame:o}};var Yl=({previousPageBorderBoxCenter:e,moveRelativeTo:t,insideDestination:n,draggable:r,draggables:o,destination:i,viewport:a,afterCritical:l})=>{if(!t){if(n.length)return null;const p={displaced:Jt,displacedBy:oi,at:{type:"REORDER",destination:{droppableId:i.descriptor.id,index:0}}},d=Bn({impact:p,draggable:r,droppable:i,draggables:o,afterCritical:l}),m=kt(r,i)?i:pi(i,r,o);return di({draggable:r,destination:m,newPageBorderBoxCenter:d,viewport:a.frame,withDroppableDisplacement:!1,onlyOnMainAxis:!0})?p:null}const u=e[i.axis.line]<=t.page.borderBox.center[i.axis.line],c=(()=>{const p=t.descriptor.index;return t.descriptor.id===r.descriptor.id||u?p:p+1})(),f=sn(i.axis,r.displaceBy);return wn({draggable:r,insideDestination:n,destination:i,viewport:a,displacedBy:f,last:Jt,index:c})},Jl=({isMovingForward:e,previousPageBorderBoxCenter:t,draggable:n,isOver:r,draggables:o,droppables:i,viewport:a,afterCritical:l})=>{const u=Hl({isMovingForward:e,pageBorderBoxCenter:t,source:r,droppables:i,viewport:a});if(!u)return null;const c=Ct(u.descriptor.id,o),f=jl({pageBorderBoxCenter:t,viewport:a,destination:u,insideDestination:c,afterCritical:l}),p=Yl({previousPageBorderBoxCenter:t,destination:u,draggable:n,draggables:o,moveRelativeTo:f,insideDestination:c,viewport:a,afterCritical:l});if(!p)return null;const d=Bn({impact:p,draggable:n,droppable:u,draggables:o,afterCritical:l});return{clientSelection:Dr({pageBorderBoxCenter:d,draggable:n,viewport:a}),impact:p,scrollJumpRequest:null}},Fe=e=>{const t=e.at;return t?t.type==="REORDER"?t.destination.droppableId:t.combine.droppableId:null};const Xl=(e,t)=>{const n=Fe(e);return n?t[n]:null};var Zl=({state:e,type:t})=>{const n=Xl(e.impact,e.dimensions.droppables),r=!!n,o=e.dimensions.droppables[e.critical.droppable.id],i=n||o,a=i.axis.direction,l=a==="vertical"&&(t==="MOVE_UP"||t==="MOVE_DOWN")||a==="horizontal"&&(t==="MOVE_LEFT"||t==="MOVE_RIGHT");if(l&&!r)return null;const u=t==="MOVE_DOWN"||t==="MOVE_RIGHT",c=e.dimensions.draggables[e.critical.draggable.id],f=e.current.page.borderBoxCenter,{draggables:p,droppables:d}=e.dimensions;return l?zl({isMovingForward:u,previousPageBorderBoxCenter:f,draggable:c,destination:i,draggables:p,viewport:e.viewport,previousClientSelection:e.current.client.selection,previousImpact:e.impact,afterCritical:e.afterCritical}):Jl({isMovingForward:u,previousPageBorderBoxCenter:f,draggable:c,isOver:i,draggables:p,droppables:d,viewport:e.viewport,afterCritical:e.afterCritical})};function Dt(e){return e.phase==="DRAGGING"||e.phase==="COLLECTING"}function fi(e){const t=Ge(e.top,e.bottom),n=Ge(e.left,e.right);return function(o){return t(o.y)&&n(o.x)}}function Ql(e,t){return e.left<t.right&&e.right>t.left&&e.top<t.bottom&&e.bottom>t.top}function ec({pageBorderBox:e,draggable:t,candidates:n}){const r=t.page.borderBox.center,o=n.map(i=>{const a=i.axis,l=Et(i.axis.line,e.center[a.line],i.page.borderBox.center[a.crossAxisLine]);return{id:i.descriptor.id,distance:Yt(r,l)}}).sort((i,a)=>a.distance-i.distance);return o[0]?o[0].id:null}function tc({pageBorderBox:e,draggable:t,droppables:n}){const r=Rn(n).filter(o=>{if(!o.isEnabled)return!1;const i=o.subject.active;if(!i||!Ql(e,i))return!1;if(fi(i)(e.center))return!0;const a=o.axis,l=i.center[a.crossAxisLine],u=e[a.crossAxisStart],c=e[a.crossAxisEnd],f=Ge(i[a.crossAxisStart],i[a.crossAxisEnd]),p=f(u),d=f(c);return!p&&!d?!0:p?u<l:c>l});return r.length?r.length===1?r[0].descriptor.id:ec({pageBorderBox:e,draggable:t,candidates:r}):null}const mi=(e,t)=>He(an(e,t));var nc=(e,t)=>{const n=e.frame;return n?mi(t,n.scroll.diff.value):t};function hi({displaced:e,id:t}){return!!(e.visible[t]||e.invisible[t])}function rc({draggable:e,closest:t,inHomeList:n}){return t?n&&t.descriptor.index>e.descriptor.index?t.descriptor.index-1:t.descriptor.index:null}var oc=({pageBorderBoxWithDroppableScroll:e,draggable:t,destination:n,insideDestination:r,last:o,viewport:i,afterCritical:a})=>{const l=n.axis,u=sn(n.axis,t.displaceBy),c=u.value,f=e[l.start],p=e[l.end],m=$n(t,r).find(y=>{const x=y.descriptor.id,D=y.page.borderBox.center[l.line],E=bt(x,a),P=hi({displaced:o,id:x});return E?P?p<=D:f<D-c:P?p<=D+c:f<D})||null,g=rc({draggable:t,closest:m,inHomeList:kt(t,n)});return wn({draggable:t,insideDestination:r,destination:n,viewport:i,last:o,displacedBy:u,index:g})};const ic=4;var ac=({draggable:e,pageBorderBoxWithDroppableScroll:t,previousImpact:n,destination:r,insideDestination:o,afterCritical:i})=>{if(!r.isCombineEnabled)return null;const a=r.axis,l=sn(r.axis,e.displaceBy),u=l.value,c=t[a.start],f=t[a.end],d=$n(e,o).find(g=>{const y=g.descriptor.id,x=g.page.borderBox,E=x[a.size]/ic,P=bt(y,i),N=hi({displaced:n.displaced,id:y});return P?N?f>x[a.start]+E&&f<x[a.end]-E:c>x[a.start]-u+E&&c<x[a.end]-u-E:N?f>x[a.start]+u+E&&f<x[a.end]+u-E:c>x[a.start]+E&&c<x[a.end]-E});return d?{displacedBy:l,displaced:n.displaced,at:{type:"COMBINE",combine:{draggableId:d.descriptor.id,droppableId:r.descriptor.id}}}:null},gi=({pageOffset:e,draggable:t,draggables:n,droppables:r,previousImpact:o,viewport:i,afterCritical:a})=>{const l=mi(t.page.borderBox,e),u=tc({pageBorderBox:l,draggable:t,droppables:r});if(!u)return xl;const c=r[u],f=Ct(c.descriptor.id,n),p=nc(c,l);return ac({pageBorderBoxWithDroppableScroll:p,draggable:t,previousImpact:o,destination:c,insideDestination:f,afterCritical:a})||oc({pageBorderBoxWithDroppableScroll:p,draggable:t,destination:c,insideDestination:f,last:o.displaced,viewport:i,afterCritical:a})},Er=(e,t)=>({...e,[t.descriptor.id]:t});const sc=({previousImpact:e,impact:t,droppables:n})=>{const r=Fe(e),o=Fe(t);if(!r||r===o)return n;const i=n[r];if(!i.subject.withPlaceholder)return n;const a=Kl(i);return Er(n,a)};var lc=({draggable:e,draggables:t,droppables:n,previousImpact:r,impact:o})=>{const i=sc({previousImpact:r,impact:o,droppables:n}),a=Fe(o);if(!a)return i;const l=n[a];if(kt(e,l)||l.subject.withPlaceholder)return i;const u=pi(l,e,t);return Er(i,u)},Ut=({state:e,clientSelection:t,dimensions:n,viewport:r,impact:o,scrollJumpRequest:i})=>{const a=r||e.viewport,l=n||e.dimensions,u=t||e.current.client.selection,c=ke(u,e.initial.client.selection),f={offset:c,selection:u,borderBoxCenter:De(e.initial.client.borderBoxCenter,c)},p={selection:De(f.selection,a.scroll.current),borderBoxCenter:De(f.borderBoxCenter,a.scroll.current),offset:De(f.offset,a.scroll.diff.value)},d={client:f,page:p};if(e.phase==="COLLECTING")return{...e,dimensions:l,viewport:a,current:d};const m=l.draggables[e.critical.draggable.id],g=o||gi({pageOffset:p.offset,draggable:m,draggables:l.draggables,droppables:l.droppables,previousImpact:e.impact,viewport:a,afterCritical:e.afterCritical}),y=lc({draggable:m,impact:g,previousImpact:e.impact,draggables:l.draggables,droppables:l.droppables});return{...e,current:d,dimensions:{draggables:l.draggables,droppables:y},impact:g,viewport:a,scrollJumpRequest:i||null,forceShouldAnimate:i?!1:null}};function cc(e,t){return e.map(n=>t[n])}var bi=({impact:e,viewport:t,draggables:n,destination:r,forceShouldAnimate:o})=>{const i=e.displaced,a=cc(i.all,n),l=Xt({afterDragging:a,destination:r,displacedBy:e.displacedBy,viewport:t.frame,forceShouldAnimate:o,last:i});return{...e,displaced:l}},yi=({impact:e,draggable:t,droppable:n,draggables:r,viewport:o,afterCritical:i})=>{const a=Bn({impact:e,draggable:t,draggables:r,droppable:n,afterCritical:i});return Dr({pageBorderBoxCenter:a,draggable:t,viewport:o})},vi=({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:l}=i,u=a[e.critical.draggable.id],c=Fe(r);c||(process.env.NODE_ENV!=="production"?h(!1,"Must be over a destination in SNAP movement mode"):h());const f=l[c],p=bi({impact:r,viewport:o,destination:f,draggables:a}),d=yi({impact:p,draggable:u,droppable:f,draggables:a,viewport:o,afterCritical:e.afterCritical});return Ut({impact:p,clientSelection:d,state:e,dimensions:i,viewport:o})},dc=e=>({index:e.index,droppableId:e.droppableId}),xi=({draggable:e,home:t,draggables:n,viewport:r})=>{const o=sn(t.axis,e.displaceBy),i=Ct(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 l=i.slice(a+1),u=l.reduce((d,m)=>(d[m.descriptor.id]=!0,d),{}),c={inVirtualList:t.descriptor.mode==="virtual",displacedBy:o,effected:u};return{impact:{displaced:Xt({afterDragging:l,destination:t,displacedBy:o,last:null,viewport:r.frame,forceShouldAnimate:!1}),displacedBy:o,at:{type:"REORDER",destination:dc(e.descriptor)}},afterCritical:c}},uc=(e,t)=>({draggables:e.draggables,droppables:Er(e.droppables,t)});const ln=e=>{process.env.NODE_ENV},cn=e=>{process.env.NODE_ENV};var pc=({draggable:e,offset:t,initialWindowScroll:n})=>{const r=xn(e.client,t),o=Dn(r,n);return{...e,placeholder:{...e.placeholder,client:r},client:r,page:o}},fc=e=>{const t=e.frame;return t||(process.env.NODE_ENV!=="production"?h(!1,"Expected Droppable to have a frame"):h()),t},mc=({additions:e,updatedDroppables:t,viewport:n})=>{const r=n.scroll.diff.value;return e.map(o=>{const i=o.descriptor.droppableId,a=t[i],u=fc(a).scroll.diff.value,c=De(r,u);return pc({draggable:o,offset:c,initialWindowScroll:n.scroll.initial})})},hc=({state:e,published:t})=>{ln();const n=t.modified.map(D=>{const E=e.dimensions.droppables[D.droppableId];return gr(E,D.scroll)}),r={...e.dimensions.droppables,...ni(n)},o=ri(mc({additions:t.additions,updatedDroppables:r,viewport:e.viewport})),i={...e.dimensions.draggables,...o};t.removals.forEach(D=>{delete i[D]});const a={droppables:r,draggables:i},l=Fe(e.impact),u=l?a.droppables[l]:null,c=a.draggables[e.critical.draggable.id],f=a.droppables[e.critical.droppable.id],{impact:p,afterCritical:d}=xi({draggable:c,home:f,draggables:i,viewport:e.viewport}),m=u&&u.isCombineEnabled?e.impact:p,g=gi({pageOffset:e.current.page.offset,draggable:a.draggables[e.critical.draggable.id],draggables:a.draggables,droppables:a.droppables,previousImpact:m,viewport:e.viewport,afterCritical:d});cn();const y={...e,phase:"DRAGGING",impact:g,onLiftImpact:p,dimensions:a,afterCritical:d,forceShouldAnimate:!1};return e.phase==="COLLECTING"?y:{...y,phase:"DROP_PENDING",reason:e.reason,isWaiting:!1}};const nr=e=>e.movementMode==="SNAP",Wn=(e,t,n)=>{const r=uc(e.dimensions,t);return!nr(e)||n?Ut({state:e,dimensions:r}):vi({state:e,dimensions:r})};function zn(e){return e.isDragging&&e.movementMode==="SNAP"?{...e,scrollJumpRequest:null}:e}const mo={phase:"IDLE",completed:null,shouldFlush:!1};var gc=(e=mo,t)=>{if(t.type==="FLUSH")return{...mo,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,l=i.draggables[n.draggable.id],u=i.droppables[n.droppable.id],c={selection:r,borderBoxCenter:l.client.borderBox.center,offset:xe},f={client:c,page:{selection:De(c.selection,o.scroll.initial),borderBoxCenter:De(c.selection,o.scroll.initial),offset:De(c.selection,o.scroll.diff.value)}},p=Rn(i.droppables).every(y=>!y.isFixedOnPage),{impact:d,afterCritical:m}=xi({draggable:l,home:u,draggables:i.draggables,viewport:o});return{phase:"DRAGGING",isDragging:!0,critical:n,movementMode:a,dimensions:i,initial:f,current:f,isWindowScrollAllowed:p,impact:d,afterCritical:m,onLiftImpact:d,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()),hc({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 ht(n,e.current.client.selection)?e:Ut({state:e,clientSelection:n,impact:nr(e)?e.impact:null})}if(t.type==="UPDATE_DROPPABLE_SCROLL"){if(e.phase==="DROP_PENDING"||e.phase==="COLLECTING")return zn(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=gr(o,r);return Wn(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 Wn(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 Wn(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(ht(e.viewport.scroll.current,n))return zn(e);const r=ci(e.viewport,n);return nr(e)?vi({state:e,viewport:r}):Ut({state:e,viewport:r})}if(t.type==="UPDATE_VIEWPORT_MAX_SCROLL"){if(!Dt(e))return e;const n=t.payload.maxScroll;if(ht(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=Zl({state:e,type:t.type});return n?Ut({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 Y(e,t){return e instanceof Object&&"type"in e&&e.type===t}const bc=e=>({type:"BEFORE_INITIAL_CAPTURE",payload:e}),yc=e=>({type:"LIFT",payload:e}),vc=e=>({type:"INITIAL_PUBLISH",payload:e}),xc=e=>({type:"PUBLISH_WHILE_DRAGGING",payload:e}),Dc=()=>({type:"COLLECTION_STARTING",payload:null}),Ec=e=>({type:"UPDATE_DROPPABLE_SCROLL",payload:e}),wc=e=>({type:"UPDATE_DROPPABLE_IS_ENABLED",payload:e}),Ic=e=>({type:"UPDATE_DROPPABLE_IS_COMBINE_ENABLED",payload:e}),Di=e=>({type:"MOVE",payload:e}),Cc=e=>({type:"MOVE_BY_WINDOW_SCROLL",payload:e}),Nc=e=>({type:"UPDATE_VIEWPORT_MAX_SCROLL",payload:e}),Sc=()=>({type:"MOVE_UP",payload:null}),Oc=()=>({type:"MOVE_DOWN",payload:null}),Pc=()=>({type:"MOVE_RIGHT",payload:null}),Ac=()=>({type:"MOVE_LEFT",payload:null}),wr=()=>({type:"FLUSH",payload:null}),Rc=e=>({type:"DROP_ANIMATE",payload:e}),Ir=e=>({type:"DROP_COMPLETE",payload:e}),Ei=e=>({type:"DROP",payload:e}),Tc=e=>({type:"DROP_PENDING",payload:e}),wi=()=>({type:"DROP_ANIMATION_FINISHED",payload:null});function $c(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"&&ie(`
|
|
49
|
+
Detected non-consecutive <Draggable /> indexes.
|
|
50
|
+
|
|
51
|
+
(This can cause unexpected bugs)
|
|
52
|
+
|
|
53
|
+
${r}
|
|
54
|
+
`)}function Bc(e,t){if(process.env.NODE_ENV!=="production"){const n=Ct(e.droppable.id,t.draggables);$c(n)}}var kc=e=>({getState:t,dispatch:n})=>r=>o=>{if(!Y(o,"LIFT")){r(o);return}const{id:i,clientSelection:a,movementMode:l}=o.payload,u=t();u.phase==="DROP_ANIMATING"&&n(Ir({completed:u.completed})),t().phase!=="IDLE"&&(process.env.NODE_ENV!=="production"?h(!1,"Unexpected phase to start a drag"):h()),n(wr()),n(bc({draggableId:i,movementMode:l}));const f={draggableId:i,scrollOptions:{shouldPublishImmediately:l==="SNAP"}},{critical:p,dimensions:d,viewport:m}=e.startPublishing(f);Bc(p,d),n(vc({critical:p,dimensions:d,clientSelection:a,movementMode:l,viewport:m}))},Fc=e=>()=>t=>n=>{Y(n,"INITIAL_PUBLISH")&&e.dragging(),Y(n,"DROP_ANIMATE")&&e.dropping(n.payload.completed.result.reason),(Y(n,"FLUSH")||Y(n,"DROP_COMPLETE"))&&e.resting(),t(n)};const Cr={outOfTheWay:"cubic-bezier(0.2, 0, 0, 1)",drop:"cubic-bezier(.2,1,.1,1)"},Zt={opacity:{drop:0,combining:.7},scale:{drop:.75}},Ii={outOfTheWay:.2,minDropTime:.33,maxDropTime:.55},xt=`${Ii.outOfTheWay}s ${Cr.outOfTheWay}`,jt={fluid:`opacity ${xt}`,snap:`transform ${xt}, opacity ${xt}`,drop:e=>{const t=`${e}s ${Cr.drop}`;return`transform ${t}, opacity ${t}`},outOfTheWay:`transform ${xt}`,placeholder:`height ${xt}, width ${xt}, margin ${xt}`},ho=e=>ht(e,xe)?void 0:`translate(${e.x}px, ${e.y}px)`,rr={moveTo:ho,drop:(e,t)=>{const n=ho(e);if(n)return t?`${n} scale(${Zt.scale.drop})`:n}},{minDropTime:or,maxDropTime:Ci}=Ii,_c=Ci-or,go=1500,Lc=.6;var Vc=({current:e,destination:t,reason:n})=>{const r=Yt(e,t);if(r<=0)return or;if(r>=go)return Ci;const o=r/go,i=or+_c*o,a=n==="CANCEL"?i*Lc:i;return Number(a.toFixed(2))},Mc=({impact:e,draggable:t,dimensions:n,viewport:r,afterCritical:o})=>{const{draggables:i,droppables:a}=n,l=Fe(e),u=l?a[l]:null,c=a[t.descriptor.droppableId],f=yi({impact:e,draggable:t,draggables:i,afterCritical:o,droppable:u||c,viewport:r});return ke(f,t.client.borderBox.center)},Gc=({draggables:e,reason:t,lastImpact:n,home:r,viewport:o,onLiftImpact:i})=>!n.at||t!=="DROP"?{impact:bi({draggables:e,impact:i,destination:r,viewport:o,forceShouldAnimate:!0}),didDropInsideDroppable:!1}:n.at.type==="REORDER"?{impact:n,didDropInsideDroppable:!0}:{impact:{...n,displaced:Jt},didDropInsideDroppable:!0};const Wc=({getState:e,dispatch:t})=>n=>r=>{if(!Y(r,"DROP")){n(r);return}const o=e(),i=r.payload.reason;if(o.phase==="COLLECTING"){t(Tc({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 l=o.critical,u=o.dimensions,c=u.draggables[o.critical.draggable.id],{impact:f,didDropInsideDroppable:p}=Gc({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}),d=p?br(f):null,m=p?Tn(f):null,g={index:l.draggable.index,droppableId:l.droppable.id},y={draggableId:c.descriptor.id,type:c.descriptor.type,source:g,reason:i,mode:o.movementMode,destination:d,combine:m},x=Mc({impact:f,draggable:c,dimensions:u,viewport:o.viewport,afterCritical:o.afterCritical}),D={critical:o.critical,afterCritical:o.afterCritical,result:y,impact:f};if(!(!ht(o.current.client.offset,x)||!!y.combine)){t(Ir({completed:D}));return}const P=Vc({current:o.current.client.offset,destination:x,reason:i});t(Rc({newHomeClientOffset:x,dropDuration:P,completed:D}))};var Ni=()=>({x:window.pageXOffset,y:window.pageYOffset});function zc(e){return{eventName:"scroll",options:{passive:!0,capture:!1},fn:t=>{t.target!==window&&t.target!==window.document||e()}}}function Hc({onWindowScroll:e}){function t(){e(Ni())}const n=qt(t),r=zc(n);let o=mt;function i(){return o!==mt}function a(){i()&&(process.env.NODE_ENV!=="production"?h(!1,"Cannot start scroll listener when already active"):h()),o=Me(window,[r])}function l(){i()||(process.env.NODE_ENV!=="production"?h(!1,"Cannot stop scroll listener when not active"):h()),n.cancel(),o(),o=mt}return{start:a,stop:l,isActive:i}}const Uc=e=>Y(e,"DROP_COMPLETE")||Y(e,"DROP_ANIMATE")||Y(e,"FLUSH"),jc=e=>{const t=Hc({onWindowScroll:n=>{e.dispatch(Cc({newScroll:n}))}});return n=>r=>{!t.isActive()&&Y(r,"INITIAL_PUBLISH")&&t.start(),t.isActive()&&Uc(r)&&t.stop(),n(r)}};var qc=e=>{let t=!1,n=!1;const r=setTimeout(()=>{n=!0}),o=i=>{if(t){process.env.NODE_ENV!=="production"&&ie("Announcement already made. Not making a second announcement");return}if(n){process.env.NODE_ENV!=="production"&&ie(`
|
|
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},Kc=()=>{const e=[],t=o=>{const i=e.findIndex(l=>l.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 Yc=(e,t)=>e==null&&t==null?!0:e==null||t==null?!1:e.droppableId===t.droppableId&&e.index===t.index,Jc=(e,t)=>e==null&&t==null?!0:e==null||t==null?!1:e.draggableId===t.draggableId&&e.droppableId===t.droppableId,Xc=(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},Gt=(e,t)=>{ln(),t(),cn()},hn=(e,t)=>({draggableId:e.draggable.id,type:e.droppable.type,source:{droppableId:e.droppable.id,index:e.draggable.index},mode:t});function Hn(e,t,n,r){if(!e){n(r(t));return}const o=qc(n);e(t,{announce:o}),o.wasCalled()||n(r(t))}var Zc=(e,t)=>{const n=Kc();let r=null;const o=(p,d)=>{r&&(process.env.NODE_ENV!=="production"?h(!1,"Cannot fire onBeforeCapture as a drag start has already been published"):h()),Gt("onBeforeCapture",()=>{const m=e().onBeforeCapture;m&&m({draggableId:p,mode:d})})},i=(p,d)=>{r&&(process.env.NODE_ENV!=="production"?h(!1,"Cannot fire onBeforeDragStart as a drag start has already been published"):h()),Gt("onBeforeDragStart",()=>{const m=e().onBeforeDragStart;m&&m(hn(p,d))})},a=(p,d)=>{r&&(process.env.NODE_ENV!=="production"?h(!1,"Cannot fire onBeforeDragStart as a drag start has already been published"):h());const m=hn(p,d);r={mode:d,lastCritical:p,lastLocation:m.source,lastCombine:null},n.add(()=>{Gt("onDragStart",()=>Hn(e().onDragStart,m,t,yn.onDragStart))})},l=(p,d)=>{const m=br(d),g=Tn(d);r||(process.env.NODE_ENV!=="production"?h(!1,"Cannot fire onDragMove when onDragStart has not been called"):h());const y=!Xc(p,r.lastCritical);y&&(r.lastCritical=p);const x=!Yc(r.lastLocation,m);x&&(r.lastLocation=m);const D=!Jc(r.lastCombine,g);if(D&&(r.lastCombine=g),!y&&!x&&!D)return;const E={...hn(p,r.mode),combine:g,destination:m};n.add(()=>{Gt("onDragUpdate",()=>Hn(e().onDragUpdate,E,t,yn.onDragUpdate))})},u=()=>{r||(process.env.NODE_ENV!=="production"?h(!1,"Can only flush responders while dragging"):h()),n.flush()},c=p=>{r||(process.env.NODE_ENV!=="production"?h(!1,"Cannot fire onDragEnd when there is no matching onDragStart"):h()),r=null,Gt("onDragEnd",()=>Hn(e().onDragEnd,p,t,yn.onDragEnd))};return{beforeCapture:o,beforeStart:i,start:a,update:l,flush:u,drop:c,abort:()=>{if(!r)return;const p={...hn(r.lastCritical,r.mode),combine:null,destination:null,reason:"CANCEL"};c(p)}}},Qc=(e,t)=>{const n=Zc(e,t);return r=>o=>i=>{if(Y(i,"BEFORE_INITIAL_CAPTURE")){n.beforeCapture(i.payload.draggableId,i.payload.movementMode);return}if(Y(i,"INITIAL_PUBLISH")){const l=i.payload.critical;n.beforeStart(l,i.payload.movementMode),o(i),n.start(l,i.payload.movementMode);return}if(Y(i,"DROP_COMPLETE")){const l=i.payload.completed.result;n.flush(),o(i),n.drop(l);return}if(o(i),Y(i,"FLUSH")){n.abort();return}const a=r.getState();a.phase==="DRAGGING"&&n.update(a.critical,a.impact)}};const ed=e=>t=>n=>{if(!Y(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(Ir({completed:r.completed}))},td=e=>{let t=null,n=null;function r(){n&&(cancelAnimationFrame(n),n=null),t&&(t(),t=null)}return o=>i=>{if((Y(i,"FLUSH")||Y(i,"DROP_COMPLETE")||Y(i,"DROP_ANIMATION_FINISHED"))&&r(),o(i),!Y(i,"DROP_ANIMATE"))return;const a={eventName:"scroll",options:{capture:!0,passive:!1,once:!0},fn:function(){e.getState().phase==="DROP_ANIMATING"&&e.dispatch(wi())}};n=requestAnimationFrame(()=>{n=null,t=Me(window,[a])})}};var nd=e=>()=>t=>n=>{(Y(n,"DROP_COMPLETE")||Y(n,"FLUSH")||Y(n,"DROP_ANIMATE"))&&e.stopPublishing(),t(n)},rd=e=>{let t=!1;return()=>n=>r=>{if(Y(r,"INITIAL_PUBLISH")){t=!0,e.tryRecordFocus(r.payload.critical.draggable.id),n(r),e.tryRestoreFocusRecorded();return}if(n(r),!!t){if(Y(r,"FLUSH")){t=!1,e.tryRestoreFocusRecorded();return}if(Y(r,"DROP_COMPLETE")){t=!1;const o=r.payload.completed.result;o.combine&&e.tryShiftRecord(o.draggableId,o.combine.draggableId),e.tryRestoreFocusRecorded()}}}};const od=e=>Y(e,"DROP_COMPLETE")||Y(e,"DROP_ANIMATE")||Y(e,"FLUSH");var id=e=>t=>n=>r=>{if(od(r)){e.stop(),n(r);return}if(Y(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 ad=e=>t=>n=>{if(t(n),!Y(n,"PUBLISH_WHILE_DRAGGING"))return;const r=e.getState();r.phase==="DROP_PENDING"&&(r.isWaiting||e.dispatch(Ei({reason:r.reason})))},sd=process.env.NODE_ENV!=="production"&&typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({name:"@hello-pangea/dnd"}):Aa;var ld=({dimensionMarshal:e,focusMarshal:t,styleMarshal:n,getResponders:r,announce:o,autoScroller:i})=>Pa(gc,sd(Ra(Fc(n),nd(e),kc(e),Wc,ed,td,ad,id(i),jc,rd(t),Qc(r,o))));const Un=()=>({additions:{},removals:{},modified:{}});function cd({registry:e,callbacks:t}){let n=Un(),r=null;const o=()=>{r||(t.collectionStarting(),r=requestAnimationFrame(()=>{r=null,ln();const{additions:u,removals:c,modified:f}=n,p=Object.keys(u).map(g=>e.draggable.getById(g).getDimension(xe)).sort((g,y)=>g.descriptor.index-y.descriptor.index),d=Object.keys(f).map(g=>{const x=e.droppable.getById(g).callbacks.getScrollWhileDragging();return{droppableId:g,scroll:x}}),m={additions:p,removals:Object.keys(c),modified:d};n=Un(),cn(),t.publish(m)}))};return{add:u=>{const c=u.descriptor.id;n.additions[c]=u,n.modified[u.descriptor.droppableId]=!0,n.removals[c]&&delete n.removals[c],o()},remove:u=>{const c=u.descriptor;n.removals[c.id]=!0,n.modified[c.droppableId]=!0,n.additions[c.id]&&delete n.additions[c.id],o()},stop:()=>{r&&(cancelAnimationFrame(r),r=null,n=Un())}}}var Si=({scrollHeight:e,scrollWidth:t,height:n,width:r})=>{const o=ke({x:t,y:e},{x:r,y:n});return{x:Math.max(0,o.x),y:Math.max(0,o.y)}},Oi=()=>{const e=document.documentElement;return e||(process.env.NODE_ENV!=="production"?h(!1,"Cannot find document.documentElement"):h()),e},Pi=()=>{const e=Oi();return Si({scrollHeight:e.scrollHeight,scrollWidth:e.scrollWidth,width:e.clientWidth,height:e.clientHeight})},dd=()=>{const e=Ni(),t=Pi(),n=e.y,r=e.x,o=Oi(),i=o.clientWidth,a=o.clientHeight,l=r+i,u=n+a;return{frame:He({top:n,left:r,right:l,bottom:u}),scroll:{initial:e,current:e,max:t,diff:{value:xe,displacement:xe}}}},ud=({critical:e,scrollOptions:t,registry:n})=>{ln();const r=dd(),o=r.scroll.current,i=e.droppable,a=n.droppable.getAllByType(i.type).map(f=>f.callbacks.getDimensionAndWatchScroll(o,t)),l=n.draggable.getAllByType(e.draggable.type).map(f=>f.getDimension(o)),u={draggables:ri(l),droppables:ni(a)};return cn(),{dimensions:u,critical:e,viewport:r}};function bo(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"&&ie(`
|
|
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 pd=(e,t)=>{let n=null;const r=cd({callbacks:{publish:t.publishWhileDragging,collectionStarting:t.collectionStarting},registry:e}),o=(d,m)=>{e.droppable.exists(d)||(process.env.NODE_ENV!=="production"?h(!1,`Cannot update is enabled flag of Droppable ${d} as it is not registered`):h()),n&&t.updateDroppableIsEnabled({id:d,isEnabled:m})},i=(d,m)=>{n&&(e.droppable.exists(d)||(process.env.NODE_ENV!=="production"?h(!1,`Cannot update isCombineEnabled flag of Droppable ${d} as it is not registered`):h()),t.updateDroppableIsCombineEnabled({id:d,isCombineEnabled:m}))},a=(d,m)=>{n&&(e.droppable.exists(d)||(process.env.NODE_ENV!=="production"?h(!1,`Cannot update the scroll on Droppable ${d} as it is not registered`):h()),t.updateDroppableScroll({id:d,newScroll:m}))},l=(d,m)=>{n&&e.droppable.getById(d).callbacks.scroll(m)},u=()=>{if(!n)return;r.stop();const d=n.critical.droppable;e.droppable.getAllByType(d.type).forEach(m=>m.callbacks.dragStopped()),n.unsubscribe(),n=null},c=d=>{n||(process.env.NODE_ENV!=="production"?h(!1,"Should only be subscribed when a collection is occurring"):h());const m=n.critical.draggable;d.type==="ADDITION"&&bo(e,m,d.value)&&r.add(d.value),d.type==="REMOVAL"&&bo(e,m,d.value)&&r.remove(d.value)};return{updateDroppableIsEnabled:o,updateDroppableIsCombineEnabled:i,scrollDroppable:l,updateDroppableScroll:a,startPublishing:d=>{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(d.draggableId),g=e.droppable.getById(m.descriptor.droppableId),y={draggable:m.descriptor,droppable:g.descriptor},x=e.subscribe(c);return n={critical:y,unsubscribe:x},ud({critical:y,registry:e,scrollOptions:d.scrollOptions})},stopPublishing:u}},Ai=(e,t)=>e.phase==="IDLE"?!0:e.phase!=="DROP_ANIMATING"||e.completed.result.draggableId===t?!1:e.completed.result.reason==="DROP",fd=e=>{window.scrollBy(e.x,e.y)};const md=ve(e=>Rn(e).filter(t=>!(!t.isEnabled||!t.frame))),hd=(e,t)=>md(t).find(r=>(r.frame||(process.env.NODE_ENV!=="production"?h(!1,"Invalid result"):h()),fi(r.frame.pageMarginBox)(e)))||null;var gd=({center:e,destination:t,droppables:n})=>{if(t){const o=n[t];return o.frame?o:null}return hd(e,n)};const Qt={startFromPercentage:.25,maxScrollAtPercentage:.05,maxPixelScroll:28,ease:e=>e**2,durationDampening:{stopDampeningAt:1200,accelerateAt:360},disabled:!1};var bd=(e,t,n=()=>Qt)=>{const r=n(),o=e[t.size]*r.startFromPercentage,i=e[t.size]*r.maxScrollAtPercentage;return{startScrollingFrom:o,maxScrollValueAt:i}},Ri=({startOfRange:e,endOfRange:t,current:n})=>{const r=t-e;return r===0?(process.env.NODE_ENV!=="production"&&ie(`
|
|
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},Nr=1,yd=(e,t,n=()=>Qt)=>{const r=n();if(e>t.startScrollingFrom)return 0;if(e<=t.maxScrollValueAt)return r.maxPixelScroll;if(e===t.startScrollingFrom)return Nr;const i=1-Ri({startOfRange:t.maxScrollValueAt,endOfRange:t.startScrollingFrom,current:e}),a=r.maxPixelScroll*r.ease(i);return Math.ceil(a)},vd=(e,t,n)=>{const r=n(),o=r.durationDampening.accelerateAt,i=r.durationDampening.stopDampeningAt,a=t,l=i,c=Date.now()-a;if(c>=i)return e;if(c<o)return Nr;const f=Ri({startOfRange:o,endOfRange:l,current:c}),p=e*r.ease(f);return Math.ceil(p)},yo=({distanceToEdge:e,thresholds:t,dragStartTime:n,shouldUseTimeDampening:r,getAutoScrollerOptions:o})=>{const i=yd(e,t,o);return i===0?0:r?Math.max(vd(i,n,o),Nr):i},vo=({container:e,distanceToEdges:t,dragStartTime:n,axis:r,shouldUseTimeDampening:o,getAutoScrollerOptions:i})=>{const a=bd(e,r,i);return t[r.end]<t[r.start]?yo({distanceToEdge:t[r.end],thresholds:a,dragStartTime:n,shouldUseTimeDampening:o,getAutoScrollerOptions:i}):-1*yo({distanceToEdge:t[r.start],thresholds:a,dragStartTime:n,shouldUseTimeDampening:o,getAutoScrollerOptions:i})},xd=({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 Dd=ti(e=>e===0?0:e);var Ti=({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},l=vo({container:t,distanceToEdges:a,dragStartTime:e,axis:yr,shouldUseTimeDampening:o,getAutoScrollerOptions:i}),u=vo({container:t,distanceToEdges:a,dragStartTime:e,axis:ai,shouldUseTimeDampening:o,getAutoScrollerOptions:i}),c=Dd({x:u,y:l});if(ht(c,xe))return null;const f=xd({container:t,subject:n,proposedScroll:c});return f?ht(f,xe)?null:f:null};const Ed=ti(e=>e===0?0:e>0?1:-1),Sr=(()=>{const e=(t,n)=>t<0?t:t>n?t-n:0;return({current:t,max:n,change:r})=>{const o=De(t,r),i={x:e(o.x,n.x),y:e(o.y,n.y)};return ht(i,xe)?null:i}})(),$i=({max:e,current:t,change:n})=>{const r={x:Math.max(t.x,e.x),y:Math.max(t.y,e.y)},o=Ed(n),i=Sr({max:r,current:t,change:o});return!i||o.x!==0&&i.x===0||o.y!==0&&i.y===0},Or=(e,t)=>$i({current:e.scroll.current,max:e.scroll.max,change:t}),wd=(e,t)=>{if(!Or(e,t))return null;const n=e.scroll.max,r=e.scroll.current;return Sr({current:r,max:n,change:t})},Pr=(e,t)=>{const n=e.frame;return n?$i({current:n.scroll.current,max:n.scroll.max,change:t}):!1},Id=(e,t)=>{const n=e.frame;return!n||!Pr(e,t)?null:Sr({current:n.scroll.current,max:n.scroll.max,change:t})};var Cd=({viewport:e,subject:t,center:n,dragStartTime:r,shouldUseTimeDampening:o,getAutoScrollerOptions:i})=>{const a=Ti({dragStartTime:r,container:e.frame,subject:t,center:n,shouldUseTimeDampening:o,getAutoScrollerOptions:i});return a&&Or(e,a)?a:null},Nd=({droppable:e,subject:t,center:n,dragStartTime:r,shouldUseTimeDampening:o,getAutoScrollerOptions:i})=>{const a=e.frame;if(!a)return null;const l=Ti({dragStartTime:r,container:a.pageMarginBox,subject:t,center:n,shouldUseTimeDampening:o,getAutoScrollerOptions:i});return l&&Pr(e,l)?l:null},xo=({state:e,dragStartTime:t,shouldUseTimeDampening:n,scrollWindow:r,scrollDroppable:o,getAutoScrollerOptions:i})=>{const a=e.current.page.borderBoxCenter,u=e.dimensions.draggables[e.critical.draggable.id].page.marginBox;if(e.isWindowScrollAllowed){const p=e.viewport,d=Cd({dragStartTime:t,viewport:p,subject:u,center:a,shouldUseTimeDampening:n,getAutoScrollerOptions:i});if(d){r(d);return}}const c=gd({center:a,destination:Fe(e.impact),droppables:e.dimensions.droppables});if(!c)return;const f=Nd({dragStartTime:t,droppable:c,subject:u,center:a,shouldUseTimeDampening:n,getAutoScrollerOptions:i});f&&o(c.descriptor.id,f)},Sd=({scrollWindow:e,scrollDroppable:t,getAutoScrollerOptions:n=()=>Qt})=>{const r=qt(e),o=qt(t);let i=null;const a=c=>{i||(process.env.NODE_ENV!=="production"?h(!1,"Cannot fluid scroll if not dragging"):h());const{shouldUseTimeDampening:f,dragStartTime:p}=i;xo({state:c,scrollWindow:r,scrollDroppable:o,dragStartTime:p,shouldUseTimeDampening:f,getAutoScrollerOptions:n})};return{start:c=>{ln(),i&&(process.env.NODE_ENV!=="production"?h(!1,"Cannot start auto scrolling when already started"):h());const f=Date.now();let p=!1;const d=()=>{p=!0};xo({state:c,dragStartTime:0,shouldUseTimeDampening:!1,scrollWindow:d,scrollDroppable:d,getAutoScrollerOptions:n}),i={dragStartTime:f,shouldUseTimeDampening:p},cn(),p&&a(c)},stop:()=>{i&&(r.cancel(),o.cancel(),i=null)},scroll:a}},Od=({move:e,scrollDroppable:t,scrollWindow:n})=>{const r=(l,u)=>{const c=De(l.current.client.selection,u);e({client:c})},o=(l,u)=>{if(!Pr(l,u))return u;const c=Id(l,u);if(!c)return t(l.descriptor.id,u),null;const f=ke(u,c);return t(l.descriptor.id,f),ke(u,f)},i=(l,u,c)=>{if(!l||!Or(u,c))return c;const f=wd(u,c);if(!f)return n(c),null;const p=ke(c,f);return n(p),ke(c,p)};return l=>{const u=l.scrollJumpRequest;if(!u)return;const c=Fe(l.impact);c||(process.env.NODE_ENV!=="production"?h(!1,"Cannot perform a jump scroll when there is no destination"):h());const f=o(l.dimensions.droppables[c],u);if(!f)return;const p=l.viewport,d=i(l.isWindowScrollAllowed,p,f);d&&r(l,d)}},Pd=({scrollDroppable:e,scrollWindow:t,move:n,getAutoScrollerOptions:r})=>{const o=Sd({scrollWindow:t,scrollDroppable:e,getAutoScrollerOptions:r}),i=Od({move:n,scrollWindow:t,scrollDroppable:e});return{scroll:u=>{if(!(r().disabled||u.phase!=="DRAGGING")){if(u.movementMode==="FLUID"){o.scroll(u);return}u.scrollJumpRequest&&i(u)}},start:o.start,stop:o.stop}};const Pt="data-rfd",At=(()=>{const e=`${Pt}-drag-handle`;return{base:e,draggableId:`${e}-draggable-id`,contextId:`${e}-context-id`}})(),ir=(()=>{const e=`${Pt}-draggable`;return{base:e,contextId:`${e}-context-id`,id:`${e}-id`}})(),Ad=(()=>{const e=`${Pt}-droppable`;return{base:e,contextId:`${e}-context-id`,id:`${e}-id`}})(),Do={contextId:`${Pt}-scroll-container-context-id`},Rd=e=>t=>`[${t}="${e}"]`,Wt=(e,t)=>e.map(n=>{const r=n.styles[t];return r?`${n.selector} { ${r} }`:""}).join(" "),Td="pointer-events: none;";var $d=e=>{const t=Rd(e),n=(()=>{const l=`
|
|
67
|
+
cursor: -webkit-grab;
|
|
68
|
+
cursor: grab;
|
|
69
|
+
`;return{selector:t(At.contextId),styles:{always:`
|
|
70
|
+
-webkit-touch-callout: none;
|
|
71
|
+
-webkit-tap-highlight-color: rgba(0,0,0,0);
|
|
72
|
+
touch-action: manipulation;
|
|
73
|
+
`,resting:l,dragging:Td,dropAnimating:l}}})(),r=(()=>{const l=`
|
|
74
|
+
transition: ${jt.outOfTheWay};
|
|
75
|
+
`;return{selector:t(ir.contextId),styles:{dragging:l,dropAnimating:l,userCancel:l}}})(),o={selector:t(Ad.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:Wt(a,"always"),resting:Wt(a,"resting"),dragging:Wt(a,"dragging"),dropAnimating:Wt(a,"dropAnimating"),userCancel:Wt(a,"userCancel")}};const _e=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u"?ma:Ce,jn=()=>{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},Eo=e=>{const t=document.createElement("style");return e&&t.setAttribute("nonce",e),t.type="text/css",t};function Bd(e,t){const n=z(()=>$d(e),[e]),r=W(null),o=W(null),i=S(ve(p=>{const d=o.current;d||(process.env.NODE_ENV!=="production"?h(!1,"Cannot set dynamic style element if it is not set"):h()),d.textContent=p}),[]),a=S(p=>{const d=r.current;d||(process.env.NODE_ENV!=="production"?h(!1,"Cannot set dynamic style element if it is not set"):h()),d.textContent=p},[]);_e(()=>{!r.current&&!o.current||(process.env.NODE_ENV!=="production"?h(!1,"style elements already mounted"):h());const p=Eo(t),d=Eo(t);return r.current=p,o.current=d,p.setAttribute(`${Pt}-always`,e),d.setAttribute(`${Pt}-dynamic`,e),jn().appendChild(p),jn().appendChild(d),a(n.always),i(n.resting),()=>{const m=g=>{const y=g.current;y||(process.env.NODE_ENV!=="production"?h(!1,"Cannot unmount ref as it is not set"):h()),jn().removeChild(y),g.current=null};m(r),m(o)}},[t,a,i,n.always,n.resting,e]);const l=S(()=>i(n.dragging),[i,n.dragging]),u=S(p=>{if(p==="DROP"){i(n.dropAnimating);return}i(n.userCancel)},[i,n.dropAnimating,n.userCancel]),c=S(()=>{o.current&&i(n.resting)},[i,n.resting]);return z(()=>({dragging:l,dropping:u,resting:c}),[l,u,c])}function Bi(e,t){return Array.from(e.querySelectorAll(t))}var ki=e=>e&&e.ownerDocument&&e.ownerDocument.defaultView?e.ownerDocument.defaultView:window;function dn(e){return e instanceof ki(e).HTMLElement}function Fi(e,t){const n=`[${At.contextId}="${e}"]`,r=Bi(document,n);if(!r.length)return process.env.NODE_ENV!=="production"&&ie(`Unable to find any drag handles in the context "${e}"`),null;const o=r.find(i=>i.getAttribute(At.draggableId)===t);return o?dn(o)?o:(process.env.NODE_ENV!=="production"&&ie("drag handle needs to be a HTMLElement"),null):(process.env.NODE_ENV!=="production"&&ie(`Unable to find drag handle with id "${t}" as no handle with a matching id was found`),null)}function kd(e){const t=W({}),n=W(null),r=W(null),o=W(!1),i=S(function(d,m){const g={id:d,focus:m};return t.current[d]=g,function(){const x=t.current;x[d]!==g&&delete x[d]}},[]),a=S(function(d){const m=Fi(e,d);m&&m!==document.activeElement&&m.focus()},[e]),l=S(function(d,m){n.current===d&&(n.current=m)},[]),u=S(function(){r.current||o.current&&(r.current=requestAnimationFrame(()=>{r.current=null;const d=n.current;d&&a(d)}))},[a]),c=S(function(d){n.current=null;const m=document.activeElement;m&&m.getAttribute(At.draggableId)===d&&(n.current=d)},[]);return _e(()=>(o.current=!0,function(){o.current=!1;const d=r.current;d&&cancelAnimationFrame(d)}),[]),z(()=>({register:i,tryRecordFocus:c,tryRestoreFocusRecorded:u,tryShiftRecord:l}),[i,c,u,l])}function Fd(){const e={draggables:{},droppables:{}},t=[];function n(p){return t.push(p),function(){const m=t.indexOf(p);m!==-1&&t.splice(m,1)}}function r(p){t.length&&t.forEach(d=>d(p))}function o(p){return e.draggables[p]||null}function i(p){const d=o(p);return d||(process.env.NODE_ENV!=="production"?h(!1,`Cannot find draggable entry with id [${p}]`):h()),d}const a={register:p=>{e.draggables[p.descriptor.id]=p,r({type:"ADDITION",value:p})},update:(p,d)=>{const m=e.draggables[d.descriptor.id];m&&m.uniqueId===p.uniqueId&&(delete e.draggables[d.descriptor.id],e.draggables[p.descriptor.id]=p)},unregister:p=>{const d=p.descriptor.id,m=o(d);m&&p.uniqueId===m.uniqueId&&(delete e.draggables[d],e.droppables[p.descriptor.droppableId]&&r({type:"REMOVAL",value:p}))},getById:i,findById:o,exists:p=>!!o(p),getAllByType:p=>Object.values(e.draggables).filter(d=>d.descriptor.type===p)};function l(p){return e.droppables[p]||null}function u(p){const d=l(p);return d||(process.env.NODE_ENV!=="production"?h(!1,`Cannot find droppable entry with id [${p}]`):h()),d}const c={register:p=>{e.droppables[p.descriptor.id]=p},unregister:p=>{const d=l(p.descriptor.id);d&&p.uniqueId===d.uniqueId&&delete e.droppables[p.descriptor.id]},getById:u,findById:l,exists:p=>!!l(p),getAllByType:p=>Object.values(e.droppables).filter(d=>d.descriptor.type===p)};function f(){e.draggables={},e.droppables={},t.length=0}return{draggable:a,droppable:c,subscribe:n,clean:f}}function _d(){const e=z(Fd,[]);return Ce(()=>function(){e.clean()},[e]),e}var Ar=oe.createContext(null),en=()=>{const e=document.body;return e||(process.env.NODE_ENV!=="production"?h(!1,"Cannot find document.body"):h()),e};const Ld={position:"absolute",width:"1px",height:"1px",margin:"-1px",border:"0",padding:"0",overflow:"hidden",clip:"rect(0 0 0 0)","clip-path":"inset(100%)"},Vd=e=>`rfd-announcement-${e}`;function Md(e){const t=z(()=>Vd(e),[e]),n=W(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"),Wo(i.style,Ld),en().appendChild(i),function(){setTimeout(function(){const u=en();u.contains(i)&&u.removeChild(i),i===n.current&&(n.current=null)})}},[t]),S(o=>{const i=n.current;if(i){i.textContent=o;return}process.env.NODE_ENV!=="production"&&ie(`
|
|
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 Gd={separator:"::"};function Rr(e,t=Gd){const n=oe.useId();return z(()=>`${e}${t.separator}${n}`,[t.separator,e,n])}function Wd({contextId:e,uniqueId:t}){return`rfd-hidden-text-${e}-${t}`}function zd({contextId:e,text:t}){const n=Rr("hidden-text",{separator:"-"}),r=z(()=>Wd({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",en().appendChild(i),function(){const l=en();l.contains(i)&&l.removeChild(i)}},[r,t]),r}var kn=oe.createContext(null),Hd={react:"^18.0.0 || ^19.0.0"};const Ud=/(\d+)\.(\d+)\.(\d+)/,wo=e=>{const t=Ud.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}},jd=(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 qd=(e,t)=>{const n=wo(e),r=wo(t);jd(n,r)||process.env.NODE_ENV!=="production"&&ie(`
|
|
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 qn=`
|
|
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 Kd=e=>{const t=e.doctype;if(!t){process.env.NODE_ENV!=="production"&&ie(`
|
|
103
|
+
No <!doctype html> found.
|
|
104
|
+
|
|
105
|
+
${qn}
|
|
106
|
+
`);return}t.name.toLowerCase()!=="html"&&process.env.NODE_ENV!=="production"&&ie(`
|
|
107
|
+
Unexpected <!doctype> found: (${t.name})
|
|
108
|
+
|
|
109
|
+
${qn}
|
|
110
|
+
`),t.publicId!==""&&process.env.NODE_ENV!=="production"&&ie(`
|
|
111
|
+
Unexpected <!doctype> publicId found: (${t.publicId})
|
|
112
|
+
A html5 doctype does not have a publicId
|
|
113
|
+
|
|
114
|
+
${qn}
|
|
115
|
+
`)};function Tr(e){process.env.NODE_ENV!=="production"&&e()}function un(e,t){Tr(()=>{Ce(()=>{try{e()}catch(n){er(`
|
|
116
|
+
A setup problem was encountered.
|
|
117
|
+
|
|
118
|
+
> ${n.message}
|
|
119
|
+
`)}},t)})}function Yd(){un(()=>{qd(Hd.react,oe.version),Kd(document)},[])}function $r(e){const t=W(e);return Ce(()=>{t.current=e}),t}function Jd(){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 l={abandon:a};return e=l,l}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 tn(e){return e.phase==="IDLE"||e.phase==="DROP_ANIMATING"?!1:e.isDragging}const Xd=9,Zd=13,Br=27,_i=32,Qd=33,eu=34,tu=35,nu=36,ru=37,ou=38,iu=39,au=40,su={[Zd]:!0,[Xd]:!0};var Li=e=>{su[e.keyCode]&&e.preventDefault()};const Fn=(()=>{const e="visibilitychange";return typeof document>"u"?e:[e,`ms${e}`,`webkit${e}`,`moz${e}`,`o${e}`].find(r=>`on${r}`in document)||e})(),Vi=0,Io=5;function lu(e,t){return Math.abs(t.x-e.x)>=Io||Math.abs(t.y-e.y)>=Io}const Co={type:"IDLE"};function cu({cancel:e,completed:t,getPhase:n,setPhase:r}){return[{eventName:"mousemove",fn:o=>{const{button:i,clientX:a,clientY:l}=o;if(i!==Vi)return;const u={x:a,y:l},c=n();if(c.type==="DRAGGING"){o.preventDefault(),c.actions.move(u);return}c.type!=="PENDING"&&(process.env.NODE_ENV!=="production"?h(!1,"Cannot be IDLE"):h());const f=c.point;if(!lu(f,u))return;o.preventDefault();const p=c.actions.fluidLift(u);r({type:"DRAGGING",actions:p})}},{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===Br){o.preventDefault(),e();return}Li(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:Fn,fn:e}]}function du(e){const t=W(Co),n=W(mt),r=z(()=>({eventName:"mousedown",fn:function(p){if(p.defaultPrevented||p.button!==Vi||p.ctrlKey||p.metaKey||p.shiftKey||p.altKey)return;const d=e.findClosestDraggableId(p);if(!d)return;const m=e.tryGetLock(d,a,{sourceEvent:p});if(!m)return;p.preventDefault();const g={x:p.clientX,y:p.clientY};n.current(),c(m,g)}}),[e]),o=z(()=>({eventName:"webkitmouseforcewillbegin",fn:f=>{if(f.defaultPrevented)return;const p=e.findClosestDraggableId(f);if(!p)return;const d=e.findOptionsForDraggable(p);d&&(d.shouldRespectForcePress||e.canGetLock(p)&&f.preventDefault())}}),[e]),i=S(function(){const p={passive:!1,capture:!0};n.current=Me(window,[o,r],p)},[o,r]),a=S(()=>{t.current.type!=="IDLE"&&(t.current=Co,n.current(),i())},[i]),l=S(()=>{const f=t.current;a(),f.type==="DRAGGING"&&f.actions.cancel({shouldBlockNextClick:!0}),f.type==="PENDING"&&f.actions.abort()},[a]),u=S(function(){const p={capture:!0,passive:!1},d=cu({cancel:l,completed:a,getPhase:()=>t.current,setPhase:m=>{t.current=m}});n.current=Me(window,d,p)},[l,a]),c=S(function(p,d){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:d,actions:p},u()},[u]);_e(function(){return i(),function(){n.current()}},[i])}function uu(){}const pu={[eu]:!0,[Qd]:!0,[nu]:!0,[tu]:!0};function fu(e,t){function n(){t(),e.cancel()}function r(){t(),e.drop()}return[{eventName:"keydown",fn:o=>{if(o.keyCode===Br){o.preventDefault(),n();return}if(o.keyCode===_i){o.preventDefault(),r();return}if(o.keyCode===au){o.preventDefault(),e.moveDown();return}if(o.keyCode===ou){o.preventDefault(),e.moveUp();return}if(o.keyCode===iu){o.preventDefault(),e.moveRight();return}if(o.keyCode===ru){o.preventDefault(),e.moveLeft();return}if(pu[o.keyCode]){o.preventDefault();return}Li(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:Fn,fn:n}]}function mu(e){const t=W(uu),n=z(()=>({eventName:"keydown",fn:function(i){if(i.defaultPrevented||i.keyCode!==_i)return;const a=e.findClosestDraggableId(i);if(!a)return;const l=e.tryGetLock(a,f,{sourceEvent:i});if(!l)return;i.preventDefault();let u=!0;const c=l.snapLift();t.current();function f(){u||(process.env.NODE_ENV!=="production"?h(!1,"Cannot stop capturing a keyboard drag when not capturing"):h()),u=!1,t.current(),r()}t.current=Me(window,fu(c,f),{capture:!0,passive:!1})}}),[e]),r=S(function(){const i={passive:!1,capture:!0};t.current=Me(window,[n],i)},[n]);_e(function(){return r(),function(){t.current()}},[r])}const Kn={type:"IDLE"},hu=120,gu=.15;function bu({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===Br&&n.preventDefault(),e()}},{eventName:Fn,fn:e}]}function yu({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],l={x:i,y:a};r.preventDefault(),o.actions.move(l)}},{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>=gu))return;const l=o.actions.shouldRespectForcePress();if(o.type==="PENDING"){l&&e();return}if(l){if(o.hasMoved){r.preventDefault();return}e();return}r.preventDefault()}},{eventName:Fn,fn:e}]}function vu(e){const t=W(Kn),n=W(mt),r=S(function(){return t.current},[]),o=S(function(m){t.current=m},[]),i=z(()=>({eventName:"touchstart",fn:function(m){if(m.defaultPrevented)return;const g=e.findClosestDraggableId(m);if(!g)return;const y=e.tryGetLock(g,l,{sourceEvent:m});if(!y)return;const x=m.touches[0],{clientX:D,clientY:E}=x,P={x:D,y:E};n.current(),p(y,P)}}),[e]),a=S(function(){const m={capture:!0,passive:!1};n.current=Me(window,[i],m)},[i]),l=S(()=>{const d=t.current;d.type!=="IDLE"&&(d.type==="PENDING"&&clearTimeout(d.longPressTimerId),o(Kn),n.current(),a())},[a,o]),u=S(()=>{const d=t.current;l(),d.type==="DRAGGING"&&d.actions.cancel({shouldBlockNextClick:!0}),d.type==="PENDING"&&d.actions.abort()},[l]),c=S(function(){const m={capture:!0,passive:!1},g={cancel:u,completed:l,getPhase:r},y=Me(window,yu(g),m),x=Me(window,bu(g),m);n.current=function(){y(),x()}},[u,r,l]),f=S(function(){const m=r();m.type!=="PENDING"&&(process.env.NODE_ENV!=="production"?h(!1,`Cannot start dragging from phase ${m.type}`):h());const g=m.actions.fluidLift(m.point);o({type:"DRAGGING",actions:g,hasMoved:!1})},[r,o]),p=S(function(m,g){r().type!=="IDLE"&&(process.env.NODE_ENV!=="production"?h(!1,"Expected to move from IDLE to PENDING drag"):h());const y=setTimeout(f,hu);o({type:"PENDING",point:g,actions:m,longPressTimerId:y}),c()},[c,r,o,f]);_e(function(){return a(),function(){n.current();const g=r();g.type==="PENDING"&&(clearTimeout(g.longPressTimerId),o(Kn))}},[r,a,o]),_e(function(){return Me(window,[{eventName:"touchmove",fn:()=>{},options:{capture:!1,passive:!1}}])},[])}function xu(e){Tr(()=>{const t=$r(e);un(()=>{t.current.length!==e.length&&(process.env.NODE_ENV!=="production"?h(!1,"Cannot change the amount of sensor hooks after mounting"):h(!1))})})}const Du=["input","button","textarea","select","option","optgroup","video","audio"];function Mi(e,t){if(t==null)return!1;if(Du.includes(t.tagName.toLowerCase()))return!0;const r=t.getAttribute("contenteditable");return r==="true"||r===""?!0:t===e?!1:Mi(e,t.parentElement)}function Eu(e,t){const n=t.target;return dn(n)?Mi(e,n):!1}var wu=e=>He(e.getBoundingClientRect()).center;function Iu(e){return e instanceof ki(e).Element}const Cu=(()=>{const e="matches";return typeof document>"u"?e:[e,"msMatchesSelector","webkitMatchesSelector"].find(r=>r in Element.prototype)||e})();function Gi(e,t){return e==null?null:e[Cu](t)?e:Gi(e.parentElement,t)}function Nu(e,t){return e.closest?e.closest(t):Gi(e,t)}function Su(e){return`[${At.contextId}="${e}"]`}function Ou(e,t){const n=t.target;if(!Iu(n))return process.env.NODE_ENV!=="production"&&ie("event.target must be a Element"),null;const r=Su(e),o=Nu(n,r);return o?dn(o)?o:(process.env.NODE_ENV!=="production"&&ie("drag handle must be a HTMLElement"),null):null}function Pu(e,t){const n=Ou(e,t);return n?n.getAttribute(At.draggableId):null}function Au(e,t){const n=`[${ir.contextId}="${e}"]`,o=Bi(document,n).find(i=>i.getAttribute(ir.id)===t);return o?dn(o)?o:(process.env.NODE_ENV!=="production"&&ie("Draggable element is not a HTMLElement"),null):null}function Ru(e){e.preventDefault()}function gn({expected:e,phase:t,isLockActive:n,shouldWarn:r}){return n()?e!==t?(r&&process.env.NODE_ENV!=="production"&&ie(`
|
|
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"&&ie(`
|
|
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 Wi({lockAPI:e,store:t,registry:n,draggableId:r}){if(e.isClaimed())return!1;const o=n.draggable.findById(r);return o?!(!o.options.isEnabled||!Ai(t.getState(),r)):(process.env.NODE_ENV!=="production"&&ie(`Unable to find draggable with id: ${r}`),!1)}function Tu({lockAPI:e,contextId:t,store:n,registry:r,draggableId:o,forceSensorStop:i,sourceEvent:a}){if(!Wi({lockAPI:e,store:n,registry:r,draggableId:o}))return null;const u=r.draggable.getById(o),c=Au(t,u.descriptor.id);if(!c)return process.env.NODE_ENV!=="production"&&ie(`Unable to find draggable element with id: ${o}`),null;if(a&&!u.options.canDragInteractiveElements&&Eu(c,a))return null;const f=e.claim(i||mt);let p="PRE_DRAG";function d(){return u.options.shouldRespectForcePress}function m(){return e.isActive(f)}function g(T,A){gn({expected:T,phase:p,isLockActive:m,shouldWarn:!0})&&n.dispatch(A())}const y=g.bind(null,"DRAGGING");function x(T){function A(){e.release(),p="COMPLETED"}p!=="PRE_DRAG"&&(A(),process.env.NODE_ENV!=="production"?h(!1,`Cannot lift in phase ${p}`):h()),n.dispatch(yc(T.liftActionArgs)),p="DRAGGING";function j(Q,be={shouldBlockNextClick:!1}){if(T.cleanup(),be.shouldBlockNextClick){const ue=Me(window,[{eventName:"click",fn:Ru,options:{once:!0,passive:!1,capture:!0}}]);setTimeout(ue)}A(),n.dispatch(Ei({reason:Q}))}return{isActive:()=>gn({expected:"DRAGGING",phase:p,isLockActive:m,shouldWarn:!1}),shouldRespectForcePress:d,drop:Q=>j("DROP",Q),cancel:Q=>j("CANCEL",Q),...T.actions}}function D(T){const A=qt(Q=>{y(()=>Di({client:Q}))});return{...x({liftActionArgs:{id:o,clientSelection:T,movementMode:"FLUID"},cleanup:()=>A.cancel(),actions:{move:A}}),move:A}}function E(){const T={moveUp:()=>y(Sc),moveRight:()=>y(Pc),moveDown:()=>y(Oc),moveLeft:()=>y(Ac)};return x({liftActionArgs:{id:o,clientSelection:wu(c),movementMode:"SNAP"},cleanup:mt,actions:T})}function P(){gn({expected:"PRE_DRAG",phase:p,isLockActive:m,shouldWarn:!0})&&e.release()}return{isActive:()=>gn({expected:"PRE_DRAG",phase:p,isLockActive:m,shouldWarn:!1}),shouldRespectForcePress:d,fluidLift:D,snapLift:E,abort:P}}const $u=[du,mu,vu];function Bu({contextId:e,store:t,registry:n,customSensors:r,enableDefaultSensors:o}){const i=[...o?$u:[],...r||[]],a=fe(()=>Jd())[0],l=S(function(x,D){tn(x)&&!tn(D)&&a.tryAbandon()},[a]);_e(function(){let x=t.getState();return t.subscribe(()=>{const E=t.getState();l(x,E),x=E})},[a,t,l]),_e(()=>a.tryAbandon,[a.tryAbandon]);const u=S(y=>Wi({lockAPI:a,registry:n,store:t,draggableId:y}),[a,n,t]),c=S((y,x,D)=>Tu({lockAPI:a,registry:n,contextId:e,store:t,draggableId:y,forceSensorStop:x||null,sourceEvent:D&&D.sourceEvent?D.sourceEvent:null}),[e,a,n,t]),f=S(y=>Pu(e,y),[e]),p=S(y=>{const x=n.draggable.findById(y);return x?x.options:null},[n.draggable]),d=S(function(){a.isClaimed()&&(a.tryAbandon(),t.getState().phase!=="IDLE"&&t.dispatch(wr()))},[a,t]),m=S(()=>a.isClaimed(),[a]),g=z(()=>({canGetLock:u,tryGetLock:c,findClosestDraggableId:f,findOptionsForDraggable:p,tryReleaseLock:d,isLockClaimed:m}),[u,c,f,p,d,m]);xu(i);for(let y=0;y<i.length;y++)i[y](g)}const ku=e=>({onBeforeCapture:t=>{Mo(()=>{e.onBeforeCapture&&e.onBeforeCapture(t)})},onBeforeDragStart:e.onBeforeDragStart,onDragStart:e.onDragStart,onDragEnd:e.onDragEnd,onDragUpdate:e.onDragUpdate}),Fu=e=>({...Qt,...e.autoScrollerOptions,durationDampening:{...Qt.durationDampening,...e.autoScrollerOptions}});function zt(e){return e.current||(process.env.NODE_ENV!=="production"?h(!1,"Could not find store from lazy ref"):h()),e.current}function _u(e){const{contextId:t,setCallbacks:n,sensors:r,nonce:o,dragHandleUsageInstructions:i}=e,a=W(null);Yd();const l=$r(e),u=S(()=>ku(l.current),[l]),c=S(()=>Fu(l.current),[l]),f=Md(t),p=zd({contextId:t,text:i}),d=Bd(t,o),m=S(ue=>{zt(a).dispatch(ue)},[]),g=z(()=>Zr({publishWhileDragging:xc,updateDroppableScroll:Ec,updateDroppableIsEnabled:wc,updateDroppableIsCombineEnabled:Ic,collectionStarting:Dc},m),[m]),y=_d(),x=z(()=>pd(y,g),[y,g]),D=z(()=>Pd({scrollWindow:fd,scrollDroppable:x.scrollDroppable,getAutoScrollerOptions:c,...Zr({move:Di},m)}),[x.scrollDroppable,m,c]),E=kd(t),P=z(()=>ld({announce:f,autoScroller:D,dimensionMarshal:x,focusMarshal:E,getResponders:u,styleMarshal:d}),[f,D,x,E,u,d]);process.env.NODE_ENV!=="production"&&a.current&&a.current!==P&&process.env.NODE_ENV!=="production"&&ie("unexpected store change"),a.current=P;const N=S(()=>{const ue=zt(a);ue.getState().phase!=="IDLE"&&ue.dispatch(wr())},[]),T=S(()=>{const ue=zt(a).getState();return ue.phase==="DROP_ANIMATING"?!0:ue.phase==="IDLE"?!1:ue.isDragging},[]),A=z(()=>({isDragging:T,tryAbort:N}),[T,N]);n(A);const j=S(ue=>Ai(zt(a).getState(),ue),[]),Q=S(()=>Dt(zt(a).getState()),[]),be=z(()=>({marshal:x,focus:E,contextId:t,canLift:j,isMovementAllowed:Q,dragHandleUsageInstructionsId:p,registry:y}),[t,x,p,E,j,Q,y]);return Bu({contextId:t,store:P,registry:y,customSensors:r||null,enableDefaultSensors:e.enableDefaultSensors!==!1}),Ce(()=>N,[N]),oe.createElement(kn.Provider,{value:be},oe.createElement(Ta,{context:Ar,store:P},e.children))}function Lu(){return oe.useId()}function zi(e){const t=Lu(),n=e.dragHandleUsageInstructions||yn.dragHandleUsageInstructions;return oe.createElement(sl,null,r=>oe.createElement(_u,{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 No={dragging:5e3,dropAnimating:4500},Vu=(e,t)=>t?jt.drop(t.duration):e?jt.snap:jt.fluid,Mu=(e,t)=>{if(e)return t?Zt.opacity.drop:Zt.opacity.combining},Gu=e=>e.forceShouldAnimate!=null?e.forceShouldAnimate:e.mode==="SNAP";function Wu(e){const n=e.dimension.client,{offset:r,combineWith:o,dropping:i}=e,a=!!o,l=Gu(e),u=!!i,c=u?rr.drop(r,a):rr.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:Vu(l,i),transform:c,opacity:Mu(a,u),zIndex:u?No.dropAnimating:No.dragging,pointerEvents:"none"}}function zu(e){return{transform:rr.moveTo(e.offset),transition:e.shouldAnimateDisplacement?void 0:"none"}}function Hu(e){return e.type==="DRAGGING"?Wu(e):zu(e)}function Uu(e,t,n=xe){const r=window.getComputedStyle(t),o=t.getBoundingClientRect(),i=Yo(o,r),a=Dn(i,n),l={client:i,tagName:t.tagName.toLowerCase(),display:r.display},u={x:i.marginBox.width,y:i.marginBox.height};return{descriptor:e,placeholder:l,displaceBy:u,client:i,page:a}}function ju(e){const t=Rr("draggable"),{descriptor:n,registry:r,getDraggableRef:o,canDragInteractiveElements:i,shouldRespectForcePress:a,isEnabled:l}=e,u=z(()=>({canDragInteractiveElements:i,shouldRespectForcePress:a,isEnabled:l}),[i,l,a]),c=S(m=>{const g=o();return g||(process.env.NODE_ENV!=="production"?h(!1,"Cannot get dimension when no ref is set"):h()),Uu(n,g,m)},[n,o]),f=z(()=>({uniqueId:t,descriptor:n,options:u,getDimension:c}),[n,c,u,t]),p=W(f),d=W(!0);_e(()=>(r.draggable.register(p.current),()=>r.draggable.unregister(p.current)),[r.draggable]),_e(()=>{if(d.current){d.current=!1;return}const m=p.current;p.current=f,r.draggable.update(f,m)},[f,r.draggable])}var kr=oe.createContext(null);function Hi(e){e&&dn(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 qu(e,t,n){un(()=>{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"&&(Hi(n()),e.isEnabled&&(Fi(t,o)||(process.env.NODE_ENV!=="production"?h(!1,`${r(o)} Unable to find drag handle`):h(!1))))})}function Ku(e){Tr(()=>{const t=W(e);un(()=>{e!==t.current&&(process.env.NODE_ENV!=="production"?h(!1,"Draggable isClone prop value changed during component life"):h(!1))},[e])})}function In(e){const t=$o(e);return t||(process.env.NODE_ENV!=="production"?h(!1,"Could not find required context"):h()),t}function Yu(e){e.preventDefault()}const Ju=e=>{const t=W(null),n=S((A=null)=>{t.current=A},[]),r=S(()=>t.current,[]),{contextId:o,dragHandleUsageInstructionsId:i,registry:a}=In(kn),{type:l,droppableId:u}=In(kr),c=z(()=>({id:e.draggableId,index:e.index,type:l,droppableId:u}),[e.draggableId,e.index,l,u]),{children:f,draggableId:p,isEnabled:d,shouldRespectForcePress:m,canDragInteractiveElements:g,isClone:y,mapped:x,dropAnimationFinished:D}=e;if(qu(e,o,r),Ku(y),!y){const A=z(()=>({descriptor:c,registry:a,getDraggableRef:r,canDragInteractiveElements:g,shouldRespectForcePress:m,isEnabled:d}),[c,a,r,g,m,d]);ju(A)}const E=z(()=>d?{tabIndex:0,role:"button","aria-describedby":i,"data-rfd-drag-handle-draggable-id":p,"data-rfd-drag-handle-context-id":o,draggable:!1,onDragStart:Yu}:null,[o,i,p,d]),P=S(A=>{x.type==="DRAGGING"&&x.dropping&&A.propertyName==="transform"&&Mo(D)},[D,x]),N=z(()=>{const A=Hu(x),j=x.type==="DRAGGING"&&x.dropping?P:void 0;return{innerRef:n,draggableProps:{"data-rfd-draggable-context-id":o,"data-rfd-draggable-id":p,style:A,onTransitionEnd:j},dragHandleProps:E}},[o,E,p,x,P,n]),T=z(()=>({draggableId:c.id,type:c.type,source:{index:c.index,droppableId:c.droppableId}}),[c.droppableId,c.id,c.index,c.type]);return oe.createElement(oe.Fragment,null,f(N,x.snapshot,T))};var Ui=(e,t)=>e===t,ji=e=>{const{combine:t,destination:n}=e;return n?n.droppableId:t?t.droppableId:null};const Xu=e=>e.combine?e.combine.draggableId:null,Zu=e=>e.at&&e.at.type==="COMBINE"?e.at.combine.draggableId:null;function Qu(){const e=ve((o,i)=>({x:o,y:i})),t=ve((o,i,a=null,l=null,u=null)=>({isDragging:!0,isClone:i,isDropAnimating:!!u,dropAnimation:u,mode:o,draggingOver:a,combineWith:l,combineTargetFor:null})),n=ve((o,i,a,l,u=null,c=null,f=null)=>({mapped:{type:"DRAGGING",dropping:null,draggingOver:u,combineWith:c,mode:i,offset:o,dimension:a,forceShouldAnimate:f,snapshot:t(i,l,u,c,null)}}));return(o,i)=>{if(tn(o)){if(o.critical.draggable.id!==i.draggableId)return null;const a=o.current.client.offset,l=o.dimensions.draggables[i.draggableId],u=Fe(o.impact),c=Zu(o.impact),f=o.forceShouldAnimate;return n(e(a.x,a.y),o.movementMode,l,i.isClone,u,c,f)}if(o.phase==="DROP_ANIMATING"){const a=o.completed;if(a.result.draggableId!==i.draggableId)return null;const l=i.isClone,u=o.dimensions.draggables[i.draggableId],c=a.result,f=c.mode,p=ji(c),d=Xu(c),g={duration:o.dropDuration,curve:Cr.drop,moveTo:o.newHomeClientOffset,opacity:d?Zt.opacity.drop:null,scale:d?Zt.scale.drop:null};return{mapped:{type:"DRAGGING",offset:o.newHomeClientOffset,dimension:u,dropping:g,draggingOver:p,combineWith:d,mode:f,forceShouldAnimate:null,snapshot:t(f,l,p,d,g)}}}return null}}function qi(e=null){return{isDragging:!1,isDropAnimating:!1,isClone:!1,dropAnimation:null,mode:null,draggingOver:null,combineTargetFor:e,combineWith:null}}const ep={mapped:{type:"SECONDARY",offset:xe,combineTargetFor:null,shouldAnimateDisplacement:!0,snapshot:qi(null)}};function tp(){const e=ve((a,l)=>({x:a,y:l})),t=ve(qi),n=ve((a,l=null,u)=>({mapped:{type:"SECONDARY",offset:a,combineTargetFor:l,shouldAnimateDisplacement:u,snapshot:t(l)}})),r=a=>a?n(xe,a,!0):null,o=(a,l,u,c)=>{const f=u.displaced.visible[a],p=!!(c.inVirtualList&&c.effected[a]),d=Tn(u),m=d&&d.draggableId===a?l:null;if(!f){if(!p)return r(m);if(u.displaced.invisible[a])return null;const x=Bt(c.displacedBy.point),D=e(x.x,x.y);return n(D,m,!0)}if(p)return r(m);const g=u.displacedBy.point,y=e(g.x,g.y);return n(y,m,f.shouldAnimate)};return(a,l)=>{if(tn(a))return a.critical.draggable.id===l.draggableId?null:o(l.draggableId,a.critical.draggable.id,a.impact,a.afterCritical);if(a.phase==="DROP_ANIMATING"){const u=a.completed;return u.result.draggableId===l.draggableId?null:o(l.draggableId,u.result.draggableId,u.impact,u.afterCritical)}return null}}const np=()=>{const e=Qu(),t=tp();return(r,o)=>e(r,o)||t(r,o)||ep},rp={dropAnimationFinished:wi},op=Go(np,rp,null,{context:Ar,areStatePropsEqual:Ui})(Ju);function Ki(e){return In(kr).isUsingCloneFor===e.draggableId&&!e.isClone?null:oe.createElement(op,e)}function Fr(e){const t=typeof e.isDragDisabled=="boolean"?!e.isDragDisabled:!0,n=!!e.disableInteractiveElementBlocking,r=!!e.shouldRespectForcePress;return oe.createElement(Ki,Wo({},e,{isClone:!1,isEnabled:t,canDragInteractiveElements:n,shouldRespectForcePress:r}))}const _r=e=>t=>e===t,ip=_r("scroll"),ap=_r("auto"),sp=_r("visible"),So=(e,t)=>t(e.overflowX)||t(e.overflowY),lp=(e,t)=>t(e.overflowX)&&t(e.overflowY),Yi=e=>{const t=window.getComputedStyle(e),n={overflowX:t.overflowX,overflowY:t.overflowY};return So(n,ip)||So(n,ap)},cp=()=>{if(process.env.NODE_ENV==="production")return!1;const e=en(),t=document.documentElement;if(t||(process.env.NODE_ENV,h()),!Yi(e))return!1;const n=window.getComputedStyle(t),r={overflowX:n.overflowX,overflowY:n.overflowY};return lp(r,sp)||process.env.NODE_ENV!=="production"&&ie(`
|
|
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},Lr=e=>e==null?null:e===document.body?cp()?e:null:e===document.documentElement?null:Yi(e)?e:Lr(e.parentElement);var dp=e=>{!e||!Lr(e.parentElement)||process.env.NODE_ENV!=="production"&&ie(`
|
|
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
|
+
`)},ar=e=>({x:e.scrollLeft,y:e.scrollTop});const Ji=e=>e?window.getComputedStyle(e).position==="fixed"?!0:Ji(e.parentElement):!1;var up=e=>{const t=Lr(e),n=Ji(e);return{closestScrollable:t,isFixedOnPage:n}},pp=({descriptor:e,isEnabled:t,isCombineEnabled:n,isFixedOnPage:r,direction:o,client:i,page:a,closest:l})=>{const u=(()=>{if(!l)return null;const{scrollSize:d,client:m}=l,g=Si({scrollHeight:d.scrollHeight,scrollWidth:d.scrollWidth,height:m.paddingBox.height,width:m.paddingBox.width});return{pageMarginBox:l.page.marginBox,frameClient:m,scrollSize:d,shouldClipSubject:l.shouldClipSubject,scroll:{initial:l.scroll,current:l.scroll,max:g,diff:{value:xe,displacement:xe}}}})(),c=o==="vertical"?yr:ai,f=Ot({page:a,withPlaceholder:null,axis:c,frame:u});return{descriptor:e,isCombineEnabled:n,isFixedOnPage:r,axis:c,isEnabled:t,client:i,page:a,frame:u,subject:f}};const fp=(e,t)=>{const n=Jo(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,u=mr({top:r,right:a,bottom:i,left:o},n.border);return hr({borderBox:u,margin:n.margin,border:n.border,padding:n.padding})};var mp=({ref:e,descriptor:t,env:n,windowScroll:r,direction:o,isDropDisabled:i,isCombineEnabled:a,shouldClipSubject:l})=>{const u=n.closestScrollable,c=fp(e,u),f=Dn(c,r),p=(()=>{if(!u)return null;const m=Jo(u),g={scrollHeight:u.scrollHeight,scrollWidth:u.scrollWidth};return{client:m,page:Dn(m,r),scroll:ar(u),scrollSize:g,shouldClipSubject:l}})();return pp({descriptor:t,isEnabled:!i,isCombineEnabled:a,isFixedOnPage:n.isFixedOnPage,direction:o,client:c,page:f,closest:p})};const hp={passive:!1},gp={passive:!0};var Oo=e=>e.shouldPublishImmediately?hp:gp;const bn=e=>e&&e.env.closestScrollable||null;function bp(e){const t=W(null),n=In(kn),r=Rr("droppable"),{registry:o,marshal:i}=n,a=$r(e),l=z(()=>({id:e.droppableId,type:e.type,mode:e.mode}),[e.droppableId,e.mode,e.type]),u=W(l),c=z(()=>ve((N,T)=>{t.current||(process.env.NODE_ENV!=="production"?h(!1,"Can only update scroll when dragging"):h());const A={x:N,y:T};i.updateDroppableScroll(l.id,A)}),[l.id,i]),f=S(()=>{const N=t.current;return!N||!N.env.closestScrollable?xe:ar(N.env.closestScrollable)},[]),p=S(()=>{const N=f();c(N.x,N.y)},[f,c]),d=z(()=>qt(p),[p]),m=S(()=>{const N=t.current,T=bn(N);if(N&&T||(process.env.NODE_ENV!=="production"?h(!1,"Could not find scroll options while scrolling"):h()),N.scrollOptions.shouldPublishImmediately){p();return}d()},[d,p]),g=S((N,T)=>{t.current&&(process.env.NODE_ENV!=="production"?h(!1,"Cannot collect a droppable while a drag is occurring"):h());const A=a.current,j=A.getDroppableRef();j||(process.env.NODE_ENV!=="production"?h(!1,"Cannot collect without a droppable ref"):h());const Q=up(j),be={ref:j,descriptor:l,env:Q,scrollOptions:T};t.current=be;const ue=mp({ref:j,descriptor:l,env:Q,windowScroll:N,direction:A.direction,isDropDisabled:A.isDropDisabled,isCombineEnabled:A.isCombineEnabled,shouldClipSubject:!A.ignoreContainerClipping}),w=Q.closestScrollable;return w&&(w.setAttribute(Do.contextId,n.contextId),w.addEventListener("scroll",m,Oo(be.scrollOptions)),process.env.NODE_ENV!=="production"&&dp(w)),ue},[n.contextId,l,m,a]),y=S(()=>{const N=t.current,T=bn(N);return N&&T||(process.env.NODE_ENV!=="production"?h(!1,"Can only recollect Droppable client for Droppables that have a scroll container"):h()),ar(T)},[]),x=S(()=>{const N=t.current;N||(process.env.NODE_ENV!=="production"?h(!1,"Cannot stop drag when no active drag"):h());const T=bn(N);t.current=null,T&&(d.cancel(),T.removeAttribute(Do.contextId),T.removeEventListener("scroll",m,Oo(N.scrollOptions)))},[m,d]),D=S(N=>{const T=t.current;T||(process.env.NODE_ENV!=="production"?h(!1,"Cannot scroll when there is no drag"):h());const A=bn(T);A||(process.env.NODE_ENV!=="production"?h(!1,"Cannot scroll a droppable with no closest scrollable"):h()),A.scrollTop+=N.y,A.scrollLeft+=N.x},[]),E=z(()=>({getDimensionAndWatchScroll:g,getScrollWhileDragging:y,dragStopped:x,scroll:D}),[x,g,y,D]),P=z(()=>({uniqueId:r,descriptor:l,callbacks:E}),[E,l,r]);_e(()=>(u.current=P.descriptor,o.droppable.register(P),()=>{t.current&&(process.env.NODE_ENV!=="production"&&ie("Unsupported: changing the droppableId or type of a Droppable during a drag"),x()),o.droppable.unregister(P)}),[E,l,x,P,i,o.droppable]),_e(()=>{t.current&&i.updateDroppableIsEnabled(u.current.id,!e.isDropDisabled)},[e.isDropDisabled,i]),_e(()=>{t.current&&i.updateDroppableIsCombineEnabled(u.current.id,e.isCombineEnabled)},[e.isCombineEnabled,i])}function Yn(){}const Po={width:0,height:0,margin:ml},yp=({isAnimatingOpenOnMount:e,placeholder:t,animate:n})=>e||n==="close"?Po:{height:t.client.borderBox.height,width:t.client.borderBox.width,margin:t.client.margin},vp=({isAnimatingOpenOnMount:e,placeholder:t,animate:n})=>{const r=yp({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"?jt.placeholder:null}},xp=e=>{const t=W(null),n=S(()=>{t.current&&(clearTimeout(t.current),t.current=null)},[]),{animate:r,onTransitionEnd:o,onClose:i,contextId:a}=e,[l,u]=fe(e.animate==="open");Ce(()=>l?r!=="open"?(n(),u(!1),Yn):t.current?Yn:(t.current=setTimeout(()=>{t.current=null,u(!1)}),n):Yn,[r,l,n]);const c=S(p=>{p.propertyName==="height"&&(o(),r==="close"&&i())},[r,i,o]),f=vp({isAnimatingOpenOnMount:l,animate:e.animate,placeholder:e.placeholder});return oe.createElement(e.placeholder.tagName,{style:f,"data-rfd-placeholder-context-id":a,onTransitionEnd:c,ref:e.innerRef})};var Dp=oe.memo(xp);function Jn(e){return typeof e=="boolean"}function Xn(e,t){t.forEach(n=>n(e))}const Ep=[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}){Jn(t.isDropDisabled)||(process.env.NODE_ENV!=="production"?h(!1,"isDropDisabled must be a boolean"):h()),Jn(t.isCombineEnabled)||(process.env.NODE_ENV!=="production"?h(!1,"isCombineEnabled must be a boolean"):h()),Jn(t.ignoreContainerClipping)||(process.env.NODE_ENV!=="production"?h(!1,"ignoreContainerClipping must be a boolean"):h())},function({getDroppableRef:t}){Hi(t())}],wp=[function({props:t,getPlaceholderRef:n}){!t.placeholder||n()||process.env.NODE_ENV!=="production"&&ie(`
|
|
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
|
+
`)}],Ip=[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 Cp(e){un(()=>{Xn(e,Ep),e.props.mode==="standard"&&Xn(e,wp),e.props.mode==="virtual"&&Xn(e,Ip)})}class Np extends oe.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 Sp=e=>{const t=$o(kn);t||(process.env.NODE_ENV!=="production"?h(!1,"Could not find app context"):h());const{contextId:n,isMovementAllowed:r}=t,o=W(null),i=W(null),{children:a,droppableId:l,type:u,mode:c,direction:f,ignoreContainerClipping:p,isDropDisabled:d,isCombineEnabled:m,snapshot:g,useClone:y,updateViewportMaxScroll:x,getContainerForClone:D}=e,E=S(()=>o.current,[]),P=S((ee=null)=>{o.current=ee},[]),N=S(()=>i.current,[]),T=S((ee=null)=>{i.current=ee},[]);Cp({props:e,getDroppableRef:E,getPlaceholderRef:N});const A=S(()=>{r()&&x({maxScroll:Pi()})},[r,x]);bp({droppableId:l,type:u,mode:c,direction:f,isDropDisabled:d,isCombineEnabled:m,ignoreContainerClipping:p,getDroppableRef:E});const j=z(()=>oe.createElement(Np,{on:e.placeholder,shouldAnimate:e.shouldAnimatePlaceholder},({onClose:ee,data:Ee,animate:Ne})=>oe.createElement(Dp,{placeholder:Ee,onClose:ee,innerRef:T,animate:Ne,contextId:n,onTransitionEnd:A})),[n,A,e.placeholder,e.shouldAnimatePlaceholder,T]),Q=z(()=>({innerRef:P,placeholder:j,droppableProps:{"data-rfd-droppable-id":l,"data-rfd-droppable-context-id":n}}),[n,l,j,P]),be=y?y.dragging.draggableId:null,ue=z(()=>({droppableId:l,type:u,isUsingCloneFor:be}),[l,be,u]);function w(){if(!y)return null;const{dragging:ee,render:Ee}=y,Ne=oe.createElement(Ki,{draggableId:ee.draggableId,index:ee.source.index,isClone:!0,isEnabled:!0,shouldRespectForcePress:!1,canDragInteractiveElements:!0},(Nt,_)=>Ee(Nt,_,ee));return Oa.createPortal(Ne,D())}return oe.createElement(kr.Provider,{value:ue},a(Q,g),w())};function Op(){return document.body||(process.env.NODE_ENV!=="production"?h(!1,"document.body is not ready"):h()),document.body}const Ao={mode:"standard",type:"DEFAULT",direction:"vertical",isDropDisabled:!1,isCombineEnabled:!1,ignoreContainerClipping:!1,renderClone:null,getContainerForClone:Op},Xi=e=>{let t={...e},n;for(n in Ao)e[n]===void 0&&(t={...t,[n]:Ao[n]});return t},Zn=(e,t)=>e===t.droppable.type,Ro=(e,t)=>t.draggables[e.draggable.id],Pp=()=>{const e={placeholder:null,shouldAnimatePlaceholder:!0,snapshot:{isDraggingOver:!1,draggingOverWith:null,draggingFromThisWith:null,isUsingPlaceholder:!1},useClone:null},t={...e,shouldAnimatePlaceholder:!1},n=ve(i=>({draggableId:i.id,type:i.type,source:{index:i.index,droppableId:i.droppableId}})),r=ve((i,a,l,u,c,f)=>{const p=c.descriptor.id;if(c.descriptor.droppableId===i){const g=f?{render:f,dragging:n(c.descriptor)}:null,y={isDraggingOver:l,draggingOverWith:l?p:null,draggingFromThisWith:p,isUsingPlaceholder:!0};return{placeholder:c.placeholder,shouldAnimatePlaceholder:!1,snapshot:y,useClone:g}}if(!a)return t;if(!u)return e;const m={isDraggingOver:l,draggingOverWith:p,draggingFromThisWith:null,isUsingPlaceholder:!0};return{placeholder:c.placeholder,shouldAnimatePlaceholder:!0,snapshot:m,useClone:null}});return(i,a)=>{const l=Xi(a),u=l.droppableId,c=l.type,f=!l.isDropDisabled,p=l.renderClone;if(tn(i)){const d=i.critical;if(!Zn(c,d))return t;const m=Ro(d,i.dimensions),g=Fe(i.impact)===u;return r(u,f,g,g,m,p)}if(i.phase==="DROP_ANIMATING"){const d=i.completed;if(!Zn(c,d.critical))return t;const m=Ro(d.critical,i.dimensions);return r(u,f,ji(d.result)===u,Fe(d.impact)===u,m,p)}if(i.phase==="IDLE"&&i.completed&&!i.shouldFlush){const d=i.completed;if(!Zn(c,d.critical))return t;const m=Fe(d.impact)===u,g=!!(d.impact.at&&d.impact.at.type==="COMBINE"),y=d.critical.droppable.id===u;return m?g?e:t:y?e:t}return t}},Ap={updateViewportMaxScroll:Nc},Cn=Go(Pp,Ap,(e,t,n)=>({...Xi(n),...e,...t}),{context:Ar,areStatePropsEqual:Ui})(Sp),_n=F.div`
|
|
165
|
+
/* Act as a flexible panel that can live inside grid/flex cells */
|
|
166
|
+
display: flex;
|
|
167
|
+
flex-direction: column;
|
|
168
|
+
height: 100%;
|
|
169
|
+
min-height: 0; /* allow inner children to shrink/scroll */
|
|
170
|
+
/* Contain overflow by default; individual inner areas can scroll */
|
|
171
|
+
overflow: hidden;
|
|
172
|
+
|
|
173
|
+
border-radius: 12px;
|
|
174
|
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
|
175
|
+
background-color: #fff;
|
|
176
|
+
padding: 1.5rem;
|
|
177
|
+
`,et=$t(Lo)(({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)"}},position:"relative","&:hover .step-actions-overlay":{opacity:1,transform:"translateY(0)"}})),tt=$t(U)(({theme:e})=>({fontWeight:"bold",fontSize:"1.2em",color:e.palette.primary.main,minWidth:30})),nt=$t(ne)({flexGrow:1}),lt=({path:e})=>v(U,{variant:"caption",color:"info.main",sx:{display:"block",fontFamily:"monospace"},children:["from ",e]}),rt=$t(U)(({statuscolor:e})=>({fontSize:"0.8em",marginTop:4,color:e||"#666",fontWeight:500})),ot=$t(ne)(({theme:e})=>({position:"absolute",top:-16,right:16,backgroundColor:e.palette.background.paper,boxShadow:e.shadows[3],border:`1px solid ${e.palette.divider}`,display:"flex",alignItems:"center",justifyContent:"center",gap:e.spacing(.5),opacity:0,transition:"all 0.2s ease-in-out",zIndex:10,borderRadius:16,padding:"4px 8px",transform:"translateY(5px)","&.visible":{opacity:1,transform:"translateY(0)"}})),Zi=$t("img")(({theme:e})=>({border:`1px solid ${e.palette.divider}`,borderRadius:4,boxShadow:e.shadows[2],width:60,height:60,objectFit:"cover"})),Rp=({step:e,stepNumber:t,onPlay:n,onPlayFromHere:r,onEdit:o,onDelete:i})=>v(et,{elevation:1,children:[s(tt,{children:t}),v(nt,{children:[s(U,{variant:"body2",color:"text.secondary",fontFamily:"monospace",children:"📄 File Reference"}),s(U,{fontWeight:"bold",children:e.descriptionText||"Add steps from file"}),v(U,{variant:"body2",children:["Path: ",e.path]}),e.overrides&&Object.keys(e.overrides).length>0&&v(ne,{sx:{mt:.5,display:"flex",alignItems:"center",flexWrap:"wrap",gap:.5},children:[s(U,{variant:"caption",color:"text.secondary",children:"Overrides:"}),Object.keys(e.overrides).map(a=>s(V,{size:"small",label:`${a}`},a))]}),e.status&&s(rt,{statuscolor:e.statusColor,children:e.status}),s(ne,{sx:{mt:1,display:"flex",gap:1,alignItems:"center"},children:e.optional?s(V,{size:"small",label:"Optional"}):null})]}),v(ot,{className:"step-actions-overlay",children:[r&&s(O,{onClick:r,size:"small","aria-label":"Play",children:s(Xe,{})}),r&&s(O,{onClick:r,size:"small","aria-label":"Play from here",children:s(Ze,{})}),o&&s(O,{onClick:o,size:"small","aria-label":"Edit",children:s(Qe,{})}),i&&s(O,{onClick:i,size:"small","aria-label":"Delete",children:s(je,{})})]})]}),Tp=({step:e,stepNumber:t,onPlay:n,onPlayFromHere:r,onEdit:o,onDelete:i})=>v(et,{elevation:1,$hasOrigin:!!e.originRef,children:[s(tt,{children:t}),e.cropBase64&&s(Zi,{src:e.cropBase64,alt:"tap target"}),v(nt,{children:[e.originRef?.path&&s(lt,{path:e.originRef?.path}),s(U,{fontWeight:"bold",children:e.descriptionText||"Tap Interaction"}),e.status&&s(rt,{statuscolor:e.statusColor,children:e.status}),v(ne,{sx:{mt:1,display:"flex",gap:1,flexWrap:"wrap"},children:[e.optional?s(V,{size:"small",label:"Optional"}):null,e.useLlmOnly?s(V,{size:"small",label:"LLM Only"}):null,e.elementId?s(V,{size:"small",label:`Element ID: ${e.elementId}`}):null,typeof e.timeout=="number"?s(V,{size:"small",label:`Timeout: ${e.timeout} ms`}):null]})]}),v(ot,{className:"step-actions-overlay",children:[s(O,{size:"small",onClick:n,title:"Play this step",children:s(Xe,{})}),s(O,{size:"small",onClick:r,title:"Play from here",children:s(Ze,{})}),s(O,{size:"small",onClick:o,title:"Edit",children:s(Qe,{})}),s(O,{size:"small",onClick:i,title:"Delete",children:s(je,{})})]})]}),$p=({step:e,stepNumber:t,onPlay:n,onPlayFromHere:r,onEdit:o,onDelete:i})=>v(et,{elevation:1,$hasOrigin:!!e.originRef,children:[s(tt,{children:t}),e.cropBase64&&s(Zi,{src:e.cropBase64,alt:"assert target",sx:{border:2,borderColor:"warning.main"}}),v(nt,{children:[e.originRef?.path&&s(lt,{path:e.originRef?.path}),s(U,{fontWeight:"bold",children:e.descriptionText||"Assert Element"}),e.status&&s(rt,{statuscolor:e.statusColor,children:e.status}),v(ne,{sx:{mt:1,display:"flex",gap:1,flexWrap:"wrap"},children:[e.optional?s(V,{size:"small",label:"Optional"}):null,e.useLlmOnly?s(V,{size:"small",label:"LLM Only"}):null,e.elementId?s(V,{size:"small",label:`Element ID: ${e.elementId}`}):null,typeof e.timeout=="number"?s(V,{size:"small",label:`Timeout: ${e.timeout} ms`}):null]})]}),v(ot,{className:"step-actions-overlay",children:[s(O,{size:"small",onClick:n,title:"Play this step",children:s(Xe,{})}),s(O,{size:"small",onClick:r,title:"Play from here",children:s(Ze,{})}),s(O,{size:"small",onClick:o,title:"Edit",children:s(Qe,{})}),s(O,{size:"small",onClick:i,title:"Delete",children:s(je,{})})]})]}),Bp=({step:e,stepNumber:t,onPlay:n,onPlayFromHere:r,onEdit:o,onDelete:i})=>v(et,{elevation:1,$hasOrigin:!!e.originRef,children:[s(tt,{children:t}),s(V,{icon:s(Wa,{}),label:"Type",color:"primary",variant:"outlined"}),v(nt,{children:[e.originRef?.path&&s(lt,{path:e.originRef?.path}),s(U,{fontWeight:"bold",children:e.descriptionText||`Type "${e.text}"`}),e.status&&s(rt,{statuscolor:e.statusColor,children:e.status}),v(ne,{sx:{mt:1,display:"flex",gap:1,flexWrap:"wrap"},children:[s(V,{size:"small",label:`Text: ${e.text}`}),e.optional?s(V,{size:"small",label:"Optional"}):null]})]}),v(ot,{className:"step-actions-overlay",children:[s(O,{size:"small",onClick:n,title:"Play this step",children:s(Xe,{})}),s(O,{size:"small",onClick:r,title:"Play from here",children:s(Ze,{})}),s(O,{size:"small",onClick:o,title:"Edit",children:s(Qe,{})}),s(O,{size:"small",onClick:i,title:"Delete",children:s(je,{})})]})]}),kp=({step:e,stepNumber:t,onPlay:n,onPlayFromHere:r,onEdit:o,onDelete:i})=>v(et,{elevation:1,$hasOrigin:!!e.originRef,children:[s(tt,{children:t}),s(V,{icon:s(Ho,{}),label:"Scroll",color:"secondary",variant:"outlined"}),v(nt,{children:[e.originRef?.path&&s(lt,{path:e.originRef?.path}),s(U,{fontWeight:"bold",children:e.descriptionText||`Scroll ${e.direction}`}),e.status&&s(rt,{statuscolor:e.statusColor,children:e.status}),v(ne,{display:"flex",gap:1,mt:1,children:[s(V,{label:`Direction: ${e.direction}`,size:"small"}),e.optional?s(V,{size:"small",label:"Optional"}):null]})]}),v(ot,{className:"step-actions-overlay",children:[s(O,{size:"small",onClick:n,title:"Play this step",children:s(Xe,{})}),s(O,{size:"small",onClick:r,title:"Play from here",children:s(Ze,{})}),s(O,{size:"small",onClick:o,title:"Edit",children:s(Qe,{})}),s(O,{size:"small",onClick:i,title:"Delete",children:s(je,{})})]})]}),Fp=({step:e,stepNumber:t,onPlay:n,onPlayFromHere:r,onEdit:o,onDelete:i})=>v(et,{elevation:1,$hasOrigin:!!e.originRef,children:[s(tt,{children:t}),s(V,{icon:s(Ho,{}),label:"Swipe",color:"secondary",variant:"outlined"}),v(nt,{children:[e.originRef?.path&&s(lt,{path:e.originRef?.path}),s(U,{fontWeight:"bold",children:e.descriptionText||`Swipe ${e.direction}`}),e.status&&s(rt,{statuscolor:e.statusColor,children:e.status}),v(ne,{display:"flex",gap:1,mt:1,children:[s(V,{label:`Direction: ${e.direction}`,size:"small"}),typeof e.x=="number"&&typeof e.y=="number"?s(V,{label:`Start: ${e.x}, ${e.y}`,size:"small"}):null,typeof e.duration=="number"?s(V,{label:`Duration: ${e.duration}ms`,size:"small"}):null,e.optional?s(V,{size:"small",label:"Optional"}):null]})]}),v(ot,{className:"step-actions-overlay",children:[s(O,{size:"small",onClick:n,title:"Play this step",children:s(Xe,{})}),s(O,{size:"small",onClick:r,title:"Play from here",children:s(Ze,{})}),s(O,{size:"small",onClick:o,title:"Edit",children:s(Qe,{})}),s(O,{size:"small",onClick:i,title:"Delete",children:s(je,{})})]})]}),_p=({step:e,stepNumber:t,onPlay:n,onPlayFromHere:r,onEdit:o,onDelete:i})=>v(et,{elevation:1,$hasOrigin:!!e.originRef,children:[s(tt,{children:t}),s(V,{icon:s(za,{}),label:"Zoom",color:"secondary",variant:"outlined"}),v(nt,{children:[e.originRef?.path&&s(lt,{path:e.originRef?.path}),s(U,{fontWeight:"bold",children:e.descriptionText||`Zoom ${e.direction}`}),e.status&&s(rt,{statuscolor:e.statusColor,children:e.status}),v(ne,{display:"flex",gap:1,mt:1,children:[s(V,{label:`Direction: ${e.direction}`,size:"small"}),e.optional?s(V,{size:"small",label:"Optional"}):null]})]}),v(ot,{className:"step-actions-overlay",children:[s(O,{size:"small",onClick:n,title:"Play this step",children:s(Xe,{})}),s(O,{size:"small",onClick:r,title:"Play from here",children:s(Ze,{})}),s(O,{size:"small",onClick:o,title:"Edit",children:s(Qe,{})}),s(O,{size:"small",onClick:i,title:"Delete",children:s(je,{})})]})]}),Lp=({step:e,stepNumber:t,onPlay:n,onPlayFromHere:r,onEdit:o,onDelete:i})=>v(et,{elevation:1,$hasOrigin:!!e.originRef,children:[s(tt,{children:t}),s(V,{icon:s(Ha,{}),label:"Scroll Until",color:"info",variant:"outlined"}),v(nt,{children:[e.originRef?.path&&s(lt,{path:e.originRef?.path}),s(U,{fontWeight:"bold",children:e.descriptionText||"Scroll Until Found"}),e.status&&s(rt,{statuscolor:e.statusColor,children:e.status}),v(ne,{display:"flex",gap:1,mt:1,alignItems:"center",sx:{flexWrap:"wrap"},children:[e.text?s(V,{label:`Find: ${e.text}`,size:"small"}):null,e.elementId?s(V,{label:`Element ID: ${e.elementId}`,size:"small"}):null,s(V,{label:`Direction: ${e.direction}`,size:"small"}),s(V,{label:`Max Scrolls: ${e.maxScrolls}`,size:"small"}),e.optional?s(V,{size:"small",label:"Optional"}):null]})]}),v(ot,{className:"step-actions-overlay",children:[s(O,{size:"small",onClick:n,title:"Play this step",children:s(Xe,{})}),s(O,{size:"small",onClick:r,title:"Play from here",children:s(Ze,{})}),s(O,{size:"small",onClick:o,title:"Edit",children:s(Qe,{})}),s(O,{size:"small",onClick:i,title:"Delete",children:s(je,{})})]})]}),Vp=({step:e,stepNumber:t,onPlay:n,onPlayFromHere:r,onEdit:o,onDelete:i})=>v(et,{elevation:1,$hasOrigin:!!e.originRef,children:[s(tt,{children:t}),s(V,{icon:s(Ua,{}),label:"Deeplink",color:"success",variant:"outlined"}),v(nt,{children:[e.originRef?.path&&s(lt,{path:e.originRef?.path}),s(U,{fontWeight:"bold",children:e.descriptionText||"Open Deep Link"}),e.status&&s(rt,{statuscolor:e.statusColor,children:e.status}),v(ne,{sx:{mt:1,display:"flex",gap:1,flexWrap:"wrap"},children:[s(V,{size:"small",label:`URL: ${e.url}`}),e.optional?s(V,{size:"small",label:"Optional"}):null]})]}),v(ot,{className:"step-actions-overlay",children:[s(O,{size:"small",onClick:n,title:"Play this step",children:s(Xe,{})}),s(O,{size:"small",onClick:r,title:"Play from here",children:s(Ze,{})}),s(O,{size:"small",onClick:o,title:"Edit",children:s(Qe,{})}),s(O,{size:"small",onClick:i,title:"Delete",children:s(je,{})})]})]}),Mp=({step:e,stepNumber:t,onPlay:n,onPlayFromHere:r,onEdit:o,onDelete:i})=>v(et,{elevation:1,$hasOrigin:!!e.originRef,children:[s(tt,{children:t}),s(V,{icon:s(ja,{}),label:"AI",color:"secondary"}),v(nt,{children:[e.originRef?.path&&s(lt,{path:e.originRef?.path}),s(U,{fontWeight:"bold",children:e.descriptionText||"AI Instruction"}),e.status&&s(rt,{statuscolor:e.statusColor,children:e.status}),v(ne,{sx:{mt:1,display:"flex",gap:1,flexWrap:"wrap"},children:[s(V,{size:"small",label:`Instruction: ${e.instruction}`}),e.optional?s(V,{size:"small",label:"Optional"}):null]})]}),v(ot,{className:"step-actions-overlay",children:[s(O,{size:"small",onClick:n,title:"Play this step",children:s(Xe,{})}),s(O,{size:"small",onClick:r,title:"Play from here",children:s(Ze,{})}),s(O,{size:"small",onClick:o,title:"Edit",children:s(Qe,{})}),s(O,{size:"small",onClick:i,title:"Delete",children:s(je,{})})]})]}),se=e=>{const t="/_serverFn/"+e;return Object.assign(async(...n)=>(await qa(e))(...n),{url:t,functionId:e,[Ka]:!0})},Gp=se("605c05774def700303f9889c0f8a28fed026e0b5c36a1563cff2835ee01d26b1"),Wp=ae({method:"POST"}).inputValidator(Ya).handler(Gp,async({data:e})=>(console.log(`Performing tap at ${e.x}, ${e.y}`),await ns(e),{success:!0})),Vr=ge({mutationKey:["device","tap"],mutationFn:e=>Wp({data:e})}),zp=se("07e23aa87e88d53c6c9e3d8e88de788d27d7b10930150bc4fd510d4447aaf3de"),Hp=ae({method:"POST"}).inputValidator(Ja).handler(zp,async({data:e})=>(console.log(`Performing type: "${e.text}"`),await rs(e),{success:!0})),Mr=ge({mutationKey:["device","type"],mutationFn:e=>Hp({data:e})}),Up=se("5c526b678a7596f28beca76784df0ac58acd292627c5770c0c8029e38e4681ec"),jp=ae({method:"POST"}).inputValidator(Xa).handler(Up,async({data:e})=>(console.log(`Performing scroll: ${e.direction}`),await Uo(e),{success:!0})),Gr=ge({mutationKey:["device","scroll"],mutationFn:e=>jp({data:e})}),qp=se("2b4a002699960d578addbcf4dd83fedcec62444d7da4bf7c2359be991ed6207e"),Kp=ae({method:"POST"}).inputValidator(ts).handler(qp,async({data:e})=>(console.log(`Performing swipe: ${e.x1},${e.y1} -> ${e.x2},${e.y2}`),await as(e),{success:!0})),Wr=ge({mutationKey:["device","swipe"],mutationFn:e=>Kp({data:e})}),Yp=se("10b616f4aacf11bb275166e4ae03f441f1d7c9a68a670dfadb03b74e1d012900"),Jp=ae({method:"POST"}).inputValidator(Za).handler(Yp,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 An(),r=await fr(n);let o=r.hierarchy?.node?.[0];const i=r.hierarchy?.node;if(i){const l=i.find(u=>u.$&&u.$.package!=="com.android.systemui");l&&(o=l)}let a=!1;if(e.elementId&&jo(o,e.elementId)&&(a=!0),!a&&e.text&&ds(o,e.text)&&(a=!0),a)return console.log("Target found!"),{success:!0,scrolls:t};t<(e.maxScrolls??15)-1&&(await Uo({direction:e.direction}),await new Promise(l=>setTimeout(l,1e3)))}return console.log("Target NOT found after max scrolls"),{success:!1}}),Xp=ge({mutationKey:["device","scrollUntil"],mutationFn:e=>Jp({data:e})}),Zp=se("c23cd3196f54848abd64a8b8d4660d7826a70cf44169d7bf29fc82e74a2cf612"),Qp=ae({method:"POST"}).inputValidator(es).handler(Zp,async({data:e})=>(console.log(`Performing zoom: ${e.direction}`),await is(e),{success:!0})),ef=ge({mutationKey:["device","zoom"],mutationFn:e=>Qp({data:e})}),tf=se("566ee4344553ab6300f847f5de346e037f92d986cb824ba1c313346e62345fbe"),nf=ae({method:"POST"}).inputValidator(Qa).handler(tf,async({data:e})=>(console.log(`Performing deep link: "${e.url}"`),await os(e.url),{success:!0})),rf=ge({mutationKey:["device","deepLink"],mutationFn:e=>nf({data:e})}),of=se("eea1073a910f7f023004366aafcef05a8c47a3a1a4a09721f71a2efe311ee70f"),af=ae({method:"POST"}).handler(of,async e=>{const{platform:t="android",deviceId:n}=pr.parse(e.data);return await ss(t,n),{success:!0}}),sf=ge({mutationKey:["device","appium","start"],mutationFn:e=>af({data:e})}),lf=se("6dbdc2968dc27a948c345034d1e55082b86918953b61da020ea8dd5836c79db3"),cf=ae({method:"GET"}).handler(lf,async e=>{const{platform:t="android",deviceId:n}=pr.parse(e.data),{isAppiumConnected:r}=await import("./appium-client-DiTTrl8p.mjs");return{connected:r(t,n)}}),df=(e={})=>Rt({queryKey:["device","appium","status",e],queryFn:()=>cf({data:e}),refetchInterval:2e3}),uf=se("c5aeaa72b9b3303af5d82ee2fa59e3e90ffef3c3f0fb32707cee49e78ff41066"),Qi=ae({method:"GET"}).handler(uf,async e=>{const t=pr.parse(e.data),{platform:n="android",deviceId:r}=t,o=async()=>({success:!0,base64:`data:image/png;base64,${(await xs(r)).toString("base64")}`,format:"base64",platform:"android",deviceId:r}),i=async()=>({success:!0,base64:`data:image/jpeg;base64,${(await ws(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}}}),ea=(e={})=>Rt({queryKey:["device","screenshot",e],queryFn:()=>Qi({data:e}),staleTime:0,gcTime:0}),pf=ge({mutationKey:["device","screenshot_mutation"],mutationFn:e=>Qi({data:e})}),ff=se("1ed4d2aa14be99e8c5a81eefbece63cea629a89f75862c60f9ff19c4d4dc67c5"),mf=ae().handler(ff,async()=>{const e=await An(),t=ls(),n=cs(),r=t==="ios"?fs(e):ms(e),o=hs({elements:r,deviceDimensions:n,allowNonClickableItems:!0,ignoredElements:[]}),i=gs({items:o});return{...n,elements:i}}),hf=se("05faf0772038a170c70083fd8de4a8b77a40e4ec46e0bbf6878670f02621b5df"),gf=ae({method:"POST"}).inputValidator(Cs).handler(hf,async({data:e})=>{console.log(`Getting element ID at ${e.x}, ${e.y}`);const t=await An(),n=(await fr(t))?.hierarchy?.node?.[0];if(!n)return console.log("No root node found in hierarchy"),{elementId:""};const r=bs(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=ys(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:""}}),ta=ge({mutationKey:["device","hierarchy","getElementId"],mutationFn:e=>gf({data:e})}),bf=se("9bcbf5303827d2a25f347c2054b0121655a82322fa07108653f43246875348f7"),yf=ae({method:"POST"}).inputValidator(Is).handler(bf,async({data:e})=>{console.log(`Looking for element with ID: ${e.elementId}`);const t=await An(),n=(await fr(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 l=us(n,r);o<l.length&&(a=l[o],console.log(`Found element at index ${o}`))}else a=jo(n,e.elementId);if(a){const l=ps(a);if(l)return console.log(`Found element at center: ${l.x}, ${l.y}`),{found:!0,x:l.x,y:l.y}}return console.log("Element not found or no bounds"),{found:!1}}),vf=ge({mutationKey:["device","hierarchy","findElementById"],mutationFn:e=>yf({data:e})}),na=({enabled:e})=>Rt({queryKey:["visibleElements"],queryFn:mf,enabled:e}),xf=se("9f335634267a450fc9f34b1ab33c55da00cb1efc709604b2e3114602020075a2"),Df=ae({method:"POST"}).handler(xf,async()=>(console.log("Disabling Android animations..."),await Ds(),{success:!0})),Ef=ge({mutationKey:["device","adb","disableAnimations"],mutationFn:()=>Df()}),wf=se("33557b2fcc5cedc5814d20bca9cd9cde2e45318755de1da4d613e8fa84ee38d1"),If=ae({method:"GET"}).handler(wf,async()=>{const[e,t]=await Promise.all([vs(),Es()]);return[...e,...t]}),ra=Rt({queryKey:["devices"],queryFn:()=>If()}),oa="https://cache.mobileboost.io";function ia(){const e=Ae.join(process.cwd(),"mobileboost.config.json");if(!to.existsSync(e))throw new Error("mobileboost.config.json not found");const t=to.readFileSync(e,"utf-8");return JSON.parse(t)}function aa(e,t,n,r,o,i){const a=i?`${i.width}x${i.height}`:"",l=`${e}${t||""}${n}${r}${o||""}${a}`;return Ns.createHash("sha256").update(l).digest("hex")}function sa(e,t){return e.match(/([xy])=(\d+)/)?e.replace(/([xy])=(\d+)/g,(n,r,o)=>{const i=parseInt(o,10);let a;return t==="multiply"?a=Math.round(i*pt):a=Math.round(i/pt),`${r}=${a}`}):e.replace(/(^|;)(\d+);(\d+)(;|$)/,(n,r,o,i,a)=>{const l=parseInt(o,10),u=parseInt(i,10);let c,f;return t==="multiply"?(c=Math.round(l*pt),f=Math.round(u*pt)):(c=Math.round(l/pt),f=Math.round(u/pt)),`${r}${c};${f}${a}`})}const Cf=se("fcbe7e11d05240fa28a1dd79ec8c395f6c03682edbaeb19f469bd78d6399cdde"),Nf=ae({method:"POST"}).inputValidator(e=>Ps.parse(e)).handler(Cf,async({data:e})=>{try{const t=ia().apiKey;if(!t)throw new Error("API Key missing");const n=aa(t,e.filepath,e.stepNumber,e.stepDescription,e.platform,e.screenResolution),r=await Promise.all(e.executionData.map(async l=>{const u=Buffer.from(l.screenshot.replace(/^data:image\/\w+;base64,/,""),"base64"),c=(await Ht(u).metadata()).width??1080,f=Math.round(c/pt),p=await Ht(u).resize({width:f,withoutEnlargement:!0}).toBuffer(),d=l.commands.map(m=>sa(m,"divide"));return{screenshot:p.toString("base64"),commands:d}})),o=JSON.stringify(r),i=(o.length/(1024*1024)).toFixed(2);console.log(`[Cache Client] Populating cache with payload size: ~${i} MB (Hash: ${n})`);const a=await fetch(`${oa}/populate-cache?hash=${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:o});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)}}}),Sf=se("7d2aacaab26ab11cdc66f03a4ed01b8b38186abf16ab1f9306801ea7769aaa2a"),Of=ae({method:"POST"}).inputValidator(e=>Ss.parse(e)).handler(Sf,async({data:e})=>{try{const t=ia().apiKey;if(!t)throw new Error("API Key missing");const n=aa(t,e.filepath,e.stepNumber,e.stepDescription,e.platform,e.screenResolution),r=Buffer.from(e.screenshot.replace(/^data:image\/\w+;base64,/,""),"base64"),o=(await Ht(r).metadata()).width??1080,i=Math.round(o/pt),a=await Ht(r).resize({width:i,withoutEnlargement:!0}).toBuffer(),l=await Ht(a).metadata();console.log(l.width,l.height);const u=new FormData;u.append("hash",n);const c=new Blob([new Uint8Array(a)],{type:"image/png"}),f=(c.size/(1024*1024)).toFixed(2);console.log(`[Cache Client] Executing from cache with screenshot size: ${f} MB`),u.append("screenshot",c,"screenshot.png"),e.highest_used_index!==void 0&&e.highest_used_index!==null&&(console.log(`[Cache Client] Sending highest_used_index: ${e.highest_used_index} (Type: ${typeof e.highest_used_index})`),u.append("highest_used_index",String(e.highest_used_index)));const p=await fetch(`${oa}/execute-from-cache`,{method:"POST",body:u});if(!p.ok){const g=await p.text();return console.warn("Cache lookup failed:",g),{found:!1}}const d=await p.json(),m=Os.safeParse(d);if(m.success){const g={...m.data};return g.found&&g.cacheCommands&&(g.cacheCommands=g.cacheCommands.map(y=>sa(y,"multiply"))),g}return console.error("Invalid cache response:",d),{found:!1}}catch(t){return console.error("Error executing from cache:",t),{found:!1,error:String(t)}}}),Pf={mutationFn:e=>Of({data:e})},zr={mutationFn:e=>Nf({data:e})},Af=se("5918013064f9b88efb265b30a770275d6c9d52bf42318f451bab8a47bc850917"),Rf=ae({method:"POST"}).inputValidator(As).handler(Af,async({data:e})=>await Rs(e)),Tf=ge({mutationKey:["ai","executeAgentStep"],mutationFn:e=>Rf({data:e})});async function pn(){const e=Ae.join(process.cwd(),"mobileboost.config.json");let t="./tests";if(await Re.pathExists(e))try{const n=await Re.readJSON(e);n.testDir&&(t=n.testDir)}catch(n){console.error("Error reading config, using default testDir",n)}return Ae.resolve(process.cwd(),t)}async function Ln(e){const t=await pn(),n=Ae.resolve(t,e);if(!n.startsWith(t))throw new Error("Invalid path: must be within test directory");return n}L.object({name:L.string(),type:L.enum(["file","directory"]),path:L.string()});const $f=se("00fb1fe03e9689cf8c179ba0d5cadc5eeaa6879def224ac38037d70a1a51300d"),Bf=ae({method:"GET"}).handler($f,async()=>{const e=await pn();await Re.ensureDir(e);async function t(n){let r=[];const o=await Re.readdir(n,{withFileTypes:!0});for(const i of o){const a=Ae.join(n,i.name),l=Ae.relative(e,a);i.isDirectory()?(r.push({name:i.name,type:"directory",path:l}),r=r.concat(await t(a))):r.push({name:i.name,type:"file",path:l})}return r}return{files:await t(e)}}),kf=L.record(L.string(),L.string()).optional().default({});L.object({testDir:L.string(),driver:L.string(),port:L.number(),apiKey:L.string(),variables:kf});const Ff=se("54b0d7153f4ee4f963b29e7c835e76cedaaf345527fdc912c49030ea79353b5e"),_f=ae({method:"GET"}).handler(Ff,async()=>{let e={};const t=Ae.join(process.cwd(),"mobileboost.config.json"),n=Ae.join(process.cwd(),".env");if(await Re.pathExists(t))try{e={...(await Re.readJSON(t)).variables}}catch{}if(await Re.pathExists(n))try{const r=await Bs(n,"utf-8"),o=ks.parse(r);e={...e,...o}}catch{}return e}),Hr=Rt({queryKey:["files"],queryFn:()=>Bf()}),Lf=L.object({name:L.string(),type:L.enum(["file","directory"]),parentPath:L.string().optional()}),Vf=se("ac7bf7f1d727949cd28713a8f36bb77e7bd8fc0e48854ed8cb1ee93ce80fb6d0"),Mf=ae({method:"POST"}).inputValidator(Lf).handler(Vf,async({data:e})=>{const t=await pn(),n=e.parentPath?Ae.join(t,e.parentPath):t;if(!Ae.resolve(n).startsWith(t))throw new Error("Invalid parent path");const r=Ae.join(n,e.name);if(e.type==="directory")await Re.ensureDir(r);else{if(await Re.pathExists(r))throw new Error("File already exists");await Re.writeJSON(r,[],{spaces:2})}return{success:!0}}),Gf=ge({mutationKey:["createFile"],mutationFn:e=>Mf({data:e})}),Wf=L.object({path:L.string()}),zf=se("b41e844ce533c224e7c720e69d821468deffcbf208fc008a7f5af83cb0596b15"),Hf=ae({method:"POST"}).inputValidator(Wf).handler(zf,async({data:e})=>{const t=await Ln(e.path);try{return{content:await Re.readJSON(t),path:e.path}}catch(n){throw console.error("Failed to read file",n),new Error("Failed to read file or invalid format")}}),Ur=ge({mutationKey:["readFile"],mutationFn:e=>Hf({data:e})}),Uf=L.object({path:L.string(),content:Ga}),jf=se("1b2a0d276d9ce90b2a1d72134c1bf95b9f6b7b049a8f415e8f0da3e6fc5ce4ae"),qf=ae({method:"POST"}).inputValidator(L.unknown()).handler(jf,async({data:e})=>{const t=Uf.parse(e),n=await Ln(t.path);return await Re.writeJSON(n,t.content,{spaces:2}),{success:!0}}),la=Rt({queryKey:["variables"],queryFn:_f,refetchInterval:1e4}),Kf=ge({mutationKey:["saveFile"],mutationFn:e=>qf({data:e})}),Yf=L.object({oldPath:L.string(),newPath:L.string()}),Jf=se("098d52adf25ea567d43facba347871f887828c6ab804021bbfa0f2759209c0c6"),Xf=ae({method:"POST"}).inputValidator(Yf).handler(Jf,async({data:e})=>{const t=await Ln(e.oldPath),n=await pn(),r=Ae.resolve(n,e.newPath);if(!r.startsWith(n))throw new Error("Invalid new path");return await Re.rename(t,r),{success:!0}}),Zf=ge({mutationKey:["renameFile"],mutationFn:e=>Xf({data:e})}),Qf=L.object({sourcePath:L.string(),targetPath:L.string()}),em=se("efbbc22c41cf491631b07076417c9ec65d5ac71debfcc00b5a7e0d368772104f"),tm=ae({method:"POST"}).inputValidator(Qf).handler(em,async({data:e})=>{const t=await Ln(e.sourcePath),n=await pn(),r=Ae.resolve(n,e.targetPath);if(!r.startsWith(n))throw new Error("Invalid target path");await Re.ensureDir(r);const o=Ae.basename(t),i=Ae.join(r,o);return await Re.move(t,i,{overwrite:!1}),{success:!0}});ge({mutationKey:["moveFile"],mutationFn:e=>tm({data:e})});function nm(e){const t=e?.bounds||e?.attributes?.bounds,n=t?{x:t.x,y:t.y,width:t.width,height:t.height}:void 0,r=e?.text??e?.attributes?.text??e?.name??void 0,o=e?.resourceId??e?.attributes?.["resource-id"]??void 0,i=e?.attributes?.["content-desc"]??e?.attributes?.["accessibility-text"]??e?.accessibilityText??void 0,a=e?.label??e?.attributes?.label??void 0,l=e?.accessibilityIdentifier??e?.attributes?.accessibilityIdentifier??void 0,u=e?.hint??e?.attributes?.hint??e?.value??e?.attributes?.value??void 0,c={...n?{bounds:n}:{},...r?{text:String(r)}:{},...o?{resourceId:String(o)}:{},...i?{contentDesc:String(i)}:{},...a?{accessibilityLabel:String(a)}:{},...l?{accessibilityIdentifier:String(l)}:{},...u?{hint:String(u)}:{}};return Object.keys(c).length>0?c:void 0}function rm(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){const r=nm(n);r&&t.push(r)}return t}const om=/\{\{\s*([a-zA-Z0-9_.-]+)\s*\}\}/g,jr=e=>{if(!e)return[];const t=new Set;let n;const r=new RegExp(om);for(;(n=r.exec(e))!==null;)n[1]&&t.add(n[1]);return Array.from(t)},wt=(e,t)=>{const n=t?.required??!1;return({value:r})=>{const o=String(r??"").trim();if(!o)return n?"This field is required":void 0;const i=jr(o);if(i.length===0)return;const a=e(),l=i.filter(u=>!Object.prototype.hasOwnProperty.call(a,u));if(l.length>0)return`Undefined params: ${l.join(", ")}`}},qr=L.number().min(0,"Must be 0 or greater");L.string().min(1,"This field is required");const ca=L.enum(["up","down"]),im=L.enum(["in","out"]),am=L.string().min(1,"URL is required").regex(/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\/.+$/,"Invalid deeplink format (e.g., myapp://screen)"),Ie=e=>e.length?e.map(t=>typeof t=="string"?t:t?.message).filter(Boolean).join(", "):null,sm=({step:e,onSave:t,onCancel:n})=>{const r=vn(()=>({id:Date.now(),type:"tap",descriptionText:"",optional:!1,timeout:3e3,useLlmOnly:!1,text:"",elementId:"",maxScrolls:15,direction:"down",url:"",instruction:"",path:""}),[]),{data:o}=Je(Hr),{data:i}=Je(la),a=oe.useCallback(()=>({...I.state.test.params,...i??{}}),[i]),l=new Set((o?.files||[]).filter(c=>c.type==="file").map(c=>c.path)),u=Fs({defaultValues:{...r(),...e},onSubmit:({value:c})=>{if(c&&(c.type==="tap"||c.type==="assert")&&("x"in c&&delete c.x,"y"in c&&delete c.y),c.type==="fileRef"){const p=(c.path||"").trim();if(!p||o&&!l.has(p)){alert("The specified file does not exist in your tests directory.");return}}let f;switch(c.type){case"tap":f=Ma.parse(c);break;case"assert":f=Va.parse(c);break;case"type":f=La.parse(c);break;case"scroll":f=_a.parse(c);break;case"scrollUntil":f=Fa.parse(c);break;case"deeplink":f=ka.parse(c);break;case"ai":f=Ba.parse(c);break;case"fileRef":f=$a.parse(c);break;default:f=zo.parse(c)}if(!e)I.setState(p=>({...p,test:{...p.test,steps:[...p.test.steps,f]}}));else{const p=f.id;I.setState(d=>({...d,test:{...d.test,steps:d.test.steps.map(m=>m.id===p?f:m)}}))}t()}});return v(ym,{children:[s(U,{variant:"h6",gutterBottom:!0,children:e?"Edit Step":"Add New Step"}),s("form",{onSubmit:c=>{c.preventDefault(),c.stopPropagation(),u.handleSubmit()},children:v(vm,{children:[s(u.Field,{name:"type",validators:{onChange:eo},children:c=>{const f=c.state.meta.errors.length>0;return v(Tt,{fullWidth:!0,error:f,children:[s(rn,{id:"step-type",children:"Step type"}),s(on,{labelId:"step-type",id:"step-type",value:c.state.value,label:"Step type",onChange:p=>{const d=p.target.value,m=u.state.values.id;u.reset(),u.setFieldValue("id",m),u.setFieldValue("type",d)},onBlur:c.handleBlur,children:eo.options.map(p=>s(gt,{value:p,children:p},p))}),f&&s(On,{children:Ie(c.state.meta.errors)})]})}}),s(nn,{sx:{mb:1}}),v(xm,{children:[s(Ue,{children:"General Settings"}),s(u.Field,{name:"descriptionText",validators:{onChange:wt(a,{required:!1})},children:c=>s(me,{id:"description-text",label:"Description",value:c.state.value??"",onChange:f=>c.handleChange(f.target.value),onBlur:c.handleBlur,placeholder:"Enter a description (you can use {{key}})",helperText:Ie(c.state.meta.errors)??"Use {{key}} to insert a param value",error:c.state.meta.errors?.length>0})}),s(u.Field,{name:"optional",validators:{onChange:L.boolean().optional()},children:c=>s(Pn,{control:s(ur,{checked:c.state.value??!1,onChange:f=>c.handleChange(f.target.checked)}),label:"Optional"})})]}),s(u.Subscribe,{selector:c=>c.values.type,children:c=>{switch(c){case"tap":return s(dm,{form:u});case"assert":return s(um,{form:u});case"type":return s(pm,{form:u,getDefinedParams:a});case"scroll":return s(fm,{form:u});case"zoom":return s(mm,{form:u});case"scrollUntil":return s(hm,{form:u,getDefinedParams:a});case"deeplink":return s(gm,{form:u,getDefinedParams:a});case"ai":return s(bm,{form:u,getDefinedParams:a});case"fileRef":return s(lm,{form:u,getDefinedParams:a});default:return null}}}),v(Dm,{children:[s(Be,{startIcon:s(_s,{}),variant:"contained",type:"submit",children:"Save"}),s(Be,{startIcon:s(Ls,{}),variant:"outlined",color:"error",onClick:n,children:"Cancel"})]})]})})]})},lm=({form:e,getDefinedParams:t})=>{const{data:n,isLoading:r}=Je(Hr),o=new Set((n?.files||[]).filter(i=>i.type==="file").map(i=>i.path));return v(ct,{children:[s(Ue,{children:"File Reference"}),s(e.Field,{name:"path",validators:{onChange:({value:i})=>{const a=String(i??"").trim();if(!a)return"This field is required";if(jr(a).length>0)return wt(t,{required:!0})({value:a});if(!r&&n&&!o.has(a))return"File not found in tests directory"}},children:i=>{const a=i.state.meta.errors?.length>0,l=a?Ie(i.state.meta.errors):r?"Checking files...":"Path is relative to your tests directory (supports {{key}})";return s(me,{id:"file-path",label:"File path",placeholder:"e.g., test2.json or subfolder/flow.json (you can use {{key}})",value:i.state.value??"",onChange:u=>i.handleChange(u.target.value),onBlur:i.handleBlur,error:a,helperText:l,fullWidth:!0})}}),s(e.Subscribe,{selector:i=>({path:i.values.path,overrides:i.values.overrides}),children:({path:i,overrides:a})=>s(cm,{path:i,overrides:a,onChange:l=>e.setFieldValue("overrides",l),validPaths:o})})]})},cm=({path:e,overrides:t,onChange:n,validPaths:r})=>{const[o,i]=oe.useState(!1),[a,l]=oe.useState({}),u=G(Ur);oe.useEffect(()=>{let d=!1;return(async()=>{if(!e||!r.has(e)){l({});return}i(!0);try{const m=(await u.mutateAsync({path:e}))?.content;Array.isArray(m)?l({}):l(m&&typeof m=="object"?m.params||{}:{})}catch{l({})}finally{d||i(!1)}})(),()=>{d=!0}},[e]);const c=t||{},f=(d,m)=>{const g={...c};m?g[d]=m:delete g[d],n(g)},p=Object.keys(a);return e?v(ne,{sx:{mt:2},children:[s(U,{variant:"subtitle2",children:"Param overrides"}),o?s(U,{variant:"caption",color:"text.secondary",children:"Loading referenced test…"}):p.length===0?s(U,{variant:"caption",color:"text.secondary",children:"Referenced test has no params"}):s(ne,{sx:{display:"flex",flexDirection:"column",gap:1,mt:1},children:p.map(d=>v(ne,{sx:{display:"grid",gridTemplateColumns:"160px 1fr",gap:1,alignItems:"center"},children:[s(me,{size:"small",label:"Key",value:d,disabled:!0}),v(ne,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:1},children:[s(me,{size:"small",label:"Default",value:a[d]??"",disabled:!0}),s(me,{size:"small",label:"Override (optional)",value:c[d]??"",onChange:m=>f(d,m.target.value)})]})]},d))})]}):null},dm=({form:e})=>v(ct,{children:[s(Ue,{children:"Tap Configuration"}),s(e.Field,{name:"timeout",validators:{onChange:qr},children:t=>{const n=t.state.meta.errors?.length>0;return s(me,{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:Ie(t.state.meta.errors)})}}),s(e.Field,{name:"elementId",validators:{onChange:L.string().optional()},children:t=>{const n=t.state.meta.errors?.length>0;return s(me,{id:"tap-element-id",label:"Element Identifier (elementId)",value:t.state.value??"",onChange:r=>t.handleChange(r.target.value),onBlur:t.handleBlur,placeholder:"Android: com.app:id/button | iOS: accessibilityIdentifier/name/label",error:n,helperText:Ie(t.state.meta.errors)??(I.state.selectedPlatform==="ios"?"Optional. iOS: prefer accessibilityIdentifier, otherwise name/label. Supports index like value[2].":"Optional. Android: resource-id (e.g., com.app:id/button). Supports index like id[2].")})}}),s(e.Field,{name:"useLlmOnly",validators:{onChange:L.boolean().optional()},children:t=>s(Pn,{control:s(ur,{checked:t.state.value??!1,onChange:n=>t.handleChange(n.target.checked)}),label:"Use LLM only"})})]}),um=({form:e})=>v(ct,{children:[s(Ue,{children:"Assert Configuration"}),s(e.Field,{name:"timeout",validators:{onChange:qr},children:t=>{const n=t.state.meta.errors?.length>0;return s(me,{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:Ie(t.state.meta.errors)})}}),s(e.Field,{name:"elementId",validators:{onChange:L.string().optional()},children:t=>{const n=t.state.meta.errors?.length>0;return s(me,{id:"assert-element-id",label:"Resource ID (elementId)",value:t.state.value??"",onChange:r=>t.handleChange(r.target.value),onBlur:t.handleBlur,placeholder:"e.g. com.app:id/label or com.app:id/label[1]",error:n,helperText:Ie(t.state.meta.errors)??"Optional. Android resource-id of the element to assert."})}}),s(e.Field,{name:"useLlmOnly",validators:{onChange:L.boolean().optional()},children:t=>s(Pn,{control:s(ur,{checked:t.state.value??!1,onChange:n=>t.handleChange(n.target.checked)}),label:"Use LLM only"})})]}),pm=({form:e,getDefinedParams:t})=>v(ct,{children:[s(Ue,{children:"Type Configuration"}),s(e.Field,{name:"text",validators:{onChange:wt(t,{required:!0})},children:n=>{const r=n.state.meta.errors?.length>0;return s(me,{id:"text",label:"Text to type",value:n.state.value??"",onChange:o=>n.handleChange(o.target.value),onBlur:n.handleBlur,placeholder:"Enter text to type (you can use {{key}})",multiline:!0,rows:3,error:r,helperText:Ie(n.state.meta.errors)??"Use {{key}} to insert a param value"})}})]}),fm=({form:e})=>v(ct,{children:[s(Ue,{children:"Scroll Configuration"}),s(e.Field,{name:"direction",validators:{onChange:ca},children:t=>{const n=t.state.meta.errors?.length>0;return v(Tt,{fullWidth:!0,error:n,children:[s(rn,{id:"scroll-direction",children:"Direction"}),v(on,{labelId:"scroll-direction",id:"scroll-direction",value:t.state.value??"down",label:"Direction",onChange:r=>t.handleChange(r.target.value),onBlur:t.handleBlur,children:[s(gt,{value:"up",children:"Up"}),s(gt,{value:"down",children:"Down"})]}),n&&s(On,{children:Ie(t.state.meta.errors)})]})}})]}),mm=({form:e})=>v(ct,{children:[s(Ue,{children:"Zoom Configuration"}),s(e.Field,{name:"direction",validators:{onChange:im},children:t=>{const n=t.state.meta.errors?.length>0;return v(Tt,{fullWidth:!0,error:n,children:[s(rn,{id:"zoom-direction",children:"Direction"}),v(on,{labelId:"zoom-direction",id:"zoom-direction",value:t.state.value??"in",label:"Direction",onChange:r=>t.handleChange(r.target.value),onBlur:t.handleBlur,children:[s(gt,{value:"in",children:"In (spread)"}),s(gt,{value:"out",children:"Out (pinch)"})]}),n&&s(On,{children:Ie(t.state.meta.errors)})]})}})]}),hm=({form:e,getDefinedParams:t})=>v(ct,{children:[s(Ue,{children:"Scroll Until Configuration"}),s(e.Field,{name:"direction",validators:{onChange:ca},children:n=>{const r=n.state.meta.errors?.length>0;return v(Tt,{fullWidth:!0,error:r,children:[s(rn,{id:"scroll-until-direction",children:"Direction"}),v(on,{labelId:"scroll-until-direction",id:"scroll-until-direction",value:n.state.value??"down",label:"Direction",onChange:o=>n.handleChange(o.target.value),onBlur:n.handleBlur,children:[s(gt,{value:"up",children:"Up"}),s(gt,{value:"down",children:"Down"})]}),r&&s(On,{children:Ie(n.state.meta.errors)})]})}}),s(e.Field,{name:"maxScrolls",validators:{onChange:qr},children:n=>{const r=n.state.meta.errors?.length>0;return s(me,{type:"number",id:"max-scrolls",label:"Max Scrolls",value:n.state.value??15,onChange:o=>n.handleChange(parseInt(o.target.value)||15),onBlur:n.handleBlur,placeholder:"Maximum scroll attempts",error:r,helperText:Ie(n.state.meta.errors)??"Maximum number of scroll attempts (default: 15)"})}}),s(Ue,{sx:{mt:1},children:"Stop Condition (at least one)"}),s(e.Field,{name:"text",validators:{onChange:wt(t,{required:!1})},children:n=>{const r=n.state.meta.errors?.length>0;return s(me,{id:"scroll-until-text",label:"Text to find",value:n.state.value??"",onChange:o=>n.handleChange(o.target.value),onBlur:n.handleBlur,placeholder:"Text content to scroll until visible (supports {{key}})",error:r,helperText:Ie(n.state.meta.errors)??"Scroll until this text (with params resolved) is visible on screen"})}}),s(e.Field,{name:"elementId",validators:{onChange:wt(t,{required:!1})},children:n=>{const r=n.state.meta.errors?.length>0;return s(me,{id:"scroll-until-element-id",label:"Element ID",value:n.state.value??"",onChange:o=>n.handleChange(o.target.value),onBlur:n.handleBlur,placeholder:"Element ID to scroll until visible (supports {{key}})",error:r,helperText:Ie(n.state.meta.errors)??"Scroll until element with this ID (after resolving params) is visible"})}})]}),gm=({form:e,getDefinedParams:t})=>v(ct,{children:[s(Ue,{children:"Deeplink Configuration"}),s(e.Field,{name:"url",validators:{onChange:({value:n})=>{const r=String(n??"").trim();if(!r)return"URL is required";if(jr(r).length>0)return wt(t,{required:!0})({value:r});const o=am.safeParse(r);return o.success?void 0:o.error.issues[0]?.message||"Invalid URL"}},children:n=>{const r=n.state.meta.errors?.length>0;return s(me,{id:"url",label:"URL",value:n.state.value??"",onChange:o=>n.handleChange(o.target.value),onBlur:n.handleBlur,placeholder:"Enter deeplink URL (you can use {{key}})",fullWidth:!0,error:r,helperText:Ie(n.state.meta.errors)??"Use {{key}} to insert a param value"})}})]}),bm=({form:e,getDefinedParams:t})=>v(ct,{children:[s(Ue,{children:"AI Configuration"}),s(e.Field,{name:"instruction",validators:{onChange:wt(t,{required:!0})},children:n=>{const r=n.state.meta.errors?.length>0;return s(me,{id:"instruction",label:"AI Instruction",value:n.state.value??"",onChange:o=>n.handleChange(o.target.value),onBlur:n.handleBlur,placeholder:"Enter instruction for AI to execute (you can use {{key}})",multiline:!0,rows:4,error:r,helperText:Ie(n.state.meta.errors)??"Use {{key}} to insert a param value"})}})]}),ym=It(ne)`
|
|
178
|
+
padding: 1.5rem;
|
|
179
|
+
margin-bottom: 1.5rem;
|
|
180
|
+
`,vm=It(ne)`
|
|
181
|
+
display: flex;
|
|
182
|
+
flex-direction: column;
|
|
183
|
+
gap: 1.25rem;
|
|
184
|
+
`,da=It(ne)`
|
|
185
|
+
display: flex;
|
|
186
|
+
flex-direction: column;
|
|
187
|
+
gap: 1rem;
|
|
188
|
+
padding: 1rem;
|
|
189
|
+
border-radius: 6px;
|
|
190
|
+
`,xm=It(da)`
|
|
191
|
+
background-color: #fafafa;
|
|
192
|
+
border: 1px solid #e0e0e0;
|
|
193
|
+
`,ct=It(da)`
|
|
194
|
+
background-color: #f5f5f5;
|
|
195
|
+
border: 1px dashed #bdbdbd;
|
|
196
|
+
`,Ue=It(U)`
|
|
197
|
+
font-size: 0.75rem;
|
|
198
|
+
color: #757575;
|
|
199
|
+
text-transform: uppercase;
|
|
200
|
+
letter-spacing: 0.5px;
|
|
201
|
+
margin-bottom: 0.5rem;
|
|
202
|
+
`,Dm=It(ne)`
|
|
203
|
+
display: flex;
|
|
204
|
+
gap: 0.5rem;
|
|
205
|
+
justify-content: center;
|
|
206
|
+
`,ua=48,Em=()=>{const[e,t]=fe(!1),[n,r]=fe(!1),o=ye(I,l=>l.executionLog),i=ye(I,l=>l.isPlaying);if(o.length===0&&!i)return null;const a=()=>{r(!n)};return v(wm,{$isMaximized:n,children:[v(Im,{onClick:a,children:[v(U,{variant:"subtitle2",children:["Execution Log (",o.length," steps)"]}),s(O,{size:"small",onClick:l=>{l.stopPropagation(),a()},children:n?s(Ms,{}):s(Vs,{})})]}),n&&s(Cm,{children:s(Nm,{children:o.map(l=>v(Sm,{children:[s(Om,{src:l.screenshot,alt:`Step ${l.stepNumber}`}),v(Pm,{children:[v(Am,{children:["#",l.stepNumber]}),s(Rm,{children:l.cacheHit?s(ft,{title:"Cache Hit",children:s(Gs,{color:"success",fontSize:"small"})}):s(ft,{title:"Cache Miss / Fresh Execution",children:s(Ws,{color:"info",fontSize:"small"})})})]})]},l.stepId))})})]})},wm=F(Lo)`
|
|
207
|
+
position: fixed;
|
|
208
|
+
bottom: 0;
|
|
209
|
+
left: 0;
|
|
210
|
+
right: 0;
|
|
211
|
+
z-index: 1300; // High z-index to be on top of everything
|
|
212
|
+
border-top-left-radius: 8px;
|
|
213
|
+
border-top-right-radius: 8px;
|
|
214
|
+
overflow: hidden;
|
|
215
|
+
transition: height 0.3s ease;
|
|
216
|
+
height: ${({$isMaximized:e})=>e?"400px":`${ua}px`};
|
|
217
|
+
display: flex;
|
|
218
|
+
flex-direction: column;
|
|
219
|
+
background-color: ${({theme:e})=>e.palette?.background?.paper||"#fff"};
|
|
220
|
+
box-shadow: 0px -2px 10px rgba(0,0,0,0.1);
|
|
221
|
+
`,Im=F.div`
|
|
222
|
+
height: ${ua}px;
|
|
223
|
+
padding: 0 16px;
|
|
224
|
+
display: flex;
|
|
225
|
+
align-items: center;
|
|
226
|
+
justify-content: space-between;
|
|
227
|
+
cursor: pointer;
|
|
228
|
+
background-color: rgba(0, 0, 0, 0.05);
|
|
229
|
+
&:hover {
|
|
230
|
+
background-color: rgba(0, 0, 0, 0.08);
|
|
231
|
+
}
|
|
232
|
+
flex-shrink: 0;
|
|
233
|
+
`,Cm=F.div`
|
|
234
|
+
flex: 1;
|
|
235
|
+
overflow-x: auto;
|
|
236
|
+
overflow-y: hidden;
|
|
237
|
+
padding: 16px;
|
|
238
|
+
background-color: rgba(0,0,0,0.02);
|
|
239
|
+
`,Nm=F.div`
|
|
240
|
+
display: flex;
|
|
241
|
+
gap: 16px;
|
|
242
|
+
height: 100%;
|
|
243
|
+
align-items: center;
|
|
244
|
+
`,Sm=F.div`
|
|
245
|
+
position: relative;
|
|
246
|
+
height: 100%;
|
|
247
|
+
aspect-ratio: 9/16; // Assumes mobile portrait roughly, will adjust to image
|
|
248
|
+
border-radius: 8px;
|
|
249
|
+
overflow: hidden;
|
|
250
|
+
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
|
251
|
+
background: #000;
|
|
252
|
+
flex-shrink: 0;
|
|
253
|
+
`,Om=F.img`
|
|
254
|
+
width: 100%;
|
|
255
|
+
height: 100%;
|
|
256
|
+
object-fit: contain;
|
|
257
|
+
`,Pm=F.div`
|
|
258
|
+
position: absolute;
|
|
259
|
+
top: 0;
|
|
260
|
+
left: 0;
|
|
261
|
+
right: 0;
|
|
262
|
+
padding: 4px 8px;
|
|
263
|
+
display: flex;
|
|
264
|
+
justify-content: space-between;
|
|
265
|
+
align-items: start;
|
|
266
|
+
background: linear-gradient(to bottom, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0) 100%);
|
|
267
|
+
`,Am=F.span`
|
|
268
|
+
color: white;
|
|
269
|
+
font-weight: bold;
|
|
270
|
+
font-size: 14px;
|
|
271
|
+
text-shadow: 0 1px 2px rgba(0,0,0,0.8);
|
|
272
|
+
`,Rm=F.div`
|
|
273
|
+
display: flex;
|
|
274
|
+
align-items: center;
|
|
275
|
+
justify-content: center;
|
|
276
|
+
background: rgba(255,255,255,0.9);
|
|
277
|
+
border-radius: 50%;
|
|
278
|
+
padding: 2px;
|
|
279
|
+
`,fn=new ha({open:!1,maintainDisplayed:!1});function Tm(){fn.setState(e=>({...e,open:!1}))}function Kr(e,t){fn.setState({type:"success",title:t?.title??"Success",description:e,listContent:t?.listContent,open:!0,maintainDisplayed:t?.maintainDisplayed??!1})}function sr(e,t){fn.setState({type:"error",title:t?.title??"Error",description:e,listContent:t?.listContent,open:!0,maintainDisplayed:t?.maintainDisplayed??!1})}function $m(e,t){fn.setState({type:"info",title:t?.title,description:e,listContent:t?.listContent,open:!0,maintainDisplayed:t?.maintainDisplayed??!1})}const Bm=/\{\{\s*([a-zA-Z0-9_.-]+)\s*\}\}/g;function km(e,t){const n=new Set;return{value:e.replace(Bm,(r,o)=>Object.prototype.hasOwnProperty.call(t,o)?t[o]??"":(n.add(o),"")),missing:Array.from(n)}}function St(e,t){const n={...e},r={},o=i=>{const a=n[i];if(typeof a=="string"&&a.includes("{{")){const{value:l,missing:u}=km(a,t);n[i]=l,u.length&&(r[i]=u)}};return o("descriptionText"),o("text"),o("elementId"),o("url"),o("instruction"),o("path"),{step:n,missingMap:r}}const Fm=({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 s(Tp,{step:e,...a});case"assert":return s($p,{step:e,...a});case"type":return s(Bp,{step:e,...a});case"scroll":return s(kp,{step:e,...a});case"swipe":return s(Fp,{step:e,...a});case"zoom":return s(_p,{step:e,...a});case"scrollUntil":return s(Lp,{step:e,...a});case"deeplink":return s(Vp,{step:e,...a});case"ai":return s(Mp,{step:e,...a});case"fileRef":return s(Rp,{step:e,...a});default:return null}},_m=({onSave:e,canSave:t})=>{const[n,r]=fe(!1),[o,i]=fe(void 0),a=ye(I,b=>b.isRecording),l=ye(I,b=>b.test.steps),u=ye(I,b=>b.isPlaying),c=ye(I,b=>b.selectedPlatform),f=ye(I,b=>b.selectedDeviceId),{data:p=[]}=Je(ra),d=W(null),m=()=>{I.setState(b=>({...b,isRecording:!b.isRecording}))},g=G(Vr),y=G(Mr),x=G(Gr),D=G(Xp),E=G(rf),P=G(ef),N=G(Wr);G(vf);const T=G(pf),A=G(Pf),j=G(zr),Q=G(Tf),be=G(Ur),ue=Sn(),w=(b,C,R)=>{I.setState(B=>({...B,test:{...B.test,steps:B.test.steps.map(M=>M.id===b?{...M,status:C,statusColor:R}:M)}}))},ee=b=>{I.setState(C=>({...C,currentStepId:b}))},{data:Ee}=Je(la),Ne=b=>new Promise(C=>setTimeout(C,b)),Nt=async()=>{try{const b=await T.mutateAsync({platform:c,deviceId:f});if(!b.success||!b.base64)throw new Error(b.error||"Failed to capture screenshot");const C=(b.base64.length*.75/(1024*1024)).toFixed(2);return console.log(`[Editor] Captured screenshot: ~${C} MB (${b.base64.length} chars)`),b.base64}catch(b){throw console.error("Screenshot failed:",b),b}},_=b=>new Promise(C=>{const R=new Image;R.onload=()=>C({width:R.naturalWidth,height:R.naturalHeight}),R.src=b}),q=async(b,C,R,B,M=[],pe,ce)=>{w(b,"Starting Smart Loop...","purple");try{let H=0;const le=15;let $=[...M],J,X=!1;const Z=[];for(;H<le;){if(d.current?.signal.aborted)throw new Error("Aborted");let te="",de=[],Ke=!1;const vt=2e3,we=500,he=Math.floor(vt/we);for(let K=0;K<he;K++){if(d.current?.signal.aborted)throw new Error("Aborted");te=await Nt();try{const{width:re,height:Oe}=await _(te);console.log(`Checking cache (Attempt ${K+1}/${he}) with:`,{stepNumber:C,description:R,platform:c,resolution:{width:re,height:Oe},highest_used_index:J});const st=await A.mutateAsync({stepNumber:C,stepDescription:R,filepath:ce,screenshot:te,platform:c,screenResolution:{width:re,height:Oe},highest_used_index:J});if(console.log("Cache result:",st),st.found&&st.cacheCommands){de=st.cacheCommands,J=st.cacheIndex,Ke=!0,w(b,`Cache Hit! (${de.length} cmds)`,"green");break}}catch(re){console.warn("Cache check failed:",re)}K<he-1&&(w(b,`Cache miss, retrying... (${K+1}/${he})`,"orange"),await Ne(we))}I.setState(K=>({...K,executionLog:[...K.executionLog,{stepId:b,stepNumber:C,screenshot:te,cacheHit:Ke,timestamp:Date.now()}]}));let Le=[],Se=[];if(!Ke){X=!0,w(b,"Cache Miss. Asking AI...","orange");let K;if(pe)try{const ze=await ue.fetchQuery(na({enabled:!0}));K=rm(ze.elements)}catch(ze){console.warn("Failed to fetch visible elements for uiHierarchy:",ze)}const re=await Q.mutateAsync({base64_screenshot:te.replace(/^data:image\/\w+;base64,/,""),instruction:B,action_history:$,elementId:pe,uiHierarchy:K});Se=re.appetizeCommands||[];const Oe=re.gptCommands?.findIndex(ze=>ze.startsWith("reasoning:"));if(Oe!==-1){Le=re.gptCommands?.slice(Oe)||[];const ze=Le.filter(Mt=>Mt.startsWith("remember:"));ze?.length>0&&M.push(...ze),$=[...$,...Le]}const st=re.gptCommands||[];de=[...Se]}Z.push({screenshot:te,commands:Se.length>0?Se:de});let Ye=!1,Vt=!1;de.length>0&&(console.log(`[Step ${b}] Executing commands:`,de),Ke&&w(b,`Executing ${de.length} cached commands...`,"blue"));for(const K of de){if(d.current?.signal.aborted)throw new Error("Aborted");if(K.toLowerCase().includes("task complete:")){Vt=!0;continue}if(K.toLowerCase().includes("error detected:"))throw new Error(`AI Reported Error: ${K}`);if(K.startsWith("remember:")&&M.push(K),K.match(/^t(ap|ab)On:/)){console.log(`Tap Match: ${K}`);let re,Oe;const st=K.match(/x=(\d+)/),ze=K.match(/y=(\d+)/);if(st&&ze)re=parseInt(st[1],10),Oe=parseInt(ze[1],10);else{const Mt=K.split(";");Mt.length>=3&&(re=parseInt(Mt[1],10),Oe=parseInt(Mt[2],10))}console.log(`Tap: ${re},${Oe}`),re!==void 0&&Oe!==void 0&&(w(b,`Exec: Tap ${re},${Oe}`,"blue"),await g.mutateAsync({x:re,y:Oe,platform:c,deviceId:f}),Ye=!0)}else if(K.startsWith("wait:")){const re=K.match(/wait:\s*(\d+)/)?.[1];if(re){const Oe=parseInt(re,10);w(b,`Exec: Wait ${Oe}s`,"blue"),await Ne(Oe*1e3),Ye=!0}}else if(K.startsWith("scroll:")){const re=K.match(/scroll:\s*(up|down)/i)?.[1];re&&(w(b,`Scroll ${re}`,"blue"),await x.mutateAsync({direction:re.toLowerCase(),platform:c,deviceId:f}),Ye=!0)}}if(Ye&&(Ke&&$.push(...de),await Ne(100)),Vt){if(w(b,"Task Completed.","green"),X){w(b,"Populating Cache...","green");try{await j.mutateAsync({stepNumber:C,stepDescription:R,filepath:ce,executionData:Z,platform:c,screenResolution:await _(Z[0].screenshot)}),console.log("Cache populated successfully")}catch(K){console.error("Failed to populate cache:",K)}}else console.log("Skipping cache population (all actions cached)"),w(b,"Task Completed (Cached)","green");return!0}H++}throw new Error("Smart Loop Timeout")}catch(H){throw H}},k=async(b,C,R,B=[])=>{if(R.aborted)return!1;ee(b.id),w(b.id,"Executing...","blue");const M={platform:c,deviceId:f},pe=Date.now();try{let ce;const H=()=>I.state.currentScreenshot||void 0;switch(b.type){case"tap":{let $=b.descriptionText;$||(b.elementId&&b.elementId.trim()?$=`tap the element with id "${b.elementId}"`:b.x!==void 0&&b.y!==void 0?$=`tap on the screen at x=${b.x} y=${b.y}`:$="tap on the screen"),await q(b.id,C,b.descriptionText||"tap",$,B,b.elementId,b?.originRef?.path);break}case"swipe":{const $=b,J=typeof $.duration=="number"?$.duration:500;let X=1080,Z=1920;try{const Le=await Nt(),Se=await _(Le);X=Se.width,Z=Se.height}catch(Le){console.warn("Falling back to default screen size for swipe computation",Le)}let te;typeof $.x=="number"?te=Math.round($.x):te=$.direction==="left"?Math.round(X*.8):Math.round(X*.2);let de;typeof $.y=="number"?de=Math.round($.y):de=Math.round(Z*.5);const Ke=Math.max(80,Math.round(X*.5));let vt=$.direction==="left"?te-Ke:te+Ke,we=de;const he=5;te=Math.min(Math.max(he,te),X-he),de=Math.min(Math.max(he,de),Z-he),vt=Math.min(Math.max(he,vt),X-he),we=Math.min(Math.max(he,we),Z-he),await N.mutateAsync({x1:te,y1:de,x2:vt,y2:we,duration:J,...M}),w(b.id,"Swipe Performed","green");break}case"assert":{let $=`Verify that: ${b.descriptionText}`;!b.descriptionText&&b.elementId&&($=`Verify element with id ${b.elementId} exists`),await q(b.id,C,b.descriptionText||"assert",$,B,b.elementId,b?.originRef?.path),w(b.id,"Assertion Passed","green");break}case"ai":{const $={...Ee,...I.state.test.params},{step:J,missingMap:X}=St(b,$);if(X.instruction?.length)throw new Error(`Missing params for placeholders -> instruction: ${X.instruction.join(", ")}`);await q(b.id,C,J.instruction,J.instruction,B,void 0,b?.originRef?.path);break}case"type":{ce=H();const $={...Ee,...I.state.test.params},{step:J,missingMap:X}=St(b,$);if(Object.keys(X).length){const Z=Object.entries(X).map(([te,de])=>`${te}: ${de.join(", ")}`).join("; ");throw new Error(`Missing params for placeholders -> ${Z}`)}await y.mutateAsync({text:J.text,...M}),w(b.id,"Typed","green");break}case"scroll":{ce=H(),await x.mutateAsync({direction:b.direction,...M}),w(b.id,"Scrolled","green");break}case"zoom":{ce=H(),await P.mutateAsync({direction:b.direction,...M}),w(b.id,"Zoomed","green");break}case"scrollUntil":{ce=H();const $={...Ee,...I.state.test.params},{step:J,missingMap:X}=St(b,$);if(X.text?.length)throw new Error(`Missing params for placeholders -> text: ${X.text.join(", ")}`);w(b.id,"Scrolling until found...","blue");const Z=await D.mutateAsync({text:J.text,elementId:J.elementId,direction:J.direction,maxScrolls:J.maxScrolls,...M});if(Z.success)w(b.id,`Found after ${Z.scrolls??0} scrolls`,"green");else throw new Error("Target not found after scrolling");break}case"deeplink":{ce=H();const $={...Ee,...I.state.test.params},{step:J,missingMap:X}=St(b,$);if(X.url?.length)throw new Error(`Missing params for placeholders -> url: ${X.url.join(", ")}`);await E.mutateAsync({url:J.url,...M}),w(b.id,"Opened deeplink","green");break}case"fileRef":{w(b.id,"Loading steps from file...","blue");const $={...Ee,...I.state.test.params},{step:J,missingMap:X}=St(b,$);if(X.path?.length)throw new Error(`Missing params for placeholders -> path: ${X.path.join(", ")}`);const Z=(await be.mutateAsync({path:J.path}))?.content;let te=[],de={};if(Array.isArray(Z))te=Z;else if(Z&&Array.isArray(Z.steps))te=Z.steps,de=Z.params||{};else throw new Error("Referenced file must be an array or an object with steps");const Ke={...Ee,...I.state.test.params,...de,...b.overrides},vt=zo.array().parse(te).map((we,he)=>{const Le=typeof we.id=="number"?we.id:Date.now()+he,{step:Se,missingMap:Ye}=St(we,Ke);if(Se.type==="type"&&Ye.text?.length||Se.type==="scrollUntil"&&Ye.text?.length||Se.type==="deeplink"&&Ye.url?.length||Se.type==="ai"&&Ye.instruction?.length){const Vt=[];for(const[K,re]of Object.entries(Ye))re.length&&Vt.push(`${K}: ${re.join(", ")}`);throw new Error(`Referenced step has missing params -> ${Vt.join("; ")}`)}return{id:Le,...Se,originRef:{refId:b.id,path:b.path,descriptionText:b.descriptionText,optional:b.optional,overrides:b.overrides,stepNumber:he+1}}});I.setState(we=>{const he=we.test.steps.findIndex(Se=>Se.id===b.id);if(he===-1)return we;const Le=[...we.test.steps];return Le.splice(he,1,...vt),{...we,test:{...we.test,steps:Le}}}),w(b.id,"Expanded steps from file","green");break}}await Ne(100);const le=Date.now()-pe;return console.log(`[Step ${b.id}] Execution Finished. Total Duration: ${le}ms`),ce&&I.setState($=>({...$,executionLog:[...$.executionLog,{stepId:b.id,stepNumber:C,screenshot:ce,cacheHit:!1,timestamp:Date.now()}]})),!0}catch(ce){const H=ce instanceof Error?ce.message:"Unknown error";return b.optional?(w(b.id,`Failed (optional): ${H}`,"orange"),!0):(w(b.id,`Error: ${H}`,"red"),!1)}},Te=()=>{I.setState(b=>{const C=b.test.steps,R=[],B=new Set,M=new Set;let pe=0;for(;pe<C.length;){const H=C[pe];if(H?.type==="fileRef"){const le=H.path;if(M.has(le)){pe++;continue}B.add(H.id),M.add(le),R.push(H),pe++;continue}if(H&&H.originRef){const le=H.originRef.refId,$=H.originRef.path,J=H.originRef.descriptionText,X=H.originRef.optional;let Z=pe;for(;Z<C.length&&C[Z]?.originRef?.refId===le;)Z++;if(B.has(le)||M.has($)){pe=Z;continue}const te={id:le,type:"fileRef",path:$,descriptionText:J,optional:X,overrides:H?.originRef?.overrides};R.some(de=>de.id===te.id)&&(te.id=Date.now()),R.push(te),B.add(te.id),M.add($),pe=Z;continue}R.push(H),pe++}const ce=[];for(const H of R){const le=ce[ce.length-1];le?.type==="fileRef"&&H?.type==="fileRef"&&le.path===H.path||ce.push(H)}return{...b,test:{...b.test,steps:ce}}})},$e=async(b,C)=>{if(console.log("Running playback from index:",b),I.state.test.steps.length===0){alert("No steps to play!");return}d.current=new AbortController;const R=d.current.signal;I.setState(le=>({...le,isPlaying:!0})),I.setState(le=>({...le,test:{...le.test,steps:le.test.steps.map(($,J)=>J>=b?{...$,status:"",statusColor:""}:$)},executionLog:[]}));let B=b;const M=b+1,pe=[];let ce=!1,H;for(;!R.aborted;){const le=I.state.test.steps,$=C?M:le.length;if(B>=$)break;const J=le[B],X=J.type,Z=J?.originRef?.stepNumber??B+1;if(!await k(J,Z,R,pe)&&!J.optional){ce=!0,H=I.state.test.steps.find(te=>te.id===J.id)?.status||"Execution failed";break}if(X==="fileRef"){if(C)break;continue}B++}await Ne(500),Te(),ee(null),I.setState(le=>({...le,isPlaying:!1})),d.current=null,R.aborted||(ce?sr(H||"Playback failed",{title:"Execution Failed"}):Kr("Playback finished successfully",{title:"Execution Completed"}))},qe=()=>$e(0,!1),Ft=b=>{const C=l.findIndex(R=>R.id===b);C!==-1&&$e(C,!0)},yt=b=>{const C=l.findIndex(R=>R.id===b);C!==-1&&$e(C,!1)},dt=()=>{d.current?.abort(),Te(),I.setState(b=>({...b,isPlaying:!1})),ee(null),$m("Playback stopped",{title:"Stopped"})},it=b=>{i(b),r(!1)},at=()=>{r(!1),i(void 0)},We=()=>{r(!1),i(void 0)},mn=b=>{confirm("Delete this step?")&&I.setState(C=>({...C,test:{...C.test,steps:C.test.steps.filter(R=>R.id!==b)}}))},_t=()=>{confirm("Are you sure you want to clear all steps?")&&I.setState(b=>({...b,test:{...b.test,steps:[]}}))},Lt=u||a,ut=n||!!o;return v(Lm,{$hasForm:ut,children:[v(Wm,{children:[s(me,{variant:"standard",value:ye(I,b=>b.test.name),onChange:b=>{I.setState(C=>({...C,test:{...C.test,name:b.target.value}}))},placeholder:"Untitled",InputProps:{disableUnderline:!0,style:{fontSize:"1.5rem",fontWeight:500}},fullWidth:!0,sx:{mr:2}}),e&&s(Be,{variant:"contained",color:"primary",onClick:e,disabled:!t||u,sx:{flexShrink:0},children:"Save"})]}),s(nn,{}),v(Vm,{children:[s(Be,{variant:a?"contained":"outlined",color:a?"error":"primary",startIcon:a?s(Vo,{}):s(wa,{}),onClick:m,children:a?"Stop Recording":"Record"}),u?s(Be,{variant:"contained",color:"error",onClick:dt,children:"Stop"}):s(Be,{variant:"contained",disabled:a||l.length===0,onClick:qe,startIcon:s(Ia,{}),children:"Run from start"}),s(Be,{variant:"outlined",disabled:Lt||l.length===0,onClick:_t,children:"Clear All"})]}),s(cr,{open:n||!!o,onClose:We,maxWidth:"md",fullWidth:!0,children:s(dr,{children:s(ne,{pt:1,children:s(sm,{step:o,onSave:at,onCancel:We})})})}),v(Mm,{children:[l.length===0?s(Gm,{children:s(U,{color:"text.secondary",children:"No steps recorded yet. Enable recording and click on the device screen to add steps."})}):s(zi,{onDragEnd:b=>{const{source:C,destination:R}=b;if(!R||C.index===R.index)return;const B=[...I.state.test.steps],[M]=B.splice(C.index,1);B.splice(R.index,0,M),I.setState(pe=>({...pe,test:{...pe.test,steps:B}}))},children:s(Cn,{droppableId:"steps-droppable",children:b=>v("div",{ref:b.innerRef,...b.droppableProps,children:[l.map((C,R)=>s(Fr,{draggableId:String(C.id),index:R,children:(B,M)=>s("div",{ref:B.innerRef,...B.draggableProps,...B.dragHandleProps,style:{...B.draggableProps.style,opacity:M.isDragging?.9:1},children:s(Fm,{step:C,index:R,onPlay:()=>Ft(C.id),onPlayFromHere:()=>yt(C.id),onEdit:()=>it(C),onDelete:()=>mn(C.id)})})},C.id)),b.placeholder]})})}),!ut&&s(ne,{mt:2,display:"flex",justifyContent:"center",children:s(Be,{variant:"contained",disabled:Lt,onClick:()=>r(!0),fullWidth:!0,children:"+ Add Step"})})]}),s(Em,{})]})},Lm=F(_n)`
|
|
280
|
+
display: grid;
|
|
281
|
+
grid-template-areas:
|
|
282
|
+
'header'
|
|
283
|
+
'divider'
|
|
284
|
+
'actions'
|
|
285
|
+
'steps';
|
|
286
|
+
grid-template-rows: auto auto auto minmax(0, 1fr);
|
|
287
|
+
row-gap: 0.75rem;
|
|
288
|
+
overflow: hidden;
|
|
289
|
+
`,Vm=F.div`
|
|
290
|
+
display: flex;
|
|
291
|
+
gap: 0.5rem;
|
|
292
|
+
flex-wrap: wrap;
|
|
293
|
+
`,Mm=F.div`
|
|
294
|
+
overflow-y: auto;
|
|
295
|
+
padding-right: 0.5rem;
|
|
296
|
+
`,Gm=F.div`
|
|
297
|
+
display: flex;
|
|
298
|
+
align-items: center;
|
|
299
|
+
justify-content: center;
|
|
300
|
+
height: 100%;
|
|
301
|
+
padding: 2rem;
|
|
302
|
+
text-align: center;
|
|
303
|
+
`,Wm=F.div`
|
|
304
|
+
grid-area: header;
|
|
305
|
+
display: flex;
|
|
306
|
+
justify-content: space-between;
|
|
307
|
+
align-items: center;
|
|
308
|
+
`,zm=(e,t,n,r,o,i)=>o>=e&&o<=e+n&&i>=t&&i<=t+r,Hm=({dimensions:e,elements:t,mouse:n})=>{if(t.length===0)return null;const r=t.filter(o=>{const i=o.bounds;if(i==null)return!1;const a=o.text??o.attributes?.text,l=o.resourceId??o.attributes?.["resource-id"],u=o.accessibilityText??o.attributes?.accessibilityText??o.attributes?.["accessibility-text"]??o.attributes?.["content-desc"],c=o.accessibilityIdentifier??o.attributes?.accessibilityIdentifier,f=o.name??o.attributes?.name,p=o.label??o.attributes?.label,d=o.value??o.attributes?.value;if(!a&&!l&&!u&&!c&&!f&&!p&&!d)return!1;const{x:m,y:g,width:y,height:x}=i,{x:D,y:E,elementWidth:P,elementHeight:N}=n;return D===null||E===null||P===null||N===null?!1:zm(m/e.width,g/e.height,y/e.width,x/e.height,D/P,E/N)});return r.length===0?null:r.sort((o,i)=>{if(o.bounds==null&&i.bounds==null)return 0;if(o.bounds==null)return 1;if(i.bounds==null)return-1;const a=o.drawingOrderPath??o.indexPath??[],l=i.drawingOrderPath??i.indexPath??[];for(let u=0;u<Math.min(a.length,l.length);u++){const c=parseInt(a[u]),f=parseInt(l[u]);if(c!==f)return f-c}return a.length!==l.length?l.length-a.length:o.bounds.width*o.bounds.height-i.bounds.width*i.bounds.height})[0]},To=(e,t)=>`${Math.round(100*e/t)}%`,Um=e=>{if(typeof e.x!="number"||typeof e.y!="number"||typeof e.elementWidth!="number"||typeof e.elementHeight!="number")return null;const t=To(e.x,e.elementWidth),n=To(e.y,e.elementHeight);return`${t}, ${n}`},jm=({open:e,handleClose:t,options:n,onAfterCopy:r})=>{const o=lr(()=>n?typeof n[0]=="string"?n.map(c=>({label:c,value:c})):n:[],[n]),[i,a]=fe(""),l=vn(()=>{a(""),t()},[t]),u=vn(async()=>{const c=i||(o[0]?.value??"");if(c){try{await navigator.clipboard.writeText(c),Kr("Copied to clipboard")}catch{}r?.(),l()}},[i,o,r,l]);return v(cr,{open:e,onClose:l,maxWidth:"md",fullWidth:!0,children:[s(ko,{children:"Select an attribute"}),s(dr,{children:s(Tt,{children:s(va,{name:"attribute-options",children:o.map(c=>s(Pn,{value:c.value,control:s(xa,{}),label:c.label,onChange:()=>a(c.value)},`${c.label}-${c.value}`))})})}),v(Fo,{children:[s(Be,{color:"error",onClick:l,children:"Cancel"}),s(Be,{onClick:u,disabled:!i&&o.length===0,variant:"contained",children:"Copy"})]})]})},qm=se("f8084cb106c8126bb2deaeef7c98992d9ff9475ad3dc85c6ced04f08c3962b6e"),Km=ae({method:"POST"}).inputValidator(Ts).handler(qm,async({data:e})=>({description:await $s(e)})),pa=ge({mutationKey:["ai","describe"],mutationFn:e=>Km({data:e})});function Ym(e){return e.normalize("NFKC").replace(`
|
|
309
|
+
`,"").replace(/['`´''‚‛′’]/g,"'").replace(/[""„‟″]/g,'"').replace(/[–—]/g,"-").replace(/[\u00A0\u2000-\u200A\u202F\u205F]/g," ").replace(/[\u200B-\u200F\uFEFF]/g,"").replace(/[\uE000-\uF8FF]|[\u{F0000}-\u{FFFFD}]|[\u{100000}-\u{10FFFD}]/gu,"").trim()}const Jm=()=>{const e=ye(I,w=>w.mode),t=ye(I,w=>w.isRecording),n=ye(I,w=>w.enableAnimations);Sn();const r=W(null),[o,i]=fe(!1),[a,l]=fe(!1),[u,c]=fe([]),{data:f=[]}=Je(ra),p=ye(I,w=>w.selectedDeviceId);ye(I,w=>w.selectedPlatform),Ce(()=>{if(!p&&f.length>0){const w=f[0];I.setState(ee=>({...ee,selectedDeviceId:w.id,selectedPlatform:w.platform}))}},[f,p]);const d=f.find(w=>w.id===p),{data:m,isError:g,isLoading:y}=Je({...ea({platform:d?.platform,deviceId:d?.id}),refetchInterval:250,enabled:!!d});Ce(()=>{const w=m?.base64;w&&I.setState(ee=>({...ee,currentScreenshot:w}))},[m]);const{data:x}=Je({...df({platform:d?.platform,deviceId:d?.id}),enabled:!!d,refetchInterval:1e3}),D=G(sf),{data:E}=Je({...na({enabled:o&&!!d}),refetchInterval:o?1e3:!1});Ce(()=>{d?.id&&x?.connected===!1&&!D.isPending&&D.mutate({platform:d.platform,deviceId:d.id})},[d,x?.connected]);const P=m?.success??!1,N=x?.connected??!1,T=P&&N,A=m?.base64,j=G(Ef);G(Vr),G(Mr),G(Gr),G(Wr),G(ta),G(pa),G(zr);const Q=async()=>{const w=!n;I.setState(ee=>({...ee,enableAnimations:w})),w||await j.mutateAsync()},be=()=>{I.setState(w=>({...w,isRecording:!w.isRecording}))},ue=y?"Connecting...":g?"Error":T?"Connected":P&&!N?"Starting Appium...":"Disconnected";return v(nh,{children:[v(rh,{children:[s(U,{variant:"h5",children:"Device"}),v(oh,{children:[s(ft,{title:t?"Stop Recording":"Start Recording",children:s(O,{onClick:be,color:t?"error":"default",size:"small",children:t?s(Vo,{}):s(Ca,{})})}),s(ft,{title:o?"Disable UI Inspector":"Enable UI Inspector",children:s(O,{onClick:()=>i(!o),color:o?"primary":"default",size:"small",children:s(Na,{})})}),s(ft,{title:n?"Disable Animations":"Enable Animations",children:s(O,{onClick:Q,color:n?"primary":"default",size:"small",children:s(Sa,{})})})]})]}),s(nn,{}),v(ih,{children:[v(ne,{display:"flex",alignItems:"center",gap:1,flexGrow:1,children:[v(Tt,{size:"small",sx:{minWidth:150,flex:1},children:[s(rn,{children:"Device"}),s(on,{value:p||"",label:"Device",onChange:w=>{const ee=w.target.value,Ee=f.find(Ne=>Ne.id===ee);I.setState(Ne=>({...Ne,selectedDeviceId:ee,selectedPlatform:Ee?.platform||"android"}))},children:f.map(w=>v(gt,{value:w.id,children:[w.name," (",w.platform,")"]},w.id))})]}),s(ah,{connected:T,children:ue})]}),t&&v(ga,{color:"primary",exclusive:!0,value:e,onChange:(w,ee)=>{ee&&I.setState(Ee=>({...Ee,mode:ee}))},"aria-label":"Mode",size:"small",children:[s(Yr,{value:"interact",children:"Interact"}),s(Yr,{value:"assert",children:"Assert"})]})]}),s(sh,{children:A?v(dh,{children:[s(lh,{ref:r,src:A,alt:"Device Screen",draggable:!1,recording:t}),s(eh,{imgRef:r,uiDisabled:o,platform:d?.platform||"android",deviceId:d?.id,src:A}),o&&E?.elements&&s(th,{imgRef:r,deviceWidth:E.width,deviceHeight:E.height,elements:E.elements,onPickAttributes:w=>{c(w),l(!0)}})]}):s(ch,{children:f.length===0?s(U,{variant:"body2",color:"text.secondary",children:"No devices found."}):p?v(Nn,{children:[s(Bo,{}),s(U,{variant:"body2",color:"text.secondary",children:"Connecting to device..."})]}):s(U,{variant:"body2",color:"text.secondary",children:"Select a device."})})}),s(jm,{open:a,handleClose:()=>l(!1),options:u,onAfterCopy:()=>{i(!1)}})]})},Xm=50,Zm=10,Qm=250,eh=({imgRef:e,uiDisabled:t,platform:n,deviceId:r,src:o})=>{const i=W(null);qo(i,{enterDelay:0,leaveDelay:0});const a=ye(I,_=>_.isRecording),l=ye(I,_=>_.mode),u=G(Vr),c=G(Mr),f=G(Gr),p=G(Wr),d=G(ta),m=Sn(),g=G(pa),y=G(zr),x=W(null),D=W(""),E=W(null),P=()=>({platform:n||"android",deviceId:r}),N=(_,q)=>{const k=e.current;if(!k)return null;const Te=k.getBoundingClientRect(),$e=k.naturalWidth/Te.width,qe=k.naturalHeight/Te.height,Ft=Math.round((_-Te.left)*$e),yt=Math.round((q-Te.top)*qe);return{x:Ft,y:yt,rect:Te,img:k}},T=(_,q,k,Te=500)=>{try{const $e={id:Date.now(),type:"swipe",direction:_,x:q,y:k,duration:Te,descriptionText:void 0};I.setState(qe=>({...qe,test:{...qe.test,steps:[...qe.test.steps,$e]}}))}catch($e){console.warn("Failed to record swipe step",$e)}},A=_=>{try{const q={id:Date.now(),type:"scroll",direction:_};I.setState(k=>({...k,test:{...k.test,steps:[...k.test.steps,q]}}))}catch(q){console.warn("Failed to record scroll step",q)}},j=()=>{if(!a)return;const _=D.current;if(!_)return;const q={id:Date.now(),type:"type",text:_};I.setState(k=>({...k,test:{...k.test,steps:[...k.test.steps,q]}})),D.current="",E.current&&(window.clearTimeout(E.current),E.current=null)},Q=W(0),be=W(null),ue=180,w=40,ee=_=>{if(t)return;const q=N(_.clientX,_.clientY);q&&(x.current={x:q.x,y:q.y,t:Date.now()},i.current?.focus())},Ee=async _=>{if(t)return;const q=x.current;x.current=null;const k=N(_.clientX,_.clientY);if(!q||!k)return;const Te=k.x-q.x,$e=k.y-q.y,qe=Math.hypot(Te,$e),Ft=Date.now()-q.t,yt=P();if(qe<=Zm&&Ft<=Qm){const dt=o;if(l!=="assert"&&await u.mutateAsync({x:k.x,y:k.y,...yt}),a&&k.img){const it=k.img,at=document.createElement("canvas"),We=100;at.width=We,at.height=We;const mn=at.getContext("2d");let _t;mn&&(mn.drawImage(it,k.x-We/2,k.y-We/2,We,We,0,0,We,We),_t=at.toDataURL("image/jpeg",.8));let Lt="";try{Lt=(await d.mutateAsync({x:k.x,y:k.y}))?.elementId||""}catch{}const ut=Date.now();I.setState(b=>({...b,test:{...b.test,steps:[...b.test.steps,{id:ut,type:l==="assert"?"assert":"tap",x:k.x,y:k.y,cropBase64:_t,elementId:Lt,descriptionText:"Generating description..."}]}})),(async()=>{let b=dt;if(l==="interact"&&(await new Promise(C=>setTimeout(C,2e3)),r))try{const C=await m.fetchQuery({...ea({platform:n||"android",deviceId:r}),staleTime:0});C?.base64&&(b=C.base64)}catch(C){console.error("Failed to fetch post-action screenshot",C)}try{const C=await g.mutateAsync({fullImage:dt??"",croppedImage:_t,targetImage:b??"",type:l==="assert"?"assert":"interaction"});I.setState(R=>({...R,test:{...R.test,steps:R.test.steps.map(B=>B.id===ut?{...B,descriptionText:C.description}:B)}}));try{const R=I.state.test.steps,B=R.findIndex(pe=>pe.id===ut),M=B!==-1?B+1:R.length;y.mutate({stepNumber:M,stepDescription:C.description,filepath:void 0,executionData:[{screenshot:dt,commands:l==="interact"?[`tapOn: x=${k.x} y=${k.y}`,"Task complete:"]:["Task complete:"]}],platform:n||"android",screenResolution:{width:it.naturalWidth,height:it.naturalHeight}})}catch(R){console.error("Error populating cache:",R)}}catch(C){console.error("Failed to describe interaction",C);const R=l==="assert"?"Assert Element":"Tap Interaction";I.setState(B=>({...B,test:{...B.test,steps:B.test.steps.map(M=>M.id===ut?{...M,descriptionText:R}:M)}}));try{const B=I.state.test.steps,M=B.findIndex(ce=>ce.id===ut),pe=M!==-1?M+1:B.length;y.mutate({stepNumber:pe,stepDescription:R,filepath:void 0,executionData:[{screenshot:dt,commands:l==="interact"?[`tapOn: x=${k.x} y=${k.y}`,"Task complete:"]:["Task complete:"]}],platform:n||"android",screenResolution:{width:it.naturalWidth,height:it.naturalHeight}})}catch(B){console.error("Error populating cache (fallback):",B)}}})()}return}if(qe>=Xm){const dt=Math.abs(Te);if(Math.abs($e)>=dt*1.5){const at=$e>0?"up":"down";await f.mutateAsync({direction:at,...yt}),a&&A(at);return}await p.mutateAsync({x1:q.x,y1:q.y,x2:k.x,y2:k.y,duration:500,...yt});const it=k.x-q.x>=0?"right":"left";a&&T(it,q.x,q.y,500)}},Ne=async _=>{t||(_.preventDefault(),Q.current+=_.deltaY,be.current&&(window.clearTimeout(be.current),be.current=null),be.current=window.setTimeout(async()=>{const q=Q.current;if(Q.current=0,Math.abs(q)<w)return;const k=q>0?"down":"up";await f.mutateAsync({direction:k,...P()}),a&&A(k)},ue))},Nt=async _=>{if(!t){if(_.key.length===1||_.key===" "){await c.mutateAsync({text:_.key,...P()}),a&&(D.current+=_.key,E.current&&window.clearTimeout(E.current),E.current=window.setTimeout(j,400)),_.preventDefault();return}if(_.key==="Backspace"){j(),await c.mutateAsync({text:"",...P()}),_.preventDefault();return}if(_.key==="Enter"){await c.mutateAsync({text:`
|
|
310
|
+
`,...P()}),a&&(D.current+=`
|
|
311
|
+
`,E.current&&window.clearTimeout(E.current),E.current=window.setTimeout(j,400)),_.preventDefault();return}}};return Ce(()=>()=>{j()},[]),s("div",{ref:i,tabIndex:0,onMouseDown:ee,onMouseUp:Ee,onWheel:Ne,onKeyDown:Nt,style:{position:"absolute",inset:0,outline:"none"}})},th=({imgRef:e,deviceWidth:t,deviceHeight:n,elements:r,onPickAttributes:o})=>{const[i,a]=fe(null),l=W(null),u=qo(l,{enterDelay:100,leaveDelay:100}),c=i!=null?r[i]:null,f=lr(()=>{const d=c,m=d?.text||d?.attributes?.text||"",g=d?.accessibilityText||d?.attributes?.accessibilityText||d?.attributes?.["accessibility-text"]||d?.attributes?.["content-desc"]||"",y=d?.resourceId||d?.attributes?.["resource-id"]||"",x=d?.accessibilityIdentifier||d?.attributes?.accessibilityIdentifier||"",D=d?.name||d?.attributes?.name||"",E=d?.label||d?.attributes?.label||"",P=d?.value||d?.attributes?.value||"";return x||D||E||m||g||y||P||Um(u)||""},[c,u]);Ce(()=>{if(u)if(u.isOver){const d=Hm({dimensions:{width:t,height:n},elements:r,mouse:u});if(d){let m=r.indexOf(d);if(m<0&&d.bounds){const g=d.bounds;m=r.findIndex(y=>y.bounds&&y.bounds.x===g.x&&y.bounds.y===g.y&&y.bounds.width===g.width&&y.bounds.height===g.height)}a(m>=0?m:null)}else a(null)}else a(null)},[u,t,n,r]);const p=u&&u.isOver&&typeof u.x=="number"&&typeof u.y=="number"&&typeof u.elementWidth=="number"&&typeof u.elementHeight=="number";return s(ft,{title:f,followCursor:!0,children:v(uh,{ref:l,onClick:()=>{const d=i!=null?r[i]:null;if(!d)return;const m=[],g=d.text??d.attributes?.text,y=d.accessibilityText??d.attributes?.["accessibility-text"]??d.attributes?.["content-desc"],x=d.resourceId??d.attributes?.["resource-id"],D=d.accessibilityIdentifier??d.attributes?.accessibilityIdentifier,E=d.name??d.attributes?.name,P=d.label??d.attributes?.label,N=(T,A)=>{const j=typeof A=="string"?Ym(A):"";j&&!m.some(Q=>Q.value===j)&&m.push({label:`${T}: "${j}"`,value:j})};N("accessibility-id",D),N("name",E),N("label",P),N("text",g),N("accessibility-text",y),N("resource-id",x),m.length>0&&o(m)},children:[p&&v(Nn,{children:[s(fh,{style:{left:`${u.x/u.elementWidth*100}%`}}),s(mh,{style:{top:`${u.y/u.elementHeight*100}%`}})]}),r.map((d,m)=>{if(!d.bounds)return null;const{x:g,y,width:x,height:D}=d.bounds,E=g/t*100,P=y/n*100,N=x/t*100,T=D/n*100,A=i===m;return s(ph,{style:{left:`${E}%`,top:`${P}%`,width:`${N}%`,height:`${T}%`},"data-hovered":A||void 0},m)})]})})},nh=F(_n)`
|
|
312
|
+
display: grid;
|
|
313
|
+
grid-template-areas:
|
|
314
|
+
'header'
|
|
315
|
+
'divider'
|
|
316
|
+
'actions'
|
|
317
|
+
'device';
|
|
318
|
+
/* Allow the content row to actually shrink instead of clamping to min-content */
|
|
319
|
+
grid-template-rows: auto auto auto minmax(0, 1fr);
|
|
320
|
+
row-gap: 0.75rem;
|
|
321
|
+
overflow: hidden;
|
|
322
|
+
/* Ensure grid children can shrink horizontally */
|
|
323
|
+
min-width: 0;
|
|
324
|
+
`,rh=F.div`
|
|
325
|
+
grid-area: header;
|
|
326
|
+
display: flex;
|
|
327
|
+
justify-content: space-between;
|
|
328
|
+
align-items: center;
|
|
329
|
+
`,oh=F.div`
|
|
330
|
+
display: flex;
|
|
331
|
+
gap: 0.25rem;
|
|
332
|
+
`,ih=F.div`
|
|
333
|
+
grid-area: actions;
|
|
334
|
+
display: flex;
|
|
335
|
+
gap: 0.5rem;
|
|
336
|
+
flex-wrap: wrap;
|
|
337
|
+
align-items: center;
|
|
338
|
+
justify-content: space-between;
|
|
339
|
+
`,ah=F(U)`
|
|
340
|
+
font-size: 0.875rem;
|
|
341
|
+
color: ${({connected:e})=>e?"#4caf50":"#f44336"};
|
|
342
|
+
`,sh=F.div`
|
|
343
|
+
grid-area: device;
|
|
344
|
+
display: flex;
|
|
345
|
+
justify-content: center;
|
|
346
|
+
align-items: flex-start; /* align to the top instead of centering vertically */
|
|
347
|
+
overflow: scroll;
|
|
348
|
+
height: 100%;
|
|
349
|
+
min-height: 0;
|
|
350
|
+
min-width: 0;
|
|
351
|
+
`,lh=F.img`
|
|
352
|
+
display: block; /* remove inline gaps and let container wrap to image */
|
|
353
|
+
max-width: 100%;
|
|
354
|
+
height: auto; /* keep aspect ratio and define image-driven height */
|
|
355
|
+
border: 2px solid #333;
|
|
356
|
+
border-radius: 8px;
|
|
357
|
+
cursor: crosshair;
|
|
358
|
+
box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
|
|
359
|
+
${({recording:e})=>e&&`
|
|
360
|
+
border-color: #2196f3;
|
|
361
|
+
box-shadow: 0 0 20px rgba(33, 150, 243, 0.4);
|
|
362
|
+
`}
|
|
363
|
+
`,ch=F(ne)`
|
|
364
|
+
display: flex;
|
|
365
|
+
flex-direction: column;
|
|
366
|
+
align-items: center;
|
|
367
|
+
gap: 1rem;
|
|
368
|
+
`,dh=F.div`
|
|
369
|
+
position: relative;
|
|
370
|
+
display: inline-block; /* shrink-wrap to image size */
|
|
371
|
+
max-width: 100%;
|
|
372
|
+
height: auto;
|
|
373
|
+
`,uh=F.div`
|
|
374
|
+
position: absolute;
|
|
375
|
+
inset: 0;
|
|
376
|
+
pointer-events: auto;
|
|
377
|
+
`,ph=F.div`
|
|
378
|
+
position: absolute;
|
|
379
|
+
box-sizing: border-box;
|
|
380
|
+
pointer-events: none;
|
|
381
|
+
border: 2px dashed rgba(236, 72, 153, 0.7);
|
|
382
|
+
background: transparent;
|
|
383
|
+
&[data-hovered] {
|
|
384
|
+
border-color: rgba(59, 130, 246, 0.95);
|
|
385
|
+
border-style: solid;
|
|
386
|
+
outline: 2px solid rgba(59, 130, 246, 0.6);
|
|
387
|
+
box-shadow: none;
|
|
388
|
+
}
|
|
389
|
+
`,fh=F.div`
|
|
390
|
+
position: absolute;
|
|
391
|
+
top: 0;
|
|
392
|
+
bottom: 0;
|
|
393
|
+
width: 1px;
|
|
394
|
+
background: rgba(59, 130, 246, 0.9);
|
|
395
|
+
transform: translateX(-0.5px);
|
|
396
|
+
pointer-events: none;
|
|
397
|
+
`,mh=F.div`
|
|
398
|
+
position: absolute;
|
|
399
|
+
left: 0;
|
|
400
|
+
right: 0;
|
|
401
|
+
height: 1px;
|
|
402
|
+
background: rgba(59, 130, 246, 0.9);
|
|
403
|
+
transform: translateY(-0.5px);
|
|
404
|
+
pointer-events: none;
|
|
405
|
+
`;function hh(e){const t={};return e.forEach(n=>{const r=n.path.split("/");let o=t,i="";r.forEach((a,l)=>{i=i?`${i}/${a}`:a,o[a]||(o[a]={name:a,fullPath:i,type:l===r.length-1?n.type:"directory",children:{}}),l===r.length-1&&(o[a].type=n.type,o[a].fullPath=i),o=o[a].children})}),t}const fa=({item:e,level:t,onSelect:n,selectedFile:r,onRename:o})=>{const[i,a]=fe(!1),[l,u]=fe(!1),[c,f]=fe(e.name),p=()=>{c&&c!==e.name&&o(e.fullPath,c),u(!1)},d=Object.keys(e.children).length>0,m=Object.values(e.children).sort((g,y)=>g.type===y.type?g.name.localeCompare(y.name):g.type==="directory"?-1:1);return l?s(Vn,{sx:{pl:t*2},children:s(me,{value:c,onChange:g=>f(g.target.value),size:"small",autoFocus:!0,onBlur:p,onKeyDown:g=>{g.key==="Enter"&&p(),g.key==="Escape"&&u(!1)},InputProps:{endAdornment:s(Da,{position:"end",children:s(O,{size:"small",onMouseDown:p,children:s(Ys,{fontSize:"small"})})})}})}):v(Nn,{children:[e.type==="directory"?s(Cn,{droppableId:`FOLDER_ROW::${e.fullPath}`,children:(g,y)=>v("div",{ref:g.innerRef,...g.droppableProps,children:[v(Vn,{button:!0,onClick:x=>{a(!i)},onDoubleClick:()=>{f(e.name),u(!0)},selected:r===e.fullPath,sx:{pl:t*2,bgcolor:y.isDraggingOver?"action.hover":void 0},children:[s(Jr,{sx:{minWidth:32},children:s(Us,{fontSize:"small",color:"primary"})}),s(Xr,{primary:e.name,primaryTypographyProps:{variant:"body2",noWrap:!0}}),d&&(i?s(qs,{fontSize:"small"}):s(Ks,{fontSize:"small"}))]}),g.placeholder]})}):v(Vn,{button:!0,onClick:()=>n(e.fullPath),onDoubleClick:()=>{f(e.name),u(!0)},selected:r===e.fullPath,sx:{pl:t*2},children:[s(Jr,{sx:{minWidth:32},children:s(js,{fontSize:"small",color:"action"})}),s(Xr,{primary:e.name,primaryTypographyProps:{variant:"body2",noWrap:!0}})]}),e.type==="directory"&&s(Ea,{in:i,timeout:"auto",unmountOnExit:!0,children:s(Cn,{droppableId:e.fullPath,children:g=>v(_o,{component:"div",disablePadding:!0,ref:g.innerRef,...g.droppableProps,children:[m.map((y,x)=>s(Fr,{draggableId:y.fullPath,index:x,children:(D,E)=>s("div",{ref:D.innerRef,...D.draggableProps,...D.dragHandleProps,style:{...D.draggableProps.style,opacity:E.isDragging?.9:1},children:s(fa,{item:y,level:t+1,onSelect:n,selectedFile:r,onRename:o})})},y.fullPath)),g.placeholder]})})})]})};function gh({files:e,onSelect:t,selectedFile:n,refetch:r}){const o=hh(e),i=Object.values(o).sort((u,c)=>u.type===c.type?u.name.localeCompare(c.name):u.type==="directory"?-1:1),a=G(Zf),l=async(u,c)=>{try{const f=u.split("/");f.pop();const p=f.join("/"),d=p?`${p}/${c}`:c;await a.mutateAsync({oldPath:u,newPath:d}),r()}catch(f){alert("Rename failed: "+f.message)}};return s(zi,{onDragEnd:async u=>{const{destination:c,draggableId:f}=u;if(!c)return;const p=c.droppableId;let d="";p==="ROOT"?d="":p.startsWith("FOLDER_ROW::")?d=p.slice(12):d=p;const m=f;if(!m||d&&(m===d||d.startsWith(m+"/")))return;const g=m.lastIndexOf("/"),y=g>=0?m.slice(0,g):"";if((d||"")===y)return;const x=g>=0?m.slice(g+1):m,D=d?`${d}/${x}`:x;try{await a.mutateAsync({oldPath:m,newPath:D}),r()}catch(E){alert("Move failed: "+E.message)}},children:s(Cn,{droppableId:"ROOT",children:u=>v(_o,{dense:!0,ref:u.innerRef,...u.droppableProps,children:[i.map((c,f)=>s(Fr,{draggableId:c.fullPath||c.name,index:f,children:(p,d)=>s("div",{ref:p.innerRef,...p.draggableProps,...p.dragHandleProps,style:{...p.draggableProps.style,opacity:d.isDragging?.9:1},children:s(fa,{item:c,level:1,onSelect:t,selectedFile:n,onRename:l})})},c.fullPath||c.name)),u.placeholder]})})})}function bh({onSelectFile:e,selectedFile:t}){const{data:n,isLoading:r,error:o,refetch:i}=Je({...Hr,refetchInterval:2e3}),[a,l]=fe(!1),[u,c]=fe("file"),[f,p]=fe(""),d=G(Gf),m=async()=>{if(!f)return;let x=f;u==="file"&&!x.endsWith(".json")&&(x+=".json");try{await d.mutateAsync({name:x,type:u}),l(!1),p(""),i()}catch(D){alert("Failed to create: "+D.message)}},g=x=>{c(x),p(""),l(!0)};if(r)return s(Qn,{children:s(Bo,{})});if(o)return s(Qn,{children:s(U,{color:"error",children:"Error loading files"})});const y=n?.files||[];return v(Qn,{children:[v(yh,{children:[s(U,{variant:"h6",children:"Tests"}),v(ne,{children:[s(O,{onClick:()=>i(),size:"small",title:"Refresh",children:s(zs,{})}),s(O,{onClick:()=>g("directory"),size:"small",title:"New Folder",children:s(Hs,{})}),s(O,{onClick:()=>g("file"),size:"small",color:"primary",title:"New Test",children:s(Ko,{})})]})]}),s(nn,{}),s(vh,{children:y.length===0?s(U,{variant:"caption",sx:{p:2,display:"block",textAlign:"center",color:"text.secondary"},children:"No tests found"}):s(gh,{files:y,onSelect:e,selectedFile:t,refetch:i})}),v(cr,{open:a,onClose:()=>l(!1),children:[v(ko,{children:["Create New ",u==="file"?"Test":"Folder"]}),s(dr,{children:s(me,{autoFocus:!0,margin:"dense",label:"Name",fullWidth:!0,value:f,onChange:x=>p(x.target.value),placeholder:u==="file"?"my-test":"my-folder"})}),v(Fo,{children:[s(Be,{onClick:()=>l(!1),children:"Cancel"}),s(Be,{onClick:m,variant:"contained",children:"Create"})]})]})]})}const Qn=F(_n)`
|
|
406
|
+
display: flex;
|
|
407
|
+
flex-direction: column;
|
|
408
|
+
padding: 0;
|
|
409
|
+
overflow: hidden;
|
|
410
|
+
height: 100%;
|
|
411
|
+
`,yh=F.div`
|
|
412
|
+
padding: 1rem;
|
|
413
|
+
display: flex;
|
|
414
|
+
align-items: center;
|
|
415
|
+
justify-content: space-between;
|
|
416
|
+
`,vh=F.div`
|
|
417
|
+
flex: 1;
|
|
418
|
+
overflow-y: auto;
|
|
419
|
+
padding: 0.5rem 0;
|
|
420
|
+
`;function xh({disabled:e}){const t=ye(I,c=>c.test.params),[n,r]=fe(()=>Object.entries(t||{}).map(([c,f])=>({key:c,value:f})));Ce(()=>{r(Object.entries(t||{}).map(([c,f])=>({key:c,value:f})))},[t]),lr(()=>new Set(n.map(c=>c.key)),[n]);const o=c=>{const f={};for(const p of c)p.key&&(f[p.key]=p.value);I.setState(p=>({...p,test:{...p.test,params:f}}))},i=()=>{const c=[...n,{key:"",value:""}];r(c)},a=c=>{const f=n.filter((p,d)=>d!==c);r(f),o(f)},l=(c,f)=>{const p=n.map((d,m)=>m===c?{...d,key:f}:d);r(p),o(p)},u=(c,f)=>{const p=n.map((d,m)=>m===c?{...d,value:f}:d);r(p),o(p)};return v(Dh,{children:[v(Eh,{children:[s(U,{variant:"subtitle1",children:"Test Params"}),s(ft,{title:e?"Select a test to edit params":"Add parameter",children:s("span",{children:s(O,{size:"small",disabled:e,onClick:i,color:"primary",children:s(Ko,{})})})})]}),s(nn,{}),v(wh,{children:[n.length===0&&s(Ch,{children:s(U,{variant:"caption",color:"text.secondary",children:e?"No test selected":"No params. Click + to add"})}),n.map((c,f)=>{const p=c.key&&n.some((d,m)=>m!==f&&d.key===c.key);return v(Ih,{children:[s(me,{size:"small",label:"Key",value:c.key,onChange:d=>l(f,d.target.value),disabled:e,error:!!p,helperText:p?"Duplicate key":" "}),s(me,{size:"small",label:"Value",value:c.value,onChange:d=>u(f,d.target.value),disabled:e}),s(ft,{title:e?"":"Remove",children:s("span",{children:s(O,{size:"small",disabled:e,onClick:()=>a(f),children:s(je,{})})})})]},f)})]}),!e&&n.length>0&&s(ne,{sx:{p:1,display:"flex",justifyContent:"flex-end"},children:s(Be,{size:"small",onClick:()=>o(n),children:"Apply"})})]})}const Dh=F(_n)`
|
|
421
|
+
display: flex;
|
|
422
|
+
flex-direction: column;
|
|
423
|
+
padding: 0;
|
|
424
|
+
height: 100%;
|
|
425
|
+
overflow: hidden;
|
|
426
|
+
`,Eh=F.div`
|
|
427
|
+
padding: 0.75rem 1rem;
|
|
428
|
+
display: flex;
|
|
429
|
+
align-items: center;
|
|
430
|
+
justify-content: space-between;
|
|
431
|
+
`,wh=F.div`
|
|
432
|
+
padding: 0.5rem 0.75rem;
|
|
433
|
+
display: flex;
|
|
434
|
+
flex-direction: column;
|
|
435
|
+
gap: 0.5rem;
|
|
436
|
+
overflow: auto;
|
|
437
|
+
`,Ih=F.div`
|
|
438
|
+
display: grid;
|
|
439
|
+
grid-template-columns: 1fr 1fr auto;
|
|
440
|
+
gap: 0.5rem;
|
|
441
|
+
align-items: start;
|
|
442
|
+
padding-top: 0.5rem;
|
|
443
|
+
`,Ch=F.div`
|
|
444
|
+
padding: 0.75rem;
|
|
445
|
+
text-align: center;
|
|
446
|
+
`;function Nh(){const e=ye(fn,n=>n),t=vn(()=>{Tm()},[]);return s(ba,{open:e.open,onClose:t,className:"absolute z-10",style:{maxWidth:"384px"},anchorOrigin:{vertical:"top",horizontal:"right"},autoHideDuration:e.maintainDisplayed?null:3e3,children:v(ya,{severity:e.type,onClose:t,children:[e.title!==void 0&&s(Js,{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&&s("ul",{className:"mt-2 ml-2 list-disc list-inside",children:e.listContent.map((n,r)=>s("li",{children:n},r))})]})})}function nb(){const[e,t]=fe(),n=G(Ur),r=G(Kf),o=Sn(),[i,a]=fe("");Ce(()=>{e?n.mutateAsync({path:e}).then(c=>{const f=c.content;let p=[],d={};Array.isArray(f)?(p=f,d={}):f&&Array.isArray(f.steps)&&(p=f.steps,d=f.params||{});const m=p.map((D,E)=>({...D,id:D.id||Date.now()+E})),g={name:c.path,steps:m,params:d};I.setState(D=>({...D,test:g}));const y=I.state.test,x={...y,steps:y.steps.map(D=>{const E={...D};for(const P of Object.keys(Mn))delete E[P];return E})};a(JSON.stringify(x))}).catch(c=>{c instanceof Error?c.message:String(c),sr("Failed to read file",{title:"Read Error"})}):a(JSON.stringify({name:"untitled",steps:[],params:{}}))},[e]);const l=ye(I,c=>c.test),u=(()=>{const c={...l,steps:l.steps.map(f=>{const p={...f};for(const d of Object.keys(Mn))delete p[d];return p})};return JSON.stringify(c)!==i})();return v(Nn,{children:[v(Sh,{children:[s(Oh,{children:s(bh,{onSelectFile:t,selectedFile:e})}),s(Ph,{children:s(xh,{disabled:!e})}),s(Ah,{children:s(_m,{onSave:async()=>{let c=e;const f=I.state.test,p=f.steps.map(m=>{const g={...m};for(const y of Object.keys(Mn))delete g[y];return g}),d={...f,steps:p};if(!c){const m=(f.name||"untitled").replace(/[^a-z0-9_\-\.]/gi,"_");c=m.endsWith(".json")?m:`${m}.json`}try{await r.mutateAsync({path:c,content:d}),a(JSON.stringify(d)),e||(t(c),o.invalidateQueries({queryKey:["files"]})),Kr("File saved",{title:"Saved"})}catch(m){sr(m?.message?String(m.message):"Failed to save",{title:"Save Error"})}},canSave:u})}),s(Rh,{children:s(Jm,{})})]}),s(Nh,{})]})}const Sh=F.div`
|
|
447
|
+
display: grid;
|
|
448
|
+
grid-template-areas:
|
|
449
|
+
'files editor simulator'
|
|
450
|
+
'params editor simulator';
|
|
451
|
+
grid-template-columns: 250px minmax(0, 1fr) 400px;
|
|
452
|
+
grid-template-rows: 1fr minmax(160px, 35%);
|
|
453
|
+
background-color: #f0f2f5;
|
|
454
|
+
height: 100vh;
|
|
455
|
+
padding: 1rem;
|
|
456
|
+
column-gap: 1rem;
|
|
457
|
+
row-gap: 1rem;
|
|
458
|
+
`,Oh=F.div`
|
|
459
|
+
grid-area: files;
|
|
460
|
+
min-height: 0; /* allow internal scroll */
|
|
461
|
+
`,Ph=F.div`
|
|
462
|
+
grid-area: params;
|
|
463
|
+
min-height: 0;
|
|
464
|
+
`,Ah=F.div`
|
|
465
|
+
grid-area: editor;
|
|
466
|
+
min-height: 0;
|
|
467
|
+
height: 100%;
|
|
468
|
+
overflow-y: auto;
|
|
469
|
+
`,Rh=F.div`
|
|
470
|
+
grid-area: simulator;
|
|
471
|
+
min-height: 0;
|
|
472
|
+
min-width: 0; /* allow child panel to shrink horizontally */
|
|
473
|
+
height: 100%;
|
|
474
|
+
`;export{nb as component};
|