@fugood/bricks-cli 2.25.0-beta.6 → 2.25.0-beta.60
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/README.md +61 -2
- package/lib/10.js +1 -1
- package/lib/117.js +165 -162
- package/lib/178.js +1 -1
- package/lib/223.js +4 -0
- package/lib/249.js +1 -0
- package/lib/305.js +1 -0
- package/lib/456.js +3 -1
- package/lib/511.js +1 -1
- package/lib/75.js +1 -0
- package/lib/940.js +1 -1
- package/lib/index.js +276 -113
- package/package.json +3 -2
- package/lib/602.js +0 -3
package/lib/940.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"ink";import*as l from"react";import{Fragment as r,jsx as t,jsxs as n}from"react/jsx-runtime";export const __rspack_esm_id=940;export const __rspack_esm_ids=[940];export const __webpack_modules__={8498(l){l.exports=e},51649(e){e.exports=l},92319(e,l,i){i.r(l),i.d(l,{AppList:()=>O,CONTROL_ACTIONS:()=>T,MainMenu:()=>I,Header:()=>y,ModuleDetail:()=>R,ONLINE_THRESHOLD_MS:()=>p,ShortEditEditor:()=>q,MediaFileList:()=>F,App:()=>es,DeviceDetail:()=>L,VIEWS:()=>m,runInteractiveMode:()=>ex,DeviceList:()=>C,MediaBoxList:()=>$,Loading:()=>D,DeviceControl:()=>k,ProjectInitView:()=>eu,GroupDetail:()=>G,ModuleList:()=>P,MediaBoxDetail:()=>V,GroupList:()=>N,Footer:()=>b,DeviceStatus:()=>E,AppDetail:()=>M,DeviceScreenshot:()=>w,MediaFileDetail:()=>j});var o,a,c=i(99436),d=i(51649),u=i(8498),s=i(68832),h=i(85382),x=i(23258),g=i(60450),m={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",ACTIVITY_LOG:"activity_log"},T=[{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"}],p=3e5,f=i(47882),v=(e,l=!0)=>{var r=Math.floor(60),t=s((0,d.useState)(r),2),n=t[0],i=t[1],o=s((0,d.useState)(null),2),a=o[0],c=o[1],u=(0,d.useRef)(e);(0,d.useEffect)(()=>{u.current=e},[e]);var h=(0,d.useCallback)(()=>{i(r),c(Date.now())},[r]);return(0,d.useEffect)(()=>{if(l){var e=setInterval(()=>{i(e=>e<=1?(u.current?.(),c(Date.now()),r):e-1)},1e3);return()=>clearInterval(e)}},[l,r]),(0,d.useEffect)(()=>{l&&(i(r),c(Date.now()))},[l,r]),{countdown:n,lastRefreshTime:a,resetCountdown:h}},_=({countdown:e,lastRefreshTime:l})=>t(u.Box,{children:n(u.Text,{color:"gray",children:["Next refresh in ",n(u.Text,{color:"cyan",children:[e,"s"]}),l&&n(u.Text,{color:"gray",children:[" (last: ",l?new Date(l).toLocaleTimeString():null,")"]})]})}),y=({workspace:e,view:l})=>n(u.Box,{flexDirection:"column",marginBottom:1,children:[n(u.Box,{children:[t(u.Text,{bold:!0,color:"cyan",children:"BRICKS CLI"}),t(u.Text,{color:"gray",children:" - Interactive Mode"})]}),n(u.Box,{children:[t(u.Text,{color:"gray",children:"Workspace: "}),t(u.Text,{color:"green",children:e?.name||"Not connected"}),t(u.Text,{color:"gray",children:" | View: "}),t(u.Text,{color:"yellow",children:l})]}),t(u.Text,{color:"gray",children:"─".repeat(60)})]}),b=()=>n(u.Box,{marginTop:1,flexDirection:"column",children:[t(u.Text,{color:"gray",children:"─".repeat(60)}),n(u.Text,{color:"gray",children:["Press ",t(u.Text,{color:"cyan",children:"q"})," to quit, ",t(u.Text,{color:"cyan",children:"Esc"})," to go back"]})]}),D=({text:e})=>n(u.Box,{children:[t(u.Text,{color:"green",children:t(f.A,{type:"dots"})}),n(u.Text,{children:[" ",e||"Loading..."]})]}),E=({lastAliveTime:e})=>{if(!e)return t(u.Text,{color:"gray",children:"○ Unknown"});var l=Date.now()-new Date(e).getTime();if(l<=p)return t(u.Text,{color:"green",children:"● Online"});var r=Math.floor(l/6e4);if(r<60)return n(u.Text,{color:"yellow",children:["○ Offline (",r,"m ago)"]});var i=Math.floor(r/60);if(i<24)return n(u.Text,{color:"red",children:["○ Offline (",i,"h ago)"]});var o=Math.floor(i/24);return n(u.Text,{color:"red",children:["○ Offline (",o,"d ago)"]})},S=i(48724),I=({onSelect:e,mediaEnabled:l,activityLogEnabled:r})=>{var i=[{label:"Devices",value:m.DEVICES},{label:"Applications",value:m.APPS},{label:"Modules",value:m.MODULES},{label:"Device Groups",value:m.GROUPS},...l?[{label:"Media Flow",value:m.MEDIA_BOXES}]:[],...r?[{label:"Activity Log",value:m.ACTIVITY_LOG}]:[],{label:"Exit",value:"exit"}];return n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,marginBottom:1,children:"Main Menu"}),t(S.Ay,{items:i,onSelect:e})]})},A="1"===process.env.BRICKS_CLI_DISTRIBUTION,B=e=>{var l=s((0,d.useState)(null),2),r=l[0],n=l[1];return((0,d.useEffect)(()=>{if(!A){var e=!0;return i.e(166).then(i.bind(i,29557)).then(l=>{e&&n(()=>l.default)}).catch(()=>{e&&n(!1)}),()=>{e=!1}}},[]),A||!1===r)?t(u.Text,{color:"gray",children:"Image preview is not available in this CLI build."}):r?t(r,{...e}):t(D,{text:"Preparing image preview..."})},C=({devices:e,loading:l,onSelect:r,countdown:i,lastRefreshTime:o})=>{if(l)return t(D,{text:"Loading devices..."});if(!e?.length)return n(u.Box,{flexDirection:"column",children:[t(u.Text,{color:"yellow",children:"No devices found"}),t(_,{countdown:i,lastRefreshTime:o})]});var a=[...e.map(e=>{var l=(e=>{if(!e)return"○ Unknown";var l=Date.now()-new Date(e).getTime();if(l<=p)return"● Online";var r=Math.floor(l/6e4);if(r<60)return`○ ${r}m ago`;var t=Math.floor(r/60);if(t<24)return`○ ${t}h ago`;var n=Math.floor(t/24);return`○ ${n}d ago`})(e.entry_detail?.watch_dog_timer?.last_alive_time);return{label:`${l} - ${e.name||e.device_name}`,value:e._id,device:e}}),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return n(u.Box,{flexDirection:"column",children:[n(u.Box,{marginBottom:1,children:[n(u.Text,{bold:!0,children:["Devices (",e.length,")"]}),t(u.Text,{color:"gray",children:" - "}),t(_,{countdown:i,lastRefreshTime:o})]}),t(S.Ay,{items:a,onSelect:r})]})},L=({device:e,loading:l,error:r,onSelect:i,mediaEnabled:o,countdown:a,lastRefreshTime:c})=>{if(l)return t(D,{text:"Loading device..."});if(r)return n(u.Box,{flexDirection:"column",children:[n(u.Text,{color:"red",children:["Error: ",r]}),t(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:i})]});if(!e)return t(u.Text,{color:"red",children:"Device not found"});var d=[{label:"Control Device",value:"control"},...o?[{label:"View Screenshot",value:"screenshot"}]:[],{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],s=e.entry_detail,h=s?.screen,x=s?.update,g=s?.local_sync;return n(u.Box,{flexDirection:"column",children:[n(u.Box,{children:[t(u.Text,{bold:!0,color:"cyan",children:e.name||e.device_name}),t(u.Text,{color:"gray",children:" - "}),t(_,{countdown:a,lastRefreshTime:c})]}),e.description&&t(u.Text,{color:"gray",children:e.description}),n(u.Box,{marginY:1,flexDirection:"column",children:[n(u.Box,{children:[t(u.Text,{color:"gray",children:"Status: "}),t(E,{lastAliveTime:s?.watch_dog_timer?.last_alive_time})]}),n(u.Text,{color:"gray",children:["ID: ",e._id]}),e.tags?.length>0&&n(u.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),s?.application&&n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Application"}),n(u.Text,{color:"gray",children:[" Name: ",s.application.name]}),n(u.Text,{color:"gray",children:[" Mode: ",s.operation_mode||"N/A"]})]}),h&&n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Screen"}),h.resolution&&n(u.Text,{color:"gray",children:[" ","Resolution: ",h.resolution.width,"x",h.resolution.height,h.resolution.scale&&` @${h.resolution.scale}x`]}),h.orientation&&n(u.Text,{color:"gray",children:[" Orientation: ",h.orientation]}),h.touch&&n(u.Text,{color:"gray",children:[" ","Touch:"," ",h.touch.available?`Yes (${h.touch.touch_point} points)`:"No"]})]}),(s?.memory_usage||s?.disk_usage)&&n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"System"}),s.memory_usage&&n(u.Text,{color:"gray",children:[" Memory: ",Math.round(100*s.memory_usage),"%"]}),s.disk_usage&&n(u.Text,{color:"gray",children:[" Disk: ",Math.round(100*s.disk_usage),"%"]})]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Capabilities"}),n(u.Text,{color:"gray",children:[" ","Sound: ",s?.sound?.available?"✓":"✗"," | ","Camera: ",s?.camera?.available?"✓":"✗"," | ","Audio In: ",s?.audio_in?.available?"✓":"✗"]})]}),g&&n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Local Sync"}),n(u.Text,{color:"gray",children:[" ","Role: ",g.is_main?"Main":"Peer",g.peer_count>0&&` | Peers: ${g.peer_count}`,g.mean_latency&&` | Latency: ${g.mean_latency}ms`]})]}),x&&n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Update"}),n(u.Text,{color:x.need_update?"yellow":"gray",children:[" ","Status: ",x.need_update?"⚠ Update available":"✓ Up to date"]}),x.current_version&&n(u.Text,{color:"gray",children:[" Version: ",x.current_version]})]})]}),t(S.Ay,{items:d,onSelect:i})]})},k=({device:e,onSelect:l,controlling:r,controlResult:i})=>n(u.Box,{flexDirection:"column",children:[n(u.Text,{bold:!0,color:"cyan",children:["Control: ",e?.name||e?.device_name]}),r&&t(D,{text:"Sending command..."}),i&&t(u.Text,{color:i.success?"green":"red",children:i.message}),t(u.Box,{marginTop:1,children:t(S.Ay,{items:T,onSelect:l})})]}),w=({device:e,screenshot:l,loading:r,error:i,onSelect:o})=>{var a=l?.file?.meta,c=a?.originalWidth!=null&&a?.originalHeight!=null,d=a?.originalFileSize!=null;return n(u.Box,{flexDirection:"column",children:[n(u.Text,{bold:!0,color:"cyan",children:["Screenshot: ",e?.name||e?.device_name||"Unknown"]}),r&&t(D,{text:"Loading screenshot..."}),i&&t(u.Box,{marginY:1,children:t(u.Text,{color:"red",children:String(i)})}),!r&&!i&&l&&n(u.Box,{flexDirection:"column",children:[t(u.Box,{height:30,children:t(B,{src:l.path,width:80,alt:"Device screenshot"})}),n(u.Box,{marginY:1,flexDirection:"column",children:[t(u.Text,{bold:!0,color:"white",children:"Screenshot Details"}),n(u.Box,{marginY:1,children:[t(u.Text,{color:"green",children:"Screenshot saved to: "}),t(u.Text,{color:"cyan",children:String(l.path||"")})]}),c&&n(u.Text,{color:"gray",children:["Size: ",String(a.originalWidth),"x",String(a.originalHeight)]}),d&&n(u.Text,{color:"gray",children:["File: ",(Number(a.originalFileSize)/1024).toFixed(1)," KB"]}),l.file?.updatedAt&&n(u.Text,{color:"gray",children:["Updated: ",new Date(l.file.updatedAt).toLocaleString()]})]})]}),!r&&!i&&!l&&t(u.Box,{marginY:1,children:t(u.Text,{color:"yellow",children:"No screenshot available. Try taking a new one."})}),t(u.Box,{marginTop:1,children:t(S.Ay,{items:[{label:"Take New Screenshot",value:"take"},{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],onSelect:o})})]})},O=({apps:e,loading:l,onSelect:r})=>{if(l)return t(D,{text:"Loading applications..."});if(!e?.length)return t(u.Text,{color:"yellow",children:"No applications found"});var i=[...e.map(e=>({label:`${e.has_unreleased_changes?"●":"○"} ${e.name}`,value:e._id,app:e})),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return n(u.Box,{flexDirection:"column",children:[n(u.Text,{bold:!0,marginBottom:1,children:["Applications (",e.length,")"]}),t(S.Ay,{items:i,onSelect:r})]})},M=({app:e,loading:l,error:r,onSelect:i})=>{if(l)return t(D,{text:"Loading application..."});if(r)return n(u.Box,{flexDirection:"column",children:[n(u.Text,{color:"red",children:["Error: ",r]}),t(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:i})]});if(!e)return t(u.Text,{color:"red",children:"Application not found"});var o=[{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"}],a=e.devices?.length||0,c=e.devices?.filter(e=>"online"===e.status)?.length||0;return n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,color:"cyan",children:e.name}),e.description&&t(u.Text,{color:"gray",children:e.description}),n(u.Box,{marginY:1,flexDirection:"column",children:[n(u.Text,{color:"gray",children:["ID: ",e._id]}),e.tags?.length>0&&n(u.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Version"}),n(u.Text,{color:"gray",children:[" ","Current: ",e.current_version?`v${e.current_version}`:"N/A"]}),n(u.Text,{color:e.has_unreleased_changes?"yellow":"gray",children:[" ","Changes:"," ",e.has_unreleased_changes?"● Unreleased changes":"○ No pending changes"]}),e.current_version_details&&n(u.Text,{color:"gray",children:[" ","Released: v",e.current_version_details.version||"N/A"]})]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Devices"}),n(u.Text,{color:"gray",children:[" ","Total: ",a,a>0&&` (${c} online)`]})]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Features"}),n(u.Text,{color:"gray",children:[" ","Short Edit: ",e.short_edit?.enabled?"✓ Enabled":"✗ Disabled"]}),n(u.Text,{color:"gray",children:[" ","Canvas Control: ",e.canvas_control?.enabled?"✓ Enabled":"✗ Disabled"]}),n(u.Text,{color:"gray",children:[" ","Device Control: ",e.device_control?.enabled?"✓ Enabled":"✗ Disabled"]}),n(u.Text,{color:e.lock?.enabled?"yellow":"gray",children:[" ","Lock: ",e.lock?.enabled?"\uD83D\uDD12 Locked":"\uD83D\uDD13 Unlocked"]})]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Timestamps"}),e.create_datetime&&n(u.Text,{color:"gray",children:[" Created: ",new Date(e.create_datetime).toLocaleString()]}),e.last_modify_datetime&&n(u.Text,{color:"gray",children:[" ","Modified: ",new Date(e.last_modify_datetime).toLocaleString()]})]})]}),t(S.Ay,{items:o,onSelect:i})]})},P=({modules:e,loading:l,onSelect:r})=>{if(l)return t(D,{text:"Loading modules..."});var i=[...(e||[]).map(e=>({label:`${e.current_version?"●":"○"} ${e.name}`,value:e._id,module:e})),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return n(u.Box,{flexDirection:"column",children:[n(u.Text,{bold:!0,marginBottom:1,children:["Modules (",e?.length||0,")"]}),!e?.length&&t(u.Text,{color:"yellow",children:"No modules found"}),t(S.Ay,{items:i,onSelect:r})]})},R=({module:e,loading:l,error:r,onSelect:i})=>{if(l)return t(D,{text:"Loading module..."});if(r)return n(u.Box,{flexDirection:"column",children:[n(u.Text,{color:"red",children:["Error: ",r]}),t(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:i})]});if(!e)return t(u.Text,{color:"red",children:"Module not found"});var o=[{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 n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,color:"cyan",children:e.name}),e.description&&t(u.Text,{color:"gray",children:e.description}),n(u.Box,{marginY:1,flexDirection:"column",children:[n(u.Text,{color:"gray",children:["ID: ",e._id]}),e.tags?.length>0&&n(u.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Version"}),n(u.Text,{color:"gray",children:[" ","Current: ",e.current_version?`v${e.current_version}`:"N/A"]}),n(u.Text,{color:e.has_unreleased_changes?"yellow":"gray",children:[" ","Changes:"," ",e.has_unreleased_changes?"● Unreleased changes":"○ No pending changes"]})]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Usage"}),n(u.Text,{color:"gray",children:[" ","Used in: ",e.use_count?.total_count||0," application(s)"]})]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Settings"}),n(u.Text,{color:"gray",children:[" ","Public: ",e.is_public?"✓ Yes":"✗ No"]}),n(u.Text,{color:"gray",children:[" ","Modifiable: ",e.is_allow_modify?"✓ Yes":"✗ No"]}),n(u.Text,{color:"gray",children:[" ","Short Edit: ",e.short_edit?.enabled?"✓ Enabled":"✗ Disabled"]})]}),e.expose_properties?.length>0&&n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Exposed Properties"}),n(u.Text,{color:"gray",children:[" ",e.expose_properties.length," properties exposed"]})]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Timestamps"}),e.create_datetime&&n(u.Text,{color:"gray",children:[" Created: ",new Date(e.create_datetime).toLocaleString()]}),e.last_modify_datetime&&n(u.Text,{color:"gray",children:[" ","Modified: ",new Date(e.last_modify_datetime).toLocaleString()]})]})]}),t(S.Ay,{items:o,onSelect:i})]})},N=({groups:e,loading:l,onSelect:r,countdown:i,lastRefreshTime:o})=>{if(l)return t(D,{text:"Loading device groups..."});var a=[...(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 n(u.Box,{flexDirection:"column",children:[n(u.Box,{marginBottom:1,children:[n(u.Text,{bold:!0,children:["Device Groups (",e?.length||0,")"]}),t(u.Text,{color:"gray",children:" - "}),t(_,{countdown:i,lastRefreshTime:o})]}),!e?.length&&t(u.Text,{color:"yellow",children:"No device groups found"}),t(S.Ay,{items:a,onSelect:r})]})},U=({loading:e,groupDevices:l})=>e?t(D,{text:"Loading devices..."}):l?.length?n(r,{children:[l.slice(0,10).map(e=>n(u.Box,{children:[t(u.Text,{color:"gray",children:" "}),t(E,{lastAliveTime:e.entry_detail?.watch_dog_timer?.last_alive_time}),n(u.Text,{color:"gray",children:[" ",e.name||e.device_name]}),e.device_target_name&&n(u.Text,{color:"gray",dimColor:!0,children:[" ","(",e.device_target_name,")"]})]},e._id)),l.length>10&&n(u.Text,{color:"gray",dimColor:!0,children:[" ","... and ",l.length-10," more"]})]}):t(u.Text,{color:"gray",children:" No devices in this group"}),G=({group:e,groupDevices:l,loading:r,error:i,onSelect:o,countdown:a,lastRefreshTime:c})=>r&&!e?t(D,{text:"Loading device group..."}):i?n(u.Box,{flexDirection:"column",children:[n(u.Text,{color:"red",children:["Error: ",i]}),t(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:o})]}):e?n(u.Box,{flexDirection:"column",children:[n(u.Box,{children:[t(u.Text,{bold:!0,color:"cyan",children:e.name}),t(u.Text,{color:"gray",children:" - "}),t(_,{countdown:a,lastRefreshTime:c})]}),e.description&&t(u.Text,{color:"gray",children:e.description}),n(u.Box,{marginY:1,flexDirection:"column",children:[n(u.Text,{color:"gray",children:["ID: ",e._id]}),e.tags?.length>0&&n(u.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[n(u.Text,{bold:!0,color:"white",children:["Devices (",e.devices?.length||0,")"]}),t(U,{loading:r,groupDevices:l})]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Timestamps"}),e.create_datetime&&n(u.Text,{color:"gray",children:[" Created: ",new Date(e.create_datetime).toLocaleString()]}),e.last_modify_datetime&&n(u.Text,{color:"gray",children:[" ","Modified: ",new Date(e.last_modify_datetime).toLocaleString()]})]})]}),t(S.Ay,{items:[{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],onSelect:o})]}):t(u.Text,{color:"red",children:"Device group not found"}),$=({boxes:e,loading:l,onSelect:r})=>{if(l)return t(D,{text:"Loading media boxes..."});if(!e?.length)return t(u.Text,{color:"yellow",children:"No media boxes found"});var i=[...e.map(e=>({label:`📦 ${e.name||"Unnamed"}`,value:e.id,box:e})),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return n(u.Box,{flexDirection:"column",children:[n(u.Text,{bold:!0,marginBottom:1,children:["Media Boxes (",e.length,")"]}),t(S.Ay,{items:i,onSelect:r})]})},V=({box:e,loading:l,error:r,onSelect:i})=>l&&!e?t(D,{text:"Loading media box..."}):r?n(u.Box,{flexDirection:"column",children:[n(u.Text,{color:"red",children:["Error: ",r]}),t(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:i})]}):e?n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,color:"cyan",children:e.name||"Unnamed"}),e.description&&t(u.Text,{color:"gray",children:e.description}),n(u.Box,{marginY:1,flexDirection:"column",children:[n(u.Text,{color:"gray",children:["ID: ",e.id]}),e.tags?.length>0&&n(u.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),null!=e.size&&n(u.Text,{color:"gray",children:["Size: ",e.size]}),e.passcodes?.length>0&&n(u.Box,{flexDirection:"column",marginTop:1,children:[n(u.Text,{bold:!0,color:"white",children:["Passcodes (",e.passcodes.length,")"]}),e.passcodes.slice(0,5).map(e=>n(u.Text,{color:"gray",children:[" ",e.name||"Passcode",": ",e.code]},e.id)),e.passcodes.length>5&&n(u.Text,{color:"gray",dimColor:!0,children:[" ","... and ",e.passcodes.length-5," more"]})]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Timestamps"}),e.createdAt&&n(u.Text,{color:"gray",children:[" Created: ",new Date(e.createdAt).toLocaleString()]}),e.updatedAt&&n(u.Text,{color:"gray",children:[" Modified: ",new Date(e.updatedAt).toLocaleString()]})]})]}),t(S.Ay,{items:[{label:"List Files",value:"files"},{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],onSelect:i})]}):t(u.Text,{color:"red",children:"Media box not found"}),F=({files:e,loading:l,onSelect:r,box:i})=>{if(l)return t(D,{text:"Loading media files..."});if(!e?.length)return t(u.Text,{color:"yellow",children:"No media files found"});var o=[...e.map(e=>{var l;return{label:`${"Image"===(l=e.fileType)?"\uD83D\uDDBC":"Video"===l?"\uD83C\uDF9E":"Audio"===l?"\uD83C\uDFB5":"\uD83D\uDCC4"} ${e.name||"Unnamed"}`,value:e.id,file:e}}),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return n(u.Box,{flexDirection:"column",children:[n(u.Text,{bold:!0,marginBottom:1,children:["Media Files (",e.length,")",i?.name?` - ${i.name}`:""]}),t(S.Ay,{items:o,onSelect:r})]})},j=({file:e,loading:l,error:r,onSelect:i})=>{if(l&&!e)return t(D,{text:"Loading media file..."});if(r)return n(u.Box,{flexDirection:"column",children:[n(u.Text,{color:"red",children:["Error: ",r]}),t(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:i})]});if(!e)return t(u.Text,{color:"red",children:"Media file not found"});var o=e.meta,a=(0,g.Gu)(e),c=(0,g.Gu)(e,{preferThumbnail:!0}),d=!!(c&&c!==a);return n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,color:"cyan",children:e.name||"Unnamed"}),e.description&&t(u.Text,{color:"gray",children:e.description}),n(u.Box,{marginY:1,flexDirection:"column",children:[n(u.Text,{color:"gray",children:["ID: ",e.id]}),n(u.Text,{color:"gray",children:["Box ID: ",e.boxId]}),n(u.Text,{color:"gray",children:["Type: ",e.fileType]}),e.userTags?.length>0&&n(u.Text,{color:"gray",children:["Tags: ",e.userTags.join(", ")]}),o?.originalWidth!=null&&o?.originalHeight!=null&&n(u.Text,{color:"gray",children:["Size: ",o.originalWidth,"x",o.originalHeight]}),o?.originalFileSize!=null&&n(u.Text,{color:"gray",children:["File: ",(Number(o.originalFileSize)/1024).toFixed(1)," KB"]}),a&&n(u.Text,{color:"gray",children:["Original URL: ",a]}),d&&n(u.Text,{color:"gray",children:["Thumbnail URL: ",c]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Timestamps"}),e.createdAt&&n(u.Text,{color:"gray",children:[" Created: ",new Date(e.createdAt).toLocaleString()]}),e.updatedAt&&n(u.Text,{color:"gray",children:[" Modified: ",new Date(e.updatedAt).toLocaleString()]})]})]}),t(S.Ay,{items:[{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],onSelect:i})]})},H=i(92642),Y=(e,l)=>{if(!e)return"";var r="string"==typeof e?e:JSON.stringify(e);return r.length>l?r.slice(0,l-1)+"…":r},z=({onBack:e})=>{var l=s((0,d.useState)([]),2),r=l[0],i=l[1],o=s((0,d.useState)(!0),2),a=o[0],h=o[1],g=s((0,d.useState)(null),2),m=g[0],T=g[1];return(0,d.useEffect)(()=>{var e,l=(0,x.getCurrentProfile)(),r=(0,x.getToken)(l),t=(0,x.getActivityLogBaseUrl)();if(!r){T("Not logged in. Run `bricks auth login` first."),h(!1);return}if(!t){T("Activity log URL not configured."),h(!1);return}var n=(0,H.W)(t,r),o=new Date(Date.now()-36e5).toISOString(),a=new Date().toISOString(),d=new AbortController;return(e=c(function*(){try{var e=yield n.collectEvents({start_time:o,end_time:a},{limit:50,signal:d.signal});i(e)}catch(e){"AbortError"!==e.name&&T(e.message)}h(!1)}),function(){return e.apply(this,arguments)})(),()=>d.abort()},[]),n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,marginBottom:1,children:"Activity Log (last 1h)"}),a&&t(D,{text:"Fetching events..."}),m&&n(u.Text,{color:"red",children:["Error: ",m]}),!a&&!m&&0===r.length&&t(u.Text,{color:"yellow",children:"No events found in the last hour"}),!a&&r.length>0&&n(u.Box,{flexDirection:"column",marginBottom:1,children:[n(u.Text,{color:"gray",children:["Timestamp".padEnd(22)," ","Type".padEnd(12)," ","Device".padEnd(14)," ","Event Name".padEnd(24)," Sender"]}),r.map((e,l)=>n(u.Text,{children:[new Date(e.timestamp).toISOString().replace("T"," ").replace(/\.\d+Z$/,"Z").padEnd(22)," ",Y(e.event_type||"",12).padEnd(12)," ",Y(e.device_id||"",14).padEnd(14)," ",Y(e.event_name||"",24).padEnd(24)," ",Y(e.sender||"",16)]},l)),r.length>=50&&n(u.Text,{color:"yellow",children:["Showing first ",50," events"]})]}),t(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:l=>"back"===l.value&&e()})]})},X=i(29253),J=i(44618),W=["B","C","G","D"],q=({instanceType:e,instance:l,client:r,onDone:i,onCancel:o})=>{var a,h=(0,u.useApp)().exit,x=s((0,d.useState)("select_ref"),2),g=x[0],m=x[1],T=s((0,d.useState)(""),2),p=T[0],f=T[1],v=s((0,d.useState)("search"),2),_=v[0],y=v[1],b=s((0,d.useState)(null),2),E=b[0],I=b[1],A=s((0,d.useState)(null),2),B=A[0],C=A[1],L=s((0,d.useState)(""),2),k=L[0],w=L[1],O=s((0,d.useState)(""),2),M=O[0],P=O[1],R=s((0,d.useState)(null),2),N=R[0],U=R[1],G=l?.short_edit?.ref_map||{},$=Object.entries(G).filter(([,e])=>e&&!e.hide),V=(0,J.V)(G,{keyword:p,types:W}),F=V.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}))]),j=[...p?[{label:"↻ Clear Search",value:"__clear_search__"}]:[],{label:"← Back",value:"__back__"}],H=F.length>0?[...F,...j]:j,Y=H.findIndex(e=>!e.isHeader&&!e.value?.startsWith("__"));(0,u.useInput)((e,l)=>{l.tab&&"select_ref"===g?y(e=>"search"===e?"list":"search"):(l.escape&&("select_ref"===g&&o(),"input_path"===g&&m("select_ref"),"input_content"===g&&m("input_path"),"confirm"===g&&m("input_content"),"done"===g&&o()),"q"===e&&"input_path"!==g&&"input_content"!==g&&("select_ref"!==g||"search"!==_)&&h())},{isActive:!0});var z=(a=c(function*(){if(r&&l?._id&&E){m("submitting"),U(null);try{var t={shortId:E,path:k.trim(),content:(e=>{var l=e.trim();if(""===l)return null;try{return JSON.parse(l)}catch{return l}})(M),forwardDataLink:!0};B?.inner_ref?.pid&&(t.innerRefParentShortId=B.inner_ref.pid),"application"===e?yield r.shortEditApplication({id:l._id,list:[t]}):yield r.shortEditModule({id:l._id,list:[t]}),yield i(),m("done")}catch(e){U(e.message),m("confirm")}}}),function(){return a.apply(this,arguments)});return l?.short_edit?.enabled?0===$.length?n(u.Box,{flexDirection:"column",children:[t(u.Text,{color:"yellow",children:"No Short Edit references found."}),t(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:o})]}):"select_ref"===g?n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,children:"Short Edit References"}),t(u.Text,{color:"gray",dimColor:!0,children:"Showing: Brick, Canvas, Generator, Data"}),n(u.Box,{marginTop:1,flexDirection:"column",children:[t(u.Text,{color:"gray",children:"Search (title or shortId)"}),t(X.A,{value:p,placeholder:"type to filter, Enter to focus list",onChange:e=>f(e),onSubmit:()=>y("list"),focus:"search"===_}),t(u.Text,{color:"gray",dimColor:!0,children:"Press Tab to switch focus"})]}),n(u.Box,{marginTop:1,children:[0===V.length&&t(u.Text,{color:"yellow",children:"No references match your search."}),t(S.Ay,{items:H,isFocused:"list"===_,initialIndex:Y>-1?Y:0,indicatorComponent:()=>null,itemComponent:({label:e,isSelected:l,isHeader:r})=>r?t(u.Box,{marginTop:1,children:t(u.Text,{bold:!0,color:"white",children:e})}):n(u.Text,{color:l?"blue":void 0,children:[l?"❯":" "," ",e]}),onSelect:e=>{if("__back__"===e.value)return void o();if("__clear_search__"===e.value){f(""),y("search");return}e.isHeader||(I(e.value),C(e.ref),m("input_path"))}})]})]}):"input_path"===g?n(u.Box,{flexDirection:"column",children:[n(u.Text,{children:["Reference:"," ",n(u.Text,{color:"cyan",children:[B?.title||E," (",E,")"]})]}),t(u.Text,{marginTop:1,children:"Enter property path (e.g. title, property.backgroundColor)"}),N&&n(u.Text,{color:"red",children:["Error: ",N]}),t(X.A,{value:k,placeholder:"path",onChange:e=>{w(e),N&&U(null)},onSubmit:e=>{var l=e.trim();l?(w(l),m("input_content")):U("Path is required")},focus:!0})]}):"input_content"===g?n(u.Box,{flexDirection:"column",children:[n(u.Text,{children:["Path: ",t(u.Text,{color:"cyan",children:k})]}),t(u.Text,{marginTop:1,children:"Enter new content (JSON or plain text). Empty to clear."}),N&&n(u.Text,{color:"red",children:["Error: ",N]}),t(X.A,{value:M,placeholder:"content",onChange:e=>{P(e),N&&U(null)},onSubmit:()=>m("confirm"),focus:!0})]}):"submitting"===g?t(D,{text:"Applying short edit..."}):"done"===g?n(u.Box,{flexDirection:"column",children:[t(u.Text,{color:"green",children:"Short edit applied successfully."}),t(S.Ay,{items:[{label:"Edit another property",value:"again"},{label:"← Back",value:"back"}],onSelect:e=>{"again"===e.value?(m("select_ref"),I(null),C(null),w(""),P(""),U(null)):o()}})]}):n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,marginBottom:1,children:"Confirm Short Edit"}),n(u.Text,{children:["Reference:"," ",n(u.Text,{color:"cyan",children:[B?.title||E," (",E,")"]})]}),n(u.Text,{children:["Path: ",t(u.Text,{color:"cyan",children:k})]}),n(u.Text,{children:["Content: ",t(u.Text,{color:"cyan",children:M||"<empty>"})]}),N&&n(u.Text,{color:"red",children:["Error: ",N]}),t(S.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&&z(),"edit_path"===e.value&&m("input_path"),"edit_content"===e.value&&m("input_content"),"back"===e.value&&o()}})]}):n(u.Box,{flexDirection:"column",children:[n(u.Text,{color:"yellow",children:["Short Edit is not enabled for this ",e,"."]}),t(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:o})]})},K=i(16928),Z=i(79896),Q=i(35317),ee=i(10750),el="options",er="output_dir",et="confirm",en="generating",ei="post_install",eo="done",ea=e=>{try{return(0,Q.execSync)(`which ${e}`,{stdio:"ignore"}),!0}catch{return!1}},ec=(e,l,r)=>new Promise((t,n)=>{var i=[e,...l].join(" "),o=(0,Q.spawn)(i,[],{cwd:r,stdio:"pipe",shell:!0});o.on("close",e=>{0===e?t():n(Error(`Command failed with code ${e}`))}),o.on("error",n)}),ed=(o=c(function*(e,l){try{var r=(yield i.e(456).then(i.bind(i,79491))).format;return(yield r(l,e,{trailingComma:"all",tabWidth:2,semi:!1,singleQuote:!0,printWidth:100})).code}catch{}return e}),function(e,l){return o.apply(this,arguments)}),eu=({type:e,instance:l,client:r,onDone:i,onCancel:o})=>{var a,h=(0,u.useApp)().exit,x=s((0,d.useState)(el),2),g=x[0],m=x[1],T=s((0,d.useState)({setupGitHubActions:!0,setupAgents:!0,setupClaudeCode:!0,setupGeminiCLI:!1,runBunInstall:!0,initGit:!0}),2),p=T[0],v=T[1],_=s((0,d.useState)(process.cwd()),2),y=_[0],b=_[1],D=s((0,d.useState)(""),2),E=D[0],I=D[1],A=s((0,d.useState)(null),2),B=A[0],C=A[1],L=s((0,d.useState)(null),2),k=L[0],w=L[1],O=ee(l?.name||"bricks-ctor"),M=K.resolve(y,O),P=(0,d.useCallback)(e=>{"back"===e.value?o():"continue"===e.value?m(er):v(l=>({...l,[e.value]:!l[e.value]}))},[o]),R=(0,d.useCallback)(()=>{Z.existsSync(M)?C(`Directory already exists: ${M}`):(C(null),m(et))},[M]),N=(0,d.useCallback)((a=c(function*(t){if("back"===t.value)return void m(er);if("cancel"===t.value)return void o();if("confirm"===t.value){m(en);try{I("Fetching project from BRICKS...");var n,i="application"===e,a=i?r.queries.applicationProject:r.queries.moduleProject,d=(yield r.query(a,{id:l._id,buildApplicationOnly:!1,setupGitHubActions:p.setupGitHubActions,setupAgents:p.setupAgents,setupClaudeCode:p.setupClaudeCode,setupGeminiCLI:p.setupGeminiCLI}))[i?"UNSTABLE_applicationProject":"UNSTABLE_moduleProject"];if(!d?.files)throw Error("Failed to fetch project files");I("Creating project directory..."),Z.mkdirSync(M,{recursive:!0}),I(`Writing ${d.files.length} files...`),(yield Promise.all(d.files.map((n=c(function*(e){var l=K.join(M,e.name),r=e.input;return e.formatable&&(r=yield ed(r,l)),{...e,filePath:l,content:r}}),function(e){return n.apply(this,arguments)})))).forEach(e=>{var l=K.dirname(e.filePath);Z.existsSync(l)||Z.mkdirSync(l,{recursive:!0}),Z.writeFileSync(e.filePath,e.content)}),m(ei);var u={path:M,files:d.files.length,bunInstalled:!1,gitInitialized:!1};if(p.runBunInstall&&ea("bun")){I("Installing dependencies (bun install)...");try{yield ec("bun",["install"],M),u.bunInstalled=!0}catch{}}if(p.initGit&&ea("git")){I("Initializing git repository...");try{yield ec("git",["init"],M),yield ec("git",["add","."],M),yield ec("git",["-c 'user.name=BRICKS CLI'","-c 'user.email=cli@bricks.tools'","commit","-m 'chore: initialize commit'"],M),u.gitInitialized=!0}catch{}}w(u),m(eo)}catch(e){C(e.message),m(el)}}}),function(e){return a.apply(this,arguments)}),[r,l,e,p,M,o]),U=(0,d.useCallback)(e=>{"exit"===e.value?h():i()},[h,i]);if(g===el){var G=[{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 n(u.Box,{flexDirection:"column",children:[n(u.Text,{bold:!0,color:"cyan",children:["Initialize BRICKS Project: ",l?.name||"Untitled"]}),t(u.Text,{color:"gray",marginBottom:1,children:"Select options for project generation (press Enter to toggle)"}),B&&n(u.Text,{color:"red",marginBottom:1,children:["Error: ",B]}),t(S.Ay,{items:G,onSelect:P})]})}return g===er?n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,color:"cyan",children:"Output Directory"}),t(u.Text,{color:"gray",marginBottom:1,children:"Enter the parent directory for the project:"}),B&&t(u.Text,{color:"red",marginBottom:1,children:B}),n(u.Box,{children:[t(u.Text,{children:"Directory: "}),t(X.A,{value:y,onChange:b,onSubmit:R})]}),n(u.Text,{color:"gray",marginTop:1,children:["Project will be created at: ",M]})]}):g===et?n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,color:"cyan",children:"Confirm Project Generation"}),n(u.Box,{marginY:1,flexDirection:"column",children:[n(u.Text,{children:["Name: ",t(u.Text,{color:"green",children:l?.name||"Untitled"})]}),n(u.Text,{children:["Type: ",t(u.Text,{color:"yellow",children:e})]}),n(u.Text,{children:["Path: ",t(u.Text,{color:"cyan",children:M})]}),t(u.Text,{color:"gray",marginTop:1,children:"Options:"}),n(u.Text,{color:"gray",children:[" - GitHub Actions: ",p.setupGitHubActions?"Yes":"No"]}),n(u.Text,{color:"gray",children:[" - AGENTS.md: ",p.setupAgents?"Yes":"No"]}),n(u.Text,{color:"gray",children:[" - CLAUDE.md: ",p.setupClaudeCode?"Yes":"No"]}),n(u.Text,{color:"gray",children:[" - GEMINI.md: ",p.setupGeminiCLI?"Yes":"No"]}),n(u.Text,{color:"gray",children:[" - Run bun install: ",p.runBunInstall?"Yes":"No"]}),n(u.Text,{color:"gray",children:[" - Initialize git: ",p.initGit?"Yes":"No"]})]}),t(S.Ay,{items:[{label:"Confirm & Generate",value:"confirm"},{label:"← Change Directory",value:"back"},{label:"Cancel",value:"cancel"}],onSelect:N})]}):g===en||g===ei?n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,color:"cyan",children:"Generating Project..."}),n(u.Box,{marginY:1,children:[t(u.Text,{color:"green",children:t(f.A,{type:"dots"})}),n(u.Text,{children:[" ",E]})]})]}):g===eo&&k?n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,color:"green",children:"Project initialized successfully!"}),n(u.Box,{marginY:1,flexDirection:"column",children:[n(u.Text,{children:["Path: ",t(u.Text,{color:"cyan",children:k.path})]}),n(u.Text,{children:["Files: ",t(u.Text,{color:"green",children:k.files})]}),n(u.Text,{children:["Dependencies:"," ",t(u.Text,{color:k.bunInstalled?"green":"yellow",children:k.bunInstalled?"Installed":"Not installed (run bun install manually)"})]}),n(u.Text,{children:["Git:"," ",t(u.Text,{color:k.gitInitialized?"green":"yellow",children:k.gitInitialized?"Initialized":"Not initialized"})]})]}),t(u.Text,{bold:!0,marginY:1,children:"Next steps:"}),n(u.Text,{color:"gray",children:[" cd ",O]}),!k.bunInstalled&&t(u.Text,{color:"gray",children:" bun install"}),t(u.Text,{color:"gray",children:" bun preview"}),n(u.Text,{color:"gray",marginTop:1,children:["For more information, see ",O,"/README.md"]}),t(u.Box,{marginTop:1,children:t(S.Ay,{items:[{label:"← Back to Detail",value:"back"},{label:"Exit CLI",value:"exit"}],onSelect:U})})]}):null};let es=()=>{var e,l,r,i,o,a,T,p,f=(0,u.useApp)().exit,_=s((0,d.useState)(m.MAIN),2),E=_[0],S=_[1],A=s((0,d.useState)(null),2),B=A[0],U=A[1],H=s((0,d.useState)(null),2),Y=H[0],X=H[1],J=s((0,d.useState)(!0),2),W=J[0],K=J[1],Z=s((0,d.useState)(null),2),Q=Z[0],ee=Z[1],el=s((0,d.useState)([]),2),er=el[0],et=el[1],en=s((0,d.useState)(null),2),ei=en[0],eo=en[1],ea=s((0,d.useState)([]),2),ec=ea[0],ed=ea[1],es=s((0,d.useState)(null),2),eh=es[0],ex=es[1],eg=s((0,d.useState)([]),2),em=eg[0],eT=eg[1],ep=s((0,d.useState)(null),2),ef=ep[0],ev=ep[1],e_=s((0,d.useState)([]),2),ey=e_[0],eb=e_[1],eD=s((0,d.useState)(null),2),eE=eD[0],eS=eD[1],eI=s((0,d.useState)([]),2),eA=eI[0],eB=eI[1],eC=s((0,d.useState)(!1),2),eL=eC[0],ek=eC[1],ew=s((0,d.useState)(null),2),eO=ew[0],eM=ew[1],eP=s((0,d.useState)(null),2),eR=eP[0],eN=eP[1],eU=s((0,d.useState)(null),2),eG=eU[0],e$=eU[1],eV=s((0,d.useState)(null),2),eF=eV[0],ej=eV[1],eH=s((0,d.useState)([]),2),eY=eH[0],ez=eH[1],eX=s((0,d.useState)(null),2),eJ=eX[0],eW=eX[1],eq=s((0,d.useState)([]),2),eK=eq[0],eZ=eq[1],eQ=s((0,d.useState)(null),2),e0=eQ[0],e1=eQ[1],e2=E===m.DEVICES,e4=E===m.DEVICE_DETAIL,e6=E===m.GROUPS,e5=E===m.GROUP_DETAIL;(0,d.useEffect)(()=>{var e=(0,x.getCurrentProfile)(),l=(0,x.getToken)(e);if(!l){ee("Not logged in. Run `bricks auth login` first."),K(!1);return}var r=(0,h.createClient)((0,x.getBaseUrl)(),l);U(r),r.workspace().then(e=>{X(e),K(!1)}).catch(e=>{ee(e.message),K(!1)})},[]),(0,u.useInput)((e,l)=>{"q"===e&&f(),l.escape&&(E===m.DEVICE_CONTROL?(S(m.DEVICE_DETAIL),eM(null)):E===m.DEVICE_SCREENSHOT?(S(m.DEVICE_DETAIL),e$(null),ej(null)):E===m.DEVICE_DETAIL?(S(m.DEVICES),eo(null)):E===m.APP_DETAIL?(S(m.APPS),ex(null)):E===m.MODULE_DETAIL?(S(m.MODULES),ev(null)):E===m.GROUP_DETAIL?(S(m.GROUPS),eS(null),eB([])):E===m.MEDIA_FILE_DETAIL?(S(m.MEDIA_FILES),e1(null)):E===m.MEDIA_FILES?(S(m.MEDIA_BOX_DETAIL),e1(null)):E===m.MEDIA_BOX_DETAIL?(S(m.MEDIA_BOXES),eW(null),eZ([])):E===m.MEDIA_BOXES?S(m.MAIN):E!==m.MAIN&&S(m.MAIN))},{isActive:E!==m.APP_SHORT_EDIT&&E!==m.MODULE_SHORT_EDIT&&E!==m.APP_PROJECT_INIT&&E!==m.MODULE_PROJECT_INIT});var e9=(0,d.useCallback)(c(function*(){if(B){K(!0);try{var e=yield B.devices({});et(e||[])}catch(e){ee(e.message)}K(!1)}}),[B]),e8=(0,d.useCallback)((e=c(function*(e){if(B){K(!0),eN(null);try{var l=yield B.device({id:e});eo(l)}catch(e){eN(e.message)}K(!1)}}),function(l){return e.apply(this,arguments)}),[B]),e3=(0,d.useCallback)(c(function*(){if(B){K(!0);try{var e=yield B.applications({});ed(e||[])}catch(e){ee(e.message)}K(!1)}}),[B]),e7=(0,d.useCallback)((l=c(function*(e){if(B){K(!0),eN(null);try{var l=yield B.application({id:e});ex(l)}catch(e){eN(e.message)}K(!1)}}),function(e){return l.apply(this,arguments)}),[B]),le=(0,d.useCallback)(c(function*(){if(B){K(!0);try{var e=yield B.modules({});eT(e||[])}catch(e){ee(e.message)}K(!1)}}),[B]),ll=(0,d.useCallback)((r=c(function*(e){if(B){K(!0),eN(null);try{var l=yield B.module({id:e});ev(l)}catch(e){eN(e.message)}K(!1)}}),function(e){return r.apply(this,arguments)}),[B]),lr=(0,d.useCallback)(c(function*(){if(B){K(!0);try{var e=yield B.deviceGroups({});eb(e||[])}catch(e){ee(e.message)}K(!1)}}),[B]),lt=(0,d.useCallback)((i=c(function*(e){if(B){K(!0),eN(null);try{var l=yield Promise.all([B.deviceGroup({id:e}),B.devicesByGroup({id:e})]),r=s(l,2),t=r[0],n=r[1];eS(t),eB(n||[])}catch(e){eN(e.message)}K(!1)}}),function(e){return i.apply(this,arguments)}),[B]),ln=(0,d.useCallback)(c(function*(){if(B){K(!0);try{var e=yield B.mediaBoxes();ez(e||[])}catch(e){ee(e.message)}K(!1)}}),[B]),li=(0,d.useCallback)((o=c(function*(e){if(B){K(!0),eN(null);try{var l=yield B.mediaBox({id:e});eW(l)}catch(e){eN(e.message)}K(!1)}}),function(e){return o.apply(this,arguments)}),[B]),lo=(0,d.useCallback)((a=c(function*(e){if(B){K(!0);try{var l=yield B.mediaFiles({boxId:e});eZ(l||[])}catch(e){ee(e.message)}K(!1)}}),function(e){return a.apply(this,arguments)}),[B]),la=(0,d.useCallback)((T=c(function*(e){if(B){K(!0),eN(null);try{var l=yield B.mediaFile({id:e});e1(l)}catch(e){eN(e.message)}K(!1)}}),function(e){return T.apply(this,arguments)}),[B]),lc=(0,d.useCallback)((p=c(function*(e){if(B&&ei){ek(!0),eM(null);try{yield B.controlDevice({id:ei._id,type:e}),eM({success:!0,message:`Command sent: ${e}`})}catch(e){eM({success:!1,message:e.message})}ek(!1)}}),function(e){return p.apply(this,arguments)}),[B,ei]),ld=(0,d.useCallback)(c(function*(e=!1){if(B&&ei&&Y){K(!0),ej(null),e$(null);try{e&&(yield B.controlDevice({id:ei._id,type:"take-screenshot"}),yield new Promise(e=>setTimeout(e,3e3)));var l=yield(0,g.he)(B,Y,ei._id,null,{preferThumbnail:!0});l.error?ej(l.error):e$(l)}catch(e){ej(e.message)}K(!1)}}),[B,ei,Y]),lu=v((0,d.useCallback)(()=>{B&&e9()},[B,e9]),e2),ls=v((0,d.useCallback)(()=>{B&&ei&&e8(ei._id)},[B,ei,e8]),e4),lh=v((0,d.useCallback)(()=>{B&&lr()},[B,lr]),e6),lx=v((0,d.useCallback)(()=>{B&&eE&<(eE._id)},[B,eE,lt]),e5);return W&&!Y?n(u.Box,{flexDirection:"column",children:[t(y,{workspace:Y,view:E}),t(D,{text:"Connecting to workspace..."})]}):Q&&!Y?n(u.Box,{flexDirection:"column",children:[t(y,{workspace:Y,view:E}),n(u.Text,{color:"red",children:["Error: ",Q]}),t(b,{})]}):n(u.Box,{flexDirection:"column",children:[t(y,{workspace:Y,view:E}),E===m.MAIN&&t(I,{onSelect:e=>{"exit"===e.value?f():(S(e.value),e.value===m.DEVICES?e9():e.value===m.APPS?e3():e.value===m.MODULES?le():e.value===m.GROUPS?lr():e.value===m.MEDIA_BOXES&&ln())},mediaEnabled:(0,g.wR)(Y),activityLogEnabled:!!(0,x.getActivityLogBaseUrl)()}),E===m.DEVICES&&t(C,{devices:er,loading:W,onSelect:e=>{if("back"===e.value)return void S(m.MAIN);if("refresh"===e.value){e9(),lu.resetCountdown();return}eo(null),K(!0),S(m.DEVICE_DETAIL),e8(e.value)},countdown:lu.countdown,lastRefreshTime:lu.lastRefreshTime}),E===m.DEVICE_DETAIL&&t(L,{device:ei,loading:W,error:eR,onSelect:e=>{if("back"===e.value){S(m.DEVICES),eo(null);return}if("refresh"===e.value){e8(ei._id),ls.resetCountdown();return}"control"===e.value&&(S(m.DEVICE_CONTROL),eM(null)),"screenshot"===e.value&&(S(m.DEVICE_SCREENSHOT),e$(null),ej(null),ld(!1))},mediaEnabled:(0,g.wR)(Y),countdown:ls.countdown,lastRefreshTime:ls.lastRefreshTime}),E===m.DEVICE_CONTROL&&t(k,{device:ei,onSelect:e=>{if("back"===e.value){S(m.DEVICE_DETAIL),eM(null);return}lc(e.value)},controlling:eL,controlResult:eO}),E===m.DEVICE_SCREENSHOT&&t(w,{device:ei,screenshot:eG,loading:W,error:eF,onSelect:e=>{if("back"===e.value){S(m.DEVICE_DETAIL),e$(null),ej(null);return}"refresh"===e.value?ld(!1):"take"===e.value&&ld(!0)}}),E===m.APPS&&t(O,{apps:ec,loading:W,onSelect:e=>{"back"===e.value?S(m.MAIN):"refresh"===e.value?e3():(ex(null),K(!0),S(m.APP_DETAIL),e7(e.value))}}),E===m.APP_DETAIL&&t(M,{app:eh,loading:W,error:eR,onSelect:e=>{if("back"===e.value){S(m.APPS),ex(null);return}"refresh"===e.value?e7(eh._id):("short_edit"===e.value&&(S(m.APP_SHORT_EDIT),eN(null)),"project_init"===e.value&&(S(m.APP_PROJECT_INIT),eN(null)))}}),E===m.APP_SHORT_EDIT&&t(q,{instanceType:"application",instance:eh,client:B,onDone:c(function*(){return e7(eh._id)}),onCancel:()=>S(m.APP_DETAIL)}),E===m.APP_PROJECT_INIT&&t(eu,{type:"application",instance:eh,client:B,onDone:()=>S(m.APP_DETAIL),onCancel:()=>S(m.APP_DETAIL)}),E===m.MODULES&&t(P,{modules:em,loading:W,onSelect:e=>{"back"===e.value?S(m.MAIN):"refresh"===e.value?le():(ev(null),K(!0),S(m.MODULE_DETAIL),ll(e.value))}}),E===m.MODULE_DETAIL&&t(R,{module:ef,loading:W,error:eR,onSelect:e=>{if("back"===e.value){S(m.MODULES),ev(null);return}"refresh"===e.value?ll(ef._id):("short_edit"===e.value&&(S(m.MODULE_SHORT_EDIT),eN(null)),"project_init"===e.value&&(S(m.MODULE_PROJECT_INIT),eN(null)))}}),E===m.MODULE_SHORT_EDIT&&t(q,{instanceType:"module",instance:ef,client:B,onDone:c(function*(){return ll(ef._id)}),onCancel:()=>S(m.MODULE_DETAIL)}),E===m.MODULE_PROJECT_INIT&&t(eu,{type:"module",instance:ef,client:B,onDone:()=>S(m.MODULE_DETAIL),onCancel:()=>S(m.MODULE_DETAIL)}),E===m.GROUPS&&t(N,{groups:ey,loading:W,onSelect:e=>{if("back"===e.value)return void S(m.MAIN);if("refresh"===e.value){lr(),lh.resetCountdown();return}eS(null),eB([]),K(!0),S(m.GROUP_DETAIL),lt(e.value)},countdown:lh.countdown,lastRefreshTime:lh.lastRefreshTime}),E===m.GROUP_DETAIL&&t(G,{group:eE,groupDevices:eA,loading:W,error:eR,onSelect:e=>{if("back"===e.value){S(m.GROUPS),eS(null),eB([]);return}"refresh"===e.value&&(lt(eE._id),lx.resetCountdown())},countdown:lx.countdown,lastRefreshTime:lx.lastRefreshTime}),E===m.ACTIVITY_LOG&&t(z,{onBack:()=>S(m.MAIN)}),E===m.MEDIA_BOXES&&t($,{boxes:eY,loading:W,onSelect:e=>{"back"===e.value?S(m.MAIN):"refresh"===e.value?ln():(eW(null),eZ([]),K(!0),S(m.MEDIA_BOX_DETAIL),li(e.value))}}),E===m.MEDIA_BOX_DETAIL&&t(V,{box:eJ,loading:W,error:eR,onSelect:e=>{if("back"===e.value){S(m.MEDIA_BOXES),eW(null),eZ([]);return}"refresh"===e.value?li(eJ.id):"files"===e.value&&(eZ([]),e1(null),S(m.MEDIA_FILES),lo(eJ.id))}}),E===m.MEDIA_FILES&&t(F,{files:eK,box:eJ,loading:W,onSelect:e=>{if("back"===e.value){S(m.MEDIA_BOX_DETAIL),e1(null);return}"refresh"===e.value?lo(eJ.id):(e1(null),K(!0),S(m.MEDIA_FILE_DETAIL),la(e.value))}}),E===m.MEDIA_FILE_DETAIL&&t(j,{file:e0,loading:W,error:eR,onSelect:e=>{if("back"===e.value){S(m.MEDIA_FILES),e1(null);return}"refresh"===e.value&&la(e0.id)}}),t(b,{})]})};var eh="1"===process.env.BRICKS_CLI_DISTRIBUTION,ex=(a=c(function*(){if(eh)return void(0,u.render)(t(es,{}));var e=(yield i.e(166).then(i.bind(i,29557))).TerminalInfoProvider;(0,u.render)(t(e,{children:t(es,{})}))}),function(){return a.apply(this,arguments)})}};
|
|
1
|
+
import*as e from"ink";import*as l from"react";import{Fragment as r,jsx as t,jsxs as n}from"react/jsx-runtime";export const __rspack_esm_id=940;export const __rspack_esm_ids=[940];export const __webpack_modules__={8498(l){l.exports=e},51649(e){e.exports=l},92319(e,l,i){i.r(l),i.d(l,{AppList:()=>w,CONTROL_ACTIONS:()=>x,MainMenu:()=>S,Header:()=>y,ModuleDetail:()=>M,ONLINE_THRESHOLD_MS:()=>p,ShortEditEditor:()=>J,MediaFileList:()=>$,App:()=>ea,DeviceDetail:()=>C,VIEWS:()=>m,runInteractiveMode:()=>ed,DeviceList:()=>B,MediaBoxList:()=>G,Loading:()=>b,DeviceControl:()=>k,ProjectInitView:()=>eo,GroupDetail:()=>U,ModuleList:()=>P,MediaBoxDetail:()=>j,GroupList:()=>R,Footer:()=>_,DeviceStatus:()=>D,AppDetail:()=>O,DeviceScreenshot:()=>L,MediaFileDetail:()=>V});var o,a=i(99436),c=i(51649),d=i(8498),u=i(68832),s=i(85382),h=i(47988),g=i(60450),m={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",ACTIVITY_LOG:"activity_log"},x=[{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"}],p=3e5,f=i(47882),T=(e,l=!0)=>{var r=Math.floor(60),t=u((0,c.useState)(r),2),n=t[0],i=t[1],o=u((0,c.useState)(null),2),a=o[0],d=o[1],s=(0,c.useRef)(e);(0,c.useEffect)(()=>{s.current=e},[e]);var h=(0,c.useCallback)(()=>{i(r),d(Date.now())},[r]);return(0,c.useEffect)(()=>{if(l){var e=setInterval(()=>{i(e=>e<=1?(s.current?.(),d(Date.now()),r):e-1)},1e3);return()=>clearInterval(e)}},[l,r]),(0,c.useEffect)(()=>{l&&(i(r),d(Date.now()))},[l,r]),{countdown:n,lastRefreshTime:a,resetCountdown:h}},v=({countdown:e,lastRefreshTime:l})=>t(d.Box,{children:n(d.Text,{color:"gray",children:["Next refresh in ",n(d.Text,{color:"cyan",children:[e,"s"]}),l&&n(d.Text,{color:"gray",children:[" (last: ",l?new Date(l).toLocaleTimeString():null,")"]})]})}),y=({workspace:e,view:l})=>n(d.Box,{flexDirection:"column",marginBottom:1,children:[n(d.Box,{children:[t(d.Text,{bold:!0,color:"cyan",children:"BRICKS CLI"}),t(d.Text,{color:"gray",children:" - Interactive Mode"})]}),n(d.Box,{children:[t(d.Text,{color:"gray",children:"Workspace: "}),t(d.Text,{color:"green",children:e?.name||"Not connected"}),t(d.Text,{color:"gray",children:" | View: "}),t(d.Text,{color:"yellow",children:l})]}),t(d.Text,{color:"gray",children:"─".repeat(60)})]}),_=()=>n(d.Box,{marginTop:1,flexDirection:"column",children:[t(d.Text,{color:"gray",children:"─".repeat(60)}),n(d.Text,{color:"gray",children:["Press ",t(d.Text,{color:"cyan",children:"q"})," to quit, ",t(d.Text,{color:"cyan",children:"Esc"})," to go back"]})]}),b=({text:e})=>n(d.Box,{children:[t(d.Text,{color:"green",children:t(f.A,{type:"dots"})}),n(d.Text,{children:[" ",e||"Loading..."]})]}),D=({lastAliveTime:e})=>{if(!e)return t(d.Text,{color:"gray",children:"○ Unknown"});var l=Date.now()-new Date(e).getTime();if(l<=p)return t(d.Text,{color:"green",children:"● Online"});var r=Math.floor(l/6e4);if(r<60)return n(d.Text,{color:"yellow",children:["○ Offline (",r,"m ago)"]});var i=Math.floor(r/60);if(i<24)return n(d.Text,{color:"red",children:["○ Offline (",i,"h ago)"]});var o=Math.floor(i/24);return n(d.Text,{color:"red",children:["○ Offline (",o,"d ago)"]})},E=i(48724),S=({onSelect:e,mediaEnabled:l,activityLogEnabled:r})=>{var i=[{label:"Devices",value:m.DEVICES},{label:"Applications",value:m.APPS},{label:"Modules",value:m.MODULES},{label:"Device Groups",value:m.GROUPS},...l?[{label:"Media Flow",value:m.MEDIA_BOXES}]:[],...r?[{label:"Activity Log",value:m.ACTIVITY_LOG}]:[],{label:"Exit",value:"exit"}];return n(d.Box,{flexDirection:"column",children:[t(d.Text,{bold:!0,marginBottom:1,children:"Main Menu"}),t(E.Ay,{items:i,onSelect:e})]})},I="1"===process.env.BRICKS_CLI_DISTRIBUTION,A=e=>{var l=u((0,c.useState)(null),2),r=l[0],n=l[1];return((0,c.useEffect)(()=>{if(!I){var e=!0;return i.e(166).then(i.bind(i,29557)).then(l=>{e&&n(()=>l.default)}).catch(()=>{e&&n(!1)}),()=>{e=!1}}},[]),I||!1===r)?t(d.Text,{color:"gray",children:"Image preview is not available in this CLI build."}):r?t(r,{...e}):t(b,{text:"Preparing image preview..."})},B=({devices:e,loading:l,onSelect:r,countdown:i,lastRefreshTime:o})=>{if(l)return t(b,{text:"Loading devices..."});if(!e?.length)return n(d.Box,{flexDirection:"column",children:[t(d.Text,{color:"yellow",children:"No devices found"}),t(v,{countdown:i,lastRefreshTime:o})]});var a=[...e.map(e=>{var l=(e=>{if(!e)return"○ Unknown";var l=Date.now()-new Date(e).getTime();if(l<=p)return"● Online";var r=Math.floor(l/6e4);if(r<60)return`○ ${r}m ago`;var t=Math.floor(r/60);if(t<24)return`○ ${t}h ago`;var n=Math.floor(t/24);return`○ ${n}d ago`})(e.entry_detail?.watch_dog_timer?.last_alive_time);return{label:`${l} - ${e.name||e.device_name}`,value:e._id,device:e}}),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return n(d.Box,{flexDirection:"column",children:[n(d.Box,{marginBottom:1,children:[n(d.Text,{bold:!0,children:["Devices (",e.length,")"]}),t(d.Text,{color:"gray",children:" - "}),t(v,{countdown:i,lastRefreshTime:o})]}),t(E.Ay,{items:a,onSelect:r})]})},C=({device:e,loading:l,error:r,onSelect:i,mediaEnabled:o,countdown:a,lastRefreshTime:c})=>{if(l)return t(b,{text:"Loading device..."});if(r)return n(d.Box,{flexDirection:"column",children:[n(d.Text,{color:"red",children:["Error: ",r]}),t(E.Ay,{items:[{label:"← Back",value:"back"}],onSelect:i})]});if(!e)return t(d.Text,{color:"red",children:"Device not found"});var u=[{label:"Control Device",value:"control"},...o?[{label:"View Screenshot",value:"screenshot"}]:[],{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],s=e.entry_detail,h=s?.screen,g=s?.update,m=s?.local_sync;return n(d.Box,{flexDirection:"column",children:[n(d.Box,{children:[t(d.Text,{bold:!0,color:"cyan",children:e.name||e.device_name}),t(d.Text,{color:"gray",children:" - "}),t(v,{countdown:a,lastRefreshTime:c})]}),e.description&&t(d.Text,{color:"gray",children:e.description}),n(d.Box,{marginY:1,flexDirection:"column",children:[n(d.Box,{children:[t(d.Text,{color:"gray",children:"Status: "}),t(D,{lastAliveTime:s?.watch_dog_timer?.last_alive_time})]}),n(d.Text,{color:"gray",children:["ID: ",e._id]}),e.tags?.length>0&&n(d.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),s?.application&&n(d.Box,{flexDirection:"column",marginTop:1,children:[t(d.Text,{bold:!0,color:"white",children:"Application"}),n(d.Text,{color:"gray",children:[" Name: ",s.application.name]}),n(d.Text,{color:"gray",children:[" Mode: ",s.operation_mode||"N/A"]})]}),h&&n(d.Box,{flexDirection:"column",marginTop:1,children:[t(d.Text,{bold:!0,color:"white",children:"Screen"}),h.resolution&&n(d.Text,{color:"gray",children:[" ","Resolution: ",h.resolution.width,"x",h.resolution.height,h.resolution.scale&&` @${h.resolution.scale}x`]}),h.orientation&&n(d.Text,{color:"gray",children:[" Orientation: ",h.orientation]}),h.touch&&n(d.Text,{color:"gray",children:[" ","Touch:"," ",h.touch.available?`Yes (${h.touch.touch_point} points)`:"No"]})]}),(s?.memory_usage||s?.disk_usage)&&n(d.Box,{flexDirection:"column",marginTop:1,children:[t(d.Text,{bold:!0,color:"white",children:"System"}),s.memory_usage&&n(d.Text,{color:"gray",children:[" Memory: ",Math.round(100*s.memory_usage),"%"]}),s.disk_usage&&n(d.Text,{color:"gray",children:[" Disk: ",Math.round(100*s.disk_usage),"%"]})]}),n(d.Box,{flexDirection:"column",marginTop:1,children:[t(d.Text,{bold:!0,color:"white",children:"Capabilities"}),n(d.Text,{color:"gray",children:[" ","Sound: ",s?.sound?.available?"✓":"✗"," | ","Camera: ",s?.camera?.available?"✓":"✗"," | ","Audio In: ",s?.audio_in?.available?"✓":"✗"]})]}),m&&n(d.Box,{flexDirection:"column",marginTop:1,children:[t(d.Text,{bold:!0,color:"white",children:"Local Sync"}),n(d.Text,{color:"gray",children:[" ","Role: ",m.is_main?"Main":"Peer",m.peer_count>0&&` | Peers: ${m.peer_count}`,m.mean_latency&&` | Latency: ${m.mean_latency}ms`]})]}),g&&n(d.Box,{flexDirection:"column",marginTop:1,children:[t(d.Text,{bold:!0,color:"white",children:"Update"}),n(d.Text,{color:g.need_update?"yellow":"gray",children:[" ","Status: ",g.need_update?"⚠ Update available":"✓ Up to date"]}),g.current_version&&n(d.Text,{color:"gray",children:[" Version: ",g.current_version]})]})]}),t(E.Ay,{items:u,onSelect:i})]})},k=({device:e,onSelect:l,controlling:r,controlResult:i})=>n(d.Box,{flexDirection:"column",children:[n(d.Text,{bold:!0,color:"cyan",children:["Control: ",e?.name||e?.device_name]}),r&&t(b,{text:"Sending command..."}),i&&t(d.Text,{color:i.success?"green":"red",children:i.message}),t(d.Box,{marginTop:1,children:t(E.Ay,{items:x,onSelect:l})})]}),L=({device:e,screenshot:l,loading:r,error:i,onSelect:o})=>{var a=l?.file?.meta,c=a?.originalWidth!=null&&a?.originalHeight!=null,u=a?.originalFileSize!=null;return n(d.Box,{flexDirection:"column",children:[n(d.Text,{bold:!0,color:"cyan",children:["Screenshot: ",e?.name||e?.device_name||"Unknown"]}),r&&t(b,{text:"Loading screenshot..."}),i&&t(d.Box,{marginY:1,children:t(d.Text,{color:"red",children:String(i)})}),!r&&!i&&l&&n(d.Box,{flexDirection:"column",children:[t(d.Box,{height:30,children:t(A,{src:l.path,width:80,alt:"Device screenshot"})}),n(d.Box,{marginY:1,flexDirection:"column",children:[t(d.Text,{bold:!0,color:"white",children:"Screenshot Details"}),n(d.Box,{marginY:1,children:[t(d.Text,{color:"green",children:"Screenshot saved to: "}),t(d.Text,{color:"cyan",children:String(l.path||"")})]}),c&&n(d.Text,{color:"gray",children:["Size: ",String(a.originalWidth),"x",String(a.originalHeight)]}),u&&n(d.Text,{color:"gray",children:["File: ",(Number(a.originalFileSize)/1024).toFixed(1)," KB"]}),l.file?.updatedAt&&n(d.Text,{color:"gray",children:["Updated: ",new Date(l.file.updatedAt).toLocaleString()]})]})]}),!r&&!i&&!l&&t(d.Box,{marginY:1,children:t(d.Text,{color:"yellow",children:"No screenshot available. Try taking a new one."})}),t(d.Box,{marginTop:1,children:t(E.Ay,{items:[{label:"Take New Screenshot",value:"take"},{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],onSelect:o})})]})},w=({apps:e,loading:l,onSelect:r})=>{if(l)return t(b,{text:"Loading applications..."});if(!e?.length)return t(d.Text,{color:"yellow",children:"No applications found"});var i=[...e.map(e=>({label:`${e.has_unreleased_changes?"●":"○"} ${e.name}`,value:e._id,app:e})),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return n(d.Box,{flexDirection:"column",children:[n(d.Text,{bold:!0,marginBottom:1,children:["Applications (",e.length,")"]}),t(E.Ay,{items:i,onSelect:r})]})},O=({app:e,loading:l,error:r,onSelect:i})=>{if(l)return t(b,{text:"Loading application..."});if(r)return n(d.Box,{flexDirection:"column",children:[n(d.Text,{color:"red",children:["Error: ",r]}),t(E.Ay,{items:[{label:"← Back",value:"back"}],onSelect:i})]});if(!e)return t(d.Text,{color:"red",children:"Application not found"});var o=[{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"}],a=e.devices?.length||0,c=e.devices?.filter(e=>"online"===e.status)?.length||0;return n(d.Box,{flexDirection:"column",children:[t(d.Text,{bold:!0,color:"cyan",children:e.name}),e.description&&t(d.Text,{color:"gray",children:e.description}),n(d.Box,{marginY:1,flexDirection:"column",children:[n(d.Text,{color:"gray",children:["ID: ",e._id]}),e.tags?.length>0&&n(d.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),n(d.Box,{flexDirection:"column",marginTop:1,children:[t(d.Text,{bold:!0,color:"white",children:"Version"}),n(d.Text,{color:"gray",children:[" ","Current: ",e.current_version?`v${e.current_version}`:"N/A"]}),n(d.Text,{color:e.has_unreleased_changes?"yellow":"gray",children:[" ","Changes:"," ",e.has_unreleased_changes?"● Unreleased changes":"○ No pending changes"]}),e.current_version_details&&n(d.Text,{color:"gray",children:[" ","Released: v",e.current_version_details.version||"N/A"]})]}),n(d.Box,{flexDirection:"column",marginTop:1,children:[t(d.Text,{bold:!0,color:"white",children:"Devices"}),n(d.Text,{color:"gray",children:[" ","Total: ",a,a>0&&` (${c} online)`]})]}),n(d.Box,{flexDirection:"column",marginTop:1,children:[t(d.Text,{bold:!0,color:"white",children:"Features"}),n(d.Text,{color:"gray",children:[" ","Short Edit: ",e.short_edit?.enabled?"✓ Enabled":"✗ Disabled"]}),n(d.Text,{color:"gray",children:[" ","Canvas Control: ",e.canvas_control?.enabled?"✓ Enabled":"✗ Disabled"]}),n(d.Text,{color:"gray",children:[" ","Device Control: ",e.device_control?.enabled?"✓ Enabled":"✗ Disabled"]}),n(d.Text,{color:e.lock?.enabled?"yellow":"gray",children:[" ","Lock: ",e.lock?.enabled?"\uD83D\uDD12 Locked":"\uD83D\uDD13 Unlocked"]})]}),n(d.Box,{flexDirection:"column",marginTop:1,children:[t(d.Text,{bold:!0,color:"white",children:"Timestamps"}),e.create_datetime&&n(d.Text,{color:"gray",children:[" Created: ",new Date(e.create_datetime).toLocaleString()]}),e.last_modify_datetime&&n(d.Text,{color:"gray",children:[" ","Modified: ",new Date(e.last_modify_datetime).toLocaleString()]})]})]}),t(E.Ay,{items:o,onSelect:i})]})},P=({modules:e,loading:l,onSelect:r})=>{if(l)return t(b,{text:"Loading modules..."});var i=[...(e||[]).map(e=>({label:`${e.current_version?"●":"○"} ${e.name}`,value:e._id,module:e})),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return n(d.Box,{flexDirection:"column",children:[n(d.Text,{bold:!0,marginBottom:1,children:["Modules (",e?.length||0,")"]}),!e?.length&&t(d.Text,{color:"yellow",children:"No modules found"}),t(E.Ay,{items:i,onSelect:r})]})},M=({module:e,loading:l,error:r,onSelect:i})=>{if(l)return t(b,{text:"Loading module..."});if(r)return n(d.Box,{flexDirection:"column",children:[n(d.Text,{color:"red",children:["Error: ",r]}),t(E.Ay,{items:[{label:"← Back",value:"back"}],onSelect:i})]});if(!e)return t(d.Text,{color:"red",children:"Module not found"});var o=[{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 n(d.Box,{flexDirection:"column",children:[t(d.Text,{bold:!0,color:"cyan",children:e.name}),e.description&&t(d.Text,{color:"gray",children:e.description}),n(d.Box,{marginY:1,flexDirection:"column",children:[n(d.Text,{color:"gray",children:["ID: ",e._id]}),e.tags?.length>0&&n(d.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),n(d.Box,{flexDirection:"column",marginTop:1,children:[t(d.Text,{bold:!0,color:"white",children:"Version"}),n(d.Text,{color:"gray",children:[" ","Current: ",e.current_version?`v${e.current_version}`:"N/A"]}),n(d.Text,{color:e.has_unreleased_changes?"yellow":"gray",children:[" ","Changes:"," ",e.has_unreleased_changes?"● Unreleased changes":"○ No pending changes"]})]}),n(d.Box,{flexDirection:"column",marginTop:1,children:[t(d.Text,{bold:!0,color:"white",children:"Usage"}),n(d.Text,{color:"gray",children:[" ","Used in: ",e.use_count?.total_count||0," application(s)"]})]}),n(d.Box,{flexDirection:"column",marginTop:1,children:[t(d.Text,{bold:!0,color:"white",children:"Settings"}),n(d.Text,{color:"gray",children:[" ","Public: ",e.is_public?"✓ Yes":"✗ No"]}),n(d.Text,{color:"gray",children:[" ","Modifiable: ",e.is_allow_modify?"✓ Yes":"✗ No"]}),n(d.Text,{color:"gray",children:[" ","Short Edit: ",e.short_edit?.enabled?"✓ Enabled":"✗ Disabled"]})]}),e.expose_properties?.length>0&&n(d.Box,{flexDirection:"column",marginTop:1,children:[t(d.Text,{bold:!0,color:"white",children:"Exposed Properties"}),n(d.Text,{color:"gray",children:[" ",e.expose_properties.length," properties exposed"]})]}),n(d.Box,{flexDirection:"column",marginTop:1,children:[t(d.Text,{bold:!0,color:"white",children:"Timestamps"}),e.create_datetime&&n(d.Text,{color:"gray",children:[" Created: ",new Date(e.create_datetime).toLocaleString()]}),e.last_modify_datetime&&n(d.Text,{color:"gray",children:[" ","Modified: ",new Date(e.last_modify_datetime).toLocaleString()]})]})]}),t(E.Ay,{items:o,onSelect:i})]})},R=({groups:e,loading:l,onSelect:r,countdown:i,lastRefreshTime:o})=>{if(l)return t(b,{text:"Loading device groups..."});var a=[...(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 n(d.Box,{flexDirection:"column",children:[n(d.Box,{marginBottom:1,children:[n(d.Text,{bold:!0,children:["Device Groups (",e?.length||0,")"]}),t(d.Text,{color:"gray",children:" - "}),t(v,{countdown:i,lastRefreshTime:o})]}),!e?.length&&t(d.Text,{color:"yellow",children:"No device groups found"}),t(E.Ay,{items:a,onSelect:r})]})},N=({loading:e,groupDevices:l})=>e?t(b,{text:"Loading devices..."}):l?.length?n(r,{children:[l.slice(0,10).map(e=>n(d.Box,{children:[t(d.Text,{color:"gray",children:" "}),t(D,{lastAliveTime:e.entry_detail?.watch_dog_timer?.last_alive_time}),n(d.Text,{color:"gray",children:[" ",e.name||e.device_name]}),e.device_target_name&&n(d.Text,{color:"gray",dimColor:!0,children:[" ","(",e.device_target_name,")"]})]},e._id)),l.length>10&&n(d.Text,{color:"gray",dimColor:!0,children:[" ","... and ",l.length-10," more"]})]}):t(d.Text,{color:"gray",children:" No devices in this group"}),U=({group:e,groupDevices:l,loading:r,error:i,onSelect:o,countdown:a,lastRefreshTime:c})=>r&&!e?t(b,{text:"Loading device group..."}):i?n(d.Box,{flexDirection:"column",children:[n(d.Text,{color:"red",children:["Error: ",i]}),t(E.Ay,{items:[{label:"← Back",value:"back"}],onSelect:o})]}):e?n(d.Box,{flexDirection:"column",children:[n(d.Box,{children:[t(d.Text,{bold:!0,color:"cyan",children:e.name}),t(d.Text,{color:"gray",children:" - "}),t(v,{countdown:a,lastRefreshTime:c})]}),e.description&&t(d.Text,{color:"gray",children:e.description}),n(d.Box,{marginY:1,flexDirection:"column",children:[n(d.Text,{color:"gray",children:["ID: ",e._id]}),e.tags?.length>0&&n(d.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),n(d.Box,{flexDirection:"column",marginTop:1,children:[n(d.Text,{bold:!0,color:"white",children:["Devices (",e.devices?.length||0,")"]}),t(N,{loading:r,groupDevices:l})]}),n(d.Box,{flexDirection:"column",marginTop:1,children:[t(d.Text,{bold:!0,color:"white",children:"Timestamps"}),e.create_datetime&&n(d.Text,{color:"gray",children:[" Created: ",new Date(e.create_datetime).toLocaleString()]}),e.last_modify_datetime&&n(d.Text,{color:"gray",children:[" ","Modified: ",new Date(e.last_modify_datetime).toLocaleString()]})]})]}),t(E.Ay,{items:[{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],onSelect:o})]}):t(d.Text,{color:"red",children:"Device group not found"}),G=({boxes:e,loading:l,onSelect:r})=>{if(l)return t(b,{text:"Loading media boxes..."});if(!e?.length)return t(d.Text,{color:"yellow",children:"No media boxes found"});var i=[...e.map(e=>({label:`📦 ${e.name||"Unnamed"}`,value:e.id,box:e})),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return n(d.Box,{flexDirection:"column",children:[n(d.Text,{bold:!0,marginBottom:1,children:["Media Boxes (",e.length,")"]}),t(E.Ay,{items:i,onSelect:r})]})},j=({box:e,loading:l,error:r,onSelect:i})=>l&&!e?t(b,{text:"Loading media box..."}):r?n(d.Box,{flexDirection:"column",children:[n(d.Text,{color:"red",children:["Error: ",r]}),t(E.Ay,{items:[{label:"← Back",value:"back"}],onSelect:i})]}):e?n(d.Box,{flexDirection:"column",children:[t(d.Text,{bold:!0,color:"cyan",children:e.name||"Unnamed"}),e.description&&t(d.Text,{color:"gray",children:e.description}),n(d.Box,{marginY:1,flexDirection:"column",children:[n(d.Text,{color:"gray",children:["ID: ",e.id]}),e.tags?.length>0&&n(d.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),null!=e.size&&n(d.Text,{color:"gray",children:["Size: ",e.size]}),e.passcodes?.length>0&&n(d.Box,{flexDirection:"column",marginTop:1,children:[n(d.Text,{bold:!0,color:"white",children:["Passcodes (",e.passcodes.length,")"]}),e.passcodes.slice(0,5).map(e=>n(d.Text,{color:"gray",children:[" ",e.name||"Passcode",": ",e.code]},e.id)),e.passcodes.length>5&&n(d.Text,{color:"gray",dimColor:!0,children:[" ","... and ",e.passcodes.length-5," more"]})]}),n(d.Box,{flexDirection:"column",marginTop:1,children:[t(d.Text,{bold:!0,color:"white",children:"Timestamps"}),e.createdAt&&n(d.Text,{color:"gray",children:[" Created: ",new Date(e.createdAt).toLocaleString()]}),e.updatedAt&&n(d.Text,{color:"gray",children:[" Modified: ",new Date(e.updatedAt).toLocaleString()]})]})]}),t(E.Ay,{items:[{label:"List Files",value:"files"},{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],onSelect:i})]}):t(d.Text,{color:"red",children:"Media box not found"}),$=({files:e,loading:l,onSelect:r,box:i})=>{if(l)return t(b,{text:"Loading media files..."});if(!e?.length)return t(d.Text,{color:"yellow",children:"No media files found"});var o=[...e.map(e=>{var l;return{label:`${"Image"===(l=e.fileType)?"\uD83D\uDDBC":"Video"===l?"\uD83C\uDF9E":"Audio"===l?"\uD83C\uDFB5":"\uD83D\uDCC4"} ${e.name||"Unnamed"}`,value:e.id,file:e}}),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return n(d.Box,{flexDirection:"column",children:[n(d.Text,{bold:!0,marginBottom:1,children:["Media Files (",e.length,")",i?.name?` - ${i.name}`:""]}),t(E.Ay,{items:o,onSelect:r})]})},V=({file:e,loading:l,error:r,onSelect:i})=>{if(l&&!e)return t(b,{text:"Loading media file..."});if(r)return n(d.Box,{flexDirection:"column",children:[n(d.Text,{color:"red",children:["Error: ",r]}),t(E.Ay,{items:[{label:"← Back",value:"back"}],onSelect:i})]});if(!e)return t(d.Text,{color:"red",children:"Media file not found"});var o=e.meta,a=(0,g.Gu)(e),c=(0,g.Gu)(e,{preferThumbnail:!0}),u=!!(c&&c!==a);return n(d.Box,{flexDirection:"column",children:[t(d.Text,{bold:!0,color:"cyan",children:e.name||"Unnamed"}),e.description&&t(d.Text,{color:"gray",children:e.description}),n(d.Box,{marginY:1,flexDirection:"column",children:[n(d.Text,{color:"gray",children:["ID: ",e.id]}),n(d.Text,{color:"gray",children:["Box ID: ",e.boxId]}),n(d.Text,{color:"gray",children:["Type: ",e.fileType]}),e.userTags?.length>0&&n(d.Text,{color:"gray",children:["Tags: ",e.userTags.join(", ")]}),o?.originalWidth!=null&&o?.originalHeight!=null&&n(d.Text,{color:"gray",children:["Size: ",o.originalWidth,"x",o.originalHeight]}),o?.originalFileSize!=null&&n(d.Text,{color:"gray",children:["File: ",(Number(o.originalFileSize)/1024).toFixed(1)," KB"]}),a&&n(d.Text,{color:"gray",children:["Original URL: ",a]}),u&&n(d.Text,{color:"gray",children:["Thumbnail URL: ",c]}),n(d.Box,{flexDirection:"column",marginTop:1,children:[t(d.Text,{bold:!0,color:"white",children:"Timestamps"}),e.createdAt&&n(d.Text,{color:"gray",children:[" Created: ",new Date(e.createdAt).toLocaleString()]}),e.updatedAt&&n(d.Text,{color:"gray",children:[" Modified: ",new Date(e.updatedAt).toLocaleString()]})]})]}),t(E.Ay,{items:[{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],onSelect:i})]})},F=i(92642),H=(e,l)=>{if(!e)return"";var r="string"==typeof e?e:JSON.stringify(e);return r.length>l?r.slice(0,l-1)+"…":r},z=({onBack:e})=>{var l=u((0,c.useState)([]),2),r=l[0],i=l[1],o=u((0,c.useState)(!0),2),s=o[0],g=o[1],m=u((0,c.useState)(null),2),x=m[0],p=m[1];return(0,c.useEffect)(()=>{var e,l=(0,h.getCurrentProfile)(),r=(0,h.getToken)(l),t=(0,h.getActivityLogBaseUrl)();if(!r){p("Not logged in. Run `bricks auth login` first."),g(!1);return}if(!t){p("Activity log URL not configured."),g(!1);return}var n=(0,F.W)(t,r),o=new Date(Date.now()-36e5).toISOString(),c=new Date().toISOString(),d=new AbortController;return(e=a(function*(){try{var e=yield n.collectEvents({start_time:o,end_time:c},{limit:50,signal:d.signal});i(e)}catch(e){"AbortError"!==e.name&&p(e.message)}g(!1)}),function(){return e.apply(this,arguments)})(),()=>d.abort()},[]),n(d.Box,{flexDirection:"column",children:[t(d.Text,{bold:!0,marginBottom:1,children:"Activity Log (last 1h)"}),s&&t(b,{text:"Fetching events..."}),x&&n(d.Text,{color:"red",children:["Error: ",x]}),!s&&!x&&0===r.length&&t(d.Text,{color:"yellow",children:"No events found in the last hour"}),!s&&r.length>0&&n(d.Box,{flexDirection:"column",marginBottom:1,children:[n(d.Text,{color:"gray",children:["Timestamp".padEnd(22)," ","Type".padEnd(12)," ","Device".padEnd(14)," ","Event Name".padEnd(24)," Sender"]}),r.map((e,l)=>n(d.Text,{children:[new Date(e.timestamp).toISOString().replace("T"," ").replace(/\.\d+Z$/,"Z").padEnd(22)," ",H(e.event_type||"",12).padEnd(12)," ",H(e.device_id||"",14).padEnd(14)," ",H(e.event_name||"",24).padEnd(24)," ",H(e.sender||"",16)]},l)),r.length>=50&&n(d.Text,{color:"yellow",children:["Showing first ",50," events"]})]}),t(E.Ay,{items:[{label:"← Back",value:"back"}],onSelect:l=>"back"===l.value&&e()})]})},Y=i(29253),q=i(44618),X=["B","C","G","D"],J=({instanceType:e,instance:l,client:r,onDone:i,onCancel:o})=>{var s,h=(0,d.useApp)().exit,g=u((0,c.useState)("select_ref"),2),m=g[0],x=g[1],p=u((0,c.useState)(""),2),f=p[0],T=p[1],v=u((0,c.useState)("search"),2),y=v[0],_=v[1],D=u((0,c.useState)(null),2),S=D[0],I=D[1],A=u((0,c.useState)(null),2),B=A[0],C=A[1],k=u((0,c.useState)(""),2),L=k[0],w=k[1],O=u((0,c.useState)(""),2),P=O[0],M=O[1],R=u((0,c.useState)(null),2),N=R[0],U=R[1],G=l?.short_edit?.ref_map||{},j=Object.entries(G).filter(([,e])=>e&&!e.hide),$=(0,q.V)(G,{keyword:f,types:X}),V=$.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}))]),F=[...f?[{label:"↻ Clear Search",value:"__clear_search__"}]:[],{label:"← Back",value:"__back__"}],H=V.length>0?[...V,...F]:F,z=H.findIndex(e=>!e.isHeader&&!e.value?.startsWith("__"));(0,d.useInput)((e,l)=>{l.tab&&"select_ref"===m?_(e=>"search"===e?"list":"search"):(l.escape&&("select_ref"===m&&o(),"input_path"===m&&x("select_ref"),"input_content"===m&&x("input_path"),"confirm"===m&&x("input_content"),"done"===m&&o()),"q"===e&&"input_path"!==m&&"input_content"!==m&&("select_ref"!==m||"search"!==y)&&h())},{isActive:!0});var J=(s=a(function*(){if(r&&l?._id&&S){x("submitting"),U(null);try{var t={shortId:S,path:L.trim(),content:(e=>{var l=e.trim();if(""===l)return null;try{return JSON.parse(l)}catch{return l}})(P),forwardDataLink:!0};B?.inner_ref?.pid&&(t.innerRefParentShortId=B.inner_ref.pid),"application"===e?yield r.shortEditApplication({id:l._id,list:[t]}):yield r.shortEditModule({id:l._id,list:[t]}),yield i(),x("done")}catch(e){U(e.message),x("confirm")}}}),function(){return s.apply(this,arguments)});return l?.short_edit?.enabled?0===j.length?n(d.Box,{flexDirection:"column",children:[t(d.Text,{color:"yellow",children:"No Short Edit references found."}),t(E.Ay,{items:[{label:"← Back",value:"back"}],onSelect:o})]}):"select_ref"===m?n(d.Box,{flexDirection:"column",children:[t(d.Text,{bold:!0,children:"Short Edit References"}),t(d.Text,{color:"gray",dimColor:!0,children:"Showing: Brick, Canvas, Generator, Data"}),n(d.Box,{marginTop:1,flexDirection:"column",children:[t(d.Text,{color:"gray",children:"Search (title or shortId)"}),t(Y.A,{value:f,placeholder:"type to filter, Enter to focus list",onChange:e=>T(e),onSubmit:()=>_("list"),focus:"search"===y}),t(d.Text,{color:"gray",dimColor:!0,children:"Press Tab to switch focus"})]}),n(d.Box,{marginTop:1,children:[0===$.length&&t(d.Text,{color:"yellow",children:"No references match your search."}),t(E.Ay,{items:H,isFocused:"list"===y,initialIndex:z>-1?z:0,indicatorComponent:()=>null,itemComponent:({label:e,isSelected:l,isHeader:r})=>r?t(d.Box,{marginTop:1,children:t(d.Text,{bold:!0,color:"white",children:e})}):n(d.Text,{color:l?"blue":void 0,children:[l?"❯":" "," ",e]}),onSelect:e=>{if("__back__"===e.value)return void o();if("__clear_search__"===e.value){T(""),_("search");return}e.isHeader||(I(e.value),C(e.ref),x("input_path"))}})]})]}):"input_path"===m?n(d.Box,{flexDirection:"column",children:[n(d.Text,{children:["Reference:"," ",n(d.Text,{color:"cyan",children:[B?.title||S," (",S,")"]})]}),t(d.Text,{marginTop:1,children:"Enter property path (e.g. title, property.backgroundColor)"}),N&&n(d.Text,{color:"red",children:["Error: ",N]}),t(Y.A,{value:L,placeholder:"path",onChange:e=>{w(e),N&&U(null)},onSubmit:e=>{var l=e.trim();l?(w(l),x("input_content")):U("Path is required")},focus:!0})]}):"input_content"===m?n(d.Box,{flexDirection:"column",children:[n(d.Text,{children:["Path: ",t(d.Text,{color:"cyan",children:L})]}),t(d.Text,{marginTop:1,children:"Enter new content (JSON or plain text). Empty to clear."}),N&&n(d.Text,{color:"red",children:["Error: ",N]}),t(Y.A,{value:P,placeholder:"content",onChange:e=>{M(e),N&&U(null)},onSubmit:()=>x("confirm"),focus:!0})]}):"submitting"===m?t(b,{text:"Applying short edit..."}):"done"===m?n(d.Box,{flexDirection:"column",children:[t(d.Text,{color:"green",children:"Short edit applied successfully."}),t(E.Ay,{items:[{label:"Edit another property",value:"again"},{label:"← Back",value:"back"}],onSelect:e=>{"again"===e.value?(x("select_ref"),I(null),C(null),w(""),M(""),U(null)):o()}})]}):n(d.Box,{flexDirection:"column",children:[t(d.Text,{bold:!0,marginBottom:1,children:"Confirm Short Edit"}),n(d.Text,{children:["Reference:"," ",n(d.Text,{color:"cyan",children:[B?.title||S," (",S,")"]})]}),n(d.Text,{children:["Path: ",t(d.Text,{color:"cyan",children:L})]}),n(d.Text,{children:["Content: ",t(d.Text,{color:"cyan",children:P||"<empty>"})]}),N&&n(d.Text,{color:"red",children:["Error: ",N]}),t(E.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&&J(),"edit_path"===e.value&&x("input_path"),"edit_content"===e.value&&x("input_content"),"back"===e.value&&o()}})]}):n(d.Box,{flexDirection:"column",children:[n(d.Text,{color:"yellow",children:["Short Edit is not enabled for this ",e,"."]}),t(E.Ay,{items:[{label:"← Back",value:"back"}],onSelect:o})]})},K=i(16928),W=i(79896),Z=i(10750),Q=i(77768),ee="options",el="output_dir",er="confirm",et="generating",en="post_install",ei="done",eo=({type:e,instance:l,client:r,onDone:i,onCancel:o})=>{var s,h=(0,d.useApp)().exit,g=u((0,c.useState)(ee),2),m=g[0],x=g[1],p=u((0,c.useState)({setupGitHubActions:!0,setupAgents:!0,setupClaudeCode:!0,setupGeminiCLI:!1,runBunInstall:!0,initGit:!0}),2),T=p[0],v=p[1],y=u((0,c.useState)(process.cwd()),2),_=y[0],b=y[1],D=u((0,c.useState)(""),2),S=D[0],I=D[1],A=u((0,c.useState)(null),2),B=A[0],C=A[1],k=u((0,c.useState)(null),2),L=k[0],w=k[1],O=Z(l?.name||"bricks-ctor"),P=K.resolve(_,O),M=(0,c.useCallback)(e=>{"back"===e.value?o():"continue"===e.value?x(el):v(l=>({...l,[e.value]:!l[e.value]}))},[o]),R=(0,c.useCallback)(()=>{W.existsSync(P)?C(`Directory already exists: ${P}`):(C(null),x(er))},[P]),N=(0,c.useCallback)((s=a(function*(t){if("back"===t.value)return void x(el);if("cancel"===t.value)return void o();if("confirm"===t.value){x(et);try{I("Fetching project from BRICKS...");var n="application"===e,i=n?r.queries.applicationProject:r.queries.moduleProject,a=(yield r.query(i,{id:l._id,buildApplicationOnly:!1,setupGitHubActions:T.setupGitHubActions,setupAgents:T.setupAgents,setupClaudeCode:T.setupClaudeCode,setupGeminiCLI:T.setupGeminiCLI}))[n?"applicationProject":"moduleProject"];if(!a?.files)throw Error("Failed to fetch project files");I("Creating project directory..."),W.mkdirSync(P,{recursive:!0}),I(`Writing ${a.files.length} files...`);var c=yield(0,Q.KN)(a.files,P);(0,Q.oz)(c),x(en);var d={path:P,files:a.files.length,bunInstalled:!1,gitInitialized:!1};Object.assign(d,(yield(0,Q.o0)(P,{install:T.runBunInstall,git:T.initGit,onStatus:I}))),w(d),x(ei)}catch(e){C(e.message),x(ee)}}}),function(e){return s.apply(this,arguments)}),[r,l,e,T,P,o]),U=(0,c.useCallback)(e=>{"exit"===e.value?h():i()},[h,i]);if(m===ee){var G=[{label:`${T.setupGitHubActions?"[x]":"[ ]"} GitHub Actions workflow`,value:"setupGitHubActions"},{label:`${T.setupAgents?"[x]":"[ ]"} AGENTS.md`,value:"setupAgents"},{label:`${T.setupClaudeCode?"[x]":"[ ]"} CLAUDE.md`,value:"setupClaudeCode"},{label:`${T.setupGeminiCLI?"[x]":"[ ]"} GEMINI.md`,value:"setupGeminiCLI"},{label:`${T.runBunInstall?"[x]":"[ ]"} Run bun install after generation`,value:"runBunInstall"},{label:`${T.initGit?"[x]":"[ ]"} Initialize git repository`,value:"initGit"},{label:"→ Continue",value:"continue"},{label:"← Back",value:"back"}];return n(d.Box,{flexDirection:"column",children:[n(d.Text,{bold:!0,color:"cyan",children:["Initialize BRICKS Project: ",l?.name||"Untitled"]}),t(d.Text,{color:"gray",marginBottom:1,children:"Select options for project generation (press Enter to toggle)"}),B&&n(d.Text,{color:"red",marginBottom:1,children:["Error: ",B]}),t(E.Ay,{items:G,onSelect:M})]})}return m===el?n(d.Box,{flexDirection:"column",children:[t(d.Text,{bold:!0,color:"cyan",children:"Output Directory"}),t(d.Text,{color:"gray",marginBottom:1,children:"Enter the parent directory for the project:"}),B&&t(d.Text,{color:"red",marginBottom:1,children:B}),n(d.Box,{children:[t(d.Text,{children:"Directory: "}),t(Y.A,{value:_,onChange:b,onSubmit:R})]}),n(d.Text,{color:"gray",marginTop:1,children:["Project will be created at: ",P]})]}):m===er?n(d.Box,{flexDirection:"column",children:[t(d.Text,{bold:!0,color:"cyan",children:"Confirm Project Generation"}),n(d.Box,{marginY:1,flexDirection:"column",children:[n(d.Text,{children:["Name: ",t(d.Text,{color:"green",children:l?.name||"Untitled"})]}),n(d.Text,{children:["Type: ",t(d.Text,{color:"yellow",children:e})]}),n(d.Text,{children:["Path: ",t(d.Text,{color:"cyan",children:P})]}),t(d.Text,{color:"gray",marginTop:1,children:"Options:"}),n(d.Text,{color:"gray",children:[" - GitHub Actions: ",T.setupGitHubActions?"Yes":"No"]}),n(d.Text,{color:"gray",children:[" - AGENTS.md: ",T.setupAgents?"Yes":"No"]}),n(d.Text,{color:"gray",children:[" - CLAUDE.md: ",T.setupClaudeCode?"Yes":"No"]}),n(d.Text,{color:"gray",children:[" - GEMINI.md: ",T.setupGeminiCLI?"Yes":"No"]}),n(d.Text,{color:"gray",children:[" - Run bun install: ",T.runBunInstall?"Yes":"No"]}),n(d.Text,{color:"gray",children:[" - Initialize git: ",T.initGit?"Yes":"No"]})]}),t(E.Ay,{items:[{label:"Confirm & Generate",value:"confirm"},{label:"← Change Directory",value:"back"},{label:"Cancel",value:"cancel"}],onSelect:N})]}):m===et||m===en?n(d.Box,{flexDirection:"column",children:[t(d.Text,{bold:!0,color:"cyan",children:"Generating Project..."}),n(d.Box,{marginY:1,children:[t(d.Text,{color:"green",children:t(f.A,{type:"dots"})}),n(d.Text,{children:[" ",S]})]})]}):m===ei&&L?n(d.Box,{flexDirection:"column",children:[t(d.Text,{bold:!0,color:"green",children:"Project initialized successfully!"}),n(d.Box,{marginY:1,flexDirection:"column",children:[n(d.Text,{children:["Path: ",t(d.Text,{color:"cyan",children:L.path})]}),n(d.Text,{children:["Files: ",t(d.Text,{color:"green",children:L.files})]}),n(d.Text,{children:["Dependencies:"," ",t(d.Text,{color:L.bunInstalled?"green":"yellow",children:L.bunInstalled?"Installed":"Not installed (run bun install manually)"})]}),n(d.Text,{children:["Git:"," ",t(d.Text,{color:L.gitInitialized?"green":"yellow",children:L.gitInitialized?"Initialized":"Not initialized"})]})]}),t(d.Text,{bold:!0,marginY:1,children:"Next steps:"}),n(d.Text,{color:"gray",children:[" cd ",O]}),!L.bunInstalled&&t(d.Text,{color:"gray",children:" bun install"}),t(d.Text,{color:"gray",children:" bun invoke-simulator"}),n(d.Text,{color:"gray",marginTop:1,children:["For more information, see ",O,"/README.md"]}),t(d.Box,{marginTop:1,children:t(E.Ay,{items:[{label:"← Back to Detail",value:"back"},{label:"Exit CLI",value:"exit"}],onSelect:U})})]}):null};let ea=()=>{var e,l,r,i,o,x,p,f,v=(0,d.useApp)().exit,D=u((0,c.useState)(m.MAIN),2),E=D[0],I=D[1],A=u((0,c.useState)(null),2),N=A[0],F=A[1],H=u((0,c.useState)(null),2),Y=H[0],q=H[1],X=u((0,c.useState)(!0),2),K=X[0],W=X[1],Z=u((0,c.useState)(null),2),Q=Z[0],ee=Z[1],el=u((0,c.useState)([]),2),er=el[0],et=el[1],en=u((0,c.useState)(null),2),ei=en[0],ea=en[1],ec=u((0,c.useState)([]),2),ed=ec[0],eu=ec[1],es=u((0,c.useState)(null),2),eh=es[0],eg=es[1],em=u((0,c.useState)([]),2),ex=em[0],ep=em[1],ef=u((0,c.useState)(null),2),eT=ef[0],ev=ef[1],ey=u((0,c.useState)([]),2),e_=ey[0],eb=ey[1],eD=u((0,c.useState)(null),2),eE=eD[0],eS=eD[1],eI=u((0,c.useState)([]),2),eA=eI[0],eB=eI[1],eC=u((0,c.useState)(!1),2),ek=eC[0],eL=eC[1],ew=u((0,c.useState)(null),2),eO=ew[0],eP=ew[1],eM=u((0,c.useState)(null),2),eR=eM[0],eN=eM[1],eU=u((0,c.useState)(null),2),eG=eU[0],ej=eU[1],e$=u((0,c.useState)(null),2),eV=e$[0],eF=e$[1],eH=u((0,c.useState)([]),2),ez=eH[0],eY=eH[1],eq=u((0,c.useState)(null),2),eX=eq[0],eJ=eq[1],eK=u((0,c.useState)([]),2),eW=eK[0],eZ=eK[1],eQ=u((0,c.useState)(null),2),e0=eQ[0],e1=eQ[1],e2=E===m.DEVICES,e4=E===m.DEVICE_DETAIL,e6=E===m.GROUPS,e9=E===m.GROUP_DETAIL;(0,c.useEffect)(()=>{var e=(0,h.getCurrentProfile)(),l=(0,h.getToken)(e);if(!l){ee("Not logged in. Run `bricks auth login` first."),W(!1);return}var r=(0,s.createClient)((0,h.getBaseUrl)(),l);F(r),r.workspace().then(e=>{q(e),W(!1)}).catch(e=>{ee(e.message),W(!1)})},[]),(0,d.useInput)((e,l)=>{"q"===e&&v(),l.escape&&(E===m.DEVICE_CONTROL?(I(m.DEVICE_DETAIL),eP(null)):E===m.DEVICE_SCREENSHOT?(I(m.DEVICE_DETAIL),ej(null),eF(null)):E===m.DEVICE_DETAIL?(I(m.DEVICES),ea(null)):E===m.APP_DETAIL?(I(m.APPS),eg(null)):E===m.MODULE_DETAIL?(I(m.MODULES),ev(null)):E===m.GROUP_DETAIL?(I(m.GROUPS),eS(null),eB([])):E===m.MEDIA_FILE_DETAIL?(I(m.MEDIA_FILES),e1(null)):E===m.MEDIA_FILES?(I(m.MEDIA_BOX_DETAIL),e1(null)):E===m.MEDIA_BOX_DETAIL?(I(m.MEDIA_BOXES),eJ(null),eZ([])):E===m.MEDIA_BOXES?I(m.MAIN):E!==m.MAIN&&I(m.MAIN))},{isActive:E!==m.APP_SHORT_EDIT&&E!==m.MODULE_SHORT_EDIT&&E!==m.APP_PROJECT_INIT&&E!==m.MODULE_PROJECT_INIT});var e5=(0,c.useCallback)(a(function*(){if(N){W(!0);try{var e=yield N.devices({});et(e||[])}catch(e){ee(e.message)}W(!1)}}),[N]),e8=(0,c.useCallback)((e=a(function*(e){if(N){W(!0),eN(null);try{var l=yield N.device({id:e});ea(l)}catch(e){eN(e.message)}W(!1)}}),function(l){return e.apply(this,arguments)}),[N]),e7=(0,c.useCallback)(a(function*(){if(N){W(!0);try{var e=yield N.applications({});eu(e||[])}catch(e){ee(e.message)}W(!1)}}),[N]),e3=(0,c.useCallback)((l=a(function*(e){if(N){W(!0),eN(null);try{var l=yield N.application({id:e});eg(l)}catch(e){eN(e.message)}W(!1)}}),function(e){return l.apply(this,arguments)}),[N]),le=(0,c.useCallback)(a(function*(){if(N){W(!0);try{var e=yield N.modules({});ep(e||[])}catch(e){ee(e.message)}W(!1)}}),[N]),ll=(0,c.useCallback)((r=a(function*(e){if(N){W(!0),eN(null);try{var l=yield N.module({id:e});ev(l)}catch(e){eN(e.message)}W(!1)}}),function(e){return r.apply(this,arguments)}),[N]),lr=(0,c.useCallback)(a(function*(){if(N){W(!0);try{var e=yield N.deviceGroups({});eb(e||[])}catch(e){ee(e.message)}W(!1)}}),[N]),lt=(0,c.useCallback)((i=a(function*(e){if(N){W(!0),eN(null);try{var l=yield Promise.all([N.deviceGroup({id:e}),N.devicesByGroup({id:e})]),r=u(l,2),t=r[0],n=r[1];eS(t),eB(n||[])}catch(e){eN(e.message)}W(!1)}}),function(e){return i.apply(this,arguments)}),[N]),ln=(0,c.useCallback)(a(function*(){if(N){W(!0);try{var e=yield N.mediaBoxes();eY(e||[])}catch(e){ee(e.message)}W(!1)}}),[N]),li=(0,c.useCallback)((o=a(function*(e){if(N){W(!0),eN(null);try{var l=yield N.mediaBox({id:e});eJ(l)}catch(e){eN(e.message)}W(!1)}}),function(e){return o.apply(this,arguments)}),[N]),lo=(0,c.useCallback)((x=a(function*(e){if(N){W(!0);try{var l=yield N.mediaFiles({boxId:e});eZ(l||[])}catch(e){ee(e.message)}W(!1)}}),function(e){return x.apply(this,arguments)}),[N]),la=(0,c.useCallback)((p=a(function*(e){if(N){W(!0),eN(null);try{var l=yield N.mediaFile({id:e});e1(l)}catch(e){eN(e.message)}W(!1)}}),function(e){return p.apply(this,arguments)}),[N]),lc=(0,c.useCallback)((f=a(function*(e){if(N&&ei){eL(!0),eP(null);try{yield N.controlDevice({id:ei._id,type:e}),eP({success:!0,message:`Command sent: ${e}`})}catch(e){eP({success:!1,message:e.message})}eL(!1)}}),function(e){return f.apply(this,arguments)}),[N,ei]),ld=(0,c.useCallback)(a(function*(e=!1){if(N&&ei&&Y){W(!0),eF(null),ej(null);try{e&&(yield N.controlDevice({id:ei._id,type:"take-screenshot"}),yield new Promise(e=>setTimeout(e,3e3)));var l=yield(0,g.he)(N,Y,ei._id,null,{preferThumbnail:!0});l.error?eF(l.error):ej(l)}catch(e){eF(e.message)}W(!1)}}),[N,ei,Y]),lu=T((0,c.useCallback)(()=>{N&&e5()},[N,e5]),e2),ls=T((0,c.useCallback)(()=>{N&&ei&&e8(ei._id)},[N,ei,e8]),e4),lh=T((0,c.useCallback)(()=>{N&&lr()},[N,lr]),e6),lg=T((0,c.useCallback)(()=>{N&&eE&<(eE._id)},[N,eE,lt]),e9);return K&&!Y?n(d.Box,{flexDirection:"column",children:[t(y,{workspace:Y,view:E}),t(b,{text:"Connecting to workspace..."})]}):Q&&!Y?n(d.Box,{flexDirection:"column",children:[t(y,{workspace:Y,view:E}),n(d.Text,{color:"red",children:["Error: ",Q]}),t(_,{})]}):n(d.Box,{flexDirection:"column",children:[t(y,{workspace:Y,view:E}),E===m.MAIN&&t(S,{onSelect:e=>{"exit"===e.value?v():(I(e.value),e.value===m.DEVICES?e5():e.value===m.APPS?e7():e.value===m.MODULES?le():e.value===m.GROUPS?lr():e.value===m.MEDIA_BOXES&&ln())},mediaEnabled:(0,g.wR)(Y),activityLogEnabled:!!(0,h.getActivityLogBaseUrl)()}),E===m.DEVICES&&t(B,{devices:er,loading:K,onSelect:e=>{if("back"===e.value)return void I(m.MAIN);if("refresh"===e.value){e5(),lu.resetCountdown();return}ea(null),W(!0),I(m.DEVICE_DETAIL),e8(e.value)},countdown:lu.countdown,lastRefreshTime:lu.lastRefreshTime}),E===m.DEVICE_DETAIL&&t(C,{device:ei,loading:K,error:eR,onSelect:e=>{if("back"===e.value){I(m.DEVICES),ea(null);return}if("refresh"===e.value){e8(ei._id),ls.resetCountdown();return}"control"===e.value&&(I(m.DEVICE_CONTROL),eP(null)),"screenshot"===e.value&&(I(m.DEVICE_SCREENSHOT),ej(null),eF(null),ld(!1))},mediaEnabled:(0,g.wR)(Y),countdown:ls.countdown,lastRefreshTime:ls.lastRefreshTime}),E===m.DEVICE_CONTROL&&t(k,{device:ei,onSelect:e=>{if("back"===e.value){I(m.DEVICE_DETAIL),eP(null);return}lc(e.value)},controlling:ek,controlResult:eO}),E===m.DEVICE_SCREENSHOT&&t(L,{device:ei,screenshot:eG,loading:K,error:eV,onSelect:e=>{if("back"===e.value){I(m.DEVICE_DETAIL),ej(null),eF(null);return}"refresh"===e.value?ld(!1):"take"===e.value&&ld(!0)}}),E===m.APPS&&t(w,{apps:ed,loading:K,onSelect:e=>{"back"===e.value?I(m.MAIN):"refresh"===e.value?e7():(eg(null),W(!0),I(m.APP_DETAIL),e3(e.value))}}),E===m.APP_DETAIL&&t(O,{app:eh,loading:K,error:eR,onSelect:e=>{if("back"===e.value){I(m.APPS),eg(null);return}"refresh"===e.value?e3(eh._id):("short_edit"===e.value&&(I(m.APP_SHORT_EDIT),eN(null)),"project_init"===e.value&&(I(m.APP_PROJECT_INIT),eN(null)))}}),E===m.APP_SHORT_EDIT&&t(J,{instanceType:"application",instance:eh,client:N,onDone:a(function*(){return e3(eh._id)}),onCancel:()=>I(m.APP_DETAIL)}),E===m.APP_PROJECT_INIT&&t(eo,{type:"application",instance:eh,client:N,onDone:()=>I(m.APP_DETAIL),onCancel:()=>I(m.APP_DETAIL)}),E===m.MODULES&&t(P,{modules:ex,loading:K,onSelect:e=>{"back"===e.value?I(m.MAIN):"refresh"===e.value?le():(ev(null),W(!0),I(m.MODULE_DETAIL),ll(e.value))}}),E===m.MODULE_DETAIL&&t(M,{module:eT,loading:K,error:eR,onSelect:e=>{if("back"===e.value){I(m.MODULES),ev(null);return}"refresh"===e.value?ll(eT._id):("short_edit"===e.value&&(I(m.MODULE_SHORT_EDIT),eN(null)),"project_init"===e.value&&(I(m.MODULE_PROJECT_INIT),eN(null)))}}),E===m.MODULE_SHORT_EDIT&&t(J,{instanceType:"module",instance:eT,client:N,onDone:a(function*(){return ll(eT._id)}),onCancel:()=>I(m.MODULE_DETAIL)}),E===m.MODULE_PROJECT_INIT&&t(eo,{type:"module",instance:eT,client:N,onDone:()=>I(m.MODULE_DETAIL),onCancel:()=>I(m.MODULE_DETAIL)}),E===m.GROUPS&&t(R,{groups:e_,loading:K,onSelect:e=>{if("back"===e.value)return void I(m.MAIN);if("refresh"===e.value){lr(),lh.resetCountdown();return}eS(null),eB([]),W(!0),I(m.GROUP_DETAIL),lt(e.value)},countdown:lh.countdown,lastRefreshTime:lh.lastRefreshTime}),E===m.GROUP_DETAIL&&t(U,{group:eE,groupDevices:eA,loading:K,error:eR,onSelect:e=>{if("back"===e.value){I(m.GROUPS),eS(null),eB([]);return}"refresh"===e.value&&(lt(eE._id),lg.resetCountdown())},countdown:lg.countdown,lastRefreshTime:lg.lastRefreshTime}),E===m.ACTIVITY_LOG&&t(z,{onBack:()=>I(m.MAIN)}),E===m.MEDIA_BOXES&&t(G,{boxes:ez,loading:K,onSelect:e=>{"back"===e.value?I(m.MAIN):"refresh"===e.value?ln():(eJ(null),eZ([]),W(!0),I(m.MEDIA_BOX_DETAIL),li(e.value))}}),E===m.MEDIA_BOX_DETAIL&&t(j,{box:eX,loading:K,error:eR,onSelect:e=>{if("back"===e.value){I(m.MEDIA_BOXES),eJ(null),eZ([]);return}"refresh"===e.value?li(eX.id):"files"===e.value&&(eZ([]),e1(null),I(m.MEDIA_FILES),lo(eX.id))}}),E===m.MEDIA_FILES&&t($,{files:eW,box:eX,loading:K,onSelect:e=>{if("back"===e.value){I(m.MEDIA_BOX_DETAIL),e1(null);return}"refresh"===e.value?lo(eX.id):(e1(null),W(!0),I(m.MEDIA_FILE_DETAIL),la(e.value))}}),E===m.MEDIA_FILE_DETAIL&&t(V,{file:e0,loading:K,error:eR,onSelect:e=>{if("back"===e.value){I(m.MEDIA_FILES),e1(null);return}"refresh"===e.value&&la(e0.id)}}),t(_,{})]})};var ec="1"===process.env.BRICKS_CLI_DISTRIBUTION,ed=(o=a(function*(){if(ec)return void(0,d.render)(t(ea,{}));var e=(yield i.e(166).then(i.bind(i,29557))).TerminalInfoProvider;(0,d.render)(t(e,{children:t(ea,{})}))}),function(){return o.apply(this,arguments)})},77768(e,l,r){r.d(l,{BZ:()=>v,KN:()=>p,kU:()=>x,o0:()=>T,oz:()=>f});var t,n,i,o,a=r(99436),c=r(16928),d=r(79896),u=r(35317),s=r(10750),h=e=>{try{return(0,u.execSync)(`which ${e}`,{stdio:"ignore"}),!0}catch{return!1}},g=(e,l,r)=>new Promise((t,n)=>{var i=[e,...l].join(" "),o=(0,u.spawn)(i,[],{cwd:r,stdio:"pipe",shell:!0}),a=[];o.stderr.on("data",e=>a.push(e)),o.on("close",e=>{0===e?t():n(Error(Buffer.concat(a).toString().trim()||`Command failed with code ${e}`))}),o.on("error",n)}),m=(t=a(function*(e,l){try{var t=(yield r.e(75).then(r.bind(r,79491))).format;return(yield t(l,e,{trailingComma:"all",tabWidth:2,semi:!1,singleQuote:!0,printWidth:100})).code}catch{}return e}),function(e,l){return t.apply(this,arguments)}),x=(e=[])=>{var l=e.find(e=>"application.json"===e.name);if(!l)return"bricks-ctor";try{var r=JSON.parse(l.input);return s(r.name||"bricks-ctor")}catch{return"bricks-ctor"}},p=(n=a(function*(e,l){var r;return Promise.all(e.map((r=a(function*(e){var r=c.join(l,e.name),t=e.input;return e.formatable&&(t=yield m(t,r)),{...e,filePath:r,content:t}}),function(e){return r.apply(this,arguments)})))}),function(e,l){return n.apply(this,arguments)}),f=e=>{e.forEach(e=>{d.mkdirSync(c.dirname(e.filePath),{recursive:!0}),d.writeFileSync(e.filePath,e.content)})},T=(i=a(function*(e,l={}){var r="function"==typeof l.onStatus?l.onStatus:()=>{},t=!1,n=!1;if(!1!==l.install&&h("bun")){r("Installing dependencies (bun install)...");try{yield g("bun",["install"],e),t=!0}catch{}}if(!1!==l.git&&h("git")){r("Initializing git repository...");try{yield g("git",["init"],e),yield g("git",["add","."],e),yield g("git",["-c 'user.name=BRICKS CLI'","-c 'user.email=cli@bricks.tools'","commit","-m 'chore: initialize commit'"],e),n=!0}catch{}}return{bunInstalled:t,gitInitialized:n}}),function(e){return i.apply(this,arguments)}),v=(o=a(function*(e,l,r){var t=r.client,n=r.output,i=r.outputAsTarget;if(!t)throw Error("client is required");if(!n)throw Error("output directory is required");var o=(e=>{for(var l=c.resolve(e);;){if(d.existsSync(c.join(l,"application.json"))||d.existsSync(c.join(l,"module.json")))return l;var r=c.dirname(l);if(r===l)return null;l=r}})(i?c.dirname(c.resolve(n)):n);if(o)throw Error(`Cannot initialize a new BRICKS project inside an existing project (${o}). Choose a directory outside the project.`);var a="application"===e,u=a?t.queries.applicationProject:t.queries.moduleProject,s=(yield t.query(u,{id:l,buildApplicationOnly:!1,setupGitHubActions:!1!==r.githubActions,setupAgents:!1!==r.agents,setupClaudeCode:!1!==r.claude,setupGeminiCLI:!0===r.gemini}))[a?"applicationProject":"moduleProject"];if(!s?.files)throw Error(`${e} project not found`);var h=x(s.files),g=i?c.resolve(n):c.resolve(n,h);if(d.existsSync(g))throw Error(`Directory already exists: ${g}`);d.mkdirSync(g,{recursive:!0}),f((yield p(s.files,g)));var m=yield T(g,r),v=m.bunInstalled,y=m.gitInitialized;return{success:!0,path:g,files:s.files.length,bunInstalled:v,gitInitialized:y}}),function(e,l,r){return o.apply(this,arguments)})}};
|