@camstack/addon-admin-ui 1.2.688 → 1.2.689

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 (91) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/assets/{Addons-2wfM1edN.js → Addons-DY29xpxZ.js} +1 -1
  3. package/dist/assets/{AdminPage-BGtK1GBq.js → AdminPage-BZ0d3KIi.js} +1 -1
  4. package/dist/assets/{AdminSectionedPage-CRtQpSxT.js → AdminSectionedPage-CivTk-bE.js} +1 -1
  5. package/dist/assets/{AiProfiles-BHwb3nSo.js → AiProfiles-tt4dx8wK.js} +1 -1
  6. package/dist/assets/{BootstrapSettingsForm-BS87l0cS.js → BootstrapSettingsForm-Cyk46Mh8.js} +1 -1
  7. package/dist/assets/{Build-DIVuAKYP.js → Build-CDp7r2o2.js} +1 -1
  8. package/dist/assets/{Calendars-CF3LuetJ.js → Calendars-DcanbjM1.js} +1 -1
  9. package/dist/assets/{CameraGrids-6UFohBNL.js → CameraGrids-D0rLrR4c.js} +1 -1
  10. package/dist/assets/{Cluster-mnQtI40N.js → Cluster-Dr-johc0.js} +1 -1
  11. package/dist/assets/{CompositionBlockEditor-CY2C2J8Z.js → CompositionBlockEditor-Dm8WVd7r.js} +1 -1
  12. package/dist/assets/{CompositionEditorPage-B37HL2Dz.js → CompositionEditorPage-BQzbI-bs.js} +1 -1
  13. package/dist/assets/{Data-C7m-cbr4.js → Data-DLn1T8hw.js} +1 -1
  14. package/dist/assets/{DeviceDetail-BBiCkxxi.js → DeviceDetail-BiT7xDfc.js} +1 -1
  15. package/dist/assets/{Devices-MX4ikexb.js → Devices-Dn8t45Xi.js} +1 -1
  16. package/dist/assets/EmbedDevicePage-BtrHGVT2.js +1 -0
  17. package/dist/assets/{EmbedPlayerPage-DRlowAOp.js → EmbedPlayerPage-Cpe5M1Q-.js} +1 -1
  18. package/dist/assets/{History-DqZqNlZz.js → History-BbdiSj1c.js} +1 -1
  19. package/dist/assets/{Identity-CM4Ortr-.js → Identity-C0GPwuiI.js} +1 -1
  20. package/dist/assets/InstancesTable-j-4OK4zO.js +1 -0
  21. package/dist/assets/{IntegrationDetail-CsdGAa7R.js → IntegrationDetail-jfy5nNNW.js} +1 -1
  22. package/dist/assets/{Integrations-DpijggGk.js → Integrations-BDNPovWf.js} +1 -1
  23. package/dist/assets/{Integrations-Dl7VYw1x.js → Integrations-beSlWUhd.js} +1 -1
  24. package/dist/assets/{Library-Bp85cSAL.js → Library-B2A58WTO.js} +1 -1
  25. package/dist/assets/{Locations-IZq43PGv.js → Locations-CisH18lP.js} +1 -1
  26. package/dist/assets/{Logs-CrDOCX6k.js → Logs-D7jdjIJK.js} +1 -1
  27. package/dist/assets/{MaskShapeCanvas-DjZ_ENJI.js → MaskShapeCanvas-CkL1-Z2p.js} +1 -1
  28. package/dist/assets/{MotionZonesSettings-BRV1q6cp.js → MotionZonesSettings-CglI9jLC.js} +1 -1
  29. package/dist/assets/{MyAccess-d5w8yPDS.js → MyAccess-BaeZoW7T.js} +1 -1
  30. package/dist/assets/{Network-A8Hzlr9I.js → Network-BRESDnEF.js} +1 -1
  31. package/dist/assets/{NodeAddonsSettingsPanel-CFTTKJTW.js → NodeAddonsSettingsPanel-Cs-4A2nm.js} +1 -1
  32. package/dist/assets/{Notifications-yofgwGYi.js → Notifications-BLIvNXbr.js} +1 -1
  33. package/dist/assets/{Pipeline-C58uJw5q.js → Pipeline-DQlV8HzY.js} +1 -1
  34. package/dist/assets/{PrivacyMaskSettings-YvPDriCm.js → PrivacyMaskSettings-Cfst7tBt.js} +1 -1
  35. package/dist/assets/{Recordings-CNS2YQnv.js → Recordings-BoAz9UAs.js} +1 -1
  36. package/dist/assets/{SceneMonitorEditor-DH2-nekM.js → SceneMonitorEditor-DPm4jF5N.js} +1 -1
  37. package/dist/assets/{ServerShell-W8Wp5cGt.js → ServerShell-CTyuWz03.js} +1 -1
  38. package/dist/assets/{SessionsList-CYvDTfln.js → SessionsList-CKIbxGRm.js} +1 -1
  39. package/dist/assets/{Showroom-DFesEW-P.js → Showroom-Ca4Y5ZQK.js} +1 -1
  40. package/dist/assets/StorageLocationsTable-C4W7zsGI.js +1 -0
  41. package/dist/assets/{System-B8KmJqiE.js → System-JFcPuvVK.js} +1 -1
  42. package/dist/assets/{TemplateEditorDialog-DTAAJR9z.js → TemplateEditorDialog-BqcmsBtt.js} +1 -1
  43. package/dist/assets/{Terminal-D0cZGsnW.js → Terminal-DpsQgC9x.js} +1 -1
  44. package/dist/assets/{TerminalPanel-J1w2vmDS.js → TerminalPanel-CGquUW8j.js} +1 -1
  45. package/dist/assets/{TrainingProviders-BFbXHvOM.js → TrainingProviders-CPNjxb58.js} +1 -1
  46. package/dist/assets/{Viewer-ZYjr8fFf.js → Viewer-CO1F-6xh.js} +1 -1
  47. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-D3ruWlC-.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-D0G_tF_l.js} +1 -1
  48. package/dist/assets/{action-draft-DNplCdnd.js → action-draft-Bg11zRAj.js} +1 -1
  49. package/dist/assets/{ai-page.helpers-CLp_BM_b.js → ai-page.helpers-CB1jbKz_.js} +1 -1
  50. package/dist/assets/{assignment-candidates-Cs1bHYCE.js → assignment-candidates-B6H3O80X.js} +1 -1
  51. package/dist/assets/{authed-media-D3P2p3qZ.js → authed-media-xniEMsSm.js} +1 -1
  52. package/dist/assets/{board-model-CEczoawG.js → board-model-B2JiEhiD.js} +1 -1
  53. package/dist/assets/{client-DIFc5Ulp.js → client-CuXMhtQa.js} +1 -1
  54. package/dist/assets/{command-vocab-Dp8EnV9z.js → command-vocab-CnGweFaG.js} +1 -1
  55. package/dist/assets/{device-detail-D28nIlrx.js → device-detail-DJ7UsGNh.js} +1 -1
  56. package/dist/assets/{device-integration-icon-CGnRiBbM.js → device-integration-icon-BL4OR8Tu.js} +1 -1
  57. package/dist/assets/device-picker-model-CmD_rtEB.js +1 -0
  58. package/dist/assets/{dist-GJ2aJJ7U.js → dist-BIKSreSn.js} +1 -1
  59. package/dist/assets/{dist-DVUXvJ_X.js → dist-b4Z4Rn9L.js} +1 -1
  60. package/dist/assets/{format-BqZcr5Z7.js → format-D-lO-1j1.js} +1 -1
  61. package/dist/assets/{hostInit-BCFIcylY.js → hostInit-DVaasUc0.js} +1 -1
  62. package/dist/assets/i18n-BXCE99oN.js +1 -0
  63. package/dist/assets/{icons-Cjxpx-EC.js → icons-C8z46zRV.js} +1 -1
  64. package/dist/assets/{index-CqFqTrNf.js → index-DltGFPYA.js} +3 -3
  65. package/dist/assets/{linked-devices-model-BIS0JhHd.js → linked-devices-model-Bz36XHKW.js} +1 -1
  66. package/dist/assets/{mf-entry-bootstrap-0-8782dcf2.js → mf-entry-bootstrap-0-a6b7ded2.js} +2 -2
  67. package/dist/assets/mount-CmD_rtEB.js +1 -0
  68. package/dist/assets/{notification-rule-status-ikR-6LJe.js → notification-rule-status-BprPUtT4.js} +1 -1
  69. package/dist/assets/{player-overlays-Cro1Q2AX.js → player-overlays-6CqWKNYt.js} +1 -1
  70. package/dist/assets/remoteEntry-DKzXIU3g.js +1 -0
  71. package/dist/assets/src-Ddt5cb2R.js +279 -0
  72. package/dist/assets/{sso-popup-Dd0yy6b3.js → sso-popup-CTYyuiaU.js} +1 -1
  73. package/dist/assets/{step-inspector-model-Dbe3pGib.js → step-inspector-model-BBqHZ2d-.js} +1 -1
  74. package/dist/assets/{use-scenes-feed-Cbr4UyCd.js → use-scenes-feed-Ci4MtEAr.js} +1 -1
  75. package/dist/assets/{use-stationary-objects-tm2lHAjw.js → use-stationary-objects-DK2HFw6V.js} +1 -1
  76. package/dist/assets/{useAdminDeviceRemoval-DNwUFqF2.js → useAdminDeviceRemoval-C2ITjRTs.js} +1 -1
  77. package/dist/assets/useEventInvalidation-CmD_rtEB.js +1 -0
  78. package/dist/assets/{useNodeUrlSelection-Cbif6CY8.js → useNodeUrlSelection-Dfowz4k5.js} +1 -1
  79. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CExmog1q.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-D4WQjLc3.js} +2 -2
  80. package/dist/index.html +8 -8
  81. package/dist/server/addon.js +7 -1
  82. package/package.json +2 -2
  83. package/dist/assets/EmbedDevicePage-DHBOCKzI.js +0 -1
  84. package/dist/assets/InstancesTable-CT4Kr3zo.js +0 -1
  85. package/dist/assets/StorageLocationsTable-D7z9VM03.js +0 -1
  86. package/dist/assets/device-picker-model-DMqoJA3J.js +0 -1
  87. package/dist/assets/i18n-CmzYiG85.js +0 -1
  88. package/dist/assets/mount-DMqoJA3J.js +0 -1
  89. package/dist/assets/remoteEntry-Cr4tLhkx.js +0 -1
  90. package/dist/assets/src-o5EApxkv.js +0 -279
  91. package/dist/assets/useEventInvalidation-DMqoJA3J.js +0 -1
@@ -1105,7 +1105,7 @@ ${d.map(({leaf:e,path:t})=>dfe(e,t)).join(`
1105
1105
  }
1106
1106
  }
1107
1107
  `}function Cfe(e){return`subjects`in e?e.subjects:e.classes.map(zh)}var wfe=new Set(Object.values(Ah.mapping));function Tfe(e){return Ah.mapping[e]??e}function Efe(e,t){let n=e.toLowerCase(),r=t.toLowerCase();return n===r?!0:wfe.has(n)&&Tfe(r)===n}function Dfe(e){return e===`start`||e===`update`||e===`end`}var Ofe=class{trigger;fired=new Map;subjects;constructor(e){this.trigger=e,this.subjects=Cfe(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`||!Dfe(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=Uh(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 kfe(e){return`classes`in e}function Afe(e){return e===`appeared`||e===`departed`}function jfe(e,t){let{deviceId:n,entryId:r,phase:i}=t;if(typeof n!=`number`||typeof r!=`string`||!Afe(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=kfe(e)?e.classes?.map(zh):e.subjects;if(c!==void 0){let e=Uh(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}}function I(e,t){return{en:e,it:t}}var X_=x({deviceId:p(),eventType:m(),sourceId:m().optional(),data:d(m(),u()).nullable(),timestamp:p().meta(k(`none`)),seq:p().meta(k(`count`))}),Z_=x({eventTypes:C(m()),vocabulary:C(Ap).default([]),lastEvent:X_.nullable(),eventCountSinceStart:p().meta(k(`count`))}),Q_={name:`event-emitter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.EventEmitter],methods:{},events:{onEvent:{data:X_,trigger:{category:w.EventEmitted,label:I(`Fired an event`,`Ha generato un evento`),phrase:I(`When {device} fires an event`,`Quando {device} genera un evento`),icon:`zap`}}},status:{schema:Z_,kind:`push`},runtimeState:Z_,durability:`session`,history:`none`,vocabulary:{noun:I(`Event source`,`Sorgente di eventi`),order:5280}},Mfe=3,Nfe=32;function Pfe(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`}function $_(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ffe(e){let t={},n=(e,r,i)=>{if(!(Object.keys(t).length>=Nfe)){if(Pfe(e)){t[r]=e;return}if(!(!$_(e)||i>=Mfe))for(let[t,a]of Object.entries(e))n(a,`${r}.${t}`,i+1)}};if($_(e))for(let[t,r]of Object.entries(e))n(r,`data.${t}`,1);return t}function Ife(e,t){let n=e;for(let e of t.split(`.`)){if(!$_(n))return;n=n[e]}return n}function Lfe(e,t){return t===null?!0:e.timestamp===t.timestamp?e.seq>t.seq:e.timestamp>t.timestamp}var Rfe=`recovered by reconcile`,zfe=class{leaf;#e=null;#t=!1;#n=null;constructor(e){this.leaf=e}onEvent(e){let t=X_.safeParse(e);if(!t.success)return{kind:`ignore`,why:`malformed event`};let n=t.data;return n.deviceId===this.leaf.deviceId?Lfe(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=Z_.safeParse(e);if(!t.success)return{kind:`ignore`,why:`the event-emitter status is unreadable`};this.#n=Pp(t.data);let n=t.data.lastEvent,r=!this.#t;return this.#t=!0,n===null?{kind:`ignore`,why:`the device has not fired`}:Lfe(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??Np([e.eventType]);return(Fp(t,e.eventType,e.sourceId)??Fp(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=Ffe(e.data);for(let t of a??[]){let n=Ife(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} — ${Rfe}`:l,vars:s,data:c}}},Bfe=6e4;function ev(e){return(e/Bfe).toFixed(1)}var Vfe=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*Bfe;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 ${ev(n)} min ago`};let r=`${ev(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 ${ev(n)} min ago, ${r}`}}},Hfe=S([`string`,`number`,`boolean`,`select`]),Ufe=/^[A-Za-z_][A-Za-z0-9_]*$/,tv=l([m(),p(),y()]),nv=x({name:m().regex(Ufe),label:m().min(1).max(120).optional(),type:Hfe,required:y().optional(),default:tv.optional(),options:C(m().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&&rv(e,e.default)!==null&&t.addIssue({code:`custom`,message:rv(e,e.default)??`invalid default`,path:[`default`]})});function rv(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 Wfe(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=rv(e,t);if(n!==null)return{ok:!1,error:n};i[e.name]=t}return{ok:!0,values:i}}var Gfe=S([`internal`,`addon`]),Kfe=`internal:`;function qfe(e){return`${Kfe}${e}`}function iv(e){return e.startsWith(`internal:`)&&e.length>9}function Jfe(e){if(iv(e))return null;let t=e.indexOf(`:`);return t>0&&t<e.length-1?e.slice(0,t):null}var Yfe=x({isRunning:y(),lastRunAt:p().nullable(),lastError:m().nullable()}),Xfe={isRunning:!1,lastRunAt:null,lastError:null},av=p().int().min(0).max(86400),ov=x({id:m().min(3),name:m().min(1).max(120),addonId:m().min(1),source:Gfe,readOnly:y(),steps:C(Hg).min(1).max(50).optional(),variables:C(nv).max(20).optional(),minDelaySec:av.optional(),tags:Qu.optional(),status:Yfe}).superRefine((e,t)=>{if(e.source===`internal`){iv(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`]}),Jfe(e.id)===null&&t.addIssue({code:`custom`,message:`an addon action id is <addonId>:<localId>`,path:[`id`]})}),sv=x({name:m().min(1).max(120),steps:C(Hg).min(1).max(50),variables:C(nv).max(20).optional(),minDelaySec:av.optional(),tags:Qu.optional()}),Zfe=x({blockId:m().min(1).optional()}),Qfe=l([__,s(`started`),s(`timed-out`)]),$fe=x({runId:m().min(1),outcome:Qfe,message:m().optional()}),epe=S([`not-found`,`read-only`,`invalid-variables`,`invalid-steps`,`not-linked`,`template-scope`,`busy`]),tpe=class extends Error{code;constructor(e,t){super(`[${e}] ${t}`),this.name=`ActionError`,this.code=e}},npe=x({actionId:m(),runId:m(),isRunning:y(),outcome:__.optional(),lastRunAt:p().nullable(),lastError:m().nullable()});function rpe(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 ipe(e){return[...e.kind===`command`&&e.target.kind===`devices`?[{actionId:e.actionId,ids:e.target.ids}]:[],...rpe(e).flatMap(ipe)]}async function ape(e,t){let n=e.flatMap(ipe);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){vp(e,void 0);for(let n of t)yp(e,n,i.get(n)??[])}}async function ope(e,t,n=Date.now,r,i,a){let o=r?.mirror??new Nde(I_(e));await o.refresh(t);let s=V_(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 spe(e){try{return await e()}catch(e){return{result:`unknown`,reason:e instanceof Error?e.message:String(e)}}}async function cpe(e){let t=e.now(),n=t+e.timeoutMs;for(;;){let r=await spe(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 lpe(e,t){return`timed out after ${e} s: ${t}`}function cv(e){return tc(e)}function lv(e){let t=cv(e);if(t===void 0)return[];let n=ph(t);return n===void 0?[t]:[t,...yh(n).filter(e=>e!==t)]}var uv=x({path:m(),deviceId:p().int().optional(),field:m(),value:p(),assumedUnit:m(),message:m()});function upe(e){let t=$m(e);return t instanceof se?t:void 0}function dv(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[...nh(r.schema),...r.itemArray===void 0?[]:rh(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=upe(i)?.shape[r];return a===void 0?void 0:Eh(a)}}}function dpe(e){return sh(e)??e}function fpe(e){return lv(e).length>1}function ppe(e){return{...e,message:`${e.field}: the bare number ${e.value} was taken as ${e.assumedUnit} — send { value, unit } to state the unit`}}function mpe(e,t){Ch({value:1,unit:e,target:t})}function hpe(e,t,n){let r=t.fieldQuantity(e.cap,e.fieldPath),i=r===void 0?void 0:cv(r),a=Sh(e.value)||e.unit!==void 0;if(i===void 0||r===void 0){if(a)throw new bh(`no-quantity`,`${e.cap}.${e.fieldPath} is not a quantity — it takes no unit`);return{leaf:e,warnings:[]}}if(Sh(e.value)){let t=Ch({value:e.value.value,unit:e.value.unit,target:i});return{leaf:{...e,value:t,unit:dpe(e.value.unit)},warnings:[]}}return typeof e.value==`number`?e.unit===void 0?fpe(r)?{leaf:e,warnings:[ppe({path:n,deviceId:e.deviceId,field:e.fieldPath,value:e.value,assumedUnit:i})]}:{leaf:e,warnings:[]}:(mpe(e.unit,i),{leaf:e,warnings:[]}):{leaf:e,warnings:[]}}function fv(e,t,n=`when`){switch(e.kind){case`device-is`:{let{leaf:r,warnings:i}=hpe(e,t,n);return{value:r,warnings:i}}case`not`:{let r=fv(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)=>fv(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 gpe(e,t,n){let r=e.target.kind===`devices`&&e.target.ids.length===1?e.target.ids[0]:void 0,{cap:i,method:a}=vp(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 bh(`no-quantity`,`${i}.${a}(${n}) is not a quantity — it takes no unit`);mpe(r,e.unit)}for(let[l,u]of Object.entries(e.args??{})){let e=t.paramMeta(i,a,l);e!==void 0&&(Sh(u)?(o[l]=Ch({value:u.value,unit:u.unit,target:e.unit}),s[l]=dpe(u.unit)):typeof u==`number`&&s[l]===void 0&&fpe(e.quantity)&&c.push(ppe({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 _pe(e,t,n=`steps`){let r=[],i=[];return e.forEach((e,a)=>{if(e.kind!==`command`){r.push(e);return}let o=gpe(e,t,`${n}.${a}`);r.push(o.value),i.push(...o.warnings)}),{value:r,warnings:i}}function vpe(e,t){let n=fv(e.when,t,`when`),r=_pe(e.actions,t,`actions`);return{value:{...e,when:n.value,actions:r.value},warnings:[...n.warnings,...r.warnings]}}function pv(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||lv(n).length<2)return e;let r=cv(n);return r===void 0?e:{...e,unit:r}}case`not`:return{...e,child:pv(e.child,t)};case`all`:case`any`:return{...e,children:e.children.map(e=>pv(e,t))};default:return e}}function ype(e,t){if(e.kind!==`command`||e.args===void 0)return e;let{cap:n,method:r}=vp(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&&lv(e.quantity).length>1&&(i[a]=e.unit)}return Object.keys(i).length===0?e:{...e,argUnits:i}}function mv(e,t){let n={...e,when:pv(e.when,t),actions:e.actions.map(e=>ype(e,t))};try{return{ok:!0,recipe:vpe(n,t).value}}catch(e){if(e instanceof bh)return{ok:!1,error:e.message};throw e}}var bpe=[`devices`,`time`,`cameras`,`events`,`logic`,`system`],hv=[`trigger`,`any`],gv=[`trigger`,`guard`,`any`],_v={detection:{kind:`detection`,category:`cameras`,role:`event`,allowedIn:hv,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:hv,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:hv,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:hv,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:hv,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:hv,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:hv,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:hv,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:gv,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:gv,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:gv,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:gv,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:gv,i18nKey:`automation.leafCatalog.expression`,keywords:[`formula`,`math`,`arithmetic`,`sum`,`compare`,`calculate`,`held`],needsDeviceValue:!1,seed:()=>({kind:`expression`,expr:``,bindings:{}})}},vv=[`detection`,`stationary`,`device-becomes`,`device-fired`,`device-event`,`schedule`,`interval`,`manual`,`device-is`,`stationary-present`,`time-is`,`triggered-by`,`expression`];function xpe(e){return _v[e]}function Spe(e){return _v[e].seed()}function Cpe(e){return vv.filter(t=>_v[t].allowedIn.includes(e))}function wpe(e){return e instanceof Error?e.message:String(e)}function Tpe(e){return e.startsWith(`[busy]`)?`already-running`:e.startsWith(`[not-found]`)?`not-found`:null}async function Epe(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=wpe(e),i=Tpe(n);return i===null?(t.warn(`${r}: exported action failed`,{tags:a,meta:{message:n}}),{status:`failed`,message:n}):o(i,n)}}async function Dpe(e,t,n){let{exporter:r,targetId:i}=n,a={targetId:i};try{let{targets:o,unreadable:s}=await ua(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:hi.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=wpe(e);return t.warn(`${r}: exported notifier send failed`,{tags:a,meta:{message:n}}),{status:`failed`,message:n}}}function Ope(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 yv=m().min(1),bv=x({instanceId:yv.optional()}),xv=x({instanceId:yv,name:m(),enabled:y(),kind:m().optional(),nameRule:m().optional()}),Sv=`export-instance-unknown`,kpe=class extends Error{code=Sv;instanceId;constructor(e,t){super(`${Sv}: ${e} serves no instance "${t}"`),this.name=`ExportInstanceUnknownError`,this.instanceId=t}};function Ape(e){return`instanceId`in e?e.instanceId:void 0}function jpe(e,t,n){if(n!==void 0&&n!==t)throw new kpe(e,n)}var Mpe=S([`unlinked`,`linked`,`error`]),Npe=x({label:m(),value:m(),secret:y().optional()}),Ppe=x({qr:m().optional(),fields:C(Npe).readonly().optional(),note:m().optional()}),Cv=x({linkState:Mpe,exposedDeviceCount:p(),error:m().optional(),setup:Ppe.optional()}),Fpe=m(),wv=x({deviceId:m(),exposedAs:m().optional(),exposedName:m().optional(),capabilities:C(m()).optional()}),Ipe=x({instanceId:yv,deviceId:m(),capabilities:C(m()).optional(),exposedName:m().nullable().optional()}),Lpe=x({instanceId:yv,deviceId:m(),name:m().nullable(),dryRun:y().optional()}),Tv=`export-name-refused`,Rpe=class extends Error{code=Tv;instanceId;reason;constructor(e,t){super(`${Tv}: ${t}`),this.name=`ExportNameRefusedError`,this.instanceId=e,this.reason=t}},zpe=x({instanceId:yv,deviceId:m()}),Ev=S([`device`,`action`,`notifier`]),Dv=a(`kind`,[x({kind:s(`device`),deviceId:m()}),x({kind:s(`action`),actionId:m().min(1)}),x({kind:s(`notifier`),targetId:m().min(1)})]),Ov=x({entity:Dv,exposedAs:m().optional()}),Bpe=x({instanceId:yv,entity:Dv}),Vpe=x({instanceId:yv,entity:Dv}),Hpe={name:`device-export`,scope:`system`,mode:`collection`,providerKind:`device-export`,status:{schema:Cv,kind:`poll`},exposesDeviceSettings:!0,methods:{getStatus:E(bv,Cv),listInstances:E(v(),C(xv)),listSupportedDeviceKinds:E(bv,C(Fpe)),listExposedDevices:E(bv,C(wv)),exposeDevice:E(Ipe,v(),{kind:`mutation`,auth:`admin`}),unexposeDevice:E(zpe,v(),{kind:`mutation`,auth:`admin`}),setExposedName:E(Lpe,v(),{kind:`mutation`,auth:`admin`}),listSupportedEntityKinds:D(v(),C(Ev)),listExposedEntities:D(bv,C(Ov)),exposeEntity:D(Bpe,v(),{kind:`mutation`,auth:`admin`}),unexposeEntity:D(Vpe,v(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`exports to other ecosystems — configured on the export pages`}},kv=`exposedNames`,Upe=d(m(),m());function Av(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 jv(e){let t=Upe.safeParse(e[kv]);return t.success?t.data:{}}function Wpe(e,t,n){let r=jv(e)[t];if(r===void 0)return null;let i=Av(r,n);return i.ok?i.name:null}function Mv(e,t,n){let r=Object.fromEntries(Object.entries(jv(e)).filter(([e])=>e!==t));return{[kv]:n===null?r:{...r,[t]:n}}}async function Gpe(e){let t=Av(e.raw,e.validate);if(!t.ok)throw new Rpe(e.instanceId,t.reason);if(e.dryRun===!0)return{changed:!1,name:t.name};let n=await e.store.read(e.deviceId);return(jv(n)[e.instanceId]??null)===t.name?{changed:!1,name:t.name}:(await e.store.write(e.deviceId,Mv(n,e.instanceId,t.name)),{changed:!0,name:t.name})}function Kpe(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 qpe(e,t){let n=await e.listDeviceStoreIds();if(n.length===0)return[];let r=[];for(let[i,a]of await e.readDeviceStoreBatch(n))jv(a)[t]!==void 0&&(await e.writeDeviceStore(i,Mv(a,t,null)),r.push(i));return r}function Jpe(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 Ype=[`automation`,`action`,`scheduler`,`composition`],Xpe=S(Ype),Zpe=x({id:p().int().nonnegative(),name:m().min(1),type:m().min(1),room:m().min(1).nullable(),addonId:m().min(1),stableId:m().min(1),caps:C(m().min(1)),zones:C(m().min(1)).optional()}),Qpe=x({timeZone:m().min(1),location:x({latitude:p(),longitude:p()}).nullable(),rooms:C(m().min(1)),devices:C(Zpe).min(1),actions:C(x({id:m().min(1),name:m().min(1)})).default([])}),$pe=x({childDeviceIds:C(p()).readonly(),hiddenChildIds:C(p()).readonly()}),eme={name:`accessories`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera,j.Switch,j.Light,j.Sensor,j.Climate,j.Cover,j.Lock,j.Fan,j.MediaPlayer,j.AlarmPanel,j.Generic],methods:{setChildHidden:E(x({deviceId:p().int().nonnegative(),childDeviceId:p().int().nonnegative(),hidden:y()}),v(),{kind:`mutation`,auth:`admin`})},events:{onAccessoriesChanged:{data:x({deviceId:p(),childDeviceIds:C(p()).readonly(),hiddenChildIds:C(p()).readonly()}),notOperatorFacing:`the device’s child list changed — administration, not a happening`},onChildVisibilityChanged:{data:x({deviceId:p(),childDeviceId:p(),hidden:y()}),notOperatorFacing:`an operator hid or showed a child — administration, not a happening`}},status:{schema:$pe,kind:`command-driven`},vocabulary:{noun:I(`Accessories`,`Accessori`),order:3e3}},tme={name:`action-source`,scope:`system`,mode:`collection`,methods:{listActions:E(x({}),C(ov),{auth:`admin`}),runAction:E(x({actionId:m().min(1),variables:d(m(),tv).optional()}),v(),{kind:`mutation`,auth:`admin`}),stopAction:E(x({actionId:m().min(1)}),v(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.INTERNAL}},nme=60*6e4,rme=3e4,ime=363e4;function ame(e){let t=0;for(let n of e)n.kind===`wait`&&(t+=n.seconds*1e3);return t}var Nv=x({actionId:m().min(1)}),Pv=x({deviceId:p().int().nonnegative(),actionIds:C(m().min(1)).max(100)}),ome={name:`actions`,scope:`system`,mode:`singleton`,methods:{list:E(x({}),C(ov),{auth:`admin`}),get:E(x({actionId:m().min(1),deviceId:p().int().nonnegative().optional()}),x({action:ov.nullable()}),{role:`viewer`,auth:`protected`,kind:`query`,caller:`required`}),run:E(x({actionId:m().min(1),variables:d(m(),tv).optional(),wait:y().optional(),origin:Zfe.optional(),deviceId:p().int().nonnegative().optional()}),$fe,{role:`viewer`,auth:`protected`,kind:`mutation`,caller:`required`,timeoutMs:ime}),stop:E(Nv,v(),{kind:`mutation`,auth:`admin`}),getTraces:E(Nv,x({traces:C(y_)}),{auth:`admin`}),create:E(x({action:sv}),x({action:ov,warnings:C(uv).optional()}),{kind:`mutation`,auth:`admin`}),update:E(x({actionId:m().min(1),action:sv.partial()}),x({action:ov,warnings:C(uv).optional()}),{kind:`mutation`,auth:`admin`}),delete:E(Nv,v(),{kind:`mutation`,auth:`admin`}),listForCamera:E(x({deviceId:p().int().nonnegative()}),C(ov),{role:`viewer`,auth:`protected`,kind:`query`}),getLinks:E(x({deviceId:p().int().nonnegative()}),Pv,{auth:`admin`}),setLinks:E(Pv,Pv,{kind:`mutation`,auth:`admin`})},events:{onRunChanged:{data:npe}},vocabulary:{notOperatorFacing:`declared actions — run from the Actions page and from the cameras that link them`}},sme=x({id:m(),label:m(),icon:m(),path:m(),remoteName:m(),bundle:m(),section:m().optional(),sectionLabel:m().optional()}),cme=x({addonId:m(),page:sme,bundleUrl:m()}),lme={name:`addon-pages`,scope:`system`,mode:`singleton`,methods:{listPages:E(v(),C(cme).readonly())},vocabulary:{notOperatorFacing:O.UI_PLUMBING}},ume=x({id:m(),label:m(),icon:m(),path:m(),remoteName:m(),bundle:m(),section:m().optional(),sectionLabel:m().optional()}),dme={name:`addon-pages-source`,scope:`system`,mode:`collection`,internal:!0,methods:{listPages:E(v(),C(ume).readonly(),{auth:`admin`})},vocabulary:{notOperatorFacing:O.UI_PLUMBING}},fme=x({method:S([`GET`,`POST`,`PUT`,`DELETE`,`PATCH`]),path:m(),access:S([`public`,`authenticated`,`admin`]).optional(),description:m().optional(),rateLimit:S([`auth`]).optional(),perInstance:y().optional()}),pme=x({method:m(),path:m(),params:d(m(),m()),query:d(m(),m()),body:u(),headers:d(m(),m()),instanceId:m().optional(),user:x({id:m(),username:m(),isAdmin:y()}).optional(),scopedToken:u().optional()}),mme=x({status:p().int(),headers:d(m(),m()),redirectUrl:m().nullable(),body:u().optional(),contentType:m().optional()}),hme={name:`addon-routes`,scope:`system`,mode:`collection`,internal:!0,methods:{getRoutes:E(v(),C(fme)),invoke:E(pme,mme,{kind:`mutation`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:O.UI_PLUMBING}},gme=x({id:m(),label:m(),icon:m(),order:p().optional()}),_me=x({id:m(),title:m(),titleKey:m().optional(),description:m().optional(),descriptionKey:m().optional(),style:S([`card`,`accordion`]).optional(),defaultCollapsed:y().optional(),columns:l([s(1),s(2),s(3),s(4)]).optional(),tab:m().optional(),location:S([`settings`,`top-tab`,`hero`]).optional(),order:p().optional(),fields:C(he())}),Fv=x({tabs:C(gme).optional(),sections:C(_me)}),Iv=d(m(),u()),Lv=S(tr),vme=x({cap:m(),scope:Lv,sectionIds:C(m())}),Rv=x({success:s(!0)}),yme={name:`addon-settings`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,methods:{getScopedSettings:E(x({addonId:m(),cap:m(),scope:Lv,nodeId:m().optional()}),Fv.nullable()),listScopedSettings:E(x({addonId:m(),nodeId:m().optional()}),C(vme).nullable()),updateScopedSettings:E(x({addonId:m(),cap:m(),scope:Lv,nodeId:m().optional(),patch:Iv}),Rv,{kind:`mutation`,auth:`admin`}),readScopedValues:E(x({addonId:m(),cap:m(),scope:Lv,nodeId:m().optional()}),d(m(),u()).nullable()),getDeclaredSettingsKeys:E(x({addonId:m(),nodeId:m().optional()}),x({keys:C(m())}).nullable(),{auth:`admin`}),unsetStoredSettingsKeys:E(x({addonId:m(),nodeId:m().optional(),keys:C(m())}),x({removed:C(m()),refused:C(x({key:m(),reason:m()})),secretsCleared:p()}),{kind:`mutation`,auth:`admin`}),getDeviceSettings:E(x({addonId:m(),deviceId:p(),nodeId:m().optional()}),Fv.nullable()),updateDeviceSettings:E(x({addonId:m(),deviceId:p(),nodeId:m().optional(),patch:Iv}),Rv,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.ADDON_ADMIN}},bme=S([`device-tab`,`dashboard`,`integration-detail`]),zv=S([`xs`,`sm`,`md`,`lg`,`xl`]),Bv=x({remoteName:m(),exposedModule:m(),componentKey:m().optional()}),Vv=x({tab:m(),subTab:m().optional(),label:m(),order:p().optional(),kind:s(`remote`),remote:Bv,stableId:m(),description:m().optional(),icon:m().optional(),bundle:m(),hosts:C(bme).readonly(),requires:x({deviceContext:y().default(!1),integrationContext:y().default(!1)}),preAuth:y().optional().default(!1),defaultSize:zv.default(`md`),allowedSizes:C(zv).readonly().default([`sm`,`md`,`lg`]),defaultColumns:p().int().min(1).max(12).default(6),defaultRows:p().int().min(1).max(12).default(1)}),xme={name:`addon-widgets-source`,scope:`system`,mode:`collection`,internal:!0,methods:{listWidgets:E(v(),C(Vv).readonly(),{auth:`admin`})},vocabulary:{notOperatorFacing:O.UI_PLUMBING}},Sme=Vv.extend({addonId:m(),bundleUrl:m()}),Cme={name:`addon-widgets`,scope:`system`,mode:`singleton`,methods:{listWidgets:E(v(),C(Sme).readonly())},vocabulary:{notOperatorFacing:O.UI_PLUMBING}},wme=S([`install`,`update`,`uninstall`,`restart`]),Hv=S([`queued`,`fetching`,`staged`,`validating`,`applying`,`restarting`,`applied`,`done`,`failed`,`skipped`]),Tme=S([`framework`,`addon`]),Eme=x({tsMs:p(),nodeId:m(),packageName:m(),phase:Hv,message:m()}),Dme=x({taskId:m(),nodeId:m(),packageName:m(),fromVersion:m().nullable(),toVersion:m(),target:Tme,phase:Hv,stagedPath:m().nullable(),attempts:p(),steps:C(Eme),error:m().nullable(),startedAtMs:p().nullable(),finishedAtMs:p().nullable()}),Ome=S([`running`,`completed`,`failed`,`partially-failed`,`cancelled`]),kme=S([`single`,`bulk`,`cluster`]),Uv=x({jobId:m(),kind:wme,createdAtMs:p(),createdBy:m(),scope:kme,tasks:C(Dme),state:Ome,schemaVersion:s(1)}),Ame=S([`debug`,`info`,`warn`,`error`]),Wv=S([`off`,`latest`,`beta`]),jme=S([`off`,`latest`,`beta`,`inherit`]),Mme=x({id:m(),name:m().optional(),version:m().optional(),description:m().optional(),icon:m().optional(),color:m().optional(),capabilities:C(u()).readonly().optional(),packageName:m(),packageVersion:m(),packageDisplayName:m().optional(),bundle:x({displayName:m(),description:m().optional(),icon:m().optional()}).optional(),protected:y().optional(),removable:y().optional(),integrationSection:S([`system`,`providers`]).optional()}),Nme=x({pid:p().optional(),mode:m(),state:m(),reason:m().optional()}),Pme=x({phase:S([`pending`,`healthy`,`failed`]),retryCount:p(),firstFailureAt:p().nullable(),lastAttemptAt:p().nullable(),lastError:x({message:m(),stack:m().optional()}).nullable(),nextRetryAt:p().nullable(),alertEmitted:y(),retrying:y(),inGracePeriod:y()}),Fme=x({manifest:Mme,declaration:u().optional(),source:m(),installSource:m().optional(),process:Nme.optional(),hasBackup:y().optional(),health:Pme.nullable().optional()}),Ime=x({name:m(),version:m(),dir:m(),installSource:m().optional()}),Lme=x({name:m(),currentVersion:m(),latestVersion:m(),category:S([`addon`,`core`]),requiresRestart:y(),isSystem:y(),blockedBy:C(Ir).readonly().optional()}),Rme=x({version:m(),publishedAt:m(),deprecated:m().optional(),distTags:C(m()).readonly()}),zme=a(`status`,[x({status:s(`ok`),markdown:m()}),x({status:s(`missing`)}),x({status:s(`error`),message:m()})]),Bme=x({name:m(),version:m(),readme:zme,changelog:zme}),Vme=x({name:m(),version:m(),description:m(),keywords:C(m()).readonly(),publishedAt:m(),author:m(),installed:y(),installedVersion:m().optional(),capabilities:C(m()).readonly().nullable()}),Gv=x({channel:Wv,intervalSeconds:p(),updateCheckIntervalSeconds:p()}),Kv=jme,Hme=u(),Ume=u(),Wme=u(),qv=S([`uninstalled`,`not-installed`,`refused`,`failed`,`pending-reconnect`]),Jv=x({nodeId:m(),outcome:qv,error:m().optional(),addonIds:C(m()).readonly(),runnersStopped:C(m()).readonly(),warnings:C(m()).readonly()}),Yv=x({success:y(),packageName:m(),results:C(Jv).readonly()}),Xv=x({packageName:m(),nodeId:m(),nodeName:m(),isHub:y(),isOnline:y(),version:m().nullable(),addonIds:C(m()).readonly(),source:S([`live`,`recorded`]),onHub:y()}),Zv=x({installations:C(Xv).readonly(),unreachable:C(x({nodeId:m(),error:m()})).readonly()}),Gme=S([`queued`,`updating`,`done`,`done-pending-restart`,`failed`]),Kme=x({name:m(),isSystem:y(),fromVersion:m(),toVersion:m(),status:Gme,error:m().optional(),startedAtMs:p().optional(),completedAtMs:p().optional()}),qme=S([`regular`,`system`,`restarting`,`finalizing`]);x({id:m(),nodeId:m(),startedAtMs:p(),completedAtMs:p().optional(),total:p(),completed:p(),failed:p(),current:m().nullable(),phase:qme,cancelled:y(),items:C(Kme).readonly()});var Jme=x({packageName:m(),currentVersion:m(),latestVersion:m().nullable(),hasUpdate:y(),description:m().optional(),buildId:m().nullable()}),Qv=x({timestamp:m(),level:m(),message:m(),scope:m().optional()}),Yme=u(),$v=x({addonId:m().min(1),action:m().min(1),input:u()}),ey={name:`addons`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,methods:{list:E(x({nodeId:m().optional()}).optional(),C(Fme).readonly()),getLogs:E(x({addonId:m(),limit:p().min(1).max(500).default(100),level:Ame.optional()}),C(Yme)),listPackages:E(v(),C(Ime).readonly()),installPackage:E(x({packageName:m(),version:m().optional()}),Ume,{kind:`mutation`,auth:`admin`}),uninstallPackage:E(x({packageName:m().min(1),nodeId:m().optional(),everywhere:y().optional()}),Yv,{kind:`mutation`,auth:`admin`}),listInstallations:E(x({packageName:m().optional()}),Zv,{auth:`admin`}),reloadPackages:E(v(),Wme,{kind:`mutation`,auth:`admin`}),searchAvailable:E(x({query:m().optional(),capability:m().optional()}),C(Vme)),listUpdates:E(x({nodeId:m().optional()}),C(Lme).readonly(),{auth:`admin`}),updatePackage:E(x({name:m().min(1),version:m().optional(),nodeId:m().optional()}),u(),{kind:`mutation`,auth:`admin`}),rollbackPackage:E(x({name:m().min(1)}),x({rolledBackTo:m().nullable()}),{kind:`mutation`,auth:`admin`}),forceRefresh:E(x({nodeId:m().optional()}),u(),{kind:`mutation`,auth:`admin`}),restartServer:E(x({confirm:s(!0)}),u(),{kind:`mutation`,auth:`admin`}),getLastRestart:E(v(),x({kind:S([`framework-update`,`manual`,`system`,`framework-bulk-update`]),packageName:m().optional(),fromVersion:m().optional(),toVersion:m().optional(),requestedBy:m().optional(),requestedAt:p()}).nullable(),{auth:`admin`}),listFrameworkPackages:E(v(),C(Jme).readonly(),{auth:`admin`}),listCapabilityProviders:E(x({capName:m().min(1)}),C(x({addonId:m(),mode:S([`singleton`,`collection`]),isActive:y()})).readonly()),setCapabilityProviderEnabled:E(x({capName:m().min(1),addonId:m().min(1),enabled:y()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),getVersions:E(x({name:m()}),C(Rme).readonly()),getPackageDocs:E(x({name:m().min(1),version:m().min(1).optional()}),Bme,{auth:`admin`}),restartAddon:E(x({addonId:m()}),Hme,{kind:`mutation`,auth:`admin`}),retryLoad:E(x({packageName:m()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),getAutoUpdateSettings:E(v(),Gv,{auth:`admin`}),setAutoUpdateSettings:E(x({channel:Wv,intervalSeconds:p().min(300).max(86400).optional(),updateCheckIntervalSeconds:p().min(900).max(604800).optional()}),u(),{kind:`mutation`,auth:`admin`}),getAddonAutoUpdate:E(x({addonId:m()}),Kv,{auth:`admin`}),setAddonAutoUpdate:E(x({addonId:m(),channel:jme}),u(),{kind:`mutation`,auth:`admin`}),applyAutoUpdateToAll:E(x({channel:Wv}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),custom:E($v,u(),{role:`viewer`,kind:`mutation`}),startJob:E(x({kind:S([`install`,`update`,`uninstall`,`restart`]),targets:C(x({name:m().min(1),version:m().min(1)})).min(1),nodeIds:C(m()).optional()}),x({jobId:m()}),{kind:`mutation`,auth:`admin`}),getJob:E(x({jobId:m()}),Uv.nullable(),{auth:`admin`}),listJobs:E(x({activeOnly:y().optional()}),C(Uv),{auth:`admin`}),cancelJob:E(x({jobId:m()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),onAddonLogs:E(x({addonId:m(),level:Ame.optional()}),Qv,{kind:`subscription`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:O.ADDON_ADMIN}},Xme=x({staticDir:m()}),Zme=x({version:m()}),ty={name:`admin-ui`,scope:`system`,mode:`singleton`,internal:!0,methods:{getStaticDir:E(v(),Xme,{auth:`admin`}),getVersion:E(v(),Zme,{auth:`admin`})},vocabulary:{notOperatorFacing:O.UI_PLUMBING}},ny=x({co2:p().min(0).optional().meta(k(`concentration-volume`)),voc:p().min(0).optional().meta(k(`concentration-ppb`)),pm25:p().min(0).optional().meta(k(`concentration-mass`)),pm10:p().min(0).optional().meta(k(`concentration-mass`)),aqi:p().optional().meta(k(`index`)),lastFetchedAt:p()}),ry={name:`air-quality-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor],methods:{},status:{schema:ny,kind:`push`},runtimeState:ny,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:I(`Air quality`,`Qualità dell’aria`),order:5e3,state:[{kind:`numeric`,field:`co2`,quantity:I(`the CO₂`,`la CO₂`),label:I(`CO₂`,`CO₂`),unit:`ppm`,icon:`wind`},{kind:`numeric`,field:`voc`,quantity:I(`the VOC level`,`il livello di COV`),label:I(`VOC`,`COV`),unit:`ppb`,icon:`wind`},{kind:`numeric`,field:`pm25`,quantity:I(`the PM2.5`,`il PM2,5`),label:I(`PM2.5`,`PM2,5`),unit:`µg/m³`,icon:`cloud-fog`},{kind:`numeric`,field:`pm10`,quantity:I(`the PM10`,`il PM10`),label:I(`PM10`,`PM10`),unit:`µg/m³`,icon:`cloud-fog`},{kind:`numeric`,field:`aqi`,quantity:I(`the air quality index`,`l’indice di qualità dell’aria`),label:I(`AQI`,`IQA`),icon:`wind`}]}},iy=S([`disarmed`,`armed_home`,`armed_away`,`armed_night`,`armed_vacation`,`armed_custom_bypass`,`arming`,`disarming`,`pending`,`triggered`]),ay=S([`home`,`away`,`night`,`vacation`,`custom_bypass`]),oy=x({state:iy,targetMode:ay.nullable().optional(),availableModes:C(ay),requiresCode:y(),lastChangedAt:p()}),sy={name:`alarm-panel`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.AlarmPanel],methods:{trigger:E(x({deviceId:p().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`alarm.trigger`,label:I(`Trigger alarm`,`Fai scattare l’allarme`),phrase:I(`Trigger the alarm on {device}`,`Fai scattare l’allarme su {device}`),icon:`siren`}]}),disarm:E(x({deviceId:p().int().nonnegative(),code:m().min(1).optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`alarm.disarm`,label:I(`Disarm`,`Disinserisci`),phrase:I(`Disarm {device}`,`Disinserisci {device}`),icon:`shield-off`,effect:{field:`state`,value:`disarmed`},openArgs:[{key:`code`,label:I(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]}),arm:E(x({deviceId:p().int().nonnegative(),mode:ay,code:m().min(1).optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`alarm.arm.home`,label:I(`Arm home`,`Inserisci in casa`),phrase:I(`Arm {device} for home`,`Inserisci {device} in modalità casa`),icon:`house`,effect:{field:`state`,value:`armed_home`},args:{mode:`home`},openArgs:[{key:`code`,label:I(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.away`,label:I(`Arm away`,`Inserisci fuori casa`),phrase:I(`Arm {device} for away`,`Inserisci {device} in modalità fuori casa`),icon:`shield-check`,effect:{field:`state`,value:`armed_away`},args:{mode:`away`},openArgs:[{key:`code`,label:I(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.night`,label:I(`Arm night`,`Inserisci notte`),phrase:I(`Arm {device} for the night`,`Inserisci {device} in modalità notte`),icon:`moon`,effect:{field:`state`,value:`armed_night`},args:{mode:`night`},openArgs:[{key:`code`,label:I(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.vacation`,label:I(`Arm vacation`,`Inserisci vacanza`),phrase:I(`Arm {device} for vacation`,`Inserisci {device} in modalità vacanza`),icon:`plane`,effect:{field:`state`,value:`armed_vacation`},args:{mode:`vacation`},openArgs:[{key:`code`,label:I(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.custom_bypass`,label:I(`Arm custom bypass`,`Inserisci con esclusioni`),phrase:I(`Arm {device} with its custom bypass`,`Inserisci {device} con le zone escluse`),icon:`shield-half`,effect:{field:`state`,value:`armed_custom_bypass`},args:{mode:`custom_bypass`},openArgs:[{key:`code`,label:I(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]})},status:{schema:oy,kind:`push`},runtimeState:oy,durability:`restored`,history:{fields:{state:{kind:`enum`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:I(`Alarm panel`,`Centrale d’allarme`),order:1120,state:[{kind:`enum`,field:`state`,label:I(`Alarm state`,`Stato dell’allarme`),values:[{value:`disarmed`,label:I(`Disarmed`,`Disinserito`),phrase:I(`When {device} is disarmed`,`Quando {device} viene disinserito`)},{value:`armed_home`,label:I(`Armed home`,`Inserito in casa`),phrase:I(`When {device} is armed for home`,`Quando {device} viene inserito in modalità casa`)},{value:`armed_away`,label:I(`Armed away`,`Inserito fuori casa`),phrase:I(`When {device} is armed for away`,`Quando {device} viene inserito in modalità fuori casa`)},{value:`armed_night`,label:I(`Armed night`,`Inserito notte`),phrase:I(`When {device} is armed for the night`,`Quando {device} viene inserito in modalità notte`)},{value:`armed_vacation`,label:I(`Armed vacation`,`Inserito vacanza`)},{value:`armed_custom_bypass`,label:I(`Armed with bypass`,`Inserito con esclusioni`)},{value:`arming`,label:I(`Arming`,`In inserimento`)},{value:`disarming`,label:I(`Disarming`,`In disinserimento`)},{value:`pending`,label:I(`Entry delay`,`Ritardo d’ingresso`)},{value:`triggered`,label:I(`Triggered`,`In allarme`),phrase:I(`When {device} goes off`,`Quando {device} scatta`)}],icon:`shield`}]}},cy=S([`info`,`success`,`warning`,`error`,`critical`]),Qme=x({addonId:m().min(1),action:m().min(1),input:d(m(),u()).optional()}),$me=x({label:m(),href:m().optional(),invoke:Qme.optional(),navigation:S([`app`,`server`]).optional()}),ly=S([`active`,`in-progress`,`completed`,`failed`,`dismissed`]),uy=x({type:m(),id:m()}),dy=x({id:m(),category:m(),severity:cy,title:m(),message:m(),action:$me.optional(),status:ly,progress:p().optional(),read:y(),createdAt:p(),updatedAt:p(),source:uy.optional(),metadata:d(m(),u()).optional()}),fy={name:`alerts`,scope:`system`,mode:`singleton`,methods:{emit:E(dy,v(),{kind:`mutation`}),update:E(x({alertId:m(),patch:dy.partial()}),v(),{kind:`mutation`}),list:E(x({unreadOnly:y().optional(),limit:p().optional()}).optional(),C(dy).readonly()),getUnreadCount:E(v(),p()),markRead:E(x({alertId:m()}),v(),{kind:`mutation`}),markAllRead:E(v(),v(),{kind:`mutation`}),dismiss:E(x({alertId:m()}),v(),{kind:`mutation`})},vocabulary:{notOperatorFacing:`the alert centre — read and acknowledged on its own page`}},py=x({illuminance:p().min(0).nullable().meta(k(`illuminance`,{precision:0,label:`Illuminance`})),lastFetchedAt:p()}),my={name:`ambient-light-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor],methods:{},status:{schema:py,kind:`push`},runtimeState:py,durability:`restored`,history:{fields:{illuminance:{kind:`gauge`,unit:`lx`,deadbandPct:10,minIntervalMs:6e4}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`Light level`,`Luminosità ambiente`),order:5010,state:[{kind:`numeric`,field:`illuminance`,quantity:I(`the light level`,`la luminosità`),label:I(`Illuminance`,`Illuminamento`),unit:`lx`,icon:`sun`}]}},hy={name:`audio-analysis`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[j.Camera],exposesDeviceSettings:!0,methods:{resolveDeviceSettings:E(x({deviceId:p()}),_e())},events:{onAudioLevel:si(x({deviceId:p(),rms:p(),dbfs:p()}),{notOperatorFacing:`a sound-level sample at stream rate; loud-noise rules belong to the detection pipeline`})},vocabulary:{noun:I(`Audio analysis`,`Analisi audio`),order:3010}},ehe=S([`jpeg`,`rgb`,`bgr`,`yuv420`,`gray`]),gy=x({data:_e(),format:ehe,width:p(),height:p(),timestamp:p()}),_y=x({x:p(),y:p(),w:p(),h:p()}),the=x({class:m(),originalClass:m(),score:p(),bbox:_y}),vy=x({data:b(Uint8Array),sampleRate:p(),channels:p(),timestamp:p(),deviceId:p().optional()}),yy=x({rms:p(),dbfs:p()}),by=x({className:m(),originalClass:m().optional(),score:p()}),xy=[`superseded`,`error`,`timeout`,`disposed`],Sy=a(`state`,[x({state:s(`classified`)}),x({state:s(`not-classified`),reason:S(xy)})]),Cy=x({level:yy,classification:x({labels:C(by).readonly(),inferenceMs:p()}).optional(),classifyOutcome:Sy,timestamp:p()}),wy=x({minConfidence:p().min(0).max(1).default(.3),allowedClasses:C(m()).default([])}),Ty=x({deviceId:p(),brokerId:m(),ingestNodeId:m(),settings:wy}),Ey=x({attached:y(),replaced:y()}),Dy=x({detached:y()}),Oy=x({labels:C(by).readonly(),rawLabels:C(by).readonly().optional(),inferenceMs:p()}),nhe=[{value:`auto`,label:`Auto (platform default)`},{value:`apple-soundanalysis`,label:`Apple SoundAnalysis (macOS 12+)`},{value:`yamnet-onnx`,label:`YAMNet ONNX (cross-platform)`}],rhe={audioBackend:`auto`,probedBestAudioBackend:``},ky={name:`audio-analyzer`,scope:`system`,mode:`singleton`,methods:{analyseChunk:E(x({chunk:vy,settings:wy}),Cy.nullable(),{kind:`mutation`}),classify:E(vy,Oy,{timeoutMs:3e4}),attachDevice:E(Ty,Ey,{kind:`mutation`}),detachDevice:E(x({deviceId:p()}),Dy,{kind:`mutation`}),isReady:E(v(),y()),dispose:E(v(),v(),{kind:`mutation`}),reprobeAudioEngine:E(v(),x({backend:m()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.PIPELINE}},Ay=S([`f32le`,`s16le`]),jy=x({codec:m(),canDecode:y(),canEncode:y(),label:m().optional()}),My=x({codec:m(),sourceSampleRate:p().int().positive(),sourceChannels:p().int().positive(),extraData:b(Uint8Array).optional(),targetSampleRate:p().int().positive(),targetChannels:p().int().positive(),targetFormat:Ay.optional(),idleMs:p().int().positive().optional(),tag:m().optional()}),Ny=x({codec:m(),sourceSampleRate:p().int().positive(),sourceChannels:p().int().positive(),sourceFormat:Ay.optional(),targetSampleRate:p().int().positive(),targetChannels:p().int().positive(),bitrateKbps:p().int().positive().optional(),idleMs:p().int().positive().optional(),tag:m().optional()}),Py=x({data:b(Uint8Array),sampleRate:p().int().positive(),channels:p().int().positive(),format:Ay,pts:p()}),Fy=x({data:b(Uint8Array),codec:m(),pts:p(),frameComplete:y()}),ihe=x({sessionId:m(),kind:S([`decode`,`encode`]),codec:m(),sourceSampleRate:p(),sourceChannels:p(),targetSampleRate:p(),targetChannels:p(),format:Ay,tag:m().optional(),createdAtMs:p(),lastActivityMs:p(),framesIn:p(),framesOut:p()}),Iy={name:`audio-codec`,scope:`system`,mode:`singleton`,preferredProvider:`decoder-nodeav`,methods:{listSupportedCodecs:E(v(),C(jy).readonly()),canHandle:E(x({codec:m(),kind:S([`decode`,`encode`])}),y()),createDecodeSession:E(My,x({sessionId:m(),nodeId:m()}),{kind:`mutation`}),createEncodeSession:E(Ny,x({sessionId:m(),nodeId:m()}),{kind:`mutation`}),closeSession:E(x({sessionId:m(),nodeId:m().optional()}),v(),{kind:`mutation`}),pushEncodedFrame:E(x({sessionId:m(),nodeId:m().optional(),data:b(Uint8Array),pts:p().optional()}),v(),{kind:`mutation`}),pullPcm:E(x({sessionId:m(),nodeId:m().optional(),maxCount:p().int().positive().default(8)}),C(Py)),pushPcm:E(x({sessionId:m(),nodeId:m().optional(),data:b(Uint8Array),pts:p().optional()}),v(),{kind:`mutation`}),pullEncoded:E(x({sessionId:m(),nodeId:m().optional(),maxCount:p().int().positive().default(8)}),C(Fy)),flushEncode:E(x({sessionId:m(),nodeId:m().optional()}),C(Fy),{kind:`mutation`}),listActiveSessions:E(v(),C(ihe).readonly())},vocabulary:{notOperatorFacing:O.INTERNAL}},Ly=x({className:m(),hits:p().int().nonnegative(),avgScore:p().min(0).max(1),peakScore:p().min(0).max(1)}),Ry=x({ts:p().int(),windowSec:p().int().positive(),level:x({rms:p(),dbfs:p()}),peakDbfs:p(),avgDbfs:p(),current:x({className:m(),score:p().min(0).max(1),timestamp:p().int()}).nullable(),byClass:C(Ly).readonly()}),zy=x({ts:p().int(),dbfs:p().nullable(),peakDbfs:p(),avgDbfs:p(),topClass:m().nullable(),topScore:p().min(0).max(1).nullable()}),By=x({points:C(zy).readonly(),effectiveSampleEveryMs:p().int().positive(),windowMsActual:p().int().nonnegative()}),Vy={name:`audio-metrics`,scope:`device`,mode:`singleton`,deviceTypes:[j.Camera],methods:{getCurrentSnapshot:E(x({deviceId:p()}),Ry.nullable()),getHistory:E(x({deviceId:p(),windowSec:p().int().positive().optional(),sampleEveryMs:p().int().positive().optional()}),By)},runtimeState:Ry,durability:`session`,history:`none`,vocabulary:{noun:I(`Audio metrics`,`Metriche audio`),order:3020}},Hy=x({userId:m(),username:m(),email:m().optional(),displayName:m().optional(),isAdmin:y().default(!1)}),Uy={name:`auth-provider`,scope:`system`,mode:`collection`,internal:!0,methods:{validateCredentials:E(x({username:m(),password:m()}),Hy.nullable(),{kind:`mutation`}),getLoginUrl:E(x({state:m()}),m()),handleCallback:E(d(m(),m()),Hy,{kind:`mutation`}),validateToken:E(x({token:m()}),Hy.nullable())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:O.IDENTITY}},Wy=x({enabled:y(),isRunning:y(),lastTriggeredAt:p(),lastError:m().nullable(),lastChangedAt:p()}),Gy={name:`automation-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Automation],methods:{enable:E(x({deviceId:p().int().nonnegative()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`haAutomation.enable`,label:I(`Enable automation`,`Abilita l’automazione`),phrase:I(`Enable {device}`,`Abilita {device}`),icon:`toggle-right`}]}),disable:E(x({deviceId:p().int().nonnegative()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`haAutomation.disable`,label:I(`Disable automation`,`Disabilita l’automazione`),phrase:I(`Disable {device}`,`Disabilita {device}`),icon:`toggle-left`}]}),trigger:E(x({deviceId:p().int().nonnegative(),skipCondition:y().optional()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`haAutomation.trigger`,label:I(`Trigger automation`,`Avvia l’automazione`),phrase:I(`Run {device} now`,`Esegui subito {device}`),icon:`workflow`}]})},status:{schema:Wy,kind:`push`},runtimeState:Wy,durability:`session`,history:`none`,vocabulary:{noun:I(`Automation`,`Automazione`),order:2100,state:[{kind:`boolean`,field:`enabled`,label:I(`Enabled`,`Abilitata`),whenTrue:I(`When {device} is enabled`,`Quando {device} viene abilitata`),whenFalse:I(`When {device} is disabled`,`Quando {device} viene disabilitata`),icon:`toggle-right`},{kind:`boolean`,field:`isRunning`,label:I(`Running`,`In esecuzione`),whenTrue:I(`When {device} starts running`,`Quando {device} parte`),whenFalse:I(`When {device} finishes`,`Quando {device} termina`),icon:`workflow`}]}},ahe=`.backup-snapshot`,ohe=`.backup-snapshot-partial`,Ky=30*6e4,qy=x({databases:C(x({databaseId:jo,livePath:m()}))}),Jy=x({name:m(),rows:p().int().nonnegative()}),Yy=x({livePath:m(),snapshotPath:m(),sizeBytes:p().int().nonnegative(),pageCount:p().int().nonnegative(),pageSize:p().int().positive(),tables:C(Jy),copyMs:p().nonnegative(),verifyMs:p().nonnegative(),takenAt:p()}),Xy=Yy.extend({databaseId:jo}),Zy=x({databaseId:jo}),Qy=Yy.extend({livePath:m(),snapshotPath:m(),databaseId:jo.optional()}),$y={name:`database-snapshot`,scope:`system`,mode:`singleton`,internal:!0,methods:{listDatabases:E(x({}),qy,{auth:`admin`}),writeSnapshot:E(Zy,Xy,{kind:`mutation`,auth:`admin`,timeoutMs:Ky})},vocabulary:{notOperatorFacing:O.INTERNAL}},eb=x({subId:m(),displayName:m(),description:m().optional(),kind:m(),triggerSupported:y(),restoreSupported:y()}).extend({id:m(),addonId:m(),enabled:y(),retentionCount:p(),label:m().optional(),lastSuccessAt:p().optional(),lastSuccessSizeBytes:p().optional(),cron:m().optional(),nextRunAt:p().optional(),lastAttemptAt:p().optional(),lastError:m().optional()}),tb=x({scheme:m(),keyId:m()}),nb=x({enabled:y(),active:x({keyId:m(),publicKey:m(),createdAt:p()}).nullable(),keys:C(x({keyId:m(),createdAt:p(),retiredAt:p().nullable()})).readonly()}),she=x({id:m(),filename:m(),createdAt:p(),sizeBytes:p(),label:m().optional(),locations:C(m()).readonly(),encryption:tb.optional(),databases:C(jo).readonly().optional()}),rb=x({id:m(),destinationId:m().optional(),label:m().optional(),createdAt:p(),sizeBytes:p(),locations:C(m()).optional(),encryption:tb.optional()}),ib=x({path:m(),kind:S([`file`,`dir`,`symlink`]),sizeBytes:p(),mtime:p()}),ab=x({archiveVersion:s(1),createdAt:p(),dataDir:m(),locations:C(m()),entries:C(ib),totalBytes:p(),totalFiles:p(),sqliteSnapshots:C(Qy).optional(),omittedDatabases:C(jo).optional()}),ob=x({name:m(),sizeBytes:p(),fileCount:p(),present:y()}),sb=S([`queued`,`running`,`succeeded`,`failed`,`cancelled`]),cb=S([`queued`,`building`,`uploading`,`done`]),lb=x({id:m(),state:sb,phase:cb,destinationIds:C(m()).readonly(),label:m().optional(),requestedAt:p(),startedAt:p().optional(),finishedAt:p().optional(),stagedBytes:p(),archiveSizeBytes:p().optional(),uploadedBytes:p(),completedDestinationIds:C(m()).readonly(),failedDestinationIds:C(m()).readonly(),error:m().optional(),queuePosition:p().int().min(1).optional()}),ub=x({runId:m(),queued:y(),joined:y(),cancelled:y(),entries:C(rb).readonly()}),db=x({id:m(),label:m(),cron:m(),enabled:y(),locationIds:C(m()).readonly(),retentionCount:p().int().min(1).max(1e3),dataSources:C(m()).readonly().optional(),databases:C(jo).readonly().optional(),lastAttemptAt:p().optional(),lastSuccessAt:p().optional(),lastError:m().optional(),nextRunAt:p().optional()}),fb={name:`backup`,scope:`system`,mode:`singleton`,methods:{listDestinations:E(v(),C(eb).readonly(),{auth:`admin`}),trigger:E(x({destinations:C(m()).optional(),locations:C(m()).optional(),label:m().optional(),retentionCount:p().int().min(1).max(1e3).optional(),databases:C(jo).optional()}).optional(),ub,{kind:`mutation`,auth:`admin`}),listRuns:E(v(),C(lb).readonly(),{auth:`admin`}),cancel:E(x({runId:m()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),list:E(v(),C(rb).readonly(),{auth:`admin`}),listLocations:E(v(),C(ob).readonly(),{auth:`admin`}),getEntries:E(x({destinationId:m(),backupId:m()}),ab.nullable(),{auth:`admin`}),restore:E(x({destinationId:m(),backupId:m(),locations:C(m()).optional(),backupSecretKey:m().optional()}),v(),{kind:`mutation`,auth:`admin`}),getEncryption:E(v(),nb,{auth:`admin`}),setupEncryption:E(x({}),x({keyId:m(),secretKey:m(),publicKey:m(),createdAt:p(),replacedKeyId:m().nullable()}),{kind:`mutation`,auth:`admin`}),disableEncryption:E(x({}),x({disabledKeyId:m().nullable()}),{kind:`mutation`,auth:`admin`}),checkBackupKey:E(x({backupSecretKey:m()}),x({valid:y(),keyId:m().nullable(),known:y(),active:y(),error:m().optional()}),{kind:`mutation`,auth:`admin`}),delete:E(x({destinationId:m(),backupId:m()}),v(),{kind:`mutation`,auth:`admin`}),listArchives:E(x({destinationId:m()}),C(she).readonly(),{auth:`admin`}),upsertDestinationPolicy:E(x({locationId:m(),enabled:y(),retentionCount:p().int().min(1).max(1e3),label:m().optional()}),v(),{kind:`mutation`,auth:`admin`}),previewSchedule:E(x({cron:m(),count:p().int().min(1).max(20).optional()}),x({ok:y(),error:m().optional(),nextRuns:C(p()).readonly()})),listSchedules:E(v(),C(db).readonly(),{auth:`admin`}),listAvailableDatabases:E(v(),x({answered:y(),databases:C(jo).readonly()}),{auth:`admin`}),upsertSchedule:E(x({id:m().optional(),label:m(),cron:m(),enabled:y(),locationIds:C(m()).readonly(),retentionCount:p().int().min(1).max(1e3),dataSources:C(m()).readonly().optional(),databases:C(jo).readonly().optional()}),db,{kind:`mutation`,auth:`admin`}),deleteSchedule:E(x({id:m()}),v(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`system backups — run and restored from the Backups page`}},pb=x({level:p().min(0).max(100).nullable().meta(k(`percentage`,{label:`Charge`})),charging:S([`dc`,`solar`,`none`,`unknown`]).meta({label:`Charging source`}),sleeping:y().meta({label:`Sleeping`}),lastUpdated:p().meta(k(`none`)),voltage:p().nullable().optional().meta(k(`voltage`,{label:`Voltage`})),lastContactAt:p().optional(),lastFullRefreshAt:p().optional(),binary:y().optional().meta({label:`Binary indicator`})}),mb=[j.Camera,j.Sensor,j.Button,j.Switch,j.PetFeeder,j.Container,j.Climate,j.EventEmitter],che={version:1,targets:[{id:`level`,cardinality:`scalar`,vocabulary:{cap:`battery`,stateField:`level`},deviceTypes:mb,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}]},hb={name:`battery`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:mb,methods:{wakeForStream:E(x({deviceId:p(),timeoutMs:p().int().min(500).max(3e4).default(8e3)}),x({awoke:y(),durationMs:p()}),{kind:`mutation`,notOperatorFacing:`a stream consumer wakes a sleeping camera to watch it; an automation that wants footage asks for the footage`})},composedMethods:{wakeForStream:{kind:`answer`,value:{awoke:!1,durationMs:0}}},events:{onStatusChanged:{data:x({deviceId:p(),status:pb}),notOperatorFacing:`the level / sleeping / charging state triggers each read one field of this change`}},status:{schema:pb,kind:`push`,empty:{level:null,charging:`unknown`,sleeping:!1,lastUpdated:0}},runtimeState:pb,durability:`restored`,history:{fields:{level:{kind:`gauge`,unit:`%`},voltage:{kind:`gauge`,unit:`V`}}},customize:che,volatileStateFields:[`lastUpdated`],vocabulary:{noun:I(`Battery`,`Batteria`),order:5240,state:[{kind:`numeric`,field:`level`,quantity:I(`the battery level`,`il livello della batteria`),label:I(`Battery`,`Batteria`),unit:`%`,icon:`battery`},{kind:`boolean`,field:`sleeping`,label:I(`Asleep`,`In sospensione`),whenTrue:I(`When {device} goes to sleep`,`Quando {device} va in sospensione`),whenFalse:I(`When {device} wakes up`,`Quando {device} si risveglia`),icon:`moon`},{kind:`enum`,field:`charging`,label:I(`Charging`,`Ricarica`),values:[{value:`dc`,label:I(`Charging from mains`,`In carica da rete`),phrase:I(`When {device} starts charging`,`Quando {device} inizia a caricarsi`)},{value:`solar`,label:I(`Charging from solar`,`In carica dal pannello solare`),phrase:I(`When {device} charges from its solar panel`,`Quando {device} si carica dal pannello solare`)},{value:`none`,label:I(`Not charging`,`Non in carica`),phrase:I(`When {device} stops charging`,`Quando {device} smette di caricarsi`)},{value:`unknown`,label:I(`Unknown`,`Sconosciuto`)}],icon:`battery-charging`}],extraEvents:[{category:w.DeviceAwake,label:I(`Woke up`,`Risvegliato`),phrase:I(`When {device} wakes up`,`Quando {device} si risveglia`),icon:`sun`},{category:w.DeviceSleeping,label:I(`Went to sleep`,`In sospensione`),phrase:I(`When {device} goes to sleep`,`Quando {device} va in sospensione`),icon:`moon`}]}},gb=x({on:y().meta({label:`On`}),lastChangedAt:p()}),_b={name:`binary`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor],methods:{},status:{schema:gb,kind:`push`},runtimeState:gb,durability:`restored`,history:{fields:{on:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:I(`Binary sensor`,`Sensore binario`),order:5020,state:[{kind:`boolean`,field:`on`,label:I(`On`,`Acceso`),whenTrue:I(`When {device} turns active`,`Quando {device} si attiva`),whenFalse:I(`When {device} turns inactive`,`Quando {device} si disattiva`),icon:`toggle-right`}],overrides:{byRole:{[N.MotionSensor]:{state:{on:{label:I(`Motion`,`Movimento`),whenTrue:I(`When {device} detects motion`,`Quando {device} rileva movimento`),whenFalse:I(`When motion clears on {device}`,`Quando il movimento su {device} cessa`),icon:`activity`}}},[N.ContactSensor]:{state:{on:{label:I(`Open`,`Aperto`),whenTrue:I(`When {device} opens`,`Quando {device} si apre`),whenFalse:I(`When {device} closes`,`Quando {device} si chiude`),icon:`door-open`}}},[N.LeakSensor]:{state:{on:{label:I(`Leak`,`Perdita`),whenTrue:I(`When {device} detects a leak`,`Quando {device} rileva una perdita`),whenFalse:I(`When {device} is dry again`,`Quando {device} torna asciutto`),icon:`droplets`}}},[N.SmokeSensor]:{state:{on:{label:I(`Smoke`,`Fumo`),whenTrue:I(`When {device} detects smoke`,`Quando {device} rileva fumo`),whenFalse:I(`When smoke clears on {device}`,`Quando il fumo su {device} si dirada`),icon:`alarm-smoke`}}},[N.COSensor]:{state:{on:{label:I(`Carbon monoxide`,`Monossido di carbonio`),whenTrue:I(`When {device} detects carbon monoxide`,`Quando {device} rileva monossido di carbonio`),whenFalse:I(`When the carbon monoxide clears on {device}`,`Quando il monossido su {device} rientra`),icon:`cloud-alert`}}},[N.GasSensor]:{state:{on:{label:I(`Gas`,`Gas`),whenTrue:I(`When {device} detects gas`,`Quando {device} rileva gas`),whenFalse:I(`When the gas clears on {device}`,`Quando il gas su {device} rientra`),icon:`flame`}}},[N.TamperSensor]:{state:{on:{label:I(`Tampered`,`Manomesso`),whenTrue:I(`When {device} is tampered with`,`Quando {device} viene manomesso`),whenFalse:I(`When the tamper alert on {device} clears`,`Quando l’allarme di manomissione di {device} rientra`),icon:`shield-alert`}}},[N.VibrationSensor]:{state:{on:{label:I(`Vibration`,`Vibrazione`),whenTrue:I(`When {device} vibrates`,`Quando {device} vibra`),whenFalse:I(`When {device} is still again`,`Quando {device} torna fermo`),icon:`vibrate`}}},[N.ConnectivitySensor]:{state:{on:{label:I(`Connected`,`Connesso`),whenTrue:I(`When {device} connects`,`Quando {device} si connette`),whenFalse:I(`When {device} disconnects`,`Quando {device} si disconnette`),icon:`wifi`}}},[N.SoundSensor]:{state:{on:{label:I(`Sound`,`Suono`),whenTrue:I(`When {device} hears a sound`,`Quando {device} sente un suono`),whenFalse:I(`When {device} is quiet again`,`Quando {device} torna silenzioso`),icon:`ear`}}},[N.BatterySensor]:{state:{on:{label:I(`Battery low`,`Batteria scarica`),whenTrue:I(`When the battery of {device} runs low`,`Quando la batteria di {device} si scarica`),whenFalse:I(`When the battery of {device} is fine again`,`Quando la batteria di {device} torna a posto`),icon:`battery-low`}}},[N.BinaryHelper]:{state:{on:{label:I(`On`,`Acceso`),whenTrue:I(`When {device} turns on`,`Quando {device} si accende`),whenFalse:I(`When {device} turns off`,`Quando {device} si spegne`),icon:`toggle-right`}}}}}}},vb=S([`unknown-source`,`not-admin`,`no-builder`,`no-ingress-url`,`unreachable`,`unknown-board`,`no-encryption-key`,`unreadable-config`]),lhe=x({sourceId:m(),name:m()}),uhe=x({configuration:m(),name:m(),address:m().nullable()}),yb=x({ok:s(!1),reason:vb,detail:m().optional()}),dhe=a(`ok`,[x({ok:s(!0),boards:C(uhe).readonly()}),yb]),fhe=a(`ok`,[x({ok:s(!0),key:m()}),yb]),bb={name:`board-key-source`,scope:`system`,mode:`collection`,methods:{listSources:E(v(),C(lhe).readonly(),{auth:`admin`}),listBoards:E(x({sourceId:m().min(1)}),dhe,{auth:`admin`}),getBoardKey:E(x({sourceId:m().min(1),configuration:m().min(1)}),fhe,{auth:`admin`})},vocabulary:{notOperatorFacing:O.INTERNAL}},xb=x({level:p().min(0).max(100).meta(k(`percentage`)),lastChangedAt:p()}),Sb={name:`brightness`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Light],methods:{setBrightness:E(x({deviceId:p().int().nonnegative(),level:p().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`brightness.full`,label:I(`Full brightness`,`Luminosità massima`),phrase:I(`Set {device} to full brightness`,`Porta {device} alla massima luminosità`),icon:`sun`,effect:{field:`level`,value:100},args:{level:100}},{id:`brightness.half`,label:I(`Half brightness`,`Luminosità a metà`),phrase:I(`Dim {device} to half`,`Abbassa {device} a metà luminosità`),icon:`sun-dim`,effect:{field:`level`,value:50},args:{level:50}},{id:`brightness.off`,label:I(`Brightness off`,`Luminosità a zero`),phrase:I(`Dim {device} to zero`,`Abbassa {device} a zero`),icon:`lightbulb-off`,effect:{field:`level`,value:0},args:{level:0}},{id:`brightness.set`,label:I(`Set brightness`,`Imposta la luminosità`),phrase:I(`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:I(`Percentage`,`Percentuale`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]})},events:{onBrightnessChanged:{data:x({deviceId:p(),level:p().min(0).max(100),lastChangedAt:p()}),notOperatorFacing:"the `level` state trigger reads the same change"}},status:{schema:xb,kind:`command-driven`},runtimeState:xb,durability:`session`,history:{fields:{level:{kind:`gauge`,unit:`%`,minIntervalMs:0}}},vocabulary:{noun:I(`Brightness`,`Luminosità`),order:1010,state:[{kind:`numeric`,field:`level`,quantity:I(`the brightness`,`la luminosità`),label:I(`Brightness`,`Luminosità`),unit:`%`,icon:`sun`}]}},phe=S([`connected`,`disconnected`,`connecting`,`auth-failed`,`unreachable`,`error`]),Cb=x({brokerCount:p().int().nonnegative(),connectedCount:p().int().nonnegative()}),mhe=x({id:m()}),hhe=d(m(),u()),wb=x({brokerId:m(),target:d(m(),u()),payload:u().optional()}),Tb=x({brokerId:m(),filter:d(m(),u())}),Eb=x({subscriptionId:m()}),Db=x({brokerId:m(),subscriptionId:m()}),Ob=x({brokerId:m(),key:m()}),kb={name:`broker`,scope:`system`,mode:`collection`,providerKind:`broker`,status:{schema:Cb,kind:`poll`},methods:{getBrokerConfig:E(mhe,hhe.nullable(),{auth:`admin`}),publish:E(wb,u(),{kind:`mutation`,auth:`admin`}),subscribe:E(Tb,Eb,{kind:`mutation`,auth:`admin`}),unsubscribe:E(Db,v(),{kind:`mutation`,auth:`admin`}),getState:E(Ob,u().nullable(),{auth:`admin`}),getStatus:E(v(),Cb)},vocabulary:{notOperatorFacing:`message-broker connections — configured, not actuated`}},Ab={name:`button`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Button],methods:{press:E(x({deviceId:p().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`button.press`,label:I(`Press`,`Premi`),phrase:I(`Press {device}`,`Premi {device}`),icon:`circle-dot`}]})},vocabulary:{noun:I(`Button`,`Pulsante`),order:1130}},jb=S([`ha`,`addon`]),Mb=x({id:m().min(1),name:m().min(1),source:jb,enabled:y(),instanceId:m().min(1).optional()}),Nb=x({id:m().min(1),calendarId:m().min(1),title:m(),startMs:p().int(),endMs:p().int(),allDay:y().optional(),description:m().optional(),location:m().optional()}),Pb=x({calendarIds:C(m().min(1)).max(64).optional(),startMs:p().int(),endMs:p().int()}),Fb={name:`calendar-source`,scope:`system`,mode:`collection`,internal:!0,providerKind:`calendar`,methods:{listCalendars:E(v(),C(Mb).readonly(),{auth:`admin`}),listEvents:E(Pb,C(Nb).readonly(),{auth:`admin`})},vocabulary:{notOperatorFacing:O.INTERNAL}};function Ib(e){let t=new Date(e);return new Date(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()).getTime()}function Lb(e){if(e.allDay!==!0)return{startMs:e.startMs,endMs:e.endMs};let t=Ib(e.startMs),n=Ib(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 Rb(e,t){let n=new Date(t),r=new Date(n.getFullYear(),n.getMonth(),n.getDate()+1).getTime(),i=Lb(e);return i.startMs<r&&i.endMs>t}var zb=m().regex(/^#[0-9A-Fa-f]{6}$/,`expected #RRGGBB`),Bb=Mb.extend({id:m().min(1),providerAddonId:m().min(1).optional(),defaultColor:zb,color:zb,visible:y()}),Vb=x({visible:y().optional(),color:zb.optional()}),Hb=x({calendars:d(m(),Vb)}),Ub=x({calendarId:m().min(1),visible:y().optional(),color:zb.nullable().optional()}),Wb={name:`calendars`,scope:`system`,mode:`singleton`,methods:{listCalendars:E(v(),C(Bb).readonly(),{auth:`admin`}),listEvents:E(Pb,C(Nb).readonly(),{auth:`admin`}),getPreferences:E(x({}),Hb,{auth:`admin`,caller:`required`}),setCalendarPreference:E(Ub,Hb,{auth:`admin`,kind:`mutation`,caller:`required`})},vocabulary:{notOperatorFacing:`calendars feed schedules and conditions, not device actions`}},Gb=x({host:m(),port:p().int().positive().optional(),onvifPort:p().int().positive().optional(),rtspPort:p().int().positive().optional(),https:y().optional(),username:m().optional(),password:m().optional(),onvifProfile:m().optional()}),Kb=x({host:m(),port:p().int().positive().nullable(),onvifPort:p().int().positive().nullable(),rtspPort:p().int().positive().nullable(),https:y().nullable(),hasUsername:y(),hasPassword:y(),onvifProfile:m().nullable()}),qb={name:`camera-credentials`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],methods:{getCredentials:E(x({deviceId:p()}),Gb.nullable(),{kind:`query`,auth:`admin`})},status:{schema:Kb,kind:`command-driven`},vocabulary:{noun:I(`Camera credentials`,`Credenziali della telecamera`),order:3030}},Jb=x({x:p().min(0).max(1),y:p().min(0).max(1),width:p().gt(0).max(1),height:p().gt(0).max(1)}),Yb=x({deviceId:p().int().positive(),source:Jb,cell:Jb}),ghe=x({profile:S([`high`,`mid`,`low`]),offered:y(),missingSources:C(p().int().positive()),canvas:m(),published:y()}),Xb=x({instanceId:m(),deviceId:p().int().nonnegative(),name:m(),fps:p().int(),cells:C(Yb),profiles:C(ghe)}),Zb=x({deviceId:p().int().nonnegative(),name:m().min(1).max(160).optional(),fps:p().int().min(1).max(60).optional(),publishedProfiles:C(S([`high`,`mid`,`low`])).max(3).optional(),cells:C(Yb).max(16)}),Qb={name:`camera-grid-layout`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],exposesDeviceSettings:!0,methods:{getLayout:E(x({deviceId:p().int().nonnegative()}),Xb.nullable(),{auth:`admin`}),saveLayout:E(Zb,Xb,{kind:`mutation`,auth:`admin`})},vocabulary:{noun:I(`Grid layout`,`Layout a griglia`),order:3040}},$b={name:`camera-pipeline-config`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[j.Camera],exposesDeviceSettings:!0,methods:{},vocabulary:{noun:I(`Detection settings`,`Impostazioni di rilevamento`),order:3050}},ex=S([`webrtc`,`hls`,`mjpeg`,`rtsp`]),tx=S([`mp4`,`gif`]),nx=x({kind:tx,handle:m(),nodeId:m(),mime:m(),bytes:p().int(),width:p().int(),height:p().int()}),rx=x({fromTs:p(),toTs:p(),packets:p().int()}),ix=x({media:C(nx).readonly(),coverage:rx,profile:A,video:S([`copy`,`encode`])}),ax=x({brokerId:m(),url:m(),mutedUrl:m(),enabled:y(),codec:m().optional(),resolution:x({width:p().int().positive(),height:p().int().positive()}).optional()}),ox=x({sessionId:m(),remoteAddr:m(),userAgent:m().nullish(),playing:y(),muted:y(),connectedAt:p(),lastRtpAt:p(),bytesSent:p()}),sx=x({tag:m(),subscribedAt:p(),chunksDelivered:p()}),cx=S([`alexa`,`homekit`,`webrtc-browser`,`webrtc-mobile`,`webrtc-whep`,`rtsp-listen`,`derived-broker`,`recording`,`pipeline`,`snapshot`,`warmup`,`unknown`]),lx=x({kind:cx,label:m().optional(),media:S([`audio`,`video`,`both`]).optional(),targetCodec:m().optional(),transport:S([`passthrough`,`repacketize`,`transcode`]).optional(),remoteAddr:m().optional(),userAgent:m().optional(),userId:m().optional(),sessionId:m().optional(),extra:d(m(),m()).optional()}).readonly(),ux=x({id:m(),channel:S([`annexb`,`rtp`]),attribution:lx,subscribedAt:p(),packetsDelivered:p()}),dx=x({rtsp:C(ox).readonly(),audio:C(sx).readonly(),encoded:C(ux).readonly(),pipeClients:p(),encodedSubscribers:p()}),fx=x({deviceId:p().int().nonnegative(),viewers:p().int().positive()}),_he=S([`reconnecting`,`sleeping`,`offline`,`disabled`,`waking`]),vhe=S([`h264`,`h265`,`copy`]),yhe=S([`aac`,`opus`,`pcmu`,`copy`,`none`]),px=x({deviceId:p().int().nonnegative(),video:vhe,audio:yhe.optional(),profile:A.optional(),targetResolution:x({width:p().int().positive(),height:p().int().positive()}).optional(),outputArgs:C(m()).optional(),audioEgress:y().optional(),hostname:m().optional(),tag:m().optional()}),mx=x({url:m(),sentryUrl:m().nullable().optional(),videoCodec:S([`H264`,`H265`]),audioCodec:m(),resolution:x({width:p().int().positive(),height:p().int().positive()}),transcoded:y(),encoder:m(),pipelineKey:m()}),hx=pa.omit({inputArgs:!0,outputArgs:!0}),gx=S([`tight`,`relaxed`]),_x=x({deviceId:p().int().nonnegative(),source:a(`kind`,[x({kind:s(`profile`),profile:A}),x({kind:s(`cam-stream`),camStreamId:m().min(1)})]),encode:hx,rateControl:gx.optional(),bitstreamFilter:S([`dump_extra`,`h264_mp4toannexb`,`hevc_mp4toannexb`]).optional(),publishLocally:y().optional(),pixelFormat:S([`yuv420p`,`nv12`]).optional(),decodeHwAccel:S([`auto`,`none`,`videotoolbox`,`vaapi`,`qsv`,`cuda`]).optional(),hostname:m().optional(),tag:m().optional()}),vx=x({url:m(),pipelineKey:m(),videoCodec:S([`H264`,`H265`]),resolution:x({width:p().int().positive(),height:p().int().positive()}),transcoded:y(),encoder:m(),decodeHwAccel:m().nullable(),camStreamId:m().nullable()}),yx={name:`stream-broker`,scope:`system`,mode:`singleton`,exposesDeviceSettings:!0,methods:{reportStreamSignal:E(x({deviceId:p().int().nonnegative(),code:m().min(1),at:p().optional()}),x({accepted:y(),reason:S([`woke`,`hold-extended`,`not-enabled`,`no-consumer`,`unknown-code`])}),{kind:`mutation`}),publishCameraStream:E(x({deviceId:p().int().nonnegative(),camStreamId:m().min(1),kind:sc,url:m().optional(),codec:m().optional(),resolution:cc.optional(),fps:p().positive().optional(),label:m().optional(),deviceFeatures:C(m()).optional(),autoEligible:y().optional(),profileHint:A.optional(),metadata:d(m(),u()).optional(),sourceCamStreamId:m().min(1).optional(),encodeProfile:pa.optional()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),retractCameraStream:E(x({deviceId:p().int().nonnegative(),camStreamId:m().min(1)}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),assignProfile:E(x({deviceId:p().int().nonnegative(),profile:A,camStreamId:m().min(1)}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),unassignProfile:E(x({deviceId:p().int().nonnegative(),profile:A}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),forgetDeviceHardware:E(x({deviceId:p().int().nonnegative()}),x({derivedStreamsDeleted:C(m()).readonly(),assignmentsPurged:y(),probeSnapshotsDropped:p().int().nonnegative(),rtspTokenRowsDeleted:p().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),renderPreBufferClip:E(x({deviceId:p(),profile:A.optional(),aroundMs:p(),preRollSec:p().min(0).max(20).default(3),postRollSec:p().min(0).max(20).default(5),format:S([`gif`,`mp4`]).default(`gif`),maxWidth:p().int().min(120).max(1920).default(480),fps:p().int().min(1).max(15).default(5),speed:p().min(1).max(8).default(2)}),x({base64:m(),mime:m(),bytes:p().int(),profile:A,durationMs:p()}),{kind:`mutation`,auth:`admin`}),produceEventMedia:E(x({deviceId:p(),profile:A.optional(),aroundMs:p(),preSeconds:p().min(0).max(20).default(4),postSeconds:p().min(0).max(20).default(6),kinds:C(tx).min(1).default([`mp4`]),gifMaxWidth:p().int().min(120).max(1280).default(640),gifFps:p().int().min(1).max(15).default(12),gifSpeed:p().min(1).max(8).default(4),speed:p().min(1).max(8).default(4)}),ix,{kind:`mutation`,auth:`admin`}),fetchEventMedia:E(x({handle:m()}),x({base64:m(),mime:m(),bytes:p().int()}).nullable(),{kind:`mutation`,auth:`admin`}),listAllCameraStreams:E(v(),C(lc).readonly()),listAllProfileSlots:E(v(),C(dc).readonly()),getBrokerStats:E(x({brokerId:m()}),xc),probeStream:E(x({brokerId:m()}),x({probed:y(),summary:m()}),{kind:`mutation`,auth:`admin`}),listClients:E(x({brokerId:m()}),dx),getLiveViewerCounts:E(v(),C(fx).readonly(),{role:`viewer`}),killClient:E(x({brokerId:m(),channel:S([`rtsp`,`audio`]),handle:m()}),x({killed:y()}),{kind:`mutation`,auth:`admin`}),restartProfile:E(x({deviceId:p().int().nonnegative(),profile:A}),x({success:y()}),{kind:`mutation`,auth:`admin`}),getStreamUrl:E(x({streamId:m(),format:ex}),x({url:m()})),getStreamWithCodec:E(px,mx,{kind:`mutation`,auth:`admin`}),releaseStreamWithCodec:E(x({pipelineKey:m()}),x({released:y(),refcount:p().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),acquireEgressTranscode:E(_x,vx,{kind:`mutation`,auth:`admin`}),releaseEgressTranscode:E(x({pipelineKey:m()}),x({released:y(),refcount:p().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),subscribeAudioChunks:E(vc,yc,{kind:`mutation`}),pullAudioChunks:E(x({subscriptionId:m(),maxCount:p().int().positive().default(8)}),C(_c).readonly()),unsubscribeAudioChunks:E(x({subscriptionId:m()}),x({released:y()}),{kind:`mutation`}),setPreBufferDuration:E(x({brokerId:m(),seconds:p().min(0).max(30)}),v(),{kind:`mutation`,auth:`admin`}),getPreBufferInfo:E(x({brokerId:m()}),x({configuredSec:p(),bufferedMs:p(),packetCount:p()})),getRtspPort:E(v(),p()),getAllRtspEntries:E(x({hostname:m().optional()}),C(ax).readonly()),getRtspEntry:E(x({brokerId:m(),hostname:m().optional()}),ax.nullable()),regenerateRtspToken:E(x({brokerId:m()}),m().nullable(),{kind:`mutation`,auth:`admin`}),setRtspEnabled:E(x({brokerId:m(),enabled:y()}),v(),{kind:`mutation`,auth:`admin`}),isRtspEnabled:E(x({brokerId:m()}),y()),getDeviceAudioMute:E(x({deviceId:p().int()}),x({muted:y(),appliedBrokers:p().int().nonnegative()})),setDeviceAudioMute:E(x({deviceId:p().int(),muted:y()}),x({muted:y(),appliedBrokers:p().int().nonnegative()}),{kind:`mutation`,auth:`admin`})},events:{onCamStreamDemand:si(x({deviceId:p().int().nonnegative(),camStreamId:m(),profile:A})),onCamStreamIdle:si(x({deviceId:p().int().nonnegative(),camStreamId:m()})),onRequestStreamSourceRefresh:si(x({deviceId:p().int().nonnegative(),camStreamId:m(),brokerId:m()}))},vocabulary:{notOperatorFacing:O.PIPELINE}},bx=S([`h264`,`h265`,`hevc`,`av1`,`mjpeg`,`vp8`,`vp9`]),xx=x({acceptCodecs:C(bx).readonly().optional(),minHeight:p().int().positive().optional(),maxHeight:p().int().positive().optional(),minWidth:p().int().positive().optional(),excludeDerived:y().optional(),requireSiblingCodec:C(bx).readonly().optional(),allowTranscode:y().optional(),requireProfileBound:y().optional()}).readonly(),Sx=x({preferredProviders:C(m()).readonly().optional(),resolutionPreference:S([`highest`,`lowest`]).optional(),targetHeight:p().int().positive().optional()}).readonly(),Cx=x({camStreamId:m(),codec:m().optional(),resolution:cc.optional(),transcodes:y(),reason:m(),profile:A.optional(),brokerId:m().optional(),url:m().optional(),fps:p().positive().optional(),fpsSource:S([`published`,`measured`]).optional()}),wx={name:`camera-streams`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[j.Camera],methods:{getCameraStreams:E(x({deviceId:p().int().nonnegative()}),C(lc).readonly()),getBrokerStreams:E(x({deviceId:p().int().nonnegative()}),C(dc).readonly()),getRtspEntries:E(x({deviceId:p().int().nonnegative(),hostname:m().optional()}),C(ax).readonly()),getProfileRtspEntries:E(x({deviceId:p().int().nonnegative(),hostname:m().optional()}),C(Sc).readonly()),pickStream:E(x({deviceId:p().int().nonnegative(),requirements:xx,preferences:Sx.optional()}),Cx.nullable())},events:{onCamStreamsChanged:si(x({deviceId:p().int().nonnegative(),camStreams:C(lc).readonly()}),{notOperatorFacing:`the stream catalog was rebuilt — plumbing, not a happening`}),onProfileSlotsChanged:si(x({deviceId:p().int().nonnegative(),profileSlots:C(dc).readonly()}),{notOperatorFacing:`stream profiles were reassigned — plumbing, not a happening`})},runtimeState:x({online:y(),slotStatuses:x({high:uc.optional(),mid:uc.optional(),low:uc.optional()}),slotErrors:x({high:m().optional(),mid:m().optional(),low:m().optional()}),lastChangedAt:p()}),durability:`session`,history:`none`,vocabulary:{noun:I(`Camera streams`,`Flussi della telecamera`),order:3060}},Tx=x({detected:y(),lastChangedAt:p()}),Ex={name:`carbon-monoxide`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor],methods:{},status:{schema:Tx,kind:`push`},runtimeState:Tx,durability:`restored`,history:{fields:{detected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:I(`Carbon monoxide`,`Monossido di carbonio`),order:5030,state:[{kind:`boolean`,field:`detected`,label:I(`Detected`,`Rilevato`),whenTrue:I(`When {device} detects carbon monoxide`,`Quando {device} rileva monossido di carbonio`),whenFalse:I(`When the carbon monoxide clears on {device}`,`Quando il monossido su {device} rientra`),icon:`cloud-alert`}]}},Dx=S([`off`,`heat`,`cool`,`auto`,`heat_cool`,`fan_only`,`dry`]),Ox=S([`heating`,`cooling`,`drying`,`fan`,`idle`,`off`]),kx=x({mode:Dx,action:Ox.nullable().optional(),availableModes:C(Dx),fanMode:m(),availableFanModes:C(m()),preset:m(),availablePresets:C(m()),target:p().nullable().meta(k(`temperature`)),targetHigh:p().nullable().meta(k(`temperature`)),targetLow:p().nullable().meta(k(`temperature`)),targetHumidity:p().min(0).max(100).nullable().meta(k(`humidity`)),currentTemp:p().nullable().meta(k(`temperature`)),currentHumidity:p().min(0).max(100).nullable().meta(k(`humidity`)),swingVertical:y().nullable(),swingHorizontal:y().nullable(),minTemp:p().nullable().optional().meta(k(`temperature`)),maxTemp:p().nullable().optional().meta(k(`temperature`)),tempStep:p().positive().nullable().optional().meta(k(`temperature`)),lastActiveMode:Dx.exclude([`off`]).optional(),lastFetchedAt:p()}),bhe=[j.Climate];function Ax(e,t){return{id:e,cardinality:`scalar`,vocabulary:{cap:`climate-control`,stateField:t},deviceTypes:bhe,apply:`replace`,path:t,sources:[{kind:`numeric`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}}var jx=[Ax(`room-temperature`,`currentTemp`),Ax(`room-humidity`,`currentHumidity`)],xhe={version:1,overridable:jx.map(e=>({path:e.path,by:e.id})),targets:jx},Mx={name:`climate-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Climate],power:{kind:`mode`,field:`mode`,offValue:`off`,set:`setMode`,lastField:`lastActiveMode`},methods:{setMode:E(x({deviceId:p().int().nonnegative(),mode:Dx}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.off`,label:I(`Climate off`,`Clima spento`),phrase:I(`Turn off {device}`,`Spegni {device}`),icon:`power-off`,effect:{field:`mode`,value:`off`},args:{mode:`off`}},{id:`climate.heat`,label:I(`Heat`,`Riscalda`),phrase:I(`Set {device} to heat`,`Metti {device} in riscaldamento`),icon:`flame`,effect:{field:`mode`,value:`heat`},args:{mode:`heat`}},{id:`climate.cool`,label:I(`Cool`,`Raffresca`),phrase:I(`Set {device} to cool`,`Metti {device} in raffrescamento`),icon:`snowflake`,effect:{field:`mode`,value:`cool`},args:{mode:`cool`}},{id:`climate.auto`,label:I(`Climate auto`,`Clima automatico`),phrase:I(`Set {device} to automatic`,`Metti {device} in automatico`),icon:`thermometer`,effect:{field:`mode`,value:`auto`},args:{mode:`auto`}},{id:`climate.mode`,label:I(`Set mode`,`Imposta la modalità`),phrase:I(`Set {device} to {mode}`,`Imposta {device} su {mode}`),icon:`thermometer`,effect:{field:`mode`,fromArg:`mode`},openArgs:[{key:`mode`,label:I(`Mode`,`Modalità`),offer:{kind:`enum`,values:[{value:`off`,label:I(`Off`,`Spento`)},{value:`heat`,label:I(`Heat`,`Riscaldamento`)},{value:`cool`,label:I(`Cool`,`Raffrescamento`)},{value:`auto`,label:I(`Automatic`,`Automatico`)},{value:`heat_cool`,label:I(`Heat and cool`,`Caldo e freddo`)},{value:`fan_only`,label:I(`Fan only`,`Solo ventilazione`)},{value:`dry`,label:I(`Dry`,`Deumidificazione`)}]}}]}]}),setTarget:E(x({deviceId:p().int().nonnegative(),target:p()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.target`,label:I(`Set temperature`,`Imposta la temperatura`),phrase:I(`Set {device} to {target}`,`Imposta {device} a {target}`),icon:`thermometer`,effect:{field:`target`,fromArg:`target`},openArgs:[{key:`target`,label:I(`Temperature`,`Temperatura`),offer:{kind:`number`,step:.5,unit:`°C`}}]}]}),setTargetRange:D(x({deviceId:p().int().nonnegative(),targetLow:p(),targetHigh:p()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.targetRange`,label:I(`Set temperature range`,`Imposta l’intervallo di temperatura`),phrase:I(`Keep {device} between {targetLow} and {targetHigh}`,`Mantieni {device} tra {targetLow} e {targetHigh}`),icon:`thermometer`,openArgs:[{key:`targetLow`,label:I(`Lowest`,`Minima`),offer:{kind:`number`,step:.5,unit:`°C`}},{key:`targetHigh`,label:I(`Highest`,`Massima`),offer:{kind:`number`,step:.5,unit:`°C`}}]}]}),setTargetHumidity:D(x({deviceId:p().int().nonnegative(),targetHumidity:p().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.targetHumidity`,label:I(`Set humidity`,`Imposta l’umidità`),phrase:I(`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:I(`Humidity`,`Umidità`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setFanMode:D(x({deviceId:p().int().nonnegative(),fanMode:m().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.fanMode`,label:I(`Set fan mode`,`Imposta la ventilazione`),phrase:I(`Set the fan of {device} to {fanMode}`,`Imposta la ventilazione di {device} su {fanMode}`),icon:`fan`,openArgs:[{key:`fanMode`,label:I(`Fan mode`,`Ventilazione`),offer:{kind:`dynamic`,from:`status`,field:`availableFanModes`}}]}]}),setPreset:D(x({deviceId:p().int().nonnegative(),preset:m().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.preset`,label:I(`Set preset`,`Imposta il preset`),phrase:I(`Set {device} to preset {preset}`,`Imposta {device} sul preset {preset}`),icon:`list`,openArgs:[{key:`preset`,label:I(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`status`,field:`availablePresets`}}]}]}),setSwingVertical:D(x({deviceId:p().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.swingVerticalOn`,label:I(`Vertical swing on`,`Oscillazione verticale attiva`),phrase:I(`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:I(`Vertical swing off`,`Oscillazione verticale spenta`),phrase:I(`Stop the vertical swing of {device}`,`Ferma l’oscillazione verticale di {device}`),icon:`move-vertical`,effect:{field:`swingVertical`,value:!1},args:{on:!1}}]}),setSwingHorizontal:D(x({deviceId:p().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.swingHorizontalOn`,label:I(`Horizontal swing on`,`Oscillazione orizzontale attiva`),phrase:I(`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:I(`Horizontal swing off`,`Oscillazione orizzontale spenta`),phrase:I(`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:kx,kind:`push`},runtimeState:kx,customize:xhe,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:I(`Climate`,`Clima`),order:1070,state:[{kind:`enum`,field:`mode`,label:I(`Mode`,`Modalità`),values:[{value:`off`,label:I(`Off`,`Spento`),phrase:I(`When {device} turns off`,`Quando {device} si spegne`)},{value:`heat`,label:I(`Heat`,`Riscaldamento`),phrase:I(`When {device} starts heating`,`Quando {device} passa al riscaldamento`)},{value:`cool`,label:I(`Cool`,`Raffrescamento`),phrase:I(`When {device} starts cooling`,`Quando {device} passa al raffrescamento`)},{value:`auto`,label:I(`Automatic`,`Automatico`)},{value:`heat_cool`,label:I(`Heat and cool`,`Caldo e freddo`)},{value:`fan_only`,label:I(`Fan only`,`Solo ventilazione`)},{value:`dry`,label:I(`Dry`,`Deumidificazione`)}],icon:`thermometer`},{kind:`numeric`,field:`currentTemp`,quantity:I(`the temperature`,`la temperatura`),label:I(`Temperature`,`Temperatura`),unit:`°C`,icon:`thermometer`},{kind:`numeric`,field:`currentHumidity`,quantity:I(`the humidity`,`l’umidità`),label:I(`Humidity`,`Umidità`),unit:`%`,icon:`droplets`},{kind:`numeric`,field:`target`,quantity:I(`the set temperature`,`la temperatura impostata`),label:I(`Set temperature`,`Temperatura impostata`),unit:`°C`,icon:`thermometer`}]}},Nx=S([`backup`,`hub-server`,`agent-server`,`addons`]),Px=S([`pending`,`running`,`ok`,`failed`,`skipped`]),Fx=S([`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`]),Ix=x({kind:Nx,nodeId:m().optional(),status:Px,detail:m(),reason:Fx.optional(),fromVersion:m().nullable().optional(),packages:C(m()).readonly().optional(),startedAt:p().optional(),finishedAt:p().optional()}),Lx=S([`running`,`succeeded`,`failed`]),Rx=x({id:m(),state:Lx,targetVersion:m(),requestedBy:m(),startedAt:p(),finishedAt:p().optional(),steps:C(Ix).readonly(),stoppedAt:m().optional(),reason:Fx.optional(),skippedOffline:C(m()).readonly()}),zx=x({version:m().optional(),addons:y().optional(),backup:y().optional()}),Bx=S([`no-target`,`node-busy`,`job-running`,`nothing-to-do`,`status-unreadable`]),Vx=x({targetVersion:m().nullable(),steps:C(Ix).readonly(),skippedOffline:C(m()).readonly(),blocker:Bx.nullable(),blockerDetail:m().nullable()}),Hx=x({accepted:y(),jobId:m().nullable(),blocker:Bx.nullable(),message:m()}),Ux={name:`cluster-update`,scope:`system`,mode:`singleton`,methods:{previewClusterUpdate:E(zx,Vx,{auth:`admin`}),startClusterUpdate:E(zx,Hx,{kind:`mutation`,auth:`admin`}),getClusterUpdateJob:E(x({jobId:m().optional()}),Rx.nullable(),{auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:O.CLUSTER}},Wx=x({r:p().int().min(0).max(255).meta(k(`none`)),g:p().int().min(0).max(255).meta(k(`none`)),b:p().int().min(0).max(255).meta(k(`none`))}),Gx=x({h:p().min(0).max(360).meta(k(`none`)),s:p().min(0).max(100).meta(k(`none`)),v:p().min(0).max(100).meta(k(`none`))}),Kx=a(`mode`,[x({mode:s(`rgb`),rgb:Wx}),x({mode:s(`hsv`),hsv:Gx}),x({mode:s(`mired`),colorTemperature:p().int().min(50).max(1e3)})]),qx=x({mode:S([`rgb`,`hsv`,`mired`]),rgb:Wx.optional(),hsv:Gx.optional(),colorTemperature:p().int().optional().meta(k(`colour-temperature`)),lastChangedAt:p()});function She(e){let t=Kx.safeParse(e);return t.success?t.data:null}var Jx={name:`color`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Light],methods:{setColor:E(x({deviceId:p().int().nonnegative(),color:Kx}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`color.warmWhite`,label:I(`Warm white`,`Bianco caldo`),phrase:I(`Set {device} to warm white`,`Imposta {device} su bianco caldo`),icon:`sun`,args:{color:{mode:`mired`,colorTemperature:370}}},{id:`color.coolWhite`,label:I(`Cool white`,`Bianco freddo`),phrase:I(`Set {device} to cool white`,`Imposta {device} su bianco freddo`),icon:`snowflake`,args:{color:{mode:`mired`,colorTemperature:200}}},{id:`color.red`,label:I(`Red`,`Rosso`),phrase:I(`Turn {device} red`,`Colora {device} di rosso`),icon:`palette`,args:{color:{mode:`rgb`,rgb:{r:255,g:0,b:0}}}},{id:`color.green`,label:I(`Green`,`Verde`),phrase:I(`Turn {device} green`,`Colora {device} di verde`),icon:`palette`,args:{color:{mode:`rgb`,rgb:{r:0,g:255,b:0}}}},{id:`color.blue`,label:I(`Blue`,`Blu`),phrase:I(`Turn {device} blue`,`Colora {device} di blu`),icon:`palette`,args:{color:{mode:`rgb`,rgb:{r:0,g:0,b:255}}}}]})},events:{onColorChanged:{data:x({deviceId:p(),mode:S([`rgb`,`hsv`,`mired`]),rgb:Wx.optional(),hsv:Gx.optional(),colorTemperature:p().int().optional(),lastChangedAt:p()}),notOperatorFacing:"a colour change is read through the `mode` state trigger"}},status:{schema:qx,kind:`command-driven`},runtimeState:qx,durability:`session`,history:`none`,vocabulary:{noun:I(`Colour`,`Colore`),order:1020,state:[{kind:`enum`,field:`mode`,label:I(`Colour mode`,`Modalità colore`),values:[{value:`rgb`,label:I(`RGB colour`,`Colore RGB`)},{value:`hsv`,label:I(`HSV colour`,`Colore HSV`)},{value:`mired`,label:I(`White temperature`,`Temperatura del bianco`)}],icon:`palette`}]}},Yx=1/36e8;function Xx(e){return e*Yx}var Zx=[`min`,`max`,`mean`,`sum`,`count`,`change`],Che=[`gauge`,`counter`,`boolean`];function Qx(e){return typeof e==`number`&&Number.isFinite(e)}function $x(e){return Qx(e.value)?e.value:Qx(e.last)?e.last:null}function whe(e){let t=e.points.filter(t=>t.t>=e.from&&t.t<e.to),n=Qx(e.before?.value)?e.before.value:null,r=n,i=e.from,a=0,o=[];if(r===null){let n=t.find(e=>$x(e)!==null);if(n===void 0)return{segments:o,included:0,gaps:1,end:null,start:null};n.t>e.from&&(a+=1),i=n.t,r=$x(n)}for(let e of t){let t=$x(e);r!==null&&e.t>i&&o.push({value:r,ms:e.t-i}),t!==null&&(r=t),e.t>i&&(i=e.t)}r!==null&&e.to>i&&o.push({value:r,ms:e.to-i});let s=t.reduce((e,t)=>$x(t)??e,r);return{segments:o,included:t.length,gaps:a,end:s,start:n}}function The(e){let t=e.points.filter(e=>Qx(e.twMean)&&Qx(e.twMs)&&e.twMs>0);if(t.length===0)return null;let n=t[0],r=+(e.before===null&&n!==void 0&&n.t>e.from),i=e.points.flatMap(e=>Qx(e.last)?[e.last]:[]),a=i.length>0?i[i.length-1]??null:null;return{segments:t.flatMap(e=>Qx(e.twMean)&&Qx(e.twMs)?[{value:e.twMean,ms:e.twMs}]:[]),included:t.length,gaps:r,end:a,start:Qx(e.before?.value)?e.before.value:null}}function eS(e){if(e.tier!==`raw`){let t=The(e);if(t!==null)return t}return whe(e)}function Ehe(e){let t=0,n=0;for(let r of e)t+=r.ms,n+=r.value*r.ms;return t<=0?null:n/t}function Dhe(e,t){let n=[],r=[];for(let t of e.points)Qx(t.min)&&n.push(t.min),Qx(t.max)&&r.push(t.max);return t.start!==null&&(n.push(t.start),r.push(t.start)),{min:n.length===0?null:Math.min(...n),max:r.length===0?null:Math.max(...r)}}function Ohe(e){let t=e.points.flatMap(e=>Qx(e.delta)?[e.delta]:[]);return t.length===0?null:t.reduce((e,t)=>e+t,0)}function tS(e){return{write:`hold`,value:null,included:0,excluded:0,reason:e}}function nS(e,t){return{write:`null`,value:null,included:t,excluded:1,reason:e}}function rS(e,t,n,r){return{write:`number`,value:e,included:t,excluded:n,reason:n>0?r:null}}var iS=`history has a gap — that interval was not counted as zero`;function khe(e,t){if(t.truncated)return tS(`the history query was truncated — the last statistic is kept`);if(e===`sum`&&t.kind!==`counter`)return tS(`a gauge has no sum — that is the integral template`);if(t.to<=t.from)return nS(`the range is empty`,0);let n=eS(t);if(n.segments.length===0&&n.start===null)return nS(iS,n.included);if(e===`count`)return rS(n.included,n.included,n.gaps,iS);if(e===`sum`||e===`change`&&t.kind===`counter`){let e=Ohe(t);return e===null?nS(`the counter has no growth in this range`,n.included):rS(e,n.included,n.gaps,iS)}if(e===`change`)return n.start===null||n.end===null?nS(`the change has no value at the start of the range`,n.included):rS(n.end-n.start,n.included,n.gaps,iS);if(e===`min`||e===`max`){let r=Dhe(t,n),i=e===`min`?r.min:r.max;return i===null?nS(iS,n.included):rS(i,n.included,n.gaps,iS)}let r=Ehe(n.segments);return r===null?nS(iS,n.included):rS(r,n.included,n.gaps,iS)}function Ahe(e,t){if(e.truncated)return tS(`the history query was truncated — the last total is kept`);if(e.kind===`counter`)return tS(`a counter is already a total — it is not integrated again`);if(e.to<=e.from)return nS(`the range is empty`,0);let n=eS(e);if(n.segments.length===0)return{write:`hold`,value:null,included:n.included,excluded:n.gaps,reason:iS};let r=0;for(let e of n.segments)r+=e.value*e.ms;return rS(t===`energy-kwh`?Xx(r):r/1e3,n.included,n.gaps,iS)}function jhe(e){let t=[];e.before!==null&&Qx(e.before.value)&&t.push({at:e.from,value:e.before.value});for(let n of e.points){if(n.t<e.from||n.t>e.to)continue;let r=$x(n);if(r===null)continue;let i=e.tier===`raw`||!Qx(n.twMs)?n.t:n.t+n.twMs;t.push({at:Math.min(i,e.to),value:r})}return t.toSorted((e,t)=>e.at-t.at)}var Mhe=.1,Nhe=`history stops short of the window — the rate is over the part that was measured`;function aS(e,t,n,r,i){return rS(e/(t/n),r,+(i-t>i*Mhe),Nhe)}function Phe(e,t){if(e.truncated)return tS(`the history query was truncated — the last rate is kept`);if(e.to<=e.from)return nS(`the range is empty`,0);let n=e.to-e.from,r=jhe(e),i=r[0],a=r[r.length-1];if(i===void 0||a===void 0)return nS(`history has no reading in this window`,0);if(e.kind===`counter`){let o=e.before!==null&&Qx(e.before.value),s=o?e.from:i.at,c=e.points.flatMap(t=>t.t>=e.from&&t.t<=e.to&&Qx(t.delta)&&(o||t.t>i.at)?[t.delta]:[]),l=a.at-s;return c.length===0||l<=0?nS(`the counter has no growth in this window`,r.length):aS(c.reduce((e,t)=>e+t,0),l,t,r.length,n)}if(r.length===1&&i.at===e.from&&e.before!==null)return rS(0,1,0,null);let o=a.at-i.at;return r.length<2||o<=0?nS(`the rate needs two readings in the window`,r.length):aS(a.value-i.value,o,t,r.length,n)}var oS=6e4,sS=60*oS,cS=24*sS,lS=[`1h`,`24h`,`2d`,`7d`,`30d`,`custom`],uS=[`today`,`yesterday`,`this-week`,`this-month`],Fhe=[`raw`,`5m`,`1h`,`1d`],dS=[`never`,`daily`,`weekly`,`monthly`],fS=6e4,pS=5*oS,Ihe={"1h":sS,"24h":24*sS,"2d":2*cS,"7d":7*cS,"30d":30*cS},mS={rawMs:7*cS,fiveMinuteMs:30*cS,hourMs:365*cS,dayMs:null};function Lhe(e){return{rawMs:hS(e.rawDays,mS.rawMs),fiveMinuteMs:hS(e.fiveMinuteDays,mS.fiveMinuteMs),hourMs:hS(e.hourDays,mS.hourMs),dayMs:Rhe(e.dayDays)}}function hS(e,t){return typeof e==`number`&&Number.isFinite(e)&&e>0?e*cS:t}function Rhe(e){return typeof e!=`number`||!Number.isFinite(e)||e<=0?null:e*cS}var gS=x({kind:s(`rolling`),span:S(lS),customMinutes:p().int().min(5).optional()}).check(e=>{e.value.span===`custom`&&e.value.customMinutes===void 0&&e.issues.push({code:`custom`,message:`a custom range needs a duration in minutes`,path:[`customMinutes`],input:e.value}),e.value.span!==`custom`&&e.value.customMinutes!==void 0&&e.issues.push({code:`custom`,message:`only a custom range carries a duration`,path:[`customMinutes`],input:e.value})}),_S=gS,vS=x({kind:s(`calendar`),period:S(uS)}),zhe=vS,yS=a(`kind`,[gS,vS]),Bhe={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6},bS=new Map;function Vhe(e){let t=bS.get(e);if(t!==void 0)return t;let n;try{n=new Intl.DateTimeFormat(`en-US`,{timeZone:e,weekday:`short`,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`})}catch{n=null}return bS.set(e,n),n}function xS(e,t){let n=Vhe(t);if(n===null)return null;let r=n.formatToParts(new Date(e)),i=e=>r.find(t=>t.type===e)?.value,a=Number(i(`year`)),o=Number(i(`month`)),s=Number(i(`day`)),c=Number(i(`hour`)),l=Number(i(`minute`)),u=Number(i(`second`)),d=Bhe[i(`weekday`)??``];return!Number.isInteger(a)||!Number.isInteger(o)||!Number.isInteger(s)||!Number.isInteger(c)||!Number.isInteger(l)||!Number.isInteger(u)||d===void 0?null:{year:a,month:o,day:s,hour:c===24?0:c,minute:l,second:u,weekday:d}}function SS(e,t){let n=Date.UTC(e.year,e.month-1,e.day,e.hour,e.minute,e.second),r=xS(n,t);if(r===null)return null;let i=Date.UTC(r.year,r.month-1,r.day,r.hour,r.minute,r.second)-n,a=n-i,o=xS(a,t);if(o===null)return null;let s=Date.UTC(o.year,o.month-1,o.day,o.hour,o.minute,o.second)-a;return s===i?a:n-s}function CS(e,t){let n=xS(e,t);return n===null?null:SS({...n,hour:0,minute:0,second:0},t)}function wS(e,t){let n=xS(e,t);return n===null?null:SS({...n,day:1,hour:0,minute:0,second:0},t)}function TS(e,t){let n=xS(e,t),r=CS(e,t);if(n===null||r===null)return null;let i=n.weekday===0?6:n.weekday-1;for(let e=0;e<i;e++){let e=CS(r-1,t);if(e===null)return null;r=e}return r}function ES(e){return e===null?`forever`:e%864e5==0?`${e/cS} d`:e%36e5==0?`${e/sS} h`:`${e/oS} min`}function Hhe(e){return`raw ${ES(e.rawMs)}, 5m ${ES(e.fiveMinuteMs)}, 1h ${ES(e.hourMs)}, 1d ${ES(e.dayMs)}`}function DS(e,t){let n=[{tier:`raw`,keptMs:t.rawMs},{tier:`5m`,keptMs:t.fiveMinuteMs},{tier:`1h`,keptMs:t.hourMs},{tier:`1d`,keptMs:t.dayMs}];for(let t of n)if(t.keptMs===null||t.keptMs>e)return{ok:!0,tier:t.tier,maxDurationMs:e};return{ok:!1,reason:`the range is ${ES(e)} and no history tier is kept strictly longer (${Hhe(t)})`}}function OS(e){return e.span===`custom`?e.customMinutes===void 0?null:e.customMinutes*oS:Ihe[e.span]}function kS(e){if(e.kind===`rolling`)return OS(e);switch(e.period){case`today`:case`yesterday`:return 25*sS;case`this-week`:return 6084e5;case`this-month`:return 2682e6}}function AS(e,t){let n=kS(e);return n===null?{ok:!1,reason:`a custom range needs a duration of at least 5 minutes`}:DS(n,t)}function jS(e,t){switch(e){case`never`:return DS(1/0,t);case`daily`:return DS(25*sS,t);case`weekly`:return DS(6084e5,t);case`monthly`:return DS(2682e6,t)}}function Uhe(e,t,n){if(e.kind===`rolling`){let n=OS(e);return n===null?null:{from:t-n,to:t}}let r=CS(t,n);if(r===null)return null;switch(e.period){case`today`:return{from:r,to:t};case`yesterday`:{let e=CS(r-1,n);return e===null?null:{from:e,to:r}}case`this-week`:{let e=TS(t,n);return e===null?null:{from:e,to:t}}case`this-month`:{let e=wS(t,n);return e===null?null:{from:e,to:t}}}}function Whe(e,t,n){if(e===`never`)return{from:0,to:t};let r=CS(t,n);if(r===null)return null;if(e===`daily`)return{from:r,to:t};if(e===`weekly`){let e=TS(t,n);return e===null?null:{from:e,to:t}}let i=wS(t,n);return i===null?null:{from:i,to:t}}function Ghe(e,t){let n=CS(e,t);return n===null?null:CS(n+26*sS,t)}function Khe(e){if(e.kind===`calendar`)return e.period===`today`?fS:pS;let t=OS(e);return t!==null&&t<=24*36e5?fS:pS}function qhe(e){return e===`raw`?fS:pS}var MS=x({addonId:m().min(1),stableId:m().min(1)}),NS=[`temperature`,`humidity`,`pressure`,`illuminance`,`power`,`energy`,`battery`,`numeric`,`motion`,`contact`,`leak`,`smoke`,`occupancy`,`binary`,`switch`,`light`,`fan`,`cover`,`valve`,`lock`,`media-player`,`climate`],PS=[`mean`,`median`,`min`,`max`,`sum`],FS=[`any`,`all`],IS=[`at-least-one`,`all`],LS=[`mean`,`median`,`min`,`max`,`sum`,`any`,`all`],RS=S(NS),zS=S(LS),BS=S(IS),VS=x({source:MS,cap:m().min(1),fieldPath:m().min(1)}),HS=x({kind:s(`group`),templateId:RS,aggregate:zS,members:C(VS).min(1).max(64),active:BS.optional()}),US=x({kind:s(`statistic`),stat:S(Zx),window:yS,source:VS}),Jhe=US,WS=[`energy`,`meter`],GS=x({kind:s(`integral`),reset:S(dS),output:S(WS),source:VS}),Yhe=GS,KS=x({kind:s(`threshold`),source:VS,high:p(),low:p(),onForMs:p().int().nonnegative(),offForMs:p().int().nonnegative()}),Xhe=KS,qS=[`sum`,`difference`,`ratio`],JS=x({kind:s(`arithmetic`),op:S(qS),inputs:C(VS).min(2).max(64)}),Zhe=JS,YS=[`number`,`boolean`],XS=x({kind:s(`expression`),expr:m().min(1),inputs:C(x({name:m().min(1),member:VS})).min(1).max(64),output:S(YS)}),Qhe=XS,ZS=[`second`,`minute`,`hour`],QS=x({kind:s(`derivative`),window:_S,per:S(ZS),source:VS}),$he=QS,$S=a(`kind`,[HS,US,GS,KS,JS,XS,QS]);function eC(e){return e.kind===`statistic`||e.kind===`integral`||e.kind===`derivative`}function ege(e){switch(e.kind){case`group`:return e.members;case`statistic`:case`integral`:case`threshold`:case`derivative`:return[e.source];case`arithmetic`:return e.inputs;case`expression`:return e.inputs.map(e=>e.member)}}var tC=`composed-`,nC=`composer`,tge=`customize:`,rC=2e4,iC=x({source:MS,cap:m().min(1),fieldPath:m().min(1)}),aC=iC.extend({kind:s(`from`)}),oC=x({kind:s(`literal`),value:l([m(),p(),y(),ie()])}),sC=a(`kind`,[aC,oC]),cC=x({kind:s(`expression`),expr:m().min(1).max(am),bindings:d(m().regex(om),sC)}).superRefine((e,t)=>{let n=wm(e);n!==null&&t.addIssue({code:`custom`,message:n,path:[`expr`]})}),lC=x({kind:s(`code`),code:m().min(1).max(rC)}),uC=x({kind:s(`aggregate`),reducer:S([`mean`,`median`,`min`,`max`,`sum`,`any`,`all`]),reads:C(iC).min(1).max(64),activeWhen:C(m().min(1)).min(1).optional(),publish:S([`value`,`included`,`excluded`,`total`]),empty:S([`null`,`omit`,`offline`])}),dC=x({kind:s(`series`),read:iC,publish:S([`value`,`included`,`excluded`,`total`]),empty:S([`null`,`omit`,`offline`])}),fC=a(`kind`,[aC,cC,lC,uC,dC]),pC=`$input`,mC=l([m(),p(),y(),f({[pC]:m().min(1)}),d(m().min(1),_(()=>mC))]),hC=mC;function gC(e){return typeof e==`object`&&typeof e.$input==`string`}var _C=x({kind:s(`forward`),source:MS,cap:m().min(1),method:m().min(1),args:d(m().min(1),hC).optional()}),vC=x({kind:s(`extension`),target:s(`remote`)}),yC=a(`kind`,[_C,lC,vC]),bC=/^[a-z0-9][a-z0-9-]{0,47}$/,xC=`items`,SC=x({label:m().min(1).max(80),fields:d(m().min(1),fC),reset:_C.optional()}),CC=x({kind:s(`fields`),cap:m().min(1),enabled:y().optional(),fields:d(m().min(1),fC).refine(e=>Object.keys(e).length<=32,{message:`at most 32 fields per capability`}),items:d(m().regex(bC),SC).refine(e=>Object.keys(e).length<=16,{message:`at most 16 items`}).optional(),commands:d(m().min(1),yC).optional()}),wC=x({kind:s(`passthrough`),cap:m().min(1),enabled:y().optional(),source:MS}),TC=a(`kind`,[CC,wC]);function EC(e){return e.enabled!==!1}var DC=x({kind:s(`new`),type:S(j),role:S(N).optional()});function nge(e){if(!OC(e))return e;let t=Reflect.get(e,`source`);if(!OC(t))return e;let n=Reflect.get(t,`composition`);if(!OC(n))return e;let r=Reflect.get(n,`target`);if(!OC(r))return e;let i=Reflect.get(r,`type`);if(typeof i!=`string`)return e;let a={...r,type:mf(i)};return{...e,source:{...t,composition:{...n,target:a}}}}function OC(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var kC=x({kind:s(`existing`),device:MS}),AC=a(`kind`,[DC,kC]),jC=x({target:AC,features:C(TC).min(0).max(16),helper:$S.optional()}).superRefine((e,t)=>{let n=new Set;e.features.forEach((e,r)=>{n.has(e.cap)&&t.addIssue({code:`custom`,message:`capability \`${e.cap}\` is composed twice — one feature per capability`,path:[`features`,r,`cap`]}),n.add(e.cap)})});function MC(e){return`${e.addonId}/${e.stableId}`}function NC(e,t){return`${MC(e)}#${t}`}function PC(e){return`${NC(e.source,e.cap)}.${e.fieldPath}`}function FC(e){return`${tC}${e}`}function IC(e){return{addonId:nC,stableId:FC(e)}}function LC(e){switch(e.kind){case`from`:return[{source:e.source,cap:e.cap,fieldPath:e.fieldPath}];case`expression`:return Object.values(e.bindings).flatMap(e=>e.kind===`from`?[{source:e.source,cap:e.cap,fieldPath:e.fieldPath}]:[]);case`aggregate`:return e.reads;case`series`:return[e.read];case`code`:return[]}}function RC(e,t,n){return`${e}[${t}].${n}`}function zC(e,t=xC){return[...Object.entries(e.fields).map(([e,t])=>({fieldPath:e,source:t})),...Object.entries(e.items??{}).flatMap(([e,n])=>Object.entries(n.fields).map(([n,r])=>({fieldPath:RC(t,e,n),source:r})))]}function BC(e){return zC(e).map(e=>e.source)}function VC(e,t){let n=e;for(let e of t.split(`.`)){let t=$m(n);if(!(t instanceof se))return null;let r=t.shape[e];if(!(r instanceof re))return null;n=r}return n}function HC(e,t){let n=nh(e).find(e=>e.path===t);if(n===void 0)return null;let r=VC(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 UC(e){return new Map(nh(e).filter(e=>!e.path.includes(`.`)).flatMap(t=>{let n=HC(e,t.path);return n===null?[]:[[t.path,n]]}))}function WC(e){let t=$m(e);return t instanceof se?Object.entries(t.shape).flatMap(([e,t])=>t instanceof re&&!t.safeParse(void 0).success?[e]:[]):[]}function GC(e,t){let n=t.split(`.`);return n.slice(0,-1).flatMap((t,r)=>{let i=n.slice(0,r+1).join(`.`),a=VC(e,i);return a!==null&&a.safeParse(void 0).success?[i]:[]})}var KC={"doorbell.onPressed":w.DoorbellOnPressed},rge=KC,qC=x({featureIndex:p().int().nonnegative(),cap:m(),eventName:m(),category:S(w),stateField:m(),fieldKey:m()});function JC(e,t,n){return{code:e,path:t,message:n}}function ige(e){return e.issues.map(e=>`${e.path.length===0?`payload`:e.path.join(`.`)}: ${e.message}`).join(`; `)}function YC(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?HC(e.runtimeState,s.field):null;if(l===null){r.push(JC(`unknown-field`,c,`\`${e.name}.${a}\` derives from missing state field \`${s.field}\``));continue}if(l.kind!==`number`){r.push(JC(`kind-mismatch`,c,`\`${e.name}.${a}\` needs a numeric state field; \`${s.field}\` is ${l.kind}`));continue}let u=`${e.name}.${a}`,d=rge[u];if(d===void 0){r.push(JC(`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(JC(`not-composable`,`features[${t.featureIndex}].cap`,`\`${u}\` cannot be derived from { deviceId, timestamp }: ${ige(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(JC(`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 XC=S(`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`.split(`.`)),ZC=x({code:XC,path:m(),message:m()}),QC=S([`string`,`number`,`boolean`,`enum`]),$C=S([`null`,`offline`,`unknown`,`release`,`omit`]),ew=S([`derived`,`clock`,`constant`,`accumulator`]),tw=x({arrayPath:m(),key:m(),label:m(),resettable:y().optional()}),nw=x({cap:m(),path:m(),item:tw.optional(),featureIndex:p().int().nonnegative(),kind:QC,nullable:y(),required:y(),unavailable:$C,role:ew,source:fC,reads:C(iC)});function rw(e){let t=e.item===void 0?e.path:RC(e.item.arrayPath,e.item.key,e.path);return`${e.cap}.${t}`}var iw=S([`new`,`add`,`replace`]),aw=x({featureIndex:p().int().nonnegative(),cap:m(),mode:iw}),ow=x({ok:y(),problems:C(ZC),fields:C(nw),features:C(aw),events:C(qC)}),sw=S([`stopped`,`starting`,`running`,`degraded`,`incomplete`,`failed`]),cw=S([`fresh`,`stale`,`unavailable`]),lw=x({cap:m(),path:m(),item:tw.optional(),state:cw,value:l([m(),p(),y(),ie()]),reason:m().optional()}),uw=x({blockId:m(),deviceId:p().nullable(),status:sw,reason:m().optional(),fields:C(lw)}),age=nC,dw=x({id:m().min(1),name:m().min(1).max(120),enabled:y(),updatedAt:p(),composition:jC}),fw=x({id:m().min(1),name:m().nullable(),error:m()}),pw=x({deviceId:p().int(),capName:m(),owner:m(),error:m()}),mw=x({integrationId:m().nullable(),storeLoaded:y(),blocks:C(dw),restartBlockIds:C(m()),unreadableBlocks:C(fw),retiredBlockIds:C(m()).optional()}),hw=x({blockId:m(),status:sw,reason:m().optional()}),gw=x({blocks:C(hw),acted:y(),unreleasedClaims:C(pw).optional()}),_w={name:`composer`,scope:`system`,mode:`singleton`,internal:!0,methods:{applyBlocks:E(mw,gw,{kind:`mutation`,auth:`admin`}),getStates:E(x({blockIds:C(m())}),x({states:C(uw)}),{auth:`admin`})},vocabulary:{notOperatorFacing:`device composition — an authoring tool, not an action`}},vw=x({connected:y(),lastChangedAt:p()}),yw={name:`connectivity`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor],methods:{},status:{schema:vw,kind:`push`},runtimeState:vw,durability:`restored`,history:{fields:{connected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:I(`Connectivity`,`Connettività`),order:5040,state:[{kind:`boolean`,field:`connected`,label:I(`Connected`,`Connesso`),whenTrue:I(`When {device} connects`,`Quando {device} si connette`),whenFalse:I(`When {device} disconnects`,`Quando {device} si disconnette`),icon:`wifi`}]}},bw=S([`wear`,`supply`,`waste`]),xw=S([`part`,`tank`,`product`,`bin`]),Sw=S([`ok`,`low`,`empty`,`full`,`replace`]),Cw=S([`ok`,`low`,`empty`,`full`]);function ww(e){return e.kind??`wear`}var oge={wear:`part`,waste:`bin`,supply:`product`};function Tw(e){return e.form??oge[ww(e)]}var Ew=S([`duration`,`count`]),Dw=x({value:p().min(0).nullable().meta(k(`device`)),kind:Ew}),Ow=x({key:m().min(1),label:m().min(1),level:p().min(0).max(100).nullable().meta(k(`percentage`)),status:Sw.nullable(),kind:bw.optional(),form:xw.optional(),lastResetAt:p().nullable(),resettable:y(),remaining:Dw.optional()}),kw=x({items:C(Ow),lastChangedAt:p()}),sge={items:[],lastChangedAt:0},cge={version:1,targets:[{id:`items`,cardinality:`keyedArray`,vocabulary:{cap:`consumables`},deviceTypes:Object.values(j),apply:`add`,path:`items`,keyField:`key`,labelField:`label`,itemSchema:Ow,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:[...Ew.options]}]},{path:`status`,sources:[{kind:`enum`,transforms:[{kind:`enum-map`,outputValues:[...Sw.options],unmapped:null}]}]}],traits:[{path:`kind`,values:[...bw.options],defaultValue:`wear`},{path:`form`,values:[...xw.options],defaultValue:`part`}],companions:[{kind:`clock`,path:`lastChangedAt`,when:`add`},{kind:`clock`,path:`lastFetchedAt`,when:`add`}],advancedExpression:!0}]},Aw={name:`consumables`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:Object.values(j),methods:{reset:E(x({deviceId:p().int().nonnegative(),key:m().min(1)}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`consumables.reset`,label:I(`Mark as replaced`,`Segna come sostituito`),phrase:I(`Mark {key} as replaced on {device}`,`Segna {key} come sostituito su {device}`),icon:`refresh-cw`,openArgs:[{key:`key`,label:I(`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:kw,kind:`push`,empty:sge,itemArray:{path:`items`,keyField:`key`,labelField:`label`,itemSchema:Ow,emptyItem:{key:``,label:``,level:null,status:null,lastResetAt:null,resettable:!1}}},runtimeState:kw.extend({lastFetchedAt:p()}),durability:`restored`,customize:cge,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:I(`Consumables`,`Materiali di consumo`),order:2070}},jw=x({entryOpen:y(),lastChangedAt:p()}),Mw={name:`contact`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor],methods:{},status:{schema:jw,kind:`push`},runtimeState:jw,durability:`restored`,history:{fields:{entryOpen:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:I(`Contact`,`Contatto`),order:5050,state:[{kind:`boolean`,field:`entryOpen`,label:I(`Open`,`Aperto`),whenTrue:I(`When {device} opens`,`Quando {device} si apre`),whenFalse:I(`When {device} closes`,`Quando {device} si chiude`),icon:`door-open`}]}},Nw=S([`numeric`,`select`,`text`,`datetime`]),Pw=x({kind:Nw,value:l([p().meta(k(`device`)),m()]),options:C(m()),lastChangedAt:p(),min:p().optional().meta(k(`device`)),max:p().optional().meta(k(`device`)),step:p().optional().meta(k(`device`))}),lge=a(`kind`,[x({kind:s(`numeric`),value:p()}),x({kind:s(`select`),value:m().min(1)}),x({kind:s(`text`),value:m()}),x({kind:s(`datetime`),value:m().min(1)})]),Fw=x({deviceId:p().int().nonnegative(),cycle:y().default(!0)}),Iw=x({deviceId:p().int().nonnegative()}),Lw={name:`control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Control],methods:{setValue:E(x({deviceId:p().int().nonnegative(),control:lge}),v(),{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:D(Fw,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.next`,label:I(`Next option`,`Opzione successiva`),phrase:I(`Select the next option on {device}`,`Seleziona l’opzione successiva su {device}`),icon:`skip-forward`,openArgs:[{key:`cycle`,label:I(`Wrap to the first option`,`Ricomincia dalla prima opzione`),offer:{kind:`boolean`}}]}]}),previous:D(Fw,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.previous`,label:I(`Previous option`,`Opzione precedente`),phrase:I(`Select the previous option on {device}`,`Seleziona l’opzione precedente su {device}`),icon:`skip-back`,openArgs:[{key:`cycle`,label:I(`Wrap to the last option`,`Ricomincia dall’ultima opzione`),offer:{kind:`boolean`}}]}]}),first:D(Iw,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.first`,label:I(`First option`,`Prima opzione`),phrase:I(`Select the first option on {device}`,`Seleziona la prima opzione su {device}`),icon:`chevron-first`}]}),last:D(Iw,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.last`,label:I(`Last option`,`Ultima opzione`),phrase:I(`Select the last option on {device}`,`Seleziona l’ultima opzione su {device}`),icon:`chevron-last`}]})},status:{schema:Pw,kind:`push`},runtimeState:Pw,durability:`session`,history:`none`,vocabulary:{noun:I(`Control`,`Controllo`),order:1150,state:[{kind:`value`,field:`value`,label:I(`Value`,`Valore`),offer:{kind:`dynamic`,from:`status`,field:`options`},icon:`sliders-horizontal`}]}},L=class extends Error{code;constructor(e,t){super(t),this.name=`IrCodecError`,this.code=e}},Rw=1024,zw=C(p().int()).min(2).max(Rw).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]})})}),Bw=x({carrierHz:p().int().positive().optional(),dutyCyclePercent:p().int().min(1).max(100).optional(),repeat:p().int().min(0).max(20).optional(),repeatDelayMs:p().int().min(0).optional()}),uge=.241246,dge=0;function Vw(e){let t=e.trim().split(/\s+/).filter(e=>e.length>0);if(t.length<4)throw new L(`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 L(`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 L(`pronto-malformed`,`Pronto header incomplete`);if(r!==dge)throw new L(`pronto-unsupported-form`,`Pronto form ${t[0]??``} is not supported, only the learned 0000 form`);if(i===0)throw new L(`pronto-malformed`,`Pronto frequency word is zero`);let s=a+o;if(s===0||n.length!==4+s*2)throw new L(`pronto-malformed`,`Pronto declares ${s} burst pairs but carries ${(n.length-4)/2} word pairs`);let c=i*uge,l=n.slice(4).map((e,t)=>{let n=Math.max(1,Math.round(e*c));return t%2==0?n:-n}),u=zw.safeParse(l);if(!u.success)throw new L(`invalid-timings`,`Pronto decoded to invalid timings: ${u.error.message}`);return{timings:u.data,carrierHz:Math.round(1e6/c)}}var fge=8192,Hw=32,Uw=3,pge=264,Ww=Rw*2;function mge(e){let t=[],n=0,r=e=>{if(t.length+e>Ww)throw new L(`tuya-malformed`,`decompressed code is larger than any IR train`)},i=()=>{let t=e[n++];if(t===void 0)throw new L(`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 L(`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 L(`tuya-malformed`,`back-reference is invalid`);t.push(n)}}return Uint8Array.from(t)}function hge(e){let t=[],n=new Map,r=0,i=n=>{for(let i=r;i<n;i+=Hw){let r=Math.min(i+Hw,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+Uw<=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<=fge){let t=0;for(;a+t<e.length&&t<pge&&e[r+t]===e[a+t];)t++;t>=Uw&&(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 Gw=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,gge=65535;function _ge(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+=Gw[o>>18&63],t+=Gw[o>>12&63],t+=n+1<e.length?Gw[o>>6&63]:`=`,t+=n+2<e.length?Gw[o&63]:`=`}return t}function vge(e){let t=e.trim().replace(/=+$/,``);if(t.length===0||t.length%4==1)throw new L(`tuya-malformed`,`not a base64 string`);let n=[],r=0,i=0;for(let e of t){let t=Gw.indexOf(e);if(t<0)throw new L(`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 Kw(e){let t=new Uint8Array(e.length*2);return e.forEach((e,n)=>{let r=Math.abs(e);if(r===0||r>gge)throw new L(`invalid-timings`,`timing ${n} does not fit 16 bits`);t[n*2]=r&255,t[n*2+1]=r>>8}),_ge(hge(t))}function qw(e){let t=mge(vge(e));if(t.length===0||t.length%2!=0)throw new L(`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=zw.safeParse(n);if(!r.success)throw new L(`tuya-malformed`,r.error.message);return r.data}var Jw=S([`tuya`]),Yw=Math.ceil((Ww+Math.ceil(Ww/32))/3)*4+256,Xw=x({format:Jw,code:m().min(1).max(Yw)}),Zw={tuya:{encode:Kw,decode:qw}},Qw=a(`kind`,[x({kind:s(`raw`),timings:C(p().int()),settings:Bw.optional()}),x({kind:s(`pronto`),code:m()}),x({kind:s(`native`),format:Jw,code:m()})]);function $w(e){if(e.kind===`pronto`){let t=Vw(e.code);return{timings:t.timings,settings:{carrierHz:t.carrierHz}}}if(e.kind===`native`)return{timings:Zw[e.format].decode(e.code),settings:{}};let t=zw.safeParse(e.timings);if(!t.success)throw new L(`invalid-timings`,t.error.message);return{timings:t.data,settings:e.settings??{}}}var eT=`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(`.`),tT=[`source_select`];function nT(e){return tT.includes(e)}var rT=`custom:`,yge=/^[a-z0-9][a-z0-9_]{0,47}$/,bge=new Set(eT);function iT(e){return bge.has(e)}function aT(e){return yge.test(e)}function oT(e){return`${rT}${e}`}function sT(e){if(!e.startsWith(`custom:`))return null;let t=e.slice(7);return aT(t)?t:null}function cT(e){return iT(e)||sT(e)!==null}var lT=m().refine(cT,{message:`a role is one of the known roles or custom:<key> (lowercase letters, digits, _)`}),uT=[`digits`,`sequence`,`ir`],xge=S(uT),Sge=/^[a-z0-9][a-z0-9_-]{0,47}$/,Cge=RegExp(`^[0-9]{1,6}$`),dT={id:m().regex(Sge,{message:`a lowercase slug`}),name:m().trim().min(1).max(60)},fT=x({...dT,kind:s(`digits`),number:m().regex(Cge,{message:`up to 6 digits`})}),pT=x({...dT,kind:s(`sequence`),steps:C(lT).min(1).max(16)}),mT=x({...dT,kind:s(`ir`),transmitterId:p().int().nonnegative().optional(),payload:Qw}),hT=a(`kind`,[fT,pT,mT]),gT=3e3;function _T(e){switch(e.kind){case`sequence`:return e.steps;case`digits`:return Array.from(e.number,e=>`digit_${e}`);case`ir`:return[]}}function vT(e){try{return $w(e.payload),null}catch(e){if(e instanceof L)return e.message;throw e}}function wge(e,t){return e.trim().toLowerCase()===t.trim().toLowerCase()}function yT(e,t){let n=t.trim();for(let t of e)if(t.kind===`digits`&&t.number===n)return t;return null}function Tge(e,t){let n=e.find(e=>wge(e.name,t));if(n!==void 0)return n;let r=e.find(e=>e.id===t.trim());return r===void 0?yT(e,t):r}var bT=S([`off`,`on`,`idle`,`playing`,`paused`,`buffering`,`standby`]),xT=S([`off`,`all`,`one`]),Ege=x({type:m(),title:m(),artist:m().optional(),album:m().optional(),imageUrl:m().optional()}),ST=S([`reported`,`assumed`]),CT=S([`state`,`volumeLevel`,`isMuted`,`source`]),wT=x({state:bT,stateSource:ST.default(`reported`),assumedFields:C(CT).default([]),volumeLevel:p().min(0).max(100).nullable().meta(k(`percentage`)),isMuted:y().nullable(),muteReadback:y().optional(),source:m(),availableSources:C(m()),declaredSources:C(x({name:m(),kind:S(uT),number:m().optional()})).optional(),currentMedia:Ege.nullable(),position:p().int().nonnegative().nullable().meta(k(`duration-ms`)),duration:p().int().nonnegative().nullable().meta(k(`duration-ms`)),shuffle:y().nullable(),repeat:xT.nullable(),positionUpdatedAt:p().nullable().default(null),lastChangedAt:p()}),TT=x({deviceId:p().int().nonnegative(),steps:p().int().min(1).max(50).default(1)}),ET=x({deviceId:p().int().nonnegative()}),DT={name:`media-player`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.MediaPlayer],power:{kind:`methods`,field:`state`,offValues:[`off`,`standby`],on:`turnOn`,off:`turnOff`},methods:{turnOn:D(ET,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.turnOn`,label:I(`Turn on`,`Accendi`),phrase:I(`Turn on {device}`,`Accendi {device}`),icon:`power`}]}),turnOff:D(ET,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.turnOff`,label:I(`Turn off`,`Spegni`),phrase:I(`Turn off {device}`,`Spegni {device}`),icon:`power`}]}),volumeUp:D(TT,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.volumeUp`,label:I(`Volume up`,`Alza il volume`),phrase:I(`Raise the volume of {device}`,`Alza il volume di {device}`),icon:`volume-2`}]}),volumeDown:D(TT,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.volumeDown`,label:I(`Volume down`,`Abbassa il volume`),phrase:I(`Lower the volume of {device}`,`Abbassa il volume di {device}`),icon:`volume-2`}]}),channelUp:D(TT,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.channelUp`,label:I(`Channel up`,`Canale successivo`),phrase:I(`Go to the next channel on {device}`,`Passa al canale successivo su {device}`),icon:`skip-forward`}]}),channelDown:D(TT,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.channelDown`,label:I(`Channel down`,`Canale precedente`),phrase:I(`Go to the previous channel on {device}`,`Torna al canale precedente su {device}`),icon:`skip-back`}]}),play:E(x({deviceId:p().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.play`,label:I(`Play`,`Riproduci`),phrase:I(`Play on {device}`,`Avvia la riproduzione su {device}`),icon:`play`}]}),pause:E(x({deviceId:p().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.pause`,label:I(`Pause media`,`Metti in pausa`),phrase:I(`Pause {device}`,`Metti in pausa {device}`),icon:`pause`}]}),stop:D(x({deviceId:p().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.stop`,label:I(`Stop media`,`Ferma la riproduzione`),phrase:I(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),next:D(x({deviceId:p().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.next`,label:I(`Next track`,`Brano successivo`),phrase:I(`Skip to the next track on {device}`,`Passa al brano successivo su {device}`),icon:`skip-forward`}]}),previous:D(x({deviceId:p().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.previous`,label:I(`Previous track`,`Brano precedente`),phrase:I(`Go back to the previous track on {device}`,`Torna al brano precedente su {device}`),icon:`skip-back`}]}),setVolume:D(x({deviceId:p().int().nonnegative(),volumeLevel:p().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.volume`,label:I(`Set volume`,`Imposta il volume`),phrase:I(`Set the volume of {device} to {volumeLevel}`,`Imposta il volume di {device} al {volumeLevel}`),icon:`volume-2`,openArgs:[{key:`volumeLevel`,label:I(`Volume`,`Volume`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setMute:D(x({deviceId:p().int().nonnegative(),muted:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.mute`,label:I(`Mute`,`Silenzia`),phrase:I(`Mute {device}`,`Silenzia {device}`),icon:`volume-x`,args:{muted:!0}},{id:`media.unmute`,label:I(`Unmute`,`Riattiva l’audio`),phrase:I(`Unmute {device}`,`Riattiva l’audio di {device}`),icon:`volume-2`,args:{muted:!1}}]}),setShuffle:D(x({deviceId:p().int().nonnegative(),shuffle:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.shuffleOn`,label:I(`Shuffle on`,`Riproduzione casuale attiva`),phrase:I(`Turn on shuffle on {device}`,`Attiva la riproduzione casuale su {device}`),icon:`shuffle`,args:{shuffle:!0}},{id:`media.shuffleOff`,label:I(`Shuffle off`,`Riproduzione casuale spenta`),phrase:I(`Turn off shuffle on {device}`,`Disattiva la riproduzione casuale su {device}`),icon:`shuffle`,args:{shuffle:!1}}]}),setRepeat:D(x({deviceId:p().int().nonnegative(),repeat:xT}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.repeat`,label:I(`Set repeat`,`Imposta la ripetizione`),phrase:I(`Set repeat on {device} to {repeat}`,`Imposta la ripetizione di {device} su {repeat}`),icon:`repeat`,openArgs:[{key:`repeat`,label:I(`Repeat`,`Ripetizione`),offer:{kind:`enum`,values:[{value:`off`,label:I(`Off`,`Disattivata`)},{value:`all`,label:I(`All`,`Tutti i brani`)},{value:`one`,label:I(`One track`,`Un brano`)}]}}]}]}),selectSource:D(x({deviceId:p().int().nonnegative(),source:m().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.source`,label:I(`Select source`,`Scegli la sorgente`),phrase:I(`Switch {device} to {source}`,`Passa {device} alla sorgente {source}`),icon:`cast`,openArgs:[{key:`source`,label:I(`Source`,`Sorgente`),offer:{kind:`dynamic`,from:`status`,field:`availableSources`}}]}]}),seek:D(x({deviceId:p().int().nonnegative(),position:p().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.seek`,label:I(`Seek`,`Vai al punto`),phrase:I(`Move {device} to {position}`,`Porta {device} al punto {position}`),icon:`fast-forward`,openArgs:[{key:`position`,label:I(`Position`,`Posizione`),offer:{kind:`number`,min:0,step:1e3,unit:`ms`}}]}]}),playMedia:D(x({deviceId:p().int().nonnegative(),mediaId:m().min(1),mediaType:m().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.playMedia`,label:I(`Play media`,`Riproduci un contenuto`),phrase:I(`Play {mediaId} on {device}`,`Riproduci {mediaId} su {device}`),icon:`music`,openArgs:[{key:`mediaId`,label:I(`Media`,`Contenuto`),offer:{kind:`text`}},{key:`mediaType`,label:I(`Media type`,`Tipo di contenuto`),offer:{kind:`text`}}]}]})},status:{schema:wT,kind:`push`},runtimeState:wT,durability:`session`,history:{fields:{volumeLevel:{kind:`gauge`,unit:`%`,deadband:1},isMuted:{kind:`boolean`}}},vocabulary:{noun:I(`Media player`,`Lettore multimediale`),order:2060,state:[{kind:`enum`,field:`state`,label:I(`Playback`,`Riproduzione`),values:[{value:`off`,label:I(`Off`,`Spento`),phrase:I(`When {device} turns off`,`Quando {device} si spegne`)},{value:`on`,label:I(`On`,`Acceso`),phrase:I(`When {device} turns on`,`Quando {device} si accende`)},{value:`idle`,label:I(`Idle`,`Inattivo`)},{value:`playing`,label:I(`Playing`,`In riproduzione`),phrase:I(`When {device} starts playing`,`Quando {device} inizia a riprodurre`)},{value:`paused`,label:I(`Paused`,`In pausa`),phrase:I(`When {device} is paused`,`Quando {device} va in pausa`)},{value:`buffering`,label:I(`Buffering`,`In caricamento`)},{value:`standby`,label:I(`Standby`,`In standby`)}],icon:`music`},{kind:`numeric`,field:`volumeLevel`,quantity:I(`the volume`,`il volume`),label:I(`Volume`,`Volume`),unit:`%`,icon:`volume-2`},{kind:`boolean`,field:`isMuted`,label:I(`Muted`,`Silenziato`),whenTrue:I(`When {device} is muted`,`Quando {device} viene silenziato`),whenFalse:I(`When {device} is unmuted`,`Quando l’audio di {device} torna attivo`),icon:`volume-x`},{kind:`value`,field:`source`,label:I(`Source`,`Sorgente`),offer:{kind:`dynamic`,from:`status`,field:`availableSources`},icon:`cast`}]}},OT={battery:{version:1,targets:[{id:`level`,cardinality:`scalar`,deviceTypes:[j.Camera,j.Sensor,j.Button,j.Switch,j.PetFeeder,j.Container,j.Climate,j.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:[j.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:[j.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:[j.Camera,j.Light,j.Siren,j.Switch,j.Sensor,j.Climate,j.Button,j.EventEmitter,j.Update,j.Generic,j.Notifier,j.Script,j.Automation,j.Lock,j.Cover,j.Valve,j.Humidifier,j.WaterHeater,j.Fan,j.MediaPlayer,j.AlarmPanel,j.Control,j.Presence,j.Weather,j.WeatherStation,j.Vacuum,j.LawnMower,j.Container,j.Image,j.PetFeeder,j.PetFountain,j.Dishwasher,j.Washer,j.Dryer,j.Gateway,j.HeatPump,j.EnergySystem],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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.Switch,j.Light,j.Fan,j.Climate,j.Humidifier,j.WaterHeater,j.MediaPlayer,j.Washer,j.Dryer,j.Dishwasher,j.Vacuum,j.LawnMower,j.PetFeeder],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:[j.Switch,j.Light,j.Fan,j.Climate,j.Humidifier,j.WaterHeater,j.MediaPlayer,j.Washer,j.Dryer,j.Dishwasher,j.Vacuum,j.LawnMower,j.PetFeeder],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:[j.Switch,j.Light,j.Fan,j.Climate,j.Humidifier,j.WaterHeater,j.MediaPlayer,j.Washer,j.Dryer,j.Dishwasher,j.Vacuum,j.LawnMower,j.PetFeeder],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:[j.Switch,j.Light,j.Fan,j.Climate,j.Humidifier,j.WaterHeater,j.MediaPlayer,j.Washer,j.Dryer,j.Dishwasher,j.Vacuum,j.LawnMower,j.PetFeeder],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:[j.Gateway,j.Camera,j.Sensor,j.MediaPlayer,j.Vacuum,j.Generic,j.Washer,j.Dryer,j.Dishwasher,j.PetFountain,j.Fan,j.Humidifier,j.Climate,j.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:[j.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:[j.Washer,j.Dryer,j.Dishwasher,j.Vacuum,j.LawnMower,j.MediaPlayer,j.WaterHeater,j.Humidifier,j.Fan,j.Climate,j.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:{[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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`}]}},kT={"ambient-light-sensor":{illuminance:`lx`},battery:{level:`%`,voltage:`V`},"humidity-sensor":{humidity:`%`},"power-meter":{power:`W`,energy:`kWh`,voltage:`V`,current:`A`},"temperature-sensor":{temperature:`°C`}};function R(e,t,n){return{code:e,path:t,message:n}}function AT(...e){return{problems:e,fields:[],features:[],events:[]}}function jT(e){let t=e.item===void 0?`fields`:`items.${e.item.key}.fields`;return`features[${e.featureIndex}].${t}.${e.path}`}var MT={kind:`fixed`,result:[`number`]},NT={kind:`fixed`,result:[`boolean`]},PT=Object.freeze({min:MT,max:MT,abs:MT,floor:MT,ceil:MT,sqrt:MT,round:MT,pow:MT,clamp:MT,avg:MT,sum:MT,age:MT,convert:MT,coalesce:{kind:`coalesce`},any:NT,all:NT,within:NT,latest:{kind:`fixed`,result:[`number`,`null`]},number:{kind:`fixed`,result:[`number`,`null`]},rose:{kind:`fixed`,result:[`number`,`null`]},count:MT,dwell:{kind:`fixed`,result:[`boolean`,`null`]},latchedAt:{kind:`fixed`,result:[`number`,`null`]},schmitt:{kind:`fixed`,result:[`boolean`,`null`]}}),FT=class extends Error{};function IT(e){return e===null?`null`:typeof e==`number`?`number`:typeof e==`string`?`string`:`boolean`}function LT(e){return new Set([e])}function RT(...e){return new Set(e.flatMap(e=>[...e]))}function Dge(e){return new Set([...e].filter(e=>e!==`null`))}function Oge(e,t,n){if(e===`+`){let e=[...t,...n];return e.every(e=>e===`string`)?LT(`string`):e.every(e=>e===`number`)?LT(`number`):new Set([`number`,`string`])}return LT(e===`-`||e===`*`||e===`/`||e===`%`?`number`:`boolean`)}function kge(e){return e.minArgs===e.maxArgs?`exactly ${e.minArgs}`:e.maxArgs===1/0?`at least ${e.minArgs}`:`${e.minArgs}–${e.maxArgs}`}function Age(e,t){let n=rm[e];if(n!==void 0&&(t.length<n.minArgs||t.length>n.maxArgs))throw new FT(`${e}: wrong number of arguments (${t.length}); expected ${kge(n)}`);let r=PT[e];if(r===void 0)throw new FT(`no result-kind rule for builtin '${e}'`);if(r.kind===`fixed`)return new Set(r.result);let i=RT(...t.map(Dge));return t.every(e=>e.has(`null`))?RT(i,LT(`null`)):i}function zT(e,t){switch(e.kind){case`literal`:return LT(IT(e.value));case`identifier`:{if(e.name===`now`)return LT(`number`);let n=t.get(e.name);if(n===void 0)throw new FT(`unbound identifier '${e.name}'`);return n}case`unary`:return LT(e.op===`!`?`boolean`:`number`);case`binary`:return Oge(e.op,zT(e.left,t),zT(e.right,t));case`logical`:return RT(zT(e.left,t),zT(e.right,t));case`conditional`:return RT(zT(e.consequent,t),zT(e.alternate,t));case`call`:return Age(e.callee,e.args.map(e=>zT(e,t)))}}function BT(e,t){switch(e.kind){case`literal`:case`identifier`:return!1;case`unary`:return BT(e.operand,t);case`binary`:case`logical`:return BT(e.left,t)||BT(e.right,t);case`conditional`:return BT(e.test,t)||BT(e.consequent,t)||BT(e.alternate,t);case`call`:return e.callee===t||e.args.some(e=>BT(e,t))}}function VT(e,t){let n=mm(e);return n.ok&&BT(n.parsed.ast,t)}function HT(e){let t=mm(e.expr);if(!t.ok)return{ok:!1,error:t.error};try{return{ok:!0,kinds:zT(t.parsed.ast,e.bindingKinds)}}catch(e){if(e instanceof FT)return{ok:!1,error:e.message};throw e}}function jge(e){return e.publish===`value`&&e.empty===`null`?{ok:!0,kinds:new Set([`number`,`null`])}:{ok:!0,kinds:new Set([`number`])}}function Mge(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 UT(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=HC(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 WT(e,t,n){return R(`kind-mismatch`,n,`\`${e}.${t}\` is a union — it is read as a source, never written`)}function GT(e){return e.kind===`union`?null:e.kind===`enum`?`string`:e.kind}function KT(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=HC(a,e.fieldPath),s=GT(t);return o?.kind!==`union`||s===null||!n.has(s)?n:new Set(n.has(`null`)?[s,`null`]:[s])}function qT(e,t){if(e.kind===`from`)return UT(e,t);if(e.kind===`code`)return{ok:!1,code:`reserved-variant`,message:`code fields arrive in slice 4`};if(e.kind===`aggregate`)return Mge(e);if(e.kind===`series`)return jge(e);let n=new Map;for(let[r,i]of Object.entries(e.bindings)){if(i.kind===`literal`){n.set(r,new Set([IT(i.value)]));continue}let e=UT(i,t);if(!e.ok)return{...e,message:`binding \`${r}\`: ${e.message}`};n.set(r,e.kinds)}let r=HT({expr:e.expr,bindingKinds:n});return r.ok?{ok:!0,kinds:r.kinds}:{ok:!1,code:`expression-invalid`,message:r.error}}function JT(e,t,n,r){let i=GT(t);if(i===null)return[WT(e,t.path,r)];let a=[...n].filter(e=>e!==`null`&&e!==i),o=[];return a.length>0&&o.push(R(`kind-mismatch`,r,`\`${e}.${t.path}\` is a ${t.kind}; this source can produce ${a.join(` or `)}`)),n.has(`null`)&&!t.nullable&&o.push(R(`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 Nge(e){if(e.kind!==`expression`)return null;let t=mm(e.expr);if(!t.ok)return null;let n=t.parsed.ast;return n.kind===`literal`&&typeof n.value==`string`?n.value:null}function YT(e,t,n,r){if(t.kind!==`enum`||t.enumValues===void 0)return null;let i=Nge(n);if(i===null||t.enumValues.includes(i))return null;let a=t.enumValues.map(e=>`\`${e}\``).join(`, `);return R(`kind-mismatch`,r,`\`${e}.${t.path}\` accepts only ${a}; this source is the literal \`${i}\``)}function XT(e){if(e.kind!==`expression`)return`derived`;if(VT(e.expr,`count`))return`accumulator`;if(LC(e).length>0)return`derived`;let t=mm(e.expr);return t.ok&&t.parsed.identifiers.has(`now`)?`clock`:`constant`}function ZT(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:R(`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 QT={resettable:!1};function Pge(e){return new Set([e.keyField,...e.labelField===void 0?[]:[e.labelField],...Object.keys(QT)])}function Fge(e,t,n){let r=HC(e.itemSchema,t);return r===null||!r.required?!1:GC(e.itemSchema,t).every(e=>n.some(t=>t.startsWith(`${e}.`)))}function Ige({capName:e,itemArray:t,reserved:n},r,i){let a=Object.keys(r.fields);return nh(t.itemSchema).flatMap(o=>{if(n.has(o.path)||o.path in r.fields||!Fge(t,o.path,a))return[];let s=HC(t.itemSchema,o.path);return s===null||s.nullable?[]:[R(`missing-field`,`${i}.fields.${o.path}`,`\`${e}.${t.path}[].${o.path}\` is required and has no source`)]})}function Lge(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 AT(R(`item-field-reserved`,u,`\`${n}.${r.path}[].${c}\` is set by the composer itself — it takes no source`));let d=HC(r.itemSchema,c);if(d===null)return AT(R(`unknown-field`,u,`a \`${n}\` item has no field \`${c}\``));if(d.kind===`union`)return AT(WT(n,c,u));let f=qT(l,a);if(!f.ok)return AT(R(f.code,u,f.message));let p=XT(l),m=ZT(d,p,e.mode,n,u);if(!m.ok)return AT(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:[...LC(l)]},g=YT(n,d,l,u);return{problems:[...JT(n,d,KT(l,d,f.kinds,a),u),...g===null?[]:[g]],fields:[h],features:[],events:[]}}function $T(e,t,n,r,i=`new`){let a=`features[${n}].items`,o=e.status?.itemArray;if(o===void 0)return AT(R(`not-item-array`,a,`\`${e.name}\` has no item array — it takes no \`items\``));if(o.path!==`items`)return AT(R(`not-item-array`,a,`\`${e.name}\`'s item array is at \`${o.path}\`, not \`${xC}\` — not composable yet`));let s={capName:e.name,itemArray:o,reserved:Pge(o),featureIndex:n,lookupCap:r,mode:i},c=Object.entries(t.items??{}).flatMap(([e,t])=>[{problems:Ige(s,t,`${a}.${e}`),fields:[],features:[],events:[]},...Object.entries(t.fields).map(([n,r])=>Lge(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 eE=`deviceId`;function tE(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 nE(e){let t=e.features.flatMap((e,t)=>e.kind===`fields`&&EC(e)?tE(e,t).map(e=>e.command.source):[]);return[...new Map(t.map(e=>[MC(e),e])).values()]}function Rge(e,t){return e.name===`switch`&&t===`toggle`}function rE(e){return Object.entries(e.methods).filter(([t,n])=>n.systemOnly!==!0&&e.composedMethods?.[t]===void 0&&!Rge(e,t)).map(([e])=>e)}function iE(){return Object.fromEntries(rE(DT).map(e=>[e,{kind:`extension`,target:`remote`}]))}var aE={all:new Set,required:new Set};function oE(e,t){let n=e.methods[t]?.input;if(n===void 0)return null;let r=$m(n);if(!(r instanceof se))return null;let i=Object.entries(r.shape).filter(([e])=>e!==eE);return{all:new Set(i.map(([e])=>e)),required:new Set(i.flatMap(([e,t])=>t instanceof re&&!t.safeParse(void 0).success?[e]:[]))}}function sE(e){return typeof e==`object`?gC(e)?[e.$input]:Object.values(e).flatMap(sE):[]}function cE(e){return[...e].map(e=>`\`${e}\``).join(`, `)}function zge(e,t){let{command:n,at:r}=e,i=t(n.cap);if(i===null)return{def:null,problems:[R(`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:[R(`command-source-unknown`,`${r}.method`,`\`${n.cap}\` has no method \`${n.method}\` to forward to`)]}:a.kind===`mutation`?{def:i,problems:[]}:{def:null,problems:[R(`command-source-unknown`,`${r}.method`,`\`${n.cap}.${n.method}\` is a query — a command calls a mutation of the source`)]}}function Bge(e,t,n,r){let{at:i,command:a}=e,o=`${a.cap}.${a.method}`,s=[];if(`deviceId`in r&&s.push(R(`command-input-unknown`,`${i}.args.${eE}`,`\`${eE}\` 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(R(`command-input-unknown`,`${i}.args.${e}`,`\`${o}\` has no input field \`${e}\` (it takes ${cE(n.all)})`));let e=[...n.required].filter(e=>!(e in r));e.length>0&&s.push(R(`command-input-missing`,`${i}.args`,`\`${o}\` needs ${cE(e)}, which \`args\` does not provide`))}let c=e.itemKey===void 0?t:aE;if(c!==null)for(let t of Object.values(r).flatMap(sE))c.all.has(t)||s.push(R(`command-input-unknown`,`${i}.args`,c===aE?`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 ${cE(c.all)})`));return s}function Vge(e,t,n){let{at:r,command:i}=e,a=`${i.cap}.${i.method}`,o=e.itemKey===void 0?t:aE;if(o===null||n===null)return[];let s=[];for(let t of[...o.all].filter(e=>!n.all.has(e)))s.push(R(`command-input-unknown`,`${r}.args`,`\`${e.method}\` takes \`${t}\`, which \`${a}\` does not (it takes ${cE(n.all)}) — add \`args\` to map it`));let c=[...n.required].filter(e=>!o.all.has(e));return c.length>0&&s.push(R(`command-input-missing`,`${r}.args`,`\`${a}\` needs ${cE(c)}, which \`${e.method}\` does not take — add \`args\` to provide it`)),s}function lE(e,t,n){let r=zge(t,n);if(r.def===null)return r.problems;let i=oE(e,t.method),a=oE(r.def,t.command.method),o=t.command.args;return o===void 0?Vge(t,i,a):Bge(t,i,a,o)}function uE(e,t,n){let r=new Set(rE(e));return Object.keys(t.commands??{}).flatMap(t=>{if(r.has(t))return[];let i=e.composedMethods?.[t]!==void 0;return[R(`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 dE(e,t){return e.features.flatMap((e,n)=>e.kind!==`fields`||!EC(e)?[]:tE(e,n).flatMap(e=>{let n=MC(e.command.source),r=t.get(n),i=`${e.at}.source`;return r===void 0||r.kind===`unreadable`?[R(`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`?[R(`source-missing`,i,`source \`${n}\` does not exist`)]:r.caps.has(e.command.cap)?[]:[R(`source-capability-missing`,i,`source \`${n}\` (device ${r.deviceId}) has no \`${e.command.cap}\``)]}))}var fE={fieldPath:`lastFetchedAt`,expr:`now`},pE={fieldPath:`lastChangedAt`,expr:`now`};function mE(e){let{alsoFrom:t,...n}=e;return{...n,family:`numeric`,deviceType:j.Sensor,memberDeviceType:j.Sensor,memberDeviceTypes:[j.Sensor,...t?.deviceTypes??[]],activeWhen:void 0,commandCaps:[],baseUnit:tc(e.quantity),aggregates:PS,accept:[{cap:e.outputCap,fieldPath:e.outputField},...t===void 0?[]:[t.accept]]}}var hE=[j.Climate];function gE(e){return{...e,family:`binary`,deviceType:j.Sensor,memberDeviceType:j.Sensor,memberDeviceTypes:[j.Sensor],activeWhen:void 0,commandCaps:[],quantity:`none`,baseUnit:void 0,aggregates:FS,empty:`offline`}}var _E=[mE({id:`temperature`,summary:`Mean, median, min, max or sum of temperatures. Offline and unknown members are left out, never read as 0 °C.`,role:N.TemperatureSensor,outputCap:`temperature-sensor`,outputField:`temperature`,quantity:`temperature`,defaultAggregate:`mean`,empty:`null`,companions:[fE],alsoFrom:{deviceTypes:hE,accept:{cap:`climate-control`,fieldPath:`currentTemp`}}}),mE({id:`humidity`,summary:`Humidity in percent. Offline and unknown members are left out, never read as 0 %.`,role:N.HumiditySensor,outputCap:`humidity-sensor`,outputField:`humidity`,quantity:`humidity`,defaultAggregate:`mean`,empty:`null`,companions:[fE],alsoFrom:{deviceTypes:hE,accept:{cap:`climate-control`,fieldPath:`currentHumidity`}}}),mE({id:`pressure`,summary:`Pressure in hectopascals. Offline and unknown members are left out, never read as 0 hPa.`,role:N.PressureSensor,outputCap:`pressure-sensor`,outputField:`pressure`,quantity:`pressure`,defaultAggregate:`mean`,empty:`null`,companions:[fE]}),mE({id:`illuminance`,summary:`Illuminance in lux. Offline and unknown members are left out, never read as 0 lx.`,role:N.AmbientLightSensor,outputCap:`ambient-light-sensor`,outputField:`illuminance`,quantity:`illuminance`,defaultAggregate:`mean`,empty:`null`,companions:[fE]}),mE({id:`power`,summary:`Power in watts, summed by default. Nobody reporting omits the key rather than writing 0 W.`,role:N.PowerSensor,outputCap:`power-meter`,outputField:`power`,quantity:`power`,defaultAggregate:`sum`,empty:`omit`,companions:[fE]}),mE({id:`energy`,summary:`Energy in kilowatt-hours, summed by default. Nobody reporting omits the key rather than writing 0 kWh.`,role:N.EnergySensor,outputCap:`power-meter`,outputField:`energy`,quantity:`energy`,defaultAggregate:`sum`,empty:`omit`,companions:[fE]}),mE({id:`battery`,summary:`Battery charge in percent. Offline and unknown members are left out, never read as 0 %.`,role:N.BatterySensor,outputCap:`battery`,outputField:`level`,quantity:`percentage`,defaultAggregate:`mean`,empty:`null`,companions:[{fieldPath:`charging`,expr:`"unknown"`},{fieldPath:`sleeping`,expr:`false`},{fieldPath:`lastUpdated`,expr:`now`}]}),mE({id:`numeric`,summary:`A numeric reading in the members’ shared quantity. Mixed quantities are refused. Nobody reporting publishes null, not 0.`,role:N.NumericSensor,outputCap:`numeric-sensor`,outputField:`value`,quantity:`device`,defaultAggregate:`mean`,empty:`null`,companions:[fE]}),gE({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:N.MotionSensor,outputCap:`motion`,outputField:`detected`,defaultAggregate:`any`,accept:[{cap:`motion`,fieldPath:`detected`}],companions:[{fieldPath:`lastDetectedAt`,expr:`null`},{fieldPath:`autoClearAfterMs`,expr:`null`}]}),gE({id:`contact`,summary:`Any or all open contacts. Offline and unknown members are left out, never read as closed.`,role:N.ContactSensor,outputCap:`contact`,outputField:`entryOpen`,defaultAggregate:`any`,accept:[{cap:`contact`,fieldPath:`entryOpen`}],companions:[pE]}),gE({id:`leak`,summary:`Any or all leak detections. Offline and unknown members are left out, never read as dry.`,role:N.LeakSensor,outputCap:`flood`,outputField:`flooded`,defaultAggregate:`any`,accept:[{cap:`flood`,fieldPath:`flooded`}],companions:[pE]}),gE({id:`smoke`,summary:`Any or all smoke detections. Offline and unknown members are left out, never read as clear.`,role:N.SmokeSensor,outputCap:`smoke`,outputField:`detected`,defaultAggregate:`any`,accept:[{cap:`smoke`,fieldPath:`detected`}],companions:[pE]}),gE({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:N.BinarySensor,outputCap:`binary`,outputField:`on`,defaultAggregate:`any`,accept:[{cap:`motion`,fieldPath:`detected`},{cap:`binary`,fieldPath:`on`}],companions:[pE]}),gE({id:`binary`,summary:`Any or all generic binary sensors. Offline and unknown members are left out, never read as off.`,role:N.BinarySensor,outputCap:`binary`,outputField:`on`,defaultAggregate:`any`,accept:[{cap:`binary`,fieldPath:`on`}],companions:[pE]}),vE({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:j.Switch,outputCap:`switch`,outputField:`on`,member:{cap:`switch`,fieldPath:`on`},commandCaps:[`switch`]}),vE({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:j.Light,outputCap:`switch`,outputField:`on`,member:{cap:`switch`,fieldPath:`on`},commandCaps:[`switch`,`brightness`,`color`]}),vE({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:j.Fan,outputCap:`switch`,outputField:`on`,member:{cap:`switch`,fieldPath:`on`},commandCaps:[`switch`,`fan-control`]}),vE({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:j.Cover,outputCap:`group-active`,outputField:`active`,member:{cap:`cover`,fieldPath:`state`},activeWhen:[`open`,`opening`,`stopped`],commandCaps:[`cover`]}),vE({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:j.Valve,outputCap:`group-active`,outputField:`active`,member:{cap:`valve`,fieldPath:`state`},activeWhen:[`open`,`opening`,`stopped`],commandCaps:[`valve`]}),vE({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:j.Lock,outputCap:`group-active`,outputField:`active`,member:{cap:`lock-control`,fieldPath:`state`},activeWhen:[`locked`],commandCaps:[`lock-control`]}),vE({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:j.MediaPlayer,outputCap:`group-active`,outputField:`active`,member:{cap:`media-player`,fieldPath:`state`},activeWhen:[`playing`,`buffering`],commandCaps:[`media-player`]}),vE({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:j.Climate,memberDeviceTypes:[j.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 vE(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:FS,defaultAggregate:`any`,empty:`offline`,accept:[e.member],companions:[pE]}}var Hge=new Map(_E.map(e=>[e.id,e]));function yE(e){return Hge.get(e)??null}var bE={"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:[j.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}}},Uge={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`}}}},xE={"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}},Wge=`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.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.stream-catalog.stream-signals.timed-run.update.zone-analytics.zone-rules.zones`.split(`.`);function SE(e){return bE[e]??{}}function CE(e,t,n){return wE(e.deviceTypes,t,n)}function wE(e,t,n){return e.length===0||e.some(e=>e===t)?!0:vf(t,n)&&e.includes(j.Light)}function TE(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 EE(e){return{fieldChoice:`operator`,purpose:`historised`,multiple:!1,max:1,deviceTypes:[],accept:DE(e),history:{required:!0,minRetentionMs:null},mustBindCaps:[],exclude:[]}}function DE(e){let t=[];for(let n of Object.keys(bE))for(let[r,i]of Object.entries(SE(n)))i.kind!==`enum`&&(e===`integral`&&i.kind!==`gauge`||t.push({cap:n,fieldPath:r,valueKind:i.kind===`boolean`?`boolean`:`number`}));return t}function OE(e){if(e===`derivative`)return{...EE(`statistic`),accept:kE()};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:kE(),history:{required:!1,minRetentionMs:null},mustBindCaps:[],exclude:[]}}function kE(){return DE(`statistic`).filter(e=>e.valueKind===`number`)}var AE=[`switch`,`brightness`,`color`],Gge=[M.LightColorRgb,M.LightColorHsv,M.LightColorMired];function jE(e){return e===`all`?`all`:`any`}function Kge(e){return e===`all`?`all`:`at-least-one`}function qge(e){return e.length===0?[]:AE.filter(t=>e.every(e=>e.includes(t)))}function ME(e){return e.length===0?[]:Gge.filter(t=>e.every(e=>e.includes(t)))}function Jge(e,t,n,r){return e.flatMap(e=>e.caps.includes(t)?[{deviceId:e.deviceId,cap:t,method:n,args:{...r}}]:[])}async function Yge(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 Xge={kind:`expression`,expr:`now`,bindings:{}};function NE(e,t,n){return{kind:`series`,read:{source:e.source,cap:e.cap,fieldPath:e.fieldPath},publish:t,empty:n}}function Zge(e){return{included:NE(e,`included`,`offline`),excluded:NE(e,`excluded`,`offline`),total:NE(e,`total`,`offline`)}}var Qge={second:`s`,minute:`min`,hour:`h`};function PE(e){let t=SE(e.source.cap)[e.source.fieldPath]?.unit;return t===void 0?null:`${t}/${Qge[e.per]}`}function FE(e){let t=SE(e.cap)[e.fieldPath];return t===void 0?null:t.kind}function IE(e){return FE(e)===null?[R(`member-constraint`,`helper.source`,`${e.cap}.${e.fieldPath} has no history declaration`)]:[]}function LE(e){return{target:{kind:`new`,type:j.Sensor,role:e.role},helper:e.spec,features:[{kind:`fields`,cap:e.cap,fields:{[e.field]:NE(e.member,`value`,e.empty),lastFetchedAt:Xge}},{kind:`fields`,cap:`group-status`,fields:Zge(e.member)}]}}function RE(e,t=mS){let n=[...IE(e.source)],r=FE(e.source);r===`enum`&&n.push(R(`kind-mismatch`,`helper.source`,`a statistic reads a number or a boolean, not a state`)),e.stat===`sum`&&r!==`counter`&&n.push(R(`kind-mismatch`,`helper.stat`,`a gauge has no sum — that is the integral template`));let i=AS(e.window,t);return i.ok||n.push(R(`retention`,`helper.window`,i.reason)),{problems:n,draft:LE({role:N.NumericSensor,cap:`numeric-sensor`,field:`value`,empty:`null`,spec:e,member:e.source})}}function zE(e,t=mS){let n=[...IE(e.source)],r=FE(e.source);(r===`enum`||r===`boolean`)&&n.push(R(`kind-mismatch`,`helper.source`,`a derivative reads a number that moves, not a yes/no or a state`));let i=AS(e.window,t);return i.ok||n.push(R(`retention`,`helper.window`,i.reason)),{problems:n,draft:LE({role:N.NumericSensor,cap:`numeric-sensor`,field:`value`,empty:`null`,spec:e,member:e.source})}}function BE(e,t=mS){let n=[...IE(e.source)],r=FE(e.source),i=e.source.cap===`power-meter`&&e.source.fieldPath===`power`;(r===`counter`||r===`boolean`||r===`enum`)&&n.push(R(`kind-mismatch`,`helper.source`,`an integral reads an instantaneous gauge, not a counter or a state`)),e.output===`energy`&&!i&&n.push(R(`kind-mismatch`,`helper.output`,`energy is the integral of power-meter.power; another reading uses the meter`)),e.output===`meter`&&i&&n.push(R(`kind-mismatch`,`helper.output`,`power integrates to power-meter.energy, which energy dashboards already read`));let a=jS(e.reset,t);a.ok||n.push(R(`retention`,`helper.reset`,a.reason));let o=e.output===`energy`;return{problems:n,draft:LE({role:o?N.EnergySensor:N.NumericSensor,cap:o?`power-meter`:`meter`,field:o?`energy`:`value`,empty:`offline`,spec:e,member:e.source})}}var $ge=/^\d+(?:\.\d+)?$/,e_e=/^-?\d+(?:\.\d+)?$/,t_e=/^dwell\(x (>=|<=) (\d+(?:\.\d+)?), (\d+(?:\.\d+)?), (\d+(?:\.\d+)?)(?:, (\d+))?\)$/,n_e=/^clamp\((x|number\(x\)) \* (-?\d+(?:\.\d+)?) \+ (-?\d+(?:\.\d+)?), (-?\d+(?:\.\d+)?), (-?\d+(?:\.\d+)?)\)$/,r_e=/^(x|number\(x\)) \* (-?\d+(?:\.\d+)?) \+ (-?\d+(?:\.\d+)?)$/,i_e=/^[A-Za-z_][A-Za-z0-9_]*$/;function VE(e){return ZE(e,$ge)}function HE(e){return ZE(e,e_e)}function UE(e){return typeof e==`string`?JSON.stringify(e):typeof e==`number`?HE(e):typeof e==`boolean`?e?`true`:`false`:`null`}function WE(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 GE(e){return i_e.test(e)}function KE(e,t,n,r,i=1){return`dwell(x ${e===`gte`?`>=`:`<=`} ${t}, ${n}, ${r}${i>1?`, ${i}`:``})`}function qE(e,t,n,r,i){let a=`${e} * ${t} + ${n}`;return r===null||i===null?a:`clamp(${a}, ${r}, ${i})`}function JE(e){let t=t_e.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 YE(e){let t=n_e.exec(e);if(t!==null)return QE(t[1],t[2],t[3],t[4],t[5]);let n=r_e.exec(e);return n===null?null:QE(n[1],n[2],n[3],void 0,void 0)}function XE(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 ZE(e,t){if(!Number.isFinite(e))return null;let n=Object.is(e,-0)?`0`:String(e);return t.test(n)?n:null}function QE(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 $E={kind:`expression`,expr:`now`,bindings:{}};function eD(e){return{kind:`from`,source:e.source,cap:e.cap,fieldPath:e.fieldPath}}function tD(e,t){return{kind:`expression`,expr:e,bindings:t}}function a_e(e,t){return e.source.addonId===t.source.addonId&&e.source.stableId===t.source.stableId&&e.cap===t.cap&&e.fieldPath===t.fieldPath}function nD(e,t,n=[]){return{target:{kind:`new`,type:j.Sensor,role:N.NumericSensor},helper:e,features:[{kind:`fields`,cap:`numeric-sensor`,fields:{value:t,lastFetchedAt:$E}},...n]}}function rD(e,t){return{target:{kind:`new`,type:j.Sensor,role:N.BinarySensor},helper:e,features:[{kind:`fields`,cap:`binary`,fields:{on:t,lastChangedAt:$E}}]}}function iD(e){let t=[],n=HE(e.high),r=HE(e.low);n===null&&t.push(R(`kind-mismatch`,`helper.high`,`the high edge is a finite number`)),r===null&&t.push(R(`kind-mismatch`,`helper.low`,`the low edge is a finite number`)),n!==null&&r!==null&&e.low>e.high&&t.push(R(`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=VE(e.onForMs),a=VE(e.offForMs);(i===null||a===null)&&t.push(R(`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:rD(e,tD(`coalesce(schmitt(x, ${n??`0`}, ${r??`0`}${o}), false)`,{x:eD(e.source)}))}}var o_e=[`a`,`b`];function s_e(e){let t=[],n=e.op!==`sum`;return n&&e.inputs.length!==2&&t.push(R(`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(R(`member-constraint`,`helper.inputs`,`a sum takes two or more readings`)),e.inputs.forEach((n,r)=>{e.inputs.slice(0,r).some(e=>a_e(e,n))&&t.push(R(`member-constraint`,`helper.inputs[${r}]`,`this reading is already an input`))}),t}var c_e=[`included`,`excluded`,`total`];function aD(e){let t=s_e(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(c_e.map(e=>[e,r(e)]));return{problems:t,draft:nD(e,r(`value`),[{kind:`fields`,cap:`group-status`,fields:i}])}}let n=Object.fromEntries(e.inputs.slice(0,2).map((e,t)=>[o_e[t]??`a`,eD(e)]));return{problems:t,draft:nD(e,tD(e.op===`difference`?`a - b`:`b == 0 ? null : a / b`,n))}}function l_e(e){let t=[],n=new Set;if(e.inputs.forEach((e,r)=>{let i=`helper.inputs[${r}].name`;GE(e.name)||t.push(R(`expression-invalid`,i,`\`${e.name}\` is not a name — use letters, digits and _, starting with a letter`)),n.has(e.name)&&t.push(R(`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,eD(e.member)])),i=wm({expr:e.expr,bindings:r});return i===null?[]:[R(`expression-invalid`,`helper.expr`,i)]}function oD(e){let t=l_e(e),n=Object.fromEntries(e.inputs.map(e=>[e.name,eD(e.member)])),r=tD(e.expr,n);return{problems:t,draft:e.output===`boolean`?rD(e,r):nD(e,r)}}function u_e(e,t){return e.addonId===t.addonId&&e.stableId===t.stableId}function d_e(e,t){return u_e(e.source,t.source)&&e.cap===t.cap&&e.fieldPath===t.fieldPath}function f_e(e,t){return e.accept.some(e=>e.cap===t.cap&&e.fieldPath===t.fieldPath)}function p_e(e,t){return t.members.flatMap((n,r)=>{let i=`helper.members[${r}]`,a=[];if(!f_e(e,n)){let t=e.accept.map(e=>`${e.cap}.${e.fieldPath}`).join(` or `);a.push(R(`member-constraint`,i,`a ${e.id} group reads ${t}; this member is ${n.cap}.${n.fieldPath}`))}return t.members.slice(0,r).some(e=>d_e(e,n))&&a.push(R(`member-constraint`,i,`this member is already in the group`)),a})}function sD(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 m_e(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,g_e(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]:sD(e,t,n,`value`),...r}},{kind:`fields`,cap:`group-status`,fields:{included:sD(e,t,n,`included`),excluded:sD(e,t,n,`excluded`),total:sD(e,t,n,`total`)}}]}}function h_e(e,t){if(e.family===`actuator`){if(t.active===void 0)return[R(`kind-mismatch`,`helper.active`,`a ${e.id} group needs an active criterion (at-least-one or all)`)];let n=jE(t.active);return t.aggregate===n?[]:[R(`kind-mismatch`,`helper.aggregate`,`active \`${t.active}\` aggregates by \`${n}\`, not \`${t.aggregate}\``)]}return t.active===void 0?[]:[R(`kind-mismatch`,`helper.active`,`a ${e.id} group has no active criterion — that belongs to an actuator group`)]}function cD(e){let t=jC.safeParse(e);return t.success?{ok:!0,composition:t.data}:{ok:!1,problems:[R(`helper-mismatch`,`helper`,`the template did not compile: ${t.error.issues.map(e=>e.message).join(`; `)}`)]}}function g_e(e,t={}){return{kind:`expression`,expr:e,bindings:t}}function lD(e,t=mS){switch(e.kind){case`group`:return __e(e);case`statistic`:{let n=RE(e,t);return n.problems.length>0?{ok:!1,problems:n.problems}:cD(n.draft)}case`integral`:{let n=BE(e,t);return n.problems.length>0?{ok:!1,problems:n.problems}:cD(n.draft)}case`derivative`:{let n=zE(e,t);return n.problems.length>0?{ok:!1,problems:n.problems}:cD(n.draft)}case`threshold`:return uD(iD(e));case`arithmetic`:return uD(aD(e));case`expression`:return uD(oD(e))}}function uD(e){return e.problems.length>0?{ok:!1,problems:e.problems}:cD(e.draft)}function __e(e){let t=yE(e.templateId);if(t===null)return{ok:!1,problems:[R(`member-constraint`,`helper.templateId`,`unknown template \`${e.templateId}\``)]};let n=h_e(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:[R(`kind-mismatch`,`helper.aggregate`,`a ${t.id} group aggregates by ${n}, not \`${e.aggregate}\``)]}}let r=p_e(t,e);return r.length>0?{ok:!1,problems:r}:cD(m_e(t,e))}function dD(e,t){return JSON.stringify(e.target)===JSON.stringify(t.target)&&JSON.stringify(e.features)===JSON.stringify(t.features)}function v_e(e){return e.kind===`group`?yE(e.templateId)?.memberDeviceType??null:null}function y_e(e,t){if(e.kind!==`group`)return[];let n=yE(e.templateId);if(n===null||n.family!==`numeric`)return[];let r=e.members.flatMap((e,n)=>{let r=t.get(MC(e.source))?.quantity;return r===void 0?[]:[{index:n,quantity:r}]});if(n.quantity!==`device`)return r.flatMap(e=>e.quantity===n.quantity?[]:[R(`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?[]:[R(`mixed-quantity`,`helper.members`,`a numeric group requires one quantity; members report ${i.join(` and `)}`)]}function b_e(e,t){if(e.kind!==`group`)return[];let n=yE(e.templateId);return n===null?[]:e.members.flatMap((e,r)=>{let i=t.get(MC(e.source)),a=i?.deviceType;return a===void 0||wE(n.memberDeviceTypes,a,i?.role)?[]:[R(`member-constraint`,`helper.members[${r}]`,`a ${n.id} group takes ${n.memberDeviceTypes.join(` or `)} devices; this member is a ${a}`)]})}function fD(e,t){let n=e.helper;if(n===void 0)return[];let r=lD(n);return r.ok?dD(e,r.composition)?n.kind===`arithmetic`?x_e(n,t):n.kind===`group`?[...y_e(n,t),...b_e(n,t)]:[]:[R(`helper-mismatch`,`helper`,`the stored features are not this template — the helper spec is the only writer`)]:r.problems}function x_e(e,t){let n=e.inputs.flatMap(e=>{let n=t.get(MC(e.source))?.quantity;return n===void 0?[]:[n]}),r=[...new Set(n)];return r.length<=1?[]:[R(`mixed-quantity`,`helper.inputs`,`a ${e.op} needs readings of one quantity; these inputs report ${r.join(` and `)}`)]}var pD=class extends Error{};function S_e(e){return new Set(e.composition.features.flatMap(e=>!EC(e)||e.kind!==`fields`?[]:zC(e).map(({fieldPath:t})=>`${e.cap}.${t}`)))}function C_e(e,t,n){if(MC(n.source)!==MC(e.target))return!0;let r=`${n.cap}.${n.fieldPath}`;return t.has(r)&&e.replaced?.has(r)!==!0}function w_e(e){let t=S_e(e);return e.composition.features.flatMap(n=>!EC(n)||n.kind!==`fields`?[]:zC(n).map(({fieldPath:r,source:i})=>[PC({source:e.target,cap:n.cap,fieldPath:r}),LC(i).filter(n=>C_e(e,t,n)).map(PC)]))}function T_e(e,t){let n=MC(e.target),r=new Map;for(let i of t){if(i.blockId===e.blockId)continue;let t=MC(i.target);if(t===n)throw new pD(`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 pD(`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 mD(e,t){let n=T_e(e,t).flatMap(w_e);return new Map(n)}function E_e(e,t){let n=mD(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 D_e(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 O_e(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 hD(e,t){let n=mD(e,t),r=`${MC(e.target)}#`;return D_e(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:O_e(t,i,n),component:i}]})}var gD=S([`no-power-source`,`switch-missing`,`switch-offline`,`switch-unknown`,`restart-in-progress`,`switch-call-failed`,`switch-is-actuator`]),_D=a(`accepted`,[x({accepted:s(!0)}),x({accepted:s(!1),reason:gD,message:m()})]),vD=x({linked:y(),switchDeviceId:p().nullable(),switchName:m().nullable(),switchOn:y().nullable(),switchOnline:y().nullable(),restartInProgress:y(),offSeconds:p().int()}),yD=x({switchOn:y().nullable(),offSeconds:p().int(),lastFetchedAt:p()}),bD=[j.Gateway,j.Camera,j.Sensor,j.MediaPlayer,j.Vacuum,j.Generic,j.Washer,j.Dryer,j.Dishwasher,j.PetFountain,j.Fan,j.Humidifier,j.Climate,j.WaterHeater],k_e={version:1,targets:[{id:`switch`,cardinality:`scalar`,vocabulary:{cap:`power-source`,stateField:`switchOn`},deviceTypes:bD,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`}}]},xD=x({deviceId:p().int().nonnegative()}),SD={name:`power-source`,scope:`device`,mode:`singleton`,deviceTypes:bD,methods:{getStatus:oi(xD,vD,{auth:`protected`}),powerOn:oi(xD,_D,{kind:`mutation`,auth:`protected`,actions:[{id:`powerSource.on`,label:I(`Power on`,`Dai corrente`),phrase:I(`Power on {device}`,`Dai corrente a {device}`),icon:`power`}]}),powerOff:oi(xD,_D,{kind:`mutation`,auth:`protected`,actions:[{id:`powerSource.off`,label:I(`Power off`,`Togli corrente`),phrase:I(`Cut the power of {device}`,`Togli la corrente a {device}`),icon:`power-off`}]}),forceRestart:oi(xD,_D,{kind:`mutation`,auth:`protected`,actions:[{id:`powerSource.forceRestart`,label:I(`Force restart`,`Riavvio forzato`),phrase:I(`Force restart {device} by cutting its power`,`Riavvia {device} togliendo la corrente`),icon:`refresh-cw`}]})},runtimeState:yD,customize:k_e,durability:`session`,history:`none`,vocabulary:{noun:I(`Power source`,`Alimentazione`),order:1050,state:[{kind:`boolean`,field:`switchOn`,label:I(`Power switch on`,`Presa accesa`),whenTrue:I(`When the power of {device} comes on`,`Quando arriva la corrente a {device}`),whenFalse:I(`When the power of {device} is cut`,`Quando manca la corrente a {device}`),icon:`power`}]}};function CD(e){return typeof e!=`number`||!Number.isFinite(e)?10:Math.min(120,Math.max(3,Math.round(e)))}function A_e(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 j_e(e,t){if(e===null)return null;let n;if(e.target.kind===`existing`)n=e.target.device;else if(t!==void 0)n=IC(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=LC(i).find(e=>e.cap===`switch`);return a===void 0?null:{device:n,switch:a.source,offSeconds:CD(A_e(e))}}var wD=`switch`;function M_e(e){let t=new Set;return e.target.kind===`existing`&&t.add(MC(e.target.device)),e.features.forEach((e,n)=>{if(!(e.kind!==`fields`||e.cap!==wD)&&EC(e)){for(let n of BC(e))for(let e of LC(n))t.add(MC(e.source));for(let r of tE(e,n))t.add(MC(r.command.source))}}),t}function TD(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=M_e(e);return LC(r).filter(e=>e.cap===wD&&i.has(MC(e.source))).map(e=>({path:`features[${t}].fields.switchOn`,switch:e.source}))}function ED(e){let t=new Map(e.map(e=>[e.name,e]));return e=>t.get(e)??null}var DD=new Set([`device-status`,`feature-probe`]),N_e={addonId:nC,stableId:`${tC}(unsaved)`},P_e=`(unsaved)`;function F_e(e,t,n){let r=n(e.cap);if(r===null)return R(`unknown-capability`,`${t}.cap`,`no capability is named \`${e.cap}\``);if(DD.has(r.name))return R(`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?R(`not-composable`,`${t}.cap`,`\`${r.name}\` has no per-device state to compose`):{def:r,state:i,fields:UC(i)}}function I_e(e){let t=e.helper;if(t===void 0||t.kind!==`group`)return new Set;let n=yE(t.templateId);return n===null||n.family!==`actuator`?new Set:new Set(n.commandCaps)}function L_e(e,t){return e.name===DT.name&&Object.values(t.commands??{}).some(e=>e.kind===`extension`)}function R_e({def:e,state:t,fields:n},r,i,a,o){let s=[];e.deviceTypes!==void 0&&!e.deviceTypes.includes(a)&&s.push(R(`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=rE(e).filter(e=>!c.has(e)).map(e=>`\`${e}\``);l.length>0&&!o.has(e.name)&&s.push(R(`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=L_e(e,r);for(let a of d?[]:WC(t))a!==u&&(n.has(a)?a in r.fields||s.push(R(`missing-field`,`${i}.fields.${a}`,`\`${e.name}.${a}\` is required and has no source`)):s.push(R(`not-composable`,`${i}.fields`,`\`${e.name}.${a}\` is not a scalar — nested fields arrive in a later slice`)));return s}function z_e({fields:e,state:t},n,r){return n.includes(`.`)?r===`replace`?HC(t,n)??void 0:`nested`:e.get(n)}function B_e(e,t,n,r){let{def:i}=e,{featureIndex:a,path:o,source:s}=t,c=`features[${a}].fields.${o}`,l=z_e(e,o,n);if(l===`nested`)return AT(R(`nested-field`,c,`\`${o}\` is nested — a nested field is planned only on a declared replace (D1034)`));if(l===void 0)return AT(R(`unknown-field`,c,`\`${i.name}\` has no field \`${o}\``));if(l.kind===`union`)return AT(WT(i.name,o,c));let u=qT(s,r);if(!u.ok)return AT(R(u.code,c,u.message));let d=XT(s),f=ZT(l,d,n,i.name,c);if(!f.ok)return AT(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:[...LC(s)]},h=YT(i.name,l,s,c);return{problems:[...JT(i.name,l,KT(s,l,u.kinds,r),c),...h===null?[]:[h]],fields:[m],features:[],events:[]}}function V_e(e,t,n,r,i){let a=`features[${n}]`,o=tE(t,n),s=Object.entries(t.commands??{}).filter(([,e])=>e.kind===`code`).map(([e])=>R(`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!==DT.name?[...s,...c.map(([t])=>R(`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,R(`reserved-variant`,`${a}.commands`,"commands (`forward`) are served only by a capability a NEW device builds — not on an existing device")]:[...s,...uE(e,t,a),...o.flatMap(t=>lE(e,t,i))]}function OD(e,t,n,r,i){let a=`features[${t}]`,o=F_e(e,a,r);if(`code`in o)return AT(o);let s=n.mode===`replace`?[]:[...R_e(o,e,a,n.deviceType,i)];s.push(...V_e(o.def,e,t,n.mode,r));let c=Object.entries(e.fields).map(([e,i])=>B_e(o,{featureIndex:t,path:e,source:i},n.mode,r)),l=e.items===void 0?[]:[$T(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=YC(o.def,f,d);return{problems:[...s,...u.flatMap(e=>e.problems),...p.problems],fields:d,features:[f],events:p.events}}function kD(e,t){let n=e.nativeCaps.get(t);return n!==void 0&&n!==`composer`}function H_e(e){return`code`in e}function U_e(e,t){if(e.target.kind===`new`)return{kind:`new`,type:e.target.type};let n=MC(e.target.device);return t===void 0?R(`target-unreadable`,`target`,`target device \`${n}\` was not read — the save is refused rather than stored unchecked`):t.kind===`absent`?R(`target-missing`,`target`,`target device \`${n}\` does not exist`):t.kind===`unreadable`?R(`target-unreadable`,`target`,`could not read target device \`${n}\` (${t.error}) — the save is refused rather than stored unchecked`):{kind:`existing`,found:t}}var W_e=new Set([`not-composable`,`unknown-capability`,`reserved-variant`]);function G_e(e,t){let n=t.problems.filter(e=>W_e.has(e.code));return n.length>0?{problems:n,fields:[],features:[],events:[]}:AT(e)}var K_e=OT;function q_e(e){let t=K_e[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 J_e(e,t,n){let r=t.cap;return e.kind===`new`?{mode:`new`,deviceType:e.type}:kD(e.found,r)?q_e(t)?{mode:`replace`,deviceType:e.found.type}:R(`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 AD(e,t,n){let r=U_e(e,n);if(`code`in r)return AT(r);let i=I_e(e),a=e.features.map((e,n)=>{let a=`features[${n}]`;if(e.kind===`passthrough`)return AT(R(`reserved-variant`,a,`whole-capability passthrough of \`${e.cap}\` arrives in slice 3`));let o=J_e(r,e,a);if(H_e(o))return!EC(e)||r.kind!==`existing`?{problems:[],fields:[],features:[],events:[]}:G_e(o,OD(e,n,{mode:`add`,deviceType:r.found.type},t,i));let s=OD(e,n,o,t,i);return EC(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 Y_e(e){let t=e.features.flatMap(e=>EC(e)&&e.kind===`fields`?BC(e).flatMap(LC).map(e=>e.source):[]);return[...new Map([...t,...nE(e)].map(e=>[MC(e),e])).values()]}function X_e(e,t){return e.features.flatMap(e=>EC(e)&&e.kind===`fields`?BC(e).flatMap(e=>{if(e.kind!==`from`)return[];let n=t(e.cap),r=n?.runtimeState??n?.status?.schema;return r===void 0?[]:HC(r,e.fieldPath)?.kind===`union`?[e]:[]}):[])}function Z_e(e,t,n){return{ref:e.target.kind===`existing`?e.target.device:t.self??N_e,native:e.target.kind===`existing`&&t.target?.kind===`found`?t.target:null,replaced:jD(n)}}function jD(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(rw))}function Q_e(e,t,n,r){let i=`${e.cap}.${e.fieldPath}`;return n.some(e=>rw(e)===i&&!r.replaced.has(i))?[]:r.native===null?[R(`source-field-unknown`,t,`this device has no composed field \`${e.cap}.${e.fieldPath}\``)]:kD(r.native,e.cap)?[]:[R(`source-capability-missing`,t,`the target device (device ${r.native.deviceId}) has no native \`${e.cap}\``)]}function $_e(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?[]:[R(`source-kind-mismatch`,r,`\`${t.cap}.${t.fieldPath}\` of device ${n.deviceId} reads a ${i} now; \`${e.cap}.${e.path}\` takes a ${a}`)]}function eve(e,t,n){let r=MC(n.ref);return e.flatMap(i=>i.reads.flatMap(a=>{let o=jT(i),s=MC(a.source);if(s===r)return Q_e(a,o,e,n);let c=t.sources.get(s);return c===void 0||c.kind===`unreadable`?[R(`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`?[R(`source-missing`,o,`source \`${s}\` does not exist`)]:c.caps.has(a.cap)?$_e(i,a,c,o):[R(`source-capability-missing`,o,`source \`${s}\` (device ${c.deviceId}) has no \`${a.cap}\``)]}))}function tve(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 nve(e,t,n){for(let r of e){let e=tve(r,t);if(e===null)continue;let i=`${e.cap}.${e.fieldPath}`,a=n.find(e=>rw(e)===i);if(a!==void 0)return jT(a)}return`features`}function rve(e,t){for(let[n,r]of t)if(e.some(e=>e.startsWith(`${n}#`)))return{key:n,error:r};return null}function ive(e,t,n,r){let i={blockId:t.blockId??`(unsaved)`,target:r.ref,composition:e,replaced:r.replaced},a=MC(i.target),o=t.unreadTargets??new Map;try{return hD(i,t.peers).map(e=>{let t=nve(e.path,a,n),r=rve([...e.component],o);return r===null?R(`cycle`,t,`a field reads itself: ${e.path.join(` → `)}`):R(`cycle`,t,`possible cycle through \`${r.key}\` — its state could not be read (${r.error}): ${e.path.join(` → `)}`)})}catch(e){if(e instanceof pD)return[R(`duplicate-target`,`features`,e.message)];throw e}}function MD(e,t){let n=AD(e,t.lookupCap,t.target??void 0),r=Z_e(e,t,n),i=n.problems.filter(e=>e.code===`native-capability-replace`).map(e=>e.path),a=ive(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,...eve(n.fields,t,r),...dE(e,t.sources),...a,...fD(e,o),...TD(e).map(e=>R(`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 ND=x({path:m(),kind:QC,nullable:y(),required:y(),enumValues:C(m()).optional()}),PD=x({cap:m(),fields:C(ND),itemArray:x({path:m(),keyField:m()}).optional()}),FD=x({caps:C(PD)});function ID(e,t){if(DD.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=UC(n),a=e.status?.itemArray?.path??null;return WC(n).some(e=>e!==a&&!i.has(e))&&r.push(`not-composable`),YC(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 ave(e,t){return e.filter(e=>ID(e,t).length===0).map(e=>{let t=e.runtimeState,n=t===void 0?[]:[...UC(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 LD=x({addonId:m().min(1),stableId:m().min(1),cap:m().min(1),fieldPath:m().min(1)}),ove=x({kind:s(`identity`)}),sve=x({kind:s(`invert`)}),RD=x({kind:s(`threshold`),comparison:S([`gte`,`lte`]),threshold:p(),startDwellMs:p().nonnegative(),stopDwellMs:p().nonnegative(),minSamples:p().int().min(1).optional()}),zD=a(`kind`,[ove,sve,RD,x({kind:s(`linear`),scale:p(),offset:p(),clampMin:p().optional(),clampMax:p().optional()}),x({kind:s(`enum-map`),mapping:d(m(),m().nullable())}),x({kind:s(`number`)})]),cve=x({kind:s(`scalar`),cap:m().min(1),targetId:m().min(1),source:LD,transform:zD}),lve=x({kind:s(`keyedArray`),cap:m().min(1),targetId:m().min(1),key:m().min(1),label:m().min(1),fieldPath:m().min(1),source:LD,transform:zD}),uve=x({kind:s(`pulse`),cap:m().min(1),targetId:m().min(1),enabled:y(),debounceMs:p().nonnegative(),edges:C(S([`rising`,`button`,`native-event`])).min(1).optional(),sources:C(LD).min(1)}),dve=LD.extend({mode:S([`in-addition`,`confirm`,`replace`]).optional()}),fve=a(`kind`,[cve,lve,uve,x({kind:s(`span`),cap:m().min(1),targetId:m().min(1),timeoutMs:p().nonnegative(),cooldownMs:p().nonnegative().optional(),sources:C(dve)})]),pve=x({targetId:m().min(1),configured:y(),source:S([`native`,`assigned`]),state:S([`active`,`stale`,`released`,`unavailable`]),reason:m().nullable()}),BD=S([`raw`,`5m`]),VD=S([`high`,`medium`,`low`]),HD=S([`no-history`,`span-too-short`,`truncated`,`no-idle-floor`,`no-runs`,`no-separation`]),UD=x({intervals:p().int().nonnegative(),extra:p().int().nonnegative(),missed:p().int().nonnegative()}),WD=x({tier:BD,spanMs:p().nonnegative(),from:p(),to:p(),points:p().int().nonnegative(),runsFound:p().int().nonnegative(),pausesFound:p().int().nonnegative(),longestPauseMs:p().nonnegative(),pulsesFound:p().int().nonnegative(),longestPulseMs:p().nonnegative(),idleFloorW:p(),noiseCeilingW:p(),plateauW:p(),replay:UD}),GD=x({spanMs:p().nonnegative(),points:p().int().nonnegative(),runsFound:p().int().nonnegative()}),KD=a(`state`,[x({state:s(`proposal`),transform:RD,evidence:WD,confidence:VD,notes:C(m())}),x({state:s(`insufficient`),reason:HD,evidence:GD,fallback:RD})]),qD=x({apply:y()}),JD=x({apply:y(),rows:p().int(),raw:p().int(),markers:p().int(),migrated:p().int(),failed:p().int(),remainingRaw:p().int(),unresolvedMarkers:p().int(),redundantCopies:p().int().optional(),verified:y()}),YD=`core-block-`,XD=`core-blocks`;function ZD(e){return`${YD}${e}`}function mve(e){if(!e.startsWith(`core-block-`))return null;let t=e.slice(11);return t.length>0?t:null}var QD=l([s(`hub`),m().min(1)]),$D=S([`stopped`,`starting`,`running`,`degraded`,`incomplete`,`failed`]),eO=`main.ts`,tO=d(m().min(1).max(260),m().max(2e5)),nO=_e(),rO=x({name:m().min(1).max(120),code:m().max(2e5).optional(),files:tO.optional(),entry:m().min(1).max(260).optional(),enabled:y(),placement:QD,integrationId:m().optional(),settingsSchema:nO.optional(),tags:Qu.optional()}),iO=rO.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 aO(e){return e!==void 0&&e.length>0?e:eO}function oO(e){let t=aO(e.entry);return e.files===void 0?{files:{[t]:e.code},entry:t}:{files:{...e.files},entry:t}}function hve(e){if(e.files!==void 0){let t=aO(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 sO=a(`kind`,[x({kind:s(`code`)}),x({kind:s(`recipe`),recipe:t_}),x({kind:s(`composition`),composition:jC})]),cO=x({name:m().min(1).max(120).optional(),enabled:y(),composition:jC}),lO=x({name:m().min(1).max(120),code:m().max(2e5),files:tO.optional(),entry:m().min(1).max(260).optional(),enabled:y(),placement:QD,integrationId:m().optional(),settingsSchema:nO.optional(),tags:Qu.optional(),id:m(),createdAt:p(),updatedAt:p(),createdBy:m(),status:$D,lastError:m().optional(),lastChangedAt:p(),source:sO.optional()});function uO(e){return e.source?.kind??`code`}function dO(e){return e.source?.kind===`composition`?e.source.composition:null}var fO=a(`kind`,[x({kind:s(`answered`),state:uw.nullable()}),x({kind:s(`unreachable`),error:m()})]),pO=x({block:lO,state:fO}),mO=x({state:s(`not-loaded`),reason:m()}),hO=a(`state`,[x({state:s(`loaded`),views:C(pO)}),mO]),gO=a(`state`,[x({state:s(`loaded`),view:pO.nullable()}),mO]),_O=a(`state`,[x({state:s(`loaded`),view:pO.nullable()}),mO]),vO=x({ok:y(),error:m().optional(),line:p().optional(),column:p().optional()}),yO=x({code:m().optional(),files:tO.optional(),entry:m().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`]})}),bO={name:`core-blocks`,scope:`system`,mode:`singleton`,methods:{list:E(x({}),x({blocks:C(lO)}),{auth:`admin`}),get:E(x({blockId:m()}),x({block:lO.nullable()}),{auth:`admin`}),create:E(x({block:iO}),x({block:lO}),{kind:`mutation`,auth:`admin`,caller:`required`}),update:E(x({blockId:m(),block:rO.partial()}),x({block:lO}),{kind:`mutation`,auth:`admin`,caller:`required`}),delete:E(x({blockId:m()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),setEnabled:E(x({blockId:m(),enabled:y()}),x({block:lO}),{kind:`mutation`,auth:`admin`}),restart:E(x({blockId:m()}),x({block:lO}),{kind:`mutation`,auth:`admin`}),compile:E(yO,vO,{kind:`mutation`,auth:`admin`}),getBlockSettings:E(x({blockId:m()}),Fv.nullable(),{auth:`admin`}),updateBlockSettings:E(x({blockId:m(),patch:Iv}),Rv,{kind:`mutation`,auth:`admin`}),migrateRawSecrets:E(qD,JD,{kind:`mutation`,auth:`admin`}),getTypeDefs:E(x({}),x({libs:C(x({filePath:m(),content:m()}))}),{auth:`admin`}),createComposition:E(x({block:cO}),x({block:lO}),{kind:`mutation`,auth:`admin`,caller:`required`}),updateComposition:E(x({blockId:m(),expectedUpdatedAt:p(),block:cO.partial()}),x({block:lO}),{kind:`mutation`,auth:`admin`,caller:`required`}),getComposition:E(x({blockId:m()}),gO,{auth:`admin`}),listCompositions:E(x({}),hO,{auth:`admin`}),getCustomization:E(x({addonId:m().min(1),stableId:m().min(1)}),_O,{auth:`admin`}),listComposableCaps:E(x({deviceType:S(j)}),FD,{auth:`admin`}),validateComposition:E(x({composition:jC,blockId:m().optional()}),ow,{kind:`mutation`,auth:`admin`,access:`view`}),proposeRunningThreshold:E(x({deviceId:p().int(),cap:m().min(1),fieldPath:m().min(1),deviceType:S(j).optional()}),KD,{auth:`admin`,access:`view`}),reportAutomationRun:E(x({blockId:m().min(1),trace:y_.optional(),runStartedAt:p().optional(),keepTraces:p().int().min(1).max(100).optional()}),v(),{kind:`mutation`,auth:`admin`}),getAutomationRunState:E(x({blockId:m().min(1)}),Gue,{auth:`admin`}),getTraces:E(x({blockId:m().min(1)}),x({traces:C(y_),lastError:m().nullable()}),{auth:`admin`})},vocabulary:{notOperatorFacing:O.INTERNAL}},xO=S([`open`,`opening`,`closing`,`closed`,`stopped`]),SO=x({state:xO,position:p().min(0).max(100).nullable().meta(k(`percentage`)),tiltPosition:p().min(0).max(100).nullable().meta(k(`percentage`)),lastChangedAt:p()}),CO={name:`cover`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Cover],methods:{open:E(x({deviceId:p().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.open`,label:I(`Open`,`Apri`),phrase:I(`Open {device}`,`Apri {device}`),icon:`arrow-up-to-line`,effect:{field:`state`,value:`open`}}]}),close:E(x({deviceId:p().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.close`,label:I(`Close`,`Chiudi`),phrase:I(`Close {device}`,`Chiudi {device}`),icon:`arrow-down-to-line`,effect:{field:`state`,value:`closed`}}]}),stop:D(x({deviceId:p().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.stop`,label:I(`Stop`,`Ferma`),phrase:I(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),setPosition:D(x({deviceId:p().int().nonnegative(),position:p().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.position`,label:I(`Set position`,`Imposta la posizione`),phrase:I(`Move {device} to {position} open`,`Porta {device} al {position} di apertura`),icon:`blinds`,effect:{field:`position`,fromArg:`position`},openArgs:[{key:`position`,label:I(`Position`,`Posizione`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setTiltPosition:D(x({deviceId:p().int().nonnegative(),tiltPosition:p().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.tilt`,label:I(`Set tilt`,`Imposta l’inclinazione`),phrase:I(`Tilt {device} to {tiltPosition}`,`Inclina {device} al {tiltPosition}`),icon:`blinds`,effect:{field:`tiltPosition`,fromArg:`tiltPosition`},openArgs:[{key:`tiltPosition`,label:I(`Tilt`,`Inclinazione`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]})},status:{schema:SO,kind:`push`},runtimeState:SO,durability:`restored`,history:{fields:{position:{kind:`gauge`,unit:`%`,minIntervalMs:0}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:I(`Cover`,`Copertura`),order:1030,state:[{kind:`enum`,field:`state`,label:I(`State`,`Stato`),values:[{value:`open`,label:I(`Open`,`Aperto`),phrase:I(`When {device} is fully open`,`Quando {device} è tutto aperto`)},{value:`opening`,label:I(`Opening`,`In apertura`),phrase:I(`When {device} starts opening`,`Quando {device} inizia ad aprirsi`)},{value:`closing`,label:I(`Closing`,`In chiusura`),phrase:I(`When {device} starts closing`,`Quando {device} inizia a chiudersi`)},{value:`closed`,label:I(`Closed`,`Chiuso`),phrase:I(`When {device} is fully closed`,`Quando {device} è tutto chiuso`)},{value:`stopped`,label:I(`Stopped`,`Fermo`),phrase:I(`When {device} stops part-way`,`Quando {device} si ferma a metà`)}],icon:`blinds`},{kind:`numeric`,field:`position`,quantity:I(`the opening`,`l’apertura`),label:I(`Position`,`Posizione`),unit:`%`,icon:`blinds`}],overrides:{byRole:{[N.CoverGarage]:{actions:{"cover.open":{phrase:I(`Open the garage door {device}`,`Apri il garage {device}`),icon:`warehouse`},"cover.close":{phrase:I(`Close the garage door {device}`,`Chiudi il garage {device}`),icon:`warehouse`}}},[N.CoverGate]:{actions:{"cover.open":{phrase:I(`Open the gate {device}`,`Apri il cancello {device}`),icon:`fence`},"cover.close":{phrase:I(`Close the gate {device}`,`Chiudi il cancello {device}`),icon:`fence`}}},[N.CoverDoor]:{actions:{"cover.open":{phrase:I(`Open the door {device}`,`Apri la porta {device}`),icon:`door-open`},"cover.close":{phrase:I(`Close the door {device}`,`Chiudi la porta {device}`),icon:`door-closed`}}},[N.CoverWindow]:{actions:{"cover.open":{phrase:I(`Open the window {device}`,`Apri la finestra {device}`),icon:`app-window`},"cover.close":{phrase:I(`Close the window {device}`,`Chiudi la finestra {device}`),icon:`app-window`}}},[N.CoverShutter]:{actions:{"cover.open":{phrase:I(`Raise the shutter {device}`,`Alza la tapparella {device}`)},"cover.close":{phrase:I(`Lower the shutter {device}`,`Abbassa la tapparella {device}`)}}},[N.CoverAwning]:{actions:{"cover.open":{phrase:I(`Extend the awning {device}`,`Apri la tenda da sole {device}`)},"cover.close":{phrase:I(`Retract the awning {device}`,`Chiudi la tenda da sole {device}`)}}}}}}},wO=x({stepId:m(),entry:Zd}),TO=x({path:m().min(1),bytes:p().int().nonnegative(),sha256:m().regex(/^[0-9a-f]{64}$/)}),EO=x({addonId:m(),stepId:m().min(1),entries:C(Zd).min(1).max(4),bundle:x({ticket:Ja,bytes:p().int().positive(),sha256:m().regex(/^[0-9a-f]{64}$/)}),files:C(TO).min(1).max(64),distribute:y()}),DO=a(`kind`,[x({kind:s(`imported`),modelIds:C(m()).readonly(),distributed:C(x({modelId:m(),nodeId:m(),format:S(Rd),ok:y(),error:m().optional()})).readonly()}),x({kind:s(`refused`),reason:S([`transfer-failed`,`checksum-mismatch`,`bundle-mismatch`,`invalid-entry`,`id-taken`]),detail:m()})]),OO={name:`custom-model-registry`,scope:`system`,mode:`collection`,internal:!0,methods:{listModels:E(v(),C(wO).readonly(),{auth:`admin`}),importModelBundle:E(EO,DO,{kind:`mutation`,auth:`admin`,timeoutMs:30*6e4})},vocabulary:{notOperatorFacing:O.ML}},kO=x({engineId:m(),kind:S([`relational`,`vector`]),displayName:m()}),AO={name:`data-store-provider`,scope:`system`,mode:`collection`,internal:!0,methods:{getEngineInfo:E(v(),kO,{auth:`admin`}),get:E(x({namespace:m().optional(),collection:m(),key:m()}),u(),{auth:`admin`}),set:E(x({namespace:m().optional(),collection:m(),key:m(),value:u()}),v(),{kind:`mutation`,auth:`admin`}),query:E(x({namespace:m().optional(),collection:m(),filter:Do.optional(),columns:C(m()).readonly().optional()}),C(ko).readonly(),{auth:`admin`}),insert:E(x({namespace:m().optional(),collection:m(),record:x({id:m().optional(),data:d(m(),u())})}),x({id:l([m(),p()])}),{kind:`mutation`,auth:`admin`}),upsert:E(x({namespace:m().optional(),collection:m(),conflict:C(m()).readonly(),record:Ao}),x({id:l([m(),p()])}),{kind:`mutation`,auth:`admin`}),upsertMany:E(x({namespace:m().optional(),collection:m(),conflict:C(m()).readonly(),records:C(Ao).readonly()}),x({upserted:p().int()}),{kind:`mutation`,auth:`admin`}),insertMany:E(x({namespace:m().optional(),collection:m(),records:C(Ao).readonly()}),x({inserted:p().int()}),{kind:`mutation`,auth:`admin`}),transact:E(x({namespace:m().optional(),guard:die.optional(),ops:C(uie).readonly()}),x({applied:y(),current:u().optional()}),{kind:`mutation`,auth:`admin`}),update:E(x({namespace:m().optional(),collection:m(),id:m(),data:d(m(),u())}),v(),{kind:`mutation`,auth:`admin`}),delete:E(x({namespace:m().optional(),collection:m(),key:m()}),v(),{kind:`mutation`,auth:`admin`}),deleteWhere:E(x({namespace:m().optional(),collection:m(),filter:Oo}),x({deleted:p().int()}),{kind:`mutation`,auth:`admin`}),updateWhere:E(x({namespace:m().optional(),collection:m(),filter:Oo,data:d(m(),u())}),x({updated:p().int()}),{kind:`mutation`,auth:`admin`}),count:E(x({namespace:m().optional(),collection:m(),filter:Do.optional()}),p(),{auth:`admin`}),aggregate:E(x({namespace:m().optional(),collection:m(),fields:C(sie).readonly(),filter:Do.optional()}),cie,{auth:`admin`}),histogram:E(x({namespace:m().optional(),collection:m(),field:m(),bucketSize:p().int().positive(),origin:p().int(),filter:Do.optional()}),C(x({bucket:p().int(),count:p().int()})).readonly(),{auth:`admin`}),isEmpty:E(x({namespace:m().optional(),collection:m()}),y(),{auth:`admin`}),declareCollection:E(Mo,v(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.INTERNAL}},jO=S([`auto`,`day`,`night`,`schedule`]),MO=x({min:p(),max:p(),step:p()}),NO=x({mode:jO,sensitivity:p().optional().meta(k(`none`)),switchDelaySec:p().optional().meta(k(`duration`)),lastFetchedAt:p()}),PO=x({modes:C(jO),supportsSensitivity:y(),sensitivity:MO.optional(),supportsSwitchDelay:y(),switchDelaySec:MO.optional()}),FO=x({mode:jO.optional(),sensitivity:p().optional(),switchDelaySec:p().optional()}),IO={name:`day-night`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],deviceConfig:{ui:{kind:`derived-form`,builderId:`day-night`,tab:`image`}},methods:{getOptions:E(x({deviceId:p()}),PO),setSettings:E(x({deviceId:p(),settings:FO}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`dayNight.auto`,label:I(`Day/night auto`,`Giorno/notte automatico`),phrase:I(`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:I(`Day mode`,`Modalità giorno`),phrase:I(`Force {device} into day mode`,`Forza {device} in modalità giorno`),icon:`sun`,args:{settings:{mode:`day`}}},{id:`dayNight.night`,label:I(`Night mode`,`Modalità notte`),phrase:I(`Force {device} into night mode`,`Forza {device} in modalità notte`),icon:`moon`,args:{settings:{mode:`night`}}}]})},status:{schema:NO,kind:`poll`},runtimeState:NO,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`Day/night`,`Giorno/notte`),order:3070,state:[{kind:`enum`,field:`mode`,label:I(`Day/night mode`,`Modalità giorno/notte`),values:[{value:`auto`,label:I(`Automatic`,`Automatica`)},{value:`day`,label:I(`Day`,`Giorno`),phrase:I(`When {device} switches to day mode`,`Quando {device} passa in modalità giorno`)},{value:`night`,label:I(`Night`,`Notte`),phrase:I(`When {device} switches to night mode`,`Quando {device} passa in modalità notte`)},{value:`schedule`,label:I(`Scheduled`,`Programmata`)}],icon:`sun-moon`}]}},gve=[{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)`}],_ve={hwaccel:`auto`,probedBestHwaccel:``},LO={name:`decoder`,scope:`system`,mode:`singleton`,preferredProvider:`decoder-nodeav`,methods:{getInfo:E(v(),x({id:m(),name:m(),hwaccel:m().optional(),probedBestHwaccel:m().optional()})),reprobeHwaccel:E(v(),x({backend:m()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.PIPELINE}},RO={name:`detection-pipeline`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[j.Camera],exposesDeviceSettings:!0,methods:{},vocabulary:{noun:I(`Detection pipeline`,`Pipeline di rilevamento`),order:3080}},zO=S([`device`,`integration`]),BO=x({url:m(),label:m(),target:zO,host:m()}),VO={name:`device-admin-link`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{getAdminLink:E(x({deviceId:p().int().nonnegative()}),BO.nullable(),{auth:`admin`})},vocabulary:{noun:I(`Admin link`,`Link di amministrazione`),order:3090}},HO=S([`online`,`sleeping`,`offline`,`unknown`]),UO=_(()=>x({childNativeId:m(),name:m(),type:S(j),status:HO,metadata:x({model:m().optional(),serialNumber:m().optional(),uid:m().optional(),rtspChannel:p().int().nonnegative().optional(),isBattery:y().optional(),isDoorbell:y().optional(),isMultifocal:y().optional(),externalLocation:m().optional(),manufacturer:m().optional(),integration:m().optional()}).default({}),alreadyAdopted:y(),adoptedDeviceId:p().int().nonnegative().nullable(),capabilities:C(m()).readonly().optional(),features:C(m()).readonly().optional(),sourceInfo:ih.optional(),children:C(UO).readonly().optional(),parentStableId:m().optional()})),WO=x({id:m(),label:m(),isDefault:y().optional()}),GO=x({search:m().optional(),area:m().optional(),manufacturer:m().optional(),adoptedOnly:y().optional(),unadoptedOnly:y().optional()}),KO=x({integrationId:m(),page:p().int().positive().default(1),pageSize:p().int().positive().max(2e4).default(50),filter:m().optional(),filterText:GO.optional()}),qO=x({candidates:C(UO).readonly(),totalCount:p().int().nonnegative(),page:p().int().positive(),pageSize:p().int().positive()}),JO=x({integrationId:m(),childNativeId:m()}),YO=x({lastDiscoveryAt:p().int().nonnegative().nullable(),candidateCount:p().int().nonnegative(),adoptedCount:p().int().nonnegative(),lastError:m().nullable()}),vve=x({name:m().min(1).optional(),hiddenChildIds:C(m()).optional()}),XO=x({integrationId:m(),childNativeIds:C(m()).min(1),filter:m().optional(),importLocations:y().optional(),perCandidate:d(m(),vve).optional()}),ZO=x({adopted:C(x({childNativeId:m(),parentDeviceId:p().int().nonnegative(),accessoryDeviceIds:C(p().int().nonnegative()).readonly()})).readonly()}),QO=x({integrationId:m(),camDeviceId:p().int().nonnegative()}),$O=x({camDeviceId:p().int().nonnegative(),resetToSource:y().optional()}),ek=x({changed:y(),rebuiltChildren:p().int().nonnegative(),removedChildren:p().int().nonnegative().optional()}),tk={name:`device-adoption`,scope:`system`,mode:`collection`,status:{schema:YO,kind:`poll`},methods:{listCandidateFilters:E(x({integrationId:m()}),x({filters:C(WO)}),{auth:`admin`}),listCandidates:E(KO,qO,{auth:`admin`}),getCandidate:E(JO,UO.nullable(),{auth:`admin`}),refresh:E(x({integrationId:m()}),YO,{kind:`mutation`,auth:`admin`}),adopt:E(XO,ZO,{kind:`mutation`,auth:`admin`}),release:E(QO,v(),{kind:`mutation`,auth:`admin`}),resync:E($O,ek,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`device adoption — an onboarding flow, not an action`}},nk=a(`state`,[x({state:s(`absent`)}),x({state:s(`ready`),subject:m(),fingerprintSha256:m(),validTo:m()}),x({state:s(`unavailable`),reason:m()})]),rk=x({selfEnrollment:S([`allowed`,`disabled`])}),ik={name:`device-credentials`,scope:`system`,mode:`singleton`,methods:{listDeviceCredentials:E(x({userId:m().min(1).optional(),includeRevoked:y().default(!1)}),C(ip).readonly(),{auth:`admin`}),startEnrollment:E(x({userId:m().min(1),deviceName:m().min(1).max(80)}),ap,{kind:`mutation`,auth:`admin`,caller:`required`}),revokeDeviceCredential:E(x({id:m().min(1)}),x({revoked:y(),sessionsEnded:p().int(),status:rp}),{kind:`mutation`,auth:`admin`,caller:`required`}),getDeviceCertificateSettings:E(x({}),rk,{auth:`admin`}),setDeviceCertificateSettings:E(rk,rk,{kind:`mutation`,auth:`admin`}),deleteDeviceCredential:E(x({id:m().min(1)}),x({result:S([`deleted`,`live`,`unknown`])}),{kind:`mutation`,auth:`admin`,caller:`required`}),getDeviceCaStatus:E(x({}),nk,{auth:`admin`}),renameDeviceCredential:E(x({id:m().min(1),deviceName:m().min(1).max(80)}),x({renamed:y()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.IDENTITY}},ak=/^[a-z][a-z0-9_]*$/,yve=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(`.`)),ok=m().max(64).regex(ak);function sk(e){return yve.has(e)}function ck(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 bve(e,t){let n=ck(e);if(!sk(n)&&!t(n))return n;for(let e=2;;e+=1){let r=`${n}_${e}`;if(!t(r))return r}}function xve(e,t){return e.length===0?{ok:!1,reason:`empty`}:e.length>64?{ok:!1,reason:`too-long`}:ak.test(e)?sk(e)?{ok:!1,reason:`reserved`}:t(e)?{ok:!1,reason:`taken`}:{ok:!0,alias:e}:{ok:!1,reason:`grammar`}}var lk=[`filter`,`global`,`variable`],uk=[`number`,`unit`,`text`,`state`,`time`,`fallback`,`loop`,`variable`],dk=[`string`,`number`,`boolean`],fk=a(`kind`,[x({kind:s(`units-of-field`)}),x({kind:s(`choices`),options:C(x({value:m(),labelKey:m().min(1)})).min(1)}),x({kind:s(`range`),min:p(),max:p(),step:p().positive()})]),Sve=fk,pk=x({name:m().min(1),type:S(dk),optional:y(),default:l([m(),p(),y()]).optional(),values:fk.optional()}),Cve=x({name:m().min(1),kind:S(lk),category:S(uk),params:C(pk),descriptionKey:m().min(1),exampleKey:m().min(1)});function mk(e,t,n,r,i){let a=r===void 0?{name:e,type:t,optional:n}:{name:e,type:t,optional:n,default:r};return i===void 0?a:{...a,values:i}}function z(e,t,n,r){return{name:e,kind:t,category:n,params:[...r],descriptionKey:`uiLibrary.deviceTemplateCatalogue.${e}.description`,exampleKey:`uiLibrary.deviceTemplateCatalogue.${e}.example`}}var hk=mk(`digits`,`number`,!0,0,{kind:`range`,min:0,max:4,step:1}),gk={kind:`units-of-field`},_k=[[`hm`,`HH:mm`,`Hours and minutes (14:05)`,`Ore e minuti (14:05)`],[`hms`,`HH:mm:ss`,`Hours, minutes, seconds (14:05:09)`,`Ore, minuti, secondi (14:05:09)`],[`dm`,`DD/MM`,`Day and month (31/12)`,`Giorno e mese (31/12)`],[`dmy`,`DD/MM/YYYY`,`Day, month, year (31/12/2026)`,`Giorno, mese, anno (31/12/2026)`],[`dmyhm`,`DD/MM/YYYY HH:mm`,`Date and time (31/12/2026 14:05)`,`Data e ora (31/12/2026 14:05)`],[`iso`,`YYYY-MM-DD`,`ISO date (2026-12-31)`,`Data ISO (2026-12-31)`],[`isohms`,`YYYY-MM-DD HH:mm:ss`,`ISO date and time (2026-12-31 14:05:09)`,`Data e ora ISO (2026-12-31 14:05:09)`]],vk=e=>`uiLibrary.deviceTemplateCatalogue.choice.time.${e}`,wve={kind:`choices`,options:_k.map(([e,t])=>({value:t,labelKey:vk(e)}))},yk=mk(`fallback`,`string`,!1),bk=mk(`falsy`,`boolean`,!0,!1),xk=[z(`unit`,`filter`,`unit`,[mk(`symbol`,`string`,!1,void 0,gk),mk(`from`,`string`,!0,void 0,gk)]),z(`round`,`filter`,`number`,[hk]),z(`trunc`,`filter`,`number`,[hk]),z(`onoff`,`filter`,`state`,[]),z(`default`,`filter`,`fallback`,[yk,bk]),z(`since`,`filter`,`time`,[]),z(`ago`,`filter`,`time`,[]),z(`format`,`filter`,`text`,[mk(`pattern`,`string`,!1)]),z(`upper`,`filter`,`text`,[]),z(`lower`,`filter`,`text`,[]),z(`title`,`filter`,`text`,[]),z(`capitalize`,`filter`,`text`,[]),z(`trim`,`filter`,`text`,[]),z(`abs`,`filter`,`number`,[]),z(`int`,`filter`,`number`,[mk(`fallback`,`number`,!0,0)]),z(`float`,`filter`,`number`,[mk(`fallback`,`number`,!0,0)]),z(`length`,`filter`,`text`,[]),z(`d`,`filter`,`fallback`,[yk,bk]),z(`join`,`filter`,`text`,[mk(`separator`,`string`,!0,``)]),z(`replace`,`filter`,`text`,[mk(`old`,`string`,!1),mk(`new`,`string`,!1),mk(`count`,`number`,!0)]),z(`first`,`filter`,`loop`,[]),z(`last`,`filter`,`loop`,[]),z(`sort`,`filter`,`loop`,[mk(`reverse`,`boolean`,!0,!1),mk(`caseSensitive`,`boolean`,!0,!1)]),z(`reverse`,`filter`,`loop`,[]),z(`sum`,`filter`,`number`,[]),z(`string`,`filter`,`text`,[]),z(`list`,`filter`,`loop`,[]),z(`truncate`,`filter`,`text`,[mk(`length`,`number`,!1),mk(`killwords`,`boolean`,!0,!1),mk(`end`,`string`,!0,`…`)]),z(`time`,`filter`,`time`,[mk(`pattern`,`string`,!1,void 0,wve)]),z(`range`,`global`,`loop`,[mk(`stop`,`number`,!1),mk(`start`,`number`,!0,0),mk(`step`,`number`,!0,1)]),z(`now`,`variable`,`time`,[]),z(`camera`,`variable`,`variable`,[]),z(`loop`,`variable`,`loop`,[]),z(`lastPerson`,`variable`,`variable`,[]),z(`lastPlate`,`variable`,`variable`,[])],Tve={unit:{description:[`Converts a number from the field’s base unit and prints the symbol.`,`Converte un numero dall’unità di base del campo e stampa il simbolo.`],example:[`{{ garage.temperature | unit('°C') }}`,`{{ garage.temperature | unit('°C') }}`]},round:{description:[`Rounds a number to the given decimals.`,`Arrotonda un numero ai decimali indicati.`],example:[`{{ garage.temperature | round(1) }}`,`{{ garage.temperature | round(1) }}`]},trunc:{description:[`Cuts decimals toward zero, without rounding.`,`Taglia i decimali verso zero, senza arrotondare.`],example:[`{{ garage.temperature | trunc(1) }}`,`{{ garage.temperature | trunc(1) }}`]},onoff:{description:[`Prints a boolean as ON or OFF.`,`Stampa un sì/no come ON oppure OFF.`],example:[`{{ garage.switch | onoff }}`,`{{ garage.switch | onoff }}`]},default:{description:[`Replaces a missing value. The second argument also replaces a false or zero.`,`Sostituisce un valore assente. Il secondo argomento sostituisce anche falso o zero.`],example:[`{{ camera.lastPerson | default('') }}`,`{{ camera.lastPerson | default('') }}`]},since:{description:[`How long ago a timestamp was, as “5 min”.`,`Quanto tempo fa era un istante, come «5 min».`],example:[`{{ garage.updated | since }}`,`{{ garage.updated | since }}`]},ago:{description:[`The same duration as since, followed by “ago”.`,`La stessa durata di since, seguita da «ago».`],example:[`{{ garage.updated | ago }}`,`{{ garage.updated | ago }}`]},format:{description:[`Prints one value with a single %s, %d or %.Nf placeholder.`,`Stampa un valore con un solo segnaposto %s, %d o %.Nf.`],example:[`{{ garage.temperature | format('%.1f') }}`,`{{ garage.temperature | format('%.1f') }}`]},upper:{description:[`Uppercase text.`,`Testo in maiuscolo.`],example:[`{{ camera.lastPerson | upper }}`,`{{ camera.lastPerson | upper }}`]},lower:{description:[`Lowercase text.`,`Testo in minuscolo.`],example:[`{{ camera.lastPlate | lower }}`,`{{ camera.lastPlate | lower }}`]},title:{description:[`Capitalises each word.`,`Mette la maiuscola a ogni parola.`],example:[`{{ camera.lastPerson | title }}`,`{{ camera.lastPerson | title }}`]},capitalize:{description:[`Capitalises the first letter.`,`Mette la maiuscola alla prima lettera.`],example:[`{{ camera.lastPerson | capitalize }}`,`{{ camera.lastPerson | capitalize }}`]},trim:{description:[`Removes spaces at both ends.`,`Toglie gli spazi alle estremità.`],example:[`{{ camera.lastPerson | trim }}`,`{{ camera.lastPerson | trim }}`]},abs:{description:[`The absolute value of a number.`,`Il valore assoluto di un numero.`],example:[`{{ garage.power | abs }}`,`{{ garage.power | abs }}`]},int:{description:[`The whole part of a number.`,`La parte intera di un numero.`],example:[`{{ garage.temperature | int }}`,`{{ garage.temperature | int }}`]},float:{description:[`Reads the value as a decimal number.`,`Legge il valore come numero decimale.`],example:[`{{ garage.temperature | float }}`,`{{ garage.temperature | float }}`]},length:{description:[`How many characters or items.`,`Quanti caratteri o elementi.`],example:[`{{ camera.lastPerson | length }}`,`{{ camera.lastPerson | length }}`]},d:{description:[`The short name of default.`,`Il nome breve di default.`],example:[`{{ camera.lastPerson | d('') }}`,`{{ camera.lastPerson | d('') }}`]},join:{description:[`Joins a list with a separator.`,`Unisce un elenco con un separatore.`],example:[`{{ range(3) | join(', ') }}`,`{{ range(3) | join(', ') }}`]},replace:{description:[`Replaces text, optionally only the first few times.`,`Sostituisce del testo, volendo solo le prime volte.`],example:[`{{ camera.lastPlate | replace(' ', '') }}`,`{{ camera.lastPlate | replace(' ', '') }}`]},first:{description:[`The first item of a list.`,`Il primo elemento di un elenco.`],example:[`{{ range(3) | first }}`,`{{ range(3) | first }}`]},last:{description:[`The last item of a list.`,`L’ultimo elemento di un elenco.`],example:[`{{ range(3) | last }}`,`{{ range(3) | last }}`]},sort:{description:[`Sorts a list. The arguments reverse it or keep case.`,`Ordina un elenco. Gli argomenti lo invertono o rispettano le maiuscole.`],example:[`{{ range(3) | reverse | sort }}`,`{{ range(3) | reverse | sort }}`]},reverse:{description:[`Reverses a list.`,`Inverte un elenco.`],example:[`{{ range(3) | reverse }}`,`{{ range(3) | reverse }}`]},sum:{description:[`Adds the numbers in a list.`,`Somma i numeri di un elenco.`],example:[`{{ range(3) | sum }}`,`{{ range(3) | sum }}`]},string:{description:[`Prints the value as text.`,`Stampa il valore come testo.`],example:[`{{ garage.temperature | string }}`,`{{ garage.temperature | string }}`]},list:{description:[`Wraps the value in a list.`,`Mette il valore in un elenco.`],example:[`{{ garage.temperature | list }}`,`{{ garage.temperature | list }}`]},truncate:{description:[`Shortens text to a length, with an ending.`,`Accorcia il testo a una lunghezza, con una chiusura.`],example:[`{{ camera.lastPerson | truncate(12) }}`,`{{ camera.lastPerson | truncate(12) }}`]},time:{description:[`Prints a timestamp in the server’s time zone. Tokens: YYYY MM DD HH mm ss.`,`Stampa un istante nel fuso del server. Segni: YYYY MM DD HH mm ss.`],example:[`{{ now | time('HH:mm') }}`,`{{ now | time('HH:mm') }}`]},range:{description:[`The integers up to stop, or from start to stop by step. At most 1000 items.`,`Gli interi fino a stop, oppure da start a stop con step. Al massimo 1000 elementi.`],example:[`{% for i in range(3) %}{{ i }}{% endfor %}`,`{% for i in range(3) %}{{ i }}{% endfor %}`]},now:{description:[`The hub clock. A bare now prints ISO; time prints a pattern.`,`L’orologio dell’hub. now da solo stampa ISO; time stampa un formato.`],example:[`{{ now | time('HH:mm') }}`,`{{ now | time('HH:mm') }}`]},camera:{description:[`The device this text is written for. It stays correct when the text is copied to another camera.`,`Il dispositivo per cui è scritto il testo. Resta corretto se il testo viene copiato su un’altra telecamera.`],example:[`{{ camera.temperature }}`,`{{ camera.temperature }}`]},loop:{description:[`The for-loop counter (index, length) inside {% for %}.`,`Il contatore del ciclo (index, length) dentro {% for %}.`],example:[`{% for i in range(3) %}{{ loop.index }}{% endfor %}`,`{% for i in range(3) %}{{ loop.index }}{% endfor %}`]},lastPerson:{description:[`The last person recognised on this camera, empty until there is one.`,`L’ultima persona riconosciuta su questa telecamera, vuota finché non ce n’è una.`],example:[`{{ camera.lastPerson }}`,`{{ camera.lastPerson }}`]},lastPlate:{description:[`The last plate recognised on this camera, empty until there is one.`,`L’ultima targa riconosciuta su questa telecamera, vuota finché non ce n’è una.`],example:[`{{ camera.lastPlate }}`,`{{ camera.lastPlate }}`]}};function Eve(){let e={};for(let t of xk){let n=Tve[t.name];n!==void 0&&(e[t.descriptionKey]={en:n.description[0],it:n.description[1]},e[t.exampleKey]={en:n.example[0],it:n.example[1]})}for(let[t,,n,r]of _k)e[vk(t)]={en:n,it:r};return e}var Sk=Eve();function Ck(){return xk.filter(e=>e.kind===`filter`).map(e=>e.name)}function Dve(){let e={};for(let t of xk)t.kind===`filter`&&(e[t.name]=t.params.length);return e}function Ove(){return xk.filter(e=>e.kind===`global`).map(e=>({name:e.name,min:Math.max(1,e.params.filter(e=>!e.optional).length),max:e.params.length}))}var wk=new Set([`now`,`camera`,`loop`]);function Tk(){return xk.filter(e=>e.kind===`variable`&&wk.has(e.name))}function Ek(){return xk.filter(e=>e.kind===`variable`&&!wk.has(e.name))}function Dk(e){if(e.kind===`variable`)return e.name;let t=e.params.map(e=>e.optional?`${e.name}?`:e.name).join(`, `);return`${e.name}(${t})`}function Ok(e,t){return Sk[e]?.[t]}function kve(){let e=[`| Name | Kind | What it does | Example |`,`| --- | --- | --- | --- |`],t=xk.map(e=>{let t=kk(Ok(e.descriptionKey,`en`)??``),n=kk(Ok(e.exampleKey,`en`)??``);return`| \`${Dk(e)}\` | ${e.kind} | ${t} | \`${n}\` |`});return[...e,...t].join(`
1108
- `)}function kk(e){return e.replaceAll(`|`,`\\|`)}function Ave(){let e=[];for(let t of Object.values(uh))e.includes(t.dimension)||e.push(t.dimension);return e.map(e=>({group:e,choices:yh(e).map(e=>({value:e}))}))}function Ak(e,t){if(e===void 0)return[];if(e.kind===`choices`)return[{group:null,choices:e.options.map(e=>({...e}))}];if(e.kind===`range`){let t=[],n=Math.floor((e.max-e.min)/e.step+1e-9);for(let r=0;r<=n;r+=1)t.push({value:String(e.min+r*e.step)});return[{group:null,choices:t}]}let n=t===void 0?void 0:ph(t);return n===void 0?Ave():[{group:n,choices:yh(n).map(e=>({value:e}))}]}var jk=4096,jve=4096,Mk=m().min(1).max(jk),Mve=`camera`,Nk=l([m(),p(),y()]),Pk=x({deviceId:p().int(),values:d(m().min(1).max(64),Nk).optional()}),Nve=`values`,Pve=Ck(),Fk=[`too-long`,`syntax`,`forbidden-syntax`,`forbidden-member`,`unknown-filter`,`ambiguous-field`,`busy`,`budget-exceeded`,`timeout`,`output-too-large`,`render-failed`,`out-of-scope`,`unavailable`],Ik=x({reason:S(Fk),message:m()}),Lk=[`unknown-alias`,`unknown-field`,`no-field`,`unavailable`],Rk=x({ref:m(),reason:S(Lk)}),zk=a(`ok`,[x({ok:s(!0),text:m(),trace:C(Rk)}),x({ok:s(!1),refusal:Ik,trace:C(Rk)})]);function Bk(e){return e.replace(/-/g,`_`)}function Vk(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Hk(e,t){let n=e;for(let e of t)if(Array.isArray(n)&&typeof e==`number`)n=n[e];else if(Vk(n)&&Object.hasOwn(n,String(e)))n=n[String(e)];else return;return n}function Fve(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||Bk(e)===n);if(i!==void 0){let n=t.slice(1);if(n.length===0)return{kind:`missing`,reason:`no-field`};let r=Hk(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 Vk(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=Hk(e.slices[o],t);return s===void 0?{kind:`missing`,reason:`unknown-field`}:{kind:`value`,cap:o,fieldPath:t,value:s}}var Uk=x({zoneKey:m(),label:m(),icon:Vu.nullable(),locationKeys:C(m())});function Ive(e){return e.trim().toLowerCase()}var Wk=x({caps:C(m()).readonly().optional(),actions:C(m()).readonly().optional(),mode:S([`any`,`all`]).optional()}),Gk=x({locations:C(m()).readonly().optional(),integrationIds:C(m()).readonly().optional(),types:C(m()).readonly().optional()}),Kk=x({text:m().optional(),requires:Wk.optional(),filters:Gk.optional(),includeIncompatible:y().optional(),contextDeviceId:p().optional(),ids:C(p()).readonly().optional(),cursor:m().nullable().optional(),limit:p().int().min(1).max(200).optional()}),qk=x({cap:m(),path:m(),label:m(),reading:m().nullable(),unit:m().nullable().optional(),quantity:Qs.optional()}),Jk=x({id:p(),name:m(),type:S(j),location:m().nullable(),integrationId:m().nullable(),integrationLabel:m().nullable(),online:y().nullable(),disabled:y(),compatible:y(),values:C(qk).readonly()}),Yk=x({value:m(),count:p()}),Xk=x({id:m(),label:m(),count:p()}),Zk=x({locations:C(Yk).readonly(),integrations:C(Xk).readonly(),types:C(Yk).readonly()}),Qk=x({items:C(Jk).readonly(),nextCursor:m().nullable(),total:p(),compatibleTotal:p(),fleetTotal:p(),hiddenIncompatible:p(),facets:Zk,suggested:C(Jk).readonly(),missingIds:C(p()).readonly()}),$k=x({connected:y(),deviceCount:p(),error:m().optional(),motionSliceWriter:s(`orchestrator`).optional()}),Lve=x({externalId:m(),name:m(),type:m(),metadata:d(m(),u()).optional()}),eA=a(`kind`,[x({kind:s(`mdns`),serviceType:m().min(1),instancePattern:m().optional()}),x({kind:s(`ws-discovery`),types:C(m()).optional()}),x({kind:s(`ssdp`),searchTarget:m().min(1)}),x({kind:s(`udp-broadcast`),port:p().int().min(1).max(65535),payloadHex:m().regex(/^([0-9a-fA-F]{2})*$/),listenPort:p().int().min(1).max(65535).optional()}),x({kind:s(`http-probe`),port:p().int().min(1).max(65535),path:m().startsWith(`/`),method:S([`GET`,`POST`]).default(`GET`),bodyText:m().optional(),contentType:m().optional(),tls:y().default(!1),acceptStatus:C(p().int()).optional()}),x({kind:s(`custom`),reason:m().min(1)})]),tA=x({modeIndex:p().int().min(0),host:m(),port:p().int(),http:x({status:p().int(),headers:d(m(),m()),bodyText:m()}).optional(),mdns:x({instance:m(),host:m(),port:p().int(),txt:d(m(),m())}).optional(),udp:x({payloadHex:m()}).optional(),wsd:x({xaddrs:C(m()),types:C(m()),scopes:C(m())}).optional()}),nA=x({stableId:m(),type:S(j),suggestedName:m(),prefilledConfig:d(m(),u()),sourceInfo:ih.optional(),alreadyOnboarded:y().optional(),onboardedDeviceId:p().optional(),onboardedName:m().optional(),setupIntegration:y().optional(),parentStableId:m().optional(),selectable:y().optional(),needsParams:C(m()).optional()}),rA=x({id:p(),stableId:m(),addonId:m(),type:m(),name:m(),parentDeviceId:p().nullable(),online:y(),features:C(m()),config:d(m(),u()),sourceInfo:ih.optional()}),iA=x({status:S([`ok`,`error`]),labels:C(m()).optional(),error:m().optional()}),aA=u(),oA={name:`device-provider`,scope:`system`,mode:`collection`,methods:{start:E(v(),v(),{kind:`mutation`}),stop:E(v(),v(),{kind:`mutation`}),getStatus:E(v(),$k),getDevices:E(v(),C(x({id:m(),name:m(),type:m()}))),reloadDevice:E(x({stableId:m()}),x({deviceId:p()}),{kind:`mutation`,timeoutMs:3*6e4}),supportsDiscovery:E(x({}),y()),discoverDevices:E(x({params:d(m(),u()).optional()}),C(nA),{kind:`mutation`,auth:`admin`}),getDiscoveryModes:E(x({}),C(eA)),classifyDiscoveryHits:E(x({hits:C(tA),params:d(m(),u()).optional()}),C(nA),{kind:`mutation`,auth:`admin`}),getDiscoveryParamsSchema:E(x({}),aA),getManualCreationType:E(x({integrationId:m().optional()}),x({deviceType:S(j).nullable()})),adoptDiscoveredDevice:E(x({candidate:nA,integrationId:m().optional()}),rA,{kind:`mutation`,auth:`admin`}),supportsManualCreation:E(x({}),y()),getChildCreationSchema:E(x({type:S(j),integrationId:m().optional()}),aA),createDevice:E(x({type:S(j),config:d(m(),u()),integrationId:m().optional()}),rA,{kind:`mutation`,auth:`admin`}),testCreationField:E(x({type:S(j),key:m(),value:u(),formValues:d(m(),u()).optional()}),iA,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.INTERNAL}},sA=a(`kind`,[x({kind:s(`mdns`),serviceType:m(),instance:m(),host:m(),address:m().nullable(),port:p().int(),txt:d(m(),m())}),x({kind:s(`ssdp`),host:m(),port:p().int(),target:m(),headers:d(m(),m())})]),Rve=x({addonId:m(),candidate:nA,firstSeenAt:p(),lastSeenAt:p(),dismissed:y()}),cA=x({id:m(),addonId:m(),candidate:nA,firstSeenAt:p(),lastSeenAt:p(),dismissed:y()}),lA=x({childKey:m(),section:m(),order:p().optional(),collapsed:y().optional()}),zve=x({unit:m().min(1).optional(),precision:p().int().min(0).max(10).optional()}),uA=x({icon:m().min(1).optional(),label:m().min(1).optional(),unit:m().min(1).optional(),precision:p().int().min(0).max(10).optional(),hidden:y().optional(),perCap:d(m(),zve).optional()}),dA=x({unit:m().min(1).optional(),precision:p().int().min(0).max(10).optional(),icon:m().min(1).optional()}),fA=x({id:p(),stableId:m(),addonId:m(),type:S(j),name:m(),alias:ok.optional(),location:m().nullable(),tags:Qu.optional(),disabled:y(),parentDeviceId:p().nullable(),role:m().nullable().optional(),online:y(),probed:y().optional(),features:C(m()),isCamera:y(),config:d(m(),u()),secretConfigPaths:C(m()).optional(),metadata:d(m(),u()).nullable().optional(),sourceInfo:ih.optional(),integrationId:m().optional(),linkDeviceId:p().nullable().optional(),primaryChildEntityId:m().nullable().optional(),childLayout:C(lA).readonly().optional(),primaryChildPreference:C(m()).readonly().optional(),display:uA.optional()}),pA=x({key:m(),value:u(),description:m().optional()}),mA=S([`manual`]),hA=x({deviceId:p(),name:m(),location:m().nullable(),features:C(m()),producesTrackedEvents:y().optional()}),gA=x({deviceIds:C(p().int().positive()),trackedDeviceIds:C(p().int().positive()).optional()}),_A={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:[j.Camera],sourceCaps:`any`,cardinality:`many`,value:gA},Bve=x({deviceId:p(),mode:mA,devices:C(hA)}),vA=x({deviceId:p(),entries:C(x({capName:m(),kind:S([`native`,`wrapped`]),providerAddonId:m(),providerNodeId:m(),nativeAddonId:m(),implementedMethods:C(m()).optional()}))}),yA=a(`kind`,[x({kind:s(`value`),wrapperAddonId:m().nullable()}),x({kind:s(`missing`)}),x({kind:s(`failed`),error:m()})]),Vve=x({id:p(),stableId:m(),type:m(),name:m(),location:m().nullable(),tags:Qu.optional(),disabled:y(),parentDeviceId:p().nullable(),role:m().nullable().optional()}),Hve=x({id:p(),stableId:m(),addonId:m(),type:m(),name:m(),userNamed:y().optional(),location:m().nullable(),tags:Qu.optional(),disabled:y(),parentDeviceId:p().nullable(),metadata:d(m(),u()).nullable().optional(),sourceInfo:ih.optional(),integrationId:m().optional(),linkDeviceId:p().nullable().optional(),primaryChildEntityId:m().nullable().optional(),childLayout:C(lA).readonly().optional(),primaryChildPreference:C(m()).readonly().optional(),role:m().nullable().optional(),display:uA.optional()}),Uve=u().nullable(),Wve=x({streamId:m(),width:p().optional(),height:p().optional(),codec:m().optional(),fps:p().optional(),bitrateKbps:p().optional()}),Gve=x({addonId:m(),stableId:m(),id:p(),type:m(),name:m(),location:m().nullable().optional(),disabled:y().optional(),parentDeviceId:p().nullable(),role:m().nullable().optional(),features:C(m()).optional(),config:d(m(),u()),secretConfigPaths:C(m()).optional()}),bA=x({deviceId:p().int().positive(),deletedAt:p(),providerAddonId:m()}),xA=2160*60*60*1e3,SA=x({deviceId:p().int().positive(),stores:d(m(),p().int().nonnegative())}),CA=x({status:S([`skipped`,`dry-run`,`cleaned`]),reason:m().nullable(),devices:C(SA),unreachable:C(m())}),Kve=x({deviceId:p()}),qve=x({deviceId:p(),data:d(m(),u()),secretConfigPaths:C(m()).optional()}),wA=S([`off`,`on`,`not-offered`,`unreachable`]),TA=x({deviceId:p(),switchId:Ya,outcome:wA,detail:m().optional()}),EA=x({sourceId:p(),targetId:p(),switches:C(TA).readonly(),sourceStillLive:C(Ya).readonly(),swapped:y()}),DA={name:`device-manager`,scope:`system`,mode:`singleton`,extensionSlots:[_A],methods:{allocateDeviceId:E(x({addonId:m(),stableId:m()}),x({id:p()}),{kind:`mutation`}),migrateDevice:E(x({sourceId:p(),targetId:p()}),EA,{kind:`mutation`,auth:`admin`,timeoutMs:12*6e4}),registerDevice:E(Gve,v(),{kind:`mutation`}),removeDevice:E(Kve,v(),{kind:`mutation`}),persistConfig:E(qve,v(),{kind:`mutation`,auth:`admin`}),loadConfig:E(x({deviceId:p()}),d(m(),u()),{auth:`admin`}),loadRuntimeState:E(x({deviceId:p()}),d(m(),u()),{auth:`admin`}),loadMeta:E(x({deviceId:p()}),Hve.nullable()),setName:E(x({deviceId:p(),name:m(),stampUserNamed:y().optional()}),v(),{kind:`mutation`,auth:`admin`}),setAlias:E(x({deviceId:p(),alias:m()}),a(`ok`,[x({ok:s(!0),alias:ok}),x({ok:s(!1),reason:S([`empty`,`too-long`,`grammar`,`reserved`,`taken`]),takenBy:p().optional()})]),{kind:`mutation`,auth:`admin`}),renderDeviceTemplates:E(x({templates:C(Mk).max(64),allowedDeviceIds:C(p().int()).optional(),thisDevice:Pk.optional()}),x({results:C(zk)}),{auth:`admin`}),checkDeviceTemplates:E(x({templates:C(m()).max(64),allowedDeviceIds:C(p().int()).optional(),thisDevice:Pk.optional()}),x({results:C(a(`ok`,[x({ok:s(!0),aliases:C(x({alias:m(),deviceId:p().int().nullable(),allowed:y(),reads:C(m())})),readsClock:y()}),x({ok:s(!1),refusal:Ik})]))}),{auth:`admin`}),setLocation:E(x({deviceId:p(),location:m().nullable()}),v(),{kind:`mutation`,auth:`admin`}),setTags:E(x({deviceId:p(),tags:Qu}),v(),{kind:`mutation`,auth:`admin`}),setType:E(x({deviceId:p(),type:S(j)}),v(),{kind:`mutation`,auth:`admin`}),setIntegrationId:E(x({deviceId:p(),integrationId:m()}),v(),{kind:`mutation`,auth:`admin`}),setLinkDeviceId:E(x({deviceId:p(),linkDeviceId:p().nullable()}),v(),{kind:`mutation`,auth:`admin`}),setPrimaryChildEntityId:E(x({deviceId:p(),primaryChildEntityId:m().nullable()}),v(),{kind:`mutation`,auth:`admin`}),setChildLayout:E(x({deviceId:p(),childLayout:C(lA).readonly()}),v(),{kind:`mutation`,auth:`admin`}),setPrimaryChildPreference:E(x({deviceId:p(),primaryChildPreference:C(m()).readonly()}),v(),{kind:`mutation`,auth:`admin`}),setDisplay:E(x({deviceId:p(),display:uA.nullable()}),v(),{kind:`mutation`,auth:`admin`}),getRoleDisplayDefaults:E(x({}),x({defaults:d(m(),dA)}),{role:`viewer`,kind:`query`}),setRoleDisplayDefaults:E(x({defaults:d(m(),dA)}),v(),{kind:`mutation`,auth:`admin`}),getWireableFields:E(x({deviceId:p(),includeSynthesizable:y().optional()}),x({caps:C(x({cap:m(),fields:C(x({path:m(),kind:S([`string`,`number`,`boolean`,`enum`,`union`]),unionMembers:C(S([`string`,`number`,`boolean`])).optional(),enumValues:C(m()).optional(),item:y().optional(),quantity:Qs.optional()})).readonly(),itemArray:x({path:m(),keyField:m()}).optional()})).readonly()}),{kind:`query`}),setRole:E(x({deviceId:p(),role:m().nullable()}),v(),{kind:`mutation`,auth:`admin`}),applyInitialMeta:E(x({deviceId:p(),name:m().optional(),location:m().nullable().optional(),tags:Qu.optional(),type:S(j).optional(),integrationId:m().optional(),linkDeviceId:p().nullable().optional(),role:m().nullable().optional()}),v(),{kind:`mutation`,auth:`admin`}),setMetadata:E(x({deviceId:p(),patch:d(m(),u())}),v(),{kind:`mutation`,auth:`admin`}),listLocations:E(v(),C(m())),addLocation:E(x({name:m()}),v(),{kind:`mutation`,auth:`admin`}),removeLocation:E(x({name:m(),cascade:y().optional()}),v(),{kind:`mutation`,auth:`admin`}),renameLocation:E(x({from:m(),to:m()}),x({moved:p()}),{kind:`mutation`,auth:`admin`}),listLocationIcons:E(v(),C(xp),{role:`viewer`}),setLocationIcon:E(x({location:m(),icon:Vu.nullable()}),v(),{kind:`mutation`,auth:`admin`}),listLocationDescriptions:E(v(),C(Cp)),setLocationDescription:E(x({location:m(),description:m().max(400).nullable()}),v(),{kind:`mutation`,auth:`admin`}),listSiteZones:E(v(),C(Uk),{role:`viewer`}),setSiteZone:E(x({name:m(),icon:Vu.nullable().optional()}),v(),{kind:`mutation`,auth:`admin`}),removeSiteZone:E(x({name:m()}),v(),{kind:`mutation`,auth:`admin`}),renameSiteZone:E(x({from:m(),to:m()}),v(),{kind:`mutation`,auth:`admin`}),setLocationZone:E(x({location:m(),zone:m().nullable()}),v(),{kind:`mutation`,auth:`admin`}),setDisabled:E(x({deviceId:p(),disabled:y()}),v(),{kind:`mutation`,auth:`admin`}),listPersistedByAddon:E(x({addonId:m()}),C(Vve)),listAll:E(x({addonId:m().optional(),projection:S([`full`,`slim`]).optional(),isCamera:y().optional(),deviceIds:C(p()).optional()}),C(fA),{role:`viewer`}),search:E(Kk,Qk,{role:`viewer`}),getDevice:E(x({deviceId:p()}),fA.nullable()),getChildren:E(x({parentDeviceId:p()}),C(fA),{role:`viewer`}),getChildrenBatch:E(x({parentDeviceIds:C(p()).max(256)}),d(m(),C(fA))),getLinkedDevices:E(x({deviceId:p()}),x({mode:mA,devices:C(hA)}),{role:`viewer`}),getLinkedDevicesBatch:E(x({deviceIds:C(p())}),C(Bve),{role:`viewer`}),getStreamSources:E(x({deviceId:p()}),C(mc)),getConfigSchema:E(x({deviceId:p()}),C(pA)),getSettingsSchema:E(x({deviceId:p()}),Uve),updateConfig:E(x({deviceId:p(),values:d(m(),u())}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),enable:E(x({deviceId:p()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),disable:E(x({deviceId:p()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),remove:E(x({deviceId:p()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),listDeletedSince:E(x({sinceMs:p()}),C(bA).readonly(),{auth:`admin`}),cleanupDeletedDevicesData:E(x({confirm:y()}),CA,{kind:`mutation`,auth:`admin`}),removeByIntegration:E(x({integrationId:m()}),x({removed:p()}),{kind:`mutation`,auth:`admin`}),getStreamProfileMap:E(x({deviceId:p()}),d(m(),m().nullable())),setStreamProfileMap:E(x({deviceId:p(),profileMap:d(m(),m().nullable())}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),probeStreams:E(x({deviceId:p()}),C(Wve),{kind:`mutation`,auth:`admin`}),getBindings:E(x({deviceId:p()}),vA,{role:`viewer`}),getBindingsBatch:E(x({deviceIds:C(p())}),C(vA)),getAllBindings:E(x({}),C(vA)),listDeviceIdsByCaps:E(x({capNames:C(m().min(1)).min(1).max(16)}),C(p()),{role:`viewer`}),setWrapperActive:E(x({deviceId:p(),capName:m(),wrapperAddonId:m(),active:y()}),v(),{kind:`mutation`,auth:`admin`}),getWrapperActivation:E(x({deviceId:p(),capName:m().min(1)}),yA),listWrappersForCap:E(x({capName:m()}),C(m())),listBindableCapsForDeviceType:E(x({deviceType:m()}),C(x({capName:m(),wrappers:C(m())}))),getDeviceSettingsAggregate:E(x({deviceId:p()}),Fv.nullable()),getDeviceLiveInfoAggregate:E(x({deviceId:p()}),Fv.nullable(),{role:`viewer`}),getDeviceAggregate:E(x({deviceId:p()}),x({settings:Fv.nullable(),live:Fv.nullable()})),runDeviceAction:E(x({deviceId:p().int().nonnegative(),action:m().min(1),input:u()}),u(),{kind:`mutation`}),updateDeviceField:E(x({deviceId:p(),writerCapName:m(),writerAddonId:m(),key:m(),value:u()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),updateDeviceFieldsBatch:E(x({deviceId:p(),changes:C(x({writerCapName:m(),writerAddonId:m(),key:m(),value:u()}))}),x({success:s(!0),failures:C(x({writerCapName:m(),writerAddonId:m(),error:m()}))}),{kind:`mutation`,auth:`admin`}),discoverDevices:E(x({addonId:m()}),C(nA),{kind:`mutation`,auth:`admin`}),adoptDevice:E(x({addonId:m(),candidate:nA,integrationId:m().optional()}),rA,{kind:`mutation`,auth:`admin`}),getCreationSchema:E(x({addonId:m(),type:S(j),integrationId:m().optional()}),u().nullable()),createDevice:E(x({addonId:m(),type:S(j),config:d(m(),u()),integrationId:m().optional()}),rA,{kind:`mutation`,auth:`admin`}),testCreationField:E(x({addonId:m(),type:S(j),key:m(),value:u(),formValues:d(m(),u()).optional()}),iA,{kind:`mutation`,auth:`admin`}),adoptionListCandidateFilters:E(x({addonId:m(),integrationId:m()}),x({filters:C(WO)}),{auth:`admin`}),adoptionListCandidates:E(KO.extend({addonId:m()}),qO,{auth:`admin`}),adoptionRefresh:E(x({addonId:m(),integrationId:m()}),YO,{kind:`mutation`,auth:`admin`}),adoptionAdopt:E(XO.extend({addonId:m()}),ZO,{kind:`mutation`,auth:`admin`}),adoptionRelease:E(QO.extend({addonId:m()}),v(),{kind:`mutation`,auth:`admin`}),adoptionStartJob:E(XO.extend({addonId:m()}),x({jobId:m()}),{kind:`mutation`,auth:`admin`}),adoptionListJobs:E(x({addonId:m(),integrationId:m().optional()}),C(ure).readonly(),{auth:`admin`}),adoptionCancelJob:E(x({jobId:m()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),adoptionResync:E($O,ek,{kind:`mutation`,auth:`admin`}),discoveryProviders:E(x({}),x({providers:C(x({addonId:m(),label:m()})).readonly()}),{auth:`admin`}),discoverAllProviders:E(x({subnets:C(m()).optional()}),x({groups:C(x({addonId:m(),label:m(),candidates:C(nA).readonly(),error:m().nullable()})).readonly()}),{kind:`mutation`,auth:`admin`}),discoverProvider:E(x({addonId:m(),params:d(m(),u()).optional(),subnets:C(m()).optional()}),x({candidates:C(nA).readonly()}),{kind:`mutation`,auth:`admin`}),listDiscoveryProposals:E(x({}),x({proposals:C(cA).readonly()}),{auth:`admin`}),dismissDiscoveryProposal:E(x({id:m()}),x({dismissed:y()}),{kind:`mutation`,auth:`admin`}),reportDiscoveryObservations:E(x({observations:C(sA).max(512)}),x({proposed:p().int()}),{kind:`mutation`,auth:`admin`}),runDiscoverySweep:E(x({}),x({providers:p().int(),proposed:p().int()}),{kind:`mutation`,auth:`admin`,timeoutMs:12e4}),providerCreationType:E(x({addonId:m(),integrationId:m().optional()}),x({deviceType:S(j).nullable()}),{auth:`admin`}),providerDiscoveryParamsSchema:E(x({addonId:m()}),u(),{auth:`admin`}),testField:E(x({deviceId:p(),key:m(),value:u()}),iA,{kind:`mutation`,auth:`admin`}),getDeviceStatusAggregate:E(x({deviceId:p(),caps:C(m()).readonly().optional()}),d(m(),u().nullable())),getDeviceStatusAggregateBatch:E(x({deviceIds:C(p()).readonly(),caps:C(m()).readonly().optional()}),d(m(),d(m(),u().nullable())),{role:`viewer`})},vocabulary:{notOperatorFacing:`the device registry itself — rename, move and remove are administration`}},OA=[`linked-devices`],kA=S(OA),AA={"linked-devices":{descriptor:_A,declaringCap:`device-manager`,hostDeviceTypes:[j.Camera]}},jA=a(`slot`,[gA.extend({slot:s(`linked-devices`)})]),MA=[j.Camera],Jve=`listSlots`,NA=a(`state`,[x({state:s(`ok`)}),x({state:s(`unreachable`),reason:m()})]),PA=x({source:m(),label:m(),addonId:m().optional(),availability:NA}),FA=S([`ok`,`missing`,`foreign`,`unavailable`]),IA=x({deviceId:p().int(),name:m().nullable(),health:FA,detail:m().optional()}),LA=x({state:S([`active`,`inactive`,`unknown`]),authority:m(),detail:m().optional()}),RA=x({state:s(`ok`),slotRef:m(),slot:kA,authority:m(),activation:LA.nullable(),value:jA,sources:C(IA),impliedSources:C(IA).optional()}),zA=x({state:s(`unreachable`),addonId:m(),reason:m()}),BA=a(`state`,[RA,zA]);function Yve(e,t){return{state:`unreachable`,addonId:e,reason:t}}var VA=x({deviceId:p().int(),name:m(),type:m(),location:m().nullable(),parentName:m().nullable(),suggested:y(),reason:m().nullable()}),HA=x({candidates:C(VA)}),UA=x({applied:s(!0),reload:S([`none`,`host`,`parent`])}),WA=x({deviceId:p().int(),slotRef:m().min(1)}),GA=WA.extend({value:jA}),KA={name:`device-extension`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:MA,deviceConfig:{ui:{kind:`widget`,widgetId:`host/extensions-panel`,tab:`general`,label:`Extensions`,order:72}},methods:{listSources:E(x({deviceId:p().int()}),C(PA)),listSlots:E(x({deviceId:p().int()}),C(BA)),listCandidates:E(WA,HA),setSlot:E(GA,UA,{kind:`mutation`,auth:`admin`})},vocabulary:{noun:I(`Device extension`,`Estensione del dispositivo`),order:3100}},qA=a(`kind`,[x({kind:s(`device`),deviceId:p().int()}),x({kind:s(`node`),nodeId:m().min(1)})]),JA=S([`gauge`,`counter`,`boolean`,`enum`]),YA=S([`gauge`,`counter`,`boolean`]),XA=`derived:energy.kwh`,ZA=S([`raw`,`5m`,`1h`,`1d`]),QA=S([`undeclared`,`not-owner`,`opted-out`,`not-a-real-device`,`rate`,`ingest-mismatch`,`out-of-range`]),Xve=x({key:m(),reason:QA,count:p().int()}),$A=x({accepted:p().int(),refused:C(Xve).readonly()}),ej=x({key:m(),scope:m(),kind:JA,unit:m().nullable(),displayName:m(),source:S([`cap`,`addon`,`derived`]),values:C(m()).readonly().nullable(),firstTs:p(),lastTs:p()}),Zve=x({t:p(),samples:p().int(),mean:p().nullable(),twMean:p().nullable(),min:p(),max:p(),last:p().nullable(),delta:p().nullable(),state:m().nullable(),states:d(m(),p()).nullable()}),Qve=x({scope:m(),before:x({t:p(),value:p().nullable(),state:m().nullable()}).nullable(),points:C(Zve).readonly(),derivedFrom:m().nullable()}),tj={key:m(),scope:m().optional(),from:p(),to:p(),resolution:l([ZA,s(`auto`)]).default(`auto`),maxPoints:p().int().positive().max(5e3).default(1e3)},nj=x({resolution:ZA,series:C(Qve).readonly(),truncated:y()}),$ve=l([x({deviceId:p().int(),key:m(),scope:m().optional()}),x({forNodeId:m().min(1),key:m(),scope:m().optional()})]),eye=a(`ok`,[x({ok:s(!0),result:nj}),x({ok:s(!1),error:m()})]),tye=x({tier:ZA,rows:p().int().nullable(),approxBytes:p().nullable(),countedAt:p().nullable()}),rj=S([`device-gone`,`undeclared`]),ij=x({raw:p().int(),"5m":p().int(),"1h":p().int(),"1d":p().int()}),nye=x({seriesId:p().int(),deviceId:p().int(),key:m(),scope:m(),displayName:m().nullable(),reason:rj,missingSince:p().nullable(),firstTs:p(),lastTs:p(),rows:ij}),aj=S([`not-found`,`not-orphan`,`failed`]),rye=a(`ok`,[x({seriesId:p().int(),ok:s(!0),deleted:ij}),x({seriesId:p().int(),ok:s(!1),reason:aj})]),iye=x({series:C(nye).readonly(),truncated:y()}),oj=S([`invalid-range`,`range-too-large`,`series-not-found`,`not-a-point-series`]),aye=x({"5m":p().int(),"1h":p().int(),"1d":p().int()}),oye=a(`ok`,[x({ok:s(!0),dryRun:y(),seriesId:p().int(),rows:ij,rewritten:aye.nullable()}),x({ok:s(!1),reason:oj})]),sj=x({startedAt:p(),ready:y(),series:p().int(),metrics:p().int(),optedOutDevices:p().int(),tiers:C(tye).readonly(),capture:x({eventsSeen:p().int(),pointsEmitted:p().int(),pointsWritten:p().int(),pointsDropped:p().int(),bufferDepth:p().int(),trailingEmitted:p().int(),reconciledPoints:p().int(),reconcileRuns:p().int(),reconcileFailures:p().int(),lastReconcileAt:p().nullable(),lastFlushAt:p().nullable(),flushFailures:p().int(),skipped:d(m(),p().int())}),ingest:x({accepted:p().int(),refused:d(m(),p().int())}),rollup:x({last5mAt:p().nullable(),last1hAt:p().nullable(),last1dAt:p().nullable(),errors:p().int(),dirty5m:p().int(),dirty1h:p().int(),dirty1d:p().int()}),retention:x({lastRunAt:p().nullable(),deleted:d(m(),p().int()),purgedSeries:p().int()}),directory:x({devices:p().int(),lastRefreshAt:p().nullable()})}),cj={name:`device-history`,scope:`system`,mode:`singleton`,methods:{listSeries:E(x({deviceId:p().int()}),C(ej).readonly()),listNodeSeries:E(x({forNodeId:m().min(1)}),C(ej).readonly(),{auth:`admin`}),query:E(x({deviceId:p().int(),...tj}),nj),queryNode:E(x({forNodeId:m().min(1),...tj}),nj,{auth:`admin`}),queryMany:E(x({items:C($ve).min(1).max(24),from:tj.from,to:tj.to,resolution:tj.resolution,maxPoints:tj.maxPoints}),x({results:C(eye).readonly()}),{auth:`admin`}),declareSeries:E(x({name:m().regex(/^[a-z0-9-]+$/),subjectKind:S([`device`,`node`]),kind:YA,unit:m().optional(),displayName:m().min(1),ingest:S([`points`,`buckets`])}),x({key:m()}),{kind:`mutation`,auth:`admin`}),record:E(x({points:C(x({key:m(),subject:qA,scope:m().default(``),ts:p(),value:p()})).max(5e3)}),$A,{kind:`mutation`,auth:`admin`}),recordBuckets:E(x({buckets:C(x({key:m(),subject:qA,scope:m().default(``),bucketStart:p(),samples:p().int().positive(),sum:p(),min:p(),max:p(),last:p().nullable(),lastTs:p().nullable()})).max(5e3)}),$A,{kind:`mutation`,auth:`admin`}),getDeviceEnabled:E(x({deviceId:p().int()}),x({enabled:y()})),setDeviceEnabled:E(x({deviceId:p().int(),enabled:y()}),x({enabled:y()}),{kind:`mutation`,auth:`admin`}),getStatus:E(x({}),sj,{auth:`admin`}),listOrphanSeries:E(x({}),iye,{auth:`admin`}),deleteOrphanSeries:E(x({seriesIds:C(p().int()).min(1).max(50)}),x({results:C(rye).readonly()}),{kind:`mutation`,auth:`admin`}),deleteSeriesRange:E(x({deviceId:p().int(),key:m().min(1),scope:m(),fromMs:p().int().nonnegative(),toMs:p().int().nonnegative(),dryRun:y()}),oye,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`recorded history of device state — read by charts, not actuated`}},sye=x({id:m(),label:m(),protocol:S([`rtsp`,`rtmp`,`annexb`,`http-mjpeg`,`webrtc`,`custom`]),url:m().optional(),resolution:x({width:p(),height:p()}).optional(),fps:p().optional(),bitrate:p().optional(),codec:m().optional(),profileHint:A.optional(),sdp:m().optional()}),cye=x({key:m(),value:u()}),lj=x({source:m(),data:d(m(),u())}),uj={name:`device-ops`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{getStreamSources:E(x({deviceId:p()}),C(sye)),getConfigEntries:E(x({deviceId:p()}),C(cye)),setConfig:E(x({deviceId:p(),values:d(m(),u())}),v(),{kind:`mutation`,auth:`admin`}),runAction:E(x({deviceId:p(),action:m().min(1),input:u()}),u(),{kind:`mutation`,notOperatorFacing:`a provider-defined custom action whose id and input only the addon knows; it reaches the picker through the custom-actions surface, not a fixed phrase`}),removeDevice:E(x({deviceId:p()}),v(),{kind:`mutation`,auth:`admin`}),getSettingsSchema:E(x({deviceId:p()}),u().nullable()),getRawState:E(x({deviceId:p()}),lj.nullable(),{auth:`protected`})},vocabulary:{noun:I(`Device operations`,`Operazioni del dispositivo`),order:3110}},dj=x({deviceId:p().int().positive(),deletedAt:p(),providerAddonId:m()}),fj=x({counts:d(m(),p().int().nonnegative())}),pj=x({store:m(),deviceId:p().int().positive(),count:p().int().nonnegative()}),mj={name:`device-removal-hook`,scope:`system`,mode:`collection`,internal:!0,methods:{onDeviceRemoved:E(dj,fj,{kind:`mutation`,auth:`admin`}),listDeviceData:E(v(),C(pj).readonly(),{auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:O.INTERNAL}},hj=S([`appliance`,`mower`,`vacuum`]),gj=S([`open`,`closed`]),_j=S([`completed`,`aborted`,`error`,`unknown`]),vj=S([`running-state`,`activity`,`reconcile`]),yj=S([`counter-delta`,`history-integral`]),bj=x({phase:m(),at:p()}),xj=x({kind:s(`appliance`),energyKwh:p().nullable().meta(k(`energy`)),energyMethod:yj.nullable(),peakW:p().nullable().meta(k(`power`)),avgW:p().nullable().meta(k(`power`)),program:m().nullable(),remainingAtStartSec:p().nullable().meta(k(`duration`)),finalPhase:m().nullable(),energyStartKwh:p().nullable().meta(k(`energy`)),powerObservedMs:p()}),Sj=a(`kind`,[xj]),Cj=x({runId:m(),deviceId:p().int(),kind:hj,state:gj,startedAt:p(),endedAt:p().nullable(),durationMs:p().nullable(),outcome:_j.nullable(),startSource:vj,endSource:vj.nullable(),runningSource:S([`native`,`assigned`]).nullable(),phases:C(bj),detail:Sj}),wj={name:`device-runs`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[j.Washer,j.Dryer,j.Dishwasher],methods:{listRuns:E(x({deviceId:p().int(),outcome:_j.optional(),atFrom:p().optional(),atTo:p().optional(),limit:p().int().positive().max(200).default(50),cursor:m().optional()}),x({runs:C(Cj).readonly(),nextCursor:m().nullable()})),getRun:E(x({deviceId:p().int(),runId:m()}),Cj.nullable()),getCurrentRun:E(x({deviceId:p().int()}),Cj.nullable())},events:{onRunOpened:{data:Cj,notOperatorFacing:`the durable record of a run that the running-state start flip already announces`},onRunClosed:{data:Cj,notOperatorFacing:`the durable record of a run that the running-state finish flip already announces`}},vocabulary:{noun:I(`Runs`,`Esecuzioni`),order:2130}},Tj=S([`replace`,`add`]),Ej=a(`ok`,[x({ok:s(!0),changed:y()}),x({ok:s(!1),code:S([`owned-by-other`,`not-claimed`,`field-not-claimed`,`invalid-slice`,`unknown-device`,`row-unreadable`,`migration-in-flight`]),message:m()})]),Dj=x({deviceId:p(),capName:m(),owner:m().min(1),mode:Tj,fields:C(m().min(1)).min(1)}),Oj=a(`state`,[x({state:s(`loaded`),claims:C(Dj)}),x({state:s(`not-loaded`),reason:m()})]),kj={name:`device-state`,scope:`system`,mode:`singleton`,methods:{getSnapshot:E(x({deviceId:p()}),d(m(),d(m(),u()))),getCapSlice:E(x({deviceId:p(),capName:m()}),d(m(),u()).nullable()),getAllSnapshots:E(x({}),d(m(),d(m(),d(m(),u())))),setCapSlice:E(x({deviceId:p(),capName:m(),slice:d(m(),u())}),v(),{kind:`mutation`}),claimFields:E(x({deviceId:p(),capName:m(),owner:m().min(1),mode:Tj,fields:C(m().min(1)).min(1),values:d(m(),u())}),Ej,{kind:`mutation`,auth:`admin`}),patchOwnedFields:E(x({deviceId:p(),capName:m(),owner:m().min(1),values:d(m(),u())}),Ej,{kind:`mutation`,auth:`admin`}),releaseClaim:E(x({deviceId:p(),capName:m(),owner:m().min(1)}),Ej,{kind:`mutation`,auth:`admin`}),listClaims:E(x({ownerPrefix:m().optional()}),Oj,{auth:`admin`}),getNativeCapSlice:E(x({deviceId:p(),capName:m()}),d(m(),u()).nullable(),{auth:`admin`})},events:{onChanged:si(x({deviceId:p(),capName:m(),slice:d(m(),u())}))},vocabulary:{notOperatorFacing:`the runtime-state mirror every trigger already reads through`}},Aj=x({online:y(),lastChangedAt:p()}),jj={name:`device-status`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},events:{onStatusChanged:{data:x({deviceId:p(),status:Aj}),notOperatorFacing:"the `online` state trigger phrases both edges of this change"}},status:{schema:Aj,kind:`push`},runtimeState:Aj,durability:`restored`,history:{fields:{online:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:I(`Reachability`,`Raggiungibilità`),order:5260,state:[{kind:`boolean`,field:`online`,label:I(`Online`,`Online`),whenTrue:I(`When {device} comes back online`,`Quando {device} torna online`),whenFalse:I(`When {device} goes offline`,`Quando {device} va offline`),icon:`wifi`}],extraEvents:[{category:w.DeviceOnline,label:I(`Came online`,`Tornato online`),phrase:I(`When {device} comes back online`,`Quando {device} torna online`),icon:`wifi`},{category:w.DeviceOffline,label:I(`Went offline`,`Andato offline`),phrase:I(`When {device} goes offline`,`Quando {device} va offline`),icon:`wifi-off`}]}},Mj=S([`not-kernel`,`invalid`]),Nj=x({written:p().int().nonnegative(),refused:C(x({id:m(),reason:Mj})).readonly()}),Pj=x({rows:p().int().nullable(),lastWriteAt:p().nullable(),refused:d(m(),p())}),Fj={name:`device-transitions`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:Object.values(j).filter(e=>e!==j.Container),methods:{listTransitions:E(x({deviceId:p().int(),capName:m().optional(),actorKind:wo.optional(),outcome:To.optional(),atFrom:p().optional(),atTo:p().optional(),limit:p().int().positive().max(200).default(50),cursor:m().optional()}),x({transitions:C(Eo).readonly(),nextCursor:m().nullable()})),getTransition:E(x({deviceId:p().int(),id:m()}),Eo.nullable()),listRecentTransitions:oi(x({actorKind:wo.optional(),outcome:To.optional(),atFrom:p().optional(),atTo:p().optional(),limit:p().int().positive().max(200).default(50),cursor:m().optional()}),x({transitions:C(Eo).readonly(),nextCursor:m().nullable()}),{auth:`admin`}),record:oi(x({transitions:C(Eo).max(500)}),Nj,{kind:`mutation`,auth:`admin`}),getStatus:oi(x({}),Pj,{auth:`admin`})},vocabulary:{noun:I(`Transitions`,`Transizioni`),order:2140}},Ij=S([`idle`,`running`,`paused`,`finished`,`error`,`unavailable`]),Lj=S([`Inactive`,`Ready`,`DelayedStart`,`Run`,`Pause`,`ActionRequired`,`Finished`,`Error`,`Aborting`]),Rj=S([`available`,`offline`,`description-missing`]),zj=x({availability:Rj,state:Ij,operationState:Lj.nullable(),program:m().nullable(),selectedProgram:m().nullable(),availablePrograms:C(m()),remaining:p().int().nonnegative().nullable().meta(k(`duration`)),delayedStart:p().int().nonnegative().nullable().meta(k(`duration`)),progress:p().min(0).max(100).nullable().meta(k(`percentage`)),doorOpen:y().nullable(),doorLocked:y().nullable(),remoteStartAllowed:y().nullable(),remoteControlActive:y().nullable(),localControlActive:y().nullable(),powerOn:y().nullable(),powerState:m().nullable(),filterCleaningDue:y().nullable(),machineCareDue:y().nullable(),machineCareRemainingRuns:p().int().nonnegative().nullable().meta(k(`count`)),halfLoad:y().nullable(),hygienePlus:y().nullable(),extraDry:y().nullable(),intensiveZone:y().nullable(),varioSpeedPlus:y().nullable(),childLock:y().nullable(),activeEvents:C(m()),errorCode:p().nullable().meta(k(`none`)),errorLabel:m().nullable(),lastFetchedAt:p()}),Bj=p().int().nonnegative(),Vj=l([y(),m(),p()]),Hj=S([`none`,`read`,`readWrite`,`writeOnly`,`readStatic`]),Uj=x({key:m(),name:m(),type:S([`boolean`,`number`,`enum`,`string`]),access:Hj,available:y(),unit:m().nullable(),min:p().nullable(),max:p().nullable(),step:p().nullable(),enumValues:C(m()).nullable(),defaultValue:Vj.nullable()}),Wj=x({key:m(),name:m(),available:y(),options:C(Uj)}),Gj=x({availability:Rj,supportsStart:y(),supportsPause:y(),supportsResume:y(),supportsStop:y(),supportsPower:y(),programs:C(Wj),options:C(Uj)}),Kj={name:`dishwasher`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Dishwasher],methods:{start:E(x({deviceId:Bj,program:m().min(1).optional(),options:d(m(),Vj).optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.start`,label:I(`Start cycle`,`Avvia il lavaggio`),phrase:I(`Start {device}`,`Avvia {device}`),icon:`play`,openArgs:[{key:`program`,label:I(`Programme`,`Programma`),offer:{kind:`dynamic`,from:`status`,field:`availablePrograms`},optional:!0}]}]}),pause:E(x({deviceId:Bj}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.pause`,label:I(`Pause`,`Metti in pausa`),phrase:I(`Pause {device}`,`Metti in pausa {device}`),icon:`pause`}]}),resume:E(x({deviceId:Bj}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.resume`,label:I(`Resume`,`Riprendi`),phrase:I(`Resume {device}`,`Riprendi il lavaggio di {device}`),icon:`play`}]}),stop:E(x({deviceId:Bj}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.stop`,label:I(`Stop`,`Ferma`),phrase:I(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),setProgram:E(x({deviceId:Bj,program:m().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.program`,label:I(`Choose programme`,`Scegli il programma`),phrase:I(`Select the {program} programme on {device}`,`Seleziona il programma {program} su {device}`),icon:`list`,openArgs:[{key:`program`,label:I(`Programme`,`Programma`),offer:{kind:`dynamic`,from:`status`,field:`availablePrograms`}}]}]}),setPower:E(x({deviceId:Bj,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.powerOn`,label:I(`Power on`,`Accendi`),phrase:I(`Turn on {device}`,`Accendi {device}`),icon:`power`,args:{on:!0}},{id:`dishwasher.powerOff`,label:I(`Power off`,`Spegni`),phrase:I(`Turn off {device}`,`Spegni {device}`),icon:`power-off`,args:{on:!1}}]}),setHalfLoad:E(x({deviceId:Bj,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.halfLoadOn`,label:I(`Half load on`,`Mezzo carico attivo`),phrase:I(`Turn on half load on {device}`,`Attiva il mezzo carico su {device}`),icon:`contrast`,args:{on:!0}},{id:`dishwasher.halfLoadOff`,label:I(`Half load off`,`Mezzo carico spento`),phrase:I(`Turn off half load on {device}`,`Disattiva il mezzo carico su {device}`),icon:`contrast`,args:{on:!1}}]}),setHygienePlus:E(x({deviceId:Bj,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.hygienePlusOn`,label:I(`Hygiene Plus on`,`Igiene Plus attiva`),phrase:I(`Turn on Hygiene Plus on {device}`,`Attiva Igiene Plus su {device}`),icon:`sparkles`,args:{on:!0}},{id:`dishwasher.hygienePlusOff`,label:I(`Hygiene Plus off`,`Igiene Plus spenta`),phrase:I(`Turn off Hygiene Plus on {device}`,`Disattiva Igiene Plus su {device}`),icon:`sparkles`,args:{on:!1}}]}),setExtraDry:E(x({deviceId:Bj,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.extraDryOn`,label:I(`Extra dry on`,`Asciugatura extra attiva`),phrase:I(`Turn on extra dry on {device}`,`Attiva l’asciugatura extra su {device}`),icon:`sun`,args:{on:!0}},{id:`dishwasher.extraDryOff`,label:I(`Extra dry off`,`Asciugatura extra spenta`),phrase:I(`Turn off extra dry on {device}`,`Disattiva l’asciugatura extra su {device}`),icon:`sun`,args:{on:!1}}]}),setIntensiveZone:E(x({deviceId:Bj,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.intensiveZoneOn`,label:I(`Intensive zone on`,`Zona intensiva attiva`),phrase:I(`Turn on the intensive zone on {device}`,`Attiva la zona intensiva su {device}`),icon:`flame`,args:{on:!0}},{id:`dishwasher.intensiveZoneOff`,label:I(`Intensive zone off`,`Zona intensiva spenta`),phrase:I(`Turn off the intensive zone on {device}`,`Disattiva la zona intensiva su {device}`),icon:`flame`,args:{on:!1}}]}),setVarioSpeedPlus:E(x({deviceId:Bj,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.varioSpeedOn`,label:I(`Speed boost on`,`Lavaggio rapido attivo`),phrase:I(`Turn on the speed boost on {device}`,`Attiva il lavaggio rapido su {device}`),icon:`zap`,args:{on:!0}},{id:`dishwasher.varioSpeedOff`,label:I(`Speed boost off`,`Lavaggio rapido spento`),phrase:I(`Turn off the speed boost on {device}`,`Disattiva il lavaggio rapido su {device}`),icon:`zap`,args:{on:!1}}]}),setChildLock:E(x({deviceId:Bj,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.childLockOn`,label:I(`Child lock on`,`Blocco bambini attivo`),phrase:I(`Turn on the child lock of {device}`,`Attiva il blocco bambini di {device}`),icon:`lock`,args:{on:!0}},{id:`dishwasher.childLockOff`,label:I(`Child lock off`,`Blocco bambini spento`),phrase:I(`Turn off the child lock of {device}`,`Disattiva il blocco bambini di {device}`),icon:`lock-open`,args:{on:!1}}]}),setOption:E(x({deviceId:Bj,key:m().min(1),value:Vj}),v(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`a raw appliance option key/value; every option worth naming has its own action above`}),getOptions:E(x({deviceId:Bj}),Gj,{auth:`protected`})},status:{schema:zj,kind:`poll`},runtimeState:zj,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:I(`Dishwasher`,`Lavastoviglie`),order:2020,state:[{kind:`enum`,field:`state`,label:I(`Cycle`,`Ciclo`),values:[{value:`idle`,label:I(`Idle`,`Inattiva`)},{value:`running`,label:I(`Running`,`In funzione`),phrase:I(`When {device} starts a cycle`,`Quando {device} inizia un lavaggio`)},{value:`paused`,label:I(`Paused`,`In pausa`)},{value:`finished`,label:I(`Finished`,`Terminato`),phrase:I(`When {device} finishes`,`Quando {device} finisce il lavaggio`)},{value:`error`,label:I(`Error`,`Errore`),phrase:I(`When {device} reports an error`,`Quando {device} segnala un errore`)},{value:`unavailable`,label:I(`Unavailable`,`Non disponibile`)}],icon:`washing-machine`},{kind:`numeric`,field:`progress`,quantity:I(`the cycle progress`,`l’avanzamento del lavaggio`),label:I(`Progress`,`Avanzamento`),unit:`%`,icon:`loader`},{kind:`boolean`,field:`doorOpen`,label:I(`Door open`,`Sportello aperto`),whenTrue:I(`When the door of {device} opens`,`Quando si apre lo sportello di {device}`),whenFalse:I(`When the door of {device} closes`,`Quando si chiude lo sportello di {device}`),icon:`door-open`},{kind:`boolean`,field:`filterCleaningDue`,label:I(`Filter cleaning due`,`Pulizia filtro da fare`),whenTrue:I(`When {device} asks for its filter to be cleaned`,`Quando {device} chiede di pulire il filtro`),whenFalse:I(`When the filter reminder of {device} clears`,`Quando l’avviso filtro di {device} rientra`),icon:`funnel`},{kind:`boolean`,field:`machineCareDue`,label:I(`Machine care due`,`Manutenzione da fare`),whenTrue:I(`When {device} asks for a machine-care cycle`,`Quando {device} chiede un ciclo di manutenzione`),whenFalse:I(`When the machine-care reminder of {device} clears`,`Quando l’avviso di manutenzione di {device} rientra`),icon:`wrench`}]}},qj=`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(`.`),Jj=`audio`,Yj=[.3,.42,.55,.7,.85,1],Xj=[`camstack`,`high-contrast`,`okabe-ito`];function lye(e){return qj.includes(e)}function uye(e){return Xj.includes(e)}var Zj={dark:`#0c0a09`,light:`#fafaf9`},dye=[`live`,`heatmapScrub`],Qj=/^#[0-9a-fA-F]{6}$/;function $j(e,t){return Number.parseInt(e.slice(t,t+2),16)}function eM(e){let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function tM(e){let t=eM($j(e,1)),n=eM($j(e,3)),r=eM($j(e,5));return .2126*t+.7152*n+.0722*r}function fye(e,t){if(!Qj.test(e)||!Qj.test(t))return 0;let n=Math.max(tM(e),tM(t)),r=Math.min(tM(e),tM(t));return(n+.05)/(r+.05)}function nM(e){let t=eM($j(e,1)),n=eM($j(e,3)),r=eM($j(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 rM(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 pye(e,t){if(!Qj.test(e)||!Qj.test(t))return 0;let n=nM(e),r=nM(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=rM(o,n.b),d=rM(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 _=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),v=30*Math.exp(-(((g-275)/25)**2)),ee=h**7,y=2*Math.sqrt(ee/(ee+25**7)),te=1+.015*(m-50)**2/Math.sqrt(20+(m-50)**2),ne=1+.045*h,re=1+.015*h*_,ie=-Math.sin(2*v*Math.PI/180)*y,b=r.L-n.L,ae=l-c;return Math.sqrt((b/te)**2+(ae/ne)**2+(p/re)**2+ae/ne*ie*(p/re))}var mye={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`},hye=[`#b34dc7`,`#1d7d34`,`#db6b6c`,`#a43d29`,`#0e6ee6`,`#29a10b`,`#a98731`,`#0181c6`],gye={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`},_ye=[`#817f3b`,`#a0733e`,`#8658b2`,`#956301`,`#bc652d`,`#647331`,`#a14c9e`,`#d14e71`],vye={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`},yye=[`#9a3784`,`#a7392c`,`#409d50`,`#6987e7`,`#ee5b3d`,`#c0430d`,`#af79b3`,`#4b6628`],iM=m().regex(/^#[0-9a-f]{6}$/),aM=a(`form`,[x({form:s(`solid`),hex:iM}),x({form:s(`gradient`),hex:iM,alphas:C(p().gt(0).lte(1)).length(Yj.length)})]),oM=x({status:s(`ready`),presetId:S(Xj),customized:y(),source:S([`stored`,`unconfigured`]),swatches:d(m(),aM),fallbacks:C(iM).length(8)}),sM=a(`status`,[oM,x({status:s(`unknown`),reason:m()})]),cM=l([x({presetId:m()}),x({presetId:m(),overrides:d(m(),aM)})]),lM=x({presetId:m(),overrides:d(m(),aM)});function bye(e){return{form:`solid`,hex:e}}function xye(e){return{form:`gradient`,hex:e,alphas:[...Yj]}}function Sye(e){let t={};for(let n of qj){let r=e[n];if(r===void 0)throw Error(`palette table missing ${n}`);t[n]=n===`audio`?xye(r):bye(r)}return t}function uM(e,t,n,r){return{id:e,name:t,swatches:Sye(n),fallbacks:r}}var dM=[uM(`camstack`,`CamStack`,mye,hye),uM(`high-contrast`,`High contrast`,gye,_ye),uM(`okabe-ito`,`Colour-blind safe`,vye,yye)];function fM(e){return dM.find(t=>t.id===e)}function pM(){let e=fM(`camstack`);if(e===void 0)throw Error(`CamStack preset missing`);return Cye(e,`unconfigured`,!1)}function Cye(e,t,n){return{status:`ready`,presetId:e.id,customized:n,source:t,swatches:e.swatches,fallbacks:[...e.fallbacks]}}function wye(e){return e.hex}function Tye(e,t){let n=[];for(let t of qj){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 Eye(e){let t=e[Jj];return t===void 0||t.form===`gradient`&&Yj.every((e,n)=>t.alphas[n]===e)?[]:[{code:`bad-gradient`,entry:Jj}]}function Dye(e,t){let n=dye;return n.includes(e)&&n.includes(t)}function mM(e,t){let n=[];for(let t of qj)e[t]===void 0&&n.push({code:`missing-entry`,entry:t});for(let t of Object.keys(e))lye(t)||n.push({code:`unknown-entry`,entry:t});t.length!==8&&n.push({code:`bad-fallbacks`}),n.push(...Eye(e));let r=Tye(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=pye(i.hex,a.hex);o<(Dye(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=fye(e.hex,Zj[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 Oye(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 hM(e){return e.map(Oye).join(`; `)}var gM=class extends Error{violations;constructor(e){super(hM(e)),this.name=`PaletteRejectedError`,this.violations=e}};function _M(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 vM(e,t,n){let r=n.trim().toLowerCase();if(r.startsWith(`audio-`)){let n=e[Jj];return n===void 0?_M(r,t):n.hex}let i=e[r];return i===void 0?_M(r,t):i.hex}function yM(e,t){return{...e,...t}}function kye(e){return`overrides`in e?e.overrides:{}}function Aye(e){let t=fM(e.presetId);if(t===void 0||!uye(e.presetId))throw new gM([{code:`unknown-preset`,presetId:e.presetId}]);let n=kye(e),r=yM(t.swatches,n),i=mM(r,t.fallbacks);if(!i.ok)throw new gM(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 jye(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.keys(e).length===0}function Mye(e){if(e==null||jye(e))return pM();let t=lM.safeParse(e);if(!t.success)return{status:`unknown`,reason:`stored palette is unreadable`};let n=fM(t.data.presetId);if(n===void 0)return{status:`unknown`,reason:`unknown preset ${t.data.presetId}`};let r=yM(n.swatches,t.data.overrides),i=mM(r,n.fallbacks);if(!i.ok)return{status:`unknown`,reason:hM(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 Nye(e,t){return{presetId:e.presetId,overrides:{...t}}}var Pye=x({id:m(),name:m(),swatches:d(m(),aM),fallbacks:C(m())}),bM={name:`display-palette`,scope:`system`,mode:`singleton`,methods:{getPalette:E(v(),sM,{auth:`protected`,role:`viewer`}),listPresets:E(v(),C(Pye).readonly(),{auth:`protected`,role:`viewer`}),setPalette:E(cM,oM,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`the cluster display palette — one colour table for every client, not a device action`}},xM=x({enabled:y().nullable().meta({label:`Do not disturb`}),lastChangedAt:p()}),SM={name:`do-not-disturb`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.MediaPlayer],methods:{setEnabled:E(x({deviceId:p().int(),enabled:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dnd.on`,label:I(`Do not disturb on`,`Attiva Non disturbare`),phrase:I(`Turn on Do not disturb on {device}`,`Attiva Non disturbare su {device}`),icon:`bell-off`,args:{enabled:!0}},{id:`dnd.off`,label:I(`Do not disturb off`,`Disattiva Non disturbare`),phrase:I(`Turn off Do not disturb on {device}`,`Disattiva Non disturbare su {device}`),icon:`bell`,args:{enabled:!1}}]})},status:{schema:xM,kind:`push`},runtimeState:xM,durability:`session`,history:{fields:{enabled:{kind:`boolean`}}},vocabulary:{noun:I(`Do not disturb`,`Non disturbare`),order:2160,state:[{kind:`boolean`,field:`enabled`,label:I(`Do not disturb`,`Non disturbare`),whenTrue:I(`When Do not disturb turns on on {device}`,`Quando {device} attiva Non disturbare`),whenFalse:I(`When Do not disturb turns off on {device}`,`Quando {device} disattiva Non disturbare`),icon:`bell-off`}]}},CM=2e3,Fye={version:1,targets:[{id:`pressed`,cardinality:`event`,shape:`pulse`,vocabulary:{cap:`doorbell`,eventName:`onPressed`},deviceTypes:[j.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:CM,changedAtRequired:!0},sources:[{kind:`binary`},{kind:`switch`}],sourceReport:{status:`assignment-status`},advancedExpression:!0}]},wM=x({lastPressedAt:p().nullable(),pressCountSinceStart:p().meta(k(`count`))}),TM=x({deviceId:p(),timestamp:p()}),EM={name:`doorbell`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Button,j.Camera],methods:{},events:{onPressed:{data:TM,fromState:{field:`lastPressedAt`,on:`advance`},trigger:{category:w.DoorbellOnPressed,label:I(`Rang`,`Ha suonato`),phrase:I(`When someone rings {device}`,`Quando qualcuno suona a {device}`),icon:`bell-ring`}}},status:{schema:wM,kind:`push`},runtimeState:wM,durability:`restored`,history:`none`,customize:Fye,vocabulary:{noun:I(`Doorbell`,`Campanello`),order:5270}},DM=x({embedding:C(p()),inferenceMs:p()}),OM=S([`image`,`text`]),kM=x({modelId:m(),tower:OM,nodeId:m(),crashes:p(),windowMs:p(),sinceMs:p(),lastReason:m()}),AM=x({modelId:m(),tower:OM,nodeId:m(),attempts:p(),sinceMs:p(),lastReason:m()}),jM=x({modelId:m(),embeddingDim:p(),ready:y(),nodeId:m().optional(),failedModels:C(kM).optional(),failedRequirements:C(AM).optional()}),MM=`embedding-model-failed`,NM=`embedding-requirements-unavailable`,PM=`embedding-requirements-failed`,FM=S([MM,NM,PM]);function IM(e,t){return`[${e} model=${t.modelId} tower=${t.tower} node=${t.nodeId}]`}function Iye(e){return Error(`${IM(MM,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 Lye(e,t){return Error(`${IM(NM,e)} ${e.modelId} (${e.tower} tower) on ${e.nodeId}: ${t}`)}function Rye(e){return Error(`${IM(PM,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 zye=RegExp(`\\[(${MM}|${NM}|${PM}) model=([^\\s\\]]+) tower=(image|text) node=([^\\s\\]]+)\\]`);function LM(e){let t=e instanceof Error?e.message:String(e),n=zye.exec(t);if(n===null)return null;let r=FM.safeParse(n[1]),i=OM.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 Bye(e){return RM(e)!==null}function RM(e){let t=LM(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 zM={name:`embedding-encoder`,scope:`system`,mode:`collection`,internal:!0,methods:{encode:E(x({crop:b(Uint8Array),width:p(),height:p()}),DM,{auth:`admin`}),encodeText:E(x({text:m(),modelId:m().min(1).optional()}),DM,{auth:`admin`}),getInfo:E(v(),jM,{auth:`admin`}),resetFailedModels:E(x({modelId:m().min(1).optional()}),x({cleared:C(m()),nodeId:m()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.ML}},BM=x({powerW:p().nullable().meta(k(`power`)),energyKwh:p().nullable().meta(k(`energy`)),todayKwh:p().nullable().meta(k(`energy`))}),VM=x({powerW:p().nullable().meta(k(`power`)),importKwh:p().nullable().meta(k(`energy`)),exportKwh:p().nullable().meta(k(`energy`)),importTodayKwh:p().nullable().meta(k(`energy`)),exportTodayKwh:p().nullable().meta(k(`energy`))}),HM=x({powerW:p().nullable().meta(k(`power`)),energyKwh:p().nullable().meta(k(`energy`)),todayKwh:p().nullable().meta(k(`energy`))}),UM=x({stateOfChargePct:p().nullable().meta(k(`percentage`)),storedKwh:p().nullable().meta(k(`energy`)),capacityKwh:p().nullable().meta(k(`energy`)),powerW:p().nullable().meta(k(`power`)),chargedKwh:p().nullable().meta(k(`energy`)),dischargedKwh:p().nullable().meta(k(`energy`)),chargedTodayKwh:p().nullable().meta(k(`energy`)),dischargedTodayKwh:p().nullable().meta(k(`energy`)),healthPct:p().nullable().meta(k(`percentage`))}),WM=x({solar:BM.nullable(),grid:VM.nullable(),house:HM.nullable(),heatPump:HM.nullable(),storage:UM.nullable(),lastFetchedAt:p()});function GM(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 KM={name:`energy-system`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.EnergySystem],methods:{},status:{schema:WM,kind:`push`},runtimeState:WM,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:I(`Energy system`,`Sistema energetico`),order:4020}},Vye=S([`date`,`time`,`datetime`]),qM=x({value:m(),timestamp:y().optional(),lastFetchedAt:p()}),JM={name:`enum-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor],methods:{},status:{schema:qM,kind:`push`},runtimeState:qM,durability:`restored`,history:{fields:{value:{kind:`enum`,skipWhenSet:`timestamp`}}},volatileStateFields:[`lastFetchedAt`,`timestamp`],vocabulary:{noun:I(`State sensor`,`Sensore di stato`),order:5060,state:[{kind:`value`,field:`value`,label:I(`State`,`Stato`),icon:`list`}]}},YM=S([`warning`,`error`]),XM=x({code:m(),label:m(),severity:YM}),ZM=x({active:y().nullable(),code:m().nullable(),label:m().nullable(),severity:YM,since:p().nullable(),faults:C(XM).optional(),lastFetchedAt:p()}),QM={active:null,code:null,label:null,severity:`error`,since:null,lastFetchedAt:0},$M={name:`error`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},status:{schema:ZM,kind:`push`,empty:QM},runtimeState:ZM,durability:`restored`,volatileStateFields:[`lastFetchedAt`],history:`none`,vocabulary:{noun:I(`Fault`,`Guasto`),order:5265,state:[{kind:`boolean`,field:`active`,label:I(`Fault`,`Guasto`),whenTrue:I(`When {device} reports a fault`,`Quando {device} segnala un guasto`),whenFalse:I(`When the fault of {device} clears`,`Quando il guasto di {device} si risolve`),icon:`triangle-alert`}]}},eN=x({id:m(),name:m(),sampleCount:p().int().nonnegative(),coverMediaId:p().int().optional(),coverBase64:m().optional()}),Hye=x({id:m(),source:S([`detected`,`photo`]),addedAt:p().int(),deviceId:p().int().optional(),base64:m().optional(),mediaId:p().int().optional(),keyFrameMediaId:p().int().optional(),faceBbox:_y.optional()}),Uye=x({sampleId:m(),enrolledAt:p().int(),deviceId:p().int().optional(),source:S([`detected`,`photo`]),mediaId:p().int().optional(),comparable:y(),selfMean:p().nullable(),bestForeign:x({identityId:m(),name:m(),score:p()}).optional(),suspicion:p()}),Wye=x({identityId:m(),name:m(),modelId:m(),totalSamples:p().int(),comparableSamples:p().int(),flagged:p().int(),flagThreshold:p(),rows:C(Uye).readonly()}),tN=x({faceId:m(),deviceId:p().int(),trackId:m(),timestamp:p().int(),recognizedIdentityId:m().optional(),identityName:m().optional(),assigned:y(),base64:m().optional(),cropUrl:m().optional(),faceBbox:_y.optional(),keyFrameMediaId:p().int().optional(),bestMatchScore:p().optional(),nativeFaceShortSidePx:p().optional(),suggestedIdentityId:m().optional(),suggestedMatchScore:p().optional()}),Gye=S([`unassigned`,`recognized`,`identified`,`all`]),Kye=S([`timestamp`,`suggestionConfidence`]),qye=S([`asc`,`desc`]),Jye=x({faceIds:C(m()).readonly(),representativeFaceId:m(),size:p().int(),cohesion:p()}),Yye=x({mediaId:p().int(),kind:m(),url:m(),sizeBytes:p(),timestamp:p()}),nN={name:`face-gallery`,role:{feature:`face-assignment`},scope:`system`,mode:`singleton`,methods:{listIdentities:E(x({includeCrops:y().optional()}).optional(),C(eN).readonly(),{role:`viewer`}),createIdentity:E(x({name:m().min(1)}),eN,{kind:`mutation`,auth:`admin`}),renameIdentity:E(x({id:m(),name:m().min(1)}),v(),{kind:`mutation`,auth:`admin`}),deleteIdentity:E(x({id:m()}),v(),{kind:`mutation`,auth:`admin`}),listIdentitySamples:E(x({identityId:m()}),C(Hye).readonly()),auditIdentitySamples:E(x({identityId:m().min(1)}),Wye,{auth:`admin`}),removeSample:E(x({identityId:m(),sampleId:m()}),v(),{kind:`mutation`,auth:`admin`}),moveIdentitySample:E(x({sampleId:m().min(1),toIdentityId:m().min(1)}),v(),{kind:`mutation`,auth:`admin`}),listRecentFaces:E(x({deviceId:p().int().optional(),deviceIds:C(p().int()).optional(),limit:p().int().positive().optional(),filter:Gye.optional(),since:p().int().optional(),until:p().int().optional(),sortBy:Kye.optional(),sortDirection:qye.optional(),includeCrops:y().optional()}).optional(),C(tN).readonly()),getFaceByTrack:E(x({deviceId:p().int(),trackId:m()}),tN.nullable(),{role:`viewer`}),getFaceMedia:E(x({faceId:m()}),C(Yye).readonly()),assignFace:E(x({faceId:m(),identityId:m()}),v(),{kind:`mutation`,auth:`admin`}),unassignFace:E(x({faceId:m()}),v(),{kind:`mutation`,auth:`admin`}),deleteFace:E(x({faceId:m()}),v(),{kind:`mutation`,auth:`admin`}),assignFaces:E(x({faceIds:C(m()).min(1),identityId:m()}),x({assigned:p().int(),failed:C(m()).readonly()}),{kind:`mutation`,auth:`admin`}),unassignFaces:E(x({faceIds:C(m()).min(1)}),x({unassigned:p().int(),failed:C(m()).readonly()}),{kind:`mutation`,auth:`admin`}),suggestFaceClusters:E(x({threshold:p().min(0).max(1).optional(),minClusterSize:p().int().min(2).optional(),maxClusters:p().int().positive().optional(),limit:p().int().positive().optional(),maxFacesScanned:p().int().positive().optional()}).optional(),C(Jye).readonly())},vocabulary:{notOperatorFacing:`the face gallery — curated on its own page`}},rN=x({reason:m(),count:p().int().nonnegative()}),iN=x({family:m(),deviceId:p().int().positive(),variant:m().optional(),sinceMs:p(),atMs:p(),attempts:p().int().nonnegative(),succeeded:p().int().nonnegative(),reasons:C(rN).readonly()}),aN={name:`failure-contribution`,scope:`system`,mode:`collection`,internal:!0,methods:{list:E(v(),C(iN).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:O.INTERNAL}},oN=S([`forward`,`reverse`]),sN=[`horizontal`,`vertical`],cN=S(sN),lN=[`oscillating`,`angle`,`sweepFrom`,`sweepTo`],uN=S(lN),dN=[`min`,`max`,`step`],fN=x({oscillating:y().nullable().default(null),angle:p().nullable().default(null),sweepFrom:p().nullable().default(null),sweepTo:p().nullable().default(null),min:p().nullable().default(null),max:p().nullable().default(null),step:p().nullable().default(null)}),pN=x({horizontal:fN.nullable().default(null),vertical:fN.nullable().default(null)}),mN=[`nothing-to-set`,`axis-not-linked`,`out-of-range`,`source-gone`,`source-unknown`,`source-call-failed`],hN=S(mN),gN=a(`status`,[x({status:s(`applied`)}),x({status:s(`refused`),reason:hN,field:uN.optional(),detail:m(),applied:C(uN)})]),_N=x({deviceId:p().int().nonnegative(),axis:cN,oscillating:y().optional(),angle:p().optional(),sweepFrom:p().optional(),sweepTo:p().optional()});function vN(e,t){return`oscillationAxes.${e}.${t}`}var yN=x({speed:p().min(0).max(100).nullable().meta(k(`percentage`)),percentageStep:p().positive().optional().meta(k(`percentage`)),preset:m(),availablePresets:C(m()),direction:oN.nullable(),oscillating:y().nullable(),oscillationAxes:pN.optional(),lastChangedAt:p()});function Xye(e){let t=e.oscillationAxes;if(t===void 0)return e.oscillating;let n=sN.flatMap(e=>{let n=t[e]?.oscillating;return n==null?[]:[n]});return n.length===0?e.oscillating:n.some(Boolean)}var bN=[j.Fan],xN=`oscillation-axes`;function Zye(e){return{id:`${e}-oscillating`,cardinality:`scalar`,vocabulary:{cap:`fan-control`,stateField:`oscillating`},deviceTypes:bN,apply:`replace`,section:xN,path:vN(e,`oscillating`),sources:[{kind:`switch`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}}function SN(e,t){let n={id:`${e}-${t}`,cardinality:`scalar`,vocabulary:{cap:`fan-control`},deviceTypes:bN,apply:`replace`,section:xN,path:vN(e,t),sources:[{kind:`numeric`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}};return t===`angle`?{...n,companions:dN.map(t=>({kind:`source-field`,path:vN(e,t),field:t}))}:n}var Qye=sN.flatMap(e=>[Zye(e),SN(e,`angle`),SN(e,`sweepFrom`),SN(e,`sweepTo`)]),$ye={id:`preset`,cardinality:`scalar`,vocabulary:{cap:`fan-control`},deviceTypes:bN,apply:`replace`,path:`preset`,sources:[{kind:`field`,valueKinds:[`string`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}},CN=[...Qye,$ye],ebe={version:1,overridable:CN.map(e=>({path:e.path,by:e.id})),targets:CN},wN={name:`fan-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Fan],methods:{setPercentage:D(x({deviceId:p().int().nonnegative(),speed:p().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.off`,label:I(`Fan off`,`Ventilatore spento`),phrase:I(`Stop {device}`,`Ferma {device}`),icon:`power-off`,effect:{field:`speed`,value:0},args:{speed:0}},{id:`fan.full`,label:I(`Fan full`,`Ventilatore al massimo`),phrase:I(`Run {device} at full speed`,`Porta {device} alla massima velocità`),icon:`fan`,effect:{field:`speed`,value:100},args:{speed:100}},{id:`fan.speed`,label:I(`Set speed`,`Imposta la velocità`),phrase:I(`Set the speed of {device} to {speed}`,`Imposta la velocità di {device} al {speed}`),icon:`fan`,effect:{field:`speed`,fromArg:`speed`},openArgs:[{key:`speed`,label:I(`Speed`,`Velocità`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setPreset:D(x({deviceId:p().int().nonnegative(),preset:m().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.preset`,label:I(`Set preset`,`Imposta il preset`),phrase:I(`Set {device} to preset {preset}`,`Imposta {device} sul preset {preset}`),icon:`list`,openArgs:[{key:`preset`,label:I(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`status`,field:`availablePresets`}}]}]}),setDirection:D(x({deviceId:p().int().nonnegative(),direction:oN}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.forward`,label:I(`Spin forward`,`Rotazione avanti`),phrase:I(`Spin {device} forward`,`Fai girare {device} in avanti`),icon:`refresh-cw`,effect:{field:`direction`,value:`forward`},args:{direction:`forward`}},{id:`fan.reverse`,label:I(`Spin in reverse`,`Rotazione inversa`),phrase:I(`Spin {device} in reverse`,`Fai girare {device} al contrario`),icon:`rotate-ccw`,effect:{field:`direction`,value:`reverse`},args:{direction:`reverse`}}]}),setOscillating:D(x({deviceId:p().int().nonnegative(),oscillating:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.oscillateOn`,label:I(`Oscillate`,`Oscillazione attiva`),phrase:I(`Make {device} oscillate`,`Fai oscillare {device}`),icon:`move-horizontal`,effect:{field:`oscillating`,value:!0},args:{oscillating:!0}},{id:`fan.oscillateOff`,label:I(`Stop oscillating`,`Oscillazione spenta`),phrase:I(`Stop {device} oscillating`,`Ferma l’oscillazione di {device}`),icon:`move-horizontal`,effect:{field:`oscillating`,value:!1},args:{oscillating:!1}}]}),setOscillationAxis:D(_N,gN,{kind:`mutation`,auth:`protected`,actions:[{id:`fan.horizontalOscillateOn`,label:I(`Horizontal oscillation on`,`Oscillazione orizzontale attiva`),phrase:I(`Start the horizontal oscillation of {device}`,`Attiva l’oscillazione orizzontale di {device}`),icon:`move-horizontal`,args:{axis:`horizontal`,oscillating:!0}},{id:`fan.horizontalOscillateOff`,label:I(`Horizontal oscillation off`,`Oscillazione orizzontale spenta`),phrase:I(`Stop the horizontal oscillation of {device}`,`Ferma l’oscillazione orizzontale di {device}`),icon:`move-horizontal`,args:{axis:`horizontal`,oscillating:!1}},{id:`fan.verticalOscillateOn`,label:I(`Vertical oscillation on`,`Oscillazione verticale attiva`),phrase:I(`Start the vertical oscillation of {device}`,`Attiva l’oscillazione verticale di {device}`),icon:`move-vertical`,args:{axis:`vertical`,oscillating:!0}},{id:`fan.verticalOscillateOff`,label:I(`Vertical oscillation off`,`Oscillazione verticale spenta`),phrase:I(`Stop the vertical oscillation of {device}`,`Ferma l’oscillazione verticale di {device}`),icon:`move-vertical`,args:{axis:`vertical`,oscillating:!1}}]})},status:{schema:yN,kind:`push`},runtimeState:yN,customize:ebe,durability:`session`,history:{fields:{speed:{kind:`gauge`,unit:`%`,minIntervalMs:0},oscillating:{kind:`boolean`}}},vocabulary:{noun:I(`Fan`,`Ventilatore`),order:1080,state:[{kind:`numeric`,field:`speed`,quantity:I(`the speed`,`la velocità`),label:I(`Speed`,`Velocità`),unit:`%`,icon:`fan`},{kind:`boolean`,field:`oscillating`,label:I(`Oscillating`,`Oscillazione`),whenTrue:I(`When {device} starts oscillating`,`Quando {device} inizia a oscillare`),whenFalse:I(`When {device} stops oscillating`,`Quando {device} smette di oscillare`),icon:`move-horizontal`}]}},TN=x({oscillating:y().optional(),angle:p().optional(),sweepFrom:p().optional(),sweepTo:p().optional()}),EN=x({speed:p().min(0).max(100).optional(),preset:m().min(1).optional(),direction:oN.optional(),oscillationAxes:x({horizontal:TN.optional(),vertical:TN.optional()}).optional()}),DN=x({id:m().min(1).max(64),name:m().trim().min(1).max(40),state:EN}),ON=[`empty-state`,`duplicate-name`,`duplicate-id`,`too-many`,`not-a-fan`],kN=S(ON),AN=a(`status`,[x({status:s(`saved`),count:p().int().nonnegative()}),x({status:s(`refused`),reason:kN,detail:m()})]),jN=x({field:m(),outcome:S([`applied`,`failed`,`not-run`,`refused`]),message:m().optional()}),MN=x({status:S([`applied`,`partial`,`refused`]),fields:C(jN)}),NN=[`speed`,`direction`,`preset`,`oscillationAxes`],PN=S(NN),FN=x({what:m(),reason:m()}),IN=x({state:EN,omitted:C(FN)}),LN=x({deviceId:p().int().nonnegative()}),tbe={version:1,targets:[{id:`presets`,cardinality:`config`,vocabulary:{cap:`fan-presets`},deviceTypes:[j.Fan],apply:`add`,readMethod:`getPresets`,writeMethod:`setPresets`}]},RN={name:`fan-presets`,scope:`system`,mode:`singleton`,methods:{getPresets:E(LN,C(DN),{auth:`protected`}),setPresets:E(LN.extend({presets:C(DN).max(12)}),AN,{kind:`mutation`,auth:`admin`}),applyPreset:E(LN.extend({presetId:m().min(1)}),MN,{kind:`mutation`,auth:`protected`}),capturePreset:E(LN.extend({fields:C(PN).optional()}),IN,{auth:`protected`})},customize:tbe,vocabulary:{notOperatorFacing:`the per-fan presets — authored in the Customize presets editor, applied through the actions the exports list`}},zN=x({flags:d(m(),u()),deviceType:m().nullable(),model:m().nullable(),channelCount:p().nullable().meta(k(`count`)),lastProbedAt:p(),lastFetchedAt:p()}),BN={name:`feature-probe`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},events:{onProbeChanged:{data:x({deviceId:p(),status:zN}),notOperatorFacing:`the device’s capabilities were re-probed — plumbing, not a happening`}},status:{schema:zN,kind:`push`},runtimeState:zN,durability:`session`,history:`none`,vocabulary:{noun:I(`Feature probe`,`Rilevamento funzioni`),order:3120}},nbe=x({name:m(),path:m()}),rbe=x({path:m(),entries:C(nbe).readonly(),freeBytes:p(),totalBytes:p()}),VN={name:`filesystem-browse`,scope:`system`,mode:`singleton`,internal:!0,methods:{listAllowedRoots:E(v(),C(m()).readonly(),{auth:`admin`}),browse:E(x({path:m()}),rbe,{auth:`admin`}),createDir:E(x({path:m()}),x({path:m()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.INTERNAL}},HN=x({flooded:y(),lastChangedAt:p()}),UN={name:`flood`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor],methods:{},status:{schema:HN,kind:`push`},runtimeState:HN,durability:`restored`,history:{fields:{flooded:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:I(`Leak sensor`,`Sensore di allagamento`),order:5070,state:[{kind:`boolean`,field:`flooded`,label:I(`Leak`,`Perdita`),whenTrue:I(`When {device} detects a leak`,`Quando {device} rileva una perdita`),whenFalse:I(`When {device} is dry again`,`Quando {device} torna asciutto`),icon:`droplets`}]}},WN=x({detected:y(),lastChangedAt:p()}),GN={name:`gas`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor],methods:{},status:{schema:WN,kind:`push`},runtimeState:WN,durability:`restored`,history:{fields:{detected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:I(`Gas sensor`,`Sensore di gas`),order:5080,state:[{kind:`boolean`,field:`detected`,label:I(`Detected`,`Rilevato`),whenTrue:I(`When {device} detects gas`,`Quando {device} rileva gas`),whenFalse:I(`When the gas clears on {device}`,`Quando il gas su {device} rientra`),icon:`flame`}]}},KN=x({active:y().meta({label:`Active`}),lastChangedAt:p()}),qN={name:`group-active`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Cover,j.Valve,j.Lock,j.MediaPlayer,j.Climate],methods:{},status:{schema:KN,kind:`push`},runtimeState:KN,durability:`session`,history:`none`,vocabulary:{noun:I(`Group state`,`Stato del gruppo`),order:5090}},JN=x({deviceId:p().int().nonnegative(),cap:m().min(1),method:m().min(1),ok:y(),error:m().optional(),at:p()}),YN=x({results:C(JN)}),XN={name:`group-commands`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Switch,j.Light,j.Fan,j.Cover,j.Valve,j.Lock,j.MediaPlayer,j.Climate],methods:{},status:{schema:YN,kind:`push`},runtimeState:YN,durability:`session`,history:`none`,vocabulary:{noun:I(`Group command`,`Comando di gruppo`),order:5100}},ZN=x({included:p().int().nonnegative().meta(k(`count`,{precision:0,label:`Reporting`})),excluded:p().int().nonnegative().meta(k(`count`,{precision:0,label:`Excluded`})),total:p().int().nonnegative().meta(k(`count`,{precision:0,label:`Members`}))}),QN={name:`group-status`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor,j.Switch,j.Light,j.Fan,j.Cover,j.Valve,j.Lock,j.MediaPlayer,j.Climate],methods:{},status:{schema:ZN,kind:`push`},runtimeState:ZN,durability:`session`,history:`none`,vocabulary:{noun:I(`Group`,`Gruppo`),order:5110,state:[{kind:`numeric`,field:`included`,quantity:I(`the members reporting`,`i membri che rispondono`),label:I(`Reporting`,`Rispondono`),icon:`users`},{kind:`numeric`,field:`excluded`,quantity:I(`the members left out`,`i membri esclusi`),label:I(`Excluded`,`Esclusi`),icon:`users`},{kind:`numeric`,field:`total`,quantity:I(`the member count`,`il numero di membri`),label:I(`Members`,`Membri`),icon:`sigma`}]}},$N=p().int().nonnegative(),eP=m().min(1),tP=m().min(1),nP=p().finite(),rP={key:`circuitId`,label:I(`Circuit`,`Circuito`),offer:{kind:`dynamic`,from:`status`,cap:`heat-pump-status`,field:`circuits`,valueKey:`id`,labelKey:`label`,where:{key:`kind`,equals:`heating`}}},iP={...rP,label:I(`Hot water circuit`,`Circuito acqua calda`),offer:{...rP.offer,where:{key:`kind`,equals:`dhw`}}},aP={key:`mode`,label:I(`Mode`,`Modalità`),offer:{kind:`text`}},ibe={key:`level`,label:I(`Level`,`Livello`),offer:{kind:`text`}},oP={key:`temp`,label:I(`Temperature`,`Temperatura`),offer:{kind:`number`,step:.5,unit:`°C`}},abe={key:`minutes`,label:I(`Minutes`,`Minuti`),offer:{kind:`number`,min:1,step:1,unit:`min`}},sP={name:`heat-pump-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.HeatPump],methods:{setSilentMode:E(x({deviceId:$N,mode:tP}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.silent`,label:I(`Set silent mode`,`Imposta la modalità silenziosa`),phrase:I(`Set silent mode of {device} to {mode}`,`Imposta la modalità silenziosa di {device} su {mode}`),icon:`volume-x`,openArgs:[{key:`mode`,label:I(`Silent mode`,`Modalità silenziosa`),offer:{kind:`enum`,values:[{value:`off`,label:I(`Off`,`Off`)},{value:`auto`,label:I(`Auto`,`Auto`)},{value:`on`,label:I(`On`,`On`)}]}}]}]}),setAwayMode:E(x({deviceId:$N,mode:tP}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.away`,label:I(`Set away mode`,`Imposta la modalità assente`),phrase:I(`Set away mode of {device} to {mode}`,`Imposta la modalità assente di {device} su {mode}`),icon:`plane`,openArgs:[{key:`mode`,label:I(`Away mode`,`Modalità assente`),offer:{kind:`enum`,values:[{value:`off`,label:I(`Off`,`Off`)},{value:`on`,label:I(`On`,`On`)}]}}]}]}),setAdditionalHeaterMode:E(x({deviceId:$N,mode:tP}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.additionalHeater`,label:I(`Set additional heater`,`Imposta il riscaldatore aggiuntivo`),phrase:I(`Set the additional heater of {device} to {mode}`,`Imposta il riscaldatore aggiuntivo di {device} su {mode}`),icon:`flame`,openArgs:[{key:`mode`,label:I(`Additional heater`,`Riscaldatore aggiuntivo`),offer:{kind:`enum`,values:[{value:`off`,label:I(`Off`,`Off`)},{value:`manual`,label:I(`Manual`,`Manuale`)},{value:`auto`,label:I(`Auto`,`Auto`)}]}}]}]}),setHolidayMode:E(x({deviceId:$N,mode:tP}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.holiday`,label:I(`Set holiday mode`,`Imposta la modalità vacanza`),phrase:I(`Set holiday mode of {device} to {mode}`,`Imposta la modalità vacanza di {device} su {mode}`),icon:`tree-palm`,openArgs:[{key:`mode`,label:I(`Holiday programme`,`Programma vacanza`),offer:{kind:`enum`,values:[{value:`off`,label:I(`Off`,`Off`)},{value:`hm1`,label:I(`Programme 1`,`Programma 1`)},{value:`hm2`,label:I(`Programme 2`,`Programma 2`)},{value:`hm3`,label:I(`Programme 3`,`Programma 3`)},{value:`hm4`,label:I(`Programme 4`,`Programma 4`)},{value:`hm5`,label:I(`Programme 5`,`Programma 5`)},{value:`hm6`,label:I(`Programme 6`,`Programma 6`)},{value:`hm7`,label:I(`Programme 7`,`Programma 7`)},{value:`hm8`,label:I(`Programme 8`,`Programma 8`)}]}}]}]}),setCircuitOperationMode:E(x({deviceId:$N,circuitId:eP,mode:tP}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitOperationMode`,label:I(`Set circuit operation mode`,`Imposta la modalità del circuito`),phrase:I(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`thermometer`,openArgs:[rP,aP]}]}),setCircuitHeatCoolMode:E(x({deviceId:$N,circuitId:eP,mode:tP}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitHeatCoolMode`,label:I(`Set circuit heat / cool`,`Imposta caldo / freddo del circuito`),phrase:I(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`sun-snow`,openArgs:[rP,aP]}]}),setCircuitSummerWinter:E(x({deviceId:$N,circuitId:eP,mode:tP}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitSummerWinter`,label:I(`Set circuit summer / winter`,`Imposta estate / inverno del circuito`),phrase:I(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`sun`,openArgs:[rP,aP]}]}),setCircuitComfortSetpoint:E(x({deviceId:$N,circuitId:eP,temp:nP}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitComfortSetpoint`,label:I(`Set comfort temperature`,`Imposta la temperatura comfort`),phrase:I(`Set the comfort temperature of {circuitId} on {device} to {temp}`,`Imposta la temperatura comfort di {circuitId} su {device} a {temp}`),icon:`thermometer-sun`,openArgs:[rP,oP]}]}),setCircuitEcoSetpoint:E(x({deviceId:$N,circuitId:eP,temp:nP}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitEcoSetpoint`,label:I(`Set eco temperature`,`Imposta la temperatura eco`),phrase:I(`Set the eco temperature of {circuitId} on {device} to {temp}`,`Imposta la temperatura eco di {circuitId} su {device} a {temp}`),icon:`leaf`,openArgs:[rP,oP]}]}),setCircuitMaxFlowTemp:E(x({deviceId:$N,circuitId:eP,temp:nP}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitMaxFlowTemp`,label:I(`Set maximum flow temperature`,`Imposta la temperatura massima di mandata`),phrase:I(`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:[rP,oP]}]}),setDhwOperationMode:E(x({deviceId:$N,circuitId:eP,mode:tP}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwOperationMode`,label:I(`Set hot water mode`,`Imposta la modalità acqua calda`),phrase:I(`Set hot water {circuitId} of {device} to {mode}`,`Imposta l'acqua calda {circuitId} di {device} su {mode}`),icon:`shower-head`,openArgs:[iP,aP]}]}),setDhwTemperatureLevel:E(x({deviceId:$N,circuitId:eP,level:tP}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwTemperatureLevel`,label:I(`Set hot water level`,`Imposta il livello acqua calda`),phrase:I(`Set hot water {circuitId} of {device} to level {level}`,`Imposta l'acqua calda {circuitId} di {device} al livello {level}`),icon:`droplet`,openArgs:[iP,ibe]}]}),setDhwChargeDuration:E(x({deviceId:$N,circuitId:eP,minutes:p().int().positive()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwChargeDuration`,label:I(`Set hot water charge duration`,`Imposta la durata della carica acqua calda`),phrase:I(`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:[iP,abe]}]}),startExtraHotWater:E(x({deviceId:$N,circuitId:eP}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.extraHotWater`,label:I(`Start extra hot water`,`Avvia acqua calda extra`),phrase:I(`Start an extra hot water charge of {circuitId} on {device}`,`Avvia una carica extra di acqua calda {circuitId} su {device}`),icon:`droplets`,openArgs:[iP]}]})},vocabulary:{noun:I(`Heat pump settings`,`Impostazioni pompa di calore`),order:4010}},cP=[`heating`,`dhw`,`cooling`,`solar`],lP=S(cP),uP=x({value:m().nullable(),allowed:C(m())}),dP=x({value:p().nullable(),min:p().nullable(),max:p().nullable(),step:p().nullable()}),fP=x({id:m().min(1),kind:lP,label:m(),icon:Vu,currentTemp:p().nullable().meta(k(`temperature`)),targetTemp:p().nullable().meta(k(`temperature`)),mode:m().nullable(),active:y().nullable(),operationMode:uP.nullable(),heatCoolMode:uP.nullable(),summerWinter:uP.nullable(),comfortSetpoint:dP.nullable(),ecoSetpoint:dP.nullable(),maxFlowTemp:dP.nullable(),temperatureLevel:uP.nullable(),chargeDuration:dP.nullable(),extraHotWater:y().nullable()}),pP=x({silent:uP.nullable(),away:uP.nullable(),additionalHeater:uP.nullable(),holiday:uP.nullable()}),mP=x({thermalW:p().nullable().meta(k(`power`)),electricalW:p().nullable().meta(k(`power`)),compressorPct:p().nullable().meta(k(`percentage`))}),hP=x({supply:p().nullable().meta(k(`temperature`)),return:p().nullable().meta(k(`temperature`)),outdoor:p().nullable().meta(k(`temperature`))}),gP=x({thermalKwh:p().nullable().meta(k(`energy`)),electricalKwh:p().nullable().meta(k(`energy`))}),_P=x({circuits:C(fP),system:pP,power:mP,temperatures:hP,energy:gP,waterPressureBar:p().nullable(),starts:p().nullable(),lastFetchedAt:p()});function vP(e){let{thermalW:t,electricalW:n}=e;return t===null||n===null||n<=0?null:t/n}var yP={name:`heat-pump-status`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.HeatPump],methods:{},status:{schema:_P,kind:`push`},runtimeState:_P,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:I(`Heat pump`,`Pompa di calore`),order:4e3}},bP=x({position:p().min(0).max(100).nullable().meta(k(`percentage`)),lastFetchedAt:p()}),xP={name:`heating-valve`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Climate],methods:{},status:{schema:bP,kind:`push`},runtimeState:bP,durability:`session`,history:{fields:{position:{kind:`gauge`,unit:`%`,deadband:1}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`Radiator valve`,`Valvola termostatica`),order:1110,state:[{kind:`numeric`,field:`position`,quantity:I(`the valve opening`,`l’apertura della valvola`),label:I(`Valve opening`,`Apertura della valvola`),unit:`%`,icon:`heater`}]}},SP=S([`s`,`min`]),obe=S([`switch`,`pet-fountain`]),CP={actuator:`switch`,maxSeconds:10800,unit:`min`,quickRunDefault:30},wP={actuator:`pet-fountain`,maxSeconds:300,unit:`s`,quickRunDefault:60},TP=[j.Switch,j.PetFountain],EP={[j.Switch]:[N.SwitchHeater]};function DP(e,t){return e===j.PetFountain?wP:e===j.Switch&&t===N.SwitchHeater?CP:null}var sbe=1e3,cbe=6e4;function OP(e,t,n){let r=e-t;return r<=0?0:Math.max(1,Math.ceil(r/(n===`min`?cbe:sbe)))}function lbe(e,t){return t===`min`?e*60:e}function kP(e){return e.unit===`min`?Math.floor(e.maxSeconds/60):e.maxSeconds}var AP=x({duration:p().positive().finite(),unit:SP});function jP(e,t){let n=kP(e);return{duration:Math.min((t!==null&&Number.isFinite(t)&&t>0?t:null)??e.quickRunDefault,n),unit:e.unit}}var MP=S([`unsupported-device`,`over-max`,`command-failed`]),NP=a(`ok`,[x({ok:s(!0),activeUntil:p()}),x({ok:s(!1),reason:MP,maxSeconds:p().nullable()})]),PP=x({activeUntil:p().nullable(),requestedBy:m().nullable(),quickRun:AP.nullable(),lastFetchedAt:p()}),FP=x({unit:SP,maxDuration:p(),defaultDuration:p()}),IP=x({quickRunDuration:p().positive().finite().nullable().optional()}),LP={name:`timed-run`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:TP,deviceRoles:EP,deviceConfig:{ui:{kind:`derived-form`,builderId:`timed-run`,tab:`general`}},methods:{getOptions:E(x({deviceId:p().int()}),FP),setSettings:E(x({deviceId:p().int(),settings:IP}),v(),{kind:`mutation`,auth:`admin`}),runFor:E(x({deviceId:p().int(),duration:p().positive().finite(),unit:SP}),NP,{kind:`mutation`,auth:`protected`,actions:[{id:`timedRun.runForMinutes`,label:I(`Run for minutes`,`Accendi per alcuni minuti`),phrase:I(`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:I(`Minutes`,`Minuti`),offer:{kind:`number`,min:1,step:1,unit:`min`}}]},{id:`timedRun.runForSeconds`,label:I(`Run for seconds`,`Accendi per alcuni secondi`),phrase:I(`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:I(`Seconds`,`Secondi`),offer:{kind:`number`,min:1,step:1,unit:`s`}}]}]}),cancel:E(x({deviceId:p().int()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`timedRun.cancel`,label:I(`Cancel the timer`,`Annulla il timer`),phrase:I(`Cancel the pending switch-off of {device}`,`Annulla lo spegnimento programmato di {device}`),icon:`timer-off`}]})},status:{schema:PP,kind:`push`},runtimeState:PP,durability:`session`,history:`none`,vocabulary:{noun:I(`Timed run`,`Esecuzione a tempo`),order:2150}},RP=[`on`,`off`,`running`,`idle`,`standby`,`alert`,`offline`,`unknown`],zP=[`success`,`warning`,`danger`,`primary`,`info`,`muted`],BP=[`none`,`pulse`,`spin`,`glow`,`halo`,`wave`,`rise`,`fall`,`tumble`,`equalizer`,`blink`,`breathe`],VP=[`plain`,`heat-rise`,`cool-fall`,`glow`,`water`,`drum`,`sky`,`mist`,`alert-wash`],HP=S(RP),UP=S(zP),ube=S(BP),WP=x({icon:Vu,tone:UP,background:S(VP),animation:ube});function GP(e){let t=xE[e];return t===void 0?null:`cap:${e}.${t.field}`}function KP(e){return e.enabledCaps.flatMap(e=>{let t=GP(e),n=xE[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 qP=x({en:m(),it:m()}),JP={en:`—`,it:`—`};function YP(e){return e.en===JP.en&&e.it===JP.it}var XP=[`temperature`,`humidity`,`power`,`contact`,`text`],ZP=[`hot`,`mild`,`cold`],QP=[`updated`,`changed`],$P=x({value:p(),quantity:Qs}),eF=x({quantity:S(XP),reading:$P.nullable(),icon:Vu.nullable(),value:qP,unit:m().nullable(),band:S(ZP).nullable(),level:p().min(0).max(1).nullable(),word:qP,tone:S(zP),since:p().nullable(),sinceKind:S(QP),historyKey:m().nullable()}),dbe=3e3,tF=e=>I(e,e),nF=e=>Math.min(1,Math.max(0,e)),fbe=(e,t)=>String(Number(e.toFixed(t)));function rF(e){return e<12?`cold`:e>28?`hot`:`mild`}var pbe={hot:I(`Hot`,`Caldo`),mild:I(`Normal`,`Normale`),cold:I(`Cold`,`Freddo`)},mbe={hot:`warning`,mild:`muted`,cold:`info`};function iF(e,t){let n=rF(e);return{quantity:`temperature`,reading:{value:e,quantity:`temperature`},icon:`thermometer`,value:tF(fbe(e,1)),unit:`°C`,band:n,level:null,word:pbe[n],tone:mbe[n],since:t,sinceKind:`updated`,historyKey:GP(`temperature-sensor`)}}function aF(e,t){let n=e<30,r=e>70;return{quantity:`humidity`,reading:{value:e,quantity:`humidity`},icon:`droplets`,value:tF(String(Math.round(e))),unit:`%`,band:null,level:nF(e/100),word:n?I(`Dry`,`Secco`):r?I(`Humid`,`Umido`):I(`Normal`,`Normale`),tone:n||r?`warning`:`info`,since:t,sinceKind:`updated`,historyKey:GP(`humidity-sensor`)}}function oF(e,t){let n=e>0;return{quantity:`power`,reading:{value:e,quantity:`power`},icon:`zap`,value:tF(String(Math.round(e))),unit:`W`,band:null,level:nF(e/dbe),word:n?I(`Active`,`Attivo`):I(`Idle`,`Inattivo`),tone:n?`primary`:`muted`,since:t,sinceKind:`updated`,historyKey:GP(`power-meter`)}}function sF(e,t){return{quantity:`contact`,reading:null,icon:e?`door-open`:`door-closed`,value:e?I(`Open`,`Aperto`):I(`Closed`,`Chiuso`),unit:null,band:null,level:+!!e,word:e?I(`Open`,`Aperto`):I(`Closed`,`Chiuso`),tone:e?`warning`:`success`,since:t,sinceKind:`changed`,historyKey:null}}function cF(e,t){return{quantity:`text`,reading:null,icon:null,value:tF(e),unit:null,band:null,level:null,word:I(`Changed`,`Cambiato`),tone:`muted`,since:t,sinceKind:`updated`,historyKey:null}}var hbe={temperature:{icon:`thermometer`,unit:`°C`,sinceKind:`updated`,historyKey:GP(`temperature-sensor`)},humidity:{icon:`droplets`,unit:`%`,sinceKind:`updated`,historyKey:GP(`humidity-sensor`)},power:{icon:`zap`,unit:`W`,sinceKind:`updated`,historyKey:GP(`power-meter`)},contact:{icon:null,unit:null,sinceKind:`changed`,historyKey:null},text:{icon:null,unit:null,sinceKind:`updated`,historyKey:null}};function lF(e){let t=hbe[e];return{quantity:e,reading:null,icon:t.icon,value:JP,unit:t.unit,band:null,level:null,word:JP,tone:`muted`,since:null,sinceKind:t.sinceKind,historyKey:t.historyKey}}var gbe={power:new Set([`energy-sensor`,`voltage-sensor`,`current-sensor`])};function uF(e,t){return t===null?!0:!(gbe[e.quantity]?.has(t)??!1)}var dF=`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(`.`),_be=S(dF),fF=[`cool`,`heat`,`dry`,`fan`,`auto`,`playing`,`paused`,`open`,`closed`],pF=x({id:_be,mode:S(fF).nullable(),level:p().min(0).max(1).nullable()}),mF={[j.Camera]:`camera`,[j.Light]:`light`,[j.Siren]:`siren`,[j.Switch]:`plug`,[j.Sensor]:`sensor-sparkline`,[j.Climate]:`thermostat`,[j.Button]:`button`,[j.EventEmitter]:`event-stream`,[j.Update]:`update`,[j.Generic]:`generic`,[j.Notifier]:`event-stream`,[j.Script]:`event-stream`,[j.Automation]:`event-stream`,[j.Lock]:`lock`,[j.Cover]:`cover`,[j.Valve]:`control-dial`,[j.Humidifier]:`control-dial`,[j.WaterHeater]:`heater`,[j.HeatPump]:`heat-pump`,[j.EnergySystem]:`generic`,[j.Fan]:`fan`,[j.MediaPlayer]:`tv`,[j.AlarmPanel]:`alarm`,[j.Control]:`control-dial`,[j.Presence]:`presence`,[j.Weather]:`weather`,[j.WeatherStation]:`weather`,[j.Vacuum]:`vacuum`,[j.LawnMower]:`lawn-mower`,[j.Container]:`generic`,[j.Image]:`camera`,[j.PetFeeder]:`pet-feeder`,[j.PetFountain]:`pet-fountain`,[j.Dishwasher]:`dishwasher`,[j.Washer]:`washer`,[j.Dryer]:`dryer`,[j.Gateway]:`gateway`},hF={[N.Siren]:`siren`,[N.Floodlight]:`light`,[N.Spotlight]:`light`,[N.PirSensor]:`presence`,[N.Chime]:`speaker`,[N.Autotrack]:`inherit`,[N.Nightvision]:`inherit`,[N.PrivacyMask]:`inherit`,[N.Doorbell]:`inherit`,[N.CoverBlind]:`inherit`,[N.CoverShutter]:`inherit`,[N.CoverAwning]:`inherit`,[N.CoverCurtain]:`inherit`,[N.CoverGarage]:`inherit`,[N.CoverGate]:`inherit`,[N.CoverDoor]:`inherit`,[N.CoverWindow]:`inherit`,[N.BinaryHelper]:`inherit`,[N.Outlet]:`plug`,[N.SwitchHeater]:`heater`,[N.SwitchFan]:`fan`,[N.SwitchLight]:`light`,[N.ClimateAc]:`ac`,[N.ClimateThermostat]:`inherit`,[N.ClimateFloor]:`inherit`,[N.ClimateRadiator]:`inherit`,[N.ClimateHeater]:`inherit`,[N.ClimateHeatPumpCircuit]:`inherit`,[N.MotionSensor]:`presence`,[N.ContactSensor]:`contact`,[N.LeakSensor]:`inherit`,[N.SmokeSensor]:`alarm`,[N.COSensor]:`alarm`,[N.GasSensor]:`alarm`,[N.TamperSensor]:`inherit`,[N.VibrationSensor]:`inherit`,[N.ConnectivitySensor]:`inherit`,[N.SoundSensor]:`inherit`,[N.BinarySensor]:`inherit`,[N.TemperatureSensor]:`sensor-sparkline`,[N.HumiditySensor]:`sensor-sparkline`,[N.AmbientLightSensor]:`inherit`,[N.PressureSensor]:`weather`,[N.WindSensor]:`weather`,[N.RainSensor]:`weather`,[N.UvSensor]:`weather`,[N.SolarRadiationSensor]:`weather`,[N.SoilMoistureSensor]:`inherit`,[N.PowerSensor]:`plug`,[N.EnergySensor]:`plug`,[N.VoltageSensor]:`plug`,[N.CurrentSensor]:`plug`,[N.AirQualitySensor]:`inherit`,[N.BatterySensor]:`inherit`,[N.NumericSensor]:`inherit`,[N.EnumSensor]:`inherit`,[N.DateTimeSensor]:`inherit`,[N.GenericSensor]:`inherit`,[N.NumericControl]:`control-dial`,[N.SelectControl]:`control-dial`,[N.TextControl]:`inherit`,[N.DateTimeControl]:`inherit`,[N.MobilePushNotifier]:`inherit`,[N.MessagingNotifier]:`inherit`,[N.EmailNotifier]:`inherit`,[N.GenericNotifier]:`inherit`,[N.IrTransmitter]:`inherit`};function vbe(e){return Object.values(j).includes(e)}function ybe(e){return Object.values(N).includes(e)}function gF(e,t){let n=e!==null&&ybe(e)?hF[e]:void 0;return n!==void 0&&n!==`inherit`?n:vbe(t)?mF[t]:`generic`}var _F=`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(`.`),vF=S(_F),yF={progress:I(`Progress`,`Avanzamento`),"run-for":I(`Run for`,`Avvia per`),cycle:I(`Cycle`,`Ciclo`),program:I(`Program`,`Programma`),"appliance-power":I(`Appliance`,`Elettrodomestico`),"now-playing":I(`Now playing`,`In riproduzione`),playback:I(`Playback`,`Riproduzione`),volume:I(`Volume`,`Volume`),source:I(`Source`,`Sorgente`),contact:I(`Door`,`Porta`),"motion-trigger":I(`Motion`,`Movimento`),lock:I(`Lock`,`Serratura`),alarm:I(`Alarm`,`Allarme`),fan:I(`Fan`,`Ventola`),vacuum:I(`Cleaning`,`Pulizia`),"vacuum-suction":I(`Suction`,`Aspirazione`),mower:I(`Mowing`,`Taglio`),feeder:I(`Feed now`,`Eroga ora`),fountain:I(`Pump`,`Pompa`),"pump-cycle":I(`Pump cycle`,`Ciclo pompa`),automation:I(`Automation`,`Automazione`),script:I(`Script`,`Script`),"do-not-disturb":I(`Do not disturb`,`Non disturbare`),brightness:I(`Brightness`,`Luminosità`),color:I(`Colour`,`Colore`),cover:I(`Position`,`Posizione`),valve:I(`Valve`,`Valvola`),humidifier:I(`Humidifier`,`Umidificatore`),update:I(`Firmware`,`Firmware`),button:I(`Action`,`Azione`),"climate-mode":I(`Mode`,`Modalità`),"climate-fan":I(`Fan`,`Ventola`),setpoint:I(`Setpoint`,`Temperatura`),channel:I(`Channel`,`Canale`),control:I(`Control`,`Controllo`),circuit:I(`Circuit`,`Circuito`),"heat-pump-power":I(`Power`,`Potenza`),"system-mode":I(`Mode`,`Modalità`)},bF=_(()=>l([m(),p(),y(),d(m(),bF)])),bbe=d(m(),bF);function xF(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]:xF(o,i,n)}}function SF(e,t,n){return xF(e,t.split(`.`),n)}var CF=x({cap:m(),method:m(),args:bbe}),xbe=S([`off-while-running`,`unlock`,`install`,`press`]),wF=x({id:m(),label:qP,icon:Vu,call:CF,emphasis:S([`primary`,`normal`]),confirm:xbe.nullable()}),TF=a(`kind`,[x({kind:s(`action`),action:wF}),x({kind:s(`toggle`),id:m(),label:qP,on:y().nullable(),turnOn:wF,turnOff:wF}),x({kind:s(`slider`),id:m(),label:qP,value:p().nullable(),min:p(),max:p(),step:p(),unit:m(),call:CF,valueArg:m()}),x({kind:s(`picker`),id:m(),label:qP,current:m().nullable(),options:C(m()),optionLabels:d(m(),qP).optional(),call:CF,valueArg:m()}),x({kind:s(`number`),id:m(),label:qP,value:p().nullable(),step:p().nullable(),unit:m(),call:CF,valueArg:m()}),x({kind:s(`text`),id:m(),label:qP,value:m().nullable(),call:CF,valueArg:m()})]),Sbe=x({icon:Vu.nullable(),text:qP,tone:UP}),Cbe=new Set([`cover`,`valve`,`lock`,`vacuum`,`playback`,`brightness`]),wbe=x({id:vF,placement:S([`row`,`scene`]).optional(),label:qP.optional(),group:qP.optional(),pills:C(Sbe).optional(),icon:Vu,status:qP.nullable(),controls:C(TF),progress:p().min(0).max(1).nullable().optional()}),EF=x({label:qP,value:l([p(),m()]),unit:m().nullable()}),Tbe=x({id:S([`battery`,`network-link`,`integration`]),icon:Vu,tone:UP,value:p().nullable(),label:qP}),DF=`remote.open`,Ebe=x({commands:p().int().nullable(),open:wF.optional()}),Dbe=x({items:C(x({key:m(),label:m(),level:p().nullable(),needsAttention:y()})),attention:p().int()}),Obe=a(`kind`,[x({kind:s(`power`),watts:p(),detail:C(EF)}),x({kind:s(`running`),running:y().nullable(),since:p().nullable(),phase:m().nullable(),detail:C(EF)})]),kbe=x({source:S([`switch`,`media-player`,`climate-control`]),on:y().nullable(),assumed:y(),turnOn:wF,turnOff:wF}),Abe=x({activeUntil:p().nullable(),quickRun:AP,run:wF,cancel:wF,remaining:p().nullable()}),jbe=x({on:y().nullable(),confirmOffWhileRunning:y(),running:y().nullable(),powerOn:wF,powerOff:wF,restart:wF}),OF=x({token:S(VP),animation:S(BP)}),kF=x({id:S([`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:Vu.nullable(),text:qP,tone:UP}),AF=x({label:qP,value:qP,tone:UP.optional(),at:p().optional()}),Mbe=x({left:C(AF).max(2),right:C(AF).max(2)}),Nbe=a(`kind`,[x({kind:s(`artwork`),url:m(),fallback:OF}),x({kind:s(`state`),...OF.shape})]),Pbe=x({partId:m(),cap:m()}),Fbe=x({deviceId:p().int(),type:m(),role:m().nullable(),name:m(),state:HP,stateAssumed:y(),look:WP,background:Nbe,scene:pF,facts:C(kF),sideTiles:Mbe,title:qP,caption:qP.optional(),badges:C(Tbe),remote:Ebe.nullable(),historyLabel:qP,consumables:Dbe.nullable(),consumption:Obe.nullable(),ownPower:kbe.nullable(),timedRun:Abe.nullable(),powerSupply:jbe.nullable(),rows:C(wbe),measurement:eF.optional(),gated:C(m()),provenance:C(Pbe)}),Ibe=x({id:S([`timed-run.run`,`timed-run.cancel`]),duration:p(),unit:S([`min`,`s`])}),jF=x({deviceId:p().int(),name:m(),type:m(),state:HP,stateAssumed:y(),look:WP,scene:pF,statusLine:C(qP),primary:TF.nullable(),timedRun:Ibe.nullable(),extras:C(TF).max(2).optional(),trailing:kF.nullable(),measurement:eF.optional()}),MF=[`temperature`,`humidity`,`pressure`,`illuminance`,`reading`,`air-quality`,`valve`],Lbe=[`power`,`battery`,`consumables`],Rbe=new Set(MF);function zbe(e){for(let t of Lbe){let n=e.facts.find(e=>e.id===t);if(n!==void 0)return n}return e.facts.find(t=>Rbe.has(t.id)&&t.text.en===e.title.en)??null}var Bbe={[j.Climate]:`climate.mode`};function Vbe(e){let t=Bbe[e.type];if(t!==void 0){let n=PF(e,t);if(n!==null)return n}let n=e.ownPower;if(n!==null)return e.gated.includes(`own-power`)?null:{kind:`toggle`,id:`own-power`,label:n.turnOn.label,on:n.on,turnOn:n.turnOn,turnOff:n.turnOff};for(let t of e.rows){let n=t.controls[0];if(n!==void 0)return e.gated.includes(t.id)?null:n}return null}var Hbe={[j.Climate]:[`climate.target`],[j.Vacuum]:[`vacuum.base`],[j.LawnMower]:[`mower.dock`],[j.MediaPlayer]:[`volume.level`,DF],[j.Automation]:[`automation.enabled`]},NF=e=>e.kind===`action`?e.action.id:e.id;function PF(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=>NF(e)===t);if(r!==void 0)return r}return null}function Ube(e,t){let n=Hbe[e.type]??[],r=t===null?null:NF(t);return n.filter(e=>e!==r).flatMap(t=>{let n=PF(e,t);return n===null?[]:[n]}).slice(0,2)}function Wbe(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 Gbe(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 Kbe(e){let t=zbe(e),n=Vbe(e);return{deviceId:e.deviceId,name:e.name,type:e.type,state:e.state,stateAssumed:e.stateAssumed,look:e.look,scene:e.scene,statusLine:Wbe(e,t),primary:n,timedRun:Gbe(e),extras:Ube(e,n),trailing:t,...e.measurement===void 0?{}:{measurement:e.measurement}}}var qbe=x({deviceId:p().int().nonnegative(),canActuate:y().optional()}),Jbe=x({deviceIds:C(p().int().nonnegative()).max(500),canActuate:y().optional()}),FF=x({type:m(),rows:C(vF)}),IF={name:`hero-layout`,scope:`system`,mode:`singleton`,methods:{getHeroModel:E(qbe,Fbe.nullable(),{auth:`protected`,role:`viewer`}),getRowModels:E(Jbe,C(jF.nullable()),{auth:`protected`,role:`viewer`}),getLayout:E(x({deviceType:m(),role:m().nullable().optional()}),FF,{auth:`protected`,role:`viewer`})},vocabulary:{notOperatorFacing:`the device hero model — read-only data the UI draws, never actuated`}},LF=x({on:y(),currentHumidity:p().min(0).max(100).nullable().meta(k(`humidity`)),targetHumidity:p().min(0).max(100).nullable().meta(k(`humidity`)),mode:m().nullable(),availableModes:C(m()),action:m().nullable(),minHumidity:p().nullable().meta(k(`humidity`)),maxHumidity:p().nullable().meta(k(`humidity`)),lastChangedAt:p()}),RF={name:`humidifier`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Humidifier],power:{kind:`field`,field:`on`,set:`setOn`},methods:{setOn:E(x({deviceId:p().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.on`,label:I(`Humidifier on`,`Umidificatore acceso`),phrase:I(`Turn on {device}`,`Accendi {device}`),icon:`power`,effect:{field:`on`,value:!0},args:{on:!0}},{id:`humidifier.off`,label:I(`Humidifier off`,`Umidificatore spento`),phrase:I(`Turn off {device}`,`Spegni {device}`),icon:`power-off`,effect:{field:`on`,value:!1},args:{on:!1}}]}),setTargetHumidity:E(x({deviceId:p().int().nonnegative(),humidity:p().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.target`,label:I(`Set humidity`,`Imposta l’umidità`),phrase:I(`Set {device} to {humidity} humidity`,`Imposta {device} al {humidity} di umidità`),icon:`droplets`,effect:{field:`targetHumidity`,fromArg:`humidity`},openArgs:[{key:`humidity`,label:I(`Humidity`,`Umidità`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setMode:E(x({deviceId:p().int().nonnegative(),mode:m().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.mode`,label:I(`Set mode`,`Imposta la modalità`),phrase:I(`Set {device} to {mode}`,`Imposta {device} su {mode}`),icon:`list`,effect:{field:`mode`,fromArg:`mode`},openArgs:[{key:`mode`,label:I(`Mode`,`Modalità`),offer:{kind:`dynamic`,from:`status`,field:`availableModes`}}]}]})},status:{schema:LF,kind:`push`},runtimeState:LF,durability:`session`,history:{fields:{currentHumidity:{kind:`gauge`,unit:`%`,deadband:.5},on:{kind:`boolean`}}},vocabulary:{noun:I(`Humidifier`,`Umidificatore`),order:1090,state:[{kind:`boolean`,field:`on`,label:I(`On`,`Acceso`),whenTrue:I(`When {device} turns on`,`Quando {device} si accende`),whenFalse:I(`When {device} turns off`,`Quando {device} si spegne`),icon:`power`},{kind:`numeric`,field:`currentHumidity`,quantity:I(`the humidity`,`l’umidità`),label:I(`Humidity`,`Umidità`),unit:`%`,icon:`droplets`}]}},zF=x({humidity:p().min(0).max(100).nullable().meta(k(`humidity`,{precision:0,label:`Humidity`})),lastFetchedAt:p()}),BF={name:`humidity-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor,j.Climate],methods:{},status:{schema:zF,kind:`push`},runtimeState:zF,durability:`restored`,history:{primary:`humidity`,priority:90,fields:{humidity:{kind:`gauge`,unit:`%`,deadband:.5}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`Humidity`,`Umidità`),order:5120,state:[{kind:`numeric`,field:`humidity`,quantity:I(`the humidity`,`l’umidità`),label:I(`Humidity`,`Umidità`),unit:`%`,icon:`droplets`}]}},VF=x({url:m().nullable(),lastUpdated:p().nullable().meta(k(`none`))}),HF={name:`image`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Image],methods:{},status:{schema:VF,kind:`push`},runtimeState:VF,durability:`session`,history:`none`,vocabulary:{noun:I(`Image`,`Immagine`),order:3130}},UF=S([`0`,`90`,`180`,`270`]),WF=S([`auto`,`manual`]),GF=S([`auto`,`manual`]),KF=S([`off`,`blc`,`wdr`,`hlc`]),qF=x({min:p(),max:p(),step:p()}),JF=x({brightness:p().optional().meta(k(`none`)),contrast:p().optional().meta(k(`none`)),saturation:p().optional().meta(k(`none`)),sharpness:p().optional().meta(k(`none`)),mirror:y().optional(),flip:y().optional(),rotate:UF.optional(),whiteBalance:WF.optional(),warmth:p().optional().meta(k(`none`)),exposureMode:GF.optional(),backlightMode:KF.optional(),lastFetchedAt:p()}),YF=x({supportsBrightness:y(),brightness:qF.optional(),supportsContrast:y(),contrast:qF.optional(),supportsSaturation:y(),saturation:qF.optional(),supportsSharpness:y(),sharpness:qF.optional(),supportsMirror:y(),supportsFlip:y(),rotateOptions:C(UF),whiteBalanceModes:C(WF),supportsWarmth:y(),warmth:qF.optional(),exposureModes:C(GF),backlightModes:C(KF)}),XF=x({brightness:p().optional(),contrast:p().optional(),saturation:p().optional(),sharpness:p().optional(),mirror:y().optional(),flip:y().optional(),rotate:UF.optional(),whiteBalance:WF.optional(),warmth:p().optional(),exposureMode:GF.optional(),backlightMode:KF.optional()}),ZF={name:`image-settings`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],deviceConfig:{ui:{kind:`derived-form`,builderId:`image-settings`,tab:`image`}},methods:{getOptions:E(x({deviceId:p()}),YF),setSettings:E(x({deviceId:p(),settings:XF}),v(),{kind:`mutation`,auth:`admin`})},status:{schema:JF,kind:`poll`},runtimeState:JF,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`Image settings`,`Impostazioni immagine`),order:3140}},QF=x({id:m(),addonId:m(),name:m(),enabled:y(),switchUnknown:s(!0).optional(),info:d(m(),u()).readonly(),originStableId:m().optional(),createdAt:p(),updatedAt:p(),processState:m()}),$F=x({id:m(),addonId:m(),name:m(),enabled:y(),switchUnknown:s(!0).optional(),info:d(m(),u()).readonly(),originStableId:m().optional(),createdAt:p(),updatedAt:p()}),eI=x({addonId:m(),name:m(),providerLabel:m().optional(),description:m(),iconUrl:m().nullable(),color:m(),instanceMode:m(),mode:S([`standalone`,`account`,`broker`]),discoveryMode:m(),kind:S([`device-adoption`,`device-provider`]),brokerKind:m().nullable(),supportsLocationImport:y(),canTest:y(),existingInstances:C(x({id:m(),name:m()})),canAdd:y()}),tI=S([`validated`,`rejected`,`inconclusive`,`unsupported`]),nI=x({success:y(),error:m().optional(),status:tI.optional(),testedBy:m().nullable().optional(),latencyMs:p().nonnegative().optional(),detail:m().optional()}),rI=x({id:m(),name:m().optional(),enabled:y().optional(),info:d(m(),u()).optional()}),iI=x({success:y(),deletedId:m()}),aI={name:`integrations`,scope:`system`,mode:`singleton`,methods:{list:E(v(),C(QF)),get:E(x({id:m()}),QF),getByAddonId:E(x({addonId:m()}),$F.nullable()),update:E(rI,$F,{kind:`mutation`,auth:`admin`}),delete:E(x({id:m()}),iI,{kind:`mutation`,auth:`admin`}),getAvailableTypes:E(v(),C(eI),{auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:O.ADDON_ADMIN}},Ybe=_e(),oI=m().min(1),sI=S([`single`,`multiple`]),cI=S([`devices`,`services`]),lI=x({id:m().min(1),label:m().min(1),functionCap:m().min(1),brokerKind:m().min(1).optional(),alsoServes:C(m().min(1)).optional(),iconUrl:m().min(1).optional(),iconMediaType:m().min(1).optional(),role:cI.optional(),canTest:y().optional(),signIn:x({basePath:m().min(1),methods:C(S([`device-code`,`proxy`])).optional()}).optional(),connectPath:m().min(1).optional(),disconnectPath:m().min(1).optional(),widgets:C(x({id:m().min(1),placement:S([`connection`,`model`])})).optional()}),uI=x({mode:S([`none`,`lan`,`account`]),scopedToInstance:y()}),dI=x({kind:m().min(1),field:m().min(1),to:x({cap:m().min(1),kind:m().min(1).optional()})}),fI=x({role:cI,discovery:uI.optional(),instanceMode:sI,kind:m(),canTest:y(),kinds:C(lI).min(1),allowRestoreId:y().optional(),mintsId:y().optional(),links:C(dI).optional(),userScoped:y().optional()}),pI=x({state:S([`ok`,`off`,`error`,`unknown`]),detail:m().optional(),label:m().optional()}),mI=x({id:oI,name:m(),configured:y(),enabled:y().optional(),kind:m().min(1),formValues:d(m(),u()),status:pI.optional(),lastCheckedAt:p().optional()}),hI=x({id:oI,name:m().min(1).optional(),values:d(m(),u())}),gI={name:`integration-instances`,scope:`system`,mode:`collection`,methods:{describe:E(v(),fI,{auth:`admin`}),instanceFormSchema:E(x({id:oI.nullable(),kind:m().min(1).optional(),mode:S([`standalone`,`account`,`broker`]).optional(),candidateStableId:m().min(1).optional()}),Ybe,{auth:`admin`}),listInstances:E(o({}),C(mI).readonly(),{auth:`protected`,caller:`scoped`}),getInstance:E(x({id:oI}),mI.nullable(),{auth:`protected`,caller:`scoped`}),createInstance:E(x({id:oI.optional(),name:m().min(1),kind:m().min(1).optional(),values:d(m(),u()).optional(),originStableId:m().min(1).optional(),seed:x({info:d(m(),u())}).optional()}),x({id:m()}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),updateInstance:E(hI,x({ok:s(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),setInstanceEnabled:E(x({id:oI,enabled:y()}),x({ok:s(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),deleteInstance:E(x({id:oI}),x({ok:s(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),testInstance:D(x({id:oI.nullable(),values:d(m(),u()),kind:m().min(1).optional()}),nI,{kind:`mutation`,auth:`protected`,caller:`scoped`})},vocabulary:{notOperatorFacing:O.INTERNAL}},_I=x({codecs:C(m()),sampleRate:p().meta(k(`none`)),duplex:S([`half`,`full`]),maxBacklogMs:p().meta(k(`duration-ms`))}),vI=x({talking:y(),lastSessionAt:p().nullable(),ability:_I.nullable()}),Xbe=S([`opus`,`s16le`,`g711ulaw`,`g711alaw`]),yI={name:`intercom`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],methods:{startSession:E(x({deviceId:p()}),x({sessionId:m(),sdpOffer:m()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),handleAnswer:E(x({deviceId:p(),sessionId:m(),sdpAnswer:m()}),v(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),stopSession:E(x({deviceId:p(),sessionId:m()}),v(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),startTalkSession:E(x({deviceId:p()}),x({sessionId:m()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`two-way talk is a person speaking through the viewer, not an automation step`}),pushTalkAudio:E(x({deviceId:p(),audioBase64:m(),codec:Xbe.optional(),sampleRate:p().int().positive().optional(),channels:p().int().positive().optional(),sequenceNumber:p().int()}),x({accepted:y()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),endTalkSession:E(x({deviceId:p()}),v(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`})},events:{onStatusChanged:{data:x({deviceId:p(),status:vI}),notOperatorFacing:"the `talking` state trigger phrases both edges of this change"}},status:{schema:vI,kind:`command-driven`},runtimeState:vI,durability:`session`,history:`none`,vocabulary:{noun:I(`Intercom`,`Citofono`),order:3150,state:[{kind:`boolean`,field:`talking`,label:I(`Talking`,`In conversazione`),whenTrue:I(`When someone starts talking through {device}`,`Quando qualcuno inizia a parlare tramite {device}`),whenFalse:I(`When the conversation on {device} ends`,`Quando la conversazione su {device} finisce`),icon:`mic`}]}},bI=S([`carrierHz`,`dutyCyclePercent`,`repeat`,`repeatDelayMs`]),xI=S([`ir`,`rf`]),SI=x({ok:s(!0),ignoredSettings:C(m())}),CI=x({media:C(xI),settable:C(bI),maxTimings:p().int().positive(),learn:y().default(!1),formats:C(Jw).default([])}),wI=2e4,TI=6e4,EI=x({native:Xw.nullable(),timings:zw,carrierHz:p().int().positive().nullable()}),DI=x({at:p(),ok:y(),error:m().nullable()}),OI=DI.extend({medium:xI}),kI=x({lastSend:OI.nullable(),lastLearn:DI.nullable(),lastFetchedAt:p()});function AI(e){return!(e.kind===`learn`&&e.error===`ir-transmitter.learn-unsupported`)}function Zbe(e,t,n){let r=e??{lastSend:null,lastLearn:null,lastFetchedAt:n};return AI(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 Qbe(e){return Qr(e)?.code??null}var jI={name:`ir-transmitter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Generic],methods:{send:E(x({deviceId:p().int().nonnegative(),timings:zw.optional(),native:Xw.optional(),settings:Bw.optional()}).refine(e=>e.timings===void 0!=(e.native===void 0),{message:`send takes exactly one of timings or native`}),SI,{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:E(x({deviceId:p().int().nonnegative(),timeoutMs:p().int().positive().max(TI).default(wI)}),EI,{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:E(x({deviceId:p().int().nonnegative()}),CI,{kind:`query`,auth:`protected`})},runtimeState:kI,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`IR / RF transmitter`,`Trasmettitore IR / RF`),order:1140}},MI=S([`key-missing`,`wrong-key`,`key-file-unreadable`,`store-unavailable`,`not-initialized`,`decrypt-failed`]),NI=a(`state`,[x({state:s(`ready`)}),x({state:s(`locked`),reason:MI})]),PI=a(`kind`,[x({kind:s(`value`),value:m(),version:p().int()}),x({kind:s(`missing`)}),x({kind:s(`unavailable`),reason:MI}),x({kind:s(`forbidden`)})]),FI=d(m(),PI),II=x({ref:m(),owner:m(),scope:m(),fieldPath:m(),version:p().int(),createdAt:p(),updatedAt:p(),updatedBy:m(),lastReadAt:p().nullable()}),LI=C(m().min(1)).max(512),RI={name:`keychain`,scope:`system`,mode:`singleton`,internal:!0,methods:{put:E(x({ref:m().min(1),value:m().min(1)}),x({ref:m(),version:p().int()}),{kind:`mutation`,auth:`admin`}),resolve:E(x({refs:LI}),FI,{auth:`admin`}),delete:E(x({refs:LI}),x({deleted:p().int()}),{kind:`mutation`,auth:`admin`}),deleteDeviceScope:E(x({deviceId:p().int()}),x({refs:C(m()).readonly()}),{kind:`mutation`,auth:`admin`}),releaseRecordRefs:E(x({refs:LI,onBehalfOf:m().min(1)}),x({released:p().int()}),{kind:`mutation`,auth:`admin`}),listMeta:E(x({}),C(II).readonly(),{auth:`admin`}),getState:E(x({}),NI,{auth:`admin`})},vocabulary:{notOperatorFacing:O.IDENTITY}},zI=S([`mounted-file`,`previous-mounted-file`,`platform`,`default-file`]),BI=x({kind:zI,path:m().optional(),sharesBackupWithDatabase:y()}),VI=`trigger-file`,HI=x({id:m(),at:p(),actor:m(),lockedReason:m().nullable(),archived:p().int(),archivedCollection:m().nullable(),archivedKeysCollection:m().nullable(),clearedSettingsKeys:C(m()).readonly(),acknowledgedAt:p().nullable()}),UI=x({keychain:NI,keySource:BI.nullable(),configuredSource:BI,fingerprint:m().nullable(),activeKeyId:m().nullable(),rotationPending:y(),retiredWraps:p().int(),recoveryKeyDownloadedAt:p().nullable(),secretCount:p().int(),lastReset:HI.nullable()}),WI=S([`in-use`,`orphan`,`unknown`]),GI=II.extend({usage:WI}),KI=S([`put`,`delete`,`reveal`,`rotate-master-key`,`purge-retired-keys`,`download-recovery-key`,`delete-orphans`,`reset`,`acknowledge-reset`,`initialize`]),qI=x({id:m(),at:p(),action:KI,actor:m(),ref:m().nullable(),detail:m().nullable()}),JI=`RESET KEYCHAIN`,YI=S([`jwt-signing-key`]),XI={name:`keychain-admin`,scope:`system`,mode:`singleton`,methods:{status:E(x({}),UI,{auth:`admin`}),listSecrets:E(x({}),C(GI).readonly(),{auth:`admin`}),listAudit:E(x({limit:p().int().min(1).max(500).optional()}),C(qI).readonly(),{auth:`admin`}),reveal:E(x({ref:m().min(1)}),x({value:m(),version:p().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),setSystemSecret:E(x({name:YI,value:m().min(16)}),x({ref:m(),version:p().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),importSecret:E(x({ref:m().min(1),value:m().min(1)}),x({ref:m(),version:p().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),deleteOrphans:E(x({refs:C(m().min(1)).max(1e3)}),x({deleted:C(m()).readonly(),kept:C(x({ref:m(),usage:WI})).readonly()}),{kind:`mutation`,auth:`admin`,caller:`required`}),rotateMasterKey:E(x({}),x({fingerprint:m(),keySource:BI}),{kind:`mutation`,auth:`admin`,caller:`required`}),purgeRetiredKeys:E(x({}),x({purged:p().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),downloadRecoveryKey:E(x({}),x({key:m(),fingerprint:m(),keySource:BI}),{kind:`mutation`,auth:`admin`,caller:`required`}),resetKeychain:E(x({confirm:s(JI)}),x({archivedCollection:m().nullable(),archived:p().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),resetReport:E(x({}),x({reset:HI.nullable(),pendingReentry:C(II).readonly()}),{auth:`admin`}),acknowledgeReset:E(x({}),x({acknowledged:y()}),{kind:`mutation`,auth:`admin`,caller:`required`})},vocabulary:{notOperatorFacing:O.IDENTITY}},ZI=S([`idle`,`mowing`,`paused`,`docked`,`error`]),QI=S([`info`,`warning`,`error`]),$I=x({activity:ZI,batteryLevel:p().min(0).max(100).nullable().meta(k(`percentage`)),progress:p().min(0).max(100).nullable().meta(k(`percentage`)),currentCode:p().nullable().meta(k(`none`)),currentCodeLabel:m().nullable(),severity:QI,lastChangedAt:p()}),eL={name:`lawn-mower-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.LawnMower],methods:{startMowing:E(x({deviceId:p().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.start`,label:I(`Start mowing`,`Avvia il taglio`),phrase:I(`Start {device} mowing`,`Fai partire il taglio di {device}`),icon:`play`}]}),pause:E(x({deviceId:p().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.pause`,label:I(`Pause mower`,`Metti in pausa il tosaerba`),phrase:I(`Pause {device}`,`Metti in pausa {device}`),icon:`pause`}]}),dock:E(x({deviceId:p().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.dock`,label:I(`Dock mower`,`Riporta alla base`),phrase:I(`Send {device} back to its dock`,`Rimanda {device} alla base`),icon:`house`}]})},status:{schema:$I,kind:`push`},runtimeState:$I,durability:`session`,history:{fields:{batteryLevel:{kind:`gauge`,unit:`%`,deadband:2}}},vocabulary:{noun:I(`Robot mower`,`Robot tosaerba`),order:2010,state:[{kind:`enum`,field:`activity`,label:I(`Activity`,`Attività`),values:[{value:`idle`,label:I(`Idle`,`Inattivo`)},{value:`mowing`,label:I(`Mowing`,`In taglio`),phrase:I(`When {device} starts mowing`,`Quando {device} inizia a tagliare`)},{value:`paused`,label:I(`Paused`,`In pausa`)},{value:`docked`,label:I(`Docked`,`Alla base`),phrase:I(`When {device} docks`,`Quando {device} arriva alla base`)},{value:`error`,label:I(`Error`,`Errore`),phrase:I(`When {device} reports an error`,`Quando {device} segnala un errore`)}],icon:`bot`},{kind:`numeric`,field:`batteryLevel`,quantity:I(`the battery level`,`il livello della batteria`),label:I(`Battery`,`Batteria`),unit:`%`,icon:`battery`}]}},tL=6e5,$be=60*6e4,nL=x({inputTokens:p(),outputTokens:p()}),rL=S([`timeout`,`rate-limited`,`auth`,`refusal`,`bad-request`,`unavailable`,`no-profile`,`budget-exceeded`,`adapter-error`]),iL=x({ok:s(!0),text:m(),model:m(),usage:nL,truncated:y(),latencyMs:p()}),aL=S([`guardrail`,`model`]),oL=x({ok:s(!1),code:rL,message:m(),retryAfterMs:p().optional(),refusalSource:aL.optional()}),sL=a(`ok`,[iL,oL]),cL=x({bytes:b(Uint8Array),mimeType:m()}),lL=x({enabled:y().default(!1),maxAttempts:p().int().min(1).max(5).default(1)}),exe={totalMs:6e4,connectMs:1e4,firstTokenMs:12e4,idleMs:6e4},uL=x({addonId:m().optional(),profileId:m().optional(),consumer:m(),system:m().optional(),prompt:m(),jsonSchema:d(m(),u()).optional(),maxTokens:p().int().positive().optional(),temperature:p().optional(),topP:p().min(0).max(1).optional(),topK:p().int().positive().optional(),reasoningEffort:S([`off`,`low`,`medium`,`high`]).optional(),timeoutMs:p().int().positive().optional(),retry:lL.optional(),requestId:m().optional()}),dL=x({url:m(),filename:m(),sizeBytes:p(),sha256:m().optional()}),fL=a(`kind`,[x({kind:s(`catalog`),catalogId:m()}),x({kind:s(`url`),url:m(),sha256:m().optional(),label:m().optional(),sizeBytes:p().optional(),extraFiles:C(dL).optional()}),x({kind:s(`path`),path:m()})]),pL=x({nodeId:m(),engine:S([`llama-cpp`]),model:fL,contextSize:p().int().default(4096),gpuLayers:p().int().default(0),threads:p().int().optional(),parallel:p().int().default(1),batchSize:p().int().positive().optional(),ubatchSize:p().int().positive().optional(),flashAttention:y().default(!1),mlock:y().default(!1),noMmap:y().default(!1),cacheTypeK:S([`f32`,`f16`,`q8_0`,`q5_1`,`q5_0`,`q4_1`,`q4_0`]).optional(),cacheTypeV:S([`f32`,`f16`,`q8_0`,`q5_1`,`q5_0`,`q4_1`,`q4_0`]).optional(),extraArgs:C(m()).default([]),autoStart:y().default(!1),idleStopMinutes:p().int().default(30)}),mL=x({phase:S([`downloading`,`verifying`]),file:m(),fileIndex:p().int(),fileCount:p().int(),downloadedBytes:p(),totalBytes:p().optional()}),hL=x({nodeId:m(),state:S([`stopped`,`downloading`,`starting`,`ready`,`crashed`,`failed`]),pid:p().optional(),port:p().optional(),modelPath:m().optional(),modelId:m().optional(),downloadProgress:p().min(0).max(1).optional(),download:mL.optional(),lastError:m().optional(),crashesInWindow:p(),memoryBytes:p().optional(),vramBytes:p().optional()}),gL=x({file:m(),sizeBytes:p(),catalogId:m().optional(),installedAt:p().optional(),path:m().optional()}),_L=x({nodeId:m(),modelsBytes:p(),freeBytes:p().optional()}),vL=uL.extend({images:C(cL).optional(),runtime:pL,timeoutMs:p().int().positive().optional()}),yL=S([`deviceNotEligible`,`appleIntelligenceNotEnabled`,`modelNotReady`,`osTooOld`,`helperMissing`,`helperCrashed`]),bL=a(`state`,[x({state:s(`available`),osVersion:m(),contextSize:p().int().positive(),languages:C(m()),imageInput:y()}),x({state:s(`unavailable`),reason:yL,osVersion:m().nullable(),detail:m()}),x({state:s(`unsupported-platform`),platform:m()}),x({state:s(`unknown`),error:m()})]),xL=uL.extend({images:C(cL).optional(),timeoutMs:p().int().positive().optional()}),SL=x({requestId:m()}),CL={name:`llm-runtime`,scope:`system`,mode:`singleton`,internal:!0,methods:{complete:E(vL,sL,{kind:`mutation`,auth:`admin`,timeoutMs:tL}),ensureStarted:E(x({runtime:pL}),hL,{kind:`mutation`,auth:`admin`,timeoutMs:tL}),stop:E(x({}),v(),{kind:`mutation`,auth:`admin`}),status:E(x({}),hL,{auth:`admin`}),installModel:E(x({model:fL}),v(),{kind:`mutation`,auth:`admin`,timeoutMs:$be}),deleteModel:E(x({file:m()}),v(),{kind:`mutation`,auth:`admin`}),listLocalModels:E(x({}),C(gL),{auth:`admin`}),getDiskUsage:E(x({}),_L,{auth:`admin`}),cancel:E(SL,v(),{kind:`mutation`,auth:`admin`}),appleAvailability:E(x({}),bL,{auth:`admin`}),completeApple:E(xL,sL,{kind:`mutation`,auth:`admin`,timeoutMs:tL})},vocabulary:{notOperatorFacing:O.ML}},wL=/^[a-z0-9][a-z0-9-]{0,63}$/,TL=m().regex(wL,`a kind id is lower-case letters, digits and dashes`),EL=x({vision:y(),tools:y(),streaming:y(),reasoning:y().nullable().optional()}),DL=x({id:m(),label:m().optional(),contextLength:p().int().positive().optional(),features:EL.partial().optional()}),OL=d(m(),u()),txe=x({id:m(),name:m(),kind:TL,addonId:m(),enabled:y(),model:m(),supportsVision:y(),temperature:p().min(0).max(2).optional(),topP:p().min(0).max(1).optional(),topK:p().int().positive().optional(),maxTokens:p().int().positive().optional(),reasoningEffort:S([`off`,`low`,`medium`,`high`]).optional(),contextLength:p().int().positive().optional(),systemPrompt:m().optional(),timeoutMs:p().int().positive().default(6e4),connectTimeoutMs:p().int().positive().default(1e4),firstTokenTimeoutMs:p().int().positive().default(12e4),idleTimeoutMs:p().int().positive().default(6e4),retry:lL.default({enabled:!1,maxAttempts:1}),toolsEnabled:y().default(!1),providerConfig:OL.default({})}),kL=S([`temperature`,`topP`,`topK`,`maxTokens`,`reasoningEffort`,`contextLength`,`systemPrompt`,`timeoutMs`,`connectTimeoutMs`,`firstTokenTimeoutMs`,`idleTimeoutMs`,`retry`,`toolsEnabled`]),AL=x({id:m(),placement:S([`connection`,`model`]),requires:C(m()).optional()}),jL=u(),nxe=x({kind:TL,label:m(),icon:m(),addonId:m(),connectionSchema:jL,advancedSchema:jL.optional(),features:EL,visionEditable:y(),modelCatalog:S([`fetch`,`static`,`none`]),staticModels:C(DL).optional(),profileFields:C(kL),providerWidgets:C(AL).optional()}),ML=x({addonId:m(),kind:TL,profileId:m().optional(),connection:OL.optional()}),NL=S([`auth`,`network`,`unsupported`,`invalid`]),PL=a(`ok`,[x({ok:s(!0),models:C(DL)}),x({ok:s(!1),code:NL,message:m()})]),FL=l([x({consumer:m()}),x({purpose:S([`text`,`vision`])})]),IL=x({selector:FL,profileId:m()}),LL=x({day:m(),consumer:m(),profileId:m(),calls:p(),okCalls:p(),errorCalls:p(),inputTokens:p(),outputTokens:p(),avgLatencyMs:p()}),RL=x({id:m(),label:m(),family:m(),purpose:S([`text`,`vision`]),url:m(),sha256:m(),sizeBytes:p(),quantization:m(),minRamBytes:p(),contextSizeDefault:p().int(),mmprojUrl:m().optional()}),zL=a(`ok`,[x({ok:s(!0),model:fL,label:m(),repo:m(),quantization:m(),purpose:S([`text`,`vision`]),totalBytes:p(),extraFilenames:C(m())}),x({ok:s(!1),code:m(),message:m(),candidates:C(m()).optional(),requiredBytes:p().optional()})]),BL=x({nodeId:m(),reachable:y(),status:hL.optional(),disk:_L.optional(),error:m().optional(),apple:bL.optional()}),rxe=uL.extend({images:C(cL).min(1)}),VL=x({addonId:m(),profileId:m()}),HL={name:`llm`,scope:`system`,mode:`collection`,internal:!1,providerKind:`ai`,nodeIdMode:`data`,methods:{generate:E(uL,sL,{kind:`mutation`,timeoutMs:tL}),generateVision:E(rxe,sL,{kind:`mutation`,timeoutMs:tL}),cancel:E(x({addonId:m().optional(),requestId:m()}),v(),{kind:`mutation`}),listModels:E(ML,PL,{kind:`mutation`,auth:`admin`}),getDefaults:E(x({}),C(IL)),setDefault:E(x({selector:FL,profileId:m().nullable()}),v(),{kind:`mutation`,auth:`admin`}),getUsage:E(x({since:p().optional(),until:p().optional(),consumer:m().optional(),profileId:m().optional()}),C(LL)),listModelCatalog:E(x({}),C(RL)),listRuntimeNodes:E(x({}),C(BL)),listNodeModels:E(x({nodeId:m()}),C(gL)),resolveModelRef:E(x({ref:m(),maxBytes:p().positive().optional()}),zL,{kind:`mutation`,auth:`admin`}),installModel:E(x({nodeId:m(),model:fL}),v(),{kind:`mutation`,auth:`admin`}),deleteModel:E(x({nodeId:m(),file:m()}),v(),{kind:`mutation`,auth:`admin`}),getRuntimeStatus:E(VL,hL),startRuntime:E(VL,hL,{kind:`mutation`,auth:`admin`}),stopRuntime:E(VL,v(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.ML}},UL=[`decode`,`transcode`,`recording`,`streaming`,`detection`],WL=[`measured`,`accounted`,`unattributable`],GL=x({role:S(UL),deviceId:p().int().positive().nullable(),attribution:S(WL),unit:m(),pid:p().int().positive().optional(),startedAtMs:p().optional(),cpuSeconds:p().optional(),rssBytes:p().optional()}),KL={name:`load-contribution`,scope:`system`,mode:`collection`,internal:!0,methods:{list:E(v(),C(GL).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:O.INTERNAL}},qL=`https://camstack.zentik.app`,JL=`/viewer/camstack`;function YL(e){if(e==null||e===``)return!1;try{return new URL(e).origin===qL}catch{return!1}}function ixe(e){let t=e.baseUrl??e.resolved;return YL(t)?{form:`app`,hubBaseUrl:e.appLinkHub??null}:{form:`hub`,hubBaseUrl:t}}function XL(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 axe(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=XL(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 oxe(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 ZL(e){return e.length===0?``:`?${e.map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join(`&`)}`}function sxe(e){let t=oxe(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:XL(r),n=e===null?t.query:[...t.query,[`hub`,e]];return`${qL}${t.path}${ZL(n)}`}return r===``||YL(r)?null:`${r}${JL}${t.path}${ZL(t.query)}`}var QL=[`appConnections`,`notificationTaps`,`internal`,`publicEndpoint`],cxe=[`notificationTaps`,`internal`,`publicEndpoint`];function lxe(e){return e!==`appConnections`}var uxe={appConnections:[],notificationTaps:null,internal:null,publicEndpoint:null},dxe=/^\d{1,3}(?:\.\d{1,3}){3}$/;function $L(e){try{let t=new URL(e).hostname;return t.length>0?t:null}catch{return null}}function fxe(e){return e.replace(/\/+$/,``)}function eR(e){return e.kind===`public`&&e.interfaceKind===`vpn`}function pxe(e){return e.kind===`public`&&e.interfaceKind===`public`}function tR(e){return(e.kind===`lan-ipv4`||e.kind===`lan-ipv6`)&&e.plausible}function nR(e){if(e.kind!==`lan-ipv4`||!e.plausible)return!1;let t=$L(e.baseUrl);return t!==null&&dxe.test(t)}function rR(e){return e.stable===!1}function mxe(e,t){return t.kind===`loopback`||t.kind===`app-link`||t.kind===`custom`||$L(t.baseUrl)===null||rR(t)?null:e===`internal`?nR(t)?0:tR(t)?1:eR(t)?2:null:pxe(t)?0:eR(t)?1:nR(t)?2:tR(t)?3:null}var hxe=new Set([`localhost`,`0.0.0.0`,`::1`,`[::1]`,`::`,`[::]`]);function gxe(e){let t=e.toLowerCase();return hxe.has(t)||t.endsWith(`.localhost`)?!0:/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(t)}function iR(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.`}:gxe(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 aR=`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 oR(e,t,n={}){if(YL(t))return e===`notificationTaps`?{ok:!0,baseUrl:qL}:{ok:!1,reason:`The CamStack app link is not a hub address — only notification taps can use it.`};let r=iR(t);return r.ok&&e===`publicEndpoint`&&r.baseUrl.startsWith(`http:`)&&n.acceptInsecureHttp!==!0?{ok:!1,reason:aR}:r}function sR(e,t){if(t===null||t===``)return null;let n=oR(e,t,{acceptInsecureHttp:!0});return n.ok?n.baseUrl:null}function _xe(e,t){let n=e.flatMap(e=>{let n=mxe(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:fxe(n.endpoint.baseUrl)}function cR(e,t,n){let r=sR(t,n);if(r!==null)return{flagged:r,resolved:r,source:`flagged`};let i=_xe(e,t);return{flagged:null,resolved:i,source:i===null?`none`:`auto`}}function lR(e,t){return cR(e,`internal`,t.internal)}function uR(e,t){return cR(e,`publicEndpoint`,t.publicEndpoint)}function dR(e){let t=sR(`notificationTaps`,e.notificationTaps);return t!==null&&!YL(t)?{flagged:t,resolved:t,source:`flagged`}:{flagged:null,resolved:qL,source:`auto`}}function fR(e){return rR(e)?!1:e.kind===`lan-ipv4`?!0:e.kind===`public`&&e.interfaceKind===`public`}function pR(e,t){let n=e.filter(fR);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 mR(e,t){let n=new Set(t.appConnections),r=pR(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 vxe(e,t,n){return{appConnections:mR(e,n),notificationTaps:dR(n),internal:lR(t,n),publicEndpoint:uR(t,n)}}function yxe(e){return e===null?null:$L(e)}var bxe=`camstack`,xxe=`_camstack._tcp.local`,Sxe={nodeId:`nodeId`,version:`version`,role:`role`,url:`url`,hubId:`hubId`},hR=/^hub-[0-9a-f]{16}$/;function Cxe(e){return typeof e==`string`&&hR.test(e)}var wxe=`camstack-agent`,Txe=`_camstack-agent._tcp.local`,Exe={nodeId:`nodeId`,version:`version`,name:`name`,state:`state`,keyFingerprint:`fp`},Dxe=S([`lan`,`wifi`,`docker`,`vpn`,`loopback`,`other`]),gR=x({name:m(),family:S([`IPv4`,`IPv6`]),address:m(),cidr:m(),netmask:m(),internal:y(),mac:m(),kind:Dxe,preferred:y(),plausible:y(),plausibleReason:m()}),Oxe=x({interfaces:C(gR).readonly(),probedAt:p()}),kxe=gR.nullable(),_R=x({label:m(),baseUrl:m(),kind:S([`lan-ipv4`,`lan-ipv6`,`public`,`loopback`,`app-link`,`custom`]),interfaceKind:S([`lan`,`wifi`,`docker`,`vpn`,`other`,`loopback`,`public`]),plausible:y(),plausibleReason:m(),priority:p(),stable:y().optional()}),Axe=S([`server-config`,`server-env`,`caller-hint`,`default`]),jxe=x({port:p().int().min(1).max(65535),source:Axe}),Mxe=x({endpoints:C(_R).readonly(),localPort:jxe}),vR=x({baseUrl:m().nullable(),resolved:m().nullable(),appLinkHub:m().nullable()}),yR=x({baseUrls:C(m()).readonly(),resolved:C(m()).readonly()}),bR=x({override:m().nullable(),resolved:m().nullable(),source:S([`override`,`auto`,`none`])}),Nxe=x({cluster:bR,browser:bR}),xR=S(QL),SR=S([`flagged`,`auto`,`none`]),CR=x({flagged:m().nullable(),resolved:m().nullable(),source:SR}),Pxe=x({flagged:C(m()).readonly(),resolved:C(m()).readonly(),source:SR}),wR=x({rows:C(_R.extend({detected:y(),custom:y(),flags:C(xR).readonly(),inUse:C(xR).readonly(),eligible:C(xR).readonly()})).readonly(),roles:x({appConnections:Pxe,notificationTaps:CR,internal:CR,publicEndpoint:CR}),appLinkHub:m().nullable(),listenerOrigins:C(m()).readonly().optional()}),TR=x({addresses:C(m()).readonly()}),ER=x({mode:S([`generated`,`uploaded`,`disabled`]),leafFingerprintSha256:m().nullable(),caFingerprintSha256:m().nullable(),validTo:m().nullable(),sans:C(m()),caCertPem:m().nullable(),reissueError:m().nullable(),restartRequired:y(),caMissing:y(),localCaConstrained:y().nullable(),caReplacedAt:m().nullable(),storedUpload:x({leafFingerprintSha256:m(),validTo:m(),hasCa:y()}).nullable()}),Fxe=x({providerId:m().min(1),modes:C(eA)}),Ixe=x({providerId:m().optional(),mode:m().optional(),message:m()}),Lxe=x({hostsProbed:p().int(),hits:p().int(),timeouts:p().int(),byMode:d(m(),x({probed:p().int(),hits:p().int(),timeouts:p().int()}))}),Rxe=x({hits:C(x({providerId:m(),hit:tA})),subnetsScanned:C(m()),errors:C(Ixe),stats:Lxe}),DR={name:`local-network`,scope:`system`,mode:`singleton`,methods:{list:E(v(),Oxe),getPreferred:E(v(),kxe),getConnectionEndpoints:E(x({port:p().int().min(1).max(65535).optional(),includeLoopback:y().optional(),ipv4Only:y().optional(),scheme:S([`http`,`https`]).optional(),includeAppLink:y().optional()}),Mxe),getNotificationEndpoint:E(v(),vR),setNotificationEndpoint:E(x({baseUrl:m().nullable()}),vR,{kind:`mutation`}),getViewerEndpoints:E(v(),yR),setViewerEndpoints:E(x({baseUrls:C(m()).readonly()}),yR,{kind:`mutation`}),getAddresses:E(x({scheme:S([`http`,`https`]).optional()}).optional(),wR),addCustomAddress:E(x({baseUrl:m(),label:m().max(80)}),wR,{kind:`mutation`,auth:`admin`}),removeCustomAddress:E(x({baseUrl:m()}),wR,{kind:`mutation`,auth:`admin`}),setAddressRole:E(x({role:xR,baseUrl:m().nullable(),enabled:y(),acceptInsecureHttp:y().optional()}),wR,{kind:`mutation`,auth:`admin`}),getHubAddresses:E(v(),Nxe),getAllowedAddresses:E(v(),TR),setAllowedAddresses:E(TR,x({success:s(!0)}),{kind:`mutation`}),resetAllowlistToBestMatch:E(v(),TR,{kind:`mutation`}),getTlsStatus:E(v(),ER),regenerateCertificate:E(x({reason:m().optional()}),ER,{kind:`mutation`,auth:`admin`}),uploadCertificate:E(x({certPem:m().min(1),keyPem:m().min(1),caPem:m().optional()}),ER,{kind:`mutation`,auth:`admin`}),downloadCa:E(v(),x({pem:m()})),useStoredUploadedCertificate:E(v(),ER,{kind:`mutation`,auth:`admin`}),scanNetwork:E(x({requests:C(Fxe),subnets:C(m()).optional()}),Rxe,{kind:`mutation`,auth:`admin`,timeoutMs:9e4}),getScanSubnets:E(v(),x({subnets:C(m())}),{auth:`admin`}),setScanSubnets:E(x({subnets:C(m())}),x({subnets:C(m())}),{kind:`mutation`,auth:`admin`}),revertToGeneratedCertificate:E(v(),ER,{kind:`mutation`,auth:`admin`})},mount:{kind:`hub-only`},vocabulary:{notOperatorFacing:O.NETWORK}},OR=S([`locked`,`unlocked`,`locking`,`unlocking`,`jammed`,`door-open`]),kR=x({state:OR,lastChangedAt:p()}),zxe={version:1,overridable:[{path:`state`,by:`door-contact`}],targets:[{id:`door-contact`,cardinality:`scalar`,vocabulary:{cap:`lock-control`,stateField:`state`},deviceTypes:[j.Lock],apply:`replace`,path:`state`,override:{whenSourceTrue:`door-open`,unlessNative:[`jammed`]},sources:[{kind:`binary`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}]},AR={name:`lock-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Lock],methods:{lock:E(x({deviceId:p().int().nonnegative(),code:m().min(1).optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.lock`,label:I(`Lock`,`Chiudi a chiave`),phrase:I(`Lock {device}`,`Chiudi a chiave {device}`),icon:`lock`,effect:{field:`state`,value:`locked`},openArgs:[{key:`code`,label:I(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]}),unlock:E(x({deviceId:p().int().nonnegative(),code:m().min(1).optional(),confirm:y().optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.unlock`,label:I(`Unlock`,`Apri la serratura`),phrase:I(`Unlock {device}`,`Sblocca {device}`),icon:`lock-open`,effect:{field:`state`,value:`unlocked`},openArgs:[{key:`code`,label:I(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]}),open:D(x({deviceId:p().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.open`,label:I(`Open latch`,`Apri lo scrocco`),phrase:I(`Release the latch of {device}`,`Fai scattare lo scrocco di {device}`),icon:`door-open`}]})},status:{schema:kR,kind:`push`},runtimeState:kR,customize:zxe,durability:`restored`,history:{fields:{state:{kind:`enum`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:I(`Lock`,`Serratura`),order:1060,state:[{kind:`enum`,field:`state`,label:I(`Lock state`,`Stato della serratura`),values:[{value:`locked`,label:I(`Locked`,`Chiusa a chiave`),phrase:I(`When {device} locks`,`Quando {device} si chiude a chiave`)},{value:`unlocked`,label:I(`Unlocked`,`Sbloccata`),phrase:I(`When {device} unlocks`,`Quando {device} si sblocca`)},{value:`locking`,label:I(`Locking`,`In chiusura`),phrase:I(`When {device} starts locking`,`Quando {device} inizia a chiudersi`)},{value:`unlocking`,label:I(`Unlocking`,`In apertura`),phrase:I(`When {device} starts unlocking`,`Quando {device} inizia a sbloccarsi`)},{value:`jammed`,label:I(`Jammed`,`Inceppata`),phrase:I(`When {device} jams`,`Quando {device} si inceppa`)},{value:`door-open`,label:I(`Door open`,`Porta aperta`),phrase:I(`When the door of {device} opens`,`Quando la porta di {device} si apre`)}],icon:`lock`}]}},jR=x({armed:p().int().min(0),unknown:C(m()).readonly()}),MR={name:`log-channels`,scope:`system`,mode:`collection`,internal:!0,methods:{list:E(v(),C(pu).readonly()),apply:E(x({windows:C(mu).readonly()}),jR,{kind:`mutation`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:O.INTERNAL}},NR=S([`debug`,`info`,`warn`,`error`]),PR=x({timestamp:g(),level:NR,scope:C(m()),message:m(),meta:d(m(),u()).optional(),tags:d(m(),m()).optional()}),FR=x({instanceId:m().min(1).max(200).optional(),requestId:m().min(1).max(64).optional(),deviceId:p().int().optional(),fromAddonId:m().min(1).max(200).optional(),fromNodeId:m().min(1).max(200).optional(),tags:d(m(),l([m(),p()])).optional(),level:NR.optional(),text:m().min(1).max(200).optional(),since:p().optional(),until:p().optional(),before:m().min(1).max(1024).optional(),after:m().min(1).max(1024).optional(),limit:p().int().min(1).max(1e3).optional(),budgetMs:p().int().min(50).max(1e4).optional()}),IR=x({id:m().optional(),timestamp:p(),level:NR,scope:m().optional(),message:m(),tags:d(m(),l([m(),p()])).optional(),meta:d(m(),u()).optional()}),LR=x({entries:C(IR),nextBefore:m().nullable(),nextAfter:m().nullable(),scannedBytes:p().int().nonnegative(),done:y(),cancelled:y().optional()}),Bxe=x({instanceId:m().min(1).max(200).optional()}),RR=x({readable:y(),reason:m().nullable(),filters:x({deviceId:y(),addonId:y(),nodeId:y(),tags:y(),level:y(),text:y(),timeRange:y()}),retentionDays:p().nullable()}),zR={name:`log-destination`,scope:`system`,mode:`collection`,internal:!0,methods:{write:E(PR,v(),{kind:`mutation`}),describeRead:D(Bxe,RR,{auth:`admin`}),read:D(FR,LR,{auth:`admin`}),cancelRead:D(x({requestId:m().min(1).max(64)}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:O.INTERNAL}},BR=S([`primary`,`second-factor`]),VR=x({kind:s(`redirect`),id:m(),label:m(),icon:m().optional(),startUrl:m(),stage:BR,linkable:y().optional(),app:Gf.nullable().optional()}),HR=x({kind:s(`widget`),id:m(),addonId:m(),bundle:m(),remote:Bv,stage:BR,app:Gf.nullable().optional()}),UR=x({kind:s(`passkey`),id:m(),label:m(),stage:BR,rpId:m(),origin:m().nullable(),app:Gf.nullable().optional()}),WR=a(`kind`,[VR,HR,UR]),GR={name:`login-method`,scope:`system`,mode:`collection`,internal:!0,methods:{getLoginMethods:E(v(),C(WR).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:O.IDENTITY}},Vxe=x({id:m(),label:m(),scope:S([`mesh`,`public`]),url:m(),hostname:m(),port:p(),protocol:S([`http`,`https`])}),KR=x({id:m(),hostname:m(),magicDns:m(),addresses:C(m()).readonly(),os:m().optional(),online:y(),lastSeenMs:p(),isSelf:y(),connection:S([`direct`,`relay`,`idle`]),relay:m().nullable(),lastHandshakeMs:p(),rxBytes:p(),txBytes:p(),tags:C(m()).readonly(),exitNodeOption:y(),advertisedRoutes:C(m()).readonly(),userLogin:m().nullable(),keyExpiry:p().nullable()}),qR=x({joined:y(),meshIp:m(),magicDnsHostname:m(),peerCount:p(),endpoints:C(Vxe).readonly(),error:m().optional(),tenantName:m(),magicDnsSuffix:m(),userLogin:m().nullable(),controlPlaneUrl:m(),keyExpiry:p().nullable(),daemonSocket:m().optional(),daemonCliPath:m().optional()}),JR={name:`mesh-network`,scope:`system`,mode:`collection`,providerKind:`mesh`,methods:{getStatus:E(v(),qR),join:E(x({authKey:m().min(8),hostname:m().optional()}),x({joined:s(!0)}),{kind:`mutation`}),startLogin:E(x({hostname:m().optional()}),x({loginUrl:m()}),{kind:`mutation`}),leave:E(v(),x({left:s(!0)}),{kind:`mutation`}),logout:E(v(),x({loggedOut:s(!0)}),{kind:`mutation`}),listPeers:E(v(),x({peers:C(KR).readonly()}))},vocabulary:{notOperatorFacing:O.NETWORK}},YR=x({value:p().nullable().meta(k(`device`,{label:`Total`})),lastFetchedAt:p()}),XR={name:`meter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor],methods:{},status:{schema:YR,kind:`push`},runtimeState:YR,durability:`restored`,history:{fields:{value:{kind:`counter`,deadband:.001,minIntervalMs:6e4}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`Meter`,`Contatore`),order:5140,state:[{kind:`numeric`,field:`value`,quantity:I(`the total`,`il totale`),label:I(`Total`,`Totale`),icon:`gauge`}]}},Hxe=x({total:p(),user:p(),system:p(),irq:p(),nice:p(),loadAvg:c([p(),p(),p()]),cores:p()}),Uxe=x({percent:p().nullable(),totalBytes:p(),usedBytes:p().nullable(),availableBytes:p().nullable(),swapUsedBytes:p(),swapTotalBytes:p()}),Wxe=x({readBytes:p(),writeBytes:p(),readOps:p(),writeOps:p(),timestampMs:p()}),Gxe=x({rxBytes:p(),txBytes:p(),rxPackets:p(),txPackets:p(),rxErrors:p(),txErrors:p(),timestampMs:p()}),ZR=x({utilization:p(),model:m(),memoryUsedBytes:p(),memoryTotalBytes:p(),temperature:p().nullable()}),Kxe=x({openFds:p(),threadCount:p(),activeHandles:p(),activeRequests:p()}),QR=x({avg10:p(),avg60:p(),avg300:p()}),$R=x({some:QR,full:QR.nullable()}),ez=x({cpu:Hxe,memory:Uxe,gpu:ZR.nullable(),network:Gxe,disk:Wxe,pressure:x({cpu:$R.nullable(),memory:$R.nullable(),io:$R.nullable()}),process:Kxe,cpuTemperature:p().nullable(),timestampMs:p()}),qxe=x({path:m(),totalBytes:p(),usedBytes:p(),availableBytes:p(),percent:p()}),tz=x({pid:p(),cpu:p(),memory:p(),privateBytes:p().optional(),sharedBytes:p().optional()}),Jxe=x({addonId:m(),nodeId:m(),role:S([`hub`,`worker`]),pid:p(),state:S([`starting`,`running`,`stopping`,`stopped`,`crashed`]),uptimeSec:p()}),Yxe=x({pid:p(),ppid:p(),pgid:p(),classification:S([`root`,`managed`,`system`]),addonId:m().nullable(),nodeId:m().nullable(),command:m(),cpuPercent:p(),memoryRssBytes:p(),cpuMainPercent:p().nullable(),cpuGcPercent:p().nullable(),threadCount:p().nullable(),uptimeSec:p()}),Xxe=x({source:S([`cgroup-v2`,`cgroup-v1`]),currentBytes:p(),limitBytes:p().nullable(),anonBytes:p().nullable(),fileBytes:p().nullable(),shmemBytes:p().nullable(),slabBytes:p().nullable(),gpuShmemBytes:p().nullable()}).extend({atMs:p()}),Zxe=x({atMs:p(),samples:p().int(),cpuMainPercent:p().nullable(),cpuMainPercentMin:p().nullable(),cpuGcPercent:p().nullable(),cpuGcPercentMin:p().nullable(),cpuLifetimePercent:p(),cpuLifetimePercentMin:p(),memoryRssBytes:p(),memoryRssBytesMin:p(),processCount:p().int(),processCountMin:p().int()}),Qxe=x({key:m(),kind:S([`addon`,`root`,`unattributed`]),points:C(Zxe).readonly()}),$xe=x({nodeId:m(),series:C(Qxe).readonly(),containerMemory:C(Xxe).readonly(),bucketMs:p(),retainedSamples:p(),oldestAtMs:p().nullable(),cadenceMs:p(),durable:y()}),eSe=x({forNodeId:m(),sinceMs:p().optional(),maxPoints:p().int().positive().optional()}),nz=x({cpuPercent:p(),memoryPercent:p().nullable(),memoryUsedMB:p().nullable(),memoryTotalMB:p(),diskPercent:p().optional(),temperature:p().optional(),gpuPercent:p().optional(),gpuMemoryPercent:p().optional()}),rz={name:`metrics-provider`,scope:`system`,mode:`singleton`,methods:{collectSnapshot:E(v(),ez),getCached:E(v(),ez.nullable()),getCurrent:E(v(),nz),getDiskSpace:E(x({dirPath:m()}),qxe),getGpuInfo:E(v(),ZR.nullable()),getCpuTemperature:E(v(),p().nullable()),getProcessStats:E(x({pids:C(p())}),C(tz)),listAddonInstances:E(v(),C(Jxe).readonly()),getAddonStats:E(x({addonId:m()}),tz.nullable()),listNodeProcesses:E(v(),C(Yxe).readonly()),getLoadSeries:E(eSe,$xe)},vocabulary:{notOperatorFacing:O.CLUSTER}},iz=m().min(1).max(256),az=d(m(),u()),oz=x({id:iz,deviceId:p().int().optional(),at:p().int().optional(),expiresAt:p().int().optional(),data:az}),sz=x({id:m(),deviceId:p().int().nullable(),at:p().nullable(),expiresAt:p().nullable(),rev:p().int(),updatedAt:p(),data:az}),cz=d(ji,l([m(),p(),y(),x({in:C(l([m(),p(),y()])).min(1).max(Pn)}),x({gt:l([m(),p()]).optional(),gte:l([m(),p()]).optional(),lt:l([m(),p()]).optional(),lte:l([m(),p()]).optional()}).refine(e=>Object.keys(e).length>0,{message:`name at least one bound`})])),lz={kind:Li},uz={deviceId:p().int().optional(),atFrom:p().optional(),atTo:p().optional()},dz=x({...lz,...uz,where:cz.optional(),order:S([`at`,`id`]).optional(),desc:y().optional(),limit:p().int().min(1).max(In).default(100),cursor:m().min(1).optional()}),fz=x({records:C(sz),nextCursor:m().nullable()}),tSe=S([`created`,`unchanged`,`updated`]),pz=x({kindId:p().int(),state:tSe,createdIndexes:C(m())}),mz=C(m()),hz=a(`op`,[x({op:s(`put`),kind:Li,record:oz,ifRev:p().int().min(0).optional()}),x({op:s(`patch`),kind:Li,id:iz,data:az,at:p().int().nullable().optional(),expiresAt:p().int().nullable().optional(),ifRev:p().int().min(1).optional()}),x({op:s(`delete`),kind:Li,id:iz})]),gz=d(m(),d(m(),m())),_z={name:`records`,scope:`system`,mode:`singleton`,internal:!0,methods:{declareKinds:E(x({kinds:d(Li,Ii)}),x({kinds:d(m(),pz)}),{kind:`mutation`,auth:`admin`}),get:E(x({...lz,id:iz}),sz.nullable(),{auth:`admin`}),getMany:E(x({...lz,ids:C(iz).min(1).max(Pn)}),C(sz),{auth:`admin`}),secretRefs:E(x({...lz,ids:C(iz).min(1).max(Pn)}),gz,{auth:`admin`}),put:E(x({...lz,record:oz,ifRev:p().int().min(0).optional()}),x({rev:p().int(),releasedRefs:mz}),{kind:`mutation`,auth:`admin`}),putMany:E(x({...lz,records:C(oz).min(1).max(Pn)}),x({count:p().int(),releasedRefs:mz}),{kind:`mutation`,auth:`admin`}),patch:E(x({...lz,id:iz,data:az,at:p().int().nullable().optional(),expiresAt:p().int().nullable().optional(),ifRev:p().int().min(1).optional()}),x({rev:p().int(),releasedRefs:mz}),{kind:`mutation`,auth:`admin`}),delete:E(x({...lz,id:iz}),x({deleted:y(),secretRefs:mz}),{kind:`mutation`,auth:`admin`}),deleteMany:E(x({...lz,ids:C(iz).min(1).max(Pn)}),x({deleted:p().int(),secretRefs:mz}),{kind:`mutation`,auth:`admin`}),query:E(dz,fz,{auth:`admin`}),count:E(x({...lz,...uz,where:cz.optional()}),x({count:p().int()}),{auth:`admin`}),histogram:E(x({...lz,deviceId:p().int().optional(),from:p(),to:p(),bucketMs:p().int().positive()}),x({buckets:C(x({bucketStart:p(),count:p().int()}))}),{auth:`admin`}),aggregate:E(x({...lz,op:S([`sum`,`min`,`max`,`count`]),field:ji.optional(),groupBy:ji.optional(),where:cz.optional()}),x({rows:C(x({group:l([m(),p(),ie()]),value:p().nullable()}))}),{auth:`admin`}),deleteWhere:E(x({...lz,deviceId:p().int().optional(),atBefore:p().optional(),where:cz.optional()}),x({deleted:p().int(),secretRefs:mz}),{kind:`mutation`,auth:`admin`}),transact:E(x({ops:C(hz).min(1).max(Pn)}),x({results:C(x({rev:p().int().nullable(),deleted:y()})),releasedRefs:mz,secretRefs:mz}),{kind:`mutation`,auth:`admin`}),deleteDevice:E(x({deviceId:p().int(),kinds:C(Li).optional()}),x({deleted:d(m(),p().int()),secretRefs:mz}),{kind:`mutation`,auth:`admin`}),allocateId:E(x(lz),x({id:p().int()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.INTERNAL}},vz=d(m(),u()),yz=x({integrationId:m().min(1)}),bz=x({id:m().min(1)}),xz=x({id:m(),deviceId:p().int().nullable(),at:p().nullable(),expiresAt:p().nullable(),rev:p().int(),updatedAt:p(),data:vz}),Sz={id:m().min(1),deviceId:p().int().optional(),at:p().int().optional(),expiresAt:p().int().optional(),data:vz},Cz=x({id:m(),addonId:m(),name:m(),info:vz,enabled:y().optional(),originStableId:m().optional()}),nSe=x({id:p().int(),integrationId:m().nullable().optional(),parentDeviceId:p().int().nullable().optional(),type:m().optional(),name:m().optional(),stableId:m().optional()}),wz=x({version:p().int(),methods:C(m())}),Tz=x({message:m(),meta:vz.optional(),tags:x({deviceId:p().int().optional()}).optional()}),rSe={"ledger.declare":{input:x({owner:m().min(1),metas:C(Fo)}),output:x({bootId:m(),snapshot:S([`none`,`written`,`refused`]),steps:C(Wo),migrationApi:wz.optional()}),behaviours:[`ledger.declare.answers-steps-in-engine-order`,`ledger.declare.answers-the-migration-api`]},"ledger.start":{input:x({id:m().min(1)}),output:x({proceed:y(),state:l([s(`pending`),Bo]),reason:m().nullable()}),behaviours:[`ledger.start.proceeds-when-predecessors-applied`]},"ledger.finish":{input:x({id:m().min(1),result:zo}),output:x({status:Bo,error:m().nullable(),rowsChanged:p().int().nonnegative()}),behaviours:[`ledger.finish.records-the-outcome`]},"legacyRows.read":{input:yz,output:vz,behaviours:[`legacyRows.read.returns-stored-rows`,`legacyRows.read.absent-store-is-empty`,`legacyRows.caller.sibling-package`]},"legacyRows.clear":{input:yz,output:x({rows:p().int().nonnegative(),secrets:p().int().nonnegative()}),behaviours:[`legacyRows.clear.deletes-the-rows`,`legacyRows.clear.absent-store-is-noop`]},"legacyRows.patch":{input:yz.extend({patch:vz}),output:x({written:y()}),behaviours:[`legacyRows.patch.upserts-keys-and-keeps-the-rest`,`legacyRows.patch.absent-store-writes-nothing`]},"legacyRows.deleteKeys":{input:yz.extend({keys:C(m().min(1))}),output:x({present:y(),removed:vz}),behaviours:[`legacyRows.deleteKeys.removes-the-named-keys`,`legacyRows.deleteKeys.absent-store-reports-not-present`]},"records.get":{input:bz,output:xz.nullable(),behaviours:[`records.get.returns-the-row-or-null`]},"records.getResolved":{input:bz,output:xz.nullable(),behaviours:[`records.getResolved.resolves-secret-fields`]},"records.put":{input:x({...Sz,ifRev:p().int().optional()}),output:x({rev:p().int()}),behaviours:[`records.put.creates-and-replaces`,`records.put.if-rev-conflict-throws`]},"records.putMany":{input:x({records:C(x(Sz))}),output:x({count:p().int().nonnegative()}),behaviours:[`records.putMany.writes-every-row`]},"records.patch":{input:bz.extend({partial:vz,ifRev:p().int().optional()}),output:x({rev:p().int()}),behaviours:[`records.patch.merges-and-null-removes`]},"records.delete":{input:bz,output:x({deleted:y()}),behaviours:[`records.delete.reports-whether-a-row-went`]},"records.query":{input:x({deviceId:p().int().optional(),atFrom:p().optional(),atTo:p().optional(),where:cz.optional(),limit:p().int().min(1).optional(),cursor:m().min(1).optional(),resolveSecrets:y().optional()}),output:x({records:C(xz),nextCursor:m().nullable()}),behaviours:[`records.query.pages-with-a-cursor`,`records.query.filters-on-a-declared-index`]},"records.deleteWhere":{input:x({deviceId:p().int().optional(),atBefore:p().optional(),where:cz.optional()}),output:x({count:p().int().nonnegative()}),behaviours:[`records.deleteWhere.deletes-the-matching-rows`]},"settings.read":{input:x({}),output:x({store:vz}),behaviours:[`settings.read.returns-the-addon-store`]},"settings.write":{input:x({patch:vz}),output:x({}),behaviours:[`settings.write.merges-and-keeps-other-keys`]},"settings.deleteKeys":{input:x({keys:C(m().min(1))}),output:x({removed:C(m())}),behaviours:[`settings.deleteKeys.removes-only-the-named-keys`]},"deviceSettings.listIds":{input:x({}),output:x({deviceIds:C(p().int())}),behaviours:[`deviceSettings.listIds.names-only-the-addons-own-devices`]},"deviceSettings.read":{input:x({deviceIds:C(p().int())}),output:x({blobs:d(m(),vz)}),behaviours:[`deviceSettings.read.returns-only-the-addons-own-blobs`]},"secrets.resolve":{input:x({refs:C(m())}),output:x({values:d(m(),m().nullable())}),behaviours:[`secrets.resolve.answers-null-for-a-missing-ref`]},"secrets.put":{input:x({ref:m().min(1),value:m()}),output:x({}),behaviours:[`secrets.put.stores-under-the-owner`]},"secrets.delete":{input:x({refs:C(m())}),output:x({deleted:p().int().nonnegative()}),behaviours:[`secrets.delete.ignores-unknown-refs`]},"integrations.list":{input:x({}),output:x({integrations:C(Cz)}),behaviours:[`integrations.list.lists-every-integration`]},"integrations.get":{input:x({id:m().min(1)}),output:Cz.nullable(),behaviours:[`integrations.get.null-for-an-unknown-id`]},"devices.list":{input:x({addonId:m().min(1),integrationId:m().min(1).optional()}),output:x({devices:C(nSe)}),behaviours:[`devices.list.scoped-to-the-addon`,`devices.list.filters-by-integration`]},"devices.get":{input:x({deviceId:p().int()}),output:x({id:p().int(),integrationId:m().nullable(),hasConfig:y()}).nullable(),behaviours:[`devices.get.null-for-an-unknown-id`,`devices.get.reports-link-and-config`]},"devices.aliases":{input:x({deviceIds:C(p().int())}),output:x({aliases:d(m(),m())}),behaviours:[`devices.aliases.answers-for-the-named-ids-only`]},"devices.setIntegrationId":{input:x({deviceId:p().int(),integrationId:m().min(1)}),output:x({}),behaviours:[`devices.setIntegrationId.links-the-device`]},"node.localNodeId":{input:x({}),output:x({nodeId:m()}),behaviours:[`node.localNodeId.names-this-node`]},"log.info":{input:Tz,output:x({}),behaviours:[`log.info.writes-a-line`]},"log.warn":{input:Tz,output:x({}),behaviours:[`log.warn.writes-a-line`]}},Ez={name:`migrations`,scope:`system`,mode:`singleton`,internal:!0,methods:{listLedger:E(x({}),x({entries:C(Vo)}),{auth:`admin`}),listPending:E(x({owner:m().optional()}),x({pending:C(Ho)}),{auth:`admin`}),dryRun:E(x({id:m().min(1)}),Uo,{auth:`admin`}),markFailed:E(x({id:m().min(1),error:m().min(1)}),Vo,{kind:`mutation`,auth:`admin`}),retry:E(x({id:m().min(1)}),x({entries:C(Vo)}),{kind:`mutation`,auth:`admin`}),restorePreMigration:E(x({database:jo,snapshotId:m().min(1)}),x({scheduled:y(),held:C(m()),restartRequired:y()}),{kind:`mutation`,auth:`admin`}),declareOwner:E(x({owner:m().min(1),metas:C(Fo),retired:C(m().min(1)).optional()}),x({bootId:m(),snapshot:S([`none`,`written`,`refused`]),steps:C(Wo),migrationApi:wz.optional()}),{kind:`mutation`,auth:`admin`}),startMigration:E(x({id:m().min(1)}),x({proceed:y(),state:l([s(`pending`),Bo]),reason:m().nullable()}),{kind:`mutation`,auth:`admin`}),finishMigration:E(x({id:m().min(1),result:zo}),x({status:Bo,error:m().nullable(),rowsChanged:p().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),readLegacyIntegrationRows:E(x({integrationId:m().min(1)}),d(m(),u()),{auth:`admin`}),clearLegacyIntegrationRows:E(x({integrationId:m().min(1)}),x({rows:p().int().nonnegative(),secrets:p().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),patchLegacyIntegrationRows:E(x({integrationId:m().min(1),patch:d(m(),u())}),x({written:y()}),{kind:`mutation`,auth:`admin`}),deleteLegacyIntegrationRowKeys:E(x({integrationId:m().min(1),keys:C(m().min(1))}),x({present:y(),removed:d(m(),u())}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.INTERNAL}},Dz=x({sourceUrl:m(),metadata:$d,targets:C(Qd).min(1).readonly(),calibrationRef:m().optional(),sessionId:m().optional()}),Oz={name:`model-convert`,scope:`system`,mode:`singleton`,internal:!0,methods:{convert:E(Dz,tf,{kind:`mutation`,auth:`admin`,timeoutMs:6e5})},vocabulary:{notOperatorFacing:O.ML}},kz=x({targetNodeId:m(),modelId:m(),format:S(Rd),entry:Zd}),Az=x({ok:y(),sha256:m(),bytes:p(),path:m()}),jz={name:`model-distributor`,scope:`system`,mode:`singleton`,internal:!0,methods:{distributeModel:E(kz,Az,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.ML}},Mz=a(`kind`,[x({kind:s(`camera`)}),x({kind:s(`sensor`),deviceId:p().int().positive()})]),Nz=Object.freeze({kind:`camera`});function iSe(e){if(e===void 0)return{triggeredBy:Nz,malformed:!1};let t=Mz.safeParse(e);return t.success?{triggeredBy:t.data,malformed:!1}:{triggeredBy:Nz,malformed:!0}}var aSe=`cameraSensors`,Pz=x({addonId:m().min(1),stableId:m().min(1)});function Fz(e){return`${e.addonId}/${e.stableId}`}var Iz=S([`in-addition`,`confirm`,`replace`]),Lz=`in-addition`,Rz=Pz.extend({mode:Iz.default(Lz)}),zz=x({sensors:C(Rz).min(1).max(8)}).superRefine((e,t)=>{let n=new Set;e.sensors.forEach((e,r)=>{let i=Fz(e);n.has(i)&&t.addIssue({code:`custom`,path:[`sensors`,r],message:`duplicate camera sensor ${i}`}),n.add(i)})}),Bz={addonId:m(),stableId:m(),mode:Iz.default(Lz)},Vz=a(`state`,[x({...Bz,state:s(`ready`),deviceId:p(),name:m(),caps:C(m()).readonly()}),x({...Bz,state:s(`offline`),deviceId:p(),name:m(),reason:S([`offline`,`disabled`])}),x({...Bz,state:s(`missing`),reason:m()}),x({...Bz,state:s(`unsupported`),deviceId:p(),name:m(),reason:m()}),x({...Bz,state:s(`unreadable`),reason:m()})]),Hz=S([`onboard-not-listed`,`no-active-detection`]),Uz=S([`always`,`when-confirmed`,`never`]),Wz=S([`provider-not-split`]),Gz=x({detected:y(),atMs:p()}),Kz=a(`state`,[x({state:s(`not-configured`),cameraLevel:Gz.optional()}),x({state:s(`unreadable`),reason:m(),cameraLevel:Gz.optional()}),x({state:s(`configured`),cameraLevel:Gz.optional(),sensors:C(Vz).readonly(),cameraMotion:Uz.optional(),notForwarded:Hz.optional(),notEnforced:Wz.optional()})]),qz=Object.freeze({state:`unreadable`,reason:`camera sensor mappings not loaded`}),Jz=x({bbox:_y,pixelCount:p(),intensity:p()}),Yz=x({detected:y(),regionCount:p(),regions:C(Jz).readonly(),rawRegions:C(Jz).readonly(),frameWidth:p(),frameHeight:p(),analysisMs:p()}),Xz={name:`motion-detection`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[j.Camera],exposesDeviceSettings:!0,methods:{analyze:E(x({deviceId:p(),frame:gy.optional(),frameHandle:hc.optional()}),Yz,{role:`admin`,kind:`mutation`,notOperatorFacing:`the pipeline feeds it frames — an internal stage, never called by a person`}),removeCamera:E(x({deviceId:p()}),v(),{role:`admin`,kind:`mutation`,notOperatorFacing:`pipeline housekeeping when a camera leaves`}),reset:E(v(),v(),{role:`admin`,kind:`mutation`,notOperatorFacing:`pipeline housekeeping`})},events:{onMotion:{data:x({deviceId:p(),detected:y(),regionCount:p()}),notOperatorFacing:"the analyzer’s raw verdict; the operator signal is the `motion` cap’s `detected` state"}},vocabulary:{noun:I(`Motion analysis`,`Analisi del movimento`),order:3160}},Zz=x({package:y(),confidence:p().min(0).max(1),reason:m().min(1)}),Qz=x({x:p(),y:p()}),$z=x({kind:s(`rect`),x:p(),y:p(),width:p(),height:p()}),eB=x({kind:s(`polygon`),points:C(Qz)}),tB=x({kind:s(`grid`),gridWidth:p().meta(k(`none`)),gridHeight:p().meta(k(`none`)),cells:C(y())}),nB=x({kind:s(`line`),points:C(Qz)}),oSe=a(`kind`,[$z,eB,tB,nB]),rB=S([`rect`,`polygon`,`grid`,`line`]),iB=x({min:p(),max:p()}),aB=x({width:p(),height:p()}),oB=[`owner-not-ready`,`store-read-failed`,`three-way-read-unavailable`,`invalid-stored`,`not-cluster-scoped`],sB=[{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)`}]}],sSe=`cluster-step-models`;function cB(e){return`clusterModel:${e}`}function cSe(e){return sB.some(t=>t.stepId===e)}var lB=Object.freeze(Object.fromEntries(sB.map(e=>[e.stepId,e.defaultModelId])));function uB(e){return e==null||e===``?{kind:`absent`}:typeof e==`string`?{kind:`chosen`,modelId:e}:{kind:`invalid`,value:e}}function dB(e){let t=[];for(let n of sB){let r=uB(e[cB(n.stepId)]);r.kind===`invalid`&&t.push({stepId:n.stepId,value:r.value})}return t}function fB(e){let t={};for(let n of sB){let r=uB(e[cB(n.stepId)]);t[n.stepId]=r.kind===`chosen`?r.modelId:n.defaultModelId}return t}function lSe(e){return typeof e==`object`&&!!e&&`key`in e}function pB(e){return e===null?lB:fB(hB(e,mB()))}function uSe(e){return e===null?[]:dB(hB(e,mB()))}function mB(){return new Set(sB.map(e=>cB(e.stepId)))}function hB(e,t){let n={};for(let r of e.sections)for(let e of r.fields)!lSe(e)||typeof e.key!=`string`||t.has(e.key)&&(n[e.key]=e.value);return n}function dSe(e,t){let n=sB.find(t=>t.stepId===e);if(n===void 0)return null;let r=t[e];return r!==void 0&&r!==``?r:n.defaultModelId}var gB=[{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 _B(e,t){return`clusterStepSetting:${e}:${t}`}function vB(e){return gB.filter(t=>t.stepId===e)}var fSe=p().finite();function yB(e){let t={};for(let n of gB){let r=fSe.safeParse(e[_B(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 bB=yB({});function xB(e){return e===null?bB:yB(hB(e,new Set(gB.map(e=>_B(e.stepId,e.key)))))}function pSe(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 SB=S([`new`,`entered`,`left`,`moving`,`idle`]),CB=S([`motion`,`object`,`audio`]),wB=a(`kind`,[$z,eB]),TB=S([`motion`,`audio`,`person`,`vehicle`,`animal`,`door`,`pir`,`smoke`,`water`,`button`,`package`,`generic`]),EB=S([`motion`,`audio`,`detection`,`sensor`,`control`,`custom`,`package`]),mSe=S([`macro`,`sub`]),DB=x({kind:m(),labelKey:m(),label:m(),color:m(),iconId:m(),icon:TB,category:EB,parentKind:m().nullable(),level:mSe,source:x({capName:m(),deviceId:p()})}),OB=x({deviceId:p(),kinds:C(DB).readonly()}),kB=x({id:m(),deviceId:p(),sourceDeviceId:p(),kind:m(),value:d(m(),u()).nullable(),timestamp:p()}),AB=x({x:p(),y:p(),timestamp:p(),bbox:_y,source:S([`frame`,`recovery`]).optional(),score:p().optional()}),hSe=x({timestamp:p(),position:AB,mediaId:p().int()}),jB=x({minX:p(),minY:p(),maxX:p(),maxY:p()}),MB=S([`full`,`slim`]),NB=x({label:m(),peakScore:p(),count:p(),firstAt:p(),lastAt:p()}),PB=S([`pipeline`,`onboard`,`sensor`,`audio`]),FB=S([`none`,`staging`,`trained`]),IB={markForTrain:y().optional(),debug:y().optional(),debugNote:m().max(500).optional(),favourited:y().optional()},LB={retrainStatus:FB.optional()},RB=x(IB),zB=x({trackId:m(),markForTrain:y(),debug:y(),debugNote:m(),favourited:y(),retrainStatus:FB}),gSe=l([s(1),s(2)]),BB=x({stepId:m(),modelId:m().optional(),decidedAt:p(),identityId:m().optional()}),VB={label:m().optional(),labelScore:p().optional(),labelMeta:BB.optional(),subLabel:m().optional(),subLabelScore:p().optional(),subLabelMeta:BB.optional()},HB=x({deviceId:p(),tracks:p().int(),files:p().int(),bytes:p().int()}),UB=x({generatedAt:p(),trackCount:p().int(),fileCount:p().int(),byteCount:p().int(),truncated:y(),devices:C(HB).readonly()}),WB=x({nodeId:m(),deviceKey:m().optional(),modelId:m().optional()}),GB=x({trackId:m(),deviceId:p(),className:m(),...VB,producingDeviceName:m().optional(),source:PB.optional(),firstSeen:p(),lastSeen:p(),positions:C(AB).readonly(),snapshots:C(hSe).readonly(),zonesVisited:C(m()).readonly(),zoneNames:C(m()).readonly().optional(),classes:C(m()).readonly().optional(),totalDistance:p(),state:SB,active:y(),importance:p().optional(),bestEventId:m().optional(),importanceReason:m().optional(),audioLabels:C(NB).readonly().optional(),envelope:jB.optional(),hasFace:y().optional(),hasEmbeddedFace:y().optional(),hasRider:y().optional(),previewMissReason:m().optional(),modelId:m().optional(),openedPlacement:WB.optional(),closedPlacement:WB.optional(),frameWidth:p().optional(),frameHeight:p().optional(),...IB,...LB}),KB={id:p().int(),deviceId:p(),timestamp:p()},qB=x({...KB,kind:s(`motion`),regionCount:p(),regions:C(x({bbox:_y,pixelCount:p(),intensity:p()})).readonly().optional(),frameWidth:p().optional(),frameHeight:p().optional(),mediaUrl:m().optional(),triggeredBy:Mz.optional(),durationMs:p().nullable().optional(),edges:C(p()).readonly().optional()}),JB=S([`pipeline`,`onboard`]),YB=S([`enter`,`exit`]),XB=x({direction:YB,zoneId:m(),zoneName:m().optional()}),_Se=x({zoneId:m(),zoneName:m().optional(),overlapPct:p()}),ZB=x({...KB,kind:s(`object`),source:JB.optional(),frameId:m().optional(),idempotencyKey:m().optional(),trackId:m().optional(),className:m(),...VB,confidence:p().optional(),bbox:_y.optional(),zones:C(m()).readonly().optional(),zoneOverlaps:C(_Se).readonly().optional(),spawnRefused:m().optional(),state:SB.optional(),zoneCrossing:XB.optional(),frameWidth:p().optional(),frameHeight:p().optional(),mediaId:p().int().optional(),keyFrameMediaId:p().int().optional(),mediaUrl:m().optional(),observedAt:p().optional(),packagePossible:y().optional(),packageLlmVerdict:Zz.optional(),importance:p().optional()}),QB=x({...KB,kind:s(`audio`),rms:p(),dbfs:p(),classification:x({className:m(),originalClass:m().optional(),score:p()}).optional(),classifyOutcome:Sy.optional(),mediaUrl:m().optional()}),$B=S([`crop`,`thumbnail`,`snapshot`,`firstFrame`,`lastFrame`,`fullFrame`,`fullFrameBoxed`,`faceCrop`,`plateCrop`,`keyFrame`,`keyFrameSmall`,`thumbnailSmall`,`confirmationCrop`,`debugCrop`,`sceneFrame`,`lastSceneFrame`]),eV=x({mediaId:p().int(),kind:$B,sizeBytes:p(),timestamp:p()}),tV=eV.extend({url:m(),base64:m()}),nV=tV.omit({base64:!0}),rV=S([`person`,`vehicle`,`animal`,`package`,`face`,`plate`]),iV=S([`subject`,`model_error`]),aV=S([`operator`,`assist`,`pipeline`,`llm`]),oV=x({x:p(),y:p(),w:p(),h:p()}),sV=x({source:aV,ref:m().min(1),bbox:oV,macroClass:rV,label:m().optional(),score:p().optional(),modelId:m().optional()}),cV=x({ref:m().min(1),snapshot:sV}),lV=S(_s),uV=x({ref:m(),savedId:m().optional(),status:lV,approximate:y(),origin:sV.optional(),macroClass:rV.optional(),label:m().optional(),iou:p().optional()}),dV=x({boxes:C(uV).readonly(),summary:x({counts:d(lV,p().int()),total:p().int(),changed:p().int(),approximate:y()})}),fV=x({id:m(),trackId:m().optional(),deviceId:p(),mediaKey:m(),bbox:oV,macroClass:rV,label:m().optional(),subLabel:m().optional(),kind:iV,source:aV,assistModelId:m().optional(),assistScore:p().optional(),origin:sV.nullable().optional(),exportedInBatch:m().optional(),createdAt:p()}),pV=fV.omit({id:!0,trackId:!0,deviceId:!0,mediaKey:!0,createdAt:!0,exportedInBatch:!0}),mV=S([`correct`,`wrong`,`wrong-label`]),hV=x({verdict:mV,suggestedClass:m().optional(),suggestedMacroClass:rV.optional(),suggestedLabel:m().optional(),trackId:m(),at:p().optional()}),gV=x({trackId:m(),className:m(),label:m().optional(),bbox:oV.optional(),verdict:mV,suggestedClass:m().optional(),at:p().optional()}),_V=x({trackId:m(),deviceId:p(),className:m(),label:m().optional(),firstSeen:p(),lastSeen:p(),frameCount:p().int(),annotationCount:p().int(),verdict:hV.optional()}),vV=x({mediaId:p().int(),kind:$B,timestamp:p(),sizeBytes:p().int(),copied:y()}),yV=x({bbox:oV,macroClass:rV,label:m().optional(),subLabel:m().optional(),score:p().optional(),modelId:m().optional(),trackId:m(),basis:S([`subject-box`,`position`,`verdict`]),deltaMs:p()}),bV=S([`track`,`recording`]),xV=x({frameId:m(),deviceId:p(),origin:bV,trackId:m().optional(),sourceMediaId:p().int().optional(),epochMs:p().optional(),sourceKind:$B,sizeBytes:p().int(),width:p().int(),height:p().int(),copiedAt:p(),capturedAt:p().optional(),complete:y(),pipelineBoxes:C(yV).readonly().optional(),collectionIds:C(m()).readonly().optional(),verdict:hV.optional(),revision:p().int().optional(),dismissed:C(cV).readonly().optional(),review:dV.optional(),imageUrl:m().optional(),thumbnailUrl:m().optional()}),SV=S([`source-missing`,`unreadable-image`,`write-failed`]),CV=x({copied:C(xV).readonly(),refused:C(x({sourceMediaId:p().int(),reason:SV})).readonly()}),wV=x({candidates:C(vV).readonly(),copies:C(xV).readonly(),autoPickMediaId:p().int().optional()}),TV=S([`unannotated`,`annotated`,`complete`]),EV=x({workState:TV.optional(),deviceIds:C(p()).max(500).optional(),collectionId:m().optional(),classes:C(rV).optional(),page:p().int().positive().default(1),pageSize:p().int().positive().max(100).default(50)}),DV=xV.extend({workState:TV}),OV=x({frames:C(DV).readonly(),total:p().int().nonnegative(),page:p().int().positive(),pageSize:p().int().positive()}),kV=x({deviceId:p(),unannotated:p().int().nonnegative(),annotated:p().int().nonnegative(),complete:p().int().nonnegative(),pctOfCorpus:p().min(0).max(1).nullable()}),AV=x({total:p().int().nonnegative(),unannotated:p().int().nonnegative(),annotated:p().int().nonnegative(),complete:p().int().nonnegative(),cameras:C(kV).readonly()}),jV=x({deviceIds:C(p()).optional(),frameIds:C(m()).max(2e4).optional(),collectionIds:C(m()).max(200).optional(),collectionId:m().optional(),batchId:m().optional(),completeOnly:y().optional(),workState:TV.optional(),classes:C(rV).optional()}),MV=S([`frames`,`crops`]),NV=x({kind:s(`http`),method:S([`PUT`,`POST`]),url:m().url(),headers:d(m(),m()).optional()}),PV=x({batchId:m(),frames:p().int(),crops:p().int(),annotations:p().int(),missing:p().int(),bytes:p().int(),sha256:m(),status:p().int()}),FV=a(`kind`,[x({kind:s(`package`),zone:oV.optional()}),x({kind:s(`objects`),modelId:m(),minScore:p().optional()})]),IV=a(`kind`,[x({kind:s(`proposed`),modelId:m(),stepId:m(),minScore:p(),proposals:C(pV).readonly(),belowThreshold:p().int()}),x({kind:s(`refused`),reason:m(),detail:m().optional()})]),LV=x({id:m(),name:m(),createdAt:p(),frameCount:p().int()}),RV=a(`kind`,[x({kind:s(`created`),collection:LV}),x({kind:s(`refused`),reason:S([`empty-name`,`duplicate-name`])})]),zV=a(`kind`,[x({kind:s(`renamed`),collection:LV}),x({kind:s(`refused`),reason:S([`empty-name`,`duplicate-name`,`unknown-collection`])})]),BV=a(`kind`,[x({kind:s(`added`),collectionId:m(),frame:xV,reused:y()}),x({kind:s(`refused`),reason:S([`unknown-collection`,`still-unavailable`,`still-busy`,`unreadable-image`,`write-failed`]),detail:m().optional()})]),VV=x({id:m(),name:m(),model:m(),kind:m(),leavesHouse:y()}),HV=pV.extend({reason:m()}),UV=x({ref:m(),verdict:S([`confirmed`,`wrong-class`,`not-an-object`,`uncertain`]),suggestedClass:rV.optional(),reason:m()}),WV=a(`kind`,[x({kind:s(`proposed`),profileId:m(),model:m(),leftHouse:y(),proposals:C(HV).readonly(),reviews:C(UV).readonly(),rejected:p().int()}),x({kind:s(`refused`),reason:S([`unknown-frame`,`unreadable-frame`,`unknown-profile`,`profile-disabled`,`no-vision`,`cloud-not-confirmed`,`llm-error`,`malformed-answer`]),detail:m().optional()})]),GV=x({deviceIds:C(p()).readonly().optional(),collectionIds:C(m()).max(200).readonly().optional(),frameIds:C(m()).max(2e4).readonly().optional()}),KV=x({frames:p().int(),completeFrames:p().int(),completeness:p(),subjects:p().int(),modelErrors:p().int(),hardNegatives:p().int(),cells:C(x({macroClass:m(),deviceId:p(),lighting:S([`day`,`night`,`unknown`]),subjects:p().int(),frames:p().int()})).readonly(),cameras:C(x({deviceId:p(),frames:p().int(),completeFrames:p().int()})).readonly()}),vSe=x({id:m(),name:m(),createdAt:p(),selection:GV,layout:MV,completeOnly:y(),frameCount:p().int(),annotationHash:m(),manifestSchema:m(),stats:KV}),qV=x({collectionIds:C(m()).min(1),workState:S([`complete`,`annotated_or_complete`,`any_annotated`]).default(`complete`)}),JV=a(`kind`,[x({kind:s(`resolved`),frameIds:C(m()).max(2e4).readonly(),stats:KV,annotationHash:m(),layout:MV}),x({kind:s(`refused`),reason:S([`unknown-collection`,`no-frames`]),detail:m()})]),YV=x({trackId:m(),retrainStatus:FB,changed:y(),reason:S([`unknown-track`,`no-frames-copied`,`not-staging`,`not-trained`,`unchanged`]).optional()}),XV=1e3,ZV=5e3,QV=x({deviceId:p(),since:p().optional(),until:p().optional(),limit:p().int().min(1).max(ZV).default(XV),projection:S([`full`,`slim`]).optional()}),ySe=QV.extend({classFilter:m().optional()}),$V=x({deviceIds:C(p()),since:p().optional(),until:p().optional(),limit:p().int().min(1).max(1e3).default(200),cursor:m().optional(),projection:MB.optional(),includeStationary:y().optional(),classes:C(m()).optional(),excludeSources:C(PB).optional()}),eH=x({tracks:C(GB).readonly(),nextCursor:m().nullable()}),tH=50,nH=200,bSe=x({deviceId:p(),since:p(),until:p(),limit:p().int().min(1).max(nH).default(tH),minImportance:p().min(0).max(1).optional(),classFilter:m().optional()}),rH=x({id:m(),trackId:m(),timestamp:p(),className:m(),...VB,importance:p(),bestEventId:m(),windowMs:p().optional(),audioLabels:C(NB).readonly().optional(),...IB,...LB}),xSe=x({deviceIds:C(p()).min(1).max(200),since:p(),until:p(),limit:p().int().min(1).max(nH).default(tH),minImportance:p().min(0).max(1).optional(),classFilter:m().optional()}),SSe=x({deviceId:p(),events:C(rH).readonly()}),iH=x({bucketStart:p(),motion:p().int(),object:p().int(),audio:p().int(),audioDbfs:p().optional()}),aH=x({deviceId:p(),read:S([`read`,`unreadable`]),buckets:C(iH).readonly()}),CSe=x({trackId:m(),className:m(),confidence:p(),bbox:_y,zones:C(m()).readonly(),state:SB}),wSe=o({id:m(),kind:S([`first-level`,`detail`]),macroClass:m(),score:p(),bbox:x({x:p(),y:p(),width:p(),height:p()}),labels:C(o({label:m(),score:p()})).readonly(),parentId:m().optional()}),oH=ZB.extend({score:p()}),TSe=x({text:m(),deviceId:p().optional(),since:p().optional(),until:p().optional(),classFilter:m().optional(),limit:p().default(50),minScore:p().min(0).max(1).optional(),strictness:_d.optional(),modelId:m().min(1).optional()}),sH=x({tracks:p().int(),events:p().int(),media:p().int(),faces:p().int(),plates:p().int(),embeddings:p().int()}),ESe=x({mediaDropped:p().int(),tracks:p().int(),events:p().int()}),DSe=x({deviceId:p(),rows:p().int(),bytes:p().int()}),OSe=x({totalRows:p().int(),totalBytes:p().int(),devices:C(DSe).readonly()}),kSe=x({kind:$B,rows:p().int(),bytes:p().int()}),ASe=x({totalRows:p().int(),totalBytes:p().int(),kinds:C(kSe).readonly(),unaccountedRows:p().int(),unaccountedBytes:p().int()}),cH=x({motion:p().int(),object:p().int(),audio:p().int()}),jSe=x({deviceId:p().optional(),since:p().optional(),until:p().optional(),maxTracks:p().int().positive().optional(),executeOnNodeId:m().optional(),pacingMs:p().int().nonnegative().optional(),force:y().optional()}),MSe=x({deleted:p(),failedIndexes:C(m()).optional()}),lH=S([`stores-unavailable`,...oB,`method-unavailable`,`read-failed`,`reads-disagree`,`not-a-clip-model`,`force-requires-max-tracks`]),NSe=x({started:y(),alreadyRunning:y(),refusal:lH.optional(),modelId:m().optional(),index:m().optional()}),PSe=x({running:y(),scanned:p(),rebuilt:p(),missingKeyFrame:p(),missingEvent:p(),missingBbox:p(),boxSource:x({subjectBox:p(),positions:p(),event:p(),refused:p()}),alreadyInSpace:p(),force:y().nullable(),forcedInSpace:p(),notRunnable:p(),noCapableNode:p(),failed:p(),complete:y().nullable(),startedAtMs:p().nullable(),finishedAtMs:p().nullable(),error:m().nullable(),modelId:m().nullable(),index:m().nullable()}),FSe=x({started:y(),alreadyRunning:y()}),ISe=x({mode:S([`report`,`reclaim`]).default(`report`),scopes:C(S([`motion-still`,`track-filmstrip`])).min(1).optional(),deviceIds:C(p().int()).min(1).optional(),restart:y().optional(),pageSize:p().int().min(50).max(5e3).optional(),maxRowsPerDevice:p().int().min(1).max(5e5).optional(),maxReclaimPerDevice:p().int().min(1).max(5e5).optional(),maxBytesPerRun:p().int().min(1).optional(),budgetMinutes:p().int().min(1).max(720).optional(),throttleBytesPerSec:p().int().min(64*1024).optional(),graceMinutes:p().int().min(1).max(10080).optional()}),LSe=x({running:y(),mode:S([`report`,`reclaim`]).nullable(),totalExamined:p(),totalEligible:p(),totalReclaimed:p(),totalBytesReclaimed:p(),totalRefused:p(),devicesDone:p(),complete:y().nullable(),startedAtMs:p().nullable(),finishedAtMs:p().nullable(),error:m().nullable()}),uH=S([`motion`,`audio-dbfs`,`battery`,`occupancy`]);function RSe(e,t){let n=e??``;return t===void 0?n:`${n}|${t}`}function dH(e){let t=e.indexOf(`|`);return t<0?{zoneId:e}:{zoneId:e.slice(0,t),className:e.slice(t+1)}}var fH=x({scope:m(),bucketStart:p().int(),samples:p().int().nonnegative(),sum:p(),min:p(),max:p()}),pH={name:`pipeline-analytics`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[j.Camera],exposesDeviceSettings:!0,methods:{getActiveTracks:E(x({deviceId:p()}),C(GB).readonly()),getTrack:E(x({deviceId:p(),trackId:m()}),GB.nullable()),listTracks:E(x({deviceId:p(),since:p().optional(),until:p().optional(),limit:p().optional(),zone:wB.optional(),projection:MB.optional(),includeStationary:y().optional(),classes:C(m()).optional(),excludeSources:C(PB).optional()}),C(GB).readonly()),listRecentTracks:E($V,eH),clearTracks:E(x({deviceId:p()}),v(),{kind:`mutation`,auth:`admin`}),getMotionEvents:E(QV,C(qB).readonly()),getObjectEvents:E(ySe,C(ZB).readonly()),getAudioEvents:E(QV,C(QB).readonly()),listEventKinds:E(x({deviceId:p()}),C(DB).readonly()),listEventKindsBatch:E(x({deviceIds:C(p()).min(1).max(200)}),C(OB).readonly()),getSensorEvents:E(x({deviceId:p(),since:p().optional(),until:p().optional(),kinds:C(m()).optional(),limit:p().int().min(1).max(ZV).default(XV)}),C(kB).readonly()),getKeyEvents:E(bSe,C(rH).readonly()),getKeyEventsBatch:E(xSe,C(SSe).readonly()),readLongTermSeries:E(x({deviceId:p(),series:uH,scope:m().optional(),from:p(),to:p(),limit:p().int().positive().optional()}),C(fH).readonly()),getEventDensity:E(x({deviceId:p(),since:p(),until:p(),bucketMs:p().int().positive()}),C(iH).readonly()),getEventDensityBatch:E(x({deviceIds:C(p()).min(1).max(200),since:p(),until:p(),bucketMs:p().int().positive()}),C(aH).readonly()),pruneEventsBefore:E(x({deviceId:p(),cutoffMs:p()}),x({motion:p().int(),object:p().int(),audio:p().int()}),{kind:`mutation`,auth:`admin`}),pruneTracksBefore:E(x({deviceId:p(),cutoffMs:p()}),sH,{kind:`mutation`,auth:`admin`}),wipeAllAnalytics:E(x({deviceId:p()}),sH,{kind:`mutation`,auth:`admin`}),reconcileFromDisk:E(x({deviceId:p()}),ESe,{kind:`mutation`,auth:`admin`}),deleteTracks:E(x({deviceId:p(),trackIds:C(m()).min(1)}),x({deleted:p().int(),failed:C(m()).readonly(),sparedMediaIds:C(p().int()).readonly().optional()}),{kind:`mutation`,auth:`admin`}),setTrackFlags:E(x({deviceId:p(),trackId:m(),flags:RB}),zB,{kind:`mutation`,notOperatorFacing:`curating a recorded track in the review UI, not a live step`}),listArchivedDebugNotes:E(Os,C(Ds).readonly(),{kind:`query`}),setTrackRelation:E(Ps,Ms,{kind:`mutation`,notOperatorFacing:`curating recorded tracks in the review UI, not a live step`}),clearTrackRelation:E(Fs,Is,{kind:`mutation`,notOperatorFacing:`curating recorded tracks in the review UI, not a live step`}),setTrackPurity:E(Ls,Rs,{kind:`mutation`,notOperatorFacing:`curating a recorded track in the review UI, not a live step`}),listTrackRelations:E(zs,Bs,{kind:`query`}),listBirthDecisions:E(Es,C(Ts).readonly(),{kind:`query`}),getEventStoreFootprint:E(x({}),OSe,{kind:`query`,auth:`admin`}),getEventMediaFootprintByKind:E(x({deviceId:p().int().optional()}),ASe,{kind:`query`,auth:`admin`}),pruneEvents:E(x({olderThanMs:p(),reason:Js.optional()}),cH,{kind:`mutation`,auth:`admin`}),deleteDeviceEvents:E(x({deviceId:p()}),cH,{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:E(Xc,x({paused:s(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:E(Xc,x({resumed:s(!0)}),{kind:`mutation`,auth:`admin`}),refreshStorageLocationsForMigration:E(Xc,x({refreshed:s(!0)}),{kind:`mutation`,auth:`admin`}),startStorageMigrationMove:E(al,x({jobId:m()}),{kind:`mutation`,auth:`admin`}),getStorageMigrationMoveStatus:E(x({jobId:m()}),qc.nullable(),{auth:`admin`}),cancelStorageMigrationMove:E(x({jobId:m()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),relocateMedia:E($c,x({jobId:m()}),{kind:`mutation`,auth:`admin`}),countUnstampedEventMedia:E(x({}),tl,{auth:`admin`}),getMediaLocationCensus:E(nl,il,{kind:`query`,auth:`admin`}),countRelocatableMedia:E(jl,Al,{kind:`query`,auth:`admin`}),listRelocateMediaJobs:E(x({}),C(qc).readonly(),{kind:`query`,auth:`admin`}),cancelRelocateMedia:E(x({jobId:m()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),listOpsLog:E(Xs,C(Ys).readonly(),{kind:`query`,auth:`admin`}),reclaimDebugMedia:E(ISe,FSe,{kind:`mutation`,auth:`admin`}),getMediaReclaimStatus:E(x({}),LSe,{kind:`query`,auth:`admin`}),getTrainingExportSummary:E(x({deviceIds:C(p()).optional()}),UB,{kind:`query`,auth:`admin`}),getTrainingExportUrl:E(x({deviceIds:C(p()).optional()}),x({url:m()}),{kind:`query`,auth:`admin`}),listRetrainStaging:E(x({deviceIds:C(p()).optional(),limit:p().int().min(1).max(500).optional()}),C(_V).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),listRetrainCorpusPage:E(EV,OV,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),getRetrainCorpusKpi:E(x({}),AV,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),listRetrainFrames:E(x({trackId:m()}),wV,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),selectRetrainFrames:E(x({deviceId:p(),trackId:m(),mediaIds:C(p().int()).min(1)}),CV,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),deselectRetrainFrame:E(x({deviceId:p(),trackId:m().optional(),frameId:m()}),x({removed:y(),removedAnnotations:p().int()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),getRetrainFrameImage:E(x({frameId:m()}),x({base64:m(),width:p().int(),height:p().int()}),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),proposeRetrainAnnotations:E(x({deviceId:p(),trackId:m().optional(),frameId:m(),subject:FV,nodeId:m().optional()}),IV,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainAnnotations:E(x({trackId:m().optional(),frameIds:C(m()).max(2e3).optional()}),C(fV).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),saveRetrainAnnotations:E(x({deviceId:p(),trackId:m().optional(),frameId:m(),annotations:C(pV),expectedRevision:p().int().optional(),dismissed:C(cV).optional()}),C(fV).readonly(),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),backfillRetrainOrigins:E(x({deviceId:p(),trackId:m().optional(),frameId:m(),expectedRevision:p().int().optional(),origins:C(x({annotationId:m(),origin:sV})).min(1).max(500)}),x({updated:p().int(),skipped:p().int(),revision:p().int()}),{kind:`mutation`,auth:`admin`}),completeRetrainTrack:E(x({deviceId:p(),trackId:m()}),YV,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),restageRetrainTrack:E(x({deviceId:p(),trackId:m()}),YV,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),getRetrainExportUrl:E(jV.extend({layout:MV.optional()}),x({url:m()}),{kind:`query`,auth:`admin`}),setRetrainFrameComplete:E(x({deviceId:p(),trackId:m().optional(),frameId:m(),complete:y()}),xV,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),writeRetrainArchive:E(x({filter:jV,layout:MV,target:NV}),PV,{kind:`mutation`,auth:`admin`,timeoutMs:60*6e4}),offerRetrainArchive:E(x({filter:jV,layout:MV}),x({ticket:Ja,frames:p().int(),annotations:p().int()}),{kind:`mutation`,auth:`admin`,timeoutMs:12e4}),listRetrainAssistProfiles:E(x({}),C(VV).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),proposeRetrainAnnotationsWithLlm:E(x({deviceId:p(),trackId:m().optional(),frameId:m(),profileId:m(),classes:C(rV).min(1),boxes:C(x({ref:m(),bbox:oV,macroClass:rV,label:m().optional()})).max(50),allowCloud:y()}),WV,{kind:`mutation`,auth:`admin`,timeoutMs:18e4}),createRetrainCollection:E(x({name:m().max(120)}),RV,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainCollections:E(x({}),C(LV).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),resolveRetrainTrainingCorpus:E(qV,JV,{kind:`query`,auth:`admin`,timeoutMs:6e4}),renameRetrainCollection:E(x({id:m(),name:m().max(120)}),zV,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),deleteRetrainCollection:E(x({id:m()}),x({deleted:y(),removedFrames:p().int()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),addRetrainFrameFromRecording:E(x({collectionId:m(),deviceId:p(),epochMs:p(),verdictSubject:gV.optional()}),BV,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`,timeoutMs:6e4}),addRetrainFramesToCollection:E(x({collectionId:m(),frameIds:C(m()).min(1).max(500)}),x({added:p().int(),alreadyMember:p().int(),unknownFrameIds:C(m()).readonly()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),removeRetrainFrameFromCollection:E(x({collectionId:m(),frameId:m()}),x({removed:y(),deletedFrame:y()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainCollectionFrames:E(x({collectionId:m()}),C(xV).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),getEventMedia:E(x({ownerType:Je,eventId:p().int(),kind:$B.optional(),deviceId:p()}),C(tV).readonly()),getTrackMedia:E(x({trackId:m(),kinds:C($B).optional(),deviceId:p()}),C(tV).readonly()),listTrackMedia:E(x({trackId:m(),deviceId:p()}),C(nV).readonly()),listEventMedia:E(x({ownerType:Je,eventId:p().int(),deviceId:p()}),C(nV).readonly()),ownersWithMedia:E(x({deviceId:p(),ownerKind:Xe,ownerIds:C(m()).max(5e3)}),C(m()).readonly()),searchObjectEvents:E(TSe,C(oH).readonly(),{caller:`required`}),wipeObjectEmbeddings:E(x({}),MSe,{kind:`mutation`,auth:`admin`}),rebuildObjectEmbeddings:E(jSe,NSe,{kind:`mutation`,auth:`admin`}),getObjectEmbeddingRebuildStatus:E(x({}),PSe)},events:{onFrameTracked:{data:x({deviceId:p(),timestamp:p(),frameWidth:p(),frameHeight:p(),detections:C(wSe).readonly()}),notOperatorFacing:`one tracker frame — stream rate, never an automation trigger`},onTrackStarted:{data:x({deviceId:p(),trackId:m(),className:m()}),trigger:{category:w.PipelineAnalyticsTrackStarted,label:I(`Subject appeared`,`Soggetto comparso`),phrase:I(`When {device} starts following a subject`,`Quando {device} inizia a seguire un soggetto`),icon:`scan-eye`}},onTrackEnded:{data:x({deviceId:p(),trackId:m(),className:m(),durationMs:p()}),trigger:{category:w.PipelineAnalyticsTrackEnded,label:I(`Subject left`,`Soggetto uscito`),phrase:I(`When a subject leaves the view of {device}`,`Quando un soggetto esce dall’inquadratura di {device}`),icon:`scan-eye`}},onDetectionEvent:{data:x({deviceId:p(),kind:CB,eventId:m(),timestamp:p()}),trigger:{category:w.PipelineAnalyticsDetectionEvent,label:I(`Detection event`,`Evento di rilevamento`),phrase:I(`When {device} records a detection event`,`Quando {device} registra un evento di rilevamento`),icon:`radar`}}},vocabulary:{noun:I(`Tracking`,`Tracciamento`),order:3200,extraEvents:[{category:w.PipelineAnalyticsPackageDelivered,label:I(`Package delivered`,`Pacco consegnato`),phrase:I(`When a package is left in front of {device}`,`Quando viene lasciato un pacco davanti a {device}`),icon:`package`},{category:w.PipelineAnalyticsPackagePickedUp,label:I(`Package picked up`,`Pacco ritirato`),phrase:I(`When a package is picked up in front of {device}`,`Quando viene ritirato un pacco davanti a {device}`),icon:`package-open`}]}},mH=_(()=>x({addonId:m(),modelId:m().optional(),enabled:y().default(!0),children:C(mH).optional(),settings:d(m(),u()).optional(),jumpDeviceKey:m().optional()})),hH=_e(),gH=x({stepId:m(),modelId:m(),detections:C(x({bbox:c([p(),p(),p(),p()]),score:p(),landmarks:C(x({x:p(),y:p()})).optional()})).min(1)}),_H=x({handle:hc,cropFrameSpace:x({x:p(),y:p(),w:p(),h:p()})});x({crop:x({left:p(),top:p(),width:p().positive(),height:p().positive()}).optional(),content:x({width:p().int().positive(),height:p().int().positive()}),fit:S([`stretch`,`contain`]),format:S([`rgb`,`gray`,`jpeg`])});var zSe=x({registryId:m().min(1),id:m().min(1),width:p().int().positive(),height:p().int().positive(),format:S([`rgb`,`gray`]),timestamp:p(),capturedAt:p().optional()}),vH=S([`onnx`,`coreml`,`openvino`,`tflite`,`pt`,`gguf`]),yH=S([`detector`,`cropper`,`classifier`,`refiner`,`audio-classifier`]),bH=x({runtime:s(`python`),backend:m(),format:vH,device:m().optional()}),xH=x({deviceKey:m().nullable(),runtime:m(),batchMode:m(),windowMs:p(),maxBatchSize:p(),concurrency:p(),numWorkers:p()}),BSe=x({engine:bH,devices:C(x({id:m(),label:m(),description:m().optional()})).readonly(),defaultDevice:m()}),SH=_(()=>x({addonId:m(),addonName:m(),slot:yH,inputClasses:C(m()).readonly(),outputClasses:C(m()).readonly(),enabled:y(),modelId:m(),children:C(SH).readonly(),group:m().optional(),settings:d(m(),u()).optional()})),VSe=x({id:m(),name:m(),formats:d(m(),Hd),group:Gd.optional(),legacy:y().optional(),provider:qd.optional(),defaultConfidence:p().optional(),suppliesSteps:C(Xd).readonly().optional()}),HSe=_e(),USe=x({id:m(),name:m(),slot:yH,inputClasses:C(m()).readonly(),outputClasses:C(m()).readonly(),childSlots:C(yH).readonly(),models:C(VSe).readonly(),defaultModelId:m(),defaultModelIdByFormat:d(m(),m()).optional(),enabledByDefault:y().optional(),defaultConfidence:p(),group:m().optional(),configSchema:C(HSe).readonly().optional()}),WSe=x({id:yH,label:m(),priority:p(),parentSlot:yH.nullable(),addons:C(USe).readonly()}),GSe=x({availableEngines:C(BSe).readonly(),selectedEngine:bH,slots:C(WSe).readonly()}),KSe=x({runtimeId:S([`onnx`,`openvino`,`coreml`,`edgetpu`]).nullable(),device:m().nullable(),state:S([`idle`,`installing`,`verifying`,`ready`,`failed`]),progress:p().optional(),error:m().optional(),nextRetryAt:p().optional(),configIssues:C(m()).optional()}),CH=x({addonId:m(),chosen:m(),running:m(),format:m()}),wH=x({addonId:m(),kind:S([`unknown-addon`,`no-format-build`,`unknown-device`]),detail:m()}),TH=x({ok:y(),issues:C(wH).readonly(),substitutions:C(CH).readonly(),format:m()}),qSe=x({filename:m(),stepIds:C(m()).readonly().optional()}),JSe=x({base64:m(),filename:m()}),YSe=x({filename:m(),sizeKb:p()}),XSe=x({base64:m()}),ZSe=x({id:m(),name:m(),description:m(),available:y(),rawLabels:C(m()).readonly().optional()}),QSe=x({activeBackend:m(),availableBackends:C(ZSe).readonly(),sampleRate:p(),chunkDurationMs:p()}),$Se=x({filePath:m(),sizeMB:p(),durationMs:p()}),eCe=x({success:y(),error:m().optional(),frame:_e().optional()}),tCe=_e(),nCe=_e(),rCe=_e(),iCe=_e(),EH={name:`pipeline-executor`,scope:`system`,mode:`singleton`,methods:{getAvailableEngines:E(v(),C(bH)),getSelectedEngine:E(v(),bH),getEngineProvisioning:E(x({nodeId:m()}),KSe),getVideoPipelineSteps:E(v(),d(m(),x({modelId:m(),settings:d(m(),u()).readonly()}))),setVideoPipelineSteps:E(x({steps:d(m(),x({modelId:m(),settings:d(m(),u()).readonly()}))}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),getInferenceDeviceHealth:E(x({nodeId:m()}),x({unhealthy:C(x({deviceKey:m(),state:S([`failed`,`backoff`]),since:p(),deaths:p(),lastError:m()})).readonly()})),rearmInferenceDevice:E(x({nodeId:m(),deviceKey:m()}),x({rearmed:y()}),{kind:`mutation`,auth:`admin`}),getSchema:E(v(),GSe),getOrchestratorConfigSchema:E(v(),tCe),validatePipeline:E(x({steps:C(mH),deviceKey:m().optional()}),TH),getCapabilities:E(v(),rCe),getAddonModels:E(x({addonId:m()}),iCe),downloadModel:E(x({addonId:m(),modelId:m(),format:vH}),$Se,{kind:`mutation`}),deleteModel:E(x({addonId:m(),modelId:m(),format:vH}),x({success:s(!0)}),{kind:`mutation`}),runPipeline:E(x({steps:C(mH).min(1),frame:gy.optional(),frameRef:zSe.optional(),frameHandle:hc.optional(),imageBase64:m().optional(),image:b(Uint8Array).optional(),referenceImage:m().optional(),deviceId:p().optional(),sessionId:m().optional(),plane:S([`full`,`frame`]).optional(),deviceKey:m().optional(),nativeCropRef:_H.optional(),replay:s(!0).optional(),suppliedRoot:gH.optional()}),hH,{kind:`mutation`}),runPipelineBatch:E(x({steps:C(mH).min(1),frames:C(gy).min(1).max(255),deviceId:p().optional(),sessionId:m().optional(),frameId:p().int().nonnegative().optional(),deviceKey:m().optional()}),x({results:C(hH).readonly()}),{kind:`mutation`}),cacheFrameInPool:E(x({data:b(Uint8Array),width:p().int().positive(),height:p().int().positive(),format:S([`rgb`,`bgr`,`gray`])}),x({frameId:p(),width:p(),height:p()}),{kind:`mutation`}),inferCached:E(x({stepId:m(),frameId:p().int(),modelId:m().min(1)}),d(m(),u()),{kind:`mutation`}),uncacheFrame:E(x({frameId:p().int()}),v(),{kind:`mutation`}),getEffectiveTuning:E(x({deviceKey:m().optional()}),xH),listLoadedEngines:E(v(),C(x({engineKey:m(),engine:bH,modelsLoaded:C(m()).readonly(),inUseByCameras:C(p()).readonly(),kind:S([`runtime`,`device-pool`]),poolPid:p().nullable(),idleMs:p().nullable(),idleTtlMs:p().nullable()})).readonly()),spinEngine:E(x({engine:bH}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),killEngine:E(x({engine:bH,force:y().optional()}),x({success:y(),reason:m().optional()}),{kind:`mutation`,auth:`admin`}),listReferenceImages:E(v(),C(qSe).readonly()),getReferenceImage:E(x({filename:m()}),JSe.nullable()),getReferenceAudioFiles:E(v(),C(YSe).readonly()),getReferenceAudio:E(x({filename:m()}),XSe.nullable()),getAudioCapabilities:E(v(),QSe),runAudioTest:E(x({addonId:m(),modelId:m(),filename:m().optional(),settings:d(m(),u()).optional()}),eCe,{kind:`mutation`}),getDetectionConfigSchema:E(v(),nCe)},vocabulary:{notOperatorFacing:O.PIPELINE}},aCe=x({activeCameras:p(),throttledCameras:p(),avgInferenceTimeMs:p(),queueDepth:p()}),DH=x({detectionMode:S([`disabled`,`always-on`,`on-motion`]),configuredFps:p(),actualFps:p(),queueDepth:p(),avgInferenceTimeMs:p(),droppedFrames:p(),nativeCropMisses:p().optional(),phase:S([`idle`,`watching`,`active`])}),OH=DH.extend({deviceId:p()}),kH=S([`polygon`,`tripwire`]),AH=x({x:p(),y:p()}),jH=x({id:m(),name:m(),kind:kH.default(`polygon`),polygon:C(AH).readonly(),color:m().default(`#3b82f6`)}),MH={name:`zones`,scope:`device`,mode:`singleton`,deviceTypes:[j.Camera],methods:{listZones:E(x({deviceId:p()}),C(jH).readonly()),addZone:E(x({deviceId:p(),zone:jH}),v(),{kind:`mutation`,auth:`admin`}),removeZone:E(x({deviceId:p(),zoneId:m()}),v(),{kind:`mutation`,auth:`admin`}),updateZone:E(x({deviceId:p(),zone:jH}),v(),{kind:`mutation`,auth:`admin`})},runtimeState:x({zones:C(jH).readonly()}),durability:`restored`,history:`none`,vocabulary:{noun:I(`Zones`,`Zone`),order:3370}},NH={fpsPerStream:10,budgetMinutes:45,minBudgetMinutes:10,maxBudgetMinutes:120,staleAfterDays:30,settleSec:5,measureSec:20,drainTimeoutSec:120,maxModelsPerDevice:6},PH=S([`device`,`pipeline`]),FH=x({deviceKey:m().min(1),modelIds:C(m().min(1)).min(1).max(NH.maxModelsPerDevice)}),IH=x({nodeId:m().min(1),devices:C(FH).min(1),phases:C(PH).min(1).default([`device`,`pipeline`]),steps:C(m().min(1)).default([]),fpsPerStream:p().int().min(1).max(30).default(NH.fpsPerStream),budgetMinutes:p().int().min(NH.minBudgetMinutes).max(NH.maxBudgetMinutes).default(NH.budgetMinutes),keepDownloadedModels:y().default(!1),acceptInsufficientHeadroom:y().default(!1)}),LH=S([`benchmark-active`,`node-offline`,`unknown-device`,`no-phase`,`insufficient-headroom`]),RH=x({kind:LH,detail:m(),overridable:y()}),zH=x({deviceId:p(),placedOnNode:y(),pinnedToNode:y()}),BH=x({deviceId:p(),reason:s(`only-frame-source`)}),VH=x({nodeId:m(),online:y(),moving:C(zH).readonly(),staying:C(BH).readonly(),estimatedDurationMs:p(),budgetMs:p(),phases:C(PH).readonly(),steps:C(m()).readonly(),devices:C(FH).readonly(),headroom:x({sessionsNow:p(),otherNodesCapacitySessions:p().nullable()}),refusals:C(RH).readonly(),canStart:y()}),HH=x({phase:S([`preparing`,`device`,`pipeline`,`cleanup`]),deviceKey:m().nullable(),modelId:m().nullable(),load:p().nullable(),cellsDone:p(),cellsTotal:p(),message:m()}),UH=S([`p95`,`drops`,`errors`,`stall`,`cpu`,`ram`,`none`]),WH=x({load:p(),pass:y(),p95Ms:p(),dropRatio:p(),fps:p(),cpuPct:p().nullable(),ramFreePct:p().nullable(),failReasons:C(m()).readonly()}),GH=x({phase:s(`device`),deviceKey:m(),modelId:m(),p50Ms:p(),p95Ms:p(),p99Ms:p(),fps:p(),kMax:p(),limitedBy:UH,warmupMs:p(),ramp:C(WH).readonly()}),KH=x({phase:s(`pipeline`),deviceKey:m(),modelId:m(),steps:C(m()).readonly(),maxSessions:p(),limitedBy:UH,stepsFired:C(m()).readonly(),warmupMs:p(),ramp:C(WH).readonly()}),qH=a(`phase`,[GH,KH]),JH=x({pipelineVersion:m().nullable(),cpuModel:m().nullable(),ramGb:p().nullable(),os:m().nullable(),pools:d(m(),x({runtime:m(),numWorkers:p(),concurrency:p(),batchMode:m()})).default({})}),YH=x({id:m(),revision:m().nullable(),frames:p(),width:p(),height:p()}),XH=x({runId:m().min(1),devices:C(FH).min(1),phases:C(PH).min(1),steps:C(m()).default([]),fpsPerStream:p().int().min(1).max(30),deadlineAtMs:p(),settleSec:p().min(0).max(60).default(NH.settleSec),measureSec:p().min(2).max(300).default(NH.measureSec),keepDownloadedModels:y().default(!1)}),ZH=S([`running`,`done`,`failed`,`aborted`]),QH=x({runId:m(),nodeId:m(),state:ZH,progress:HH.nullable(),cells:C(qH).readonly(),fingerprint:JH.nullable(),clip:YH.nullable(),activeCameraIds:C(p()).readonly(),deletedModels:C(m()).readonly(),error:m().nullable(),startedAtMs:p(),finishedAtMs:p().nullable()}),$H=S([`draining`,`measuring`,`restoring`,`done`,`failed`,`aborted`]),eU=S([`completed`,`operator-abort`,`deadline`,`node-lost`,`runner-lost`,`hub-restart`,`drain-timeout`,`failed`]),tU=x({runId:m(),nodeId:m(),state:$H,plan:IH,startedAtMs:p(),deadlineAtMs:p(),finishedAtMs:p().nullable(),endReason:eU.nullable(),error:m().nullable(),moved:C(p()).readonly(),staying:C(p()).readonly(),contaminated:y(),progress:HH.nullable(),resultIds:C(m()).readonly()}),nU=x({modeNodeId:m().nullable(),run:tU.nullable()}),rU=x({id:m(),runId:m(),nodeId:m(),cell:qH,fpsPerStream:p(),fingerprint:JH.nullable(),clip:YH.nullable(),contaminated:y(),stayingCameras:C(p()).readonly(),partialRun:y(),measuredAtMs:p()}),iU=x({nodeId:m().optional(),deviceKey:m().optional()}),aU=rU.extend({standing:S([`fresh`,`stale`,`superseded`]),staleWhy:S([`age`,`runtime`,`pool-tuning`]).nullable()}),oCe=x({runId:m(),nodeId:m(),startedAtMs:p(),deadlineAtMs:p(),plan:IH,moved:C(p()).readonly(),staying:C(p()).readonly()}),oU=x({nodeId:m(),reachable:y(),devices:C(x({deviceKey:m(),enabled:y(),available:y(),suggested:C(m()).readonly(),all:C(m()).readonly(),currentModelId:m().nullable()})).readonly(),steps:C(x({id:m(),name:m(),slot:m()})).readonly()}),sU=x({x:p(),y:p(),w:p(),h:p()}),cU=x({bytes:b(Uint8Array).optional(),jpeg:m().optional(),jpegBytes:b(Uint8Array).optional(),width:p().int().positive(),height:p().int().positive(),tier:S([`native`,`ram-fullframe`]).optional()}),lU=S([`keyFrame`,`thumbnail`]),uU=S([`handle-gone`,`encode-failed`]),dU=a(`parked`,[x({parked:s(!0),nodeId:m(),width:p().int().positive(),height:p().int().positive(),bytes:p().int().nonnegative(),replaced:y()}),x({parked:s(!1),nodeId:m(),reason:uU,handleAgeMs:p().nullable(),detail:m().optional()})]),fU=x({jpeg:m().optional(),jpegBytes:b(Uint8Array).optional(),width:p().int().positive(),height:p().int().positive(),timestamp:p(),parkedAt:p()}),sCe=x({bbox:sU,className:m()}),pU=x({stepId:m(),className:m(),score:p(),bbox:sU.optional(),embedding:m().optional(),embeddingMagnitude:p().optional(),embeddingModelId:m().optional(),label:m().optional(),labelTier:l([s(1),s(2)]).optional(),labelModelId:m().optional(),alignedCropJpeg:m().optional(),nativeFaceShortSidePx:p().optional(),landmarks:C(x({x:p(),y:p()})).optional()}),cCe=S([`unknown-step`,`model-not-servable`,`unreadable-frame`,`execution-failed`]),lCe=a(`kind`,[x({kind:s(`ran`),nodeId:m(),modelId:m(),details:C(pU)}),x({kind:s(`refused`),nodeId:m(),reason:cCe,detail:m()})]),mU={min:0,max:6e4,default:3e4,step:500},hU={min:0,max:6e5,default:12e4,step:5e3},gU={min:5e3,max:6e5,default:9e4,step:5e3},_U={min:1,max:30,default:4,step:1},vU={min:1,max:30,default:10,step:1},yU={min:0,max:300,default:300,step:5},bU={min:1,max:10,default:4,step:1},xU={min:0,max:30,default:12,step:1},SU=S([`onboard`,`analyzer`,`device-activity`]),CU=x({source:SU,triggeredBy:Mz,sensorName:m().optional()}),wU=C(SU),TU={analyzer:`Frame-diff Analyzer (motion addon)`,onboard:`Camera sensors`,"device-activity":`Device activity (the device says it is working)`};function EU(e){let t=SU.safeParse(e);return t.success?TU[t.data]:e}var uCe=[`analyzer`,`onboard`,`device-activity`],DU=oe(e=>Array.isArray(e)&&e.length>1?e.slice(0,1):e,C(JB).max(1)),OU=x({deviceId:p(),detected:y(),source:SU.default(`analyzer`),regions:C(Jz).readonly().optional()}),kU=a(`kind`,[x({kind:s(`local-broker`)}),x({kind:s(`remote-restream`),ownerNodeId:m(),ownerReachableHost:m().optional(),hubHostnameOverride:m().optional()})]).describe(`Per-camera frame-source mode for the runner (P2c)`),AU=x({modelId:m().optional(),settings:d(m(),u()).optional()}),jU=x({deviceKey:m(),weight:p().positive().default(1),maxSessions:p().int().positive().nullable().default(null),steps:d(m(),AU).optional()}),MU=x({deviceId:p(),detectionMode:S([`disabled`,`always-on`,`on-motion`]).default(`on-motion`),audioMode:S([`disabled`,`always-on`,`on-motion`]).default(`always-on`),motionCooldownMs:p().min(mU.min).default(mU.default),maxSessionHoldMs:p().min(hU.min).max(hU.max).optional(),audioMotionWindowMs:p().min(gU.min).max(gU.max).optional(),motionFps:p().min(_U.min).max(_U.max).default(_U.default),detectionFps:p().min(vU.min).max(vU.max).default(vU.default),motionStreamId:m(),detectionStreamId:m(),audioStreamPick:oc.optional(),motionSources:wU.default([`analyzer`]),sessionTrigger:CU.optional(),detectionSources:DU.default([`pipeline`]),pipelineEnabled:y().default(!0),steps:C(mH).readonly().optional(),audio:x({modelId:m().optional(),enabled:y()}).nullable().optional(),zones:C(jH).readonly().default([]),onboardMotionDrivesAnalyzer:y().default(!0),preRollInferenceEnabled:y().default(!0),preRollInferenceFrames:p().min(xU.min).max(xU.max).default(xU.default),occupancyRecheckEnabled:y().default(!0),occupancyRecheckSec:p().min(yU.min).max(yU.max).default(yU.default),occupancyRecheckFrames:p().min(bU.min).max(bU.max).default(bU.default),frameSource:kU.default({kind:`local-broker`}),deviceKey:m().optional(),inferenceDevices:C(jU).readonly().optional()}),dCe=[{key:`motionSources`,type:`multiselect`,label:`Motion Sources`,default:[`analyzer`],options:uCe.map(e=>e===`onboard`?{value:e,label:TU[e],description:`The camera's own motion, plus any sensor attached to it`}:{value:e,label:TU[e]})},{key:`motionFps`,type:`slider`,label:`Motion FPS (analyzer)`,min:_U.min,max:_U.max,step:_U.step,default:_U.default,showValue:!0,unit:`fps`,nullable:!0,nullLabel:`Default`,showWhen:{field:`motionSources`,includes:`analyzer`}},{key:`detectionFps`,type:`slider`,label:`Detection FPS`,min:vU.min,max:vU.max,step:vU.step,default:vU.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:mU.min,max:mU.max,step:mU.step,default:mU.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:hU.min,max:hU.max,step:hU.step,default:hU.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:gU.min,max:gU.max,step:gU.step,default:gU.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:xU.min,max:xU.max,step:xU.step,default:xU.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:yU.min,max:yU.max,step:yU.step,default:yU.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:bU.min,max:bU.max,step:bU.step,default:bU.default,showValue:!0,showWhen:{field:`occupancyRecheckEnabled`,equals:!0}}],NU=x({nodeId:m(),attachedCameras:p(),activeCameras:p(),avgInferenceFps:p(),avgInferenceTimeMs:p(),queueDepthTotal:p(),devices:C(x({deviceKey:m(),backend:m(),attachedCameras:p()})).default([]),hardware:x({hasGpu:y(),inferenceBackend:m().optional(),cpuCores:p().optional()}),motionSliceWriter:s(`orchestrator`).optional()}),PU=x({framesDecoded:p(),framesAdmitted:p(),framesDroppedPixelFree:p(),viewsMaterialized:p(),viewsSkipped:p(),workerToRunnerBytes:p(),runnerToPoolRawBytes:p(),runnerToPoolJpegBytes:p(),onDemandFullFrameRequests:p(),onDemandCropRequests:p(),nativeHits:p(),nativeMisses:p(),tileHits:p(),tileMisses:p(),fallbackHits:p(),fallbackMisses:p(),retainedWritesAvoided:p(),residentRefs:p(),residentBytes:p(),releases:p(),evictions:p(),staleMisses:p()}),FU=x({node:PU,cameras:C(PU.extend({deviceId:p()}))}),IU=x({nodeId:m(),activeCameras:p(),throttledCameras:p(),avgInferenceTimeMs:p(),queueDepth:p(),frameLazy:FU.optional()}),LU=S([`not-attached`,`battery-asleep`,`not-watching`,`already-bursting`]),RU={name:`pipeline-runner`,scope:`system`,mode:`singleton`,methods:{attachCamera:E(MU,x({success:s(!0)}),{kind:`mutation`}),detachCamera:E(x({deviceId:p()}),x({success:s(!0)}),{kind:`mutation`}),reportMotion:E(OU,x({success:s(!0)}),{kind:`mutation`}),getLocalLoad:E(v(),NU),getLocalMetrics:E(v(),IU),getCameraMetrics:E(x({deviceId:p()}),DH.nullable()),getAllCameraMetrics:E(v(),C(OH).readonly()),getLocalCameras:E(v(),C(p()).readonly()),requestOccupancyBurst:E(x({deviceId:p(),frames:p().int().positive().optional(),reason:m()}),x({started:y(),refusedBecause:LU.optional()}),{auth:`admin`,kind:`mutation`}),getNativeCrop:E(x({handle:hc,bbox:sU,maxWidth:p().int().positive().optional(),acceptJpegBytes:y().optional(),encodeJpeg:y().optional()}),cU.nullable()),runDetailSubtree:E(x({deviceId:p(),frameHandle:hc.optional(),frameJpeg:m().optional(),cropJpeg:m().optional(),parent:sCe,steps:C(m()).optional(),supplied:x({stepId:m(),modelId:m(),boxes:C(x({bbox:sU,score:p()})).min(1)}).optional()}),x({details:C(pU)}).nullable(),{kind:`mutation`}),runStatelessStep:E(x({stepId:m(),modelId:m(),frameJpeg:m(),bbox:sU,className:m(),sourceDeviceId:p()}),lCe,{kind:`mutation`}),parkTrackFrame:E(x({deviceId:p(),trackId:m(),kind:lU,handle:hc,bbox:sU,maxWidth:p().int().positive().optional(),timestamp:p()}),dU,{kind:`mutation`}),getParkedTrackFrame:E(x({deviceId:p(),trackId:m(),kind:lU,acceptJpegBytes:y().optional()}),fU.nullable()),releaseParkedTrackFrames:E(x({deviceId:p(),trackId:m()}),x({released:p().int().nonnegative()}),{kind:`mutation`}),startNodeBench:E(XH,x({accepted:s(!0),runId:m()}),{kind:`mutation`,auth:`admin`}),getNodeBenchStatus:E(x({runId:m()}),QH.nullable(),{auth:`admin`}),abortNodeBench:E(x({runId:m()}),x({aborted:y()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.PIPELINE}},zU=3e4,fCe={version:1,targets:[{id:`detected`,cardinality:`event`,shape:`span`,vocabulary:{cap:`motion`,eventName:`onMotionChanged`},deviceTypes:[j.Camera],apply:`add`,applyAuthority:{kind:`camera-sensors`,timeoutField:`motionCooldownMs`},eventName:`onMotionChanged`,start:`rising-edge`,end:`falling-edge-or-timeout`,timeoutMs:zU,combine:`any`,sourceModes:[`in-addition`,`confirm`,`replace`],sources:[{kind:`binary`},{kind:`switch`}],sourceReport:{status:`assignment-status`},advancedExpression:!1}]},pCe=15e3,BU=x({detected:y(),lastDetectedAt:p().nullable(),autoClearAfterMs:p().nullable().meta(k(`duration-ms`))}),VU=x({deviceId:p(),detected:y(),timestamp:p(),source:SU,regions:C(Jz).readonly().optional(),triggeredBy:Mz.optional()}),HU={name:`motion`,scope:`device`,mode:`singleton`,deviceNative:!0,deviceTypes:[j.Camera,j.Sensor],methods:{isDetected:E(x({deviceId:p()}),y())},composedMethods:{isDetected:{kind:`slice`,field:`detected`}},events:{onMotionChanged:{data:VU,notOperatorFacing:"the `detected` state trigger phrases both edges, from the mirror that survives a dropped event (D49)"}},status:{schema:BU,kind:`push`},runtimeState:BU,durability:`session`,history:{fields:{detected:{kind:`boolean`,excludeDeviceTypes:[j.Camera]}}},customize:fCe,vocabulary:{noun:I(`Motion`,`Movimento`),order:5130,state:[{kind:`boolean`,field:`detected`,label:I(`Motion`,`Movimento`),whenTrue:I(`When {device} detects motion`,`Quando {device} rileva movimento`),whenFalse:I(`When motion clears on {device}`,`Quando il movimento su {device} cessa`),icon:`activity`}]}},UU=x({enabled:y(),lastChangedAt:p()}),WU=UU.extend({lastFetchedAt:p()}),GU={name:`motion-trigger`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Light,j.Siren,j.Switch],methods:{setMotionTrigger:E(x({deviceId:p().int().nonnegative(),enabled:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`motionTrigger.on`,label:I(`Motion trigger on`,`Attivazione al movimento attiva`),phrase:I(`Let motion trigger {device}`,`Fai attivare {device} dal movimento`),icon:`activity`,effect:{field:`enabled`,value:!0},args:{enabled:!0}},{id:`motionTrigger.off`,label:I(`Motion trigger off`,`Attivazione al movimento spenta`),phrase:I(`Stop motion triggering {device}`,`Non far più attivare {device} dal movimento`),icon:`activity`,effect:{field:`enabled`,value:!1},args:{enabled:!1}}]})},events:{onMotionTriggerChanged:{data:x({deviceId:p(),enabled:y(),lastChangedAt:p()}),notOperatorFacing:"the `enabled` state trigger phrases both edges of this change"}},status:{schema:UU,kind:`command-driven`},runtimeState:WU,durability:`session`,history:`none`,vocabulary:{noun:I(`Motion trigger`,`Attivazione al movimento`),order:1160,state:[{kind:`boolean`,field:`enabled`,label:I(`Motion trigger`,`Attivazione al movimento`),whenTrue:I(`When motion triggering is turned on for {device}`,`Quando si attiva l’attivazione al movimento di {device}`),whenFalse:I(`When motion triggering is turned off for {device}`,`Quando si disattiva l’attivazione al movimento di {device}`),icon:`activity`}]}},KU=x({id:p(),enabled:y(),shape:tB}),qU=x({enabled:y(),sensitivity:p().meta(k(`none`)),regions:C(KU),lastFetchedAt:p()}),JU=x({maxRegions:p(),supportedShapes:C(rB),grid:aB,sensitivity:x({min:p(),max:p(),step:p()})}),YU=x({enabled:y().optional(),sensitivity:p().optional(),regions:C(KU).optional()}),XU={name:`motion-zones`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/motion-zones-grid`,tab:`motion`,label:`Motion Zones`}},methods:{getOptions:E(x({deviceId:p()}),JU),setZone:E(x({deviceId:p(),patch:YU}),v(),{kind:`mutation`,auth:`admin`})},status:{schema:qU,kind:`poll`},runtimeState:qU,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`Motion zones`,`Zone di movimento`),order:3170}},mCe=S([`external`,`embedded`]),hCe=S([`connected`,`disconnected`,`auth-failed`,`unreachable`,`tls-error`]),ZU=x({id:m(),name:m(),url:m(),kind:mCe,status:hCe,latencyMs:p().nullable(),error:m().optional(),connectedClients:p().int().nonnegative().optional(),lastCheckedAt:p().optional()}),QU=x({url:m(),username:m().optional(),password:m().optional(),clientIdPrefix:m().optional()}),$U=x({name:m().min(1),url:m().regex(/^(mqtt|mqtts|ws|wss):\/\//,`URL must start with mqtt(s):// or ws(s)://`),username:m().optional(),password:m().optional(),clientIdPrefix:m().optional()}),gCe=x({id:m()}),eW=x({id:m()}),tW=x({port:p().int().min(1).max(65535).default(1883),allowAnonymous:y().default(!1),username:m().optional(),password:m().optional()}),_Ce=x({id:m(),url:m()}),nW=x({brokerCount:p(),embeddedRunning:y()}),rW={name:`mqtt-broker`,scope:`system`,mode:`collection`,providerKind:`broker`,status:{schema:nW,kind:`poll`},methods:{listBrokers:E(v(),C(ZU)),getBrokerConfig:E(eW,QU,{auth:`admin`}),addBroker:E($U,gCe,{kind:`mutation`,auth:`admin`}),removeBroker:E(eW,v(),{kind:`mutation`,auth:`admin`}),startEmbeddedBroker:E(tW,_Ce,{kind:`mutation`,auth:`admin`}),stopEmbeddedBroker:E(eW,v(),{kind:`mutation`,auth:`admin`}),getStatus:E(v(),nW)},vocabulary:{notOperatorFacing:O.NETWORK}},iW=S([`person`,`vehicle`,`animal`,`face`,`package`,`other`]),aW=x({class:iW,timestamp:p(),confidence:p().min(0).max(1).optional()}),oW=x({lastByClass:r(iW,aW.nullable()),supportedClasses:C(iW).readonly(),enabled:y()}),sW=S([`boxed`,`while-streaming`,`flag-only`]),cW=x({supportedClasses:C(iW).readonly(),geometry:sW}),lW=x({enabled:y().optional()}),uW=oW.extend({lastFetchedAt:p()}),dW={name:`native-object-detection`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],methods:{getOptions:E(x({deviceId:p()}),cW),setSettings:E(x({deviceId:p(),settings:lW}),v(),{kind:`mutation`,auth:`admin`}),setEnabled:E(x({deviceId:p(),enabled:y()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`nativeDetection.on`,label:I(`On-camera detection on`,`Rilevamento a bordo attivo`),phrase:I(`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:I(`On-camera detection off`,`Rilevamento a bordo spento`),phrase:I(`Turn off the on-camera detection of {device}`,`Disattiva il rilevamento a bordo di {device}`),icon:`scan-eye`,args:{enabled:!1}}]})},events:{onDetected:{data:x({deviceId:p(),detection:aW}),trigger:{category:w.DetectionCameraNative,label:I(`Camera spotted something`,`La telecamera ha rilevato qualcosa`),phrase:I(`When {device} spots something with its own detector`,`Quando {device} rileva qualcosa con il proprio rilevatore`),icon:`scan-eye`}}},status:{schema:oW,kind:`push`},runtimeState:uW,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`On-camera detection`,`Rilevamento a bordo`),order:3180,state:[{kind:`boolean`,field:`enabled`,label:I(`On-camera detection`,`Rilevamento a bordo`),whenTrue:I(`When the on-camera detection of {device} is turned on`,`Quando si attiva il rilevamento a bordo di {device}`),whenFalse:I(`When the on-camera detection of {device} is turned off`,`Quando si disattiva il rilevamento a bordo di {device}`),icon:`scan-eye`}]}},fW=x({pan:p().min(-1).max(1).optional(),tilt:p().min(-1).max(1).optional(),speed:p().min(0).max(1).optional()}),pW=S([`goHome`,`locate`,`spotClean`,`findPet`,`personFollow`,`stop`,`startClean`,`pauseClean`,`dockWash`,`autoEmpty`,`flashOn`,`flashOff`]),mW=S([`action`,`sound`]),hW=x({id:m(),kind:mW,label:m(),icon:m(),soundId:p().int().optional(),enabled:y()}),vCe=[{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}],gW=x({x:p(),y:p()}),_W=x({move:y(),stop:y(),goToPoint:y(),runAction:y(),playSound:y(),light:y(),lightMode:y()}),vW=S([`auto`,`manual`]),yW=S([`idle`,`cleaning`,`spot`,`following`,`goto`,`returning`,`paused`,`unknown`]),bW=x({mode:yW,following:y(),flash:y(),lightMode:vW,lightLevel:p().min(40).max(100).meta(k(`none`)),lastChangedAt:p()}),xW=bW.extend({lastFetchedAt:p()}),SW={name:`navigation`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/navigation-panel`,tab:`navigation`,topTab:!0,label:`Navigation`,order:0}},methods:{move:E(fW.extend({deviceId:p()}),v(),{kind:`mutation`,notOperatorFacing:`joystick control from the live view — continuous, not a discrete step`}),stop:E(x({deviceId:p()}),v(),{kind:`mutation`,actions:[{id:`navigation.stop`,label:I(`Stop`,`Ferma`),phrase:I(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),goToPoint:E(gW.extend({deviceId:p()}),v(),{kind:`mutation`,notOperatorFacing:`tap-to-go on the live map — the point only means something on that picture`}),listActions:E(x({deviceId:p()}),C(hW)),runAction:E(x({deviceId:p(),actionId:pW}),v(),{kind:`mutation`,actions:[{id:`navigation.runAction`,label:I(`Run a routine`,`Esegui una routine`),phrase:I(`Have {device} {actionId}`,`Fai eseguire a {device}: {actionId}`),icon:`bot`,openArgs:[{key:`actionId`,label:I(`Routine`,`Routine`),offer:{kind:`enum`,values:[{value:`goHome`,label:I(`go home`,`torna alla base`)},{value:`locate`,label:I(`beep so you can find it`,`suona per farsi trovare`)},{value:`spotClean`,label:I(`clean this spot`,`pulisci questo punto`)},{value:`findPet`,label:I(`find the pet`,`cerca l’animale`)},{value:`personFollow`,label:I(`follow a person`,`segui una persona`)},{value:`stop`,label:I(`stop`,`fermati`)},{value:`startClean`,label:I(`start cleaning`,`inizia a pulire`)},{value:`pauseClean`,label:I(`pause cleaning`,`metti in pausa la pulizia`)},{value:`dockWash`,label:I(`wash the mop at the dock`,`lava il mocio alla base`)},{value:`autoEmpty`,label:I(`empty the bin at the dock`,`svuota il contenitore alla base`)},{value:`flashOn`,label:I(`turn the flash on`,`accendi il flash`)},{value:`flashOff`,label:I(`turn the flash off`,`spegni il flash`)}]}}]}]}),playSound:E(x({deviceId:p(),soundId:p().int()}),v(),{kind:`mutation`,actions:[{id:`navigation.playSound`,label:I(`Play sound`,`Riproduci un suono`),phrase:I(`Play {soundId} on {device}`,`Riproduci {soundId} su {device}`),icon:`volume-2`,openArgs:[{key:`soundId`,label:I(`Sound`,`Suono`),offer:{kind:`dynamic`,from:`method`,method:`listActions`,valueKey:`soundId`,labelKey:`label`,where:{key:`kind`,equals:`sound`},valueKind:`number`}}]}]}),setLightOn:E(x({deviceId:p(),on:y()}),v(),{kind:`mutation`,actions:[{id:`navigation.lightOn`,label:I(`Light on`,`Luce accesa`),phrase:I(`Turn on the light of {device}`,`Accendi la luce di {device}`),icon:`lightbulb`,args:{on:!0}},{id:`navigation.lightOff`,label:I(`Light off`,`Luce spenta`),phrase:I(`Turn off the light of {device}`,`Spegni la luce di {device}`),icon:`lightbulb-off`,args:{on:!1}}]}),setLightMode:E(x({deviceId:p(),mode:vW,level:p().min(40).max(100).optional()}),v(),{kind:`mutation`,actions:[{id:`navigation.lightAuto`,label:I(`Light automatic`,`Luce automatica`),phrase:I(`Set the light of {device} to automatic`,`Metti la luce di {device} in automatico`),icon:`lightbulb`,args:{mode:`auto`}}]}),setLightLevel:E(x({deviceId:p(),level:p().min(40).max(100)}),v(),{kind:`mutation`,actions:[{id:`navigation.lightLevel`,label:I(`Set light level`,`Imposta la luce`),phrase:I(`Set the light of {device} to {level}`,`Imposta la luce di {device} al {level}`),icon:`sun-medium`,openArgs:[{key:`level`,label:I(`Level`,`Livello`),offer:{kind:`number`,min:40,max:100,step:1,unit:`%`}}]}]}),getFeatures:E(x({deviceId:p()}),_W)},events:{onStatusChanged:{data:x({deviceId:p(),status:bW}),notOperatorFacing:"the `mode` state trigger reads the same change"}},status:{schema:bW,kind:`push`},runtimeState:xW,durability:`session`,history:`none`,vocabulary:{noun:I(`Robot movement`,`Movimento del robot`),order:2080,state:[{kind:`enum`,field:`mode`,label:I(`Activity`,`Attività`),values:[{value:`idle`,label:I(`Idle`,`Inattivo`)},{value:`cleaning`,label:I(`Cleaning`,`In pulizia`)},{value:`spot`,label:I(`Spot cleaning`,`Pulizia localizzata`)},{value:`following`,label:I(`Following`,`In inseguimento`)},{value:`goto`,label:I(`Moving to a point`,`In movimento verso un punto`)},{value:`returning`,label:I(`Returning`,`In rientro`)},{value:`paused`,label:I(`Paused`,`In pausa`)},{value:`unknown`,label:I(`Unknown`,`Sconosciuto`)}],icon:`bot`}]}},CW=x({url:m(),hostname:m(),port:p(),protocol:S([`http`,`https`]),stable:y().optional()}),yCe=x({url:m(),stable:y().optional(),updated:y().optional()}),wW=x({connected:y(),endpoint:CW.nullable(),error:m().optional()}),bCe=CW.extend({id:m(),label:m(),mode:m().optional(),sourcePort:p().optional()}),TW={name:`network-access`,scope:`system`,mode:`collection`,providerKind:`ingress`,methods:{start:E(v(),CW,{kind:`mutation`}),stop:E(v(),v(),{kind:`mutation`}),getEndpoint:E(v(),CW.nullable()),getStatus:E(v(),wW),listEndpoints:E(v(),C(bCe).readonly())},vocabulary:{notOperatorFacing:O.NETWORK}},EW=[`wifi`,`ethernet`,`cellular`,`unknown`],DW=x({type:S(EW),signal:p().min(0).max(100).nullable().meta(k(`percentage`)),rssi:p().optional().meta(k(`signal-level`)),ssid:m().optional(),lastUpdated:p().meta(k(`none`))}),OW={type:`unknown`,signal:null,lastUpdated:0};function xCe(e,t){return e===void 0||!Number.isFinite(e)||t<=0||e<0||e>t?null:Math.round(e/t*100)}function SCe(e){return e===void 0||!Number.isFinite(e)||e>0?null:Math.round((Math.min(-50,Math.max(-100,e))+100)*2)}var kW={name:`network-link`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera,j.Sensor,j.Button,j.Switch,j.Light,j.Lock,j.Siren],methods:{},events:{onStatusChanged:{data:x({deviceId:p(),status:DW}),notOperatorFacing:`the signal / link-type state triggers each read one field of this change`}},status:{schema:DW,kind:`push`,empty:OW},runtimeState:DW,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:I(`Network link`,`Collegamento di rete`),order:5250,state:[{kind:`numeric`,field:`signal`,quantity:I(`the signal strength`,`l’intensità del segnale`),label:I(`Signal`,`Segnale`),unit:`%`,icon:`wifi`},{kind:`enum`,field:`type`,label:I(`Link type`,`Tipo di collegamento`),values:[{value:`wifi`,label:I(`Wi-Fi`,`Wi-Fi`)},{value:`ethernet`,label:I(`Ethernet`,`Ethernet`)},{value:`cellular`,label:I(`Cellular`,`Rete mobile`)},{value:`unknown`,label:I(`Unknown`,`Sconosciuto`)}],icon:`network`}]}},AW=x({nominalBitrateKbps:p(),observedBitrateKbps:p(),peakBitrateKbps:p(),packetLossPercent:p(),lastUpdated:p()}),jW=x({rttMs:p(),jitterMs:p(),estimatedBandwidthKbps:p(),packetLossPercent:p().min(0).max(100),downlinkMbps:p().optional(),downlinkAgeMs:p().optional(),lastUpdated:p()}),MW=x({deviceId:p(),streams:d(m(),AW),client:jW.optional()}),NW={name:`network-quality`,scope:`system`,mode:`singleton`,methods:{getDeviceStats:E(x({deviceId:p()}),MW.nullable()),getAllStats:E(v(),C(MW).readonly()),reportClientStats:E(x({deviceId:p(),rttMs:p().min(0).max(6e4),jitterMs:p().min(0).max(1e4),estimatedBandwidthKbps:p().min(0).max(1e6),packetLossPercent:p().min(0).max(100),downlinkMbps:p().min(0).max(1e5).optional(),downlinkAgeMs:p().min(0).max(864e5).optional()}),v(),{role:`viewer`,kind:`mutation`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:O.NETWORK}},PW=x({cn:m(),serial:m(),fingerprintSha256:m(),notBefore:p(),notAfter:p()}),FW=x({fingerprintSha256:m(),issuer:m(),sans:C(m()),notBefore:p(),notAfter:p()}),IW=a(`state`,[x({state:s(`served`),leaf:FW}),x({state:s(`not-issued`),reason:m()})]),LW={name:`node-certificates`,scope:`system`,mode:`singleton`,internal:!0,methods:{getCertificates:E(x({}),x({nodeId:m(),mesh:PW.nullable(),https:IW}),{auth:`admin`}),prepareMeshRenewal:E(x({}),x({csrPem:m()}),{kind:`mutation`,auth:`admin`}),installMeshLeaf:E(x({certPem:m().min(1),caCertPem:m().min(1),confirmWithinMs:p().int().min(1e4).max(6e5)}),x({fingerprintSha256:m(),serial:m()}),{kind:`mutation`,auth:`admin`}),confirmMeshLeaf:E(x({fingerprintSha256:m()}),x({confirmed:y()}),{kind:`mutation`,auth:`admin`}),rollbackMeshLeaf:E(x({}),x({rolledBack:y()}),{kind:`mutation`,auth:`admin`}),prepareHttpsCertificate:E(x({}),x({csrPem:m(),hostnames:C(m()),addresses:C(m()),pinnedCaFingerprintSha256:m().nullable()}),{kind:`mutation`,auth:`admin`}),forgetHub:E(x({}),x({ok:s(!0)}),{kind:`mutation`,auth:`admin`}),installHttpsCertificate:E(x({certPem:m().min(1),caCertPem:m().min(1),caRotation:y().optional()}),FW,{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:O.IDENTITY}},RW=x({nodeId:m().min(1),removedAt:p()}),zW=x({counts:d(m(),p().int().nonnegative())}),BW={name:`node-removal-hook`,scope:`system`,mode:`collection`,internal:!0,methods:{onNodeRemoved:E(RW,zW,{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:O.INTERNAL}},VW=x({addonId:m(),capabilities:C(m()).readonly(),status:m()}),HW=x({pid:p(),name:m(),state:m(),cpuPercent:p(),memoryRss:p(),uptimeSeconds:p(),services:C(VW).readonly(),groupId:m().optional()}),CCe=x({id:m(),status:m(),cpuPercent:p(),memoryRss:p()}),wCe=x({category:m(),total:p(),healthy:p(),addons:C(CCe).readonly()}),TCe=x({name:m(),version:m()}),UW=x({id:m(),name:m(),hostname:m(),platform:m(),arch:m(),cpuModel:m().nullable(),cpuCores:p(),memoryMB:p(),engines:C(m()).readonly(),isHub:y(),isOnline:y(),cpuPercent:p(),memoryPercent:p().nullable(),uptime:p(),lastSeen:m(),localIps:C(m()).readonly(),addons:C(x({id:m(),capabilities:C(m()).readonly(),status:m()})).readonly(),processes:C(HW).readonly(),categories:C(wCe).readonly(),rootPackage:TCe.nullable(),meshTransport:S([`tls`,`clear`]).optional(),capabilitiesRegistered:y().optional()}),ECe=x({callerAddonId:m(),providerAddonId:m(),capName:m(),callsPerMin:p(),lastCallAtMs:p()}),WW=x({nodeId:m(),name:m(),version:m(),status:m(),synced:y()}),GW=x({hubVersion:m(),nodes:C(WW)}),KW=x({nodeId:m(),addonId:m()}),DCe=x({id:m(),status:m(),version:m().optional(),packageName:m().optional()}),qW=x({success:y()}),OCe=x({success:y(),reason:m().optional()}),kCe=x({restarted:C(m()).readonly(),failed:C(m()).readonly()}),ACe=x({nodeId:m(),name:m()}),JW=x({id:m(),name:m(),isHub:y(),isOnline:y()}),YW=x({nodes:C(JW).readonly(),complete:y()}),XW={name:`nodes`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,methods:{topology:E(v(),C(UW).readonly(),{auth:`admin`}),directory:E(v(),YW,{auth:`admin`}),deployAddon:E(KW,qW,{kind:`mutation`,auth:`admin`}),undeployAddon:E(KW,qW,{kind:`mutation`,auth:`admin`}),restartAddon:E(KW,qW,{kind:`mutation`,auth:`admin`}),restartProcess:E(x({nodeId:m(),processName:m()}),OCe,{kind:`mutation`,auth:`admin`}),restartNode:E(x({nodeId:m()}),kCe,{kind:`mutation`,auth:`admin`}),shutdownNode:E(x({nodeId:m()}),qW,{kind:`mutation`,auth:`admin`}),renameNode:E(x({nodeId:m(),name:m().min(1).max(64)}),ACe,{kind:`mutation`,auth:`admin`}),clusterAddonStatus:E(v(),d(m(),GW),{auth:`admin`}),getCapUsageGraph:E(x({windowSeconds:p().int().positive().max(300).default(60)}),C(ECe).readonly(),{auth:`admin`}),getNodeAddons:E(x({nodeId:m()}),C(DCe).readonly(),{auth:`admin`}),setProcessLogLevel:E(x({nodeId:m(),level:m()}),qW,{kind:`mutation`,auth:`admin`}),executeQuery:E(x({nodeId:m(),addonId:m(),queryName:m(),params:d(m(),u()).optional()}),u(),{kind:`mutation`,auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:O.CLUSTER}},ZW=[{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`}],QW={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},$W={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},eG=new Map;for(let[e,t]of Object.entries(QW.mapping))eG.set(e.toLowerCase(),t);for(let[e,t]of Object.entries($W.mapping))eG.set(e.toLowerCase(),t);function jCe(e){return eG.get(e.toLowerCase())??null}function MCe(){return ZW.map(e=>e.id)}var tG=pM();function nG(e){return vM(tG.swatches,tG.fallbacks,e)}function NCe(e){let t=e[0];if(t===void 0)throw Error(`display palette has no fallback colour`);return t}var PCe=NCe(tG.fallbacks);function FCe(e){return e.split(/[-_ ]/).filter(e=>e.length>0).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}var rG=new Map;function iG(e,t,n,r){rG.set(e,{kind:e,parentKind:null,level:`macro`,category:t,color:nG(e),iconId:n,labelKey:`eventKind.${e}`,label:r})}function aG(e,t,n,r,i){rG.set(e,{kind:e,parentKind:t,level:`sub`,category:n,color:nG(e),iconId:r,labelKey:`eventKind.${e}`,label:i})}iG(`motion`,`motion`,`motion`,`Motion`),iG(`audio`,`audio`,`audio`,`Audio`),iG(`person`,`detection`,`person`,`Person`),iG(`vehicle`,`detection`,`vehicle`,`Vehicle`),iG(`animal`,`detection`,`animal`,`Animal`),iG(`package`,`package`,`package`,`Package`),iG(`sensor`,`sensor`,`sensor`,`Sensor`),iG(`control`,`control`,`control`,`Control`);for(let[e,t]of Object.entries(Ah.mapping))t!==`vehicle`&&t!==`animal`||rG.has(e)||aG(e,t,`detection`,e,FCe(e));aG(`package-delivered`,`package`,`package`,`package`,`Package delivered`),aG(`package-picked-up`,`package`,`package`,`package`,`Package picked up`),aG(`contact`,`sensor`,`sensor`,`door`,`Contact`),aG(`motion-sensor`,`sensor`,`sensor`,`pir`,`Motion sensor`),aG(`smoke`,`sensor`,`sensor`,`smoke`,`Smoke`),aG(`flood`,`sensor`,`sensor`,`water`,`Water leak`),aG(`gas`,`sensor`,`sensor`,`gas`,`Gas`),aG(`carbon-monoxide`,`sensor`,`sensor`,`smoke`,`Carbon monoxide`),aG(`vibration`,`sensor`,`sensor`,`vibration`,`Vibration`),aG(`tamper`,`sensor`,`sensor`,`tamper`,`Tamper`),aG(`presence`,`sensor`,`sensor`,`presence`,`Presence`),aG(`enum-sensor`,`sensor`,`sensor`,`generic`,`Sensor state`),aG(`device-event`,`sensor`,`sensor`,`button`,`Device event`),aG(`lock`,`control`,`control`,`lock`,`Lock`),aG(`cover`,`control`,`control`,`door`,`Cover`),aG(`switch`,`control`,`control`,`switch`,`Switch`),aG(`siren`,`control`,`control`,`siren`,`Siren`),aG(`button`,`control`,`control`,`button`,`Button`),aG(`doorbell`,`control`,`control`,`doorbell`,`Doorbell`),aG(`appliance-cycle`,`control`,`control`,`switch`,`Appliance cycle`);for(let e of ZW){let t=`audio-${e.id}`;rG.has(t)||aG(t,`audio`,`audio`,t,e.name)}var oG=Object.freeze(Object.fromEntries(rG));function sG(e){return oG[e]}function ICe(e){return nG(e)}function LCe(e){let t=[];for(let n of Object.values(oG))n.parentKind===e&&t.push(n);return t}var cG=x({kind:m(),label:m(),parentKind:m().nullable()}),lG=x({videoClasses:C(cG),audioKinds:C(cG),labels:C(cG)});function uG(e,t,n){return{kind:e,label:t,parentKind:n}}function dG(){let e=Object.values(oG);return{videoClasses:e.filter(e=>e.category===`detection`).map(e=>uG(e.kind,e.label,e.parentKind)),audioKinds:e.filter(e=>e.category===`audio`&&e.level===`sub`).map(e=>uG(e.kind,e.label,e.parentKind)),labels:e.filter(e=>e.category===`sensor`||e.category===`control`).map(e=>uG(e.kind,e.label,e.parentKind))}}var RCe=Object.freeze(dG()),fG=S([`immediate`,`track-end`,`device-event`,`package-event`,`system-event`]),pG=S(`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(`.`)),mG=[`camera-online`,`camera-offline`,`camera-disabled`,`camera-enabled`],zCe=new Set(mG),BCe=pG.options.filter(e=>!zCe.has(e)),hG=[`alarm-arm-refused`,`alarm-check-failed`,`alarm-arming`,`alarm-armed`,`alarm-pending`,`alarm-triggered`,`alarm-rearmed`,`alarm-sensor-bypass`,`alarm-disarmed`],gG=[`device-battery-low`,`device-battery-normal`,`device-consumable-low`,`device-consumable-normal`],_G=[`device-consumable-low`,`device-consumable-normal`],vG=[`confirmed`,`already`,`unconfirmed`,`failed`],yG=[`user`,`addon`,`action`,`scheduler`,`composition`,`node`],bG=x({kinds:C(pG).min(1),deviceIds:C(p().int()).min(1).optional(),deviceTypes:C(m().min(1)).min(1).optional(),excludeDeviceIds:C(p().int()).min(1).optional(),nodeIds:C(m().min(1)).min(1).optional(),packageNames:C(m().min(1)).min(1).optional(),commandActions:C(m().min(1)).min(1).optional(),commandOutcomes:C(S(vG)).min(1).optional(),commandActorKinds:C(S(yG)).min(1).optional(),consumableLowPercent:p().int().min(1).max(95).optional()});function VCe(e){return e.consumableLowPercent??15}var xG=1440,HCe=[10,30,60],SG=x({days:C(p().int().min(0).max(6)).min(1),startMinute:p().int().min(0).max(1439),endMinute:p().int().min(0).max(1439)}),CG=x({windows:C(SG).min(1),timezone:m().optional(),invert:y().optional()}),wG=S([`instant`,`summary`]),UCe=S([`activation`,`deactivation`,`schedule`]),TG=S([`rule`,`section`]),EG=a(`mode`,[x({mode:s(`instant`)}),x({mode:s(`summary`),schedule:CG,split:TG.optional()}),x({mode:s(`modes`),onActivation:y(),onDeactivation:y(),onSchedule:x({schedule:CG,grouping:TG}).optional()})]),DG=x({values:C(m().min(1)),maxDistance:p().int().min(0).max(3).default(1)}),OG=x({zoneId:m().optional(),className:m().optional(),op:S([`became-occupied`,`became-free`,`>=`,`<=`]).default(`became-occupied`),count:p().int().min(0).default(1),sustainSeconds:p().int().min(0).max(3600).default(15)}),kG=x({labels:C(m().min(1)).min(1).optional(),dbThreshold:p().min(-96).max(0).optional(),hitPercent:p().int().min(1).max(100).default(60),samplingSeconds:p().int().min(1).max(300).default(10),confirmHits:p().int().min(1).max(20).optional(),confirmWindowSec:p().int().min(1).max(60).optional()}),AG=S([`enter`,`exit`,`any`]),jG=S([`raised`,`cleared`]),MG=x({ids:C(m().min(1)).min(1),match:S([`any`,`all`]).optional()}),NG=m().min(1),PG=C(NG).max(4),FG=x({id:m().min(1).max(64),label:m().min(1).max(40),actionId:NG,icon:di.optional(),destructive:y().optional()}),IG=x({onActivation:PG.optional(),onDeactivation:PG.optional(),onTrigger:PG.optional(),onTriggerOff:PG.optional(),buttons:C(FG).max(8).optional()}),LG=x({deviceId:p().int(),states:C(m().min(1)).min(1)}),RG=x({sceneId:m().min(1),deviceId:p().int().optional(),requiredState:S([`matched`,`diverged`]),latched:y().optional()}),zG=x({deviceState:LG.optional(),scene:RG.optional(),devices:C(p()).optional(),devicesExclude:C(p()).min(1).optional(),classes:C(m().min(1)).optional(),classesExclude:C(m().min(1)).optional(),minConfidence:p().min(0).max(1).optional(),zones:MG.optional(),zonesExclude:C(m().min(1)).optional(),crossing:AG.optional(),labelEquals:C(m().min(1)).optional(),identities:C(m().min(1)).optional(),plates:DG.optional(),identitiesExclude:C(m().min(1)).optional(),minImportance:p().min(0).max(1).optional(),minDwellSeconds:p().min(0).optional(),source:S([`pipeline`,`onboard`,`sensor`,`audio`,`any`]).optional(),minLabelConfidence:p().min(0).max(1).optional(),eventTypeTokens:C(m().min(1)).optional(),sensorKinds:C(m().min(1)).optional(),sensorTransition:jG.optional(),packagePhase:S([`delivered`,`picked-up`,`both`]).optional(),systemEvent:bG.optional(),customZones:C(eB).optional(),occupancy:OG.optional(),audio:kG.optional()}),BG=x({targetId:m().min(1),params:d(m(),u()).optional()}),VG=S([`none`,`image`,`clip`,`gif`]),HG=x({template:x({title:m().max(500).optional(),body:m().max(2e3).optional()}).optional(),schedule:CG.optional(),priority:p().int().min(1).max(5).optional(),attachment:VG.optional(),actions:y().optional()}),UG=d(m(),HG),WG=S([`scene-boxes`,`crop`,`clean`,`none`]),GG=S([`cropped`,`full`,`boxed`]),KG=S([`mosaic`,`each`]),qG=x({image:WG.optional(),showTriggerZone:y().optional(),showSubjectPath:y().optional(),attach:S([`best`,`best-matching`,`keyFrame`,`none`]).optional(),frame:GG.optional(),zoneCrop:y().optional(),gif:y().optional(),clip:y().optional(),clipPreRollSec:p().int().min(0).max(30).optional(),clipPostRollSec:p().int().min(0).max(30).optional(),clipSpeed:p().min(1).max(8).optional(),profile:A.optional(),linkedCameras:KG.optional(),wakeSleepingCamera:y().optional()}),JG=S([`shared`,`per-class`]),YG=x({cooldownSec:p().int().min(0).max(86400).default(60),scope:S([`rule`,`rule-device`]).default(`rule-device`),granularity:JG.optional()}),XG=1e3,ZG=2e4,QG=8e3,$G=x({op:S([`>=`,`>`,`<=`,`<`,`==`]),count:p().int().min(0).max(1e3)}),eK=x({enabled:y().default(!1),profileId:m().optional(),prompt:m().max(1e3).optional(),expect:$G.optional(),timeoutMs:p().int().min(XG).max(ZG).default(QG),onTimeout:S([`fire`,`suppress`]).default(`fire`),maxImagePx:p().int().min(64).max(2048).default(448)}),tK=x({name:m().min(1).max(200),enabled:y().default(!0),delivery:fG,conditions:zG.default({}),schedule:CG.optional(),systemEventDelivery:EG.optional(),targets:C(BG),targetUsers:C(m()).optional(),targetOverrides:UG.optional(),media:qG.default({}),throttle:YG.default({cooldownSec:60,scope:`rule-device`}),template:x({title:m().max(500).optional(),body:m().max(2e3).optional()}).optional(),priority:p().int().min(1).max(5).default(3),ownerUserId:m().optional(),snoozeAllowGlobal:y().optional(),snoozeOptions:C(p().int().min(1).max(xG)).max(4).optional(),actions:IG.optional(),confirm:eK.optional(),groupingSec:p().int().min(5).max(60).optional(),groupWithinSec:p().int().min(0).max(300).optional(),askVerdict:y().optional()}),nK=tK.partial().extend({disabledTargetIds:C(m()).optional(),enabled:y().optional(),conditions:zG.optional(),media:qG.optional(),throttle:YG.optional(),priority:p().int().min(1).max(5).optional()}),rK=[`waitForEnhancement`,`groupIdleSec`];function WCe(e){return rK.some(t=>t===e)}var iK=[`template`,`schedule`,`targetUsers`,`snoozeOptions`,`snoozeAllowGlobal`,`actions`,`confirm`,`groupingSec`,`waitForEnhancement`,`groupIdleSec`],aK=S(iK),oK=x({ruleId:m(),patch:nK,clear:C(aK).optional()}),sK=tK.extend({id:m(),createdBy:m(),createdAt:p(),updatedAt:p(),disabledTargetIds:C(m()).default([])}),cK=[`device-state`,`streams`,`battery`,`consumables`,`detection-blind`,`nodes`,`addons`,`addon-updates`,`updates`],lK=S(cK),uK=x({id:lK,status:S([`read`,`unavailable`]),items:p().int().nonnegative(),reason:m().optional()}),dK=x({section:lK.optional(),title:m(),text:m(),count:p().int().nonnegative()}),fK=x({empty:y(),count:p().int().nonnegative(),text:m(),sections:C(uK),dropped:d(m(),p().int().nonnegative()),excludedGroups:C(m()),split:TG.optional(),rows:C(dK).optional()}),pK=x({recordId:m(),recordKind:S([`object-event`,`track`,`device-event`,`package-event`,`system-event`]),deviceId:p(),timestamp:p(),wouldFire:y(),failedCondition:m().optional(),className:m().optional(),label:m().optional()}),mK=S([`detection`,`sensor`,`occupancy`,`sound`,`device-events`,`system`,`alarm`,`mixed`]),hK=S([`detection`,`sensor`,`occupancy`,`sound`,`system`]),gK=x({id:S([`appliance-cycle`]),kind:mK,title:m(),body:m()}),_K=S([`rule`,`timelapse`,`summary`]),vK=S([`title`,`body`,`previewText`,`captionText`]),yK=S([`subject`,`place`,`time`,`rule`,`occupancy`,`sound`,`sensor`,`system`,`digest`,`ai`]),bK=x({name:m().regex(/^\w+$/),label:m(),description:m().optional(),example:m(),group:yK,families:C(_K).min(1),fields:C(vK).optional(),kinds:C(hK).optional(),deliveries:C(fG).optional(),systemEventKinds:C(pG).optional(),systemEventDeliveries:C(wG).optional(),dynamic:x({prefix:s(`count_`),from:s(`classes`)}).optional()}),xK=x({family:_K,field:vK,kind:mK.optional(),delivery:fG.optional(),systemEventKinds:C(pG).optional(),systemEventDelivery:wG.optional()}),SK=x({context:xK,template:x({title:m().max(500).optional(),body:m().max(2e3).optional()})}),CK=x({title:m().nullable(),body:m().nullable(),unknown:C(m())}),wK=x({id:m(),group:S([`scope`,`class`,`zones`,`quality`,`label`,`schedule`,`device`,`package`,`occupancy`,`audio`,`system`]),label:m(),valueType:S([`deviceIdList`,`deviceIdExcludeList`,`stringList`,`number01`,`number`,`sourceSelect`,`zoneSelection`,`zoneIdList`,`schedule`,`plateMatcher`,`packagePhase`,`crossingSelect`,`sensorTransition`,`polygonDraw`,`occupancy`,`audio`,`deviceState`,`scene`,`systemEvent`]),operator:S([`in`,`notIn`,`anyOf`,`allOf`,`gte`,`fuzzyIn`,`withinSchedule`]),appliesTo:C(fG),phase:m(),description:m().optional(),options:C(x({value:m(),label:m(),hint:m().optional()})).readonly().optional()}),TK=[{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.`}],EK=S([`pending`,`sent`,`dead`]),DK=S([`object-event`,`track-end`,`device-event`,`package-event`,`system-event`]),OK=x({className:m(),label:m().optional(),confidence:p().optional(),zones:C(m()),timestamp:p(),systemEvent:x({kind:pG,subject:m(),title:m(),body:m(),data:d(m(),u())}).optional()}),kK=x({id:m(),ruleId:m(),ruleName:m(),delivery:fG,targetId:m(),deviceId:p(),recordKind:DK,recordId:m(),trackId:m().optional(),status:EK,attempts:p().int(),createdAt:p(),updatedAt:p(),error:m().optional(),subject:OK,title:m().optional(),body:m().optional(),artifactIds:C(m().min(1)).optional(),groupedInto:m().min(1).optional()}),AK=x({ruleId:m().optional(),deviceId:p().optional(),status:EK.optional(),since:p().optional(),until:p().optional(),limit:p().int().min(1).max(500).default(100)}),jK=x({ruleId:m(),lastAt:p(),status:EK,deviceId:p()}),MK=x({runs:C(jK),horizonMs:p().nonnegative().nullable()}),NK=S([`rule`,`device`,`all`]),PK=x({scope:NK,ruleId:m().optional(),deviceId:p().int().optional(),classes:C(m().min(1)).min(1).optional(),durationMinutes:p().int().min(1).max(xG),global:y().optional(),summary:y().optional()}),FK=x({id:m(),userId:m(),scope:NK,ruleId:m().optional(),deviceId:p().int().optional(),classes:C(m().min(1)).min(1).optional(),startedAt:p(),expiresAt:p(),global:y(),summary:y(),digestSentAt:p().optional()}),GCe=x({snoozeId:m(),targetId:m(),ruleId:m(),ruleName:m(),deviceId:p().int(),count:p().int(),firstAt:p(),lastAt:p()}),IK=3600,LK=p().int().min(0).max(600),RK=p().int().min(0).max(IK),zK=e=>new Set(e.map(e=>e.mode)).size===e.length,BK=S([`rearmAfter`,`disableAfter`,`doNothing`]),VK=x({mode:ay,exitDelaySec:LK.optional(),entryDelaySec:LK.optional(),triggeredDurationSec:RK.optional(),postTriggeredAction:BK.optional(),schedule:CG.optional(),notifyDuringEntryDelay:y().optional(),notifySensorRewatched:y().optional(),notifySensorIgnored:y().optional()}),KCe=C(VK).max(8).refine(zK,{message:`modeDelays: at most one entry per arm mode`}),HK=x({mode:ay,exitDelaySec:LK.nullable().optional(),entryDelaySec:LK.nullable().optional(),triggeredDurationSec:RK.nullable().optional(),postTriggeredAction:BK.nullable().optional(),schedule:CG.nullable().optional(),notifyDuringEntryDelay:y().nullable().optional(),notifySensorRewatched:y().nullable().optional(),notifySensorIgnored:y().nullable().optional()}),qCe=C(HK).max(8).refine(zK,{message:`modeDelays: at most one edit per arm mode`}),UK=x({mode:ay,deviceId:p().int().positive(),nonBlocking:y()}),WK=x({mode:ay,deviceId:p().int().positive(),blocking:y()}),GK=x({mode:ay,deviceId:p().int().positive(),secureOnArm:y()}),KK=x({mode:ay,deviceIds:C(p().int()).max(200)}),qK=KK,JK=KK,YK=KK,XK=C(qK).max(8).refine(zK,{message:`nonBlocking: at most one list per arm mode`}),ZK=C(JK).max(8).refine(zK,{message:`blocking: at most one list per arm mode`}),QK=C(YK).max(8).refine(zK,{message:`secureOnArmOff: at most one list per arm mode`}),$K=x({exitDelaySec:LK,entryDelaySec:LK,triggeredDurationSec:RK,postTriggeredAction:BK.optional(),announceArm:y().optional(),announceTargets:C(m().min(1)).max(16),nonBlocking:XK.default([]),blocking:ZK.default([]),secureOnArmOff:QK.default([]),modeDelays:KCe.default([])}),eq=x({id:m().min(1).max(64),name:m().min(1).max(64),isDefault:y()}),tq=x({activeId:m().min(1),items:C(eq).min(1)}),nq=x({name:m().min(1).max(64),cloneFromId:m().min(1).max(64).optional()}),rq=x({id:m().min(1).max(64),name:m().min(1).max(64)}),iq=x({id:m().min(1).max(64)}),aq=$K.extend({nonBlocking:XK,blocking:ZK,secureOnArmOff:QK,modeDelays:qCe,nonBlockingEdit:UK,blockingEdit:WK,secureOnArmEdit:GK}).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`}),oq=S([`muted`,`detection-off`,`offline`]),sq=x({deviceId:p().int(),reason:oq}),cq=x({mode:ay,ruleCount:p().int().min(0),allDevices:y(),deviceIds:C(p().int()),allDevicesExcept:C(p().int()).default([]),skippedDevices:C(sq).default([])}),JCe=x({deviceId:p().int(),name:m(),state:m(),blocking:y()}),YCe=x({deviceId:p().int(),name:m(),phase:S([`open`,`closed`])}),XCe=x({mode:ay,devices:C(JCe),unknown:C(p().int())}),ZCe=x({ruleId:m(),ruleName:m(),deviceId:p().int(),name:m(),since:p(),dropped:p().int().min(0)}),QCe=x({state:iy,targetMode:ay.nullable(),availableModes:C(ay),openings:C(XCe),exclusions:C(YCe),bypassedInputs:C(ZCe).default([])}),lq=x({deviceId:p().int().nullable(),settings:$K,profiles:tq.optional(),coverage:C(cq),live:QCe.optional()}),uq=S([`open`,`closed`,`unknown`,`not-opening`]),dq=x({deviceId:p().int().positive(),reading:uq,state:m().nullable(),unknownWhy:S([`read-failed`,`unknown-word`]).nullable(),online:y().nullable(),controllable:y().default(!1)}),fq=x({deviceIds:C(p().int().positive()).max(500)}),pq=x({sensors:C(dq),readAt:p().int().nonnegative()}),mq=x({deviceId:p().int().nonnegative().optional(),seconds:p().min(0).max(60),profile:A.optional(),ruleId:m(),ruleName:m(),reason:S([`window`,`occupancy`])}),hq=x({rulesLoaded:y(),asks:C(mq).readonly()}),gq={name:`notification-rules`,scope:`system`,mode:`singleton`,methods:{listRules:E(x({}),x({rules:C(sK)}),{auth:`admin`}),getRule:E(x({ruleId:m()}),x({rule:sK.nullable()}),{auth:`admin`}),createRule:E(x({rule:tK}),x({rule:sK}),{kind:`mutation`,auth:`admin`,caller:`required`}),updateRule:E(oK,x({rule:sK}),{kind:`mutation`,auth:`admin`,caller:`required`}),deleteRule:E(x({ruleId:m()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),setRuleEnabled:E(x({ruleId:m(),enabled:y()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),getClipRetentionAsks:E(x({}),hq,{auth:`admin`}),listDeviceMutes:E(x({}),x({mutedDeviceIds:C(p().int()).readonly()}),{auth:`admin`}),setDeviceMuted:E(x({deviceId:p().int(),muted:y()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),testRule:E(x({rule:tK,lookbackMinutes:p().int().min(1).max(1440).default(60)}),x({results:C(pK)}),{kind:`mutation`,auth:`admin`}),previewStateSummary:E(x({rule:tK}),fK,{kind:`mutation`,auth:`admin`,access:`view`}),getConditionCatalog:E(x({}),x({catalog:C(wK),taxonomy:lG.optional()})),getTemplateCatalog:E(x({}),x({vars:C(bK),defaults:C(gK)})),previewTemplate:E(SK,CK,{kind:`mutation`,access:`view`}),getHistory:E(x({filter:AK.default({limit:100})}),x({entries:C(kK)}),{auth:`admin`}),getRuleLastRuns:E(x({}),MK,{auth:`admin`}),resolveArtifactUrl:E(x({artifactId:m().min(1)}),x({url:m().nullable()}),{auth:`admin`}),listSnoozes:E(x({}),x({snoozes:C(FK)}),{caller:`required`}),createSnooze:E(x({snooze:PK}),x({snooze:FK}),{kind:`mutation`,caller:`required`}),cancelSnooze:E(x({snoozeId:m()}),x({success:s(!0)}),{kind:`mutation`,caller:`required`}),getAlarmConfig:E(x({}),lq,{auth:`admin`}),setAlarmConfig:E(x({patch:aq}),lq,{kind:`mutation`,auth:`admin`}),createAlarmProfile:E(nq,lq,{kind:`mutation`,auth:`admin`}),renameAlarmProfile:E(rq,lq,{kind:`mutation`,auth:`admin`}),deleteAlarmProfile:E(iq,lq,{kind:`mutation`,auth:`admin`}),activateAlarmProfile:E(iq,lq,{kind:`mutation`,auth:`admin`}),getAlarmSensors:E(fq,pq,{auth:`admin`})},vocabulary:{notOperatorFacing:`notification rules — authored on their own page`}},$Ce=S([`min`,`low`,`normal`,`high`]),ewe=x({id:m().min(1),title:m().min(1),uri:h().optional(),destructive:y().optional()}),twe=x({image:y(),priority:y(),data:y(),actions:y(),recipients:y()}),_q=x({lastSentAt:p(),lastError:m().nullable(),queueDepth:p().int().nonnegative().meta(k(`count`)),supports:twe}),nwe=x({deviceId:p().int().nonnegative(),title:m().optional(),body:m().min(1),image:m().optional(),priority:$Ce.optional(),channel:m().optional(),recipients:C(m()).optional(),actions:C(ewe).optional(),data:d(m(),u()).optional()}),rwe=x({notificationId:m(),acceptedAt:p()}),vq={name:`notifier`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Notifier],methods:{send:E(nwe,rwe,{kind:`mutation`,auth:`admin`,actions:[{id:`notifier.send`,label:I(`Send a notification`,`Invia una notifica`),phrase:I(`Send “{body}” through {device}`,`Invia «{body}» tramite {device}`),icon:`send`,openArgs:[{key:`title`,label:I(`Title`,`Titolo`),offer:{kind:`text`},optional:!0},{key:`body`,label:I(`Message`,`Messaggio`),offer:{kind:`text`}},{key:`priority`,label:I(`Priority`,`Priorità`),offer:{kind:`enum`,values:[{value:`min`,label:I(`Minimal`,`Minima`)},{value:`low`,label:I(`Low`,`Bassa`)},{value:`normal`,label:I(`Normal`,`Normale`)},{value:`high`,label:I(`High`,`Alta`)}]},optional:!0}]}]}),cancel:E(x({deviceId:p().int().nonnegative(),notificationId:m().min(1)}),v(),{kind:`mutation`,auth:`admin`})},events:{onSent:{data:x({deviceId:p(),notificationId:m(),success:y(),error:m().nullable(),acceptedAt:p()}),notOperatorFacing:`a delivery receipt of a send this system made — not a fact about the world`}},status:{schema:_q,kind:`command-driven`},runtimeState:_q,durability:`session`,history:`none`,vocabulary:{noun:I(`Notifier`,`Notificatore`),order:2110}},yq=x({value:p().nullable().meta(k(`device`)),lastFetchedAt:p()}),bq={name:`numeric-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor],methods:{},status:{schema:yq,kind:`push`},runtimeState:yq,durability:`restored`,history:{fields:{value:{kind:`gauge`,minIntervalMs:3e4}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`Sensor`,`Sensore`),order:5150,state:[{kind:`numeric`,field:`value`,quantity:I(`the reading`,`il valore`),label:I(`Reading`,`Valore`),icon:`gauge`}]}},xq=x({integrationId:m(),displayName:m(),requestedScopes:C(Sf),allowedRedirectPrefixes:C(m()).min(1),allowedPrivateHostPaths:C(m()).optional(),requiresPkce:y().optional(),hubUrl:m().optional(),refreshTokenTtlSec:l([p().int().positive(),s(`never`)]).optional(),instances:C(x({id:m(),displayName:m()})).optional()}),Sq={name:`oauth-integration`,scope:`system`,mode:`collection`,internal:!0,methods:{getDescriptor:E(v(),xq,{auth:`admin`})},vocabulary:{notOperatorFacing:O.IDENTITY}},Cq=S([`text`,`timestamp`,`watermark`]),wq=S([`top-left`,`top-center`,`top-right`,`bottom-left`,`bottom-center`,`bottom-right`,`custom`]),Tq=x({id:m(),kind:Cq,enabled:y(),text:m().optional(),position:wq.optional(),availablePositions:C(wq).readonly(),readOnly:y().optional(),maxCharacters:p().int().positive().optional()}),Eq=x({overlays:C(Tq).readonly()}),Dq=x({enabled:y().optional(),text:m().optional(),position:wq.optional()}).partial(),Oq={name:`osd`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],methods:{setOverlay:E(x({deviceId:p(),overlayId:m(),patch:Dq}),v(),{kind:`mutation`,auth:`admin`})},events:{onStatusChanged:{data:x({deviceId:p(),status:Eq}),notOperatorFacing:`an overlay setting changed — configuration, not a happening`}},status:{schema:Eq,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:I(`On-screen text`,`Testo in sovrimpressione`),order:3190}},kq=1024,Aq=x({id:m().min(1).max(64),name:m().min(1).max(64),text:m().max(kq).default(``)}),jq=a(`kind`,[x({kind:s(`none`)}),x({kind:s(`static`),text:m().max(kq)}),x({kind:s(`template`),templateId:m().min(1).max(64)})]),Mq=x({enabled:y().default(!0),source:jq,schedule:CG.optional(),conditions:zG.optional()}),Nq=x({slotId:m(),kind:Cq,readOnly:y(),cameraEnabled:y(),cameraText:m().optional(),binding:Mq.nullable()}),Pq=S([`written`,`unchanged`,`gated`,`unreadable`,`disabled`,`unbound`,`failed`]),Fq=x({slotId:m(),outcome:Pq,text:m(),reason:m().optional()}),Iq=x({ok:y(),text:m(),notes:C(m())}),Lq={name:`osd-manager`,scope:`system`,mode:`singleton`,methods:{getDeviceOsd:E(x({deviceId:p().int()}),x({supported:y(),slots:C(Nq)}),{auth:`admin`}),getConditionSupport:E(x({}),x({supported:C(m()),catalog:C(wK)}),{auth:`admin`}),setSlotBinding:E(x({deviceId:p().int(),slotId:m().min(1),binding:Mq}),x({slot:Nq,render:Fq}),{kind:`mutation`,auth:`admin`}),clearSlotBinding:E(x({deviceId:p().int(),slotId:m().min(1)}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),setSlotCameraEnabled:E(x({deviceId:p().int(),slotId:m().min(1),enabled:y()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),copyDeviceConfiguration:E(x({sourceDeviceId:p().int(),targetDeviceId:p().int()}),x({copied:p().int().nonnegative(),skipped:p().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),previewSlot:E(x({deviceId:p().int(),slotId:m().min(1),binding:Mq.optional()}),Fq,{kind:`mutation`,auth:`admin`}),previewTemplate:E(x({deviceId:p().int(),text:m().max(kq)}),Iq,{kind:`mutation`,auth:`admin`}),renderDevice:E(x({deviceId:p().int()}),x({results:C(Fq)}),{kind:`mutation`,auth:`admin`}),listTemplates:E(x({}),x({templates:C(Aq)}),{auth:`admin`}),upsertTemplate:E(x({template:Aq}),x({template:Aq}),{kind:`mutation`,auth:`admin`}),deleteTemplate:E(x({templateId:m().min(1).max(64)}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.PIPELINE}},iwe=S([`normal`,`offline`,`on_batteries`]),Rq=p().int().min(4).max(200),zq=Rq.meta(wh({quantity:`mass`,unit:`g`})),Bq=x({foodLevel:p().nullable().meta(k(`none`)),bowlFood:p().nullable().meta(k(`mass`)),eating:y(),supportsMarkRefilled:y(),food1:p().nullable().meta(k(`none`)),food2:p().nullable().meta(k(`none`)),lowFood:y(),batteryPower:p().min(0).max(100).nullable().meta(k(`percentage`)),powerSource:S([`mains`,`battery`]).nullable(),desiccantLeftDays:p().nullable().meta(k(`duration`)),feeding:y(),status:iwe.nullable(),error:m().nullable(),errorCode:p().nullable().meta(k(`none`)),isDualHopper:y(),childLock:y(),indicatorLight:y(),feedSound:y(),volume:p().meta(k(`none`)),lastFeedGrams:Rq.nullable(),lastFeedHopper1:Rq.nullable(),lastFeedHopper2:Rq.nullable(),lastFetchedAt:p()}),Vq={name:`pet-feeder`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.PetFeeder],methods:{feed:E(x({deviceId:p().int().nonnegative(),grams:zq.optional(),hopper1:zq.optional(),hopper2:zq.optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.feed`,label:I(`Feed`,`Dai da mangiare`),phrase:I(`Dispense {grams} from {device}`,`Eroga {grams} da {device}`),icon:`paw-print`,openArgs:[{key:`grams`,label:I(`Grams`,`Grammi`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0}]},{id:`petFeeder.feedHoppers`,label:I(`Feed from both hoppers`,`Eroga da entrambi i serbatoi`),phrase:I(`Dispense {hopper1} and {hopper2} from {device}`,`Eroga {hopper1} e {hopper2} da {device}`),icon:`paw-print`,openArgs:[{key:`hopper1`,label:I(`Hopper 1`,`Serbatoio 1`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0},{key:`hopper2`,label:I(`Hopper 2`,`Serbatoio 2`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0}]}]}),cancelFeed:E(x({deviceId:p().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.cancelFeed`,label:I(`Cancel feeding`,`Annulla l’erogazione`),phrase:I(`Cancel the feeding on {device}`,`Annulla l’erogazione di {device}`),icon:`circle-x`}]}),callPet:E(x({deviceId:p().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.callPet`,label:I(`Call pet`,`Chiama l’animale`),phrase:I(`Call your pet with {device}`,`Chiama l’animale con {device}`),icon:`megaphone`}]}),playSound:E(x({deviceId:p().int().nonnegative(),soundId:p().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.playSound`,label:I(`Play sound`,`Riproduci un suono`),phrase:I(`Play sound {soundId} on {device}`,`Riproduci il suono {soundId} su {device}`),icon:`volume-2`,openArgs:[{key:`soundId`,label:I(`Sound`,`Suono`),offer:{kind:`number`,min:0,step:1}}]}]}),resetDesiccant:E(x({deviceId:p().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.resetDesiccant`,label:I(`Desiccant replaced`,`Essiccante sostituito`),phrase:I(`Mark the desiccant of {device} as replaced`,`Segna come sostituito l’essiccante di {device}`),icon:`refresh-cw`}]}),markFoodReplenished:E(x({deviceId:p().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.foodReplenished`,label:I(`Food refilled`,`Cibo ricaricato`),phrase:I(`Mark {device} as refilled`,`Segna {device} come ricaricato`),icon:`package`}]}),setChildLock:E(x({deviceId:p().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.childLockOn`,label:I(`Child lock on`,`Blocco bambini attivo`),phrase:I(`Turn on the child lock of {device}`,`Attiva il blocco bambini di {device}`),icon:`lock`,args:{on:!0}},{id:`petFeeder.childLockOff`,label:I(`Child lock off`,`Blocco bambini spento`),phrase:I(`Turn off the child lock of {device}`,`Disattiva il blocco bambini di {device}`),icon:`lock-open`,args:{on:!1}}]}),setIndicatorLight:E(x({deviceId:p().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.lightOn`,label:I(`Indicator light on`,`Spia accesa`),phrase:I(`Turn on the indicator light of {device}`,`Accendi la spia di {device}`),icon:`lightbulb`,args:{on:!0}},{id:`petFeeder.lightOff`,label:I(`Indicator light off`,`Spia spenta`),phrase:I(`Turn off the indicator light of {device}`,`Spegni la spia di {device}`),icon:`lightbulb-off`,args:{on:!1}}]}),setFeedSound:E(x({deviceId:p().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.feedSoundOn`,label:I(`Feeding sound on`,`Suono di erogazione attivo`),phrase:I(`Turn on the feeding sound of {device}`,`Attiva il suono di erogazione di {device}`),icon:`volume-2`,args:{on:!0}},{id:`petFeeder.feedSoundOff`,label:I(`Feeding sound off`,`Suono di erogazione spento`),phrase:I(`Turn off the feeding sound of {device}`,`Disattiva il suono di erogazione di {device}`),icon:`volume-x`,args:{on:!1}}]}),setVolume:E(x({deviceId:p().int().nonnegative(),level:p().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.volume`,label:I(`Set volume`,`Imposta il volume`),phrase:I(`Set the volume of {device} to {level}`,`Imposta il volume di {device} a {level}`),icon:`volume-2`,openArgs:[{key:`level`,label:I(`Volume`,`Volume`),offer:{kind:`number`,min:0,step:1}}]}]})},status:{schema:Bq,kind:`poll`},runtimeState:Bq,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:I(`Pet feeder`,`Distributore di cibo`),order:2030,state:[{kind:`boolean`,field:`lowFood`,label:I(`Food low`,`Cibo in esaurimento`),whenTrue:I(`When {device} runs low on food`,`Quando il cibo di {device} sta finendo`),whenFalse:I(`When {device} has enough food again`,`Quando {device} ha di nuovo cibo a sufficienza`),icon:`package`},{kind:`boolean`,field:`feeding`,label:I(`Feeding`,`In erogazione`),whenTrue:I(`When {device} starts feeding`,`Quando {device} inizia a erogare`),whenFalse:I(`When {device} finishes feeding`,`Quando {device} finisce di erogare`),icon:`paw-print`},{kind:`numeric`,field:`desiccantLeftDays`,quantity:I(`the desiccant life`,`la durata dell’essiccante`),label:I(`Desiccant`,`Essiccante`),unit:`d`,icon:`calendar-clock`}]}},Hq=x({waterLevel:p().min(0).max(100).nullable().meta(k(`percentage`)),waterVolume:p().min(0).nullable().meta(k(`volume`)),empty:y().nullable(),pumpRunning:y().nullable(),error:m().nullable(),lastFetchedAt:p()}),Uq=`water`;function awe(e){let t=e.waterLevel!==null||e.empty===null?null:e.empty?`empty`:`ok`;return{key:Uq,label:`Water`,level:e.waterLevel,status:t,kind:`supply`,form:`tank`,lastResetAt:null,resettable:!1}}var owe=p().int().nonnegative(),Wq={name:`pet-fountain`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.PetFountain],power:{kind:`field`,field:`pumpRunning`,set:`setPump`},methods:{setPump:E(x({deviceId:owe,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFountain.pumpOn`,label:I(`Pump on`,`Pompa accesa`),phrase:I(`Start the pump of {device}`,`Avvia la pompa di {device}`),icon:`play`,args:{on:!0}},{id:`petFountain.pumpOff`,label:I(`Pump off`,`Pompa spenta`),phrase:I(`Stop the pump of {device}`,`Ferma la pompa di {device}`),icon:`square`,args:{on:!1}}]})},status:{schema:Hq,kind:`push`},runtimeState:Hq,durability:`session`,history:{fields:{waterLevel:{kind:`gauge`,unit:`%`,deadband:1},waterVolume:{kind:`gauge`,unit:`L`}}},vocabulary:{noun:I(`Pet fountain`,`Fontana per animali`),order:2040,state:[{kind:`boolean`,field:`empty`,label:I(`Tank empty`,`Serbatoio vuoto`),whenTrue:I(`When the tank of {device} is empty`,`Quando il serbatoio di {device} è vuoto`),whenFalse:I(`When the tank of {device} is refilled`,`Quando il serbatoio di {device} viene riempito`),icon:`droplet`},{kind:`numeric`,field:`waterLevel`,quantity:I(`the water level`,`il livello dell’acqua`),label:I(`Water level`,`Livello dell’acqua`),unit:`%`,icon:`droplets`}]}},swe=S(Rd),Gq={min:1,max:8},Kq=S([`intel-core-ultra`,`intel-n-series`,`apple-m-base`,`apple-m-pro`,`amd-phoenix`,`unknown`]),qq=S([`intel-npu`,`intel-igpu`,`amd-igpu`,`amd-npu`,`x86-cpu`,`arm-cpu`,`apple-ane`,`coral`]),Jq=a(`kind`,[x({kind:s(`capacity`),sessions:p(),minSessions:p()}),x({kind:s(`tie-faster`),over:m(),recallDelta:p()}),x({kind:s(`stepped-down`),from:m(),to:m(),limitedBy:m()}),x({kind:s(`no-fit-lightest`),sessions:p(),minSessions:p()}),x({kind:s(`derived-latency`),modelId:m()}),x({kind:s(`cpu-device`)}),x({kind:s(`device-disabled`)}),x({kind:s(`device-unavailable`)}),x({kind:s(`node-offline`)}),x({kind:s(`no-hardware-facts`)}),x({kind:s(`no-measured-data`),hardwareClass:Kq}),x({kind:s(`no-family-build`),format:swe}),x({kind:s(`kept-custom-pin`),modelId:m(),deviceKey:m()})]),Yq=S([`custom-pin`]),Xq=a(`kind`,[x({kind:s(`table`)}),x({kind:s(`node-benchmark`),resultId:m(),measuredAtMs:p()}),x({kind:s(`estimated`),estimatedFrom:Kq})]),Zq=x({modelId:m(),p50Ms:p(),fps:p(),measured:y(),source:Xq.optional(),estimatedFrom:Kq.optional(),capacitySessions:p(),personRecall:p()}),Qq=x({deviceKey:m(),accelerator:qq.nullable(),enabled:y(),available:y(),chosen:Zq.nullable(),kept:Yq.optional(),reasons:C(Jq).readonly()}),$q=x({nodeId:m(),reachable:y(),hardwareClass:Kq.nullable(),cpuModel:m().nullable(),skipped:y(),acceleratorModelId:m().nullable(),devices:C(Qq).readonly(),reasons:C(Jq).readonly()}),eJ=x({stepId:m(),before:m().nullable(),after:m().nullable()}),tJ=x({nodeId:m(),deviceKey:m(),madeExplicit:y(),modelPins:C(eJ).readonly(),thresholds:C(x({stepId:m(),keys:C(m()).readonly()})).readonly()}),nJ=a(`kind`,[x({kind:s(`custom-pin-kept`),nodeId:m(),deviceKey:m(),modelId:m()}),x({kind:s(`custom-registry-unreadable`),error:m()})]),rJ=x({headroom:p().min(.3).max(.5).default(.4),minSessionsPerDevice:p().int().min(Gq.min).max(Gq.max).default(2)}),iJ=x({planHash:m(),family:s(`yolov9`),headroom:p(),minSessionsPerDevice:p(),cameraFps:p(),generatedAt:p(),nodes:C($q).readonly(),nodeChanges:C(tJ).readonly(),warnings:C(nJ).readonly()}),aJ=x({planHash:m(),headroom:p().min(.3).max(.5).default(.4),minSessionsPerDevice:p().int().min(Gq.min).max(Gq.max).default(2)}),oJ=x({phase:S([`download`,`node-models`,`redispatch`]),ok:y(),detail:m()}),sJ=a(`kind`,[x({kind:s(`applied`),planHash:m(),phases:C(oJ).readonly()}),x({kind:s(`aborted`),phases:C(oJ).readonly()}),x({kind:s(`stale`),plan:iJ}),x({kind:s(`refused`),reason:S([`apply-in-progress`])})]),cJ=S([`least-loaded`,`share`]),lJ=`share`,cwe=`sessionPlacement`;function lwe(e){let t=cJ.safeParse(e);return t.success?t.data:lJ}var uJ=x({nodes:d(m(),p().positive()).default({}),devices:d(m(),d(m(),p().positive())).default({})}),dJ=x({windowMs:p().int().min(6e4).max(1440*60*1e3).default(3600*1e3)}),fJ=x({deviceKey:m(),sessionsNow:p(),sessionsStarted:p(),observedShare:p().nullable()}),pJ=x({nodeId:m(),sessionsNow:p(),sessionsStarted:p(),observedShare:p().nullable(),peakSessions:p(),yieldsAway:p(),devices:C(fJ).readonly()}),mJ=x({deviceId:p(),deviceKey:m(),reason:S([`disabled`,`absent`])}),hJ=x({policy:cJ,windowMs:p(),observedForMs:p(),sessionsNow:p(),clusterPeakSessions:p(),nodes:C(pJ).readonly(),stalePins:C(mJ).readonly()}),gJ=S([`hardware`,`benchmark`]),_J=S([`no-benchmark-results`,`partial-benchmark-results`]),vJ=x({headroom:p().min(.3).max(.5).default(.4),source:gJ.default(`hardware`)}),yJ=x({deviceKey:m(),share:p(),modelId:m().nullable(),fps:p().nullable(),measured:y(),suggestedMaxSessions:p().nullable()}),bJ=x({nodeId:m(),share:p().nullable(),capacitySessions:p(),devices:C(yJ).readonly(),skippedReason:m().nullable(),capacitySource:gJ.nullable(),capacityFallback:_J.nullable()}),xJ=x({headroom:p(),source:gJ,cameraFps:p(),minSessionsPerDevice:p(),nodes:C(bJ).readonly()}),SJ=S([`hardware`,`benchmark`,`manual`]),CJ=`benchmark`;function wJ(e){return e!==`manual`}var uwe=.4,dwe=`shareSource`;function fwe(e){if(e===`auto`)return`hardware`;let t=SJ.safeParse(e);return t.success?t.data:CJ}var TJ=x({source:SJ}),pwe=x({nodes:d(m(),p()),devices:d(m(),d(m(),p()))}),EJ=x({deviceKey:m(),eligible:y(),configuredPct:p(),effectivePct:p()}),DJ=x({nodeId:m(),eligible:y(),configuredPct:p(),effectivePct:p(),capacitySource:gJ.nullable(),capacityFallback:_J.nullable(),devices:C(EJ).readonly()}),OJ=x({source:SJ,policy:cJ,autoPending:y(),computedAt:p().nullable(),trigger:m().nullable(),nodes:C(DJ).readonly(),nodeWeights:d(m(),p()),deviceWeights:d(m(),d(m(),p()))}),kJ=[`motion-without-detections`,`detections-under-floor`,`inference-too-slow`,`frames-shed`,`inference-device-unusable`],AJ=S(kJ),jJ=S([`info`,`warning`,`critical`]),MJ=a(`type`,[x({type:s(`camera`),deviceId:p()}),x({type:s(`node`),nodeId:m()}),x({type:s(`inference-device`),nodeId:m(),deviceKey:m()})]),NJ=x({id:m(),kind:AJ,severity:jJ,subject:MJ,what:m(),evidence:d(m(),p().nullable()),action:m()}),PJ=x({source:m(),entries:p().nullable()}),FJ=x({nodeId:m(),sessionsNow:p(),unusableDevices:C(m()).readonly(),devices:C(x({deviceKey:m(),sessionsNow:p(),usable:y()})).readonly()}),IJ=x({deviceId:p(),nativeCropMissesSincePreviousTick:p().nullable()}),LJ=x({generatedAt:p(),tickMs:p(),camerasSeen:p().nullable(),findings:C(NJ).readonly(),cameraSignals:C(IJ).readonly(),nodes:C(FJ).readonly(),sources:C(PJ).readonly(),notCovered:C(m()).readonly()}),RJ=x({history:p().int().min(1).max(24).default(1)}),zJ=x({latest:LJ.nullable(),previous:C(LJ).readonly()}),mwe=x({engine:bH.optional(),steps:C(mH).readonly(),audio:x({engine:bH.optional(),modelId:m().optional(),enabled:y(),settings:d(m(),u()).readonly().optional()}).nullable().optional()}),BJ=x({modelId:m().optional(),settings:d(m(),u()).optional(),jumpDeviceKey:m().optional()}),VJ=x({maxCameras:p().int().nonnegative().nullable().default(null),detectWeight:p().positive().optional(),detect:y().optional(),decode:y().optional(),audio:y().optional(),ingest:y().optional(),decodeBudgetMb:p().int().min(1024).max(65536).optional(),maxLiveDecodeWorkers:p().int().min(1).max(32).optional(),reachableHost:m().optional(),color:Pu.optional(),stepSettings:d(m(),d(m(),u()).readonly()).optional(),inferenceDevices:d(m(),x({enabled:y(),weight:p().positive().optional(),maxSessions:p().int().positive().optional(),steps:d(m(),BJ).optional()})).optional()}),hwe=d(m(),d(m(),u()).readonly()),HJ=S([`pipeline`,`onboard`,`none`]),gwe=x({stepToggles:d(m(),y()).optional(),stepSettings:hwe.optional()}),UJ=x({deviceId:p(),agentNodeId:m(),pinned:y(),reason:S([`manual`,`capacity`,`hardware-affinity`,`failover`,`rebalance`]),assignedAt:p()}),WJ=x({nodeId:m(),online:y(),load:NU,score:p(),decodeHwaccel:m().nullable()}),GJ=x({totalAgents:p(),onlineAgents:p(),totalCameras:p(),attachedCameras:p(),activeCameras:p(),avgInferenceTimeMs:p(),queueDepth:p()}),KJ=d(m(),m()),qJ=x({ownerNodeId:m(),reachableHost:m().optional(),configIssue:m().optional()}),JJ=x({camStreamId:m(),codec:m(),width:p(),height:p(),fps:p(),kind:m()}),YJ=x({streams:C(JJ).readonly()}),XJ=x({detectionNodeId:m().nullable(),decoderNodeId:m().nullable(),audioNodeId:m().nullable(),sourceNodeId:m().nullable(),pinned:x({detection:y(),decoder:y(),audio:y()}),reasons:x({detection:m().optional(),decoder:m().optional(),audio:m().optional()})}),ZJ=x({profile:m(),status:m(),codec:m(),width:p(),height:p(),subscribers:p(),inFps:p().nullable()}),QJ=x({profiles:C(ZJ).readonly(),webrtcSessions:p(),rtspRestream:y()}),$J=x({nodeId:m()}),eY=x({enabled:y(),fps:p()}),tY=S([`idle`,`installing`,`verifying`,`ready`,`failed`]),nY=x({state:tY,error:m().optional()}),rY=S([`idle`,`watching`,`active`]),iY=x({nodeId:m(),engine:x({backend:m(),device:m()}),phase:rY,configuredFps:p(),actualFps:p(),queueDepth:p(),avgInferenceMs:p(),provisioning:nY}),aY=x({nodeId:m(),enabled:y()}),oY=Ac,sY=x({mode:oY,active:y(),storageBytes:p()}),cY=S([`source`,`broker`,`detection`,`recording`,`switches`]),lY=S([`timeout`,`error`,`partial`]),uY=x({stage:cY,reason:lY,elapsedMs:p()}),dY=x({state:S([`idle`,`running`,`done`,`error`]),total:p().int().nonnegative(),completed:p().int().nonnegative(),currentDeviceId:p().int().nullable(),failed:C(p().int()).readonly(),mediaDropped:p().int().nonnegative(),tracks:p().int().nonnegative(),events:p().int().nonnegative(),startedAtMs:p().int().nullable(),finishedAtMs:p().int().nullable(),error:m().nullable()}),fY=x({deviceId:p(),assignment:XJ,source:YJ,broker:QJ.nullable(),decoder:$J.nullable(),motion:eY.nullable(),detection:iY.nullable(),audio:aY.nullable(),recording:sY.nullable(),switchedOff:C(Ya).readonly(),cameraSensors:Kz.optional(),degraded:C(uY).readonly(),fetchedAt:p()}),pY=[`disabled`,`unavailable`,`cannot-host-camera-root`,`accelerator-preferred`],mY=S(pY),_we=x({key:m(),backend:m(),device:m(),format:S(Rd),available:y(),presence:S([`present`,`absent`,`unknown`]).optional(),enabled:y(),weight:p(),maxSessions:p().nullable(),defaultModelId:m(),steps:d(m(),BJ).optional(),exclusion:mY.nullable()}),hY=a(`kind`,[x({kind:s(`stored`),modelId:m()}),x({kind:s(`absent`),defaultModelId:m()}),x({kind:s(`unreadable`),reason:S(oB),error:m().optional()})]),vwe=x({nodeId:m(),reachable:y(),devices:C(_we).readonly()}),gY=x({deviceId:p().int().nonnegative(),config:zz.nullable()}),_Y=S([`unknown-camera`,`out-of-range`,`no-burst-producer`,`already-looked`]),vY=x({deviceId:p().int().nonnegative(),afterMs:p().finite(),reason:m()}),yY=x({scheduled:y(),dueInMs:p().optional(),refusedBecause:_Y.optional()}),bY={name:`pipeline-orchestrator`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,exposesDeviceSettings:!0,methods:{requestOccupancyLook:E(vY,yY,{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:E(Xc,x({paused:s(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:E(Xc,x({resumed:s(!0)}),{kind:`mutation`,auth:`admin`}),assignPipeline:E(x({deviceId:p(),agentNodeId:m()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),unassignPipeline:E(x({deviceId:p()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),setPipelineDevicePin:E(x({deviceId:p(),deviceKey:m()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),getPipelineDevicePin:E(x({deviceId:p()}),x({deviceKey:m().nullable()})),rebalance:E(v(),x({migrated:p(),skipped:C(x({deviceId:p(),targetNodeId:m(),reason:m()})).default([])}),{kind:`mutation`,auth:`admin`}),getPipelineAssignments:E(v(),C(UJ).readonly()),getPipelineAssignment:E(x({deviceId:p()}),UJ.nullable()),getAgentLoad:E(v(),C(WJ).readonly()),getClusterModelChoice:E(x({stepId:m()}),hY),getGlobalMetrics:E(v(),GJ),getCameraMetrics:E(x({deviceId:p()}),DH.nullable()),getCapabilityBindings:E(x({nodeId:m()}),KJ),setCapabilityBinding:E(x({nodeId:m(),capName:m(),addonId:m()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),getIngestOwner:E(v(),qJ),assignAudio:E(x({deviceId:p(),nodeId:m()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),unassignAudio:E(x({deviceId:p()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),getAudioAssignment:E(x({deviceId:p()}),x({nodeId:m(),pinned:y(),assignedAt:p()}).nullable()),getAudioNodeLoad:E(v(),C(x({nodeId:m(),deviceCount:p()}))),getAudioAssignments:E(v(),C(x({deviceId:p(),nodeId:m(),pinned:y(),assignedAt:p()}))),getAgentSettings:E(x({agentNodeId:m()}),VJ.nullable()),listAgentSettings:E(v(),C(x({nodeId:m(),settings:VJ})).readonly()),removeAgentSettings:E(x({agentNodeId:m()}),x({success:y(),removed:y()}),{kind:`mutation`,auth:`admin`}),setAgentMaxCameras:E(x({agentNodeId:m(),maxCameras:p().int().nonnegative().nullable()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),setAgentCapabilities:E(x({agentNodeId:m(),detect:y().nullable().optional(),audio:y().nullable().optional(),ingest:y().nullable().optional()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),setAgentDecodeLimits:E(x({agentNodeId:m(),decodeBudgetMb:p().int().min(1024).max(65536).nullable().optional(),maxLiveDecodeWorkers:p().int().min(1).max(32).nullable().optional()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),setAgentReachableHost:E(x({agentNodeId:m(),reachableHost:m().nullable().optional(),color:Pu.nullable().optional()}).refine(e=>e.reachableHost!==void 0||e.color!==void 0,{message:`reachableHost or color required`}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),setAgentInferenceDevices:E(x({agentNodeId:m(),inferenceDevices:d(m(),x({enabled:y(),weight:p().positive().optional(),maxSessions:p().int().positive().optional(),steps:d(m(),BJ).optional()}))}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),setNodeStepSettings:E(x({agentNodeId:m(),addonId:m(),settings:d(m(),u()).nullable()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),getNodeInferenceDevices:E(x({nodeId:m()}),vwe),forgetInferenceDevice:E(x({agentNodeId:m(),deviceKey:m()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),resetNodePipelineDefaults:E(x({agentNodeId:m()}),x({success:s(!0),effectiveModelId:m().nullable()}),{kind:`mutation`,auth:`admin`}),planAutoTune:E(rJ,iJ,{auth:`admin`}),applyAutoTune:E(aJ,sJ,{kind:`mutation`,auth:`admin`}),setLoadBalancingShares:E(uJ,x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),getPlacementStats:E(dJ,hJ,{auth:`admin`}),getHealthDigest:E(RJ,zJ,{auth:`admin`}),suggestShares:E(vJ,xJ,{auth:`admin`}),getEffectiveShares:E(v(),OJ,{auth:`admin`}),setShareSource:E(TJ,x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkPreflight:E(IH,VH,{auth:`admin`}),startNodeBenchmark:E(IH,a(`kind`,[x({kind:s(`started`),runId:m()}),x({kind:s(`refused`),preflight:VH})]),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkStatus:E(v(),nU,{auth:`admin`}),abortNodeBenchmark:E(x({runId:m()}),x({aborted:y()}),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkCandidates:E(x({nodeId:m()}),oU,{auth:`admin`}),listNodeBenchmarkResults:E(iU,C(aU).readonly(),{auth:`admin`}),deleteNodeBenchmarkResult:E(x({id:m()}),x({deleted:y()}),{kind:`mutation`,auth:`admin`}),getCameraSettings:E(x({deviceId:p()}),gwe.nullable()),setCameraStepToggle:E(x({deviceId:p(),addonId:m(),enabled:y().nullable()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),getCameraDetectionSource:E(x({deviceId:p()}),x({source:HJ,explicit:y(),onboard:x({available:y(),geometry:S([`boxed`,`while-streaming`,`flag-only`,`unknown`])})})),setCameraDetectionSource:E(x({deviceId:p(),source:HJ}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),setCameraStepSettings:E(x({deviceId:p(),addonId:m(),settings:d(m(),u()).nullable()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),resolvePipeline:E(x({deviceId:p(),agentNodeId:m().optional()}),mwe),getCameraSwitches:E(x({deviceId:p()}),Za,{role:`viewer`}),setCameraSwitch:E(x({deviceId:p(),switchId:Ya,enabled:y()}),Za,{kind:`mutation`,auth:`admin`}),getCameraStatus:E(x({deviceId:p()}),fY),getCameraStatuses:E(x({deviceIds:C(p()).optional()}),C(fY).readonly()),setCameraSensors:E(gY,x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),reconcileFromDisk:E(v(),dY,{kind:`mutation`,auth:`admin`}),getReconcileFromDiskStatus:E(v(),dY,{auth:`admin`})},vocabulary:{notOperatorFacing:O.PIPELINE}},xY=x({id:m(),name:m(),sampleCount:p().int().nonnegative(),coverMediaId:p().int().optional(),coverBase64:m().optional()}),ywe=x({id:m(),text:m(),score:p(),addedAt:p().int(),deviceId:p().int().optional(),base64:m().optional(),mediaId:p().int().optional(),keyFrameMediaId:p().int().optional(),plateBbox:_y.optional()}),SY=x({plateId:m(),deviceId:p().int(),trackId:m(),timestamp:p().int(),text:m(),score:p(),corrected:y(),recognizedVehicleId:m().optional(),vehicleName:m().optional(),assigned:y(),plateBbox:_y.optional(),keyFrameMediaId:p().int().optional(),base64:m().optional(),cropUrl:m().optional(),cropMissReason:m().optional()}),bwe=x({mediaId:p().int(),kind:m(),url:m(),sizeBytes:p(),timestamp:p()}),xwe=x({plateIds:C(m()).readonly(),representativePlateId:m(),representativeText:m(),size:p().int(),cohesion:p()}),CY={name:`plate-gallery`,role:{feature:`plate-assignment`},scope:`system`,mode:`singleton`,methods:{listPlates:E(x({deviceId:p().int().optional(),limit:p().int().positive().optional(),includeCrops:y().optional()}).optional(),C(SY).readonly()),getPlateByTrack:E(x({deviceId:p().int(),trackId:m()}),SY.nullable(),{role:`viewer`}),getPlateMedia:E(x({plateId:m()}),C(bwe).readonly()),searchPlates:E(x({text:m().min(1),maxDistance:p().int().min(0).optional(),limit:p().int().positive().optional(),includeCrops:y().optional()}),C(SY).readonly()),suggestPlateClusters:E(x({maxDistance:p().int().min(0).optional(),minClusterSize:p().int().min(2).optional(),limit:p().int().positive().optional()}).optional(),C(xwe).readonly()),correctPlateText:E(x({plateId:m(),text:m().min(1)}),v(),{kind:`mutation`,auth:`admin`}),deletePlate:E(x({plateId:m()}),v(),{kind:`mutation`,auth:`admin`}),listVehicles:E(x({includeCrops:y().optional()}).optional(),C(xY).readonly()),createVehicle:E(x({name:m().min(1)}),xY,{kind:`mutation`,auth:`admin`}),renameVehicle:E(x({id:m(),name:m().min(1)}),v(),{kind:`mutation`,auth:`admin`}),deleteVehicle:E(x({id:m()}),v(),{kind:`mutation`,auth:`admin`}),listVehicleSamples:E(x({vehicleId:m()}),C(ywe).readonly()),removeVehicleSample:E(x({vehicleId:m(),sampleId:m()}),v(),{kind:`mutation`,auth:`admin`}),moveVehicleSample:E(x({sampleId:m().min(1),toVehicleId:m().min(1)}),v(),{kind:`mutation`,auth:`admin`}),assignPlate:E(x({plateId:m(),vehicleId:m()}),v(),{kind:`mutation`,auth:`admin`}),unassignPlate:E(x({plateId:m()}),v(),{kind:`mutation`,auth:`admin`}),assignPlates:E(x({plateIds:C(m()).min(1),vehicleId:m()}),x({assigned:p().int(),failed:C(m()).readonly()}),{kind:`mutation`,auth:`admin`}),unassignPlates:E(x({plateIds:C(m()).min(1)}),x({unassigned:p().int(),failed:C(m()).readonly()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`the plate gallery — curated on its own page`}},wY={"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}}}},TY={"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}},EY=.5,Swe=.05,DY=2e3,OY=p().nullable().transform(e=>e!==null&&Number.isFinite(e)&&e>0?e:null),kY=m().nullable().transform(e=>e!==null&&e.trim()!==``?e:null),AY=x({int8:OY,fp16:OY}),jY=x({deviceKey:m(),fullDeviceName:kY,executionUnits:OY,clockMHz:OY,gops:AY.nullable(),architecture:kY,npuName:kY,tops:OY,vendor:kY,webgpuArchitecture:kY,webgpuDevice:kY,computeUnits:OY}),Cwe=x({accelerators:C(jY).nullable()}),MY=[{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*DY}},{hardwareClass:`amd-phoenix`,accelerator:`amd-igpu`,score:{metric:`cu`,value:12}}];function wwe(e){let t=Cwe.safeParse(e);return!t.success||t.data.accelerators===null?null:t.data.accelerators}function NY(e){return e!==null&&e>0?e:null}function PY(e){let t=[],n=NY(e.gops?.int8??null);n!==null&&t.push({metric:`gops-int8`,value:n});let r=NY(e.gops?.fp16??null);r!==null&&t.push({metric:`gops-fp16`,value:r});let i=NY(e.executionUnits),a=NY(e.clockMHz);i!==null&&a!==null&&t.push({metric:`eu-mhz`,value:i*a});let o=NY(e.computeUnits);o!==null&&t.push({metric:`cu`,value:o});let s=NY(e.tops);return s!==null&&t.push({metric:`tops`,value:s}),t}function FY(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 IY(e,t,n){for(let r of PY(e))if(FY(t,r,n)!==null)return r;return null}function LY(e,t,n=MY){return IY(e,t,n)!==null}function RY(e,t,n){if(t!==`unknown`)return e[t]?.[n]}function Twe(e){return Math.round(e*10)/10}function Ewe(e){return Math.min(2,Math.max(EY,e))}function Dwe(e,t,n){let r={};for(let[i,a]of Object.entries(e))r[i]={p50Ms:Twe(a.p50Ms/t),fps:Math.max(1,Math.round(a.fps*t)),measured:!1,estimatedFrom:n};return r}function zY(e){let t=e.perf??wY,n=e.references??MY,r=RY(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:IY(e.report,e.accelerator,n);if(i===null)return r===void 0?null:{column:r,estimatedFrom:null};let a=FY(e.accelerator,i,n),o=a===null?void 0:RY(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:Dwe(o,Ewe(s),a.hardwareClass),estimatedFrom:a.hardwareClass}}var BY=S(Rd),Owe=S([`videotoolbox`,`cuda`,`nvdec`,`vaapi`,`qsv`,`d3d11va`,`dxva2`,`amf`,`vdpau`,`drm`,`coreml`,`tensorrt`,`openvino`,`directml`,`webgpu`,`none`]).nullable().optional(),kwe=x({preferred:C(m()).readonly(),rationale:m()}),VY=S([`h264_videotoolbox`,`hevc_videotoolbox`,`h264_vaapi`,`hevc_vaapi`,`h264_nvenc`,`hevc_nvenc`,`h264_qsv`,`hevc_qsv`,`h264_amf`,`hevc_amf`,`libx264`,`libx265`]);x({encoders:C(x({encoder:VY,codec:S([`H264`,`H265`]),family:S([`videotoolbox`,`vaapi`,`nvenc`,`qsv`,`amf`,`software`]),available:y(),reason:m().optional()})).readonly(),defaultH264:VY,defaultH265:VY,probedAt:p()}),x({methods:C(m()).readonly(),probedAt:p()});var Awe=S([`darwin`,`linux`,`win32`]),jwe=S([`arm64`,`x64`]),Mwe=x({type:S([`nvidia`,`amd`,`intel`,`apple`]),name:m(),memoryMB:p().optional()}),Nwe=x({type:S([`apple-ane`,`intel-npu`,`amd-xdna`]),name:m().optional(),generation:S([`xdna1`,`xdna2`]).optional()}),HY=S([`usb`,`pci`]),Pwe=x({type:s(`coral-edgetpu`),bus:m().optional(),count:p().int().nonnegative().optional(),units:C(x({bus:HY,count:p().int().nonnegative()})).readonly().optional(),unavailable:C(x({bus:HY,count:p().int().nonnegative(),reason:S([`driver-missing`,`device-not-accessible`])})).readonly().optional()}),UY=x({platform:Awe,arch:jwe,cpuModel:m(),cpuCores:p(),totalRAM_MB:p(),availableRAM_MB:p(),gpu:Mwe.nullable(),npu:Nwe.nullable(),coral:Pwe.nullable().optional(),accelerators:C(jY).readonly().optional()}),WY=x({runtime:s(`python`),backend:m(),format:S([`onnx`,`coreml`,`openvino`,`tflite`]),score:p(),reason:m(),available:y()}),GY=x({key:m(),backend:m(),device:m(),format:BY,runtime:s(`python`),score:p(),available:y()}),Fwe=x({hardware:UY,scores:C(WY).readonly(),bestScore:WY,pythonPath:m().nullable(),devices:C(GY).readonly()}),Iwe=x({modelId:m(),name:m(),minRAM_MB:p(),accuracyScore:p(),formats:C(m()).readonly()}),Lwe=x({modelId:m(),runtime:s(`python`),backend:m(),format:BY,reason:m()}),Rwe=x({devices:C(GY).readonly(),appeared:C(m()).readonly(),disappeared:C(m()).readonly(),usbBus:S([`observed`,`unobservable`]),decidedBy:S([`usb-ids`,`pci`,`delegate-fallback`,`none`])}),KY={name:`platform-probe`,scope:`system`,mode:`singleton`,methods:{getCapabilities:E(v(),Fwe),getHardware:E(v(),UY),resolveInferenceConfig:E(x({requirements:C(Iwe).readonly()}),Lwe),resolveHwAccel:E(x({prefer:Owe}),kwe),rescanAccelerators:E(v(),Rwe,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.CLUSTER}},qY=x({power:p().optional().meta(k(`power`,{label:`Power`})),energy:p().optional().meta(k(`energy`,{label:`Energy`})),voltage:p().optional().meta(k(`voltage`,{label:`Voltage`})),current:p().optional().meta(k(`current`,{label:`Current`})),apparentPower:p().optional().meta(k(`apparent-power`)),powerFactor:p().min(0).max(1).optional().meta(k(`ratio`)),lastFetchedAt:p()}),zwe=[j.Sensor,j.Switch,j.Light,j.Fan,j.Climate,j.Humidifier,j.WaterHeater,j.MediaPlayer,j.Washer,j.Dryer,j.Dishwasher,j.Vacuum,j.LawnMower,j.PetFeeder],Bwe=zwe.filter(e=>e!==j.Sensor);function JY(e,t){return{id:e,cardinality:`scalar`,vocabulary:{cap:`power-meter`,stateField:e},deviceTypes:Bwe,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 Vwe={version:1,targets:[JY(`power`,`W`),JY(`energy`,`kWh`),JY(`voltage`,`V`),JY(`current`,`A`)]},YY={name:`power-meter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:zwe,deviceConfig:{ui:{kind:`widget`,widgetId:`host/power-meter-line`,tab:`power`,placement:`hero`,label:`Power`,order:4}},methods:{},status:{schema:qY,kind:`push`},runtimeState:qY,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:Vwe,vocabulary:{noun:I(`Power meter`,`Misuratore di energia`),order:5160,state:[{kind:`numeric`,field:`power`,quantity:I(`the power draw`,`il consumo`),label:I(`Power`,`Potenza`),unit:`W`,icon:`zap`},{kind:`numeric`,field:`energy`,quantity:I(`the energy used`,`l’energia consumata`),label:I(`Energy`,`Energia`),unit:`kWh`,icon:`zap`},{kind:`numeric`,field:`voltage`,quantity:I(`the voltage`,`la tensione`),label:I(`Voltage`,`Tensione`),unit:`V`,icon:`zap`},{kind:`numeric`,field:`current`,quantity:I(`the current`,`la corrente`),label:I(`Current`,`Corrente`),unit:`A`,icon:`zap`}]}},Hwe=x({latitude:p().min(-90).max(90).meta(k(`angle`)),longitude:p().min(-180).max(180).meta(k(`angle`)),accuracyMeters:p().nonnegative().meta(k(`length`))}),XY=x({state:m(),location:m().nullable(),gps:Hwe.nullable(),lastChangedAt:p()}),ZY={name:`presence`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Presence],methods:{},status:{schema:XY,kind:`push`},runtimeState:XY,durability:`restored`,history:`none`,volatileStateFields:[`lastChangedAt`],vocabulary:{noun:I(`Presence`,`Presenza`),order:5170,state:[{kind:`value`,field:`state`,label:I(`Where`,`Posizione`),phrase:I(`When {device} is at {value}`,`Quando {device} è in {value}`),icon:`map-pin`}]}},QY=x({pressure:p().nullable().meta(k(`pressure`,{precision:0})),lastFetchedAt:p()}),$Y={name:`pressure-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor],methods:{},status:{schema:QY,kind:`push`},runtimeState:QY,durability:`restored`,history:{fields:{pressure:{kind:`gauge`,unit:`hPa`,deadband:.1}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`Pressure`,`Pressione`),order:5180,state:[{kind:`numeric`,field:`pressure`,quantity:I(`the pressure`,`la pressione`),label:I(`Pressure`,`Pressione`),unit:`hPa`,icon:`gauge`}]}},eX=a(`kind`,[$z,eB]),tX=x({id:p(),enabled:y(),shape:eX}),nX=x({enabled:y(),regions:C(tX).nullable(),audioEnabled:y().nullable(),lastFetchedAt:p()}),rX=x({maxRegions:p(),supportedShapes:C(rB),polygonVertices:iB.optional(),supportsAudioMute:y()}),iX=x({enabled:y().optional(),regions:C(tX).optional()}),aX={name:`privacy-mask`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/privacy-mask-grid`,tab:`image`,label:`Privacy Mask`}},methods:{getOptions:E(x({deviceId:p()}),rX),setMask:E(x({deviceId:p(),patch:iX}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`privacy.maskOn`,label:I(`Privacy mask on`,`Maschera privacy attiva`),phrase:I(`Cover the privacy zones of {device}`,`Oscura le zone private di {device}`),icon:`eye-off`,args:{patch:{enabled:!0}}},{id:`privacy.maskOff`,label:I(`Privacy mask off`,`Maschera privacy spenta`),phrase:I(`Uncover the privacy zones of {device}`,`Scopri le zone private di {device}`),icon:`eye`,args:{patch:{enabled:!1}}}]}),setAudioEnabled:E(x({deviceId:p(),enabled:y()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`privacy.micOn`,label:I(`Microphone on`,`Microfono attivo`),phrase:I(`Turn on the microphone of {device}`,`Attiva il microfono di {device}`),icon:`mic`,args:{enabled:!0}},{id:`privacy.micOff`,label:I(`Microphone off`,`Microfono spento`),phrase:I(`Turn off the microphone of {device}`,`Disattiva il microfono di {device}`),icon:`mic-off`,args:{enabled:!1}}]})},status:{schema:nX,kind:`poll`},runtimeState:nX,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`Privacy`,`Privacy`),order:3210,state:[{kind:`boolean`,field:`enabled`,label:I(`Privacy mask`,`Maschera privacy`),whenTrue:I(`When the privacy mask of {device} is turned on`,`Quando si attiva la maschera privacy di {device}`),whenFalse:I(`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:I(`Microphone`,`Microfono`),whenTrue:I(`When the microphone of {device} is turned on`,`Quando si attiva il microfono di {device}`),whenFalse:I(`When the microphone of {device} is turned off`,`Quando si disattiva il microfono di {device}`),icon:`mic`}]}};function Uwe(e){return e.length===0?null:e.some(e=>e.audioEnabled)}var oX=S([`home`,`day-mode`,`night-mode`,`day-night-auto`,`set-limits`,`save-limits`,`reboot`,`osd-menu`]),sX=x({id:m(),name:m(),fn:oX.nullable(),writable:y()}),cX=x({pan:p().nullable(),tilt:p().nullable(),zoom:p().nullable()}),lX=x({pan:p().optional(),tilt:p().optional(),zoom:p().optional(),speed:p().optional()}),uX=cX.extend({autofocus:y()}),dX=x({hasPan:y(),hasTilt:y(),hasZoom:y(),supportsPresets:y(),maxPresets:p().optional(),hasAutofocus:y(),speedSteps:p().int().positive().nullable(),moveImpulseMs:p().int().positive().nullable()}),fX=x({presetId:m().nullable(),source:S([`operator`,`firmware`,`native`,`none`])}),pX=x({enabled:y(),seconds:p().int()}),mX={name:`ptz`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/ptz-panel`,tab:`ptz`,topTab:!0,label:`PTZ`,order:0}},methods:{move:E(lX.extend({deviceId:p()}),v(),{kind:`mutation`,notOperatorFacing:`a relative nudge from the live-view joystick; a fixed place is a preset`}),continuousMove:E(lX.extend({deviceId:p()}),v(),{kind:`mutation`,notOperatorFacing:`joystick motion held until released — continuous, not a discrete step`}),goHome:E(x({deviceId:p()}),v(),{kind:`mutation`,actions:[{id:`ptz.goHome`,label:I(`PTZ go home`,`Torna alla posizione iniziale`),phrase:I(`Send {device} to its home position`,`Riporta {device} alla posizione iniziale`),icon:`house`}]}),getPresets:E(x({deviceId:p()}),C(sX)),goToPreset:E(x({deviceId:p(),presetId:m()}),v(),{kind:`mutation`,actions:[{id:`ptz.goToPreset`,label:I(`PTZ go to preset`,`Vai a un preset`),phrase:I(`Move {device} to {presetId}`,`Sposta {device} su {presetId}`),icon:`move`,openArgs:[{key:`presetId`,label:I(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}}]}]}),savePreset:E(x({deviceId:p(),presetId:m(),name:m()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.savePreset`,label:I(`Save PTZ preset here`,`Salva qui un preset`),phrase:I(`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:I(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}},{key:`name`,label:I(`Name`,`Nome`),offer:{kind:`text`}}]}]}),deletePreset:E(x({deviceId:p(),presetId:m()}),v(),{kind:`mutation`,auth:`admin`}),getOptions:E(x({deviceId:p()}),dX),stop:E(x({deviceId:p()}),v(),{kind:`mutation`,actions:[{id:`ptz.stop`,label:I(`Stop moving`,`Ferma il movimento`),phrase:I(`Stop {device} moving`,`Ferma il movimento di {device}`),icon:`square`}]}),getHomePreset:E(x({deviceId:p()}),fX),setHomePreset:E(x({deviceId:p(),presetId:m().nullable()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.setHomePreset`,label:I(`Set PTZ home preset`,`Imposta il preset iniziale`),phrase:I(`Make {presetId} the home position of {device}`,`Rendi {presetId} la posizione iniziale di {device}`),icon:`house`,openArgs:[{key:`presetId`,label:I(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}}]}]}),captureHomeHere:E(x({deviceId:p()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.captureHomeHere`,label:I(`Set PTZ home here`,`Imposta qui la posizione iniziale`),phrase:I(`Make where {device} points now its home position`,`Rendi la posizione attuale di {device} la sua posizione iniziale`),icon:`map-pin`}]}),getHomeReturn:E(x({deviceId:p()}),pX.nullable()),setHomeReturn:E(x({deviceId:p(),enabled:y(),seconds:p().int().min(0).max(3600)}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.setHomeReturn`,label:I(`Set PTZ return home`,`Imposta il ritorno alla posizione iniziale`),phrase:I(`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:I(`Return home`,`Torna alla posizione iniziale`),offer:{kind:`boolean`}},{key:`seconds`,label:I(`Idle seconds`,`Secondi da fermo`),offer:{kind:`number`,min:0,max:3600,step:1,unit:`s`}}]}]}),getPosition:E(x({deviceId:p()}),cX),setAutofocus:E(x({deviceId:p(),enabled:y()}),v(),{kind:`mutation`,actions:[{id:`ptz.autofocusOn`,label:I(`Autofocus on`,`Autofocus attivo`),phrase:I(`Turn on autofocus on {device}`,`Attiva l’autofocus su {device}`),icon:`focus`,args:{enabled:!0}},{id:`ptz.autofocusOff`,label:I(`Autofocus off`,`Autofocus spento`),phrase:I(`Turn off autofocus on {device}`,`Disattiva l’autofocus su {device}`),icon:`focus`,args:{enabled:!1}}]})},status:{schema:uX,kind:`command-driven`},vocabulary:{noun:I(`Pan / tilt / zoom`,`Brandeggio`),order:3220}},hX=x({targetType:m().describe(`Vendor target string (people/vehicle/pet); empty = camera default`),stopDelaySeconds:p().int().min(0).max(300).meta(k(`duration`)),disappearDelaySeconds:p().int().min(0).max(300).meta(k(`duration`))}),gX=x({value:m(),label:m()}),_X=x({enabled:y(),lastChangedAt:p(),currentSettings:hX.nullable(),supportedTargetTypes:C(gX)}),vX=_X.extend({lastFetchedAt:p()}),yX={name:`ptz-autotrack`,scope:`device`,deviceNative:!0,mode:`singleton`,kind:`wrapper`,defaultActive:!1,deviceTypes:[j.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/ptz-autotrack`,tab:`ptz`,topTab:!0,label:`Auto-Tracking`,order:5}},methods:{getStatus:E(x({deviceId:p()}),_X),setEnabled:E(x({deviceId:p(),enabled:y()}),v(),{kind:`mutation`,actions:[{id:`ptz.autotrackOn`,label:I(`Autotrack on`,`Inseguimento attivo`),phrase:I(`Start autotracking on {device}`,`Attiva l’inseguimento automatico su {device}`),icon:`crosshair`,args:{enabled:!0}},{id:`ptz.autotrackOff`,label:I(`Autotrack off`,`Inseguimento spento`),phrase:I(`Stop autotracking on {device}`,`Disattiva l’inseguimento automatico su {device}`),icon:`crosshair`,args:{enabled:!1}}]}),getSettings:E(x({deviceId:p()}),hX.nullable()),setSettings:E(x({deviceId:p(),settings:hX.partial()}),v(),{role:`admin`,kind:`mutation`,notOperatorFacing:`tracking tuning (target type, delays) — set once on the camera’s PTZ page`})},events:{onStatusChanged:{data:x({deviceId:p(),status:_X}),notOperatorFacing:"the `enabled` state trigger phrases both edges of this change"}},status:{schema:_X,kind:`command-driven`},runtimeState:vX,durability:`session`,history:`none`,vocabulary:{noun:I(`Autotracking`,`Inseguimento automatico`),order:3230,state:[{kind:`boolean`,field:`enabled`,label:I(`Autotracking`,`Inseguimento automatico`),whenTrue:I(`When autotracking is turned on for {device}`,`Quando si attiva l’inseguimento automatico di {device}`),whenFalse:I(`When autotracking is turned off for {device}`,`Quando si disattiva l’inseguimento automatico di {device}`),icon:`crosshair`}]}},bX=x({enabled:y().nullable(),onTime:p().min(0).nullable().meta(k(`duration`)),offTime:p().min(0).nullable().meta(k(`duration`)),lastFetchedAt:p()}),xX=p().int().nonnegative(),SX=p().int().min(0),CX={name:`pump-cycle`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.PetFountain],methods:{setEnabled:E(x({deviceId:xX,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.on`,label:I(`Pump cycle on`,`Ciclo pompa attivo`),phrase:I(`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`,label:I(`Pump cycle off`,`Ciclo pompa spento`),phrase:I(`Run the pump of {device} continuously`,`Fai lavorare la pompa di {device} in continuo`),icon:`timer-off`,args:{on:!1}}]}),setOnMinutes:E(x({deviceId:xX,minutes:SX}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.onMinutes`,label:I(`Set pump run time`,`Imposta il tempo di lavoro della pompa`),phrase:I(`Set the pump of {device} to run {minutes} minutes per cycle`,`Imposta la pompa di {device} a lavorare {minutes} minuti per ciclo`),icon:`timer`,openArgs:[{key:`minutes`,label:I(`Minutes`,`Minuti`),offer:{kind:`number`,min:0,step:1,unit:`min`}}]}]}),setOffMinutes:E(x({deviceId:xX,minutes:SX}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.offMinutes`,label:I(`Set pump rest time`,`Imposta il tempo di riposo della pompa`),phrase:I(`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`,openArgs:[{key:`minutes`,label:I(`Minutes`,`Minuti`),offer:{kind:`number`,min:0,step:1,unit:`min`}}]}]})},status:{schema:bX,kind:`push`},runtimeState:bX,durability:`session`,history:`none`,vocabulary:{noun:I(`Pump cycle`,`Ciclo della pompa`),order:2050,state:[{kind:`boolean`,field:`enabled`,label:I(`Pump cycle`,`Ciclo pompa`),whenTrue:I(`When {device} starts running its pump on a cycle`,`Quando {device} inizia a far lavorare la pompa a ciclo`),whenFalse:I(`When {device} runs its pump continuously`,`Quando {device} fa lavorare la pompa in continuo`),icon:`timer`}]}},wX={name:`reboot`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera,j.Sensor,j.Switch,j.Gateway],methods:{reboot:E(x({deviceId:p().int().nonnegative()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`,actions:[{id:`reboot.reboot`,label:I(`Reboot device`,`Riavvia il dispositivo`),phrase:I(`Reboot {device}`,`Riavvia {device}`),icon:`refresh-cw`}]})},vocabulary:{noun:I(`Reboot`,`Riavvio`),order:3240}},TX=x({owner:m(),kind:Li,title:m(),nameField:m(),fields:d(m(),u()),secretPaths:C(m()),rows:p().int().nonnegative()}),EX=x({id:iz,name:m(),rev:p().int(),updatedAt:p(),data:az}),DX={owner:m().min(1),kind:Li},OX={name:`record-entries`,scope:`system`,mode:`singleton`,methods:{listEntryKinds:E(x({}),x({kinds:C(TX)}),{auth:`admin`}),listEntries:E(x({...DX}),x({entries:C(EX)}),{auth:`admin`}),putEntry:E(x({...DX,id:iz.optional(),data:az,ifRev:p().int().min(1).optional()}),x({id:m(),rev:p().int()}),{kind:`mutation`,auth:`admin`}),deleteEntry:E(x({...DX,id:iz}),x({deleted:y()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.INTERNAL}},Wwe=`camstack`,kX=`recorder`,AX=x({profile:m(),startMs:p(),endMs:p()}),jX=S([`read`,`unreadable`]),MX=x({deviceId:p(),read:jX,ranges:C(AX),profilesWithFootage:C(m())}),NX=x({deviceId:p(),read:jX,days:C(p())}),PX=x({deviceId:p(),localMasterPath:m().nullable(),playbackUrl:m().nullable(),playbackEndpoints:C(m())}),FX=x({state:S([`ok`,`sleeping`,`unreachable`,`no-storage`,`index-empty`]),reason:m().optional(),coverageAsOf:p().optional()}),IX=x({source:m(),label:m(),addonId:m().optional(),availability:FX}),LX=x({transport:S([`archive`,`stream`,`realtime`]),coverage:S([`continuous`,`sparse`]),seek:S([`free`,`forward`,`segment`]),stepBack:y(),scrub:y(),rates:C(p().positive()).min(1).readonly(),exclusive:y()}),RX=a(`kind`,[x({kind:s(`hls`),manifest:PX}),x({kind:s(`clip`),source:m(),clipId:m(),startsAtMs:p()}),x({kind:s(`none`),reason:m()})]),zX={name:`recording`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:[j.Camera],methods:{listSources:E(x({deviceId:p()}),C(IX).readonly(),{kind:`query`,auth:`protected`}),getAvailability:E(x({deviceId:p(),provider:m().min(1),fromMs:p(),toMs:p(),profile:m().optional()}),MX,{kind:`query`,auth:`protected`}),getDaysWithRecordings:E(x({deviceId:p(),provider:m().min(1),fromMs:p(),toMs:p(),tzOffsetMinutes:p()}),NX,{kind:`query`,auth:`protected`}),getPlayback:E(x({deviceId:p(),provider:m().min(1),fromMs:p(),toMs:p(),profile:A.optional()}),RX,{kind:`query`,auth:`protected`}),getPlaybackOptions:E(x({deviceId:p(),provider:m().min(1)}),LX,{kind:`query`,auth:`protected`})},vocabulary:{noun:I(`Recording`,`Registrazione`),order:3250}},BX=x({deviceId:p(),enabled:y(),activeMode:Ac,nodeId:m(),storageBytes:p()}),VX=x({deviceId:p(),read:S([`read`,`unreadable`]),ranges:C(AX).readonly(),profilesWithFootage:C(m()).readonly()}),HX=x({deviceId:p(),read:S([`read`,`unreadable`]),days:C(p()).readonly()}),UX=x({deviceId:p(),usedBytes:p(),oldestMs:p().nullable().optional(),segments:p().optional(),residentBytes:p().optional(),residentOldestMs:p().nullable().optional()}),WX=x({locationId:m().nullable(),locationIds:C(m()).optional(),root:m().optional(),usedBytes:p(),availableBytes:p().nullable(),totalBytes:p().nullable()}),GX=x({nodeId:m(),totalUsedBytes:p(),devices:C(UX),devicesRead:S([`archive`,`unavailable`]).optional(),complete:y().optional(),locations:C(WX).optional()}),KX=x({deviceId:p(),profile:m(),fromLocationId:m(),toLocationId:m(),bytes:p(),files:p().int()}),qX=S([`unassigned`,`target-not-writable`,`below-threshold`,`no-headroom`]),JX=x({deviceId:p(),profile:m(),fromLocationId:m(),toLocationId:m().nullable(),bytes:p(),reason:qX}),YX=x({moves:C(KX),skipped:C(JX),bytesToMove:p(),jobIds:C(m())}),XX=x({throttleMbps:p().min(1).max(1e3).optional(),minMoveGb:p().min(0).optional()}),Gwe=x({deviceId:p().int(),profile:m(),locationId:m()}),Kwe=x({deviceId:p().int(),locationId:m()}),qwe=x({assignments:C(Gwe),pins:C(Kwe),defaultLocations:d(m(),m())}),Jwe=x({deviceId:p().int(),locationId:m().nullable()}),ZX=a(`kind`,[x({kind:s(`segment`),startMs:p(),durMs:p(),bytes:p()}),x({kind:s(`gap`),nearestEdgeMs:p().nullable(),prevEndMs:p().nullable().optional()})]),QX=x({data:b(Uint8Array)}),$X=x({data:b(Uint8Array),gopStartMs:p(),gopDurMs:p()}),eZ=a(`kind`,[x({kind:s(`ok`),data:b(Uint8Array),gopStartMs:p(),gopDurMs:p(),reachesRequestedEnd:y()}),x({kind:s(`spans-multiple-segments`),segmentEndMs:p()})]),tZ={name:`recording-archive`,scope:`system`,mode:`singleton`,exposesDeviceSettings:!0,status:{schema:BX,kind:`command-driven`},methods:{getAvailabilityBatch:E(x({deviceIds:C(p()).min(1).max(200),fromMs:p(),toMs:p()}),C(VX).readonly(),{role:`viewer`,kind:`query`,auth:`protected`}),getDaysWithRecordingsBatch:E(x({deviceIds:C(p()).min(1).max(200),fromMs:p(),toMs:p(),tzOffsetMinutes:p()}),C(HX).readonly(),{role:`viewer`,kind:`query`,auth:`protected`}),getStorageUsage:E(x({}),GX,{kind:`query`,auth:`admin`}),getDeviceConfig:E(x({deviceId:p()}),Bc,{role:`viewer`,kind:`query`,auth:`protected`}),locateSegment:E(x({deviceId:p(),profile:m(),epochMs:p()}),ZX,{kind:`query`,auth:`admin`}),readSegmentBytes:E(x({deviceId:p(),profile:m(),startMs:p()}),QX,{kind:`query`,auth:`admin`}),readGopBytes:E(x({deviceId:p(),profile:m(),startMs:p(),epochMs:p()}),$X,{kind:`query`,auth:`admin`}),readWindowBytes:E(x({deviceId:p(),profile:m(),startMs:p(),fromMs:p(),toMs:p()}),eZ,{kind:`query`,auth:`admin`}),setDeviceConfig:E(x({deviceId:p(),config:Bc}),Bc,{kind:`mutation`,auth:`admin`}),rescanStorage:E(x({deviceId:p()}),BX,{kind:`mutation`,auth:`admin`}),pruneFootage:E(x({deviceId:p(),reason:Js.optional()}),x({floorMs:p().nullable(),deletedBuckets:p().int(),reclaimedBytes:p().int()}),{kind:`mutation`,auth:`admin`}),deleteFootprint:E(x({deviceId:p(),fromMs:p().optional(),toMs:p().optional()}),x({deletedBuckets:p().int(),reclaimedBytes:p().int()}),{kind:`mutation`,auth:`admin`}),listOpsLog:E(Xs,C(Ys).readonly(),{kind:`query`,auth:`admin`}),renderGif:E(x({deviceId:p(),aroundMs:p(),preRollSec:p().min(0).max(30).default(2),postRollSec:p().min(0).max(30).default(5),maxWidth:p().int().min(120).max(1280).default(480),fps:p().int().min(1).max(15).default(5)}),x({gifBase64:m(),fromMs:p(),toMs:p()}),{kind:`mutation`,auth:`admin`}),renderClip:E(x({deviceId:p(),aroundMs:p(),preRollSec:p().min(0).max(30).default(3),postRollSec:p().min(0).max(30).default(7),maxWidth:p().int().min(160).max(1920).default(640)}),x({clipBase64:m(),mime:m(),fromMs:p(),toMs:p(),bytes:p().int()}),{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:E(Xc,x({paused:s(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:E(Xc,x({resumed:s(!0)}),{kind:`mutation`,auth:`admin`}),refreshStorageLocationsForMigration:E(Xc,x({refreshed:s(!0)}),{kind:`mutation`,auth:`admin`}),startStorageMigrationMove:E(Zc,x({jobId:m()}),{kind:`mutation`,auth:`admin`}),getStorageMigrationMoveStatus:E(x({jobId:m()}),qc.nullable(),{auth:`admin`}),cancelStorageMigrationMove:E(x({jobId:m()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),relocateFootage:E(Yc,x({jobId:m()}),{kind:`mutation`,auth:`admin`}),listRelocateJobs:E(x({}),C(qc).readonly(),{kind:`query`,auth:`admin`}),getRelocateResidue:E(Cl,wl,{kind:`query`,auth:`admin`}),reconcileLedgerAgainstDisk:E(Tl,kl,{kind:`mutation`,auth:`admin`}),cancelRelocateJob:E(x({jobId:m()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),planStorageRebalance:E(XX,YX,{kind:`query`,auth:`admin`}),startStorageRebalance:E(XX,YX,{kind:`mutation`,auth:`admin`}),getPlacement:E(x({}),qwe,{kind:`query`,auth:`admin`}),setDevicePlacement:E(Jwe,x({ok:s(!0)}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.STORAGE}},Ywe=S([`queue-full`,`camera-backoff`,`sleeping`,`camera-refused`,`no-keyframe`,`decode-failed`,`no-catalog-row`,`unsupported`,`unknown-device`,`uid-missing`]),Xwe=S([`deferred`,`final`]),nZ=`x-camstack-reason`;function Zwe(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 rZ=`x-camstack-reason-code`,iZ=`x-camstack-disposition`,Qwe=`x-camstack-clip-transport`,aZ=x({id:m(),source:m(),kind:S([`motion`,`object`,`audio`,`native`]),timeRange:x({startMs:p(),endMs:p()}),labels:C(m()).max(3).optional(),thumbnail:m().optional(),stillAtMs:p().optional(),eventIds:C(m()).optional(),eventCount:p().int().nonnegative().optional(),holes:C(x({startMs:p(),endMs:p()})).optional(),thumbnailMint:m().optional(),thumbnailUnavailable:x({reason:S([`sleeping`,`camera-refused`,`no-keyframe`,`unsupported`])}).optional(),catalogAsOf:p().optional(),nativeTypes:C(m()).optional(),behaviours:C(m()).optional(),streams:x({sub:x({id:m(),bytes:p().optional()}).optional(),main:x({id:m(),bytes:p().optional()}).optional()}).optional(),supportSub:y().optional(),playable:y().optional(),unplayableReason:m().optional(),inProgress:y().optional()}),oZ=x({playbackUrl:m(),format:S([`hls`,`mp4`]).optional(),served:A.optional(),playbackEndpoints:C(m()).optional(),token:m().optional()}),sZ=S([`authorised`]),$we=50*1024*1024,eTe=500*1024*1024,cZ=x({base64:m(),contentType:m(),name:m(),bytes:p().int().nonnegative(),served:A,durationMs:p().positive().optional()}),lZ=x({ticket:Ja,contentType:m(),name:m(),served:A,durationMs:p().positive().optional()}),uZ=S([`opus`,`pcmu`,`none`]),dZ=S([`not-requested`,`unsupported-ask`]),fZ=x({url:m().min(1),expiresAtMs:p(),transport:s(`forward-only`),served:A,servedAudio:uZ,audioReason:dZ.optional()}),pZ=[.25,.5,1,1.5,2,4,8],mZ=[.25,.5,1,1.5,2,4],hZ=[.25,.5,1],gZ=x({transport:S([`stream`,`file`]),seek:S([`forward`,`free`]),stepBack:y(),scrub:y(),rates:C(p().positive()).min(1).readonly()}),_Z=x({state:S([`ok`,`sleeping`,`unreachable`,`no-storage`,`index-empty`]),reason:m().optional(),catalogAsOf:p().optional()}),vZ=x({source:m(),label:m(),addonId:m().optional(),availability:_Z}),yZ={name:`videoclips`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:[j.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/clips-browser`,tab:`recording`,topTab:!0,label:`Clips`,order:100}},methods:{listClips:E(x({deviceId:p(),since:p(),until:p(),limit:p().int().positive().optional(),provider:m().min(1)}),C(aZ).readonly(),{kind:`query`,auth:`protected`}),listSources:E(x({deviceId:p()}),C(vZ).readonly(),{kind:`query`,auth:`protected`}),getClipPlayback:E(x({deviceId:p(),clipId:m(),profile:A.optional()}),oZ,{kind:`query`,auth:`protected`}),readClipBytes:D(x({deviceId:p(),clipId:m().min(1),provider:m().min(1),profile:A.optional(),maxBytes:p().int().positive().optional(),wake:sZ.optional()}),cZ,{kind:`query`,auth:`protected`}),offerClipBytes:D(x({deviceId:p(),clipId:m().min(1),provider:m().min(1),profile:A.optional(),maxBytes:p().int().positive().optional(),wake:sZ.optional()}),lZ,{kind:`query`,auth:`protected`}),dialClipStream:D(x({deviceId:p(),clipId:m().min(1),provider:m().min(1),profile:A.optional(),audio:uZ.optional()}),fZ,{kind:`query`,auth:`protected`}),getPlaybackOptions:D(x({deviceId:p(),provider:m().min(1)}),gZ,{kind:`query`,auth:`protected`})},vocabulary:{noun:I(`Video clips`,`Clip video`),order:3330}},tTe={stream:{transport:`stream`,seek:`forward`,stepBack:!1,scrub:!1,rates:mZ},realtimeStream:{transport:`stream`,seek:`forward`,stepBack:!1,scrub:!1,rates:hZ},file:{transport:`file`,seek:`free`,stepBack:!0,scrub:!0,rates:pZ}},bZ=p().min(.25).max(32),xZ=x({fromSec:p().nonnegative(),toSec:p().nonnegative()}).refine(e=>e.toSec>e.fromSec,{message:`dense range must have toSec > fromSec`}),SZ=x({everyMs:p().int().positive(),ranges:C(xZ).min(1).max(200)}),CZ=x({everyMs:p().int().positive(),outputFps:p().int().min(1).max(60).optional(),dense:SZ.optional()}).superRefine((e,t)=>{e.dense!==void 0&&e.dense.everyMs>=e.everyMs&&t.addIssue({code:ce.custom,message:`dense.everyMs must be strictly smaller than the base everyMs`,path:[`dense`,`everyMs`]})}),wZ=x({speed:bZ.optional(),timelapse:CZ.optional(),includeAudio:y(),maxLifeMs:p().int().positive(),deleteAfterDownload:y(),title:m().max(200).optional(),notifyTargetIds:C(m().min(1)).max(20).optional()}).superRefine((e,t)=>{e.speed!==void 0&&e.timelapse!==void 0&&t.addIssue({code:ce.custom,message:`speed and timelapse are mutually exclusive`,path:[`timelapse`]})}),TZ=S([`queued`,`rendering`,`ready`,`failed`,`expired`,`deleted`]),EZ=x({kind:s(`footage`),deviceId:p(),profiles:C(m()).min(1),fromMs:p(),toMs:p()}),DZ=x({kind:s(`clip`),deviceId:p(),provider:m().min(1),source:m().min(1),sourceLabel:m().min(1),clipId:m().min(1),catalogWindow:x({sinceMs:p(),untilMs:p()}),profile:S([`high`,`mid`,`low`]),wake:sZ.optional()}),OZ=a(`kind`,[EZ,DZ]),kZ=x({id:m(),deviceId:p(),profile:m(),fromMs:p(),toMs:p(),subject:OZ.optional(),options:wZ,state:TZ,progressPct:p().nullable(),fileBytes:p().nullable(),expiresAt:p(),deleteAfterDownload:y(),downloadedAt:p().nullable(),createdAt:p(),createdBy:m(),error:m().nullable()}),AZ=S([`catalog-miss`,`catalog-unreachable`,`no-file-for-window`,`clip-in-progress`,`unsupported-option`,`sleeping`,`camera-refused`,`fetch-failed`,`too-large-to-transfer`,`wake-expired`]);function nTe(e,t){return t.length>0?`${e}: ${t}`:e}function rTe(e){if(e===null)return null;let t=e.split(`:`,1)[0]??``,n=AZ.safeParse(t.trim());return n.success?n.data:null}var jZ=x({url:m(),endpoints:C(m())}),iTe=50*1024*1024,MZ=x({base64:m(),contentType:m(),name:m(),bytes:p().int().nonnegative()});function NZ(e){return e.profiles!==void 0&&e.profiles.length>0?[...e.profiles]:typeof e.profile==`string`&&e.profile.length>0?[e.profile]:[]}var aTe=x({deviceId:p(),profile:m().optional(),profiles:C(m()).min(1).optional(),fromMs:p().optional(),toMs:p().optional(),subject:OZ.optional(),options:wZ}).superRefine((e,t)=>{if(e.subject?.kind===`clip`){e.subject.deviceId!==e.deviceId&&t.addIssue({code:ce.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:ce.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:ce.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:ce.custom,message:`a footage export needs fromMs and toMs`,path:[`fromMs`]}),(e.subject?.kind===`footage`?[...e.subject.profiles]:NZ(e)).length<1&&t.addIssue({code:ce.custom,message:`pass profiles[] (min 1) or legacy profile`,path:[`profiles`]})});function oTe(e){if(e.subject!==void 0)return e.subject;let t=NZ(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 sTe(e){return e.subject===void 0?{kind:`footage`,deviceId:e.deviceId,profiles:[e.profile],fromMs:e.fromMs,toMs:e.toMs}:e.subject}var PZ={name:`recording-export`,scope:`system`,mode:`singleton`,methods:{createExport:E(aTe,kZ,{role:`viewer`,kind:`mutation`,auth:`protected`}),listExports:E(x({deviceId:p().optional()}),C(kZ),{role:`viewer`,kind:`query`,auth:`protected`}),getExport:E(x({exportId:m()}),kZ,{role:`viewer`,kind:`query`,auth:`protected`}),cancelExport:E(x({exportId:m()}),kZ,{role:`viewer`,kind:`mutation`,auth:`protected`}),deleteExport:E(x({exportId:m()}),kZ,{role:`viewer`,kind:`mutation`,auth:`protected`}),getDownloadUrl:E(x({exportId:m()}),jZ,{role:`viewer`,kind:`query`,auth:`protected`}),readExportBytes:E(x({exportId:m()}),MZ,{kind:`query`,auth:`protected`})},vocabulary:{notOperatorFacing:`recording exports — requested from the timeline, not an automation step`}},FZ=S([`continuous`,`motion`,`person`,`vehicle`,`animal`,`lineCrossing`,`intrusion`,`loitering`,`alarmInput`]),IZ=x({trigger:FZ,day:p().int().min(0).max(6).meta(k(`none`)),startMinute:p().int().min(0).max(1439).meta(k(`none`)),endMinute:p().int().min(1).max(1440).meta(k(`none`))}),LZ=x({id:m(),label:m().optional(),status:S([`ok`,`unformatted`,`error`,`offline`,`unknown`]),capacityMb:p().nullable(),freeMb:p().nullable(),writable:y().optional()}),RZ=a(`kind`,[x({kind:s(`present`),volumes:C(LZ)}),x({kind:s(`absent`),reason:m()}),x({kind:s(`unknown`),reason:m()})]),zZ=x({id:m(),enabled:y(),isVideo:y(),codec:m().nullable(),resolution:m().nullable(),overwriteWhenFull:y().nullable()}),BZ=x({storage:RZ,tracks:C(zZ),primaryTrackId:m().nullable(),enabled:y().nullable(),overwriteWhenFull:y().nullable(),preRecordSec:p().nullable().meta(k(`duration`)),postRecordSec:p().nullable().meta(k(`duration`)),segmentMinutes:p().nullable().meta(k(`none`)),windows:C(IZ),unreadableWindows:p().meta(k(`count`)),recordingToNowhere:y(),lastFetchedAt:p()}),VZ=x({min:p(),max:p(),step:p()}),HZ=x({values:C(p()).min(1),sentinel:x({value:p(),meaning:S([`no-limit`,`disabled`])}).optional()}),UZ=x({readable:y(),writable:y(),reason:m().optional()}),WZ=x({support:UZ,granularityMinutes:p(),triggers:C(FZ),supportsOverlappingTriggers:y()}),GZ=x({enabled:UZ,overwriteWhenFull:UZ,preRecordSec:UZ,preRecordSecRange:VZ.optional(),preRecordSecAllowed:HZ.optional(),postRecordSec:UZ,postRecordSecRange:VZ.optional(),postRecordSecAllowed:HZ.optional(),segmentMinutes:UZ,segmentMinutesRange:VZ.optional(),segmentMinutesAllowed:HZ.optional(),schedule:WZ}),KZ=x({enabled:y().optional(),overwriteWhenFull:y().optional(),preRecordSec:p().optional(),postRecordSec:p().optional(),segmentMinutes:p().optional(),windows:C(IZ).optional()}),qZ={name:`recording-onboard`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],deviceConfig:{ui:{kind:`derived-form`,builderId:`recording-onboard`,tab:`recording`}},methods:{getOptions:E(x({deviceId:p()}),GZ),setSettings:E(x({deviceId:p(),settings:KZ}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`recordingOnboard.on`,label:I(`On-camera recording on`,`Registrazione a bordo attiva`),phrase:I(`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:I(`On-camera recording off`,`Registrazione a bordo spenta`),phrase:I(`Turn off recording to the card of {device}`,`Disattiva la registrazione sulla scheda di {device}`),icon:`hard-drive`,args:{settings:{enabled:!1}}}]})},status:{schema:BZ,kind:`poll`},runtimeState:BZ,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`On-camera recording`,`Registrazione a bordo`),order:3260,state:[{kind:`boolean`,field:`recordingToNowhere`,label:I(`Recording to nowhere`,`Registra nel vuoto`),whenTrue:I(`When {device} is recording with no card to write to`,`Quando {device} registra senza una scheda su cui scrivere`),whenFalse:I(`When {device} has a card to record to again`,`Quando {device} ha di nuovo una scheda su cui registrare`),icon:`hard-drive`}]}},JZ=x({active:y(),reason:m(),lastChangedAt:p()}),YZ=JZ.extend({lastFetchedAt:p()}),XZ={name:`recording-signal`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],methods:{getStatus:E(x({deviceId:p()}),JZ)},status:{schema:JZ,kind:`push`,empty:{active:!1,reason:`unknown`,lastChangedAt:0}},runtimeState:YZ,durability:`session`,history:`none`,vocabulary:{noun:I(`Recording signal`,`Segnale di registrazione`),order:3270,state:[{kind:`boolean`,field:`active`,label:I(`Recording`,`In registrazione`),whenTrue:I(`When {device} starts recording`,`Quando {device} inizia a registrare`),whenFalse:I(`When {device} stops recording`,`Quando {device} smette di registrare`),icon:`circle-dot`}]}},ZZ=x({kind:s(`cap`),deviceId:p().int().nonnegative(),cap:m().min(1),method:m().min(1),args:d(m(),u()).optional(),argUnits:d(m(),m().min(1)).optional()}),QZ=x({action:ZZ}),$Z=x({key:m().refine(aT,{message:`a lowercase slug`}),name:m().min(1).max(60)});function cTe(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=vT(a);e!==null&&s(e,`payload`)}for(let t of _T(a))nT(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 eQ=x({index:p().int().nonnegative(),id:m().nullable(),name:m().nullable(),reason:m()}),tQ=x({layoutTemplateId:m().min(1).nullable(),defaultTransmitterId:p().int().nonnegative().nullable().default(null),bindings:d(m(),QZ),customButtons:C($Z).max(100),sources:C(hT).max(200).default([]),stepDelayMs:p().int().min(100).max(gT).default(500),refusedSources:C(eQ).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)nT(e)?t.addIssue({code:`custom`,message:`"${e}" is a layout widget, not a command: it cannot be bound`,path:[`bindings`,e]}):cT(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=sT(e);n!==null&&!r.has(n)&&t.addIssue({code:`custom`,message:`${e} is bound but has no entry in customButtons`,path:[`bindings`,e]})}cTe(e,t)}),lTe=o({sources:C(u())}),uTe=x({id:m(),name:m()}).partial();function dTe(e){let t=lTe.safeParse(e);if(!t.success)return nQ(tQ.safeParse(e));let n=[],r=[];t.data.sources.forEach((e,t)=>{let i=hT.safeParse(e),a=i.success&&i.data.kind===`ir`?vT(i.data):null;if(i.success&&a===null){n.push(e);return}let o=uTe.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=nQ(tQ.safeParse({...t.data,sources:n}));return!i.success||r.length===0?i:{success:!0,data:{...i.data,refusedSources:r}}}function nQ(e){return e.success?{success:!0,data:e.data}:{success:!1,issues:e.error.issues.length}}var fTe={layoutTemplateId:null,defaultTransmitterId:null,bindings:{},customButtons:[],sources:[],stepDelayMs:500},pTe=x({power:x({state:S([`on`,`off`]),at:p()}).nullable(),muted:x({value:y(),at:p()}).nullable(),source:x({name:m(),at:p()}).nullable().default(null)}),mTe={power:null,muted:null,source:null},rQ=[`rect`,`rounded`,`round`,`pill`],iQ=S(rQ),aQ=[`neutral`,`accent`,`danger`,`red`,`green`,`yellow`,`blue`],oQ=S(aQ),sQ=[`none`,`panel`,`divider`,`dpad`,`rocker-v`,`rocker-h`,`keypad`],cQ=S(sQ),lQ=x({id:m().min(1).max(40),row:p().int().min(0).max(24),col:p().int().min(0).max(24),rowSpan:p().int().min(1).max(24),colSpan:p().int().min(1).max(24),icon:m().min(1).max(60).optional(),label:m().min(1).max(40).optional(),role:lT,shape:iQ.optional(),tone:oQ.optional(),showLegend:y().optional(),groupId:m().min(1).max(40).optional()}),uQ=x({id:m().min(1).max(40),componentId:m().min(1).max(80),frame:cQ,row:p().int().min(0).max(24),col:p().int().min(0).max(24),rowSpan:p().int().min(1).max(24),colSpan:p().int().min(1).max(24),title:m().min(1).max(40).optional(),size:S([`compact`,`normal`]).optional(),hideTitle:y().optional()});function dQ(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 fQ(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 hTe(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&&dQ(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`]),fQ(n,e)||i(`button "${e.id}" lies outside its group "${n.id}"`,[`buttons`,t]);return}let a=n.find(t=>dQ(t,e));a!==void 0&&i(`button "${e.id}" lies inside group "${a.id}" but is not a member`,[`buttons`,t])})}var pQ=x({columns:p().int().min(1).max(24),rows:p().int().min(1).max(24),buttons:C(lQ).max(200),groups:C(uQ).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)}}),hTe(e,t)}),mQ=x({role:lT,label:m().optional(),custom:y()}),hQ=x({layoutTemplateId:m().nullable(),commands:C(mQ),sources:C(hT)}),gQ=[`no-remote`,`unbound-role`,`action-failed`,`unknown-source`,`unbound-step`,`undeclared-channel`,`press-timeout`,`no-transmitter`],_Q=S(gQ),vQ=a(`status`,[x({status:s(`sent`),sends:p().int().min(1)}),x({status:s(`skipped`),reason:s(`already-in-state`)}),x({status:s(`refused`),reason:_Q,detail:m().optional(),step:x({index:p().int().min(1),role:m()}).optional()})]),yQ=[`play`,`pause`,`stop`,`next`,`previous`,`setMute`,`selectSource`,`playMedia`,`turnOn`,`turnOff`,`volumeUp`,`volumeDown`,`channelUp`,`channelDown`],bQ=S(yQ),xQ=a(`status`,[...vQ.options,x({status:s(`not-routed`)})]),SQ=[`unknown-template`,`not-a-media-player`],CQ=a(`status`,[x({status:s(`saved`)}),x({status:s(`refused`),reason:S(SQ),detail:m()})]),wQ=x({deviceId:p().int().nonnegative()}),gTe={version:1,targets:[{id:`remote`,cardinality:`config`,vocabulary:{cap:`remote`},deviceTypes:[j.MediaPlayer],apply:`add`,readMethod:`getConfig`,writeMethod:`setConfig`}]},TQ={name:`remote`,scope:`system`,mode:`singleton`,methods:{getConfig:E(wQ,tQ,{auth:`admin`}),setConfig:E(wQ.extend({config:tQ}),CQ,{kind:`mutation`,auth:`admin`}),listCommands:E(wQ,hQ,{auth:`protected`}),sendCommand:E(wQ.extend({role:lT,repeat:p().int().min(1).max(50).default(1)}),vQ,{kind:`mutation`,auth:`protected`}),getAssumedStatus:E(wQ,wT.nullable(),{auth:`protected`}),sendMediaCommand:E(wQ.extend({command:bQ,muted:y().optional(),source:m().optional(),mediaType:m().optional(),mediaId:m().optional(),repeat:p().int().min(1).max(50).default(1)}),xQ,{kind:`mutation`,auth:`protected`})},customize:gTe,vocabulary:{notOperatorFacing:`the per-device remote setup — authored in the Customize remote editor, sent through the remote UI`}},EQ=[`power`,`navigation`,`volume`,`numbers`,`media`,`colour`,`apps`,`layout`],DQ=S(EQ),_Te=/^[a-z0-9][a-z0-9_.-]*:[a-z0-9][a-z0-9_-]*$/,OQ=x({idSuffix:m().regex(/^[a-z0-9][a-z0-9_-]{0,19}$/,{message:`a short lowercase slug`}),row:p().int().min(0).max(24),col:p().int().min(0).max(24),rowSpan:p().int().min(1).max(24),colSpan:p().int().min(1).max(24),role:lT,icon:m().min(1).max(60).optional(),label:m().min(1).max(40).optional(),shape:iQ.optional(),tone:oQ.optional(),showLegend:y().optional()}),kQ=x({id:m().max(80).regex(_Te,{message:`<namespace>:<name>, lowercase`}),name:m().min(1).max(60),nameI18n:x({en:m().min(1).max(60),it:m().min(1).max(60)}).optional(),icon:m().min(1).max(60),category:DQ,size:x({rows:p().int().min(1).max(24),cols:p().int().min(1).max(24)}),group:x({frame:cQ,title:m().min(1).max(40).optional()}).nullable(),buttons:C(OQ).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&&dQ(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`]})}),AQ={name:`remote-layout-components`,scope:`system`,mode:`collection`,methods:{listComponents:E(x({}),C(kQ),{auth:`protected`})},vocabulary:{notOperatorFacing:`the palette of the remote template editor — read-only data, never actuated`}},jQ=3e4,MQ=18e4,NQ={startDwellMs:jQ,stopDwellMs:MQ,minSamples:2},PQ={[j.MediaPlayer]:{startDwellMs:1e4,stopDwellMs:1e4,minSamples:1}};function FQ(e){return e!==void 0&&PQ[e]!==void 0}function IQ(e){return e===void 0?NQ:PQ[e]??NQ}var vTe={running:null,since:null,source:`native`,phase:null,lastFetchedAt:null},LQ=S([`native`,`assigned`]),RQ=x({running:y().nullable(),since:p().nullable().meta(k(`none`)),source:LQ.meta({label:`Source`}),phase:m().nullable(),lastFetchedAt:p().nullable()}),zQ=x({deviceId:p(),since:p().nullable(),phase:m().nullable()}),yTe=Object.values(j),BQ=[j.Washer,j.Dryer,j.Dishwasher,j.Vacuum,j.LawnMower,j.MediaPlayer,j.WaterHeater,j.Humidifier,j.Fan,j.Climate,j.PetFeeder],bTe={version:1,overridable:[{path:`running`,by:`running`}],targets:[{id:`running`,cardinality:`scalar`,vocabulary:{cap:`running-state`,stateField:`running`},deviceTypes:BQ,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:jQ,defaultStopDwellMs:MQ,deviceTypeDefaults:PQ,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}]},VQ={name:`running-state`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:yTe,methods:{},events:{onStarted:{data:zQ,trigger:{category:w.RunningStarted,label:I(`Started running`,`Ha iniziato a funzionare`),phrase:I(`When {device} starts running`,`Quando {device} inizia a funzionare`),icon:`play`}},onFinished:{data:zQ,trigger:{category:w.RunningFinished,label:I(`Finished`,`Ha finito`),phrase:I(`When {device} finishes`,`Quando {device} finisce`),icon:`square`}}},status:{schema:RQ,kind:`push`},runtimeState:RQ,durability:`restored`,history:{fields:{running:{kind:`boolean`}}},volatileStateFields:[`lastFetchedAt`],customize:bTe,vocabulary:{noun:I(`Running`,`In funzione`),order:2120,state:[{kind:`boolean`,field:`running`,label:I(`Running`,`In funzione`),whenTrue:I(`When {device} starts`,`Quando {device} inizia`),whenFalse:I(`When {device} finishes`,`Quando {device} finisce`),icon:`play`}],overrides:{byType:{[j.Washer]:{state:{running:{whenTrue:I(`When the washing machine starts`,`Quando la lavatrice inizia`),whenFalse:I(`When the washing machine has finished`,`Quando la lavatrice ha finito`)}},events:{onStarted:{phrase:I(`When the washing machine starts`,`Quando la lavatrice inizia`)},onFinished:{phrase:I(`When the washing machine has finished`,`Quando la lavatrice ha finito`)}}},[j.Dryer]:{state:{running:{whenTrue:I(`When the dryer starts`,`Quando l'asciugatrice inizia`),whenFalse:I(`When the dryer has finished`,`Quando l'asciugatrice ha finito`)}},events:{onStarted:{phrase:I(`When the dryer starts`,`Quando l'asciugatrice inizia`)},onFinished:{phrase:I(`When the dryer has finished`,`Quando l'asciugatrice ha finito`)}}},[j.Dishwasher]:{state:{running:{whenTrue:I(`When the dishwasher starts`,`Quando la lavastoviglie inizia`),whenFalse:I(`When the dishwasher has finished`,`Quando la lavastoviglie ha finito`)}},events:{onStarted:{phrase:I(`When the dishwasher starts`,`Quando la lavastoviglie inizia`)},onFinished:{phrase:I(`When the dishwasher has finished`,`Quando la lavastoviglie ha finito`)}}}}}}},HQ=m(),xTe=[`day`,`ir`,`night`,`dawn`,`dusk`],UQ=S([`skip`,`judge-anyway`]),STe=`__diverged__`,WQ=S([`matched`,`diverged`,`unknown`]),GQ=S([`no-reference-for-condition`,`view-shifted`,`no-vision-profile`,`encoder-model-changed`,`no-snapshot`]),KQ=x({embedding:C(p()),modelId:m(),condition:HQ,capturedAt:p(),thumbnailMediaId:p().int().optional(),anchorEmbedding:C(p()).optional()}),qQ=x({id:m(),label:m(),references:C(KQ),textPrompts:C(m()).optional(),referenceCount:p(),currentlyMatched:y()}),JQ=a(`mode`,[x({mode:s(`similarity`),threshold:p().min(0).max(1),hysteresisCount:p().int().positive()}),x({mode:s(`llm`),prompt:m(),profileId:m().optional(),hysteresisCount:p().int().positive()})]),YQ=.85,XQ=`skip`,ZQ=8e3,QQ=x({enabled:y().default(!1),prompt:m().min(1).max(1e3),profileId:m().optional(),timeoutMs:p().int().min(1e3).max(2e4).default(ZQ),maxImagePx:p().int().min(64).max(2048).default(448),onTimeout:S([`flip`,`hold`]).default(`hold`)}),$Q=x({id:m(),label:m(),roi:$z,enabled:y(),triggerMode:S([`periodic`,`on-motion`,`both`]),checkIntervalSec:p().optional(),check:JQ,states:C(qQ),currentStateId:m().nullable(),lastCheckedAt:p().nullable(),lastConfidence:p().nullable(),currentCondition:HQ.nullable(),availability:S([`ok`,`unavailable`]),unavailableReason:m().nullable(),baselineStateId:m().nullable(),emit:S([`latched`,`live`]).default(`latched`),verdict:WQ,latched:y(),armedAt:p(),divergedAt:p().nullable(),restoredAt:p().nullable(),quietSeconds:p().int().min(0).max(3600).default(60),minObservationSpacingSec:p().int().min(0).max(3600).default(120),confirm:QQ.optional(),anchorThreshold:p().min(0).max(1).default(YQ),autoRestore:y().default(!1),onUncoveredCondition:UQ.default(XQ),suspendedCondition:HQ.nullable().default(null),unavailable:GQ.nullable(),coveredConditions:C(HQ)}),e$=x({monitors:C($Q),lastFetchedAt:p()}),t$=x({deviceId:p(),status:e$.nullable()}),n$={name:`scene-monitor`,role:{feature:`scenes`},scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[j.Camera],methods:{listScenes:E(x({deviceId:p()}),e$),listScenesBatch:E(x({deviceIds:C(p()).min(1).max(200)}),C(t$).readonly()),createScene:E(x({deviceId:p(),label:m(),roi:$z,check:JQ,triggerMode:S([`periodic`,`on-motion`,`both`]).optional(),checkIntervalSec:p().optional()}),$Q,{kind:`mutation`,auth:`admin`}),updateScene:E(x({deviceId:p(),monitorId:m(),patch:x({label:m().optional(),roi:$z.optional(),enabled:y().optional(),triggerMode:S([`periodic`,`on-motion`,`both`]).optional(),checkIntervalSec:p().optional(),check:JQ.optional(),emit:S([`latched`,`live`]).optional(),quietSeconds:p().int().min(0).max(3600).optional(),minObservationSpacingSec:p().int().min(0).max(3600).optional(),anchorThreshold:p().min(0).max(1).optional(),autoRestore:y().optional(),onUncoveredCondition:UQ.optional(),confirm:QQ.nullable().optional()})}),v(),{kind:`mutation`,auth:`admin`}),deleteScene:E(x({deviceId:p(),monitorId:m()}),v(),{kind:`mutation`,auth:`admin`}),captureReference:E(x({deviceId:p(),monitorId:m(),stateId:m().optional(),label:m().optional(),condition:HQ.optional()}),x({stateId:m(),referenceCount:p()}),{kind:`mutation`,auth:`admin`}),deleteReference:E(x({deviceId:p(),monitorId:m(),stateId:m(),index:p()}),v(),{kind:`mutation`,auth:`admin`}),recheckNow:E(x({deviceId:p(),monitorId:m()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`sceneMonitor.recheck`,label:I(`Re-check a scene`,`Ricontrolla una scena`),phrase:I(`Re-check {monitorId} on {device} now`,`Ricontrolla subito {monitorId} su {device}`),icon:`scan-search`,openArgs:[{key:`monitorId`,label:I(`Scene`,`Scena`),offer:{kind:`dynamic`,from:`status`,field:`monitors`,valueKey:`id`,labelKey:`label`}}]}]}),resetScene:E(x({deviceId:p(),monitorId:m(),recapture:y().optional()}),v(),{kind:`mutation`,auth:`admin`})},status:{schema:e$,kind:`push`},runtimeState:e$,durability:`session`,history:`none`,vocabulary:{noun:I(`Scene watch`,`Controllo della scena`),order:3280,extraEvents:[{category:w.EnrichmentSceneStateChanged,label:I(`Scene changed`,`Scena cambiata`),phrase:I(`When a watched scene on {device} changes`,`Quando cambia una scena controllata su {device}`),icon:`scan-search`}]}},r$=x({schedulerId:m().min(1)}),i$={name:`schedulers`,scope:`system`,mode:`singleton`,methods:{list:E(x({}),C(p_),{auth:`admin`}),get:E(r$,x({scheduler:p_.nullable()}),{auth:`admin`}),create:E(x({scheduler:f_}),x({scheduler:p_}),{kind:`mutation`,auth:`admin`}),update:E(x({schedulerId:m().min(1),scheduler:f_}),x({scheduler:p_}),{kind:`mutation`,auth:`admin`}),delete:E(r$,v(),{kind:`mutation`,auth:`admin`}),setEnabled:E(x({schedulerId:m().min(1),profileId:m().min(1).optional(),enabled:y()}),x({scheduler:p_}),{kind:`mutation`,auth:`admin`}),preview:E(x({schedulerId:m().min(1),date:m().regex(h_).optional()}),Nue,{auth:`admin`}),conflicts:E(x({scheduler:f_,schedulerId:m().min(1).optional()}),x({conflicts:C(Pue)}),{auth:`admin`}),getStatus:E(x({}),C(Iue),{auth:`admin`}),getTraces:E(r$,x({traces:C(y_)}),{auth:`admin`})},vocabulary:{notOperatorFacing:`time schedulers — authored on their own page, not device actions`}},a$=x({isRunning:y(),lastRunAt:p(),lastRunSuccess:y().nullable(),lastError:m().nullable(),lastChangedAt:p()}),o$={name:`script-runner`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Script],methods:{run:E(x({deviceId:p().int().nonnegative(),variables:d(m(),u()).optional()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`script.run`,label:I(`Run script`,`Esegui lo script`),phrase:I(`Run {device}`,`Esegui {device}`),icon:`scroll-text`}]}),stop:E(x({deviceId:p().int().nonnegative()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`script.stop`,label:I(`Stop script`,`Ferma lo script`),phrase:I(`Stop {device}`,`Ferma {device}`),icon:`square`}]})},status:{schema:a$,kind:`push`},runtimeState:a$,durability:`session`,history:`none`,vocabulary:{noun:I(`Script`,`Script`),order:2090,state:[{kind:`boolean`,field:`isRunning`,label:I(`Running`,`In esecuzione`),whenTrue:I(`When {device} starts running`,`Quando {device} parte`),whenFalse:I(`When {device} finishes`,`Quando {device} termina`),icon:`scroll-text`}]}},s$=S([`workspace`,`baked`,`data-root`]),c$=S([`idle`,`checking`,`staging`,`pending-restart`,`awaiting-confirmation`]),l$=S([`in-sync`,`behind-patch`,`behind-series`,`ahead`,`unknown`]),u$=x({state:l$,seedVersion:m().nullable(),contractVersion:m().nullable(),contractSource:S([`registry`,`running`]).nullable(),message:m()}),d$=S([`docker`,`electron`,`native`,`contradictory`,`unknown`]),f$=x({fact:S([`dockerenv-file`,`proc-1-cgroup`,`platform`,`electron-app-version-env`]),mode:S([`observed`,`declared`]),holds:y(),detail:m()}),p$=x({kind:d$,evidence:C(f$),currentVersion:m().nullable()}),m$=x({fromVersion:m(),toVersion:m().nullable(),atMs:p(),reason:m()}),h$=x({version:m(),update:x({available:y(),downloaded:y(),version:m().nullable(),checking:y(),error:m().nullable()}),stateAtMs:p(),stale:y()}),g$=S([`not-electron`,`no-app-state`,`app-state-stale`,`not-downloaded`]),_$=x({accepted:y(),reason:g$.nullable()}),v$=x({runnerId:m(),addonIds:C(m()),reason:m()}),y$=x({checkedAtMs:p(),expected:p(),running:p(),failed:C(m()),refused:C(v$),missing:C(m()),pending:C(m()).optional(),planKnown:y()}),b$=x({packageName:m(),runningVersion:m().nullable(),nodeRuntimeVersion:m().nullable(),activeVersion:m().nullable(),installedVersion:m().nullable().optional(),restartRequired:y().optional(),previousVersion:m().nullable(),seedVersion:m().nullable(),latestVersion:m().nullable(),updateAvailable:y(),bootMode:s$,updateState:c$,pendingVersion:m().nullable(),rolledBack:m$.nullable(),stateFileCorrupt:y(),lastCheckedAtMs:p().nullable(),imageContract:u$.optional(),wrapper:p$.optional(),runners:y$.optional(),desktopApp:h$.optional()}),x$=x({packageName:m(),runningVersion:m().nullable(),latestVersion:m().nullable(),updateAvailable:y(),checkedAtMs:p(),error:m().nullable(),pendingVersion:m().nullable().optional(),restartRequired:y().optional()}),S$=S([`staged`,`restart-scheduled`,`already-current`,`refused`,`failed`]),C$=x({addonId:m(),reason:m(),remedy:m()}),w$=x({accepted:y(),targetVersion:m().nullable(),restarting:y(),message:m(),outcome:S$.optional(),reason:m().nullable().optional(),error:m().nullable().optional(),blockers:C(C$).optional(),unmet:C(Ir).optional(),requiredAddonUpdates:C(Lr).optional()}),T$=x({heapMb:p().int().nullable(),rssBudgetMb:p().int().nullable()}),CTe=x({heapMb:p().int().min(512).max(65536).nullable(),rssBudgetMb:p().int().min(512).max(65536).nullable().optional()}),wTe=T$.extend({restartRequired:y()}),E$={name:`server-management`,scope:`system`,mode:`singleton`,methods:{getServerPackageStatus:E(v(),b$,{auth:`admin`}),checkServerUpdate:E(v(),x$,{kind:`mutation`,auth:`admin`}),applyServerUpdate:E(x({version:m().optional(),acknowledgeRefusals:y().optional()}),w$,{kind:`mutation`,auth:`admin`,timeoutMs:16*6e4}),installDesktopUpdate:E(v(),_$,{kind:`mutation`,auth:`admin`}),rollbackServerUpdate:E(v(),w$,{kind:`mutation`,auth:`admin`}),restartServer:E(v(),w$,{kind:`mutation`,auth:`admin`}),getLaunchOverrides:E(v(),T$,{auth:`admin`}),setLaunchOverrides:E(CTe,wTe,{kind:`mutation`,auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:O.CLUSTER}},D$=x({detected:y(),lastChangedAt:p()}),O$={name:`smoke`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor],methods:{},status:{schema:D$,kind:`push`},runtimeState:D$,durability:`restored`,history:{fields:{detected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:I(`Smoke detector`,`Rilevatore di fumo`),order:5190,state:[{kind:`boolean`,field:`detected`,label:I(`Detected`,`Rilevato`),whenTrue:I(`When {device} detects smoke`,`Quando {device} rileva fumo`),whenFalse:I(`When smoke clears on {device}`,`Quando il fumo su {device} si dirada`),icon:`alarm-smoke`}]}},k$=5*1024*1024,A$=`<!--camstack-images-->`,j$=x({ticket:Ja,mime:m().min(1),name:m().min(1),contentId:m().min(1),placement:S([`inline`,`attachment`]),deviceId:p().int().nonnegative().optional()}),M$=0;function N$(e){return M$+=1,`camstack_${e}_${M$.toString(36)}_${Date.now().toString(36)}`}function TTe(e){return/^[\x20-\x7E]*$/.test(e)?e:`=?UTF-8?B?${Buffer.from(e,`utf8`).toString(`base64`)}?=`}function P$(e){return(Array.isArray(e)?e:[e]).join(`, `)}function ETe(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`)}function F$(e,t){let n=e.replace(/[\r\n"]/g,``).trim();return n.length>0?n:t}function DTe(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
1108
+ `)}function kk(e){return e.replaceAll(`|`,`\\|`)}function Ave(){let e=[];for(let t of Object.values(uh))e.includes(t.dimension)||e.push(t.dimension);return e.map(e=>({group:e,choices:yh(e).map(e=>({value:e}))}))}function Ak(e,t){if(e===void 0)return[];if(e.kind===`choices`)return[{group:null,choices:e.options.map(e=>({...e}))}];if(e.kind===`range`){let t=[],n=Math.floor((e.max-e.min)/e.step+1e-9);for(let r=0;r<=n;r+=1)t.push({value:String(e.min+r*e.step)});return[{group:null,choices:t}]}let n=t===void 0?void 0:ph(t);return n===void 0?Ave():[{group:n,choices:yh(n).map(e=>({value:e}))}]}var jk=4096,jve=4096,Mk=m().min(1).max(jk),Mve=`camera`,Nk=l([m(),p(),y()]),Pk=x({deviceId:p().int(),values:d(m().min(1).max(64),Nk).optional()}),Nve=`values`,Pve=Ck(),Fk=[`too-long`,`syntax`,`forbidden-syntax`,`forbidden-member`,`unknown-filter`,`ambiguous-field`,`busy`,`budget-exceeded`,`timeout`,`output-too-large`,`render-failed`,`out-of-scope`,`unavailable`],Ik=x({reason:S(Fk),message:m()}),Lk=[`unknown-alias`,`unknown-field`,`no-field`,`unavailable`],Rk=x({ref:m(),reason:S(Lk)}),zk=a(`ok`,[x({ok:s(!0),text:m(),trace:C(Rk)}),x({ok:s(!1),refusal:Ik,trace:C(Rk)})]);function Bk(e){return e.replace(/-/g,`_`)}function Vk(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Hk(e,t){let n=e;for(let e of t)if(Array.isArray(n)&&typeof e==`number`)n=n[e];else if(Vk(n)&&Object.hasOwn(n,String(e)))n=n[String(e)];else return;return n}function Fve(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||Bk(e)===n);if(i!==void 0){let n=t.slice(1);if(n.length===0)return{kind:`missing`,reason:`no-field`};let r=Hk(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 Vk(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=Hk(e.slices[o],t);return s===void 0?{kind:`missing`,reason:`unknown-field`}:{kind:`value`,cap:o,fieldPath:t,value:s}}var Uk=x({zoneKey:m(),label:m(),icon:Vu.nullable(),locationKeys:C(m())});function Ive(e){return e.trim().toLowerCase()}var Wk=x({caps:C(m()).readonly().optional(),actions:C(m()).readonly().optional(),mode:S([`any`,`all`]).optional()}),Gk=x({locations:C(m()).readonly().optional(),integrationIds:C(m()).readonly().optional(),types:C(m()).readonly().optional()}),Kk=x({text:m().optional(),requires:Wk.optional(),filters:Gk.optional(),includeIncompatible:y().optional(),contextDeviceId:p().optional(),ids:C(p()).readonly().optional(),cursor:m().nullable().optional(),limit:p().int().min(1).max(200).optional()}),qk=x({cap:m(),path:m(),label:m(),reading:m().nullable(),unit:m().nullable().optional(),quantity:Qs.optional()}),Jk=x({id:p(),name:m(),type:S(j),location:m().nullable(),integrationId:m().nullable(),integrationLabel:m().nullable(),online:y().nullable(),disabled:y(),compatible:y(),values:C(qk).readonly()}),Yk=x({value:m(),count:p()}),Xk=x({id:m(),label:m(),count:p()}),Zk=x({locations:C(Yk).readonly(),integrations:C(Xk).readonly(),types:C(Yk).readonly()}),Qk=x({items:C(Jk).readonly(),nextCursor:m().nullable(),total:p(),compatibleTotal:p(),fleetTotal:p(),hiddenIncompatible:p(),facets:Zk,suggested:C(Jk).readonly(),missingIds:C(p()).readonly()}),$k=x({connected:y(),deviceCount:p(),error:m().optional(),motionSliceWriter:s(`orchestrator`).optional()}),Lve=x({externalId:m(),name:m(),type:m(),metadata:d(m(),u()).optional()}),eA=a(`kind`,[x({kind:s(`mdns`),serviceType:m().min(1),instancePattern:m().optional()}),x({kind:s(`ws-discovery`),types:C(m()).optional()}),x({kind:s(`ssdp`),searchTarget:m().min(1)}),x({kind:s(`udp-broadcast`),port:p().int().min(1).max(65535),payloadHex:m().regex(/^([0-9a-fA-F]{2})*$/),listenPort:p().int().min(1).max(65535).optional()}),x({kind:s(`http-probe`),port:p().int().min(1).max(65535),path:m().startsWith(`/`),method:S([`GET`,`POST`]).default(`GET`),bodyText:m().optional(),contentType:m().optional(),tls:y().default(!1),acceptStatus:C(p().int()).optional()}),x({kind:s(`custom`),reason:m().min(1)})]),tA=x({modeIndex:p().int().min(0),host:m(),port:p().int(),http:x({status:p().int(),headers:d(m(),m()),bodyText:m()}).optional(),mdns:x({instance:m(),host:m(),port:p().int(),txt:d(m(),m())}).optional(),udp:x({payloadHex:m()}).optional(),wsd:x({xaddrs:C(m()),types:C(m()),scopes:C(m())}).optional()}),nA=x({stableId:m(),type:S(j),suggestedName:m(),prefilledConfig:d(m(),u()),sourceInfo:ih.optional(),alreadyOnboarded:y().optional(),onboardedDeviceId:p().optional(),onboardedName:m().optional(),setupIntegration:y().optional(),parentStableId:m().optional(),selectable:y().optional(),needsParams:C(m()).optional()}),rA=x({id:p(),stableId:m(),addonId:m(),type:m(),name:m(),parentDeviceId:p().nullable(),online:y(),features:C(m()),config:d(m(),u()),sourceInfo:ih.optional()}),iA=x({status:S([`ok`,`error`]),labels:C(m()).optional(),error:m().optional()}),aA=u(),oA={name:`device-provider`,scope:`system`,mode:`collection`,methods:{start:E(v(),v(),{kind:`mutation`}),stop:E(v(),v(),{kind:`mutation`}),getStatus:E(v(),$k),getDevices:E(v(),C(x({id:m(),name:m(),type:m()}))),reloadDevice:E(x({stableId:m()}),x({deviceId:p()}),{kind:`mutation`,timeoutMs:3*6e4}),supportsDiscovery:E(x({}),y()),discoverDevices:E(x({params:d(m(),u()).optional()}),C(nA),{kind:`mutation`,auth:`admin`}),getDiscoveryModes:E(x({}),C(eA)),classifyDiscoveryHits:E(x({hits:C(tA),params:d(m(),u()).optional()}),C(nA),{kind:`mutation`,auth:`admin`}),getDiscoveryParamsSchema:E(x({}),aA),getManualCreationType:E(x({integrationId:m().optional()}),x({deviceType:S(j).nullable()})),adoptDiscoveredDevice:E(x({candidate:nA,integrationId:m().optional()}),rA,{kind:`mutation`,auth:`admin`}),supportsManualCreation:E(x({}),y()),getChildCreationSchema:E(x({type:S(j),integrationId:m().optional()}),aA),createDevice:E(x({type:S(j),config:d(m(),u()),integrationId:m().optional()}),rA,{kind:`mutation`,auth:`admin`}),testCreationField:E(x({type:S(j),key:m(),value:u(),formValues:d(m(),u()).optional()}),iA,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.INTERNAL}},sA=a(`kind`,[x({kind:s(`mdns`),serviceType:m(),instance:m(),host:m(),address:m().nullable(),port:p().int(),txt:d(m(),m())}),x({kind:s(`ssdp`),host:m(),port:p().int(),target:m(),headers:d(m(),m())})]),Rve=x({addonId:m(),candidate:nA,firstSeenAt:p(),lastSeenAt:p(),dismissed:y()}),cA=x({id:m(),addonId:m(),candidate:nA,firstSeenAt:p(),lastSeenAt:p(),dismissed:y()}),lA=x({childKey:m(),section:m(),order:p().optional(),collapsed:y().optional()}),zve=x({unit:m().min(1).optional(),precision:p().int().min(0).max(10).optional()}),uA=x({icon:m().min(1).optional(),label:m().min(1).optional(),unit:m().min(1).optional(),precision:p().int().min(0).max(10).optional(),hidden:y().optional(),perCap:d(m(),zve).optional()}),dA=x({unit:m().min(1).optional(),precision:p().int().min(0).max(10).optional(),icon:m().min(1).optional()}),fA=x({id:p(),stableId:m(),addonId:m(),type:S(j),name:m(),alias:ok.optional(),location:m().nullable(),tags:Qu.optional(),disabled:y(),parentDeviceId:p().nullable(),role:m().nullable().optional(),online:y(),probed:y().optional(),features:C(m()),isCamera:y(),config:d(m(),u()),secretConfigPaths:C(m()).optional(),metadata:d(m(),u()).nullable().optional(),sourceInfo:ih.optional(),integrationId:m().optional(),linkDeviceId:p().nullable().optional(),primaryChildEntityId:m().nullable().optional(),childLayout:C(lA).readonly().optional(),primaryChildPreference:C(m()).readonly().optional(),display:uA.optional()}),pA=x({key:m(),value:u(),description:m().optional()}),mA=S([`manual`]),hA=x({deviceId:p(),name:m(),location:m().nullable(),features:C(m()),producesTrackedEvents:y().optional()}),gA=x({deviceIds:C(p().int().positive()),trackedDeviceIds:C(p().int().positive()).optional()}),_A={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:[j.Camera],sourceCaps:`any`,cardinality:`many`,value:gA},Bve=x({deviceId:p(),mode:mA,devices:C(hA)}),vA=x({deviceId:p(),entries:C(x({capName:m(),kind:S([`native`,`wrapped`]),providerAddonId:m(),providerNodeId:m(),nativeAddonId:m(),implementedMethods:C(m()).optional()}))}),yA=a(`kind`,[x({kind:s(`value`),wrapperAddonId:m().nullable()}),x({kind:s(`missing`)}),x({kind:s(`failed`),error:m()})]),Vve=x({id:p(),stableId:m(),type:m(),name:m(),location:m().nullable(),tags:Qu.optional(),disabled:y(),parentDeviceId:p().nullable(),role:m().nullable().optional()}),Hve=x({id:p(),stableId:m(),addonId:m(),type:m(),name:m(),userNamed:y().optional(),location:m().nullable(),tags:Qu.optional(),disabled:y(),parentDeviceId:p().nullable(),metadata:d(m(),u()).nullable().optional(),sourceInfo:ih.optional(),integrationId:m().optional(),linkDeviceId:p().nullable().optional(),primaryChildEntityId:m().nullable().optional(),childLayout:C(lA).readonly().optional(),primaryChildPreference:C(m()).readonly().optional(),role:m().nullable().optional(),display:uA.optional()}),Uve=u().nullable(),Wve=x({streamId:m(),width:p().optional(),height:p().optional(),codec:m().optional(),fps:p().optional(),bitrateKbps:p().optional()}),Gve=x({addonId:m(),stableId:m(),id:p(),type:m(),name:m(),location:m().nullable().optional(),disabled:y().optional(),parentDeviceId:p().nullable(),role:m().nullable().optional(),features:C(m()).optional(),config:d(m(),u()),secretConfigPaths:C(m()).optional()}),bA=x({deviceId:p().int().positive(),deletedAt:p(),providerAddonId:m()}),xA=2160*60*60*1e3,SA=x({deviceId:p().int().positive(),stores:d(m(),p().int().nonnegative())}),CA=x({status:S([`skipped`,`dry-run`,`cleaned`]),reason:m().nullable(),devices:C(SA),unreachable:C(m())}),Kve=x({deviceId:p()}),qve=x({deviceId:p(),data:d(m(),u()),secretConfigPaths:C(m()).optional()}),wA=S([`off`,`on`,`not-offered`,`unreachable`]),TA=x({deviceId:p(),switchId:Ya,outcome:wA,detail:m().optional()}),EA=x({sourceId:p(),targetId:p(),switches:C(TA).readonly(),sourceStillLive:C(Ya).readonly(),swapped:y()}),DA={name:`device-manager`,scope:`system`,mode:`singleton`,extensionSlots:[_A],methods:{allocateDeviceId:E(x({addonId:m(),stableId:m()}),x({id:p()}),{kind:`mutation`}),migrateDevice:E(x({sourceId:p(),targetId:p()}),EA,{kind:`mutation`,auth:`admin`,timeoutMs:12*6e4}),registerDevice:E(Gve,v(),{kind:`mutation`}),removeDevice:E(Kve,v(),{kind:`mutation`}),persistConfig:E(qve,v(),{kind:`mutation`,auth:`admin`}),loadConfig:E(x({deviceId:p()}),d(m(),u()),{auth:`admin`}),loadRuntimeState:E(x({deviceId:p()}),d(m(),u()),{auth:`admin`}),loadMeta:E(x({deviceId:p()}),Hve.nullable()),setName:E(x({deviceId:p(),name:m(),stampUserNamed:y().optional()}),v(),{kind:`mutation`,auth:`admin`}),setAlias:E(x({deviceId:p(),alias:m()}),a(`ok`,[x({ok:s(!0),alias:ok}),x({ok:s(!1),reason:S([`empty`,`too-long`,`grammar`,`reserved`,`taken`]),takenBy:p().optional()})]),{kind:`mutation`,auth:`admin`}),renderDeviceTemplates:E(x({templates:C(Mk).max(64),allowedDeviceIds:C(p().int()).optional(),thisDevice:Pk.optional()}),x({results:C(zk)}),{auth:`admin`}),checkDeviceTemplates:E(x({templates:C(m()).max(64),allowedDeviceIds:C(p().int()).optional(),thisDevice:Pk.optional()}),x({results:C(a(`ok`,[x({ok:s(!0),aliases:C(x({alias:m(),deviceId:p().int().nullable(),allowed:y(),reads:C(m())})),readsClock:y()}),x({ok:s(!1),refusal:Ik})]))}),{auth:`admin`}),setLocation:E(x({deviceId:p(),location:m().nullable()}),v(),{kind:`mutation`,auth:`admin`}),setTags:E(x({deviceId:p(),tags:Qu}),v(),{kind:`mutation`,auth:`admin`}),setType:E(x({deviceId:p(),type:S(j)}),v(),{kind:`mutation`,auth:`admin`}),setIntegrationId:E(x({deviceId:p(),integrationId:m()}),v(),{kind:`mutation`,auth:`admin`}),setLinkDeviceId:E(x({deviceId:p(),linkDeviceId:p().nullable()}),v(),{kind:`mutation`,auth:`admin`}),setPrimaryChildEntityId:E(x({deviceId:p(),primaryChildEntityId:m().nullable()}),v(),{kind:`mutation`,auth:`admin`}),setChildLayout:E(x({deviceId:p(),childLayout:C(lA).readonly()}),v(),{kind:`mutation`,auth:`admin`}),setPrimaryChildPreference:E(x({deviceId:p(),primaryChildPreference:C(m()).readonly()}),v(),{kind:`mutation`,auth:`admin`}),setDisplay:E(x({deviceId:p(),display:uA.nullable()}),v(),{kind:`mutation`,auth:`admin`}),getRoleDisplayDefaults:E(x({}),x({defaults:d(m(),dA)}),{role:`viewer`,kind:`query`}),setRoleDisplayDefaults:E(x({defaults:d(m(),dA)}),v(),{kind:`mutation`,auth:`admin`}),getWireableFields:E(x({deviceId:p(),includeSynthesizable:y().optional()}),x({caps:C(x({cap:m(),fields:C(x({path:m(),kind:S([`string`,`number`,`boolean`,`enum`,`union`]),unionMembers:C(S([`string`,`number`,`boolean`])).optional(),enumValues:C(m()).optional(),item:y().optional(),quantity:Qs.optional()})).readonly(),itemArray:x({path:m(),keyField:m()}).optional()})).readonly()}),{kind:`query`}),setRole:E(x({deviceId:p(),role:m().nullable()}),v(),{kind:`mutation`,auth:`admin`}),applyInitialMeta:E(x({deviceId:p(),name:m().optional(),location:m().nullable().optional(),tags:Qu.optional(),type:S(j).optional(),integrationId:m().optional(),linkDeviceId:p().nullable().optional(),role:m().nullable().optional()}),v(),{kind:`mutation`,auth:`admin`}),setMetadata:E(x({deviceId:p(),patch:d(m(),u())}),v(),{kind:`mutation`,auth:`admin`}),listLocations:E(v(),C(m())),addLocation:E(x({name:m()}),v(),{kind:`mutation`,auth:`admin`}),removeLocation:E(x({name:m(),cascade:y().optional()}),v(),{kind:`mutation`,auth:`admin`}),renameLocation:E(x({from:m(),to:m()}),x({moved:p()}),{kind:`mutation`,auth:`admin`}),listLocationIcons:E(v(),C(xp),{role:`viewer`}),setLocationIcon:E(x({location:m(),icon:Vu.nullable()}),v(),{kind:`mutation`,auth:`admin`}),listLocationDescriptions:E(v(),C(Cp)),setLocationDescription:E(x({location:m(),description:m().max(400).nullable()}),v(),{kind:`mutation`,auth:`admin`}),listSiteZones:E(v(),C(Uk),{role:`viewer`}),setSiteZone:E(x({name:m(),icon:Vu.nullable().optional()}),v(),{kind:`mutation`,auth:`admin`}),removeSiteZone:E(x({name:m()}),v(),{kind:`mutation`,auth:`admin`}),renameSiteZone:E(x({from:m(),to:m()}),v(),{kind:`mutation`,auth:`admin`}),setLocationZone:E(x({location:m(),zone:m().nullable()}),v(),{kind:`mutation`,auth:`admin`}),setDisabled:E(x({deviceId:p(),disabled:y()}),v(),{kind:`mutation`,auth:`admin`}),listPersistedByAddon:E(x({addonId:m()}),C(Vve)),listAll:E(x({addonId:m().optional(),projection:S([`full`,`slim`]).optional(),isCamera:y().optional(),deviceIds:C(p()).optional()}),C(fA),{role:`viewer`}),search:E(Kk,Qk,{role:`viewer`}),getDevice:E(x({deviceId:p()}),fA.nullable()),getChildren:E(x({parentDeviceId:p()}),C(fA),{role:`viewer`}),getChildrenBatch:E(x({parentDeviceIds:C(p()).max(256)}),d(m(),C(fA))),getLinkedDevices:E(x({deviceId:p()}),x({mode:mA,devices:C(hA)}),{role:`viewer`}),getLinkedDevicesBatch:E(x({deviceIds:C(p())}),C(Bve),{role:`viewer`}),getStreamSources:E(x({deviceId:p()}),C(mc)),getConfigSchema:E(x({deviceId:p()}),C(pA)),getSettingsSchema:E(x({deviceId:p()}),Uve),updateConfig:E(x({deviceId:p(),values:d(m(),u())}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),enable:E(x({deviceId:p()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),disable:E(x({deviceId:p()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),remove:E(x({deviceId:p()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),listDeletedSince:E(x({sinceMs:p()}),C(bA).readonly(),{auth:`admin`}),cleanupDeletedDevicesData:E(x({confirm:y()}),CA,{kind:`mutation`,auth:`admin`}),removeByIntegration:E(x({integrationId:m()}),x({removed:p()}),{kind:`mutation`,auth:`admin`}),getStreamProfileMap:E(x({deviceId:p()}),d(m(),m().nullable())),setStreamProfileMap:E(x({deviceId:p(),profileMap:d(m(),m().nullable())}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),probeStreams:E(x({deviceId:p()}),C(Wve),{kind:`mutation`,auth:`admin`}),getBindings:E(x({deviceId:p()}),vA,{role:`viewer`}),getBindingsBatch:E(x({deviceIds:C(p())}),C(vA)),getAllBindings:E(x({}),C(vA)),listDeviceIdsByCaps:E(x({capNames:C(m().min(1)).min(1).max(16)}),C(p()),{role:`viewer`}),setWrapperActive:E(x({deviceId:p(),capName:m(),wrapperAddonId:m(),active:y()}),v(),{kind:`mutation`,auth:`admin`}),getWrapperActivation:E(x({deviceId:p(),capName:m().min(1)}),yA),listWrappersForCap:E(x({capName:m()}),C(m())),listBindableCapsForDeviceType:E(x({deviceType:m()}),C(x({capName:m(),wrappers:C(m())}))),getDeviceSettingsAggregate:E(x({deviceId:p()}),Fv.nullable()),getDeviceLiveInfoAggregate:E(x({deviceId:p()}),Fv.nullable(),{role:`viewer`}),getDeviceAggregate:E(x({deviceId:p()}),x({settings:Fv.nullable(),live:Fv.nullable()})),runDeviceAction:E(x({deviceId:p().int().nonnegative(),action:m().min(1),input:u()}),u(),{kind:`mutation`}),updateDeviceField:E(x({deviceId:p(),writerCapName:m(),writerAddonId:m(),key:m(),value:u()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),updateDeviceFieldsBatch:E(x({deviceId:p(),changes:C(x({writerCapName:m(),writerAddonId:m(),key:m(),value:u()}))}),x({success:s(!0),failures:C(x({writerCapName:m(),writerAddonId:m(),error:m()}))}),{kind:`mutation`,auth:`admin`}),discoverDevices:E(x({addonId:m()}),C(nA),{kind:`mutation`,auth:`admin`}),adoptDevice:E(x({addonId:m(),candidate:nA,integrationId:m().optional()}),rA,{kind:`mutation`,auth:`admin`}),getCreationSchema:E(x({addonId:m(),type:S(j),integrationId:m().optional()}),u().nullable()),createDevice:E(x({addonId:m(),type:S(j),config:d(m(),u()),integrationId:m().optional()}),rA,{kind:`mutation`,auth:`admin`}),testCreationField:E(x({addonId:m(),type:S(j),key:m(),value:u(),formValues:d(m(),u()).optional()}),iA,{kind:`mutation`,auth:`admin`}),adoptionListCandidateFilters:E(x({addonId:m(),integrationId:m()}),x({filters:C(WO)}),{auth:`admin`}),adoptionListCandidates:E(KO.extend({addonId:m()}),qO,{auth:`admin`}),adoptionRefresh:E(x({addonId:m(),integrationId:m()}),YO,{kind:`mutation`,auth:`admin`}),adoptionAdopt:E(XO.extend({addonId:m()}),ZO,{kind:`mutation`,auth:`admin`}),adoptionRelease:E(QO.extend({addonId:m()}),v(),{kind:`mutation`,auth:`admin`}),adoptionStartJob:E(XO.extend({addonId:m()}),x({jobId:m()}),{kind:`mutation`,auth:`admin`}),adoptionListJobs:E(x({addonId:m(),integrationId:m().optional()}),C(ure).readonly(),{auth:`admin`}),adoptionCancelJob:E(x({jobId:m()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),adoptionResync:E($O,ek,{kind:`mutation`,auth:`admin`}),discoveryProviders:E(x({}),x({providers:C(x({addonId:m(),label:m()})).readonly()}),{auth:`admin`}),discoverAllProviders:E(x({subnets:C(m()).optional()}),x({groups:C(x({addonId:m(),label:m(),candidates:C(nA).readonly(),error:m().nullable()})).readonly()}),{kind:`mutation`,auth:`admin`}),discoverProvider:E(x({addonId:m(),params:d(m(),u()).optional(),subnets:C(m()).optional()}),x({candidates:C(nA).readonly()}),{kind:`mutation`,auth:`admin`}),listDiscoveryProposals:E(x({}),x({proposals:C(cA).readonly()}),{auth:`admin`}),dismissDiscoveryProposal:E(x({id:m()}),x({dismissed:y()}),{kind:`mutation`,auth:`admin`}),reportDiscoveryObservations:E(x({observations:C(sA).max(512)}),x({proposed:p().int()}),{kind:`mutation`,auth:`admin`}),runDiscoverySweep:E(x({}),x({providers:p().int(),proposed:p().int()}),{kind:`mutation`,auth:`admin`,timeoutMs:12e4}),providerCreationType:E(x({addonId:m(),integrationId:m().optional()}),x({deviceType:S(j).nullable()}),{auth:`admin`}),providerDiscoveryParamsSchema:E(x({addonId:m()}),u(),{auth:`admin`}),testField:E(x({deviceId:p(),key:m(),value:u()}),iA,{kind:`mutation`,auth:`admin`}),getDeviceStatusAggregate:E(x({deviceId:p(),caps:C(m()).readonly().optional()}),d(m(),u().nullable())),getDeviceStatusAggregateBatch:E(x({deviceIds:C(p()).readonly(),caps:C(m()).readonly().optional()}),d(m(),d(m(),u().nullable())),{role:`viewer`})},vocabulary:{notOperatorFacing:`the device registry itself — rename, move and remove are administration`}},OA=[`linked-devices`],kA=S(OA),AA={"linked-devices":{descriptor:_A,declaringCap:`device-manager`,hostDeviceTypes:[j.Camera]}},jA=a(`slot`,[gA.extend({slot:s(`linked-devices`)})]),MA=[j.Camera],Jve=`listSlots`,NA=a(`state`,[x({state:s(`ok`)}),x({state:s(`unreachable`),reason:m()})]),PA=x({source:m(),label:m(),addonId:m().optional(),availability:NA}),FA=S([`ok`,`missing`,`foreign`,`unavailable`]),IA=x({deviceId:p().int(),name:m().nullable(),health:FA,detail:m().optional()}),LA=x({state:S([`active`,`inactive`,`unknown`]),authority:m(),detail:m().optional()}),RA=x({state:s(`ok`),slotRef:m(),slot:kA,authority:m(),activation:LA.nullable(),value:jA,sources:C(IA),impliedSources:C(IA).optional()}),zA=x({state:s(`unreachable`),addonId:m(),reason:m()}),BA=a(`state`,[RA,zA]);function Yve(e,t){return{state:`unreachable`,addonId:e,reason:t}}var VA=x({deviceId:p().int(),name:m(),type:m(),location:m().nullable(),parentName:m().nullable(),suggested:y(),reason:m().nullable()}),HA=x({candidates:C(VA)}),UA=x({applied:s(!0),reload:S([`none`,`host`,`parent`])}),WA=x({deviceId:p().int(),slotRef:m().min(1)}),GA=WA.extend({value:jA}),KA={name:`device-extension`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:MA,deviceConfig:{ui:{kind:`widget`,widgetId:`host/extensions-panel`,tab:`general`,label:`Extensions`,order:72}},methods:{listSources:E(x({deviceId:p().int()}),C(PA)),listSlots:E(x({deviceId:p().int()}),C(BA)),listCandidates:E(WA,HA),setSlot:E(GA,UA,{kind:`mutation`,auth:`admin`})},vocabulary:{noun:I(`Device extension`,`Estensione del dispositivo`),order:3100}},qA=a(`kind`,[x({kind:s(`device`),deviceId:p().int()}),x({kind:s(`node`),nodeId:m().min(1)})]),JA=S([`gauge`,`counter`,`boolean`,`enum`]),YA=S([`gauge`,`counter`,`boolean`]),XA=`derived:energy.kwh`,ZA=S([`raw`,`5m`,`1h`,`1d`]),QA=S([`undeclared`,`not-owner`,`opted-out`,`not-a-real-device`,`rate`,`ingest-mismatch`,`out-of-range`]),Xve=x({key:m(),reason:QA,count:p().int()}),$A=x({accepted:p().int(),refused:C(Xve).readonly()}),ej=x({key:m(),scope:m(),kind:JA,unit:m().nullable(),displayName:m(),source:S([`cap`,`addon`,`derived`]),values:C(m()).readonly().nullable(),firstTs:p(),lastTs:p()}),Zve=x({t:p(),samples:p().int(),mean:p().nullable(),twMean:p().nullable(),min:p(),max:p(),last:p().nullable(),delta:p().nullable(),state:m().nullable(),states:d(m(),p()).nullable()}),Qve=x({scope:m(),before:x({t:p(),value:p().nullable(),state:m().nullable()}).nullable(),points:C(Zve).readonly(),derivedFrom:m().nullable()}),tj={key:m(),scope:m().optional(),from:p(),to:p(),resolution:l([ZA,s(`auto`)]).default(`auto`),maxPoints:p().int().positive().max(5e3).default(1e3)},nj=x({resolution:ZA,series:C(Qve).readonly(),truncated:y()}),$ve=l([x({deviceId:p().int(),key:m(),scope:m().optional()}),x({forNodeId:m().min(1),key:m(),scope:m().optional()})]),eye=a(`ok`,[x({ok:s(!0),result:nj}),x({ok:s(!1),error:m()})]),tye=x({tier:ZA,rows:p().int().nullable(),approxBytes:p().nullable(),countedAt:p().nullable()}),rj=S([`device-gone`,`undeclared`]),ij=x({raw:p().int(),"5m":p().int(),"1h":p().int(),"1d":p().int()}),nye=x({seriesId:p().int(),deviceId:p().int(),key:m(),scope:m(),displayName:m().nullable(),reason:rj,missingSince:p().nullable(),firstTs:p(),lastTs:p(),rows:ij}),aj=S([`not-found`,`not-orphan`,`failed`]),rye=a(`ok`,[x({seriesId:p().int(),ok:s(!0),deleted:ij}),x({seriesId:p().int(),ok:s(!1),reason:aj})]),iye=x({series:C(nye).readonly(),truncated:y()}),oj=S([`invalid-range`,`range-too-large`,`series-not-found`,`not-a-point-series`]),aye=x({"5m":p().int(),"1h":p().int(),"1d":p().int()}),oye=a(`ok`,[x({ok:s(!0),dryRun:y(),seriesId:p().int(),rows:ij,rewritten:aye.nullable()}),x({ok:s(!1),reason:oj})]),sj=x({startedAt:p(),ready:y(),series:p().int(),metrics:p().int(),optedOutDevices:p().int(),tiers:C(tye).readonly(),capture:x({eventsSeen:p().int(),pointsEmitted:p().int(),pointsWritten:p().int(),pointsDropped:p().int(),bufferDepth:p().int(),trailingEmitted:p().int(),reconciledPoints:p().int(),reconcileRuns:p().int(),reconcileFailures:p().int(),lastReconcileAt:p().nullable(),lastFlushAt:p().nullable(),flushFailures:p().int(),skipped:d(m(),p().int())}),ingest:x({accepted:p().int(),refused:d(m(),p().int())}),rollup:x({last5mAt:p().nullable(),last1hAt:p().nullable(),last1dAt:p().nullable(),errors:p().int(),dirty5m:p().int(),dirty1h:p().int(),dirty1d:p().int()}),retention:x({lastRunAt:p().nullable(),deleted:d(m(),p().int()),purgedSeries:p().int()}),directory:x({devices:p().int(),lastRefreshAt:p().nullable()})}),cj={name:`device-history`,scope:`system`,mode:`singleton`,methods:{listSeries:E(x({deviceId:p().int()}),C(ej).readonly()),listNodeSeries:E(x({forNodeId:m().min(1)}),C(ej).readonly(),{auth:`admin`}),query:E(x({deviceId:p().int(),...tj}),nj),queryNode:E(x({forNodeId:m().min(1),...tj}),nj,{auth:`admin`}),queryMany:E(x({items:C($ve).min(1).max(24),from:tj.from,to:tj.to,resolution:tj.resolution,maxPoints:tj.maxPoints}),x({results:C(eye).readonly()}),{auth:`admin`}),declareSeries:E(x({name:m().regex(/^[a-z0-9-]+$/),subjectKind:S([`device`,`node`]),kind:YA,unit:m().optional(),displayName:m().min(1),ingest:S([`points`,`buckets`])}),x({key:m()}),{kind:`mutation`,auth:`admin`}),record:E(x({points:C(x({key:m(),subject:qA,scope:m().default(``),ts:p(),value:p()})).max(5e3)}),$A,{kind:`mutation`,auth:`admin`}),recordBuckets:E(x({buckets:C(x({key:m(),subject:qA,scope:m().default(``),bucketStart:p(),samples:p().int().positive(),sum:p(),min:p(),max:p(),last:p().nullable(),lastTs:p().nullable()})).max(5e3)}),$A,{kind:`mutation`,auth:`admin`}),getDeviceEnabled:E(x({deviceId:p().int()}),x({enabled:y()})),setDeviceEnabled:E(x({deviceId:p().int(),enabled:y()}),x({enabled:y()}),{kind:`mutation`,auth:`admin`}),getStatus:E(x({}),sj,{auth:`admin`}),listOrphanSeries:E(x({}),iye,{auth:`admin`}),deleteOrphanSeries:E(x({seriesIds:C(p().int()).min(1).max(50)}),x({results:C(rye).readonly()}),{kind:`mutation`,auth:`admin`}),deleteSeriesRange:E(x({deviceId:p().int(),key:m().min(1),scope:m(),fromMs:p().int().nonnegative(),toMs:p().int().nonnegative(),dryRun:y()}),oye,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`recorded history of device state — read by charts, not actuated`}},sye=x({id:m(),label:m(),protocol:S([`rtsp`,`rtmp`,`annexb`,`http-mjpeg`,`webrtc`,`custom`]),url:m().optional(),resolution:x({width:p(),height:p()}).optional(),fps:p().optional(),bitrate:p().optional(),codec:m().optional(),profileHint:A.optional(),sdp:m().optional()}),cye=x({key:m(),value:u()}),lj=x({source:m(),data:d(m(),u())}),uj={name:`device-ops`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{getStreamSources:E(x({deviceId:p()}),C(sye)),getConfigEntries:E(x({deviceId:p()}),C(cye)),setConfig:E(x({deviceId:p(),values:d(m(),u())}),v(),{kind:`mutation`,auth:`admin`}),runAction:E(x({deviceId:p(),action:m().min(1),input:u()}),u(),{kind:`mutation`,notOperatorFacing:`a provider-defined custom action whose id and input only the addon knows; it reaches the picker through the custom-actions surface, not a fixed phrase`}),removeDevice:E(x({deviceId:p()}),v(),{kind:`mutation`,auth:`admin`}),getSettingsSchema:E(x({deviceId:p()}),u().nullable()),getRawState:E(x({deviceId:p()}),lj.nullable(),{auth:`protected`})},vocabulary:{noun:I(`Device operations`,`Operazioni del dispositivo`),order:3110}},dj=x({deviceId:p().int().positive(),deletedAt:p(),providerAddonId:m()}),fj=x({counts:d(m(),p().int().nonnegative())}),pj=x({store:m(),deviceId:p().int().positive(),count:p().int().nonnegative()}),mj={name:`device-removal-hook`,scope:`system`,mode:`collection`,internal:!0,methods:{onDeviceRemoved:E(dj,fj,{kind:`mutation`,auth:`admin`}),listDeviceData:E(v(),C(pj).readonly(),{auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:O.INTERNAL}},hj=S([`appliance`,`mower`,`vacuum`]),gj=S([`open`,`closed`]),_j=S([`completed`,`aborted`,`error`,`unknown`]),vj=S([`running-state`,`activity`,`reconcile`]),yj=S([`counter-delta`,`history-integral`]),bj=x({phase:m(),at:p()}),xj=x({kind:s(`appliance`),energyKwh:p().nullable().meta(k(`energy`)),energyMethod:yj.nullable(),peakW:p().nullable().meta(k(`power`)),avgW:p().nullable().meta(k(`power`)),program:m().nullable(),remainingAtStartSec:p().nullable().meta(k(`duration`)),finalPhase:m().nullable(),energyStartKwh:p().nullable().meta(k(`energy`)),powerObservedMs:p()}),Sj=a(`kind`,[xj]),Cj=x({runId:m(),deviceId:p().int(),kind:hj,state:gj,startedAt:p(),endedAt:p().nullable(),durationMs:p().nullable(),outcome:_j.nullable(),startSource:vj,endSource:vj.nullable(),runningSource:S([`native`,`assigned`]).nullable(),phases:C(bj),detail:Sj}),wj={name:`device-runs`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[j.Washer,j.Dryer,j.Dishwasher],methods:{listRuns:E(x({deviceId:p().int(),outcome:_j.optional(),atFrom:p().optional(),atTo:p().optional(),limit:p().int().positive().max(200).default(50),cursor:m().optional()}),x({runs:C(Cj).readonly(),nextCursor:m().nullable()})),getRun:E(x({deviceId:p().int(),runId:m()}),Cj.nullable()),getCurrentRun:E(x({deviceId:p().int()}),Cj.nullable())},events:{onRunOpened:{data:Cj,notOperatorFacing:`the durable record of a run that the running-state start flip already announces`},onRunClosed:{data:Cj,notOperatorFacing:`the durable record of a run that the running-state finish flip already announces`}},vocabulary:{noun:I(`Runs`,`Esecuzioni`),order:2130}},Tj=S([`replace`,`add`]),Ej=a(`ok`,[x({ok:s(!0),changed:y()}),x({ok:s(!1),code:S([`owned-by-other`,`not-claimed`,`field-not-claimed`,`invalid-slice`,`unknown-device`,`row-unreadable`,`migration-in-flight`]),message:m()})]),Dj=x({deviceId:p(),capName:m(),owner:m().min(1),mode:Tj,fields:C(m().min(1)).min(1)}),Oj=a(`state`,[x({state:s(`loaded`),claims:C(Dj)}),x({state:s(`not-loaded`),reason:m()})]),kj={name:`device-state`,scope:`system`,mode:`singleton`,methods:{getSnapshot:E(x({deviceId:p()}),d(m(),d(m(),u()))),getCapSlice:E(x({deviceId:p(),capName:m()}),d(m(),u()).nullable()),getAllSnapshots:E(x({}),d(m(),d(m(),d(m(),u())))),setCapSlice:E(x({deviceId:p(),capName:m(),slice:d(m(),u())}),v(),{kind:`mutation`}),claimFields:E(x({deviceId:p(),capName:m(),owner:m().min(1),mode:Tj,fields:C(m().min(1)).min(1),values:d(m(),u())}),Ej,{kind:`mutation`,auth:`admin`}),patchOwnedFields:E(x({deviceId:p(),capName:m(),owner:m().min(1),values:d(m(),u())}),Ej,{kind:`mutation`,auth:`admin`}),releaseClaim:E(x({deviceId:p(),capName:m(),owner:m().min(1)}),Ej,{kind:`mutation`,auth:`admin`}),listClaims:E(x({ownerPrefix:m().optional()}),Oj,{auth:`admin`}),getNativeCapSlice:E(x({deviceId:p(),capName:m()}),d(m(),u()).nullable(),{auth:`admin`})},events:{onChanged:si(x({deviceId:p(),capName:m(),slice:d(m(),u())}))},vocabulary:{notOperatorFacing:`the runtime-state mirror every trigger already reads through`}},Aj=x({online:y(),lastChangedAt:p()}),jj={name:`device-status`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},events:{onStatusChanged:{data:x({deviceId:p(),status:Aj}),notOperatorFacing:"the `online` state trigger phrases both edges of this change"}},status:{schema:Aj,kind:`push`},runtimeState:Aj,durability:`restored`,history:{fields:{online:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:I(`Reachability`,`Raggiungibilità`),order:5260,state:[{kind:`boolean`,field:`online`,label:I(`Online`,`Online`),whenTrue:I(`When {device} comes back online`,`Quando {device} torna online`),whenFalse:I(`When {device} goes offline`,`Quando {device} va offline`),icon:`wifi`}],extraEvents:[{category:w.DeviceOnline,label:I(`Came online`,`Tornato online`),phrase:I(`When {device} comes back online`,`Quando {device} torna online`),icon:`wifi`},{category:w.DeviceOffline,label:I(`Went offline`,`Andato offline`),phrase:I(`When {device} goes offline`,`Quando {device} va offline`),icon:`wifi-off`}]}},Mj=S([`not-kernel`,`invalid`]),Nj=x({written:p().int().nonnegative(),refused:C(x({id:m(),reason:Mj})).readonly()}),Pj=x({rows:p().int().nullable(),lastWriteAt:p().nullable(),refused:d(m(),p())}),Fj={name:`device-transitions`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:Object.values(j).filter(e=>e!==j.Container),methods:{listTransitions:E(x({deviceId:p().int(),capName:m().optional(),actorKind:wo.optional(),outcome:To.optional(),atFrom:p().optional(),atTo:p().optional(),limit:p().int().positive().max(200).default(50),cursor:m().optional()}),x({transitions:C(Eo).readonly(),nextCursor:m().nullable()})),getTransition:E(x({deviceId:p().int(),id:m()}),Eo.nullable()),listRecentTransitions:oi(x({actorKind:wo.optional(),outcome:To.optional(),atFrom:p().optional(),atTo:p().optional(),limit:p().int().positive().max(200).default(50),cursor:m().optional()}),x({transitions:C(Eo).readonly(),nextCursor:m().nullable()}),{auth:`admin`}),record:oi(x({transitions:C(Eo).max(500)}),Nj,{kind:`mutation`,auth:`admin`}),getStatus:oi(x({}),Pj,{auth:`admin`})},vocabulary:{noun:I(`Transitions`,`Transizioni`),order:2140}},Ij=S([`idle`,`running`,`paused`,`finished`,`error`,`unavailable`]),Lj=S([`Inactive`,`Ready`,`DelayedStart`,`Run`,`Pause`,`ActionRequired`,`Finished`,`Error`,`Aborting`]),Rj=S([`available`,`offline`,`description-missing`]),zj=x({availability:Rj,state:Ij,operationState:Lj.nullable(),program:m().nullable(),selectedProgram:m().nullable(),availablePrograms:C(m()),remaining:p().int().nonnegative().nullable().meta(k(`duration`)),delayedStart:p().int().nonnegative().nullable().meta(k(`duration`)),progress:p().min(0).max(100).nullable().meta(k(`percentage`)),doorOpen:y().nullable(),doorLocked:y().nullable(),remoteStartAllowed:y().nullable(),remoteControlActive:y().nullable(),localControlActive:y().nullable(),powerOn:y().nullable(),powerState:m().nullable(),filterCleaningDue:y().nullable(),machineCareDue:y().nullable(),machineCareRemainingRuns:p().int().nonnegative().nullable().meta(k(`count`)),halfLoad:y().nullable(),hygienePlus:y().nullable(),extraDry:y().nullable(),intensiveZone:y().nullable(),varioSpeedPlus:y().nullable(),childLock:y().nullable(),activeEvents:C(m()),errorCode:p().nullable().meta(k(`none`)),errorLabel:m().nullable(),lastFetchedAt:p()}),Bj=p().int().nonnegative(),Vj=l([y(),m(),p()]),Hj=S([`none`,`read`,`readWrite`,`writeOnly`,`readStatic`]),Uj=x({key:m(),name:m(),type:S([`boolean`,`number`,`enum`,`string`]),access:Hj,available:y(),unit:m().nullable(),min:p().nullable(),max:p().nullable(),step:p().nullable(),enumValues:C(m()).nullable(),defaultValue:Vj.nullable()}),Wj=x({key:m(),name:m(),available:y(),options:C(Uj)}),Gj=x({availability:Rj,supportsStart:y(),supportsPause:y(),supportsResume:y(),supportsStop:y(),supportsPower:y(),programs:C(Wj),options:C(Uj)}),Kj={name:`dishwasher`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Dishwasher],methods:{start:E(x({deviceId:Bj,program:m().min(1).optional(),options:d(m(),Vj).optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.start`,label:I(`Start cycle`,`Avvia il lavaggio`),phrase:I(`Start {device}`,`Avvia {device}`),icon:`play`,openArgs:[{key:`program`,label:I(`Programme`,`Programma`),offer:{kind:`dynamic`,from:`status`,field:`availablePrograms`},optional:!0}]}]}),pause:E(x({deviceId:Bj}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.pause`,label:I(`Pause`,`Metti in pausa`),phrase:I(`Pause {device}`,`Metti in pausa {device}`),icon:`pause`}]}),resume:E(x({deviceId:Bj}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.resume`,label:I(`Resume`,`Riprendi`),phrase:I(`Resume {device}`,`Riprendi il lavaggio di {device}`),icon:`play`}]}),stop:E(x({deviceId:Bj}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.stop`,label:I(`Stop`,`Ferma`),phrase:I(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),setProgram:E(x({deviceId:Bj,program:m().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.program`,label:I(`Choose programme`,`Scegli il programma`),phrase:I(`Select the {program} programme on {device}`,`Seleziona il programma {program} su {device}`),icon:`list`,openArgs:[{key:`program`,label:I(`Programme`,`Programma`),offer:{kind:`dynamic`,from:`status`,field:`availablePrograms`}}]}]}),setPower:E(x({deviceId:Bj,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.powerOn`,label:I(`Power on`,`Accendi`),phrase:I(`Turn on {device}`,`Accendi {device}`),icon:`power`,args:{on:!0}},{id:`dishwasher.powerOff`,label:I(`Power off`,`Spegni`),phrase:I(`Turn off {device}`,`Spegni {device}`),icon:`power-off`,args:{on:!1}}]}),setHalfLoad:E(x({deviceId:Bj,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.halfLoadOn`,label:I(`Half load on`,`Mezzo carico attivo`),phrase:I(`Turn on half load on {device}`,`Attiva il mezzo carico su {device}`),icon:`contrast`,args:{on:!0}},{id:`dishwasher.halfLoadOff`,label:I(`Half load off`,`Mezzo carico spento`),phrase:I(`Turn off half load on {device}`,`Disattiva il mezzo carico su {device}`),icon:`contrast`,args:{on:!1}}]}),setHygienePlus:E(x({deviceId:Bj,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.hygienePlusOn`,label:I(`Hygiene Plus on`,`Igiene Plus attiva`),phrase:I(`Turn on Hygiene Plus on {device}`,`Attiva Igiene Plus su {device}`),icon:`sparkles`,args:{on:!0}},{id:`dishwasher.hygienePlusOff`,label:I(`Hygiene Plus off`,`Igiene Plus spenta`),phrase:I(`Turn off Hygiene Plus on {device}`,`Disattiva Igiene Plus su {device}`),icon:`sparkles`,args:{on:!1}}]}),setExtraDry:E(x({deviceId:Bj,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.extraDryOn`,label:I(`Extra dry on`,`Asciugatura extra attiva`),phrase:I(`Turn on extra dry on {device}`,`Attiva l’asciugatura extra su {device}`),icon:`sun`,args:{on:!0}},{id:`dishwasher.extraDryOff`,label:I(`Extra dry off`,`Asciugatura extra spenta`),phrase:I(`Turn off extra dry on {device}`,`Disattiva l’asciugatura extra su {device}`),icon:`sun`,args:{on:!1}}]}),setIntensiveZone:E(x({deviceId:Bj,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.intensiveZoneOn`,label:I(`Intensive zone on`,`Zona intensiva attiva`),phrase:I(`Turn on the intensive zone on {device}`,`Attiva la zona intensiva su {device}`),icon:`flame`,args:{on:!0}},{id:`dishwasher.intensiveZoneOff`,label:I(`Intensive zone off`,`Zona intensiva spenta`),phrase:I(`Turn off the intensive zone on {device}`,`Disattiva la zona intensiva su {device}`),icon:`flame`,args:{on:!1}}]}),setVarioSpeedPlus:E(x({deviceId:Bj,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.varioSpeedOn`,label:I(`Speed boost on`,`Lavaggio rapido attivo`),phrase:I(`Turn on the speed boost on {device}`,`Attiva il lavaggio rapido su {device}`),icon:`zap`,args:{on:!0}},{id:`dishwasher.varioSpeedOff`,label:I(`Speed boost off`,`Lavaggio rapido spento`),phrase:I(`Turn off the speed boost on {device}`,`Disattiva il lavaggio rapido su {device}`),icon:`zap`,args:{on:!1}}]}),setChildLock:E(x({deviceId:Bj,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.childLockOn`,label:I(`Child lock on`,`Blocco bambini attivo`),phrase:I(`Turn on the child lock of {device}`,`Attiva il blocco bambini di {device}`),icon:`lock`,args:{on:!0}},{id:`dishwasher.childLockOff`,label:I(`Child lock off`,`Blocco bambini spento`),phrase:I(`Turn off the child lock of {device}`,`Disattiva il blocco bambini di {device}`),icon:`lock-open`,args:{on:!1}}]}),setOption:E(x({deviceId:Bj,key:m().min(1),value:Vj}),v(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`a raw appliance option key/value; every option worth naming has its own action above`}),getOptions:E(x({deviceId:Bj}),Gj,{auth:`protected`})},status:{schema:zj,kind:`poll`},runtimeState:zj,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:I(`Dishwasher`,`Lavastoviglie`),order:2020,state:[{kind:`enum`,field:`state`,label:I(`Cycle`,`Ciclo`),values:[{value:`idle`,label:I(`Idle`,`Inattiva`)},{value:`running`,label:I(`Running`,`In funzione`),phrase:I(`When {device} starts a cycle`,`Quando {device} inizia un lavaggio`)},{value:`paused`,label:I(`Paused`,`In pausa`)},{value:`finished`,label:I(`Finished`,`Terminato`),phrase:I(`When {device} finishes`,`Quando {device} finisce il lavaggio`)},{value:`error`,label:I(`Error`,`Errore`),phrase:I(`When {device} reports an error`,`Quando {device} segnala un errore`)},{value:`unavailable`,label:I(`Unavailable`,`Non disponibile`)}],icon:`washing-machine`},{kind:`numeric`,field:`progress`,quantity:I(`the cycle progress`,`l’avanzamento del lavaggio`),label:I(`Progress`,`Avanzamento`),unit:`%`,icon:`loader`},{kind:`boolean`,field:`doorOpen`,label:I(`Door open`,`Sportello aperto`),whenTrue:I(`When the door of {device} opens`,`Quando si apre lo sportello di {device}`),whenFalse:I(`When the door of {device} closes`,`Quando si chiude lo sportello di {device}`),icon:`door-open`},{kind:`boolean`,field:`filterCleaningDue`,label:I(`Filter cleaning due`,`Pulizia filtro da fare`),whenTrue:I(`When {device} asks for its filter to be cleaned`,`Quando {device} chiede di pulire il filtro`),whenFalse:I(`When the filter reminder of {device} clears`,`Quando l’avviso filtro di {device} rientra`),icon:`funnel`},{kind:`boolean`,field:`machineCareDue`,label:I(`Machine care due`,`Manutenzione da fare`),whenTrue:I(`When {device} asks for a machine-care cycle`,`Quando {device} chiede un ciclo di manutenzione`),whenFalse:I(`When the machine-care reminder of {device} clears`,`Quando l’avviso di manutenzione di {device} rientra`),icon:`wrench`}]}},qj=`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(`.`),Jj=`audio`,Yj=[.3,.42,.55,.7,.85,1],Xj=[`camstack`,`high-contrast`,`okabe-ito`];function lye(e){return qj.includes(e)}function uye(e){return Xj.includes(e)}var Zj={dark:`#0c0a09`,light:`#fafaf9`},dye=[`live`,`heatmapScrub`],Qj=/^#[0-9a-fA-F]{6}$/;function $j(e,t){return Number.parseInt(e.slice(t,t+2),16)}function eM(e){let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function tM(e){let t=eM($j(e,1)),n=eM($j(e,3)),r=eM($j(e,5));return .2126*t+.7152*n+.0722*r}function fye(e,t){if(!Qj.test(e)||!Qj.test(t))return 0;let n=Math.max(tM(e),tM(t)),r=Math.min(tM(e),tM(t));return(n+.05)/(r+.05)}function nM(e){let t=eM($j(e,1)),n=eM($j(e,3)),r=eM($j(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 rM(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 pye(e,t){if(!Qj.test(e)||!Qj.test(t))return 0;let n=nM(e),r=nM(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=rM(o,n.b),d=rM(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 _=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),v=30*Math.exp(-(((g-275)/25)**2)),ee=h**7,y=2*Math.sqrt(ee/(ee+25**7)),te=1+.015*(m-50)**2/Math.sqrt(20+(m-50)**2),ne=1+.045*h,re=1+.015*h*_,ie=-Math.sin(2*v*Math.PI/180)*y,b=r.L-n.L,ae=l-c;return Math.sqrt((b/te)**2+(ae/ne)**2+(p/re)**2+ae/ne*ie*(p/re))}var mye={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`},hye=[`#b34dc7`,`#1d7d34`,`#db6b6c`,`#a43d29`,`#0e6ee6`,`#29a10b`,`#a98731`,`#0181c6`],gye={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`},_ye=[`#817f3b`,`#a0733e`,`#8658b2`,`#956301`,`#bc652d`,`#647331`,`#a14c9e`,`#d14e71`],vye={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`},yye=[`#9a3784`,`#a7392c`,`#409d50`,`#6987e7`,`#ee5b3d`,`#c0430d`,`#af79b3`,`#4b6628`],iM=m().regex(/^#[0-9a-f]{6}$/),aM=a(`form`,[x({form:s(`solid`),hex:iM}),x({form:s(`gradient`),hex:iM,alphas:C(p().gt(0).lte(1)).length(Yj.length)})]),oM=x({status:s(`ready`),presetId:S(Xj),customized:y(),source:S([`stored`,`unconfigured`]),swatches:d(m(),aM),fallbacks:C(iM).length(8)}),sM=a(`status`,[oM,x({status:s(`unknown`),reason:m()})]),cM=l([x({presetId:m()}),x({presetId:m(),overrides:d(m(),aM)})]),lM=x({presetId:m(),overrides:d(m(),aM)});function bye(e){return{form:`solid`,hex:e}}function xye(e){return{form:`gradient`,hex:e,alphas:[...Yj]}}function Sye(e){let t={};for(let n of qj){let r=e[n];if(r===void 0)throw Error(`palette table missing ${n}`);t[n]=n===`audio`?xye(r):bye(r)}return t}function uM(e,t,n,r){return{id:e,name:t,swatches:Sye(n),fallbacks:r}}var dM=[uM(`camstack`,`CamStack`,mye,hye),uM(`high-contrast`,`High contrast`,gye,_ye),uM(`okabe-ito`,`Colour-blind safe`,vye,yye)];function fM(e){return dM.find(t=>t.id===e)}function pM(){let e=fM(`camstack`);if(e===void 0)throw Error(`CamStack preset missing`);return Cye(e,`unconfigured`,!1)}function Cye(e,t,n){return{status:`ready`,presetId:e.id,customized:n,source:t,swatches:e.swatches,fallbacks:[...e.fallbacks]}}function wye(e){return e.hex}function Tye(e,t){let n=[];for(let t of qj){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 Eye(e){let t=e[Jj];return t===void 0||t.form===`gradient`&&Yj.every((e,n)=>t.alphas[n]===e)?[]:[{code:`bad-gradient`,entry:Jj}]}function Dye(e,t){let n=dye;return n.includes(e)&&n.includes(t)}function mM(e,t){let n=[];for(let t of qj)e[t]===void 0&&n.push({code:`missing-entry`,entry:t});for(let t of Object.keys(e))lye(t)||n.push({code:`unknown-entry`,entry:t});t.length!==8&&n.push({code:`bad-fallbacks`}),n.push(...Eye(e));let r=Tye(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=pye(i.hex,a.hex);o<(Dye(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=fye(e.hex,Zj[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 Oye(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 hM(e){return e.map(Oye).join(`; `)}var gM=class extends Error{violations;constructor(e){super(hM(e)),this.name=`PaletteRejectedError`,this.violations=e}};function _M(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 vM(e,t,n){let r=n.trim().toLowerCase();if(r.startsWith(`audio-`)){let n=e[Jj];return n===void 0?_M(r,t):n.hex}let i=e[r];return i===void 0?_M(r,t):i.hex}function yM(e,t){return{...e,...t}}function kye(e){return`overrides`in e?e.overrides:{}}function Aye(e){let t=fM(e.presetId);if(t===void 0||!uye(e.presetId))throw new gM([{code:`unknown-preset`,presetId:e.presetId}]);let n=kye(e),r=yM(t.swatches,n),i=mM(r,t.fallbacks);if(!i.ok)throw new gM(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 jye(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.keys(e).length===0}function Mye(e){if(e==null||jye(e))return pM();let t=lM.safeParse(e);if(!t.success)return{status:`unknown`,reason:`stored palette is unreadable`};let n=fM(t.data.presetId);if(n===void 0)return{status:`unknown`,reason:`unknown preset ${t.data.presetId}`};let r=yM(n.swatches,t.data.overrides),i=mM(r,n.fallbacks);if(!i.ok)return{status:`unknown`,reason:hM(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 Nye(e,t){return{presetId:e.presetId,overrides:{...t}}}var Pye=x({id:m(),name:m(),swatches:d(m(),aM),fallbacks:C(m())}),bM={name:`display-palette`,scope:`system`,mode:`singleton`,methods:{getPalette:E(v(),sM,{auth:`protected`,role:`viewer`}),listPresets:E(v(),C(Pye).readonly(),{auth:`protected`,role:`viewer`}),setPalette:E(cM,oM,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`the cluster display palette — one colour table for every client, not a device action`}},xM=x({enabled:y().nullable().meta({label:`Do not disturb`}),lastChangedAt:p()}),SM={name:`do-not-disturb`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.MediaPlayer],methods:{setEnabled:E(x({deviceId:p().int(),enabled:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dnd.on`,label:I(`Do not disturb on`,`Attiva Non disturbare`),phrase:I(`Turn on Do not disturb on {device}`,`Attiva Non disturbare su {device}`),icon:`bell-off`,args:{enabled:!0}},{id:`dnd.off`,label:I(`Do not disturb off`,`Disattiva Non disturbare`),phrase:I(`Turn off Do not disturb on {device}`,`Disattiva Non disturbare su {device}`),icon:`bell`,args:{enabled:!1}}]})},status:{schema:xM,kind:`push`},runtimeState:xM,durability:`session`,history:{fields:{enabled:{kind:`boolean`}}},vocabulary:{noun:I(`Do not disturb`,`Non disturbare`),order:2160,state:[{kind:`boolean`,field:`enabled`,label:I(`Do not disturb`,`Non disturbare`),whenTrue:I(`When Do not disturb turns on on {device}`,`Quando {device} attiva Non disturbare`),whenFalse:I(`When Do not disturb turns off on {device}`,`Quando {device} disattiva Non disturbare`),icon:`bell-off`}]}},CM=2e3,Fye={version:1,targets:[{id:`pressed`,cardinality:`event`,shape:`pulse`,vocabulary:{cap:`doorbell`,eventName:`onPressed`},deviceTypes:[j.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:CM,changedAtRequired:!0},sources:[{kind:`binary`},{kind:`switch`}],sourceReport:{status:`assignment-status`},advancedExpression:!0}]},wM=x({lastPressedAt:p().nullable(),pressCountSinceStart:p().meta(k(`count`))}),TM=x({deviceId:p(),timestamp:p()}),EM={name:`doorbell`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Button,j.Camera],methods:{},events:{onPressed:{data:TM,fromState:{field:`lastPressedAt`,on:`advance`},trigger:{category:w.DoorbellOnPressed,label:I(`Rang`,`Ha suonato`),phrase:I(`When someone rings {device}`,`Quando qualcuno suona a {device}`),icon:`bell-ring`}}},status:{schema:wM,kind:`push`},runtimeState:wM,durability:`restored`,history:`none`,customize:Fye,vocabulary:{noun:I(`Doorbell`,`Campanello`),order:5270}},DM=x({embedding:C(p()),inferenceMs:p()}),OM=S([`image`,`text`]),kM=x({modelId:m(),tower:OM,nodeId:m(),crashes:p(),windowMs:p(),sinceMs:p(),lastReason:m()}),AM=x({modelId:m(),tower:OM,nodeId:m(),attempts:p(),sinceMs:p(),lastReason:m()}),jM=x({modelId:m(),embeddingDim:p(),ready:y(),nodeId:m().optional(),failedModels:C(kM).optional(),failedRequirements:C(AM).optional()}),MM=`embedding-model-failed`,NM=`embedding-requirements-unavailable`,PM=`embedding-requirements-failed`,FM=S([MM,NM,PM]);function IM(e,t){return`[${e} model=${t.modelId} tower=${t.tower} node=${t.nodeId}]`}function Iye(e){return Error(`${IM(MM,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 Lye(e,t){return Error(`${IM(NM,e)} ${e.modelId} (${e.tower} tower) on ${e.nodeId}: ${t}`)}function Rye(e){return Error(`${IM(PM,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 zye=RegExp(`\\[(${MM}|${NM}|${PM}) model=([^\\s\\]]+) tower=(image|text) node=([^\\s\\]]+)\\]`);function LM(e){let t=e instanceof Error?e.message:String(e),n=zye.exec(t);if(n===null)return null;let r=FM.safeParse(n[1]),i=OM.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 Bye(e){return RM(e)!==null}function RM(e){let t=LM(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 zM={name:`embedding-encoder`,scope:`system`,mode:`collection`,internal:!0,methods:{encode:E(x({crop:b(Uint8Array),width:p(),height:p()}),DM,{auth:`admin`}),encodeText:E(x({text:m(),modelId:m().min(1).optional()}),DM,{auth:`admin`}),getInfo:E(v(),jM,{auth:`admin`}),resetFailedModels:E(x({modelId:m().min(1).optional()}),x({cleared:C(m()),nodeId:m()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.ML}},BM=x({powerW:p().nullable().meta(k(`power`)),energyKwh:p().nullable().meta(k(`energy`)),todayKwh:p().nullable().meta(k(`energy`))}),VM=x({powerW:p().nullable().meta(k(`power`)),importKwh:p().nullable().meta(k(`energy`)),exportKwh:p().nullable().meta(k(`energy`)),importTodayKwh:p().nullable().meta(k(`energy`)),exportTodayKwh:p().nullable().meta(k(`energy`))}),HM=x({powerW:p().nullable().meta(k(`power`)),energyKwh:p().nullable().meta(k(`energy`)),todayKwh:p().nullable().meta(k(`energy`))}),UM=x({stateOfChargePct:p().nullable().meta(k(`percentage`)),storedKwh:p().nullable().meta(k(`energy`)),capacityKwh:p().nullable().meta(k(`energy`)),powerW:p().nullable().meta(k(`power`)),chargedKwh:p().nullable().meta(k(`energy`)),dischargedKwh:p().nullable().meta(k(`energy`)),chargedTodayKwh:p().nullable().meta(k(`energy`)),dischargedTodayKwh:p().nullable().meta(k(`energy`)),healthPct:p().nullable().meta(k(`percentage`))}),WM=x({solar:BM.nullable(),grid:VM.nullable(),house:HM.nullable(),heatPump:HM.nullable(),storage:UM.nullable(),lastFetchedAt:p()});function GM(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 KM={name:`energy-system`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.EnergySystem],methods:{},status:{schema:WM,kind:`push`},runtimeState:WM,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:I(`Energy system`,`Sistema energetico`),order:4020}},Vye=S([`date`,`time`,`datetime`]),qM=x({value:m(),timestamp:y().optional(),lastFetchedAt:p()}),JM={name:`enum-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor],methods:{},status:{schema:qM,kind:`push`},runtimeState:qM,durability:`restored`,history:{fields:{value:{kind:`enum`,skipWhenSet:`timestamp`}}},volatileStateFields:[`lastFetchedAt`,`timestamp`],vocabulary:{noun:I(`State sensor`,`Sensore di stato`),order:5060,state:[{kind:`value`,field:`value`,label:I(`State`,`Stato`),icon:`list`}]}},YM=S([`warning`,`error`]),XM=x({code:m(),label:m(),severity:YM}),ZM=x({active:y().nullable(),code:m().nullable(),label:m().nullable(),severity:YM,since:p().nullable(),faults:C(XM).optional(),lastFetchedAt:p()}),QM={active:null,code:null,label:null,severity:`error`,since:null,lastFetchedAt:0},$M={name:`error`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},status:{schema:ZM,kind:`push`,empty:QM},runtimeState:ZM,durability:`restored`,volatileStateFields:[`lastFetchedAt`],history:`none`,vocabulary:{noun:I(`Fault`,`Guasto`),order:5265,state:[{kind:`boolean`,field:`active`,label:I(`Fault`,`Guasto`),whenTrue:I(`When {device} reports a fault`,`Quando {device} segnala un guasto`),whenFalse:I(`When the fault of {device} clears`,`Quando il guasto di {device} si risolve`),icon:`triangle-alert`}]}},eN=x({id:m(),name:m(),sampleCount:p().int().nonnegative(),coverMediaId:p().int().optional(),coverBase64:m().optional()}),Hye=x({id:m(),source:S([`detected`,`photo`]),addedAt:p().int(),deviceId:p().int().optional(),base64:m().optional(),mediaId:p().int().optional(),keyFrameMediaId:p().int().optional(),faceBbox:_y.optional()}),Uye=x({sampleId:m(),enrolledAt:p().int(),deviceId:p().int().optional(),source:S([`detected`,`photo`]),mediaId:p().int().optional(),comparable:y(),selfMean:p().nullable(),bestForeign:x({identityId:m(),name:m(),score:p()}).optional(),suspicion:p()}),Wye=x({identityId:m(),name:m(),modelId:m(),totalSamples:p().int(),comparableSamples:p().int(),flagged:p().int(),flagThreshold:p(),rows:C(Uye).readonly()}),tN=x({faceId:m(),deviceId:p().int(),trackId:m(),timestamp:p().int(),recognizedIdentityId:m().optional(),identityName:m().optional(),assigned:y(),base64:m().optional(),cropUrl:m().optional(),faceBbox:_y.optional(),keyFrameMediaId:p().int().optional(),bestMatchScore:p().optional(),nativeFaceShortSidePx:p().optional(),suggestedIdentityId:m().optional(),suggestedMatchScore:p().optional()}),Gye=S([`unassigned`,`recognized`,`identified`,`all`]),Kye=S([`timestamp`,`suggestionConfidence`]),qye=S([`asc`,`desc`]),Jye=x({faceIds:C(m()).readonly(),representativeFaceId:m(),size:p().int(),cohesion:p()}),Yye=x({mediaId:p().int(),kind:m(),url:m(),sizeBytes:p(),timestamp:p()}),nN={name:`face-gallery`,role:{feature:`face-assignment`},scope:`system`,mode:`singleton`,methods:{listIdentities:E(x({includeCrops:y().optional()}).optional(),C(eN).readonly(),{role:`viewer`}),createIdentity:E(x({name:m().min(1)}),eN,{kind:`mutation`,auth:`admin`}),renameIdentity:E(x({id:m(),name:m().min(1)}),v(),{kind:`mutation`,auth:`admin`}),deleteIdentity:E(x({id:m()}),v(),{kind:`mutation`,auth:`admin`}),listIdentitySamples:E(x({identityId:m()}),C(Hye).readonly()),auditIdentitySamples:E(x({identityId:m().min(1)}),Wye,{auth:`admin`}),removeSample:E(x({identityId:m(),sampleId:m()}),v(),{kind:`mutation`,auth:`admin`}),moveIdentitySample:E(x({sampleId:m().min(1),toIdentityId:m().min(1)}),v(),{kind:`mutation`,auth:`admin`}),listRecentFaces:E(x({deviceId:p().int().optional(),deviceIds:C(p().int()).optional(),limit:p().int().positive().optional(),filter:Gye.optional(),since:p().int().optional(),until:p().int().optional(),sortBy:Kye.optional(),sortDirection:qye.optional(),includeCrops:y().optional()}).optional(),C(tN).readonly()),getFaceByTrack:E(x({deviceId:p().int(),trackId:m()}),tN.nullable(),{role:`viewer`}),getFaceMedia:E(x({faceId:m()}),C(Yye).readonly()),assignFace:E(x({faceId:m(),identityId:m()}),v(),{kind:`mutation`,auth:`admin`}),unassignFace:E(x({faceId:m()}),v(),{kind:`mutation`,auth:`admin`}),deleteFace:E(x({faceId:m()}),v(),{kind:`mutation`,auth:`admin`}),assignFaces:E(x({faceIds:C(m()).min(1),identityId:m()}),x({assigned:p().int(),failed:C(m()).readonly()}),{kind:`mutation`,auth:`admin`}),unassignFaces:E(x({faceIds:C(m()).min(1)}),x({unassigned:p().int(),failed:C(m()).readonly()}),{kind:`mutation`,auth:`admin`}),suggestFaceClusters:E(x({threshold:p().min(0).max(1).optional(),minClusterSize:p().int().min(2).optional(),maxClusters:p().int().positive().optional(),limit:p().int().positive().optional(),maxFacesScanned:p().int().positive().optional()}).optional(),C(Jye).readonly())},vocabulary:{notOperatorFacing:`the face gallery — curated on its own page`}},rN=x({reason:m(),count:p().int().nonnegative()}),iN=x({family:m(),deviceId:p().int().positive(),variant:m().optional(),sinceMs:p(),atMs:p(),attempts:p().int().nonnegative(),succeeded:p().int().nonnegative(),reasons:C(rN).readonly()}),aN={name:`failure-contribution`,scope:`system`,mode:`collection`,internal:!0,methods:{list:E(v(),C(iN).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:O.INTERNAL}},oN=S([`forward`,`reverse`]),sN=[`horizontal`,`vertical`],cN=S(sN),lN=[`oscillating`,`angle`,`sweepFrom`,`sweepTo`],uN=S(lN),dN=[`min`,`max`,`step`],fN=x({oscillating:y().nullable().default(null),angle:p().nullable().default(null),sweepFrom:p().nullable().default(null),sweepTo:p().nullable().default(null),min:p().nullable().default(null),max:p().nullable().default(null),step:p().nullable().default(null)}),pN=x({horizontal:fN.nullable().default(null),vertical:fN.nullable().default(null)}),mN=[`nothing-to-set`,`axis-not-linked`,`out-of-range`,`source-gone`,`source-unknown`,`source-call-failed`],hN=S(mN),gN=a(`status`,[x({status:s(`applied`)}),x({status:s(`refused`),reason:hN,field:uN.optional(),detail:m(),applied:C(uN)})]),_N=x({deviceId:p().int().nonnegative(),axis:cN,oscillating:y().optional(),angle:p().optional(),sweepFrom:p().optional(),sweepTo:p().optional()});function vN(e,t){return`oscillationAxes.${e}.${t}`}var yN=x({speed:p().min(0).max(100).nullable().meta(k(`percentage`)),percentageStep:p().positive().optional().meta(k(`percentage`)),preset:m(),availablePresets:C(m()),direction:oN.nullable(),oscillating:y().nullable(),oscillationAxes:pN.optional(),lastChangedAt:p()});function Xye(e){let t=e.oscillationAxes;if(t===void 0)return e.oscillating;let n=sN.flatMap(e=>{let n=t[e]?.oscillating;return n==null?[]:[n]});return n.length===0?e.oscillating:n.some(Boolean)}var bN=[j.Fan],xN=`oscillation-axes`;function Zye(e){return{id:`${e}-oscillating`,cardinality:`scalar`,vocabulary:{cap:`fan-control`,stateField:`oscillating`},deviceTypes:bN,apply:`replace`,section:xN,path:vN(e,`oscillating`),sources:[{kind:`switch`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}}function SN(e,t){let n={id:`${e}-${t}`,cardinality:`scalar`,vocabulary:{cap:`fan-control`},deviceTypes:bN,apply:`replace`,section:xN,path:vN(e,t),sources:[{kind:`numeric`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}};return t===`angle`?{...n,companions:dN.map(t=>({kind:`source-field`,path:vN(e,t),field:t}))}:n}var Qye=sN.flatMap(e=>[Zye(e),SN(e,`angle`),SN(e,`sweepFrom`),SN(e,`sweepTo`)]),$ye={id:`preset`,cardinality:`scalar`,vocabulary:{cap:`fan-control`},deviceTypes:bN,apply:`replace`,path:`preset`,sources:[{kind:`field`,valueKinds:[`string`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}},CN=[...Qye,$ye],ebe={version:1,overridable:CN.map(e=>({path:e.path,by:e.id})),targets:CN},wN={name:`fan-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Fan],methods:{setPercentage:D(x({deviceId:p().int().nonnegative(),speed:p().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.off`,label:I(`Fan off`,`Ventilatore spento`),phrase:I(`Stop {device}`,`Ferma {device}`),icon:`power-off`,effect:{field:`speed`,value:0},args:{speed:0}},{id:`fan.full`,label:I(`Fan full`,`Ventilatore al massimo`),phrase:I(`Run {device} at full speed`,`Porta {device} alla massima velocità`),icon:`fan`,effect:{field:`speed`,value:100},args:{speed:100}},{id:`fan.speed`,label:I(`Set speed`,`Imposta la velocità`),phrase:I(`Set the speed of {device} to {speed}`,`Imposta la velocità di {device} al {speed}`),icon:`fan`,effect:{field:`speed`,fromArg:`speed`},openArgs:[{key:`speed`,label:I(`Speed`,`Velocità`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setPreset:D(x({deviceId:p().int().nonnegative(),preset:m().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.preset`,label:I(`Set preset`,`Imposta il preset`),phrase:I(`Set {device} to preset {preset}`,`Imposta {device} sul preset {preset}`),icon:`list`,openArgs:[{key:`preset`,label:I(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`status`,field:`availablePresets`}}]}]}),setDirection:D(x({deviceId:p().int().nonnegative(),direction:oN}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.forward`,label:I(`Spin forward`,`Rotazione avanti`),phrase:I(`Spin {device} forward`,`Fai girare {device} in avanti`),icon:`refresh-cw`,effect:{field:`direction`,value:`forward`},args:{direction:`forward`}},{id:`fan.reverse`,label:I(`Spin in reverse`,`Rotazione inversa`),phrase:I(`Spin {device} in reverse`,`Fai girare {device} al contrario`),icon:`rotate-ccw`,effect:{field:`direction`,value:`reverse`},args:{direction:`reverse`}}]}),setOscillating:D(x({deviceId:p().int().nonnegative(),oscillating:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.oscillateOn`,label:I(`Oscillate`,`Oscillazione attiva`),phrase:I(`Make {device} oscillate`,`Fai oscillare {device}`),icon:`move-horizontal`,effect:{field:`oscillating`,value:!0},args:{oscillating:!0}},{id:`fan.oscillateOff`,label:I(`Stop oscillating`,`Oscillazione spenta`),phrase:I(`Stop {device} oscillating`,`Ferma l’oscillazione di {device}`),icon:`move-horizontal`,effect:{field:`oscillating`,value:!1},args:{oscillating:!1}}]}),setOscillationAxis:D(_N,gN,{kind:`mutation`,auth:`protected`,actions:[{id:`fan.horizontalOscillateOn`,label:I(`Horizontal oscillation on`,`Oscillazione orizzontale attiva`),phrase:I(`Start the horizontal oscillation of {device}`,`Attiva l’oscillazione orizzontale di {device}`),icon:`move-horizontal`,args:{axis:`horizontal`,oscillating:!0}},{id:`fan.horizontalOscillateOff`,label:I(`Horizontal oscillation off`,`Oscillazione orizzontale spenta`),phrase:I(`Stop the horizontal oscillation of {device}`,`Ferma l’oscillazione orizzontale di {device}`),icon:`move-horizontal`,args:{axis:`horizontal`,oscillating:!1}},{id:`fan.verticalOscillateOn`,label:I(`Vertical oscillation on`,`Oscillazione verticale attiva`),phrase:I(`Start the vertical oscillation of {device}`,`Attiva l’oscillazione verticale di {device}`),icon:`move-vertical`,args:{axis:`vertical`,oscillating:!0}},{id:`fan.verticalOscillateOff`,label:I(`Vertical oscillation off`,`Oscillazione verticale spenta`),phrase:I(`Stop the vertical oscillation of {device}`,`Ferma l’oscillazione verticale di {device}`),icon:`move-vertical`,args:{axis:`vertical`,oscillating:!1}}]})},status:{schema:yN,kind:`push`},runtimeState:yN,customize:ebe,durability:`session`,history:{fields:{speed:{kind:`gauge`,unit:`%`,minIntervalMs:0},oscillating:{kind:`boolean`}}},vocabulary:{noun:I(`Fan`,`Ventilatore`),order:1080,state:[{kind:`numeric`,field:`speed`,quantity:I(`the speed`,`la velocità`),label:I(`Speed`,`Velocità`),unit:`%`,icon:`fan`},{kind:`boolean`,field:`oscillating`,label:I(`Oscillating`,`Oscillazione`),whenTrue:I(`When {device} starts oscillating`,`Quando {device} inizia a oscillare`),whenFalse:I(`When {device} stops oscillating`,`Quando {device} smette di oscillare`),icon:`move-horizontal`}]}},TN=x({oscillating:y().optional(),angle:p().optional(),sweepFrom:p().optional(),sweepTo:p().optional()}),EN=x({speed:p().min(0).max(100).optional(),preset:m().min(1).optional(),direction:oN.optional(),oscillationAxes:x({horizontal:TN.optional(),vertical:TN.optional()}).optional()}),DN=x({id:m().min(1).max(64),name:m().trim().min(1).max(40),state:EN}),ON=[`empty-state`,`duplicate-name`,`duplicate-id`,`too-many`,`not-a-fan`],kN=S(ON),AN=a(`status`,[x({status:s(`saved`),count:p().int().nonnegative()}),x({status:s(`refused`),reason:kN,detail:m()})]),jN=x({field:m(),outcome:S([`applied`,`failed`,`not-run`,`refused`]),message:m().optional()}),MN=x({status:S([`applied`,`partial`,`refused`]),fields:C(jN)}),NN=[`speed`,`direction`,`preset`,`oscillationAxes`],PN=S(NN),FN=x({what:m(),reason:m()}),IN=x({state:EN,omitted:C(FN)}),LN=x({deviceId:p().int().nonnegative()}),tbe={version:1,targets:[{id:`presets`,cardinality:`config`,vocabulary:{cap:`fan-presets`},deviceTypes:[j.Fan],apply:`add`,readMethod:`getPresets`,writeMethod:`setPresets`}]},RN={name:`fan-presets`,scope:`system`,mode:`singleton`,methods:{getPresets:E(LN,C(DN),{auth:`protected`}),setPresets:E(LN.extend({presets:C(DN).max(12)}),AN,{kind:`mutation`,auth:`admin`}),applyPreset:E(LN.extend({presetId:m().min(1)}),MN,{kind:`mutation`,auth:`protected`}),capturePreset:E(LN.extend({fields:C(PN).optional()}),IN,{auth:`protected`})},customize:tbe,vocabulary:{notOperatorFacing:`the per-fan presets — authored in the Customize presets editor, applied through the actions the exports list`}},zN=x({flags:d(m(),u()),deviceType:m().nullable(),model:m().nullable(),channelCount:p().nullable().meta(k(`count`)),lastProbedAt:p(),lastFetchedAt:p()}),BN={name:`feature-probe`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},events:{onProbeChanged:{data:x({deviceId:p(),status:zN}),notOperatorFacing:`the device’s capabilities were re-probed — plumbing, not a happening`}},status:{schema:zN,kind:`push`},runtimeState:zN,durability:`session`,history:`none`,vocabulary:{noun:I(`Feature probe`,`Rilevamento funzioni`),order:3120}},nbe=x({name:m(),path:m()}),rbe=x({path:m(),entries:C(nbe).readonly(),freeBytes:p(),totalBytes:p()}),VN={name:`filesystem-browse`,scope:`system`,mode:`singleton`,internal:!0,methods:{listAllowedRoots:E(v(),C(m()).readonly(),{auth:`admin`}),browse:E(x({path:m()}),rbe,{auth:`admin`}),createDir:E(x({path:m()}),x({path:m()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.INTERNAL}},HN=x({flooded:y(),lastChangedAt:p()}),UN={name:`flood`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor],methods:{},status:{schema:HN,kind:`push`},runtimeState:HN,durability:`restored`,history:{fields:{flooded:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:I(`Leak sensor`,`Sensore di allagamento`),order:5070,state:[{kind:`boolean`,field:`flooded`,label:I(`Leak`,`Perdita`),whenTrue:I(`When {device} detects a leak`,`Quando {device} rileva una perdita`),whenFalse:I(`When {device} is dry again`,`Quando {device} torna asciutto`),icon:`droplets`}]}},WN=x({detected:y(),lastChangedAt:p()}),GN={name:`gas`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor],methods:{},status:{schema:WN,kind:`push`},runtimeState:WN,durability:`restored`,history:{fields:{detected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:I(`Gas sensor`,`Sensore di gas`),order:5080,state:[{kind:`boolean`,field:`detected`,label:I(`Detected`,`Rilevato`),whenTrue:I(`When {device} detects gas`,`Quando {device} rileva gas`),whenFalse:I(`When the gas clears on {device}`,`Quando il gas su {device} rientra`),icon:`flame`}]}},KN=x({active:y().meta({label:`Active`}),lastChangedAt:p()}),qN={name:`group-active`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Cover,j.Valve,j.Lock,j.MediaPlayer,j.Climate],methods:{},status:{schema:KN,kind:`push`},runtimeState:KN,durability:`session`,history:`none`,vocabulary:{noun:I(`Group state`,`Stato del gruppo`),order:5090}},JN=x({deviceId:p().int().nonnegative(),cap:m().min(1),method:m().min(1),ok:y(),error:m().optional(),at:p()}),YN=x({results:C(JN)}),XN={name:`group-commands`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Switch,j.Light,j.Fan,j.Cover,j.Valve,j.Lock,j.MediaPlayer,j.Climate],methods:{},status:{schema:YN,kind:`push`},runtimeState:YN,durability:`session`,history:`none`,vocabulary:{noun:I(`Group command`,`Comando di gruppo`),order:5100}},ZN=x({included:p().int().nonnegative().meta(k(`count`,{precision:0,label:`Reporting`})),excluded:p().int().nonnegative().meta(k(`count`,{precision:0,label:`Excluded`})),total:p().int().nonnegative().meta(k(`count`,{precision:0,label:`Members`}))}),QN={name:`group-status`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor,j.Switch,j.Light,j.Fan,j.Cover,j.Valve,j.Lock,j.MediaPlayer,j.Climate],methods:{},status:{schema:ZN,kind:`push`},runtimeState:ZN,durability:`session`,history:`none`,vocabulary:{noun:I(`Group`,`Gruppo`),order:5110,state:[{kind:`numeric`,field:`included`,quantity:I(`the members reporting`,`i membri che rispondono`),label:I(`Reporting`,`Rispondono`),icon:`users`},{kind:`numeric`,field:`excluded`,quantity:I(`the members left out`,`i membri esclusi`),label:I(`Excluded`,`Esclusi`),icon:`users`},{kind:`numeric`,field:`total`,quantity:I(`the member count`,`il numero di membri`),label:I(`Members`,`Membri`),icon:`sigma`}]}},$N=p().int().nonnegative(),eP=m().min(1),tP=m().min(1),nP=p().finite(),rP={key:`circuitId`,label:I(`Circuit`,`Circuito`),offer:{kind:`dynamic`,from:`status`,cap:`heat-pump-status`,field:`circuits`,valueKey:`id`,labelKey:`label`,where:{key:`kind`,equals:`heating`}}},iP={...rP,label:I(`Hot water circuit`,`Circuito acqua calda`),offer:{...rP.offer,where:{key:`kind`,equals:`dhw`}}},aP={key:`mode`,label:I(`Mode`,`Modalità`),offer:{kind:`text`}},ibe={key:`level`,label:I(`Level`,`Livello`),offer:{kind:`text`}},oP={key:`temp`,label:I(`Temperature`,`Temperatura`),offer:{kind:`number`,step:.5,unit:`°C`}},abe={key:`minutes`,label:I(`Minutes`,`Minuti`),offer:{kind:`number`,min:1,step:1,unit:`min`}},sP={name:`heat-pump-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.HeatPump],methods:{setSilentMode:E(x({deviceId:$N,mode:tP}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.silent`,label:I(`Set silent mode`,`Imposta la modalità silenziosa`),phrase:I(`Set silent mode of {device} to {mode}`,`Imposta la modalità silenziosa di {device} su {mode}`),icon:`volume-x`,openArgs:[{key:`mode`,label:I(`Silent mode`,`Modalità silenziosa`),offer:{kind:`enum`,values:[{value:`off`,label:I(`Off`,`Off`)},{value:`auto`,label:I(`Auto`,`Auto`)},{value:`on`,label:I(`On`,`On`)}]}}]}]}),setAwayMode:E(x({deviceId:$N,mode:tP}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.away`,label:I(`Set away mode`,`Imposta la modalità assente`),phrase:I(`Set away mode of {device} to {mode}`,`Imposta la modalità assente di {device} su {mode}`),icon:`plane`,openArgs:[{key:`mode`,label:I(`Away mode`,`Modalità assente`),offer:{kind:`enum`,values:[{value:`off`,label:I(`Off`,`Off`)},{value:`on`,label:I(`On`,`On`)}]}}]}]}),setAdditionalHeaterMode:E(x({deviceId:$N,mode:tP}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.additionalHeater`,label:I(`Set additional heater`,`Imposta il riscaldatore aggiuntivo`),phrase:I(`Set the additional heater of {device} to {mode}`,`Imposta il riscaldatore aggiuntivo di {device} su {mode}`),icon:`flame`,openArgs:[{key:`mode`,label:I(`Additional heater`,`Riscaldatore aggiuntivo`),offer:{kind:`enum`,values:[{value:`off`,label:I(`Off`,`Off`)},{value:`manual`,label:I(`Manual`,`Manuale`)},{value:`auto`,label:I(`Auto`,`Auto`)}]}}]}]}),setHolidayMode:E(x({deviceId:$N,mode:tP}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.holiday`,label:I(`Set holiday mode`,`Imposta la modalità vacanza`),phrase:I(`Set holiday mode of {device} to {mode}`,`Imposta la modalità vacanza di {device} su {mode}`),icon:`tree-palm`,openArgs:[{key:`mode`,label:I(`Holiday programme`,`Programma vacanza`),offer:{kind:`enum`,values:[{value:`off`,label:I(`Off`,`Off`)},{value:`hm1`,label:I(`Programme 1`,`Programma 1`)},{value:`hm2`,label:I(`Programme 2`,`Programma 2`)},{value:`hm3`,label:I(`Programme 3`,`Programma 3`)},{value:`hm4`,label:I(`Programme 4`,`Programma 4`)},{value:`hm5`,label:I(`Programme 5`,`Programma 5`)},{value:`hm6`,label:I(`Programme 6`,`Programma 6`)},{value:`hm7`,label:I(`Programme 7`,`Programma 7`)},{value:`hm8`,label:I(`Programme 8`,`Programma 8`)}]}}]}]}),setCircuitOperationMode:E(x({deviceId:$N,circuitId:eP,mode:tP}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitOperationMode`,label:I(`Set circuit operation mode`,`Imposta la modalità del circuito`),phrase:I(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`thermometer`,openArgs:[rP,aP]}]}),setCircuitHeatCoolMode:E(x({deviceId:$N,circuitId:eP,mode:tP}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitHeatCoolMode`,label:I(`Set circuit heat / cool`,`Imposta caldo / freddo del circuito`),phrase:I(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`sun-snow`,openArgs:[rP,aP]}]}),setCircuitSummerWinter:E(x({deviceId:$N,circuitId:eP,mode:tP}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitSummerWinter`,label:I(`Set circuit summer / winter`,`Imposta estate / inverno del circuito`),phrase:I(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`sun`,openArgs:[rP,aP]}]}),setCircuitComfortSetpoint:E(x({deviceId:$N,circuitId:eP,temp:nP}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitComfortSetpoint`,label:I(`Set comfort temperature`,`Imposta la temperatura comfort`),phrase:I(`Set the comfort temperature of {circuitId} on {device} to {temp}`,`Imposta la temperatura comfort di {circuitId} su {device} a {temp}`),icon:`thermometer-sun`,openArgs:[rP,oP]}]}),setCircuitEcoSetpoint:E(x({deviceId:$N,circuitId:eP,temp:nP}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitEcoSetpoint`,label:I(`Set eco temperature`,`Imposta la temperatura eco`),phrase:I(`Set the eco temperature of {circuitId} on {device} to {temp}`,`Imposta la temperatura eco di {circuitId} su {device} a {temp}`),icon:`leaf`,openArgs:[rP,oP]}]}),setCircuitMaxFlowTemp:E(x({deviceId:$N,circuitId:eP,temp:nP}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitMaxFlowTemp`,label:I(`Set maximum flow temperature`,`Imposta la temperatura massima di mandata`),phrase:I(`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:[rP,oP]}]}),setDhwOperationMode:E(x({deviceId:$N,circuitId:eP,mode:tP}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwOperationMode`,label:I(`Set hot water mode`,`Imposta la modalità acqua calda`),phrase:I(`Set hot water {circuitId} of {device} to {mode}`,`Imposta l'acqua calda {circuitId} di {device} su {mode}`),icon:`shower-head`,openArgs:[iP,aP]}]}),setDhwTemperatureLevel:E(x({deviceId:$N,circuitId:eP,level:tP}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwTemperatureLevel`,label:I(`Set hot water level`,`Imposta il livello acqua calda`),phrase:I(`Set hot water {circuitId} of {device} to level {level}`,`Imposta l'acqua calda {circuitId} di {device} al livello {level}`),icon:`droplet`,openArgs:[iP,ibe]}]}),setDhwChargeDuration:E(x({deviceId:$N,circuitId:eP,minutes:p().int().positive()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwChargeDuration`,label:I(`Set hot water charge duration`,`Imposta la durata della carica acqua calda`),phrase:I(`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:[iP,abe]}]}),startExtraHotWater:E(x({deviceId:$N,circuitId:eP}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.extraHotWater`,label:I(`Start extra hot water`,`Avvia acqua calda extra`),phrase:I(`Start an extra hot water charge of {circuitId} on {device}`,`Avvia una carica extra di acqua calda {circuitId} su {device}`),icon:`droplets`,openArgs:[iP]}]})},vocabulary:{noun:I(`Heat pump settings`,`Impostazioni pompa di calore`),order:4010}},cP=[`heating`,`dhw`,`cooling`,`solar`],lP=S(cP),uP=x({value:m().nullable(),allowed:C(m())}),dP=x({value:p().nullable(),min:p().nullable(),max:p().nullable(),step:p().nullable()}),fP=x({id:m().min(1),kind:lP,label:m(),icon:Vu,currentTemp:p().nullable().meta(k(`temperature`)),targetTemp:p().nullable().meta(k(`temperature`)),mode:m().nullable(),active:y().nullable(),operationMode:uP.nullable(),heatCoolMode:uP.nullable(),summerWinter:uP.nullable(),comfortSetpoint:dP.nullable(),ecoSetpoint:dP.nullable(),maxFlowTemp:dP.nullable(),temperatureLevel:uP.nullable(),chargeDuration:dP.nullable(),extraHotWater:y().nullable()}),pP=x({silent:uP.nullable(),away:uP.nullable(),additionalHeater:uP.nullable(),holiday:uP.nullable()}),mP=x({thermalW:p().nullable().meta(k(`power`)),electricalW:p().nullable().meta(k(`power`)),compressorPct:p().nullable().meta(k(`percentage`))}),hP=x({supply:p().nullable().meta(k(`temperature`)),return:p().nullable().meta(k(`temperature`)),outdoor:p().nullable().meta(k(`temperature`))}),gP=x({thermalKwh:p().nullable().meta(k(`energy`)),electricalKwh:p().nullable().meta(k(`energy`))}),_P=x({circuits:C(fP),system:pP,power:mP,temperatures:hP,energy:gP,waterPressureBar:p().nullable(),starts:p().nullable(),lastFetchedAt:p()});function vP(e){let{thermalW:t,electricalW:n}=e;return t===null||n===null||n<=0?null:t/n}var yP={name:`heat-pump-status`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.HeatPump],methods:{},status:{schema:_P,kind:`push`},runtimeState:_P,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:I(`Heat pump`,`Pompa di calore`),order:4e3}},bP=x({position:p().min(0).max(100).nullable().meta(k(`percentage`)),lastFetchedAt:p()}),xP={name:`heating-valve`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Climate],methods:{},status:{schema:bP,kind:`push`},runtimeState:bP,durability:`session`,history:{fields:{position:{kind:`gauge`,unit:`%`,deadband:1}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`Radiator valve`,`Valvola termostatica`),order:1110,state:[{kind:`numeric`,field:`position`,quantity:I(`the valve opening`,`l’apertura della valvola`),label:I(`Valve opening`,`Apertura della valvola`),unit:`%`,icon:`heater`}]}},SP=S([`s`,`min`]),obe=S([`switch`,`pet-fountain`]),CP={actuator:`switch`,maxSeconds:10800,unit:`min`,quickRunDefault:30},wP={actuator:`pet-fountain`,maxSeconds:300,unit:`s`,quickRunDefault:60},TP=[j.Switch,j.PetFountain],EP={[j.Switch]:[N.SwitchHeater]};function DP(e,t){return e===j.PetFountain?wP:e===j.Switch&&t===N.SwitchHeater?CP:null}var sbe=1e3,cbe=6e4;function OP(e,t,n){let r=e-t;return r<=0?0:Math.max(1,Math.ceil(r/(n===`min`?cbe:sbe)))}function lbe(e,t){return t===`min`?e*60:e}function kP(e){return e.unit===`min`?Math.floor(e.maxSeconds/60):e.maxSeconds}var AP=x({duration:p().positive().finite(),unit:SP});function jP(e,t){let n=kP(e);return{duration:Math.min((t!==null&&Number.isFinite(t)&&t>0?t:null)??e.quickRunDefault,n),unit:e.unit}}var MP=S([`unsupported-device`,`over-max`,`command-failed`]),NP=a(`ok`,[x({ok:s(!0),activeUntil:p()}),x({ok:s(!1),reason:MP,maxSeconds:p().nullable()})]),PP=x({activeUntil:p().nullable(),requestedBy:m().nullable(),quickRun:AP.nullable(),lastFetchedAt:p()}),FP=x({unit:SP,maxDuration:p(),defaultDuration:p()}),IP=x({quickRunDuration:p().positive().finite().nullable().optional()}),LP={name:`timed-run`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:TP,deviceRoles:EP,deviceConfig:{ui:{kind:`derived-form`,builderId:`timed-run`,tab:`general`}},methods:{getOptions:E(x({deviceId:p().int()}),FP),setSettings:E(x({deviceId:p().int(),settings:IP}),v(),{kind:`mutation`,auth:`admin`}),runFor:E(x({deviceId:p().int(),duration:p().positive().finite(),unit:SP}),NP,{kind:`mutation`,auth:`protected`,actions:[{id:`timedRun.runForMinutes`,label:I(`Run for minutes`,`Accendi per alcuni minuti`),phrase:I(`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:I(`Minutes`,`Minuti`),offer:{kind:`number`,min:1,step:1,unit:`min`}}]},{id:`timedRun.runForSeconds`,label:I(`Run for seconds`,`Accendi per alcuni secondi`),phrase:I(`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:I(`Seconds`,`Secondi`),offer:{kind:`number`,min:1,step:1,unit:`s`}}]}]}),cancel:E(x({deviceId:p().int()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`timedRun.cancel`,label:I(`Cancel the timer`,`Annulla il timer`),phrase:I(`Cancel the pending switch-off of {device}`,`Annulla lo spegnimento programmato di {device}`),icon:`timer-off`}]})},status:{schema:PP,kind:`push`},runtimeState:PP,durability:`session`,history:`none`,vocabulary:{noun:I(`Timed run`,`Esecuzione a tempo`),order:2150}},RP=[`on`,`off`,`running`,`idle`,`standby`,`alert`,`offline`,`unknown`],zP=[`success`,`warning`,`danger`,`primary`,`info`,`muted`],BP=[`none`,`pulse`,`spin`,`glow`,`halo`,`wave`,`rise`,`fall`,`tumble`,`equalizer`,`blink`,`breathe`],VP=[`plain`,`heat-rise`,`cool-fall`,`glow`,`water`,`drum`,`sky`,`mist`,`alert-wash`],HP=S(RP),UP=S(zP),ube=S(BP),WP=x({icon:Vu,tone:UP,background:S(VP),animation:ube});function GP(e){let t=xE[e];return t===void 0?null:`cap:${e}.${t.field}`}function KP(e){return e.enabledCaps.flatMap(e=>{let t=GP(e),n=xE[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 qP=x({en:m(),it:m()}),JP={en:`—`,it:`—`};function YP(e){return e.en===JP.en&&e.it===JP.it}var XP=[`temperature`,`humidity`,`power`,`contact`,`text`],ZP=[`hot`,`mild`,`cold`],QP=[`updated`,`changed`],$P=x({value:p(),quantity:Qs}),eF=x({quantity:S(XP),reading:$P.nullable(),icon:Vu.nullable(),value:qP,unit:m().nullable(),band:S(ZP).nullable(),level:p().min(0).max(1).nullable(),word:qP,tone:S(zP),since:p().nullable(),sinceKind:S(QP),historyKey:m().nullable()}),dbe=3e3,tF=e=>I(e,e),nF=e=>Math.min(1,Math.max(0,e)),fbe=(e,t)=>String(Number(e.toFixed(t)));function rF(e){return e<12?`cold`:e>28?`hot`:`mild`}var pbe={hot:I(`Hot`,`Caldo`),mild:I(`Normal`,`Normale`),cold:I(`Cold`,`Freddo`)},mbe={hot:`warning`,mild:`muted`,cold:`info`};function iF(e,t){let n=rF(e);return{quantity:`temperature`,reading:{value:e,quantity:`temperature`},icon:`thermometer`,value:tF(fbe(e,1)),unit:`°C`,band:n,level:null,word:pbe[n],tone:mbe[n],since:t,sinceKind:`updated`,historyKey:GP(`temperature-sensor`)}}function aF(e,t){let n=e<30,r=e>70;return{quantity:`humidity`,reading:{value:e,quantity:`humidity`},icon:`droplets`,value:tF(String(Math.round(e))),unit:`%`,band:null,level:nF(e/100),word:n?I(`Dry`,`Secco`):r?I(`Humid`,`Umido`):I(`Normal`,`Normale`),tone:n||r?`warning`:`info`,since:t,sinceKind:`updated`,historyKey:GP(`humidity-sensor`)}}function oF(e,t){let n=e>0;return{quantity:`power`,reading:{value:e,quantity:`power`},icon:`zap`,value:tF(String(Math.round(e))),unit:`W`,band:null,level:nF(e/dbe),word:n?I(`Active`,`Attivo`):I(`Idle`,`Inattivo`),tone:n?`primary`:`muted`,since:t,sinceKind:`updated`,historyKey:GP(`power-meter`)}}function sF(e,t){return{quantity:`contact`,reading:null,icon:e?`door-open`:`door-closed`,value:e?I(`Open`,`Aperto`):I(`Closed`,`Chiuso`),unit:null,band:null,level:+!!e,word:e?I(`Open`,`Aperto`):I(`Closed`,`Chiuso`),tone:e?`warning`:`success`,since:t,sinceKind:`changed`,historyKey:null}}function cF(e,t){return{quantity:`text`,reading:null,icon:null,value:tF(e),unit:null,band:null,level:null,word:I(`Changed`,`Cambiato`),tone:`muted`,since:t,sinceKind:`updated`,historyKey:null}}var hbe={temperature:{icon:`thermometer`,unit:`°C`,sinceKind:`updated`,historyKey:GP(`temperature-sensor`)},humidity:{icon:`droplets`,unit:`%`,sinceKind:`updated`,historyKey:GP(`humidity-sensor`)},power:{icon:`zap`,unit:`W`,sinceKind:`updated`,historyKey:GP(`power-meter`)},contact:{icon:null,unit:null,sinceKind:`changed`,historyKey:null},text:{icon:null,unit:null,sinceKind:`updated`,historyKey:null}};function lF(e){let t=hbe[e];return{quantity:e,reading:null,icon:t.icon,value:JP,unit:t.unit,band:null,level:null,word:JP,tone:`muted`,since:null,sinceKind:t.sinceKind,historyKey:t.historyKey}}var gbe={power:new Set([`energy-sensor`,`voltage-sensor`,`current-sensor`])};function uF(e,t){return t===null?!0:!(gbe[e.quantity]?.has(t)??!1)}var dF=`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(`.`),_be=S(dF),fF=[`cool`,`heat`,`dry`,`fan`,`auto`,`playing`,`paused`,`open`,`closed`],pF=x({id:_be,mode:S(fF).nullable(),level:p().min(0).max(1).nullable()}),mF={[j.Camera]:`camera`,[j.Light]:`light`,[j.Siren]:`siren`,[j.Switch]:`plug`,[j.Sensor]:`sensor-sparkline`,[j.Climate]:`thermostat`,[j.Button]:`button`,[j.EventEmitter]:`event-stream`,[j.Update]:`update`,[j.Generic]:`generic`,[j.Notifier]:`event-stream`,[j.Script]:`event-stream`,[j.Automation]:`event-stream`,[j.Lock]:`lock`,[j.Cover]:`cover`,[j.Valve]:`control-dial`,[j.Humidifier]:`control-dial`,[j.WaterHeater]:`heater`,[j.HeatPump]:`heat-pump`,[j.EnergySystem]:`generic`,[j.Fan]:`fan`,[j.MediaPlayer]:`tv`,[j.AlarmPanel]:`alarm`,[j.Control]:`control-dial`,[j.Presence]:`presence`,[j.Weather]:`weather`,[j.WeatherStation]:`weather`,[j.Vacuum]:`vacuum`,[j.LawnMower]:`lawn-mower`,[j.Container]:`generic`,[j.Image]:`camera`,[j.PetFeeder]:`pet-feeder`,[j.PetFountain]:`pet-fountain`,[j.Dishwasher]:`dishwasher`,[j.Washer]:`washer`,[j.Dryer]:`dryer`,[j.Gateway]:`gateway`},hF={[N.Siren]:`siren`,[N.Floodlight]:`light`,[N.Spotlight]:`light`,[N.PirSensor]:`presence`,[N.Chime]:`speaker`,[N.Autotrack]:`inherit`,[N.Nightvision]:`inherit`,[N.PrivacyMask]:`inherit`,[N.Doorbell]:`inherit`,[N.CoverBlind]:`inherit`,[N.CoverShutter]:`inherit`,[N.CoverAwning]:`inherit`,[N.CoverCurtain]:`inherit`,[N.CoverGarage]:`inherit`,[N.CoverGate]:`inherit`,[N.CoverDoor]:`inherit`,[N.CoverWindow]:`inherit`,[N.BinaryHelper]:`inherit`,[N.Outlet]:`plug`,[N.SwitchHeater]:`heater`,[N.SwitchFan]:`fan`,[N.SwitchLight]:`light`,[N.ClimateAc]:`ac`,[N.ClimateThermostat]:`inherit`,[N.ClimateFloor]:`inherit`,[N.ClimateRadiator]:`inherit`,[N.ClimateHeater]:`inherit`,[N.ClimateHeatPumpCircuit]:`inherit`,[N.MotionSensor]:`presence`,[N.ContactSensor]:`contact`,[N.LeakSensor]:`inherit`,[N.SmokeSensor]:`alarm`,[N.COSensor]:`alarm`,[N.GasSensor]:`alarm`,[N.TamperSensor]:`inherit`,[N.VibrationSensor]:`inherit`,[N.ConnectivitySensor]:`inherit`,[N.SoundSensor]:`inherit`,[N.BinarySensor]:`inherit`,[N.TemperatureSensor]:`sensor-sparkline`,[N.HumiditySensor]:`sensor-sparkline`,[N.AmbientLightSensor]:`inherit`,[N.PressureSensor]:`weather`,[N.WindSensor]:`weather`,[N.RainSensor]:`weather`,[N.UvSensor]:`weather`,[N.SolarRadiationSensor]:`weather`,[N.SoilMoistureSensor]:`inherit`,[N.PowerSensor]:`plug`,[N.EnergySensor]:`plug`,[N.VoltageSensor]:`plug`,[N.CurrentSensor]:`plug`,[N.AirQualitySensor]:`inherit`,[N.BatterySensor]:`inherit`,[N.NumericSensor]:`inherit`,[N.EnumSensor]:`inherit`,[N.DateTimeSensor]:`inherit`,[N.GenericSensor]:`inherit`,[N.NumericControl]:`control-dial`,[N.SelectControl]:`control-dial`,[N.TextControl]:`inherit`,[N.DateTimeControl]:`inherit`,[N.MobilePushNotifier]:`inherit`,[N.MessagingNotifier]:`inherit`,[N.EmailNotifier]:`inherit`,[N.GenericNotifier]:`inherit`,[N.IrTransmitter]:`inherit`};function vbe(e){return Object.values(j).includes(e)}function ybe(e){return Object.values(N).includes(e)}function gF(e,t){let n=e!==null&&ybe(e)?hF[e]:void 0;return n!==void 0&&n!==`inherit`?n:vbe(t)?mF[t]:`generic`}var _F=`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(`.`),vF=S(_F),yF={progress:I(`Progress`,`Avanzamento`),"run-for":I(`Run for`,`Avvia per`),cycle:I(`Cycle`,`Ciclo`),program:I(`Program`,`Programma`),"appliance-power":I(`Appliance`,`Elettrodomestico`),"now-playing":I(`Now playing`,`In riproduzione`),playback:I(`Playback`,`Riproduzione`),volume:I(`Volume`,`Volume`),source:I(`Source`,`Sorgente`),contact:I(`Door`,`Porta`),"motion-trigger":I(`Motion`,`Movimento`),lock:I(`Lock`,`Serratura`),alarm:I(`Alarm`,`Allarme`),fan:I(`Fan`,`Ventola`),vacuum:I(`Cleaning`,`Pulizia`),"vacuum-suction":I(`Suction`,`Aspirazione`),mower:I(`Mowing`,`Taglio`),feeder:I(`Feed now`,`Eroga ora`),fountain:I(`Pump`,`Pompa`),"pump-cycle":I(`Pump cycle`,`Ciclo pompa`),automation:I(`Automation`,`Automazione`),script:I(`Script`,`Script`),"do-not-disturb":I(`Do not disturb`,`Non disturbare`),brightness:I(`Brightness`,`Luminosità`),color:I(`Colour`,`Colore`),cover:I(`Position`,`Posizione`),valve:I(`Valve`,`Valvola`),humidifier:I(`Humidifier`,`Umidificatore`),update:I(`Firmware`,`Firmware`),button:I(`Action`,`Azione`),"climate-mode":I(`Mode`,`Modalità`),"climate-fan":I(`Fan`,`Ventola`),setpoint:I(`Setpoint`,`Temperatura`),channel:I(`Channel`,`Canale`),control:I(`Control`,`Controllo`),circuit:I(`Circuit`,`Circuito`),"heat-pump-power":I(`Power`,`Potenza`),"system-mode":I(`Mode`,`Modalità`)},bF=_(()=>l([m(),p(),y(),d(m(),bF)])),bbe=d(m(),bF);function xF(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]:xF(o,i,n)}}function SF(e,t,n){return xF(e,t.split(`.`),n)}var CF=x({cap:m(),method:m(),args:bbe}),xbe=S([`off-while-running`,`unlock`,`install`,`press`]),wF=x({id:m(),label:qP,icon:Vu,call:CF,emphasis:S([`primary`,`normal`]),confirm:xbe.nullable()}),TF=a(`kind`,[x({kind:s(`action`),action:wF}),x({kind:s(`toggle`),id:m(),label:qP,on:y().nullable(),turnOn:wF,turnOff:wF}),x({kind:s(`slider`),id:m(),label:qP,value:p().nullable(),min:p(),max:p(),step:p(),unit:m(),call:CF,valueArg:m()}),x({kind:s(`picker`),id:m(),label:qP,current:m().nullable(),options:C(m()),optionLabels:d(m(),qP).optional(),call:CF,valueArg:m()}),x({kind:s(`number`),id:m(),label:qP,value:p().nullable(),step:p().nullable(),unit:m(),call:CF,valueArg:m()}),x({kind:s(`text`),id:m(),label:qP,value:m().nullable(),call:CF,valueArg:m()})]),Sbe=x({icon:Vu.nullable(),text:qP,tone:UP}),Cbe=new Set([`cover`,`valve`,`lock`,`vacuum`,`playback`,`brightness`]),wbe=x({id:vF,placement:S([`row`,`scene`]).optional(),label:qP.optional(),group:qP.optional(),pills:C(Sbe).optional(),icon:Vu,status:qP.nullable(),controls:C(TF),progress:p().min(0).max(1).nullable().optional()}),EF=x({label:qP,value:l([p(),m()]),unit:m().nullable()}),Tbe=x({id:S([`battery`,`network-link`,`integration`]),icon:Vu,tone:UP,value:p().nullable(),label:qP}),DF=`remote.open`,Ebe=x({commands:p().int().nullable(),open:wF.optional()}),Dbe=x({items:C(x({key:m(),label:m(),level:p().nullable(),needsAttention:y()})),attention:p().int()}),Obe=a(`kind`,[x({kind:s(`power`),watts:p(),detail:C(EF)}),x({kind:s(`running`),running:y().nullable(),since:p().nullable(),phase:m().nullable(),detail:C(EF)})]),kbe=x({source:S([`switch`,`media-player`,`climate-control`]),on:y().nullable(),assumed:y(),turnOn:wF,turnOff:wF}),Abe=x({activeUntil:p().nullable(),quickRun:AP,run:wF,cancel:wF,remaining:p().nullable()}),jbe=x({on:y().nullable(),confirmOffWhileRunning:y(),running:y().nullable(),powerOn:wF,powerOff:wF,restart:wF}),OF=x({token:S(VP),animation:S(BP)}),kF=x({id:S([`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:Vu.nullable(),text:qP,tone:UP}),AF=x({label:qP,value:qP,tone:UP.optional(),at:p().optional()}),Mbe=x({left:C(AF).max(2),right:C(AF).max(2)}),Nbe=a(`kind`,[x({kind:s(`artwork`),url:m(),fallback:OF}),x({kind:s(`state`),...OF.shape})]),Pbe=x({partId:m(),cap:m()}),Fbe=x({deviceId:p().int(),type:m(),role:m().nullable(),name:m(),state:HP,stateAssumed:y(),look:WP,background:Nbe,scene:pF,facts:C(kF),sideTiles:Mbe,title:qP,caption:qP.optional(),badges:C(Tbe),remote:Ebe.nullable(),historyLabel:qP,consumables:Dbe.nullable(),consumption:Obe.nullable(),ownPower:kbe.nullable(),timedRun:Abe.nullable(),powerSupply:jbe.nullable(),rows:C(wbe),measurement:eF.optional(),gated:C(m()),provenance:C(Pbe)}),Ibe=x({id:S([`timed-run.run`,`timed-run.cancel`]),duration:p(),unit:S([`min`,`s`])}),jF=x({deviceId:p().int(),name:m(),type:m(),state:HP,stateAssumed:y(),look:WP,scene:pF,statusLine:C(qP),primary:TF.nullable(),primaryGated:y().optional(),timedRun:Ibe.nullable(),extras:C(TF).max(2).optional(),trailing:kF.nullable(),measurement:eF.optional()}),MF=[`temperature`,`humidity`,`pressure`,`illuminance`,`reading`,`air-quality`,`valve`],Lbe=[`power`,`battery`,`consumables`],Rbe=new Set(MF);function zbe(e){for(let t of Lbe){let n=e.facts.find(e=>e.id===t);if(n!==void 0)return n}return e.facts.find(t=>Rbe.has(t.id)&&t.text.en===e.title.en)??null}var Bbe={[j.Climate]:`climate.mode`};function Vbe(e){let t=Bbe[e.type];if(t!==void 0){let n=PF(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 Hbe={[j.Climate]:[`climate.target`],[j.Vacuum]:[`vacuum.base`],[j.LawnMower]:[`mower.dock`],[j.MediaPlayer]:[`volume.level`,DF],[j.Automation]:[`automation.enabled`]},NF=e=>e.kind===`action`?e.action.id:e.id;function PF(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=>NF(e)===t);if(r!==void 0)return r}return null}function Ube(e,t){let n=Hbe[e.type]??[],r=t===null?null:NF(t);return n.filter(e=>e!==r).flatMap(t=>{let n=PF(e,t);return n===null?[]:[n]}).slice(0,2)}function Wbe(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 Gbe(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 Kbe(e){let t=zbe(e),{control:n,gated:r}=Vbe(e);return{deviceId:e.deviceId,name:e.name,type:e.type,state:e.state,stateAssumed:e.stateAssumed,look:e.look,scene:e.scene,statusLine:Wbe(e,t),primary:n,primaryGated:r,timedRun:Gbe(e),extras:Ube(e,n),trailing:t,...e.measurement===void 0?{}:{measurement:e.measurement}}}var qbe=x({deviceId:p().int().nonnegative(),canActuate:y().optional()}),Jbe=x({deviceIds:C(p().int().nonnegative()).max(500),canActuate:y().optional()}),FF=x({type:m(),rows:C(vF)}),IF={name:`hero-layout`,scope:`system`,mode:`singleton`,methods:{getHeroModel:E(qbe,Fbe.nullable(),{auth:`protected`,role:`viewer`}),getRowModels:E(Jbe,C(jF.nullable()),{auth:`protected`,role:`viewer`}),getLayout:E(x({deviceType:m(),role:m().nullable().optional()}),FF,{auth:`protected`,role:`viewer`})},vocabulary:{notOperatorFacing:`the device hero model — read-only data the UI draws, never actuated`}},LF=x({on:y(),currentHumidity:p().min(0).max(100).nullable().meta(k(`humidity`)),targetHumidity:p().min(0).max(100).nullable().meta(k(`humidity`)),mode:m().nullable(),availableModes:C(m()),action:m().nullable(),minHumidity:p().nullable().meta(k(`humidity`)),maxHumidity:p().nullable().meta(k(`humidity`)),lastChangedAt:p()}),RF={name:`humidifier`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Humidifier],power:{kind:`field`,field:`on`,set:`setOn`},methods:{setOn:E(x({deviceId:p().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.on`,label:I(`Humidifier on`,`Umidificatore acceso`),phrase:I(`Turn on {device}`,`Accendi {device}`),icon:`power`,effect:{field:`on`,value:!0},args:{on:!0}},{id:`humidifier.off`,label:I(`Humidifier off`,`Umidificatore spento`),phrase:I(`Turn off {device}`,`Spegni {device}`),icon:`power-off`,effect:{field:`on`,value:!1},args:{on:!1}}]}),setTargetHumidity:E(x({deviceId:p().int().nonnegative(),humidity:p().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.target`,label:I(`Set humidity`,`Imposta l’umidità`),phrase:I(`Set {device} to {humidity} humidity`,`Imposta {device} al {humidity} di umidità`),icon:`droplets`,effect:{field:`targetHumidity`,fromArg:`humidity`},openArgs:[{key:`humidity`,label:I(`Humidity`,`Umidità`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setMode:E(x({deviceId:p().int().nonnegative(),mode:m().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.mode`,label:I(`Set mode`,`Imposta la modalità`),phrase:I(`Set {device} to {mode}`,`Imposta {device} su {mode}`),icon:`list`,effect:{field:`mode`,fromArg:`mode`},openArgs:[{key:`mode`,label:I(`Mode`,`Modalità`),offer:{kind:`dynamic`,from:`status`,field:`availableModes`}}]}]})},status:{schema:LF,kind:`push`},runtimeState:LF,durability:`session`,history:{fields:{currentHumidity:{kind:`gauge`,unit:`%`,deadband:.5},on:{kind:`boolean`}}},vocabulary:{noun:I(`Humidifier`,`Umidificatore`),order:1090,state:[{kind:`boolean`,field:`on`,label:I(`On`,`Acceso`),whenTrue:I(`When {device} turns on`,`Quando {device} si accende`),whenFalse:I(`When {device} turns off`,`Quando {device} si spegne`),icon:`power`},{kind:`numeric`,field:`currentHumidity`,quantity:I(`the humidity`,`l’umidità`),label:I(`Humidity`,`Umidità`),unit:`%`,icon:`droplets`}]}},zF=x({humidity:p().min(0).max(100).nullable().meta(k(`humidity`,{precision:0,label:`Humidity`})),lastFetchedAt:p()}),BF={name:`humidity-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor,j.Climate],methods:{},status:{schema:zF,kind:`push`},runtimeState:zF,durability:`restored`,history:{primary:`humidity`,priority:90,fields:{humidity:{kind:`gauge`,unit:`%`,deadband:.5}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`Humidity`,`Umidità`),order:5120,state:[{kind:`numeric`,field:`humidity`,quantity:I(`the humidity`,`l’umidità`),label:I(`Humidity`,`Umidità`),unit:`%`,icon:`droplets`}]}},VF=x({url:m().nullable(),lastUpdated:p().nullable().meta(k(`none`))}),HF={name:`image`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Image],methods:{},status:{schema:VF,kind:`push`},runtimeState:VF,durability:`session`,history:`none`,vocabulary:{noun:I(`Image`,`Immagine`),order:3130}},UF=S([`0`,`90`,`180`,`270`]),WF=S([`auto`,`manual`]),GF=S([`auto`,`manual`]),KF=S([`off`,`blc`,`wdr`,`hlc`]),qF=x({min:p(),max:p(),step:p()}),JF=x({brightness:p().optional().meta(k(`none`)),contrast:p().optional().meta(k(`none`)),saturation:p().optional().meta(k(`none`)),sharpness:p().optional().meta(k(`none`)),mirror:y().optional(),flip:y().optional(),rotate:UF.optional(),whiteBalance:WF.optional(),warmth:p().optional().meta(k(`none`)),exposureMode:GF.optional(),backlightMode:KF.optional(),lastFetchedAt:p()}),YF=x({supportsBrightness:y(),brightness:qF.optional(),supportsContrast:y(),contrast:qF.optional(),supportsSaturation:y(),saturation:qF.optional(),supportsSharpness:y(),sharpness:qF.optional(),supportsMirror:y(),supportsFlip:y(),rotateOptions:C(UF),whiteBalanceModes:C(WF),supportsWarmth:y(),warmth:qF.optional(),exposureModes:C(GF),backlightModes:C(KF)}),XF=x({brightness:p().optional(),contrast:p().optional(),saturation:p().optional(),sharpness:p().optional(),mirror:y().optional(),flip:y().optional(),rotate:UF.optional(),whiteBalance:WF.optional(),warmth:p().optional(),exposureMode:GF.optional(),backlightMode:KF.optional()}),ZF={name:`image-settings`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],deviceConfig:{ui:{kind:`derived-form`,builderId:`image-settings`,tab:`image`}},methods:{getOptions:E(x({deviceId:p()}),YF),setSettings:E(x({deviceId:p(),settings:XF}),v(),{kind:`mutation`,auth:`admin`})},status:{schema:JF,kind:`poll`},runtimeState:JF,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`Image settings`,`Impostazioni immagine`),order:3140}},QF=x({id:m(),addonId:m(),name:m(),enabled:y(),switchUnknown:s(!0).optional(),info:d(m(),u()).readonly(),originStableId:m().optional(),createdAt:p(),updatedAt:p(),processState:m()}),$F=x({id:m(),addonId:m(),name:m(),enabled:y(),switchUnknown:s(!0).optional(),info:d(m(),u()).readonly(),originStableId:m().optional(),createdAt:p(),updatedAt:p()}),eI=x({addonId:m(),name:m(),providerLabel:m().optional(),description:m(),iconUrl:m().nullable(),color:m(),instanceMode:m(),mode:S([`standalone`,`account`,`broker`]),discoveryMode:m(),kind:S([`device-adoption`,`device-provider`]),brokerKind:m().nullable(),supportsLocationImport:y(),canTest:y(),existingInstances:C(x({id:m(),name:m()})),canAdd:y()}),tI=S([`validated`,`rejected`,`inconclusive`,`unsupported`]),nI=x({success:y(),error:m().optional(),status:tI.optional(),testedBy:m().nullable().optional(),latencyMs:p().nonnegative().optional(),detail:m().optional()}),rI=x({id:m(),name:m().optional(),enabled:y().optional(),info:d(m(),u()).optional()}),iI=x({success:y(),deletedId:m()}),aI={name:`integrations`,scope:`system`,mode:`singleton`,methods:{list:E(v(),C(QF)),get:E(x({id:m()}),QF),getByAddonId:E(x({addonId:m()}),$F.nullable()),update:E(rI,$F,{kind:`mutation`,auth:`admin`}),delete:E(x({id:m()}),iI,{kind:`mutation`,auth:`admin`}),getAvailableTypes:E(v(),C(eI),{auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:O.ADDON_ADMIN}},Ybe=_e(),oI=m().min(1),sI=S([`single`,`multiple`]),cI=S([`devices`,`services`]),lI=x({id:m().min(1),label:m().min(1),functionCap:m().min(1),brokerKind:m().min(1).optional(),alsoServes:C(m().min(1)).optional(),iconUrl:m().min(1).optional(),iconMediaType:m().min(1).optional(),role:cI.optional(),canTest:y().optional(),signIn:x({basePath:m().min(1),methods:C(S([`device-code`,`proxy`])).optional()}).optional(),connectPath:m().min(1).optional(),disconnectPath:m().min(1).optional(),widgets:C(x({id:m().min(1),placement:S([`connection`,`model`])})).optional()}),uI=x({mode:S([`none`,`lan`,`account`]),scopedToInstance:y()}),dI=x({kind:m().min(1),field:m().min(1),to:x({cap:m().min(1),kind:m().min(1).optional()})}),fI=x({role:cI,discovery:uI.optional(),instanceMode:sI,kind:m(),canTest:y(),kinds:C(lI).min(1),allowRestoreId:y().optional(),mintsId:y().optional(),links:C(dI).optional(),userScoped:y().optional()}),pI=x({state:S([`ok`,`off`,`error`,`unknown`]),detail:m().optional(),label:m().optional()}),mI=x({id:oI,name:m(),configured:y(),enabled:y().optional(),kind:m().min(1),formValues:d(m(),u()),status:pI.optional(),lastCheckedAt:p().optional()}),hI=x({id:oI,name:m().min(1).optional(),values:d(m(),u())}),gI={name:`integration-instances`,scope:`system`,mode:`collection`,methods:{describe:E(v(),fI,{auth:`admin`}),instanceFormSchema:E(x({id:oI.nullable(),kind:m().min(1).optional(),mode:S([`standalone`,`account`,`broker`]).optional(),candidateStableId:m().min(1).optional()}),Ybe,{auth:`admin`}),listInstances:E(o({}),C(mI).readonly(),{auth:`protected`,caller:`scoped`}),getInstance:E(x({id:oI}),mI.nullable(),{auth:`protected`,caller:`scoped`}),createInstance:E(x({id:oI.optional(),name:m().min(1),kind:m().min(1).optional(),values:d(m(),u()).optional(),originStableId:m().min(1).optional(),seed:x({info:d(m(),u())}).optional()}),x({id:m()}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),updateInstance:E(hI,x({ok:s(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),setInstanceEnabled:E(x({id:oI,enabled:y()}),x({ok:s(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),deleteInstance:E(x({id:oI}),x({ok:s(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),testInstance:D(x({id:oI.nullable(),values:d(m(),u()),kind:m().min(1).optional()}),nI,{kind:`mutation`,auth:`protected`,caller:`scoped`})},vocabulary:{notOperatorFacing:O.INTERNAL}},_I=x({codecs:C(m()),sampleRate:p().meta(k(`none`)),duplex:S([`half`,`full`]),maxBacklogMs:p().meta(k(`duration-ms`))}),vI=x({talking:y(),lastSessionAt:p().nullable(),ability:_I.nullable()}),Xbe=S([`opus`,`s16le`,`g711ulaw`,`g711alaw`]),yI={name:`intercom`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],methods:{startSession:E(x({deviceId:p()}),x({sessionId:m(),sdpOffer:m()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),handleAnswer:E(x({deviceId:p(),sessionId:m(),sdpAnswer:m()}),v(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),stopSession:E(x({deviceId:p(),sessionId:m()}),v(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),startTalkSession:E(x({deviceId:p()}),x({sessionId:m()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`two-way talk is a person speaking through the viewer, not an automation step`}),pushTalkAudio:E(x({deviceId:p(),audioBase64:m(),codec:Xbe.optional(),sampleRate:p().int().positive().optional(),channels:p().int().positive().optional(),sequenceNumber:p().int()}),x({accepted:y()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),endTalkSession:E(x({deviceId:p()}),v(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`})},events:{onStatusChanged:{data:x({deviceId:p(),status:vI}),notOperatorFacing:"the `talking` state trigger phrases both edges of this change"}},status:{schema:vI,kind:`command-driven`},runtimeState:vI,durability:`session`,history:`none`,vocabulary:{noun:I(`Intercom`,`Citofono`),order:3150,state:[{kind:`boolean`,field:`talking`,label:I(`Talking`,`In conversazione`),whenTrue:I(`When someone starts talking through {device}`,`Quando qualcuno inizia a parlare tramite {device}`),whenFalse:I(`When the conversation on {device} ends`,`Quando la conversazione su {device} finisce`),icon:`mic`}]}},bI=S([`carrierHz`,`dutyCyclePercent`,`repeat`,`repeatDelayMs`]),xI=S([`ir`,`rf`]),SI=x({ok:s(!0),ignoredSettings:C(m())}),CI=x({media:C(xI),settable:C(bI),maxTimings:p().int().positive(),learn:y().default(!1),formats:C(Jw).default([])}),wI=2e4,TI=6e4,EI=x({native:Xw.nullable(),timings:zw,carrierHz:p().int().positive().nullable()}),DI=x({at:p(),ok:y(),error:m().nullable()}),OI=DI.extend({medium:xI}),kI=x({lastSend:OI.nullable(),lastLearn:DI.nullable(),lastFetchedAt:p()});function AI(e){return!(e.kind===`learn`&&e.error===`ir-transmitter.learn-unsupported`)}function Zbe(e,t,n){let r=e??{lastSend:null,lastLearn:null,lastFetchedAt:n};return AI(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 Qbe(e){return Qr(e)?.code??null}var jI={name:`ir-transmitter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Generic],methods:{send:E(x({deviceId:p().int().nonnegative(),timings:zw.optional(),native:Xw.optional(),settings:Bw.optional()}).refine(e=>e.timings===void 0!=(e.native===void 0),{message:`send takes exactly one of timings or native`}),SI,{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:E(x({deviceId:p().int().nonnegative(),timeoutMs:p().int().positive().max(TI).default(wI)}),EI,{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:E(x({deviceId:p().int().nonnegative()}),CI,{kind:`query`,auth:`protected`})},runtimeState:kI,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`IR / RF transmitter`,`Trasmettitore IR / RF`),order:1140}},MI=S([`key-missing`,`wrong-key`,`key-file-unreadable`,`store-unavailable`,`not-initialized`,`decrypt-failed`]),NI=a(`state`,[x({state:s(`ready`)}),x({state:s(`locked`),reason:MI})]),PI=a(`kind`,[x({kind:s(`value`),value:m(),version:p().int()}),x({kind:s(`missing`)}),x({kind:s(`unavailable`),reason:MI}),x({kind:s(`forbidden`)})]),FI=d(m(),PI),II=x({ref:m(),owner:m(),scope:m(),fieldPath:m(),version:p().int(),createdAt:p(),updatedAt:p(),updatedBy:m(),lastReadAt:p().nullable()}),LI=C(m().min(1)).max(512),RI={name:`keychain`,scope:`system`,mode:`singleton`,internal:!0,methods:{put:E(x({ref:m().min(1),value:m().min(1)}),x({ref:m(),version:p().int()}),{kind:`mutation`,auth:`admin`}),resolve:E(x({refs:LI}),FI,{auth:`admin`}),delete:E(x({refs:LI}),x({deleted:p().int()}),{kind:`mutation`,auth:`admin`}),deleteDeviceScope:E(x({deviceId:p().int()}),x({refs:C(m()).readonly()}),{kind:`mutation`,auth:`admin`}),releaseRecordRefs:E(x({refs:LI,onBehalfOf:m().min(1)}),x({released:p().int()}),{kind:`mutation`,auth:`admin`}),listMeta:E(x({}),C(II).readonly(),{auth:`admin`}),getState:E(x({}),NI,{auth:`admin`})},vocabulary:{notOperatorFacing:O.IDENTITY}},zI=S([`mounted-file`,`previous-mounted-file`,`platform`,`default-file`]),BI=x({kind:zI,path:m().optional(),sharesBackupWithDatabase:y()}),VI=`trigger-file`,HI=x({id:m(),at:p(),actor:m(),lockedReason:m().nullable(),archived:p().int(),archivedCollection:m().nullable(),archivedKeysCollection:m().nullable(),clearedSettingsKeys:C(m()).readonly(),acknowledgedAt:p().nullable()}),UI=x({keychain:NI,keySource:BI.nullable(),configuredSource:BI,fingerprint:m().nullable(),activeKeyId:m().nullable(),rotationPending:y(),retiredWraps:p().int(),recoveryKeyDownloadedAt:p().nullable(),secretCount:p().int(),lastReset:HI.nullable()}),WI=S([`in-use`,`orphan`,`unknown`]),GI=II.extend({usage:WI}),KI=S([`put`,`delete`,`reveal`,`rotate-master-key`,`purge-retired-keys`,`download-recovery-key`,`delete-orphans`,`reset`,`acknowledge-reset`,`initialize`]),qI=x({id:m(),at:p(),action:KI,actor:m(),ref:m().nullable(),detail:m().nullable()}),JI=`RESET KEYCHAIN`,YI=S([`jwt-signing-key`]),XI={name:`keychain-admin`,scope:`system`,mode:`singleton`,methods:{status:E(x({}),UI,{auth:`admin`}),listSecrets:E(x({}),C(GI).readonly(),{auth:`admin`}),listAudit:E(x({limit:p().int().min(1).max(500).optional()}),C(qI).readonly(),{auth:`admin`}),reveal:E(x({ref:m().min(1)}),x({value:m(),version:p().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),setSystemSecret:E(x({name:YI,value:m().min(16)}),x({ref:m(),version:p().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),importSecret:E(x({ref:m().min(1),value:m().min(1)}),x({ref:m(),version:p().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),deleteOrphans:E(x({refs:C(m().min(1)).max(1e3)}),x({deleted:C(m()).readonly(),kept:C(x({ref:m(),usage:WI})).readonly()}),{kind:`mutation`,auth:`admin`,caller:`required`}),rotateMasterKey:E(x({}),x({fingerprint:m(),keySource:BI}),{kind:`mutation`,auth:`admin`,caller:`required`}),purgeRetiredKeys:E(x({}),x({purged:p().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),downloadRecoveryKey:E(x({}),x({key:m(),fingerprint:m(),keySource:BI}),{kind:`mutation`,auth:`admin`,caller:`required`}),resetKeychain:E(x({confirm:s(JI)}),x({archivedCollection:m().nullable(),archived:p().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),resetReport:E(x({}),x({reset:HI.nullable(),pendingReentry:C(II).readonly()}),{auth:`admin`}),acknowledgeReset:E(x({}),x({acknowledged:y()}),{kind:`mutation`,auth:`admin`,caller:`required`})},vocabulary:{notOperatorFacing:O.IDENTITY}},ZI=S([`idle`,`mowing`,`paused`,`docked`,`error`]),QI=S([`info`,`warning`,`error`]),$I=x({activity:ZI,batteryLevel:p().min(0).max(100).nullable().meta(k(`percentage`)),progress:p().min(0).max(100).nullable().meta(k(`percentage`)),currentCode:p().nullable().meta(k(`none`)),currentCodeLabel:m().nullable(),severity:QI,lastChangedAt:p()}),eL={name:`lawn-mower-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.LawnMower],methods:{startMowing:E(x({deviceId:p().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.start`,label:I(`Start mowing`,`Avvia il taglio`),phrase:I(`Start {device} mowing`,`Fai partire il taglio di {device}`),icon:`play`}]}),pause:E(x({deviceId:p().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.pause`,label:I(`Pause mower`,`Metti in pausa il tosaerba`),phrase:I(`Pause {device}`,`Metti in pausa {device}`),icon:`pause`}]}),dock:E(x({deviceId:p().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.dock`,label:I(`Dock mower`,`Riporta alla base`),phrase:I(`Send {device} back to its dock`,`Rimanda {device} alla base`),icon:`house`}]})},status:{schema:$I,kind:`push`},runtimeState:$I,durability:`session`,history:{fields:{batteryLevel:{kind:`gauge`,unit:`%`,deadband:2}}},vocabulary:{noun:I(`Robot mower`,`Robot tosaerba`),order:2010,state:[{kind:`enum`,field:`activity`,label:I(`Activity`,`Attività`),values:[{value:`idle`,label:I(`Idle`,`Inattivo`)},{value:`mowing`,label:I(`Mowing`,`In taglio`),phrase:I(`When {device} starts mowing`,`Quando {device} inizia a tagliare`)},{value:`paused`,label:I(`Paused`,`In pausa`)},{value:`docked`,label:I(`Docked`,`Alla base`),phrase:I(`When {device} docks`,`Quando {device} arriva alla base`)},{value:`error`,label:I(`Error`,`Errore`),phrase:I(`When {device} reports an error`,`Quando {device} segnala un errore`)}],icon:`bot`},{kind:`numeric`,field:`batteryLevel`,quantity:I(`the battery level`,`il livello della batteria`),label:I(`Battery`,`Batteria`),unit:`%`,icon:`battery`}]}},tL=6e5,$be=60*6e4,nL=x({inputTokens:p(),outputTokens:p()}),rL=S([`timeout`,`rate-limited`,`auth`,`refusal`,`bad-request`,`unavailable`,`no-profile`,`budget-exceeded`,`adapter-error`]),iL=x({ok:s(!0),text:m(),model:m(),usage:nL,truncated:y(),latencyMs:p()}),aL=S([`guardrail`,`model`]),oL=x({ok:s(!1),code:rL,message:m(),retryAfterMs:p().optional(),refusalSource:aL.optional()}),sL=a(`ok`,[iL,oL]),cL=x({bytes:b(Uint8Array),mimeType:m()}),lL=x({enabled:y().default(!1),maxAttempts:p().int().min(1).max(5).default(1)}),exe={totalMs:6e4,connectMs:1e4,firstTokenMs:12e4,idleMs:6e4},uL=x({addonId:m().optional(),profileId:m().optional(),consumer:m(),system:m().optional(),prompt:m(),jsonSchema:d(m(),u()).optional(),maxTokens:p().int().positive().optional(),temperature:p().optional(),topP:p().min(0).max(1).optional(),topK:p().int().positive().optional(),reasoningEffort:S([`off`,`low`,`medium`,`high`]).optional(),timeoutMs:p().int().positive().optional(),retry:lL.optional(),requestId:m().optional()}),dL=x({url:m(),filename:m(),sizeBytes:p(),sha256:m().optional()}),fL=a(`kind`,[x({kind:s(`catalog`),catalogId:m()}),x({kind:s(`url`),url:m(),sha256:m().optional(),label:m().optional(),sizeBytes:p().optional(),extraFiles:C(dL).optional()}),x({kind:s(`path`),path:m()})]),pL=x({nodeId:m(),engine:S([`llama-cpp`]),model:fL,contextSize:p().int().default(4096),gpuLayers:p().int().default(0),threads:p().int().optional(),parallel:p().int().default(1),batchSize:p().int().positive().optional(),ubatchSize:p().int().positive().optional(),flashAttention:y().default(!1),mlock:y().default(!1),noMmap:y().default(!1),cacheTypeK:S([`f32`,`f16`,`q8_0`,`q5_1`,`q5_0`,`q4_1`,`q4_0`]).optional(),cacheTypeV:S([`f32`,`f16`,`q8_0`,`q5_1`,`q5_0`,`q4_1`,`q4_0`]).optional(),extraArgs:C(m()).default([]),autoStart:y().default(!1),idleStopMinutes:p().int().default(30)}),mL=x({phase:S([`downloading`,`verifying`]),file:m(),fileIndex:p().int(),fileCount:p().int(),downloadedBytes:p(),totalBytes:p().optional()}),hL=x({nodeId:m(),state:S([`stopped`,`downloading`,`starting`,`ready`,`crashed`,`failed`]),pid:p().optional(),port:p().optional(),modelPath:m().optional(),modelId:m().optional(),downloadProgress:p().min(0).max(1).optional(),download:mL.optional(),lastError:m().optional(),crashesInWindow:p(),memoryBytes:p().optional(),vramBytes:p().optional()}),gL=x({file:m(),sizeBytes:p(),catalogId:m().optional(),installedAt:p().optional(),path:m().optional()}),_L=x({nodeId:m(),modelsBytes:p(),freeBytes:p().optional()}),vL=uL.extend({images:C(cL).optional(),runtime:pL,timeoutMs:p().int().positive().optional()}),yL=S([`deviceNotEligible`,`appleIntelligenceNotEnabled`,`modelNotReady`,`osTooOld`,`helperMissing`,`helperCrashed`]),bL=a(`state`,[x({state:s(`available`),osVersion:m(),contextSize:p().int().positive(),languages:C(m()),imageInput:y()}),x({state:s(`unavailable`),reason:yL,osVersion:m().nullable(),detail:m()}),x({state:s(`unsupported-platform`),platform:m()}),x({state:s(`unknown`),error:m()})]),xL=uL.extend({images:C(cL).optional(),timeoutMs:p().int().positive().optional()}),SL=x({requestId:m()}),CL={name:`llm-runtime`,scope:`system`,mode:`singleton`,internal:!0,methods:{complete:E(vL,sL,{kind:`mutation`,auth:`admin`,timeoutMs:tL}),ensureStarted:E(x({runtime:pL}),hL,{kind:`mutation`,auth:`admin`,timeoutMs:tL}),stop:E(x({}),v(),{kind:`mutation`,auth:`admin`}),status:E(x({}),hL,{auth:`admin`}),installModel:E(x({model:fL}),v(),{kind:`mutation`,auth:`admin`,timeoutMs:$be}),deleteModel:E(x({file:m()}),v(),{kind:`mutation`,auth:`admin`}),listLocalModels:E(x({}),C(gL),{auth:`admin`}),getDiskUsage:E(x({}),_L,{auth:`admin`}),cancel:E(SL,v(),{kind:`mutation`,auth:`admin`}),appleAvailability:E(x({}),bL,{auth:`admin`}),completeApple:E(xL,sL,{kind:`mutation`,auth:`admin`,timeoutMs:tL})},vocabulary:{notOperatorFacing:O.ML}},wL=/^[a-z0-9][a-z0-9-]{0,63}$/,TL=m().regex(wL,`a kind id is lower-case letters, digits and dashes`),EL=x({vision:y(),tools:y(),streaming:y(),reasoning:y().nullable().optional()}),DL=x({id:m(),label:m().optional(),contextLength:p().int().positive().optional(),features:EL.partial().optional()}),OL=d(m(),u()),txe=x({id:m(),name:m(),kind:TL,addonId:m(),enabled:y(),model:m(),supportsVision:y(),temperature:p().min(0).max(2).optional(),topP:p().min(0).max(1).optional(),topK:p().int().positive().optional(),maxTokens:p().int().positive().optional(),reasoningEffort:S([`off`,`low`,`medium`,`high`]).optional(),contextLength:p().int().positive().optional(),systemPrompt:m().optional(),timeoutMs:p().int().positive().default(6e4),connectTimeoutMs:p().int().positive().default(1e4),firstTokenTimeoutMs:p().int().positive().default(12e4),idleTimeoutMs:p().int().positive().default(6e4),retry:lL.default({enabled:!1,maxAttempts:1}),toolsEnabled:y().default(!1),providerConfig:OL.default({})}),kL=S([`temperature`,`topP`,`topK`,`maxTokens`,`reasoningEffort`,`contextLength`,`systemPrompt`,`timeoutMs`,`connectTimeoutMs`,`firstTokenTimeoutMs`,`idleTimeoutMs`,`retry`,`toolsEnabled`]),AL=x({id:m(),placement:S([`connection`,`model`]),requires:C(m()).optional()}),jL=u(),nxe=x({kind:TL,label:m(),icon:m(),addonId:m(),connectionSchema:jL,advancedSchema:jL.optional(),features:EL,visionEditable:y(),modelCatalog:S([`fetch`,`static`,`none`]),staticModels:C(DL).optional(),profileFields:C(kL),providerWidgets:C(AL).optional()}),ML=x({addonId:m(),kind:TL,profileId:m().optional(),connection:OL.optional()}),NL=S([`auth`,`network`,`unsupported`,`invalid`]),PL=a(`ok`,[x({ok:s(!0),models:C(DL)}),x({ok:s(!1),code:NL,message:m()})]),FL=l([x({consumer:m()}),x({purpose:S([`text`,`vision`])})]),IL=x({selector:FL,profileId:m()}),LL=x({day:m(),consumer:m(),profileId:m(),calls:p(),okCalls:p(),errorCalls:p(),inputTokens:p(),outputTokens:p(),avgLatencyMs:p()}),RL=x({id:m(),label:m(),family:m(),purpose:S([`text`,`vision`]),url:m(),sha256:m(),sizeBytes:p(),quantization:m(),minRamBytes:p(),contextSizeDefault:p().int(),mmprojUrl:m().optional()}),zL=a(`ok`,[x({ok:s(!0),model:fL,label:m(),repo:m(),quantization:m(),purpose:S([`text`,`vision`]),totalBytes:p(),extraFilenames:C(m())}),x({ok:s(!1),code:m(),message:m(),candidates:C(m()).optional(),requiredBytes:p().optional()})]),BL=x({nodeId:m(),reachable:y(),status:hL.optional(),disk:_L.optional(),error:m().optional(),apple:bL.optional()}),rxe=uL.extend({images:C(cL).min(1)}),VL=x({addonId:m(),profileId:m()}),HL={name:`llm`,scope:`system`,mode:`collection`,internal:!1,providerKind:`ai`,nodeIdMode:`data`,methods:{generate:E(uL,sL,{kind:`mutation`,timeoutMs:tL}),generateVision:E(rxe,sL,{kind:`mutation`,timeoutMs:tL}),cancel:E(x({addonId:m().optional(),requestId:m()}),v(),{kind:`mutation`}),listModels:E(ML,PL,{kind:`mutation`,auth:`admin`}),getDefaults:E(x({}),C(IL)),setDefault:E(x({selector:FL,profileId:m().nullable()}),v(),{kind:`mutation`,auth:`admin`}),getUsage:E(x({since:p().optional(),until:p().optional(),consumer:m().optional(),profileId:m().optional()}),C(LL)),listModelCatalog:E(x({}),C(RL)),listRuntimeNodes:E(x({}),C(BL)),listNodeModels:E(x({nodeId:m()}),C(gL)),resolveModelRef:E(x({ref:m(),maxBytes:p().positive().optional()}),zL,{kind:`mutation`,auth:`admin`}),installModel:E(x({nodeId:m(),model:fL}),v(),{kind:`mutation`,auth:`admin`}),deleteModel:E(x({nodeId:m(),file:m()}),v(),{kind:`mutation`,auth:`admin`}),getRuntimeStatus:E(VL,hL),startRuntime:E(VL,hL,{kind:`mutation`,auth:`admin`}),stopRuntime:E(VL,v(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.ML}},UL=[`decode`,`transcode`,`recording`,`streaming`,`detection`],WL=[`measured`,`accounted`,`unattributable`],GL=x({role:S(UL),deviceId:p().int().positive().nullable(),attribution:S(WL),unit:m(),pid:p().int().positive().optional(),startedAtMs:p().optional(),cpuSeconds:p().optional(),rssBytes:p().optional()}),KL={name:`load-contribution`,scope:`system`,mode:`collection`,internal:!0,methods:{list:E(v(),C(GL).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:O.INTERNAL}},qL=`https://camstack.zentik.app`,JL=`/viewer/camstack`;function YL(e){if(e==null||e===``)return!1;try{return new URL(e).origin===qL}catch{return!1}}function ixe(e){let t=e.baseUrl??e.resolved;return YL(t)?{form:`app`,hubBaseUrl:e.appLinkHub??null}:{form:`hub`,hubBaseUrl:t}}function XL(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 axe(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=XL(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 oxe(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 ZL(e){return e.length===0?``:`?${e.map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join(`&`)}`}function sxe(e){let t=oxe(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:XL(r),n=e===null?t.query:[...t.query,[`hub`,e]];return`${qL}${t.path}${ZL(n)}`}return r===``||YL(r)?null:`${r}${JL}${t.path}${ZL(t.query)}`}var QL=[`appConnections`,`notificationTaps`,`internal`,`publicEndpoint`],cxe=[`notificationTaps`,`internal`,`publicEndpoint`];function lxe(e){return e!==`appConnections`}var uxe={appConnections:[],notificationTaps:null,internal:null,publicEndpoint:null},dxe=/^\d{1,3}(?:\.\d{1,3}){3}$/;function $L(e){try{let t=new URL(e).hostname;return t.length>0?t:null}catch{return null}}function fxe(e){return e.replace(/\/+$/,``)}function eR(e){return e.kind===`public`&&e.interfaceKind===`vpn`}function pxe(e){return e.kind===`public`&&e.interfaceKind===`public`}function tR(e){return(e.kind===`lan-ipv4`||e.kind===`lan-ipv6`)&&e.plausible}function nR(e){if(e.kind!==`lan-ipv4`||!e.plausible)return!1;let t=$L(e.baseUrl);return t!==null&&dxe.test(t)}function rR(e){return e.stable===!1}function mxe(e,t){return t.kind===`loopback`||t.kind===`app-link`||t.kind===`custom`||$L(t.baseUrl)===null||rR(t)?null:e===`internal`?nR(t)?0:tR(t)?1:eR(t)?2:null:pxe(t)?0:eR(t)?1:nR(t)?2:tR(t)?3:null}var hxe=new Set([`localhost`,`0.0.0.0`,`::1`,`[::1]`,`::`,`[::]`]);function gxe(e){let t=e.toLowerCase();return hxe.has(t)||t.endsWith(`.localhost`)?!0:/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(t)}function iR(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.`}:gxe(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 aR=`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 oR(e,t,n={}){if(YL(t))return e===`notificationTaps`?{ok:!0,baseUrl:qL}:{ok:!1,reason:`The CamStack app link is not a hub address — only notification taps can use it.`};let r=iR(t);return r.ok&&e===`publicEndpoint`&&r.baseUrl.startsWith(`http:`)&&n.acceptInsecureHttp!==!0?{ok:!1,reason:aR}:r}function sR(e,t){if(t===null||t===``)return null;let n=oR(e,t,{acceptInsecureHttp:!0});return n.ok?n.baseUrl:null}function _xe(e,t){let n=e.flatMap(e=>{let n=mxe(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:fxe(n.endpoint.baseUrl)}function cR(e,t,n){let r=sR(t,n);if(r!==null)return{flagged:r,resolved:r,source:`flagged`};let i=_xe(e,t);return{flagged:null,resolved:i,source:i===null?`none`:`auto`}}function lR(e,t){return cR(e,`internal`,t.internal)}function uR(e,t){return cR(e,`publicEndpoint`,t.publicEndpoint)}function dR(e){let t=sR(`notificationTaps`,e.notificationTaps);return t!==null&&!YL(t)?{flagged:t,resolved:t,source:`flagged`}:{flagged:null,resolved:qL,source:`auto`}}function fR(e){return rR(e)?!1:e.kind===`lan-ipv4`?!0:e.kind===`public`&&e.interfaceKind===`public`}function pR(e,t){let n=e.filter(fR);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 mR(e,t){let n=new Set(t.appConnections),r=pR(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 vxe(e,t,n){return{appConnections:mR(e,n),notificationTaps:dR(n),internal:lR(t,n),publicEndpoint:uR(t,n)}}function yxe(e){return e===null?null:$L(e)}var bxe=`camstack`,xxe=`_camstack._tcp.local`,Sxe={nodeId:`nodeId`,version:`version`,role:`role`,url:`url`,hubId:`hubId`},hR=/^hub-[0-9a-f]{16}$/;function Cxe(e){return typeof e==`string`&&hR.test(e)}var wxe=`camstack-agent`,Txe=`_camstack-agent._tcp.local`,Exe={nodeId:`nodeId`,version:`version`,name:`name`,state:`state`,keyFingerprint:`fp`},Dxe=S([`lan`,`wifi`,`docker`,`vpn`,`loopback`,`other`]),gR=x({name:m(),family:S([`IPv4`,`IPv6`]),address:m(),cidr:m(),netmask:m(),internal:y(),mac:m(),kind:Dxe,preferred:y(),plausible:y(),plausibleReason:m()}),Oxe=x({interfaces:C(gR).readonly(),probedAt:p()}),kxe=gR.nullable(),_R=x({label:m(),baseUrl:m(),kind:S([`lan-ipv4`,`lan-ipv6`,`public`,`loopback`,`app-link`,`custom`]),interfaceKind:S([`lan`,`wifi`,`docker`,`vpn`,`other`,`loopback`,`public`]),plausible:y(),plausibleReason:m(),priority:p(),stable:y().optional()}),Axe=S([`server-config`,`server-env`,`caller-hint`,`default`]),jxe=x({port:p().int().min(1).max(65535),source:Axe}),Mxe=x({endpoints:C(_R).readonly(),localPort:jxe}),vR=x({baseUrl:m().nullable(),resolved:m().nullable(),appLinkHub:m().nullable()}),yR=x({baseUrls:C(m()).readonly(),resolved:C(m()).readonly()}),bR=x({override:m().nullable(),resolved:m().nullable(),source:S([`override`,`auto`,`none`])}),Nxe=x({cluster:bR,browser:bR}),xR=S(QL),SR=S([`flagged`,`auto`,`none`]),CR=x({flagged:m().nullable(),resolved:m().nullable(),source:SR}),Pxe=x({flagged:C(m()).readonly(),resolved:C(m()).readonly(),source:SR}),wR=x({rows:C(_R.extend({detected:y(),custom:y(),flags:C(xR).readonly(),inUse:C(xR).readonly(),eligible:C(xR).readonly()})).readonly(),roles:x({appConnections:Pxe,notificationTaps:CR,internal:CR,publicEndpoint:CR}),appLinkHub:m().nullable(),listenerOrigins:C(m()).readonly().optional()}),TR=x({addresses:C(m()).readonly()}),ER=x({mode:S([`generated`,`uploaded`,`disabled`]),leafFingerprintSha256:m().nullable(),caFingerprintSha256:m().nullable(),validTo:m().nullable(),sans:C(m()),caCertPem:m().nullable(),reissueError:m().nullable(),restartRequired:y(),caMissing:y(),localCaConstrained:y().nullable(),caReplacedAt:m().nullable(),storedUpload:x({leafFingerprintSha256:m(),validTo:m(),hasCa:y()}).nullable()}),Fxe=x({providerId:m().min(1),modes:C(eA)}),Ixe=x({providerId:m().optional(),mode:m().optional(),message:m()}),Lxe=x({hostsProbed:p().int(),hits:p().int(),timeouts:p().int(),byMode:d(m(),x({probed:p().int(),hits:p().int(),timeouts:p().int()}))}),Rxe=x({hits:C(x({providerId:m(),hit:tA})),subnetsScanned:C(m()),errors:C(Ixe),stats:Lxe}),DR={name:`local-network`,scope:`system`,mode:`singleton`,methods:{list:E(v(),Oxe),getPreferred:E(v(),kxe),getConnectionEndpoints:E(x({port:p().int().min(1).max(65535).optional(),includeLoopback:y().optional(),ipv4Only:y().optional(),scheme:S([`http`,`https`]).optional(),includeAppLink:y().optional()}),Mxe),getNotificationEndpoint:E(v(),vR),setNotificationEndpoint:E(x({baseUrl:m().nullable()}),vR,{kind:`mutation`}),getViewerEndpoints:E(v(),yR),setViewerEndpoints:E(x({baseUrls:C(m()).readonly()}),yR,{kind:`mutation`}),getAddresses:E(x({scheme:S([`http`,`https`]).optional()}).optional(),wR),addCustomAddress:E(x({baseUrl:m(),label:m().max(80)}),wR,{kind:`mutation`,auth:`admin`}),removeCustomAddress:E(x({baseUrl:m()}),wR,{kind:`mutation`,auth:`admin`}),setAddressRole:E(x({role:xR,baseUrl:m().nullable(),enabled:y(),acceptInsecureHttp:y().optional()}),wR,{kind:`mutation`,auth:`admin`}),getHubAddresses:E(v(),Nxe),getAllowedAddresses:E(v(),TR),setAllowedAddresses:E(TR,x({success:s(!0)}),{kind:`mutation`}),resetAllowlistToBestMatch:E(v(),TR,{kind:`mutation`}),getTlsStatus:E(v(),ER),regenerateCertificate:E(x({reason:m().optional()}),ER,{kind:`mutation`,auth:`admin`}),uploadCertificate:E(x({certPem:m().min(1),keyPem:m().min(1),caPem:m().optional()}),ER,{kind:`mutation`,auth:`admin`}),downloadCa:E(v(),x({pem:m()})),useStoredUploadedCertificate:E(v(),ER,{kind:`mutation`,auth:`admin`}),scanNetwork:E(x({requests:C(Fxe),subnets:C(m()).optional()}),Rxe,{kind:`mutation`,auth:`admin`,timeoutMs:9e4}),getScanSubnets:E(v(),x({subnets:C(m())}),{auth:`admin`}),setScanSubnets:E(x({subnets:C(m())}),x({subnets:C(m())}),{kind:`mutation`,auth:`admin`}),revertToGeneratedCertificate:E(v(),ER,{kind:`mutation`,auth:`admin`})},mount:{kind:`hub-only`},vocabulary:{notOperatorFacing:O.NETWORK}},OR=S([`locked`,`unlocked`,`locking`,`unlocking`,`jammed`,`door-open`]),kR=x({state:OR,lastChangedAt:p()}),zxe={version:1,overridable:[{path:`state`,by:`door-contact`}],targets:[{id:`door-contact`,cardinality:`scalar`,vocabulary:{cap:`lock-control`,stateField:`state`},deviceTypes:[j.Lock],apply:`replace`,path:`state`,override:{whenSourceTrue:`door-open`,unlessNative:[`jammed`]},sources:[{kind:`binary`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}]},AR={name:`lock-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Lock],methods:{lock:E(x({deviceId:p().int().nonnegative(),code:m().min(1).optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.lock`,label:I(`Lock`,`Chiudi a chiave`),phrase:I(`Lock {device}`,`Chiudi a chiave {device}`),icon:`lock`,effect:{field:`state`,value:`locked`},openArgs:[{key:`code`,label:I(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]}),unlock:E(x({deviceId:p().int().nonnegative(),code:m().min(1).optional(),confirm:y().optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.unlock`,label:I(`Unlock`,`Apri la serratura`),phrase:I(`Unlock {device}`,`Sblocca {device}`),icon:`lock-open`,effect:{field:`state`,value:`unlocked`},openArgs:[{key:`code`,label:I(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]}),open:D(x({deviceId:p().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.open`,label:I(`Open latch`,`Apri lo scrocco`),phrase:I(`Release the latch of {device}`,`Fai scattare lo scrocco di {device}`),icon:`door-open`}]})},status:{schema:kR,kind:`push`},runtimeState:kR,customize:zxe,durability:`restored`,history:{fields:{state:{kind:`enum`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:I(`Lock`,`Serratura`),order:1060,state:[{kind:`enum`,field:`state`,label:I(`Lock state`,`Stato della serratura`),values:[{value:`locked`,label:I(`Locked`,`Chiusa a chiave`),phrase:I(`When {device} locks`,`Quando {device} si chiude a chiave`)},{value:`unlocked`,label:I(`Unlocked`,`Sbloccata`),phrase:I(`When {device} unlocks`,`Quando {device} si sblocca`)},{value:`locking`,label:I(`Locking`,`In chiusura`),phrase:I(`When {device} starts locking`,`Quando {device} inizia a chiudersi`)},{value:`unlocking`,label:I(`Unlocking`,`In apertura`),phrase:I(`When {device} starts unlocking`,`Quando {device} inizia a sbloccarsi`)},{value:`jammed`,label:I(`Jammed`,`Inceppata`),phrase:I(`When {device} jams`,`Quando {device} si inceppa`)},{value:`door-open`,label:I(`Door open`,`Porta aperta`),phrase:I(`When the door of {device} opens`,`Quando la porta di {device} si apre`)}],icon:`lock`}]}},jR=x({armed:p().int().min(0),unknown:C(m()).readonly()}),MR={name:`log-channels`,scope:`system`,mode:`collection`,internal:!0,methods:{list:E(v(),C(pu).readonly()),apply:E(x({windows:C(mu).readonly()}),jR,{kind:`mutation`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:O.INTERNAL}},NR=S([`debug`,`info`,`warn`,`error`]),PR=x({timestamp:g(),level:NR,scope:C(m()),message:m(),meta:d(m(),u()).optional(),tags:d(m(),m()).optional()}),FR=x({instanceId:m().min(1).max(200).optional(),requestId:m().min(1).max(64).optional(),deviceId:p().int().optional(),fromAddonId:m().min(1).max(200).optional(),fromNodeId:m().min(1).max(200).optional(),tags:d(m(),l([m(),p()])).optional(),level:NR.optional(),text:m().min(1).max(200).optional(),since:p().optional(),until:p().optional(),before:m().min(1).max(1024).optional(),after:m().min(1).max(1024).optional(),limit:p().int().min(1).max(1e3).optional(),budgetMs:p().int().min(50).max(1e4).optional()}),IR=x({id:m().optional(),timestamp:p(),level:NR,scope:m().optional(),message:m(),tags:d(m(),l([m(),p()])).optional(),meta:d(m(),u()).optional()}),LR=x({entries:C(IR),nextBefore:m().nullable(),nextAfter:m().nullable(),scannedBytes:p().int().nonnegative(),done:y(),cancelled:y().optional()}),Bxe=x({instanceId:m().min(1).max(200).optional()}),RR=x({readable:y(),reason:m().nullable(),filters:x({deviceId:y(),addonId:y(),nodeId:y(),tags:y(),level:y(),text:y(),timeRange:y()}),retentionDays:p().nullable()}),zR={name:`log-destination`,scope:`system`,mode:`collection`,internal:!0,methods:{write:E(PR,v(),{kind:`mutation`}),describeRead:D(Bxe,RR,{auth:`admin`}),read:D(FR,LR,{auth:`admin`}),cancelRead:D(x({requestId:m().min(1).max(64)}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:O.INTERNAL}},BR=S([`primary`,`second-factor`]),VR=x({kind:s(`redirect`),id:m(),label:m(),icon:m().optional(),startUrl:m(),stage:BR,linkable:y().optional(),app:Gf.nullable().optional()}),HR=x({kind:s(`widget`),id:m(),addonId:m(),bundle:m(),remote:Bv,stage:BR,app:Gf.nullable().optional()}),UR=x({kind:s(`passkey`),id:m(),label:m(),stage:BR,rpId:m(),origin:m().nullable(),app:Gf.nullable().optional()}),WR=a(`kind`,[VR,HR,UR]),GR={name:`login-method`,scope:`system`,mode:`collection`,internal:!0,methods:{getLoginMethods:E(v(),C(WR).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:O.IDENTITY}},Vxe=x({id:m(),label:m(),scope:S([`mesh`,`public`]),url:m(),hostname:m(),port:p(),protocol:S([`http`,`https`])}),KR=x({id:m(),hostname:m(),magicDns:m(),addresses:C(m()).readonly(),os:m().optional(),online:y(),lastSeenMs:p(),isSelf:y(),connection:S([`direct`,`relay`,`idle`]),relay:m().nullable(),lastHandshakeMs:p(),rxBytes:p(),txBytes:p(),tags:C(m()).readonly(),exitNodeOption:y(),advertisedRoutes:C(m()).readonly(),userLogin:m().nullable(),keyExpiry:p().nullable()}),qR=x({joined:y(),meshIp:m(),magicDnsHostname:m(),peerCount:p(),endpoints:C(Vxe).readonly(),error:m().optional(),tenantName:m(),magicDnsSuffix:m(),userLogin:m().nullable(),controlPlaneUrl:m(),keyExpiry:p().nullable(),daemonSocket:m().optional(),daemonCliPath:m().optional()}),JR={name:`mesh-network`,scope:`system`,mode:`collection`,providerKind:`mesh`,methods:{getStatus:E(v(),qR),join:E(x({authKey:m().min(8),hostname:m().optional()}),x({joined:s(!0)}),{kind:`mutation`}),startLogin:E(x({hostname:m().optional()}),x({loginUrl:m()}),{kind:`mutation`}),leave:E(v(),x({left:s(!0)}),{kind:`mutation`}),logout:E(v(),x({loggedOut:s(!0)}),{kind:`mutation`}),listPeers:E(v(),x({peers:C(KR).readonly()}))},vocabulary:{notOperatorFacing:O.NETWORK}},YR=x({value:p().nullable().meta(k(`device`,{label:`Total`})),lastFetchedAt:p()}),XR={name:`meter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor],methods:{},status:{schema:YR,kind:`push`},runtimeState:YR,durability:`restored`,history:{fields:{value:{kind:`counter`,deadband:.001,minIntervalMs:6e4}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`Meter`,`Contatore`),order:5140,state:[{kind:`numeric`,field:`value`,quantity:I(`the total`,`il totale`),label:I(`Total`,`Totale`),icon:`gauge`}]}},Hxe=x({total:p(),user:p(),system:p(),irq:p(),nice:p(),loadAvg:c([p(),p(),p()]),cores:p()}),Uxe=x({percent:p().nullable(),totalBytes:p(),usedBytes:p().nullable(),availableBytes:p().nullable(),swapUsedBytes:p(),swapTotalBytes:p()}),Wxe=x({readBytes:p(),writeBytes:p(),readOps:p(),writeOps:p(),timestampMs:p()}),Gxe=x({rxBytes:p(),txBytes:p(),rxPackets:p(),txPackets:p(),rxErrors:p(),txErrors:p(),timestampMs:p()}),ZR=x({utilization:p(),model:m(),memoryUsedBytes:p(),memoryTotalBytes:p(),temperature:p().nullable()}),Kxe=x({openFds:p(),threadCount:p(),activeHandles:p(),activeRequests:p()}),QR=x({avg10:p(),avg60:p(),avg300:p()}),$R=x({some:QR,full:QR.nullable()}),ez=x({cpu:Hxe,memory:Uxe,gpu:ZR.nullable(),network:Gxe,disk:Wxe,pressure:x({cpu:$R.nullable(),memory:$R.nullable(),io:$R.nullable()}),process:Kxe,cpuTemperature:p().nullable(),timestampMs:p()}),qxe=x({path:m(),totalBytes:p(),usedBytes:p(),availableBytes:p(),percent:p()}),tz=x({pid:p(),cpu:p(),memory:p(),privateBytes:p().optional(),sharedBytes:p().optional()}),Jxe=x({addonId:m(),nodeId:m(),role:S([`hub`,`worker`]),pid:p(),state:S([`starting`,`running`,`stopping`,`stopped`,`crashed`]),uptimeSec:p()}),Yxe=x({pid:p(),ppid:p(),pgid:p(),classification:S([`root`,`managed`,`system`]),addonId:m().nullable(),nodeId:m().nullable(),command:m(),cpuPercent:p(),memoryRssBytes:p(),cpuMainPercent:p().nullable(),cpuGcPercent:p().nullable(),threadCount:p().nullable(),uptimeSec:p()}),Xxe=x({source:S([`cgroup-v2`,`cgroup-v1`]),currentBytes:p(),limitBytes:p().nullable(),anonBytes:p().nullable(),fileBytes:p().nullable(),shmemBytes:p().nullable(),slabBytes:p().nullable(),gpuShmemBytes:p().nullable()}).extend({atMs:p()}),Zxe=x({atMs:p(),samples:p().int(),cpuMainPercent:p().nullable(),cpuMainPercentMin:p().nullable(),cpuGcPercent:p().nullable(),cpuGcPercentMin:p().nullable(),cpuLifetimePercent:p(),cpuLifetimePercentMin:p(),memoryRssBytes:p(),memoryRssBytesMin:p(),processCount:p().int(),processCountMin:p().int()}),Qxe=x({key:m(),kind:S([`addon`,`root`,`unattributed`]),points:C(Zxe).readonly()}),$xe=x({nodeId:m(),series:C(Qxe).readonly(),containerMemory:C(Xxe).readonly(),bucketMs:p(),retainedSamples:p(),oldestAtMs:p().nullable(),cadenceMs:p(),durable:y()}),eSe=x({forNodeId:m(),sinceMs:p().optional(),maxPoints:p().int().positive().optional()}),nz=x({cpuPercent:p(),memoryPercent:p().nullable(),memoryUsedMB:p().nullable(),memoryTotalMB:p(),diskPercent:p().optional(),temperature:p().optional(),gpuPercent:p().optional(),gpuMemoryPercent:p().optional()}),rz={name:`metrics-provider`,scope:`system`,mode:`singleton`,methods:{collectSnapshot:E(v(),ez),getCached:E(v(),ez.nullable()),getCurrent:E(v(),nz),getDiskSpace:E(x({dirPath:m()}),qxe),getGpuInfo:E(v(),ZR.nullable()),getCpuTemperature:E(v(),p().nullable()),getProcessStats:E(x({pids:C(p())}),C(tz)),listAddonInstances:E(v(),C(Jxe).readonly()),getAddonStats:E(x({addonId:m()}),tz.nullable()),listNodeProcesses:E(v(),C(Yxe).readonly()),getLoadSeries:E(eSe,$xe)},vocabulary:{notOperatorFacing:O.CLUSTER}},iz=m().min(1).max(256),az=d(m(),u()),oz=x({id:iz,deviceId:p().int().optional(),at:p().int().optional(),expiresAt:p().int().optional(),data:az}),sz=x({id:m(),deviceId:p().int().nullable(),at:p().nullable(),expiresAt:p().nullable(),rev:p().int(),updatedAt:p(),data:az}),cz=d(ji,l([m(),p(),y(),x({in:C(l([m(),p(),y()])).min(1).max(Pn)}),x({gt:l([m(),p()]).optional(),gte:l([m(),p()]).optional(),lt:l([m(),p()]).optional(),lte:l([m(),p()]).optional()}).refine(e=>Object.keys(e).length>0,{message:`name at least one bound`})])),lz={kind:Li},uz={deviceId:p().int().optional(),atFrom:p().optional(),atTo:p().optional()},dz=x({...lz,...uz,where:cz.optional(),order:S([`at`,`id`]).optional(),desc:y().optional(),limit:p().int().min(1).max(In).default(100),cursor:m().min(1).optional()}),fz=x({records:C(sz),nextCursor:m().nullable()}),tSe=S([`created`,`unchanged`,`updated`]),pz=x({kindId:p().int(),state:tSe,createdIndexes:C(m())}),mz=C(m()),hz=a(`op`,[x({op:s(`put`),kind:Li,record:oz,ifRev:p().int().min(0).optional()}),x({op:s(`patch`),kind:Li,id:iz,data:az,at:p().int().nullable().optional(),expiresAt:p().int().nullable().optional(),ifRev:p().int().min(1).optional()}),x({op:s(`delete`),kind:Li,id:iz})]),gz=d(m(),d(m(),m())),_z={name:`records`,scope:`system`,mode:`singleton`,internal:!0,methods:{declareKinds:E(x({kinds:d(Li,Ii)}),x({kinds:d(m(),pz)}),{kind:`mutation`,auth:`admin`}),get:E(x({...lz,id:iz}),sz.nullable(),{auth:`admin`}),getMany:E(x({...lz,ids:C(iz).min(1).max(Pn)}),C(sz),{auth:`admin`}),secretRefs:E(x({...lz,ids:C(iz).min(1).max(Pn)}),gz,{auth:`admin`}),put:E(x({...lz,record:oz,ifRev:p().int().min(0).optional()}),x({rev:p().int(),releasedRefs:mz}),{kind:`mutation`,auth:`admin`}),putMany:E(x({...lz,records:C(oz).min(1).max(Pn)}),x({count:p().int(),releasedRefs:mz}),{kind:`mutation`,auth:`admin`}),patch:E(x({...lz,id:iz,data:az,at:p().int().nullable().optional(),expiresAt:p().int().nullable().optional(),ifRev:p().int().min(1).optional()}),x({rev:p().int(),releasedRefs:mz}),{kind:`mutation`,auth:`admin`}),delete:E(x({...lz,id:iz}),x({deleted:y(),secretRefs:mz}),{kind:`mutation`,auth:`admin`}),deleteMany:E(x({...lz,ids:C(iz).min(1).max(Pn)}),x({deleted:p().int(),secretRefs:mz}),{kind:`mutation`,auth:`admin`}),query:E(dz,fz,{auth:`admin`}),count:E(x({...lz,...uz,where:cz.optional()}),x({count:p().int()}),{auth:`admin`}),histogram:E(x({...lz,deviceId:p().int().optional(),from:p(),to:p(),bucketMs:p().int().positive()}),x({buckets:C(x({bucketStart:p(),count:p().int()}))}),{auth:`admin`}),aggregate:E(x({...lz,op:S([`sum`,`min`,`max`,`count`]),field:ji.optional(),groupBy:ji.optional(),where:cz.optional()}),x({rows:C(x({group:l([m(),p(),ie()]),value:p().nullable()}))}),{auth:`admin`}),deleteWhere:E(x({...lz,deviceId:p().int().optional(),atBefore:p().optional(),where:cz.optional()}),x({deleted:p().int(),secretRefs:mz}),{kind:`mutation`,auth:`admin`}),transact:E(x({ops:C(hz).min(1).max(Pn)}),x({results:C(x({rev:p().int().nullable(),deleted:y()})),releasedRefs:mz,secretRefs:mz}),{kind:`mutation`,auth:`admin`}),deleteDevice:E(x({deviceId:p().int(),kinds:C(Li).optional()}),x({deleted:d(m(),p().int()),secretRefs:mz}),{kind:`mutation`,auth:`admin`}),allocateId:E(x(lz),x({id:p().int()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.INTERNAL}},vz=d(m(),u()),yz=x({integrationId:m().min(1)}),bz=x({id:m().min(1)}),xz=x({id:m(),deviceId:p().int().nullable(),at:p().nullable(),expiresAt:p().nullable(),rev:p().int(),updatedAt:p(),data:vz}),Sz={id:m().min(1),deviceId:p().int().optional(),at:p().int().optional(),expiresAt:p().int().optional(),data:vz},Cz=x({id:m(),addonId:m(),name:m(),info:vz,enabled:y().optional(),originStableId:m().optional()}),nSe=x({id:p().int(),integrationId:m().nullable().optional(),parentDeviceId:p().int().nullable().optional(),type:m().optional(),name:m().optional(),stableId:m().optional()}),wz=x({version:p().int(),methods:C(m())}),Tz=x({message:m(),meta:vz.optional(),tags:x({deviceId:p().int().optional()}).optional()}),rSe={"ledger.declare":{input:x({owner:m().min(1),metas:C(Fo)}),output:x({bootId:m(),snapshot:S([`none`,`written`,`refused`]),steps:C(Wo),migrationApi:wz.optional()}),behaviours:[`ledger.declare.answers-steps-in-engine-order`,`ledger.declare.answers-the-migration-api`]},"ledger.start":{input:x({id:m().min(1)}),output:x({proceed:y(),state:l([s(`pending`),Bo]),reason:m().nullable()}),behaviours:[`ledger.start.proceeds-when-predecessors-applied`]},"ledger.finish":{input:x({id:m().min(1),result:zo}),output:x({status:Bo,error:m().nullable(),rowsChanged:p().int().nonnegative()}),behaviours:[`ledger.finish.records-the-outcome`]},"legacyRows.read":{input:yz,output:vz,behaviours:[`legacyRows.read.returns-stored-rows`,`legacyRows.read.absent-store-is-empty`,`legacyRows.caller.sibling-package`]},"legacyRows.clear":{input:yz,output:x({rows:p().int().nonnegative(),secrets:p().int().nonnegative()}),behaviours:[`legacyRows.clear.deletes-the-rows`,`legacyRows.clear.absent-store-is-noop`]},"legacyRows.patch":{input:yz.extend({patch:vz}),output:x({written:y()}),behaviours:[`legacyRows.patch.upserts-keys-and-keeps-the-rest`,`legacyRows.patch.absent-store-writes-nothing`]},"legacyRows.deleteKeys":{input:yz.extend({keys:C(m().min(1))}),output:x({present:y(),removed:vz}),behaviours:[`legacyRows.deleteKeys.removes-the-named-keys`,`legacyRows.deleteKeys.absent-store-reports-not-present`]},"records.get":{input:bz,output:xz.nullable(),behaviours:[`records.get.returns-the-row-or-null`]},"records.getResolved":{input:bz,output:xz.nullable(),behaviours:[`records.getResolved.resolves-secret-fields`]},"records.put":{input:x({...Sz,ifRev:p().int().optional()}),output:x({rev:p().int()}),behaviours:[`records.put.creates-and-replaces`,`records.put.if-rev-conflict-throws`]},"records.putMany":{input:x({records:C(x(Sz))}),output:x({count:p().int().nonnegative()}),behaviours:[`records.putMany.writes-every-row`]},"records.patch":{input:bz.extend({partial:vz,ifRev:p().int().optional()}),output:x({rev:p().int()}),behaviours:[`records.patch.merges-and-null-removes`]},"records.delete":{input:bz,output:x({deleted:y()}),behaviours:[`records.delete.reports-whether-a-row-went`]},"records.query":{input:x({deviceId:p().int().optional(),atFrom:p().optional(),atTo:p().optional(),where:cz.optional(),limit:p().int().min(1).optional(),cursor:m().min(1).optional(),resolveSecrets:y().optional()}),output:x({records:C(xz),nextCursor:m().nullable()}),behaviours:[`records.query.pages-with-a-cursor`,`records.query.filters-on-a-declared-index`]},"records.deleteWhere":{input:x({deviceId:p().int().optional(),atBefore:p().optional(),where:cz.optional()}),output:x({count:p().int().nonnegative()}),behaviours:[`records.deleteWhere.deletes-the-matching-rows`]},"settings.read":{input:x({}),output:x({store:vz}),behaviours:[`settings.read.returns-the-addon-store`]},"settings.write":{input:x({patch:vz}),output:x({}),behaviours:[`settings.write.merges-and-keeps-other-keys`]},"settings.deleteKeys":{input:x({keys:C(m().min(1))}),output:x({removed:C(m())}),behaviours:[`settings.deleteKeys.removes-only-the-named-keys`]},"deviceSettings.listIds":{input:x({}),output:x({deviceIds:C(p().int())}),behaviours:[`deviceSettings.listIds.names-only-the-addons-own-devices`]},"deviceSettings.read":{input:x({deviceIds:C(p().int())}),output:x({blobs:d(m(),vz)}),behaviours:[`deviceSettings.read.returns-only-the-addons-own-blobs`]},"secrets.resolve":{input:x({refs:C(m())}),output:x({values:d(m(),m().nullable())}),behaviours:[`secrets.resolve.answers-null-for-a-missing-ref`]},"secrets.put":{input:x({ref:m().min(1),value:m()}),output:x({}),behaviours:[`secrets.put.stores-under-the-owner`]},"secrets.delete":{input:x({refs:C(m())}),output:x({deleted:p().int().nonnegative()}),behaviours:[`secrets.delete.ignores-unknown-refs`]},"integrations.list":{input:x({}),output:x({integrations:C(Cz)}),behaviours:[`integrations.list.lists-every-integration`]},"integrations.get":{input:x({id:m().min(1)}),output:Cz.nullable(),behaviours:[`integrations.get.null-for-an-unknown-id`]},"devices.list":{input:x({addonId:m().min(1),integrationId:m().min(1).optional()}),output:x({devices:C(nSe)}),behaviours:[`devices.list.scoped-to-the-addon`,`devices.list.filters-by-integration`]},"devices.get":{input:x({deviceId:p().int()}),output:x({id:p().int(),integrationId:m().nullable(),hasConfig:y()}).nullable(),behaviours:[`devices.get.null-for-an-unknown-id`,`devices.get.reports-link-and-config`]},"devices.aliases":{input:x({deviceIds:C(p().int())}),output:x({aliases:d(m(),m())}),behaviours:[`devices.aliases.answers-for-the-named-ids-only`]},"devices.setIntegrationId":{input:x({deviceId:p().int(),integrationId:m().min(1)}),output:x({}),behaviours:[`devices.setIntegrationId.links-the-device`]},"node.localNodeId":{input:x({}),output:x({nodeId:m()}),behaviours:[`node.localNodeId.names-this-node`]},"log.info":{input:Tz,output:x({}),behaviours:[`log.info.writes-a-line`]},"log.warn":{input:Tz,output:x({}),behaviours:[`log.warn.writes-a-line`]}},Ez={name:`migrations`,scope:`system`,mode:`singleton`,internal:!0,methods:{listLedger:E(x({}),x({entries:C(Vo)}),{auth:`admin`}),listPending:E(x({owner:m().optional()}),x({pending:C(Ho)}),{auth:`admin`}),dryRun:E(x({id:m().min(1)}),Uo,{auth:`admin`}),markFailed:E(x({id:m().min(1),error:m().min(1)}),Vo,{kind:`mutation`,auth:`admin`}),retry:E(x({id:m().min(1)}),x({entries:C(Vo)}),{kind:`mutation`,auth:`admin`}),restorePreMigration:E(x({database:jo,snapshotId:m().min(1)}),x({scheduled:y(),held:C(m()),restartRequired:y()}),{kind:`mutation`,auth:`admin`}),declareOwner:E(x({owner:m().min(1),metas:C(Fo),retired:C(m().min(1)).optional()}),x({bootId:m(),snapshot:S([`none`,`written`,`refused`]),steps:C(Wo),migrationApi:wz.optional()}),{kind:`mutation`,auth:`admin`}),startMigration:E(x({id:m().min(1)}),x({proceed:y(),state:l([s(`pending`),Bo]),reason:m().nullable()}),{kind:`mutation`,auth:`admin`}),finishMigration:E(x({id:m().min(1),result:zo}),x({status:Bo,error:m().nullable(),rowsChanged:p().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),readLegacyIntegrationRows:E(x({integrationId:m().min(1)}),d(m(),u()),{auth:`admin`}),clearLegacyIntegrationRows:E(x({integrationId:m().min(1)}),x({rows:p().int().nonnegative(),secrets:p().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),patchLegacyIntegrationRows:E(x({integrationId:m().min(1),patch:d(m(),u())}),x({written:y()}),{kind:`mutation`,auth:`admin`}),deleteLegacyIntegrationRowKeys:E(x({integrationId:m().min(1),keys:C(m().min(1))}),x({present:y(),removed:d(m(),u())}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.INTERNAL}},Dz=x({sourceUrl:m(),metadata:$d,targets:C(Qd).min(1).readonly(),calibrationRef:m().optional(),sessionId:m().optional()}),Oz={name:`model-convert`,scope:`system`,mode:`singleton`,internal:!0,methods:{convert:E(Dz,tf,{kind:`mutation`,auth:`admin`,timeoutMs:6e5})},vocabulary:{notOperatorFacing:O.ML}},kz=x({targetNodeId:m(),modelId:m(),format:S(Rd),entry:Zd}),Az=x({ok:y(),sha256:m(),bytes:p(),path:m()}),jz={name:`model-distributor`,scope:`system`,mode:`singleton`,internal:!0,methods:{distributeModel:E(kz,Az,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.ML}},Mz=a(`kind`,[x({kind:s(`camera`)}),x({kind:s(`sensor`),deviceId:p().int().positive()})]),Nz=Object.freeze({kind:`camera`});function iSe(e){if(e===void 0)return{triggeredBy:Nz,malformed:!1};let t=Mz.safeParse(e);return t.success?{triggeredBy:t.data,malformed:!1}:{triggeredBy:Nz,malformed:!0}}var aSe=`cameraSensors`,Pz=x({addonId:m().min(1),stableId:m().min(1)});function Fz(e){return`${e.addonId}/${e.stableId}`}var Iz=S([`in-addition`,`confirm`,`replace`]),Lz=`in-addition`,Rz=Pz.extend({mode:Iz.default(Lz)}),zz=x({sensors:C(Rz).min(1).max(8)}).superRefine((e,t)=>{let n=new Set;e.sensors.forEach((e,r)=>{let i=Fz(e);n.has(i)&&t.addIssue({code:`custom`,path:[`sensors`,r],message:`duplicate camera sensor ${i}`}),n.add(i)})}),Bz={addonId:m(),stableId:m(),mode:Iz.default(Lz)},Vz=a(`state`,[x({...Bz,state:s(`ready`),deviceId:p(),name:m(),caps:C(m()).readonly()}),x({...Bz,state:s(`offline`),deviceId:p(),name:m(),reason:S([`offline`,`disabled`])}),x({...Bz,state:s(`missing`),reason:m()}),x({...Bz,state:s(`unsupported`),deviceId:p(),name:m(),reason:m()}),x({...Bz,state:s(`unreadable`),reason:m()})]),Hz=S([`onboard-not-listed`,`no-active-detection`]),Uz=S([`always`,`when-confirmed`,`never`]),Wz=S([`provider-not-split`]),Gz=x({detected:y(),atMs:p()}),Kz=a(`state`,[x({state:s(`not-configured`),cameraLevel:Gz.optional()}),x({state:s(`unreadable`),reason:m(),cameraLevel:Gz.optional()}),x({state:s(`configured`),cameraLevel:Gz.optional(),sensors:C(Vz).readonly(),cameraMotion:Uz.optional(),notForwarded:Hz.optional(),notEnforced:Wz.optional()})]),qz=Object.freeze({state:`unreadable`,reason:`camera sensor mappings not loaded`}),Jz=x({bbox:_y,pixelCount:p(),intensity:p()}),Yz=x({detected:y(),regionCount:p(),regions:C(Jz).readonly(),rawRegions:C(Jz).readonly(),frameWidth:p(),frameHeight:p(),analysisMs:p()}),Xz={name:`motion-detection`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[j.Camera],exposesDeviceSettings:!0,methods:{analyze:E(x({deviceId:p(),frame:gy.optional(),frameHandle:hc.optional()}),Yz,{role:`admin`,kind:`mutation`,notOperatorFacing:`the pipeline feeds it frames — an internal stage, never called by a person`}),removeCamera:E(x({deviceId:p()}),v(),{role:`admin`,kind:`mutation`,notOperatorFacing:`pipeline housekeeping when a camera leaves`}),reset:E(v(),v(),{role:`admin`,kind:`mutation`,notOperatorFacing:`pipeline housekeeping`})},events:{onMotion:{data:x({deviceId:p(),detected:y(),regionCount:p()}),notOperatorFacing:"the analyzer’s raw verdict; the operator signal is the `motion` cap’s `detected` state"}},vocabulary:{noun:I(`Motion analysis`,`Analisi del movimento`),order:3160}},Zz=x({package:y(),confidence:p().min(0).max(1),reason:m().min(1)}),Qz=x({x:p(),y:p()}),$z=x({kind:s(`rect`),x:p(),y:p(),width:p(),height:p()}),eB=x({kind:s(`polygon`),points:C(Qz)}),tB=x({kind:s(`grid`),gridWidth:p().meta(k(`none`)),gridHeight:p().meta(k(`none`)),cells:C(y())}),nB=x({kind:s(`line`),points:C(Qz)}),oSe=a(`kind`,[$z,eB,tB,nB]),rB=S([`rect`,`polygon`,`grid`,`line`]),iB=x({min:p(),max:p()}),aB=x({width:p(),height:p()}),oB=[`owner-not-ready`,`store-read-failed`,`three-way-read-unavailable`,`invalid-stored`,`not-cluster-scoped`],sB=[{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)`}]}],sSe=`cluster-step-models`;function cB(e){return`clusterModel:${e}`}function cSe(e){return sB.some(t=>t.stepId===e)}var lB=Object.freeze(Object.fromEntries(sB.map(e=>[e.stepId,e.defaultModelId])));function uB(e){return e==null||e===``?{kind:`absent`}:typeof e==`string`?{kind:`chosen`,modelId:e}:{kind:`invalid`,value:e}}function dB(e){let t=[];for(let n of sB){let r=uB(e[cB(n.stepId)]);r.kind===`invalid`&&t.push({stepId:n.stepId,value:r.value})}return t}function fB(e){let t={};for(let n of sB){let r=uB(e[cB(n.stepId)]);t[n.stepId]=r.kind===`chosen`?r.modelId:n.defaultModelId}return t}function lSe(e){return typeof e==`object`&&!!e&&`key`in e}function pB(e){return e===null?lB:fB(hB(e,mB()))}function uSe(e){return e===null?[]:dB(hB(e,mB()))}function mB(){return new Set(sB.map(e=>cB(e.stepId)))}function hB(e,t){let n={};for(let r of e.sections)for(let e of r.fields)!lSe(e)||typeof e.key!=`string`||t.has(e.key)&&(n[e.key]=e.value);return n}function dSe(e,t){let n=sB.find(t=>t.stepId===e);if(n===void 0)return null;let r=t[e];return r!==void 0&&r!==``?r:n.defaultModelId}var gB=[{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 _B(e,t){return`clusterStepSetting:${e}:${t}`}function vB(e){return gB.filter(t=>t.stepId===e)}var fSe=p().finite();function yB(e){let t={};for(let n of gB){let r=fSe.safeParse(e[_B(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 bB=yB({});function xB(e){return e===null?bB:yB(hB(e,new Set(gB.map(e=>_B(e.stepId,e.key)))))}function pSe(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 SB=S([`new`,`entered`,`left`,`moving`,`idle`]),CB=S([`motion`,`object`,`audio`]),wB=a(`kind`,[$z,eB]),TB=S([`motion`,`audio`,`person`,`vehicle`,`animal`,`door`,`pir`,`smoke`,`water`,`button`,`package`,`generic`]),EB=S([`motion`,`audio`,`detection`,`sensor`,`control`,`custom`,`package`]),mSe=S([`macro`,`sub`]),DB=x({kind:m(),labelKey:m(),label:m(),color:m(),iconId:m(),icon:TB,category:EB,parentKind:m().nullable(),level:mSe,source:x({capName:m(),deviceId:p()})}),OB=x({deviceId:p(),kinds:C(DB).readonly()}),kB=x({id:m(),deviceId:p(),sourceDeviceId:p(),kind:m(),value:d(m(),u()).nullable(),timestamp:p()}),AB=x({x:p(),y:p(),timestamp:p(),bbox:_y,source:S([`frame`,`recovery`]).optional(),score:p().optional()}),hSe=x({timestamp:p(),position:AB,mediaId:p().int()}),jB=x({minX:p(),minY:p(),maxX:p(),maxY:p()}),MB=S([`full`,`slim`]),NB=x({label:m(),peakScore:p(),count:p(),firstAt:p(),lastAt:p()}),PB=S([`pipeline`,`onboard`,`sensor`,`audio`]),FB=S([`none`,`staging`,`trained`]),IB={markForTrain:y().optional(),debug:y().optional(),debugNote:m().max(500).optional(),favourited:y().optional()},LB={retrainStatus:FB.optional()},RB=x(IB),zB=x({trackId:m(),markForTrain:y(),debug:y(),debugNote:m(),favourited:y(),retrainStatus:FB}),gSe=l([s(1),s(2)]),BB=x({stepId:m(),modelId:m().optional(),decidedAt:p(),identityId:m().optional()}),VB={label:m().optional(),labelScore:p().optional(),labelMeta:BB.optional(),subLabel:m().optional(),subLabelScore:p().optional(),subLabelMeta:BB.optional()},HB=x({deviceId:p(),tracks:p().int(),files:p().int(),bytes:p().int()}),UB=x({generatedAt:p(),trackCount:p().int(),fileCount:p().int(),byteCount:p().int(),truncated:y(),devices:C(HB).readonly()}),WB=x({nodeId:m(),deviceKey:m().optional(),modelId:m().optional()}),GB=x({trackId:m(),deviceId:p(),className:m(),...VB,producingDeviceName:m().optional(),source:PB.optional(),firstSeen:p(),lastSeen:p(),positions:C(AB).readonly(),snapshots:C(hSe).readonly(),zonesVisited:C(m()).readonly(),zoneNames:C(m()).readonly().optional(),classes:C(m()).readonly().optional(),totalDistance:p(),state:SB,active:y(),importance:p().optional(),bestEventId:m().optional(),importanceReason:m().optional(),audioLabels:C(NB).readonly().optional(),envelope:jB.optional(),hasFace:y().optional(),hasEmbeddedFace:y().optional(),hasRider:y().optional(),previewMissReason:m().optional(),modelId:m().optional(),openedPlacement:WB.optional(),closedPlacement:WB.optional(),frameWidth:p().optional(),frameHeight:p().optional(),...IB,...LB}),KB={id:p().int(),deviceId:p(),timestamp:p()},qB=x({...KB,kind:s(`motion`),regionCount:p(),regions:C(x({bbox:_y,pixelCount:p(),intensity:p()})).readonly().optional(),frameWidth:p().optional(),frameHeight:p().optional(),mediaUrl:m().optional(),triggeredBy:Mz.optional(),durationMs:p().nullable().optional(),edges:C(p()).readonly().optional()}),JB=S([`pipeline`,`onboard`]),YB=S([`enter`,`exit`]),XB=x({direction:YB,zoneId:m(),zoneName:m().optional()}),_Se=x({zoneId:m(),zoneName:m().optional(),overlapPct:p()}),ZB=x({...KB,kind:s(`object`),source:JB.optional(),frameId:m().optional(),idempotencyKey:m().optional(),trackId:m().optional(),className:m(),...VB,confidence:p().optional(),bbox:_y.optional(),zones:C(m()).readonly().optional(),zoneOverlaps:C(_Se).readonly().optional(),spawnRefused:m().optional(),state:SB.optional(),zoneCrossing:XB.optional(),frameWidth:p().optional(),frameHeight:p().optional(),mediaId:p().int().optional(),keyFrameMediaId:p().int().optional(),mediaUrl:m().optional(),observedAt:p().optional(),packagePossible:y().optional(),packageLlmVerdict:Zz.optional(),importance:p().optional()}),QB=x({...KB,kind:s(`audio`),rms:p(),dbfs:p(),classification:x({className:m(),originalClass:m().optional(),score:p()}).optional(),classifyOutcome:Sy.optional(),mediaUrl:m().optional()}),$B=S([`crop`,`thumbnail`,`snapshot`,`firstFrame`,`lastFrame`,`fullFrame`,`fullFrameBoxed`,`faceCrop`,`plateCrop`,`keyFrame`,`keyFrameSmall`,`thumbnailSmall`,`confirmationCrop`,`debugCrop`,`sceneFrame`,`lastSceneFrame`]),eV=x({mediaId:p().int(),kind:$B,sizeBytes:p(),timestamp:p()}),tV=eV.extend({url:m(),base64:m()}),nV=tV.omit({base64:!0}),rV=S([`person`,`vehicle`,`animal`,`package`,`face`,`plate`]),iV=S([`subject`,`model_error`]),aV=S([`operator`,`assist`,`pipeline`,`llm`]),oV=x({x:p(),y:p(),w:p(),h:p()}),sV=x({source:aV,ref:m().min(1),bbox:oV,macroClass:rV,label:m().optional(),score:p().optional(),modelId:m().optional()}),cV=x({ref:m().min(1),snapshot:sV}),lV=S(_s),uV=x({ref:m(),savedId:m().optional(),status:lV,approximate:y(),origin:sV.optional(),macroClass:rV.optional(),label:m().optional(),iou:p().optional()}),dV=x({boxes:C(uV).readonly(),summary:x({counts:d(lV,p().int()),total:p().int(),changed:p().int(),approximate:y()})}),fV=x({id:m(),trackId:m().optional(),deviceId:p(),mediaKey:m(),bbox:oV,macroClass:rV,label:m().optional(),subLabel:m().optional(),kind:iV,source:aV,assistModelId:m().optional(),assistScore:p().optional(),origin:sV.nullable().optional(),exportedInBatch:m().optional(),createdAt:p()}),pV=fV.omit({id:!0,trackId:!0,deviceId:!0,mediaKey:!0,createdAt:!0,exportedInBatch:!0}),mV=S([`correct`,`wrong`,`wrong-label`]),hV=x({verdict:mV,suggestedClass:m().optional(),suggestedMacroClass:rV.optional(),suggestedLabel:m().optional(),trackId:m(),at:p().optional()}),gV=x({trackId:m(),className:m(),label:m().optional(),bbox:oV.optional(),verdict:mV,suggestedClass:m().optional(),at:p().optional()}),_V=x({trackId:m(),deviceId:p(),className:m(),label:m().optional(),firstSeen:p(),lastSeen:p(),frameCount:p().int(),annotationCount:p().int(),verdict:hV.optional()}),vV=x({mediaId:p().int(),kind:$B,timestamp:p(),sizeBytes:p().int(),copied:y()}),yV=x({bbox:oV,macroClass:rV,label:m().optional(),subLabel:m().optional(),score:p().optional(),modelId:m().optional(),trackId:m(),basis:S([`subject-box`,`position`,`verdict`]),deltaMs:p()}),bV=S([`track`,`recording`]),xV=x({frameId:m(),deviceId:p(),origin:bV,trackId:m().optional(),sourceMediaId:p().int().optional(),epochMs:p().optional(),sourceKind:$B,sizeBytes:p().int(),width:p().int(),height:p().int(),copiedAt:p(),capturedAt:p().optional(),complete:y(),pipelineBoxes:C(yV).readonly().optional(),collectionIds:C(m()).readonly().optional(),verdict:hV.optional(),revision:p().int().optional(),dismissed:C(cV).readonly().optional(),review:dV.optional(),imageUrl:m().optional(),thumbnailUrl:m().optional()}),SV=S([`source-missing`,`unreadable-image`,`write-failed`]),CV=x({copied:C(xV).readonly(),refused:C(x({sourceMediaId:p().int(),reason:SV})).readonly()}),wV=x({candidates:C(vV).readonly(),copies:C(xV).readonly(),autoPickMediaId:p().int().optional()}),TV=S([`unannotated`,`annotated`,`complete`]),EV=x({workState:TV.optional(),deviceIds:C(p()).max(500).optional(),collectionId:m().optional(),classes:C(rV).optional(),page:p().int().positive().default(1),pageSize:p().int().positive().max(100).default(50)}),DV=xV.extend({workState:TV}),OV=x({frames:C(DV).readonly(),total:p().int().nonnegative(),page:p().int().positive(),pageSize:p().int().positive()}),kV=x({deviceId:p(),unannotated:p().int().nonnegative(),annotated:p().int().nonnegative(),complete:p().int().nonnegative(),pctOfCorpus:p().min(0).max(1).nullable()}),AV=x({total:p().int().nonnegative(),unannotated:p().int().nonnegative(),annotated:p().int().nonnegative(),complete:p().int().nonnegative(),cameras:C(kV).readonly()}),jV=x({deviceIds:C(p()).optional(),frameIds:C(m()).max(2e4).optional(),collectionIds:C(m()).max(200).optional(),collectionId:m().optional(),batchId:m().optional(),completeOnly:y().optional(),workState:TV.optional(),classes:C(rV).optional()}),MV=S([`frames`,`crops`]),NV=x({kind:s(`http`),method:S([`PUT`,`POST`]),url:m().url(),headers:d(m(),m()).optional()}),PV=x({batchId:m(),frames:p().int(),crops:p().int(),annotations:p().int(),missing:p().int(),bytes:p().int(),sha256:m(),status:p().int()}),FV=a(`kind`,[x({kind:s(`package`),zone:oV.optional()}),x({kind:s(`objects`),modelId:m(),minScore:p().optional()})]),IV=a(`kind`,[x({kind:s(`proposed`),modelId:m(),stepId:m(),minScore:p(),proposals:C(pV).readonly(),belowThreshold:p().int()}),x({kind:s(`refused`),reason:m(),detail:m().optional()})]),LV=x({id:m(),name:m(),createdAt:p(),frameCount:p().int()}),RV=a(`kind`,[x({kind:s(`created`),collection:LV}),x({kind:s(`refused`),reason:S([`empty-name`,`duplicate-name`])})]),zV=a(`kind`,[x({kind:s(`renamed`),collection:LV}),x({kind:s(`refused`),reason:S([`empty-name`,`duplicate-name`,`unknown-collection`])})]),BV=a(`kind`,[x({kind:s(`added`),collectionId:m(),frame:xV,reused:y()}),x({kind:s(`refused`),reason:S([`unknown-collection`,`still-unavailable`,`still-busy`,`unreadable-image`,`write-failed`]),detail:m().optional()})]),VV=x({id:m(),name:m(),model:m(),kind:m(),leavesHouse:y()}),HV=pV.extend({reason:m()}),UV=x({ref:m(),verdict:S([`confirmed`,`wrong-class`,`not-an-object`,`uncertain`]),suggestedClass:rV.optional(),reason:m()}),WV=a(`kind`,[x({kind:s(`proposed`),profileId:m(),model:m(),leftHouse:y(),proposals:C(HV).readonly(),reviews:C(UV).readonly(),rejected:p().int()}),x({kind:s(`refused`),reason:S([`unknown-frame`,`unreadable-frame`,`unknown-profile`,`profile-disabled`,`no-vision`,`cloud-not-confirmed`,`llm-error`,`malformed-answer`]),detail:m().optional()})]),GV=x({deviceIds:C(p()).readonly().optional(),collectionIds:C(m()).max(200).readonly().optional(),frameIds:C(m()).max(2e4).readonly().optional()}),KV=x({frames:p().int(),completeFrames:p().int(),completeness:p(),subjects:p().int(),modelErrors:p().int(),hardNegatives:p().int(),cells:C(x({macroClass:m(),deviceId:p(),lighting:S([`day`,`night`,`unknown`]),subjects:p().int(),frames:p().int()})).readonly(),cameras:C(x({deviceId:p(),frames:p().int(),completeFrames:p().int()})).readonly()}),vSe=x({id:m(),name:m(),createdAt:p(),selection:GV,layout:MV,completeOnly:y(),frameCount:p().int(),annotationHash:m(),manifestSchema:m(),stats:KV}),qV=x({collectionIds:C(m()).min(1),workState:S([`complete`,`annotated_or_complete`,`any_annotated`]).default(`complete`)}),JV=a(`kind`,[x({kind:s(`resolved`),frameIds:C(m()).max(2e4).readonly(),stats:KV,annotationHash:m(),layout:MV}),x({kind:s(`refused`),reason:S([`unknown-collection`,`no-frames`]),detail:m()})]),YV=x({trackId:m(),retrainStatus:FB,changed:y(),reason:S([`unknown-track`,`no-frames-copied`,`not-staging`,`not-trained`,`unchanged`]).optional()}),XV=1e3,ZV=5e3,QV=x({deviceId:p(),since:p().optional(),until:p().optional(),limit:p().int().min(1).max(ZV).default(XV),projection:S([`full`,`slim`]).optional()}),ySe=QV.extend({classFilter:m().optional()}),$V=x({deviceIds:C(p()),since:p().optional(),until:p().optional(),limit:p().int().min(1).max(1e3).default(200),cursor:m().optional(),projection:MB.optional(),includeStationary:y().optional(),classes:C(m()).optional(),excludeSources:C(PB).optional()}),eH=x({tracks:C(GB).readonly(),nextCursor:m().nullable()}),tH=50,nH=200,bSe=x({deviceId:p(),since:p(),until:p(),limit:p().int().min(1).max(nH).default(tH),minImportance:p().min(0).max(1).optional(),classFilter:m().optional()}),rH=x({id:m(),trackId:m(),timestamp:p(),className:m(),...VB,importance:p(),bestEventId:m(),windowMs:p().optional(),audioLabels:C(NB).readonly().optional(),...IB,...LB}),xSe=x({deviceIds:C(p()).min(1).max(200),since:p(),until:p(),limit:p().int().min(1).max(nH).default(tH),minImportance:p().min(0).max(1).optional(),classFilter:m().optional()}),SSe=x({deviceId:p(),events:C(rH).readonly()}),iH=x({bucketStart:p(),motion:p().int(),object:p().int(),audio:p().int(),audioDbfs:p().optional()}),aH=x({deviceId:p(),read:S([`read`,`unreadable`]),buckets:C(iH).readonly()}),CSe=x({trackId:m(),className:m(),confidence:p(),bbox:_y,zones:C(m()).readonly(),state:SB}),wSe=o({id:m(),kind:S([`first-level`,`detail`]),macroClass:m(),score:p(),bbox:x({x:p(),y:p(),width:p(),height:p()}),labels:C(o({label:m(),score:p()})).readonly(),parentId:m().optional()}),oH=ZB.extend({score:p()}),TSe=x({text:m(),deviceId:p().optional(),since:p().optional(),until:p().optional(),classFilter:m().optional(),limit:p().default(50),minScore:p().min(0).max(1).optional(),strictness:_d.optional(),modelId:m().min(1).optional()}),sH=x({tracks:p().int(),events:p().int(),media:p().int(),faces:p().int(),plates:p().int(),embeddings:p().int()}),ESe=x({mediaDropped:p().int(),tracks:p().int(),events:p().int()}),DSe=x({deviceId:p(),rows:p().int(),bytes:p().int()}),OSe=x({totalRows:p().int(),totalBytes:p().int(),devices:C(DSe).readonly()}),kSe=x({kind:$B,rows:p().int(),bytes:p().int()}),ASe=x({totalRows:p().int(),totalBytes:p().int(),kinds:C(kSe).readonly(),unaccountedRows:p().int(),unaccountedBytes:p().int()}),cH=x({motion:p().int(),object:p().int(),audio:p().int()}),jSe=x({deviceId:p().optional(),since:p().optional(),until:p().optional(),maxTracks:p().int().positive().optional(),executeOnNodeId:m().optional(),pacingMs:p().int().nonnegative().optional(),force:y().optional()}),MSe=x({deleted:p(),failedIndexes:C(m()).optional()}),lH=S([`stores-unavailable`,...oB,`method-unavailable`,`read-failed`,`reads-disagree`,`not-a-clip-model`,`force-requires-max-tracks`]),NSe=x({started:y(),alreadyRunning:y(),refusal:lH.optional(),modelId:m().optional(),index:m().optional()}),PSe=x({running:y(),scanned:p(),rebuilt:p(),missingKeyFrame:p(),missingEvent:p(),missingBbox:p(),boxSource:x({subjectBox:p(),positions:p(),event:p(),refused:p()}),alreadyInSpace:p(),force:y().nullable(),forcedInSpace:p(),notRunnable:p(),noCapableNode:p(),failed:p(),complete:y().nullable(),startedAtMs:p().nullable(),finishedAtMs:p().nullable(),error:m().nullable(),modelId:m().nullable(),index:m().nullable()}),FSe=x({started:y(),alreadyRunning:y()}),ISe=x({mode:S([`report`,`reclaim`]).default(`report`),scopes:C(S([`motion-still`,`track-filmstrip`])).min(1).optional(),deviceIds:C(p().int()).min(1).optional(),restart:y().optional(),pageSize:p().int().min(50).max(5e3).optional(),maxRowsPerDevice:p().int().min(1).max(5e5).optional(),maxReclaimPerDevice:p().int().min(1).max(5e5).optional(),maxBytesPerRun:p().int().min(1).optional(),budgetMinutes:p().int().min(1).max(720).optional(),throttleBytesPerSec:p().int().min(64*1024).optional(),graceMinutes:p().int().min(1).max(10080).optional()}),LSe=x({running:y(),mode:S([`report`,`reclaim`]).nullable(),totalExamined:p(),totalEligible:p(),totalReclaimed:p(),totalBytesReclaimed:p(),totalRefused:p(),devicesDone:p(),complete:y().nullable(),startedAtMs:p().nullable(),finishedAtMs:p().nullable(),error:m().nullable()}),uH=S([`motion`,`audio-dbfs`,`battery`,`occupancy`]);function RSe(e,t){let n=e??``;return t===void 0?n:`${n}|${t}`}function dH(e){let t=e.indexOf(`|`);return t<0?{zoneId:e}:{zoneId:e.slice(0,t),className:e.slice(t+1)}}var fH=x({scope:m(),bucketStart:p().int(),samples:p().int().nonnegative(),sum:p(),min:p(),max:p()}),pH={name:`pipeline-analytics`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[j.Camera],exposesDeviceSettings:!0,methods:{getActiveTracks:E(x({deviceId:p()}),C(GB).readonly()),getTrack:E(x({deviceId:p(),trackId:m()}),GB.nullable()),listTracks:E(x({deviceId:p(),since:p().optional(),until:p().optional(),limit:p().optional(),zone:wB.optional(),projection:MB.optional(),includeStationary:y().optional(),classes:C(m()).optional(),excludeSources:C(PB).optional()}),C(GB).readonly()),listRecentTracks:E($V,eH),clearTracks:E(x({deviceId:p()}),v(),{kind:`mutation`,auth:`admin`}),getMotionEvents:E(QV,C(qB).readonly()),getObjectEvents:E(ySe,C(ZB).readonly()),getAudioEvents:E(QV,C(QB).readonly()),listEventKinds:E(x({deviceId:p()}),C(DB).readonly()),listEventKindsBatch:E(x({deviceIds:C(p()).min(1).max(200)}),C(OB).readonly()),getSensorEvents:E(x({deviceId:p(),since:p().optional(),until:p().optional(),kinds:C(m()).optional(),limit:p().int().min(1).max(ZV).default(XV)}),C(kB).readonly()),getKeyEvents:E(bSe,C(rH).readonly()),getKeyEventsBatch:E(xSe,C(SSe).readonly()),readLongTermSeries:E(x({deviceId:p(),series:uH,scope:m().optional(),from:p(),to:p(),limit:p().int().positive().optional()}),C(fH).readonly()),getEventDensity:E(x({deviceId:p(),since:p(),until:p(),bucketMs:p().int().positive()}),C(iH).readonly()),getEventDensityBatch:E(x({deviceIds:C(p()).min(1).max(200),since:p(),until:p(),bucketMs:p().int().positive()}),C(aH).readonly()),pruneEventsBefore:E(x({deviceId:p(),cutoffMs:p()}),x({motion:p().int(),object:p().int(),audio:p().int()}),{kind:`mutation`,auth:`admin`}),pruneTracksBefore:E(x({deviceId:p(),cutoffMs:p()}),sH,{kind:`mutation`,auth:`admin`}),wipeAllAnalytics:E(x({deviceId:p()}),sH,{kind:`mutation`,auth:`admin`}),reconcileFromDisk:E(x({deviceId:p()}),ESe,{kind:`mutation`,auth:`admin`}),deleteTracks:E(x({deviceId:p(),trackIds:C(m()).min(1)}),x({deleted:p().int(),failed:C(m()).readonly(),sparedMediaIds:C(p().int()).readonly().optional()}),{kind:`mutation`,auth:`admin`}),setTrackFlags:E(x({deviceId:p(),trackId:m(),flags:RB}),zB,{kind:`mutation`,notOperatorFacing:`curating a recorded track in the review UI, not a live step`}),listArchivedDebugNotes:E(Os,C(Ds).readonly(),{kind:`query`}),setTrackRelation:E(Ps,Ms,{kind:`mutation`,notOperatorFacing:`curating recorded tracks in the review UI, not a live step`}),clearTrackRelation:E(Fs,Is,{kind:`mutation`,notOperatorFacing:`curating recorded tracks in the review UI, not a live step`}),setTrackPurity:E(Ls,Rs,{kind:`mutation`,notOperatorFacing:`curating a recorded track in the review UI, not a live step`}),listTrackRelations:E(zs,Bs,{kind:`query`}),listBirthDecisions:E(Es,C(Ts).readonly(),{kind:`query`}),getEventStoreFootprint:E(x({}),OSe,{kind:`query`,auth:`admin`}),getEventMediaFootprintByKind:E(x({deviceId:p().int().optional()}),ASe,{kind:`query`,auth:`admin`}),pruneEvents:E(x({olderThanMs:p(),reason:Js.optional()}),cH,{kind:`mutation`,auth:`admin`}),deleteDeviceEvents:E(x({deviceId:p()}),cH,{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:E(Xc,x({paused:s(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:E(Xc,x({resumed:s(!0)}),{kind:`mutation`,auth:`admin`}),refreshStorageLocationsForMigration:E(Xc,x({refreshed:s(!0)}),{kind:`mutation`,auth:`admin`}),startStorageMigrationMove:E(al,x({jobId:m()}),{kind:`mutation`,auth:`admin`}),getStorageMigrationMoveStatus:E(x({jobId:m()}),qc.nullable(),{auth:`admin`}),cancelStorageMigrationMove:E(x({jobId:m()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),relocateMedia:E($c,x({jobId:m()}),{kind:`mutation`,auth:`admin`}),countUnstampedEventMedia:E(x({}),tl,{auth:`admin`}),getMediaLocationCensus:E(nl,il,{kind:`query`,auth:`admin`}),countRelocatableMedia:E(jl,Al,{kind:`query`,auth:`admin`}),listRelocateMediaJobs:E(x({}),C(qc).readonly(),{kind:`query`,auth:`admin`}),cancelRelocateMedia:E(x({jobId:m()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),listOpsLog:E(Xs,C(Ys).readonly(),{kind:`query`,auth:`admin`}),reclaimDebugMedia:E(ISe,FSe,{kind:`mutation`,auth:`admin`}),getMediaReclaimStatus:E(x({}),LSe,{kind:`query`,auth:`admin`}),getTrainingExportSummary:E(x({deviceIds:C(p()).optional()}),UB,{kind:`query`,auth:`admin`}),getTrainingExportUrl:E(x({deviceIds:C(p()).optional()}),x({url:m()}),{kind:`query`,auth:`admin`}),listRetrainStaging:E(x({deviceIds:C(p()).optional(),limit:p().int().min(1).max(500).optional()}),C(_V).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),listRetrainCorpusPage:E(EV,OV,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),getRetrainCorpusKpi:E(x({}),AV,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),listRetrainFrames:E(x({trackId:m()}),wV,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),selectRetrainFrames:E(x({deviceId:p(),trackId:m(),mediaIds:C(p().int()).min(1)}),CV,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),deselectRetrainFrame:E(x({deviceId:p(),trackId:m().optional(),frameId:m()}),x({removed:y(),removedAnnotations:p().int()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),getRetrainFrameImage:E(x({frameId:m()}),x({base64:m(),width:p().int(),height:p().int()}),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),proposeRetrainAnnotations:E(x({deviceId:p(),trackId:m().optional(),frameId:m(),subject:FV,nodeId:m().optional()}),IV,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainAnnotations:E(x({trackId:m().optional(),frameIds:C(m()).max(2e3).optional()}),C(fV).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),saveRetrainAnnotations:E(x({deviceId:p(),trackId:m().optional(),frameId:m(),annotations:C(pV),expectedRevision:p().int().optional(),dismissed:C(cV).optional()}),C(fV).readonly(),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),backfillRetrainOrigins:E(x({deviceId:p(),trackId:m().optional(),frameId:m(),expectedRevision:p().int().optional(),origins:C(x({annotationId:m(),origin:sV})).min(1).max(500)}),x({updated:p().int(),skipped:p().int(),revision:p().int()}),{kind:`mutation`,auth:`admin`}),completeRetrainTrack:E(x({deviceId:p(),trackId:m()}),YV,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),restageRetrainTrack:E(x({deviceId:p(),trackId:m()}),YV,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),getRetrainExportUrl:E(jV.extend({layout:MV.optional()}),x({url:m()}),{kind:`query`,auth:`admin`}),setRetrainFrameComplete:E(x({deviceId:p(),trackId:m().optional(),frameId:m(),complete:y()}),xV,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),writeRetrainArchive:E(x({filter:jV,layout:MV,target:NV}),PV,{kind:`mutation`,auth:`admin`,timeoutMs:60*6e4}),offerRetrainArchive:E(x({filter:jV,layout:MV}),x({ticket:Ja,frames:p().int(),annotations:p().int()}),{kind:`mutation`,auth:`admin`,timeoutMs:12e4}),listRetrainAssistProfiles:E(x({}),C(VV).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),proposeRetrainAnnotationsWithLlm:E(x({deviceId:p(),trackId:m().optional(),frameId:m(),profileId:m(),classes:C(rV).min(1),boxes:C(x({ref:m(),bbox:oV,macroClass:rV,label:m().optional()})).max(50),allowCloud:y()}),WV,{kind:`mutation`,auth:`admin`,timeoutMs:18e4}),createRetrainCollection:E(x({name:m().max(120)}),RV,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainCollections:E(x({}),C(LV).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),resolveRetrainTrainingCorpus:E(qV,JV,{kind:`query`,auth:`admin`,timeoutMs:6e4}),renameRetrainCollection:E(x({id:m(),name:m().max(120)}),zV,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),deleteRetrainCollection:E(x({id:m()}),x({deleted:y(),removedFrames:p().int()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),addRetrainFrameFromRecording:E(x({collectionId:m(),deviceId:p(),epochMs:p(),verdictSubject:gV.optional()}),BV,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`,timeoutMs:6e4}),addRetrainFramesToCollection:E(x({collectionId:m(),frameIds:C(m()).min(1).max(500)}),x({added:p().int(),alreadyMember:p().int(),unknownFrameIds:C(m()).readonly()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),removeRetrainFrameFromCollection:E(x({collectionId:m(),frameId:m()}),x({removed:y(),deletedFrame:y()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainCollectionFrames:E(x({collectionId:m()}),C(xV).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),getEventMedia:E(x({ownerType:Je,eventId:p().int(),kind:$B.optional(),deviceId:p()}),C(tV).readonly()),getTrackMedia:E(x({trackId:m(),kinds:C($B).optional(),deviceId:p()}),C(tV).readonly()),listTrackMedia:E(x({trackId:m(),deviceId:p()}),C(nV).readonly()),listEventMedia:E(x({ownerType:Je,eventId:p().int(),deviceId:p()}),C(nV).readonly()),ownersWithMedia:E(x({deviceId:p(),ownerKind:Xe,ownerIds:C(m()).max(5e3)}),C(m()).readonly()),searchObjectEvents:E(TSe,C(oH).readonly(),{caller:`required`}),wipeObjectEmbeddings:E(x({}),MSe,{kind:`mutation`,auth:`admin`}),rebuildObjectEmbeddings:E(jSe,NSe,{kind:`mutation`,auth:`admin`}),getObjectEmbeddingRebuildStatus:E(x({}),PSe)},events:{onFrameTracked:{data:x({deviceId:p(),timestamp:p(),frameWidth:p(),frameHeight:p(),detections:C(wSe).readonly()}),notOperatorFacing:`one tracker frame — stream rate, never an automation trigger`},onTrackStarted:{data:x({deviceId:p(),trackId:m(),className:m()}),trigger:{category:w.PipelineAnalyticsTrackStarted,label:I(`Subject appeared`,`Soggetto comparso`),phrase:I(`When {device} starts following a subject`,`Quando {device} inizia a seguire un soggetto`),icon:`scan-eye`}},onTrackEnded:{data:x({deviceId:p(),trackId:m(),className:m(),durationMs:p()}),trigger:{category:w.PipelineAnalyticsTrackEnded,label:I(`Subject left`,`Soggetto uscito`),phrase:I(`When a subject leaves the view of {device}`,`Quando un soggetto esce dall’inquadratura di {device}`),icon:`scan-eye`}},onDetectionEvent:{data:x({deviceId:p(),kind:CB,eventId:m(),timestamp:p()}),trigger:{category:w.PipelineAnalyticsDetectionEvent,label:I(`Detection event`,`Evento di rilevamento`),phrase:I(`When {device} records a detection event`,`Quando {device} registra un evento di rilevamento`),icon:`radar`}}},vocabulary:{noun:I(`Tracking`,`Tracciamento`),order:3200,extraEvents:[{category:w.PipelineAnalyticsPackageDelivered,label:I(`Package delivered`,`Pacco consegnato`),phrase:I(`When a package is left in front of {device}`,`Quando viene lasciato un pacco davanti a {device}`),icon:`package`},{category:w.PipelineAnalyticsPackagePickedUp,label:I(`Package picked up`,`Pacco ritirato`),phrase:I(`When a package is picked up in front of {device}`,`Quando viene ritirato un pacco davanti a {device}`),icon:`package-open`}]}},mH=_(()=>x({addonId:m(),modelId:m().optional(),enabled:y().default(!0),children:C(mH).optional(),settings:d(m(),u()).optional(),jumpDeviceKey:m().optional()})),hH=_e(),gH=x({stepId:m(),modelId:m(),detections:C(x({bbox:c([p(),p(),p(),p()]),score:p(),landmarks:C(x({x:p(),y:p()})).optional()})).min(1)}),_H=x({handle:hc,cropFrameSpace:x({x:p(),y:p(),w:p(),h:p()})});x({crop:x({left:p(),top:p(),width:p().positive(),height:p().positive()}).optional(),content:x({width:p().int().positive(),height:p().int().positive()}),fit:S([`stretch`,`contain`]),format:S([`rgb`,`gray`,`jpeg`])});var zSe=x({registryId:m().min(1),id:m().min(1),width:p().int().positive(),height:p().int().positive(),format:S([`rgb`,`gray`]),timestamp:p(),capturedAt:p().optional()}),vH=S([`onnx`,`coreml`,`openvino`,`tflite`,`pt`,`gguf`]),yH=S([`detector`,`cropper`,`classifier`,`refiner`,`audio-classifier`]),bH=x({runtime:s(`python`),backend:m(),format:vH,device:m().optional()}),xH=x({deviceKey:m().nullable(),runtime:m(),batchMode:m(),windowMs:p(),maxBatchSize:p(),concurrency:p(),numWorkers:p()}),BSe=x({engine:bH,devices:C(x({id:m(),label:m(),description:m().optional()})).readonly(),defaultDevice:m()}),SH=_(()=>x({addonId:m(),addonName:m(),slot:yH,inputClasses:C(m()).readonly(),outputClasses:C(m()).readonly(),enabled:y(),modelId:m(),children:C(SH).readonly(),group:m().optional(),settings:d(m(),u()).optional()})),VSe=x({id:m(),name:m(),formats:d(m(),Hd),group:Gd.optional(),legacy:y().optional(),provider:qd.optional(),defaultConfidence:p().optional(),suppliesSteps:C(Xd).readonly().optional()}),HSe=_e(),USe=x({id:m(),name:m(),slot:yH,inputClasses:C(m()).readonly(),outputClasses:C(m()).readonly(),childSlots:C(yH).readonly(),models:C(VSe).readonly(),defaultModelId:m(),defaultModelIdByFormat:d(m(),m()).optional(),enabledByDefault:y().optional(),defaultConfidence:p(),group:m().optional(),configSchema:C(HSe).readonly().optional()}),WSe=x({id:yH,label:m(),priority:p(),parentSlot:yH.nullable(),addons:C(USe).readonly()}),GSe=x({availableEngines:C(BSe).readonly(),selectedEngine:bH,slots:C(WSe).readonly()}),KSe=x({runtimeId:S([`onnx`,`openvino`,`coreml`,`edgetpu`]).nullable(),device:m().nullable(),state:S([`idle`,`installing`,`verifying`,`ready`,`failed`]),progress:p().optional(),error:m().optional(),nextRetryAt:p().optional(),configIssues:C(m()).optional()}),CH=x({addonId:m(),chosen:m(),running:m(),format:m()}),wH=x({addonId:m(),kind:S([`unknown-addon`,`no-format-build`,`unknown-device`]),detail:m()}),TH=x({ok:y(),issues:C(wH).readonly(),substitutions:C(CH).readonly(),format:m()}),qSe=x({filename:m(),stepIds:C(m()).readonly().optional()}),JSe=x({base64:m(),filename:m()}),YSe=x({filename:m(),sizeKb:p()}),XSe=x({base64:m()}),ZSe=x({id:m(),name:m(),description:m(),available:y(),rawLabels:C(m()).readonly().optional()}),QSe=x({activeBackend:m(),availableBackends:C(ZSe).readonly(),sampleRate:p(),chunkDurationMs:p()}),$Se=x({filePath:m(),sizeMB:p(),durationMs:p()}),eCe=x({success:y(),error:m().optional(),frame:_e().optional()}),tCe=_e(),nCe=_e(),rCe=_e(),iCe=_e(),EH={name:`pipeline-executor`,scope:`system`,mode:`singleton`,methods:{getAvailableEngines:E(v(),C(bH)),getSelectedEngine:E(v(),bH),getEngineProvisioning:E(x({nodeId:m()}),KSe),getVideoPipelineSteps:E(v(),d(m(),x({modelId:m(),settings:d(m(),u()).readonly()}))),setVideoPipelineSteps:E(x({steps:d(m(),x({modelId:m(),settings:d(m(),u()).readonly()}))}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),getInferenceDeviceHealth:E(x({nodeId:m()}),x({unhealthy:C(x({deviceKey:m(),state:S([`failed`,`backoff`]),since:p(),deaths:p(),lastError:m()})).readonly()})),rearmInferenceDevice:E(x({nodeId:m(),deviceKey:m()}),x({rearmed:y()}),{kind:`mutation`,auth:`admin`}),getSchema:E(v(),GSe),getOrchestratorConfigSchema:E(v(),tCe),validatePipeline:E(x({steps:C(mH),deviceKey:m().optional()}),TH),getCapabilities:E(v(),rCe),getAddonModels:E(x({addonId:m()}),iCe),downloadModel:E(x({addonId:m(),modelId:m(),format:vH}),$Se,{kind:`mutation`}),deleteModel:E(x({addonId:m(),modelId:m(),format:vH}),x({success:s(!0)}),{kind:`mutation`}),runPipeline:E(x({steps:C(mH).min(1),frame:gy.optional(),frameRef:zSe.optional(),frameHandle:hc.optional(),imageBase64:m().optional(),image:b(Uint8Array).optional(),referenceImage:m().optional(),deviceId:p().optional(),sessionId:m().optional(),plane:S([`full`,`frame`]).optional(),deviceKey:m().optional(),nativeCropRef:_H.optional(),replay:s(!0).optional(),suppliedRoot:gH.optional()}),hH,{kind:`mutation`}),runPipelineBatch:E(x({steps:C(mH).min(1),frames:C(gy).min(1).max(255),deviceId:p().optional(),sessionId:m().optional(),frameId:p().int().nonnegative().optional(),deviceKey:m().optional()}),x({results:C(hH).readonly()}),{kind:`mutation`}),cacheFrameInPool:E(x({data:b(Uint8Array),width:p().int().positive(),height:p().int().positive(),format:S([`rgb`,`bgr`,`gray`])}),x({frameId:p(),width:p(),height:p()}),{kind:`mutation`}),inferCached:E(x({stepId:m(),frameId:p().int(),modelId:m().min(1)}),d(m(),u()),{kind:`mutation`}),uncacheFrame:E(x({frameId:p().int()}),v(),{kind:`mutation`}),getEffectiveTuning:E(x({deviceKey:m().optional()}),xH),listLoadedEngines:E(v(),C(x({engineKey:m(),engine:bH,modelsLoaded:C(m()).readonly(),inUseByCameras:C(p()).readonly(),kind:S([`runtime`,`device-pool`]),poolPid:p().nullable(),idleMs:p().nullable(),idleTtlMs:p().nullable()})).readonly()),spinEngine:E(x({engine:bH}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),killEngine:E(x({engine:bH,force:y().optional()}),x({success:y(),reason:m().optional()}),{kind:`mutation`,auth:`admin`}),listReferenceImages:E(v(),C(qSe).readonly()),getReferenceImage:E(x({filename:m()}),JSe.nullable()),getReferenceAudioFiles:E(v(),C(YSe).readonly()),getReferenceAudio:E(x({filename:m()}),XSe.nullable()),getAudioCapabilities:E(v(),QSe),runAudioTest:E(x({addonId:m(),modelId:m(),filename:m().optional(),settings:d(m(),u()).optional()}),eCe,{kind:`mutation`}),getDetectionConfigSchema:E(v(),nCe)},vocabulary:{notOperatorFacing:O.PIPELINE}},aCe=x({activeCameras:p(),throttledCameras:p(),avgInferenceTimeMs:p(),queueDepth:p()}),DH=x({detectionMode:S([`disabled`,`always-on`,`on-motion`]),configuredFps:p(),actualFps:p(),queueDepth:p(),avgInferenceTimeMs:p(),droppedFrames:p(),nativeCropMisses:p().optional(),phase:S([`idle`,`watching`,`active`])}),OH=DH.extend({deviceId:p()}),kH=S([`polygon`,`tripwire`]),AH=x({x:p(),y:p()}),jH=x({id:m(),name:m(),kind:kH.default(`polygon`),polygon:C(AH).readonly(),color:m().default(`#3b82f6`)}),MH={name:`zones`,scope:`device`,mode:`singleton`,deviceTypes:[j.Camera],methods:{listZones:E(x({deviceId:p()}),C(jH).readonly()),addZone:E(x({deviceId:p(),zone:jH}),v(),{kind:`mutation`,auth:`admin`}),removeZone:E(x({deviceId:p(),zoneId:m()}),v(),{kind:`mutation`,auth:`admin`}),updateZone:E(x({deviceId:p(),zone:jH}),v(),{kind:`mutation`,auth:`admin`})},runtimeState:x({zones:C(jH).readonly()}),durability:`restored`,history:`none`,vocabulary:{noun:I(`Zones`,`Zone`),order:3370}},NH={fpsPerStream:10,budgetMinutes:45,minBudgetMinutes:10,maxBudgetMinutes:120,staleAfterDays:30,settleSec:5,measureSec:20,drainTimeoutSec:120,maxModelsPerDevice:6},PH=S([`device`,`pipeline`]),FH=x({deviceKey:m().min(1),modelIds:C(m().min(1)).min(1).max(NH.maxModelsPerDevice)}),IH=x({nodeId:m().min(1),devices:C(FH).min(1),phases:C(PH).min(1).default([`device`,`pipeline`]),steps:C(m().min(1)).default([]),fpsPerStream:p().int().min(1).max(30).default(NH.fpsPerStream),budgetMinutes:p().int().min(NH.minBudgetMinutes).max(NH.maxBudgetMinutes).default(NH.budgetMinutes),keepDownloadedModels:y().default(!1),acceptInsufficientHeadroom:y().default(!1)}),LH=S([`benchmark-active`,`node-offline`,`unknown-device`,`no-phase`,`insufficient-headroom`]),RH=x({kind:LH,detail:m(),overridable:y()}),zH=x({deviceId:p(),placedOnNode:y(),pinnedToNode:y()}),BH=x({deviceId:p(),reason:s(`only-frame-source`)}),VH=x({nodeId:m(),online:y(),moving:C(zH).readonly(),staying:C(BH).readonly(),estimatedDurationMs:p(),budgetMs:p(),phases:C(PH).readonly(),steps:C(m()).readonly(),devices:C(FH).readonly(),headroom:x({sessionsNow:p(),otherNodesCapacitySessions:p().nullable()}),refusals:C(RH).readonly(),canStart:y()}),HH=x({phase:S([`preparing`,`device`,`pipeline`,`cleanup`]),deviceKey:m().nullable(),modelId:m().nullable(),load:p().nullable(),cellsDone:p(),cellsTotal:p(),message:m()}),UH=S([`p95`,`drops`,`errors`,`stall`,`cpu`,`ram`,`none`]),WH=x({load:p(),pass:y(),p95Ms:p(),dropRatio:p(),fps:p(),cpuPct:p().nullable(),ramFreePct:p().nullable(),failReasons:C(m()).readonly()}),GH=x({phase:s(`device`),deviceKey:m(),modelId:m(),p50Ms:p(),p95Ms:p(),p99Ms:p(),fps:p(),kMax:p(),limitedBy:UH,warmupMs:p(),ramp:C(WH).readonly()}),KH=x({phase:s(`pipeline`),deviceKey:m(),modelId:m(),steps:C(m()).readonly(),maxSessions:p(),limitedBy:UH,stepsFired:C(m()).readonly(),warmupMs:p(),ramp:C(WH).readonly()}),qH=a(`phase`,[GH,KH]),JH=x({pipelineVersion:m().nullable(),cpuModel:m().nullable(),ramGb:p().nullable(),os:m().nullable(),pools:d(m(),x({runtime:m(),numWorkers:p(),concurrency:p(),batchMode:m()})).default({})}),YH=x({id:m(),revision:m().nullable(),frames:p(),width:p(),height:p()}),XH=x({runId:m().min(1),devices:C(FH).min(1),phases:C(PH).min(1),steps:C(m()).default([]),fpsPerStream:p().int().min(1).max(30),deadlineAtMs:p(),settleSec:p().min(0).max(60).default(NH.settleSec),measureSec:p().min(2).max(300).default(NH.measureSec),keepDownloadedModels:y().default(!1)}),ZH=S([`running`,`done`,`failed`,`aborted`]),QH=x({runId:m(),nodeId:m(),state:ZH,progress:HH.nullable(),cells:C(qH).readonly(),fingerprint:JH.nullable(),clip:YH.nullable(),activeCameraIds:C(p()).readonly(),deletedModels:C(m()).readonly(),error:m().nullable(),startedAtMs:p(),finishedAtMs:p().nullable()}),$H=S([`draining`,`measuring`,`restoring`,`done`,`failed`,`aborted`]),eU=S([`completed`,`operator-abort`,`deadline`,`node-lost`,`runner-lost`,`hub-restart`,`drain-timeout`,`failed`]),tU=x({runId:m(),nodeId:m(),state:$H,plan:IH,startedAtMs:p(),deadlineAtMs:p(),finishedAtMs:p().nullable(),endReason:eU.nullable(),error:m().nullable(),moved:C(p()).readonly(),staying:C(p()).readonly(),contaminated:y(),progress:HH.nullable(),resultIds:C(m()).readonly()}),nU=x({modeNodeId:m().nullable(),run:tU.nullable()}),rU=x({id:m(),runId:m(),nodeId:m(),cell:qH,fpsPerStream:p(),fingerprint:JH.nullable(),clip:YH.nullable(),contaminated:y(),stayingCameras:C(p()).readonly(),partialRun:y(),measuredAtMs:p()}),iU=x({nodeId:m().optional(),deviceKey:m().optional()}),aU=rU.extend({standing:S([`fresh`,`stale`,`superseded`]),staleWhy:S([`age`,`runtime`,`pool-tuning`]).nullable()}),oCe=x({runId:m(),nodeId:m(),startedAtMs:p(),deadlineAtMs:p(),plan:IH,moved:C(p()).readonly(),staying:C(p()).readonly()}),oU=x({nodeId:m(),reachable:y(),devices:C(x({deviceKey:m(),enabled:y(),available:y(),suggested:C(m()).readonly(),all:C(m()).readonly(),currentModelId:m().nullable()})).readonly(),steps:C(x({id:m(),name:m(),slot:m()})).readonly()}),sU=x({x:p(),y:p(),w:p(),h:p()}),cU=x({bytes:b(Uint8Array).optional(),jpeg:m().optional(),jpegBytes:b(Uint8Array).optional(),width:p().int().positive(),height:p().int().positive(),tier:S([`native`,`ram-fullframe`]).optional()}),lU=S([`keyFrame`,`thumbnail`]),uU=S([`handle-gone`,`encode-failed`]),dU=a(`parked`,[x({parked:s(!0),nodeId:m(),width:p().int().positive(),height:p().int().positive(),bytes:p().int().nonnegative(),replaced:y()}),x({parked:s(!1),nodeId:m(),reason:uU,handleAgeMs:p().nullable(),detail:m().optional()})]),fU=x({jpeg:m().optional(),jpegBytes:b(Uint8Array).optional(),width:p().int().positive(),height:p().int().positive(),timestamp:p(),parkedAt:p()}),sCe=x({bbox:sU,className:m()}),pU=x({stepId:m(),className:m(),score:p(),bbox:sU.optional(),embedding:m().optional(),embeddingMagnitude:p().optional(),embeddingModelId:m().optional(),label:m().optional(),labelTier:l([s(1),s(2)]).optional(),labelModelId:m().optional(),alignedCropJpeg:m().optional(),nativeFaceShortSidePx:p().optional(),landmarks:C(x({x:p(),y:p()})).optional()}),cCe=S([`unknown-step`,`model-not-servable`,`unreadable-frame`,`execution-failed`]),lCe=a(`kind`,[x({kind:s(`ran`),nodeId:m(),modelId:m(),details:C(pU)}),x({kind:s(`refused`),nodeId:m(),reason:cCe,detail:m()})]),mU={min:0,max:6e4,default:3e4,step:500},hU={min:0,max:6e5,default:12e4,step:5e3},gU={min:5e3,max:6e5,default:9e4,step:5e3},_U={min:1,max:30,default:4,step:1},vU={min:1,max:30,default:10,step:1},yU={min:0,max:300,default:300,step:5},bU={min:1,max:10,default:4,step:1},xU={min:0,max:30,default:12,step:1},SU=S([`onboard`,`analyzer`,`device-activity`]),CU=x({source:SU,triggeredBy:Mz,sensorName:m().optional()}),wU=C(SU),TU={analyzer:`Frame-diff Analyzer (motion addon)`,onboard:`Camera sensors`,"device-activity":`Device activity (the device says it is working)`};function EU(e){let t=SU.safeParse(e);return t.success?TU[t.data]:e}var uCe=[`analyzer`,`onboard`,`device-activity`],DU=oe(e=>Array.isArray(e)&&e.length>1?e.slice(0,1):e,C(JB).max(1)),OU=x({deviceId:p(),detected:y(),source:SU.default(`analyzer`),regions:C(Jz).readonly().optional()}),kU=a(`kind`,[x({kind:s(`local-broker`)}),x({kind:s(`remote-restream`),ownerNodeId:m(),ownerReachableHost:m().optional(),hubHostnameOverride:m().optional()})]).describe(`Per-camera frame-source mode for the runner (P2c)`),AU=x({modelId:m().optional(),settings:d(m(),u()).optional()}),jU=x({deviceKey:m(),weight:p().positive().default(1),maxSessions:p().int().positive().nullable().default(null),steps:d(m(),AU).optional()}),MU=x({deviceId:p(),detectionMode:S([`disabled`,`always-on`,`on-motion`]).default(`on-motion`),audioMode:S([`disabled`,`always-on`,`on-motion`]).default(`always-on`),motionCooldownMs:p().min(mU.min).default(mU.default),maxSessionHoldMs:p().min(hU.min).max(hU.max).optional(),audioMotionWindowMs:p().min(gU.min).max(gU.max).optional(),motionFps:p().min(_U.min).max(_U.max).default(_U.default),detectionFps:p().min(vU.min).max(vU.max).default(vU.default),motionStreamId:m(),detectionStreamId:m(),audioStreamPick:oc.optional(),motionSources:wU.default([`analyzer`]),sessionTrigger:CU.optional(),detectionSources:DU.default([`pipeline`]),pipelineEnabled:y().default(!0),steps:C(mH).readonly().optional(),audio:x({modelId:m().optional(),enabled:y()}).nullable().optional(),zones:C(jH).readonly().default([]),onboardMotionDrivesAnalyzer:y().default(!0),preRollInferenceEnabled:y().default(!0),preRollInferenceFrames:p().min(xU.min).max(xU.max).default(xU.default),occupancyRecheckEnabled:y().default(!0),occupancyRecheckSec:p().min(yU.min).max(yU.max).default(yU.default),occupancyRecheckFrames:p().min(bU.min).max(bU.max).default(bU.default),frameSource:kU.default({kind:`local-broker`}),deviceKey:m().optional(),inferenceDevices:C(jU).readonly().optional()}),dCe=[{key:`motionSources`,type:`multiselect`,label:`Motion Sources`,default:[`analyzer`],options:uCe.map(e=>e===`onboard`?{value:e,label:TU[e],description:`The camera's own motion, plus any sensor attached to it`}:{value:e,label:TU[e]})},{key:`motionFps`,type:`slider`,label:`Motion FPS (analyzer)`,min:_U.min,max:_U.max,step:_U.step,default:_U.default,showValue:!0,unit:`fps`,nullable:!0,nullLabel:`Default`,showWhen:{field:`motionSources`,includes:`analyzer`}},{key:`detectionFps`,type:`slider`,label:`Detection FPS`,min:vU.min,max:vU.max,step:vU.step,default:vU.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:mU.min,max:mU.max,step:mU.step,default:mU.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:hU.min,max:hU.max,step:hU.step,default:hU.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:gU.min,max:gU.max,step:gU.step,default:gU.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:xU.min,max:xU.max,step:xU.step,default:xU.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:yU.min,max:yU.max,step:yU.step,default:yU.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:bU.min,max:bU.max,step:bU.step,default:bU.default,showValue:!0,showWhen:{field:`occupancyRecheckEnabled`,equals:!0}}],NU=x({nodeId:m(),attachedCameras:p(),activeCameras:p(),avgInferenceFps:p(),avgInferenceTimeMs:p(),queueDepthTotal:p(),devices:C(x({deviceKey:m(),backend:m(),attachedCameras:p()})).default([]),hardware:x({hasGpu:y(),inferenceBackend:m().optional(),cpuCores:p().optional()}),motionSliceWriter:s(`orchestrator`).optional()}),PU=x({framesDecoded:p(),framesAdmitted:p(),framesDroppedPixelFree:p(),viewsMaterialized:p(),viewsSkipped:p(),workerToRunnerBytes:p(),runnerToPoolRawBytes:p(),runnerToPoolJpegBytes:p(),onDemandFullFrameRequests:p(),onDemandCropRequests:p(),nativeHits:p(),nativeMisses:p(),tileHits:p(),tileMisses:p(),fallbackHits:p(),fallbackMisses:p(),retainedWritesAvoided:p(),residentRefs:p(),residentBytes:p(),releases:p(),evictions:p(),staleMisses:p()}),FU=x({node:PU,cameras:C(PU.extend({deviceId:p()}))}),IU=x({nodeId:m(),activeCameras:p(),throttledCameras:p(),avgInferenceTimeMs:p(),queueDepth:p(),frameLazy:FU.optional()}),LU=S([`not-attached`,`battery-asleep`,`not-watching`,`already-bursting`]),RU={name:`pipeline-runner`,scope:`system`,mode:`singleton`,methods:{attachCamera:E(MU,x({success:s(!0)}),{kind:`mutation`}),detachCamera:E(x({deviceId:p()}),x({success:s(!0)}),{kind:`mutation`}),reportMotion:E(OU,x({success:s(!0)}),{kind:`mutation`}),getLocalLoad:E(v(),NU),getLocalMetrics:E(v(),IU),getCameraMetrics:E(x({deviceId:p()}),DH.nullable()),getAllCameraMetrics:E(v(),C(OH).readonly()),getLocalCameras:E(v(),C(p()).readonly()),requestOccupancyBurst:E(x({deviceId:p(),frames:p().int().positive().optional(),reason:m()}),x({started:y(),refusedBecause:LU.optional()}),{auth:`admin`,kind:`mutation`}),getNativeCrop:E(x({handle:hc,bbox:sU,maxWidth:p().int().positive().optional(),acceptJpegBytes:y().optional(),encodeJpeg:y().optional()}),cU.nullable()),runDetailSubtree:E(x({deviceId:p(),frameHandle:hc.optional(),frameJpeg:m().optional(),cropJpeg:m().optional(),parent:sCe,steps:C(m()).optional(),supplied:x({stepId:m(),modelId:m(),boxes:C(x({bbox:sU,score:p()})).min(1)}).optional()}),x({details:C(pU)}).nullable(),{kind:`mutation`}),runStatelessStep:E(x({stepId:m(),modelId:m(),frameJpeg:m(),bbox:sU,className:m(),sourceDeviceId:p()}),lCe,{kind:`mutation`}),parkTrackFrame:E(x({deviceId:p(),trackId:m(),kind:lU,handle:hc,bbox:sU,maxWidth:p().int().positive().optional(),timestamp:p()}),dU,{kind:`mutation`}),getParkedTrackFrame:E(x({deviceId:p(),trackId:m(),kind:lU,acceptJpegBytes:y().optional()}),fU.nullable()),releaseParkedTrackFrames:E(x({deviceId:p(),trackId:m()}),x({released:p().int().nonnegative()}),{kind:`mutation`}),startNodeBench:E(XH,x({accepted:s(!0),runId:m()}),{kind:`mutation`,auth:`admin`}),getNodeBenchStatus:E(x({runId:m()}),QH.nullable(),{auth:`admin`}),abortNodeBench:E(x({runId:m()}),x({aborted:y()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.PIPELINE}},zU=3e4,fCe={version:1,targets:[{id:`detected`,cardinality:`event`,shape:`span`,vocabulary:{cap:`motion`,eventName:`onMotionChanged`},deviceTypes:[j.Camera],apply:`add`,applyAuthority:{kind:`camera-sensors`,timeoutField:`motionCooldownMs`},eventName:`onMotionChanged`,start:`rising-edge`,end:`falling-edge-or-timeout`,timeoutMs:zU,combine:`any`,sourceModes:[`in-addition`,`confirm`,`replace`],sources:[{kind:`binary`},{kind:`switch`}],sourceReport:{status:`assignment-status`},advancedExpression:!1}]},pCe=15e3,BU=x({detected:y(),lastDetectedAt:p().nullable(),autoClearAfterMs:p().nullable().meta(k(`duration-ms`))}),VU=x({deviceId:p(),detected:y(),timestamp:p(),source:SU,regions:C(Jz).readonly().optional(),triggeredBy:Mz.optional()}),HU={name:`motion`,scope:`device`,mode:`singleton`,deviceNative:!0,deviceTypes:[j.Camera,j.Sensor],methods:{isDetected:E(x({deviceId:p()}),y())},composedMethods:{isDetected:{kind:`slice`,field:`detected`}},events:{onMotionChanged:{data:VU,notOperatorFacing:"the `detected` state trigger phrases both edges, from the mirror that survives a dropped event (D49)"}},status:{schema:BU,kind:`push`},runtimeState:BU,durability:`session`,history:{fields:{detected:{kind:`boolean`,excludeDeviceTypes:[j.Camera]}}},customize:fCe,vocabulary:{noun:I(`Motion`,`Movimento`),order:5130,state:[{kind:`boolean`,field:`detected`,label:I(`Motion`,`Movimento`),whenTrue:I(`When {device} detects motion`,`Quando {device} rileva movimento`),whenFalse:I(`When motion clears on {device}`,`Quando il movimento su {device} cessa`),icon:`activity`}]}},UU=x({enabled:y(),lastChangedAt:p()}),WU=UU.extend({lastFetchedAt:p()}),GU={name:`motion-trigger`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Light,j.Siren,j.Switch],methods:{setMotionTrigger:E(x({deviceId:p().int().nonnegative(),enabled:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`motionTrigger.on`,label:I(`Motion trigger on`,`Attivazione al movimento attiva`),phrase:I(`Let motion trigger {device}`,`Fai attivare {device} dal movimento`),icon:`activity`,effect:{field:`enabled`,value:!0},args:{enabled:!0}},{id:`motionTrigger.off`,label:I(`Motion trigger off`,`Attivazione al movimento spenta`),phrase:I(`Stop motion triggering {device}`,`Non far più attivare {device} dal movimento`),icon:`activity`,effect:{field:`enabled`,value:!1},args:{enabled:!1}}]})},events:{onMotionTriggerChanged:{data:x({deviceId:p(),enabled:y(),lastChangedAt:p()}),notOperatorFacing:"the `enabled` state trigger phrases both edges of this change"}},status:{schema:UU,kind:`command-driven`},runtimeState:WU,durability:`session`,history:`none`,vocabulary:{noun:I(`Motion trigger`,`Attivazione al movimento`),order:1160,state:[{kind:`boolean`,field:`enabled`,label:I(`Motion trigger`,`Attivazione al movimento`),whenTrue:I(`When motion triggering is turned on for {device}`,`Quando si attiva l’attivazione al movimento di {device}`),whenFalse:I(`When motion triggering is turned off for {device}`,`Quando si disattiva l’attivazione al movimento di {device}`),icon:`activity`}]}},KU=x({id:p(),enabled:y(),shape:tB}),qU=x({enabled:y(),sensitivity:p().meta(k(`none`)),regions:C(KU),lastFetchedAt:p()}),JU=x({maxRegions:p(),supportedShapes:C(rB),grid:aB,sensitivity:x({min:p(),max:p(),step:p()})}),YU=x({enabled:y().optional(),sensitivity:p().optional(),regions:C(KU).optional()}),XU={name:`motion-zones`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/motion-zones-grid`,tab:`motion`,label:`Motion Zones`}},methods:{getOptions:E(x({deviceId:p()}),JU),setZone:E(x({deviceId:p(),patch:YU}),v(),{kind:`mutation`,auth:`admin`})},status:{schema:qU,kind:`poll`},runtimeState:qU,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`Motion zones`,`Zone di movimento`),order:3170}},mCe=S([`external`,`embedded`]),hCe=S([`connected`,`disconnected`,`auth-failed`,`unreachable`,`tls-error`]),ZU=x({id:m(),name:m(),url:m(),kind:mCe,status:hCe,latencyMs:p().nullable(),error:m().optional(),connectedClients:p().int().nonnegative().optional(),lastCheckedAt:p().optional()}),QU=x({url:m(),username:m().optional(),password:m().optional(),clientIdPrefix:m().optional()}),$U=x({name:m().min(1),url:m().regex(/^(mqtt|mqtts|ws|wss):\/\//,`URL must start with mqtt(s):// or ws(s)://`),username:m().optional(),password:m().optional(),clientIdPrefix:m().optional()}),gCe=x({id:m()}),eW=x({id:m()}),tW=x({port:p().int().min(1).max(65535).default(1883),allowAnonymous:y().default(!1),username:m().optional(),password:m().optional()}),_Ce=x({id:m(),url:m()}),nW=x({brokerCount:p(),embeddedRunning:y()}),rW={name:`mqtt-broker`,scope:`system`,mode:`collection`,providerKind:`broker`,status:{schema:nW,kind:`poll`},methods:{listBrokers:E(v(),C(ZU)),getBrokerConfig:E(eW,QU,{auth:`admin`}),addBroker:E($U,gCe,{kind:`mutation`,auth:`admin`}),removeBroker:E(eW,v(),{kind:`mutation`,auth:`admin`}),startEmbeddedBroker:E(tW,_Ce,{kind:`mutation`,auth:`admin`}),stopEmbeddedBroker:E(eW,v(),{kind:`mutation`,auth:`admin`}),getStatus:E(v(),nW)},vocabulary:{notOperatorFacing:O.NETWORK}},iW=S([`person`,`vehicle`,`animal`,`face`,`package`,`other`]),aW=x({class:iW,timestamp:p(),confidence:p().min(0).max(1).optional()}),oW=x({lastByClass:r(iW,aW.nullable()),supportedClasses:C(iW).readonly(),enabled:y()}),sW=S([`boxed`,`while-streaming`,`flag-only`]),cW=x({supportedClasses:C(iW).readonly(),geometry:sW}),lW=x({enabled:y().optional()}),uW=oW.extend({lastFetchedAt:p()}),dW={name:`native-object-detection`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],methods:{getOptions:E(x({deviceId:p()}),cW),setSettings:E(x({deviceId:p(),settings:lW}),v(),{kind:`mutation`,auth:`admin`}),setEnabled:E(x({deviceId:p(),enabled:y()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`nativeDetection.on`,label:I(`On-camera detection on`,`Rilevamento a bordo attivo`),phrase:I(`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:I(`On-camera detection off`,`Rilevamento a bordo spento`),phrase:I(`Turn off the on-camera detection of {device}`,`Disattiva il rilevamento a bordo di {device}`),icon:`scan-eye`,args:{enabled:!1}}]})},events:{onDetected:{data:x({deviceId:p(),detection:aW}),trigger:{category:w.DetectionCameraNative,label:I(`Camera spotted something`,`La telecamera ha rilevato qualcosa`),phrase:I(`When {device} spots something with its own detector`,`Quando {device} rileva qualcosa con il proprio rilevatore`),icon:`scan-eye`}}},status:{schema:oW,kind:`push`},runtimeState:uW,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`On-camera detection`,`Rilevamento a bordo`),order:3180,state:[{kind:`boolean`,field:`enabled`,label:I(`On-camera detection`,`Rilevamento a bordo`),whenTrue:I(`When the on-camera detection of {device} is turned on`,`Quando si attiva il rilevamento a bordo di {device}`),whenFalse:I(`When the on-camera detection of {device} is turned off`,`Quando si disattiva il rilevamento a bordo di {device}`),icon:`scan-eye`}]}},fW=x({pan:p().min(-1).max(1).optional(),tilt:p().min(-1).max(1).optional(),speed:p().min(0).max(1).optional()}),pW=S([`goHome`,`locate`,`spotClean`,`findPet`,`personFollow`,`stop`,`startClean`,`pauseClean`,`dockWash`,`autoEmpty`,`flashOn`,`flashOff`]),mW=S([`action`,`sound`]),hW=x({id:m(),kind:mW,label:m(),icon:m(),soundId:p().int().optional(),enabled:y()}),vCe=[{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}],gW=x({x:p(),y:p()}),_W=x({move:y(),stop:y(),goToPoint:y(),runAction:y(),playSound:y(),light:y(),lightMode:y()}),vW=S([`auto`,`manual`]),yW=S([`idle`,`cleaning`,`spot`,`following`,`goto`,`returning`,`paused`,`unknown`]),bW=x({mode:yW,following:y(),flash:y(),lightMode:vW,lightLevel:p().min(40).max(100).meta(k(`none`)),lastChangedAt:p()}),xW=bW.extend({lastFetchedAt:p()}),SW={name:`navigation`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/navigation-panel`,tab:`navigation`,topTab:!0,label:`Navigation`,order:0}},methods:{move:E(fW.extend({deviceId:p()}),v(),{kind:`mutation`,notOperatorFacing:`joystick control from the live view — continuous, not a discrete step`}),stop:E(x({deviceId:p()}),v(),{kind:`mutation`,actions:[{id:`navigation.stop`,label:I(`Stop`,`Ferma`),phrase:I(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),goToPoint:E(gW.extend({deviceId:p()}),v(),{kind:`mutation`,notOperatorFacing:`tap-to-go on the live map — the point only means something on that picture`}),listActions:E(x({deviceId:p()}),C(hW)),runAction:E(x({deviceId:p(),actionId:pW}),v(),{kind:`mutation`,actions:[{id:`navigation.runAction`,label:I(`Run a routine`,`Esegui una routine`),phrase:I(`Have {device} {actionId}`,`Fai eseguire a {device}: {actionId}`),icon:`bot`,openArgs:[{key:`actionId`,label:I(`Routine`,`Routine`),offer:{kind:`enum`,values:[{value:`goHome`,label:I(`go home`,`torna alla base`)},{value:`locate`,label:I(`beep so you can find it`,`suona per farsi trovare`)},{value:`spotClean`,label:I(`clean this spot`,`pulisci questo punto`)},{value:`findPet`,label:I(`find the pet`,`cerca l’animale`)},{value:`personFollow`,label:I(`follow a person`,`segui una persona`)},{value:`stop`,label:I(`stop`,`fermati`)},{value:`startClean`,label:I(`start cleaning`,`inizia a pulire`)},{value:`pauseClean`,label:I(`pause cleaning`,`metti in pausa la pulizia`)},{value:`dockWash`,label:I(`wash the mop at the dock`,`lava il mocio alla base`)},{value:`autoEmpty`,label:I(`empty the bin at the dock`,`svuota il contenitore alla base`)},{value:`flashOn`,label:I(`turn the flash on`,`accendi il flash`)},{value:`flashOff`,label:I(`turn the flash off`,`spegni il flash`)}]}}]}]}),playSound:E(x({deviceId:p(),soundId:p().int()}),v(),{kind:`mutation`,actions:[{id:`navigation.playSound`,label:I(`Play sound`,`Riproduci un suono`),phrase:I(`Play {soundId} on {device}`,`Riproduci {soundId} su {device}`),icon:`volume-2`,openArgs:[{key:`soundId`,label:I(`Sound`,`Suono`),offer:{kind:`dynamic`,from:`method`,method:`listActions`,valueKey:`soundId`,labelKey:`label`,where:{key:`kind`,equals:`sound`},valueKind:`number`}}]}]}),setLightOn:E(x({deviceId:p(),on:y()}),v(),{kind:`mutation`,actions:[{id:`navigation.lightOn`,label:I(`Light on`,`Luce accesa`),phrase:I(`Turn on the light of {device}`,`Accendi la luce di {device}`),icon:`lightbulb`,args:{on:!0}},{id:`navigation.lightOff`,label:I(`Light off`,`Luce spenta`),phrase:I(`Turn off the light of {device}`,`Spegni la luce di {device}`),icon:`lightbulb-off`,args:{on:!1}}]}),setLightMode:E(x({deviceId:p(),mode:vW,level:p().min(40).max(100).optional()}),v(),{kind:`mutation`,actions:[{id:`navigation.lightAuto`,label:I(`Light automatic`,`Luce automatica`),phrase:I(`Set the light of {device} to automatic`,`Metti la luce di {device} in automatico`),icon:`lightbulb`,args:{mode:`auto`}}]}),setLightLevel:E(x({deviceId:p(),level:p().min(40).max(100)}),v(),{kind:`mutation`,actions:[{id:`navigation.lightLevel`,label:I(`Set light level`,`Imposta la luce`),phrase:I(`Set the light of {device} to {level}`,`Imposta la luce di {device} al {level}`),icon:`sun-medium`,openArgs:[{key:`level`,label:I(`Level`,`Livello`),offer:{kind:`number`,min:40,max:100,step:1,unit:`%`}}]}]}),getFeatures:E(x({deviceId:p()}),_W)},events:{onStatusChanged:{data:x({deviceId:p(),status:bW}),notOperatorFacing:"the `mode` state trigger reads the same change"}},status:{schema:bW,kind:`push`},runtimeState:xW,durability:`session`,history:`none`,vocabulary:{noun:I(`Robot movement`,`Movimento del robot`),order:2080,state:[{kind:`enum`,field:`mode`,label:I(`Activity`,`Attività`),values:[{value:`idle`,label:I(`Idle`,`Inattivo`)},{value:`cleaning`,label:I(`Cleaning`,`In pulizia`)},{value:`spot`,label:I(`Spot cleaning`,`Pulizia localizzata`)},{value:`following`,label:I(`Following`,`In inseguimento`)},{value:`goto`,label:I(`Moving to a point`,`In movimento verso un punto`)},{value:`returning`,label:I(`Returning`,`In rientro`)},{value:`paused`,label:I(`Paused`,`In pausa`)},{value:`unknown`,label:I(`Unknown`,`Sconosciuto`)}],icon:`bot`}]}},CW=x({url:m(),hostname:m(),port:p(),protocol:S([`http`,`https`]),stable:y().optional()}),yCe=x({url:m(),stable:y().optional(),updated:y().optional()}),wW=x({connected:y(),endpoint:CW.nullable(),error:m().optional()}),bCe=CW.extend({id:m(),label:m(),mode:m().optional(),sourcePort:p().optional()}),TW={name:`network-access`,scope:`system`,mode:`collection`,providerKind:`ingress`,methods:{start:E(v(),CW,{kind:`mutation`}),stop:E(v(),v(),{kind:`mutation`}),getEndpoint:E(v(),CW.nullable()),getStatus:E(v(),wW),listEndpoints:E(v(),C(bCe).readonly())},vocabulary:{notOperatorFacing:O.NETWORK}},EW=[`wifi`,`ethernet`,`cellular`,`unknown`],DW=x({type:S(EW),signal:p().min(0).max(100).nullable().meta(k(`percentage`)),rssi:p().optional().meta(k(`signal-level`)),ssid:m().optional(),lastUpdated:p().meta(k(`none`))}),OW={type:`unknown`,signal:null,lastUpdated:0};function xCe(e,t){return e===void 0||!Number.isFinite(e)||t<=0||e<0||e>t?null:Math.round(e/t*100)}function SCe(e){return e===void 0||!Number.isFinite(e)||e>0?null:Math.round((Math.min(-50,Math.max(-100,e))+100)*2)}var kW={name:`network-link`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera,j.Sensor,j.Button,j.Switch,j.Light,j.Lock,j.Siren],methods:{},events:{onStatusChanged:{data:x({deviceId:p(),status:DW}),notOperatorFacing:`the signal / link-type state triggers each read one field of this change`}},status:{schema:DW,kind:`push`,empty:OW},runtimeState:DW,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:I(`Network link`,`Collegamento di rete`),order:5250,state:[{kind:`numeric`,field:`signal`,quantity:I(`the signal strength`,`l’intensità del segnale`),label:I(`Signal`,`Segnale`),unit:`%`,icon:`wifi`},{kind:`enum`,field:`type`,label:I(`Link type`,`Tipo di collegamento`),values:[{value:`wifi`,label:I(`Wi-Fi`,`Wi-Fi`)},{value:`ethernet`,label:I(`Ethernet`,`Ethernet`)},{value:`cellular`,label:I(`Cellular`,`Rete mobile`)},{value:`unknown`,label:I(`Unknown`,`Sconosciuto`)}],icon:`network`}]}},AW=x({nominalBitrateKbps:p(),observedBitrateKbps:p(),peakBitrateKbps:p(),packetLossPercent:p(),lastUpdated:p()}),jW=x({rttMs:p(),jitterMs:p(),estimatedBandwidthKbps:p(),packetLossPercent:p().min(0).max(100),downlinkMbps:p().optional(),downlinkAgeMs:p().optional(),lastUpdated:p()}),MW=x({deviceId:p(),streams:d(m(),AW),client:jW.optional()}),NW={name:`network-quality`,scope:`system`,mode:`singleton`,methods:{getDeviceStats:E(x({deviceId:p()}),MW.nullable()),getAllStats:E(v(),C(MW).readonly()),reportClientStats:E(x({deviceId:p(),rttMs:p().min(0).max(6e4),jitterMs:p().min(0).max(1e4),estimatedBandwidthKbps:p().min(0).max(1e6),packetLossPercent:p().min(0).max(100),downlinkMbps:p().min(0).max(1e5).optional(),downlinkAgeMs:p().min(0).max(864e5).optional()}),v(),{role:`viewer`,kind:`mutation`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:O.NETWORK}},PW=x({cn:m(),serial:m(),fingerprintSha256:m(),notBefore:p(),notAfter:p()}),FW=x({fingerprintSha256:m(),issuer:m(),sans:C(m()),notBefore:p(),notAfter:p()}),IW=a(`state`,[x({state:s(`served`),leaf:FW}),x({state:s(`not-issued`),reason:m()})]),LW={name:`node-certificates`,scope:`system`,mode:`singleton`,internal:!0,methods:{getCertificates:E(x({}),x({nodeId:m(),mesh:PW.nullable(),https:IW}),{auth:`admin`}),prepareMeshRenewal:E(x({}),x({csrPem:m()}),{kind:`mutation`,auth:`admin`}),installMeshLeaf:E(x({certPem:m().min(1),caCertPem:m().min(1),confirmWithinMs:p().int().min(1e4).max(6e5)}),x({fingerprintSha256:m(),serial:m()}),{kind:`mutation`,auth:`admin`}),confirmMeshLeaf:E(x({fingerprintSha256:m()}),x({confirmed:y()}),{kind:`mutation`,auth:`admin`}),rollbackMeshLeaf:E(x({}),x({rolledBack:y()}),{kind:`mutation`,auth:`admin`}),prepareHttpsCertificate:E(x({}),x({csrPem:m(),hostnames:C(m()),addresses:C(m()),pinnedCaFingerprintSha256:m().nullable()}),{kind:`mutation`,auth:`admin`}),forgetHub:E(x({}),x({ok:s(!0)}),{kind:`mutation`,auth:`admin`}),installHttpsCertificate:E(x({certPem:m().min(1),caCertPem:m().min(1),caRotation:y().optional()}),FW,{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:O.IDENTITY}},RW=x({nodeId:m().min(1),removedAt:p()}),zW=x({counts:d(m(),p().int().nonnegative())}),BW={name:`node-removal-hook`,scope:`system`,mode:`collection`,internal:!0,methods:{onNodeRemoved:E(RW,zW,{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:O.INTERNAL}},VW=x({addonId:m(),capabilities:C(m()).readonly(),status:m()}),HW=x({pid:p(),name:m(),state:m(),cpuPercent:p(),memoryRss:p(),uptimeSeconds:p(),services:C(VW).readonly(),groupId:m().optional()}),CCe=x({id:m(),status:m(),cpuPercent:p(),memoryRss:p()}),wCe=x({category:m(),total:p(),healthy:p(),addons:C(CCe).readonly()}),TCe=x({name:m(),version:m()}),UW=x({id:m(),name:m(),hostname:m(),platform:m(),arch:m(),cpuModel:m().nullable(),cpuCores:p(),memoryMB:p(),engines:C(m()).readonly(),isHub:y(),isOnline:y(),cpuPercent:p(),memoryPercent:p().nullable(),uptime:p(),lastSeen:m(),localIps:C(m()).readonly(),addons:C(x({id:m(),capabilities:C(m()).readonly(),status:m()})).readonly(),processes:C(HW).readonly(),categories:C(wCe).readonly(),rootPackage:TCe.nullable(),meshTransport:S([`tls`,`clear`]).optional(),capabilitiesRegistered:y().optional()}),ECe=x({callerAddonId:m(),providerAddonId:m(),capName:m(),callsPerMin:p(),lastCallAtMs:p()}),WW=x({nodeId:m(),name:m(),version:m(),status:m(),synced:y()}),GW=x({hubVersion:m(),nodes:C(WW)}),KW=x({nodeId:m(),addonId:m()}),DCe=x({id:m(),status:m(),version:m().optional(),packageName:m().optional()}),qW=x({success:y()}),OCe=x({success:y(),reason:m().optional()}),kCe=x({restarted:C(m()).readonly(),failed:C(m()).readonly()}),ACe=x({nodeId:m(),name:m()}),JW=x({id:m(),name:m(),isHub:y(),isOnline:y()}),YW=x({nodes:C(JW).readonly(),complete:y()}),XW={name:`nodes`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,methods:{topology:E(v(),C(UW).readonly(),{auth:`admin`}),directory:E(v(),YW,{auth:`admin`}),deployAddon:E(KW,qW,{kind:`mutation`,auth:`admin`}),undeployAddon:E(KW,qW,{kind:`mutation`,auth:`admin`}),restartAddon:E(KW,qW,{kind:`mutation`,auth:`admin`}),restartProcess:E(x({nodeId:m(),processName:m()}),OCe,{kind:`mutation`,auth:`admin`}),restartNode:E(x({nodeId:m()}),kCe,{kind:`mutation`,auth:`admin`}),shutdownNode:E(x({nodeId:m()}),qW,{kind:`mutation`,auth:`admin`}),renameNode:E(x({nodeId:m(),name:m().min(1).max(64)}),ACe,{kind:`mutation`,auth:`admin`}),clusterAddonStatus:E(v(),d(m(),GW),{auth:`admin`}),getCapUsageGraph:E(x({windowSeconds:p().int().positive().max(300).default(60)}),C(ECe).readonly(),{auth:`admin`}),getNodeAddons:E(x({nodeId:m()}),C(DCe).readonly(),{auth:`admin`}),setProcessLogLevel:E(x({nodeId:m(),level:m()}),qW,{kind:`mutation`,auth:`admin`}),executeQuery:E(x({nodeId:m(),addonId:m(),queryName:m(),params:d(m(),u()).optional()}),u(),{kind:`mutation`,auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:O.CLUSTER}},ZW=[{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`}],QW={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},$W={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},eG=new Map;for(let[e,t]of Object.entries(QW.mapping))eG.set(e.toLowerCase(),t);for(let[e,t]of Object.entries($W.mapping))eG.set(e.toLowerCase(),t);function jCe(e){return eG.get(e.toLowerCase())??null}function MCe(){return ZW.map(e=>e.id)}var tG=pM();function nG(e){return vM(tG.swatches,tG.fallbacks,e)}function NCe(e){let t=e[0];if(t===void 0)throw Error(`display palette has no fallback colour`);return t}var PCe=NCe(tG.fallbacks);function FCe(e){return e.split(/[-_ ]/).filter(e=>e.length>0).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}var rG=new Map;function iG(e,t,n,r){rG.set(e,{kind:e,parentKind:null,level:`macro`,category:t,color:nG(e),iconId:n,labelKey:`eventKind.${e}`,label:r})}function aG(e,t,n,r,i){rG.set(e,{kind:e,parentKind:t,level:`sub`,category:n,color:nG(e),iconId:r,labelKey:`eventKind.${e}`,label:i})}iG(`motion`,`motion`,`motion`,`Motion`),iG(`audio`,`audio`,`audio`,`Audio`),iG(`person`,`detection`,`person`,`Person`),iG(`vehicle`,`detection`,`vehicle`,`Vehicle`),iG(`animal`,`detection`,`animal`,`Animal`),iG(`package`,`package`,`package`,`Package`),iG(`sensor`,`sensor`,`sensor`,`Sensor`),iG(`control`,`control`,`control`,`Control`);for(let[e,t]of Object.entries(Ah.mapping))t!==`vehicle`&&t!==`animal`||rG.has(e)||aG(e,t,`detection`,e,FCe(e));aG(`package-delivered`,`package`,`package`,`package`,`Package delivered`),aG(`package-picked-up`,`package`,`package`,`package`,`Package picked up`),aG(`contact`,`sensor`,`sensor`,`door`,`Contact`),aG(`motion-sensor`,`sensor`,`sensor`,`pir`,`Motion sensor`),aG(`smoke`,`sensor`,`sensor`,`smoke`,`Smoke`),aG(`flood`,`sensor`,`sensor`,`water`,`Water leak`),aG(`gas`,`sensor`,`sensor`,`gas`,`Gas`),aG(`carbon-monoxide`,`sensor`,`sensor`,`smoke`,`Carbon monoxide`),aG(`vibration`,`sensor`,`sensor`,`vibration`,`Vibration`),aG(`tamper`,`sensor`,`sensor`,`tamper`,`Tamper`),aG(`presence`,`sensor`,`sensor`,`presence`,`Presence`),aG(`enum-sensor`,`sensor`,`sensor`,`generic`,`Sensor state`),aG(`device-event`,`sensor`,`sensor`,`button`,`Device event`),aG(`lock`,`control`,`control`,`lock`,`Lock`),aG(`cover`,`control`,`control`,`door`,`Cover`),aG(`switch`,`control`,`control`,`switch`,`Switch`),aG(`siren`,`control`,`control`,`siren`,`Siren`),aG(`button`,`control`,`control`,`button`,`Button`),aG(`doorbell`,`control`,`control`,`doorbell`,`Doorbell`),aG(`appliance-cycle`,`control`,`control`,`switch`,`Appliance cycle`);for(let e of ZW){let t=`audio-${e.id}`;rG.has(t)||aG(t,`audio`,`audio`,t,e.name)}var oG=Object.freeze(Object.fromEntries(rG));function sG(e){return oG[e]}function ICe(e){return nG(e)}function LCe(e){let t=[];for(let n of Object.values(oG))n.parentKind===e&&t.push(n);return t}var cG=x({kind:m(),label:m(),parentKind:m().nullable()}),lG=x({videoClasses:C(cG),audioKinds:C(cG),labels:C(cG)});function uG(e,t,n){return{kind:e,label:t,parentKind:n}}function dG(){let e=Object.values(oG);return{videoClasses:e.filter(e=>e.category===`detection`).map(e=>uG(e.kind,e.label,e.parentKind)),audioKinds:e.filter(e=>e.category===`audio`&&e.level===`sub`).map(e=>uG(e.kind,e.label,e.parentKind)),labels:e.filter(e=>e.category===`sensor`||e.category===`control`).map(e=>uG(e.kind,e.label,e.parentKind))}}var RCe=Object.freeze(dG()),fG=S([`immediate`,`track-end`,`device-event`,`package-event`,`system-event`]),pG=S(`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(`.`)),mG=[`camera-online`,`camera-offline`,`camera-disabled`,`camera-enabled`],zCe=new Set(mG),BCe=pG.options.filter(e=>!zCe.has(e)),hG=[`alarm-arm-refused`,`alarm-check-failed`,`alarm-arming`,`alarm-armed`,`alarm-pending`,`alarm-triggered`,`alarm-rearmed`,`alarm-sensor-bypass`,`alarm-disarmed`],gG=[`device-battery-low`,`device-battery-normal`,`device-consumable-low`,`device-consumable-normal`],_G=[`device-consumable-low`,`device-consumable-normal`],vG=[`confirmed`,`already`,`unconfirmed`,`failed`],yG=[`user`,`addon`,`action`,`scheduler`,`composition`,`node`],bG=x({kinds:C(pG).min(1),deviceIds:C(p().int()).min(1).optional(),deviceTypes:C(m().min(1)).min(1).optional(),excludeDeviceIds:C(p().int()).min(1).optional(),nodeIds:C(m().min(1)).min(1).optional(),packageNames:C(m().min(1)).min(1).optional(),commandActions:C(m().min(1)).min(1).optional(),commandOutcomes:C(S(vG)).min(1).optional(),commandActorKinds:C(S(yG)).min(1).optional(),consumableLowPercent:p().int().min(1).max(95).optional()});function VCe(e){return e.consumableLowPercent??15}var xG=1440,HCe=[10,30,60],SG=x({days:C(p().int().min(0).max(6)).min(1),startMinute:p().int().min(0).max(1439),endMinute:p().int().min(0).max(1439)}),CG=x({windows:C(SG).min(1),timezone:m().optional(),invert:y().optional()}),wG=S([`instant`,`summary`]),UCe=S([`activation`,`deactivation`,`schedule`]),TG=S([`rule`,`section`]),EG=a(`mode`,[x({mode:s(`instant`)}),x({mode:s(`summary`),schedule:CG,split:TG.optional()}),x({mode:s(`modes`),onActivation:y(),onDeactivation:y(),onSchedule:x({schedule:CG,grouping:TG}).optional()})]),DG=x({values:C(m().min(1)),maxDistance:p().int().min(0).max(3).default(1)}),OG=x({zoneId:m().optional(),className:m().optional(),op:S([`became-occupied`,`became-free`,`>=`,`<=`]).default(`became-occupied`),count:p().int().min(0).default(1),sustainSeconds:p().int().min(0).max(3600).default(15)}),kG=x({labels:C(m().min(1)).min(1).optional(),dbThreshold:p().min(-96).max(0).optional(),hitPercent:p().int().min(1).max(100).default(60),samplingSeconds:p().int().min(1).max(300).default(10),confirmHits:p().int().min(1).max(20).optional(),confirmWindowSec:p().int().min(1).max(60).optional()}),AG=S([`enter`,`exit`,`any`]),jG=S([`raised`,`cleared`]),MG=x({ids:C(m().min(1)).min(1),match:S([`any`,`all`]).optional()}),NG=m().min(1),PG=C(NG).max(4),FG=x({id:m().min(1).max(64),label:m().min(1).max(40),actionId:NG,icon:di.optional(),destructive:y().optional()}),IG=x({onActivation:PG.optional(),onDeactivation:PG.optional(),onTrigger:PG.optional(),onTriggerOff:PG.optional(),buttons:C(FG).max(8).optional()}),LG=x({deviceId:p().int(),states:C(m().min(1)).min(1)}),RG=x({sceneId:m().min(1),deviceId:p().int().optional(),requiredState:S([`matched`,`diverged`]),latched:y().optional()}),zG=x({deviceState:LG.optional(),scene:RG.optional(),devices:C(p()).optional(),devicesExclude:C(p()).min(1).optional(),classes:C(m().min(1)).optional(),classesExclude:C(m().min(1)).optional(),minConfidence:p().min(0).max(1).optional(),zones:MG.optional(),zonesExclude:C(m().min(1)).optional(),crossing:AG.optional(),labelEquals:C(m().min(1)).optional(),identities:C(m().min(1)).optional(),plates:DG.optional(),identitiesExclude:C(m().min(1)).optional(),minImportance:p().min(0).max(1).optional(),minDwellSeconds:p().min(0).optional(),source:S([`pipeline`,`onboard`,`sensor`,`audio`,`any`]).optional(),minLabelConfidence:p().min(0).max(1).optional(),eventTypeTokens:C(m().min(1)).optional(),sensorKinds:C(m().min(1)).optional(),sensorTransition:jG.optional(),packagePhase:S([`delivered`,`picked-up`,`both`]).optional(),systemEvent:bG.optional(),customZones:C(eB).optional(),occupancy:OG.optional(),audio:kG.optional()}),BG=x({targetId:m().min(1),params:d(m(),u()).optional()}),VG=S([`none`,`image`,`clip`,`gif`]),HG=x({template:x({title:m().max(500).optional(),body:m().max(2e3).optional()}).optional(),schedule:CG.optional(),priority:p().int().min(1).max(5).optional(),attachment:VG.optional(),actions:y().optional()}),UG=d(m(),HG),WG=S([`scene-boxes`,`crop`,`clean`,`none`]),GG=S([`cropped`,`full`,`boxed`]),KG=S([`mosaic`,`each`]),qG=x({image:WG.optional(),showTriggerZone:y().optional(),showSubjectPath:y().optional(),attach:S([`best`,`best-matching`,`keyFrame`,`none`]).optional(),frame:GG.optional(),zoneCrop:y().optional(),gif:y().optional(),clip:y().optional(),clipPreRollSec:p().int().min(0).max(30).optional(),clipPostRollSec:p().int().min(0).max(30).optional(),clipSpeed:p().min(1).max(8).optional(),profile:A.optional(),linkedCameras:KG.optional(),wakeSleepingCamera:y().optional()}),JG=S([`shared`,`per-class`]),YG=x({cooldownSec:p().int().min(0).max(86400).default(60),scope:S([`rule`,`rule-device`]).default(`rule-device`),granularity:JG.optional()}),XG=1e3,ZG=2e4,QG=8e3,$G=x({op:S([`>=`,`>`,`<=`,`<`,`==`]),count:p().int().min(0).max(1e3)}),eK=x({enabled:y().default(!1),profileId:m().optional(),prompt:m().max(1e3).optional(),expect:$G.optional(),timeoutMs:p().int().min(XG).max(ZG).default(QG),onTimeout:S([`fire`,`suppress`]).default(`fire`),maxImagePx:p().int().min(64).max(2048).default(448)}),tK=x({name:m().min(1).max(200),enabled:y().default(!0),delivery:fG,conditions:zG.default({}),schedule:CG.optional(),systemEventDelivery:EG.optional(),targets:C(BG),targetUsers:C(m()).optional(),targetOverrides:UG.optional(),media:qG.default({}),throttle:YG.default({cooldownSec:60,scope:`rule-device`}),template:x({title:m().max(500).optional(),body:m().max(2e3).optional()}).optional(),priority:p().int().min(1).max(5).default(3),ownerUserId:m().optional(),snoozeAllowGlobal:y().optional(),snoozeOptions:C(p().int().min(1).max(xG)).max(4).optional(),actions:IG.optional(),confirm:eK.optional(),groupingSec:p().int().min(5).max(60).optional(),groupWithinSec:p().int().min(0).max(300).optional(),askVerdict:y().optional()}),nK=tK.partial().extend({disabledTargetIds:C(m()).optional(),enabled:y().optional(),conditions:zG.optional(),media:qG.optional(),throttle:YG.optional(),priority:p().int().min(1).max(5).optional()}),rK=[`waitForEnhancement`,`groupIdleSec`];function WCe(e){return rK.some(t=>t===e)}var iK=[`template`,`schedule`,`targetUsers`,`snoozeOptions`,`snoozeAllowGlobal`,`actions`,`confirm`,`groupingSec`,`waitForEnhancement`,`groupIdleSec`],aK=S(iK),oK=x({ruleId:m(),patch:nK,clear:C(aK).optional()}),sK=tK.extend({id:m(),createdBy:m(),createdAt:p(),updatedAt:p(),disabledTargetIds:C(m()).default([])}),cK=[`device-state`,`streams`,`battery`,`consumables`,`detection-blind`,`nodes`,`addons`,`addon-updates`,`updates`],lK=S(cK),uK=x({id:lK,status:S([`read`,`unavailable`]),items:p().int().nonnegative(),reason:m().optional()}),dK=x({section:lK.optional(),title:m(),text:m(),count:p().int().nonnegative()}),fK=x({empty:y(),count:p().int().nonnegative(),text:m(),sections:C(uK),dropped:d(m(),p().int().nonnegative()),excludedGroups:C(m()),split:TG.optional(),rows:C(dK).optional()}),pK=x({recordId:m(),recordKind:S([`object-event`,`track`,`device-event`,`package-event`,`system-event`]),deviceId:p(),timestamp:p(),wouldFire:y(),failedCondition:m().optional(),className:m().optional(),label:m().optional()}),mK=S([`detection`,`sensor`,`occupancy`,`sound`,`device-events`,`system`,`alarm`,`mixed`]),hK=S([`detection`,`sensor`,`occupancy`,`sound`,`system`]),gK=x({id:S([`appliance-cycle`]),kind:mK,title:m(),body:m()}),_K=S([`rule`,`timelapse`,`summary`]),vK=S([`title`,`body`,`previewText`,`captionText`]),yK=S([`subject`,`place`,`time`,`rule`,`occupancy`,`sound`,`sensor`,`system`,`digest`,`ai`]),bK=x({name:m().regex(/^\w+$/),label:m(),description:m().optional(),example:m(),group:yK,families:C(_K).min(1),fields:C(vK).optional(),kinds:C(hK).optional(),deliveries:C(fG).optional(),systemEventKinds:C(pG).optional(),systemEventDeliveries:C(wG).optional(),dynamic:x({prefix:s(`count_`),from:s(`classes`)}).optional()}),xK=x({family:_K,field:vK,kind:mK.optional(),delivery:fG.optional(),systemEventKinds:C(pG).optional(),systemEventDelivery:wG.optional()}),SK=x({context:xK,template:x({title:m().max(500).optional(),body:m().max(2e3).optional()})}),CK=x({title:m().nullable(),body:m().nullable(),unknown:C(m())}),wK=x({id:m(),group:S([`scope`,`class`,`zones`,`quality`,`label`,`schedule`,`device`,`package`,`occupancy`,`audio`,`system`]),label:m(),valueType:S([`deviceIdList`,`deviceIdExcludeList`,`stringList`,`number01`,`number`,`sourceSelect`,`zoneSelection`,`zoneIdList`,`schedule`,`plateMatcher`,`packagePhase`,`crossingSelect`,`sensorTransition`,`polygonDraw`,`occupancy`,`audio`,`deviceState`,`scene`,`systemEvent`]),operator:S([`in`,`notIn`,`anyOf`,`allOf`,`gte`,`fuzzyIn`,`withinSchedule`]),appliesTo:C(fG),phase:m(),description:m().optional(),options:C(x({value:m(),label:m(),hint:m().optional()})).readonly().optional()}),TK=[{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.`}],EK=S([`pending`,`sent`,`dead`]),DK=S([`object-event`,`track-end`,`device-event`,`package-event`,`system-event`]),OK=x({className:m(),label:m().optional(),confidence:p().optional(),zones:C(m()),timestamp:p(),systemEvent:x({kind:pG,subject:m(),title:m(),body:m(),data:d(m(),u())}).optional()}),kK=x({id:m(),ruleId:m(),ruleName:m(),delivery:fG,targetId:m(),deviceId:p(),recordKind:DK,recordId:m(),trackId:m().optional(),status:EK,attempts:p().int(),createdAt:p(),updatedAt:p(),error:m().optional(),subject:OK,title:m().optional(),body:m().optional(),artifactIds:C(m().min(1)).optional(),groupedInto:m().min(1).optional()}),AK=x({ruleId:m().optional(),deviceId:p().optional(),status:EK.optional(),since:p().optional(),until:p().optional(),limit:p().int().min(1).max(500).default(100)}),jK=x({ruleId:m(),lastAt:p(),status:EK,deviceId:p()}),MK=x({runs:C(jK),horizonMs:p().nonnegative().nullable()}),NK=S([`rule`,`device`,`all`]),PK=x({scope:NK,ruleId:m().optional(),deviceId:p().int().optional(),classes:C(m().min(1)).min(1).optional(),durationMinutes:p().int().min(1).max(xG),global:y().optional(),summary:y().optional()}),FK=x({id:m(),userId:m(),scope:NK,ruleId:m().optional(),deviceId:p().int().optional(),classes:C(m().min(1)).min(1).optional(),startedAt:p(),expiresAt:p(),global:y(),summary:y(),digestSentAt:p().optional()}),GCe=x({snoozeId:m(),targetId:m(),ruleId:m(),ruleName:m(),deviceId:p().int(),count:p().int(),firstAt:p(),lastAt:p()}),IK=3600,LK=p().int().min(0).max(600),RK=p().int().min(0).max(IK),zK=e=>new Set(e.map(e=>e.mode)).size===e.length,BK=S([`rearmAfter`,`disableAfter`,`doNothing`]),VK=x({mode:ay,exitDelaySec:LK.optional(),entryDelaySec:LK.optional(),triggeredDurationSec:RK.optional(),postTriggeredAction:BK.optional(),schedule:CG.optional(),notifyDuringEntryDelay:y().optional(),notifySensorRewatched:y().optional(),notifySensorIgnored:y().optional()}),KCe=C(VK).max(8).refine(zK,{message:`modeDelays: at most one entry per arm mode`}),HK=x({mode:ay,exitDelaySec:LK.nullable().optional(),entryDelaySec:LK.nullable().optional(),triggeredDurationSec:RK.nullable().optional(),postTriggeredAction:BK.nullable().optional(),schedule:CG.nullable().optional(),notifyDuringEntryDelay:y().nullable().optional(),notifySensorRewatched:y().nullable().optional(),notifySensorIgnored:y().nullable().optional()}),qCe=C(HK).max(8).refine(zK,{message:`modeDelays: at most one edit per arm mode`}),UK=x({mode:ay,deviceId:p().int().positive(),nonBlocking:y()}),WK=x({mode:ay,deviceId:p().int().positive(),blocking:y()}),GK=x({mode:ay,deviceId:p().int().positive(),secureOnArm:y()}),KK=x({mode:ay,deviceIds:C(p().int()).max(200)}),qK=KK,JK=KK,YK=KK,XK=C(qK).max(8).refine(zK,{message:`nonBlocking: at most one list per arm mode`}),ZK=C(JK).max(8).refine(zK,{message:`blocking: at most one list per arm mode`}),QK=C(YK).max(8).refine(zK,{message:`secureOnArmOff: at most one list per arm mode`}),$K=x({exitDelaySec:LK,entryDelaySec:LK,triggeredDurationSec:RK,postTriggeredAction:BK.optional(),announceArm:y().optional(),announceTargets:C(m().min(1)).max(16),nonBlocking:XK.default([]),blocking:ZK.default([]),secureOnArmOff:QK.default([]),modeDelays:KCe.default([])}),eq=x({id:m().min(1).max(64),name:m().min(1).max(64),isDefault:y()}),tq=x({activeId:m().min(1),items:C(eq).min(1)}),nq=x({name:m().min(1).max(64),cloneFromId:m().min(1).max(64).optional()}),rq=x({id:m().min(1).max(64),name:m().min(1).max(64)}),iq=x({id:m().min(1).max(64)}),aq=$K.extend({nonBlocking:XK,blocking:ZK,secureOnArmOff:QK,modeDelays:qCe,nonBlockingEdit:UK,blockingEdit:WK,secureOnArmEdit:GK}).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`}),oq=S([`muted`,`detection-off`,`offline`]),sq=x({deviceId:p().int(),reason:oq}),cq=x({mode:ay,ruleCount:p().int().min(0),allDevices:y(),deviceIds:C(p().int()),allDevicesExcept:C(p().int()).default([]),skippedDevices:C(sq).default([])}),JCe=x({deviceId:p().int(),name:m(),state:m(),blocking:y()}),YCe=x({deviceId:p().int(),name:m(),phase:S([`open`,`closed`])}),XCe=x({mode:ay,devices:C(JCe),unknown:C(p().int())}),ZCe=x({ruleId:m(),ruleName:m(),deviceId:p().int(),name:m(),since:p(),dropped:p().int().min(0)}),QCe=x({state:iy,targetMode:ay.nullable(),availableModes:C(ay),openings:C(XCe),exclusions:C(YCe),bypassedInputs:C(ZCe).default([])}),lq=x({deviceId:p().int().nullable(),settings:$K,profiles:tq.optional(),coverage:C(cq),live:QCe.optional()}),uq=S([`open`,`closed`,`unknown`,`not-opening`]),dq=x({deviceId:p().int().positive(),reading:uq,state:m().nullable(),unknownWhy:S([`read-failed`,`unknown-word`]).nullable(),online:y().nullable(),controllable:y().default(!1)}),fq=x({deviceIds:C(p().int().positive()).max(500)}),pq=x({sensors:C(dq),readAt:p().int().nonnegative()}),mq=x({deviceId:p().int().nonnegative().optional(),seconds:p().min(0).max(60),profile:A.optional(),ruleId:m(),ruleName:m(),reason:S([`window`,`occupancy`])}),hq=x({rulesLoaded:y(),asks:C(mq).readonly()}),gq={name:`notification-rules`,scope:`system`,mode:`singleton`,methods:{listRules:E(x({}),x({rules:C(sK)}),{auth:`admin`}),getRule:E(x({ruleId:m()}),x({rule:sK.nullable()}),{auth:`admin`}),createRule:E(x({rule:tK}),x({rule:sK}),{kind:`mutation`,auth:`admin`,caller:`required`}),updateRule:E(oK,x({rule:sK}),{kind:`mutation`,auth:`admin`,caller:`required`}),deleteRule:E(x({ruleId:m()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),setRuleEnabled:E(x({ruleId:m(),enabled:y()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),getClipRetentionAsks:E(x({}),hq,{auth:`admin`}),listDeviceMutes:E(x({}),x({mutedDeviceIds:C(p().int()).readonly()}),{auth:`admin`}),setDeviceMuted:E(x({deviceId:p().int(),muted:y()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),testRule:E(x({rule:tK,lookbackMinutes:p().int().min(1).max(1440).default(60)}),x({results:C(pK)}),{kind:`mutation`,auth:`admin`}),previewStateSummary:E(x({rule:tK}),fK,{kind:`mutation`,auth:`admin`,access:`view`}),getConditionCatalog:E(x({}),x({catalog:C(wK),taxonomy:lG.optional()})),getTemplateCatalog:E(x({}),x({vars:C(bK),defaults:C(gK)})),previewTemplate:E(SK,CK,{kind:`mutation`,access:`view`}),getHistory:E(x({filter:AK.default({limit:100})}),x({entries:C(kK)}),{auth:`admin`}),getRuleLastRuns:E(x({}),MK,{auth:`admin`}),resolveArtifactUrl:E(x({artifactId:m().min(1)}),x({url:m().nullable()}),{auth:`admin`}),listSnoozes:E(x({}),x({snoozes:C(FK)}),{caller:`required`}),createSnooze:E(x({snooze:PK}),x({snooze:FK}),{kind:`mutation`,caller:`required`}),cancelSnooze:E(x({snoozeId:m()}),x({success:s(!0)}),{kind:`mutation`,caller:`required`}),getAlarmConfig:E(x({}),lq,{auth:`admin`}),setAlarmConfig:E(x({patch:aq}),lq,{kind:`mutation`,auth:`admin`}),createAlarmProfile:E(nq,lq,{kind:`mutation`,auth:`admin`}),renameAlarmProfile:E(rq,lq,{kind:`mutation`,auth:`admin`}),deleteAlarmProfile:E(iq,lq,{kind:`mutation`,auth:`admin`}),activateAlarmProfile:E(iq,lq,{kind:`mutation`,auth:`admin`}),getAlarmSensors:E(fq,pq,{auth:`admin`})},vocabulary:{notOperatorFacing:`notification rules — authored on their own page`}},$Ce=S([`min`,`low`,`normal`,`high`]),ewe=x({id:m().min(1),title:m().min(1),uri:h().optional(),destructive:y().optional()}),twe=x({image:y(),priority:y(),data:y(),actions:y(),recipients:y()}),_q=x({lastSentAt:p(),lastError:m().nullable(),queueDepth:p().int().nonnegative().meta(k(`count`)),supports:twe}),nwe=x({deviceId:p().int().nonnegative(),title:m().optional(),body:m().min(1),image:m().optional(),priority:$Ce.optional(),channel:m().optional(),recipients:C(m()).optional(),actions:C(ewe).optional(),data:d(m(),u()).optional()}),rwe=x({notificationId:m(),acceptedAt:p()}),vq={name:`notifier`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Notifier],methods:{send:E(nwe,rwe,{kind:`mutation`,auth:`admin`,actions:[{id:`notifier.send`,label:I(`Send a notification`,`Invia una notifica`),phrase:I(`Send “{body}” through {device}`,`Invia «{body}» tramite {device}`),icon:`send`,openArgs:[{key:`title`,label:I(`Title`,`Titolo`),offer:{kind:`text`},optional:!0},{key:`body`,label:I(`Message`,`Messaggio`),offer:{kind:`text`}},{key:`priority`,label:I(`Priority`,`Priorità`),offer:{kind:`enum`,values:[{value:`min`,label:I(`Minimal`,`Minima`)},{value:`low`,label:I(`Low`,`Bassa`)},{value:`normal`,label:I(`Normal`,`Normale`)},{value:`high`,label:I(`High`,`Alta`)}]},optional:!0}]}]}),cancel:E(x({deviceId:p().int().nonnegative(),notificationId:m().min(1)}),v(),{kind:`mutation`,auth:`admin`})},events:{onSent:{data:x({deviceId:p(),notificationId:m(),success:y(),error:m().nullable(),acceptedAt:p()}),notOperatorFacing:`a delivery receipt of a send this system made — not a fact about the world`}},status:{schema:_q,kind:`command-driven`},runtimeState:_q,durability:`session`,history:`none`,vocabulary:{noun:I(`Notifier`,`Notificatore`),order:2110}},yq=x({value:p().nullable().meta(k(`device`)),lastFetchedAt:p()}),bq={name:`numeric-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor],methods:{},status:{schema:yq,kind:`push`},runtimeState:yq,durability:`restored`,history:{fields:{value:{kind:`gauge`,minIntervalMs:3e4}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`Sensor`,`Sensore`),order:5150,state:[{kind:`numeric`,field:`value`,quantity:I(`the reading`,`il valore`),label:I(`Reading`,`Valore`),icon:`gauge`}]}},xq=x({integrationId:m(),displayName:m(),requestedScopes:C(Sf),allowedRedirectPrefixes:C(m()).min(1),allowedPrivateHostPaths:C(m()).optional(),requiresPkce:y().optional(),hubUrl:m().optional(),refreshTokenTtlSec:l([p().int().positive(),s(`never`)]).optional(),instances:C(x({id:m(),displayName:m()})).optional()}),Sq={name:`oauth-integration`,scope:`system`,mode:`collection`,internal:!0,methods:{getDescriptor:E(v(),xq,{auth:`admin`})},vocabulary:{notOperatorFacing:O.IDENTITY}},Cq=S([`text`,`timestamp`,`watermark`]),wq=S([`top-left`,`top-center`,`top-right`,`bottom-left`,`bottom-center`,`bottom-right`,`custom`]),Tq=x({id:m(),kind:Cq,enabled:y(),text:m().optional(),position:wq.optional(),availablePositions:C(wq).readonly(),readOnly:y().optional(),maxCharacters:p().int().positive().optional()}),Eq=x({overlays:C(Tq).readonly()}),Dq=x({enabled:y().optional(),text:m().optional(),position:wq.optional()}).partial(),Oq={name:`osd`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],methods:{setOverlay:E(x({deviceId:p(),overlayId:m(),patch:Dq}),v(),{kind:`mutation`,auth:`admin`})},events:{onStatusChanged:{data:x({deviceId:p(),status:Eq}),notOperatorFacing:`an overlay setting changed — configuration, not a happening`}},status:{schema:Eq,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:I(`On-screen text`,`Testo in sovrimpressione`),order:3190}},kq=1024,Aq=x({id:m().min(1).max(64),name:m().min(1).max(64),text:m().max(kq).default(``)}),jq=a(`kind`,[x({kind:s(`none`)}),x({kind:s(`static`),text:m().max(kq)}),x({kind:s(`template`),templateId:m().min(1).max(64)})]),Mq=x({enabled:y().default(!0),source:jq,schedule:CG.optional(),conditions:zG.optional()}),Nq=x({slotId:m(),kind:Cq,readOnly:y(),cameraEnabled:y(),cameraText:m().optional(),binding:Mq.nullable()}),Pq=S([`written`,`unchanged`,`gated`,`unreadable`,`disabled`,`unbound`,`failed`]),Fq=x({slotId:m(),outcome:Pq,text:m(),reason:m().optional()}),Iq=x({ok:y(),text:m(),notes:C(m())}),Lq={name:`osd-manager`,scope:`system`,mode:`singleton`,methods:{getDeviceOsd:E(x({deviceId:p().int()}),x({supported:y(),slots:C(Nq)}),{auth:`admin`}),getConditionSupport:E(x({}),x({supported:C(m()),catalog:C(wK)}),{auth:`admin`}),setSlotBinding:E(x({deviceId:p().int(),slotId:m().min(1),binding:Mq}),x({slot:Nq,render:Fq}),{kind:`mutation`,auth:`admin`}),clearSlotBinding:E(x({deviceId:p().int(),slotId:m().min(1)}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),setSlotCameraEnabled:E(x({deviceId:p().int(),slotId:m().min(1),enabled:y()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),copyDeviceConfiguration:E(x({sourceDeviceId:p().int(),targetDeviceId:p().int()}),x({copied:p().int().nonnegative(),skipped:p().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),previewSlot:E(x({deviceId:p().int(),slotId:m().min(1),binding:Mq.optional()}),Fq,{kind:`mutation`,auth:`admin`}),previewTemplate:E(x({deviceId:p().int(),text:m().max(kq)}),Iq,{kind:`mutation`,auth:`admin`}),renderDevice:E(x({deviceId:p().int()}),x({results:C(Fq)}),{kind:`mutation`,auth:`admin`}),listTemplates:E(x({}),x({templates:C(Aq)}),{auth:`admin`}),upsertTemplate:E(x({template:Aq}),x({template:Aq}),{kind:`mutation`,auth:`admin`}),deleteTemplate:E(x({templateId:m().min(1).max(64)}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.PIPELINE}},iwe=S([`normal`,`offline`,`on_batteries`]),Rq=p().int().min(4).max(200),zq=Rq.meta(wh({quantity:`mass`,unit:`g`})),Bq=x({foodLevel:p().nullable().meta(k(`none`)),bowlFood:p().nullable().meta(k(`mass`)),eating:y(),supportsMarkRefilled:y(),food1:p().nullable().meta(k(`none`)),food2:p().nullable().meta(k(`none`)),lowFood:y(),batteryPower:p().min(0).max(100).nullable().meta(k(`percentage`)),powerSource:S([`mains`,`battery`]).nullable(),desiccantLeftDays:p().nullable().meta(k(`duration`)),feeding:y(),status:iwe.nullable(),error:m().nullable(),errorCode:p().nullable().meta(k(`none`)),isDualHopper:y(),childLock:y(),indicatorLight:y(),feedSound:y(),volume:p().meta(k(`none`)),lastFeedGrams:Rq.nullable(),lastFeedHopper1:Rq.nullable(),lastFeedHopper2:Rq.nullable(),lastFetchedAt:p()}),Vq={name:`pet-feeder`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.PetFeeder],methods:{feed:E(x({deviceId:p().int().nonnegative(),grams:zq.optional(),hopper1:zq.optional(),hopper2:zq.optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.feed`,label:I(`Feed`,`Dai da mangiare`),phrase:I(`Dispense {grams} from {device}`,`Eroga {grams} da {device}`),icon:`paw-print`,openArgs:[{key:`grams`,label:I(`Grams`,`Grammi`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0}]},{id:`petFeeder.feedHoppers`,label:I(`Feed from both hoppers`,`Eroga da entrambi i serbatoi`),phrase:I(`Dispense {hopper1} and {hopper2} from {device}`,`Eroga {hopper1} e {hopper2} da {device}`),icon:`paw-print`,openArgs:[{key:`hopper1`,label:I(`Hopper 1`,`Serbatoio 1`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0},{key:`hopper2`,label:I(`Hopper 2`,`Serbatoio 2`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0}]}]}),cancelFeed:E(x({deviceId:p().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.cancelFeed`,label:I(`Cancel feeding`,`Annulla l’erogazione`),phrase:I(`Cancel the feeding on {device}`,`Annulla l’erogazione di {device}`),icon:`circle-x`}]}),callPet:E(x({deviceId:p().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.callPet`,label:I(`Call pet`,`Chiama l’animale`),phrase:I(`Call your pet with {device}`,`Chiama l’animale con {device}`),icon:`megaphone`}]}),playSound:E(x({deviceId:p().int().nonnegative(),soundId:p().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.playSound`,label:I(`Play sound`,`Riproduci un suono`),phrase:I(`Play sound {soundId} on {device}`,`Riproduci il suono {soundId} su {device}`),icon:`volume-2`,openArgs:[{key:`soundId`,label:I(`Sound`,`Suono`),offer:{kind:`number`,min:0,step:1}}]}]}),resetDesiccant:E(x({deviceId:p().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.resetDesiccant`,label:I(`Desiccant replaced`,`Essiccante sostituito`),phrase:I(`Mark the desiccant of {device} as replaced`,`Segna come sostituito l’essiccante di {device}`),icon:`refresh-cw`}]}),markFoodReplenished:E(x({deviceId:p().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.foodReplenished`,label:I(`Food refilled`,`Cibo ricaricato`),phrase:I(`Mark {device} as refilled`,`Segna {device} come ricaricato`),icon:`package`}]}),setChildLock:E(x({deviceId:p().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.childLockOn`,label:I(`Child lock on`,`Blocco bambini attivo`),phrase:I(`Turn on the child lock of {device}`,`Attiva il blocco bambini di {device}`),icon:`lock`,args:{on:!0}},{id:`petFeeder.childLockOff`,label:I(`Child lock off`,`Blocco bambini spento`),phrase:I(`Turn off the child lock of {device}`,`Disattiva il blocco bambini di {device}`),icon:`lock-open`,args:{on:!1}}]}),setIndicatorLight:E(x({deviceId:p().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.lightOn`,label:I(`Indicator light on`,`Spia accesa`),phrase:I(`Turn on the indicator light of {device}`,`Accendi la spia di {device}`),icon:`lightbulb`,args:{on:!0}},{id:`petFeeder.lightOff`,label:I(`Indicator light off`,`Spia spenta`),phrase:I(`Turn off the indicator light of {device}`,`Spegni la spia di {device}`),icon:`lightbulb-off`,args:{on:!1}}]}),setFeedSound:E(x({deviceId:p().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.feedSoundOn`,label:I(`Feeding sound on`,`Suono di erogazione attivo`),phrase:I(`Turn on the feeding sound of {device}`,`Attiva il suono di erogazione di {device}`),icon:`volume-2`,args:{on:!0}},{id:`petFeeder.feedSoundOff`,label:I(`Feeding sound off`,`Suono di erogazione spento`),phrase:I(`Turn off the feeding sound of {device}`,`Disattiva il suono di erogazione di {device}`),icon:`volume-x`,args:{on:!1}}]}),setVolume:E(x({deviceId:p().int().nonnegative(),level:p().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.volume`,label:I(`Set volume`,`Imposta il volume`),phrase:I(`Set the volume of {device} to {level}`,`Imposta il volume di {device} a {level}`),icon:`volume-2`,openArgs:[{key:`level`,label:I(`Volume`,`Volume`),offer:{kind:`number`,min:0,step:1}}]}]})},status:{schema:Bq,kind:`poll`},runtimeState:Bq,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:I(`Pet feeder`,`Distributore di cibo`),order:2030,state:[{kind:`boolean`,field:`lowFood`,label:I(`Food low`,`Cibo in esaurimento`),whenTrue:I(`When {device} runs low on food`,`Quando il cibo di {device} sta finendo`),whenFalse:I(`When {device} has enough food again`,`Quando {device} ha di nuovo cibo a sufficienza`),icon:`package`},{kind:`boolean`,field:`feeding`,label:I(`Feeding`,`In erogazione`),whenTrue:I(`When {device} starts feeding`,`Quando {device} inizia a erogare`),whenFalse:I(`When {device} finishes feeding`,`Quando {device} finisce di erogare`),icon:`paw-print`},{kind:`numeric`,field:`desiccantLeftDays`,quantity:I(`the desiccant life`,`la durata dell’essiccante`),label:I(`Desiccant`,`Essiccante`),unit:`d`,icon:`calendar-clock`}]}},Hq=x({waterLevel:p().min(0).max(100).nullable().meta(k(`percentage`)),waterVolume:p().min(0).nullable().meta(k(`volume`)),empty:y().nullable(),pumpRunning:y().nullable(),error:m().nullable(),lastFetchedAt:p()}),Uq=`water`;function awe(e){let t=e.waterLevel!==null||e.empty===null?null:e.empty?`empty`:`ok`;return{key:Uq,label:`Water`,level:e.waterLevel,status:t,kind:`supply`,form:`tank`,lastResetAt:null,resettable:!1}}var owe=p().int().nonnegative(),Wq={name:`pet-fountain`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.PetFountain],power:{kind:`field`,field:`pumpRunning`,set:`setPump`},methods:{setPump:E(x({deviceId:owe,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFountain.pumpOn`,label:I(`Pump on`,`Pompa accesa`),phrase:I(`Start the pump of {device}`,`Avvia la pompa di {device}`),icon:`play`,args:{on:!0}},{id:`petFountain.pumpOff`,label:I(`Pump off`,`Pompa spenta`),phrase:I(`Stop the pump of {device}`,`Ferma la pompa di {device}`),icon:`square`,args:{on:!1}}]})},status:{schema:Hq,kind:`push`},runtimeState:Hq,durability:`session`,history:{fields:{waterLevel:{kind:`gauge`,unit:`%`,deadband:1},waterVolume:{kind:`gauge`,unit:`L`}}},vocabulary:{noun:I(`Pet fountain`,`Fontana per animali`),order:2040,state:[{kind:`boolean`,field:`empty`,label:I(`Tank empty`,`Serbatoio vuoto`),whenTrue:I(`When the tank of {device} is empty`,`Quando il serbatoio di {device} è vuoto`),whenFalse:I(`When the tank of {device} is refilled`,`Quando il serbatoio di {device} viene riempito`),icon:`droplet`},{kind:`numeric`,field:`waterLevel`,quantity:I(`the water level`,`il livello dell’acqua`),label:I(`Water level`,`Livello dell’acqua`),unit:`%`,icon:`droplets`}]}},swe=S(Rd),Gq={min:1,max:8},Kq=S([`intel-core-ultra`,`intel-n-series`,`apple-m-base`,`apple-m-pro`,`amd-phoenix`,`unknown`]),qq=S([`intel-npu`,`intel-igpu`,`amd-igpu`,`amd-npu`,`x86-cpu`,`arm-cpu`,`apple-ane`,`coral`]),Jq=a(`kind`,[x({kind:s(`capacity`),sessions:p(),minSessions:p()}),x({kind:s(`tie-faster`),over:m(),recallDelta:p()}),x({kind:s(`stepped-down`),from:m(),to:m(),limitedBy:m()}),x({kind:s(`no-fit-lightest`),sessions:p(),minSessions:p()}),x({kind:s(`derived-latency`),modelId:m()}),x({kind:s(`cpu-device`)}),x({kind:s(`device-disabled`)}),x({kind:s(`device-unavailable`)}),x({kind:s(`node-offline`)}),x({kind:s(`no-hardware-facts`)}),x({kind:s(`no-measured-data`),hardwareClass:Kq}),x({kind:s(`no-family-build`),format:swe}),x({kind:s(`kept-custom-pin`),modelId:m(),deviceKey:m()})]),Yq=S([`custom-pin`]),Xq=a(`kind`,[x({kind:s(`table`)}),x({kind:s(`node-benchmark`),resultId:m(),measuredAtMs:p()}),x({kind:s(`estimated`),estimatedFrom:Kq})]),Zq=x({modelId:m(),p50Ms:p(),fps:p(),measured:y(),source:Xq.optional(),estimatedFrom:Kq.optional(),capacitySessions:p(),personRecall:p()}),Qq=x({deviceKey:m(),accelerator:qq.nullable(),enabled:y(),available:y(),chosen:Zq.nullable(),kept:Yq.optional(),reasons:C(Jq).readonly()}),$q=x({nodeId:m(),reachable:y(),hardwareClass:Kq.nullable(),cpuModel:m().nullable(),skipped:y(),acceleratorModelId:m().nullable(),devices:C(Qq).readonly(),reasons:C(Jq).readonly()}),eJ=x({stepId:m(),before:m().nullable(),after:m().nullable()}),tJ=x({nodeId:m(),deviceKey:m(),madeExplicit:y(),modelPins:C(eJ).readonly(),thresholds:C(x({stepId:m(),keys:C(m()).readonly()})).readonly()}),nJ=a(`kind`,[x({kind:s(`custom-pin-kept`),nodeId:m(),deviceKey:m(),modelId:m()}),x({kind:s(`custom-registry-unreadable`),error:m()})]),rJ=x({headroom:p().min(.3).max(.5).default(.4),minSessionsPerDevice:p().int().min(Gq.min).max(Gq.max).default(2)}),iJ=x({planHash:m(),family:s(`yolov9`),headroom:p(),minSessionsPerDevice:p(),cameraFps:p(),generatedAt:p(),nodes:C($q).readonly(),nodeChanges:C(tJ).readonly(),warnings:C(nJ).readonly()}),aJ=x({planHash:m(),headroom:p().min(.3).max(.5).default(.4),minSessionsPerDevice:p().int().min(Gq.min).max(Gq.max).default(2)}),oJ=x({phase:S([`download`,`node-models`,`redispatch`]),ok:y(),detail:m()}),sJ=a(`kind`,[x({kind:s(`applied`),planHash:m(),phases:C(oJ).readonly()}),x({kind:s(`aborted`),phases:C(oJ).readonly()}),x({kind:s(`stale`),plan:iJ}),x({kind:s(`refused`),reason:S([`apply-in-progress`])})]),cJ=S([`least-loaded`,`share`]),lJ=`share`,cwe=`sessionPlacement`;function lwe(e){let t=cJ.safeParse(e);return t.success?t.data:lJ}var uJ=x({nodes:d(m(),p().positive()).default({}),devices:d(m(),d(m(),p().positive())).default({})}),dJ=x({windowMs:p().int().min(6e4).max(1440*60*1e3).default(3600*1e3)}),fJ=x({deviceKey:m(),sessionsNow:p(),sessionsStarted:p(),observedShare:p().nullable()}),pJ=x({nodeId:m(),sessionsNow:p(),sessionsStarted:p(),observedShare:p().nullable(),peakSessions:p(),yieldsAway:p(),devices:C(fJ).readonly()}),mJ=x({deviceId:p(),deviceKey:m(),reason:S([`disabled`,`absent`])}),hJ=x({policy:cJ,windowMs:p(),observedForMs:p(),sessionsNow:p(),clusterPeakSessions:p(),nodes:C(pJ).readonly(),stalePins:C(mJ).readonly()}),gJ=S([`hardware`,`benchmark`]),_J=S([`no-benchmark-results`,`partial-benchmark-results`]),vJ=x({headroom:p().min(.3).max(.5).default(.4),source:gJ.default(`hardware`)}),yJ=x({deviceKey:m(),share:p(),modelId:m().nullable(),fps:p().nullable(),measured:y(),suggestedMaxSessions:p().nullable()}),bJ=x({nodeId:m(),share:p().nullable(),capacitySessions:p(),devices:C(yJ).readonly(),skippedReason:m().nullable(),capacitySource:gJ.nullable(),capacityFallback:_J.nullable()}),xJ=x({headroom:p(),source:gJ,cameraFps:p(),minSessionsPerDevice:p(),nodes:C(bJ).readonly()}),SJ=S([`hardware`,`benchmark`,`manual`]),CJ=`benchmark`;function wJ(e){return e!==`manual`}var uwe=.4,dwe=`shareSource`;function fwe(e){if(e===`auto`)return`hardware`;let t=SJ.safeParse(e);return t.success?t.data:CJ}var TJ=x({source:SJ}),pwe=x({nodes:d(m(),p()),devices:d(m(),d(m(),p()))}),EJ=x({deviceKey:m(),eligible:y(),configuredPct:p(),effectivePct:p()}),DJ=x({nodeId:m(),eligible:y(),configuredPct:p(),effectivePct:p(),capacitySource:gJ.nullable(),capacityFallback:_J.nullable(),devices:C(EJ).readonly()}),OJ=x({source:SJ,policy:cJ,autoPending:y(),computedAt:p().nullable(),trigger:m().nullable(),nodes:C(DJ).readonly(),nodeWeights:d(m(),p()),deviceWeights:d(m(),d(m(),p()))}),kJ=[`motion-without-detections`,`detections-under-floor`,`inference-too-slow`,`frames-shed`,`inference-device-unusable`],AJ=S(kJ),jJ=S([`info`,`warning`,`critical`]),MJ=a(`type`,[x({type:s(`camera`),deviceId:p()}),x({type:s(`node`),nodeId:m()}),x({type:s(`inference-device`),nodeId:m(),deviceKey:m()})]),NJ=x({id:m(),kind:AJ,severity:jJ,subject:MJ,what:m(),evidence:d(m(),p().nullable()),action:m()}),PJ=x({source:m(),entries:p().nullable()}),FJ=x({nodeId:m(),sessionsNow:p(),unusableDevices:C(m()).readonly(),devices:C(x({deviceKey:m(),sessionsNow:p(),usable:y()})).readonly()}),IJ=x({deviceId:p(),nativeCropMissesSincePreviousTick:p().nullable()}),LJ=x({generatedAt:p(),tickMs:p(),camerasSeen:p().nullable(),findings:C(NJ).readonly(),cameraSignals:C(IJ).readonly(),nodes:C(FJ).readonly(),sources:C(PJ).readonly(),notCovered:C(m()).readonly()}),RJ=x({history:p().int().min(1).max(24).default(1)}),zJ=x({latest:LJ.nullable(),previous:C(LJ).readonly()}),mwe=x({engine:bH.optional(),steps:C(mH).readonly(),audio:x({engine:bH.optional(),modelId:m().optional(),enabled:y(),settings:d(m(),u()).readonly().optional()}).nullable().optional()}),BJ=x({modelId:m().optional(),settings:d(m(),u()).optional(),jumpDeviceKey:m().optional()}),VJ=x({maxCameras:p().int().nonnegative().nullable().default(null),detectWeight:p().positive().optional(),detect:y().optional(),decode:y().optional(),audio:y().optional(),ingest:y().optional(),decodeBudgetMb:p().int().min(1024).max(65536).optional(),maxLiveDecodeWorkers:p().int().min(1).max(32).optional(),reachableHost:m().optional(),color:Pu.optional(),stepSettings:d(m(),d(m(),u()).readonly()).optional(),inferenceDevices:d(m(),x({enabled:y(),weight:p().positive().optional(),maxSessions:p().int().positive().optional(),steps:d(m(),BJ).optional()})).optional()}),hwe=d(m(),d(m(),u()).readonly()),HJ=S([`pipeline`,`onboard`,`none`]),gwe=x({stepToggles:d(m(),y()).optional(),stepSettings:hwe.optional()}),UJ=x({deviceId:p(),agentNodeId:m(),pinned:y(),reason:S([`manual`,`capacity`,`hardware-affinity`,`failover`,`rebalance`]),assignedAt:p()}),WJ=x({nodeId:m(),online:y(),load:NU,score:p(),decodeHwaccel:m().nullable()}),GJ=x({totalAgents:p(),onlineAgents:p(),totalCameras:p(),attachedCameras:p(),activeCameras:p(),avgInferenceTimeMs:p(),queueDepth:p()}),KJ=d(m(),m()),qJ=x({ownerNodeId:m(),reachableHost:m().optional(),configIssue:m().optional()}),JJ=x({camStreamId:m(),codec:m(),width:p(),height:p(),fps:p(),kind:m()}),YJ=x({streams:C(JJ).readonly()}),XJ=x({detectionNodeId:m().nullable(),decoderNodeId:m().nullable(),audioNodeId:m().nullable(),sourceNodeId:m().nullable(),pinned:x({detection:y(),decoder:y(),audio:y()}),reasons:x({detection:m().optional(),decoder:m().optional(),audio:m().optional()})}),ZJ=x({profile:m(),status:m(),codec:m(),width:p(),height:p(),subscribers:p(),inFps:p().nullable()}),QJ=x({profiles:C(ZJ).readonly(),webrtcSessions:p(),rtspRestream:y()}),$J=x({nodeId:m()}),eY=x({enabled:y(),fps:p()}),tY=S([`idle`,`installing`,`verifying`,`ready`,`failed`]),nY=x({state:tY,error:m().optional()}),rY=S([`idle`,`watching`,`active`]),iY=x({nodeId:m(),engine:x({backend:m(),device:m()}),phase:rY,configuredFps:p(),actualFps:p(),queueDepth:p(),avgInferenceMs:p(),provisioning:nY}),aY=x({nodeId:m(),enabled:y()}),oY=Ac,sY=x({mode:oY,active:y(),storageBytes:p()}),cY=S([`source`,`broker`,`detection`,`recording`,`switches`]),lY=S([`timeout`,`error`,`partial`]),uY=x({stage:cY,reason:lY,elapsedMs:p()}),dY=x({state:S([`idle`,`running`,`done`,`error`]),total:p().int().nonnegative(),completed:p().int().nonnegative(),currentDeviceId:p().int().nullable(),failed:C(p().int()).readonly(),mediaDropped:p().int().nonnegative(),tracks:p().int().nonnegative(),events:p().int().nonnegative(),startedAtMs:p().int().nullable(),finishedAtMs:p().int().nullable(),error:m().nullable()}),fY=x({deviceId:p(),assignment:XJ,source:YJ,broker:QJ.nullable(),decoder:$J.nullable(),motion:eY.nullable(),detection:iY.nullable(),audio:aY.nullable(),recording:sY.nullable(),switchedOff:C(Ya).readonly(),cameraSensors:Kz.optional(),degraded:C(uY).readonly(),fetchedAt:p()}),pY=[`disabled`,`unavailable`,`cannot-host-camera-root`,`accelerator-preferred`],mY=S(pY),_we=x({key:m(),backend:m(),device:m(),format:S(Rd),available:y(),presence:S([`present`,`absent`,`unknown`]).optional(),enabled:y(),weight:p(),maxSessions:p().nullable(),defaultModelId:m(),steps:d(m(),BJ).optional(),exclusion:mY.nullable()}),hY=a(`kind`,[x({kind:s(`stored`),modelId:m()}),x({kind:s(`absent`),defaultModelId:m()}),x({kind:s(`unreadable`),reason:S(oB),error:m().optional()})]),vwe=x({nodeId:m(),reachable:y(),devices:C(_we).readonly()}),gY=x({deviceId:p().int().nonnegative(),config:zz.nullable()}),_Y=S([`unknown-camera`,`out-of-range`,`no-burst-producer`,`already-looked`]),vY=x({deviceId:p().int().nonnegative(),afterMs:p().finite(),reason:m()}),yY=x({scheduled:y(),dueInMs:p().optional(),refusedBecause:_Y.optional()}),bY={name:`pipeline-orchestrator`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,exposesDeviceSettings:!0,methods:{requestOccupancyLook:E(vY,yY,{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:E(Xc,x({paused:s(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:E(Xc,x({resumed:s(!0)}),{kind:`mutation`,auth:`admin`}),assignPipeline:E(x({deviceId:p(),agentNodeId:m()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),unassignPipeline:E(x({deviceId:p()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),setPipelineDevicePin:E(x({deviceId:p(),deviceKey:m()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),getPipelineDevicePin:E(x({deviceId:p()}),x({deviceKey:m().nullable()})),rebalance:E(v(),x({migrated:p(),skipped:C(x({deviceId:p(),targetNodeId:m(),reason:m()})).default([])}),{kind:`mutation`,auth:`admin`}),getPipelineAssignments:E(v(),C(UJ).readonly()),getPipelineAssignment:E(x({deviceId:p()}),UJ.nullable()),getAgentLoad:E(v(),C(WJ).readonly()),getClusterModelChoice:E(x({stepId:m()}),hY),getGlobalMetrics:E(v(),GJ),getCameraMetrics:E(x({deviceId:p()}),DH.nullable()),getCapabilityBindings:E(x({nodeId:m()}),KJ),setCapabilityBinding:E(x({nodeId:m(),capName:m(),addonId:m()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),getIngestOwner:E(v(),qJ),assignAudio:E(x({deviceId:p(),nodeId:m()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),unassignAudio:E(x({deviceId:p()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),getAudioAssignment:E(x({deviceId:p()}),x({nodeId:m(),pinned:y(),assignedAt:p()}).nullable()),getAudioNodeLoad:E(v(),C(x({nodeId:m(),deviceCount:p()}))),getAudioAssignments:E(v(),C(x({deviceId:p(),nodeId:m(),pinned:y(),assignedAt:p()}))),getAgentSettings:E(x({agentNodeId:m()}),VJ.nullable()),listAgentSettings:E(v(),C(x({nodeId:m(),settings:VJ})).readonly()),removeAgentSettings:E(x({agentNodeId:m()}),x({success:y(),removed:y()}),{kind:`mutation`,auth:`admin`}),setAgentMaxCameras:E(x({agentNodeId:m(),maxCameras:p().int().nonnegative().nullable()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),setAgentCapabilities:E(x({agentNodeId:m(),detect:y().nullable().optional(),audio:y().nullable().optional(),ingest:y().nullable().optional()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),setAgentDecodeLimits:E(x({agentNodeId:m(),decodeBudgetMb:p().int().min(1024).max(65536).nullable().optional(),maxLiveDecodeWorkers:p().int().min(1).max(32).nullable().optional()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),setAgentReachableHost:E(x({agentNodeId:m(),reachableHost:m().nullable().optional(),color:Pu.nullable().optional()}).refine(e=>e.reachableHost!==void 0||e.color!==void 0,{message:`reachableHost or color required`}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),setAgentInferenceDevices:E(x({agentNodeId:m(),inferenceDevices:d(m(),x({enabled:y(),weight:p().positive().optional(),maxSessions:p().int().positive().optional(),steps:d(m(),BJ).optional()}))}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),setNodeStepSettings:E(x({agentNodeId:m(),addonId:m(),settings:d(m(),u()).nullable()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),getNodeInferenceDevices:E(x({nodeId:m()}),vwe),forgetInferenceDevice:E(x({agentNodeId:m(),deviceKey:m()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),resetNodePipelineDefaults:E(x({agentNodeId:m()}),x({success:s(!0),effectiveModelId:m().nullable()}),{kind:`mutation`,auth:`admin`}),planAutoTune:E(rJ,iJ,{auth:`admin`}),applyAutoTune:E(aJ,sJ,{kind:`mutation`,auth:`admin`}),setLoadBalancingShares:E(uJ,x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),getPlacementStats:E(dJ,hJ,{auth:`admin`}),getHealthDigest:E(RJ,zJ,{auth:`admin`}),suggestShares:E(vJ,xJ,{auth:`admin`}),getEffectiveShares:E(v(),OJ,{auth:`admin`}),setShareSource:E(TJ,x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkPreflight:E(IH,VH,{auth:`admin`}),startNodeBenchmark:E(IH,a(`kind`,[x({kind:s(`started`),runId:m()}),x({kind:s(`refused`),preflight:VH})]),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkStatus:E(v(),nU,{auth:`admin`}),abortNodeBenchmark:E(x({runId:m()}),x({aborted:y()}),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkCandidates:E(x({nodeId:m()}),oU,{auth:`admin`}),listNodeBenchmarkResults:E(iU,C(aU).readonly(),{auth:`admin`}),deleteNodeBenchmarkResult:E(x({id:m()}),x({deleted:y()}),{kind:`mutation`,auth:`admin`}),getCameraSettings:E(x({deviceId:p()}),gwe.nullable()),setCameraStepToggle:E(x({deviceId:p(),addonId:m(),enabled:y().nullable()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),getCameraDetectionSource:E(x({deviceId:p()}),x({source:HJ,explicit:y(),onboard:x({available:y(),geometry:S([`boxed`,`while-streaming`,`flag-only`,`unknown`])})})),setCameraDetectionSource:E(x({deviceId:p(),source:HJ}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),setCameraStepSettings:E(x({deviceId:p(),addonId:m(),settings:d(m(),u()).nullable()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),resolvePipeline:E(x({deviceId:p(),agentNodeId:m().optional()}),mwe),getCameraSwitches:E(x({deviceId:p()}),Za,{role:`viewer`}),setCameraSwitch:E(x({deviceId:p(),switchId:Ya,enabled:y()}),Za,{kind:`mutation`,auth:`admin`}),getCameraStatus:E(x({deviceId:p()}),fY),getCameraStatuses:E(x({deviceIds:C(p()).optional()}),C(fY).readonly()),setCameraSensors:E(gY,x({success:s(!0)}),{kind:`mutation`,auth:`admin`}),reconcileFromDisk:E(v(),dY,{kind:`mutation`,auth:`admin`}),getReconcileFromDiskStatus:E(v(),dY,{auth:`admin`})},vocabulary:{notOperatorFacing:O.PIPELINE}},xY=x({id:m(),name:m(),sampleCount:p().int().nonnegative(),coverMediaId:p().int().optional(),coverBase64:m().optional()}),ywe=x({id:m(),text:m(),score:p(),addedAt:p().int(),deviceId:p().int().optional(),base64:m().optional(),mediaId:p().int().optional(),keyFrameMediaId:p().int().optional(),plateBbox:_y.optional()}),SY=x({plateId:m(),deviceId:p().int(),trackId:m(),timestamp:p().int(),text:m(),score:p(),corrected:y(),recognizedVehicleId:m().optional(),vehicleName:m().optional(),assigned:y(),plateBbox:_y.optional(),keyFrameMediaId:p().int().optional(),base64:m().optional(),cropUrl:m().optional(),cropMissReason:m().optional()}),bwe=x({mediaId:p().int(),kind:m(),url:m(),sizeBytes:p(),timestamp:p()}),xwe=x({plateIds:C(m()).readonly(),representativePlateId:m(),representativeText:m(),size:p().int(),cohesion:p()}),CY={name:`plate-gallery`,role:{feature:`plate-assignment`},scope:`system`,mode:`singleton`,methods:{listPlates:E(x({deviceId:p().int().optional(),limit:p().int().positive().optional(),includeCrops:y().optional()}).optional(),C(SY).readonly()),getPlateByTrack:E(x({deviceId:p().int(),trackId:m()}),SY.nullable(),{role:`viewer`}),getPlateMedia:E(x({plateId:m()}),C(bwe).readonly()),searchPlates:E(x({text:m().min(1),maxDistance:p().int().min(0).optional(),limit:p().int().positive().optional(),includeCrops:y().optional()}),C(SY).readonly()),suggestPlateClusters:E(x({maxDistance:p().int().min(0).optional(),minClusterSize:p().int().min(2).optional(),limit:p().int().positive().optional()}).optional(),C(xwe).readonly()),correctPlateText:E(x({plateId:m(),text:m().min(1)}),v(),{kind:`mutation`,auth:`admin`}),deletePlate:E(x({plateId:m()}),v(),{kind:`mutation`,auth:`admin`}),listVehicles:E(x({includeCrops:y().optional()}).optional(),C(xY).readonly()),createVehicle:E(x({name:m().min(1)}),xY,{kind:`mutation`,auth:`admin`}),renameVehicle:E(x({id:m(),name:m().min(1)}),v(),{kind:`mutation`,auth:`admin`}),deleteVehicle:E(x({id:m()}),v(),{kind:`mutation`,auth:`admin`}),listVehicleSamples:E(x({vehicleId:m()}),C(ywe).readonly()),removeVehicleSample:E(x({vehicleId:m(),sampleId:m()}),v(),{kind:`mutation`,auth:`admin`}),moveVehicleSample:E(x({sampleId:m().min(1),toVehicleId:m().min(1)}),v(),{kind:`mutation`,auth:`admin`}),assignPlate:E(x({plateId:m(),vehicleId:m()}),v(),{kind:`mutation`,auth:`admin`}),unassignPlate:E(x({plateId:m()}),v(),{kind:`mutation`,auth:`admin`}),assignPlates:E(x({plateIds:C(m()).min(1),vehicleId:m()}),x({assigned:p().int(),failed:C(m()).readonly()}),{kind:`mutation`,auth:`admin`}),unassignPlates:E(x({plateIds:C(m()).min(1)}),x({unassigned:p().int(),failed:C(m()).readonly()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`the plate gallery — curated on its own page`}},wY={"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}}}},TY={"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}},EY=.5,Swe=.05,DY=2e3,OY=p().nullable().transform(e=>e!==null&&Number.isFinite(e)&&e>0?e:null),kY=m().nullable().transform(e=>e!==null&&e.trim()!==``?e:null),AY=x({int8:OY,fp16:OY}),jY=x({deviceKey:m(),fullDeviceName:kY,executionUnits:OY,clockMHz:OY,gops:AY.nullable(),architecture:kY,npuName:kY,tops:OY,vendor:kY,webgpuArchitecture:kY,webgpuDevice:kY,computeUnits:OY}),Cwe=x({accelerators:C(jY).nullable()}),MY=[{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*DY}},{hardwareClass:`amd-phoenix`,accelerator:`amd-igpu`,score:{metric:`cu`,value:12}}];function wwe(e){let t=Cwe.safeParse(e);return!t.success||t.data.accelerators===null?null:t.data.accelerators}function NY(e){return e!==null&&e>0?e:null}function PY(e){let t=[],n=NY(e.gops?.int8??null);n!==null&&t.push({metric:`gops-int8`,value:n});let r=NY(e.gops?.fp16??null);r!==null&&t.push({metric:`gops-fp16`,value:r});let i=NY(e.executionUnits),a=NY(e.clockMHz);i!==null&&a!==null&&t.push({metric:`eu-mhz`,value:i*a});let o=NY(e.computeUnits);o!==null&&t.push({metric:`cu`,value:o});let s=NY(e.tops);return s!==null&&t.push({metric:`tops`,value:s}),t}function FY(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 IY(e,t,n){for(let r of PY(e))if(FY(t,r,n)!==null)return r;return null}function LY(e,t,n=MY){return IY(e,t,n)!==null}function RY(e,t,n){if(t!==`unknown`)return e[t]?.[n]}function Twe(e){return Math.round(e*10)/10}function Ewe(e){return Math.min(2,Math.max(EY,e))}function Dwe(e,t,n){let r={};for(let[i,a]of Object.entries(e))r[i]={p50Ms:Twe(a.p50Ms/t),fps:Math.max(1,Math.round(a.fps*t)),measured:!1,estimatedFrom:n};return r}function zY(e){let t=e.perf??wY,n=e.references??MY,r=RY(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:IY(e.report,e.accelerator,n);if(i===null)return r===void 0?null:{column:r,estimatedFrom:null};let a=FY(e.accelerator,i,n),o=a===null?void 0:RY(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:Dwe(o,Ewe(s),a.hardwareClass),estimatedFrom:a.hardwareClass}}var BY=S(Rd),Owe=S([`videotoolbox`,`cuda`,`nvdec`,`vaapi`,`qsv`,`d3d11va`,`dxva2`,`amf`,`vdpau`,`drm`,`coreml`,`tensorrt`,`openvino`,`directml`,`webgpu`,`none`]).nullable().optional(),kwe=x({preferred:C(m()).readonly(),rationale:m()}),VY=S([`h264_videotoolbox`,`hevc_videotoolbox`,`h264_vaapi`,`hevc_vaapi`,`h264_nvenc`,`hevc_nvenc`,`h264_qsv`,`hevc_qsv`,`h264_amf`,`hevc_amf`,`libx264`,`libx265`]);x({encoders:C(x({encoder:VY,codec:S([`H264`,`H265`]),family:S([`videotoolbox`,`vaapi`,`nvenc`,`qsv`,`amf`,`software`]),available:y(),reason:m().optional()})).readonly(),defaultH264:VY,defaultH265:VY,probedAt:p()}),x({methods:C(m()).readonly(),probedAt:p()});var Awe=S([`darwin`,`linux`,`win32`]),jwe=S([`arm64`,`x64`]),Mwe=x({type:S([`nvidia`,`amd`,`intel`,`apple`]),name:m(),memoryMB:p().optional()}),Nwe=x({type:S([`apple-ane`,`intel-npu`,`amd-xdna`]),name:m().optional(),generation:S([`xdna1`,`xdna2`]).optional()}),HY=S([`usb`,`pci`]),Pwe=x({type:s(`coral-edgetpu`),bus:m().optional(),count:p().int().nonnegative().optional(),units:C(x({bus:HY,count:p().int().nonnegative()})).readonly().optional(),unavailable:C(x({bus:HY,count:p().int().nonnegative(),reason:S([`driver-missing`,`device-not-accessible`])})).readonly().optional()}),UY=x({platform:Awe,arch:jwe,cpuModel:m(),cpuCores:p(),totalRAM_MB:p(),availableRAM_MB:p(),gpu:Mwe.nullable(),npu:Nwe.nullable(),coral:Pwe.nullable().optional(),accelerators:C(jY).readonly().optional()}),WY=x({runtime:s(`python`),backend:m(),format:S([`onnx`,`coreml`,`openvino`,`tflite`]),score:p(),reason:m(),available:y()}),GY=x({key:m(),backend:m(),device:m(),format:BY,runtime:s(`python`),score:p(),available:y()}),Fwe=x({hardware:UY,scores:C(WY).readonly(),bestScore:WY,pythonPath:m().nullable(),devices:C(GY).readonly()}),Iwe=x({modelId:m(),name:m(),minRAM_MB:p(),accuracyScore:p(),formats:C(m()).readonly()}),Lwe=x({modelId:m(),runtime:s(`python`),backend:m(),format:BY,reason:m()}),Rwe=x({devices:C(GY).readonly(),appeared:C(m()).readonly(),disappeared:C(m()).readonly(),usbBus:S([`observed`,`unobservable`]),decidedBy:S([`usb-ids`,`pci`,`delegate-fallback`,`none`])}),KY={name:`platform-probe`,scope:`system`,mode:`singleton`,methods:{getCapabilities:E(v(),Fwe),getHardware:E(v(),UY),resolveInferenceConfig:E(x({requirements:C(Iwe).readonly()}),Lwe),resolveHwAccel:E(x({prefer:Owe}),kwe),rescanAccelerators:E(v(),Rwe,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.CLUSTER}},qY=x({power:p().optional().meta(k(`power`,{label:`Power`})),energy:p().optional().meta(k(`energy`,{label:`Energy`})),voltage:p().optional().meta(k(`voltage`,{label:`Voltage`})),current:p().optional().meta(k(`current`,{label:`Current`})),apparentPower:p().optional().meta(k(`apparent-power`)),powerFactor:p().min(0).max(1).optional().meta(k(`ratio`)),lastFetchedAt:p()}),zwe=[j.Sensor,j.Switch,j.Light,j.Fan,j.Climate,j.Humidifier,j.WaterHeater,j.MediaPlayer,j.Washer,j.Dryer,j.Dishwasher,j.Vacuum,j.LawnMower,j.PetFeeder],Bwe=zwe.filter(e=>e!==j.Sensor);function JY(e,t){return{id:e,cardinality:`scalar`,vocabulary:{cap:`power-meter`,stateField:e},deviceTypes:Bwe,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 Vwe={version:1,targets:[JY(`power`,`W`),JY(`energy`,`kWh`),JY(`voltage`,`V`),JY(`current`,`A`)]},YY={name:`power-meter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:zwe,deviceConfig:{ui:{kind:`widget`,widgetId:`host/power-meter-line`,tab:`power`,placement:`hero`,label:`Power`,order:4}},methods:{},status:{schema:qY,kind:`push`},runtimeState:qY,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:Vwe,vocabulary:{noun:I(`Power meter`,`Misuratore di energia`),order:5160,state:[{kind:`numeric`,field:`power`,quantity:I(`the power draw`,`il consumo`),label:I(`Power`,`Potenza`),unit:`W`,icon:`zap`},{kind:`numeric`,field:`energy`,quantity:I(`the energy used`,`l’energia consumata`),label:I(`Energy`,`Energia`),unit:`kWh`,icon:`zap`},{kind:`numeric`,field:`voltage`,quantity:I(`the voltage`,`la tensione`),label:I(`Voltage`,`Tensione`),unit:`V`,icon:`zap`},{kind:`numeric`,field:`current`,quantity:I(`the current`,`la corrente`),label:I(`Current`,`Corrente`),unit:`A`,icon:`zap`}]}},Hwe=x({latitude:p().min(-90).max(90).meta(k(`angle`)),longitude:p().min(-180).max(180).meta(k(`angle`)),accuracyMeters:p().nonnegative().meta(k(`length`))}),XY=x({state:m(),location:m().nullable(),gps:Hwe.nullable(),lastChangedAt:p()}),ZY={name:`presence`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Presence],methods:{},status:{schema:XY,kind:`push`},runtimeState:XY,durability:`restored`,history:`none`,volatileStateFields:[`lastChangedAt`],vocabulary:{noun:I(`Presence`,`Presenza`),order:5170,state:[{kind:`value`,field:`state`,label:I(`Where`,`Posizione`),phrase:I(`When {device} is at {value}`,`Quando {device} è in {value}`),icon:`map-pin`}]}},QY=x({pressure:p().nullable().meta(k(`pressure`,{precision:0})),lastFetchedAt:p()}),$Y={name:`pressure-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor],methods:{},status:{schema:QY,kind:`push`},runtimeState:QY,durability:`restored`,history:{fields:{pressure:{kind:`gauge`,unit:`hPa`,deadband:.1}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`Pressure`,`Pressione`),order:5180,state:[{kind:`numeric`,field:`pressure`,quantity:I(`the pressure`,`la pressione`),label:I(`Pressure`,`Pressione`),unit:`hPa`,icon:`gauge`}]}},eX=a(`kind`,[$z,eB]),tX=x({id:p(),enabled:y(),shape:eX}),nX=x({enabled:y(),regions:C(tX).nullable(),audioEnabled:y().nullable(),lastFetchedAt:p()}),rX=x({maxRegions:p(),supportedShapes:C(rB),polygonVertices:iB.optional(),supportsAudioMute:y()}),iX=x({enabled:y().optional(),regions:C(tX).optional()}),aX={name:`privacy-mask`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/privacy-mask-grid`,tab:`image`,label:`Privacy Mask`}},methods:{getOptions:E(x({deviceId:p()}),rX),setMask:E(x({deviceId:p(),patch:iX}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`privacy.maskOn`,label:I(`Privacy mask on`,`Maschera privacy attiva`),phrase:I(`Cover the privacy zones of {device}`,`Oscura le zone private di {device}`),icon:`eye-off`,args:{patch:{enabled:!0}}},{id:`privacy.maskOff`,label:I(`Privacy mask off`,`Maschera privacy spenta`),phrase:I(`Uncover the privacy zones of {device}`,`Scopri le zone private di {device}`),icon:`eye`,args:{patch:{enabled:!1}}}]}),setAudioEnabled:E(x({deviceId:p(),enabled:y()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`privacy.micOn`,label:I(`Microphone on`,`Microfono attivo`),phrase:I(`Turn on the microphone of {device}`,`Attiva il microfono di {device}`),icon:`mic`,args:{enabled:!0}},{id:`privacy.micOff`,label:I(`Microphone off`,`Microfono spento`),phrase:I(`Turn off the microphone of {device}`,`Disattiva il microfono di {device}`),icon:`mic-off`,args:{enabled:!1}}]})},status:{schema:nX,kind:`poll`},runtimeState:nX,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`Privacy`,`Privacy`),order:3210,state:[{kind:`boolean`,field:`enabled`,label:I(`Privacy mask`,`Maschera privacy`),whenTrue:I(`When the privacy mask of {device} is turned on`,`Quando si attiva la maschera privacy di {device}`),whenFalse:I(`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:I(`Microphone`,`Microfono`),whenTrue:I(`When the microphone of {device} is turned on`,`Quando si attiva il microfono di {device}`),whenFalse:I(`When the microphone of {device} is turned off`,`Quando si disattiva il microfono di {device}`),icon:`mic`}]}};function Uwe(e){return e.length===0?null:e.some(e=>e.audioEnabled)}var oX=S([`home`,`day-mode`,`night-mode`,`day-night-auto`,`set-limits`,`save-limits`,`reboot`,`osd-menu`]),sX=x({id:m(),name:m(),fn:oX.nullable(),writable:y()}),cX=x({pan:p().nullable(),tilt:p().nullable(),zoom:p().nullable()}),lX=x({pan:p().optional(),tilt:p().optional(),zoom:p().optional(),speed:p().optional()}),uX=cX.extend({autofocus:y()}),dX=x({hasPan:y(),hasTilt:y(),hasZoom:y(),supportsPresets:y(),maxPresets:p().optional(),hasAutofocus:y(),speedSteps:p().int().positive().nullable(),moveImpulseMs:p().int().positive().nullable()}),fX=x({presetId:m().nullable(),source:S([`operator`,`firmware`,`native`,`none`])}),pX=x({enabled:y(),seconds:p().int()}),mX={name:`ptz`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/ptz-panel`,tab:`ptz`,topTab:!0,label:`PTZ`,order:0}},methods:{move:E(lX.extend({deviceId:p()}),v(),{kind:`mutation`,notOperatorFacing:`a relative nudge from the live-view joystick; a fixed place is a preset`}),continuousMove:E(lX.extend({deviceId:p()}),v(),{kind:`mutation`,notOperatorFacing:`joystick motion held until released — continuous, not a discrete step`}),goHome:E(x({deviceId:p()}),v(),{kind:`mutation`,actions:[{id:`ptz.goHome`,label:I(`PTZ go home`,`Torna alla posizione iniziale`),phrase:I(`Send {device} to its home position`,`Riporta {device} alla posizione iniziale`),icon:`house`}]}),getPresets:E(x({deviceId:p()}),C(sX)),goToPreset:E(x({deviceId:p(),presetId:m()}),v(),{kind:`mutation`,actions:[{id:`ptz.goToPreset`,label:I(`PTZ go to preset`,`Vai a un preset`),phrase:I(`Move {device} to {presetId}`,`Sposta {device} su {presetId}`),icon:`move`,openArgs:[{key:`presetId`,label:I(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}}]}]}),savePreset:E(x({deviceId:p(),presetId:m(),name:m()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.savePreset`,label:I(`Save PTZ preset here`,`Salva qui un preset`),phrase:I(`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:I(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}},{key:`name`,label:I(`Name`,`Nome`),offer:{kind:`text`}}]}]}),deletePreset:E(x({deviceId:p(),presetId:m()}),v(),{kind:`mutation`,auth:`admin`}),getOptions:E(x({deviceId:p()}),dX),stop:E(x({deviceId:p()}),v(),{kind:`mutation`,actions:[{id:`ptz.stop`,label:I(`Stop moving`,`Ferma il movimento`),phrase:I(`Stop {device} moving`,`Ferma il movimento di {device}`),icon:`square`}]}),getHomePreset:E(x({deviceId:p()}),fX),setHomePreset:E(x({deviceId:p(),presetId:m().nullable()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.setHomePreset`,label:I(`Set PTZ home preset`,`Imposta il preset iniziale`),phrase:I(`Make {presetId} the home position of {device}`,`Rendi {presetId} la posizione iniziale di {device}`),icon:`house`,openArgs:[{key:`presetId`,label:I(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}}]}]}),captureHomeHere:E(x({deviceId:p()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.captureHomeHere`,label:I(`Set PTZ home here`,`Imposta qui la posizione iniziale`),phrase:I(`Make where {device} points now its home position`,`Rendi la posizione attuale di {device} la sua posizione iniziale`),icon:`map-pin`}]}),getHomeReturn:E(x({deviceId:p()}),pX.nullable()),setHomeReturn:E(x({deviceId:p(),enabled:y(),seconds:p().int().min(0).max(3600)}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.setHomeReturn`,label:I(`Set PTZ return home`,`Imposta il ritorno alla posizione iniziale`),phrase:I(`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:I(`Return home`,`Torna alla posizione iniziale`),offer:{kind:`boolean`}},{key:`seconds`,label:I(`Idle seconds`,`Secondi da fermo`),offer:{kind:`number`,min:0,max:3600,step:1,unit:`s`}}]}]}),getPosition:E(x({deviceId:p()}),cX),setAutofocus:E(x({deviceId:p(),enabled:y()}),v(),{kind:`mutation`,actions:[{id:`ptz.autofocusOn`,label:I(`Autofocus on`,`Autofocus attivo`),phrase:I(`Turn on autofocus on {device}`,`Attiva l’autofocus su {device}`),icon:`focus`,args:{enabled:!0}},{id:`ptz.autofocusOff`,label:I(`Autofocus off`,`Autofocus spento`),phrase:I(`Turn off autofocus on {device}`,`Disattiva l’autofocus su {device}`),icon:`focus`,args:{enabled:!1}}]})},status:{schema:uX,kind:`command-driven`},vocabulary:{noun:I(`Pan / tilt / zoom`,`Brandeggio`),order:3220}},hX=x({targetType:m().describe(`Vendor target string (people/vehicle/pet); empty = camera default`),stopDelaySeconds:p().int().min(0).max(300).meta(k(`duration`)),disappearDelaySeconds:p().int().min(0).max(300).meta(k(`duration`))}),gX=x({value:m(),label:m()}),_X=x({enabled:y(),lastChangedAt:p(),currentSettings:hX.nullable(),supportedTargetTypes:C(gX)}),vX=_X.extend({lastFetchedAt:p()}),yX={name:`ptz-autotrack`,scope:`device`,deviceNative:!0,mode:`singleton`,kind:`wrapper`,defaultActive:!1,deviceTypes:[j.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/ptz-autotrack`,tab:`ptz`,topTab:!0,label:`Auto-Tracking`,order:5}},methods:{getStatus:E(x({deviceId:p()}),_X),setEnabled:E(x({deviceId:p(),enabled:y()}),v(),{kind:`mutation`,actions:[{id:`ptz.autotrackOn`,label:I(`Autotrack on`,`Inseguimento attivo`),phrase:I(`Start autotracking on {device}`,`Attiva l’inseguimento automatico su {device}`),icon:`crosshair`,args:{enabled:!0}},{id:`ptz.autotrackOff`,label:I(`Autotrack off`,`Inseguimento spento`),phrase:I(`Stop autotracking on {device}`,`Disattiva l’inseguimento automatico su {device}`),icon:`crosshair`,args:{enabled:!1}}]}),getSettings:E(x({deviceId:p()}),hX.nullable()),setSettings:E(x({deviceId:p(),settings:hX.partial()}),v(),{role:`admin`,kind:`mutation`,notOperatorFacing:`tracking tuning (target type, delays) — set once on the camera’s PTZ page`})},events:{onStatusChanged:{data:x({deviceId:p(),status:_X}),notOperatorFacing:"the `enabled` state trigger phrases both edges of this change"}},status:{schema:_X,kind:`command-driven`},runtimeState:vX,durability:`session`,history:`none`,vocabulary:{noun:I(`Autotracking`,`Inseguimento automatico`),order:3230,state:[{kind:`boolean`,field:`enabled`,label:I(`Autotracking`,`Inseguimento automatico`),whenTrue:I(`When autotracking is turned on for {device}`,`Quando si attiva l’inseguimento automatico di {device}`),whenFalse:I(`When autotracking is turned off for {device}`,`Quando si disattiva l’inseguimento automatico di {device}`),icon:`crosshair`}]}},bX=x({enabled:y().nullable(),onTime:p().min(0).nullable().meta(k(`duration`)),offTime:p().min(0).nullable().meta(k(`duration`)),lastFetchedAt:p()}),xX=p().int().nonnegative(),SX=p().int().min(0),CX={name:`pump-cycle`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.PetFountain],methods:{setEnabled:E(x({deviceId:xX,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.on`,label:I(`Pump cycle on`,`Ciclo pompa attivo`),phrase:I(`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`,label:I(`Pump cycle off`,`Ciclo pompa spento`),phrase:I(`Run the pump of {device} continuously`,`Fai lavorare la pompa di {device} in continuo`),icon:`timer-off`,args:{on:!1}}]}),setOnMinutes:E(x({deviceId:xX,minutes:SX}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.onMinutes`,label:I(`Set pump run time`,`Imposta il tempo di lavoro della pompa`),phrase:I(`Set the pump of {device} to run {minutes} minutes per cycle`,`Imposta la pompa di {device} a lavorare {minutes} minuti per ciclo`),icon:`timer`,openArgs:[{key:`minutes`,label:I(`Minutes`,`Minuti`),offer:{kind:`number`,min:0,step:1,unit:`min`}}]}]}),setOffMinutes:E(x({deviceId:xX,minutes:SX}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.offMinutes`,label:I(`Set pump rest time`,`Imposta il tempo di riposo della pompa`),phrase:I(`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`,openArgs:[{key:`minutes`,label:I(`Minutes`,`Minuti`),offer:{kind:`number`,min:0,step:1,unit:`min`}}]}]})},status:{schema:bX,kind:`push`},runtimeState:bX,durability:`session`,history:`none`,vocabulary:{noun:I(`Pump cycle`,`Ciclo della pompa`),order:2050,state:[{kind:`boolean`,field:`enabled`,label:I(`Pump cycle`,`Ciclo pompa`),whenTrue:I(`When {device} starts running its pump on a cycle`,`Quando {device} inizia a far lavorare la pompa a ciclo`),whenFalse:I(`When {device} runs its pump continuously`,`Quando {device} fa lavorare la pompa in continuo`),icon:`timer`}]}},wX={name:`reboot`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera,j.Sensor,j.Switch,j.Gateway],methods:{reboot:E(x({deviceId:p().int().nonnegative()}),x({success:s(!0)}),{kind:`mutation`,auth:`admin`,actions:[{id:`reboot.reboot`,label:I(`Reboot device`,`Riavvia il dispositivo`),phrase:I(`Reboot {device}`,`Riavvia {device}`),icon:`refresh-cw`}]})},vocabulary:{noun:I(`Reboot`,`Riavvio`),order:3240}},TX=x({owner:m(),kind:Li,title:m(),nameField:m(),fields:d(m(),u()),secretPaths:C(m()),rows:p().int().nonnegative()}),EX=x({id:iz,name:m(),rev:p().int(),updatedAt:p(),data:az}),DX={owner:m().min(1),kind:Li},OX={name:`record-entries`,scope:`system`,mode:`singleton`,methods:{listEntryKinds:E(x({}),x({kinds:C(TX)}),{auth:`admin`}),listEntries:E(x({...DX}),x({entries:C(EX)}),{auth:`admin`}),putEntry:E(x({...DX,id:iz.optional(),data:az,ifRev:p().int().min(1).optional()}),x({id:m(),rev:p().int()}),{kind:`mutation`,auth:`admin`}),deleteEntry:E(x({...DX,id:iz}),x({deleted:y()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.INTERNAL}},Wwe=`camstack`,kX=`recorder`,AX=x({profile:m(),startMs:p(),endMs:p()}),jX=S([`read`,`unreadable`]),MX=x({deviceId:p(),read:jX,ranges:C(AX),profilesWithFootage:C(m())}),NX=x({deviceId:p(),read:jX,days:C(p())}),PX=x({deviceId:p(),localMasterPath:m().nullable(),playbackUrl:m().nullable(),playbackEndpoints:C(m())}),FX=x({state:S([`ok`,`sleeping`,`unreachable`,`no-storage`,`index-empty`]),reason:m().optional(),coverageAsOf:p().optional()}),IX=x({source:m(),label:m(),addonId:m().optional(),availability:FX}),LX=x({transport:S([`archive`,`stream`,`realtime`]),coverage:S([`continuous`,`sparse`]),seek:S([`free`,`forward`,`segment`]),stepBack:y(),scrub:y(),rates:C(p().positive()).min(1).readonly(),exclusive:y()}),RX=a(`kind`,[x({kind:s(`hls`),manifest:PX}),x({kind:s(`clip`),source:m(),clipId:m(),startsAtMs:p()}),x({kind:s(`none`),reason:m()})]),zX={name:`recording`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:[j.Camera],methods:{listSources:E(x({deviceId:p()}),C(IX).readonly(),{kind:`query`,auth:`protected`}),getAvailability:E(x({deviceId:p(),provider:m().min(1),fromMs:p(),toMs:p(),profile:m().optional()}),MX,{kind:`query`,auth:`protected`}),getDaysWithRecordings:E(x({deviceId:p(),provider:m().min(1),fromMs:p(),toMs:p(),tzOffsetMinutes:p()}),NX,{kind:`query`,auth:`protected`}),getPlayback:E(x({deviceId:p(),provider:m().min(1),fromMs:p(),toMs:p(),profile:A.optional()}),RX,{kind:`query`,auth:`protected`}),getPlaybackOptions:E(x({deviceId:p(),provider:m().min(1)}),LX,{kind:`query`,auth:`protected`})},vocabulary:{noun:I(`Recording`,`Registrazione`),order:3250}},BX=x({deviceId:p(),enabled:y(),activeMode:Ac,nodeId:m(),storageBytes:p()}),VX=x({deviceId:p(),read:S([`read`,`unreadable`]),ranges:C(AX).readonly(),profilesWithFootage:C(m()).readonly()}),HX=x({deviceId:p(),read:S([`read`,`unreadable`]),days:C(p()).readonly()}),UX=x({deviceId:p(),usedBytes:p(),oldestMs:p().nullable().optional(),segments:p().optional(),residentBytes:p().optional(),residentOldestMs:p().nullable().optional()}),WX=x({locationId:m().nullable(),locationIds:C(m()).optional(),root:m().optional(),usedBytes:p(),availableBytes:p().nullable(),totalBytes:p().nullable()}),GX=x({nodeId:m(),totalUsedBytes:p(),devices:C(UX),devicesRead:S([`archive`,`unavailable`]).optional(),complete:y().optional(),locations:C(WX).optional()}),KX=x({deviceId:p(),profile:m(),fromLocationId:m(),toLocationId:m(),bytes:p(),files:p().int()}),qX=S([`unassigned`,`target-not-writable`,`below-threshold`,`no-headroom`]),JX=x({deviceId:p(),profile:m(),fromLocationId:m(),toLocationId:m().nullable(),bytes:p(),reason:qX}),YX=x({moves:C(KX),skipped:C(JX),bytesToMove:p(),jobIds:C(m())}),XX=x({throttleMbps:p().min(1).max(1e3).optional(),minMoveGb:p().min(0).optional()}),Gwe=x({deviceId:p().int(),profile:m(),locationId:m()}),Kwe=x({deviceId:p().int(),locationId:m()}),qwe=x({assignments:C(Gwe),pins:C(Kwe),defaultLocations:d(m(),m())}),Jwe=x({deviceId:p().int(),locationId:m().nullable()}),ZX=a(`kind`,[x({kind:s(`segment`),startMs:p(),durMs:p(),bytes:p()}),x({kind:s(`gap`),nearestEdgeMs:p().nullable(),prevEndMs:p().nullable().optional()})]),QX=x({data:b(Uint8Array)}),$X=x({data:b(Uint8Array),gopStartMs:p(),gopDurMs:p()}),eZ=a(`kind`,[x({kind:s(`ok`),data:b(Uint8Array),gopStartMs:p(),gopDurMs:p(),reachesRequestedEnd:y()}),x({kind:s(`spans-multiple-segments`),segmentEndMs:p()})]),tZ={name:`recording-archive`,scope:`system`,mode:`singleton`,exposesDeviceSettings:!0,status:{schema:BX,kind:`command-driven`},methods:{getAvailabilityBatch:E(x({deviceIds:C(p()).min(1).max(200),fromMs:p(),toMs:p()}),C(VX).readonly(),{role:`viewer`,kind:`query`,auth:`protected`}),getDaysWithRecordingsBatch:E(x({deviceIds:C(p()).min(1).max(200),fromMs:p(),toMs:p(),tzOffsetMinutes:p()}),C(HX).readonly(),{role:`viewer`,kind:`query`,auth:`protected`}),getStorageUsage:E(x({}),GX,{kind:`query`,auth:`admin`}),getDeviceConfig:E(x({deviceId:p()}),Bc,{role:`viewer`,kind:`query`,auth:`protected`}),locateSegment:E(x({deviceId:p(),profile:m(),epochMs:p()}),ZX,{kind:`query`,auth:`admin`}),readSegmentBytes:E(x({deviceId:p(),profile:m(),startMs:p()}),QX,{kind:`query`,auth:`admin`}),readGopBytes:E(x({deviceId:p(),profile:m(),startMs:p(),epochMs:p()}),$X,{kind:`query`,auth:`admin`}),readWindowBytes:E(x({deviceId:p(),profile:m(),startMs:p(),fromMs:p(),toMs:p()}),eZ,{kind:`query`,auth:`admin`}),setDeviceConfig:E(x({deviceId:p(),config:Bc}),Bc,{kind:`mutation`,auth:`admin`}),rescanStorage:E(x({deviceId:p()}),BX,{kind:`mutation`,auth:`admin`}),pruneFootage:E(x({deviceId:p(),reason:Js.optional()}),x({floorMs:p().nullable(),deletedBuckets:p().int(),reclaimedBytes:p().int()}),{kind:`mutation`,auth:`admin`}),deleteFootprint:E(x({deviceId:p(),fromMs:p().optional(),toMs:p().optional()}),x({deletedBuckets:p().int(),reclaimedBytes:p().int()}),{kind:`mutation`,auth:`admin`}),listOpsLog:E(Xs,C(Ys).readonly(),{kind:`query`,auth:`admin`}),renderGif:E(x({deviceId:p(),aroundMs:p(),preRollSec:p().min(0).max(30).default(2),postRollSec:p().min(0).max(30).default(5),maxWidth:p().int().min(120).max(1280).default(480),fps:p().int().min(1).max(15).default(5)}),x({gifBase64:m(),fromMs:p(),toMs:p()}),{kind:`mutation`,auth:`admin`}),renderClip:E(x({deviceId:p(),aroundMs:p(),preRollSec:p().min(0).max(30).default(3),postRollSec:p().min(0).max(30).default(7),maxWidth:p().int().min(160).max(1920).default(640)}),x({clipBase64:m(),mime:m(),fromMs:p(),toMs:p(),bytes:p().int()}),{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:E(Xc,x({paused:s(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:E(Xc,x({resumed:s(!0)}),{kind:`mutation`,auth:`admin`}),refreshStorageLocationsForMigration:E(Xc,x({refreshed:s(!0)}),{kind:`mutation`,auth:`admin`}),startStorageMigrationMove:E(Zc,x({jobId:m()}),{kind:`mutation`,auth:`admin`}),getStorageMigrationMoveStatus:E(x({jobId:m()}),qc.nullable(),{auth:`admin`}),cancelStorageMigrationMove:E(x({jobId:m()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),relocateFootage:E(Yc,x({jobId:m()}),{kind:`mutation`,auth:`admin`}),listRelocateJobs:E(x({}),C(qc).readonly(),{kind:`query`,auth:`admin`}),getRelocateResidue:E(Cl,wl,{kind:`query`,auth:`admin`}),reconcileLedgerAgainstDisk:E(Tl,kl,{kind:`mutation`,auth:`admin`}),cancelRelocateJob:E(x({jobId:m()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),planStorageRebalance:E(XX,YX,{kind:`query`,auth:`admin`}),startStorageRebalance:E(XX,YX,{kind:`mutation`,auth:`admin`}),getPlacement:E(x({}),qwe,{kind:`query`,auth:`admin`}),setDevicePlacement:E(Jwe,x({ok:s(!0)}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.STORAGE}},Ywe=S([`queue-full`,`camera-backoff`,`sleeping`,`camera-refused`,`no-keyframe`,`decode-failed`,`no-catalog-row`,`unsupported`,`unknown-device`,`uid-missing`]),Xwe=S([`deferred`,`final`]),nZ=`x-camstack-reason`;function Zwe(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 rZ=`x-camstack-reason-code`,iZ=`x-camstack-disposition`,Qwe=`x-camstack-clip-transport`,aZ=x({id:m(),source:m(),kind:S([`motion`,`object`,`audio`,`native`]),timeRange:x({startMs:p(),endMs:p()}),labels:C(m()).max(3).optional(),thumbnail:m().optional(),stillAtMs:p().optional(),eventIds:C(m()).optional(),eventCount:p().int().nonnegative().optional(),holes:C(x({startMs:p(),endMs:p()})).optional(),thumbnailMint:m().optional(),thumbnailUnavailable:x({reason:S([`sleeping`,`camera-refused`,`no-keyframe`,`unsupported`])}).optional(),catalogAsOf:p().optional(),nativeTypes:C(m()).optional(),behaviours:C(m()).optional(),streams:x({sub:x({id:m(),bytes:p().optional()}).optional(),main:x({id:m(),bytes:p().optional()}).optional()}).optional(),supportSub:y().optional(),playable:y().optional(),unplayableReason:m().optional(),inProgress:y().optional()}),oZ=x({playbackUrl:m(),format:S([`hls`,`mp4`]).optional(),served:A.optional(),playbackEndpoints:C(m()).optional(),token:m().optional()}),sZ=S([`authorised`]),$we=50*1024*1024,eTe=500*1024*1024,cZ=x({base64:m(),contentType:m(),name:m(),bytes:p().int().nonnegative(),served:A,durationMs:p().positive().optional()}),lZ=x({ticket:Ja,contentType:m(),name:m(),served:A,durationMs:p().positive().optional()}),uZ=S([`opus`,`pcmu`,`none`]),dZ=S([`not-requested`,`unsupported-ask`]),fZ=x({url:m().min(1),expiresAtMs:p(),transport:s(`forward-only`),served:A,servedAudio:uZ,audioReason:dZ.optional()}),pZ=[.25,.5,1,1.5,2,4,8],mZ=[.25,.5,1,1.5,2,4],hZ=[.25,.5,1],gZ=x({transport:S([`stream`,`file`]),seek:S([`forward`,`free`]),stepBack:y(),scrub:y(),rates:C(p().positive()).min(1).readonly()}),_Z=x({state:S([`ok`,`sleeping`,`unreachable`,`no-storage`,`index-empty`]),reason:m().optional(),catalogAsOf:p().optional()}),vZ=x({source:m(),label:m(),addonId:m().optional(),availability:_Z}),yZ={name:`videoclips`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:[j.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/clips-browser`,tab:`recording`,topTab:!0,label:`Clips`,order:100}},methods:{listClips:E(x({deviceId:p(),since:p(),until:p(),limit:p().int().positive().optional(),provider:m().min(1)}),C(aZ).readonly(),{kind:`query`,auth:`protected`}),listSources:E(x({deviceId:p()}),C(vZ).readonly(),{kind:`query`,auth:`protected`}),getClipPlayback:E(x({deviceId:p(),clipId:m(),profile:A.optional()}),oZ,{kind:`query`,auth:`protected`}),readClipBytes:D(x({deviceId:p(),clipId:m().min(1),provider:m().min(1),profile:A.optional(),maxBytes:p().int().positive().optional(),wake:sZ.optional()}),cZ,{kind:`query`,auth:`protected`}),offerClipBytes:D(x({deviceId:p(),clipId:m().min(1),provider:m().min(1),profile:A.optional(),maxBytes:p().int().positive().optional(),wake:sZ.optional()}),lZ,{kind:`query`,auth:`protected`}),dialClipStream:D(x({deviceId:p(),clipId:m().min(1),provider:m().min(1),profile:A.optional(),audio:uZ.optional()}),fZ,{kind:`query`,auth:`protected`}),getPlaybackOptions:D(x({deviceId:p(),provider:m().min(1)}),gZ,{kind:`query`,auth:`protected`})},vocabulary:{noun:I(`Video clips`,`Clip video`),order:3330}},tTe={stream:{transport:`stream`,seek:`forward`,stepBack:!1,scrub:!1,rates:mZ},realtimeStream:{transport:`stream`,seek:`forward`,stepBack:!1,scrub:!1,rates:hZ},file:{transport:`file`,seek:`free`,stepBack:!0,scrub:!0,rates:pZ}},bZ=p().min(.25).max(32),xZ=x({fromSec:p().nonnegative(),toSec:p().nonnegative()}).refine(e=>e.toSec>e.fromSec,{message:`dense range must have toSec > fromSec`}),SZ=x({everyMs:p().int().positive(),ranges:C(xZ).min(1).max(200)}),CZ=x({everyMs:p().int().positive(),outputFps:p().int().min(1).max(60).optional(),dense:SZ.optional()}).superRefine((e,t)=>{e.dense!==void 0&&e.dense.everyMs>=e.everyMs&&t.addIssue({code:ce.custom,message:`dense.everyMs must be strictly smaller than the base everyMs`,path:[`dense`,`everyMs`]})}),wZ=x({speed:bZ.optional(),timelapse:CZ.optional(),includeAudio:y(),maxLifeMs:p().int().positive(),deleteAfterDownload:y(),title:m().max(200).optional(),notifyTargetIds:C(m().min(1)).max(20).optional()}).superRefine((e,t)=>{e.speed!==void 0&&e.timelapse!==void 0&&t.addIssue({code:ce.custom,message:`speed and timelapse are mutually exclusive`,path:[`timelapse`]})}),TZ=S([`queued`,`rendering`,`ready`,`failed`,`expired`,`deleted`]),EZ=x({kind:s(`footage`),deviceId:p(),profiles:C(m()).min(1),fromMs:p(),toMs:p()}),DZ=x({kind:s(`clip`),deviceId:p(),provider:m().min(1),source:m().min(1),sourceLabel:m().min(1),clipId:m().min(1),catalogWindow:x({sinceMs:p(),untilMs:p()}),profile:S([`high`,`mid`,`low`]),wake:sZ.optional()}),OZ=a(`kind`,[EZ,DZ]),kZ=x({id:m(),deviceId:p(),profile:m(),fromMs:p(),toMs:p(),subject:OZ.optional(),options:wZ,state:TZ,progressPct:p().nullable(),fileBytes:p().nullable(),expiresAt:p(),deleteAfterDownload:y(),downloadedAt:p().nullable(),createdAt:p(),createdBy:m(),error:m().nullable()}),AZ=S([`catalog-miss`,`catalog-unreachable`,`no-file-for-window`,`clip-in-progress`,`unsupported-option`,`sleeping`,`camera-refused`,`fetch-failed`,`too-large-to-transfer`,`wake-expired`]);function nTe(e,t){return t.length>0?`${e}: ${t}`:e}function rTe(e){if(e===null)return null;let t=e.split(`:`,1)[0]??``,n=AZ.safeParse(t.trim());return n.success?n.data:null}var jZ=x({url:m(),endpoints:C(m())}),iTe=50*1024*1024,MZ=x({base64:m(),contentType:m(),name:m(),bytes:p().int().nonnegative()});function NZ(e){return e.profiles!==void 0&&e.profiles.length>0?[...e.profiles]:typeof e.profile==`string`&&e.profile.length>0?[e.profile]:[]}var aTe=x({deviceId:p(),profile:m().optional(),profiles:C(m()).min(1).optional(),fromMs:p().optional(),toMs:p().optional(),subject:OZ.optional(),options:wZ}).superRefine((e,t)=>{if(e.subject?.kind===`clip`){e.subject.deviceId!==e.deviceId&&t.addIssue({code:ce.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:ce.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:ce.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:ce.custom,message:`a footage export needs fromMs and toMs`,path:[`fromMs`]}),(e.subject?.kind===`footage`?[...e.subject.profiles]:NZ(e)).length<1&&t.addIssue({code:ce.custom,message:`pass profiles[] (min 1) or legacy profile`,path:[`profiles`]})});function oTe(e){if(e.subject!==void 0)return e.subject;let t=NZ(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 sTe(e){return e.subject===void 0?{kind:`footage`,deviceId:e.deviceId,profiles:[e.profile],fromMs:e.fromMs,toMs:e.toMs}:e.subject}var PZ={name:`recording-export`,scope:`system`,mode:`singleton`,methods:{createExport:E(aTe,kZ,{role:`viewer`,kind:`mutation`,auth:`protected`}),listExports:E(x({deviceId:p().optional()}),C(kZ),{role:`viewer`,kind:`query`,auth:`protected`}),getExport:E(x({exportId:m()}),kZ,{role:`viewer`,kind:`query`,auth:`protected`}),cancelExport:E(x({exportId:m()}),kZ,{role:`viewer`,kind:`mutation`,auth:`protected`}),deleteExport:E(x({exportId:m()}),kZ,{role:`viewer`,kind:`mutation`,auth:`protected`}),getDownloadUrl:E(x({exportId:m()}),jZ,{role:`viewer`,kind:`query`,auth:`protected`}),readExportBytes:E(x({exportId:m()}),MZ,{kind:`query`,auth:`protected`})},vocabulary:{notOperatorFacing:`recording exports — requested from the timeline, not an automation step`}},FZ=S([`continuous`,`motion`,`person`,`vehicle`,`animal`,`lineCrossing`,`intrusion`,`loitering`,`alarmInput`]),IZ=x({trigger:FZ,day:p().int().min(0).max(6).meta(k(`none`)),startMinute:p().int().min(0).max(1439).meta(k(`none`)),endMinute:p().int().min(1).max(1440).meta(k(`none`))}),LZ=x({id:m(),label:m().optional(),status:S([`ok`,`unformatted`,`error`,`offline`,`unknown`]),capacityMb:p().nullable(),freeMb:p().nullable(),writable:y().optional()}),RZ=a(`kind`,[x({kind:s(`present`),volumes:C(LZ)}),x({kind:s(`absent`),reason:m()}),x({kind:s(`unknown`),reason:m()})]),zZ=x({id:m(),enabled:y(),isVideo:y(),codec:m().nullable(),resolution:m().nullable(),overwriteWhenFull:y().nullable()}),BZ=x({storage:RZ,tracks:C(zZ),primaryTrackId:m().nullable(),enabled:y().nullable(),overwriteWhenFull:y().nullable(),preRecordSec:p().nullable().meta(k(`duration`)),postRecordSec:p().nullable().meta(k(`duration`)),segmentMinutes:p().nullable().meta(k(`none`)),windows:C(IZ),unreadableWindows:p().meta(k(`count`)),recordingToNowhere:y(),lastFetchedAt:p()}),VZ=x({min:p(),max:p(),step:p()}),HZ=x({values:C(p()).min(1),sentinel:x({value:p(),meaning:S([`no-limit`,`disabled`])}).optional()}),UZ=x({readable:y(),writable:y(),reason:m().optional()}),WZ=x({support:UZ,granularityMinutes:p(),triggers:C(FZ),supportsOverlappingTriggers:y()}),GZ=x({enabled:UZ,overwriteWhenFull:UZ,preRecordSec:UZ,preRecordSecRange:VZ.optional(),preRecordSecAllowed:HZ.optional(),postRecordSec:UZ,postRecordSecRange:VZ.optional(),postRecordSecAllowed:HZ.optional(),segmentMinutes:UZ,segmentMinutesRange:VZ.optional(),segmentMinutesAllowed:HZ.optional(),schedule:WZ}),KZ=x({enabled:y().optional(),overwriteWhenFull:y().optional(),preRecordSec:p().optional(),postRecordSec:p().optional(),segmentMinutes:p().optional(),windows:C(IZ).optional()}),qZ={name:`recording-onboard`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],deviceConfig:{ui:{kind:`derived-form`,builderId:`recording-onboard`,tab:`recording`}},methods:{getOptions:E(x({deviceId:p()}),GZ),setSettings:E(x({deviceId:p(),settings:KZ}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`recordingOnboard.on`,label:I(`On-camera recording on`,`Registrazione a bordo attiva`),phrase:I(`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:I(`On-camera recording off`,`Registrazione a bordo spenta`),phrase:I(`Turn off recording to the card of {device}`,`Disattiva la registrazione sulla scheda di {device}`),icon:`hard-drive`,args:{settings:{enabled:!1}}}]})},status:{schema:BZ,kind:`poll`},runtimeState:BZ,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`On-camera recording`,`Registrazione a bordo`),order:3260,state:[{kind:`boolean`,field:`recordingToNowhere`,label:I(`Recording to nowhere`,`Registra nel vuoto`),whenTrue:I(`When {device} is recording with no card to write to`,`Quando {device} registra senza una scheda su cui scrivere`),whenFalse:I(`When {device} has a card to record to again`,`Quando {device} ha di nuovo una scheda su cui registrare`),icon:`hard-drive`}]}},JZ=x({active:y(),reason:m(),lastChangedAt:p()}),YZ=JZ.extend({lastFetchedAt:p()}),XZ={name:`recording-signal`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],methods:{getStatus:E(x({deviceId:p()}),JZ)},status:{schema:JZ,kind:`push`,empty:{active:!1,reason:`unknown`,lastChangedAt:0}},runtimeState:YZ,durability:`session`,history:`none`,vocabulary:{noun:I(`Recording signal`,`Segnale di registrazione`),order:3270,state:[{kind:`boolean`,field:`active`,label:I(`Recording`,`In registrazione`),whenTrue:I(`When {device} starts recording`,`Quando {device} inizia a registrare`),whenFalse:I(`When {device} stops recording`,`Quando {device} smette di registrare`),icon:`circle-dot`}]}},ZZ=x({kind:s(`cap`),deviceId:p().int().nonnegative(),cap:m().min(1),method:m().min(1),args:d(m(),u()).optional(),argUnits:d(m(),m().min(1)).optional()}),QZ=x({action:ZZ}),$Z=x({key:m().refine(aT,{message:`a lowercase slug`}),name:m().min(1).max(60)});function cTe(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=vT(a);e!==null&&s(e,`payload`)}for(let t of _T(a))nT(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 eQ=x({index:p().int().nonnegative(),id:m().nullable(),name:m().nullable(),reason:m()}),tQ=x({layoutTemplateId:m().min(1).nullable(),defaultTransmitterId:p().int().nonnegative().nullable().default(null),bindings:d(m(),QZ),customButtons:C($Z).max(100),sources:C(hT).max(200).default([]),stepDelayMs:p().int().min(100).max(gT).default(500),refusedSources:C(eQ).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)nT(e)?t.addIssue({code:`custom`,message:`"${e}" is a layout widget, not a command: it cannot be bound`,path:[`bindings`,e]}):cT(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=sT(e);n!==null&&!r.has(n)&&t.addIssue({code:`custom`,message:`${e} is bound but has no entry in customButtons`,path:[`bindings`,e]})}cTe(e,t)}),lTe=o({sources:C(u())}),uTe=x({id:m(),name:m()}).partial();function dTe(e){let t=lTe.safeParse(e);if(!t.success)return nQ(tQ.safeParse(e));let n=[],r=[];t.data.sources.forEach((e,t)=>{let i=hT.safeParse(e),a=i.success&&i.data.kind===`ir`?vT(i.data):null;if(i.success&&a===null){n.push(e);return}let o=uTe.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=nQ(tQ.safeParse({...t.data,sources:n}));return!i.success||r.length===0?i:{success:!0,data:{...i.data,refusedSources:r}}}function nQ(e){return e.success?{success:!0,data:e.data}:{success:!1,issues:e.error.issues.length}}var fTe={layoutTemplateId:null,defaultTransmitterId:null,bindings:{},customButtons:[],sources:[],stepDelayMs:500},pTe=x({power:x({state:S([`on`,`off`]),at:p()}).nullable(),muted:x({value:y(),at:p()}).nullable(),source:x({name:m(),at:p()}).nullable().default(null)}),mTe={power:null,muted:null,source:null},rQ=[`rect`,`rounded`,`round`,`pill`],iQ=S(rQ),aQ=[`neutral`,`accent`,`danger`,`red`,`green`,`yellow`,`blue`],oQ=S(aQ),sQ=[`none`,`panel`,`divider`,`dpad`,`rocker-v`,`rocker-h`,`keypad`],cQ=S(sQ),lQ=x({id:m().min(1).max(40),row:p().int().min(0).max(24),col:p().int().min(0).max(24),rowSpan:p().int().min(1).max(24),colSpan:p().int().min(1).max(24),icon:m().min(1).max(60).optional(),label:m().min(1).max(40).optional(),role:lT,shape:iQ.optional(),tone:oQ.optional(),showLegend:y().optional(),groupId:m().min(1).max(40).optional()}),uQ=x({id:m().min(1).max(40),componentId:m().min(1).max(80),frame:cQ,row:p().int().min(0).max(24),col:p().int().min(0).max(24),rowSpan:p().int().min(1).max(24),colSpan:p().int().min(1).max(24),title:m().min(1).max(40).optional(),size:S([`compact`,`normal`]).optional(),hideTitle:y().optional()});function dQ(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 fQ(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 hTe(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&&dQ(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`]),fQ(n,e)||i(`button "${e.id}" lies outside its group "${n.id}"`,[`buttons`,t]);return}let a=n.find(t=>dQ(t,e));a!==void 0&&i(`button "${e.id}" lies inside group "${a.id}" but is not a member`,[`buttons`,t])})}var pQ=x({columns:p().int().min(1).max(24),rows:p().int().min(1).max(24),buttons:C(lQ).max(200),groups:C(uQ).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)}}),hTe(e,t)}),mQ=x({role:lT,label:m().optional(),custom:y()}),hQ=x({layoutTemplateId:m().nullable(),commands:C(mQ),sources:C(hT)}),gQ=[`no-remote`,`unbound-role`,`action-failed`,`unknown-source`,`unbound-step`,`undeclared-channel`,`press-timeout`,`no-transmitter`],_Q=S(gQ),vQ=a(`status`,[x({status:s(`sent`),sends:p().int().min(1)}),x({status:s(`skipped`),reason:s(`already-in-state`)}),x({status:s(`refused`),reason:_Q,detail:m().optional(),step:x({index:p().int().min(1),role:m()}).optional()})]),yQ=[`play`,`pause`,`stop`,`next`,`previous`,`setMute`,`selectSource`,`playMedia`,`turnOn`,`turnOff`,`volumeUp`,`volumeDown`,`channelUp`,`channelDown`],bQ=S(yQ),xQ=a(`status`,[...vQ.options,x({status:s(`not-routed`)})]),SQ=[`unknown-template`,`not-a-media-player`],CQ=a(`status`,[x({status:s(`saved`)}),x({status:s(`refused`),reason:S(SQ),detail:m()})]),wQ=x({deviceId:p().int().nonnegative()}),gTe={version:1,targets:[{id:`remote`,cardinality:`config`,vocabulary:{cap:`remote`},deviceTypes:[j.MediaPlayer],apply:`add`,readMethod:`getConfig`,writeMethod:`setConfig`}]},TQ={name:`remote`,scope:`system`,mode:`singleton`,methods:{getConfig:E(wQ,tQ,{auth:`admin`}),setConfig:E(wQ.extend({config:tQ}),CQ,{kind:`mutation`,auth:`admin`}),listCommands:E(wQ,hQ,{auth:`protected`}),sendCommand:E(wQ.extend({role:lT,repeat:p().int().min(1).max(50).default(1)}),vQ,{kind:`mutation`,auth:`protected`}),getAssumedStatus:E(wQ,wT.nullable(),{auth:`protected`}),sendMediaCommand:E(wQ.extend({command:bQ,muted:y().optional(),source:m().optional(),mediaType:m().optional(),mediaId:m().optional(),repeat:p().int().min(1).max(50).default(1)}),xQ,{kind:`mutation`,auth:`protected`})},customize:gTe,vocabulary:{notOperatorFacing:`the per-device remote setup — authored in the Customize remote editor, sent through the remote UI`}},EQ=[`power`,`navigation`,`volume`,`numbers`,`media`,`colour`,`apps`,`layout`],DQ=S(EQ),_Te=/^[a-z0-9][a-z0-9_.-]*:[a-z0-9][a-z0-9_-]*$/,OQ=x({idSuffix:m().regex(/^[a-z0-9][a-z0-9_-]{0,19}$/,{message:`a short lowercase slug`}),row:p().int().min(0).max(24),col:p().int().min(0).max(24),rowSpan:p().int().min(1).max(24),colSpan:p().int().min(1).max(24),role:lT,icon:m().min(1).max(60).optional(),label:m().min(1).max(40).optional(),shape:iQ.optional(),tone:oQ.optional(),showLegend:y().optional()}),kQ=x({id:m().max(80).regex(_Te,{message:`<namespace>:<name>, lowercase`}),name:m().min(1).max(60),nameI18n:x({en:m().min(1).max(60),it:m().min(1).max(60)}).optional(),icon:m().min(1).max(60),category:DQ,size:x({rows:p().int().min(1).max(24),cols:p().int().min(1).max(24)}),group:x({frame:cQ,title:m().min(1).max(40).optional()}).nullable(),buttons:C(OQ).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&&dQ(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`]})}),AQ={name:`remote-layout-components`,scope:`system`,mode:`collection`,methods:{listComponents:E(x({}),C(kQ),{auth:`protected`})},vocabulary:{notOperatorFacing:`the palette of the remote template editor — read-only data, never actuated`}},jQ=3e4,MQ=18e4,NQ={startDwellMs:jQ,stopDwellMs:MQ,minSamples:2},PQ={[j.MediaPlayer]:{startDwellMs:1e4,stopDwellMs:1e4,minSamples:1}};function FQ(e){return e!==void 0&&PQ[e]!==void 0}function IQ(e){return e===void 0?NQ:PQ[e]??NQ}var vTe={running:null,since:null,source:`native`,phase:null,lastFetchedAt:null},LQ=S([`native`,`assigned`]),RQ=x({running:y().nullable(),since:p().nullable().meta(k(`none`)),source:LQ.meta({label:`Source`}),phase:m().nullable(),lastFetchedAt:p().nullable()}),zQ=x({deviceId:p(),since:p().nullable(),phase:m().nullable()}),yTe=Object.values(j),BQ=[j.Washer,j.Dryer,j.Dishwasher,j.Vacuum,j.LawnMower,j.MediaPlayer,j.WaterHeater,j.Humidifier,j.Fan,j.Climate,j.PetFeeder],bTe={version:1,overridable:[{path:`running`,by:`running`}],targets:[{id:`running`,cardinality:`scalar`,vocabulary:{cap:`running-state`,stateField:`running`},deviceTypes:BQ,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:jQ,defaultStopDwellMs:MQ,deviceTypeDefaults:PQ,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}]},VQ={name:`running-state`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:yTe,methods:{},events:{onStarted:{data:zQ,trigger:{category:w.RunningStarted,label:I(`Started running`,`Ha iniziato a funzionare`),phrase:I(`When {device} starts running`,`Quando {device} inizia a funzionare`),icon:`play`}},onFinished:{data:zQ,trigger:{category:w.RunningFinished,label:I(`Finished`,`Ha finito`),phrase:I(`When {device} finishes`,`Quando {device} finisce`),icon:`square`}}},status:{schema:RQ,kind:`push`},runtimeState:RQ,durability:`restored`,history:{fields:{running:{kind:`boolean`}}},volatileStateFields:[`lastFetchedAt`],customize:bTe,vocabulary:{noun:I(`Running`,`In funzione`),order:2120,state:[{kind:`boolean`,field:`running`,label:I(`Running`,`In funzione`),whenTrue:I(`When {device} starts`,`Quando {device} inizia`),whenFalse:I(`When {device} finishes`,`Quando {device} finisce`),icon:`play`}],overrides:{byType:{[j.Washer]:{state:{running:{whenTrue:I(`When the washing machine starts`,`Quando la lavatrice inizia`),whenFalse:I(`When the washing machine has finished`,`Quando la lavatrice ha finito`)}},events:{onStarted:{phrase:I(`When the washing machine starts`,`Quando la lavatrice inizia`)},onFinished:{phrase:I(`When the washing machine has finished`,`Quando la lavatrice ha finito`)}}},[j.Dryer]:{state:{running:{whenTrue:I(`When the dryer starts`,`Quando l'asciugatrice inizia`),whenFalse:I(`When the dryer has finished`,`Quando l'asciugatrice ha finito`)}},events:{onStarted:{phrase:I(`When the dryer starts`,`Quando l'asciugatrice inizia`)},onFinished:{phrase:I(`When the dryer has finished`,`Quando l'asciugatrice ha finito`)}}},[j.Dishwasher]:{state:{running:{whenTrue:I(`When the dishwasher starts`,`Quando la lavastoviglie inizia`),whenFalse:I(`When the dishwasher has finished`,`Quando la lavastoviglie ha finito`)}},events:{onStarted:{phrase:I(`When the dishwasher starts`,`Quando la lavastoviglie inizia`)},onFinished:{phrase:I(`When the dishwasher has finished`,`Quando la lavastoviglie ha finito`)}}}}}}},HQ=m(),xTe=[`day`,`ir`,`night`,`dawn`,`dusk`],UQ=S([`skip`,`judge-anyway`]),STe=`__diverged__`,WQ=S([`matched`,`diverged`,`unknown`]),GQ=S([`no-reference-for-condition`,`view-shifted`,`no-vision-profile`,`encoder-model-changed`,`no-snapshot`]),KQ=x({embedding:C(p()),modelId:m(),condition:HQ,capturedAt:p(),thumbnailMediaId:p().int().optional(),anchorEmbedding:C(p()).optional()}),qQ=x({id:m(),label:m(),references:C(KQ),textPrompts:C(m()).optional(),referenceCount:p(),currentlyMatched:y()}),JQ=a(`mode`,[x({mode:s(`similarity`),threshold:p().min(0).max(1),hysteresisCount:p().int().positive()}),x({mode:s(`llm`),prompt:m(),profileId:m().optional(),hysteresisCount:p().int().positive()})]),YQ=.85,XQ=`skip`,ZQ=8e3,QQ=x({enabled:y().default(!1),prompt:m().min(1).max(1e3),profileId:m().optional(),timeoutMs:p().int().min(1e3).max(2e4).default(ZQ),maxImagePx:p().int().min(64).max(2048).default(448),onTimeout:S([`flip`,`hold`]).default(`hold`)}),$Q=x({id:m(),label:m(),roi:$z,enabled:y(),triggerMode:S([`periodic`,`on-motion`,`both`]),checkIntervalSec:p().optional(),check:JQ,states:C(qQ),currentStateId:m().nullable(),lastCheckedAt:p().nullable(),lastConfidence:p().nullable(),currentCondition:HQ.nullable(),availability:S([`ok`,`unavailable`]),unavailableReason:m().nullable(),baselineStateId:m().nullable(),emit:S([`latched`,`live`]).default(`latched`),verdict:WQ,latched:y(),armedAt:p(),divergedAt:p().nullable(),restoredAt:p().nullable(),quietSeconds:p().int().min(0).max(3600).default(60),minObservationSpacingSec:p().int().min(0).max(3600).default(120),confirm:QQ.optional(),anchorThreshold:p().min(0).max(1).default(YQ),autoRestore:y().default(!1),onUncoveredCondition:UQ.default(XQ),suspendedCondition:HQ.nullable().default(null),unavailable:GQ.nullable(),coveredConditions:C(HQ)}),e$=x({monitors:C($Q),lastFetchedAt:p()}),t$=x({deviceId:p(),status:e$.nullable()}),n$={name:`scene-monitor`,role:{feature:`scenes`},scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[j.Camera],methods:{listScenes:E(x({deviceId:p()}),e$),listScenesBatch:E(x({deviceIds:C(p()).min(1).max(200)}),C(t$).readonly()),createScene:E(x({deviceId:p(),label:m(),roi:$z,check:JQ,triggerMode:S([`periodic`,`on-motion`,`both`]).optional(),checkIntervalSec:p().optional()}),$Q,{kind:`mutation`,auth:`admin`}),updateScene:E(x({deviceId:p(),monitorId:m(),patch:x({label:m().optional(),roi:$z.optional(),enabled:y().optional(),triggerMode:S([`periodic`,`on-motion`,`both`]).optional(),checkIntervalSec:p().optional(),check:JQ.optional(),emit:S([`latched`,`live`]).optional(),quietSeconds:p().int().min(0).max(3600).optional(),minObservationSpacingSec:p().int().min(0).max(3600).optional(),anchorThreshold:p().min(0).max(1).optional(),autoRestore:y().optional(),onUncoveredCondition:UQ.optional(),confirm:QQ.nullable().optional()})}),v(),{kind:`mutation`,auth:`admin`}),deleteScene:E(x({deviceId:p(),monitorId:m()}),v(),{kind:`mutation`,auth:`admin`}),captureReference:E(x({deviceId:p(),monitorId:m(),stateId:m().optional(),label:m().optional(),condition:HQ.optional()}),x({stateId:m(),referenceCount:p()}),{kind:`mutation`,auth:`admin`}),deleteReference:E(x({deviceId:p(),monitorId:m(),stateId:m(),index:p()}),v(),{kind:`mutation`,auth:`admin`}),recheckNow:E(x({deviceId:p(),monitorId:m()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`sceneMonitor.recheck`,label:I(`Re-check a scene`,`Ricontrolla una scena`),phrase:I(`Re-check {monitorId} on {device} now`,`Ricontrolla subito {monitorId} su {device}`),icon:`scan-search`,openArgs:[{key:`monitorId`,label:I(`Scene`,`Scena`),offer:{kind:`dynamic`,from:`status`,field:`monitors`,valueKey:`id`,labelKey:`label`}}]}]}),resetScene:E(x({deviceId:p(),monitorId:m(),recapture:y().optional()}),v(),{kind:`mutation`,auth:`admin`})},status:{schema:e$,kind:`push`},runtimeState:e$,durability:`session`,history:`none`,vocabulary:{noun:I(`Scene watch`,`Controllo della scena`),order:3280,extraEvents:[{category:w.EnrichmentSceneStateChanged,label:I(`Scene changed`,`Scena cambiata`),phrase:I(`When a watched scene on {device} changes`,`Quando cambia una scena controllata su {device}`),icon:`scan-search`}]}},r$=x({schedulerId:m().min(1)}),i$={name:`schedulers`,scope:`system`,mode:`singleton`,methods:{list:E(x({}),C(p_),{auth:`admin`}),get:E(r$,x({scheduler:p_.nullable()}),{auth:`admin`}),create:E(x({scheduler:f_}),x({scheduler:p_}),{kind:`mutation`,auth:`admin`}),update:E(x({schedulerId:m().min(1),scheduler:f_}),x({scheduler:p_}),{kind:`mutation`,auth:`admin`}),delete:E(r$,v(),{kind:`mutation`,auth:`admin`}),setEnabled:E(x({schedulerId:m().min(1),profileId:m().min(1).optional(),enabled:y()}),x({scheduler:p_}),{kind:`mutation`,auth:`admin`}),preview:E(x({schedulerId:m().min(1),date:m().regex(h_).optional()}),Nue,{auth:`admin`}),conflicts:E(x({scheduler:f_,schedulerId:m().min(1).optional()}),x({conflicts:C(Pue)}),{auth:`admin`}),getStatus:E(x({}),C(Iue),{auth:`admin`}),getTraces:E(r$,x({traces:C(y_)}),{auth:`admin`})},vocabulary:{notOperatorFacing:`time schedulers — authored on their own page, not device actions`}},a$=x({isRunning:y(),lastRunAt:p(),lastRunSuccess:y().nullable(),lastError:m().nullable(),lastChangedAt:p()}),o$={name:`script-runner`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Script],methods:{run:E(x({deviceId:p().int().nonnegative(),variables:d(m(),u()).optional()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`script.run`,label:I(`Run script`,`Esegui lo script`),phrase:I(`Run {device}`,`Esegui {device}`),icon:`scroll-text`}]}),stop:E(x({deviceId:p().int().nonnegative()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`script.stop`,label:I(`Stop script`,`Ferma lo script`),phrase:I(`Stop {device}`,`Ferma {device}`),icon:`square`}]})},status:{schema:a$,kind:`push`},runtimeState:a$,durability:`session`,history:`none`,vocabulary:{noun:I(`Script`,`Script`),order:2090,state:[{kind:`boolean`,field:`isRunning`,label:I(`Running`,`In esecuzione`),whenTrue:I(`When {device} starts running`,`Quando {device} parte`),whenFalse:I(`When {device} finishes`,`Quando {device} termina`),icon:`scroll-text`}]}},s$=S([`workspace`,`baked`,`data-root`]),c$=S([`idle`,`checking`,`staging`,`pending-restart`,`awaiting-confirmation`]),l$=S([`in-sync`,`behind-patch`,`behind-series`,`ahead`,`unknown`]),u$=x({state:l$,seedVersion:m().nullable(),contractVersion:m().nullable(),contractSource:S([`registry`,`running`]).nullable(),message:m()}),d$=S([`docker`,`electron`,`native`,`contradictory`,`unknown`]),f$=x({fact:S([`dockerenv-file`,`proc-1-cgroup`,`platform`,`electron-app-version-env`]),mode:S([`observed`,`declared`]),holds:y(),detail:m()}),p$=x({kind:d$,evidence:C(f$),currentVersion:m().nullable()}),m$=x({fromVersion:m(),toVersion:m().nullable(),atMs:p(),reason:m()}),h$=x({version:m(),update:x({available:y(),downloaded:y(),version:m().nullable(),checking:y(),error:m().nullable()}),stateAtMs:p(),stale:y()}),g$=S([`not-electron`,`no-app-state`,`app-state-stale`,`not-downloaded`]),_$=x({accepted:y(),reason:g$.nullable()}),v$=x({runnerId:m(),addonIds:C(m()),reason:m()}),y$=x({checkedAtMs:p(),expected:p(),running:p(),failed:C(m()),refused:C(v$),missing:C(m()),pending:C(m()).optional(),planKnown:y()}),b$=x({packageName:m(),runningVersion:m().nullable(),nodeRuntimeVersion:m().nullable(),activeVersion:m().nullable(),installedVersion:m().nullable().optional(),restartRequired:y().optional(),previousVersion:m().nullable(),seedVersion:m().nullable(),latestVersion:m().nullable(),updateAvailable:y(),bootMode:s$,updateState:c$,pendingVersion:m().nullable(),rolledBack:m$.nullable(),stateFileCorrupt:y(),lastCheckedAtMs:p().nullable(),imageContract:u$.optional(),wrapper:p$.optional(),runners:y$.optional(),desktopApp:h$.optional()}),x$=x({packageName:m(),runningVersion:m().nullable(),latestVersion:m().nullable(),updateAvailable:y(),checkedAtMs:p(),error:m().nullable(),pendingVersion:m().nullable().optional(),restartRequired:y().optional()}),S$=S([`staged`,`restart-scheduled`,`already-current`,`refused`,`failed`]),C$=x({addonId:m(),reason:m(),remedy:m()}),w$=x({accepted:y(),targetVersion:m().nullable(),restarting:y(),message:m(),outcome:S$.optional(),reason:m().nullable().optional(),error:m().nullable().optional(),blockers:C(C$).optional(),unmet:C(Ir).optional(),requiredAddonUpdates:C(Lr).optional()}),T$=x({heapMb:p().int().nullable(),rssBudgetMb:p().int().nullable()}),CTe=x({heapMb:p().int().min(512).max(65536).nullable(),rssBudgetMb:p().int().min(512).max(65536).nullable().optional()}),wTe=T$.extend({restartRequired:y()}),E$={name:`server-management`,scope:`system`,mode:`singleton`,methods:{getServerPackageStatus:E(v(),b$,{auth:`admin`}),checkServerUpdate:E(v(),x$,{kind:`mutation`,auth:`admin`}),applyServerUpdate:E(x({version:m().optional(),acknowledgeRefusals:y().optional()}),w$,{kind:`mutation`,auth:`admin`,timeoutMs:16*6e4}),installDesktopUpdate:E(v(),_$,{kind:`mutation`,auth:`admin`}),rollbackServerUpdate:E(v(),w$,{kind:`mutation`,auth:`admin`}),restartServer:E(v(),w$,{kind:`mutation`,auth:`admin`}),getLaunchOverrides:E(v(),T$,{auth:`admin`}),setLaunchOverrides:E(CTe,wTe,{kind:`mutation`,auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:O.CLUSTER}},D$=x({detected:y(),lastChangedAt:p()}),O$={name:`smoke`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor],methods:{},status:{schema:D$,kind:`push`},runtimeState:D$,durability:`restored`,history:{fields:{detected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:I(`Smoke detector`,`Rilevatore di fumo`),order:5190,state:[{kind:`boolean`,field:`detected`,label:I(`Detected`,`Rilevato`),whenTrue:I(`When {device} detects smoke`,`Quando {device} rileva fumo`),whenFalse:I(`When smoke clears on {device}`,`Quando il fumo su {device} si dirada`),icon:`alarm-smoke`}]}},k$=5*1024*1024,A$=`<!--camstack-images-->`,j$=x({ticket:Ja,mime:m().min(1),name:m().min(1),contentId:m().min(1),placement:S([`inline`,`attachment`]),deviceId:p().int().nonnegative().optional()}),M$=0;function N$(e){return M$+=1,`camstack_${e}_${M$.toString(36)}_${Date.now().toString(36)}`}function TTe(e){return/^[\x20-\x7E]*$/.test(e)?e:`=?UTF-8?B?${Buffer.from(e,`utf8`).toString(`base64`)}?=`}function P$(e){return(Array.isArray(e)?e:[e]).join(`, `)}function ETe(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`)}function F$(e,t){let n=e.replace(/[\r\n"]/g,``).trim();return n.length>0?n:t}function DTe(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
1109
1109
  `)}function OTe(e){return`<img src="cid:${ETe(e.contentId)}" alt="">`}function kTe(e,t){return e.replaceAll(A$,t.map(OTe).join(``))}function I$(e){let t=[`From: ${e.from}`,`To: ${P$(e.to)}`];return e.cc!==void 0&&e.cc.length>0&&t.push(`Cc: ${P$(e.cc)}`),e.bcc!==void 0&&e.bcc.length>0&&t.push(`Bcc: ${P$(e.bcc)}`),e.replyTo!==void 0&&e.replyTo.length>0&&t.push(`Reply-To: ${e.replyTo}`),t.push(`Subject: ${TTe(e.subject)}`),t.push(`MIME-Version: 1.0`),t}function L$(e,t){return[`--${e}`,`Content-Type: text/plain; charset="UTF-8"`,`Content-Transfer-Encoding: 8bit`,``,t]}function R$(e,t){return[`--${e}`,`Content-Type: text/html; charset="UTF-8"`,`Content-Transfer-Encoding: 8bit`,``,t]}function z$(e,t){let n=F$(t.mime,`image/jpeg`),r=F$(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: <${F$(t.contentId,`image`)}>`),a.push(``,DTe(t.bytes)),a}function B$(e,t,n){let r=N$(`alt`);return[`--${e}`,`Content-Type: multipart/alternative; boundary="${r}"`,``,...L$(r,t),...R$(r,n),`--${r}--`]}function ATe(e,t){let n=I$(e);if(t!==void 0){let r=N$(`alt`);return n.push(`Content-Type: multipart/alternative; boundary="${r}"`,``),n.push(...L$(r,e.text),...R$(r,t),`--${r}--`),n}return n.push(`Content-Type: text/plain; charset="UTF-8"`,`Content-Transfer-Encoding: 8bit`,``,e.text),n}function jTe(e,t,n){let r=N$(`mix`),i=I$(e);i.push(`Content-Type: multipart/mixed; boundary="${r}"`,``),t===void 0?i.push(...L$(r,e.text)):i.push(...B$(r,e.text,t));for(let e of n)i.push(...z$(r,e));return i.push(`--${r}--`),i}function MTe(e,t,n,r){let i=N$(`rel`),a=I$(e);a.push(`Content-Type: multipart/related; boundary="${i}"; type="multipart/alternative"`,``,...B$(i,e.text,t));for(let e of n)a.push(...z$(i,e));for(let e of r)a.push(...z$(i,e));return a.push(`--${i}--`),a}function V$(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?kTe(e.html,n):void 0;return i!==void 0&&n.length>0?MTe(e,i,n,r).join(`\r
1110
1110
  `):r.length>0||n.length>0?jTe(e,i,r.length>0?r:n).join(`\r
1111
1111
  `):ATe(e,i).join(`\r