@fugood/bricks-cli 2.24.0-beta.41 → 2.24.0-beta.43

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/lib/775.js DELETED
@@ -1 +0,0 @@
1
- export const __webpack_esm_id__=775;export const __webpack_esm_ids__=[775];export const __webpack_esm_modules__={76775:(e,l,r)=>{r.d(l,{App:()=>te,AppDetail:()=>C,AppList:()=>B,CONTROL_ACTIONS:()=>h,DeviceControl:()=>I,DeviceDetail:()=>S,DeviceList:()=>E,DeviceScreenshot:()=>A,DeviceStatus:()=>y,Footer:()=>v,GroupDetail:()=>M,GroupList:()=>L,Header:()=>p,Loading:()=>_,MainMenu:()=>D,MediaBoxDetail:()=>R,MediaBoxList:()=>O,MediaFileDetail:()=>U,MediaFileList:()=>N,ModuleDetail:()=>w,ModuleList:()=>k,ONLINE_THRESHOLD_MS:()=>g,ProjectInitView:()=>ne,ShortEditEditor:()=>H,VIEWS:()=>u,runInteractiveMode:()=>ie}),r.r(l);var n,t=r(51649),i=r(8498),o=r(29557),a=r(99436),s=r(68832),c=r(50700),d=r(74752),x=r(47336),u={MAIN:"main",DEVICES:"devices",DEVICE_DETAIL:"device_detail",DEVICE_CONTROL:"device_control",DEVICE_SCREENSHOT:"device_screenshot",APPS:"apps",APP_DETAIL:"app_detail",APP_SHORT_EDIT:"app_short_edit",APP_PROJECT_INIT:"app_project_init",MODULES:"modules",MODULE_DETAIL:"module_detail",MODULE_SHORT_EDIT:"module_short_edit",MODULE_PROJECT_INIT:"module_project_init",GROUPS:"groups",GROUP_DETAIL:"group_detail",MEDIA_BOXES:"media_boxes",MEDIA_BOX_DETAIL:"media_box_detail",MEDIA_FILES:"media_files",MEDIA_FILE_DETAIL:"media_file_detail"},h=[{label:"Refresh Application",value:"refresh"},{label:"Clear Cache",value:"clear-cache"},{label:"Take Screenshot",value:"take-screenshot"},{label:"Open System Menu",value:"system-menu-open"},{label:"Close System Menu",value:"system-menu-close"},{label:"Open Debug Panel",value:"debug-panel-open"},{label:"Close Debug Panel",value:"debug-panel-close"},{label:"Enable Logging",value:"logging-on"},{label:"Disable Logging",value:"logging-off"},{label:"← Back",value:"back"}],g=3e5,m=r(47882),j=r(71178),T=(e,l=!0)=>{var r=Math.floor(60),n=(0,t.useState)(r),i=s(n,2),o=i[0],a=i[1],c=(0,t.useState)(null),d=s(c,2),x=d[0],u=d[1],h=(0,t.useRef)(e);(0,t.useEffect)(()=>{h.current=e},[e]);var g=(0,t.useCallback)(()=>{a(r),u(Date.now())},[r]);return(0,t.useEffect)(()=>{if(l){var e=setInterval(()=>{a(e=>e<=1?(h.current?.(),u(Date.now()),r):e-1)},1e3);return()=>clearInterval(e)}},[l,r]),(0,t.useEffect)(()=>{l&&(a(r),u(Date.now()))},[l,r]),{countdown:o,lastRefreshTime:x,resetCountdown:g}},f=({countdown:e,lastRefreshTime:l})=>(0,j.jsx)(i.Box,{children:(0,j.jsxs)(i.Text,{color:"gray",children:["Next refresh in ",(0,j.jsxs)(i.Text,{color:"cyan",children:[e,"s"]}),l&&(0,j.jsxs)(i.Text,{color:"gray",children:[" (last: ",l?new Date(l).toLocaleTimeString():null,")"]})]})}),p=({workspace:e,view:l})=>(0,j.jsxs)(i.Box,{flexDirection:"column",marginBottom:1,children:[(0,j.jsxs)(i.Box,{children:[(0,j.jsx)(i.Text,{bold:!0,color:"cyan",children:"BRICKS CLI"}),(0,j.jsx)(i.Text,{color:"gray",children:" - Interactive Mode"})]}),(0,j.jsxs)(i.Box,{children:[(0,j.jsx)(i.Text,{color:"gray",children:"Workspace: "}),(0,j.jsx)(i.Text,{color:"green",children:e?.name||"Not connected"}),(0,j.jsx)(i.Text,{color:"gray",children:" | View: "}),(0,j.jsx)(i.Text,{color:"yellow",children:l})]}),(0,j.jsx)(i.Text,{color:"gray",children:"─".repeat(60)})]}),v=()=>(0,j.jsxs)(i.Box,{marginTop:1,flexDirection:"column",children:[(0,j.jsx)(i.Text,{color:"gray",children:"─".repeat(60)}),(0,j.jsxs)(i.Text,{color:"gray",children:["Press ",(0,j.jsx)(i.Text,{color:"cyan",children:"q"})," to quit, ",(0,j.jsx)(i.Text,{color:"cyan",children:"Esc"})," to go back"]})]}),_=({text:e})=>(0,j.jsxs)(i.Box,{children:[(0,j.jsx)(i.Text,{color:"green",children:(0,j.jsx)(m.A,{type:"dots"})}),(0,j.jsxs)(i.Text,{children:[" ",e||"Loading..."]})]}),y=({lastAliveTime:e})=>{if(!e)return(0,j.jsx)(i.Text,{color:"gray",children:"○ Unknown"});var l=Date.now()-new Date(e).getTime();if(l<=g)return(0,j.jsx)(i.Text,{color:"green",children:"● Online"});var r=Math.floor(l/6e4);if(r<60)return(0,j.jsxs)(i.Text,{color:"yellow",children:["○ Offline (",r,"m ago)"]});var n=Math.floor(r/60);if(n<24)return(0,j.jsxs)(i.Text,{color:"red",children:["○ Offline (",n,"h ago)"]});var t=Math.floor(n/24);return(0,j.jsxs)(i.Text,{color:"red",children:["○ Offline (",t,"d ago)"]})},b=r(25291),D=({onSelect:e,mediaEnabled:l})=>{var r=[{label:"Devices",value:u.DEVICES},{label:"Applications",value:u.APPS},{label:"Modules",value:u.MODULES},{label:"Device Groups",value:u.GROUPS},...l?[{label:"Media Flow",value:u.MEDIA_BOXES}]:[],{label:"Exit",value:"exit"}];return(0,j.jsxs)(i.Box,{flexDirection:"column",children:[(0,j.jsx)(i.Text,{bold:!0,marginBottom:1,children:"Main Menu"}),(0,j.jsx)(b.Ay,{items:r,onSelect:e})]})},E=({devices:e,loading:l,onSelect:r,countdown:n,lastRefreshTime:t})=>{if(l)return(0,j.jsx)(_,{text:"Loading devices..."});if(!e?.length)return(0,j.jsxs)(i.Box,{flexDirection:"column",children:[(0,j.jsx)(i.Text,{color:"yellow",children:"No devices found"}),(0,j.jsx)(f,{countdown:n,lastRefreshTime:t})]});var o=[...e.map(e=>({label:`${(e=>{if(!e)return"○ Unknown";var l=Date.now()-new Date(e).getTime();if(l<=g)return"● Online";var r=Math.floor(l/6e4);if(r<60)return`○ ${r}m ago`;var n=Math.floor(r/60);return n<24?`○ ${n}h ago`:`○ ${Math.floor(n/24)}d ago`})(e.entry_detail?.watch_dog_timer?.last_alive_time)} - ${e.name||e.device_name}`,value:e._id,device:e})),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return(0,j.jsxs)(i.Box,{flexDirection:"column",children:[(0,j.jsxs)(i.Box,{marginBottom:1,children:[(0,j.jsxs)(i.Text,{bold:!0,children:["Devices (",e.length,")"]}),(0,j.jsx)(i.Text,{color:"gray",children:" - "}),(0,j.jsx)(f,{countdown:n,lastRefreshTime:t})]}),(0,j.jsx)(b.Ay,{items:o,onSelect:r})]})},S=({device:e,loading:l,error:r,onSelect:n,mediaEnabled:t,countdown:o,lastRefreshTime:a})=>{if(l)return(0,j.jsx)(_,{text:"Loading device..."});if(r)return(0,j.jsxs)(i.Box,{flexDirection:"column",children:[(0,j.jsxs)(i.Text,{color:"red",children:["Error: ",r]}),(0,j.jsx)(b.Ay,{items:[{label:"← Back",value:"back"}],onSelect:n})]});if(!e)return(0,j.jsx)(i.Text,{color:"red",children:"Device not found"});var s=[{label:"Control Device",value:"control"},...t?[{label:"View Screenshot",value:"screenshot"}]:[],{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],c=e.entry_detail,d=c?.screen,x=c?.update,u=c?.local_sync;return(0,j.jsxs)(i.Box,{flexDirection:"column",children:[(0,j.jsxs)(i.Box,{children:[(0,j.jsx)(i.Text,{bold:!0,color:"cyan",children:e.name||e.device_name}),(0,j.jsx)(i.Text,{color:"gray",children:" - "}),(0,j.jsx)(f,{countdown:o,lastRefreshTime:a})]}),e.description&&(0,j.jsx)(i.Text,{color:"gray",children:e.description}),(0,j.jsxs)(i.Box,{marginY:1,flexDirection:"column",children:[(0,j.jsxs)(i.Box,{children:[(0,j.jsx)(i.Text,{color:"gray",children:"Status: "}),(0,j.jsx)(y,{lastAliveTime:c?.watch_dog_timer?.last_alive_time})]}),(0,j.jsxs)(i.Text,{color:"gray",children:["ID: ",e._id]}),e.tags?.length>0&&(0,j.jsxs)(i.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),c?.application&&(0,j.jsxs)(i.Box,{flexDirection:"column",marginTop:1,children:[(0,j.jsx)(i.Text,{bold:!0,color:"white",children:"Application"}),(0,j.jsxs)(i.Text,{color:"gray",children:[" Name: ",c.application.name]}),(0,j.jsxs)(i.Text,{color:"gray",children:[" Mode: ",c.operation_mode||"N/A"]})]}),d&&(0,j.jsxs)(i.Box,{flexDirection:"column",marginTop:1,children:[(0,j.jsx)(i.Text,{bold:!0,color:"white",children:"Screen"}),d.resolution&&(0,j.jsxs)(i.Text,{color:"gray",children:[" ","Resolution: ",d.resolution.width,"x",d.resolution.height,d.resolution.scale&&` @${d.resolution.scale}x`]}),d.orientation&&(0,j.jsxs)(i.Text,{color:"gray",children:[" Orientation: ",d.orientation]}),d.touch&&(0,j.jsxs)(i.Text,{color:"gray",children:[" ","Touch:"," ",d.touch.available?`Yes (${d.touch.touch_point} points)`:"No"]})]}),(c?.memory_usage||c?.disk_usage)&&(0,j.jsxs)(i.Box,{flexDirection:"column",marginTop:1,children:[(0,j.jsx)(i.Text,{bold:!0,color:"white",children:"System"}),c.memory_usage&&(0,j.jsxs)(i.Text,{color:"gray",children:[" Memory: ",Math.round(100*c.memory_usage),"%"]}),c.disk_usage&&(0,j.jsxs)(i.Text,{color:"gray",children:[" Disk: ",Math.round(100*c.disk_usage),"%"]})]}),(0,j.jsxs)(i.Box,{flexDirection:"column",marginTop:1,children:[(0,j.jsx)(i.Text,{bold:!0,color:"white",children:"Capabilities"}),(0,j.jsxs)(i.Text,{color:"gray",children:[" ","Sound: ",c?.sound?.available?"✓":"✗"," | ","Camera: ",c?.camera?.available?"✓":"✗"," | ","Audio In: ",c?.audio_in?.available?"✓":"✗"]})]}),u&&(0,j.jsxs)(i.Box,{flexDirection:"column",marginTop:1,children:[(0,j.jsx)(i.Text,{bold:!0,color:"white",children:"Local Sync"}),(0,j.jsxs)(i.Text,{color:"gray",children:[" ","Role: ",u.is_main?"Main":"Peer",u.peer_count>0&&` | Peers: ${u.peer_count}`,u.mean_latency&&` | Latency: ${u.mean_latency}ms`]})]}),x&&(0,j.jsxs)(i.Box,{flexDirection:"column",marginTop:1,children:[(0,j.jsx)(i.Text,{bold:!0,color:"white",children:"Update"}),(0,j.jsxs)(i.Text,{color:x.need_update?"yellow":"gray",children:[" ","Status: ",x.need_update?"⚠ Update available":"✓ Up to date"]}),x.current_version&&(0,j.jsxs)(i.Text,{color:"gray",children:[" Version: ",x.current_version]})]})]}),(0,j.jsx)(b.Ay,{items:s,onSelect:n})]})},I=({device:e,onSelect:l,controlling:r,controlResult:n})=>(0,j.jsxs)(i.Box,{flexDirection:"column",children:[(0,j.jsxs)(i.Text,{bold:!0,color:"cyan",children:["Control: ",e?.name||e?.device_name]}),r&&(0,j.jsx)(_,{text:"Sending command..."}),n&&(0,j.jsx)(i.Text,{color:n.success?"green":"red",children:n.message}),(0,j.jsx)(i.Box,{marginTop:1,children:(0,j.jsx)(b.Ay,{items:h,onSelect:l})})]}),A=({device:e,screenshot:l,loading:r,error:n,onSelect:t})=>{var a=l?.file?.meta,s=null!=a?.originalWidth&&null!=a?.originalHeight,c=null!=a?.originalFileSize;return(0,j.jsxs)(i.Box,{flexDirection:"column",children:[(0,j.jsxs)(i.Text,{bold:!0,color:"cyan",children:["Screenshot: ",e?.name||e?.device_name||"Unknown"]}),r&&(0,j.jsx)(_,{text:"Loading screenshot..."}),n&&(0,j.jsx)(i.Box,{marginY:1,children:(0,j.jsx)(i.Text,{color:"red",children:String(n)})}),!r&&!n&&l&&(0,j.jsxs)(i.Box,{flexDirection:"column",children:[(0,j.jsx)(i.Box,{height:30,children:(0,j.jsx)(o.default,{src:l.path,width:80,alt:"Device screenshot"})}),(0,j.jsxs)(i.Box,{marginY:1,flexDirection:"column",children:[(0,j.jsx)(i.Text,{bold:!0,color:"white",children:"Screenshot Details"}),(0,j.jsxs)(i.Box,{marginY:1,children:[(0,j.jsx)(i.Text,{color:"green",children:"Screenshot saved to: "}),(0,j.jsx)(i.Text,{color:"cyan",children:String(l.path||"")})]}),s&&(0,j.jsxs)(i.Text,{color:"gray",children:["Size: ",String(a.originalWidth),"x",String(a.originalHeight)]}),c&&(0,j.jsxs)(i.Text,{color:"gray",children:["File: ",(Number(a.originalFileSize)/1024).toFixed(1)," KB"]}),l.file?.updatedAt&&(0,j.jsxs)(i.Text,{color:"gray",children:["Updated: ",new Date(l.file.updatedAt).toLocaleString()]})]})]}),!r&&!n&&!l&&(0,j.jsx)(i.Box,{marginY:1,children:(0,j.jsx)(i.Text,{color:"yellow",children:"No screenshot available. Try taking a new one."})}),(0,j.jsx)(i.Box,{marginTop:1,children:(0,j.jsx)(b.Ay,{items:[{label:"Take New Screenshot",value:"take"},{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],onSelect:t})})]})},B=({apps:e,loading:l,onSelect:r})=>{if(l)return(0,j.jsx)(_,{text:"Loading applications..."});if(!e?.length)return(0,j.jsx)(i.Text,{color:"yellow",children:"No applications found"});var n=[...e.map(e=>({label:`${e.has_unreleased_changes?"●":"○"} ${e.name}`,value:e._id,app:e})),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return(0,j.jsxs)(i.Box,{flexDirection:"column",children:[(0,j.jsxs)(i.Text,{bold:!0,marginBottom:1,children:["Applications (",e.length,")"]}),(0,j.jsx)(b.Ay,{items:n,onSelect:r})]})},C=({app:e,loading:l,error:r,onSelect:n})=>{if(l)return(0,j.jsx)(_,{text:"Loading application..."});if(r)return(0,j.jsxs)(i.Box,{flexDirection:"column",children:[(0,j.jsxs)(i.Text,{color:"red",children:["Error: ",r]}),(0,j.jsx)(b.Ay,{items:[{label:"← Back",value:"back"}],onSelect:n})]});if(!e)return(0,j.jsx)(i.Text,{color:"red",children:"Application not found"});var t=[{label:"⚡ Initialize Project",value:"project_init"},...e.short_edit?.enabled&&e.short_edit.ref_map?[{label:"Short Edit",value:"short_edit"}]:[],{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],o=e.devices?.length||0,a=e.devices?.filter(e=>"online"===e.status)?.length||0;return(0,j.jsxs)(i.Box,{flexDirection:"column",children:[(0,j.jsx)(i.Text,{bold:!0,color:"cyan",children:e.name}),e.description&&(0,j.jsx)(i.Text,{color:"gray",children:e.description}),(0,j.jsxs)(i.Box,{marginY:1,flexDirection:"column",children:[(0,j.jsxs)(i.Text,{color:"gray",children:["ID: ",e._id]}),e.tags?.length>0&&(0,j.jsxs)(i.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),(0,j.jsxs)(i.Box,{flexDirection:"column",marginTop:1,children:[(0,j.jsx)(i.Text,{bold:!0,color:"white",children:"Version"}),(0,j.jsxs)(i.Text,{color:"gray",children:[" ","Current: ",e.current_version?`v${e.current_version}`:"N/A"]}),(0,j.jsxs)(i.Text,{color:e.has_unreleased_changes?"yellow":"gray",children:[" ","Changes:"," ",e.has_unreleased_changes?"● Unreleased changes":"○ No pending changes"]}),e.current_version_details&&(0,j.jsxs)(i.Text,{color:"gray",children:[" ","Released: v",e.current_version_details.version||"N/A"]})]}),(0,j.jsxs)(i.Box,{flexDirection:"column",marginTop:1,children:[(0,j.jsx)(i.Text,{bold:!0,color:"white",children:"Devices"}),(0,j.jsxs)(i.Text,{color:"gray",children:[" ","Total: ",o,o>0&&` (${a} online)`]})]}),(0,j.jsxs)(i.Box,{flexDirection:"column",marginTop:1,children:[(0,j.jsx)(i.Text,{bold:!0,color:"white",children:"Features"}),(0,j.jsxs)(i.Text,{color:"gray",children:[" ","Short Edit: ",e.short_edit?.enabled?"✓ Enabled":"✗ Disabled"]}),(0,j.jsxs)(i.Text,{color:"gray",children:[" ","Canvas Control: ",e.canvas_control?.enabled?"✓ Enabled":"✗ Disabled"]}),(0,j.jsxs)(i.Text,{color:"gray",children:[" ","Device Control: ",e.device_control?.enabled?"✓ Enabled":"✗ Disabled"]}),(0,j.jsxs)(i.Text,{color:e.lock?.enabled?"yellow":"gray",children:[" ","Lock: ",e.lock?.enabled?"🔒 Locked":"🔓 Unlocked"]})]}),(0,j.jsxs)(i.Box,{flexDirection:"column",marginTop:1,children:[(0,j.jsx)(i.Text,{bold:!0,color:"white",children:"Timestamps"}),e.create_datetime&&(0,j.jsxs)(i.Text,{color:"gray",children:[" Created: ",new Date(e.create_datetime).toLocaleString()]}),e.last_modify_datetime&&(0,j.jsxs)(i.Text,{color:"gray",children:[" ","Modified: ",new Date(e.last_modify_datetime).toLocaleString()]})]})]}),(0,j.jsx)(b.Ay,{items:t,onSelect:n})]})},k=({modules:e,loading:l,onSelect:r})=>{if(l)return(0,j.jsx)(_,{text:"Loading modules..."});var n=[...(e||[]).map(e=>({label:`${e.current_version?"●":"○"} ${e.name}`,value:e._id,module:e})),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return(0,j.jsxs)(i.Box,{flexDirection:"column",children:[(0,j.jsxs)(i.Text,{bold:!0,marginBottom:1,children:["Modules (",e?.length||0,")"]}),!e?.length&&(0,j.jsx)(i.Text,{color:"yellow",children:"No modules found"}),(0,j.jsx)(b.Ay,{items:n,onSelect:r})]})},w=({module:e,loading:l,error:r,onSelect:n})=>{if(l)return(0,j.jsx)(_,{text:"Loading module..."});if(r)return(0,j.jsxs)(i.Box,{flexDirection:"column",children:[(0,j.jsxs)(i.Text,{color:"red",children:["Error: ",r]}),(0,j.jsx)(b.Ay,{items:[{label:"← Back",value:"back"}],onSelect:n})]});if(!e)return(0,j.jsx)(i.Text,{color:"red",children:"Module not found"});var t=[{label:"⚡ Initialize Project",value:"project_init"},...e.short_edit?.enabled&&e.short_edit.ref_map?[{label:"Short Edit",value:"short_edit"}]:[],{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return(0,j.jsxs)(i.Box,{flexDirection:"column",children:[(0,j.jsx)(i.Text,{bold:!0,color:"cyan",children:e.name}),e.description&&(0,j.jsx)(i.Text,{color:"gray",children:e.description}),(0,j.jsxs)(i.Box,{marginY:1,flexDirection:"column",children:[(0,j.jsxs)(i.Text,{color:"gray",children:["ID: ",e._id]}),e.tags?.length>0&&(0,j.jsxs)(i.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),(0,j.jsxs)(i.Box,{flexDirection:"column",marginTop:1,children:[(0,j.jsx)(i.Text,{bold:!0,color:"white",children:"Version"}),(0,j.jsxs)(i.Text,{color:"gray",children:[" ","Current: ",e.current_version?`v${e.current_version}`:"N/A"]}),(0,j.jsxs)(i.Text,{color:e.has_unreleased_changes?"yellow":"gray",children:[" ","Changes:"," ",e.has_unreleased_changes?"● Unreleased changes":"○ No pending changes"]})]}),(0,j.jsxs)(i.Box,{flexDirection:"column",marginTop:1,children:[(0,j.jsx)(i.Text,{bold:!0,color:"white",children:"Usage"}),(0,j.jsxs)(i.Text,{color:"gray",children:[" ","Used in: ",e.use_count?.total_count||0," application(s)"]})]}),(0,j.jsxs)(i.Box,{flexDirection:"column",marginTop:1,children:[(0,j.jsx)(i.Text,{bold:!0,color:"white",children:"Settings"}),(0,j.jsxs)(i.Text,{color:"gray",children:[" ","Public: ",e.is_public?"✓ Yes":"✗ No"]}),(0,j.jsxs)(i.Text,{color:"gray",children:[" ","Modifiable: ",e.is_allow_modify?"✓ Yes":"✗ No"]}),(0,j.jsxs)(i.Text,{color:"gray",children:[" ","Short Edit: ",e.short_edit?.enabled?"✓ Enabled":"✗ Disabled"]})]}),e.expose_properties?.length>0&&(0,j.jsxs)(i.Box,{flexDirection:"column",marginTop:1,children:[(0,j.jsx)(i.Text,{bold:!0,color:"white",children:"Exposed Properties"}),(0,j.jsxs)(i.Text,{color:"gray",children:[" ",e.expose_properties.length," properties exposed"]})]}),(0,j.jsxs)(i.Box,{flexDirection:"column",marginTop:1,children:[(0,j.jsx)(i.Text,{bold:!0,color:"white",children:"Timestamps"}),e.create_datetime&&(0,j.jsxs)(i.Text,{color:"gray",children:[" Created: ",new Date(e.create_datetime).toLocaleString()]}),e.last_modify_datetime&&(0,j.jsxs)(i.Text,{color:"gray",children:[" ","Modified: ",new Date(e.last_modify_datetime).toLocaleString()]})]})]}),(0,j.jsx)(b.Ay,{items:t,onSelect:n})]})},L=({groups:e,loading:l,onSelect:r,countdown:n,lastRefreshTime:t})=>{if(l)return(0,j.jsx)(_,{text:"Loading device groups..."});var o=[...(e||[]).map(e=>({label:`📁 ${e.name} (${e.devices?.length||0} devices)`,value:e._id,group:e})),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return(0,j.jsxs)(i.Box,{flexDirection:"column",children:[(0,j.jsxs)(i.Box,{marginBottom:1,children:[(0,j.jsxs)(i.Text,{bold:!0,children:["Device Groups (",e?.length||0,")"]}),(0,j.jsx)(i.Text,{color:"gray",children:" - "}),(0,j.jsx)(f,{countdown:n,lastRefreshTime:t})]}),!e?.length&&(0,j.jsx)(i.Text,{color:"yellow",children:"No device groups found"}),(0,j.jsx)(b.Ay,{items:o,onSelect:r})]})},P=({loading:e,groupDevices:l})=>e?(0,j.jsx)(_,{text:"Loading devices..."}):l?.length?(0,j.jsxs)(j.Fragment,{children:[l.slice(0,10).map(e=>(0,j.jsxs)(i.Box,{children:[(0,j.jsx)(i.Text,{color:"gray",children:" "}),(0,j.jsx)(y,{lastAliveTime:e.entry_detail?.watch_dog_timer?.last_alive_time}),(0,j.jsxs)(i.Text,{color:"gray",children:[" ",e.name||e.device_name]}),e.device_target_name&&(0,j.jsxs)(i.Text,{color:"gray",dimColor:!0,children:[" ","(",e.device_target_name,")"]})]},e._id)),l.length>10&&(0,j.jsxs)(i.Text,{color:"gray",dimColor:!0,children:[" ","... and ",l.length-10," more"]})]}):(0,j.jsx)(i.Text,{color:"gray",children:" No devices in this group"}),M=({group:e,groupDevices:l,loading:r,error:n,onSelect:t,countdown:o,lastRefreshTime:a})=>{if(r&&!e)return(0,j.jsx)(_,{text:"Loading device group..."});if(n)return(0,j.jsxs)(i.Box,{flexDirection:"column",children:[(0,j.jsxs)(i.Text,{color:"red",children:["Error: ",n]}),(0,j.jsx)(b.Ay,{items:[{label:"← Back",value:"back"}],onSelect:t})]});if(!e)return(0,j.jsx)(i.Text,{color:"red",children:"Device group not found"});return(0,j.jsxs)(i.Box,{flexDirection:"column",children:[(0,j.jsxs)(i.Box,{children:[(0,j.jsx)(i.Text,{bold:!0,color:"cyan",children:e.name}),(0,j.jsx)(i.Text,{color:"gray",children:" - "}),(0,j.jsx)(f,{countdown:o,lastRefreshTime:a})]}),e.description&&(0,j.jsx)(i.Text,{color:"gray",children:e.description}),(0,j.jsxs)(i.Box,{marginY:1,flexDirection:"column",children:[(0,j.jsxs)(i.Text,{color:"gray",children:["ID: ",e._id]}),e.tags?.length>0&&(0,j.jsxs)(i.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),(0,j.jsxs)(i.Box,{flexDirection:"column",marginTop:1,children:[(0,j.jsxs)(i.Text,{bold:!0,color:"white",children:["Devices (",e.devices?.length||0,")"]}),(0,j.jsx)(P,{loading:r,groupDevices:l})]}),(0,j.jsxs)(i.Box,{flexDirection:"column",marginTop:1,children:[(0,j.jsx)(i.Text,{bold:!0,color:"white",children:"Timestamps"}),e.create_datetime&&(0,j.jsxs)(i.Text,{color:"gray",children:[" Created: ",new Date(e.create_datetime).toLocaleString()]}),e.last_modify_datetime&&(0,j.jsxs)(i.Text,{color:"gray",children:[" ","Modified: ",new Date(e.last_modify_datetime).toLocaleString()]})]})]}),(0,j.jsx)(b.Ay,{items:[{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],onSelect:t})]})},O=({boxes:e,loading:l,onSelect:r})=>{if(l)return(0,j.jsx)(_,{text:"Loading media boxes..."});if(!e?.length)return(0,j.jsx)(i.Text,{color:"yellow",children:"No media boxes found"});var n=[...e.map(e=>({label:`📦 ${e.name||"Unnamed"}`,value:e.id,box:e})),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return(0,j.jsxs)(i.Box,{flexDirection:"column",children:[(0,j.jsxs)(i.Text,{bold:!0,marginBottom:1,children:["Media Boxes (",e.length,")"]}),(0,j.jsx)(b.Ay,{items:n,onSelect:r})]})},R=({box:e,loading:l,error:r,onSelect:n})=>{if(l&&!e)return(0,j.jsx)(_,{text:"Loading media box..."});if(r)return(0,j.jsxs)(i.Box,{flexDirection:"column",children:[(0,j.jsxs)(i.Text,{color:"red",children:["Error: ",r]}),(0,j.jsx)(b.Ay,{items:[{label:"← Back",value:"back"}],onSelect:n})]});if(!e)return(0,j.jsx)(i.Text,{color:"red",children:"Media box not found"});return(0,j.jsxs)(i.Box,{flexDirection:"column",children:[(0,j.jsx)(i.Text,{bold:!0,color:"cyan",children:e.name||"Unnamed"}),e.description&&(0,j.jsx)(i.Text,{color:"gray",children:e.description}),(0,j.jsxs)(i.Box,{marginY:1,flexDirection:"column",children:[(0,j.jsxs)(i.Text,{color:"gray",children:["ID: ",e.id]}),e.tags?.length>0&&(0,j.jsxs)(i.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),null!=e.size&&(0,j.jsxs)(i.Text,{color:"gray",children:["Size: ",e.size]}),e.passcodes?.length>0&&(0,j.jsxs)(i.Box,{flexDirection:"column",marginTop:1,children:[(0,j.jsxs)(i.Text,{bold:!0,color:"white",children:["Passcodes (",e.passcodes.length,")"]}),e.passcodes.slice(0,5).map(e=>(0,j.jsxs)(i.Text,{color:"gray",children:[" ",e.name||"Passcode",": ",e.code]},e.id)),e.passcodes.length>5&&(0,j.jsxs)(i.Text,{color:"gray",dimColor:!0,children:[" ","... and ",e.passcodes.length-5," more"]})]}),(0,j.jsxs)(i.Box,{flexDirection:"column",marginTop:1,children:[(0,j.jsx)(i.Text,{bold:!0,color:"white",children:"Timestamps"}),e.createdAt&&(0,j.jsxs)(i.Text,{color:"gray",children:[" Created: ",new Date(e.createdAt).toLocaleString()]}),e.updatedAt&&(0,j.jsxs)(i.Text,{color:"gray",children:[" Modified: ",new Date(e.updatedAt).toLocaleString()]})]})]}),(0,j.jsx)(b.Ay,{items:[{label:"List Files",value:"files"},{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],onSelect:n})]})},N=({files:e,loading:l,onSelect:r,box:n})=>{if(l)return(0,j.jsx)(_,{text:"Loading media files..."});if(!e?.length)return(0,j.jsx)(i.Text,{color:"yellow",children:"No media files found"});var t=[...e.map(e=>{return{label:`${l=e.fileType,"Image"===l?"🖼":"Video"===l?"🎞":"Audio"===l?"🎵":"📄"} ${e.name||"Unnamed"}`,value:e.id,file:e};var l}),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return(0,j.jsxs)(i.Box,{flexDirection:"column",children:[(0,j.jsxs)(i.Text,{bold:!0,marginBottom:1,children:["Media Files (",e.length,")",n?.name?` - ${n.name}`:""]}),(0,j.jsx)(b.Ay,{items:t,onSelect:r})]})},U=({file:e,loading:l,error:r,onSelect:n})=>{if(l&&!e)return(0,j.jsx)(_,{text:"Loading media file..."});if(r)return(0,j.jsxs)(i.Box,{flexDirection:"column",children:[(0,j.jsxs)(i.Text,{color:"red",children:["Error: ",r]}),(0,j.jsx)(b.Ay,{items:[{label:"← Back",value:"back"}],onSelect:n})]});if(!e)return(0,j.jsx)(i.Text,{color:"red",children:"Media file not found"});var t=e.meta,o=(0,x.Gu)(e),a=(0,x.Gu)(e,{preferThumbnail:!0}),s=Boolean(a&&a!==o);return(0,j.jsxs)(i.Box,{flexDirection:"column",children:[(0,j.jsx)(i.Text,{bold:!0,color:"cyan",children:e.name||"Unnamed"}),e.description&&(0,j.jsx)(i.Text,{color:"gray",children:e.description}),(0,j.jsxs)(i.Box,{marginY:1,flexDirection:"column",children:[(0,j.jsxs)(i.Text,{color:"gray",children:["ID: ",e.id]}),(0,j.jsxs)(i.Text,{color:"gray",children:["Box ID: ",e.boxId]}),(0,j.jsxs)(i.Text,{color:"gray",children:["Type: ",e.fileType]}),e.userTags?.length>0&&(0,j.jsxs)(i.Text,{color:"gray",children:["Tags: ",e.userTags.join(", ")]}),null!=t?.originalWidth&&null!=t?.originalHeight&&(0,j.jsxs)(i.Text,{color:"gray",children:["Size: ",t.originalWidth,"x",t.originalHeight]}),null!=t?.originalFileSize&&(0,j.jsxs)(i.Text,{color:"gray",children:["File: ",(Number(t.originalFileSize)/1024).toFixed(1)," KB"]}),o&&(0,j.jsxs)(i.Text,{color:"gray",children:["Original URL: ",o]}),s&&(0,j.jsxs)(i.Text,{color:"gray",children:["Thumbnail URL: ",a]}),(0,j.jsxs)(i.Box,{flexDirection:"column",marginTop:1,children:[(0,j.jsx)(i.Text,{bold:!0,color:"white",children:"Timestamps"}),e.createdAt&&(0,j.jsxs)(i.Text,{color:"gray",children:[" Created: ",new Date(e.createdAt).toLocaleString()]}),e.updatedAt&&(0,j.jsxs)(i.Text,{color:"gray",children:[" Modified: ",new Date(e.updatedAt).toLocaleString()]})]})]}),(0,j.jsx)(b.Ay,{items:[{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],onSelect:n})]})},G=r(29253),F=r(35704),V=["B","C","G","D"],H=({instanceType:e,instance:l,client:r,onDone:n,onCancel:o})=>{var c=(0,i.useApp)().exit,d=(0,t.useState)("select_ref"),x=s(d,2),u=x[0],h=x[1],g=(0,t.useState)(""),m=s(g,2),T=m[0],f=m[1],p=(0,t.useState)("search"),v=s(p,2),y=v[0],D=v[1],E=(0,t.useState)(null),S=s(E,2),I=S[0],A=S[1],B=(0,t.useState)(null),C=s(B,2),k=C[0],w=C[1],L=(0,t.useState)(""),P=s(L,2),M=P[0],O=P[1],R=(0,t.useState)(""),N=s(R,2),U=N[0],H=N[1],$=(0,t.useState)(null),z=s($,2),Y=z[0],X=z[1],J=l?.short_edit?.ref_map||{},W=Object.entries(J).filter(([,e])=>e&&!e.hide),q=(0,F.V)(J,{keyword:T,types:V}),K=q.flatMap(e=>[{label:e.label,value:`__header_${e.prefix}__`,isHeader:!0},...e.refs.map(({shortId:e,ref:l})=>({label:`${l.title||e} (${e})`,value:e,ref:l}))]),Q=[...T?[{label:"↻ Clear Search",value:"__clear_search__"}]:[],{label:"← Back",value:"__back__"}],Z=K.length>0?[...K,...Q]:Q,ee=Z.findIndex(e=>!e.isHeader&&!e.value?.startsWith("__"));(0,i.useInput)((e,l)=>{l.tab&&"select_ref"===u?D(e=>"search"===e?"list":"search"):(l.escape&&("select_ref"===u&&o(),"input_path"===u&&h("select_ref"),"input_content"===u&&h("input_path"),"confirm"===u&&h("input_content"),"done"===u&&o()),"q"!==e||("input_path"===u||"input_content"===u)||"select_ref"===u&&"search"===y||c())},{isActive:!0});var le,re=e=>{var l=e.trim();if(""===l)return null;try{return JSON.parse(l)}catch{return l}},ne=(le=a(function*(){if(r&&l?._id&&I){h("submitting"),X(null);try{var t={shortId:I,path:M.trim(),content:re(U),forwardDataLink:!0};k?.inner_ref?.pid&&(t.innerRefParentShortId=k.inner_ref.pid),"application"===e?yield r.shortEditApplication({id:l._id,list:[t]}):yield r.shortEditModule({id:l._id,list:[t]}),yield n(),h("done")}catch(e){X(e.message),h("confirm")}}}),function(){return le.apply(this,arguments)});return l?.short_edit?.enabled?0===W.length?(0,j.jsxs)(i.Box,{flexDirection:"column",children:[(0,j.jsx)(i.Text,{color:"yellow",children:"No Short Edit references found."}),(0,j.jsx)(b.Ay,{items:[{label:"← Back",value:"back"}],onSelect:o})]}):"select_ref"===u?(0,j.jsxs)(i.Box,{flexDirection:"column",children:[(0,j.jsx)(i.Text,{bold:!0,children:"Short Edit References"}),(0,j.jsx)(i.Text,{color:"gray",dimColor:!0,children:"Showing: Brick, Canvas, Generator, Data"}),(0,j.jsxs)(i.Box,{marginTop:1,flexDirection:"column",children:[(0,j.jsx)(i.Text,{color:"gray",children:"Search (title or shortId)"}),(0,j.jsx)(G.A,{value:T,placeholder:"type to filter, Enter to focus list",onChange:e=>f(e),onSubmit:()=>D("list"),focus:"search"===y}),(0,j.jsx)(i.Text,{color:"gray",dimColor:!0,children:"Press Tab to switch focus"})]}),(0,j.jsxs)(i.Box,{marginTop:1,children:[0===q.length&&(0,j.jsx)(i.Text,{color:"yellow",children:"No references match your search."}),(0,j.jsx)(b.Ay,{items:Z,isFocused:"list"===y,initialIndex:ee>-1?ee:0,indicatorComponent:()=>null,itemComponent:({label:e,isSelected:l,isHeader:r})=>r?(0,j.jsx)(i.Box,{marginTop:1,children:(0,j.jsx)(i.Text,{bold:!0,color:"white",children:e})}):(0,j.jsxs)(i.Text,{color:l?"blue":void 0,children:[l?"❯":" "," ",e]}),onSelect:e=>{if("__back__"!==e.value)return"__clear_search__"===e.value?(f(""),void D("search")):void(e.isHeader||(A(e.value),w(e.ref),h("input_path")));o()}})]})]}):"input_path"===u?(0,j.jsxs)(i.Box,{flexDirection:"column",children:[(0,j.jsxs)(i.Text,{children:["Reference:"," ",(0,j.jsxs)(i.Text,{color:"cyan",children:[k?.title||I," (",I,")"]})]}),(0,j.jsx)(i.Text,{marginTop:1,children:"Enter property path (e.g. title, property.backgroundColor)"}),Y&&(0,j.jsxs)(i.Text,{color:"red",children:["Error: ",Y]}),(0,j.jsx)(G.A,{value:M,placeholder:"path",onChange:e=>{O(e),Y&&X(null)},onSubmit:e=>{var l=e.trim();l?(O(l),h("input_content")):X("Path is required")},focus:!0})]}):"input_content"===u?(0,j.jsxs)(i.Box,{flexDirection:"column",children:[(0,j.jsxs)(i.Text,{children:["Path: ",(0,j.jsx)(i.Text,{color:"cyan",children:M})]}),(0,j.jsx)(i.Text,{marginTop:1,children:"Enter new content (JSON or plain text). Empty to clear."}),Y&&(0,j.jsxs)(i.Text,{color:"red",children:["Error: ",Y]}),(0,j.jsx)(G.A,{value:U,placeholder:"content",onChange:e=>{H(e),Y&&X(null)},onSubmit:()=>h("confirm"),focus:!0})]}):"submitting"===u?(0,j.jsx)(_,{text:"Applying short edit..."}):"done"===u?(0,j.jsxs)(i.Box,{flexDirection:"column",children:[(0,j.jsx)(i.Text,{color:"green",children:"Short edit applied successfully."}),(0,j.jsx)(b.Ay,{items:[{label:"Edit another property",value:"again"},{label:"← Back",value:"back"}],onSelect:e=>{"again"===e.value?(h("select_ref"),A(null),w(null),O(""),H(""),X(null)):o()}})]}):(0,j.jsxs)(i.Box,{flexDirection:"column",children:[(0,j.jsx)(i.Text,{bold:!0,marginBottom:1,children:"Confirm Short Edit"}),(0,j.jsxs)(i.Text,{children:["Reference:"," ",(0,j.jsxs)(i.Text,{color:"cyan",children:[k?.title||I," (",I,")"]})]}),(0,j.jsxs)(i.Text,{children:["Path: ",(0,j.jsx)(i.Text,{color:"cyan",children:M})]}),(0,j.jsxs)(i.Text,{children:["Content: ",(0,j.jsx)(i.Text,{color:"cyan",children:U||"<empty>"})]}),Y&&(0,j.jsxs)(i.Text,{color:"red",children:["Error: ",Y]}),(0,j.jsx)(b.Ay,{items:[{label:"Apply",value:"apply"},{label:"Edit Path",value:"edit_path"},{label:"Edit Content",value:"edit_content"},{label:"← Back",value:"back"}],onSelect:e=>{"apply"===e.value&&ne(),"edit_path"===e.value&&h("input_path"),"edit_content"===e.value&&h("input_content"),"back"===e.value&&o()}})]}):(0,j.jsxs)(i.Box,{flexDirection:"column",children:[(0,j.jsxs)(i.Text,{color:"yellow",children:["Short Edit is not enabled for this ",e,"."]}),(0,j.jsx)(b.Ay,{items:[{label:"← Back",value:"back"}],onSelect:o})]})},$=r(16928),z=r(79896),Y=r(35317),X=r(10750),J="options",W="output_dir",q="confirm",K="generating",Q="post_install",Z="done",ee=e=>{try{return(0,Y.execSync)(`which ${e}`,{stdio:"ignore"}),!0}catch{return!1}},le=(e,l,r)=>new Promise((n,t)=>{var i=[e,...l].join(" "),o=(0,Y.spawn)(i,[],{cwd:r,stdio:"pipe",shell:!0});o.on("close",e=>{0===e?n():t(new Error(`Command failed with code ${e}`))}),o.on("error",t)}),re=(n=a(function*(e,l){try{var n=(yield Promise.resolve().then(r.bind(r,79491))).format;return(yield n(l,e,{trailingComma:"all",tabWidth:2,semi:!1,singleQuote:!0,printWidth:100})).code}catch{}return e}),function(e,l){return n.apply(this,arguments)}),ne=({type:e,instance:l,client:r,onDone:n,onCancel:o})=>{var c,d=(0,i.useApp)().exit,x=(0,t.useState)(J),u=s(x,2),h=u[0],g=u[1],T=(0,t.useState)({setupGitHubActions:!0,setupAgents:!0,setupClaudeCode:!0,setupGeminiCLI:!1,runBunInstall:!0,initGit:!0}),f=s(T,2),p=f[0],v=f[1],_=(0,t.useState)(process.cwd()),y=s(_,2),D=y[0],E=y[1],S=(0,t.useState)(""),I=s(S,2),A=I[0],B=I[1],C=(0,t.useState)(null),k=s(C,2),w=k[0],L=k[1],P=(0,t.useState)(null),M=s(P,2),O=M[0],R=M[1],N=X(l?.name||"bricks-ctor"),U=$.resolve(D,N),F=(0,t.useCallback)(e=>{"back"!==e.value?"continue"!==e.value?v(l=>({...l,[e.value]:!l[e.value]})):g(W):o()},[o]),V=(0,t.useCallback)(()=>{z.existsSync(U)?L(`Directory already exists: ${U}`):(L(null),g(q))},[U]),H=(0,t.useCallback)((c=a(function*(n){var t;if("back"!==n.value)if("cancel"!==n.value){if("confirm"===n.value){g(K);try{B("Fetching project from BRICKS...");var i="application"===e,s=i?"UNSTABLE_applicationProject":"UNSTABLE_moduleProject",c=i?r.queries.applicationProject:r.queries.moduleProject,d=(yield r.query(c,{id:l._id,buildApplicationOnly:!1,setupGitHubActions:p.setupGitHubActions,setupAgents:p.setupAgents,setupClaudeCode:p.setupClaudeCode,setupGeminiCLI:p.setupGeminiCLI}))[s];if(!d?.files)throw new Error("Failed to fetch project files");B("Creating project directory..."),z.mkdirSync(U,{recursive:!0}),B(`Writing ${d.files.length} files...`);var x=yield Promise.all(d.files.map((t=a(function*(e){var l=$.join(U,e.name),r=e.input;return e.formatable&&(r=yield re(r,l)),{...e,filePath:l,content:r}}),function(e){return t.apply(this,arguments)})));x.forEach(e=>{var l=$.dirname(e.filePath);z.existsSync(l)||z.mkdirSync(l,{recursive:!0}),z.writeFileSync(e.filePath,e.content)}),g(Q);var u={path:U,files:d.files.length,bunInstalled:!1,gitInitialized:!1};if(p.runBunInstall&&ee("bun")){B("Installing dependencies (bun install)...");try{yield le("bun",["install"],U),u.bunInstalled=!0}catch{}}if(p.initGit&&ee("git")){B("Initializing git repository...");try{yield le("git",["init"],U),yield le("git",["add","."],U),yield le("git",["-c 'user.name=BRICKS CLI'","-c 'user.email=cli@bricks.tools'","commit","-m 'chore: initialize commit'"],U),u.gitInitialized=!0}catch{}}R(u),g(Z)}catch(e){L(e.message),g(J)}}}else o();else g(W)}),function(e){return c.apply(this,arguments)}),[r,l,e,p,U,o]),Y=(0,t.useCallback)(e=>{"exit"===e.value?d():n()},[d,n]);if(h===J){var ne=[{label:(p.setupGitHubActions?"[x]":"[ ]")+" GitHub Actions workflow",value:"setupGitHubActions"},{label:(p.setupAgents?"[x]":"[ ]")+" AGENTS.md",value:"setupAgents"},{label:(p.setupClaudeCode?"[x]":"[ ]")+" CLAUDE.md",value:"setupClaudeCode"},{label:(p.setupGeminiCLI?"[x]":"[ ]")+" GEMINI.md",value:"setupGeminiCLI"},{label:(p.runBunInstall?"[x]":"[ ]")+" Run bun install after generation",value:"runBunInstall"},{label:(p.initGit?"[x]":"[ ]")+" Initialize git repository",value:"initGit"},{label:"→ Continue",value:"continue"},{label:"← Back",value:"back"}];return(0,j.jsxs)(i.Box,{flexDirection:"column",children:[(0,j.jsxs)(i.Text,{bold:!0,color:"cyan",children:["Initialize BRICKS Project: ",l?.name||"Untitled"]}),(0,j.jsx)(i.Text,{color:"gray",marginBottom:1,children:"Select options for project generation (press Enter to toggle)"}),w&&(0,j.jsxs)(i.Text,{color:"red",marginBottom:1,children:["Error: ",w]}),(0,j.jsx)(b.Ay,{items:ne,onSelect:F})]})}if(h===W)return(0,j.jsxs)(i.Box,{flexDirection:"column",children:[(0,j.jsx)(i.Text,{bold:!0,color:"cyan",children:"Output Directory"}),(0,j.jsx)(i.Text,{color:"gray",marginBottom:1,children:"Enter the parent directory for the project:"}),w&&(0,j.jsx)(i.Text,{color:"red",marginBottom:1,children:w}),(0,j.jsxs)(i.Box,{children:[(0,j.jsx)(i.Text,{children:"Directory: "}),(0,j.jsx)(G.A,{value:D,onChange:E,onSubmit:V})]}),(0,j.jsxs)(i.Text,{color:"gray",marginTop:1,children:["Project will be created at: ",U]})]});if(h===q){return(0,j.jsxs)(i.Box,{flexDirection:"column",children:[(0,j.jsx)(i.Text,{bold:!0,color:"cyan",children:"Confirm Project Generation"}),(0,j.jsxs)(i.Box,{marginY:1,flexDirection:"column",children:[(0,j.jsxs)(i.Text,{children:["Name: ",(0,j.jsx)(i.Text,{color:"green",children:l?.name||"Untitled"})]}),(0,j.jsxs)(i.Text,{children:["Type: ",(0,j.jsx)(i.Text,{color:"yellow",children:e})]}),(0,j.jsxs)(i.Text,{children:["Path: ",(0,j.jsx)(i.Text,{color:"cyan",children:U})]}),(0,j.jsx)(i.Text,{color:"gray",marginTop:1,children:"Options:"}),(0,j.jsxs)(i.Text,{color:"gray",children:[" - GitHub Actions: ",p.setupGitHubActions?"Yes":"No"]}),(0,j.jsxs)(i.Text,{color:"gray",children:[" - AGENTS.md: ",p.setupAgents?"Yes":"No"]}),(0,j.jsxs)(i.Text,{color:"gray",children:[" - CLAUDE.md: ",p.setupClaudeCode?"Yes":"No"]}),(0,j.jsxs)(i.Text,{color:"gray",children:[" - GEMINI.md: ",p.setupGeminiCLI?"Yes":"No"]}),(0,j.jsxs)(i.Text,{color:"gray",children:[" - Run bun install: ",p.runBunInstall?"Yes":"No"]}),(0,j.jsxs)(i.Text,{color:"gray",children:[" - Initialize git: ",p.initGit?"Yes":"No"]})]}),(0,j.jsx)(b.Ay,{items:[{label:"Confirm & Generate",value:"confirm"},{label:"← Change Directory",value:"back"},{label:"Cancel",value:"cancel"}],onSelect:H})]})}if(h===K||h===Q)return(0,j.jsxs)(i.Box,{flexDirection:"column",children:[(0,j.jsx)(i.Text,{bold:!0,color:"cyan",children:"Generating Project..."}),(0,j.jsxs)(i.Box,{marginY:1,children:[(0,j.jsx)(i.Text,{color:"green",children:(0,j.jsx)(m.A,{type:"dots"})}),(0,j.jsxs)(i.Text,{children:[" ",A]})]})]});if(h===Z&&O){return(0,j.jsxs)(i.Box,{flexDirection:"column",children:[(0,j.jsx)(i.Text,{bold:!0,color:"green",children:"Project initialized successfully!"}),(0,j.jsxs)(i.Box,{marginY:1,flexDirection:"column",children:[(0,j.jsxs)(i.Text,{children:["Path: ",(0,j.jsx)(i.Text,{color:"cyan",children:O.path})]}),(0,j.jsxs)(i.Text,{children:["Files: ",(0,j.jsx)(i.Text,{color:"green",children:O.files})]}),(0,j.jsxs)(i.Text,{children:["Dependencies:"," ",(0,j.jsx)(i.Text,{color:O.bunInstalled?"green":"yellow",children:O.bunInstalled?"Installed":"Not installed (run bun install manually)"})]}),(0,j.jsxs)(i.Text,{children:["Git:"," ",(0,j.jsx)(i.Text,{color:O.gitInitialized?"green":"yellow",children:O.gitInitialized?"Initialized":"Not initialized"})]})]}),(0,j.jsx)(i.Text,{bold:!0,marginY:1,children:"Next steps:"}),(0,j.jsxs)(i.Text,{color:"gray",children:[" cd ",N]}),!O.bunInstalled&&(0,j.jsx)(i.Text,{color:"gray",children:" bun install"}),(0,j.jsx)(i.Text,{color:"gray",children:" bun preview"}),(0,j.jsxs)(i.Text,{color:"gray",marginTop:1,children:["For more information, see ",N,"/README.md"]}),(0,j.jsx)(i.Box,{marginTop:1,children:(0,j.jsx)(b.Ay,{items:[{label:"← Back to Detail",value:"back"},{label:"Exit CLI",value:"exit"}],onSelect:Y})})]})}return null};const te=()=>{var e=(0,i.useApp)().exit,l=(0,t.useState)(u.MAIN),r=s(l,2),n=r[0],o=r[1],h=(0,t.useState)(null),g=s(h,2),m=g[0],f=g[1],y=(0,t.useState)(null),b=s(y,2),P=b[0],G=b[1],F=(0,t.useState)(!0),V=s(F,2),$=V[0],z=V[1],Y=(0,t.useState)(null),X=s(Y,2),J=X[0],W=X[1],q=(0,t.useState)([]),K=s(q,2),Q=K[0],Z=K[1],ee=(0,t.useState)(null),le=s(ee,2),re=le[0],te=le[1],ie=(0,t.useState)([]),oe=s(ie,2),ae=oe[0],se=oe[1],ce=(0,t.useState)(null),de=s(ce,2),xe=de[0],ue=de[1],he=(0,t.useState)([]),ge=s(he,2),me=ge[0],je=ge[1],Te=(0,t.useState)(null),fe=s(Te,2),pe=fe[0],ve=fe[1],_e=(0,t.useState)([]),ye=s(_e,2),be=ye[0],De=ye[1],Ee=(0,t.useState)(null),Se=s(Ee,2),Ie=Se[0],Ae=Se[1],Be=(0,t.useState)([]),Ce=s(Be,2),ke=Ce[0],we=Ce[1],Le=(0,t.useState)(!1),Pe=s(Le,2),Me=Pe[0],Oe=Pe[1],Re=(0,t.useState)(null),Ne=s(Re,2),Ue=Ne[0],Ge=Ne[1],Fe=(0,t.useState)(null),Ve=s(Fe,2),He=Ve[0],$e=Ve[1],ze=(0,t.useState)(null),Ye=s(ze,2),Xe=Ye[0],Je=Ye[1],We=(0,t.useState)(null),qe=s(We,2),Ke=qe[0],Qe=qe[1],Ze=(0,t.useState)([]),el=s(Ze,2),ll=el[0],rl=el[1],nl=(0,t.useState)(null),tl=s(nl,2),il=tl[0],ol=tl[1],al=(0,t.useState)([]),sl=s(al,2),cl=sl[0],dl=sl[1],xl=(0,t.useState)(null),ul=s(xl,2),hl=ul[0],gl=ul[1],ml=n===u.DEVICES,jl=n===u.DEVICE_DETAIL,Tl=n===u.GROUPS,fl=n===u.GROUP_DETAIL;(0,t.useEffect)(()=>{var e=(0,d.getCurrentProfile)(),l=(0,d.getToken)(e);if(!l)return W("Not logged in. Run `bricks auth login` first."),void z(!1);var r=(0,c.createClient)((0,d.getBaseUrl)(),l);f(r),r.workspace().then(e=>{G(e),z(!1)}).catch(e=>{W(e.message),z(!1)})},[]),(0,i.useInput)((l,r)=>{"q"===l&&e(),r.escape&&(n===u.DEVICE_CONTROL?(o(u.DEVICE_DETAIL),Ge(null)):n===u.DEVICE_SCREENSHOT?(o(u.DEVICE_DETAIL),Je(null),Qe(null)):n===u.DEVICE_DETAIL?(o(u.DEVICES),te(null)):n===u.APP_DETAIL?(o(u.APPS),ue(null)):n===u.MODULE_DETAIL?(o(u.MODULES),ve(null)):n===u.GROUP_DETAIL?(o(u.GROUPS),Ae(null),we([])):n===u.MEDIA_FILE_DETAIL?(o(u.MEDIA_FILES),gl(null)):n===u.MEDIA_FILES?(o(u.MEDIA_BOX_DETAIL),gl(null)):n===u.MEDIA_BOX_DETAIL?(o(u.MEDIA_BOXES),ol(null),dl([])):(n===u.MEDIA_BOXES||n!==u.MAIN)&&o(u.MAIN))},{isActive:n!==u.APP_SHORT_EDIT&&n!==u.MODULE_SHORT_EDIT&&n!==u.APP_PROJECT_INIT&&n!==u.MODULE_PROJECT_INIT});var pl,vl,_l,yl,bl,Dl,El,Sl,Il=(0,t.useCallback)(a(function*(){if(m){z(!0);try{var e=yield m.devices({});Z(e||[])}catch(e){W(e.message)}z(!1)}}),[m]),Al=(0,t.useCallback)((pl=a(function*(e){if(m){z(!0),$e(null);try{var l=yield m.device({id:e});te(l)}catch(e){$e(e.message)}z(!1)}}),function(e){return pl.apply(this,arguments)}),[m]),Bl=(0,t.useCallback)(a(function*(){if(m){z(!0);try{var e=yield m.applications({});se(e||[])}catch(e){W(e.message)}z(!1)}}),[m]),Cl=(0,t.useCallback)((vl=a(function*(e){if(m){z(!0),$e(null);try{var l=yield m.application({id:e});ue(l)}catch(e){$e(e.message)}z(!1)}}),function(e){return vl.apply(this,arguments)}),[m]),kl=(0,t.useCallback)(a(function*(){if(m){z(!0);try{var e=yield m.modules({});je(e||[])}catch(e){W(e.message)}z(!1)}}),[m]),wl=(0,t.useCallback)((_l=a(function*(e){if(m){z(!0),$e(null);try{var l=yield m.module({id:e});ve(l)}catch(e){$e(e.message)}z(!1)}}),function(e){return _l.apply(this,arguments)}),[m]),Ll=(0,t.useCallback)(a(function*(){if(m){z(!0);try{var e=yield m.deviceGroups({});De(e||[])}catch(e){W(e.message)}z(!1)}}),[m]),Pl=(0,t.useCallback)((yl=a(function*(e){if(m){z(!0),$e(null);try{var l=yield Promise.all([m.deviceGroup({id:e}),m.devicesByGroup({id:e})]),r=s(l,2),n=r[0],t=r[1];Ae(n),we(t||[])}catch(e){$e(e.message)}z(!1)}}),function(e){return yl.apply(this,arguments)}),[m]),Ml=(0,t.useCallback)(a(function*(){if(m){z(!0);try{var e=yield m.mediaBoxes();rl(e||[])}catch(e){W(e.message)}z(!1)}}),[m]),Ol=(0,t.useCallback)((bl=a(function*(e){if(m){z(!0),$e(null);try{var l=yield m.mediaBox({id:e});ol(l)}catch(e){$e(e.message)}z(!1)}}),function(e){return bl.apply(this,arguments)}),[m]),Rl=(0,t.useCallback)((Dl=a(function*(e){if(m){z(!0);try{var l=yield m.mediaFiles({boxId:e});dl(l||[])}catch(e){W(e.message)}z(!1)}}),function(e){return Dl.apply(this,arguments)}),[m]),Nl=(0,t.useCallback)((El=a(function*(e){if(m){z(!0),$e(null);try{var l=yield m.mediaFile({id:e});gl(l)}catch(e){$e(e.message)}z(!1)}}),function(e){return El.apply(this,arguments)}),[m]),Ul=(0,t.useCallback)((Sl=a(function*(e){if(m&&re){Oe(!0),Ge(null);try{yield m.controlDevice({id:re._id,type:e}),Ge({success:!0,message:`Command sent: ${e}`})}catch(e){Ge({success:!1,message:e.message})}Oe(!1)}}),function(e){return Sl.apply(this,arguments)}),[m,re]),Gl=(0,t.useCallback)(a(function*(e=!1){if(m&&re&&P){z(!0),Qe(null),Je(null);try{e&&(yield m.controlDevice({id:re._id,type:"take-screenshot"}),yield new Promise(e=>setTimeout(e,3e3)));var l=yield(0,x.he)(m,P,re._id,null,{preferThumbnail:!0});l.error?Qe(l.error):Je(l)}catch(e){Qe(e.message)}z(!1)}}),[m,re,P]),Fl=T((0,t.useCallback)(()=>{m&&Il()},[m,Il]),ml),Vl=T((0,t.useCallback)(()=>{m&&re&&Al(re._id)},[m,re,Al]),jl),Hl=T((0,t.useCallback)(()=>{m&&Ll()},[m,Ll]),Tl),$l=T((0,t.useCallback)(()=>{m&&Ie&&Pl(Ie._id)},[m,Ie,Pl]),fl);return $&&!P?(0,j.jsxs)(i.Box,{flexDirection:"column",children:[(0,j.jsx)(p,{workspace:P,view:n}),(0,j.jsx)(_,{text:"Connecting to workspace..."})]}):J&&!P?(0,j.jsxs)(i.Box,{flexDirection:"column",children:[(0,j.jsx)(p,{workspace:P,view:n}),(0,j.jsxs)(i.Text,{color:"red",children:["Error: ",J]}),(0,j.jsx)(v,{})]}):(0,j.jsxs)(i.Box,{flexDirection:"column",children:[(0,j.jsx)(p,{workspace:P,view:n}),n===u.MAIN&&(0,j.jsx)(D,{onSelect:l=>{"exit"!==l.value?(o(l.value),l.value===u.DEVICES?Il():l.value===u.APPS?Bl():l.value===u.MODULES?kl():l.value===u.GROUPS?Ll():l.value===u.MEDIA_BOXES&&Ml()):e()},mediaEnabled:(0,x.wR)(P)}),n===u.DEVICES&&(0,j.jsx)(E,{devices:Q,loading:$,onSelect:e=>{if("back"!==e.value){if("refresh"===e.value)return Il(),void Fl.resetCountdown();te(null),z(!0),o(u.DEVICE_DETAIL),Al(e.value)}else o(u.MAIN)},countdown:Fl.countdown,lastRefreshTime:Fl.lastRefreshTime}),n===u.DEVICE_DETAIL&&(0,j.jsx)(S,{device:re,loading:$,error:He,onSelect:e=>"back"===e.value?(o(u.DEVICES),void te(null)):"refresh"===e.value?(Al(re._id),void Vl.resetCountdown()):("control"===e.value&&(o(u.DEVICE_CONTROL),Ge(null)),void("screenshot"===e.value&&(o(u.DEVICE_SCREENSHOT),Je(null),Qe(null),Gl(!1)))),mediaEnabled:(0,x.wR)(P),countdown:Vl.countdown,lastRefreshTime:Vl.lastRefreshTime}),n===u.DEVICE_CONTROL&&(0,j.jsx)(I,{device:re,onSelect:e=>{if("back"===e.value)return o(u.DEVICE_DETAIL),void Ge(null);Ul(e.value)},controlling:Me,controlResult:Ue}),n===u.DEVICE_SCREENSHOT&&(0,j.jsx)(A,{device:re,screenshot:Xe,loading:$,error:Ke,onSelect:e=>{if("back"===e.value)return o(u.DEVICE_DETAIL),Je(null),void Qe(null);"refresh"!==e.value?"take"===e.value&&Gl(!0):Gl(!1)}}),n===u.APPS&&(0,j.jsx)(B,{apps:ae,loading:$,onSelect:e=>{"back"!==e.value?"refresh"!==e.value?(ue(null),z(!0),o(u.APP_DETAIL),Cl(e.value)):Bl():o(u.MAIN)}}),n===u.APP_DETAIL&&(0,j.jsx)(C,{app:xe,loading:$,error:He,onSelect:e=>{if("back"===e.value)return o(u.APPS),void ue(null);"refresh"!==e.value?("short_edit"===e.value&&(o(u.APP_SHORT_EDIT),$e(null)),"project_init"===e.value&&(o(u.APP_PROJECT_INIT),$e(null))):Cl(xe._id)}}),n===u.APP_SHORT_EDIT&&(0,j.jsx)(H,{instanceType:"application",instance:xe,client:m,onDone:a(function*(){return Cl(xe._id)}),onCancel:()=>o(u.APP_DETAIL)}),n===u.APP_PROJECT_INIT&&(0,j.jsx)(ne,{type:"application",instance:xe,client:m,onDone:()=>o(u.APP_DETAIL),onCancel:()=>o(u.APP_DETAIL)}),n===u.MODULES&&(0,j.jsx)(k,{modules:me,loading:$,onSelect:e=>{"back"!==e.value?"refresh"!==e.value?(ve(null),z(!0),o(u.MODULE_DETAIL),wl(e.value)):kl():o(u.MAIN)}}),n===u.MODULE_DETAIL&&(0,j.jsx)(w,{module:pe,loading:$,error:He,onSelect:e=>{if("back"===e.value)return o(u.MODULES),void ve(null);"refresh"!==e.value?("short_edit"===e.value&&(o(u.MODULE_SHORT_EDIT),$e(null)),"project_init"===e.value&&(o(u.MODULE_PROJECT_INIT),$e(null))):wl(pe._id)}}),n===u.MODULE_SHORT_EDIT&&(0,j.jsx)(H,{instanceType:"module",instance:pe,client:m,onDone:a(function*(){return wl(pe._id)}),onCancel:()=>o(u.MODULE_DETAIL)}),n===u.MODULE_PROJECT_INIT&&(0,j.jsx)(ne,{type:"module",instance:pe,client:m,onDone:()=>o(u.MODULE_DETAIL),onCancel:()=>o(u.MODULE_DETAIL)}),n===u.GROUPS&&(0,j.jsx)(L,{groups:be,loading:$,onSelect:e=>{if("back"!==e.value){if("refresh"===e.value)return Ll(),void Hl.resetCountdown();Ae(null),we([]),z(!0),o(u.GROUP_DETAIL),Pl(e.value)}else o(u.MAIN)},countdown:Hl.countdown,lastRefreshTime:Hl.lastRefreshTime}),n===u.GROUP_DETAIL&&(0,j.jsx)(M,{group:Ie,groupDevices:ke,loading:$,error:He,onSelect:e=>{if("back"===e.value)return o(u.GROUPS),Ae(null),void we([]);"refresh"===e.value&&(Pl(Ie._id),$l.resetCountdown())},countdown:$l.countdown,lastRefreshTime:$l.lastRefreshTime}),n===u.MEDIA_BOXES&&(0,j.jsx)(O,{boxes:ll,loading:$,onSelect:e=>{"back"!==e.value?"refresh"!==e.value?(ol(null),dl([]),z(!0),o(u.MEDIA_BOX_DETAIL),Ol(e.value)):Ml():o(u.MAIN)}}),n===u.MEDIA_BOX_DETAIL&&(0,j.jsx)(R,{box:il,loading:$,error:He,onSelect:e=>{if("back"===e.value)return o(u.MEDIA_BOXES),ol(null),void dl([]);"refresh"!==e.value?"files"===e.value&&(dl([]),gl(null),o(u.MEDIA_FILES),Rl(il.id)):Ol(il.id)}}),n===u.MEDIA_FILES&&(0,j.jsx)(N,{files:cl,box:il,loading:$,onSelect:e=>{if("back"===e.value)return o(u.MEDIA_BOX_DETAIL),void gl(null);"refresh"!==e.value?(gl(null),z(!0),o(u.MEDIA_FILE_DETAIL),Nl(e.value)):Rl(il.id)}}),n===u.MEDIA_FILE_DETAIL&&(0,j.jsx)(U,{file:hl,loading:$,error:He,onSelect:e=>{if("back"===e.value)return o(u.MEDIA_FILES),void gl(null);"refresh"===e.value&&Nl(hl.id)}}),(0,j.jsx)(v,{})]})};var ie=()=>{(0,i.render)((0,j.jsx)(o.TerminalInfoProvider,{children:(0,j.jsx)(te,{})}))}}};