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