@fugood/bricks-cli 2.24.0-beta.2 → 2.24.0-beta.20
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/356.js +1 -0
- package/lib/44.js +1 -0
- package/lib/465.js +1 -0
- package/lib/612.js +1 -0
- package/lib/890.js +1 -0
- package/lib/index.js +531 -456
- package/package.json +21 -13
- package/lib/153.index.js +0 -1
- package/lib/612.index.js +0 -1
- package/lib/616.index.js +0 -1
package/lib/44.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const __webpack_esm_id__=44;export const __webpack_esm_ids__=[44];export const __webpack_esm_modules__={2044:(r,e,t)=>{t.r(e),t.d(e,{discoverDevToolsServers:()=>d,httpProbeSubnet:()=>l,verifyDevToolsServer:()=>f});var o,a,n=t(9436),s=t(1314),i=t(8161),u="bricks-devtools",c=()=>{var r=[],e=i.networkInterfaces();for(var t of Object.values(e)){var o=function(){if("IPv4"!==a.family||a.internal)return 1;var e=a.address.split(".").map(Number),t=a.netmask.split(".").map(Number),o=e.map((r,e)=>(r|255&~t[e]).toString()).join(".");r.push({address:a.address,broadcast:o})};for(var a of t)o()}return r},d=({timeout:r=3e3}={})=>new Promise((e,t)=>{var o=new Map,a=s.createSocket("udp4"),n=()=>{try{a.close()}catch{}};a.on("error",r=>{n(),t(r)}),a.on("message",(r,e)=>{try{var t=JSON.parse(r.toString());if(t.s!==u)return;if("ANNOUNCE"!==t.t&&"RESPONSE"!==t.t)return;var a=t.d?.info;if(!a)return;var n=e.address,s=`${n}:${a.port}`;o.has(s)||o.set(s,{...a,address:n})}catch{}}),a.bind(()=>{a.setBroadcast(!0);var t=Buffer.from(JSON.stringify({t:"QUERY",v:"1.0",s:u,d:{id:`cli-${Math.random().toString(36).substring(2,9)}`}})),s=new Set(["255.255.255.255","127.0.0.1"]);for(var i of c())s.add(i.broadcast);for(var d of s)a.send(t,0,t.length,19900,d);setTimeout(()=>{n(),e([...o.values()])},r)})}),l=(o=n(function*({port:r=19851,connectTimeout:e=500,concurrency:t=50}={}){var o=c();if(0===o.length)return[];var a=[],s=[],i=new Set;for(var u of o){var d=u.address.split(".").slice(0,3).join(".");if(!i.has(d)){i.add(d);for(var l=1;l<255;l++)s.push(`${d}.${l}`)}}for(var v=0;v<s.length;v+=t){var p=s.slice(v,v+t);yield Promise.allSettled(p.map(function(){var t=n(function*(t){var o=yield f(t,r,e);o&&a.push({...o,address:t,port:r})});return function(r){return t.apply(this,arguments)}}()))}return a}),function(){return o.apply(this,arguments)}),f=(a=n(function*(r,e,t=3e3){try{var o=new AbortController,a=setTimeout(()=>o.abort(),t),n=yield fetch(`http://${r}:${e}/devtools/info`,{signal:o.signal});return clearTimeout(a),n.ok?yield n.json():null}catch{return null}}),function(r,e){return a.apply(this,arguments)})}};
|
package/lib/465.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const __webpack_esm_id__=465;export const __webpack_esm_ids__=[465];export const __webpack_esm_modules__={6465:(e,i,t)=>{t.d(i,{initProject:()=>w}),t.r(i);var n,r,o=t(9436),l=t(6928),c=t(8568),a=t(9790),s=t(750),u=t(637),d=t(4752),p=t(700),g=t(9896),y=t(5317),m=e=>{try{return(0,y.execSync)(`which ${e}`,{stdio:"ignore"}),!0}catch{return!1}},f=(e,i,t)=>new Promise((n,r)=>{var o=[e,...i].join(" "),l=(0,y.spawn)(o,[],{cwd:t,stdio:"pipe",shell:!0}),c=[];l.stderr.on("data",e=>c.push(e)),l.on("close",e=>{if(0===e)n();else{var i=Buffer.concat(c).toString().trim();r(new Error(i||`Command failed with code ${e}`))}}),l.on("error",r)}),h=(n=o(function*(e,i){try{var n=(yield Promise.resolve().then(t.bind(t,9491))).format;return(yield n(i,e,{trailingComma:"all",tabWidth:2,semi:!1,singleQuote:!0,printWidth:100})).code}catch{}return e}),function(e,i){return n.apply(this,arguments)}),v=(r=o(function*(e,i,t){var n=t.client,r=t.output;if(!n)throw new Error("client is required");if(!r)throw new Error("output directory is required");var c="application"===e,a=c?"UNSTABLE_applicationProject":"UNSTABLE_moduleProject",u=c?n.queries.applicationProject:n.queries.moduleProject,d=(yield n.query(u,{id:i,buildApplicationOnly:!1,setupGitHubActions:!1!==t.githubActions,setupAgents:!1!==t.agents,setupClaudeCode:!1!==t.claude,setupGeminiCLI:!0===t.gemini}))[a];if(!d?.files)throw new Error(`${e} project not found`);var p="bricks-project",y=d.files.find(e=>"application.json"===e.name);if(y)try{var v=JSON.parse(y.input);p=s(v.name||"bricks-project")}catch{}var b=l.resolve(r,p);if(g.existsSync(b))throw new Error(`Directory already exists: ${b}`);g.mkdirSync(b,{recursive:!0});var A,w=yield Promise.all(d.files.map((A=o(function*(e){var i=l.join(b,e.name),t=e.input;return e.formatable&&(t=yield h(t,i)),{...e,filePath:i,content:t}}),function(e){return A.apply(this,arguments)})));w.forEach(e=>{var i=l.dirname(e.filePath);g.existsSync(i)||g.mkdirSync(i,{recursive:!0}),g.writeFileSync(e.filePath,e.content)});var j=m("bun"),k=m("git"),_=!1,S=!1;if(!1!==t.install&&j)try{yield f("bun",["install"],b),_=!0}catch{}if(!1!==t.git&&k)try{yield f("git",["init"],b),yield f("git",["add","."],b),yield f("git",["-c 'user.name=BRICKS CLI'","-c 'user.email=cli@bricks.tools'","commit","-m 'chore: initialize commit'"],b),S=!0}catch{}return{success:!0,path:b,files:d.files.length,bunInstalled:_,gitInitialized:S}}),function(e,i,t){return r.apply(this,arguments)}),b=()=>{var e=(0,d.getCurrentProfile)(),i=(0,d.getToken)(e);return i||(console.error(c.Ay.red("Not logged in. Use `bricks auth login` first.")),process.exit(1)),(0,p.createClient)((0,d.getBaseUrl)(),i)},A=function(){var e=o(function*(e,i){console.log(c.Ay.bold.cyan(`\nInitialize BRICKS Project: ${i}\n`));var t=yield(0,u.kv)({message:"Select files to include:",choices:[{name:"GitHub Actions workflow (.github/workflows/ci.yml)",value:"githubActions",checked:!1!==e.githubActions},{name:"AGENTS.md",value:"agents",checked:!1!==e.agents},{name:"CLAUDE.md",value:"claude",checked:!1!==e.claude},{name:"GEMINI.md",value:"gemini",checked:!0===e.gemini}]}),n=yield(0,u.kv)({message:"Select post-generation steps:",choices:[{name:"Run bun install",value:"install",checked:!1!==e.install},{name:"Initialize git repository",value:"git",checked:!1!==e.git}]}),r=yield(0,u.hF)({message:"Output directory:",default:e.output||process.cwd()});return{githubActions:t.includes("githubActions"),agents:t.includes("agents"),claude:t.includes("claude"),gemini:t.includes("gemini"),install:n.includes("install"),git:n.includes("git"),output:r}});return function(i,t){return e.apply(this,arguments)}}(),w=function(){var e=o(function*(e,i,t){var n=b(),r=t.json,o=t.yes||r,u="application"===e,d=u?"UNSTABLE_applicationProject":"UNSTABLE_moduleProject",p=u?n.queries.applicationProject:n.queries.moduleProject,g=r?null:(0,a.default)(`Fetching ${e} info...`).start(),y="bricks-project";try{var m=(yield n.query(p,{id:i,buildApplicationOnly:!0}))[d];if(m?.files){var f=m.files.find(e=>"application.json"===e.name);if(f)try{var h=JSON.parse(f.input);y=s(h.name||"bricks-project")}catch{}}g&&g.stop()}catch{g&&g.stop()}var w={...t};if(!o)try{var j=yield A(t,y);w={...t,...j}}catch{console.log(c.Ay.yellow("\nCancelled")),process.exit(0)}g=r?null:(0,a.default)(`Fetching ${e} project...`).start();try{var k=yield v(e,i,{client:n,output:w.output||process.cwd(),install:w.install,git:w.git,githubActions:w.githubActions,agents:w.agents,claude:w.claude,gemini:w.gemini});g&&g.succeed(`Project created: ${c.Ay.green(k.path)} (${k.files} files)`),r?console.log(JSON.stringify(k)):(console.log(""),console.log(c.Ay.bold.green("Project initialized successfully!")),console.log(""),console.log(c.Ay.bold("Next steps:")),console.log(c.Ay.gray(` cd ${l.basename(k.path)}`)),k.bunInstalled||console.log(c.Ay.gray(" bun install")),console.log(c.Ay.gray(" bun preview")),console.log(""),console.log(c.Ay.gray(`For more information, see ${l.basename(k.path)}/README.md`)))}catch(i){r?console.error(JSON.stringify({error:i.message})):g?g.fail(`Failed to initialize ${e} project: ${i.message}`):console.error(c.Ay.red(`Failed to initialize ${e} project: ${i.message}`)),process.exit(1)}});return function(i,t,n){return e.apply(this,arguments)}}()}};
|
package/lib/612.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const __webpack_esm_id__=612;export const __webpack_esm_ids__=[612];export const __webpack_esm_modules__={750:(e,l,t)=>{var n=t(3640)(function(e,l,t){return e+(t?"-":"")+l.toLowerCase()});e.exports=n},9612:(e,l,t)=>{t.d(l,{App:()=>je,AppDetail:()=>V,AppList:()=>G,CONTROL_ACTIONS:()=>x,DeviceControl:()=>M,DeviceDetail:()=>P,DeviceList:()=>O,DeviceScreenshot:()=>N,DeviceStatus:()=>v,Footer:()=>T,GroupDetail:()=>z,GroupList:()=>$,Header:()=>D,Loading:()=>b,MainMenu:()=>U,MediaBoxDetail:()=>W,MediaBoxList:()=>Y,MediaFileDetail:()=>J,MediaFileList:()=>X,ModuleDetail:()=>H,ModuleList:()=>F,ONLINE_THRESHOLD_MS:()=>h,ProjectInitView:()=>pe,ShortEditEditor:()=>ne,VIEWS:()=>u,runInteractiveMode:()=>De}),t.r(l);var n=t(1649),i=t(8498),o=t(9557),r=t(9436),a=t(8832),s=t(700),c=t(4752),d=t(7336),u={MAIN:"main",DEVICES:"devices",DEVICE_DETAIL:"device_detail",DEVICE_CONTROL:"device_control",DEVICE_SCREENSHOT:"device_screenshot",APPS:"apps",APP_DETAIL:"app_detail",APP_SHORT_EDIT:"app_short_edit",APP_PROJECT_INIT:"app_project_init",MODULES:"modules",MODULE_DETAIL:"module_detail",MODULE_SHORT_EDIT:"module_short_edit",MODULE_PROJECT_INIT:"module_project_init",GROUPS:"groups",GROUP_DETAIL:"group_detail",MEDIA_BOXES:"media_boxes",MEDIA_BOX_DETAIL:"media_box_detail",MEDIA_FILES:"media_files",MEDIA_FILE_DETAIL:"media_file_detail"},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"}],h=3e5,g=t(7661);const f=function({type:e="dots"}){const[l,t]=(0,n.useState)(0),o=g[e];return(0,n.useEffect)(()=>{const e=setInterval(()=>{t(e=>e===o.frames.length-1?0:e+1)},o.interval);return()=>{clearInterval(e)}},[o]),n.default.createElement(i.Text,null,o.frames[l])};var m=t(1178),p=(e,l=!0)=>{var t=Math.floor(60),i=(0,n.useState)(t),o=a(i,2),r=o[0],s=o[1],c=(0,n.useState)(null),d=a(c,2),u=d[0],x=d[1],h=(0,n.useRef)(e);(0,n.useEffect)(()=>{h.current=e},[e]);var g=(0,n.useCallback)(()=>{s(t),x(Date.now())},[t]);return(0,n.useEffect)(()=>{if(l){var e=setInterval(()=>{s(e=>e<=1?(h.current?.(),x(Date.now()),t):e-1)},1e3);return()=>clearInterval(e)}},[l,t]),(0,n.useEffect)(()=>{l&&(s(t),x(Date.now()))},[l,t]),{countdown:r,lastRefreshTime:u,resetCountdown:g}},j=({countdown:e,lastRefreshTime:l})=>(0,m.jsx)(i.Box,{children:(0,m.jsxs)(i.Text,{color:"gray",children:["Next refresh in ",(0,m.jsxs)(i.Text,{color:"cyan",children:[e,"s"]}),l&&(0,m.jsxs)(i.Text,{color:"gray",children:[" (last: ",l?new Date(l).toLocaleTimeString():null,")"]})]})}),D=({workspace:e,view:l})=>(0,m.jsxs)(i.Box,{flexDirection:"column",marginBottom:1,children:[(0,m.jsxs)(i.Box,{children:[(0,m.jsx)(i.Text,{bold:!0,color:"cyan",children:"BRICKS CLI"}),(0,m.jsx)(i.Text,{color:"gray",children:" - Interactive Mode"})]}),(0,m.jsxs)(i.Box,{children:[(0,m.jsx)(i.Text,{color:"gray",children:"Workspace: "}),(0,m.jsx)(i.Text,{color:"green",children:e?.name||"Not connected"}),(0,m.jsx)(i.Text,{color:"gray",children:" | View: "}),(0,m.jsx)(i.Text,{color:"yellow",children:l})]}),(0,m.jsx)(i.Text,{color:"gray",children:"─".repeat(60)})]}),T=()=>(0,m.jsxs)(i.Box,{marginTop:1,flexDirection:"column",children:[(0,m.jsx)(i.Text,{color:"gray",children:"─".repeat(60)}),(0,m.jsxs)(i.Text,{color:"gray",children:["Press ",(0,m.jsx)(i.Text,{color:"cyan",children:"q"})," to quit, ",(0,m.jsx)(i.Text,{color:"cyan",children:"Esc"})," to go back"]})]}),b=({text:e})=>(0,m.jsxs)(i.Box,{children:[(0,m.jsx)(i.Text,{color:"green",children:(0,m.jsx)(f,{type:"dots"})}),(0,m.jsxs)(i.Text,{children:[" ",e||"Loading..."]})]}),v=({lastAliveTime:e})=>{if(!e)return(0,m.jsx)(i.Text,{color:"gray",children:"○ Unknown"});var l=Date.now()-new Date(e).getTime();if(l<=h)return(0,m.jsx)(i.Text,{color:"green",children:"● Online"});var t=Math.floor(l/6e4);if(t<60)return(0,m.jsxs)(i.Text,{color:"yellow",children:["○ Offline (",t,"m ago)"]});var n=Math.floor(t/60);if(n<24)return(0,m.jsxs)(i.Text,{color:"red",children:["○ Offline (",n,"h ago)"]});var o=Math.floor(n/24);return(0,m.jsxs)(i.Text,{color:"red",children:["○ Offline (",o,"d ago)"]})},_=t(9122);const y={circleQuestionMark:"(?)",questionMarkPrefix:"(?)",square:"█",squareDarkShade:"▓",squareMediumShade:"▒",squareLightShade:"░",squareTop:"▀",squareBottom:"▄",squareLeft:"▌",squareRight:"▐",squareCenter:"■",bullet:"●",dot:"․",ellipsis:"…",pointerSmall:"›",triangleUp:"▲",triangleUpSmall:"▴",triangleDown:"▼",triangleDownSmall:"▾",triangleLeftSmall:"◂",triangleRightSmall:"▸",home:"⌂",heart:"♥",musicNote:"♪",musicNoteBeamed:"♫",arrowUp:"↑",arrowDown:"↓",arrowLeft:"←",arrowRight:"→",arrowLeftRight:"↔",arrowUpDown:"↕",almostEqual:"≈",notEqual:"≠",lessOrEqual:"≤",greaterOrEqual:"≥",identical:"≡",infinity:"∞",subscriptZero:"₀",subscriptOne:"₁",subscriptTwo:"₂",subscriptThree:"₃",subscriptFour:"₄",subscriptFive:"₅",subscriptSix:"₆",subscriptSeven:"₇",subscriptEight:"₈",subscriptNine:"₉",oneHalf:"½",oneThird:"⅓",oneQuarter:"¼",oneFifth:"⅕",oneSixth:"⅙",oneEighth:"⅛",twoThirds:"⅔",twoFifths:"⅖",threeQuarters:"¾",threeFifths:"⅗",threeEighths:"⅜",fourFifths:"⅘",fiveSixths:"⅚",fiveEighths:"⅝",sevenEighths:"⅞",line:"─",lineBold:"━",lineDouble:"═",lineDashed0:"┄",lineDashed1:"┅",lineDashed2:"┈",lineDashed3:"┉",lineDashed4:"╌",lineDashed5:"╍",lineDashed6:"╴",lineDashed7:"╶",lineDashed8:"╸",lineDashed9:"╺",lineDashed10:"╼",lineDashed11:"╾",lineDashed12:"−",lineDashed13:"–",lineDashed14:"‐",lineDashed15:"⁃",lineVertical:"│",lineVerticalBold:"┃",lineVerticalDouble:"║",lineVerticalDashed0:"┆",lineVerticalDashed1:"┇",lineVerticalDashed2:"┊",lineVerticalDashed3:"┋",lineVerticalDashed4:"╎",lineVerticalDashed5:"╏",lineVerticalDashed6:"╵",lineVerticalDashed7:"╷",lineVerticalDashed8:"╹",lineVerticalDashed9:"╻",lineVerticalDashed10:"╽",lineVerticalDashed11:"╿",lineDownLeft:"┐",lineDownLeftArc:"╮",lineDownBoldLeftBold:"┓",lineDownBoldLeft:"┒",lineDownLeftBold:"┑",lineDownDoubleLeftDouble:"╗",lineDownDoubleLeft:"╖",lineDownLeftDouble:"╕",lineDownRight:"┌",lineDownRightArc:"╭",lineDownBoldRightBold:"┏",lineDownBoldRight:"┎",lineDownRightBold:"┍",lineDownDoubleRightDouble:"╔",lineDownDoubleRight:"╓",lineDownRightDouble:"╒",lineUpLeft:"┘",lineUpLeftArc:"╯",lineUpBoldLeftBold:"┛",lineUpBoldLeft:"┚",lineUpLeftBold:"┙",lineUpDoubleLeftDouble:"╝",lineUpDoubleLeft:"╜",lineUpLeftDouble:"╛",lineUpRight:"└",lineUpRightArc:"╰",lineUpBoldRightBold:"┗",lineUpBoldRight:"┖",lineUpRightBold:"┕",lineUpDoubleRightDouble:"╚",lineUpDoubleRight:"╙",lineUpRightDouble:"╘",lineUpDownLeft:"┤",lineUpBoldDownBoldLeftBold:"┫",lineUpBoldDownBoldLeft:"┨",lineUpDownLeftBold:"┥",lineUpBoldDownLeftBold:"┩",lineUpDownBoldLeftBold:"┪",lineUpDownBoldLeft:"┧",lineUpBoldDownLeft:"┦",lineUpDoubleDownDoubleLeftDouble:"╣",lineUpDoubleDownDoubleLeft:"╢",lineUpDownLeftDouble:"╡",lineUpDownRight:"├",lineUpBoldDownBoldRightBold:"┣",lineUpBoldDownBoldRight:"┠",lineUpDownRightBold:"┝",lineUpBoldDownRightBold:"┡",lineUpDownBoldRightBold:"┢",lineUpDownBoldRight:"┟",lineUpBoldDownRight:"┞",lineUpDoubleDownDoubleRightDouble:"╠",lineUpDoubleDownDoubleRight:"╟",lineUpDownRightDouble:"╞",lineDownLeftRight:"┬",lineDownBoldLeftBoldRightBold:"┳",lineDownLeftBoldRightBold:"┯",lineDownBoldLeftRight:"┰",lineDownBoldLeftBoldRight:"┱",lineDownBoldLeftRightBold:"┲",lineDownLeftRightBold:"┮",lineDownLeftBoldRight:"┭",lineDownDoubleLeftDoubleRightDouble:"╦",lineDownDoubleLeftRight:"╥",lineDownLeftDoubleRightDouble:"╤",lineUpLeftRight:"┴",lineUpBoldLeftBoldRightBold:"┻",lineUpLeftBoldRightBold:"┷",lineUpBoldLeftRight:"┸",lineUpBoldLeftBoldRight:"┹",lineUpBoldLeftRightBold:"┺",lineUpLeftRightBold:"┶",lineUpLeftBoldRight:"┵",lineUpDoubleLeftDoubleRightDouble:"╩",lineUpDoubleLeftRight:"╨",lineUpLeftDoubleRightDouble:"╧",lineUpDownLeftRight:"┼",lineUpBoldDownBoldLeftBoldRightBold:"╋",lineUpDownBoldLeftBoldRightBold:"╈",lineUpBoldDownLeftBoldRightBold:"╇",lineUpBoldDownBoldLeftRightBold:"╊",lineUpBoldDownBoldLeftBoldRight:"╉",lineUpBoldDownLeftRight:"╀",lineUpDownBoldLeftRight:"╁",lineUpDownLeftBoldRight:"┽",lineUpDownLeftRightBold:"┾",lineUpBoldDownBoldLeftRight:"╂",lineUpDownLeftBoldRightBold:"┿",lineUpBoldDownLeftBoldRight:"╃",lineUpBoldDownLeftRightBold:"╄",lineUpDownBoldLeftBoldRight:"╅",lineUpDownBoldLeftRightBold:"╆",lineUpDoubleDownDoubleLeftDoubleRightDouble:"╬",lineUpDoubleDownDoubleLeftRight:"╫",lineUpDownLeftDoubleRightDouble:"╪",lineCross:"╳",lineBackslash:"╲",lineSlash:"╱"},B={tick:"✔",info:"ℹ",warning:"⚠",cross:"✘",squareSmall:"◻",squareSmallFilled:"◼",circle:"◯",circleFilled:"◉",circleDotted:"◌",circleDouble:"◎",circleCircle:"ⓞ",circleCross:"ⓧ",circlePipe:"Ⓘ",radioOn:"◉",radioOff:"◯",checkboxOn:"☒",checkboxOff:"☐",checkboxCircleOn:"ⓧ",checkboxCircleOff:"Ⓘ",pointer:"❯",triangleUpOutline:"△",triangleLeft:"◀",triangleRight:"▶",lozenge:"◆",lozengeOutline:"◇",hamburger:"☰",smiley:"㋡",mustache:"෴",star:"★",play:"▶",nodejs:"⬢",oneSeventh:"⅐",oneNinth:"⅑",oneTenth:"⅒"},S={...y,...B},E={...y,tick:"√",info:"i",warning:"‼",cross:"×",squareSmall:"□",squareSmallFilled:"■",circle:"( )",circleFilled:"(*)",circleDotted:"( )",circleDouble:"( )",circleCircle:"(○)",circleCross:"(×)",circlePipe:"(│)",radioOn:"(*)",radioOff:"( )",checkboxOn:"[×]",checkboxOff:"[ ]",checkboxCircleOn:"(×)",checkboxCircleOff:"( )",pointer:">",triangleUpOutline:"∆",triangleLeft:"◄",triangleRight:"►",lozenge:"♦",lozengeOutline:"◊",hamburger:"≡",smiley:"☺",mustache:"┌─┐",star:"✶",play:"►",nodejs:"♦",oneSeventh:"1/7",oneNinth:"1/9",oneTenth:"1/10"},w=(0,_.A)(),L=w?S:E;Object.entries(B);const I=function({isSelected:e=!1}){return n.default.createElement(i.Box,{marginRight:1},e?n.default.createElement(i.Text,{color:"blue"},L.pointer):n.default.createElement(i.Text,null," "))};const A=function({isSelected:e=!1,label:l}){return n.createElement(i.Text,{color:e?"blue":void 0},l)};var C=t(7975);function R(e,l){if(!Array.isArray(e))throw new TypeError(`Expected an array, got \`${typeof e}\`.`);if(!Number.isSafeInteger(l))throw new TypeError(`The \`steps\` parameter must be an integer, got ${l}.`);const{length:t}=e;if(0===t)return[...e];const n=(l%t+t)%t;return 0===n?[...e]:[...e.slice(-n),...e.slice(0,-n)]}const k=function({items:e=[],isFocused:l=!0,initialIndex:t=0,indicatorComponent:o=I,itemComponent:r=A,limit:a,onSelect:s,onHighlight:c}){const d="number"==typeof a&&e.length>a,u=d?Math.min(a,e.length):e.length,x=u-1,[h,g]=(0,n.useState)(t>x?x-t:0),[f,m]=(0,n.useState)(t?t>x?x:t:0),p=(0,n.useRef)(e);(0,n.useEffect)(()=>{(0,C.isDeepStrictEqual)(p.current.map(e=>e.value),e.map(e=>e.value))||(g(0),m(0)),p.current=e},[e]),(0,i.useInput)((0,n.useCallback)((l,t)=>{if("k"===l||t.upArrow){const l=(d?u:e.length)-1,t=0===f,n=t?h+1:h,i=t?d?f:l:f-1;g(n),m(i);const o=d?R(e,n).slice(0,u):e;"function"==typeof c&&c(o[i])}if("j"===l||t.downArrow){const l=f===(d?u:e.length)-1,t=l?h-1:h,n=l?d?f:0:f+1;g(t),m(n);const i=d?R(e,t).slice(0,u):e;"function"==typeof c&&c(i[n])}if(/^[1-9]$/.test(l)){const t=Number.parseInt(l,10)-1,n=d?R(e,h).slice(0,u):e;if(t>=0&&t<n.length){const e=n[t];e&&s?.(e)}}if(t.return){const l=d?R(e,h).slice(0,u):e;"function"==typeof s&&s(l[f])}},[d,u,h,f,e,s,c]),{isActive:l});const j=d?R(e,h).slice(0,u):e;return n.default.createElement(i.Box,{flexDirection:"column"},j.map((e,l)=>{const t=l===f;return n.default.createElement(i.Box,{key:e.key??e.value},n.default.createElement(o,{isSelected:t}),n.default.createElement(r,{...e,isSelected:t}))}))};var U=({onSelect:e,mediaEnabled:l})=>{var t=[{label:"Devices",value:u.DEVICES},{label:"Applications",value:u.APPS},{label:"Modules",value:u.MODULES},{label:"Device Groups",value:u.GROUPS},...l?[{label:"Media Flow",value:u.MEDIA_BOXES}]:[],{label:"Exit",value:"exit"}];return(0,m.jsxs)(i.Box,{flexDirection:"column",children:[(0,m.jsx)(i.Text,{bold:!0,marginBottom:1,children:"Main Menu"}),(0,m.jsx)(k,{items:t,onSelect:e})]})},O=({devices:e,loading:l,onSelect:t,countdown:n,lastRefreshTime:o})=>{if(l)return(0,m.jsx)(b,{text:"Loading devices..."});if(!e?.length)return(0,m.jsxs)(i.Box,{flexDirection:"column",children:[(0,m.jsx)(i.Text,{color:"yellow",children:"No devices found"}),(0,m.jsx)(j,{countdown:n,lastRefreshTime:o})]});var r=[...e.map(e=>({label:`${(e=>{if(!e)return"○ Unknown";var l=Date.now()-new Date(e).getTime();if(l<=h)return"● Online";var t=Math.floor(l/6e4);if(t<60)return`○ ${t}m ago`;var n=Math.floor(t/60);return n<24?`○ ${n}h ago`:`○ ${Math.floor(n/24)}d ago`})(e.entry_detail?.watch_dog_timer?.last_alive_time)} - ${e.name||e.device_name}`,value:e._id,device:e})),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return(0,m.jsxs)(i.Box,{flexDirection:"column",children:[(0,m.jsxs)(i.Box,{marginBottom:1,children:[(0,m.jsxs)(i.Text,{bold:!0,children:["Devices (",e.length,")"]}),(0,m.jsx)(i.Text,{color:"gray",children:" - "}),(0,m.jsx)(j,{countdown:n,lastRefreshTime:o})]}),(0,m.jsx)(k,{items:r,onSelect:t})]})},P=({device:e,loading:l,error:t,onSelect:n,mediaEnabled:o,countdown:r,lastRefreshTime:a})=>{if(l)return(0,m.jsx)(b,{text:"Loading device..."});if(t)return(0,m.jsxs)(i.Box,{flexDirection:"column",children:[(0,m.jsxs)(i.Text,{color:"red",children:["Error: ",t]}),(0,m.jsx)(k,{items:[{label:"← Back",value:"back"}],onSelect:n})]});if(!e)return(0,m.jsx)(i.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"}],c=e.entry_detail,d=c?.screen,u=c?.update,x=c?.local_sync;return(0,m.jsxs)(i.Box,{flexDirection:"column",children:[(0,m.jsxs)(i.Box,{children:[(0,m.jsx)(i.Text,{bold:!0,color:"cyan",children:e.name||e.device_name}),(0,m.jsx)(i.Text,{color:"gray",children:" - "}),(0,m.jsx)(j,{countdown:r,lastRefreshTime:a})]}),e.description&&(0,m.jsx)(i.Text,{color:"gray",children:e.description}),(0,m.jsxs)(i.Box,{marginY:1,flexDirection:"column",children:[(0,m.jsxs)(i.Box,{children:[(0,m.jsx)(i.Text,{color:"gray",children:"Status: "}),(0,m.jsx)(v,{lastAliveTime:c?.watch_dog_timer?.last_alive_time})]}),(0,m.jsxs)(i.Text,{color:"gray",children:["ID: ",e._id]}),e.tags?.length>0&&(0,m.jsxs)(i.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),c?.application&&(0,m.jsxs)(i.Box,{flexDirection:"column",marginTop:1,children:[(0,m.jsx)(i.Text,{bold:!0,color:"white",children:"Application"}),(0,m.jsxs)(i.Text,{color:"gray",children:[" Name: ",c.application.name]}),(0,m.jsxs)(i.Text,{color:"gray",children:[" Mode: ",c.operation_mode||"N/A"]})]}),d&&(0,m.jsxs)(i.Box,{flexDirection:"column",marginTop:1,children:[(0,m.jsx)(i.Text,{bold:!0,color:"white",children:"Screen"}),d.resolution&&(0,m.jsxs)(i.Text,{color:"gray",children:[" ","Resolution: ",d.resolution.width,"x",d.resolution.height,d.resolution.scale&&` @${d.resolution.scale}x`]}),d.orientation&&(0,m.jsxs)(i.Text,{color:"gray",children:[" Orientation: ",d.orientation]}),d.touch&&(0,m.jsxs)(i.Text,{color:"gray",children:[" ","Touch:"," ",d.touch.available?`Yes (${d.touch.touch_point} points)`:"No"]})]}),(c?.memory_usage||c?.disk_usage)&&(0,m.jsxs)(i.Box,{flexDirection:"column",marginTop:1,children:[(0,m.jsx)(i.Text,{bold:!0,color:"white",children:"System"}),c.memory_usage&&(0,m.jsxs)(i.Text,{color:"gray",children:[" Memory: ",Math.round(100*c.memory_usage),"%"]}),c.disk_usage&&(0,m.jsxs)(i.Text,{color:"gray",children:[" Disk: ",Math.round(100*c.disk_usage),"%"]})]}),(0,m.jsxs)(i.Box,{flexDirection:"column",marginTop:1,children:[(0,m.jsx)(i.Text,{bold:!0,color:"white",children:"Capabilities"}),(0,m.jsxs)(i.Text,{color:"gray",children:[" ","Sound: ",c?.sound?.available?"✓":"✗"," | ","Camera: ",c?.camera?.available?"✓":"✗"," | ","Audio In: ",c?.audio_in?.available?"✓":"✗"]})]}),x&&(0,m.jsxs)(i.Box,{flexDirection:"column",marginTop:1,children:[(0,m.jsx)(i.Text,{bold:!0,color:"white",children:"Local Sync"}),(0,m.jsxs)(i.Text,{color:"gray",children:[" ","Role: ",x.is_main?"Main":"Peer",x.peer_count>0&&` | Peers: ${x.peer_count}`,x.mean_latency&&` | Latency: ${x.mean_latency}ms`]})]}),u&&(0,m.jsxs)(i.Box,{flexDirection:"column",marginTop:1,children:[(0,m.jsx)(i.Text,{bold:!0,color:"white",children:"Update"}),(0,m.jsxs)(i.Text,{color:u.need_update?"yellow":"gray",children:[" ","Status: ",u.need_update?"⚠ Update available":"✓ Up to date"]}),u.current_version&&(0,m.jsxs)(i.Text,{color:"gray",children:[" Version: ",u.current_version]})]})]}),(0,m.jsx)(k,{items:s,onSelect:n})]})},M=({device:e,onSelect:l,controlling:t,controlResult:n})=>(0,m.jsxs)(i.Box,{flexDirection:"column",children:[(0,m.jsxs)(i.Text,{bold:!0,color:"cyan",children:["Control: ",e?.name||e?.device_name]}),t&&(0,m.jsx)(b,{text:"Sending command..."}),n&&(0,m.jsx)(i.Text,{color:n.success?"green":"red",children:n.message}),(0,m.jsx)(i.Box,{marginTop:1,children:(0,m.jsx)(k,{items:x,onSelect:l})})]}),N=({device:e,screenshot:l,loading:t,error:n,onSelect:r})=>{var a=l?.file?.meta,s=null!=a?.originalWidth&&null!=a?.originalHeight,c=null!=a?.originalFileSize;return(0,m.jsxs)(i.Box,{flexDirection:"column",children:[(0,m.jsxs)(i.Text,{bold:!0,color:"cyan",children:["Screenshot: ",e?.name||e?.device_name||"Unknown"]}),t&&(0,m.jsx)(b,{text:"Loading screenshot..."}),n&&(0,m.jsx)(i.Box,{marginY:1,children:(0,m.jsx)(i.Text,{color:"red",children:String(n)})}),!t&&!n&&l&&(0,m.jsxs)(i.Box,{flexDirection:"column",children:[(0,m.jsx)(i.Box,{height:30,children:(0,m.jsx)(o.default,{src:l.path,width:80,alt:"Device screenshot"})}),(0,m.jsxs)(i.Box,{marginY:1,flexDirection:"column",children:[(0,m.jsx)(i.Text,{bold:!0,color:"white",children:"Screenshot Details"}),(0,m.jsxs)(i.Box,{marginY:1,children:[(0,m.jsx)(i.Text,{color:"green",children:"Screenshot saved to: "}),(0,m.jsx)(i.Text,{color:"cyan",children:String(l.path||"")})]}),s&&(0,m.jsxs)(i.Text,{color:"gray",children:["Size: ",String(a.originalWidth),"x",String(a.originalHeight)]}),c&&(0,m.jsxs)(i.Text,{color:"gray",children:["File: ",(Number(a.originalFileSize)/1024).toFixed(1)," KB"]}),l.file?.updatedAt&&(0,m.jsxs)(i.Text,{color:"gray",children:["Updated: ",new Date(l.file.updatedAt).toLocaleString()]})]})]}),!t&&!n&&!l&&(0,m.jsx)(i.Box,{marginY:1,children:(0,m.jsx)(i.Text,{color:"yellow",children:"No screenshot available. Try taking a new one."})}),(0,m.jsx)(i.Box,{marginTop:1,children:(0,m.jsx)(k,{items:[{label:"Take New Screenshot",value:"take"},{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],onSelect:r})})]})},G=({apps:e,loading:l,onSelect:t})=>{if(l)return(0,m.jsx)(b,{text:"Loading applications..."});if(!e?.length)return(0,m.jsx)(i.Text,{color:"yellow",children:"No applications found"});var n=[...e.map(e=>({label:`${e.has_unreleased_changes?"●":"○"} ${e.name}`,value:e._id,app:e})),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return(0,m.jsxs)(i.Box,{flexDirection:"column",children:[(0,m.jsxs)(i.Text,{bold:!0,marginBottom:1,children:["Applications (",e.length,")"]}),(0,m.jsx)(k,{items:n,onSelect:t})]})},V=({app:e,loading:l,error:t,onSelect:n})=>{if(l)return(0,m.jsx)(b,{text:"Loading application..."});if(t)return(0,m.jsxs)(i.Box,{flexDirection:"column",children:[(0,m.jsxs)(i.Text,{color:"red",children:["Error: ",t]}),(0,m.jsx)(k,{items:[{label:"← Back",value:"back"}],onSelect:n})]});if(!e)return(0,m.jsx)(i.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"}],r=e.devices?.length||0,a=e.devices?.filter(e=>"online"===e.status)?.length||0;return(0,m.jsxs)(i.Box,{flexDirection:"column",children:[(0,m.jsx)(i.Text,{bold:!0,color:"cyan",children:e.name}),e.description&&(0,m.jsx)(i.Text,{color:"gray",children:e.description}),(0,m.jsxs)(i.Box,{marginY:1,flexDirection:"column",children:[(0,m.jsxs)(i.Text,{color:"gray",children:["ID: ",e._id]}),e.tags?.length>0&&(0,m.jsxs)(i.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),(0,m.jsxs)(i.Box,{flexDirection:"column",marginTop:1,children:[(0,m.jsx)(i.Text,{bold:!0,color:"white",children:"Version"}),(0,m.jsxs)(i.Text,{color:"gray",children:[" ","Current: ",e.current_version?`v${e.current_version}`:"N/A"]}),(0,m.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,m.jsxs)(i.Text,{color:"gray",children:[" ","Released: v",e.current_version_details.version||"N/A"]})]}),(0,m.jsxs)(i.Box,{flexDirection:"column",marginTop:1,children:[(0,m.jsx)(i.Text,{bold:!0,color:"white",children:"Devices"}),(0,m.jsxs)(i.Text,{color:"gray",children:[" ","Total: ",r,r>0&&` (${a} online)`]})]}),(0,m.jsxs)(i.Box,{flexDirection:"column",marginTop:1,children:[(0,m.jsx)(i.Text,{bold:!0,color:"white",children:"Features"}),(0,m.jsxs)(i.Text,{color:"gray",children:[" ","Short Edit: ",e.short_edit?.enabled?"✓ Enabled":"✗ Disabled"]}),(0,m.jsxs)(i.Text,{color:"gray",children:[" ","Canvas Control: ",e.canvas_control?.enabled?"✓ Enabled":"✗ Disabled"]}),(0,m.jsxs)(i.Text,{color:"gray",children:[" ","Device Control: ",e.device_control?.enabled?"✓ Enabled":"✗ Disabled"]}),(0,m.jsxs)(i.Text,{color:e.lock?.enabled?"yellow":"gray",children:[" ","Lock: ",e.lock?.enabled?"🔒 Locked":"🔓 Unlocked"]})]}),(0,m.jsxs)(i.Box,{flexDirection:"column",marginTop:1,children:[(0,m.jsx)(i.Text,{bold:!0,color:"white",children:"Timestamps"}),e.create_datetime&&(0,m.jsxs)(i.Text,{color:"gray",children:[" Created: ",new Date(e.create_datetime).toLocaleString()]}),e.last_modify_datetime&&(0,m.jsxs)(i.Text,{color:"gray",children:[" ","Modified: ",new Date(e.last_modify_datetime).toLocaleString()]})]})]}),(0,m.jsx)(k,{items:o,onSelect:n})]})},F=({modules:e,loading:l,onSelect:t})=>{if(l)return(0,m.jsx)(b,{text:"Loading modules..."});var n=[...(e||[]).map(e=>({label:`${e.current_version?"●":"○"} ${e.name}`,value:e._id,module:e})),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return(0,m.jsxs)(i.Box,{flexDirection:"column",children:[(0,m.jsxs)(i.Text,{bold:!0,marginBottom:1,children:["Modules (",e?.length||0,")"]}),!e?.length&&(0,m.jsx)(i.Text,{color:"yellow",children:"No modules found"}),(0,m.jsx)(k,{items:n,onSelect:t})]})},H=({module:e,loading:l,error:t,onSelect:n})=>{if(l)return(0,m.jsx)(b,{text:"Loading module..."});if(t)return(0,m.jsxs)(i.Box,{flexDirection:"column",children:[(0,m.jsxs)(i.Text,{color:"red",children:["Error: ",t]}),(0,m.jsx)(k,{items:[{label:"← Back",value:"back"}],onSelect:n})]});if(!e)return(0,m.jsx)(i.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(0,m.jsxs)(i.Box,{flexDirection:"column",children:[(0,m.jsx)(i.Text,{bold:!0,color:"cyan",children:e.name}),e.description&&(0,m.jsx)(i.Text,{color:"gray",children:e.description}),(0,m.jsxs)(i.Box,{marginY:1,flexDirection:"column",children:[(0,m.jsxs)(i.Text,{color:"gray",children:["ID: ",e._id]}),e.tags?.length>0&&(0,m.jsxs)(i.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),(0,m.jsxs)(i.Box,{flexDirection:"column",marginTop:1,children:[(0,m.jsx)(i.Text,{bold:!0,color:"white",children:"Version"}),(0,m.jsxs)(i.Text,{color:"gray",children:[" ","Current: ",e.current_version?`v${e.current_version}`:"N/A"]}),(0,m.jsxs)(i.Text,{color:e.has_unreleased_changes?"yellow":"gray",children:[" ","Changes:"," ",e.has_unreleased_changes?"● Unreleased changes":"○ No pending changes"]})]}),(0,m.jsxs)(i.Box,{flexDirection:"column",marginTop:1,children:[(0,m.jsx)(i.Text,{bold:!0,color:"white",children:"Usage"}),(0,m.jsxs)(i.Text,{color:"gray",children:[" ","Used in: ",e.use_count?.total_count||0," application(s)"]})]}),(0,m.jsxs)(i.Box,{flexDirection:"column",marginTop:1,children:[(0,m.jsx)(i.Text,{bold:!0,color:"white",children:"Settings"}),(0,m.jsxs)(i.Text,{color:"gray",children:[" ","Public: ",e.is_public?"✓ Yes":"✗ No"]}),(0,m.jsxs)(i.Text,{color:"gray",children:[" ","Modifiable: ",e.is_allow_modify?"✓ Yes":"✗ No"]}),(0,m.jsxs)(i.Text,{color:"gray",children:[" ","Short Edit: ",e.short_edit?.enabled?"✓ Enabled":"✗ Disabled"]})]}),e.expose_properties?.length>0&&(0,m.jsxs)(i.Box,{flexDirection:"column",marginTop:1,children:[(0,m.jsx)(i.Text,{bold:!0,color:"white",children:"Exposed Properties"}),(0,m.jsxs)(i.Text,{color:"gray",children:[" ",e.expose_properties.length," properties exposed"]})]}),(0,m.jsxs)(i.Box,{flexDirection:"column",marginTop:1,children:[(0,m.jsx)(i.Text,{bold:!0,color:"white",children:"Timestamps"}),e.create_datetime&&(0,m.jsxs)(i.Text,{color:"gray",children:[" Created: ",new Date(e.create_datetime).toLocaleString()]}),e.last_modify_datetime&&(0,m.jsxs)(i.Text,{color:"gray",children:[" ","Modified: ",new Date(e.last_modify_datetime).toLocaleString()]})]})]}),(0,m.jsx)(k,{items:o,onSelect:n})]})},$=({groups:e,loading:l,onSelect:t,countdown:n,lastRefreshTime:o})=>{if(l)return(0,m.jsx)(b,{text:"Loading device groups..."});var r=[...(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)(i.Box,{flexDirection:"column",children:[(0,m.jsxs)(i.Box,{marginBottom:1,children:[(0,m.jsxs)(i.Text,{bold:!0,children:["Device Groups (",e?.length||0,")"]}),(0,m.jsx)(i.Text,{color:"gray",children:" - "}),(0,m.jsx)(j,{countdown:n,lastRefreshTime:o})]}),!e?.length&&(0,m.jsx)(i.Text,{color:"yellow",children:"No device groups found"}),(0,m.jsx)(k,{items:r,onSelect:t})]})},q=({loading:e,groupDevices:l})=>e?(0,m.jsx)(b,{text:"Loading devices..."}):l?.length?(0,m.jsxs)(m.Fragment,{children:[l.slice(0,10).map(e=>(0,m.jsxs)(i.Box,{children:[(0,m.jsx)(i.Text,{color:"gray",children:" "}),(0,m.jsx)(v,{lastAliveTime:e.entry_detail?.watch_dog_timer?.last_alive_time}),(0,m.jsxs)(i.Text,{color:"gray",children:[" ",e.name||e.device_name]}),e.device_target_name&&(0,m.jsxs)(i.Text,{color:"gray",dimColor:!0,children:[" ","(",e.device_target_name,")"]})]},e._id)),l.length>10&&(0,m.jsxs)(i.Text,{color:"gray",dimColor:!0,children:[" ","... and ",l.length-10," more"]})]}):(0,m.jsx)(i.Text,{color:"gray",children:" No devices in this group"}),z=({group:e,groupDevices:l,loading:t,error:n,onSelect:o,countdown:r,lastRefreshTime:a})=>{if(t&&!e)return(0,m.jsx)(b,{text:"Loading device group..."});if(n)return(0,m.jsxs)(i.Box,{flexDirection:"column",children:[(0,m.jsxs)(i.Text,{color:"red",children:["Error: ",n]}),(0,m.jsx)(k,{items:[{label:"← Back",value:"back"}],onSelect:o})]});if(!e)return(0,m.jsx)(i.Text,{color:"red",children:"Device group not found"});return(0,m.jsxs)(i.Box,{flexDirection:"column",children:[(0,m.jsxs)(i.Box,{children:[(0,m.jsx)(i.Text,{bold:!0,color:"cyan",children:e.name}),(0,m.jsx)(i.Text,{color:"gray",children:" - "}),(0,m.jsx)(j,{countdown:r,lastRefreshTime:a})]}),e.description&&(0,m.jsx)(i.Text,{color:"gray",children:e.description}),(0,m.jsxs)(i.Box,{marginY:1,flexDirection:"column",children:[(0,m.jsxs)(i.Text,{color:"gray",children:["ID: ",e._id]}),e.tags?.length>0&&(0,m.jsxs)(i.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),(0,m.jsxs)(i.Box,{flexDirection:"column",marginTop:1,children:[(0,m.jsxs)(i.Text,{bold:!0,color:"white",children:["Devices (",e.devices?.length||0,")"]}),(0,m.jsx)(q,{loading:t,groupDevices:l})]}),(0,m.jsxs)(i.Box,{flexDirection:"column",marginTop:1,children:[(0,m.jsx)(i.Text,{bold:!0,color:"white",children:"Timestamps"}),e.create_datetime&&(0,m.jsxs)(i.Text,{color:"gray",children:[" Created: ",new Date(e.create_datetime).toLocaleString()]}),e.last_modify_datetime&&(0,m.jsxs)(i.Text,{color:"gray",children:[" ","Modified: ",new Date(e.last_modify_datetime).toLocaleString()]})]})]}),(0,m.jsx)(k,{items:[{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],onSelect:o})]})},Y=({boxes:e,loading:l,onSelect:t})=>{if(l)return(0,m.jsx)(b,{text:"Loading media boxes..."});if(!e?.length)return(0,m.jsx)(i.Text,{color:"yellow",children:"No media boxes found"});var n=[...e.map(e=>({label:`📦 ${e.name||"Unnamed"}`,value:e.id,box:e})),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return(0,m.jsxs)(i.Box,{flexDirection:"column",children:[(0,m.jsxs)(i.Text,{bold:!0,marginBottom:1,children:["Media Boxes (",e.length,")"]}),(0,m.jsx)(k,{items:n,onSelect:t})]})},W=({box:e,loading:l,error:t,onSelect:n})=>{if(l&&!e)return(0,m.jsx)(b,{text:"Loading media box..."});if(t)return(0,m.jsxs)(i.Box,{flexDirection:"column",children:[(0,m.jsxs)(i.Text,{color:"red",children:["Error: ",t]}),(0,m.jsx)(k,{items:[{label:"← Back",value:"back"}],onSelect:n})]});if(!e)return(0,m.jsx)(i.Text,{color:"red",children:"Media box not found"});return(0,m.jsxs)(i.Box,{flexDirection:"column",children:[(0,m.jsx)(i.Text,{bold:!0,color:"cyan",children:e.name||"Unnamed"}),e.description&&(0,m.jsx)(i.Text,{color:"gray",children:e.description}),(0,m.jsxs)(i.Box,{marginY:1,flexDirection:"column",children:[(0,m.jsxs)(i.Text,{color:"gray",children:["ID: ",e.id]}),e.tags?.length>0&&(0,m.jsxs)(i.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),null!=e.size&&(0,m.jsxs)(i.Text,{color:"gray",children:["Size: ",e.size]}),e.passcodes?.length>0&&(0,m.jsxs)(i.Box,{flexDirection:"column",marginTop:1,children:[(0,m.jsxs)(i.Text,{bold:!0,color:"white",children:["Passcodes (",e.passcodes.length,")"]}),e.passcodes.slice(0,5).map(e=>(0,m.jsxs)(i.Text,{color:"gray",children:[" ",e.name||"Passcode",": ",e.code]},e.id)),e.passcodes.length>5&&(0,m.jsxs)(i.Text,{color:"gray",dimColor:!0,children:[" ","... and ",e.passcodes.length-5," more"]})]}),(0,m.jsxs)(i.Box,{flexDirection:"column",marginTop:1,children:[(0,m.jsx)(i.Text,{bold:!0,color:"white",children:"Timestamps"}),e.createdAt&&(0,m.jsxs)(i.Text,{color:"gray",children:[" Created: ",new Date(e.createdAt).toLocaleString()]}),e.updatedAt&&(0,m.jsxs)(i.Text,{color:"gray",children:[" Modified: ",new Date(e.updatedAt).toLocaleString()]})]})]}),(0,m.jsx)(k,{items:[{label:"List Files",value:"files"},{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],onSelect:n})]})},X=({files:e,loading:l,onSelect:t,box:n})=>{if(l)return(0,m.jsx)(b,{text:"Loading media files..."});if(!e?.length)return(0,m.jsx)(i.Text,{color:"yellow",children:"No media files found"});var o=[...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)(i.Box,{flexDirection:"column",children:[(0,m.jsxs)(i.Text,{bold:!0,marginBottom:1,children:["Media Files (",e.length,")",n?.name?` - ${n.name}`:""]}),(0,m.jsx)(k,{items:o,onSelect:t})]})},J=({file:e,loading:l,error:t,onSelect:n})=>{if(l&&!e)return(0,m.jsx)(b,{text:"Loading media file..."});if(t)return(0,m.jsxs)(i.Box,{flexDirection:"column",children:[(0,m.jsxs)(i.Text,{color:"red",children:["Error: ",t]}),(0,m.jsx)(k,{items:[{label:"← Back",value:"back"}],onSelect:n})]});if(!e)return(0,m.jsx)(i.Text,{color:"red",children:"Media file not found"});var o=e.meta,r=(0,d.Gu)(e),a=(0,d.Gu)(e,{preferThumbnail:!0}),s=Boolean(a&&a!==r);return(0,m.jsxs)(i.Box,{flexDirection:"column",children:[(0,m.jsx)(i.Text,{bold:!0,color:"cyan",children:e.name||"Unnamed"}),e.description&&(0,m.jsx)(i.Text,{color:"gray",children:e.description}),(0,m.jsxs)(i.Box,{marginY:1,flexDirection:"column",children:[(0,m.jsxs)(i.Text,{color:"gray",children:["ID: ",e.id]}),(0,m.jsxs)(i.Text,{color:"gray",children:["Box ID: ",e.boxId]}),(0,m.jsxs)(i.Text,{color:"gray",children:["Type: ",e.fileType]}),e.userTags?.length>0&&(0,m.jsxs)(i.Text,{color:"gray",children:["Tags: ",e.userTags.join(", ")]}),null!=o?.originalWidth&&null!=o?.originalHeight&&(0,m.jsxs)(i.Text,{color:"gray",children:["Size: ",o.originalWidth,"x",o.originalHeight]}),null!=o?.originalFileSize&&(0,m.jsxs)(i.Text,{color:"gray",children:["File: ",(Number(o.originalFileSize)/1024).toFixed(1)," KB"]}),r&&(0,m.jsxs)(i.Text,{color:"gray",children:["Original URL: ",r]}),s&&(0,m.jsxs)(i.Text,{color:"gray",children:["Thumbnail URL: ",a]}),(0,m.jsxs)(i.Box,{flexDirection:"column",marginTop:1,children:[(0,m.jsx)(i.Text,{bold:!0,color:"white",children:"Timestamps"}),e.createdAt&&(0,m.jsxs)(i.Text,{color:"gray",children:[" Created: ",new Date(e.createdAt).toLocaleString()]}),e.updatedAt&&(0,m.jsxs)(i.Text,{color:"gray",children:[" Modified: ",new Date(e.updatedAt).toLocaleString()]})]})]}),(0,m.jsx)(k,{items:[{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],onSelect:n})]})},K=t(8568);function Q({value:e,placeholder:l="",focus:t=!0,mask:o,highlightPastedText:r=!1,showCursor:a=!0,onChange:s,onSubmit:c}){const[d,u]=(0,n.useState)({cursorOffset:(e||"").length,cursorWidth:0}),{cursorOffset:x,cursorWidth:h}=d;(0,n.useEffect)(()=>{u(l=>{if(!t||!a)return l;const n=e||"";return l.cursorOffset>n.length-1?{cursorOffset:n.length,cursorWidth:0}:l})},[e,t,a]);const g=r?h:0,f=o?o.repeat(e.length):e;let m=f,p=l?K.Ay.grey(l):void 0;if(a&&t){p=l.length>0?K.Ay.inverse(l[0])+K.Ay.grey(l.slice(1)):K.Ay.inverse(" "),m=f.length>0?"":K.Ay.inverse(" ");let e=0;for(const l of f)m+=e>=x-g&&e<=x?K.Ay.inverse(l):l,e++;f.length>0&&x===f.length&&(m+=K.Ay.inverse(" "))}return(0,i.useInput)((l,t)=>{if(t.upArrow||t.downArrow||t.ctrl&&"c"===l||t.tab||t.shift&&t.tab)return;if(t.return)return void(c&&c(e));let n=x,i=e,o=0;t.leftArrow?a&&n--:t.rightArrow?a&&n++:t.backspace||t.delete?x>0&&(i=e.slice(0,x-1)+e.slice(x,e.length),n--):(i=e.slice(0,x)+l+e.slice(x,e.length),n+=l.length,l.length>1&&(o=l.length)),x<0&&(n=0),x>e.length&&(n=e.length),u({cursorOffset:n,cursorWidth:o}),i!==e&&s(i)},{isActive:t}),n.default.createElement(i.Text,null,l?f.length>0?m:p:m)}const Z=Q;var ee,le=t(5704),te=["B","C","G","D"],ne=({instanceType:e,instance:l,client:t,onDone:o,onCancel:s})=>{var c=(0,i.useApp)().exit,d=(0,n.useState)("select_ref"),u=a(d,2),x=u[0],h=u[1],g=(0,n.useState)(""),f=a(g,2),p=f[0],j=f[1],D=(0,n.useState)("search"),T=a(D,2),v=T[0],_=T[1],y=(0,n.useState)(null),B=a(y,2),S=B[0],E=B[1],w=(0,n.useState)(null),L=a(w,2),I=L[0],A=L[1],C=(0,n.useState)(""),R=a(C,2),U=R[0],O=R[1],P=(0,n.useState)(""),M=a(P,2),N=M[0],G=M[1],V=(0,n.useState)(null),F=a(V,2),H=F[0],$=F[1],q=l?.short_edit?.ref_map||{},z=Object.entries(q).filter(([,e])=>e&&!e.hide),Y=(0,le.V)(q,{keyword:p,types:te}),W=Y.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}))]),X=[...p?[{label:"↻ Clear Search",value:"__clear_search__"}]:[],{label:"← Back",value:"__back__"}],J=W.length>0?[...W,...X]:X,K=J.findIndex(e=>!e.isHeader&&!e.value?.startsWith("__"));(0,i.useInput)((e,l)=>{l.tab&&"select_ref"===x?_(e=>"search"===e?"list":"search"):(l.escape&&("select_ref"===x&&s(),"input_path"===x&&h("select_ref"),"input_content"===x&&h("input_path"),"confirm"===x&&h("input_content"),"done"===x&&s()),"q"!==e||("input_path"===x||"input_content"===x)||"select_ref"===x&&"search"===v||c())},{isActive:!0});var Q,ee=e=>{var l=e.trim();if(""===l)return null;try{return JSON.parse(l)}catch{return l}},ne=(Q=r(function*(){if(t&&l?._id&&S){h("submitting"),$(null);try{var n={shortId:S,path:U.trim(),content:ee(N),forwardDataLink:!0};I?.inner_ref?.pid&&(n.innerRefParentShortId=I.inner_ref.pid),"application"===e?yield t.shortEditApplication({id:l._id,list:[n]}):yield t.shortEditModule({id:l._id,list:[n]}),yield o(),h("done")}catch(e){$(e.message),h("confirm")}}}),function(){return Q.apply(this,arguments)});return l?.short_edit?.enabled?0===z.length?(0,m.jsxs)(i.Box,{flexDirection:"column",children:[(0,m.jsx)(i.Text,{color:"yellow",children:"No Short Edit references found."}),(0,m.jsx)(k,{items:[{label:"← Back",value:"back"}],onSelect:s})]}):"select_ref"===x?(0,m.jsxs)(i.Box,{flexDirection:"column",children:[(0,m.jsx)(i.Text,{bold:!0,children:"Short Edit References"}),(0,m.jsx)(i.Text,{color:"gray",dimColor:!0,children:"Showing: Brick, Canvas, Generator, Data"}),(0,m.jsxs)(i.Box,{marginTop:1,flexDirection:"column",children:[(0,m.jsx)(i.Text,{color:"gray",children:"Search (title or shortId)"}),(0,m.jsx)(Z,{value:p,placeholder:"type to filter, Enter to focus list",onChange:e=>j(e),onSubmit:()=>_("list"),focus:"search"===v}),(0,m.jsx)(i.Text,{color:"gray",dimColor:!0,children:"Press Tab to switch focus"})]}),(0,m.jsxs)(i.Box,{marginTop:1,children:[0===Y.length&&(0,m.jsx)(i.Text,{color:"yellow",children:"No references match your search."}),(0,m.jsx)(k,{items:J,isFocused:"list"===v,initialIndex:K>-1?K:0,indicatorComponent:()=>null,itemComponent:({label:e,isSelected:l,isHeader:t})=>t?(0,m.jsx)(i.Box,{marginTop:1,children:(0,m.jsx)(i.Text,{bold:!0,color:"white",children:e})}):(0,m.jsxs)(i.Text,{color:l?"blue":void 0,children:[l?"❯":" "," ",e]}),onSelect:e=>{if("__back__"!==e.value)return"__clear_search__"===e.value?(j(""),void _("search")):void(e.isHeader||(E(e.value),A(e.ref),h("input_path")));s()}})]})]}):"input_path"===x?(0,m.jsxs)(i.Box,{flexDirection:"column",children:[(0,m.jsxs)(i.Text,{children:["Reference:"," ",(0,m.jsxs)(i.Text,{color:"cyan",children:[I?.title||S," (",S,")"]})]}),(0,m.jsx)(i.Text,{marginTop:1,children:"Enter property path (e.g. title, property.backgroundColor)"}),H&&(0,m.jsxs)(i.Text,{color:"red",children:["Error: ",H]}),(0,m.jsx)(Z,{value:U,placeholder:"path",onChange:e=>{O(e),H&&$(null)},onSubmit:e=>{var l=e.trim();l?(O(l),h("input_content")):$("Path is required")},focus:!0})]}):"input_content"===x?(0,m.jsxs)(i.Box,{flexDirection:"column",children:[(0,m.jsxs)(i.Text,{children:["Path: ",(0,m.jsx)(i.Text,{color:"cyan",children:U})]}),(0,m.jsx)(i.Text,{marginTop:1,children:"Enter new content (JSON or plain text). Empty to clear."}),H&&(0,m.jsxs)(i.Text,{color:"red",children:["Error: ",H]}),(0,m.jsx)(Z,{value:N,placeholder:"content",onChange:e=>{G(e),H&&$(null)},onSubmit:()=>h("confirm"),focus:!0})]}):"submitting"===x?(0,m.jsx)(b,{text:"Applying short edit..."}):"done"===x?(0,m.jsxs)(i.Box,{flexDirection:"column",children:[(0,m.jsx)(i.Text,{color:"green",children:"Short edit applied successfully."}),(0,m.jsx)(k,{items:[{label:"Edit another property",value:"again"},{label:"← Back",value:"back"}],onSelect:e=>{"again"===e.value?(h("select_ref"),E(null),A(null),O(""),G(""),$(null)):s()}})]}):(0,m.jsxs)(i.Box,{flexDirection:"column",children:[(0,m.jsx)(i.Text,{bold:!0,marginBottom:1,children:"Confirm Short Edit"}),(0,m.jsxs)(i.Text,{children:["Reference:"," ",(0,m.jsxs)(i.Text,{color:"cyan",children:[I?.title||S," (",S,")"]})]}),(0,m.jsxs)(i.Text,{children:["Path: ",(0,m.jsx)(i.Text,{color:"cyan",children:U})]}),(0,m.jsxs)(i.Text,{children:["Content: ",(0,m.jsx)(i.Text,{color:"cyan",children:N||"<empty>"})]}),H&&(0,m.jsxs)(i.Text,{color:"red",children:["Error: ",H]}),(0,m.jsx)(k,{items:[{label:"Apply",value:"apply"},{label:"Edit Path",value:"edit_path"},{label:"Edit Content",value:"edit_content"},{label:"← Back",value:"back"}],onSelect:e=>{"apply"===e.value&&ne(),"edit_path"===e.value&&h("input_path"),"edit_content"===e.value&&h("input_content"),"back"===e.value&&s()}})]}):(0,m.jsxs)(i.Box,{flexDirection:"column",children:[(0,m.jsxs)(i.Text,{color:"yellow",children:["Short Edit is not enabled for this ",e,"."]}),(0,m.jsx)(k,{items:[{label:"← Back",value:"back"}],onSelect:s})]})},ie=t(6928),oe=t(9896),re=t(5317),ae=t(750),se="options",ce="output_dir",de="confirm",ue="generating",xe="post_install",he="done",ge=e=>{try{return(0,re.execSync)(`which ${e}`,{stdio:"ignore"}),!0}catch{return!1}},fe=(e,l,t)=>new Promise((n,i)=>{var o=[e,...l].join(" "),r=(0,re.spawn)(o,[],{cwd:t,stdio:"pipe",shell:!0});r.on("close",e=>{0===e?n():i(new Error(`Command failed with code ${e}`))}),r.on("error",i)}),me=(ee=r(function*(e,l){try{var n=(yield Promise.resolve().then(t.bind(t,9491))).format;return(yield n(l,e,{trailingComma:"all",tabWidth:2,semi:!1,singleQuote:!0,printWidth:100})).code}catch{}return e}),function(e,l){return ee.apply(this,arguments)}),pe=({type:e,instance:l,client:t,onDone:o,onCancel:s})=>{var c,d=(0,i.useApp)().exit,u=(0,n.useState)(se),x=a(u,2),h=x[0],g=x[1],p=(0,n.useState)({setupGitHubActions:!0,setupAgents:!0,setupClaudeCode:!0,setupGeminiCLI:!1,runBunInstall:!0,initGit:!0}),j=a(p,2),D=j[0],T=j[1],b=(0,n.useState)(process.cwd()),v=a(b,2),_=v[0],y=v[1],B=(0,n.useState)(""),S=a(B,2),E=S[0],w=S[1],L=(0,n.useState)(null),I=a(L,2),A=I[0],C=I[1],R=(0,n.useState)(null),U=a(R,2),O=U[0],P=U[1],M=ae(l?.name||"bricks-project"),N=ie.resolve(_,M),G=(0,n.useCallback)(e=>{"back"!==e.value?"continue"!==e.value?T(l=>({...l,[e.value]:!l[e.value]})):g(ce):s()},[s]),V=(0,n.useCallback)(()=>{oe.existsSync(N)?C(`Directory already exists: ${N}`):(C(null),g(de))},[N]),F=(0,n.useCallback)((c=r(function*(n){var i;if("back"!==n.value)if("cancel"!==n.value){if("confirm"===n.value){g(ue);try{w("Fetching project from BRICKS...");var o="application"===e,a=o?"UNSTABLE_applicationProject":"UNSTABLE_moduleProject",c=o?t.queries.applicationProject:t.queries.moduleProject,d=(yield t.query(c,{id:l._id,buildApplicationOnly:!1,setupGitHubActions:D.setupGitHubActions,setupAgents:D.setupAgents,setupClaudeCode:D.setupClaudeCode,setupGeminiCLI:D.setupGeminiCLI}))[a];if(!d?.files)throw new Error("Failed to fetch project files");w("Creating project directory..."),oe.mkdirSync(N,{recursive:!0}),w(`Writing ${d.files.length} files...`);var u=yield Promise.all(d.files.map((i=r(function*(e){var l=ie.join(N,e.name),t=e.input;return e.formatable&&(t=yield me(t,l)),{...e,filePath:l,content:t}}),function(e){return i.apply(this,arguments)})));u.forEach(e=>{var l=ie.dirname(e.filePath);oe.existsSync(l)||oe.mkdirSync(l,{recursive:!0}),oe.writeFileSync(e.filePath,e.content)}),g(xe);var x={path:N,files:d.files.length,bunInstalled:!1,gitInitialized:!1};if(D.runBunInstall&&ge("bun")){w("Installing dependencies (bun install)...");try{yield fe("bun",["install"],N),x.bunInstalled=!0}catch{}}if(D.initGit&&ge("git")){w("Initializing git repository...");try{yield fe("git",["init"],N),yield fe("git",["add","."],N),yield fe("git",["-c 'user.name=BRICKS CLI'","-c 'user.email=cli@bricks.tools'","commit","-m 'chore: initialize commit'"],N),x.gitInitialized=!0}catch{}}P(x),g(he)}catch(e){C(e.message),g(se)}}}else s();else g(ce)}),function(e){return c.apply(this,arguments)}),[t,l,e,D,N,s]),H=(0,n.useCallback)(e=>{"exit"===e.value?d():o()},[d,o]);if(h===se){var $=[{label:(D.setupGitHubActions?"[x]":"[ ]")+" GitHub Actions workflow",value:"setupGitHubActions"},{label:(D.setupAgents?"[x]":"[ ]")+" AGENTS.md",value:"setupAgents"},{label:(D.setupClaudeCode?"[x]":"[ ]")+" CLAUDE.md",value:"setupClaudeCode"},{label:(D.setupGeminiCLI?"[x]":"[ ]")+" GEMINI.md",value:"setupGeminiCLI"},{label:(D.runBunInstall?"[x]":"[ ]")+" Run bun install after generation",value:"runBunInstall"},{label:(D.initGit?"[x]":"[ ]")+" Initialize git repository",value:"initGit"},{label:"→ Continue",value:"continue"},{label:"← Back",value:"back"}];return(0,m.jsxs)(i.Box,{flexDirection:"column",children:[(0,m.jsxs)(i.Text,{bold:!0,color:"cyan",children:["Initialize BRICKS Project: ",l?.name||"Untitled"]}),(0,m.jsx)(i.Text,{color:"gray",marginBottom:1,children:"Select options for project generation (press Enter to toggle)"}),A&&(0,m.jsxs)(i.Text,{color:"red",marginBottom:1,children:["Error: ",A]}),(0,m.jsx)(k,{items:$,onSelect:G})]})}if(h===ce)return(0,m.jsxs)(i.Box,{flexDirection:"column",children:[(0,m.jsx)(i.Text,{bold:!0,color:"cyan",children:"Output Directory"}),(0,m.jsx)(i.Text,{color:"gray",marginBottom:1,children:"Enter the parent directory for the project:"}),A&&(0,m.jsx)(i.Text,{color:"red",marginBottom:1,children:A}),(0,m.jsxs)(i.Box,{children:[(0,m.jsx)(i.Text,{children:"Directory: "}),(0,m.jsx)(Z,{value:_,onChange:y,onSubmit:V})]}),(0,m.jsxs)(i.Text,{color:"gray",marginTop:1,children:["Project will be created at: ",N]})]});if(h===de){return(0,m.jsxs)(i.Box,{flexDirection:"column",children:[(0,m.jsx)(i.Text,{bold:!0,color:"cyan",children:"Confirm Project Generation"}),(0,m.jsxs)(i.Box,{marginY:1,flexDirection:"column",children:[(0,m.jsxs)(i.Text,{children:["Name: ",(0,m.jsx)(i.Text,{color:"green",children:l?.name||"Untitled"})]}),(0,m.jsxs)(i.Text,{children:["Type: ",(0,m.jsx)(i.Text,{color:"yellow",children:e})]}),(0,m.jsxs)(i.Text,{children:["Path: ",(0,m.jsx)(i.Text,{color:"cyan",children:N})]}),(0,m.jsx)(i.Text,{color:"gray",marginTop:1,children:"Options:"}),(0,m.jsxs)(i.Text,{color:"gray",children:[" - GitHub Actions: ",D.setupGitHubActions?"Yes":"No"]}),(0,m.jsxs)(i.Text,{color:"gray",children:[" - AGENTS.md: ",D.setupAgents?"Yes":"No"]}),(0,m.jsxs)(i.Text,{color:"gray",children:[" - CLAUDE.md: ",D.setupClaudeCode?"Yes":"No"]}),(0,m.jsxs)(i.Text,{color:"gray",children:[" - GEMINI.md: ",D.setupGeminiCLI?"Yes":"No"]}),(0,m.jsxs)(i.Text,{color:"gray",children:[" - Run bun install: ",D.runBunInstall?"Yes":"No"]}),(0,m.jsxs)(i.Text,{color:"gray",children:[" - Initialize git: ",D.initGit?"Yes":"No"]})]}),(0,m.jsx)(k,{items:[{label:"Confirm & Generate",value:"confirm"},{label:"← Change Directory",value:"back"},{label:"Cancel",value:"cancel"}],onSelect:F})]})}if(h===ue||h===xe)return(0,m.jsxs)(i.Box,{flexDirection:"column",children:[(0,m.jsx)(i.Text,{bold:!0,color:"cyan",children:"Generating Project..."}),(0,m.jsxs)(i.Box,{marginY:1,children:[(0,m.jsx)(i.Text,{color:"green",children:(0,m.jsx)(f,{type:"dots"})}),(0,m.jsxs)(i.Text,{children:[" ",E]})]})]});if(h===he&&O){return(0,m.jsxs)(i.Box,{flexDirection:"column",children:[(0,m.jsx)(i.Text,{bold:!0,color:"green",children:"Project initialized successfully!"}),(0,m.jsxs)(i.Box,{marginY:1,flexDirection:"column",children:[(0,m.jsxs)(i.Text,{children:["Path: ",(0,m.jsx)(i.Text,{color:"cyan",children:O.path})]}),(0,m.jsxs)(i.Text,{children:["Files: ",(0,m.jsx)(i.Text,{color:"green",children:O.files})]}),(0,m.jsxs)(i.Text,{children:["Dependencies:"," ",(0,m.jsx)(i.Text,{color:O.bunInstalled?"green":"yellow",children:O.bunInstalled?"Installed":"Not installed (run bun install manually)"})]}),(0,m.jsxs)(i.Text,{children:["Git:"," ",(0,m.jsx)(i.Text,{color:O.gitInitialized?"green":"yellow",children:O.gitInitialized?"Initialized":"Not initialized"})]})]}),(0,m.jsx)(i.Text,{bold:!0,marginY:1,children:"Next steps:"}),(0,m.jsxs)(i.Text,{color:"gray",children:[" cd ",M]}),!O.bunInstalled&&(0,m.jsx)(i.Text,{color:"gray",children:" bun install"}),(0,m.jsx)(i.Text,{color:"gray",children:" bun preview"}),(0,m.jsxs)(i.Text,{color:"gray",marginTop:1,children:["For more information, see ",M,"/README.md"]}),(0,m.jsx)(i.Box,{marginTop:1,children:(0,m.jsx)(k,{items:[{label:"← Back to Detail",value:"back"},{label:"Exit CLI",value:"exit"}],onSelect:H})})]})}return null};const je=()=>{var e=(0,i.useApp)().exit,l=(0,n.useState)(u.MAIN),t=a(l,2),o=t[0],x=t[1],h=(0,n.useState)(null),g=a(h,2),f=g[0],j=g[1],v=(0,n.useState)(null),_=a(v,2),y=_[0],B=_[1],S=(0,n.useState)(!0),E=a(S,2),w=E[0],L=E[1],I=(0,n.useState)(null),A=a(I,2),C=A[0],R=A[1],k=(0,n.useState)([]),q=a(k,2),K=q[0],Q=q[1],Z=(0,n.useState)(null),ee=a(Z,2),le=ee[0],te=ee[1],ie=(0,n.useState)([]),oe=a(ie,2),re=oe[0],ae=oe[1],se=(0,n.useState)(null),ce=a(se,2),de=ce[0],ue=ce[1],xe=(0,n.useState)([]),he=a(xe,2),ge=he[0],fe=he[1],me=(0,n.useState)(null),je=a(me,2),De=je[0],Te=je[1],be=(0,n.useState)([]),ve=a(be,2),_e=ve[0],ye=ve[1],Be=(0,n.useState)(null),Se=a(Be,2),Ee=Se[0],we=Se[1],Le=(0,n.useState)([]),Ie=a(Le,2),Ae=Ie[0],Ce=Ie[1],Re=(0,n.useState)(!1),ke=a(Re,2),Ue=ke[0],Oe=ke[1],Pe=(0,n.useState)(null),Me=a(Pe,2),Ne=Me[0],Ge=Me[1],Ve=(0,n.useState)(null),Fe=a(Ve,2),He=Fe[0],$e=Fe[1],qe=(0,n.useState)(null),ze=a(qe,2),Ye=ze[0],We=ze[1],Xe=(0,n.useState)(null),Je=a(Xe,2),Ke=Je[0],Qe=Je[1],Ze=(0,n.useState)([]),el=a(Ze,2),ll=el[0],tl=el[1],nl=(0,n.useState)(null),il=a(nl,2),ol=il[0],rl=il[1],al=(0,n.useState)([]),sl=a(al,2),cl=sl[0],dl=sl[1],ul=(0,n.useState)(null),xl=a(ul,2),hl=xl[0],gl=xl[1],fl=o===u.DEVICES,ml=o===u.DEVICE_DETAIL,pl=o===u.GROUPS,jl=o===u.GROUP_DETAIL;(0,n.useEffect)(()=>{var e=(0,c.getCurrentProfile)(),l=(0,c.getToken)(e);if(!l)return R("Not logged in. Run `bricks auth login` first."),void L(!1);var t=(0,s.createClient)((0,c.getBaseUrl)(),l);j(t),t.workspace().then(e=>{B(e),L(!1)}).catch(e=>{R(e.message),L(!1)})},[]),(0,i.useInput)((l,t)=>{"q"===l&&e(),t.escape&&(o===u.DEVICE_CONTROL?(x(u.DEVICE_DETAIL),Ge(null)):o===u.DEVICE_SCREENSHOT?(x(u.DEVICE_DETAIL),We(null),Qe(null)):o===u.DEVICE_DETAIL?(x(u.DEVICES),te(null)):o===u.APP_DETAIL?(x(u.APPS),ue(null)):o===u.MODULE_DETAIL?(x(u.MODULES),Te(null)):o===u.GROUP_DETAIL?(x(u.GROUPS),we(null),Ce([])):o===u.MEDIA_FILE_DETAIL?(x(u.MEDIA_FILES),gl(null)):o===u.MEDIA_FILES?(x(u.MEDIA_BOX_DETAIL),gl(null)):o===u.MEDIA_BOX_DETAIL?(x(u.MEDIA_BOXES),rl(null),dl([])):(o===u.MEDIA_BOXES||o!==u.MAIN)&&x(u.MAIN))},{isActive:o!==u.APP_SHORT_EDIT&&o!==u.MODULE_SHORT_EDIT&&o!==u.APP_PROJECT_INIT&&o!==u.MODULE_PROJECT_INIT});var Dl,Tl,bl,vl,_l,yl,Bl,Sl,El=(0,n.useCallback)(r(function*(){if(f){L(!0);try{var e=yield f.devices({});Q(e||[])}catch(e){R(e.message)}L(!1)}}),[f]),wl=(0,n.useCallback)((Dl=r(function*(e){if(f){L(!0),$e(null);try{var l=yield f.device({id:e});te(l)}catch(e){$e(e.message)}L(!1)}}),function(e){return Dl.apply(this,arguments)}),[f]),Ll=(0,n.useCallback)(r(function*(){if(f){L(!0);try{var e=yield f.applications({});ae(e||[])}catch(e){R(e.message)}L(!1)}}),[f]),Il=(0,n.useCallback)((Tl=r(function*(e){if(f){L(!0),$e(null);try{var l=yield f.application({id:e});ue(l)}catch(e){$e(e.message)}L(!1)}}),function(e){return Tl.apply(this,arguments)}),[f]),Al=(0,n.useCallback)(r(function*(){if(f){L(!0);try{var e=yield f.modules({});fe(e||[])}catch(e){R(e.message)}L(!1)}}),[f]),Cl=(0,n.useCallback)((bl=r(function*(e){if(f){L(!0),$e(null);try{var l=yield f.module({id:e});Te(l)}catch(e){$e(e.message)}L(!1)}}),function(e){return bl.apply(this,arguments)}),[f]),Rl=(0,n.useCallback)(r(function*(){if(f){L(!0);try{var e=yield f.deviceGroups({});ye(e||[])}catch(e){R(e.message)}L(!1)}}),[f]),kl=(0,n.useCallback)((vl=r(function*(e){if(f){L(!0),$e(null);try{var l=yield Promise.all([f.deviceGroup({id:e}),f.devicesByGroup({id:e})]),t=a(l,2),n=t[0],i=t[1];we(n),Ce(i||[])}catch(e){$e(e.message)}L(!1)}}),function(e){return vl.apply(this,arguments)}),[f]),Ul=(0,n.useCallback)(r(function*(){if(f){L(!0);try{var e=yield f.mediaBoxes();tl(e||[])}catch(e){R(e.message)}L(!1)}}),[f]),Ol=(0,n.useCallback)((_l=r(function*(e){if(f){L(!0),$e(null);try{var l=yield f.mediaBox({id:e});rl(l)}catch(e){$e(e.message)}L(!1)}}),function(e){return _l.apply(this,arguments)}),[f]),Pl=(0,n.useCallback)((yl=r(function*(e){if(f){L(!0);try{var l=yield f.mediaFiles({boxId:e});dl(l||[])}catch(e){R(e.message)}L(!1)}}),function(e){return yl.apply(this,arguments)}),[f]),Ml=(0,n.useCallback)((Bl=r(function*(e){if(f){L(!0),$e(null);try{var l=yield f.mediaFile({id:e});gl(l)}catch(e){$e(e.message)}L(!1)}}),function(e){return Bl.apply(this,arguments)}),[f]),Nl=(0,n.useCallback)((Sl=r(function*(e){if(f&&le){Oe(!0),Ge(null);try{yield f.controlDevice({id:le._id,type:e}),Ge({success:!0,message:`Command sent: ${e}`})}catch(e){Ge({success:!1,message:e.message})}Oe(!1)}}),function(e){return Sl.apply(this,arguments)}),[f,le]),Gl=(0,n.useCallback)(r(function*(e=!1){if(f&&le&&y){L(!0),Qe(null),We(null);try{e&&(yield f.controlDevice({id:le._id,type:"take-screenshot"}),yield new Promise(e=>setTimeout(e,3e3)));var l=yield(0,d.he)(f,y,le._id,null,{preferThumbnail:!0});l.error?Qe(l.error):We(l)}catch(e){Qe(e.message)}L(!1)}}),[f,le,y]),Vl=p((0,n.useCallback)(()=>{f&&El()},[f,El]),fl),Fl=p((0,n.useCallback)(()=>{f&&le&&wl(le._id)},[f,le,wl]),ml),Hl=p((0,n.useCallback)(()=>{f&&Rl()},[f,Rl]),pl),$l=p((0,n.useCallback)(()=>{f&&Ee&&kl(Ee._id)},[f,Ee,kl]),jl);return w&&!y?(0,m.jsxs)(i.Box,{flexDirection:"column",children:[(0,m.jsx)(D,{workspace:y,view:o}),(0,m.jsx)(b,{text:"Connecting to workspace..."})]}):C&&!y?(0,m.jsxs)(i.Box,{flexDirection:"column",children:[(0,m.jsx)(D,{workspace:y,view:o}),(0,m.jsxs)(i.Text,{color:"red",children:["Error: ",C]}),(0,m.jsx)(T,{})]}):(0,m.jsxs)(i.Box,{flexDirection:"column",children:[(0,m.jsx)(D,{workspace:y,view:o}),o===u.MAIN&&(0,m.jsx)(U,{onSelect:l=>{"exit"!==l.value?(x(l.value),l.value===u.DEVICES?El():l.value===u.APPS?Ll():l.value===u.MODULES?Al():l.value===u.GROUPS?Rl():l.value===u.MEDIA_BOXES&&Ul()):e()},mediaEnabled:(0,d.wR)(y)}),o===u.DEVICES&&(0,m.jsx)(O,{devices:K,loading:w,onSelect:e=>{if("back"!==e.value){if("refresh"===e.value)return El(),void Vl.resetCountdown();te(null),L(!0),x(u.DEVICE_DETAIL),wl(e.value)}else x(u.MAIN)},countdown:Vl.countdown,lastRefreshTime:Vl.lastRefreshTime}),o===u.DEVICE_DETAIL&&(0,m.jsx)(P,{device:le,loading:w,error:He,onSelect:e=>"back"===e.value?(x(u.DEVICES),void te(null)):"refresh"===e.value?(wl(le._id),void Fl.resetCountdown()):("control"===e.value&&(x(u.DEVICE_CONTROL),Ge(null)),void("screenshot"===e.value&&(x(u.DEVICE_SCREENSHOT),We(null),Qe(null),Gl(!1)))),mediaEnabled:(0,d.wR)(y),countdown:Fl.countdown,lastRefreshTime:Fl.lastRefreshTime}),o===u.DEVICE_CONTROL&&(0,m.jsx)(M,{device:le,onSelect:e=>{if("back"===e.value)return x(u.DEVICE_DETAIL),void Ge(null);Nl(e.value)},controlling:Ue,controlResult:Ne}),o===u.DEVICE_SCREENSHOT&&(0,m.jsx)(N,{device:le,screenshot:Ye,loading:w,error:Ke,onSelect:e=>{if("back"===e.value)return x(u.DEVICE_DETAIL),We(null),void Qe(null);"refresh"!==e.value?"take"===e.value&&Gl(!0):Gl(!1)}}),o===u.APPS&&(0,m.jsx)(G,{apps:re,loading:w,onSelect:e=>{"back"!==e.value?"refresh"!==e.value?(ue(null),L(!0),x(u.APP_DETAIL),Il(e.value)):Ll():x(u.MAIN)}}),o===u.APP_DETAIL&&(0,m.jsx)(V,{app:de,loading:w,error:He,onSelect:e=>{if("back"===e.value)return x(u.APPS),void ue(null);"refresh"!==e.value?("short_edit"===e.value&&(x(u.APP_SHORT_EDIT),$e(null)),"project_init"===e.value&&(x(u.APP_PROJECT_INIT),$e(null))):Il(de._id)}}),o===u.APP_SHORT_EDIT&&(0,m.jsx)(ne,{instanceType:"application",instance:de,client:f,onDone:r(function*(){return Il(de._id)}),onCancel:()=>x(u.APP_DETAIL)}),o===u.APP_PROJECT_INIT&&(0,m.jsx)(pe,{type:"application",instance:de,client:f,onDone:()=>x(u.APP_DETAIL),onCancel:()=>x(u.APP_DETAIL)}),o===u.MODULES&&(0,m.jsx)(F,{modules:ge,loading:w,onSelect:e=>{"back"!==e.value?"refresh"!==e.value?(Te(null),L(!0),x(u.MODULE_DETAIL),Cl(e.value)):Al():x(u.MAIN)}}),o===u.MODULE_DETAIL&&(0,m.jsx)(H,{module:De,loading:w,error:He,onSelect:e=>{if("back"===e.value)return x(u.MODULES),void Te(null);"refresh"!==e.value?("short_edit"===e.value&&(x(u.MODULE_SHORT_EDIT),$e(null)),"project_init"===e.value&&(x(u.MODULE_PROJECT_INIT),$e(null))):Cl(De._id)}}),o===u.MODULE_SHORT_EDIT&&(0,m.jsx)(ne,{instanceType:"module",instance:De,client:f,onDone:r(function*(){return Cl(De._id)}),onCancel:()=>x(u.MODULE_DETAIL)}),o===u.MODULE_PROJECT_INIT&&(0,m.jsx)(pe,{type:"module",instance:De,client:f,onDone:()=>x(u.MODULE_DETAIL),onCancel:()=>x(u.MODULE_DETAIL)}),o===u.GROUPS&&(0,m.jsx)($,{groups:_e,loading:w,onSelect:e=>{if("back"!==e.value){if("refresh"===e.value)return Rl(),void Hl.resetCountdown();we(null),Ce([]),L(!0),x(u.GROUP_DETAIL),kl(e.value)}else x(u.MAIN)},countdown:Hl.countdown,lastRefreshTime:Hl.lastRefreshTime}),o===u.GROUP_DETAIL&&(0,m.jsx)(z,{group:Ee,groupDevices:Ae,loading:w,error:He,onSelect:e=>{if("back"===e.value)return x(u.GROUPS),we(null),void Ce([]);"refresh"===e.value&&(kl(Ee._id),$l.resetCountdown())},countdown:$l.countdown,lastRefreshTime:$l.lastRefreshTime}),o===u.MEDIA_BOXES&&(0,m.jsx)(Y,{boxes:ll,loading:w,onSelect:e=>{"back"!==e.value?"refresh"!==e.value?(rl(null),dl([]),L(!0),x(u.MEDIA_BOX_DETAIL),Ol(e.value)):Ul():x(u.MAIN)}}),o===u.MEDIA_BOX_DETAIL&&(0,m.jsx)(W,{box:ol,loading:w,error:He,onSelect:e=>{if("back"===e.value)return x(u.MEDIA_BOXES),rl(null),void dl([]);"refresh"!==e.value?"files"===e.value&&(dl([]),gl(null),x(u.MEDIA_FILES),Pl(ol.id)):Ol(ol.id)}}),o===u.MEDIA_FILES&&(0,m.jsx)(X,{files:cl,box:ol,loading:w,onSelect:e=>{if("back"===e.value)return x(u.MEDIA_BOX_DETAIL),void gl(null);"refresh"!==e.value?(gl(null),L(!0),x(u.MEDIA_FILE_DETAIL),Ml(e.value)):Pl(ol.id)}}),o===u.MEDIA_FILE_DETAIL&&(0,m.jsx)(J,{file:hl,loading:w,error:He,onSelect:e=>{if("back"===e.value)return x(u.MEDIA_FILES),void gl(null);"refresh"===e.value&&Ml(hl.id)}}),(0,m.jsx)(T,{})]})};var De=()=>{(0,i.render)((0,m.jsx)(o.TerminalInfoProvider,{children:(0,m.jsx)(je,{})}))}}};
|
package/lib/890.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const __webpack_esm_id__=890;export const __webpack_esm_ids__=[890];export const __webpack_esm_modules__={6343:(e,r,a)=>{const{v4:t}=a(3502),i=a(5479),{nameMap:n,brickMapping:o,generatorMapping:s}=a(3981);r.idByItem=(e={})=>e.canvas_id||e.subspace_id||e.brick_id||e.generator_id||e.property_bank_id||e.property_bank_calc_id||e.bank_id||e.scene_id,r.getAnimationType=e=>e.type||e.compose_type||e.composeType,r.cleanUpAnimationMap=e=>Object.entries(e).reduce((e,[r,a])=>((a.type||a.compose_type)&&(e[r]=a),e),{}),r.matchItemByItem=(e,r)=>{if(!e)return!1;let a;switch("string"==typeof r&&(a=r),e.type){case"brick":return e.brick_id===(a||r.brick_id);case"subspace":return e.subspace_id===(a||r.subspace_id);case"canvas":return e.canvas_id===(a||r.canvas_id);case"generator":return e.generator_id===(a||r.generator_id);case"property_bank":return e.property_bank_id===(a||r.property_bank_id);default:return!1}},r.makePasscode=()=>t(),r.kindOneOfTypes={string:["color","datetime","id","graphql","rich-text-content","sandbox-script","llm-prompt","media-resource-image","media-resource-video","media-resource-audio","media-resource-file","lottie-file-uri","rive-file-uri","ggml-model-asset","gguf-model-asset","binary-asset"],number:["unit"],object:["tts-speaker-config"],"array-object":["llm-tools","llm-messages","mcp-server-resources","mcp-server-tools","mcp-server-prompts"]},r.getKindOneOfTypes=(e,a)=>"array"===e?"object"===a?r.kindOneOfTypes[`${e}-${a}`]:void 0:r.kindOneOfTypes[e],r.unitOneOfTypes=["grid","px","ms"],r.idOneOfTypes=["canvas","brick","generator","animation","property_bank"],r.typeToName={brick:"Brick",generator:"Generator",subspace:"Subspace",canvas:"Canvas",animation:"Animation",property_bank:"Data",property_bank_calc:"Calculation"},r.getBrickName=(e,a,t)=>{if(!a)return e.toUpperCase();if(a.title)return a.title;let o;switch(e){case"bank":o="BANK";break;case"subspace":o="SUBSPACE";break;case"canvas":o="CANVAS";break;case"animation":o=`<${i(r.getAnimationType(a))}>`;break;case"property_bank":o="<Data>";break;case"property_bank_calc":o="<Map>";break;case"state_group":o="<Switch Case>";break;default:o=`<${n[a.template_key||a.templateKey]||"Unknown"}>`}return t&&t.length>10?o+=` (${t.replace(/[A-Z_]+/g,"").substr(0,6)}...)`:t&&(o+=` (${t})`),o},r.getCallInternalActions=e=>{const r=o[e]||s[e];if(r)return r.callInternalActions},r.mapToList=(e,a)=>Object.entries(a).reduce((a,[t,i])=>(a.push({id:t,...i,title:r.getBrickName(e,i,t)}),a),[]);const p={subspaceMap:"subspace",brickMap:"brick",generatorMap:"generator",propertyBankMap:"property_bank",propertyAvailableToAdd:"property_bank",canvasMap:"canvas",animationMap:"animation"},c={};r.mapToListForDerivedState=(e,a,t,i)=>{const n=t[e]||c;return n!==i[e]?{[e]:n,[a]:r.mapToList(p[e],n)}:{}},r.arrayTypePrefix="array of ",r.propertyBankTypes=["string","number","bool","object","any",`${r.arrayTypePrefix}string`,`${r.arrayTypePrefix}number`,`${r.arrayTypePrefix}bool`,`${r.arrayTypePrefix}object`],r.animationRunTypes=["once","loop"],r.stopPropagationOnKeyBackspace=e=>{8===e.keyCode&&e.stopPropagation()},r.nestedTypes=["object","array","any"],r.isPropertyBankTypeNested=e=>r.nestedTypes.includes(e),r.propertyTypeToSchema=e=>{const a=e.indexOf(r.arrayTypePrefix)>-1,t=e.replace(r.arrayTypePrefix,"");return{type:t,properties:"object"===t?{}:void 0,allowNewItem:a,allowCustomProperty:"object"===t}}},8890:(e,r,a)=>{const{getDocByTemplateKey:t}=a(3981),i=a(211),n=a(5907),{getBrickName:o}=a(6343);r.checkConfigDeprecatedFeatures=e=>{const r=[];return Object.entries(e.subspace_map||{}).forEach(([e,a])=>{Object.entries(a.brick_map||{}).forEach(([i,n])=>{void 0===n.property?.borderLeftWidth&&void 0===n.property?.borderRightWidth&&void 0===n.property?.borderTopWidth&&void 0===n.property?.borderBottomWidth||r.push({id:i,name:"Used Deprecated Feature",data:`In v2.16, we have been changed \`Border Width\` to \`Border Size\` (Unit \`px\` to \`grid\`). The \`${o("brick",n,i)}\` brick still used the border width. Please re-edit it to transfer to the new unit.`});const s=t(n.template_key);s?.brickMeta?.deprecated&&r.push({id:i,name:"Used Deprecated Feature",data:`The \`${o("brick",n,i)}\` brick in \`${o("subspace",a,e)}\` have been deprecated, it may not work in the future, please consider to remove it. If you can't see the item, please enable \`Show Deprecated Features\` in setting.`})}),Object.entries(a.generator_map||{}).forEach(([i,n])=>{const s=t(n.template_key);s?.brickMeta?.deprecated&&r.push({id:i,name:"Used Deprecated Feature",data:`The \`${o("brick",n,i)}\` brick in \`${o("subspace",a,e)}\` have been deprecated, it may not work in the future, please consider to remove it. If you can't see the item, please enable \`Show Deprecated Features\` in setting.`})})}),r},r.checkConfig=e=>{const r={schema:i(e),ref:n(e)};return r.valid=0===r.schema.length&&0===r.ref.length,r.message=r.schema.concat(r.ref).map(({dataPath:e,field:r,message:a})=>`${e||r}: ${a}`).join("\n"),r}}};
|