import{sn as e}from"./call-_dlYen_W.js";import{i as t,r as n,t as r}from"./node-commands-8GBOiktk.js";const i=[`canvas.present`,`canvas.hide`,`canvas.navigate`,`canvas.eval`,`canvas.snapshot`,`canvas.a2ui.push`,`canvas.a2ui.pushJSONL`,`canvas.a2ui.reset`],a=[`camera.list`],o=[`camera.snap`,`camera.clip`],s=[`screen.record`],c=[`location.get`],l=[...[`notifications.list`],`notifications.actions`],u=[`device.info`,`device.status`],d=[...u,`device.permissions`,`device.health`],f=[`contacts.search`],p=[`contacts.add`],m=[`calendar.events`],h=[`calendar.add`],g=[`reminders.list`],_=[`reminders.add`],v=[`photos.latest`],y=[`motion.activity`,`motion.pedometer`],b=[`sms.send`],x=[n],S=[...t,n,r],C=[...i,...a,...c,n],w=[...o,...s,...p,...h,..._,...b],T={ios:[...i,...a,...c,...u,...f,...m,...g,...v,...y,...x],android:[...i,...a,...c,...l,n,...d,...f,...m,...g,...v,...y],macos:[...i,...a,...c,...u,...f,...m,...g,...v,...y,...S],linux:[...S],windows:[...S],unknown:[...C]},E=[{id:`ios`,prefixes:[`ios`]},{id:`android`,prefixes:[`android`]},{id:`macos`,prefixes:[`mac`,`darwin`]},{id:`windows`,prefixes:[`win`]},{id:`linux`,prefixes:[`linux`]}],D=[{id:`ios`,tokens:[`iphone`,`ipad`,`ios`]},{id:`android`,tokens:[`android`]},{id:`macos`,tokens:[`mac`]},{id:`windows`,tokens:[`windows`]},{id:`linux`,tokens:[`linux`]}];function O(e){for(let t of E)if(t.prefixes.some(t=>e.startsWith(t)))return t.id}function k(e){for(let t of D)if(t.tokens.some(t=>e.includes(t)))return t.id}function A(t,n){return O(e(t))||(k(e(n))??`unknown`)}function j(e,t){let n=T[A(t?.platform,t?.deviceFamily)]??T.unknown,r=e.gateway?.nodes?.allowCommands??[],i=new Set(e.gateway?.nodes?.denyCommands??[]),a=new Set([...n,...r].map(e=>e.trim()).filter(Boolean));for(let e of i){let t=e.trim();t&&a.delete(t)}return a}function M(e){let t=e.command.trim();if(!t)return{ok:!1,reason:`command required`};if(!e.allowlist.has(t))return{ok:!1,reason:`command not allowlisted`};if(Array.isArray(e.declaredCommands)&&e.declaredCommands.length>0){if(!e.declaredCommands.includes(t))return{ok:!1,reason:`command not declared by node`}}else return{ok:!1,reason:`node did not declare commands`};return{ok:!0}}export{M as n,j as r,w as t};
