@fugood/bricks-cli 2.25.0-beta.63 → 2.25.0-beta.64

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.
Files changed (82) hide show
  1. package/lib/1010.js +1 -0
  2. package/lib/1178.js +1 -0
  3. package/lib/1215.js +1 -0
  4. package/lib/{708.js → 1708.js} +2 -2
  5. package/lib/1759.js +1 -0
  6. package/lib/1936.js +1 -0
  7. package/lib/2151.js +1 -0
  8. package/lib/{209.js → 2209.js} +3 -3
  9. package/lib/2247.js +1 -0
  10. package/lib/2486.js +1 -0
  11. package/lib/2557.js +1 -0
  12. package/lib/{223.js → 3223.js} +1 -1
  13. package/lib/3332.js +13 -0
  14. package/lib/3690.js +1 -0
  15. package/lib/3774.js +44 -0
  16. package/lib/3976.js +14 -0
  17. package/lib/4305.js +1 -0
  18. package/lib/4456.js +3 -0
  19. package/lib/{192.js → 4479.js} +4 -4
  20. package/lib/4530.js +22 -0
  21. package/lib/4642.js +9 -0
  22. package/lib/4685.js +1202 -0
  23. package/lib/5212.js +1 -0
  24. package/lib/{658.js → 5658.js} +1 -1
  25. package/lib/5785.js +1 -0
  26. package/lib/6194.js +3 -0
  27. package/lib/6370.js +1 -0
  28. package/lib/6645.js +1 -0
  29. package/lib/6818.js +1 -0
  30. package/lib/7111.js +2 -0
  31. package/lib/7456.js +1 -0
  32. package/lib/7511.js +1 -0
  33. package/lib/7574.js +1 -0
  34. package/lib/7648.js +1 -0
  35. package/lib/8026.js +1 -0
  36. package/lib/{117.js → 8117.js} +2 -2
  37. package/lib/8166.js +1 -0
  38. package/lib/853.js +1 -0
  39. package/lib/915.js +3 -3
  40. package/lib/9320.js +3 -0
  41. package/lib/{387.js → 9387.js} +1 -1
  42. package/lib/9405.js +1 -0
  43. package/lib/9430.js +1 -0
  44. package/lib/{583.js → 9583.js} +1 -1
  45. package/lib/9663.js +1 -0
  46. package/lib/{866.js → 9866.js} +1 -1
  47. package/lib/9940.js +19 -0
  48. package/lib/index.js +17 -17
  49. package/package.json +5 -5
  50. package/lib/10.js +0 -1
  51. package/lib/111.js +0 -2
  52. package/lib/166.js +0 -1
  53. package/lib/178.js +0 -1
  54. package/lib/212.js +0 -1
  55. package/lib/215.js +0 -1
  56. package/lib/247.js +0 -1
  57. package/lib/274.js +0 -55
  58. package/lib/305.js +0 -1
  59. package/lib/306.js +0 -1
  60. package/lib/320.js +0 -3
  61. package/lib/332.js +0 -13
  62. package/lib/358.js +0 -1
  63. package/lib/370.js +0 -1
  64. package/lib/405.js +0 -1
  65. package/lib/430.js +0 -1
  66. package/lib/456.js +0 -3
  67. package/lib/479.js +0 -1231
  68. package/lib/486.js +0 -1
  69. package/lib/511.js +0 -1
  70. package/lib/557.js +0 -1
  71. package/lib/574.js +0 -1
  72. package/lib/645.js +0 -1
  73. package/lib/648.js +0 -1
  74. package/lib/663.js +0 -1
  75. package/lib/690.js +0 -1
  76. package/lib/75.js +0 -1
  77. package/lib/759.js +0 -1
  78. package/lib/785.js +0 -1
  79. package/lib/818.js +0 -1
  80. package/lib/917.js +0 -1
  81. package/lib/936.js +0 -1
  82. package/lib/940.js +0 -19
package/lib/940.js DELETED
@@ -1,19 +0,0 @@
1
- import*as e from"ink";import*as r from"react";import{Fragment as t,jsx as l,jsxs as n}from"react/jsx-runtime";export const __rspack_esm_id=940;export const __rspack_esm_ids=[940];export const __webpack_modules__={8498(r){r.exports=e},51649(e){e.exports=r},92319(e,r,i){i.r(r),i.d(r,{AppList:()=>L,CONTROL_ACTIONS:()=>g,MainMenu:()=>E,Header:()=>T,ModuleDetail:()=>M,ONLINE_THRESHOLD_MS:()=>p,ShortEditEditor:()=>K,MediaFileList:()=>G,App:()=>ea,DeviceDetail:()=>C,VIEWS:()=>m,runInteractiveMode:()=>ed,DeviceList:()=>B,MediaBoxList:()=>j,Loading:()=>_,DeviceControl:()=>k,ProjectInitView:()=>eo,GroupDetail:()=>U,ModuleList:()=>P,MediaBoxDetail:()=>$,GroupList:()=>R,Footer:()=>b,DeviceStatus:()=>D,AppDetail:()=>O,DeviceScreenshot:()=>w,MediaFileDetail:()=>F});var o,a=i(99436),c=i(51649),d=i(8498),s=i(68832),u=i(85382),h=i(47988),f=i(60450),m={MAIN:"main",DEVICES:"devices",DEVICE_DETAIL:"device_detail",DEVICE_CONTROL:"device_control",DEVICE_SCREENSHOT:"device_screenshot",APPS:"apps",APP_DETAIL:"app_detail",APP_SHORT_EDIT:"app_short_edit",APP_PROJECT_INIT:"app_project_init",MODULES:"modules",MODULE_DETAIL:"module_detail",MODULE_SHORT_EDIT:"module_short_edit",MODULE_PROJECT_INIT:"module_project_init",GROUPS:"groups",GROUP_DETAIL:"group_detail",MEDIA_BOXES:"media_boxes",MEDIA_BOX_DETAIL:"media_box_detail",MEDIA_FILES:"media_files",MEDIA_FILE_DETAIL:"media_file_detail",ACTIVITY_LOG:"activity_log"},g=[{label:"Refresh Application",value:"refresh"},{label:"Clear Cache",value:"clear-cache"},{label:"Take Screenshot",value:"take-screenshot"},{label:"Open System Menu",value:"system-menu-open"},{label:"Close System Menu",value:"system-menu-close"},{label:"Open Debug Panel",value:"debug-panel-open"},{label:"Close Debug Panel",value:"debug-panel-close"},{label:"Enable Logging",value:"logging-on"},{label:"Disable Logging",value:"logging-off"},{label:"← Back",value:"back"}],p=3e5,x=i(47882),y=(e,r=!0)=>{var t=Math.floor(60),l=s((0,c.useState)(t),2),n=l[0],i=l[1],o=s((0,c.useState)(null),2),a=o[0],d=o[1],u=(0,c.useRef)(e);(0,c.useEffect)(()=>{u.current=e},[e]);var h=(0,c.useCallback)(()=>{i(t),d(Date.now())},[t]);return(0,c.useEffect)(()=>{if(r){var e=setInterval(()=>{i(e=>e<=1?(u.current?.(),d(Date.now()),t):e-1)},1e3);return()=>clearInterval(e)}},[r,t]),(0,c.useEffect)(()=>{r&&(i(t),d(Date.now()))},[r,t]),{countdown:n,lastRefreshTime:a,resetCountdown:h}},v=({countdown:e,lastRefreshTime:r})=>l(d.Box,{children:n(d.Text,{color:"gray",children:["Next refresh in ",n(d.Text,{color:"cyan",children:[e,"s"]}),r&&n(d.Text,{color:"gray",children:[" (last: ",r?new Date(r).toLocaleTimeString():null,")"]})]})}),T=({workspace:e,view:r})=>n(d.Box,{flexDirection:"column",marginBottom:1,children:[n(d.Box,{children:[l(d.Text,{bold:!0,color:"cyan",children:"BRICKS CLI"}),l(d.Text,{color:"gray",children:" - Interactive Mode"})]}),n(d.Box,{children:[l(d.Text,{color:"gray",children:"Workspace: "}),l(d.Text,{color:"green",children:e?.name||"Not connected"}),l(d.Text,{color:"gray",children:" | View: "}),l(d.Text,{color:"yellow",children:r})]}),l(d.Text,{color:"gray",children:"─".repeat(60)})]}),b=()=>n(d.Box,{marginTop:1,flexDirection:"column",children:[l(d.Text,{color:"gray",children:"─".repeat(60)}),n(d.Text,{color:"gray",children:["Press ",l(d.Text,{color:"cyan",children:"q"})," to quit, ",l(d.Text,{color:"cyan",children:"Esc"})," to go back"]})]}),_=({text:e})=>n(d.Box,{children:[l(d.Text,{color:"green",children:l(x.A,{type:"dots"})}),n(d.Text,{children:[" ",e||"Loading..."]})]}),D=({lastAliveTime:e})=>{if(!e)return l(d.Text,{color:"gray",children:"○ Unknown"});var r=Date.now()-new Date(e).getTime();if(r<=p)return l(d.Text,{color:"green",children:"● Online"});var t=Math.floor(r/6e4);if(t<60)return n(d.Text,{color:"yellow",children:["○ Offline (",t,"m ago)"]});var i=Math.floor(t/60);if(i<24)return n(d.Text,{color:"red",children:["○ Offline (",i,"h ago)"]});var o=Math.floor(i/24);return n(d.Text,{color:"red",children:["○ Offline (",o,"d ago)"]})},S=i(48724),E=({onSelect:e,mediaEnabled:r,activityLogEnabled:t})=>{var i=[{label:"Devices",value:m.DEVICES},{label:"Applications",value:m.APPS},{label:"Modules",value:m.MODULES},{label:"Device Groups",value:m.GROUPS},...r?[{label:"Media Flow",value:m.MEDIA_BOXES}]:[],...t?[{label:"Activity Log",value:m.ACTIVITY_LOG}]:[],{label:"Exit",value:"exit"}];return n(d.Box,{flexDirection:"column",children:[l(d.Text,{bold:!0,marginBottom:1,children:"Main Menu"}),l(S.Ay,{items:i,onSelect:e})]})},I="1"===process.env.BRICKS_CLI_DISTRIBUTION,A=e=>{var r=s((0,c.useState)(null),2),t=r[0],n=r[1];return((0,c.useEffect)(()=>{if(!I){var e=!0;return i.e(166).then(i.bind(i,29557)).then(r=>{e&&n(()=>r.default)}).catch(()=>{e&&n(!1)}),()=>{e=!1}}},[]),I||!1===t)?l(d.Text,{color:"gray",children:"Image preview is not available in this CLI build."}):t?l(t,{...e}):l(_,{text:"Preparing image preview..."})},B=({devices:e,loading:r,onSelect:t,countdown:i,lastRefreshTime:o})=>{if(r)return l(_,{text:"Loading devices..."});if(!e?.length)return n(d.Box,{flexDirection:"column",children:[l(d.Text,{color:"yellow",children:"No devices found"}),l(v,{countdown:i,lastRefreshTime:o})]});var a=[...e.map(e=>{var r=(e=>{if(!e)return"○ Unknown";var r=Date.now()-new Date(e).getTime();if(r<=p)return"● Online";var t=Math.floor(r/6e4);if(t<60)return`○ ${t}m ago`;var l=Math.floor(t/60);if(l<24)return`○ ${l}h ago`;var n=Math.floor(l/24);return`○ ${n}d ago`})(e.entry_detail?.watch_dog_timer?.last_alive_time);return{label:`${r} - ${e.name||e.device_name}`,value:e._id,device:e}}),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return n(d.Box,{flexDirection:"column",children:[n(d.Box,{marginBottom:1,children:[n(d.Text,{bold:!0,children:["Devices (",e.length,")"]}),l(d.Text,{color:"gray",children:" - "}),l(v,{countdown:i,lastRefreshTime:o})]}),l(S.Ay,{items:a,onSelect:t})]})},C=({device:e,loading:r,error:t,onSelect:i,mediaEnabled:o,countdown:a,lastRefreshTime:c})=>{if(r)return l(_,{text:"Loading device..."});if(t)return n(d.Box,{flexDirection:"column",children:[n(d.Text,{color:"red",children:["Error: ",t]}),l(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:i})]});if(!e)return l(d.Text,{color:"red",children:"Device not found"});var s=[{label:"Control Device",value:"control"},...o?[{label:"View Screenshot",value:"screenshot"}]:[],{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],u=e.entry_detail,h=u?.screen,f=u?.update,m=u?.local_sync;return n(d.Box,{flexDirection:"column",children:[n(d.Box,{children:[l(d.Text,{bold:!0,color:"cyan",children:e.name||e.device_name}),l(d.Text,{color:"gray",children:" - "}),l(v,{countdown:a,lastRefreshTime:c})]}),e.description&&l(d.Text,{color:"gray",children:e.description}),n(d.Box,{marginY:1,flexDirection:"column",children:[n(d.Box,{children:[l(d.Text,{color:"gray",children:"Status: "}),l(D,{lastAliveTime:u?.watch_dog_timer?.last_alive_time})]}),n(d.Text,{color:"gray",children:["ID: ",e._id]}),e.tags?.length>0&&n(d.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),u?.application&&n(d.Box,{flexDirection:"column",marginTop:1,children:[l(d.Text,{bold:!0,color:"white",children:"Application"}),n(d.Text,{color:"gray",children:[" Name: ",u.application.name]}),n(d.Text,{color:"gray",children:[" Mode: ",u.operation_mode||"N/A"]})]}),h&&n(d.Box,{flexDirection:"column",marginTop:1,children:[l(d.Text,{bold:!0,color:"white",children:"Screen"}),h.resolution&&n(d.Text,{color:"gray",children:[" ","Resolution: ",h.resolution.width,"x",h.resolution.height,h.resolution.scale&&` @${h.resolution.scale}x`]}),h.orientation&&n(d.Text,{color:"gray",children:[" Orientation: ",h.orientation]}),h.touch&&n(d.Text,{color:"gray",children:[" ","Touch:"," ",h.touch.available?`Yes (${h.touch.touch_point} points)`:"No"]})]}),(u?.memory_usage||u?.disk_usage)&&n(d.Box,{flexDirection:"column",marginTop:1,children:[l(d.Text,{bold:!0,color:"white",children:"System"}),u.memory_usage&&n(d.Text,{color:"gray",children:[" Memory: ",Math.round(100*u.memory_usage),"%"]}),u.disk_usage&&n(d.Text,{color:"gray",children:[" Disk: ",Math.round(100*u.disk_usage),"%"]})]}),n(d.Box,{flexDirection:"column",marginTop:1,children:[l(d.Text,{bold:!0,color:"white",children:"Capabilities"}),n(d.Text,{color:"gray",children:[" ","Sound: ",u?.sound?.available?"✓":"✗"," | ","Camera: ",u?.camera?.available?"✓":"✗"," | ","Audio In: ",u?.audio_in?.available?"✓":"✗"]})]}),m&&n(d.Box,{flexDirection:"column",marginTop:1,children:[l(d.Text,{bold:!0,color:"white",children:"Local Sync"}),n(d.Text,{color:"gray",children:[" ","Role: ",m.is_main?"Main":"Peer",m.peer_count>0&&` | Peers: ${m.peer_count}`,m.mean_latency&&` | Latency: ${m.mean_latency}ms`]})]}),f&&n(d.Box,{flexDirection:"column",marginTop:1,children:[l(d.Text,{bold:!0,color:"white",children:"Update"}),n(d.Text,{color:f.need_update?"yellow":"gray",children:[" ","Status: ",f.need_update?"⚠ Update available":"✓ Up to date"]}),f.current_version&&n(d.Text,{color:"gray",children:[" Version: ",f.current_version]})]})]}),l(S.Ay,{items:s,onSelect:i})]})},k=({device:e,onSelect:r,controlling:t,controlResult:i})=>n(d.Box,{flexDirection:"column",children:[n(d.Text,{bold:!0,color:"cyan",children:["Control: ",e?.name||e?.device_name]}),t&&l(_,{text:"Sending command..."}),i&&l(d.Text,{color:i.success?"green":"red",children:i.message}),l(d.Box,{marginTop:1,children:l(S.Ay,{items:g,onSelect:r})})]}),w=({device:e,screenshot:r,loading:t,error:i,onSelect:o})=>{var a=r?.file?.meta,c=a?.originalWidth!=null&&a?.originalHeight!=null,s=a?.originalFileSize!=null;return n(d.Box,{flexDirection:"column",children:[n(d.Text,{bold:!0,color:"cyan",children:["Screenshot: ",e?.name||e?.device_name||"Unknown"]}),t&&l(_,{text:"Loading screenshot..."}),i&&l(d.Box,{marginY:1,children:l(d.Text,{color:"red",children:String(i)})}),!t&&!i&&r&&n(d.Box,{flexDirection:"column",children:[l(d.Box,{height:30,children:l(A,{src:r.path,width:80,alt:"Device screenshot"})}),n(d.Box,{marginY:1,flexDirection:"column",children:[l(d.Text,{bold:!0,color:"white",children:"Screenshot Details"}),n(d.Box,{marginY:1,children:[l(d.Text,{color:"green",children:"Screenshot saved to: "}),l(d.Text,{color:"cyan",children:String(r.path||"")})]}),c&&n(d.Text,{color:"gray",children:["Size: ",String(a.originalWidth),"x",String(a.originalHeight)]}),s&&n(d.Text,{color:"gray",children:["File: ",(Number(a.originalFileSize)/1024).toFixed(1)," KB"]}),r.file?.updatedAt&&n(d.Text,{color:"gray",children:["Updated: ",new Date(r.file.updatedAt).toLocaleString()]})]})]}),!t&&!i&&!r&&l(d.Box,{marginY:1,children:l(d.Text,{color:"yellow",children:"No screenshot available. Try taking a new one."})}),l(d.Box,{marginTop:1,children:l(S.Ay,{items:[{label:"Take New Screenshot",value:"take"},{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],onSelect:o})})]})},L=({apps:e,loading:r,onSelect:t})=>{if(r)return l(_,{text:"Loading applications..."});if(!e?.length)return l(d.Text,{color:"yellow",children:"No applications found"});var i=[...e.map(e=>({label:`${e.has_unreleased_changes?"●":"○"} ${e.name}`,value:e._id,app:e})),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return n(d.Box,{flexDirection:"column",children:[n(d.Text,{bold:!0,marginBottom:1,children:["Applications (",e.length,")"]}),l(S.Ay,{items:i,onSelect:t})]})},O=({app:e,loading:r,error:t,onSelect:i})=>{if(r)return l(_,{text:"Loading application..."});if(t)return n(d.Box,{flexDirection:"column",children:[n(d.Text,{color:"red",children:["Error: ",t]}),l(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:i})]});if(!e)return l(d.Text,{color:"red",children:"Application not found"});var o=[{label:"⚡ Initialize Project",value:"project_init"},...e.short_edit?.enabled&&e.short_edit.ref_map?[{label:"Short Edit",value:"short_edit"}]:[],{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],a=e.devices?.length||0,c=e.devices?.filter(e=>"online"===e.status)?.length||0;return n(d.Box,{flexDirection:"column",children:[l(d.Text,{bold:!0,color:"cyan",children:e.name}),e.description&&l(d.Text,{color:"gray",children:e.description}),n(d.Box,{marginY:1,flexDirection:"column",children:[n(d.Text,{color:"gray",children:["ID: ",e._id]}),e.tags?.length>0&&n(d.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),n(d.Box,{flexDirection:"column",marginTop:1,children:[l(d.Text,{bold:!0,color:"white",children:"Version"}),n(d.Text,{color:"gray",children:[" ","Current: ",e.current_version?`v${e.current_version}`:"N/A"]}),n(d.Text,{color:e.has_unreleased_changes?"yellow":"gray",children:[" ","Changes:"," ",e.has_unreleased_changes?"● Unreleased changes":"○ No pending changes"]}),e.current_version_details&&n(d.Text,{color:"gray",children:[" ","Released: v",e.current_version_details.version||"N/A"]})]}),n(d.Box,{flexDirection:"column",marginTop:1,children:[l(d.Text,{bold:!0,color:"white",children:"Devices"}),n(d.Text,{color:"gray",children:[" ","Total: ",a,a>0&&` (${c} online)`]})]}),n(d.Box,{flexDirection:"column",marginTop:1,children:[l(d.Text,{bold:!0,color:"white",children:"Features"}),n(d.Text,{color:"gray",children:[" ","Short Edit: ",e.short_edit?.enabled?"✓ Enabled":"✗ Disabled"]}),n(d.Text,{color:"gray",children:[" ","Canvas Control: ",e.canvas_control?.enabled?"✓ Enabled":"✗ Disabled"]}),n(d.Text,{color:"gray",children:[" ","Device Control: ",e.device_control?.enabled?"✓ Enabled":"✗ Disabled"]}),n(d.Text,{color:e.lock?.enabled?"yellow":"gray",children:[" ","Lock: ",e.lock?.enabled?"\uD83D\uDD12 Locked":"\uD83D\uDD13 Unlocked"]})]}),n(d.Box,{flexDirection:"column",marginTop:1,children:[l(d.Text,{bold:!0,color:"white",children:"Timestamps"}),e.create_datetime&&n(d.Text,{color:"gray",children:[" Created: ",new Date(e.create_datetime).toLocaleString()]}),e.last_modify_datetime&&n(d.Text,{color:"gray",children:[" ","Modified: ",new Date(e.last_modify_datetime).toLocaleString()]})]})]}),l(S.Ay,{items:o,onSelect:i})]})},P=({modules:e,loading:r,onSelect:t})=>{if(r)return l(_,{text:"Loading modules..."});var i=[...(e||[]).map(e=>({label:`${e.current_version?"●":"○"} ${e.name}`,value:e._id,module:e})),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return n(d.Box,{flexDirection:"column",children:[n(d.Text,{bold:!0,marginBottom:1,children:["Modules (",e?.length||0,")"]}),!e?.length&&l(d.Text,{color:"yellow",children:"No modules found"}),l(S.Ay,{items:i,onSelect:t})]})},M=({module:e,loading:r,error:t,onSelect:i})=>{if(r)return l(_,{text:"Loading module..."});if(t)return n(d.Box,{flexDirection:"column",children:[n(d.Text,{color:"red",children:["Error: ",t]}),l(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:i})]});if(!e)return l(d.Text,{color:"red",children:"Module not found"});var o=[{label:"⚡ Initialize Project",value:"project_init"},...e.short_edit?.enabled&&e.short_edit.ref_map?[{label:"Short Edit",value:"short_edit"}]:[],{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return n(d.Box,{flexDirection:"column",children:[l(d.Text,{bold:!0,color:"cyan",children:e.name}),e.description&&l(d.Text,{color:"gray",children:e.description}),n(d.Box,{marginY:1,flexDirection:"column",children:[n(d.Text,{color:"gray",children:["ID: ",e._id]}),e.tags?.length>0&&n(d.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),n(d.Box,{flexDirection:"column",marginTop:1,children:[l(d.Text,{bold:!0,color:"white",children:"Version"}),n(d.Text,{color:"gray",children:[" ","Current: ",e.current_version?`v${e.current_version}`:"N/A"]}),n(d.Text,{color:e.has_unreleased_changes?"yellow":"gray",children:[" ","Changes:"," ",e.has_unreleased_changes?"● Unreleased changes":"○ No pending changes"]})]}),n(d.Box,{flexDirection:"column",marginTop:1,children:[l(d.Text,{bold:!0,color:"white",children:"Usage"}),n(d.Text,{color:"gray",children:[" ","Used in: ",e.use_count?.total_count||0," application(s)"]})]}),n(d.Box,{flexDirection:"column",marginTop:1,children:[l(d.Text,{bold:!0,color:"white",children:"Settings"}),n(d.Text,{color:"gray",children:[" ","Public: ",e.is_public?"✓ Yes":"✗ No"]}),n(d.Text,{color:"gray",children:[" ","Modifiable: ",e.is_allow_modify?"✓ Yes":"✗ No"]}),n(d.Text,{color:"gray",children:[" ","Short Edit: ",e.short_edit?.enabled?"✓ Enabled":"✗ Disabled"]})]}),e.expose_properties?.length>0&&n(d.Box,{flexDirection:"column",marginTop:1,children:[l(d.Text,{bold:!0,color:"white",children:"Exposed Properties"}),n(d.Text,{color:"gray",children:[" ",e.expose_properties.length," properties exposed"]})]}),n(d.Box,{flexDirection:"column",marginTop:1,children:[l(d.Text,{bold:!0,color:"white",children:"Timestamps"}),e.create_datetime&&n(d.Text,{color:"gray",children:[" Created: ",new Date(e.create_datetime).toLocaleString()]}),e.last_modify_datetime&&n(d.Text,{color:"gray",children:[" ","Modified: ",new Date(e.last_modify_datetime).toLocaleString()]})]})]}),l(S.Ay,{items:o,onSelect:i})]})},R=({groups:e,loading:r,onSelect:t,countdown:i,lastRefreshTime:o})=>{if(r)return l(_,{text:"Loading device groups..."});var a=[...(e||[]).map(e=>({label:`📁 ${e.name} (${e.devices?.length||0} devices)`,value:e._id,group:e})),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return n(d.Box,{flexDirection:"column",children:[n(d.Box,{marginBottom:1,children:[n(d.Text,{bold:!0,children:["Device Groups (",e?.length||0,")"]}),l(d.Text,{color:"gray",children:" - "}),l(v,{countdown:i,lastRefreshTime:o})]}),!e?.length&&l(d.Text,{color:"yellow",children:"No device groups found"}),l(S.Ay,{items:a,onSelect:t})]})},N=({loading:e,groupDevices:r})=>e?l(_,{text:"Loading devices..."}):r?.length?n(t,{children:[r.slice(0,10).map(e=>n(d.Box,{children:[l(d.Text,{color:"gray",children:" "}),l(D,{lastAliveTime:e.entry_detail?.watch_dog_timer?.last_alive_time}),n(d.Text,{color:"gray",children:[" ",e.name||e.device_name]}),e.device_target_name&&n(d.Text,{color:"gray",dimColor:!0,children:[" ","(",e.device_target_name,")"]})]},e._id)),r.length>10&&n(d.Text,{color:"gray",dimColor:!0,children:[" ","... and ",r.length-10," more"]})]}):l(d.Text,{color:"gray",children:" No devices in this group"}),U=({group:e,groupDevices:r,loading:t,error:i,onSelect:o,countdown:a,lastRefreshTime:c})=>t&&!e?l(_,{text:"Loading device group..."}):i?n(d.Box,{flexDirection:"column",children:[n(d.Text,{color:"red",children:["Error: ",i]}),l(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:o})]}):e?n(d.Box,{flexDirection:"column",children:[n(d.Box,{children:[l(d.Text,{bold:!0,color:"cyan",children:e.name}),l(d.Text,{color:"gray",children:" - "}),l(v,{countdown:a,lastRefreshTime:c})]}),e.description&&l(d.Text,{color:"gray",children:e.description}),n(d.Box,{marginY:1,flexDirection:"column",children:[n(d.Text,{color:"gray",children:["ID: ",e._id]}),e.tags?.length>0&&n(d.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),n(d.Box,{flexDirection:"column",marginTop:1,children:[n(d.Text,{bold:!0,color:"white",children:["Devices (",e.devices?.length||0,")"]}),l(N,{loading:t,groupDevices:r})]}),n(d.Box,{flexDirection:"column",marginTop:1,children:[l(d.Text,{bold:!0,color:"white",children:"Timestamps"}),e.create_datetime&&n(d.Text,{color:"gray",children:[" Created: ",new Date(e.create_datetime).toLocaleString()]}),e.last_modify_datetime&&n(d.Text,{color:"gray",children:[" ","Modified: ",new Date(e.last_modify_datetime).toLocaleString()]})]})]}),l(S.Ay,{items:[{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],onSelect:o})]}):l(d.Text,{color:"red",children:"Device group not found"}),j=({boxes:e,loading:r,onSelect:t})=>{if(r)return l(_,{text:"Loading media boxes..."});if(!e?.length)return l(d.Text,{color:"yellow",children:"No media boxes found"});var i=[...e.map(e=>({label:`📦 ${e.name||"Unnamed"}`,value:e.id,box:e})),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return n(d.Box,{flexDirection:"column",children:[n(d.Text,{bold:!0,marginBottom:1,children:["Media Boxes (",e.length,")"]}),l(S.Ay,{items:i,onSelect:t})]})},$=({box:e,loading:r,error:t,onSelect:i})=>r&&!e?l(_,{text:"Loading media box..."}):t?n(d.Box,{flexDirection:"column",children:[n(d.Text,{color:"red",children:["Error: ",t]}),l(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:i})]}):e?n(d.Box,{flexDirection:"column",children:[l(d.Text,{bold:!0,color:"cyan",children:e.name||"Unnamed"}),e.description&&l(d.Text,{color:"gray",children:e.description}),n(d.Box,{marginY:1,flexDirection:"column",children:[n(d.Text,{color:"gray",children:["ID: ",e.id]}),e.tags?.length>0&&n(d.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),null!=e.size&&n(d.Text,{color:"gray",children:["Size: ",e.size]}),e.passcodes?.length>0&&n(d.Box,{flexDirection:"column",marginTop:1,children:[n(d.Text,{bold:!0,color:"white",children:["Passcodes (",e.passcodes.length,")"]}),e.passcodes.slice(0,5).map(e=>n(d.Text,{color:"gray",children:[" ",e.name||"Passcode",": ",e.code]},e.id)),e.passcodes.length>5&&n(d.Text,{color:"gray",dimColor:!0,children:[" ","... and ",e.passcodes.length-5," more"]})]}),n(d.Box,{flexDirection:"column",marginTop:1,children:[l(d.Text,{bold:!0,color:"white",children:"Timestamps"}),e.createdAt&&n(d.Text,{color:"gray",children:[" Created: ",new Date(e.createdAt).toLocaleString()]}),e.updatedAt&&n(d.Text,{color:"gray",children:[" Modified: ",new Date(e.updatedAt).toLocaleString()]})]})]}),l(S.Ay,{items:[{label:"List Files",value:"files"},{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],onSelect:i})]}):l(d.Text,{color:"red",children:"Media box not found"}),G=({files:e,loading:r,onSelect:t,box:i})=>{if(r)return l(_,{text:"Loading media files..."});if(!e?.length)return l(d.Text,{color:"yellow",children:"No media files found"});var o=[...e.map(e=>{var r;return{label:`${"Image"===(r=e.fileType)?"\uD83D\uDDBC":"Video"===r?"\uD83C\uDF9E":"Audio"===r?"\uD83C\uDFB5":"\uD83D\uDCC4"} ${e.name||"Unnamed"}`,value:e.id,file:e}}),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return n(d.Box,{flexDirection:"column",children:[n(d.Text,{bold:!0,marginBottom:1,children:["Media Files (",e.length,")",i?.name?` - ${i.name}`:""]}),l(S.Ay,{items:o,onSelect:t})]})},F=({file:e,loading:r,error:t,onSelect:i})=>{if(r&&!e)return l(_,{text:"Loading media file..."});if(t)return n(d.Box,{flexDirection:"column",children:[n(d.Text,{color:"red",children:["Error: ",t]}),l(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:i})]});if(!e)return l(d.Text,{color:"red",children:"Media file not found"});var o=e.meta,a=(0,f.buildScreenshotUrl)(e),c=(0,f.buildScreenshotUrl)(e,{preferThumbnail:!0}),s=!!(c&&c!==a);return n(d.Box,{flexDirection:"column",children:[l(d.Text,{bold:!0,color:"cyan",children:e.name||"Unnamed"}),e.description&&l(d.Text,{color:"gray",children:e.description}),n(d.Box,{marginY:1,flexDirection:"column",children:[n(d.Text,{color:"gray",children:["ID: ",e.id]}),n(d.Text,{color:"gray",children:["Box ID: ",e.boxId]}),n(d.Text,{color:"gray",children:["Type: ",e.fileType]}),e.userTags?.length>0&&n(d.Text,{color:"gray",children:["Tags: ",e.userTags.join(", ")]}),o?.originalWidth!=null&&o?.originalHeight!=null&&n(d.Text,{color:"gray",children:["Size: ",o.originalWidth,"x",o.originalHeight]}),o?.originalFileSize!=null&&n(d.Text,{color:"gray",children:["File: ",(Number(o.originalFileSize)/1024).toFixed(1)," KB"]}),a&&n(d.Text,{color:"gray",children:["Original URL: ",a]}),s&&n(d.Text,{color:"gray",children:["Thumbnail URL: ",c]}),n(d.Box,{flexDirection:"column",marginTop:1,children:[l(d.Text,{bold:!0,color:"white",children:"Timestamps"}),e.createdAt&&n(d.Text,{color:"gray",children:[" Created: ",new Date(e.createdAt).toLocaleString()]}),e.updatedAt&&n(d.Text,{color:"gray",children:[" Modified: ",new Date(e.updatedAt).toLocaleString()]})]})]}),l(S.Ay,{items:[{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],onSelect:i})]})},V=i(92642),H=(e,r)=>{if(!e)return"";var t="string"==typeof e?e:JSON.stringify(e);return t.length>r?t.slice(0,r-1)+"…":t},z=({onBack:e})=>{var r=s((0,c.useState)([]),2),t=r[0],i=r[1],o=s((0,c.useState)(!0),2),u=o[0],f=o[1],m=s((0,c.useState)(null),2),g=m[0],p=m[1];return(0,c.useEffect)(()=>{var e,r=(0,h.getCurrentProfile)(),t=(0,h.getToken)(r),l=(0,h.getActivityLogBaseUrl)();if(!t){p("Not logged in. Run `bricks auth login` first."),f(!1);return}if(!l){p("Activity log URL not configured."),f(!1);return}var n=(0,V.createActivityLogClient)(l,t),o=new Date(Date.now()-36e5).toISOString(),c=new Date().toISOString(),d=new AbortController;return(e=a(function*(){try{var e=yield n.collectEvents({start_time:o,end_time:c},{limit:50,signal:d.signal});i(e)}catch(e){"AbortError"!==e.name&&p(e.message)}f(!1)}),function(){return e.apply(this,arguments)})(),()=>d.abort()},[]),n(d.Box,{flexDirection:"column",children:[l(d.Text,{bold:!0,marginBottom:1,children:"Activity Log (last 1h)"}),u&&l(_,{text:"Fetching events..."}),g&&n(d.Text,{color:"red",children:["Error: ",g]}),!u&&!g&&0===t.length&&l(d.Text,{color:"yellow",children:"No events found in the last hour"}),!u&&t.length>0&&n(d.Box,{flexDirection:"column",marginBottom:1,children:[n(d.Text,{color:"gray",children:["Timestamp".padEnd(22)," ","Type".padEnd(12)," ","Device".padEnd(14)," ","Event Name".padEnd(24)," Sender"]}),t.map((e,r)=>n(d.Text,{children:[new Date(e.timestamp).toISOString().replace("T"," ").replace(/\.\d+Z$/,"Z").padEnd(22)," ",H(e.event_type||"",12).padEnd(12)," ",H(e.device_id||"",14).padEnd(14)," ",H(e.event_name||"",24).padEnd(24)," ",H(e.sender||"",16)]},r)),t.length>=50&&n(d.Text,{color:"yellow",children:["Showing first ",50," events"]})]}),l(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:r=>"back"===r.value&&e()})]})},Y=i(29253),q=i(44618),J=["B","C","G","D"],K=({instanceType:e,instance:r,client:t,onDone:i,onCancel:o})=>{var u,h=(0,d.useApp)().exit,f=s((0,c.useState)("select_ref"),2),m=f[0],g=f[1],p=s((0,c.useState)(""),2),x=p[0],y=p[1],v=s((0,c.useState)("search"),2),T=v[0],b=v[1],D=s((0,c.useState)(null),2),E=D[0],I=D[1],A=s((0,c.useState)(null),2),B=A[0],C=A[1],k=s((0,c.useState)(""),2),w=k[0],L=k[1],O=s((0,c.useState)(""),2),P=O[0],M=O[1],R=s((0,c.useState)(null),2),N=R[0],U=R[1],j=r?.short_edit?.ref_map||{},$=Object.entries(j).filter(([,e])=>e&&!e.hide),G=(0,q.V)(j,{keyword:x,types:J}),F=G.flatMap(e=>[{label:e.label,value:`__header_${e.prefix}__`,isHeader:!0},...e.refs.map(({shortId:e,ref:r})=>({label:`${r.title||e} (${e})`,value:e,ref:r}))]),V=[...x?[{label:"↻ Clear Search",value:"__clear_search__"}]:[],{label:"← Back",value:"__back__"}],H=F.length>0?[...F,...V]:V,z=H.findIndex(e=>!e.isHeader&&!e.value?.startsWith("__"));(0,d.useInput)((e,r)=>{r.tab&&"select_ref"===m?b(e=>"search"===e?"list":"search"):(r.escape&&("select_ref"===m&&o(),"input_path"===m&&g("select_ref"),"input_content"===m&&g("input_path"),"confirm"===m&&g("input_content"),"done"===m&&o()),"q"===e&&"input_path"!==m&&"input_content"!==m&&("select_ref"!==m||"search"!==T)&&h())},{isActive:!0});var K=(u=a(function*(){if(t&&r?._id&&E){g("submitting"),U(null);try{var l={shortId:E,path:w.trim(),content:(e=>{var r=e.trim();if(""===r)return null;try{return JSON.parse(r)}catch{return r}})(P),forwardDataLink:!0};B?.inner_ref?.pid&&(l.innerRefParentShortId=B.inner_ref.pid),"application"===e?yield t.shortEditApplication({id:r._id,list:[l]}):yield t.shortEditModule({id:r._id,list:[l]}),yield i(),g("done")}catch(e){U(e.message),g("confirm")}}}),function(){return u.apply(this,arguments)});return r?.short_edit?.enabled?0===$.length?n(d.Box,{flexDirection:"column",children:[l(d.Text,{color:"yellow",children:"No Short Edit references found."}),l(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:o})]}):"select_ref"===m?n(d.Box,{flexDirection:"column",children:[l(d.Text,{bold:!0,children:"Short Edit References"}),l(d.Text,{color:"gray",dimColor:!0,children:"Showing: Brick, Canvas, Generator, Data"}),n(d.Box,{marginTop:1,flexDirection:"column",children:[l(d.Text,{color:"gray",children:"Search (title or shortId)"}),l(Y.A,{value:x,placeholder:"type to filter, Enter to focus list",onChange:e=>y(e),onSubmit:()=>b("list"),focus:"search"===T}),l(d.Text,{color:"gray",dimColor:!0,children:"Press Tab to switch focus"})]}),n(d.Box,{marginTop:1,children:[0===G.length&&l(d.Text,{color:"yellow",children:"No references match your search."}),l(S.Ay,{items:H,isFocused:"list"===T,initialIndex:z>-1?z:0,indicatorComponent:()=>null,itemComponent:({label:e,isSelected:r,isHeader:t})=>t?l(d.Box,{marginTop:1,children:l(d.Text,{bold:!0,color:"white",children:e})}):n(d.Text,{color:r?"blue":void 0,children:[r?"❯":" "," ",e]}),onSelect:e=>{if("__back__"===e.value)return void o();if("__clear_search__"===e.value){y(""),b("search");return}e.isHeader||(I(e.value),C(e.ref),g("input_path"))}})]})]}):"input_path"===m?n(d.Box,{flexDirection:"column",children:[n(d.Text,{children:["Reference:"," ",n(d.Text,{color:"cyan",children:[B?.title||E," (",E,")"]})]}),l(d.Text,{marginTop:1,children:"Enter property path (e.g. title, property.backgroundColor)"}),N&&n(d.Text,{color:"red",children:["Error: ",N]}),l(Y.A,{value:w,placeholder:"path",onChange:e=>{L(e),N&&U(null)},onSubmit:e=>{var r=e.trim();r?(L(r),g("input_content")):U("Path is required")},focus:!0})]}):"input_content"===m?n(d.Box,{flexDirection:"column",children:[n(d.Text,{children:["Path: ",l(d.Text,{color:"cyan",children:w})]}),l(d.Text,{marginTop:1,children:"Enter new content (JSON or plain text). Empty to clear."}),N&&n(d.Text,{color:"red",children:["Error: ",N]}),l(Y.A,{value:P,placeholder:"content",onChange:e=>{M(e),N&&U(null)},onSubmit:()=>g("confirm"),focus:!0})]}):"submitting"===m?l(_,{text:"Applying short edit..."}):"done"===m?n(d.Box,{flexDirection:"column",children:[l(d.Text,{color:"green",children:"Short edit applied successfully."}),l(S.Ay,{items:[{label:"Edit another property",value:"again"},{label:"← Back",value:"back"}],onSelect:e=>{"again"===e.value?(g("select_ref"),I(null),C(null),L(""),M(""),U(null)):o()}})]}):n(d.Box,{flexDirection:"column",children:[l(d.Text,{bold:!0,marginBottom:1,children:"Confirm Short Edit"}),n(d.Text,{children:["Reference:"," ",n(d.Text,{color:"cyan",children:[B?.title||E," (",E,")"]})]}),n(d.Text,{children:["Path: ",l(d.Text,{color:"cyan",children:w})]}),n(d.Text,{children:["Content: ",l(d.Text,{color:"cyan",children:P||"<empty>"})]}),N&&n(d.Text,{color:"red",children:["Error: ",N]}),l(S.Ay,{items:[{label:"Apply",value:"apply"},{label:"Edit Path",value:"edit_path"},{label:"Edit Content",value:"edit_content"},{label:"← Back",value:"back"}],onSelect:e=>{"apply"===e.value&&K(),"edit_path"===e.value&&g("input_path"),"edit_content"===e.value&&g("input_content"),"back"===e.value&&o()}})]}):n(d.Box,{flexDirection:"column",children:[n(d.Text,{color:"yellow",children:["Short Edit is not enabled for this ",e,"."]}),l(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:o})]})},W=i(16928),X=i(79896),Q=i(10750),Z=i(77768),ee="options",er="output_dir",et="confirm",el="generating",en="post_install",ei="done",eo=({type:e,instance:r,client:t,onDone:i,onCancel:o})=>{var u,h=(0,d.useApp)().exit,f=s((0,c.useState)(ee),2),m=f[0],g=f[1],p=s((0,c.useState)({setupGitHubActions:!0,setupAgents:!0,setupClaudeCode:!0,setupGeminiCLI:!1,runBunInstall:!0,initGit:!0}),2),y=p[0],v=p[1],T=s((0,c.useState)(process.cwd()),2),b=T[0],_=T[1],D=s((0,c.useState)(""),2),E=D[0],I=D[1],A=s((0,c.useState)(null),2),B=A[0],C=A[1],k=s((0,c.useState)(null),2),w=k[0],L=k[1],O=Q(r?.name||"bricks-ctor"),P=W.resolve(b,O),M=(0,c.useCallback)(e=>{"back"===e.value?o():"continue"===e.value?g(er):v(r=>({...r,[e.value]:!r[e.value]}))},[o]),R=(0,c.useCallback)(()=>{X.existsSync(P)?C(`Directory already exists: ${P}`):(C(null),g(et))},[P]),N=(0,c.useCallback)((u=a(function*(l){if("back"===l.value)return void g(er);if("cancel"===l.value)return void o();if("confirm"===l.value){g(el);try{I("Fetching project from BRICKS...");var n="application"===e,i=n?t.queries.applicationProject:t.queries.moduleProject,a=(yield t.query(i,{id:r._id,buildApplicationOnly:!1,setupGitHubActions:y.setupGitHubActions,setupAgents:y.setupAgents,setupClaudeCode:y.setupClaudeCode,setupGeminiCLI:y.setupGeminiCLI}))[n?"applicationProject":"moduleProject"];if(!a?.files)throw Error("Failed to fetch project files");I("Creating project directory..."),X.mkdirSync(P,{recursive:!0}),I(`Writing ${a.files.length} files...`);var c=yield(0,Z.KN)(a.files,P);(0,Z.oz)(c),g(en);var d={path:P,files:a.files.length,bunInstalled:!1,gitInitialized:!1};Object.assign(d,(yield(0,Z.o0)(P,{install:y.runBunInstall,git:y.initGit,onStatus:I}))),L(d),g(ei)}catch(e){C(e.message),g(ee)}}}),function(e){return u.apply(this,arguments)}),[t,r,e,y,P,o]),U=(0,c.useCallback)(e=>{"exit"===e.value?h():i()},[h,i]);if(m===ee){var j=[{label:`${y.setupGitHubActions?"[x]":"[ ]"} GitHub Actions workflow`,value:"setupGitHubActions"},{label:`${y.setupAgents?"[x]":"[ ]"} AGENTS.md`,value:"setupAgents"},{label:`${y.setupClaudeCode?"[x]":"[ ]"} CLAUDE.md`,value:"setupClaudeCode"},{label:`${y.setupGeminiCLI?"[x]":"[ ]"} GEMINI.md`,value:"setupGeminiCLI"},{label:`${y.runBunInstall?"[x]":"[ ]"} Run bun install after generation`,value:"runBunInstall"},{label:`${y.initGit?"[x]":"[ ]"} Initialize git repository`,value:"initGit"},{label:"→ Continue",value:"continue"},{label:"← Back",value:"back"}];return n(d.Box,{flexDirection:"column",children:[n(d.Text,{bold:!0,color:"cyan",children:["Initialize BRICKS Project: ",r?.name||"Untitled"]}),l(d.Text,{color:"gray",marginBottom:1,children:"Select options for project generation (press Enter to toggle)"}),B&&n(d.Text,{color:"red",marginBottom:1,children:["Error: ",B]}),l(S.Ay,{items:j,onSelect:M})]})}return m===er?n(d.Box,{flexDirection:"column",children:[l(d.Text,{bold:!0,color:"cyan",children:"Output Directory"}),l(d.Text,{color:"gray",marginBottom:1,children:"Enter the parent directory for the project:"}),B&&l(d.Text,{color:"red",marginBottom:1,children:B}),n(d.Box,{children:[l(d.Text,{children:"Directory: "}),l(Y.A,{value:b,onChange:_,onSubmit:R})]}),n(d.Text,{color:"gray",marginTop:1,children:["Project will be created at: ",P]})]}):m===et?n(d.Box,{flexDirection:"column",children:[l(d.Text,{bold:!0,color:"cyan",children:"Confirm Project Generation"}),n(d.Box,{marginY:1,flexDirection:"column",children:[n(d.Text,{children:["Name: ",l(d.Text,{color:"green",children:r?.name||"Untitled"})]}),n(d.Text,{children:["Type: ",l(d.Text,{color:"yellow",children:e})]}),n(d.Text,{children:["Path: ",l(d.Text,{color:"cyan",children:P})]}),l(d.Text,{color:"gray",marginTop:1,children:"Options:"}),n(d.Text,{color:"gray",children:[" - GitHub Actions: ",y.setupGitHubActions?"Yes":"No"]}),n(d.Text,{color:"gray",children:[" - AGENTS.md: ",y.setupAgents?"Yes":"No"]}),n(d.Text,{color:"gray",children:[" - CLAUDE.md: ",y.setupClaudeCode?"Yes":"No"]}),n(d.Text,{color:"gray",children:[" - GEMINI.md: ",y.setupGeminiCLI?"Yes":"No"]}),n(d.Text,{color:"gray",children:[" - Run bun install: ",y.runBunInstall?"Yes":"No"]}),n(d.Text,{color:"gray",children:[" - Initialize git: ",y.initGit?"Yes":"No"]})]}),l(S.Ay,{items:[{label:"Confirm & Generate",value:"confirm"},{label:"← Change Directory",value:"back"},{label:"Cancel",value:"cancel"}],onSelect:N})]}):m===el||m===en?n(d.Box,{flexDirection:"column",children:[l(d.Text,{bold:!0,color:"cyan",children:"Generating Project..."}),n(d.Box,{marginY:1,children:[l(d.Text,{color:"green",children:l(x.A,{type:"dots"})}),n(d.Text,{children:[" ",E]})]})]}):m===ei&&w?n(d.Box,{flexDirection:"column",children:[l(d.Text,{bold:!0,color:"green",children:"Project initialized successfully!"}),n(d.Box,{marginY:1,flexDirection:"column",children:[n(d.Text,{children:["Path: ",l(d.Text,{color:"cyan",children:w.path})]}),n(d.Text,{children:["Files: ",l(d.Text,{color:"green",children:w.files})]}),n(d.Text,{children:["Dependencies:"," ",l(d.Text,{color:w.bunInstalled?"green":"yellow",children:w.bunInstalled?"Installed":"Not installed (run bun install manually)"})]}),n(d.Text,{children:["Git:"," ",l(d.Text,{color:w.gitInitialized?"green":"yellow",children:w.gitInitialized?"Initialized":"Not initialized"})]})]}),l(d.Text,{bold:!0,marginY:1,children:"Next steps:"}),n(d.Text,{color:"gray",children:[" cd ",O]}),!w.bunInstalled&&l(d.Text,{color:"gray",children:" bun install"}),l(d.Text,{color:"gray",children:" bun invoke-simulator"}),n(d.Text,{color:"gray",marginTop:1,children:["For more information, see ",O,"/README.md"]}),l(d.Box,{marginTop:1,children:l(S.Ay,{items:[{label:"← Back to Detail",value:"back"},{label:"Exit CLI",value:"exit"}],onSelect:U})})]}):null};let ea=()=>{var e,r,t,i,o,g,p,x,v=(0,d.useApp)().exit,D=s((0,c.useState)(m.MAIN),2),S=D[0],I=D[1],A=s((0,c.useState)(null),2),N=A[0],V=A[1],H=s((0,c.useState)(null),2),Y=H[0],q=H[1],J=s((0,c.useState)(!0),2),W=J[0],X=J[1],Q=s((0,c.useState)(null),2),Z=Q[0],ee=Q[1],er=s((0,c.useState)([]),2),et=er[0],el=er[1],en=s((0,c.useState)(null),2),ei=en[0],ea=en[1],ec=s((0,c.useState)([]),2),ed=ec[0],es=ec[1],eu=s((0,c.useState)(null),2),eh=eu[0],ef=eu[1],em=s((0,c.useState)([]),2),eg=em[0],ep=em[1],ex=s((0,c.useState)(null),2),ey=ex[0],ev=ex[1],eT=s((0,c.useState)([]),2),eb=eT[0],e_=eT[1],eD=s((0,c.useState)(null),2),eS=eD[0],eE=eD[1],eI=s((0,c.useState)([]),2),eA=eI[0],eB=eI[1],eC=s((0,c.useState)(!1),2),ek=eC[0],ew=eC[1],eL=s((0,c.useState)(null),2),eO=eL[0],eP=eL[1],eM=s((0,c.useState)(null),2),eR=eM[0],eN=eM[1],eU=s((0,c.useState)(null),2),ej=eU[0],e$=eU[1],eG=s((0,c.useState)(null),2),eF=eG[0],eV=eG[1],eH=s((0,c.useState)([]),2),ez=eH[0],eY=eH[1],eq=s((0,c.useState)(null),2),eJ=eq[0],eK=eq[1],eW=s((0,c.useState)([]),2),eX=eW[0],eQ=eW[1],eZ=s((0,c.useState)(null),2),e0=eZ[0],e1=eZ[1],e2=S===m.DEVICES,e4=S===m.DEVICE_DETAIL,e6=S===m.GROUPS,e9=S===m.GROUP_DETAIL;(0,c.useEffect)(()=>{var e=(0,h.getCurrentProfile)(),r=(0,h.getToken)(e);if(!r){ee("Not logged in. Run `bricks auth login` first."),X(!1);return}var t=(0,u.createClient)((0,h.getBaseUrl)(),r);V(t),t.workspace().then(e=>{q(e),X(!1)}).catch(e=>{ee(e.message),X(!1)})},[]),(0,d.useInput)((e,r)=>{"q"===e&&v(),r.escape&&(S===m.DEVICE_CONTROL?(I(m.DEVICE_DETAIL),eP(null)):S===m.DEVICE_SCREENSHOT?(I(m.DEVICE_DETAIL),e$(null),eV(null)):S===m.DEVICE_DETAIL?(I(m.DEVICES),ea(null)):S===m.APP_DETAIL?(I(m.APPS),ef(null)):S===m.MODULE_DETAIL?(I(m.MODULES),ev(null)):S===m.GROUP_DETAIL?(I(m.GROUPS),eE(null),eB([])):S===m.MEDIA_FILE_DETAIL?(I(m.MEDIA_FILES),e1(null)):S===m.MEDIA_FILES?(I(m.MEDIA_BOX_DETAIL),e1(null)):S===m.MEDIA_BOX_DETAIL?(I(m.MEDIA_BOXES),eK(null),eQ([])):S===m.MEDIA_BOXES?I(m.MAIN):S!==m.MAIN&&I(m.MAIN))},{isActive:S!==m.APP_SHORT_EDIT&&S!==m.MODULE_SHORT_EDIT&&S!==m.APP_PROJECT_INIT&&S!==m.MODULE_PROJECT_INIT});var e5=(0,c.useCallback)(a(function*(){if(N){X(!0);try{var e=yield N.devices({});el(e||[])}catch(e){ee(e.message)}X(!1)}}),[N]),e7=(0,c.useCallback)((e=a(function*(e){if(N){X(!0),eN(null);try{var r=yield N.device({id:e});ea(r)}catch(e){eN(e.message)}X(!1)}}),function(r){return e.apply(this,arguments)}),[N]),e8=(0,c.useCallback)(a(function*(){if(N){X(!0);try{var e=yield N.applications({});es(e||[])}catch(e){ee(e.message)}X(!1)}}),[N]),e3=(0,c.useCallback)((r=a(function*(e){if(N){X(!0),eN(null);try{var r=yield N.application({id:e});ef(r)}catch(e){eN(e.message)}X(!1)}}),function(e){return r.apply(this,arguments)}),[N]),re=(0,c.useCallback)(a(function*(){if(N){X(!0);try{var e=yield N.modules({});ep(e||[])}catch(e){ee(e.message)}X(!1)}}),[N]),rr=(0,c.useCallback)((t=a(function*(e){if(N){X(!0),eN(null);try{var r=yield N.module({id:e});ev(r)}catch(e){eN(e.message)}X(!1)}}),function(e){return t.apply(this,arguments)}),[N]),rt=(0,c.useCallback)(a(function*(){if(N){X(!0);try{var e=yield N.deviceGroups({});e_(e||[])}catch(e){ee(e.message)}X(!1)}}),[N]),rl=(0,c.useCallback)((i=a(function*(e){if(N){X(!0),eN(null);try{var r=yield Promise.all([N.deviceGroup({id:e}),N.devicesByGroup({id:e})]),t=s(r,2),l=t[0],n=t[1];eE(l),eB(n||[])}catch(e){eN(e.message)}X(!1)}}),function(e){return i.apply(this,arguments)}),[N]),rn=(0,c.useCallback)(a(function*(){if(N){X(!0);try{var e=yield N.mediaBoxes();eY(e||[])}catch(e){ee(e.message)}X(!1)}}),[N]),ri=(0,c.useCallback)((o=a(function*(e){if(N){X(!0),eN(null);try{var r=yield N.mediaBox({id:e});eK(r)}catch(e){eN(e.message)}X(!1)}}),function(e){return o.apply(this,arguments)}),[N]),ro=(0,c.useCallback)((g=a(function*(e){if(N){X(!0);try{var r=yield N.mediaFiles({boxId:e});eQ(r||[])}catch(e){ee(e.message)}X(!1)}}),function(e){return g.apply(this,arguments)}),[N]),ra=(0,c.useCallback)((p=a(function*(e){if(N){X(!0),eN(null);try{var r=yield N.mediaFile({id:e});e1(r)}catch(e){eN(e.message)}X(!1)}}),function(e){return p.apply(this,arguments)}),[N]),rc=(0,c.useCallback)((x=a(function*(e){if(N&&ei){ew(!0),eP(null);try{yield N.controlDevice({id:ei._id,type:e}),eP({success:!0,message:`Command sent: ${e}`})}catch(e){eP({success:!1,message:e.message})}ew(!1)}}),function(e){return x.apply(this,arguments)}),[N,ei]),rd=(0,c.useCallback)(a(function*(e=!1){if(N&&ei&&Y){X(!0),eV(null),e$(null);try{e&&(yield N.controlDevice({id:ei._id,type:"take-screenshot"}),yield new Promise(e=>setTimeout(e,3e3)));var r=yield(0,f.fetchAndSaveScreenshot)(N,Y,ei._id,null,{preferThumbnail:!0});r.error?eV(r.error):e$(r)}catch(e){eV(e.message)}X(!1)}}),[N,ei,Y]),rs=y((0,c.useCallback)(()=>{N&&e5()},[N,e5]),e2),ru=y((0,c.useCallback)(()=>{N&&ei&&e7(ei._id)},[N,ei,e7]),e4),rh=y((0,c.useCallback)(()=>{N&&rt()},[N,rt]),e6),rf=y((0,c.useCallback)(()=>{N&&eS&&rl(eS._id)},[N,eS,rl]),e9);return W&&!Y?n(d.Box,{flexDirection:"column",children:[l(T,{workspace:Y,view:S}),l(_,{text:"Connecting to workspace..."})]}):Z&&!Y?n(d.Box,{flexDirection:"column",children:[l(T,{workspace:Y,view:S}),n(d.Text,{color:"red",children:["Error: ",Z]}),l(b,{})]}):n(d.Box,{flexDirection:"column",children:[l(T,{workspace:Y,view:S}),S===m.MAIN&&l(E,{onSelect:e=>{"exit"===e.value?v():(I(e.value),e.value===m.DEVICES?e5():e.value===m.APPS?e8():e.value===m.MODULES?re():e.value===m.GROUPS?rt():e.value===m.MEDIA_BOXES&&rn())},mediaEnabled:(0,f.isMediaEnabled)(Y),activityLogEnabled:!!(0,h.getActivityLogBaseUrl)()}),S===m.DEVICES&&l(B,{devices:et,loading:W,onSelect:e=>{if("back"===e.value)return void I(m.MAIN);if("refresh"===e.value){e5(),rs.resetCountdown();return}ea(null),X(!0),I(m.DEVICE_DETAIL),e7(e.value)},countdown:rs.countdown,lastRefreshTime:rs.lastRefreshTime}),S===m.DEVICE_DETAIL&&l(C,{device:ei,loading:W,error:eR,onSelect:e=>{if("back"===e.value){I(m.DEVICES),ea(null);return}if("refresh"===e.value){e7(ei._id),ru.resetCountdown();return}"control"===e.value&&(I(m.DEVICE_CONTROL),eP(null)),"screenshot"===e.value&&(I(m.DEVICE_SCREENSHOT),e$(null),eV(null),rd(!1))},mediaEnabled:(0,f.isMediaEnabled)(Y),countdown:ru.countdown,lastRefreshTime:ru.lastRefreshTime}),S===m.DEVICE_CONTROL&&l(k,{device:ei,onSelect:e=>{if("back"===e.value){I(m.DEVICE_DETAIL),eP(null);return}rc(e.value)},controlling:ek,controlResult:eO}),S===m.DEVICE_SCREENSHOT&&l(w,{device:ei,screenshot:ej,loading:W,error:eF,onSelect:e=>{if("back"===e.value){I(m.DEVICE_DETAIL),e$(null),eV(null);return}"refresh"===e.value?rd(!1):"take"===e.value&&rd(!0)}}),S===m.APPS&&l(L,{apps:ed,loading:W,onSelect:e=>{"back"===e.value?I(m.MAIN):"refresh"===e.value?e8():(ef(null),X(!0),I(m.APP_DETAIL),e3(e.value))}}),S===m.APP_DETAIL&&l(O,{app:eh,loading:W,error:eR,onSelect:e=>{if("back"===e.value){I(m.APPS),ef(null);return}"refresh"===e.value?e3(eh._id):("short_edit"===e.value&&(I(m.APP_SHORT_EDIT),eN(null)),"project_init"===e.value&&(I(m.APP_PROJECT_INIT),eN(null)))}}),S===m.APP_SHORT_EDIT&&l(K,{instanceType:"application",instance:eh,client:N,onDone:a(function*(){return e3(eh._id)}),onCancel:()=>I(m.APP_DETAIL)}),S===m.APP_PROJECT_INIT&&l(eo,{type:"application",instance:eh,client:N,onDone:()=>I(m.APP_DETAIL),onCancel:()=>I(m.APP_DETAIL)}),S===m.MODULES&&l(P,{modules:eg,loading:W,onSelect:e=>{"back"===e.value?I(m.MAIN):"refresh"===e.value?re():(ev(null),X(!0),I(m.MODULE_DETAIL),rr(e.value))}}),S===m.MODULE_DETAIL&&l(M,{module:ey,loading:W,error:eR,onSelect:e=>{if("back"===e.value){I(m.MODULES),ev(null);return}"refresh"===e.value?rr(ey._id):("short_edit"===e.value&&(I(m.MODULE_SHORT_EDIT),eN(null)),"project_init"===e.value&&(I(m.MODULE_PROJECT_INIT),eN(null)))}}),S===m.MODULE_SHORT_EDIT&&l(K,{instanceType:"module",instance:ey,client:N,onDone:a(function*(){return rr(ey._id)}),onCancel:()=>I(m.MODULE_DETAIL)}),S===m.MODULE_PROJECT_INIT&&l(eo,{type:"module",instance:ey,client:N,onDone:()=>I(m.MODULE_DETAIL),onCancel:()=>I(m.MODULE_DETAIL)}),S===m.GROUPS&&l(R,{groups:eb,loading:W,onSelect:e=>{if("back"===e.value)return void I(m.MAIN);if("refresh"===e.value){rt(),rh.resetCountdown();return}eE(null),eB([]),X(!0),I(m.GROUP_DETAIL),rl(e.value)},countdown:rh.countdown,lastRefreshTime:rh.lastRefreshTime}),S===m.GROUP_DETAIL&&l(U,{group:eS,groupDevices:eA,loading:W,error:eR,onSelect:e=>{if("back"===e.value){I(m.GROUPS),eE(null),eB([]);return}"refresh"===e.value&&(rl(eS._id),rf.resetCountdown())},countdown:rf.countdown,lastRefreshTime:rf.lastRefreshTime}),S===m.ACTIVITY_LOG&&l(z,{onBack:()=>I(m.MAIN)}),S===m.MEDIA_BOXES&&l(j,{boxes:ez,loading:W,onSelect:e=>{"back"===e.value?I(m.MAIN):"refresh"===e.value?rn():(eK(null),eQ([]),X(!0),I(m.MEDIA_BOX_DETAIL),ri(e.value))}}),S===m.MEDIA_BOX_DETAIL&&l($,{box:eJ,loading:W,error:eR,onSelect:e=>{if("back"===e.value){I(m.MEDIA_BOXES),eK(null),eQ([]);return}"refresh"===e.value?ri(eJ.id):"files"===e.value&&(eQ([]),e1(null),I(m.MEDIA_FILES),ro(eJ.id))}}),S===m.MEDIA_FILES&&l(G,{files:eX,box:eJ,loading:W,onSelect:e=>{if("back"===e.value){I(m.MEDIA_BOX_DETAIL),e1(null);return}"refresh"===e.value?ro(eJ.id):(e1(null),X(!0),I(m.MEDIA_FILE_DETAIL),ra(e.value))}}),S===m.MEDIA_FILE_DETAIL&&l(F,{file:e0,loading:W,error:eR,onSelect:e=>{if("back"===e.value){I(m.MEDIA_FILES),e1(null);return}"refresh"===e.value&&ra(e0.id)}}),l(b,{})]})};var ec="1"===process.env.BRICKS_CLI_DISTRIBUTION,ed=(o=a(function*(){if(ec)return void(0,d.render)(l(ea,{}));var e=(yield i.e(166).then(i.bind(i,29557))).TerminalInfoProvider;(0,d.render)(l(e,{children:l(ea,{})}))}),function(){return o.apply(this,arguments)})},92642(e,r,t){t.r(r),t.d(r,{ActivityLogClient:()=>_,createActivityLogClient:()=>D});var l,n,i,o=t(99436),a=t(5018),c=t(44668),d=t(4275),s=t(32235),u=t(62192),h=t(79657),f=t(64007);function m(e){var r,t,l,n=2;for("u">typeof Symbol&&(t=Symbol.asyncIterator,l=Symbol.iterator);n--;){if(t&&null!=(r=e[t]))return r.call(e);if(l&&null!=(r=e[l]))return new g(r.call(e));t="@@asyncIterator",l="@@iterator"}throw TypeError("Object is not async iterable")}function g(e){function r(e){if(Object(e)!==e)return Promise.reject(TypeError(e+" is not an object."));var r=e.done;return Promise.resolve(e.value).then(function(e){return{value:e,done:r}})}return(g=function(e){this.s=e,this.n=e.next}).prototype={s:null,n:null,next:function(){return r(this.n.apply(this.s,arguments))},return:function(e){var t=this.s.return;return void 0===t?Promise.resolve({value:e,done:!0}):r(t.apply(this.s,arguments))},throw:function(e){var t=this.s.return;return void 0===t?Promise.reject(e):r(t.apply(this.s,arguments))}},new g(e)}function*p(e){if(e.errors?.length)throw Error(e.errors.map(e=>e.message).join("\n"));if(e.data){for(var r of Object.values(e.data))if(Array.isArray(r))for(var t of r)yield t}if(Array.isArray(e.incremental)){for(var l of e.incremental)if(Array.isArray(l.items))for(var n of l.items)yield n}}function x(){return(x=d(function*(e){var r=e.headers.get("content-type")||"";if(r.includes("application/json")){var t=yield s(e.json());if(t.errors?.length)throw Error(t.errors.map(e=>e.message).join("\n"));var l=Object.keys(t.data||{})[0];if(l&&Array.isArray(t.data[l]))for(var n of t.data[l])yield n;return}var i=r.match(/boundary="?([^";]+)"?/),o=i?i[1]:"-",a=`--${o}`,c="",d=!1,h=new TextDecoder,f=e=>{for(var r=0;-1!==(r=e.indexOf(a,r));){if(0===r||"\n"===e[r-1])return r;r+=a.length}return -1},g=function*(){for(var e;-1!==(e=f(c));){var r=c.slice(0,e);(c=c.slice(e+a.length)).startsWith("\r\n")?c=c.slice(2):c.startsWith("\n")&&(c=c.slice(1));var t=r.indexOf("\r\n\r\n"),l=-1!==t?r.slice(t+4).trim():r.trim();if(l){var n=void 0;try{n=JSON.parse(l)}catch{continue}if(yield*p(n),!1===n.hasNext){d=!0;return}}}};try{var x=!1,y=!1;try{for(var v,T,b=m(e.body);x=!(T=yield s(b.next())).done;x=!1){var _=T.value;if(c+=h.decode(_,{stream:!0}),yield*u(m(g()),s),d)break}}catch(e){y=!0,v=e}finally{try{x&&null!=b.return&&(yield s(b.return()))}finally{if(y)throw v}}}catch(e){if(!e.message?.includes("Premature close")||!d)throw e}if(!d&&c.trim()){var D,S=c.indexOf("\r\n\r\n"),E=-1!==S?c.slice(S+4).trim():c.trim();if(E&&!E.startsWith("--")){try{D=JSON.parse(E)}catch{}D&&(yield*u(m(p(D)),s),!1===D.hasNext&&(d=!0))}}e.body?.destroy()})).apply(this,arguments)}var y=`
2
- query AL_events($filter: EventsFilter!) {
3
- events(filter: $filter) @stream {
4
- device_id
5
- event_type
6
- event_name
7
- subspace_id
8
- sender
9
- payload
10
- timestamp
11
- }
12
- }
13
- `,v=`
14
- query AL_screenshots($filter: ScreenshotFilter!) {
15
- screenshots(filter: $filter) @stream {
16
- timestamp
17
- }
18
- }
19
- `;function T(e){var r,t,l,n=2;for("u">typeof Symbol&&(t=Symbol.asyncIterator,l=Symbol.iterator);n--;){if(t&&null!=(r=e[t]))return r.call(e);if(l&&null!=(r=e[l]))return new b(r.call(e));t="@@asyncIterator",l="@@iterator"}throw TypeError("Object is not async iterable")}function b(e){function r(e){if(Object(e)!==e)return Promise.reject(TypeError(e+" is not an object."));var r=e.done;return Promise.resolve(e.value).then(function(e){return{value:e,done:r}})}return(b=function(e){this.s=e,this.n=e.next}).prototype={s:null,n:null,next:function(){return r(this.n.apply(this.s,arguments))},return:function(e){var t=this.s.return;return void 0===t?Promise.resolve({value:e,done:!0}):r(t.apply(this.s,arguments))},throw:function(e){var t=this.s.return;return void 0===t?Promise.reject(e):r(t.apply(this.s,arguments))}},new b(e)}var _=c(function e(r,t){a(this,e),this.baseUrl=r,this.token=t,this.graphqlUrl=`${r}/api/graphql`,this.fetch=function(e){var r=process.env.HTTPS_PROXY||process.env.https_proxy;if(!r||!e.startsWith("https://"))return h.Ay;var t=new f(r);return(e,r={})=>(0,h.Ay)(e,{...r,agent:t})}(r)},[{key:"streamQuery",value:function(e,r){var t=this;return d(function*(e,r,{signal:l}={}){var n=yield s(t.fetch(t.graphqlUrl,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t.token}`,Accept:'multipart/mixed; boundary="-", application/json'},body:JSON.stringify({query:e,variables:r}),signal:l}));if(!n.ok){var i=yield s(n.text().catch(()=>""));throw Error(`Activity-log query failed (${n.status}): ${i}`)}yield*u(T(function(e){return x.apply(this,arguments)}(n)),s)}).apply(this,arguments)}},{key:"events",value:function(e,r){var t=this;return d(function*(){yield*u(T(t.streamQuery(y,{filter:e},r)),s)})()}},{key:"screenshots",value:function(e,r){var t=this;return d(function*(){yield*u(T(t.streamQuery(v,{filter:e},r)),s)})()}},{key:"collectEvents",value:(l=o(function*(e,{limit:r,signal:t}={}){var l=[],n=!1,i=!1;try{for(var o,a,c=T(this.events(e,{signal:t}));n=!(a=yield c.next()).done;n=!1){var d=a.value;if(l.push(d),r&&l.length>=r)break}}catch(e){i=!0,o=e}finally{try{n&&null!=c.return&&(yield c.return())}finally{if(i)throw o}}return l}),function(e){return l.apply(this,arguments)})},{key:"collectScreenshots",value:(n=o(function*(e,{signal:r}={}){var t=[],l=!1,n=!1;try{for(var i,o,a=T(this.screenshots(e,{signal:r}));l=!(o=yield a.next()).done;l=!1){var c=o.value;t.push(c)}}catch(e){n=!0,i=e}finally{try{l&&null!=a.return&&(yield a.return())}finally{if(n)throw i}}return t}),function(e){return n.apply(this,arguments)})},{key:"downloadScreenshot",value:(i=o(function*(e,r,t,{signal:l}={}){var n=`${this.baseUrl}/api/v1/${encodeURIComponent(e)}/${encodeURIComponent(r)}/screenshot?ts=${encodeURIComponent(t)}`,i=yield this.fetch(n,{headers:{Authorization:`Bearer ${this.token}`},signal:l});if(!i.ok){var o=yield i.text().catch(()=>"");throw Error(`Screenshot fetch failed (${i.status}): ${o}`)}return Buffer.from((yield i.arrayBuffer()))}),function(e,r,t){return i.apply(this,arguments)})}]),D=(e,r)=>new _(e,r)},77768(e,r,t){t.d(r,{BZ:()=>v,KN:()=>p,kU:()=>g,o0:()=>y,oz:()=>x});var l,n,i,o,a=t(99436),c=t(16928),d=t(79896),s=t(35317),u=t(10750),h=e=>{try{return(0,s.execSync)(`which ${e}`,{stdio:"ignore"}),!0}catch{return!1}},f=(e,r,t)=>new Promise((l,n)=>{var i=[e,...r].join(" "),o=(0,s.spawn)(i,[],{cwd:t,stdio:"pipe",shell:!0}),a=[];o.stderr.on("data",e=>a.push(e)),o.on("close",e=>{0===e?l():n(Error(Buffer.concat(a).toString().trim()||`Command failed with code ${e}`))}),o.on("error",n)}),m=(l=a(function*(e,r){try{var l=(yield t.e(75).then(t.bind(t,79491))).format;return(yield l(r,e,{trailingComma:"all",tabWidth:2,semi:!1,singleQuote:!0,printWidth:100})).code}catch{}return e}),function(e,r){return l.apply(this,arguments)}),g=(e=[])=>{var r=e.find(e=>"application.json"===e.name);if(!r)return"bricks-ctor";try{var t=JSON.parse(r.input);return u(t.name||"bricks-ctor")}catch{return"bricks-ctor"}},p=(n=a(function*(e,r){var t;return Promise.all(e.map((t=a(function*(e){var t=c.join(r,e.name),l=e.input;return e.formatable&&(l=yield m(l,t)),{...e,filePath:t,content:l}}),function(e){return t.apply(this,arguments)})))}),function(e,r){return n.apply(this,arguments)}),x=e=>{e.forEach(e=>{d.mkdirSync(c.dirname(e.filePath),{recursive:!0}),d.writeFileSync(e.filePath,e.content)})},y=(i=a(function*(e,r={}){var t="function"==typeof r.onStatus?r.onStatus:()=>{},l=!1,n=!1;if(!1!==r.install&&h("bun")){t("Installing dependencies (bun install)...");try{yield f("bun",["install"],e),l=!0}catch{}}if(!1!==r.git&&h("git")){t("Initializing git repository...");try{yield f("git",["init"],e),yield f("git",["add","."],e),yield f("git",["-c 'user.name=BRICKS CLI'","-c 'user.email=cli@bricks.tools'","commit","-m 'chore: initialize commit'"],e),n=!0}catch{}}return{bunInstalled:l,gitInitialized:n}}),function(e){return i.apply(this,arguments)}),v=(o=a(function*(e,r,t){var l=t.client,n=t.output,i=t.outputAsTarget;if(!l)throw Error("client is required");if(!n)throw Error("output directory is required");var o=(e=>{for(var r=c.resolve(e);;){if(d.existsSync(c.join(r,"application.json"))||d.existsSync(c.join(r,"module.json")))return r;var t=c.dirname(r);if(t===r)return null;r=t}})(i?c.dirname(c.resolve(n)):n);if(o)throw Error(`Cannot initialize a new BRICKS project inside an existing project (${o}). Choose a directory outside the project.`);var a="application"===e?l.applicationProject:l.moduleProject,s=yield a({id:r,buildApplicationOnly:!1,setupGitHubActions:!1!==t.githubActions,setupAgents:!1!==t.agents,setupClaudeCode:!1!==t.claude,setupGeminiCLI:!0===t.gemini});if(!s?.files)throw Error(`${e} project not found`);var u=g(s.files),h=i?c.resolve(n):c.resolve(n,u);if(d.existsSync(h))throw Error(`Directory already exists: ${h}`);d.mkdirSync(h,{recursive:!0}),x((yield p(s.files,h)));var f=yield y(h,t),m=f.bunInstalled,v=f.gitInitialized;return{success:!0,path:h,files:s.files.length,bunInstalled:m,gitInitialized:v}}),function(e,r,t){return o.apply(this,arguments)})},60450(e,r,t){t.r(r),t.d(r,{buildScreenshotUrl:()=>m,downloadScreenshot:()=>g,fetchAndSaveScreenshot:()=>p,getDeviceScreenshot:()=>f,getSystemMediaBoxId:()=>h,isMediaEnabled:()=>u});var l,n,i,o=t(99436),a=t(79657),c=t(73024),d=t(76760),s=t(48161),u=e=>e?.media_resource?.enable_media_workspace===!0,h=e=>u(e)&&e.media_resource?.system_media_box_id||null,f=(l=o(function*(e,r,t){var l=yield e.mediaFiles({boxId:r,userTags:[`bricks_screenshot_${t}`],limit:1});return l?.[0]||null}),function(e,r,t){return l.apply(this,arguments)}),m=(e,{preferThumbnail:r=!1}={})=>{if(!e?.meta?.storageEndpoint)return null;var t=e.meta,l=t.storageEndpoint,n=t.originalFileKey,i=(r?(e=>{var r=e?.meta;if(!r)return null;if("Video"===e.fileType&&r.videoThumbOriginalFileKey)return r.videoThumbOriginalFileKey;var t=r.imageVersions||[];if(!Array.isArray(t)||0===t.length)return null;var l=t.filter(e=>e?.strategy==="BOUNDED"&&"number"==typeof e.width).sort((e,r)=>e.width-r.width);return(l[0]||t[0])?.key||null})(e):null)||n;return i?`${l}/${i}`:null},g=(n=o(function*(e,r=null){var t=yield(0,a.Ay)(e);if(!t.ok)throw Error(`Failed to download screenshot: ${t.statusText}`);var l=yield t.buffer(),n=r||d.join(s.tmpdir(),`bricks-screenshot-${Date.now()}.png`),i=d.dirname(n);return c.existsSync(i)||c.mkdirSync(i,{recursive:!0}),c.writeFileSync(n,l),n}),function(e){return n.apply(this,arguments)}),p=(i=o(function*(e,r,t,l=null,n={}){var i=h(r);if(!i)return{error:"Media workspace not enabled for this workspace"};var o=yield f(e,i,t);if(!o)return{error:"No screenshot available for this device"};var a=m(o,n);return a?{path:yield g(a,l),file:o,url:a}:{error:"Could not build screenshot URL"}}),function(e,r,t){return i.apply(this,arguments)})}};