@camstack/addon-admin-ui 1.2.711 → 1.2.712

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 (95) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/assets/{AccessSection-AIpZlwxO.js → AccessSection-BMHyeXXs.js} +1 -1
  3. package/dist/assets/{Addons-hU_fWopb.js → Addons-Czq7HK5o.js} +1 -1
  4. package/dist/assets/{AdminPage-CEHWflgd.js → AdminPage-DgcMq51y.js} +1 -1
  5. package/dist/assets/{AdminSectionedPage-dotwaj8o.js → AdminSectionedPage-BKAltoSC.js} +1 -1
  6. package/dist/assets/{AiProfiles-C0U_Edl7.js → AiProfiles-C3dVuuEs.js} +1 -1
  7. package/dist/assets/Archive-DD70ZFMv.js +1 -0
  8. package/dist/assets/{BootstrapSettingsForm-BBeQw3lq.js → BootstrapSettingsForm-DNIVKIZZ.js} +1 -1
  9. package/dist/assets/Build-B0vH9mDa.js +40 -0
  10. package/dist/assets/{Calendars-D8KLSblw.js → Calendars-B1cBJoa1.js} +1 -1
  11. package/dist/assets/{Cluster-zF_gXM_9.js → Cluster-BMZ_3SCr.js} +1 -1
  12. package/dist/assets/CompositionBlockEditor-Bj14wly_.js +2 -0
  13. package/dist/assets/{CompositionEditorPage-DtI14l9N.js → CompositionEditorPage-sUNp8qe7.js} +1 -1
  14. package/dist/assets/{Data-xJLAfERW.js → Data-DcunBcmb.js} +1 -1
  15. package/dist/assets/DeviceDetail-CUJRNGTx.js +1 -0
  16. package/dist/assets/{Devices-D5MT_v0Z.js → Devices-DxX8ybfM.js} +1 -1
  17. package/dist/assets/{EmbedDevicePage-Ugq5wlK_.js → EmbedDevicePage-G-VhlNDT.js} +1 -1
  18. package/dist/assets/{EmbedPlayerPage-OuqicvX2.js → EmbedPlayerPage-CVF9_4Ua.js} +1 -1
  19. package/dist/assets/{History-Bts05Ze9.js → History-DhTpectV.js} +1 -1
  20. package/dist/assets/{Identity-ByCLSEvY.js → Identity-BhsJ_1aP.js} +1 -1
  21. package/dist/assets/{InstancesTable-DnlFxw5B.js → InstancesTable-w-0XwFaG.js} +1 -1
  22. package/dist/assets/{IntegrationDetail-B_bLy2pT.js → IntegrationDetail-jDFoyrP9.js} +1 -1
  23. package/dist/assets/{Integrations-DaVrDDJ0.js → Integrations-C28hBhrU.js} +1 -1
  24. package/dist/assets/{Integrations-D1RoIeBe.js → Integrations-C9wh6FxD.js} +1 -1
  25. package/dist/assets/{Library-CZAHEUDs.js → Library-Cia1655I.js} +1 -1
  26. package/dist/assets/{Locations-B7nkcRUX.js → Locations-C1F9DRbX.js} +1 -1
  27. package/dist/assets/{Logs-DI0KlEbj.js → Logs-D24n8jj9.js} +1 -1
  28. package/dist/assets/{MaskShapeCanvas-BmW3cBvx.js → MaskShapeCanvas-mnq8FU_f.js} +1 -1
  29. package/dist/assets/{MotionZonesSettings-E1JiKqu9.js → MotionZonesSettings-D7_18_A_.js} +1 -1
  30. package/dist/assets/{MyAccess-C4lodqcX.js → MyAccess-CHM9pog8.js} +1 -1
  31. package/dist/assets/{Network-Ct2wpBcf.js → Network-dIj7QC_n.js} +1 -1
  32. package/dist/assets/{NewExportModal-B7PD25jZ.js → NewExportModal-94DuvHcM.js} +1 -1
  33. package/dist/assets/{NodeAddonsSettingsPanel-YwplZhej.js → NodeAddonsSettingsPanel-D_zP_si3.js} +1 -1
  34. package/dist/assets/Notifications-BtDiQ8BU.js +1 -0
  35. package/dist/assets/{PanelContent-BeFcR75x.js → PanelContent-_kL0sZaa.js} +1 -1
  36. package/dist/assets/{Pipeline-BffUx3BA.js → Pipeline-Cz-2Qr0F.js} +1 -1
  37. package/dist/assets/{PrivacyMaskSettings-D-MffrSL.js → PrivacyMaskSettings-D4w4a5Cj.js} +1 -1
  38. package/dist/assets/{SceneMonitorEditor-CY_3hsvd.js → SceneMonitorEditor-CUpdk172.js} +1 -1
  39. package/dist/assets/{SessionsList-BiwWycIZ.js → SessionsList-DoB89UjE.js} +1 -1
  40. package/dist/assets/{Showroom-0s5B_CeO.js → Showroom-Bc0RMx1T.js} +1 -1
  41. package/dist/assets/{StorageLocationsTable-C1DVGBNx.js → StorageLocationsTable-DdQZaTIL.js} +1 -1
  42. package/dist/assets/{System-BwuY4roI.js → System-xU_4F1qj.js} +1 -1
  43. package/dist/assets/TemplateEditorDialog-DFNJgsxk.js +1 -0
  44. package/dist/assets/{Terminal-05LvIPmb.js → Terminal-CF3uGeFD.js} +1 -1
  45. package/dist/assets/{TrainingProviders-Bn3XcU87.js → TrainingProviders-B_G3A6On.js} +1 -1
  46. package/dist/assets/{Viewer-CEGgQL3O.js → Viewer-WyKz0Azc.js} +1 -1
  47. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DDhXAQLs.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CkUFXaiW.js} +1 -1
  48. package/dist/assets/{action-draft-DZRCzvUT.js → action-draft-CwJf5eW2.js} +1 -1
  49. package/dist/assets/{ai-page.helpers-BqFZuECV.js → ai-page.helpers-BHBXHNQI.js} +1 -1
  50. package/dist/assets/{assignment-candidates-HrM1L9T_.js → assignment-candidates-DRmDIzIf.js} +1 -1
  51. package/dist/assets/{authed-media-1CgRYZwt.js → authed-media-DQnc3x5u.js} +1 -1
  52. package/dist/assets/{board-model-BOzVRklS.js → board-model-CAPxQYkg.js} +1 -1
  53. package/dist/assets/{camera-block-model-BhMWHCN1.js → camera-block-model-Cvhw1ACQ.js} +1 -1
  54. package/dist/assets/{client-BsVqhZVt.js → client-CU9hiVrv.js} +9 -9
  55. package/dist/assets/{command-vocab-CtYEjFuy.js → command-vocab-3vo0YGZY.js} +1 -1
  56. package/dist/assets/{device-integration-icon-ZlePL-_n.js → device-integration-icon-CZX0mESs.js} +1 -1
  57. package/dist/assets/device-picker-model-BoRMX84w.js +1 -0
  58. package/dist/assets/{dist-DbcyxH5L.js → dist-BWrpV4hP.js} +1 -1
  59. package/dist/assets/{dist-0V6xn4uA.js → dist-LYFPq0g9.js} +1 -1
  60. package/dist/assets/{format-CcYZ7maC.js → format-kIcasnZL.js} +1 -1
  61. package/dist/assets/{hostInit-D-lwg3-d.js → hostInit-BZDzYAHr.js} +1 -1
  62. package/dist/assets/i18n-B5Xm3ktp.js +1 -0
  63. package/dist/assets/{icons-B2CVt1RT.js → icons-Cnaoe6qZ.js} +1 -1
  64. package/dist/assets/{index-BoIO5dDB.js → index-ByN-VTu-.js} +4 -4
  65. package/dist/assets/index-CaKMKRxP.css +2 -0
  66. package/dist/assets/{linked-devices-model-fPUtRPaP.js → linked-devices-model-B9Gz49sE.js} +1 -1
  67. package/dist/assets/{mf-entry-bootstrap-0-92a26d32.js → mf-entry-bootstrap-0-ac9760ea.js} +2 -2
  68. package/dist/assets/mount-BoRMX84w.js +1 -0
  69. package/dist/assets/{notification-rule-status-hMaW4ja5.js → notification-rule-status-CFjuiCT9.js} +1 -1
  70. package/dist/assets/{player-overlays-u4qsAGYn.js → player-overlays-C-OmGoqt.js} +1 -1
  71. package/dist/assets/remoteEntry-ComxP4sU.js +1 -0
  72. package/dist/assets/src-BL1KpPQ2.js +279 -0
  73. package/dist/assets/{sso-popup-TOufVS-B.js → sso-popup-D9gVafKd.js} +1 -1
  74. package/dist/assets/{step-inspector-model-CdKo7nrB.js → step-inspector-model-zgo3LXy6.js} +1 -1
  75. package/dist/assets/{use-scenes-feed-MgmG62bq.js → use-scenes-feed-C4jyU72L.js} +1 -1
  76. package/dist/assets/{useAdminDeviceRemoval-B-tQ7WmY.js → useAdminDeviceRemoval-B5adL9sz.js} +1 -1
  77. package/dist/assets/useEventInvalidation-BoRMX84w.js +1 -0
  78. package/dist/assets/{useNodeUrlSelection-BZYxtInW.js → useNodeUrlSelection-vqyOWkjs.js} +1 -1
  79. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DnfMKM8x.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DV6hhcvX.js} +2 -2
  80. package/dist/index.html +9 -9
  81. package/dist/server/addon.js +1 -1
  82. package/package.json +2 -2
  83. package/dist/assets/Archive-Dco2WJrr.js +0 -1
  84. package/dist/assets/Build-D-Naokiz.js +0 -40
  85. package/dist/assets/CompositionBlockEditor-DCbO8CrA.js +0 -2
  86. package/dist/assets/DeviceDetail-DuJyhGDF.js +0 -1
  87. package/dist/assets/Notifications-Dz97CCgI.js +0 -1
  88. package/dist/assets/TemplateEditorDialog-DJH053yf.js +0 -1
  89. package/dist/assets/device-picker-model-DmUpoaWG.js +0 -1
  90. package/dist/assets/i18n-C-O-HI_i.js +0 -1
  91. package/dist/assets/index-CK-kENqn.css +0 -2
  92. package/dist/assets/mount-DmUpoaWG.js +0 -1
  93. package/dist/assets/remoteEntry-By4S20tm.js +0 -1
  94. package/dist/assets/src-D8P6H9lv.js +0 -279
  95. package/dist/assets/useEventInvalidation-DmUpoaWG.js +0 -1
@@ -1110,7 +1110,7 @@ ${d.map(({leaf:e,path:t})=>D_e(e,t)).join(`
1110
1110
  for (const dispose of disposers) dispose()
1111
1111
  }
1112
1112
  }
1113
- `}function R_e(e){return`subjects`in e?e.subjects:e.classes.map(c_)}var z_e=new Set(Object.values(n_.mapping));function B_e(e){return n_.mapping[e]??e}function V_e(e,t){let n=e.toLowerCase(),r=t.toLowerCase();return n===r?!0:z_e.has(n)&&B_e(r)===n}function H_e(e){return e===`start`||e===`update`||e===`end`}var U_e=class{trigger;fired=new Map;subjects;constructor(e){this.trigger=e,this.subjects=R_e(e)}get firedCount(){return this.fired.size}evaluate(e,t){let{deviceId:n,trackId:r,phase:i}=e;if(typeof n!=`number`||typeof r!=`string`||!H_e(i))return{kind:`ignore`,why:`malformed track-lifecycle event`};if(!this.trigger.deviceIds.includes(n))return{kind:`ignore`,why:`device ${n} is not one of the trigger's devices`};let a=`${n}|${r}`;if(i===`end`)return this.fired.delete(a),{kind:`ignore`,why:`track ended`};this.expire(t);let o=typeof e.bestClassName==`string`?e.bestClassName:``,s=typeof e.bestConfidence==`number`?e.bestConfidence:0,c={deviceId:n,className:o,trackId:r,score:s,label:``};if(this.fired.has(a))return{kind:`reject`,reason:`already fired for track ${r}`,vars:c};let l=f_(this.subjects,{className:o,...Array.isArray(e.classes)?{classes:e.classes.filter(e=>typeof e==`string`)}:{},...typeof e.label==`string`?{label:e.label}:{},...typeof e.identityId==`string`?{identityId:e.identityId}:{},...typeof e.plateText==`string`?{plateText:e.plateText}:{}});if(!l.matches)return{kind:`reject`,reason:l.reason,vars:c};let u={...c,label:l.label};if(this.trigger.minScore!==void 0&&s<this.trigger.minScore)return{kind:`reject`,reason:`score ${s} < ${this.trigger.minScore}`,vars:u};if(this.trigger.zones!==void 0){let t=Array.isArray(e.zonesVisited)?e.zonesVisited.filter(e=>typeof e==`string`):[];if(!this.trigger.zones.some(e=>t.includes(e)))return{kind:`reject`,reason:`zone mismatch: visited [${t.join(`, `)}], wanted [${this.trigger.zones.join(`, `)}]`,vars:u}}return this.remember(a,t),{kind:`fire`,reason:`${l.label===``?o:l.label} ${s} on device ${n}`,vars:u}}remember(e,t){for(this.fired.set(e,t);this.fired.size>512;){let e=this.fired.keys().next();if(e.done===!0)break;this.fired.delete(e.value)}}expire(e){for(let[t,n]of this.fired){if(e-n<9e5)break;this.fired.delete(t)}}};function W_e(e){return`classes`in e}function G_e(e){return e===`appeared`||e===`departed`}function K_e(e,t){let{deviceId:n,entryId:r,phase:i}=t;if(typeof n!=`number`||typeof r!=`string`||!G_e(i))return{kind:`ignore`,why:`malformed stationary-changed event`};if(!e.deviceIds.includes(n))return{kind:`ignore`,why:`device ${n} is not one of the trigger's devices`};if(i!==e.phase)return{kind:`ignore`,why:`phase ${i}, the trigger wants ${e.phase}`};let a=typeof t.className==`string`?t.className:``,o=Array.isArray(t.zones)?t.zones.filter(e=>typeof e==`string`):[],s={deviceId:n,className:a,zones:o,phase:i,entryId:r},c=W_e(e)?e.classes?.map(c_):e.subjects;if(c!==void 0){let e=f_(c,{className:a});if(!e.matches)return{kind:`reject`,reason:e.reason,vars:s}}return e.zones!==void 0&&!e.zones.some(e=>o.includes(e))?{kind:`reject`,reason:`zone mismatch: in [${o.join(`, `)}], wanted [${e.zones.join(`, `)}]`,vars:s}:{kind:`fire`,reason:`${a} ${i} on device ${n}`,vars:s}}var Ab=b({deviceId:n(),eventType:l(),sourceId:l().optional(),data:m(l(),C()).nullable(),timestamp:n().meta(M(`none`)),seq:n().meta(M(`count`))}),jb=b({eventTypes:S(l()),vocabulary:S(Cme).default([]),lastEvent:Ab.nullable(),eventCountSinceStart:n().meta(M(`count`))}),Mb={name:`event-emitter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.EventEmitter],methods:{},events:{onEvent:{data:Ab,trigger:{category:w.EventEmitted,label:P(`Fired an event`,`Ha generato un evento`),phrase:P(`When {device} fires an event`,`Quando {device} genera un evento`),icon:`zap`}}},status:{schema:jb,kind:`push`},runtimeState:jb,durability:`session`,history:`none`,vocabulary:{noun:P(`Event source`,`Sorgente di eventi`),order:5280}},q_e=3,J_e=32;function Y_e(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`}function Nb(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Pb(e){let t={},n=(e,r,i)=>{if(!(Object.keys(t).length>=J_e)){if(Y_e(e)){t[r]=e;return}if(!(!Nb(e)||i>=q_e))for(let[t,a]of Object.entries(e))n(a,`${r}.${t}`,i+1)}};if(Nb(e))for(let[t,r]of Object.entries(e))n(r,`data.${t}`,1);return t}function X_e(e,t){let n=e;for(let e of t.split(`.`)){if(!Nb(n))return;n=n[e]}return n}function Fb(e,t){return t===null?!0:e.timestamp===t.timestamp?e.seq>t.seq:e.timestamp>t.timestamp}var Ib=`recovered by reconcile`,Z_e=class{leaf;#e=null;#t=!1;#n=null;constructor(e){this.leaf=e}onEvent(e){let t=Ab.safeParse(e);if(!t.success)return{kind:`ignore`,why:`malformed event`};let n=t.data;return n.deviceId===this.leaf.deviceId?Fb(n,this.#e)?(this.#e={timestamp:n.timestamp,seq:n.seq},this.#t=!0,this.#i(n,!1)):{kind:`ignore`,why:`this fire was already handled`}:{kind:`ignore`,why:`device ${n.deviceId} is not the trigger's device`}}onStatus(e){let t=jb.safeParse(e);if(!t.success)return{kind:`ignore`,why:`the event-emitter status is unreadable`};this.#n=kme(t.data);let n=t.data.lastEvent,r=!this.#t;return this.#t=!0,n===null?{kind:`ignore`,why:`the device has not fired`}:Fb(n,this.#e)?(this.#e={timestamp:n.timestamp,seq:n.seq},r?{kind:`ignore`,why:`seeded: what fired before the start is not a trigger`}:n.deviceId===this.leaf.deviceId?this.#i(n,!0):{kind:`ignore`,why:`device ${n.deviceId} is not the trigger's device`}):{kind:`ignore`,why:`this fire was already handled`}}#r(e){let t=this.#n??Dme([e.eventType]);return(kg(t,e.eventType,e.sourceId)??kg(t,e.eventType))?.kind}#i(e,t){let{eventIds:n,sourceIds:r,kinds:i,match:a}=this.leaf;if(n!==void 0&&!n.includes(e.eventType))return{kind:`ignore`,why:`event ${e.eventType} is not one of [${n.join(`, `)}]`};if(r!==void 0&&(e.sourceId===void 0||!r.includes(e.sourceId)))return{kind:`ignore`,why:`source ${e.sourceId??`(none)`} is not one of [${r.join(`, `)}]`};let o=this.#r(e);if(i!==void 0&&(o===void 0||!i.includes(o)))return{kind:`ignore`,why:`kind ${o??`(none)`} is not one of [${i.join(`, `)}]`};let s={deviceId:e.deviceId,eventType:e.eventType,sourceId:e.sourceId??``,eventKind:o??``},c=Pb(e.data);for(let t of a??[]){let n=X_e(e.data,t.path);if(n!==t.equals)return{kind:`reject`,reason:`data.${t.path} is ${JSON.stringify(n)??`not set`}, the trigger wants ${JSON.stringify(t.equals)}`,vars:s,data:c}}let l=`${e.eventType}${e.sourceId===void 0?``:` from ${e.sourceId}`}`;return{kind:`fire`,reason:t?`${l} — ${Ib}`:l,vars:s,data:c}}},Lb=6e4;function Rb(e){return(e/Lb).toFixed(1)}var Q_e=class{mode;active=0;pending=0;constructor(e){this.mode=e}get activeRuns(){return this.active}get queuedTriggers(){return this.pending}admit(){let e=this.mode;switch(e.mode){case`single`:case`cooldown`:return this.active>0?{decision:`drop`,reason:`${e.mode}: a run is already in progress`}:(this.active+=1,{decision:`run`,reason:`${e.mode}: no run in progress`});case`restart`:return this.active>0?(this.active+=1,{decision:`restart`,reason:`restart: aborting ${this.active-1} run(s) in progress`}):(this.active+=1,{decision:`run`,reason:`restart: no run in progress`});case`queued`:return this.active===0?(this.active+=1,{decision:`run`,reason:`queued: no run in progress`}):this.pending<e.max?(this.pending+=1,{decision:`queued`,reason:`queued: a run is in progress, waiting ${this.pending} of ${e.max}`}):{decision:`drop`,reason:`queued: a run is in progress and the queue is full (${e.max})`};case`parallel`:return this.active<e.max?(this.active+=1,{decision:`run`,reason:`parallel: ${this.active} of ${e.max} running`}):{decision:`drop`,reason:`parallel: ${e.max} runs already in progress`}}}release(){return this.active>0&&--this.active,this.mode.mode===`queued`&&this.pending>0?(--this.pending,this.active+=1,!0):!1}cooldown(e){if(this.mode.mode!==`cooldown`)return{ok:!0,bypassed:!1,reason:``};let t=this.mode.minutes*Lb;if(e.lastRunStartedAt===null)return{ok:!0,bypassed:!1,reason:`cooldown ${this.mode.minutes} min: no earlier run`};let n=e.now-e.lastRunStartedAt;if(n>=t)return{ok:!0,bypassed:!1,reason:`cooldown ${this.mode.minutes} min: last run started ${Rb(n)} min ago`};let r=`${Rb(t-n)} min left`;return e.manual?{ok:!0,bypassed:!0,reason:`cooldown ${this.mode.minutes} min bypassed by a manual trigger (${r})`}:{ok:!1,bypassed:!1,reason:`cooldown ${this.mode.minutes} min: last run started ${Rb(n)} min ago, ${r}`}}},zb=x([`string`,`number`,`boolean`,`select`]),$_e=/^[A-Za-z_][A-Za-z0-9_]*$/,Bb=h([l(),n(),v()]),Vb=b({name:l().regex($_e),label:l().min(1).max(120).optional(),type:zb,required:v().optional(),default:Bb.optional(),options:S(l().min(1)).min(1).optional()}).superRefine((e,t)=>{e.type===`select`&&e.options===void 0&&t.addIssue({code:`custom`,message:`a select variable needs options`,path:[`options`]}),e.default!==void 0&&Hb(e,e.default)!==null&&t.addIssue({code:`custom`,message:Hb(e,e.default)??`invalid default`,path:[`default`]})});function Hb(e,t){switch(e.type){case`string`:return typeof t==`string`?null:`variable "${e.name}" must be a string`;case`number`:return typeof t==`number`&&Number.isFinite(t)?null:`variable "${e.name}" must be a number`;case`boolean`:return typeof t==`boolean`?null:`variable "${e.name}" must be true or false`;case`select`:return typeof t==`string`&&(e.options??[]).includes(t)?null:`variable "${e.name}" must be one of ${(e.options??[]).join(`, `)}`}}function eve(e,t){let n=e??[],r=t??{};for(let e of Object.keys(r))if(!n.some(t=>t.name===e))return{ok:!1,error:`unknown variable "${e}"`};let i={};for(let e of n){let t=r[e.name]??e.default;if(t===void 0){if(e.required===!0)return{ok:!1,error:`variable "${e.name}" is required`};continue}let n=Hb(e,t);if(n!==null)return{ok:!1,error:n};i[e.name]=t}return{ok:!0,values:i}}var Ub=x([`internal`,`addon`]),Wb=`internal:`;function tve(e){return`${Wb}${e}`}function Gb(e){return e.startsWith(`internal:`)&&e.length>9}function Kb(e){if(Gb(e))return null;let t=e.indexOf(`:`);return t>0&&t<e.length-1?e.slice(0,t):null}var qb=b({isRunning:v(),lastRunAt:n().nullable(),lastError:l().nullable()}),nve={isRunning:!1,lastRunAt:null,lastError:null},Jb=n().int().min(0).max(86400),Yb=b({id:l().min(3),name:l().min(1).max(120),addonId:l().min(1),source:Ub,readOnly:v(),steps:S(vv).min(1).max(50).optional(),variables:S(Vb).max(20).optional(),minDelaySec:Jb.optional(),tags:Vh.optional(),status:qb}).superRefine((e,t)=>{if(e.source===`internal`){Gb(e.id)||t.addIssue({code:`custom`,message:`an internal action id is internal:<uuid>`,path:[`id`]});return}e.steps!==void 0&&t.addIssue({code:`custom`,message:`only an internal action carries steps`,path:[`steps`]}),e.readOnly||t.addIssue({code:`custom`,message:`an addon action is read-only here`,path:[`readOnly`]}),Kb(e.id)===null&&t.addIssue({code:`custom`,message:`an addon action id is <addonId>:<localId>`,path:[`id`]})}),Xb=b({name:l().min(1).max(120),steps:S(vv).min(1).max(50),variables:S(Vb).max(20).optional(),minDelaySec:Jb.optional(),tags:Vh.optional()}),Zb=b({blockId:l().min(1).optional()}),Qb=h([yy,p(`started`),p(`timed-out`)]),$b=b({runId:l().min(1),outcome:Qb,message:l().optional()}),rve=x([`not-found`,`read-only`,`invalid-variables`,`invalid-steps`,`not-linked`,`template-scope`,`busy`]),ive=class extends Error{code;constructor(e,t){super(`[${e}] ${t}`),this.name=`ActionError`,this.code=e}},ex=b({actionId:l(),runId:l(),isRunning:v(),outcome:yy.optional(),lastRunAt:n().nullable(),lastError:l().nullable()});function ave(e){switch(e.kind){case`wait`:case`command`:return`else`in e?e.else??[]:[];case`parallel`:case`repeat`:return e.steps;case`choose`:return[...e.branches.flatMap(e=>e.steps),...e.else??[]];default:return[]}}function tx(e){return[...e.kind===`command`&&e.target.kind===`devices`?[{actionId:e.actionId,ids:e.target.ids}]:[],...ave(e).flatMap(tx)]}async function ove(e,t){let n=e.flatMap(tx);if(n.length===0)return;let r=[...new Set(n.flatMap(e=>e.ids))],i=r.length===0?new Map:await t.boundCapsOf(r);for(let{actionId:e,ids:t}of n){Va(e,void 0);for(let n of t)Wne(e,n,i.get(n)??[])}}async function sve(e,t,n=Date.now,r,i,a){let o=r?.mirror??new ub(ob(e));await o.refresh(t);let s=_b(e,o,n(),{...r===void 0?{}:{holds:r.holds,rootPath:r.rootPath},...i===void 0?{}:{site:i},trigger:a??`unknown`}),c=s.nodes.filter(e=>e.outcome!==`pass`).map(e=>e.reason)[0];return s.unknown?{result:`unknown`,reason:`a state the condition reads is not known${c===void 0?``:` (${c})`}`}:s.pass?{result:`true`,reason:`the condition holds`}:{result:`false`,reason:c??`the condition does not hold`}}async function cve(e){try{return await e()}catch(e){return{result:`unknown`,reason:e instanceof Error?e.message:String(e)}}}async function lve(e){let t=e.now(),n=t+e.timeoutMs;for(;;){let r=await cve(e.read),i=e.now()-t;if(e.isAborted())return{result:`aborted`,waitedMs:i};if(r.result===`true`)return{result:`met`,waitedMs:i};let a=n-e.now();if(a<=0)return{result:`timed-out`,waitedMs:i,lastReason:r.reason};if(await e.nextWake(a),e.isAborted())return{result:`aborted`,waitedMs:e.now()-t}}}function uve(e,t){return`timed out after ${e} s: ${t}`}function nx(e){return ma(e)}function rx(e){let t=nx(e);if(t===void 0)return[];let n=Vl(t);return n===void 0?[t]:[t,...Kl(n).filter(e=>e!==t)]}var ix=b({path:l(),deviceId:n().int().optional(),field:l(),value:n(),assumedUnit:l(),message:l()});function dve(e){let t=qg(e);return t instanceof le?t:void 0}function ax(e){let t=new Map(e.map(e=>[e.name,e]));return{fieldQuantity(e,n){let r=t.get(e)?.status;if(r!==void 0)return[...Jg(r.schema),...r.itemArray===void 0?[]:rhe(r.itemArray)].find(e=>e.path===n)?.quantity},paramMeta(e,n,r){let i=t.get(e)?.methods[n]?.input;if(i===void 0)return;let a=dve(i)?.shape[r];return a===void 0?void 0:uhe(a)}}}function ox(e){return Xg(e)??e}function sx(e){return rx(e).length>1}function cx(e){return{...e,message:`${e.field}: the bare number ${e.value} was taken as ${e.assumedUnit} — send { value, unit } to state the unit`}}function lx(e,t){t_({value:1,unit:e,target:t})}function fve(e,t,n){let r=t.fieldQuantity(e.cap,e.fieldPath),i=r===void 0?void 0:nx(r),a=e_(e.value)||e.unit!==void 0;if(i===void 0||r===void 0){if(a)throw new Qg(`no-quantity`,`${e.cap}.${e.fieldPath} is not a quantity — it takes no unit`);return{leaf:e,warnings:[]}}if(e_(e.value)){let t=t_({value:e.value.value,unit:e.value.unit,target:i});return{leaf:{...e,value:t,unit:ox(e.value.unit)},warnings:[]}}return typeof e.value==`number`?e.unit===void 0?sx(r)?{leaf:e,warnings:[cx({path:n,deviceId:e.deviceId,field:e.fieldPath,value:e.value,assumedUnit:i})]}:{leaf:e,warnings:[]}:(lx(e.unit,i),{leaf:e,warnings:[]}):{leaf:e,warnings:[]}}function ux(e,t,n=`when`){switch(e.kind){case`device-is`:{let{leaf:r,warnings:i}=fve(e,t,n);return{value:r,warnings:i}}case`not`:{let r=ux(e.child,t,`${n}.child`);return{value:{...e,child:r.value},warnings:r.warnings}}case`all`:case`any`:{let r=e.children.map((e,r)=>ux(e,t,`${n}.children.${r}`));return{value:{...e,children:r.map(e=>e.value)},warnings:r.flatMap(e=>e.warnings)}}default:return{value:e,warnings:[]}}}function pve(e,t,n){if(La(e.actionId)===void 0)return{value:e,warnings:[]};let r=e.target.kind===`devices`&&e.target.ids.length===1?e.target.ids[0]:void 0,{cap:i,method:a}=Va(e.actionId,void 0),o={...e.args},s={...e.argUnits},c=[];for(let[n,r]of Object.entries(e.argUnits??{})){let e=t.paramMeta(i,a,n);if(e===void 0)throw new Qg(`no-quantity`,`${i}.${a}(${n}) is not a quantity — it takes no unit`);lx(r,e.unit)}for(let[l,u]of Object.entries(e.args??{})){let e=t.paramMeta(i,a,l);e!==void 0&&(e_(u)?(o[l]=t_({value:u.value,unit:u.unit,target:e.unit}),s[l]=ox(u.unit)):typeof u==`number`&&s[l]===void 0&&sx(e.quantity)&&c.push(cx({path:`${n}.args.${l}`,...r===void 0?{}:{deviceId:r},field:l,value:u,assumedUnit:e.unit})))}let{argUnits:l,...u}=e;return{value:{...u,...e.args===void 0?{}:{args:o},...Object.keys(s).length>0?{argUnits:s}:{}},warnings:c}}function dx(e,t,n=`steps`){let r=[],i=[];return e.forEach((e,a)=>{if(e.kind!==`command`){r.push(e);return}let o=pve(e,t,`${n}.${a}`);r.push(o.value),i.push(...o.warnings)}),{value:r,warnings:i}}function fx(e,t){let n=ux(e.when,t,`when`),r=dx(e.actions,t,`actions`);return{value:{...e,when:n.value,actions:r.value},warnings:[...n.warnings,...r.warnings]}}function px(e,t){switch(e.kind){case`device-is`:{if(typeof e.value!=`number`||e.unit!==void 0)return e;let n=t.fieldQuantity(e.cap,e.fieldPath);if(n===void 0||rx(n).length<2)return e;let r=nx(n);return r===void 0?e:{...e,unit:r}}case`not`:return{...e,child:px(e.child,t)};case`all`:case`any`:return{...e,children:e.children.map(e=>px(e,t))};default:return e}}function mve(e,t){if(e.kind!==`command`||e.args===void 0||La(e.actionId)===void 0)return e;let{cap:n,method:r}=Va(e.actionId,void 0),i={...e.argUnits};for(let[a,o]of Object.entries(e.args)){if(typeof o!=`number`||i[a]!==void 0)continue;let e=t.paramMeta(n,r,a);e!==void 0&&rx(e.quantity).length>1&&(i[a]=e.unit)}return Object.keys(i).length===0?e:{...e,argUnits:i}}function mx(e,t){let n={...e,when:px(e.when,t),actions:e.actions.map(e=>mve(e,t))};try{return{ok:!0,recipe:fx(n,t).value}}catch(e){if(e instanceof Qg)return{ok:!1,error:e.message};throw e}}var hve=[`devices`,`time`,`cameras`,`events`,`logic`,`system`],hx=[`trigger`,`any`],gx=[`trigger`,`guard`,`any`],_x={detection:{kind:`detection`,category:`cameras`,role:`event`,allowedIn:hx,i18nKey:`automation.leafCatalog.detection`,keywords:[`camera`,`person`,`vehicle`,`animal`,`object`,`motion`,`detected`],needsDeviceValue:!1,seed:()=>({kind:`detection`,subjects:[{macro:`person`}],deviceIds:[]})},stationary:{kind:`stationary`,category:`cameras`,role:`event`,allowedIn:hx,i18nKey:`automation.leafCatalog.stationary`,keywords:[`camera`,`parked`,`stops`,`leaves`,`left`,`appeared`,`object`],needsDeviceValue:!1,seed:()=>({kind:`stationary`,deviceIds:[],phase:`appeared`})},"device-becomes":{kind:`device-becomes`,category:`devices`,role:`event`,allowedIn:hx,i18nKey:`automation.leafCatalog.device-becomes`,keywords:[`device`,`value`,`changes`,`turns`,`on`,`off`,`above`,`below`,`state`],needsDeviceValue:!0,seed:()=>({kind:`device-becomes`,deviceId:0,cap:``,fieldPath:``})},"device-event":{kind:`device-event`,category:`events`,role:`event`,allowedIn:hx,i18nKey:`automation.leafCatalog.device-event`,keywords:[`event`,`system`,`button`,`press`,`doorbell`,`alarm`,`category`],needsDeviceValue:!1,seed:()=>({kind:`device-event`,category:``})},"device-fired":{kind:`device-fired`,category:`devices`,role:`event`,allowedIn:hx,i18nKey:`automation.leafCatalog.device-fired`,keywords:[`button`,`press`,`long`,`remote`,`switch`,`key`,`fires`,`event`,`click`],needsDeviceValue:!1,seed:()=>({kind:`device-fired`,deviceId:0})},schedule:{kind:`schedule`,category:`time`,role:`event`,allowedIn:hx,i18nKey:`automation.leafCatalog.schedule`,keywords:[`time`,`clock`,`daily`,`cron`,`sunrise`,`sunset`,`at`,`weekday`],needsDeviceValue:!1,seed:()=>({kind:`schedule`,cron:`0 30 23 * * *`})},interval:{kind:`interval`,category:`time`,role:`event`,allowedIn:hx,i18nKey:`automation.leafCatalog.interval`,keywords:[`time`,`every`,`minutes`,`repeat`,`periodic`,`timer`],needsDeviceValue:!1,seed:()=>({kind:`interval`,minutes:5})},manual:{kind:`manual`,category:`system`,role:`event`,allowedIn:hx,i18nKey:`automation.leafCatalog.manual`,keywords:[`run`,`button`,`hand`,`test`,`on demand`],needsDeviceValue:!1,seed:()=>({kind:`manual`})},"device-is":{kind:`device-is`,category:`devices`,role:`state`,allowedIn:gx,i18nKey:`automation.leafCatalog.device-is`,keywords:[`device`,`value`,`is`,`equals`,`above`,`below`,`held`,`stable`,`for`],needsDeviceValue:!0,seed:()=>({kind:`device-is`,deviceId:0,cap:``,fieldPath:``,operator:`eq`,value:``})},"stationary-present":{kind:`stationary-present`,category:`cameras`,role:`state`,allowedIn:gx,i18nKey:`automation.leafCatalog.stationary-present`,keywords:[`camera`,`parked`,`present`,`car`,`object`,`still there`],needsDeviceValue:!1,seed:()=>({kind:`stationary-present`,deviceId:0})},"time-is":{kind:`time-is`,category:`time`,role:`state`,allowedIn:gx,i18nKey:`automation.leafCatalog.time-is`,keywords:[`time`,`hour`,`window`,`between`,`night`,`day`,`weekday`,`sunset`,`sunrise`],needsDeviceValue:!1,seed:()=>({kind:`time-is`,between:{from:{kind:`clock`,hh:22,mm:0},to:{kind:`clock`,hh:6,mm:0}}})},"triggered-by":{kind:`triggered-by`,category:`logic`,role:`state`,allowedIn:gx,i18nKey:`automation.leafCatalog.triggered-by`,keywords:[`trigger`,`triggered`,`started`,`which`,`branch`,`fired`],needsDeviceValue:!1,seed:()=>({kind:`triggered-by`,leafIds:[]})},expression:{kind:`expression`,category:`logic`,role:`state`,allowedIn:gx,i18nKey:`automation.leafCatalog.expression`,keywords:[`formula`,`math`,`arithmetic`,`sum`,`compare`,`calculate`,`held`],needsDeviceValue:!1,seed:()=>({kind:`expression`,expr:``,bindings:{}})}},vx=[`detection`,`stationary`,`device-becomes`,`device-fired`,`device-event`,`schedule`,`interval`,`manual`,`device-is`,`stationary-present`,`time-is`,`triggered-by`,`expression`];function gve(e){return _x[e]}function _ve(e){return _x[e].seed()}function vve(e){return vx.filter(t=>_x[t].allowedIn.includes(e))}function yx(e){return e instanceof Error?e.message:String(e)}function yve(e){return e.startsWith(`[busy]`)?`already-running`:e.startsWith(`[not-found]`)?`not-found`:null}async function bve(e,t,n){let{exporter:r,actionId:i}=n,a={actionId:i},o=(e,n)=>(t.warn(`${r}: exported action not run — ${e}`,{tags:a,meta:{reason:e,...n?{detail:n}:{}}}),{status:`refused`,reason:e});try{let n=await e.actions.run.mutate({actionId:i});if(n.outcome===`skipped-overlap`)return o(`already-running`,n.message);if(n.outcome===`skipped-cooldown`)return o(`cooldown`,n.message);if(n.outcome===`failed`||n.outcome===`aborted`||n.outcome===`timed-out`){let e=n.message??n.outcome;return t.warn(`${r}: exported action failed`,{tags:a,meta:{outcome:n.outcome,message:e}}),{status:`failed`,message:e}}return t.info(`${r}: exported action ran`,{tags:a,meta:{outcome:n.outcome}}),{status:`started`}}catch(e){let n=yx(e),i=yve(n);return i===null?(t.warn(`${r}: exported action failed`,{tags:a,meta:{message:n}}),{status:`failed`,message:n}):o(i,n)}}async function xve(e,t,n){let{exporter:r,targetId:i}=n,a={targetId:i};try{let{targets:o,unreadable:s}=await kd(e),c=o.find(e=>e.id===i);if(c===void 0&&s.length>0)throw Error(`notification targets unreadable from ${s.map(e=>e.addonId).join(`, `)}`);if(c===void 0)return t.warn(`${r}: exported notifier not used — target-gone`,{tags:a,meta:{reason:`target-gone`}}),{status:`refused`,reason:`target-gone`};if(!c.enabled)return t.warn(`${r}: exported notifier not used — target-disabled`,{tags:a,meta:{reason:`target-disabled`}}),{status:`refused`,reason:`target-disabled`};let l=await e.notificationOutput.send.mutate({targetId:i,addonId:c.addonId,notification:$u.parse(n.notification)});if(!l.success){let e=l.error??`send failed`;return t.warn(`${r}: exported notifier send failed`,{tags:a,meta:{message:e}}),{status:`failed`,message:e}}return{status:`sent`}}catch(e){let n=yx(e);return t.warn(`${r}: exported notifier send failed`,{tags:a,meta:{message:n}}),{status:`failed`,message:n}}}function Sve(e,t,n,r){let i=[],a=[];for(let o of e)o.kind===`action`&&!t.actionIds.has(o.actionId)?(a.push(o),n.warn(`${r}: exported action was deleted — dropped from the export`,{tags:{actionId:o.actionId}})):o.kind===`notifier`&&!t.targetIds.has(o.targetId)?(a.push(o),n.warn(`${r}: exported notifier target was deleted — dropped from the export`,{tags:{targetId:o.targetId}})):i.push(o);return{kept:i,dropped:a}}var bx=l().min(1),xx=b({instanceId:bx.optional()}),Sx=b({instanceId:bx,name:l(),enabled:v(),kind:l().optional(),nameRule:l().optional()}),Cx=`export-instance-unknown`,wx=class extends Error{code=Cx;instanceId;constructor(e,t){super(`${Cx}: ${e} serves no instance "${t}"`),this.name=`ExportInstanceUnknownError`,this.instanceId=t}};function Tx(e){return`instanceId`in e?e.instanceId:void 0}function Cve(e,t,n){if(n!==void 0&&n!==t)throw new wx(e,n)}var wve=x([`unlinked`,`linked`,`error`]),Ex=b({label:l(),value:l(),secret:v().optional()}),Dx=b({qr:l().optional(),fields:S(Ex).readonly().optional(),note:l().optional()}),Ox=b({linkState:wve,exposedDeviceCount:n(),error:l().optional(),setup:Dx.optional()}),Tve=l(),kx=b({deviceId:l(),exposedAs:l().optional(),exposedName:l().optional(),capabilities:S(l()).optional()}),Ax=b({instanceId:bx,deviceId:l(),capabilities:S(l()).optional(),exposedName:l().nullable().optional()}),jx=b({instanceId:bx,deviceId:l(),name:l().nullable(),dryRun:v().optional()}),Mx=`export-name-refused`,Nx=class extends Error{code=Mx;instanceId;reason;constructor(e,t){super(`${Mx}: ${t}`),this.name=`ExportNameRefusedError`,this.instanceId=e,this.reason=t}},Px=b({instanceId:bx,deviceId:l()}),Fx=x([`device`,`action`,`notifier`]),Ix=i(`kind`,[b({kind:p(`device`),deviceId:l()}),b({kind:p(`action`),actionId:l().min(1)}),b({kind:p(`notifier`),targetId:l().min(1)})]),Lx=b({entity:Ix,exposedAs:l().optional()}),Rx=b({instanceId:bx,entity:Ix}),zx=b({instanceId:bx,entity:Ix}),Bx={name:`device-export`,scope:`system`,mode:`collection`,providerKind:`device-export`,status:{schema:Ox,kind:`poll`},exposesDeviceSettings:!0,methods:{getStatus:k(xx,Ox),listInstances:k(_(),S(Sx)),listSupportedDeviceKinds:k(xx,S(Tve)),listExposedDevices:k(xx,S(kx)),exposeDevice:k(Ax,_(),{kind:`mutation`,auth:`admin`}),unexposeDevice:k(Px,_(),{kind:`mutation`,auth:`admin`}),setExposedName:k(jx,_(),{kind:`mutation`,auth:`admin`}),listSupportedEntityKinds:A(_(),S(Fx)),listExposedEntities:A(xx,S(Lx)),exposeEntity:A(Rx,_(),{kind:`mutation`,auth:`admin`}),unexposeEntity:A(zx,_(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`exports to other ecosystems — configured on the export pages`}},Vx=`exposedNames`,Eve=m(l(),l());function Hx(e,t){if(e==null)return{ok:!0,name:null};if(typeof e!=`string`)return{ok:!1,reason:`The name must be text.`};let n=e.trim().replace(/\s+/g,` `);return n.length===0?{ok:!0,name:null}:t(n)}function Ux(e){let t=Eve.safeParse(e[Vx]);return t.success?t.data:{}}function Dve(e,t,n){let r=Ux(e)[t];if(r===void 0)return null;let i=Hx(r,n);return i.ok?i.name:null}function Wx(e,t,n){let r=Object.fromEntries(Object.entries(Ux(e)).filter(([e])=>e!==t));return{[Vx]:n===null?r:{...r,[t]:n}}}async function Ove(e){let t=Hx(e.raw,e.validate);if(!t.ok)throw new Nx(e.instanceId,t.reason);if(e.dryRun===!0)return{changed:!1,name:t.name};let n=await e.store.read(e.deviceId);return(Ux(n)[e.instanceId]??null)===t.name?{changed:!1,name:t.name}:(await e.store.write(e.deviceId,Wx(n,e.instanceId,t.name)),{changed:!0,name:t.name})}function kve(e,t){let n=()=>{if(e===void 0)throw Error(`${t}: settings are not available`);return e};return{read:e=>n().readDeviceStore(e),write:(e,t)=>n().writeDeviceStore(e,t)}}async function Ave(e,t){let n=await e.listDeviceStoreIds();if(n.length===0)return[];let r=[];for(let[i,a]of await e.readDeviceStoreBatch(n))Ux(a)[t]!==void 0&&(await e.writeDeviceStore(i,Wx(a,t,null)),r.push(i));return r}function jve(e,t){return n=>n.length>t?{ok:!1,reason:`The name is ${n.length} characters; ${e} allows at most ${t}.`}:/\p{Cc}/u.test(n)?{ok:!1,reason:`The name may not contain control characters.`}:{ok:!0,name:n}}var Gx=[`automation`,`action`,`scheduler`,`composition`],Mve=x(Gx),Kx=b({id:n().int().nonnegative(),name:l().min(1),type:l().min(1),room:l().min(1).nullable(),addonId:l().min(1),stableId:l().min(1),caps:S(l().min(1)),zones:S(l().min(1)).optional()}),Nve=b({timeZone:l().min(1),location:b({latitude:n(),longitude:n()}).nullable(),rooms:S(l().min(1)),devices:S(Kx).min(1),actions:S(b({id:l().min(1),name:l().min(1)})).default([])}),Pve=60,qx=b({childDeviceIds:S(n()).readonly(),hiddenChildIds:S(n()).readonly()}),Jx={name:`accessories`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Camera,T.Switch,T.Light,T.Sensor,T.Climate,T.Cover,T.Lock,T.Fan,T.MediaPlayer,T.AlarmPanel,T.Generic],methods:{setChildHidden:k(b({deviceId:n().int().nonnegative(),childDeviceId:n().int().nonnegative(),hidden:v()}),_(),{kind:`mutation`,auth:`admin`})},events:{onAccessoriesChanged:{data:b({deviceId:n(),childDeviceIds:S(n()).readonly(),hiddenChildIds:S(n()).readonly()}),notOperatorFacing:`the device’s child list changed — administration, not a happening`},onChildVisibilityChanged:{data:b({deviceId:n(),childDeviceId:n(),hidden:v()}),notOperatorFacing:`an operator hid or showed a child — administration, not a happening`}},status:{schema:qx,kind:`command-driven`},vocabulary:{noun:P(`Accessories`,`Accessori`),order:3e3}},Yx={name:`action-source`,scope:`system`,mode:`collection`,methods:{listActions:k(b({}),S(Yb),{auth:`admin`}),runAction:k(b({actionId:l().min(1),variables:m(l(),Bb).optional()}),_(),{kind:`mutation`,auth:`admin`}),stopAction:k(b({actionId:l().min(1)}),_(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:j.INTERNAL}},Fve=60*6e4,Ive=3e4,Xx=363e4;function Lve(e){let t=0;for(let n of e)n.kind===`wait`&&(t+=n.seconds*1e3);return t}var Zx=b({actionId:l().min(1)}),Qx=b({deviceId:n().int().nonnegative(),actionIds:S(l().min(1)).max(100)}),$x={name:`actions`,scope:`system`,mode:`singleton`,methods:{list:k(b({}),S(Yb),{auth:`admin`}),get:k(b({actionId:l().min(1),deviceId:n().int().nonnegative().optional()}),b({action:Yb.nullable()}),{role:`viewer`,auth:`protected`,kind:`query`,caller:`required`}),run:k(b({actionId:l().min(1),variables:m(l(),Bb).optional(),wait:v().optional(),origin:Zb.optional(),deviceId:n().int().nonnegative().optional()}),$b,{role:`viewer`,auth:`protected`,kind:`mutation`,caller:`required`,timeoutMs:Xx}),stop:k(Zx,_(),{kind:`mutation`,auth:`admin`}),getTraces:k(Zx,b({traces:S(Oy)}),{auth:`admin`}),create:k(b({action:Xb}),b({action:Yb,warnings:S(ix).optional()}),{kind:`mutation`,auth:`admin`}),update:k(b({actionId:l().min(1),action:Xb.partial()}),b({action:Yb,warnings:S(ix).optional()}),{kind:`mutation`,auth:`admin`}),delete:k(Zx,_(),{kind:`mutation`,auth:`admin`}),listForCamera:k(b({deviceId:n().int().nonnegative()}),S(Yb),{role:`viewer`,auth:`protected`,kind:`query`}),getLinks:k(b({deviceId:n().int().nonnegative()}),Qx,{auth:`admin`}),setLinks:k(Qx,Qx,{kind:`mutation`,auth:`admin`})},events:{onRunChanged:{data:ex}},vocabulary:{notOperatorFacing:`declared actions — run from the Actions page and from the cameras that link them`}},Rve=b({id:l(),label:l(),icon:l(),path:l(),remoteName:l(),bundle:l(),section:l().optional(),sectionLabel:l().optional()}),eS=b({addonId:l(),page:Rve,bundleUrl:l()}),tS={name:`addon-pages`,scope:`system`,mode:`singleton`,methods:{listPages:k(_(),S(eS).readonly())},vocabulary:{notOperatorFacing:j.UI_PLUMBING}},zve=b({method:x([`GET`,`POST`,`PUT`,`DELETE`,`PATCH`]),path:l(),access:x([`public`,`authenticated`,`admin`]).optional(),description:l().optional(),rateLimit:x([`auth`]).optional(),perInstance:v().optional()}),Bve=b({method:l(),path:l(),params:m(l(),l()),query:m(l(),l()),body:C(),headers:m(l(),l()),instanceId:l().optional(),user:b({id:l(),username:l(),isAdmin:v()}).optional(),scopedToken:C().optional()}),Vve=b({status:n().int(),headers:m(l(),l()),redirectUrl:l().nullable(),body:C().optional(),contentType:l().optional()}),nS={name:`addon-routes`,scope:`system`,mode:`collection`,internal:!0,methods:{getRoutes:k(_(),S(zve)),invoke:k(Bve,Vve,{kind:`mutation`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:j.UI_PLUMBING}},rS=b({id:l(),label:l(),icon:l(),order:n().optional()}),iS=b({id:l(),title:l(),titleKey:l().optional(),description:l().optional(),descriptionKey:l().optional(),style:x([`card`,`accordion`]).optional(),defaultCollapsed:v().optional(),columns:h([p(1),p(2),p(3),p(4)]).optional(),tab:l().optional(),location:x([`settings`,`top-tab`,`hero`]).optional(),order:n().optional(),fields:S(_e())}),aS=b({tabs:S(rS).optional(),sections:S(iS)}),oS=m(l(),C()),sS=x(ur),Hve=b({cap:l(),scope:sS,sectionIds:S(l())}),cS=b({success:p(!0)}),lS={name:`addon-settings`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,methods:{getScopedSettings:k(b({addonId:l(),cap:l(),scope:sS,nodeId:l().optional()}),aS.nullable()),listScopedSettings:k(b({addonId:l(),nodeId:l().optional()}),S(Hve).nullable()),updateScopedSettings:k(b({addonId:l(),cap:l(),scope:sS,nodeId:l().optional(),patch:oS}),cS,{kind:`mutation`,auth:`admin`}),readScopedValues:k(b({addonId:l(),cap:l(),scope:sS,nodeId:l().optional()}),m(l(),C()).nullable()),getDeclaredSettingsKeys:k(b({addonId:l(),nodeId:l().optional()}),b({keys:S(l())}).nullable(),{auth:`admin`}),unsetStoredSettingsKeys:k(b({addonId:l(),nodeId:l().optional(),keys:S(l())}),b({removed:S(l()),refused:S(b({key:l(),reason:l()})),secretsCleared:n()}),{kind:`mutation`,auth:`admin`}),getDeviceSettings:k(b({addonId:l(),deviceId:n(),nodeId:l().optional()}),aS.nullable()),updateDeviceSettings:k(b({addonId:l(),deviceId:n(),nodeId:l().optional(),patch:oS}),cS,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:j.ADDON_ADMIN}},uS=x([`device-tab`,`dashboard`,`integration-detail`]),dS=x([`xs`,`sm`,`md`,`lg`,`xl`]),fS=b({remoteName:l(),exposedModule:l(),componentKey:l().optional()}),pS=b({tab:l(),subTab:l().optional(),label:l(),order:n().optional(),kind:p(`remote`),remote:fS,stableId:l(),description:l().optional(),icon:l().optional(),bundle:l(),hosts:S(uS).readonly(),requires:b({deviceContext:v().default(!1),integrationContext:v().default(!1)}),preAuth:v().optional().default(!1),defaultSize:dS.default(`md`),allowedSizes:S(dS).readonly().default([`sm`,`md`,`lg`]),defaultColumns:n().int().min(1).max(12).default(6),defaultRows:n().int().min(1).max(12).default(1)}),mS={name:`addon-widgets-source`,scope:`system`,mode:`collection`,internal:!0,methods:{listWidgets:k(_(),S(pS).readonly(),{auth:`admin`})},vocabulary:{notOperatorFacing:j.UI_PLUMBING}},hS=pS.extend({addonId:l(),bundleUrl:l()}),gS={name:`addon-widgets`,scope:`system`,mode:`singleton`,methods:{listWidgets:k(_(),S(hS).readonly())},vocabulary:{notOperatorFacing:j.UI_PLUMBING}},_S=x([`install`,`update`,`uninstall`,`restart`]),vS=x([`queued`,`fetching`,`staged`,`validating`,`applying`,`restarting`,`applied`,`done`,`failed`,`skipped`]),yS=x([`framework`,`addon`]),bS=b({tsMs:n(),nodeId:l(),packageName:l(),phase:vS,message:l()}),xS=b({taskId:l(),nodeId:l(),packageName:l(),fromVersion:l().nullable(),toVersion:l(),target:yS,phase:vS,stagedPath:l().nullable(),attempts:n(),steps:S(bS),error:l().nullable(),startedAtMs:n().nullable(),finishedAtMs:n().nullable()}),SS=x([`running`,`completed`,`failed`,`partially-failed`,`cancelled`]),CS=x([`single`,`bulk`,`cluster`]),wS=b({jobId:l(),kind:_S,createdAtMs:n(),createdBy:l(),scope:CS,tasks:S(xS),state:SS,schemaVersion:p(1)}),TS=x([`debug`,`info`,`warn`,`error`]),ES=x([`off`,`latest`,`beta`]),DS=x([`off`,`latest`,`beta`,`inherit`]),Uve=b({id:l(),name:l().optional(),version:l().optional(),description:l().optional(),icon:l().optional(),color:l().optional(),capabilities:S(C()).readonly().optional(),packageName:l(),packageVersion:l(),packageDisplayName:l().optional(),bundle:b({displayName:l(),description:l().optional(),icon:l().optional()}).optional(),protected:v().optional(),removable:v().optional(),integrationSection:x([`system`,`providers`]).optional()}),Wve=b({pid:n().optional(),mode:l(),state:l(),reason:l().optional()}),Gve=b({phase:x([`pending`,`healthy`,`failed`]),retryCount:n(),firstFailureAt:n().nullable(),lastAttemptAt:n().nullable(),lastError:b({message:l(),stack:l().optional()}).nullable(),nextRetryAt:n().nullable(),alertEmitted:v(),retrying:v(),inGracePeriod:v()}),OS=b({manifest:Uve,declaration:C().optional(),source:l(),installSource:l().optional(),process:Wve.optional(),hasBackup:v().optional(),health:Gve.nullable().optional()}),kS=b({name:l(),version:l(),dir:l(),installSource:l().optional()}),AS=b({name:l(),currentVersion:l(),latestVersion:l(),category:x([`addon`,`core`]),requiresRestart:v(),isSystem:v(),blockedBy:S(Nu).readonly().optional()}),jS=b({version:l(),publishedAt:l(),deprecated:l().optional(),distTags:S(l()).readonly()}),MS=i(`status`,[b({status:p(`ok`),markdown:l()}),b({status:p(`missing`)}),b({status:p(`error`),message:l()})]),Kve=b({name:l(),version:l(),readme:MS,changelog:MS}),NS=b({name:l(),version:l(),description:l(),keywords:S(l()).readonly(),publishedAt:l(),author:l(),installed:v(),installedVersion:l().optional(),capabilities:S(l()).readonly().nullable()}),PS=b({channel:ES,intervalSeconds:n(),updateCheckIntervalSeconds:n()}),FS=DS,qve=C(),Jve=C(),Yve=C(),IS=x([`uninstalled`,`not-installed`,`refused`,`failed`,`pending-reconnect`]),LS=b({nodeId:l(),outcome:IS,error:l().optional(),addonIds:S(l()).readonly(),runnersStopped:S(l()).readonly(),warnings:S(l()).readonly()}),RS=b({success:v(),packageName:l(),results:S(LS).readonly()}),zS=b({packageName:l(),nodeId:l(),nodeName:l(),isHub:v(),isOnline:v(),version:l().nullable(),addonIds:S(l()).readonly(),source:x([`live`,`recorded`]),onHub:v()}),BS=b({installations:S(zS).readonly(),unreachable:S(b({nodeId:l(),error:l()})).readonly()}),Xve=x([`queued`,`updating`,`done`,`done-pending-restart`,`failed`]),Zve=b({name:l(),isSystem:v(),fromVersion:l(),toVersion:l(),status:Xve,error:l().optional(),startedAtMs:n().optional(),completedAtMs:n().optional()}),Qve=x([`regular`,`system`,`restarting`,`finalizing`]);b({id:l(),nodeId:l(),startedAtMs:n(),completedAtMs:n().optional(),total:n(),completed:n(),failed:n(),current:l().nullable(),phase:Qve,cancelled:v(),items:S(Zve).readonly()});var $ve=b({packageName:l(),currentVersion:l(),latestVersion:l().nullable(),hasUpdate:v(),description:l().optional(),buildId:l().nullable()}),VS=b({timestamp:l(),level:l(),message:l(),scope:l().optional()}),eye=C(),HS=b({addonId:l().min(1),action:l().min(1),input:C()}),US={name:`addons`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,methods:{list:k(b({nodeId:l().optional()}).optional(),S(OS).readonly()),getLogs:k(b({addonId:l(),limit:n().min(1).max(500).default(100),level:TS.optional()}),S(eye)),listPackages:k(_(),S(kS).readonly()),installPackage:k(b({packageName:l(),version:l().optional()}),Jve,{kind:`mutation`,auth:`admin`}),uninstallPackage:k(b({packageName:l().min(1),nodeId:l().optional(),everywhere:v().optional()}),RS,{kind:`mutation`,auth:`admin`}),listInstallations:k(b({packageName:l().optional()}),BS,{auth:`admin`}),reloadPackages:k(_(),Yve,{kind:`mutation`,auth:`admin`}),searchAvailable:k(b({query:l().optional(),capability:l().optional()}),S(NS)),listUpdates:k(b({nodeId:l().optional()}),S(AS).readonly(),{auth:`admin`}),updatePackage:k(b({name:l().min(1),version:l().optional(),nodeId:l().optional()}),C(),{kind:`mutation`,auth:`admin`}),rollbackPackage:k(b({name:l().min(1)}),b({rolledBackTo:l().nullable()}),{kind:`mutation`,auth:`admin`}),forceRefresh:k(b({nodeId:l().optional()}),C(),{kind:`mutation`,auth:`admin`}),restartServer:k(b({confirm:p(!0)}),C(),{kind:`mutation`,auth:`admin`}),getLastRestart:k(_(),b({kind:x([`framework-update`,`manual`,`system`,`framework-bulk-update`]),packageName:l().optional(),fromVersion:l().optional(),toVersion:l().optional(),requestedBy:l().optional(),requestedAt:n()}).nullable(),{auth:`admin`}),listFrameworkPackages:k(_(),S($ve).readonly(),{auth:`admin`}),listCapabilityProviders:k(b({capName:l().min(1)}),S(b({addonId:l(),mode:x([`singleton`,`collection`]),isActive:v()})).readonly()),setCapabilityProviderEnabled:k(b({capName:l().min(1),addonId:l().min(1),enabled:v()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getVersions:k(b({name:l()}),S(jS).readonly()),getPackageDocs:k(b({name:l().min(1),version:l().min(1).optional()}),Kve,{auth:`admin`}),restartAddon:k(b({addonId:l()}),qve,{kind:`mutation`,auth:`admin`}),retryLoad:k(b({packageName:l()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getAutoUpdateSettings:k(_(),PS,{auth:`admin`}),setAutoUpdateSettings:k(b({channel:ES,intervalSeconds:n().min(300).max(86400).optional(),updateCheckIntervalSeconds:n().min(900).max(604800).optional()}),C(),{kind:`mutation`,auth:`admin`}),getAddonAutoUpdate:k(b({addonId:l()}),FS,{auth:`admin`}),setAddonAutoUpdate:k(b({addonId:l(),channel:DS}),C(),{kind:`mutation`,auth:`admin`}),applyAutoUpdateToAll:k(b({channel:ES}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),custom:k(HS,C(),{role:`viewer`,kind:`mutation`}),startJob:k(b({kind:x([`install`,`update`,`uninstall`,`restart`]),targets:S(b({name:l().min(1),version:l().min(1)})).min(1),nodeIds:S(l()).optional()}),b({jobId:l()}),{kind:`mutation`,auth:`admin`}),getJob:k(b({jobId:l()}),wS.nullable(),{auth:`admin`}),listJobs:k(b({activeOnly:v().optional()}),S(wS),{auth:`admin`}),cancelJob:k(b({jobId:l()}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`}),onAddonLogs:k(b({addonId:l(),level:TS.optional()}),VS,{kind:`subscription`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:j.ADDON_ADMIN}},WS=b({co2:n().min(0).optional().meta(M(`concentration-volume`)),voc:n().min(0).optional().meta(M(`concentration-ppb`)),pm25:n().min(0).optional().meta(M(`concentration-mass`)),pm10:n().min(0).optional().meta(M(`concentration-mass`)),aqi:n().optional().meta(M(`index`)),lastFetchedAt:n()}),GS={name:`air-quality-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Sensor],methods:{},status:{schema:WS,kind:`push`},runtimeState:WS,durability:`restored`,history:{fields:{co2:{kind:`gauge`,unit:`ppm`,deadband:5},voc:{kind:`gauge`,unit:`ppb`,deadband:5},pm25:{group:`particulates`,kind:`gauge`,unit:`µg/m³`,deadband:1},pm10:{group:`particulates`,kind:`gauge`,unit:`µg/m³`,deadband:1},aqi:{kind:`gauge`,unit:`count`,deadband:1}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:P(`Air quality`,`Qualità dell’aria`),order:5e3,state:[{kind:`numeric`,field:`co2`,quantity:P(`the CO₂`,`la CO₂`),label:P(`CO₂`,`CO₂`),unit:`ppm`,icon:`wind`},{kind:`numeric`,field:`voc`,quantity:P(`the VOC level`,`il livello di COV`),label:P(`VOC`,`COV`),unit:`ppb`,icon:`wind`},{kind:`numeric`,field:`pm25`,quantity:P(`the PM2.5`,`il PM2,5`),label:P(`PM2.5`,`PM2,5`),unit:`µg/m³`,icon:`cloud-fog`},{kind:`numeric`,field:`pm10`,quantity:P(`the PM10`,`il PM10`),label:P(`PM10`,`PM10`),unit:`µg/m³`,icon:`cloud-fog`},{kind:`numeric`,field:`aqi`,quantity:P(`the air quality index`,`l’indice di qualità dell’aria`),label:P(`AQI`,`IQA`),icon:`wind`}]}},KS=x([`disarmed`,`armed_home`,`armed_away`,`armed_night`,`armed_vacation`,`armed_custom_bypass`,`arming`,`disarming`,`pending`,`triggered`]),qS=x([`home`,`away`,`night`,`vacation`,`custom_bypass`]),JS=b({state:KS,targetMode:qS.nullable().optional(),availableModes:S(qS),codeRequired:v().nullable(),lastChangedAt:n()}),YS={name:`alarm-panel`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.AlarmPanel],methods:{trigger:k(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`alarm.trigger`,label:P(`Trigger alarm`,`Fai scattare l’allarme`),phrase:P(`Trigger the alarm on {device}`,`Fai scattare l’allarme su {device}`),icon:`siren`}]}),disarm:k(b({deviceId:n().int().nonnegative(),code:l().min(1).optional()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`alarm.disarm`,label:P(`Disarm`,`Disinserisci`),phrase:P(`Disarm {device}`,`Disinserisci {device}`),icon:`shield-off`,effect:{field:`state`,value:`disarmed`},hold:{effects:[{field:`state`,value:`disarming`,when:{field:`state`,notIn:[`disarmed`]}}]},openArgs:[{key:`code`,label:P(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]}),arm:k(b({deviceId:n().int().nonnegative(),mode:qS,code:l().min(1).optional()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`alarm.arm.home`,label:P(`Arm home`,`Inserisci in casa`),phrase:P(`Arm {device} for home`,`Inserisci {device} in modalità casa`),icon:`house`,effect:{field:`state`,value:`armed_home`},hold:{effects:[{field:`state`,value:`arming`,when:{field:`state`,notIn:[`armed_home`]}}]},args:{mode:`home`},openArgs:[{key:`code`,label:P(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.away`,label:P(`Arm away`,`Inserisci fuori casa`),phrase:P(`Arm {device} for away`,`Inserisci {device} in modalità fuori casa`),icon:`shield-check`,effect:{field:`state`,value:`armed_away`},hold:{effects:[{field:`state`,value:`arming`,when:{field:`state`,notIn:[`armed_away`]}}]},args:{mode:`away`},openArgs:[{key:`code`,label:P(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.night`,label:P(`Arm night`,`Inserisci notte`),phrase:P(`Arm {device} for the night`,`Inserisci {device} in modalità notte`),icon:`moon`,effect:{field:`state`,value:`armed_night`},hold:{effects:[{field:`state`,value:`arming`,when:{field:`state`,notIn:[`armed_night`]}}]},args:{mode:`night`},openArgs:[{key:`code`,label:P(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.vacation`,label:P(`Arm vacation`,`Inserisci vacanza`),phrase:P(`Arm {device} for vacation`,`Inserisci {device} in modalità vacanza`),icon:`plane`,effect:{field:`state`,value:`armed_vacation`},hold:{effects:[{field:`state`,value:`arming`,when:{field:`state`,notIn:[`armed_vacation`]}}]},args:{mode:`vacation`},openArgs:[{key:`code`,label:P(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.custom_bypass`,label:P(`Arm custom bypass`,`Inserisci con esclusioni`),phrase:P(`Arm {device} with its custom bypass`,`Inserisci {device} con le zone escluse`),icon:`shield-half`,effect:{field:`state`,value:`armed_custom_bypass`},hold:{effects:[{field:`state`,value:`arming`,when:{field:`state`,notIn:[`armed_custom_bypass`]}}]},args:{mode:`custom_bypass`},openArgs:[{key:`code`,label:P(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]})},status:{schema:JS,kind:`push`},runtimeState:JS,durability:`restored`,restoredFieldRenames:{requiresCode:`codeRequired`},history:{fields:{state:{kind:`enum`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:P(`Alarm panel`,`Centrale d’allarme`),order:1120,state:[{kind:`enum`,field:`state`,label:P(`Alarm state`,`Stato dell’allarme`),values:[{value:`disarmed`,label:P(`Disarmed`,`Disinserito`),phrase:P(`When {device} is disarmed`,`Quando {device} viene disinserito`)},{value:`armed_home`,label:P(`Armed home`,`Inserito in casa`),phrase:P(`When {device} is armed for home`,`Quando {device} viene inserito in modalità casa`)},{value:`armed_away`,label:P(`Armed away`,`Inserito fuori casa`),phrase:P(`When {device} is armed for away`,`Quando {device} viene inserito in modalità fuori casa`)},{value:`armed_night`,label:P(`Armed night`,`Inserito notte`),phrase:P(`When {device} is armed for the night`,`Quando {device} viene inserito in modalità notte`)},{value:`armed_vacation`,label:P(`Armed vacation`,`Inserito vacanza`)},{value:`armed_custom_bypass`,label:P(`Armed with bypass`,`Inserito con esclusioni`)},{value:`arming`,label:P(`Arming`,`In inserimento`)},{value:`disarming`,label:P(`Disarming`,`In disinserimento`)},{value:`pending`,label:P(`Entry delay`,`Ritardo d’ingresso`)},{value:`triggered`,label:P(`Triggered`,`In allarme`),phrase:P(`When {device} goes off`,`Quando {device} scatta`)}],icon:`shield`}]}},XS=x([`info`,`success`,`warning`,`error`,`critical`]),tye=b({addonId:l().min(1),action:l().min(1),input:m(l(),C()).optional()}),nye=b({label:l(),href:l().optional(),invoke:tye.optional(),navigation:x([`app`,`server`]).optional()}),ZS=x([`active`,`in-progress`,`completed`,`failed`,`dismissed`]),QS=b({type:l(),id:l()}),$S=b({id:l(),category:l(),severity:XS,title:l(),message:l(),action:nye.optional(),status:ZS,progress:n().optional(),read:v(),createdAt:n(),updatedAt:n(),source:QS.optional(),metadata:m(l(),C()).optional()}),eC={name:`alerts`,scope:`system`,mode:`singleton`,methods:{emit:k($S,_(),{kind:`mutation`}),update:k(b({alertId:l(),patch:$S.partial()}),_(),{kind:`mutation`}),list:k(b({unreadOnly:v().optional(),limit:n().optional()}).optional(),S($S).readonly()),getUnreadCount:k(_(),n()),markRead:k(b({alertId:l()}),_(),{kind:`mutation`}),markAllRead:k(_(),_(),{kind:`mutation`}),dismiss:k(b({alertId:l()}),_(),{kind:`mutation`})},vocabulary:{notOperatorFacing:`the alert centre — read and acknowledged on its own page`}},tC=b({illuminance:n().min(0).nullable().meta(M(`illuminance`,{precision:0,label:`Illuminance`})),lastFetchedAt:n()}),nC={name:`ambient-light-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Sensor],methods:{},status:{schema:tC,kind:`push`},runtimeState:tC,durability:`restored`,history:{fields:{illuminance:{kind:`gauge`,unit:`lx`,deadbandPct:10,minIntervalMs:6e4}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:P(`Light level`,`Luminosità ambiente`),order:5010,state:[{kind:`numeric`,field:`illuminance`,quantity:P(`the light level`,`la luminosità`),label:P(`Illuminance`,`Illuminamento`),unit:`lx`,icon:`sun`}]}},rC={name:`audio-analysis`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[T.Camera],exposesDeviceSettings:!0,methods:{resolveDeviceSettings:k(b({deviceId:n()}),ye())},events:{onAudioLevel:ai(b({deviceId:n(),rms:n(),dbfs:n()}),{notOperatorFacing:`a sound-level sample at stream rate; loud-noise rules belong to the detection pipeline`})},vocabulary:{noun:P(`Audio analysis`,`Analisi audio`),order:3010}},rye=x([`jpeg`,`rgb`,`bgr`,`yuv420`,`gray`]),iC=b({data:ye(),format:rye,width:n(),height:n(),timestamp:n()}),aC=b({x:n(),y:n(),w:n(),h:n()}),iye=b({class:l(),originalClass:l(),score:n(),bbox:aC}),oC=b({data:y(Uint8Array),sampleRate:n(),channels:n(),timestamp:n(),deviceId:n().optional()}),sC=b({rms:n(),dbfs:n()}),cC=b({className:l(),originalClass:l().optional(),score:n()}),lC=[`superseded`,`error`,`timeout`,`disposed`],uC=i(`state`,[b({state:p(`classified`)}),b({state:p(`not-classified`),reason:x(lC)})]),dC=b({level:sC,classification:b({labels:S(cC).readonly(),inferenceMs:n()}).optional(),classifyOutcome:uC,timestamp:n()}),fC=b({minConfidence:n().min(0).max(1).default(.3),allowedClasses:S(l()).default([])}),pC=b({deviceId:n(),brokerId:l(),ingestNodeId:l(),settings:fC}),mC=b({attached:v(),replaced:v()}),hC=b({detached:v()}),gC=b({labels:S(cC).readonly(),rawLabels:S(cC).readonly().optional(),inferenceMs:n()}),aye=[{value:`auto`,label:`Auto (platform default)`},{value:`apple-soundanalysis`,label:`Apple SoundAnalysis (macOS 12+)`},{value:`yamnet-onnx`,label:`YAMNet ONNX (cross-platform)`}],oye={audioBackend:`auto`,probedBestAudioBackend:``},_C={name:`audio-analyzer`,scope:`system`,mode:`singleton`,methods:{analyseChunk:k(b({chunk:oC,settings:fC}),dC.nullable(),{kind:`mutation`}),classify:k(oC,gC,{timeoutMs:3e4}),attachDevice:k(pC,mC,{kind:`mutation`}),detachDevice:k(b({deviceId:n()}),hC,{kind:`mutation`}),isReady:k(_(),v()),dispose:k(_(),_(),{kind:`mutation`}),reprobeAudioEngine:k(_(),b({backend:l()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:j.PIPELINE}},vC=x([`f32le`,`s16le`]),yC=b({codec:l(),canDecode:v(),canEncode:v(),label:l().optional()}),bC=b({codec:l(),sourceSampleRate:n().int().positive(),sourceChannels:n().int().positive(),extraData:y(Uint8Array).optional(),targetSampleRate:n().int().positive(),targetChannels:n().int().positive(),targetFormat:vC.optional(),idleMs:n().int().positive().optional(),tag:l().optional()}),xC=b({codec:l(),sourceSampleRate:n().int().positive(),sourceChannels:n().int().positive(),sourceFormat:vC.optional(),targetSampleRate:n().int().positive(),targetChannels:n().int().positive(),bitrateKbps:n().int().positive().optional(),idleMs:n().int().positive().optional(),tag:l().optional()}),SC=b({data:y(Uint8Array),sampleRate:n().int().positive(),channels:n().int().positive(),format:vC,pts:n()}),CC=b({data:y(Uint8Array),codec:l(),pts:n(),frameComplete:v()}),sye=b({sessionId:l(),kind:x([`decode`,`encode`]),codec:l(),sourceSampleRate:n(),sourceChannels:n(),targetSampleRate:n(),targetChannels:n(),format:vC,tag:l().optional(),createdAtMs:n(),lastActivityMs:n(),framesIn:n(),framesOut:n()}),wC={name:`audio-codec`,scope:`system`,mode:`singleton`,preferredProvider:`decoder-nodeav`,methods:{listSupportedCodecs:k(_(),S(yC).readonly()),canHandle:k(b({codec:l(),kind:x([`decode`,`encode`])}),v()),createDecodeSession:k(bC,b({sessionId:l(),nodeId:l()}),{kind:`mutation`}),createEncodeSession:k(xC,b({sessionId:l(),nodeId:l()}),{kind:`mutation`}),closeSession:k(b({sessionId:l(),nodeId:l().optional()}),_(),{kind:`mutation`}),pushEncodedFrame:k(b({sessionId:l(),nodeId:l().optional(),data:y(Uint8Array),pts:n().optional()}),_(),{kind:`mutation`}),pullPcm:k(b({sessionId:l(),nodeId:l().optional(),maxCount:n().int().positive().default(8)}),S(SC)),pushPcm:k(b({sessionId:l(),nodeId:l().optional(),data:y(Uint8Array),pts:n().optional()}),_(),{kind:`mutation`}),pullEncoded:k(b({sessionId:l(),nodeId:l().optional(),maxCount:n().int().positive().default(8)}),S(CC)),flushEncode:k(b({sessionId:l(),nodeId:l().optional()}),S(CC),{kind:`mutation`}),listActiveSessions:k(_(),S(sye).readonly())},vocabulary:{notOperatorFacing:j.INTERNAL}},TC=b({className:l(),hits:n().int().nonnegative(),avgScore:n().min(0).max(1),peakScore:n().min(0).max(1)}),EC=b({ts:n().int(),windowSec:n().int().positive(),level:b({rms:n(),dbfs:n()}),peakDbfs:n(),avgDbfs:n(),current:b({className:l(),score:n().min(0).max(1),timestamp:n().int()}).nullable(),byClass:S(TC).readonly()}),DC=b({ts:n().int(),dbfs:n().nullable(),peakDbfs:n(),avgDbfs:n(),topClass:l().nullable(),topScore:n().min(0).max(1).nullable()}),OC=b({points:S(DC).readonly(),effectiveSampleEveryMs:n().int().positive(),windowMsActual:n().int().nonnegative()}),kC={name:`audio-metrics`,scope:`device`,mode:`singleton`,deviceTypes:[T.Camera],methods:{getCurrentSnapshot:k(b({deviceId:n()}),EC.nullable()),getHistory:k(b({deviceId:n(),windowSec:n().int().positive().optional(),sampleEveryMs:n().int().positive().optional()}),OC)},runtimeState:EC,durability:`session`,history:`none`,vocabulary:{noun:P(`Audio metrics`,`Metriche audio`),order:3020}},AC=b({userId:l(),username:l(),email:l().optional(),displayName:l().optional(),isAdmin:v().default(!1)}),jC={name:`auth-provider`,scope:`system`,mode:`collection`,internal:!0,methods:{validateCredentials:k(b({username:l(),password:l()}),AC.nullable(),{kind:`mutation`}),getLoginUrl:k(b({state:l()}),l()),handleCallback:k(m(l(),l()),AC,{kind:`mutation`}),validateToken:k(b({token:l()}),AC.nullable())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:j.IDENTITY}},MC=b({enabled:v(),isRunning:v(),lastTriggeredAt:n(),lastError:l().nullable(),lastChangedAt:n()}),NC={name:`automation-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Automation],methods:{enable:k(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`haAutomation.enable`,effect:{field:`enabled`,value:!0},label:P(`Enable automation`,`Abilita l’automazione`),phrase:P(`Enable {device}`,`Abilita {device}`),icon:`toggle-right`}]}),disable:k(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`haAutomation.disable`,effect:{field:`enabled`,value:!1},label:P(`Disable automation`,`Disabilita l’automazione`),phrase:P(`Disable {device}`,`Disabilita {device}`),icon:`toggle-left`}]}),trigger:k(b({deviceId:n().int().nonnegative(),skipCondition:v().optional()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`haAutomation.trigger`,label:P(`Trigger automation`,`Avvia l’automazione`),phrase:P(`Run {device} now`,`Esegui subito {device}`),icon:`workflow`}]})},status:{schema:MC,kind:`push`},runtimeState:MC,durability:`session`,history:`none`,vocabulary:{noun:P(`Automation`,`Automazione`),order:2100,state:[{kind:`boolean`,field:`enabled`,label:P(`Enabled`,`Abilitata`),whenTrue:P(`When {device} is enabled`,`Quando {device} viene abilitata`),whenFalse:P(`When {device} is disabled`,`Quando {device} viene disabilitata`),icon:`toggle-right`},{kind:`boolean`,field:`isRunning`,label:P(`Running`,`In esecuzione`),whenTrue:P(`When {device} starts running`,`Quando {device} parte`),whenFalse:P(`When {device} finishes`,`Quando {device} termina`),icon:`workflow`}]}},cye=`.backup-snapshot`,lye=`.backup-snapshot-partial`,PC=30*6e4,FC=b({databases:S(b({databaseId:vf,livePath:l()}))}),IC=b({name:l(),rows:n().int().nonnegative()}),LC=b({livePath:l(),snapshotPath:l(),sizeBytes:n().int().nonnegative(),pageCount:n().int().nonnegative(),pageSize:n().int().positive(),tables:S(IC),copyMs:n().nonnegative(),verifyMs:n().nonnegative(),takenAt:n()}),RC=LC.extend({databaseId:vf}),zC=b({databaseId:vf}),BC=LC.extend({livePath:l(),snapshotPath:l(),databaseId:vf.optional()}),VC={name:`database-snapshot`,scope:`system`,mode:`singleton`,internal:!0,methods:{listDatabases:k(b({}),FC,{auth:`admin`}),writeSnapshot:k(zC,RC,{kind:`mutation`,auth:`admin`,timeoutMs:PC})},vocabulary:{notOperatorFacing:j.INTERNAL}},HC=b({subId:l(),displayName:l(),description:l().optional(),kind:l(),triggerSupported:v(),restoreSupported:v()}).extend({id:l(),addonId:l(),enabled:v(),retentionCount:n(),label:l().optional(),lastSuccessAt:n().optional(),lastSuccessSizeBytes:n().optional(),cron:l().optional(),nextRunAt:n().optional(),lastAttemptAt:n().optional(),lastError:l().optional()}),UC=b({scheme:l(),keyId:l()}),WC=b({enabled:v(),active:b({keyId:l(),publicKey:l(),createdAt:n()}).nullable(),keys:S(b({keyId:l(),createdAt:n(),retiredAt:n().nullable()})).readonly()}),uye=b({id:l(),filename:l(),createdAt:n(),sizeBytes:n(),label:l().optional(),locations:S(l()).readonly(),encryption:UC.optional(),databases:S(vf).readonly().optional()}),GC=b({id:l(),destinationId:l().optional(),label:l().optional(),createdAt:n(),sizeBytes:n(),locations:S(l()).optional(),encryption:UC.optional()}),KC=b({path:l(),kind:x([`file`,`dir`,`symlink`]),sizeBytes:n(),mtime:n()}),qC=b({archiveVersion:p(1),createdAt:n(),dataDir:l(),locations:S(l()),entries:S(KC),totalBytes:n(),totalFiles:n(),sqliteSnapshots:S(BC).optional(),omittedDatabases:S(vf).optional()}),JC=b({name:l(),sizeBytes:n(),fileCount:n(),present:v()}),YC=x([`queued`,`running`,`succeeded`,`failed`,`cancelled`]),XC=x([`queued`,`building`,`uploading`,`done`]),ZC=b({id:l(),state:YC,phase:XC,destinationIds:S(l()).readonly(),label:l().optional(),requestedAt:n(),startedAt:n().optional(),finishedAt:n().optional(),stagedBytes:n(),archiveSizeBytes:n().optional(),uploadedBytes:n(),completedDestinationIds:S(l()).readonly(),failedDestinationIds:S(l()).readonly(),error:l().optional(),queuePosition:n().int().min(1).optional()}),QC=b({runId:l(),queued:v(),joined:v(),cancelled:v(),entries:S(GC).readonly()}),$C=b({id:l(),label:l(),cron:l(),enabled:v(),locationIds:S(l()).readonly(),retentionCount:n().int().min(1).max(1e3),dataSources:S(l()).readonly().optional(),databases:S(vf).readonly().optional(),lastAttemptAt:n().optional(),lastSuccessAt:n().optional(),lastError:l().optional(),nextRunAt:n().optional()}),ew={name:`backup`,scope:`system`,mode:`singleton`,methods:{listDestinations:k(_(),S(HC).readonly(),{auth:`admin`}),trigger:k(b({destinations:S(l()).optional(),locations:S(l()).optional(),label:l().optional(),retentionCount:n().int().min(1).max(1e3).optional(),databases:S(vf).optional()}).optional(),QC,{kind:`mutation`,auth:`admin`}),listRuns:k(_(),S(ZC).readonly(),{auth:`admin`}),cancel:k(b({runId:l()}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`}),list:k(_(),S(GC).readonly(),{auth:`admin`}),listLocations:k(_(),S(JC).readonly(),{auth:`admin`}),getEntries:k(b({destinationId:l(),backupId:l()}),qC.nullable(),{auth:`admin`}),restore:k(b({destinationId:l(),backupId:l(),locations:S(l()).optional(),backupSecretKey:l().optional()}),_(),{kind:`mutation`,auth:`admin`}),getEncryption:k(_(),WC,{auth:`admin`}),setupEncryption:k(b({}),b({keyId:l(),secretKey:l(),publicKey:l(),createdAt:n(),replacedKeyId:l().nullable()}),{kind:`mutation`,auth:`admin`}),disableEncryption:k(b({}),b({disabledKeyId:l().nullable()}),{kind:`mutation`,auth:`admin`}),checkBackupKey:k(b({backupSecretKey:l()}),b({valid:v(),keyId:l().nullable(),known:v(),active:v(),error:l().optional()}),{kind:`mutation`,auth:`admin`}),delete:k(b({destinationId:l(),backupId:l()}),_(),{kind:`mutation`,auth:`admin`}),listArchives:k(b({destinationId:l()}),S(uye).readonly(),{auth:`admin`}),upsertDestinationPolicy:k(b({locationId:l(),enabled:v(),retentionCount:n().int().min(1).max(1e3),label:l().optional()}),_(),{kind:`mutation`,auth:`admin`}),previewSchedule:k(b({cron:l(),count:n().int().min(1).max(20).optional()}),b({ok:v(),error:l().optional(),nextRuns:S(n()).readonly()})),listSchedules:k(_(),S($C).readonly(),{auth:`admin`}),listAvailableDatabases:k(_(),b({answered:v(),databases:S(vf).readonly()}),{auth:`admin`}),upsertSchedule:k(b({id:l().optional(),label:l(),cron:l(),enabled:v(),locationIds:S(l()).readonly(),retentionCount:n().int().min(1).max(1e3),dataSources:S(l()).readonly().optional(),databases:S(vf).readonly().optional()}),$C,{kind:`mutation`,auth:`admin`}),deleteSchedule:k(b({id:l()}),_(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`system backups — run and restored from the Backups page`}},tw=b({level:n().min(0).max(100).nullable().meta(M(`percentage`,{label:`Charge`})),charging:x([`dc`,`solar`,`none`,`unknown`]).meta({label:`Charging source`}),sleeping:v().meta({label:`Sleeping`}),lastUpdated:n().meta(M(`none`)),voltage:n().nullable().optional().meta(M(`voltage`,{label:`Voltage`})),lastContactAt:n().optional(),lastFullRefreshAt:n().optional(),binary:v().optional().meta({label:`Binary indicator`})}),nw=[T.Camera,T.Sensor,T.Button,T.Switch,T.PetFeeder,T.Container,T.Climate,T.EventEmitter],dye={version:1,targets:[{id:`level`,cardinality:`scalar`,vocabulary:{cap:`battery`,stateField:`level`},deviceTypes:nw,apply:`add`,path:`level`,sources:[{kind:`field`,valueKinds:[`number`,`string`],transforms:[{kind:`identity`},{kind:`linear`,defaultScale:1,defaultOffset:0,clampMin:0,clampMax:100}]}],companions:[{kind:`constant`,path:`charging`,value:`unknown`,when:`add`},{kind:`constant`,path:`sleeping`,value:!1,when:`add`},{kind:`clock`,path:`lastUpdated`,when:`add`}],sourceReport:{status:`assignment-status`},advancedExpression:!0}]},rw={name:`battery`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:nw,methods:{},events:{onStatusChanged:{data:b({deviceId:n(),status:tw}),notOperatorFacing:`the level / sleeping / charging state triggers each read one field of this change`}},status:{schema:tw,kind:`push`,empty:{level:null,charging:`unknown`,sleeping:!1,lastUpdated:0}},runtimeState:tw,durability:`restored`,history:{fields:{level:{kind:`gauge`,unit:`%`},voltage:{kind:`gauge`,unit:`V`}}},customize:dye,volatileStateFields:[`lastUpdated`],vocabulary:{noun:P(`Battery`,`Batteria`),order:5240,state:[{kind:`numeric`,field:`level`,quantity:P(`the battery level`,`il livello della batteria`),label:P(`Battery`,`Batteria`),unit:`%`,icon:`battery`},{kind:`boolean`,field:`sleeping`,label:P(`Asleep`,`In sospensione`),whenTrue:P(`When {device} goes to sleep`,`Quando {device} va in sospensione`),whenFalse:P(`When {device} wakes up`,`Quando {device} si risveglia`),icon:`moon`},{kind:`enum`,field:`charging`,label:P(`Charging`,`Ricarica`),values:[{value:`dc`,label:P(`Charging from mains`,`In carica da rete`),phrase:P(`When {device} starts charging`,`Quando {device} inizia a caricarsi`)},{value:`solar`,label:P(`Charging from solar`,`In carica dal pannello solare`),phrase:P(`When {device} charges from its solar panel`,`Quando {device} si carica dal pannello solare`)},{value:`none`,label:P(`Not charging`,`Non in carica`),phrase:P(`When {device} stops charging`,`Quando {device} smette di caricarsi`)},{value:`unknown`,label:P(`Unknown`,`Sconosciuto`)}],icon:`battery-charging`}],extraEvents:[{category:w.DeviceAwake,label:P(`Woke up`,`Risvegliato`),phrase:P(`When {device} wakes up`,`Quando {device} si risveglia`),icon:`sun`},{category:w.DeviceSleeping,label:P(`Went to sleep`,`In sospensione`),phrase:P(`When {device} goes to sleep`,`Quando {device} va in sospensione`),icon:`moon`}]}},iw=b({on:v().meta({label:`On`}),lastChangedAt:n()}),aw={name:`binary`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Sensor],methods:{},status:{schema:iw,kind:`push`},runtimeState:iw,durability:`restored`,history:{fields:{on:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:P(`Binary sensor`,`Sensore binario`),order:5020,state:[{kind:`boolean`,field:`on`,label:P(`On`,`Acceso`),whenTrue:P(`When {device} turns active`,`Quando {device} si attiva`),whenFalse:P(`When {device} turns inactive`,`Quando {device} si disattiva`),icon:`toggle-right`}],overrides:{byRole:{[D.MotionSensor]:{state:{on:{label:P(`Motion`,`Movimento`),whenTrue:P(`When {device} detects motion`,`Quando {device} rileva movimento`),whenFalse:P(`When motion clears on {device}`,`Quando il movimento su {device} cessa`),icon:`activity`}}},[D.ContactSensor]:{state:{on:{label:P(`Open`,`Aperto`),whenTrue:P(`When {device} opens`,`Quando {device} si apre`),whenFalse:P(`When {device} closes`,`Quando {device} si chiude`),icon:`door-open`}}},[D.LeakSensor]:{state:{on:{label:P(`Leak`,`Perdita`),whenTrue:P(`When {device} detects a leak`,`Quando {device} rileva una perdita`),whenFalse:P(`When {device} is dry again`,`Quando {device} torna asciutto`),icon:`droplets`}}},[D.SmokeSensor]:{state:{on:{label:P(`Smoke`,`Fumo`),whenTrue:P(`When {device} detects smoke`,`Quando {device} rileva fumo`),whenFalse:P(`When smoke clears on {device}`,`Quando il fumo su {device} si dirada`),icon:`alarm-smoke`}}},[D.COSensor]:{state:{on:{label:P(`Carbon monoxide`,`Monossido di carbonio`),whenTrue:P(`When {device} detects carbon monoxide`,`Quando {device} rileva monossido di carbonio`),whenFalse:P(`When the carbon monoxide clears on {device}`,`Quando il monossido su {device} rientra`),icon:`cloud-alert`}}},[D.GasSensor]:{state:{on:{label:P(`Gas`,`Gas`),whenTrue:P(`When {device} detects gas`,`Quando {device} rileva gas`),whenFalse:P(`When the gas clears on {device}`,`Quando il gas su {device} rientra`),icon:`flame`}}},[D.TamperSensor]:{state:{on:{label:P(`Tampered`,`Manomesso`),whenTrue:P(`When {device} is tampered with`,`Quando {device} viene manomesso`),whenFalse:P(`When the tamper alert on {device} clears`,`Quando l’allarme di manomissione di {device} rientra`),icon:`shield-alert`}}},[D.VibrationSensor]:{state:{on:{label:P(`Vibration`,`Vibrazione`),whenTrue:P(`When {device} vibrates`,`Quando {device} vibra`),whenFalse:P(`When {device} is still again`,`Quando {device} torna fermo`),icon:`vibrate`}}},[D.ConnectivitySensor]:{state:{on:{label:P(`Connected`,`Connesso`),whenTrue:P(`When {device} connects`,`Quando {device} si connette`),whenFalse:P(`When {device} disconnects`,`Quando {device} si disconnette`),icon:`wifi`}}},[D.SoundSensor]:{state:{on:{label:P(`Sound`,`Suono`),whenTrue:P(`When {device} hears a sound`,`Quando {device} sente un suono`),whenFalse:P(`When {device} is quiet again`,`Quando {device} torna silenzioso`),icon:`ear`}}},[D.BatterySensor]:{state:{on:{label:P(`Battery low`,`Batteria scarica`),whenTrue:P(`When the battery of {device} runs low`,`Quando la batteria di {device} si scarica`),whenFalse:P(`When the battery of {device} is fine again`,`Quando la batteria di {device} torna a posto`),icon:`battery-low`}}},[D.BinaryHelper]:{state:{on:{label:P(`On`,`Acceso`),whenTrue:P(`When {device} turns on`,`Quando {device} si accende`),whenFalse:P(`When {device} turns off`,`Quando {device} si spegne`),icon:`toggle-right`}}}}}}},ow=x([`unknown-source`,`not-admin`,`no-builder`,`no-ingress-url`,`unreachable`,`unknown-board`,`no-encryption-key`,`unreadable-config`]),fye=b({sourceId:l(),name:l()}),pye=b({configuration:l(),name:l(),address:l().nullable()}),sw=b({ok:p(!1),reason:ow,detail:l().optional()}),mye=i(`ok`,[b({ok:p(!0),boards:S(pye).readonly()}),sw]),hye=i(`ok`,[b({ok:p(!0),key:l()}),sw]),cw={name:`board-key-source`,scope:`system`,mode:`collection`,methods:{listSources:k(_(),S(fye).readonly(),{auth:`admin`}),listBoards:k(b({sourceId:l().min(1)}),mye,{auth:`admin`}),getBoardKey:k(b({sourceId:l().min(1),configuration:l().min(1)}),hye,{auth:`admin`})},vocabulary:{notOperatorFacing:j.INTERNAL}},lw=b({level:n().min(0).max(100).meta(M(`percentage`)),lastChangedAt:n()}),uw={name:`brightness`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Light],methods:{setBrightness:k(b({deviceId:n().int().nonnegative(),level:n().min(0).max(100)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`brightness.full`,label:P(`Full brightness`,`Luminosità massima`),phrase:P(`Set {device} to full brightness`,`Porta {device} alla massima luminosità`),icon:`sun`,effect:{field:`level`,value:100},args:{level:100}},{id:`brightness.half`,label:P(`Half brightness`,`Luminosità a metà`),phrase:P(`Dim {device} to half`,`Abbassa {device} a metà luminosità`),icon:`sun-dim`,effect:{field:`level`,value:50},args:{level:50}},{id:`brightness.off`,label:P(`Brightness off`,`Luminosità a zero`),phrase:P(`Dim {device} to zero`,`Abbassa {device} a zero`),icon:`lightbulb-off`,effect:{field:`level`,value:0},args:{level:0}},{id:`brightness.set`,label:P(`Set brightness`,`Imposta la luminosità`),phrase:P(`Set the brightness of {device} to {level}`,`Imposta la luminosità di {device} a {level}`),icon:`sun-medium`,effect:{field:`level`,fromArg:`level`},openArgs:[{key:`level`,label:P(`Percentage`,`Percentuale`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]})},events:{onBrightnessChanged:{data:b({deviceId:n(),level:n().min(0).max(100),lastChangedAt:n()}),notOperatorFacing:"the `level` state trigger reads the same change"}},status:{schema:lw,kind:`command-driven`},runtimeState:lw,durability:`session`,history:{fields:{level:{kind:`gauge`,unit:`%`,minIntervalMs:0}}},vocabulary:{noun:P(`Brightness`,`Luminosità`),order:1010,state:[{kind:`numeric`,field:`level`,quantity:P(`the brightness`,`la luminosità`),label:P(`Brightness`,`Luminosità`),unit:`%`,icon:`sun`}]}},gye=x([`connected`,`disconnected`,`connecting`,`auth-failed`,`unreachable`,`error`]),dw=b({brokerCount:n().int().nonnegative(),connectedCount:n().int().nonnegative()}),_ye=b({id:l()}),vye=m(l(),C()),fw=b({brokerId:l(),target:m(l(),C()),payload:C().optional()}),pw=b({brokerId:l(),filter:m(l(),C())}),mw=b({subscriptionId:l()}),hw=b({brokerId:l(),subscriptionId:l()}),gw=b({brokerId:l(),key:l()}),_w={name:`broker`,scope:`system`,mode:`collection`,providerKind:`broker`,status:{schema:dw,kind:`poll`},methods:{getBrokerConfig:k(_ye,vye.nullable(),{auth:`admin`}),publish:k(fw,C(),{kind:`mutation`,auth:`admin`}),subscribe:k(pw,mw,{kind:`mutation`,auth:`admin`}),unsubscribe:k(hw,_(),{kind:`mutation`,auth:`admin`}),getState:k(gw,C().nullable(),{auth:`admin`}),getStatus:k(_(),dw)},vocabulary:{notOperatorFacing:`message-broker connections — configured, not actuated`}},vw={name:`button`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Button],methods:{press:k(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`button.press`,label:P(`Press`,`Premi`),phrase:P(`Press {device}`,`Premi {device}`),icon:`circle-dot`}]})},vocabulary:{noun:P(`Button`,`Pulsante`),order:1130}},yw=x([`ha`,`addon`]),bw=b({id:l().min(1),name:l().min(1),source:yw,enabled:v(),instanceId:l().min(1).optional()}),xw=b({id:l().min(1),calendarId:l().min(1),title:l(),startMs:n().int(),endMs:n().int(),allDay:v().optional(),description:l().optional(),location:l().optional()}),Sw=b({calendarIds:S(l().min(1)).max(64).optional(),startMs:n().int(),endMs:n().int()}),Cw={name:`calendar-source`,scope:`system`,mode:`collection`,internal:!0,providerKind:`calendar`,methods:{listCalendars:k(_(),S(bw).readonly(),{auth:`admin`}),listEvents:k(Sw,S(xw).readonly(),{auth:`admin`})},vocabulary:{notOperatorFacing:j.INTERNAL}};function ww(e){let t=new Date(e);return new Date(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()).getTime()}function Tw(e){if(e.allDay!==!0)return{startMs:e.startMs,endMs:e.endMs};let t=ww(e.startMs),n=ww(e.endMs);if(n>t)return{startMs:t,endMs:n};let r=new Date(t);return{startMs:t,endMs:new Date(r.getFullYear(),r.getMonth(),r.getDate()+1).getTime()}}function yye(e,t){let n=new Date(t),r=new Date(n.getFullYear(),n.getMonth(),n.getDate()+1).getTime(),i=Tw(e);return i.startMs<r&&i.endMs>t}var Ew=l().regex(/^#[0-9A-Fa-f]{6}$/,`expected #RRGGBB`),Dw=bw.extend({id:l().min(1),providerAddonId:l().min(1).optional(),defaultColor:Ew,color:Ew,visible:v()}),Ow=b({visible:v().optional(),color:Ew.optional()}),kw=b({calendars:m(l(),Ow)}),Aw=b({calendarId:l().min(1),visible:v().optional(),color:Ew.nullable().optional()}),jw={name:`calendars`,scope:`system`,mode:`singleton`,methods:{listCalendars:k(_(),S(Dw).readonly(),{auth:`admin`}),listEvents:k(Sw,S(xw).readonly(),{auth:`admin`}),getPreferences:k(b({}),kw,{auth:`admin`,caller:`required`}),setCalendarPreference:k(Aw,kw,{auth:`admin`,kind:`mutation`,caller:`required`})},vocabulary:{notOperatorFacing:`calendars feed schedules and conditions, not device actions`}},Mw=b({host:l(),port:n().int().positive().optional(),onvifPort:n().int().positive().optional(),rtspPort:n().int().positive().optional(),https:v().optional(),username:l().optional(),password:l().optional(),onvifProfile:l().optional()}),Nw=b({host:l(),port:n().int().positive().nullable(),onvifPort:n().int().positive().nullable(),rtspPort:n().int().positive().nullable(),https:v().nullable(),hasUsername:v(),hasPassword:v(),onvifProfile:l().nullable()}),Pw={name:`camera-credentials`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Camera],methods:{getCredentials:k(b({deviceId:n()}),Mw.nullable(),{kind:`query`,auth:`admin`})},status:{schema:Nw,kind:`command-driven`},vocabulary:{noun:P(`Camera credentials`,`Credenziali della telecamera`),order:3030}},Fw=b({x:n().min(0).max(1),y:n().min(0).max(1),width:n().gt(0).max(1),height:n().gt(0).max(1)}),Iw=b({deviceId:n().int().positive(),source:Fw,cell:Fw}),bye=b({profile:x([`high`,`mid`,`low`]),offered:v(),missingSources:S(n().int().positive()),canvas:l(),published:v()}),Lw=b({blockId:l(),deviceId:n().int().nonnegative(),name:l(),fps:n().int(),cells:S(Iw),profiles:S(bye)}),Rw=b({deviceId:n().int().nonnegative(),fps:n().int().min(1).max(60).optional(),publishedProfiles:S(x([`high`,`mid`,`low`])).max(3).optional(),cells:S(Iw).max(16)}),zw={name:`camera-grid-layout`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Camera],exposesDeviceSettings:!0,methods:{getLayout:k(b({deviceId:n().int().nonnegative()}),Lw.nullable(),{auth:`admin`}),saveLayout:k(Rw,Lw,{kind:`mutation`,auth:`admin`})},vocabulary:{noun:P(`Grid layout`,`Layout a griglia`),order:3040}},Bw={name:`camera-pipeline-config`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[T.Camera],exposesDeviceSettings:!0,methods:{},vocabulary:{noun:P(`Detection settings`,`Impostazioni di rilevamento`),order:3050}},Vw=x([`webrtc`,`hls`,`mjpeg`,`rtsp`]),Hw=x([`mp4`,`gif`]),Uw=b({kind:Hw,handle:l(),nodeId:l(),mime:l(),bytes:n().int(),width:n().int(),height:n().int()}),Ww=b({fromTs:n(),toTs:n(),packets:n().int()}),Gw=b({media:S(Uw).readonly(),coverage:Ww,profile:N,video:x([`copy`,`encode`])}),Kw=b({brokerId:l(),url:l(),mutedUrl:l(),enabled:v(),codec:l().optional(),resolution:b({width:n().int().positive(),height:n().int().positive()}).optional()}),qw=b({sessionId:l(),remoteAddr:l(),userAgent:l().nullish(),playing:v(),muted:v(),connectedAt:n(),lastRtpAt:n(),bytesSent:n()}),Jw=b({tag:l(),subscribedAt:n(),chunksDelivered:n()}),Yw=x([`alexa`,`homekit`,`webrtc-browser`,`webrtc-mobile`,`webrtc-whep`,`rtsp-listen`,`derived-broker`,`recording`,`pipeline`,`snapshot`,`warmup`,`unknown`]),Xw=b({kind:Yw,label:l().optional(),media:x([`audio`,`video`,`both`]).optional(),targetCodec:l().optional(),transport:x([`passthrough`,`repacketize`,`transcode`]).optional(),remoteAddr:l().optional(),userAgent:l().optional(),userId:l().optional(),sessionId:l().optional(),extra:m(l(),l()).optional()}).readonly(),Zw=b({id:l(),channel:x([`annexb`,`rtp`]),attribution:Xw,subscribedAt:n(),packetsDelivered:n()}),Qw=b({rtsp:S(qw).readonly(),audio:S(Jw).readonly(),encoded:S(Zw).readonly(),pipeClients:n(),encodedSubscribers:n()}),$w=b({deviceId:n().int().nonnegative(),viewers:n().int().positive()}),xye=x([`reconnecting`,`sleeping`,`offline`,`disabled`,`waking`]),Sye=x([`h264`,`h265`,`copy`]),Cye=x([`aac`,`opus`,`pcmu`,`copy`,`none`]),eT=b({deviceId:n().int().nonnegative(),video:Sye,audio:Cye.optional(),profile:N.optional(),targetResolution:b({width:n().int().positive(),height:n().int().positive()}).optional(),outputArgs:S(l()).optional(),audioEgress:v().optional(),hostname:l().optional(),tag:l().optional()}),tT=b({url:l(),sentryUrl:l().nullable().optional(),videoCodec:x([`H264`,`H265`]),audioCodec:l(),resolution:b({width:n().int().positive(),height:n().int().positive()}),transcoded:v(),encoder:l(),pipelineKey:l()}),nT=Md.omit({inputArgs:!0,outputArgs:!0}),rT=x([`tight`,`relaxed`]),iT=b({deviceId:n().int().nonnegative(),source:i(`kind`,[b({kind:p(`profile`),profile:N}),b({kind:p(`cam-stream`),camStreamId:l().min(1)})]),encode:nT,rateControl:rT.optional(),bitstreamFilter:x([`dump_extra`,`h264_mp4toannexb`,`hevc_mp4toannexb`]).optional(),publishLocally:v().optional(),pixelFormat:x([`yuv420p`,`nv12`]).optional(),decodeHwAccel:x([`auto`,`none`,`videotoolbox`,`vaapi`,`qsv`,`cuda`]).optional(),hostname:l().optional(),tag:l().optional()}),aT=b({url:l(),pipelineKey:l(),videoCodec:x([`H264`,`H265`]),resolution:b({width:n().int().positive(),height:n().int().positive()}),transcoded:v(),encoder:l(),decodeHwAccel:l().nullable(),camStreamId:l().nullable()}),oT={name:`stream-broker`,scope:`system`,mode:`singleton`,exposesDeviceSettings:!0,methods:{reportStreamSignal:k(b({deviceId:n().int().nonnegative(),code:l().min(1),at:n().optional()}),b({accepted:v(),reason:x([`woke`,`hold-extended`,`not-enabled`,`no-consumer`,`unknown-code`])}),{kind:`mutation`}),publishCameraStream:k(b({deviceId:n().int().nonnegative(),camStreamId:l().min(1),kind:va,url:l().optional(),codec:l().optional(),resolution:ya.optional(),fps:n().positive().optional(),label:l().optional(),deviceFeatures:S(l()).optional(),autoEligible:v().optional(),profileHint:N.optional(),metadata:m(l(),C()).optional(),sourceCamStreamId:l().min(1).optional(),encodeProfile:Md.optional()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),retractCameraStream:k(b({deviceId:n().int().nonnegative(),camStreamId:l().min(1)}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),assignProfile:k(b({deviceId:n().int().nonnegative(),profile:N,camStreamId:l().min(1)}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),unassignProfile:k(b({deviceId:n().int().nonnegative(),profile:N}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),forgetDeviceHardware:k(b({deviceId:n().int().nonnegative()}),b({derivedStreamsDeleted:S(l()).readonly(),assignmentsPurged:v(),probeSnapshotsDropped:n().int().nonnegative(),rtspTokenRowsDeleted:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),renderPreBufferClip:k(b({deviceId:n(),profile:N.optional(),aroundMs:n(),preRollSec:n().min(0).max(20).default(3),postRollSec:n().min(0).max(20).default(5),format:x([`gif`,`mp4`]).default(`gif`),maxWidth:n().int().min(120).max(1920).default(480),fps:n().int().min(1).max(15).default(5),speed:n().min(1).max(8).default(2)}),b({base64:l(),mime:l(),bytes:n().int(),profile:N,durationMs:n()}),{kind:`mutation`,auth:`admin`}),produceEventMedia:k(b({deviceId:n(),profile:N.optional(),aroundMs:n(),preSeconds:n().min(0).max(20).default(4),postSeconds:n().min(0).max(20).default(6),kinds:S(Hw).min(1).default([`mp4`]),gifMaxWidth:n().int().min(120).max(1280).default(640),gifFps:n().int().min(1).max(15).default(12),gifSpeed:n().min(1).max(8).default(4),speed:n().min(1).max(8).default(4)}),Gw,{kind:`mutation`,auth:`admin`}),fetchEventMedia:k(b({handle:l()}),b({base64:l(),mime:l(),bytes:n().int()}).nullable(),{kind:`mutation`,auth:`admin`}),listAllCameraStreams:k(_(),S(ba).readonly()),listAllProfileSlots:k(_(),S(Sa).readonly()),getBrokerStats:k(b({brokerId:l()}),Ene),previewDerivedEncode:k(b({deviceId:n().int().nonnegative(),profile:Md,source:Sne.optional()}),Tne),probeStream:k(b({brokerId:l()}),b({probed:v(),summary:l()}),{kind:`mutation`,auth:`admin`}),listClients:k(b({brokerId:l()}),Qw),getLiveViewerCounts:k(_(),S($w).readonly(),{role:`viewer`}),killClient:k(b({brokerId:l(),channel:x([`rtsp`,`audio`]),handle:l()}),b({killed:v()}),{kind:`mutation`,auth:`admin`}),restartProfile:k(b({deviceId:n().int().nonnegative(),profile:N}),b({success:v()}),{kind:`mutation`,auth:`admin`}),getStreamUrl:k(b({streamId:l(),format:Vw}),b({url:l()})),getStreamWithCodec:k(eT,tT,{kind:`mutation`,auth:`admin`}),releaseStreamWithCodec:k(b({pipelineKey:l()}),b({released:v(),refcount:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),acquireEgressTranscode:k(iT,aT,{kind:`mutation`,auth:`admin`}),releaseEgressTranscode:k(b({pipelineKey:l()}),b({released:v(),refcount:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),subscribeAudioChunks:k(yne,bne,{kind:`mutation`}),pullAudioChunks:k(b({subscriptionId:l(),maxCount:n().int().positive().default(8)}),S(vne).readonly()),unsubscribeAudioChunks:k(b({subscriptionId:l()}),b({released:v()}),{kind:`mutation`}),setPreBufferDuration:k(b({brokerId:l(),seconds:n().min(0).max(30)}),_(),{kind:`mutation`,auth:`admin`}),getPreBufferInfo:k(b({brokerId:l()}),b({configuredSec:n(),bufferedMs:n(),packetCount:n()})),getRtspPort:k(_(),n()),getAllRtspEntries:k(b({hostname:l().optional()}),S(Kw).readonly()),getRtspEntry:k(b({brokerId:l(),hostname:l().optional()}),Kw.nullable()),regenerateRtspToken:k(b({brokerId:l()}),l().nullable(),{kind:`mutation`,auth:`admin`}),setRtspEnabled:k(b({brokerId:l(),enabled:v()}),_(),{kind:`mutation`,auth:`admin`}),isRtspEnabled:k(b({brokerId:l()}),v()),getDeviceAudioMute:k(b({deviceId:n().int()}),b({muted:v(),appliedBrokers:n().int().nonnegative()})),setDeviceAudioMute:k(b({deviceId:n().int(),muted:v()}),b({muted:v(),appliedBrokers:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`})},events:{onCamStreamDemand:ai(b({deviceId:n().int().nonnegative(),camStreamId:l(),profile:N})),onCamStreamIdle:ai(b({deviceId:n().int().nonnegative(),camStreamId:l()})),onRequestStreamSourceRefresh:ai(b({deviceId:n().int().nonnegative(),camStreamId:l(),brokerId:l()}))},vocabulary:{notOperatorFacing:j.PIPELINE}},sT=x([`h264`,`h265`,`hevc`,`av1`,`mjpeg`,`vp8`,`vp9`]),cT=b({acceptCodecs:S(sT).readonly().optional(),minHeight:n().int().positive().optional(),maxHeight:n().int().positive().optional(),minWidth:n().int().positive().optional(),excludeDerived:v().optional(),requireSiblingCodec:S(sT).readonly().optional(),allowTranscode:v().optional(),requireProfileBound:v().optional()}).readonly(),lT=b({preferredProviders:S(l()).readonly().optional(),resolutionPreference:x([`highest`,`lowest`]).optional(),targetHeight:n().int().positive().optional()}).readonly(),uT=b({camStreamId:l(),codec:l().optional(),resolution:ya.optional(),transcodes:v(),reason:l(),profile:N.optional(),brokerId:l().optional(),url:l().optional(),fps:n().positive().optional(),fpsSource:x([`published`,`measured`]).optional()}),dT={name:`camera-streams`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[T.Camera],methods:{getCameraStreams:k(b({deviceId:n().int().nonnegative()}),S(ba).readonly()),getBrokerStreams:k(b({deviceId:n().int().nonnegative()}),S(Sa).readonly()),getRtspEntries:k(b({deviceId:n().int().nonnegative(),hostname:l().optional()}),S(Kw).readonly()),getProfileRtspEntries:k(b({deviceId:n().int().nonnegative(),hostname:l().optional()}),S(Dne).readonly()),pickStream:k(b({deviceId:n().int().nonnegative(),requirements:cT,preferences:lT.optional()}),uT.nullable())},events:{onCamStreamsChanged:ai(b({deviceId:n().int().nonnegative(),camStreams:S(ba).readonly()}),{notOperatorFacing:`the stream catalog was rebuilt — plumbing, not a happening`}),onProfileSlotsChanged:ai(b({deviceId:n().int().nonnegative(),profileSlots:S(Sa).readonly()}),{notOperatorFacing:`stream profiles were reassigned — plumbing, not a happening`})},runtimeState:b({online:v(),slotStatuses:b({high:xa.optional(),mid:xa.optional(),low:xa.optional()}),slotErrors:b({high:l().optional(),mid:l().optional(),low:l().optional()}),lastChangedAt:n()}),durability:`session`,history:`none`,vocabulary:{noun:P(`Camera streams`,`Flussi della telecamera`),order:3060}},fT=b({detected:v(),lastChangedAt:n()}),pT={name:`carbon-monoxide`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Sensor],methods:{},status:{schema:fT,kind:`push`},runtimeState:fT,durability:`restored`,history:{fields:{detected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:P(`Carbon monoxide`,`Monossido di carbonio`),order:5030,state:[{kind:`boolean`,field:`detected`,label:P(`Detected`,`Rilevato`),whenTrue:P(`When {device} detects carbon monoxide`,`Quando {device} rileva monossido di carbonio`),whenFalse:P(`When the carbon monoxide clears on {device}`,`Quando il monossido su {device} rientra`),icon:`cloud-alert`}]}},mT=x([`off`,`heat`,`cool`,`auto`,`heat_cool`,`fan_only`,`dry`]),hT=x([`heating`,`cooling`,`drying`,`fan`,`idle`,`off`]),gT=b({mode:mT,action:hT.nullable().optional(),availableModes:S(mT),fanMode:l(),availableFanModes:S(l()),preset:l(),availablePresets:S(l()),target:n().nullable().meta(M(`temperature`)),targetHigh:n().nullable().meta(M(`temperature`)),targetLow:n().nullable().meta(M(`temperature`)),targetHumidity:n().min(0).max(100).nullable().meta(M(`humidity`)),currentTemp:n().nullable().meta(M(`temperature`)),currentHumidity:n().min(0).max(100).nullable().meta(M(`humidity`)),swingVertical:v().nullable(),swingHorizontal:v().nullable(),minTemp:n().nullable().optional().meta(M(`temperature`)),maxTemp:n().nullable().optional().meta(M(`temperature`)),tempStep:n().positive().nullable().optional().meta(M(`temperature`)),lastActiveMode:mT.exclude([`off`]).optional(),lastFetchedAt:n()}),wye=[T.Climate];function _T(e,t){return{id:e,cardinality:`scalar`,vocabulary:{cap:`climate-control`,stateField:t},deviceTypes:wye,apply:`replace`,path:t,sources:[{kind:`numeric`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}}var vT=[_T(`room-temperature`,`currentTemp`),_T(`room-humidity`,`currentHumidity`)],Tye={version:1,overridable:vT.map(e=>({path:e.path,by:e.id})),targets:vT},yT={name:`climate-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Climate],power:{kind:`mode`,field:`mode`,offValue:`off`,set:`setMode`,lastField:`lastActiveMode`},methods:{setMode:k(b({deviceId:n().int().nonnegative(),mode:mT}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.off`,label:P(`Climate off`,`Clima spento`),phrase:P(`Turn off {device}`,`Spegni {device}`),icon:`power-off`,effect:{field:`mode`,value:`off`},args:{mode:`off`}},{id:`climate.heat`,label:P(`Heat`,`Riscalda`),phrase:P(`Set {device} to heat`,`Metti {device} in riscaldamento`),icon:`flame`,effect:{field:`mode`,value:`heat`},args:{mode:`heat`}},{id:`climate.cool`,label:P(`Cool`,`Raffresca`),phrase:P(`Set {device} to cool`,`Metti {device} in raffrescamento`),icon:`snowflake`,effect:{field:`mode`,value:`cool`},args:{mode:`cool`}},{id:`climate.auto`,label:P(`Climate auto`,`Clima automatico`),phrase:P(`Set {device} to automatic`,`Metti {device} in automatico`),icon:`thermometer`,effect:{field:`mode`,value:`auto`},args:{mode:`auto`}},{id:`climate.mode`,label:P(`Set mode`,`Imposta la modalità`),phrase:P(`Set {device} to {mode}`,`Imposta {device} su {mode}`),icon:`thermometer`,effect:{field:`mode`,fromArg:`mode`},openArgs:[{key:`mode`,label:P(`Mode`,`Modalità`),offer:{kind:`enum`,values:[{value:`off`,label:P(`Off`,`Spento`)},{value:`heat`,label:P(`Heat`,`Riscaldamento`)},{value:`cool`,label:P(`Cool`,`Raffrescamento`)},{value:`auto`,label:P(`Automatic`,`Automatico`)},{value:`heat_cool`,label:P(`Heat and cool`,`Caldo e freddo`)},{value:`fan_only`,label:P(`Fan only`,`Solo ventilazione`)},{value:`dry`,label:P(`Dry`,`Deumidificazione`)}]}}]}]}),setTarget:k(b({deviceId:n().int().nonnegative(),target:n()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.target`,label:P(`Set temperature`,`Imposta la temperatura`),phrase:P(`Set {device} to {target}`,`Imposta {device} a {target}`),icon:`thermometer`,effect:{field:`target`,fromArg:`target`},openArgs:[{key:`target`,label:P(`Temperature`,`Temperatura`),offer:{kind:`number`,step:.5,unit:`°C`}}]}]}),setTargetRange:A(b({deviceId:n().int().nonnegative(),targetLow:n(),targetHigh:n()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.targetRange`,label:P(`Set temperature range`,`Imposta l’intervallo di temperatura`),phrase:P(`Keep {device} between {targetLow} and {targetHigh}`,`Mantieni {device} tra {targetLow} e {targetHigh}`),icon:`thermometer`,effect:{field:`targetLow`,fromArg:`targetLow`},sideEffects:[{field:`targetHigh`,fromArg:`targetHigh`}],openArgs:[{key:`targetLow`,label:P(`Lowest`,`Minima`),offer:{kind:`number`,step:.5,unit:`°C`}},{key:`targetHigh`,label:P(`Highest`,`Massima`),offer:{kind:`number`,step:.5,unit:`°C`}}]}]}),setTargetHumidity:A(b({deviceId:n().int().nonnegative(),targetHumidity:n().min(0).max(100)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.targetHumidity`,label:P(`Set humidity`,`Imposta l’umidità`),phrase:P(`Set the humidity target of {device} to {targetHumidity}`,`Imposta l’umidità obiettivo di {device} al {targetHumidity}`),icon:`droplets`,effect:{field:`targetHumidity`,fromArg:`targetHumidity`},openArgs:[{key:`targetHumidity`,label:P(`Humidity`,`Umidità`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setFanMode:A(b({deviceId:n().int().nonnegative(),fanMode:l().min(1)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.fanMode`,label:P(`Set fan mode`,`Imposta la ventilazione`),phrase:P(`Set the fan of {device} to {fanMode}`,`Imposta la ventilazione di {device} su {fanMode}`),icon:`fan`,effect:{field:`fanMode`,fromArg:`fanMode`},openArgs:[{key:`fanMode`,label:P(`Fan mode`,`Ventilazione`),offer:{kind:`dynamic`,from:`status`,field:`availableFanModes`}}]}]}),setPreset:A(b({deviceId:n().int().nonnegative(),preset:l().min(1)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.preset`,label:P(`Set preset`,`Imposta il preset`),phrase:P(`Set {device} to preset {preset}`,`Imposta {device} sul preset {preset}`),icon:`list`,effect:{field:`preset`,fromArg:`preset`},openArgs:[{key:`preset`,label:P(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`status`,field:`availablePresets`}}]}]}),setSwingVertical:A(b({deviceId:n().int().nonnegative(),on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.swingVerticalOn`,label:P(`Vertical swing on`,`Oscillazione verticale attiva`),phrase:P(`Start the vertical swing of {device}`,`Attiva l’oscillazione verticale di {device}`),icon:`move-vertical`,effect:{field:`swingVertical`,value:!0},args:{on:!0}},{id:`climate.swingVerticalOff`,label:P(`Vertical swing off`,`Oscillazione verticale spenta`),phrase:P(`Stop the vertical swing of {device}`,`Ferma l’oscillazione verticale di {device}`),icon:`move-vertical`,effect:{field:`swingVertical`,value:!1},args:{on:!1}}]}),setSwingHorizontal:A(b({deviceId:n().int().nonnegative(),on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.swingHorizontalOn`,label:P(`Horizontal swing on`,`Oscillazione orizzontale attiva`),phrase:P(`Start the horizontal swing of {device}`,`Attiva l’oscillazione orizzontale di {device}`),icon:`move-horizontal`,effect:{field:`swingHorizontal`,value:!0},args:{on:!0}},{id:`climate.swingHorizontalOff`,label:P(`Horizontal swing off`,`Oscillazione orizzontale spenta`),phrase:P(`Stop the horizontal swing of {device}`,`Ferma l’oscillazione orizzontale di {device}`),icon:`move-horizontal`,effect:{field:`swingHorizontal`,value:!1},args:{on:!1}}]})},status:{schema:gT,kind:`push`},runtimeState:gT,customize:Tye,durability:`restored`,restoredStateFields:[`lastActiveMode`],history:{primary:`currentTemp`,priority:70,fields:{currentTemp:{group:`temperature`,kind:`gauge`,unit:`°C`,deadband:.1},currentHumidity:{kind:`gauge`,unit:`%`,deadband:.5},target:{group:`temperature`,kind:`gauge`,unit:`°C`,minIntervalMs:0},targetHigh:{group:`target-range`,kind:`gauge`,unit:`°C`,minIntervalMs:0},targetLow:{group:`target-range`,kind:`gauge`,unit:`°C`,minIntervalMs:0}}},vocabulary:{noun:P(`Climate`,`Clima`),order:1070,state:[{kind:`enum`,field:`mode`,label:P(`Mode`,`Modalità`),values:[{value:`off`,label:P(`Off`,`Spento`),phrase:P(`When {device} turns off`,`Quando {device} si spegne`)},{value:`heat`,label:P(`Heat`,`Riscaldamento`),phrase:P(`When {device} starts heating`,`Quando {device} passa al riscaldamento`)},{value:`cool`,label:P(`Cool`,`Raffrescamento`),phrase:P(`When {device} starts cooling`,`Quando {device} passa al raffrescamento`)},{value:`auto`,label:P(`Automatic`,`Automatico`)},{value:`heat_cool`,label:P(`Heat and cool`,`Caldo e freddo`)},{value:`fan_only`,label:P(`Fan only`,`Solo ventilazione`)},{value:`dry`,label:P(`Dry`,`Deumidificazione`)}],icon:`thermometer`},{kind:`numeric`,field:`currentTemp`,quantity:P(`the temperature`,`la temperatura`),label:P(`Temperature`,`Temperatura`),unit:`°C`,icon:`thermometer`},{kind:`numeric`,field:`currentHumidity`,quantity:P(`the humidity`,`l’umidità`),label:P(`Humidity`,`Umidità`),unit:`%`,icon:`droplets`},{kind:`numeric`,field:`target`,quantity:P(`the set temperature`,`la temperatura impostata`),label:P(`Set temperature`,`Temperatura impostata`),unit:`°C`,icon:`thermometer`}]}},bT=x([`backup`,`hub-server`,`agent-server`,`addons`]),xT=x([`pending`,`running`,`ok`,`failed`,`skipped`]),ST=x([`backup-unavailable`,`backup-failed`,`server-refused`,`server-not-on-target`,`node-capless`,`status-unreadable`,`addon-update-failed`,`addons-not-converged`,`interrupted`,`timeout-stall`,`timeout-ceiling`]),CT=b({kind:bT,nodeId:l().optional(),status:xT,detail:l(),reason:ST.optional(),fromVersion:l().nullable().optional(),packages:S(l()).readonly().optional(),startedAt:n().optional(),finishedAt:n().optional()}),wT=x([`running`,`succeeded`,`failed`]),TT=b({id:l(),state:wT,targetVersion:l(),requestedBy:l(),startedAt:n(),finishedAt:n().optional(),steps:S(CT).readonly(),stoppedAt:l().optional(),reason:ST.optional(),skippedOffline:S(l()).readonly()}),ET=b({version:l().optional(),addons:v().optional(),backup:v().optional()}),DT=x([`no-target`,`node-busy`,`job-running`,`nothing-to-do`,`status-unreadable`]),OT=b({targetVersion:l().nullable(),steps:S(CT).readonly(),skippedOffline:S(l()).readonly(),blocker:DT.nullable(),blockerDetail:l().nullable()}),kT=b({accepted:v(),jobId:l().nullable(),blocker:DT.nullable(),message:l()}),AT={name:`cluster-update`,scope:`system`,mode:`singleton`,methods:{previewClusterUpdate:k(ET,OT,{auth:`admin`}),startClusterUpdate:k(ET,kT,{kind:`mutation`,auth:`admin`}),getClusterUpdateJob:k(b({jobId:l().optional()}),TT.nullable(),{auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:j.CLUSTER}},jT=b({r:n().int().min(0).max(255).meta(M(`none`)),g:n().int().min(0).max(255).meta(M(`none`)),b:n().int().min(0).max(255).meta(M(`none`))}),MT=b({h:n().min(0).max(360).meta(M(`none`)),s:n().min(0).max(100).meta(M(`none`)),v:n().min(0).max(100).meta(M(`none`))}),NT=i(`mode`,[b({mode:p(`rgb`),rgb:jT}),b({mode:p(`hsv`),hsv:MT}),b({mode:p(`mired`),colorTemperature:n().int().min(50).max(1e3)})]),PT=b({mode:x([`rgb`,`hsv`,`mired`]),rgb:jT.optional(),hsv:MT.optional(),colorTemperature:n().int().optional().meta(M(`colour-temperature`)),lastChangedAt:n()});function Eye(e){let t=NT.safeParse(e);return t.success?t.data:null}var FT={name:`color`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Light],methods:{setColor:k(b({deviceId:n().int().nonnegative(),color:NT}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`color.warmWhite`,label:P(`Warm white`,`Bianco caldo`),phrase:P(`Set {device} to warm white`,`Imposta {device} su bianco caldo`),icon:`sun`,args:{color:{mode:`mired`,colorTemperature:370}}},{id:`color.coolWhite`,label:P(`Cool white`,`Bianco freddo`),phrase:P(`Set {device} to cool white`,`Imposta {device} su bianco freddo`),icon:`snowflake`,args:{color:{mode:`mired`,colorTemperature:200}}},{id:`color.red`,label:P(`Red`,`Rosso`),phrase:P(`Turn {device} red`,`Colora {device} di rosso`),icon:`palette`,args:{color:{mode:`rgb`,rgb:{r:255,g:0,b:0}}}},{id:`color.green`,label:P(`Green`,`Verde`),phrase:P(`Turn {device} green`,`Colora {device} di verde`),icon:`palette`,args:{color:{mode:`rgb`,rgb:{r:0,g:255,b:0}}}},{id:`color.blue`,label:P(`Blue`,`Blu`),phrase:P(`Turn {device} blue`,`Colora {device} di blu`),icon:`palette`,args:{color:{mode:`rgb`,rgb:{r:0,g:0,b:255}}}}]})},events:{onColorChanged:{data:b({deviceId:n(),mode:x([`rgb`,`hsv`,`mired`]),rgb:jT.optional(),hsv:MT.optional(),colorTemperature:n().int().optional(),lastChangedAt:n()}),notOperatorFacing:"a colour change is read through the `mode` state trigger"}},status:{schema:PT,kind:`command-driven`},runtimeState:PT,durability:`session`,history:`none`,vocabulary:{noun:P(`Colour`,`Colore`),order:1020,state:[{kind:`enum`,field:`mode`,label:P(`Colour mode`,`Modalità colore`),values:[{value:`rgb`,label:P(`RGB colour`,`Colore RGB`)},{value:`hsv`,label:P(`HSV colour`,`Colore HSV`)},{value:`mired`,label:P(`White temperature`,`Temperatura del bianco`)}],icon:`palette`}]}};function IT(e,t){let n=e;for(let e of t.split(`.`)){let t=qg(n);if(!(t instanceof le))return null;let r=t.shape[e];if(!(r instanceof ae))return null;n=r}return n}function LT(e,t){let n=Jg(e).find(e=>e.path===t);if(n===void 0)return null;let r=IT(e,t);return r===null?null:{path:t,kind:n.kind,nullable:r.safeParse(null).success,required:!r.safeParse(void 0).success,...n.enumValues===void 0?{}:{enumValues:n.enumValues},...n.unionMembers===void 0?{}:{unionMembers:n.unionMembers}}}function RT(e){return new Map(Jg(e).filter(e=>!e.path.includes(`.`)).flatMap(t=>{let n=LT(e,t.path);return n===null?[]:[[t.path,n]]}))}function zT(e){let t=qg(e);return t instanceof le?Object.entries(t.shape).flatMap(([e,t])=>t instanceof ae&&!t.safeParse(void 0).success?[e]:[]):[]}function BT(e,t){let n=t.split(`.`);return n.slice(0,-1).flatMap((t,r)=>{let i=n.slice(0,r+1).join(`.`),a=IT(e,i);return a!==null&&a.safeParse(void 0).success?[i]:[]})}var VT={"doorbell.onPressed":w.DoorbellOnPressed},Dye=VT,HT=b({featureIndex:n().int().nonnegative(),cap:l(),eventName:l(),category:x(w),stateField:l(),fieldKey:l()});function UT(e,t,n){return{code:e,path:t,message:n}}function Oye(e){return e.issues.map(e=>`${e.path.length===0?`payload`:e.path.join(`.`)}: ${e.message}`).join(`; `)}function WT(e,t,n){if(t.mode===`replace`)return{problems:[],events:[]};let r=[],i=[];for(let[a,o]of Object.entries(e.events??{})){let s=o.fromState;if(s===void 0)continue;let c=`features[${t.featureIndex}].fields.${s.field}`,l=e.runtimeState?LT(e.runtimeState,s.field):null;if(l===null){r.push(UT(`unknown-field`,c,`\`${e.name}.${a}\` derives from missing state field \`${s.field}\``));continue}if(l.kind!==`number`){r.push(UT(`kind-mismatch`,c,`\`${e.name}.${a}\` needs a numeric state field; \`${s.field}\` is ${l.kind}`));continue}let u=`${e.name}.${a}`,d=Dye[u];if(d===void 0){r.push(UT(`not-composable`,`features[${t.featureIndex}].cap`,`\`${u}\` has no explicit composition event-category mapping`));continue}let f=o.data.safeParse({deviceId:1,timestamp:1});if(!f.success){r.push(UT(`not-composable`,`features[${t.featureIndex}].cap`,`\`${u}\` cannot be derived from { deviceId, timestamp }: ${Oye(f.error)}`));continue}let p=n.find(n=>n.featureIndex===t.featureIndex&&n.cap===e.name&&n.path===s.field&&n.item===void 0);if(p===void 0){r.push(UT(`unknown-field`,c,`\`${u}\` derives from \`${s.field}\`, but that field is not composed`));continue}i.push({featureIndex:t.featureIndex,cap:e.name,eventName:a,category:d,stateField:s.field,fieldKey:`${p.cap}.${p.path}`})}return{problems:r,events:i}}var GT=x(`reserved-variant.unknown-capability.not-composable.wrong-device-type.has-commands.unknown-field.nested-field.missing-field.kind-mismatch.source-kind-mismatch.may-be-null.source-missing.source-unreadable.source-capability-missing.source-field-unknown.expression-invalid.cycle.duplicate-target.not-item-array.item-field-reserved.target-missing.target-unreadable.not-replaceable.native-capability-replace.mixed-quantity.helper-mismatch.member-constraint.retention.command-method-unknown.command-source-unknown.command-input-unknown.command-input-missing.power-source-is-actuator.link-contribution-removed`.split(`.`)),KT=b({code:GT,path:l(),message:l()}),qT=x([`string`,`number`,`boolean`,`enum`]),JT=x([`null`,`offline`,`unknown`,`release`,`omit`]),YT=x([`derived`,`clock`,`constant`,`accumulator`]),XT=b({arrayPath:l(),key:l(),label:l(),resettable:v().optional()}),ZT=b({cap:l(),path:l(),item:XT.optional(),featureIndex:n().int().nonnegative(),kind:qT,nullable:v(),required:v(),unavailable:JT,role:YT,source:ol,reads:S(Qc)});function QT(e){let t=e.item===void 0?e.path:Nl(e.item.arrayPath,e.item.key,e.path);return`${e.cap}.${t}`}var $T=x([`new`,`add`,`replace`]),eE=b({featureIndex:n().int().nonnegative(),cap:l(),mode:$T}),tE=b({ok:v(),problems:S(KT),fields:S(ZT),features:S(eE),events:S(HT)}),nE=x([`stopped`,`starting`,`running`,`degraded`,`incomplete`,`failed`]),rE=x([`fresh`,`stale`,`unavailable`]),iE=b({cap:l(),path:l(),item:XT.optional(),state:rE,value:h([l(),n(),v(),oe()]),reason:l().optional()}),aE=b({blockId:l(),deviceId:n().nullable(),status:nE,reason:l().optional(),fields:S(iE)}),kye=Xc,oE=b({id:l().min(1),name:l().min(1).max(120),enabled:v(),updatedAt:n(),composition:El}),sE=b({id:l().min(1),name:l().nullable(),error:l()}),cE=b({deviceId:n().int(),capName:l(),owner:l(),error:l()}),lE=b({integrationId:l().nullable(),storeLoaded:v(),blocks:S(oE),restartBlockIds:S(l()),unreadableBlocks:S(sE),retiredBlockIds:S(l()).optional()}),uE=b({blockId:l(),status:nE,reason:l().optional()}),dE=b({blocks:S(uE),acted:v(),unreleasedClaims:S(cE).optional()}),fE={name:`composer`,scope:`system`,mode:`singleton`,internal:!0,methods:{applyBlocks:k(lE,dE,{kind:`mutation`,auth:`admin`}),getStates:k(b({blockIds:S(l())}),b({states:S(aE)}),{auth:`admin`})},vocabulary:{notOperatorFacing:`device composition — an authoring tool, not an action`}},pE=b({connected:v(),lastChangedAt:n()}),mE={name:`connectivity`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Sensor],methods:{},status:{schema:pE,kind:`push`},runtimeState:pE,durability:`restored`,history:{fields:{connected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:P(`Connectivity`,`Connettività`),order:5040,state:[{kind:`boolean`,field:`connected`,label:P(`Connected`,`Connesso`),whenTrue:P(`When {device} connects`,`Quando {device} si connette`),whenFalse:P(`When {device} disconnects`,`Quando {device} si disconnette`),icon:`wifi`}]}},hE=x([`wear`,`supply`,`waste`]),gE=x([`part`,`tank`,`product`,`bin`]),_E=x([`ok`,`low`,`empty`,`full`,`replace`]),Aye=x([`ok`,`low`,`empty`,`full`]);function vE(e){return e.kind??`wear`}var jye={wear:`part`,waste:`bin`,supply:`product`};function Mye(e){return e.form??jye[vE(e)]}var yE=x([`duration`,`count`]),bE=b({value:n().min(0).nullable().meta(M(`device`)),kind:yE}),xE=b({key:l().min(1),label:l().min(1),level:n().min(0).max(100).nullable().meta(M(`percentage`)),status:_E.nullable(),kind:hE.optional(),form:gE.optional(),lastResetAt:n().nullable(),resettable:v(),remaining:bE.optional()}),SE=b({items:S(xE),lastChangedAt:n()}),Nye={items:[],lastChangedAt:0},Pye={version:1,targets:[{id:`items`,cardinality:`keyedArray`,vocabulary:{cap:`consumables`},deviceTypes:Object.values(T),apply:`add`,path:`items`,keyField:`key`,labelField:`label`,itemSchema:xE,nativeItems:`read-only`,sourceReport:{status:`assignment-status`},fields:[{path:`level`,sources:[{kind:`numeric`,transforms:[{kind:`identity`},{kind:`linear`,defaultScale:1,defaultOffset:0,clampMin:0,clampMax:100}]}]},{path:`remaining.value`,sources:[{kind:`numeric`,transforms:[{kind:`identity`}]}],literals:[{path:`remaining.kind`,values:[...yE.options]}]},{path:`status`,sources:[{kind:`enum`,transforms:[{kind:`enum-map`,outputValues:[..._E.options],unmapped:null}]}]}],traits:[{path:`kind`,values:[...hE.options],defaultValue:`wear`},{path:`form`,values:[...gE.options],defaultValue:`part`}],companions:[{kind:`clock`,path:`lastChangedAt`,when:`add`},{kind:`clock`,path:`lastFetchedAt`,when:`add`}],advancedExpression:!0}]},CE={name:`consumables`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:Object.values(T),methods:{reset:k(b({deviceId:n().int().nonnegative(),key:l().min(1)}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`consumables.reset`,label:P(`Mark as replaced`,`Segna come sostituito`),phrase:P(`Mark {key} as replaced on {device}`,`Segna {key} come sostituito su {device}`),icon:`refresh-cw`,openArgs:[{key:`key`,label:P(`Consumable`,`Materiale`),offer:{kind:`dynamic`,from:`status`,field:`items`,valueKey:`key`,labelKey:`label`,where:{key:`resettable`,equals:!0}}}]}]})},composedMethods:{reset:{kind:`refuse`,reason:`a consumable added to an existing device is not resettable — only a new composed device forwards a reset`}},status:{schema:SE,kind:`push`,empty:Nye,itemArray:{path:`items`,keyField:`key`,labelField:`label`,itemSchema:xE,emptyItem:{key:``,label:``,level:null,status:null,lastResetAt:null,resettable:!1}}},runtimeState:SE.extend({lastFetchedAt:n()}),durability:`restored`,customize:Pye,history:{fields:{},items:{path:`items`,key:`key`,label:`label`,fields:{level:{kind:`gauge`,unit:`%`,deadband:2,displayName:`Level`},status:{kind:`enum`,displayName:`Status`},"remaining.value":{kind:`gauge`,deadband:1,displayName:`Remaining`}}}},volatileStateFields:[`lastChangedAt`,`lastFetchedAt`],vocabulary:{noun:P(`Consumables`,`Materiali di consumo`),order:2070}},wE=b({entryOpen:v(),lastChangedAt:n()}),TE={name:`contact`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Sensor],methods:{},status:{schema:wE,kind:`push`},runtimeState:wE,durability:`restored`,history:{fields:{entryOpen:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:P(`Contact`,`Contatto`),order:5050,state:[{kind:`boolean`,field:`entryOpen`,label:P(`Open`,`Aperto`),whenTrue:P(`When {device} opens`,`Quando {device} si apre`),whenFalse:P(`When {device} closes`,`Quando {device} si chiude`),icon:`door-open`}]}},EE=x([`numeric`,`select`,`text`,`datetime`]),DE=b({kind:EE,value:h([n().meta(M(`device`)),l()]),options:S(l()),lastChangedAt:n(),min:n().optional().meta(M(`device`)),max:n().optional().meta(M(`device`)),step:n().optional().meta(M(`device`))}),Fye=i(`kind`,[b({kind:p(`numeric`),value:n()}),b({kind:p(`select`),value:l().min(1)}),b({kind:p(`text`),value:l()}),b({kind:p(`datetime`),value:l().min(1)})]),OE=b({deviceId:n().int().nonnegative(),cycle:v().default(!0)}),kE=b({deviceId:n().int().nonnegative()}),AE={name:`control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Control],methods:{setValue:k(b({deviceId:n().int().nonnegative(),control:Fye}),_(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`the value shape depends on the control kind (numeric / select / text / datetime) read from status; a typed picker for it is a follow-up of the automations rework`}),next:A(OE,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.next`,label:P(`Next option`,`Opzione successiva`),phrase:P(`Select the next option on {device}`,`Seleziona l’opzione successiva su {device}`),icon:`skip-forward`,openArgs:[{key:`cycle`,label:P(`Wrap to the first option`,`Ricomincia dalla prima opzione`),offer:{kind:`boolean`}}]}]}),previous:A(OE,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.previous`,label:P(`Previous option`,`Opzione precedente`),phrase:P(`Select the previous option on {device}`,`Seleziona l’opzione precedente su {device}`),icon:`skip-back`,openArgs:[{key:`cycle`,label:P(`Wrap to the last option`,`Ricomincia dall’ultima opzione`),offer:{kind:`boolean`}}]}]}),first:A(kE,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.first`,label:P(`First option`,`Prima opzione`),phrase:P(`Select the first option on {device}`,`Seleziona la prima opzione su {device}`),icon:`chevron-first`}]}),last:A(kE,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.last`,label:P(`Last option`,`Ultima opzione`),phrase:P(`Select the last option on {device}`,`Seleziona l’ultima opzione su {device}`),icon:`chevron-last`}]})},status:{schema:DE,kind:`push`},runtimeState:DE,durability:`session`,history:`none`,vocabulary:{noun:P(`Control`,`Controllo`),order:1150,state:[{kind:`value`,field:`value`,label:P(`Value`,`Valore`),offer:{kind:`dynamic`,from:`status`,field:`options`},icon:`sliders-horizontal`}]}},B=class extends Error{code;constructor(e,t){super(t),this.name=`IrCodecError`,this.code=e}},jE=1024,ME=S(n().int()).min(2).max(jE).superRefine((e,t)=>{e.forEach((e,n)=>{let r=n%2==0;(e===0||e>0!==r)&&t.addIssue({code:`custom`,message:`timing ${n} must be a non-zero ${r?`mark (positive)`:`space (negative)`}`,path:[n]})})}),NE=b({carrierHz:n().int().positive().optional(),dutyCyclePercent:n().int().min(1).max(100).optional(),repeat:n().int().min(0).max(20).optional(),repeatDelayMs:n().int().min(0).optional()}),Iye=.241246,Lye=0;function PE(e){let t=e.trim().split(/\s+/).filter(e=>e.length>0);if(t.length<4)throw new B(`pronto-malformed`,`Pronto code needs at least 4 words, got ${t.length}`);let n=t.map(e=>/^[0-9a-fA-F]{1,4}$/.test(e)?parseInt(e,16):NaN);if(n.some(e=>Number.isNaN(e)))throw new B(`pronto-malformed`,`Pronto code must be 4-digit hexadecimal words`);let[r,i,a,o]=n;if(r===void 0||i===void 0||a===void 0||o===void 0)throw new B(`pronto-malformed`,`Pronto header incomplete`);if(r!==Lye)throw new B(`pronto-unsupported-form`,`Pronto form ${t[0]??``} is not supported, only the learned 0000 form`);if(i===0)throw new B(`pronto-malformed`,`Pronto frequency word is zero`);let s=a+o;if(s===0||n.length!==4+s*2)throw new B(`pronto-malformed`,`Pronto declares ${s} burst pairs but carries ${(n.length-4)/2} word pairs`);let c=i*Iye,l=n.slice(4).map((e,t)=>{let n=Math.max(1,Math.round(e*c));return t%2==0?n:-n}),u=ME.safeParse(l);if(!u.success)throw new B(`invalid-timings`,`Pronto decoded to invalid timings: ${u.error.message}`);return{timings:u.data,carrierHz:Math.round(1e6/c)}}var Rye=8192,FE=32,IE=3,zye=264,LE=jE*2;function Bye(e){let t=[],n=0,r=e=>{if(t.length+e>LE)throw new B(`tuya-malformed`,`decompressed code is larger than any IR train`)},i=()=>{let t=e[n++];if(t===void 0)throw new B(`tuya-malformed`,`compressed stream is truncated`);return t};for(;n<e.length;){let e=i();if(e<32){r(e+1);for(let n=0;n<=e;n++)t.push(i());continue}let n=(e>>5)-1;n===6&&(n+=i());let a=((e&31)<<8)+i()+1,o=t.length-a;if(o<0)throw new B(`tuya-malformed`,`back-reference points before the stream`);r(n+3);for(let e=0;e<n+3;e++){let n=t[o+e];if(n===void 0)throw new B(`tuya-malformed`,`back-reference is invalid`);t.push(n)}}return Uint8Array.from(t)}function Vye(e){let t=[],n=new Map,r=0,i=n=>{for(let i=r;i<n;i+=FE){let r=Math.min(i+FE,n);t.push(r-i-1);for(let n=i;n<r;n++)t.push(e[n]??0)}},a=0;for(;a<e.length;){let o=0,s=0;if(a+IE<=e.length){let t=(e[a]??0)<<16|(e[a+1]??0)<<8|(e[a+2]??0),r=n.get(t);if(n.set(t,a),r!==void 0&&a-r<=Rye){let t=0;for(;a+t<e.length&&t<zye&&e[r+t]===e[a+t];)t++;t>=IE&&(o=t,s=a-r-1)}}if(o===0){a++;continue}i(a);let c=o-2;c<7?t.push(c<<5|s>>8):t.push(224|s>>8,c-7),t.push(s&255),a+=o,r=a}return i(e.length),Uint8Array.from(t)}var RE=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Hye=65535;function Uye(e){let t=``;for(let n=0;n<e.length;n+=3){let r=e[n]??0,i=e[n+1]??0,a=e[n+2]??0,o=r<<16|i<<8|a;t+=RE[o>>18&63],t+=RE[o>>12&63],t+=n+1<e.length?RE[o>>6&63]:`=`,t+=n+2<e.length?RE[o&63]:`=`}return t}function Wye(e){let t=e.trim().replace(/=+$/,``);if(t.length===0||t.length%4==1)throw new B(`tuya-malformed`,`not a base64 string`);let n=[],r=0,i=0;for(let e of t){let t=RE.indexOf(e);if(t<0)throw new B(`tuya-malformed`,`not a base64 string`);i=i<<6|t,r+=6,r>=8&&(r-=8,n.push(i>>r&255))}return Uint8Array.from(n)}function zE(e){let t=new Uint8Array(e.length*2);return e.forEach((e,n)=>{let r=Math.abs(e);if(r===0||r>Hye)throw new B(`invalid-timings`,`timing ${n} does not fit 16 bits`);t[n*2]=r&255,t[n*2+1]=r>>8}),Uye(Vye(t))}function BE(e){let t=Bye(Wye(e));if(t.length===0||t.length%2!=0)throw new B(`tuya-malformed`,`payload is not a list of 16-bit durations`);let n=[];for(let e=0;e<t.length;e+=2){let r=(t[e]??0)|(t[e+1]??0)<<8;n.push(e/2%2==0?r:-r)}let r=ME.safeParse(n);if(!r.success)throw new B(`tuya-malformed`,r.error.message);return r.data}var VE=x([`tuya`]),HE=Math.ceil((LE+Math.ceil(LE/32))/3)*4+256,UE=b({format:VE,code:l().min(1).max(HE)}),WE={tuya:{encode:zE,decode:BE}},GE=i(`kind`,[b({kind:p(`raw`),timings:S(n().int()),settings:NE.optional()}),b({kind:p(`pronto`),code:l()}),b({kind:p(`native`),format:VE,code:l()})]);function KE(e){if(e.kind===`pronto`){let t=PE(e.code);return{timings:t.timings,settings:{carrierHz:t.carrierHz}}}if(e.kind===`native`)return{timings:WE[e.format].decode(e.code),settings:{}};let t=ME.safeParse(e.timings);if(!t.success)throw new B(`invalid-timings`,t.error.message);return{timings:t.data,settings:e.settings??{}}}var qE=`power.power_on.power_off.volume_up.volume_down.mute.channel_up.channel_down.up.down.left.right.ok.back.home.menu.info.guide.exit.input.play.pause.play_pause.stop.next.previous.fast_forward.rewind.digit_0.digit_1.digit_2.digit_3.digit_4.digit_5.digit_6.digit_7.digit_8.digit_9.source_select`.split(`.`),JE=[`source_select`];function YE(e){return JE.includes(e)}var XE=`custom:`,Gye=/^[a-z0-9][a-z0-9_]{0,47}$/,Kye=new Set(qE);function ZE(e){return Kye.has(e)}function QE(e){return Gye.test(e)}function $E(e){return`${XE}${e}`}function eD(e){if(!e.startsWith(`custom:`))return null;let t=e.slice(7);return QE(t)?t:null}function tD(e){return ZE(e)||eD(e)!==null}var nD=l().refine(tD,{message:`a role is one of the known roles or custom:<key> (lowercase letters, digits, _)`}),rD=[`digits`,`sequence`,`ir`],qye=x(rD),Jye=200,Yye=16,Xye=6,Zye=/^[a-z0-9][a-z0-9_-]{0,47}$/,Qye=RegExp(`^[0-9]{1,6}$`),iD={id:l().regex(Zye,{message:`a lowercase slug`}),name:l().trim().min(1).max(60)},aD=b({...iD,kind:p(`digits`),number:l().regex(Qye,{message:`up to 6 digits`})}),oD=b({...iD,kind:p(`sequence`),steps:S(nD).min(1).max(16)}),sD=b({...iD,kind:p(`ir`),transmitterId:n().int().nonnegative().optional(),payload:GE}),cD=i(`kind`,[aD,oD,sD]),$ye=500,ebe=100,lD=3e3;function uD(e){switch(e.kind){case`sequence`:return e.steps;case`digits`:return Array.from(e.number,e=>`digit_${e}`);case`ir`:return[]}}function dD(e){try{return KE(e.payload),null}catch(e){if(e instanceof B)return e.message;throw e}}function tbe(e,t){return e.trim().toLowerCase()===t.trim().toLowerCase()}function fD(e,t){let n=t.trim();for(let t of e)if(t.kind===`digits`&&t.number===n)return t;return null}function nbe(e,t){let n=e.find(e=>tbe(e.name,t));if(n!==void 0)return n;let r=e.find(e=>e.id===t.trim());return r===void 0?fD(e,t):r}var pD=x([`off`,`on`,`idle`,`playing`,`paused`,`buffering`,`standby`]),mD=x([`off`,`all`,`one`]),rbe=b({type:l(),title:l(),artist:l().optional(),album:l().optional(),imageUrl:l().optional()}),hD=x([`reported`,`assumed`]),gD=x([`state`,`volumeLevel`,`isMuted`,`source`]),_D=b({state:pD,stateSource:hD.default(`reported`),assumedFields:S(gD).default([]),volumeLevel:n().min(0).max(100).nullable().meta(M(`percentage`)),isMuted:v().nullable(),muteReadback:v().optional(),source:l(),availableSources:S(l()),declaredSources:S(b({name:l(),kind:x(rD),number:l().optional()})).optional(),currentMedia:rbe.nullable(),position:n().int().nonnegative().nullable().meta(M(`duration-ms`)),duration:n().int().nonnegative().nullable().meta(M(`duration-ms`)),shuffle:v().nullable(),repeat:mD.nullable(),positionUpdatedAt:n().nullable().default(null),lastChangedAt:n()}),ibe=50,vD=b({deviceId:n().int().nonnegative(),steps:n().int().min(1).max(50).default(1)}),yD=b({deviceId:n().int().nonnegative()}),bD={name:`media-player`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.MediaPlayer],power:{kind:`methods`,field:`state`,offValues:[`off`,`standby`],on:`turnOn`,off:`turnOff`},methods:{turnOn:A(yD,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.turnOn`,label:P(`Turn on`,`Accendi`),phrase:P(`Turn on {device}`,`Accendi {device}`),icon:`power`}]}),turnOff:A(yD,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.turnOff`,label:P(`Turn off`,`Spegni`),phrase:P(`Turn off {device}`,`Spegni {device}`),icon:`power`}]}),volumeUp:A(vD,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.volumeUp`,label:P(`Volume up`,`Alza il volume`),phrase:P(`Raise the volume of {device}`,`Alza il volume di {device}`),icon:`volume-2`}]}),volumeDown:A(vD,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.volumeDown`,label:P(`Volume down`,`Abbassa il volume`),phrase:P(`Lower the volume of {device}`,`Abbassa il volume di {device}`),icon:`volume-2`}]}),channelUp:A(vD,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.channelUp`,label:P(`Channel up`,`Canale successivo`),phrase:P(`Go to the next channel on {device}`,`Passa al canale successivo su {device}`),icon:`skip-forward`}]}),channelDown:A(vD,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.channelDown`,label:P(`Channel down`,`Canale precedente`),phrase:P(`Go to the previous channel on {device}`,`Torna al canale precedente su {device}`),icon:`skip-back`}]}),play:k(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.play`,effect:{field:`state`,value:`playing`},label:P(`Play`,`Riproduci`),phrase:P(`Play on {device}`,`Avvia la riproduzione su {device}`),icon:`play`}]}),pause:k(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.pause`,effect:{field:`state`,value:`paused`},label:P(`Pause media`,`Metti in pausa`),phrase:P(`Pause {device}`,`Metti in pausa {device}`),icon:`pause`}]}),stop:A(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.stop`,label:P(`Stop media`,`Ferma la riproduzione`),phrase:P(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),next:A(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.next`,label:P(`Next track`,`Brano successivo`),phrase:P(`Skip to the next track on {device}`,`Passa al brano successivo su {device}`),icon:`skip-forward`}]}),previous:A(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.previous`,label:P(`Previous track`,`Brano precedente`),phrase:P(`Go back to the previous track on {device}`,`Torna al brano precedente su {device}`),icon:`skip-back`}]}),setVolume:A(b({deviceId:n().int().nonnegative(),volumeLevel:n().min(0).max(100)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.volume`,effect:{field:`volumeLevel`,fromArg:`volumeLevel`},label:P(`Set volume`,`Imposta il volume`),phrase:P(`Set the volume of {device} to {volumeLevel}`,`Imposta il volume di {device} al {volumeLevel}`),icon:`volume-2`,openArgs:[{key:`volumeLevel`,label:P(`Volume`,`Volume`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setMute:A(b({deviceId:n().int().nonnegative(),muted:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.mute`,effect:{field:`isMuted`,value:!0},label:P(`Mute`,`Silenzia`),phrase:P(`Mute {device}`,`Silenzia {device}`),icon:`volume-x`,args:{muted:!0}},{id:`media.unmute`,effect:{field:`isMuted`,value:!1},label:P(`Unmute`,`Riattiva l’audio`),phrase:P(`Unmute {device}`,`Riattiva l’audio di {device}`),icon:`volume-2`,args:{muted:!1}}]}),setShuffle:A(b({deviceId:n().int().nonnegative(),shuffle:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.shuffleOn`,effect:{field:`shuffle`,value:!0},label:P(`Shuffle on`,`Riproduzione casuale attiva`),phrase:P(`Turn on shuffle on {device}`,`Attiva la riproduzione casuale su {device}`),icon:`shuffle`,args:{shuffle:!0}},{id:`media.shuffleOff`,effect:{field:`shuffle`,value:!1},label:P(`Shuffle off`,`Riproduzione casuale spenta`),phrase:P(`Turn off shuffle on {device}`,`Disattiva la riproduzione casuale su {device}`),icon:`shuffle`,args:{shuffle:!1}}]}),setRepeat:A(b({deviceId:n().int().nonnegative(),repeat:mD}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.repeat`,effect:{field:`repeat`,fromArg:`repeat`},label:P(`Set repeat`,`Imposta la ripetizione`),phrase:P(`Set repeat on {device} to {repeat}`,`Imposta la ripetizione di {device} su {repeat}`),icon:`repeat`,openArgs:[{key:`repeat`,label:P(`Repeat`,`Ripetizione`),offer:{kind:`enum`,values:[{value:`off`,label:P(`Off`,`Disattivata`)},{value:`all`,label:P(`All`,`Tutti i brani`)},{value:`one`,label:P(`One track`,`Un brano`)}]}}]}]}),selectSource:A(b({deviceId:n().int().nonnegative(),source:l().min(1)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.source`,effect:{field:`source`,fromArg:`source`},label:P(`Select source`,`Scegli la sorgente`),phrase:P(`Switch {device} to {source}`,`Passa {device} alla sorgente {source}`),icon:`cast`,openArgs:[{key:`source`,label:P(`Source`,`Sorgente`),offer:{kind:`dynamic`,from:`status`,field:`availableSources`}}]}]}),seek:A(b({deviceId:n().int().nonnegative(),position:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.seek`,label:P(`Seek`,`Vai al punto`),phrase:P(`Move {device} to {position}`,`Porta {device} al punto {position}`),icon:`fast-forward`,openArgs:[{key:`position`,label:P(`Position`,`Posizione`),offer:{kind:`number`,min:0,step:1e3,unit:`ms`}}]}]}),playMedia:A(b({deviceId:n().int().nonnegative(),mediaId:l().min(1),mediaType:l().min(1)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.playMedia`,label:P(`Play media`,`Riproduci un contenuto`),phrase:P(`Play {mediaId} on {device}`,`Riproduci {mediaId} su {device}`),icon:`music`,openArgs:[{key:`mediaId`,label:P(`Media`,`Contenuto`),offer:{kind:`text`}},{key:`mediaType`,label:P(`Media type`,`Tipo di contenuto`),offer:{kind:`text`}}]}]})},status:{schema:_D,kind:`push`},runtimeState:_D,durability:`session`,history:{fields:{volumeLevel:{kind:`gauge`,unit:`%`,deadband:1},isMuted:{kind:`boolean`}}},vocabulary:{noun:P(`Media player`,`Lettore multimediale`),order:2060,state:[{kind:`enum`,field:`state`,label:P(`Playback`,`Riproduzione`),values:[{value:`off`,label:P(`Off`,`Spento`),phrase:P(`When {device} turns off`,`Quando {device} si spegne`)},{value:`on`,label:P(`On`,`Acceso`),phrase:P(`When {device} turns on`,`Quando {device} si accende`)},{value:`idle`,label:P(`Idle`,`Inattivo`)},{value:`playing`,label:P(`Playing`,`In riproduzione`),phrase:P(`When {device} starts playing`,`Quando {device} inizia a riprodurre`)},{value:`paused`,label:P(`Paused`,`In pausa`),phrase:P(`When {device} is paused`,`Quando {device} va in pausa`)},{value:`buffering`,label:P(`Buffering`,`In caricamento`)},{value:`standby`,label:P(`Standby`,`In standby`)}],icon:`music`},{kind:`numeric`,field:`volumeLevel`,quantity:P(`the volume`,`il volume`),label:P(`Volume`,`Volume`),unit:`%`,icon:`volume-2`},{kind:`boolean`,field:`isMuted`,label:P(`Muted`,`Silenziato`),whenTrue:P(`When {device} is muted`,`Quando {device} viene silenziato`),whenFalse:P(`When {device} is unmuted`,`Quando l’audio di {device} torna attivo`),icon:`volume-x`},{kind:`value`,field:`source`,label:P(`Source`,`Sorgente`),offer:{kind:`dynamic`,from:`status`,field:`availableSources`},icon:`cast`}]}},xD={battery:{version:1,targets:[{id:`level`,cardinality:`scalar`,deviceTypes:[T.Camera,T.Sensor,T.Button,T.Switch,T.PetFeeder,T.Container,T.Climate,T.EventEmitter],apply:`add`,vocabularyCap:`battery`,vocabularyStateField:`level`,sources:[{kind:`field`,valueKinds:[`number`,`string`],transformKinds:[`identity`,`linear`],transforms:[{kind:`identity`},{kind:`linear`,defaultScale:1,defaultOffset:0,clampMin:0,clampMax:100}]}],sourceReport:{status:`assignment-status`},advancedExpression:!0,path:`level`,valueKind:`number`,nullable:!0,companions:[{kind:`constant`,path:`charging`,value:`unknown`,when:`add`},{kind:`constant`,path:`sleeping`,value:!1,when:`add`},{kind:`clock`,path:`lastUpdated`,when:`add`}]}]},"climate-control":{version:1,targets:[{id:`room-temperature`,cardinality:`scalar`,deviceTypes:[T.Climate],apply:`replace`,vocabularyCap:`climate-control`,vocabularyStateField:`currentTemp`,sources:[{kind:`numeric`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`currentTemp`,valueKind:`number`,nullable:!0},{id:`room-humidity`,cardinality:`scalar`,deviceTypes:[T.Climate],apply:`replace`,vocabularyCap:`climate-control`,vocabularyStateField:`currentHumidity`,sources:[{kind:`numeric`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`currentHumidity`,valueKind:`number`,nullable:!0}],overridable:[{path:`currentTemp`,by:`room-temperature`},{path:`currentHumidity`,by:`room-humidity`}]},consumables:{version:1,targets:[{id:`items`,cardinality:`keyedArray`,deviceTypes:[T.Camera,T.Light,T.Siren,T.Switch,T.Sensor,T.Climate,T.Button,T.EventEmitter,T.Update,T.Generic,T.Notifier,T.Script,T.Automation,T.Lock,T.Cover,T.Valve,T.Humidifier,T.WaterHeater,T.Fan,T.MediaPlayer,T.AlarmPanel,T.Control,T.Presence,T.Weather,T.WeatherStation,T.Vacuum,T.LawnMower,T.Container,T.Image,T.PetFeeder,T.PetFountain,T.Dishwasher,T.Washer,T.Dryer,T.Gateway,T.HeatPump,T.EnergySystem,T.Workload],apply:`add`,vocabularyCap:`consumables`,sources:[],sourceReport:{status:`assignment-status`},advancedExpression:!0,path:`items`,keyField:`key`,labelField:`label`,nativeItems:`read-only`,fields:[{path:`level`,valueKind:`number`,nullable:!0,sources:[{kind:`numeric`,transformKinds:[`identity`,`linear`],transforms:[{kind:`identity`},{kind:`linear`,defaultScale:1,defaultOffset:0,clampMin:0,clampMax:100}]}]},{path:`remaining.value`,valueKind:`number`,nullable:!0,sources:[{kind:`numeric`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],literals:[{path:`remaining.kind`,values:[`duration`,`count`]}]},{path:`status`,valueKind:`enum`,nullable:!0,enumValues:[`ok`,`low`,`empty`,`full`,`replace`],sources:[{kind:`enum`,transformKinds:[`enum-map`],transforms:[{kind:`enum-map`,outputValues:[`ok`,`low`,`empty`,`full`,`replace`],unmapped:null}]}]}],traits:[{path:`kind`,values:[`wear`,`supply`,`waste`],defaultValue:`wear`},{path:`form`,values:[`part`,`tank`,`product`,`bin`],defaultValue:`part`}],companions:[{kind:`clock`,path:`lastChangedAt`,when:`add`},{kind:`clock`,path:`lastFetchedAt`,when:`add`}]}]},doorbell:{version:1,targets:[{id:`pressed`,cardinality:`event`,deviceTypes:[T.Camera],apply:`add`,vocabularyCap:`doorbell`,vocabularyEvent:`onPressed`,sources:[{kind:`binary`,transformKinds:[],transforms:[]},{kind:`switch`,transformKinds:[],transforms:[]}],sourceReport:{status:`assignment-status`},advancedExpression:!0,shape:`pulse`,applyAuthority:{kind:`composition-claim`},eventName:`onPressed`,combine:`any`,edges:[`rising`],defaultEdge:`rising`,timestampPath:`lastPressedAt`,counterPath:`pressCountSinceStart`,highWater:`composer-advance`,debounceMs:2e3}]},"fan-control":{version:1,targets:[{id:`horizontal-oscillating`,cardinality:`scalar`,deviceTypes:[T.Fan],apply:`replace`,vocabularyCap:`fan-control`,vocabularyStateField:`oscillating`,sources:[{kind:`switch`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,section:`oscillation-axes`,path:`oscillationAxes.horizontal.oscillating`,valueKind:`boolean`,nullable:!0},{id:`horizontal-angle`,cardinality:`scalar`,deviceTypes:[T.Fan],apply:`replace`,vocabularyCap:`fan-control`,sources:[{kind:`numeric`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,section:`oscillation-axes`,path:`oscillationAxes.horizontal.angle`,valueKind:`number`,nullable:!0,companions:[{kind:`source-field`,path:`oscillationAxes.horizontal.min`,field:`min`},{kind:`source-field`,path:`oscillationAxes.horizontal.max`,field:`max`},{kind:`source-field`,path:`oscillationAxes.horizontal.step`,field:`step`}]},{id:`horizontal-sweepFrom`,cardinality:`scalar`,deviceTypes:[T.Fan],apply:`replace`,vocabularyCap:`fan-control`,sources:[{kind:`numeric`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,section:`oscillation-axes`,path:`oscillationAxes.horizontal.sweepFrom`,valueKind:`number`,nullable:!0},{id:`horizontal-sweepTo`,cardinality:`scalar`,deviceTypes:[T.Fan],apply:`replace`,vocabularyCap:`fan-control`,sources:[{kind:`numeric`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,section:`oscillation-axes`,path:`oscillationAxes.horizontal.sweepTo`,valueKind:`number`,nullable:!0},{id:`vertical-oscillating`,cardinality:`scalar`,deviceTypes:[T.Fan],apply:`replace`,vocabularyCap:`fan-control`,vocabularyStateField:`oscillating`,sources:[{kind:`switch`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,section:`oscillation-axes`,path:`oscillationAxes.vertical.oscillating`,valueKind:`boolean`,nullable:!0},{id:`vertical-angle`,cardinality:`scalar`,deviceTypes:[T.Fan],apply:`replace`,vocabularyCap:`fan-control`,sources:[{kind:`numeric`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,section:`oscillation-axes`,path:`oscillationAxes.vertical.angle`,valueKind:`number`,nullable:!0,companions:[{kind:`source-field`,path:`oscillationAxes.vertical.min`,field:`min`},{kind:`source-field`,path:`oscillationAxes.vertical.max`,field:`max`},{kind:`source-field`,path:`oscillationAxes.vertical.step`,field:`step`}]},{id:`vertical-sweepFrom`,cardinality:`scalar`,deviceTypes:[T.Fan],apply:`replace`,vocabularyCap:`fan-control`,sources:[{kind:`numeric`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,section:`oscillation-axes`,path:`oscillationAxes.vertical.sweepFrom`,valueKind:`number`,nullable:!0},{id:`vertical-sweepTo`,cardinality:`scalar`,deviceTypes:[T.Fan],apply:`replace`,vocabularyCap:`fan-control`,sources:[{kind:`numeric`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,section:`oscillation-axes`,path:`oscillationAxes.vertical.sweepTo`,valueKind:`number`,nullable:!0},{id:`preset`,cardinality:`scalar`,deviceTypes:[T.Fan],apply:`replace`,vocabularyCap:`fan-control`,sources:[{kind:`field`,valueKinds:[`string`],transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`preset`,valueKind:`string`,nullable:!1}],overridable:[{path:`oscillationAxes.horizontal.oscillating`,by:`horizontal-oscillating`},{path:`oscillationAxes.horizontal.angle`,by:`horizontal-angle`},{path:`oscillationAxes.horizontal.sweepFrom`,by:`horizontal-sweepFrom`},{path:`oscillationAxes.horizontal.sweepTo`,by:`horizontal-sweepTo`},{path:`oscillationAxes.vertical.oscillating`,by:`vertical-oscillating`},{path:`oscillationAxes.vertical.angle`,by:`vertical-angle`},{path:`oscillationAxes.vertical.sweepFrom`,by:`vertical-sweepFrom`},{path:`oscillationAxes.vertical.sweepTo`,by:`vertical-sweepTo`},{path:`preset`,by:`preset`}]},"fan-presets":{version:1,targets:[{id:`presets`,cardinality:`config`,deviceTypes:[T.Fan],apply:`add`,readMethod:`getPresets`,writeMethod:`setPresets`,vocabularyCap:`fan-presets`,sources:[],sourceReport:{status:`assignment-status`},advancedExpression:!1}]},"lock-control":{version:1,targets:[{id:`door-contact`,cardinality:`scalar`,deviceTypes:[T.Lock],apply:`replace`,vocabularyCap:`lock-control`,vocabularyStateField:`state`,sources:[{kind:`binary`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`state`,override:{whenSourceTrue:`door-open`,unlessNative:[`jammed`]},valueKind:`enum`,nullable:!1,enumValues:[`locked`,`unlocked`,`locking`,`unlocking`,`jammed`,`door-open`]}],overridable:[{path:`state`,by:`door-contact`}]},motion:{version:1,targets:[{id:`detected`,cardinality:`event`,deviceTypes:[T.Camera],apply:`add`,vocabularyCap:`motion`,vocabularyEvent:`onMotionChanged`,sources:[{kind:`binary`,transformKinds:[],transforms:[]},{kind:`switch`,transformKinds:[],transforms:[]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,shape:`span`,applyAuthority:{kind:`camera-sensors`,timeoutField:`motionCooldownMs`},eventName:`onMotionChanged`,combine:`any`,start:`rising-edge`,end:`falling-edge-or-timeout`,timeoutMs:3e4,sourceModes:[`in-addition`,`confirm`,`replace`]}]},"power-meter":{version:1,targets:[{id:`power`,cardinality:`scalar`,deviceTypes:[T.Switch,T.Light,T.Fan,T.Climate,T.Humidifier,T.WaterHeater,T.MediaPlayer,T.Washer,T.Dryer,T.Dishwasher,T.Vacuum,T.LawnMower,T.PetFeeder,T.Workload],apply:`add`,vocabularyCap:`power-meter`,vocabularyStateField:`power`,sources:[{kind:`numeric`,requiredUnit:`W`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!0,path:`power`,valueKind:`number`,nullable:!1,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`always`}]},{id:`energy`,cardinality:`scalar`,deviceTypes:[T.Switch,T.Light,T.Fan,T.Climate,T.Humidifier,T.WaterHeater,T.MediaPlayer,T.Washer,T.Dryer,T.Dishwasher,T.Vacuum,T.LawnMower,T.PetFeeder,T.Workload],apply:`add`,vocabularyCap:`power-meter`,vocabularyStateField:`energy`,sources:[{kind:`numeric`,requiredUnit:`kWh`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!0,path:`energy`,valueKind:`number`,nullable:!1,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`always`}]},{id:`voltage`,cardinality:`scalar`,deviceTypes:[T.Switch,T.Light,T.Fan,T.Climate,T.Humidifier,T.WaterHeater,T.MediaPlayer,T.Washer,T.Dryer,T.Dishwasher,T.Vacuum,T.LawnMower,T.PetFeeder,T.Workload],apply:`add`,vocabularyCap:`power-meter`,vocabularyStateField:`voltage`,sources:[{kind:`numeric`,requiredUnit:`V`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!0,path:`voltage`,valueKind:`number`,nullable:!1,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`always`}]},{id:`current`,cardinality:`scalar`,deviceTypes:[T.Switch,T.Light,T.Fan,T.Climate,T.Humidifier,T.WaterHeater,T.MediaPlayer,T.Washer,T.Dryer,T.Dishwasher,T.Vacuum,T.LawnMower,T.PetFeeder,T.Workload],apply:`add`,vocabularyCap:`power-meter`,vocabularyStateField:`current`,sources:[{kind:`numeric`,requiredUnit:`A`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!0,path:`current`,valueKind:`number`,nullable:!1,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`always`}]}]},"power-source":{version:1,targets:[{id:`switch`,cardinality:`scalar`,deviceTypes:[T.Gateway,T.Camera,T.Sensor,T.MediaPlayer,T.Vacuum,T.Generic,T.Washer,T.Dryer,T.Dishwasher,T.PetFountain,T.Fan,T.Humidifier,T.Climate,T.WaterHeater],apply:`add`,vocabularyCap:`power-source`,vocabularyStateField:`switchOn`,sources:[{kind:`switch`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`switchOn`,valueKind:`boolean`,nullable:!0,companions:[{kind:`constant`,path:`offSeconds`,value:10,when:`add`,formerValues:[0]},{kind:`clock`,path:`lastFetchedAt`,when:`always`}]}]},remote:{version:1,targets:[{id:`remote`,cardinality:`config`,deviceTypes:[T.MediaPlayer],apply:`add`,readMethod:`getConfig`,writeMethod:`setConfig`,vocabularyCap:`remote`,sources:[],sourceReport:{status:`assignment-status`},advancedExpression:!1}]},"running-state":{version:1,targets:[{id:`running`,cardinality:`scalar`,deviceTypes:[T.Washer,T.Dryer,T.Dishwasher,T.Vacuum,T.LawnMower,T.MediaPlayer,T.WaterHeater,T.Humidifier,T.Fan,T.Climate,T.PetFeeder],apply:`add`,vocabularyCap:`running-state`,vocabularyStateField:`running`,sources:[{kind:`switch`,transformKinds:[`identity`],transforms:[{kind:`identity`}]},{kind:`binary`,transformKinds:[`identity`,`invert`],transforms:[{kind:`identity`},{kind:`invert`}]},{kind:`numeric`,requiredUnit:`W`,transformKinds:[`threshold`],transforms:[{kind:`threshold`,comparisons:[`gte`,`lte`],comparison:`gte`,defaultThreshold:5,defaultStartDwellMs:3e4,defaultStopDwellMs:18e4,deviceTypeDefaults:{[T.MediaPlayer]:{startDwellMs:1e4,stopDwellMs:1e4,minSamples:1}},thresholdUnit:`W`}]}],sourceReport:{status:`assignment-status`,runtimeField:`source`,nativeValue:`native`,assignedValue:`assigned`},advancedExpression:!0,path:`running`,valueKind:`boolean`,nullable:!0,companions:[{kind:`constant`,path:`source`,value:`assigned`,when:`always`},{kind:`constant`,path:`phase`,value:null,when:`add`},{kind:`clock`,path:`lastFetchedAt`,when:`always`},{kind:`transition-time`,path:`since`,sourceChangedAt:`prefer`}]}],overridable:[{path:`running`,by:`running`}]},"weather-station":{version:1,targets:[{id:`temperature`,cardinality:`scalar`,deviceTypes:[T.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`temperature`,sources:[{kind:`numeric`,requiredUnit:`°C`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`temperature`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`humidity`,cardinality:`scalar`,deviceTypes:[T.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`humidity`,sources:[{kind:`numeric`,requiredUnit:`%`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`humidity`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`pressure`,cardinality:`scalar`,deviceTypes:[T.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`pressure`,sources:[{kind:`numeric`,requiredUnit:`hPa`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`pressure`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`windSpeed`,cardinality:`scalar`,deviceTypes:[T.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`windSpeed`,sources:[{kind:`numeric`,requiredUnit:`m/s`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`windSpeed`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`windGust`,cardinality:`scalar`,deviceTypes:[T.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`windGust`,sources:[{kind:`numeric`,requiredUnit:`m/s`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`windGust`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`windBearing`,cardinality:`scalar`,deviceTypes:[T.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`windBearing`,sources:[{kind:`numeric`,requiredUnit:`°`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`windBearing`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`rainRate`,cardinality:`scalar`,deviceTypes:[T.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`rainRate`,sources:[{kind:`numeric`,requiredUnit:`mm/h`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`rainRate`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`rainDaily`,cardinality:`scalar`,deviceTypes:[T.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`rainDaily`,sources:[{kind:`numeric`,requiredUnit:`mm`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`rainDaily`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`rainEvent`,cardinality:`scalar`,deviceTypes:[T.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`rainEvent`,sources:[{kind:`numeric`,requiredUnit:`mm`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`rainEvent`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`uv`,cardinality:`scalar`,deviceTypes:[T.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`uv`,sources:[{kind:`numeric`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`uv`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`solarRadiation`,cardinality:`scalar`,deviceTypes:[T.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`solarRadiation`,sources:[{kind:`numeric`,requiredUnit:`W/m²`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`solarRadiation`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`dewPoint`,cardinality:`scalar`,deviceTypes:[T.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`dewPoint`,sources:[{kind:`numeric`,requiredUnit:`°C`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`dewPoint`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`feelsLike`,cardinality:`scalar`,deviceTypes:[T.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`feelsLike`,sources:[{kind:`numeric`,requiredUnit:`°C`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`feelsLike`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`vpd`,cardinality:`scalar`,deviceTypes:[T.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`vpd`,sources:[{kind:`numeric`,requiredUnit:`kPa`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`vpd`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`windGustMax`,cardinality:`scalar`,deviceTypes:[T.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`windGustMax`,sources:[{kind:`numeric`,requiredUnit:`m/s`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`windGustMax`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`windBearingAvg`,cardinality:`scalar`,deviceTypes:[T.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`windBearingAvg`,sources:[{kind:`numeric`,requiredUnit:`°`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`windBearingAvg`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`rain24h`,cardinality:`scalar`,deviceTypes:[T.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`rain24h`,sources:[{kind:`numeric`,requiredUnit:`mm`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`rain24h`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`rainWeekly`,cardinality:`scalar`,deviceTypes:[T.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`rainWeekly`,sources:[{kind:`numeric`,requiredUnit:`mm`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`rainWeekly`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`rainMonthly`,cardinality:`scalar`,deviceTypes:[T.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`rainMonthly`,sources:[{kind:`numeric`,requiredUnit:`mm`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`rainMonthly`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`rainYearly`,cardinality:`scalar`,deviceTypes:[T.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`rainYearly`,sources:[{kind:`numeric`,requiredUnit:`mm`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`rainYearly`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]}],overridable:[{path:`temperature`,by:`temperature`},{path:`humidity`,by:`humidity`},{path:`pressure`,by:`pressure`},{path:`windSpeed`,by:`windSpeed`},{path:`windGust`,by:`windGust`},{path:`windBearing`,by:`windBearing`},{path:`rainRate`,by:`rainRate`},{path:`rainDaily`,by:`rainDaily`},{path:`rainEvent`,by:`rainEvent`},{path:`uv`,by:`uv`},{path:`solarRadiation`,by:`solarRadiation`},{path:`dewPoint`,by:`dewPoint`},{path:`feelsLike`,by:`feelsLike`},{path:`vpd`,by:`vpd`},{path:`windGustMax`,by:`windGustMax`},{path:`windBearingAvg`,by:`windBearingAvg`},{path:`rain24h`,by:`rain24h`},{path:`rainWeekly`,by:`rainWeekly`},{path:`rainMonthly`,by:`rainMonthly`},{path:`rainYearly`,by:`rainYearly`}]}},SD={"ambient-light-sensor":{illuminance:`lx`},battery:{level:`%`,voltage:`V`},"humidity-sensor":{humidity:`%`},"power-meter":{power:`W`,deliveredPower:`W`,energy:`kWh`,voltage:`V`,current:`A`},"temperature-sensor":{temperature:`°C`}};function V(e,t,n){return{code:e,path:t,message:n}}function CD(...e){return{problems:e,fields:[],features:[],events:[]}}function wD(e){let t=e.item===void 0?`fields`:`items.${e.item.key}.fields`;return`features[${e.featureIndex}].${t}.${e.path}`}var TD={kind:`fixed`,result:[`number`]},ED={kind:`fixed`,result:[`boolean`]},DD=Object.freeze({min:TD,max:TD,abs:TD,floor:TD,ceil:TD,sqrt:TD,round:TD,pow:TD,clamp:TD,avg:TD,sum:TD,age:TD,convert:TD,coalesce:{kind:`coalesce`},any:ED,all:ED,within:ED,latest:{kind:`fixed`,result:[`number`,`null`]},number:{kind:`fixed`,result:[`number`,`null`]},rose:{kind:`fixed`,result:[`number`,`null`]},count:TD,dwell:{kind:`fixed`,result:[`boolean`,`null`]},latchedAt:{kind:`fixed`,result:[`number`,`null`]},schmitt:{kind:`fixed`,result:[`boolean`,`null`]}}),OD=class extends Error{};function kD(e){return e===null?`null`:typeof e==`number`?`number`:typeof e==`string`?`string`:`boolean`}function AD(e){return new Set([e])}function jD(...e){return new Set(e.flatMap(e=>[...e]))}function abe(e){return new Set([...e].filter(e=>e!==`null`))}function obe(e,t,n){if(e===`+`){let e=[...t,...n];return e.every(e=>e===`string`)?AD(`string`):e.every(e=>e===`number`)?AD(`number`):new Set([`number`,`string`])}return AD(e===`-`||e===`*`||e===`/`||e===`%`?`number`:`boolean`)}function sbe(e){return e.minArgs===e.maxArgs?`exactly ${e.minArgs}`:e.maxArgs===1/0?`at least ${e.minArgs}`:`${e.minArgs}–${e.maxArgs}`}function cbe(e,t){let n=gs[e];if(n!==void 0&&(t.length<n.minArgs||t.length>n.maxArgs))throw new OD(`${e}: wrong number of arguments (${t.length}); expected ${sbe(n)}`);let r=DD[e];if(r===void 0)throw new OD(`no result-kind rule for builtin '${e}'`);if(r.kind===`fixed`)return new Set(r.result);let i=jD(...t.map(abe));return t.every(e=>e.has(`null`))?jD(i,AD(`null`)):i}function MD(e,t){switch(e.kind){case`literal`:return AD(kD(e.value));case`identifier`:{if(e.name===`now`)return AD(`number`);let n=t.get(e.name);if(n===void 0)throw new OD(`unbound identifier '${e.name}'`);return n}case`unary`:return AD(e.op===`!`?`boolean`:`number`);case`binary`:return obe(e.op,MD(e.left,t),MD(e.right,t));case`logical`:return jD(MD(e.left,t),MD(e.right,t));case`conditional`:return jD(MD(e.consequent,t),MD(e.alternate,t));case`call`:return cbe(e.callee,e.args.map(e=>MD(e,t)))}}function ND(e,t){switch(e.kind){case`literal`:case`identifier`:return!1;case`unary`:return ND(e.operand,t);case`binary`:case`logical`:return ND(e.left,t)||ND(e.right,t);case`conditional`:return ND(e.test,t)||ND(e.consequent,t)||ND(e.alternate,t);case`call`:return e.callee===t||e.args.some(e=>ND(e,t))}}function PD(e,t){let n=Ds(e);return n.ok&&ND(n.parsed.ast,t)}function FD(e){let t=Ds(e.expr);if(!t.ok)return{ok:!1,error:t.error};try{return{ok:!0,kinds:MD(t.parsed.ast,e.bindingKinds)}}catch(e){if(e instanceof OD)return{ok:!1,error:e.message};throw e}}function lbe(e){return e.publish===`value`&&e.empty===`null`?{ok:!0,kinds:new Set([`number`,`null`])}:{ok:!0,kinds:new Set([`number`])}}function ube(e){return e.publish===`value`?e.reducer===`any`||e.reducer===`all`?{ok:!0,kinds:new Set([`boolean`])}:e.empty===`null`?{ok:!0,kinds:new Set([`number`,`null`])}:{ok:!0,kinds:new Set([`number`])}:{ok:!0,kinds:new Set([`number`])}}function ID(e,t){let n=t(e.cap),r=n?.runtimeState??n?.status?.schema;if(n===null||r===void 0)return{ok:!1,code:`source-field-unknown`,message:`no capability \`${e.cap}\` with state to read`};let i=LT(r,e.fieldPath);if(i===null)return{ok:!1,code:`source-field-unknown`,message:`\`${e.cap}\` has no field \`${e.fieldPath}\``};let a=i.kind===`union`?i.unionMembers??[]:[i.kind===`enum`?`string`:i.kind];return{ok:!0,kinds:new Set(i.nullable?[...a,`null`]:a)}}function LD(e,t,n){return V(`kind-mismatch`,n,`\`${e}.${t}\` is a union — it is read as a source, never written`)}function RD(e){return e.kind===`union`?null:e.kind===`enum`?`string`:e.kind}function zD(e,t,n,r){if(e.kind!==`from`)return n;let i=r(e.cap),a=i?.runtimeState??i?.status?.schema;if(a===void 0)return n;let o=LT(a,e.fieldPath),s=RD(t);return o?.kind!==`union`||s===null||!n.has(s)?n:new Set(n.has(`null`)?[s,`null`]:[s])}function BD(e,t){if(e.kind===`from`)return ID(e,t);if(e.kind===`code`)return{ok:!1,code:`reserved-variant`,message:`code fields arrive in slice 4`};if(e.kind===`aggregate`)return ube(e);if(e.kind===`series`)return lbe(e);let n=new Map;for(let[r,i]of Object.entries(e.bindings)){if(i.kind===`literal`){n.set(r,new Set([kD(i.value)]));continue}let e=ID(i,t);if(!e.ok)return{...e,message:`binding \`${r}\`: ${e.message}`};n.set(r,e.kinds)}let r=FD({expr:e.expr,bindingKinds:n});return r.ok?{ok:!0,kinds:r.kinds}:{ok:!1,code:`expression-invalid`,message:r.error}}function VD(e,t,n,r){let i=RD(t);if(i===null)return[LD(e,t.path,r)];let a=[...n].filter(e=>e!==`null`&&e!==i),o=[];return a.length>0&&o.push(V(`kind-mismatch`,r,`\`${e}.${t.path}\` is a ${t.kind}; this source can produce ${a.join(` or `)}`)),n.has(`null`)&&!t.nullable&&o.push(V(`may-be-null`,r,`\`${e}.${t.path}\` cannot be null and this source can produce null — wrap it in coalesce(…) or pick a non-null source`)),o}function dbe(e){if(e.kind!==`expression`)return null;let t=Ds(e.expr);if(!t.ok)return null;let n=t.parsed.ast;return n.kind===`literal`&&typeof n.value==`string`?n.value:null}function HD(e,t,n,r){if(t.kind!==`enum`||t.enumValues===void 0)return null;let i=dbe(n);if(i===null||t.enumValues.includes(i))return null;let a=t.enumValues.map(e=>`\`${e}\``).join(`, `);return V(`kind-mismatch`,r,`\`${e}.${t.path}\` accepts only ${a}; this source is the literal \`${i}\``)}function UD(e){if(e.kind!==`expression`)return`derived`;if(PD(e.expr,`count`))return`accumulator`;if(Ml(e).length>0)return`derived`;let t=Ds(e.expr);return t.ok&&t.parsed.identifiers.has(`now`)?`clock`:`constant`}function WD(e,t,n,r,i){return n===`replace`&&(t===`derived`||t===`accumulator`)?{ok:!0,unavailable:`release`}:n===`new`||t!==`derived`?{ok:!0,unavailable:e.nullable?`null`:`offline`}:e.nullable?{ok:!0,unavailable:`null`}:e.enumValues?.includes(`unknown`)===!0?{ok:!0,unavailable:`unknown`}:e.required?{ok:!1,problem:V(`not-replaceable`,i,`\`${r}.${e.path}\` reads a source but can say neither null nor 'unknown', and an ADDED capability has no native reading to fall back to`)}:{ok:!0,unavailable:`omit`}}var GD={resettable:!1};function fbe(e){return new Set([e.keyField,...e.labelField===void 0?[]:[e.labelField],...Object.keys(GD)])}function pbe(e,t,n){let r=LT(e.itemSchema,t);return r===null||!r.required?!1:BT(e.itemSchema,t).every(e=>n.some(t=>t.startsWith(`${e}.`)))}function mbe({capName:e,itemArray:t,reserved:n},r,i){let a=Object.keys(r.fields);return Jg(t.itemSchema).flatMap(o=>{if(n.has(o.path)||o.path in r.fields||!pbe(t,o.path,a))return[];let s=LT(t.itemSchema,o.path);return s===null||s.nullable?[]:[V(`missing-field`,`${i}.fields.${o.path}`,`\`${e}.${t.path}[].${o.path}\` is required and has no source`)]})}function hbe(e,t){let{capName:n,itemArray:r,featureIndex:i,lookupCap:a}=e,{key:o,label:s,path:c,source:l}=t,u=`features[${i}].items.${o}.fields.${c}`;if(e.reserved.has(c))return CD(V(`item-field-reserved`,u,`\`${n}.${r.path}[].${c}\` is set by the composer itself — it takes no source`));let d=LT(r.itemSchema,c);if(d===null)return CD(V(`unknown-field`,u,`a \`${n}\` item has no field \`${c}\``));if(d.kind===`union`)return CD(LD(n,c,u));let f=BD(l,a);if(!f.ok)return CD(V(f.code,u,f.message));let p=UD(l),m=WD(d,p,e.mode,n,u);if(!m.ok)return CD(m.problem);let h={cap:n,path:c,item:{arrayPath:r.path,key:o,label:s,...t.resettable?{resettable:!0}:{}},featureIndex:i,kind:d.kind,nullable:d.nullable,required:d.required,unavailable:m.unavailable,role:p,source:l,reads:[...Ml(l)]},g=HD(n,d,l,u);return{problems:[...VD(n,d,zD(l,d,f.kinds,a),u),...g===null?[]:[g]],fields:[h],features:[],events:[]}}function KD(e,t,n,r,i=`new`){let a=`features[${n}].items`,o=e.status?.itemArray;if(o===void 0)return CD(V(`not-item-array`,a,`\`${e.name}\` has no item array — it takes no \`items\``));if(o.path!==`items`)return CD(V(`not-item-array`,a,`\`${e.name}\`'s item array is at \`${o.path}\`, not \`${hl}\` — not composable yet`));let s={capName:e.name,itemArray:o,reserved:fbe(o),featureIndex:n,lookupCap:r,mode:i},c=Object.entries(t.items??{}).flatMap(([e,t])=>[{problems:mbe(s,t,`${a}.${e}`),fields:[],features:[],events:[]},...Object.entries(t.fields).map(([n,r])=>hbe(s,{key:e,label:t.label,resettable:t.reset!==void 0,path:n,source:r}))]);return{problems:c.flatMap(e=>e.problems),fields:c.flatMap(e=>e.fields),features:[],events:[]}}var qD=`deviceId`;function JD(e,t){let n=`features[${t}]`,r=Object.entries(e.commands??{}).flatMap(([e,t])=>t.kind===`forward`?[{at:`${n}.commands.${e}`,method:e,command:t}]:[]),i=Object.entries(e.items??{}).flatMap(([e,t])=>t.reset===void 0?[]:[{at:`${n}.items.${e}.reset`,method:`reset`,itemKey:e,command:t.reset}]);return[...r,...i]}function YD(e){let t=e.features.flatMap((e,t)=>e.kind===`fields`&&xl(e)?JD(e,t).map(e=>e.command.source):[]);return[...new Map(t.map(e=>[Dl(e),e])).values()]}function gbe(e,t){return e.name===`switch`&&t===`toggle`}function XD(e){return Object.entries(e.methods).filter(([t,n])=>n.systemOnly!==!0&&e.composedMethods?.[t]===void 0&&!gbe(e,t)).map(([e])=>e)}function _be(){return Object.fromEntries(XD(bD).map(e=>[e,{kind:`extension`,target:`remote`}]))}var ZD={all:new Set,required:new Set};function QD(e,t){let n=e.methods[t]?.input;if(n===void 0)return null;let r=qg(n);if(!(r instanceof le))return null;let i=Object.entries(r.shape).filter(([e])=>e!==qD);return{all:new Set(i.map(([e])=>e)),required:new Set(i.flatMap(([e,t])=>t instanceof ae&&!t.safeParse(void 0).success?[e]:[]))}}function $D(e){return typeof e==`object`?ul(e)?[e.$input]:Object.values(e).flatMap($D):[]}function eO(e){return[...e].map(e=>`\`${e}\``).join(`, `)}function vbe(e,t){let{command:n,at:r}=e,i=t(n.cap);if(i===null)return{def:null,problems:[V(`command-source-unknown`,`${r}.cap`,`no capability is named \`${n.cap}\``)]};let a=i.methods[n.method];return a===void 0||a.systemOnly===!0?{def:null,problems:[V(`command-source-unknown`,`${r}.method`,`\`${n.cap}\` has no method \`${n.method}\` to forward to`)]}:a.kind===`mutation`?{def:i,problems:[]}:{def:null,problems:[V(`command-source-unknown`,`${r}.method`,`\`${n.cap}.${n.method}\` is a query — a command calls a mutation of the source`)]}}function ybe(e,t,n,r){let{at:i,command:a}=e,o=`${a.cap}.${a.method}`,s=[];if(`deviceId`in r&&s.push(V(`command-input-unknown`,`${i}.args.${qD}`,`\`${qD}\` is the source device's own — a forward never takes it as an argument`)),n!==null){for(let e of Object.keys(r).filter(e=>e!==`deviceId`&&!n.all.has(e)))s.push(V(`command-input-unknown`,`${i}.args.${e}`,`\`${o}\` has no input field \`${e}\` (it takes ${eO(n.all)})`));let e=[...n.required].filter(e=>!(e in r));e.length>0&&s.push(V(`command-input-missing`,`${i}.args`,`\`${o}\` needs ${eO(e)}, which \`args\` does not provide`))}let c=e.itemKey===void 0?t:ZD;if(c!==null)for(let t of Object.values(r).flatMap($D))c.all.has(t)||s.push(V(`command-input-unknown`,`${i}.args`,c===ZD?`an item's \`reset\` takes no input — \`$input: ${t}\` has nothing to read`:`\`$input: ${t}\` is not a field of the \`${e.method}\` input (it takes ${eO(c.all)})`));return s}function bbe(e,t,n){let{at:r,command:i}=e,a=`${i.cap}.${i.method}`,o=e.itemKey===void 0?t:ZD;if(o===null||n===null)return[];let s=[];for(let t of[...o.all].filter(e=>!n.all.has(e)))s.push(V(`command-input-unknown`,`${r}.args`,`\`${e.method}\` takes \`${t}\`, which \`${a}\` does not (it takes ${eO(n.all)}) — add \`args\` to map it`));let c=[...n.required].filter(e=>!o.all.has(e));return c.length>0&&s.push(V(`command-input-missing`,`${r}.args`,`\`${a}\` needs ${eO(c)}, which \`${e.method}\` does not take — add \`args\` to provide it`)),s}function tO(e,t,n){let r=vbe(t,n);if(r.def===null)return r.problems;let i=QD(e,t.method),a=QD(r.def,t.command.method),o=t.command.args;return o===void 0?bbe(t,i,a):ybe(t,i,a,o)}function nO(e,t,n){let r=new Set(XD(e));return Object.keys(t.commands??{}).flatMap(t=>{if(r.has(t))return[];let i=e.composedMethods?.[t]!==void 0;return[V(`command-method-unknown`,`${n}.commands.${t}`,i?`\`${e.name}.${t}\` is answered by the composer itself — an item's \`reset\` serves it`:`\`${e.name}\` has no method \`${t}\` to serve`)]})}function rO(e,t){return e.features.flatMap((e,n)=>e.kind!==`fields`||!xl(e)?[]:JD(e,n).flatMap(e=>{let n=Dl(e.command.source),r=t.get(n),i=`${e.at}.source`;return r===void 0||r.kind===`unreadable`?[V(`source-unreadable`,i,`could not read source \`${n}\` (${r===void 0?`it was not read`:r.error}) — the save is refused rather than stored unchecked`)]:r.kind===`absent`?[V(`source-missing`,i,`source \`${n}\` does not exist`)]:r.caps.has(e.command.cap)?[]:[V(`source-capability-missing`,i,`source \`${n}\` (device ${r.deviceId}) has no \`${e.command.cap}\``)]}))}var iO={fieldPath:`lastFetchedAt`,expr:`now`},aO={fieldPath:`lastChangedAt`,expr:`now`};function oO(e){let{alsoFrom:t,...n}=e;return{...n,family:`numeric`,deviceType:T.Sensor,memberDeviceType:T.Sensor,memberDeviceTypes:[T.Sensor,...t?.deviceTypes??[]],activeWhen:void 0,commandCaps:[],baseUnit:ma(e.quantity),aggregates:wc,accept:[{cap:e.outputCap,fieldPath:e.outputField},...t===void 0?[]:[t.accept]]}}var sO=[T.Climate];function cO(e){return{...e,family:`binary`,deviceType:T.Sensor,memberDeviceType:T.Sensor,memberDeviceTypes:[T.Sensor],activeWhen:void 0,commandCaps:[],quantity:`none`,baseUnit:void 0,aggregates:Tc,empty:`offline`}}var lO=[oO({id:`temperature`,summary:`Mean, median, min, max or sum of temperatures. Offline and unknown members are left out, never read as 0 °C.`,role:D.TemperatureSensor,outputCap:`temperature-sensor`,outputField:`temperature`,quantity:`temperature`,defaultAggregate:`mean`,empty:`null`,companions:[iO],alsoFrom:{deviceTypes:sO,accept:{cap:`climate-control`,fieldPath:`currentTemp`}}}),oO({id:`humidity`,summary:`Humidity in percent. Offline and unknown members are left out, never read as 0 %.`,role:D.HumiditySensor,outputCap:`humidity-sensor`,outputField:`humidity`,quantity:`humidity`,defaultAggregate:`mean`,empty:`null`,companions:[iO],alsoFrom:{deviceTypes:sO,accept:{cap:`climate-control`,fieldPath:`currentHumidity`}}}),oO({id:`pressure`,summary:`Pressure in hectopascals. Offline and unknown members are left out, never read as 0 hPa.`,role:D.PressureSensor,outputCap:`pressure-sensor`,outputField:`pressure`,quantity:`pressure`,defaultAggregate:`mean`,empty:`null`,companions:[iO]}),oO({id:`illuminance`,summary:`Illuminance in lux. Offline and unknown members are left out, never read as 0 lx.`,role:D.AmbientLightSensor,outputCap:`ambient-light-sensor`,outputField:`illuminance`,quantity:`illuminance`,defaultAggregate:`mean`,empty:`null`,companions:[iO]}),oO({id:`power`,summary:`Power in watts, summed by default. Nobody reporting omits the key rather than writing 0 W.`,role:D.PowerSensor,outputCap:`power-meter`,outputField:`power`,quantity:`power`,defaultAggregate:`sum`,empty:`omit`,companions:[iO]}),oO({id:`energy`,summary:`Energy in kilowatt-hours, summed by default. Nobody reporting omits the key rather than writing 0 kWh.`,role:D.EnergySensor,outputCap:`power-meter`,outputField:`energy`,quantity:`energy`,defaultAggregate:`sum`,empty:`omit`,companions:[iO]}),oO({id:`battery`,summary:`Battery charge in percent. Offline and unknown members are left out, never read as 0 %.`,role:D.BatterySensor,outputCap:`battery`,outputField:`level`,quantity:`percentage`,defaultAggregate:`mean`,empty:`null`,companions:[{fieldPath:`charging`,expr:`"unknown"`},{fieldPath:`sleeping`,expr:`false`},{fieldPath:`lastUpdated`,expr:`now`}]}),oO({id:`numeric`,summary:`A numeric reading in the members’ shared quantity. Mixed quantities are refused. Nobody reporting publishes null, not 0.`,role:D.NumericSensor,outputCap:`numeric-sensor`,outputField:`value`,quantity:`device`,defaultAggregate:`mean`,empty:`null`,companions:[iO]}),cO({id:`motion`,summary:`Any or all motion. Offline and unknown members are left out, never read as off. Nobody reporting takes the device offline.`,role:D.MotionSensor,outputCap:`motion`,outputField:`detected`,defaultAggregate:`any`,accept:[{cap:`motion`,fieldPath:`detected`}],companions:[{fieldPath:`lastDetectedAt`,expr:`null`},{fieldPath:`autoClearAfterMs`,expr:`null`}]}),cO({id:`contact`,summary:`Any or all open contacts. Offline and unknown members are left out, never read as closed.`,role:D.ContactSensor,outputCap:`contact`,outputField:`entryOpen`,defaultAggregate:`any`,accept:[{cap:`contact`,fieldPath:`entryOpen`}],companions:[aO]}),cO({id:`leak`,summary:`Any or all leak detections. Offline and unknown members are left out, never read as dry.`,role:D.LeakSensor,outputCap:`flood`,outputField:`flooded`,defaultAggregate:`any`,accept:[{cap:`flood`,fieldPath:`flooded`}],companions:[aO]}),cO({id:`smoke`,summary:`Any or all smoke detections. Offline and unknown members are left out, never read as clear.`,role:D.SmokeSensor,outputCap:`smoke`,outputField:`detected`,defaultAggregate:`any`,accept:[{cap:`smoke`,fieldPath:`detected`}],companions:[aO]}),cO({id:`occupancy`,summary:`Any or all of motion or binary sensors, published as a binary. Presence zones are not aggregated. Nobody reporting is offline, not off.`,role:D.BinarySensor,outputCap:`binary`,outputField:`on`,defaultAggregate:`any`,accept:[{cap:`motion`,fieldPath:`detected`},{cap:`binary`,fieldPath:`on`}],companions:[aO]}),cO({id:`binary`,summary:`Any or all generic binary sensors. Offline and unknown members are left out, never read as off.`,role:D.BinarySensor,outputCap:`binary`,outputField:`on`,defaultAggregate:`any`,accept:[{cap:`binary`,fieldPath:`on`}],companions:[aO]}),uO({id:`switch`,summary:`On when at least one switch is on, or when all of them are. Offline and unknown members are left out of that decision, never read as off, and still receive the command.`,deviceType:T.Switch,outputCap:`switch`,outputField:`on`,member:{cap:`switch`,fieldPath:`on`},commandCaps:[`switch`]}),uO({id:`light`,summary:`On when at least one light is on, or when all of them are. Brightness and colour are offered only when every member has them. A command is not sent to a member that lacks it.`,deviceType:T.Light,outputCap:`switch`,outputField:`on`,member:{cap:`switch`,fieldPath:`on`},commandCaps:[`switch`,`brightness`,`color`]}),uO({id:`fan`,summary:`On when at least one fan is on, or when all of them are. Speed, preset, direction and oscillation are offered only when every fan has them. A command is not sent to a fan that lacks it.`,deviceType:T.Fan,outputCap:`switch`,outputField:`on`,member:{cap:`switch`,fieldPath:`on`},commandCaps:[`switch`,`fan-control`]}),uO({id:`cover`,summary:`Open when at least one cover is open or part-open, or only when all of them are. Position and tilt are offered only when every cover has them. A cover that reports nothing is left out, never read as closed.`,deviceType:T.Cover,outputCap:`group-active`,outputField:`active`,member:{cap:`cover`,fieldPath:`state`},activeWhen:[`open`,`opening`,`stopped`],commandCaps:[`cover`]}),uO({id:`valve`,summary:`Open when at least one valve is open or part-open, or only when all of them are. Position is offered only when every valve has it. A valve that reports nothing is left out, never read as closed.`,deviceType:T.Valve,outputCap:`group-active`,outputField:`active`,member:{cap:`valve`,fieldPath:`state`},activeWhen:[`open`,`opening`,`stopped`],commandCaps:[`valve`]}),uO({id:`lock`,summary:`Locked when at least one lock is locked, or only when all of them are. A jammed or moving lock is not locked. Locking is one tap; unlocking the group needs a confirmation every time, and nothing is sent without it.`,deviceType:T.Lock,outputCap:`group-active`,outputField:`active`,member:{cap:`lock-control`,fieldPath:`state`},activeWhen:[`locked`],commandCaps:[`lock-control`]}),uO({id:`media-player`,summary:`Playing when at least one player is playing, or only when all of them are. Volume is offered only when every player has it. A player that reports nothing is left out, never read as stopped.`,deviceType:T.MediaPlayer,outputCap:`group-active`,outputField:`active`,member:{cap:`media-player`,fieldPath:`state`},activeWhen:[`playing`,`buffering`],commandCaps:[`media-player`]}),uO({id:`climate`,summary:`Running when at least one thermostat or air conditioner is not off, or only when all of them are. Target temperature and fan are offered only when every device has them. A device that reports nothing is left out, never read as off.`,deviceType:T.Climate,memberDeviceTypes:[T.Climate],outputCap:`group-active`,outputField:`active`,member:{cap:`climate-control`,fieldPath:`mode`},activeWhen:[`heat`,`cool`,`auto`,`heat_cool`,`fan_only`,`dry`],commandCaps:[`climate-control`]})];function uO(e){return{id:e.id,summary:e.summary,deviceType:e.deviceType,outputCap:e.outputCap,outputField:e.outputField,commandCaps:e.commandCaps,family:`actuator`,role:void 0,memberDeviceType:e.deviceType,memberDeviceTypes:e.memberDeviceTypes??[e.deviceType],activeWhen:e.activeWhen,quantity:`none`,baseUnit:void 0,aggregates:Tc,defaultAggregate:`any`,empty:`offline`,accept:[e.member],companions:[aO]}}var xbe=new Map(lO.map(e=>[e.id,e]));function dO(e){return xbe.get(e)??null}var fO={"air-quality-sensor":{co2:{kind:`gauge`,unit:`ppm`,deadband:5},voc:{kind:`gauge`,unit:`ppb`,deadband:5},pm25:{group:`particulates`,kind:`gauge`,unit:`µg/m³`,deadband:1},pm10:{group:`particulates`,kind:`gauge`,unit:`µg/m³`,deadband:1},aqi:{kind:`gauge`,unit:`count`,deadband:1}},"alarm-panel":{state:{kind:`enum`,values:[`disarmed`,`armed_home`,`armed_away`,`armed_night`,`armed_vacation`,`armed_custom_bypass`,`arming`,`disarming`,`pending`,`triggered`]}},"ambient-light-sensor":{illuminance:{kind:`gauge`,unit:`lx`,deadbandPct:10,minIntervalMs:6e4}},battery:{level:{kind:`gauge`,unit:`%`},voltage:{kind:`gauge`,unit:`V`}},binary:{on:{kind:`boolean`}},brightness:{level:{kind:`gauge`,unit:`%`,minIntervalMs:0}},"carbon-monoxide":{detected:{kind:`boolean`}},"climate-control":{currentTemp:{group:`temperature`,kind:`gauge`,unit:`°C`,deadband:.1},currentHumidity:{kind:`gauge`,unit:`%`,deadband:.5},target:{group:`temperature`,kind:`gauge`,unit:`°C`,minIntervalMs:0},targetHigh:{group:`target-range`,kind:`gauge`,unit:`°C`,minIntervalMs:0},targetLow:{group:`target-range`,kind:`gauge`,unit:`°C`,minIntervalMs:0}},connectivity:{connected:{kind:`boolean`}},contact:{entryOpen:{kind:`boolean`}},cover:{position:{kind:`gauge`,unit:`%`,minIntervalMs:0}},"device-status":{online:{kind:`boolean`}},dishwasher:{progress:{kind:`gauge`,unit:`%`,deadband:2},state:{kind:`enum`,values:[`idle`,`running`,`paused`,`finished`,`error`,`unavailable`]},operationState:{kind:`enum`,values:[`Inactive`,`Ready`,`DelayedStart`,`Run`,`Pause`,`ActionRequired`,`Finished`,`Error`,`Aborting`]},remaining:{kind:`gauge`,unit:`s`,minIntervalMs:6e4},doorOpen:{kind:`boolean`},powerOn:{kind:`boolean`}},"do-not-disturb":{enabled:{kind:`boolean`}},"energy-system":{"solar.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Solar power`},"solar.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`Solar energy`},"grid.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Grid power`},"grid.importKwh":{kind:`counter`,unit:`kWh`,displayName:`Grid import`},"grid.exportKwh":{kind:`counter`,unit:`kWh`,displayName:`Grid export`},"house.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`House power`},"house.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`House energy`},"heatPump.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Heat pump power`},"heatPump.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`Heat pump energy`},"storage.stateOfChargePct":{kind:`gauge`,unit:`%`,deadband:1,displayName:`Storage charge`},"storage.storedKwh":{kind:`gauge`,unit:`kWh`,deadband:.05,displayName:`Stored energy`},"storage.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Storage power`},"storage.chargedKwh":{kind:`counter`,unit:`kWh`,displayName:`Storage charged`},"storage.dischargedKwh":{kind:`counter`,unit:`kWh`,displayName:`Storage discharged`},"storage.healthPct":{kind:`gauge`,unit:`%`,deadband:1,displayName:`Storage health`}},"enum-sensor":{value:{kind:`enum`,skipWhenSet:`timestamp`}},"fan-control":{speed:{kind:`gauge`,unit:`%`,minIntervalMs:0},oscillating:{kind:`boolean`}},flood:{flooded:{kind:`boolean`}},gas:{detected:{kind:`boolean`}},"heat-pump-status":{"power.thermalW":{group:`power`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Thermal power`},"power.electricalW":{group:`power`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Electrical power`},"power.compressorPct":{kind:`gauge`,unit:`%`,deadband:2,displayName:`Compressor`},"temperatures.supply":{group:`loop`,kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Supply`},"temperatures.return":{group:`loop`,kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Return`},"temperatures.outdoor":{kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Outdoor`},"energy.thermalKwh":{kind:`counter`,unit:`kWh`,displayName:`Thermal energy`},"energy.electricalKwh":{kind:`counter`,unit:`kWh`,displayName:`Electrical energy`}},"heating-valve":{position:{kind:`gauge`,unit:`%`,deadband:1}},humidifier:{currentHumidity:{kind:`gauge`,unit:`%`,deadband:.5},on:{kind:`boolean`}},"humidity-sensor":{humidity:{kind:`gauge`,unit:`%`,deadband:.5}},"lawn-mower-control":{batteryLevel:{kind:`gauge`,unit:`%`,deadband:2}},"lock-control":{state:{kind:`enum`,values:[`locked`,`unlocked`,`locking`,`unlocking`,`jammed`,`door-open`]}},"media-player":{volumeLevel:{kind:`gauge`,unit:`%`,deadband:1},isMuted:{kind:`boolean`}},meter:{value:{kind:`counter`,deadband:.001,minIntervalMs:6e4}},motion:{detected:{kind:`boolean`,excludeDeviceTypes:[T.Camera]}},"network-link":{signal:{kind:`gauge`,unit:`%`,deadband:3,minIntervalMs:6e4},rssi:{kind:`gauge`,unit:`dBm`,deadband:2,minIntervalMs:6e4}},"numeric-sensor":{value:{kind:`gauge`,minIntervalMs:3e4}},"pet-feeder":{feeding:{kind:`boolean`},eating:{kind:`boolean`},foodLevel:{kind:`gauge`},bowlFood:{kind:`gauge`},food1:{kind:`gauge`},food2:{kind:`gauge`},batteryPower:{kind:`gauge`,unit:`%`,deadband:2},desiccantLeftDays:{kind:`gauge`,unit:`s`}},"pet-fountain":{waterLevel:{kind:`gauge`,unit:`%`,deadband:1},waterVolume:{kind:`gauge`,unit:`L`}},"power-meter":{power:{kind:`gauge`,unit:`W`,deadband:1,minIntervalMs:3e4},energy:{kind:`counter`,unit:`kWh`,deadband:.01,minIntervalMs:6e4},voltage:{kind:`gauge`,unit:`V`,deadband:1,minIntervalMs:3e4},current:{kind:`gauge`,unit:`A`,deadband:.05,minIntervalMs:3e4},apparentPower:{kind:`gauge`,unit:`VA`,deadband:1,minIntervalMs:3e4},powerFactor:{kind:`gauge`,unit:`ratio`,deadband:.01,minIntervalMs:6e4}},"pressure-sensor":{pressure:{kind:`gauge`,unit:`hPa`,deadband:.1}},"running-state":{running:{kind:`boolean`}},smoke:{detected:{kind:`boolean`}},"stream-params":{"main.bitrate":{group:`bitrate`,kind:`gauge`,unit:`kbps`},"main.framerate":{group:`framerate`,kind:`gauge`,unit:`fps`},"sub.bitrate":{group:`bitrate`,kind:`gauge`,unit:`kbps`},"sub.framerate":{group:`framerate`,kind:`gauge`,unit:`fps`}},switch:{on:{kind:`boolean`}},tamper:{tampered:{kind:`boolean`}},"temperature-sensor":{temperature:{kind:`gauge`,unit:`°C`,deadband:.1}},"vacuum-control":{batteryLevel:{kind:`gauge`,unit:`%`,deadband:2}},valve:{position:{kind:`gauge`,unit:`%`,minIntervalMs:0}},vibration:{detected:{kind:`boolean`}},"water-heater":{currentTemp:{group:`temperature`,kind:`gauge`,unit:`°C`,deadband:.5},targetTemp:{group:`temperature`,kind:`gauge`,unit:`°C`,minIntervalMs:0}},weather:{temperature:{kind:`gauge`,unit:`°C`,deadband:.2},humidity:{kind:`gauge`,unit:`%`,deadband:1},pressure:{kind:`gauge`,unit:`hPa`,deadband:.5},windSpeed:{kind:`gauge`,unit:`m/s`,deadband:.5}},"weather-station":{temperature:{group:`temperature`,kind:`gauge`,unit:`°C`,deadband:.1},humidity:{kind:`gauge`,unit:`%`,deadband:1},pressure:{kind:`gauge`,unit:`hPa`,deadband:.2},windSpeed:{group:`wind-speed`,kind:`gauge`,unit:`m/s`,deadband:.2},windGust:{group:`wind-speed`,kind:`gauge`,unit:`m/s`,deadband:.2},windBearing:{group:`wind-bearing`,kind:`gauge`,unit:`°`,deadband:5},rainRate:{kind:`gauge`,unit:`mm/h`,deadband:.1},rainDaily:{kind:`gauge`,unit:`mm`,deadband:.1},rainEvent:{kind:`gauge`,unit:`mm`,deadband:.1},uv:{kind:`gauge`,unit:`index`,deadband:.1},solarRadiation:{kind:`gauge`,unit:`W/m²`,deadband:5},dewPoint:{group:`temperature`,kind:`gauge`,unit:`°C`,deadband:.1},feelsLike:{group:`temperature`,kind:`gauge`,unit:`°C`,deadband:.1},vpd:{kind:`gauge`,unit:`kPa`,deadband:.05},windGustMax:{group:`wind-speed`,kind:`gauge`,unit:`m/s`,deadband:.2},windBearingAvg:{group:`wind-bearing`,kind:`gauge`,unit:`°`,deadband:5},rain24h:{kind:`gauge`,unit:`mm`,deadband:.1},rainWeekly:{kind:`gauge`,unit:`mm`,deadband:.1},rainMonthly:{kind:`gauge`,unit:`mm`,deadband:.1},rainYearly:{kind:`gauge`,unit:`mm`,deadband:.1}},workload:{state:{kind:`enum`,values:[`running`,`paused`,`stopped`,`starting`,`stopping`,`crashed`]},"resources.cpuPercent":{kind:`gauge`,unit:`%`,deadband:2,displayName:`CPU`},"resources.memoryUsedBytes":{kind:`gauge`,unit:`bytes`,displayName:`Memory used`},"resources.memoryPercent":{kind:`gauge`,unit:`%`,deadband:2,displayName:`Memory`},"resources.netRxKbps":{group:`network`,kind:`gauge`,unit:`kbps`,displayName:`Network received`},"resources.netTxKbps":{group:`network`,kind:`gauge`,unit:`kbps`,displayName:`Network sent`}}},Sbe={consumables:{path:`items`,key:`key`,label:`label`,fields:{level:{kind:`gauge`,unit:`%`,deadband:2,displayName:`Level`},status:{kind:`enum`,displayName:`Status`,values:[`ok`,`low`,`empty`,`full`,`replace`]},"remaining.value":{kind:`gauge`,deadband:1,displayName:`Remaining`}}},"heat-pump-status":{path:`circuits`,key:`id`,label:`label`,fields:{currentTemp:{kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Temperature`},targetTemp:{kind:`gauge`,unit:`°C`,minIntervalMs:0,displayName:`Setpoint`},mode:{kind:`enum`,displayName:`Mode`}}}},pO={"climate-control":{field:`currentTemp`,priority:70},"energy-system":{field:`house.powerW`,priority:50},"humidity-sensor":{field:`humidity`,priority:90},"power-meter":{field:`power`,priority:80},"temperature-sensor":{field:`temperature`,priority:100},"weather-station":{field:`temperature`,priority:60},workload:{field:`resources.cpuPercent`,priority:40}},Cbe=`audio-metrics.automation-control.camera-streams.color.control.day-night.doorbell.error.event-emitter.feature-probe.group-active.group-commands.group-status.image.image-settings.intercom.ir-transmitter.low-power-sleep.motion-trigger.motion-zones.native-object-detection.navigation.notifier.power-source.presence.privacy-mask.ptz-autotrack.pump-cycle.recording-onboard.recording-signal.scene-monitor.script-runner.siren.stream-catalog.stream-signals.timed-run.update.zone-analytics.zone-rules.zones`.split(`.`);function mO(e){return fO[e]??{}}function wbe(e,t,n){return hO(e.deviceTypes,t,n)}function hO(e,t,n){return e.length===0||e.some(e=>e===t)?!0:Jo(t,n)&&e.includes(T.Light)}function Tbe(e){let t=e.family===`numeric`?`number`:e.activeWhen===void 0?`boolean`:`state`;return{fieldChoice:e.family===`numeric`?`first-match`:`operator`,purpose:`member`,multiple:!0,max:64,deviceTypes:[...e.memberDeviceTypes],accept:e.accept.map(e=>({...e,valueKind:t})),history:{required:!1,minRetentionMs:null},mustBindCaps:e.family===`actuator`?e.accept.map(e=>e.cap):[],exclude:[]}}function gO(e){return{fieldChoice:`operator`,purpose:`historised`,multiple:!1,max:1,deviceTypes:[],accept:_O(e),history:{required:!0,minRetentionMs:null},mustBindCaps:[],exclude:[]}}function _O(e){let t=[];for(let n of Object.keys(fO))for(let[r,i]of Object.entries(mO(n)))i.kind!==`enum`&&(e===`integral`&&i.kind!==`gauge`||t.push({cap:n,fieldPath:r,valueKind:i.kind===`boolean`?`boolean`:`number`}));return t}function Ebe(e){if(e===`derivative`)return{...gO(`statistic`),accept:vO()};let t=e===`sum`||e===`expression`,n=e===`difference`||e===`ratio`?2:t?64:1;return{fieldChoice:`operator`,purpose:`reading`,multiple:t||n>1,max:n,deviceTypes:[],accept:vO(),history:{required:!1,minRetentionMs:null},mustBindCaps:[],exclude:[]}}function vO(){return _O(`statistic`).filter(e=>e.valueKind===`number`)}var yO=[`switch`,`brightness`,`color`],Dbe=[E.LightColorRgb,E.LightColorHsv,E.LightColorMired],Obe=4;function bO(e){return e===`all`?`all`:`any`}function kbe(e){return e===`all`?`all`:`at-least-one`}function Abe(e){return e.length===0?[]:yO.filter(t=>e.every(e=>e.includes(t)))}function jbe(e){return e.length===0?[]:Dbe.filter(t=>e.every(e=>e.includes(t)))}function Mbe(e,t,n,r){return e.flatMap(e=>e.caps.includes(t)?[{deviceId:e.deviceId,cap:t,method:n,args:{...r}}]:[])}async function Nbe(e,t){let n=[],r=0,i=async()=>{for(;;){let i=r;r+=1;let a=e[i];if(a===void 0)return;try{await t(a),n[i]={deviceId:a.deviceId,ok:!0}}catch(e){let t=e instanceof Error?e.message:String(e);n[i]={deviceId:a.deviceId,ok:!1,error:t}}}},a=Math.min(4,e.length);return await Promise.all(Array.from({length:a},()=>i())),n}var Pbe={kind:`expression`,expr:`now`,bindings:{}};function xO(e,t,n){return{kind:`series`,read:{source:e.source,cap:e.cap,fieldPath:e.fieldPath},publish:t,empty:n}}function Fbe(e){return{included:xO(e,`included`,`offline`),excluded:xO(e,`excluded`,`offline`),total:xO(e,`total`,`offline`)}}var Ibe={second:`s`,minute:`min`,hour:`h`};function Lbe(e){let t=mO(e.source.cap)[e.source.fieldPath]?.unit;return t===void 0?null:`${t}/${Ibe[e.per]}`}function SO(e){let t=mO(e.cap)[e.fieldPath];return t===void 0?null:t.kind}function CO(e){return SO(e)===null?[V(`member-constraint`,`helper.source`,`${e.cap}.${e.fieldPath} has no history declaration`)]:[]}function wO(e){return{target:{kind:`new`,type:T.Sensor,role:e.role},helper:e.spec,features:[{kind:`fields`,cap:e.cap,fields:{[e.field]:xO(e.member,`value`,e.empty),lastFetchedAt:Pbe}},{kind:`fields`,cap:`group-status`,fields:Fbe(e.member)}]}}function TO(e,t=ic){let n=[...CO(e.source)],r=SO(e.source);r===`enum`&&n.push(V(`kind-mismatch`,`helper.source`,`a statistic reads a number or a boolean, not a state`)),e.stat===`sum`&&r!==`counter`&&n.push(V(`kind-mismatch`,`helper.stat`,`a gauge has no sum — that is the integral template`));let i=bc(e.window,t);return i.ok||n.push(V(`retention`,`helper.window`,i.reason)),{problems:n,draft:wO({role:D.NumericSensor,cap:`numeric-sensor`,field:`value`,empty:`null`,spec:e,member:e.source})}}function EO(e,t=ic){let n=[...CO(e.source)],r=SO(e.source);(r===`enum`||r===`boolean`)&&n.push(V(`kind-mismatch`,`helper.source`,`a derivative reads a number that moves, not a yes/no or a state`));let i=bc(e.window,t);return i.ok||n.push(V(`retention`,`helper.window`,i.reason)),{problems:n,draft:wO({role:D.NumericSensor,cap:`numeric-sensor`,field:`value`,empty:`null`,spec:e,member:e.source})}}function DO(e,t=ic){let n=[...CO(e.source)],r=SO(e.source),i=e.source.cap===`power-meter`&&e.source.fieldPath===`power`;(r===`counter`||r===`boolean`||r===`enum`)&&n.push(V(`kind-mismatch`,`helper.source`,`an integral reads an instantaneous gauge, not a counter or a state`)),e.output===`energy`&&!i&&n.push(V(`kind-mismatch`,`helper.output`,`energy is the integral of power-meter.power; another reading uses the meter`)),e.output===`meter`&&i&&n.push(V(`kind-mismatch`,`helper.output`,`power integrates to power-meter.energy, which energy dashboards already read`));let a=xc(e.reset,t);a.ok||n.push(V(`retention`,`helper.reset`,a.reason));let o=e.output===`energy`;return{problems:n,draft:wO({role:o?D.EnergySensor:D.NumericSensor,cap:o?`power-meter`:`meter`,field:o?`energy`:`value`,empty:`offline`,spec:e,member:e.source})}}var Rbe=/^\d+(?:\.\d+)?$/,zbe=/^-?\d+(?:\.\d+)?$/,Bbe=/^dwell\(x (>=|<=) (\d+(?:\.\d+)?), (\d+(?:\.\d+)?), (\d+(?:\.\d+)?)(?:, (\d+))?\)$/,Vbe=/^clamp\((x|number\(x\)) \* (-?\d+(?:\.\d+)?) \+ (-?\d+(?:\.\d+)?), (-?\d+(?:\.\d+)?), (-?\d+(?:\.\d+)?)\)$/,Hbe=/^(x|number\(x\)) \* (-?\d+(?:\.\d+)?) \+ (-?\d+(?:\.\d+)?)$/,Ube=/^[A-Za-z_][A-Za-z0-9_]*$/;function OO(e){return RO(e,Rbe)}function kO(e){return RO(e,zbe)}function AO(e){return typeof e==`string`?JSON.stringify(e):typeof e==`number`?kO(e):typeof e==`boolean`?e?`true`:`false`:`null`}function jO(e,t){let n=t.map(e=>`native == ${JSON.stringify(e)}`).join(` || `),r=`(x ? ${JSON.stringify(e)} : native)`;return n===``?r.slice(1,-1):`${n} ? native : ${r}`}function MO(e){return Ube.test(e)}function NO(e,t,n,r,i=1){return`dwell(x ${e===`gte`?`>=`:`<=`} ${t}, ${n}, ${r}${i>1?`, ${i}`:``})`}function PO(e,t,n,r,i){let a=`${e} * ${t} + ${n}`;return r===null||i===null?a:`clamp(${a}, ${r}, ${i})`}function FO(e){let t=Bbe.exec(e);if(t===null)return null;let n=Number(t[2]),r=Number(t[3]),i=Number(t[4]);if(!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(i))return null;let a=t[1]===`<=`?`lte`:`gte`,o=t[5]===void 0?1:Number(t[5]);return!Number.isInteger(o)||o<1?null:{comparison:a,threshold:n,startDwellMs:r,stopDwellMs:i,minSamples:o}}function IO(e){let t=Vbe.exec(e);if(t!==null)return zO(t[1],t[2],t[3],t[4],t[5]);let n=Hbe.exec(e);return n===null?null:zO(n[1],n[2],n[3],void 0,void 0)}function LO(e){if(e.kind===`from`)return{cap:e.cap,fieldPath:e.fieldPath,addonId:e.source.addonId,stableId:e.source.stableId};if(e.kind!==`expression`||Object.keys(e.bindings).length!==1)return null;let t=e.bindings.x;return t===void 0||t.kind!==`from`?null:{cap:t.cap,fieldPath:t.fieldPath,addonId:t.source.addonId,stableId:t.source.stableId}}function RO(e,t){if(!Number.isFinite(e))return null;let n=Object.is(e,-0)?`0`:String(e);return t.test(n)?n:null}function zO(e,t,n,r,i){if(e!==`x`&&e!==`number(x)`||t===void 0||n===void 0)return null;let a=Number(t),o=Number(n);if(!Number.isFinite(a)||!Number.isFinite(o))return null;if(r===void 0||i===void 0)return{inner:e,scale:a,offset:o};let s=Number(r),c=Number(i);return!Number.isFinite(s)||!Number.isFinite(c)?null:{inner:e,scale:a,offset:o,clampMin:s,clampMax:c}}var BO={kind:`expression`,expr:`now`,bindings:{}};function VO(e){return{kind:`from`,source:e.source,cap:e.cap,fieldPath:e.fieldPath}}function HO(e,t){return{kind:`expression`,expr:e,bindings:t}}function Wbe(e,t){return e.source.addonId===t.source.addonId&&e.source.stableId===t.source.stableId&&e.cap===t.cap&&e.fieldPath===t.fieldPath}function UO(e,t,n=[]){return{target:{kind:`new`,type:T.Sensor,role:D.NumericSensor},helper:e,features:[{kind:`fields`,cap:`numeric-sensor`,fields:{value:t,lastFetchedAt:BO}},...n]}}function WO(e,t){return{target:{kind:`new`,type:T.Sensor,role:D.BinarySensor},helper:e,features:[{kind:`fields`,cap:`binary`,fields:{on:t,lastChangedAt:BO}}]}}function GO(e){let t=[],n=kO(e.high),r=kO(e.low);n===null&&t.push(V(`kind-mismatch`,`helper.high`,`the high edge is a finite number`)),r===null&&t.push(V(`kind-mismatch`,`helper.low`,`the low edge is a finite number`)),n!==null&&r!==null&&e.low>e.high&&t.push(V(`kind-mismatch`,`helper.low`,`the low edge (${e.low}) is above the high edge (${e.high}) — it turns on at the high edge and off at the low one`));let i=OO(e.onForMs),a=OO(e.offForMs);(i===null||a===null)&&t.push(V(`kind-mismatch`,`helper.onForMs`,`the on and off delays are a non-negative number of milliseconds`));let o=i!==null&&a!==null&&(e.onForMs>0||e.offForMs>0)?`, ${i}, ${a}`:``;return{problems:t,draft:WO(e,HO(`coalesce(schmitt(x, ${n??`0`}, ${r??`0`}${o}), false)`,{x:VO(e.source)}))}}var Gbe=[`a`,`b`];function Kbe(e){let t=[],n=e.op!==`sum`;return n&&e.inputs.length!==2&&t.push(V(`member-constraint`,`helper.inputs`,`a ${e.op} takes exactly two readings, the first ${e.op===`ratio`?`over`:`minus`} the second`)),!n&&e.inputs.length<2&&t.push(V(`member-constraint`,`helper.inputs`,`a sum takes two or more readings`)),e.inputs.forEach((n,r)=>{e.inputs.slice(0,r).some(e=>Wbe(e,n))&&t.push(V(`member-constraint`,`helper.inputs[${r}]`,`this reading is already an input`))}),t}var qbe=[`included`,`excluded`,`total`];function KO(e){let t=Kbe(e);if(e.op===`sum`){let n=e.inputs.map(e=>({source:e.source,cap:e.cap,fieldPath:e.fieldPath})),r=e=>({kind:`aggregate`,reducer:`sum`,reads:n,publish:e,empty:`null`}),i=Object.fromEntries(qbe.map(e=>[e,r(e)]));return{problems:t,draft:UO(e,r(`value`),[{kind:`fields`,cap:`group-status`,fields:i}])}}let n=Object.fromEntries(e.inputs.slice(0,2).map((e,t)=>[Gbe[t]??`a`,VO(e)]));return{problems:t,draft:UO(e,HO(e.op===`difference`?`a - b`:`b == 0 ? null : a / b`,n))}}function Jbe(e){let t=[],n=new Set;if(e.inputs.forEach((e,r)=>{let i=`helper.inputs[${r}].name`;MO(e.name)||t.push(V(`expression-invalid`,i,`\`${e.name}\` is not a name — use letters, digits and _, starting with a letter`)),n.has(e.name)&&t.push(V(`expression-invalid`,i,`the name \`${e.name}\` is used twice`)),n.add(e.name)}),t.length>0)return t;let r=Object.fromEntries(e.inputs.map(e=>[e.name,VO(e.member)])),i=Ls({expr:e.expr,bindings:r});return i===null?[]:[V(`expression-invalid`,`helper.expr`,i)]}function qO(e){let t=Jbe(e),n=Object.fromEntries(e.inputs.map(e=>[e.name,VO(e.member)])),r=HO(e.expr,n);return{problems:t,draft:e.output===`boolean`?WO(e,r):UO(e,r)}}function Ybe(e,t){return e.addonId===t.addonId&&e.stableId===t.stableId}function Xbe(e,t){return Ybe(e.source,t.source)&&e.cap===t.cap&&e.fieldPath===t.fieldPath}function Zbe(e,t){return e.accept.some(e=>e.cap===t.cap&&e.fieldPath===t.fieldPath)}function Qbe(e,t){return t.members.flatMap((n,r)=>{let i=`helper.members[${r}]`,a=[];if(!Zbe(e,n)){let t=e.accept.map(e=>`${e.cap}.${e.fieldPath}`).join(` or `);a.push(V(`member-constraint`,i,`a ${e.id} group reads ${t}; this member is ${n.cap}.${n.fieldPath}`))}return t.members.slice(0,r).some(e=>Xbe(e,n))&&a.push(V(`member-constraint`,i,`this member is already in the group`)),a})}function JO(e,t,n,r){return{kind:`aggregate`,reducer:t.aggregate,reads:[...n],publish:r,empty:e.empty,...e.activeWhen===void 0?{}:{activeWhen:[...e.activeWhen]}}}function $be(e,t){let n=t.members.map(e=>({source:e.source,cap:e.cap,fieldPath:e.fieldPath})),r=Object.fromEntries(e.companions.map(e=>[e.fieldPath,txe(e.expr)]));return{target:{kind:`new`,type:e.deviceType,...e.role===void 0?{}:{role:e.role}},helper:t,features:[{kind:`fields`,cap:e.outputCap,fields:{[e.outputField]:JO(e,t,n,`value`),...r}},{kind:`fields`,cap:`group-status`,fields:{included:JO(e,t,n,`included`),excluded:JO(e,t,n,`excluded`),total:JO(e,t,n,`total`)}}]}}function exe(e,t){if(e.family===`actuator`){if(t.active===void 0)return[V(`kind-mismatch`,`helper.active`,`a ${e.id} group needs an active criterion (at-least-one or all)`)];let n=bO(t.active);return t.aggregate===n?[]:[V(`kind-mismatch`,`helper.aggregate`,`active \`${t.active}\` aggregates by \`${n}\`, not \`${t.aggregate}\``)]}return t.active===void 0?[]:[V(`kind-mismatch`,`helper.active`,`a ${e.id} group has no active criterion — that belongs to an actuator group`)]}function YO(e){let t=El.safeParse(e);return t.success?{ok:!0,composition:t.data}:{ok:!1,problems:[V(`helper-mismatch`,`helper`,`the template did not compile: ${t.error.issues.map(e=>e.message).join(`; `)}`)]}}function txe(e,t={}){return{kind:`expression`,expr:e,bindings:t}}function XO(e,t=ic){switch(e.kind){case`group`:return rxe(e);case`statistic`:{let n=TO(e,t);return n.problems.length>0?{ok:!1,problems:n.problems}:YO(n.draft)}case`integral`:{let n=DO(e,t);return n.problems.length>0?{ok:!1,problems:n.problems}:YO(n.draft)}case`derivative`:{let n=EO(e,t);return n.problems.length>0?{ok:!1,problems:n.problems}:YO(n.draft)}case`threshold`:return ZO(GO(e));case`arithmetic`:return ZO(KO(e));case`expression`:return ZO(qO(e));case`grid`:case`terminal`:return YO(nxe(e))}}function nxe(e){return{target:{kind:`new`,type:T.Camera},helper:e,features:[]}}function ZO(e){return e.problems.length>0?{ok:!1,problems:e.problems}:YO(e.draft)}function rxe(e){let t=dO(e.templateId);if(t===null)return{ok:!1,problems:[V(`member-constraint`,`helper.templateId`,`unknown template \`${e.templateId}\``)]};let n=exe(t,e);if(n.length>0)return{ok:!1,problems:n};if(!t.aggregates.includes(e.aggregate)){let n=t.aggregates.join(`, `);return{ok:!1,problems:[V(`kind-mismatch`,`helper.aggregate`,`a ${t.id} group aggregates by ${n}, not \`${e.aggregate}\``)]}}let r=Qbe(t,e);return r.length>0?{ok:!1,problems:r}:YO($be(t,e))}function QO(e,t){return JSON.stringify(e.target)===JSON.stringify(t.target)&&JSON.stringify(e.features)===JSON.stringify(t.features)}function ixe(e){return e.kind===`group`?dO(e.templateId)?.memberDeviceType??null:null}function axe(e,t){if(e.kind!==`group`)return[];let n=dO(e.templateId);if(n===null||n.family!==`numeric`)return[];let r=e.members.flatMap((e,n)=>{let r=t.get(Dl(e.source))?.quantity;return r===void 0?[]:[{index:n,quantity:r}]});if(n.quantity!==`device`)return r.flatMap(e=>e.quantity===n.quantity?[]:[V(`mixed-quantity`,`helper.members[${e.index}]`,`a ${n.id} group is ${n.quantity}${n.baseUnit===void 0?``:` (${n.baseUnit})`}; this member is ${e.quantity}`)]);let i=[...new Set(r.map(e=>e.quantity))];return i.length<=1?[]:[V(`mixed-quantity`,`helper.members`,`a numeric group requires one quantity; members report ${i.join(` and `)}`)]}function oxe(e,t){if(e.kind!==`group`)return[];let n=dO(e.templateId);return n===null?[]:e.members.flatMap((e,r)=>{let i=t.get(Dl(e.source)),a=i?.deviceType;return a===void 0||hO(n.memberDeviceTypes,a,i?.role)?[]:[V(`member-constraint`,`helper.members[${r}]`,`a ${n.id} group takes ${n.memberDeviceTypes.join(` or `)} devices; this member is a ${a}`)]})}function $O(e,t){let n=e.helper;if(n===void 0)return[];let r=XO(n);return r.ok?QO(e,r.composition)?n.kind===`arithmetic`?sxe(n,t):n.kind===`group`?[...axe(n,t),...oxe(n,t)]:[]:[V(`helper-mismatch`,`helper`,`the stored features are not this template — the helper spec is the only writer`)]:r.problems}function sxe(e,t){let n=e.inputs.flatMap(e=>{let n=t.get(Dl(e.source))?.quantity;return n===void 0?[]:[n]}),r=[...new Set(n)];return r.length<=1?[]:[V(`mixed-quantity`,`helper.inputs`,`a ${e.op} needs readings of one quantity; these inputs report ${r.join(` and `)}`)]}var ek=class extends Error{};function cxe(e){return new Set(e.composition.features.flatMap(e=>!xl(e)||e.kind!==`fields`?[]:Pl(e).map(({fieldPath:t})=>`${e.cap}.${t}`)))}function lxe(e,t,n){if(Dl(n.source)!==Dl(e.target))return!0;let r=`${n.cap}.${n.fieldPath}`;return t.has(r)&&e.replaced?.has(r)!==!0}function uxe(e){let t=cxe(e);return e.composition.features.flatMap(n=>!xl(n)||n.kind!==`fields`?[]:Pl(n).map(({fieldPath:r,source:i})=>[kl({source:e.target,cap:n.cap,fieldPath:r}),Ml(i).filter(n=>lxe(e,t,n)).map(kl)]))}function dxe(e,t){let n=Dl(e.target),r=new Map;for(let i of t){if(i.blockId===e.blockId)continue;let t=Dl(i.target);if(t===n)throw new ek(`block \`${i.blockId}\` and block \`${e.blockId}\` both target device \`${t}\` — one composition per device; delete or edit the existing one`);let a=r.get(t);if(a!==void 0)throw new ek(`two stored compositions (\`${a.blockId}\`, \`${i.blockId}\`) both target device \`${t}\` — refusing to build the field graph`);r.set(t,i)}return[...r.values(),e]}function tk(e,t){let n=dxe(e,t).flatMap(uxe);return new Map(n)}function fxe(e,t){let n=tk(e,t),r=new Map,i=new Map,a=(e,t)=>{let o=r.get(e);if(o!==`done`){if(o===`visiting`){let n=[...t.slice(t.indexOf(e)),e],r=[...new Set(n)].toSorted().join(`|`);i.has(r)||i.set(r,{path:n});return}r.set(e,`visiting`);for(let r of n.get(e)??[])a(r,[...t,e]);r.set(e,`done`)}};for(let e of n.keys())a(e,[]);return[...i.values()]}function pxe(e){let t=new Map,n=new Map,r=new Set,i=[],a=[],o=s=>{t.set(s,t.size),n.set(s,t.get(s)??0),i.push(s),r.add(s);for(let i of e.get(s)??[])t.has(i)?r.has(i)&&n.set(s,Math.min(n.get(s)??0,t.get(i)??0)):(o(i),n.set(s,Math.min(n.get(s)??0,n.get(i)??0)));if(n.get(s)!==t.get(s))return;let c=[];for(let e=i.pop();e!==void 0&&(r.delete(e),c.push(e),e!==s);e=i.pop());a.push(c)};for(let n of e.keys())t.has(n)||o(n);return a}function mxe(e,t,n){let r=new Map,i=[e];for(let a=0;a<i.length;a+=1){let o=i[a];if(o===void 0)break;for(let a of n.get(o)??[]){if(a===e){let t=[];for(let n=o;n!==void 0&&n!==e;n=r.get(n))t.push(n);return[e,...t.reverse(),e]}!t.has(a)||r.has(a)||(r.set(a,o),i.push(a))}}return[e,e]}function nk(e,t){let n=tk(e,t),r=`${Dl(e.target)}#`;return pxe(n).flatMap(e=>{let t=e.find(e=>e.startsWith(r));if(t===void 0)return[];let i=new Set(e),a=e.length===1&&(n.get(t)??[]).includes(t);return e.length===1&&!a?[]:[{path:mxe(t,i,n),component:i}]})}var hxe=3,gxe=120,_xe=10,rk=x([`no-power-source`,`switch-missing`,`switch-offline`,`switch-unknown`,`restart-in-progress`,`switch-call-failed`,`switch-options-unreadable`,`not-settable`,`switch-is-actuator`,`link-lost`,`link-unknown`]),ik=i(`accepted`,[b({accepted:p(!0)}),b({accepted:p(!1),reason:rk,message:l()})]),ak=b({linked:v(),switchDeviceId:n().nullable(),switchName:l().nullable(),switchOn:v().nullable(),switchOnline:v().nullable(),switchSettable:v().nullable().optional(),restartInProgress:v(),offSeconds:n().int()}),ok=b({switchOn:v().nullable(),offSeconds:n().int(),lastFetchedAt:n()}),sk=[T.Gateway,T.Camera,T.Sensor,T.MediaPlayer,T.Vacuum,T.Generic,T.Washer,T.Dryer,T.Dishwasher,T.PetFountain,T.Fan,T.Humidifier,T.Climate,T.WaterHeater],vxe={version:1,targets:[{id:`switch`,cardinality:`scalar`,vocabulary:{cap:`power-source`,stateField:`switchOn`},deviceTypes:sk,apply:`add`,path:`switchOn`,sources:[{kind:`switch`,transforms:[{kind:`identity`}]}],companions:[{kind:`constant`,path:`offSeconds`,value:10,when:`add`,formerValues:[0]},{kind:`clock`,path:`lastFetchedAt`,when:`always`}],sourceReport:{status:`assignment-status`}}]},ck=b({deviceId:n().int().nonnegative()}),lk={method:`getStatus`,field:`switchSettable`},uk={name:`power-source`,scope:`device`,mode:`singleton`,deviceTypes:sk,methods:{getStatus:ii(ck,ak,{auth:`protected`}),powerOn:ii(ck,ik,{kind:`mutation`,auth:`protected`,actions:[{id:`powerSource.on`,label:P(`Power on`,`Dai corrente`),phrase:P(`Power on {device}`,`Dai corrente a {device}`),icon:`power`,offeredWhen:lk}]}),powerOff:ii(ck,ik,{kind:`mutation`,auth:`protected`,actions:[{id:`powerSource.off`,label:P(`Power off`,`Togli corrente`),phrase:P(`Cut the power of {device}`,`Togli la corrente a {device}`),icon:`power-off`,offeredWhen:lk}]}),forceRestart:ii(ck,ik,{kind:`mutation`,auth:`protected`,actions:[{id:`powerSource.forceRestart`,label:P(`Force restart`,`Riavvio forzato`),phrase:P(`Force restart {device} by cutting its power`,`Riavvia {device} togliendo la corrente`),icon:`refresh-cw`}]})},runtimeState:ok,customize:vxe,durability:`session`,history:`none`,vocabulary:{noun:P(`Power source`,`Alimentazione`),order:1050,state:[{kind:`boolean`,field:`switchOn`,label:P(`Power switch on`,`Presa accesa`),whenTrue:P(`When the power of {device} comes on`,`Quando arriva la corrente a {device}`),whenFalse:P(`When the power of {device} is cut`,`Quando manca la corrente a {device}`),icon:`power`}]}};function dk(e){return typeof e!=`number`||!Number.isFinite(e)?10:Math.min(120,Math.max(3,Math.round(e)))}function yxe(e){let t=e.features.find(e=>e.cap===`power-source`);if(t===void 0||t.kind!==`fields`)return;let n=t.fields.offSeconds;if(n===void 0||n.kind!==`expression`)return;let r=Number(n.expr);return n.expr.trim()===``||!Number.isFinite(r)?void 0:r}function bxe(e,t){if(e===null)return null;let n;if(e.target.kind===`existing`)n=e.target.device;else if(t!==void 0)n=jl(t);else return null;let r=e.features.find(e=>e.cap===`power-source`);if(r===void 0||r.kind!==`fields`||r.enabled===!1)return null;let i=r.fields.switchOn;if(i===void 0)return null;let a=Ml(i).find(e=>e.cap===`switch`);return a===void 0?null:{device:n,switch:a.source,offSeconds:dk(yxe(e)),...r.contributedBy===void 0?{}:{contributedBy:r.contributedBy}}}var fk=`switch`;function xxe(e){let t=new Set;return e.target.kind===`existing`&&t.add(Dl(e.target.device)),e.features.forEach((e,n)=>{if(!(e.kind!==`fields`||e.cap!==fk)&&xl(e)){for(let n of Fl(e))for(let e of Ml(n))t.add(Dl(e.source));for(let r of JD(e,n))t.add(Dl(r.command.source))}}),t}function pk(e){let t=e.features.findIndex(e=>e.cap===`power-source`),n=e.features[t];if(n===void 0||n.kind!==`fields`||n.enabled===!1)return[];let r=n.fields.switchOn;if(r===void 0)return[];let i=xxe(e);return Ml(r).filter(e=>e.cap===fk&&i.has(Dl(e.source))).map(e=>({path:`features[${t}].fields.switchOn`,switch:e.source}))}function mk(e){let t=new Map(e.map(e=>[e.name,e]));return e=>t.get(e)??null}var hk=new Set([`device-status`,`feature-probe`]),Sxe={addonId:Xc,stableId:`${Ee}(unsaved)`},Cxe=`(unsaved)`;function wxe(e,t,n){let r=n(e.cap);if(r===null)return V(`unknown-capability`,`${t}.cap`,`no capability is named \`${e.cap}\``);if(hk.has(r.name))return V(`not-composable`,`${t}.cap`,`\`${r.name}\` is registered by every device itself — it cannot be composed`);let i=r.runtimeState;return r.scope!==`device`||i===void 0?V(`not-composable`,`${t}.cap`,`\`${r.name}\` has no per-device state to compose`):{def:r,state:i,fields:RT(i)}}function Txe(e){let t=e.helper;if(t===void 0||t.kind!==`group`)return new Set;let n=dO(t.templateId);return n===null||n.family!==`actuator`?new Set:new Set(n.commandCaps)}function Exe(e,t){return e.name===bD.name&&Object.values(t.commands??{}).some(e=>e.kind===`extension`)}function Dxe({def:e,state:t,fields:n},r,i,a,o){let s=[];e.deviceTypes!==void 0&&!e.deviceTypes.includes(a)&&s.push(V(`wrong-device-type`,`${i}.cap`,`\`${e.name}\` is not offered on a \`${a}\` device (it allows ${e.deviceTypes.join(`, `)})`));let c=new Set(Object.entries(r.commands??{}).flatMap(([e,t])=>t.kind===`forward`||t.kind===`extension`?[e]:[])),l=XD(e).filter(e=>!c.has(e)).map(e=>`\`${e}\``);l.length>0&&!o.has(e.name)&&s.push(V(`has-commands`,`${i}.cap`,`\`${e.name}\` has ${l.join(`, `)} with no command — a composed device serves a method only through a \`forward\` (D967)`));let u=r.items===void 0?null:e.status?.itemArray?.path??null,d=Exe(e,r);for(let a of d?[]:zT(t))a!==u&&(n.has(a)?a in r.fields||s.push(V(`missing-field`,`${i}.fields.${a}`,`\`${e.name}.${a}\` is required and has no source`)):s.push(V(`not-composable`,`${i}.fields`,`\`${e.name}.${a}\` is not a scalar — nested fields arrive in a later slice`)));return s}function Oxe({fields:e,state:t},n,r){return n.includes(`.`)?r===`replace`?LT(t,n)??void 0:`nested`:e.get(n)}function kxe(e,t,n,r){let{def:i}=e,{featureIndex:a,path:o,source:s}=t,c=`features[${a}].fields.${o}`,l=Oxe(e,o,n);if(l===`nested`)return CD(V(`nested-field`,c,`\`${o}\` is nested — a nested field is planned only on a declared replace (D1034)`));if(l===void 0)return CD(V(`unknown-field`,c,`\`${i.name}\` has no field \`${o}\``));if(l.kind===`union`)return CD(LD(i.name,o,c));let u=BD(s,r);if(!u.ok)return CD(V(u.code,c,u.message));let d=UD(s),f=WD(l,d,n,i.name,c);if(!f.ok)return CD(f.problem);let p=s.kind===`aggregate`&&s.publish===`value`&&s.empty===`omit`,m={cap:i.name,path:o,featureIndex:a,kind:l.kind,nullable:l.nullable,required:l.required,unavailable:p?`omit`:f.unavailable,role:d,source:s,reads:[...Ml(s)]},h=HD(i.name,l,s,c);return{problems:[...VD(i.name,l,zD(s,l,u.kinds,r),c),...h===null?[]:[h]],fields:[m],features:[],events:[]}}function Axe(e,t,n,r,i){let a=`features[${n}]`,o=JD(t,n),s=Object.entries(t.commands??{}).filter(([,e])=>e.kind===`code`).map(([e])=>V(`reserved-variant`,`${a}.commands.${e}`,"a `code` command arrives in slice 4")),c=Object.entries(t.commands??{}).filter(([,e])=>e.kind===`extension`);return c.length>0&&e.name!==bD.name?[...s,...c.map(([t])=>V(`command-method-unknown`,`${a}.commands.${t}`,`the \`remote\` extension serves a \`media-player\` only, not \`${e.name}\``))]:(o.length>0||c.length>0)&&r!==`new`?[...s,V(`reserved-variant`,`${a}.commands`,"commands (`forward`) are served only by a capability a NEW device builds — not on an existing device")]:[...s,...nO(e,t,a),...o.flatMap(t=>tO(e,t,i))]}function gk(e,t,n,r,i){let a=`features[${t}]`,o=wxe(e,a,r);if(`code`in o)return CD(o);let s=n.mode===`replace`?[]:[...Dxe(o,e,a,n.deviceType,i)];s.push(...Axe(o.def,e,t,n.mode,r));let c=Object.entries(e.fields).map(([e,i])=>kxe(o,{featureIndex:t,path:e,source:i},n.mode,r)),l=e.items===void 0?[]:[KD(o.def,e,t,r,n.mode)],u=[...c,...l],d=u.flatMap(e=>e.fields),f={featureIndex:t,cap:o.def.name,mode:n.mode},p=WT(o.def,f,d);return{problems:[...s,...u.flatMap(e=>e.problems),...p.problems],fields:d,features:[f],events:p.events}}function _k(e,t){let n=e.nativeCaps.get(t);return n!==void 0&&n!==`composer`}function jxe(e){return`code`in e}function Mxe(e,t){if(e.target.kind===`new`)return{kind:`new`,type:e.target.type};let n=Dl(e.target.device);return t===void 0?V(`target-unreadable`,`target`,`target device \`${n}\` was not read — the save is refused rather than stored unchecked`):t.kind===`absent`?V(`target-missing`,`target`,`target device \`${n}\` does not exist`):t.kind===`unreadable`?V(`target-unreadable`,`target`,`could not read target device \`${n}\` (${t.error}) — the save is refused rather than stored unchecked`):{kind:`existing`,found:t}}var Nxe=new Set([`not-composable`,`unknown-capability`,`reserved-variant`]);function Pxe(e,t){let n=t.problems.filter(e=>Nxe.has(e.code));return n.length>0?{problems:n,fields:[],features:[],events:[]}:CD(e)}var Fxe=xD;function Ixe(e){let t=Fxe[e.cap],n=new Set((t?.overridable??[]).flatMap(e=>{let n=(t?.targets.find(t=>t.id===e.by&&t.path===e.path)?.companions??[]).filter(e=>e.kind===`transition-time`||e.kind===`source-field`||e.when===`always`);return[e.path,...n.map(e=>e.path)]})),r=Object.keys(e.fields);return r.length>0&&r.every(e=>n.has(e))&&e.items===void 0&&e.commands===void 0}function Lxe(e,t,n){let r=t.cap;return e.kind===`new`?{mode:`new`,deviceType:e.type}:_k(e.found,r)?Ixe(t)?{mode:`replace`,deviceType:e.found.type}:V(`native-capability-replace`,n,`native-capability-replace: stored override replaces native capability \`${r}\` on device ${e.found.deviceId} — refused (D944)`):{mode:`add`,deviceType:e.found.type}}function vk(e,t,n){let r=Mxe(e,n);if(`code`in r)return CD(r);let i=Txe(e),a=e.features.map((e,n)=>{let a=`features[${n}]`;if(e.kind===`passthrough`)return CD(V(`reserved-variant`,a,`whole-capability passthrough of \`${e.cap}\` arrives in slice 3`));let o=Lxe(r,e,a);if(jxe(o))return!xl(e)||r.kind!==`existing`?{problems:[],fields:[],features:[],events:[]}:Pxe(o,gk(e,n,{mode:`add`,deviceType:r.found.type},t,i));let s=gk(e,n,o,t,i);return xl(e)?s:{problems:Object.keys(e.fields).length===0?s.problems.filter(e=>e.code!==`missing-field`):s.problems,fields:[],features:[],events:[]}});return{problems:a.flatMap(e=>e.problems),fields:a.flatMap(e=>e.fields),features:a.flatMap(e=>e.features),events:a.flatMap(e=>e.events)}}function Rxe(e){let t=e.features.flatMap(e=>xl(e)&&e.kind===`fields`?Fl(e).flatMap(Ml).map(e=>e.source):[]);return[...new Map([...t,...YD(e)].map(e=>[Dl(e),e])).values()]}function zxe(e,t){return e.features.flatMap(e=>xl(e)&&e.kind===`fields`?Fl(e).flatMap(e=>{if(e.kind!==`from`)return[];let n=t(e.cap),r=n?.runtimeState??n?.status?.schema;return r===void 0?[]:LT(r,e.fieldPath)?.kind===`union`?[e]:[]}):[])}function Bxe(e,t,n){return{ref:e.target.kind===`existing`?e.target.device:t.self??Sxe,native:e.target.kind===`existing`&&t.target?.kind===`found`?t.target:null,replaced:yk(n)}}function yk(e){let t=new Set(e.features.filter(e=>e.mode===`replace`).map(e=>e.featureIndex));return new Set(e.fields.filter(e=>t.has(e.featureIndex)).map(QT))}function Vxe(e,t,n,r){let i=`${e.cap}.${e.fieldPath}`;return n.some(e=>QT(e)===i&&!r.replaced.has(i))?[]:r.native===null?[V(`source-field-unknown`,t,`this device has no composed field \`${e.cap}.${e.fieldPath}\``)]:_k(r.native,e.cap)?[]:[V(`source-capability-missing`,t,`the target device (device ${r.native.deviceId}) has no native \`${e.cap}\``)]}function Hxe(e,t,n,r){if(e.source.kind!==`from`)return[];let i=n.liveKinds?.get(`${t.cap}.${t.fieldPath}`),a=e.kind===`enum`?`string`:e.kind;return i===void 0||i===a?[]:[V(`source-kind-mismatch`,r,`\`${t.cap}.${t.fieldPath}\` of device ${n.deviceId} reads a ${i} now; \`${e.cap}.${e.path}\` takes a ${a}`)]}function Uxe(e,t,n){let r=Dl(n.ref);return e.flatMap(i=>i.reads.flatMap(a=>{let o=wD(i),s=Dl(a.source);if(s===r)return Vxe(a,o,e,n);let c=t.sources.get(s);return c===void 0||c.kind===`unreadable`?[V(`source-unreadable`,o,`could not read source \`${s}\` (${c===void 0?`it was not read`:c.error}) — the save is refused rather than stored unchecked`)]:c.kind===`absent`?[V(`source-missing`,o,`source \`${s}\` does not exist`)]:c.caps.has(a.cap)?Hxe(i,a,c,o):[V(`source-capability-missing`,o,`source \`${s}\` (device ${c.deviceId}) has no \`${a.cap}\``)]}))}function Wxe(e,t){let n=`${t}#`;if(!e.startsWith(n))return null;let r=e.slice(n.length),i=r.indexOf(`.`);return i===-1?null:{cap:r.slice(0,i),fieldPath:r.slice(i+1)}}function Gxe(e,t,n){for(let r of e){let e=Wxe(r,t);if(e===null)continue;let i=`${e.cap}.${e.fieldPath}`,a=n.find(e=>QT(e)===i);if(a!==void 0)return wD(a)}return`features`}function Kxe(e,t){for(let[n,r]of t)if(e.some(e=>e.startsWith(`${n}#`)))return{key:n,error:r};return null}function qxe(e,t,n,r){let i={blockId:t.blockId??`(unsaved)`,target:r.ref,composition:e,replaced:r.replaced},a=Dl(i.target),o=t.unreadTargets??new Map;try{return nk(i,t.peers).map(e=>{let t=Gxe(e.path,a,n),r=Kxe([...e.component],o);return r===null?V(`cycle`,t,`a field reads itself: ${e.path.join(` → `)}`):V(`cycle`,t,`possible cycle through \`${r.key}\` — its state could not be read (${r.error}): ${e.path.join(` → `)}`)})}catch(e){if(e instanceof ek)return[V(`duplicate-target`,`features`,e.message)];throw e}}function bk(e,t){let n=vk(e,t.lookupCap,t.target??void 0),r=Bxe(e,t,n),i=n.problems.filter(e=>e.code===`native-capability-replace`).map(e=>e.path),a=qxe(e,t,n.fields,r).filter(e=>i.some(t=>e.path===t||e.path.startsWith(`${t}.`))?!1:i.length===0||e.path!==`features`),o=new Map([...t.sources].flatMap(([e,t])=>t.kind===`found`?[[e,{deviceType:t.deviceType,role:t.role,quantity:t.quantity}]]:[])),s=[...n.problems,...Uxe(n.fields,t,r),...rO(e,t.sources),...a,...$O(e,o),...pk(e).map(e=>V(`power-source-is-actuator`,e.path,`the power source \`${e.switch.stableId}\` is one of this device's own switches — pick the plug that feeds it`))];return{ok:s.length===0,problems:s,fields:[...n.fields],features:[...n.features],events:[...n.events]}}var xk=b({path:l(),kind:qT,nullable:v(),required:v(),enumValues:S(l()).optional()}),Sk=b({cap:l(),fields:S(xk),itemArray:b({path:l(),keyField:l()}).optional()}),Ck=b({caps:S(Sk)});function wk(e,t){if(hk.has(e.name))return[`not-composable`];let n=e.runtimeState;if(e.scope!==`device`||n===void 0)return[`not-composable`];let r=[];e.deviceTypes!==void 0&&!e.deviceTypes.includes(t)&&r.push(`wrong-device-type`),Object.entries(e.methods).filter(([t,n])=>n.systemOnly!==!0&&e.composedMethods?.[t]===void 0).length>0&&r.push(`has-commands`);let i=RT(n),a=e.status?.itemArray?.path??null;return zT(n).some(e=>e!==a&&!i.has(e))&&r.push(`not-composable`),WT(e,{featureIndex:0,cap:e.name,mode:`new`},[]).problems.some(e=>e.code===`not-composable`)&&!r.includes(`not-composable`)&&r.push(`not-composable`),r}function Jxe(e,t){return e.filter(e=>wk(e,t).length===0).map(e=>{let t=e.runtimeState,n=t===void 0?[]:[...RT(t).values()],r=e.status?.itemArray;return{cap:e.name,fields:n.flatMap(e=>e.kind===`union`?[]:[{path:e.path,kind:e.kind,nullable:e.nullable,required:e.required,...e.enumValues===void 0?{}:{enumValues:[...e.enumValues]}}]),...r===void 0?{}:{itemArray:{path:r.path,keyField:r.keyField}}}}).toSorted((e,t)=>e.cap.localeCompare(t.cap))}var Tk=b({addonId:l().min(1),stableId:l().min(1),cap:l().min(1),fieldPath:l().min(1)}),Yxe=b({kind:p(`identity`)}),Xxe=b({kind:p(`invert`)}),Ek=b({kind:p(`threshold`),comparison:x([`gte`,`lte`]),threshold:n(),startDwellMs:n().nonnegative(),stopDwellMs:n().nonnegative(),minSamples:n().int().min(1).optional()}),Dk=i(`kind`,[Yxe,Xxe,Ek,b({kind:p(`linear`),scale:n(),offset:n(),clampMin:n().optional(),clampMax:n().optional()}),b({kind:p(`enum-map`),mapping:m(l(),l().nullable())}),b({kind:p(`number`)})]),Zxe=b({kind:p(`scalar`),cap:l().min(1),targetId:l().min(1),source:Tk,transform:Dk}),Qxe=b({kind:p(`keyedArray`),cap:l().min(1),targetId:l().min(1),key:l().min(1),label:l().min(1),fieldPath:l().min(1),source:Tk,transform:Dk}),$xe=b({kind:p(`pulse`),cap:l().min(1),targetId:l().min(1),enabled:v(),debounceMs:n().nonnegative(),edges:S(x([`rising`,`button`,`native-event`])).min(1).optional(),sources:S(Tk).min(1)}),eSe=Tk.extend({mode:x([`in-addition`,`confirm`,`replace`]).optional()}),tSe=i(`kind`,[Zxe,Qxe,$xe,b({kind:p(`span`),cap:l().min(1),targetId:l().min(1),timeoutMs:n().nonnegative(),cooldownMs:n().nonnegative().optional(),sources:S(eSe)})]),nSe=b({targetId:l().min(1),configured:v(),source:x([`native`,`assigned`]),state:x([`active`,`stale`,`released`,`unavailable`]),reason:l().nullable()}),Ok=x([`raw`,`5m`]),kk=x([`high`,`medium`,`low`]),Ak=x([`no-history`,`span-too-short`,`truncated`,`no-idle-floor`,`no-runs`,`no-separation`]),jk=b({intervals:n().int().nonnegative(),extra:n().int().nonnegative(),missed:n().int().nonnegative()}),Mk=b({tier:Ok,spanMs:n().nonnegative(),from:n(),to:n(),points:n().int().nonnegative(),runsFound:n().int().nonnegative(),pausesFound:n().int().nonnegative(),longestPauseMs:n().nonnegative(),pulsesFound:n().int().nonnegative(),longestPulseMs:n().nonnegative(),idleFloorW:n(),noiseCeilingW:n(),plateauW:n(),replay:jk}),Nk=b({spanMs:n().nonnegative(),points:n().int().nonnegative(),runsFound:n().int().nonnegative()}),Pk=i(`state`,[b({state:p(`proposal`),transform:Ek,evidence:Mk,confidence:kk,notes:S(l())}),b({state:p(`insufficient`),reason:Ak,evidence:Nk,fallback:Ek})]),Fk=b({apply:v()}),Ik=b({apply:v(),rows:n().int(),raw:n().int(),markers:n().int(),migrated:n().int(),failed:n().int(),remainingRaw:n().int(),unresolvedMarkers:n().int(),redundantCopies:n().int().optional(),verified:v()}),Lk=`core-block-`,Rk=`core-blocks`;function rSe(e){return`${Lk}${e}`}function iSe(e){if(!e.startsWith(`core-block-`))return null;let t=e.slice(11);return t.length>0?t:null}var zk=h([p(`hub`),l().min(1)]),Bk=x([`stopped`,`starting`,`running`,`degraded`,`incomplete`,`failed`]),Vk=`main.ts`,Hk=m(l().min(1).max(260),l().max(2e5)),Uk=ye(),Wk=b({name:l().min(1).max(120),code:l().max(2e5).optional(),files:Hk.optional(),entry:l().min(1).max(260).optional(),enabled:v(),placement:zk,integrationId:l().optional(),settingsSchema:Uk.optional(),tags:Vh.optional()}),Gk=Wk.superRefine((e,t)=>{let n=e.entry??`main.ts`;if(e.files!==void 0){e.files[n]===void 0&&t.addIssue({code:`custom`,message:`files must include the entry "${n}"`,path:[`files`]});return}e.code===void 0&&t.addIssue({code:`custom`,message:`code or files is required`,path:[`code`]})});function Kk(e){return e!==void 0&&e.length>0?e:Vk}function aSe(e){let t=Kk(e.entry);return e.files===void 0?{files:{[t]:e.code},entry:t}:{files:{...e.files},entry:t}}function oSe(e){if(e.files!==void 0){let t=Kk(e.entry);return{code:e.files[t]??e.code??``,files:{...e.files},entry:t}}return{code:e.code??``,...e.entry===void 0?{}:{entry:e.entry}}}var qk=i(`kind`,[b({kind:p(`code`)}),b({kind:p(`recipe`),recipe:Wv}),b({kind:p(`composition`),composition:El})]),Jk=b({name:l().min(1).max(120).optional(),enabled:v(),composition:El}),Yk=b({name:l().min(1).max(120),code:l().max(2e5),files:Hk.optional(),entry:l().min(1).max(260).optional(),enabled:v(),placement:zk,integrationId:l().optional(),settingsSchema:Uk.optional(),tags:Vh.optional(),id:l(),createdAt:n(),updatedAt:n(),createdBy:l(),status:Bk,lastError:l().optional(),lastChangedAt:n(),source:qk.optional()});function sSe(e){return e.source?.kind??`code`}function cSe(e){return e.source?.kind===`composition`?e.source.composition:null}var Xk=i(`kind`,[b({kind:p(`answered`),state:aE.nullable()}),b({kind:p(`unreachable`),error:l()})]),Zk=b({block:Yk,state:Xk}),Qk=b({state:p(`not-loaded`),reason:l()}),$k=i(`state`,[b({state:p(`loaded`),views:S(Zk)}),Qk]),eA=i(`state`,[b({state:p(`loaded`),view:Zk.nullable()}),Qk]),tA=i(`state`,[b({state:p(`loaded`),view:Zk.nullable()}),Qk]),nA=b({ok:v(),error:l().optional(),line:n().optional(),column:n().optional()}),rA=b({code:l().optional(),files:Hk.optional(),entry:l().min(1).max(260).optional()}).superRefine((e,t)=>{if(e.files!==void 0){let n=e.entry??`main.ts`;e.files[n]===void 0&&t.addIssue({code:`custom`,message:`files must include the entry "${n}"`,path:[`files`]});return}e.code===void 0&&t.addIssue({code:`custom`,message:`code or files is required`,path:[`code`]})}),iA={name:`core-blocks`,scope:`system`,mode:`singleton`,methods:{list:k(b({}),b({blocks:S(Yk)}),{auth:`admin`}),get:k(b({blockId:l()}),b({block:Yk.nullable()}),{auth:`admin`}),create:k(b({block:Gk}),b({block:Yk}),{kind:`mutation`,auth:`admin`,caller:`required`}),update:k(b({blockId:l(),block:Wk.partial()}),b({block:Yk}),{kind:`mutation`,auth:`admin`,caller:`required`}),delete:k(b({blockId:l()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setEnabled:k(b({blockId:l(),enabled:v()}),b({block:Yk}),{kind:`mutation`,auth:`admin`}),restart:k(b({blockId:l()}),b({block:Yk}),{kind:`mutation`,auth:`admin`}),compile:k(rA,nA,{kind:`mutation`,auth:`admin`}),getBlockSettings:k(b({blockId:l()}),aS.nullable(),{auth:`admin`}),updateBlockSettings:k(b({blockId:l(),patch:oS}),cS,{kind:`mutation`,auth:`admin`}),migrateRawSecrets:k(Fk,Ik,{kind:`mutation`,auth:`admin`}),getTypeDefs:k(b({}),b({libs:S(b({filePath:l(),content:l()}))}),{auth:`admin`}),createComposition:k(b({block:Jk}),b({block:Yk}),{kind:`mutation`,auth:`admin`,caller:`required`}),updateComposition:k(b({blockId:l(),expectedUpdatedAt:n(),block:Jk.partial()}),b({block:Yk}),{kind:`mutation`,auth:`admin`,caller:`required`}),getComposition:k(b({blockId:l()}),eA,{auth:`admin`}),listCompositions:k(b({}),$k,{auth:`admin`}),getCustomization:k(b({addonId:l().min(1),stableId:l().min(1)}),tA,{auth:`admin`}),listComposableCaps:k(b({deviceType:x(T)}),Ck,{auth:`admin`}),validateComposition:k(b({composition:El,blockId:l().optional()}),tE,{kind:`mutation`,auth:`admin`,access:`view`}),proposeRunningThreshold:k(b({deviceId:n().int(),cap:l().min(1),fieldPath:l().min(1),deviceType:x(T).optional()}),Pk,{auth:`admin`,access:`view`}),reportAutomationRun:k(b({blockId:l().min(1),trace:Oy.optional(),runStartedAt:n().optional(),keepTraces:n().int().min(1).max(100).optional()}),_(),{kind:`mutation`,auth:`admin`}),getAutomationRunState:k(b({blockId:l().min(1)}),ky,{auth:`admin`}),getTraces:k(b({blockId:l().min(1)}),b({traces:S(Oy),lastError:l().nullable()}),{auth:`admin`})},vocabulary:{notOperatorFacing:j.INTERNAL}},aA=x([`open`,`opening`,`closing`,`closed`,`stopped`]),oA=b({state:aA,position:n().min(0).max(100).nullable().meta(M(`percentage`)),tiltPosition:n().min(0).max(100).nullable().meta(M(`percentage`)),lastChangedAt:n()}),sA={name:`cover`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Cover],methods:{open:k(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.open`,label:P(`Open`,`Apri`),phrase:P(`Open {device}`,`Apri {device}`),icon:`arrow-up-to-line`,effect:{field:`state`,value:`open`}}]}),close:k(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.close`,label:P(`Close`,`Chiudi`),phrase:P(`Close {device}`,`Chiudi {device}`),icon:`arrow-down-to-line`,effect:{field:`state`,value:`closed`}}]}),stop:A(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.stop`,label:P(`Stop`,`Ferma`),phrase:P(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),setPosition:A(b({deviceId:n().int().nonnegative(),position:n().min(0).max(100)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.position`,label:P(`Set position`,`Imposta la posizione`),phrase:P(`Move {device} to {position} open`,`Porta {device} al {position} di apertura`),icon:`blinds`,effect:{field:`position`,fromArg:`position`},openArgs:[{key:`position`,label:P(`Position`,`Posizione`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setTiltPosition:A(b({deviceId:n().int().nonnegative(),tiltPosition:n().min(0).max(100)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.tilt`,label:P(`Set tilt`,`Imposta l’inclinazione`),phrase:P(`Tilt {device} to {tiltPosition}`,`Inclina {device} al {tiltPosition}`),icon:`blinds`,effect:{field:`tiltPosition`,fromArg:`tiltPosition`},openArgs:[{key:`tiltPosition`,label:P(`Tilt`,`Inclinazione`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]})},status:{schema:oA,kind:`push`},runtimeState:oA,durability:`restored`,history:{fields:{position:{kind:`gauge`,unit:`%`,minIntervalMs:0}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:P(`Cover`,`Copertura`),order:1030,state:[{kind:`enum`,field:`state`,label:P(`State`,`Stato`),values:[{value:`open`,label:P(`Open`,`Aperto`),phrase:P(`When {device} is fully open`,`Quando {device} è tutto aperto`)},{value:`opening`,label:P(`Opening`,`In apertura`),phrase:P(`When {device} starts opening`,`Quando {device} inizia ad aprirsi`)},{value:`closing`,label:P(`Closing`,`In chiusura`),phrase:P(`When {device} starts closing`,`Quando {device} inizia a chiudersi`)},{value:`closed`,label:P(`Closed`,`Chiuso`),phrase:P(`When {device} is fully closed`,`Quando {device} è tutto chiuso`)},{value:`stopped`,label:P(`Stopped`,`Fermo`),phrase:P(`When {device} stops part-way`,`Quando {device} si ferma a metà`)}],icon:`blinds`},{kind:`numeric`,field:`position`,quantity:P(`the opening`,`l’apertura`),label:P(`Position`,`Posizione`),unit:`%`,icon:`blinds`}],overrides:{byRole:{[D.CoverGarage]:{actions:{"cover.open":{phrase:P(`Open the garage door {device}`,`Apri il garage {device}`),icon:`warehouse`},"cover.close":{phrase:P(`Close the garage door {device}`,`Chiudi il garage {device}`),icon:`warehouse`}}},[D.CoverGate]:{actions:{"cover.open":{phrase:P(`Open the gate {device}`,`Apri il cancello {device}`),icon:`fence`},"cover.close":{phrase:P(`Close the gate {device}`,`Chiudi il cancello {device}`),icon:`fence`}}},[D.CoverDoor]:{actions:{"cover.open":{phrase:P(`Open the door {device}`,`Apri la porta {device}`),icon:`door-open`},"cover.close":{phrase:P(`Close the door {device}`,`Chiudi la porta {device}`),icon:`door-closed`}}},[D.CoverWindow]:{actions:{"cover.open":{phrase:P(`Open the window {device}`,`Apri la finestra {device}`),icon:`app-window`},"cover.close":{phrase:P(`Close the window {device}`,`Chiudi la finestra {device}`),icon:`app-window`}}},[D.CoverShutter]:{actions:{"cover.open":{phrase:P(`Raise the shutter {device}`,`Alza la tapparella {device}`)},"cover.close":{phrase:P(`Lower the shutter {device}`,`Abbassa la tapparella {device}`)}}},[D.CoverAwning]:{actions:{"cover.open":{phrase:P(`Extend the awning {device}`,`Apri la tenda da sole {device}`)},"cover.close":{phrase:P(`Retract the awning {device}`,`Chiudi la tenda da sole {device}`)}}}}}}},cA=b({stepId:l(),entry:ng}),lA=b({path:l().min(1),bytes:n().int().nonnegative(),sha256:l().regex(/^[0-9a-f]{64}$/)}),uA=b({addonId:l(),stepId:l().min(1),entries:S(ng).min(1).max(4),bundle:b({ticket:Ti,bytes:n().int().positive(),sha256:l().regex(/^[0-9a-f]{64}$/)}),files:S(lA).min(1).max(64),distribute:v()}),dA=i(`kind`,[b({kind:p(`imported`),modelIds:S(l()).readonly(),distributed:S(b({modelId:l(),nodeId:l(),format:x(Pa),ok:v(),error:l().optional()})).readonly()}),b({kind:p(`refused`),reason:x([`transfer-failed`,`checksum-mismatch`,`bundle-mismatch`,`invalid-entry`,`id-taken`]),detail:l()})]),fA={name:`custom-model-registry`,scope:`system`,mode:`collection`,internal:!0,methods:{listModels:k(_(),S(cA).readonly(),{auth:`admin`}),importModelBundle:k(uA,dA,{kind:`mutation`,auth:`admin`,timeoutMs:30*6e4})},vocabulary:{notOperatorFacing:j.ML}},pA=b({engineId:l(),kind:x([`relational`,`vector`]),displayName:l()}),mA={name:`data-store-provider`,scope:`system`,mode:`collection`,internal:!0,methods:{getEngineInfo:k(_(),pA,{auth:`admin`}),get:k(b({namespace:l().optional(),collection:l(),key:l()}),C(),{auth:`admin`}),set:k(b({namespace:l().optional(),collection:l(),key:l(),value:C()}),_(),{kind:`mutation`,auth:`admin`}),query:k(b({namespace:l().optional(),collection:l(),filter:ff.optional(),columns:S(l()).readonly().optional()}),S(gf).readonly(),{auth:`admin`}),insert:k(b({namespace:l().optional(),collection:l(),record:b({id:l().optional(),data:m(l(),C())})}),b({id:h([l(),n()])}),{kind:`mutation`,auth:`admin`}),upsert:k(b({namespace:l().optional(),collection:l(),conflict:S(l()).readonly(),record:_f}),b({id:h([l(),n()])}),{kind:`mutation`,auth:`admin`}),upsertMany:k(b({namespace:l().optional(),collection:l(),conflict:S(l()).readonly(),records:S(_f).readonly()}),b({upserted:n().int()}),{kind:`mutation`,auth:`admin`}),insertMany:k(b({namespace:l().optional(),collection:l(),records:S(_f).readonly()}),b({inserted:n().int()}),{kind:`mutation`,auth:`admin`}),transact:k(b({namespace:l().optional(),guard:bf.optional(),ops:S(yf).readonly()}),b({applied:v(),current:C().optional()}),{kind:`mutation`,auth:`admin`}),update:k(b({namespace:l().optional(),collection:l(),id:l(),data:m(l(),C())}),_(),{kind:`mutation`,auth:`admin`}),delete:k(b({namespace:l().optional(),collection:l(),key:l()}),_(),{kind:`mutation`,auth:`admin`}),deleteWhere:k(b({namespace:l().optional(),collection:l(),filter:pf}),b({deleted:n().int()}),{kind:`mutation`,auth:`admin`}),updateWhere:k(b({namespace:l().optional(),collection:l(),filter:pf,data:m(l(),C())}),b({updated:n().int()}),{kind:`mutation`,auth:`admin`}),count:k(b({namespace:l().optional(),collection:l(),filter:ff.optional()}),n(),{auth:`admin`}),aggregate:k(b({namespace:l().optional(),collection:l(),fields:S(mf).readonly(),filter:ff.optional()}),hf,{auth:`admin`}),histogram:k(b({namespace:l().optional(),collection:l(),field:l(),bucketSize:n().int().positive(),origin:n().int(),filter:ff.optional()}),S(b({bucket:n().int(),count:n().int()})).readonly(),{auth:`admin`}),isEmpty:k(b({namespace:l().optional(),collection:l()}),v(),{auth:`admin`}),declareCollection:k(Cf,_(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:j.INTERNAL}},hA=x([`auto`,`day`,`night`,`schedule`]),gA=b({min:n(),max:n(),step:n()}),_A=b({mode:hA,sensitivity:n().optional().meta(M(`none`)),switchDelaySec:n().optional().meta(M(`duration`)),lastFetchedAt:n()}),vA=b({modes:S(hA),supportsSensitivity:v(),sensitivity:gA.optional(),supportsSwitchDelay:v(),switchDelaySec:gA.optional()}),yA=b({mode:hA.optional(),sensitivity:n().optional(),switchDelaySec:n().optional()}),bA={name:`day-night`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Camera],deviceConfig:{ui:{kind:`derived-form`,builderId:`day-night`,tab:`image`}},methods:{getOptions:k(b({deviceId:n()}),vA),setSettings:k(b({deviceId:n(),settings:yA}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`dayNight.auto`,label:P(`Day/night auto`,`Giorno/notte automatico`),phrase:P(`Let {device} switch day and night by itself`,`Fai passare {device} da giorno a notte in automatico`),icon:`sun-moon`,args:{settings:{mode:`auto`}}},{id:`dayNight.day`,label:P(`Day mode`,`Modalità giorno`),phrase:P(`Force {device} into day mode`,`Forza {device} in modalità giorno`),icon:`sun`,args:{settings:{mode:`day`}}},{id:`dayNight.night`,label:P(`Night mode`,`Modalità notte`),phrase:P(`Force {device} into night mode`,`Forza {device} in modalità notte`),icon:`moon`,args:{settings:{mode:`night`}}}]})},status:{schema:_A,kind:`poll`},runtimeState:_A,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:P(`Day/night`,`Giorno/notte`),order:3070,state:[{kind:`enum`,field:`mode`,label:P(`Day/night mode`,`Modalità giorno/notte`),values:[{value:`auto`,label:P(`Automatic`,`Automatica`)},{value:`day`,label:P(`Day`,`Giorno`),phrase:P(`When {device} switches to day mode`,`Quando {device} passa in modalità giorno`)},{value:`night`,label:P(`Night`,`Notte`),phrase:P(`When {device} switches to night mode`,`Quando {device} passa in modalità notte`)},{value:`schedule`,label:P(`Scheduled`,`Programmata`)}],icon:`sun-moon`}]}},lSe=[{value:`auto`,label:`Auto (defer to probed best)`},{value:`none`,label:`Off (software)`},{value:`videotoolbox`,label:`VideoToolbox (macOS)`},{value:`cuda`,label:`CUDA (NVIDIA)`},{value:`nvdec`,label:`NVDEC (NVIDIA legacy)`},{value:`vaapi`,label:`VAAPI (Linux Intel/AMD)`},{value:`qsv`,label:`QuickSync (Intel)`},{value:`d3d11va`,label:`D3D11VA (Windows)`},{value:`dxva2`,label:`DXVA2 (Windows legacy)`},{value:`amf`,label:`AMF (AMD)`},{value:`vdpau`,label:`VDPAU (Linux NVIDIA legacy)`},{value:`drm`,label:`DRM (Linux generic)`}],uSe={hwaccel:`auto`,probedBestHwaccel:``},xA={name:`decoder`,scope:`system`,mode:`singleton`,preferredProvider:`decoder-nodeav`,methods:{getInfo:k(_(),b({id:l(),name:l(),hwaccel:l().optional(),probedBestHwaccel:l().optional()})),reprobeHwaccel:k(_(),b({backend:l()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:j.PIPELINE}},SA={name:`detection-pipeline`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[T.Camera],exposesDeviceSettings:!0,methods:{},vocabulary:{noun:P(`Detection pipeline`,`Pipeline di rilevamento`),order:3080}},CA=x([`device`,`integration`]),wA=b({url:l(),label:l(),target:CA,host:l()}),TA={name:`device-admin-link`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{getAdminLink:k(b({deviceId:n().int().nonnegative()}),wA.nullable(),{auth:`admin`})},vocabulary:{noun:P(`Admin link`,`Link di amministrazione`),order:3090}},EA=x([`online`,`sleeping`,`offline`,`unknown`]),DA=a(()=>b({childNativeId:l(),name:l(),type:x(T),status:EA,metadata:b({model:l().optional(),serialNumber:l().optional(),uid:l().optional(),rtspChannel:n().int().nonnegative().optional(),isBattery:v().optional(),isDoorbell:v().optional(),isMultifocal:v().optional(),externalLocation:l().optional(),manufacturer:l().optional(),integration:l().optional()}).default({}),alreadyAdopted:v(),adoptedDeviceId:n().int().nonnegative().nullable(),capabilities:S(l()).readonly().optional(),features:S(l()).readonly().optional(),sourceInfo:Yg.optional(),children:S(DA).readonly().optional(),parentStableId:l().optional()})),OA=b({id:l(),label:l(),isDefault:v().optional()}),kA=b({search:l().optional(),area:l().optional(),manufacturer:l().optional(),adoptedOnly:v().optional(),unadoptedOnly:v().optional()}),AA=b({integrationId:l(),page:n().int().positive().default(1),pageSize:n().int().positive().max(2e4).default(50),filter:l().optional(),filterText:kA.optional()}),jA=b({candidates:S(DA).readonly(),totalCount:n().int().nonnegative(),page:n().int().positive(),pageSize:n().int().positive()}),MA=b({integrationId:l(),childNativeId:l()}),NA=b({lastDiscoveryAt:n().int().nonnegative().nullable(),candidateCount:n().int().nonnegative(),adoptedCount:n().int().nonnegative(),lastError:l().nullable()}),dSe=b({name:l().min(1).optional(),hiddenChildIds:S(l()).optional()}),PA=b({integrationId:l(),childNativeIds:S(l()).min(1),filter:l().optional(),importLocations:v().optional(),perCandidate:m(l(),dSe).optional()}),FA=b({adopted:S(b({childNativeId:l(),parentDeviceId:n().int().nonnegative(),accessoryDeviceIds:S(n().int().nonnegative()).readonly()})).readonly()}),IA=b({integrationId:l(),camDeviceId:n().int().nonnegative()}),LA=b({camDeviceId:n().int().nonnegative(),resetToSource:v().optional()}),RA=b({changed:v(),rebuiltChildren:n().int().nonnegative(),removedChildren:n().int().nonnegative().optional()}),zA={name:`device-adoption`,scope:`system`,mode:`collection`,status:{schema:NA,kind:`poll`},methods:{listCandidateFilters:k(b({integrationId:l()}),b({filters:S(OA)}),{auth:`admin`}),listCandidates:k(AA,jA,{auth:`admin`}),getCandidate:k(MA,DA.nullable(),{auth:`admin`}),refresh:k(b({integrationId:l()}),NA,{kind:`mutation`,auth:`admin`}),adopt:k(PA,FA,{kind:`mutation`,auth:`admin`}),release:k(IA,_(),{kind:`mutation`,auth:`admin`}),resync:k(LA,RA,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`device adoption — an onboarding flow, not an action`}},BA=i(`state`,[b({state:p(`absent`)}),b({state:p(`ready`),subject:l(),fingerprintSha256:l(),validTo:l()}),b({state:p(`unavailable`),reason:l()})]),VA=b({selfEnrollment:x([`allowed`,`disabled`])}),HA={name:`device-credentials`,scope:`system`,mode:`singleton`,methods:{listDeviceCredentials:k(b({userId:l().min(1).optional(),includeRevoked:v().default(!1)}),S($pe).readonly(),{auth:`admin`}),startEnrollment:k(b({userId:l().min(1),deviceName:l().min(1).max(80)}),eme,{kind:`mutation`,auth:`admin`,caller:`required`}),revokeDeviceCredential:k(b({id:l().min(1)}),b({revoked:v(),sessionsEnded:n().int(),status:Cg}),{kind:`mutation`,auth:`admin`,caller:`required`}),getDeviceCertificateSettings:k(b({}),VA,{auth:`admin`}),setDeviceCertificateSettings:k(VA,VA,{kind:`mutation`,auth:`admin`}),deleteDeviceCredential:k(b({id:l().min(1)}),b({result:x([`deleted`,`live`,`unknown`])}),{kind:`mutation`,auth:`admin`,caller:`required`}),getDeviceCaStatus:k(b({}),BA,{auth:`admin`}),renameDeviceCredential:k(b({id:l().min(1),deviceName:l().min(1).max(80)}),b({renamed:v()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:j.IDENTITY}},fSe=64,UA=/^[a-z][a-z0-9_]*$/,pSe=new Set(`true.false.none.null.and.or.not.in.is.if.elif.else.endif.for.endfor.loop.set.range.cycler.joiner.self.caller.super.import.include.extends.block.macro.now.camera`.split(`.`)),WA=l().max(64).regex(UA);function GA(e){return pSe.has(e)}function KA(e){let t=e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``);return t.length===0?`device`:(/^[0-9]/.test(t)?`device_${t}`:t).slice(0,60).replace(/_+$/g,``)}function mSe(e,t){let n=KA(e);if(!GA(n)&&!t(n))return n;for(let e=2;;e+=1){let r=`${n}_${e}`;if(!t(r))return r}}function hSe(e,t){return e.length===0?{ok:!1,reason:`empty`}:e.length>64?{ok:!1,reason:`too-long`}:UA.test(e)?GA(e)?{ok:!1,reason:`reserved`}:t(e)?{ok:!1,reason:`taken`}:{ok:!0,alias:e}:{ok:!1,reason:`grammar`}}var qA=4096,gSe=50,_Se=4096,vSe=`—`,JA=l().min(1).max(qA),ySe=`now`,bSe=`camera`,YA=h([l(),n(),v()]),XA=b({deviceId:n().int(),values:m(l().min(1).max(64),YA).optional()}),xSe=`values`,SSe=su(),ZA=[`too-long`,`syntax`,`forbidden-syntax`,`forbidden-member`,`unknown-filter`,`ambiguous-field`,`busy`,`budget-exceeded`,`timeout`,`output-too-large`,`render-failed`,`out-of-scope`,`unavailable`],QA=b({reason:x(ZA),message:l()}),$A=[`unknown-alias`,`unknown-field`,`no-field`,`unavailable`],ej=b({ref:l(),reason:x($A)}),tj=i(`ok`,[b({ok:p(!0),text:l(),trace:S(ej)}),b({ok:p(!1),refusal:QA,trace:S(ej)})]);function nj(e){return e.replace(/-/g,`_`)}function rj(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ij(e,t){let n=e;for(let e of t)if(Array.isArray(n)&&typeof e==`number`)n=n[e];else if(rj(n)&&Object.hasOwn(n,String(e)))n=n[String(e)];else return;return n}function CSe(e,t){let n=t[0];if(n===void 0)return{kind:`missing`,reason:`no-field`};let r=Object.keys(e.slices),i=r.find(e=>e===n||nj(e)===n);if(i!==void 0){let n=t.slice(1);if(n.length===0)return{kind:`missing`,reason:`no-field`};let r=ij(e.slices[i],n);return r===void 0?{kind:`missing`,reason:`unknown-field`}:{kind:`value`,cap:i,fieldPath:n,value:r}}let a=r.filter(t=>{let r=e.slices[t];return rj(r)&&Object.hasOwn(r,String(n))});if(a.length===0)return{kind:`missing`,reason:`unknown-field`};let[o]=a;if(a.length>1||o===void 0)return{kind:`ambiguous`,field:String(n),caps:a};let s=ij(e.slices[o],t);return s===void 0?{kind:`missing`,reason:`unknown-field`}:{kind:`value`,cap:o,fieldPath:t,value:s}}var aj=b({zoneKey:l(),label:l(),icon:Ih.nullable(),locationKeys:S(l())});function wSe(e){return e.trim().toLowerCase()}var oj=[`mac`,`serial`,`machine-uuid`,`vendor-uid`,`hostname`,`ip`],sj=x(oj),cj=x([`read`,`derived`]),TSe=/^[0-9a-f]{2}(?::[0-9a-f]{2}){5}$/,lj=/^[a-z0-9][a-z0-9._-]*:[^\sA-Z]+$/,uj=/^[0-9a-f][0-9a-f-]{7,}$/,dj=/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;function fj(e){return b({value:e,origin:cj,readAt:n().int().nonnegative()}).strict()}var ESe=fj(l().regex(TSe)),DSe=fj(l().regex(lj)),OSe=fj(l().regex(uj)),kSe=fj(l().regex(lj)),ASe=fj(l().regex(dj)),jSe=fj(h([ee(),o()])),MSe=b({value:l().min(1),origin:cj,readAt:n().int().nonnegative()}).strict(),pj=b({mac:S(ESe).min(1).readonly().optional(),serial:DSe.optional(),"machine-uuid":OSe.optional(),"vendor-uid":kSe.optional(),hostname:ASe.optional(),ip:jSe.optional()}).strict(),NSe={mac:`strong`,serial:`strong`,"machine-uuid":`strong`,"vendor-uid":`strong`,hostname:`weak`,ip:`weak`};function PSe(e){return NSe[e]}function mj(e){return oj.every(t=>e[t]===void 0)}var FSe=/^(?:unknown|none|n\/?a|null|undefined|default|0+|-+)$/i,ISe=new Set([`00:00:00:00:00:00`,`ff:ff:ff:ff:ff:ff`]);function hj(e){return{ok:!1,reason:e}}function gj(e){let t=e.trim().toLowerCase().replace(/[\s:.-]/g,``);if(!/^[0-9a-f]{12}$/.test(t))return hj(`not a 48-bit MAC`);let n=(t.match(/../g)??[]).join(`:`);return ISe.has(n)?hj(`placeholder MAC`):{ok:!0,value:n}}function LSe(e){return e.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,`-`).replace(/^[-._]+|[-._]+$/g,``)}function _j(e,t,n){let r=LSe(e);if(r.length===0)return hj(`no ${n}`);let i=t.trim().toLowerCase().replace(/\s+/g,``);return i.length===0?hj(`blank value`):FSe.test(i)?hj(`placeholder value`):{ok:!0,value:`${r}:${i}`}}function RSe(e){let t=e.trim().toLowerCase().replace(/^\{|\}$/g,``);return uj.test(t)?/^[0-]+$/.test(t)||/^[f-]+$/.test(t)?hj(`placeholder uuid`):{ok:!0,value:t}:hj(`not a uuid`)}function vj(e){return h([ee(),o()]).safeParse(e).success}function zSe(e){let t=e.trim().toLowerCase().replace(/\.$/,``);if(t.length===0)return hj(`blank hostname`);if(vj(t))return hj(`an address, not a hostname`);let n=t.split(`.`)[0]??``;return dj.test(n)?n===`localhost`?hj(`placeholder hostname`):{ok:!0,value:n}:hj(`not a hostname`)}function BSe(e){let t=e.trim().toLowerCase().replace(/^\[|\]$/g,``);return vj(t)?t===`0.0.0.0`||t===`::`||t===`::1`||t.startsWith(`127.`)?hj(`loopback or unspecified address`):{ok:!0,value:t}:hj(`not an IP address`)}function yj(e){return e==null||e.trim().length===0}function bj(e,t={}){let n=t.readAt??Date.now(),r=e=>t.originByKey?.[e]??t.origin??`read`,i=(e,t)=>({value:t,origin:r(e),readAt:n}),a=[],o=(e,t,n)=>{if(n.ok)return i(e,n.value);a.push({key:e,value:t,reason:n.reason})},s=e.mac===null||e.mac===void 0?[]:[e.mac].flat(),c=[];for(let e of s){if(yj(e))continue;let t=o(`mac`,e,gj(e));t!==void 0&&!c.some(e=>e.value===t.value)&&c.push(t)}let l=e.serial===null||e.serial===void 0||yj(e.serial.serial)?void 0:o(`serial`,`${e.serial.manufacturer}:${e.serial.serial}`,_j(e.serial.manufacturer,e.serial.serial,`manufacturer`)),u=e.vendorUid===null||e.vendorUid===void 0||yj(e.vendorUid.id)?void 0:o(`vendor-uid`,`${e.vendorUid.vendor}:${e.vendorUid.id}`,_j(e.vendorUid.vendor,e.vendorUid.id,`vendor`)),d=yj(e.machineUuid)?void 0:o(`machine-uuid`,e.machineUuid,RSe(e.machineUuid)),f=yj(e.host)?null:e.host.trim(),p=f!==null&&vj(f.toLowerCase().replace(/^\[|\]$/g,``)),m=yj(e.hostname)?p?null:f:e.hostname,h=yj(e.ip)?p?f:null:e.ip,g=m===null?void 0:o(`hostname`,m,zSe(m)),ee=h===null?void 0:o(`ip`,h,BSe(h));return{identifiers:{...c.length>0?{mac:c}:{},...l===void 0?{}:{serial:l},...d===void 0?{}:{"machine-uuid":d},...u===void 0?{}:{"vendor-uid":u},...g===void 0?{}:{hostname:g},...ee===void 0?{}:{ip:ee}},rejected:a}}function xj(e,t){return e.value===t.value&&e.origin===t.origin}function Sj(e,t){return t!==void 0&&xj(e,t)?t:e}function VSe(e,t,n=[]){let r=e??{},i=t??{},a=new Set(n),o=a.has(`mac`)?r.mac:i.mac?.map(e=>Sj(e,r.mac?.find(t=>xj(t,e)))),s=e=>{if(a.has(e))return r[e];let t=i[e];return t===void 0?void 0:Sj(t,r[e])},c=s(`serial`),l=s(`machine-uuid`),u=s(`vendor-uid`),d=s(`hostname`),f=s(`ip`),p={...o!==void 0&&o.length>0?{mac:o}:{},...c===void 0?{}:{serial:c},...l===void 0?{}:{"machine-uuid":l},...u===void 0?{}:{"vendor-uid":u},...d===void 0?{}:{hostname:d},...f===void 0?{}:{ip:f}};return mj(p)?null:p}function HSe(e,t){let n=e=>e==null||mj(e)?``:JSON.stringify(oj.map(t=>[t,e[t]??null]).map(([e,t])=>[e,t===null?null:[t].flat().map(e=>[e.value,e.origin,e.readAt])]));return n(e)===n(t)}var Cj=x([`auto`,`proposal`]),wj=b({key:sj,value:l()}),Tj=b({deviceId:n().int(),addonId:l(),integrationId:l().nullable()}),Ej=b({a:Tj,b:Tj,keys:S(wj).readonly(),confidence:Cj}),Dj=i(`status`,[b({status:p(`unknown`),reason:l()}),b({status:p(`answered`),pairs:S(Ej).readonly(),undeclaredDeviceIds:S(n().int()).readonly()})]),Oj=[`same-device`,`poe-power`],kj=x(Oj),Aj=x([`proposed`,`linked`,`dismissed`]),jj=x([`auto`,`operator`]),Mj=b({addonId:l().min(1),stableId:l().min(1),deviceId:n().int()}),Nj=b({kind:kj,a:Mj,b:Mj,state:Aj,origin:jj,evidence:S(wj).readonly(),evidenceGone:p(!0).optional(),createdAt:n().int().nonnegative(),decidedAt:n().int().nonnegative().optional()}),Pj=Nj.extend({id:l().min(1)}),Fj={"same-device":{directional:!1,attachingRole:null,contributions:[]},"poe-power":{directional:!0,attachingRole:D.PoePort,contributions:[{cap:`power-source`,targetId:`switch`,host:`b`,source:`a`,sourceCap:`switch`,sourceField:`on`}]}};function USe(e,t){let n=Fj[e].attachingRole;return n===null||t===n?null:`attaching-side-role`}function Ij(e){return`${e.addonId}/${e.stableId}`}function WSe(e,t,n){let r=Ij(t),i=Ij(n);return Fj[e].directional||r<=i?`${e}:${r}|${i}`:`${e}:${i}|${r}`}var Lj=i(`status`,[b({status:p(`not-loaded`),reason:l()}),b({status:p(`answered`),links:S(Pj).readonly()})]),Rj=x([`not-loaded`,`unknown-link`,`wrong-state`]),zj=i(`ok`,[b({ok:p(!0),link:Pj}),b({ok:p(!1),reason:Rj,message:l()})]),Bj=x([`evidence-gone`,`device-removed`,`operator-unlinked`]),GSe=b({linkId:l(),kind:kj,aDeviceId:n().int(),bDeviceId:n().int(),origin:jj,reason:Bj.optional()}),KSe=50,qSe=200,Vj=b({caps:S(l()).readonly().optional(),actions:S(l()).readonly().optional(),mode:x([`any`,`all`]).optional()}),Hj=b({locations:S(l()).readonly().optional(),integrationIds:S(l()).readonly().optional(),types:S(l()).readonly().optional()}),Uj=b({text:l().optional(),requires:Vj.optional(),filters:Hj.optional(),includeIncompatible:v().optional(),contextDeviceId:n().optional(),ids:S(n()).readonly().optional(),cursor:l().nullable().optional(),limit:n().int().min(1).max(200).optional()}),Wj=b({cap:l(),path:l(),label:l(),reading:l().nullable(),unit:l().nullable().optional(),quantity:da.optional()}),Gj=b({id:n(),name:l(),type:x(T),location:l().nullable(),integrationId:l().nullable(),integrationLabel:l().nullable(),online:v().nullable(),disabled:v(),compatible:v(),values:S(Wj).readonly()}),Kj=b({value:l(),count:n()}),qj=b({id:l(),label:l(),count:n()}),Jj=b({locations:S(Kj).readonly(),integrations:S(qj).readonly(),types:S(Kj).readonly()}),Yj=b({items:S(Gj).readonly(),nextCursor:l().nullable(),total:n(),compatibleTotal:n(),fleetTotal:n(),hiddenIncompatible:n(),facets:Jj,suggested:S(Gj).readonly(),missingIds:S(n()).readonly()}),Xj=b({connected:v(),deviceCount:n(),error:l().optional(),motionSliceWriter:p(`orchestrator`).optional()}),JSe=b({externalId:l(),name:l(),type:l(),metadata:m(l(),C()).optional()}),Zj=i(`kind`,[b({kind:p(`mdns`),serviceType:l().min(1),instancePattern:l().optional()}),b({kind:p(`ws-discovery`),types:S(l()).optional()}),b({kind:p(`ssdp`),searchTarget:l().min(1)}),b({kind:p(`udp-broadcast`),port:n().int().min(1).max(65535),payloadHex:l().regex(/^([0-9a-fA-F]{2})*$/),listenPort:n().int().min(1).max(65535).optional()}),b({kind:p(`http-probe`),port:n().int().min(1).max(65535),path:l().startsWith(`/`),method:x([`GET`,`POST`]).default(`GET`),bodyText:l().optional(),contentType:l().optional(),tls:v().default(!1),acceptStatus:S(n().int()).optional()}),b({kind:p(`custom`),reason:l().min(1)})]),Qj=b({modeIndex:n().int().min(0),host:l(),port:n().int(),http:b({status:n().int(),headers:m(l(),l()),bodyText:l()}).optional(),mdns:b({instance:l(),host:l(),port:n().int(),txt:m(l(),l())}).optional(),udp:b({payloadHex:l()}).optional(),wsd:b({xaddrs:S(l()),types:S(l()),scopes:S(l())}).optional()}),$j=b({stableId:l(),type:x(T),suggestedName:l(),prefilledConfig:m(l(),C()),sourceInfo:Yg.optional(),alreadyOnboarded:v().optional(),onboardedDeviceId:n().optional(),onboardedName:l().optional(),setupIntegration:v().optional(),parentStableId:l().optional(),selectable:v().optional(),needsParams:S(l()).optional()}),eM=b({id:n(),stableId:l(),addonId:l(),type:l(),name:l(),parentDeviceId:n().nullable(),online:v(),features:S(l()),config:m(l(),C()),sourceInfo:Yg.optional()}),tM=b({status:x([`ok`,`error`]),labels:S(l()).optional(),error:l().optional()}),nM=C(),rM={name:`device-provider`,scope:`system`,mode:`collection`,methods:{start:k(_(),_(),{kind:`mutation`}),stop:k(_(),_(),{kind:`mutation`}),getStatus:k(_(),Xj),getDevices:k(_(),S(b({id:l(),name:l(),type:l()}))),reloadDevice:k(b({stableId:l()}),b({deviceId:n()}),{kind:`mutation`,timeoutMs:3*6e4}),supportsDiscovery:k(b({}),v()),discoverDevices:k(b({params:m(l(),C()).optional()}),S($j),{kind:`mutation`,auth:`admin`}),getDiscoveryModes:k(b({}),S(Zj)),classifyDiscoveryHits:k(b({hits:S(Qj),params:m(l(),C()).optional()}),S($j),{kind:`mutation`,auth:`admin`}),getDiscoveryParamsSchema:k(b({}),nM),getManualCreationType:k(b({integrationId:l().optional()}),b({deviceType:x(T).nullable()})),adoptDiscoveredDevice:k(b({candidate:$j,integrationId:l().optional()}),eM,{kind:`mutation`,auth:`admin`}),supportsManualCreation:k(b({}),v()),getChildCreationSchema:k(b({type:x(T),integrationId:l().optional()}),nM),createDevice:k(b({type:x(T),config:m(l(),C()),integrationId:l().optional()}),eM,{kind:`mutation`,auth:`admin`}),testCreationField:k(b({type:x(T),key:l(),value:C(),formValues:m(l(),C()).optional()}),tM,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:j.INTERNAL}},iM=i(`kind`,[b({kind:p(`mdns`),serviceType:l(),instance:l(),host:l(),address:l().nullable(),port:n().int(),txt:m(l(),l())}),b({kind:p(`ssdp`),host:l(),port:n().int(),target:l(),headers:m(l(),l())})]),YSe=b({addonId:l(),candidate:$j,firstSeenAt:n(),lastSeenAt:n(),dismissed:v()}),aM=b({id:l(),addonId:l(),candidate:$j,firstSeenAt:n(),lastSeenAt:n(),dismissed:v()}),oM=b({childKey:l(),section:l(),order:n().optional(),collapsed:v().optional()}),XSe=b({unit:l().min(1).optional(),precision:n().int().min(0).max(10).optional()}),sM=b({icon:l().min(1).optional(),label:l().min(1).optional(),unit:l().min(1).optional(),precision:n().int().min(0).max(10).optional(),hidden:v().optional(),perCap:m(l(),XSe).optional()}),cM=b({unit:l().min(1).optional(),precision:n().int().min(0).max(10).optional(),icon:l().min(1).optional()}),lM=b({id:n(),stableId:l(),addonId:l(),type:x(T),name:l(),alias:WA.optional(),location:l().nullable(),tags:Vh.optional(),disabled:v(),parentDeviceId:n().nullable(),role:l().nullable().optional(),online:v(),probed:v().optional(),features:S(l()),isCamera:v(),config:m(l(),C()),secretConfigPaths:S(l()).optional(),metadata:m(l(),C()).nullable().optional(),identifiers:pj.optional(),attachedIdentifiers:pj.optional(),sourceInfo:Yg.optional(),integrationId:l().optional(),linkDeviceId:n().nullable().optional(),primaryChildEntityId:l().nullable().optional(),childLayout:S(oM).readonly().optional(),primaryChildPreference:S(l()).readonly().optional(),display:sM.optional()}),uM=b({key:l(),value:C(),description:l().optional()}),dM=x([`manual`]),fM=b({deviceId:n(),name:l(),location:l().nullable(),features:S(l()),producesTrackedEvents:v().optional()}),pM=b({deviceIds:S(n().int().positive()),trackedDeviceIds:S(n().int().positive()).optional()}),mM={id:`linked-devices`,label:`Linked devices`,description:`Companion devices of this camera: their controls appear with it, and the ones you opt in produce tracked events on it.`,shape:`association`,hostDeviceTypes:[T.Camera],sourceCaps:`any`,cardinality:`many`,value:pM},ZSe=b({deviceId:n(),mode:dM,devices:S(fM)}),hM=b({deviceId:n(),entries:S(b({capName:l(),kind:x([`native`,`wrapped`]),providerAddonId:l(),providerNodeId:l(),nativeAddonId:l(),implementedMethods:S(l()).optional()}))}),gM=i(`kind`,[b({kind:p(`value`),wrapperAddonId:l().nullable()}),b({kind:p(`missing`)}),b({kind:p(`failed`),error:l()})]),QSe=b({id:n(),stableId:l(),type:l(),name:l(),location:l().nullable(),tags:Vh.optional(),disabled:v(),parentDeviceId:n().nullable(),role:l().nullable().optional()}),$Se=b({id:n(),stableId:l(),addonId:l(),type:l(),name:l(),userNamed:v().optional(),location:l().nullable(),tags:Vh.optional(),disabled:v(),parentDeviceId:n().nullable(),metadata:m(l(),C()).nullable().optional(),identifiers:pj.optional(),attachedIdentifiers:pj.optional(),sourceInfo:Yg.optional(),integrationId:l().optional(),linkDeviceId:n().nullable().optional(),primaryChildEntityId:l().nullable().optional(),childLayout:S(oM).readonly().optional(),primaryChildPreference:S(l()).readonly().optional(),role:l().nullable().optional(),display:sM.optional()}),eCe=C().nullable(),tCe=b({streamId:l(),width:n().optional(),height:n().optional(),codec:l().optional(),fps:n().optional(),bitrateKbps:n().optional()}),nCe=b({addonId:l(),stableId:l(),id:n(),type:l(),name:l(),location:l().nullable().optional(),disabled:v().optional(),parentDeviceId:n().nullable(),role:l().nullable().optional(),features:S(l()).optional(),config:m(l(),C()),secretConfigPaths:S(l()).optional()}),_M=b({deviceId:n().int().positive(),deletedAt:n(),providerAddonId:l()}),vM=2160*60*60*1e3,yM=b({deviceId:n().int().positive(),stores:m(l(),n().int().nonnegative())}),bM=b({status:x([`skipped`,`dry-run`,`cleaned`]),reason:l().nullable(),devices:S(yM),unreachable:S(l())}),rCe=b({deviceId:n()}),iCe=b({deviceId:n(),data:m(l(),C()),secretConfigPaths:S(l()).optional()}),xM=x([`off`,`on`,`not-offered`,`unreachable`]),SM=b({deviceId:n(),switchId:Qd,outcome:xM,detail:l().optional()}),CM=b({sourceId:n(),targetId:n(),switches:S(SM).readonly(),sourceStillLive:S(Qd).readonly(),swapped:v()}),wM={name:`device-manager`,scope:`system`,mode:`singleton`,extensionSlots:[mM],methods:{allocateDeviceId:k(b({addonId:l(),stableId:l()}),b({id:n()}),{kind:`mutation`}),migrateDevice:k(b({sourceId:n(),targetId:n()}),CM,{kind:`mutation`,auth:`admin`,timeoutMs:12*6e4}),registerDevice:k(nCe,_(),{kind:`mutation`}),removeDevice:k(rCe,_(),{kind:`mutation`}),persistConfig:k(iCe,_(),{kind:`mutation`,auth:`admin`}),loadConfig:k(b({deviceId:n()}),m(l(),C()),{auth:`admin`}),loadRuntimeState:k(b({deviceId:n()}),m(l(),C()),{auth:`admin`}),loadMeta:k(b({deviceId:n()}),$Se.nullable()),setName:k(b({deviceId:n(),name:l(),stampUserNamed:v().optional()}),_(),{kind:`mutation`,auth:`admin`}),setAlias:k(b({deviceId:n(),alias:l()}),i(`ok`,[b({ok:p(!0),alias:WA}),b({ok:p(!1),reason:x([`empty`,`too-long`,`grammar`,`reserved`,`taken`]),takenBy:n().optional()})]),{kind:`mutation`,auth:`admin`}),renderDeviceTemplates:k(b({templates:S(JA).max(64),allowedDeviceIds:S(n().int()).optional(),thisDevice:XA.optional()}),b({results:S(tj)}),{auth:`admin`}),checkDeviceTemplates:k(b({templates:S(l()).max(64),allowedDeviceIds:S(n().int()).optional(),thisDevice:XA.optional()}),b({results:S(i(`ok`,[b({ok:p(!0),aliases:S(b({alias:l(),deviceId:n().int().nullable(),allowed:v(),reads:S(l())})),readsClock:v()}),b({ok:p(!1),refusal:QA})]))}),{auth:`admin`}),setLocation:k(b({deviceId:n(),location:l().nullable()}),_(),{kind:`mutation`,auth:`admin`}),setTags:k(b({deviceId:n(),tags:Vh}),_(),{kind:`mutation`,auth:`admin`}),setType:k(b({deviceId:n(),type:x(T)}),_(),{kind:`mutation`,auth:`admin`}),setIntegrationId:k(b({deviceId:n(),integrationId:l()}),_(),{kind:`mutation`,auth:`admin`}),setLinkDeviceId:k(b({deviceId:n(),linkDeviceId:n().nullable()}),_(),{kind:`mutation`,auth:`admin`}),setPrimaryChildEntityId:k(b({deviceId:n(),primaryChildEntityId:l().nullable()}),_(),{kind:`mutation`,auth:`admin`}),setChildLayout:k(b({deviceId:n(),childLayout:S(oM).readonly()}),_(),{kind:`mutation`,auth:`admin`}),setPrimaryChildPreference:k(b({deviceId:n(),primaryChildPreference:S(l()).readonly()}),_(),{kind:`mutation`,auth:`admin`}),setDisplay:k(b({deviceId:n(),display:sM.nullable()}),_(),{kind:`mutation`,auth:`admin`}),getRoleDisplayDefaults:k(b({}),b({defaults:m(l(),cM)}),{role:`viewer`,kind:`query`}),setRoleDisplayDefaults:k(b({defaults:m(l(),cM)}),_(),{kind:`mutation`,auth:`admin`}),getWireableFields:k(b({deviceId:n(),includeSynthesizable:v().optional()}),b({caps:S(b({cap:l(),fields:S(b({path:l(),kind:x([`string`,`number`,`boolean`,`enum`,`union`]),unionMembers:S(x([`string`,`number`,`boolean`])).optional(),enumValues:S(l()).optional(),item:v().optional(),quantity:da.optional()})).readonly(),itemArray:b({path:l(),keyField:l()}).optional()})).readonly()}),{kind:`query`}),setRole:k(b({deviceId:n(),role:l().nullable()}),_(),{kind:`mutation`,auth:`admin`}),applyInitialMeta:k(b({deviceId:n(),name:l().optional(),location:l().nullable().optional(),tags:Vh.optional(),type:x(T).optional(),integrationId:l().optional(),linkDeviceId:n().nullable().optional(),role:l().nullable().optional()}),_(),{kind:`mutation`,auth:`admin`}),setMetadata:k(b({deviceId:n(),patch:m(l(),C())}),_(),{kind:`mutation`,auth:`admin`}),setIdentifiers:k(b({deviceId:n(),identifiers:pj.nullable(),unread:S(sj).optional()}),_(),{kind:`mutation`,auth:`admin`}),listIdentityCandidates:k(b({}),Dj,{kind:`query`,auth:`admin`}),setAttachedIdentifiers:k(b({deviceId:n(),identifiers:pj.nullable(),unread:S(sj).optional()}),_(),{kind:`mutation`,auth:`admin`}),listIdentityLinks:k(b({deviceId:n().int().optional()}),Lj,{kind:`query`,auth:`admin`}),confirmIdentityLink:k(b({linkId:l().min(1)}),zj,{kind:`mutation`,auth:`admin`}),dismissIdentityLink:k(b({linkId:l().min(1)}),zj,{kind:`mutation`,auth:`admin`}),unlinkIdentity:k(b({linkId:l().min(1)}),zj,{kind:`mutation`,auth:`admin`}),listLocations:k(_(),S(l())),addLocation:k(b({name:l()}),_(),{kind:`mutation`,auth:`admin`}),removeLocation:k(b({name:l(),cascade:v().optional()}),_(),{kind:`mutation`,auth:`admin`}),renameLocation:k(b({from:l(),to:l()}),b({moved:n()}),{kind:`mutation`,auth:`admin`}),listLocationIcons:k(_(),S(ume),{role:`viewer`}),setLocationIcon:k(b({location:l(),icon:Ih.nullable()}),_(),{kind:`mutation`,auth:`admin`}),listLocationDescriptions:k(_(),S(fme)),setLocationDescription:k(b({location:l(),description:l().max(400).nullable()}),_(),{kind:`mutation`,auth:`admin`}),listSiteZones:k(_(),S(aj),{role:`viewer`}),setSiteZone:k(b({name:l(),icon:Ih.nullable().optional()}),_(),{kind:`mutation`,auth:`admin`}),removeSiteZone:k(b({name:l()}),_(),{kind:`mutation`,auth:`admin`}),renameSiteZone:k(b({from:l(),to:l()}),_(),{kind:`mutation`,auth:`admin`}),setLocationZone:k(b({location:l(),zone:l().nullable()}),_(),{kind:`mutation`,auth:`admin`}),setDisabled:k(b({deviceId:n(),disabled:v()}),_(),{kind:`mutation`,auth:`admin`}),listPersistedByAddon:k(b({addonId:l()}),S(QSe)),listAll:k(b({addonId:l().optional(),projection:x([`full`,`slim`]).optional(),isCamera:v().optional(),deviceIds:S(n()).optional()}),S(lM),{role:`viewer`}),search:k(Uj,Yj,{role:`viewer`}),getDevice:k(b({deviceId:n()}),lM.nullable()),getChildren:k(b({parentDeviceId:n()}),S(lM),{role:`viewer`}),getChildrenBatch:k(b({parentDeviceIds:S(n()).max(256)}),m(l(),S(lM))),getLinkedDevices:k(b({deviceId:n()}),b({mode:dM,devices:S(fM)}),{role:`viewer`}),getLinkedDevicesBatch:k(b({deviceIds:S(n())}),S(ZSe),{role:`viewer`}),getStreamSources:k(b({deviceId:n()}),S(gne)),getConfigSchema:k(b({deviceId:n()}),S(uM)),getSettingsSchema:k(b({deviceId:n()}),eCe),updateConfig:k(b({deviceId:n(),values:m(l(),C())}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),enable:k(b({deviceId:n()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),disable:k(b({deviceId:n()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),remove:k(b({deviceId:n()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),listDeletedSince:k(b({sinceMs:n()}),S(_M).readonly(),{auth:`admin`}),cleanupDeletedDevicesData:k(b({confirm:v()}),bM,{kind:`mutation`,auth:`admin`}),removeByIntegration:k(b({integrationId:l()}),b({removed:n()}),{kind:`mutation`,auth:`admin`}),getStreamProfileMap:k(b({deviceId:n()}),m(l(),l().nullable())),setStreamProfileMap:k(b({deviceId:n(),profileMap:m(l(),l().nullable())}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),probeStreams:k(b({deviceId:n()}),S(tCe),{kind:`mutation`,auth:`admin`}),getBindings:k(b({deviceId:n()}),hM,{role:`viewer`}),getBindingsBatch:k(b({deviceIds:S(n())}),S(hM)),getAllBindings:k(b({}),S(hM)),listDeviceIdsByCaps:k(b({capNames:S(l().min(1)).min(1).max(16)}),S(n()),{role:`viewer`}),setWrapperActive:k(b({deviceId:n(),capName:l(),wrapperAddonId:l(),active:v()}),_(),{kind:`mutation`,auth:`admin`}),getWrapperActivation:k(b({deviceId:n(),capName:l().min(1)}),gM),listWrappersForCap:k(b({capName:l()}),S(l())),listBindableCapsForDeviceType:k(b({deviceType:l()}),S(b({capName:l(),wrappers:S(l())}))),getDeviceSettingsAggregate:k(b({deviceId:n()}),aS.nullable()),getDeviceLiveInfoAggregate:k(b({deviceId:n()}),aS.nullable(),{role:`viewer`}),getDeviceAggregate:k(b({deviceId:n()}),b({settings:aS.nullable(),live:aS.nullable()})),runDeviceAction:k(b({deviceId:n().int().nonnegative(),action:l().min(1),input:C()}),C(),{kind:`mutation`}),updateDeviceField:k(b({deviceId:n(),writerCapName:l(),writerAddonId:l(),key:l(),value:C()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),updateDeviceFieldsBatch:k(b({deviceId:n(),changes:S(b({writerCapName:l(),writerAddonId:l(),key:l(),value:C()}))}),b({success:p(!0),failures:S(b({writerCapName:l(),writerAddonId:l(),error:l()}))}),{kind:`mutation`,auth:`admin`}),discoverDevices:k(b({addonId:l()}),S($j),{kind:`mutation`,auth:`admin`}),adoptDevice:k(b({addonId:l(),candidate:$j,integrationId:l().optional()}),eM,{kind:`mutation`,auth:`admin`}),getCreationSchema:k(b({addonId:l(),type:x(T),integrationId:l().optional()}),C().nullable()),createDevice:k(b({addonId:l(),type:x(T),config:m(l(),C()),integrationId:l().optional()}),eM,{kind:`mutation`,auth:`admin`}),testCreationField:k(b({addonId:l(),type:x(T),key:l(),value:C(),formValues:m(l(),C()).optional()}),tM,{kind:`mutation`,auth:`admin`}),adoptionListCandidateFilters:k(b({addonId:l(),integrationId:l()}),b({filters:S(OA)}),{auth:`admin`}),adoptionListCandidates:k(AA.extend({addonId:l()}),jA,{auth:`admin`}),adoptionRefresh:k(b({addonId:l(),integrationId:l()}),NA,{kind:`mutation`,auth:`admin`}),adoptionAdopt:k(PA.extend({addonId:l()}),FA,{kind:`mutation`,auth:`admin`}),adoptionRelease:k(IA.extend({addonId:l()}),_(),{kind:`mutation`,auth:`admin`}),adoptionStartJob:k(PA.extend({addonId:l()}),b({jobId:l()}),{kind:`mutation`,auth:`admin`}),adoptionListJobs:k(b({addonId:l(),integrationId:l().optional()}),S(Zd).readonly(),{auth:`admin`}),adoptionCancelJob:k(b({jobId:l()}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`}),adoptionResync:k(LA,RA,{kind:`mutation`,auth:`admin`}),discoveryProviders:k(b({}),b({providers:S(b({addonId:l(),label:l()})).readonly()}),{auth:`admin`}),discoverAllProviders:k(b({subnets:S(l()).optional()}),b({groups:S(b({addonId:l(),label:l(),candidates:S($j).readonly(),error:l().nullable()})).readonly()}),{kind:`mutation`,auth:`admin`}),discoverProvider:k(b({addonId:l(),params:m(l(),C()).optional(),subnets:S(l()).optional()}),b({candidates:S($j).readonly()}),{kind:`mutation`,auth:`admin`}),listDiscoveryProposals:k(b({}),b({proposals:S(aM).readonly()}),{auth:`admin`}),dismissDiscoveryProposal:k(b({id:l()}),b({dismissed:v()}),{kind:`mutation`,auth:`admin`}),reportDiscoveryObservations:k(b({observations:S(iM).max(512)}),b({proposed:n().int()}),{kind:`mutation`,auth:`admin`}),runDiscoverySweep:k(b({}),b({providers:n().int(),proposed:n().int()}),{kind:`mutation`,auth:`admin`,timeoutMs:12e4}),providerCreationType:k(b({addonId:l(),integrationId:l().optional()}),b({deviceType:x(T).nullable()}),{auth:`admin`}),providerDiscoveryParamsSchema:k(b({addonId:l()}),C(),{auth:`admin`}),testField:k(b({deviceId:n(),key:l(),value:C()}),tM,{kind:`mutation`,auth:`admin`}),getDeviceStatusAggregate:k(b({deviceId:n(),caps:S(l()).readonly().optional()}),m(l(),C().nullable())),getDeviceStatusAggregateBatch:k(b({deviceIds:S(n()).readonly(),caps:S(l()).readonly().optional()}),m(l(),m(l(),C().nullable())),{role:`viewer`})},vocabulary:{notOperatorFacing:`the device registry itself — rename, move and remove are administration`}},TM=[`linked-devices`],EM=x(TM),DM={"linked-devices":{descriptor:mM,declaringCap:`device-manager`,hostDeviceTypes:[T.Camera]}},OM=i(`slot`,[pM.extend({slot:p(`linked-devices`)})]),kM=[T.Camera],aCe=`:`,oCe=`listSlots`,AM=i(`state`,[b({state:p(`ok`)}),b({state:p(`unreachable`),reason:l()})]),jM=b({source:l(),label:l(),addonId:l().optional(),availability:AM}),MM=x([`ok`,`missing`,`foreign`,`unavailable`]),NM=b({deviceId:n().int(),name:l().nullable(),health:MM,detail:l().optional()}),PM=b({state:x([`active`,`inactive`,`unknown`]),authority:l(),detail:l().optional()}),FM=b({state:p(`ok`),slotRef:l(),slot:EM,authority:l(),activation:PM.nullable(),value:OM,sources:S(NM),impliedSources:S(NM).optional()}),IM=b({state:p(`unreachable`),addonId:l(),reason:l()}),LM=i(`state`,[FM,IM]);function sCe(e,t){return{state:`unreachable`,addonId:e,reason:t}}var RM=b({deviceId:n().int(),name:l(),type:l(),location:l().nullable(),parentName:l().nullable(),suggested:v(),reason:l().nullable()}),zM=b({candidates:S(RM)}),BM=b({applied:p(!0),reload:x([`none`,`host`,`parent`])}),VM=b({deviceId:n().int(),slotRef:l().min(1)}),HM=VM.extend({value:OM}),UM={name:`device-extension`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:kM,deviceConfig:{ui:{kind:`widget`,widgetId:`host/extensions-panel`,tab:`general`,label:`Extensions`,order:72}},methods:{listSources:k(b({deviceId:n().int()}),S(jM)),listSlots:k(b({deviceId:n().int()}),S(LM)),listCandidates:k(VM,zM),setSlot:k(HM,BM,{kind:`mutation`,auth:`admin`})},vocabulary:{noun:P(`Device extension`,`Estensione del dispositivo`),order:3100}},WM=i(`kind`,[b({kind:p(`device`),deviceId:n().int()}),b({kind:p(`node`),nodeId:l().min(1)})]),GM=x([`gauge`,`counter`,`boolean`,`enum`]),KM=x([`gauge`,`counter`,`boolean`]),cCe=`derived:energy.kwh`,qM=x([`raw`,`5m`,`1h`,`1d`]),JM=x([`undeclared`,`not-owner`,`opted-out`,`not-a-real-device`,`rate`,`ingest-mismatch`,`out-of-range`]),lCe=b({key:l(),reason:JM,count:n().int()}),YM=b({accepted:n().int(),refused:S(lCe).readonly()}),XM=b({key:l(),scope:l(),kind:GM,unit:l().nullable(),displayName:l(),source:x([`cap`,`addon`,`derived`]),values:S(l()).readonly().nullable(),firstTs:n(),lastTs:n()}),uCe=b({t:n(),samples:n().int(),mean:n().nullable(),twMean:n().nullable(),min:n(),max:n(),last:n().nullable(),delta:n().nullable(),state:l().nullable(),states:m(l(),n()).nullable()}),dCe=b({scope:l(),before:b({t:n(),value:n().nullable(),state:l().nullable()}).nullable(),points:S(uCe).readonly(),derivedFrom:l().nullable()}),ZM={key:l(),scope:l().optional(),from:n(),to:n(),resolution:h([qM,p(`auto`)]).default(`auto`),maxPoints:n().int().positive().max(5e3).default(1e3)},QM=b({resolution:qM,series:S(dCe).readonly(),truncated:v()}),fCe=24,pCe=h([b({deviceId:n().int(),key:l(),scope:l().optional()}),b({forNodeId:l().min(1),key:l(),scope:l().optional()})]),mCe=i(`ok`,[b({ok:p(!0),result:QM}),b({ok:p(!1),error:l()})]),hCe=b({tier:qM,rows:n().int().nullable(),approxBytes:n().nullable(),countedAt:n().nullable()}),$M=x([`device-gone`,`undeclared`]),eN=b({raw:n().int(),"5m":n().int(),"1h":n().int(),"1d":n().int()}),gCe=b({seriesId:n().int(),deviceId:n().int(),key:l(),scope:l(),displayName:l().nullable(),reason:$M,missingSince:n().nullable(),firstTs:n(),lastTs:n(),rows:eN}),_Ce=200,vCe=50,tN=x([`not-found`,`not-orphan`,`failed`]),yCe=i(`ok`,[b({seriesId:n().int(),ok:p(!0),deleted:eN}),b({seriesId:n().int(),ok:p(!1),reason:tN})]),bCe=b({series:S(gCe).readonly(),truncated:v()}),nN=x([`invalid-range`,`range-too-large`,`series-not-found`,`not-a-point-series`]),xCe=b({"5m":n().int(),"1h":n().int(),"1d":n().int()}),SCe=i(`ok`,[b({ok:p(!0),dryRun:v(),seriesId:n().int(),rows:eN,rewritten:xCe.nullable()}),b({ok:p(!1),reason:nN})]),rN=b({startedAt:n(),ready:v(),series:n().int(),metrics:n().int(),optedOutDevices:n().int(),tiers:S(hCe).readonly(),capture:b({eventsSeen:n().int(),pointsEmitted:n().int(),pointsWritten:n().int(),pointsDropped:n().int(),bufferDepth:n().int(),trailingEmitted:n().int(),reconciledPoints:n().int(),reconcileRuns:n().int(),reconcileFailures:n().int(),lastReconcileAt:n().nullable(),lastFlushAt:n().nullable(),flushFailures:n().int(),skipped:m(l(),n().int())}),ingest:b({accepted:n().int(),refused:m(l(),n().int())}),rollup:b({last5mAt:n().nullable(),last1hAt:n().nullable(),last1dAt:n().nullable(),errors:n().int(),dirty5m:n().int(),dirty1h:n().int(),dirty1d:n().int()}),retention:b({lastRunAt:n().nullable(),deleted:m(l(),n().int()),purgedSeries:n().int()}),directory:b({devices:n().int(),lastRefreshAt:n().nullable()})}),iN={name:`device-history`,scope:`system`,mode:`singleton`,methods:{listSeries:k(b({deviceId:n().int()}),S(XM).readonly()),listNodeSeries:k(b({forNodeId:l().min(1)}),S(XM).readonly(),{auth:`admin`}),query:k(b({deviceId:n().int(),...ZM}),QM),queryNode:k(b({forNodeId:l().min(1),...ZM}),QM,{auth:`admin`}),queryMany:k(b({items:S(pCe).min(1).max(24),from:ZM.from,to:ZM.to,resolution:ZM.resolution,maxPoints:ZM.maxPoints}),b({results:S(mCe).readonly()}),{auth:`admin`}),declareSeries:k(b({name:l().regex(/^[a-z0-9-]+$/),subjectKind:x([`device`,`node`]),kind:KM,unit:l().optional(),displayName:l().min(1),ingest:x([`points`,`buckets`])}),b({key:l()}),{kind:`mutation`,auth:`admin`}),record:k(b({points:S(b({key:l(),subject:WM,scope:l().default(``),ts:n(),value:n()})).max(5e3)}),YM,{kind:`mutation`,auth:`admin`}),recordBuckets:k(b({buckets:S(b({key:l(),subject:WM,scope:l().default(``),bucketStart:n(),samples:n().int().positive(),sum:n(),min:n(),max:n(),last:n().nullable(),lastTs:n().nullable()})).max(5e3)}),YM,{kind:`mutation`,auth:`admin`}),getDeviceEnabled:k(b({deviceId:n().int()}),b({enabled:v()})),setDeviceEnabled:k(b({deviceId:n().int(),enabled:v()}),b({enabled:v()}),{kind:`mutation`,auth:`admin`}),getStatus:k(b({}),rN,{auth:`admin`}),listOrphanSeries:k(b({}),bCe,{auth:`admin`}),deleteOrphanSeries:k(b({seriesIds:S(n().int()).min(1).max(50)}),b({results:S(yCe).readonly()}),{kind:`mutation`,auth:`admin`}),deleteSeriesRange:k(b({deviceId:n().int(),key:l().min(1),scope:l(),fromMs:n().int().nonnegative(),toMs:n().int().nonnegative(),dryRun:v()}),SCe,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`recorded history of device state — read by charts, not actuated`}},aN=b({deviceId:n().int().positive(),deletedAt:n(),providerAddonId:l()}),oN=b({counts:m(l(),n().int().nonnegative())}),sN=b({store:l(),deviceId:n().int().positive(),count:n().int().nonnegative()}),cN={name:`device-removal-hook`,scope:`system`,mode:`collection`,internal:!0,methods:{onDeviceRemoved:k(aN,oN,{kind:`mutation`,auth:`admin`}),listDeviceData:k(_(),S(sN).readonly(),{auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:j.INTERNAL}},lN=x([`appliance`,`mower`,`vacuum`]),uN=x([`open`,`closed`]),dN=x([`completed`,`aborted`,`error`,`unknown`]),fN=x([`running-state`,`activity`,`reconcile`]),pN=x([`counter-delta`,`history-integral`]),mN=b({phase:l(),at:n()}),hN=b({kind:p(`appliance`),energyKwh:n().nullable().meta(M(`energy`)),energyMethod:pN.nullable(),peakW:n().nullable().meta(M(`power`)),avgW:n().nullable().meta(M(`power`)),program:l().nullable(),remainingAtStartSec:n().nullable().meta(M(`duration`)),finalPhase:l().nullable(),energyStartKwh:n().nullable().meta(M(`energy`)),powerObservedMs:n()}),gN=i(`kind`,[hN]),_N=b({runId:l(),deviceId:n().int(),kind:lN,state:uN,startedAt:n(),endedAt:n().nullable(),durationMs:n().nullable(),outcome:dN.nullable(),startSource:fN,endSource:fN.nullable(),runningSource:x([`native`,`assigned`]).nullable(),phases:S(mN),detail:gN}),CCe=[T.Washer,T.Dryer,T.Dishwasher],wCe=200,vN={name:`device-runs`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:CCe,methods:{listRuns:k(b({deviceId:n().int(),outcome:dN.optional(),atFrom:n().optional(),atTo:n().optional(),limit:n().int().positive().max(200).default(50),cursor:l().optional()}),b({runs:S(_N).readonly(),nextCursor:l().nullable()})),getRun:k(b({deviceId:n().int(),runId:l()}),_N.nullable()),getCurrentRun:k(b({deviceId:n().int()}),_N.nullable())},events:{onRunOpened:{data:_N,notOperatorFacing:`the durable record of a run that the running-state start flip already announces`},onRunClosed:{data:_N,notOperatorFacing:`the durable record of a run that the running-state finish flip already announces`}},vocabulary:{noun:P(`Runs`,`Esecuzioni`),order:2130}},yN=x([`replace`,`add`]),bN=i(`ok`,[b({ok:p(!0),changed:v()}),b({ok:p(!1),code:x([`owned-by-other`,`not-claimed`,`field-not-claimed`,`invalid-slice`,`unknown-device`,`row-unreadable`,`migration-in-flight`]),message:l()})]),xN=b({deviceId:n(),capName:l(),owner:l().min(1),mode:yN,fields:S(l().min(1)).min(1)}),SN=i(`state`,[b({state:p(`loaded`),claims:S(xN)}),b({state:p(`not-loaded`),reason:l()})]),CN={name:`device-state`,scope:`system`,mode:`singleton`,methods:{getSnapshot:k(b({deviceId:n()}),m(l(),m(l(),C()))),getCapSlice:k(b({deviceId:n(),capName:l(),confirmed:v().optional()}),m(l(),C()).nullable()),getAllSnapshots:k(b({confirmed:v().optional()}),m(l(),m(l(),m(l(),C())))),setCapSlice:k(b({deviceId:n(),capName:l(),slice:m(l(),C())}),_(),{kind:`mutation`}),claimFields:k(b({deviceId:n(),capName:l(),owner:l().min(1),mode:yN,fields:S(l().min(1)).min(1),values:m(l(),C())}),bN,{kind:`mutation`,auth:`admin`}),patchOwnedFields:k(b({deviceId:n(),capName:l(),owner:l().min(1),values:m(l(),C())}),bN,{kind:`mutation`,auth:`admin`}),releaseClaim:k(b({deviceId:n(),capName:l(),owner:l().min(1)}),bN,{kind:`mutation`,auth:`admin`}),listClaims:k(b({ownerPrefix:l().optional()}),SN,{auth:`admin`}),getNativeCapSlice:k(b({deviceId:n(),capName:l()}),m(l(),C()).nullable(),{auth:`admin`})},events:{onChanged:ai(b({deviceId:n(),capName:l(),slice:m(l(),C())}))},vocabulary:{notOperatorFacing:`the runtime-state mirror every trigger already reads through`}},wN=x([`schedule`,`command`,`burst`]),TN=x([`none`,`partial`,`full`]),EN=1e3,TCe=b({integrationId:l().min(1),minIntervalMs:n().int().min(EN),intervalMs:n().int().positive().optional(),batch:v(),push:TN,heartbeatMs:n().int().positive().optional(),connectionEpoch:n().int().nonnegative().optional()});function ECe(e){let t=e.intervalMs??0;return Math.max(e.minIntervalMs,t)}var DN=[3e3,1e4],ON=1e4,kN=2e3;function DCe(e){let t=DN.filter(t=>t<e),n=e-kN,r=(t[t.length-1]??0)+ON;for(;r<n;)t.push(r),r+=ON;let i=t[t.length-1];return(i===void 0?n>0:n-i>=1e3)&&t.push(n),t}var OCe=2500,AN=b({deviceId:n().int().nonnegative(),deviceIds:S(n().int().nonnegative()).min(1),reason:wN}),jN=b({deviceId:n().int().nonnegative()}),MN=b({ok:p(!0)}),NN=`the core schedules state refreshes itself; an operator never asks for one`,PN={name:`device-state-refresh`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{refresh:k(AN,MN,{kind:`mutation`,auth:`admin`,notOperatorFacing:NN}),resubscribe:k(jN,MN,{kind:`mutation`,auth:`admin`,notOperatorFacing:NN})},vocabulary:{noun:P(`State refresh`,`Aggiornamento dello stato`),order:3247}},FN=b({online:v(),lastChangedAt:n()}),IN={name:`device-status`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},events:{onStatusChanged:{data:b({deviceId:n(),status:FN}),notOperatorFacing:"the `online` state trigger phrases both edges of this change"}},status:{schema:FN,kind:`push`},runtimeState:FN,durability:`restored`,history:{fields:{online:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:P(`Reachability`,`Raggiungibilità`),order:5260,state:[{kind:`boolean`,field:`online`,label:P(`Online`,`Online`),whenTrue:P(`When {device} comes back online`,`Quando {device} torna online`),whenFalse:P(`When {device} goes offline`,`Quando {device} va offline`),icon:`wifi`}],extraEvents:[{category:w.DeviceOnline,label:P(`Came online`,`Tornato online`),phrase:P(`When {device} comes back online`,`Quando {device} torna online`),icon:`wifi`},{category:w.DeviceOffline,label:P(`Went offline`,`Andato offline`),phrase:P(`When {device} goes offline`,`Quando {device} va offline`),icon:`wifi-off`}]}},kCe=200,ACe=500,LN=x([`not-kernel`,`invalid`]),RN=b({written:n().int().nonnegative(),refused:S(b({id:l(),reason:LN})).readonly()}),zN=b({rows:n().int().nullable(),lastWriteAt:n().nullable(),refused:m(l(),n())}),BN={name:`device-transitions`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:Object.values(T).filter(e=>e!==T.Container),methods:{listTransitions:k(b({deviceId:n().int(),capName:l().optional(),actorKind:oa.optional(),outcome:sa.optional(),atFrom:n().optional(),atTo:n().optional(),limit:n().int().positive().max(200).default(50),cursor:l().optional()}),b({transitions:S(la).readonly(),nextCursor:l().nullable()})),getTransition:k(b({deviceId:n().int(),id:l()}),la.nullable()),listRecentTransitions:ii(b({actorKind:oa.optional(),outcome:sa.optional(),atFrom:n().optional(),atTo:n().optional(),limit:n().int().positive().max(200).default(50),cursor:l().optional()}),b({transitions:S(la).readonly(),nextCursor:l().nullable()}),{auth:`admin`}),record:ii(b({transitions:S(la).max(500)}),RN,{kind:`mutation`,auth:`admin`}),getStatus:ii(b({}),zN,{auth:`admin`})},vocabulary:{noun:P(`Transitions`,`Transizioni`),order:2140}},VN=x([`idle`,`running`,`paused`,`finished`,`error`,`unavailable`]),HN=x([`Inactive`,`Ready`,`DelayedStart`,`Run`,`Pause`,`ActionRequired`,`Finished`,`Error`,`Aborting`]),UN=x([`available`,`offline`,`description-missing`]),WN=b({availability:UN,state:VN,operationState:HN.nullable(),program:l().nullable(),selectedProgram:l().nullable(),availablePrograms:S(l()),remaining:n().int().nonnegative().nullable().meta(M(`duration`)),delayedStart:n().int().nonnegative().nullable().meta(M(`duration`)),progress:n().min(0).max(100).nullable().meta(M(`percentage`)),doorOpen:v().nullable(),doorLocked:v().nullable(),remoteStartAllowed:v().nullable(),remoteControlActive:v().nullable(),localControlActive:v().nullable(),powerOn:v().nullable(),powerState:l().nullable(),filterCleaningDue:v().nullable(),machineCareDue:v().nullable(),machineCareRemainingRuns:n().int().nonnegative().nullable().meta(M(`count`)),halfLoad:v().nullable(),hygienePlus:v().nullable(),extraDry:v().nullable(),intensiveZone:v().nullable(),varioSpeedPlus:v().nullable(),childLock:v().nullable(),activeEvents:S(l()),errorCode:n().nullable().meta(M(`none`)),errorLabel:l().nullable(),lastFetchedAt:n()}),GN=n().int().nonnegative(),KN=h([v(),l(),n()]),qN=x([`none`,`read`,`readWrite`,`writeOnly`,`readStatic`]),JN=b({key:l(),name:l(),type:x([`boolean`,`number`,`enum`,`string`]),access:qN,available:v(),unit:l().nullable(),min:n().nullable(),max:n().nullable(),step:n().nullable(),enumValues:S(l()).nullable(),defaultValue:KN.nullable()}),YN=b({key:l(),name:l(),available:v(),options:S(JN)}),XN=b({availability:UN,supportsStart:v(),supportsPause:v(),supportsResume:v(),supportsStop:v(),supportsPower:v(),programs:S(YN),options:S(JN)}),ZN={name:`dishwasher`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Dishwasher],methods:{start:k(b({deviceId:GN,program:l().min(1).optional(),options:m(l(),KN).optional()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.start`,label:P(`Start cycle`,`Avvia il lavaggio`),phrase:P(`Start {device}`,`Avvia {device}`),icon:`play`,openArgs:[{key:`program`,label:P(`Programme`,`Programma`),offer:{kind:`dynamic`,from:`status`,field:`availablePrograms`},optional:!0}]}]}),pause:k(b({deviceId:GN}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.pause`,label:P(`Pause`,`Metti in pausa`),phrase:P(`Pause {device}`,`Metti in pausa {device}`),icon:`pause`}]}),resume:k(b({deviceId:GN}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.resume`,label:P(`Resume`,`Riprendi`),phrase:P(`Resume {device}`,`Riprendi il lavaggio di {device}`),icon:`play`}]}),stop:k(b({deviceId:GN}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.stop`,label:P(`Stop`,`Ferma`),phrase:P(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),setProgram:k(b({deviceId:GN,program:l().min(1)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.program`,label:P(`Choose programme`,`Scegli il programma`),phrase:P(`Select the {program} programme on {device}`,`Seleziona il programma {program} su {device}`),icon:`list`,openArgs:[{key:`program`,label:P(`Programme`,`Programma`),offer:{kind:`dynamic`,from:`status`,field:`availablePrograms`}}]}]}),setPower:k(b({deviceId:GN,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.powerOn`,label:P(`Power on`,`Accendi`),phrase:P(`Turn on {device}`,`Accendi {device}`),icon:`power`,args:{on:!0}},{id:`dishwasher.powerOff`,label:P(`Power off`,`Spegni`),phrase:P(`Turn off {device}`,`Spegni {device}`),icon:`power-off`,args:{on:!1}}]}),setHalfLoad:k(b({deviceId:GN,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.halfLoadOn`,label:P(`Half load on`,`Mezzo carico attivo`),phrase:P(`Turn on half load on {device}`,`Attiva il mezzo carico su {device}`),icon:`contrast`,args:{on:!0}},{id:`dishwasher.halfLoadOff`,label:P(`Half load off`,`Mezzo carico spento`),phrase:P(`Turn off half load on {device}`,`Disattiva il mezzo carico su {device}`),icon:`contrast`,args:{on:!1}}]}),setHygienePlus:k(b({deviceId:GN,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.hygienePlusOn`,label:P(`Hygiene Plus on`,`Igiene Plus attiva`),phrase:P(`Turn on Hygiene Plus on {device}`,`Attiva Igiene Plus su {device}`),icon:`sparkles`,args:{on:!0}},{id:`dishwasher.hygienePlusOff`,label:P(`Hygiene Plus off`,`Igiene Plus spenta`),phrase:P(`Turn off Hygiene Plus on {device}`,`Disattiva Igiene Plus su {device}`),icon:`sparkles`,args:{on:!1}}]}),setExtraDry:k(b({deviceId:GN,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.extraDryOn`,label:P(`Extra dry on`,`Asciugatura extra attiva`),phrase:P(`Turn on extra dry on {device}`,`Attiva l’asciugatura extra su {device}`),icon:`sun`,args:{on:!0}},{id:`dishwasher.extraDryOff`,label:P(`Extra dry off`,`Asciugatura extra spenta`),phrase:P(`Turn off extra dry on {device}`,`Disattiva l’asciugatura extra su {device}`),icon:`sun`,args:{on:!1}}]}),setIntensiveZone:k(b({deviceId:GN,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.intensiveZoneOn`,label:P(`Intensive zone on`,`Zona intensiva attiva`),phrase:P(`Turn on the intensive zone on {device}`,`Attiva la zona intensiva su {device}`),icon:`flame`,args:{on:!0}},{id:`dishwasher.intensiveZoneOff`,label:P(`Intensive zone off`,`Zona intensiva spenta`),phrase:P(`Turn off the intensive zone on {device}`,`Disattiva la zona intensiva su {device}`),icon:`flame`,args:{on:!1}}]}),setVarioSpeedPlus:k(b({deviceId:GN,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.varioSpeedOn`,label:P(`Speed boost on`,`Lavaggio rapido attivo`),phrase:P(`Turn on the speed boost on {device}`,`Attiva il lavaggio rapido su {device}`),icon:`zap`,args:{on:!0}},{id:`dishwasher.varioSpeedOff`,label:P(`Speed boost off`,`Lavaggio rapido spento`),phrase:P(`Turn off the speed boost on {device}`,`Disattiva il lavaggio rapido su {device}`),icon:`zap`,args:{on:!1}}]}),setChildLock:k(b({deviceId:GN,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.childLockOn`,label:P(`Child lock on`,`Blocco bambini attivo`),phrase:P(`Turn on the child lock of {device}`,`Attiva il blocco bambini di {device}`),icon:`lock`,args:{on:!0}},{id:`dishwasher.childLockOff`,label:P(`Child lock off`,`Blocco bambini spento`),phrase:P(`Turn off the child lock of {device}`,`Disattiva il blocco bambini di {device}`),icon:`lock-open`,args:{on:!1}}]}),setOption:k(b({deviceId:GN,key:l().min(1),value:KN}),_(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`a raw appliance option key/value; every option worth naming has its own action above`}),getOptions:k(b({deviceId:GN}),XN,{auth:`protected`})},status:{schema:WN,kind:`poll`},runtimeState:WN,durability:`session`,history:{fields:{progress:{kind:`gauge`,unit:`%`,deadband:2},state:{kind:`enum`},operationState:{kind:`enum`},remaining:{kind:`gauge`,unit:`s`,minIntervalMs:6e4},doorOpen:{kind:`boolean`},powerOn:{kind:`boolean`}}},vocabulary:{noun:P(`Dishwasher`,`Lavastoviglie`),order:2020,state:[{kind:`enum`,field:`state`,label:P(`Cycle`,`Ciclo`),values:[{value:`idle`,label:P(`Idle`,`Inattiva`)},{value:`running`,label:P(`Running`,`In funzione`),phrase:P(`When {device} starts a cycle`,`Quando {device} inizia un lavaggio`)},{value:`paused`,label:P(`Paused`,`In pausa`)},{value:`finished`,label:P(`Finished`,`Terminato`),phrase:P(`When {device} finishes`,`Quando {device} finisce il lavaggio`)},{value:`error`,label:P(`Error`,`Errore`),phrase:P(`When {device} reports an error`,`Quando {device} segnala un errore`)},{value:`unavailable`,label:P(`Unavailable`,`Non disponibile`)}],icon:`washing-machine`},{kind:`numeric`,field:`progress`,quantity:P(`the cycle progress`,`l’avanzamento del lavaggio`),label:P(`Progress`,`Avanzamento`),unit:`%`,icon:`loader`},{kind:`boolean`,field:`doorOpen`,label:P(`Door open`,`Sportello aperto`),whenTrue:P(`When the door of {device} opens`,`Quando si apre lo sportello di {device}`),whenFalse:P(`When the door of {device} closes`,`Quando si chiude lo sportello di {device}`),icon:`door-open`},{kind:`boolean`,field:`filterCleaningDue`,label:P(`Filter cleaning due`,`Pulizia filtro da fare`),whenTrue:P(`When {device} asks for its filter to be cleaned`,`Quando {device} chiede di pulire il filtro`),whenFalse:P(`When the filter reminder of {device} clears`,`Quando l’avviso filtro di {device} rientra`),icon:`funnel`},{kind:`boolean`,field:`machineCareDue`,label:P(`Machine care due`,`Manutenzione da fare`),whenTrue:P(`When {device} asks for a machine-care cycle`,`Quando {device} chiede un ciclo di manutenzione`),whenFalse:P(`When the machine-care reminder of {device} clears`,`Quando l’avviso di manutenzione di {device} rientra`),icon:`wrench`}]}},QN=`motion.audio.recording.live.heatmapScrub.person.vehicle.animal.package.sensor.control.face.plate.car.truck.bus.motorcycle.bicycle.airplane.boat.train.bird.dog.cat.horse.sheep.cow.elephant.bear.zebra.giraffe.package-delivered.package-picked-up.suitcase.backpack.handbag.contact.motion-sensor.smoke.flood.gas.carbon-monoxide.vibration.tamper.presence.enum-sensor.device-event.lock.cover.switch.siren.button.doorbell.appliance-cycle`.split(`.`),$N=`audio`,eP=[.3,.42,.55,.7,.85,1],tP=[`camstack`,`high-contrast`,`okabe-ito`];function jCe(e){return QN.includes(e)}function MCe(e){return tP.includes(e)}var nP={dark:`#0c0a09`,light:`#fafaf9`},NCe=7,PCe=20,FCe=[`live`,`heatmapScrub`],ICe=3,rP=/^#[0-9a-fA-F]{6}$/;function iP(e,t){return Number.parseInt(e.slice(t,t+2),16)}function aP(e){let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function oP(e){let t=aP(iP(e,1)),n=aP(iP(e,3)),r=aP(iP(e,5));return .2126*t+.7152*n+.0722*r}function LCe(e,t){if(!rP.test(e)||!rP.test(t))return 0;let n=Math.max(oP(e),oP(t)),r=Math.min(oP(e),oP(t));return(n+.05)/(r+.05)}function sP(e){let t=aP(iP(e,1)),n=aP(iP(e,3)),r=aP(iP(e,5)),i=.4124564*t+.3575761*n+.1804375*r,a=.2126729*t+.7151522*n+.072175*r,o=.0193339*t+.119192*n+.9503041*r,s=e=>e>.008856?Math.cbrt(e):7.787*e+16/116,c=s(i/.95047),l=s(a),u=s(o/1.08883);return{L:116*l-16,a:500*(c-l),b:200*(l-u)}}function cP(e,t){if(e===0&&t===0)return 0;let n=Math.atan2(t,e)*180/Math.PI;return n<0?n+360:n}function RCe(e,t){if(!rP.test(e)||!rP.test(t))return 0;let n=sP(e),r=sP(t),i=((Math.hypot(n.a,n.b)+Math.hypot(r.a,r.b))/2)**7,a=.5*(1-Math.sqrt(i/(i+25**7))),o=(1+a)*n.a,s=(1+a)*r.a,c=Math.hypot(o,n.b),l=Math.hypot(s,r.b),u=cP(o,n.b),d=cP(s,r.b),f=0;c*l!==0&&(f=d-u,f>180?f-=360:f<-180&&(f+=360));let p=2*Math.sqrt(c*l)*Math.sin(f*Math.PI/360),m=(n.L+r.L)/2,h=(c+l)/2,g=u+d;c*l!==0&&(Math.abs(u-d)>180&&(g+=g<360?360:-360),g/=2);let ee=1-.17*Math.cos((g-30)*Math.PI/180)+.24*Math.cos(2*g*Math.PI/180)+.32*Math.cos((3*g+6)*Math.PI/180)-.2*Math.cos((4*g-63)*Math.PI/180),te=30*Math.exp(-(((g-275)/25)**2)),_=h**7,ne=2*Math.sqrt(_/(_+25**7)),v=1+.015*(m-50)**2/Math.sqrt(20+(m-50)**2),re=1+.045*h,ie=1+.015*h*ee,ae=-Math.sin(2*te*Math.PI/180)*ne,oe=r.L-n.L,y=l-c;return Math.sqrt((oe/v)**2+(y/re)**2+(p/ie)**2+y/re*ae*(p/ie))}var zCe={motion:`#d946ef`,audio:`#059eb8`,recording:`#ef4444`,live:`#8d7a00`,heatmapScrub:`#4b32ff`,person:`#11a64c`,vehicle:`#3b82f6`,animal:`#ea6a09`,package:`#924667`,sensor:`#624bbc`,control:`#944d24`,face:`#ed4f8d`,plate:`#4b7027`,car:`#9684cf`,truck:`#0f9b89`,bus:`#a734a9`,motorcycle:`#c1133a`,bicycle:`#0e6a9b`,airplane:`#7c9928`,boat:`#b17933`,train:`#ad6ca3`,bird:`#0f7c55`,dog:`#c82700`,cat:`#7268f2`,horse:`#cb795e`,sheep:`#b8636b`,cow:`#cb2969`,elephant:`#1158d2`,bear:`#8d5e00`,zebra:`#0097d6`,giraffe:`#8f61bb`,"package-delivered":`#cd3f9b`,"package-picked-up":`#388a08`,suitcase:`#666800`,backpack:`#ec5022`,handbag:`#a76ef8`,contact:`#ab5a49`,"motion-sensor":`#b95d1a`,smoke:`#dd3858`,flood:`#b31e7d`,gas:`#5b70b5`,"carbon-monoxide":`#7b4e8e`,vibration:`#e65bba`,tamper:`#98464b`,presence:`#3a9468`,"enum-sensor":`#7885f8`,"device-event":`#8c43c8`,lock:`#649653`,cover:`#c67597`,switch:`#7a812a`,siren:`#ac5d7f`,button:`#b276cd`,doorbell:`#0087ab`,"appliance-cycle":`#2a8c8c`},BCe=[`#b34dc7`,`#1d7d34`,`#db6b6c`,`#a43d29`,`#0e6ee6`,`#29a10b`,`#a98731`,`#0181c6`],VCe={motion:`#964360`,audio:`#23a132`,recording:`#2494ca`,live:`#bd7e2b`,heatmapScrub:`#ad6eea`,person:`#62611e`,vehicle:`#f4534c`,animal:`#1556cd`,package:`#9c4415`,sensor:`#066c48`,control:`#f2479f`,face:`#139d8a`,plate:`#909024`,car:`#8e35ab`,truck:`#bd0b2b`,bus:`#7a88ca`,motorcycle:`#e26725`,bicycle:`#a6679b`,airplane:`#7c5720`,boat:`#467a1b`,train:`#6f65a4`,bird:`#cb717f`,dog:`#c62490`,cat:`#b36850`,horse:`#1872ac`,sheep:`#927939`,cow:`#428a5c`,elephant:`#d41160`,bear:`#799453`,zebra:`#a85455`,giraffe:`#746be8`,"package-delivered":`#824a80`,"package-picked-up":`#614ac1`,suitcase:`#2f77f3`,backpack:`#fa476d`,handbag:`#c14cbe`,contact:`#c83921`,"motion-sensor":`#a07ebd`,smoke:`#a25b13`,flood:`#526bab`,gas:`#924938`,"carbon-monoxide":`#bb7e53`,vibration:`#b66182`,tamper:`#3c6931`,presence:`#6c851d`,"enum-sensor":`#ad2d48`,"device-event":`#5e9b04`,lock:`#00a062`,cover:`#ad8624`,switch:`#d05259`,siren:`#cd67b3`,button:`#c9746a`,doorbell:`#338eeb`,"appliance-cycle":`#00848a`},HCe=[`#817f3b`,`#a0733e`,`#8658b2`,`#956301`,`#bc652d`,`#647331`,`#a14c9e`,`#d14e71`],UCe={motion:`#b88128`,audio:`#1096c8`,recording:`#009e73`,live:`#9c8c22`,heatmapScrub:`#0072b2`,person:`#d55e00`,vehicle:`#c0739f`,animal:`#226d18`,package:`#91446c`,sensor:`#217b56`,control:`#648647`,face:`#c22998`,plate:`#fa4575`,car:`#956301`,truck:`#2f77f3`,bus:`#7a4e86`,motorcycle:`#f54597`,bicycle:`#bb3e75`,airplane:`#e054c0`,boat:`#457942`,train:`#867afa`,bird:`#88914c`,dog:`#1556cd`,cat:`#71702c`,horse:`#9b4fa4`,sheep:`#c0559d`,cow:`#d14f65`,elephant:`#98470f`,bear:`#595896`,zebra:`#96790e`,giraffe:`#cb717b`,"package-delivered":`#139d8a`,"package-picked-up":`#906ead`,suitcase:`#d02939`,backpack:`#d41160`,handbag:`#f64f54`,contact:`#7258d2`,"motion-sensor":`#b66182`,smoke:`#627abb`,flood:`#b86ae4`,gas:`#a95261`,"carbon-monoxide":`#c65d3c`,vibration:`#7a40b7`,tamper:`#914b34`,presence:`#9481c3`,"enum-sensor":`#ac6d47`,"device-event":`#7b6fce`,lock:`#c67662`,cover:`#a6564d`,switch:`#ad2c4e`,siren:`#348e08`,button:`#d27303`,doorbell:`#55770f`,"appliance-cycle":`#00737d`},WCe=[`#9a3784`,`#a7392c`,`#409d50`,`#6987e7`,`#ee5b3d`,`#c0430d`,`#af79b3`,`#4b6628`],lP=l().regex(/^#[0-9a-f]{6}$/),uP=i(`form`,[b({form:p(`solid`),hex:lP}),b({form:p(`gradient`),hex:lP,alphas:S(n().gt(0).lte(1)).length(eP.length)})]),dP=b({status:p(`ready`),presetId:x(tP),customized:v(),source:x([`stored`,`unconfigured`]),swatches:m(l(),uP),fallbacks:S(lP).length(8)}),fP=i(`status`,[dP,b({status:p(`unknown`),reason:l()})]),pP=h([b({presetId:l()}),b({presetId:l(),overrides:m(l(),uP)})]),mP=b({presetId:l(),overrides:m(l(),uP)});function GCe(e){return{form:`solid`,hex:e}}function KCe(e){return{form:`gradient`,hex:e,alphas:[...eP]}}function qCe(e){let t={};for(let n of QN){let r=e[n];if(r===void 0)throw Error(`palette table missing ${n}`);t[n]=n===`audio`?KCe(r):GCe(r)}return t}function hP(e,t,n,r){return{id:e,name:t,swatches:qCe(n),fallbacks:r}}var gP=[hP(`camstack`,`CamStack`,zCe,BCe),hP(`high-contrast`,`High contrast`,VCe,HCe),hP(`okabe-ito`,`Colour-blind safe`,UCe,WCe)];function _P(e){return gP.find(t=>t.id===e)}function vP(){let e=_P(`camstack`);if(e===void 0)throw Error(`CamStack preset missing`);return JCe(e,`unconfigured`,!1)}function JCe(e,t,n){return{status:`ready`,presetId:e.id,customized:n,source:t,swatches:e.swatches,fallbacks:[...e.fallbacks]}}function YCe(e){return e.hex}function XCe(e,t){let n=[];for(let t of QN){let r=e[t];r!==void 0&&n.push({name:t,hex:r.hex})}return t.forEach((e,t)=>{n.push({name:`fallback-${t}`,hex:e})}),n}function ZCe(e){let t=e[$N];return t===void 0||t.form===`gradient`&&eP.every((e,n)=>t.alphas[n]===e)?[]:[{code:`bad-gradient`,entry:$N}]}function QCe(e,t){let n=FCe;return n.includes(e)&&n.includes(t)}function yP(e,t){let n=[];for(let t of QN)e[t]===void 0&&n.push({code:`missing-entry`,entry:t});for(let t of Object.keys(e))jCe(t)||n.push({code:`unknown-entry`,entry:t});t.length!==8&&n.push({code:`bad-fallbacks`}),n.push(...ZCe(e));let r=XCe(e,t);for(let e=0;e<r.length;e++)for(let t=e+1;t<r.length;t++){let i=r[e],a=r[t];if(i===void 0||a===void 0)continue;let o=RCe(i.hex,a.hex);o<(QCe(i.name,a.name)?20:7)&&n.push({code:`too-close`,left:i.name,right:a.name,deltaE:o})}for(let e of r)for(let t of[`dark`,`light`]){let r=LCe(e.hex,nP[t]);r<3&&n.push({code:`low-contrast`,entry:e.name,background:t,contrast:r})}return n.length===0?{ok:!0}:{ok:!1,violations:n}}function $Ce(e){switch(e.code){case`too-close`:return`${e.left} vs ${e.right} (ΔE ${e.deltaE.toFixed(1)})`;case`low-contrast`:return`${e.entry} on ${e.background} (${e.contrast.toFixed(1)}:1)`;case`missing-entry`:return`${e.entry} is missing`;case`unknown-entry`:return`${e.entry} is not a palette entry`;case`bad-gradient`:return`${e.entry} gradient is not the six canonical steps`;case`bad-fallbacks`:return`fallback list must hold eight colours`;case`unknown-preset`:return`${e.presetId} is not a preset`}}function bP(e){return e.map($Ce).join(`; `)}var xP=class extends Error{violations;constructor(e){super(bP(e)),this.name=`PaletteRejectedError`,this.violations=e}};function SP(e,t){let n=0;for(let t=0;t<e.length;t++)n=n*31+(e.codePointAt(t)??0)>>>0;let r=t[n%t.length];if(r===void 0)throw Error(`display palette has no fallback colour`);return r}function CP(e,t,n){let r=n.trim().toLowerCase();if(r.startsWith(`audio-`)){let n=e[$N];return n===void 0?SP(r,t):n.hex}let i=e[r];return i===void 0?SP(r,t):i.hex}function wP(e,t){return{...e,...t}}function ewe(e){return`overrides`in e?e.overrides:{}}function twe(e){let t=_P(e.presetId);if(t===void 0||!MCe(e.presetId))throw new xP([{code:`unknown-preset`,presetId:e.presetId}]);let n=ewe(e),r=wP(t.swatches,n),i=yP(r,t.fallbacks);if(!i.ok)throw new xP(i.violations);let a=Object.keys(n).length>0;return{status:`ready`,presetId:t.id,customized:a,source:`stored`,swatches:r,fallbacks:[...t.fallbacks]}}function nwe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.keys(e).length===0}function rwe(e){if(e==null||nwe(e))return vP();let t=mP.safeParse(e);if(!t.success)return{status:`unknown`,reason:`stored palette is unreadable`};let n=_P(t.data.presetId);if(n===void 0)return{status:`unknown`,reason:`unknown preset ${t.data.presetId}`};let r=wP(n.swatches,t.data.overrides),i=yP(r,n.fallbacks);if(!i.ok)return{status:`unknown`,reason:bP(i.violations)};let a=Object.keys(t.data.overrides).length>0;return{status:`ready`,presetId:n.id,customized:a,source:`stored`,swatches:r,fallbacks:[...n.fallbacks]}}function iwe(e,t){return{presetId:e.presetId,overrides:{...t}}}var awe=b({id:l(),name:l(),swatches:m(l(),uP),fallbacks:S(l())}),TP={name:`display-palette`,scope:`system`,mode:`singleton`,methods:{getPalette:k(_(),fP,{auth:`protected`,role:`viewer`}),listPresets:k(_(),S(awe).readonly(),{auth:`protected`,role:`viewer`}),setPalette:k(pP,dP,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`the cluster display palette — one colour table for every client, not a device action`}},EP=b({enabled:v().nullable().meta({label:`Do not disturb`}),lastChangedAt:n()}),DP={name:`do-not-disturb`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.MediaPlayer],methods:{setEnabled:k(b({deviceId:n().int(),enabled:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dnd.on`,label:P(`Do not disturb on`,`Attiva Non disturbare`),phrase:P(`Turn on Do not disturb on {device}`,`Attiva Non disturbare su {device}`),icon:`bell-off`,args:{enabled:!0}},{id:`dnd.off`,label:P(`Do not disturb off`,`Disattiva Non disturbare`),phrase:P(`Turn off Do not disturb on {device}`,`Disattiva Non disturbare su {device}`),icon:`bell`,args:{enabled:!1}}]})},status:{schema:EP,kind:`push`},runtimeState:EP,durability:`session`,history:{fields:{enabled:{kind:`boolean`}}},vocabulary:{noun:P(`Do not disturb`,`Non disturbare`),order:2160,state:[{kind:`boolean`,field:`enabled`,label:P(`Do not disturb`,`Non disturbare`),whenTrue:P(`When Do not disturb turns on on {device}`,`Quando {device} attiva Non disturbare`),whenFalse:P(`When Do not disturb turns off on {device}`,`Quando {device} disattiva Non disturbare`),icon:`bell-off`}]}},OP=2e3,owe={version:1,targets:[{id:`pressed`,cardinality:`event`,shape:`pulse`,vocabulary:{cap:`doorbell`,eventName:`onPressed`},deviceTypes:[T.Camera],apply:`add`,applyAuthority:{kind:`composition-claim`},eventName:`onPressed`,edges:[`rising`],defaultEdge:`rising`,timestampPath:`lastPressedAt`,counterPath:`pressCountSinceStart`,highWater:`composer-advance`,combine:`any`,debounce:{kind:`rising-edge`,defaultDebounceMs:OP,changedAtRequired:!0},sources:[{kind:`binary`},{kind:`switch`}],sourceReport:{status:`assignment-status`},advancedExpression:!0}]},kP=b({lastPressedAt:n().nullable(),pressCountSinceStart:n().meta(M(`count`))}),AP=b({deviceId:n(),timestamp:n()}),jP={name:`doorbell`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Button,T.Camera],methods:{},events:{onPressed:{data:AP,fromState:{field:`lastPressedAt`,on:`advance`},trigger:{category:w.DoorbellOnPressed,label:P(`Rang`,`Ha suonato`),phrase:P(`When someone rings {device}`,`Quando qualcuno suona a {device}`),icon:`bell-ring`}}},status:{schema:kP,kind:`push`},runtimeState:kP,durability:`restored`,history:`none`,customize:owe,vocabulary:{noun:P(`Doorbell`,`Campanello`),order:5270}},MP=b({embedding:S(n()),inferenceMs:n()}),NP=x([`image`,`text`]),PP=b({modelId:l(),tower:NP,nodeId:l(),crashes:n(),windowMs:n(),sinceMs:n(),lastReason:l()}),FP=b({modelId:l(),tower:NP,nodeId:l(),attempts:n(),sinceMs:n(),lastReason:l()}),IP=b({modelId:l(),embeddingDim:n(),ready:v(),nodeId:l().optional(),failedModels:S(PP).optional(),failedRequirements:S(FP).optional()}),LP=`embedding-model-failed`,RP=`embedding-requirements-unavailable`,zP=`embedding-requirements-failed`,BP=x([LP,RP,zP]);function VP(e,t){return`[${e} model=${t.modelId} tower=${t.tower} node=${t.nodeId}]`}function swe(e){return Error(`${VP(LP,e)} ${e.modelId} (${e.tower} tower) crashed ${String(e.crashes)} times in ${String(Math.round(e.windowMs/1e3))}s on ${e.nodeId} — ${e.lastReason}. Cleared by embeddingEncoder.resetFailedModels({ modelId: "${e.modelId}", nodeId: "${e.nodeId}" }) or a model change.`)}function cwe(e,t){return Error(`${VP(RP,e)} ${e.modelId} (${e.tower} tower) on ${e.nodeId}: ${t}`)}function lwe(e){return Error(`${VP(zP,e)} ${e.modelId} (${e.tower} tower) on ${e.nodeId}: requirements can never be met — ${String(e.attempts)} attempts, last: ${e.lastReason}. Cleared by embeddingEncoder.resetFailedModels({ modelId: "${e.modelId}", nodeId: "${e.nodeId}" }) or a model change.`)}var uwe=RegExp(`\\[(${LP}|${RP}|${zP}) model=([^\\s\\]]+) tower=(image|text) node=([^\\s\\]]+)\\]`);function HP(e){let t=e instanceof Error?e.message:String(e),n=uwe.exec(t);if(n===null)return null;let r=BP.safeParse(n[1]),i=NP.safeParse(n[3]);return!r.success||!i.success||n[2]===void 0||n[4]===void 0?null:{code:r.data,modelId:n[2],tower:i.data,nodeId:n[4]}}function dwe(e){return UP(e)!==null}function UP(e){let t=HP(e);if(t===null||t.code!==`embedding-model-failed`)return null;let{modelId:n,tower:r,nodeId:i}=t;return{modelId:n,tower:r,nodeId:i}}var WP={name:`embedding-encoder`,scope:`system`,mode:`collection`,internal:!0,methods:{encode:k(b({crop:y(Uint8Array),width:n(),height:n()}),MP,{auth:`admin`}),encodeText:k(b({text:l(),modelId:l().min(1).optional()}),MP,{auth:`admin`}),getInfo:k(_(),IP,{auth:`admin`}),resetFailedModels:k(b({modelId:l().min(1).optional()}),b({cleared:S(l()),nodeId:l()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:j.ML}},GP=b({powerW:n().nullable().meta(M(`power`)),energyKwh:n().nullable().meta(M(`energy`)),todayKwh:n().nullable().meta(M(`energy`))}),KP=b({powerW:n().nullable().meta(M(`power`)),importKwh:n().nullable().meta(M(`energy`)),exportKwh:n().nullable().meta(M(`energy`)),importTodayKwh:n().nullable().meta(M(`energy`)),exportTodayKwh:n().nullable().meta(M(`energy`))}),qP=b({powerW:n().nullable().meta(M(`power`)),energyKwh:n().nullable().meta(M(`energy`)),todayKwh:n().nullable().meta(M(`energy`))}),JP=b({stateOfChargePct:n().nullable().meta(M(`percentage`)),storedKwh:n().nullable().meta(M(`energy`)),capacityKwh:n().nullable().meta(M(`energy`)),powerW:n().nullable().meta(M(`power`)),chargedKwh:n().nullable().meta(M(`energy`)),dischargedKwh:n().nullable().meta(M(`energy`)),chargedTodayKwh:n().nullable().meta(M(`energy`)),dischargedTodayKwh:n().nullable().meta(M(`energy`)),healthPct:n().nullable().meta(M(`percentage`))}),YP=b({solar:GP.nullable(),grid:KP.nullable(),house:qP.nullable(),heatPump:qP.nullable(),storage:JP.nullable(),lastFetchedAt:n()});function fwe(e){let t=e.solar?.todayKwh??null,n=e.grid?.exportTodayKwh??null;return t===null||n===null||t<=0?null:Math.max(0,Math.min(100,(t-n)/t*100))}var XP={name:`energy-system`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.EnergySystem],methods:{},status:{schema:YP,kind:`push`},runtimeState:YP,durability:`session`,history:{primary:`house.powerW`,priority:50,fields:{"solar.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Solar power`},"solar.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`Solar energy`},"grid.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Grid power`},"grid.importKwh":{kind:`counter`,unit:`kWh`,displayName:`Grid import`},"grid.exportKwh":{kind:`counter`,unit:`kWh`,displayName:`Grid export`},"house.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`House power`},"house.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`House energy`},"heatPump.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Heat pump power`},"heatPump.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`Heat pump energy`},"storage.stateOfChargePct":{kind:`gauge`,unit:`%`,deadband:1,displayName:`Storage charge`},"storage.storedKwh":{kind:`gauge`,unit:`kWh`,deadband:.05,displayName:`Stored energy`},"storage.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Storage power`},"storage.chargedKwh":{kind:`counter`,unit:`kWh`,displayName:`Storage charged`},"storage.dischargedKwh":{kind:`counter`,unit:`kWh`,displayName:`Storage discharged`},"storage.healthPct":{kind:`gauge`,unit:`%`,deadband:1,displayName:`Storage health`}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:P(`Energy system`,`Sistema energetico`),order:4020}},pwe=x([`date`,`time`,`datetime`]),ZP=b({value:l(),timestamp:v().optional(),lastFetchedAt:n()}),QP={name:`enum-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Sensor],methods:{},status:{schema:ZP,kind:`push`},runtimeState:ZP,durability:`restored`,history:{fields:{value:{kind:`enum`,skipWhenSet:`timestamp`}}},volatileStateFields:[`lastFetchedAt`,`timestamp`],vocabulary:{noun:P(`State sensor`,`Sensore di stato`),order:5060,state:[{kind:`value`,field:`value`,label:P(`State`,`Stato`),icon:`list`}]}},$P=x([`warning`,`error`]),eF=b({code:l(),label:l(),severity:$P}),tF=b({active:v().nullable(),code:l().nullable(),label:l().nullable(),severity:$P,since:n().nullable(),faults:S(eF).optional(),lastFetchedAt:n()}),nF={active:null,code:null,label:null,severity:`error`,since:null,lastFetchedAt:0},rF={name:`error`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},status:{schema:tF,kind:`push`,empty:nF},runtimeState:tF,durability:`restored`,volatileStateFields:[`lastFetchedAt`],history:`none`,vocabulary:{noun:P(`Fault`,`Guasto`),order:5265,state:[{kind:`boolean`,field:`active`,label:P(`Fault`,`Guasto`),whenTrue:P(`When {device} reports a fault`,`Quando {device} segnala un guasto`),whenFalse:P(`When the fault of {device} clears`,`Quando il guasto di {device} si risolve`),icon:`triangle-alert`}]}},iF=b({id:l(),name:l(),sampleCount:n().int().nonnegative(),coverMediaId:n().int().optional(),coverBase64:l().optional()}),mwe=b({id:l(),source:x([`detected`,`photo`]),addedAt:n().int(),deviceId:n().int().optional(),base64:l().optional(),mediaId:n().int().optional(),keyFrameMediaId:n().int().optional(),faceBbox:aC.optional()}),hwe=b({sampleId:l(),enrolledAt:n().int(),deviceId:n().int().optional(),source:x([`detected`,`photo`]),mediaId:n().int().optional(),comparable:v(),selfMean:n().nullable(),bestForeign:b({identityId:l(),name:l(),score:n()}).optional(),suspicion:n()}),gwe=b({identityId:l(),name:l(),modelId:l(),totalSamples:n().int(),comparableSamples:n().int(),flagged:n().int(),flagThreshold:n(),rows:S(hwe).readonly()}),aF=b({faceId:l(),deviceId:n().int(),trackId:l(),timestamp:n().int(),recognizedIdentityId:l().optional(),identityName:l().optional(),assigned:v(),base64:l().optional(),cropUrl:l().optional(),faceBbox:aC.optional(),keyFrameMediaId:n().int().optional(),bestMatchScore:n().optional(),nativeFaceShortSidePx:n().optional(),suggestedIdentityId:l().optional(),suggestedMatchScore:n().optional()}),_we=x([`unassigned`,`recognized`,`identified`,`all`]),vwe=x([`timestamp`,`suggestionConfidence`]),ywe=x([`asc`,`desc`]),bwe=b({faceIds:S(l()).readonly(),representativeFaceId:l(),size:n().int(),cohesion:n()}),xwe=b({mediaId:n().int(),kind:l(),url:l(),sizeBytes:n(),timestamp:n()}),oF={name:`face-gallery`,role:{feature:`face-assignment`},scope:`system`,mode:`singleton`,methods:{listIdentities:k(b({includeCrops:v().optional()}).optional(),S(iF).readonly(),{role:`viewer`}),createIdentity:k(b({name:l().min(1)}),iF,{kind:`mutation`,auth:`admin`}),renameIdentity:k(b({id:l(),name:l().min(1)}),_(),{kind:`mutation`,auth:`admin`}),deleteIdentity:k(b({id:l()}),_(),{kind:`mutation`,auth:`admin`}),listIdentitySamples:k(b({identityId:l()}),S(mwe).readonly()),auditIdentitySamples:k(b({identityId:l().min(1)}),gwe,{auth:`admin`}),removeSample:k(b({identityId:l(),sampleId:l()}),_(),{kind:`mutation`,auth:`admin`}),moveIdentitySample:k(b({sampleId:l().min(1),toIdentityId:l().min(1)}),_(),{kind:`mutation`,auth:`admin`}),listRecentFaces:k(b({deviceId:n().int().optional(),deviceIds:S(n().int()).optional(),limit:n().int().positive().optional(),filter:_we.optional(),since:n().int().optional(),until:n().int().optional(),sortBy:vwe.optional(),sortDirection:ywe.optional(),includeCrops:v().optional()}).optional(),S(aF).readonly()),getFaceByTrack:k(b({deviceId:n().int(),trackId:l()}),aF.nullable(),{role:`viewer`}),getFaceMedia:k(b({faceId:l()}),S(xwe).readonly()),assignFace:k(b({faceId:l(),identityId:l()}),_(),{kind:`mutation`,auth:`admin`}),unassignFace:k(b({faceId:l()}),_(),{kind:`mutation`,auth:`admin`}),deleteFace:k(b({faceId:l()}),_(),{kind:`mutation`,auth:`admin`}),assignFaces:k(b({faceIds:S(l()).min(1),identityId:l()}),b({assigned:n().int(),failed:S(l()).readonly()}),{kind:`mutation`,auth:`admin`}),unassignFaces:k(b({faceIds:S(l()).min(1)}),b({unassigned:n().int(),failed:S(l()).readonly()}),{kind:`mutation`,auth:`admin`}),suggestFaceClusters:k(b({threshold:n().min(0).max(1).optional(),minClusterSize:n().int().min(2).optional(),maxClusters:n().int().positive().optional(),limit:n().int().positive().optional(),maxFacesScanned:n().int().positive().optional()}).optional(),S(bwe).readonly())},vocabulary:{notOperatorFacing:`the face gallery — curated on its own page`}},sF=b({reason:l(),count:n().int().nonnegative()}),cF=b({family:l(),deviceId:n().int().positive(),variant:l().optional(),sinceMs:n(),atMs:n(),attempts:n().int().nonnegative(),succeeded:n().int().nonnegative(),reasons:S(sF).readonly()}),lF={name:`failure-contribution`,scope:`system`,mode:`collection`,internal:!0,methods:{list:k(_(),S(cF).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:j.INTERNAL}},uF=x([`forward`,`reverse`]),dF=[`horizontal`,`vertical`],fF=x(dF),pF=[`oscillating`,`angle`,`sweepFrom`,`sweepTo`],mF=x(pF),hF=[`min`,`max`,`step`],gF=b({oscillating:v().nullable().default(null),angle:n().nullable().default(null),sweepFrom:n().nullable().default(null),sweepTo:n().nullable().default(null),min:n().nullable().default(null),max:n().nullable().default(null),step:n().nullable().default(null)}),_F=b({horizontal:gF.nullable().default(null),vertical:gF.nullable().default(null)}),vF=[`nothing-to-set`,`axis-not-linked`,`out-of-range`,`source-gone`,`source-unknown`,`source-call-failed`],yF=x(vF),bF=i(`status`,[b({status:p(`applied`)}),b({status:p(`refused`),reason:yF,field:mF.optional(),detail:l(),applied:S(mF)})]),xF=b({deviceId:n().int().nonnegative(),axis:fF,oscillating:v().optional(),angle:n().optional(),sweepFrom:n().optional(),sweepTo:n().optional()});function SF(e,t){return`oscillationAxes.${e}.${t}`}var CF=b({speed:n().min(0).max(100).nullable().meta(M(`percentage`)),percentageStep:n().positive().optional().meta(M(`percentage`)),preset:l(),availablePresets:S(l()),direction:uF.nullable(),oscillating:v().nullable(),oscillationAxes:_F.optional(),lastChangedAt:n()});function Swe(e){let t=e.oscillationAxes;if(t===void 0)return e.oscillating;let n=dF.flatMap(e=>{let n=t[e]?.oscillating;return n==null?[]:[n]});return n.length===0?e.oscillating:n.some(Boolean)}var wF=[T.Fan],TF=`oscillation-axes`;function Cwe(e){return{id:`${e}-oscillating`,cardinality:`scalar`,vocabulary:{cap:`fan-control`,stateField:`oscillating`},deviceTypes:wF,apply:`replace`,section:TF,path:SF(e,`oscillating`),sources:[{kind:`switch`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}}function EF(e,t){let n={id:`${e}-${t}`,cardinality:`scalar`,vocabulary:{cap:`fan-control`},deviceTypes:wF,apply:`replace`,section:TF,path:SF(e,t),sources:[{kind:`numeric`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}};return t===`angle`?{...n,companions:hF.map(t=>({kind:`source-field`,path:SF(e,t),field:t}))}:n}var wwe=dF.flatMap(e=>[Cwe(e),EF(e,`angle`),EF(e,`sweepFrom`),EF(e,`sweepTo`)]),Twe={id:`preset`,cardinality:`scalar`,vocabulary:{cap:`fan-control`},deviceTypes:wF,apply:`replace`,path:`preset`,sources:[{kind:`field`,valueKinds:[`string`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}},DF=[...wwe,Twe],Ewe={version:1,overridable:DF.map(e=>({path:e.path,by:e.id})),targets:DF},OF={name:`fan-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Fan],methods:{setPercentage:A(b({deviceId:n().int().nonnegative(),speed:n().min(0).max(100)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.off`,label:P(`Fan off`,`Ventilatore spento`),phrase:P(`Stop {device}`,`Ferma {device}`),icon:`power-off`,effect:{field:`speed`,value:0},args:{speed:0}},{id:`fan.full`,label:P(`Fan full`,`Ventilatore al massimo`),phrase:P(`Run {device} at full speed`,`Porta {device} alla massima velocità`),icon:`fan`,effect:{field:`speed`,value:100},args:{speed:100},sideEffects:[{field:`preset`,value:``,when:{field:`preset`,notIn:[``]}}]},{id:`fan.speed`,label:P(`Set speed`,`Imposta la velocità`),phrase:P(`Set the speed of {device} to {speed}`,`Imposta la velocità di {device} al {speed}`),icon:`fan`,effect:{field:`speed`,fromArg:`speed`},sideEffects:[{field:`preset`,value:``,when:{field:`preset`,notIn:[``]}}],openArgs:[{key:`speed`,label:P(`Speed`,`Velocità`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setPreset:A(b({deviceId:n().int().nonnegative(),preset:l().min(1)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.preset`,label:P(`Set preset`,`Imposta il preset`),phrase:P(`Set {device} to preset {preset}`,`Imposta {device} sul preset {preset}`),icon:`list`,effect:{field:`preset`,fromArg:`preset`},openArgs:[{key:`preset`,label:P(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`status`,field:`availablePresets`}}]}]}),setDirection:A(b({deviceId:n().int().nonnegative(),direction:uF}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.forward`,label:P(`Spin forward`,`Rotazione avanti`),phrase:P(`Spin {device} forward`,`Fai girare {device} in avanti`),icon:`refresh-cw`,effect:{field:`direction`,value:`forward`},args:{direction:`forward`}},{id:`fan.reverse`,label:P(`Spin in reverse`,`Rotazione inversa`),phrase:P(`Spin {device} in reverse`,`Fai girare {device} al contrario`),icon:`rotate-ccw`,effect:{field:`direction`,value:`reverse`},args:{direction:`reverse`}}]}),setOscillating:A(b({deviceId:n().int().nonnegative(),oscillating:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.oscillateOn`,label:P(`Oscillate`,`Oscillazione attiva`),phrase:P(`Make {device} oscillate`,`Fai oscillare {device}`),icon:`move-horizontal`,effect:{field:`oscillating`,value:!0},args:{oscillating:!0}},{id:`fan.oscillateOff`,label:P(`Stop oscillating`,`Oscillazione spenta`),phrase:P(`Stop {device} oscillating`,`Ferma l’oscillazione di {device}`),icon:`move-horizontal`,effect:{field:`oscillating`,value:!1},args:{oscillating:!1}}]}),setOscillationAxis:A(xF,bF,{kind:`mutation`,auth:`protected`,actions:[{id:`fan.horizontalOscillateOn`,label:P(`Horizontal oscillation on`,`Oscillazione orizzontale attiva`),phrase:P(`Start the horizontal oscillation of {device}`,`Attiva l’oscillazione orizzontale di {device}`),icon:`move-horizontal`,args:{axis:`horizontal`,oscillating:!0}},{id:`fan.horizontalOscillateOff`,label:P(`Horizontal oscillation off`,`Oscillazione orizzontale spenta`),phrase:P(`Stop the horizontal oscillation of {device}`,`Ferma l’oscillazione orizzontale di {device}`),icon:`move-horizontal`,args:{axis:`horizontal`,oscillating:!1}},{id:`fan.verticalOscillateOn`,label:P(`Vertical oscillation on`,`Oscillazione verticale attiva`),phrase:P(`Start the vertical oscillation of {device}`,`Attiva l’oscillazione verticale di {device}`),icon:`move-vertical`,args:{axis:`vertical`,oscillating:!0}},{id:`fan.verticalOscillateOff`,label:P(`Vertical oscillation off`,`Oscillazione verticale spenta`),phrase:P(`Stop the vertical oscillation of {device}`,`Ferma l’oscillazione verticale di {device}`),icon:`move-vertical`,args:{axis:`vertical`,oscillating:!1}}]})},status:{schema:CF,kind:`push`},runtimeState:CF,customize:Ewe,durability:`session`,history:{fields:{speed:{kind:`gauge`,unit:`%`,minIntervalMs:0},oscillating:{kind:`boolean`}}},vocabulary:{noun:P(`Fan`,`Ventilatore`),order:1080,state:[{kind:`numeric`,field:`speed`,quantity:P(`the speed`,`la velocità`),label:P(`Speed`,`Velocità`),unit:`%`,icon:`fan`},{kind:`boolean`,field:`oscillating`,label:P(`Oscillating`,`Oscillazione`),whenTrue:P(`When {device} starts oscillating`,`Quando {device} inizia a oscillare`),whenFalse:P(`When {device} stops oscillating`,`Quando {device} smette di oscillare`),icon:`move-horizontal`}]}},Dwe=12,kF=b({oscillating:v().optional(),angle:n().optional(),sweepFrom:n().optional(),sweepTo:n().optional()}),AF=b({speed:n().min(0).max(100).optional(),preset:l().min(1).optional(),direction:uF.optional(),oscillationAxes:b({horizontal:kF.optional(),vertical:kF.optional()}).optional()}),jF=b({id:l().min(1).max(64),name:l().trim().min(1).max(40),state:AF}),MF=[`empty-state`,`duplicate-name`,`duplicate-id`,`too-many`,`not-a-fan`],NF=x(MF),PF=i(`status`,[b({status:p(`saved`),count:n().int().nonnegative()}),b({status:p(`refused`),reason:NF,detail:l()})]),FF=b({field:l(),outcome:x([`applied`,`failed`,`not-run`,`refused`]),message:l().optional()}),IF=b({status:x([`applied`,`partial`,`refused`]),fields:S(FF)}),LF=[`speed`,`direction`,`preset`,`oscillationAxes`],RF=x(LF),zF=b({what:l(),reason:l()}),BF=b({state:AF,omitted:S(zF)}),VF=b({deviceId:n().int().nonnegative()}),Owe={version:1,targets:[{id:`presets`,cardinality:`config`,vocabulary:{cap:`fan-presets`},deviceTypes:[T.Fan],apply:`add`,readMethod:`getPresets`,writeMethod:`setPresets`}]},HF={name:`fan-presets`,scope:`system`,mode:`singleton`,methods:{getPresets:k(VF,S(jF),{auth:`protected`}),setPresets:k(VF.extend({presets:S(jF).max(12)}),PF,{kind:`mutation`,auth:`admin`}),applyPreset:k(VF.extend({presetId:l().min(1)}),IF,{kind:`mutation`,auth:`protected`}),capturePreset:k(VF.extend({fields:S(RF).optional()}),BF,{auth:`protected`})},customize:Owe,vocabulary:{notOperatorFacing:`the per-fan presets — authored in the Customize presets editor, applied through the actions the exports list`}},UF=b({flags:m(l(),C()),deviceType:l().nullable(),model:l().nullable(),channelCount:n().nullable().meta(M(`count`)),lastProbedAt:n(),lastFetchedAt:n()}),WF={name:`feature-probe`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},events:{onProbeChanged:{data:b({deviceId:n(),status:UF}),notOperatorFacing:`the device’s capabilities were re-probed — plumbing, not a happening`}},status:{schema:UF,kind:`push`},runtimeState:UF,durability:`session`,history:`none`,vocabulary:{noun:P(`Feature probe`,`Rilevamento funzioni`),order:3120}},kwe=b({name:l(),path:l()}),Awe=b({path:l(),entries:S(kwe).readonly(),freeBytes:n(),totalBytes:n()}),GF={name:`filesystem-browse`,scope:`system`,mode:`singleton`,internal:!0,methods:{listAllowedRoots:k(_(),S(l()).readonly(),{auth:`admin`}),browse:k(b({path:l()}),Awe,{auth:`admin`}),createDir:k(b({path:l()}),b({path:l()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:j.INTERNAL}},KF=b({flooded:v(),lastChangedAt:n()}),qF={name:`flood`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Sensor],methods:{},status:{schema:KF,kind:`push`},runtimeState:KF,durability:`restored`,history:{fields:{flooded:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:P(`Leak sensor`,`Sensore di allagamento`),order:5070,state:[{kind:`boolean`,field:`flooded`,label:P(`Leak`,`Perdita`),whenTrue:P(`When {device} detects a leak`,`Quando {device} rileva una perdita`),whenFalse:P(`When {device} is dry again`,`Quando {device} torna asciutto`),icon:`droplets`}]}},JF=b({detected:v(),lastChangedAt:n()}),YF={name:`gas`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Sensor],methods:{},status:{schema:JF,kind:`push`},runtimeState:JF,durability:`restored`,history:{fields:{detected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:P(`Gas sensor`,`Sensore di gas`),order:5080,state:[{kind:`boolean`,field:`detected`,label:P(`Detected`,`Rilevato`),whenTrue:P(`When {device} detects gas`,`Quando {device} rileva gas`),whenFalse:P(`When the gas clears on {device}`,`Quando il gas su {device} rientra`),icon:`flame`}]}},XF=b({active:v().meta({label:`Active`}),lastChangedAt:n()}),ZF={name:`group-active`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Cover,T.Valve,T.Lock,T.MediaPlayer,T.Climate],methods:{},status:{schema:XF,kind:`push`},runtimeState:XF,durability:`session`,history:`none`,vocabulary:{noun:P(`Group state`,`Stato del gruppo`),order:5090}},QF=b({deviceId:n().int().nonnegative(),cap:l().min(1),method:l().min(1),ok:v(),error:l().optional(),at:n()}),$F=b({results:S(QF)}),eI={name:`group-commands`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Switch,T.Light,T.Fan,T.Cover,T.Valve,T.Lock,T.MediaPlayer,T.Climate],methods:{},status:{schema:$F,kind:`push`},runtimeState:$F,durability:`session`,history:`none`,vocabulary:{noun:P(`Group command`,`Comando di gruppo`),order:5100}},tI=b({included:n().int().nonnegative().meta(M(`count`,{precision:0,label:`Reporting`})),excluded:n().int().nonnegative().meta(M(`count`,{precision:0,label:`Excluded`})),total:n().int().nonnegative().meta(M(`count`,{precision:0,label:`Members`}))}),nI={name:`group-status`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Sensor,T.Switch,T.Light,T.Fan,T.Cover,T.Valve,T.Lock,T.MediaPlayer,T.Climate],methods:{},status:{schema:tI,kind:`push`},runtimeState:tI,durability:`session`,history:`none`,vocabulary:{noun:P(`Group`,`Gruppo`),order:5110,state:[{kind:`numeric`,field:`included`,quantity:P(`the members reporting`,`i membri che rispondono`),label:P(`Reporting`,`Rispondono`),icon:`users`},{kind:`numeric`,field:`excluded`,quantity:P(`the members left out`,`i membri esclusi`),label:P(`Excluded`,`Esclusi`),icon:`users`},{kind:`numeric`,field:`total`,quantity:P(`the member count`,`il numero di membri`),label:P(`Members`,`Membri`),icon:`sigma`}]}},rI=n().int().nonnegative(),iI=l().min(1),aI=l().min(1),oI=n().finite(),sI={key:`circuitId`,label:P(`Circuit`,`Circuito`),offer:{kind:`dynamic`,from:`status`,cap:`heat-pump-status`,field:`circuits`,valueKey:`id`,labelKey:`label`,where:{key:`kind`,equals:`heating`}}},cI={...sI,label:P(`Hot water circuit`,`Circuito acqua calda`),offer:{...sI.offer,where:{key:`kind`,equals:`dhw`}}},lI={key:`mode`,label:P(`Mode`,`Modalità`),offer:{kind:`text`}},jwe={key:`level`,label:P(`Level`,`Livello`),offer:{kind:`text`}},uI={key:`temp`,label:P(`Temperature`,`Temperatura`),offer:{kind:`number`,step:.5,unit:`°C`}},Mwe={key:`minutes`,label:P(`Minutes`,`Minuti`),offer:{kind:`number`,min:1,step:1,unit:`min`}},dI={name:`heat-pump-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.HeatPump],methods:{setSilentMode:k(b({deviceId:rI,mode:aI}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.silent`,label:P(`Set silent mode`,`Imposta la modalità silenziosa`),phrase:P(`Set silent mode of {device} to {mode}`,`Imposta la modalità silenziosa di {device} su {mode}`),icon:`volume-x`,openArgs:[{key:`mode`,label:P(`Silent mode`,`Modalità silenziosa`),offer:{kind:`enum`,values:[{value:`off`,label:P(`Off`,`Off`)},{value:`auto`,label:P(`Auto`,`Auto`)},{value:`on`,label:P(`On`,`On`)}]}}]}]}),setAwayMode:k(b({deviceId:rI,mode:aI}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.away`,label:P(`Set away mode`,`Imposta la modalità assente`),phrase:P(`Set away mode of {device} to {mode}`,`Imposta la modalità assente di {device} su {mode}`),icon:`plane`,openArgs:[{key:`mode`,label:P(`Away mode`,`Modalità assente`),offer:{kind:`enum`,values:[{value:`off`,label:P(`Off`,`Off`)},{value:`on`,label:P(`On`,`On`)}]}}]}]}),setAdditionalHeaterMode:k(b({deviceId:rI,mode:aI}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.additionalHeater`,label:P(`Set additional heater`,`Imposta il riscaldatore aggiuntivo`),phrase:P(`Set the additional heater of {device} to {mode}`,`Imposta il riscaldatore aggiuntivo di {device} su {mode}`),icon:`flame`,openArgs:[{key:`mode`,label:P(`Additional heater`,`Riscaldatore aggiuntivo`),offer:{kind:`enum`,values:[{value:`off`,label:P(`Off`,`Off`)},{value:`manual`,label:P(`Manual`,`Manuale`)},{value:`auto`,label:P(`Auto`,`Auto`)}]}}]}]}),setHolidayMode:k(b({deviceId:rI,mode:aI}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.holiday`,label:P(`Set holiday mode`,`Imposta la modalità vacanza`),phrase:P(`Set holiday mode of {device} to {mode}`,`Imposta la modalità vacanza di {device} su {mode}`),icon:`tree-palm`,openArgs:[{key:`mode`,label:P(`Holiday programme`,`Programma vacanza`),offer:{kind:`enum`,values:[{value:`off`,label:P(`Off`,`Off`)},{value:`hm1`,label:P(`Programme 1`,`Programma 1`)},{value:`hm2`,label:P(`Programme 2`,`Programma 2`)},{value:`hm3`,label:P(`Programme 3`,`Programma 3`)},{value:`hm4`,label:P(`Programme 4`,`Programma 4`)},{value:`hm5`,label:P(`Programme 5`,`Programma 5`)},{value:`hm6`,label:P(`Programme 6`,`Programma 6`)},{value:`hm7`,label:P(`Programme 7`,`Programma 7`)},{value:`hm8`,label:P(`Programme 8`,`Programma 8`)}]}}]}]}),setCircuitOperationMode:k(b({deviceId:rI,circuitId:iI,mode:aI}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitOperationMode`,label:P(`Set circuit operation mode`,`Imposta la modalità del circuito`),phrase:P(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`thermometer`,openArgs:[sI,lI]}]}),setCircuitHeatCoolMode:k(b({deviceId:rI,circuitId:iI,mode:aI}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitHeatCoolMode`,label:P(`Set circuit heat / cool`,`Imposta caldo / freddo del circuito`),phrase:P(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`sun-snow`,openArgs:[sI,lI]}]}),setCircuitSummerWinter:k(b({deviceId:rI,circuitId:iI,mode:aI}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitSummerWinter`,label:P(`Set circuit summer / winter`,`Imposta estate / inverno del circuito`),phrase:P(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`sun`,openArgs:[sI,lI]}]}),setCircuitComfortSetpoint:k(b({deviceId:rI,circuitId:iI,temp:oI}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitComfortSetpoint`,label:P(`Set comfort temperature`,`Imposta la temperatura comfort`),phrase:P(`Set the comfort temperature of {circuitId} on {device} to {temp}`,`Imposta la temperatura comfort di {circuitId} su {device} a {temp}`),icon:`thermometer-sun`,openArgs:[sI,uI]}]}),setCircuitEcoSetpoint:k(b({deviceId:rI,circuitId:iI,temp:oI}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitEcoSetpoint`,label:P(`Set eco temperature`,`Imposta la temperatura eco`),phrase:P(`Set the eco temperature of {circuitId} on {device} to {temp}`,`Imposta la temperatura eco di {circuitId} su {device} a {temp}`),icon:`leaf`,openArgs:[sI,uI]}]}),setCircuitMaxFlowTemp:k(b({deviceId:rI,circuitId:iI,temp:oI}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitMaxFlowTemp`,label:P(`Set maximum flow temperature`,`Imposta la temperatura massima di mandata`),phrase:P(`Set the maximum flow temperature of {circuitId} on {device} to {temp}`,`Imposta la temperatura massima di mandata di {circuitId} su {device} a {temp}`),icon:`flame`,openArgs:[sI,uI]}]}),setDhwOperationMode:k(b({deviceId:rI,circuitId:iI,mode:aI}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwOperationMode`,label:P(`Set hot water mode`,`Imposta la modalità acqua calda`),phrase:P(`Set hot water {circuitId} of {device} to {mode}`,`Imposta l'acqua calda {circuitId} di {device} su {mode}`),icon:`shower-head`,openArgs:[cI,lI]}]}),setDhwTemperatureLevel:k(b({deviceId:rI,circuitId:iI,level:aI}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwTemperatureLevel`,label:P(`Set hot water level`,`Imposta il livello acqua calda`),phrase:P(`Set hot water {circuitId} of {device} to level {level}`,`Imposta l'acqua calda {circuitId} di {device} al livello {level}`),icon:`droplet`,openArgs:[cI,jwe]}]}),setDhwChargeDuration:k(b({deviceId:rI,circuitId:iI,minutes:n().int().positive()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwChargeDuration`,label:P(`Set hot water charge duration`,`Imposta la durata della carica acqua calda`),phrase:P(`Set the charge of hot water {circuitId} on {device} to {minutes} min`,`Imposta la carica dell'acqua calda {circuitId} di {device} a {minutes} min`),icon:`timer`,openArgs:[cI,Mwe]}]}),startExtraHotWater:k(b({deviceId:rI,circuitId:iI}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.extraHotWater`,label:P(`Start extra hot water`,`Avvia acqua calda extra`),phrase:P(`Start an extra hot water charge of {circuitId} on {device}`,`Avvia una carica extra di acqua calda {circuitId} su {device}`),icon:`droplets`,openArgs:[cI]}]})},vocabulary:{noun:P(`Heat pump settings`,`Impostazioni pompa di calore`),order:4010}},fI=[`heating`,`dhw`,`cooling`,`solar`],pI=x(fI),mI=b({value:l().nullable(),allowed:S(l())}),hI=b({value:n().nullable(),min:n().nullable(),max:n().nullable(),step:n().nullable()}),gI=b({id:l().min(1),kind:pI,label:l(),icon:Ih,currentTemp:n().nullable().meta(M(`temperature`)),targetTemp:n().nullable().meta(M(`temperature`)),mode:l().nullable(),active:v().nullable(),operationMode:mI.nullable(),heatCoolMode:mI.nullable(),summerWinter:mI.nullable(),comfortSetpoint:hI.nullable(),ecoSetpoint:hI.nullable(),maxFlowTemp:hI.nullable(),temperatureLevel:mI.nullable(),chargeDuration:hI.nullable(),extraHotWater:v().nullable()}),_I=b({silent:mI.nullable(),away:mI.nullable(),additionalHeater:mI.nullable(),holiday:mI.nullable()}),vI=b({thermalW:n().nullable().meta(M(`power`)),electricalW:n().nullable().meta(M(`power`)),compressorPct:n().nullable().meta(M(`percentage`))}),yI=b({supply:n().nullable().meta(M(`temperature`)),return:n().nullable().meta(M(`temperature`)),outdoor:n().nullable().meta(M(`temperature`))}),bI=b({thermalKwh:n().nullable().meta(M(`energy`)),electricalKwh:n().nullable().meta(M(`energy`))}),xI=b({circuits:S(gI),system:_I,power:vI,temperatures:yI,energy:bI,waterPressureBar:n().nullable(),starts:n().nullable(),lastFetchedAt:n()});function SI(e){let{thermalW:t,electricalW:n}=e;return t===null||n===null||n<=0?null:t/n}var CI={name:`heat-pump-status`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.HeatPump],methods:{},status:{schema:xI,kind:`push`},runtimeState:xI,durability:`session`,history:{fields:{"power.thermalW":{group:`power`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Thermal power`},"power.electricalW":{group:`power`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Electrical power`},"power.compressorPct":{kind:`gauge`,unit:`%`,deadband:2,displayName:`Compressor`},"temperatures.supply":{group:`loop`,kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Supply`},"temperatures.return":{group:`loop`,kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Return`},"temperatures.outdoor":{kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Outdoor`},"energy.thermalKwh":{kind:`counter`,unit:`kWh`,displayName:`Thermal energy`},"energy.electricalKwh":{kind:`counter`,unit:`kWh`,displayName:`Electrical energy`}},items:{path:`circuits`,key:`id`,label:`label`,fields:{currentTemp:{kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Temperature`},targetTemp:{kind:`gauge`,unit:`°C`,minIntervalMs:0,displayName:`Setpoint`},mode:{kind:`enum`,displayName:`Mode`}}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:P(`Heat pump`,`Pompa di calore`),order:4e3}},wI=b({position:n().min(0).max(100).nullable().meta(M(`percentage`)),lastFetchedAt:n()}),TI={name:`heating-valve`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Climate],methods:{},status:{schema:wI,kind:`push`},runtimeState:wI,durability:`session`,history:{fields:{position:{kind:`gauge`,unit:`%`,deadband:1}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:P(`Radiator valve`,`Valvola termostatica`),order:1110,state:[{kind:`numeric`,field:`position`,quantity:P(`the valve opening`,`l’apertura della valvola`),label:P(`Valve opening`,`Apertura della valvola`),unit:`%`,icon:`heater`}]}},EI=x([`s`,`min`]),Nwe=x([`switch`,`pet-fountain`]),DI={actuator:`switch`,maxSeconds:10800,unit:`min`,quickRunDefault:30},OI={actuator:`pet-fountain`,maxSeconds:300,unit:`s`,quickRunDefault:60},kI=[T.Switch,T.PetFountain],AI={[T.Switch]:[D.SwitchHeater]};function jI(e,t){return e===T.PetFountain?OI:e===T.Switch&&t===D.SwitchHeater?DI:null}var Pwe=1e3,Fwe=6e4;function MI(e,t,n){let r=e-t;return r<=0?0:Math.max(1,Math.ceil(r/(n===`min`?Fwe:Pwe)))}function Iwe(e,t){return t===`min`?e*60:e}function NI(e){return e.unit===`min`?Math.floor(e.maxSeconds/60):e.maxSeconds}var PI=b({duration:n().positive().finite(),unit:EI});function FI(e,t){let n=NI(e);return{duration:Math.min((t!==null&&Number.isFinite(t)&&t>0?t:null)??e.quickRunDefault,n),unit:e.unit}}var II=x([`unsupported-device`,`over-max`,`command-failed`]),LI=i(`ok`,[b({ok:p(!0),activeUntil:n()}),b({ok:p(!1),reason:II,maxSeconds:n().nullable()})]),RI=b({activeUntil:n().nullable(),requestedBy:l().nullable(),quickRun:PI.nullable(),lastFetchedAt:n()}),zI=b({unit:EI,maxDuration:n(),defaultDuration:n()}),BI=b({quickRunDuration:n().positive().finite().nullable().optional()}),VI={name:`timed-run`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:kI,deviceRoles:AI,deviceConfig:{ui:{kind:`derived-form`,builderId:`timed-run`,tab:`general`}},methods:{getOptions:k(b({deviceId:n().int()}),zI),setSettings:k(b({deviceId:n().int(),settings:BI}),_(),{kind:`mutation`,auth:`admin`}),runFor:k(b({deviceId:n().int(),duration:n().positive().finite(),unit:EI}),LI,{kind:`mutation`,auth:`protected`,actions:[{id:`timedRun.runForMinutes`,label:P(`Run for minutes`,`Accendi per alcuni minuti`),phrase:P(`Run {device} for {duration} minutes, then switch it off`,`Tieni acceso {device} per {duration} minuti, poi spegnilo`),icon:`timer`,args:{unit:`min`},openArgs:[{key:`duration`,label:P(`Minutes`,`Minuti`),offer:{kind:`number`,min:1,step:1,unit:`min`}}]},{id:`timedRun.runForSeconds`,label:P(`Run for seconds`,`Accendi per alcuni secondi`),phrase:P(`Run {device} for {duration} seconds, then switch it off`,`Tieni acceso {device} per {duration} secondi, poi spegnilo`),icon:`timer`,args:{unit:`s`},openArgs:[{key:`duration`,label:P(`Seconds`,`Secondi`),offer:{kind:`number`,min:1,step:1,unit:`s`}}]}]}),cancel:k(b({deviceId:n().int()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`timedRun.cancel`,label:P(`Cancel the timer`,`Annulla il timer`),phrase:P(`Cancel the pending switch-off of {device}`,`Annulla lo spegnimento programmato di {device}`),icon:`timer-off`}]})},status:{schema:RI,kind:`push`},runtimeState:RI,durability:`session`,history:`none`,vocabulary:{noun:P(`Timed run`,`Esecuzione a tempo`),order:2150}},HI=[`on`,`off`,`running`,`idle`,`standby`,`alert`,`offline`,`unknown`],UI=[`success`,`warning`,`danger`,`primary`,`info`,`muted`],WI=[`none`,`pulse`,`spin`,`glow`,`halo`,`wave`,`rise`,`fall`,`tumble`,`equalizer`,`blink`,`breathe`],GI=[`plain`,`heat-rise`,`cool-fall`,`glow`,`water`,`drum`,`sky`,`mist`,`alert-wash`],KI=x(HI),qI=x(UI),Lwe=x(WI),JI=b({icon:Ih,tone:qI,background:x(GI),animation:Lwe});function YI(e){let t=pO[e];return t===void 0?null:`cap:${e}.${t.field}`}function Rwe(e){return e.enabledCaps.flatMap(e=>{let t=YI(e),n=pO[e];return t===null||n===void 0?[]:[{key:t,priority:n.priority}]}).sort((e,t)=>t.priority-e.priority).find(t=>e.hasData(t.key))?.key??null}var XI=b({en:l(),it:l()}),ZI={en:`—`,it:`—`};function zwe(e){return e.en===ZI.en&&e.it===ZI.it}var QI=[`temperature`,`humidity`,`power`,`contact`,`text`],$I=[`hot`,`mild`,`cold`],eL=[`updated`,`changed`],tL=b({value:n(),quantity:da}),nL=b({quantity:x(QI),reading:tL.nullable(),icon:Ih.nullable(),value:XI,unit:l().nullable(),band:x($I).nullable(),level:n().min(0).max(1).nullable(),word:XI,tone:x(UI),since:n().nullable(),sinceKind:x(eL),historyKey:l().nullable()}),Bwe=3e3,rL=e=>P(e,e),iL=e=>Math.min(1,Math.max(0,e)),Vwe=(e,t)=>String(Number(e.toFixed(t)));function aL(e){return e<12?`cold`:e>28?`hot`:`mild`}var Hwe={hot:P(`Hot`,`Caldo`),mild:P(`Normal`,`Normale`),cold:P(`Cold`,`Freddo`)},Uwe={hot:`warning`,mild:`muted`,cold:`info`};function oL(e,t){let n=aL(e);return{quantity:`temperature`,reading:{value:e,quantity:`temperature`},icon:`thermometer`,value:rL(Vwe(e,1)),unit:`°C`,band:n,level:null,word:Hwe[n],tone:Uwe[n],since:t,sinceKind:`updated`,historyKey:YI(`temperature-sensor`)}}function sL(e,t){let n=e<30,r=e>70;return{quantity:`humidity`,reading:{value:e,quantity:`humidity`},icon:`droplets`,value:rL(String(Math.round(e))),unit:`%`,band:null,level:iL(e/100),word:n?P(`Dry`,`Secco`):r?P(`Humid`,`Umido`):P(`Normal`,`Normale`),tone:n||r?`warning`:`info`,since:t,sinceKind:`updated`,historyKey:YI(`humidity-sensor`)}}function cL(e,t){let n=e>0;return{quantity:`power`,reading:{value:e,quantity:`power`},icon:`zap`,value:rL(String(Math.round(e))),unit:`W`,band:null,level:iL(e/Bwe),word:n?P(`Active`,`Attivo`):P(`Idle`,`Inattivo`),tone:n?`primary`:`muted`,since:t,sinceKind:`updated`,historyKey:YI(`power-meter`)}}function lL(e,t){return{quantity:`contact`,reading:null,icon:e?`door-open`:`door-closed`,value:e?P(`Open`,`Aperto`):P(`Closed`,`Chiuso`),unit:null,band:null,level:+!!e,word:e?P(`Open`,`Aperto`):P(`Closed`,`Chiuso`),tone:e?`warning`:`success`,since:t,sinceKind:`changed`,historyKey:null}}function uL(e,t){return{quantity:`text`,reading:null,icon:null,value:rL(e),unit:null,band:null,level:null,word:P(`Changed`,`Cambiato`),tone:`muted`,since:t,sinceKind:`updated`,historyKey:null}}var Wwe={temperature:{icon:`thermometer`,unit:`°C`,sinceKind:`updated`,historyKey:YI(`temperature-sensor`)},humidity:{icon:`droplets`,unit:`%`,sinceKind:`updated`,historyKey:YI(`humidity-sensor`)},power:{icon:`zap`,unit:`W`,sinceKind:`updated`,historyKey:YI(`power-meter`)},contact:{icon:null,unit:null,sinceKind:`changed`,historyKey:null},text:{icon:null,unit:null,sinceKind:`updated`,historyKey:null}};function dL(e){let t=Wwe[e];return{quantity:e,reading:null,icon:t.icon,value:ZI,unit:t.unit,band:null,level:null,word:ZI,tone:`muted`,since:null,sinceKind:t.sinceKind,historyKey:t.historyKey}}var Gwe={power:new Set([`energy-sensor`,`voltage-sensor`,`current-sensor`])};function fL(e,t){return t===null?!0:!(Gwe[e.quantity]?.has(t)??!1)}var pL=`ac.thermostat.heater.heat-pump.fan.washer.dryer.dishwasher.pet-fountain.pet-feeder.vacuum.lawn-mower.tv.speaker.camera.light.cover.lock.alarm.siren.sensor-sparkline.contact.presence.weather.plug.button.update.control-dial.event-stream.gateway.generic`.split(`.`),Kwe=x(pL),mL=[`cool`,`heat`,`dry`,`fan`,`auto`,`playing`,`paused`,`open`,`closed`],hL=b({id:Kwe,mode:x(mL).nullable(),level:n().min(0).max(1).nullable()}),gL={[T.Camera]:`camera`,[T.Light]:`light`,[T.Siren]:`siren`,[T.Switch]:`plug`,[T.Sensor]:`sensor-sparkline`,[T.Climate]:`thermostat`,[T.Button]:`button`,[T.EventEmitter]:`event-stream`,[T.Update]:`update`,[T.Generic]:`generic`,[T.Notifier]:`event-stream`,[T.Script]:`event-stream`,[T.Automation]:`event-stream`,[T.Lock]:`lock`,[T.Cover]:`cover`,[T.Valve]:`control-dial`,[T.Humidifier]:`control-dial`,[T.WaterHeater]:`heater`,[T.HeatPump]:`heat-pump`,[T.EnergySystem]:`generic`,[T.Workload]:`generic`,[T.Fan]:`fan`,[T.MediaPlayer]:`tv`,[T.AlarmPanel]:`alarm`,[T.Control]:`control-dial`,[T.Presence]:`presence`,[T.Weather]:`weather`,[T.WeatherStation]:`weather`,[T.Vacuum]:`vacuum`,[T.LawnMower]:`lawn-mower`,[T.Container]:`generic`,[T.Image]:`camera`,[T.PetFeeder]:`pet-feeder`,[T.PetFountain]:`pet-fountain`,[T.Dishwasher]:`dishwasher`,[T.Washer]:`washer`,[T.Dryer]:`dryer`,[T.Gateway]:`gateway`},_L={[D.Siren]:`siren`,[D.Floodlight]:`light`,[D.Spotlight]:`light`,[D.PirSensor]:`presence`,[D.Chime]:`speaker`,[D.Autotrack]:`inherit`,[D.Nightvision]:`inherit`,[D.PrivacyMask]:`inherit`,[D.Doorbell]:`inherit`,[D.CoverBlind]:`inherit`,[D.CoverShutter]:`inherit`,[D.CoverAwning]:`inherit`,[D.CoverCurtain]:`inherit`,[D.CoverGarage]:`inherit`,[D.CoverGate]:`inherit`,[D.CoverDoor]:`inherit`,[D.CoverWindow]:`inherit`,[D.BinaryHelper]:`inherit`,[D.Outlet]:`plug`,[D.SwitchHeater]:`heater`,[D.SwitchFan]:`fan`,[D.SwitchLight]:`light`,[D.PoePort]:`plug`,[D.ClimateAc]:`ac`,[D.ClimateThermostat]:`inherit`,[D.ClimateFloor]:`inherit`,[D.ClimateRadiator]:`inherit`,[D.ClimateHeater]:`inherit`,[D.ClimateHeatPumpCircuit]:`inherit`,[D.MotionSensor]:`presence`,[D.ContactSensor]:`contact`,[D.LeakSensor]:`inherit`,[D.SmokeSensor]:`alarm`,[D.COSensor]:`alarm`,[D.GasSensor]:`alarm`,[D.TamperSensor]:`inherit`,[D.VibrationSensor]:`inherit`,[D.ConnectivitySensor]:`inherit`,[D.SoundSensor]:`inherit`,[D.BinarySensor]:`inherit`,[D.TemperatureSensor]:`sensor-sparkline`,[D.HumiditySensor]:`sensor-sparkline`,[D.AmbientLightSensor]:`inherit`,[D.PressureSensor]:`weather`,[D.WindSensor]:`weather`,[D.RainSensor]:`weather`,[D.UvSensor]:`weather`,[D.SolarRadiationSensor]:`weather`,[D.SoilMoistureSensor]:`inherit`,[D.PowerSensor]:`plug`,[D.EnergySensor]:`plug`,[D.VoltageSensor]:`plug`,[D.CurrentSensor]:`plug`,[D.AirQualitySensor]:`inherit`,[D.BatterySensor]:`inherit`,[D.NumericSensor]:`inherit`,[D.EnumSensor]:`inherit`,[D.DateTimeSensor]:`inherit`,[D.GenericSensor]:`inherit`,[D.NumericControl]:`control-dial`,[D.SelectControl]:`control-dial`,[D.TextControl]:`inherit`,[D.DateTimeControl]:`inherit`,[D.MobilePushNotifier]:`inherit`,[D.MessagingNotifier]:`inherit`,[D.EmailNotifier]:`inherit`,[D.GenericNotifier]:`inherit`,[D.IrTransmitter]:`inherit`,[D.Vm]:`inherit`,[D.AppContainer]:`inherit`,[D.Lxc]:`inherit`,[D.App]:`inherit`,[D.Host]:`inherit`,[D.Ups]:`inherit`};function qwe(e){return Object.values(T).includes(e)}function Jwe(e){return Object.values(D).includes(e)}function vL(e,t){let n=e!==null&&Jwe(e)?_L[e]:void 0;return n!==void 0&&n!==`inherit`?n:qwe(t)?gL[t]:`generic`}var yL=`progress.run-for.cycle.program.appliance-power.now-playing.playback.volume.source.contact.motion-trigger.lock.alarm.fan.vacuum.vacuum-suction.mower.feeder.fountain.pump-cycle.automation.script.do-not-disturb.brightness.color.cover.valve.humidifier.update.button.climate-mode.climate-fan.setpoint.channel.control.circuit.heat-pump-power.system-mode`.split(`.`),bL=x(yL),Ywe={progress:P(`Progress`,`Avanzamento`),"run-for":P(`Run for`,`Avvia per`),cycle:P(`Cycle`,`Ciclo`),program:P(`Program`,`Programma`),"appliance-power":P(`Appliance`,`Elettrodomestico`),"now-playing":P(`Now playing`,`In riproduzione`),playback:P(`Playback`,`Riproduzione`),volume:P(`Volume`,`Volume`),source:P(`Source`,`Sorgente`),contact:P(`Door`,`Porta`),"motion-trigger":P(`Motion`,`Movimento`),lock:P(`Lock`,`Serratura`),alarm:P(`Alarm`,`Allarme`),fan:P(`Fan`,`Ventola`),vacuum:P(`Cleaning`,`Pulizia`),"vacuum-suction":P(`Suction`,`Aspirazione`),mower:P(`Mowing`,`Taglio`),feeder:P(`Feed now`,`Eroga ora`),fountain:P(`Pump`,`Pompa`),"pump-cycle":P(`Pump cycle`,`Ciclo pompa`),automation:P(`Automation`,`Automazione`),script:P(`Script`,`Script`),"do-not-disturb":P(`Do not disturb`,`Non disturbare`),brightness:P(`Brightness`,`Luminosità`),color:P(`Colour`,`Colore`),cover:P(`Position`,`Posizione`),valve:P(`Valve`,`Valvola`),humidifier:P(`Humidifier`,`Umidificatore`),update:P(`Firmware`,`Firmware`),button:P(`Action`,`Azione`),"climate-mode":P(`Mode`,`Modalità`),"climate-fan":P(`Fan`,`Ventola`),setpoint:P(`Setpoint`,`Temperatura`),channel:P(`Channel`,`Canale`),control:P(`Control`,`Controllo`),circuit:P(`Circuit`,`Circuito`),"heat-pump-power":P(`Power`,`Potenza`),"system-mode":P(`Mode`,`Modalità`)},xL=a(()=>h([l(),n(),v(),m(l(),xL)])),Xwe=m(l(),xL);function SL(e,t,n){let[r,...i]=t;if(r===void 0)return e;if(i.length===0)return{...e,[r]:n};let a=e[r],o=typeof a==`object`?a:{};return{...e,[r]:SL(o,i,n)}}function Zwe(e,t,n){return SL(e,t.split(`.`),n)}var CL=b({cap:l(),method:l(),args:Xwe}),Qwe=x([`off-while-running`,`unlock`,`install`,`press`]),wL=b({id:l(),label:XI,icon:Ih,call:CL,emphasis:x([`primary`,`normal`]),confirm:Qwe.nullable()}),TL=i(`kind`,[b({kind:p(`action`),action:wL}),b({kind:p(`toggle`),id:l(),label:XI,on:v().nullable(),turnOn:wL,turnOff:wL}),b({kind:p(`slider`),id:l(),label:XI,value:n().nullable(),min:n(),max:n(),step:n(),unit:l(),call:CL,valueArg:l()}),b({kind:p(`picker`),id:l(),label:XI,current:l().nullable(),options:S(l()),optionLabels:m(l(),XI).optional(),call:CL,valueArg:l()}),b({kind:p(`number`),id:l(),label:XI,value:n().nullable(),step:n().nullable(),unit:l(),call:CL,valueArg:l()}),b({kind:p(`text`),id:l(),label:XI,value:l().nullable(),call:CL,valueArg:l()})]),$we=b({icon:Ih.nullable(),text:XI,tone:qI}),eTe=new Set([`cover`,`valve`,`lock`,`vacuum`,`playback`,`brightness`]),tTe=b({id:bL,placement:x([`row`,`scene`]).optional(),label:XI.optional(),group:XI.optional(),pills:S($we).optional(),icon:Ih,status:XI.nullable(),controls:S(TL),progress:n().min(0).max(1).nullable().optional()}),EL=b({label:XI,value:h([n(),l()]),unit:l().nullable()}),nTe=b({id:x([`battery`,`network-link`,`integration`]),icon:Ih,tone:qI,value:n().nullable(),label:XI}),DL=`remote.open`,rTe=b({commands:n().int().nullable(),open:wL.optional()}),iTe=b({items:S(b({key:l(),label:l(),level:n().nullable(),needsAttention:v()})),attention:n().int()}),aTe=i(`kind`,[b({kind:p(`power`),watts:n(),detail:S(EL)}),b({kind:p(`running`),running:v().nullable(),since:n().nullable(),phase:l().nullable(),detail:S(EL)})]),oTe=b({source:x([`switch`,`media-player`,`climate-control`]),on:v().nullable(),assumed:v(),turnOn:wL,turnOff:wL}),sTe=b({activeUntil:n().nullable(),quickRun:PI,run:wL,cancel:wL,remaining:n().nullable()}),cTe=b({on:v().nullable(),confirmOffWhileRunning:v(),running:v().nullable(),powerOn:wL.nullable(),powerOff:wL.nullable(),restart:wL}),OL=b({token:x(GI),animation:x(WI)}),kL=b({id:x([`power`,`energy`,`battery`,`link`,`phase`,`remaining`,`volume`,`source`,`consumables`,`since`,`speed`,`progress`,`level`,`last-run`,`event`,`members`,`failures`,`reading`,`climate`,`temperature`,`humidity`,`pressure`,`air-quality`,`illuminance`,`valve`]),icon:Ih.nullable(),text:XI,tone:qI}),AL=b({label:XI,value:XI,tone:qI.optional(),at:n().optional()}),lTe=b({left:S(AL).max(2),right:S(AL).max(2)}),uTe=i(`kind`,[b({kind:p(`artwork`),url:l(),fallback:OL}),b({kind:p(`state`),...OL.shape})]),dTe=b({partId:l(),cap:l()}),fTe=b({deviceId:n().int(),type:l(),role:l().nullable(),name:l(),state:KI,stateAssumed:v(),look:JI,background:uTe,scene:hL,facts:S(kL),sideTiles:lTe,title:XI,caption:XI.optional(),badges:S(nTe),remote:rTe.nullable(),historyLabel:XI,consumables:iTe.nullable(),consumption:aTe.nullable(),ownPower:oTe.nullable(),timedRun:sTe.nullable(),powerSupply:cTe.nullable(),rows:S(tTe),measurement:nL.optional(),gated:S(l()),provenance:S(dTe)}),pTe=b({id:x([`timed-run.run`,`timed-run.cancel`]),duration:n(),unit:x([`min`,`s`])}),jL=b({deviceId:n().int(),name:l(),type:l(),state:KI,stateAssumed:v(),look:JI,scene:hL,statusLine:S(XI),primary:TL.nullable(),primaryGated:v().optional(),timedRun:pTe.nullable(),extras:S(TL).max(2).optional(),trailing:kL.nullable(),measurement:nL.optional()}),ML=[`temperature`,`humidity`,`pressure`,`illuminance`,`reading`,`air-quality`,`valve`],mTe=[`power`,`battery`,`consumables`],hTe=new Set(ML);function gTe(e){for(let t of mTe){let n=e.facts.find(e=>e.id===t);if(n!==void 0)return n}return e.facts.find(t=>hTe.has(t.id)&&t.text.en===e.title.en)??null}var _Te={[T.Climate]:`climate.mode`};function vTe(e){let t=_Te[e.type];if(t!==void 0){let n=PL(e,t);if(n!==null)return{control:n,gated:!1}}let n=e.ownPower;if(n!==null)return e.gated.includes(`own-power`)?{control:null,gated:!0}:{control:{kind:`toggle`,id:`own-power`,label:n.turnOn.label,on:n.on,turnOn:n.turnOn,turnOff:n.turnOff},gated:!1};for(let t of e.rows){let n=t.controls[0];if(n!==void 0)return e.gated.includes(t.id)?{control:null,gated:!0}:{control:n,gated:!1}}return{control:null,gated:!1}}var yTe={[T.Climate]:[`climate.target`],[T.Vacuum]:[`vacuum.base`],[T.LawnMower]:[`mower.dock`],[T.MediaPlayer]:[`volume.level`,DL],[T.Automation]:[`automation.enabled`]},NL=e=>e.kind===`action`?e.action.id:e.id;function PL(e,t){if(t===`remote.open`){let t=e.remote?.open;return t===void 0||e.gated.includes(`remote`)?null:{kind:`action`,action:t}}for(let n of e.rows){if(e.gated.includes(n.id))continue;let r=n.controls.find(e=>NL(e)===t);if(r!==void 0)return r}return null}function bTe(e,t){let n=yTe[e.type]??[],r=t===null?null:NL(t);return n.filter(e=>e!==r).flatMap(t=>{let n=PL(e,t);return n===null?[]:[n]}).slice(0,2)}function xTe(e,t){let n=e.rows.find(e=>e.id===`now-playing`)?.status??null??e.title,r=e.facts.filter(e=>e!==t).map(e=>e.text).slice(0,3),i=e.timedRun;if(i===null||i.remaining===null)return[n,...r];let a=i.quickRun.unit===`min`?`min`:`s`,o={en:`${i.remaining} ${a}`,it:`${i.remaining} ${a}`};return[n,...r,o]}function STe(e){let t=e.timedRun;return t===null||e.gated.includes(`timed-run`)?null:{id:t.activeUntil===null?`timed-run.run`:`timed-run.cancel`,duration:t.quickRun.duration,unit:t.quickRun.unit}}function CTe(e){let t=gTe(e),{control:n,gated:r}=vTe(e);return{deviceId:e.deviceId,name:e.name,type:e.type,state:e.state,stateAssumed:e.stateAssumed,look:e.look,scene:e.scene,statusLine:xTe(e,t),primary:n,primaryGated:r,timedRun:STe(e),extras:bTe(e,n),trailing:t,...e.measurement===void 0?{}:{measurement:e.measurement}}}var wTe=b({deviceId:n().int().nonnegative(),canActuate:v().optional()}),TTe=500,ETe=b({deviceIds:S(n().int().nonnegative()).max(500),canActuate:v().optional()}),FL=b({type:l(),rows:S(bL)}),IL={name:`hero-layout`,scope:`system`,mode:`singleton`,methods:{getHeroModel:k(wTe,fTe.nullable(),{auth:`protected`,role:`viewer`}),getRowModels:k(ETe,S(jL.nullable()),{auth:`protected`,role:`viewer`}),getLayout:k(b({deviceType:l(),role:l().nullable().optional()}),FL,{auth:`protected`,role:`viewer`})},vocabulary:{notOperatorFacing:`the device hero model — read-only data the UI draws, never actuated`}},LL=b({on:v(),currentHumidity:n().min(0).max(100).nullable().meta(M(`humidity`)),targetHumidity:n().min(0).max(100).nullable().meta(M(`humidity`)),mode:l().nullable(),availableModes:S(l()),action:l().nullable(),minHumidity:n().nullable().meta(M(`humidity`)),maxHumidity:n().nullable().meta(M(`humidity`)),lastChangedAt:n()}),RL={name:`humidifier`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Humidifier],power:{kind:`field`,field:`on`,set:`setOn`},methods:{setOn:k(b({deviceId:n().int().nonnegative(),on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.on`,label:P(`Humidifier on`,`Umidificatore acceso`),phrase:P(`Turn on {device}`,`Accendi {device}`),icon:`power`,effect:{field:`on`,value:!0},args:{on:!0}},{id:`humidifier.off`,label:P(`Humidifier off`,`Umidificatore spento`),phrase:P(`Turn off {device}`,`Spegni {device}`),icon:`power-off`,effect:{field:`on`,value:!1},args:{on:!1}}]}),setTargetHumidity:k(b({deviceId:n().int().nonnegative(),humidity:n().min(0).max(100)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.target`,label:P(`Set humidity`,`Imposta l’umidità`),phrase:P(`Set {device} to {humidity} humidity`,`Imposta {device} al {humidity} di umidità`),icon:`droplets`,effect:{field:`targetHumidity`,fromArg:`humidity`},openArgs:[{key:`humidity`,label:P(`Humidity`,`Umidità`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setMode:k(b({deviceId:n().int().nonnegative(),mode:l().min(1)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.mode`,label:P(`Set mode`,`Imposta la modalità`),phrase:P(`Set {device} to {mode}`,`Imposta {device} su {mode}`),icon:`list`,effect:{field:`mode`,fromArg:`mode`},openArgs:[{key:`mode`,label:P(`Mode`,`Modalità`),offer:{kind:`dynamic`,from:`status`,field:`availableModes`}}]}]})},status:{schema:LL,kind:`push`},runtimeState:LL,durability:`session`,history:{fields:{currentHumidity:{kind:`gauge`,unit:`%`,deadband:.5},on:{kind:`boolean`}}},vocabulary:{noun:P(`Humidifier`,`Umidificatore`),order:1090,state:[{kind:`boolean`,field:`on`,label:P(`On`,`Acceso`),whenTrue:P(`When {device} turns on`,`Quando {device} si accende`),whenFalse:P(`When {device} turns off`,`Quando {device} si spegne`),icon:`power`},{kind:`numeric`,field:`currentHumidity`,quantity:P(`the humidity`,`l’umidità`),label:P(`Humidity`,`Umidità`),unit:`%`,icon:`droplets`}]}},zL=b({humidity:n().min(0).max(100).nullable().meta(M(`humidity`,{precision:0,label:`Humidity`})),lastFetchedAt:n()}),BL={name:`humidity-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Sensor,T.Climate],methods:{},status:{schema:zL,kind:`push`},runtimeState:zL,durability:`restored`,history:{primary:`humidity`,priority:90,fields:{humidity:{kind:`gauge`,unit:`%`,deadband:.5}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:P(`Humidity`,`Umidità`),order:5120,state:[{kind:`numeric`,field:`humidity`,quantity:P(`the humidity`,`l’umidità`),label:P(`Humidity`,`Umidità`),unit:`%`,icon:`droplets`}]}},VL=b({url:l().nullable(),lastUpdated:n().nullable().meta(M(`none`))}),HL={name:`image`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Image],methods:{},status:{schema:VL,kind:`push`},runtimeState:VL,durability:`session`,history:`none`,vocabulary:{noun:P(`Image`,`Immagine`),order:3130}},UL=x([`0`,`90`,`180`,`270`]),WL=x([`auto`,`manual`]),GL=x([`auto`,`manual`]),KL=x([`off`,`blc`,`wdr`,`hlc`]),qL=b({min:n(),max:n(),step:n()}),JL=b({brightness:n().optional().meta(M(`none`)),contrast:n().optional().meta(M(`none`)),saturation:n().optional().meta(M(`none`)),sharpness:n().optional().meta(M(`none`)),mirror:v().optional(),flip:v().optional(),rotate:UL.optional(),whiteBalance:WL.optional(),warmth:n().optional().meta(M(`none`)),exposureMode:GL.optional(),backlightMode:KL.optional(),lastFetchedAt:n()}),YL=b({supportsBrightness:v(),brightness:qL.optional(),supportsContrast:v(),contrast:qL.optional(),supportsSaturation:v(),saturation:qL.optional(),supportsSharpness:v(),sharpness:qL.optional(),supportsMirror:v(),supportsFlip:v(),rotateOptions:S(UL),whiteBalanceModes:S(WL),supportsWarmth:v(),warmth:qL.optional(),exposureModes:S(GL),backlightModes:S(KL)}),XL=b({brightness:n().optional(),contrast:n().optional(),saturation:n().optional(),sharpness:n().optional(),mirror:v().optional(),flip:v().optional(),rotate:UL.optional(),whiteBalance:WL.optional(),warmth:n().optional(),exposureMode:GL.optional(),backlightMode:KL.optional()}),ZL={name:`image-settings`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Camera],deviceConfig:{ui:{kind:`derived-form`,builderId:`image-settings`,tab:`image`}},methods:{getOptions:k(b({deviceId:n()}),YL),setSettings:k(b({deviceId:n(),settings:XL}),_(),{kind:`mutation`,auth:`admin`})},status:{schema:JL,kind:`poll`},runtimeState:JL,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:P(`Image settings`,`Impostazioni immagine`),order:3140}},QL=b({id:l(),addonId:l(),name:l(),enabled:v(),info:m(l(),C()).readonly(),originStableId:l().optional(),createdAt:n(),updatedAt:n(),processState:l()}),$L=b({id:l(),addonId:l(),name:l(),enabled:v(),info:m(l(),C()).readonly(),originStableId:l().optional(),createdAt:n(),updatedAt:n()}),eR=b({addonId:l(),name:l(),providerLabel:l().optional(),description:l(),iconUrl:l().nullable(),color:l(),instanceMode:l(),mode:x([`standalone`,`account`,`broker`]),discoveryMode:l(),kind:x([`device-adoption`,`device-provider`]),brokerKind:l().nullable(),supportsLocationImport:v(),canTest:v(),existingInstances:S(b({id:l(),name:l()})),canAdd:v()}),tR=x([`validated`,`rejected`,`inconclusive`,`unsupported`]),nR=b({success:v(),error:l().optional(),status:tR.optional(),testedBy:l().nullable().optional(),latencyMs:n().nonnegative().optional(),detail:l().optional()}),rR=b({id:l(),name:l().optional(),enabled:v().optional(),info:m(l(),C()).optional()}),iR=b({success:v(),deletedId:l()}),aR={name:`integrations`,scope:`system`,mode:`singleton`,methods:{list:k(_(),S(QL)),get:k(b({id:l()}),QL),getByAddonId:k(b({addonId:l()}),$L.nullable()),listByAddon:k(b({addonId:l()}),S($L)),adoptInstanceRows:k(b({addonId:l(),rows:S(b({id:l().min(1),name:l(),enabled:v(),stated:v()}))}),b({created:n().int(),updated:n().int(),conflicts:S(b({id:l(),ownerAddonId:l()}))}),{kind:`mutation`,auth:`admin`}),update:k(rR,$L,{kind:`mutation`,auth:`admin`}),delete:k(b({id:l()}),iR,{kind:`mutation`,auth:`admin`}),getAvailableTypes:k(_(),S(eR),{auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:j.ADDON_ADMIN}},DTe=ye(),oR=l().min(1),sR=x([`single`,`multiple`]),cR=x([`devices`,`services`]),lR=b({id:l().min(1),label:l().min(1),functionCap:l().min(1),brokerKind:l().min(1).optional(),alsoServes:S(l().min(1)).optional(),iconUrl:l().min(1).optional(),iconMediaType:l().min(1).optional(),role:cR.optional(),canTest:v().optional(),signIn:b({basePath:l().min(1),methods:S(x([`device-code`,`proxy`])).optional()}).optional(),connectPath:l().min(1).optional(),disconnectPath:l().min(1).optional(),widgets:S(b({id:l().min(1),placement:x([`connection`,`model`])})).optional()}),uR=b({mode:x([`none`,`lan`,`account`]),scopedToInstance:v()}),dR=b({kind:l().min(1),field:l().min(1),to:b({cap:l().min(1),kind:l().min(1).optional()})}),fR=b({role:cR,discovery:uR.optional(),instanceMode:sR,kind:l(),canTest:v(),kinds:S(lR).min(1),allowRestoreId:v().optional(),mintsId:v().optional(),links:S(dR).optional(),userScoped:v().optional()}),pR=b({state:x([`ok`,`off`,`error`,`unknown`]),detail:l().optional(),label:l().optional()}),mR=x([`scan`,`children`,`none`]),hR=b({id:oR,name:l(),configured:v(),enabled:v().optional(),kind:l().min(1),formValues:m(l(),C()),status:pR.optional(),lastCheckedAt:n().optional(),addDevice:mR.optional()}),gR=b({id:oR,name:l().min(1).optional(),values:m(l(),C())}),_R={name:`integration-instances`,scope:`system`,mode:`collection`,methods:{describe:k(_(),fR,{auth:`admin`}),instanceFormSchema:k(b({id:oR.nullable(),kind:l().min(1).optional(),mode:x([`standalone`,`account`,`broker`]).optional(),candidateStableId:l().min(1).optional()}),DTe,{auth:`admin`}),listInstances:k(ce({}),S(hR).readonly(),{auth:`protected`,caller:`scoped`}),getInstance:k(b({id:oR}),hR.nullable(),{auth:`protected`,caller:`scoped`}),createInstance:k(b({id:oR.optional(),name:l().min(1),kind:l().min(1).optional(),values:m(l(),C()).optional(),originStableId:l().min(1).optional(),seed:b({info:m(l(),C())}).optional()}),b({id:l()}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),updateInstance:k(gR,b({ok:p(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),setInstanceEnabled:k(b({id:oR,enabled:v()}),b({ok:p(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),deleteInstance:k(b({id:oR}),b({ok:p(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),testInstance:A(b({id:oR.nullable(),values:m(l(),C()),kind:l().min(1).optional()}),nR,{kind:`mutation`,auth:`protected`,caller:`scoped`})},vocabulary:{notOperatorFacing:j.INTERNAL}},vR=b({codecs:S(l()),sampleRate:n().meta(M(`none`)),duplex:x([`half`,`full`]),maxBacklogMs:n().meta(M(`duration-ms`))}),yR=b({talking:v(),lastSessionAt:n().nullable(),ability:vR.nullable()}),OTe=x([`opus`,`s16le`,`g711ulaw`,`g711alaw`]),bR={name:`intercom`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Camera],methods:{startSession:k(b({deviceId:n()}),b({sessionId:l(),sdpOffer:l()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),handleAnswer:k(b({deviceId:n(),sessionId:l(),sdpAnswer:l()}),_(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),stopSession:k(b({deviceId:n(),sessionId:l()}),_(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),startTalkSession:k(b({deviceId:n()}),b({sessionId:l()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`two-way talk is a person speaking through the viewer, not an automation step`}),pushTalkAudio:k(b({deviceId:n(),audioBase64:l(),codec:OTe.optional(),sampleRate:n().int().positive().optional(),channels:n().int().positive().optional(),sequenceNumber:n().int()}),b({accepted:v()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),endTalkSession:k(b({deviceId:n()}),_(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`})},events:{onStatusChanged:{data:b({deviceId:n(),status:yR}),notOperatorFacing:"the `talking` state trigger phrases both edges of this change"}},status:{schema:yR,kind:`command-driven`},runtimeState:yR,durability:`session`,history:`none`,vocabulary:{noun:P(`Intercom`,`Citofono`),order:3150,state:[{kind:`boolean`,field:`talking`,label:P(`Talking`,`In conversazione`),whenTrue:P(`When someone starts talking through {device}`,`Quando qualcuno inizia a parlare tramite {device}`),whenFalse:P(`When the conversation on {device} ends`,`Quando la conversazione su {device} finisce`),icon:`mic`}]}},xR=x([`carrierHz`,`dutyCyclePercent`,`repeat`,`repeatDelayMs`]),SR=x([`ir`,`rf`]),CR=b({ok:p(!0),ignoredSettings:S(l())}),wR=b({media:S(SR),settable:S(xR),maxTimings:n().int().positive(),learn:v().default(!1),formats:S(VE).default([])}),TR=2e4,ER=6e4,DR=b({native:UE.nullable(),timings:ME,carrierHz:n().int().positive().nullable()}),OR=b({at:n(),ok:v(),error:l().nullable()}),kR=OR.extend({medium:SR}),AR=b({lastSend:kR.nullable(),lastLearn:OR.nullable(),lastFetchedAt:n()});function jR(e){return!(e.kind===`learn`&&e.error===`ir-transmitter.learn-unsupported`)}function kTe(e,t,n){let r=e??{lastSend:null,lastLearn:null,lastFetchedAt:n};return jR(t)?t.kind===`send`?{lastSend:{at:n,ok:t.ok,error:t.error,medium:t.medium},lastLearn:r.lastLearn,lastFetchedAt:n}:{lastSend:r.lastSend,lastLearn:{at:n,ok:t.ok,error:t.error},lastFetchedAt:n}:r}function ATe(e){return Xr(e)?.code??null}var MR={name:`ir-transmitter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Generic],methods:{send:k(b({deviceId:n().int().nonnegative(),timings:ME.optional(),native:UE.optional(),settings:NE.optional()}).refine(e=>e.timings===void 0!=(e.native===void 0),{message:`send takes exactly one of timings or native`}),CR,{kind:`mutation`,auth:`protected`,notOperatorFacing:`a raw pulse train is not something an operator composes in an automation; the remote that owns the command table sends it`}),learn:k(b({deviceId:n().int().nonnegative(),timeoutMs:n().int().positive().max(ER).default(TR)}),DR,{kind:`mutation`,auth:`protected`,notOperatorFacing:`an interactive capture the operator starts from the source dialog and answers by pressing a physical remote; no automation can supply the signal`}),getInfo:k(b({deviceId:n().int().nonnegative()}),wR,{kind:`query`,auth:`protected`})},runtimeState:AR,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:P(`IR / RF transmitter`,`Trasmettitore IR / RF`),order:1140}},NR=x([`key-missing`,`wrong-key`,`key-file-unreadable`,`store-unavailable`,`not-initialized`,`decrypt-failed`]),PR=i(`state`,[b({state:p(`ready`)}),b({state:p(`locked`),reason:NR})]),FR=i(`kind`,[b({kind:p(`value`),value:l(),version:n().int()}),b({kind:p(`missing`)}),b({kind:p(`unavailable`),reason:NR}),b({kind:p(`forbidden`)})]),IR=m(l(),FR),LR=b({ref:l(),owner:l(),scope:l(),fieldPath:l(),version:n().int(),createdAt:n(),updatedAt:n(),updatedBy:l(),lastReadAt:n().nullable()}),jTe=512,RR=S(l().min(1)).max(512),zR={name:`keychain`,scope:`system`,mode:`singleton`,internal:!0,methods:{put:k(b({ref:l().min(1),value:l().min(1)}),b({ref:l(),version:n().int()}),{kind:`mutation`,auth:`admin`}),resolve:k(b({refs:RR}),IR,{auth:`admin`}),delete:k(b({refs:RR}),b({deleted:n().int()}),{kind:`mutation`,auth:`admin`}),deleteDeviceScope:k(b({deviceId:n().int()}),b({refs:S(l()).readonly()}),{kind:`mutation`,auth:`admin`}),releaseRecordRefs:k(b({refs:RR,onBehalfOf:l().min(1)}),b({released:n().int()}),{kind:`mutation`,auth:`admin`}),listMeta:k(b({}),S(LR).readonly(),{auth:`admin`}),getState:k(b({}),PR,{auth:`admin`})},vocabulary:{notOperatorFacing:j.IDENTITY}},BR=x([`mounted-file`,`previous-mounted-file`,`platform`,`default-file`]),VR=b({kind:BR,path:l().optional(),sharesBackupWithDatabase:v()}),MTe=`trigger-file`,HR=b({id:l(),at:n(),actor:l(),lockedReason:l().nullable(),archived:n().int(),archivedCollection:l().nullable(),archivedKeysCollection:l().nullable(),clearedSettingsKeys:S(l()).readonly(),acknowledgedAt:n().nullable()}),UR=b({keychain:PR,keySource:VR.nullable(),configuredSource:VR,fingerprint:l().nullable(),activeKeyId:l().nullable(),rotationPending:v(),retiredWraps:n().int(),recoveryKeyDownloadedAt:n().nullable(),secretCount:n().int(),lastReset:HR.nullable()}),WR=x([`in-use`,`orphan`,`unknown`]),GR=LR.extend({usage:WR}),KR=x([`put`,`delete`,`reveal`,`rotate-master-key`,`purge-retired-keys`,`download-recovery-key`,`delete-orphans`,`reset`,`acknowledge-reset`,`initialize`]),qR=b({id:l(),at:n(),action:KR,actor:l(),ref:l().nullable(),detail:l().nullable()}),JR=`RESET KEYCHAIN`,YR=x([`jwt-signing-key`]),XR={name:`keychain-admin`,scope:`system`,mode:`singleton`,methods:{status:k(b({}),UR,{auth:`admin`}),listSecrets:k(b({}),S(GR).readonly(),{auth:`admin`}),listAudit:k(b({limit:n().int().min(1).max(500).optional()}),S(qR).readonly(),{auth:`admin`}),reveal:k(b({ref:l().min(1)}),b({value:l(),version:n().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),setSystemSecret:k(b({name:YR,value:l().min(16)}),b({ref:l(),version:n().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),importSecret:k(b({ref:l().min(1),value:l().min(1)}),b({ref:l(),version:n().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),deleteOrphans:k(b({refs:S(l().min(1)).max(1e3)}),b({deleted:S(l()).readonly(),kept:S(b({ref:l(),usage:WR})).readonly()}),{kind:`mutation`,auth:`admin`,caller:`required`}),rotateMasterKey:k(b({}),b({fingerprint:l(),keySource:VR}),{kind:`mutation`,auth:`admin`,caller:`required`}),purgeRetiredKeys:k(b({}),b({purged:n().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),downloadRecoveryKey:k(b({}),b({key:l(),fingerprint:l(),keySource:VR}),{kind:`mutation`,auth:`admin`,caller:`required`}),resetKeychain:k(b({confirm:p(JR)}),b({archivedCollection:l().nullable(),archived:n().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),resetReport:k(b({}),b({reset:HR.nullable(),pendingReentry:S(LR).readonly()}),{auth:`admin`}),acknowledgeReset:k(b({}),b({acknowledged:v()}),{kind:`mutation`,auth:`admin`,caller:`required`})},vocabulary:{notOperatorFacing:j.IDENTITY}},ZR=x([`idle`,`mowing`,`paused`,`docked`,`error`]),QR=x([`info`,`warning`,`error`]),$R=b({activity:ZR,batteryLevel:n().min(0).max(100).nullable().meta(M(`percentage`)),progress:n().min(0).max(100).nullable().meta(M(`percentage`)),currentCode:n().nullable().meta(M(`none`)),currentCodeLabel:l().nullable(),severity:QR,lastChangedAt:n()}),ez={name:`lawn-mower-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.LawnMower],methods:{startMowing:k(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.start`,label:P(`Start mowing`,`Avvia il taglio`),phrase:P(`Start {device} mowing`,`Fai partire il taglio di {device}`),icon:`play`}]}),pause:k(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.pause`,label:P(`Pause mower`,`Metti in pausa il tosaerba`),phrase:P(`Pause {device}`,`Metti in pausa {device}`),icon:`pause`}]}),dock:k(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.dock`,label:P(`Dock mower`,`Riporta alla base`),phrase:P(`Send {device} back to its dock`,`Rimanda {device} alla base`),icon:`house`}]})},status:{schema:$R,kind:`push`},runtimeState:$R,durability:`session`,history:{fields:{batteryLevel:{kind:`gauge`,unit:`%`,deadband:2}}},vocabulary:{noun:P(`Robot mower`,`Robot tosaerba`),order:2010,state:[{kind:`enum`,field:`activity`,label:P(`Activity`,`Attività`),values:[{value:`idle`,label:P(`Idle`,`Inattivo`)},{value:`mowing`,label:P(`Mowing`,`In taglio`),phrase:P(`When {device} starts mowing`,`Quando {device} inizia a tagliare`)},{value:`paused`,label:P(`Paused`,`In pausa`)},{value:`docked`,label:P(`Docked`,`Alla base`),phrase:P(`When {device} docks`,`Quando {device} arriva alla base`)},{value:`error`,label:P(`Error`,`Errore`),phrase:P(`When {device} reports an error`,`Quando {device} segnala un errore`)}],icon:`bot`},{kind:`numeric`,field:`batteryLevel`,quantity:P(`the battery level`,`il livello della batteria`),label:P(`Battery`,`Batteria`),unit:`%`,icon:`battery`}]}},tz=6e5,NTe=60*6e4,nz=b({inputTokens:n(),outputTokens:n()}),rz=x([`timeout`,`rate-limited`,`auth`,`refusal`,`bad-request`,`unavailable`,`no-profile`,`budget-exceeded`,`adapter-error`]),iz=b({ok:p(!0),text:l(),model:l(),usage:nz,truncated:v(),latencyMs:n()}),az=x([`guardrail`,`model`]),oz=b({ok:p(!1),code:rz,message:l(),retryAfterMs:n().optional(),refusalSource:az.optional()}),sz=i(`ok`,[iz,oz]),cz=b({bytes:y(Uint8Array),mimeType:l()}),lz=b({enabled:v().default(!1),maxAttempts:n().int().min(1).max(5).default(1)}),PTe={totalMs:6e4,connectMs:1e4,firstTokenMs:12e4,idleMs:6e4},uz=b({addonId:l().optional(),profileId:l().optional(),consumer:l(),system:l().optional(),prompt:l(),jsonSchema:m(l(),C()).optional(),maxTokens:n().int().positive().optional(),temperature:n().optional(),topP:n().min(0).max(1).optional(),topK:n().int().positive().optional(),reasoningEffort:x([`off`,`low`,`medium`,`high`]).optional(),timeoutMs:n().int().positive().optional(),retry:lz.optional(),requestId:l().optional()}),dz=b({url:l(),filename:l(),sizeBytes:n(),sha256:l().optional()}),fz=i(`kind`,[b({kind:p(`catalog`),catalogId:l()}),b({kind:p(`url`),url:l(),sha256:l().optional(),label:l().optional(),sizeBytes:n().optional(),extraFiles:S(dz).optional()}),b({kind:p(`path`),path:l()})]),pz=b({nodeId:l(),engine:x([`llama-cpp`]),model:fz,contextSize:n().int().default(4096),gpuLayers:n().int().default(0),threads:n().int().optional(),parallel:n().int().default(1),batchSize:n().int().positive().optional(),ubatchSize:n().int().positive().optional(),flashAttention:v().default(!1),mlock:v().default(!1),noMmap:v().default(!1),cacheTypeK:x([`f32`,`f16`,`q8_0`,`q5_1`,`q5_0`,`q4_1`,`q4_0`]).optional(),cacheTypeV:x([`f32`,`f16`,`q8_0`,`q5_1`,`q5_0`,`q4_1`,`q4_0`]).optional(),extraArgs:S(l()).default([]),autoStart:v().default(!1),idleStopMinutes:n().int().default(30)}),mz=b({phase:x([`downloading`,`verifying`]),file:l(),fileIndex:n().int(),fileCount:n().int(),downloadedBytes:n(),totalBytes:n().optional()}),hz=b({nodeId:l(),state:x([`stopped`,`downloading`,`starting`,`ready`,`crashed`,`failed`]),pid:n().optional(),port:n().optional(),modelPath:l().optional(),modelId:l().optional(),downloadProgress:n().min(0).max(1).optional(),download:mz.optional(),lastError:l().optional(),crashesInWindow:n(),memoryBytes:n().optional(),vramBytes:n().optional()}),gz=b({file:l(),sizeBytes:n(),catalogId:l().optional(),installedAt:n().optional(),path:l().optional()}),_z=b({nodeId:l(),modelsBytes:n(),freeBytes:n().optional()}),vz=uz.extend({images:S(cz).optional(),runtime:pz,timeoutMs:n().int().positive().optional()}),yz=x([`deviceNotEligible`,`appleIntelligenceNotEnabled`,`modelNotReady`,`osTooOld`,`helperMissing`,`helperCrashed`]),bz=i(`state`,[b({state:p(`available`),osVersion:l(),contextSize:n().int().positive(),languages:S(l()),imageInput:v()}),b({state:p(`unavailable`),reason:yz,osVersion:l().nullable(),detail:l()}),b({state:p(`unsupported-platform`),platform:l()}),b({state:p(`unknown`),error:l()})]),xz=uz.extend({images:S(cz).optional(),timeoutMs:n().int().positive().optional()}),Sz=b({requestId:l()}),Cz={name:`llm-runtime`,scope:`system`,mode:`singleton`,internal:!0,methods:{complete:k(vz,sz,{kind:`mutation`,auth:`admin`,timeoutMs:tz}),ensureStarted:k(b({runtime:pz}),hz,{kind:`mutation`,auth:`admin`,timeoutMs:tz}),stop:k(b({}),_(),{kind:`mutation`,auth:`admin`}),status:k(b({}),hz,{auth:`admin`}),installModel:k(b({model:fz}),_(),{kind:`mutation`,auth:`admin`,timeoutMs:NTe}),deleteModel:k(b({file:l()}),_(),{kind:`mutation`,auth:`admin`}),listLocalModels:k(b({}),S(gz),{auth:`admin`}),getDiskUsage:k(b({}),_z,{auth:`admin`}),cancel:k(Sz,_(),{kind:`mutation`,auth:`admin`}),appleAvailability:k(b({}),bz,{auth:`admin`}),completeApple:k(xz,sz,{kind:`mutation`,auth:`admin`,timeoutMs:tz})},vocabulary:{notOperatorFacing:j.ML}},wz=/^[a-z0-9][a-z0-9-]{0,63}$/,Tz=l().regex(wz,`a kind id is lower-case letters, digits and dashes`),Ez=b({vision:v(),tools:v(),streaming:v(),reasoning:v().nullable().optional()}),Dz=b({id:l(),label:l().optional(),contextLength:n().int().positive().optional(),features:Ez.partial().optional()}),Oz=m(l(),C()),FTe=b({id:l(),name:l(),kind:Tz,addonId:l(),enabled:v(),model:l(),supportsVision:v(),temperature:n().min(0).max(2).optional(),topP:n().min(0).max(1).optional(),topK:n().int().positive().optional(),maxTokens:n().int().positive().optional(),reasoningEffort:x([`off`,`low`,`medium`,`high`]).optional(),contextLength:n().int().positive().optional(),systemPrompt:l().optional(),timeoutMs:n().int().positive().default(6e4),connectTimeoutMs:n().int().positive().default(1e4),firstTokenTimeoutMs:n().int().positive().default(12e4),idleTimeoutMs:n().int().positive().default(6e4),retry:lz.default({enabled:!1,maxAttempts:1}),toolsEnabled:v().default(!1),providerConfig:Oz.default({})}),kz=x([`temperature`,`topP`,`topK`,`maxTokens`,`reasoningEffort`,`contextLength`,`systemPrompt`,`timeoutMs`,`connectTimeoutMs`,`firstTokenTimeoutMs`,`idleTimeoutMs`,`retry`,`toolsEnabled`]),Az=b({id:l(),placement:x([`connection`,`model`]),requires:S(l()).optional()}),jz=C(),ITe=b({kind:Tz,label:l(),icon:l(),addonId:l(),connectionSchema:jz,advancedSchema:jz.optional(),features:Ez,visionEditable:v(),modelCatalog:x([`fetch`,`static`,`none`]),staticModels:S(Dz).optional(),profileFields:S(kz),providerWidgets:S(Az).optional()}),Mz=b({addonId:l(),kind:Tz,profileId:l().optional(),connection:Oz.optional()}),Nz=x([`auth`,`network`,`unsupported`,`invalid`]),Pz=i(`ok`,[b({ok:p(!0),models:S(Dz)}),b({ok:p(!1),code:Nz,message:l()})]),Fz=h([b({consumer:l()}),b({purpose:x([`text`,`vision`])})]),Iz=b({selector:Fz,profileId:l()}),Lz=b({day:l(),consumer:l(),profileId:l(),calls:n(),okCalls:n(),errorCalls:n(),inputTokens:n(),outputTokens:n(),avgLatencyMs:n()}),Rz=b({id:l(),label:l(),family:l(),purpose:x([`text`,`vision`]),url:l(),sha256:l(),sizeBytes:n(),quantization:l(),minRamBytes:n(),contextSizeDefault:n().int(),mmprojUrl:l().optional()}),zz=i(`ok`,[b({ok:p(!0),model:fz,label:l(),repo:l(),quantization:l(),purpose:x([`text`,`vision`]),totalBytes:n(),extraFilenames:S(l())}),b({ok:p(!1),code:l(),message:l(),candidates:S(l()).optional(),requiredBytes:n().optional()})]),Bz=b({nodeId:l(),reachable:v(),status:hz.optional(),disk:_z.optional(),error:l().optional(),apple:bz.optional()}),LTe=uz.extend({images:S(cz).min(1)}),Vz=b({addonId:l(),profileId:l()}),Hz={name:`llm`,scope:`system`,mode:`collection`,internal:!1,providerKind:`ai`,nodeIdMode:`data`,methods:{generate:k(uz,sz,{kind:`mutation`,timeoutMs:tz}),generateVision:k(LTe,sz,{kind:`mutation`,timeoutMs:tz}),cancel:k(b({addonId:l().optional(),requestId:l()}),_(),{kind:`mutation`}),listModels:k(Mz,Pz,{kind:`mutation`,auth:`admin`}),getDefaults:k(b({}),S(Iz)),setDefault:k(b({selector:Fz,profileId:l().nullable()}),_(),{kind:`mutation`,auth:`admin`}),getUsage:k(b({since:n().optional(),until:n().optional(),consumer:l().optional(),profileId:l().optional()}),S(Lz)),listModelCatalog:k(b({}),S(Rz)),listRuntimeNodes:k(b({}),S(Bz)),listNodeModels:k(b({nodeId:l()}),S(gz)),resolveModelRef:k(b({ref:l(),maxBytes:n().positive().optional()}),zz,{kind:`mutation`,auth:`admin`}),installModel:k(b({nodeId:l(),model:fz}),_(),{kind:`mutation`,auth:`admin`}),deleteModel:k(b({nodeId:l(),file:l()}),_(),{kind:`mutation`,auth:`admin`}),getRuntimeStatus:k(Vz,hz),startRuntime:k(Vz,hz,{kind:`mutation`,auth:`admin`}),stopRuntime:k(Vz,_(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:j.ML}},Uz=[`decode`,`transcode`,`recording`,`streaming`,`detection`],Wz=[`measured`,`accounted`,`unattributable`],Gz=b({role:x(Uz),deviceId:n().int().positive().nullable(),attribution:x(Wz),unit:l(),pid:n().int().positive().optional(),startedAtMs:n().optional(),cpuSeconds:n().optional(),rssBytes:n().optional()}),Kz={name:`load-contribution`,scope:`system`,mode:`collection`,internal:!0,methods:{list:k(_(),S(Gz).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:j.INTERNAL}},qz=`https://camstack.zentik.app`,Jz=`/viewer/camstack`;function Yz(e){if(e==null||e===``)return!1;try{return new URL(e).origin===qz}catch{return!1}}function RTe(e){let t=e.baseUrl??e.resolved;return Yz(t)?{form:`app`,hubBaseUrl:e.appLinkHub??null}:{form:`hub`,hubBaseUrl:t}}function Xz(e){let t;try{t=new URL(e)}catch{return null}return t.protocol!==`https:`&&t.protocol!==`http:`||t.username!==``||t.password!==``||t.hostname===``?null:t.origin}function zTe(e){let t=e=>e.kind!==`public`||!e.baseUrl.startsWith(`https://`)?null:e.interfaceKind===`public`?0:e.interfaceKind===`vpn`?1:null;return e.flatMap(e=>{let n=t(e),r=Xz(e.baseUrl);return n===null||r===null?[]:[{r:n,p:e.priority,origin:r}]}).toSorted((e,t)=>e.r-t.r||e.p-t.p)[0]?.origin??null}function BTe(e){switch(e.kind){case`camera`:{if(!Number.isInteger(e.deviceId)||e.deviceId<=0)return null;let t=e.atMs;return{path:`/camera/${String(e.deviceId)}`,query:t!==void 0&&Number.isFinite(t)?[[`at`,String(Math.trunc(t))]]:[]}}case`events`:return{path:`/events`,query:[]};case`notifications`:return{path:`/notifications`,query:[]}}}function Zz(e){return e.length===0?``:`?${e.map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join(`&`)}`}function VTe(e){let t=BTe(e.destination);if(t===null)return null;let n=e.base.hubBaseUrl,r=n===null?``:n.replace(/\/+$/,``);if(e.base.form===`app`){let e=r===``?null:Xz(r),n=e===null?t.query:[...t.query,[`hub`,e]];return`${qz}${t.path}${Zz(n)}`}return r===``||Yz(r)?null:`${r}${Jz}${t.path}${Zz(t.query)}`}var Qz=[`appConnections`,`notificationTaps`,`internal`,`publicEndpoint`],HTe=[`notificationTaps`,`internal`,`publicEndpoint`];function UTe(e){return e!==`appConnections`}var WTe={appConnections:[],notificationTaps:null,internal:null,publicEndpoint:null},GTe=/^\d{1,3}(?:\.\d{1,3}){3}$/;function $z(e){try{let t=new URL(e).hostname;return t.length>0?t:null}catch{return null}}function KTe(e){return e.replace(/\/+$/,``)}function eB(e){return e.kind===`public`&&e.interfaceKind===`vpn`}function qTe(e){return e.kind===`public`&&e.interfaceKind===`public`}function tB(e){return(e.kind===`lan-ipv4`||e.kind===`lan-ipv6`)&&e.plausible}function nB(e){if(e.kind!==`lan-ipv4`||!e.plausible)return!1;let t=$z(e.baseUrl);return t!==null&&GTe.test(t)}function rB(e){return e.stable===!1}function JTe(e,t){return t.kind===`loopback`||t.kind===`app-link`||t.kind===`custom`||$z(t.baseUrl)===null||rB(t)?null:e===`internal`?nB(t)?0:tB(t)?1:eB(t)?2:null:qTe(t)?0:eB(t)?1:nB(t)?2:tB(t)?3:null}var YTe=new Set([`localhost`,`0.0.0.0`,`::1`,`[::1]`,`::`,`[::]`]);function XTe(e){let t=e.toLowerCase();return YTe.has(t)||t.endsWith(`.localhost`)?!0:/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(t)}function iB(e){let t=e.trim();if(t===``)return{ok:!1,reason:`Enter an address, e.g. https://192.0.2.20:4443.`};let n;try{n=new URL(t)}catch{return{ok:!1,reason:`Not a URL — include http:// or https://.`}}return n.protocol!==`https:`&&n.protocol!==`http:`?{ok:!1,reason:`Use an http:// or https:// address.`}:n.username!==``||n.password!==``?{ok:!1,reason:`The address must not carry a user name or password.`}:n.hostname===``?{ok:!1,reason:`The address has no host.`}:XTe(n.hostname)?{ok:!1,reason:`A loopback address names whoever dials it, never this hub — use an address other machines reach.`}:n.pathname!==`/`||n.search!==``||n.hash!==``?{ok:!1,reason:`Enter only the address (scheme, host and port), without a path.`}:{ok:!0,baseUrl:n.origin}}var aB=`The public endpoint needs an https:// address: passkeys and most identity providers refuse a plain-http origin. Accept http only when sign-in and notification links never leave your own network.`;function oB(e,t,n={}){if(Yz(t))return e===`notificationTaps`?{ok:!0,baseUrl:qz}:{ok:!1,reason:`The CamStack app link is not a hub address — only notification taps can use it.`};let r=iB(t);return r.ok&&e===`publicEndpoint`&&r.baseUrl.startsWith(`http:`)&&n.acceptInsecureHttp!==!0?{ok:!1,reason:aB}:r}function sB(e,t){if(t===null||t===``)return null;let n=oB(e,t,{acceptInsecureHttp:!0});return n.ok?n.baseUrl:null}function ZTe(e,t){let n=e.flatMap(e=>{let n=JTe(t,e);return n===null?[]:[{rank:n,priority:e.priority,endpoint:e}]}).toSorted((e,t)=>e.rank-t.rank||e.priority-t.priority)[0];return n===void 0?null:KTe(n.endpoint.baseUrl)}function cB(e,t,n){let r=sB(t,n);if(r!==null)return{flagged:r,resolved:r,source:`flagged`};let i=ZTe(e,t);return{flagged:null,resolved:i,source:i===null?`none`:`auto`}}function lB(e,t){return cB(e,`internal`,t.internal)}function uB(e,t){return cB(e,`publicEndpoint`,t.publicEndpoint)}function dB(e){let t=sB(`notificationTaps`,e.notificationTaps);return t!==null&&!Yz(t)?{flagged:t,resolved:t,source:`flagged`}:{flagged:null,resolved:qz,source:`auto`}}function fB(e){return rB(e)?!1:e.kind===`lan-ipv4`?!0:e.kind===`public`&&e.interfaceKind===`public`}function pB(e,t){let n=e.filter(fB);if(t.appConnections.length===0)return n;let r=new Set(t.appConnections),i=e.filter(e=>r.has(e.baseUrl));return i.length>0?i:n}function mB(e,t){let n=new Set(t.appConnections),r=pB(e,t),i=r.some(e=>n.has(e.baseUrl));return{flagged:t.appConnections,resolved:r.map(e=>e.baseUrl),source:r.length===0?`none`:i?`flagged`:`auto`}}function QTe(e,t,n){return{appConnections:mB(e,n),notificationTaps:dB(n),internal:lB(t,n),publicEndpoint:uB(t,n)}}function $Te(e){return e===null?null:$z(e)}var eEe=`camstack`,tEe=`_camstack._tcp.local`,nEe={nodeId:`nodeId`,version:`version`,role:`role`,url:`url`,hubId:`hubId`},rEe=`hub`,hB=/^hub-[0-9a-f]{16}$/;function iEe(e){return typeof e==`string`&&hB.test(e)}var aEe=`camstack-agent`,oEe=`_camstack-agent._tcp.local`,sEe={nodeId:`nodeId`,version:`version`,name:`name`,state:`state`,keyFingerprint:`fp`},cEe=x([`lan`,`wifi`,`docker`,`vpn`,`loopback`,`other`]),gB=b({name:l(),family:x([`IPv4`,`IPv6`]),address:l(),cidr:l(),netmask:l(),internal:v(),mac:l(),kind:cEe,preferred:v(),plausible:v(),plausibleReason:l()}),lEe=b({interfaces:S(gB).readonly(),probedAt:n()}),uEe=gB.nullable(),_B=b({label:l(),baseUrl:l(),kind:x([`lan-ipv4`,`lan-ipv6`,`public`,`loopback`,`app-link`,`custom`]),interfaceKind:x([`lan`,`wifi`,`docker`,`vpn`,`other`,`loopback`,`public`]),plausible:v(),plausibleReason:l(),priority:n(),stable:v().optional()}),dEe=x([`server-config`,`server-env`,`caller-hint`,`default`]),fEe=b({port:n().int().min(1).max(65535),source:dEe}),pEe=b({endpoints:S(_B).readonly(),localPort:fEe}),vB=b({baseUrl:l().nullable(),resolved:l().nullable(),appLinkHub:l().nullable()}),yB=b({baseUrls:S(l()).readonly(),resolved:S(l()).readonly()}),bB=b({override:l().nullable(),resolved:l().nullable(),source:x([`override`,`auto`,`none`])}),mEe=b({cluster:bB,browser:bB}),xB=x(Qz),SB=x([`flagged`,`auto`,`none`]),CB=b({flagged:l().nullable(),resolved:l().nullable(),source:SB}),hEe=b({flagged:S(l()).readonly(),resolved:S(l()).readonly(),source:SB}),wB=b({rows:S(_B.extend({detected:v(),custom:v(),flags:S(xB).readonly(),inUse:S(xB).readonly(),eligible:S(xB).readonly()})).readonly(),roles:b({appConnections:hEe,notificationTaps:CB,internal:CB,publicEndpoint:CB}),appLinkHub:l().nullable(),listenerOrigins:S(l()).readonly().optional()}),TB=b({addresses:S(l()).readonly()}),EB=b({mode:x([`generated`,`uploaded`,`disabled`]),leafFingerprintSha256:l().nullable(),caFingerprintSha256:l().nullable(),validTo:l().nullable(),sans:S(l()),caCertPem:l().nullable(),reissueError:l().nullable(),restartRequired:v(),caMissing:v(),localCaConstrained:v().nullable(),caReplacedAt:l().nullable(),storedUpload:b({leafFingerprintSha256:l(),validTo:l(),hasCa:v()}).nullable()}),gEe=b({providerId:l().min(1),modes:S(Zj)}),_Ee=b({providerId:l().optional(),mode:l().optional(),message:l()}),vEe=b({hostsProbed:n().int(),hits:n().int(),timeouts:n().int(),byMode:m(l(),b({probed:n().int(),hits:n().int(),timeouts:n().int()}))}),yEe=b({hits:S(b({providerId:l(),hit:Qj})),subnetsScanned:S(l()),errors:S(_Ee),stats:vEe}),DB={name:`local-network`,scope:`system`,mode:`singleton`,methods:{list:k(_(),lEe),getPreferred:k(_(),uEe),getConnectionEndpoints:k(b({port:n().int().min(1).max(65535).optional(),includeLoopback:v().optional(),ipv4Only:v().optional(),scheme:x([`http`,`https`]).optional(),includeAppLink:v().optional()}),pEe),getNotificationEndpoint:k(_(),vB),setNotificationEndpoint:k(b({baseUrl:l().nullable()}),vB,{kind:`mutation`}),getViewerEndpoints:k(_(),yB),setViewerEndpoints:k(b({baseUrls:S(l()).readonly()}),yB,{kind:`mutation`}),getAddresses:k(b({scheme:x([`http`,`https`]).optional()}).optional(),wB),addCustomAddress:k(b({baseUrl:l(),label:l().max(80)}),wB,{kind:`mutation`,auth:`admin`}),removeCustomAddress:k(b({baseUrl:l()}),wB,{kind:`mutation`,auth:`admin`}),setAddressRole:k(b({role:xB,baseUrl:l().nullable(),enabled:v(),acceptInsecureHttp:v().optional()}),wB,{kind:`mutation`,auth:`admin`}),getHubAddresses:k(_(),mEe),getAllowedAddresses:k(_(),TB),setAllowedAddresses:k(TB,b({success:p(!0)}),{kind:`mutation`}),resetAllowlistToBestMatch:k(_(),TB,{kind:`mutation`}),getTlsStatus:k(_(),EB),regenerateCertificate:k(b({reason:l().optional()}),EB,{kind:`mutation`,auth:`admin`}),uploadCertificate:k(b({certPem:l().min(1),keyPem:l().min(1),caPem:l().optional()}),EB,{kind:`mutation`,auth:`admin`}),downloadCa:k(_(),b({pem:l()})),useStoredUploadedCertificate:k(_(),EB,{kind:`mutation`,auth:`admin`}),scanNetwork:k(b({requests:S(gEe),subnets:S(l()).optional()}),yEe,{kind:`mutation`,auth:`admin`,timeoutMs:9e4}),getScanSubnets:k(_(),b({subnets:S(l())}),{auth:`admin`}),setScanSubnets:k(b({subnets:S(l())}),b({subnets:S(l())}),{kind:`mutation`,auth:`admin`}),revertToGeneratedCertificate:k(_(),EB,{kind:`mutation`,auth:`admin`})},mount:{kind:`hub-only`},vocabulary:{notOperatorFacing:j.NETWORK}},OB=x([`locked`,`unlocked`,`locking`,`unlocking`,`jammed`,`door-open`]),kB=b({state:OB,codeRequired:v().nullable().optional(),lastChangedAt:n()}),bEe={version:1,overridable:[{path:`state`,by:`door-contact`}],targets:[{id:`door-contact`,cardinality:`scalar`,vocabulary:{cap:`lock-control`,stateField:`state`},deviceTypes:[T.Lock],apply:`replace`,path:`state`,override:{whenSourceTrue:`door-open`,unlessNative:[`jammed`]},sources:[{kind:`binary`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}]},AB={name:`lock-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Lock],methods:{lock:k(b({deviceId:n().int().nonnegative(),code:l().min(1).optional()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.lock`,label:P(`Lock`,`Chiudi a chiave`),phrase:P(`Lock {device}`,`Chiudi a chiave {device}`),icon:`lock`,effect:{field:`state`,value:`locked`},hold:{effects:[{field:`state`,value:`locking`,when:{field:`state`,notIn:[`locked`]}}]},openArgs:[{key:`code`,label:P(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]}),unlock:k(b({deviceId:n().int().nonnegative(),code:l().min(1).optional(),confirm:v().optional()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.unlock`,label:P(`Unlock`,`Apri la serratura`),phrase:P(`Unlock {device}`,`Sblocca {device}`),icon:`lock-open`,effect:{field:`state`,value:`unlocked`},hold:{effects:[{field:`state`,value:`unlocking`,when:{field:`state`,notIn:[`unlocked`]}}]},openArgs:[{key:`code`,label:P(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]}),open:A(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.open`,label:P(`Open latch`,`Apri lo scrocco`),phrase:P(`Release the latch of {device}`,`Fai scattare lo scrocco di {device}`),icon:`door-open`}]})},status:{schema:kB,kind:`push`},runtimeState:kB,customize:bEe,durability:`restored`,history:{fields:{state:{kind:`enum`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:P(`Lock`,`Serratura`),order:1060,state:[{kind:`enum`,field:`state`,label:P(`Lock state`,`Stato della serratura`),values:[{value:`locked`,label:P(`Locked`,`Chiusa a chiave`),phrase:P(`When {device} locks`,`Quando {device} si chiude a chiave`)},{value:`unlocked`,label:P(`Unlocked`,`Sbloccata`),phrase:P(`When {device} unlocks`,`Quando {device} si sblocca`)},{value:`locking`,label:P(`Locking`,`In chiusura`),phrase:P(`When {device} starts locking`,`Quando {device} inizia a chiudersi`)},{value:`unlocking`,label:P(`Unlocking`,`In apertura`),phrase:P(`When {device} starts unlocking`,`Quando {device} inizia a sbloccarsi`)},{value:`jammed`,label:P(`Jammed`,`Inceppata`),phrase:P(`When {device} jams`,`Quando {device} si inceppa`)},{value:`door-open`,label:P(`Door open`,`Porta aperta`),phrase:P(`When the door of {device} opens`,`Quando la porta di {device} si apre`)}],icon:`lock`}]}},jB=b({armed:n().int().min(0),unknown:S(l()).readonly()}),MB={name:`log-channels`,scope:`system`,mode:`collection`,internal:!0,methods:{list:k(_(),S(Oh).readonly()),apply:k(b({windows:S(Lle).readonly()}),jB,{kind:`mutation`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:j.INTERNAL}},NB=x([`debug`,`info`,`warn`,`error`]),PB=b({timestamp:g(),level:NB,scope:S(l()),message:l(),meta:m(l(),C()).optional(),tags:m(l(),l()).optional()}),FB=b({instanceId:l().min(1).max(200).optional(),requestId:l().min(1).max(64).optional(),deviceId:n().int().optional(),fromAddonId:l().min(1).max(200).optional(),fromNodeId:l().min(1).max(200).optional(),tags:m(l(),h([l(),n()])).optional(),level:NB.optional(),text:l().min(1).max(200).optional(),since:n().optional(),until:n().optional(),before:l().min(1).max(1024).optional(),after:l().min(1).max(1024).optional(),limit:n().int().min(1).max(1e3).optional(),budgetMs:n().int().min(50).max(1e4).optional()}),IB=b({id:l().optional(),timestamp:n(),level:NB,scope:l().optional(),message:l(),tags:m(l(),h([l(),n()])).optional(),meta:m(l(),C()).optional()}),LB=b({entries:S(IB),nextBefore:l().nullable(),nextAfter:l().nullable(),scannedBytes:n().int().nonnegative(),done:v(),cancelled:v().optional()}),xEe=b({instanceId:l().min(1).max(200).optional()}),RB=b({readable:v(),reason:l().nullable(),filters:b({deviceId:v(),addonId:v(),nodeId:v(),tags:v(),level:v(),text:v(),timeRange:v()}),retentionDays:n().nullable()}),zB={name:`log-destination`,scope:`system`,mode:`collection`,internal:!0,methods:{write:k(PB,_(),{kind:`mutation`}),describeRead:A(xEe,RB,{auth:`admin`}),read:A(FB,LB,{auth:`admin`}),cancelRead:A(b({requestId:l().min(1).max(64)}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:j.INTERNAL}},BB=x([`primary`,`second-factor`]),VB=b({kind:p(`redirect`),id:l(),label:l(),icon:l().optional(),startUrl:l(),stage:BB,linkable:v().optional(),app:hg.nullable().optional()}),HB=b({kind:p(`widget`),id:l(),addonId:l(),bundle:l(),remote:fS,stage:BB,app:hg.nullable().optional()}),UB=b({kind:p(`passkey`),id:l(),label:l(),stage:BB,rpId:l(),origin:l().nullable(),app:hg.nullable().optional()}),WB=i(`kind`,[VB,HB,UB]),GB={name:`login-method`,scope:`system`,mode:`collection`,internal:!0,methods:{getLoginMethods:k(_(),S(WB).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:j.IDENTITY}},KB=b({sleeping:v().meta({label:`Sleeping`}),lastContactAt:n().optional(),lastUpdated:n().meta(M(`none`))}),qB={name:`low-power-sleep`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Camera],methods:{wakeUp:k(b({deviceId:n(),timeoutMs:n().int().min(500).max(3e4).default(8e3)}),b({awoke:v(),durationMs:n()}),{kind:`mutation`,notOperatorFacing:`a stream consumer wakes a sleeping camera to watch it; an automation that wants footage asks for the footage`})},status:{schema:KB,kind:`push`,empty:{sleeping:!1,lastUpdated:0}},runtimeState:KB,durability:`restored`,history:`none`,volatileStateFields:[`lastUpdated`],vocabulary:{noun:P(`Low-power sleep`,`Sospensione a basso consumo`),order:5245}},SEe=b({id:l(),label:l(),scope:x([`mesh`,`public`]),url:l(),hostname:l(),port:n(),protocol:x([`http`,`https`])}),JB=b({id:l(),hostname:l(),magicDns:l(),addresses:S(l()).readonly(),os:l().optional(),online:v(),lastSeenMs:n(),isSelf:v(),connection:x([`direct`,`relay`,`idle`]),relay:l().nullable(),lastHandshakeMs:n(),rxBytes:n(),txBytes:n(),tags:S(l()).readonly(),exitNodeOption:v(),advertisedRoutes:S(l()).readonly(),userLogin:l().nullable(),keyExpiry:n().nullable()}),YB=b({joined:v(),meshIp:l(),magicDnsHostname:l(),peerCount:n(),endpoints:S(SEe).readonly(),error:l().optional(),tenantName:l(),magicDnsSuffix:l(),userLogin:l().nullable(),controlPlaneUrl:l(),keyExpiry:n().nullable(),daemonSocket:l().optional(),daemonCliPath:l().optional()}),XB={name:`mesh-network`,scope:`system`,mode:`collection`,providerKind:`mesh`,methods:{getStatus:k(_(),YB),join:k(b({authKey:l().min(8),hostname:l().optional()}),b({joined:p(!0)}),{kind:`mutation`}),startLogin:k(b({hostname:l().optional()}),b({loginUrl:l()}),{kind:`mutation`}),leave:k(_(),b({left:p(!0)}),{kind:`mutation`}),logout:k(_(),b({loggedOut:p(!0)}),{kind:`mutation`}),listPeers:k(_(),b({peers:S(JB).readonly()}))},vocabulary:{notOperatorFacing:j.NETWORK}},ZB=b({value:n().nullable().meta(M(`device`,{label:`Total`})),lastFetchedAt:n()}),QB={name:`meter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Sensor],methods:{},status:{schema:ZB,kind:`push`},runtimeState:ZB,durability:`restored`,history:{fields:{value:{kind:`counter`,deadband:.001,minIntervalMs:6e4}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:P(`Meter`,`Contatore`),order:5140,state:[{kind:`numeric`,field:`value`,quantity:P(`the total`,`il totale`),label:P(`Total`,`Totale`),icon:`gauge`}]}},CEe=b({total:n(),user:n(),system:n(),irq:n(),nice:n(),loadAvg:u([n(),n(),n()]),cores:n()}),wEe=b({percent:n().nullable(),totalBytes:n(),usedBytes:n().nullable(),availableBytes:n().nullable(),swapUsedBytes:n(),swapTotalBytes:n()}),TEe=b({readBytes:n(),writeBytes:n(),readOps:n(),writeOps:n(),timestampMs:n()}),EEe=b({rxBytes:n(),txBytes:n(),rxPackets:n(),txPackets:n(),rxErrors:n(),txErrors:n(),timestampMs:n()}),$B=b({utilization:n(),model:l(),memoryUsedBytes:n(),memoryTotalBytes:n(),temperature:n().nullable()}),DEe=b({openFds:n(),threadCount:n(),activeHandles:n(),activeRequests:n()}),eV=b({avg10:n(),avg60:n(),avg300:n()}),tV=b({some:eV,full:eV.nullable()}),nV=b({cpu:CEe,memory:wEe,gpu:$B.nullable(),network:EEe,disk:TEe,pressure:b({cpu:tV.nullable(),memory:tV.nullable(),io:tV.nullable()}),process:DEe,cpuTemperature:n().nullable(),timestampMs:n()}),OEe=b({path:l(),totalBytes:n(),usedBytes:n(),availableBytes:n(),percent:n()}),rV=b({pid:n(),cpu:n(),memory:n(),privateBytes:n().optional(),sharedBytes:n().optional()}),kEe=b({addonId:l(),nodeId:l(),role:x([`hub`,`worker`]),pid:n(),state:x([`starting`,`running`,`stopping`,`stopped`,`crashed`]),uptimeSec:n()}),AEe=b({pid:n(),ppid:n(),pgid:n(),classification:x([`root`,`managed`,`system`]),addonId:l().nullable(),nodeId:l().nullable(),command:l(),cpuPercent:n(),memoryRssBytes:n(),cpuMainPercent:n().nullable(),cpuGcPercent:n().nullable(),threadCount:n().nullable(),uptimeSec:n()}),jEe=b({source:x([`cgroup-v2`,`cgroup-v1`]),currentBytes:n(),limitBytes:n().nullable(),anonBytes:n().nullable(),fileBytes:n().nullable(),shmemBytes:n().nullable(),slabBytes:n().nullable(),gpuShmemBytes:n().nullable()}).extend({atMs:n()}),MEe=b({atMs:n(),samples:n().int(),cpuMainPercent:n().nullable(),cpuMainPercentMin:n().nullable(),cpuGcPercent:n().nullable(),cpuGcPercentMin:n().nullable(),cpuLifetimePercent:n(),cpuLifetimePercentMin:n(),memoryRssBytes:n(),memoryRssBytesMin:n(),processCount:n().int(),processCountMin:n().int()}),NEe=b({key:l(),kind:x([`addon`,`root`,`unattributed`]),points:S(MEe).readonly()}),PEe=b({nodeId:l(),series:S(NEe).readonly(),containerMemory:S(jEe).readonly(),bucketMs:n(),retainedSamples:n(),oldestAtMs:n().nullable(),cadenceMs:n(),durable:v()}),FEe=b({forNodeId:l(),sinceMs:n().optional(),maxPoints:n().int().positive().optional()}),iV=b({cpuPercent:n(),memoryPercent:n().nullable(),memoryUsedMB:n().nullable(),memoryTotalMB:n(),diskPercent:n().optional(),temperature:n().optional(),gpuPercent:n().optional(),gpuMemoryPercent:n().optional()}),aV={name:`metrics-provider`,scope:`system`,mode:`singleton`,methods:{collectSnapshot:k(_(),nV),getCached:k(_(),nV.nullable()),getCurrent:k(_(),iV),getDiskSpace:k(b({dirPath:l()}),OEe),getGpuInfo:k(_(),$B.nullable()),getCpuTemperature:k(_(),n().nullable()),getProcessStats:k(b({pids:S(n())}),S(rV)),listAddonInstances:k(_(),S(kEe).readonly()),getAddonStats:k(b({addonId:l()}),rV.nullable()),listNodeProcesses:k(_(),S(AEe).readonly()),getLoadSeries:k(FEe,PEe)},vocabulary:{notOperatorFacing:j.CLUSTER}},oV=l().min(1).max(256),sV=m(l(),C()),cV=b({id:oV,deviceId:n().int().optional(),at:n().int().optional(),expiresAt:n().int().optional(),data:sV}),lV=b({id:l(),deviceId:n().int().nullable(),at:n().nullable(),expiresAt:n().nullable(),rev:n().int(),updatedAt:n(),data:sV}),uV=m(ui,h([l(),n(),v(),b({in:S(h([l(),n(),v()])).min(1).max(zn)}),b({gt:h([l(),n()]).optional(),gte:h([l(),n()]).optional(),lt:h([l(),n()]).optional(),lte:h([l(),n()]).optional()}).refine(e=>Object.keys(e).length>0,{message:`name at least one bound`})])),dV={kind:gi},fV={deviceId:n().int().optional(),atFrom:n().optional(),atTo:n().optional()},pV=b({...dV,...fV,where:uV.optional(),order:x([`at`,`id`]).optional(),desc:v().optional(),limit:n().int().min(1).max(Vn).default(100),cursor:l().min(1).optional()}),mV=b({records:S(lV),nextCursor:l().nullable()}),IEe=x([`created`,`unchanged`,`updated`]),hV=b({kindId:n().int(),state:IEe,createdIndexes:S(l())}),gV=S(l()),_V=i(`op`,[b({op:p(`put`),kind:gi,record:cV,ifRev:n().int().min(0).optional()}),b({op:p(`patch`),kind:gi,id:oV,data:sV,at:n().int().nullable().optional(),expiresAt:n().int().nullable().optional(),ifRev:n().int().min(1).optional()}),b({op:p(`delete`),kind:gi,id:oV})]),vV=m(l(),m(l(),l())),yV={name:`records`,scope:`system`,mode:`singleton`,internal:!0,methods:{declareKinds:k(b({kinds:m(gi,hi)}),b({kinds:m(l(),hV)}),{kind:`mutation`,auth:`admin`}),get:k(b({...dV,id:oV}),lV.nullable(),{auth:`admin`}),getMany:k(b({...dV,ids:S(oV).min(1).max(zn)}),S(lV),{auth:`admin`}),secretRefs:k(b({...dV,ids:S(oV).min(1).max(zn)}),vV,{auth:`admin`}),put:k(b({...dV,record:cV,ifRev:n().int().min(0).optional()}),b({rev:n().int(),releasedRefs:gV}),{kind:`mutation`,auth:`admin`}),putMany:k(b({...dV,records:S(cV).min(1).max(zn)}),b({count:n().int(),releasedRefs:gV}),{kind:`mutation`,auth:`admin`}),patch:k(b({...dV,id:oV,data:sV,at:n().int().nullable().optional(),expiresAt:n().int().nullable().optional(),ifRev:n().int().min(1).optional()}),b({rev:n().int(),releasedRefs:gV}),{kind:`mutation`,auth:`admin`}),delete:k(b({...dV,id:oV}),b({deleted:v(),secretRefs:gV}),{kind:`mutation`,auth:`admin`}),deleteMany:k(b({...dV,ids:S(oV).min(1).max(zn)}),b({deleted:n().int(),secretRefs:gV}),{kind:`mutation`,auth:`admin`}),query:k(pV,mV,{auth:`admin`}),count:k(b({...dV,...fV,where:uV.optional()}),b({count:n().int()}),{auth:`admin`}),histogram:k(b({...dV,deviceId:n().int().optional(),from:n(),to:n(),bucketMs:n().int().positive()}),b({buckets:S(b({bucketStart:n(),count:n().int()}))}),{auth:`admin`}),aggregate:k(b({...dV,op:x([`sum`,`min`,`max`,`count`]),field:ui.optional(),groupBy:ui.optional(),where:uV.optional()}),b({rows:S(b({group:h([l(),n(),oe()]),value:n().nullable()}))}),{auth:`admin`}),deleteWhere:k(b({...dV,deviceId:n().int().optional(),atBefore:n().optional(),where:uV.optional()}),b({deleted:n().int(),secretRefs:gV}),{kind:`mutation`,auth:`admin`}),transact:k(b({ops:S(_V).min(1).max(zn)}),b({results:S(b({rev:n().int().nullable(),deleted:v()})),releasedRefs:gV,secretRefs:gV}),{kind:`mutation`,auth:`admin`}),deleteDevice:k(b({deviceId:n().int(),kinds:S(gi).optional()}),b({deleted:m(l(),n().int()),secretRefs:gV}),{kind:`mutation`,auth:`admin`}),allocateId:k(b(dV),b({id:n().int()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:j.INTERNAL}},bV=m(l(),C()),xV=b({integrationId:l().min(1)}),SV=b({id:l().min(1)}),CV=b({id:l(),deviceId:n().int().nullable(),at:n().nullable(),expiresAt:n().nullable(),rev:n().int(),updatedAt:n(),data:bV}),wV={id:l().min(1),deviceId:n().int().optional(),at:n().int().optional(),expiresAt:n().int().optional(),data:bV},TV=b({id:l(),addonId:l(),name:l(),info:bV,enabled:v().optional(),originStableId:l().optional()}),LEe=b({id:n().int(),integrationId:l().nullable().optional(),parentDeviceId:n().int().nullable().optional(),type:l().optional(),name:l().optional(),stableId:l().optional()}),EV=b({version:n().int(),methods:S(l())}),DV=b({message:l(),meta:bV.optional(),tags:b({deviceId:n().int().optional()}).optional()}),REe={"ledger.declare":{input:b({owner:l().min(1),metas:S(Mf)}),output:b({bootId:l(),snapshot:x([`none`,`written`,`refused`]),steps:S(Kf),migrationApi:EV.optional()}),behaviours:[`ledger.declare.answers-steps-in-engine-order`,`ledger.declare.answers-the-migration-api`]},"ledger.start":{input:b({id:l().min(1)}),output:b({proceed:v(),state:h([p(`pending`),Hf]),reason:l().nullable()}),behaviours:[`ledger.start.proceeds-when-predecessors-applied`]},"ledger.finish":{input:b({id:l().min(1),result:Vf}),output:b({status:Hf,error:l().nullable(),rowsChanged:n().int().nonnegative()}),behaviours:[`ledger.finish.records-the-outcome`]},"legacyRows.read":{input:xV,output:bV,behaviours:[`legacyRows.read.returns-stored-rows`,`legacyRows.read.absent-store-is-empty`,`legacyRows.caller.sibling-package`]},"legacyRows.clear":{input:xV,output:b({rows:n().int().nonnegative(),secrets:n().int().nonnegative()}),behaviours:[`legacyRows.clear.deletes-the-rows`,`legacyRows.clear.absent-store-is-noop`]},"legacyRows.patch":{input:xV.extend({patch:bV}),output:b({written:v()}),behaviours:[`legacyRows.patch.upserts-keys-and-keeps-the-rest`,`legacyRows.patch.absent-store-writes-nothing`]},"legacyRows.deleteKeys":{input:xV.extend({keys:S(l().min(1))}),output:b({present:v(),removed:bV}),behaviours:[`legacyRows.deleteKeys.removes-the-named-keys`,`legacyRows.deleteKeys.absent-store-reports-not-present`]},"records.get":{input:SV,output:CV.nullable(),behaviours:[`records.get.returns-the-row-or-null`]},"records.getResolved":{input:SV,output:CV.nullable(),behaviours:[`records.getResolved.resolves-secret-fields`]},"records.put":{input:b({...wV,ifRev:n().int().optional()}),output:b({rev:n().int()}),behaviours:[`records.put.creates-and-replaces`,`records.put.if-rev-conflict-throws`]},"records.putMany":{input:b({records:S(b(wV))}),output:b({count:n().int().nonnegative()}),behaviours:[`records.putMany.writes-every-row`]},"records.patch":{input:SV.extend({partial:bV,ifRev:n().int().optional()}),output:b({rev:n().int()}),behaviours:[`records.patch.merges-and-null-removes`]},"records.delete":{input:SV,output:b({deleted:v()}),behaviours:[`records.delete.reports-whether-a-row-went`]},"records.query":{input:b({deviceId:n().int().optional(),atFrom:n().optional(),atTo:n().optional(),where:uV.optional(),limit:n().int().min(1).optional(),cursor:l().min(1).optional(),resolveSecrets:v().optional()}),output:b({records:S(CV),nextCursor:l().nullable()}),behaviours:[`records.query.pages-with-a-cursor`,`records.query.filters-on-a-declared-index`]},"records.deleteWhere":{input:b({deviceId:n().int().optional(),atBefore:n().optional(),where:uV.optional()}),output:b({count:n().int().nonnegative()}),behaviours:[`records.deleteWhere.deletes-the-matching-rows`]},"settings.read":{input:b({}),output:b({store:bV}),behaviours:[`settings.read.returns-the-addon-store`]},"settings.write":{input:b({patch:bV}),output:b({}),behaviours:[`settings.write.merges-and-keeps-other-keys`]},"settings.deleteKeys":{input:b({keys:S(l().min(1))}),output:b({removed:S(l())}),behaviours:[`settings.deleteKeys.removes-only-the-named-keys`]},"deviceSettings.listIds":{input:b({}),output:b({deviceIds:S(n().int())}),behaviours:[`deviceSettings.listIds.names-only-the-addons-own-devices`]},"deviceSettings.read":{input:b({deviceIds:S(n().int())}),output:b({blobs:m(l(),bV)}),behaviours:[`deviceSettings.read.returns-only-the-addons-own-blobs`]},"secrets.resolve":{input:b({refs:S(l())}),output:b({values:m(l(),l().nullable())}),behaviours:[`secrets.resolve.answers-null-for-a-missing-ref`]},"secrets.put":{input:b({ref:l().min(1),value:l()}),output:b({}),behaviours:[`secrets.put.stores-under-the-owner`]},"secrets.delete":{input:b({refs:S(l())}),output:b({deleted:n().int().nonnegative()}),behaviours:[`secrets.delete.ignores-unknown-refs`]},"integrations.list":{input:b({}),output:b({integrations:S(TV)}),behaviours:[`integrations.list.lists-every-integration`]},"integrations.get":{input:b({id:l().min(1)}),output:TV.nullable(),behaviours:[`integrations.get.null-for-an-unknown-id`]},"devices.list":{input:b({addonId:l().min(1),integrationId:l().min(1).optional()}),output:b({devices:S(LEe)}),behaviours:[`devices.list.scoped-to-the-addon`,`devices.list.filters-by-integration`]},"devices.get":{input:b({deviceId:n().int()}),output:b({id:n().int(),integrationId:l().nullable(),hasConfig:v()}).nullable(),behaviours:[`devices.get.null-for-an-unknown-id`,`devices.get.reports-link-and-config`]},"devices.aliases":{input:b({deviceIds:S(n().int())}),output:b({aliases:m(l(),l())}),behaviours:[`devices.aliases.answers-for-the-named-ids-only`]},"devices.setIntegrationId":{input:b({deviceId:n().int(),integrationId:l().min(1)}),output:b({}),behaviours:[`devices.setIntegrationId.links-the-device`]},"node.localNodeId":{input:b({}),output:b({nodeId:l()}),behaviours:[`node.localNodeId.names-this-node`]},"log.info":{input:DV,output:b({}),behaviours:[`log.info.writes-a-line`]},"log.warn":{input:DV,output:b({}),behaviours:[`log.warn.writes-a-line`]}},OV={name:`migrations`,scope:`system`,mode:`singleton`,internal:!0,methods:{listLedger:k(b({}),b({entries:S(Uf)}),{auth:`admin`}),listPending:k(b({owner:l().optional()}),b({pending:S(Wf)}),{auth:`admin`}),dryRun:k(b({id:l().min(1)}),Gf,{auth:`admin`}),markFailed:k(b({id:l().min(1),error:l().min(1)}),Uf,{kind:`mutation`,auth:`admin`}),retry:k(b({id:l().min(1)}),b({entries:S(Uf)}),{kind:`mutation`,auth:`admin`}),restorePreMigration:k(b({database:vf,snapshotId:l().min(1)}),b({scheduled:v(),held:S(l()),restartRequired:v()}),{kind:`mutation`,auth:`admin`}),declareOwner:k(b({owner:l().min(1),metas:S(Mf),retired:S(l().min(1)).optional()}),b({bootId:l(),snapshot:x([`none`,`written`,`refused`]),steps:S(Kf),migrationApi:EV.optional()}),{kind:`mutation`,auth:`admin`}),startMigration:k(b({id:l().min(1)}),b({proceed:v(),state:h([p(`pending`),Hf]),reason:l().nullable()}),{kind:`mutation`,auth:`admin`}),finishMigration:k(b({id:l().min(1),result:Vf}),b({status:Hf,error:l().nullable(),rowsChanged:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),readLegacyIntegrationRows:k(b({integrationId:l().min(1)}),m(l(),C()),{auth:`admin`}),clearLegacyIntegrationRows:k(b({integrationId:l().min(1)}),b({rows:n().int().nonnegative(),secrets:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),patchLegacyIntegrationRows:k(b({integrationId:l().min(1),patch:m(l(),C())}),b({written:v()}),{kind:`mutation`,auth:`admin`}),deleteLegacyIntegrationRowKeys:k(b({integrationId:l().min(1),keys:S(l().min(1))}),b({present:v(),removed:m(l(),C())}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:j.INTERNAL}},kV=b({sourceUrl:l(),metadata:Xde,targets:S(Yde).min(1).readonly(),calibrationRef:l().optional(),sessionId:l().optional()}),AV={name:`model-convert`,scope:`system`,mode:`singleton`,internal:!0,methods:{convert:k(kV,Qde,{kind:`mutation`,auth:`admin`,timeoutMs:6e5})},vocabulary:{notOperatorFacing:j.ML}},jV=b({targetNodeId:l(),modelId:l(),format:x(Pa),entry:ng}),MV=b({ok:v(),sha256:l(),bytes:n(),path:l()}),NV={name:`model-distributor`,scope:`system`,mode:`singleton`,internal:!0,methods:{distributeModel:k(jV,MV,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:j.ML}},PV=i(`kind`,[b({kind:p(`camera`)}),b({kind:p(`sensor`),deviceId:n().int().positive()})]),FV=Object.freeze({kind:`camera`});function zEe(e){if(e===void 0)return{triggeredBy:FV,malformed:!1};let t=PV.safeParse(e);return t.success?{triggeredBy:t.data,malformed:!1}:{triggeredBy:FV,malformed:!0}}var BEe=`cameraSensors`,VEe=8,IV=b({addonId:l().min(1),stableId:l().min(1)});function LV(e){return`${e.addonId}/${e.stableId}`}var RV=x([`in-addition`,`confirm`,`replace`]),zV=`in-addition`,BV=IV.extend({mode:RV.default(zV)}),VV=b({sensors:S(BV).min(1).max(8)}).superRefine((e,t)=>{let n=new Set;e.sensors.forEach((e,r)=>{let i=LV(e);n.has(i)&&t.addIssue({code:`custom`,path:[`sensors`,r],message:`duplicate camera sensor ${i}`}),n.add(i)})}),HV={addonId:l(),stableId:l(),mode:RV.default(zV)},UV=i(`state`,[b({...HV,state:p(`ready`),deviceId:n(),name:l(),caps:S(l()).readonly()}),b({...HV,state:p(`offline`),deviceId:n(),name:l(),reason:x([`offline`,`disabled`])}),b({...HV,state:p(`missing`),reason:l()}),b({...HV,state:p(`unsupported`),deviceId:n(),name:l(),reason:l()}),b({...HV,state:p(`unreadable`),reason:l()})]),WV=x([`onboard-not-listed`,`no-active-detection`]),GV=x([`always`,`when-confirmed`,`never`]),KV=x([`provider-not-split`]),qV=b({detected:v(),atMs:n()}),JV=i(`state`,[b({state:p(`not-configured`),cameraLevel:qV.optional()}),b({state:p(`unreadable`),reason:l(),cameraLevel:qV.optional()}),b({state:p(`configured`),cameraLevel:qV.optional(),sensors:S(UV).readonly(),cameraMotion:GV.optional(),notForwarded:WV.optional(),notEnforced:KV.optional()})]),HEe=Object.freeze({state:`unreadable`,reason:`camera sensor mappings not loaded`}),YV=b({bbox:aC,pixelCount:n(),intensity:n()}),XV=b({detected:v(),regionCount:n(),regions:S(YV).readonly(),rawRegions:S(YV).readonly(),frameWidth:n(),frameHeight:n(),analysisMs:n()}),ZV={name:`motion-detection`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[T.Camera],exposesDeviceSettings:!0,methods:{analyze:k(b({deviceId:n(),frame:iC.optional(),frameHandle:Ca.optional()}),XV,{role:`admin`,kind:`mutation`,notOperatorFacing:`the pipeline feeds it frames — an internal stage, never called by a person`}),removeCamera:k(b({deviceId:n()}),_(),{role:`admin`,kind:`mutation`,notOperatorFacing:`pipeline housekeeping when a camera leaves`}),reset:k(_(),_(),{role:`admin`,kind:`mutation`,notOperatorFacing:`pipeline housekeeping`})},events:{onMotion:{data:b({deviceId:n(),detected:v(),regionCount:n()}),notOperatorFacing:"the analyzer’s raw verdict; the operator signal is the `motion` cap’s `detected` state"}},vocabulary:{noun:P(`Motion analysis`,`Analisi del movimento`),order:3160}},QV=b({package:v(),confidence:n().min(0).max(1),reason:l().min(1)}),$V=b({x:n(),y:n()}),eH=b({kind:p(`rect`),x:n(),y:n(),width:n(),height:n()}),tH=b({kind:p(`polygon`),points:S($V)}),nH=b({kind:p(`grid`),gridWidth:n().meta(M(`none`)),gridHeight:n().meta(M(`none`)),cells:S(v())}),rH=b({kind:p(`line`),points:S($V)}),UEe=i(`kind`,[eH,tH,nH,rH]),iH=x([`rect`,`polygon`,`grid`,`line`]),aH=b({min:n(),max:n()}),oH=b({width:n(),height:n()}),sH=[`owner-not-ready`,`store-read-failed`,`three-way-read-unavailable`,`invalid-stored`,`not-cluster-scoped`],cH=[{stepId:`face-embedding`,label:`Face recognition model`,defaultModelId:`auraface-r100`,indexName:`the enrolled face gallery`,options:[{id:`auraface-r100`,label:`AuraFace R100`}]},{stepId:`clip-embedding`,label:`Semantic search model`,defaultModelId:`siglip2-b16-224`,indexName:`the object semantic-search index`,options:[{id:`siglip2-b16-224`,label:`SigLIP2 B/16 (Apache-2.0)`}]}],WEe=`cluster-step-models`;function lH(e){return`clusterModel:${e}`}function GEe(e){return cH.some(t=>t.stepId===e)}var uH=Object.freeze(Object.fromEntries(cH.map(e=>[e.stepId,e.defaultModelId])));function dH(e){return e==null||e===``?{kind:`absent`}:typeof e==`string`?{kind:`chosen`,modelId:e}:{kind:`invalid`,value:e}}function fH(e){let t=[];for(let n of cH){let r=dH(e[lH(n.stepId)]);r.kind===`invalid`&&t.push({stepId:n.stepId,value:r.value})}return t}function pH(e){let t={};for(let n of cH){let r=dH(e[lH(n.stepId)]);t[n.stepId]=r.kind===`chosen`?r.modelId:n.defaultModelId}return t}function KEe(e){return typeof e==`object`&&!!e&&`key`in e}function qEe(e){return e===null?uH:pH(hH(e,mH()))}function JEe(e){return e===null?[]:fH(hH(e,mH()))}function mH(){return new Set(cH.map(e=>lH(e.stepId)))}function hH(e,t){let n={};for(let r of e.sections)for(let e of r.fields)!KEe(e)||typeof e.key!=`string`||t.has(e.key)&&(n[e.key]=e.value);return n}function YEe(e,t){let n=cH.find(t=>t.stepId===e);if(n===void 0)return null;let r=t[e];return r!==void 0&&r!==``?r:n.defaultModelId}var XEe=24,gH=[{stepId:`face-embedding`,key:`minLandmarkFaceSize`,label:`Min face size to embed (detection-frame px)`,description:`Faces smaller than this in the small frame the detector sees are not embedded, so they can never be recognised. Below it the face cannot be aligned reliably and a bad embedding matches everyone. Same value on every node. 0 = no limit.`,type:`slider`,min:0,max:64,step:2,default:24}];function _H(e,t){return`clusterStepSetting:${e}:${t}`}function ZEe(e){return gH.filter(t=>t.stepId===e)}var QEe=n().finite();function vH(e){let t={};for(let n of gH){let r=QEe.safeParse(e[_H(n.stepId,n.key)]),i=r.success?r.data:n.default,a=t[n.stepId]??{};t[n.stepId]={...a,[n.key]:i}}return t}var yH=vH({});function $Ee(e){return e===null?yH:vH(hH(e,new Set(gH.map(e=>_H(e.stepId,e.key)))))}function eDe(e,t,n){let r=n[e];return r===void 0||Object.keys(r).length===0?t===void 0?void 0:{...t}:t===void 0?{...r}:{...t,...r}}var bH=x([`new`,`entered`,`left`,`moving`,`idle`]),xH=x([`motion`,`object`,`audio`]),SH=i(`kind`,[eH,tH]),CH=x([`motion`,`audio`,`person`,`vehicle`,`animal`,`door`,`pir`,`smoke`,`water`,`button`,`package`,`generic`]),wH=x([`motion`,`audio`,`detection`,`sensor`,`control`,`custom`,`package`]),tDe=x([`macro`,`sub`]),TH=b({kind:l(),labelKey:l(),label:l(),color:l(),iconId:l(),icon:CH,category:wH,parentKind:l().nullable(),level:tDe,source:b({capName:l(),deviceId:n()})}),EH=b({deviceId:n(),kinds:S(TH).readonly()}),DH=b({id:l(),deviceId:n(),sourceDeviceId:n(),kind:l(),value:m(l(),C()).nullable(),timestamp:n()}),OH=b({x:n(),y:n(),timestamp:n(),bbox:aC,source:x([`frame`,`recovery`]).optional(),score:n().optional()}),nDe=b({timestamp:n(),position:OH,mediaId:n().int()}),kH=b({minX:n(),minY:n(),maxX:n(),maxY:n()}),AH=x([`full`,`slim`]),jH=b({label:l(),peakScore:n(),count:n(),firstAt:n(),lastAt:n()}),MH=x([`pipeline`,`onboard`,`sensor`,`audio`]),NH=x([`none`,`staging`,`trained`]),rDe=500,PH={markForTrain:v().optional(),debug:v().optional(),debugNote:l().max(500).optional(),favourited:v().optional()},FH={retrainStatus:NH.optional()},IH=b(PH),LH=b({trackId:l(),markForTrain:v(),debug:v(),debugNote:l(),favourited:v(),retrainStatus:NH}),iDe=h([p(1),p(2)]),RH=b({stepId:l(),modelId:l().optional(),decidedAt:n(),identityId:l().optional()}),zH={label:l().optional(),labelScore:n().optional(),labelMeta:RH.optional(),subLabel:l().optional(),subLabelScore:n().optional(),subLabelMeta:RH.optional()},BH=b({deviceId:n(),tracks:n().int(),files:n().int(),bytes:n().int()}),VH=b({generatedAt:n(),trackCount:n().int(),fileCount:n().int(),byteCount:n().int(),truncated:v(),devices:S(BH).readonly()}),HH=b({nodeId:l(),deviceKey:l().optional(),modelId:l().optional()}),UH=b({trackId:l(),deviceId:n(),className:l(),...zH,producingDeviceName:l().optional(),source:MH.optional(),firstSeen:n(),lastSeen:n(),positions:S(OH).readonly(),snapshots:S(nDe).readonly(),zonesVisited:S(l()).readonly(),zoneNames:S(l()).readonly().optional(),classes:S(l()).readonly().optional(),totalDistance:n(),state:bH,active:v(),importance:n().optional(),bestEventId:l().optional(),importanceReason:l().optional(),audioLabels:S(jH).readonly().optional(),envelope:kH.optional(),hasFace:v().optional(),hasEmbeddedFace:v().optional(),hasRider:v().optional(),previewMissReason:l().optional(),modelId:l().optional(),openedPlacement:HH.optional(),closedPlacement:HH.optional(),frameWidth:n().optional(),frameHeight:n().optional(),...PH,...FH}),WH={id:n().int(),deviceId:n(),timestamp:n()},GH=b({...WH,kind:p(`motion`),regionCount:n(),regions:S(b({bbox:aC,pixelCount:n(),intensity:n()})).readonly().optional(),frameWidth:n().optional(),frameHeight:n().optional(),mediaUrl:l().optional(),triggeredBy:PV.optional(),durationMs:n().nullable().optional(),edges:S(n()).readonly().optional()}),KH=x([`pipeline`,`onboard`]),qH=x([`enter`,`exit`]),JH=b({direction:qH,zoneId:l(),zoneName:l().optional()}),aDe=b({zoneId:l(),zoneName:l().optional(),overlapPct:n()}),YH=b({...WH,kind:p(`object`),source:KH.optional(),frameId:l().optional(),idempotencyKey:l().optional(),trackId:l().optional(),className:l(),...zH,confidence:n().optional(),bbox:aC.optional(),zones:S(l()).readonly().optional(),zoneOverlaps:S(aDe).readonly().optional(),spawnRefused:l().optional(),state:bH.optional(),zoneCrossing:JH.optional(),frameWidth:n().optional(),frameHeight:n().optional(),mediaId:n().int().optional(),keyFrameMediaId:n().int().optional(),mediaUrl:l().optional(),observedAt:n().optional(),packagePossible:v().optional(),packageLlmVerdict:QV.optional(),importance:n().optional()}),XH=b({...WH,kind:p(`audio`),rms:n(),dbfs:n(),classification:b({className:l(),originalClass:l().optional(),score:n()}).optional(),classifyOutcome:uC.optional(),mediaUrl:l().optional()}),ZH=x([`crop`,`thumbnail`,`snapshot`,`firstFrame`,`lastFrame`,`fullFrame`,`fullFrameBoxed`,`faceCrop`,`plateCrop`,`keyFrame`,`keyFrameSmall`,`thumbnailSmall`,`confirmationCrop`,`debugCrop`,`sceneFrame`,`lastSceneFrame`]),QH=b({mediaId:n().int(),kind:ZH,sizeBytes:n(),timestamp:n()}),$H=QH.extend({url:l(),base64:l()}),eU=$H.omit({base64:!0}),tU=x([`person`,`vehicle`,`animal`,`package`,`face`,`plate`]),nU=x([`subject`,`model_error`]),rU=x([`operator`,`assist`,`pipeline`,`llm`]),iU=b({x:n(),y:n(),w:n(),h:n()}),aU=b({source:rU,ref:l().min(1),bbox:iU,macroClass:tU,label:l().optional(),score:n().optional(),modelId:l().optional()}),oU=b({ref:l().min(1),snapshot:aU}),sU=x(yp),cU=b({ref:l(),savedId:l().optional(),status:sU,approximate:v(),origin:aU.optional(),macroClass:tU.optional(),label:l().optional(),iou:n().optional()}),lU=b({boxes:S(cU).readonly(),summary:b({counts:m(sU,n().int()),total:n().int(),changed:n().int(),approximate:v()})}),uU=b({id:l(),trackId:l().optional(),deviceId:n(),mediaKey:l(),bbox:iU,macroClass:tU,label:l().optional(),subLabel:l().optional(),kind:nU,source:rU,assistModelId:l().optional(),assistScore:n().optional(),origin:aU.nullable().optional(),exportedInBatch:l().optional(),createdAt:n()}),dU=uU.omit({id:!0,trackId:!0,deviceId:!0,mediaKey:!0,createdAt:!0,exportedInBatch:!0}),fU=x([`correct`,`wrong`,`wrong-label`]),pU=b({verdict:fU,suggestedClass:l().optional(),suggestedMacroClass:tU.optional(),suggestedLabel:l().optional(),trackId:l(),at:n().optional()}),mU=b({trackId:l(),className:l(),label:l().optional(),bbox:iU.optional(),verdict:fU,suggestedClass:l().optional(),at:n().optional()}),hU=b({trackId:l(),deviceId:n(),className:l(),label:l().optional(),firstSeen:n(),lastSeen:n(),frameCount:n().int(),annotationCount:n().int(),verdict:pU.optional()}),gU=b({mediaId:n().int(),kind:ZH,timestamp:n(),sizeBytes:n().int(),copied:v()}),_U=b({bbox:iU,macroClass:tU,label:l().optional(),subLabel:l().optional(),score:n().optional(),modelId:l().optional(),trackId:l(),basis:x([`subject-box`,`position`,`verdict`]),deltaMs:n()}),vU=x([`track`,`recording`]),yU=b({frameId:l(),deviceId:n(),origin:vU,trackId:l().optional(),sourceMediaId:n().int().optional(),epochMs:n().optional(),sourceKind:ZH,sizeBytes:n().int(),width:n().int(),height:n().int(),copiedAt:n(),capturedAt:n().optional(),complete:v(),pipelineBoxes:S(_U).readonly().optional(),collectionIds:S(l()).readonly().optional(),verdict:pU.optional(),revision:n().int().optional(),dismissed:S(oU).readonly().optional(),review:lU.optional(),imageUrl:l().optional(),thumbnailUrl:l().optional()}),bU=x([`source-missing`,`unreadable-image`,`write-failed`]),xU=b({copied:S(yU).readonly(),refused:S(b({sourceMediaId:n().int(),reason:bU})).readonly()}),SU=b({candidates:S(gU).readonly(),copies:S(yU).readonly(),autoPickMediaId:n().int().optional()}),CU=x([`unannotated`,`annotated`,`complete`]),wU=b({workState:CU.optional(),deviceIds:S(n()).max(500).optional(),collectionId:l().optional(),classes:S(tU).optional(),page:n().int().positive().default(1),pageSize:n().int().positive().max(100).default(50)}),TU=yU.extend({workState:CU}),EU=b({frames:S(TU).readonly(),total:n().int().nonnegative(),page:n().int().positive(),pageSize:n().int().positive()}),DU=b({deviceId:n(),unannotated:n().int().nonnegative(),annotated:n().int().nonnegative(),complete:n().int().nonnegative(),pctOfCorpus:n().min(0).max(1).nullable()}),OU=b({total:n().int().nonnegative(),unannotated:n().int().nonnegative(),annotated:n().int().nonnegative(),complete:n().int().nonnegative(),cameras:S(DU).readonly()}),kU=b({deviceIds:S(n()).optional(),frameIds:S(l()).max(2e4).optional(),collectionIds:S(l()).max(200).optional(),collectionId:l().optional(),batchId:l().optional(),completeOnly:v().optional(),workState:CU.optional(),classes:S(tU).optional()}),AU=x([`frames`,`crops`]),jU=b({kind:p(`http`),method:x([`PUT`,`POST`]),url:l().url(),headers:m(l(),l()).optional()}),MU=b({batchId:l(),frames:n().int(),crops:n().int(),annotations:n().int(),missing:n().int(),bytes:n().int(),sha256:l(),status:n().int()}),NU=i(`kind`,[b({kind:p(`package`),zone:iU.optional()}),b({kind:p(`objects`),modelId:l(),minScore:n().optional()})]),PU=i(`kind`,[b({kind:p(`proposed`),modelId:l(),stepId:l(),minScore:n(),proposals:S(dU).readonly(),belowThreshold:n().int()}),b({kind:p(`refused`),reason:l(),detail:l().optional()})]),FU=b({id:l(),name:l(),createdAt:n(),frameCount:n().int()}),IU=i(`kind`,[b({kind:p(`created`),collection:FU}),b({kind:p(`refused`),reason:x([`empty-name`,`duplicate-name`])})]),LU=i(`kind`,[b({kind:p(`renamed`),collection:FU}),b({kind:p(`refused`),reason:x([`empty-name`,`duplicate-name`,`unknown-collection`])})]),RU=i(`kind`,[b({kind:p(`added`),collectionId:l(),frame:yU,reused:v()}),b({kind:p(`refused`),reason:x([`unknown-collection`,`still-unavailable`,`still-busy`,`unreadable-image`,`write-failed`]),detail:l().optional()})]),zU=b({id:l(),name:l(),model:l(),kind:l(),leavesHouse:v()}),BU=dU.extend({reason:l()}),VU=b({ref:l(),verdict:x([`confirmed`,`wrong-class`,`not-an-object`,`uncertain`]),suggestedClass:tU.optional(),reason:l()}),HU=i(`kind`,[b({kind:p(`proposed`),profileId:l(),model:l(),leftHouse:v(),proposals:S(BU).readonly(),reviews:S(VU).readonly(),rejected:n().int()}),b({kind:p(`refused`),reason:x([`unknown-frame`,`unreadable-frame`,`unknown-profile`,`profile-disabled`,`no-vision`,`cloud-not-confirmed`,`llm-error`,`malformed-answer`]),detail:l().optional()})]),UU=b({deviceIds:S(n()).readonly().optional(),collectionIds:S(l()).max(200).readonly().optional(),frameIds:S(l()).max(2e4).readonly().optional()}),WU=b({frames:n().int(),completeFrames:n().int(),completeness:n(),subjects:n().int(),modelErrors:n().int(),hardNegatives:n().int(),cells:S(b({macroClass:l(),deviceId:n(),lighting:x([`day`,`night`,`unknown`]),subjects:n().int(),frames:n().int()})).readonly(),cameras:S(b({deviceId:n(),frames:n().int(),completeFrames:n().int()})).readonly()}),oDe=b({id:l(),name:l(),createdAt:n(),selection:UU,layout:AU,completeOnly:v(),frameCount:n().int(),annotationHash:l(),manifestSchema:l(),stats:WU}),GU=b({collectionIds:S(l()).min(1),workState:x([`complete`,`annotated_or_complete`,`any_annotated`]).default(`complete`)}),KU=i(`kind`,[b({kind:p(`resolved`),frameIds:S(l()).max(2e4).readonly(),stats:WU,annotationHash:l(),layout:AU}),b({kind:p(`refused`),reason:x([`unknown-collection`,`no-frames`]),detail:l()})]),qU=b({trackId:l(),retrainStatus:NH,changed:v(),reason:x([`unknown-track`,`no-frames-copied`,`not-staging`,`not-trained`,`unchanged`]).optional()}),JU=1e3,YU=5e3,XU=b({deviceId:n(),since:n().optional(),until:n().optional(),limit:n().int().min(1).max(YU).default(JU),projection:x([`full`,`slim`]).optional()}),sDe=XU.extend({classFilter:l().optional()}),ZU=b({deviceIds:S(n()),since:n().optional(),until:n().optional(),limit:n().int().min(1).max(1e3).default(200),cursor:l().optional(),projection:AH.optional(),includeStationary:v().optional(),classes:S(l()).optional(),excludeSources:S(MH).optional()}),QU=b({tracks:S(UH).readonly(),nextCursor:l().nullable()}),$U=50,eW=200,cDe=b({deviceId:n(),since:n(),until:n(),limit:n().int().min(1).max(eW).default($U),minImportance:n().min(0).max(1).optional(),classFilter:l().optional()}),tW=b({id:l(),trackId:l(),timestamp:n(),className:l(),...zH,importance:n(),bestEventId:l(),windowMs:n().optional(),audioLabels:S(jH).readonly().optional(),...PH,...FH}),lDe=b({deviceIds:S(n()).min(1).max(200),since:n(),until:n(),limit:n().int().min(1).max(eW).default($U),minImportance:n().min(0).max(1).optional(),classFilter:l().optional()}),uDe=b({deviceId:n(),events:S(tW).readonly()}),nW=b({bucketStart:n(),motion:n().int(),object:n().int(),audio:n().int(),audioDbfs:n().optional()}),dDe=200,rW=b({deviceId:n(),read:x([`read`,`unreadable`]),buckets:S(nW).readonly()}),fDe=b({trackId:l(),className:l(),confidence:n(),bbox:aC,zones:S(l()).readonly(),state:bH}),pDe=ce({id:l(),kind:x([`first-level`,`detail`]),macroClass:l(),score:n(),bbox:b({x:n(),y:n(),width:n(),height:n()}),labels:S(ce({label:l(),score:n()})).readonly(),parentId:l().optional()}),iW=YH.extend({score:n()}),mDe=b({text:l(),deviceId:n().optional(),since:n().optional(),until:n().optional(),classFilter:l().optional(),limit:n().default(50),minScore:n().min(0).max(1).optional(),strictness:dde.optional(),modelId:l().min(1).optional()}),aW=b({tracks:n().int(),events:n().int(),media:n().int(),faces:n().int(),plates:n().int(),embeddings:n().int()}),hDe=b({mediaDropped:n().int(),tracks:n().int(),events:n().int()}),gDe=b({deviceId:n(),rows:n().int(),bytes:n().int()}),_De=b({totalRows:n().int(),totalBytes:n().int(),devices:S(gDe).readonly()}),vDe=b({kind:ZH,rows:n().int(),bytes:n().int()}),yDe=b({totalRows:n().int(),totalBytes:n().int(),kinds:S(vDe).readonly(),unaccountedRows:n().int(),unaccountedBytes:n().int()}),oW=b({motion:n().int(),object:n().int(),audio:n().int()}),bDe=b({deviceId:n().optional(),since:n().optional(),until:n().optional(),maxTracks:n().int().positive().optional(),executeOnNodeId:l().optional(),pacingMs:n().int().nonnegative().optional(),force:v().optional()}),xDe=b({deleted:n(),failedIndexes:S(l()).optional()}),sW=x([`stores-unavailable`,...sH,`method-unavailable`,`read-failed`,`reads-disagree`,`not-a-clip-model`,`force-requires-max-tracks`]),SDe=b({started:v(),alreadyRunning:v(),refusal:sW.optional(),modelId:l().optional(),index:l().optional()}),CDe=b({running:v(),scanned:n(),rebuilt:n(),missingKeyFrame:n(),missingEvent:n(),missingBbox:n(),boxSource:b({subjectBox:n(),positions:n(),event:n(),refused:n()}),alreadyInSpace:n(),force:v().nullable(),forcedInSpace:n(),notRunnable:n(),noCapableNode:n(),failed:n(),complete:v().nullable(),startedAtMs:n().nullable(),finishedAtMs:n().nullable(),error:l().nullable(),modelId:l().nullable(),index:l().nullable()}),wDe=b({started:v(),alreadyRunning:v()}),TDe=b({mode:x([`report`,`reclaim`]).default(`report`),scopes:S(x([`motion-still`,`track-filmstrip`])).min(1).optional(),deviceIds:S(n().int()).min(1).optional(),restart:v().optional(),pageSize:n().int().min(50).max(5e3).optional(),maxRowsPerDevice:n().int().min(1).max(5e5).optional(),maxReclaimPerDevice:n().int().min(1).max(5e5).optional(),maxBytesPerRun:n().int().min(1).optional(),budgetMinutes:n().int().min(1).max(720).optional(),throttleBytesPerSec:n().int().min(64*1024).optional(),graceMinutes:n().int().min(1).max(10080).optional()}),EDe=b({running:v(),mode:x([`report`,`reclaim`]).nullable(),totalExamined:n(),totalEligible:n(),totalReclaimed:n(),totalBytesReclaimed:n(),totalRefused:n(),devicesDone:n(),complete:v().nullable(),startedAtMs:n().nullable(),finishedAtMs:n().nullable(),error:l().nullable()}),cW=x([`motion`,`audio-dbfs`,`battery`,`occupancy`]),DDe=`|`;function ODe(e,t){let n=e??``;return t===void 0?n:`${n}|${t}`}function kDe(e){let t=e.indexOf(`|`);return t<0?{zoneId:e}:{zoneId:e.slice(0,t),className:e.slice(t+1)}}var lW=b({scope:l(),bucketStart:n().int(),samples:n().int().nonnegative(),sum:n(),min:n(),max:n()}),uW={name:`pipeline-analytics`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[T.Camera],exposesDeviceSettings:!0,methods:{getActiveTracks:k(b({deviceId:n()}),S(UH).readonly()),getTrack:k(b({deviceId:n(),trackId:l()}),UH.nullable()),listTracks:k(b({deviceId:n(),since:n().optional(),until:n().optional(),limit:n().optional(),zone:SH.optional(),projection:AH.optional(),includeStationary:v().optional(),classes:S(l()).optional(),excludeSources:S(MH).optional()}),S(UH).readonly()),listRecentTracks:k(ZU,QU),clearTracks:k(b({deviceId:n()}),_(),{kind:`mutation`,auth:`admin`}),getMotionEvents:k(XU,S(GH).readonly()),getObjectEvents:k(sDe,S(YH).readonly()),getAudioEvents:k(XU,S(XH).readonly()),listEventKinds:k(b({deviceId:n()}),S(TH).readonly()),listEventKindsBatch:k(b({deviceIds:S(n()).min(1).max(200)}),S(EH).readonly()),getSensorEvents:k(b({deviceId:n(),since:n().optional(),until:n().optional(),kinds:S(l()).optional(),limit:n().int().min(1).max(YU).default(JU)}),S(DH).readonly()),getKeyEvents:k(cDe,S(tW).readonly()),getKeyEventsBatch:k(lDe,S(uDe).readonly()),readLongTermSeries:k(b({deviceId:n(),series:cW,scope:l().optional(),from:n(),to:n(),limit:n().int().positive().optional()}),S(lW).readonly()),getEventDensity:k(b({deviceId:n(),since:n(),until:n(),bucketMs:n().int().positive()}),S(nW).readonly()),getEventDensityBatch:k(b({deviceIds:S(n()).min(1).max(200),since:n(),until:n(),bucketMs:n().int().positive()}),S(rW).readonly()),pruneEventsBefore:k(b({deviceId:n(),cutoffMs:n()}),b({motion:n().int(),object:n().int(),audio:n().int()}),{kind:`mutation`,auth:`admin`}),pruneTracksBefore:k(b({deviceId:n(),cutoffMs:n()}),aW,{kind:`mutation`,auth:`admin`}),wipeAllAnalytics:k(b({deviceId:n()}),aW,{kind:`mutation`,auth:`admin`}),reconcileFromDisk:k(b({deviceId:n()}),hDe,{kind:`mutation`,auth:`admin`}),deleteTracks:k(b({deviceId:n(),trackIds:S(l()).min(1)}),b({deleted:n().int(),failed:S(l()).readonly(),sparedMediaIds:S(n().int()).readonly().optional()}),{kind:`mutation`,auth:`admin`}),setTrackFlags:k(b({deviceId:n(),trackId:l(),flags:IH}),LH,{kind:`mutation`,notOperatorFacing:`curating a recorded track in the review UI, not a live step`}),listArchivedDebugNotes:k(Ap,S(kp).readonly(),{kind:`query`}),setTrackRelation:k(Ip,Pp,{kind:`mutation`,notOperatorFacing:`curating recorded tracks in the review UI, not a live step`}),clearTrackRelation:k(Lp,Rp,{kind:`mutation`,notOperatorFacing:`curating recorded tracks in the review UI, not a live step`}),setTrackPurity:k(zp,Bp,{kind:`mutation`,notOperatorFacing:`curating a recorded track in the review UI, not a live step`}),listTrackRelations:k(Vp,Hp,{kind:`query`}),listBirthDecisions:k(Op,S(Dp).readonly(),{kind:`query`}),getEventStoreFootprint:k(b({}),_De,{kind:`query`,auth:`admin`}),getEventMediaFootprintByKind:k(b({deviceId:n().int().optional()}),yDe,{kind:`query`,auth:`admin`}),pruneEvents:k(b({olderThanMs:n(),reason:Xp.optional()}),oW,{kind:`mutation`,auth:`admin`}),deleteDeviceEvents:k(b({deviceId:n()}),oW,{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:k(wm,b({paused:p(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:k(wm,b({resumed:p(!0)}),{kind:`mutation`,auth:`admin`}),refreshStorageLocationsForMigration:k(wm,b({refreshed:p(!0)}),{kind:`mutation`,auth:`admin`}),startStorageMigrationMove:k(Nm,b({jobId:l()}),{kind:`mutation`,auth:`admin`}),getStorageMigrationMoveStatus:k(b({jobId:l()}),xm.nullable(),{auth:`admin`}),cancelStorageMigrationMove:k(b({jobId:l()}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`}),relocateMedia:k(Dm,b({jobId:l()}),{kind:`mutation`,auth:`admin`}),countUnstampedEventMedia:k(b({}),km,{auth:`admin`}),getMediaLocationCensus:k(Am,Mm,{kind:`query`,auth:`admin`}),countRelocatableMedia:k(ah,ih,{kind:`query`,auth:`admin`}),listRelocateMediaJobs:k(b({}),S(xm).readonly(),{kind:`query`,auth:`admin`}),cancelRelocateMedia:k(b({jobId:l()}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`}),listOpsLog:k(Qp,S(Zp).readonly(),{kind:`query`,auth:`admin`}),reclaimDebugMedia:k(TDe,wDe,{kind:`mutation`,auth:`admin`}),getMediaReclaimStatus:k(b({}),EDe,{kind:`query`,auth:`admin`}),getTrainingExportSummary:k(b({deviceIds:S(n()).optional()}),VH,{kind:`query`,auth:`admin`}),getTrainingExportUrl:k(b({deviceIds:S(n()).optional()}),b({url:l()}),{kind:`query`,auth:`admin`}),listRetrainStaging:k(b({deviceIds:S(n()).optional(),limit:n().int().min(1).max(500).optional()}),S(hU).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),listRetrainCorpusPage:k(wU,EU,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),getRetrainCorpusKpi:k(b({}),OU,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),listRetrainFrames:k(b({trackId:l()}),SU,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),selectRetrainFrames:k(b({deviceId:n(),trackId:l(),mediaIds:S(n().int()).min(1)}),xU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),deselectRetrainFrame:k(b({deviceId:n(),trackId:l().optional(),frameId:l()}),b({removed:v(),removedAnnotations:n().int()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),getRetrainFrameImage:k(b({frameId:l()}),b({base64:l(),width:n().int(),height:n().int()}),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),proposeRetrainAnnotations:k(b({deviceId:n(),trackId:l().optional(),frameId:l(),subject:NU,nodeId:l().optional()}),PU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainAnnotations:k(b({trackId:l().optional(),frameIds:S(l()).max(2e3).optional()}),S(uU).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),saveRetrainAnnotations:k(b({deviceId:n(),trackId:l().optional(),frameId:l(),annotations:S(dU),expectedRevision:n().int().optional(),dismissed:S(oU).optional()}),S(uU).readonly(),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),backfillRetrainOrigins:k(b({deviceId:n(),trackId:l().optional(),frameId:l(),expectedRevision:n().int().optional(),origins:S(b({annotationId:l(),origin:aU})).min(1).max(500)}),b({updated:n().int(),skipped:n().int(),revision:n().int()}),{kind:`mutation`,auth:`admin`}),completeRetrainTrack:k(b({deviceId:n(),trackId:l()}),qU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),restageRetrainTrack:k(b({deviceId:n(),trackId:l()}),qU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),getRetrainExportUrl:k(kU.extend({layout:AU.optional()}),b({url:l()}),{kind:`query`,auth:`admin`}),setRetrainFrameComplete:k(b({deviceId:n(),trackId:l().optional(),frameId:l(),complete:v()}),yU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),writeRetrainArchive:k(b({filter:kU,layout:AU,target:jU}),MU,{kind:`mutation`,auth:`admin`,timeoutMs:60*6e4}),offerRetrainArchive:k(b({filter:kU,layout:AU}),b({ticket:Ti,frames:n().int(),annotations:n().int()}),{kind:`mutation`,auth:`admin`,timeoutMs:12e4}),listRetrainAssistProfiles:k(b({}),S(zU).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),proposeRetrainAnnotationsWithLlm:k(b({deviceId:n(),trackId:l().optional(),frameId:l(),profileId:l(),classes:S(tU).min(1),boxes:S(b({ref:l(),bbox:iU,macroClass:tU,label:l().optional()})).max(50),allowCloud:v()}),HU,{kind:`mutation`,auth:`admin`,timeoutMs:18e4}),createRetrainCollection:k(b({name:l().max(120)}),IU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainCollections:k(b({}),S(FU).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),resolveRetrainTrainingCorpus:k(GU,KU,{kind:`query`,auth:`admin`,timeoutMs:6e4}),renameRetrainCollection:k(b({id:l(),name:l().max(120)}),LU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),deleteRetrainCollection:k(b({id:l()}),b({deleted:v(),removedFrames:n().int()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),addRetrainFrameFromRecording:k(b({collectionId:l(),deviceId:n(),epochMs:n(),verdictSubject:mU.optional()}),RU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`,timeoutMs:6e4}),addRetrainFramesToCollection:k(b({collectionId:l(),frameIds:S(l()).min(1).max(500)}),b({added:n().int(),alreadyMember:n().int(),unknownFrameIds:S(l()).readonly()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),removeRetrainFrameFromCollection:k(b({collectionId:l(),frameId:l()}),b({removed:v(),deletedFrame:v()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainCollectionFrames:k(b({collectionId:l()}),S(yU).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),getEventMedia:k(b({ownerType:Eu,eventId:n().int(),kind:ZH.optional(),deviceId:n()}),S($H).readonly()),getTrackMedia:k(b({trackId:l(),kinds:S(ZH).optional(),deviceId:n()}),S($H).readonly()),listTrackMedia:k(b({trackId:l(),deviceId:n()}),S(eU).readonly()),listEventMedia:k(b({ownerType:Eu,eventId:n().int(),deviceId:n()}),S(eU).readonly()),ownersWithMedia:k(b({deviceId:n(),ownerKind:Ou,ownerIds:S(l()).max(5e3)}),S(l()).readonly()),searchObjectEvents:k(mDe,S(iW).readonly(),{caller:`required`}),wipeObjectEmbeddings:k(b({}),xDe,{kind:`mutation`,auth:`admin`}),rebuildObjectEmbeddings:k(bDe,SDe,{kind:`mutation`,auth:`admin`}),getObjectEmbeddingRebuildStatus:k(b({}),CDe)},events:{onFrameTracked:{data:b({deviceId:n(),timestamp:n(),frameWidth:n(),frameHeight:n(),detections:S(pDe).readonly()}),notOperatorFacing:`one tracker frame — stream rate, never an automation trigger`},onTrackStarted:{data:b({deviceId:n(),trackId:l(),className:l()}),trigger:{category:w.PipelineAnalyticsTrackStarted,label:P(`Subject appeared`,`Soggetto comparso`),phrase:P(`When {device} starts following a subject`,`Quando {device} inizia a seguire un soggetto`),icon:`scan-eye`}},onTrackEnded:{data:b({deviceId:n(),trackId:l(),className:l(),durationMs:n()}),trigger:{category:w.PipelineAnalyticsTrackEnded,label:P(`Subject left`,`Soggetto uscito`),phrase:P(`When a subject leaves the view of {device}`,`Quando un soggetto esce dall’inquadratura di {device}`),icon:`scan-eye`}},onDetectionEvent:{data:b({deviceId:n(),kind:xH,eventId:l(),timestamp:n()}),trigger:{category:w.PipelineAnalyticsDetectionEvent,label:P(`Detection event`,`Evento di rilevamento`),phrase:P(`When {device} records a detection event`,`Quando {device} registra un evento di rilevamento`),icon:`radar`}}},vocabulary:{noun:P(`Tracking`,`Tracciamento`),order:3200,extraEvents:[{category:w.PipelineAnalyticsPackageDelivered,label:P(`Package delivered`,`Pacco consegnato`),phrase:P(`When a package is left in front of {device}`,`Quando viene lasciato un pacco davanti a {device}`),icon:`package`},{category:w.PipelineAnalyticsPackagePickedUp,label:P(`Package picked up`,`Pacco ritirato`),phrase:P(`When a package is picked up in front of {device}`,`Quando viene ritirato un pacco davanti a {device}`),icon:`package-open`}]}},dW=b({x:n(),y:n(),w:n(),h:n()}),fW=b({stepId:l(),modelId:l(),detections:S(b({bbox:u([n(),n(),n(),n()]),score:n(),landmarks:S(b({x:n(),y:n()})).optional()})).min(1)}),pW=b({handle:Ca,cropFrameSpace:b({x:n(),y:n(),w:n(),h:n()})});b({crop:b({left:n(),top:n(),width:n().positive(),height:n().positive()}).optional(),content:b({width:n().int().positive(),height:n().int().positive()}),fit:x([`stretch`,`contain`]),format:x([`rgb`,`gray`,`jpeg`])});var ADe=b({registryId:l().min(1),id:l().min(1),width:n().int().positive(),height:n().int().positive(),format:x([`rgb`,`gray`]),timestamp:n(),capturedAt:n().optional()}),mW=x([`onnx`,`coreml`,`openvino`,`tflite`,`pt`,`gguf`]),hW=x([`detector`,`cropper`,`classifier`,`refiner`,`audio-classifier`]),gW=b({runtime:p(`python`),backend:l(),format:mW,device:l().optional()}),_W=b({deviceKey:l().nullable(),runtime:l(),batchMode:l(),windowMs:n(),maxBatchSize:n(),concurrency:n(),numWorkers:n()}),jDe=b({engine:gW,devices:S(b({id:l(),label:l(),description:l().optional()})).readonly(),defaultDevice:l()}),vW=a(()=>b({addonId:l(),addonName:l(),slot:hW,inputClasses:S(l()).readonly(),outputClasses:S(l()).readonly(),enabled:v(),modelId:l(),children:S(vW).readonly(),group:l().optional(),settings:m(l(),C()).optional()})),MDe=b({id:l(),name:l(),formats:m(l(),Hde),group:$h.optional(),legacy:v().optional(),provider:eg.optional(),defaultConfidence:n().optional(),suppliesSteps:S(tg).readonly().optional()}),NDe=ye(),PDe=b({id:l(),name:l(),slot:hW,inputClasses:S(l()).readonly(),outputClasses:S(l()).readonly(),childSlots:S(hW).readonly(),models:S(MDe).readonly(),defaultModelId:l(),defaultModelIdByFormat:m(l(),l()).optional(),enabledByDefault:v().optional(),defaultConfidence:n(),group:l().optional(),configSchema:S(NDe).readonly().optional()}),FDe=b({id:hW,label:l(),priority:n(),parentSlot:hW.nullable(),addons:S(PDe).readonly()}),IDe=b({availableEngines:S(jDe).readonly(),selectedEngine:gW,slots:S(FDe).readonly()}),LDe=b({runtimeId:x([`onnx`,`openvino`,`coreml`,`edgetpu`]).nullable(),device:l().nullable(),state:x([`idle`,`installing`,`verifying`,`ready`,`failed`]),progress:n().optional(),error:l().optional(),nextRetryAt:n().optional(),configIssues:S(l()).optional()}),yW=b({addonId:l(),chosen:l(),running:l(),format:l()}),bW=b({addonId:l(),kind:x([`unknown-addon`,`no-format-build`,`unknown-device`]),detail:l()}),xW=b({ok:v(),issues:S(bW).readonly(),substitutions:S(yW).readonly(),format:l()}),RDe=b({filename:l(),stepIds:S(l()).readonly().optional()}),zDe=b({base64:l(),filename:l()}),BDe=b({filename:l(),sizeKb:n()}),VDe=b({base64:l()}),HDe=b({id:l(),name:l(),description:l(),available:v(),rawLabels:S(l()).readonly().optional()}),UDe=b({activeBackend:l(),availableBackends:S(HDe).readonly(),sampleRate:n(),chunkDurationMs:n()}),WDe=b({filePath:l(),sizeMB:n(),durationMs:n()}),GDe=b({success:v(),error:l().optional(),frame:ye().optional()}),KDe=ye(),qDe=ye(),JDe=ye(),YDe=ye(),SW={name:`pipeline-executor`,scope:`system`,mode:`singleton`,methods:{getAvailableEngines:k(_(),S(gW)),getSelectedEngine:k(_(),gW),getEngineProvisioning:k(b({nodeId:l()}),LDe),getVideoPipelineSteps:k(_(),m(l(),b({modelId:l(),settings:m(l(),C()).readonly()}))),setVideoPipelineSteps:k(b({steps:m(l(),b({modelId:l(),settings:m(l(),C()).readonly()}))}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getInferenceDeviceHealth:k(b({nodeId:l()}),b({unhealthy:S(b({deviceKey:l(),state:x([`failed`,`backoff`]),since:n(),deaths:n(),lastError:l(),absentReason:x([`no-gpu-device`]).optional()})).readonly()})),rearmInferenceDevice:k(b({nodeId:l(),deviceKey:l()}),b({rearmed:v()}),{kind:`mutation`,auth:`admin`}),getSchema:k(_(),IDe),getOrchestratorConfigSchema:k(_(),KDe),validatePipeline:k(b({steps:S(Ha),deviceKey:l().optional()}),xW),getCapabilities:k(_(),JDe),getAddonModels:k(b({addonId:l()}),YDe),downloadModel:k(b({addonId:l(),modelId:l(),format:mW}),WDe,{kind:`mutation`}),deleteModel:k(b({addonId:l(),modelId:l(),format:mW}),b({success:p(!0)}),{kind:`mutation`}),runPipeline:k(b({steps:S(Ha).min(1),frame:iC.optional(),frameRef:ADe.optional(),frameHandle:Ca.optional(),imageBase64:l().optional(),image:y(Uint8Array).optional(),referenceImage:l().optional(),deviceId:n().optional(),sessionId:l().optional(),plane:x([`full`,`frame`]).optional(),deviceKey:l().optional(),nativeCropRef:pW.optional(),replay:p(!0).optional(),suppliedRoot:fW.optional(),motionRegions:S(dW).optional()}),Ua,{kind:`mutation`}),runPipelineBatch:k(b({steps:S(Ha).min(1),frames:S(iC).min(1).max(255),deviceId:n().optional(),sessionId:l().optional(),frameId:n().int().nonnegative().optional(),deviceKey:l().optional()}),b({results:S(Ua).readonly()}),{kind:`mutation`}),cacheFrameInPool:k(b({data:y(Uint8Array),width:n().int().positive(),height:n().int().positive(),format:x([`rgb`,`bgr`,`gray`])}),b({frameId:n(),width:n(),height:n()}),{kind:`mutation`}),inferCached:k(b({stepId:l(),frameId:n().int(),modelId:l().min(1)}),m(l(),C()),{kind:`mutation`}),uncacheFrame:k(b({frameId:n().int()}),_(),{kind:`mutation`}),getEffectiveTuning:k(b({deviceKey:l().optional()}),_W),listLoadedEngines:k(_(),S(b({engineKey:l(),engine:gW,modelsLoaded:S(l()).readonly(),inUseByCameras:S(n()).readonly(),kind:x([`runtime`,`device-pool`]),poolPid:n().nullable(),idleMs:n().nullable(),idleTtlMs:n().nullable()})).readonly()),spinEngine:k(b({engine:gW}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),killEngine:k(b({engine:gW,force:v().optional()}),b({success:v(),reason:l().optional()}),{kind:`mutation`,auth:`admin`}),listReferenceImages:k(_(),S(RDe).readonly()),getReferenceImage:k(b({filename:l()}),zDe.nullable()),getReferenceAudioFiles:k(_(),S(BDe).readonly()),getReferenceAudio:k(b({filename:l()}),VDe.nullable()),getAudioCapabilities:k(_(),UDe),runAudioTest:k(b({addonId:l(),modelId:l(),filename:l().optional(),settings:m(l(),C()).optional()}),GDe,{kind:`mutation`}),getDetectionConfigSchema:k(_(),qDe)},vocabulary:{notOperatorFacing:j.PIPELINE}},XDe=b({activeCameras:n(),throttledCameras:n(),avgInferenceTimeMs:n(),queueDepth:n()}),CW=b({detectionMode:x([`disabled`,`always-on`,`on-motion`]),configuredFps:n(),actualFps:n(),queueDepth:n(),avgInferenceTimeMs:n(),droppedFrames:n(),nativeCropMisses:n().optional(),phase:x([`idle`,`watching`,`active`])}),wW=CW.extend({deviceId:n()}),TW=x([`polygon`,`tripwire`]),EW=b({x:n(),y:n()}),DW=b({id:l(),name:l(),kind:TW.default(`polygon`),polygon:S(EW).readonly(),color:l().default(`#3b82f6`)}),OW={name:`zones`,scope:`device`,mode:`singleton`,deviceTypes:[T.Camera],methods:{listZones:k(b({deviceId:n()}),S(DW).readonly()),addZone:k(b({deviceId:n(),zone:DW}),_(),{kind:`mutation`,auth:`admin`}),removeZone:k(b({deviceId:n(),zoneId:l()}),_(),{kind:`mutation`,auth:`admin`}),updateZone:k(b({deviceId:n(),zone:DW}),_(),{kind:`mutation`,auth:`admin`})},runtimeState:b({zones:S(DW).readonly()}),durability:`restored`,history:`none`,vocabulary:{noun:P(`Zones`,`Zone`),order:3370}},kW={fpsPerStream:10,budgetMinutes:45,minBudgetMinutes:10,maxBudgetMinutes:120,staleAfterDays:30,settleSec:5,measureSec:20,drainTimeoutSec:120,maxModelsPerDevice:6},AW=x([`device`,`pipeline`]),jW=b({deviceKey:l().min(1),modelIds:S(l().min(1)).min(1).max(kW.maxModelsPerDevice)}),MW=b({nodeId:l().min(1),devices:S(jW).min(1),phases:S(AW).min(1).default([`device`,`pipeline`]),steps:S(l().min(1)).default([]),fpsPerStream:n().int().min(1).max(30).default(kW.fpsPerStream),budgetMinutes:n().int().min(kW.minBudgetMinutes).max(kW.maxBudgetMinutes).default(kW.budgetMinutes),keepDownloadedModels:v().default(!1),acceptInsufficientHeadroom:v().default(!1)}),NW=x([`benchmark-active`,`node-offline`,`unknown-device`,`no-phase`,`insufficient-headroom`]),PW=b({kind:NW,detail:l(),overridable:v()}),FW=b({deviceId:n(),placedOnNode:v(),pinnedToNode:v()}),IW=b({deviceId:n(),reason:p(`only-frame-source`)}),LW=b({nodeId:l(),online:v(),moving:S(FW).readonly(),staying:S(IW).readonly(),estimatedDurationMs:n(),budgetMs:n(),phases:S(AW).readonly(),steps:S(l()).readonly(),devices:S(jW).readonly(),headroom:b({sessionsNow:n(),otherNodesCapacitySessions:n().nullable()}),refusals:S(PW).readonly(),canStart:v()}),RW=b({phase:x([`preparing`,`device`,`pipeline`,`cleanup`]),deviceKey:l().nullable(),modelId:l().nullable(),load:n().nullable(),cellsDone:n(),cellsTotal:n(),message:l()}),zW=x([`p95`,`drops`,`errors`,`stall`,`cpu`,`ram`,`none`]),BW=b({load:n(),pass:v(),p95Ms:n(),dropRatio:n(),fps:n(),cpuPct:n().nullable(),ramFreePct:n().nullable(),failReasons:S(l()).readonly()}),VW=b({phase:p(`device`),deviceKey:l(),modelId:l(),p50Ms:n(),p95Ms:n(),p99Ms:n(),fps:n(),kMax:n(),limitedBy:zW,warmupMs:n(),ramp:S(BW).readonly()}),HW=b({phase:p(`pipeline`),deviceKey:l(),modelId:l(),steps:S(l()).readonly(),maxSessions:n(),limitedBy:zW,stepsFired:S(l()).readonly(),warmupMs:n(),ramp:S(BW).readonly()}),UW=i(`phase`,[VW,HW]),WW=b({pipelineVersion:l().nullable(),cpuModel:l().nullable(),ramGb:n().nullable(),os:l().nullable(),pools:m(l(),b({runtime:l(),numWorkers:n(),concurrency:n(),batchMode:l()})).default({})}),GW=b({id:l(),revision:l().nullable(),frames:n(),width:n(),height:n()}),KW=b({runId:l().min(1),devices:S(jW).min(1),phases:S(AW).min(1),steps:S(l()).default([]),fpsPerStream:n().int().min(1).max(30),deadlineAtMs:n(),settleSec:n().min(0).max(60).default(kW.settleSec),measureSec:n().min(2).max(300).default(kW.measureSec),keepDownloadedModels:v().default(!1)}),qW=x([`running`,`done`,`failed`,`aborted`]),JW=b({runId:l(),nodeId:l(),state:qW,progress:RW.nullable(),cells:S(UW).readonly(),fingerprint:WW.nullable(),clip:GW.nullable(),activeCameraIds:S(n()).readonly(),deletedModels:S(l()).readonly(),error:l().nullable(),startedAtMs:n(),finishedAtMs:n().nullable()}),YW=x([`draining`,`measuring`,`restoring`,`done`,`failed`,`aborted`]),XW=x([`completed`,`operator-abort`,`deadline`,`node-lost`,`runner-lost`,`hub-restart`,`drain-timeout`,`failed`]),ZW=b({runId:l(),nodeId:l(),state:YW,plan:MW,startedAtMs:n(),deadlineAtMs:n(),finishedAtMs:n().nullable(),endReason:XW.nullable(),error:l().nullable(),moved:S(n()).readonly(),staying:S(n()).readonly(),contaminated:v(),progress:RW.nullable(),resultIds:S(l()).readonly()}),QW=b({modeNodeId:l().nullable(),run:ZW.nullable()}),$W=b({id:l(),runId:l(),nodeId:l(),cell:UW,fpsPerStream:n(),fingerprint:WW.nullable(),clip:GW.nullable(),contaminated:v(),stayingCameras:S(n()).readonly(),partialRun:v(),measuredAtMs:n()}),eG=b({nodeId:l().optional(),deviceKey:l().optional()}),tG=$W.extend({standing:x([`fresh`,`stale`,`superseded`]),staleWhy:x([`age`,`runtime`,`pool-tuning`]).nullable()}),ZDe=b({runId:l(),nodeId:l(),startedAtMs:n(),deadlineAtMs:n(),plan:MW,moved:S(n()).readonly(),staying:S(n()).readonly()}),nG=b({nodeId:l(),reachable:v(),devices:S(b({deviceKey:l(),enabled:v(),available:v(),suggested:S(l()).readonly(),all:S(l()).readonly(),currentModelId:l().nullable()})).readonly(),steps:S(b({id:l(),name:l(),slot:l()})).readonly()}),rG=b({x:n(),y:n(),w:n(),h:n()}),iG=b({bytes:y(Uint8Array).optional(),jpeg:l().optional(),jpegBytes:y(Uint8Array).optional(),width:n().int().positive(),height:n().int().positive(),tier:x([`native`,`ram-fullframe`]).optional()}),aG=x([`keyFrame`,`thumbnail`]),oG=x([`handle-gone`,`encode-failed`]),sG=i(`parked`,[b({parked:p(!0),nodeId:l(),width:n().int().positive(),height:n().int().positive(),bytes:n().int().nonnegative(),replaced:v()}),b({parked:p(!1),nodeId:l(),reason:oG,handleAgeMs:n().nullable(),detail:l().optional()})]),cG=b({jpeg:l().optional(),jpegBytes:y(Uint8Array).optional(),width:n().int().positive(),height:n().int().positive(),timestamp:n(),parkedAt:n()}),QDe=b({bbox:rG,className:l()}),lG=b({stepId:l(),className:l(),score:n(),bbox:rG.optional(),embedding:l().optional(),embeddingMagnitude:n().optional(),embeddingModelId:l().optional(),label:l().optional(),labelTier:h([p(1),p(2)]).optional(),labelModelId:l().optional(),alignedCropJpeg:l().optional(),nativeFaceShortSidePx:n().optional(),landmarks:S(b({x:n(),y:n()})).optional()}),$De=x([`unknown-step`,`model-not-servable`,`unreadable-frame`,`execution-failed`,`no-eligible-device`]),eOe=i(`kind`,[b({kind:p(`ran`),nodeId:l(),modelId:l(),details:S(lG)}),b({kind:p(`refused`),nodeId:l(),reason:$De,detail:l()})]),uG={min:0,max:6e4,default:3e4,step:500},dG={min:0,max:6e5,default:12e4,step:5e3},fG={min:5e3,max:6e5,default:9e4,step:5e3},pG={min:1,max:30,default:4,step:1},mG={min:1,max:30,default:10,step:1},hG={min:0,max:300,default:300,step:5},gG={min:1,max:10,default:4,step:1},_G={min:0,max:30,default:12,step:1},vG=x([`onboard`,`analyzer`,`device-activity`]),yG=b({source:vG,triggeredBy:PV,sensorName:l().optional()}),bG=S(vG),xG={analyzer:`Frame-diff Analyzer (motion addon)`,onboard:`Camera sensors`,"device-activity":`Device activity (the device says it is working)`};function tOe(e){let t=vG.safeParse(e);return t.success?xG[t.data]:e}var nOe=[`analyzer`,`onboard`,`device-activity`],SG=f(e=>Array.isArray(e)&&e.length>1?e.slice(0,1):e,S(KH).max(1)),CG=b({deviceId:n(),detected:v(),source:vG.default(`analyzer`),regions:S(YV).readonly().optional()}),wG=i(`kind`,[b({kind:p(`local-broker`)}),b({kind:p(`remote-restream`),ownerNodeId:l(),ownerReachableHost:l().optional(),hubHostnameOverride:l().optional()})]).describe(`Per-camera frame-source mode for the runner (P2c)`),TG=b({modelId:l().optional(),settings:m(l(),C()).optional()}),EG=b({deviceKey:l(),weight:n().positive().default(1),maxSessions:n().int().positive().nullable().default(null),steps:m(l(),TG).optional(),disabledSteps:S(l()).readonly().optional()}),DG=b({deviceId:n(),detectionMode:x([`disabled`,`always-on`,`on-motion`]).default(`on-motion`),audioMode:x([`disabled`,`always-on`,`on-motion`]).default(`always-on`),motionCooldownMs:n().min(uG.min).default(uG.default),maxSessionHoldMs:n().min(dG.min).max(dG.max).optional(),audioMotionWindowMs:n().min(fG.min).max(fG.max).optional(),motionFps:n().min(pG.min).max(pG.max).default(pG.default),detectionFps:n().min(mG.min).max(mG.max).default(mG.default),motionStreamId:l(),detectionStreamId:l(),audioStreamPick:_a.optional(),motionSources:bG.default([`analyzer`]),sessionTrigger:yG.optional(),detectionSources:SG.default([`pipeline`]),pipelineEnabled:v().default(!0),steps:S(Ha).readonly().optional(),audio:b({modelId:l().optional(),enabled:v()}).nullable().optional(),zones:S(DW).readonly().default([]),onboardMotionDrivesAnalyzer:v().default(!0),preRollInferenceEnabled:v().default(!0),preRollInferenceFrames:n().min(_G.min).max(_G.max).default(_G.default),occupancyRecheckEnabled:v().default(!0),occupancyRecheckSec:n().min(hG.min).max(hG.max).default(hG.default),occupancyRecheckFrames:n().min(gG.min).max(gG.max).default(gG.default),frameSource:wG.default({kind:`local-broker`}),deviceKey:l().optional(),inferenceDevices:S(EG).readonly().optional()}),rOe=[{key:`motionSources`,type:`multiselect`,label:`Motion Sources`,default:[`analyzer`],options:nOe.map(e=>e===`onboard`?{value:e,label:xG[e],description:`The camera's own motion, plus any sensor attached to it`}:{value:e,label:xG[e]})},{key:`motionFps`,type:`slider`,label:`Motion FPS (analyzer)`,min:pG.min,max:pG.max,step:pG.step,default:pG.default,showValue:!0,unit:`fps`,nullable:!0,nullLabel:`Default`,showWhen:{field:`motionSources`,includes:`analyzer`}},{key:`detectionFps`,type:`slider`,label:`Detection FPS`,min:mG.min,max:mG.max,step:mG.step,default:mG.default,showValue:!0,unit:`fps`,nullable:!0,nullLabel:`Default`},{key:`motionCooldownMs`,type:`slider`,label:`Motion Cooldown`,description:`Time without a fresh motion event before the active phase ends. Applies to all motion sources — every motion event re-arms the timer.`,min:uG.min,max:uG.max,step:uG.step,default:uG.default,showValue:!0,unit:`s`,displayScale:1e3,nullable:!0,nullLabel:`Default`},{key:`maxSessionHoldMs`,type:`slider`,label:`Max session hold`,description:`Upper bound on how long detection keeps running past the motion cooldown while a subject is still moving in-frame but no longer triggering motion. Prevents the detection box from stopping on a slow-moving subject. Set to 0 to disable.`,min:dG.min,max:dG.max,step:dG.step,default:dG.default,showValue:!0,unit:`s`,displayScale:1e3,nullable:!0,nullLabel:`Default`},{key:`audioMotionWindowMs`,type:`slider`,label:`Audio window after motion`,description:`How long audio keeps being analysed after the last motion event. Each new motion event extends the window without restarting the audio stream.`,min:fG.min,max:fG.max,step:fG.step,default:fG.default,showValue:!0,unit:`s`,displayScale:1e3,nullable:!0,nullLabel:`Default`,showWhen:{field:`audioMode`,equals:`on-motion`}},{key:`onboardMotionDrivesAnalyzer`,type:`boolean`,label:`Run motion analyzer on onboard motion`,description:`When onboard motion is detected, temporarily start the frame-diff analyzer to emit zone results. Stops after the motion cooldown window.`,default:!0,showWhen:{field:`motionSources`,includes:`onboard`}},{key:`preRollInferenceEnabled`,type:`boolean`,style:`checkbox`,label:`Detect in the pre-roll`,description:`Run detection over the few seconds of footage the camera had already buffered when motion fired, so a subject that was in view before the trigger is found at the moment it appeared rather than seconds later. The burst is bounded and never delays live detection.`,default:!0},{key:`preRollInferenceFrames`,type:`slider`,label:`Pre-roll frames`,description:`How many frames of buffered history may be detected on, per session. Higher samples the history more densely; 0 disables the pass.`,min:_G.min,max:_G.max,step:_G.step,default:_G.default,showValue:!0,showWhen:{field:`preRollInferenceEnabled`,equals:!0}},{key:`occupancyRecheckEnabled`,type:`boolean`,style:`checkbox`,label:`Occupancy re-check`,description:`Periodically re-sample a few frames during the watching phase, so objects that are simply parked are still counted (motion gating alone loses them after a restart). On by default at a wide interval; turn it off on cameras where the extra decoder re-dial is expensive.`,default:!0},{key:`occupancyRecheckSec`,type:`slider`,label:`Occupancy re-check interval`,description:`How often (in seconds) the runner re-samples a few frames to confirm the scene is truly empty during the watching phase.`,min:hG.min,max:hG.max,step:hG.step,default:hG.default,showValue:!0,unit:`s`,showWhen:{field:`occupancyRecheckEnabled`,equals:!0}},{key:`occupancyRecheckFrames`,type:`slider`,label:`Occupancy re-check frames`,description:`Number of frames sampled per occupancy re-check burst.`,min:gG.min,max:gG.max,step:gG.step,default:gG.default,showValue:!0,showWhen:{field:`occupancyRecheckEnabled`,equals:!0}}],OG=b({nodeId:l(),attachedCameras:n(),activeCameras:n(),avgInferenceFps:n(),avgInferenceTimeMs:n(),queueDepthTotal:n(),devices:S(b({deviceKey:l(),backend:l(),attachedCameras:n()})).default([]),hardware:b({hasGpu:v(),inferenceBackend:l().optional(),cpuCores:n().optional()}),motionSliceWriter:p(`orchestrator`).optional()}),kG=b({framesDecoded:n(),framesAdmitted:n(),framesDroppedPixelFree:n(),viewsMaterialized:n(),viewsSkipped:n(),workerToRunnerBytes:n(),runnerToPoolRawBytes:n(),runnerToPoolJpegBytes:n(),onDemandFullFrameRequests:n(),onDemandCropRequests:n(),nativeHits:n(),nativeMisses:n(),tileHits:n(),tileMisses:n(),fallbackHits:n(),fallbackMisses:n(),retainedWritesAvoided:n(),residentRefs:n(),residentBytes:n(),releases:n(),evictions:n(),staleMisses:n()}),AG=b({node:kG,cameras:S(kG.extend({deviceId:n()}))}),jG=b({nodeId:l(),activeCameras:n(),throttledCameras:n(),avgInferenceTimeMs:n(),queueDepth:n(),frameLazy:AG.optional()}),MG=x([`not-attached`,`battery-asleep`,`not-watching`,`already-bursting`]),NG={name:`pipeline-runner`,scope:`system`,mode:`singleton`,methods:{attachCamera:k(DG,b({success:p(!0)}),{kind:`mutation`}),detachCamera:k(b({deviceId:n()}),b({success:p(!0)}),{kind:`mutation`}),reportMotion:k(CG,b({success:p(!0)}),{kind:`mutation`}),getLocalLoad:k(_(),OG),getLocalMetrics:k(_(),jG),getCameraMetrics:k(b({deviceId:n()}),CW.nullable()),getAllCameraMetrics:k(_(),S(wW).readonly()),getLocalCameras:k(_(),S(n()).readonly()),requestOccupancyBurst:k(b({deviceId:n(),frames:n().int().positive().optional(),reason:l()}),b({started:v(),refusedBecause:MG.optional()}),{auth:`admin`,kind:`mutation`}),getNativeCrop:k(b({handle:Ca,bbox:rG,maxWidth:n().int().positive().optional(),acceptJpegBytes:v().optional(),encodeJpeg:v().optional()}),iG.nullable()),runDetailSubtree:k(b({deviceId:n(),frameHandle:Ca.optional(),frameJpeg:l().optional(),cropJpeg:l().optional(),parent:QDe,steps:S(l()).optional(),supplied:b({stepId:l(),modelId:l(),boxes:S(b({bbox:rG,score:n()})).min(1)}).optional()}),b({details:S(lG)}).nullable(),{kind:`mutation`}),runStatelessStep:k(b({stepId:l(),modelId:l(),frameJpeg:l(),bbox:rG,className:l(),sourceDeviceId:n()}),eOe,{kind:`mutation`}),parkTrackFrame:k(b({deviceId:n(),trackId:l(),kind:aG,handle:Ca,bbox:rG,maxWidth:n().int().positive().optional(),timestamp:n()}),sG,{kind:`mutation`}),getParkedTrackFrame:k(b({deviceId:n(),trackId:l(),kind:aG,acceptJpegBytes:v().optional()}),cG.nullable()),releaseParkedTrackFrames:k(b({deviceId:n(),trackId:l()}),b({released:n().int().nonnegative()}),{kind:`mutation`}),startNodeBench:k(KW,b({accepted:p(!0),runId:l()}),{kind:`mutation`,auth:`admin`}),getNodeBenchStatus:k(b({runId:l()}),JW.nullable(),{auth:`admin`}),abortNodeBench:k(b({runId:l()}),b({aborted:v()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:j.PIPELINE}},PG=3e4,iOe={version:1,targets:[{id:`detected`,cardinality:`event`,shape:`span`,vocabulary:{cap:`motion`,eventName:`onMotionChanged`},deviceTypes:[T.Camera],apply:`add`,applyAuthority:{kind:`camera-sensors`,timeoutField:`motionCooldownMs`},eventName:`onMotionChanged`,start:`rising-edge`,end:`falling-edge-or-timeout`,timeoutMs:PG,combine:`any`,sourceModes:[`in-addition`,`confirm`,`replace`],sources:[{kind:`binary`},{kind:`switch`}],sourceReport:{status:`assignment-status`},advancedExpression:!1}]},aOe=15e3,FG=b({detected:v(),lastDetectedAt:n().nullable(),autoClearAfterMs:n().nullable().meta(M(`duration-ms`))}),IG=b({deviceId:n(),detected:v(),timestamp:n(),source:vG,regions:S(YV).readonly().optional(),triggeredBy:PV.optional()}),LG={name:`motion`,scope:`device`,mode:`singleton`,deviceNative:!0,deviceTypes:[T.Camera,T.Sensor],methods:{isDetected:k(b({deviceId:n()}),v())},composedMethods:{isDetected:{kind:`slice`,field:`detected`}},events:{onMotionChanged:{data:IG,notOperatorFacing:"the `detected` state trigger phrases both edges, from the mirror that survives a dropped event (D49)"}},status:{schema:FG,kind:`push`},runtimeState:FG,durability:`session`,history:{fields:{detected:{kind:`boolean`,excludeDeviceTypes:[T.Camera]}}},customize:iOe,vocabulary:{noun:P(`Motion`,`Movimento`),order:5130,state:[{kind:`boolean`,field:`detected`,label:P(`Motion`,`Movimento`),whenTrue:P(`When {device} detects motion`,`Quando {device} rileva movimento`),whenFalse:P(`When motion clears on {device}`,`Quando il movimento su {device} cessa`),icon:`activity`}]}},RG=b({enabled:v(),lastChangedAt:n()}),zG=RG.extend({lastFetchedAt:n()}),BG={name:`motion-trigger`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Light,T.Siren,T.Switch],methods:{setMotionTrigger:k(b({deviceId:n().int().nonnegative(),enabled:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`motionTrigger.on`,label:P(`Motion trigger on`,`Attivazione al movimento attiva`),phrase:P(`Let motion trigger {device}`,`Fai attivare {device} dal movimento`),icon:`activity`,effect:{field:`enabled`,value:!0},args:{enabled:!0}},{id:`motionTrigger.off`,label:P(`Motion trigger off`,`Attivazione al movimento spenta`),phrase:P(`Stop motion triggering {device}`,`Non far più attivare {device} dal movimento`),icon:`activity`,effect:{field:`enabled`,value:!1},args:{enabled:!1}}]})},events:{onMotionTriggerChanged:{data:b({deviceId:n(),enabled:v(),lastChangedAt:n()}),notOperatorFacing:"the `enabled` state trigger phrases both edges of this change"}},status:{schema:RG,kind:`command-driven`},runtimeState:zG,durability:`session`,history:`none`,vocabulary:{noun:P(`Motion trigger`,`Attivazione al movimento`),order:1160,state:[{kind:`boolean`,field:`enabled`,label:P(`Motion trigger`,`Attivazione al movimento`),whenTrue:P(`When motion triggering is turned on for {device}`,`Quando si attiva l’attivazione al movimento di {device}`),whenFalse:P(`When motion triggering is turned off for {device}`,`Quando si disattiva l’attivazione al movimento di {device}`),icon:`activity`}]}},VG=b({id:n(),enabled:v(),shape:nH}),HG=b({enabled:v(),sensitivity:n().meta(M(`none`)),regions:S(VG),lastFetchedAt:n()}),UG=b({maxRegions:n(),supportedShapes:S(iH),grid:oH,sensitivity:b({min:n(),max:n(),step:n()})}),WG=b({enabled:v().optional(),sensitivity:n().optional(),regions:S(VG).optional()}),GG={name:`motion-zones`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/motion-zones-grid`,tab:`motion`,label:`Motion Zones`}},methods:{getOptions:k(b({deviceId:n()}),UG),setZone:k(b({deviceId:n(),patch:WG}),_(),{kind:`mutation`,auth:`admin`})},status:{schema:HG,kind:`poll`},runtimeState:HG,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:P(`Motion zones`,`Zone di movimento`),order:3170}},oOe=x([`external`,`embedded`]),sOe=x([`connected`,`disconnected`,`auth-failed`,`unreachable`,`tls-error`]),KG=b({id:l(),name:l(),url:l(),kind:oOe,status:sOe,latencyMs:n().nullable(),error:l().optional(),connectedClients:n().int().nonnegative().optional(),lastCheckedAt:n().optional()}),qG=b({url:l(),username:l().optional(),password:l().optional(),clientIdPrefix:l().optional()}),JG=b({name:l().min(1),url:l().regex(/^(mqtt|mqtts|ws|wss):\/\//,`URL must start with mqtt(s):// or ws(s)://`),username:l().optional(),password:l().optional(),clientIdPrefix:l().optional()}),cOe=b({id:l()}),YG=b({id:l()}),XG=b({port:n().int().min(1).max(65535).default(1883),allowAnonymous:v().default(!1),username:l().optional(),password:l().optional()}),lOe=b({id:l(),url:l()}),ZG=b({brokerCount:n(),embeddedRunning:v()}),QG={name:`mqtt-broker`,scope:`system`,mode:`collection`,providerKind:`broker`,status:{schema:ZG,kind:`poll`},methods:{listBrokers:k(_(),S(KG)),getBrokerConfig:k(YG,qG,{auth:`admin`}),addBroker:k(JG,cOe,{kind:`mutation`,auth:`admin`}),removeBroker:k(YG,_(),{kind:`mutation`,auth:`admin`}),startEmbeddedBroker:k(XG,lOe,{kind:`mutation`,auth:`admin`}),stopEmbeddedBroker:k(YG,_(),{kind:`mutation`,auth:`admin`}),getStatus:k(_(),ZG)},vocabulary:{notOperatorFacing:j.NETWORK}},$G=x([`person`,`vehicle`,`animal`,`face`,`package`,`other`]),eK=b({class:$G,timestamp:n(),confidence:n().min(0).max(1).optional()}),tK=b({lastByClass:d($G,eK.nullable()),supportedClasses:S($G).readonly(),enabled:v()}),nK=x([`boxed`,`while-streaming`,`flag-only`]),rK=b({supportedClasses:S($G).readonly(),geometry:nK}),iK=b({enabled:v().optional()}),aK=tK.extend({lastFetchedAt:n()}),oK={name:`native-object-detection`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Camera],methods:{getOptions:k(b({deviceId:n()}),rK),setSettings:k(b({deviceId:n(),settings:iK}),_(),{kind:`mutation`,auth:`admin`}),setEnabled:k(b({deviceId:n(),enabled:v()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`nativeDetection.on`,label:P(`On-camera detection on`,`Rilevamento a bordo attivo`),phrase:P(`Turn on the on-camera detection of {device}`,`Attiva il rilevamento a bordo di {device}`),icon:`scan-eye`,args:{enabled:!0}},{id:`nativeDetection.off`,label:P(`On-camera detection off`,`Rilevamento a bordo spento`),phrase:P(`Turn off the on-camera detection of {device}`,`Disattiva il rilevamento a bordo di {device}`),icon:`scan-eye`,args:{enabled:!1}}]})},events:{onDetected:{data:b({deviceId:n(),detection:eK}),trigger:{category:w.DetectionCameraNative,label:P(`Camera spotted something`,`La telecamera ha rilevato qualcosa`),phrase:P(`When {device} spots something with its own detector`,`Quando {device} rileva qualcosa con il proprio rilevatore`),icon:`scan-eye`}}},status:{schema:tK,kind:`push`},runtimeState:aK,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:P(`On-camera detection`,`Rilevamento a bordo`),order:3180,state:[{kind:`boolean`,field:`enabled`,label:P(`On-camera detection`,`Rilevamento a bordo`),whenTrue:P(`When the on-camera detection of {device} is turned on`,`Quando si attiva il rilevamento a bordo di {device}`),whenFalse:P(`When the on-camera detection of {device} is turned off`,`Quando si disattiva il rilevamento a bordo di {device}`),icon:`scan-eye`}]}},sK=b({pan:n().min(-1).max(1).optional(),tilt:n().min(-1).max(1).optional(),speed:n().min(0).max(1).optional()}),cK=x([`goHome`,`locate`,`spotClean`,`findPet`,`personFollow`,`stop`,`startClean`,`pauseClean`,`dockWash`,`autoEmpty`,`flashOn`,`flashOff`]),lK=x([`action`,`sound`]),uK=b({id:l(),kind:lK,label:l(),icon:l(),soundId:n().int().optional(),enabled:v()}),uOe=[{id:`startClean`,kind:`action`,label:`Start cleaning`,icon:`play`,enabled:!0},{id:`pauseClean`,kind:`action`,label:`Pause cleaning`,icon:`pause`,enabled:!0},{id:`stop`,kind:`action`,label:`Stop`,icon:`hand`,enabled:!0},{id:`goHome`,kind:`action`,label:`Return to dock`,icon:`home`,enabled:!0},{id:`locate`,kind:`action`,label:`Locate`,icon:`bell`,enabled:!0},{id:`spotClean`,kind:`action`,label:`Spot clean here`,icon:`crosshair`,enabled:!0},{id:`findPet`,kind:`action`,label:`Find pet`,icon:`paw-print`,enabled:!0},{id:`personFollow`,kind:`action`,label:`Follow me`,icon:`footprints`,enabled:!0},{id:`dockWash`,kind:`action`,label:`Wash mop`,icon:`droplets`,enabled:!0},{id:`autoEmpty`,kind:`action`,label:`Empty dustbin`,icon:`trash-2`,enabled:!0},{id:`flashOn`,kind:`action`,label:`Flash on`,icon:`flashlight`,enabled:!0},{id:`flashOff`,kind:`action`,label:`Flash off`,icon:`flashlight-off`,enabled:!0},{id:`sound:meow`,kind:`sound`,label:`Meow`,icon:`cat`,soundId:684,enabled:!0},{id:`sound:bark`,kind:`sound`,label:`Woof`,icon:`dog`,soundId:685,enabled:!0},{id:`sound:footsteps`,kind:`sound`,label:`Footsteps`,icon:`footprints`,soundId:686,enabled:!0},{id:`sound:purring`,kind:`sound`,label:`Purring`,icon:`cat`,soundId:687,enabled:!0},{id:`sound:tickTock`,kind:`sound`,label:`Tick-tock`,icon:`clock`,soundId:688,enabled:!0}],dK=b({x:n(),y:n()}),fK=b({move:v(),stop:v(),goToPoint:v(),runAction:v(),playSound:v(),light:v(),lightMode:v()}),pK=x([`auto`,`manual`]),dOe=40,fOe=100,mK=x([`idle`,`cleaning`,`spot`,`following`,`goto`,`returning`,`paused`,`unknown`]),hK=b({mode:mK,following:v(),flash:v(),lightMode:pK,lightLevel:n().min(40).max(100).meta(M(`none`)),lastChangedAt:n()}),gK=hK.extend({lastFetchedAt:n()}),_K={name:`navigation`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/navigation-panel`,tab:`navigation`,topTab:!0,label:`Navigation`,order:0}},methods:{move:k(sK.extend({deviceId:n()}),_(),{kind:`mutation`,notOperatorFacing:`joystick control from the live view — continuous, not a discrete step`}),stop:k(b({deviceId:n()}),_(),{kind:`mutation`,actions:[{id:`navigation.stop`,label:P(`Stop`,`Ferma`),phrase:P(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),goToPoint:k(dK.extend({deviceId:n()}),_(),{kind:`mutation`,notOperatorFacing:`tap-to-go on the live map — the point only means something on that picture`}),listActions:k(b({deviceId:n()}),S(uK)),runAction:k(b({deviceId:n(),actionId:cK}),_(),{kind:`mutation`,actions:[{id:`navigation.runAction`,label:P(`Run a routine`,`Esegui una routine`),phrase:P(`Have {device} {actionId}`,`Fai eseguire a {device}: {actionId}`),icon:`bot`,openArgs:[{key:`actionId`,label:P(`Routine`,`Routine`),offer:{kind:`enum`,values:[{value:`goHome`,label:P(`go home`,`torna alla base`)},{value:`locate`,label:P(`beep so you can find it`,`suona per farsi trovare`)},{value:`spotClean`,label:P(`clean this spot`,`pulisci questo punto`)},{value:`findPet`,label:P(`find the pet`,`cerca l’animale`)},{value:`personFollow`,label:P(`follow a person`,`segui una persona`)},{value:`stop`,label:P(`stop`,`fermati`)},{value:`startClean`,label:P(`start cleaning`,`inizia a pulire`)},{value:`pauseClean`,label:P(`pause cleaning`,`metti in pausa la pulizia`)},{value:`dockWash`,label:P(`wash the mop at the dock`,`lava il mocio alla base`)},{value:`autoEmpty`,label:P(`empty the bin at the dock`,`svuota il contenitore alla base`)},{value:`flashOn`,label:P(`turn the flash on`,`accendi il flash`)},{value:`flashOff`,label:P(`turn the flash off`,`spegni il flash`)}]}}]}]}),playSound:k(b({deviceId:n(),soundId:n().int()}),_(),{kind:`mutation`,actions:[{id:`navigation.playSound`,label:P(`Play sound`,`Riproduci un suono`),phrase:P(`Play {soundId} on {device}`,`Riproduci {soundId} su {device}`),icon:`volume-2`,openArgs:[{key:`soundId`,label:P(`Sound`,`Suono`),offer:{kind:`dynamic`,from:`method`,method:`listActions`,valueKey:`soundId`,labelKey:`label`,where:{key:`kind`,equals:`sound`},valueKind:`number`}}]}]}),setLightOn:k(b({deviceId:n(),on:v()}),_(),{kind:`mutation`,actions:[{id:`navigation.lightOn`,label:P(`Light on`,`Luce accesa`),phrase:P(`Turn on the light of {device}`,`Accendi la luce di {device}`),icon:`lightbulb`,args:{on:!0}},{id:`navigation.lightOff`,label:P(`Light off`,`Luce spenta`),phrase:P(`Turn off the light of {device}`,`Spegni la luce di {device}`),icon:`lightbulb-off`,args:{on:!1}}]}),setLightMode:k(b({deviceId:n(),mode:pK,level:n().min(40).max(100).optional()}),_(),{kind:`mutation`,actions:[{id:`navigation.lightAuto`,label:P(`Light automatic`,`Luce automatica`),phrase:P(`Set the light of {device} to automatic`,`Metti la luce di {device} in automatico`),icon:`lightbulb`,args:{mode:`auto`}}]}),setLightLevel:k(b({deviceId:n(),level:n().min(40).max(100)}),_(),{kind:`mutation`,actions:[{id:`navigation.lightLevel`,label:P(`Set light level`,`Imposta la luce`),phrase:P(`Set the light of {device} to {level}`,`Imposta la luce di {device} al {level}`),icon:`sun-medium`,openArgs:[{key:`level`,label:P(`Level`,`Livello`),offer:{kind:`number`,min:40,max:100,step:1,unit:`%`}}]}]}),getFeatures:k(b({deviceId:n()}),fK)},events:{onStatusChanged:{data:b({deviceId:n(),status:hK}),notOperatorFacing:"the `mode` state trigger reads the same change"}},status:{schema:hK,kind:`push`},runtimeState:gK,durability:`session`,history:`none`,vocabulary:{noun:P(`Robot movement`,`Movimento del robot`),order:2080,state:[{kind:`enum`,field:`mode`,label:P(`Activity`,`Attività`),values:[{value:`idle`,label:P(`Idle`,`Inattivo`)},{value:`cleaning`,label:P(`Cleaning`,`In pulizia`)},{value:`spot`,label:P(`Spot cleaning`,`Pulizia localizzata`)},{value:`following`,label:P(`Following`,`In inseguimento`)},{value:`goto`,label:P(`Moving to a point`,`In movimento verso un punto`)},{value:`returning`,label:P(`Returning`,`In rientro`)},{value:`paused`,label:P(`Paused`,`In pausa`)},{value:`unknown`,label:P(`Unknown`,`Sconosciuto`)}],icon:`bot`}]}},vK=b({url:l(),hostname:l(),port:n(),protocol:x([`http`,`https`]),stable:v().optional()}),pOe=b({url:l(),stable:v().optional(),updated:v().optional()}),yK=b({connected:v(),endpoint:vK.nullable(),error:l().optional()}),mOe=vK.extend({id:l(),label:l(),mode:l().optional(),sourcePort:n().optional()}),bK={name:`network-access`,scope:`system`,mode:`collection`,providerKind:`ingress`,methods:{start:k(_(),vK,{kind:`mutation`}),stop:k(_(),_(),{kind:`mutation`}),getEndpoint:k(_(),vK.nullable()),getStatus:k(_(),yK),listEndpoints:k(_(),S(mOe).readonly())},vocabulary:{notOperatorFacing:j.NETWORK}},xK=[`wifi`,`ethernet`,`cellular`,`unknown`],SK=b({type:x(xK),signal:n().min(0).max(100).nullable().meta(M(`percentage`)),rssi:n().optional().meta(M(`signal-level`)),ssid:l().optional(),speedKbps:n().nonnegative().nullable().optional().meta(M(`bitrate`)),linkUp:v().nullable().optional(),lastUpdated:n().meta(M(`none`))}),CK={type:`unknown`,signal:null,lastUpdated:0};function hOe(e,t){return e===void 0||!Number.isFinite(e)||t<=0||e<0||e>t?null:Math.round(e/t*100)}function gOe(e){return e===void 0||!Number.isFinite(e)||e>0?null:Math.round((Math.min(-50,Math.max(-100,e))+100)*2)}var wK={name:`network-link`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Camera,T.Sensor,T.Button,T.Switch,T.Light,T.Lock,T.Siren],methods:{},events:{onStatusChanged:{data:b({deviceId:n(),status:SK}),notOperatorFacing:`the signal / link-type state triggers each read one field of this change`}},status:{schema:SK,kind:`push`,empty:CK},runtimeState:SK,durability:`restored`,history:{fields:{signal:{kind:`gauge`,unit:`%`,deadband:3,minIntervalMs:6e4},rssi:{kind:`gauge`,unit:`dBm`,deadband:2,minIntervalMs:6e4}}},volatileStateFields:[`lastUpdated`],vocabulary:{noun:P(`Network link`,`Collegamento di rete`),order:5250,state:[{kind:`numeric`,field:`signal`,quantity:P(`the signal strength`,`l’intensità del segnale`),label:P(`Signal`,`Segnale`),unit:`%`,icon:`wifi`},{kind:`enum`,field:`type`,label:P(`Link type`,`Tipo di collegamento`),values:[{value:`wifi`,label:P(`Wi-Fi`,`Wi-Fi`)},{value:`ethernet`,label:P(`Ethernet`,`Ethernet`)},{value:`cellular`,label:P(`Cellular`,`Rete mobile`)},{value:`unknown`,label:P(`Unknown`,`Sconosciuto`)}],icon:`network`}]}},TK=b({nominalBitrateKbps:n(),observedBitrateKbps:n(),peakBitrateKbps:n(),packetLossPercent:n(),lastUpdated:n()}),EK=b({rttMs:n(),jitterMs:n(),estimatedBandwidthKbps:n(),packetLossPercent:n().min(0).max(100),downlinkMbps:n().optional(),downlinkAgeMs:n().optional(),lastUpdated:n()}),DK=b({deviceId:n(),streams:m(l(),TK),client:EK.optional()}),OK={name:`network-quality`,scope:`system`,mode:`singleton`,methods:{getDeviceStats:k(b({deviceId:n()}),DK.nullable()),getAllStats:k(_(),S(DK).readonly()),reportClientStats:k(b({deviceId:n(),rttMs:n().min(0).max(6e4),jitterMs:n().min(0).max(1e4),estimatedBandwidthKbps:n().min(0).max(1e6),packetLossPercent:n().min(0).max(100),downlinkMbps:n().min(0).max(1e5).optional(),downlinkAgeMs:n().min(0).max(864e5).optional()}),_(),{role:`viewer`,kind:`mutation`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:j.NETWORK}},kK=b({cn:l(),serial:l(),fingerprintSha256:l(),notBefore:n(),notAfter:n()}),AK=b({fingerprintSha256:l(),issuer:l(),sans:S(l()),notBefore:n(),notAfter:n()}),jK=i(`state`,[b({state:p(`served`),leaf:AK}),b({state:p(`not-issued`),reason:l()})]),MK={name:`node-certificates`,scope:`system`,mode:`singleton`,internal:!0,methods:{getCertificates:k(b({}),b({nodeId:l(),mesh:kK.nullable(),https:jK}),{auth:`admin`}),prepareMeshRenewal:k(b({}),b({csrPem:l()}),{kind:`mutation`,auth:`admin`}),installMeshLeaf:k(b({certPem:l().min(1),caCertPem:l().min(1),confirmWithinMs:n().int().min(1e4).max(6e5)}),b({fingerprintSha256:l(),serial:l()}),{kind:`mutation`,auth:`admin`}),confirmMeshLeaf:k(b({fingerprintSha256:l()}),b({confirmed:v()}),{kind:`mutation`,auth:`admin`}),rollbackMeshLeaf:k(b({}),b({rolledBack:v()}),{kind:`mutation`,auth:`admin`}),prepareHttpsCertificate:k(b({}),b({csrPem:l(),hostnames:S(l()),addresses:S(l()),pinnedCaFingerprintSha256:l().nullable()}),{kind:`mutation`,auth:`admin`}),forgetHub:k(b({}),b({ok:p(!0)}),{kind:`mutation`,auth:`admin`}),installHttpsCertificate:k(b({certPem:l().min(1),caCertPem:l().min(1),caRotation:v().optional()}),AK,{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:j.IDENTITY}},NK=b({nodeId:l().min(1),removedAt:n()}),PK=b({counts:m(l(),n().int().nonnegative())}),FK={name:`node-removal-hook`,scope:`system`,mode:`collection`,internal:!0,methods:{onNodeRemoved:k(NK,PK,{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:j.INTERNAL}},IK=b({addonId:l(),capabilities:S(l()).readonly(),status:l()}),LK=b({pid:n(),name:l(),state:l(),cpuPercent:n(),memoryRss:n(),uptimeSeconds:n(),services:S(IK).readonly(),groupId:l().optional()}),_Oe=b({id:l(),status:l(),cpuPercent:n(),memoryRss:n()}),vOe=b({category:l(),total:n(),healthy:n(),addons:S(_Oe).readonly()}),yOe=b({name:l(),version:l()}),RK=b({id:l(),name:l(),hostname:l(),platform:l(),arch:l(),cpuModel:l().nullable(),cpuCores:n(),memoryMB:n(),engines:S(l()).readonly(),isHub:v(),isOnline:v(),cpuPercent:n(),memoryPercent:n().nullable(),uptime:n(),lastSeen:l(),localIps:S(l()).readonly(),addons:S(b({id:l(),capabilities:S(l()).readonly(),status:l()})).readonly(),processes:S(LK).readonly(),categories:S(vOe).readonly(),rootPackage:yOe.nullable(),meshTransport:x([`tls`,`clear`]).optional(),capabilitiesRegistered:v().optional()}),bOe=b({callerAddonId:l(),providerAddonId:l(),capName:l(),callsPerMin:n(),lastCallAtMs:n()}),zK=b({nodeId:l(),name:l(),version:l(),status:l(),synced:v()}),BK=b({hubVersion:l(),nodes:S(zK)}),VK=b({nodeId:l(),addonId:l()}),xOe=b({id:l(),status:l(),version:l().optional(),packageName:l().optional()}),HK=b({success:v()}),SOe=b({success:v(),reason:l().optional()}),COe=b({restarted:S(l()).readonly(),failed:S(l()).readonly()}),wOe=b({nodeId:l(),name:l()}),UK=b({id:l(),name:l(),isHub:v(),isOnline:v()}),WK=b({nodes:S(UK).readonly(),complete:v()}),GK={name:`nodes`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,methods:{topology:k(_(),S(RK).readonly(),{auth:`admin`}),directory:k(_(),WK,{auth:`admin`}),deployAddon:k(VK,HK,{kind:`mutation`,auth:`admin`}),undeployAddon:k(VK,HK,{kind:`mutation`,auth:`admin`}),restartAddon:k(VK,HK,{kind:`mutation`,auth:`admin`}),restartProcess:k(b({nodeId:l(),processName:l()}),SOe,{kind:`mutation`,auth:`admin`}),restartNode:k(b({nodeId:l()}),COe,{kind:`mutation`,auth:`admin`}),shutdownNode:k(b({nodeId:l()}),HK,{kind:`mutation`,auth:`admin`}),renameNode:k(b({nodeId:l(),name:l().min(1).max(64)}),wOe,{kind:`mutation`,auth:`admin`}),clusterAddonStatus:k(_(),m(l(),BK),{auth:`admin`}),getCapUsageGraph:k(b({windowSeconds:n().int().positive().max(300).default(60)}),S(bOe).readonly(),{auth:`admin`}),getNodeAddons:k(b({nodeId:l()}),S(xOe).readonly(),{auth:`admin`}),setProcessLogLevel:k(b({nodeId:l(),level:l()}),HK,{kind:`mutation`,auth:`admin`}),executeQuery:k(b({nodeId:l(),addonId:l(),queryName:l(),params:m(l(),C()).optional()}),C(),{kind:`mutation`,auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:j.CLUSTER}},KK=[{id:`speech`,name:`Speech`},{id:`scream`,name:`Scream / Shout`},{id:`crying`,name:`Crying / Baby`},{id:`laughter`,name:`Laughter`},{id:`music`,name:`Music`},{id:`dog`,name:`Dog`},{id:`cat`,name:`Cat`},{id:`bird`,name:`Bird`},{id:`animal`,name:`Animal (other)`},{id:`alarm`,name:`Alarm / Siren`},{id:`doorbell`,name:`Doorbell / Knock`},{id:`glass_breaking`,name:`Glass Breaking`},{id:`gunshot`,name:`Gunshot / Explosion`},{id:`vehicle`,name:`Vehicle`},{id:`siren`,name:`Emergency Siren`},{id:`fire`,name:`Fire / Smoke`},{id:`water`,name:`Water`},{id:`wind`,name:`Wind / Weather`},{id:`door`,name:`Door`},{id:`footsteps`,name:`Footsteps`},{id:`crowd`,name:`Crowd / Chatter`},{id:`telephone`,name:`Telephone`},{id:`engine`,name:`Engine / Motor`},{id:`tools`,name:`Tools / Construction`},{id:`silence`,name:`Silence`}],qK={mapping:{Speech:`speech`,"Child speech, kid speaking":`speech`,Conversation:`speech`,"Narration, monologue":`speech`,Babbling:`speech`,Whispering:`speech`,"Speech synthesizer":`speech`,Humming:`speech`,Rapping:`speech`,Singing:`speech`,Choir:`speech`,"Child singing":`speech`,Shout:`scream`,Bellow:`scream`,Yell:`scream`,Screaming:`scream`,"Children shouting":`scream`,Whoop:`scream`,"Crying, sobbing":`crying`,"Baby cry, infant cry":`crying`,Whimper:`crying`,"Wail, moan":`crying`,Groan:`crying`,Laughter:`laughter`,"Baby laughter":`laughter`,Giggle:`laughter`,Snicker:`laughter`,"Belly laugh":`laughter`,"Chuckle, chortle":`laughter`,Music:`music`,"Musical instrument":`music`,Guitar:`music`,Piano:`music`,Drum:`music`,"Drum kit":`music`,"Violin, fiddle":`music`,Flute:`music`,Saxophone:`music`,Trumpet:`music`,Synthesizer:`music`,"Pop music":`music`,"Rock music":`music`,"Hip hop music":`music`,"Classical music":`music`,Jazz:`music`,"Electronic music":`music`,"Background music":`music`,Dog:`dog`,Bark:`dog`,Yip:`dog`,Howl:`dog`,"Bow-wow":`dog`,Growling:`dog`,"Whimper (dog)":`dog`,Cat:`cat`,Purr:`cat`,Meow:`cat`,Hiss:`cat`,Caterwaul:`cat`,Bird:`bird`,"Bird vocalization, bird call, bird song":`bird`,"Chirp, tweet":`bird`,Squawk:`bird`,Crow:`bird`,Owl:`bird`,"Pigeon, dove":`bird`,Animal:`animal`,"Domestic animals, pets":`animal`,"Livestock, farm animals, working animals":`animal`,Horse:`animal`,"Cattle, bovinae":`animal`,Pig:`animal`,Sheep:`animal`,Goat:`animal`,Frog:`animal`,Insect:`animal`,Cricket:`animal`,Alarm:`alarm`,"Alarm clock":`alarm`,"Smoke detector, smoke alarm":`alarm`,"Fire alarm":`alarm`,Buzzer:`alarm`,"Civil defense siren":`alarm`,"Car alarm":`alarm`,Siren:`siren`,"Police car (siren)":`siren`,"Ambulance (siren)":`siren`,"Fire engine, fire truck (siren)":`siren`,"Emergency vehicle":`siren`,Foghorn:`siren`,Doorbell:`doorbell`,"Ding-dong":`doorbell`,Knock:`doorbell`,Tap:`doorbell`,Glass:`glass_breaking`,Shatter:`glass_breaking`,"Chink, clink":`glass_breaking`,"Gunshot, gunfire":`gunshot`,"Machine gun":`gunshot`,Explosion:`gunshot`,Fireworks:`gunshot`,Firecracker:`gunshot`,"Artillery fire":`gunshot`,"Cap gun":`gunshot`,Boom:`gunshot`,Vehicle:`vehicle`,Car:`vehicle`,Truck:`vehicle`,Bus:`vehicle`,Motorcycle:`vehicle`,"Car passing by":`vehicle`,"Vehicle horn, car horn, honking":`vehicle`,"Traffic noise, roadway noise":`vehicle`,Train:`vehicle`,Aircraft:`vehicle`,Helicopter:`vehicle`,Bicycle:`vehicle`,Skateboard:`vehicle`,Fire:`fire`,Crackle:`fire`,Water:`water`,Rain:`water`,Raindrop:`water`,"Rain on surface":`water`,Stream:`water`,Waterfall:`water`,Ocean:`water`,"Waves, surf":`water`,"Splash, splatter":`water`,Wind:`wind`,Thunderstorm:`wind`,Thunder:`wind`,"Wind noise (microphone)":`wind`,"Rustling leaves":`wind`,Door:`door`,"Sliding door":`door`,Slam:`door`,"Cupboard open or close":`door`,"Walk, footsteps":`footsteps`,Run:`footsteps`,Shuffle:`footsteps`,Crowd:`crowd`,Chatter:`crowd`,Cheering:`crowd`,Applause:`crowd`,"Children playing":`crowd`,"Hubbub, speech noise, speech babble":`crowd`,Telephone:`telephone`,"Telephone bell ringing":`telephone`,Ringtone:`telephone`,"Telephone dialing, DTMF":`telephone`,"Busy signal":`telephone`,Engine:`engine`,"Engine starting":`engine`,Idling:`engine`,"Accelerating, revving, vroom":`engine`,"Light engine (high frequency)":`engine`,"Medium engine (mid frequency)":`engine`,"Heavy engine (low frequency)":`engine`,"Lawn mower":`engine`,Chainsaw:`engine`,Hammer:`tools`,Jackhammer:`tools`,Sawing:`tools`,"Power tool":`tools`,Drill:`tools`,Sanding:`tools`,Silence:`silence`},preserveOriginal:!1},JK={mapping:{speech:`speech`,child_speech:`speech`,conversation:`speech`,whispering:`speech`,singing:`speech`,humming:`speech`,shout:`scream`,yell:`scream`,screaming:`scream`,crying:`crying`,baby_crying:`crying`,sobbing:`crying`,laughter:`laughter`,baby_laughter:`laughter`,giggling:`laughter`,music:`music`,guitar:`music`,piano:`music`,drums:`music`,dog_bark:`dog`,dog_bow_wow:`dog`,dog_growling:`dog`,dog_howl:`dog`,cat_meow:`cat`,cat_purr:`cat`,cat_hiss:`cat`,bird:`bird`,bird_chirp:`bird`,bird_squawk:`bird`,animal:`animal`,horse:`animal`,cow_moo:`animal`,insect:`animal`,alarm:`alarm`,smoke_alarm:`alarm`,fire_alarm:`alarm`,car_alarm:`alarm`,siren:`siren`,police_siren:`siren`,ambulance_siren:`siren`,doorbell:`doorbell`,door_knock:`doorbell`,knocking:`doorbell`,glass_breaking:`glass_breaking`,glass_shatter:`glass_breaking`,gunshot:`gunshot`,explosion:`gunshot`,fireworks:`gunshot`,car:`vehicle`,truck:`vehicle`,motorcycle:`vehicle`,car_horn:`vehicle`,vehicle_horn:`vehicle`,traffic:`vehicle`,fire:`fire`,fire_crackle:`fire`,water:`water`,rain:`water`,ocean:`water`,splash:`water`,wind:`wind`,thunder:`wind`,thunderstorm:`wind`,door:`door`,door_slam:`door`,sliding_door:`door`,footsteps:`footsteps`,walking:`footsteps`,running:`footsteps`,crowd:`crowd`,chatter:`crowd`,cheering:`crowd`,applause:`crowd`,telephone_ring:`telephone`,ringtone:`telephone`,engine:`engine`,engine_starting:`engine`,lawn_mower:`engine`,chainsaw:`engine`,hammer:`tools`,jackhammer:`tools`,drill:`tools`,power_tool:`tools`,silence:`silence`},preserveOriginal:!1},YK=new Map;for(let[e,t]of Object.entries(qK.mapping))YK.set(e.toLowerCase(),t);for(let[e,t]of Object.entries(JK.mapping))YK.set(e.toLowerCase(),t);function TOe(e){return YK.get(e.toLowerCase())??null}function EOe(){return KK.map(e=>e.id)}var XK=vP();function ZK(e){return CP(XK.swatches,XK.fallbacks,e)}function DOe(e){let t=e[0];if(t===void 0)throw Error(`display palette has no fallback colour`);return t}var OOe=DOe(XK.fallbacks);function kOe(e){return e.split(/[-_ ]/).filter(e=>e.length>0).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}var QK=new Map;function $K(e,t,n,r){QK.set(e,{kind:e,parentKind:null,level:`macro`,category:t,color:ZK(e),iconId:n,labelKey:`eventKind.${e}`,label:r})}function eq(e,t,n,r,i){QK.set(e,{kind:e,parentKind:t,level:`sub`,category:n,color:ZK(e),iconId:r,labelKey:`eventKind.${e}`,label:i})}$K(`motion`,`motion`,`motion`,`Motion`),$K(`audio`,`audio`,`audio`,`Audio`),$K(`person`,`detection`,`person`,`Person`),$K(`vehicle`,`detection`,`vehicle`,`Vehicle`),$K(`animal`,`detection`,`animal`,`Animal`),$K(`package`,`package`,`package`,`Package`),$K(`sensor`,`sensor`,`sensor`,`Sensor`),$K(`control`,`control`,`control`,`Control`);for(let[e,t]of Object.entries(n_.mapping))t!==`vehicle`&&t!==`animal`||QK.has(e)||eq(e,t,`detection`,e,kOe(e));eq(`package-delivered`,`package`,`package`,`package`,`Package delivered`),eq(`package-picked-up`,`package`,`package`,`package`,`Package picked up`),eq(`contact`,`sensor`,`sensor`,`door`,`Contact`),eq(`motion-sensor`,`sensor`,`sensor`,`pir`,`Motion sensor`),eq(`smoke`,`sensor`,`sensor`,`smoke`,`Smoke`),eq(`flood`,`sensor`,`sensor`,`water`,`Water leak`),eq(`gas`,`sensor`,`sensor`,`gas`,`Gas`),eq(`carbon-monoxide`,`sensor`,`sensor`,`smoke`,`Carbon monoxide`),eq(`vibration`,`sensor`,`sensor`,`vibration`,`Vibration`),eq(`tamper`,`sensor`,`sensor`,`tamper`,`Tamper`),eq(`presence`,`sensor`,`sensor`,`presence`,`Presence`),eq(`enum-sensor`,`sensor`,`sensor`,`generic`,`Sensor state`),eq(`device-event`,`sensor`,`sensor`,`button`,`Device event`),eq(`lock`,`control`,`control`,`lock`,`Lock`),eq(`cover`,`control`,`control`,`door`,`Cover`),eq(`switch`,`control`,`control`,`switch`,`Switch`),eq(`siren`,`control`,`control`,`siren`,`Siren`),eq(`button`,`control`,`control`,`button`,`Button`),eq(`doorbell`,`control`,`control`,`doorbell`,`Doorbell`),eq(`appliance-cycle`,`control`,`control`,`switch`,`Appliance cycle`);for(let e of KK){let t=`audio-${e.id}`;QK.has(t)||eq(t,`audio`,`audio`,t,e.name)}var tq=Object.freeze(Object.fromEntries(QK));function nq(e){return tq[e]}function AOe(e){return ZK(e)}function jOe(e){let t=[];for(let n of Object.values(tq))n.parentKind===e&&t.push(n);return t}var rq=b({kind:l(),label:l(),parentKind:l().nullable()}),iq=b({videoClasses:S(rq),audioKinds:S(rq),labels:S(rq)});function aq(e,t,n){return{kind:e,label:t,parentKind:n}}function oq(){let e=Object.values(tq);return{videoClasses:e.filter(e=>e.category===`detection`).map(e=>aq(e.kind,e.label,e.parentKind)),audioKinds:e.filter(e=>e.category===`audio`&&e.level===`sub`).map(e=>aq(e.kind,e.label,e.parentKind)),labels:e.filter(e=>e.category===`sensor`||e.category===`control`).map(e=>aq(e.kind,e.label,e.parentKind))}}var MOe=Object.freeze(oq()),sq=x([`immediate`,`track-end`,`device-event`,`package-event`,`system-event`]),cq=x(`device-online.device-offline.device-disabled.device-enabled.device-battery-low.device-battery-normal.device-consumable-low.device-consumable-normal.stream-online.stream-offline.node-online.node-offline.node-restarting.node-updating.node-inference-unavailable.detection-blind.motion-noisy.motion-calm.package-llm-silent.package-llm-answered.recording-stalled.recording-healthy.recording-degraded.device-attention-required.device-attention-resolved.device-command.storage-location-low.storage-location-critical.storage-location-ok.storage-drain-progress.storage-drain-complete.addon-crash-loop.addon-update-available.server-update-available.wrapper-update-available.alarm-triggered.alarm-armed.alarm-disarmed.alarm-arming.alarm-arm-refused.alarm-pending.alarm-rearmed.alarm-sensor-bypass.alarm-check-failed.addon-updated.server-updated.export-completed.backup-completed.alert-critical.alert-error.alert-critical-resolved.rule-broken.rule-repaired.camera-online.camera-offline.camera-disabled.camera-enabled`.split(`.`)),lq=[`camera-online`,`camera-offline`,`camera-disabled`,`camera-enabled`],NOe=new Set(lq),POe=cq.options.filter(e=>!NOe.has(e)),uq=[`alarm-arm-refused`,`alarm-check-failed`,`alarm-arming`,`alarm-armed`,`alarm-pending`,`alarm-triggered`,`alarm-rearmed`,`alarm-sensor-bypass`,`alarm-disarmed`],FOe=[`device-battery-low`,`device-battery-normal`,`device-consumable-low`,`device-consumable-normal`],dq=[`device-consumable-low`,`device-consumable-normal`],IOe=15,LOe=95,fq=[`confirmed`,`already`,`unconfirmed`,`failed`],pq=[`user`,`addon`,`action`,`scheduler`,`composition`,`node`],mq=b({kinds:S(cq).min(1),deviceIds:S(n().int()).min(1).optional(),deviceTypes:S(l().min(1)).min(1).optional(),excludeDeviceIds:S(n().int()).min(1).optional(),nodeIds:S(l().min(1)).min(1).optional(),packageNames:S(l().min(1)).min(1).optional(),commandActions:S(l().min(1)).min(1).optional(),commandOutcomes:S(x(fq)).min(1).optional(),commandActorKinds:S(x(pq)).min(1).optional(),consumableLowPercent:n().int().min(1).max(95).optional()});function ROe(e){return e.consumableLowPercent??15}var zOe=1,hq=1440,BOe=[10,30,60],gq=b({days:S(n().int().min(0).max(6)).min(1),startMinute:n().int().min(0).max(1439),endMinute:n().int().min(0).max(1439)}),_q=b({windows:S(gq).min(1),timezone:l().optional(),invert:v().optional()}),vq=x([`instant`,`summary`]),VOe=x([`activation`,`deactivation`,`schedule`]),yq=x([`rule`,`section`]),bq=i(`mode`,[b({mode:p(`instant`)}),b({mode:p(`summary`),schedule:_q,split:yq.optional()}),b({mode:p(`modes`),onActivation:v(),onDeactivation:v(),onSchedule:b({schedule:_q,grouping:yq}).optional()})]),xq=b({values:S(l().min(1)),maxDistance:n().int().min(0).max(3).default(1)}),Sq=b({zoneId:l().optional(),className:l().optional(),op:x([`became-occupied`,`became-free`,`>=`,`<=`]).default(`became-occupied`),count:n().int().min(0).default(1),sustainSeconds:n().int().min(0).max(3600).default(15)}),HOe=-96,Cq=b({labels:S(l().min(1)).min(1).optional(),dbThreshold:n().min(-96).max(0).optional(),hitPercent:n().int().min(1).max(100).default(60),samplingSeconds:n().int().min(1).max(300).default(10),confirmHits:n().int().min(1).max(20).optional(),confirmWindowSec:n().int().min(1).max(60).optional()}),wq=x([`enter`,`exit`,`any`]),Tq=x([`raised`,`cleared`]),Eq=b({ids:S(l().min(1)).min(1),match:x([`any`,`all`]).optional()}),Dq=l().min(1),Oq=S(Dq).max(4),kq=b({id:l().min(1).max(64),label:l().min(1).max(40),actionId:Dq,icon:Yu.optional(),destructive:v().optional()}),Aq=b({onActivation:Oq.optional(),onDeactivation:Oq.optional(),onTrigger:Oq.optional(),onTriggerOff:Oq.optional(),buttons:S(kq).max(8).optional()}),jq=b({deviceId:n().int(),states:S(l().min(1)).min(1)}),Mq=b({sceneId:l().min(1),deviceId:n().int().optional(),requiredState:x([`matched`,`diverged`]),latched:v().optional()}),Nq=b({deviceState:jq.optional(),scene:Mq.optional(),devices:S(n()).optional(),devicesExclude:S(n()).min(1).optional(),classes:S(l().min(1)).optional(),classesExclude:S(l().min(1)).optional(),minConfidence:n().min(0).max(1).optional(),zones:Eq.optional(),zonesExclude:S(l().min(1)).optional(),crossing:wq.optional(),labelEquals:S(l().min(1)).optional(),identities:S(l().min(1)).optional(),plates:xq.optional(),identitiesExclude:S(l().min(1)).optional(),minImportance:n().min(0).max(1).optional(),minDwellSeconds:n().min(0).optional(),source:x([`pipeline`,`onboard`,`sensor`,`audio`,`any`]).optional(),minLabelConfidence:n().min(0).max(1).optional(),eventTypeTokens:S(l().min(1)).optional(),sensorKinds:S(l().min(1)).optional(),sensorTransition:Tq.optional(),packagePhase:x([`delivered`,`picked-up`,`both`]).optional(),systemEvent:mq.optional(),customZones:S(tH).optional(),occupancy:Sq.optional(),audio:Cq.optional()}),Pq=b({targetId:l().min(1),params:m(l(),C()).optional()}),UOe=500,Fq=x([`none`,`image`,`clip`,`gif`]),Iq=b({template:b({title:l().max(500).optional(),body:l().max(2e3).optional()}).optional(),schedule:_q.optional(),priority:n().int().min(1).max(5).optional(),attachment:Fq.optional(),actions:v().optional()}),Lq=m(l(),Iq),Rq=x([`scene-boxes`,`crop`,`clean`,`none`]),zq=x([`cropped`,`full`,`boxed`]),Bq=x([`mosaic`,`each`]),WOe=4,GOe=6,Vq=b({image:Rq.optional(),showTriggerZone:v().optional(),showSubjectPath:v().optional(),attach:x([`best`,`best-matching`,`keyFrame`,`none`]).optional(),frame:zq.optional(),zoneCrop:v().optional(),gif:v().optional(),clip:v().optional(),clipPreRollSec:n().int().min(0).max(30).optional(),clipPostRollSec:n().int().min(0).max(30).optional(),clipSpeed:n().min(1).max(8).optional(),profile:N.optional(),linkedCameras:Bq.optional(),wakeSleepingCamera:v().optional()}),Hq=x([`shared`,`per-class`]),Uq=b({cooldownSec:n().int().min(0).max(86400).default(60),scope:x([`rule`,`rule-device`]).default(`rule-device`),granularity:Hq.optional()}),Wq=1e3,Gq=2e4,Kq=8e3,KOe=448,qq=b({op:x([`>=`,`>`,`<=`,`<`,`==`]),count:n().int().min(0).max(1e3)}),Jq=b({enabled:v().default(!1),profileId:l().optional(),prompt:l().max(1e3).optional(),expect:qq.optional(),timeoutMs:n().int().min(Wq).max(Gq).default(Kq),onTimeout:x([`fire`,`suppress`]).default(`fire`),maxImagePx:n().int().min(64).max(2048).default(448)}),qOe=5,JOe=20,YOe=60,XOe=5,ZOe=0,QOe=300,Yq=b({name:l().min(1).max(200),enabled:v().default(!0),delivery:sq,conditions:Nq.default({}),schedule:_q.optional(),systemEventDelivery:bq.optional(),targets:S(Pq),targetUsers:S(l()).optional(),targetOverrides:Lq.optional(),media:Vq.default({}),throttle:Uq.default({cooldownSec:60,scope:`rule-device`}),template:b({title:l().max(500).optional(),body:l().max(2e3).optional()}).optional(),priority:n().int().min(1).max(5).default(3),ownerUserId:l().optional(),snoozeAllowGlobal:v().optional(),snoozeOptions:S(n().int().min(1).max(hq)).max(4).optional(),actions:Aq.optional(),confirm:Jq.optional(),groupingSec:n().int().min(5).max(60).optional(),groupWithinSec:n().int().min(0).max(300).optional(),askVerdict:v().optional(),tags:Vh.optional()}),Xq=x([`event`,`summary`,`timelapse`,`calendar-events`]),Zq=b({kind:Xq,ruleId:l(),tags:S(l())}),Qq=Yq.partial().extend({disabledTargetIds:S(l()).optional(),enabled:v().optional(),conditions:Nq.optional(),media:Vq.optional(),throttle:Uq.optional(),priority:n().int().min(1).max(5).optional()}),$q=[`waitForEnhancement`,`groupIdleSec`];function $Oe(e){return $q.some(t=>t===e)}var eJ=[`template`,`schedule`,`targetUsers`,`snoozeOptions`,`snoozeAllowGlobal`,`actions`,`confirm`,`groupingSec`,`waitForEnhancement`,`groupIdleSec`],tJ=x(eJ),nJ=b({ruleId:l(),patch:Qq,clear:S(tJ).optional()}),rJ=Yq.extend({id:l(),createdBy:l(),createdAt:n(),updatedAt:n(),disabledTargetIds:S(l()).default([])}),iJ=[`device-state`,`streams`,`battery`,`consumables`,`detection-blind`,`nodes`,`addons`,`addon-updates`,`updates`],aJ=x(iJ),oJ=b({id:aJ,status:x([`read`,`unavailable`]),items:n().int().nonnegative(),reason:l().optional()}),sJ=b({section:aJ.optional(),title:l(),text:l(),count:n().int().nonnegative()}),cJ=b({empty:v(),count:n().int().nonnegative(),text:l(),sections:S(oJ),dropped:m(l(),n().int().nonnegative()),excludedGroups:S(l()),split:yq.optional(),rows:S(sJ).optional()}),lJ=b({recordId:l(),recordKind:x([`object-event`,`track`,`device-event`,`package-event`,`system-event`]),deviceId:n(),timestamp:n(),wouldFire:v(),failedCondition:l().optional(),className:l().optional(),label:l().optional()}),uJ=x([`detection`,`sensor`,`occupancy`,`sound`,`device-events`,`system`,`alarm`,`mixed`]),dJ=x([`detection`,`sensor`,`occupancy`,`sound`,`system`]),fJ=b({id:x([`appliance-cycle`]),kind:uJ,title:l(),body:l()}),pJ=x([`rule`,`timelapse`,`summary`]),mJ=x([`title`,`body`,`previewText`,`captionText`]),hJ=x([`subject`,`place`,`time`,`rule`,`occupancy`,`sound`,`sensor`,`system`,`digest`,`ai`]),gJ=b({name:l().regex(/^\w+$/),label:l(),description:l().optional(),example:l(),group:hJ,families:S(pJ).min(1),fields:S(mJ).optional(),kinds:S(dJ).optional(),deliveries:S(sq).optional(),systemEventKinds:S(cq).optional(),systemEventDeliveries:S(vq).optional(),dynamic:b({prefix:p(`count_`),from:p(`classes`)}).optional()}),_J=b({family:pJ,field:mJ,kind:uJ.optional(),delivery:sq.optional(),systemEventKinds:S(cq).optional(),systemEventDelivery:vq.optional()}),vJ=b({context:_J,template:b({title:l().max(500).optional(),body:l().max(2e3).optional()})}),yJ=b({title:l().nullable(),body:l().nullable(),unknown:S(l())}),bJ=b({id:l(),group:x([`scope`,`class`,`zones`,`quality`,`label`,`schedule`,`device`,`package`,`occupancy`,`audio`,`system`]),label:l(),valueType:x([`deviceIdList`,`deviceIdExcludeList`,`stringList`,`number01`,`number`,`sourceSelect`,`zoneSelection`,`zoneIdList`,`schedule`,`plateMatcher`,`packagePhase`,`crossingSelect`,`sensorTransition`,`polygonDraw`,`occupancy`,`audio`,`deviceState`,`scene`,`systemEvent`]),operator:x([`in`,`notIn`,`anyOf`,`allOf`,`gte`,`fuzzyIn`,`withinSchedule`]),appliesTo:S(sq),phase:l(),description:l().optional(),options:S(b({value:l(),label:l(),hint:l().optional()})).readonly().optional()}),eke=[{id:`systemEvent`,group:`system`,label:`System event`,valueType:`systemEvent`,options:[{value:`device-online`,label:`Device online`},{value:`device-offline`,label:`Device offline`},{value:`device-disabled`,label:`Device switched off`},{value:`device-enabled`,label:`Device switched on`},{value:`stream-online`,label:`Stream online`},{value:`stream-offline`,label:`Stream offline`},{value:`node-online`,label:`Node online`},{value:`node-offline`,label:`Node offline`},{value:`node-restarting`,label:`Node restarting`},{value:`node-updating`,label:`Node updating (restart imminent)`},{value:`node-inference-unavailable`,label:`Node has no usable inference device`},{value:`detection-blind`,label:`Camera detecting nothing`},{value:`motion-noisy`,label:`Camera motion constant, no subject`},{value:`motion-calm`,label:`Camera motion calm again`},{value:`package-llm-silent`,label:`Package confirm not answering`},{value:`package-llm-answered`,label:`Package confirm answering again`},{value:`recording-stalled`,label:`Recording stalled`},{value:`recording-healthy`,label:`Recording healthy again`},{value:`recording-degraded`,label:`Recording degraded (restart storm)`},{value:`device-attention-required`,label:`Device needs attention`},{value:`device-attention-resolved`,label:`Device attention resolved`},{value:`device-command`,label:`Command given to a device`},{value:`storage-location-low`,label:`Storage location low`},{value:`storage-location-critical`,label:`Storage location critical`},{value:`storage-location-ok`,label:`Storage location ok again`},{value:`storage-drain-progress`,label:`Storage drain progress`},{value:`storage-drain-complete`,label:`Storage drain complete`},{value:`addon-crash-loop`,label:`Addon stopped after repeated crashes`},{value:`addon-update-available`,label:`Addon update available`},{value:`server-update-available`,label:`Server update available`},{value:`wrapper-update-available`,label:`Container / app update available`},{value:`addon-updated`,label:`Addons updated`},{value:`server-updated`,label:`Server updated`},{value:`device-battery-low`,label:`Battery low`},{value:`device-battery-normal`,label:`Battery back to normal`},{value:`device-consumable-low`,label:`Consumable low`},{value:`device-consumable-normal`,label:`Consumable replaced`},{value:`export-completed`,label:`Export completed`},{value:`backup-completed`,label:`Backup completed`},{value:`alert-critical`,label:`Critical alert raised`},{value:`alert-error`,label:`Error alert raised`},{value:`alert-critical-resolved`,label:`Critical alert resolved`},{value:`rule-broken`,label:`Notification rule broken`},{value:`rule-repaired`,label:`Notification rule repaired`},{value:`alarm-arm-refused`,label:`Alarm arm refused`},{value:`alarm-check-failed`,label:`Alarm check failed (armed anyway)`},{value:`alarm-arming`,label:`Alarm arming (exit delay)`},{value:`alarm-armed`,label:`Alarm armed`},{value:`alarm-pending`,label:`Alarm entry delay started`},{value:`alarm-triggered`,label:`Alarm triggered`},{value:`alarm-rearmed`,label:`Alarm re-armed after siren`},{value:`alarm-sensor-bypass`,label:`Alarm sensor bypass`},{value:`alarm-disarmed`,label:`Alarm disarmed`}],operator:`in`,appliesTo:[`system-event`],phase:`P1`,description:`Infrastructure and update events. Device liveness covers EVERY device type — narrow it by device type (cameras only, say) and/or by device, node events by node id, and addon updates by package name.`},{id:`devices`,group:`scope`,label:`Devices`,valueType:`deviceIdList`,operator:`in`,appliesTo:[`immediate`,`track-end`,`device-event`,`package-event`],phase:`P1`,description:`Restrict the rule to these devices; absent = all devices. A sensor event matches either the SENSOR that fired or the camera it is attributed to, so a rule may name either one.`},{id:`devicesExclude`,group:`scope`,label:`Excluded devices`,valueType:`deviceIdExcludeList`,operator:`notIn`,appliesTo:[`immediate`,`track-end`,`device-event`,`package-event`],phase:`P1`,description:`Every device except these. Judged on the same device ids as Devices: a sensor event is excluded by the SENSOR that fired or by the camera it is attributed to.`},{id:`classes`,group:`class`,label:`Object classes`,valueType:`stringList`,operator:`in`,appliesTo:[`immediate`,`track-end`,`package-event`],phase:`P1`,description:`Any overlap with the detection class set passes.`},{id:`classesExclude`,group:`class`,label:`Excluded classes`,valueType:`stringList`,operator:`notIn`,appliesTo:[`immediate`,`track-end`,`package-event`],phase:`P1`},{id:`minConfidence`,group:`quality`,label:`Minimum confidence`,valueType:`number01`,operator:`gte`,appliesTo:[`immediate`,`track-end`,`package-event`],phase:`P1`},{id:`zones`,group:`zones`,label:`Zones`,valueType:`zoneSelection`,operator:`anyOf`,appliesTo:[`immediate`,`track-end`,`package-event`],phase:`P1`,description:`The zones the subject must be in (included) or never in (excluded).`},{id:`zonesExclude`,group:`zones`,label:`Excluded zones`,valueType:`zoneIdList`,operator:`notIn`,appliesTo:[`immediate`,`track-end`,`package-event`],phase:`P1`},{id:`crossing`,group:`zones`,label:`Zone crossing`,valueType:`crossingSelect`,options:[{value:``,label:`Entering`,hint:`Entries and ordinary movement; never an exit.`},{value:`exit`,label:`Leaving`,hint:`Only an exit from a zone.`},{value:`any`,label:`Entering or leaving`,hint:`Entries, exits and ordinary movement.`}],operator:`in`,appliesTo:[`immediate`],phase:`P1`,description:`Which way the subject crosses the zone.`},{id:`labelEquals`,group:`label`,label:`Label equals`,valueType:`stringList`,operator:`in`,appliesTo:[`immediate`,`track-end`],phase:`P1`,description:`Exact match on the collapsed label (identity / plate / subclass).`},{id:`identities`,group:`label`,label:`Known faces`,valueType:`stringList`,operator:`in`,appliesTo:[`immediate`,`track-end`],phase:`P1`,description:`Only recognised people. Selecting NOBODY means every identity in the face gallery; selecting some narrows to those. Matched on the gallery id, so renaming a person does not break the rule. On Immediate delivery the name must already be known when an event is written — choose Immediate, grouped to wait for it.`},{id:`plates`,group:`label`,label:`Known plates`,valueType:`plateMatcher`,operator:`fuzzyIn`,appliesTo:[`immediate`,`track-end`],phase:`P1`,description:`Only vehicles whose plate was read. Selecting NO plate means any readable plate; listed plates are matched Levenshtein-tolerantly, because OCR noise makes an exact match useless.`},{id:`identitiesExclude`,group:`label`,label:`Excluded faces`,valueType:`stringList`,operator:`notIn`,appliesTo:[`immediate`,`track-end`],phase:`P1`,description:`Veto by identity (mirror of Known faces, same gallery ids). A subject nobody recognised passes — there is nothing to exclude.`},{id:`minLabelConfidence`,group:`label`,label:`Minimum label confidence`,valueType:`number01`,operator:`gte`,appliesTo:[`track-end`],phase:`P1`,description:`Best identity/plate recognition match confidence [0,1] for the label the track carries at close (peak assigned-identity cosine / peak plate OCR score; the higher of the two when both were read). Distinct from detection confidence. Fails closed for a track that ended un-recognized.`},{id:`minImportance`,group:`quality`,label:`Minimum importance`,valueType:`number01`,operator:`gte`,appliesTo:[`track-end`],phase:`P1`,description:`Server-computed key-event importance [0,1]; track-end rules only (importance is scored at close). Fails when the record has none.`},{id:`minDwellSeconds`,group:`quality`,label:`Minimum dwell (seconds)`,valueType:`number`,operator:`gte`,appliesTo:[`track-end`],phase:`P1`,description:`Track lifespan in seconds (lastSeen − firstSeen); track-end rules only.`},{id:`source`,group:`scope`,label:`Detection source`,valueType:`sourceSelect`,options:[{value:`any`,label:`Any source`},{value:`pipeline`,label:`Pipeline`},{value:`onboard`,label:`Onboard (camera)`},{value:`sensor`,label:`Sensor`},{value:`audio`,label:`Audio marker`}],operator:`in`,appliesTo:[`immediate`,`track-end`,`device-event`,`package-event`],phase:`P1`,description:`pipeline / onboard / sensor / audio; a record with no stamped source counts as pipeline.`},{id:`deviceState`,group:`scope`,label:`Device state`,valueType:`deviceState`,operator:`in`,appliesTo:[`immediate`,`track-end`,`device-event`,`package-event`],phase:`P2`,description:`Only fire while another device is in one of the chosen states — the alarm armed, a switch on, a contact closed. A state that cannot be read does NOT fire.`},{id:`scene`,group:`scope`,label:`Scene state`,valueType:`scene`,operator:`in`,appliesTo:[`immediate`,`track-end`,`device-event`,`package-event`],phase:`P3`,description:`Only fire while a scene is matched or diverged.`},{id:`sensorKinds`,group:`device`,label:`Sensor kinds`,valueType:`stringList`,operator:`in`,appliesTo:[`device-event`],phase:`P1`,description:`Sensor/control taxonomy kinds (doorbell / contact / button / …) matched against the persisted device event.`},{id:`eventTypeTokens`,group:`device`,label:`Event-type tokens`,valueType:`stringList`,operator:`in`,appliesTo:[`device-event`],phase:`P1`,description:`Raw device event-type tokens (e.g. doorbell press / press_long) from the event-emitter slice; absent on doorbell-pulse / passive sensors.`},{id:`sensorTransition`,group:`device`,label:`Notify when`,valueType:`sensorTransition`,options:[{value:``,label:`When it starts and when it finishes`,hint:`Every change: the alert itself, and the return to normal.`},{value:`raised`,label:`Only when it starts`,hint:`Water detected, smoke, a contact opening — never the return to normal.`},{value:`cleared`,label:`Only when it finishes`,hint:`Back to dry, smoke gone, a contact closing — never the alert itself.`}],operator:`in`,appliesTo:[`device-event`],phase:`P2`,description:`Fire on one edge of a boolean sensor. Offered only when every chosen sensor kind raises and clears; a reading that cannot be placed still notifies.`},{id:`packagePhase`,group:`package`,label:`Package phase`,valueType:`packagePhase`,options:[{value:`delivered`,label:`Delivered`},{value:`picked-up`,label:`Picked up`},{value:`both`,label:`Both`}],operator:`in`,appliesTo:[`package-event`],phase:`P1`,description:`Delivered / picked-up / both.`},{id:`occupancy`,group:`occupancy`,label:`Occupancy`,valueType:`occupancy`,operator:`anyOf`,appliesTo:[`device-event`],phase:`P1`,description:`ZoneAnalytics occupancy edge (optionally zone/class-scoped): count crosses the threshold and holds for sustainSeconds. Fail-closed on a missing snapshot.`},{id:`audio`,group:`audio`,label:`Sound`,valueType:`audio`,operator:`anyOf`,appliesTo:[`immediate`],phase:`P2`,description:`Fires when at least hitPercent% of the samples in a samplingSeconds window are hits — a hit clears the dBFS floor AND carries one of the chosen sounds. Both filters are optional and independent, but naming NEITHER never matches: every sample would be a hit, so the engine refuses rather than notifying on silence. dBFS is negative-going (0 = full scale, -96 = silence).`},{id:`customZones`,group:`zones`,label:`Custom zones`,valueType:`polygonDraw`,operator:`anyOf`,appliesTo:[`immediate`,`track-end`,`package-event`],phase:`P1`,description:`User-drawn polygons; a detection whose bbox overlaps any polygon matches.`},{id:`schedule`,group:`schedule`,label:`Schedule`,valueType:`schedule`,operator:`withinSchedule`,appliesTo:[`immediate`,`track-end`,`device-event`,`package-event`,`system-event`],phase:`P1`,description:`Weekly activation windows (invertible); absent = always active.`}],xJ=x([`pending`,`sent`,`dead`]),SJ=x([`object-event`,`track-end`,`device-event`,`package-event`,`system-event`]),CJ=b({className:l(),label:l().optional(),confidence:n().optional(),zones:S(l()),timestamp:n(),systemEvent:b({kind:cq,subject:l(),title:l(),body:l(),data:m(l(),C())}).optional()}),wJ=b({id:l(),ruleId:l(),ruleName:l(),delivery:sq,targetId:l(),deviceId:n(),recordKind:SJ,recordId:l(),trackId:l().optional(),status:xJ,attempts:n().int(),createdAt:n(),updatedAt:n(),error:l().optional(),subject:CJ,title:l().optional(),body:l().optional(),artifactIds:S(l().min(1)).optional(),groupedInto:l().min(1).optional()}),tke=100,nke=500,TJ=b({ruleId:l().optional(),deviceId:n().optional(),status:xJ.optional(),since:n().optional(),until:n().optional(),limit:n().int().min(1).max(500).default(100)}),EJ=b({ruleId:l(),lastAt:n(),status:xJ,deviceId:n()}),DJ=b({runs:S(EJ),horizonMs:n().nonnegative().nullable()}),OJ=x([`rule`,`device`,`all`]),kJ=b({scope:OJ,ruleId:l().optional(),deviceId:n().int().optional(),classes:S(l().min(1)).min(1).optional(),durationMinutes:n().int().min(1).max(hq),global:v().optional(),summary:v().optional()}),AJ=b({id:l(),userId:l(),scope:OJ,ruleId:l().optional(),deviceId:n().int().optional(),classes:S(l().min(1)).min(1).optional(),startedAt:n(),expiresAt:n(),global:v(),summary:v(),digestSentAt:n().optional()}),rke=b({snoozeId:l(),targetId:l(),ruleId:l(),ruleName:l(),deviceId:n().int(),count:n().int(),firstAt:n(),lastAt:n()}),ike=600,jJ=3600,ake=200,MJ=n().int().min(0).max(600),NJ=n().int().min(0).max(jJ),PJ=e=>new Set(e.map(e=>e.mode)).size===e.length,FJ=x([`rearmAfter`,`disableAfter`,`doNothing`]),IJ=b({mode:qS,exitDelaySec:MJ.optional(),entryDelaySec:MJ.optional(),triggeredDurationSec:NJ.optional(),postTriggeredAction:FJ.optional(),schedule:_q.optional(),notifyDuringEntryDelay:v().optional(),notifySensorRewatched:v().optional(),notifySensorIgnored:v().optional()}),oke=S(IJ).max(8).refine(PJ,{message:`modeDelays: at most one entry per arm mode`}),LJ=b({mode:qS,exitDelaySec:MJ.nullable().optional(),entryDelaySec:MJ.nullable().optional(),triggeredDurationSec:NJ.nullable().optional(),postTriggeredAction:FJ.nullable().optional(),schedule:_q.nullable().optional(),notifyDuringEntryDelay:v().nullable().optional(),notifySensorRewatched:v().nullable().optional(),notifySensorIgnored:v().nullable().optional()}),ske=S(LJ).max(8).refine(PJ,{message:`modeDelays: at most one edit per arm mode`}),RJ=b({mode:qS,deviceId:n().int().positive(),nonBlocking:v()}),zJ=b({mode:qS,deviceId:n().int().positive(),blocking:v()}),BJ=b({mode:qS,deviceId:n().int().positive(),secureOnArm:v()}),VJ=b({mode:qS,deviceIds:S(n().int()).max(200)}),HJ=VJ,UJ=VJ,WJ=VJ,GJ=S(HJ).max(8).refine(PJ,{message:`nonBlocking: at most one list per arm mode`}),KJ=S(UJ).max(8).refine(PJ,{message:`blocking: at most one list per arm mode`}),qJ=S(WJ).max(8).refine(PJ,{message:`secureOnArmOff: at most one list per arm mode`}),JJ=b({exitDelaySec:MJ,entryDelaySec:MJ,triggeredDurationSec:NJ,postTriggeredAction:FJ.optional(),announceArm:v().optional(),announceTargets:S(l().min(1)).max(16),nonBlocking:GJ.default([]),blocking:KJ.default([]),secureOnArmOff:qJ.default([]),modeDelays:oke.default([])}),YJ=b({id:l().min(1).max(64),name:l().min(1).max(64),isDefault:v()}),XJ=b({activeId:l().min(1),items:S(YJ).min(1)}),ZJ=b({name:l().min(1).max(64),cloneFromId:l().min(1).max(64).optional()}),QJ=b({id:l().min(1).max(64),name:l().min(1).max(64)}),$J=b({id:l().min(1).max(64)}),eY=JJ.extend({nonBlocking:GJ,blocking:KJ,secureOnArmOff:qJ,modeDelays:ske,nonBlockingEdit:RJ,blockingEdit:zJ,secureOnArmEdit:BJ}).partial().refine(e=>e.nonBlocking===void 0||e.nonBlockingEdit===void 0,{message:`nonBlocking and nonBlockingEdit are exclusive — send the whole lists or one edit`}).refine(e=>e.blocking===void 0||e.blockingEdit===void 0,{message:`blocking and blockingEdit are exclusive — send the whole lists or one edit`}).refine(e=>e.secureOnArmOff===void 0||e.secureOnArmEdit===void 0,{message:`secureOnArmOff and secureOnArmEdit are exclusive — send the whole lists or one edit`}),cke=x([`muted`,`detection-off`,`offline`]),tY=b({deviceId:n().int(),reason:cke}),nY=b({mode:qS,ruleCount:n().int().min(0),allDevices:v(),deviceIds:S(n().int()),allDevicesExcept:S(n().int()).default([]),skippedDevices:S(tY).default([])}),lke=b({deviceId:n().int(),name:l(),state:l(),blocking:v()}),uke=b({deviceId:n().int(),name:l(),phase:x([`open`,`closed`])}),dke=b({mode:qS,devices:S(lke),unknown:S(n().int())}),fke=b({ruleId:l(),ruleName:l(),deviceId:n().int(),name:l(),since:n(),dropped:n().int().min(0)}),pke=b({state:KS,targetMode:qS.nullable(),availableModes:S(qS),openings:S(dke),exclusions:S(uke),bypassedInputs:S(fke).default([])}),rY=b({deviceId:n().int().nullable(),settings:JJ,profiles:XJ.optional(),coverage:S(nY),live:pke.optional()}),mke=500,iY=x([`open`,`closed`,`unknown`,`not-opening`]),aY=b({deviceId:n().int().positive(),reading:iY,state:l().nullable(),unknownWhy:x([`read-failed`,`unknown-word`]).nullable(),online:v().nullable(),controllable:v().default(!1)}),oY=b({deviceIds:S(n().int().positive()).max(500)}),sY=b({sensors:S(aY),readAt:n().int().nonnegative()}),hke=60,cY=b({deviceId:n().int().nonnegative().optional(),seconds:n().min(0).max(60),profile:N.optional(),ruleId:l(),ruleName:l(),reason:x([`window`,`occupancy`])}),lY=b({rulesLoaded:v(),asks:S(cY).readonly()}),uY={name:`notification-rules`,scope:`system`,mode:`singleton`,methods:{listRules:k(b({}),b({rules:S(rJ)}),{auth:`admin`}),getRule:k(b({ruleId:l()}),b({rule:rJ.nullable()}),{auth:`admin`}),createRule:k(b({rule:Yq}),b({rule:rJ}),{kind:`mutation`,auth:`admin`,caller:`required`}),updateRule:k(nJ,b({rule:rJ}),{kind:`mutation`,auth:`admin`,caller:`required`}),deleteRule:k(b({ruleId:l()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setRuleEnabled:k(b({ruleId:l(),enabled:v()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),listRuleTags:k(b({}),b({rules:S(Zq)}),{kind:`query`,auth:`admin`}),setRuleTags:k(b({kind:Xq,ruleId:l(),tags:Vh}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getClipRetentionAsks:k(b({}),lY,{auth:`admin`}),listDeviceMutes:k(b({}),b({mutedDeviceIds:S(n().int()).readonly()}),{auth:`admin`}),setDeviceMuted:k(b({deviceId:n().int(),muted:v()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),testRule:k(b({rule:Yq,lookbackMinutes:n().int().min(1).max(1440).default(60)}),b({results:S(lJ)}),{kind:`mutation`,auth:`admin`}),previewStateSummary:k(b({rule:Yq}),cJ,{kind:`mutation`,auth:`admin`,access:`view`}),getConditionCatalog:k(b({}),b({catalog:S(bJ),taxonomy:iq.optional()})),getTemplateCatalog:k(b({}),b({vars:S(gJ),defaults:S(fJ)})),previewTemplate:k(vJ,yJ,{kind:`mutation`,access:`view`}),getHistory:k(b({filter:TJ.default({limit:100})}),b({entries:S(wJ)}),{auth:`admin`}),getRuleLastRuns:k(b({}),DJ,{auth:`admin`}),resolveArtifactUrl:k(b({artifactId:l().min(1)}),b({url:l().nullable()}),{auth:`admin`}),listSnoozes:k(b({}),b({snoozes:S(AJ)}),{caller:`required`}),createSnooze:k(b({snooze:kJ}),b({snooze:AJ}),{kind:`mutation`,caller:`required`}),cancelSnooze:k(b({snoozeId:l()}),b({success:p(!0)}),{kind:`mutation`,caller:`required`}),getAlarmConfig:k(b({}),rY,{auth:`admin`}),setAlarmConfig:k(b({patch:eY}),rY,{kind:`mutation`,auth:`admin`}),createAlarmProfile:k(ZJ,rY,{kind:`mutation`,auth:`admin`}),renameAlarmProfile:k(QJ,rY,{kind:`mutation`,auth:`admin`}),deleteAlarmProfile:k($J,rY,{kind:`mutation`,auth:`admin`}),activateAlarmProfile:k($J,rY,{kind:`mutation`,auth:`admin`}),getAlarmSensors:k(oY,sY,{auth:`admin`})},vocabulary:{notOperatorFacing:`notification rules — authored on their own page`}},gke=x([`min`,`low`,`normal`,`high`]),_ke=b({id:l().min(1),title:l().min(1),uri:r().optional(),destructive:v().optional()}),vke=b({image:v(),priority:v(),data:v(),actions:v(),recipients:v()}),dY=b({lastSentAt:n(),lastError:l().nullable(),queueDepth:n().int().nonnegative().meta(M(`count`)),supports:vke}),yke=b({deviceId:n().int().nonnegative(),title:l().optional(),body:l().min(1),image:l().optional(),priority:gke.optional(),channel:l().optional(),recipients:S(l()).optional(),actions:S(_ke).optional(),data:m(l(),C()).optional()}),bke=b({notificationId:l(),acceptedAt:n()}),fY={name:`notifier`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Notifier],methods:{send:k(yke,bke,{kind:`mutation`,auth:`admin`,actions:[{id:`notifier.send`,label:P(`Send a notification`,`Invia una notifica`),phrase:P(`Send “{body}” through {device}`,`Invia «{body}» tramite {device}`),icon:`send`,openArgs:[{key:`title`,label:P(`Title`,`Titolo`),offer:{kind:`text`},optional:!0},{key:`body`,label:P(`Message`,`Messaggio`),offer:{kind:`text`}},{key:`priority`,label:P(`Priority`,`Priorità`),offer:{kind:`enum`,values:[{value:`min`,label:P(`Minimal`,`Minima`)},{value:`low`,label:P(`Low`,`Bassa`)},{value:`normal`,label:P(`Normal`,`Normale`)},{value:`high`,label:P(`High`,`Alta`)}]},optional:!0}]}]}),cancel:k(b({deviceId:n().int().nonnegative(),notificationId:l().min(1)}),_(),{kind:`mutation`,auth:`admin`})},events:{onSent:{data:b({deviceId:n(),notificationId:l(),success:v(),error:l().nullable(),acceptedAt:n()}),notOperatorFacing:`a delivery receipt of a send this system made — not a fact about the world`}},status:{schema:dY,kind:`command-driven`},runtimeState:dY,durability:`session`,history:`none`,vocabulary:{noun:P(`Notifier`,`Notificatore`),order:2110}},pY=b({value:n().nullable().meta(M(`device`)),lastFetchedAt:n()}),mY={name:`numeric-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Sensor],methods:{},status:{schema:pY,kind:`push`},runtimeState:pY,durability:`restored`,history:{fields:{value:{kind:`gauge`,minIntervalMs:3e4}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:P(`Sensor`,`Sensore`),order:5150,state:[{kind:`numeric`,field:`value`,quantity:P(`the reading`,`il valore`),label:P(`Reading`,`Valore`),icon:`gauge`}]}},hY=b({integrationId:l(),displayName:l(),requestedScopes:S(sg),allowedRedirectPrefixes:S(l()).min(1),allowedPrivateHostPaths:S(l()).optional(),requiresPkce:v().optional(),hubUrl:l().optional(),refreshTokenTtlSec:h([n().int().positive(),p(`never`)]).optional(),instances:S(b({id:l(),displayName:l()})).optional()}),gY={name:`oauth-integration`,scope:`system`,mode:`collection`,internal:!0,methods:{getDescriptor:k(_(),hY,{auth:`admin`})},vocabulary:{notOperatorFacing:j.IDENTITY}},_Y=x([`text`,`timestamp`,`watermark`]),vY=x([`top-left`,`top-center`,`top-right`,`bottom-left`,`bottom-center`,`bottom-right`,`custom`]),yY=b({id:l(),kind:_Y,enabled:v(),text:l().optional(),position:vY.optional(),availablePositions:S(vY).readonly(),readOnly:v().optional(),maxCharacters:n().int().positive().optional()}),bY=b({overlays:S(yY).readonly()}),xY=b({enabled:v().optional(),text:l().optional(),position:vY.optional()}).partial(),SY={name:`osd`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Camera],methods:{setOverlay:k(b({deviceId:n(),overlayId:l(),patch:xY}),_(),{kind:`mutation`,auth:`admin`})},events:{onStatusChanged:{data:b({deviceId:n(),status:bY}),notOperatorFacing:`an overlay setting changed — configuration, not a happening`}},status:{schema:bY,kind:`command-driven`},settings:{bindings:[{kind:`array`,statusPath:`overlays`,idField:`id`,method:`setOverlay`,idArg:`overlayId`,patchArg:`patch`,sectionId:`osd`,sectionTitle:`Video overlays`,itemFields:{enabled:{label:e=>`${String(e.id)} enabled`,kind:`boolean`},text:{label:e=>`${String(e.id)} text`,kind:`text`,when:e=>e.kind!==`timestamp`&&!e.readOnly},position:{label:e=>`${String(e.id)} position`,kind:`select`,options:e=>e.availablePositions??[],when:e=>Array.isArray(e.availablePositions)&&e.availablePositions.length>0}}}]},vocabulary:{noun:P(`On-screen text`,`Testo in sovrimpressione`),order:3190}},CY=1024,wY=b({id:l().min(1).max(64),name:l().min(1).max(64),text:l().max(CY).default(``)}),TY=i(`kind`,[b({kind:p(`none`)}),b({kind:p(`static`),text:l().max(CY)}),b({kind:p(`template`),templateId:l().min(1).max(64)})]),EY=b({enabled:v().default(!0),source:TY,schedule:_q.optional(),conditions:Nq.optional()}),DY=b({slotId:l(),kind:_Y,readOnly:v(),cameraEnabled:v(),cameraText:l().optional(),binding:EY.nullable()}),OY=x([`written`,`unchanged`,`gated`,`unreadable`,`disabled`,`unbound`,`failed`]),kY=b({slotId:l(),outcome:OY,text:l(),reason:l().optional()}),AY=b({ok:v(),text:l(),notes:S(l())}),jY={name:`osd-manager`,scope:`system`,mode:`singleton`,methods:{getDeviceOsd:k(b({deviceId:n().int()}),b({supported:v(),slots:S(DY)}),{auth:`admin`}),getConditionSupport:k(b({}),b({supported:S(l()),catalog:S(bJ)}),{auth:`admin`}),setSlotBinding:k(b({deviceId:n().int(),slotId:l().min(1),binding:EY}),b({slot:DY,render:kY}),{kind:`mutation`,auth:`admin`}),clearSlotBinding:k(b({deviceId:n().int(),slotId:l().min(1)}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setSlotCameraEnabled:k(b({deviceId:n().int(),slotId:l().min(1),enabled:v()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),copyDeviceConfiguration:k(b({sourceDeviceId:n().int(),targetDeviceId:n().int()}),b({copied:n().int().nonnegative(),skipped:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),previewSlot:k(b({deviceId:n().int(),slotId:l().min(1),binding:EY.optional()}),kY,{kind:`mutation`,auth:`admin`}),previewTemplate:k(b({deviceId:n().int(),text:l().max(CY)}),AY,{kind:`mutation`,auth:`admin`}),renderDevice:k(b({deviceId:n().int()}),b({results:S(kY)}),{kind:`mutation`,auth:`admin`}),listTemplates:k(b({}),b({templates:S(wY)}),{auth:`admin`}),upsertTemplate:k(b({template:wY}),b({template:wY}),{kind:`mutation`,auth:`admin`}),deleteTemplate:k(b({templateId:l().min(1).max(64)}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:j.PIPELINE}},MY=1e4,xke=4,Ske=200,Cke=x([`normal`,`offline`,`on_batteries`]),NY=n().int().min(4).max(200),PY=NY.meta(she({quantity:`mass`,unit:`g`})),FY=b({foodLevel:n().nullable().meta(M(`none`)),bowlFood:n().nullable().meta(M(`mass`)),eating:v(),supportsMarkRefilled:v(),food1:n().nullable().meta(M(`none`)),food2:n().nullable().meta(M(`none`)),lowFood:v(),batteryPower:n().min(0).max(100).nullable().meta(M(`percentage`)),powerSource:x([`mains`,`battery`]).nullable(),desiccantLeftDays:n().nullable().meta(M(`duration`)),feeding:v(),status:Cke.nullable(),error:l().nullable(),errorCode:n().nullable().meta(M(`none`)),isDualHopper:v(),childLock:v(),indicatorLight:v(),feedSound:v(),volume:n().meta(M(`none`)),lastFeedGrams:NY.nullable(),lastFeedHopper1:NY.nullable(),lastFeedHopper2:NY.nullable(),lastFetchedAt:n()}),IY={name:`pet-feeder`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.PetFeeder],methods:{feed:k(b({deviceId:n().int().nonnegative(),grams:PY.optional(),hopper1:PY.optional(),hopper2:PY.optional()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.feed`,label:P(`Feed`,`Dai da mangiare`),phrase:P(`Dispense {grams} from {device}`,`Eroga {grams} da {device}`),icon:`paw-print`,hold:{effects:[{field:`feeding`,value:!0}],holdMs:MY},openArgs:[{key:`grams`,label:P(`Grams`,`Grammi`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0}]},{id:`petFeeder.feedHoppers`,label:P(`Feed from both hoppers`,`Eroga da entrambi i serbatoi`),phrase:P(`Dispense {hopper1} and {hopper2} from {device}`,`Eroga {hopper1} e {hopper2} da {device}`),icon:`paw-print`,hold:{effects:[{field:`feeding`,value:!0}],holdMs:MY},openArgs:[{key:`hopper1`,label:P(`Hopper 1`,`Serbatoio 1`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0},{key:`hopper2`,label:P(`Hopper 2`,`Serbatoio 2`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0}]}]}),cancelFeed:k(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.cancelFeed`,label:P(`Cancel feeding`,`Annulla l’erogazione`),phrase:P(`Cancel the feeding on {device}`,`Annulla l’erogazione di {device}`),icon:`circle-x`}]}),callPet:k(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.callPet`,label:P(`Call pet`,`Chiama l’animale`),phrase:P(`Call your pet with {device}`,`Chiama l’animale con {device}`),icon:`megaphone`}]}),playSound:k(b({deviceId:n().int().nonnegative(),soundId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.playSound`,label:P(`Play sound`,`Riproduci un suono`),phrase:P(`Play sound {soundId} on {device}`,`Riproduci il suono {soundId} su {device}`),icon:`volume-2`,openArgs:[{key:`soundId`,label:P(`Sound`,`Suono`),offer:{kind:`number`,min:0,step:1}}]}]}),resetDesiccant:k(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.resetDesiccant`,label:P(`Desiccant replaced`,`Essiccante sostituito`),phrase:P(`Mark the desiccant of {device} as replaced`,`Segna come sostituito l’essiccante di {device}`),icon:`refresh-cw`}]}),markFoodReplenished:k(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.foodReplenished`,label:P(`Food refilled`,`Cibo ricaricato`),phrase:P(`Mark {device} as refilled`,`Segna {device} come ricaricato`),icon:`package`}]}),setChildLock:k(b({deviceId:n().int().nonnegative(),on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.childLockOn`,effect:{field:`childLock`,value:!0},label:P(`Child lock on`,`Blocco bambini attivo`),phrase:P(`Turn on the child lock of {device}`,`Attiva il blocco bambini di {device}`),icon:`lock`,args:{on:!0}},{id:`petFeeder.childLockOff`,effect:{field:`childLock`,value:!1},label:P(`Child lock off`,`Blocco bambini spento`),phrase:P(`Turn off the child lock of {device}`,`Disattiva il blocco bambini di {device}`),icon:`lock-open`,args:{on:!1}}]}),setIndicatorLight:k(b({deviceId:n().int().nonnegative(),on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.lightOn`,effect:{field:`indicatorLight`,value:!0},label:P(`Indicator light on`,`Spia accesa`),phrase:P(`Turn on the indicator light of {device}`,`Accendi la spia di {device}`),icon:`lightbulb`,args:{on:!0}},{id:`petFeeder.lightOff`,effect:{field:`indicatorLight`,value:!1},label:P(`Indicator light off`,`Spia spenta`),phrase:P(`Turn off the indicator light of {device}`,`Spegni la spia di {device}`),icon:`lightbulb-off`,args:{on:!1}}]}),setFeedSound:k(b({deviceId:n().int().nonnegative(),on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.feedSoundOn`,effect:{field:`feedSound`,value:!0},label:P(`Feeding sound on`,`Suono di erogazione attivo`),phrase:P(`Turn on the feeding sound of {device}`,`Attiva il suono di erogazione di {device}`),icon:`volume-2`,args:{on:!0}},{id:`petFeeder.feedSoundOff`,effect:{field:`feedSound`,value:!1},label:P(`Feeding sound off`,`Suono di erogazione spento`),phrase:P(`Turn off the feeding sound of {device}`,`Disattiva il suono di erogazione di {device}`),icon:`volume-x`,args:{on:!1}}]}),setVolume:k(b({deviceId:n().int().nonnegative(),level:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.volume`,effect:{field:`volume`,fromArg:`level`},label:P(`Set volume`,`Imposta il volume`),phrase:P(`Set the volume of {device} to {level}`,`Imposta il volume di {device} a {level}`),icon:`volume-2`,openArgs:[{key:`level`,label:P(`Volume`,`Volume`),offer:{kind:`number`,min:0,step:1}}]}]})},status:{schema:FY,kind:`poll`},runtimeState:FY,durability:`session`,history:{fields:{feeding:{kind:`boolean`},eating:{kind:`boolean`},foodLevel:{kind:`gauge`},bowlFood:{kind:`gauge`},food1:{kind:`gauge`},food2:{kind:`gauge`},batteryPower:{kind:`gauge`,unit:`%`,deadband:2},desiccantLeftDays:{kind:`gauge`,unit:`s`}}},vocabulary:{noun:P(`Pet feeder`,`Distributore di cibo`),order:2030,state:[{kind:`boolean`,field:`lowFood`,label:P(`Food low`,`Cibo in esaurimento`),whenTrue:P(`When {device} runs low on food`,`Quando il cibo di {device} sta finendo`),whenFalse:P(`When {device} has enough food again`,`Quando {device} ha di nuovo cibo a sufficienza`),icon:`package`},{kind:`boolean`,field:`feeding`,label:P(`Feeding`,`In erogazione`),whenTrue:P(`When {device} starts feeding`,`Quando {device} inizia a erogare`),whenFalse:P(`When {device} finishes feeding`,`Quando {device} finisce di erogare`),icon:`paw-print`},{kind:`numeric`,field:`desiccantLeftDays`,quantity:P(`the desiccant life`,`la durata dell’essiccante`),label:P(`Desiccant`,`Essiccante`),unit:`d`,icon:`calendar-clock`}]}},LY=b({waterLevel:n().min(0).max(100).nullable().meta(M(`percentage`)),waterVolume:n().min(0).nullable().meta(M(`volume`)),empty:v().nullable(),pumpRunning:v().nullable(),error:l().nullable(),lastFetchedAt:n()}),RY=`water`;function wke(e){let t=e.waterLevel!==null||e.empty===null?null:e.empty?`empty`:`ok`;return{key:RY,label:`Water`,level:e.waterLevel,status:t,kind:`supply`,form:`tank`,lastResetAt:null,resettable:!1}}var Tke=n().int().nonnegative(),zY={name:`pet-fountain`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.PetFountain],power:{kind:`field`,field:`pumpRunning`,set:`setPump`},methods:{setPump:k(b({deviceId:Tke,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFountain.pumpOn`,effect:{field:`pumpRunning`,value:!0},label:P(`Pump on`,`Pompa accesa`),phrase:P(`Start the pump of {device}`,`Avvia la pompa di {device}`),icon:`play`,args:{on:!0}},{id:`petFountain.pumpOff`,effect:{field:`pumpRunning`,value:!1},label:P(`Pump off`,`Pompa spenta`),phrase:P(`Stop the pump of {device}`,`Ferma la pompa di {device}`),icon:`square`,args:{on:!1}}]})},status:{schema:LY,kind:`push`},runtimeState:LY,durability:`session`,history:{fields:{waterLevel:{kind:`gauge`,unit:`%`,deadband:1},waterVolume:{kind:`gauge`,unit:`L`}}},vocabulary:{noun:P(`Pet fountain`,`Fontana per animali`),order:2040,state:[{kind:`boolean`,field:`empty`,label:P(`Tank empty`,`Serbatoio vuoto`),whenTrue:P(`When the tank of {device} is empty`,`Quando il serbatoio di {device} è vuoto`),whenFalse:P(`When the tank of {device} is refilled`,`Quando il serbatoio di {device} viene riempito`),icon:`droplet`},{kind:`numeric`,field:`waterLevel`,quantity:P(`the water level`,`il livello dell’acqua`),label:P(`Water level`,`Livello dell’acqua`),unit:`%`,icon:`droplets`}]}},Eke=x(Pa),Dke=2,BY={min:1,max:8},VY=x([`intel-core-ultra`,`intel-n-series`,`apple-m-base`,`apple-m-pro`,`amd-phoenix`,`unknown`]),HY=x([`intel-npu`,`intel-igpu`,`amd-igpu`,`amd-npu`,`x86-cpu`,`arm-cpu`,`apple-ane`,`coral`]),UY=i(`kind`,[b({kind:p(`capacity`),sessions:n(),minSessions:n()}),b({kind:p(`tie-faster`),over:l(),recallDelta:n()}),b({kind:p(`stepped-down`),from:l(),to:l(),limitedBy:l()}),b({kind:p(`no-fit-lightest`),sessions:n(),minSessions:n()}),b({kind:p(`derived-latency`),modelId:l()}),b({kind:p(`cpu-device`)}),b({kind:p(`device-disabled`)}),b({kind:p(`device-unavailable`)}),b({kind:p(`node-offline`)}),b({kind:p(`no-hardware-facts`)}),b({kind:p(`no-measured-data`),hardwareClass:VY}),b({kind:p(`no-family-build`),format:Eke}),b({kind:p(`kept-custom-pin`),modelId:l(),deviceKey:l()})]),WY=x([`custom-pin`]),GY=i(`kind`,[b({kind:p(`table`)}),b({kind:p(`node-benchmark`),resultId:l(),measuredAtMs:n()}),b({kind:p(`estimated`),estimatedFrom:VY})]),KY=b({modelId:l(),p50Ms:n(),fps:n(),measured:v(),source:GY.optional(),estimatedFrom:VY.optional(),capacitySessions:n(),personRecall:n()}),qY=b({deviceKey:l(),accelerator:HY.nullable(),enabled:v(),available:v(),chosen:KY.nullable(),kept:WY.optional(),reasons:S(UY).readonly()}),JY=b({nodeId:l(),reachable:v(),hardwareClass:VY.nullable(),cpuModel:l().nullable(),skipped:v(),acceleratorModelId:l().nullable(),devices:S(qY).readonly(),reasons:S(UY).readonly()}),YY=b({stepId:l(),before:l().nullable(),after:l().nullable()}),XY=b({nodeId:l(),deviceKey:l(),madeExplicit:v(),modelPins:S(YY).readonly(),thresholds:S(b({stepId:l(),keys:S(l()).readonly()})).readonly()}),ZY=i(`kind`,[b({kind:p(`custom-pin-kept`),nodeId:l(),deviceKey:l(),modelId:l()}),b({kind:p(`custom-registry-unreadable`),error:l()})]),QY=b({headroom:n().min(.3).max(.5).default(.4),minSessionsPerDevice:n().int().min(BY.min).max(BY.max).default(2)}),$Y=b({planHash:l(),family:p(`yolov9`),headroom:n(),minSessionsPerDevice:n(),cameraFps:n(),generatedAt:n(),nodes:S(JY).readonly(),nodeChanges:S(XY).readonly(),warnings:S(ZY).readonly()}),eX=b({planHash:l(),headroom:n().min(.3).max(.5).default(.4),minSessionsPerDevice:n().int().min(BY.min).max(BY.max).default(2)}),tX=b({phase:x([`download`,`node-models`,`redispatch`]),ok:v(),detail:l()}),nX=i(`kind`,[b({kind:p(`applied`),planHash:l(),phases:S(tX).readonly()}),b({kind:p(`aborted`),phases:S(tX).readonly()}),b({kind:p(`stale`),plan:$Y}),b({kind:p(`refused`),reason:x([`apply-in-progress`])})]),rX=x([`least-loaded`,`share`]),iX=`share`,Oke=`sessionPlacement`;function kke(e){let t=rX.safeParse(e);return t.success?t.data:iX}var aX=b({nodes:m(l(),n().positive()).default({}),devices:m(l(),m(l(),n().positive())).default({})}),oX=b({windowMs:n().int().min(6e4).max(1440*60*1e3).default(3600*1e3)}),sX=b({deviceKey:l(),sessionsNow:n(),sessionsStarted:n(),observedShare:n().nullable()}),cX=b({nodeId:l(),sessionsNow:n(),sessionsStarted:n(),observedShare:n().nullable(),peakSessions:n(),yieldsAway:n(),devices:S(sX).readonly()}),lX=b({deviceId:n(),deviceKey:l(),reason:x([`disabled`,`absent`])}),uX=b({policy:rX,windowMs:n(),observedForMs:n(),sessionsNow:n(),clusterPeakSessions:n(),nodes:S(cX).readonly(),stalePins:S(lX).readonly()}),dX=x([`hardware`,`benchmark`]),fX=x([`no-benchmark-results`,`partial-benchmark-results`]),pX=b({headroom:n().min(.3).max(.5).default(.4),source:dX.default(`hardware`)}),mX=b({deviceKey:l(),share:n(),modelId:l().nullable(),fps:n().nullable(),measured:v(),suggestedMaxSessions:n().nullable()}),hX=b({nodeId:l(),share:n().nullable(),capacitySessions:n(),devices:S(mX).readonly(),skippedReason:l().nullable(),capacitySource:dX.nullable(),capacityFallback:fX.nullable()}),gX=b({headroom:n(),source:dX,cameraFps:n(),minSessionsPerDevice:n(),nodes:S(hX).readonly()}),_X=x([`hardware`,`benchmark`,`manual`]),vX=`benchmark`;function yX(e){return e!==`manual`}var Ake=.4,jke=`shareSource`;function Mke(e){if(e===`auto`)return`hardware`;let t=_X.safeParse(e);return t.success?t.data:vX}var bX=b({source:_X}),Nke=b({nodes:m(l(),n()),devices:m(l(),m(l(),n()))}),xX=b({deviceKey:l(),eligible:v(),configuredPct:n(),effectivePct:n()}),SX=b({nodeId:l(),eligible:v(),configuredPct:n(),effectivePct:n(),capacitySource:dX.nullable(),capacityFallback:fX.nullable(),devices:S(xX).readonly()}),CX=b({source:_X,policy:rX,autoPending:v(),computedAt:n().nullable(),trigger:l().nullable(),nodes:S(SX).readonly(),nodeWeights:m(l(),n()),deviceWeights:m(l(),m(l(),n()))}),wX=[`motion-without-detections`,`detections-under-floor`,`inference-too-slow`,`frames-shed`,`inference-device-unusable`],TX=x(wX),EX=x([`info`,`warning`,`critical`]),DX=i(`type`,[b({type:p(`camera`),deviceId:n()}),b({type:p(`node`),nodeId:l()}),b({type:p(`inference-device`),nodeId:l(),deviceKey:l()})]),OX=b({id:l(),kind:TX,severity:EX,subject:DX,what:l(),evidence:m(l(),n().nullable()),action:l()}),kX=b({source:l(),entries:n().nullable()}),AX=b({nodeId:l(),sessionsNow:n(),unusableDevices:S(l()).readonly(),devices:S(b({deviceKey:l(),sessionsNow:n(),usable:v()})).readonly()}),jX=b({deviceId:n(),nativeCropMissesSincePreviousTick:n().nullable()}),MX=b({generatedAt:n(),tickMs:n(),camerasSeen:n().nullable(),findings:S(OX).readonly(),cameraSignals:S(jX).readonly(),nodes:S(AX).readonly(),sources:S(kX).readonly(),notCovered:S(l()).readonly()}),NX=b({history:n().int().min(1).max(24).default(1)}),PX=b({latest:MX.nullable(),previous:S(MX).readonly()}),Pke=b({engine:gW.optional(),steps:S(Ha).readonly(),audio:b({engine:gW.optional(),modelId:l().optional(),enabled:v(),settings:m(l(),C()).readonly().optional()}).nullable().optional()}),FX=b({modelId:l().optional(),settings:m(l(),C()).optional(),jumpDeviceKey:l().optional(),enabled:v().optional()}),IX=b({maxCameras:n().int().nonnegative().nullable().default(null),detectWeight:n().positive().optional(),detect:v().optional(),decode:v().optional(),audio:v().optional(),ingest:v().optional(),decodeBudgetMb:n().int().min(1024).max(65536).optional(),maxLiveDecodeWorkers:n().int().min(1).max(32).optional(),reachableHost:l().optional(),color:Ll.optional(),stepSettings:m(l(),m(l(),C()).readonly()).optional(),stepEnabled:m(l(),v()).optional(),inferenceDevices:m(l(),b({enabled:v(),weight:n().positive().optional(),maxSessions:n().int().positive().optional(),steps:m(l(),FX).optional()})).optional()}),Fke=m(l(),m(l(),C()).readonly()),LX=x([`pipeline`,`onboard`,`none`]),Ike=b({stepToggles:m(l(),v()).optional(),stepSettings:Fke.optional()}),RX=b({deviceId:n(),agentNodeId:l(),pinned:v(),reason:x([`manual`,`capacity`,`hardware-affinity`,`failover`,`rebalance`]),assignedAt:n()}),zX=b({nodeId:l(),online:v(),load:OG,score:n(),decodeHwaccel:l().nullable()}),BX=b({totalAgents:n(),onlineAgents:n(),totalCameras:n(),attachedCameras:n(),activeCameras:n(),avgInferenceTimeMs:n(),queueDepth:n()}),VX=m(l(),l()),HX=b({ownerNodeId:l(),reachableHost:l().optional(),configIssue:l().optional()}),UX=b({camStreamId:l(),codec:l(),width:n(),height:n(),fps:n(),kind:l()}),WX=b({streams:S(UX).readonly()}),GX=b({detectionNodeId:l().nullable(),decoderNodeId:l().nullable(),audioNodeId:l().nullable(),sourceNodeId:l().nullable(),pinned:b({detection:v(),decoder:v(),audio:v()}),reasons:b({detection:l().optional(),decoder:l().optional(),audio:l().optional()})}),KX=b({profile:l(),status:l(),codec:l(),width:n(),height:n(),subscribers:n(),inFps:n().nullable()}),qX=b({profiles:S(KX).readonly(),webrtcSessions:n(),rtspRestream:v()}),JX=b({nodeId:l()}),YX=b({enabled:v(),fps:n()}),XX=x([`idle`,`installing`,`verifying`,`ready`,`failed`]),ZX=b({state:XX,error:l().optional()}),QX=x([`idle`,`watching`,`active`]),$X=b({nodeId:l(),engine:b({backend:l(),device:l()}),phase:QX,configuredFps:n(),actualFps:n(),queueDepth:n(),avgInferenceMs:n(),provisioning:ZX}),eZ=b({nodeId:l(),enabled:v()}),tZ=om,nZ=b({mode:tZ,active:v(),storageBytes:n()}),rZ=x([`source`,`broker`,`detection`,`recording`,`switches`]),iZ=x([`timeout`,`error`,`partial`]),aZ=b({stage:rZ,reason:iZ,elapsedMs:n()}),oZ=b({state:x([`idle`,`running`,`done`,`error`]),total:n().int().nonnegative(),completed:n().int().nonnegative(),currentDeviceId:n().int().nullable(),failed:S(n().int()).readonly(),mediaDropped:n().int().nonnegative(),tracks:n().int().nonnegative(),events:n().int().nonnegative(),startedAtMs:n().int().nullable(),finishedAtMs:n().int().nullable(),error:l().nullable()}),sZ=b({deviceId:n(),assignment:GX,source:WX,broker:qX.nullable(),decoder:JX.nullable(),motion:YX.nullable(),detection:$X.nullable(),audio:eZ.nullable(),recording:nZ.nullable(),switchedOff:S(Qd).readonly(),cameraSensors:JV.optional(),degraded:S(aZ).readonly(),fetchedAt:n()}),cZ=[`disabled`,`unavailable`,`cannot-host-camera-root`,`accelerator-preferred`,`root-switched-off`,`no-gpu-device`],lZ=x(cZ),Lke=b({key:l(),backend:l(),device:l(),format:x(Pa),available:v(),presence:x([`present`,`absent`,`unknown`]).optional(),enabled:v(),weight:n(),maxSessions:n().nullable(),defaultModelId:l(),steps:m(l(),FX).optional(),exclusion:lZ.nullable()}),uZ=i(`kind`,[b({kind:p(`stored`),modelId:l()}),b({kind:p(`absent`),defaultModelId:l()}),b({kind:p(`unreadable`),reason:x(sH),error:l().optional()})]),Rke=b({nodeId:l(),reachable:v(),devices:S(Lke).readonly(),defaultPoolExcluded:v().optional()}),dZ=x([`off`,`on`,`opt-in`]),fZ=i(`kind`,[b({kind:p(`on`)}),b({kind:p(`off-cluster`)}),b({kind:p(`off-node`)}),b({kind:p(`off-device`)}),b({kind:p(`jump`),toDeviceKey:l()}),b({kind:p(`skip`),reason:x([`no-compatible-model`,`root-not-runnable-on-elected-device`])}),b({kind:p(`zone-driven`)}),b({kind:p(`supplied-by-root`),rootModelId:l()}),b({kind:p(`opt-in-unused`)})]),zke=b({deviceKey:l(),format:x(Pa),stepEnabled:v().nullable(),eligible:v(),cell:fZ}),Bke=b({nodeId:l(),reachable:v(),stepEnabled:v().nullable(),devices:S(zke).readonly()}),pZ=b({steps:S(b({stepId:l(),name:l(),slot:l(),clusterMode:dZ.nullable(),effectiveMode:dZ,camerasEnabling:n().int().nonnegative(),camerasDisabling:n().int().nonnegative(),nodes:S(Bke).readonly()})).readonly()}),mZ=b({deviceId:n().int().nonnegative(),config:VV.nullable()}),hZ=x([`unknown-camera`,`out-of-range`,`no-burst-producer`,`already-looked`]),gZ=b({deviceId:n().int().nonnegative(),afterMs:n().finite(),reason:l()}),_Z=b({scheduled:v(),dueInMs:n().optional(),refusedBecause:hZ.optional()}),vZ={name:`pipeline-orchestrator`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,exposesDeviceSettings:!0,methods:{requestOccupancyLook:k(gZ,_Z,{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:k(wm,b({paused:p(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:k(wm,b({resumed:p(!0)}),{kind:`mutation`,auth:`admin`}),assignPipeline:k(b({deviceId:n(),agentNodeId:l()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),unassignPipeline:k(b({deviceId:n()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setPipelineDevicePin:k(b({deviceId:n(),deviceKey:l()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getPipelineDevicePin:k(b({deviceId:n()}),b({deviceKey:l().nullable()})),rebalance:k(_(),b({migrated:n(),skipped:S(b({deviceId:n(),targetNodeId:l(),reason:l()})).default([])}),{kind:`mutation`,auth:`admin`}),getPipelineAssignments:k(_(),S(RX).readonly()),getPipelineAssignment:k(b({deviceId:n()}),RX.nullable()),getAgentLoad:k(_(),S(zX).readonly()),getClusterModelChoice:k(b({stepId:l()}),uZ),getGlobalMetrics:k(_(),BX),getCameraMetrics:k(b({deviceId:n()}),CW.nullable()),getCapabilityBindings:k(b({nodeId:l()}),VX),setCapabilityBinding:k(b({nodeId:l(),capName:l(),addonId:l()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getIngestOwner:k(_(),HX),assignAudio:k(b({deviceId:n(),nodeId:l()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),unassignAudio:k(b({deviceId:n()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getAudioAssignment:k(b({deviceId:n()}),b({nodeId:l(),pinned:v(),assignedAt:n()}).nullable()),getAudioNodeLoad:k(_(),S(b({nodeId:l(),deviceCount:n()}))),getAudioAssignments:k(_(),S(b({deviceId:n(),nodeId:l(),pinned:v(),assignedAt:n()}))),getAgentSettings:k(b({agentNodeId:l()}),IX.nullable()),listAgentSettings:k(_(),S(b({nodeId:l(),settings:IX})).readonly()),removeAgentSettings:k(b({agentNodeId:l()}),b({success:v(),removed:v()}),{kind:`mutation`,auth:`admin`}),setAgentMaxCameras:k(b({agentNodeId:l(),maxCameras:n().int().nonnegative().nullable()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setAgentCapabilities:k(b({agentNodeId:l(),detect:v().nullable().optional(),audio:v().nullable().optional(),ingest:v().nullable().optional()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setAgentDecodeLimits:k(b({agentNodeId:l(),decodeBudgetMb:n().int().min(1024).max(65536).nullable().optional(),maxLiveDecodeWorkers:n().int().min(1).max(32).nullable().optional()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setAgentReachableHost:k(b({agentNodeId:l(),reachableHost:l().nullable().optional(),color:Ll.nullable().optional()}).refine(e=>e.reachableHost!==void 0||e.color!==void 0,{message:`reachableHost or color required`}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setAgentInferenceDevices:k(b({agentNodeId:l(),inferenceDevices:m(l(),b({enabled:v(),weight:n().positive().optional(),maxSessions:n().int().positive().optional(),steps:m(l(),FX).optional()}))}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setNodeStepSettings:k(b({agentNodeId:l(),addonId:l(),settings:m(l(),C()).nullable()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setClusterStepMode:k(b({stepId:l(),mode:dZ.nullable()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setNodeStepEnabled:k(b({agentNodeId:l(),stepId:l(),enabled:v().nullable()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setDeviceStepEnabled:k(b({agentNodeId:l(),deviceKey:l(),stepId:l(),enabled:v().nullable()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getStepSwitches:k(_(),pZ),getNodeInferenceDevices:k(b({nodeId:l()}),Rke),forgetInferenceDevice:k(b({agentNodeId:l(),deviceKey:l()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),resetNodePipelineDefaults:k(b({agentNodeId:l()}),b({success:p(!0),effectiveModelId:l().nullable()}),{kind:`mutation`,auth:`admin`}),planAutoTune:k(QY,$Y,{auth:`admin`}),applyAutoTune:k(eX,nX,{kind:`mutation`,auth:`admin`}),setLoadBalancingShares:k(aX,b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getPlacementStats:k(oX,uX,{auth:`admin`}),getHealthDigest:k(NX,PX,{auth:`admin`}),suggestShares:k(pX,gX,{auth:`admin`}),getEffectiveShares:k(_(),CX,{auth:`admin`}),setShareSource:k(bX,b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkPreflight:k(MW,LW,{auth:`admin`}),startNodeBenchmark:k(MW,i(`kind`,[b({kind:p(`started`),runId:l()}),b({kind:p(`refused`),preflight:LW})]),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkStatus:k(_(),QW,{auth:`admin`}),abortNodeBenchmark:k(b({runId:l()}),b({aborted:v()}),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkCandidates:k(b({nodeId:l()}),nG,{auth:`admin`}),listNodeBenchmarkResults:k(eG,S(tG).readonly(),{auth:`admin`}),deleteNodeBenchmarkResult:k(b({id:l()}),b({deleted:v()}),{kind:`mutation`,auth:`admin`}),getCameraSettings:k(b({deviceId:n()}),Ike.nullable()),setCameraStepToggle:k(b({deviceId:n(),addonId:l(),enabled:v().nullable()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getCameraDetectionSource:k(b({deviceId:n()}),b({source:LX,explicit:v(),onboard:b({available:v(),geometry:x([`boxed`,`while-streaming`,`flag-only`,`unknown`])})})),setCameraDetectionSource:k(b({deviceId:n(),source:LX}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setCameraStepSettings:k(b({deviceId:n(),addonId:l(),settings:m(l(),C()).nullable()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),resolvePipeline:k(b({deviceId:n(),agentNodeId:l().optional()}),Pke),getCameraSwitches:k(b({deviceId:n()}),af,{role:`viewer`}),setCameraSwitch:k(b({deviceId:n(),switchId:Qd,enabled:v()}),af,{kind:`mutation`,auth:`admin`}),getCameraStatus:k(b({deviceId:n()}),sZ),getCameraStatuses:k(b({deviceIds:S(n()).optional()}),S(sZ).readonly()),setCameraSensors:k(mZ,b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),reconcileFromDisk:k(_(),oZ,{kind:`mutation`,auth:`admin`}),getReconcileFromDiskStatus:k(_(),oZ,{auth:`admin`})},vocabulary:{notOperatorFacing:j.PIPELINE}},yZ=b({id:l(),name:l(),sampleCount:n().int().nonnegative(),coverMediaId:n().int().optional(),coverBase64:l().optional()}),Vke=b({id:l(),text:l(),score:n(),addedAt:n().int(),deviceId:n().int().optional(),base64:l().optional(),mediaId:n().int().optional(),keyFrameMediaId:n().int().optional(),plateBbox:aC.optional()}),bZ=b({plateId:l(),deviceId:n().int(),trackId:l(),timestamp:n().int(),text:l(),score:n(),corrected:v(),recognizedVehicleId:l().optional(),vehicleName:l().optional(),assigned:v(),plateBbox:aC.optional(),keyFrameMediaId:n().int().optional(),base64:l().optional(),cropUrl:l().optional(),cropMissReason:l().optional()}),Hke=b({mediaId:n().int(),kind:l(),url:l(),sizeBytes:n(),timestamp:n()}),Uke=b({plateIds:S(l()).readonly(),representativePlateId:l(),representativeText:l(),size:n().int(),cohesion:n()}),xZ={name:`plate-gallery`,role:{feature:`plate-assignment`},scope:`system`,mode:`singleton`,methods:{listPlates:k(b({deviceId:n().int().optional(),limit:n().int().positive().optional(),includeCrops:v().optional()}).optional(),S(bZ).readonly()),getPlateByTrack:k(b({deviceId:n().int(),trackId:l()}),bZ.nullable(),{role:`viewer`}),getPlateMedia:k(b({plateId:l()}),S(Hke).readonly()),searchPlates:k(b({text:l().min(1),maxDistance:n().int().min(0).optional(),limit:n().int().positive().optional(),includeCrops:v().optional()}),S(bZ).readonly()),suggestPlateClusters:k(b({maxDistance:n().int().min(0).optional(),minClusterSize:n().int().min(2).optional(),limit:n().int().positive().optional()}).optional(),S(Uke).readonly()),correctPlateText:k(b({plateId:l(),text:l().min(1)}),_(),{kind:`mutation`,auth:`admin`}),deletePlate:k(b({plateId:l()}),_(),{kind:`mutation`,auth:`admin`}),listVehicles:k(b({includeCrops:v().optional()}).optional(),S(yZ).readonly()),createVehicle:k(b({name:l().min(1)}),yZ,{kind:`mutation`,auth:`admin`}),renameVehicle:k(b({id:l(),name:l().min(1)}),_(),{kind:`mutation`,auth:`admin`}),deleteVehicle:k(b({id:l()}),_(),{kind:`mutation`,auth:`admin`}),listVehicleSamples:k(b({vehicleId:l()}),S(Vke).readonly()),removeVehicleSample:k(b({vehicleId:l(),sampleId:l()}),_(),{kind:`mutation`,auth:`admin`}),moveVehicleSample:k(b({sampleId:l().min(1),toVehicleId:l().min(1)}),_(),{kind:`mutation`,auth:`admin`}),assignPlate:k(b({plateId:l(),vehicleId:l()}),_(),{kind:`mutation`,auth:`admin`}),unassignPlate:k(b({plateId:l()}),_(),{kind:`mutation`,auth:`admin`}),assignPlates:k(b({plateIds:S(l()).min(1),vehicleId:l()}),b({assigned:n().int(),failed:S(l()).readonly()}),{kind:`mutation`,auth:`admin`}),unassignPlates:k(b({plateIds:S(l()).min(1)}),b({unassigned:n().int(),failed:S(l()).readonly()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`the plate gallery — curated on its own page`}},SZ={"intel-core-ultra":{"intel-npu":{"yolov9t-320":{p50Ms:2.9,fps:383,measured:!0},"yolov9t-320-int8":{p50Ms:3.8,fps:333,measured:!0},"yolov9t-640":{p50Ms:7.4,fps:139,measured:!0},"yolov9t-640-int8":{p50Ms:7.5,fps:144,measured:!0},"yolov9s-320":{p50Ms:4.4,fps:241,measured:!0},"yolov9s-320-int8":{p50Ms:4.1,fps:264,measured:!0},"yolov9s-640":{p50Ms:12.7,fps:82,measured:!0},"yolov9s-640-int8":{p50Ms:10.7,fps:99,measured:!0},"yolov9m-320":{p50Ms:8.4,fps:123,measured:!0},"yolov9m-320-int8":{p50Ms:6.5,fps:165,measured:!0},"yolov9m-640":{p50Ms:29.5,fps:32,measured:!0},"yolov9m-640-int8":{p50Ms:19.5,fps:52,measured:!0}},"intel-igpu":{"yolov9t-320":{p50Ms:2.6,fps:405,measured:!0},"yolov9t-320-int8":{p50Ms:2.8,fps:324,measured:!0},"yolov9t-640":{p50Ms:6.5,fps:157,measured:!0},"yolov9t-640-int8":{p50Ms:5.6,fps:185,measured:!0},"yolov9s-320":{p50Ms:4.6,fps:200,measured:!0},"yolov9s-320-int8":{p50Ms:4.1,fps:239,measured:!0},"yolov9s-640":{p50Ms:15.2,fps:69,measured:!0},"yolov9s-640-int8":{p50Ms:10.5,fps:99,measured:!0},"yolov9m-320":{p50Ms:11.4,fps:88,measured:!0},"yolov9m-320-int8":{p50Ms:7,fps:127,measured:!0},"yolov9m-640":{p50Ms:40,fps:25,measured:!0},"yolov9m-640-int8":{p50Ms:23.5,fps:44,measured:!0}},"x86-cpu":{"yolov9t-320":{p50Ms:6.9,fps:145,measured:!0},"yolov9t-320-int8":{p50Ms:2.7,fps:405,measured:!0},"yolov9t-640":{p50Ms:23,fps:44,measured:!0},"yolov9t-640-int8":{p50Ms:8.8,fps:124,measured:!0},"yolov9s-320":{p50Ms:15.8,fps:63,measured:!0},"yolov9s-320-int8":{p50Ms:6.5,fps:180,measured:!0},"yolov9s-640":{p50Ms:58.2,fps:17,measured:!0},"yolov9s-640-int8":{p50Ms:20.1,fps:52,measured:!0},"yolov9m-320":{p50Ms:40,fps:25,measured:!0},"yolov9m-320-int8":{p50Ms:14.2,fps:74,measured:!0},"yolov9m-640":{p50Ms:155.8,fps:6,measured:!0},"yolov9m-640-int8":{p50Ms:52.4,fps:19,measured:!0}},coral:{"yolov9s-320-edgetpu":{p50Ms:32,fps:31,measured:!1}}},"intel-n-series":{"intel-igpu":{"yolov9t-320":{p50Ms:15,fps:48,measured:!0},"yolov9t-320-int8":{p50Ms:14.1,fps:67,measured:!0},"yolov9t-640":{p50Ms:38.5,fps:26,measured:!0},"yolov9t-640-int8":{p50Ms:50,fps:20,measured:!0},"yolov9s-320":{p50Ms:41.4,fps:24,measured:!0},"yolov9s-320-int8":{p50Ms:23.3,fps:34,measured:!0},"yolov9s-640":{p50Ms:127.4,fps:8,measured:!0},"yolov9s-640-int8":{p50Ms:81,fps:12,measured:!0},"yolov9m-320":{p50Ms:63.5,fps:16,measured:!0},"yolov9m-320-int8":{p50Ms:66,fps:15,measured:!0},"yolov9m-640":{p50Ms:215.5,fps:5,measured:!0},"yolov9m-640-int8":{p50Ms:163,fps:6,measured:!0}},"x86-cpu":{"yolov9t-320":{p50Ms:86.2,fps:12,measured:!0},"yolov9t-320-int8":{p50Ms:52.7,fps:20,measured:!0},"yolov9t-640":{p50Ms:322.1,fps:3,measured:!0},"yolov9t-640-int8":{p50Ms:205.6,fps:5,measured:!0},"yolov9s-320":{p50Ms:164.4,fps:6,measured:!0},"yolov9s-320-int8":{p50Ms:86.9,fps:12,measured:!0},"yolov9s-640":{p50Ms:341.3,fps:3,measured:!0},"yolov9s-640-int8":{p50Ms:185.3,fps:5,measured:!0},"yolov9m-320":{p50Ms:166.8,fps:6,measured:!0},"yolov9m-320-int8":{p50Ms:226.3,fps:4,measured:!0},"yolov9m-640":{p50Ms:663.5,fps:2,measured:!0},"yolov9m-640-int8":{p50Ms:324.4,fps:3,measured:!0}},coral:{"yolov9s-320-edgetpu":{p50Ms:32,fps:31,measured:!1}}},"amd-phoenix":{"x86-cpu":{"yolov9t-320":{p50Ms:24,fps:42,measured:!0},"yolov9t-320-int8":{p50Ms:12,fps:83,measured:!0},"yolov9t-640":{p50Ms:50,fps:20,measured:!0},"yolov9t-640-int8":{p50Ms:20,fps:50,measured:!0},"yolov9s-320":{p50Ms:30,fps:33,measured:!0},"yolov9s-320-int8":{p50Ms:15,fps:67,measured:!0},"yolov9s-640":{p50Ms:92,fps:11,measured:!0},"yolov9s-640-int8":{p50Ms:27,fps:37,measured:!0},"yolov9m-320":{p50Ms:67,fps:15,measured:!0},"yolov9m-320-int8":{p50Ms:21,fps:48,measured:!0},"yolov9m-640":{p50Ms:229,fps:4,measured:!0},"yolov9m-640-int8":{p50Ms:48,fps:21,measured:!0}},"amd-igpu":{"yolov9t-320":{p50Ms:40,fps:25,measured:!0},"yolov9t-640":{p50Ms:89,fps:11,measured:!0},"yolov9s-320":{p50Ms:65,fps:15,measured:!0},"yolov9s-640":{p50Ms:125,fps:8,measured:!0},"yolov9m-320":{p50Ms:85,fps:12,measured:!0},"yolov9m-640":{p50Ms:228,fps:4,measured:!0}},coral:{"yolov9s-320-edgetpu":{p50Ms:32,fps:31,measured:!0}}},"apple-m-pro":{"apple-ane":{"yolov9t-320":{p50Ms:1.1,fps:952,measured:!0},"yolov9t-640":{p50Ms:3,fps:333,measured:!0},"yolov9s-320":{p50Ms:1.5,fps:667,measured:!0},"yolov9s-640":{p50Ms:5.1,fps:196,measured:!0},"yolov9m-320":{p50Ms:3.2,fps:312,measured:!0},"yolov9m-640":{p50Ms:10.2,fps:98,measured:!0}},coral:{"yolov9s-320-edgetpu":{p50Ms:32,fps:31,measured:!1}}},"apple-m-base":{"apple-ane":{"yolov9t-320":{p50Ms:1.32,fps:758,measured:!1},"yolov9t-640":{p50Ms:3.45,fps:290,measured:!0},"yolov9s-320":{p50Ms:1.8,fps:556,measured:!1},"yolov9s-640":{p50Ms:5.46,fps:183,measured:!0},"yolov9m-320":{p50Ms:3.79,fps:264,measured:!0},"yolov9m-640":{p50Ms:10.34,fps:97,measured:!0}},coral:{"yolov9s-320-edgetpu":{p50Ms:32,fps:31,measured:!1}}}},CZ={"yolov9m-320":{personPrecision:.979,personRecall:.649},"yolov9m-320-int8":{personPrecision:.974,personRecall:.684},"yolov9m-640":{personPrecision:.976,personRecall:.854},"yolov9m-640-int8":{personPrecision:.976,personRecall:.847},"yolov9s-320":{personPrecision:.958,personRecall:.479},"yolov9s-320-int8":{personPrecision:.969,personRecall:.438},"yolov9s-640":{personPrecision:.986,personRecall:.753},"yolov9s-640-int8":{personPrecision:.963,personRecall:.823},"yolov9t-320":{personPrecision:.946,personRecall:.368},"yolov9t-320-int8":{personPrecision:.943,personRecall:.347},"yolov9t-640":{personPrecision:.979,personRecall:.646},"yolov9t-640-int8":{personPrecision:.979,personRecall:.646}},wZ=.5,Wke=2,Gke=.05,Kke=24,qke=750,Jke=64,TZ=2e3,Yke=12,EZ=n().nullable().transform(e=>e!==null&&Number.isFinite(e)&&e>0?e:null),DZ=l().nullable().transform(e=>e!==null&&e.trim()!==``?e:null),OZ=b({int8:EZ,fp16:EZ}),kZ=b({deviceKey:l(),fullDeviceName:DZ,executionUnits:EZ,clockMHz:EZ,gops:OZ.nullable(),architecture:DZ,npuName:DZ,tops:EZ,vendor:DZ,webgpuArchitecture:DZ,webgpuDevice:DZ,computeUnits:EZ}),Xke=b({accelerators:S(kZ).nullable()}),AZ=[{hardwareClass:`intel-n-series`,accelerator:`intel-igpu`,score:{metric:`eu-mhz`,value:24*750}},{hardwareClass:`intel-core-ultra`,accelerator:`intel-igpu`,score:{metric:`eu-mhz`,value:64*TZ}},{hardwareClass:`amd-phoenix`,accelerator:`amd-igpu`,score:{metric:`cu`,value:12}}];function Zke(e){let t=Xke.safeParse(e);return!t.success||t.data.accelerators===null?null:t.data.accelerators}function jZ(e){return e!==null&&e>0?e:null}function MZ(e){let t=[],n=jZ(e.gops?.int8??null);n!==null&&t.push({metric:`gops-int8`,value:n});let r=jZ(e.gops?.fp16??null);r!==null&&t.push({metric:`gops-fp16`,value:r});let i=jZ(e.executionUnits),a=jZ(e.clockMHz);i!==null&&a!==null&&t.push({metric:`eu-mhz`,value:i*a});let o=jZ(e.computeUnits);o!==null&&t.push({metric:`cu`,value:o});let s=jZ(e.tops);return s!==null&&t.push({metric:`tops`,value:s}),t}function NZ(e,t,n){let r=n.filter(n=>n.accelerator===e&&n.score.metric===t.metric&&n.score.value>0),i=r[0];return i===void 0?null:r.reduce((e,n)=>Math.abs(Math.log(t.value/n.score.value))<Math.abs(Math.log(t.value/e.score.value))?n:e,i)}function PZ(e,t,n){for(let r of MZ(e))if(NZ(t,r,n)!==null)return r;return null}function FZ(e,t,n=AZ){return PZ(e,t,n)!==null}function IZ(e,t,n){if(t!==`unknown`)return e[t]?.[n]}function Qke(e){return Math.round(e*10)/10}function $ke(e){return Math.min(2,Math.max(wZ,e))}function eAe(e,t,n){let r={};for(let[i,a]of Object.entries(e))r[i]={p50Ms:Qke(a.p50Ms/t),fps:Math.max(1,Math.round(a.fps*t)),measured:!1,estimatedFrom:n};return r}function LZ(e){let t=e.perf??SZ,n=e.references??AZ,r=IZ(t,e.hardwareClass,e.accelerator);if(r!==void 0&&e.hardwareClass!==`intel-n-series`)return{column:r,estimatedFrom:null};let i=e.report===null?null:PZ(e.report,e.accelerator,n);if(i===null)return r===void 0?null:{column:r,estimatedFrom:null};let a=NZ(e.accelerator,i,n),o=a===null?void 0:IZ(t,a.hardwareClass,e.accelerator);if(a===null||o===void 0)return r===void 0?null:{column:r,estimatedFrom:null};let s=i.value/a.score.value;return e.hardwareClass===a.hardwareClass&&Math.abs(s-1)<=.05?{column:o,estimatedFrom:null}:{column:eAe(o,$ke(s),a.hardwareClass),estimatedFrom:a.hardwareClass}}var RZ=x(Pa),tAe=x([`videotoolbox`,`cuda`,`nvdec`,`vaapi`,`qsv`,`d3d11va`,`dxva2`,`amf`,`vdpau`,`drm`,`coreml`,`tensorrt`,`openvino`,`directml`,`webgpu`,`none`]).nullable().optional(),nAe=b({preferred:S(l()).readonly(),rationale:l()}),zZ=x([`h264_videotoolbox`,`hevc_videotoolbox`,`h264_vaapi`,`hevc_vaapi`,`h264_nvenc`,`hevc_nvenc`,`h264_qsv`,`hevc_qsv`,`h264_amf`,`hevc_amf`,`libx264`,`libx265`]);b({encoders:S(b({encoder:zZ,codec:x([`H264`,`H265`]),family:x([`videotoolbox`,`vaapi`,`nvenc`,`qsv`,`amf`,`software`]),available:v(),reason:l().optional()})).readonly(),defaultH264:zZ,defaultH265:zZ,probedAt:n()}),b({methods:S(l()).readonly(),probedAt:n()});var rAe=x([`darwin`,`linux`,`win32`]),iAe=x([`arm64`,`x64`]),aAe=b({type:x([`nvidia`,`amd`,`intel`,`apple`]),name:l(),memoryMB:n().optional()}),oAe=b({type:x([`apple-ane`,`intel-npu`,`amd-xdna`]),name:l().optional(),generation:x([`xdna1`,`xdna2`]).optional()}),BZ=x([`usb`,`pci`]),sAe=b({type:p(`coral-edgetpu`),bus:l().optional(),count:n().int().nonnegative().optional(),units:S(b({bus:BZ,count:n().int().nonnegative()})).readonly().optional(),unavailable:S(b({bus:BZ,count:n().int().nonnegative(),reason:x([`driver-missing`,`device-not-accessible`])})).readonly().optional()}),VZ=b({type:p(`nvidia`),name:l(),memoryMB:n().optional()}),cAe=i(`usable`,[VZ.extend({usable:p(!0)}),VZ.extend({usable:p(!1),reason:x([`no-cuda-execution-provider`])})]),HZ=b({platform:rAe,arch:iAe,cpuModel:l(),cpuCores:n(),totalRAM_MB:n(),availableRAM_MB:n(),gpu:aAe.nullable(),npu:oAe.nullable(),coral:sAe.nullable().optional(),nvidia:cAe.nullable().optional(),accelerators:S(kZ).readonly().optional()}),UZ=b({runtime:p(`python`),backend:l(),format:x([`onnx`,`coreml`,`openvino`,`tflite`]),score:n(),reason:l(),available:v()}),WZ=b({key:l(),backend:l(),device:l(),format:RZ,runtime:p(`python`),score:n(),available:v()}),lAe=b({hardware:HZ,scores:S(UZ).readonly(),bestScore:UZ,pythonPath:l().nullable(),devices:S(WZ).readonly()}),uAe=b({modelId:l(),name:l(),minRAM_MB:n(),accuracyScore:n(),formats:S(l()).readonly()}),dAe=b({modelId:l(),runtime:p(`python`),backend:l(),format:RZ,reason:l()}),fAe=b({devices:S(WZ).readonly(),appeared:S(l()).readonly(),disappeared:S(l()).readonly(),usbBus:x([`observed`,`unobservable`]),decidedBy:x([`usb-ids`,`pci`,`delegate-fallback`,`none`])}),GZ={name:`platform-probe`,scope:`system`,mode:`singleton`,methods:{getCapabilities:k(_(),lAe),getHardware:k(_(),HZ),resolveInferenceConfig:k(b({requirements:S(uAe).readonly()}),dAe),resolveHwAccel:k(b({prefer:tAe}),nAe),rescanAccelerators:k(_(),fAe,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:j.CLUSTER}},KZ=b({power:n().optional().meta(M(`power`,{label:`Power`})),deliveredPower:n().optional().meta(M(`power`,{label:`Delivered`})),energy:n().optional().meta(M(`energy`,{label:`Energy`})),voltage:n().optional().meta(M(`voltage`,{label:`Voltage`})),current:n().optional().meta(M(`current`,{label:`Current`})),apparentPower:n().optional().meta(M(`apparent-power`)),powerFactor:n().min(0).max(1).optional().meta(M(`ratio`)),lastFetchedAt:n()});function pAe(e){if(e.power===void 0)return;let t=e.power-(e.deliveredPower??0);return t<0?void 0:t}var qZ=[T.Sensor,T.Switch,T.Light,T.Fan,T.Climate,T.Humidifier,T.WaterHeater,T.MediaPlayer,T.Washer,T.Dryer,T.Dishwasher,T.Vacuum,T.LawnMower,T.PetFeeder,T.Workload],mAe=qZ.filter(e=>e!==T.Sensor);function JZ(e,t){return{id:e,cardinality:`scalar`,vocabulary:{cap:`power-meter`,stateField:e},deviceTypes:mAe,apply:`add`,path:e,sources:[{kind:`numeric`,requiredUnit:t,transforms:[{kind:`identity`}]}],companions:[{kind:`clock`,path:`lastFetchedAt`,when:`always`}],sourceReport:{status:`assignment-status`},advancedExpression:!0}}var hAe={version:1,targets:[JZ(`power`,`W`),JZ(`energy`,`kWh`),JZ(`voltage`,`V`),JZ(`current`,`A`)]},YZ={name:`power-meter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:qZ,deviceConfig:{ui:{kind:`widget`,widgetId:`host/power-meter-line`,tab:`power`,placement:`hero`,label:`Power`,order:4}},methods:{},status:{schema:KZ,kind:`push`},runtimeState:KZ,durability:`restored`,history:{primary:`power`,priority:80,fields:{power:{kind:`gauge`,unit:`W`,deadband:1,minIntervalMs:3e4},energy:{kind:`counter`,unit:`kWh`,deadband:.01,minIntervalMs:6e4},voltage:{kind:`gauge`,unit:`V`,deadband:1,minIntervalMs:3e4},current:{kind:`gauge`,unit:`A`,deadband:.05,minIntervalMs:3e4},apparentPower:{kind:`gauge`,unit:`VA`,deadband:1,minIntervalMs:3e4},powerFactor:{kind:`gauge`,unit:`ratio`,deadband:.01,minIntervalMs:6e4}}},volatileStateFields:[`lastFetchedAt`],customize:hAe,vocabulary:{noun:P(`Power meter`,`Misuratore di energia`),order:5160,state:[{kind:`numeric`,field:`power`,quantity:P(`the power draw`,`il consumo`),label:P(`Power`,`Potenza`),unit:`W`,icon:`zap`},{kind:`numeric`,field:`energy`,quantity:P(`the energy used`,`l’energia consumata`),label:P(`Energy`,`Energia`),unit:`kWh`,icon:`zap`},{kind:`numeric`,field:`voltage`,quantity:P(`the voltage`,`la tensione`),label:P(`Voltage`,`Tensione`),unit:`V`,icon:`zap`},{kind:`numeric`,field:`current`,quantity:P(`the current`,`la corrente`),label:P(`Current`,`Corrente`),unit:`A`,icon:`zap`}]}},gAe=b({latitude:n().min(-90).max(90).meta(M(`angle`)),longitude:n().min(-180).max(180).meta(M(`angle`)),accuracyMeters:n().nonnegative().meta(M(`length`))}),XZ=b({state:l(),location:l().nullable(),gps:gAe.nullable(),lastChangedAt:n()}),ZZ={name:`presence`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Presence],methods:{},status:{schema:XZ,kind:`push`},runtimeState:XZ,durability:`restored`,history:`none`,volatileStateFields:[`lastChangedAt`],vocabulary:{noun:P(`Presence`,`Presenza`),order:5170,state:[{kind:`value`,field:`state`,label:P(`Where`,`Posizione`),phrase:P(`When {device} is at {value}`,`Quando {device} è in {value}`),icon:`map-pin`}]}},QZ=b({pressure:n().nullable().meta(M(`pressure`,{precision:0})),lastFetchedAt:n()}),$Z={name:`pressure-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Sensor],methods:{},status:{schema:QZ,kind:`push`},runtimeState:QZ,durability:`restored`,history:{fields:{pressure:{kind:`gauge`,unit:`hPa`,deadband:.1}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:P(`Pressure`,`Pressione`),order:5180,state:[{kind:`numeric`,field:`pressure`,quantity:P(`the pressure`,`la pressione`),label:P(`Pressure`,`Pressione`),unit:`hPa`,icon:`gauge`}]}},eQ=i(`kind`,[eH,tH]),tQ=b({id:n(),enabled:v(),shape:eQ}),nQ=b({enabled:v(),regions:S(tQ).nullable(),audioEnabled:v().nullable(),lastFetchedAt:n()}),rQ=b({maxRegions:n(),supportedShapes:S(iH),polygonVertices:aH.optional(),supportsAudioMute:v()}),iQ=b({enabled:v().optional(),regions:S(tQ).optional()}),aQ={name:`privacy-mask`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/privacy-mask-grid`,tab:`image`,label:`Privacy Mask`}},methods:{getOptions:k(b({deviceId:n()}),rQ),setMask:k(b({deviceId:n(),patch:iQ}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`privacy.maskOn`,label:P(`Privacy mask on`,`Maschera privacy attiva`),phrase:P(`Cover the privacy zones of {device}`,`Oscura le zone private di {device}`),icon:`eye-off`,args:{patch:{enabled:!0}}},{id:`privacy.maskOff`,label:P(`Privacy mask off`,`Maschera privacy spenta`),phrase:P(`Uncover the privacy zones of {device}`,`Scopri le zone private di {device}`),icon:`eye`,args:{patch:{enabled:!1}}}]}),setAudioEnabled:k(b({deviceId:n(),enabled:v()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`privacy.micOn`,label:P(`Microphone on`,`Microfono attivo`),phrase:P(`Turn on the microphone of {device}`,`Attiva il microfono di {device}`),icon:`mic`,args:{enabled:!0}},{id:`privacy.micOff`,label:P(`Microphone off`,`Microfono spento`),phrase:P(`Turn off the microphone of {device}`,`Disattiva il microfono di {device}`),icon:`mic-off`,args:{enabled:!1}}]})},status:{schema:nQ,kind:`poll`},runtimeState:nQ,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:P(`Privacy`,`Privacy`),order:3210,state:[{kind:`boolean`,field:`enabled`,label:P(`Privacy mask`,`Maschera privacy`),whenTrue:P(`When the privacy mask of {device} is turned on`,`Quando si attiva la maschera privacy di {device}`),whenFalse:P(`When the privacy mask of {device} is turned off`,`Quando si disattiva la maschera privacy di {device}`),icon:`eye-off`},{kind:`boolean`,field:`audioEnabled`,label:P(`Microphone`,`Microfono`),whenTrue:P(`When the microphone of {device} is turned on`,`Quando si attiva il microfono di {device}`),whenFalse:P(`When the microphone of {device} is turned off`,`Quando si disattiva il microfono di {device}`),icon:`mic`}]}};function _Ae(e){return e.length===0?null:e.some(e=>e.audioEnabled)}var oQ=x([`home`,`day-mode`,`night-mode`,`day-night-auto`,`set-limits`,`save-limits`,`reboot`,`osd-menu`]),sQ=b({id:l(),name:l(),fn:oQ.nullable(),writable:v()}),cQ=b({pan:n().nullable(),tilt:n().nullable(),zoom:n().nullable()}),lQ=b({pan:n().optional(),tilt:n().optional(),zoom:n().optional(),speed:n().optional()}),uQ=cQ.extend({autofocus:v()}),dQ=b({hasPan:v(),hasTilt:v(),hasZoom:v(),supportsPresets:v(),maxPresets:n().optional(),hasAutofocus:v(),speedSteps:n().int().positive().nullable(),moveImpulseMs:n().int().positive().nullable()}),fQ=b({presetId:l().nullable(),source:x([`operator`,`firmware`,`native`,`none`])}),pQ=b({enabled:v(),seconds:n().int()}),mQ={name:`ptz`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/ptz-panel`,tab:`ptz`,topTab:!0,label:`PTZ`,order:0}},methods:{move:k(lQ.extend({deviceId:n()}),_(),{kind:`mutation`,notOperatorFacing:`a relative nudge from the live-view joystick; a fixed place is a preset`}),continuousMove:k(lQ.extend({deviceId:n()}),_(),{kind:`mutation`,notOperatorFacing:`joystick motion held until released — continuous, not a discrete step`}),goHome:k(b({deviceId:n()}),_(),{kind:`mutation`,actions:[{id:`ptz.goHome`,label:P(`PTZ go home`,`Torna alla posizione iniziale`),phrase:P(`Send {device} to its home position`,`Riporta {device} alla posizione iniziale`),icon:`house`}]}),getPresets:k(b({deviceId:n()}),S(sQ)),goToPreset:k(b({deviceId:n(),presetId:l()}),_(),{kind:`mutation`,actions:[{id:`ptz.goToPreset`,label:P(`PTZ go to preset`,`Vai a un preset`),phrase:P(`Move {device} to {presetId}`,`Sposta {device} su {presetId}`),icon:`move`,openArgs:[{key:`presetId`,label:P(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}}]}]}),savePreset:k(b({deviceId:n(),presetId:l(),name:l()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.savePreset`,label:P(`Save PTZ preset here`,`Salva qui un preset`),phrase:P(`Save where {device} points now as preset {presetId} ({name})`,`Salva la posizione attuale di {device} come preset {presetId} ({name})`),icon:`bookmark-plus`,openArgs:[{key:`presetId`,label:P(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}},{key:`name`,label:P(`Name`,`Nome`),offer:{kind:`text`}}]}]}),deletePreset:k(b({deviceId:n(),presetId:l()}),_(),{kind:`mutation`,auth:`admin`}),getOptions:k(b({deviceId:n()}),dQ),stop:k(b({deviceId:n()}),_(),{kind:`mutation`,actions:[{id:`ptz.stop`,label:P(`Stop moving`,`Ferma il movimento`),phrase:P(`Stop {device} moving`,`Ferma il movimento di {device}`),icon:`square`}]}),getHomePreset:k(b({deviceId:n()}),fQ),setHomePreset:k(b({deviceId:n(),presetId:l().nullable()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.setHomePreset`,label:P(`Set PTZ home preset`,`Imposta il preset iniziale`),phrase:P(`Make {presetId} the home position of {device}`,`Rendi {presetId} la posizione iniziale di {device}`),icon:`house`,openArgs:[{key:`presetId`,label:P(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}}]}]}),captureHomeHere:k(b({deviceId:n()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.captureHomeHere`,label:P(`Set PTZ home here`,`Imposta qui la posizione iniziale`),phrase:P(`Make where {device} points now its home position`,`Rendi la posizione attuale di {device} la sua posizione iniziale`),icon:`map-pin`}]}),getHomeReturn:k(b({deviceId:n()}),pQ.nullable()),setHomeReturn:k(b({deviceId:n(),enabled:v(),seconds:n().int().min(0).max(3600)}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.setHomeReturn`,label:P(`Set PTZ return home`,`Imposta il ritorno alla posizione iniziale`),phrase:P(`Set {device} to return home when idle ({enabled}) after {seconds} s`,`Imposta {device} per tornare alla posizione iniziale da fermo ({enabled}) dopo {seconds} s`),icon:`undo-2`,openArgs:[{key:`enabled`,label:P(`Return home`,`Torna alla posizione iniziale`),offer:{kind:`boolean`}},{key:`seconds`,label:P(`Idle seconds`,`Secondi da fermo`),offer:{kind:`number`,min:0,max:3600,step:1,unit:`s`}}]}]}),getPosition:k(b({deviceId:n()}),cQ),setAutofocus:k(b({deviceId:n(),enabled:v()}),_(),{kind:`mutation`,actions:[{id:`ptz.autofocusOn`,label:P(`Autofocus on`,`Autofocus attivo`),phrase:P(`Turn on autofocus on {device}`,`Attiva l’autofocus su {device}`),icon:`focus`,args:{enabled:!0}},{id:`ptz.autofocusOff`,label:P(`Autofocus off`,`Autofocus spento`),phrase:P(`Turn off autofocus on {device}`,`Disattiva l’autofocus su {device}`),icon:`focus`,args:{enabled:!1}}]})},status:{schema:uQ,kind:`command-driven`},vocabulary:{noun:P(`Pan / tilt / zoom`,`Brandeggio`),order:3220}},hQ=b({targetType:l().describe(`Vendor target string (people/vehicle/pet); empty = camera default`),stopDelaySeconds:n().int().min(0).max(300).meta(M(`duration`)),disappearDelaySeconds:n().int().min(0).max(300).meta(M(`duration`))}),gQ=b({value:l(),label:l()}),_Q=b({enabled:v(),lastChangedAt:n(),currentSettings:hQ.nullable(),supportedTargetTypes:S(gQ)}),vQ=_Q.extend({lastFetchedAt:n()}),yQ={name:`ptz-autotrack`,scope:`device`,deviceNative:!0,mode:`singleton`,kind:`wrapper`,defaultActive:!1,deviceTypes:[T.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/ptz-autotrack`,tab:`ptz`,topTab:!0,label:`Auto-Tracking`,order:5}},methods:{getStatus:k(b({deviceId:n()}),_Q),setEnabled:k(b({deviceId:n(),enabled:v()}),_(),{kind:`mutation`,actions:[{id:`ptz.autotrackOn`,label:P(`Autotrack on`,`Inseguimento attivo`),phrase:P(`Start autotracking on {device}`,`Attiva l’inseguimento automatico su {device}`),icon:`crosshair`,args:{enabled:!0}},{id:`ptz.autotrackOff`,label:P(`Autotrack off`,`Inseguimento spento`),phrase:P(`Stop autotracking on {device}`,`Disattiva l’inseguimento automatico su {device}`),icon:`crosshair`,args:{enabled:!1}}]}),getSettings:k(b({deviceId:n()}),hQ.nullable()),setSettings:k(b({deviceId:n(),settings:hQ.partial()}),_(),{role:`admin`,kind:`mutation`,notOperatorFacing:`tracking tuning (target type, delays) — set once on the camera’s PTZ page`})},events:{onStatusChanged:{data:b({deviceId:n(),status:_Q}),notOperatorFacing:"the `enabled` state trigger phrases both edges of this change"}},status:{schema:_Q,kind:`command-driven`},runtimeState:vQ,durability:`session`,history:`none`,vocabulary:{noun:P(`Autotracking`,`Inseguimento automatico`),order:3230,state:[{kind:`boolean`,field:`enabled`,label:P(`Autotracking`,`Inseguimento automatico`),whenTrue:P(`When autotracking is turned on for {device}`,`Quando si attiva l’inseguimento automatico di {device}`),whenFalse:P(`When autotracking is turned off for {device}`,`Quando si disattiva l’inseguimento automatico di {device}`),icon:`crosshair`}]}},bQ=b({enabled:v().nullable(),onTime:n().min(0).nullable().meta(M(`duration`)),offTime:n().min(0).nullable().meta(M(`duration`)),lastFetchedAt:n()}),xQ=n().int().nonnegative(),SQ=n().int().min(0),CQ={name:`pump-cycle`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.PetFountain],methods:{setEnabled:k(b({deviceId:xQ,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.on`,effect:{field:`enabled`,value:!0},label:P(`Pump cycle on`,`Ciclo pompa attivo`),phrase:P(`Run the pump of {device} on its on/off cycle`,`Fai lavorare la pompa di {device} a ciclo acceso/spento`),icon:`timer`,args:{on:!0}},{id:`pumpCycle.off`,effect:{field:`enabled`,value:!1},label:P(`Pump cycle off`,`Ciclo pompa spento`),phrase:P(`Run the pump of {device} continuously`,`Fai lavorare la pompa di {device} in continuo`),icon:`timer-off`,args:{on:!1}}]}),setOnMinutes:k(b({deviceId:xQ,minutes:SQ}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.onMinutes`,label:P(`Set pump run time`,`Imposta il tempo di lavoro della pompa`),phrase:P(`Set the pump of {device} to run {minutes} minutes per cycle`,`Imposta la pompa di {device} a lavorare {minutes} minuti per ciclo`),icon:`timer`,effect:{field:`onTime`,fromArg:`minutes`,scale:60},openArgs:[{key:`minutes`,label:P(`Minutes`,`Minuti`),offer:{kind:`number`,min:0,step:1,unit:`min`}}]}]}),setOffMinutes:k(b({deviceId:xQ,minutes:SQ}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.offMinutes`,label:P(`Set pump rest time`,`Imposta il tempo di riposo della pompa`),phrase:P(`Set the pump of {device} to rest {minutes} minutes per cycle`,`Imposta la pompa di {device} a riposare {minutes} minuti per ciclo`),icon:`timer-off`,effect:{field:`offTime`,fromArg:`minutes`,scale:60},openArgs:[{key:`minutes`,label:P(`Minutes`,`Minuti`),offer:{kind:`number`,min:0,step:1,unit:`min`}}]}]})},status:{schema:bQ,kind:`push`},runtimeState:bQ,durability:`session`,history:`none`,vocabulary:{noun:P(`Pump cycle`,`Ciclo della pompa`),order:2050,state:[{kind:`boolean`,field:`enabled`,label:P(`Pump cycle`,`Ciclo pompa`),whenTrue:P(`When {device} starts running its pump on a cycle`,`Quando {device} inizia a far lavorare la pompa a ciclo`),whenFalse:P(`When {device} runs its pump continuously`,`Quando {device} fa lavorare la pompa in continuo`),icon:`timer`}]}},wQ={name:`reboot`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Camera,T.Sensor,T.Switch,T.Gateway],methods:{reboot:k(b({deviceId:n().int().nonnegative()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`,actions:[{id:`reboot.reboot`,label:P(`Reboot device`,`Riavvia il dispositivo`),phrase:P(`Reboot {device}`,`Riavvia {device}`),icon:`refresh-cw`}]})},vocabulary:{noun:P(`Reboot`,`Riavvio`),order:3240}},TQ=b({owner:l(),kind:gi,title:l(),nameField:l(),fields:m(l(),C()),secretPaths:S(l()),rows:n().int().nonnegative()}),EQ=b({id:oV,name:l(),rev:n().int(),updatedAt:n(),data:sV}),DQ={owner:l().min(1),kind:gi},OQ={name:`record-entries`,scope:`system`,mode:`singleton`,methods:{listEntryKinds:k(b({}),b({kinds:S(TQ)}),{auth:`admin`}),listEntries:k(b({...DQ}),b({entries:S(EQ)}),{auth:`admin`}),putEntry:k(b({...DQ,id:oV.optional(),data:sV,ifRev:n().int().min(1).optional()}),b({id:l(),rev:n().int()}),{kind:`mutation`,auth:`admin`}),deleteEntry:k(b({...DQ,id:oV}),b({deleted:v()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:j.INTERNAL}},vAe=`camstack`,yAe=`recorder`,kQ=b({profile:l(),startMs:n(),endMs:n()}),AQ=x([`read`,`unreadable`]),jQ=b({deviceId:n(),read:AQ,ranges:S(kQ),profilesWithFootage:S(l())}),MQ=b({deviceId:n(),read:AQ,days:S(n())}),NQ=b({deviceId:n(),localMasterPath:l().nullable(),playbackUrl:l().nullable(),playbackEndpoints:S(l())}),PQ=b({state:x([`ok`,`sleeping`,`unreachable`,`no-storage`,`index-empty`]),reason:l().optional(),coverageAsOf:n().optional()}),FQ=b({source:l(),label:l(),addonId:l().optional(),availability:PQ}),IQ=b({transport:x([`archive`,`stream`,`realtime`]),coverage:x([`continuous`,`sparse`]),seek:x([`free`,`forward`,`segment`]),stepBack:v(),scrub:v(),rates:S(n().positive()).min(1).readonly(),exclusive:v()}),LQ=i(`kind`,[b({kind:p(`hls`),manifest:NQ}),b({kind:p(`clip`),source:l(),clipId:l(),startsAtMs:n()}),b({kind:p(`none`),reason:l()})]),RQ={name:`recording`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:[T.Camera],methods:{listSources:k(b({deviceId:n()}),S(FQ).readonly(),{kind:`query`,auth:`protected`}),getAvailability:k(b({deviceId:n(),provider:l().min(1),fromMs:n(),toMs:n(),profile:l().optional()}),jQ,{kind:`query`,auth:`protected`}),getDaysWithRecordings:k(b({deviceId:n(),provider:l().min(1),fromMs:n(),toMs:n(),tzOffsetMinutes:n()}),MQ,{kind:`query`,auth:`protected`}),getPlayback:k(b({deviceId:n(),provider:l().min(1),fromMs:n(),toMs:n(),profile:N.optional()}),LQ,{kind:`query`,auth:`protected`}),getPlaybackOptions:k(b({deviceId:n(),provider:l().min(1)}),IQ,{kind:`query`,auth:`protected`})},vocabulary:{noun:P(`Recording`,`Registrazione`),order:3250}},zQ=b({deviceId:n(),enabled:v(),activeMode:om,nodeId:l(),storageBytes:n()}),bAe=200,BQ=b({deviceId:n(),read:x([`read`,`unreadable`]),ranges:S(kQ).readonly(),profilesWithFootage:S(l()).readonly()}),VQ=b({deviceId:n(),read:x([`read`,`unreadable`]),days:S(n()).readonly()}),HQ=b({deviceId:n(),usedBytes:n(),oldestMs:n().nullable().optional(),segments:n().optional(),residentBytes:n().optional(),residentOldestMs:n().nullable().optional()}),UQ=b({locationId:l().nullable(),locationIds:S(l()).optional(),root:l().optional(),usedBytes:n(),availableBytes:n().nullable(),totalBytes:n().nullable()}),WQ=b({nodeId:l(),totalUsedBytes:n(),devices:S(HQ),devicesRead:x([`archive`,`unavailable`]).optional(),complete:v().optional(),locations:S(UQ).optional()}),GQ=b({deviceId:n(),profile:l(),fromLocationId:l(),toLocationId:l(),bytes:n(),files:n().int()}),KQ=x([`unassigned`,`target-not-writable`,`below-threshold`,`no-headroom`]),qQ=b({deviceId:n(),profile:l(),fromLocationId:l(),toLocationId:l().nullable(),bytes:n(),reason:KQ}),JQ=b({moves:S(GQ),skipped:S(qQ),bytesToMove:n(),jobIds:S(l())}),YQ=b({throttleMbps:n().min(1).max(1e3).optional(),minMoveGb:n().min(0).optional()}),xAe=b({deviceId:n().int(),profile:l(),locationId:l()}),SAe=b({deviceId:n().int(),locationId:l()}),CAe=b({assignments:S(xAe),pins:S(SAe),defaultLocations:m(l(),l())}),wAe=b({deviceId:n().int(),locationId:l().nullable()}),XQ=i(`kind`,[b({kind:p(`segment`),startMs:n(),durMs:n(),bytes:n()}),b({kind:p(`gap`),nearestEdgeMs:n().nullable(),prevEndMs:n().nullable().optional()})]),ZQ=b({data:y(Uint8Array)}),QQ=b({data:y(Uint8Array),gopStartMs:n(),gopDurMs:n()}),$Q=i(`kind`,[b({kind:p(`ok`),data:y(Uint8Array),gopStartMs:n(),gopDurMs:n(),reachesRequestedEnd:v()}),b({kind:p(`spans-multiple-segments`),segmentEndMs:n()})]),e$={name:`recording-archive`,scope:`system`,mode:`singleton`,exposesDeviceSettings:!0,status:{schema:zQ,kind:`command-driven`},methods:{getAvailabilityBatch:k(b({deviceIds:S(n()).min(1).max(200),fromMs:n(),toMs:n()}),S(BQ).readonly(),{role:`viewer`,kind:`query`,auth:`protected`}),getDaysWithRecordingsBatch:k(b({deviceIds:S(n()).min(1).max(200),fromMs:n(),toMs:n(),tzOffsetMinutes:n()}),S(VQ).readonly(),{role:`viewer`,kind:`query`,auth:`protected`}),getStorageUsage:k(b({}),WQ,{kind:`query`,auth:`admin`}),getDeviceConfig:k(b({deviceId:n()}),gm,{role:`viewer`,kind:`query`,auth:`protected`}),locateSegment:k(b({deviceId:n(),profile:l(),epochMs:n()}),XQ,{kind:`query`,auth:`admin`}),readSegmentBytes:k(b({deviceId:n(),profile:l(),startMs:n()}),ZQ,{kind:`query`,auth:`admin`}),readGopBytes:k(b({deviceId:n(),profile:l(),startMs:n(),epochMs:n()}),QQ,{kind:`query`,auth:`admin`}),readWindowBytes:k(b({deviceId:n(),profile:l(),startMs:n(),fromMs:n(),toMs:n()}),$Q,{kind:`query`,auth:`admin`}),setDeviceConfig:k(b({deviceId:n(),config:gm}),gm,{kind:`mutation`,auth:`admin`}),rescanStorage:k(b({deviceId:n()}),zQ,{kind:`mutation`,auth:`admin`}),pruneFootage:k(b({deviceId:n(),reason:Xp.optional()}),b({floorMs:n().nullable(),deletedBuckets:n().int(),reclaimedBytes:n().int()}),{kind:`mutation`,auth:`admin`}),deleteFootprint:k(b({deviceId:n(),fromMs:n().optional(),toMs:n().optional()}),b({deletedBuckets:n().int(),reclaimedBytes:n().int()}),{kind:`mutation`,auth:`admin`}),listOpsLog:k(Qp,S(Zp).readonly(),{kind:`query`,auth:`admin`}),renderGif:k(b({deviceId:n(),aroundMs:n(),preRollSec:n().min(0).max(30).default(2),postRollSec:n().min(0).max(30).default(5),maxWidth:n().int().min(120).max(1280).default(480),fps:n().int().min(1).max(15).default(5)}),b({gifBase64:l(),fromMs:n(),toMs:n()}),{kind:`mutation`,auth:`admin`}),renderClip:k(b({deviceId:n(),aroundMs:n(),preRollSec:n().min(0).max(30).default(3),postRollSec:n().min(0).max(30).default(7),maxWidth:n().int().min(160).max(1920).default(640)}),b({clipBase64:l(),mime:l(),fromMs:n(),toMs:n(),bytes:n().int()}),{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:k(wm,b({paused:p(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:k(wm,b({resumed:p(!0)}),{kind:`mutation`,auth:`admin`}),refreshStorageLocationsForMigration:k(wm,b({refreshed:p(!0)}),{kind:`mutation`,auth:`admin`}),startStorageMigrationMove:k(Tm,b({jobId:l()}),{kind:`mutation`,auth:`admin`}),getStorageMigrationMoveStatus:k(b({jobId:l()}),xm.nullable(),{auth:`admin`}),cancelStorageMigrationMove:k(b({jobId:l()}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`}),relocateFootage:k(Cm,b({jobId:l()}),{kind:`mutation`,auth:`admin`}),listRelocateJobs:k(b({}),S(xm).readonly(),{kind:`query`,auth:`admin`}),getRelocateResidue:k(Zm,Qm,{kind:`query`,auth:`admin`}),reconcileLedgerAgainstDisk:k($m,rh,{kind:`mutation`,auth:`admin`}),cancelRelocateJob:k(b({jobId:l()}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`}),planStorageRebalance:k(YQ,JQ,{kind:`query`,auth:`admin`}),startStorageRebalance:k(YQ,JQ,{kind:`mutation`,auth:`admin`}),getPlacement:k(b({}),CAe,{kind:`query`,auth:`admin`}),setDevicePlacement:k(wAe,b({ok:p(!0)}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:j.STORAGE}},TAe=24,EAe=3,DAe=x([`queue-full`,`camera-backoff`,`sleeping`,`camera-refused`,`no-keyframe`,`decode-failed`,`no-catalog-row`,`unsupported`,`unknown-device`,`uid-missing`]),OAe=x([`deferred`,`final`]),kAe=`x-camstack-reason`,AAe=500;function jAe(e){let t=e.replace(/[\u2013\u2014\u2212]/g,`-`).replace(/[\u2018\u2019\u201b]/g,`'`).replace(/[\u201c\u201d]/g,`"`).replace(/\u2026/g,`...`).replace(/[\u00a0\u2007\u202f]/g,` `),n=``;for(let e of t){let t=e.codePointAt(0)??0;t<32||t===127?n+=` `:t>255?n+=`?`:n+=e}return n.slice(0,500).trim()}var MAe=`x-camstack-reason-code`,NAe=`x-camstack-disposition`,PAe=`x-camstack-clip-transport`,t$=b({id:l(),source:l(),kind:x([`motion`,`object`,`audio`,`native`]),timeRange:b({startMs:n(),endMs:n()}),labels:S(l()).max(3).optional(),thumbnail:l().optional(),stillAtMs:n().optional(),eventIds:S(l()).optional(),eventCount:n().int().nonnegative().optional(),holes:S(b({startMs:n(),endMs:n()})).optional(),thumbnailMint:l().optional(),thumbnailUnavailable:b({reason:x([`sleeping`,`camera-refused`,`no-keyframe`,`unsupported`])}).optional(),catalogAsOf:n().optional(),nativeTypes:S(l()).optional(),behaviours:S(l()).optional(),streams:b({sub:b({id:l(),bytes:n().optional()}).optional(),main:b({id:l(),bytes:n().optional()}).optional()}).optional(),supportSub:v().optional(),playable:v().optional(),unplayableReason:l().optional(),inProgress:v().optional()}),n$=b({playbackUrl:l(),format:x([`hls`,`mp4`]).optional(),served:N.optional(),playbackEndpoints:S(l()).optional(),token:l().optional()}),r$=x([`authorised`]),FAe=50*1024*1024,IAe=500*1024*1024,i$=b({base64:l(),contentType:l(),name:l(),bytes:n().int().nonnegative(),served:N,durationMs:n().positive().optional()}),a$=b({ticket:Ti,contentType:l(),name:l(),served:N,durationMs:n().positive().optional()}),o$=x([`opus`,`pcmu`,`none`]),s$=x([`not-requested`,`unsupported-ask`]),c$=b({url:l().min(1),expiresAtMs:n(),transport:p(`forward-only`),served:N,servedAudio:o$,audioReason:s$.optional()}),l$=[.25,.5,1,1.5,2,4,8],u$=[.25,.5,1,1.5,2,4],d$=[.25,.5,1],f$=b({transport:x([`stream`,`file`]),seek:x([`forward`,`free`]),stepBack:v(),scrub:v(),rates:S(n().positive()).min(1).readonly()}),p$=b({state:x([`ok`,`sleeping`,`unreachable`,`no-storage`,`index-empty`]),reason:l().optional(),catalogAsOf:n().optional()}),m$=b({source:l(),label:l(),addonId:l().optional(),availability:p$}),h$={name:`videoclips`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:[T.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/clips-browser`,tab:`recording`,topTab:!0,label:`Clips`,order:100}},methods:{listClips:k(b({deviceId:n(),since:n(),until:n(),limit:n().int().positive().optional(),provider:l().min(1)}),S(t$).readonly(),{kind:`query`,auth:`protected`}),listSources:k(b({deviceId:n()}),S(m$).readonly(),{kind:`query`,auth:`protected`}),getClipPlayback:k(b({deviceId:n(),clipId:l(),profile:N.optional()}),n$,{kind:`query`,auth:`protected`}),readClipBytes:A(b({deviceId:n(),clipId:l().min(1),provider:l().min(1),profile:N.optional(),maxBytes:n().int().positive().optional(),wake:r$.optional()}),i$,{kind:`query`,auth:`protected`}),offerClipBytes:A(b({deviceId:n(),clipId:l().min(1),provider:l().min(1),profile:N.optional(),maxBytes:n().int().positive().optional(),wake:r$.optional()}),a$,{kind:`query`,auth:`protected`}),dialClipStream:A(b({deviceId:n(),clipId:l().min(1),provider:l().min(1),profile:N.optional(),audio:o$.optional(),wake:r$.optional()}),c$,{kind:`query`,auth:`protected`}),getPlaybackOptions:A(b({deviceId:n(),provider:l().min(1)}),f$,{kind:`query`,auth:`protected`})},vocabulary:{noun:P(`Video clips`,`Clip video`),order:3330}},LAe={stream:{transport:`stream`,seek:`forward`,stepBack:!1,scrub:!1,rates:u$},realtimeStream:{transport:`stream`,seek:`forward`,stepBack:!1,scrub:!1,rates:d$},file:{transport:`file`,seek:`free`,stepBack:!0,scrub:!0,rates:l$}},g$=n().min(.25).max(32),_$=b({fromSec:n().nonnegative(),toSec:n().nonnegative()}).refine(e=>e.toSec>e.fromSec,{message:`dense range must have toSec > fromSec`}),RAe=200,v$=b({everyMs:n().int().positive(),ranges:S(_$).min(1).max(200)}),y$=b({everyMs:n().int().positive(),outputFps:n().int().min(1).max(60).optional(),dense:v$.optional()}).superRefine((e,t)=>{e.dense!==void 0&&e.dense.everyMs>=e.everyMs&&t.addIssue({code:ue.custom,message:`dense.everyMs must be strictly smaller than the base everyMs`,path:[`dense`,`everyMs`]})}),b$=b({speed:g$.optional(),timelapse:y$.optional(),includeAudio:v(),maxLifeMs:n().int().positive(),deleteAfterDownload:v(),title:l().max(200).optional(),notifyTargetIds:S(l().min(1)).max(20).optional()}).superRefine((e,t)=>{e.speed!==void 0&&e.timelapse!==void 0&&t.addIssue({code:ue.custom,message:`speed and timelapse are mutually exclusive`,path:[`timelapse`]})}),x$=x([`queued`,`rendering`,`ready`,`failed`,`expired`,`deleted`]),S$=b({kind:p(`footage`),deviceId:n(),profiles:S(l()).min(1),fromMs:n(),toMs:n()}),C$=b({kind:p(`clip`),deviceId:n(),provider:l().min(1),source:l().min(1),sourceLabel:l().min(1),clipId:l().min(1),catalogWindow:b({sinceMs:n(),untilMs:n()}),profile:x([`high`,`mid`,`low`]),wake:r$.optional()}),w$=i(`kind`,[S$,C$]),T$=b({id:l(),deviceId:n(),profile:l(),fromMs:n(),toMs:n(),subject:w$.optional(),options:b$,state:x$,progressPct:n().nullable(),fileBytes:n().nullable(),expiresAt:n(),deleteAfterDownload:v(),downloadedAt:n().nullable(),createdAt:n(),createdBy:l(),error:l().nullable()}),E$=x([`catalog-miss`,`catalog-unreachable`,`no-file-for-window`,`clip-in-progress`,`unsupported-option`,`sleeping`,`camera-refused`,`fetch-failed`,`too-large-to-transfer`,`wake-expired`,`wake-timeout`]);function zAe(e,t){return t.length>0?`${e}: ${t}`:e}function BAe(e){if(e===null)return null;let t=e.split(`:`,1)[0]??``,n=E$.safeParse(t.trim());return n.success?n.data:null}var D$=b({url:l(),endpoints:S(l())}),VAe=50*1024*1024,O$=b({base64:l(),contentType:l(),name:l(),bytes:n().int().nonnegative()});function k$(e){return e.profiles!==void 0&&e.profiles.length>0?[...e.profiles]:typeof e.profile==`string`&&e.profile.length>0?[e.profile]:[]}var HAe=b({deviceId:n(),profile:l().optional(),profiles:S(l()).min(1).optional(),fromMs:n().optional(),toMs:n().optional(),subject:w$.optional(),options:b$}).superRefine((e,t)=>{if(e.subject?.kind===`clip`){e.subject.deviceId!==e.deviceId&&t.addIssue({code:ue.custom,message:`subject.deviceId (${e.subject.deviceId}) must equal deviceId (${e.deviceId}) — the top-level field is what per-device scope enforcement reads`,path:[`subject`,`deviceId`]}),(e.fromMs!==void 0||e.toMs!==void 0)&&t.addIssue({code:ue.custom,message:`a clip export asks for no time range: the camera chose the boundaries and they are read from the catalog row`,path:[`fromMs`]});return}e.subject?.kind===`footage`&&e.subject.deviceId!==e.deviceId&&t.addIssue({code:ue.custom,message:`subject.deviceId (${e.subject.deviceId}) must equal deviceId (${e.deviceId})`,path:[`subject`,`deviceId`]});let n=e.subject?.kind===`footage`?e.subject.fromMs:e.fromMs,r=e.subject?.kind===`footage`?e.subject.toMs:e.toMs;(typeof n!=`number`||typeof r!=`number`)&&t.addIssue({code:ue.custom,message:`a footage export needs fromMs and toMs`,path:[`fromMs`]}),(e.subject?.kind===`footage`?[...e.subject.profiles]:k$(e)).length<1&&t.addIssue({code:ue.custom,message:`pass profiles[] (min 1) or legacy profile`,path:[`profiles`]})});function UAe(e){if(e.subject!==void 0)return e.subject;let t=k$(e);if(typeof e.fromMs!=`number`||typeof e.toMs!=`number`)throw Error(`recording-export: a footage export needs fromMs and toMs`);return{kind:`footage`,deviceId:e.deviceId,profiles:t,fromMs:e.fromMs,toMs:e.toMs}}function WAe(e){return e.subject===void 0?{kind:`footage`,deviceId:e.deviceId,profiles:[e.profile],fromMs:e.fromMs,toMs:e.toMs}:e.subject}var A$={name:`recording-export`,scope:`system`,mode:`singleton`,methods:{createExport:k(HAe,T$,{role:`viewer`,kind:`mutation`,auth:`protected`}),listExports:k(b({deviceId:n().optional()}),S(T$),{role:`viewer`,kind:`query`,auth:`protected`}),getExport:k(b({exportId:l()}),T$,{role:`viewer`,kind:`query`,auth:`protected`}),cancelExport:k(b({exportId:l()}),T$,{role:`viewer`,kind:`mutation`,auth:`protected`}),deleteExport:k(b({exportId:l()}),T$,{role:`viewer`,kind:`mutation`,auth:`protected`}),getDownloadUrl:k(b({exportId:l()}),D$,{role:`viewer`,kind:`query`,auth:`protected`}),readExportBytes:k(b({exportId:l()}),O$,{kind:`query`,auth:`protected`})},vocabulary:{notOperatorFacing:`recording exports — requested from the timeline, not an automation step`}},j$=x([`continuous`,`motion`,`person`,`vehicle`,`animal`,`lineCrossing`,`intrusion`,`loitering`,`alarmInput`]),M$=b({trigger:j$,day:n().int().min(0).max(6).meta(M(`none`)),startMinute:n().int().min(0).max(1439).meta(M(`none`)),endMinute:n().int().min(1).max(1440).meta(M(`none`))}),N$=b({id:l(),label:l().optional(),status:x([`ok`,`unformatted`,`error`,`offline`,`unknown`]),capacityMb:n().nullable(),freeMb:n().nullable(),writable:v().optional()}),P$=i(`kind`,[b({kind:p(`present`),volumes:S(N$)}),b({kind:p(`absent`),reason:l()}),b({kind:p(`unknown`),reason:l()})]),F$=b({id:l(),enabled:v(),isVideo:v(),codec:l().nullable(),resolution:l().nullable(),overwriteWhenFull:v().nullable()}),I$=b({storage:P$,tracks:S(F$),primaryTrackId:l().nullable(),enabled:v().nullable(),overwriteWhenFull:v().nullable(),preRecordSec:n().nullable().meta(M(`duration`)),postRecordSec:n().nullable().meta(M(`duration`)),segmentMinutes:n().nullable().meta(M(`none`)),windows:S(M$),unreadableWindows:n().meta(M(`count`)),recordingToNowhere:v(),lastFetchedAt:n()}),L$=b({min:n(),max:n(),step:n()}),R$=b({values:S(n()).min(1),sentinel:b({value:n(),meaning:x([`no-limit`,`disabled`])}).optional()}),z$=b({readable:v(),writable:v(),reason:l().optional()}),B$=b({support:z$,granularityMinutes:n(),triggers:S(j$),supportsOverlappingTriggers:v()}),V$=b({enabled:z$,overwriteWhenFull:z$,preRecordSec:z$,preRecordSecRange:L$.optional(),preRecordSecAllowed:R$.optional(),postRecordSec:z$,postRecordSecRange:L$.optional(),postRecordSecAllowed:R$.optional(),segmentMinutes:z$,segmentMinutesRange:L$.optional(),segmentMinutesAllowed:R$.optional(),schedule:B$}),H$=b({enabled:v().optional(),overwriteWhenFull:v().optional(),preRecordSec:n().optional(),postRecordSec:n().optional(),segmentMinutes:n().optional(),windows:S(M$).optional()}),U$={name:`recording-onboard`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Camera],deviceConfig:{ui:{kind:`derived-form`,builderId:`recording-onboard`,tab:`recording`}},methods:{getOptions:k(b({deviceId:n()}),V$),setSettings:k(b({deviceId:n(),settings:H$}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`recordingOnboard.on`,label:P(`On-camera recording on`,`Registrazione a bordo attiva`),phrase:P(`Turn on recording to the card of {device}`,`Attiva la registrazione sulla scheda di {device}`),icon:`hard-drive`,args:{settings:{enabled:!0}}},{id:`recordingOnboard.off`,label:P(`On-camera recording off`,`Registrazione a bordo spenta`),phrase:P(`Turn off recording to the card of {device}`,`Disattiva la registrazione sulla scheda di {device}`),icon:`hard-drive`,args:{settings:{enabled:!1}}}]})},status:{schema:I$,kind:`poll`},runtimeState:I$,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:P(`On-camera recording`,`Registrazione a bordo`),order:3260,state:[{kind:`boolean`,field:`recordingToNowhere`,label:P(`Recording to nowhere`,`Registra nel vuoto`),whenTrue:P(`When {device} is recording with no card to write to`,`Quando {device} registra senza una scheda su cui scrivere`),whenFalse:P(`When {device} has a card to record to again`,`Quando {device} ha di nuovo una scheda su cui registrare`),icon:`hard-drive`}]}},W$=b({active:v(),reason:l(),lastChangedAt:n()}),G$=W$.extend({lastFetchedAt:n()}),K$={name:`recording-signal`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Camera],methods:{getStatus:k(b({deviceId:n()}),W$)},status:{schema:W$,kind:`push`,empty:{active:!1,reason:`unknown`,lastChangedAt:0}},runtimeState:G$,durability:`session`,history:`none`,vocabulary:{noun:P(`Recording signal`,`Segnale di registrazione`),order:3270,state:[{kind:`boolean`,field:`active`,label:P(`Recording`,`In registrazione`),whenTrue:P(`When {device} starts recording`,`Quando {device} inizia a registrare`),whenFalse:P(`When {device} stops recording`,`Quando {device} smette di registrare`),icon:`circle-dot`}]}},q$=b({kind:p(`cap`),deviceId:n().int().nonnegative(),cap:l().min(1),method:l().min(1),args:m(l(),C()).optional(),argUnits:m(l(),l().min(1)).optional()}),J$=b({action:q$}),Y$=b({key:l().refine(QE,{message:`a lowercase slug`}),name:l().min(1).max(60)}),GAe=200,KAe=100;function qAe(e,t){let n=new Set,r=new Set,i=new Set;e.sources.forEach((a,o)=>{let s=(e,n)=>{t.addIssue({code:`custom`,message:e,path:[`sources`,o,n]})};n.has(a.id)&&s(`source id "${a.id}" is used twice`,`id`),n.add(a.id);let c=a.name.trim().toLowerCase();if(r.has(c)&&s(`source name "${a.name}" is used twice`,`name`),r.add(c),a.kind===`digits`&&(i.has(a.number)&&s(`channel ${a.number} is declared twice`,`number`),i.add(a.number)),a.kind===`ir`){let e=dD(a);e!==null&&s(e,`payload`)}for(let t of uD(a))YE(t)?s(`"${a.name}" presses ${t}, a layout widget, not a command`,`steps`):e.bindings[t]===void 0&&s(`"${a.name}" presses ${t}, which is not bound`,`steps`)}),e.sources.forEach((n,r)=>{for(let i of e.sources)if(!(i.kind!==`digits`||i===n))for(let e of[`name`,`id`])n[e].trim()===i.number&&t.addIssue({code:`custom`,message:`${e} "${n[e]}" is the channel number of "${i.name}"`,path:[`sources`,r,e]})})}var X$=b({index:n().int().nonnegative(),id:l().nullable(),name:l().nullable(),reason:l()}),Z$=b({layoutTemplateId:l().min(1).nullable(),defaultTransmitterId:n().int().nonnegative().nullable().default(null),bindings:m(l(),J$),customButtons:S(Y$).max(100),sources:S(cD).max(200).default([]),stepDelayMs:n().int().min(100).max(lD).default(500),refusedSources:S(X$).optional()}).superRefine((e,t)=>{let n=Object.keys(e.bindings);n.length>200&&t.addIssue({code:`custom`,message:`too many bindings`,path:[`bindings`]});for(let e of n)YE(e)?t.addIssue({code:`custom`,message:`"${e}" is a layout widget, not a command: it cannot be bound`,path:[`bindings`,e]}):tD(e)||t.addIssue({code:`custom`,message:`"${e}" is not a role`,path:[`bindings`,e]});let r=new Set;e.customButtons.forEach((e,n)=>{r.has(e.key)&&t.addIssue({code:`custom`,message:`custom button "${e.key}" is listed twice`,path:[`customButtons`,n,`key`]}),r.add(e.key)});for(let e of n){let n=eD(e);n!==null&&!r.has(n)&&t.addIssue({code:`custom`,message:`${e} is bound but has no entry in customButtons`,path:[`bindings`,e]})}qAe(e,t)}),JAe=ce({sources:S(C())}),YAe=b({id:l(),name:l()}).partial();function XAe(e){let t=JAe.safeParse(e);if(!t.success)return Q$(Z$.safeParse(e));let n=[],r=[];t.data.sources.forEach((e,t)=>{let i=cD.safeParse(e),a=i.success&&i.data.kind===`ir`?dD(i.data):null;if(i.success&&a===null){n.push(e);return}let o=YAe.safeParse(e),s=a??i.error?.issues[0]?.message??`not a source`;r.push({index:t,id:o.success?o.data.id??null:null,name:o.success?o.data.name??null:null,reason:s})});let i=Q$(Z$.safeParse({...t.data,sources:n}));return!i.success||r.length===0?i:{success:!0,data:{...i.data,refusedSources:r}}}function Q$(e){return e.success?{success:!0,data:e.data}:{success:!1,issues:e.error.issues.length}}var ZAe={layoutTemplateId:null,defaultTransmitterId:null,bindings:{},customButtons:[],sources:[],stepDelayMs:500},QAe=b({power:b({state:x([`on`,`off`]),at:n()}).nullable(),muted:b({value:v(),at:n()}).nullable(),source:b({name:l(),at:n()}).nullable().default(null)}),$Ae={power:null,muted:null,source:null},eje=24,tje=50,$$=[`rect`,`rounded`,`round`,`pill`],e1=x($$),t1=[`neutral`,`accent`,`danger`,`red`,`green`,`yellow`,`blue`],n1=x(t1),r1=[`none`,`panel`,`divider`,`dpad`,`rocker-v`,`rocker-h`,`keypad`],i1=x(r1),a1=b({id:l().min(1).max(40),row:n().int().min(0).max(24),col:n().int().min(0).max(24),rowSpan:n().int().min(1).max(24),colSpan:n().int().min(1).max(24),icon:l().min(1).max(60).optional(),label:l().min(1).max(40).optional(),role:nD,shape:e1.optional(),tone:n1.optional(),showLegend:v().optional(),groupId:l().min(1).max(40).optional()}),o1=b({id:l().min(1).max(40),componentId:l().min(1).max(80),frame:i1,row:n().int().min(0).max(24),col:n().int().min(0).max(24),rowSpan:n().int().min(1).max(24),colSpan:n().int().min(1).max(24),title:l().min(1).max(40).optional(),size:x([`compact`,`normal`]).optional(),hideTitle:v().optional()});function s1(e,t){return e.row<t.row+t.rowSpan&&t.row<e.row+e.rowSpan&&e.col<t.col+t.colSpan&&t.col<e.col+e.colSpan}function c1(e,t){return t.row>=e.row&&t.col>=e.col&&t.row+t.rowSpan<=e.row+e.rowSpan&&t.col+t.colSpan<=e.col+e.colSpan}function nje(e,t){let n=e.groups??[],r=new Map,i=(e,n)=>{t.addIssue({code:`custom`,message:e,path:n})};n.forEach((t,a)=>{r.has(t.id)&&i(`group id "${t.id}" is used twice`,[`groups`,a,`id`]),r.set(t.id,t),(t.row+t.rowSpan>e.rows||t.col+t.colSpan>e.columns)&&i(`group "${t.id}" leaves the grid`,[`groups`,a]);for(let e=0;e<a;e+=1){let r=n[e];if(r!==void 0&&s1(r,t)){i(`groups "${r.id}" and "${t.id}" overlap`,[`groups`,a]);return}}}),e.buttons.forEach((e,t)=>{if(e.groupId!==void 0){let n=r.get(e.groupId);if(n===void 0){i(`button "${e.id}" names the unknown group "${e.groupId}"`,[`buttons`,t,`groupId`]);return}n.frame===`divider`&&i(`a divider group ("${n.id}") holds no buttons`,[`buttons`,t,`groupId`]),c1(n,e)||i(`button "${e.id}" lies outside its group "${n.id}"`,[`buttons`,t]);return}let a=n.find(t=>s1(t,e));a!==void 0&&i(`button "${e.id}" lies inside group "${a.id}" but is not a member`,[`buttons`,t])})}var l1=b({columns:n().int().min(1).max(24),rows:n().int().min(1).max(24),buttons:S(a1).max(200),groups:S(o1).max(50).optional()}).superRefine((e,t)=>{let n=new Set,r=new Map;e.buttons.forEach((i,a)=>{if(n.has(i.id)&&t.addIssue({code:`custom`,message:`button id "${i.id}" is used twice`,path:[`buttons`,a,`id`]}),n.add(i.id),i.row+i.rowSpan>e.rows||i.col+i.colSpan>e.columns){t.addIssue({code:`custom`,message:`button "${i.id}" leaves the grid`,path:[`buttons`,a]});return}for(let e=i.row;e<i.row+i.rowSpan;e+=1)for(let n=i.col;n<i.col+i.colSpan;n+=1){let o=`${e}:${n}`,s=r.get(o);if(s!==void 0){t.addIssue({code:`custom`,message:`buttons "${s}" and "${i.id}" overlap`,path:[`buttons`,a]});return}r.set(o,i.id)}}),nje(e,t)}),rje=50,u1=b({role:nD,label:l().optional(),custom:v()}),d1=b({layoutTemplateId:l().nullable(),commands:S(u1),sources:S(cD)}),f1=[`no-remote`,`unbound-role`,`action-failed`,`unknown-source`,`unbound-step`,`undeclared-channel`,`press-timeout`,`no-transmitter`],p1=x(f1),m1=i(`status`,[b({status:p(`sent`),sends:n().int().min(1)}),b({status:p(`skipped`),reason:p(`already-in-state`)}),b({status:p(`refused`),reason:p1,detail:l().optional(),step:b({index:n().int().min(1),role:l()}).optional()})]),h1=[`play`,`pause`,`stop`,`next`,`previous`,`setMute`,`selectSource`,`playMedia`,`turnOn`,`turnOff`,`volumeUp`,`volumeDown`,`channelUp`,`channelDown`],g1=x(h1),_1=i(`status`,[...m1.options,b({status:p(`not-routed`)})]),v1=[`unknown-template`,`not-a-media-player`],y1=i(`status`,[b({status:p(`saved`)}),b({status:p(`refused`),reason:x(v1),detail:l()})]),b1=b({deviceId:n().int().nonnegative()}),ije={version:1,targets:[{id:`remote`,cardinality:`config`,vocabulary:{cap:`remote`},deviceTypes:[T.MediaPlayer],apply:`add`,readMethod:`getConfig`,writeMethod:`setConfig`}]},x1={name:`remote`,scope:`system`,mode:`singleton`,methods:{getConfig:k(b1,Z$,{auth:`admin`}),setConfig:k(b1.extend({config:Z$}),y1,{kind:`mutation`,auth:`admin`}),listCommands:k(b1,d1,{auth:`protected`}),sendCommand:k(b1.extend({role:nD,repeat:n().int().min(1).max(50).default(1)}),m1,{kind:`mutation`,auth:`protected`}),getAssumedStatus:k(b1,_D.nullable(),{auth:`protected`}),sendMediaCommand:k(b1.extend({command:g1,muted:v().optional(),source:l().optional(),mediaType:l().optional(),mediaId:l().optional(),repeat:n().int().min(1).max(50).default(1)}),_1,{kind:`mutation`,auth:`protected`})},customize:ije,vocabulary:{notOperatorFacing:`the per-device remote setup — authored in the Customize remote editor, sent through the remote UI`}},S1=[`power`,`navigation`,`volume`,`numbers`,`media`,`colour`,`apps`,`layout`],C1=x(S1),aje=40,oje=/^[a-z0-9][a-z0-9_.-]*:[a-z0-9][a-z0-9_-]*$/,w1=b({idSuffix:l().regex(/^[a-z0-9][a-z0-9_-]{0,19}$/,{message:`a short lowercase slug`}),row:n().int().min(0).max(24),col:n().int().min(0).max(24),rowSpan:n().int().min(1).max(24),colSpan:n().int().min(1).max(24),role:nD,icon:l().min(1).max(60).optional(),label:l().min(1).max(40).optional(),shape:e1.optional(),tone:n1.optional(),showLegend:v().optional()}),T1=b({id:l().max(80).regex(oje,{message:`<namespace>:<name>, lowercase`}),name:l().min(1).max(60),nameI18n:b({en:l().min(1).max(60),it:l().min(1).max(60)}).optional(),icon:l().min(1).max(60),category:C1,size:b({rows:n().int().min(1).max(24),cols:n().int().min(1).max(24)}),group:b({frame:i1,title:l().min(1).max(40).optional()}).nullable(),buttons:S(w1).max(40)}).superRefine((e,t)=>{let n=new Set;e.buttons.forEach((r,i)=>{if(n.has(r.idSuffix)&&t.addIssue({code:`custom`,message:`button "${r.idSuffix}" is listed twice`,path:[`buttons`,i,`idSuffix`]}),n.add(r.idSuffix),r.row+r.rowSpan>e.size.rows||r.col+r.colSpan>e.size.cols){t.addIssue({code:`custom`,message:`button "${r.idSuffix}" leaves the component`,path:[`buttons`,i]});return}for(let n=0;n<i;n+=1){let a=e.buttons[n];if(a!==void 0&&s1(a,r)){t.addIssue({code:`custom`,message:`buttons "${a.idSuffix}" and "${r.idSuffix}" overlap`,path:[`buttons`,i]});return}}}),e.group?.frame===`divider`&&e.buttons.length>0&&t.addIssue({code:`custom`,message:`a divider component holds no buttons`,path:[`buttons`]})}),E1={name:`remote-layout-components`,scope:`system`,mode:`collection`,methods:{listComponents:k(b({}),S(T1),{auth:`protected`})},vocabulary:{notOperatorFacing:`the palette of the remote template editor — read-only data, never actuated`}},D1=b({deviceId:n().int().nonnegative(),resetToSource:v().optional()}),O1={name:`resync`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Container,T.Workload,T.WeatherStation],methods:{resync:k(D1,RA,{kind:`mutation`,auth:`admin`,notOperatorFacing:`device adoption — re-aligning a device with its source is an onboarding step, not an automation action`})},vocabulary:{noun:P(`Re-sync`,`Risincronizzazione`),order:3245}},sje=5,cje=2,k1=3e4,A1=18e4,j1={startDwellMs:k1,stopDwellMs:A1,minSamples:2},M1={[T.MediaPlayer]:{startDwellMs:1e4,stopDwellMs:1e4,minSamples:1}};function N1(e){return e!==void 0&&M1[e]!==void 0}function P1(e){return e===void 0?j1:M1[e]??j1}var lje={running:null,since:null,source:`native`,phase:null,lastFetchedAt:null},F1=x([`native`,`assigned`]),I1=b({running:v().nullable(),since:n().nullable().meta(M(`none`)),source:F1.meta({label:`Source`}),phase:l().nullable(),lastFetchedAt:n().nullable()}),L1=b({deviceId:n(),since:n().nullable(),phase:l().nullable()}),uje=Object.values(T),R1=[T.Washer,T.Dryer,T.Dishwasher,T.Vacuum,T.LawnMower,T.MediaPlayer,T.WaterHeater,T.Humidifier,T.Fan,T.Climate,T.PetFeeder],dje={version:1,overridable:[{path:`running`,by:`running`}],targets:[{id:`running`,cardinality:`scalar`,vocabulary:{cap:`running-state`,stateField:`running`},deviceTypes:R1,apply:`add`,path:`running`,sources:[{kind:`switch`,transforms:[{kind:`identity`}]},{kind:`binary`,transforms:[{kind:`identity`},{kind:`invert`}]},{kind:`numeric`,requiredUnit:`W`,transforms:[{kind:`threshold`,comparisons:[`gte`,`lte`],comparison:`gte`,defaultThreshold:5,defaultStartDwellMs:k1,defaultStopDwellMs:A1,deviceTypeDefaults:M1,thresholdUnit:`W`}]}],companions:[{kind:`constant`,path:`source`,value:`assigned`,when:`always`},{kind:`constant`,path:`phase`,value:null,when:`add`},{kind:`clock`,path:`lastFetchedAt`,when:`always`},{kind:`transition-time`,path:`since`,sourceChangedAt:`prefer`}],sourceReport:{status:`assignment-status`,runtimeField:`source`,nativeValue:`native`,assignedValue:`assigned`},advancedExpression:!0}]},z1={name:`running-state`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:uje,methods:{},events:{onStarted:{data:L1,trigger:{category:w.RunningStarted,label:P(`Started running`,`Ha iniziato a funzionare`),phrase:P(`When {device} starts running`,`Quando {device} inizia a funzionare`),icon:`play`}},onFinished:{data:L1,trigger:{category:w.RunningFinished,label:P(`Finished`,`Ha finito`),phrase:P(`When {device} finishes`,`Quando {device} finisce`),icon:`square`}}},status:{schema:I1,kind:`push`},runtimeState:I1,durability:`restored`,history:{fields:{running:{kind:`boolean`}}},volatileStateFields:[`lastFetchedAt`],customize:dje,vocabulary:{noun:P(`Running`,`In funzione`),order:2120,state:[{kind:`boolean`,field:`running`,label:P(`Running`,`In funzione`),whenTrue:P(`When {device} starts`,`Quando {device} inizia`),whenFalse:P(`When {device} finishes`,`Quando {device} finisce`),icon:`play`}],overrides:{byType:{[T.Washer]:{state:{running:{whenTrue:P(`When the washing machine starts`,`Quando la lavatrice inizia`),whenFalse:P(`When the washing machine has finished`,`Quando la lavatrice ha finito`)}},events:{onStarted:{phrase:P(`When the washing machine starts`,`Quando la lavatrice inizia`)},onFinished:{phrase:P(`When the washing machine has finished`,`Quando la lavatrice ha finito`)}}},[T.Dryer]:{state:{running:{whenTrue:P(`When the dryer starts`,`Quando l'asciugatrice inizia`),whenFalse:P(`When the dryer has finished`,`Quando l'asciugatrice ha finito`)}},events:{onStarted:{phrase:P(`When the dryer starts`,`Quando l'asciugatrice inizia`)},onFinished:{phrase:P(`When the dryer has finished`,`Quando l'asciugatrice ha finito`)}}},[T.Dishwasher]:{state:{running:{whenTrue:P(`When the dishwasher starts`,`Quando la lavastoviglie inizia`),whenFalse:P(`When the dishwasher has finished`,`Quando la lavastoviglie ha finito`)}},events:{onStarted:{phrase:P(`When the dishwasher starts`,`Quando la lavastoviglie inizia`)},onFinished:{phrase:P(`When the dishwasher has finished`,`Quando la lavastoviglie ha finito`)}}}}}}},B1=l(),fje=[`day`,`ir`,`night`,`dawn`,`dusk`],V1=x([`skip`,`judge-anyway`]),pje=`__diverged__`,H1=x([`matched`,`diverged`,`unknown`]),U1=x([`no-reference-for-condition`,`view-shifted`,`no-vision-profile`,`encoder-model-changed`,`no-snapshot`]),W1=b({embedding:S(n()),modelId:l(),condition:B1,capturedAt:n(),thumbnailMediaId:n().int().optional(),anchorEmbedding:S(n()).optional()}),G1=b({id:l(),label:l(),references:S(W1),textPrompts:S(l()).optional(),referenceCount:n(),currentlyMatched:v()}),K1=i(`mode`,[b({mode:p(`similarity`),threshold:n().min(0).max(1),hysteresisCount:n().int().positive()}),b({mode:p(`llm`),prompt:l(),profileId:l().optional(),hysteresisCount:n().int().positive()})]),mje=60,hje=120,gje=60,q1=.85,J1=`skip`,Y1=8e3,_je=448,vje=!0,X1=b({enabled:v().default(!1),prompt:l().min(1).max(1e3),profileId:l().optional(),timeoutMs:n().int().min(1e3).max(2e4).default(Y1),maxImagePx:n().int().min(64).max(2048).default(448),onTimeout:x([`flip`,`hold`]).default(`hold`)}),Z1=b({id:l(),label:l(),roi:eH,enabled:v(),triggerMode:x([`periodic`,`on-motion`,`both`]),checkIntervalSec:n().optional(),check:K1,states:S(G1),currentStateId:l().nullable(),lastCheckedAt:n().nullable(),lastConfidence:n().nullable(),currentCondition:B1.nullable(),availability:x([`ok`,`unavailable`]),unavailableReason:l().nullable(),baselineStateId:l().nullable(),emit:x([`latched`,`live`]).default(`latched`),verdict:H1,latched:v(),armedAt:n(),divergedAt:n().nullable(),restoredAt:n().nullable(),quietSeconds:n().int().min(0).max(3600).default(60),minObservationSpacingSec:n().int().min(0).max(3600).default(120),confirm:X1.optional(),anchorThreshold:n().min(0).max(1).default(q1),autoRestore:v().default(!1),onUncoveredCondition:V1.default(J1),suspendedCondition:B1.nullable().default(null),unavailable:U1.nullable(),coveredConditions:S(B1)}),Q1=b({monitors:S(Z1),lastFetchedAt:n()}),$1=b({deviceId:n(),status:Q1.nullable()}),e0={name:`scene-monitor`,role:{feature:`scenes`},scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[T.Camera],methods:{listScenes:k(b({deviceId:n()}),Q1),listScenesBatch:k(b({deviceIds:S(n()).min(1).max(200)}),S($1).readonly()),createScene:k(b({deviceId:n(),label:l(),roi:eH,check:K1,triggerMode:x([`periodic`,`on-motion`,`both`]).optional(),checkIntervalSec:n().optional()}),Z1,{kind:`mutation`,auth:`admin`}),updateScene:k(b({deviceId:n(),monitorId:l(),patch:b({label:l().optional(),roi:eH.optional(),enabled:v().optional(),triggerMode:x([`periodic`,`on-motion`,`both`]).optional(),checkIntervalSec:n().optional(),check:K1.optional(),emit:x([`latched`,`live`]).optional(),quietSeconds:n().int().min(0).max(3600).optional(),minObservationSpacingSec:n().int().min(0).max(3600).optional(),anchorThreshold:n().min(0).max(1).optional(),autoRestore:v().optional(),onUncoveredCondition:V1.optional(),confirm:X1.nullable().optional()})}),_(),{kind:`mutation`,auth:`admin`}),deleteScene:k(b({deviceId:n(),monitorId:l()}),_(),{kind:`mutation`,auth:`admin`}),captureReference:k(b({deviceId:n(),monitorId:l(),stateId:l().optional(),label:l().optional(),condition:B1.optional()}),b({stateId:l(),referenceCount:n()}),{kind:`mutation`,auth:`admin`}),deleteReference:k(b({deviceId:n(),monitorId:l(),stateId:l(),index:n()}),_(),{kind:`mutation`,auth:`admin`}),recheckNow:k(b({deviceId:n(),monitorId:l()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`sceneMonitor.recheck`,label:P(`Re-check a scene`,`Ricontrolla una scena`),phrase:P(`Re-check {monitorId} on {device} now`,`Ricontrolla subito {monitorId} su {device}`),icon:`scan-search`,openArgs:[{key:`monitorId`,label:P(`Scene`,`Scena`),offer:{kind:`dynamic`,from:`status`,field:`monitors`,valueKey:`id`,labelKey:`label`}}]}]}),resetScene:k(b({deviceId:n(),monitorId:l(),recapture:v().optional()}),_(),{kind:`mutation`,auth:`admin`})},status:{schema:Q1,kind:`push`},runtimeState:Q1,durability:`session`,history:`none`,vocabulary:{noun:P(`Scene watch`,`Controllo della scena`),order:3280,extraEvents:[{category:w.EnrichmentSceneStateChanged,label:P(`Scene changed`,`Scena cambiata`),phrase:P(`When a watched scene on {device} changes`,`Quando cambia una scena controllata su {device}`),icon:`scan-search`}]}},t0=b({schedulerId:l().min(1)}),n0={name:`schedulers`,scope:`system`,mode:`singleton`,methods:{list:k(b({}),S(oy),{auth:`admin`}),get:k(t0,b({scheduler:oy.nullable()}),{auth:`admin`}),create:k(b({scheduler:ay}),b({scheduler:oy}),{kind:`mutation`,auth:`admin`}),update:k(b({schedulerId:l().min(1),scheduler:ay}),b({scheduler:oy}),{kind:`mutation`,auth:`admin`}),delete:k(t0,_(),{kind:`mutation`,auth:`admin`}),setEnabled:k(b({schedulerId:l().min(1),profileId:l().min(1).optional(),enabled:v()}),b({scheduler:oy}),{kind:`mutation`,auth:`admin`}),preview:k(b({schedulerId:l().min(1),date:l().regex(fy).optional()}),my,{auth:`admin`}),conflicts:k(b({scheduler:ay,schedulerId:l().min(1).optional()}),b({conflicts:S(hy)}),{auth:`admin`}),getStatus:k(b({}),S(_y),{auth:`admin`}),getTraces:k(t0,b({traces:S(Oy)}),{auth:`admin`})},vocabulary:{notOperatorFacing:`time schedulers — authored on their own page, not device actions`}},r0=b({isRunning:v(),lastRunAt:n(),lastRunSuccess:v().nullable(),lastError:l().nullable(),lastChangedAt:n()}),i0={name:`script-runner`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Script],methods:{run:k(b({deviceId:n().int().nonnegative(),variables:m(l(),C()).optional()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`script.run`,label:P(`Run script`,`Esegui lo script`),phrase:P(`Run {device}`,`Esegui {device}`),icon:`scroll-text`,hold:{effects:[{field:`isRunning`,value:!0}],holdMs:MY}}]}),stop:k(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`script.stop`,effect:{field:`isRunning`,value:!1},label:P(`Stop script`,`Ferma lo script`),phrase:P(`Stop {device}`,`Ferma {device}`),icon:`square`}]})},status:{schema:r0,kind:`push`},runtimeState:r0,durability:`session`,history:`none`,vocabulary:{noun:P(`Script`,`Script`),order:2090,state:[{kind:`boolean`,field:`isRunning`,label:P(`Running`,`In esecuzione`),whenTrue:P(`When {device} starts running`,`Quando {device} parte`),whenFalse:P(`When {device} finishes`,`Quando {device} termina`),icon:`scroll-text`}]}},a0=x([`workspace`,`baked`,`data-root`]),o0=x([`idle`,`checking`,`staging`,`pending-restart`,`awaiting-confirmation`]),s0=x([`in-sync`,`behind-patch`,`behind-series`,`ahead`,`unknown`]),c0=b({state:s0,seedVersion:l().nullable(),contractVersion:l().nullable(),contractSource:x([`registry`,`running`]).nullable(),message:l()}),l0=x([`docker`,`electron`,`native`,`contradictory`,`unknown`]),u0=b({fact:x([`dockerenv-file`,`proc-1-cgroup`,`platform`,`electron-app-version-env`]),mode:x([`observed`,`declared`]),holds:v(),detail:l()}),d0=b({kind:l0,evidence:S(u0),currentVersion:l().nullable()}),f0=b({fromVersion:l(),toVersion:l().nullable(),atMs:n(),reason:l()}),p0=b({version:l(),update:b({available:v(),downloaded:v(),version:l().nullable(),checking:v(),error:l().nullable()}),stateAtMs:n(),stale:v()}),m0=x([`not-electron`,`no-app-state`,`app-state-stale`,`not-downloaded`]),h0=b({accepted:v(),reason:m0.nullable()}),g0=b({runnerId:l(),addonIds:S(l()),reason:l()}),_0=b({checkedAtMs:n(),expected:n(),running:n(),failed:S(l()),refused:S(g0),missing:S(l()),pending:S(l()).optional(),planKnown:v()}),v0=b({packageName:l(),runningVersion:l().nullable(),nodeRuntimeVersion:l().nullable(),activeVersion:l().nullable(),installedVersion:l().nullable().optional(),restartRequired:v().optional(),previousVersion:l().nullable(),seedVersion:l().nullable(),latestVersion:l().nullable(),updateAvailable:v(),bootMode:a0,updateState:o0,pendingVersion:l().nullable(),rolledBack:f0.nullable(),stateFileCorrupt:v(),lastCheckedAtMs:n().nullable(),imageContract:c0.optional(),wrapper:d0.optional(),runners:_0.optional(),desktopApp:p0.optional()}),y0=b({packageName:l(),runningVersion:l().nullable(),latestVersion:l().nullable(),updateAvailable:v(),checkedAtMs:n(),error:l().nullable(),pendingVersion:l().nullable().optional(),restartRequired:v().optional()}),b0=x([`staged`,`restart-scheduled`,`already-current`,`refused`,`failed`]),x0=b({addonId:l(),reason:l(),remedy:l()}),S0=b({accepted:v(),targetVersion:l().nullable(),restarting:v(),message:l(),outcome:b0.optional(),reason:l().nullable().optional(),error:l().nullable().optional(),blockers:S(x0).optional(),unmet:S(Nu).optional(),requiredAddonUpdates:S(Pu).optional()}),C0=b({heapMb:n().int().nullable(),rssBudgetMb:n().int().nullable()}),yje=b({heapMb:n().int().min(512).max(65536).nullable(),rssBudgetMb:n().int().min(512).max(65536).nullable().optional()}),bje=C0.extend({restartRequired:v()}),w0={name:`server-management`,scope:`system`,mode:`singleton`,methods:{getServerPackageStatus:k(_(),v0,{auth:`admin`}),checkServerUpdate:k(_(),y0,{kind:`mutation`,auth:`admin`}),applyServerUpdate:k(b({version:l().optional(),acknowledgeRefusals:v().optional()}),S0,{kind:`mutation`,auth:`admin`,timeoutMs:16*6e4}),installDesktopUpdate:k(_(),h0,{kind:`mutation`,auth:`admin`}),rollbackServerUpdate:k(_(),S0,{kind:`mutation`,auth:`admin`}),restartServer:k(_(),S0,{kind:`mutation`,auth:`admin`}),getLaunchOverrides:k(_(),C0,{auth:`admin`}),setLaunchOverrides:k(yje,bje,{kind:`mutation`,auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:j.CLUSTER}},T0={Seconds:`seconds`,Plays:`plays`},E0={Camera:`camera`,Fallback:`fallback`},D0=b({min:n().positive(),max:n().positive(),step:n().positive()}),O0=b({allowedSeconds:S(n().positive()).nullable(),rangeSeconds:D0.nullable(),defaultSeconds:n().positive(),allowedPlays:S(n().int().positive()).nullable().default(null),rangePlays:D0.nullable().default(null),defaultPlays:n().int().positive().nullable().default(null),unit:x([T0.Seconds,T0.Plays]),secondsPerPlay:n().positive().nullable(),source:x([E0.Camera,E0.Fallback]),fetchedAt:n()}),k0=b({active:v(),activeUntil:n().nullable(),durationSeconds:n().nullable(),plays:n().int().positive().nullable().default(null),activeUntilEstimated:v().default(!1),lastTriggeredAt:n()}),A0=b({deviceId:n().int().nonnegative(),durationSeconds:n().positive().optional(),plays:n().int().positive().optional()}).refine(e=>e.durationSeconds===void 0||e.plays===void 0,{message:`a siren trigger takes durationSeconds or plays, not both`,path:[`plays`]}),j0=k0.extend({lastFetchedAt:n()}),M0={name:`siren`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Siren],methods:{getOptions:k(b({deviceId:n().int().nonnegative()}),O0,{kind:`query`,auth:`protected`}),getPlayChoices:k(b({deviceId:n().int().nonnegative()}),S(n().int().positive()),{kind:`query`,auth:`protected`}),trigger:k(A0,k0,{kind:`mutation`,auth:`protected`,actions:[{id:`siren.trigger`,label:P(`Sound the siren`,`Fai suonare la sirena`),phrase:P(`Sound {device}`,`Fai suonare {device}`),icon:`siren`,args:{}},{id:`siren.triggerPlays`,label:P(`Sound the siren N times`,`Fai suonare la sirena N volte`),phrase:P(`Sound {device} {plays} times`,`Fai suonare {device} {plays} volte`),icon:`siren`,openArgs:[{key:`plays`,label:P(`Plays`,`Riproduzioni`),offer:{kind:`dynamic`,from:`method`,method:`getPlayChoices`,valueKind:`number`}}]}]}),stop:k(b({deviceId:n().int().nonnegative()}),k0,{kind:`mutation`,auth:`protected`,actions:[{id:`siren.stop`,label:P(`Silence the siren`,`Zittisci la sirena`),phrase:P(`Silence {device}`,`Zittisci {device}`),icon:`siren`,effect:{field:`active`,value:!1},args:{}}]})},events:{onSirenChanged:{data:b({deviceId:n(),active:v(),activeUntil:n().nullable()}),notOperatorFacing:"the `active` state trigger phrases both edges of this change"}},status:{schema:k0,kind:`command-driven`},runtimeState:j0,durability:`session`,history:`none`,vocabulary:{noun:P(`Siren`,`Sirena`),order:1170,state:[{kind:`boolean`,field:`active`,label:P(`Siren sounding`,`Sirena in funzione`),whenTrue:P(`When {device} starts sounding`,`Quando {device} inizia a suonare`),whenFalse:P(`When {device} falls silent`,`Quando {device} smette di suonare`),icon:`siren`}]}},N0=b({detected:v(),lastChangedAt:n()}),P0={name:`smoke`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Sensor],methods:{},status:{schema:N0,kind:`push`},runtimeState:N0,durability:`restored`,history:{fields:{detected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:P(`Smoke detector`,`Rilevatore di fumo`),order:5190,state:[{kind:`boolean`,field:`detected`,label:P(`Detected`,`Rilevato`),whenTrue:P(`When {device} detects smoke`,`Quando {device} rileva fumo`),whenFalse:P(`When smoke clears on {device}`,`Quando il fumo su {device} si dirada`),icon:`alarm-smoke`}]}},xje=3,F0=5*1024*1024,I0=`<!--camstack-images-->`,L0=b({ticket:Ti,mime:l().min(1),name:l().min(1),contentId:l().min(1),placement:x([`inline`,`attachment`]),deviceId:n().int().nonnegative().optional()}),R0=0;function z0(e){return R0+=1,`camstack_${e}_${R0.toString(36)}_${Date.now().toString(36)}`}function Sje(e){return/^[\x20-\x7E]*$/.test(e)?e:`=?UTF-8?B?${Buffer.from(e,`utf8`).toString(`base64`)}?=`}function B0(e){return(Array.isArray(e)?e:[e]).join(`, `)}function Cje(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`)}function V0(e,t){let n=e.replace(/[\r\n"]/g,``).trim();return n.length>0?n:t}function wje(e){let t=Buffer.from(e).toString(`base64`),n=[];for(let e=0;e<t.length;e+=76)n.push(t.slice(e,e+76));return n.join(`\r
1113
+ `}function R_e(e){return`subjects`in e?e.subjects:e.classes.map(c_)}var z_e=new Set(Object.values(n_.mapping));function B_e(e){return n_.mapping[e]??e}function V_e(e,t){let n=e.toLowerCase(),r=t.toLowerCase();return n===r?!0:z_e.has(n)&&B_e(r)===n}function H_e(e){return e===`start`||e===`update`||e===`end`}var U_e=class{trigger;fired=new Map;subjects;constructor(e){this.trigger=e,this.subjects=R_e(e)}get firedCount(){return this.fired.size}evaluate(e,t){let{deviceId:n,trackId:r,phase:i}=e;if(typeof n!=`number`||typeof r!=`string`||!H_e(i))return{kind:`ignore`,why:`malformed track-lifecycle event`};if(!this.trigger.deviceIds.includes(n))return{kind:`ignore`,why:`device ${n} is not one of the trigger's devices`};let a=`${n}|${r}`;if(i===`end`)return this.fired.delete(a),{kind:`ignore`,why:`track ended`};this.expire(t);let o=typeof e.bestClassName==`string`?e.bestClassName:``,s=typeof e.bestConfidence==`number`?e.bestConfidence:0,c={deviceId:n,className:o,trackId:r,score:s,label:``};if(this.fired.has(a))return{kind:`reject`,reason:`already fired for track ${r}`,vars:c};let l=f_(this.subjects,{className:o,...Array.isArray(e.classes)?{classes:e.classes.filter(e=>typeof e==`string`)}:{},...typeof e.label==`string`?{label:e.label}:{},...typeof e.identityId==`string`?{identityId:e.identityId}:{},...typeof e.plateText==`string`?{plateText:e.plateText}:{}});if(!l.matches)return{kind:`reject`,reason:l.reason,vars:c};let u={...c,label:l.label};if(this.trigger.minScore!==void 0&&s<this.trigger.minScore)return{kind:`reject`,reason:`score ${s} < ${this.trigger.minScore}`,vars:u};if(this.trigger.zones!==void 0){let t=Array.isArray(e.zonesVisited)?e.zonesVisited.filter(e=>typeof e==`string`):[];if(!this.trigger.zones.some(e=>t.includes(e)))return{kind:`reject`,reason:`zone mismatch: visited [${t.join(`, `)}], wanted [${this.trigger.zones.join(`, `)}]`,vars:u}}return this.remember(a,t),{kind:`fire`,reason:`${l.label===``?o:l.label} ${s} on device ${n}`,vars:u}}remember(e,t){for(this.fired.set(e,t);this.fired.size>512;){let e=this.fired.keys().next();if(e.done===!0)break;this.fired.delete(e.value)}}expire(e){for(let[t,n]of this.fired){if(e-n<9e5)break;this.fired.delete(t)}}};function W_e(e){return`classes`in e}function G_e(e){return e===`appeared`||e===`departed`}function K_e(e,t){let{deviceId:n,entryId:r,phase:i}=t;if(typeof n!=`number`||typeof r!=`string`||!G_e(i))return{kind:`ignore`,why:`malformed stationary-changed event`};if(!e.deviceIds.includes(n))return{kind:`ignore`,why:`device ${n} is not one of the trigger's devices`};if(i!==e.phase)return{kind:`ignore`,why:`phase ${i}, the trigger wants ${e.phase}`};let a=typeof t.className==`string`?t.className:``,o=Array.isArray(t.zones)?t.zones.filter(e=>typeof e==`string`):[],s={deviceId:n,className:a,zones:o,phase:i,entryId:r},c=W_e(e)?e.classes?.map(c_):e.subjects;if(c!==void 0){let e=f_(c,{className:a});if(!e.matches)return{kind:`reject`,reason:e.reason,vars:s}}return e.zones!==void 0&&!e.zones.some(e=>o.includes(e))?{kind:`reject`,reason:`zone mismatch: in [${o.join(`, `)}], wanted [${e.zones.join(`, `)}]`,vars:s}:{kind:`fire`,reason:`${a} ${i} on device ${n}`,vars:s}}var Ab=b({deviceId:n(),eventType:l(),sourceId:l().optional(),data:m(l(),C()).nullable(),timestamp:n().meta(M(`none`)),seq:n().meta(M(`count`))}),jb=b({eventTypes:S(l()),vocabulary:S(Cme).default([]),lastEvent:Ab.nullable(),eventCountSinceStart:n().meta(M(`count`))}),Mb={name:`event-emitter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.EventEmitter],methods:{},events:{onEvent:{data:Ab,trigger:{category:w.EventEmitted,label:P(`Fired an event`,`Ha generato un evento`),phrase:P(`When {device} fires an event`,`Quando {device} genera un evento`),icon:`zap`}}},status:{schema:jb,kind:`push`},runtimeState:jb,durability:`session`,history:`none`,vocabulary:{noun:P(`Event source`,`Sorgente di eventi`),order:5280}},q_e=3,J_e=32;function Y_e(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`}function Nb(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Pb(e){let t={},n=(e,r,i)=>{if(!(Object.keys(t).length>=J_e)){if(Y_e(e)){t[r]=e;return}if(!(!Nb(e)||i>=q_e))for(let[t,a]of Object.entries(e))n(a,`${r}.${t}`,i+1)}};if(Nb(e))for(let[t,r]of Object.entries(e))n(r,`data.${t}`,1);return t}function X_e(e,t){let n=e;for(let e of t.split(`.`)){if(!Nb(n))return;n=n[e]}return n}function Fb(e,t){return t===null?!0:e.timestamp===t.timestamp?e.seq>t.seq:e.timestamp>t.timestamp}var Ib=`recovered by reconcile`,Z_e=class{leaf;#e=null;#t=!1;#n=null;constructor(e){this.leaf=e}onEvent(e){let t=Ab.safeParse(e);if(!t.success)return{kind:`ignore`,why:`malformed event`};let n=t.data;return n.deviceId===this.leaf.deviceId?Fb(n,this.#e)?(this.#e={timestamp:n.timestamp,seq:n.seq},this.#t=!0,this.#i(n,!1)):{kind:`ignore`,why:`this fire was already handled`}:{kind:`ignore`,why:`device ${n.deviceId} is not the trigger's device`}}onStatus(e){let t=jb.safeParse(e);if(!t.success)return{kind:`ignore`,why:`the event-emitter status is unreadable`};this.#n=kme(t.data);let n=t.data.lastEvent,r=!this.#t;return this.#t=!0,n===null?{kind:`ignore`,why:`the device has not fired`}:Fb(n,this.#e)?(this.#e={timestamp:n.timestamp,seq:n.seq},r?{kind:`ignore`,why:`seeded: what fired before the start is not a trigger`}:n.deviceId===this.leaf.deviceId?this.#i(n,!0):{kind:`ignore`,why:`device ${n.deviceId} is not the trigger's device`}):{kind:`ignore`,why:`this fire was already handled`}}#r(e){let t=this.#n??Dme([e.eventType]);return(kg(t,e.eventType,e.sourceId)??kg(t,e.eventType))?.kind}#i(e,t){let{eventIds:n,sourceIds:r,kinds:i,match:a}=this.leaf;if(n!==void 0&&!n.includes(e.eventType))return{kind:`ignore`,why:`event ${e.eventType} is not one of [${n.join(`, `)}]`};if(r!==void 0&&(e.sourceId===void 0||!r.includes(e.sourceId)))return{kind:`ignore`,why:`source ${e.sourceId??`(none)`} is not one of [${r.join(`, `)}]`};let o=this.#r(e);if(i!==void 0&&(o===void 0||!i.includes(o)))return{kind:`ignore`,why:`kind ${o??`(none)`} is not one of [${i.join(`, `)}]`};let s={deviceId:e.deviceId,eventType:e.eventType,sourceId:e.sourceId??``,eventKind:o??``},c=Pb(e.data);for(let t of a??[]){let n=X_e(e.data,t.path);if(n!==t.equals)return{kind:`reject`,reason:`data.${t.path} is ${JSON.stringify(n)??`not set`}, the trigger wants ${JSON.stringify(t.equals)}`,vars:s,data:c}}let l=`${e.eventType}${e.sourceId===void 0?``:` from ${e.sourceId}`}`;return{kind:`fire`,reason:t?`${l} — ${Ib}`:l,vars:s,data:c}}},Lb=6e4;function Rb(e){return(e/Lb).toFixed(1)}var Q_e=class{mode;active=0;pending=0;constructor(e){this.mode=e}get activeRuns(){return this.active}get queuedTriggers(){return this.pending}admit(){let e=this.mode;switch(e.mode){case`single`:case`cooldown`:return this.active>0?{decision:`drop`,reason:`${e.mode}: a run is already in progress`}:(this.active+=1,{decision:`run`,reason:`${e.mode}: no run in progress`});case`restart`:return this.active>0?(this.active+=1,{decision:`restart`,reason:`restart: aborting ${this.active-1} run(s) in progress`}):(this.active+=1,{decision:`run`,reason:`restart: no run in progress`});case`queued`:return this.active===0?(this.active+=1,{decision:`run`,reason:`queued: no run in progress`}):this.pending<e.max?(this.pending+=1,{decision:`queued`,reason:`queued: a run is in progress, waiting ${this.pending} of ${e.max}`}):{decision:`drop`,reason:`queued: a run is in progress and the queue is full (${e.max})`};case`parallel`:return this.active<e.max?(this.active+=1,{decision:`run`,reason:`parallel: ${this.active} of ${e.max} running`}):{decision:`drop`,reason:`parallel: ${e.max} runs already in progress`}}}release(){return this.active>0&&--this.active,this.mode.mode===`queued`&&this.pending>0?(--this.pending,this.active+=1,!0):!1}cooldown(e){if(this.mode.mode!==`cooldown`)return{ok:!0,bypassed:!1,reason:``};let t=this.mode.minutes*Lb;if(e.lastRunStartedAt===null)return{ok:!0,bypassed:!1,reason:`cooldown ${this.mode.minutes} min: no earlier run`};let n=e.now-e.lastRunStartedAt;if(n>=t)return{ok:!0,bypassed:!1,reason:`cooldown ${this.mode.minutes} min: last run started ${Rb(n)} min ago`};let r=`${Rb(t-n)} min left`;return e.manual?{ok:!0,bypassed:!0,reason:`cooldown ${this.mode.minutes} min bypassed by a manual trigger (${r})`}:{ok:!1,bypassed:!1,reason:`cooldown ${this.mode.minutes} min: last run started ${Rb(n)} min ago, ${r}`}}},zb=x([`string`,`number`,`boolean`,`select`]),$_e=/^[A-Za-z_][A-Za-z0-9_]*$/,Bb=h([l(),n(),v()]),Vb=b({name:l().regex($_e),label:l().min(1).max(120).optional(),type:zb,required:v().optional(),default:Bb.optional(),options:S(l().min(1)).min(1).optional()}).superRefine((e,t)=>{e.type===`select`&&e.options===void 0&&t.addIssue({code:`custom`,message:`a select variable needs options`,path:[`options`]}),e.default!==void 0&&Hb(e,e.default)!==null&&t.addIssue({code:`custom`,message:Hb(e,e.default)??`invalid default`,path:[`default`]})});function Hb(e,t){switch(e.type){case`string`:return typeof t==`string`?null:`variable "${e.name}" must be a string`;case`number`:return typeof t==`number`&&Number.isFinite(t)?null:`variable "${e.name}" must be a number`;case`boolean`:return typeof t==`boolean`?null:`variable "${e.name}" must be true or false`;case`select`:return typeof t==`string`&&(e.options??[]).includes(t)?null:`variable "${e.name}" must be one of ${(e.options??[]).join(`, `)}`}}function eve(e,t){let n=e??[],r=t??{};for(let e of Object.keys(r))if(!n.some(t=>t.name===e))return{ok:!1,error:`unknown variable "${e}"`};let i={};for(let e of n){let t=r[e.name]??e.default;if(t===void 0){if(e.required===!0)return{ok:!1,error:`variable "${e.name}" is required`};continue}let n=Hb(e,t);if(n!==null)return{ok:!1,error:n};i[e.name]=t}return{ok:!0,values:i}}var Ub=x([`internal`,`addon`]),Wb=`internal:`;function tve(e){return`${Wb}${e}`}function Gb(e){return e.startsWith(`internal:`)&&e.length>9}function Kb(e){if(Gb(e))return null;let t=e.indexOf(`:`);return t>0&&t<e.length-1?e.slice(0,t):null}var qb=b({isRunning:v(),lastRunAt:n().nullable(),lastError:l().nullable()}),nve={isRunning:!1,lastRunAt:null,lastError:null},Jb=n().int().min(0).max(86400),Yb=b({id:l().min(3),name:l().min(1).max(120),addonId:l().min(1),source:Ub,readOnly:v(),steps:S(vv).min(1).max(50).optional(),variables:S(Vb).max(20).optional(),minDelaySec:Jb.optional(),tags:Vh.optional(),status:qb}).superRefine((e,t)=>{if(e.source===`internal`){Gb(e.id)||t.addIssue({code:`custom`,message:`an internal action id is internal:<uuid>`,path:[`id`]});return}e.steps!==void 0&&t.addIssue({code:`custom`,message:`only an internal action carries steps`,path:[`steps`]}),e.readOnly||t.addIssue({code:`custom`,message:`an addon action is read-only here`,path:[`readOnly`]}),Kb(e.id)===null&&t.addIssue({code:`custom`,message:`an addon action id is <addonId>:<localId>`,path:[`id`]})}),Xb=b({name:l().min(1).max(120),steps:S(vv).min(1).max(50),variables:S(Vb).max(20).optional(),minDelaySec:Jb.optional(),tags:Vh.optional()}),Zb=b({blockId:l().min(1).optional()}),Qb=h([yy,p(`started`),p(`timed-out`)]),$b=b({runId:l().min(1),outcome:Qb,message:l().optional()}),rve=x([`not-found`,`read-only`,`invalid-variables`,`invalid-steps`,`not-linked`,`template-scope`,`busy`]),ive=class extends Error{code;constructor(e,t){super(`[${e}] ${t}`),this.name=`ActionError`,this.code=e}},ex=b({actionId:l(),runId:l(),isRunning:v(),outcome:yy.optional(),lastRunAt:n().nullable(),lastError:l().nullable()});function ave(e){switch(e.kind){case`wait`:case`command`:return`else`in e?e.else??[]:[];case`parallel`:case`repeat`:return e.steps;case`choose`:return[...e.branches.flatMap(e=>e.steps),...e.else??[]];default:return[]}}function tx(e){return[...e.kind===`command`&&e.target.kind===`devices`?[{actionId:e.actionId,ids:e.target.ids}]:[],...ave(e).flatMap(tx)]}async function ove(e,t){let n=e.flatMap(tx);if(n.length===0)return;let r=[...new Set(n.flatMap(e=>e.ids))],i=r.length===0?new Map:await t.boundCapsOf(r);for(let{actionId:e,ids:t}of n){Va(e,void 0);for(let n of t)Wne(e,n,i.get(n)??[])}}async function sve(e,t,n=Date.now,r,i,a){let o=r?.mirror??new ub(ob(e));await o.refresh(t);let s=_b(e,o,n(),{...r===void 0?{}:{holds:r.holds,rootPath:r.rootPath},...i===void 0?{}:{site:i},trigger:a??`unknown`}),c=s.nodes.filter(e=>e.outcome!==`pass`).map(e=>e.reason)[0];return s.unknown?{result:`unknown`,reason:`a state the condition reads is not known${c===void 0?``:` (${c})`}`}:s.pass?{result:`true`,reason:`the condition holds`}:{result:`false`,reason:c??`the condition does not hold`}}async function cve(e){try{return await e()}catch(e){return{result:`unknown`,reason:e instanceof Error?e.message:String(e)}}}async function lve(e){let t=e.now(),n=t+e.timeoutMs;for(;;){let r=await cve(e.read),i=e.now()-t;if(e.isAborted())return{result:`aborted`,waitedMs:i};if(r.result===`true`)return{result:`met`,waitedMs:i};let a=n-e.now();if(a<=0)return{result:`timed-out`,waitedMs:i,lastReason:r.reason};if(await e.nextWake(a),e.isAborted())return{result:`aborted`,waitedMs:e.now()-t}}}function uve(e,t){return`timed out after ${e} s: ${t}`}function nx(e){return ma(e)}function rx(e){let t=nx(e);if(t===void 0)return[];let n=Vl(t);return n===void 0?[t]:[t,...Kl(n).filter(e=>e!==t)]}var ix=b({path:l(),deviceId:n().int().optional(),field:l(),value:n(),assumedUnit:l(),message:l()});function dve(e){let t=qg(e);return t instanceof le?t:void 0}function ax(e){let t=new Map(e.map(e=>[e.name,e]));return{fieldQuantity(e,n){let r=t.get(e)?.status;if(r!==void 0)return[...Jg(r.schema),...r.itemArray===void 0?[]:rhe(r.itemArray)].find(e=>e.path===n)?.quantity},paramMeta(e,n,r){let i=t.get(e)?.methods[n]?.input;if(i===void 0)return;let a=dve(i)?.shape[r];return a===void 0?void 0:uhe(a)}}}function ox(e){return Xg(e)??e}function sx(e){return rx(e).length>1}function cx(e){return{...e,message:`${e.field}: the bare number ${e.value} was taken as ${e.assumedUnit} — send { value, unit } to state the unit`}}function lx(e,t){t_({value:1,unit:e,target:t})}function fve(e,t,n){let r=t.fieldQuantity(e.cap,e.fieldPath),i=r===void 0?void 0:nx(r),a=e_(e.value)||e.unit!==void 0;if(i===void 0||r===void 0){if(a)throw new Qg(`no-quantity`,`${e.cap}.${e.fieldPath} is not a quantity — it takes no unit`);return{leaf:e,warnings:[]}}if(e_(e.value)){let t=t_({value:e.value.value,unit:e.value.unit,target:i});return{leaf:{...e,value:t,unit:ox(e.value.unit)},warnings:[]}}return typeof e.value==`number`?e.unit===void 0?sx(r)?{leaf:e,warnings:[cx({path:n,deviceId:e.deviceId,field:e.fieldPath,value:e.value,assumedUnit:i})]}:{leaf:e,warnings:[]}:(lx(e.unit,i),{leaf:e,warnings:[]}):{leaf:e,warnings:[]}}function ux(e,t,n=`when`){switch(e.kind){case`device-is`:{let{leaf:r,warnings:i}=fve(e,t,n);return{value:r,warnings:i}}case`not`:{let r=ux(e.child,t,`${n}.child`);return{value:{...e,child:r.value},warnings:r.warnings}}case`all`:case`any`:{let r=e.children.map((e,r)=>ux(e,t,`${n}.children.${r}`));return{value:{...e,children:r.map(e=>e.value)},warnings:r.flatMap(e=>e.warnings)}}default:return{value:e,warnings:[]}}}function pve(e,t,n){if(La(e.actionId)===void 0)return{value:e,warnings:[]};let r=e.target.kind===`devices`&&e.target.ids.length===1?e.target.ids[0]:void 0,{cap:i,method:a}=Va(e.actionId,void 0),o={...e.args},s={...e.argUnits},c=[];for(let[n,r]of Object.entries(e.argUnits??{})){let e=t.paramMeta(i,a,n);if(e===void 0)throw new Qg(`no-quantity`,`${i}.${a}(${n}) is not a quantity — it takes no unit`);lx(r,e.unit)}for(let[l,u]of Object.entries(e.args??{})){let e=t.paramMeta(i,a,l);e!==void 0&&(e_(u)?(o[l]=t_({value:u.value,unit:u.unit,target:e.unit}),s[l]=ox(u.unit)):typeof u==`number`&&s[l]===void 0&&sx(e.quantity)&&c.push(cx({path:`${n}.args.${l}`,...r===void 0?{}:{deviceId:r},field:l,value:u,assumedUnit:e.unit})))}let{argUnits:l,...u}=e;return{value:{...u,...e.args===void 0?{}:{args:o},...Object.keys(s).length>0?{argUnits:s}:{}},warnings:c}}function dx(e,t,n=`steps`){let r=[],i=[];return e.forEach((e,a)=>{if(e.kind!==`command`){r.push(e);return}let o=pve(e,t,`${n}.${a}`);r.push(o.value),i.push(...o.warnings)}),{value:r,warnings:i}}function fx(e,t){let n=ux(e.when,t,`when`),r=dx(e.actions,t,`actions`);return{value:{...e,when:n.value,actions:r.value},warnings:[...n.warnings,...r.warnings]}}function px(e,t){switch(e.kind){case`device-is`:{if(typeof e.value!=`number`||e.unit!==void 0)return e;let n=t.fieldQuantity(e.cap,e.fieldPath);if(n===void 0||rx(n).length<2)return e;let r=nx(n);return r===void 0?e:{...e,unit:r}}case`not`:return{...e,child:px(e.child,t)};case`all`:case`any`:return{...e,children:e.children.map(e=>px(e,t))};default:return e}}function mve(e,t){if(e.kind!==`command`||e.args===void 0||La(e.actionId)===void 0)return e;let{cap:n,method:r}=Va(e.actionId,void 0),i={...e.argUnits};for(let[a,o]of Object.entries(e.args)){if(typeof o!=`number`||i[a]!==void 0)continue;let e=t.paramMeta(n,r,a);e!==void 0&&rx(e.quantity).length>1&&(i[a]=e.unit)}return Object.keys(i).length===0?e:{...e,argUnits:i}}function mx(e,t){let n={...e,when:px(e.when,t),actions:e.actions.map(e=>mve(e,t))};try{return{ok:!0,recipe:fx(n,t).value}}catch(e){if(e instanceof Qg)return{ok:!1,error:e.message};throw e}}var hve=[`devices`,`time`,`cameras`,`events`,`logic`,`system`],hx=[`trigger`,`any`],gx=[`trigger`,`guard`,`any`],_x={detection:{kind:`detection`,category:`cameras`,role:`event`,allowedIn:hx,i18nKey:`automation.leafCatalog.detection`,keywords:[`camera`,`person`,`vehicle`,`animal`,`object`,`motion`,`detected`],needsDeviceValue:!1,seed:()=>({kind:`detection`,subjects:[{macro:`person`}],deviceIds:[]})},stationary:{kind:`stationary`,category:`cameras`,role:`event`,allowedIn:hx,i18nKey:`automation.leafCatalog.stationary`,keywords:[`camera`,`parked`,`stops`,`leaves`,`left`,`appeared`,`object`],needsDeviceValue:!1,seed:()=>({kind:`stationary`,deviceIds:[],phase:`appeared`})},"device-becomes":{kind:`device-becomes`,category:`devices`,role:`event`,allowedIn:hx,i18nKey:`automation.leafCatalog.device-becomes`,keywords:[`device`,`value`,`changes`,`turns`,`on`,`off`,`above`,`below`,`state`],needsDeviceValue:!0,seed:()=>({kind:`device-becomes`,deviceId:0,cap:``,fieldPath:``})},"device-event":{kind:`device-event`,category:`events`,role:`event`,allowedIn:hx,i18nKey:`automation.leafCatalog.device-event`,keywords:[`event`,`system`,`button`,`press`,`doorbell`,`alarm`,`category`],needsDeviceValue:!1,seed:()=>({kind:`device-event`,category:``})},"device-fired":{kind:`device-fired`,category:`devices`,role:`event`,allowedIn:hx,i18nKey:`automation.leafCatalog.device-fired`,keywords:[`button`,`press`,`long`,`remote`,`switch`,`key`,`fires`,`event`,`click`],needsDeviceValue:!1,seed:()=>({kind:`device-fired`,deviceId:0})},schedule:{kind:`schedule`,category:`time`,role:`event`,allowedIn:hx,i18nKey:`automation.leafCatalog.schedule`,keywords:[`time`,`clock`,`daily`,`cron`,`sunrise`,`sunset`,`at`,`weekday`],needsDeviceValue:!1,seed:()=>({kind:`schedule`,cron:`0 30 23 * * *`})},interval:{kind:`interval`,category:`time`,role:`event`,allowedIn:hx,i18nKey:`automation.leafCatalog.interval`,keywords:[`time`,`every`,`minutes`,`repeat`,`periodic`,`timer`],needsDeviceValue:!1,seed:()=>({kind:`interval`,minutes:5})},manual:{kind:`manual`,category:`system`,role:`event`,allowedIn:hx,i18nKey:`automation.leafCatalog.manual`,keywords:[`run`,`button`,`hand`,`test`,`on demand`],needsDeviceValue:!1,seed:()=>({kind:`manual`})},"device-is":{kind:`device-is`,category:`devices`,role:`state`,allowedIn:gx,i18nKey:`automation.leafCatalog.device-is`,keywords:[`device`,`value`,`is`,`equals`,`above`,`below`,`held`,`stable`,`for`],needsDeviceValue:!0,seed:()=>({kind:`device-is`,deviceId:0,cap:``,fieldPath:``,operator:`eq`,value:``})},"stationary-present":{kind:`stationary-present`,category:`cameras`,role:`state`,allowedIn:gx,i18nKey:`automation.leafCatalog.stationary-present`,keywords:[`camera`,`parked`,`present`,`car`,`object`,`still there`],needsDeviceValue:!1,seed:()=>({kind:`stationary-present`,deviceId:0})},"time-is":{kind:`time-is`,category:`time`,role:`state`,allowedIn:gx,i18nKey:`automation.leafCatalog.time-is`,keywords:[`time`,`hour`,`window`,`between`,`night`,`day`,`weekday`,`sunset`,`sunrise`],needsDeviceValue:!1,seed:()=>({kind:`time-is`,between:{from:{kind:`clock`,hh:22,mm:0},to:{kind:`clock`,hh:6,mm:0}}})},"triggered-by":{kind:`triggered-by`,category:`logic`,role:`state`,allowedIn:gx,i18nKey:`automation.leafCatalog.triggered-by`,keywords:[`trigger`,`triggered`,`started`,`which`,`branch`,`fired`],needsDeviceValue:!1,seed:()=>({kind:`triggered-by`,leafIds:[]})},expression:{kind:`expression`,category:`logic`,role:`state`,allowedIn:gx,i18nKey:`automation.leafCatalog.expression`,keywords:[`formula`,`math`,`arithmetic`,`sum`,`compare`,`calculate`,`held`],needsDeviceValue:!1,seed:()=>({kind:`expression`,expr:``,bindings:{}})}},vx=[`detection`,`stationary`,`device-becomes`,`device-fired`,`device-event`,`schedule`,`interval`,`manual`,`device-is`,`stationary-present`,`time-is`,`triggered-by`,`expression`];function gve(e){return _x[e]}function _ve(e){return _x[e].seed()}function vve(e){return vx.filter(t=>_x[t].allowedIn.includes(e))}function yx(e){return e instanceof Error?e.message:String(e)}function yve(e){return e.startsWith(`[busy]`)?`already-running`:e.startsWith(`[not-found]`)?`not-found`:null}async function bve(e,t,n){let{exporter:r,actionId:i}=n,a={actionId:i},o=(e,n)=>(t.warn(`${r}: exported action not run — ${e}`,{tags:a,meta:{reason:e,...n?{detail:n}:{}}}),{status:`refused`,reason:e});try{let n=await e.actions.run.mutate({actionId:i});if(n.outcome===`skipped-overlap`)return o(`already-running`,n.message);if(n.outcome===`skipped-cooldown`)return o(`cooldown`,n.message);if(n.outcome===`failed`||n.outcome===`aborted`||n.outcome===`timed-out`){let e=n.message??n.outcome;return t.warn(`${r}: exported action failed`,{tags:a,meta:{outcome:n.outcome,message:e}}),{status:`failed`,message:e}}return t.info(`${r}: exported action ran`,{tags:a,meta:{outcome:n.outcome}}),{status:`started`}}catch(e){let n=yx(e),i=yve(n);return i===null?(t.warn(`${r}: exported action failed`,{tags:a,meta:{message:n}}),{status:`failed`,message:n}):o(i,n)}}async function xve(e,t,n){let{exporter:r,targetId:i}=n,a={targetId:i};try{let{targets:o,unreadable:s}=await kd(e),c=o.find(e=>e.id===i);if(c===void 0&&s.length>0)throw Error(`notification targets unreadable from ${s.map(e=>e.addonId).join(`, `)}`);if(c===void 0)return t.warn(`${r}: exported notifier not used — target-gone`,{tags:a,meta:{reason:`target-gone`}}),{status:`refused`,reason:`target-gone`};if(!c.enabled)return t.warn(`${r}: exported notifier not used — target-disabled`,{tags:a,meta:{reason:`target-disabled`}}),{status:`refused`,reason:`target-disabled`};let l=await e.notificationOutput.send.mutate({targetId:i,addonId:c.addonId,notification:$u.parse(n.notification)});if(!l.success){let e=l.error??`send failed`;return t.warn(`${r}: exported notifier send failed`,{tags:a,meta:{message:e}}),{status:`failed`,message:e}}return{status:`sent`}}catch(e){let n=yx(e);return t.warn(`${r}: exported notifier send failed`,{tags:a,meta:{message:n}}),{status:`failed`,message:n}}}function Sve(e,t,n,r){let i=[],a=[];for(let o of e)o.kind===`action`&&!t.actionIds.has(o.actionId)?(a.push(o),n.warn(`${r}: exported action was deleted — dropped from the export`,{tags:{actionId:o.actionId}})):o.kind===`notifier`&&!t.targetIds.has(o.targetId)?(a.push(o),n.warn(`${r}: exported notifier target was deleted — dropped from the export`,{tags:{targetId:o.targetId}})):i.push(o);return{kept:i,dropped:a}}var bx=l().min(1),xx=b({instanceId:bx.optional()}),Sx=b({instanceId:bx,name:l(),enabled:v(),kind:l().optional(),nameRule:l().optional()}),Cx=`export-instance-unknown`,wx=class extends Error{code=Cx;instanceId;constructor(e,t){super(`${Cx}: ${e} serves no instance "${t}"`),this.name=`ExportInstanceUnknownError`,this.instanceId=t}};function Tx(e){return`instanceId`in e?e.instanceId:void 0}function Cve(e,t,n){if(n!==void 0&&n!==t)throw new wx(e,n)}var wve=x([`unlinked`,`linked`,`error`]),Ex=b({label:l(),value:l(),secret:v().optional()}),Dx=b({qr:l().optional(),fields:S(Ex).readonly().optional(),note:l().optional()}),Ox=b({linkState:wve,exposedDeviceCount:n(),error:l().optional(),setup:Dx.optional()}),Tve=l(),kx=b({deviceId:l(),exposedAs:l().optional(),exposedName:l().optional(),capabilities:S(l()).optional()}),Ax=b({instanceId:bx,deviceId:l(),capabilities:S(l()).optional(),exposedName:l().nullable().optional()}),jx=b({instanceId:bx,deviceId:l(),name:l().nullable(),dryRun:v().optional()}),Mx=`export-name-refused`,Nx=class extends Error{code=Mx;instanceId;reason;constructor(e,t){super(`${Mx}: ${t}`),this.name=`ExportNameRefusedError`,this.instanceId=e,this.reason=t}},Px=b({instanceId:bx,deviceId:l()}),Fx=x([`device`,`action`,`notifier`]),Ix=i(`kind`,[b({kind:p(`device`),deviceId:l()}),b({kind:p(`action`),actionId:l().min(1)}),b({kind:p(`notifier`),targetId:l().min(1)})]),Lx=b({entity:Ix,exposedAs:l().optional()}),Rx=b({instanceId:bx,entity:Ix}),zx=b({instanceId:bx,entity:Ix}),Bx={name:`device-export`,scope:`system`,mode:`collection`,providerKind:`device-export`,status:{schema:Ox,kind:`poll`},exposesDeviceSettings:!0,methods:{getStatus:k(xx,Ox),listInstances:k(_(),S(Sx)),listSupportedDeviceKinds:k(xx,S(Tve)),listExposedDevices:k(xx,S(kx)),exposeDevice:k(Ax,_(),{kind:`mutation`,auth:`admin`}),unexposeDevice:k(Px,_(),{kind:`mutation`,auth:`admin`}),setExposedName:k(jx,_(),{kind:`mutation`,auth:`admin`}),listSupportedEntityKinds:A(_(),S(Fx)),listExposedEntities:A(xx,S(Lx)),exposeEntity:A(Rx,_(),{kind:`mutation`,auth:`admin`}),unexposeEntity:A(zx,_(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`exports to other ecosystems — configured on the export pages`}},Vx=`exposedNames`,Eve=m(l(),l());function Hx(e,t){if(e==null)return{ok:!0,name:null};if(typeof e!=`string`)return{ok:!1,reason:`The name must be text.`};let n=e.trim().replace(/\s+/g,` `);return n.length===0?{ok:!0,name:null}:t(n)}function Ux(e){let t=Eve.safeParse(e[Vx]);return t.success?t.data:{}}function Dve(e,t,n){let r=Ux(e)[t];if(r===void 0)return null;let i=Hx(r,n);return i.ok?i.name:null}function Wx(e,t,n){let r=Object.fromEntries(Object.entries(Ux(e)).filter(([e])=>e!==t));return{[Vx]:n===null?r:{...r,[t]:n}}}async function Ove(e){let t=Hx(e.raw,e.validate);if(!t.ok)throw new Nx(e.instanceId,t.reason);if(e.dryRun===!0)return{changed:!1,name:t.name};let n=await e.store.read(e.deviceId);return(Ux(n)[e.instanceId]??null)===t.name?{changed:!1,name:t.name}:(await e.store.write(e.deviceId,Wx(n,e.instanceId,t.name)),{changed:!0,name:t.name})}function kve(e,t){let n=()=>{if(e===void 0)throw Error(`${t}: settings are not available`);return e};return{read:e=>n().readDeviceStore(e),write:(e,t)=>n().writeDeviceStore(e,t)}}async function Ave(e,t){let n=await e.listDeviceStoreIds();if(n.length===0)return[];let r=[];for(let[i,a]of await e.readDeviceStoreBatch(n))Ux(a)[t]!==void 0&&(await e.writeDeviceStore(i,Wx(a,t,null)),r.push(i));return r}function jve(e,t){return n=>n.length>t?{ok:!1,reason:`The name is ${n.length} characters; ${e} allows at most ${t}.`}:/\p{Cc}/u.test(n)?{ok:!1,reason:`The name may not contain control characters.`}:{ok:!0,name:n}}var Gx=[`automation`,`action`,`scheduler`,`composition`],Mve=x(Gx),Kx=b({id:n().int().nonnegative(),name:l().min(1),type:l().min(1),room:l().min(1).nullable(),addonId:l().min(1),stableId:l().min(1),caps:S(l().min(1)),zones:S(l().min(1)).optional()}),Nve=b({timeZone:l().min(1),location:b({latitude:n(),longitude:n()}).nullable(),rooms:S(l().min(1)),devices:S(Kx).min(1),actions:S(b({id:l().min(1),name:l().min(1)})).default([])}),Pve=60,qx=b({childDeviceIds:S(n()).readonly(),hiddenChildIds:S(n()).readonly()}),Jx={name:`accessories`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Camera,T.Switch,T.Light,T.Sensor,T.Climate,T.Cover,T.Lock,T.Fan,T.MediaPlayer,T.AlarmPanel,T.Generic],methods:{setChildHidden:k(b({deviceId:n().int().nonnegative(),childDeviceId:n().int().nonnegative(),hidden:v()}),_(),{kind:`mutation`,auth:`admin`})},events:{onAccessoriesChanged:{data:b({deviceId:n(),childDeviceIds:S(n()).readonly(),hiddenChildIds:S(n()).readonly()}),notOperatorFacing:`the device’s child list changed — administration, not a happening`},onChildVisibilityChanged:{data:b({deviceId:n(),childDeviceId:n(),hidden:v()}),notOperatorFacing:`an operator hid or showed a child — administration, not a happening`}},status:{schema:qx,kind:`command-driven`},vocabulary:{noun:P(`Accessories`,`Accessori`),order:3e3}},Yx={name:`action-source`,scope:`system`,mode:`collection`,methods:{listActions:k(b({}),S(Yb),{auth:`admin`}),runAction:k(b({actionId:l().min(1),variables:m(l(),Bb).optional()}),_(),{kind:`mutation`,auth:`admin`}),stopAction:k(b({actionId:l().min(1)}),_(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:j.INTERNAL}},Fve=60*6e4,Ive=3e4,Xx=363e4;function Lve(e){let t=0;for(let n of e)n.kind===`wait`&&(t+=n.seconds*1e3);return t}var Zx=b({actionId:l().min(1)}),Qx=b({deviceId:n().int().nonnegative(),actionIds:S(l().min(1)).max(100)}),$x={name:`actions`,scope:`system`,mode:`singleton`,methods:{list:k(b({}),S(Yb),{auth:`admin`}),get:k(b({actionId:l().min(1),deviceId:n().int().nonnegative().optional()}),b({action:Yb.nullable()}),{role:`viewer`,auth:`protected`,kind:`query`,caller:`required`}),run:k(b({actionId:l().min(1),variables:m(l(),Bb).optional(),wait:v().optional(),origin:Zb.optional(),deviceId:n().int().nonnegative().optional()}),$b,{role:`viewer`,auth:`protected`,kind:`mutation`,caller:`required`,timeoutMs:Xx}),stop:k(Zx,_(),{kind:`mutation`,auth:`admin`}),getTraces:k(Zx,b({traces:S(Oy)}),{auth:`admin`}),create:k(b({action:Xb}),b({action:Yb,warnings:S(ix).optional()}),{kind:`mutation`,auth:`admin`}),update:k(b({actionId:l().min(1),action:Xb.partial()}),b({action:Yb,warnings:S(ix).optional()}),{kind:`mutation`,auth:`admin`}),delete:k(Zx,_(),{kind:`mutation`,auth:`admin`}),listForCamera:k(b({deviceId:n().int().nonnegative()}),S(Yb),{role:`viewer`,auth:`protected`,kind:`query`}),getLinks:k(b({deviceId:n().int().nonnegative()}),Qx,{auth:`admin`}),setLinks:k(Qx,Qx,{kind:`mutation`,auth:`admin`})},events:{onRunChanged:{data:ex}},vocabulary:{notOperatorFacing:`declared actions — run from the Actions page and from the cameras that link them`}},Rve=b({id:l(),label:l(),icon:l(),path:l(),remoteName:l(),bundle:l(),section:l().optional(),sectionLabel:l().optional()}),eS=b({addonId:l(),page:Rve,bundleUrl:l()}),tS={name:`addon-pages`,scope:`system`,mode:`singleton`,methods:{listPages:k(_(),S(eS).readonly())},vocabulary:{notOperatorFacing:j.UI_PLUMBING}},zve=b({method:x([`GET`,`POST`,`PUT`,`DELETE`,`PATCH`]),path:l(),access:x([`public`,`authenticated`,`admin`]).optional(),description:l().optional(),rateLimit:x([`auth`]).optional(),perInstance:v().optional()}),Bve=b({method:l(),path:l(),params:m(l(),l()),query:m(l(),l()),body:C(),headers:m(l(),l()),instanceId:l().optional(),user:b({id:l(),username:l(),isAdmin:v()}).optional(),scopedToken:C().optional()}),Vve=b({status:n().int(),headers:m(l(),l()),redirectUrl:l().nullable(),body:C().optional(),contentType:l().optional()}),nS={name:`addon-routes`,scope:`system`,mode:`collection`,internal:!0,methods:{getRoutes:k(_(),S(zve)),invoke:k(Bve,Vve,{kind:`mutation`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:j.UI_PLUMBING}},rS=b({id:l(),label:l(),icon:l(),order:n().optional()}),iS=b({id:l(),title:l(),titleKey:l().optional(),description:l().optional(),descriptionKey:l().optional(),style:x([`card`,`accordion`]).optional(),defaultCollapsed:v().optional(),columns:h([p(1),p(2),p(3),p(4)]).optional(),tab:l().optional(),location:x([`settings`,`top-tab`,`hero`]).optional(),order:n().optional(),fields:S(_e())}),aS=b({tabs:S(rS).optional(),sections:S(iS)}),oS=m(l(),C()),sS=x(ur),Hve=b({cap:l(),scope:sS,sectionIds:S(l())}),cS=b({success:p(!0)}),lS={name:`addon-settings`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,methods:{getScopedSettings:k(b({addonId:l(),cap:l(),scope:sS,nodeId:l().optional()}),aS.nullable()),listScopedSettings:k(b({addonId:l(),nodeId:l().optional()}),S(Hve).nullable()),updateScopedSettings:k(b({addonId:l(),cap:l(),scope:sS,nodeId:l().optional(),patch:oS}),cS,{kind:`mutation`,auth:`admin`}),readScopedValues:k(b({addonId:l(),cap:l(),scope:sS,nodeId:l().optional()}),m(l(),C()).nullable()),getDeclaredSettingsKeys:k(b({addonId:l(),nodeId:l().optional()}),b({keys:S(l())}).nullable(),{auth:`admin`}),unsetStoredSettingsKeys:k(b({addonId:l(),nodeId:l().optional(),keys:S(l())}),b({removed:S(l()),refused:S(b({key:l(),reason:l()})),secretsCleared:n()}),{kind:`mutation`,auth:`admin`}),getDeviceSettings:k(b({addonId:l(),deviceId:n(),nodeId:l().optional()}),aS.nullable()),updateDeviceSettings:k(b({addonId:l(),deviceId:n(),nodeId:l().optional(),patch:oS}),cS,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:j.ADDON_ADMIN}},uS=x([`device-tab`,`dashboard`,`integration-detail`]),dS=x([`xs`,`sm`,`md`,`lg`,`xl`]),fS=b({remoteName:l(),exposedModule:l(),componentKey:l().optional()}),pS=b({tab:l(),subTab:l().optional(),label:l(),order:n().optional(),kind:p(`remote`),remote:fS,stableId:l(),description:l().optional(),icon:l().optional(),bundle:l(),hosts:S(uS).readonly(),requires:b({deviceContext:v().default(!1),integrationContext:v().default(!1)}),preAuth:v().optional().default(!1),defaultSize:dS.default(`md`),allowedSizes:S(dS).readonly().default([`sm`,`md`,`lg`]),defaultColumns:n().int().min(1).max(12).default(6),defaultRows:n().int().min(1).max(12).default(1)}),mS={name:`addon-widgets-source`,scope:`system`,mode:`collection`,internal:!0,methods:{listWidgets:k(_(),S(pS).readonly(),{auth:`admin`})},vocabulary:{notOperatorFacing:j.UI_PLUMBING}},hS=pS.extend({addonId:l(),bundleUrl:l()}),gS={name:`addon-widgets`,scope:`system`,mode:`singleton`,methods:{listWidgets:k(_(),S(hS).readonly())},vocabulary:{notOperatorFacing:j.UI_PLUMBING}},_S=x([`install`,`update`,`uninstall`,`restart`]),vS=x([`queued`,`fetching`,`staged`,`validating`,`applying`,`restarting`,`applied`,`done`,`failed`,`skipped`]),yS=x([`framework`,`addon`]),bS=b({tsMs:n(),nodeId:l(),packageName:l(),phase:vS,message:l()}),xS=b({taskId:l(),nodeId:l(),packageName:l(),fromVersion:l().nullable(),toVersion:l(),target:yS,phase:vS,stagedPath:l().nullable(),attempts:n(),steps:S(bS),error:l().nullable(),startedAtMs:n().nullable(),finishedAtMs:n().nullable()}),SS=x([`running`,`completed`,`failed`,`partially-failed`,`cancelled`]),CS=x([`single`,`bulk`,`cluster`]),wS=b({jobId:l(),kind:_S,createdAtMs:n(),createdBy:l(),scope:CS,tasks:S(xS),state:SS,schemaVersion:p(1)}),TS=x([`debug`,`info`,`warn`,`error`]),ES=x([`off`,`latest`,`beta`]),DS=x([`off`,`latest`,`beta`,`inherit`]),Uve=b({id:l(),name:l().optional(),version:l().optional(),description:l().optional(),icon:l().optional(),color:l().optional(),capabilities:S(C()).readonly().optional(),packageName:l(),packageVersion:l(),packageDisplayName:l().optional(),bundle:b({displayName:l(),description:l().optional(),icon:l().optional()}).optional(),protected:v().optional(),removable:v().optional(),integrationSection:x([`system`,`providers`]).optional()}),Wve=b({pid:n().optional(),mode:l(),state:l(),reason:l().optional()}),Gve=b({phase:x([`pending`,`healthy`,`failed`]),retryCount:n(),firstFailureAt:n().nullable(),lastAttemptAt:n().nullable(),lastError:b({message:l(),stack:l().optional()}).nullable(),nextRetryAt:n().nullable(),alertEmitted:v(),retrying:v(),inGracePeriod:v()}),OS=b({manifest:Uve,declaration:C().optional(),source:l(),installSource:l().optional(),process:Wve.optional(),hasBackup:v().optional(),health:Gve.nullable().optional()}),kS=b({name:l(),version:l(),dir:l(),installSource:l().optional()}),AS=b({name:l(),currentVersion:l(),latestVersion:l(),category:x([`addon`,`core`]),requiresRestart:v(),isSystem:v(),blockedBy:S(Nu).readonly().optional()}),jS=b({version:l(),publishedAt:l(),deprecated:l().optional(),distTags:S(l()).readonly()}),MS=i(`status`,[b({status:p(`ok`),markdown:l()}),b({status:p(`missing`)}),b({status:p(`error`),message:l()})]),Kve=b({name:l(),version:l(),readme:MS,changelog:MS}),NS=b({name:l(),version:l(),description:l(),keywords:S(l()).readonly(),publishedAt:l(),author:l(),installed:v(),installedVersion:l().optional(),capabilities:S(l()).readonly().nullable()}),PS=b({channel:ES,intervalSeconds:n(),updateCheckIntervalSeconds:n()}),FS=DS,qve=C(),Jve=C(),Yve=C(),IS=x([`uninstalled`,`not-installed`,`refused`,`failed`,`pending-reconnect`]),LS=b({nodeId:l(),outcome:IS,error:l().optional(),addonIds:S(l()).readonly(),runnersStopped:S(l()).readonly(),warnings:S(l()).readonly()}),RS=b({success:v(),packageName:l(),results:S(LS).readonly()}),zS=b({packageName:l(),nodeId:l(),nodeName:l(),isHub:v(),isOnline:v(),version:l().nullable(),addonIds:S(l()).readonly(),source:x([`live`,`recorded`]),onHub:v()}),BS=b({installations:S(zS).readonly(),unreachable:S(b({nodeId:l(),error:l()})).readonly()}),Xve=x([`queued`,`updating`,`done`,`done-pending-restart`,`failed`]),Zve=b({name:l(),isSystem:v(),fromVersion:l(),toVersion:l(),status:Xve,error:l().optional(),startedAtMs:n().optional(),completedAtMs:n().optional()}),Qve=x([`regular`,`system`,`restarting`,`finalizing`]);b({id:l(),nodeId:l(),startedAtMs:n(),completedAtMs:n().optional(),total:n(),completed:n(),failed:n(),current:l().nullable(),phase:Qve,cancelled:v(),items:S(Zve).readonly()});var $ve=b({packageName:l(),currentVersion:l(),latestVersion:l().nullable(),hasUpdate:v(),description:l().optional(),buildId:l().nullable()}),VS=b({timestamp:l(),level:l(),message:l(),scope:l().optional()}),eye=C(),HS=b({addonId:l().min(1),action:l().min(1),input:C()}),US={name:`addons`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,methods:{list:k(b({nodeId:l().optional()}).optional(),S(OS).readonly()),getLogs:k(b({addonId:l(),limit:n().min(1).max(500).default(100),level:TS.optional()}),S(eye)),listPackages:k(_(),S(kS).readonly()),installPackage:k(b({packageName:l(),version:l().optional()}),Jve,{kind:`mutation`,auth:`admin`}),uninstallPackage:k(b({packageName:l().min(1),nodeId:l().optional(),everywhere:v().optional()}),RS,{kind:`mutation`,auth:`admin`}),listInstallations:k(b({packageName:l().optional()}),BS,{auth:`admin`}),reloadPackages:k(_(),Yve,{kind:`mutation`,auth:`admin`}),searchAvailable:k(b({query:l().optional(),capability:l().optional()}),S(NS)),listUpdates:k(b({nodeId:l().optional()}),S(AS).readonly(),{auth:`admin`}),updatePackage:k(b({name:l().min(1),version:l().optional(),nodeId:l().optional()}),C(),{kind:`mutation`,auth:`admin`}),rollbackPackage:k(b({name:l().min(1)}),b({rolledBackTo:l().nullable()}),{kind:`mutation`,auth:`admin`}),forceRefresh:k(b({nodeId:l().optional()}),C(),{kind:`mutation`,auth:`admin`}),restartServer:k(b({confirm:p(!0)}),C(),{kind:`mutation`,auth:`admin`}),getLastRestart:k(_(),b({kind:x([`framework-update`,`manual`,`system`,`framework-bulk-update`]),packageName:l().optional(),fromVersion:l().optional(),toVersion:l().optional(),requestedBy:l().optional(),requestedAt:n()}).nullable(),{auth:`admin`}),listFrameworkPackages:k(_(),S($ve).readonly(),{auth:`admin`}),listCapabilityProviders:k(b({capName:l().min(1)}),S(b({addonId:l(),mode:x([`singleton`,`collection`]),isActive:v()})).readonly()),setCapabilityProviderEnabled:k(b({capName:l().min(1),addonId:l().min(1),enabled:v()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getVersions:k(b({name:l()}),S(jS).readonly()),getPackageDocs:k(b({name:l().min(1),version:l().min(1).optional()}),Kve,{auth:`admin`}),restartAddon:k(b({addonId:l()}),qve,{kind:`mutation`,auth:`admin`}),retryLoad:k(b({packageName:l()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getAutoUpdateSettings:k(_(),PS,{auth:`admin`}),setAutoUpdateSettings:k(b({channel:ES,intervalSeconds:n().min(300).max(86400).optional(),updateCheckIntervalSeconds:n().min(900).max(604800).optional()}),C(),{kind:`mutation`,auth:`admin`}),getAddonAutoUpdate:k(b({addonId:l()}),FS,{auth:`admin`}),setAddonAutoUpdate:k(b({addonId:l(),channel:DS}),C(),{kind:`mutation`,auth:`admin`}),applyAutoUpdateToAll:k(b({channel:ES}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),custom:k(HS,C(),{role:`viewer`,kind:`mutation`}),startJob:k(b({kind:x([`install`,`update`,`uninstall`,`restart`]),targets:S(b({name:l().min(1),version:l().min(1)})).min(1),nodeIds:S(l()).optional()}),b({jobId:l()}),{kind:`mutation`,auth:`admin`}),getJob:k(b({jobId:l()}),wS.nullable(),{auth:`admin`}),listJobs:k(b({activeOnly:v().optional()}),S(wS),{auth:`admin`}),cancelJob:k(b({jobId:l()}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`}),onAddonLogs:k(b({addonId:l(),level:TS.optional()}),VS,{kind:`subscription`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:j.ADDON_ADMIN}},WS=b({co2:n().min(0).optional().meta(M(`concentration-volume`)),voc:n().min(0).optional().meta(M(`concentration-ppb`)),pm25:n().min(0).optional().meta(M(`concentration-mass`)),pm10:n().min(0).optional().meta(M(`concentration-mass`)),aqi:n().optional().meta(M(`index`)),lastFetchedAt:n()}),GS={name:`air-quality-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Sensor],methods:{},status:{schema:WS,kind:`push`},runtimeState:WS,durability:`restored`,history:{fields:{co2:{kind:`gauge`,unit:`ppm`,deadband:5},voc:{kind:`gauge`,unit:`ppb`,deadband:5},pm25:{group:`particulates`,kind:`gauge`,unit:`µg/m³`,deadband:1},pm10:{group:`particulates`,kind:`gauge`,unit:`µg/m³`,deadband:1},aqi:{kind:`gauge`,unit:`count`,deadband:1}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:P(`Air quality`,`Qualità dell’aria`),order:5e3,state:[{kind:`numeric`,field:`co2`,quantity:P(`the CO₂`,`la CO₂`),label:P(`CO₂`,`CO₂`),unit:`ppm`,icon:`wind`},{kind:`numeric`,field:`voc`,quantity:P(`the VOC level`,`il livello di COV`),label:P(`VOC`,`COV`),unit:`ppb`,icon:`wind`},{kind:`numeric`,field:`pm25`,quantity:P(`the PM2.5`,`il PM2,5`),label:P(`PM2.5`,`PM2,5`),unit:`µg/m³`,icon:`cloud-fog`},{kind:`numeric`,field:`pm10`,quantity:P(`the PM10`,`il PM10`),label:P(`PM10`,`PM10`),unit:`µg/m³`,icon:`cloud-fog`},{kind:`numeric`,field:`aqi`,quantity:P(`the air quality index`,`l’indice di qualità dell’aria`),label:P(`AQI`,`IQA`),icon:`wind`}]}},KS=x([`disarmed`,`armed_home`,`armed_away`,`armed_night`,`armed_vacation`,`armed_custom_bypass`,`arming`,`disarming`,`pending`,`triggered`]),qS=x([`home`,`away`,`night`,`vacation`,`custom_bypass`]),JS=b({state:KS,targetMode:qS.nullable().optional(),availableModes:S(qS),codeRequired:v().nullable(),lastChangedAt:n()}),YS={name:`alarm-panel`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.AlarmPanel],methods:{trigger:k(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`alarm.trigger`,label:P(`Trigger alarm`,`Fai scattare l’allarme`),phrase:P(`Trigger the alarm on {device}`,`Fai scattare l’allarme su {device}`),icon:`siren`}]}),disarm:k(b({deviceId:n().int().nonnegative(),code:l().min(1).optional()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`alarm.disarm`,label:P(`Disarm`,`Disinserisci`),phrase:P(`Disarm {device}`,`Disinserisci {device}`),icon:`shield-off`,effect:{field:`state`,value:`disarmed`},hold:{effects:[{field:`state`,value:`disarming`,when:{field:`state`,notIn:[`disarmed`]}}]},openArgs:[{key:`code`,label:P(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]}),arm:k(b({deviceId:n().int().nonnegative(),mode:qS,code:l().min(1).optional()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`alarm.arm.home`,label:P(`Arm home`,`Inserisci in casa`),phrase:P(`Arm {device} for home`,`Inserisci {device} in modalità casa`),icon:`house`,effect:{field:`state`,value:`armed_home`},hold:{effects:[{field:`state`,value:`arming`,when:{field:`state`,notIn:[`armed_home`]}}]},args:{mode:`home`},openArgs:[{key:`code`,label:P(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.away`,label:P(`Arm away`,`Inserisci fuori casa`),phrase:P(`Arm {device} for away`,`Inserisci {device} in modalità fuori casa`),icon:`shield-check`,effect:{field:`state`,value:`armed_away`},hold:{effects:[{field:`state`,value:`arming`,when:{field:`state`,notIn:[`armed_away`]}}]},args:{mode:`away`},openArgs:[{key:`code`,label:P(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.night`,label:P(`Arm night`,`Inserisci notte`),phrase:P(`Arm {device} for the night`,`Inserisci {device} in modalità notte`),icon:`moon`,effect:{field:`state`,value:`armed_night`},hold:{effects:[{field:`state`,value:`arming`,when:{field:`state`,notIn:[`armed_night`]}}]},args:{mode:`night`},openArgs:[{key:`code`,label:P(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.vacation`,label:P(`Arm vacation`,`Inserisci vacanza`),phrase:P(`Arm {device} for vacation`,`Inserisci {device} in modalità vacanza`),icon:`plane`,effect:{field:`state`,value:`armed_vacation`},hold:{effects:[{field:`state`,value:`arming`,when:{field:`state`,notIn:[`armed_vacation`]}}]},args:{mode:`vacation`},openArgs:[{key:`code`,label:P(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.custom_bypass`,label:P(`Arm custom bypass`,`Inserisci con esclusioni`),phrase:P(`Arm {device} with its custom bypass`,`Inserisci {device} con le zone escluse`),icon:`shield-half`,effect:{field:`state`,value:`armed_custom_bypass`},hold:{effects:[{field:`state`,value:`arming`,when:{field:`state`,notIn:[`armed_custom_bypass`]}}]},args:{mode:`custom_bypass`},openArgs:[{key:`code`,label:P(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]})},status:{schema:JS,kind:`push`},runtimeState:JS,durability:`restored`,restoredFieldRenames:{requiresCode:`codeRequired`},history:{fields:{state:{kind:`enum`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:P(`Alarm panel`,`Centrale d’allarme`),order:1120,state:[{kind:`enum`,field:`state`,label:P(`Alarm state`,`Stato dell’allarme`),values:[{value:`disarmed`,label:P(`Disarmed`,`Disinserito`),phrase:P(`When {device} is disarmed`,`Quando {device} viene disinserito`)},{value:`armed_home`,label:P(`Armed home`,`Inserito in casa`),phrase:P(`When {device} is armed for home`,`Quando {device} viene inserito in modalità casa`)},{value:`armed_away`,label:P(`Armed away`,`Inserito fuori casa`),phrase:P(`When {device} is armed for away`,`Quando {device} viene inserito in modalità fuori casa`)},{value:`armed_night`,label:P(`Armed night`,`Inserito notte`),phrase:P(`When {device} is armed for the night`,`Quando {device} viene inserito in modalità notte`)},{value:`armed_vacation`,label:P(`Armed vacation`,`Inserito vacanza`)},{value:`armed_custom_bypass`,label:P(`Armed with bypass`,`Inserito con esclusioni`)},{value:`arming`,label:P(`Arming`,`In inserimento`)},{value:`disarming`,label:P(`Disarming`,`In disinserimento`)},{value:`pending`,label:P(`Entry delay`,`Ritardo d’ingresso`)},{value:`triggered`,label:P(`Triggered`,`In allarme`),phrase:P(`When {device} goes off`,`Quando {device} scatta`)}],icon:`shield`}]}},XS=x([`info`,`success`,`warning`,`error`,`critical`]),tye=b({addonId:l().min(1),action:l().min(1),input:m(l(),C()).optional()}),nye=b({label:l(),href:l().optional(),invoke:tye.optional(),navigation:x([`app`,`server`]).optional()}),ZS=x([`active`,`in-progress`,`completed`,`failed`,`dismissed`]),QS=b({type:l(),id:l()}),$S=b({id:l(),category:l(),severity:XS,title:l(),message:l(),action:nye.optional(),status:ZS,progress:n().optional(),read:v(),createdAt:n(),updatedAt:n(),source:QS.optional(),metadata:m(l(),C()).optional()}),eC={name:`alerts`,scope:`system`,mode:`singleton`,methods:{emit:k($S,_(),{kind:`mutation`}),update:k(b({alertId:l(),patch:$S.partial()}),_(),{kind:`mutation`}),list:k(b({unreadOnly:v().optional(),limit:n().optional()}).optional(),S($S).readonly()),getUnreadCount:k(_(),n()),markRead:k(b({alertId:l()}),_(),{kind:`mutation`}),markAllRead:k(_(),_(),{kind:`mutation`}),dismiss:k(b({alertId:l()}),_(),{kind:`mutation`})},vocabulary:{notOperatorFacing:`the alert centre — read and acknowledged on its own page`}},tC=b({illuminance:n().min(0).nullable().meta(M(`illuminance`,{precision:0,label:`Illuminance`})),lastFetchedAt:n()}),nC={name:`ambient-light-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Sensor],methods:{},status:{schema:tC,kind:`push`},runtimeState:tC,durability:`restored`,history:{fields:{illuminance:{kind:`gauge`,unit:`lx`,deadbandPct:10,minIntervalMs:6e4}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:P(`Light level`,`Luminosità ambiente`),order:5010,state:[{kind:`numeric`,field:`illuminance`,quantity:P(`the light level`,`la luminosità`),label:P(`Illuminance`,`Illuminamento`),unit:`lx`,icon:`sun`}]}},rC={name:`audio-analysis`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[T.Camera],exposesDeviceSettings:!0,methods:{resolveDeviceSettings:k(b({deviceId:n()}),ye())},events:{onAudioLevel:ai(b({deviceId:n(),rms:n(),dbfs:n()}),{notOperatorFacing:`a sound-level sample at stream rate; loud-noise rules belong to the detection pipeline`})},vocabulary:{noun:P(`Audio analysis`,`Analisi audio`),order:3010}},rye=x([`jpeg`,`rgb`,`bgr`,`yuv420`,`gray`]),iC=b({data:ye(),format:rye,width:n(),height:n(),timestamp:n()}),aC=b({x:n(),y:n(),w:n(),h:n()}),iye=b({class:l(),originalClass:l(),score:n(),bbox:aC}),oC=b({data:y(Uint8Array),sampleRate:n(),channels:n(),timestamp:n(),deviceId:n().optional()}),sC=b({rms:n(),dbfs:n()}),cC=b({className:l(),originalClass:l().optional(),score:n()}),lC=[`superseded`,`error`,`timeout`,`disposed`],uC=i(`state`,[b({state:p(`classified`)}),b({state:p(`not-classified`),reason:x(lC)})]),dC=b({level:sC,classification:b({labels:S(cC).readonly(),inferenceMs:n()}).optional(),classifyOutcome:uC,timestamp:n()}),fC=b({minConfidence:n().min(0).max(1).default(.3),allowedClasses:S(l()).default([])}),pC=b({deviceId:n(),brokerId:l(),ingestNodeId:l(),settings:fC}),mC=b({attached:v(),replaced:v()}),hC=b({detached:v()}),gC=b({labels:S(cC).readonly(),rawLabels:S(cC).readonly().optional(),inferenceMs:n()}),aye=[{value:`auto`,label:`Auto (platform default)`},{value:`apple-soundanalysis`,label:`Apple SoundAnalysis (macOS 12+)`},{value:`yamnet-onnx`,label:`YAMNet ONNX (cross-platform)`}],oye={audioBackend:`auto`,probedBestAudioBackend:``},_C={name:`audio-analyzer`,scope:`system`,mode:`singleton`,methods:{analyseChunk:k(b({chunk:oC,settings:fC}),dC.nullable(),{kind:`mutation`}),classify:k(oC,gC,{timeoutMs:3e4}),attachDevice:k(pC,mC,{kind:`mutation`}),detachDevice:k(b({deviceId:n()}),hC,{kind:`mutation`}),isReady:k(_(),v()),dispose:k(_(),_(),{kind:`mutation`}),reprobeAudioEngine:k(_(),b({backend:l()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:j.PIPELINE}},vC=x([`f32le`,`s16le`]),yC=b({codec:l(),canDecode:v(),canEncode:v(),label:l().optional()}),bC=b({codec:l(),sourceSampleRate:n().int().positive(),sourceChannels:n().int().positive(),extraData:y(Uint8Array).optional(),targetSampleRate:n().int().positive(),targetChannels:n().int().positive(),targetFormat:vC.optional(),idleMs:n().int().positive().optional(),tag:l().optional()}),xC=b({codec:l(),sourceSampleRate:n().int().positive(),sourceChannels:n().int().positive(),sourceFormat:vC.optional(),targetSampleRate:n().int().positive(),targetChannels:n().int().positive(),bitrateKbps:n().int().positive().optional(),idleMs:n().int().positive().optional(),tag:l().optional()}),SC=b({data:y(Uint8Array),sampleRate:n().int().positive(),channels:n().int().positive(),format:vC,pts:n()}),CC=b({data:y(Uint8Array),codec:l(),pts:n(),frameComplete:v()}),sye=b({sessionId:l(),kind:x([`decode`,`encode`]),codec:l(),sourceSampleRate:n(),sourceChannels:n(),targetSampleRate:n(),targetChannels:n(),format:vC,tag:l().optional(),createdAtMs:n(),lastActivityMs:n(),framesIn:n(),framesOut:n()}),wC={name:`audio-codec`,scope:`system`,mode:`singleton`,preferredProvider:`decoder-nodeav`,methods:{listSupportedCodecs:k(_(),S(yC).readonly()),canHandle:k(b({codec:l(),kind:x([`decode`,`encode`])}),v()),createDecodeSession:k(bC,b({sessionId:l(),nodeId:l()}),{kind:`mutation`}),createEncodeSession:k(xC,b({sessionId:l(),nodeId:l()}),{kind:`mutation`}),closeSession:k(b({sessionId:l(),nodeId:l().optional()}),_(),{kind:`mutation`}),pushEncodedFrame:k(b({sessionId:l(),nodeId:l().optional(),data:y(Uint8Array),pts:n().optional()}),_(),{kind:`mutation`}),pullPcm:k(b({sessionId:l(),nodeId:l().optional(),maxCount:n().int().positive().default(8)}),S(SC)),pushPcm:k(b({sessionId:l(),nodeId:l().optional(),data:y(Uint8Array),pts:n().optional()}),_(),{kind:`mutation`}),pullEncoded:k(b({sessionId:l(),nodeId:l().optional(),maxCount:n().int().positive().default(8)}),S(CC)),flushEncode:k(b({sessionId:l(),nodeId:l().optional()}),S(CC),{kind:`mutation`}),listActiveSessions:k(_(),S(sye).readonly())},vocabulary:{notOperatorFacing:j.INTERNAL}},TC=b({className:l(),hits:n().int().nonnegative(),avgScore:n().min(0).max(1),peakScore:n().min(0).max(1)}),EC=b({ts:n().int(),windowSec:n().int().positive(),level:b({rms:n(),dbfs:n()}),peakDbfs:n(),avgDbfs:n(),current:b({className:l(),score:n().min(0).max(1),timestamp:n().int()}).nullable(),byClass:S(TC).readonly()}),DC=b({ts:n().int(),dbfs:n().nullable(),peakDbfs:n(),avgDbfs:n(),topClass:l().nullable(),topScore:n().min(0).max(1).nullable()}),OC=b({points:S(DC).readonly(),effectiveSampleEveryMs:n().int().positive(),windowMsActual:n().int().nonnegative()}),kC={name:`audio-metrics`,scope:`device`,mode:`singleton`,deviceTypes:[T.Camera],methods:{getCurrentSnapshot:k(b({deviceId:n()}),EC.nullable()),getHistory:k(b({deviceId:n(),windowSec:n().int().positive().optional(),sampleEveryMs:n().int().positive().optional()}),OC)},runtimeState:EC,durability:`session`,history:`none`,vocabulary:{noun:P(`Audio metrics`,`Metriche audio`),order:3020}},AC=b({userId:l(),username:l(),email:l().optional(),displayName:l().optional(),isAdmin:v().default(!1)}),jC={name:`auth-provider`,scope:`system`,mode:`collection`,internal:!0,methods:{validateCredentials:k(b({username:l(),password:l()}),AC.nullable(),{kind:`mutation`}),getLoginUrl:k(b({state:l()}),l()),handleCallback:k(m(l(),l()),AC,{kind:`mutation`}),validateToken:k(b({token:l()}),AC.nullable())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:j.IDENTITY}},MC=b({enabled:v(),isRunning:v(),lastTriggeredAt:n(),lastError:l().nullable(),lastChangedAt:n()}),NC={name:`automation-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Automation],methods:{enable:k(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`haAutomation.enable`,effect:{field:`enabled`,value:!0},label:P(`Enable automation`,`Abilita l’automazione`),phrase:P(`Enable {device}`,`Abilita {device}`),icon:`toggle-right`}]}),disable:k(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`haAutomation.disable`,effect:{field:`enabled`,value:!1},label:P(`Disable automation`,`Disabilita l’automazione`),phrase:P(`Disable {device}`,`Disabilita {device}`),icon:`toggle-left`}]}),trigger:k(b({deviceId:n().int().nonnegative(),skipCondition:v().optional()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`haAutomation.trigger`,label:P(`Trigger automation`,`Avvia l’automazione`),phrase:P(`Run {device} now`,`Esegui subito {device}`),icon:`workflow`}]})},status:{schema:MC,kind:`push`},runtimeState:MC,durability:`session`,history:`none`,vocabulary:{noun:P(`Automation`,`Automazione`),order:2100,state:[{kind:`boolean`,field:`enabled`,label:P(`Enabled`,`Abilitata`),whenTrue:P(`When {device} is enabled`,`Quando {device} viene abilitata`),whenFalse:P(`When {device} is disabled`,`Quando {device} viene disabilitata`),icon:`toggle-right`},{kind:`boolean`,field:`isRunning`,label:P(`Running`,`In esecuzione`),whenTrue:P(`When {device} starts running`,`Quando {device} parte`),whenFalse:P(`When {device} finishes`,`Quando {device} termina`),icon:`workflow`}]}},cye=`.backup-snapshot`,lye=`.backup-snapshot-partial`,PC=30*6e4,FC=b({databases:S(b({databaseId:vf,livePath:l()}))}),IC=b({name:l(),rows:n().int().nonnegative()}),LC=b({livePath:l(),snapshotPath:l(),sizeBytes:n().int().nonnegative(),pageCount:n().int().nonnegative(),pageSize:n().int().positive(),tables:S(IC),copyMs:n().nonnegative(),verifyMs:n().nonnegative(),takenAt:n()}),RC=LC.extend({databaseId:vf}),zC=b({databaseId:vf}),BC=LC.extend({livePath:l(),snapshotPath:l(),databaseId:vf.optional()}),VC={name:`database-snapshot`,scope:`system`,mode:`singleton`,internal:!0,methods:{listDatabases:k(b({}),FC,{auth:`admin`}),writeSnapshot:k(zC,RC,{kind:`mutation`,auth:`admin`,timeoutMs:PC})},vocabulary:{notOperatorFacing:j.INTERNAL}},HC=b({subId:l(),displayName:l(),description:l().optional(),kind:l(),triggerSupported:v(),restoreSupported:v()}).extend({id:l(),addonId:l(),enabled:v(),retentionCount:n(),label:l().optional(),lastSuccessAt:n().optional(),lastSuccessSizeBytes:n().optional(),cron:l().optional(),nextRunAt:n().optional(),lastAttemptAt:n().optional(),lastError:l().optional()}),UC=b({scheme:l(),keyId:l()}),WC=b({enabled:v(),active:b({keyId:l(),publicKey:l(),createdAt:n()}).nullable(),keys:S(b({keyId:l(),createdAt:n(),retiredAt:n().nullable()})).readonly()}),uye=b({id:l(),filename:l(),createdAt:n(),sizeBytes:n(),label:l().optional(),locations:S(l()).readonly(),encryption:UC.optional(),databases:S(vf).readonly().optional()}),GC=b({id:l(),destinationId:l().optional(),label:l().optional(),createdAt:n(),sizeBytes:n(),locations:S(l()).optional(),encryption:UC.optional()}),KC=b({path:l(),kind:x([`file`,`dir`,`symlink`]),sizeBytes:n(),mtime:n()}),qC=b({archiveVersion:p(1),createdAt:n(),dataDir:l(),locations:S(l()),entries:S(KC),totalBytes:n(),totalFiles:n(),sqliteSnapshots:S(BC).optional(),omittedDatabases:S(vf).optional()}),JC=b({name:l(),sizeBytes:n(),fileCount:n(),present:v()}),YC=x([`queued`,`running`,`succeeded`,`failed`,`cancelled`]),XC=x([`queued`,`building`,`uploading`,`done`]),ZC=b({id:l(),state:YC,phase:XC,destinationIds:S(l()).readonly(),label:l().optional(),requestedAt:n(),startedAt:n().optional(),finishedAt:n().optional(),stagedBytes:n(),archiveSizeBytes:n().optional(),uploadedBytes:n(),completedDestinationIds:S(l()).readonly(),failedDestinationIds:S(l()).readonly(),error:l().optional(),queuePosition:n().int().min(1).optional()}),QC=b({runId:l(),queued:v(),joined:v(),cancelled:v(),entries:S(GC).readonly()}),$C=b({id:l(),label:l(),cron:l(),enabled:v(),locationIds:S(l()).readonly(),retentionCount:n().int().min(1).max(1e3),dataSources:S(l()).readonly().optional(),databases:S(vf).readonly().optional(),lastAttemptAt:n().optional(),lastSuccessAt:n().optional(),lastError:l().optional(),nextRunAt:n().optional()}),ew={name:`backup`,scope:`system`,mode:`singleton`,methods:{listDestinations:k(_(),S(HC).readonly(),{auth:`admin`}),trigger:k(b({destinations:S(l()).optional(),locations:S(l()).optional(),label:l().optional(),retentionCount:n().int().min(1).max(1e3).optional(),databases:S(vf).optional()}).optional(),QC,{kind:`mutation`,auth:`admin`}),listRuns:k(_(),S(ZC).readonly(),{auth:`admin`}),cancel:k(b({runId:l()}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`}),list:k(_(),S(GC).readonly(),{auth:`admin`}),listLocations:k(_(),S(JC).readonly(),{auth:`admin`}),getEntries:k(b({destinationId:l(),backupId:l()}),qC.nullable(),{auth:`admin`}),restore:k(b({destinationId:l(),backupId:l(),locations:S(l()).optional(),backupSecretKey:l().optional()}),_(),{kind:`mutation`,auth:`admin`}),getEncryption:k(_(),WC,{auth:`admin`}),setupEncryption:k(b({}),b({keyId:l(),secretKey:l(),publicKey:l(),createdAt:n(),replacedKeyId:l().nullable()}),{kind:`mutation`,auth:`admin`}),disableEncryption:k(b({}),b({disabledKeyId:l().nullable()}),{kind:`mutation`,auth:`admin`}),checkBackupKey:k(b({backupSecretKey:l()}),b({valid:v(),keyId:l().nullable(),known:v(),active:v(),error:l().optional()}),{kind:`mutation`,auth:`admin`}),delete:k(b({destinationId:l(),backupId:l()}),_(),{kind:`mutation`,auth:`admin`}),listArchives:k(b({destinationId:l()}),S(uye).readonly(),{auth:`admin`}),upsertDestinationPolicy:k(b({locationId:l(),enabled:v(),retentionCount:n().int().min(1).max(1e3),label:l().optional()}),_(),{kind:`mutation`,auth:`admin`}),previewSchedule:k(b({cron:l(),count:n().int().min(1).max(20).optional()}),b({ok:v(),error:l().optional(),nextRuns:S(n()).readonly()})),listSchedules:k(_(),S($C).readonly(),{auth:`admin`}),listAvailableDatabases:k(_(),b({answered:v(),databases:S(vf).readonly()}),{auth:`admin`}),upsertSchedule:k(b({id:l().optional(),label:l(),cron:l(),enabled:v(),locationIds:S(l()).readonly(),retentionCount:n().int().min(1).max(1e3),dataSources:S(l()).readonly().optional(),databases:S(vf).readonly().optional()}),$C,{kind:`mutation`,auth:`admin`}),deleteSchedule:k(b({id:l()}),_(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`system backups — run and restored from the Backups page`}},tw=b({level:n().min(0).max(100).nullable().meta(M(`percentage`,{label:`Charge`})),charging:x([`dc`,`solar`,`none`,`unknown`]).meta({label:`Charging source`}),sleeping:v().meta({label:`Sleeping`}),lastUpdated:n().meta(M(`none`)),voltage:n().nullable().optional().meta(M(`voltage`,{label:`Voltage`})),lastContactAt:n().optional(),lastFullRefreshAt:n().optional(),binary:v().optional().meta({label:`Binary indicator`})}),nw=[T.Camera,T.Sensor,T.Button,T.Switch,T.PetFeeder,T.Container,T.Climate,T.EventEmitter],dye={version:1,targets:[{id:`level`,cardinality:`scalar`,vocabulary:{cap:`battery`,stateField:`level`},deviceTypes:nw,apply:`add`,path:`level`,sources:[{kind:`field`,valueKinds:[`number`,`string`],transforms:[{kind:`identity`},{kind:`linear`,defaultScale:1,defaultOffset:0,clampMin:0,clampMax:100}]}],companions:[{kind:`constant`,path:`charging`,value:`unknown`,when:`add`},{kind:`constant`,path:`sleeping`,value:!1,when:`add`},{kind:`clock`,path:`lastUpdated`,when:`add`}],sourceReport:{status:`assignment-status`},advancedExpression:!0}]},rw={name:`battery`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:nw,methods:{},events:{onStatusChanged:{data:b({deviceId:n(),status:tw}),notOperatorFacing:`the level / sleeping / charging state triggers each read one field of this change`}},status:{schema:tw,kind:`push`,empty:{level:null,charging:`unknown`,sleeping:!1,lastUpdated:0}},runtimeState:tw,durability:`restored`,history:{fields:{level:{kind:`gauge`,unit:`%`},voltage:{kind:`gauge`,unit:`V`}}},customize:dye,volatileStateFields:[`lastUpdated`],vocabulary:{noun:P(`Battery`,`Batteria`),order:5240,state:[{kind:`numeric`,field:`level`,quantity:P(`the battery level`,`il livello della batteria`),label:P(`Battery`,`Batteria`),unit:`%`,icon:`battery`},{kind:`boolean`,field:`sleeping`,label:P(`Asleep`,`In sospensione`),whenTrue:P(`When {device} goes to sleep`,`Quando {device} va in sospensione`),whenFalse:P(`When {device} wakes up`,`Quando {device} si risveglia`),icon:`moon`},{kind:`enum`,field:`charging`,label:P(`Charging`,`Ricarica`),values:[{value:`dc`,label:P(`Charging from mains`,`In carica da rete`),phrase:P(`When {device} starts charging`,`Quando {device} inizia a caricarsi`)},{value:`solar`,label:P(`Charging from solar`,`In carica dal pannello solare`),phrase:P(`When {device} charges from its solar panel`,`Quando {device} si carica dal pannello solare`)},{value:`none`,label:P(`Not charging`,`Non in carica`),phrase:P(`When {device} stops charging`,`Quando {device} smette di caricarsi`)},{value:`unknown`,label:P(`Unknown`,`Sconosciuto`)}],icon:`battery-charging`}],extraEvents:[{category:w.DeviceAwake,label:P(`Woke up`,`Risvegliato`),phrase:P(`When {device} wakes up`,`Quando {device} si risveglia`),icon:`sun`},{category:w.DeviceSleeping,label:P(`Went to sleep`,`In sospensione`),phrase:P(`When {device} goes to sleep`,`Quando {device} va in sospensione`),icon:`moon`}]}},iw=b({on:v().meta({label:`On`}),lastChangedAt:n()}),aw={name:`binary`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Sensor],methods:{},status:{schema:iw,kind:`push`},runtimeState:iw,durability:`restored`,history:{fields:{on:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:P(`Binary sensor`,`Sensore binario`),order:5020,state:[{kind:`boolean`,field:`on`,label:P(`On`,`Acceso`),whenTrue:P(`When {device} turns active`,`Quando {device} si attiva`),whenFalse:P(`When {device} turns inactive`,`Quando {device} si disattiva`),icon:`toggle-right`}],overrides:{byRole:{[D.MotionSensor]:{state:{on:{label:P(`Motion`,`Movimento`),whenTrue:P(`When {device} detects motion`,`Quando {device} rileva movimento`),whenFalse:P(`When motion clears on {device}`,`Quando il movimento su {device} cessa`),icon:`activity`}}},[D.ContactSensor]:{state:{on:{label:P(`Open`,`Aperto`),whenTrue:P(`When {device} opens`,`Quando {device} si apre`),whenFalse:P(`When {device} closes`,`Quando {device} si chiude`),icon:`door-open`}}},[D.LeakSensor]:{state:{on:{label:P(`Leak`,`Perdita`),whenTrue:P(`When {device} detects a leak`,`Quando {device} rileva una perdita`),whenFalse:P(`When {device} is dry again`,`Quando {device} torna asciutto`),icon:`droplets`}}},[D.SmokeSensor]:{state:{on:{label:P(`Smoke`,`Fumo`),whenTrue:P(`When {device} detects smoke`,`Quando {device} rileva fumo`),whenFalse:P(`When smoke clears on {device}`,`Quando il fumo su {device} si dirada`),icon:`alarm-smoke`}}},[D.COSensor]:{state:{on:{label:P(`Carbon monoxide`,`Monossido di carbonio`),whenTrue:P(`When {device} detects carbon monoxide`,`Quando {device} rileva monossido di carbonio`),whenFalse:P(`When the carbon monoxide clears on {device}`,`Quando il monossido su {device} rientra`),icon:`cloud-alert`}}},[D.GasSensor]:{state:{on:{label:P(`Gas`,`Gas`),whenTrue:P(`When {device} detects gas`,`Quando {device} rileva gas`),whenFalse:P(`When the gas clears on {device}`,`Quando il gas su {device} rientra`),icon:`flame`}}},[D.TamperSensor]:{state:{on:{label:P(`Tampered`,`Manomesso`),whenTrue:P(`When {device} is tampered with`,`Quando {device} viene manomesso`),whenFalse:P(`When the tamper alert on {device} clears`,`Quando l’allarme di manomissione di {device} rientra`),icon:`shield-alert`}}},[D.VibrationSensor]:{state:{on:{label:P(`Vibration`,`Vibrazione`),whenTrue:P(`When {device} vibrates`,`Quando {device} vibra`),whenFalse:P(`When {device} is still again`,`Quando {device} torna fermo`),icon:`vibrate`}}},[D.ConnectivitySensor]:{state:{on:{label:P(`Connected`,`Connesso`),whenTrue:P(`When {device} connects`,`Quando {device} si connette`),whenFalse:P(`When {device} disconnects`,`Quando {device} si disconnette`),icon:`wifi`}}},[D.SoundSensor]:{state:{on:{label:P(`Sound`,`Suono`),whenTrue:P(`When {device} hears a sound`,`Quando {device} sente un suono`),whenFalse:P(`When {device} is quiet again`,`Quando {device} torna silenzioso`),icon:`ear`}}},[D.BatterySensor]:{state:{on:{label:P(`Battery low`,`Batteria scarica`),whenTrue:P(`When the battery of {device} runs low`,`Quando la batteria di {device} si scarica`),whenFalse:P(`When the battery of {device} is fine again`,`Quando la batteria di {device} torna a posto`),icon:`battery-low`}}},[D.BinaryHelper]:{state:{on:{label:P(`On`,`Acceso`),whenTrue:P(`When {device} turns on`,`Quando {device} si accende`),whenFalse:P(`When {device} turns off`,`Quando {device} si spegne`),icon:`toggle-right`}}}}}}},ow=x([`unknown-source`,`not-admin`,`no-builder`,`no-ingress-url`,`unreachable`,`unknown-board`,`no-encryption-key`,`unreadable-config`]),fye=b({sourceId:l(),name:l()}),pye=b({configuration:l(),name:l(),address:l().nullable()}),sw=b({ok:p(!1),reason:ow,detail:l().optional()}),mye=i(`ok`,[b({ok:p(!0),boards:S(pye).readonly()}),sw]),hye=i(`ok`,[b({ok:p(!0),key:l()}),sw]),cw={name:`board-key-source`,scope:`system`,mode:`collection`,methods:{listSources:k(_(),S(fye).readonly(),{auth:`admin`}),listBoards:k(b({sourceId:l().min(1)}),mye,{auth:`admin`}),getBoardKey:k(b({sourceId:l().min(1),configuration:l().min(1)}),hye,{auth:`admin`})},vocabulary:{notOperatorFacing:j.INTERNAL}},lw=b({level:n().min(0).max(100).meta(M(`percentage`)),lastChangedAt:n()}),uw={name:`brightness`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Light],methods:{setBrightness:k(b({deviceId:n().int().nonnegative(),level:n().min(0).max(100)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`brightness.full`,label:P(`Full brightness`,`Luminosità massima`),phrase:P(`Set {device} to full brightness`,`Porta {device} alla massima luminosità`),icon:`sun`,effect:{field:`level`,value:100},args:{level:100}},{id:`brightness.half`,label:P(`Half brightness`,`Luminosità a metà`),phrase:P(`Dim {device} to half`,`Abbassa {device} a metà luminosità`),icon:`sun-dim`,effect:{field:`level`,value:50},args:{level:50}},{id:`brightness.off`,label:P(`Brightness off`,`Luminosità a zero`),phrase:P(`Dim {device} to zero`,`Abbassa {device} a zero`),icon:`lightbulb-off`,effect:{field:`level`,value:0},args:{level:0}},{id:`brightness.set`,label:P(`Set brightness`,`Imposta la luminosità`),phrase:P(`Set the brightness of {device} to {level}`,`Imposta la luminosità di {device} a {level}`),icon:`sun-medium`,effect:{field:`level`,fromArg:`level`},openArgs:[{key:`level`,label:P(`Percentage`,`Percentuale`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]})},events:{onBrightnessChanged:{data:b({deviceId:n(),level:n().min(0).max(100),lastChangedAt:n()}),notOperatorFacing:"the `level` state trigger reads the same change"}},status:{schema:lw,kind:`command-driven`},runtimeState:lw,durability:`session`,history:{fields:{level:{kind:`gauge`,unit:`%`,minIntervalMs:0}}},vocabulary:{noun:P(`Brightness`,`Luminosità`),order:1010,state:[{kind:`numeric`,field:`level`,quantity:P(`the brightness`,`la luminosità`),label:P(`Brightness`,`Luminosità`),unit:`%`,icon:`sun`}]}},gye=x([`connected`,`disconnected`,`connecting`,`auth-failed`,`unreachable`,`error`]),dw=b({brokerCount:n().int().nonnegative(),connectedCount:n().int().nonnegative()}),_ye=b({id:l()}),vye=m(l(),C()),fw=b({brokerId:l(),target:m(l(),C()),payload:C().optional()}),pw=b({brokerId:l(),filter:m(l(),C())}),mw=b({subscriptionId:l()}),hw=b({brokerId:l(),subscriptionId:l()}),gw=b({brokerId:l(),key:l()}),_w={name:`broker`,scope:`system`,mode:`collection`,providerKind:`broker`,status:{schema:dw,kind:`poll`},methods:{getBrokerConfig:k(_ye,vye.nullable(),{auth:`admin`}),publish:k(fw,C(),{kind:`mutation`,auth:`admin`}),subscribe:k(pw,mw,{kind:`mutation`,auth:`admin`}),unsubscribe:k(hw,_(),{kind:`mutation`,auth:`admin`}),getState:k(gw,C().nullable(),{auth:`admin`}),getStatus:k(_(),dw)},vocabulary:{notOperatorFacing:`message-broker connections — configured, not actuated`}},vw={name:`button`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Button],methods:{press:k(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`button.press`,label:P(`Press`,`Premi`),phrase:P(`Press {device}`,`Premi {device}`),icon:`circle-dot`}]})},vocabulary:{noun:P(`Button`,`Pulsante`),order:1130}},yw=x([`ha`,`addon`]),bw=b({id:l().min(1),name:l().min(1),source:yw,enabled:v(),instanceId:l().min(1).optional()}),xw=b({id:l().min(1),calendarId:l().min(1),title:l(),startMs:n().int(),endMs:n().int(),allDay:v().optional(),description:l().optional(),location:l().optional()}),Sw=b({calendarIds:S(l().min(1)).max(64).optional(),startMs:n().int(),endMs:n().int()}),Cw={name:`calendar-source`,scope:`system`,mode:`collection`,internal:!0,providerKind:`calendar`,methods:{listCalendars:k(_(),S(bw).readonly(),{auth:`admin`}),listEvents:k(Sw,S(xw).readonly(),{auth:`admin`})},vocabulary:{notOperatorFacing:j.INTERNAL}};function ww(e){let t=new Date(e);return new Date(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()).getTime()}function Tw(e){if(e.allDay!==!0)return{startMs:e.startMs,endMs:e.endMs};let t=ww(e.startMs),n=ww(e.endMs);if(n>t)return{startMs:t,endMs:n};let r=new Date(t);return{startMs:t,endMs:new Date(r.getFullYear(),r.getMonth(),r.getDate()+1).getTime()}}function yye(e,t){let n=new Date(t),r=new Date(n.getFullYear(),n.getMonth(),n.getDate()+1).getTime(),i=Tw(e);return i.startMs<r&&i.endMs>t}var Ew=l().regex(/^#[0-9A-Fa-f]{6}$/,`expected #RRGGBB`),Dw=bw.extend({id:l().min(1),providerAddonId:l().min(1).optional(),defaultColor:Ew,color:Ew,visible:v()}),Ow=b({visible:v().optional(),color:Ew.optional()}),kw=b({calendars:m(l(),Ow)}),Aw=b({calendarId:l().min(1),visible:v().optional(),color:Ew.nullable().optional()}),jw={name:`calendars`,scope:`system`,mode:`singleton`,methods:{listCalendars:k(_(),S(Dw).readonly(),{auth:`admin`}),listEvents:k(Sw,S(xw).readonly(),{auth:`admin`}),getPreferences:k(b({}),kw,{auth:`admin`,caller:`required`}),setCalendarPreference:k(Aw,kw,{auth:`admin`,kind:`mutation`,caller:`required`})},vocabulary:{notOperatorFacing:`calendars feed schedules and conditions, not device actions`}},Mw=b({host:l(),port:n().int().positive().optional(),onvifPort:n().int().positive().optional(),rtspPort:n().int().positive().optional(),https:v().optional(),username:l().optional(),password:l().optional(),onvifProfile:l().optional()}),Nw=b({host:l(),port:n().int().positive().nullable(),onvifPort:n().int().positive().nullable(),rtspPort:n().int().positive().nullable(),https:v().nullable(),hasUsername:v(),hasPassword:v(),onvifProfile:l().nullable()}),Pw={name:`camera-credentials`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Camera],methods:{getCredentials:k(b({deviceId:n()}),Mw.nullable(),{kind:`query`,auth:`admin`})},status:{schema:Nw,kind:`command-driven`},vocabulary:{noun:P(`Camera credentials`,`Credenziali della telecamera`),order:3030}},Fw=b({x:n().min(0).max(1),y:n().min(0).max(1),width:n().gt(0).max(1),height:n().gt(0).max(1)}),Iw=b({deviceId:n().int().positive(),source:Fw,cell:Fw}),bye=b({profile:x([`high`,`mid`,`low`]),offered:v(),missingSources:S(n().int().positive()),canvas:l(),published:v()}),Lw=b({blockId:l(),deviceId:n().int().nonnegative(),name:l(),fps:n().int(),cells:S(Iw),profiles:S(bye)}),Rw=b({deviceId:n().int().nonnegative(),fps:n().int().min(1).max(60).optional(),publishedProfiles:S(x([`high`,`mid`,`low`])).max(3).optional(),cells:S(Iw).max(16)}),zw={name:`camera-grid-layout`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Camera],exposesDeviceSettings:!0,methods:{getLayout:k(b({deviceId:n().int().nonnegative()}),Lw.nullable(),{auth:`admin`}),saveLayout:k(Rw,Lw,{kind:`mutation`,auth:`admin`})},vocabulary:{noun:P(`Grid layout`,`Layout a griglia`),order:3040}},Bw={name:`camera-pipeline-config`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[T.Camera],exposesDeviceSettings:!0,methods:{},vocabulary:{noun:P(`Detection settings`,`Impostazioni di rilevamento`),order:3050}},Vw=x([`webrtc`,`hls`,`mjpeg`,`rtsp`]),Hw=x([`mp4`,`gif`]),Uw=b({kind:Hw,handle:l(),nodeId:l(),mime:l(),bytes:n().int(),width:n().int(),height:n().int()}),Ww=b({fromTs:n(),toTs:n(),packets:n().int()}),Gw=b({media:S(Uw).readonly(),coverage:Ww,profile:N,video:x([`copy`,`encode`])}),Kw=b({brokerId:l(),url:l(),mutedUrl:l(),enabled:v(),codec:l().optional(),resolution:b({width:n().int().positive(),height:n().int().positive()}).optional()}),qw=b({sessionId:l(),remoteAddr:l(),userAgent:l().nullish(),playing:v(),muted:v(),connectedAt:n(),lastRtpAt:n(),bytesSent:n()}),Jw=b({tag:l(),subscribedAt:n(),chunksDelivered:n()}),Yw=x([`alexa`,`homekit`,`webrtc-browser`,`webrtc-mobile`,`webrtc-whep`,`rtsp-listen`,`derived-broker`,`recording`,`pipeline`,`snapshot`,`warmup`,`unknown`]),Xw=b({kind:Yw,label:l().optional(),media:x([`audio`,`video`,`both`]).optional(),targetCodec:l().optional(),transport:x([`passthrough`,`repacketize`,`transcode`]).optional(),remoteAddr:l().optional(),userAgent:l().optional(),userId:l().optional(),sessionId:l().optional(),extra:m(l(),l()).optional()}).readonly(),Zw=b({id:l(),channel:x([`annexb`,`rtp`]),attribution:Xw,subscribedAt:n(),packetsDelivered:n()}),Qw=b({rtsp:S(qw).readonly(),audio:S(Jw).readonly(),encoded:S(Zw).readonly(),pipeClients:n(),encodedSubscribers:n()}),$w=b({deviceId:n().int().nonnegative(),viewers:n().int().positive()}),xye=x([`reconnecting`,`sleeping`,`offline`,`disabled`,`waking`]),Sye=x([`h264`,`h265`,`copy`]),Cye=x([`aac`,`opus`,`pcmu`,`copy`,`none`]),eT=b({deviceId:n().int().nonnegative(),video:Sye,audio:Cye.optional(),profile:N.optional(),targetResolution:b({width:n().int().positive(),height:n().int().positive()}).optional(),outputArgs:S(l()).optional(),audioEgress:v().optional(),hostname:l().optional(),tag:l().optional()}),tT=b({url:l(),sentryUrl:l().nullable().optional(),videoCodec:x([`H264`,`H265`]),audioCodec:l(),resolution:b({width:n().int().positive(),height:n().int().positive()}),transcoded:v(),encoder:l(),pipelineKey:l()}),nT=Md.omit({inputArgs:!0,outputArgs:!0}),rT=x([`tight`,`relaxed`]),iT=b({deviceId:n().int().nonnegative(),source:i(`kind`,[b({kind:p(`profile`),profile:N}),b({kind:p(`cam-stream`),camStreamId:l().min(1)})]),encode:nT,rateControl:rT.optional(),bitstreamFilter:x([`dump_extra`,`h264_mp4toannexb`,`hevc_mp4toannexb`]).optional(),publishLocally:v().optional(),pixelFormat:x([`yuv420p`,`nv12`]).optional(),decodeHwAccel:x([`auto`,`none`,`videotoolbox`,`vaapi`,`qsv`,`cuda`]).optional(),hostname:l().optional(),tag:l().optional()}),aT=b({url:l(),pipelineKey:l(),videoCodec:x([`H264`,`H265`]),resolution:b({width:n().int().positive(),height:n().int().positive()}),transcoded:v(),encoder:l(),decodeHwAccel:l().nullable(),camStreamId:l().nullable()}),oT={name:`stream-broker`,scope:`system`,mode:`singleton`,exposesDeviceSettings:!0,methods:{reportStreamSignal:k(b({deviceId:n().int().nonnegative(),code:l().min(1),at:n().optional()}),b({accepted:v(),reason:x([`woke`,`hold-extended`,`not-enabled`,`no-consumer`,`unknown-code`])}),{kind:`mutation`}),publishCameraStream:k(b({deviceId:n().int().nonnegative(),camStreamId:l().min(1),kind:va,url:l().optional(),codec:l().optional(),resolution:ya.optional(),fps:n().positive().optional(),label:l().optional(),deviceFeatures:S(l()).optional(),autoEligible:v().optional(),profileHint:N.optional(),metadata:m(l(),C()).optional(),sourceCamStreamId:l().min(1).optional(),encodeProfile:Md.optional()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),retractCameraStream:k(b({deviceId:n().int().nonnegative(),camStreamId:l().min(1)}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),assignProfile:k(b({deviceId:n().int().nonnegative(),profile:N,camStreamId:l().min(1)}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),unassignProfile:k(b({deviceId:n().int().nonnegative(),profile:N}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),forgetDeviceHardware:k(b({deviceId:n().int().nonnegative()}),b({derivedStreamsDeleted:S(l()).readonly(),assignmentsPurged:v(),probeSnapshotsDropped:n().int().nonnegative(),rtspTokenRowsDeleted:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),renderPreBufferClip:k(b({deviceId:n(),profile:N.optional(),aroundMs:n(),preRollSec:n().min(0).max(20).default(3),postRollSec:n().min(0).max(20).default(5),format:x([`gif`,`mp4`]).default(`gif`),maxWidth:n().int().min(120).max(1920).default(480),fps:n().int().min(1).max(15).default(5),speed:n().min(1).max(8).default(2)}),b({base64:l(),mime:l(),bytes:n().int(),profile:N,durationMs:n()}),{kind:`mutation`,auth:`admin`}),produceEventMedia:k(b({deviceId:n(),profile:N.optional(),aroundMs:n(),preSeconds:n().min(0).max(20).default(4),postSeconds:n().min(0).max(20).default(6),kinds:S(Hw).min(1).default([`mp4`]),gifMaxWidth:n().int().min(120).max(1280).default(640),gifFps:n().int().min(1).max(15).default(12),gifSpeed:n().min(1).max(8).default(4),speed:n().min(1).max(8).default(4)}),Gw,{kind:`mutation`,auth:`admin`}),fetchEventMedia:k(b({handle:l()}),b({base64:l(),mime:l(),bytes:n().int()}).nullable(),{kind:`mutation`,auth:`admin`}),listAllCameraStreams:k(_(),S(ba).readonly()),listAllProfileSlots:k(_(),S(Sa).readonly()),getBrokerStats:k(b({brokerId:l()}),Ene),previewDerivedEncode:k(b({deviceId:n().int().nonnegative(),profile:Md,source:Sne.optional()}),Tne),probeStream:k(b({brokerId:l()}),b({probed:v(),summary:l()}),{kind:`mutation`,auth:`admin`}),listClients:k(b({brokerId:l()}),Qw),getLiveViewerCounts:k(_(),S($w).readonly(),{role:`viewer`}),killClient:k(b({brokerId:l(),channel:x([`rtsp`,`audio`]),handle:l()}),b({killed:v()}),{kind:`mutation`,auth:`admin`}),restartProfile:k(b({deviceId:n().int().nonnegative(),profile:N}),b({success:v()}),{kind:`mutation`,auth:`admin`}),getStreamUrl:k(b({streamId:l(),format:Vw}),b({url:l()})),getStreamWithCodec:k(eT,tT,{kind:`mutation`,auth:`admin`}),releaseStreamWithCodec:k(b({pipelineKey:l()}),b({released:v(),refcount:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),acquireEgressTranscode:k(iT,aT,{kind:`mutation`,auth:`admin`}),releaseEgressTranscode:k(b({pipelineKey:l()}),b({released:v(),refcount:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),subscribeAudioChunks:k(yne,bne,{kind:`mutation`}),pullAudioChunks:k(b({subscriptionId:l(),maxCount:n().int().positive().default(8)}),S(vne).readonly()),unsubscribeAudioChunks:k(b({subscriptionId:l()}),b({released:v()}),{kind:`mutation`}),setPreBufferDuration:k(b({brokerId:l(),seconds:n().min(0).max(30)}),_(),{kind:`mutation`,auth:`admin`}),getPreBufferInfo:k(b({brokerId:l()}),b({configuredSec:n(),bufferedMs:n(),packetCount:n()})),getRtspPort:k(_(),n()),getAllRtspEntries:k(b({hostname:l().optional()}),S(Kw).readonly()),getRtspEntry:k(b({brokerId:l(),hostname:l().optional()}),Kw.nullable()),regenerateRtspToken:k(b({brokerId:l()}),l().nullable(),{kind:`mutation`,auth:`admin`}),setRtspEnabled:k(b({brokerId:l(),enabled:v()}),_(),{kind:`mutation`,auth:`admin`}),isRtspEnabled:k(b({brokerId:l()}),v()),getDeviceAudioMute:k(b({deviceId:n().int()}),b({muted:v(),appliedBrokers:n().int().nonnegative()})),setDeviceAudioMute:k(b({deviceId:n().int(),muted:v()}),b({muted:v(),appliedBrokers:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`})},events:{onCamStreamDemand:ai(b({deviceId:n().int().nonnegative(),camStreamId:l(),profile:N})),onCamStreamIdle:ai(b({deviceId:n().int().nonnegative(),camStreamId:l()})),onRequestStreamSourceRefresh:ai(b({deviceId:n().int().nonnegative(),camStreamId:l(),brokerId:l()}))},vocabulary:{notOperatorFacing:j.PIPELINE}},sT=x([`h264`,`h265`,`hevc`,`av1`,`mjpeg`,`vp8`,`vp9`]),cT=b({acceptCodecs:S(sT).readonly().optional(),minHeight:n().int().positive().optional(),maxHeight:n().int().positive().optional(),minWidth:n().int().positive().optional(),excludeDerived:v().optional(),requireSiblingCodec:S(sT).readonly().optional(),allowTranscode:v().optional(),requireProfileBound:v().optional()}).readonly(),lT=b({preferredProviders:S(l()).readonly().optional(),resolutionPreference:x([`highest`,`lowest`]).optional(),targetHeight:n().int().positive().optional()}).readonly(),uT=b({camStreamId:l(),codec:l().optional(),resolution:ya.optional(),transcodes:v(),reason:l(),profile:N.optional(),brokerId:l().optional(),url:l().optional(),fps:n().positive().optional(),fpsSource:x([`published`,`measured`]).optional()}),dT={name:`camera-streams`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[T.Camera],methods:{getCameraStreams:k(b({deviceId:n().int().nonnegative()}),S(ba).readonly()),getBrokerStreams:k(b({deviceId:n().int().nonnegative()}),S(Sa).readonly()),getRtspEntries:k(b({deviceId:n().int().nonnegative(),hostname:l().optional()}),S(Kw).readonly()),getProfileRtspEntries:k(b({deviceId:n().int().nonnegative(),hostname:l().optional()}),S(Dne).readonly()),pickStream:k(b({deviceId:n().int().nonnegative(),requirements:cT,preferences:lT.optional()}),uT.nullable())},events:{onCamStreamsChanged:ai(b({deviceId:n().int().nonnegative(),camStreams:S(ba).readonly()}),{notOperatorFacing:`the stream catalog was rebuilt — plumbing, not a happening`}),onProfileSlotsChanged:ai(b({deviceId:n().int().nonnegative(),profileSlots:S(Sa).readonly()}),{notOperatorFacing:`stream profiles were reassigned — plumbing, not a happening`})},runtimeState:b({online:v(),slotStatuses:b({high:xa.optional(),mid:xa.optional(),low:xa.optional()}),slotErrors:b({high:l().optional(),mid:l().optional(),low:l().optional()}),lastChangedAt:n()}),durability:`session`,history:`none`,vocabulary:{noun:P(`Camera streams`,`Flussi della telecamera`),order:3060}},fT=b({detected:v(),lastChangedAt:n()}),pT={name:`carbon-monoxide`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Sensor],methods:{},status:{schema:fT,kind:`push`},runtimeState:fT,durability:`restored`,history:{fields:{detected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:P(`Carbon monoxide`,`Monossido di carbonio`),order:5030,state:[{kind:`boolean`,field:`detected`,label:P(`Detected`,`Rilevato`),whenTrue:P(`When {device} detects carbon monoxide`,`Quando {device} rileva monossido di carbonio`),whenFalse:P(`When the carbon monoxide clears on {device}`,`Quando il monossido su {device} rientra`),icon:`cloud-alert`}]}},mT=x([`off`,`heat`,`cool`,`auto`,`heat_cool`,`fan_only`,`dry`]),hT=x([`heating`,`cooling`,`drying`,`fan`,`idle`,`off`]),gT=b({mode:mT,action:hT.nullable().optional(),availableModes:S(mT),fanMode:l(),availableFanModes:S(l()),preset:l(),availablePresets:S(l()),target:n().nullable().meta(M(`temperature`)),targetHigh:n().nullable().meta(M(`temperature`)),targetLow:n().nullable().meta(M(`temperature`)),targetHumidity:n().min(0).max(100).nullable().meta(M(`humidity`)),currentTemp:n().nullable().meta(M(`temperature`)),currentHumidity:n().min(0).max(100).nullable().meta(M(`humidity`)),swingVertical:v().nullable(),swingHorizontal:v().nullable(),minTemp:n().nullable().optional().meta(M(`temperature`)),maxTemp:n().nullable().optional().meta(M(`temperature`)),tempStep:n().positive().nullable().optional().meta(M(`temperature`)),lastActiveMode:mT.exclude([`off`]).optional(),lastFetchedAt:n()}),wye=[T.Climate];function _T(e,t){return{id:e,cardinality:`scalar`,vocabulary:{cap:`climate-control`,stateField:t},deviceTypes:wye,apply:`replace`,path:t,sources:[{kind:`numeric`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}}var vT=[_T(`room-temperature`,`currentTemp`),_T(`room-humidity`,`currentHumidity`)],Tye={version:1,overridable:vT.map(e=>({path:e.path,by:e.id})),targets:vT},yT={name:`climate-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Climate],power:{kind:`mode`,field:`mode`,offValue:`off`,set:`setMode`,lastField:`lastActiveMode`},methods:{setMode:k(b({deviceId:n().int().nonnegative(),mode:mT}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.off`,label:P(`Climate off`,`Clima spento`),phrase:P(`Turn off {device}`,`Spegni {device}`),icon:`power-off`,effect:{field:`mode`,value:`off`},args:{mode:`off`}},{id:`climate.heat`,label:P(`Heat`,`Riscalda`),phrase:P(`Set {device} to heat`,`Metti {device} in riscaldamento`),icon:`flame`,effect:{field:`mode`,value:`heat`},args:{mode:`heat`}},{id:`climate.cool`,label:P(`Cool`,`Raffresca`),phrase:P(`Set {device} to cool`,`Metti {device} in raffrescamento`),icon:`snowflake`,effect:{field:`mode`,value:`cool`},args:{mode:`cool`}},{id:`climate.auto`,label:P(`Climate auto`,`Clima automatico`),phrase:P(`Set {device} to automatic`,`Metti {device} in automatico`),icon:`thermometer`,effect:{field:`mode`,value:`auto`},args:{mode:`auto`}},{id:`climate.mode`,label:P(`Set mode`,`Imposta la modalità`),phrase:P(`Set {device} to {mode}`,`Imposta {device} su {mode}`),icon:`thermometer`,effect:{field:`mode`,fromArg:`mode`},openArgs:[{key:`mode`,label:P(`Mode`,`Modalità`),offer:{kind:`enum`,values:[{value:`off`,label:P(`Off`,`Spento`)},{value:`heat`,label:P(`Heat`,`Riscaldamento`)},{value:`cool`,label:P(`Cool`,`Raffrescamento`)},{value:`auto`,label:P(`Automatic`,`Automatico`)},{value:`heat_cool`,label:P(`Heat and cool`,`Caldo e freddo`)},{value:`fan_only`,label:P(`Fan only`,`Solo ventilazione`)},{value:`dry`,label:P(`Dry`,`Deumidificazione`)}]}}]}]}),setTarget:k(b({deviceId:n().int().nonnegative(),target:n()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.target`,label:P(`Set temperature`,`Imposta la temperatura`),phrase:P(`Set {device} to {target}`,`Imposta {device} a {target}`),icon:`thermometer`,effect:{field:`target`,fromArg:`target`},openArgs:[{key:`target`,label:P(`Temperature`,`Temperatura`),offer:{kind:`number`,step:.5,unit:`°C`}}]}]}),setTargetRange:A(b({deviceId:n().int().nonnegative(),targetLow:n(),targetHigh:n()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.targetRange`,label:P(`Set temperature range`,`Imposta l’intervallo di temperatura`),phrase:P(`Keep {device} between {targetLow} and {targetHigh}`,`Mantieni {device} tra {targetLow} e {targetHigh}`),icon:`thermometer`,effect:{field:`targetLow`,fromArg:`targetLow`},sideEffects:[{field:`targetHigh`,fromArg:`targetHigh`}],openArgs:[{key:`targetLow`,label:P(`Lowest`,`Minima`),offer:{kind:`number`,step:.5,unit:`°C`}},{key:`targetHigh`,label:P(`Highest`,`Massima`),offer:{kind:`number`,step:.5,unit:`°C`}}]}]}),setTargetHumidity:A(b({deviceId:n().int().nonnegative(),targetHumidity:n().min(0).max(100)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.targetHumidity`,label:P(`Set humidity`,`Imposta l’umidità`),phrase:P(`Set the humidity target of {device} to {targetHumidity}`,`Imposta l’umidità obiettivo di {device} al {targetHumidity}`),icon:`droplets`,effect:{field:`targetHumidity`,fromArg:`targetHumidity`},openArgs:[{key:`targetHumidity`,label:P(`Humidity`,`Umidità`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setFanMode:A(b({deviceId:n().int().nonnegative(),fanMode:l().min(1)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.fanMode`,label:P(`Set fan mode`,`Imposta la ventilazione`),phrase:P(`Set the fan of {device} to {fanMode}`,`Imposta la ventilazione di {device} su {fanMode}`),icon:`fan`,effect:{field:`fanMode`,fromArg:`fanMode`},openArgs:[{key:`fanMode`,label:P(`Fan mode`,`Ventilazione`),offer:{kind:`dynamic`,from:`status`,field:`availableFanModes`}}]}]}),setPreset:A(b({deviceId:n().int().nonnegative(),preset:l().min(1)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.preset`,label:P(`Set preset`,`Imposta il preset`),phrase:P(`Set {device} to preset {preset}`,`Imposta {device} sul preset {preset}`),icon:`list`,effect:{field:`preset`,fromArg:`preset`},openArgs:[{key:`preset`,label:P(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`status`,field:`availablePresets`}}]}]}),setSwingVertical:A(b({deviceId:n().int().nonnegative(),on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.swingVerticalOn`,label:P(`Vertical swing on`,`Oscillazione verticale attiva`),phrase:P(`Start the vertical swing of {device}`,`Attiva l’oscillazione verticale di {device}`),icon:`move-vertical`,effect:{field:`swingVertical`,value:!0},args:{on:!0}},{id:`climate.swingVerticalOff`,label:P(`Vertical swing off`,`Oscillazione verticale spenta`),phrase:P(`Stop the vertical swing of {device}`,`Ferma l’oscillazione verticale di {device}`),icon:`move-vertical`,effect:{field:`swingVertical`,value:!1},args:{on:!1}}]}),setSwingHorizontal:A(b({deviceId:n().int().nonnegative(),on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.swingHorizontalOn`,label:P(`Horizontal swing on`,`Oscillazione orizzontale attiva`),phrase:P(`Start the horizontal swing of {device}`,`Attiva l’oscillazione orizzontale di {device}`),icon:`move-horizontal`,effect:{field:`swingHorizontal`,value:!0},args:{on:!0}},{id:`climate.swingHorizontalOff`,label:P(`Horizontal swing off`,`Oscillazione orizzontale spenta`),phrase:P(`Stop the horizontal swing of {device}`,`Ferma l’oscillazione orizzontale di {device}`),icon:`move-horizontal`,effect:{field:`swingHorizontal`,value:!1},args:{on:!1}}]})},status:{schema:gT,kind:`push`},runtimeState:gT,customize:Tye,durability:`restored`,restoredStateFields:[`lastActiveMode`],history:{primary:`currentTemp`,priority:70,fields:{currentTemp:{group:`temperature`,kind:`gauge`,unit:`°C`,deadband:.1},currentHumidity:{kind:`gauge`,unit:`%`,deadband:.5},target:{group:`temperature`,kind:`gauge`,unit:`°C`,minIntervalMs:0},targetHigh:{group:`target-range`,kind:`gauge`,unit:`°C`,minIntervalMs:0},targetLow:{group:`target-range`,kind:`gauge`,unit:`°C`,minIntervalMs:0}}},vocabulary:{noun:P(`Climate`,`Clima`),order:1070,state:[{kind:`enum`,field:`mode`,label:P(`Mode`,`Modalità`),values:[{value:`off`,label:P(`Off`,`Spento`),phrase:P(`When {device} turns off`,`Quando {device} si spegne`)},{value:`heat`,label:P(`Heat`,`Riscaldamento`),phrase:P(`When {device} starts heating`,`Quando {device} passa al riscaldamento`)},{value:`cool`,label:P(`Cool`,`Raffrescamento`),phrase:P(`When {device} starts cooling`,`Quando {device} passa al raffrescamento`)},{value:`auto`,label:P(`Automatic`,`Automatico`)},{value:`heat_cool`,label:P(`Heat and cool`,`Caldo e freddo`)},{value:`fan_only`,label:P(`Fan only`,`Solo ventilazione`)},{value:`dry`,label:P(`Dry`,`Deumidificazione`)}],icon:`thermometer`},{kind:`numeric`,field:`currentTemp`,quantity:P(`the temperature`,`la temperatura`),label:P(`Temperature`,`Temperatura`),unit:`°C`,icon:`thermometer`},{kind:`numeric`,field:`currentHumidity`,quantity:P(`the humidity`,`l’umidità`),label:P(`Humidity`,`Umidità`),unit:`%`,icon:`droplets`},{kind:`numeric`,field:`target`,quantity:P(`the set temperature`,`la temperatura impostata`),label:P(`Set temperature`,`Temperatura impostata`),unit:`°C`,icon:`thermometer`}]}},bT=x([`backup`,`hub-server`,`agent-server`,`addons`]),xT=x([`pending`,`running`,`ok`,`failed`,`skipped`]),ST=x([`backup-unavailable`,`backup-failed`,`server-refused`,`server-not-on-target`,`node-capless`,`status-unreadable`,`addon-update-failed`,`addons-not-converged`,`interrupted`,`timeout-stall`,`timeout-ceiling`]),CT=b({kind:bT,nodeId:l().optional(),status:xT,detail:l(),reason:ST.optional(),fromVersion:l().nullable().optional(),packages:S(l()).readonly().optional(),startedAt:n().optional(),finishedAt:n().optional()}),wT=x([`running`,`succeeded`,`failed`]),TT=b({id:l(),state:wT,targetVersion:l(),requestedBy:l(),startedAt:n(),finishedAt:n().optional(),steps:S(CT).readonly(),stoppedAt:l().optional(),reason:ST.optional(),skippedOffline:S(l()).readonly()}),ET=b({version:l().optional(),addons:v().optional(),backup:v().optional()}),DT=x([`no-target`,`node-busy`,`job-running`,`nothing-to-do`,`status-unreadable`]),OT=b({targetVersion:l().nullable(),steps:S(CT).readonly(),skippedOffline:S(l()).readonly(),blocker:DT.nullable(),blockerDetail:l().nullable()}),kT=b({accepted:v(),jobId:l().nullable(),blocker:DT.nullable(),message:l()}),AT={name:`cluster-update`,scope:`system`,mode:`singleton`,methods:{previewClusterUpdate:k(ET,OT,{auth:`admin`}),startClusterUpdate:k(ET,kT,{kind:`mutation`,auth:`admin`}),getClusterUpdateJob:k(b({jobId:l().optional()}),TT.nullable(),{auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:j.CLUSTER}},jT=b({r:n().int().min(0).max(255).meta(M(`none`)),g:n().int().min(0).max(255).meta(M(`none`)),b:n().int().min(0).max(255).meta(M(`none`))}),MT=b({h:n().min(0).max(360).meta(M(`none`)),s:n().min(0).max(100).meta(M(`none`)),v:n().min(0).max(100).meta(M(`none`))}),NT=i(`mode`,[b({mode:p(`rgb`),rgb:jT}),b({mode:p(`hsv`),hsv:MT}),b({mode:p(`mired`),colorTemperature:n().int().min(50).max(1e3)})]),PT=b({mode:x([`rgb`,`hsv`,`mired`]),rgb:jT.optional(),hsv:MT.optional(),colorTemperature:n().int().optional().meta(M(`colour-temperature`)),lastChangedAt:n()});function Eye(e){let t=NT.safeParse(e);return t.success?t.data:null}var FT={name:`color`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Light],methods:{setColor:k(b({deviceId:n().int().nonnegative(),color:NT}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`color.warmWhite`,label:P(`Warm white`,`Bianco caldo`),phrase:P(`Set {device} to warm white`,`Imposta {device} su bianco caldo`),icon:`sun`,args:{color:{mode:`mired`,colorTemperature:370}}},{id:`color.coolWhite`,label:P(`Cool white`,`Bianco freddo`),phrase:P(`Set {device} to cool white`,`Imposta {device} su bianco freddo`),icon:`snowflake`,args:{color:{mode:`mired`,colorTemperature:200}}},{id:`color.red`,label:P(`Red`,`Rosso`),phrase:P(`Turn {device} red`,`Colora {device} di rosso`),icon:`palette`,args:{color:{mode:`rgb`,rgb:{r:255,g:0,b:0}}}},{id:`color.green`,label:P(`Green`,`Verde`),phrase:P(`Turn {device} green`,`Colora {device} di verde`),icon:`palette`,args:{color:{mode:`rgb`,rgb:{r:0,g:255,b:0}}}},{id:`color.blue`,label:P(`Blue`,`Blu`),phrase:P(`Turn {device} blue`,`Colora {device} di blu`),icon:`palette`,args:{color:{mode:`rgb`,rgb:{r:0,g:0,b:255}}}}]})},events:{onColorChanged:{data:b({deviceId:n(),mode:x([`rgb`,`hsv`,`mired`]),rgb:jT.optional(),hsv:MT.optional(),colorTemperature:n().int().optional(),lastChangedAt:n()}),notOperatorFacing:"a colour change is read through the `mode` state trigger"}},status:{schema:PT,kind:`command-driven`},runtimeState:PT,durability:`session`,history:`none`,vocabulary:{noun:P(`Colour`,`Colore`),order:1020,state:[{kind:`enum`,field:`mode`,label:P(`Colour mode`,`Modalità colore`),values:[{value:`rgb`,label:P(`RGB colour`,`Colore RGB`)},{value:`hsv`,label:P(`HSV colour`,`Colore HSV`)},{value:`mired`,label:P(`White temperature`,`Temperatura del bianco`)}],icon:`palette`}]}};function IT(e,t){let n=e;for(let e of t.split(`.`)){let t=qg(n);if(!(t instanceof le))return null;let r=t.shape[e];if(!(r instanceof ae))return null;n=r}return n}function LT(e,t){let n=Jg(e).find(e=>e.path===t);if(n===void 0)return null;let r=IT(e,t);return r===null?null:{path:t,kind:n.kind,nullable:r.safeParse(null).success,required:!r.safeParse(void 0).success,...n.enumValues===void 0?{}:{enumValues:n.enumValues},...n.unionMembers===void 0?{}:{unionMembers:n.unionMembers}}}function RT(e){return new Map(Jg(e).filter(e=>!e.path.includes(`.`)).flatMap(t=>{let n=LT(e,t.path);return n===null?[]:[[t.path,n]]}))}function zT(e){let t=qg(e);return t instanceof le?Object.entries(t.shape).flatMap(([e,t])=>t instanceof ae&&!t.safeParse(void 0).success?[e]:[]):[]}function BT(e,t){let n=t.split(`.`);return n.slice(0,-1).flatMap((t,r)=>{let i=n.slice(0,r+1).join(`.`),a=IT(e,i);return a!==null&&a.safeParse(void 0).success?[i]:[]})}var VT={"doorbell.onPressed":w.DoorbellOnPressed},Dye=VT,HT=b({featureIndex:n().int().nonnegative(),cap:l(),eventName:l(),category:x(w),stateField:l(),fieldKey:l()});function UT(e,t,n){return{code:e,path:t,message:n}}function Oye(e){return e.issues.map(e=>`${e.path.length===0?`payload`:e.path.join(`.`)}: ${e.message}`).join(`; `)}function WT(e,t,n){if(t.mode===`replace`)return{problems:[],events:[]};let r=[],i=[];for(let[a,o]of Object.entries(e.events??{})){let s=o.fromState;if(s===void 0)continue;let c=`features[${t.featureIndex}].fields.${s.field}`,l=e.runtimeState?LT(e.runtimeState,s.field):null;if(l===null){r.push(UT(`unknown-field`,c,`\`${e.name}.${a}\` derives from missing state field \`${s.field}\``));continue}if(l.kind!==`number`){r.push(UT(`kind-mismatch`,c,`\`${e.name}.${a}\` needs a numeric state field; \`${s.field}\` is ${l.kind}`));continue}let u=`${e.name}.${a}`,d=Dye[u];if(d===void 0){r.push(UT(`not-composable`,`features[${t.featureIndex}].cap`,`\`${u}\` has no explicit composition event-category mapping`));continue}let f=o.data.safeParse({deviceId:1,timestamp:1});if(!f.success){r.push(UT(`not-composable`,`features[${t.featureIndex}].cap`,`\`${u}\` cannot be derived from { deviceId, timestamp }: ${Oye(f.error)}`));continue}let p=n.find(n=>n.featureIndex===t.featureIndex&&n.cap===e.name&&n.path===s.field&&n.item===void 0);if(p===void 0){r.push(UT(`unknown-field`,c,`\`${u}\` derives from \`${s.field}\`, but that field is not composed`));continue}i.push({featureIndex:t.featureIndex,cap:e.name,eventName:a,category:d,stateField:s.field,fieldKey:`${p.cap}.${p.path}`})}return{problems:r,events:i}}var GT=x(`reserved-variant.unknown-capability.not-composable.wrong-device-type.has-commands.unknown-field.nested-field.missing-field.kind-mismatch.source-kind-mismatch.may-be-null.source-missing.source-unreadable.source-capability-missing.source-field-unknown.expression-invalid.cycle.duplicate-target.not-item-array.item-field-reserved.target-missing.target-unreadable.not-replaceable.native-capability-replace.mixed-quantity.helper-mismatch.member-constraint.retention.command-method-unknown.command-source-unknown.command-input-unknown.command-input-missing.power-source-is-actuator.link-contribution-removed`.split(`.`)),KT=b({code:GT,path:l(),message:l()}),qT=x([`string`,`number`,`boolean`,`enum`]),JT=x([`null`,`offline`,`unknown`,`release`,`omit`]),YT=x([`derived`,`clock`,`constant`,`accumulator`]),XT=b({arrayPath:l(),key:l(),label:l(),resettable:v().optional()}),ZT=b({cap:l(),path:l(),item:XT.optional(),featureIndex:n().int().nonnegative(),kind:qT,nullable:v(),required:v(),unavailable:JT,role:YT,source:ol,reads:S(Qc)});function QT(e){let t=e.item===void 0?e.path:Nl(e.item.arrayPath,e.item.key,e.path);return`${e.cap}.${t}`}var $T=x([`new`,`add`,`replace`]),eE=b({featureIndex:n().int().nonnegative(),cap:l(),mode:$T}),tE=b({ok:v(),problems:S(KT),fields:S(ZT),features:S(eE),events:S(HT)}),nE=x([`stopped`,`starting`,`running`,`degraded`,`incomplete`,`failed`]),rE=x([`fresh`,`stale`,`unavailable`]),iE=b({cap:l(),path:l(),item:XT.optional(),state:rE,value:h([l(),n(),v(),oe()]),reason:l().optional()}),aE=b({blockId:l(),deviceId:n().nullable(),status:nE,reason:l().optional(),fields:S(iE)}),kye=Xc,oE=b({id:l().min(1),name:l().min(1).max(120),enabled:v(),updatedAt:n(),composition:El}),sE=b({id:l().min(1),name:l().nullable(),error:l()}),cE=b({deviceId:n().int(),capName:l(),owner:l(),error:l()}),lE=b({integrationId:l().nullable(),storeLoaded:v(),blocks:S(oE),restartBlockIds:S(l()),unreadableBlocks:S(sE),retiredBlockIds:S(l()).optional()}),uE=b({blockId:l(),status:nE,reason:l().optional()}),dE=b({blocks:S(uE),acted:v(),unreleasedClaims:S(cE).optional()}),fE={name:`composer`,scope:`system`,mode:`singleton`,internal:!0,methods:{applyBlocks:k(lE,dE,{kind:`mutation`,auth:`admin`}),getStates:k(b({blockIds:S(l())}),b({states:S(aE)}),{auth:`admin`})},vocabulary:{notOperatorFacing:`device composition — an authoring tool, not an action`}},pE=b({connected:v(),lastChangedAt:n()}),mE={name:`connectivity`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Sensor],methods:{},status:{schema:pE,kind:`push`},runtimeState:pE,durability:`restored`,history:{fields:{connected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:P(`Connectivity`,`Connettività`),order:5040,state:[{kind:`boolean`,field:`connected`,label:P(`Connected`,`Connesso`),whenTrue:P(`When {device} connects`,`Quando {device} si connette`),whenFalse:P(`When {device} disconnects`,`Quando {device} si disconnette`),icon:`wifi`}]}},hE=x([`wear`,`supply`,`waste`]),gE=x([`part`,`tank`,`product`,`bin`]),_E=x([`ok`,`low`,`empty`,`full`,`replace`]),Aye=x([`ok`,`low`,`empty`,`full`]);function vE(e){return e.kind??`wear`}var jye={wear:`part`,waste:`bin`,supply:`product`};function Mye(e){return e.form??jye[vE(e)]}var yE=x([`duration`,`count`]),bE=b({value:n().min(0).nullable().meta(M(`device`)),kind:yE}),xE=b({key:l().min(1),label:l().min(1),level:n().min(0).max(100).nullable().meta(M(`percentage`)),status:_E.nullable(),kind:hE.optional(),form:gE.optional(),lastResetAt:n().nullable(),resettable:v(),remaining:bE.optional()}),SE=b({items:S(xE),lastChangedAt:n()}),Nye={items:[],lastChangedAt:0},Pye={version:1,targets:[{id:`items`,cardinality:`keyedArray`,vocabulary:{cap:`consumables`},deviceTypes:Object.values(T),apply:`add`,path:`items`,keyField:`key`,labelField:`label`,itemSchema:xE,nativeItems:`read-only`,sourceReport:{status:`assignment-status`},fields:[{path:`level`,sources:[{kind:`numeric`,transforms:[{kind:`identity`},{kind:`linear`,defaultScale:1,defaultOffset:0,clampMin:0,clampMax:100}]}]},{path:`remaining.value`,sources:[{kind:`numeric`,transforms:[{kind:`identity`}]}],literals:[{path:`remaining.kind`,values:[...yE.options]}]},{path:`status`,sources:[{kind:`enum`,transforms:[{kind:`enum-map`,outputValues:[..._E.options],unmapped:null}]}]}],traits:[{path:`kind`,values:[...hE.options],defaultValue:`wear`},{path:`form`,values:[...gE.options],defaultValue:`part`}],companions:[{kind:`clock`,path:`lastChangedAt`,when:`add`},{kind:`clock`,path:`lastFetchedAt`,when:`add`}],advancedExpression:!0}]},CE={name:`consumables`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:Object.values(T),methods:{reset:k(b({deviceId:n().int().nonnegative(),key:l().min(1)}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`consumables.reset`,label:P(`Mark as replaced`,`Segna come sostituito`),phrase:P(`Mark {key} as replaced on {device}`,`Segna {key} come sostituito su {device}`),icon:`refresh-cw`,openArgs:[{key:`key`,label:P(`Consumable`,`Materiale`),offer:{kind:`dynamic`,from:`status`,field:`items`,valueKey:`key`,labelKey:`label`,where:{key:`resettable`,equals:!0}}}]}]})},composedMethods:{reset:{kind:`refuse`,reason:`a consumable added to an existing device is not resettable — only a new composed device forwards a reset`}},status:{schema:SE,kind:`push`,empty:Nye,itemArray:{path:`items`,keyField:`key`,labelField:`label`,itemSchema:xE,emptyItem:{key:``,label:``,level:null,status:null,lastResetAt:null,resettable:!1}}},runtimeState:SE.extend({lastFetchedAt:n()}),durability:`restored`,customize:Pye,history:{fields:{},items:{path:`items`,key:`key`,label:`label`,fields:{level:{kind:`gauge`,unit:`%`,deadband:2,displayName:`Level`},status:{kind:`enum`,displayName:`Status`},"remaining.value":{kind:`gauge`,deadband:1,displayName:`Remaining`}}}},volatileStateFields:[`lastChangedAt`,`lastFetchedAt`],vocabulary:{noun:P(`Consumables`,`Materiali di consumo`),order:2070}},wE=b({entryOpen:v(),lastChangedAt:n()}),TE={name:`contact`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Sensor],methods:{},status:{schema:wE,kind:`push`},runtimeState:wE,durability:`restored`,history:{fields:{entryOpen:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:P(`Contact`,`Contatto`),order:5050,state:[{kind:`boolean`,field:`entryOpen`,label:P(`Open`,`Aperto`),whenTrue:P(`When {device} opens`,`Quando {device} si apre`),whenFalse:P(`When {device} closes`,`Quando {device} si chiude`),icon:`door-open`}]}},EE=x([`numeric`,`select`,`text`,`datetime`]),DE=b({kind:EE,value:h([n().meta(M(`device`)),l()]),options:S(l()),lastChangedAt:n(),min:n().optional().meta(M(`device`)),max:n().optional().meta(M(`device`)),step:n().optional().meta(M(`device`))}),Fye=i(`kind`,[b({kind:p(`numeric`),value:n()}),b({kind:p(`select`),value:l().min(1)}),b({kind:p(`text`),value:l()}),b({kind:p(`datetime`),value:l().min(1)})]),OE=b({deviceId:n().int().nonnegative(),cycle:v().default(!0)}),kE=b({deviceId:n().int().nonnegative()}),AE={name:`control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Control],methods:{setValue:k(b({deviceId:n().int().nonnegative(),control:Fye}),_(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`the value shape depends on the control kind (numeric / select / text / datetime) read from status; a typed picker for it is a follow-up of the automations rework`}),next:A(OE,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.next`,label:P(`Next option`,`Opzione successiva`),phrase:P(`Select the next option on {device}`,`Seleziona l’opzione successiva su {device}`),icon:`skip-forward`,openArgs:[{key:`cycle`,label:P(`Wrap to the first option`,`Ricomincia dalla prima opzione`),offer:{kind:`boolean`}}]}]}),previous:A(OE,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.previous`,label:P(`Previous option`,`Opzione precedente`),phrase:P(`Select the previous option on {device}`,`Seleziona l’opzione precedente su {device}`),icon:`skip-back`,openArgs:[{key:`cycle`,label:P(`Wrap to the last option`,`Ricomincia dall’ultima opzione`),offer:{kind:`boolean`}}]}]}),first:A(kE,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.first`,label:P(`First option`,`Prima opzione`),phrase:P(`Select the first option on {device}`,`Seleziona la prima opzione su {device}`),icon:`chevron-first`}]}),last:A(kE,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.last`,label:P(`Last option`,`Ultima opzione`),phrase:P(`Select the last option on {device}`,`Seleziona l’ultima opzione su {device}`),icon:`chevron-last`}]})},status:{schema:DE,kind:`push`},runtimeState:DE,durability:`session`,history:`none`,vocabulary:{noun:P(`Control`,`Controllo`),order:1150,state:[{kind:`value`,field:`value`,label:P(`Value`,`Valore`),offer:{kind:`dynamic`,from:`status`,field:`options`},icon:`sliders-horizontal`}]}},B=class extends Error{code;constructor(e,t){super(t),this.name=`IrCodecError`,this.code=e}},jE=1024,ME=S(n().int()).min(2).max(jE).superRefine((e,t)=>{e.forEach((e,n)=>{let r=n%2==0;(e===0||e>0!==r)&&t.addIssue({code:`custom`,message:`timing ${n} must be a non-zero ${r?`mark (positive)`:`space (negative)`}`,path:[n]})})}),NE=b({carrierHz:n().int().positive().optional(),dutyCyclePercent:n().int().min(1).max(100).optional(),repeat:n().int().min(0).max(20).optional(),repeatDelayMs:n().int().min(0).optional()}),Iye=.241246,Lye=0;function PE(e){let t=e.trim().split(/\s+/).filter(e=>e.length>0);if(t.length<4)throw new B(`pronto-malformed`,`Pronto code needs at least 4 words, got ${t.length}`);let n=t.map(e=>/^[0-9a-fA-F]{1,4}$/.test(e)?parseInt(e,16):NaN);if(n.some(e=>Number.isNaN(e)))throw new B(`pronto-malformed`,`Pronto code must be 4-digit hexadecimal words`);let[r,i,a,o]=n;if(r===void 0||i===void 0||a===void 0||o===void 0)throw new B(`pronto-malformed`,`Pronto header incomplete`);if(r!==Lye)throw new B(`pronto-unsupported-form`,`Pronto form ${t[0]??``} is not supported, only the learned 0000 form`);if(i===0)throw new B(`pronto-malformed`,`Pronto frequency word is zero`);let s=a+o;if(s===0||n.length!==4+s*2)throw new B(`pronto-malformed`,`Pronto declares ${s} burst pairs but carries ${(n.length-4)/2} word pairs`);let c=i*Iye,l=n.slice(4).map((e,t)=>{let n=Math.max(1,Math.round(e*c));return t%2==0?n:-n}),u=ME.safeParse(l);if(!u.success)throw new B(`invalid-timings`,`Pronto decoded to invalid timings: ${u.error.message}`);return{timings:u.data,carrierHz:Math.round(1e6/c)}}var Rye=8192,FE=32,IE=3,zye=264,LE=jE*2;function Bye(e){let t=[],n=0,r=e=>{if(t.length+e>LE)throw new B(`tuya-malformed`,`decompressed code is larger than any IR train`)},i=()=>{let t=e[n++];if(t===void 0)throw new B(`tuya-malformed`,`compressed stream is truncated`);return t};for(;n<e.length;){let e=i();if(e<32){r(e+1);for(let n=0;n<=e;n++)t.push(i());continue}let n=(e>>5)-1;n===6&&(n+=i());let a=((e&31)<<8)+i()+1,o=t.length-a;if(o<0)throw new B(`tuya-malformed`,`back-reference points before the stream`);r(n+3);for(let e=0;e<n+3;e++){let n=t[o+e];if(n===void 0)throw new B(`tuya-malformed`,`back-reference is invalid`);t.push(n)}}return Uint8Array.from(t)}function Vye(e){let t=[],n=new Map,r=0,i=n=>{for(let i=r;i<n;i+=FE){let r=Math.min(i+FE,n);t.push(r-i-1);for(let n=i;n<r;n++)t.push(e[n]??0)}},a=0;for(;a<e.length;){let o=0,s=0;if(a+IE<=e.length){let t=(e[a]??0)<<16|(e[a+1]??0)<<8|(e[a+2]??0),r=n.get(t);if(n.set(t,a),r!==void 0&&a-r<=Rye){let t=0;for(;a+t<e.length&&t<zye&&e[r+t]===e[a+t];)t++;t>=IE&&(o=t,s=a-r-1)}}if(o===0){a++;continue}i(a);let c=o-2;c<7?t.push(c<<5|s>>8):t.push(224|s>>8,c-7),t.push(s&255),a+=o,r=a}return i(e.length),Uint8Array.from(t)}var RE=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Hye=65535;function Uye(e){let t=``;for(let n=0;n<e.length;n+=3){let r=e[n]??0,i=e[n+1]??0,a=e[n+2]??0,o=r<<16|i<<8|a;t+=RE[o>>18&63],t+=RE[o>>12&63],t+=n+1<e.length?RE[o>>6&63]:`=`,t+=n+2<e.length?RE[o&63]:`=`}return t}function Wye(e){let t=e.trim().replace(/=+$/,``);if(t.length===0||t.length%4==1)throw new B(`tuya-malformed`,`not a base64 string`);let n=[],r=0,i=0;for(let e of t){let t=RE.indexOf(e);if(t<0)throw new B(`tuya-malformed`,`not a base64 string`);i=i<<6|t,r+=6,r>=8&&(r-=8,n.push(i>>r&255))}return Uint8Array.from(n)}function zE(e){let t=new Uint8Array(e.length*2);return e.forEach((e,n)=>{let r=Math.abs(e);if(r===0||r>Hye)throw new B(`invalid-timings`,`timing ${n} does not fit 16 bits`);t[n*2]=r&255,t[n*2+1]=r>>8}),Uye(Vye(t))}function BE(e){let t=Bye(Wye(e));if(t.length===0||t.length%2!=0)throw new B(`tuya-malformed`,`payload is not a list of 16-bit durations`);let n=[];for(let e=0;e<t.length;e+=2){let r=(t[e]??0)|(t[e+1]??0)<<8;n.push(e/2%2==0?r:-r)}let r=ME.safeParse(n);if(!r.success)throw new B(`tuya-malformed`,r.error.message);return r.data}var VE=x([`tuya`]),HE=Math.ceil((LE+Math.ceil(LE/32))/3)*4+256,UE=b({format:VE,code:l().min(1).max(HE)}),WE={tuya:{encode:zE,decode:BE}},GE=i(`kind`,[b({kind:p(`raw`),timings:S(n().int()),settings:NE.optional()}),b({kind:p(`pronto`),code:l()}),b({kind:p(`native`),format:VE,code:l()})]);function KE(e){if(e.kind===`pronto`){let t=PE(e.code);return{timings:t.timings,settings:{carrierHz:t.carrierHz}}}if(e.kind===`native`)return{timings:WE[e.format].decode(e.code),settings:{}};let t=ME.safeParse(e.timings);if(!t.success)throw new B(`invalid-timings`,t.error.message);return{timings:t.data,settings:e.settings??{}}}var qE=`power.power_on.power_off.volume_up.volume_down.mute.channel_up.channel_down.up.down.left.right.ok.back.home.menu.info.guide.exit.input.play.pause.play_pause.stop.next.previous.fast_forward.rewind.digit_0.digit_1.digit_2.digit_3.digit_4.digit_5.digit_6.digit_7.digit_8.digit_9.source_select`.split(`.`),JE=[`source_select`];function YE(e){return JE.includes(e)}var XE=`custom:`,Gye=/^[a-z0-9][a-z0-9_]{0,47}$/,Kye=new Set(qE);function ZE(e){return Kye.has(e)}function QE(e){return Gye.test(e)}function $E(e){return`${XE}${e}`}function eD(e){if(!e.startsWith(`custom:`))return null;let t=e.slice(7);return QE(t)?t:null}function tD(e){return ZE(e)||eD(e)!==null}var nD=l().refine(tD,{message:`a role is one of the known roles or custom:<key> (lowercase letters, digits, _)`}),rD=[`digits`,`sequence`,`ir`],qye=x(rD),Jye=200,Yye=16,Xye=6,Zye=/^[a-z0-9][a-z0-9_-]{0,47}$/,Qye=RegExp(`^[0-9]{1,6}$`),iD={id:l().regex(Zye,{message:`a lowercase slug`}),name:l().trim().min(1).max(60)},aD=b({...iD,kind:p(`digits`),number:l().regex(Qye,{message:`up to 6 digits`})}),oD=b({...iD,kind:p(`sequence`),steps:S(nD).min(1).max(16)}),sD=b({...iD,kind:p(`ir`),transmitterId:n().int().nonnegative().optional(),payload:GE}),cD=i(`kind`,[aD,oD,sD]),$ye=500,ebe=100,lD=3e3;function uD(e){switch(e.kind){case`sequence`:return e.steps;case`digits`:return Array.from(e.number,e=>`digit_${e}`);case`ir`:return[]}}function dD(e){try{return KE(e.payload),null}catch(e){if(e instanceof B)return e.message;throw e}}function tbe(e,t){return e.trim().toLowerCase()===t.trim().toLowerCase()}function fD(e,t){let n=t.trim();for(let t of e)if(t.kind===`digits`&&t.number===n)return t;return null}function nbe(e,t){let n=e.find(e=>tbe(e.name,t));if(n!==void 0)return n;let r=e.find(e=>e.id===t.trim());return r===void 0?fD(e,t):r}var pD=x([`off`,`on`,`idle`,`playing`,`paused`,`buffering`,`standby`]),mD=x([`off`,`all`,`one`]),rbe=b({type:l(),title:l(),artist:l().optional(),album:l().optional(),imageUrl:l().optional()}),hD=x([`reported`,`assumed`]),gD=x([`state`,`volumeLevel`,`isMuted`,`source`]),_D=b({state:pD,stateSource:hD.default(`reported`),assumedFields:S(gD).default([]),volumeLevel:n().min(0).max(100).nullable().meta(M(`percentage`)),isMuted:v().nullable(),muteReadback:v().optional(),source:l(),availableSources:S(l()),declaredSources:S(b({name:l(),kind:x(rD),number:l().optional()})).optional(),currentMedia:rbe.nullable(),position:n().int().nonnegative().nullable().meta(M(`duration-ms`)),duration:n().int().nonnegative().nullable().meta(M(`duration-ms`)),shuffle:v().nullable(),repeat:mD.nullable(),positionUpdatedAt:n().nullable().default(null),lastChangedAt:n()}),ibe=50,vD=b({deviceId:n().int().nonnegative(),steps:n().int().min(1).max(50).default(1)}),yD=b({deviceId:n().int().nonnegative()}),bD={name:`media-player`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.MediaPlayer],power:{kind:`methods`,field:`state`,offValues:[`off`,`standby`],on:`turnOn`,off:`turnOff`},methods:{turnOn:A(yD,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.turnOn`,label:P(`Turn on`,`Accendi`),phrase:P(`Turn on {device}`,`Accendi {device}`),icon:`power`}]}),turnOff:A(yD,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.turnOff`,label:P(`Turn off`,`Spegni`),phrase:P(`Turn off {device}`,`Spegni {device}`),icon:`power`}]}),volumeUp:A(vD,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.volumeUp`,label:P(`Volume up`,`Alza il volume`),phrase:P(`Raise the volume of {device}`,`Alza il volume di {device}`),icon:`volume-2`}]}),volumeDown:A(vD,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.volumeDown`,label:P(`Volume down`,`Abbassa il volume`),phrase:P(`Lower the volume of {device}`,`Abbassa il volume di {device}`),icon:`volume-2`}]}),channelUp:A(vD,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.channelUp`,label:P(`Channel up`,`Canale successivo`),phrase:P(`Go to the next channel on {device}`,`Passa al canale successivo su {device}`),icon:`skip-forward`}]}),channelDown:A(vD,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.channelDown`,label:P(`Channel down`,`Canale precedente`),phrase:P(`Go to the previous channel on {device}`,`Torna al canale precedente su {device}`),icon:`skip-back`}]}),play:k(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.play`,effect:{field:`state`,value:`playing`},label:P(`Play`,`Riproduci`),phrase:P(`Play on {device}`,`Avvia la riproduzione su {device}`),icon:`play`}]}),pause:k(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.pause`,effect:{field:`state`,value:`paused`},label:P(`Pause media`,`Metti in pausa`),phrase:P(`Pause {device}`,`Metti in pausa {device}`),icon:`pause`}]}),stop:A(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.stop`,label:P(`Stop media`,`Ferma la riproduzione`),phrase:P(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),next:A(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.next`,label:P(`Next track`,`Brano successivo`),phrase:P(`Skip to the next track on {device}`,`Passa al brano successivo su {device}`),icon:`skip-forward`}]}),previous:A(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.previous`,label:P(`Previous track`,`Brano precedente`),phrase:P(`Go back to the previous track on {device}`,`Torna al brano precedente su {device}`),icon:`skip-back`}]}),setVolume:A(b({deviceId:n().int().nonnegative(),volumeLevel:n().min(0).max(100)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.volume`,effect:{field:`volumeLevel`,fromArg:`volumeLevel`},label:P(`Set volume`,`Imposta il volume`),phrase:P(`Set the volume of {device} to {volumeLevel}`,`Imposta il volume di {device} al {volumeLevel}`),icon:`volume-2`,openArgs:[{key:`volumeLevel`,label:P(`Volume`,`Volume`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setMute:A(b({deviceId:n().int().nonnegative(),muted:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.mute`,effect:{field:`isMuted`,value:!0},label:P(`Mute`,`Silenzia`),phrase:P(`Mute {device}`,`Silenzia {device}`),icon:`volume-x`,args:{muted:!0}},{id:`media.unmute`,effect:{field:`isMuted`,value:!1},label:P(`Unmute`,`Riattiva l’audio`),phrase:P(`Unmute {device}`,`Riattiva l’audio di {device}`),icon:`volume-2`,args:{muted:!1}}]}),setShuffle:A(b({deviceId:n().int().nonnegative(),shuffle:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.shuffleOn`,effect:{field:`shuffle`,value:!0},label:P(`Shuffle on`,`Riproduzione casuale attiva`),phrase:P(`Turn on shuffle on {device}`,`Attiva la riproduzione casuale su {device}`),icon:`shuffle`,args:{shuffle:!0}},{id:`media.shuffleOff`,effect:{field:`shuffle`,value:!1},label:P(`Shuffle off`,`Riproduzione casuale spenta`),phrase:P(`Turn off shuffle on {device}`,`Disattiva la riproduzione casuale su {device}`),icon:`shuffle`,args:{shuffle:!1}}]}),setRepeat:A(b({deviceId:n().int().nonnegative(),repeat:mD}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.repeat`,effect:{field:`repeat`,fromArg:`repeat`},label:P(`Set repeat`,`Imposta la ripetizione`),phrase:P(`Set repeat on {device} to {repeat}`,`Imposta la ripetizione di {device} su {repeat}`),icon:`repeat`,openArgs:[{key:`repeat`,label:P(`Repeat`,`Ripetizione`),offer:{kind:`enum`,values:[{value:`off`,label:P(`Off`,`Disattivata`)},{value:`all`,label:P(`All`,`Tutti i brani`)},{value:`one`,label:P(`One track`,`Un brano`)}]}}]}]}),selectSource:A(b({deviceId:n().int().nonnegative(),source:l().min(1)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.source`,effect:{field:`source`,fromArg:`source`},label:P(`Select source`,`Scegli la sorgente`),phrase:P(`Switch {device} to {source}`,`Passa {device} alla sorgente {source}`),icon:`cast`,openArgs:[{key:`source`,label:P(`Source`,`Sorgente`),offer:{kind:`dynamic`,from:`status`,field:`availableSources`}}]}]}),seek:A(b({deviceId:n().int().nonnegative(),position:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.seek`,label:P(`Seek`,`Vai al punto`),phrase:P(`Move {device} to {position}`,`Porta {device} al punto {position}`),icon:`fast-forward`,openArgs:[{key:`position`,label:P(`Position`,`Posizione`),offer:{kind:`number`,min:0,step:1e3,unit:`ms`}}]}]}),playMedia:A(b({deviceId:n().int().nonnegative(),mediaId:l().min(1),mediaType:l().min(1)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.playMedia`,label:P(`Play media`,`Riproduci un contenuto`),phrase:P(`Play {mediaId} on {device}`,`Riproduci {mediaId} su {device}`),icon:`music`,openArgs:[{key:`mediaId`,label:P(`Media`,`Contenuto`),offer:{kind:`text`}},{key:`mediaType`,label:P(`Media type`,`Tipo di contenuto`),offer:{kind:`text`}}]}]})},status:{schema:_D,kind:`push`},runtimeState:_D,durability:`session`,history:{fields:{volumeLevel:{kind:`gauge`,unit:`%`,deadband:1},isMuted:{kind:`boolean`}}},vocabulary:{noun:P(`Media player`,`Lettore multimediale`),order:2060,state:[{kind:`enum`,field:`state`,label:P(`Playback`,`Riproduzione`),values:[{value:`off`,label:P(`Off`,`Spento`),phrase:P(`When {device} turns off`,`Quando {device} si spegne`)},{value:`on`,label:P(`On`,`Acceso`),phrase:P(`When {device} turns on`,`Quando {device} si accende`)},{value:`idle`,label:P(`Idle`,`Inattivo`)},{value:`playing`,label:P(`Playing`,`In riproduzione`),phrase:P(`When {device} starts playing`,`Quando {device} inizia a riprodurre`)},{value:`paused`,label:P(`Paused`,`In pausa`),phrase:P(`When {device} is paused`,`Quando {device} va in pausa`)},{value:`buffering`,label:P(`Buffering`,`In caricamento`)},{value:`standby`,label:P(`Standby`,`In standby`)}],icon:`music`},{kind:`numeric`,field:`volumeLevel`,quantity:P(`the volume`,`il volume`),label:P(`Volume`,`Volume`),unit:`%`,icon:`volume-2`},{kind:`boolean`,field:`isMuted`,label:P(`Muted`,`Silenziato`),whenTrue:P(`When {device} is muted`,`Quando {device} viene silenziato`),whenFalse:P(`When {device} is unmuted`,`Quando l’audio di {device} torna attivo`),icon:`volume-x`},{kind:`value`,field:`source`,label:P(`Source`,`Sorgente`),offer:{kind:`dynamic`,from:`status`,field:`availableSources`},icon:`cast`}]}},xD={battery:{version:1,targets:[{id:`level`,cardinality:`scalar`,deviceTypes:[T.Camera,T.Sensor,T.Button,T.Switch,T.PetFeeder,T.Container,T.Climate,T.EventEmitter],apply:`add`,vocabularyCap:`battery`,vocabularyStateField:`level`,sources:[{kind:`field`,valueKinds:[`number`,`string`],transformKinds:[`identity`,`linear`],transforms:[{kind:`identity`},{kind:`linear`,defaultScale:1,defaultOffset:0,clampMin:0,clampMax:100}]}],sourceReport:{status:`assignment-status`},advancedExpression:!0,path:`level`,valueKind:`number`,nullable:!0,companions:[{kind:`constant`,path:`charging`,value:`unknown`,when:`add`},{kind:`constant`,path:`sleeping`,value:!1,when:`add`},{kind:`clock`,path:`lastUpdated`,when:`add`}]}]},"climate-control":{version:1,targets:[{id:`room-temperature`,cardinality:`scalar`,deviceTypes:[T.Climate],apply:`replace`,vocabularyCap:`climate-control`,vocabularyStateField:`currentTemp`,sources:[{kind:`numeric`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`currentTemp`,valueKind:`number`,nullable:!0},{id:`room-humidity`,cardinality:`scalar`,deviceTypes:[T.Climate],apply:`replace`,vocabularyCap:`climate-control`,vocabularyStateField:`currentHumidity`,sources:[{kind:`numeric`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`currentHumidity`,valueKind:`number`,nullable:!0}],overridable:[{path:`currentTemp`,by:`room-temperature`},{path:`currentHumidity`,by:`room-humidity`}]},consumables:{version:1,targets:[{id:`items`,cardinality:`keyedArray`,deviceTypes:[T.Camera,T.Light,T.Siren,T.Switch,T.Sensor,T.Climate,T.Button,T.EventEmitter,T.Update,T.Generic,T.Notifier,T.Script,T.Automation,T.Lock,T.Cover,T.Valve,T.Humidifier,T.WaterHeater,T.Fan,T.MediaPlayer,T.AlarmPanel,T.Control,T.Presence,T.Weather,T.WeatherStation,T.Vacuum,T.LawnMower,T.Container,T.Image,T.PetFeeder,T.PetFountain,T.Dishwasher,T.Washer,T.Dryer,T.Gateway,T.HeatPump,T.EnergySystem,T.Workload],apply:`add`,vocabularyCap:`consumables`,sources:[],sourceReport:{status:`assignment-status`},advancedExpression:!0,path:`items`,keyField:`key`,labelField:`label`,nativeItems:`read-only`,fields:[{path:`level`,valueKind:`number`,nullable:!0,sources:[{kind:`numeric`,transformKinds:[`identity`,`linear`],transforms:[{kind:`identity`},{kind:`linear`,defaultScale:1,defaultOffset:0,clampMin:0,clampMax:100}]}]},{path:`remaining.value`,valueKind:`number`,nullable:!0,sources:[{kind:`numeric`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],literals:[{path:`remaining.kind`,values:[`duration`,`count`]}]},{path:`status`,valueKind:`enum`,nullable:!0,enumValues:[`ok`,`low`,`empty`,`full`,`replace`],sources:[{kind:`enum`,transformKinds:[`enum-map`],transforms:[{kind:`enum-map`,outputValues:[`ok`,`low`,`empty`,`full`,`replace`],unmapped:null}]}]}],traits:[{path:`kind`,values:[`wear`,`supply`,`waste`],defaultValue:`wear`},{path:`form`,values:[`part`,`tank`,`product`,`bin`],defaultValue:`part`}],companions:[{kind:`clock`,path:`lastChangedAt`,when:`add`},{kind:`clock`,path:`lastFetchedAt`,when:`add`}]}]},doorbell:{version:1,targets:[{id:`pressed`,cardinality:`event`,deviceTypes:[T.Camera],apply:`add`,vocabularyCap:`doorbell`,vocabularyEvent:`onPressed`,sources:[{kind:`binary`,transformKinds:[],transforms:[]},{kind:`switch`,transformKinds:[],transforms:[]}],sourceReport:{status:`assignment-status`},advancedExpression:!0,shape:`pulse`,applyAuthority:{kind:`composition-claim`},eventName:`onPressed`,combine:`any`,edges:[`rising`],defaultEdge:`rising`,timestampPath:`lastPressedAt`,counterPath:`pressCountSinceStart`,highWater:`composer-advance`,debounceMs:2e3}]},"fan-control":{version:1,targets:[{id:`horizontal-oscillating`,cardinality:`scalar`,deviceTypes:[T.Fan],apply:`replace`,vocabularyCap:`fan-control`,vocabularyStateField:`oscillating`,sources:[{kind:`switch`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,section:`oscillation-axes`,path:`oscillationAxes.horizontal.oscillating`,valueKind:`boolean`,nullable:!0},{id:`horizontal-angle`,cardinality:`scalar`,deviceTypes:[T.Fan],apply:`replace`,vocabularyCap:`fan-control`,sources:[{kind:`numeric`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,section:`oscillation-axes`,path:`oscillationAxes.horizontal.angle`,valueKind:`number`,nullable:!0,companions:[{kind:`source-field`,path:`oscillationAxes.horizontal.min`,field:`min`},{kind:`source-field`,path:`oscillationAxes.horizontal.max`,field:`max`},{kind:`source-field`,path:`oscillationAxes.horizontal.step`,field:`step`}]},{id:`horizontal-sweepFrom`,cardinality:`scalar`,deviceTypes:[T.Fan],apply:`replace`,vocabularyCap:`fan-control`,sources:[{kind:`numeric`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,section:`oscillation-axes`,path:`oscillationAxes.horizontal.sweepFrom`,valueKind:`number`,nullable:!0},{id:`horizontal-sweepTo`,cardinality:`scalar`,deviceTypes:[T.Fan],apply:`replace`,vocabularyCap:`fan-control`,sources:[{kind:`numeric`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,section:`oscillation-axes`,path:`oscillationAxes.horizontal.sweepTo`,valueKind:`number`,nullable:!0},{id:`vertical-oscillating`,cardinality:`scalar`,deviceTypes:[T.Fan],apply:`replace`,vocabularyCap:`fan-control`,vocabularyStateField:`oscillating`,sources:[{kind:`switch`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,section:`oscillation-axes`,path:`oscillationAxes.vertical.oscillating`,valueKind:`boolean`,nullable:!0},{id:`vertical-angle`,cardinality:`scalar`,deviceTypes:[T.Fan],apply:`replace`,vocabularyCap:`fan-control`,sources:[{kind:`numeric`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,section:`oscillation-axes`,path:`oscillationAxes.vertical.angle`,valueKind:`number`,nullable:!0,companions:[{kind:`source-field`,path:`oscillationAxes.vertical.min`,field:`min`},{kind:`source-field`,path:`oscillationAxes.vertical.max`,field:`max`},{kind:`source-field`,path:`oscillationAxes.vertical.step`,field:`step`}]},{id:`vertical-sweepFrom`,cardinality:`scalar`,deviceTypes:[T.Fan],apply:`replace`,vocabularyCap:`fan-control`,sources:[{kind:`numeric`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,section:`oscillation-axes`,path:`oscillationAxes.vertical.sweepFrom`,valueKind:`number`,nullable:!0},{id:`vertical-sweepTo`,cardinality:`scalar`,deviceTypes:[T.Fan],apply:`replace`,vocabularyCap:`fan-control`,sources:[{kind:`numeric`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,section:`oscillation-axes`,path:`oscillationAxes.vertical.sweepTo`,valueKind:`number`,nullable:!0},{id:`preset`,cardinality:`scalar`,deviceTypes:[T.Fan],apply:`replace`,vocabularyCap:`fan-control`,sources:[{kind:`field`,valueKinds:[`string`],transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`preset`,valueKind:`string`,nullable:!1}],overridable:[{path:`oscillationAxes.horizontal.oscillating`,by:`horizontal-oscillating`},{path:`oscillationAxes.horizontal.angle`,by:`horizontal-angle`},{path:`oscillationAxes.horizontal.sweepFrom`,by:`horizontal-sweepFrom`},{path:`oscillationAxes.horizontal.sweepTo`,by:`horizontal-sweepTo`},{path:`oscillationAxes.vertical.oscillating`,by:`vertical-oscillating`},{path:`oscillationAxes.vertical.angle`,by:`vertical-angle`},{path:`oscillationAxes.vertical.sweepFrom`,by:`vertical-sweepFrom`},{path:`oscillationAxes.vertical.sweepTo`,by:`vertical-sweepTo`},{path:`preset`,by:`preset`}]},"fan-presets":{version:1,targets:[{id:`presets`,cardinality:`config`,deviceTypes:[T.Fan],apply:`add`,readMethod:`getPresets`,writeMethod:`setPresets`,vocabularyCap:`fan-presets`,sources:[],sourceReport:{status:`assignment-status`},advancedExpression:!1}]},"lock-control":{version:1,targets:[{id:`door-contact`,cardinality:`scalar`,deviceTypes:[T.Lock],apply:`replace`,vocabularyCap:`lock-control`,vocabularyStateField:`state`,sources:[{kind:`binary`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`state`,override:{whenSourceTrue:`door-open`,unlessNative:[`jammed`]},valueKind:`enum`,nullable:!1,enumValues:[`locked`,`unlocked`,`locking`,`unlocking`,`jammed`,`door-open`]}],overridable:[{path:`state`,by:`door-contact`}]},motion:{version:1,targets:[{id:`detected`,cardinality:`event`,deviceTypes:[T.Camera],apply:`add`,vocabularyCap:`motion`,vocabularyEvent:`onMotionChanged`,sources:[{kind:`binary`,transformKinds:[],transforms:[]},{kind:`switch`,transformKinds:[],transforms:[]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,shape:`span`,applyAuthority:{kind:`camera-sensors`,timeoutField:`motionCooldownMs`},eventName:`onMotionChanged`,combine:`any`,start:`rising-edge`,end:`falling-edge-or-timeout`,timeoutMs:3e4,sourceModes:[`in-addition`,`confirm`,`replace`]}]},"power-meter":{version:1,targets:[{id:`power`,cardinality:`scalar`,deviceTypes:[T.Switch,T.Light,T.Fan,T.Climate,T.Humidifier,T.WaterHeater,T.MediaPlayer,T.Washer,T.Dryer,T.Dishwasher,T.Vacuum,T.LawnMower,T.PetFeeder,T.Workload],apply:`add`,vocabularyCap:`power-meter`,vocabularyStateField:`power`,sources:[{kind:`numeric`,requiredUnit:`W`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!0,path:`power`,valueKind:`number`,nullable:!1,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`always`}]},{id:`energy`,cardinality:`scalar`,deviceTypes:[T.Switch,T.Light,T.Fan,T.Climate,T.Humidifier,T.WaterHeater,T.MediaPlayer,T.Washer,T.Dryer,T.Dishwasher,T.Vacuum,T.LawnMower,T.PetFeeder,T.Workload],apply:`add`,vocabularyCap:`power-meter`,vocabularyStateField:`energy`,sources:[{kind:`numeric`,requiredUnit:`kWh`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!0,path:`energy`,valueKind:`number`,nullable:!1,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`always`}]},{id:`voltage`,cardinality:`scalar`,deviceTypes:[T.Switch,T.Light,T.Fan,T.Climate,T.Humidifier,T.WaterHeater,T.MediaPlayer,T.Washer,T.Dryer,T.Dishwasher,T.Vacuum,T.LawnMower,T.PetFeeder,T.Workload],apply:`add`,vocabularyCap:`power-meter`,vocabularyStateField:`voltage`,sources:[{kind:`numeric`,requiredUnit:`V`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!0,path:`voltage`,valueKind:`number`,nullable:!1,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`always`}]},{id:`current`,cardinality:`scalar`,deviceTypes:[T.Switch,T.Light,T.Fan,T.Climate,T.Humidifier,T.WaterHeater,T.MediaPlayer,T.Washer,T.Dryer,T.Dishwasher,T.Vacuum,T.LawnMower,T.PetFeeder,T.Workload],apply:`add`,vocabularyCap:`power-meter`,vocabularyStateField:`current`,sources:[{kind:`numeric`,requiredUnit:`A`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!0,path:`current`,valueKind:`number`,nullable:!1,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`always`}]}]},"power-source":{version:1,targets:[{id:`switch`,cardinality:`scalar`,deviceTypes:[T.Gateway,T.Camera,T.Sensor,T.MediaPlayer,T.Vacuum,T.Generic,T.Washer,T.Dryer,T.Dishwasher,T.PetFountain,T.Fan,T.Humidifier,T.Climate,T.WaterHeater],apply:`add`,vocabularyCap:`power-source`,vocabularyStateField:`switchOn`,sources:[{kind:`switch`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`switchOn`,valueKind:`boolean`,nullable:!0,companions:[{kind:`constant`,path:`offSeconds`,value:10,when:`add`,formerValues:[0]},{kind:`clock`,path:`lastFetchedAt`,when:`always`}]}]},remote:{version:1,targets:[{id:`remote`,cardinality:`config`,deviceTypes:[T.MediaPlayer],apply:`add`,readMethod:`getConfig`,writeMethod:`setConfig`,vocabularyCap:`remote`,sources:[],sourceReport:{status:`assignment-status`},advancedExpression:!1}]},"running-state":{version:1,targets:[{id:`running`,cardinality:`scalar`,deviceTypes:[T.Washer,T.Dryer,T.Dishwasher,T.Vacuum,T.LawnMower,T.MediaPlayer,T.WaterHeater,T.Humidifier,T.Fan,T.Climate,T.PetFeeder],apply:`add`,vocabularyCap:`running-state`,vocabularyStateField:`running`,sources:[{kind:`switch`,transformKinds:[`identity`],transforms:[{kind:`identity`}]},{kind:`binary`,transformKinds:[`identity`,`invert`],transforms:[{kind:`identity`},{kind:`invert`}]},{kind:`numeric`,requiredUnit:`W`,transformKinds:[`threshold`],transforms:[{kind:`threshold`,comparisons:[`gte`,`lte`],comparison:`gte`,defaultThreshold:5,defaultStartDwellMs:3e4,defaultStopDwellMs:18e4,deviceTypeDefaults:{[T.MediaPlayer]:{startDwellMs:1e4,stopDwellMs:1e4,minSamples:1}},thresholdUnit:`W`}]}],sourceReport:{status:`assignment-status`,runtimeField:`source`,nativeValue:`native`,assignedValue:`assigned`},advancedExpression:!0,path:`running`,valueKind:`boolean`,nullable:!0,companions:[{kind:`constant`,path:`source`,value:`assigned`,when:`always`},{kind:`constant`,path:`phase`,value:null,when:`add`},{kind:`clock`,path:`lastFetchedAt`,when:`always`},{kind:`transition-time`,path:`since`,sourceChangedAt:`prefer`}]}],overridable:[{path:`running`,by:`running`}]},"weather-station":{version:1,targets:[{id:`temperature`,cardinality:`scalar`,deviceTypes:[T.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`temperature`,sources:[{kind:`numeric`,requiredUnit:`°C`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`temperature`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`humidity`,cardinality:`scalar`,deviceTypes:[T.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`humidity`,sources:[{kind:`numeric`,requiredUnit:`%`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`humidity`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`pressure`,cardinality:`scalar`,deviceTypes:[T.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`pressure`,sources:[{kind:`numeric`,requiredUnit:`hPa`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`pressure`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`windSpeed`,cardinality:`scalar`,deviceTypes:[T.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`windSpeed`,sources:[{kind:`numeric`,requiredUnit:`m/s`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`windSpeed`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`windGust`,cardinality:`scalar`,deviceTypes:[T.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`windGust`,sources:[{kind:`numeric`,requiredUnit:`m/s`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`windGust`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`windBearing`,cardinality:`scalar`,deviceTypes:[T.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`windBearing`,sources:[{kind:`numeric`,requiredUnit:`°`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`windBearing`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`rainRate`,cardinality:`scalar`,deviceTypes:[T.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`rainRate`,sources:[{kind:`numeric`,requiredUnit:`mm/h`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`rainRate`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`rainDaily`,cardinality:`scalar`,deviceTypes:[T.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`rainDaily`,sources:[{kind:`numeric`,requiredUnit:`mm`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`rainDaily`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`rainEvent`,cardinality:`scalar`,deviceTypes:[T.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`rainEvent`,sources:[{kind:`numeric`,requiredUnit:`mm`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`rainEvent`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`uv`,cardinality:`scalar`,deviceTypes:[T.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`uv`,sources:[{kind:`numeric`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`uv`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`solarRadiation`,cardinality:`scalar`,deviceTypes:[T.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`solarRadiation`,sources:[{kind:`numeric`,requiredUnit:`W/m²`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`solarRadiation`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`dewPoint`,cardinality:`scalar`,deviceTypes:[T.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`dewPoint`,sources:[{kind:`numeric`,requiredUnit:`°C`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`dewPoint`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`feelsLike`,cardinality:`scalar`,deviceTypes:[T.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`feelsLike`,sources:[{kind:`numeric`,requiredUnit:`°C`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`feelsLike`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`vpd`,cardinality:`scalar`,deviceTypes:[T.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`vpd`,sources:[{kind:`numeric`,requiredUnit:`kPa`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`vpd`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`windGustMax`,cardinality:`scalar`,deviceTypes:[T.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`windGustMax`,sources:[{kind:`numeric`,requiredUnit:`m/s`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`windGustMax`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`windBearingAvg`,cardinality:`scalar`,deviceTypes:[T.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`windBearingAvg`,sources:[{kind:`numeric`,requiredUnit:`°`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`windBearingAvg`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`rain24h`,cardinality:`scalar`,deviceTypes:[T.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`rain24h`,sources:[{kind:`numeric`,requiredUnit:`mm`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`rain24h`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`rainWeekly`,cardinality:`scalar`,deviceTypes:[T.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`rainWeekly`,sources:[{kind:`numeric`,requiredUnit:`mm`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`rainWeekly`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`rainMonthly`,cardinality:`scalar`,deviceTypes:[T.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`rainMonthly`,sources:[{kind:`numeric`,requiredUnit:`mm`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`rainMonthly`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`rainYearly`,cardinality:`scalar`,deviceTypes:[T.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`rainYearly`,sources:[{kind:`numeric`,requiredUnit:`mm`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`rainYearly`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]}],overridable:[{path:`temperature`,by:`temperature`},{path:`humidity`,by:`humidity`},{path:`pressure`,by:`pressure`},{path:`windSpeed`,by:`windSpeed`},{path:`windGust`,by:`windGust`},{path:`windBearing`,by:`windBearing`},{path:`rainRate`,by:`rainRate`},{path:`rainDaily`,by:`rainDaily`},{path:`rainEvent`,by:`rainEvent`},{path:`uv`,by:`uv`},{path:`solarRadiation`,by:`solarRadiation`},{path:`dewPoint`,by:`dewPoint`},{path:`feelsLike`,by:`feelsLike`},{path:`vpd`,by:`vpd`},{path:`windGustMax`,by:`windGustMax`},{path:`windBearingAvg`,by:`windBearingAvg`},{path:`rain24h`,by:`rain24h`},{path:`rainWeekly`,by:`rainWeekly`},{path:`rainMonthly`,by:`rainMonthly`},{path:`rainYearly`,by:`rainYearly`}]}},SD={"ambient-light-sensor":{illuminance:`lx`},battery:{level:`%`,voltage:`V`},"humidity-sensor":{humidity:`%`},"power-meter":{power:`W`,deliveredPower:`W`,energy:`kWh`,voltage:`V`,current:`A`},"temperature-sensor":{temperature:`°C`}};function V(e,t,n){return{code:e,path:t,message:n}}function CD(...e){return{problems:e,fields:[],features:[],events:[]}}function wD(e){let t=e.item===void 0?`fields`:`items.${e.item.key}.fields`;return`features[${e.featureIndex}].${t}.${e.path}`}var TD={kind:`fixed`,result:[`number`]},ED={kind:`fixed`,result:[`boolean`]},DD=Object.freeze({min:TD,max:TD,abs:TD,floor:TD,ceil:TD,sqrt:TD,round:TD,pow:TD,clamp:TD,avg:TD,sum:TD,age:TD,convert:TD,coalesce:{kind:`coalesce`},any:ED,all:ED,within:ED,latest:{kind:`fixed`,result:[`number`,`null`]},number:{kind:`fixed`,result:[`number`,`null`]},rose:{kind:`fixed`,result:[`number`,`null`]},count:TD,dwell:{kind:`fixed`,result:[`boolean`,`null`]},latchedAt:{kind:`fixed`,result:[`number`,`null`]},schmitt:{kind:`fixed`,result:[`boolean`,`null`]}}),OD=class extends Error{};function kD(e){return e===null?`null`:typeof e==`number`?`number`:typeof e==`string`?`string`:`boolean`}function AD(e){return new Set([e])}function jD(...e){return new Set(e.flatMap(e=>[...e]))}function abe(e){return new Set([...e].filter(e=>e!==`null`))}function obe(e,t,n){if(e===`+`){let e=[...t,...n];return e.every(e=>e===`string`)?AD(`string`):e.every(e=>e===`number`)?AD(`number`):new Set([`number`,`string`])}return AD(e===`-`||e===`*`||e===`/`||e===`%`?`number`:`boolean`)}function sbe(e){return e.minArgs===e.maxArgs?`exactly ${e.minArgs}`:e.maxArgs===1/0?`at least ${e.minArgs}`:`${e.minArgs}–${e.maxArgs}`}function cbe(e,t){let n=gs[e];if(n!==void 0&&(t.length<n.minArgs||t.length>n.maxArgs))throw new OD(`${e}: wrong number of arguments (${t.length}); expected ${sbe(n)}`);let r=DD[e];if(r===void 0)throw new OD(`no result-kind rule for builtin '${e}'`);if(r.kind===`fixed`)return new Set(r.result);let i=jD(...t.map(abe));return t.every(e=>e.has(`null`))?jD(i,AD(`null`)):i}function MD(e,t){switch(e.kind){case`literal`:return AD(kD(e.value));case`identifier`:{if(e.name===`now`)return AD(`number`);let n=t.get(e.name);if(n===void 0)throw new OD(`unbound identifier '${e.name}'`);return n}case`unary`:return AD(e.op===`!`?`boolean`:`number`);case`binary`:return obe(e.op,MD(e.left,t),MD(e.right,t));case`logical`:return jD(MD(e.left,t),MD(e.right,t));case`conditional`:return jD(MD(e.consequent,t),MD(e.alternate,t));case`call`:return cbe(e.callee,e.args.map(e=>MD(e,t)))}}function ND(e,t){switch(e.kind){case`literal`:case`identifier`:return!1;case`unary`:return ND(e.operand,t);case`binary`:case`logical`:return ND(e.left,t)||ND(e.right,t);case`conditional`:return ND(e.test,t)||ND(e.consequent,t)||ND(e.alternate,t);case`call`:return e.callee===t||e.args.some(e=>ND(e,t))}}function PD(e,t){let n=Ds(e);return n.ok&&ND(n.parsed.ast,t)}function FD(e){let t=Ds(e.expr);if(!t.ok)return{ok:!1,error:t.error};try{return{ok:!0,kinds:MD(t.parsed.ast,e.bindingKinds)}}catch(e){if(e instanceof OD)return{ok:!1,error:e.message};throw e}}function lbe(e){return e.publish===`value`&&e.empty===`null`?{ok:!0,kinds:new Set([`number`,`null`])}:{ok:!0,kinds:new Set([`number`])}}function ube(e){return e.publish===`value`?e.reducer===`any`||e.reducer===`all`?{ok:!0,kinds:new Set([`boolean`])}:e.empty===`null`?{ok:!0,kinds:new Set([`number`,`null`])}:{ok:!0,kinds:new Set([`number`])}:{ok:!0,kinds:new Set([`number`])}}function ID(e,t){let n=t(e.cap),r=n?.runtimeState??n?.status?.schema;if(n===null||r===void 0)return{ok:!1,code:`source-field-unknown`,message:`no capability \`${e.cap}\` with state to read`};let i=LT(r,e.fieldPath);if(i===null)return{ok:!1,code:`source-field-unknown`,message:`\`${e.cap}\` has no field \`${e.fieldPath}\``};let a=i.kind===`union`?i.unionMembers??[]:[i.kind===`enum`?`string`:i.kind];return{ok:!0,kinds:new Set(i.nullable?[...a,`null`]:a)}}function LD(e,t,n){return V(`kind-mismatch`,n,`\`${e}.${t}\` is a union — it is read as a source, never written`)}function RD(e){return e.kind===`union`?null:e.kind===`enum`?`string`:e.kind}function zD(e,t,n,r){if(e.kind!==`from`)return n;let i=r(e.cap),a=i?.runtimeState??i?.status?.schema;if(a===void 0)return n;let o=LT(a,e.fieldPath),s=RD(t);return o?.kind!==`union`||s===null||!n.has(s)?n:new Set(n.has(`null`)?[s,`null`]:[s])}function BD(e,t){if(e.kind===`from`)return ID(e,t);if(e.kind===`code`)return{ok:!1,code:`reserved-variant`,message:`code fields arrive in slice 4`};if(e.kind===`aggregate`)return ube(e);if(e.kind===`series`)return lbe(e);let n=new Map;for(let[r,i]of Object.entries(e.bindings)){if(i.kind===`literal`){n.set(r,new Set([kD(i.value)]));continue}let e=ID(i,t);if(!e.ok)return{...e,message:`binding \`${r}\`: ${e.message}`};n.set(r,e.kinds)}let r=FD({expr:e.expr,bindingKinds:n});return r.ok?{ok:!0,kinds:r.kinds}:{ok:!1,code:`expression-invalid`,message:r.error}}function VD(e,t,n,r){let i=RD(t);if(i===null)return[LD(e,t.path,r)];let a=[...n].filter(e=>e!==`null`&&e!==i),o=[];return a.length>0&&o.push(V(`kind-mismatch`,r,`\`${e}.${t.path}\` is a ${t.kind}; this source can produce ${a.join(` or `)}`)),n.has(`null`)&&!t.nullable&&o.push(V(`may-be-null`,r,`\`${e}.${t.path}\` cannot be null and this source can produce null — wrap it in coalesce(…) or pick a non-null source`)),o}function dbe(e){if(e.kind!==`expression`)return null;let t=Ds(e.expr);if(!t.ok)return null;let n=t.parsed.ast;return n.kind===`literal`&&typeof n.value==`string`?n.value:null}function HD(e,t,n,r){if(t.kind!==`enum`||t.enumValues===void 0)return null;let i=dbe(n);if(i===null||t.enumValues.includes(i))return null;let a=t.enumValues.map(e=>`\`${e}\``).join(`, `);return V(`kind-mismatch`,r,`\`${e}.${t.path}\` accepts only ${a}; this source is the literal \`${i}\``)}function UD(e){if(e.kind!==`expression`)return`derived`;if(PD(e.expr,`count`))return`accumulator`;if(Ml(e).length>0)return`derived`;let t=Ds(e.expr);return t.ok&&t.parsed.identifiers.has(`now`)?`clock`:`constant`}function WD(e,t,n,r,i){return n===`replace`&&(t===`derived`||t===`accumulator`)?{ok:!0,unavailable:`release`}:n===`new`||t!==`derived`?{ok:!0,unavailable:e.nullable?`null`:`offline`}:e.nullable?{ok:!0,unavailable:`null`}:e.enumValues?.includes(`unknown`)===!0?{ok:!0,unavailable:`unknown`}:e.required?{ok:!1,problem:V(`not-replaceable`,i,`\`${r}.${e.path}\` reads a source but can say neither null nor 'unknown', and an ADDED capability has no native reading to fall back to`)}:{ok:!0,unavailable:`omit`}}var GD={resettable:!1};function fbe(e){return new Set([e.keyField,...e.labelField===void 0?[]:[e.labelField],...Object.keys(GD)])}function pbe(e,t,n){let r=LT(e.itemSchema,t);return r===null||!r.required?!1:BT(e.itemSchema,t).every(e=>n.some(t=>t.startsWith(`${e}.`)))}function mbe({capName:e,itemArray:t,reserved:n},r,i){let a=Object.keys(r.fields);return Jg(t.itemSchema).flatMap(o=>{if(n.has(o.path)||o.path in r.fields||!pbe(t,o.path,a))return[];let s=LT(t.itemSchema,o.path);return s===null||s.nullable?[]:[V(`missing-field`,`${i}.fields.${o.path}`,`\`${e}.${t.path}[].${o.path}\` is required and has no source`)]})}function hbe(e,t){let{capName:n,itemArray:r,featureIndex:i,lookupCap:a}=e,{key:o,label:s,path:c,source:l}=t,u=`features[${i}].items.${o}.fields.${c}`;if(e.reserved.has(c))return CD(V(`item-field-reserved`,u,`\`${n}.${r.path}[].${c}\` is set by the composer itself — it takes no source`));let d=LT(r.itemSchema,c);if(d===null)return CD(V(`unknown-field`,u,`a \`${n}\` item has no field \`${c}\``));if(d.kind===`union`)return CD(LD(n,c,u));let f=BD(l,a);if(!f.ok)return CD(V(f.code,u,f.message));let p=UD(l),m=WD(d,p,e.mode,n,u);if(!m.ok)return CD(m.problem);let h={cap:n,path:c,item:{arrayPath:r.path,key:o,label:s,...t.resettable?{resettable:!0}:{}},featureIndex:i,kind:d.kind,nullable:d.nullable,required:d.required,unavailable:m.unavailable,role:p,source:l,reads:[...Ml(l)]},g=HD(n,d,l,u);return{problems:[...VD(n,d,zD(l,d,f.kinds,a),u),...g===null?[]:[g]],fields:[h],features:[],events:[]}}function KD(e,t,n,r,i=`new`){let a=`features[${n}].items`,o=e.status?.itemArray;if(o===void 0)return CD(V(`not-item-array`,a,`\`${e.name}\` has no item array — it takes no \`items\``));if(o.path!==`items`)return CD(V(`not-item-array`,a,`\`${e.name}\`'s item array is at \`${o.path}\`, not \`${hl}\` — not composable yet`));let s={capName:e.name,itemArray:o,reserved:fbe(o),featureIndex:n,lookupCap:r,mode:i},c=Object.entries(t.items??{}).flatMap(([e,t])=>[{problems:mbe(s,t,`${a}.${e}`),fields:[],features:[],events:[]},...Object.entries(t.fields).map(([n,r])=>hbe(s,{key:e,label:t.label,resettable:t.reset!==void 0,path:n,source:r}))]);return{problems:c.flatMap(e=>e.problems),fields:c.flatMap(e=>e.fields),features:[],events:[]}}var qD=`deviceId`;function JD(e,t){let n=`features[${t}]`,r=Object.entries(e.commands??{}).flatMap(([e,t])=>t.kind===`forward`?[{at:`${n}.commands.${e}`,method:e,command:t}]:[]),i=Object.entries(e.items??{}).flatMap(([e,t])=>t.reset===void 0?[]:[{at:`${n}.items.${e}.reset`,method:`reset`,itemKey:e,command:t.reset}]);return[...r,...i]}function YD(e){let t=e.features.flatMap((e,t)=>e.kind===`fields`&&xl(e)?JD(e,t).map(e=>e.command.source):[]);return[...new Map(t.map(e=>[Dl(e),e])).values()]}function gbe(e,t){return e.name===`switch`&&t===`toggle`}function XD(e){return Object.entries(e.methods).filter(([t,n])=>n.systemOnly!==!0&&e.composedMethods?.[t]===void 0&&!gbe(e,t)).map(([e])=>e)}function _be(){return Object.fromEntries(XD(bD).map(e=>[e,{kind:`extension`,target:`remote`}]))}var ZD={all:new Set,required:new Set};function QD(e,t){let n=e.methods[t]?.input;if(n===void 0)return null;let r=qg(n);if(!(r instanceof le))return null;let i=Object.entries(r.shape).filter(([e])=>e!==qD);return{all:new Set(i.map(([e])=>e)),required:new Set(i.flatMap(([e,t])=>t instanceof ae&&!t.safeParse(void 0).success?[e]:[]))}}function $D(e){return typeof e==`object`?ul(e)?[e.$input]:Object.values(e).flatMap($D):[]}function eO(e){return[...e].map(e=>`\`${e}\``).join(`, `)}function vbe(e,t){let{command:n,at:r}=e,i=t(n.cap);if(i===null)return{def:null,problems:[V(`command-source-unknown`,`${r}.cap`,`no capability is named \`${n.cap}\``)]};let a=i.methods[n.method];return a===void 0||a.systemOnly===!0?{def:null,problems:[V(`command-source-unknown`,`${r}.method`,`\`${n.cap}\` has no method \`${n.method}\` to forward to`)]}:a.kind===`mutation`?{def:i,problems:[]}:{def:null,problems:[V(`command-source-unknown`,`${r}.method`,`\`${n.cap}.${n.method}\` is a query — a command calls a mutation of the source`)]}}function ybe(e,t,n,r){let{at:i,command:a}=e,o=`${a.cap}.${a.method}`,s=[];if(`deviceId`in r&&s.push(V(`command-input-unknown`,`${i}.args.${qD}`,`\`${qD}\` is the source device's own — a forward never takes it as an argument`)),n!==null){for(let e of Object.keys(r).filter(e=>e!==`deviceId`&&!n.all.has(e)))s.push(V(`command-input-unknown`,`${i}.args.${e}`,`\`${o}\` has no input field \`${e}\` (it takes ${eO(n.all)})`));let e=[...n.required].filter(e=>!(e in r));e.length>0&&s.push(V(`command-input-missing`,`${i}.args`,`\`${o}\` needs ${eO(e)}, which \`args\` does not provide`))}let c=e.itemKey===void 0?t:ZD;if(c!==null)for(let t of Object.values(r).flatMap($D))c.all.has(t)||s.push(V(`command-input-unknown`,`${i}.args`,c===ZD?`an item's \`reset\` takes no input — \`$input: ${t}\` has nothing to read`:`\`$input: ${t}\` is not a field of the \`${e.method}\` input (it takes ${eO(c.all)})`));return s}function bbe(e,t,n){let{at:r,command:i}=e,a=`${i.cap}.${i.method}`,o=e.itemKey===void 0?t:ZD;if(o===null||n===null)return[];let s=[];for(let t of[...o.all].filter(e=>!n.all.has(e)))s.push(V(`command-input-unknown`,`${r}.args`,`\`${e.method}\` takes \`${t}\`, which \`${a}\` does not (it takes ${eO(n.all)}) — add \`args\` to map it`));let c=[...n.required].filter(e=>!o.all.has(e));return c.length>0&&s.push(V(`command-input-missing`,`${r}.args`,`\`${a}\` needs ${eO(c)}, which \`${e.method}\` does not take — add \`args\` to provide it`)),s}function tO(e,t,n){let r=vbe(t,n);if(r.def===null)return r.problems;let i=QD(e,t.method),a=QD(r.def,t.command.method),o=t.command.args;return o===void 0?bbe(t,i,a):ybe(t,i,a,o)}function nO(e,t,n){let r=new Set(XD(e));return Object.keys(t.commands??{}).flatMap(t=>{if(r.has(t))return[];let i=e.composedMethods?.[t]!==void 0;return[V(`command-method-unknown`,`${n}.commands.${t}`,i?`\`${e.name}.${t}\` is answered by the composer itself — an item's \`reset\` serves it`:`\`${e.name}\` has no method \`${t}\` to serve`)]})}function rO(e,t){return e.features.flatMap((e,n)=>e.kind!==`fields`||!xl(e)?[]:JD(e,n).flatMap(e=>{let n=Dl(e.command.source),r=t.get(n),i=`${e.at}.source`;return r===void 0||r.kind===`unreadable`?[V(`source-unreadable`,i,`could not read source \`${n}\` (${r===void 0?`it was not read`:r.error}) — the save is refused rather than stored unchecked`)]:r.kind===`absent`?[V(`source-missing`,i,`source \`${n}\` does not exist`)]:r.caps.has(e.command.cap)?[]:[V(`source-capability-missing`,i,`source \`${n}\` (device ${r.deviceId}) has no \`${e.command.cap}\``)]}))}var iO={fieldPath:`lastFetchedAt`,expr:`now`},aO={fieldPath:`lastChangedAt`,expr:`now`};function oO(e){let{alsoFrom:t,...n}=e;return{...n,family:`numeric`,deviceType:T.Sensor,memberDeviceType:T.Sensor,memberDeviceTypes:[T.Sensor,...t?.deviceTypes??[]],activeWhen:void 0,commandCaps:[],baseUnit:ma(e.quantity),aggregates:wc,accept:[{cap:e.outputCap,fieldPath:e.outputField},...t===void 0?[]:[t.accept]]}}var sO=[T.Climate];function cO(e){return{...e,family:`binary`,deviceType:T.Sensor,memberDeviceType:T.Sensor,memberDeviceTypes:[T.Sensor],activeWhen:void 0,commandCaps:[],quantity:`none`,baseUnit:void 0,aggregates:Tc,empty:`offline`}}var lO=[oO({id:`temperature`,summary:`Mean, median, min, max or sum of temperatures. Offline and unknown members are left out, never read as 0 °C.`,role:D.TemperatureSensor,outputCap:`temperature-sensor`,outputField:`temperature`,quantity:`temperature`,defaultAggregate:`mean`,empty:`null`,companions:[iO],alsoFrom:{deviceTypes:sO,accept:{cap:`climate-control`,fieldPath:`currentTemp`}}}),oO({id:`humidity`,summary:`Humidity in percent. Offline and unknown members are left out, never read as 0 %.`,role:D.HumiditySensor,outputCap:`humidity-sensor`,outputField:`humidity`,quantity:`humidity`,defaultAggregate:`mean`,empty:`null`,companions:[iO],alsoFrom:{deviceTypes:sO,accept:{cap:`climate-control`,fieldPath:`currentHumidity`}}}),oO({id:`pressure`,summary:`Pressure in hectopascals. Offline and unknown members are left out, never read as 0 hPa.`,role:D.PressureSensor,outputCap:`pressure-sensor`,outputField:`pressure`,quantity:`pressure`,defaultAggregate:`mean`,empty:`null`,companions:[iO]}),oO({id:`illuminance`,summary:`Illuminance in lux. Offline and unknown members are left out, never read as 0 lx.`,role:D.AmbientLightSensor,outputCap:`ambient-light-sensor`,outputField:`illuminance`,quantity:`illuminance`,defaultAggregate:`mean`,empty:`null`,companions:[iO]}),oO({id:`power`,summary:`Power in watts, summed by default. Nobody reporting omits the key rather than writing 0 W.`,role:D.PowerSensor,outputCap:`power-meter`,outputField:`power`,quantity:`power`,defaultAggregate:`sum`,empty:`omit`,companions:[iO]}),oO({id:`energy`,summary:`Energy in kilowatt-hours, summed by default. Nobody reporting omits the key rather than writing 0 kWh.`,role:D.EnergySensor,outputCap:`power-meter`,outputField:`energy`,quantity:`energy`,defaultAggregate:`sum`,empty:`omit`,companions:[iO]}),oO({id:`battery`,summary:`Battery charge in percent. Offline and unknown members are left out, never read as 0 %.`,role:D.BatterySensor,outputCap:`battery`,outputField:`level`,quantity:`percentage`,defaultAggregate:`mean`,empty:`null`,companions:[{fieldPath:`charging`,expr:`"unknown"`},{fieldPath:`sleeping`,expr:`false`},{fieldPath:`lastUpdated`,expr:`now`}]}),oO({id:`numeric`,summary:`A numeric reading in the members’ shared quantity. Mixed quantities are refused. Nobody reporting publishes null, not 0.`,role:D.NumericSensor,outputCap:`numeric-sensor`,outputField:`value`,quantity:`device`,defaultAggregate:`mean`,empty:`null`,companions:[iO]}),cO({id:`motion`,summary:`Any or all motion. Offline and unknown members are left out, never read as off. Nobody reporting takes the device offline.`,role:D.MotionSensor,outputCap:`motion`,outputField:`detected`,defaultAggregate:`any`,accept:[{cap:`motion`,fieldPath:`detected`}],companions:[{fieldPath:`lastDetectedAt`,expr:`null`},{fieldPath:`autoClearAfterMs`,expr:`null`}]}),cO({id:`contact`,summary:`Any or all open contacts. Offline and unknown members are left out, never read as closed.`,role:D.ContactSensor,outputCap:`contact`,outputField:`entryOpen`,defaultAggregate:`any`,accept:[{cap:`contact`,fieldPath:`entryOpen`}],companions:[aO]}),cO({id:`leak`,summary:`Any or all leak detections. Offline and unknown members are left out, never read as dry.`,role:D.LeakSensor,outputCap:`flood`,outputField:`flooded`,defaultAggregate:`any`,accept:[{cap:`flood`,fieldPath:`flooded`}],companions:[aO]}),cO({id:`smoke`,summary:`Any or all smoke detections. Offline and unknown members are left out, never read as clear.`,role:D.SmokeSensor,outputCap:`smoke`,outputField:`detected`,defaultAggregate:`any`,accept:[{cap:`smoke`,fieldPath:`detected`}],companions:[aO]}),cO({id:`occupancy`,summary:`Any or all of motion or binary sensors, published as a binary. Presence zones are not aggregated. Nobody reporting is offline, not off.`,role:D.BinarySensor,outputCap:`binary`,outputField:`on`,defaultAggregate:`any`,accept:[{cap:`motion`,fieldPath:`detected`},{cap:`binary`,fieldPath:`on`}],companions:[aO]}),cO({id:`binary`,summary:`Any or all generic binary sensors. Offline and unknown members are left out, never read as off.`,role:D.BinarySensor,outputCap:`binary`,outputField:`on`,defaultAggregate:`any`,accept:[{cap:`binary`,fieldPath:`on`}],companions:[aO]}),uO({id:`switch`,summary:`On when at least one switch is on, or when all of them are. Offline and unknown members are left out of that decision, never read as off, and still receive the command.`,deviceType:T.Switch,outputCap:`switch`,outputField:`on`,member:{cap:`switch`,fieldPath:`on`},commandCaps:[`switch`]}),uO({id:`light`,summary:`On when at least one light is on, or when all of them are. Brightness and colour are offered only when every member has them. A command is not sent to a member that lacks it.`,deviceType:T.Light,outputCap:`switch`,outputField:`on`,member:{cap:`switch`,fieldPath:`on`},commandCaps:[`switch`,`brightness`,`color`]}),uO({id:`fan`,summary:`On when at least one fan is on, or when all of them are. Speed, preset, direction and oscillation are offered only when every fan has them. A command is not sent to a fan that lacks it.`,deviceType:T.Fan,outputCap:`switch`,outputField:`on`,member:{cap:`switch`,fieldPath:`on`},commandCaps:[`switch`,`fan-control`]}),uO({id:`cover`,summary:`Open when at least one cover is open or part-open, or only when all of them are. Position and tilt are offered only when every cover has them. A cover that reports nothing is left out, never read as closed.`,deviceType:T.Cover,outputCap:`group-active`,outputField:`active`,member:{cap:`cover`,fieldPath:`state`},activeWhen:[`open`,`opening`,`stopped`],commandCaps:[`cover`]}),uO({id:`valve`,summary:`Open when at least one valve is open or part-open, or only when all of them are. Position is offered only when every valve has it. A valve that reports nothing is left out, never read as closed.`,deviceType:T.Valve,outputCap:`group-active`,outputField:`active`,member:{cap:`valve`,fieldPath:`state`},activeWhen:[`open`,`opening`,`stopped`],commandCaps:[`valve`]}),uO({id:`lock`,summary:`Locked when at least one lock is locked, or only when all of them are. A jammed or moving lock is not locked. Locking is one tap; unlocking the group needs a confirmation every time, and nothing is sent without it.`,deviceType:T.Lock,outputCap:`group-active`,outputField:`active`,member:{cap:`lock-control`,fieldPath:`state`},activeWhen:[`locked`],commandCaps:[`lock-control`]}),uO({id:`media-player`,summary:`Playing when at least one player is playing, or only when all of them are. Volume is offered only when every player has it. A player that reports nothing is left out, never read as stopped.`,deviceType:T.MediaPlayer,outputCap:`group-active`,outputField:`active`,member:{cap:`media-player`,fieldPath:`state`},activeWhen:[`playing`,`buffering`],commandCaps:[`media-player`]}),uO({id:`climate`,summary:`Running when at least one thermostat or air conditioner is not off, or only when all of them are. Target temperature and fan are offered only when every device has them. A device that reports nothing is left out, never read as off.`,deviceType:T.Climate,memberDeviceTypes:[T.Climate],outputCap:`group-active`,outputField:`active`,member:{cap:`climate-control`,fieldPath:`mode`},activeWhen:[`heat`,`cool`,`auto`,`heat_cool`,`fan_only`,`dry`],commandCaps:[`climate-control`]})];function uO(e){return{id:e.id,summary:e.summary,deviceType:e.deviceType,outputCap:e.outputCap,outputField:e.outputField,commandCaps:e.commandCaps,family:`actuator`,role:void 0,memberDeviceType:e.deviceType,memberDeviceTypes:e.memberDeviceTypes??[e.deviceType],activeWhen:e.activeWhen,quantity:`none`,baseUnit:void 0,aggregates:Tc,defaultAggregate:`any`,empty:`offline`,accept:[e.member],companions:[aO]}}var xbe=new Map(lO.map(e=>[e.id,e]));function dO(e){return xbe.get(e)??null}var fO={"air-quality-sensor":{co2:{kind:`gauge`,unit:`ppm`,deadband:5},voc:{kind:`gauge`,unit:`ppb`,deadband:5},pm25:{group:`particulates`,kind:`gauge`,unit:`µg/m³`,deadband:1},pm10:{group:`particulates`,kind:`gauge`,unit:`µg/m³`,deadband:1},aqi:{kind:`gauge`,unit:`count`,deadband:1}},"alarm-panel":{state:{kind:`enum`,values:[`disarmed`,`armed_home`,`armed_away`,`armed_night`,`armed_vacation`,`armed_custom_bypass`,`arming`,`disarming`,`pending`,`triggered`]}},"ambient-light-sensor":{illuminance:{kind:`gauge`,unit:`lx`,deadbandPct:10,minIntervalMs:6e4}},battery:{level:{kind:`gauge`,unit:`%`},voltage:{kind:`gauge`,unit:`V`}},binary:{on:{kind:`boolean`}},brightness:{level:{kind:`gauge`,unit:`%`,minIntervalMs:0}},"carbon-monoxide":{detected:{kind:`boolean`}},"climate-control":{currentTemp:{group:`temperature`,kind:`gauge`,unit:`°C`,deadband:.1},currentHumidity:{kind:`gauge`,unit:`%`,deadband:.5},target:{group:`temperature`,kind:`gauge`,unit:`°C`,minIntervalMs:0},targetHigh:{group:`target-range`,kind:`gauge`,unit:`°C`,minIntervalMs:0},targetLow:{group:`target-range`,kind:`gauge`,unit:`°C`,minIntervalMs:0}},connectivity:{connected:{kind:`boolean`}},contact:{entryOpen:{kind:`boolean`}},cover:{position:{kind:`gauge`,unit:`%`,minIntervalMs:0}},"device-status":{online:{kind:`boolean`}},dishwasher:{progress:{kind:`gauge`,unit:`%`,deadband:2},state:{kind:`enum`,values:[`idle`,`running`,`paused`,`finished`,`error`,`unavailable`]},operationState:{kind:`enum`,values:[`Inactive`,`Ready`,`DelayedStart`,`Run`,`Pause`,`ActionRequired`,`Finished`,`Error`,`Aborting`]},remaining:{kind:`gauge`,unit:`s`,minIntervalMs:6e4},doorOpen:{kind:`boolean`},powerOn:{kind:`boolean`}},"do-not-disturb":{enabled:{kind:`boolean`}},"energy-system":{"solar.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Solar power`},"solar.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`Solar energy`},"grid.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Grid power`},"grid.importKwh":{kind:`counter`,unit:`kWh`,displayName:`Grid import`},"grid.exportKwh":{kind:`counter`,unit:`kWh`,displayName:`Grid export`},"house.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`House power`},"house.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`House energy`},"heatPump.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Heat pump power`},"heatPump.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`Heat pump energy`},"storage.stateOfChargePct":{kind:`gauge`,unit:`%`,deadband:1,displayName:`Storage charge`},"storage.storedKwh":{kind:`gauge`,unit:`kWh`,deadband:.05,displayName:`Stored energy`},"storage.capacityKwh":{kind:`gauge`,unit:`kWh`,deadband:.1,displayName:`Storage capacity`},"storage.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Storage power`},"storage.chargedKwh":{kind:`counter`,unit:`kWh`,displayName:`Storage charged`},"storage.dischargedKwh":{kind:`counter`,unit:`kWh`,displayName:`Storage discharged`},"storage.healthPct":{kind:`gauge`,unit:`%`,deadband:1,displayName:`Storage health`}},"enum-sensor":{value:{kind:`enum`,skipWhenSet:`timestamp`}},"fan-control":{speed:{kind:`gauge`,unit:`%`,minIntervalMs:0},oscillating:{kind:`boolean`}},flood:{flooded:{kind:`boolean`}},gas:{detected:{kind:`boolean`}},"heat-pump-status":{"power.thermalW":{group:`power`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Thermal power`},"power.electricalW":{group:`power`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Electrical power`},"power.compressorPct":{kind:`gauge`,unit:`%`,deadband:2,displayName:`Compressor`},"temperatures.supply":{group:`loop`,kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Supply`},"temperatures.return":{group:`loop`,kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Return`},"temperatures.outdoor":{kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Outdoor`},"energy.thermalKwh":{kind:`counter`,unit:`kWh`,displayName:`Thermal energy`},"energy.electricalKwh":{kind:`counter`,unit:`kWh`,displayName:`Electrical energy`}},"heating-valve":{position:{kind:`gauge`,unit:`%`,deadband:1}},humidifier:{currentHumidity:{kind:`gauge`,unit:`%`,deadband:.5},on:{kind:`boolean`}},"humidity-sensor":{humidity:{kind:`gauge`,unit:`%`,deadband:.5}},"lawn-mower-control":{batteryLevel:{kind:`gauge`,unit:`%`,deadband:2}},"lock-control":{state:{kind:`enum`,values:[`locked`,`unlocked`,`locking`,`unlocking`,`jammed`,`door-open`]}},"media-player":{volumeLevel:{kind:`gauge`,unit:`%`,deadband:1},isMuted:{kind:`boolean`}},meter:{value:{kind:`counter`,deadband:.001,minIntervalMs:6e4}},motion:{detected:{kind:`boolean`,excludeDeviceTypes:[T.Camera]}},"network-link":{signal:{kind:`gauge`,unit:`%`,deadband:3,minIntervalMs:6e4},rssi:{kind:`gauge`,unit:`dBm`,deadband:2,minIntervalMs:6e4}},"numeric-sensor":{value:{kind:`gauge`,minIntervalMs:3e4}},"pet-feeder":{feeding:{kind:`boolean`},eating:{kind:`boolean`},foodLevel:{kind:`gauge`},bowlFood:{kind:`gauge`},food1:{kind:`gauge`},food2:{kind:`gauge`},batteryPower:{kind:`gauge`,unit:`%`,deadband:2},desiccantLeftDays:{kind:`gauge`,unit:`s`}},"pet-fountain":{waterLevel:{kind:`gauge`,unit:`%`,deadband:1},waterVolume:{kind:`gauge`,unit:`L`}},"power-meter":{power:{kind:`gauge`,unit:`W`,deadband:1,minIntervalMs:3e4},energy:{kind:`counter`,unit:`kWh`,deadband:.01,minIntervalMs:6e4},voltage:{kind:`gauge`,unit:`V`,deadband:1,minIntervalMs:3e4},current:{kind:`gauge`,unit:`A`,deadband:.05,minIntervalMs:3e4},apparentPower:{kind:`gauge`,unit:`VA`,deadband:1,minIntervalMs:3e4},powerFactor:{kind:`gauge`,unit:`ratio`,deadband:.01,minIntervalMs:6e4}},"pressure-sensor":{pressure:{kind:`gauge`,unit:`hPa`,deadband:.1}},"running-state":{running:{kind:`boolean`}},smoke:{detected:{kind:`boolean`}},"stream-params":{"main.bitrate":{group:`bitrate`,kind:`gauge`,unit:`kbps`},"main.framerate":{group:`framerate`,kind:`gauge`,unit:`fps`},"sub.bitrate":{group:`bitrate`,kind:`gauge`,unit:`kbps`},"sub.framerate":{group:`framerate`,kind:`gauge`,unit:`fps`}},switch:{on:{kind:`boolean`}},tamper:{tampered:{kind:`boolean`}},"temperature-sensor":{temperature:{kind:`gauge`,unit:`°C`,deadband:.1}},"vacuum-control":{batteryLevel:{kind:`gauge`,unit:`%`,deadband:2}},valve:{position:{kind:`gauge`,unit:`%`,minIntervalMs:0}},vibration:{detected:{kind:`boolean`}},"water-heater":{currentTemp:{group:`temperature`,kind:`gauge`,unit:`°C`,deadband:.5},targetTemp:{group:`temperature`,kind:`gauge`,unit:`°C`,minIntervalMs:0}},weather:{temperature:{kind:`gauge`,unit:`°C`,deadband:.2},humidity:{kind:`gauge`,unit:`%`,deadband:1},pressure:{kind:`gauge`,unit:`hPa`,deadband:.5},windSpeed:{kind:`gauge`,unit:`m/s`,deadband:.5}},"weather-station":{temperature:{group:`temperature`,kind:`gauge`,unit:`°C`,deadband:.1},humidity:{kind:`gauge`,unit:`%`,deadband:1},pressure:{kind:`gauge`,unit:`hPa`,deadband:.2},windSpeed:{group:`wind-speed`,kind:`gauge`,unit:`m/s`,deadband:.2},windGust:{group:`wind-speed`,kind:`gauge`,unit:`m/s`,deadband:.2},windBearing:{group:`wind-bearing`,kind:`gauge`,unit:`°`,deadband:5},rainRate:{kind:`gauge`,unit:`mm/h`,deadband:.1},rainDaily:{kind:`gauge`,unit:`mm`,deadband:.1},rainEvent:{kind:`gauge`,unit:`mm`,deadband:.1},uv:{kind:`gauge`,unit:`index`,deadband:.1},solarRadiation:{kind:`gauge`,unit:`W/m²`,deadband:5},dewPoint:{group:`temperature`,kind:`gauge`,unit:`°C`,deadband:.1},feelsLike:{group:`temperature`,kind:`gauge`,unit:`°C`,deadband:.1},vpd:{kind:`gauge`,unit:`kPa`,deadband:.05},windGustMax:{group:`wind-speed`,kind:`gauge`,unit:`m/s`,deadband:.2},windBearingAvg:{group:`wind-bearing`,kind:`gauge`,unit:`°`,deadband:5},rain24h:{kind:`gauge`,unit:`mm`,deadband:.1},rainWeekly:{kind:`gauge`,unit:`mm`,deadband:.1},rainMonthly:{kind:`gauge`,unit:`mm`,deadband:.1},rainYearly:{kind:`gauge`,unit:`mm`,deadband:.1}},workload:{state:{kind:`enum`,values:[`running`,`paused`,`stopped`,`starting`,`stopping`,`crashed`]},"resources.cpuPercent":{kind:`gauge`,unit:`%`,deadband:2,displayName:`CPU`},"resources.memoryUsedBytes":{kind:`gauge`,unit:`bytes`,displayName:`Memory used`},"resources.memoryPercent":{kind:`gauge`,unit:`%`,deadband:2,displayName:`Memory`},"resources.netRxKbps":{group:`network`,kind:`gauge`,unit:`kbps`,displayName:`Network received`},"resources.netTxKbps":{group:`network`,kind:`gauge`,unit:`kbps`,displayName:`Network sent`}}},Sbe={consumables:{path:`items`,key:`key`,label:`label`,fields:{level:{kind:`gauge`,unit:`%`,deadband:2,displayName:`Level`},status:{kind:`enum`,displayName:`Status`,values:[`ok`,`low`,`empty`,`full`,`replace`]},"remaining.value":{kind:`gauge`,deadband:1,displayName:`Remaining`}}},"heat-pump-status":{path:`circuits`,key:`id`,label:`label`,fields:{currentTemp:{kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Temperature`},targetTemp:{kind:`gauge`,unit:`°C`,minIntervalMs:0,displayName:`Setpoint`},mode:{kind:`enum`,displayName:`Mode`}}}},pO={"climate-control":{field:`currentTemp`,priority:70},"energy-system":{field:`house.powerW`,priority:50},"humidity-sensor":{field:`humidity`,priority:90},"power-meter":{field:`power`,priority:80},"temperature-sensor":{field:`temperature`,priority:100},"weather-station":{field:`temperature`,priority:60},workload:{field:`resources.cpuPercent`,priority:40}},Cbe=`audio-metrics.automation-control.camera-streams.color.control.day-night.doorbell.error.event-emitter.feature-probe.group-active.group-commands.group-status.image.image-settings.intercom.ir-transmitter.low-power-sleep.motion-trigger.motion-zones.native-object-detection.navigation.notifier.power-source.presence.privacy-mask.ptz-autotrack.pump-cycle.recording-onboard.recording-signal.scene-monitor.script-runner.siren.stream-catalog.stream-signals.timed-run.update.zone-analytics.zone-rules.zones`.split(`.`);function mO(e){return fO[e]??{}}function wbe(e,t,n){return hO(e.deviceTypes,t,n)}function hO(e,t,n){return e.length===0||e.some(e=>e===t)?!0:Jo(t,n)&&e.includes(T.Light)}function Tbe(e){let t=e.family===`numeric`?`number`:e.activeWhen===void 0?`boolean`:`state`;return{fieldChoice:e.family===`numeric`?`first-match`:`operator`,purpose:`member`,multiple:!0,max:64,deviceTypes:[...e.memberDeviceTypes],accept:e.accept.map(e=>({...e,valueKind:t})),history:{required:!1,minRetentionMs:null},mustBindCaps:e.family===`actuator`?e.accept.map(e=>e.cap):[],exclude:[]}}function gO(e){return{fieldChoice:`operator`,purpose:`historised`,multiple:!1,max:1,deviceTypes:[],accept:_O(e),history:{required:!0,minRetentionMs:null},mustBindCaps:[],exclude:[]}}function _O(e){let t=[];for(let n of Object.keys(fO))for(let[r,i]of Object.entries(mO(n)))i.kind!==`enum`&&(e===`integral`&&i.kind!==`gauge`||t.push({cap:n,fieldPath:r,valueKind:i.kind===`boolean`?`boolean`:`number`}));return t}function Ebe(e){if(e===`derivative`)return{...gO(`statistic`),accept:vO()};let t=e===`sum`||e===`expression`,n=e===`difference`||e===`ratio`?2:t?64:1;return{fieldChoice:`operator`,purpose:`reading`,multiple:t||n>1,max:n,deviceTypes:[],accept:vO(),history:{required:!1,minRetentionMs:null},mustBindCaps:[],exclude:[]}}function vO(){return _O(`statistic`).filter(e=>e.valueKind===`number`)}var yO=[`switch`,`brightness`,`color`],Dbe=[E.LightColorRgb,E.LightColorHsv,E.LightColorMired],Obe=4;function bO(e){return e===`all`?`all`:`any`}function kbe(e){return e===`all`?`all`:`at-least-one`}function Abe(e){return e.length===0?[]:yO.filter(t=>e.every(e=>e.includes(t)))}function jbe(e){return e.length===0?[]:Dbe.filter(t=>e.every(e=>e.includes(t)))}function Mbe(e,t,n,r){return e.flatMap(e=>e.caps.includes(t)?[{deviceId:e.deviceId,cap:t,method:n,args:{...r}}]:[])}async function Nbe(e,t){let n=[],r=0,i=async()=>{for(;;){let i=r;r+=1;let a=e[i];if(a===void 0)return;try{await t(a),n[i]={deviceId:a.deviceId,ok:!0}}catch(e){let t=e instanceof Error?e.message:String(e);n[i]={deviceId:a.deviceId,ok:!1,error:t}}}},a=Math.min(4,e.length);return await Promise.all(Array.from({length:a},()=>i())),n}var Pbe={kind:`expression`,expr:`now`,bindings:{}};function xO(e,t,n){return{kind:`series`,read:{source:e.source,cap:e.cap,fieldPath:e.fieldPath},publish:t,empty:n}}function Fbe(e){return{included:xO(e,`included`,`offline`),excluded:xO(e,`excluded`,`offline`),total:xO(e,`total`,`offline`)}}var Ibe={second:`s`,minute:`min`,hour:`h`};function Lbe(e){let t=mO(e.source.cap)[e.source.fieldPath]?.unit;return t===void 0?null:`${t}/${Ibe[e.per]}`}function SO(e){let t=mO(e.cap)[e.fieldPath];return t===void 0?null:t.kind}function CO(e){return SO(e)===null?[V(`member-constraint`,`helper.source`,`${e.cap}.${e.fieldPath} has no history declaration`)]:[]}function wO(e){return{target:{kind:`new`,type:T.Sensor,role:e.role},helper:e.spec,features:[{kind:`fields`,cap:e.cap,fields:{[e.field]:xO(e.member,`value`,e.empty),lastFetchedAt:Pbe}},{kind:`fields`,cap:`group-status`,fields:Fbe(e.member)}]}}function TO(e,t=ic){let n=[...CO(e.source)],r=SO(e.source);r===`enum`&&n.push(V(`kind-mismatch`,`helper.source`,`a statistic reads a number or a boolean, not a state`)),e.stat===`sum`&&r!==`counter`&&n.push(V(`kind-mismatch`,`helper.stat`,`a gauge has no sum — that is the integral template`));let i=bc(e.window,t);return i.ok||n.push(V(`retention`,`helper.window`,i.reason)),{problems:n,draft:wO({role:D.NumericSensor,cap:`numeric-sensor`,field:`value`,empty:`null`,spec:e,member:e.source})}}function EO(e,t=ic){let n=[...CO(e.source)],r=SO(e.source);(r===`enum`||r===`boolean`)&&n.push(V(`kind-mismatch`,`helper.source`,`a derivative reads a number that moves, not a yes/no or a state`));let i=bc(e.window,t);return i.ok||n.push(V(`retention`,`helper.window`,i.reason)),{problems:n,draft:wO({role:D.NumericSensor,cap:`numeric-sensor`,field:`value`,empty:`null`,spec:e,member:e.source})}}function DO(e,t=ic){let n=[...CO(e.source)],r=SO(e.source),i=e.source.cap===`power-meter`&&e.source.fieldPath===`power`;(r===`counter`||r===`boolean`||r===`enum`)&&n.push(V(`kind-mismatch`,`helper.source`,`an integral reads an instantaneous gauge, not a counter or a state`)),e.output===`energy`&&!i&&n.push(V(`kind-mismatch`,`helper.output`,`energy is the integral of power-meter.power; another reading uses the meter`)),e.output===`meter`&&i&&n.push(V(`kind-mismatch`,`helper.output`,`power integrates to power-meter.energy, which energy dashboards already read`));let a=xc(e.reset,t);a.ok||n.push(V(`retention`,`helper.reset`,a.reason));let o=e.output===`energy`;return{problems:n,draft:wO({role:o?D.EnergySensor:D.NumericSensor,cap:o?`power-meter`:`meter`,field:o?`energy`:`value`,empty:`offline`,spec:e,member:e.source})}}var Rbe=/^\d+(?:\.\d+)?$/,zbe=/^-?\d+(?:\.\d+)?$/,Bbe=/^dwell\(x (>=|<=) (\d+(?:\.\d+)?), (\d+(?:\.\d+)?), (\d+(?:\.\d+)?)(?:, (\d+))?\)$/,Vbe=/^clamp\((x|number\(x\)) \* (-?\d+(?:\.\d+)?) \+ (-?\d+(?:\.\d+)?), (-?\d+(?:\.\d+)?), (-?\d+(?:\.\d+)?)\)$/,Hbe=/^(x|number\(x\)) \* (-?\d+(?:\.\d+)?) \+ (-?\d+(?:\.\d+)?)$/,Ube=/^[A-Za-z_][A-Za-z0-9_]*$/;function OO(e){return RO(e,Rbe)}function kO(e){return RO(e,zbe)}function AO(e){return typeof e==`string`?JSON.stringify(e):typeof e==`number`?kO(e):typeof e==`boolean`?e?`true`:`false`:`null`}function jO(e,t){let n=t.map(e=>`native == ${JSON.stringify(e)}`).join(` || `),r=`(x ? ${JSON.stringify(e)} : native)`;return n===``?r.slice(1,-1):`${n} ? native : ${r}`}function MO(e){return Ube.test(e)}function NO(e,t,n,r,i=1){return`dwell(x ${e===`gte`?`>=`:`<=`} ${t}, ${n}, ${r}${i>1?`, ${i}`:``})`}function PO(e,t,n,r,i){let a=`${e} * ${t} + ${n}`;return r===null||i===null?a:`clamp(${a}, ${r}, ${i})`}function FO(e){let t=Bbe.exec(e);if(t===null)return null;let n=Number(t[2]),r=Number(t[3]),i=Number(t[4]);if(!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(i))return null;let a=t[1]===`<=`?`lte`:`gte`,o=t[5]===void 0?1:Number(t[5]);return!Number.isInteger(o)||o<1?null:{comparison:a,threshold:n,startDwellMs:r,stopDwellMs:i,minSamples:o}}function IO(e){let t=Vbe.exec(e);if(t!==null)return zO(t[1],t[2],t[3],t[4],t[5]);let n=Hbe.exec(e);return n===null?null:zO(n[1],n[2],n[3],void 0,void 0)}function LO(e){if(e.kind===`from`)return{cap:e.cap,fieldPath:e.fieldPath,addonId:e.source.addonId,stableId:e.source.stableId};if(e.kind!==`expression`||Object.keys(e.bindings).length!==1)return null;let t=e.bindings.x;return t===void 0||t.kind!==`from`?null:{cap:t.cap,fieldPath:t.fieldPath,addonId:t.source.addonId,stableId:t.source.stableId}}function RO(e,t){if(!Number.isFinite(e))return null;let n=Object.is(e,-0)?`0`:String(e);return t.test(n)?n:null}function zO(e,t,n,r,i){if(e!==`x`&&e!==`number(x)`||t===void 0||n===void 0)return null;let a=Number(t),o=Number(n);if(!Number.isFinite(a)||!Number.isFinite(o))return null;if(r===void 0||i===void 0)return{inner:e,scale:a,offset:o};let s=Number(r),c=Number(i);return!Number.isFinite(s)||!Number.isFinite(c)?null:{inner:e,scale:a,offset:o,clampMin:s,clampMax:c}}var BO={kind:`expression`,expr:`now`,bindings:{}};function VO(e){return{kind:`from`,source:e.source,cap:e.cap,fieldPath:e.fieldPath}}function HO(e,t){return{kind:`expression`,expr:e,bindings:t}}function Wbe(e,t){return e.source.addonId===t.source.addonId&&e.source.stableId===t.source.stableId&&e.cap===t.cap&&e.fieldPath===t.fieldPath}function UO(e,t,n=[]){return{target:{kind:`new`,type:T.Sensor,role:D.NumericSensor},helper:e,features:[{kind:`fields`,cap:`numeric-sensor`,fields:{value:t,lastFetchedAt:BO}},...n]}}function WO(e,t){return{target:{kind:`new`,type:T.Sensor,role:D.BinarySensor},helper:e,features:[{kind:`fields`,cap:`binary`,fields:{on:t,lastChangedAt:BO}}]}}function GO(e){let t=[],n=kO(e.high),r=kO(e.low);n===null&&t.push(V(`kind-mismatch`,`helper.high`,`the high edge is a finite number`)),r===null&&t.push(V(`kind-mismatch`,`helper.low`,`the low edge is a finite number`)),n!==null&&r!==null&&e.low>e.high&&t.push(V(`kind-mismatch`,`helper.low`,`the low edge (${e.low}) is above the high edge (${e.high}) — it turns on at the high edge and off at the low one`));let i=OO(e.onForMs),a=OO(e.offForMs);(i===null||a===null)&&t.push(V(`kind-mismatch`,`helper.onForMs`,`the on and off delays are a non-negative number of milliseconds`));let o=i!==null&&a!==null&&(e.onForMs>0||e.offForMs>0)?`, ${i}, ${a}`:``;return{problems:t,draft:WO(e,HO(`coalesce(schmitt(x, ${n??`0`}, ${r??`0`}${o}), false)`,{x:VO(e.source)}))}}var Gbe=[`a`,`b`];function Kbe(e){let t=[],n=e.op!==`sum`;return n&&e.inputs.length!==2&&t.push(V(`member-constraint`,`helper.inputs`,`a ${e.op} takes exactly two readings, the first ${e.op===`ratio`?`over`:`minus`} the second`)),!n&&e.inputs.length<2&&t.push(V(`member-constraint`,`helper.inputs`,`a sum takes two or more readings`)),e.inputs.forEach((n,r)=>{e.inputs.slice(0,r).some(e=>Wbe(e,n))&&t.push(V(`member-constraint`,`helper.inputs[${r}]`,`this reading is already an input`))}),t}var qbe=[`included`,`excluded`,`total`];function KO(e){let t=Kbe(e);if(e.op===`sum`){let n=e.inputs.map(e=>({source:e.source,cap:e.cap,fieldPath:e.fieldPath})),r=e=>({kind:`aggregate`,reducer:`sum`,reads:n,publish:e,empty:`null`}),i=Object.fromEntries(qbe.map(e=>[e,r(e)]));return{problems:t,draft:UO(e,r(`value`),[{kind:`fields`,cap:`group-status`,fields:i}])}}let n=Object.fromEntries(e.inputs.slice(0,2).map((e,t)=>[Gbe[t]??`a`,VO(e)]));return{problems:t,draft:UO(e,HO(e.op===`difference`?`a - b`:`b == 0 ? null : a / b`,n))}}function Jbe(e){let t=[],n=new Set;if(e.inputs.forEach((e,r)=>{let i=`helper.inputs[${r}].name`;MO(e.name)||t.push(V(`expression-invalid`,i,`\`${e.name}\` is not a name — use letters, digits and _, starting with a letter`)),n.has(e.name)&&t.push(V(`expression-invalid`,i,`the name \`${e.name}\` is used twice`)),n.add(e.name)}),t.length>0)return t;let r=Object.fromEntries(e.inputs.map(e=>[e.name,VO(e.member)])),i=Ls({expr:e.expr,bindings:r});return i===null?[]:[V(`expression-invalid`,`helper.expr`,i)]}function qO(e){let t=Jbe(e),n=Object.fromEntries(e.inputs.map(e=>[e.name,VO(e.member)])),r=HO(e.expr,n);return{problems:t,draft:e.output===`boolean`?WO(e,r):UO(e,r)}}function Ybe(e,t){return e.addonId===t.addonId&&e.stableId===t.stableId}function Xbe(e,t){return Ybe(e.source,t.source)&&e.cap===t.cap&&e.fieldPath===t.fieldPath}function Zbe(e,t){return e.accept.some(e=>e.cap===t.cap&&e.fieldPath===t.fieldPath)}function Qbe(e,t){return t.members.flatMap((n,r)=>{let i=`helper.members[${r}]`,a=[];if(!Zbe(e,n)){let t=e.accept.map(e=>`${e.cap}.${e.fieldPath}`).join(` or `);a.push(V(`member-constraint`,i,`a ${e.id} group reads ${t}; this member is ${n.cap}.${n.fieldPath}`))}return t.members.slice(0,r).some(e=>Xbe(e,n))&&a.push(V(`member-constraint`,i,`this member is already in the group`)),a})}function JO(e,t,n,r){return{kind:`aggregate`,reducer:t.aggregate,reads:[...n],publish:r,empty:e.empty,...e.activeWhen===void 0?{}:{activeWhen:[...e.activeWhen]}}}function $be(e,t){let n=t.members.map(e=>({source:e.source,cap:e.cap,fieldPath:e.fieldPath})),r=Object.fromEntries(e.companions.map(e=>[e.fieldPath,txe(e.expr)]));return{target:{kind:`new`,type:e.deviceType,...e.role===void 0?{}:{role:e.role}},helper:t,features:[{kind:`fields`,cap:e.outputCap,fields:{[e.outputField]:JO(e,t,n,`value`),...r}},{kind:`fields`,cap:`group-status`,fields:{included:JO(e,t,n,`included`),excluded:JO(e,t,n,`excluded`),total:JO(e,t,n,`total`)}}]}}function exe(e,t){if(e.family===`actuator`){if(t.active===void 0)return[V(`kind-mismatch`,`helper.active`,`a ${e.id} group needs an active criterion (at-least-one or all)`)];let n=bO(t.active);return t.aggregate===n?[]:[V(`kind-mismatch`,`helper.aggregate`,`active \`${t.active}\` aggregates by \`${n}\`, not \`${t.aggregate}\``)]}return t.active===void 0?[]:[V(`kind-mismatch`,`helper.active`,`a ${e.id} group has no active criterion — that belongs to an actuator group`)]}function YO(e){let t=El.safeParse(e);return t.success?{ok:!0,composition:t.data}:{ok:!1,problems:[V(`helper-mismatch`,`helper`,`the template did not compile: ${t.error.issues.map(e=>e.message).join(`; `)}`)]}}function txe(e,t={}){return{kind:`expression`,expr:e,bindings:t}}function XO(e,t=ic){switch(e.kind){case`group`:return rxe(e);case`statistic`:{let n=TO(e,t);return n.problems.length>0?{ok:!1,problems:n.problems}:YO(n.draft)}case`integral`:{let n=DO(e,t);return n.problems.length>0?{ok:!1,problems:n.problems}:YO(n.draft)}case`derivative`:{let n=EO(e,t);return n.problems.length>0?{ok:!1,problems:n.problems}:YO(n.draft)}case`threshold`:return ZO(GO(e));case`arithmetic`:return ZO(KO(e));case`expression`:return ZO(qO(e));case`grid`:case`terminal`:return YO(nxe(e))}}function nxe(e){return{target:{kind:`new`,type:T.Camera},helper:e,features:[]}}function ZO(e){return e.problems.length>0?{ok:!1,problems:e.problems}:YO(e.draft)}function rxe(e){let t=dO(e.templateId);if(t===null)return{ok:!1,problems:[V(`member-constraint`,`helper.templateId`,`unknown template \`${e.templateId}\``)]};let n=exe(t,e);if(n.length>0)return{ok:!1,problems:n};if(!t.aggregates.includes(e.aggregate)){let n=t.aggregates.join(`, `);return{ok:!1,problems:[V(`kind-mismatch`,`helper.aggregate`,`a ${t.id} group aggregates by ${n}, not \`${e.aggregate}\``)]}}let r=Qbe(t,e);return r.length>0?{ok:!1,problems:r}:YO($be(t,e))}function QO(e,t){return JSON.stringify(e.target)===JSON.stringify(t.target)&&JSON.stringify(e.features)===JSON.stringify(t.features)}function ixe(e){return e.kind===`group`?dO(e.templateId)?.memberDeviceType??null:null}function axe(e,t){if(e.kind!==`group`)return[];let n=dO(e.templateId);if(n===null||n.family!==`numeric`)return[];let r=e.members.flatMap((e,n)=>{let r=t.get(Dl(e.source))?.quantity;return r===void 0?[]:[{index:n,quantity:r}]});if(n.quantity!==`device`)return r.flatMap(e=>e.quantity===n.quantity?[]:[V(`mixed-quantity`,`helper.members[${e.index}]`,`a ${n.id} group is ${n.quantity}${n.baseUnit===void 0?``:` (${n.baseUnit})`}; this member is ${e.quantity}`)]);let i=[...new Set(r.map(e=>e.quantity))];return i.length<=1?[]:[V(`mixed-quantity`,`helper.members`,`a numeric group requires one quantity; members report ${i.join(` and `)}`)]}function oxe(e,t){if(e.kind!==`group`)return[];let n=dO(e.templateId);return n===null?[]:e.members.flatMap((e,r)=>{let i=t.get(Dl(e.source)),a=i?.deviceType;return a===void 0||hO(n.memberDeviceTypes,a,i?.role)?[]:[V(`member-constraint`,`helper.members[${r}]`,`a ${n.id} group takes ${n.memberDeviceTypes.join(` or `)} devices; this member is a ${a}`)]})}function $O(e,t){let n=e.helper;if(n===void 0)return[];let r=XO(n);return r.ok?QO(e,r.composition)?n.kind===`arithmetic`?sxe(n,t):n.kind===`group`?[...axe(n,t),...oxe(n,t)]:[]:[V(`helper-mismatch`,`helper`,`the stored features are not this template — the helper spec is the only writer`)]:r.problems}function sxe(e,t){let n=e.inputs.flatMap(e=>{let n=t.get(Dl(e.source))?.quantity;return n===void 0?[]:[n]}),r=[...new Set(n)];return r.length<=1?[]:[V(`mixed-quantity`,`helper.inputs`,`a ${e.op} needs readings of one quantity; these inputs report ${r.join(` and `)}`)]}var ek=class extends Error{};function cxe(e){return new Set(e.composition.features.flatMap(e=>!xl(e)||e.kind!==`fields`?[]:Pl(e).map(({fieldPath:t})=>`${e.cap}.${t}`)))}function lxe(e,t,n){if(Dl(n.source)!==Dl(e.target))return!0;let r=`${n.cap}.${n.fieldPath}`;return t.has(r)&&e.replaced?.has(r)!==!0}function uxe(e){let t=cxe(e);return e.composition.features.flatMap(n=>!xl(n)||n.kind!==`fields`?[]:Pl(n).map(({fieldPath:r,source:i})=>[kl({source:e.target,cap:n.cap,fieldPath:r}),Ml(i).filter(n=>lxe(e,t,n)).map(kl)]))}function dxe(e,t){let n=Dl(e.target),r=new Map;for(let i of t){if(i.blockId===e.blockId)continue;let t=Dl(i.target);if(t===n)throw new ek(`block \`${i.blockId}\` and block \`${e.blockId}\` both target device \`${t}\` — one composition per device; delete or edit the existing one`);let a=r.get(t);if(a!==void 0)throw new ek(`two stored compositions (\`${a.blockId}\`, \`${i.blockId}\`) both target device \`${t}\` — refusing to build the field graph`);r.set(t,i)}return[...r.values(),e]}function tk(e,t){let n=dxe(e,t).flatMap(uxe);return new Map(n)}function fxe(e,t){let n=tk(e,t),r=new Map,i=new Map,a=(e,t)=>{let o=r.get(e);if(o!==`done`){if(o===`visiting`){let n=[...t.slice(t.indexOf(e)),e],r=[...new Set(n)].toSorted().join(`|`);i.has(r)||i.set(r,{path:n});return}r.set(e,`visiting`);for(let r of n.get(e)??[])a(r,[...t,e]);r.set(e,`done`)}};for(let e of n.keys())a(e,[]);return[...i.values()]}function pxe(e){let t=new Map,n=new Map,r=new Set,i=[],a=[],o=s=>{t.set(s,t.size),n.set(s,t.get(s)??0),i.push(s),r.add(s);for(let i of e.get(s)??[])t.has(i)?r.has(i)&&n.set(s,Math.min(n.get(s)??0,t.get(i)??0)):(o(i),n.set(s,Math.min(n.get(s)??0,n.get(i)??0)));if(n.get(s)!==t.get(s))return;let c=[];for(let e=i.pop();e!==void 0&&(r.delete(e),c.push(e),e!==s);e=i.pop());a.push(c)};for(let n of e.keys())t.has(n)||o(n);return a}function mxe(e,t,n){let r=new Map,i=[e];for(let a=0;a<i.length;a+=1){let o=i[a];if(o===void 0)break;for(let a of n.get(o)??[]){if(a===e){let t=[];for(let n=o;n!==void 0&&n!==e;n=r.get(n))t.push(n);return[e,...t.reverse(),e]}!t.has(a)||r.has(a)||(r.set(a,o),i.push(a))}}return[e,e]}function nk(e,t){let n=tk(e,t),r=`${Dl(e.target)}#`;return pxe(n).flatMap(e=>{let t=e.find(e=>e.startsWith(r));if(t===void 0)return[];let i=new Set(e),a=e.length===1&&(n.get(t)??[]).includes(t);return e.length===1&&!a?[]:[{path:mxe(t,i,n),component:i}]})}var hxe=3,gxe=120,_xe=10,rk=x([`no-power-source`,`switch-missing`,`switch-offline`,`switch-unknown`,`restart-in-progress`,`switch-call-failed`,`switch-options-unreadable`,`not-settable`,`switch-is-actuator`,`link-lost`,`link-unknown`]),ik=i(`accepted`,[b({accepted:p(!0)}),b({accepted:p(!1),reason:rk,message:l()})]),ak=b({linked:v(),switchDeviceId:n().nullable(),switchName:l().nullable(),switchOn:v().nullable(),switchOnline:v().nullable(),switchSettable:v().nullable().optional(),restartInProgress:v(),offSeconds:n().int()}),ok=b({switchOn:v().nullable(),offSeconds:n().int(),lastFetchedAt:n()}),sk=[T.Gateway,T.Camera,T.Sensor,T.MediaPlayer,T.Vacuum,T.Generic,T.Washer,T.Dryer,T.Dishwasher,T.PetFountain,T.Fan,T.Humidifier,T.Climate,T.WaterHeater],vxe={version:1,targets:[{id:`switch`,cardinality:`scalar`,vocabulary:{cap:`power-source`,stateField:`switchOn`},deviceTypes:sk,apply:`add`,path:`switchOn`,sources:[{kind:`switch`,transforms:[{kind:`identity`}]}],companions:[{kind:`constant`,path:`offSeconds`,value:10,when:`add`,formerValues:[0]},{kind:`clock`,path:`lastFetchedAt`,when:`always`}],sourceReport:{status:`assignment-status`}}]},ck=b({deviceId:n().int().nonnegative()}),lk={method:`getStatus`,field:`switchSettable`},uk={name:`power-source`,scope:`device`,mode:`singleton`,deviceTypes:sk,methods:{getStatus:ii(ck,ak,{auth:`protected`}),powerOn:ii(ck,ik,{kind:`mutation`,auth:`protected`,actions:[{id:`powerSource.on`,label:P(`Power on`,`Dai corrente`),phrase:P(`Power on {device}`,`Dai corrente a {device}`),icon:`power`,offeredWhen:lk}]}),powerOff:ii(ck,ik,{kind:`mutation`,auth:`protected`,actions:[{id:`powerSource.off`,label:P(`Power off`,`Togli corrente`),phrase:P(`Cut the power of {device}`,`Togli la corrente a {device}`),icon:`power-off`,offeredWhen:lk}]}),forceRestart:ii(ck,ik,{kind:`mutation`,auth:`protected`,actions:[{id:`powerSource.forceRestart`,label:P(`Force restart`,`Riavvio forzato`),phrase:P(`Force restart {device} by cutting its power`,`Riavvia {device} togliendo la corrente`),icon:`refresh-cw`}]})},runtimeState:ok,customize:vxe,durability:`session`,history:`none`,vocabulary:{noun:P(`Power source`,`Alimentazione`),order:1050,state:[{kind:`boolean`,field:`switchOn`,label:P(`Power switch on`,`Presa accesa`),whenTrue:P(`When the power of {device} comes on`,`Quando arriva la corrente a {device}`),whenFalse:P(`When the power of {device} is cut`,`Quando manca la corrente a {device}`),icon:`power`}]}};function dk(e){return typeof e!=`number`||!Number.isFinite(e)?10:Math.min(120,Math.max(3,Math.round(e)))}function yxe(e){let t=e.features.find(e=>e.cap===`power-source`);if(t===void 0||t.kind!==`fields`)return;let n=t.fields.offSeconds;if(n===void 0||n.kind!==`expression`)return;let r=Number(n.expr);return n.expr.trim()===``||!Number.isFinite(r)?void 0:r}function bxe(e,t){if(e===null)return null;let n;if(e.target.kind===`existing`)n=e.target.device;else if(t!==void 0)n=jl(t);else return null;let r=e.features.find(e=>e.cap===`power-source`);if(r===void 0||r.kind!==`fields`||r.enabled===!1)return null;let i=r.fields.switchOn;if(i===void 0)return null;let a=Ml(i).find(e=>e.cap===`switch`);return a===void 0?null:{device:n,switch:a.source,offSeconds:dk(yxe(e)),...r.contributedBy===void 0?{}:{contributedBy:r.contributedBy}}}var fk=`switch`;function xxe(e){let t=new Set;return e.target.kind===`existing`&&t.add(Dl(e.target.device)),e.features.forEach((e,n)=>{if(!(e.kind!==`fields`||e.cap!==fk)&&xl(e)){for(let n of Fl(e))for(let e of Ml(n))t.add(Dl(e.source));for(let r of JD(e,n))t.add(Dl(r.command.source))}}),t}function pk(e){let t=e.features.findIndex(e=>e.cap===`power-source`),n=e.features[t];if(n===void 0||n.kind!==`fields`||n.enabled===!1)return[];let r=n.fields.switchOn;if(r===void 0)return[];let i=xxe(e);return Ml(r).filter(e=>e.cap===fk&&i.has(Dl(e.source))).map(e=>({path:`features[${t}].fields.switchOn`,switch:e.source}))}function mk(e){let t=new Map(e.map(e=>[e.name,e]));return e=>t.get(e)??null}var hk=new Set([`device-status`,`feature-probe`]),Sxe={addonId:Xc,stableId:`${Ee}(unsaved)`},Cxe=`(unsaved)`;function wxe(e,t,n){let r=n(e.cap);if(r===null)return V(`unknown-capability`,`${t}.cap`,`no capability is named \`${e.cap}\``);if(hk.has(r.name))return V(`not-composable`,`${t}.cap`,`\`${r.name}\` is registered by every device itself — it cannot be composed`);let i=r.runtimeState;return r.scope!==`device`||i===void 0?V(`not-composable`,`${t}.cap`,`\`${r.name}\` has no per-device state to compose`):{def:r,state:i,fields:RT(i)}}function Txe(e){let t=e.helper;if(t===void 0||t.kind!==`group`)return new Set;let n=dO(t.templateId);return n===null||n.family!==`actuator`?new Set:new Set(n.commandCaps)}function Exe(e,t){return e.name===bD.name&&Object.values(t.commands??{}).some(e=>e.kind===`extension`)}function Dxe({def:e,state:t,fields:n},r,i,a,o){let s=[];e.deviceTypes!==void 0&&!e.deviceTypes.includes(a)&&s.push(V(`wrong-device-type`,`${i}.cap`,`\`${e.name}\` is not offered on a \`${a}\` device (it allows ${e.deviceTypes.join(`, `)})`));let c=new Set(Object.entries(r.commands??{}).flatMap(([e,t])=>t.kind===`forward`||t.kind===`extension`?[e]:[])),l=XD(e).filter(e=>!c.has(e)).map(e=>`\`${e}\``);l.length>0&&!o.has(e.name)&&s.push(V(`has-commands`,`${i}.cap`,`\`${e.name}\` has ${l.join(`, `)} with no command — a composed device serves a method only through a \`forward\` (D967)`));let u=r.items===void 0?null:e.status?.itemArray?.path??null,d=Exe(e,r);for(let a of d?[]:zT(t))a!==u&&(n.has(a)?a in r.fields||s.push(V(`missing-field`,`${i}.fields.${a}`,`\`${e.name}.${a}\` is required and has no source`)):s.push(V(`not-composable`,`${i}.fields`,`\`${e.name}.${a}\` is not a scalar — nested fields arrive in a later slice`)));return s}function Oxe({fields:e,state:t},n,r){return n.includes(`.`)?r===`replace`?LT(t,n)??void 0:`nested`:e.get(n)}function kxe(e,t,n,r){let{def:i}=e,{featureIndex:a,path:o,source:s}=t,c=`features[${a}].fields.${o}`,l=Oxe(e,o,n);if(l===`nested`)return CD(V(`nested-field`,c,`\`${o}\` is nested — a nested field is planned only on a declared replace (D1034)`));if(l===void 0)return CD(V(`unknown-field`,c,`\`${i.name}\` has no field \`${o}\``));if(l.kind===`union`)return CD(LD(i.name,o,c));let u=BD(s,r);if(!u.ok)return CD(V(u.code,c,u.message));let d=UD(s),f=WD(l,d,n,i.name,c);if(!f.ok)return CD(f.problem);let p=s.kind===`aggregate`&&s.publish===`value`&&s.empty===`omit`,m={cap:i.name,path:o,featureIndex:a,kind:l.kind,nullable:l.nullable,required:l.required,unavailable:p?`omit`:f.unavailable,role:d,source:s,reads:[...Ml(s)]},h=HD(i.name,l,s,c);return{problems:[...VD(i.name,l,zD(s,l,u.kinds,r),c),...h===null?[]:[h]],fields:[m],features:[],events:[]}}function Axe(e,t,n,r,i){let a=`features[${n}]`,o=JD(t,n),s=Object.entries(t.commands??{}).filter(([,e])=>e.kind===`code`).map(([e])=>V(`reserved-variant`,`${a}.commands.${e}`,"a `code` command arrives in slice 4")),c=Object.entries(t.commands??{}).filter(([,e])=>e.kind===`extension`);return c.length>0&&e.name!==bD.name?[...s,...c.map(([t])=>V(`command-method-unknown`,`${a}.commands.${t}`,`the \`remote\` extension serves a \`media-player\` only, not \`${e.name}\``))]:(o.length>0||c.length>0)&&r!==`new`?[...s,V(`reserved-variant`,`${a}.commands`,"commands (`forward`) are served only by a capability a NEW device builds — not on an existing device")]:[...s,...nO(e,t,a),...o.flatMap(t=>tO(e,t,i))]}function gk(e,t,n,r,i){let a=`features[${t}]`,o=wxe(e,a,r);if(`code`in o)return CD(o);let s=n.mode===`replace`?[]:[...Dxe(o,e,a,n.deviceType,i)];s.push(...Axe(o.def,e,t,n.mode,r));let c=Object.entries(e.fields).map(([e,i])=>kxe(o,{featureIndex:t,path:e,source:i},n.mode,r)),l=e.items===void 0?[]:[KD(o.def,e,t,r,n.mode)],u=[...c,...l],d=u.flatMap(e=>e.fields),f={featureIndex:t,cap:o.def.name,mode:n.mode},p=WT(o.def,f,d);return{problems:[...s,...u.flatMap(e=>e.problems),...p.problems],fields:d,features:[f],events:p.events}}function _k(e,t){let n=e.nativeCaps.get(t);return n!==void 0&&n!==`composer`}function jxe(e){return`code`in e}function Mxe(e,t){if(e.target.kind===`new`)return{kind:`new`,type:e.target.type};let n=Dl(e.target.device);return t===void 0?V(`target-unreadable`,`target`,`target device \`${n}\` was not read — the save is refused rather than stored unchecked`):t.kind===`absent`?V(`target-missing`,`target`,`target device \`${n}\` does not exist`):t.kind===`unreadable`?V(`target-unreadable`,`target`,`could not read target device \`${n}\` (${t.error}) — the save is refused rather than stored unchecked`):{kind:`existing`,found:t}}var Nxe=new Set([`not-composable`,`unknown-capability`,`reserved-variant`]);function Pxe(e,t){let n=t.problems.filter(e=>Nxe.has(e.code));return n.length>0?{problems:n,fields:[],features:[],events:[]}:CD(e)}var Fxe=xD;function Ixe(e){let t=Fxe[e.cap],n=new Set((t?.overridable??[]).flatMap(e=>{let n=(t?.targets.find(t=>t.id===e.by&&t.path===e.path)?.companions??[]).filter(e=>e.kind===`transition-time`||e.kind===`source-field`||e.when===`always`);return[e.path,...n.map(e=>e.path)]})),r=Object.keys(e.fields);return r.length>0&&r.every(e=>n.has(e))&&e.items===void 0&&e.commands===void 0}function Lxe(e,t,n){let r=t.cap;return e.kind===`new`?{mode:`new`,deviceType:e.type}:_k(e.found,r)?Ixe(t)?{mode:`replace`,deviceType:e.found.type}:V(`native-capability-replace`,n,`native-capability-replace: stored override replaces native capability \`${r}\` on device ${e.found.deviceId} — refused (D944)`):{mode:`add`,deviceType:e.found.type}}function vk(e,t,n){let r=Mxe(e,n);if(`code`in r)return CD(r);let i=Txe(e),a=e.features.map((e,n)=>{let a=`features[${n}]`;if(e.kind===`passthrough`)return CD(V(`reserved-variant`,a,`whole-capability passthrough of \`${e.cap}\` arrives in slice 3`));let o=Lxe(r,e,a);if(jxe(o))return!xl(e)||r.kind!==`existing`?{problems:[],fields:[],features:[],events:[]}:Pxe(o,gk(e,n,{mode:`add`,deviceType:r.found.type},t,i));let s=gk(e,n,o,t,i);return xl(e)?s:{problems:Object.keys(e.fields).length===0?s.problems.filter(e=>e.code!==`missing-field`):s.problems,fields:[],features:[],events:[]}});return{problems:a.flatMap(e=>e.problems),fields:a.flatMap(e=>e.fields),features:a.flatMap(e=>e.features),events:a.flatMap(e=>e.events)}}function Rxe(e){let t=e.features.flatMap(e=>xl(e)&&e.kind===`fields`?Fl(e).flatMap(Ml).map(e=>e.source):[]);return[...new Map([...t,...YD(e)].map(e=>[Dl(e),e])).values()]}function zxe(e,t){return e.features.flatMap(e=>xl(e)&&e.kind===`fields`?Fl(e).flatMap(e=>{if(e.kind!==`from`)return[];let n=t(e.cap),r=n?.runtimeState??n?.status?.schema;return r===void 0?[]:LT(r,e.fieldPath)?.kind===`union`?[e]:[]}):[])}function Bxe(e,t,n){return{ref:e.target.kind===`existing`?e.target.device:t.self??Sxe,native:e.target.kind===`existing`&&t.target?.kind===`found`?t.target:null,replaced:yk(n)}}function yk(e){let t=new Set(e.features.filter(e=>e.mode===`replace`).map(e=>e.featureIndex));return new Set(e.fields.filter(e=>t.has(e.featureIndex)).map(QT))}function Vxe(e,t,n,r){let i=`${e.cap}.${e.fieldPath}`;return n.some(e=>QT(e)===i&&!r.replaced.has(i))?[]:r.native===null?[V(`source-field-unknown`,t,`this device has no composed field \`${e.cap}.${e.fieldPath}\``)]:_k(r.native,e.cap)?[]:[V(`source-capability-missing`,t,`the target device (device ${r.native.deviceId}) has no native \`${e.cap}\``)]}function Hxe(e,t,n,r){if(e.source.kind!==`from`)return[];let i=n.liveKinds?.get(`${t.cap}.${t.fieldPath}`),a=e.kind===`enum`?`string`:e.kind;return i===void 0||i===a?[]:[V(`source-kind-mismatch`,r,`\`${t.cap}.${t.fieldPath}\` of device ${n.deviceId} reads a ${i} now; \`${e.cap}.${e.path}\` takes a ${a}`)]}function Uxe(e,t,n){let r=Dl(n.ref);return e.flatMap(i=>i.reads.flatMap(a=>{let o=wD(i),s=Dl(a.source);if(s===r)return Vxe(a,o,e,n);let c=t.sources.get(s);return c===void 0||c.kind===`unreadable`?[V(`source-unreadable`,o,`could not read source \`${s}\` (${c===void 0?`it was not read`:c.error}) — the save is refused rather than stored unchecked`)]:c.kind===`absent`?[V(`source-missing`,o,`source \`${s}\` does not exist`)]:c.caps.has(a.cap)?Hxe(i,a,c,o):[V(`source-capability-missing`,o,`source \`${s}\` (device ${c.deviceId}) has no \`${a.cap}\``)]}))}function Wxe(e,t){let n=`${t}#`;if(!e.startsWith(n))return null;let r=e.slice(n.length),i=r.indexOf(`.`);return i===-1?null:{cap:r.slice(0,i),fieldPath:r.slice(i+1)}}function Gxe(e,t,n){for(let r of e){let e=Wxe(r,t);if(e===null)continue;let i=`${e.cap}.${e.fieldPath}`,a=n.find(e=>QT(e)===i);if(a!==void 0)return wD(a)}return`features`}function Kxe(e,t){for(let[n,r]of t)if(e.some(e=>e.startsWith(`${n}#`)))return{key:n,error:r};return null}function qxe(e,t,n,r){let i={blockId:t.blockId??`(unsaved)`,target:r.ref,composition:e,replaced:r.replaced},a=Dl(i.target),o=t.unreadTargets??new Map;try{return nk(i,t.peers).map(e=>{let t=Gxe(e.path,a,n),r=Kxe([...e.component],o);return r===null?V(`cycle`,t,`a field reads itself: ${e.path.join(` → `)}`):V(`cycle`,t,`possible cycle through \`${r.key}\` — its state could not be read (${r.error}): ${e.path.join(` → `)}`)})}catch(e){if(e instanceof ek)return[V(`duplicate-target`,`features`,e.message)];throw e}}function bk(e,t){let n=vk(e,t.lookupCap,t.target??void 0),r=Bxe(e,t,n),i=n.problems.filter(e=>e.code===`native-capability-replace`).map(e=>e.path),a=qxe(e,t,n.fields,r).filter(e=>i.some(t=>e.path===t||e.path.startsWith(`${t}.`))?!1:i.length===0||e.path!==`features`),o=new Map([...t.sources].flatMap(([e,t])=>t.kind===`found`?[[e,{deviceType:t.deviceType,role:t.role,quantity:t.quantity}]]:[])),s=[...n.problems,...Uxe(n.fields,t,r),...rO(e,t.sources),...a,...$O(e,o),...pk(e).map(e=>V(`power-source-is-actuator`,e.path,`the power source \`${e.switch.stableId}\` is one of this device's own switches — pick the plug that feeds it`))];return{ok:s.length===0,problems:s,fields:[...n.fields],features:[...n.features],events:[...n.events]}}var xk=b({path:l(),kind:qT,nullable:v(),required:v(),enumValues:S(l()).optional()}),Sk=b({cap:l(),fields:S(xk),itemArray:b({path:l(),keyField:l()}).optional()}),Ck=b({caps:S(Sk)});function wk(e,t){if(hk.has(e.name))return[`not-composable`];let n=e.runtimeState;if(e.scope!==`device`||n===void 0)return[`not-composable`];let r=[];e.deviceTypes!==void 0&&!e.deviceTypes.includes(t)&&r.push(`wrong-device-type`),Object.entries(e.methods).filter(([t,n])=>n.systemOnly!==!0&&e.composedMethods?.[t]===void 0).length>0&&r.push(`has-commands`);let i=RT(n),a=e.status?.itemArray?.path??null;return zT(n).some(e=>e!==a&&!i.has(e))&&r.push(`not-composable`),WT(e,{featureIndex:0,cap:e.name,mode:`new`},[]).problems.some(e=>e.code===`not-composable`)&&!r.includes(`not-composable`)&&r.push(`not-composable`),r}function Jxe(e,t){return e.filter(e=>wk(e,t).length===0).map(e=>{let t=e.runtimeState,n=t===void 0?[]:[...RT(t).values()],r=e.status?.itemArray;return{cap:e.name,fields:n.flatMap(e=>e.kind===`union`?[]:[{path:e.path,kind:e.kind,nullable:e.nullable,required:e.required,...e.enumValues===void 0?{}:{enumValues:[...e.enumValues]}}]),...r===void 0?{}:{itemArray:{path:r.path,keyField:r.keyField}}}}).toSorted((e,t)=>e.cap.localeCompare(t.cap))}var Tk=b({addonId:l().min(1),stableId:l().min(1),cap:l().min(1),fieldPath:l().min(1)}),Yxe=b({kind:p(`identity`)}),Xxe=b({kind:p(`invert`)}),Ek=b({kind:p(`threshold`),comparison:x([`gte`,`lte`]),threshold:n(),startDwellMs:n().nonnegative(),stopDwellMs:n().nonnegative(),minSamples:n().int().min(1).optional()}),Dk=i(`kind`,[Yxe,Xxe,Ek,b({kind:p(`linear`),scale:n(),offset:n(),clampMin:n().optional(),clampMax:n().optional()}),b({kind:p(`enum-map`),mapping:m(l(),l().nullable())}),b({kind:p(`number`)})]),Zxe=b({kind:p(`scalar`),cap:l().min(1),targetId:l().min(1),source:Tk,transform:Dk}),Qxe=b({kind:p(`keyedArray`),cap:l().min(1),targetId:l().min(1),key:l().min(1),label:l().min(1),fieldPath:l().min(1),source:Tk,transform:Dk}),$xe=b({kind:p(`pulse`),cap:l().min(1),targetId:l().min(1),enabled:v(),debounceMs:n().nonnegative(),edges:S(x([`rising`,`button`,`native-event`])).min(1).optional(),sources:S(Tk).min(1)}),eSe=Tk.extend({mode:x([`in-addition`,`confirm`,`replace`]).optional()}),tSe=i(`kind`,[Zxe,Qxe,$xe,b({kind:p(`span`),cap:l().min(1),targetId:l().min(1),timeoutMs:n().nonnegative(),cooldownMs:n().nonnegative().optional(),sources:S(eSe)})]),nSe=b({targetId:l().min(1),configured:v(),source:x([`native`,`assigned`]),state:x([`active`,`stale`,`released`,`unavailable`]),reason:l().nullable()}),Ok=x([`raw`,`5m`]),kk=x([`high`,`medium`,`low`]),Ak=x([`no-history`,`span-too-short`,`truncated`,`no-idle-floor`,`no-runs`,`no-separation`]),jk=b({intervals:n().int().nonnegative(),extra:n().int().nonnegative(),missed:n().int().nonnegative()}),Mk=b({tier:Ok,spanMs:n().nonnegative(),from:n(),to:n(),points:n().int().nonnegative(),runsFound:n().int().nonnegative(),pausesFound:n().int().nonnegative(),longestPauseMs:n().nonnegative(),pulsesFound:n().int().nonnegative(),longestPulseMs:n().nonnegative(),idleFloorW:n(),noiseCeilingW:n(),plateauW:n(),replay:jk}),Nk=b({spanMs:n().nonnegative(),points:n().int().nonnegative(),runsFound:n().int().nonnegative()}),Pk=i(`state`,[b({state:p(`proposal`),transform:Ek,evidence:Mk,confidence:kk,notes:S(l())}),b({state:p(`insufficient`),reason:Ak,evidence:Nk,fallback:Ek})]),Fk=b({apply:v()}),Ik=b({apply:v(),rows:n().int(),raw:n().int(),markers:n().int(),migrated:n().int(),failed:n().int(),remainingRaw:n().int(),unresolvedMarkers:n().int(),redundantCopies:n().int().optional(),verified:v()}),Lk=`core-block-`,Rk=`core-blocks`;function rSe(e){return`${Lk}${e}`}function iSe(e){if(!e.startsWith(`core-block-`))return null;let t=e.slice(11);return t.length>0?t:null}var zk=h([p(`hub`),l().min(1)]),Bk=x([`stopped`,`starting`,`running`,`degraded`,`incomplete`,`failed`]),Vk=`main.ts`,Hk=m(l().min(1).max(260),l().max(2e5)),Uk=ye(),Wk=b({name:l().min(1).max(120),code:l().max(2e5).optional(),files:Hk.optional(),entry:l().min(1).max(260).optional(),enabled:v(),placement:zk,integrationId:l().optional(),settingsSchema:Uk.optional(),tags:Vh.optional()}),Gk=Wk.superRefine((e,t)=>{let n=e.entry??`main.ts`;if(e.files!==void 0){e.files[n]===void 0&&t.addIssue({code:`custom`,message:`files must include the entry "${n}"`,path:[`files`]});return}e.code===void 0&&t.addIssue({code:`custom`,message:`code or files is required`,path:[`code`]})});function Kk(e){return e!==void 0&&e.length>0?e:Vk}function aSe(e){let t=Kk(e.entry);return e.files===void 0?{files:{[t]:e.code},entry:t}:{files:{...e.files},entry:t}}function oSe(e){if(e.files!==void 0){let t=Kk(e.entry);return{code:e.files[t]??e.code??``,files:{...e.files},entry:t}}return{code:e.code??``,...e.entry===void 0?{}:{entry:e.entry}}}var qk=i(`kind`,[b({kind:p(`code`)}),b({kind:p(`recipe`),recipe:Wv}),b({kind:p(`composition`),composition:El})]),Jk=b({name:l().min(1).max(120).optional(),enabled:v(),composition:El}),Yk=b({name:l().min(1).max(120),code:l().max(2e5),files:Hk.optional(),entry:l().min(1).max(260).optional(),enabled:v(),placement:zk,integrationId:l().optional(),settingsSchema:Uk.optional(),tags:Vh.optional(),id:l(),createdAt:n(),updatedAt:n(),createdBy:l(),status:Bk,lastError:l().optional(),lastChangedAt:n(),source:qk.optional()});function sSe(e){return e.source?.kind??`code`}function cSe(e){return e.source?.kind===`composition`?e.source.composition:null}var Xk=i(`kind`,[b({kind:p(`answered`),state:aE.nullable()}),b({kind:p(`unreachable`),error:l()})]),Zk=b({block:Yk,state:Xk}),Qk=b({state:p(`not-loaded`),reason:l()}),$k=i(`state`,[b({state:p(`loaded`),views:S(Zk)}),Qk]),eA=i(`state`,[b({state:p(`loaded`),view:Zk.nullable()}),Qk]),tA=i(`state`,[b({state:p(`loaded`),view:Zk.nullable()}),Qk]),nA=b({ok:v(),error:l().optional(),line:n().optional(),column:n().optional()}),rA=b({code:l().optional(),files:Hk.optional(),entry:l().min(1).max(260).optional()}).superRefine((e,t)=>{if(e.files!==void 0){let n=e.entry??`main.ts`;e.files[n]===void 0&&t.addIssue({code:`custom`,message:`files must include the entry "${n}"`,path:[`files`]});return}e.code===void 0&&t.addIssue({code:`custom`,message:`code or files is required`,path:[`code`]})}),iA={name:`core-blocks`,scope:`system`,mode:`singleton`,methods:{list:k(b({}),b({blocks:S(Yk)}),{auth:`admin`}),get:k(b({blockId:l()}),b({block:Yk.nullable()}),{auth:`admin`}),create:k(b({block:Gk}),b({block:Yk}),{kind:`mutation`,auth:`admin`,caller:`required`}),update:k(b({blockId:l(),block:Wk.partial()}),b({block:Yk}),{kind:`mutation`,auth:`admin`,caller:`required`}),delete:k(b({blockId:l()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setEnabled:k(b({blockId:l(),enabled:v()}),b({block:Yk}),{kind:`mutation`,auth:`admin`}),restart:k(b({blockId:l()}),b({block:Yk}),{kind:`mutation`,auth:`admin`}),compile:k(rA,nA,{kind:`mutation`,auth:`admin`}),getBlockSettings:k(b({blockId:l()}),aS.nullable(),{auth:`admin`}),updateBlockSettings:k(b({blockId:l(),patch:oS}),cS,{kind:`mutation`,auth:`admin`}),migrateRawSecrets:k(Fk,Ik,{kind:`mutation`,auth:`admin`}),getTypeDefs:k(b({}),b({libs:S(b({filePath:l(),content:l()}))}),{auth:`admin`}),createComposition:k(b({block:Jk}),b({block:Yk}),{kind:`mutation`,auth:`admin`,caller:`required`}),updateComposition:k(b({blockId:l(),expectedUpdatedAt:n(),block:Jk.partial()}),b({block:Yk}),{kind:`mutation`,auth:`admin`,caller:`required`}),getComposition:k(b({blockId:l()}),eA,{auth:`admin`}),listCompositions:k(b({}),$k,{auth:`admin`}),getCustomization:k(b({addonId:l().min(1),stableId:l().min(1)}),tA,{auth:`admin`}),listComposableCaps:k(b({deviceType:x(T)}),Ck,{auth:`admin`}),validateComposition:k(b({composition:El,blockId:l().optional()}),tE,{kind:`mutation`,auth:`admin`,access:`view`}),proposeRunningThreshold:k(b({deviceId:n().int(),cap:l().min(1),fieldPath:l().min(1),deviceType:x(T).optional()}),Pk,{auth:`admin`,access:`view`}),reportAutomationRun:k(b({blockId:l().min(1),trace:Oy.optional(),runStartedAt:n().optional(),keepTraces:n().int().min(1).max(100).optional()}),_(),{kind:`mutation`,auth:`admin`}),getAutomationRunState:k(b({blockId:l().min(1)}),ky,{auth:`admin`}),getTraces:k(b({blockId:l().min(1)}),b({traces:S(Oy),lastError:l().nullable()}),{auth:`admin`})},vocabulary:{notOperatorFacing:j.INTERNAL}},aA=x([`open`,`opening`,`closing`,`closed`,`stopped`]),oA=b({state:aA,position:n().min(0).max(100).nullable().meta(M(`percentage`)),tiltPosition:n().min(0).max(100).nullable().meta(M(`percentage`)),lastChangedAt:n()}),sA={name:`cover`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Cover],methods:{open:k(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.open`,label:P(`Open`,`Apri`),phrase:P(`Open {device}`,`Apri {device}`),icon:`arrow-up-to-line`,effect:{field:`state`,value:`open`}}]}),close:k(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.close`,label:P(`Close`,`Chiudi`),phrase:P(`Close {device}`,`Chiudi {device}`),icon:`arrow-down-to-line`,effect:{field:`state`,value:`closed`}}]}),stop:A(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.stop`,label:P(`Stop`,`Ferma`),phrase:P(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),setPosition:A(b({deviceId:n().int().nonnegative(),position:n().min(0).max(100)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.position`,label:P(`Set position`,`Imposta la posizione`),phrase:P(`Move {device} to {position} open`,`Porta {device} al {position} di apertura`),icon:`blinds`,effect:{field:`position`,fromArg:`position`},openArgs:[{key:`position`,label:P(`Position`,`Posizione`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setTiltPosition:A(b({deviceId:n().int().nonnegative(),tiltPosition:n().min(0).max(100)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.tilt`,label:P(`Set tilt`,`Imposta l’inclinazione`),phrase:P(`Tilt {device} to {tiltPosition}`,`Inclina {device} al {tiltPosition}`),icon:`blinds`,effect:{field:`tiltPosition`,fromArg:`tiltPosition`},openArgs:[{key:`tiltPosition`,label:P(`Tilt`,`Inclinazione`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]})},status:{schema:oA,kind:`push`},runtimeState:oA,durability:`restored`,history:{fields:{position:{kind:`gauge`,unit:`%`,minIntervalMs:0}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:P(`Cover`,`Copertura`),order:1030,state:[{kind:`enum`,field:`state`,label:P(`State`,`Stato`),values:[{value:`open`,label:P(`Open`,`Aperto`),phrase:P(`When {device} is fully open`,`Quando {device} è tutto aperto`)},{value:`opening`,label:P(`Opening`,`In apertura`),phrase:P(`When {device} starts opening`,`Quando {device} inizia ad aprirsi`)},{value:`closing`,label:P(`Closing`,`In chiusura`),phrase:P(`When {device} starts closing`,`Quando {device} inizia a chiudersi`)},{value:`closed`,label:P(`Closed`,`Chiuso`),phrase:P(`When {device} is fully closed`,`Quando {device} è tutto chiuso`)},{value:`stopped`,label:P(`Stopped`,`Fermo`),phrase:P(`When {device} stops part-way`,`Quando {device} si ferma a metà`)}],icon:`blinds`},{kind:`numeric`,field:`position`,quantity:P(`the opening`,`l’apertura`),label:P(`Position`,`Posizione`),unit:`%`,icon:`blinds`}],overrides:{byRole:{[D.CoverGarage]:{actions:{"cover.open":{phrase:P(`Open the garage door {device}`,`Apri il garage {device}`),icon:`warehouse`},"cover.close":{phrase:P(`Close the garage door {device}`,`Chiudi il garage {device}`),icon:`warehouse`}}},[D.CoverGate]:{actions:{"cover.open":{phrase:P(`Open the gate {device}`,`Apri il cancello {device}`),icon:`fence`},"cover.close":{phrase:P(`Close the gate {device}`,`Chiudi il cancello {device}`),icon:`fence`}}},[D.CoverDoor]:{actions:{"cover.open":{phrase:P(`Open the door {device}`,`Apri la porta {device}`),icon:`door-open`},"cover.close":{phrase:P(`Close the door {device}`,`Chiudi la porta {device}`),icon:`door-closed`}}},[D.CoverWindow]:{actions:{"cover.open":{phrase:P(`Open the window {device}`,`Apri la finestra {device}`),icon:`app-window`},"cover.close":{phrase:P(`Close the window {device}`,`Chiudi la finestra {device}`),icon:`app-window`}}},[D.CoverShutter]:{actions:{"cover.open":{phrase:P(`Raise the shutter {device}`,`Alza la tapparella {device}`)},"cover.close":{phrase:P(`Lower the shutter {device}`,`Abbassa la tapparella {device}`)}}},[D.CoverAwning]:{actions:{"cover.open":{phrase:P(`Extend the awning {device}`,`Apri la tenda da sole {device}`)},"cover.close":{phrase:P(`Retract the awning {device}`,`Chiudi la tenda da sole {device}`)}}}}}}},cA=b({stepId:l(),entry:ng}),lA=b({path:l().min(1),bytes:n().int().nonnegative(),sha256:l().regex(/^[0-9a-f]{64}$/)}),uA=b({addonId:l(),stepId:l().min(1),entries:S(ng).min(1).max(4),bundle:b({ticket:Ti,bytes:n().int().positive(),sha256:l().regex(/^[0-9a-f]{64}$/)}),files:S(lA).min(1).max(64),distribute:v()}),dA=i(`kind`,[b({kind:p(`imported`),modelIds:S(l()).readonly(),distributed:S(b({modelId:l(),nodeId:l(),format:x(Pa),ok:v(),error:l().optional()})).readonly()}),b({kind:p(`refused`),reason:x([`transfer-failed`,`checksum-mismatch`,`bundle-mismatch`,`invalid-entry`,`id-taken`]),detail:l()})]),fA={name:`custom-model-registry`,scope:`system`,mode:`collection`,internal:!0,methods:{listModels:k(_(),S(cA).readonly(),{auth:`admin`}),importModelBundle:k(uA,dA,{kind:`mutation`,auth:`admin`,timeoutMs:30*6e4})},vocabulary:{notOperatorFacing:j.ML}},pA=b({engineId:l(),kind:x([`relational`,`vector`]),displayName:l()}),mA={name:`data-store-provider`,scope:`system`,mode:`collection`,internal:!0,methods:{getEngineInfo:k(_(),pA,{auth:`admin`}),get:k(b({namespace:l().optional(),collection:l(),key:l()}),C(),{auth:`admin`}),set:k(b({namespace:l().optional(),collection:l(),key:l(),value:C()}),_(),{kind:`mutation`,auth:`admin`}),query:k(b({namespace:l().optional(),collection:l(),filter:ff.optional(),columns:S(l()).readonly().optional()}),S(gf).readonly(),{auth:`admin`}),insert:k(b({namespace:l().optional(),collection:l(),record:b({id:l().optional(),data:m(l(),C())})}),b({id:h([l(),n()])}),{kind:`mutation`,auth:`admin`}),upsert:k(b({namespace:l().optional(),collection:l(),conflict:S(l()).readonly(),record:_f}),b({id:h([l(),n()])}),{kind:`mutation`,auth:`admin`}),upsertMany:k(b({namespace:l().optional(),collection:l(),conflict:S(l()).readonly(),records:S(_f).readonly()}),b({upserted:n().int()}),{kind:`mutation`,auth:`admin`}),insertMany:k(b({namespace:l().optional(),collection:l(),records:S(_f).readonly()}),b({inserted:n().int()}),{kind:`mutation`,auth:`admin`}),transact:k(b({namespace:l().optional(),guard:bf.optional(),ops:S(yf).readonly()}),b({applied:v(),current:C().optional()}),{kind:`mutation`,auth:`admin`}),update:k(b({namespace:l().optional(),collection:l(),id:l(),data:m(l(),C())}),_(),{kind:`mutation`,auth:`admin`}),delete:k(b({namespace:l().optional(),collection:l(),key:l()}),_(),{kind:`mutation`,auth:`admin`}),deleteWhere:k(b({namespace:l().optional(),collection:l(),filter:pf}),b({deleted:n().int()}),{kind:`mutation`,auth:`admin`}),updateWhere:k(b({namespace:l().optional(),collection:l(),filter:pf,data:m(l(),C())}),b({updated:n().int()}),{kind:`mutation`,auth:`admin`}),count:k(b({namespace:l().optional(),collection:l(),filter:ff.optional()}),n(),{auth:`admin`}),aggregate:k(b({namespace:l().optional(),collection:l(),fields:S(mf).readonly(),filter:ff.optional()}),hf,{auth:`admin`}),histogram:k(b({namespace:l().optional(),collection:l(),field:l(),bucketSize:n().int().positive(),origin:n().int(),filter:ff.optional()}),S(b({bucket:n().int(),count:n().int()})).readonly(),{auth:`admin`}),isEmpty:k(b({namespace:l().optional(),collection:l()}),v(),{auth:`admin`}),declareCollection:k(Cf,_(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:j.INTERNAL}},hA=x([`auto`,`day`,`night`,`schedule`]),gA=b({min:n(),max:n(),step:n()}),_A=b({mode:hA,sensitivity:n().optional().meta(M(`none`)),switchDelaySec:n().optional().meta(M(`duration`)),lastFetchedAt:n()}),vA=b({modes:S(hA),supportsSensitivity:v(),sensitivity:gA.optional(),supportsSwitchDelay:v(),switchDelaySec:gA.optional()}),yA=b({mode:hA.optional(),sensitivity:n().optional(),switchDelaySec:n().optional()}),bA={name:`day-night`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Camera],deviceConfig:{ui:{kind:`derived-form`,builderId:`day-night`,tab:`image`}},methods:{getOptions:k(b({deviceId:n()}),vA),setSettings:k(b({deviceId:n(),settings:yA}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`dayNight.auto`,label:P(`Day/night auto`,`Giorno/notte automatico`),phrase:P(`Let {device} switch day and night by itself`,`Fai passare {device} da giorno a notte in automatico`),icon:`sun-moon`,args:{settings:{mode:`auto`}}},{id:`dayNight.day`,label:P(`Day mode`,`Modalità giorno`),phrase:P(`Force {device} into day mode`,`Forza {device} in modalità giorno`),icon:`sun`,args:{settings:{mode:`day`}}},{id:`dayNight.night`,label:P(`Night mode`,`Modalità notte`),phrase:P(`Force {device} into night mode`,`Forza {device} in modalità notte`),icon:`moon`,args:{settings:{mode:`night`}}}]})},status:{schema:_A,kind:`poll`},runtimeState:_A,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:P(`Day/night`,`Giorno/notte`),order:3070,state:[{kind:`enum`,field:`mode`,label:P(`Day/night mode`,`Modalità giorno/notte`),values:[{value:`auto`,label:P(`Automatic`,`Automatica`)},{value:`day`,label:P(`Day`,`Giorno`),phrase:P(`When {device} switches to day mode`,`Quando {device} passa in modalità giorno`)},{value:`night`,label:P(`Night`,`Notte`),phrase:P(`When {device} switches to night mode`,`Quando {device} passa in modalità notte`)},{value:`schedule`,label:P(`Scheduled`,`Programmata`)}],icon:`sun-moon`}]}},lSe=[{value:`auto`,label:`Auto (defer to probed best)`},{value:`none`,label:`Off (software)`},{value:`videotoolbox`,label:`VideoToolbox (macOS)`},{value:`cuda`,label:`CUDA (NVIDIA)`},{value:`nvdec`,label:`NVDEC (NVIDIA legacy)`},{value:`vaapi`,label:`VAAPI (Linux Intel/AMD)`},{value:`qsv`,label:`QuickSync (Intel)`},{value:`d3d11va`,label:`D3D11VA (Windows)`},{value:`dxva2`,label:`DXVA2 (Windows legacy)`},{value:`amf`,label:`AMF (AMD)`},{value:`vdpau`,label:`VDPAU (Linux NVIDIA legacy)`},{value:`drm`,label:`DRM (Linux generic)`}],uSe={hwaccel:`auto`,probedBestHwaccel:``},xA={name:`decoder`,scope:`system`,mode:`singleton`,preferredProvider:`decoder-nodeav`,methods:{getInfo:k(_(),b({id:l(),name:l(),hwaccel:l().optional(),probedBestHwaccel:l().optional()})),reprobeHwaccel:k(_(),b({backend:l()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:j.PIPELINE}},SA={name:`detection-pipeline`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[T.Camera],exposesDeviceSettings:!0,methods:{},vocabulary:{noun:P(`Detection pipeline`,`Pipeline di rilevamento`),order:3080}},CA=x([`device`,`integration`]),wA=b({url:l(),label:l(),target:CA,host:l()}),TA={name:`device-admin-link`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{getAdminLink:k(b({deviceId:n().int().nonnegative()}),wA.nullable(),{auth:`admin`})},vocabulary:{noun:P(`Admin link`,`Link di amministrazione`),order:3090}},EA=x([`online`,`sleeping`,`offline`,`unknown`]),DA=a(()=>b({childNativeId:l(),name:l(),type:x(T),status:EA,metadata:b({model:l().optional(),serialNumber:l().optional(),uid:l().optional(),rtspChannel:n().int().nonnegative().optional(),isBattery:v().optional(),isDoorbell:v().optional(),isMultifocal:v().optional(),externalLocation:l().optional(),manufacturer:l().optional(),integration:l().optional()}).default({}),alreadyAdopted:v(),adoptedDeviceId:n().int().nonnegative().nullable(),capabilities:S(l()).readonly().optional(),features:S(l()).readonly().optional(),sourceInfo:Yg.optional(),children:S(DA).readonly().optional(),parentStableId:l().optional()})),OA=b({id:l(),label:l(),isDefault:v().optional()}),kA=b({search:l().optional(),area:l().optional(),manufacturer:l().optional(),adoptedOnly:v().optional(),unadoptedOnly:v().optional()}),AA=b({integrationId:l(),page:n().int().positive().default(1),pageSize:n().int().positive().max(2e4).default(50),filter:l().optional(),filterText:kA.optional()}),jA=b({candidates:S(DA).readonly(),totalCount:n().int().nonnegative(),page:n().int().positive(),pageSize:n().int().positive()}),MA=b({integrationId:l(),childNativeId:l()}),NA=b({lastDiscoveryAt:n().int().nonnegative().nullable(),candidateCount:n().int().nonnegative(),adoptedCount:n().int().nonnegative(),lastError:l().nullable()}),dSe=b({name:l().min(1).optional(),hiddenChildIds:S(l()).optional()}),PA=b({integrationId:l(),childNativeIds:S(l()).min(1),filter:l().optional(),importLocations:v().optional(),perCandidate:m(l(),dSe).optional()}),FA=b({adopted:S(b({childNativeId:l(),parentDeviceId:n().int().nonnegative(),accessoryDeviceIds:S(n().int().nonnegative()).readonly()})).readonly()}),IA=b({integrationId:l(),camDeviceId:n().int().nonnegative()}),LA=b({camDeviceId:n().int().nonnegative(),resetToSource:v().optional()}),RA=b({changed:v(),rebuiltChildren:n().int().nonnegative(),removedChildren:n().int().nonnegative().optional()}),zA={name:`device-adoption`,scope:`system`,mode:`collection`,status:{schema:NA,kind:`poll`},methods:{listCandidateFilters:k(b({integrationId:l()}),b({filters:S(OA)}),{auth:`admin`}),listCandidates:k(AA,jA,{auth:`admin`}),getCandidate:k(MA,DA.nullable(),{auth:`admin`}),refresh:k(b({integrationId:l()}),NA,{kind:`mutation`,auth:`admin`}),adopt:k(PA,FA,{kind:`mutation`,auth:`admin`}),release:k(IA,_(),{kind:`mutation`,auth:`admin`}),resync:k(LA,RA,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`device adoption — an onboarding flow, not an action`}},BA=i(`state`,[b({state:p(`absent`)}),b({state:p(`ready`),subject:l(),fingerprintSha256:l(),validTo:l()}),b({state:p(`unavailable`),reason:l()})]),VA=b({selfEnrollment:x([`allowed`,`disabled`])}),HA={name:`device-credentials`,scope:`system`,mode:`singleton`,methods:{listDeviceCredentials:k(b({userId:l().min(1).optional(),includeRevoked:v().default(!1)}),S($pe).readonly(),{auth:`admin`}),startEnrollment:k(b({userId:l().min(1),deviceName:l().min(1).max(80)}),eme,{kind:`mutation`,auth:`admin`,caller:`required`}),revokeDeviceCredential:k(b({id:l().min(1)}),b({revoked:v(),sessionsEnded:n().int(),status:Cg}),{kind:`mutation`,auth:`admin`,caller:`required`}),getDeviceCertificateSettings:k(b({}),VA,{auth:`admin`}),setDeviceCertificateSettings:k(VA,VA,{kind:`mutation`,auth:`admin`}),deleteDeviceCredential:k(b({id:l().min(1)}),b({result:x([`deleted`,`live`,`unknown`])}),{kind:`mutation`,auth:`admin`,caller:`required`}),getDeviceCaStatus:k(b({}),BA,{auth:`admin`}),renameDeviceCredential:k(b({id:l().min(1),deviceName:l().min(1).max(80)}),b({renamed:v()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:j.IDENTITY}},fSe=64,UA=/^[a-z][a-z0-9_]*$/,pSe=new Set(`true.false.none.null.and.or.not.in.is.if.elif.else.endif.for.endfor.loop.set.range.cycler.joiner.self.caller.super.import.include.extends.block.macro.now.camera`.split(`.`)),WA=l().max(64).regex(UA);function GA(e){return pSe.has(e)}function KA(e){let t=e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``);return t.length===0?`device`:(/^[0-9]/.test(t)?`device_${t}`:t).slice(0,60).replace(/_+$/g,``)}function mSe(e,t){let n=KA(e);if(!GA(n)&&!t(n))return n;for(let e=2;;e+=1){let r=`${n}_${e}`;if(!t(r))return r}}function hSe(e,t){return e.length===0?{ok:!1,reason:`empty`}:e.length>64?{ok:!1,reason:`too-long`}:UA.test(e)?GA(e)?{ok:!1,reason:`reserved`}:t(e)?{ok:!1,reason:`taken`}:{ok:!0,alias:e}:{ok:!1,reason:`grammar`}}var qA=4096,gSe=50,_Se=4096,vSe=`—`,JA=l().min(1).max(qA),ySe=`now`,bSe=`camera`,YA=h([l(),n(),v()]),XA=b({deviceId:n().int(),values:m(l().min(1).max(64),YA).optional()}),xSe=`values`,SSe=su(),ZA=[`too-long`,`syntax`,`forbidden-syntax`,`forbidden-member`,`unknown-filter`,`ambiguous-field`,`busy`,`budget-exceeded`,`timeout`,`output-too-large`,`render-failed`,`out-of-scope`,`unavailable`],QA=b({reason:x(ZA),message:l()}),$A=[`unknown-alias`,`unknown-field`,`no-field`,`unavailable`],ej=b({ref:l(),reason:x($A)}),tj=i(`ok`,[b({ok:p(!0),text:l(),trace:S(ej)}),b({ok:p(!1),refusal:QA,trace:S(ej)})]);function nj(e){return e.replace(/-/g,`_`)}function rj(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ij(e,t){let n=e;for(let e of t)if(Array.isArray(n)&&typeof e==`number`)n=n[e];else if(rj(n)&&Object.hasOwn(n,String(e)))n=n[String(e)];else return;return n}function CSe(e,t){let n=t[0];if(n===void 0)return{kind:`missing`,reason:`no-field`};let r=Object.keys(e.slices),i=r.find(e=>e===n||nj(e)===n);if(i!==void 0){let n=t.slice(1);if(n.length===0)return{kind:`missing`,reason:`no-field`};let r=ij(e.slices[i],n);return r===void 0?{kind:`missing`,reason:`unknown-field`}:{kind:`value`,cap:i,fieldPath:n,value:r}}let a=r.filter(t=>{let r=e.slices[t];return rj(r)&&Object.hasOwn(r,String(n))});if(a.length===0)return{kind:`missing`,reason:`unknown-field`};let[o]=a;if(a.length>1||o===void 0)return{kind:`ambiguous`,field:String(n),caps:a};let s=ij(e.slices[o],t);return s===void 0?{kind:`missing`,reason:`unknown-field`}:{kind:`value`,cap:o,fieldPath:t,value:s}}var aj=b({zoneKey:l(),label:l(),icon:Ih.nullable(),locationKeys:S(l())});function wSe(e){return e.trim().toLowerCase()}var oj=[`mac`,`serial`,`machine-uuid`,`vendor-uid`,`hostname`,`ip`],sj=x(oj),cj=x([`read`,`derived`]),TSe=/^[0-9a-f]{2}(?::[0-9a-f]{2}){5}$/,lj=/^[a-z0-9][a-z0-9._-]*:[^\sA-Z]+$/,uj=/^[0-9a-f][0-9a-f-]{7,}$/,dj=/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;function fj(e){return b({value:e,origin:cj,readAt:n().int().nonnegative()}).strict()}var ESe=fj(l().regex(TSe)),DSe=fj(l().regex(lj)),OSe=fj(l().regex(uj)),kSe=fj(l().regex(lj)),ASe=fj(l().regex(dj)),jSe=fj(h([ee(),o()])),MSe=b({value:l().min(1),origin:cj,readAt:n().int().nonnegative()}).strict(),pj=b({mac:S(ESe).min(1).readonly().optional(),serial:DSe.optional(),"machine-uuid":OSe.optional(),"vendor-uid":kSe.optional(),hostname:ASe.optional(),ip:jSe.optional()}).strict(),NSe={mac:`strong`,serial:`strong`,"machine-uuid":`strong`,"vendor-uid":`strong`,hostname:`weak`,ip:`weak`};function PSe(e){return NSe[e]}function mj(e){return oj.every(t=>e[t]===void 0)}var FSe=/^(?:unknown|none|n\/?a|null|undefined|default|0+|-+)$/i,ISe=new Set([`00:00:00:00:00:00`,`ff:ff:ff:ff:ff:ff`]);function hj(e){return{ok:!1,reason:e}}function gj(e){let t=e.trim().toLowerCase().replace(/[\s:.-]/g,``);if(!/^[0-9a-f]{12}$/.test(t))return hj(`not a 48-bit MAC`);let n=(t.match(/../g)??[]).join(`:`);return ISe.has(n)?hj(`placeholder MAC`):{ok:!0,value:n}}function LSe(e){return e.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,`-`).replace(/^[-._]+|[-._]+$/g,``)}function _j(e,t,n){let r=LSe(e);if(r.length===0)return hj(`no ${n}`);let i=t.trim().toLowerCase().replace(/\s+/g,``);return i.length===0?hj(`blank value`):FSe.test(i)?hj(`placeholder value`):{ok:!0,value:`${r}:${i}`}}function RSe(e){let t=e.trim().toLowerCase().replace(/^\{|\}$/g,``);return uj.test(t)?/^[0-]+$/.test(t)||/^[f-]+$/.test(t)?hj(`placeholder uuid`):{ok:!0,value:t}:hj(`not a uuid`)}function vj(e){return h([ee(),o()]).safeParse(e).success}function zSe(e){let t=e.trim().toLowerCase().replace(/\.$/,``);if(t.length===0)return hj(`blank hostname`);if(vj(t))return hj(`an address, not a hostname`);let n=t.split(`.`)[0]??``;return dj.test(n)?n===`localhost`?hj(`placeholder hostname`):{ok:!0,value:n}:hj(`not a hostname`)}function BSe(e){let t=e.trim().toLowerCase().replace(/^\[|\]$/g,``);return vj(t)?t===`0.0.0.0`||t===`::`||t===`::1`||t.startsWith(`127.`)?hj(`loopback or unspecified address`):{ok:!0,value:t}:hj(`not an IP address`)}function yj(e){return e==null||e.trim().length===0}function bj(e,t={}){let n=t.readAt??Date.now(),r=e=>t.originByKey?.[e]??t.origin??`read`,i=(e,t)=>({value:t,origin:r(e),readAt:n}),a=[],o=(e,t,n)=>{if(n.ok)return i(e,n.value);a.push({key:e,value:t,reason:n.reason})},s=e.mac===null||e.mac===void 0?[]:[e.mac].flat(),c=[];for(let e of s){if(yj(e))continue;let t=o(`mac`,e,gj(e));t!==void 0&&!c.some(e=>e.value===t.value)&&c.push(t)}let l=e.serial===null||e.serial===void 0||yj(e.serial.serial)?void 0:o(`serial`,`${e.serial.manufacturer}:${e.serial.serial}`,_j(e.serial.manufacturer,e.serial.serial,`manufacturer`)),u=e.vendorUid===null||e.vendorUid===void 0||yj(e.vendorUid.id)?void 0:o(`vendor-uid`,`${e.vendorUid.vendor}:${e.vendorUid.id}`,_j(e.vendorUid.vendor,e.vendorUid.id,`vendor`)),d=yj(e.machineUuid)?void 0:o(`machine-uuid`,e.machineUuid,RSe(e.machineUuid)),f=yj(e.host)?null:e.host.trim(),p=f!==null&&vj(f.toLowerCase().replace(/^\[|\]$/g,``)),m=yj(e.hostname)?p?null:f:e.hostname,h=yj(e.ip)?p?f:null:e.ip,g=m===null?void 0:o(`hostname`,m,zSe(m)),ee=h===null?void 0:o(`ip`,h,BSe(h));return{identifiers:{...c.length>0?{mac:c}:{},...l===void 0?{}:{serial:l},...d===void 0?{}:{"machine-uuid":d},...u===void 0?{}:{"vendor-uid":u},...g===void 0?{}:{hostname:g},...ee===void 0?{}:{ip:ee}},rejected:a}}function xj(e,t){return e.value===t.value&&e.origin===t.origin}function Sj(e,t){return t!==void 0&&xj(e,t)?t:e}function VSe(e,t,n=[]){let r=e??{},i=t??{},a=new Set(n),o=a.has(`mac`)?r.mac:i.mac?.map(e=>Sj(e,r.mac?.find(t=>xj(t,e)))),s=e=>{if(a.has(e))return r[e];let t=i[e];return t===void 0?void 0:Sj(t,r[e])},c=s(`serial`),l=s(`machine-uuid`),u=s(`vendor-uid`),d=s(`hostname`),f=s(`ip`),p={...o!==void 0&&o.length>0?{mac:o}:{},...c===void 0?{}:{serial:c},...l===void 0?{}:{"machine-uuid":l},...u===void 0?{}:{"vendor-uid":u},...d===void 0?{}:{hostname:d},...f===void 0?{}:{ip:f}};return mj(p)?null:p}function HSe(e,t){let n=e=>e==null||mj(e)?``:JSON.stringify(oj.map(t=>[t,e[t]??null]).map(([e,t])=>[e,t===null?null:[t].flat().map(e=>[e.value,e.origin,e.readAt])]));return n(e)===n(t)}var Cj=x([`auto`,`proposal`]),wj=b({key:sj,value:l()}),Tj=b({deviceId:n().int(),addonId:l(),integrationId:l().nullable()}),Ej=b({a:Tj,b:Tj,keys:S(wj).readonly(),confidence:Cj}),Dj=i(`status`,[b({status:p(`unknown`),reason:l()}),b({status:p(`answered`),pairs:S(Ej).readonly(),undeclaredDeviceIds:S(n().int()).readonly()})]),Oj=[`same-device`,`poe-power`],kj=x(Oj),Aj=x([`proposed`,`linked`,`dismissed`]),jj=x([`auto`,`operator`]),Mj=b({addonId:l().min(1),stableId:l().min(1),deviceId:n().int()}),Nj=b({kind:kj,a:Mj,b:Mj,state:Aj,origin:jj,evidence:S(wj).readonly(),evidenceGone:p(!0).optional(),createdAt:n().int().nonnegative(),decidedAt:n().int().nonnegative().optional()}),Pj=Nj.extend({id:l().min(1)}),Fj={"same-device":{directional:!1,attachingRole:null,contributions:[]},"poe-power":{directional:!0,attachingRole:D.PoePort,contributions:[{cap:`power-source`,targetId:`switch`,host:`b`,source:`a`,sourceCap:`switch`,sourceField:`on`}]}};function USe(e,t){let n=Fj[e].attachingRole;return n===null||t===n?null:`attaching-side-role`}function Ij(e){return`${e.addonId}/${e.stableId}`}function WSe(e,t,n){let r=Ij(t),i=Ij(n);return Fj[e].directional||r<=i?`${e}:${r}|${i}`:`${e}:${i}|${r}`}var Lj=i(`status`,[b({status:p(`not-loaded`),reason:l()}),b({status:p(`answered`),links:S(Pj).readonly()})]),Rj=x([`not-loaded`,`unknown-link`,`wrong-state`]),zj=i(`ok`,[b({ok:p(!0),link:Pj}),b({ok:p(!1),reason:Rj,message:l()})]),Bj=x([`evidence-gone`,`device-removed`,`operator-unlinked`]),GSe=b({linkId:l(),kind:kj,aDeviceId:n().int(),bDeviceId:n().int(),origin:jj,reason:Bj.optional()}),KSe=50,qSe=200,Vj=b({caps:S(l()).readonly().optional(),actions:S(l()).readonly().optional(),mode:x([`any`,`all`]).optional()}),Hj=b({locations:S(l()).readonly().optional(),integrationIds:S(l()).readonly().optional(),types:S(l()).readonly().optional()}),Uj=b({text:l().optional(),requires:Vj.optional(),filters:Hj.optional(),includeIncompatible:v().optional(),contextDeviceId:n().optional(),ids:S(n()).readonly().optional(),cursor:l().nullable().optional(),limit:n().int().min(1).max(200).optional()}),Wj=b({cap:l(),path:l(),label:l(),reading:l().nullable(),unit:l().nullable().optional(),quantity:da.optional()}),Gj=b({id:n(),name:l(),type:x(T),location:l().nullable(),integrationId:l().nullable(),integrationLabel:l().nullable(),online:v().nullable(),disabled:v(),compatible:v(),values:S(Wj).readonly()}),Kj=b({value:l(),count:n()}),qj=b({id:l(),label:l(),count:n()}),Jj=b({locations:S(Kj).readonly(),integrations:S(qj).readonly(),types:S(Kj).readonly()}),Yj=b({items:S(Gj).readonly(),nextCursor:l().nullable(),total:n(),compatibleTotal:n(),fleetTotal:n(),hiddenIncompatible:n(),facets:Jj,suggested:S(Gj).readonly(),missingIds:S(n()).readonly()}),Xj=b({connected:v(),deviceCount:n(),error:l().optional(),motionSliceWriter:p(`orchestrator`).optional()}),JSe=b({externalId:l(),name:l(),type:l(),metadata:m(l(),C()).optional()}),Zj=i(`kind`,[b({kind:p(`mdns`),serviceType:l().min(1),instancePattern:l().optional()}),b({kind:p(`ws-discovery`),types:S(l()).optional()}),b({kind:p(`ssdp`),searchTarget:l().min(1)}),b({kind:p(`udp-broadcast`),port:n().int().min(1).max(65535),payloadHex:l().regex(/^([0-9a-fA-F]{2})*$/),listenPort:n().int().min(1).max(65535).optional()}),b({kind:p(`http-probe`),port:n().int().min(1).max(65535),path:l().startsWith(`/`),method:x([`GET`,`POST`]).default(`GET`),bodyText:l().optional(),contentType:l().optional(),tls:v().default(!1),acceptStatus:S(n().int()).optional()}),b({kind:p(`custom`),reason:l().min(1)})]),Qj=b({modeIndex:n().int().min(0),host:l(),port:n().int(),http:b({status:n().int(),headers:m(l(),l()),bodyText:l()}).optional(),mdns:b({instance:l(),host:l(),port:n().int(),txt:m(l(),l())}).optional(),udp:b({payloadHex:l()}).optional(),wsd:b({xaddrs:S(l()),types:S(l()),scopes:S(l())}).optional()}),$j=b({stableId:l(),type:x(T),suggestedName:l(),prefilledConfig:m(l(),C()),sourceInfo:Yg.optional(),alreadyOnboarded:v().optional(),onboardedDeviceId:n().optional(),onboardedName:l().optional(),setupIntegration:v().optional(),parentStableId:l().optional(),selectable:v().optional(),needsParams:S(l()).optional()}),eM=b({id:n(),stableId:l(),addonId:l(),type:l(),name:l(),parentDeviceId:n().nullable(),online:v(),features:S(l()),config:m(l(),C()),sourceInfo:Yg.optional()}),tM=b({status:x([`ok`,`error`]),labels:S(l()).optional(),error:l().optional()}),nM=C(),rM={name:`device-provider`,scope:`system`,mode:`collection`,methods:{start:k(_(),_(),{kind:`mutation`}),stop:k(_(),_(),{kind:`mutation`}),getStatus:k(_(),Xj),getDevices:k(_(),S(b({id:l(),name:l(),type:l()}))),reloadDevice:k(b({stableId:l()}),b({deviceId:n()}),{kind:`mutation`,timeoutMs:3*6e4}),supportsDiscovery:k(b({}),v()),discoverDevices:k(b({params:m(l(),C()).optional()}),S($j),{kind:`mutation`,auth:`admin`}),getDiscoveryModes:k(b({}),S(Zj)),classifyDiscoveryHits:k(b({hits:S(Qj),params:m(l(),C()).optional()}),S($j),{kind:`mutation`,auth:`admin`}),getDiscoveryParamsSchema:k(b({}),nM),getManualCreationType:k(b({integrationId:l().optional()}),b({deviceType:x(T).nullable()})),adoptDiscoveredDevice:k(b({candidate:$j,integrationId:l().optional()}),eM,{kind:`mutation`,auth:`admin`}),supportsManualCreation:k(b({}),v()),getChildCreationSchema:k(b({type:x(T),integrationId:l().optional()}),nM),createDevice:k(b({type:x(T),config:m(l(),C()),integrationId:l().optional()}),eM,{kind:`mutation`,auth:`admin`}),testCreationField:k(b({type:x(T),key:l(),value:C(),formValues:m(l(),C()).optional()}),tM,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:j.INTERNAL}},iM=i(`kind`,[b({kind:p(`mdns`),serviceType:l(),instance:l(),host:l(),address:l().nullable(),port:n().int(),txt:m(l(),l())}),b({kind:p(`ssdp`),host:l(),port:n().int(),target:l(),headers:m(l(),l())})]),YSe=b({addonId:l(),candidate:$j,firstSeenAt:n(),lastSeenAt:n(),dismissed:v()}),aM=b({id:l(),addonId:l(),candidate:$j,firstSeenAt:n(),lastSeenAt:n(),dismissed:v()}),oM=b({childKey:l(),section:l(),order:n().optional(),collapsed:v().optional()}),XSe=b({unit:l().min(1).optional(),precision:n().int().min(0).max(10).optional()}),sM=b({icon:l().min(1).optional(),label:l().min(1).optional(),unit:l().min(1).optional(),precision:n().int().min(0).max(10).optional(),hidden:v().optional(),perCap:m(l(),XSe).optional()}),cM=b({unit:l().min(1).optional(),precision:n().int().min(0).max(10).optional(),icon:l().min(1).optional()}),lM=b({id:n(),stableId:l(),addonId:l(),type:x(T),name:l(),alias:WA.optional(),location:l().nullable(),tags:Vh.optional(),disabled:v(),parentDeviceId:n().nullable(),role:l().nullable().optional(),online:v(),probed:v().optional(),features:S(l()),isCamera:v(),config:m(l(),C()),secretConfigPaths:S(l()).optional(),metadata:m(l(),C()).nullable().optional(),identifiers:pj.optional(),attachedIdentifiers:pj.optional(),sourceInfo:Yg.optional(),integrationId:l().optional(),linkDeviceId:n().nullable().optional(),primaryChildEntityId:l().nullable().optional(),childLayout:S(oM).readonly().optional(),primaryChildPreference:S(l()).readonly().optional(),display:sM.optional()}),uM=b({key:l(),value:C(),description:l().optional()}),dM=x([`manual`]),fM=b({deviceId:n(),name:l(),location:l().nullable(),features:S(l()),producesTrackedEvents:v().optional()}),pM=b({deviceIds:S(n().int().positive()),trackedDeviceIds:S(n().int().positive()).optional()}),mM={id:`linked-devices`,label:`Linked devices`,description:`Companion devices of this camera: their controls appear with it, and the ones you opt in produce tracked events on it.`,shape:`association`,hostDeviceTypes:[T.Camera],sourceCaps:`any`,cardinality:`many`,value:pM},ZSe=b({deviceId:n(),mode:dM,devices:S(fM)}),hM=b({deviceId:n(),entries:S(b({capName:l(),kind:x([`native`,`wrapped`]),providerAddonId:l(),providerNodeId:l(),nativeAddonId:l(),implementedMethods:S(l()).optional()}))}),gM=i(`kind`,[b({kind:p(`value`),wrapperAddonId:l().nullable()}),b({kind:p(`missing`)}),b({kind:p(`failed`),error:l()})]),QSe=b({id:n(),stableId:l(),type:l(),name:l(),location:l().nullable(),tags:Vh.optional(),disabled:v(),parentDeviceId:n().nullable(),role:l().nullable().optional()}),$Se=b({id:n(),stableId:l(),addonId:l(),type:l(),name:l(),userNamed:v().optional(),location:l().nullable(),tags:Vh.optional(),disabled:v(),parentDeviceId:n().nullable(),metadata:m(l(),C()).nullable().optional(),identifiers:pj.optional(),attachedIdentifiers:pj.optional(),sourceInfo:Yg.optional(),integrationId:l().optional(),linkDeviceId:n().nullable().optional(),primaryChildEntityId:l().nullable().optional(),childLayout:S(oM).readonly().optional(),primaryChildPreference:S(l()).readonly().optional(),role:l().nullable().optional(),display:sM.optional()}),eCe=C().nullable(),tCe=b({streamId:l(),width:n().optional(),height:n().optional(),codec:l().optional(),fps:n().optional(),bitrateKbps:n().optional()}),nCe=b({addonId:l(),stableId:l(),id:n(),type:l(),name:l(),location:l().nullable().optional(),disabled:v().optional(),parentDeviceId:n().nullable(),role:l().nullable().optional(),features:S(l()).optional(),config:m(l(),C()),secretConfigPaths:S(l()).optional()}),_M=b({deviceId:n().int().positive(),deletedAt:n(),providerAddonId:l()}),vM=2160*60*60*1e3,yM=b({deviceId:n().int().positive(),stores:m(l(),n().int().nonnegative())}),bM=b({status:x([`skipped`,`dry-run`,`cleaned`]),reason:l().nullable(),devices:S(yM),unreachable:S(l())}),rCe=b({deviceId:n()}),iCe=b({deviceId:n(),data:m(l(),C()),secretConfigPaths:S(l()).optional()}),xM=x([`off`,`on`,`not-offered`,`unreachable`]),SM=b({deviceId:n(),switchId:Qd,outcome:xM,detail:l().optional()}),CM=b({sourceId:n(),targetId:n(),switches:S(SM).readonly(),sourceStillLive:S(Qd).readonly(),swapped:v()}),wM={name:`device-manager`,scope:`system`,mode:`singleton`,extensionSlots:[mM],methods:{allocateDeviceId:k(b({addonId:l(),stableId:l()}),b({id:n()}),{kind:`mutation`}),migrateDevice:k(b({sourceId:n(),targetId:n()}),CM,{kind:`mutation`,auth:`admin`,timeoutMs:12*6e4}),registerDevice:k(nCe,_(),{kind:`mutation`}),removeDevice:k(rCe,_(),{kind:`mutation`}),persistConfig:k(iCe,_(),{kind:`mutation`,auth:`admin`}),loadConfig:k(b({deviceId:n()}),m(l(),C()),{auth:`admin`}),loadRuntimeState:k(b({deviceId:n()}),m(l(),C()),{auth:`admin`}),loadMeta:k(b({deviceId:n()}),$Se.nullable()),setName:k(b({deviceId:n(),name:l(),stampUserNamed:v().optional()}),_(),{kind:`mutation`,auth:`admin`}),setAlias:k(b({deviceId:n(),alias:l()}),i(`ok`,[b({ok:p(!0),alias:WA}),b({ok:p(!1),reason:x([`empty`,`too-long`,`grammar`,`reserved`,`taken`]),takenBy:n().optional()})]),{kind:`mutation`,auth:`admin`}),renderDeviceTemplates:k(b({templates:S(JA).max(64),allowedDeviceIds:S(n().int()).optional(),thisDevice:XA.optional()}),b({results:S(tj)}),{auth:`admin`}),checkDeviceTemplates:k(b({templates:S(l()).max(64),allowedDeviceIds:S(n().int()).optional(),thisDevice:XA.optional()}),b({results:S(i(`ok`,[b({ok:p(!0),aliases:S(b({alias:l(),deviceId:n().int().nullable(),allowed:v(),reads:S(l())})),readsClock:v()}),b({ok:p(!1),refusal:QA})]))}),{auth:`admin`}),setLocation:k(b({deviceId:n(),location:l().nullable()}),_(),{kind:`mutation`,auth:`admin`}),setTags:k(b({deviceId:n(),tags:Vh}),_(),{kind:`mutation`,auth:`admin`}),setType:k(b({deviceId:n(),type:x(T)}),_(),{kind:`mutation`,auth:`admin`}),setIntegrationId:k(b({deviceId:n(),integrationId:l()}),_(),{kind:`mutation`,auth:`admin`}),setLinkDeviceId:k(b({deviceId:n(),linkDeviceId:n().nullable()}),_(),{kind:`mutation`,auth:`admin`}),setPrimaryChildEntityId:k(b({deviceId:n(),primaryChildEntityId:l().nullable()}),_(),{kind:`mutation`,auth:`admin`}),setChildLayout:k(b({deviceId:n(),childLayout:S(oM).readonly()}),_(),{kind:`mutation`,auth:`admin`}),setPrimaryChildPreference:k(b({deviceId:n(),primaryChildPreference:S(l()).readonly()}),_(),{kind:`mutation`,auth:`admin`}),setDisplay:k(b({deviceId:n(),display:sM.nullable()}),_(),{kind:`mutation`,auth:`admin`}),getRoleDisplayDefaults:k(b({}),b({defaults:m(l(),cM)}),{role:`viewer`,kind:`query`}),setRoleDisplayDefaults:k(b({defaults:m(l(),cM)}),_(),{kind:`mutation`,auth:`admin`}),getWireableFields:k(b({deviceId:n(),includeSynthesizable:v().optional()}),b({caps:S(b({cap:l(),fields:S(b({path:l(),kind:x([`string`,`number`,`boolean`,`enum`,`union`]),unionMembers:S(x([`string`,`number`,`boolean`])).optional(),enumValues:S(l()).optional(),item:v().optional(),quantity:da.optional()})).readonly(),itemArray:b({path:l(),keyField:l()}).optional()})).readonly()}),{kind:`query`}),setRole:k(b({deviceId:n(),role:l().nullable()}),_(),{kind:`mutation`,auth:`admin`}),applyInitialMeta:k(b({deviceId:n(),name:l().optional(),location:l().nullable().optional(),tags:Vh.optional(),type:x(T).optional(),integrationId:l().optional(),linkDeviceId:n().nullable().optional(),role:l().nullable().optional()}),_(),{kind:`mutation`,auth:`admin`}),setMetadata:k(b({deviceId:n(),patch:m(l(),C())}),_(),{kind:`mutation`,auth:`admin`}),setIdentifiers:k(b({deviceId:n(),identifiers:pj.nullable(),unread:S(sj).optional()}),_(),{kind:`mutation`,auth:`admin`}),listIdentityCandidates:k(b({}),Dj,{kind:`query`,auth:`admin`}),setAttachedIdentifiers:k(b({deviceId:n(),identifiers:pj.nullable(),unread:S(sj).optional()}),_(),{kind:`mutation`,auth:`admin`}),listIdentityLinks:k(b({deviceId:n().int().optional()}),Lj,{kind:`query`,auth:`admin`}),confirmIdentityLink:k(b({linkId:l().min(1)}),zj,{kind:`mutation`,auth:`admin`}),dismissIdentityLink:k(b({linkId:l().min(1)}),zj,{kind:`mutation`,auth:`admin`}),unlinkIdentity:k(b({linkId:l().min(1)}),zj,{kind:`mutation`,auth:`admin`}),listLocations:k(_(),S(l())),addLocation:k(b({name:l()}),_(),{kind:`mutation`,auth:`admin`}),removeLocation:k(b({name:l(),cascade:v().optional()}),_(),{kind:`mutation`,auth:`admin`}),renameLocation:k(b({from:l(),to:l()}),b({moved:n()}),{kind:`mutation`,auth:`admin`}),listLocationIcons:k(_(),S(ume),{role:`viewer`}),setLocationIcon:k(b({location:l(),icon:Ih.nullable()}),_(),{kind:`mutation`,auth:`admin`}),listLocationDescriptions:k(_(),S(fme)),setLocationDescription:k(b({location:l(),description:l().max(400).nullable()}),_(),{kind:`mutation`,auth:`admin`}),listSiteZones:k(_(),S(aj),{role:`viewer`}),setSiteZone:k(b({name:l(),icon:Ih.nullable().optional()}),_(),{kind:`mutation`,auth:`admin`}),removeSiteZone:k(b({name:l()}),_(),{kind:`mutation`,auth:`admin`}),renameSiteZone:k(b({from:l(),to:l()}),_(),{kind:`mutation`,auth:`admin`}),setLocationZone:k(b({location:l(),zone:l().nullable()}),_(),{kind:`mutation`,auth:`admin`}),setDisabled:k(b({deviceId:n(),disabled:v()}),_(),{kind:`mutation`,auth:`admin`}),listPersistedByAddon:k(b({addonId:l()}),S(QSe)),listAll:k(b({addonId:l().optional(),projection:x([`full`,`slim`]).optional(),isCamera:v().optional(),deviceIds:S(n()).optional()}),S(lM),{role:`viewer`}),search:k(Uj,Yj,{role:`viewer`}),getDevice:k(b({deviceId:n()}),lM.nullable()),getChildren:k(b({parentDeviceId:n()}),S(lM),{role:`viewer`}),getChildrenBatch:k(b({parentDeviceIds:S(n()).max(256)}),m(l(),S(lM))),getLinkedDevices:k(b({deviceId:n()}),b({mode:dM,devices:S(fM)}),{role:`viewer`}),getLinkedDevicesBatch:k(b({deviceIds:S(n())}),S(ZSe),{role:`viewer`}),getStreamSources:k(b({deviceId:n()}),S(gne)),getConfigSchema:k(b({deviceId:n()}),S(uM)),getSettingsSchema:k(b({deviceId:n()}),eCe),updateConfig:k(b({deviceId:n(),values:m(l(),C())}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),enable:k(b({deviceId:n()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),disable:k(b({deviceId:n()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),remove:k(b({deviceId:n()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),listDeletedSince:k(b({sinceMs:n()}),S(_M).readonly(),{auth:`admin`}),cleanupDeletedDevicesData:k(b({confirm:v()}),bM,{kind:`mutation`,auth:`admin`}),removeByIntegration:k(b({integrationId:l()}),b({removed:n()}),{kind:`mutation`,auth:`admin`}),getStreamProfileMap:k(b({deviceId:n()}),m(l(),l().nullable())),setStreamProfileMap:k(b({deviceId:n(),profileMap:m(l(),l().nullable())}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),probeStreams:k(b({deviceId:n()}),S(tCe),{kind:`mutation`,auth:`admin`}),getBindings:k(b({deviceId:n()}),hM,{role:`viewer`}),getBindingsBatch:k(b({deviceIds:S(n())}),S(hM)),getAllBindings:k(b({}),S(hM)),listDeviceIdsByCaps:k(b({capNames:S(l().min(1)).min(1).max(16)}),S(n()),{role:`viewer`}),setWrapperActive:k(b({deviceId:n(),capName:l(),wrapperAddonId:l(),active:v()}),_(),{kind:`mutation`,auth:`admin`}),getWrapperActivation:k(b({deviceId:n(),capName:l().min(1)}),gM),listWrappersForCap:k(b({capName:l()}),S(l())),listBindableCapsForDeviceType:k(b({deviceType:l()}),S(b({capName:l(),wrappers:S(l())}))),getDeviceSettingsAggregate:k(b({deviceId:n()}),aS.nullable()),getDeviceLiveInfoAggregate:k(b({deviceId:n()}),aS.nullable(),{role:`viewer`}),getDeviceAggregate:k(b({deviceId:n()}),b({settings:aS.nullable(),live:aS.nullable()})),runDeviceAction:k(b({deviceId:n().int().nonnegative(),action:l().min(1),input:C()}),C(),{kind:`mutation`}),updateDeviceField:k(b({deviceId:n(),writerCapName:l(),writerAddonId:l(),key:l(),value:C()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),updateDeviceFieldsBatch:k(b({deviceId:n(),changes:S(b({writerCapName:l(),writerAddonId:l(),key:l(),value:C()}))}),b({success:p(!0),failures:S(b({writerCapName:l(),writerAddonId:l(),error:l()}))}),{kind:`mutation`,auth:`admin`}),discoverDevices:k(b({addonId:l()}),S($j),{kind:`mutation`,auth:`admin`}),adoptDevice:k(b({addonId:l(),candidate:$j,integrationId:l().optional()}),eM,{kind:`mutation`,auth:`admin`}),getCreationSchema:k(b({addonId:l(),type:x(T),integrationId:l().optional()}),C().nullable()),createDevice:k(b({addonId:l(),type:x(T),config:m(l(),C()),integrationId:l().optional()}),eM,{kind:`mutation`,auth:`admin`}),testCreationField:k(b({addonId:l(),type:x(T),key:l(),value:C(),formValues:m(l(),C()).optional()}),tM,{kind:`mutation`,auth:`admin`}),adoptionListCandidateFilters:k(b({addonId:l(),integrationId:l()}),b({filters:S(OA)}),{auth:`admin`}),adoptionListCandidates:k(AA.extend({addonId:l()}),jA,{auth:`admin`}),adoptionRefresh:k(b({addonId:l(),integrationId:l()}),NA,{kind:`mutation`,auth:`admin`}),adoptionAdopt:k(PA.extend({addonId:l()}),FA,{kind:`mutation`,auth:`admin`}),adoptionRelease:k(IA.extend({addonId:l()}),_(),{kind:`mutation`,auth:`admin`}),adoptionStartJob:k(PA.extend({addonId:l()}),b({jobId:l()}),{kind:`mutation`,auth:`admin`}),adoptionListJobs:k(b({addonId:l(),integrationId:l().optional()}),S(Zd).readonly(),{auth:`admin`}),adoptionCancelJob:k(b({jobId:l()}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`}),adoptionResync:k(LA,RA,{kind:`mutation`,auth:`admin`}),discoveryProviders:k(b({}),b({providers:S(b({addonId:l(),label:l()})).readonly()}),{auth:`admin`}),discoverAllProviders:k(b({subnets:S(l()).optional()}),b({groups:S(b({addonId:l(),label:l(),candidates:S($j).readonly(),error:l().nullable()})).readonly()}),{kind:`mutation`,auth:`admin`}),discoverProvider:k(b({addonId:l(),params:m(l(),C()).optional(),subnets:S(l()).optional()}),b({candidates:S($j).readonly()}),{kind:`mutation`,auth:`admin`}),listDiscoveryProposals:k(b({}),b({proposals:S(aM).readonly()}),{auth:`admin`}),dismissDiscoveryProposal:k(b({id:l()}),b({dismissed:v()}),{kind:`mutation`,auth:`admin`}),reportDiscoveryObservations:k(b({observations:S(iM).max(512)}),b({proposed:n().int()}),{kind:`mutation`,auth:`admin`}),runDiscoverySweep:k(b({}),b({providers:n().int(),proposed:n().int()}),{kind:`mutation`,auth:`admin`,timeoutMs:12e4}),providerCreationType:k(b({addonId:l(),integrationId:l().optional()}),b({deviceType:x(T).nullable()}),{auth:`admin`}),providerDiscoveryParamsSchema:k(b({addonId:l()}),C(),{auth:`admin`}),testField:k(b({deviceId:n(),key:l(),value:C()}),tM,{kind:`mutation`,auth:`admin`}),getDeviceStatusAggregate:k(b({deviceId:n(),caps:S(l()).readonly().optional()}),m(l(),C().nullable())),getDeviceStatusAggregateBatch:k(b({deviceIds:S(n()).readonly(),caps:S(l()).readonly().optional()}),m(l(),m(l(),C().nullable())),{role:`viewer`})},vocabulary:{notOperatorFacing:`the device registry itself — rename, move and remove are administration`}},TM=[`linked-devices`],EM=x(TM),DM={"linked-devices":{descriptor:mM,declaringCap:`device-manager`,hostDeviceTypes:[T.Camera]}},OM=i(`slot`,[pM.extend({slot:p(`linked-devices`)})]),kM=[T.Camera],aCe=`:`,oCe=`listSlots`,AM=i(`state`,[b({state:p(`ok`)}),b({state:p(`unreachable`),reason:l()})]),jM=b({source:l(),label:l(),addonId:l().optional(),availability:AM}),MM=x([`ok`,`missing`,`foreign`,`unavailable`]),NM=b({deviceId:n().int(),name:l().nullable(),health:MM,detail:l().optional()}),PM=b({state:x([`active`,`inactive`,`unknown`]),authority:l(),detail:l().optional()}),FM=b({state:p(`ok`),slotRef:l(),slot:EM,authority:l(),activation:PM.nullable(),value:OM,sources:S(NM),impliedSources:S(NM).optional()}),IM=b({state:p(`unreachable`),addonId:l(),reason:l()}),LM=i(`state`,[FM,IM]);function sCe(e,t){return{state:`unreachable`,addonId:e,reason:t}}var RM=b({deviceId:n().int(),name:l(),type:l(),location:l().nullable(),parentName:l().nullable(),suggested:v(),reason:l().nullable()}),zM=b({candidates:S(RM)}),BM=b({applied:p(!0),reload:x([`none`,`host`,`parent`])}),VM=b({deviceId:n().int(),slotRef:l().min(1)}),HM=VM.extend({value:OM}),UM={name:`device-extension`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:kM,deviceConfig:{ui:{kind:`widget`,widgetId:`host/extensions-panel`,tab:`general`,label:`Extensions`,order:72}},methods:{listSources:k(b({deviceId:n().int()}),S(jM)),listSlots:k(b({deviceId:n().int()}),S(LM)),listCandidates:k(VM,zM),setSlot:k(HM,BM,{kind:`mutation`,auth:`admin`})},vocabulary:{noun:P(`Device extension`,`Estensione del dispositivo`),order:3100}},WM=i(`kind`,[b({kind:p(`device`),deviceId:n().int()}),b({kind:p(`node`),nodeId:l().min(1)})]),GM=x([`gauge`,`counter`,`boolean`,`enum`]),KM=x([`gauge`,`counter`,`boolean`]),cCe=`derived:energy.kwh`,qM=x([`raw`,`5m`,`1h`,`1d`]),JM=x([`undeclared`,`not-owner`,`opted-out`,`not-a-real-device`,`rate`,`ingest-mismatch`,`out-of-range`]),lCe=b({key:l(),reason:JM,count:n().int()}),YM=b({accepted:n().int(),refused:S(lCe).readonly()}),XM=b({key:l(),scope:l(),kind:GM,unit:l().nullable(),displayName:l(),source:x([`cap`,`addon`,`derived`]),values:S(l()).readonly().nullable(),firstTs:n(),lastTs:n()}),uCe=b({t:n(),samples:n().int(),mean:n().nullable(),twMean:n().nullable(),min:n(),max:n(),last:n().nullable(),delta:n().nullable(),state:l().nullable(),states:m(l(),n()).nullable()}),dCe=b({scope:l(),before:b({t:n(),value:n().nullable(),state:l().nullable()}).nullable(),points:S(uCe).readonly(),derivedFrom:l().nullable()}),ZM={key:l(),scope:l().optional(),from:n(),to:n(),resolution:h([qM,p(`auto`)]).default(`auto`),maxPoints:n().int().positive().max(5e3).default(1e3)},QM=b({resolution:qM,series:S(dCe).readonly(),truncated:v()}),fCe=24,pCe=h([b({deviceId:n().int(),key:l(),scope:l().optional()}),b({forNodeId:l().min(1),key:l(),scope:l().optional()})]),mCe=i(`ok`,[b({ok:p(!0),result:QM}),b({ok:p(!1),error:l()})]),hCe=b({tier:qM,rows:n().int().nullable(),approxBytes:n().nullable(),countedAt:n().nullable()}),$M=x([`device-gone`,`undeclared`]),eN=b({raw:n().int(),"5m":n().int(),"1h":n().int(),"1d":n().int()}),gCe=b({seriesId:n().int(),deviceId:n().int(),key:l(),scope:l(),displayName:l().nullable(),reason:$M,missingSince:n().nullable(),firstTs:n(),lastTs:n(),rows:eN}),_Ce=200,vCe=50,tN=x([`not-found`,`not-orphan`,`failed`]),yCe=i(`ok`,[b({seriesId:n().int(),ok:p(!0),deleted:eN}),b({seriesId:n().int(),ok:p(!1),reason:tN})]),bCe=b({series:S(gCe).readonly(),truncated:v()}),nN=x([`invalid-range`,`range-too-large`,`series-not-found`,`not-a-point-series`]),xCe=b({"5m":n().int(),"1h":n().int(),"1d":n().int()}),SCe=i(`ok`,[b({ok:p(!0),dryRun:v(),seriesId:n().int(),rows:eN,rewritten:xCe.nullable()}),b({ok:p(!1),reason:nN})]),rN=b({startedAt:n(),ready:v(),series:n().int(),metrics:n().int(),optedOutDevices:n().int(),tiers:S(hCe).readonly(),capture:b({eventsSeen:n().int(),pointsEmitted:n().int(),pointsWritten:n().int(),pointsDropped:n().int(),bufferDepth:n().int(),trailingEmitted:n().int(),reconciledPoints:n().int(),reconcileRuns:n().int(),reconcileFailures:n().int(),lastReconcileAt:n().nullable(),lastFlushAt:n().nullable(),flushFailures:n().int(),skipped:m(l(),n().int())}),ingest:b({accepted:n().int(),refused:m(l(),n().int())}),rollup:b({last5mAt:n().nullable(),last1hAt:n().nullable(),last1dAt:n().nullable(),errors:n().int(),dirty5m:n().int(),dirty1h:n().int(),dirty1d:n().int()}),retention:b({lastRunAt:n().nullable(),deleted:m(l(),n().int()),purgedSeries:n().int()}),directory:b({devices:n().int(),lastRefreshAt:n().nullable()})}),iN={name:`device-history`,scope:`system`,mode:`singleton`,methods:{listSeries:k(b({deviceId:n().int()}),S(XM).readonly()),listNodeSeries:k(b({forNodeId:l().min(1)}),S(XM).readonly(),{auth:`admin`}),query:k(b({deviceId:n().int(),...ZM}),QM),queryNode:k(b({forNodeId:l().min(1),...ZM}),QM,{auth:`admin`}),queryMany:k(b({items:S(pCe).min(1).max(24),from:ZM.from,to:ZM.to,resolution:ZM.resolution,maxPoints:ZM.maxPoints}),b({results:S(mCe).readonly()}),{auth:`admin`}),declareSeries:k(b({name:l().regex(/^[a-z0-9-]+$/),subjectKind:x([`device`,`node`]),kind:KM,unit:l().optional(),displayName:l().min(1),ingest:x([`points`,`buckets`])}),b({key:l()}),{kind:`mutation`,auth:`admin`}),record:k(b({points:S(b({key:l(),subject:WM,scope:l().default(``),ts:n(),value:n()})).max(5e3)}),YM,{kind:`mutation`,auth:`admin`}),recordBuckets:k(b({buckets:S(b({key:l(),subject:WM,scope:l().default(``),bucketStart:n(),samples:n().int().positive(),sum:n(),min:n(),max:n(),last:n().nullable(),lastTs:n().nullable()})).max(5e3)}),YM,{kind:`mutation`,auth:`admin`}),getDeviceEnabled:k(b({deviceId:n().int()}),b({enabled:v()})),setDeviceEnabled:k(b({deviceId:n().int(),enabled:v()}),b({enabled:v()}),{kind:`mutation`,auth:`admin`}),getStatus:k(b({}),rN,{auth:`admin`}),listOrphanSeries:k(b({}),bCe,{auth:`admin`}),deleteOrphanSeries:k(b({seriesIds:S(n().int()).min(1).max(50)}),b({results:S(yCe).readonly()}),{kind:`mutation`,auth:`admin`}),deleteSeriesRange:k(b({deviceId:n().int(),key:l().min(1),scope:l(),fromMs:n().int().nonnegative(),toMs:n().int().nonnegative(),dryRun:v()}),SCe,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`recorded history of device state — read by charts, not actuated`}},aN=b({deviceId:n().int().positive(),deletedAt:n(),providerAddonId:l()}),oN=b({counts:m(l(),n().int().nonnegative())}),sN=b({store:l(),deviceId:n().int().positive(),count:n().int().nonnegative()}),cN={name:`device-removal-hook`,scope:`system`,mode:`collection`,internal:!0,methods:{onDeviceRemoved:k(aN,oN,{kind:`mutation`,auth:`admin`}),listDeviceData:k(_(),S(sN).readonly(),{auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:j.INTERNAL}},lN=x([`appliance`,`mower`,`vacuum`]),uN=x([`open`,`closed`]),dN=x([`completed`,`aborted`,`error`,`unknown`]),fN=x([`running-state`,`activity`,`reconcile`]),pN=x([`counter-delta`,`history-integral`]),mN=b({phase:l(),at:n()}),hN=b({kind:p(`appliance`),energyKwh:n().nullable().meta(M(`energy`)),energyMethod:pN.nullable(),peakW:n().nullable().meta(M(`power`)),avgW:n().nullable().meta(M(`power`)),program:l().nullable(),remainingAtStartSec:n().nullable().meta(M(`duration`)),finalPhase:l().nullable(),energyStartKwh:n().nullable().meta(M(`energy`)),powerObservedMs:n()}),gN=i(`kind`,[hN]),_N=b({runId:l(),deviceId:n().int(),kind:lN,state:uN,startedAt:n(),endedAt:n().nullable(),durationMs:n().nullable(),outcome:dN.nullable(),startSource:fN,endSource:fN.nullable(),runningSource:x([`native`,`assigned`]).nullable(),phases:S(mN),detail:gN}),CCe=[T.Washer,T.Dryer,T.Dishwasher],wCe=200,vN={name:`device-runs`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:CCe,methods:{listRuns:k(b({deviceId:n().int(),outcome:dN.optional(),atFrom:n().optional(),atTo:n().optional(),limit:n().int().positive().max(200).default(50),cursor:l().optional()}),b({runs:S(_N).readonly(),nextCursor:l().nullable()})),getRun:k(b({deviceId:n().int(),runId:l()}),_N.nullable()),getCurrentRun:k(b({deviceId:n().int()}),_N.nullable())},events:{onRunOpened:{data:_N,notOperatorFacing:`the durable record of a run that the running-state start flip already announces`},onRunClosed:{data:_N,notOperatorFacing:`the durable record of a run that the running-state finish flip already announces`}},vocabulary:{noun:P(`Runs`,`Esecuzioni`),order:2130}},yN=x([`replace`,`add`]),bN=i(`ok`,[b({ok:p(!0),changed:v()}),b({ok:p(!1),code:x([`owned-by-other`,`not-claimed`,`field-not-claimed`,`invalid-slice`,`unknown-device`,`row-unreadable`,`migration-in-flight`]),message:l()})]),xN=b({deviceId:n(),capName:l(),owner:l().min(1),mode:yN,fields:S(l().min(1)).min(1)}),SN=i(`state`,[b({state:p(`loaded`),claims:S(xN)}),b({state:p(`not-loaded`),reason:l()})]),CN={name:`device-state`,scope:`system`,mode:`singleton`,methods:{getSnapshot:k(b({deviceId:n()}),m(l(),m(l(),C()))),getCapSlice:k(b({deviceId:n(),capName:l(),confirmed:v().optional()}),m(l(),C()).nullable()),getAllSnapshots:k(b({confirmed:v().optional()}),m(l(),m(l(),m(l(),C())))),setCapSlice:k(b({deviceId:n(),capName:l(),slice:m(l(),C())}),_(),{kind:`mutation`}),claimFields:k(b({deviceId:n(),capName:l(),owner:l().min(1),mode:yN,fields:S(l().min(1)).min(1),values:m(l(),C())}),bN,{kind:`mutation`,auth:`admin`}),patchOwnedFields:k(b({deviceId:n(),capName:l(),owner:l().min(1),values:m(l(),C())}),bN,{kind:`mutation`,auth:`admin`}),releaseClaim:k(b({deviceId:n(),capName:l(),owner:l().min(1)}),bN,{kind:`mutation`,auth:`admin`}),listClaims:k(b({ownerPrefix:l().optional()}),SN,{auth:`admin`}),getNativeCapSlice:k(b({deviceId:n(),capName:l()}),m(l(),C()).nullable(),{auth:`admin`})},events:{onChanged:ai(b({deviceId:n(),capName:l(),slice:m(l(),C())}))},vocabulary:{notOperatorFacing:`the runtime-state mirror every trigger already reads through`}},wN=x([`schedule`,`command`,`burst`]),TN=x([`none`,`partial`,`full`]),EN=1e3,TCe=b({integrationId:l().min(1),minIntervalMs:n().int().min(EN),intervalMs:n().int().positive().optional(),batch:v(),push:TN,heartbeatMs:n().int().positive().optional(),connectionEpoch:n().int().nonnegative().optional()});function ECe(e){let t=e.intervalMs??0;return Math.max(e.minIntervalMs,t)}var DN=[3e3,1e4],ON=1e4,kN=2e3;function DCe(e){let t=DN.filter(t=>t<e),n=e-kN,r=(t[t.length-1]??0)+ON;for(;r<n;)t.push(r),r+=ON;let i=t[t.length-1];return(i===void 0?n>0:n-i>=1e3)&&t.push(n),t}var OCe=2500,AN=b({deviceId:n().int().nonnegative(),deviceIds:S(n().int().nonnegative()).min(1),reason:wN}),jN=b({deviceId:n().int().nonnegative()}),MN=b({ok:p(!0)}),NN=`the core schedules state refreshes itself; an operator never asks for one`,PN={name:`device-state-refresh`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{refresh:k(AN,MN,{kind:`mutation`,auth:`admin`,notOperatorFacing:NN}),resubscribe:k(jN,MN,{kind:`mutation`,auth:`admin`,notOperatorFacing:NN})},vocabulary:{noun:P(`State refresh`,`Aggiornamento dello stato`),order:3247}},FN=b({online:v(),lastChangedAt:n()}),IN={name:`device-status`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},events:{onStatusChanged:{data:b({deviceId:n(),status:FN}),notOperatorFacing:"the `online` state trigger phrases both edges of this change"}},status:{schema:FN,kind:`push`},runtimeState:FN,durability:`restored`,history:{fields:{online:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:P(`Reachability`,`Raggiungibilità`),order:5260,state:[{kind:`boolean`,field:`online`,label:P(`Online`,`Online`),whenTrue:P(`When {device} comes back online`,`Quando {device} torna online`),whenFalse:P(`When {device} goes offline`,`Quando {device} va offline`),icon:`wifi`}],extraEvents:[{category:w.DeviceOnline,label:P(`Came online`,`Tornato online`),phrase:P(`When {device} comes back online`,`Quando {device} torna online`),icon:`wifi`},{category:w.DeviceOffline,label:P(`Went offline`,`Andato offline`),phrase:P(`When {device} goes offline`,`Quando {device} va offline`),icon:`wifi-off`}]}},kCe=200,ACe=500,LN=x([`not-kernel`,`invalid`]),RN=b({written:n().int().nonnegative(),refused:S(b({id:l(),reason:LN})).readonly()}),zN=b({rows:n().int().nullable(),lastWriteAt:n().nullable(),refused:m(l(),n())}),BN={name:`device-transitions`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:Object.values(T).filter(e=>e!==T.Container),methods:{listTransitions:k(b({deviceId:n().int(),capName:l().optional(),actorKind:oa.optional(),outcome:sa.optional(),atFrom:n().optional(),atTo:n().optional(),limit:n().int().positive().max(200).default(50),cursor:l().optional()}),b({transitions:S(la).readonly(),nextCursor:l().nullable()})),getTransition:k(b({deviceId:n().int(),id:l()}),la.nullable()),listRecentTransitions:ii(b({actorKind:oa.optional(),outcome:sa.optional(),atFrom:n().optional(),atTo:n().optional(),limit:n().int().positive().max(200).default(50),cursor:l().optional()}),b({transitions:S(la).readonly(),nextCursor:l().nullable()}),{auth:`admin`}),record:ii(b({transitions:S(la).max(500)}),RN,{kind:`mutation`,auth:`admin`}),getStatus:ii(b({}),zN,{auth:`admin`})},vocabulary:{noun:P(`Transitions`,`Transizioni`),order:2140}},VN=x([`idle`,`running`,`paused`,`finished`,`error`,`unavailable`]),HN=x([`Inactive`,`Ready`,`DelayedStart`,`Run`,`Pause`,`ActionRequired`,`Finished`,`Error`,`Aborting`]),UN=x([`available`,`offline`,`description-missing`]),WN=b({availability:UN,state:VN,operationState:HN.nullable(),program:l().nullable(),selectedProgram:l().nullable(),availablePrograms:S(l()),remaining:n().int().nonnegative().nullable().meta(M(`duration`)),delayedStart:n().int().nonnegative().nullable().meta(M(`duration`)),progress:n().min(0).max(100).nullable().meta(M(`percentage`)),doorOpen:v().nullable(),doorLocked:v().nullable(),remoteStartAllowed:v().nullable(),remoteControlActive:v().nullable(),localControlActive:v().nullable(),powerOn:v().nullable(),powerState:l().nullable(),filterCleaningDue:v().nullable(),machineCareDue:v().nullable(),machineCareRemainingRuns:n().int().nonnegative().nullable().meta(M(`count`)),halfLoad:v().nullable(),hygienePlus:v().nullable(),extraDry:v().nullable(),intensiveZone:v().nullable(),varioSpeedPlus:v().nullable(),childLock:v().nullable(),activeEvents:S(l()),errorCode:n().nullable().meta(M(`none`)),errorLabel:l().nullable(),lastFetchedAt:n()}),GN=n().int().nonnegative(),KN=h([v(),l(),n()]),qN=x([`none`,`read`,`readWrite`,`writeOnly`,`readStatic`]),JN=b({key:l(),name:l(),type:x([`boolean`,`number`,`enum`,`string`]),access:qN,available:v(),unit:l().nullable(),min:n().nullable(),max:n().nullable(),step:n().nullable(),enumValues:S(l()).nullable(),defaultValue:KN.nullable()}),YN=b({key:l(),name:l(),available:v(),options:S(JN)}),XN=b({availability:UN,supportsStart:v(),supportsPause:v(),supportsResume:v(),supportsStop:v(),supportsPower:v(),programs:S(YN),options:S(JN)}),ZN={name:`dishwasher`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Dishwasher],methods:{start:k(b({deviceId:GN,program:l().min(1).optional(),options:m(l(),KN).optional()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.start`,label:P(`Start cycle`,`Avvia il lavaggio`),phrase:P(`Start {device}`,`Avvia {device}`),icon:`play`,openArgs:[{key:`program`,label:P(`Programme`,`Programma`),offer:{kind:`dynamic`,from:`status`,field:`availablePrograms`},optional:!0}]}]}),pause:k(b({deviceId:GN}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.pause`,label:P(`Pause`,`Metti in pausa`),phrase:P(`Pause {device}`,`Metti in pausa {device}`),icon:`pause`}]}),resume:k(b({deviceId:GN}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.resume`,label:P(`Resume`,`Riprendi`),phrase:P(`Resume {device}`,`Riprendi il lavaggio di {device}`),icon:`play`}]}),stop:k(b({deviceId:GN}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.stop`,label:P(`Stop`,`Ferma`),phrase:P(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),setProgram:k(b({deviceId:GN,program:l().min(1)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.program`,label:P(`Choose programme`,`Scegli il programma`),phrase:P(`Select the {program} programme on {device}`,`Seleziona il programma {program} su {device}`),icon:`list`,openArgs:[{key:`program`,label:P(`Programme`,`Programma`),offer:{kind:`dynamic`,from:`status`,field:`availablePrograms`}}]}]}),setPower:k(b({deviceId:GN,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.powerOn`,label:P(`Power on`,`Accendi`),phrase:P(`Turn on {device}`,`Accendi {device}`),icon:`power`,args:{on:!0}},{id:`dishwasher.powerOff`,label:P(`Power off`,`Spegni`),phrase:P(`Turn off {device}`,`Spegni {device}`),icon:`power-off`,args:{on:!1}}]}),setHalfLoad:k(b({deviceId:GN,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.halfLoadOn`,label:P(`Half load on`,`Mezzo carico attivo`),phrase:P(`Turn on half load on {device}`,`Attiva il mezzo carico su {device}`),icon:`contrast`,args:{on:!0}},{id:`dishwasher.halfLoadOff`,label:P(`Half load off`,`Mezzo carico spento`),phrase:P(`Turn off half load on {device}`,`Disattiva il mezzo carico su {device}`),icon:`contrast`,args:{on:!1}}]}),setHygienePlus:k(b({deviceId:GN,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.hygienePlusOn`,label:P(`Hygiene Plus on`,`Igiene Plus attiva`),phrase:P(`Turn on Hygiene Plus on {device}`,`Attiva Igiene Plus su {device}`),icon:`sparkles`,args:{on:!0}},{id:`dishwasher.hygienePlusOff`,label:P(`Hygiene Plus off`,`Igiene Plus spenta`),phrase:P(`Turn off Hygiene Plus on {device}`,`Disattiva Igiene Plus su {device}`),icon:`sparkles`,args:{on:!1}}]}),setExtraDry:k(b({deviceId:GN,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.extraDryOn`,label:P(`Extra dry on`,`Asciugatura extra attiva`),phrase:P(`Turn on extra dry on {device}`,`Attiva l’asciugatura extra su {device}`),icon:`sun`,args:{on:!0}},{id:`dishwasher.extraDryOff`,label:P(`Extra dry off`,`Asciugatura extra spenta`),phrase:P(`Turn off extra dry on {device}`,`Disattiva l’asciugatura extra su {device}`),icon:`sun`,args:{on:!1}}]}),setIntensiveZone:k(b({deviceId:GN,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.intensiveZoneOn`,label:P(`Intensive zone on`,`Zona intensiva attiva`),phrase:P(`Turn on the intensive zone on {device}`,`Attiva la zona intensiva su {device}`),icon:`flame`,args:{on:!0}},{id:`dishwasher.intensiveZoneOff`,label:P(`Intensive zone off`,`Zona intensiva spenta`),phrase:P(`Turn off the intensive zone on {device}`,`Disattiva la zona intensiva su {device}`),icon:`flame`,args:{on:!1}}]}),setVarioSpeedPlus:k(b({deviceId:GN,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.varioSpeedOn`,label:P(`Speed boost on`,`Lavaggio rapido attivo`),phrase:P(`Turn on the speed boost on {device}`,`Attiva il lavaggio rapido su {device}`),icon:`zap`,args:{on:!0}},{id:`dishwasher.varioSpeedOff`,label:P(`Speed boost off`,`Lavaggio rapido spento`),phrase:P(`Turn off the speed boost on {device}`,`Disattiva il lavaggio rapido su {device}`),icon:`zap`,args:{on:!1}}]}),setChildLock:k(b({deviceId:GN,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.childLockOn`,label:P(`Child lock on`,`Blocco bambini attivo`),phrase:P(`Turn on the child lock of {device}`,`Attiva il blocco bambini di {device}`),icon:`lock`,args:{on:!0}},{id:`dishwasher.childLockOff`,label:P(`Child lock off`,`Blocco bambini spento`),phrase:P(`Turn off the child lock of {device}`,`Disattiva il blocco bambini di {device}`),icon:`lock-open`,args:{on:!1}}]}),setOption:k(b({deviceId:GN,key:l().min(1),value:KN}),_(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`a raw appliance option key/value; every option worth naming has its own action above`}),getOptions:k(b({deviceId:GN}),XN,{auth:`protected`})},status:{schema:WN,kind:`poll`},runtimeState:WN,durability:`session`,history:{fields:{progress:{kind:`gauge`,unit:`%`,deadband:2},state:{kind:`enum`},operationState:{kind:`enum`},remaining:{kind:`gauge`,unit:`s`,minIntervalMs:6e4},doorOpen:{kind:`boolean`},powerOn:{kind:`boolean`}}},vocabulary:{noun:P(`Dishwasher`,`Lavastoviglie`),order:2020,state:[{kind:`enum`,field:`state`,label:P(`Cycle`,`Ciclo`),values:[{value:`idle`,label:P(`Idle`,`Inattiva`)},{value:`running`,label:P(`Running`,`In funzione`),phrase:P(`When {device} starts a cycle`,`Quando {device} inizia un lavaggio`)},{value:`paused`,label:P(`Paused`,`In pausa`)},{value:`finished`,label:P(`Finished`,`Terminato`),phrase:P(`When {device} finishes`,`Quando {device} finisce il lavaggio`)},{value:`error`,label:P(`Error`,`Errore`),phrase:P(`When {device} reports an error`,`Quando {device} segnala un errore`)},{value:`unavailable`,label:P(`Unavailable`,`Non disponibile`)}],icon:`washing-machine`},{kind:`numeric`,field:`progress`,quantity:P(`the cycle progress`,`l’avanzamento del lavaggio`),label:P(`Progress`,`Avanzamento`),unit:`%`,icon:`loader`},{kind:`boolean`,field:`doorOpen`,label:P(`Door open`,`Sportello aperto`),whenTrue:P(`When the door of {device} opens`,`Quando si apre lo sportello di {device}`),whenFalse:P(`When the door of {device} closes`,`Quando si chiude lo sportello di {device}`),icon:`door-open`},{kind:`boolean`,field:`filterCleaningDue`,label:P(`Filter cleaning due`,`Pulizia filtro da fare`),whenTrue:P(`When {device} asks for its filter to be cleaned`,`Quando {device} chiede di pulire il filtro`),whenFalse:P(`When the filter reminder of {device} clears`,`Quando l’avviso filtro di {device} rientra`),icon:`funnel`},{kind:`boolean`,field:`machineCareDue`,label:P(`Machine care due`,`Manutenzione da fare`),whenTrue:P(`When {device} asks for a machine-care cycle`,`Quando {device} chiede un ciclo di manutenzione`),whenFalse:P(`When the machine-care reminder of {device} clears`,`Quando l’avviso di manutenzione di {device} rientra`),icon:`wrench`}]}},QN=`motion.audio.recording.live.heatmapScrub.person.vehicle.animal.package.sensor.control.face.plate.car.truck.bus.motorcycle.bicycle.airplane.boat.train.bird.dog.cat.horse.sheep.cow.elephant.bear.zebra.giraffe.package-delivered.package-picked-up.suitcase.backpack.handbag.contact.motion-sensor.smoke.flood.gas.carbon-monoxide.vibration.tamper.presence.enum-sensor.device-event.lock.cover.switch.siren.button.doorbell.appliance-cycle`.split(`.`),$N=`audio`,eP=[.3,.42,.55,.7,.85,1],tP=[`camstack`,`high-contrast`,`okabe-ito`];function jCe(e){return QN.includes(e)}function MCe(e){return tP.includes(e)}var nP={dark:`#0c0a09`,light:`#fafaf9`},NCe=7,PCe=20,FCe=[`live`,`heatmapScrub`],ICe=3,rP=/^#[0-9a-fA-F]{6}$/;function iP(e,t){return Number.parseInt(e.slice(t,t+2),16)}function aP(e){let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function oP(e){let t=aP(iP(e,1)),n=aP(iP(e,3)),r=aP(iP(e,5));return .2126*t+.7152*n+.0722*r}function LCe(e,t){if(!rP.test(e)||!rP.test(t))return 0;let n=Math.max(oP(e),oP(t)),r=Math.min(oP(e),oP(t));return(n+.05)/(r+.05)}function sP(e){let t=aP(iP(e,1)),n=aP(iP(e,3)),r=aP(iP(e,5)),i=.4124564*t+.3575761*n+.1804375*r,a=.2126729*t+.7151522*n+.072175*r,o=.0193339*t+.119192*n+.9503041*r,s=e=>e>.008856?Math.cbrt(e):7.787*e+16/116,c=s(i/.95047),l=s(a),u=s(o/1.08883);return{L:116*l-16,a:500*(c-l),b:200*(l-u)}}function cP(e,t){if(e===0&&t===0)return 0;let n=Math.atan2(t,e)*180/Math.PI;return n<0?n+360:n}function RCe(e,t){if(!rP.test(e)||!rP.test(t))return 0;let n=sP(e),r=sP(t),i=((Math.hypot(n.a,n.b)+Math.hypot(r.a,r.b))/2)**7,a=.5*(1-Math.sqrt(i/(i+25**7))),o=(1+a)*n.a,s=(1+a)*r.a,c=Math.hypot(o,n.b),l=Math.hypot(s,r.b),u=cP(o,n.b),d=cP(s,r.b),f=0;c*l!==0&&(f=d-u,f>180?f-=360:f<-180&&(f+=360));let p=2*Math.sqrt(c*l)*Math.sin(f*Math.PI/360),m=(n.L+r.L)/2,h=(c+l)/2,g=u+d;c*l!==0&&(Math.abs(u-d)>180&&(g+=g<360?360:-360),g/=2);let ee=1-.17*Math.cos((g-30)*Math.PI/180)+.24*Math.cos(2*g*Math.PI/180)+.32*Math.cos((3*g+6)*Math.PI/180)-.2*Math.cos((4*g-63)*Math.PI/180),te=30*Math.exp(-(((g-275)/25)**2)),_=h**7,ne=2*Math.sqrt(_/(_+25**7)),v=1+.015*(m-50)**2/Math.sqrt(20+(m-50)**2),re=1+.045*h,ie=1+.015*h*ee,ae=-Math.sin(2*te*Math.PI/180)*ne,oe=r.L-n.L,y=l-c;return Math.sqrt((oe/v)**2+(y/re)**2+(p/ie)**2+y/re*ae*(p/ie))}var zCe={motion:`#d946ef`,audio:`#059eb8`,recording:`#ef4444`,live:`#8d7a00`,heatmapScrub:`#4b32ff`,person:`#11a64c`,vehicle:`#3b82f6`,animal:`#ea6a09`,package:`#924667`,sensor:`#624bbc`,control:`#944d24`,face:`#ed4f8d`,plate:`#4b7027`,car:`#9684cf`,truck:`#0f9b89`,bus:`#a734a9`,motorcycle:`#c1133a`,bicycle:`#0e6a9b`,airplane:`#7c9928`,boat:`#b17933`,train:`#ad6ca3`,bird:`#0f7c55`,dog:`#c82700`,cat:`#7268f2`,horse:`#cb795e`,sheep:`#b8636b`,cow:`#cb2969`,elephant:`#1158d2`,bear:`#8d5e00`,zebra:`#0097d6`,giraffe:`#8f61bb`,"package-delivered":`#cd3f9b`,"package-picked-up":`#388a08`,suitcase:`#666800`,backpack:`#ec5022`,handbag:`#a76ef8`,contact:`#ab5a49`,"motion-sensor":`#b95d1a`,smoke:`#dd3858`,flood:`#b31e7d`,gas:`#5b70b5`,"carbon-monoxide":`#7b4e8e`,vibration:`#e65bba`,tamper:`#98464b`,presence:`#3a9468`,"enum-sensor":`#7885f8`,"device-event":`#8c43c8`,lock:`#649653`,cover:`#c67597`,switch:`#7a812a`,siren:`#ac5d7f`,button:`#b276cd`,doorbell:`#0087ab`,"appliance-cycle":`#2a8c8c`},BCe=[`#b34dc7`,`#1d7d34`,`#db6b6c`,`#a43d29`,`#0e6ee6`,`#29a10b`,`#a98731`,`#0181c6`],VCe={motion:`#964360`,audio:`#23a132`,recording:`#2494ca`,live:`#bd7e2b`,heatmapScrub:`#ad6eea`,person:`#62611e`,vehicle:`#f4534c`,animal:`#1556cd`,package:`#9c4415`,sensor:`#066c48`,control:`#f2479f`,face:`#139d8a`,plate:`#909024`,car:`#8e35ab`,truck:`#bd0b2b`,bus:`#7a88ca`,motorcycle:`#e26725`,bicycle:`#a6679b`,airplane:`#7c5720`,boat:`#467a1b`,train:`#6f65a4`,bird:`#cb717f`,dog:`#c62490`,cat:`#b36850`,horse:`#1872ac`,sheep:`#927939`,cow:`#428a5c`,elephant:`#d41160`,bear:`#799453`,zebra:`#a85455`,giraffe:`#746be8`,"package-delivered":`#824a80`,"package-picked-up":`#614ac1`,suitcase:`#2f77f3`,backpack:`#fa476d`,handbag:`#c14cbe`,contact:`#c83921`,"motion-sensor":`#a07ebd`,smoke:`#a25b13`,flood:`#526bab`,gas:`#924938`,"carbon-monoxide":`#bb7e53`,vibration:`#b66182`,tamper:`#3c6931`,presence:`#6c851d`,"enum-sensor":`#ad2d48`,"device-event":`#5e9b04`,lock:`#00a062`,cover:`#ad8624`,switch:`#d05259`,siren:`#cd67b3`,button:`#c9746a`,doorbell:`#338eeb`,"appliance-cycle":`#00848a`},HCe=[`#817f3b`,`#a0733e`,`#8658b2`,`#956301`,`#bc652d`,`#647331`,`#a14c9e`,`#d14e71`],UCe={motion:`#b88128`,audio:`#1096c8`,recording:`#009e73`,live:`#9c8c22`,heatmapScrub:`#0072b2`,person:`#d55e00`,vehicle:`#c0739f`,animal:`#226d18`,package:`#91446c`,sensor:`#217b56`,control:`#648647`,face:`#c22998`,plate:`#fa4575`,car:`#956301`,truck:`#2f77f3`,bus:`#7a4e86`,motorcycle:`#f54597`,bicycle:`#bb3e75`,airplane:`#e054c0`,boat:`#457942`,train:`#867afa`,bird:`#88914c`,dog:`#1556cd`,cat:`#71702c`,horse:`#9b4fa4`,sheep:`#c0559d`,cow:`#d14f65`,elephant:`#98470f`,bear:`#595896`,zebra:`#96790e`,giraffe:`#cb717b`,"package-delivered":`#139d8a`,"package-picked-up":`#906ead`,suitcase:`#d02939`,backpack:`#d41160`,handbag:`#f64f54`,contact:`#7258d2`,"motion-sensor":`#b66182`,smoke:`#627abb`,flood:`#b86ae4`,gas:`#a95261`,"carbon-monoxide":`#c65d3c`,vibration:`#7a40b7`,tamper:`#914b34`,presence:`#9481c3`,"enum-sensor":`#ac6d47`,"device-event":`#7b6fce`,lock:`#c67662`,cover:`#a6564d`,switch:`#ad2c4e`,siren:`#348e08`,button:`#d27303`,doorbell:`#55770f`,"appliance-cycle":`#00737d`},WCe=[`#9a3784`,`#a7392c`,`#409d50`,`#6987e7`,`#ee5b3d`,`#c0430d`,`#af79b3`,`#4b6628`],lP=l().regex(/^#[0-9a-f]{6}$/),uP=i(`form`,[b({form:p(`solid`),hex:lP}),b({form:p(`gradient`),hex:lP,alphas:S(n().gt(0).lte(1)).length(eP.length)})]),dP=b({status:p(`ready`),presetId:x(tP),customized:v(),source:x([`stored`,`unconfigured`]),swatches:m(l(),uP),fallbacks:S(lP).length(8)}),fP=i(`status`,[dP,b({status:p(`unknown`),reason:l()})]),pP=h([b({presetId:l()}),b({presetId:l(),overrides:m(l(),uP)})]),mP=b({presetId:l(),overrides:m(l(),uP)});function GCe(e){return{form:`solid`,hex:e}}function KCe(e){return{form:`gradient`,hex:e,alphas:[...eP]}}function qCe(e){let t={};for(let n of QN){let r=e[n];if(r===void 0)throw Error(`palette table missing ${n}`);t[n]=n===`audio`?KCe(r):GCe(r)}return t}function hP(e,t,n,r){return{id:e,name:t,swatches:qCe(n),fallbacks:r}}var gP=[hP(`camstack`,`CamStack`,zCe,BCe),hP(`high-contrast`,`High contrast`,VCe,HCe),hP(`okabe-ito`,`Colour-blind safe`,UCe,WCe)];function _P(e){return gP.find(t=>t.id===e)}function vP(){let e=_P(`camstack`);if(e===void 0)throw Error(`CamStack preset missing`);return JCe(e,`unconfigured`,!1)}function JCe(e,t,n){return{status:`ready`,presetId:e.id,customized:n,source:t,swatches:e.swatches,fallbacks:[...e.fallbacks]}}function YCe(e){return e.hex}function XCe(e,t){let n=[];for(let t of QN){let r=e[t];r!==void 0&&n.push({name:t,hex:r.hex})}return t.forEach((e,t)=>{n.push({name:`fallback-${t}`,hex:e})}),n}function ZCe(e){let t=e[$N];return t===void 0||t.form===`gradient`&&eP.every((e,n)=>t.alphas[n]===e)?[]:[{code:`bad-gradient`,entry:$N}]}function QCe(e,t){let n=FCe;return n.includes(e)&&n.includes(t)}function yP(e,t){let n=[];for(let t of QN)e[t]===void 0&&n.push({code:`missing-entry`,entry:t});for(let t of Object.keys(e))jCe(t)||n.push({code:`unknown-entry`,entry:t});t.length!==8&&n.push({code:`bad-fallbacks`}),n.push(...ZCe(e));let r=XCe(e,t);for(let e=0;e<r.length;e++)for(let t=e+1;t<r.length;t++){let i=r[e],a=r[t];if(i===void 0||a===void 0)continue;let o=RCe(i.hex,a.hex);o<(QCe(i.name,a.name)?20:7)&&n.push({code:`too-close`,left:i.name,right:a.name,deltaE:o})}for(let e of r)for(let t of[`dark`,`light`]){let r=LCe(e.hex,nP[t]);r<3&&n.push({code:`low-contrast`,entry:e.name,background:t,contrast:r})}return n.length===0?{ok:!0}:{ok:!1,violations:n}}function $Ce(e){switch(e.code){case`too-close`:return`${e.left} vs ${e.right} (ΔE ${e.deltaE.toFixed(1)})`;case`low-contrast`:return`${e.entry} on ${e.background} (${e.contrast.toFixed(1)}:1)`;case`missing-entry`:return`${e.entry} is missing`;case`unknown-entry`:return`${e.entry} is not a palette entry`;case`bad-gradient`:return`${e.entry} gradient is not the six canonical steps`;case`bad-fallbacks`:return`fallback list must hold eight colours`;case`unknown-preset`:return`${e.presetId} is not a preset`}}function bP(e){return e.map($Ce).join(`; `)}var xP=class extends Error{violations;constructor(e){super(bP(e)),this.name=`PaletteRejectedError`,this.violations=e}};function SP(e,t){let n=0;for(let t=0;t<e.length;t++)n=n*31+(e.codePointAt(t)??0)>>>0;let r=t[n%t.length];if(r===void 0)throw Error(`display palette has no fallback colour`);return r}function CP(e,t,n){let r=n.trim().toLowerCase();if(r.startsWith(`audio-`)){let n=e[$N];return n===void 0?SP(r,t):n.hex}let i=e[r];return i===void 0?SP(r,t):i.hex}function wP(e,t){return{...e,...t}}function ewe(e){return`overrides`in e?e.overrides:{}}function twe(e){let t=_P(e.presetId);if(t===void 0||!MCe(e.presetId))throw new xP([{code:`unknown-preset`,presetId:e.presetId}]);let n=ewe(e),r=wP(t.swatches,n),i=yP(r,t.fallbacks);if(!i.ok)throw new xP(i.violations);let a=Object.keys(n).length>0;return{status:`ready`,presetId:t.id,customized:a,source:`stored`,swatches:r,fallbacks:[...t.fallbacks]}}function nwe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.keys(e).length===0}function rwe(e){if(e==null||nwe(e))return vP();let t=mP.safeParse(e);if(!t.success)return{status:`unknown`,reason:`stored palette is unreadable`};let n=_P(t.data.presetId);if(n===void 0)return{status:`unknown`,reason:`unknown preset ${t.data.presetId}`};let r=wP(n.swatches,t.data.overrides),i=yP(r,n.fallbacks);if(!i.ok)return{status:`unknown`,reason:bP(i.violations)};let a=Object.keys(t.data.overrides).length>0;return{status:`ready`,presetId:n.id,customized:a,source:`stored`,swatches:r,fallbacks:[...n.fallbacks]}}function iwe(e,t){return{presetId:e.presetId,overrides:{...t}}}var awe=b({id:l(),name:l(),swatches:m(l(),uP),fallbacks:S(l())}),TP={name:`display-palette`,scope:`system`,mode:`singleton`,methods:{getPalette:k(_(),fP,{auth:`protected`,role:`viewer`}),listPresets:k(_(),S(awe).readonly(),{auth:`protected`,role:`viewer`}),setPalette:k(pP,dP,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`the cluster display palette — one colour table for every client, not a device action`}},EP=b({enabled:v().nullable().meta({label:`Do not disturb`}),lastChangedAt:n()}),DP={name:`do-not-disturb`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.MediaPlayer],methods:{setEnabled:k(b({deviceId:n().int(),enabled:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dnd.on`,label:P(`Do not disturb on`,`Attiva Non disturbare`),phrase:P(`Turn on Do not disturb on {device}`,`Attiva Non disturbare su {device}`),icon:`bell-off`,args:{enabled:!0}},{id:`dnd.off`,label:P(`Do not disturb off`,`Disattiva Non disturbare`),phrase:P(`Turn off Do not disturb on {device}`,`Disattiva Non disturbare su {device}`),icon:`bell`,args:{enabled:!1}}]})},status:{schema:EP,kind:`push`},runtimeState:EP,durability:`session`,history:{fields:{enabled:{kind:`boolean`}}},vocabulary:{noun:P(`Do not disturb`,`Non disturbare`),order:2160,state:[{kind:`boolean`,field:`enabled`,label:P(`Do not disturb`,`Non disturbare`),whenTrue:P(`When Do not disturb turns on on {device}`,`Quando {device} attiva Non disturbare`),whenFalse:P(`When Do not disturb turns off on {device}`,`Quando {device} disattiva Non disturbare`),icon:`bell-off`}]}},OP=2e3,owe={version:1,targets:[{id:`pressed`,cardinality:`event`,shape:`pulse`,vocabulary:{cap:`doorbell`,eventName:`onPressed`},deviceTypes:[T.Camera],apply:`add`,applyAuthority:{kind:`composition-claim`},eventName:`onPressed`,edges:[`rising`],defaultEdge:`rising`,timestampPath:`lastPressedAt`,counterPath:`pressCountSinceStart`,highWater:`composer-advance`,combine:`any`,debounce:{kind:`rising-edge`,defaultDebounceMs:OP,changedAtRequired:!0},sources:[{kind:`binary`},{kind:`switch`}],sourceReport:{status:`assignment-status`},advancedExpression:!0}]},kP=b({lastPressedAt:n().nullable(),pressCountSinceStart:n().meta(M(`count`))}),AP=b({deviceId:n(),timestamp:n()}),jP={name:`doorbell`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Button,T.Camera],methods:{},events:{onPressed:{data:AP,fromState:{field:`lastPressedAt`,on:`advance`},trigger:{category:w.DoorbellOnPressed,label:P(`Rang`,`Ha suonato`),phrase:P(`When someone rings {device}`,`Quando qualcuno suona a {device}`),icon:`bell-ring`}}},status:{schema:kP,kind:`push`},runtimeState:kP,durability:`restored`,history:`none`,customize:owe,vocabulary:{noun:P(`Doorbell`,`Campanello`),order:5270}},MP=b({embedding:S(n()),inferenceMs:n()}),NP=x([`image`,`text`]),PP=b({modelId:l(),tower:NP,nodeId:l(),crashes:n(),windowMs:n(),sinceMs:n(),lastReason:l()}),FP=b({modelId:l(),tower:NP,nodeId:l(),attempts:n(),sinceMs:n(),lastReason:l()}),IP=b({modelId:l(),embeddingDim:n(),ready:v(),nodeId:l().optional(),failedModels:S(PP).optional(),failedRequirements:S(FP).optional()}),LP=`embedding-model-failed`,RP=`embedding-requirements-unavailable`,zP=`embedding-requirements-failed`,BP=x([LP,RP,zP]);function VP(e,t){return`[${e} model=${t.modelId} tower=${t.tower} node=${t.nodeId}]`}function swe(e){return Error(`${VP(LP,e)} ${e.modelId} (${e.tower} tower) crashed ${String(e.crashes)} times in ${String(Math.round(e.windowMs/1e3))}s on ${e.nodeId} — ${e.lastReason}. Cleared by embeddingEncoder.resetFailedModels({ modelId: "${e.modelId}", nodeId: "${e.nodeId}" }) or a model change.`)}function cwe(e,t){return Error(`${VP(RP,e)} ${e.modelId} (${e.tower} tower) on ${e.nodeId}: ${t}`)}function lwe(e){return Error(`${VP(zP,e)} ${e.modelId} (${e.tower} tower) on ${e.nodeId}: requirements can never be met — ${String(e.attempts)} attempts, last: ${e.lastReason}. Cleared by embeddingEncoder.resetFailedModels({ modelId: "${e.modelId}", nodeId: "${e.nodeId}" }) or a model change.`)}var uwe=RegExp(`\\[(${LP}|${RP}|${zP}) model=([^\\s\\]]+) tower=(image|text) node=([^\\s\\]]+)\\]`);function HP(e){let t=e instanceof Error?e.message:String(e),n=uwe.exec(t);if(n===null)return null;let r=BP.safeParse(n[1]),i=NP.safeParse(n[3]);return!r.success||!i.success||n[2]===void 0||n[4]===void 0?null:{code:r.data,modelId:n[2],tower:i.data,nodeId:n[4]}}function dwe(e){return UP(e)!==null}function UP(e){let t=HP(e);if(t===null||t.code!==`embedding-model-failed`)return null;let{modelId:n,tower:r,nodeId:i}=t;return{modelId:n,tower:r,nodeId:i}}var WP={name:`embedding-encoder`,scope:`system`,mode:`collection`,internal:!0,methods:{encode:k(b({crop:y(Uint8Array),width:n(),height:n()}),MP,{auth:`admin`}),encodeText:k(b({text:l(),modelId:l().min(1).optional()}),MP,{auth:`admin`}),getInfo:k(_(),IP,{auth:`admin`}),resetFailedModels:k(b({modelId:l().min(1).optional()}),b({cleared:S(l()),nodeId:l()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:j.ML}},GP=b({powerW:n().nullable().meta(M(`power`)),energyKwh:n().nullable().meta(M(`energy`)),todayKwh:n().nullable().meta(M(`energy`))}),KP=b({powerW:n().nullable().meta(M(`power`)),importKwh:n().nullable().meta(M(`energy`)),exportKwh:n().nullable().meta(M(`energy`)),importTodayKwh:n().nullable().meta(M(`energy`)),exportTodayKwh:n().nullable().meta(M(`energy`))}),qP=b({powerW:n().nullable().meta(M(`power`)),energyKwh:n().nullable().meta(M(`energy`)),todayKwh:n().nullable().meta(M(`energy`))}),JP=b({stateOfChargePct:n().nullable().meta(M(`percentage`)),storedKwh:n().nullable().meta(M(`energy`)),capacityKwh:n().nullable().meta(M(`energy`)),powerW:n().nullable().meta(M(`power`)),chargedKwh:n().nullable().meta(M(`energy`)),dischargedKwh:n().nullable().meta(M(`energy`)),chargedTodayKwh:n().nullable().meta(M(`energy`)),dischargedTodayKwh:n().nullable().meta(M(`energy`)),healthPct:n().nullable().meta(M(`percentage`))}),YP=b({solar:GP.nullable(),grid:KP.nullable(),house:qP.nullable(),heatPump:qP.nullable(),storage:JP.nullable(),lastFetchedAt:n()});function fwe(e){let t=e.solar?.todayKwh??null,n=e.grid?.exportTodayKwh??null;return t===null||n===null||t<=0?null:Math.max(0,Math.min(100,(t-n)/t*100))}var XP={name:`energy-system`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.EnergySystem],methods:{},status:{schema:YP,kind:`push`},runtimeState:YP,durability:`session`,history:{primary:`house.powerW`,priority:50,fields:{"solar.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Solar power`},"solar.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`Solar energy`},"grid.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Grid power`},"grid.importKwh":{kind:`counter`,unit:`kWh`,displayName:`Grid import`},"grid.exportKwh":{kind:`counter`,unit:`kWh`,displayName:`Grid export`},"house.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`House power`},"house.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`House energy`},"heatPump.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Heat pump power`},"heatPump.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`Heat pump energy`},"storage.stateOfChargePct":{kind:`gauge`,unit:`%`,deadband:1,displayName:`Storage charge`},"storage.storedKwh":{kind:`gauge`,unit:`kWh`,deadband:.05,displayName:`Stored energy`},"storage.capacityKwh":{kind:`gauge`,unit:`kWh`,deadband:.1,displayName:`Storage capacity`},"storage.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Storage power`},"storage.chargedKwh":{kind:`counter`,unit:`kWh`,displayName:`Storage charged`},"storage.dischargedKwh":{kind:`counter`,unit:`kWh`,displayName:`Storage discharged`},"storage.healthPct":{kind:`gauge`,unit:`%`,deadband:1,displayName:`Storage health`}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:P(`Energy system`,`Sistema energetico`),order:4020}},pwe=x([`date`,`time`,`datetime`]),ZP=b({value:l(),timestamp:v().optional(),lastFetchedAt:n()}),QP={name:`enum-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Sensor],methods:{},status:{schema:ZP,kind:`push`},runtimeState:ZP,durability:`restored`,history:{fields:{value:{kind:`enum`,skipWhenSet:`timestamp`}}},volatileStateFields:[`lastFetchedAt`,`timestamp`],vocabulary:{noun:P(`State sensor`,`Sensore di stato`),order:5060,state:[{kind:`value`,field:`value`,label:P(`State`,`Stato`),icon:`list`}]}},$P=x([`warning`,`error`]),eF=b({code:l(),label:l(),severity:$P}),tF=b({active:v().nullable(),code:l().nullable(),label:l().nullable(),severity:$P,since:n().nullable(),faults:S(eF).optional(),lastFetchedAt:n()}),nF={active:null,code:null,label:null,severity:`error`,since:null,lastFetchedAt:0},rF={name:`error`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},status:{schema:tF,kind:`push`,empty:nF},runtimeState:tF,durability:`restored`,volatileStateFields:[`lastFetchedAt`],history:`none`,vocabulary:{noun:P(`Fault`,`Guasto`),order:5265,state:[{kind:`boolean`,field:`active`,label:P(`Fault`,`Guasto`),whenTrue:P(`When {device} reports a fault`,`Quando {device} segnala un guasto`),whenFalse:P(`When the fault of {device} clears`,`Quando il guasto di {device} si risolve`),icon:`triangle-alert`}]}},iF=b({id:l(),name:l(),sampleCount:n().int().nonnegative(),coverMediaId:n().int().optional(),coverBase64:l().optional()}),mwe=b({id:l(),source:x([`detected`,`photo`]),addedAt:n().int(),deviceId:n().int().optional(),base64:l().optional(),mediaId:n().int().optional(),keyFrameMediaId:n().int().optional(),faceBbox:aC.optional()}),hwe=b({sampleId:l(),enrolledAt:n().int(),deviceId:n().int().optional(),source:x([`detected`,`photo`]),mediaId:n().int().optional(),comparable:v(),selfMean:n().nullable(),bestForeign:b({identityId:l(),name:l(),score:n()}).optional(),suspicion:n()}),gwe=b({identityId:l(),name:l(),modelId:l(),totalSamples:n().int(),comparableSamples:n().int(),flagged:n().int(),flagThreshold:n(),rows:S(hwe).readonly()}),aF=b({faceId:l(),deviceId:n().int(),trackId:l(),timestamp:n().int(),recognizedIdentityId:l().optional(),identityName:l().optional(),assigned:v(),base64:l().optional(),cropUrl:l().optional(),faceBbox:aC.optional(),keyFrameMediaId:n().int().optional(),bestMatchScore:n().optional(),nativeFaceShortSidePx:n().optional(),suggestedIdentityId:l().optional(),suggestedMatchScore:n().optional()}),_we=x([`unassigned`,`recognized`,`identified`,`all`]),vwe=x([`timestamp`,`suggestionConfidence`]),ywe=x([`asc`,`desc`]),bwe=b({faceIds:S(l()).readonly(),representativeFaceId:l(),size:n().int(),cohesion:n()}),xwe=b({mediaId:n().int(),kind:l(),url:l(),sizeBytes:n(),timestamp:n()}),oF={name:`face-gallery`,role:{feature:`face-assignment`},scope:`system`,mode:`singleton`,methods:{listIdentities:k(b({includeCrops:v().optional()}).optional(),S(iF).readonly(),{role:`viewer`}),createIdentity:k(b({name:l().min(1)}),iF,{kind:`mutation`,auth:`admin`}),renameIdentity:k(b({id:l(),name:l().min(1)}),_(),{kind:`mutation`,auth:`admin`}),deleteIdentity:k(b({id:l()}),_(),{kind:`mutation`,auth:`admin`}),listIdentitySamples:k(b({identityId:l()}),S(mwe).readonly()),auditIdentitySamples:k(b({identityId:l().min(1)}),gwe,{auth:`admin`}),removeSample:k(b({identityId:l(),sampleId:l()}),_(),{kind:`mutation`,auth:`admin`}),moveIdentitySample:k(b({sampleId:l().min(1),toIdentityId:l().min(1)}),_(),{kind:`mutation`,auth:`admin`}),listRecentFaces:k(b({deviceId:n().int().optional(),deviceIds:S(n().int()).optional(),limit:n().int().positive().optional(),filter:_we.optional(),since:n().int().optional(),until:n().int().optional(),sortBy:vwe.optional(),sortDirection:ywe.optional(),includeCrops:v().optional()}).optional(),S(aF).readonly()),getFaceByTrack:k(b({deviceId:n().int(),trackId:l()}),aF.nullable(),{role:`viewer`}),getFaceMedia:k(b({faceId:l()}),S(xwe).readonly()),assignFace:k(b({faceId:l(),identityId:l()}),_(),{kind:`mutation`,auth:`admin`}),unassignFace:k(b({faceId:l()}),_(),{kind:`mutation`,auth:`admin`}),deleteFace:k(b({faceId:l()}),_(),{kind:`mutation`,auth:`admin`}),assignFaces:k(b({faceIds:S(l()).min(1),identityId:l()}),b({assigned:n().int(),failed:S(l()).readonly()}),{kind:`mutation`,auth:`admin`}),unassignFaces:k(b({faceIds:S(l()).min(1)}),b({unassigned:n().int(),failed:S(l()).readonly()}),{kind:`mutation`,auth:`admin`}),suggestFaceClusters:k(b({threshold:n().min(0).max(1).optional(),minClusterSize:n().int().min(2).optional(),maxClusters:n().int().positive().optional(),limit:n().int().positive().optional(),maxFacesScanned:n().int().positive().optional()}).optional(),S(bwe).readonly())},vocabulary:{notOperatorFacing:`the face gallery — curated on its own page`}},sF=b({reason:l(),count:n().int().nonnegative()}),cF=b({family:l(),deviceId:n().int().positive(),variant:l().optional(),sinceMs:n(),atMs:n(),attempts:n().int().nonnegative(),succeeded:n().int().nonnegative(),reasons:S(sF).readonly()}),lF={name:`failure-contribution`,scope:`system`,mode:`collection`,internal:!0,methods:{list:k(_(),S(cF).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:j.INTERNAL}},uF=x([`forward`,`reverse`]),dF=[`horizontal`,`vertical`],fF=x(dF),pF=[`oscillating`,`angle`,`sweepFrom`,`sweepTo`],mF=x(pF),hF=[`min`,`max`,`step`],gF=b({oscillating:v().nullable().default(null),angle:n().nullable().default(null),sweepFrom:n().nullable().default(null),sweepTo:n().nullable().default(null),min:n().nullable().default(null),max:n().nullable().default(null),step:n().nullable().default(null)}),_F=b({horizontal:gF.nullable().default(null),vertical:gF.nullable().default(null)}),vF=[`nothing-to-set`,`axis-not-linked`,`out-of-range`,`source-gone`,`source-unknown`,`source-call-failed`],yF=x(vF),bF=i(`status`,[b({status:p(`applied`)}),b({status:p(`refused`),reason:yF,field:mF.optional(),detail:l(),applied:S(mF)})]),xF=b({deviceId:n().int().nonnegative(),axis:fF,oscillating:v().optional(),angle:n().optional(),sweepFrom:n().optional(),sweepTo:n().optional()});function SF(e,t){return`oscillationAxes.${e}.${t}`}var CF=b({speed:n().min(0).max(100).nullable().meta(M(`percentage`)),percentageStep:n().positive().optional().meta(M(`percentage`)),preset:l(),availablePresets:S(l()),direction:uF.nullable(),oscillating:v().nullable(),oscillationAxes:_F.optional(),lastChangedAt:n()});function Swe(e){let t=e.oscillationAxes;if(t===void 0)return e.oscillating;let n=dF.flatMap(e=>{let n=t[e]?.oscillating;return n==null?[]:[n]});return n.length===0?e.oscillating:n.some(Boolean)}var wF=[T.Fan],TF=`oscillation-axes`;function Cwe(e){return{id:`${e}-oscillating`,cardinality:`scalar`,vocabulary:{cap:`fan-control`,stateField:`oscillating`},deviceTypes:wF,apply:`replace`,section:TF,path:SF(e,`oscillating`),sources:[{kind:`switch`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}}function EF(e,t){let n={id:`${e}-${t}`,cardinality:`scalar`,vocabulary:{cap:`fan-control`},deviceTypes:wF,apply:`replace`,section:TF,path:SF(e,t),sources:[{kind:`numeric`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}};return t===`angle`?{...n,companions:hF.map(t=>({kind:`source-field`,path:SF(e,t),field:t}))}:n}var wwe=dF.flatMap(e=>[Cwe(e),EF(e,`angle`),EF(e,`sweepFrom`),EF(e,`sweepTo`)]),Twe={id:`preset`,cardinality:`scalar`,vocabulary:{cap:`fan-control`},deviceTypes:wF,apply:`replace`,path:`preset`,sources:[{kind:`field`,valueKinds:[`string`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}},DF=[...wwe,Twe],Ewe={version:1,overridable:DF.map(e=>({path:e.path,by:e.id})),targets:DF},OF={name:`fan-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Fan],methods:{setPercentage:A(b({deviceId:n().int().nonnegative(),speed:n().min(0).max(100)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.off`,label:P(`Fan off`,`Ventilatore spento`),phrase:P(`Stop {device}`,`Ferma {device}`),icon:`power-off`,effect:{field:`speed`,value:0},args:{speed:0}},{id:`fan.full`,label:P(`Fan full`,`Ventilatore al massimo`),phrase:P(`Run {device} at full speed`,`Porta {device} alla massima velocità`),icon:`fan`,effect:{field:`speed`,value:100},args:{speed:100},sideEffects:[{field:`preset`,value:``,when:{field:`preset`,notIn:[``]}}]},{id:`fan.speed`,label:P(`Set speed`,`Imposta la velocità`),phrase:P(`Set the speed of {device} to {speed}`,`Imposta la velocità di {device} al {speed}`),icon:`fan`,effect:{field:`speed`,fromArg:`speed`},sideEffects:[{field:`preset`,value:``,when:{field:`preset`,notIn:[``]}}],openArgs:[{key:`speed`,label:P(`Speed`,`Velocità`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setPreset:A(b({deviceId:n().int().nonnegative(),preset:l().min(1)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.preset`,label:P(`Set preset`,`Imposta il preset`),phrase:P(`Set {device} to preset {preset}`,`Imposta {device} sul preset {preset}`),icon:`list`,effect:{field:`preset`,fromArg:`preset`},openArgs:[{key:`preset`,label:P(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`status`,field:`availablePresets`}}]}]}),setDirection:A(b({deviceId:n().int().nonnegative(),direction:uF}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.forward`,label:P(`Spin forward`,`Rotazione avanti`),phrase:P(`Spin {device} forward`,`Fai girare {device} in avanti`),icon:`refresh-cw`,effect:{field:`direction`,value:`forward`},args:{direction:`forward`}},{id:`fan.reverse`,label:P(`Spin in reverse`,`Rotazione inversa`),phrase:P(`Spin {device} in reverse`,`Fai girare {device} al contrario`),icon:`rotate-ccw`,effect:{field:`direction`,value:`reverse`},args:{direction:`reverse`}}]}),setOscillating:A(b({deviceId:n().int().nonnegative(),oscillating:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.oscillateOn`,label:P(`Oscillate`,`Oscillazione attiva`),phrase:P(`Make {device} oscillate`,`Fai oscillare {device}`),icon:`move-horizontal`,effect:{field:`oscillating`,value:!0},args:{oscillating:!0}},{id:`fan.oscillateOff`,label:P(`Stop oscillating`,`Oscillazione spenta`),phrase:P(`Stop {device} oscillating`,`Ferma l’oscillazione di {device}`),icon:`move-horizontal`,effect:{field:`oscillating`,value:!1},args:{oscillating:!1}}]}),setOscillationAxis:A(xF,bF,{kind:`mutation`,auth:`protected`,actions:[{id:`fan.horizontalOscillateOn`,label:P(`Horizontal oscillation on`,`Oscillazione orizzontale attiva`),phrase:P(`Start the horizontal oscillation of {device}`,`Attiva l’oscillazione orizzontale di {device}`),icon:`move-horizontal`,args:{axis:`horizontal`,oscillating:!0}},{id:`fan.horizontalOscillateOff`,label:P(`Horizontal oscillation off`,`Oscillazione orizzontale spenta`),phrase:P(`Stop the horizontal oscillation of {device}`,`Ferma l’oscillazione orizzontale di {device}`),icon:`move-horizontal`,args:{axis:`horizontal`,oscillating:!1}},{id:`fan.verticalOscillateOn`,label:P(`Vertical oscillation on`,`Oscillazione verticale attiva`),phrase:P(`Start the vertical oscillation of {device}`,`Attiva l’oscillazione verticale di {device}`),icon:`move-vertical`,args:{axis:`vertical`,oscillating:!0}},{id:`fan.verticalOscillateOff`,label:P(`Vertical oscillation off`,`Oscillazione verticale spenta`),phrase:P(`Stop the vertical oscillation of {device}`,`Ferma l’oscillazione verticale di {device}`),icon:`move-vertical`,args:{axis:`vertical`,oscillating:!1}}]})},status:{schema:CF,kind:`push`},runtimeState:CF,customize:Ewe,durability:`session`,history:{fields:{speed:{kind:`gauge`,unit:`%`,minIntervalMs:0},oscillating:{kind:`boolean`}}},vocabulary:{noun:P(`Fan`,`Ventilatore`),order:1080,state:[{kind:`numeric`,field:`speed`,quantity:P(`the speed`,`la velocità`),label:P(`Speed`,`Velocità`),unit:`%`,icon:`fan`},{kind:`boolean`,field:`oscillating`,label:P(`Oscillating`,`Oscillazione`),whenTrue:P(`When {device} starts oscillating`,`Quando {device} inizia a oscillare`),whenFalse:P(`When {device} stops oscillating`,`Quando {device} smette di oscillare`),icon:`move-horizontal`}]}},Dwe=12,kF=b({oscillating:v().optional(),angle:n().optional(),sweepFrom:n().optional(),sweepTo:n().optional()}),AF=b({speed:n().min(0).max(100).optional(),preset:l().min(1).optional(),direction:uF.optional(),oscillationAxes:b({horizontal:kF.optional(),vertical:kF.optional()}).optional()}),jF=b({id:l().min(1).max(64),name:l().trim().min(1).max(40),state:AF}),MF=[`empty-state`,`duplicate-name`,`duplicate-id`,`too-many`,`not-a-fan`],NF=x(MF),PF=i(`status`,[b({status:p(`saved`),count:n().int().nonnegative()}),b({status:p(`refused`),reason:NF,detail:l()})]),FF=b({field:l(),outcome:x([`applied`,`failed`,`not-run`,`refused`]),message:l().optional()}),IF=b({status:x([`applied`,`partial`,`refused`]),fields:S(FF)}),LF=[`speed`,`direction`,`preset`,`oscillationAxes`],RF=x(LF),zF=b({what:l(),reason:l()}),BF=b({state:AF,omitted:S(zF)}),VF=b({deviceId:n().int().nonnegative()}),Owe={version:1,targets:[{id:`presets`,cardinality:`config`,vocabulary:{cap:`fan-presets`},deviceTypes:[T.Fan],apply:`add`,readMethod:`getPresets`,writeMethod:`setPresets`}]},HF={name:`fan-presets`,scope:`system`,mode:`singleton`,methods:{getPresets:k(VF,S(jF),{auth:`protected`}),setPresets:k(VF.extend({presets:S(jF).max(12)}),PF,{kind:`mutation`,auth:`admin`}),applyPreset:k(VF.extend({presetId:l().min(1)}),IF,{kind:`mutation`,auth:`protected`}),capturePreset:k(VF.extend({fields:S(RF).optional()}),BF,{auth:`protected`})},customize:Owe,vocabulary:{notOperatorFacing:`the per-fan presets — authored in the Customize presets editor, applied through the actions the exports list`}},UF=b({flags:m(l(),C()),deviceType:l().nullable(),model:l().nullable(),channelCount:n().nullable().meta(M(`count`)),lastProbedAt:n(),lastFetchedAt:n()}),WF={name:`feature-probe`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},events:{onProbeChanged:{data:b({deviceId:n(),status:UF}),notOperatorFacing:`the device’s capabilities were re-probed — plumbing, not a happening`}},status:{schema:UF,kind:`push`},runtimeState:UF,durability:`session`,history:`none`,vocabulary:{noun:P(`Feature probe`,`Rilevamento funzioni`),order:3120}},kwe=b({name:l(),path:l()}),Awe=b({path:l(),entries:S(kwe).readonly(),freeBytes:n(),totalBytes:n()}),GF={name:`filesystem-browse`,scope:`system`,mode:`singleton`,internal:!0,methods:{listAllowedRoots:k(_(),S(l()).readonly(),{auth:`admin`}),browse:k(b({path:l()}),Awe,{auth:`admin`}),createDir:k(b({path:l()}),b({path:l()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:j.INTERNAL}},KF=b({flooded:v(),lastChangedAt:n()}),qF={name:`flood`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Sensor],methods:{},status:{schema:KF,kind:`push`},runtimeState:KF,durability:`restored`,history:{fields:{flooded:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:P(`Leak sensor`,`Sensore di allagamento`),order:5070,state:[{kind:`boolean`,field:`flooded`,label:P(`Leak`,`Perdita`),whenTrue:P(`When {device} detects a leak`,`Quando {device} rileva una perdita`),whenFalse:P(`When {device} is dry again`,`Quando {device} torna asciutto`),icon:`droplets`}]}},JF=b({detected:v(),lastChangedAt:n()}),YF={name:`gas`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Sensor],methods:{},status:{schema:JF,kind:`push`},runtimeState:JF,durability:`restored`,history:{fields:{detected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:P(`Gas sensor`,`Sensore di gas`),order:5080,state:[{kind:`boolean`,field:`detected`,label:P(`Detected`,`Rilevato`),whenTrue:P(`When {device} detects gas`,`Quando {device} rileva gas`),whenFalse:P(`When the gas clears on {device}`,`Quando il gas su {device} rientra`),icon:`flame`}]}},XF=b({active:v().meta({label:`Active`}),lastChangedAt:n()}),ZF={name:`group-active`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Cover,T.Valve,T.Lock,T.MediaPlayer,T.Climate],methods:{},status:{schema:XF,kind:`push`},runtimeState:XF,durability:`session`,history:`none`,vocabulary:{noun:P(`Group state`,`Stato del gruppo`),order:5090}},QF=b({deviceId:n().int().nonnegative(),cap:l().min(1),method:l().min(1),ok:v(),error:l().optional(),at:n()}),$F=b({results:S(QF)}),eI={name:`group-commands`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Switch,T.Light,T.Fan,T.Cover,T.Valve,T.Lock,T.MediaPlayer,T.Climate],methods:{},status:{schema:$F,kind:`push`},runtimeState:$F,durability:`session`,history:`none`,vocabulary:{noun:P(`Group command`,`Comando di gruppo`),order:5100}},tI=b({included:n().int().nonnegative().meta(M(`count`,{precision:0,label:`Reporting`})),excluded:n().int().nonnegative().meta(M(`count`,{precision:0,label:`Excluded`})),total:n().int().nonnegative().meta(M(`count`,{precision:0,label:`Members`}))}),nI={name:`group-status`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Sensor,T.Switch,T.Light,T.Fan,T.Cover,T.Valve,T.Lock,T.MediaPlayer,T.Climate],methods:{},status:{schema:tI,kind:`push`},runtimeState:tI,durability:`session`,history:`none`,vocabulary:{noun:P(`Group`,`Gruppo`),order:5110,state:[{kind:`numeric`,field:`included`,quantity:P(`the members reporting`,`i membri che rispondono`),label:P(`Reporting`,`Rispondono`),icon:`users`},{kind:`numeric`,field:`excluded`,quantity:P(`the members left out`,`i membri esclusi`),label:P(`Excluded`,`Esclusi`),icon:`users`},{kind:`numeric`,field:`total`,quantity:P(`the member count`,`il numero di membri`),label:P(`Members`,`Membri`),icon:`sigma`}]}},rI=n().int().nonnegative(),iI=l().min(1),aI=l().min(1),oI=n().finite(),sI={key:`circuitId`,label:P(`Circuit`,`Circuito`),offer:{kind:`dynamic`,from:`status`,cap:`heat-pump-status`,field:`circuits`,valueKey:`id`,labelKey:`label`,where:{key:`kind`,equals:`heating`}}},cI={...sI,label:P(`Hot water circuit`,`Circuito acqua calda`),offer:{...sI.offer,where:{key:`kind`,equals:`dhw`}}},lI={key:`mode`,label:P(`Mode`,`Modalità`),offer:{kind:`text`}},jwe={key:`level`,label:P(`Level`,`Livello`),offer:{kind:`text`}},uI={key:`temp`,label:P(`Temperature`,`Temperatura`),offer:{kind:`number`,step:.5,unit:`°C`}},Mwe={key:`minutes`,label:P(`Minutes`,`Minuti`),offer:{kind:`number`,min:1,step:1,unit:`min`}},dI={name:`heat-pump-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.HeatPump],methods:{setSilentMode:k(b({deviceId:rI,mode:aI}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.silent`,label:P(`Set silent mode`,`Imposta la modalità silenziosa`),phrase:P(`Set silent mode of {device} to {mode}`,`Imposta la modalità silenziosa di {device} su {mode}`),icon:`volume-x`,openArgs:[{key:`mode`,label:P(`Silent mode`,`Modalità silenziosa`),offer:{kind:`enum`,values:[{value:`off`,label:P(`Off`,`Off`)},{value:`auto`,label:P(`Auto`,`Auto`)},{value:`on`,label:P(`On`,`On`)}]}}]}]}),setAwayMode:k(b({deviceId:rI,mode:aI}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.away`,label:P(`Set away mode`,`Imposta la modalità assente`),phrase:P(`Set away mode of {device} to {mode}`,`Imposta la modalità assente di {device} su {mode}`),icon:`plane`,openArgs:[{key:`mode`,label:P(`Away mode`,`Modalità assente`),offer:{kind:`enum`,values:[{value:`off`,label:P(`Off`,`Off`)},{value:`on`,label:P(`On`,`On`)}]}}]}]}),setAdditionalHeaterMode:k(b({deviceId:rI,mode:aI}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.additionalHeater`,label:P(`Set additional heater`,`Imposta il riscaldatore aggiuntivo`),phrase:P(`Set the additional heater of {device} to {mode}`,`Imposta il riscaldatore aggiuntivo di {device} su {mode}`),icon:`flame`,openArgs:[{key:`mode`,label:P(`Additional heater`,`Riscaldatore aggiuntivo`),offer:{kind:`enum`,values:[{value:`off`,label:P(`Off`,`Off`)},{value:`manual`,label:P(`Manual`,`Manuale`)},{value:`auto`,label:P(`Auto`,`Auto`)}]}}]}]}),setHolidayMode:k(b({deviceId:rI,mode:aI}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.holiday`,label:P(`Set holiday mode`,`Imposta la modalità vacanza`),phrase:P(`Set holiday mode of {device} to {mode}`,`Imposta la modalità vacanza di {device} su {mode}`),icon:`tree-palm`,openArgs:[{key:`mode`,label:P(`Holiday programme`,`Programma vacanza`),offer:{kind:`enum`,values:[{value:`off`,label:P(`Off`,`Off`)},{value:`hm1`,label:P(`Programme 1`,`Programma 1`)},{value:`hm2`,label:P(`Programme 2`,`Programma 2`)},{value:`hm3`,label:P(`Programme 3`,`Programma 3`)},{value:`hm4`,label:P(`Programme 4`,`Programma 4`)},{value:`hm5`,label:P(`Programme 5`,`Programma 5`)},{value:`hm6`,label:P(`Programme 6`,`Programma 6`)},{value:`hm7`,label:P(`Programme 7`,`Programma 7`)},{value:`hm8`,label:P(`Programme 8`,`Programma 8`)}]}}]}]}),setCircuitOperationMode:k(b({deviceId:rI,circuitId:iI,mode:aI}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitOperationMode`,label:P(`Set circuit operation mode`,`Imposta la modalità del circuito`),phrase:P(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`thermometer`,openArgs:[sI,lI]}]}),setCircuitHeatCoolMode:k(b({deviceId:rI,circuitId:iI,mode:aI}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitHeatCoolMode`,label:P(`Set circuit heat / cool`,`Imposta caldo / freddo del circuito`),phrase:P(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`sun-snow`,openArgs:[sI,lI]}]}),setCircuitSummerWinter:k(b({deviceId:rI,circuitId:iI,mode:aI}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitSummerWinter`,label:P(`Set circuit summer / winter`,`Imposta estate / inverno del circuito`),phrase:P(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`sun`,openArgs:[sI,lI]}]}),setCircuitComfortSetpoint:k(b({deviceId:rI,circuitId:iI,temp:oI}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitComfortSetpoint`,label:P(`Set comfort temperature`,`Imposta la temperatura comfort`),phrase:P(`Set the comfort temperature of {circuitId} on {device} to {temp}`,`Imposta la temperatura comfort di {circuitId} su {device} a {temp}`),icon:`thermometer-sun`,openArgs:[sI,uI]}]}),setCircuitEcoSetpoint:k(b({deviceId:rI,circuitId:iI,temp:oI}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitEcoSetpoint`,label:P(`Set eco temperature`,`Imposta la temperatura eco`),phrase:P(`Set the eco temperature of {circuitId} on {device} to {temp}`,`Imposta la temperatura eco di {circuitId} su {device} a {temp}`),icon:`leaf`,openArgs:[sI,uI]}]}),setCircuitMaxFlowTemp:k(b({deviceId:rI,circuitId:iI,temp:oI}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitMaxFlowTemp`,label:P(`Set maximum flow temperature`,`Imposta la temperatura massima di mandata`),phrase:P(`Set the maximum flow temperature of {circuitId} on {device} to {temp}`,`Imposta la temperatura massima di mandata di {circuitId} su {device} a {temp}`),icon:`flame`,openArgs:[sI,uI]}]}),setDhwOperationMode:k(b({deviceId:rI,circuitId:iI,mode:aI}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwOperationMode`,label:P(`Set hot water mode`,`Imposta la modalità acqua calda`),phrase:P(`Set hot water {circuitId} of {device} to {mode}`,`Imposta l'acqua calda {circuitId} di {device} su {mode}`),icon:`shower-head`,openArgs:[cI,lI]}]}),setDhwTemperatureLevel:k(b({deviceId:rI,circuitId:iI,level:aI}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwTemperatureLevel`,label:P(`Set hot water level`,`Imposta il livello acqua calda`),phrase:P(`Set hot water {circuitId} of {device} to level {level}`,`Imposta l'acqua calda {circuitId} di {device} al livello {level}`),icon:`droplet`,openArgs:[cI,jwe]}]}),setDhwChargeDuration:k(b({deviceId:rI,circuitId:iI,minutes:n().int().positive()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwChargeDuration`,label:P(`Set hot water charge duration`,`Imposta la durata della carica acqua calda`),phrase:P(`Set the charge of hot water {circuitId} on {device} to {minutes} min`,`Imposta la carica dell'acqua calda {circuitId} di {device} a {minutes} min`),icon:`timer`,openArgs:[cI,Mwe]}]}),startExtraHotWater:k(b({deviceId:rI,circuitId:iI}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.extraHotWater`,label:P(`Start extra hot water`,`Avvia acqua calda extra`),phrase:P(`Start an extra hot water charge of {circuitId} on {device}`,`Avvia una carica extra di acqua calda {circuitId} su {device}`),icon:`droplets`,openArgs:[cI]}]})},vocabulary:{noun:P(`Heat pump settings`,`Impostazioni pompa di calore`),order:4010}},fI=[`heating`,`dhw`,`cooling`,`solar`],pI=x(fI),mI=b({value:l().nullable(),allowed:S(l())}),hI=b({value:n().nullable(),min:n().nullable(),max:n().nullable(),step:n().nullable()}),gI=b({id:l().min(1),kind:pI,label:l(),icon:Ih,currentTemp:n().nullable().meta(M(`temperature`)),targetTemp:n().nullable().meta(M(`temperature`)),mode:l().nullable(),active:v().nullable(),operationMode:mI.nullable(),heatCoolMode:mI.nullable(),summerWinter:mI.nullable(),comfortSetpoint:hI.nullable(),ecoSetpoint:hI.nullable(),maxFlowTemp:hI.nullable(),temperatureLevel:mI.nullable(),chargeDuration:hI.nullable(),extraHotWater:v().nullable()}),_I=b({silent:mI.nullable(),away:mI.nullable(),additionalHeater:mI.nullable(),holiday:mI.nullable()}),vI=b({thermalW:n().nullable().meta(M(`power`)),electricalW:n().nullable().meta(M(`power`)),compressorPct:n().nullable().meta(M(`percentage`))}),yI=b({supply:n().nullable().meta(M(`temperature`)),return:n().nullable().meta(M(`temperature`)),outdoor:n().nullable().meta(M(`temperature`))}),bI=b({thermalKwh:n().nullable().meta(M(`energy`)),electricalKwh:n().nullable().meta(M(`energy`))}),xI=b({circuits:S(gI),system:_I,power:vI,temperatures:yI,energy:bI,waterPressureBar:n().nullable(),starts:n().nullable(),lastFetchedAt:n()});function SI(e){let{thermalW:t,electricalW:n}=e;return t===null||n===null||n<=0?null:t/n}var CI={name:`heat-pump-status`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.HeatPump],methods:{},status:{schema:xI,kind:`push`},runtimeState:xI,durability:`session`,history:{fields:{"power.thermalW":{group:`power`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Thermal power`},"power.electricalW":{group:`power`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Electrical power`},"power.compressorPct":{kind:`gauge`,unit:`%`,deadband:2,displayName:`Compressor`},"temperatures.supply":{group:`loop`,kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Supply`},"temperatures.return":{group:`loop`,kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Return`},"temperatures.outdoor":{kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Outdoor`},"energy.thermalKwh":{kind:`counter`,unit:`kWh`,displayName:`Thermal energy`},"energy.electricalKwh":{kind:`counter`,unit:`kWh`,displayName:`Electrical energy`}},items:{path:`circuits`,key:`id`,label:`label`,fields:{currentTemp:{kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Temperature`},targetTemp:{kind:`gauge`,unit:`°C`,minIntervalMs:0,displayName:`Setpoint`},mode:{kind:`enum`,displayName:`Mode`}}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:P(`Heat pump`,`Pompa di calore`),order:4e3}},wI=b({position:n().min(0).max(100).nullable().meta(M(`percentage`)),lastFetchedAt:n()}),TI={name:`heating-valve`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Climate],methods:{},status:{schema:wI,kind:`push`},runtimeState:wI,durability:`session`,history:{fields:{position:{kind:`gauge`,unit:`%`,deadband:1}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:P(`Radiator valve`,`Valvola termostatica`),order:1110,state:[{kind:`numeric`,field:`position`,quantity:P(`the valve opening`,`l’apertura della valvola`),label:P(`Valve opening`,`Apertura della valvola`),unit:`%`,icon:`heater`}]}},EI=x([`s`,`min`]),Nwe=x([`switch`,`pet-fountain`]),DI={actuator:`switch`,maxSeconds:10800,unit:`min`,quickRunDefault:30},OI={actuator:`pet-fountain`,maxSeconds:300,unit:`s`,quickRunDefault:60},kI=[T.Switch,T.PetFountain],AI={[T.Switch]:[D.SwitchHeater]};function jI(e,t){return e===T.PetFountain?OI:e===T.Switch&&t===D.SwitchHeater?DI:null}var Pwe=1e3,Fwe=6e4;function MI(e,t,n){let r=e-t;return r<=0?0:Math.max(1,Math.ceil(r/(n===`min`?Fwe:Pwe)))}function Iwe(e,t){return t===`min`?e*60:e}function NI(e){return e.unit===`min`?Math.floor(e.maxSeconds/60):e.maxSeconds}var PI=b({duration:n().positive().finite(),unit:EI});function FI(e,t){let n=NI(e);return{duration:Math.min((t!==null&&Number.isFinite(t)&&t>0?t:null)??e.quickRunDefault,n),unit:e.unit}}var II=x([`unsupported-device`,`over-max`,`command-failed`]),LI=i(`ok`,[b({ok:p(!0),activeUntil:n()}),b({ok:p(!1),reason:II,maxSeconds:n().nullable()})]),RI=b({activeUntil:n().nullable(),requestedBy:l().nullable(),quickRun:PI.nullable(),lastFetchedAt:n()}),zI=b({unit:EI,maxDuration:n(),defaultDuration:n()}),BI=b({quickRunDuration:n().positive().finite().nullable().optional()}),VI={name:`timed-run`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:kI,deviceRoles:AI,deviceConfig:{ui:{kind:`derived-form`,builderId:`timed-run`,tab:`general`}},methods:{getOptions:k(b({deviceId:n().int()}),zI),setSettings:k(b({deviceId:n().int(),settings:BI}),_(),{kind:`mutation`,auth:`admin`}),runFor:k(b({deviceId:n().int(),duration:n().positive().finite(),unit:EI}),LI,{kind:`mutation`,auth:`protected`,actions:[{id:`timedRun.runForMinutes`,label:P(`Run for minutes`,`Accendi per alcuni minuti`),phrase:P(`Run {device} for {duration} minutes, then switch it off`,`Tieni acceso {device} per {duration} minuti, poi spegnilo`),icon:`timer`,args:{unit:`min`},openArgs:[{key:`duration`,label:P(`Minutes`,`Minuti`),offer:{kind:`number`,min:1,step:1,unit:`min`}}]},{id:`timedRun.runForSeconds`,label:P(`Run for seconds`,`Accendi per alcuni secondi`),phrase:P(`Run {device} for {duration} seconds, then switch it off`,`Tieni acceso {device} per {duration} secondi, poi spegnilo`),icon:`timer`,args:{unit:`s`},openArgs:[{key:`duration`,label:P(`Seconds`,`Secondi`),offer:{kind:`number`,min:1,step:1,unit:`s`}}]}]}),cancel:k(b({deviceId:n().int()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`timedRun.cancel`,label:P(`Cancel the timer`,`Annulla il timer`),phrase:P(`Cancel the pending switch-off of {device}`,`Annulla lo spegnimento programmato di {device}`),icon:`timer-off`}]})},status:{schema:RI,kind:`push`},runtimeState:RI,durability:`session`,history:`none`,vocabulary:{noun:P(`Timed run`,`Esecuzione a tempo`),order:2150}},HI=[`on`,`off`,`running`,`idle`,`standby`,`alert`,`offline`,`unknown`],UI=[`success`,`warning`,`danger`,`primary`,`info`,`muted`],WI=[`none`,`pulse`,`spin`,`glow`,`halo`,`wave`,`rise`,`fall`,`tumble`,`equalizer`,`blink`,`breathe`],GI=[`plain`,`heat-rise`,`cool-fall`,`glow`,`water`,`drum`,`sky`,`mist`,`alert-wash`],KI=x(HI),qI=x(UI),Lwe=x(WI),JI=b({icon:Ih,tone:qI,background:x(GI),animation:Lwe});function YI(e){let t=pO[e];return t===void 0?null:`cap:${e}.${t.field}`}function Rwe(e){return e.enabledCaps.flatMap(e=>{let t=YI(e),n=pO[e];return t===null||n===void 0?[]:[{key:t,priority:n.priority}]}).sort((e,t)=>t.priority-e.priority).find(t=>e.hasData(t.key))?.key??null}var XI=b({en:l(),it:l()}),ZI={en:`—`,it:`—`};function zwe(e){return e.en===ZI.en&&e.it===ZI.it}var QI=[`temperature`,`humidity`,`power`,`contact`,`text`],$I=[`hot`,`mild`,`cold`],eL=[`updated`,`changed`],tL=b({value:n(),quantity:da}),nL=b({quantity:x(QI),reading:tL.nullable(),icon:Ih.nullable(),value:XI,unit:l().nullable(),band:x($I).nullable(),level:n().min(0).max(1).nullable(),word:XI,tone:x(UI),since:n().nullable(),sinceKind:x(eL),historyKey:l().nullable()}),Bwe=3e3,rL=e=>P(e,e),iL=e=>Math.min(1,Math.max(0,e)),Vwe=(e,t)=>String(Number(e.toFixed(t)));function aL(e){return e<12?`cold`:e>28?`hot`:`mild`}var Hwe={hot:P(`Hot`,`Caldo`),mild:P(`Normal`,`Normale`),cold:P(`Cold`,`Freddo`)},Uwe={hot:`warning`,mild:`muted`,cold:`info`};function oL(e,t){let n=aL(e);return{quantity:`temperature`,reading:{value:e,quantity:`temperature`},icon:`thermometer`,value:rL(Vwe(e,1)),unit:`°C`,band:n,level:null,word:Hwe[n],tone:Uwe[n],since:t,sinceKind:`updated`,historyKey:YI(`temperature-sensor`)}}function sL(e,t){let n=e<30,r=e>70;return{quantity:`humidity`,reading:{value:e,quantity:`humidity`},icon:`droplets`,value:rL(String(Math.round(e))),unit:`%`,band:null,level:iL(e/100),word:n?P(`Dry`,`Secco`):r?P(`Humid`,`Umido`):P(`Normal`,`Normale`),tone:n||r?`warning`:`info`,since:t,sinceKind:`updated`,historyKey:YI(`humidity-sensor`)}}function cL(e,t){let n=e>0;return{quantity:`power`,reading:{value:e,quantity:`power`},icon:`zap`,value:rL(String(Math.round(e))),unit:`W`,band:null,level:iL(e/Bwe),word:n?P(`Active`,`Attivo`):P(`Idle`,`Inattivo`),tone:n?`primary`:`muted`,since:t,sinceKind:`updated`,historyKey:YI(`power-meter`)}}function lL(e,t){return{quantity:`contact`,reading:null,icon:e?`door-open`:`door-closed`,value:e?P(`Open`,`Aperto`):P(`Closed`,`Chiuso`),unit:null,band:null,level:+!!e,word:e?P(`Open`,`Aperto`):P(`Closed`,`Chiuso`),tone:e?`warning`:`success`,since:t,sinceKind:`changed`,historyKey:null}}function uL(e,t){return{quantity:`text`,reading:null,icon:null,value:rL(e),unit:null,band:null,level:null,word:P(`Changed`,`Cambiato`),tone:`muted`,since:t,sinceKind:`updated`,historyKey:null}}var Wwe={temperature:{icon:`thermometer`,unit:`°C`,sinceKind:`updated`,historyKey:YI(`temperature-sensor`)},humidity:{icon:`droplets`,unit:`%`,sinceKind:`updated`,historyKey:YI(`humidity-sensor`)},power:{icon:`zap`,unit:`W`,sinceKind:`updated`,historyKey:YI(`power-meter`)},contact:{icon:null,unit:null,sinceKind:`changed`,historyKey:null},text:{icon:null,unit:null,sinceKind:`updated`,historyKey:null}};function dL(e){let t=Wwe[e];return{quantity:e,reading:null,icon:t.icon,value:ZI,unit:t.unit,band:null,level:null,word:ZI,tone:`muted`,since:null,sinceKind:t.sinceKind,historyKey:t.historyKey}}var Gwe={power:new Set([`energy-sensor`,`voltage-sensor`,`current-sensor`])};function fL(e,t){return t===null?!0:!(Gwe[e.quantity]?.has(t)??!1)}var pL=`ac.thermostat.heater.heat-pump.fan.washer.dryer.dishwasher.pet-fountain.pet-feeder.vacuum.lawn-mower.tv.speaker.camera.light.cover.lock.alarm.siren.sensor-sparkline.contact.presence.weather.plug.button.update.control-dial.event-stream.gateway.generic`.split(`.`),Kwe=x(pL),mL=[`cool`,`heat`,`dry`,`fan`,`auto`,`playing`,`paused`,`open`,`closed`],hL=b({id:Kwe,mode:x(mL).nullable(),level:n().min(0).max(1).nullable()}),gL={[T.Camera]:`camera`,[T.Light]:`light`,[T.Siren]:`siren`,[T.Switch]:`plug`,[T.Sensor]:`sensor-sparkline`,[T.Climate]:`thermostat`,[T.Button]:`button`,[T.EventEmitter]:`event-stream`,[T.Update]:`update`,[T.Generic]:`generic`,[T.Notifier]:`event-stream`,[T.Script]:`event-stream`,[T.Automation]:`event-stream`,[T.Lock]:`lock`,[T.Cover]:`cover`,[T.Valve]:`control-dial`,[T.Humidifier]:`control-dial`,[T.WaterHeater]:`heater`,[T.HeatPump]:`heat-pump`,[T.EnergySystem]:`generic`,[T.Workload]:`generic`,[T.Fan]:`fan`,[T.MediaPlayer]:`tv`,[T.AlarmPanel]:`alarm`,[T.Control]:`control-dial`,[T.Presence]:`presence`,[T.Weather]:`weather`,[T.WeatherStation]:`weather`,[T.Vacuum]:`vacuum`,[T.LawnMower]:`lawn-mower`,[T.Container]:`generic`,[T.Image]:`camera`,[T.PetFeeder]:`pet-feeder`,[T.PetFountain]:`pet-fountain`,[T.Dishwasher]:`dishwasher`,[T.Washer]:`washer`,[T.Dryer]:`dryer`,[T.Gateway]:`gateway`},_L={[D.Siren]:`siren`,[D.Floodlight]:`light`,[D.Spotlight]:`light`,[D.PirSensor]:`presence`,[D.Chime]:`speaker`,[D.Autotrack]:`inherit`,[D.Nightvision]:`inherit`,[D.PrivacyMask]:`inherit`,[D.Doorbell]:`inherit`,[D.CoverBlind]:`inherit`,[D.CoverShutter]:`inherit`,[D.CoverAwning]:`inherit`,[D.CoverCurtain]:`inherit`,[D.CoverGarage]:`inherit`,[D.CoverGate]:`inherit`,[D.CoverDoor]:`inherit`,[D.CoverWindow]:`inherit`,[D.BinaryHelper]:`inherit`,[D.Outlet]:`plug`,[D.SwitchHeater]:`heater`,[D.SwitchFan]:`fan`,[D.SwitchLight]:`light`,[D.PoePort]:`plug`,[D.ClimateAc]:`ac`,[D.ClimateThermostat]:`inherit`,[D.ClimateFloor]:`inherit`,[D.ClimateRadiator]:`inherit`,[D.ClimateHeater]:`inherit`,[D.ClimateHeatPumpCircuit]:`inherit`,[D.MotionSensor]:`presence`,[D.ContactSensor]:`contact`,[D.LeakSensor]:`inherit`,[D.SmokeSensor]:`alarm`,[D.COSensor]:`alarm`,[D.GasSensor]:`alarm`,[D.TamperSensor]:`inherit`,[D.VibrationSensor]:`inherit`,[D.ConnectivitySensor]:`inherit`,[D.SoundSensor]:`inherit`,[D.BinarySensor]:`inherit`,[D.TemperatureSensor]:`sensor-sparkline`,[D.HumiditySensor]:`sensor-sparkline`,[D.AmbientLightSensor]:`inherit`,[D.PressureSensor]:`weather`,[D.WindSensor]:`weather`,[D.RainSensor]:`weather`,[D.UvSensor]:`weather`,[D.SolarRadiationSensor]:`weather`,[D.SoilMoistureSensor]:`inherit`,[D.PowerSensor]:`plug`,[D.EnergySensor]:`plug`,[D.VoltageSensor]:`plug`,[D.CurrentSensor]:`plug`,[D.AirQualitySensor]:`inherit`,[D.BatterySensor]:`inherit`,[D.NumericSensor]:`inherit`,[D.EnumSensor]:`inherit`,[D.DateTimeSensor]:`inherit`,[D.GenericSensor]:`inherit`,[D.NumericControl]:`control-dial`,[D.SelectControl]:`control-dial`,[D.TextControl]:`inherit`,[D.DateTimeControl]:`inherit`,[D.MobilePushNotifier]:`inherit`,[D.MessagingNotifier]:`inherit`,[D.EmailNotifier]:`inherit`,[D.GenericNotifier]:`inherit`,[D.IrTransmitter]:`inherit`,[D.Vm]:`inherit`,[D.AppContainer]:`inherit`,[D.Lxc]:`inherit`,[D.App]:`inherit`,[D.Host]:`inherit`,[D.Ups]:`inherit`};function qwe(e){return Object.values(T).includes(e)}function Jwe(e){return Object.values(D).includes(e)}function vL(e,t){let n=e!==null&&Jwe(e)?_L[e]:void 0;return n!==void 0&&n!==`inherit`?n:qwe(t)?gL[t]:`generic`}var yL=`progress.run-for.cycle.program.appliance-power.now-playing.playback.volume.source.contact.motion-trigger.lock.alarm.fan.vacuum.vacuum-suction.mower.feeder.fountain.pump-cycle.automation.script.do-not-disturb.brightness.color.cover.valve.humidifier.update.button.climate-mode.climate-fan.setpoint.channel.control.circuit.heat-pump-power.system-mode`.split(`.`),bL=x(yL),Ywe={progress:P(`Progress`,`Avanzamento`),"run-for":P(`Run for`,`Avvia per`),cycle:P(`Cycle`,`Ciclo`),program:P(`Program`,`Programma`),"appliance-power":P(`Appliance`,`Elettrodomestico`),"now-playing":P(`Now playing`,`In riproduzione`),playback:P(`Playback`,`Riproduzione`),volume:P(`Volume`,`Volume`),source:P(`Source`,`Sorgente`),contact:P(`Door`,`Porta`),"motion-trigger":P(`Motion`,`Movimento`),lock:P(`Lock`,`Serratura`),alarm:P(`Alarm`,`Allarme`),fan:P(`Fan`,`Ventola`),vacuum:P(`Cleaning`,`Pulizia`),"vacuum-suction":P(`Suction`,`Aspirazione`),mower:P(`Mowing`,`Taglio`),feeder:P(`Feed now`,`Eroga ora`),fountain:P(`Pump`,`Pompa`),"pump-cycle":P(`Pump cycle`,`Ciclo pompa`),automation:P(`Automation`,`Automazione`),script:P(`Script`,`Script`),"do-not-disturb":P(`Do not disturb`,`Non disturbare`),brightness:P(`Brightness`,`Luminosità`),color:P(`Colour`,`Colore`),cover:P(`Position`,`Posizione`),valve:P(`Valve`,`Valvola`),humidifier:P(`Humidifier`,`Umidificatore`),update:P(`Firmware`,`Firmware`),button:P(`Action`,`Azione`),"climate-mode":P(`Mode`,`Modalità`),"climate-fan":P(`Fan`,`Ventola`),setpoint:P(`Setpoint`,`Temperatura`),channel:P(`Channel`,`Canale`),control:P(`Control`,`Controllo`),circuit:P(`Circuit`,`Circuito`),"heat-pump-power":P(`Power`,`Potenza`),"system-mode":P(`Mode`,`Modalità`)},xL=a(()=>h([l(),n(),v(),m(l(),xL)])),Xwe=m(l(),xL);function SL(e,t,n){let[r,...i]=t;if(r===void 0)return e;if(i.length===0)return{...e,[r]:n};let a=e[r],o=typeof a==`object`?a:{};return{...e,[r]:SL(o,i,n)}}function Zwe(e,t,n){return SL(e,t.split(`.`),n)}var CL=b({cap:l(),method:l(),args:Xwe}),Qwe=x([`off-while-running`,`unlock`,`install`,`press`]),wL=b({id:l(),label:XI,icon:Ih,call:CL,emphasis:x([`primary`,`normal`]),confirm:Qwe.nullable()}),TL=i(`kind`,[b({kind:p(`action`),action:wL}),b({kind:p(`toggle`),id:l(),label:XI,on:v().nullable(),turnOn:wL,turnOff:wL}),b({kind:p(`slider`),id:l(),label:XI,value:n().nullable(),min:n(),max:n(),step:n(),unit:l(),call:CL,valueArg:l()}),b({kind:p(`picker`),id:l(),label:XI,current:l().nullable(),options:S(l()),optionLabels:m(l(),XI).optional(),call:CL,valueArg:l()}),b({kind:p(`number`),id:l(),label:XI,value:n().nullable(),step:n().nullable(),unit:l(),call:CL,valueArg:l()}),b({kind:p(`text`),id:l(),label:XI,value:l().nullable(),call:CL,valueArg:l()})]),$we=b({icon:Ih.nullable(),text:XI,tone:qI}),eTe=new Set([`cover`,`valve`,`lock`,`vacuum`,`playback`,`brightness`]),tTe=b({id:bL,placement:x([`row`,`scene`]).optional(),label:XI.optional(),group:XI.optional(),pills:S($we).optional(),icon:Ih,status:XI.nullable(),controls:S(TL),progress:n().min(0).max(1).nullable().optional()}),EL=b({label:XI,value:h([n(),l()]),unit:l().nullable()}),nTe=b({id:x([`battery`,`network-link`,`integration`]),icon:Ih,tone:qI,value:n().nullable(),label:XI}),DL=`remote.open`,rTe=b({commands:n().int().nullable(),open:wL.optional()}),iTe=b({items:S(b({key:l(),label:l(),level:n().nullable(),needsAttention:v()})),attention:n().int()}),aTe=i(`kind`,[b({kind:p(`power`),watts:n(),detail:S(EL)}),b({kind:p(`running`),running:v().nullable(),since:n().nullable(),phase:l().nullable(),detail:S(EL)})]),oTe=b({source:x([`switch`,`media-player`,`climate-control`]),on:v().nullable(),assumed:v(),turnOn:wL,turnOff:wL}),sTe=b({activeUntil:n().nullable(),quickRun:PI,run:wL,cancel:wL,remaining:n().nullable()}),cTe=b({on:v().nullable(),confirmOffWhileRunning:v(),running:v().nullable(),powerOn:wL.nullable(),powerOff:wL.nullable(),restart:wL}),OL=b({token:x(GI),animation:x(WI)}),kL=b({id:x([`power`,`energy`,`battery`,`link`,`phase`,`remaining`,`volume`,`source`,`consumables`,`since`,`speed`,`progress`,`level`,`last-run`,`event`,`members`,`failures`,`reading`,`climate`,`temperature`,`humidity`,`pressure`,`air-quality`,`illuminance`,`valve`]),icon:Ih.nullable(),text:XI,tone:qI}),AL=b({label:XI,value:XI,tone:qI.optional(),at:n().optional()}),lTe=b({left:S(AL).max(2),right:S(AL).max(2)}),uTe=i(`kind`,[b({kind:p(`artwork`),url:l(),fallback:OL}),b({kind:p(`state`),...OL.shape})]),dTe=b({partId:l(),cap:l()}),fTe=b({deviceId:n().int(),type:l(),role:l().nullable(),name:l(),state:KI,stateAssumed:v(),look:JI,background:uTe,scene:hL,facts:S(kL),sideTiles:lTe,title:XI,caption:XI.optional(),badges:S(nTe),remote:rTe.nullable(),historyLabel:XI,consumables:iTe.nullable(),consumption:aTe.nullable(),ownPower:oTe.nullable(),timedRun:sTe.nullable(),powerSupply:cTe.nullable(),rows:S(tTe),measurement:nL.optional(),gated:S(l()),provenance:S(dTe)}),pTe=b({id:x([`timed-run.run`,`timed-run.cancel`]),duration:n(),unit:x([`min`,`s`])}),jL=b({deviceId:n().int(),name:l(),type:l(),state:KI,stateAssumed:v(),look:JI,scene:hL,statusLine:S(XI),primary:TL.nullable(),primaryGated:v().optional(),timedRun:pTe.nullable(),extras:S(TL).max(2).optional(),trailing:kL.nullable(),measurement:nL.optional()}),ML=[`temperature`,`humidity`,`pressure`,`illuminance`,`reading`,`air-quality`,`valve`],mTe=[`power`,`battery`,`consumables`],hTe=new Set(ML);function gTe(e){for(let t of mTe){let n=e.facts.find(e=>e.id===t);if(n!==void 0)return n}return e.facts.find(t=>hTe.has(t.id)&&t.text.en===e.title.en)??null}var _Te={[T.Climate]:`climate.mode`};function vTe(e){let t=_Te[e.type];if(t!==void 0){let n=PL(e,t);if(n!==null)return{control:n,gated:!1}}let n=e.ownPower;if(n!==null)return e.gated.includes(`own-power`)?{control:null,gated:!0}:{control:{kind:`toggle`,id:`own-power`,label:n.turnOn.label,on:n.on,turnOn:n.turnOn,turnOff:n.turnOff},gated:!1};for(let t of e.rows){let n=t.controls[0];if(n!==void 0)return e.gated.includes(t.id)?{control:null,gated:!0}:{control:n,gated:!1}}return{control:null,gated:!1}}var yTe={[T.Climate]:[`climate.target`],[T.Vacuum]:[`vacuum.base`],[T.LawnMower]:[`mower.dock`],[T.MediaPlayer]:[`volume.level`,DL],[T.Automation]:[`automation.enabled`]},NL=e=>e.kind===`action`?e.action.id:e.id;function PL(e,t){if(t===`remote.open`){let t=e.remote?.open;return t===void 0||e.gated.includes(`remote`)?null:{kind:`action`,action:t}}for(let n of e.rows){if(e.gated.includes(n.id))continue;let r=n.controls.find(e=>NL(e)===t);if(r!==void 0)return r}return null}function bTe(e,t){let n=yTe[e.type]??[],r=t===null?null:NL(t);return n.filter(e=>e!==r).flatMap(t=>{let n=PL(e,t);return n===null?[]:[n]}).slice(0,2)}function xTe(e,t){let n=e.rows.find(e=>e.id===`now-playing`)?.status??null??e.title,r=e.facts.filter(e=>e!==t).map(e=>e.text).slice(0,3),i=e.timedRun;if(i===null||i.remaining===null)return[n,...r];let a=i.quickRun.unit===`min`?`min`:`s`,o={en:`${i.remaining} ${a}`,it:`${i.remaining} ${a}`};return[n,...r,o]}function STe(e){let t=e.timedRun;return t===null||e.gated.includes(`timed-run`)?null:{id:t.activeUntil===null?`timed-run.run`:`timed-run.cancel`,duration:t.quickRun.duration,unit:t.quickRun.unit}}function CTe(e){let t=gTe(e),{control:n,gated:r}=vTe(e);return{deviceId:e.deviceId,name:e.name,type:e.type,state:e.state,stateAssumed:e.stateAssumed,look:e.look,scene:e.scene,statusLine:xTe(e,t),primary:n,primaryGated:r,timedRun:STe(e),extras:bTe(e,n),trailing:t,...e.measurement===void 0?{}:{measurement:e.measurement}}}var wTe=b({deviceId:n().int().nonnegative(),canActuate:v().optional()}),TTe=500,ETe=b({deviceIds:S(n().int().nonnegative()).max(500),canActuate:v().optional()}),FL=b({type:l(),rows:S(bL)}),IL={name:`hero-layout`,scope:`system`,mode:`singleton`,methods:{getHeroModel:k(wTe,fTe.nullable(),{auth:`protected`,role:`viewer`}),getRowModels:k(ETe,S(jL.nullable()),{auth:`protected`,role:`viewer`}),getLayout:k(b({deviceType:l(),role:l().nullable().optional()}),FL,{auth:`protected`,role:`viewer`})},vocabulary:{notOperatorFacing:`the device hero model — read-only data the UI draws, never actuated`}},LL=b({on:v(),currentHumidity:n().min(0).max(100).nullable().meta(M(`humidity`)),targetHumidity:n().min(0).max(100).nullable().meta(M(`humidity`)),mode:l().nullable(),availableModes:S(l()),action:l().nullable(),minHumidity:n().nullable().meta(M(`humidity`)),maxHumidity:n().nullable().meta(M(`humidity`)),lastChangedAt:n()}),RL={name:`humidifier`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Humidifier],power:{kind:`field`,field:`on`,set:`setOn`},methods:{setOn:k(b({deviceId:n().int().nonnegative(),on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.on`,label:P(`Humidifier on`,`Umidificatore acceso`),phrase:P(`Turn on {device}`,`Accendi {device}`),icon:`power`,effect:{field:`on`,value:!0},args:{on:!0}},{id:`humidifier.off`,label:P(`Humidifier off`,`Umidificatore spento`),phrase:P(`Turn off {device}`,`Spegni {device}`),icon:`power-off`,effect:{field:`on`,value:!1},args:{on:!1}}]}),setTargetHumidity:k(b({deviceId:n().int().nonnegative(),humidity:n().min(0).max(100)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.target`,label:P(`Set humidity`,`Imposta l’umidità`),phrase:P(`Set {device} to {humidity} humidity`,`Imposta {device} al {humidity} di umidità`),icon:`droplets`,effect:{field:`targetHumidity`,fromArg:`humidity`},openArgs:[{key:`humidity`,label:P(`Humidity`,`Umidità`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setMode:k(b({deviceId:n().int().nonnegative(),mode:l().min(1)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.mode`,label:P(`Set mode`,`Imposta la modalità`),phrase:P(`Set {device} to {mode}`,`Imposta {device} su {mode}`),icon:`list`,effect:{field:`mode`,fromArg:`mode`},openArgs:[{key:`mode`,label:P(`Mode`,`Modalità`),offer:{kind:`dynamic`,from:`status`,field:`availableModes`}}]}]})},status:{schema:LL,kind:`push`},runtimeState:LL,durability:`session`,history:{fields:{currentHumidity:{kind:`gauge`,unit:`%`,deadband:.5},on:{kind:`boolean`}}},vocabulary:{noun:P(`Humidifier`,`Umidificatore`),order:1090,state:[{kind:`boolean`,field:`on`,label:P(`On`,`Acceso`),whenTrue:P(`When {device} turns on`,`Quando {device} si accende`),whenFalse:P(`When {device} turns off`,`Quando {device} si spegne`),icon:`power`},{kind:`numeric`,field:`currentHumidity`,quantity:P(`the humidity`,`l’umidità`),label:P(`Humidity`,`Umidità`),unit:`%`,icon:`droplets`}]}},zL=b({humidity:n().min(0).max(100).nullable().meta(M(`humidity`,{precision:0,label:`Humidity`})),lastFetchedAt:n()}),BL={name:`humidity-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Sensor,T.Climate],methods:{},status:{schema:zL,kind:`push`},runtimeState:zL,durability:`restored`,history:{primary:`humidity`,priority:90,fields:{humidity:{kind:`gauge`,unit:`%`,deadband:.5}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:P(`Humidity`,`Umidità`),order:5120,state:[{kind:`numeric`,field:`humidity`,quantity:P(`the humidity`,`l’umidità`),label:P(`Humidity`,`Umidità`),unit:`%`,icon:`droplets`}]}},VL=b({url:l().nullable(),lastUpdated:n().nullable().meta(M(`none`))}),HL={name:`image`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Image],methods:{},status:{schema:VL,kind:`push`},runtimeState:VL,durability:`session`,history:`none`,vocabulary:{noun:P(`Image`,`Immagine`),order:3130}},UL=x([`0`,`90`,`180`,`270`]),WL=x([`auto`,`manual`]),GL=x([`auto`,`manual`]),KL=x([`off`,`blc`,`wdr`,`hlc`]),qL=b({min:n(),max:n(),step:n()}),JL=b({brightness:n().optional().meta(M(`none`)),contrast:n().optional().meta(M(`none`)),saturation:n().optional().meta(M(`none`)),sharpness:n().optional().meta(M(`none`)),mirror:v().optional(),flip:v().optional(),rotate:UL.optional(),whiteBalance:WL.optional(),warmth:n().optional().meta(M(`none`)),exposureMode:GL.optional(),backlightMode:KL.optional(),lastFetchedAt:n()}),YL=b({supportsBrightness:v(),brightness:qL.optional(),supportsContrast:v(),contrast:qL.optional(),supportsSaturation:v(),saturation:qL.optional(),supportsSharpness:v(),sharpness:qL.optional(),supportsMirror:v(),supportsFlip:v(),rotateOptions:S(UL),whiteBalanceModes:S(WL),supportsWarmth:v(),warmth:qL.optional(),exposureModes:S(GL),backlightModes:S(KL)}),XL=b({brightness:n().optional(),contrast:n().optional(),saturation:n().optional(),sharpness:n().optional(),mirror:v().optional(),flip:v().optional(),rotate:UL.optional(),whiteBalance:WL.optional(),warmth:n().optional(),exposureMode:GL.optional(),backlightMode:KL.optional()}),ZL={name:`image-settings`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Camera],deviceConfig:{ui:{kind:`derived-form`,builderId:`image-settings`,tab:`image`}},methods:{getOptions:k(b({deviceId:n()}),YL),setSettings:k(b({deviceId:n(),settings:XL}),_(),{kind:`mutation`,auth:`admin`})},status:{schema:JL,kind:`poll`},runtimeState:JL,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:P(`Image settings`,`Impostazioni immagine`),order:3140}},QL=b({id:l(),addonId:l(),name:l(),enabled:v(),info:m(l(),C()).readonly(),originStableId:l().optional(),createdAt:n(),updatedAt:n(),processState:l()}),$L=b({id:l(),addonId:l(),name:l(),enabled:v(),info:m(l(),C()).readonly(),originStableId:l().optional(),createdAt:n(),updatedAt:n()}),eR=b({addonId:l(),name:l(),providerLabel:l().optional(),description:l(),iconUrl:l().nullable(),color:l(),instanceMode:l(),mode:x([`standalone`,`account`,`broker`]),discoveryMode:l(),kind:x([`device-adoption`,`device-provider`]),brokerKind:l().nullable(),supportsLocationImport:v(),canTest:v(),existingInstances:S(b({id:l(),name:l()})),canAdd:v()}),tR=x([`validated`,`rejected`,`inconclusive`,`unsupported`]),nR=b({success:v(),error:l().optional(),status:tR.optional(),testedBy:l().nullable().optional(),latencyMs:n().nonnegative().optional(),detail:l().optional()}),rR=b({id:l(),name:l().optional(),enabled:v().optional(),info:m(l(),C()).optional()}),iR=b({success:v(),deletedId:l()}),aR={name:`integrations`,scope:`system`,mode:`singleton`,methods:{list:k(_(),S(QL)),get:k(b({id:l()}),QL),getByAddonId:k(b({addonId:l()}),$L.nullable()),listByAddon:k(b({addonId:l()}),S($L)),adoptInstanceRows:k(b({addonId:l(),rows:S(b({id:l().min(1),name:l(),enabled:v(),stated:v()}))}),b({created:n().int(),updated:n().int(),conflicts:S(b({id:l(),ownerAddonId:l()}))}),{kind:`mutation`,auth:`admin`}),update:k(rR,$L,{kind:`mutation`,auth:`admin`}),delete:k(b({id:l()}),iR,{kind:`mutation`,auth:`admin`}),getAvailableTypes:k(_(),S(eR),{auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:j.ADDON_ADMIN}},DTe=ye(),oR=l().min(1),sR=x([`single`,`multiple`]),cR=x([`devices`,`services`]),lR=b({id:l().min(1),label:l().min(1),functionCap:l().min(1),brokerKind:l().min(1).optional(),alsoServes:S(l().min(1)).optional(),iconUrl:l().min(1).optional(),iconMediaType:l().min(1).optional(),role:cR.optional(),canTest:v().optional(),signIn:b({basePath:l().min(1),methods:S(x([`device-code`,`proxy`])).optional()}).optional(),connectPath:l().min(1).optional(),disconnectPath:l().min(1).optional(),widgets:S(b({id:l().min(1),placement:x([`connection`,`model`])})).optional()}),uR=b({mode:x([`none`,`lan`,`account`]),scopedToInstance:v()}),dR=b({kind:l().min(1),field:l().min(1),to:b({cap:l().min(1),kind:l().min(1).optional()})}),fR=b({role:cR,discovery:uR.optional(),instanceMode:sR,kind:l(),canTest:v(),kinds:S(lR).min(1),allowRestoreId:v().optional(),mintsId:v().optional(),links:S(dR).optional(),userScoped:v().optional()}),pR=b({state:x([`ok`,`off`,`error`,`unknown`]),detail:l().optional(),label:l().optional()}),mR=x([`scan`,`children`,`none`]),hR=b({id:oR,name:l(),configured:v(),enabled:v().optional(),kind:l().min(1),formValues:m(l(),C()),status:pR.optional(),lastCheckedAt:n().optional(),addDevice:mR.optional()}),gR=b({id:oR,name:l().min(1).optional(),values:m(l(),C())}),_R={name:`integration-instances`,scope:`system`,mode:`collection`,methods:{describe:k(_(),fR,{auth:`admin`}),instanceFormSchema:k(b({id:oR.nullable(),kind:l().min(1).optional(),mode:x([`standalone`,`account`,`broker`]).optional(),candidateStableId:l().min(1).optional()}),DTe,{auth:`admin`}),listInstances:k(ce({}),S(hR).readonly(),{auth:`protected`,caller:`scoped`}),getInstance:k(b({id:oR}),hR.nullable(),{auth:`protected`,caller:`scoped`}),createInstance:k(b({id:oR.optional(),name:l().min(1),kind:l().min(1).optional(),values:m(l(),C()).optional(),originStableId:l().min(1).optional(),seed:b({info:m(l(),C())}).optional()}),b({id:l()}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),updateInstance:k(gR,b({ok:p(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),setInstanceEnabled:k(b({id:oR,enabled:v()}),b({ok:p(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),deleteInstance:k(b({id:oR}),b({ok:p(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),testInstance:A(b({id:oR.nullable(),values:m(l(),C()),kind:l().min(1).optional()}),nR,{kind:`mutation`,auth:`protected`,caller:`scoped`})},vocabulary:{notOperatorFacing:j.INTERNAL}},vR=b({codecs:S(l()),sampleRate:n().meta(M(`none`)),duplex:x([`half`,`full`]),maxBacklogMs:n().meta(M(`duration-ms`))}),yR=b({talking:v(),lastSessionAt:n().nullable(),ability:vR.nullable()}),OTe=x([`opus`,`s16le`,`g711ulaw`,`g711alaw`]),bR={name:`intercom`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Camera],methods:{startSession:k(b({deviceId:n()}),b({sessionId:l(),sdpOffer:l()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),handleAnswer:k(b({deviceId:n(),sessionId:l(),sdpAnswer:l()}),_(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),stopSession:k(b({deviceId:n(),sessionId:l()}),_(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),startTalkSession:k(b({deviceId:n()}),b({sessionId:l()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`two-way talk is a person speaking through the viewer, not an automation step`}),pushTalkAudio:k(b({deviceId:n(),audioBase64:l(),codec:OTe.optional(),sampleRate:n().int().positive().optional(),channels:n().int().positive().optional(),sequenceNumber:n().int()}),b({accepted:v()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),endTalkSession:k(b({deviceId:n()}),_(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`})},events:{onStatusChanged:{data:b({deviceId:n(),status:yR}),notOperatorFacing:"the `talking` state trigger phrases both edges of this change"}},status:{schema:yR,kind:`command-driven`},runtimeState:yR,durability:`session`,history:`none`,vocabulary:{noun:P(`Intercom`,`Citofono`),order:3150,state:[{kind:`boolean`,field:`talking`,label:P(`Talking`,`In conversazione`),whenTrue:P(`When someone starts talking through {device}`,`Quando qualcuno inizia a parlare tramite {device}`),whenFalse:P(`When the conversation on {device} ends`,`Quando la conversazione su {device} finisce`),icon:`mic`}]}},xR=x([`carrierHz`,`dutyCyclePercent`,`repeat`,`repeatDelayMs`]),SR=x([`ir`,`rf`]),CR=b({ok:p(!0),ignoredSettings:S(l())}),wR=b({media:S(SR),settable:S(xR),maxTimings:n().int().positive(),learn:v().default(!1),formats:S(VE).default([])}),TR=2e4,ER=6e4,DR=b({native:UE.nullable(),timings:ME,carrierHz:n().int().positive().nullable()}),OR=b({at:n(),ok:v(),error:l().nullable()}),kR=OR.extend({medium:SR}),AR=b({lastSend:kR.nullable(),lastLearn:OR.nullable(),lastFetchedAt:n()});function jR(e){return!(e.kind===`learn`&&e.error===`ir-transmitter.learn-unsupported`)}function kTe(e,t,n){let r=e??{lastSend:null,lastLearn:null,lastFetchedAt:n};return jR(t)?t.kind===`send`?{lastSend:{at:n,ok:t.ok,error:t.error,medium:t.medium},lastLearn:r.lastLearn,lastFetchedAt:n}:{lastSend:r.lastSend,lastLearn:{at:n,ok:t.ok,error:t.error},lastFetchedAt:n}:r}function ATe(e){return Xr(e)?.code??null}var MR={name:`ir-transmitter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Generic],methods:{send:k(b({deviceId:n().int().nonnegative(),timings:ME.optional(),native:UE.optional(),settings:NE.optional()}).refine(e=>e.timings===void 0!=(e.native===void 0),{message:`send takes exactly one of timings or native`}),CR,{kind:`mutation`,auth:`protected`,notOperatorFacing:`a raw pulse train is not something an operator composes in an automation; the remote that owns the command table sends it`}),learn:k(b({deviceId:n().int().nonnegative(),timeoutMs:n().int().positive().max(ER).default(TR)}),DR,{kind:`mutation`,auth:`protected`,notOperatorFacing:`an interactive capture the operator starts from the source dialog and answers by pressing a physical remote; no automation can supply the signal`}),getInfo:k(b({deviceId:n().int().nonnegative()}),wR,{kind:`query`,auth:`protected`})},runtimeState:AR,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:P(`IR / RF transmitter`,`Trasmettitore IR / RF`),order:1140}},NR=x([`key-missing`,`wrong-key`,`key-file-unreadable`,`store-unavailable`,`not-initialized`,`decrypt-failed`]),PR=i(`state`,[b({state:p(`ready`)}),b({state:p(`locked`),reason:NR})]),FR=i(`kind`,[b({kind:p(`value`),value:l(),version:n().int()}),b({kind:p(`missing`)}),b({kind:p(`unavailable`),reason:NR}),b({kind:p(`forbidden`)})]),IR=m(l(),FR),LR=b({ref:l(),owner:l(),scope:l(),fieldPath:l(),version:n().int(),createdAt:n(),updatedAt:n(),updatedBy:l(),lastReadAt:n().nullable()}),jTe=512,RR=S(l().min(1)).max(512),zR={name:`keychain`,scope:`system`,mode:`singleton`,internal:!0,methods:{put:k(b({ref:l().min(1),value:l().min(1)}),b({ref:l(),version:n().int()}),{kind:`mutation`,auth:`admin`}),resolve:k(b({refs:RR}),IR,{auth:`admin`}),delete:k(b({refs:RR}),b({deleted:n().int()}),{kind:`mutation`,auth:`admin`}),deleteDeviceScope:k(b({deviceId:n().int()}),b({refs:S(l()).readonly()}),{kind:`mutation`,auth:`admin`}),releaseRecordRefs:k(b({refs:RR,onBehalfOf:l().min(1)}),b({released:n().int()}),{kind:`mutation`,auth:`admin`}),listMeta:k(b({}),S(LR).readonly(),{auth:`admin`}),getState:k(b({}),PR,{auth:`admin`})},vocabulary:{notOperatorFacing:j.IDENTITY}},BR=x([`mounted-file`,`previous-mounted-file`,`platform`,`default-file`]),VR=b({kind:BR,path:l().optional(),sharesBackupWithDatabase:v()}),MTe=`trigger-file`,HR=b({id:l(),at:n(),actor:l(),lockedReason:l().nullable(),archived:n().int(),archivedCollection:l().nullable(),archivedKeysCollection:l().nullable(),clearedSettingsKeys:S(l()).readonly(),acknowledgedAt:n().nullable()}),UR=b({keychain:PR,keySource:VR.nullable(),configuredSource:VR,fingerprint:l().nullable(),activeKeyId:l().nullable(),rotationPending:v(),retiredWraps:n().int(),recoveryKeyDownloadedAt:n().nullable(),secretCount:n().int(),lastReset:HR.nullable()}),WR=x([`in-use`,`orphan`,`unknown`]),GR=LR.extend({usage:WR}),KR=x([`put`,`delete`,`reveal`,`rotate-master-key`,`purge-retired-keys`,`download-recovery-key`,`delete-orphans`,`reset`,`acknowledge-reset`,`initialize`]),qR=b({id:l(),at:n(),action:KR,actor:l(),ref:l().nullable(),detail:l().nullable()}),JR=`RESET KEYCHAIN`,YR=x([`jwt-signing-key`]),XR={name:`keychain-admin`,scope:`system`,mode:`singleton`,methods:{status:k(b({}),UR,{auth:`admin`}),listSecrets:k(b({}),S(GR).readonly(),{auth:`admin`}),listAudit:k(b({limit:n().int().min(1).max(500).optional()}),S(qR).readonly(),{auth:`admin`}),reveal:k(b({ref:l().min(1)}),b({value:l(),version:n().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),setSystemSecret:k(b({name:YR,value:l().min(16)}),b({ref:l(),version:n().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),importSecret:k(b({ref:l().min(1),value:l().min(1)}),b({ref:l(),version:n().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),deleteOrphans:k(b({refs:S(l().min(1)).max(1e3)}),b({deleted:S(l()).readonly(),kept:S(b({ref:l(),usage:WR})).readonly()}),{kind:`mutation`,auth:`admin`,caller:`required`}),rotateMasterKey:k(b({}),b({fingerprint:l(),keySource:VR}),{kind:`mutation`,auth:`admin`,caller:`required`}),purgeRetiredKeys:k(b({}),b({purged:n().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),downloadRecoveryKey:k(b({}),b({key:l(),fingerprint:l(),keySource:VR}),{kind:`mutation`,auth:`admin`,caller:`required`}),resetKeychain:k(b({confirm:p(JR)}),b({archivedCollection:l().nullable(),archived:n().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),resetReport:k(b({}),b({reset:HR.nullable(),pendingReentry:S(LR).readonly()}),{auth:`admin`}),acknowledgeReset:k(b({}),b({acknowledged:v()}),{kind:`mutation`,auth:`admin`,caller:`required`})},vocabulary:{notOperatorFacing:j.IDENTITY}},ZR=x([`idle`,`mowing`,`paused`,`docked`,`error`]),QR=x([`info`,`warning`,`error`]),$R=b({activity:ZR,batteryLevel:n().min(0).max(100).nullable().meta(M(`percentage`)),progress:n().min(0).max(100).nullable().meta(M(`percentage`)),currentCode:n().nullable().meta(M(`none`)),currentCodeLabel:l().nullable(),severity:QR,lastChangedAt:n()}),ez={name:`lawn-mower-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.LawnMower],methods:{startMowing:k(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.start`,label:P(`Start mowing`,`Avvia il taglio`),phrase:P(`Start {device} mowing`,`Fai partire il taglio di {device}`),icon:`play`}]}),pause:k(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.pause`,label:P(`Pause mower`,`Metti in pausa il tosaerba`),phrase:P(`Pause {device}`,`Metti in pausa {device}`),icon:`pause`}]}),dock:k(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.dock`,label:P(`Dock mower`,`Riporta alla base`),phrase:P(`Send {device} back to its dock`,`Rimanda {device} alla base`),icon:`house`}]})},status:{schema:$R,kind:`push`},runtimeState:$R,durability:`session`,history:{fields:{batteryLevel:{kind:`gauge`,unit:`%`,deadband:2}}},vocabulary:{noun:P(`Robot mower`,`Robot tosaerba`),order:2010,state:[{kind:`enum`,field:`activity`,label:P(`Activity`,`Attività`),values:[{value:`idle`,label:P(`Idle`,`Inattivo`)},{value:`mowing`,label:P(`Mowing`,`In taglio`),phrase:P(`When {device} starts mowing`,`Quando {device} inizia a tagliare`)},{value:`paused`,label:P(`Paused`,`In pausa`)},{value:`docked`,label:P(`Docked`,`Alla base`),phrase:P(`When {device} docks`,`Quando {device} arriva alla base`)},{value:`error`,label:P(`Error`,`Errore`),phrase:P(`When {device} reports an error`,`Quando {device} segnala un errore`)}],icon:`bot`},{kind:`numeric`,field:`batteryLevel`,quantity:P(`the battery level`,`il livello della batteria`),label:P(`Battery`,`Batteria`),unit:`%`,icon:`battery`}]}},tz=6e5,NTe=60*6e4,nz=b({inputTokens:n(),outputTokens:n()}),rz=x([`timeout`,`rate-limited`,`auth`,`refusal`,`bad-request`,`unavailable`,`no-profile`,`budget-exceeded`,`adapter-error`]),iz=b({ok:p(!0),text:l(),model:l(),usage:nz,truncated:v(),latencyMs:n()}),az=x([`guardrail`,`model`]),oz=b({ok:p(!1),code:rz,message:l(),retryAfterMs:n().optional(),refusalSource:az.optional()}),sz=i(`ok`,[iz,oz]),cz=b({bytes:y(Uint8Array),mimeType:l()}),lz=b({enabled:v().default(!1),maxAttempts:n().int().min(1).max(5).default(1)}),PTe={totalMs:6e4,connectMs:1e4,firstTokenMs:12e4,idleMs:6e4},uz=b({addonId:l().optional(),profileId:l().optional(),consumer:l(),system:l().optional(),prompt:l(),jsonSchema:m(l(),C()).optional(),maxTokens:n().int().positive().optional(),temperature:n().optional(),topP:n().min(0).max(1).optional(),topK:n().int().positive().optional(),reasoningEffort:x([`off`,`low`,`medium`,`high`]).optional(),timeoutMs:n().int().positive().optional(),retry:lz.optional(),requestId:l().optional()}),dz=b({url:l(),filename:l(),sizeBytes:n(),sha256:l().optional()}),fz=i(`kind`,[b({kind:p(`catalog`),catalogId:l()}),b({kind:p(`url`),url:l(),sha256:l().optional(),label:l().optional(),sizeBytes:n().optional(),extraFiles:S(dz).optional()}),b({kind:p(`path`),path:l()})]),pz=b({nodeId:l(),engine:x([`llama-cpp`]),model:fz,contextSize:n().int().default(4096),gpuLayers:n().int().default(0),threads:n().int().optional(),parallel:n().int().default(1),batchSize:n().int().positive().optional(),ubatchSize:n().int().positive().optional(),flashAttention:v().default(!1),mlock:v().default(!1),noMmap:v().default(!1),cacheTypeK:x([`f32`,`f16`,`q8_0`,`q5_1`,`q5_0`,`q4_1`,`q4_0`]).optional(),cacheTypeV:x([`f32`,`f16`,`q8_0`,`q5_1`,`q5_0`,`q4_1`,`q4_0`]).optional(),extraArgs:S(l()).default([]),autoStart:v().default(!1),idleStopMinutes:n().int().default(30)}),mz=b({phase:x([`downloading`,`verifying`]),file:l(),fileIndex:n().int(),fileCount:n().int(),downloadedBytes:n(),totalBytes:n().optional()}),hz=b({nodeId:l(),state:x([`stopped`,`downloading`,`starting`,`ready`,`crashed`,`failed`]),pid:n().optional(),port:n().optional(),modelPath:l().optional(),modelId:l().optional(),downloadProgress:n().min(0).max(1).optional(),download:mz.optional(),lastError:l().optional(),crashesInWindow:n(),memoryBytes:n().optional(),vramBytes:n().optional()}),gz=b({file:l(),sizeBytes:n(),catalogId:l().optional(),installedAt:n().optional(),path:l().optional()}),_z=b({nodeId:l(),modelsBytes:n(),freeBytes:n().optional()}),vz=uz.extend({images:S(cz).optional(),runtime:pz,timeoutMs:n().int().positive().optional()}),yz=x([`deviceNotEligible`,`appleIntelligenceNotEnabled`,`modelNotReady`,`osTooOld`,`helperMissing`,`helperCrashed`]),bz=i(`state`,[b({state:p(`available`),osVersion:l(),contextSize:n().int().positive(),languages:S(l()),imageInput:v()}),b({state:p(`unavailable`),reason:yz,osVersion:l().nullable(),detail:l()}),b({state:p(`unsupported-platform`),platform:l()}),b({state:p(`unknown`),error:l()})]),xz=uz.extend({images:S(cz).optional(),timeoutMs:n().int().positive().optional()}),Sz=b({requestId:l()}),Cz={name:`llm-runtime`,scope:`system`,mode:`singleton`,internal:!0,methods:{complete:k(vz,sz,{kind:`mutation`,auth:`admin`,timeoutMs:tz}),ensureStarted:k(b({runtime:pz}),hz,{kind:`mutation`,auth:`admin`,timeoutMs:tz}),stop:k(b({}),_(),{kind:`mutation`,auth:`admin`}),status:k(b({}),hz,{auth:`admin`}),installModel:k(b({model:fz}),_(),{kind:`mutation`,auth:`admin`,timeoutMs:NTe}),deleteModel:k(b({file:l()}),_(),{kind:`mutation`,auth:`admin`}),listLocalModels:k(b({}),S(gz),{auth:`admin`}),getDiskUsage:k(b({}),_z,{auth:`admin`}),cancel:k(Sz,_(),{kind:`mutation`,auth:`admin`}),appleAvailability:k(b({}),bz,{auth:`admin`}),completeApple:k(xz,sz,{kind:`mutation`,auth:`admin`,timeoutMs:tz})},vocabulary:{notOperatorFacing:j.ML}},wz=/^[a-z0-9][a-z0-9-]{0,63}$/,Tz=l().regex(wz,`a kind id is lower-case letters, digits and dashes`),Ez=b({vision:v(),tools:v(),streaming:v(),reasoning:v().nullable().optional()}),Dz=b({id:l(),label:l().optional(),contextLength:n().int().positive().optional(),features:Ez.partial().optional()}),Oz=m(l(),C()),FTe=b({id:l(),name:l(),kind:Tz,addonId:l(),enabled:v(),model:l(),supportsVision:v(),temperature:n().min(0).max(2).optional(),topP:n().min(0).max(1).optional(),topK:n().int().positive().optional(),maxTokens:n().int().positive().optional(),reasoningEffort:x([`off`,`low`,`medium`,`high`]).optional(),contextLength:n().int().positive().optional(),systemPrompt:l().optional(),timeoutMs:n().int().positive().default(6e4),connectTimeoutMs:n().int().positive().default(1e4),firstTokenTimeoutMs:n().int().positive().default(12e4),idleTimeoutMs:n().int().positive().default(6e4),retry:lz.default({enabled:!1,maxAttempts:1}),toolsEnabled:v().default(!1),providerConfig:Oz.default({})}),kz=x([`temperature`,`topP`,`topK`,`maxTokens`,`reasoningEffort`,`contextLength`,`systemPrompt`,`timeoutMs`,`connectTimeoutMs`,`firstTokenTimeoutMs`,`idleTimeoutMs`,`retry`,`toolsEnabled`]),Az=b({id:l(),placement:x([`connection`,`model`]),requires:S(l()).optional()}),jz=C(),ITe=b({kind:Tz,label:l(),icon:l(),addonId:l(),connectionSchema:jz,advancedSchema:jz.optional(),features:Ez,visionEditable:v(),modelCatalog:x([`fetch`,`static`,`none`]),staticModels:S(Dz).optional(),profileFields:S(kz),providerWidgets:S(Az).optional()}),Mz=b({addonId:l(),kind:Tz,profileId:l().optional(),connection:Oz.optional()}),Nz=x([`auth`,`network`,`unsupported`,`invalid`]),Pz=i(`ok`,[b({ok:p(!0),models:S(Dz)}),b({ok:p(!1),code:Nz,message:l()})]),Fz=h([b({consumer:l()}),b({purpose:x([`text`,`vision`])})]),Iz=b({selector:Fz,profileId:l()}),Lz=b({day:l(),consumer:l(),profileId:l(),calls:n(),okCalls:n(),errorCalls:n(),inputTokens:n(),outputTokens:n(),avgLatencyMs:n()}),Rz=b({id:l(),label:l(),family:l(),purpose:x([`text`,`vision`]),url:l(),sha256:l(),sizeBytes:n(),quantization:l(),minRamBytes:n(),contextSizeDefault:n().int(),mmprojUrl:l().optional()}),zz=i(`ok`,[b({ok:p(!0),model:fz,label:l(),repo:l(),quantization:l(),purpose:x([`text`,`vision`]),totalBytes:n(),extraFilenames:S(l())}),b({ok:p(!1),code:l(),message:l(),candidates:S(l()).optional(),requiredBytes:n().optional()})]),Bz=b({nodeId:l(),reachable:v(),status:hz.optional(),disk:_z.optional(),error:l().optional(),apple:bz.optional()}),LTe=uz.extend({images:S(cz).min(1)}),Vz=b({addonId:l(),profileId:l()}),Hz={name:`llm`,scope:`system`,mode:`collection`,internal:!1,providerKind:`ai`,nodeIdMode:`data`,methods:{generate:k(uz,sz,{kind:`mutation`,timeoutMs:tz}),generateVision:k(LTe,sz,{kind:`mutation`,timeoutMs:tz}),cancel:k(b({addonId:l().optional(),requestId:l()}),_(),{kind:`mutation`}),listModels:k(Mz,Pz,{kind:`mutation`,auth:`admin`}),getDefaults:k(b({}),S(Iz)),setDefault:k(b({selector:Fz,profileId:l().nullable()}),_(),{kind:`mutation`,auth:`admin`}),getUsage:k(b({since:n().optional(),until:n().optional(),consumer:l().optional(),profileId:l().optional()}),S(Lz)),listModelCatalog:k(b({}),S(Rz)),listRuntimeNodes:k(b({}),S(Bz)),listNodeModels:k(b({nodeId:l()}),S(gz)),resolveModelRef:k(b({ref:l(),maxBytes:n().positive().optional()}),zz,{kind:`mutation`,auth:`admin`}),installModel:k(b({nodeId:l(),model:fz}),_(),{kind:`mutation`,auth:`admin`}),deleteModel:k(b({nodeId:l(),file:l()}),_(),{kind:`mutation`,auth:`admin`}),getRuntimeStatus:k(Vz,hz),startRuntime:k(Vz,hz,{kind:`mutation`,auth:`admin`}),stopRuntime:k(Vz,_(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:j.ML}},Uz=[`decode`,`transcode`,`recording`,`streaming`,`detection`],Wz=[`measured`,`accounted`,`unattributable`],Gz=b({role:x(Uz),deviceId:n().int().positive().nullable(),attribution:x(Wz),unit:l(),pid:n().int().positive().optional(),startedAtMs:n().optional(),cpuSeconds:n().optional(),rssBytes:n().optional()}),Kz={name:`load-contribution`,scope:`system`,mode:`collection`,internal:!0,methods:{list:k(_(),S(Gz).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:j.INTERNAL}},qz=`https://camstack.zentik.app`,Jz=`/viewer/camstack`;function Yz(e){if(e==null||e===``)return!1;try{return new URL(e).origin===qz}catch{return!1}}function RTe(e){let t=e.baseUrl??e.resolved;return Yz(t)?{form:`app`,hubBaseUrl:e.appLinkHub??null}:{form:`hub`,hubBaseUrl:t}}function Xz(e){let t;try{t=new URL(e)}catch{return null}return t.protocol!==`https:`&&t.protocol!==`http:`||t.username!==``||t.password!==``||t.hostname===``?null:t.origin}function zTe(e){let t=e=>e.kind!==`public`||!e.baseUrl.startsWith(`https://`)?null:e.interfaceKind===`public`?0:e.interfaceKind===`vpn`?1:null;return e.flatMap(e=>{let n=t(e),r=Xz(e.baseUrl);return n===null||r===null?[]:[{r:n,p:e.priority,origin:r}]}).toSorted((e,t)=>e.r-t.r||e.p-t.p)[0]?.origin??null}function BTe(e){switch(e.kind){case`camera`:{if(!Number.isInteger(e.deviceId)||e.deviceId<=0)return null;let t=e.atMs;return{path:`/camera/${String(e.deviceId)}`,query:t!==void 0&&Number.isFinite(t)?[[`at`,String(Math.trunc(t))]]:[]}}case`events`:return{path:`/events`,query:[]};case`notifications`:return{path:`/notifications`,query:[]}}}function Zz(e){return e.length===0?``:`?${e.map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join(`&`)}`}function VTe(e){let t=BTe(e.destination);if(t===null)return null;let n=e.base.hubBaseUrl,r=n===null?``:n.replace(/\/+$/,``);if(e.base.form===`app`){let e=r===``?null:Xz(r),n=e===null?t.query:[...t.query,[`hub`,e]];return`${qz}${t.path}${Zz(n)}`}return r===``||Yz(r)?null:`${r}${Jz}${t.path}${Zz(t.query)}`}var Qz=[`appConnections`,`notificationTaps`,`internal`,`publicEndpoint`],HTe=[`notificationTaps`,`internal`,`publicEndpoint`];function UTe(e){return e!==`appConnections`}var WTe={appConnections:[],notificationTaps:null,internal:null,publicEndpoint:null},GTe=/^\d{1,3}(?:\.\d{1,3}){3}$/;function $z(e){try{let t=new URL(e).hostname;return t.length>0?t:null}catch{return null}}function KTe(e){return e.replace(/\/+$/,``)}function eB(e){return e.kind===`public`&&e.interfaceKind===`vpn`}function qTe(e){return e.kind===`public`&&e.interfaceKind===`public`}function tB(e){return(e.kind===`lan-ipv4`||e.kind===`lan-ipv6`)&&e.plausible}function nB(e){if(e.kind!==`lan-ipv4`||!e.plausible)return!1;let t=$z(e.baseUrl);return t!==null&&GTe.test(t)}function rB(e){return e.stable===!1}function JTe(e,t){return t.kind===`loopback`||t.kind===`app-link`||t.kind===`custom`||$z(t.baseUrl)===null||rB(t)?null:e===`internal`?nB(t)?0:tB(t)?1:eB(t)?2:null:qTe(t)?0:eB(t)?1:nB(t)?2:tB(t)?3:null}var YTe=new Set([`localhost`,`0.0.0.0`,`::1`,`[::1]`,`::`,`[::]`]);function XTe(e){let t=e.toLowerCase();return YTe.has(t)||t.endsWith(`.localhost`)?!0:/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(t)}function iB(e){let t=e.trim();if(t===``)return{ok:!1,reason:`Enter an address, e.g. https://192.0.2.20:4443.`};let n;try{n=new URL(t)}catch{return{ok:!1,reason:`Not a URL — include http:// or https://.`}}return n.protocol!==`https:`&&n.protocol!==`http:`?{ok:!1,reason:`Use an http:// or https:// address.`}:n.username!==``||n.password!==``?{ok:!1,reason:`The address must not carry a user name or password.`}:n.hostname===``?{ok:!1,reason:`The address has no host.`}:XTe(n.hostname)?{ok:!1,reason:`A loopback address names whoever dials it, never this hub — use an address other machines reach.`}:n.pathname!==`/`||n.search!==``||n.hash!==``?{ok:!1,reason:`Enter only the address (scheme, host and port), without a path.`}:{ok:!0,baseUrl:n.origin}}var aB=`The public endpoint needs an https:// address: passkeys and most identity providers refuse a plain-http origin. Accept http only when sign-in and notification links never leave your own network.`;function oB(e,t,n={}){if(Yz(t))return e===`notificationTaps`?{ok:!0,baseUrl:qz}:{ok:!1,reason:`The CamStack app link is not a hub address — only notification taps can use it.`};let r=iB(t);return r.ok&&e===`publicEndpoint`&&r.baseUrl.startsWith(`http:`)&&n.acceptInsecureHttp!==!0?{ok:!1,reason:aB}:r}function sB(e,t){if(t===null||t===``)return null;let n=oB(e,t,{acceptInsecureHttp:!0});return n.ok?n.baseUrl:null}function ZTe(e,t){let n=e.flatMap(e=>{let n=JTe(t,e);return n===null?[]:[{rank:n,priority:e.priority,endpoint:e}]}).toSorted((e,t)=>e.rank-t.rank||e.priority-t.priority)[0];return n===void 0?null:KTe(n.endpoint.baseUrl)}function cB(e,t,n){let r=sB(t,n);if(r!==null)return{flagged:r,resolved:r,source:`flagged`};let i=ZTe(e,t);return{flagged:null,resolved:i,source:i===null?`none`:`auto`}}function lB(e,t){return cB(e,`internal`,t.internal)}function uB(e,t){return cB(e,`publicEndpoint`,t.publicEndpoint)}function dB(e){let t=sB(`notificationTaps`,e.notificationTaps);return t!==null&&!Yz(t)?{flagged:t,resolved:t,source:`flagged`}:{flagged:null,resolved:qz,source:`auto`}}function fB(e){return rB(e)?!1:e.kind===`lan-ipv4`?!0:e.kind===`public`&&e.interfaceKind===`public`}function pB(e,t){let n=e.filter(fB);if(t.appConnections.length===0)return n;let r=new Set(t.appConnections),i=e.filter(e=>r.has(e.baseUrl));return i.length>0?i:n}function mB(e,t){let n=new Set(t.appConnections),r=pB(e,t),i=r.some(e=>n.has(e.baseUrl));return{flagged:t.appConnections,resolved:r.map(e=>e.baseUrl),source:r.length===0?`none`:i?`flagged`:`auto`}}function QTe(e,t,n){return{appConnections:mB(e,n),notificationTaps:dB(n),internal:lB(t,n),publicEndpoint:uB(t,n)}}function $Te(e){return e===null?null:$z(e)}var eEe=`camstack`,tEe=`_camstack._tcp.local`,nEe={nodeId:`nodeId`,version:`version`,role:`role`,url:`url`,hubId:`hubId`},rEe=`hub`,hB=/^hub-[0-9a-f]{16}$/;function iEe(e){return typeof e==`string`&&hB.test(e)}var aEe=`camstack-agent`,oEe=`_camstack-agent._tcp.local`,sEe={nodeId:`nodeId`,version:`version`,name:`name`,state:`state`,keyFingerprint:`fp`},cEe=x([`lan`,`wifi`,`docker`,`vpn`,`loopback`,`other`]),gB=b({name:l(),family:x([`IPv4`,`IPv6`]),address:l(),cidr:l(),netmask:l(),internal:v(),mac:l(),kind:cEe,preferred:v(),plausible:v(),plausibleReason:l()}),lEe=b({interfaces:S(gB).readonly(),probedAt:n()}),uEe=gB.nullable(),_B=b({label:l(),baseUrl:l(),kind:x([`lan-ipv4`,`lan-ipv6`,`public`,`loopback`,`app-link`,`custom`]),interfaceKind:x([`lan`,`wifi`,`docker`,`vpn`,`other`,`loopback`,`public`]),plausible:v(),plausibleReason:l(),priority:n(),stable:v().optional()}),dEe=x([`server-config`,`server-env`,`caller-hint`,`default`]),fEe=b({port:n().int().min(1).max(65535),source:dEe}),pEe=b({endpoints:S(_B).readonly(),localPort:fEe}),vB=b({baseUrl:l().nullable(),resolved:l().nullable(),appLinkHub:l().nullable()}),yB=b({baseUrls:S(l()).readonly(),resolved:S(l()).readonly()}),bB=b({override:l().nullable(),resolved:l().nullable(),source:x([`override`,`auto`,`none`])}),mEe=b({cluster:bB,browser:bB}),xB=x(Qz),SB=x([`flagged`,`auto`,`none`]),CB=b({flagged:l().nullable(),resolved:l().nullable(),source:SB}),hEe=b({flagged:S(l()).readonly(),resolved:S(l()).readonly(),source:SB}),wB=b({rows:S(_B.extend({detected:v(),custom:v(),flags:S(xB).readonly(),inUse:S(xB).readonly(),eligible:S(xB).readonly()})).readonly(),roles:b({appConnections:hEe,notificationTaps:CB,internal:CB,publicEndpoint:CB}),appLinkHub:l().nullable(),listenerOrigins:S(l()).readonly().optional()}),TB=b({addresses:S(l()).readonly()}),EB=b({mode:x([`generated`,`uploaded`,`disabled`]),leafFingerprintSha256:l().nullable(),caFingerprintSha256:l().nullable(),validTo:l().nullable(),sans:S(l()),caCertPem:l().nullable(),reissueError:l().nullable(),restartRequired:v(),caMissing:v(),localCaConstrained:v().nullable(),caReplacedAt:l().nullable(),storedUpload:b({leafFingerprintSha256:l(),validTo:l(),hasCa:v()}).nullable()}),gEe=b({providerId:l().min(1),modes:S(Zj)}),_Ee=b({providerId:l().optional(),mode:l().optional(),message:l()}),vEe=b({hostsProbed:n().int(),hits:n().int(),timeouts:n().int(),byMode:m(l(),b({probed:n().int(),hits:n().int(),timeouts:n().int()}))}),yEe=b({hits:S(b({providerId:l(),hit:Qj})),subnetsScanned:S(l()),errors:S(_Ee),stats:vEe}),DB={name:`local-network`,scope:`system`,mode:`singleton`,methods:{list:k(_(),lEe),getPreferred:k(_(),uEe),getConnectionEndpoints:k(b({port:n().int().min(1).max(65535).optional(),includeLoopback:v().optional(),ipv4Only:v().optional(),scheme:x([`http`,`https`]).optional(),includeAppLink:v().optional()}),pEe),getNotificationEndpoint:k(_(),vB),setNotificationEndpoint:k(b({baseUrl:l().nullable()}),vB,{kind:`mutation`}),getViewerEndpoints:k(_(),yB),setViewerEndpoints:k(b({baseUrls:S(l()).readonly()}),yB,{kind:`mutation`}),getAddresses:k(b({scheme:x([`http`,`https`]).optional()}).optional(),wB),addCustomAddress:k(b({baseUrl:l(),label:l().max(80)}),wB,{kind:`mutation`,auth:`admin`}),removeCustomAddress:k(b({baseUrl:l()}),wB,{kind:`mutation`,auth:`admin`}),setAddressRole:k(b({role:xB,baseUrl:l().nullable(),enabled:v(),acceptInsecureHttp:v().optional()}),wB,{kind:`mutation`,auth:`admin`}),getHubAddresses:k(_(),mEe),getAllowedAddresses:k(_(),TB),setAllowedAddresses:k(TB,b({success:p(!0)}),{kind:`mutation`}),resetAllowlistToBestMatch:k(_(),TB,{kind:`mutation`}),getTlsStatus:k(_(),EB),regenerateCertificate:k(b({reason:l().optional()}),EB,{kind:`mutation`,auth:`admin`}),uploadCertificate:k(b({certPem:l().min(1),keyPem:l().min(1),caPem:l().optional()}),EB,{kind:`mutation`,auth:`admin`}),downloadCa:k(_(),b({pem:l()})),useStoredUploadedCertificate:k(_(),EB,{kind:`mutation`,auth:`admin`}),scanNetwork:k(b({requests:S(gEe),subnets:S(l()).optional()}),yEe,{kind:`mutation`,auth:`admin`,timeoutMs:9e4}),getScanSubnets:k(_(),b({subnets:S(l())}),{auth:`admin`}),setScanSubnets:k(b({subnets:S(l())}),b({subnets:S(l())}),{kind:`mutation`,auth:`admin`}),revertToGeneratedCertificate:k(_(),EB,{kind:`mutation`,auth:`admin`})},mount:{kind:`hub-only`},vocabulary:{notOperatorFacing:j.NETWORK}},OB=x([`locked`,`unlocked`,`locking`,`unlocking`,`jammed`,`door-open`]),kB=b({state:OB,codeRequired:v().nullable().optional(),lastChangedAt:n()}),bEe={version:1,overridable:[{path:`state`,by:`door-contact`}],targets:[{id:`door-contact`,cardinality:`scalar`,vocabulary:{cap:`lock-control`,stateField:`state`},deviceTypes:[T.Lock],apply:`replace`,path:`state`,override:{whenSourceTrue:`door-open`,unlessNative:[`jammed`]},sources:[{kind:`binary`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}]},AB={name:`lock-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Lock],methods:{lock:k(b({deviceId:n().int().nonnegative(),code:l().min(1).optional()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.lock`,label:P(`Lock`,`Chiudi a chiave`),phrase:P(`Lock {device}`,`Chiudi a chiave {device}`),icon:`lock`,effect:{field:`state`,value:`locked`},hold:{effects:[{field:`state`,value:`locking`,when:{field:`state`,notIn:[`locked`]}}]},openArgs:[{key:`code`,label:P(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]}),unlock:k(b({deviceId:n().int().nonnegative(),code:l().min(1).optional(),confirm:v().optional()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.unlock`,label:P(`Unlock`,`Apri la serratura`),phrase:P(`Unlock {device}`,`Sblocca {device}`),icon:`lock-open`,effect:{field:`state`,value:`unlocked`},hold:{effects:[{field:`state`,value:`unlocking`,when:{field:`state`,notIn:[`unlocked`]}}]},openArgs:[{key:`code`,label:P(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]}),open:A(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.open`,label:P(`Open latch`,`Apri lo scrocco`),phrase:P(`Release the latch of {device}`,`Fai scattare lo scrocco di {device}`),icon:`door-open`}]})},status:{schema:kB,kind:`push`},runtimeState:kB,customize:bEe,durability:`restored`,history:{fields:{state:{kind:`enum`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:P(`Lock`,`Serratura`),order:1060,state:[{kind:`enum`,field:`state`,label:P(`Lock state`,`Stato della serratura`),values:[{value:`locked`,label:P(`Locked`,`Chiusa a chiave`),phrase:P(`When {device} locks`,`Quando {device} si chiude a chiave`)},{value:`unlocked`,label:P(`Unlocked`,`Sbloccata`),phrase:P(`When {device} unlocks`,`Quando {device} si sblocca`)},{value:`locking`,label:P(`Locking`,`In chiusura`),phrase:P(`When {device} starts locking`,`Quando {device} inizia a chiudersi`)},{value:`unlocking`,label:P(`Unlocking`,`In apertura`),phrase:P(`When {device} starts unlocking`,`Quando {device} inizia a sbloccarsi`)},{value:`jammed`,label:P(`Jammed`,`Inceppata`),phrase:P(`When {device} jams`,`Quando {device} si inceppa`)},{value:`door-open`,label:P(`Door open`,`Porta aperta`),phrase:P(`When the door of {device} opens`,`Quando la porta di {device} si apre`)}],icon:`lock`}]}},jB=b({armed:n().int().min(0),unknown:S(l()).readonly()}),MB={name:`log-channels`,scope:`system`,mode:`collection`,internal:!0,methods:{list:k(_(),S(Oh).readonly()),apply:k(b({windows:S(Lle).readonly()}),jB,{kind:`mutation`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:j.INTERNAL}},NB=x([`debug`,`info`,`warn`,`error`]),PB=b({timestamp:g(),level:NB,scope:S(l()),message:l(),meta:m(l(),C()).optional(),tags:m(l(),l()).optional()}),FB=b({instanceId:l().min(1).max(200).optional(),requestId:l().min(1).max(64).optional(),deviceId:n().int().optional(),fromAddonId:l().min(1).max(200).optional(),fromNodeId:l().min(1).max(200).optional(),tags:m(l(),h([l(),n()])).optional(),level:NB.optional(),text:l().min(1).max(200).optional(),since:n().optional(),until:n().optional(),before:l().min(1).max(1024).optional(),after:l().min(1).max(1024).optional(),limit:n().int().min(1).max(1e3).optional(),budgetMs:n().int().min(50).max(1e4).optional()}),IB=b({id:l().optional(),timestamp:n(),level:NB,scope:l().optional(),message:l(),tags:m(l(),h([l(),n()])).optional(),meta:m(l(),C()).optional()}),LB=b({entries:S(IB),nextBefore:l().nullable(),nextAfter:l().nullable(),scannedBytes:n().int().nonnegative(),done:v(),cancelled:v().optional()}),xEe=b({instanceId:l().min(1).max(200).optional()}),RB=b({readable:v(),reason:l().nullable(),filters:b({deviceId:v(),addonId:v(),nodeId:v(),tags:v(),level:v(),text:v(),timeRange:v()}),retentionDays:n().nullable()}),zB={name:`log-destination`,scope:`system`,mode:`collection`,internal:!0,methods:{write:k(PB,_(),{kind:`mutation`}),describeRead:A(xEe,RB,{auth:`admin`}),read:A(FB,LB,{auth:`admin`}),cancelRead:A(b({requestId:l().min(1).max(64)}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:j.INTERNAL}},BB=x([`primary`,`second-factor`]),VB=b({kind:p(`redirect`),id:l(),label:l(),icon:l().optional(),startUrl:l(),stage:BB,linkable:v().optional(),app:hg.nullable().optional()}),HB=b({kind:p(`widget`),id:l(),addonId:l(),bundle:l(),remote:fS,stage:BB,app:hg.nullable().optional()}),UB=b({kind:p(`passkey`),id:l(),label:l(),stage:BB,rpId:l(),origin:l().nullable(),app:hg.nullable().optional()}),WB=i(`kind`,[VB,HB,UB]),GB={name:`login-method`,scope:`system`,mode:`collection`,internal:!0,methods:{getLoginMethods:k(_(),S(WB).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:j.IDENTITY}},KB=b({sleeping:v().meta({label:`Sleeping`}),lastContactAt:n().optional(),lastUpdated:n().meta(M(`none`))}),qB={name:`low-power-sleep`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Camera],methods:{wakeUp:k(b({deviceId:n(),timeoutMs:n().int().min(500).max(3e4).default(8e3)}),b({awoke:v(),durationMs:n()}),{kind:`mutation`,notOperatorFacing:`a stream consumer wakes a sleeping camera to watch it; an automation that wants footage asks for the footage`})},status:{schema:KB,kind:`push`,empty:{sleeping:!1,lastUpdated:0}},runtimeState:KB,durability:`restored`,history:`none`,volatileStateFields:[`lastUpdated`],vocabulary:{noun:P(`Low-power sleep`,`Sospensione a basso consumo`),order:5245}},SEe=b({id:l(),label:l(),scope:x([`mesh`,`public`]),url:l(),hostname:l(),port:n(),protocol:x([`http`,`https`])}),JB=b({id:l(),hostname:l(),magicDns:l(),addresses:S(l()).readonly(),os:l().optional(),online:v(),lastSeenMs:n(),isSelf:v(),connection:x([`direct`,`relay`,`idle`]),relay:l().nullable(),lastHandshakeMs:n(),rxBytes:n(),txBytes:n(),tags:S(l()).readonly(),exitNodeOption:v(),advertisedRoutes:S(l()).readonly(),userLogin:l().nullable(),keyExpiry:n().nullable()}),YB=b({joined:v(),meshIp:l(),magicDnsHostname:l(),peerCount:n(),endpoints:S(SEe).readonly(),error:l().optional(),tenantName:l(),magicDnsSuffix:l(),userLogin:l().nullable(),controlPlaneUrl:l(),keyExpiry:n().nullable(),daemonSocket:l().optional(),daemonCliPath:l().optional()}),XB={name:`mesh-network`,scope:`system`,mode:`collection`,providerKind:`mesh`,methods:{getStatus:k(_(),YB),join:k(b({authKey:l().min(8),hostname:l().optional()}),b({joined:p(!0)}),{kind:`mutation`}),startLogin:k(b({hostname:l().optional()}),b({loginUrl:l()}),{kind:`mutation`}),leave:k(_(),b({left:p(!0)}),{kind:`mutation`}),logout:k(_(),b({loggedOut:p(!0)}),{kind:`mutation`}),listPeers:k(_(),b({peers:S(JB).readonly()}))},vocabulary:{notOperatorFacing:j.NETWORK}},ZB=b({value:n().nullable().meta(M(`device`,{label:`Total`})),lastFetchedAt:n()}),QB={name:`meter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Sensor],methods:{},status:{schema:ZB,kind:`push`},runtimeState:ZB,durability:`restored`,history:{fields:{value:{kind:`counter`,deadband:.001,minIntervalMs:6e4}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:P(`Meter`,`Contatore`),order:5140,state:[{kind:`numeric`,field:`value`,quantity:P(`the total`,`il totale`),label:P(`Total`,`Totale`),icon:`gauge`}]}},CEe=b({total:n(),user:n(),system:n(),irq:n(),nice:n(),loadAvg:u([n(),n(),n()]),cores:n()}),wEe=b({percent:n().nullable(),totalBytes:n(),usedBytes:n().nullable(),availableBytes:n().nullable(),swapUsedBytes:n(),swapTotalBytes:n()}),TEe=b({readBytes:n(),writeBytes:n(),readOps:n(),writeOps:n(),timestampMs:n()}),EEe=b({rxBytes:n(),txBytes:n(),rxPackets:n(),txPackets:n(),rxErrors:n(),txErrors:n(),timestampMs:n()}),$B=b({utilization:n(),model:l(),memoryUsedBytes:n(),memoryTotalBytes:n(),temperature:n().nullable()}),DEe=b({openFds:n(),threadCount:n(),activeHandles:n(),activeRequests:n()}),eV=b({avg10:n(),avg60:n(),avg300:n()}),tV=b({some:eV,full:eV.nullable()}),nV=b({cpu:CEe,memory:wEe,gpu:$B.nullable(),network:EEe,disk:TEe,pressure:b({cpu:tV.nullable(),memory:tV.nullable(),io:tV.nullable()}),process:DEe,cpuTemperature:n().nullable(),timestampMs:n()}),OEe=b({path:l(),totalBytes:n(),usedBytes:n(),availableBytes:n(),percent:n()}),rV=b({pid:n(),cpu:n(),memory:n(),privateBytes:n().optional(),sharedBytes:n().optional()}),kEe=b({addonId:l(),nodeId:l(),role:x([`hub`,`worker`]),pid:n(),state:x([`starting`,`running`,`stopping`,`stopped`,`crashed`]),uptimeSec:n()}),AEe=b({pid:n(),ppid:n(),pgid:n(),classification:x([`root`,`managed`,`system`]),addonId:l().nullable(),nodeId:l().nullable(),command:l(),cpuPercent:n(),memoryRssBytes:n(),cpuMainPercent:n().nullable(),cpuGcPercent:n().nullable(),threadCount:n().nullable(),uptimeSec:n()}),jEe=b({source:x([`cgroup-v2`,`cgroup-v1`]),currentBytes:n(),limitBytes:n().nullable(),anonBytes:n().nullable(),fileBytes:n().nullable(),shmemBytes:n().nullable(),slabBytes:n().nullable(),gpuShmemBytes:n().nullable()}).extend({atMs:n()}),MEe=b({atMs:n(),samples:n().int(),cpuMainPercent:n().nullable(),cpuMainPercentMin:n().nullable(),cpuGcPercent:n().nullable(),cpuGcPercentMin:n().nullable(),cpuLifetimePercent:n(),cpuLifetimePercentMin:n(),memoryRssBytes:n(),memoryRssBytesMin:n(),processCount:n().int(),processCountMin:n().int()}),NEe=b({key:l(),kind:x([`addon`,`root`,`unattributed`]),points:S(MEe).readonly()}),PEe=b({nodeId:l(),series:S(NEe).readonly(),containerMemory:S(jEe).readonly(),bucketMs:n(),retainedSamples:n(),oldestAtMs:n().nullable(),cadenceMs:n(),durable:v()}),FEe=b({forNodeId:l(),sinceMs:n().optional(),maxPoints:n().int().positive().optional()}),iV=b({cpuPercent:n(),memoryPercent:n().nullable(),memoryUsedMB:n().nullable(),memoryTotalMB:n(),diskPercent:n().optional(),temperature:n().optional(),gpuPercent:n().optional(),gpuMemoryPercent:n().optional()}),aV={name:`metrics-provider`,scope:`system`,mode:`singleton`,methods:{collectSnapshot:k(_(),nV),getCached:k(_(),nV.nullable()),getCurrent:k(_(),iV),getDiskSpace:k(b({dirPath:l()}),OEe),getGpuInfo:k(_(),$B.nullable()),getCpuTemperature:k(_(),n().nullable()),getProcessStats:k(b({pids:S(n())}),S(rV)),listAddonInstances:k(_(),S(kEe).readonly()),getAddonStats:k(b({addonId:l()}),rV.nullable()),listNodeProcesses:k(_(),S(AEe).readonly()),getLoadSeries:k(FEe,PEe)},vocabulary:{notOperatorFacing:j.CLUSTER}},oV=l().min(1).max(256),sV=m(l(),C()),cV=b({id:oV,deviceId:n().int().optional(),at:n().int().optional(),expiresAt:n().int().optional(),data:sV}),lV=b({id:l(),deviceId:n().int().nullable(),at:n().nullable(),expiresAt:n().nullable(),rev:n().int(),updatedAt:n(),data:sV}),uV=m(ui,h([l(),n(),v(),b({in:S(h([l(),n(),v()])).min(1).max(zn)}),b({gt:h([l(),n()]).optional(),gte:h([l(),n()]).optional(),lt:h([l(),n()]).optional(),lte:h([l(),n()]).optional()}).refine(e=>Object.keys(e).length>0,{message:`name at least one bound`})])),dV={kind:gi},fV={deviceId:n().int().optional(),atFrom:n().optional(),atTo:n().optional()},pV=b({...dV,...fV,where:uV.optional(),order:x([`at`,`id`]).optional(),desc:v().optional(),limit:n().int().min(1).max(Vn).default(100),cursor:l().min(1).optional()}),mV=b({records:S(lV),nextCursor:l().nullable()}),IEe=x([`created`,`unchanged`,`updated`]),hV=b({kindId:n().int(),state:IEe,createdIndexes:S(l())}),gV=S(l()),_V=i(`op`,[b({op:p(`put`),kind:gi,record:cV,ifRev:n().int().min(0).optional()}),b({op:p(`patch`),kind:gi,id:oV,data:sV,at:n().int().nullable().optional(),expiresAt:n().int().nullable().optional(),ifRev:n().int().min(1).optional()}),b({op:p(`delete`),kind:gi,id:oV})]),vV=m(l(),m(l(),l())),yV={name:`records`,scope:`system`,mode:`singleton`,internal:!0,methods:{declareKinds:k(b({kinds:m(gi,hi)}),b({kinds:m(l(),hV)}),{kind:`mutation`,auth:`admin`}),get:k(b({...dV,id:oV}),lV.nullable(),{auth:`admin`}),getMany:k(b({...dV,ids:S(oV).min(1).max(zn)}),S(lV),{auth:`admin`}),secretRefs:k(b({...dV,ids:S(oV).min(1).max(zn)}),vV,{auth:`admin`}),put:k(b({...dV,record:cV,ifRev:n().int().min(0).optional()}),b({rev:n().int(),releasedRefs:gV}),{kind:`mutation`,auth:`admin`}),putMany:k(b({...dV,records:S(cV).min(1).max(zn)}),b({count:n().int(),releasedRefs:gV}),{kind:`mutation`,auth:`admin`}),patch:k(b({...dV,id:oV,data:sV,at:n().int().nullable().optional(),expiresAt:n().int().nullable().optional(),ifRev:n().int().min(1).optional()}),b({rev:n().int(),releasedRefs:gV}),{kind:`mutation`,auth:`admin`}),delete:k(b({...dV,id:oV}),b({deleted:v(),secretRefs:gV}),{kind:`mutation`,auth:`admin`}),deleteMany:k(b({...dV,ids:S(oV).min(1).max(zn)}),b({deleted:n().int(),secretRefs:gV}),{kind:`mutation`,auth:`admin`}),query:k(pV,mV,{auth:`admin`}),count:k(b({...dV,...fV,where:uV.optional()}),b({count:n().int()}),{auth:`admin`}),histogram:k(b({...dV,deviceId:n().int().optional(),from:n(),to:n(),bucketMs:n().int().positive()}),b({buckets:S(b({bucketStart:n(),count:n().int()}))}),{auth:`admin`}),aggregate:k(b({...dV,op:x([`sum`,`min`,`max`,`count`]),field:ui.optional(),groupBy:ui.optional(),where:uV.optional()}),b({rows:S(b({group:h([l(),n(),oe()]),value:n().nullable()}))}),{auth:`admin`}),deleteWhere:k(b({...dV,deviceId:n().int().optional(),atBefore:n().optional(),where:uV.optional()}),b({deleted:n().int(),secretRefs:gV}),{kind:`mutation`,auth:`admin`}),transact:k(b({ops:S(_V).min(1).max(zn)}),b({results:S(b({rev:n().int().nullable(),deleted:v()})),releasedRefs:gV,secretRefs:gV}),{kind:`mutation`,auth:`admin`}),deleteDevice:k(b({deviceId:n().int(),kinds:S(gi).optional()}),b({deleted:m(l(),n().int()),secretRefs:gV}),{kind:`mutation`,auth:`admin`}),allocateId:k(b(dV),b({id:n().int()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:j.INTERNAL}},bV=m(l(),C()),xV=b({integrationId:l().min(1)}),SV=b({id:l().min(1)}),CV=b({id:l(),deviceId:n().int().nullable(),at:n().nullable(),expiresAt:n().nullable(),rev:n().int(),updatedAt:n(),data:bV}),wV={id:l().min(1),deviceId:n().int().optional(),at:n().int().optional(),expiresAt:n().int().optional(),data:bV},TV=b({id:l(),addonId:l(),name:l(),info:bV,enabled:v().optional(),originStableId:l().optional()}),LEe=b({id:n().int(),integrationId:l().nullable().optional(),parentDeviceId:n().int().nullable().optional(),type:l().optional(),name:l().optional(),stableId:l().optional()}),EV=b({version:n().int(),methods:S(l())}),DV=b({message:l(),meta:bV.optional(),tags:b({deviceId:n().int().optional()}).optional()}),REe={"ledger.declare":{input:b({owner:l().min(1),metas:S(Mf)}),output:b({bootId:l(),snapshot:x([`none`,`written`,`refused`]),steps:S(Kf),migrationApi:EV.optional()}),behaviours:[`ledger.declare.answers-steps-in-engine-order`,`ledger.declare.answers-the-migration-api`]},"ledger.start":{input:b({id:l().min(1)}),output:b({proceed:v(),state:h([p(`pending`),Hf]),reason:l().nullable()}),behaviours:[`ledger.start.proceeds-when-predecessors-applied`]},"ledger.finish":{input:b({id:l().min(1),result:Vf}),output:b({status:Hf,error:l().nullable(),rowsChanged:n().int().nonnegative()}),behaviours:[`ledger.finish.records-the-outcome`]},"legacyRows.read":{input:xV,output:bV,behaviours:[`legacyRows.read.returns-stored-rows`,`legacyRows.read.absent-store-is-empty`,`legacyRows.caller.sibling-package`]},"legacyRows.clear":{input:xV,output:b({rows:n().int().nonnegative(),secrets:n().int().nonnegative()}),behaviours:[`legacyRows.clear.deletes-the-rows`,`legacyRows.clear.absent-store-is-noop`]},"legacyRows.patch":{input:xV.extend({patch:bV}),output:b({written:v()}),behaviours:[`legacyRows.patch.upserts-keys-and-keeps-the-rest`,`legacyRows.patch.absent-store-writes-nothing`]},"legacyRows.deleteKeys":{input:xV.extend({keys:S(l().min(1))}),output:b({present:v(),removed:bV}),behaviours:[`legacyRows.deleteKeys.removes-the-named-keys`,`legacyRows.deleteKeys.absent-store-reports-not-present`]},"records.get":{input:SV,output:CV.nullable(),behaviours:[`records.get.returns-the-row-or-null`]},"records.getResolved":{input:SV,output:CV.nullable(),behaviours:[`records.getResolved.resolves-secret-fields`]},"records.put":{input:b({...wV,ifRev:n().int().optional()}),output:b({rev:n().int()}),behaviours:[`records.put.creates-and-replaces`,`records.put.if-rev-conflict-throws`]},"records.putMany":{input:b({records:S(b(wV))}),output:b({count:n().int().nonnegative()}),behaviours:[`records.putMany.writes-every-row`]},"records.patch":{input:SV.extend({partial:bV,ifRev:n().int().optional()}),output:b({rev:n().int()}),behaviours:[`records.patch.merges-and-null-removes`]},"records.delete":{input:SV,output:b({deleted:v()}),behaviours:[`records.delete.reports-whether-a-row-went`]},"records.query":{input:b({deviceId:n().int().optional(),atFrom:n().optional(),atTo:n().optional(),where:uV.optional(),limit:n().int().min(1).optional(),cursor:l().min(1).optional(),resolveSecrets:v().optional()}),output:b({records:S(CV),nextCursor:l().nullable()}),behaviours:[`records.query.pages-with-a-cursor`,`records.query.filters-on-a-declared-index`]},"records.deleteWhere":{input:b({deviceId:n().int().optional(),atBefore:n().optional(),where:uV.optional()}),output:b({count:n().int().nonnegative()}),behaviours:[`records.deleteWhere.deletes-the-matching-rows`]},"settings.read":{input:b({}),output:b({store:bV}),behaviours:[`settings.read.returns-the-addon-store`]},"settings.write":{input:b({patch:bV}),output:b({}),behaviours:[`settings.write.merges-and-keeps-other-keys`]},"settings.deleteKeys":{input:b({keys:S(l().min(1))}),output:b({removed:S(l())}),behaviours:[`settings.deleteKeys.removes-only-the-named-keys`]},"deviceSettings.listIds":{input:b({}),output:b({deviceIds:S(n().int())}),behaviours:[`deviceSettings.listIds.names-only-the-addons-own-devices`]},"deviceSettings.read":{input:b({deviceIds:S(n().int())}),output:b({blobs:m(l(),bV)}),behaviours:[`deviceSettings.read.returns-only-the-addons-own-blobs`]},"secrets.resolve":{input:b({refs:S(l())}),output:b({values:m(l(),l().nullable())}),behaviours:[`secrets.resolve.answers-null-for-a-missing-ref`]},"secrets.put":{input:b({ref:l().min(1),value:l()}),output:b({}),behaviours:[`secrets.put.stores-under-the-owner`]},"secrets.delete":{input:b({refs:S(l())}),output:b({deleted:n().int().nonnegative()}),behaviours:[`secrets.delete.ignores-unknown-refs`]},"integrations.list":{input:b({}),output:b({integrations:S(TV)}),behaviours:[`integrations.list.lists-every-integration`]},"integrations.get":{input:b({id:l().min(1)}),output:TV.nullable(),behaviours:[`integrations.get.null-for-an-unknown-id`]},"devices.list":{input:b({addonId:l().min(1),integrationId:l().min(1).optional()}),output:b({devices:S(LEe)}),behaviours:[`devices.list.scoped-to-the-addon`,`devices.list.filters-by-integration`]},"devices.get":{input:b({deviceId:n().int()}),output:b({id:n().int(),integrationId:l().nullable(),hasConfig:v()}).nullable(),behaviours:[`devices.get.null-for-an-unknown-id`,`devices.get.reports-link-and-config`]},"devices.aliases":{input:b({deviceIds:S(n().int())}),output:b({aliases:m(l(),l())}),behaviours:[`devices.aliases.answers-for-the-named-ids-only`]},"devices.setIntegrationId":{input:b({deviceId:n().int(),integrationId:l().min(1)}),output:b({}),behaviours:[`devices.setIntegrationId.links-the-device`]},"node.localNodeId":{input:b({}),output:b({nodeId:l()}),behaviours:[`node.localNodeId.names-this-node`]},"log.info":{input:DV,output:b({}),behaviours:[`log.info.writes-a-line`]},"log.warn":{input:DV,output:b({}),behaviours:[`log.warn.writes-a-line`]}},OV={name:`migrations`,scope:`system`,mode:`singleton`,internal:!0,methods:{listLedger:k(b({}),b({entries:S(Uf)}),{auth:`admin`}),listPending:k(b({owner:l().optional()}),b({pending:S(Wf)}),{auth:`admin`}),dryRun:k(b({id:l().min(1)}),Gf,{auth:`admin`}),markFailed:k(b({id:l().min(1),error:l().min(1)}),Uf,{kind:`mutation`,auth:`admin`}),retry:k(b({id:l().min(1)}),b({entries:S(Uf)}),{kind:`mutation`,auth:`admin`}),restorePreMigration:k(b({database:vf,snapshotId:l().min(1)}),b({scheduled:v(),held:S(l()),restartRequired:v()}),{kind:`mutation`,auth:`admin`}),declareOwner:k(b({owner:l().min(1),metas:S(Mf),retired:S(l().min(1)).optional()}),b({bootId:l(),snapshot:x([`none`,`written`,`refused`]),steps:S(Kf),migrationApi:EV.optional()}),{kind:`mutation`,auth:`admin`}),startMigration:k(b({id:l().min(1)}),b({proceed:v(),state:h([p(`pending`),Hf]),reason:l().nullable()}),{kind:`mutation`,auth:`admin`}),finishMigration:k(b({id:l().min(1),result:Vf}),b({status:Hf,error:l().nullable(),rowsChanged:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),readLegacyIntegrationRows:k(b({integrationId:l().min(1)}),m(l(),C()),{auth:`admin`}),clearLegacyIntegrationRows:k(b({integrationId:l().min(1)}),b({rows:n().int().nonnegative(),secrets:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),patchLegacyIntegrationRows:k(b({integrationId:l().min(1),patch:m(l(),C())}),b({written:v()}),{kind:`mutation`,auth:`admin`}),deleteLegacyIntegrationRowKeys:k(b({integrationId:l().min(1),keys:S(l().min(1))}),b({present:v(),removed:m(l(),C())}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:j.INTERNAL}},kV=b({sourceUrl:l(),metadata:Xde,targets:S(Yde).min(1).readonly(),calibrationRef:l().optional(),sessionId:l().optional()}),AV={name:`model-convert`,scope:`system`,mode:`singleton`,internal:!0,methods:{convert:k(kV,Qde,{kind:`mutation`,auth:`admin`,timeoutMs:6e5})},vocabulary:{notOperatorFacing:j.ML}},jV=b({targetNodeId:l(),modelId:l(),format:x(Pa),entry:ng}),MV=b({ok:v(),sha256:l(),bytes:n(),path:l()}),NV={name:`model-distributor`,scope:`system`,mode:`singleton`,internal:!0,methods:{distributeModel:k(jV,MV,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:j.ML}},PV=i(`kind`,[b({kind:p(`camera`)}),b({kind:p(`sensor`),deviceId:n().int().positive()})]),FV=Object.freeze({kind:`camera`});function zEe(e){if(e===void 0)return{triggeredBy:FV,malformed:!1};let t=PV.safeParse(e);return t.success?{triggeredBy:t.data,malformed:!1}:{triggeredBy:FV,malformed:!0}}var BEe=`cameraSensors`,VEe=8,IV=b({addonId:l().min(1),stableId:l().min(1)});function LV(e){return`${e.addonId}/${e.stableId}`}var RV=x([`in-addition`,`confirm`,`replace`]),zV=`in-addition`,BV=IV.extend({mode:RV.default(zV)}),VV=b({sensors:S(BV).min(1).max(8)}).superRefine((e,t)=>{let n=new Set;e.sensors.forEach((e,r)=>{let i=LV(e);n.has(i)&&t.addIssue({code:`custom`,path:[`sensors`,r],message:`duplicate camera sensor ${i}`}),n.add(i)})}),HV={addonId:l(),stableId:l(),mode:RV.default(zV)},UV=i(`state`,[b({...HV,state:p(`ready`),deviceId:n(),name:l(),caps:S(l()).readonly()}),b({...HV,state:p(`offline`),deviceId:n(),name:l(),reason:x([`offline`,`disabled`])}),b({...HV,state:p(`missing`),reason:l()}),b({...HV,state:p(`unsupported`),deviceId:n(),name:l(),reason:l()}),b({...HV,state:p(`unreadable`),reason:l()})]),WV=x([`onboard-not-listed`,`no-active-detection`]),GV=x([`always`,`when-confirmed`,`never`]),KV=x([`provider-not-split`]),qV=b({detected:v(),atMs:n()}),JV=i(`state`,[b({state:p(`not-configured`),cameraLevel:qV.optional()}),b({state:p(`unreadable`),reason:l(),cameraLevel:qV.optional()}),b({state:p(`configured`),cameraLevel:qV.optional(),sensors:S(UV).readonly(),cameraMotion:GV.optional(),notForwarded:WV.optional(),notEnforced:KV.optional()})]),HEe=Object.freeze({state:`unreadable`,reason:`camera sensor mappings not loaded`}),YV=b({bbox:aC,pixelCount:n(),intensity:n()}),XV=b({detected:v(),regionCount:n(),regions:S(YV).readonly(),rawRegions:S(YV).readonly(),frameWidth:n(),frameHeight:n(),analysisMs:n()}),ZV={name:`motion-detection`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[T.Camera],exposesDeviceSettings:!0,methods:{analyze:k(b({deviceId:n(),frame:iC.optional(),frameHandle:Ca.optional()}),XV,{role:`admin`,kind:`mutation`,notOperatorFacing:`the pipeline feeds it frames — an internal stage, never called by a person`}),removeCamera:k(b({deviceId:n()}),_(),{role:`admin`,kind:`mutation`,notOperatorFacing:`pipeline housekeeping when a camera leaves`}),reset:k(_(),_(),{role:`admin`,kind:`mutation`,notOperatorFacing:`pipeline housekeeping`})},events:{onMotion:{data:b({deviceId:n(),detected:v(),regionCount:n()}),notOperatorFacing:"the analyzer’s raw verdict; the operator signal is the `motion` cap’s `detected` state"}},vocabulary:{noun:P(`Motion analysis`,`Analisi del movimento`),order:3160}},QV=b({package:v(),confidence:n().min(0).max(1),reason:l().min(1)}),$V=b({x:n(),y:n()}),eH=b({kind:p(`rect`),x:n(),y:n(),width:n(),height:n()}),tH=b({kind:p(`polygon`),points:S($V)}),nH=b({kind:p(`grid`),gridWidth:n().meta(M(`none`)),gridHeight:n().meta(M(`none`)),cells:S(v())}),rH=b({kind:p(`line`),points:S($V)}),UEe=i(`kind`,[eH,tH,nH,rH]),iH=x([`rect`,`polygon`,`grid`,`line`]),aH=b({min:n(),max:n()}),oH=b({width:n(),height:n()}),sH=[`owner-not-ready`,`store-read-failed`,`three-way-read-unavailable`,`invalid-stored`,`not-cluster-scoped`],cH=[{stepId:`face-embedding`,label:`Face recognition model`,defaultModelId:`auraface-r100`,indexName:`the enrolled face gallery`,options:[{id:`auraface-r100`,label:`AuraFace R100`}]},{stepId:`clip-embedding`,label:`Semantic search model`,defaultModelId:`siglip2-b16-224`,indexName:`the object semantic-search index`,options:[{id:`siglip2-b16-224`,label:`SigLIP2 B/16 (Apache-2.0)`}]}],WEe=`cluster-step-models`;function lH(e){return`clusterModel:${e}`}function GEe(e){return cH.some(t=>t.stepId===e)}var uH=Object.freeze(Object.fromEntries(cH.map(e=>[e.stepId,e.defaultModelId])));function dH(e){return e==null||e===``?{kind:`absent`}:typeof e==`string`?{kind:`chosen`,modelId:e}:{kind:`invalid`,value:e}}function fH(e){let t=[];for(let n of cH){let r=dH(e[lH(n.stepId)]);r.kind===`invalid`&&t.push({stepId:n.stepId,value:r.value})}return t}function pH(e){let t={};for(let n of cH){let r=dH(e[lH(n.stepId)]);t[n.stepId]=r.kind===`chosen`?r.modelId:n.defaultModelId}return t}function KEe(e){return typeof e==`object`&&!!e&&`key`in e}function qEe(e){return e===null?uH:pH(hH(e,mH()))}function JEe(e){return e===null?[]:fH(hH(e,mH()))}function mH(){return new Set(cH.map(e=>lH(e.stepId)))}function hH(e,t){let n={};for(let r of e.sections)for(let e of r.fields)!KEe(e)||typeof e.key!=`string`||t.has(e.key)&&(n[e.key]=e.value);return n}function YEe(e,t){let n=cH.find(t=>t.stepId===e);if(n===void 0)return null;let r=t[e];return r!==void 0&&r!==``?r:n.defaultModelId}var XEe=24,gH=[{stepId:`face-embedding`,key:`minLandmarkFaceSize`,label:`Min face size to embed (detection-frame px)`,description:`Faces smaller than this in the small frame the detector sees are not embedded, so they can never be recognised. Below it the face cannot be aligned reliably and a bad embedding matches everyone. Same value on every node. 0 = no limit.`,type:`slider`,min:0,max:64,step:2,default:24}];function _H(e,t){return`clusterStepSetting:${e}:${t}`}function ZEe(e){return gH.filter(t=>t.stepId===e)}var QEe=n().finite();function vH(e){let t={};for(let n of gH){let r=QEe.safeParse(e[_H(n.stepId,n.key)]),i=r.success?r.data:n.default,a=t[n.stepId]??{};t[n.stepId]={...a,[n.key]:i}}return t}var yH=vH({});function $Ee(e){return e===null?yH:vH(hH(e,new Set(gH.map(e=>_H(e.stepId,e.key)))))}function eDe(e,t,n){let r=n[e];return r===void 0||Object.keys(r).length===0?t===void 0?void 0:{...t}:t===void 0?{...r}:{...t,...r}}var bH=x([`new`,`entered`,`left`,`moving`,`idle`]),xH=x([`motion`,`object`,`audio`]),SH=i(`kind`,[eH,tH]),CH=x([`motion`,`audio`,`person`,`vehicle`,`animal`,`door`,`pir`,`smoke`,`water`,`button`,`package`,`generic`]),wH=x([`motion`,`audio`,`detection`,`sensor`,`control`,`custom`,`package`]),tDe=x([`macro`,`sub`]),TH=b({kind:l(),labelKey:l(),label:l(),color:l(),iconId:l(),icon:CH,category:wH,parentKind:l().nullable(),level:tDe,source:b({capName:l(),deviceId:n()})}),EH=b({deviceId:n(),kinds:S(TH).readonly()}),DH=b({id:l(),deviceId:n(),sourceDeviceId:n(),kind:l(),value:m(l(),C()).nullable(),timestamp:n()}),OH=b({x:n(),y:n(),timestamp:n(),bbox:aC,source:x([`frame`,`recovery`]).optional(),score:n().optional()}),nDe=b({timestamp:n(),position:OH,mediaId:n().int()}),kH=b({minX:n(),minY:n(),maxX:n(),maxY:n()}),AH=x([`full`,`slim`]),jH=b({label:l(),peakScore:n(),count:n(),firstAt:n(),lastAt:n()}),MH=x([`pipeline`,`onboard`,`sensor`,`audio`]),NH=x([`none`,`staging`,`trained`]),rDe=500,PH={markForTrain:v().optional(),debug:v().optional(),debugNote:l().max(500).optional(),favourited:v().optional()},FH={retrainStatus:NH.optional()},IH=b(PH),LH=b({trackId:l(),markForTrain:v(),debug:v(),debugNote:l(),favourited:v(),retrainStatus:NH}),iDe=h([p(1),p(2)]),RH=b({stepId:l(),modelId:l().optional(),decidedAt:n(),identityId:l().optional()}),zH={label:l().optional(),labelScore:n().optional(),labelMeta:RH.optional(),subLabel:l().optional(),subLabelScore:n().optional(),subLabelMeta:RH.optional()},BH=b({deviceId:n(),tracks:n().int(),files:n().int(),bytes:n().int()}),VH=b({generatedAt:n(),trackCount:n().int(),fileCount:n().int(),byteCount:n().int(),truncated:v(),devices:S(BH).readonly()}),HH=b({nodeId:l(),deviceKey:l().optional(),modelId:l().optional()}),UH=b({trackId:l(),deviceId:n(),className:l(),...zH,producingDeviceName:l().optional(),source:MH.optional(),firstSeen:n(),lastSeen:n(),positions:S(OH).readonly(),snapshots:S(nDe).readonly(),zonesVisited:S(l()).readonly(),zoneNames:S(l()).readonly().optional(),classes:S(l()).readonly().optional(),totalDistance:n(),state:bH,active:v(),importance:n().optional(),bestEventId:l().optional(),importanceReason:l().optional(),audioLabels:S(jH).readonly().optional(),envelope:kH.optional(),hasFace:v().optional(),hasEmbeddedFace:v().optional(),hasRider:v().optional(),previewMissReason:l().optional(),modelId:l().optional(),openedPlacement:HH.optional(),closedPlacement:HH.optional(),frameWidth:n().optional(),frameHeight:n().optional(),...PH,...FH}),WH={id:n().int(),deviceId:n(),timestamp:n()},GH=b({...WH,kind:p(`motion`),regionCount:n(),regions:S(b({bbox:aC,pixelCount:n(),intensity:n()})).readonly().optional(),frameWidth:n().optional(),frameHeight:n().optional(),mediaUrl:l().optional(),triggeredBy:PV.optional(),durationMs:n().nullable().optional(),edges:S(n()).readonly().optional()}),KH=x([`pipeline`,`onboard`]),qH=x([`enter`,`exit`]),JH=b({direction:qH,zoneId:l(),zoneName:l().optional()}),aDe=b({zoneId:l(),zoneName:l().optional(),overlapPct:n()}),YH=b({...WH,kind:p(`object`),source:KH.optional(),frameId:l().optional(),idempotencyKey:l().optional(),trackId:l().optional(),className:l(),...zH,confidence:n().optional(),bbox:aC.optional(),zones:S(l()).readonly().optional(),zoneOverlaps:S(aDe).readonly().optional(),spawnRefused:l().optional(),state:bH.optional(),zoneCrossing:JH.optional(),frameWidth:n().optional(),frameHeight:n().optional(),mediaId:n().int().optional(),keyFrameMediaId:n().int().optional(),mediaUrl:l().optional(),observedAt:n().optional(),packagePossible:v().optional(),packageLlmVerdict:QV.optional(),importance:n().optional()}),XH=b({...WH,kind:p(`audio`),rms:n(),dbfs:n(),classification:b({className:l(),originalClass:l().optional(),score:n()}).optional(),classifyOutcome:uC.optional(),mediaUrl:l().optional()}),ZH=x([`crop`,`thumbnail`,`snapshot`,`firstFrame`,`lastFrame`,`fullFrame`,`fullFrameBoxed`,`faceCrop`,`plateCrop`,`keyFrame`,`keyFrameSmall`,`thumbnailSmall`,`confirmationCrop`,`debugCrop`,`sceneFrame`,`lastSceneFrame`]),QH=b({mediaId:n().int(),kind:ZH,sizeBytes:n(),timestamp:n()}),$H=QH.extend({url:l(),base64:l()}),eU=$H.omit({base64:!0}),tU=x([`person`,`vehicle`,`animal`,`package`,`face`,`plate`]),nU=x([`subject`,`model_error`]),rU=x([`operator`,`assist`,`pipeline`,`llm`]),iU=b({x:n(),y:n(),w:n(),h:n()}),aU=b({source:rU,ref:l().min(1),bbox:iU,macroClass:tU,label:l().optional(),score:n().optional(),modelId:l().optional()}),oU=b({ref:l().min(1),snapshot:aU}),sU=x(yp),cU=b({ref:l(),savedId:l().optional(),status:sU,approximate:v(),origin:aU.optional(),macroClass:tU.optional(),label:l().optional(),iou:n().optional()}),lU=b({boxes:S(cU).readonly(),summary:b({counts:m(sU,n().int()),total:n().int(),changed:n().int(),approximate:v()})}),uU=b({id:l(),trackId:l().optional(),deviceId:n(),mediaKey:l(),bbox:iU,macroClass:tU,label:l().optional(),subLabel:l().optional(),kind:nU,source:rU,assistModelId:l().optional(),assistScore:n().optional(),origin:aU.nullable().optional(),exportedInBatch:l().optional(),createdAt:n()}),dU=uU.omit({id:!0,trackId:!0,deviceId:!0,mediaKey:!0,createdAt:!0,exportedInBatch:!0}),fU=x([`correct`,`wrong`,`wrong-label`]),pU=b({verdict:fU,suggestedClass:l().optional(),suggestedMacroClass:tU.optional(),suggestedLabel:l().optional(),trackId:l(),at:n().optional()}),mU=b({trackId:l(),className:l(),label:l().optional(),bbox:iU.optional(),verdict:fU,suggestedClass:l().optional(),at:n().optional()}),hU=b({trackId:l(),deviceId:n(),className:l(),label:l().optional(),firstSeen:n(),lastSeen:n(),frameCount:n().int(),annotationCount:n().int(),verdict:pU.optional()}),gU=b({mediaId:n().int(),kind:ZH,timestamp:n(),sizeBytes:n().int(),copied:v()}),_U=b({bbox:iU,macroClass:tU,label:l().optional(),subLabel:l().optional(),score:n().optional(),modelId:l().optional(),trackId:l(),basis:x([`subject-box`,`position`,`verdict`]),deltaMs:n()}),vU=x([`track`,`recording`]),yU=b({frameId:l(),deviceId:n(),origin:vU,trackId:l().optional(),sourceMediaId:n().int().optional(),epochMs:n().optional(),sourceKind:ZH,sizeBytes:n().int(),width:n().int(),height:n().int(),copiedAt:n(),capturedAt:n().optional(),complete:v(),pipelineBoxes:S(_U).readonly().optional(),collectionIds:S(l()).readonly().optional(),verdict:pU.optional(),revision:n().int().optional(),dismissed:S(oU).readonly().optional(),review:lU.optional(),imageUrl:l().optional(),thumbnailUrl:l().optional()}),bU=x([`source-missing`,`unreadable-image`,`write-failed`]),xU=b({copied:S(yU).readonly(),refused:S(b({sourceMediaId:n().int(),reason:bU})).readonly()}),SU=b({candidates:S(gU).readonly(),copies:S(yU).readonly(),autoPickMediaId:n().int().optional()}),CU=x([`unannotated`,`annotated`,`complete`]),wU=b({workState:CU.optional(),deviceIds:S(n()).max(500).optional(),collectionId:l().optional(),classes:S(tU).optional(),page:n().int().positive().default(1),pageSize:n().int().positive().max(100).default(50)}),TU=yU.extend({workState:CU}),EU=b({frames:S(TU).readonly(),total:n().int().nonnegative(),page:n().int().positive(),pageSize:n().int().positive()}),DU=b({deviceId:n(),unannotated:n().int().nonnegative(),annotated:n().int().nonnegative(),complete:n().int().nonnegative(),pctOfCorpus:n().min(0).max(1).nullable()}),OU=b({total:n().int().nonnegative(),unannotated:n().int().nonnegative(),annotated:n().int().nonnegative(),complete:n().int().nonnegative(),cameras:S(DU).readonly()}),kU=b({deviceIds:S(n()).optional(),frameIds:S(l()).max(2e4).optional(),collectionIds:S(l()).max(200).optional(),collectionId:l().optional(),batchId:l().optional(),completeOnly:v().optional(),workState:CU.optional(),classes:S(tU).optional()}),AU=x([`frames`,`crops`]),jU=b({kind:p(`http`),method:x([`PUT`,`POST`]),url:l().url(),headers:m(l(),l()).optional()}),MU=b({batchId:l(),frames:n().int(),crops:n().int(),annotations:n().int(),missing:n().int(),bytes:n().int(),sha256:l(),status:n().int()}),NU=i(`kind`,[b({kind:p(`package`),zone:iU.optional()}),b({kind:p(`objects`),modelId:l(),minScore:n().optional()})]),PU=i(`kind`,[b({kind:p(`proposed`),modelId:l(),stepId:l(),minScore:n(),proposals:S(dU).readonly(),belowThreshold:n().int()}),b({kind:p(`refused`),reason:l(),detail:l().optional()})]),FU=b({id:l(),name:l(),createdAt:n(),frameCount:n().int()}),IU=i(`kind`,[b({kind:p(`created`),collection:FU}),b({kind:p(`refused`),reason:x([`empty-name`,`duplicate-name`])})]),LU=i(`kind`,[b({kind:p(`renamed`),collection:FU}),b({kind:p(`refused`),reason:x([`empty-name`,`duplicate-name`,`unknown-collection`])})]),RU=i(`kind`,[b({kind:p(`added`),collectionId:l(),frame:yU,reused:v()}),b({kind:p(`refused`),reason:x([`unknown-collection`,`still-unavailable`,`still-busy`,`unreadable-image`,`write-failed`]),detail:l().optional()})]),zU=b({id:l(),name:l(),model:l(),kind:l(),leavesHouse:v()}),BU=dU.extend({reason:l()}),VU=b({ref:l(),verdict:x([`confirmed`,`wrong-class`,`not-an-object`,`uncertain`]),suggestedClass:tU.optional(),reason:l()}),HU=i(`kind`,[b({kind:p(`proposed`),profileId:l(),model:l(),leftHouse:v(),proposals:S(BU).readonly(),reviews:S(VU).readonly(),rejected:n().int()}),b({kind:p(`refused`),reason:x([`unknown-frame`,`unreadable-frame`,`unknown-profile`,`profile-disabled`,`no-vision`,`cloud-not-confirmed`,`llm-error`,`malformed-answer`]),detail:l().optional()})]),UU=b({deviceIds:S(n()).readonly().optional(),collectionIds:S(l()).max(200).readonly().optional(),frameIds:S(l()).max(2e4).readonly().optional()}),WU=b({frames:n().int(),completeFrames:n().int(),completeness:n(),subjects:n().int(),modelErrors:n().int(),hardNegatives:n().int(),cells:S(b({macroClass:l(),deviceId:n(),lighting:x([`day`,`night`,`unknown`]),subjects:n().int(),frames:n().int()})).readonly(),cameras:S(b({deviceId:n(),frames:n().int(),completeFrames:n().int()})).readonly()}),oDe=b({id:l(),name:l(),createdAt:n(),selection:UU,layout:AU,completeOnly:v(),frameCount:n().int(),annotationHash:l(),manifestSchema:l(),stats:WU}),GU=b({collectionIds:S(l()).min(1),workState:x([`complete`,`annotated_or_complete`,`any_annotated`]).default(`complete`)}),KU=i(`kind`,[b({kind:p(`resolved`),frameIds:S(l()).max(2e4).readonly(),stats:WU,annotationHash:l(),layout:AU}),b({kind:p(`refused`),reason:x([`unknown-collection`,`no-frames`]),detail:l()})]),qU=b({trackId:l(),retrainStatus:NH,changed:v(),reason:x([`unknown-track`,`no-frames-copied`,`not-staging`,`not-trained`,`unchanged`]).optional()}),JU=1e3,YU=5e3,XU=b({deviceId:n(),since:n().optional(),until:n().optional(),limit:n().int().min(1).max(YU).default(JU),projection:x([`full`,`slim`]).optional()}),sDe=XU.extend({classFilter:l().optional()}),ZU=b({deviceIds:S(n()),since:n().optional(),until:n().optional(),limit:n().int().min(1).max(1e3).default(200),cursor:l().optional(),projection:AH.optional(),includeStationary:v().optional(),classes:S(l()).optional(),excludeSources:S(MH).optional()}),QU=b({tracks:S(UH).readonly(),nextCursor:l().nullable()}),$U=50,eW=200,cDe=b({deviceId:n(),since:n(),until:n(),limit:n().int().min(1).max(eW).default($U),minImportance:n().min(0).max(1).optional(),classFilter:l().optional()}),tW=b({id:l(),trackId:l(),timestamp:n(),className:l(),...zH,importance:n(),bestEventId:l(),windowMs:n().optional(),audioLabels:S(jH).readonly().optional(),...PH,...FH}),lDe=b({deviceIds:S(n()).min(1).max(200),since:n(),until:n(),limit:n().int().min(1).max(eW).default($U),minImportance:n().min(0).max(1).optional(),classFilter:l().optional()}),uDe=b({deviceId:n(),events:S(tW).readonly()}),nW=b({bucketStart:n(),motion:n().int(),object:n().int(),audio:n().int(),audioDbfs:n().optional()}),dDe=200,rW=b({deviceId:n(),read:x([`read`,`unreadable`]),buckets:S(nW).readonly()}),fDe=b({trackId:l(),className:l(),confidence:n(),bbox:aC,zones:S(l()).readonly(),state:bH}),pDe=ce({id:l(),kind:x([`first-level`,`detail`]),macroClass:l(),score:n(),bbox:b({x:n(),y:n(),width:n(),height:n()}),labels:S(ce({label:l(),score:n()})).readonly(),parentId:l().optional()}),iW=YH.extend({score:n()}),mDe=b({text:l(),deviceId:n().optional(),since:n().optional(),until:n().optional(),classFilter:l().optional(),limit:n().default(50),minScore:n().min(0).max(1).optional(),strictness:dde.optional(),modelId:l().min(1).optional()}),aW=b({tracks:n().int(),events:n().int(),media:n().int(),faces:n().int(),plates:n().int(),embeddings:n().int()}),hDe=b({mediaDropped:n().int(),tracks:n().int(),events:n().int()}),gDe=b({deviceId:n(),rows:n().int(),bytes:n().int()}),_De=b({totalRows:n().int(),totalBytes:n().int(),devices:S(gDe).readonly()}),vDe=b({kind:ZH,rows:n().int(),bytes:n().int()}),yDe=b({totalRows:n().int(),totalBytes:n().int(),kinds:S(vDe).readonly(),unaccountedRows:n().int(),unaccountedBytes:n().int()}),oW=b({motion:n().int(),object:n().int(),audio:n().int()}),bDe=b({deviceId:n().optional(),since:n().optional(),until:n().optional(),maxTracks:n().int().positive().optional(),executeOnNodeId:l().optional(),pacingMs:n().int().nonnegative().optional(),force:v().optional()}),xDe=b({deleted:n(),failedIndexes:S(l()).optional()}),sW=x([`stores-unavailable`,...sH,`method-unavailable`,`read-failed`,`reads-disagree`,`not-a-clip-model`,`force-requires-max-tracks`]),SDe=b({started:v(),alreadyRunning:v(),refusal:sW.optional(),modelId:l().optional(),index:l().optional()}),CDe=b({running:v(),scanned:n(),rebuilt:n(),missingKeyFrame:n(),missingEvent:n(),missingBbox:n(),boxSource:b({subjectBox:n(),positions:n(),event:n(),refused:n()}),alreadyInSpace:n(),force:v().nullable(),forcedInSpace:n(),notRunnable:n(),noCapableNode:n(),failed:n(),complete:v().nullable(),startedAtMs:n().nullable(),finishedAtMs:n().nullable(),error:l().nullable(),modelId:l().nullable(),index:l().nullable()}),wDe=b({started:v(),alreadyRunning:v()}),TDe=b({mode:x([`report`,`reclaim`]).default(`report`),scopes:S(x([`motion-still`,`track-filmstrip`])).min(1).optional(),deviceIds:S(n().int()).min(1).optional(),restart:v().optional(),pageSize:n().int().min(50).max(5e3).optional(),maxRowsPerDevice:n().int().min(1).max(5e5).optional(),maxReclaimPerDevice:n().int().min(1).max(5e5).optional(),maxBytesPerRun:n().int().min(1).optional(),budgetMinutes:n().int().min(1).max(720).optional(),throttleBytesPerSec:n().int().min(64*1024).optional(),graceMinutes:n().int().min(1).max(10080).optional()}),EDe=b({running:v(),mode:x([`report`,`reclaim`]).nullable(),totalExamined:n(),totalEligible:n(),totalReclaimed:n(),totalBytesReclaimed:n(),totalRefused:n(),devicesDone:n(),complete:v().nullable(),startedAtMs:n().nullable(),finishedAtMs:n().nullable(),error:l().nullable()}),cW=x([`motion`,`audio-dbfs`,`battery`,`occupancy`]),DDe=`|`;function ODe(e,t){let n=e??``;return t===void 0?n:`${n}|${t}`}function kDe(e){let t=e.indexOf(`|`);return t<0?{zoneId:e}:{zoneId:e.slice(0,t),className:e.slice(t+1)}}var lW=b({scope:l(),bucketStart:n().int(),samples:n().int().nonnegative(),sum:n(),min:n(),max:n()}),uW={name:`pipeline-analytics`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[T.Camera],exposesDeviceSettings:!0,methods:{getActiveTracks:k(b({deviceId:n()}),S(UH).readonly()),getTrack:k(b({deviceId:n(),trackId:l()}),UH.nullable()),listTracks:k(b({deviceId:n(),since:n().optional(),until:n().optional(),limit:n().optional(),zone:SH.optional(),projection:AH.optional(),includeStationary:v().optional(),classes:S(l()).optional(),excludeSources:S(MH).optional()}),S(UH).readonly()),listRecentTracks:k(ZU,QU),clearTracks:k(b({deviceId:n()}),_(),{kind:`mutation`,auth:`admin`}),getMotionEvents:k(XU,S(GH).readonly()),getObjectEvents:k(sDe,S(YH).readonly()),getAudioEvents:k(XU,S(XH).readonly()),listEventKinds:k(b({deviceId:n()}),S(TH).readonly()),listEventKindsBatch:k(b({deviceIds:S(n()).min(1).max(200)}),S(EH).readonly()),getSensorEvents:k(b({deviceId:n(),since:n().optional(),until:n().optional(),kinds:S(l()).optional(),limit:n().int().min(1).max(YU).default(JU)}),S(DH).readonly()),getKeyEvents:k(cDe,S(tW).readonly()),getKeyEventsBatch:k(lDe,S(uDe).readonly()),readLongTermSeries:k(b({deviceId:n(),series:cW,scope:l().optional(),from:n(),to:n(),limit:n().int().positive().optional()}),S(lW).readonly()),getEventDensity:k(b({deviceId:n(),since:n(),until:n(),bucketMs:n().int().positive()}),S(nW).readonly()),getEventDensityBatch:k(b({deviceIds:S(n()).min(1).max(200),since:n(),until:n(),bucketMs:n().int().positive()}),S(rW).readonly()),pruneEventsBefore:k(b({deviceId:n(),cutoffMs:n()}),b({motion:n().int(),object:n().int(),audio:n().int()}),{kind:`mutation`,auth:`admin`}),pruneTracksBefore:k(b({deviceId:n(),cutoffMs:n()}),aW,{kind:`mutation`,auth:`admin`}),wipeAllAnalytics:k(b({deviceId:n()}),aW,{kind:`mutation`,auth:`admin`}),reconcileFromDisk:k(b({deviceId:n()}),hDe,{kind:`mutation`,auth:`admin`}),deleteTracks:k(b({deviceId:n(),trackIds:S(l()).min(1)}),b({deleted:n().int(),failed:S(l()).readonly(),sparedMediaIds:S(n().int()).readonly().optional()}),{kind:`mutation`,auth:`admin`}),setTrackFlags:k(b({deviceId:n(),trackId:l(),flags:IH}),LH,{kind:`mutation`,notOperatorFacing:`curating a recorded track in the review UI, not a live step`}),listArchivedDebugNotes:k(Ap,S(kp).readonly(),{kind:`query`}),setTrackRelation:k(Ip,Pp,{kind:`mutation`,notOperatorFacing:`curating recorded tracks in the review UI, not a live step`}),clearTrackRelation:k(Lp,Rp,{kind:`mutation`,notOperatorFacing:`curating recorded tracks in the review UI, not a live step`}),setTrackPurity:k(zp,Bp,{kind:`mutation`,notOperatorFacing:`curating a recorded track in the review UI, not a live step`}),listTrackRelations:k(Vp,Hp,{kind:`query`}),listBirthDecisions:k(Op,S(Dp).readonly(),{kind:`query`}),getEventStoreFootprint:k(b({}),_De,{kind:`query`,auth:`admin`}),getEventMediaFootprintByKind:k(b({deviceId:n().int().optional()}),yDe,{kind:`query`,auth:`admin`}),pruneEvents:k(b({olderThanMs:n(),reason:Xp.optional()}),oW,{kind:`mutation`,auth:`admin`}),deleteDeviceEvents:k(b({deviceId:n()}),oW,{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:k(wm,b({paused:p(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:k(wm,b({resumed:p(!0)}),{kind:`mutation`,auth:`admin`}),refreshStorageLocationsForMigration:k(wm,b({refreshed:p(!0)}),{kind:`mutation`,auth:`admin`}),startStorageMigrationMove:k(Nm,b({jobId:l()}),{kind:`mutation`,auth:`admin`}),getStorageMigrationMoveStatus:k(b({jobId:l()}),xm.nullable(),{auth:`admin`}),cancelStorageMigrationMove:k(b({jobId:l()}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`}),relocateMedia:k(Dm,b({jobId:l()}),{kind:`mutation`,auth:`admin`}),countUnstampedEventMedia:k(b({}),km,{auth:`admin`}),getMediaLocationCensus:k(Am,Mm,{kind:`query`,auth:`admin`}),countRelocatableMedia:k(ah,ih,{kind:`query`,auth:`admin`}),listRelocateMediaJobs:k(b({}),S(xm).readonly(),{kind:`query`,auth:`admin`}),cancelRelocateMedia:k(b({jobId:l()}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`}),listOpsLog:k(Qp,S(Zp).readonly(),{kind:`query`,auth:`admin`}),reclaimDebugMedia:k(TDe,wDe,{kind:`mutation`,auth:`admin`}),getMediaReclaimStatus:k(b({}),EDe,{kind:`query`,auth:`admin`}),getTrainingExportSummary:k(b({deviceIds:S(n()).optional()}),VH,{kind:`query`,auth:`admin`}),getTrainingExportUrl:k(b({deviceIds:S(n()).optional()}),b({url:l()}),{kind:`query`,auth:`admin`}),listRetrainStaging:k(b({deviceIds:S(n()).optional(),limit:n().int().min(1).max(500).optional()}),S(hU).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),listRetrainCorpusPage:k(wU,EU,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),getRetrainCorpusKpi:k(b({}),OU,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),listRetrainFrames:k(b({trackId:l()}),SU,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),selectRetrainFrames:k(b({deviceId:n(),trackId:l(),mediaIds:S(n().int()).min(1)}),xU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),deselectRetrainFrame:k(b({deviceId:n(),trackId:l().optional(),frameId:l()}),b({removed:v(),removedAnnotations:n().int()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),getRetrainFrameImage:k(b({frameId:l()}),b({base64:l(),width:n().int(),height:n().int()}),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),proposeRetrainAnnotations:k(b({deviceId:n(),trackId:l().optional(),frameId:l(),subject:NU,nodeId:l().optional()}),PU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainAnnotations:k(b({trackId:l().optional(),frameIds:S(l()).max(2e3).optional()}),S(uU).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),saveRetrainAnnotations:k(b({deviceId:n(),trackId:l().optional(),frameId:l(),annotations:S(dU),expectedRevision:n().int().optional(),dismissed:S(oU).optional()}),S(uU).readonly(),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),backfillRetrainOrigins:k(b({deviceId:n(),trackId:l().optional(),frameId:l(),expectedRevision:n().int().optional(),origins:S(b({annotationId:l(),origin:aU})).min(1).max(500)}),b({updated:n().int(),skipped:n().int(),revision:n().int()}),{kind:`mutation`,auth:`admin`}),completeRetrainTrack:k(b({deviceId:n(),trackId:l()}),qU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),restageRetrainTrack:k(b({deviceId:n(),trackId:l()}),qU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),getRetrainExportUrl:k(kU.extend({layout:AU.optional()}),b({url:l()}),{kind:`query`,auth:`admin`}),setRetrainFrameComplete:k(b({deviceId:n(),trackId:l().optional(),frameId:l(),complete:v()}),yU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),writeRetrainArchive:k(b({filter:kU,layout:AU,target:jU}),MU,{kind:`mutation`,auth:`admin`,timeoutMs:60*6e4}),offerRetrainArchive:k(b({filter:kU,layout:AU}),b({ticket:Ti,frames:n().int(),annotations:n().int()}),{kind:`mutation`,auth:`admin`,timeoutMs:12e4}),listRetrainAssistProfiles:k(b({}),S(zU).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),proposeRetrainAnnotationsWithLlm:k(b({deviceId:n(),trackId:l().optional(),frameId:l(),profileId:l(),classes:S(tU).min(1),boxes:S(b({ref:l(),bbox:iU,macroClass:tU,label:l().optional()})).max(50),allowCloud:v()}),HU,{kind:`mutation`,auth:`admin`,timeoutMs:18e4}),createRetrainCollection:k(b({name:l().max(120)}),IU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainCollections:k(b({}),S(FU).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),resolveRetrainTrainingCorpus:k(GU,KU,{kind:`query`,auth:`admin`,timeoutMs:6e4}),renameRetrainCollection:k(b({id:l(),name:l().max(120)}),LU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),deleteRetrainCollection:k(b({id:l()}),b({deleted:v(),removedFrames:n().int()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),addRetrainFrameFromRecording:k(b({collectionId:l(),deviceId:n(),epochMs:n(),verdictSubject:mU.optional()}),RU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`,timeoutMs:6e4}),addRetrainFramesToCollection:k(b({collectionId:l(),frameIds:S(l()).min(1).max(500)}),b({added:n().int(),alreadyMember:n().int(),unknownFrameIds:S(l()).readonly()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),removeRetrainFrameFromCollection:k(b({collectionId:l(),frameId:l()}),b({removed:v(),deletedFrame:v()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainCollectionFrames:k(b({collectionId:l()}),S(yU).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),getEventMedia:k(b({ownerType:Eu,eventId:n().int(),kind:ZH.optional(),deviceId:n()}),S($H).readonly()),getTrackMedia:k(b({trackId:l(),kinds:S(ZH).optional(),deviceId:n()}),S($H).readonly()),listTrackMedia:k(b({trackId:l(),deviceId:n()}),S(eU).readonly()),listEventMedia:k(b({ownerType:Eu,eventId:n().int(),deviceId:n()}),S(eU).readonly()),ownersWithMedia:k(b({deviceId:n(),ownerKind:Ou,ownerIds:S(l()).max(5e3)}),S(l()).readonly()),searchObjectEvents:k(mDe,S(iW).readonly(),{caller:`required`}),wipeObjectEmbeddings:k(b({}),xDe,{kind:`mutation`,auth:`admin`}),rebuildObjectEmbeddings:k(bDe,SDe,{kind:`mutation`,auth:`admin`}),getObjectEmbeddingRebuildStatus:k(b({}),CDe)},events:{onFrameTracked:{data:b({deviceId:n(),timestamp:n(),frameWidth:n(),frameHeight:n(),detections:S(pDe).readonly()}),notOperatorFacing:`one tracker frame — stream rate, never an automation trigger`},onTrackStarted:{data:b({deviceId:n(),trackId:l(),className:l()}),trigger:{category:w.PipelineAnalyticsTrackStarted,label:P(`Subject appeared`,`Soggetto comparso`),phrase:P(`When {device} starts following a subject`,`Quando {device} inizia a seguire un soggetto`),icon:`scan-eye`}},onTrackEnded:{data:b({deviceId:n(),trackId:l(),className:l(),durationMs:n()}),trigger:{category:w.PipelineAnalyticsTrackEnded,label:P(`Subject left`,`Soggetto uscito`),phrase:P(`When a subject leaves the view of {device}`,`Quando un soggetto esce dall’inquadratura di {device}`),icon:`scan-eye`}},onDetectionEvent:{data:b({deviceId:n(),kind:xH,eventId:l(),timestamp:n()}),trigger:{category:w.PipelineAnalyticsDetectionEvent,label:P(`Detection event`,`Evento di rilevamento`),phrase:P(`When {device} records a detection event`,`Quando {device} registra un evento di rilevamento`),icon:`radar`}}},vocabulary:{noun:P(`Tracking`,`Tracciamento`),order:3200,extraEvents:[{category:w.PipelineAnalyticsPackageDelivered,label:P(`Package delivered`,`Pacco consegnato`),phrase:P(`When a package is left in front of {device}`,`Quando viene lasciato un pacco davanti a {device}`),icon:`package`},{category:w.PipelineAnalyticsPackagePickedUp,label:P(`Package picked up`,`Pacco ritirato`),phrase:P(`When a package is picked up in front of {device}`,`Quando viene ritirato un pacco davanti a {device}`),icon:`package-open`}]}},dW=b({x:n(),y:n(),w:n(),h:n()}),fW=b({stepId:l(),modelId:l(),detections:S(b({bbox:u([n(),n(),n(),n()]),score:n(),landmarks:S(b({x:n(),y:n()})).optional()})).min(1)}),pW=b({handle:Ca,cropFrameSpace:b({x:n(),y:n(),w:n(),h:n()})});b({crop:b({left:n(),top:n(),width:n().positive(),height:n().positive()}).optional(),content:b({width:n().int().positive(),height:n().int().positive()}),fit:x([`stretch`,`contain`]),format:x([`rgb`,`gray`,`jpeg`])});var ADe=b({registryId:l().min(1),id:l().min(1),width:n().int().positive(),height:n().int().positive(),format:x([`rgb`,`gray`]),timestamp:n(),capturedAt:n().optional()}),mW=x([`onnx`,`coreml`,`openvino`,`tflite`,`pt`,`gguf`]),hW=x([`detector`,`cropper`,`classifier`,`refiner`,`audio-classifier`]),gW=b({runtime:p(`python`),backend:l(),format:mW,device:l().optional()}),_W=b({deviceKey:l().nullable(),runtime:l(),batchMode:l(),windowMs:n(),maxBatchSize:n(),concurrency:n(),numWorkers:n()}),jDe=b({engine:gW,devices:S(b({id:l(),label:l(),description:l().optional()})).readonly(),defaultDevice:l()}),vW=a(()=>b({addonId:l(),addonName:l(),slot:hW,inputClasses:S(l()).readonly(),outputClasses:S(l()).readonly(),enabled:v(),modelId:l(),children:S(vW).readonly(),group:l().optional(),settings:m(l(),C()).optional()})),MDe=b({id:l(),name:l(),formats:m(l(),Hde),group:$h.optional(),legacy:v().optional(),provider:eg.optional(),defaultConfidence:n().optional(),suppliesSteps:S(tg).readonly().optional()}),NDe=ye(),PDe=b({id:l(),name:l(),slot:hW,inputClasses:S(l()).readonly(),outputClasses:S(l()).readonly(),childSlots:S(hW).readonly(),models:S(MDe).readonly(),defaultModelId:l(),defaultModelIdByFormat:m(l(),l()).optional(),enabledByDefault:v().optional(),defaultConfidence:n(),group:l().optional(),configSchema:S(NDe).readonly().optional()}),FDe=b({id:hW,label:l(),priority:n(),parentSlot:hW.nullable(),addons:S(PDe).readonly()}),IDe=b({availableEngines:S(jDe).readonly(),selectedEngine:gW,slots:S(FDe).readonly()}),LDe=b({runtimeId:x([`onnx`,`openvino`,`coreml`,`edgetpu`]).nullable(),device:l().nullable(),state:x([`idle`,`installing`,`verifying`,`ready`,`failed`]),progress:n().optional(),error:l().optional(),nextRetryAt:n().optional(),configIssues:S(l()).optional()}),yW=b({addonId:l(),chosen:l(),running:l(),format:l()}),bW=b({addonId:l(),kind:x([`unknown-addon`,`no-format-build`,`unknown-device`]),detail:l()}),xW=b({ok:v(),issues:S(bW).readonly(),substitutions:S(yW).readonly(),format:l()}),RDe=b({filename:l(),stepIds:S(l()).readonly().optional()}),zDe=b({base64:l(),filename:l()}),BDe=b({filename:l(),sizeKb:n()}),VDe=b({base64:l()}),HDe=b({id:l(),name:l(),description:l(),available:v(),rawLabels:S(l()).readonly().optional()}),UDe=b({activeBackend:l(),availableBackends:S(HDe).readonly(),sampleRate:n(),chunkDurationMs:n()}),WDe=b({filePath:l(),sizeMB:n(),durationMs:n()}),GDe=b({success:v(),error:l().optional(),frame:ye().optional()}),KDe=ye(),qDe=ye(),JDe=ye(),YDe=ye(),SW={name:`pipeline-executor`,scope:`system`,mode:`singleton`,methods:{getAvailableEngines:k(_(),S(gW)),getSelectedEngine:k(_(),gW),getEngineProvisioning:k(b({nodeId:l()}),LDe),getVideoPipelineSteps:k(_(),m(l(),b({modelId:l(),settings:m(l(),C()).readonly()}))),setVideoPipelineSteps:k(b({steps:m(l(),b({modelId:l(),settings:m(l(),C()).readonly()}))}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getInferenceDeviceHealth:k(b({nodeId:l()}),b({unhealthy:S(b({deviceKey:l(),state:x([`failed`,`backoff`]),since:n(),deaths:n(),lastError:l(),absentReason:x([`no-gpu-device`]).optional()})).readonly()})),rearmInferenceDevice:k(b({nodeId:l(),deviceKey:l()}),b({rearmed:v()}),{kind:`mutation`,auth:`admin`}),getSchema:k(_(),IDe),getOrchestratorConfigSchema:k(_(),KDe),validatePipeline:k(b({steps:S(Ha),deviceKey:l().optional()}),xW),getCapabilities:k(_(),JDe),getAddonModels:k(b({addonId:l()}),YDe),downloadModel:k(b({addonId:l(),modelId:l(),format:mW}),WDe,{kind:`mutation`}),deleteModel:k(b({addonId:l(),modelId:l(),format:mW}),b({success:p(!0)}),{kind:`mutation`}),runPipeline:k(b({steps:S(Ha).min(1),frame:iC.optional(),frameRef:ADe.optional(),frameHandle:Ca.optional(),imageBase64:l().optional(),image:y(Uint8Array).optional(),referenceImage:l().optional(),deviceId:n().optional(),sessionId:l().optional(),plane:x([`full`,`frame`]).optional(),deviceKey:l().optional(),nativeCropRef:pW.optional(),replay:p(!0).optional(),suppliedRoot:fW.optional(),motionRegions:S(dW).optional()}),Ua,{kind:`mutation`}),runPipelineBatch:k(b({steps:S(Ha).min(1),frames:S(iC).min(1).max(255),deviceId:n().optional(),sessionId:l().optional(),frameId:n().int().nonnegative().optional(),deviceKey:l().optional()}),b({results:S(Ua).readonly()}),{kind:`mutation`}),cacheFrameInPool:k(b({data:y(Uint8Array),width:n().int().positive(),height:n().int().positive(),format:x([`rgb`,`bgr`,`gray`])}),b({frameId:n(),width:n(),height:n()}),{kind:`mutation`}),inferCached:k(b({stepId:l(),frameId:n().int(),modelId:l().min(1)}),m(l(),C()),{kind:`mutation`}),uncacheFrame:k(b({frameId:n().int()}),_(),{kind:`mutation`}),getEffectiveTuning:k(b({deviceKey:l().optional()}),_W),listLoadedEngines:k(_(),S(b({engineKey:l(),engine:gW,modelsLoaded:S(l()).readonly(),inUseByCameras:S(n()).readonly(),kind:x([`runtime`,`device-pool`]),poolPid:n().nullable(),idleMs:n().nullable(),idleTtlMs:n().nullable()})).readonly()),spinEngine:k(b({engine:gW}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),killEngine:k(b({engine:gW,force:v().optional()}),b({success:v(),reason:l().optional()}),{kind:`mutation`,auth:`admin`}),listReferenceImages:k(_(),S(RDe).readonly()),getReferenceImage:k(b({filename:l()}),zDe.nullable()),getReferenceAudioFiles:k(_(),S(BDe).readonly()),getReferenceAudio:k(b({filename:l()}),VDe.nullable()),getAudioCapabilities:k(_(),UDe),runAudioTest:k(b({addonId:l(),modelId:l(),filename:l().optional(),settings:m(l(),C()).optional()}),GDe,{kind:`mutation`}),getDetectionConfigSchema:k(_(),qDe)},vocabulary:{notOperatorFacing:j.PIPELINE}},XDe=b({activeCameras:n(),throttledCameras:n(),avgInferenceTimeMs:n(),queueDepth:n()}),CW=b({detectionMode:x([`disabled`,`always-on`,`on-motion`]),configuredFps:n(),actualFps:n(),queueDepth:n(),avgInferenceTimeMs:n(),droppedFrames:n(),nativeCropMisses:n().optional(),phase:x([`idle`,`watching`,`active`])}),wW=CW.extend({deviceId:n()}),TW=x([`polygon`,`tripwire`]),EW=b({x:n(),y:n()}),DW=b({id:l(),name:l(),kind:TW.default(`polygon`),polygon:S(EW).readonly(),color:l().default(`#3b82f6`)}),OW={name:`zones`,scope:`device`,mode:`singleton`,deviceTypes:[T.Camera],methods:{listZones:k(b({deviceId:n()}),S(DW).readonly()),addZone:k(b({deviceId:n(),zone:DW}),_(),{kind:`mutation`,auth:`admin`}),removeZone:k(b({deviceId:n(),zoneId:l()}),_(),{kind:`mutation`,auth:`admin`}),updateZone:k(b({deviceId:n(),zone:DW}),_(),{kind:`mutation`,auth:`admin`})},runtimeState:b({zones:S(DW).readonly()}),durability:`restored`,history:`none`,vocabulary:{noun:P(`Zones`,`Zone`),order:3370}},kW={fpsPerStream:10,budgetMinutes:45,minBudgetMinutes:10,maxBudgetMinutes:120,staleAfterDays:30,settleSec:5,measureSec:20,drainTimeoutSec:120,maxModelsPerDevice:6},AW=x([`device`,`pipeline`]),jW=b({deviceKey:l().min(1),modelIds:S(l().min(1)).min(1).max(kW.maxModelsPerDevice)}),MW=b({nodeId:l().min(1),devices:S(jW).min(1),phases:S(AW).min(1).default([`device`,`pipeline`]),steps:S(l().min(1)).default([]),fpsPerStream:n().int().min(1).max(30).default(kW.fpsPerStream),budgetMinutes:n().int().min(kW.minBudgetMinutes).max(kW.maxBudgetMinutes).default(kW.budgetMinutes),keepDownloadedModels:v().default(!1),acceptInsufficientHeadroom:v().default(!1)}),NW=x([`benchmark-active`,`node-offline`,`unknown-device`,`no-phase`,`insufficient-headroom`]),PW=b({kind:NW,detail:l(),overridable:v()}),FW=b({deviceId:n(),placedOnNode:v(),pinnedToNode:v()}),IW=b({deviceId:n(),reason:p(`only-frame-source`)}),LW=b({nodeId:l(),online:v(),moving:S(FW).readonly(),staying:S(IW).readonly(),estimatedDurationMs:n(),budgetMs:n(),phases:S(AW).readonly(),steps:S(l()).readonly(),devices:S(jW).readonly(),headroom:b({sessionsNow:n(),otherNodesCapacitySessions:n().nullable()}),refusals:S(PW).readonly(),canStart:v()}),RW=b({phase:x([`preparing`,`device`,`pipeline`,`cleanup`]),deviceKey:l().nullable(),modelId:l().nullable(),load:n().nullable(),cellsDone:n(),cellsTotal:n(),message:l()}),zW=x([`p95`,`drops`,`errors`,`stall`,`cpu`,`ram`,`none`]),BW=b({load:n(),pass:v(),p95Ms:n(),dropRatio:n(),fps:n(),cpuPct:n().nullable(),ramFreePct:n().nullable(),failReasons:S(l()).readonly()}),VW=b({phase:p(`device`),deviceKey:l(),modelId:l(),p50Ms:n(),p95Ms:n(),p99Ms:n(),fps:n(),kMax:n(),limitedBy:zW,warmupMs:n(),ramp:S(BW).readonly()}),HW=b({phase:p(`pipeline`),deviceKey:l(),modelId:l(),steps:S(l()).readonly(),maxSessions:n(),limitedBy:zW,stepsFired:S(l()).readonly(),warmupMs:n(),ramp:S(BW).readonly()}),UW=i(`phase`,[VW,HW]),WW=b({pipelineVersion:l().nullable(),cpuModel:l().nullable(),ramGb:n().nullable(),os:l().nullable(),pools:m(l(),b({runtime:l(),numWorkers:n(),concurrency:n(),batchMode:l()})).default({})}),GW=b({id:l(),revision:l().nullable(),frames:n(),width:n(),height:n()}),KW=b({runId:l().min(1),devices:S(jW).min(1),phases:S(AW).min(1),steps:S(l()).default([]),fpsPerStream:n().int().min(1).max(30),deadlineAtMs:n(),settleSec:n().min(0).max(60).default(kW.settleSec),measureSec:n().min(2).max(300).default(kW.measureSec),keepDownloadedModels:v().default(!1)}),qW=x([`running`,`done`,`failed`,`aborted`]),JW=b({runId:l(),nodeId:l(),state:qW,progress:RW.nullable(),cells:S(UW).readonly(),fingerprint:WW.nullable(),clip:GW.nullable(),activeCameraIds:S(n()).readonly(),deletedModels:S(l()).readonly(),error:l().nullable(),startedAtMs:n(),finishedAtMs:n().nullable()}),YW=x([`draining`,`measuring`,`restoring`,`done`,`failed`,`aborted`]),XW=x([`completed`,`operator-abort`,`deadline`,`node-lost`,`runner-lost`,`hub-restart`,`drain-timeout`,`failed`]),ZW=b({runId:l(),nodeId:l(),state:YW,plan:MW,startedAtMs:n(),deadlineAtMs:n(),finishedAtMs:n().nullable(),endReason:XW.nullable(),error:l().nullable(),moved:S(n()).readonly(),staying:S(n()).readonly(),contaminated:v(),progress:RW.nullable(),resultIds:S(l()).readonly()}),QW=b({modeNodeId:l().nullable(),run:ZW.nullable()}),$W=b({id:l(),runId:l(),nodeId:l(),cell:UW,fpsPerStream:n(),fingerprint:WW.nullable(),clip:GW.nullable(),contaminated:v(),stayingCameras:S(n()).readonly(),partialRun:v(),measuredAtMs:n()}),eG=b({nodeId:l().optional(),deviceKey:l().optional()}),tG=$W.extend({standing:x([`fresh`,`stale`,`superseded`]),staleWhy:x([`age`,`runtime`,`pool-tuning`]).nullable()}),ZDe=b({runId:l(),nodeId:l(),startedAtMs:n(),deadlineAtMs:n(),plan:MW,moved:S(n()).readonly(),staying:S(n()).readonly()}),nG=b({nodeId:l(),reachable:v(),devices:S(b({deviceKey:l(),enabled:v(),available:v(),suggested:S(l()).readonly(),all:S(l()).readonly(),currentModelId:l().nullable()})).readonly(),steps:S(b({id:l(),name:l(),slot:l()})).readonly()}),rG=b({x:n(),y:n(),w:n(),h:n()}),iG=b({bytes:y(Uint8Array).optional(),jpeg:l().optional(),jpegBytes:y(Uint8Array).optional(),width:n().int().positive(),height:n().int().positive(),tier:x([`native`,`ram-fullframe`]).optional()}),aG=x([`keyFrame`,`thumbnail`]),oG=x([`handle-gone`,`encode-failed`]),sG=i(`parked`,[b({parked:p(!0),nodeId:l(),width:n().int().positive(),height:n().int().positive(),bytes:n().int().nonnegative(),replaced:v()}),b({parked:p(!1),nodeId:l(),reason:oG,handleAgeMs:n().nullable(),detail:l().optional()})]),cG=b({jpeg:l().optional(),jpegBytes:y(Uint8Array).optional(),width:n().int().positive(),height:n().int().positive(),timestamp:n(),parkedAt:n()}),QDe=b({bbox:rG,className:l()}),lG=b({stepId:l(),className:l(),score:n(),bbox:rG.optional(),embedding:l().optional(),embeddingMagnitude:n().optional(),embeddingModelId:l().optional(),label:l().optional(),labelTier:h([p(1),p(2)]).optional(),labelModelId:l().optional(),alignedCropJpeg:l().optional(),nativeFaceShortSidePx:n().optional(),landmarks:S(b({x:n(),y:n()})).optional()}),$De=x([`unknown-step`,`model-not-servable`,`unreadable-frame`,`execution-failed`,`no-eligible-device`]),eOe=i(`kind`,[b({kind:p(`ran`),nodeId:l(),modelId:l(),details:S(lG)}),b({kind:p(`refused`),nodeId:l(),reason:$De,detail:l()})]),uG={min:0,max:6e4,default:3e4,step:500},dG={min:0,max:6e5,default:12e4,step:5e3},fG={min:5e3,max:6e5,default:9e4,step:5e3},pG={min:1,max:30,default:4,step:1},mG={min:1,max:30,default:10,step:1},hG={min:0,max:300,default:300,step:5},gG={min:1,max:10,default:4,step:1},_G={min:0,max:30,default:12,step:1},vG=x([`onboard`,`analyzer`,`device-activity`]),yG=b({source:vG,triggeredBy:PV,sensorName:l().optional()}),bG=S(vG),xG={analyzer:`Frame-diff Analyzer (motion addon)`,onboard:`Camera sensors`,"device-activity":`Device activity (the device says it is working)`};function tOe(e){let t=vG.safeParse(e);return t.success?xG[t.data]:e}var nOe=[`analyzer`,`onboard`,`device-activity`],SG=f(e=>Array.isArray(e)&&e.length>1?e.slice(0,1):e,S(KH).max(1)),CG=b({deviceId:n(),detected:v(),source:vG.default(`analyzer`),regions:S(YV).readonly().optional()}),wG=i(`kind`,[b({kind:p(`local-broker`)}),b({kind:p(`remote-restream`),ownerNodeId:l(),ownerReachableHost:l().optional(),hubHostnameOverride:l().optional()})]).describe(`Per-camera frame-source mode for the runner (P2c)`),TG=b({modelId:l().optional(),settings:m(l(),C()).optional()}),EG=b({deviceKey:l(),weight:n().positive().default(1),maxSessions:n().int().positive().nullable().default(null),steps:m(l(),TG).optional(),disabledSteps:S(l()).readonly().optional()}),DG=b({deviceId:n(),detectionMode:x([`disabled`,`always-on`,`on-motion`]).default(`on-motion`),audioMode:x([`disabled`,`always-on`,`on-motion`]).default(`always-on`),motionCooldownMs:n().min(uG.min).default(uG.default),maxSessionHoldMs:n().min(dG.min).max(dG.max).optional(),audioMotionWindowMs:n().min(fG.min).max(fG.max).optional(),motionFps:n().min(pG.min).max(pG.max).default(pG.default),detectionFps:n().min(mG.min).max(mG.max).default(mG.default),motionStreamId:l(),detectionStreamId:l(),audioStreamPick:_a.optional(),motionSources:bG.default([`analyzer`]),sessionTrigger:yG.optional(),detectionSources:SG.default([`pipeline`]),pipelineEnabled:v().default(!0),steps:S(Ha).readonly().optional(),audio:b({modelId:l().optional(),enabled:v()}).nullable().optional(),zones:S(DW).readonly().default([]),onboardMotionDrivesAnalyzer:v().default(!0),preRollInferenceEnabled:v().default(!0),preRollInferenceFrames:n().min(_G.min).max(_G.max).default(_G.default),occupancyRecheckEnabled:v().default(!0),occupancyRecheckSec:n().min(hG.min).max(hG.max).default(hG.default),occupancyRecheckFrames:n().min(gG.min).max(gG.max).default(gG.default),frameSource:wG.default({kind:`local-broker`}),deviceKey:l().optional(),inferenceDevices:S(EG).readonly().optional()}),rOe=[{key:`motionSources`,type:`multiselect`,label:`Motion Sources`,default:[`analyzer`],options:nOe.map(e=>e===`onboard`?{value:e,label:xG[e],description:`The camera's own motion, plus any sensor attached to it`}:{value:e,label:xG[e]})},{key:`motionFps`,type:`slider`,label:`Motion FPS (analyzer)`,min:pG.min,max:pG.max,step:pG.step,default:pG.default,showValue:!0,unit:`fps`,nullable:!0,nullLabel:`Default`,showWhen:{field:`motionSources`,includes:`analyzer`}},{key:`detectionFps`,type:`slider`,label:`Detection FPS`,min:mG.min,max:mG.max,step:mG.step,default:mG.default,showValue:!0,unit:`fps`,nullable:!0,nullLabel:`Default`},{key:`motionCooldownMs`,type:`slider`,label:`Motion Cooldown`,description:`Time without a fresh motion event before the active phase ends. Applies to all motion sources — every motion event re-arms the timer.`,min:uG.min,max:uG.max,step:uG.step,default:uG.default,showValue:!0,unit:`s`,displayScale:1e3,nullable:!0,nullLabel:`Default`},{key:`maxSessionHoldMs`,type:`slider`,label:`Max session hold`,description:`Upper bound on how long detection keeps running past the motion cooldown while a subject is still moving in-frame but no longer triggering motion. Prevents the detection box from stopping on a slow-moving subject. Set to 0 to disable.`,min:dG.min,max:dG.max,step:dG.step,default:dG.default,showValue:!0,unit:`s`,displayScale:1e3,nullable:!0,nullLabel:`Default`},{key:`audioMotionWindowMs`,type:`slider`,label:`Audio window after motion`,description:`How long audio keeps being analysed after the last motion event. Each new motion event extends the window without restarting the audio stream.`,min:fG.min,max:fG.max,step:fG.step,default:fG.default,showValue:!0,unit:`s`,displayScale:1e3,nullable:!0,nullLabel:`Default`,showWhen:{field:`audioMode`,equals:`on-motion`}},{key:`onboardMotionDrivesAnalyzer`,type:`boolean`,label:`Run motion analyzer on onboard motion`,description:`When onboard motion is detected, temporarily start the frame-diff analyzer to emit zone results. Stops after the motion cooldown window.`,default:!0,showWhen:{field:`motionSources`,includes:`onboard`}},{key:`preRollInferenceEnabled`,type:`boolean`,style:`checkbox`,label:`Detect in the pre-roll`,description:`Run detection over the few seconds of footage the camera had already buffered when motion fired, so a subject that was in view before the trigger is found at the moment it appeared rather than seconds later. The burst is bounded and never delays live detection.`,default:!0},{key:`preRollInferenceFrames`,type:`slider`,label:`Pre-roll frames`,description:`How many frames of buffered history may be detected on, per session. Higher samples the history more densely; 0 disables the pass.`,min:_G.min,max:_G.max,step:_G.step,default:_G.default,showValue:!0,showWhen:{field:`preRollInferenceEnabled`,equals:!0}},{key:`occupancyRecheckEnabled`,type:`boolean`,style:`checkbox`,label:`Occupancy re-check`,description:`Periodically re-sample a few frames during the watching phase, so objects that are simply parked are still counted (motion gating alone loses them after a restart). On by default at a wide interval; turn it off on cameras where the extra decoder re-dial is expensive.`,default:!0},{key:`occupancyRecheckSec`,type:`slider`,label:`Occupancy re-check interval`,description:`How often (in seconds) the runner re-samples a few frames to confirm the scene is truly empty during the watching phase.`,min:hG.min,max:hG.max,step:hG.step,default:hG.default,showValue:!0,unit:`s`,showWhen:{field:`occupancyRecheckEnabled`,equals:!0}},{key:`occupancyRecheckFrames`,type:`slider`,label:`Occupancy re-check frames`,description:`Number of frames sampled per occupancy re-check burst.`,min:gG.min,max:gG.max,step:gG.step,default:gG.default,showValue:!0,showWhen:{field:`occupancyRecheckEnabled`,equals:!0}}],OG=b({nodeId:l(),attachedCameras:n(),activeCameras:n(),avgInferenceFps:n(),avgInferenceTimeMs:n(),queueDepthTotal:n(),devices:S(b({deviceKey:l(),backend:l(),attachedCameras:n()})).default([]),hardware:b({hasGpu:v(),inferenceBackend:l().optional(),cpuCores:n().optional()}),motionSliceWriter:p(`orchestrator`).optional()}),kG=b({framesDecoded:n(),framesAdmitted:n(),framesDroppedPixelFree:n(),viewsMaterialized:n(),viewsSkipped:n(),workerToRunnerBytes:n(),runnerToPoolRawBytes:n(),runnerToPoolJpegBytes:n(),onDemandFullFrameRequests:n(),onDemandCropRequests:n(),nativeHits:n(),nativeMisses:n(),tileHits:n(),tileMisses:n(),fallbackHits:n(),fallbackMisses:n(),retainedWritesAvoided:n(),residentRefs:n(),residentBytes:n(),releases:n(),evictions:n(),staleMisses:n()}),AG=b({node:kG,cameras:S(kG.extend({deviceId:n()}))}),jG=b({nodeId:l(),activeCameras:n(),throttledCameras:n(),avgInferenceTimeMs:n(),queueDepth:n(),frameLazy:AG.optional()}),MG=x([`not-attached`,`battery-asleep`,`not-watching`,`already-bursting`]),NG={name:`pipeline-runner`,scope:`system`,mode:`singleton`,methods:{attachCamera:k(DG,b({success:p(!0)}),{kind:`mutation`}),detachCamera:k(b({deviceId:n()}),b({success:p(!0)}),{kind:`mutation`}),reportMotion:k(CG,b({success:p(!0)}),{kind:`mutation`}),getLocalLoad:k(_(),OG),getLocalMetrics:k(_(),jG),getCameraMetrics:k(b({deviceId:n()}),CW.nullable()),getAllCameraMetrics:k(_(),S(wW).readonly()),getLocalCameras:k(_(),S(n()).readonly()),requestOccupancyBurst:k(b({deviceId:n(),frames:n().int().positive().optional(),reason:l()}),b({started:v(),refusedBecause:MG.optional()}),{auth:`admin`,kind:`mutation`}),getNativeCrop:k(b({handle:Ca,bbox:rG,maxWidth:n().int().positive().optional(),acceptJpegBytes:v().optional(),encodeJpeg:v().optional()}),iG.nullable()),runDetailSubtree:k(b({deviceId:n(),frameHandle:Ca.optional(),frameJpeg:l().optional(),cropJpeg:l().optional(),parent:QDe,steps:S(l()).optional(),supplied:b({stepId:l(),modelId:l(),boxes:S(b({bbox:rG,score:n()})).min(1)}).optional()}),b({details:S(lG)}).nullable(),{kind:`mutation`}),runStatelessStep:k(b({stepId:l(),modelId:l(),frameJpeg:l(),bbox:rG,className:l(),sourceDeviceId:n()}),eOe,{kind:`mutation`}),parkTrackFrame:k(b({deviceId:n(),trackId:l(),kind:aG,handle:Ca,bbox:rG,maxWidth:n().int().positive().optional(),timestamp:n()}),sG,{kind:`mutation`}),getParkedTrackFrame:k(b({deviceId:n(),trackId:l(),kind:aG,acceptJpegBytes:v().optional()}),cG.nullable()),releaseParkedTrackFrames:k(b({deviceId:n(),trackId:l()}),b({released:n().int().nonnegative()}),{kind:`mutation`}),startNodeBench:k(KW,b({accepted:p(!0),runId:l()}),{kind:`mutation`,auth:`admin`}),getNodeBenchStatus:k(b({runId:l()}),JW.nullable(),{auth:`admin`}),abortNodeBench:k(b({runId:l()}),b({aborted:v()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:j.PIPELINE}},PG=3e4,iOe={version:1,targets:[{id:`detected`,cardinality:`event`,shape:`span`,vocabulary:{cap:`motion`,eventName:`onMotionChanged`},deviceTypes:[T.Camera],apply:`add`,applyAuthority:{kind:`camera-sensors`,timeoutField:`motionCooldownMs`},eventName:`onMotionChanged`,start:`rising-edge`,end:`falling-edge-or-timeout`,timeoutMs:PG,combine:`any`,sourceModes:[`in-addition`,`confirm`,`replace`],sources:[{kind:`binary`},{kind:`switch`}],sourceReport:{status:`assignment-status`},advancedExpression:!1}]},aOe=15e3,FG=b({detected:v(),lastDetectedAt:n().nullable(),autoClearAfterMs:n().nullable().meta(M(`duration-ms`))}),IG=b({deviceId:n(),detected:v(),timestamp:n(),source:vG,regions:S(YV).readonly().optional(),triggeredBy:PV.optional()}),LG={name:`motion`,scope:`device`,mode:`singleton`,deviceNative:!0,deviceTypes:[T.Camera,T.Sensor],methods:{isDetected:k(b({deviceId:n()}),v())},composedMethods:{isDetected:{kind:`slice`,field:`detected`}},events:{onMotionChanged:{data:IG,notOperatorFacing:"the `detected` state trigger phrases both edges, from the mirror that survives a dropped event (D49)"}},status:{schema:FG,kind:`push`},runtimeState:FG,durability:`session`,history:{fields:{detected:{kind:`boolean`,excludeDeviceTypes:[T.Camera]}}},customize:iOe,vocabulary:{noun:P(`Motion`,`Movimento`),order:5130,state:[{kind:`boolean`,field:`detected`,label:P(`Motion`,`Movimento`),whenTrue:P(`When {device} detects motion`,`Quando {device} rileva movimento`),whenFalse:P(`When motion clears on {device}`,`Quando il movimento su {device} cessa`),icon:`activity`}]}},RG=b({enabled:v(),lastChangedAt:n()}),zG=RG.extend({lastFetchedAt:n()}),BG={name:`motion-trigger`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Light,T.Siren,T.Switch],methods:{setMotionTrigger:k(b({deviceId:n().int().nonnegative(),enabled:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`motionTrigger.on`,label:P(`Motion trigger on`,`Attivazione al movimento attiva`),phrase:P(`Let motion trigger {device}`,`Fai attivare {device} dal movimento`),icon:`activity`,effect:{field:`enabled`,value:!0},args:{enabled:!0}},{id:`motionTrigger.off`,label:P(`Motion trigger off`,`Attivazione al movimento spenta`),phrase:P(`Stop motion triggering {device}`,`Non far più attivare {device} dal movimento`),icon:`activity`,effect:{field:`enabled`,value:!1},args:{enabled:!1}}]})},events:{onMotionTriggerChanged:{data:b({deviceId:n(),enabled:v(),lastChangedAt:n()}),notOperatorFacing:"the `enabled` state trigger phrases both edges of this change"}},status:{schema:RG,kind:`command-driven`},runtimeState:zG,durability:`session`,history:`none`,vocabulary:{noun:P(`Motion trigger`,`Attivazione al movimento`),order:1160,state:[{kind:`boolean`,field:`enabled`,label:P(`Motion trigger`,`Attivazione al movimento`),whenTrue:P(`When motion triggering is turned on for {device}`,`Quando si attiva l’attivazione al movimento di {device}`),whenFalse:P(`When motion triggering is turned off for {device}`,`Quando si disattiva l’attivazione al movimento di {device}`),icon:`activity`}]}},VG=b({id:n(),enabled:v(),shape:nH}),HG=b({enabled:v(),sensitivity:n().meta(M(`none`)),regions:S(VG),lastFetchedAt:n()}),UG=b({maxRegions:n(),supportedShapes:S(iH),grid:oH,sensitivity:b({min:n(),max:n(),step:n()})}),WG=b({enabled:v().optional(),sensitivity:n().optional(),regions:S(VG).optional()}),GG={name:`motion-zones`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/motion-zones-grid`,tab:`motion`,label:`Motion Zones`}},methods:{getOptions:k(b({deviceId:n()}),UG),setZone:k(b({deviceId:n(),patch:WG}),_(),{kind:`mutation`,auth:`admin`})},status:{schema:HG,kind:`poll`},runtimeState:HG,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:P(`Motion zones`,`Zone di movimento`),order:3170}},oOe=x([`external`,`embedded`]),sOe=x([`connected`,`disconnected`,`auth-failed`,`unreachable`,`tls-error`]),KG=b({id:l(),name:l(),url:l(),kind:oOe,status:sOe,latencyMs:n().nullable(),error:l().optional(),connectedClients:n().int().nonnegative().optional(),lastCheckedAt:n().optional()}),qG=b({url:l(),username:l().optional(),password:l().optional(),clientIdPrefix:l().optional()}),JG=b({name:l().min(1),url:l().regex(/^(mqtt|mqtts|ws|wss):\/\//,`URL must start with mqtt(s):// or ws(s)://`),username:l().optional(),password:l().optional(),clientIdPrefix:l().optional()}),cOe=b({id:l()}),YG=b({id:l()}),XG=b({port:n().int().min(1).max(65535).default(1883),allowAnonymous:v().default(!1),username:l().optional(),password:l().optional()}),lOe=b({id:l(),url:l()}),ZG=b({brokerCount:n(),embeddedRunning:v()}),QG={name:`mqtt-broker`,scope:`system`,mode:`collection`,providerKind:`broker`,status:{schema:ZG,kind:`poll`},methods:{listBrokers:k(_(),S(KG)),getBrokerConfig:k(YG,qG,{auth:`admin`}),addBroker:k(JG,cOe,{kind:`mutation`,auth:`admin`}),removeBroker:k(YG,_(),{kind:`mutation`,auth:`admin`}),startEmbeddedBroker:k(XG,lOe,{kind:`mutation`,auth:`admin`}),stopEmbeddedBroker:k(YG,_(),{kind:`mutation`,auth:`admin`}),getStatus:k(_(),ZG)},vocabulary:{notOperatorFacing:j.NETWORK}},$G=x([`person`,`vehicle`,`animal`,`face`,`package`,`other`]),eK=b({class:$G,timestamp:n(),confidence:n().min(0).max(1).optional()}),tK=b({lastByClass:d($G,eK.nullable()),supportedClasses:S($G).readonly(),enabled:v()}),nK=x([`boxed`,`while-streaming`,`flag-only`]),rK=b({supportedClasses:S($G).readonly(),geometry:nK}),iK=b({enabled:v().optional()}),aK=tK.extend({lastFetchedAt:n()}),oK={name:`native-object-detection`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Camera],methods:{getOptions:k(b({deviceId:n()}),rK),setSettings:k(b({deviceId:n(),settings:iK}),_(),{kind:`mutation`,auth:`admin`}),setEnabled:k(b({deviceId:n(),enabled:v()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`nativeDetection.on`,label:P(`On-camera detection on`,`Rilevamento a bordo attivo`),phrase:P(`Turn on the on-camera detection of {device}`,`Attiva il rilevamento a bordo di {device}`),icon:`scan-eye`,args:{enabled:!0}},{id:`nativeDetection.off`,label:P(`On-camera detection off`,`Rilevamento a bordo spento`),phrase:P(`Turn off the on-camera detection of {device}`,`Disattiva il rilevamento a bordo di {device}`),icon:`scan-eye`,args:{enabled:!1}}]})},events:{onDetected:{data:b({deviceId:n(),detection:eK}),trigger:{category:w.DetectionCameraNative,label:P(`Camera spotted something`,`La telecamera ha rilevato qualcosa`),phrase:P(`When {device} spots something with its own detector`,`Quando {device} rileva qualcosa con il proprio rilevatore`),icon:`scan-eye`}}},status:{schema:tK,kind:`push`},runtimeState:aK,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:P(`On-camera detection`,`Rilevamento a bordo`),order:3180,state:[{kind:`boolean`,field:`enabled`,label:P(`On-camera detection`,`Rilevamento a bordo`),whenTrue:P(`When the on-camera detection of {device} is turned on`,`Quando si attiva il rilevamento a bordo di {device}`),whenFalse:P(`When the on-camera detection of {device} is turned off`,`Quando si disattiva il rilevamento a bordo di {device}`),icon:`scan-eye`}]}},sK=b({pan:n().min(-1).max(1).optional(),tilt:n().min(-1).max(1).optional(),speed:n().min(0).max(1).optional()}),cK=x([`goHome`,`locate`,`spotClean`,`findPet`,`personFollow`,`stop`,`startClean`,`pauseClean`,`dockWash`,`autoEmpty`,`flashOn`,`flashOff`]),lK=x([`action`,`sound`]),uK=b({id:l(),kind:lK,label:l(),icon:l(),soundId:n().int().optional(),enabled:v()}),uOe=[{id:`startClean`,kind:`action`,label:`Start cleaning`,icon:`play`,enabled:!0},{id:`pauseClean`,kind:`action`,label:`Pause cleaning`,icon:`pause`,enabled:!0},{id:`stop`,kind:`action`,label:`Stop`,icon:`hand`,enabled:!0},{id:`goHome`,kind:`action`,label:`Return to dock`,icon:`home`,enabled:!0},{id:`locate`,kind:`action`,label:`Locate`,icon:`bell`,enabled:!0},{id:`spotClean`,kind:`action`,label:`Spot clean here`,icon:`crosshair`,enabled:!0},{id:`findPet`,kind:`action`,label:`Find pet`,icon:`paw-print`,enabled:!0},{id:`personFollow`,kind:`action`,label:`Follow me`,icon:`footprints`,enabled:!0},{id:`dockWash`,kind:`action`,label:`Wash mop`,icon:`droplets`,enabled:!0},{id:`autoEmpty`,kind:`action`,label:`Empty dustbin`,icon:`trash-2`,enabled:!0},{id:`flashOn`,kind:`action`,label:`Flash on`,icon:`flashlight`,enabled:!0},{id:`flashOff`,kind:`action`,label:`Flash off`,icon:`flashlight-off`,enabled:!0},{id:`sound:meow`,kind:`sound`,label:`Meow`,icon:`cat`,soundId:684,enabled:!0},{id:`sound:bark`,kind:`sound`,label:`Woof`,icon:`dog`,soundId:685,enabled:!0},{id:`sound:footsteps`,kind:`sound`,label:`Footsteps`,icon:`footprints`,soundId:686,enabled:!0},{id:`sound:purring`,kind:`sound`,label:`Purring`,icon:`cat`,soundId:687,enabled:!0},{id:`sound:tickTock`,kind:`sound`,label:`Tick-tock`,icon:`clock`,soundId:688,enabled:!0}],dK=b({x:n(),y:n()}),fK=b({move:v(),stop:v(),goToPoint:v(),runAction:v(),playSound:v(),light:v(),lightMode:v()}),pK=x([`auto`,`manual`]),dOe=40,fOe=100,mK=x([`idle`,`cleaning`,`spot`,`following`,`goto`,`returning`,`paused`,`unknown`]),hK=b({mode:mK,following:v(),flash:v(),lightMode:pK,lightLevel:n().min(40).max(100).meta(M(`none`)),lastChangedAt:n()}),gK=hK.extend({lastFetchedAt:n()}),_K={name:`navigation`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/navigation-panel`,tab:`navigation`,topTab:!0,label:`Navigation`,order:0}},methods:{move:k(sK.extend({deviceId:n()}),_(),{kind:`mutation`,notOperatorFacing:`joystick control from the live view — continuous, not a discrete step`}),stop:k(b({deviceId:n()}),_(),{kind:`mutation`,actions:[{id:`navigation.stop`,label:P(`Stop`,`Ferma`),phrase:P(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),goToPoint:k(dK.extend({deviceId:n()}),_(),{kind:`mutation`,notOperatorFacing:`tap-to-go on the live map — the point only means something on that picture`}),listActions:k(b({deviceId:n()}),S(uK)),runAction:k(b({deviceId:n(),actionId:cK}),_(),{kind:`mutation`,actions:[{id:`navigation.runAction`,label:P(`Run a routine`,`Esegui una routine`),phrase:P(`Have {device} {actionId}`,`Fai eseguire a {device}: {actionId}`),icon:`bot`,openArgs:[{key:`actionId`,label:P(`Routine`,`Routine`),offer:{kind:`enum`,values:[{value:`goHome`,label:P(`go home`,`torna alla base`)},{value:`locate`,label:P(`beep so you can find it`,`suona per farsi trovare`)},{value:`spotClean`,label:P(`clean this spot`,`pulisci questo punto`)},{value:`findPet`,label:P(`find the pet`,`cerca l’animale`)},{value:`personFollow`,label:P(`follow a person`,`segui una persona`)},{value:`stop`,label:P(`stop`,`fermati`)},{value:`startClean`,label:P(`start cleaning`,`inizia a pulire`)},{value:`pauseClean`,label:P(`pause cleaning`,`metti in pausa la pulizia`)},{value:`dockWash`,label:P(`wash the mop at the dock`,`lava il mocio alla base`)},{value:`autoEmpty`,label:P(`empty the bin at the dock`,`svuota il contenitore alla base`)},{value:`flashOn`,label:P(`turn the flash on`,`accendi il flash`)},{value:`flashOff`,label:P(`turn the flash off`,`spegni il flash`)}]}}]}]}),playSound:k(b({deviceId:n(),soundId:n().int()}),_(),{kind:`mutation`,actions:[{id:`navigation.playSound`,label:P(`Play sound`,`Riproduci un suono`),phrase:P(`Play {soundId} on {device}`,`Riproduci {soundId} su {device}`),icon:`volume-2`,openArgs:[{key:`soundId`,label:P(`Sound`,`Suono`),offer:{kind:`dynamic`,from:`method`,method:`listActions`,valueKey:`soundId`,labelKey:`label`,where:{key:`kind`,equals:`sound`},valueKind:`number`}}]}]}),setLightOn:k(b({deviceId:n(),on:v()}),_(),{kind:`mutation`,actions:[{id:`navigation.lightOn`,label:P(`Light on`,`Luce accesa`),phrase:P(`Turn on the light of {device}`,`Accendi la luce di {device}`),icon:`lightbulb`,args:{on:!0}},{id:`navigation.lightOff`,label:P(`Light off`,`Luce spenta`),phrase:P(`Turn off the light of {device}`,`Spegni la luce di {device}`),icon:`lightbulb-off`,args:{on:!1}}]}),setLightMode:k(b({deviceId:n(),mode:pK,level:n().min(40).max(100).optional()}),_(),{kind:`mutation`,actions:[{id:`navigation.lightAuto`,label:P(`Light automatic`,`Luce automatica`),phrase:P(`Set the light of {device} to automatic`,`Metti la luce di {device} in automatico`),icon:`lightbulb`,args:{mode:`auto`}}]}),setLightLevel:k(b({deviceId:n(),level:n().min(40).max(100)}),_(),{kind:`mutation`,actions:[{id:`navigation.lightLevel`,label:P(`Set light level`,`Imposta la luce`),phrase:P(`Set the light of {device} to {level}`,`Imposta la luce di {device} al {level}`),icon:`sun-medium`,openArgs:[{key:`level`,label:P(`Level`,`Livello`),offer:{kind:`number`,min:40,max:100,step:1,unit:`%`}}]}]}),getFeatures:k(b({deviceId:n()}),fK)},events:{onStatusChanged:{data:b({deviceId:n(),status:hK}),notOperatorFacing:"the `mode` state trigger reads the same change"}},status:{schema:hK,kind:`push`},runtimeState:gK,durability:`session`,history:`none`,vocabulary:{noun:P(`Robot movement`,`Movimento del robot`),order:2080,state:[{kind:`enum`,field:`mode`,label:P(`Activity`,`Attività`),values:[{value:`idle`,label:P(`Idle`,`Inattivo`)},{value:`cleaning`,label:P(`Cleaning`,`In pulizia`)},{value:`spot`,label:P(`Spot cleaning`,`Pulizia localizzata`)},{value:`following`,label:P(`Following`,`In inseguimento`)},{value:`goto`,label:P(`Moving to a point`,`In movimento verso un punto`)},{value:`returning`,label:P(`Returning`,`In rientro`)},{value:`paused`,label:P(`Paused`,`In pausa`)},{value:`unknown`,label:P(`Unknown`,`Sconosciuto`)}],icon:`bot`}]}},vK=b({url:l(),hostname:l(),port:n(),protocol:x([`http`,`https`]),stable:v().optional()}),pOe=b({url:l(),stable:v().optional(),updated:v().optional()}),yK=b({connected:v(),endpoint:vK.nullable(),error:l().optional()}),mOe=vK.extend({id:l(),label:l(),mode:l().optional(),sourcePort:n().optional()}),bK={name:`network-access`,scope:`system`,mode:`collection`,providerKind:`ingress`,methods:{start:k(_(),vK,{kind:`mutation`}),stop:k(_(),_(),{kind:`mutation`}),getEndpoint:k(_(),vK.nullable()),getStatus:k(_(),yK),listEndpoints:k(_(),S(mOe).readonly())},vocabulary:{notOperatorFacing:j.NETWORK}},xK=[`wifi`,`ethernet`,`cellular`,`unknown`],SK=b({type:x(xK),signal:n().min(0).max(100).nullable().meta(M(`percentage`)),rssi:n().optional().meta(M(`signal-level`)),ssid:l().optional(),speedKbps:n().nonnegative().nullable().optional().meta(M(`bitrate`)),linkUp:v().nullable().optional(),lastUpdated:n().meta(M(`none`))}),CK={type:`unknown`,signal:null,lastUpdated:0};function hOe(e,t){return e===void 0||!Number.isFinite(e)||t<=0||e<0||e>t?null:Math.round(e/t*100)}function gOe(e){return e===void 0||!Number.isFinite(e)||e>0?null:Math.round((Math.min(-50,Math.max(-100,e))+100)*2)}var wK={name:`network-link`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Camera,T.Sensor,T.Button,T.Switch,T.Light,T.Lock,T.Siren],methods:{},events:{onStatusChanged:{data:b({deviceId:n(),status:SK}),notOperatorFacing:`the signal / link-type state triggers each read one field of this change`}},status:{schema:SK,kind:`push`,empty:CK},runtimeState:SK,durability:`restored`,history:{fields:{signal:{kind:`gauge`,unit:`%`,deadband:3,minIntervalMs:6e4},rssi:{kind:`gauge`,unit:`dBm`,deadband:2,minIntervalMs:6e4}}},volatileStateFields:[`lastUpdated`],vocabulary:{noun:P(`Network link`,`Collegamento di rete`),order:5250,state:[{kind:`numeric`,field:`signal`,quantity:P(`the signal strength`,`l’intensità del segnale`),label:P(`Signal`,`Segnale`),unit:`%`,icon:`wifi`},{kind:`enum`,field:`type`,label:P(`Link type`,`Tipo di collegamento`),values:[{value:`wifi`,label:P(`Wi-Fi`,`Wi-Fi`)},{value:`ethernet`,label:P(`Ethernet`,`Ethernet`)},{value:`cellular`,label:P(`Cellular`,`Rete mobile`)},{value:`unknown`,label:P(`Unknown`,`Sconosciuto`)}],icon:`network`}]}},TK=b({nominalBitrateKbps:n(),observedBitrateKbps:n(),peakBitrateKbps:n(),packetLossPercent:n(),lastUpdated:n()}),EK=b({rttMs:n(),jitterMs:n(),estimatedBandwidthKbps:n(),packetLossPercent:n().min(0).max(100),downlinkMbps:n().optional(),downlinkAgeMs:n().optional(),lastUpdated:n()}),DK=b({deviceId:n(),streams:m(l(),TK),client:EK.optional()}),OK={name:`network-quality`,scope:`system`,mode:`singleton`,methods:{getDeviceStats:k(b({deviceId:n()}),DK.nullable()),getAllStats:k(_(),S(DK).readonly()),reportClientStats:k(b({deviceId:n(),rttMs:n().min(0).max(6e4),jitterMs:n().min(0).max(1e4),estimatedBandwidthKbps:n().min(0).max(1e6),packetLossPercent:n().min(0).max(100),downlinkMbps:n().min(0).max(1e5).optional(),downlinkAgeMs:n().min(0).max(864e5).optional()}),_(),{role:`viewer`,kind:`mutation`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:j.NETWORK}},kK=b({cn:l(),serial:l(),fingerprintSha256:l(),notBefore:n(),notAfter:n()}),AK=b({fingerprintSha256:l(),issuer:l(),sans:S(l()),notBefore:n(),notAfter:n()}),jK=i(`state`,[b({state:p(`served`),leaf:AK}),b({state:p(`not-issued`),reason:l()})]),MK={name:`node-certificates`,scope:`system`,mode:`singleton`,internal:!0,methods:{getCertificates:k(b({}),b({nodeId:l(),mesh:kK.nullable(),https:jK}),{auth:`admin`}),prepareMeshRenewal:k(b({}),b({csrPem:l()}),{kind:`mutation`,auth:`admin`}),installMeshLeaf:k(b({certPem:l().min(1),caCertPem:l().min(1),confirmWithinMs:n().int().min(1e4).max(6e5)}),b({fingerprintSha256:l(),serial:l()}),{kind:`mutation`,auth:`admin`}),confirmMeshLeaf:k(b({fingerprintSha256:l()}),b({confirmed:v()}),{kind:`mutation`,auth:`admin`}),rollbackMeshLeaf:k(b({}),b({rolledBack:v()}),{kind:`mutation`,auth:`admin`}),prepareHttpsCertificate:k(b({}),b({csrPem:l(),hostnames:S(l()),addresses:S(l()),pinnedCaFingerprintSha256:l().nullable()}),{kind:`mutation`,auth:`admin`}),forgetHub:k(b({}),b({ok:p(!0)}),{kind:`mutation`,auth:`admin`}),installHttpsCertificate:k(b({certPem:l().min(1),caCertPem:l().min(1),caRotation:v().optional()}),AK,{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:j.IDENTITY}},NK=b({nodeId:l().min(1),removedAt:n()}),PK=b({counts:m(l(),n().int().nonnegative())}),FK={name:`node-removal-hook`,scope:`system`,mode:`collection`,internal:!0,methods:{onNodeRemoved:k(NK,PK,{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:j.INTERNAL}},IK=b({addonId:l(),capabilities:S(l()).readonly(),status:l()}),LK=b({pid:n(),name:l(),state:l(),cpuPercent:n(),memoryRss:n(),uptimeSeconds:n(),services:S(IK).readonly(),groupId:l().optional()}),_Oe=b({id:l(),status:l(),cpuPercent:n(),memoryRss:n()}),vOe=b({category:l(),total:n(),healthy:n(),addons:S(_Oe).readonly()}),yOe=b({name:l(),version:l()}),RK=b({id:l(),name:l(),hostname:l(),platform:l(),arch:l(),cpuModel:l().nullable(),cpuCores:n(),memoryMB:n(),engines:S(l()).readonly(),isHub:v(),isOnline:v(),cpuPercent:n(),memoryPercent:n().nullable(),uptime:n(),lastSeen:l(),localIps:S(l()).readonly(),addons:S(b({id:l(),capabilities:S(l()).readonly(),status:l()})).readonly(),processes:S(LK).readonly(),categories:S(vOe).readonly(),rootPackage:yOe.nullable(),meshTransport:x([`tls`,`clear`]).optional(),capabilitiesRegistered:v().optional()}),bOe=b({callerAddonId:l(),providerAddonId:l(),capName:l(),callsPerMin:n(),lastCallAtMs:n()}),zK=b({nodeId:l(),name:l(),version:l(),status:l(),synced:v()}),BK=b({hubVersion:l(),nodes:S(zK)}),VK=b({nodeId:l(),addonId:l()}),xOe=b({id:l(),status:l(),version:l().optional(),packageName:l().optional()}),HK=b({success:v()}),SOe=b({success:v(),reason:l().optional()}),COe=b({restarted:S(l()).readonly(),failed:S(l()).readonly()}),wOe=b({nodeId:l(),name:l()}),UK=b({id:l(),name:l(),isHub:v(),isOnline:v()}),WK=b({nodes:S(UK).readonly(),complete:v()}),GK={name:`nodes`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,methods:{topology:k(_(),S(RK).readonly(),{auth:`admin`}),directory:k(_(),WK,{auth:`admin`}),deployAddon:k(VK,HK,{kind:`mutation`,auth:`admin`}),undeployAddon:k(VK,HK,{kind:`mutation`,auth:`admin`}),restartAddon:k(VK,HK,{kind:`mutation`,auth:`admin`}),restartProcess:k(b({nodeId:l(),processName:l()}),SOe,{kind:`mutation`,auth:`admin`}),restartNode:k(b({nodeId:l()}),COe,{kind:`mutation`,auth:`admin`}),shutdownNode:k(b({nodeId:l()}),HK,{kind:`mutation`,auth:`admin`}),renameNode:k(b({nodeId:l(),name:l().min(1).max(64)}),wOe,{kind:`mutation`,auth:`admin`}),clusterAddonStatus:k(_(),m(l(),BK),{auth:`admin`}),getCapUsageGraph:k(b({windowSeconds:n().int().positive().max(300).default(60)}),S(bOe).readonly(),{auth:`admin`}),getNodeAddons:k(b({nodeId:l()}),S(xOe).readonly(),{auth:`admin`}),setProcessLogLevel:k(b({nodeId:l(),level:l()}),HK,{kind:`mutation`,auth:`admin`}),executeQuery:k(b({nodeId:l(),addonId:l(),queryName:l(),params:m(l(),C()).optional()}),C(),{kind:`mutation`,auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:j.CLUSTER}},KK=[{id:`speech`,name:`Speech`},{id:`scream`,name:`Scream / Shout`},{id:`crying`,name:`Crying / Baby`},{id:`laughter`,name:`Laughter`},{id:`music`,name:`Music`},{id:`dog`,name:`Dog`},{id:`cat`,name:`Cat`},{id:`bird`,name:`Bird`},{id:`animal`,name:`Animal (other)`},{id:`alarm`,name:`Alarm / Siren`},{id:`doorbell`,name:`Doorbell / Knock`},{id:`glass_breaking`,name:`Glass Breaking`},{id:`gunshot`,name:`Gunshot / Explosion`},{id:`vehicle`,name:`Vehicle`},{id:`siren`,name:`Emergency Siren`},{id:`fire`,name:`Fire / Smoke`},{id:`water`,name:`Water`},{id:`wind`,name:`Wind / Weather`},{id:`door`,name:`Door`},{id:`footsteps`,name:`Footsteps`},{id:`crowd`,name:`Crowd / Chatter`},{id:`telephone`,name:`Telephone`},{id:`engine`,name:`Engine / Motor`},{id:`tools`,name:`Tools / Construction`},{id:`silence`,name:`Silence`}],qK={mapping:{Speech:`speech`,"Child speech, kid speaking":`speech`,Conversation:`speech`,"Narration, monologue":`speech`,Babbling:`speech`,Whispering:`speech`,"Speech synthesizer":`speech`,Humming:`speech`,Rapping:`speech`,Singing:`speech`,Choir:`speech`,"Child singing":`speech`,Shout:`scream`,Bellow:`scream`,Yell:`scream`,Screaming:`scream`,"Children shouting":`scream`,Whoop:`scream`,"Crying, sobbing":`crying`,"Baby cry, infant cry":`crying`,Whimper:`crying`,"Wail, moan":`crying`,Groan:`crying`,Laughter:`laughter`,"Baby laughter":`laughter`,Giggle:`laughter`,Snicker:`laughter`,"Belly laugh":`laughter`,"Chuckle, chortle":`laughter`,Music:`music`,"Musical instrument":`music`,Guitar:`music`,Piano:`music`,Drum:`music`,"Drum kit":`music`,"Violin, fiddle":`music`,Flute:`music`,Saxophone:`music`,Trumpet:`music`,Synthesizer:`music`,"Pop music":`music`,"Rock music":`music`,"Hip hop music":`music`,"Classical music":`music`,Jazz:`music`,"Electronic music":`music`,"Background music":`music`,Dog:`dog`,Bark:`dog`,Yip:`dog`,Howl:`dog`,"Bow-wow":`dog`,Growling:`dog`,"Whimper (dog)":`dog`,Cat:`cat`,Purr:`cat`,Meow:`cat`,Hiss:`cat`,Caterwaul:`cat`,Bird:`bird`,"Bird vocalization, bird call, bird song":`bird`,"Chirp, tweet":`bird`,Squawk:`bird`,Crow:`bird`,Owl:`bird`,"Pigeon, dove":`bird`,Animal:`animal`,"Domestic animals, pets":`animal`,"Livestock, farm animals, working animals":`animal`,Horse:`animal`,"Cattle, bovinae":`animal`,Pig:`animal`,Sheep:`animal`,Goat:`animal`,Frog:`animal`,Insect:`animal`,Cricket:`animal`,Alarm:`alarm`,"Alarm clock":`alarm`,"Smoke detector, smoke alarm":`alarm`,"Fire alarm":`alarm`,Buzzer:`alarm`,"Civil defense siren":`alarm`,"Car alarm":`alarm`,Siren:`siren`,"Police car (siren)":`siren`,"Ambulance (siren)":`siren`,"Fire engine, fire truck (siren)":`siren`,"Emergency vehicle":`siren`,Foghorn:`siren`,Doorbell:`doorbell`,"Ding-dong":`doorbell`,Knock:`doorbell`,Tap:`doorbell`,Glass:`glass_breaking`,Shatter:`glass_breaking`,"Chink, clink":`glass_breaking`,"Gunshot, gunfire":`gunshot`,"Machine gun":`gunshot`,Explosion:`gunshot`,Fireworks:`gunshot`,Firecracker:`gunshot`,"Artillery fire":`gunshot`,"Cap gun":`gunshot`,Boom:`gunshot`,Vehicle:`vehicle`,Car:`vehicle`,Truck:`vehicle`,Bus:`vehicle`,Motorcycle:`vehicle`,"Car passing by":`vehicle`,"Vehicle horn, car horn, honking":`vehicle`,"Traffic noise, roadway noise":`vehicle`,Train:`vehicle`,Aircraft:`vehicle`,Helicopter:`vehicle`,Bicycle:`vehicle`,Skateboard:`vehicle`,Fire:`fire`,Crackle:`fire`,Water:`water`,Rain:`water`,Raindrop:`water`,"Rain on surface":`water`,Stream:`water`,Waterfall:`water`,Ocean:`water`,"Waves, surf":`water`,"Splash, splatter":`water`,Wind:`wind`,Thunderstorm:`wind`,Thunder:`wind`,"Wind noise (microphone)":`wind`,"Rustling leaves":`wind`,Door:`door`,"Sliding door":`door`,Slam:`door`,"Cupboard open or close":`door`,"Walk, footsteps":`footsteps`,Run:`footsteps`,Shuffle:`footsteps`,Crowd:`crowd`,Chatter:`crowd`,Cheering:`crowd`,Applause:`crowd`,"Children playing":`crowd`,"Hubbub, speech noise, speech babble":`crowd`,Telephone:`telephone`,"Telephone bell ringing":`telephone`,Ringtone:`telephone`,"Telephone dialing, DTMF":`telephone`,"Busy signal":`telephone`,Engine:`engine`,"Engine starting":`engine`,Idling:`engine`,"Accelerating, revving, vroom":`engine`,"Light engine (high frequency)":`engine`,"Medium engine (mid frequency)":`engine`,"Heavy engine (low frequency)":`engine`,"Lawn mower":`engine`,Chainsaw:`engine`,Hammer:`tools`,Jackhammer:`tools`,Sawing:`tools`,"Power tool":`tools`,Drill:`tools`,Sanding:`tools`,Silence:`silence`},preserveOriginal:!1},JK={mapping:{speech:`speech`,child_speech:`speech`,conversation:`speech`,whispering:`speech`,singing:`speech`,humming:`speech`,shout:`scream`,yell:`scream`,screaming:`scream`,crying:`crying`,baby_crying:`crying`,sobbing:`crying`,laughter:`laughter`,baby_laughter:`laughter`,giggling:`laughter`,music:`music`,guitar:`music`,piano:`music`,drums:`music`,dog_bark:`dog`,dog_bow_wow:`dog`,dog_growling:`dog`,dog_howl:`dog`,cat_meow:`cat`,cat_purr:`cat`,cat_hiss:`cat`,bird:`bird`,bird_chirp:`bird`,bird_squawk:`bird`,animal:`animal`,horse:`animal`,cow_moo:`animal`,insect:`animal`,alarm:`alarm`,smoke_alarm:`alarm`,fire_alarm:`alarm`,car_alarm:`alarm`,siren:`siren`,police_siren:`siren`,ambulance_siren:`siren`,doorbell:`doorbell`,door_knock:`doorbell`,knocking:`doorbell`,glass_breaking:`glass_breaking`,glass_shatter:`glass_breaking`,gunshot:`gunshot`,explosion:`gunshot`,fireworks:`gunshot`,car:`vehicle`,truck:`vehicle`,motorcycle:`vehicle`,car_horn:`vehicle`,vehicle_horn:`vehicle`,traffic:`vehicle`,fire:`fire`,fire_crackle:`fire`,water:`water`,rain:`water`,ocean:`water`,splash:`water`,wind:`wind`,thunder:`wind`,thunderstorm:`wind`,door:`door`,door_slam:`door`,sliding_door:`door`,footsteps:`footsteps`,walking:`footsteps`,running:`footsteps`,crowd:`crowd`,chatter:`crowd`,cheering:`crowd`,applause:`crowd`,telephone_ring:`telephone`,ringtone:`telephone`,engine:`engine`,engine_starting:`engine`,lawn_mower:`engine`,chainsaw:`engine`,hammer:`tools`,jackhammer:`tools`,drill:`tools`,power_tool:`tools`,silence:`silence`},preserveOriginal:!1},YK=new Map;for(let[e,t]of Object.entries(qK.mapping))YK.set(e.toLowerCase(),t);for(let[e,t]of Object.entries(JK.mapping))YK.set(e.toLowerCase(),t);function TOe(e){return YK.get(e.toLowerCase())??null}function EOe(){return KK.map(e=>e.id)}var XK=vP();function ZK(e){return CP(XK.swatches,XK.fallbacks,e)}function DOe(e){let t=e[0];if(t===void 0)throw Error(`display palette has no fallback colour`);return t}var OOe=DOe(XK.fallbacks);function kOe(e){return e.split(/[-_ ]/).filter(e=>e.length>0).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}var QK=new Map;function $K(e,t,n,r){QK.set(e,{kind:e,parentKind:null,level:`macro`,category:t,color:ZK(e),iconId:n,labelKey:`eventKind.${e}`,label:r})}function eq(e,t,n,r,i){QK.set(e,{kind:e,parentKind:t,level:`sub`,category:n,color:ZK(e),iconId:r,labelKey:`eventKind.${e}`,label:i})}$K(`motion`,`motion`,`motion`,`Motion`),$K(`audio`,`audio`,`audio`,`Audio`),$K(`person`,`detection`,`person`,`Person`),$K(`vehicle`,`detection`,`vehicle`,`Vehicle`),$K(`animal`,`detection`,`animal`,`Animal`),$K(`package`,`package`,`package`,`Package`),$K(`sensor`,`sensor`,`sensor`,`Sensor`),$K(`control`,`control`,`control`,`Control`);for(let[e,t]of Object.entries(n_.mapping))t!==`vehicle`&&t!==`animal`||QK.has(e)||eq(e,t,`detection`,e,kOe(e));eq(`package-delivered`,`package`,`package`,`package`,`Package delivered`),eq(`package-picked-up`,`package`,`package`,`package`,`Package picked up`),eq(`contact`,`sensor`,`sensor`,`door`,`Contact`),eq(`motion-sensor`,`sensor`,`sensor`,`pir`,`Motion sensor`),eq(`smoke`,`sensor`,`sensor`,`smoke`,`Smoke`),eq(`flood`,`sensor`,`sensor`,`water`,`Water leak`),eq(`gas`,`sensor`,`sensor`,`gas`,`Gas`),eq(`carbon-monoxide`,`sensor`,`sensor`,`smoke`,`Carbon monoxide`),eq(`vibration`,`sensor`,`sensor`,`vibration`,`Vibration`),eq(`tamper`,`sensor`,`sensor`,`tamper`,`Tamper`),eq(`presence`,`sensor`,`sensor`,`presence`,`Presence`),eq(`enum-sensor`,`sensor`,`sensor`,`generic`,`Sensor state`),eq(`device-event`,`sensor`,`sensor`,`button`,`Device event`),eq(`lock`,`control`,`control`,`lock`,`Lock`),eq(`cover`,`control`,`control`,`door`,`Cover`),eq(`switch`,`control`,`control`,`switch`,`Switch`),eq(`siren`,`control`,`control`,`siren`,`Siren`),eq(`button`,`control`,`control`,`button`,`Button`),eq(`doorbell`,`control`,`control`,`doorbell`,`Doorbell`),eq(`appliance-cycle`,`control`,`control`,`switch`,`Appliance cycle`);for(let e of KK){let t=`audio-${e.id}`;QK.has(t)||eq(t,`audio`,`audio`,t,e.name)}var tq=Object.freeze(Object.fromEntries(QK));function nq(e){return tq[e]}function AOe(e){return ZK(e)}function jOe(e){let t=[];for(let n of Object.values(tq))n.parentKind===e&&t.push(n);return t}var rq=b({kind:l(),label:l(),parentKind:l().nullable()}),iq=b({videoClasses:S(rq),audioKinds:S(rq),labels:S(rq)});function aq(e,t,n){return{kind:e,label:t,parentKind:n}}function oq(){let e=Object.values(tq);return{videoClasses:e.filter(e=>e.category===`detection`).map(e=>aq(e.kind,e.label,e.parentKind)),audioKinds:e.filter(e=>e.category===`audio`&&e.level===`sub`).map(e=>aq(e.kind,e.label,e.parentKind)),labels:e.filter(e=>e.category===`sensor`||e.category===`control`).map(e=>aq(e.kind,e.label,e.parentKind))}}var MOe=Object.freeze(oq()),sq=x([`immediate`,`track-end`,`device-event`,`package-event`,`system-event`]),cq=x(`device-online.device-offline.device-disabled.device-enabled.device-battery-low.device-battery-normal.device-consumable-low.device-consumable-normal.stream-online.stream-offline.node-online.node-offline.node-restarting.node-updating.node-inference-unavailable.detection-blind.motion-noisy.motion-calm.package-llm-silent.package-llm-answered.recording-stalled.recording-healthy.recording-degraded.device-attention-required.device-attention-resolved.device-command.storage-location-low.storage-location-critical.storage-location-ok.storage-drain-progress.storage-drain-complete.addon-crash-loop.addon-update-available.server-update-available.wrapper-update-available.alarm-triggered.alarm-armed.alarm-disarmed.alarm-arming.alarm-arm-refused.alarm-pending.alarm-rearmed.alarm-sensor-bypass.alarm-check-failed.addon-updated.server-updated.export-completed.backup-completed.alert-critical.alert-error.alert-critical-resolved.rule-broken.rule-repaired.camera-online.camera-offline.camera-disabled.camera-enabled`.split(`.`)),lq=[`camera-online`,`camera-offline`,`camera-disabled`,`camera-enabled`],NOe=new Set(lq),POe=cq.options.filter(e=>!NOe.has(e)),uq=[`alarm-arm-refused`,`alarm-check-failed`,`alarm-arming`,`alarm-armed`,`alarm-pending`,`alarm-triggered`,`alarm-rearmed`,`alarm-sensor-bypass`,`alarm-disarmed`],FOe=[`device-battery-low`,`device-battery-normal`,`device-consumable-low`,`device-consumable-normal`],dq=[`device-consumable-low`,`device-consumable-normal`],IOe=15,LOe=95,fq=[`confirmed`,`already`,`unconfirmed`,`failed`],pq=[`user`,`addon`,`action`,`scheduler`,`composition`,`node`],mq=b({kinds:S(cq).min(1),deviceIds:S(n().int()).min(1).optional(),deviceTypes:S(l().min(1)).min(1).optional(),excludeDeviceIds:S(n().int()).min(1).optional(),nodeIds:S(l().min(1)).min(1).optional(),packageNames:S(l().min(1)).min(1).optional(),commandActions:S(l().min(1)).min(1).optional(),commandOutcomes:S(x(fq)).min(1).optional(),commandActorKinds:S(x(pq)).min(1).optional(),consumableLowPercent:n().int().min(1).max(95).optional()});function ROe(e){return e.consumableLowPercent??15}var zOe=1,hq=1440,BOe=[10,30,60],gq=b({days:S(n().int().min(0).max(6)).min(1),startMinute:n().int().min(0).max(1439),endMinute:n().int().min(0).max(1439)}),_q=b({windows:S(gq).min(1),timezone:l().optional(),invert:v().optional()}),vq=x([`instant`,`summary`]),VOe=x([`activation`,`deactivation`,`schedule`]),yq=x([`rule`,`section`]),bq=i(`mode`,[b({mode:p(`instant`)}),b({mode:p(`summary`),schedule:_q,split:yq.optional()}),b({mode:p(`modes`),onActivation:v(),onDeactivation:v(),onSchedule:b({schedule:_q,grouping:yq}).optional()})]),xq=b({values:S(l().min(1)),maxDistance:n().int().min(0).max(3).default(1)}),Sq=b({zoneId:l().optional(),className:l().optional(),op:x([`became-occupied`,`became-free`,`>=`,`<=`]).default(`became-occupied`),count:n().int().min(0).default(1),sustainSeconds:n().int().min(0).max(3600).default(15)}),HOe=-96,Cq=b({labels:S(l().min(1)).min(1).optional(),dbThreshold:n().min(-96).max(0).optional(),hitPercent:n().int().min(1).max(100).default(60),samplingSeconds:n().int().min(1).max(300).default(10),confirmHits:n().int().min(1).max(20).optional(),confirmWindowSec:n().int().min(1).max(60).optional()}),wq=x([`enter`,`exit`,`any`]),Tq=x([`raised`,`cleared`]),Eq=b({ids:S(l().min(1)).min(1),match:x([`any`,`all`]).optional()}),Dq=l().min(1),Oq=S(Dq).max(4),kq=b({id:l().min(1).max(64),label:l().min(1).max(40),actionId:Dq,icon:Yu.optional(),destructive:v().optional()}),Aq=b({onActivation:Oq.optional(),onDeactivation:Oq.optional(),onTrigger:Oq.optional(),onTriggerOff:Oq.optional(),buttons:S(kq).max(8).optional()}),jq=b({deviceId:n().int(),states:S(l().min(1)).min(1)}),Mq=b({sceneId:l().min(1),deviceId:n().int().optional(),requiredState:x([`matched`,`diverged`]),latched:v().optional()}),Nq=b({deviceState:jq.optional(),scene:Mq.optional(),devices:S(n()).optional(),devicesExclude:S(n()).min(1).optional(),classes:S(l().min(1)).optional(),classesExclude:S(l().min(1)).optional(),minConfidence:n().min(0).max(1).optional(),zones:Eq.optional(),zonesExclude:S(l().min(1)).optional(),crossing:wq.optional(),labelEquals:S(l().min(1)).optional(),identities:S(l().min(1)).optional(),plates:xq.optional(),identitiesExclude:S(l().min(1)).optional(),minImportance:n().min(0).max(1).optional(),minDwellSeconds:n().min(0).optional(),source:x([`pipeline`,`onboard`,`sensor`,`audio`,`any`]).optional(),minLabelConfidence:n().min(0).max(1).optional(),eventTypeTokens:S(l().min(1)).optional(),sensorKinds:S(l().min(1)).optional(),sensorTransition:Tq.optional(),packagePhase:x([`delivered`,`picked-up`,`both`]).optional(),systemEvent:mq.optional(),customZones:S(tH).optional(),occupancy:Sq.optional(),audio:Cq.optional()}),Pq=b({targetId:l().min(1),params:m(l(),C()).optional()}),UOe=500,Fq=x([`none`,`image`,`clip`,`gif`]),Iq=b({template:b({title:l().max(500).optional(),body:l().max(2e3).optional()}).optional(),schedule:_q.optional(),priority:n().int().min(1).max(5).optional(),attachment:Fq.optional(),actions:v().optional()}),Lq=m(l(),Iq),Rq=x([`scene-boxes`,`crop`,`clean`,`none`]),zq=x([`cropped`,`full`,`boxed`]),Bq=x([`mosaic`,`each`]),WOe=4,GOe=6,Vq=b({image:Rq.optional(),showTriggerZone:v().optional(),showSubjectPath:v().optional(),attach:x([`best`,`best-matching`,`keyFrame`,`none`]).optional(),frame:zq.optional(),zoneCrop:v().optional(),gif:v().optional(),clip:v().optional(),clipPreRollSec:n().int().min(0).max(30).optional(),clipPostRollSec:n().int().min(0).max(30).optional(),clipSpeed:n().min(1).max(8).optional(),profile:N.optional(),linkedCameras:Bq.optional(),wakeSleepingCamera:v().optional()}),Hq=x([`shared`,`per-class`]),Uq=b({cooldownSec:n().int().min(0).max(86400).default(60),scope:x([`rule`,`rule-device`]).default(`rule-device`),granularity:Hq.optional()}),Wq=1e3,Gq=2e4,Kq=8e3,KOe=448,qq=b({op:x([`>=`,`>`,`<=`,`<`,`==`]),count:n().int().min(0).max(1e3)}),Jq=b({enabled:v().default(!1),profileId:l().optional(),prompt:l().max(1e3).optional(),expect:qq.optional(),timeoutMs:n().int().min(Wq).max(Gq).default(Kq),onTimeout:x([`fire`,`suppress`]).default(`fire`),maxImagePx:n().int().min(64).max(2048).default(448)}),qOe=5,JOe=20,YOe=60,XOe=5,ZOe=0,QOe=300,Yq=b({name:l().min(1).max(200),enabled:v().default(!0),delivery:sq,conditions:Nq.default({}),schedule:_q.optional(),systemEventDelivery:bq.optional(),targets:S(Pq),targetUsers:S(l()).optional(),targetOverrides:Lq.optional(),media:Vq.default({}),throttle:Uq.default({cooldownSec:60,scope:`rule-device`}),template:b({title:l().max(500).optional(),body:l().max(2e3).optional()}).optional(),priority:n().int().min(1).max(5).default(3),ownerUserId:l().optional(),snoozeAllowGlobal:v().optional(),snoozeOptions:S(n().int().min(1).max(hq)).max(4).optional(),actions:Aq.optional(),confirm:Jq.optional(),groupingSec:n().int().min(5).max(60).optional(),groupWithinSec:n().int().min(0).max(300).optional(),askVerdict:v().optional(),tags:Vh.optional()}),Xq=x([`event`,`summary`,`timelapse`,`calendar-events`]),Zq=b({kind:Xq,ruleId:l(),tags:S(l())}),Qq=Yq.partial().extend({disabledTargetIds:S(l()).optional(),enabled:v().optional(),conditions:Nq.optional(),media:Vq.optional(),throttle:Uq.optional(),priority:n().int().min(1).max(5).optional()}),$q=[`waitForEnhancement`,`groupIdleSec`];function $Oe(e){return $q.some(t=>t===e)}var eJ=[`template`,`schedule`,`targetUsers`,`snoozeOptions`,`snoozeAllowGlobal`,`actions`,`confirm`,`groupingSec`,`waitForEnhancement`,`groupIdleSec`],tJ=x(eJ),nJ=b({ruleId:l(),patch:Qq,clear:S(tJ).optional()}),rJ=Yq.extend({id:l(),createdBy:l(),createdAt:n(),updatedAt:n(),disabledTargetIds:S(l()).default([])}),iJ=[`device-state`,`streams`,`battery`,`consumables`,`detection-blind`,`nodes`,`addons`,`addon-updates`,`updates`],aJ=x(iJ),oJ=b({id:aJ,status:x([`read`,`unavailable`]),items:n().int().nonnegative(),reason:l().optional()}),sJ=b({section:aJ.optional(),title:l(),text:l(),count:n().int().nonnegative()}),cJ=b({empty:v(),count:n().int().nonnegative(),text:l(),sections:S(oJ),dropped:m(l(),n().int().nonnegative()),excludedGroups:S(l()),split:yq.optional(),rows:S(sJ).optional()}),lJ=b({recordId:l(),recordKind:x([`object-event`,`track`,`device-event`,`package-event`,`system-event`]),deviceId:n(),timestamp:n(),wouldFire:v(),failedCondition:l().optional(),className:l().optional(),label:l().optional()}),uJ=x([`detection`,`sensor`,`occupancy`,`sound`,`device-events`,`system`,`alarm`,`mixed`]),dJ=x([`detection`,`sensor`,`occupancy`,`sound`,`system`]),fJ=b({id:x([`appliance-cycle`]),kind:uJ,title:l(),body:l()}),pJ=x([`rule`,`timelapse`,`summary`]),mJ=x([`title`,`body`,`previewText`,`captionText`]),hJ=x([`subject`,`place`,`time`,`rule`,`occupancy`,`sound`,`sensor`,`system`,`digest`,`ai`]),gJ=b({name:l().regex(/^\w+$/),label:l(),description:l().optional(),example:l(),group:hJ,families:S(pJ).min(1),fields:S(mJ).optional(),kinds:S(dJ).optional(),deliveries:S(sq).optional(),systemEventKinds:S(cq).optional(),systemEventDeliveries:S(vq).optional(),dynamic:b({prefix:p(`count_`),from:p(`classes`)}).optional()}),_J=b({family:pJ,field:mJ,kind:uJ.optional(),delivery:sq.optional(),systemEventKinds:S(cq).optional(),systemEventDelivery:vq.optional()}),vJ=b({context:_J,template:b({title:l().max(500).optional(),body:l().max(2e3).optional()})}),yJ=b({title:l().nullable(),body:l().nullable(),unknown:S(l())}),bJ=b({id:l(),group:x([`scope`,`class`,`zones`,`quality`,`label`,`schedule`,`device`,`package`,`occupancy`,`audio`,`system`]),label:l(),valueType:x([`deviceIdList`,`deviceIdExcludeList`,`stringList`,`number01`,`number`,`sourceSelect`,`zoneSelection`,`zoneIdList`,`schedule`,`plateMatcher`,`packagePhase`,`crossingSelect`,`sensorTransition`,`polygonDraw`,`occupancy`,`audio`,`deviceState`,`scene`,`systemEvent`]),operator:x([`in`,`notIn`,`anyOf`,`allOf`,`gte`,`fuzzyIn`,`withinSchedule`]),appliesTo:S(sq),phase:l(),description:l().optional(),options:S(b({value:l(),label:l(),hint:l().optional()})).readonly().optional()}),eke=[{id:`systemEvent`,group:`system`,label:`System event`,valueType:`systemEvent`,options:[{value:`device-online`,label:`Device online`},{value:`device-offline`,label:`Device offline`},{value:`device-disabled`,label:`Device switched off`},{value:`device-enabled`,label:`Device switched on`},{value:`stream-online`,label:`Stream online`},{value:`stream-offline`,label:`Stream offline`},{value:`node-online`,label:`Node online`},{value:`node-offline`,label:`Node offline`},{value:`node-restarting`,label:`Node restarting`},{value:`node-updating`,label:`Node updating (restart imminent)`},{value:`node-inference-unavailable`,label:`Node has no usable inference device`},{value:`detection-blind`,label:`Camera detecting nothing`},{value:`motion-noisy`,label:`Camera motion constant, no subject`},{value:`motion-calm`,label:`Camera motion calm again`},{value:`package-llm-silent`,label:`Package confirm not answering`},{value:`package-llm-answered`,label:`Package confirm answering again`},{value:`recording-stalled`,label:`Recording stalled`},{value:`recording-healthy`,label:`Recording healthy again`},{value:`recording-degraded`,label:`Recording degraded (restart storm)`},{value:`device-attention-required`,label:`Device needs attention`},{value:`device-attention-resolved`,label:`Device attention resolved`},{value:`device-command`,label:`Command given to a device`},{value:`storage-location-low`,label:`Storage location low`},{value:`storage-location-critical`,label:`Storage location critical`},{value:`storage-location-ok`,label:`Storage location ok again`},{value:`storage-drain-progress`,label:`Storage drain progress`},{value:`storage-drain-complete`,label:`Storage drain complete`},{value:`addon-crash-loop`,label:`Addon stopped after repeated crashes`},{value:`addon-update-available`,label:`Addon update available`},{value:`server-update-available`,label:`Server update available`},{value:`wrapper-update-available`,label:`Container / app update available`},{value:`addon-updated`,label:`Addons updated`},{value:`server-updated`,label:`Server updated`},{value:`device-battery-low`,label:`Battery low`},{value:`device-battery-normal`,label:`Battery back to normal`},{value:`device-consumable-low`,label:`Consumable low`},{value:`device-consumable-normal`,label:`Consumable replaced`},{value:`export-completed`,label:`Export completed`},{value:`backup-completed`,label:`Backup completed`},{value:`alert-critical`,label:`Critical alert raised`},{value:`alert-error`,label:`Error alert raised`},{value:`alert-critical-resolved`,label:`Critical alert resolved`},{value:`rule-broken`,label:`Notification rule broken`},{value:`rule-repaired`,label:`Notification rule repaired`},{value:`alarm-arm-refused`,label:`Alarm arm refused`},{value:`alarm-check-failed`,label:`Alarm check failed (armed anyway)`},{value:`alarm-arming`,label:`Alarm arming (exit delay)`},{value:`alarm-armed`,label:`Alarm armed`},{value:`alarm-pending`,label:`Alarm entry delay started`},{value:`alarm-triggered`,label:`Alarm triggered`},{value:`alarm-rearmed`,label:`Alarm re-armed after siren`},{value:`alarm-sensor-bypass`,label:`Alarm sensor bypass`},{value:`alarm-disarmed`,label:`Alarm disarmed`}],operator:`in`,appliesTo:[`system-event`],phase:`P1`,description:`Infrastructure and update events. Device liveness covers EVERY device type — narrow it by device type (cameras only, say) and/or by device, node events by node id, and addon updates by package name.`},{id:`devices`,group:`scope`,label:`Devices`,valueType:`deviceIdList`,operator:`in`,appliesTo:[`immediate`,`track-end`,`device-event`,`package-event`],phase:`P1`,description:`Restrict the rule to these devices; absent = all devices. A sensor event matches either the SENSOR that fired or the camera it is attributed to, so a rule may name either one.`},{id:`devicesExclude`,group:`scope`,label:`Excluded devices`,valueType:`deviceIdExcludeList`,operator:`notIn`,appliesTo:[`immediate`,`track-end`,`device-event`,`package-event`],phase:`P1`,description:`Every device except these. Judged on the same device ids as Devices: a sensor event is excluded by the SENSOR that fired or by the camera it is attributed to.`},{id:`classes`,group:`class`,label:`Object classes`,valueType:`stringList`,operator:`in`,appliesTo:[`immediate`,`track-end`,`package-event`],phase:`P1`,description:`Any overlap with the detection class set passes.`},{id:`classesExclude`,group:`class`,label:`Excluded classes`,valueType:`stringList`,operator:`notIn`,appliesTo:[`immediate`,`track-end`,`package-event`],phase:`P1`},{id:`minConfidence`,group:`quality`,label:`Minimum confidence`,valueType:`number01`,operator:`gte`,appliesTo:[`immediate`,`track-end`,`package-event`],phase:`P1`},{id:`zones`,group:`zones`,label:`Zones`,valueType:`zoneSelection`,operator:`anyOf`,appliesTo:[`immediate`,`track-end`,`package-event`],phase:`P1`,description:`The zones the subject must be in (included) or never in (excluded).`},{id:`zonesExclude`,group:`zones`,label:`Excluded zones`,valueType:`zoneIdList`,operator:`notIn`,appliesTo:[`immediate`,`track-end`,`package-event`],phase:`P1`},{id:`crossing`,group:`zones`,label:`Zone crossing`,valueType:`crossingSelect`,options:[{value:``,label:`Entering`,hint:`Entries and ordinary movement; never an exit.`},{value:`exit`,label:`Leaving`,hint:`Only an exit from a zone.`},{value:`any`,label:`Entering or leaving`,hint:`Entries, exits and ordinary movement.`}],operator:`in`,appliesTo:[`immediate`],phase:`P1`,description:`Which way the subject crosses the zone.`},{id:`labelEquals`,group:`label`,label:`Label equals`,valueType:`stringList`,operator:`in`,appliesTo:[`immediate`,`track-end`],phase:`P1`,description:`Exact match on the collapsed label (identity / plate / subclass).`},{id:`identities`,group:`label`,label:`Known faces`,valueType:`stringList`,operator:`in`,appliesTo:[`immediate`,`track-end`],phase:`P1`,description:`Only recognised people. Selecting NOBODY means every identity in the face gallery; selecting some narrows to those. Matched on the gallery id, so renaming a person does not break the rule. On Immediate delivery the name must already be known when an event is written — choose Immediate, grouped to wait for it.`},{id:`plates`,group:`label`,label:`Known plates`,valueType:`plateMatcher`,operator:`fuzzyIn`,appliesTo:[`immediate`,`track-end`],phase:`P1`,description:`Only vehicles whose plate was read. Selecting NO plate means any readable plate; listed plates are matched Levenshtein-tolerantly, because OCR noise makes an exact match useless.`},{id:`identitiesExclude`,group:`label`,label:`Excluded faces`,valueType:`stringList`,operator:`notIn`,appliesTo:[`immediate`,`track-end`],phase:`P1`,description:`Veto by identity (mirror of Known faces, same gallery ids). A subject nobody recognised passes — there is nothing to exclude.`},{id:`minLabelConfidence`,group:`label`,label:`Minimum label confidence`,valueType:`number01`,operator:`gte`,appliesTo:[`track-end`],phase:`P1`,description:`Best identity/plate recognition match confidence [0,1] for the label the track carries at close (peak assigned-identity cosine / peak plate OCR score; the higher of the two when both were read). Distinct from detection confidence. Fails closed for a track that ended un-recognized.`},{id:`minImportance`,group:`quality`,label:`Minimum importance`,valueType:`number01`,operator:`gte`,appliesTo:[`track-end`],phase:`P1`,description:`Server-computed key-event importance [0,1]; track-end rules only (importance is scored at close). Fails when the record has none.`},{id:`minDwellSeconds`,group:`quality`,label:`Minimum dwell (seconds)`,valueType:`number`,operator:`gte`,appliesTo:[`track-end`],phase:`P1`,description:`Track lifespan in seconds (lastSeen − firstSeen); track-end rules only.`},{id:`source`,group:`scope`,label:`Detection source`,valueType:`sourceSelect`,options:[{value:`any`,label:`Any source`},{value:`pipeline`,label:`Pipeline`},{value:`onboard`,label:`Onboard (camera)`},{value:`sensor`,label:`Sensor`},{value:`audio`,label:`Audio marker`}],operator:`in`,appliesTo:[`immediate`,`track-end`,`device-event`,`package-event`],phase:`P1`,description:`pipeline / onboard / sensor / audio; a record with no stamped source counts as pipeline.`},{id:`deviceState`,group:`scope`,label:`Device state`,valueType:`deviceState`,operator:`in`,appliesTo:[`immediate`,`track-end`,`device-event`,`package-event`],phase:`P2`,description:`Only fire while another device is in one of the chosen states — the alarm armed, a switch on, a contact closed. A state that cannot be read does NOT fire.`},{id:`scene`,group:`scope`,label:`Scene state`,valueType:`scene`,operator:`in`,appliesTo:[`immediate`,`track-end`,`device-event`,`package-event`],phase:`P3`,description:`Only fire while a scene is matched or diverged.`},{id:`sensorKinds`,group:`device`,label:`Sensor kinds`,valueType:`stringList`,operator:`in`,appliesTo:[`device-event`],phase:`P1`,description:`Sensor/control taxonomy kinds (doorbell / contact / button / …) matched against the persisted device event.`},{id:`eventTypeTokens`,group:`device`,label:`Event-type tokens`,valueType:`stringList`,operator:`in`,appliesTo:[`device-event`],phase:`P1`,description:`Raw device event-type tokens (e.g. doorbell press / press_long) from the event-emitter slice; absent on doorbell-pulse / passive sensors.`},{id:`sensorTransition`,group:`device`,label:`Notify when`,valueType:`sensorTransition`,options:[{value:``,label:`When it starts and when it finishes`,hint:`Every change: the alert itself, and the return to normal.`},{value:`raised`,label:`Only when it starts`,hint:`Water detected, smoke, a contact opening — never the return to normal.`},{value:`cleared`,label:`Only when it finishes`,hint:`Back to dry, smoke gone, a contact closing — never the alert itself.`}],operator:`in`,appliesTo:[`device-event`],phase:`P2`,description:`Fire on one edge of a boolean sensor. Offered only when every chosen sensor kind raises and clears; a reading that cannot be placed still notifies.`},{id:`packagePhase`,group:`package`,label:`Package phase`,valueType:`packagePhase`,options:[{value:`delivered`,label:`Delivered`},{value:`picked-up`,label:`Picked up`},{value:`both`,label:`Both`}],operator:`in`,appliesTo:[`package-event`],phase:`P1`,description:`Delivered / picked-up / both.`},{id:`occupancy`,group:`occupancy`,label:`Occupancy`,valueType:`occupancy`,operator:`anyOf`,appliesTo:[`device-event`],phase:`P1`,description:`ZoneAnalytics occupancy edge (optionally zone/class-scoped): count crosses the threshold and holds for sustainSeconds. Fail-closed on a missing snapshot.`},{id:`audio`,group:`audio`,label:`Sound`,valueType:`audio`,operator:`anyOf`,appliesTo:[`immediate`],phase:`P2`,description:`Fires when at least hitPercent% of the samples in a samplingSeconds window are hits — a hit clears the dBFS floor AND carries one of the chosen sounds. Both filters are optional and independent, but naming NEITHER never matches: every sample would be a hit, so the engine refuses rather than notifying on silence. dBFS is negative-going (0 = full scale, -96 = silence).`},{id:`customZones`,group:`zones`,label:`Custom zones`,valueType:`polygonDraw`,operator:`anyOf`,appliesTo:[`immediate`,`track-end`,`package-event`],phase:`P1`,description:`User-drawn polygons; a detection whose bbox overlaps any polygon matches.`},{id:`schedule`,group:`schedule`,label:`Schedule`,valueType:`schedule`,operator:`withinSchedule`,appliesTo:[`immediate`,`track-end`,`device-event`,`package-event`,`system-event`],phase:`P1`,description:`Weekly activation windows (invertible); absent = always active.`}],xJ=x([`pending`,`sent`,`dead`]),SJ=x([`object-event`,`track-end`,`device-event`,`package-event`,`system-event`]),CJ=b({className:l(),label:l().optional(),confidence:n().optional(),zones:S(l()),timestamp:n(),systemEvent:b({kind:cq,subject:l(),title:l(),body:l(),data:m(l(),C())}).optional()}),wJ=b({id:l(),ruleId:l(),ruleName:l(),delivery:sq,targetId:l(),deviceId:n(),recordKind:SJ,recordId:l(),trackId:l().optional(),status:xJ,attempts:n().int(),createdAt:n(),updatedAt:n(),error:l().optional(),subject:CJ,title:l().optional(),body:l().optional(),artifactIds:S(l().min(1)).optional(),groupedInto:l().min(1).optional()}),tke=100,nke=500,TJ=b({ruleId:l().optional(),deviceId:n().optional(),status:xJ.optional(),since:n().optional(),until:n().optional(),limit:n().int().min(1).max(500).default(100)}),EJ=b({ruleId:l(),lastAt:n(),status:xJ,deviceId:n()}),DJ=b({runs:S(EJ),horizonMs:n().nonnegative().nullable()}),OJ=x([`rule`,`device`,`all`]),kJ=b({scope:OJ,ruleId:l().optional(),deviceId:n().int().optional(),classes:S(l().min(1)).min(1).optional(),durationMinutes:n().int().min(1).max(hq),global:v().optional(),summary:v().optional()}),AJ=b({id:l(),userId:l(),scope:OJ,ruleId:l().optional(),deviceId:n().int().optional(),classes:S(l().min(1)).min(1).optional(),startedAt:n(),expiresAt:n(),global:v(),summary:v(),digestSentAt:n().optional()}),rke=b({snoozeId:l(),targetId:l(),ruleId:l(),ruleName:l(),deviceId:n().int(),count:n().int(),firstAt:n(),lastAt:n()}),ike=600,jJ=3600,ake=200,MJ=n().int().min(0).max(600),NJ=n().int().min(0).max(jJ),PJ=e=>new Set(e.map(e=>e.mode)).size===e.length,FJ=x([`rearmAfter`,`disableAfter`,`doNothing`]),IJ=b({mode:qS,exitDelaySec:MJ.optional(),entryDelaySec:MJ.optional(),triggeredDurationSec:NJ.optional(),postTriggeredAction:FJ.optional(),schedule:_q.optional(),notifyDuringEntryDelay:v().optional(),notifySensorRewatched:v().optional(),notifySensorIgnored:v().optional()}),oke=S(IJ).max(8).refine(PJ,{message:`modeDelays: at most one entry per arm mode`}),LJ=b({mode:qS,exitDelaySec:MJ.nullable().optional(),entryDelaySec:MJ.nullable().optional(),triggeredDurationSec:NJ.nullable().optional(),postTriggeredAction:FJ.nullable().optional(),schedule:_q.nullable().optional(),notifyDuringEntryDelay:v().nullable().optional(),notifySensorRewatched:v().nullable().optional(),notifySensorIgnored:v().nullable().optional()}),ske=S(LJ).max(8).refine(PJ,{message:`modeDelays: at most one edit per arm mode`}),RJ=b({mode:qS,deviceId:n().int().positive(),nonBlocking:v()}),zJ=b({mode:qS,deviceId:n().int().positive(),blocking:v()}),BJ=b({mode:qS,deviceId:n().int().positive(),secureOnArm:v()}),VJ=b({mode:qS,deviceIds:S(n().int()).max(200)}),HJ=VJ,UJ=VJ,WJ=VJ,GJ=S(HJ).max(8).refine(PJ,{message:`nonBlocking: at most one list per arm mode`}),KJ=S(UJ).max(8).refine(PJ,{message:`blocking: at most one list per arm mode`}),qJ=S(WJ).max(8).refine(PJ,{message:`secureOnArmOff: at most one list per arm mode`}),JJ=b({exitDelaySec:MJ,entryDelaySec:MJ,triggeredDurationSec:NJ,postTriggeredAction:FJ.optional(),announceArm:v().optional(),announceTargets:S(l().min(1)).max(16),nonBlocking:GJ.default([]),blocking:KJ.default([]),secureOnArmOff:qJ.default([]),modeDelays:oke.default([])}),YJ=b({id:l().min(1).max(64),name:l().min(1).max(64),isDefault:v()}),XJ=b({activeId:l().min(1),items:S(YJ).min(1)}),ZJ=b({name:l().min(1).max(64),cloneFromId:l().min(1).max(64).optional()}),QJ=b({id:l().min(1).max(64),name:l().min(1).max(64)}),$J=b({id:l().min(1).max(64)}),eY=JJ.extend({nonBlocking:GJ,blocking:KJ,secureOnArmOff:qJ,modeDelays:ske,nonBlockingEdit:RJ,blockingEdit:zJ,secureOnArmEdit:BJ}).partial().refine(e=>e.nonBlocking===void 0||e.nonBlockingEdit===void 0,{message:`nonBlocking and nonBlockingEdit are exclusive — send the whole lists or one edit`}).refine(e=>e.blocking===void 0||e.blockingEdit===void 0,{message:`blocking and blockingEdit are exclusive — send the whole lists or one edit`}).refine(e=>e.secureOnArmOff===void 0||e.secureOnArmEdit===void 0,{message:`secureOnArmOff and secureOnArmEdit are exclusive — send the whole lists or one edit`}),cke=x([`muted`,`detection-off`,`offline`]),tY=b({deviceId:n().int(),reason:cke}),nY=b({mode:qS,ruleCount:n().int().min(0),allDevices:v(),deviceIds:S(n().int()),allDevicesExcept:S(n().int()).default([]),skippedDevices:S(tY).default([])}),lke=b({deviceId:n().int(),name:l(),state:l(),blocking:v()}),uke=b({deviceId:n().int(),name:l(),phase:x([`open`,`closed`])}),dke=b({mode:qS,devices:S(lke),unknown:S(n().int())}),fke=b({ruleId:l(),ruleName:l(),deviceId:n().int(),name:l(),since:n(),dropped:n().int().min(0)}),pke=b({state:KS,targetMode:qS.nullable(),availableModes:S(qS),openings:S(dke),exclusions:S(uke),bypassedInputs:S(fke).default([])}),rY=b({deviceId:n().int().nullable(),settings:JJ,profiles:XJ.optional(),coverage:S(nY),live:pke.optional()}),mke=500,iY=x([`open`,`closed`,`unknown`,`not-opening`]),aY=b({deviceId:n().int().positive(),reading:iY,state:l().nullable(),unknownWhy:x([`read-failed`,`unknown-word`]).nullable(),online:v().nullable(),controllable:v().default(!1)}),oY=b({deviceIds:S(n().int().positive()).max(500)}),sY=b({sensors:S(aY),readAt:n().int().nonnegative()}),hke=60,cY=b({deviceId:n().int().nonnegative().optional(),seconds:n().min(0).max(60),profile:N.optional(),ruleId:l(),ruleName:l(),reason:x([`window`,`occupancy`])}),lY=b({rulesLoaded:v(),asks:S(cY).readonly()}),uY={name:`notification-rules`,scope:`system`,mode:`singleton`,methods:{listRules:k(b({}),b({rules:S(rJ)}),{auth:`admin`}),getRule:k(b({ruleId:l()}),b({rule:rJ.nullable()}),{auth:`admin`}),createRule:k(b({rule:Yq}),b({rule:rJ}),{kind:`mutation`,auth:`admin`,caller:`required`}),updateRule:k(nJ,b({rule:rJ}),{kind:`mutation`,auth:`admin`,caller:`required`}),deleteRule:k(b({ruleId:l()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setRuleEnabled:k(b({ruleId:l(),enabled:v()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),listRuleTags:k(b({}),b({rules:S(Zq)}),{kind:`query`,auth:`admin`}),setRuleTags:k(b({kind:Xq,ruleId:l(),tags:Vh}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getClipRetentionAsks:k(b({}),lY,{auth:`admin`}),listDeviceMutes:k(b({}),b({mutedDeviceIds:S(n().int()).readonly()}),{auth:`admin`}),setDeviceMuted:k(b({deviceId:n().int(),muted:v()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),testRule:k(b({rule:Yq,lookbackMinutes:n().int().min(1).max(1440).default(60)}),b({results:S(lJ)}),{kind:`mutation`,auth:`admin`}),previewStateSummary:k(b({rule:Yq}),cJ,{kind:`mutation`,auth:`admin`,access:`view`}),getConditionCatalog:k(b({}),b({catalog:S(bJ),taxonomy:iq.optional()})),getTemplateCatalog:k(b({}),b({vars:S(gJ),defaults:S(fJ)})),previewTemplate:k(vJ,yJ,{kind:`mutation`,access:`view`}),getHistory:k(b({filter:TJ.default({limit:100})}),b({entries:S(wJ)}),{auth:`admin`}),getRuleLastRuns:k(b({}),DJ,{auth:`admin`}),resolveArtifactUrl:k(b({artifactId:l().min(1)}),b({url:l().nullable()}),{auth:`admin`}),listSnoozes:k(b({}),b({snoozes:S(AJ)}),{caller:`required`}),createSnooze:k(b({snooze:kJ}),b({snooze:AJ}),{kind:`mutation`,caller:`required`}),cancelSnooze:k(b({snoozeId:l()}),b({success:p(!0)}),{kind:`mutation`,caller:`required`}),getAlarmConfig:k(b({}),rY,{auth:`admin`}),setAlarmConfig:k(b({patch:eY}),rY,{kind:`mutation`,auth:`admin`}),createAlarmProfile:k(ZJ,rY,{kind:`mutation`,auth:`admin`}),renameAlarmProfile:k(QJ,rY,{kind:`mutation`,auth:`admin`}),deleteAlarmProfile:k($J,rY,{kind:`mutation`,auth:`admin`}),activateAlarmProfile:k($J,rY,{kind:`mutation`,auth:`admin`}),getAlarmSensors:k(oY,sY,{auth:`admin`})},vocabulary:{notOperatorFacing:`notification rules — authored on their own page`}},gke=x([`min`,`low`,`normal`,`high`]),_ke=b({id:l().min(1),title:l().min(1),uri:r().optional(),destructive:v().optional()}),vke=b({image:v(),priority:v(),data:v(),actions:v(),recipients:v()}),dY=b({lastSentAt:n(),lastError:l().nullable(),queueDepth:n().int().nonnegative().meta(M(`count`)),supports:vke}),yke=b({deviceId:n().int().nonnegative(),title:l().optional(),body:l().min(1),image:l().optional(),priority:gke.optional(),channel:l().optional(),recipients:S(l()).optional(),actions:S(_ke).optional(),data:m(l(),C()).optional()}),bke=b({notificationId:l(),acceptedAt:n()}),fY={name:`notifier`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Notifier],methods:{send:k(yke,bke,{kind:`mutation`,auth:`admin`,actions:[{id:`notifier.send`,label:P(`Send a notification`,`Invia una notifica`),phrase:P(`Send “{body}” through {device}`,`Invia «{body}» tramite {device}`),icon:`send`,openArgs:[{key:`title`,label:P(`Title`,`Titolo`),offer:{kind:`text`},optional:!0},{key:`body`,label:P(`Message`,`Messaggio`),offer:{kind:`text`}},{key:`priority`,label:P(`Priority`,`Priorità`),offer:{kind:`enum`,values:[{value:`min`,label:P(`Minimal`,`Minima`)},{value:`low`,label:P(`Low`,`Bassa`)},{value:`normal`,label:P(`Normal`,`Normale`)},{value:`high`,label:P(`High`,`Alta`)}]},optional:!0}]}]}),cancel:k(b({deviceId:n().int().nonnegative(),notificationId:l().min(1)}),_(),{kind:`mutation`,auth:`admin`})},events:{onSent:{data:b({deviceId:n(),notificationId:l(),success:v(),error:l().nullable(),acceptedAt:n()}),notOperatorFacing:`a delivery receipt of a send this system made — not a fact about the world`}},status:{schema:dY,kind:`command-driven`},runtimeState:dY,durability:`session`,history:`none`,vocabulary:{noun:P(`Notifier`,`Notificatore`),order:2110}},pY=b({value:n().nullable().meta(M(`device`)),lastFetchedAt:n()}),mY={name:`numeric-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Sensor],methods:{},status:{schema:pY,kind:`push`},runtimeState:pY,durability:`restored`,history:{fields:{value:{kind:`gauge`,minIntervalMs:3e4}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:P(`Sensor`,`Sensore`),order:5150,state:[{kind:`numeric`,field:`value`,quantity:P(`the reading`,`il valore`),label:P(`Reading`,`Valore`),icon:`gauge`}]}},hY=b({integrationId:l(),displayName:l(),requestedScopes:S(sg),allowedRedirectPrefixes:S(l()).min(1),allowedPrivateHostPaths:S(l()).optional(),requiresPkce:v().optional(),hubUrl:l().optional(),refreshTokenTtlSec:h([n().int().positive(),p(`never`)]).optional(),instances:S(b({id:l(),displayName:l()})).optional()}),gY={name:`oauth-integration`,scope:`system`,mode:`collection`,internal:!0,methods:{getDescriptor:k(_(),hY,{auth:`admin`})},vocabulary:{notOperatorFacing:j.IDENTITY}},_Y=x([`text`,`timestamp`,`watermark`]),vY=x([`top-left`,`top-center`,`top-right`,`bottom-left`,`bottom-center`,`bottom-right`,`custom`]),yY=b({id:l(),kind:_Y,enabled:v(),text:l().optional(),position:vY.optional(),availablePositions:S(vY).readonly(),readOnly:v().optional(),maxCharacters:n().int().positive().optional()}),bY=b({overlays:S(yY).readonly()}),xY=b({enabled:v().optional(),text:l().optional(),position:vY.optional()}).partial(),SY={name:`osd`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Camera],methods:{setOverlay:k(b({deviceId:n(),overlayId:l(),patch:xY}),_(),{kind:`mutation`,auth:`admin`})},events:{onStatusChanged:{data:b({deviceId:n(),status:bY}),notOperatorFacing:`an overlay setting changed — configuration, not a happening`}},status:{schema:bY,kind:`command-driven`},settings:{bindings:[{kind:`array`,statusPath:`overlays`,idField:`id`,method:`setOverlay`,idArg:`overlayId`,patchArg:`patch`,sectionId:`osd`,sectionTitle:`Video overlays`,itemFields:{enabled:{label:e=>`${String(e.id)} enabled`,kind:`boolean`},text:{label:e=>`${String(e.id)} text`,kind:`text`,when:e=>e.kind!==`timestamp`&&!e.readOnly},position:{label:e=>`${String(e.id)} position`,kind:`select`,options:e=>e.availablePositions??[],when:e=>Array.isArray(e.availablePositions)&&e.availablePositions.length>0}}}]},vocabulary:{noun:P(`On-screen text`,`Testo in sovrimpressione`),order:3190}},CY=1024,wY=b({id:l().min(1).max(64),name:l().min(1).max(64),text:l().max(CY).default(``)}),TY=i(`kind`,[b({kind:p(`none`)}),b({kind:p(`static`),text:l().max(CY)}),b({kind:p(`template`),templateId:l().min(1).max(64)})]),EY=b({enabled:v().default(!0),source:TY,schedule:_q.optional(),conditions:Nq.optional()}),DY=b({slotId:l(),kind:_Y,readOnly:v(),cameraEnabled:v(),cameraText:l().optional(),binding:EY.nullable()}),OY=x([`written`,`unchanged`,`gated`,`unreadable`,`disabled`,`unbound`,`failed`]),kY=b({slotId:l(),outcome:OY,text:l(),reason:l().optional()}),AY=b({ok:v(),text:l(),notes:S(l())}),jY={name:`osd-manager`,scope:`system`,mode:`singleton`,methods:{getDeviceOsd:k(b({deviceId:n().int()}),b({supported:v(),slots:S(DY)}),{auth:`admin`}),getConditionSupport:k(b({}),b({supported:S(l()),catalog:S(bJ)}),{auth:`admin`}),setSlotBinding:k(b({deviceId:n().int(),slotId:l().min(1),binding:EY}),b({slot:DY,render:kY}),{kind:`mutation`,auth:`admin`}),clearSlotBinding:k(b({deviceId:n().int(),slotId:l().min(1)}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setSlotCameraEnabled:k(b({deviceId:n().int(),slotId:l().min(1),enabled:v()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),copyDeviceConfiguration:k(b({sourceDeviceId:n().int(),targetDeviceId:n().int()}),b({copied:n().int().nonnegative(),skipped:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),previewSlot:k(b({deviceId:n().int(),slotId:l().min(1),binding:EY.optional()}),kY,{kind:`mutation`,auth:`admin`}),previewTemplate:k(b({deviceId:n().int(),text:l().max(CY)}),AY,{kind:`mutation`,auth:`admin`}),renderDevice:k(b({deviceId:n().int()}),b({results:S(kY)}),{kind:`mutation`,auth:`admin`}),listTemplates:k(b({}),b({templates:S(wY)}),{auth:`admin`}),upsertTemplate:k(b({template:wY}),b({template:wY}),{kind:`mutation`,auth:`admin`}),deleteTemplate:k(b({templateId:l().min(1).max(64)}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:j.PIPELINE}},MY=1e4,xke=4,Ske=200,Cke=x([`normal`,`offline`,`on_batteries`]),NY=n().int().min(4).max(200),PY=NY.meta(she({quantity:`mass`,unit:`g`})),FY=b({foodLevel:n().nullable().meta(M(`none`)),bowlFood:n().nullable().meta(M(`mass`)),eating:v(),supportsMarkRefilled:v(),food1:n().nullable().meta(M(`none`)),food2:n().nullable().meta(M(`none`)),lowFood:v(),batteryPower:n().min(0).max(100).nullable().meta(M(`percentage`)),powerSource:x([`mains`,`battery`]).nullable(),desiccantLeftDays:n().nullable().meta(M(`duration`)),feeding:v(),status:Cke.nullable(),error:l().nullable(),errorCode:n().nullable().meta(M(`none`)),isDualHopper:v(),childLock:v(),indicatorLight:v(),feedSound:v(),volume:n().meta(M(`none`)),lastFeedGrams:NY.nullable(),lastFeedHopper1:NY.nullable(),lastFeedHopper2:NY.nullable(),lastFetchedAt:n()}),IY={name:`pet-feeder`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.PetFeeder],methods:{feed:k(b({deviceId:n().int().nonnegative(),grams:PY.optional(),hopper1:PY.optional(),hopper2:PY.optional()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.feed`,label:P(`Feed`,`Dai da mangiare`),phrase:P(`Dispense {grams} from {device}`,`Eroga {grams} da {device}`),icon:`paw-print`,hold:{effects:[{field:`feeding`,value:!0}],holdMs:MY},openArgs:[{key:`grams`,label:P(`Grams`,`Grammi`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0}]},{id:`petFeeder.feedHoppers`,label:P(`Feed from both hoppers`,`Eroga da entrambi i serbatoi`),phrase:P(`Dispense {hopper1} and {hopper2} from {device}`,`Eroga {hopper1} e {hopper2} da {device}`),icon:`paw-print`,hold:{effects:[{field:`feeding`,value:!0}],holdMs:MY},openArgs:[{key:`hopper1`,label:P(`Hopper 1`,`Serbatoio 1`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0},{key:`hopper2`,label:P(`Hopper 2`,`Serbatoio 2`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0}]}]}),cancelFeed:k(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.cancelFeed`,label:P(`Cancel feeding`,`Annulla l’erogazione`),phrase:P(`Cancel the feeding on {device}`,`Annulla l’erogazione di {device}`),icon:`circle-x`}]}),callPet:k(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.callPet`,label:P(`Call pet`,`Chiama l’animale`),phrase:P(`Call your pet with {device}`,`Chiama l’animale con {device}`),icon:`megaphone`}]}),playSound:k(b({deviceId:n().int().nonnegative(),soundId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.playSound`,label:P(`Play sound`,`Riproduci un suono`),phrase:P(`Play sound {soundId} on {device}`,`Riproduci il suono {soundId} su {device}`),icon:`volume-2`,openArgs:[{key:`soundId`,label:P(`Sound`,`Suono`),offer:{kind:`number`,min:0,step:1}}]}]}),resetDesiccant:k(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.resetDesiccant`,label:P(`Desiccant replaced`,`Essiccante sostituito`),phrase:P(`Mark the desiccant of {device} as replaced`,`Segna come sostituito l’essiccante di {device}`),icon:`refresh-cw`}]}),markFoodReplenished:k(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.foodReplenished`,label:P(`Food refilled`,`Cibo ricaricato`),phrase:P(`Mark {device} as refilled`,`Segna {device} come ricaricato`),icon:`package`}]}),setChildLock:k(b({deviceId:n().int().nonnegative(),on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.childLockOn`,effect:{field:`childLock`,value:!0},label:P(`Child lock on`,`Blocco bambini attivo`),phrase:P(`Turn on the child lock of {device}`,`Attiva il blocco bambini di {device}`),icon:`lock`,args:{on:!0}},{id:`petFeeder.childLockOff`,effect:{field:`childLock`,value:!1},label:P(`Child lock off`,`Blocco bambini spento`),phrase:P(`Turn off the child lock of {device}`,`Disattiva il blocco bambini di {device}`),icon:`lock-open`,args:{on:!1}}]}),setIndicatorLight:k(b({deviceId:n().int().nonnegative(),on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.lightOn`,effect:{field:`indicatorLight`,value:!0},label:P(`Indicator light on`,`Spia accesa`),phrase:P(`Turn on the indicator light of {device}`,`Accendi la spia di {device}`),icon:`lightbulb`,args:{on:!0}},{id:`petFeeder.lightOff`,effect:{field:`indicatorLight`,value:!1},label:P(`Indicator light off`,`Spia spenta`),phrase:P(`Turn off the indicator light of {device}`,`Spegni la spia di {device}`),icon:`lightbulb-off`,args:{on:!1}}]}),setFeedSound:k(b({deviceId:n().int().nonnegative(),on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.feedSoundOn`,effect:{field:`feedSound`,value:!0},label:P(`Feeding sound on`,`Suono di erogazione attivo`),phrase:P(`Turn on the feeding sound of {device}`,`Attiva il suono di erogazione di {device}`),icon:`volume-2`,args:{on:!0}},{id:`petFeeder.feedSoundOff`,effect:{field:`feedSound`,value:!1},label:P(`Feeding sound off`,`Suono di erogazione spento`),phrase:P(`Turn off the feeding sound of {device}`,`Disattiva il suono di erogazione di {device}`),icon:`volume-x`,args:{on:!1}}]}),setVolume:k(b({deviceId:n().int().nonnegative(),level:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.volume`,effect:{field:`volume`,fromArg:`level`},label:P(`Set volume`,`Imposta il volume`),phrase:P(`Set the volume of {device} to {level}`,`Imposta il volume di {device} a {level}`),icon:`volume-2`,openArgs:[{key:`level`,label:P(`Volume`,`Volume`),offer:{kind:`number`,min:0,step:1}}]}]})},status:{schema:FY,kind:`poll`},runtimeState:FY,durability:`session`,history:{fields:{feeding:{kind:`boolean`},eating:{kind:`boolean`},foodLevel:{kind:`gauge`},bowlFood:{kind:`gauge`},food1:{kind:`gauge`},food2:{kind:`gauge`},batteryPower:{kind:`gauge`,unit:`%`,deadband:2},desiccantLeftDays:{kind:`gauge`,unit:`s`}}},vocabulary:{noun:P(`Pet feeder`,`Distributore di cibo`),order:2030,state:[{kind:`boolean`,field:`lowFood`,label:P(`Food low`,`Cibo in esaurimento`),whenTrue:P(`When {device} runs low on food`,`Quando il cibo di {device} sta finendo`),whenFalse:P(`When {device} has enough food again`,`Quando {device} ha di nuovo cibo a sufficienza`),icon:`package`},{kind:`boolean`,field:`feeding`,label:P(`Feeding`,`In erogazione`),whenTrue:P(`When {device} starts feeding`,`Quando {device} inizia a erogare`),whenFalse:P(`When {device} finishes feeding`,`Quando {device} finisce di erogare`),icon:`paw-print`},{kind:`numeric`,field:`desiccantLeftDays`,quantity:P(`the desiccant life`,`la durata dell’essiccante`),label:P(`Desiccant`,`Essiccante`),unit:`d`,icon:`calendar-clock`}]}},LY=b({waterLevel:n().min(0).max(100).nullable().meta(M(`percentage`)),waterVolume:n().min(0).nullable().meta(M(`volume`)),empty:v().nullable(),pumpRunning:v().nullable(),error:l().nullable(),lastFetchedAt:n()}),RY=`water`;function wke(e){let t=e.waterLevel!==null||e.empty===null?null:e.empty?`empty`:`ok`;return{key:RY,label:`Water`,level:e.waterLevel,status:t,kind:`supply`,form:`tank`,lastResetAt:null,resettable:!1}}var Tke=n().int().nonnegative(),zY={name:`pet-fountain`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.PetFountain],power:{kind:`field`,field:`pumpRunning`,set:`setPump`},methods:{setPump:k(b({deviceId:Tke,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFountain.pumpOn`,effect:{field:`pumpRunning`,value:!0},label:P(`Pump on`,`Pompa accesa`),phrase:P(`Start the pump of {device}`,`Avvia la pompa di {device}`),icon:`play`,args:{on:!0}},{id:`petFountain.pumpOff`,effect:{field:`pumpRunning`,value:!1},label:P(`Pump off`,`Pompa spenta`),phrase:P(`Stop the pump of {device}`,`Ferma la pompa di {device}`),icon:`square`,args:{on:!1}}]})},status:{schema:LY,kind:`push`},runtimeState:LY,durability:`session`,history:{fields:{waterLevel:{kind:`gauge`,unit:`%`,deadband:1},waterVolume:{kind:`gauge`,unit:`L`}}},vocabulary:{noun:P(`Pet fountain`,`Fontana per animali`),order:2040,state:[{kind:`boolean`,field:`empty`,label:P(`Tank empty`,`Serbatoio vuoto`),whenTrue:P(`When the tank of {device} is empty`,`Quando il serbatoio di {device} è vuoto`),whenFalse:P(`When the tank of {device} is refilled`,`Quando il serbatoio di {device} viene riempito`),icon:`droplet`},{kind:`numeric`,field:`waterLevel`,quantity:P(`the water level`,`il livello dell’acqua`),label:P(`Water level`,`Livello dell’acqua`),unit:`%`,icon:`droplets`}]}},Eke=x(Pa),Dke=2,BY={min:1,max:8},VY=x([`intel-core-ultra`,`intel-n-series`,`apple-m-base`,`apple-m-pro`,`amd-phoenix`,`unknown`]),HY=x([`intel-npu`,`intel-igpu`,`amd-igpu`,`amd-npu`,`x86-cpu`,`arm-cpu`,`apple-ane`,`coral`]),UY=i(`kind`,[b({kind:p(`capacity`),sessions:n(),minSessions:n()}),b({kind:p(`tie-faster`),over:l(),recallDelta:n()}),b({kind:p(`stepped-down`),from:l(),to:l(),limitedBy:l()}),b({kind:p(`no-fit-lightest`),sessions:n(),minSessions:n()}),b({kind:p(`derived-latency`),modelId:l()}),b({kind:p(`cpu-device`)}),b({kind:p(`device-disabled`)}),b({kind:p(`device-unavailable`)}),b({kind:p(`node-offline`)}),b({kind:p(`no-hardware-facts`)}),b({kind:p(`no-measured-data`),hardwareClass:VY}),b({kind:p(`no-family-build`),format:Eke}),b({kind:p(`kept-custom-pin`),modelId:l(),deviceKey:l()})]),WY=x([`custom-pin`]),GY=i(`kind`,[b({kind:p(`table`)}),b({kind:p(`node-benchmark`),resultId:l(),measuredAtMs:n()}),b({kind:p(`estimated`),estimatedFrom:VY})]),KY=b({modelId:l(),p50Ms:n(),fps:n(),measured:v(),source:GY.optional(),estimatedFrom:VY.optional(),capacitySessions:n(),personRecall:n()}),qY=b({deviceKey:l(),accelerator:HY.nullable(),enabled:v(),available:v(),chosen:KY.nullable(),kept:WY.optional(),reasons:S(UY).readonly()}),JY=b({nodeId:l(),reachable:v(),hardwareClass:VY.nullable(),cpuModel:l().nullable(),skipped:v(),acceleratorModelId:l().nullable(),devices:S(qY).readonly(),reasons:S(UY).readonly()}),YY=b({stepId:l(),before:l().nullable(),after:l().nullable()}),XY=b({nodeId:l(),deviceKey:l(),madeExplicit:v(),modelPins:S(YY).readonly(),thresholds:S(b({stepId:l(),keys:S(l()).readonly()})).readonly()}),ZY=i(`kind`,[b({kind:p(`custom-pin-kept`),nodeId:l(),deviceKey:l(),modelId:l()}),b({kind:p(`custom-registry-unreadable`),error:l()})]),QY=b({headroom:n().min(.3).max(.5).default(.4),minSessionsPerDevice:n().int().min(BY.min).max(BY.max).default(2)}),$Y=b({planHash:l(),family:p(`yolov9`),headroom:n(),minSessionsPerDevice:n(),cameraFps:n(),generatedAt:n(),nodes:S(JY).readonly(),nodeChanges:S(XY).readonly(),warnings:S(ZY).readonly()}),eX=b({planHash:l(),headroom:n().min(.3).max(.5).default(.4),minSessionsPerDevice:n().int().min(BY.min).max(BY.max).default(2)}),tX=b({phase:x([`download`,`node-models`,`redispatch`]),ok:v(),detail:l()}),nX=i(`kind`,[b({kind:p(`applied`),planHash:l(),phases:S(tX).readonly()}),b({kind:p(`aborted`),phases:S(tX).readonly()}),b({kind:p(`stale`),plan:$Y}),b({kind:p(`refused`),reason:x([`apply-in-progress`])})]),rX=x([`least-loaded`,`share`]),iX=`share`,Oke=`sessionPlacement`;function kke(e){let t=rX.safeParse(e);return t.success?t.data:iX}var aX=b({nodes:m(l(),n().positive()).default({}),devices:m(l(),m(l(),n().positive())).default({})}),oX=b({windowMs:n().int().min(6e4).max(1440*60*1e3).default(3600*1e3)}),sX=b({deviceKey:l(),sessionsNow:n(),sessionsStarted:n(),observedShare:n().nullable()}),cX=b({nodeId:l(),sessionsNow:n(),sessionsStarted:n(),observedShare:n().nullable(),peakSessions:n(),yieldsAway:n(),devices:S(sX).readonly()}),lX=b({deviceId:n(),deviceKey:l(),reason:x([`disabled`,`absent`])}),uX=b({policy:rX,windowMs:n(),observedForMs:n(),sessionsNow:n(),clusterPeakSessions:n(),nodes:S(cX).readonly(),stalePins:S(lX).readonly()}),dX=x([`hardware`,`benchmark`]),fX=x([`no-benchmark-results`,`partial-benchmark-results`]),pX=b({headroom:n().min(.3).max(.5).default(.4),source:dX.default(`hardware`)}),mX=b({deviceKey:l(),share:n(),modelId:l().nullable(),fps:n().nullable(),measured:v(),suggestedMaxSessions:n().nullable()}),hX=b({nodeId:l(),share:n().nullable(),capacitySessions:n(),devices:S(mX).readonly(),skippedReason:l().nullable(),capacitySource:dX.nullable(),capacityFallback:fX.nullable()}),gX=b({headroom:n(),source:dX,cameraFps:n(),minSessionsPerDevice:n(),nodes:S(hX).readonly()}),_X=x([`hardware`,`benchmark`,`manual`]),vX=`benchmark`;function yX(e){return e!==`manual`}var Ake=.4,jke=`shareSource`;function Mke(e){if(e===`auto`)return`hardware`;let t=_X.safeParse(e);return t.success?t.data:vX}var bX=b({source:_X}),Nke=b({nodes:m(l(),n()),devices:m(l(),m(l(),n()))}),xX=b({deviceKey:l(),eligible:v(),configuredPct:n(),effectivePct:n()}),SX=b({nodeId:l(),eligible:v(),configuredPct:n(),effectivePct:n(),capacitySource:dX.nullable(),capacityFallback:fX.nullable(),devices:S(xX).readonly()}),CX=b({source:_X,policy:rX,autoPending:v(),computedAt:n().nullable(),trigger:l().nullable(),nodes:S(SX).readonly(),nodeWeights:m(l(),n()),deviceWeights:m(l(),m(l(),n()))}),wX=[`motion-without-detections`,`detections-under-floor`,`inference-too-slow`,`frames-shed`,`inference-device-unusable`],TX=x(wX),EX=x([`info`,`warning`,`critical`]),DX=i(`type`,[b({type:p(`camera`),deviceId:n()}),b({type:p(`node`),nodeId:l()}),b({type:p(`inference-device`),nodeId:l(),deviceKey:l()})]),OX=b({id:l(),kind:TX,severity:EX,subject:DX,what:l(),evidence:m(l(),n().nullable()),action:l()}),kX=b({source:l(),entries:n().nullable()}),AX=b({nodeId:l(),sessionsNow:n(),unusableDevices:S(l()).readonly(),devices:S(b({deviceKey:l(),sessionsNow:n(),usable:v()})).readonly()}),jX=b({deviceId:n(),nativeCropMissesSincePreviousTick:n().nullable()}),MX=b({generatedAt:n(),tickMs:n(),camerasSeen:n().nullable(),findings:S(OX).readonly(),cameraSignals:S(jX).readonly(),nodes:S(AX).readonly(),sources:S(kX).readonly(),notCovered:S(l()).readonly()}),NX=b({history:n().int().min(1).max(24).default(1)}),PX=b({latest:MX.nullable(),previous:S(MX).readonly()}),Pke=b({engine:gW.optional(),steps:S(Ha).readonly(),audio:b({engine:gW.optional(),modelId:l().optional(),enabled:v(),settings:m(l(),C()).readonly().optional()}).nullable().optional()}),FX=b({modelId:l().optional(),settings:m(l(),C()).optional(),jumpDeviceKey:l().optional(),enabled:v().optional()}),IX=b({maxCameras:n().int().nonnegative().nullable().default(null),detectWeight:n().positive().optional(),detect:v().optional(),decode:v().optional(),audio:v().optional(),ingest:v().optional(),decodeBudgetMb:n().int().min(1024).max(65536).optional(),maxLiveDecodeWorkers:n().int().min(1).max(32).optional(),reachableHost:l().optional(),color:Ll.optional(),stepSettings:m(l(),m(l(),C()).readonly()).optional(),stepEnabled:m(l(),v()).optional(),inferenceDevices:m(l(),b({enabled:v(),weight:n().positive().optional(),maxSessions:n().int().positive().optional(),steps:m(l(),FX).optional()})).optional()}),Fke=m(l(),m(l(),C()).readonly()),LX=x([`pipeline`,`onboard`,`none`]),Ike=b({stepToggles:m(l(),v()).optional(),stepSettings:Fke.optional()}),RX=b({deviceId:n(),agentNodeId:l(),pinned:v(),reason:x([`manual`,`capacity`,`hardware-affinity`,`failover`,`rebalance`]),assignedAt:n()}),zX=b({nodeId:l(),online:v(),load:OG,score:n(),decodeHwaccel:l().nullable()}),BX=b({totalAgents:n(),onlineAgents:n(),totalCameras:n(),attachedCameras:n(),activeCameras:n(),avgInferenceTimeMs:n(),queueDepth:n()}),VX=m(l(),l()),HX=b({ownerNodeId:l(),reachableHost:l().optional(),configIssue:l().optional()}),UX=b({camStreamId:l(),codec:l(),width:n(),height:n(),fps:n(),kind:l()}),WX=b({streams:S(UX).readonly()}),GX=b({detectionNodeId:l().nullable(),decoderNodeId:l().nullable(),audioNodeId:l().nullable(),sourceNodeId:l().nullable(),pinned:b({detection:v(),decoder:v(),audio:v()}),reasons:b({detection:l().optional(),decoder:l().optional(),audio:l().optional()})}),KX=b({profile:l(),status:l(),codec:l(),width:n(),height:n(),subscribers:n(),inFps:n().nullable()}),qX=b({profiles:S(KX).readonly(),webrtcSessions:n(),rtspRestream:v()}),JX=b({nodeId:l()}),YX=b({enabled:v(),fps:n()}),XX=x([`idle`,`installing`,`verifying`,`ready`,`failed`]),ZX=b({state:XX,error:l().optional()}),QX=x([`idle`,`watching`,`active`]),$X=b({nodeId:l(),engine:b({backend:l(),device:l()}),phase:QX,configuredFps:n(),actualFps:n(),queueDepth:n(),avgInferenceMs:n(),provisioning:ZX}),eZ=b({nodeId:l(),enabled:v()}),tZ=om,nZ=b({mode:tZ,active:v(),storageBytes:n()}),rZ=x([`source`,`broker`,`detection`,`recording`,`switches`]),iZ=x([`timeout`,`error`,`partial`]),aZ=b({stage:rZ,reason:iZ,elapsedMs:n()}),oZ=b({state:x([`idle`,`running`,`done`,`error`]),total:n().int().nonnegative(),completed:n().int().nonnegative(),currentDeviceId:n().int().nullable(),failed:S(n().int()).readonly(),mediaDropped:n().int().nonnegative(),tracks:n().int().nonnegative(),events:n().int().nonnegative(),startedAtMs:n().int().nullable(),finishedAtMs:n().int().nullable(),error:l().nullable()}),sZ=b({deviceId:n(),assignment:GX,source:WX,broker:qX.nullable(),decoder:JX.nullable(),motion:YX.nullable(),detection:$X.nullable(),audio:eZ.nullable(),recording:nZ.nullable(),switchedOff:S(Qd).readonly(),cameraSensors:JV.optional(),degraded:S(aZ).readonly(),fetchedAt:n()}),cZ=[`disabled`,`unavailable`,`cannot-host-camera-root`,`accelerator-preferred`,`root-switched-off`,`no-gpu-device`],lZ=x(cZ),Lke=b({key:l(),backend:l(),device:l(),format:x(Pa),available:v(),presence:x([`present`,`absent`,`unknown`]).optional(),enabled:v(),weight:n(),maxSessions:n().nullable(),defaultModelId:l(),steps:m(l(),FX).optional(),exclusion:lZ.nullable()}),uZ=i(`kind`,[b({kind:p(`stored`),modelId:l()}),b({kind:p(`absent`),defaultModelId:l()}),b({kind:p(`unreadable`),reason:x(sH),error:l().optional()})]),Rke=b({nodeId:l(),reachable:v(),devices:S(Lke).readonly(),defaultPoolExcluded:v().optional()}),dZ=x([`off`,`on`,`opt-in`]),fZ=i(`kind`,[b({kind:p(`on`)}),b({kind:p(`off-cluster`)}),b({kind:p(`off-node`)}),b({kind:p(`off-device`)}),b({kind:p(`jump`),toDeviceKey:l()}),b({kind:p(`skip`),reason:x([`no-compatible-model`,`root-not-runnable-on-elected-device`])}),b({kind:p(`zone-driven`)}),b({kind:p(`supplied-by-root`),rootModelId:l()}),b({kind:p(`opt-in-unused`)})]),zke=b({deviceKey:l(),format:x(Pa),stepEnabled:v().nullable(),eligible:v(),cell:fZ}),Bke=b({nodeId:l(),reachable:v(),stepEnabled:v().nullable(),devices:S(zke).readonly()}),pZ=b({steps:S(b({stepId:l(),name:l(),slot:l(),clusterMode:dZ.nullable(),effectiveMode:dZ,camerasEnabling:n().int().nonnegative(),camerasDisabling:n().int().nonnegative(),nodes:S(Bke).readonly()})).readonly()}),mZ=b({deviceId:n().int().nonnegative(),config:VV.nullable()}),hZ=x([`unknown-camera`,`out-of-range`,`no-burst-producer`,`already-looked`]),gZ=b({deviceId:n().int().nonnegative(),afterMs:n().finite(),reason:l()}),_Z=b({scheduled:v(),dueInMs:n().optional(),refusedBecause:hZ.optional()}),vZ={name:`pipeline-orchestrator`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,exposesDeviceSettings:!0,methods:{requestOccupancyLook:k(gZ,_Z,{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:k(wm,b({paused:p(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:k(wm,b({resumed:p(!0)}),{kind:`mutation`,auth:`admin`}),assignPipeline:k(b({deviceId:n(),agentNodeId:l()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),unassignPipeline:k(b({deviceId:n()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setPipelineDevicePin:k(b({deviceId:n(),deviceKey:l()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getPipelineDevicePin:k(b({deviceId:n()}),b({deviceKey:l().nullable()})),rebalance:k(_(),b({migrated:n(),skipped:S(b({deviceId:n(),targetNodeId:l(),reason:l()})).default([])}),{kind:`mutation`,auth:`admin`}),getPipelineAssignments:k(_(),S(RX).readonly()),getPipelineAssignment:k(b({deviceId:n()}),RX.nullable()),getAgentLoad:k(_(),S(zX).readonly()),getClusterModelChoice:k(b({stepId:l()}),uZ),getGlobalMetrics:k(_(),BX),getCameraMetrics:k(b({deviceId:n()}),CW.nullable()),getCapabilityBindings:k(b({nodeId:l()}),VX),setCapabilityBinding:k(b({nodeId:l(),capName:l(),addonId:l()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getIngestOwner:k(_(),HX),assignAudio:k(b({deviceId:n(),nodeId:l()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),unassignAudio:k(b({deviceId:n()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getAudioAssignment:k(b({deviceId:n()}),b({nodeId:l(),pinned:v(),assignedAt:n()}).nullable()),getAudioNodeLoad:k(_(),S(b({nodeId:l(),deviceCount:n()}))),getAudioAssignments:k(_(),S(b({deviceId:n(),nodeId:l(),pinned:v(),assignedAt:n()}))),getAgentSettings:k(b({agentNodeId:l()}),IX.nullable()),listAgentSettings:k(_(),S(b({nodeId:l(),settings:IX})).readonly()),removeAgentSettings:k(b({agentNodeId:l()}),b({success:v(),removed:v()}),{kind:`mutation`,auth:`admin`}),setAgentMaxCameras:k(b({agentNodeId:l(),maxCameras:n().int().nonnegative().nullable()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setAgentCapabilities:k(b({agentNodeId:l(),detect:v().nullable().optional(),audio:v().nullable().optional(),ingest:v().nullable().optional()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setAgentDecodeLimits:k(b({agentNodeId:l(),decodeBudgetMb:n().int().min(1024).max(65536).nullable().optional(),maxLiveDecodeWorkers:n().int().min(1).max(32).nullable().optional()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setAgentReachableHost:k(b({agentNodeId:l(),reachableHost:l().nullable().optional(),color:Ll.nullable().optional()}).refine(e=>e.reachableHost!==void 0||e.color!==void 0,{message:`reachableHost or color required`}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setAgentInferenceDevices:k(b({agentNodeId:l(),inferenceDevices:m(l(),b({enabled:v(),weight:n().positive().optional(),maxSessions:n().int().positive().optional(),steps:m(l(),FX).optional()}))}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setNodeStepSettings:k(b({agentNodeId:l(),addonId:l(),settings:m(l(),C()).nullable()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setClusterStepMode:k(b({stepId:l(),mode:dZ.nullable()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setNodeStepEnabled:k(b({agentNodeId:l(),stepId:l(),enabled:v().nullable()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setDeviceStepEnabled:k(b({agentNodeId:l(),deviceKey:l(),stepId:l(),enabled:v().nullable()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getStepSwitches:k(_(),pZ),getNodeInferenceDevices:k(b({nodeId:l()}),Rke),forgetInferenceDevice:k(b({agentNodeId:l(),deviceKey:l()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),resetNodePipelineDefaults:k(b({agentNodeId:l()}),b({success:p(!0),effectiveModelId:l().nullable()}),{kind:`mutation`,auth:`admin`}),planAutoTune:k(QY,$Y,{auth:`admin`}),applyAutoTune:k(eX,nX,{kind:`mutation`,auth:`admin`}),setLoadBalancingShares:k(aX,b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getPlacementStats:k(oX,uX,{auth:`admin`}),getHealthDigest:k(NX,PX,{auth:`admin`}),suggestShares:k(pX,gX,{auth:`admin`}),getEffectiveShares:k(_(),CX,{auth:`admin`}),setShareSource:k(bX,b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkPreflight:k(MW,LW,{auth:`admin`}),startNodeBenchmark:k(MW,i(`kind`,[b({kind:p(`started`),runId:l()}),b({kind:p(`refused`),preflight:LW})]),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkStatus:k(_(),QW,{auth:`admin`}),abortNodeBenchmark:k(b({runId:l()}),b({aborted:v()}),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkCandidates:k(b({nodeId:l()}),nG,{auth:`admin`}),listNodeBenchmarkResults:k(eG,S(tG).readonly(),{auth:`admin`}),deleteNodeBenchmarkResult:k(b({id:l()}),b({deleted:v()}),{kind:`mutation`,auth:`admin`}),getCameraSettings:k(b({deviceId:n()}),Ike.nullable()),setCameraStepToggle:k(b({deviceId:n(),addonId:l(),enabled:v().nullable()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getCameraDetectionSource:k(b({deviceId:n()}),b({source:LX,explicit:v(),onboard:b({available:v(),geometry:x([`boxed`,`while-streaming`,`flag-only`,`unknown`])})})),setCameraDetectionSource:k(b({deviceId:n(),source:LX}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setCameraStepSettings:k(b({deviceId:n(),addonId:l(),settings:m(l(),C()).nullable()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),resolvePipeline:k(b({deviceId:n(),agentNodeId:l().optional()}),Pke),getCameraSwitches:k(b({deviceId:n()}),af,{role:`viewer`}),setCameraSwitch:k(b({deviceId:n(),switchId:Qd,enabled:v()}),af,{kind:`mutation`,auth:`admin`}),getCameraStatus:k(b({deviceId:n()}),sZ),getCameraStatuses:k(b({deviceIds:S(n()).optional()}),S(sZ).readonly()),setCameraSensors:k(mZ,b({success:p(!0)}),{kind:`mutation`,auth:`admin`}),reconcileFromDisk:k(_(),oZ,{kind:`mutation`,auth:`admin`}),getReconcileFromDiskStatus:k(_(),oZ,{auth:`admin`})},vocabulary:{notOperatorFacing:j.PIPELINE}},yZ=b({id:l(),name:l(),sampleCount:n().int().nonnegative(),coverMediaId:n().int().optional(),coverBase64:l().optional()}),Vke=b({id:l(),text:l(),score:n(),addedAt:n().int(),deviceId:n().int().optional(),base64:l().optional(),mediaId:n().int().optional(),keyFrameMediaId:n().int().optional(),plateBbox:aC.optional()}),bZ=b({plateId:l(),deviceId:n().int(),trackId:l(),timestamp:n().int(),text:l(),score:n(),corrected:v(),recognizedVehicleId:l().optional(),vehicleName:l().optional(),assigned:v(),plateBbox:aC.optional(),keyFrameMediaId:n().int().optional(),base64:l().optional(),cropUrl:l().optional(),cropMissReason:l().optional()}),Hke=b({mediaId:n().int(),kind:l(),url:l(),sizeBytes:n(),timestamp:n()}),Uke=b({plateIds:S(l()).readonly(),representativePlateId:l(),representativeText:l(),size:n().int(),cohesion:n()}),xZ={name:`plate-gallery`,role:{feature:`plate-assignment`},scope:`system`,mode:`singleton`,methods:{listPlates:k(b({deviceId:n().int().optional(),limit:n().int().positive().optional(),includeCrops:v().optional()}).optional(),S(bZ).readonly()),getPlateByTrack:k(b({deviceId:n().int(),trackId:l()}),bZ.nullable(),{role:`viewer`}),getPlateMedia:k(b({plateId:l()}),S(Hke).readonly()),searchPlates:k(b({text:l().min(1),maxDistance:n().int().min(0).optional(),limit:n().int().positive().optional(),includeCrops:v().optional()}),S(bZ).readonly()),suggestPlateClusters:k(b({maxDistance:n().int().min(0).optional(),minClusterSize:n().int().min(2).optional(),limit:n().int().positive().optional()}).optional(),S(Uke).readonly()),correctPlateText:k(b({plateId:l(),text:l().min(1)}),_(),{kind:`mutation`,auth:`admin`}),deletePlate:k(b({plateId:l()}),_(),{kind:`mutation`,auth:`admin`}),listVehicles:k(b({includeCrops:v().optional()}).optional(),S(yZ).readonly()),createVehicle:k(b({name:l().min(1)}),yZ,{kind:`mutation`,auth:`admin`}),renameVehicle:k(b({id:l(),name:l().min(1)}),_(),{kind:`mutation`,auth:`admin`}),deleteVehicle:k(b({id:l()}),_(),{kind:`mutation`,auth:`admin`}),listVehicleSamples:k(b({vehicleId:l()}),S(Vke).readonly()),removeVehicleSample:k(b({vehicleId:l(),sampleId:l()}),_(),{kind:`mutation`,auth:`admin`}),moveVehicleSample:k(b({sampleId:l().min(1),toVehicleId:l().min(1)}),_(),{kind:`mutation`,auth:`admin`}),assignPlate:k(b({plateId:l(),vehicleId:l()}),_(),{kind:`mutation`,auth:`admin`}),unassignPlate:k(b({plateId:l()}),_(),{kind:`mutation`,auth:`admin`}),assignPlates:k(b({plateIds:S(l()).min(1),vehicleId:l()}),b({assigned:n().int(),failed:S(l()).readonly()}),{kind:`mutation`,auth:`admin`}),unassignPlates:k(b({plateIds:S(l()).min(1)}),b({unassigned:n().int(),failed:S(l()).readonly()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`the plate gallery — curated on its own page`}},SZ={"intel-core-ultra":{"intel-npu":{"yolov9t-320":{p50Ms:2.9,fps:383,measured:!0},"yolov9t-320-int8":{p50Ms:3.8,fps:333,measured:!0},"yolov9t-640":{p50Ms:7.4,fps:139,measured:!0},"yolov9t-640-int8":{p50Ms:7.5,fps:144,measured:!0},"yolov9s-320":{p50Ms:4.4,fps:241,measured:!0},"yolov9s-320-int8":{p50Ms:4.1,fps:264,measured:!0},"yolov9s-640":{p50Ms:12.7,fps:82,measured:!0},"yolov9s-640-int8":{p50Ms:10.7,fps:99,measured:!0},"yolov9m-320":{p50Ms:8.4,fps:123,measured:!0},"yolov9m-320-int8":{p50Ms:6.5,fps:165,measured:!0},"yolov9m-640":{p50Ms:29.5,fps:32,measured:!0},"yolov9m-640-int8":{p50Ms:19.5,fps:52,measured:!0}},"intel-igpu":{"yolov9t-320":{p50Ms:2.6,fps:405,measured:!0},"yolov9t-320-int8":{p50Ms:2.8,fps:324,measured:!0},"yolov9t-640":{p50Ms:6.5,fps:157,measured:!0},"yolov9t-640-int8":{p50Ms:5.6,fps:185,measured:!0},"yolov9s-320":{p50Ms:4.6,fps:200,measured:!0},"yolov9s-320-int8":{p50Ms:4.1,fps:239,measured:!0},"yolov9s-640":{p50Ms:15.2,fps:69,measured:!0},"yolov9s-640-int8":{p50Ms:10.5,fps:99,measured:!0},"yolov9m-320":{p50Ms:11.4,fps:88,measured:!0},"yolov9m-320-int8":{p50Ms:7,fps:127,measured:!0},"yolov9m-640":{p50Ms:40,fps:25,measured:!0},"yolov9m-640-int8":{p50Ms:23.5,fps:44,measured:!0}},"x86-cpu":{"yolov9t-320":{p50Ms:6.9,fps:145,measured:!0},"yolov9t-320-int8":{p50Ms:2.7,fps:405,measured:!0},"yolov9t-640":{p50Ms:23,fps:44,measured:!0},"yolov9t-640-int8":{p50Ms:8.8,fps:124,measured:!0},"yolov9s-320":{p50Ms:15.8,fps:63,measured:!0},"yolov9s-320-int8":{p50Ms:6.5,fps:180,measured:!0},"yolov9s-640":{p50Ms:58.2,fps:17,measured:!0},"yolov9s-640-int8":{p50Ms:20.1,fps:52,measured:!0},"yolov9m-320":{p50Ms:40,fps:25,measured:!0},"yolov9m-320-int8":{p50Ms:14.2,fps:74,measured:!0},"yolov9m-640":{p50Ms:155.8,fps:6,measured:!0},"yolov9m-640-int8":{p50Ms:52.4,fps:19,measured:!0}},coral:{"yolov9s-320-edgetpu":{p50Ms:32,fps:31,measured:!1}}},"intel-n-series":{"intel-igpu":{"yolov9t-320":{p50Ms:15,fps:48,measured:!0},"yolov9t-320-int8":{p50Ms:14.1,fps:67,measured:!0},"yolov9t-640":{p50Ms:38.5,fps:26,measured:!0},"yolov9t-640-int8":{p50Ms:50,fps:20,measured:!0},"yolov9s-320":{p50Ms:41.4,fps:24,measured:!0},"yolov9s-320-int8":{p50Ms:23.3,fps:34,measured:!0},"yolov9s-640":{p50Ms:127.4,fps:8,measured:!0},"yolov9s-640-int8":{p50Ms:81,fps:12,measured:!0},"yolov9m-320":{p50Ms:63.5,fps:16,measured:!0},"yolov9m-320-int8":{p50Ms:66,fps:15,measured:!0},"yolov9m-640":{p50Ms:215.5,fps:5,measured:!0},"yolov9m-640-int8":{p50Ms:163,fps:6,measured:!0}},"x86-cpu":{"yolov9t-320":{p50Ms:86.2,fps:12,measured:!0},"yolov9t-320-int8":{p50Ms:52.7,fps:20,measured:!0},"yolov9t-640":{p50Ms:322.1,fps:3,measured:!0},"yolov9t-640-int8":{p50Ms:205.6,fps:5,measured:!0},"yolov9s-320":{p50Ms:164.4,fps:6,measured:!0},"yolov9s-320-int8":{p50Ms:86.9,fps:12,measured:!0},"yolov9s-640":{p50Ms:341.3,fps:3,measured:!0},"yolov9s-640-int8":{p50Ms:185.3,fps:5,measured:!0},"yolov9m-320":{p50Ms:166.8,fps:6,measured:!0},"yolov9m-320-int8":{p50Ms:226.3,fps:4,measured:!0},"yolov9m-640":{p50Ms:663.5,fps:2,measured:!0},"yolov9m-640-int8":{p50Ms:324.4,fps:3,measured:!0}},coral:{"yolov9s-320-edgetpu":{p50Ms:32,fps:31,measured:!1}}},"amd-phoenix":{"x86-cpu":{"yolov9t-320":{p50Ms:24,fps:42,measured:!0},"yolov9t-320-int8":{p50Ms:12,fps:83,measured:!0},"yolov9t-640":{p50Ms:50,fps:20,measured:!0},"yolov9t-640-int8":{p50Ms:20,fps:50,measured:!0},"yolov9s-320":{p50Ms:30,fps:33,measured:!0},"yolov9s-320-int8":{p50Ms:15,fps:67,measured:!0},"yolov9s-640":{p50Ms:92,fps:11,measured:!0},"yolov9s-640-int8":{p50Ms:27,fps:37,measured:!0},"yolov9m-320":{p50Ms:67,fps:15,measured:!0},"yolov9m-320-int8":{p50Ms:21,fps:48,measured:!0},"yolov9m-640":{p50Ms:229,fps:4,measured:!0},"yolov9m-640-int8":{p50Ms:48,fps:21,measured:!0}},"amd-igpu":{"yolov9t-320":{p50Ms:40,fps:25,measured:!0},"yolov9t-640":{p50Ms:89,fps:11,measured:!0},"yolov9s-320":{p50Ms:65,fps:15,measured:!0},"yolov9s-640":{p50Ms:125,fps:8,measured:!0},"yolov9m-320":{p50Ms:85,fps:12,measured:!0},"yolov9m-640":{p50Ms:228,fps:4,measured:!0}},coral:{"yolov9s-320-edgetpu":{p50Ms:32,fps:31,measured:!0}}},"apple-m-pro":{"apple-ane":{"yolov9t-320":{p50Ms:1.1,fps:952,measured:!0},"yolov9t-640":{p50Ms:3,fps:333,measured:!0},"yolov9s-320":{p50Ms:1.5,fps:667,measured:!0},"yolov9s-640":{p50Ms:5.1,fps:196,measured:!0},"yolov9m-320":{p50Ms:3.2,fps:312,measured:!0},"yolov9m-640":{p50Ms:10.2,fps:98,measured:!0}},coral:{"yolov9s-320-edgetpu":{p50Ms:32,fps:31,measured:!1}}},"apple-m-base":{"apple-ane":{"yolov9t-320":{p50Ms:1.32,fps:758,measured:!1},"yolov9t-640":{p50Ms:3.45,fps:290,measured:!0},"yolov9s-320":{p50Ms:1.8,fps:556,measured:!1},"yolov9s-640":{p50Ms:5.46,fps:183,measured:!0},"yolov9m-320":{p50Ms:3.79,fps:264,measured:!0},"yolov9m-640":{p50Ms:10.34,fps:97,measured:!0}},coral:{"yolov9s-320-edgetpu":{p50Ms:32,fps:31,measured:!1}}}},CZ={"yolov9m-320":{personPrecision:.979,personRecall:.649},"yolov9m-320-int8":{personPrecision:.974,personRecall:.684},"yolov9m-640":{personPrecision:.976,personRecall:.854},"yolov9m-640-int8":{personPrecision:.976,personRecall:.847},"yolov9s-320":{personPrecision:.958,personRecall:.479},"yolov9s-320-int8":{personPrecision:.969,personRecall:.438},"yolov9s-640":{personPrecision:.986,personRecall:.753},"yolov9s-640-int8":{personPrecision:.963,personRecall:.823},"yolov9t-320":{personPrecision:.946,personRecall:.368},"yolov9t-320-int8":{personPrecision:.943,personRecall:.347},"yolov9t-640":{personPrecision:.979,personRecall:.646},"yolov9t-640-int8":{personPrecision:.979,personRecall:.646}},wZ=.5,Wke=2,Gke=.05,Kke=24,qke=750,Jke=64,TZ=2e3,Yke=12,EZ=n().nullable().transform(e=>e!==null&&Number.isFinite(e)&&e>0?e:null),DZ=l().nullable().transform(e=>e!==null&&e.trim()!==``?e:null),OZ=b({int8:EZ,fp16:EZ}),kZ=b({deviceKey:l(),fullDeviceName:DZ,executionUnits:EZ,clockMHz:EZ,gops:OZ.nullable(),architecture:DZ,npuName:DZ,tops:EZ,vendor:DZ,webgpuArchitecture:DZ,webgpuDevice:DZ,computeUnits:EZ}),Xke=b({accelerators:S(kZ).nullable()}),AZ=[{hardwareClass:`intel-n-series`,accelerator:`intel-igpu`,score:{metric:`eu-mhz`,value:24*750}},{hardwareClass:`intel-core-ultra`,accelerator:`intel-igpu`,score:{metric:`eu-mhz`,value:64*TZ}},{hardwareClass:`amd-phoenix`,accelerator:`amd-igpu`,score:{metric:`cu`,value:12}}];function Zke(e){let t=Xke.safeParse(e);return!t.success||t.data.accelerators===null?null:t.data.accelerators}function jZ(e){return e!==null&&e>0?e:null}function MZ(e){let t=[],n=jZ(e.gops?.int8??null);n!==null&&t.push({metric:`gops-int8`,value:n});let r=jZ(e.gops?.fp16??null);r!==null&&t.push({metric:`gops-fp16`,value:r});let i=jZ(e.executionUnits),a=jZ(e.clockMHz);i!==null&&a!==null&&t.push({metric:`eu-mhz`,value:i*a});let o=jZ(e.computeUnits);o!==null&&t.push({metric:`cu`,value:o});let s=jZ(e.tops);return s!==null&&t.push({metric:`tops`,value:s}),t}function NZ(e,t,n){let r=n.filter(n=>n.accelerator===e&&n.score.metric===t.metric&&n.score.value>0),i=r[0];return i===void 0?null:r.reduce((e,n)=>Math.abs(Math.log(t.value/n.score.value))<Math.abs(Math.log(t.value/e.score.value))?n:e,i)}function PZ(e,t,n){for(let r of MZ(e))if(NZ(t,r,n)!==null)return r;return null}function FZ(e,t,n=AZ){return PZ(e,t,n)!==null}function IZ(e,t,n){if(t!==`unknown`)return e[t]?.[n]}function Qke(e){return Math.round(e*10)/10}function $ke(e){return Math.min(2,Math.max(wZ,e))}function eAe(e,t,n){let r={};for(let[i,a]of Object.entries(e))r[i]={p50Ms:Qke(a.p50Ms/t),fps:Math.max(1,Math.round(a.fps*t)),measured:!1,estimatedFrom:n};return r}function LZ(e){let t=e.perf??SZ,n=e.references??AZ,r=IZ(t,e.hardwareClass,e.accelerator);if(r!==void 0&&e.hardwareClass!==`intel-n-series`)return{column:r,estimatedFrom:null};let i=e.report===null?null:PZ(e.report,e.accelerator,n);if(i===null)return r===void 0?null:{column:r,estimatedFrom:null};let a=NZ(e.accelerator,i,n),o=a===null?void 0:IZ(t,a.hardwareClass,e.accelerator);if(a===null||o===void 0)return r===void 0?null:{column:r,estimatedFrom:null};let s=i.value/a.score.value;return e.hardwareClass===a.hardwareClass&&Math.abs(s-1)<=.05?{column:o,estimatedFrom:null}:{column:eAe(o,$ke(s),a.hardwareClass),estimatedFrom:a.hardwareClass}}var RZ=x(Pa),tAe=x([`videotoolbox`,`cuda`,`nvdec`,`vaapi`,`qsv`,`d3d11va`,`dxva2`,`amf`,`vdpau`,`drm`,`coreml`,`tensorrt`,`openvino`,`directml`,`webgpu`,`none`]).nullable().optional(),nAe=b({preferred:S(l()).readonly(),rationale:l()}),zZ=x([`h264_videotoolbox`,`hevc_videotoolbox`,`h264_vaapi`,`hevc_vaapi`,`h264_nvenc`,`hevc_nvenc`,`h264_qsv`,`hevc_qsv`,`h264_amf`,`hevc_amf`,`libx264`,`libx265`]);b({encoders:S(b({encoder:zZ,codec:x([`H264`,`H265`]),family:x([`videotoolbox`,`vaapi`,`nvenc`,`qsv`,`amf`,`software`]),available:v(),reason:l().optional()})).readonly(),defaultH264:zZ,defaultH265:zZ,probedAt:n()}),b({methods:S(l()).readonly(),probedAt:n()});var rAe=x([`darwin`,`linux`,`win32`]),iAe=x([`arm64`,`x64`]),aAe=b({type:x([`nvidia`,`amd`,`intel`,`apple`]),name:l(),memoryMB:n().optional()}),oAe=b({type:x([`apple-ane`,`intel-npu`,`amd-xdna`]),name:l().optional(),generation:x([`xdna1`,`xdna2`]).optional()}),BZ=x([`usb`,`pci`]),sAe=b({type:p(`coral-edgetpu`),bus:l().optional(),count:n().int().nonnegative().optional(),units:S(b({bus:BZ,count:n().int().nonnegative()})).readonly().optional(),unavailable:S(b({bus:BZ,count:n().int().nonnegative(),reason:x([`driver-missing`,`device-not-accessible`])})).readonly().optional()}),VZ=b({type:p(`nvidia`),name:l(),memoryMB:n().optional()}),cAe=i(`usable`,[VZ.extend({usable:p(!0)}),VZ.extend({usable:p(!1),reason:x([`no-cuda-execution-provider`])})]),HZ=b({platform:rAe,arch:iAe,cpuModel:l(),cpuCores:n(),totalRAM_MB:n(),availableRAM_MB:n(),gpu:aAe.nullable(),npu:oAe.nullable(),coral:sAe.nullable().optional(),nvidia:cAe.nullable().optional(),accelerators:S(kZ).readonly().optional()}),UZ=b({runtime:p(`python`),backend:l(),format:x([`onnx`,`coreml`,`openvino`,`tflite`]),score:n(),reason:l(),available:v()}),WZ=b({key:l(),backend:l(),device:l(),format:RZ,runtime:p(`python`),score:n(),available:v()}),lAe=b({hardware:HZ,scores:S(UZ).readonly(),bestScore:UZ,pythonPath:l().nullable(),devices:S(WZ).readonly()}),uAe=b({modelId:l(),name:l(),minRAM_MB:n(),accuracyScore:n(),formats:S(l()).readonly()}),dAe=b({modelId:l(),runtime:p(`python`),backend:l(),format:RZ,reason:l()}),fAe=b({devices:S(WZ).readonly(),appeared:S(l()).readonly(),disappeared:S(l()).readonly(),usbBus:x([`observed`,`unobservable`]),decidedBy:x([`usb-ids`,`pci`,`delegate-fallback`,`none`])}),GZ={name:`platform-probe`,scope:`system`,mode:`singleton`,methods:{getCapabilities:k(_(),lAe),getHardware:k(_(),HZ),resolveInferenceConfig:k(b({requirements:S(uAe).readonly()}),dAe),resolveHwAccel:k(b({prefer:tAe}),nAe),rescanAccelerators:k(_(),fAe,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:j.CLUSTER}},KZ=b({power:n().optional().meta(M(`power`,{label:`Power`})),deliveredPower:n().optional().meta(M(`power`,{label:`Delivered`})),energy:n().optional().meta(M(`energy`,{label:`Energy`})),voltage:n().optional().meta(M(`voltage`,{label:`Voltage`})),current:n().optional().meta(M(`current`,{label:`Current`})),apparentPower:n().optional().meta(M(`apparent-power`)),powerFactor:n().min(0).max(1).optional().meta(M(`ratio`)),lastFetchedAt:n()});function pAe(e){if(e.power===void 0)return;let t=e.power-(e.deliveredPower??0);return t<0?void 0:t}var qZ=[T.Sensor,T.Switch,T.Light,T.Fan,T.Climate,T.Humidifier,T.WaterHeater,T.MediaPlayer,T.Washer,T.Dryer,T.Dishwasher,T.Vacuum,T.LawnMower,T.PetFeeder,T.Workload],mAe=qZ.filter(e=>e!==T.Sensor);function JZ(e,t){return{id:e,cardinality:`scalar`,vocabulary:{cap:`power-meter`,stateField:e},deviceTypes:mAe,apply:`add`,path:e,sources:[{kind:`numeric`,requiredUnit:t,transforms:[{kind:`identity`}]}],companions:[{kind:`clock`,path:`lastFetchedAt`,when:`always`}],sourceReport:{status:`assignment-status`},advancedExpression:!0}}var hAe={version:1,targets:[JZ(`power`,`W`),JZ(`energy`,`kWh`),JZ(`voltage`,`V`),JZ(`current`,`A`)]},YZ={name:`power-meter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:qZ,deviceConfig:{ui:{kind:`widget`,widgetId:`host/power-meter-line`,tab:`power`,placement:`hero`,label:`Power`,order:4}},methods:{},status:{schema:KZ,kind:`push`},runtimeState:KZ,durability:`restored`,history:{primary:`power`,priority:80,fields:{power:{kind:`gauge`,unit:`W`,deadband:1,minIntervalMs:3e4},energy:{kind:`counter`,unit:`kWh`,deadband:.01,minIntervalMs:6e4},voltage:{kind:`gauge`,unit:`V`,deadband:1,minIntervalMs:3e4},current:{kind:`gauge`,unit:`A`,deadband:.05,minIntervalMs:3e4},apparentPower:{kind:`gauge`,unit:`VA`,deadband:1,minIntervalMs:3e4},powerFactor:{kind:`gauge`,unit:`ratio`,deadband:.01,minIntervalMs:6e4}}},volatileStateFields:[`lastFetchedAt`],customize:hAe,vocabulary:{noun:P(`Power meter`,`Misuratore di energia`),order:5160,state:[{kind:`numeric`,field:`power`,quantity:P(`the power draw`,`il consumo`),label:P(`Power`,`Potenza`),unit:`W`,icon:`zap`},{kind:`numeric`,field:`energy`,quantity:P(`the energy used`,`l’energia consumata`),label:P(`Energy`,`Energia`),unit:`kWh`,icon:`zap`},{kind:`numeric`,field:`voltage`,quantity:P(`the voltage`,`la tensione`),label:P(`Voltage`,`Tensione`),unit:`V`,icon:`zap`},{kind:`numeric`,field:`current`,quantity:P(`the current`,`la corrente`),label:P(`Current`,`Corrente`),unit:`A`,icon:`zap`}]}},gAe=b({latitude:n().min(-90).max(90).meta(M(`angle`)),longitude:n().min(-180).max(180).meta(M(`angle`)),accuracyMeters:n().nonnegative().meta(M(`length`))}),XZ=b({state:l(),location:l().nullable(),gps:gAe.nullable(),lastChangedAt:n()}),ZZ={name:`presence`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Presence],methods:{},status:{schema:XZ,kind:`push`},runtimeState:XZ,durability:`restored`,history:`none`,volatileStateFields:[`lastChangedAt`],vocabulary:{noun:P(`Presence`,`Presenza`),order:5170,state:[{kind:`value`,field:`state`,label:P(`Where`,`Posizione`),phrase:P(`When {device} is at {value}`,`Quando {device} è in {value}`),icon:`map-pin`}]}},QZ=b({pressure:n().nullable().meta(M(`pressure`,{precision:0})),lastFetchedAt:n()}),$Z={name:`pressure-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Sensor],methods:{},status:{schema:QZ,kind:`push`},runtimeState:QZ,durability:`restored`,history:{fields:{pressure:{kind:`gauge`,unit:`hPa`,deadband:.1}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:P(`Pressure`,`Pressione`),order:5180,state:[{kind:`numeric`,field:`pressure`,quantity:P(`the pressure`,`la pressione`),label:P(`Pressure`,`Pressione`),unit:`hPa`,icon:`gauge`}]}},eQ=i(`kind`,[eH,tH]),tQ=b({id:n(),enabled:v(),shape:eQ}),nQ=b({enabled:v(),regions:S(tQ).nullable(),audioEnabled:v().nullable(),lastFetchedAt:n()}),rQ=b({maxRegions:n(),supportedShapes:S(iH),polygonVertices:aH.optional(),supportsAudioMute:v()}),iQ=b({enabled:v().optional(),regions:S(tQ).optional()}),aQ={name:`privacy-mask`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/privacy-mask-grid`,tab:`image`,label:`Privacy Mask`}},methods:{getOptions:k(b({deviceId:n()}),rQ),setMask:k(b({deviceId:n(),patch:iQ}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`privacy.maskOn`,label:P(`Privacy mask on`,`Maschera privacy attiva`),phrase:P(`Cover the privacy zones of {device}`,`Oscura le zone private di {device}`),icon:`eye-off`,args:{patch:{enabled:!0}}},{id:`privacy.maskOff`,label:P(`Privacy mask off`,`Maschera privacy spenta`),phrase:P(`Uncover the privacy zones of {device}`,`Scopri le zone private di {device}`),icon:`eye`,args:{patch:{enabled:!1}}}]}),setAudioEnabled:k(b({deviceId:n(),enabled:v()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`privacy.micOn`,label:P(`Microphone on`,`Microfono attivo`),phrase:P(`Turn on the microphone of {device}`,`Attiva il microfono di {device}`),icon:`mic`,args:{enabled:!0}},{id:`privacy.micOff`,label:P(`Microphone off`,`Microfono spento`),phrase:P(`Turn off the microphone of {device}`,`Disattiva il microfono di {device}`),icon:`mic-off`,args:{enabled:!1}}]})},status:{schema:nQ,kind:`poll`},runtimeState:nQ,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:P(`Privacy`,`Privacy`),order:3210,state:[{kind:`boolean`,field:`enabled`,label:P(`Privacy mask`,`Maschera privacy`),whenTrue:P(`When the privacy mask of {device} is turned on`,`Quando si attiva la maschera privacy di {device}`),whenFalse:P(`When the privacy mask of {device} is turned off`,`Quando si disattiva la maschera privacy di {device}`),icon:`eye-off`},{kind:`boolean`,field:`audioEnabled`,label:P(`Microphone`,`Microfono`),whenTrue:P(`When the microphone of {device} is turned on`,`Quando si attiva il microfono di {device}`),whenFalse:P(`When the microphone of {device} is turned off`,`Quando si disattiva il microfono di {device}`),icon:`mic`}]}};function _Ae(e){return e.length===0?null:e.some(e=>e.audioEnabled)}var oQ=x([`home`,`day-mode`,`night-mode`,`day-night-auto`,`set-limits`,`save-limits`,`reboot`,`osd-menu`]),sQ=b({id:l(),name:l(),fn:oQ.nullable(),writable:v()}),cQ=b({pan:n().nullable(),tilt:n().nullable(),zoom:n().nullable()}),lQ=b({pan:n().optional(),tilt:n().optional(),zoom:n().optional(),speed:n().optional()}),uQ=cQ.extend({autofocus:v()}),dQ=b({hasPan:v(),hasTilt:v(),hasZoom:v(),supportsPresets:v(),maxPresets:n().optional(),hasAutofocus:v(),speedSteps:n().int().positive().nullable(),moveImpulseMs:n().int().positive().nullable()}),fQ=b({presetId:l().nullable(),source:x([`operator`,`firmware`,`native`,`none`])}),pQ=b({enabled:v(),seconds:n().int()}),mQ={name:`ptz`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/ptz-panel`,tab:`ptz`,topTab:!0,label:`PTZ`,order:0}},methods:{move:k(lQ.extend({deviceId:n()}),_(),{kind:`mutation`,notOperatorFacing:`a relative nudge from the live-view joystick; a fixed place is a preset`}),continuousMove:k(lQ.extend({deviceId:n()}),_(),{kind:`mutation`,notOperatorFacing:`joystick motion held until released — continuous, not a discrete step`}),goHome:k(b({deviceId:n()}),_(),{kind:`mutation`,actions:[{id:`ptz.goHome`,label:P(`PTZ go home`,`Torna alla posizione iniziale`),phrase:P(`Send {device} to its home position`,`Riporta {device} alla posizione iniziale`),icon:`house`}]}),getPresets:k(b({deviceId:n()}),S(sQ)),goToPreset:k(b({deviceId:n(),presetId:l()}),_(),{kind:`mutation`,actions:[{id:`ptz.goToPreset`,label:P(`PTZ go to preset`,`Vai a un preset`),phrase:P(`Move {device} to {presetId}`,`Sposta {device} su {presetId}`),icon:`move`,openArgs:[{key:`presetId`,label:P(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}}]}]}),savePreset:k(b({deviceId:n(),presetId:l(),name:l()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.savePreset`,label:P(`Save PTZ preset here`,`Salva qui un preset`),phrase:P(`Save where {device} points now as preset {presetId} ({name})`,`Salva la posizione attuale di {device} come preset {presetId} ({name})`),icon:`bookmark-plus`,openArgs:[{key:`presetId`,label:P(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}},{key:`name`,label:P(`Name`,`Nome`),offer:{kind:`text`}}]}]}),deletePreset:k(b({deviceId:n(),presetId:l()}),_(),{kind:`mutation`,auth:`admin`}),getOptions:k(b({deviceId:n()}),dQ),stop:k(b({deviceId:n()}),_(),{kind:`mutation`,actions:[{id:`ptz.stop`,label:P(`Stop moving`,`Ferma il movimento`),phrase:P(`Stop {device} moving`,`Ferma il movimento di {device}`),icon:`square`}]}),getHomePreset:k(b({deviceId:n()}),fQ),setHomePreset:k(b({deviceId:n(),presetId:l().nullable()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.setHomePreset`,label:P(`Set PTZ home preset`,`Imposta il preset iniziale`),phrase:P(`Make {presetId} the home position of {device}`,`Rendi {presetId} la posizione iniziale di {device}`),icon:`house`,openArgs:[{key:`presetId`,label:P(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}}]}]}),captureHomeHere:k(b({deviceId:n()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.captureHomeHere`,label:P(`Set PTZ home here`,`Imposta qui la posizione iniziale`),phrase:P(`Make where {device} points now its home position`,`Rendi la posizione attuale di {device} la sua posizione iniziale`),icon:`map-pin`}]}),getHomeReturn:k(b({deviceId:n()}),pQ.nullable()),setHomeReturn:k(b({deviceId:n(),enabled:v(),seconds:n().int().min(0).max(3600)}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.setHomeReturn`,label:P(`Set PTZ return home`,`Imposta il ritorno alla posizione iniziale`),phrase:P(`Set {device} to return home when idle ({enabled}) after {seconds} s`,`Imposta {device} per tornare alla posizione iniziale da fermo ({enabled}) dopo {seconds} s`),icon:`undo-2`,openArgs:[{key:`enabled`,label:P(`Return home`,`Torna alla posizione iniziale`),offer:{kind:`boolean`}},{key:`seconds`,label:P(`Idle seconds`,`Secondi da fermo`),offer:{kind:`number`,min:0,max:3600,step:1,unit:`s`}}]}]}),getPosition:k(b({deviceId:n()}),cQ),setAutofocus:k(b({deviceId:n(),enabled:v()}),_(),{kind:`mutation`,actions:[{id:`ptz.autofocusOn`,label:P(`Autofocus on`,`Autofocus attivo`),phrase:P(`Turn on autofocus on {device}`,`Attiva l’autofocus su {device}`),icon:`focus`,args:{enabled:!0}},{id:`ptz.autofocusOff`,label:P(`Autofocus off`,`Autofocus spento`),phrase:P(`Turn off autofocus on {device}`,`Disattiva l’autofocus su {device}`),icon:`focus`,args:{enabled:!1}}]})},status:{schema:uQ,kind:`command-driven`},vocabulary:{noun:P(`Pan / tilt / zoom`,`Brandeggio`),order:3220}},hQ=b({targetType:l().describe(`Vendor target string (people/vehicle/pet); empty = camera default`),stopDelaySeconds:n().int().min(0).max(300).meta(M(`duration`)),disappearDelaySeconds:n().int().min(0).max(300).meta(M(`duration`))}),gQ=b({value:l(),label:l()}),_Q=b({enabled:v(),lastChangedAt:n(),currentSettings:hQ.nullable(),supportedTargetTypes:S(gQ)}),vQ=_Q.extend({lastFetchedAt:n()}),yQ={name:`ptz-autotrack`,scope:`device`,deviceNative:!0,mode:`singleton`,kind:`wrapper`,defaultActive:!1,deviceTypes:[T.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/ptz-autotrack`,tab:`ptz`,topTab:!0,label:`Auto-Tracking`,order:5}},methods:{getStatus:k(b({deviceId:n()}),_Q),setEnabled:k(b({deviceId:n(),enabled:v()}),_(),{kind:`mutation`,actions:[{id:`ptz.autotrackOn`,label:P(`Autotrack on`,`Inseguimento attivo`),phrase:P(`Start autotracking on {device}`,`Attiva l’inseguimento automatico su {device}`),icon:`crosshair`,args:{enabled:!0}},{id:`ptz.autotrackOff`,label:P(`Autotrack off`,`Inseguimento spento`),phrase:P(`Stop autotracking on {device}`,`Disattiva l’inseguimento automatico su {device}`),icon:`crosshair`,args:{enabled:!1}}]}),getSettings:k(b({deviceId:n()}),hQ.nullable()),setSettings:k(b({deviceId:n(),settings:hQ.partial()}),_(),{role:`admin`,kind:`mutation`,notOperatorFacing:`tracking tuning (target type, delays) — set once on the camera’s PTZ page`})},events:{onStatusChanged:{data:b({deviceId:n(),status:_Q}),notOperatorFacing:"the `enabled` state trigger phrases both edges of this change"}},status:{schema:_Q,kind:`command-driven`},runtimeState:vQ,durability:`session`,history:`none`,vocabulary:{noun:P(`Autotracking`,`Inseguimento automatico`),order:3230,state:[{kind:`boolean`,field:`enabled`,label:P(`Autotracking`,`Inseguimento automatico`),whenTrue:P(`When autotracking is turned on for {device}`,`Quando si attiva l’inseguimento automatico di {device}`),whenFalse:P(`When autotracking is turned off for {device}`,`Quando si disattiva l’inseguimento automatico di {device}`),icon:`crosshair`}]}},bQ=b({enabled:v().nullable(),onTime:n().min(0).nullable().meta(M(`duration`)),offTime:n().min(0).nullable().meta(M(`duration`)),lastFetchedAt:n()}),xQ=n().int().nonnegative(),SQ=n().int().min(0),CQ={name:`pump-cycle`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.PetFountain],methods:{setEnabled:k(b({deviceId:xQ,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.on`,effect:{field:`enabled`,value:!0},label:P(`Pump cycle on`,`Ciclo pompa attivo`),phrase:P(`Run the pump of {device} on its on/off cycle`,`Fai lavorare la pompa di {device} a ciclo acceso/spento`),icon:`timer`,args:{on:!0}},{id:`pumpCycle.off`,effect:{field:`enabled`,value:!1},label:P(`Pump cycle off`,`Ciclo pompa spento`),phrase:P(`Run the pump of {device} continuously`,`Fai lavorare la pompa di {device} in continuo`),icon:`timer-off`,args:{on:!1}}]}),setOnMinutes:k(b({deviceId:xQ,minutes:SQ}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.onMinutes`,label:P(`Set pump run time`,`Imposta il tempo di lavoro della pompa`),phrase:P(`Set the pump of {device} to run {minutes} minutes per cycle`,`Imposta la pompa di {device} a lavorare {minutes} minuti per ciclo`),icon:`timer`,effect:{field:`onTime`,fromArg:`minutes`,scale:60},openArgs:[{key:`minutes`,label:P(`Minutes`,`Minuti`),offer:{kind:`number`,min:0,step:1,unit:`min`}}]}]}),setOffMinutes:k(b({deviceId:xQ,minutes:SQ}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.offMinutes`,label:P(`Set pump rest time`,`Imposta il tempo di riposo della pompa`),phrase:P(`Set the pump of {device} to rest {minutes} minutes per cycle`,`Imposta la pompa di {device} a riposare {minutes} minuti per ciclo`),icon:`timer-off`,effect:{field:`offTime`,fromArg:`minutes`,scale:60},openArgs:[{key:`minutes`,label:P(`Minutes`,`Minuti`),offer:{kind:`number`,min:0,step:1,unit:`min`}}]}]})},status:{schema:bQ,kind:`push`},runtimeState:bQ,durability:`session`,history:`none`,vocabulary:{noun:P(`Pump cycle`,`Ciclo della pompa`),order:2050,state:[{kind:`boolean`,field:`enabled`,label:P(`Pump cycle`,`Ciclo pompa`),whenTrue:P(`When {device} starts running its pump on a cycle`,`Quando {device} inizia a far lavorare la pompa a ciclo`),whenFalse:P(`When {device} runs its pump continuously`,`Quando {device} fa lavorare la pompa in continuo`),icon:`timer`}]}},wQ={name:`reboot`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Camera,T.Sensor,T.Switch,T.Gateway],methods:{reboot:k(b({deviceId:n().int().nonnegative()}),b({success:p(!0)}),{kind:`mutation`,auth:`admin`,actions:[{id:`reboot.reboot`,label:P(`Reboot device`,`Riavvia il dispositivo`),phrase:P(`Reboot {device}`,`Riavvia {device}`),icon:`refresh-cw`}]})},vocabulary:{noun:P(`Reboot`,`Riavvio`),order:3240}},TQ=b({owner:l(),kind:gi,title:l(),nameField:l(),fields:m(l(),C()),secretPaths:S(l()),rows:n().int().nonnegative()}),EQ=b({id:oV,name:l(),rev:n().int(),updatedAt:n(),data:sV}),DQ={owner:l().min(1),kind:gi},OQ={name:`record-entries`,scope:`system`,mode:`singleton`,methods:{listEntryKinds:k(b({}),b({kinds:S(TQ)}),{auth:`admin`}),listEntries:k(b({...DQ}),b({entries:S(EQ)}),{auth:`admin`}),putEntry:k(b({...DQ,id:oV.optional(),data:sV,ifRev:n().int().min(1).optional()}),b({id:l(),rev:n().int()}),{kind:`mutation`,auth:`admin`}),deleteEntry:k(b({...DQ,id:oV}),b({deleted:v()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:j.INTERNAL}},vAe=`camstack`,yAe=`recorder`,kQ=b({profile:l(),startMs:n(),endMs:n()}),AQ=x([`read`,`unreadable`]),jQ=b({deviceId:n(),read:AQ,ranges:S(kQ),profilesWithFootage:S(l())}),MQ=b({deviceId:n(),read:AQ,days:S(n())}),NQ=b({deviceId:n(),localMasterPath:l().nullable(),playbackUrl:l().nullable(),playbackEndpoints:S(l())}),PQ=b({state:x([`ok`,`sleeping`,`unreachable`,`no-storage`,`index-empty`]),reason:l().optional(),coverageAsOf:n().optional()}),FQ=b({source:l(),label:l(),addonId:l().optional(),availability:PQ}),IQ=b({transport:x([`archive`,`stream`,`realtime`]),coverage:x([`continuous`,`sparse`]),seek:x([`free`,`forward`,`segment`]),stepBack:v(),scrub:v(),rates:S(n().positive()).min(1).readonly(),exclusive:v()}),LQ=i(`kind`,[b({kind:p(`hls`),manifest:NQ}),b({kind:p(`clip`),source:l(),clipId:l(),startsAtMs:n()}),b({kind:p(`none`),reason:l()})]),RQ={name:`recording`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:[T.Camera],methods:{listSources:k(b({deviceId:n()}),S(FQ).readonly(),{kind:`query`,auth:`protected`}),getAvailability:k(b({deviceId:n(),provider:l().min(1),fromMs:n(),toMs:n(),profile:l().optional()}),jQ,{kind:`query`,auth:`protected`}),getDaysWithRecordings:k(b({deviceId:n(),provider:l().min(1),fromMs:n(),toMs:n(),tzOffsetMinutes:n()}),MQ,{kind:`query`,auth:`protected`}),getPlayback:k(b({deviceId:n(),provider:l().min(1),fromMs:n(),toMs:n(),profile:N.optional()}),LQ,{kind:`query`,auth:`protected`}),getPlaybackOptions:k(b({deviceId:n(),provider:l().min(1)}),IQ,{kind:`query`,auth:`protected`})},vocabulary:{noun:P(`Recording`,`Registrazione`),order:3250}},zQ=b({deviceId:n(),enabled:v(),activeMode:om,nodeId:l(),storageBytes:n()}),bAe=200,BQ=b({deviceId:n(),read:x([`read`,`unreadable`]),ranges:S(kQ).readonly(),profilesWithFootage:S(l()).readonly()}),VQ=b({deviceId:n(),read:x([`read`,`unreadable`]),days:S(n()).readonly()}),HQ=b({deviceId:n(),usedBytes:n(),oldestMs:n().nullable().optional(),segments:n().optional(),residentBytes:n().optional(),residentOldestMs:n().nullable().optional()}),UQ=b({locationId:l().nullable(),locationIds:S(l()).optional(),root:l().optional(),usedBytes:n(),availableBytes:n().nullable(),totalBytes:n().nullable()}),WQ=b({nodeId:l(),totalUsedBytes:n(),devices:S(HQ),devicesRead:x([`archive`,`unavailable`]).optional(),complete:v().optional(),locations:S(UQ).optional()}),GQ=b({deviceId:n(),profile:l(),fromLocationId:l(),toLocationId:l(),bytes:n(),files:n().int()}),KQ=x([`unassigned`,`target-not-writable`,`below-threshold`,`no-headroom`]),qQ=b({deviceId:n(),profile:l(),fromLocationId:l(),toLocationId:l().nullable(),bytes:n(),reason:KQ}),JQ=b({moves:S(GQ),skipped:S(qQ),bytesToMove:n(),jobIds:S(l())}),YQ=b({throttleMbps:n().min(1).max(1e3).optional(),minMoveGb:n().min(0).optional()}),xAe=b({deviceId:n().int(),profile:l(),locationId:l()}),SAe=b({deviceId:n().int(),locationId:l()}),CAe=b({assignments:S(xAe),pins:S(SAe),defaultLocations:m(l(),l())}),wAe=b({deviceId:n().int(),locationId:l().nullable()}),XQ=i(`kind`,[b({kind:p(`segment`),startMs:n(),durMs:n(),bytes:n()}),b({kind:p(`gap`),nearestEdgeMs:n().nullable(),prevEndMs:n().nullable().optional()})]),ZQ=b({data:y(Uint8Array)}),QQ=b({data:y(Uint8Array),gopStartMs:n(),gopDurMs:n()}),$Q=i(`kind`,[b({kind:p(`ok`),data:y(Uint8Array),gopStartMs:n(),gopDurMs:n(),reachesRequestedEnd:v()}),b({kind:p(`spans-multiple-segments`),segmentEndMs:n()})]),e$={name:`recording-archive`,scope:`system`,mode:`singleton`,exposesDeviceSettings:!0,status:{schema:zQ,kind:`command-driven`},methods:{getAvailabilityBatch:k(b({deviceIds:S(n()).min(1).max(200),fromMs:n(),toMs:n()}),S(BQ).readonly(),{role:`viewer`,kind:`query`,auth:`protected`}),getDaysWithRecordingsBatch:k(b({deviceIds:S(n()).min(1).max(200),fromMs:n(),toMs:n(),tzOffsetMinutes:n()}),S(VQ).readonly(),{role:`viewer`,kind:`query`,auth:`protected`}),getStorageUsage:k(b({}),WQ,{kind:`query`,auth:`admin`}),getDeviceConfig:k(b({deviceId:n()}),gm,{role:`viewer`,kind:`query`,auth:`protected`}),locateSegment:k(b({deviceId:n(),profile:l(),epochMs:n()}),XQ,{kind:`query`,auth:`admin`}),readSegmentBytes:k(b({deviceId:n(),profile:l(),startMs:n()}),ZQ,{kind:`query`,auth:`admin`}),readGopBytes:k(b({deviceId:n(),profile:l(),startMs:n(),epochMs:n()}),QQ,{kind:`query`,auth:`admin`}),readWindowBytes:k(b({deviceId:n(),profile:l(),startMs:n(),fromMs:n(),toMs:n()}),$Q,{kind:`query`,auth:`admin`}),setDeviceConfig:k(b({deviceId:n(),config:gm}),gm,{kind:`mutation`,auth:`admin`}),rescanStorage:k(b({deviceId:n()}),zQ,{kind:`mutation`,auth:`admin`}),pruneFootage:k(b({deviceId:n(),reason:Xp.optional()}),b({floorMs:n().nullable(),deletedBuckets:n().int(),reclaimedBytes:n().int()}),{kind:`mutation`,auth:`admin`}),deleteFootprint:k(b({deviceId:n(),fromMs:n().optional(),toMs:n().optional()}),b({deletedBuckets:n().int(),reclaimedBytes:n().int()}),{kind:`mutation`,auth:`admin`}),listOpsLog:k(Qp,S(Zp).readonly(),{kind:`query`,auth:`admin`}),renderGif:k(b({deviceId:n(),aroundMs:n(),preRollSec:n().min(0).max(30).default(2),postRollSec:n().min(0).max(30).default(5),maxWidth:n().int().min(120).max(1280).default(480),fps:n().int().min(1).max(15).default(5)}),b({gifBase64:l(),fromMs:n(),toMs:n()}),{kind:`mutation`,auth:`admin`}),renderClip:k(b({deviceId:n(),aroundMs:n(),preRollSec:n().min(0).max(30).default(3),postRollSec:n().min(0).max(30).default(7),maxWidth:n().int().min(160).max(1920).default(640)}),b({clipBase64:l(),mime:l(),fromMs:n(),toMs:n(),bytes:n().int()}),{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:k(wm,b({paused:p(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:k(wm,b({resumed:p(!0)}),{kind:`mutation`,auth:`admin`}),refreshStorageLocationsForMigration:k(wm,b({refreshed:p(!0)}),{kind:`mutation`,auth:`admin`}),startStorageMigrationMove:k(Tm,b({jobId:l()}),{kind:`mutation`,auth:`admin`}),getStorageMigrationMoveStatus:k(b({jobId:l()}),xm.nullable(),{auth:`admin`}),cancelStorageMigrationMove:k(b({jobId:l()}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`}),relocateFootage:k(Cm,b({jobId:l()}),{kind:`mutation`,auth:`admin`}),listRelocateJobs:k(b({}),S(xm).readonly(),{kind:`query`,auth:`admin`}),getRelocateResidue:k(Zm,Qm,{kind:`query`,auth:`admin`}),reconcileLedgerAgainstDisk:k($m,rh,{kind:`mutation`,auth:`admin`}),cancelRelocateJob:k(b({jobId:l()}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`}),planStorageRebalance:k(YQ,JQ,{kind:`query`,auth:`admin`}),startStorageRebalance:k(YQ,JQ,{kind:`mutation`,auth:`admin`}),getPlacement:k(b({}),CAe,{kind:`query`,auth:`admin`}),setDevicePlacement:k(wAe,b({ok:p(!0)}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:j.STORAGE}},TAe=24,EAe=3,DAe=x([`queue-full`,`camera-backoff`,`sleeping`,`camera-refused`,`no-keyframe`,`decode-failed`,`no-catalog-row`,`unsupported`,`unknown-device`,`uid-missing`]),OAe=x([`deferred`,`final`]),kAe=`x-camstack-reason`,AAe=500;function jAe(e){let t=e.replace(/[\u2013\u2014\u2212]/g,`-`).replace(/[\u2018\u2019\u201b]/g,`'`).replace(/[\u201c\u201d]/g,`"`).replace(/\u2026/g,`...`).replace(/[\u00a0\u2007\u202f]/g,` `),n=``;for(let e of t){let t=e.codePointAt(0)??0;t<32||t===127?n+=` `:t>255?n+=`?`:n+=e}return n.slice(0,500).trim()}var MAe=`x-camstack-reason-code`,NAe=`x-camstack-disposition`,PAe=`x-camstack-clip-transport`,t$=b({id:l(),source:l(),kind:x([`motion`,`object`,`audio`,`native`]),timeRange:b({startMs:n(),endMs:n()}),labels:S(l()).max(3).optional(),thumbnail:l().optional(),stillAtMs:n().optional(),eventIds:S(l()).optional(),eventCount:n().int().nonnegative().optional(),holes:S(b({startMs:n(),endMs:n()})).optional(),thumbnailMint:l().optional(),thumbnailUnavailable:b({reason:x([`sleeping`,`camera-refused`,`no-keyframe`,`unsupported`])}).optional(),catalogAsOf:n().optional(),nativeTypes:S(l()).optional(),behaviours:S(l()).optional(),streams:b({sub:b({id:l(),bytes:n().optional()}).optional(),main:b({id:l(),bytes:n().optional()}).optional()}).optional(),supportSub:v().optional(),playable:v().optional(),unplayableReason:l().optional(),inProgress:v().optional()}),n$=b({playbackUrl:l(),format:x([`hls`,`mp4`]).optional(),served:N.optional(),playbackEndpoints:S(l()).optional(),token:l().optional()}),r$=x([`authorised`]),FAe=50*1024*1024,IAe=500*1024*1024,i$=b({base64:l(),contentType:l(),name:l(),bytes:n().int().nonnegative(),served:N,durationMs:n().positive().optional()}),a$=b({ticket:Ti,contentType:l(),name:l(),served:N,durationMs:n().positive().optional()}),o$=x([`opus`,`pcmu`,`none`]),s$=x([`not-requested`,`unsupported-ask`]),c$=b({url:l().min(1),expiresAtMs:n(),transport:p(`forward-only`),served:N,servedAudio:o$,audioReason:s$.optional()}),l$=[.25,.5,1,1.5,2,4,8],u$=[.25,.5,1,1.5,2,4],d$=[.25,.5,1],f$=b({transport:x([`stream`,`file`]),seek:x([`forward`,`free`]),stepBack:v(),scrub:v(),rates:S(n().positive()).min(1).readonly()}),p$=b({state:x([`ok`,`sleeping`,`unreachable`,`no-storage`,`index-empty`]),reason:l().optional(),catalogAsOf:n().optional()}),m$=b({source:l(),label:l(),addonId:l().optional(),availability:p$}),h$={name:`videoclips`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:[T.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/clips-browser`,tab:`recording`,topTab:!0,label:`Clips`,order:100}},methods:{listClips:k(b({deviceId:n(),since:n(),until:n(),limit:n().int().positive().optional(),provider:l().min(1)}),S(t$).readonly(),{kind:`query`,auth:`protected`}),listSources:k(b({deviceId:n()}),S(m$).readonly(),{kind:`query`,auth:`protected`}),getClipPlayback:k(b({deviceId:n(),clipId:l(),profile:N.optional()}),n$,{kind:`query`,auth:`protected`}),readClipBytes:A(b({deviceId:n(),clipId:l().min(1),provider:l().min(1),profile:N.optional(),maxBytes:n().int().positive().optional(),wake:r$.optional()}),i$,{kind:`query`,auth:`protected`}),offerClipBytes:A(b({deviceId:n(),clipId:l().min(1),provider:l().min(1),profile:N.optional(),maxBytes:n().int().positive().optional(),wake:r$.optional()}),a$,{kind:`query`,auth:`protected`}),dialClipStream:A(b({deviceId:n(),clipId:l().min(1),provider:l().min(1),profile:N.optional(),audio:o$.optional(),wake:r$.optional()}),c$,{kind:`query`,auth:`protected`}),getPlaybackOptions:A(b({deviceId:n(),provider:l().min(1)}),f$,{kind:`query`,auth:`protected`})},vocabulary:{noun:P(`Video clips`,`Clip video`),order:3330}},LAe={stream:{transport:`stream`,seek:`forward`,stepBack:!1,scrub:!1,rates:u$},realtimeStream:{transport:`stream`,seek:`forward`,stepBack:!1,scrub:!1,rates:d$},file:{transport:`file`,seek:`free`,stepBack:!0,scrub:!0,rates:l$}},g$=n().min(.25).max(32),_$=b({fromSec:n().nonnegative(),toSec:n().nonnegative()}).refine(e=>e.toSec>e.fromSec,{message:`dense range must have toSec > fromSec`}),RAe=200,v$=b({everyMs:n().int().positive(),ranges:S(_$).min(1).max(200)}),y$=b({everyMs:n().int().positive(),outputFps:n().int().min(1).max(60).optional(),dense:v$.optional()}).superRefine((e,t)=>{e.dense!==void 0&&e.dense.everyMs>=e.everyMs&&t.addIssue({code:ue.custom,message:`dense.everyMs must be strictly smaller than the base everyMs`,path:[`dense`,`everyMs`]})}),b$=b({speed:g$.optional(),timelapse:y$.optional(),includeAudio:v(),maxLifeMs:n().int().positive(),deleteAfterDownload:v(),title:l().max(200).optional(),notifyTargetIds:S(l().min(1)).max(20).optional()}).superRefine((e,t)=>{e.speed!==void 0&&e.timelapse!==void 0&&t.addIssue({code:ue.custom,message:`speed and timelapse are mutually exclusive`,path:[`timelapse`]})}),x$=x([`queued`,`rendering`,`ready`,`failed`,`expired`,`deleted`]),S$=b({kind:p(`footage`),deviceId:n(),profiles:S(l()).min(1),fromMs:n(),toMs:n()}),C$=b({kind:p(`clip`),deviceId:n(),provider:l().min(1),source:l().min(1),sourceLabel:l().min(1),clipId:l().min(1),catalogWindow:b({sinceMs:n(),untilMs:n()}),profile:x([`high`,`mid`,`low`]),wake:r$.optional()}),w$=i(`kind`,[S$,C$]),T$=b({id:l(),deviceId:n(),profile:l(),fromMs:n(),toMs:n(),subject:w$.optional(),options:b$,state:x$,progressPct:n().nullable(),fileBytes:n().nullable(),expiresAt:n(),deleteAfterDownload:v(),downloadedAt:n().nullable(),createdAt:n(),createdBy:l(),error:l().nullable()}),E$=x([`catalog-miss`,`catalog-unreachable`,`no-file-for-window`,`clip-in-progress`,`unsupported-option`,`sleeping`,`camera-refused`,`fetch-failed`,`too-large-to-transfer`,`wake-expired`,`wake-timeout`]);function zAe(e,t){return t.length>0?`${e}: ${t}`:e}function BAe(e){if(e===null)return null;let t=e.split(`:`,1)[0]??``,n=E$.safeParse(t.trim());return n.success?n.data:null}var D$=b({url:l(),endpoints:S(l())}),VAe=50*1024*1024,O$=b({base64:l(),contentType:l(),name:l(),bytes:n().int().nonnegative()});function k$(e){return e.profiles!==void 0&&e.profiles.length>0?[...e.profiles]:typeof e.profile==`string`&&e.profile.length>0?[e.profile]:[]}var HAe=b({deviceId:n(),profile:l().optional(),profiles:S(l()).min(1).optional(),fromMs:n().optional(),toMs:n().optional(),subject:w$.optional(),options:b$}).superRefine((e,t)=>{if(e.subject?.kind===`clip`){e.subject.deviceId!==e.deviceId&&t.addIssue({code:ue.custom,message:`subject.deviceId (${e.subject.deviceId}) must equal deviceId (${e.deviceId}) — the top-level field is what per-device scope enforcement reads`,path:[`subject`,`deviceId`]}),(e.fromMs!==void 0||e.toMs!==void 0)&&t.addIssue({code:ue.custom,message:`a clip export asks for no time range: the camera chose the boundaries and they are read from the catalog row`,path:[`fromMs`]});return}e.subject?.kind===`footage`&&e.subject.deviceId!==e.deviceId&&t.addIssue({code:ue.custom,message:`subject.deviceId (${e.subject.deviceId}) must equal deviceId (${e.deviceId})`,path:[`subject`,`deviceId`]});let n=e.subject?.kind===`footage`?e.subject.fromMs:e.fromMs,r=e.subject?.kind===`footage`?e.subject.toMs:e.toMs;(typeof n!=`number`||typeof r!=`number`)&&t.addIssue({code:ue.custom,message:`a footage export needs fromMs and toMs`,path:[`fromMs`]}),(e.subject?.kind===`footage`?[...e.subject.profiles]:k$(e)).length<1&&t.addIssue({code:ue.custom,message:`pass profiles[] (min 1) or legacy profile`,path:[`profiles`]})});function UAe(e){if(e.subject!==void 0)return e.subject;let t=k$(e);if(typeof e.fromMs!=`number`||typeof e.toMs!=`number`)throw Error(`recording-export: a footage export needs fromMs and toMs`);return{kind:`footage`,deviceId:e.deviceId,profiles:t,fromMs:e.fromMs,toMs:e.toMs}}function WAe(e){return e.subject===void 0?{kind:`footage`,deviceId:e.deviceId,profiles:[e.profile],fromMs:e.fromMs,toMs:e.toMs}:e.subject}var A$={name:`recording-export`,scope:`system`,mode:`singleton`,methods:{createExport:k(HAe,T$,{role:`viewer`,kind:`mutation`,auth:`protected`}),listExports:k(b({deviceId:n().optional()}),S(T$),{role:`viewer`,kind:`query`,auth:`protected`}),getExport:k(b({exportId:l()}),T$,{role:`viewer`,kind:`query`,auth:`protected`}),cancelExport:k(b({exportId:l()}),T$,{role:`viewer`,kind:`mutation`,auth:`protected`}),deleteExport:k(b({exportId:l()}),T$,{role:`viewer`,kind:`mutation`,auth:`protected`}),getDownloadUrl:k(b({exportId:l()}),D$,{role:`viewer`,kind:`query`,auth:`protected`}),readExportBytes:k(b({exportId:l()}),O$,{kind:`query`,auth:`protected`})},vocabulary:{notOperatorFacing:`recording exports — requested from the timeline, not an automation step`}},j$=x([`continuous`,`motion`,`person`,`vehicle`,`animal`,`lineCrossing`,`intrusion`,`loitering`,`alarmInput`]),M$=b({trigger:j$,day:n().int().min(0).max(6).meta(M(`none`)),startMinute:n().int().min(0).max(1439).meta(M(`none`)),endMinute:n().int().min(1).max(1440).meta(M(`none`))}),N$=b({id:l(),label:l().optional(),status:x([`ok`,`unformatted`,`error`,`offline`,`unknown`]),capacityMb:n().nullable(),freeMb:n().nullable(),writable:v().optional()}),P$=i(`kind`,[b({kind:p(`present`),volumes:S(N$)}),b({kind:p(`absent`),reason:l()}),b({kind:p(`unknown`),reason:l()})]),F$=b({id:l(),enabled:v(),isVideo:v(),codec:l().nullable(),resolution:l().nullable(),overwriteWhenFull:v().nullable()}),I$=b({storage:P$,tracks:S(F$),primaryTrackId:l().nullable(),enabled:v().nullable(),overwriteWhenFull:v().nullable(),preRecordSec:n().nullable().meta(M(`duration`)),postRecordSec:n().nullable().meta(M(`duration`)),segmentMinutes:n().nullable().meta(M(`none`)),windows:S(M$),unreadableWindows:n().meta(M(`count`)),recordingToNowhere:v(),lastFetchedAt:n()}),L$=b({min:n(),max:n(),step:n()}),R$=b({values:S(n()).min(1),sentinel:b({value:n(),meaning:x([`no-limit`,`disabled`])}).optional()}),z$=b({readable:v(),writable:v(),reason:l().optional()}),B$=b({support:z$,granularityMinutes:n(),triggers:S(j$),supportsOverlappingTriggers:v()}),V$=b({enabled:z$,overwriteWhenFull:z$,preRecordSec:z$,preRecordSecRange:L$.optional(),preRecordSecAllowed:R$.optional(),postRecordSec:z$,postRecordSecRange:L$.optional(),postRecordSecAllowed:R$.optional(),segmentMinutes:z$,segmentMinutesRange:L$.optional(),segmentMinutesAllowed:R$.optional(),schedule:B$}),H$=b({enabled:v().optional(),overwriteWhenFull:v().optional(),preRecordSec:n().optional(),postRecordSec:n().optional(),segmentMinutes:n().optional(),windows:S(M$).optional()}),U$={name:`recording-onboard`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Camera],deviceConfig:{ui:{kind:`derived-form`,builderId:`recording-onboard`,tab:`recording`}},methods:{getOptions:k(b({deviceId:n()}),V$),setSettings:k(b({deviceId:n(),settings:H$}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`recordingOnboard.on`,label:P(`On-camera recording on`,`Registrazione a bordo attiva`),phrase:P(`Turn on recording to the card of {device}`,`Attiva la registrazione sulla scheda di {device}`),icon:`hard-drive`,args:{settings:{enabled:!0}}},{id:`recordingOnboard.off`,label:P(`On-camera recording off`,`Registrazione a bordo spenta`),phrase:P(`Turn off recording to the card of {device}`,`Disattiva la registrazione sulla scheda di {device}`),icon:`hard-drive`,args:{settings:{enabled:!1}}}]})},status:{schema:I$,kind:`poll`},runtimeState:I$,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:P(`On-camera recording`,`Registrazione a bordo`),order:3260,state:[{kind:`boolean`,field:`recordingToNowhere`,label:P(`Recording to nowhere`,`Registra nel vuoto`),whenTrue:P(`When {device} is recording with no card to write to`,`Quando {device} registra senza una scheda su cui scrivere`),whenFalse:P(`When {device} has a card to record to again`,`Quando {device} ha di nuovo una scheda su cui registrare`),icon:`hard-drive`}]}},W$=b({active:v(),reason:l(),lastChangedAt:n()}),G$=W$.extend({lastFetchedAt:n()}),K$={name:`recording-signal`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Camera],methods:{getStatus:k(b({deviceId:n()}),W$)},status:{schema:W$,kind:`push`,empty:{active:!1,reason:`unknown`,lastChangedAt:0}},runtimeState:G$,durability:`session`,history:`none`,vocabulary:{noun:P(`Recording signal`,`Segnale di registrazione`),order:3270,state:[{kind:`boolean`,field:`active`,label:P(`Recording`,`In registrazione`),whenTrue:P(`When {device} starts recording`,`Quando {device} inizia a registrare`),whenFalse:P(`When {device} stops recording`,`Quando {device} smette di registrare`),icon:`circle-dot`}]}},q$=b({kind:p(`cap`),deviceId:n().int().nonnegative(),cap:l().min(1),method:l().min(1),args:m(l(),C()).optional(),argUnits:m(l(),l().min(1)).optional()}),J$=b({action:q$}),Y$=b({key:l().refine(QE,{message:`a lowercase slug`}),name:l().min(1).max(60)}),GAe=200,KAe=100;function qAe(e,t){let n=new Set,r=new Set,i=new Set;e.sources.forEach((a,o)=>{let s=(e,n)=>{t.addIssue({code:`custom`,message:e,path:[`sources`,o,n]})};n.has(a.id)&&s(`source id "${a.id}" is used twice`,`id`),n.add(a.id);let c=a.name.trim().toLowerCase();if(r.has(c)&&s(`source name "${a.name}" is used twice`,`name`),r.add(c),a.kind===`digits`&&(i.has(a.number)&&s(`channel ${a.number} is declared twice`,`number`),i.add(a.number)),a.kind===`ir`){let e=dD(a);e!==null&&s(e,`payload`)}for(let t of uD(a))YE(t)?s(`"${a.name}" presses ${t}, a layout widget, not a command`,`steps`):e.bindings[t]===void 0&&s(`"${a.name}" presses ${t}, which is not bound`,`steps`)}),e.sources.forEach((n,r)=>{for(let i of e.sources)if(!(i.kind!==`digits`||i===n))for(let e of[`name`,`id`])n[e].trim()===i.number&&t.addIssue({code:`custom`,message:`${e} "${n[e]}" is the channel number of "${i.name}"`,path:[`sources`,r,e]})})}var X$=b({index:n().int().nonnegative(),id:l().nullable(),name:l().nullable(),reason:l()}),Z$=b({layoutTemplateId:l().min(1).nullable(),defaultTransmitterId:n().int().nonnegative().nullable().default(null),bindings:m(l(),J$),customButtons:S(Y$).max(100),sources:S(cD).max(200).default([]),stepDelayMs:n().int().min(100).max(lD).default(500),refusedSources:S(X$).optional()}).superRefine((e,t)=>{let n=Object.keys(e.bindings);n.length>200&&t.addIssue({code:`custom`,message:`too many bindings`,path:[`bindings`]});for(let e of n)YE(e)?t.addIssue({code:`custom`,message:`"${e}" is a layout widget, not a command: it cannot be bound`,path:[`bindings`,e]}):tD(e)||t.addIssue({code:`custom`,message:`"${e}" is not a role`,path:[`bindings`,e]});let r=new Set;e.customButtons.forEach((e,n)=>{r.has(e.key)&&t.addIssue({code:`custom`,message:`custom button "${e.key}" is listed twice`,path:[`customButtons`,n,`key`]}),r.add(e.key)});for(let e of n){let n=eD(e);n!==null&&!r.has(n)&&t.addIssue({code:`custom`,message:`${e} is bound but has no entry in customButtons`,path:[`bindings`,e]})}qAe(e,t)}),JAe=ce({sources:S(C())}),YAe=b({id:l(),name:l()}).partial();function XAe(e){let t=JAe.safeParse(e);if(!t.success)return Q$(Z$.safeParse(e));let n=[],r=[];t.data.sources.forEach((e,t)=>{let i=cD.safeParse(e),a=i.success&&i.data.kind===`ir`?dD(i.data):null;if(i.success&&a===null){n.push(e);return}let o=YAe.safeParse(e),s=a??i.error?.issues[0]?.message??`not a source`;r.push({index:t,id:o.success?o.data.id??null:null,name:o.success?o.data.name??null:null,reason:s})});let i=Q$(Z$.safeParse({...t.data,sources:n}));return!i.success||r.length===0?i:{success:!0,data:{...i.data,refusedSources:r}}}function Q$(e){return e.success?{success:!0,data:e.data}:{success:!1,issues:e.error.issues.length}}var ZAe={layoutTemplateId:null,defaultTransmitterId:null,bindings:{},customButtons:[],sources:[],stepDelayMs:500},QAe=b({power:b({state:x([`on`,`off`]),at:n()}).nullable(),muted:b({value:v(),at:n()}).nullable(),source:b({name:l(),at:n()}).nullable().default(null)}),$Ae={power:null,muted:null,source:null},eje=24,tje=50,$$=[`rect`,`rounded`,`round`,`pill`],e1=x($$),t1=[`neutral`,`accent`,`danger`,`red`,`green`,`yellow`,`blue`],n1=x(t1),r1=[`none`,`panel`,`divider`,`dpad`,`rocker-v`,`rocker-h`,`keypad`],i1=x(r1),a1=b({id:l().min(1).max(40),row:n().int().min(0).max(24),col:n().int().min(0).max(24),rowSpan:n().int().min(1).max(24),colSpan:n().int().min(1).max(24),icon:l().min(1).max(60).optional(),label:l().min(1).max(40).optional(),role:nD,shape:e1.optional(),tone:n1.optional(),showLegend:v().optional(),groupId:l().min(1).max(40).optional()}),o1=b({id:l().min(1).max(40),componentId:l().min(1).max(80),frame:i1,row:n().int().min(0).max(24),col:n().int().min(0).max(24),rowSpan:n().int().min(1).max(24),colSpan:n().int().min(1).max(24),title:l().min(1).max(40).optional(),size:x([`compact`,`normal`]).optional(),hideTitle:v().optional()});function s1(e,t){return e.row<t.row+t.rowSpan&&t.row<e.row+e.rowSpan&&e.col<t.col+t.colSpan&&t.col<e.col+e.colSpan}function c1(e,t){return t.row>=e.row&&t.col>=e.col&&t.row+t.rowSpan<=e.row+e.rowSpan&&t.col+t.colSpan<=e.col+e.colSpan}function nje(e,t){let n=e.groups??[],r=new Map,i=(e,n)=>{t.addIssue({code:`custom`,message:e,path:n})};n.forEach((t,a)=>{r.has(t.id)&&i(`group id "${t.id}" is used twice`,[`groups`,a,`id`]),r.set(t.id,t),(t.row+t.rowSpan>e.rows||t.col+t.colSpan>e.columns)&&i(`group "${t.id}" leaves the grid`,[`groups`,a]);for(let e=0;e<a;e+=1){let r=n[e];if(r!==void 0&&s1(r,t)){i(`groups "${r.id}" and "${t.id}" overlap`,[`groups`,a]);return}}}),e.buttons.forEach((e,t)=>{if(e.groupId!==void 0){let n=r.get(e.groupId);if(n===void 0){i(`button "${e.id}" names the unknown group "${e.groupId}"`,[`buttons`,t,`groupId`]);return}n.frame===`divider`&&i(`a divider group ("${n.id}") holds no buttons`,[`buttons`,t,`groupId`]),c1(n,e)||i(`button "${e.id}" lies outside its group "${n.id}"`,[`buttons`,t]);return}let a=n.find(t=>s1(t,e));a!==void 0&&i(`button "${e.id}" lies inside group "${a.id}" but is not a member`,[`buttons`,t])})}var l1=b({columns:n().int().min(1).max(24),rows:n().int().min(1).max(24),buttons:S(a1).max(200),groups:S(o1).max(50).optional()}).superRefine((e,t)=>{let n=new Set,r=new Map;e.buttons.forEach((i,a)=>{if(n.has(i.id)&&t.addIssue({code:`custom`,message:`button id "${i.id}" is used twice`,path:[`buttons`,a,`id`]}),n.add(i.id),i.row+i.rowSpan>e.rows||i.col+i.colSpan>e.columns){t.addIssue({code:`custom`,message:`button "${i.id}" leaves the grid`,path:[`buttons`,a]});return}for(let e=i.row;e<i.row+i.rowSpan;e+=1)for(let n=i.col;n<i.col+i.colSpan;n+=1){let o=`${e}:${n}`,s=r.get(o);if(s!==void 0){t.addIssue({code:`custom`,message:`buttons "${s}" and "${i.id}" overlap`,path:[`buttons`,a]});return}r.set(o,i.id)}}),nje(e,t)}),rje=50,u1=b({role:nD,label:l().optional(),custom:v()}),d1=b({layoutTemplateId:l().nullable(),commands:S(u1),sources:S(cD)}),f1=[`no-remote`,`unbound-role`,`action-failed`,`unknown-source`,`unbound-step`,`undeclared-channel`,`press-timeout`,`no-transmitter`],p1=x(f1),m1=i(`status`,[b({status:p(`sent`),sends:n().int().min(1)}),b({status:p(`skipped`),reason:p(`already-in-state`)}),b({status:p(`refused`),reason:p1,detail:l().optional(),step:b({index:n().int().min(1),role:l()}).optional()})]),h1=[`play`,`pause`,`stop`,`next`,`previous`,`setMute`,`selectSource`,`playMedia`,`turnOn`,`turnOff`,`volumeUp`,`volumeDown`,`channelUp`,`channelDown`],g1=x(h1),_1=i(`status`,[...m1.options,b({status:p(`not-routed`)})]),v1=[`unknown-template`,`not-a-media-player`],y1=i(`status`,[b({status:p(`saved`)}),b({status:p(`refused`),reason:x(v1),detail:l()})]),b1=b({deviceId:n().int().nonnegative()}),ije={version:1,targets:[{id:`remote`,cardinality:`config`,vocabulary:{cap:`remote`},deviceTypes:[T.MediaPlayer],apply:`add`,readMethod:`getConfig`,writeMethod:`setConfig`}]},x1={name:`remote`,scope:`system`,mode:`singleton`,methods:{getConfig:k(b1,Z$,{auth:`admin`}),setConfig:k(b1.extend({config:Z$}),y1,{kind:`mutation`,auth:`admin`}),listCommands:k(b1,d1,{auth:`protected`}),sendCommand:k(b1.extend({role:nD,repeat:n().int().min(1).max(50).default(1)}),m1,{kind:`mutation`,auth:`protected`}),getAssumedStatus:k(b1,_D.nullable(),{auth:`protected`}),sendMediaCommand:k(b1.extend({command:g1,muted:v().optional(),source:l().optional(),mediaType:l().optional(),mediaId:l().optional(),repeat:n().int().min(1).max(50).default(1)}),_1,{kind:`mutation`,auth:`protected`})},customize:ije,vocabulary:{notOperatorFacing:`the per-device remote setup — authored in the Customize remote editor, sent through the remote UI`}},S1=[`power`,`navigation`,`volume`,`numbers`,`media`,`colour`,`apps`,`layout`],C1=x(S1),aje=40,oje=/^[a-z0-9][a-z0-9_.-]*:[a-z0-9][a-z0-9_-]*$/,w1=b({idSuffix:l().regex(/^[a-z0-9][a-z0-9_-]{0,19}$/,{message:`a short lowercase slug`}),row:n().int().min(0).max(24),col:n().int().min(0).max(24),rowSpan:n().int().min(1).max(24),colSpan:n().int().min(1).max(24),role:nD,icon:l().min(1).max(60).optional(),label:l().min(1).max(40).optional(),shape:e1.optional(),tone:n1.optional(),showLegend:v().optional()}),T1=b({id:l().max(80).regex(oje,{message:`<namespace>:<name>, lowercase`}),name:l().min(1).max(60),nameI18n:b({en:l().min(1).max(60),it:l().min(1).max(60)}).optional(),icon:l().min(1).max(60),category:C1,size:b({rows:n().int().min(1).max(24),cols:n().int().min(1).max(24)}),group:b({frame:i1,title:l().min(1).max(40).optional()}).nullable(),buttons:S(w1).max(40)}).superRefine((e,t)=>{let n=new Set;e.buttons.forEach((r,i)=>{if(n.has(r.idSuffix)&&t.addIssue({code:`custom`,message:`button "${r.idSuffix}" is listed twice`,path:[`buttons`,i,`idSuffix`]}),n.add(r.idSuffix),r.row+r.rowSpan>e.size.rows||r.col+r.colSpan>e.size.cols){t.addIssue({code:`custom`,message:`button "${r.idSuffix}" leaves the component`,path:[`buttons`,i]});return}for(let n=0;n<i;n+=1){let a=e.buttons[n];if(a!==void 0&&s1(a,r)){t.addIssue({code:`custom`,message:`buttons "${a.idSuffix}" and "${r.idSuffix}" overlap`,path:[`buttons`,i]});return}}}),e.group?.frame===`divider`&&e.buttons.length>0&&t.addIssue({code:`custom`,message:`a divider component holds no buttons`,path:[`buttons`]})}),E1={name:`remote-layout-components`,scope:`system`,mode:`collection`,methods:{listComponents:k(b({}),S(T1),{auth:`protected`})},vocabulary:{notOperatorFacing:`the palette of the remote template editor — read-only data, never actuated`}},D1=b({deviceId:n().int().nonnegative(),resetToSource:v().optional()}),O1={name:`resync`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Container,T.Workload,T.WeatherStation],methods:{resync:k(D1,RA,{kind:`mutation`,auth:`admin`,notOperatorFacing:`device adoption — re-aligning a device with its source is an onboarding step, not an automation action`})},vocabulary:{noun:P(`Re-sync`,`Risincronizzazione`),order:3245}},sje=5,cje=2,k1=3e4,A1=18e4,j1={startDwellMs:k1,stopDwellMs:A1,minSamples:2},M1={[T.MediaPlayer]:{startDwellMs:1e4,stopDwellMs:1e4,minSamples:1}};function N1(e){return e!==void 0&&M1[e]!==void 0}function P1(e){return e===void 0?j1:M1[e]??j1}var lje={running:null,since:null,source:`native`,phase:null,lastFetchedAt:null},F1=x([`native`,`assigned`]),I1=b({running:v().nullable(),since:n().nullable().meta(M(`none`)),source:F1.meta({label:`Source`}),phase:l().nullable(),lastFetchedAt:n().nullable()}),L1=b({deviceId:n(),since:n().nullable(),phase:l().nullable()}),uje=Object.values(T),R1=[T.Washer,T.Dryer,T.Dishwasher,T.Vacuum,T.LawnMower,T.MediaPlayer,T.WaterHeater,T.Humidifier,T.Fan,T.Climate,T.PetFeeder],dje={version:1,overridable:[{path:`running`,by:`running`}],targets:[{id:`running`,cardinality:`scalar`,vocabulary:{cap:`running-state`,stateField:`running`},deviceTypes:R1,apply:`add`,path:`running`,sources:[{kind:`switch`,transforms:[{kind:`identity`}]},{kind:`binary`,transforms:[{kind:`identity`},{kind:`invert`}]},{kind:`numeric`,requiredUnit:`W`,transforms:[{kind:`threshold`,comparisons:[`gte`,`lte`],comparison:`gte`,defaultThreshold:5,defaultStartDwellMs:k1,defaultStopDwellMs:A1,deviceTypeDefaults:M1,thresholdUnit:`W`}]}],companions:[{kind:`constant`,path:`source`,value:`assigned`,when:`always`},{kind:`constant`,path:`phase`,value:null,when:`add`},{kind:`clock`,path:`lastFetchedAt`,when:`always`},{kind:`transition-time`,path:`since`,sourceChangedAt:`prefer`}],sourceReport:{status:`assignment-status`,runtimeField:`source`,nativeValue:`native`,assignedValue:`assigned`},advancedExpression:!0}]},z1={name:`running-state`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:uje,methods:{},events:{onStarted:{data:L1,trigger:{category:w.RunningStarted,label:P(`Started running`,`Ha iniziato a funzionare`),phrase:P(`When {device} starts running`,`Quando {device} inizia a funzionare`),icon:`play`}},onFinished:{data:L1,trigger:{category:w.RunningFinished,label:P(`Finished`,`Ha finito`),phrase:P(`When {device} finishes`,`Quando {device} finisce`),icon:`square`}}},status:{schema:I1,kind:`push`},runtimeState:I1,durability:`restored`,history:{fields:{running:{kind:`boolean`}}},volatileStateFields:[`lastFetchedAt`],customize:dje,vocabulary:{noun:P(`Running`,`In funzione`),order:2120,state:[{kind:`boolean`,field:`running`,label:P(`Running`,`In funzione`),whenTrue:P(`When {device} starts`,`Quando {device} inizia`),whenFalse:P(`When {device} finishes`,`Quando {device} finisce`),icon:`play`}],overrides:{byType:{[T.Washer]:{state:{running:{whenTrue:P(`When the washing machine starts`,`Quando la lavatrice inizia`),whenFalse:P(`When the washing machine has finished`,`Quando la lavatrice ha finito`)}},events:{onStarted:{phrase:P(`When the washing machine starts`,`Quando la lavatrice inizia`)},onFinished:{phrase:P(`When the washing machine has finished`,`Quando la lavatrice ha finito`)}}},[T.Dryer]:{state:{running:{whenTrue:P(`When the dryer starts`,`Quando l'asciugatrice inizia`),whenFalse:P(`When the dryer has finished`,`Quando l'asciugatrice ha finito`)}},events:{onStarted:{phrase:P(`When the dryer starts`,`Quando l'asciugatrice inizia`)},onFinished:{phrase:P(`When the dryer has finished`,`Quando l'asciugatrice ha finito`)}}},[T.Dishwasher]:{state:{running:{whenTrue:P(`When the dishwasher starts`,`Quando la lavastoviglie inizia`),whenFalse:P(`When the dishwasher has finished`,`Quando la lavastoviglie ha finito`)}},events:{onStarted:{phrase:P(`When the dishwasher starts`,`Quando la lavastoviglie inizia`)},onFinished:{phrase:P(`When the dishwasher has finished`,`Quando la lavastoviglie ha finito`)}}}}}}},B1=l(),fje=[`day`,`ir`,`night`,`dawn`,`dusk`],V1=x([`skip`,`judge-anyway`]),pje=`__diverged__`,H1=x([`matched`,`diverged`,`unknown`]),U1=x([`no-reference-for-condition`,`view-shifted`,`no-vision-profile`,`encoder-model-changed`,`no-snapshot`]),W1=b({embedding:S(n()),modelId:l(),condition:B1,capturedAt:n(),thumbnailMediaId:n().int().optional(),anchorEmbedding:S(n()).optional()}),G1=b({id:l(),label:l(),references:S(W1),textPrompts:S(l()).optional(),referenceCount:n(),currentlyMatched:v()}),K1=i(`mode`,[b({mode:p(`similarity`),threshold:n().min(0).max(1),hysteresisCount:n().int().positive()}),b({mode:p(`llm`),prompt:l(),profileId:l().optional(),hysteresisCount:n().int().positive()})]),mje=60,hje=120,gje=60,q1=.85,J1=`skip`,Y1=8e3,_je=448,vje=!0,X1=b({enabled:v().default(!1),prompt:l().min(1).max(1e3),profileId:l().optional(),timeoutMs:n().int().min(1e3).max(2e4).default(Y1),maxImagePx:n().int().min(64).max(2048).default(448),onTimeout:x([`flip`,`hold`]).default(`hold`)}),Z1=b({id:l(),label:l(),roi:eH,enabled:v(),triggerMode:x([`periodic`,`on-motion`,`both`]),checkIntervalSec:n().optional(),check:K1,states:S(G1),currentStateId:l().nullable(),lastCheckedAt:n().nullable(),lastConfidence:n().nullable(),currentCondition:B1.nullable(),availability:x([`ok`,`unavailable`]),unavailableReason:l().nullable(),baselineStateId:l().nullable(),emit:x([`latched`,`live`]).default(`latched`),verdict:H1,latched:v(),armedAt:n(),divergedAt:n().nullable(),restoredAt:n().nullable(),quietSeconds:n().int().min(0).max(3600).default(60),minObservationSpacingSec:n().int().min(0).max(3600).default(120),confirm:X1.optional(),anchorThreshold:n().min(0).max(1).default(q1),autoRestore:v().default(!1),onUncoveredCondition:V1.default(J1),suspendedCondition:B1.nullable().default(null),unavailable:U1.nullable(),coveredConditions:S(B1)}),Q1=b({monitors:S(Z1),lastFetchedAt:n()}),$1=b({deviceId:n(),status:Q1.nullable()}),e0={name:`scene-monitor`,role:{feature:`scenes`},scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[T.Camera],methods:{listScenes:k(b({deviceId:n()}),Q1),listScenesBatch:k(b({deviceIds:S(n()).min(1).max(200)}),S($1).readonly()),createScene:k(b({deviceId:n(),label:l(),roi:eH,check:K1,triggerMode:x([`periodic`,`on-motion`,`both`]).optional(),checkIntervalSec:n().optional()}),Z1,{kind:`mutation`,auth:`admin`}),updateScene:k(b({deviceId:n(),monitorId:l(),patch:b({label:l().optional(),roi:eH.optional(),enabled:v().optional(),triggerMode:x([`periodic`,`on-motion`,`both`]).optional(),checkIntervalSec:n().optional(),check:K1.optional(),emit:x([`latched`,`live`]).optional(),quietSeconds:n().int().min(0).max(3600).optional(),minObservationSpacingSec:n().int().min(0).max(3600).optional(),anchorThreshold:n().min(0).max(1).optional(),autoRestore:v().optional(),onUncoveredCondition:V1.optional(),confirm:X1.nullable().optional()})}),_(),{kind:`mutation`,auth:`admin`}),deleteScene:k(b({deviceId:n(),monitorId:l()}),_(),{kind:`mutation`,auth:`admin`}),captureReference:k(b({deviceId:n(),monitorId:l(),stateId:l().optional(),label:l().optional(),condition:B1.optional()}),b({stateId:l(),referenceCount:n()}),{kind:`mutation`,auth:`admin`}),deleteReference:k(b({deviceId:n(),monitorId:l(),stateId:l(),index:n()}),_(),{kind:`mutation`,auth:`admin`}),recheckNow:k(b({deviceId:n(),monitorId:l()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`sceneMonitor.recheck`,label:P(`Re-check a scene`,`Ricontrolla una scena`),phrase:P(`Re-check {monitorId} on {device} now`,`Ricontrolla subito {monitorId} su {device}`),icon:`scan-search`,openArgs:[{key:`monitorId`,label:P(`Scene`,`Scena`),offer:{kind:`dynamic`,from:`status`,field:`monitors`,valueKey:`id`,labelKey:`label`}}]}]}),resetScene:k(b({deviceId:n(),monitorId:l(),recapture:v().optional()}),_(),{kind:`mutation`,auth:`admin`})},status:{schema:Q1,kind:`push`},runtimeState:Q1,durability:`session`,history:`none`,vocabulary:{noun:P(`Scene watch`,`Controllo della scena`),order:3280,extraEvents:[{category:w.EnrichmentSceneStateChanged,label:P(`Scene changed`,`Scena cambiata`),phrase:P(`When a watched scene on {device} changes`,`Quando cambia una scena controllata su {device}`),icon:`scan-search`}]}},t0=b({schedulerId:l().min(1)}),n0={name:`schedulers`,scope:`system`,mode:`singleton`,methods:{list:k(b({}),S(oy),{auth:`admin`}),get:k(t0,b({scheduler:oy.nullable()}),{auth:`admin`}),create:k(b({scheduler:ay}),b({scheduler:oy}),{kind:`mutation`,auth:`admin`}),update:k(b({schedulerId:l().min(1),scheduler:ay}),b({scheduler:oy}),{kind:`mutation`,auth:`admin`}),delete:k(t0,_(),{kind:`mutation`,auth:`admin`}),setEnabled:k(b({schedulerId:l().min(1),profileId:l().min(1).optional(),enabled:v()}),b({scheduler:oy}),{kind:`mutation`,auth:`admin`}),preview:k(b({schedulerId:l().min(1),date:l().regex(fy).optional()}),my,{auth:`admin`}),conflicts:k(b({scheduler:ay,schedulerId:l().min(1).optional()}),b({conflicts:S(hy)}),{auth:`admin`}),getStatus:k(b({}),S(_y),{auth:`admin`}),getTraces:k(t0,b({traces:S(Oy)}),{auth:`admin`})},vocabulary:{notOperatorFacing:`time schedulers — authored on their own page, not device actions`}},r0=b({isRunning:v(),lastRunAt:n(),lastRunSuccess:v().nullable(),lastError:l().nullable(),lastChangedAt:n()}),i0={name:`script-runner`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Script],methods:{run:k(b({deviceId:n().int().nonnegative(),variables:m(l(),C()).optional()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`script.run`,label:P(`Run script`,`Esegui lo script`),phrase:P(`Run {device}`,`Esegui {device}`),icon:`scroll-text`,hold:{effects:[{field:`isRunning`,value:!0}],holdMs:MY}}]}),stop:k(b({deviceId:n().int().nonnegative()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`script.stop`,effect:{field:`isRunning`,value:!1},label:P(`Stop script`,`Ferma lo script`),phrase:P(`Stop {device}`,`Ferma {device}`),icon:`square`}]})},status:{schema:r0,kind:`push`},runtimeState:r0,durability:`session`,history:`none`,vocabulary:{noun:P(`Script`,`Script`),order:2090,state:[{kind:`boolean`,field:`isRunning`,label:P(`Running`,`In esecuzione`),whenTrue:P(`When {device} starts running`,`Quando {device} parte`),whenFalse:P(`When {device} finishes`,`Quando {device} termina`),icon:`scroll-text`}]}},a0=x([`workspace`,`baked`,`data-root`]),o0=x([`idle`,`checking`,`staging`,`pending-restart`,`awaiting-confirmation`]),s0=x([`in-sync`,`behind-patch`,`behind-series`,`ahead`,`unknown`]),c0=b({state:s0,seedVersion:l().nullable(),contractVersion:l().nullable(),contractSource:x([`registry`,`running`]).nullable(),message:l()}),l0=x([`docker`,`electron`,`native`,`contradictory`,`unknown`]),u0=b({fact:x([`dockerenv-file`,`proc-1-cgroup`,`platform`,`electron-app-version-env`]),mode:x([`observed`,`declared`]),holds:v(),detail:l()}),d0=b({kind:l0,evidence:S(u0),currentVersion:l().nullable()}),f0=b({fromVersion:l(),toVersion:l().nullable(),atMs:n(),reason:l()}),p0=b({version:l(),update:b({available:v(),downloaded:v(),version:l().nullable(),checking:v(),error:l().nullable()}),stateAtMs:n(),stale:v()}),m0=x([`not-electron`,`no-app-state`,`app-state-stale`,`not-downloaded`]),h0=b({accepted:v(),reason:m0.nullable()}),g0=b({runnerId:l(),addonIds:S(l()),reason:l()}),_0=b({checkedAtMs:n(),expected:n(),running:n(),failed:S(l()),refused:S(g0),missing:S(l()),pending:S(l()).optional(),planKnown:v()}),v0=b({packageName:l(),runningVersion:l().nullable(),nodeRuntimeVersion:l().nullable(),activeVersion:l().nullable(),installedVersion:l().nullable().optional(),restartRequired:v().optional(),previousVersion:l().nullable(),seedVersion:l().nullable(),latestVersion:l().nullable(),updateAvailable:v(),bootMode:a0,updateState:o0,pendingVersion:l().nullable(),rolledBack:f0.nullable(),stateFileCorrupt:v(),lastCheckedAtMs:n().nullable(),imageContract:c0.optional(),wrapper:d0.optional(),runners:_0.optional(),desktopApp:p0.optional()}),y0=b({packageName:l(),runningVersion:l().nullable(),latestVersion:l().nullable(),updateAvailable:v(),checkedAtMs:n(),error:l().nullable(),pendingVersion:l().nullable().optional(),restartRequired:v().optional()}),b0=x([`staged`,`restart-scheduled`,`already-current`,`refused`,`failed`]),x0=b({addonId:l(),reason:l(),remedy:l()}),S0=b({accepted:v(),targetVersion:l().nullable(),restarting:v(),message:l(),outcome:b0.optional(),reason:l().nullable().optional(),error:l().nullable().optional(),blockers:S(x0).optional(),unmet:S(Nu).optional(),requiredAddonUpdates:S(Pu).optional()}),C0=b({heapMb:n().int().nullable(),rssBudgetMb:n().int().nullable()}),yje=b({heapMb:n().int().min(512).max(65536).nullable(),rssBudgetMb:n().int().min(512).max(65536).nullable().optional()}),bje=C0.extend({restartRequired:v()}),w0={name:`server-management`,scope:`system`,mode:`singleton`,methods:{getServerPackageStatus:k(_(),v0,{auth:`admin`}),checkServerUpdate:k(_(),y0,{kind:`mutation`,auth:`admin`}),applyServerUpdate:k(b({version:l().optional(),acknowledgeRefusals:v().optional()}),S0,{kind:`mutation`,auth:`admin`,timeoutMs:16*6e4}),installDesktopUpdate:k(_(),h0,{kind:`mutation`,auth:`admin`}),rollbackServerUpdate:k(_(),S0,{kind:`mutation`,auth:`admin`}),restartServer:k(_(),S0,{kind:`mutation`,auth:`admin`}),getLaunchOverrides:k(_(),C0,{auth:`admin`}),setLaunchOverrides:k(yje,bje,{kind:`mutation`,auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:j.CLUSTER}},T0={Seconds:`seconds`,Plays:`plays`},E0={Camera:`camera`,Fallback:`fallback`},D0=b({min:n().positive(),max:n().positive(),step:n().positive()}),O0=b({allowedSeconds:S(n().positive()).nullable(),rangeSeconds:D0.nullable(),defaultSeconds:n().positive(),allowedPlays:S(n().int().positive()).nullable().default(null),rangePlays:D0.nullable().default(null),defaultPlays:n().int().positive().nullable().default(null),unit:x([T0.Seconds,T0.Plays]),secondsPerPlay:n().positive().nullable(),source:x([E0.Camera,E0.Fallback]),fetchedAt:n()}),k0=b({active:v(),activeUntil:n().nullable(),durationSeconds:n().nullable(),plays:n().int().positive().nullable().default(null),activeUntilEstimated:v().default(!1),lastTriggeredAt:n()}),A0=b({deviceId:n().int().nonnegative(),durationSeconds:n().positive().optional(),plays:n().int().positive().optional()}).refine(e=>e.durationSeconds===void 0||e.plays===void 0,{message:`a siren trigger takes durationSeconds or plays, not both`,path:[`plays`]}),j0=k0.extend({lastFetchedAt:n()}),M0={name:`siren`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Siren],methods:{getOptions:k(b({deviceId:n().int().nonnegative()}),O0,{kind:`query`,auth:`protected`}),getPlayChoices:k(b({deviceId:n().int().nonnegative()}),S(n().int().positive()),{kind:`query`,auth:`protected`}),trigger:k(A0,k0,{kind:`mutation`,auth:`protected`,actions:[{id:`siren.trigger`,label:P(`Sound the siren`,`Fai suonare la sirena`),phrase:P(`Sound {device}`,`Fai suonare {device}`),icon:`siren`,args:{}},{id:`siren.triggerPlays`,label:P(`Sound the siren N times`,`Fai suonare la sirena N volte`),phrase:P(`Sound {device} {plays} times`,`Fai suonare {device} {plays} volte`),icon:`siren`,openArgs:[{key:`plays`,label:P(`Plays`,`Riproduzioni`),offer:{kind:`dynamic`,from:`method`,method:`getPlayChoices`,valueKind:`number`}}]}]}),stop:k(b({deviceId:n().int().nonnegative()}),k0,{kind:`mutation`,auth:`protected`,actions:[{id:`siren.stop`,label:P(`Silence the siren`,`Zittisci la sirena`),phrase:P(`Silence {device}`,`Zittisci {device}`),icon:`siren`,effect:{field:`active`,value:!1},args:{}}]})},events:{onSirenChanged:{data:b({deviceId:n(),active:v(),activeUntil:n().nullable()}),notOperatorFacing:"the `active` state trigger phrases both edges of this change"}},status:{schema:k0,kind:`command-driven`},runtimeState:j0,durability:`session`,history:`none`,vocabulary:{noun:P(`Siren`,`Sirena`),order:1170,state:[{kind:`boolean`,field:`active`,label:P(`Siren sounding`,`Sirena in funzione`),whenTrue:P(`When {device} starts sounding`,`Quando {device} inizia a suonare`),whenFalse:P(`When {device} falls silent`,`Quando {device} smette di suonare`),icon:`siren`}]}},N0=b({detected:v(),lastChangedAt:n()}),P0={name:`smoke`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[T.Sensor],methods:{},status:{schema:N0,kind:`push`},runtimeState:N0,durability:`restored`,history:{fields:{detected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:P(`Smoke detector`,`Rilevatore di fumo`),order:5190,state:[{kind:`boolean`,field:`detected`,label:P(`Detected`,`Rilevato`),whenTrue:P(`When {device} detects smoke`,`Quando {device} rileva fumo`),whenFalse:P(`When smoke clears on {device}`,`Quando il fumo su {device} si dirada`),icon:`alarm-smoke`}]}},xje=3,F0=5*1024*1024,I0=`<!--camstack-images-->`,L0=b({ticket:Ti,mime:l().min(1),name:l().min(1),contentId:l().min(1),placement:x([`inline`,`attachment`]),deviceId:n().int().nonnegative().optional()}),R0=0;function z0(e){return R0+=1,`camstack_${e}_${R0.toString(36)}_${Date.now().toString(36)}`}function Sje(e){return/^[\x20-\x7E]*$/.test(e)?e:`=?UTF-8?B?${Buffer.from(e,`utf8`).toString(`base64`)}?=`}function B0(e){return(Array.isArray(e)?e:[e]).join(`, `)}function Cje(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`)}function V0(e,t){let n=e.replace(/[\r\n"]/g,``).trim();return n.length>0?n:t}function wje(e){let t=Buffer.from(e).toString(`base64`),n=[];for(let e=0;e<t.length;e+=76)n.push(t.slice(e,e+76));return n.join(`\r
1114
1114
  `)}function Tje(e){return`<img src="cid:${Cje(e.contentId)}" alt="">`}function Eje(e,t){return e.replaceAll(I0,t.map(Tje).join(``))}function H0(e){let t=[`From: ${e.from}`,`To: ${B0(e.to)}`];return e.cc!==void 0&&e.cc.length>0&&t.push(`Cc: ${B0(e.cc)}`),e.bcc!==void 0&&e.bcc.length>0&&t.push(`Bcc: ${B0(e.bcc)}`),e.replyTo!==void 0&&e.replyTo.length>0&&t.push(`Reply-To: ${e.replyTo}`),t.push(`Subject: ${Sje(e.subject)}`),t.push(`MIME-Version: 1.0`),t}function U0(e,t){return[`--${e}`,`Content-Type: text/plain; charset="UTF-8"`,`Content-Transfer-Encoding: 8bit`,``,t]}function W0(e,t){return[`--${e}`,`Content-Type: text/html; charset="UTF-8"`,`Content-Transfer-Encoding: 8bit`,``,t]}function G0(e,t){let n=V0(t.mime,`image/jpeg`),r=V0(t.name,`image.jpg`),i=t.placement===`inline`?`inline`:`attachment`,a=[`--${e}`,`Content-Type: ${n}`,`Content-Transfer-Encoding: base64`,`Content-Disposition: ${i}; filename="${r}"`];return t.placement===`inline`&&a.push(`Content-ID: <${V0(t.contentId,`image`)}>`),a.push(``,wje(t.bytes)),a}function K0(e,t,n){let r=z0(`alt`);return[`--${e}`,`Content-Type: multipart/alternative; boundary="${r}"`,``,...U0(r,t),...W0(r,n),`--${r}--`]}function Dje(e,t){let n=H0(e);if(t!==void 0){let r=z0(`alt`);return n.push(`Content-Type: multipart/alternative; boundary="${r}"`,``),n.push(...U0(r,e.text),...W0(r,t),`--${r}--`),n}return n.push(`Content-Type: text/plain; charset="UTF-8"`,`Content-Transfer-Encoding: 8bit`,``,e.text),n}function Oje(e,t,n){let r=z0(`mix`),i=H0(e);i.push(`Content-Type: multipart/mixed; boundary="${r}"`,``),t===void 0?i.push(...U0(r,e.text)):i.push(...K0(r,e.text,t));for(let e of n)i.push(...G0(r,e));return i.push(`--${r}--`),i}function kje(e,t,n,r){let i=z0(`rel`),a=H0(e);a.push(`Content-Type: multipart/related; boundary="${i}"; type="multipart/alternative"`,``,...K0(i,e.text,t));for(let e of n)a.push(...G0(i,e));for(let e of r)a.push(...G0(i,e));return a.push(`--${i}--`),a}function q0(e){let t=e.images??[],n=t.filter(e=>e.placement===`inline`),r=t.filter(e=>e.placement===`attachment`),i=e.html!==void 0&&e.html.length>0?Eje(e.html,n):void 0;return i!==void 0&&n.length>0?kje(e,i,n,r).join(`\r
1115
1115
  `):r.length>0||n.length>0?Oje(e,i,r.length>0?r:n).join(`\r
1116
1116
  `):Dje(e,i).join(`\r