@camstack/addon-admin-ui 1.2.718 → 1.2.719
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/assets/{AccessSection-P1MJ1Af8.js → AccessSection-BDNf7fWa.js} +1 -1
- package/dist/assets/{Addons-CoLqo2lc.js → Addons-BBg5QUv1.js} +3 -3
- package/dist/assets/AdminPage-Cgexl7PK.js +1 -0
- package/dist/assets/{AdminSectionedPage-hd8ao26g.js → AdminSectionedPage-DeBFqnL9.js} +1 -1
- package/dist/assets/AiProfiles-DK-d5If4.js +3 -0
- package/dist/assets/{Archive-0caQVUfL.js → Archive-BmeuZDgK.js} +1 -1
- package/dist/assets/{BootstrapSettingsForm-DZNHEP1l.js → BootstrapSettingsForm-CQ3gKeRA.js} +1 -1
- package/dist/assets/{Build-KW1nXkOY.js → Build-C46zZKEk.js} +4 -4
- package/dist/assets/{Calendars-Cqys33rs.js → Calendars-B2_pD0Oc.js} +1 -1
- package/dist/assets/{Cluster-Dey295CP.js → Cluster-D35XsJOD.js} +1 -1
- package/dist/assets/{CompositionBlockEditor-cTC7q4ie.js → CompositionBlockEditor-QKA5nMCB.js} +2 -2
- package/dist/assets/CompositionEditorPage-BsIycFw4.js +1 -0
- package/dist/assets/{Data-BgtEMfAp.js → Data-Dufa6STk.js} +2 -2
- package/dist/assets/DeviceDetail-iGVYGmkf.js +1 -0
- package/dist/assets/{Devices--k3NZKM5.js → Devices-DjJ2lZFz.js} +1 -1
- package/dist/assets/{EmbedDevicePage-D1M9MuyT.js → EmbedDevicePage-B6jliGSU.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-BOYfGF6S.js → EmbedPlayerPage-DPSpe0fe.js} +1 -1
- package/dist/assets/{History-Cj_RFHCP.js → History-YW45zgFF.js} +1 -1
- package/dist/assets/{Identity-BpkCUd4w.js → Identity-CB93BP9K.js} +1 -1
- package/dist/assets/InstancesTable-DqOZKOiw.js +1 -0
- package/dist/assets/{IntegrationDetail-C0zFWEqE.js → IntegrationDetail-DRGef_TD.js} +1 -1
- package/dist/assets/{Integrations-CtaAEnny.js → Integrations-BLSCtn93.js} +2 -2
- package/dist/assets/Integrations-D3HWeUYL.js +1 -0
- package/dist/assets/{Library-CA4q_GKE.js → Library-B0AK9o5k.js} +1 -1
- package/dist/assets/{Locations-Cyc1rEId.js → Locations-MSracM56.js} +2 -2
- package/dist/assets/{Logs-Bdh6t2qZ.js → Logs-C9YNGUTC.js} +1 -1
- package/dist/assets/{MaskShapeCanvas-CRrBVQN6.js → MaskShapeCanvas-DdB2to38.js} +1 -1
- package/dist/assets/{MotionZonesSettings-BpOT--yi.js → MotionZonesSettings-C0AZq1h1.js} +1 -1
- package/dist/assets/{MyAccess-Bip69nz7.js → MyAccess-D1eUb8NO.js} +1 -1
- package/dist/assets/{Network-DpJy2Ox2.js → Network-D5UuhaFs.js} +1 -1
- package/dist/assets/{NewExportModal-Bh8ZMA-X.js → NewExportModal-CRG5X9Xd.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-ZE9xL-Lw.js → NodeAddonsSettingsPanel-DK5hH6AQ.js} +1 -1
- package/dist/assets/Notifications-DkXaGj0i.js +1 -0
- package/dist/assets/{PanelContent-C7DmssXY.js → PanelContent-DvRTzrSI.js} +1 -1
- package/dist/assets/{Pipeline-B4OKUAfV.js → Pipeline-CUzcbUT6.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-cBVnAPXJ.js → PrivacyMaskSettings-DMAeCCre.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-BN6VvtMB.js → SceneMonitorEditor-yL3465Qt.js} +1 -1
- package/dist/assets/{SessionsList-BP--gkgA.js → SessionsList-DeqXjMvl.js} +1 -1
- package/dist/assets/{Showroom-io1e71Ip.js → Showroom-C8uNo6FX.js} +1 -1
- package/dist/assets/{StorageLocationsTable-Din9h-wU.js → StorageLocationsTable-Blio9Uwn.js} +1 -1
- package/dist/assets/{System-BF52Cmv1.js → System-B_Bhbm6A.js} +2 -2
- package/dist/assets/{TemplateEditorDialog-uOp2nN0j.js → TemplateEditorDialog-B7nwBFDa.js} +1 -1
- package/dist/assets/{Terminal-CBEq96Qx.js → Terminal-BSi5279J.js} +1 -1
- package/dist/assets/{TrainingProviders-DCnc4U_D.js → TrainingProviders-B5mWrv0H.js} +1 -1
- package/dist/assets/{Viewer-Dsyh2qsY.js → Viewer-CVHhRxp4.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-C2vqPlWv.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BcuvvAg7.js} +1 -1
- package/dist/assets/{action-draft-Dnkwhjii.js → action-draft-mvm1fG3Z.js} +1 -1
- package/dist/assets/{assignment-candidates-CmTpbdAE.js → assignment-candidates-BspACTRE.js} +1 -1
- package/dist/assets/{authed-media-Br5-b-q4.js → authed-media-C1lGKHUu.js} +1 -1
- package/dist/assets/{camera-block-model-BNOrk3xs.js → camera-block-model-Cy-p9VXW.js} +1 -1
- package/dist/assets/{client-IyXbQ5wB.js → client-CiiufhtZ.js} +1 -1
- package/dist/assets/{command-vocab-UYmHJdEK.js → command-vocab-DrT4yI_w.js} +1 -1
- package/dist/assets/{device-integration-icon-DehLyJtV.js → device-integration-icon-ltuTuHtu.js} +1 -1
- package/dist/assets/device-picker-model-CHH_K0iv.js +1 -0
- package/dist/assets/{dist-BueezuOF.js → dist-3oPp68KS.js} +1 -1
- package/dist/assets/{dist-DmzPECbr.js → dist-DFGzwWFe.js} +1 -1
- package/dist/assets/{hostInit-BMtkho8X.js → hostInit-CML8wGF-.js} +1 -1
- package/dist/assets/{icons-BUNXeEdz.js → icons-C86IhfQA.js} +1 -1
- package/dist/assets/index-BVScunnp.css +2 -0
- package/dist/assets/{index-BmLC_5Cb.js → index-BYgap-bt.js} +4 -4
- package/dist/assets/{linked-devices-model-BGMuuMzy.js → linked-devices-model-Bdif5rHp.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-a78a180a.js → mf-entry-bootstrap-0-442bdc59.js} +2 -2
- package/dist/assets/mount-CHH_K0iv.js +1 -0
- package/dist/assets/{player-overlays-DkSQ1HVl.js → player-overlays-CX_koJa1.js} +1 -1
- package/dist/assets/remoteEntry-CWH31XW5.js +1 -0
- package/dist/assets/{src-CW12NqJP.js → src-vFbZMtSO.js} +20 -20
- package/dist/assets/{step-inspector-model-D3UkdAKW.js → step-inspector-model-xQUBFCp-.js} +1 -1
- package/dist/assets/{use-scenes-feed-Bl2YPeyM.js → use-scenes-feed-CzaOWh_W.js} +1 -1
- package/dist/assets/{useAdminDeviceRemoval-Bzc7SQeT.js → useAdminDeviceRemoval-D_Wkm6SL.js} +1 -1
- package/dist/assets/useEventInvalidation-CHH_K0iv.js +1 -0
- package/dist/assets/{useNodeUrlSelection-CI6VTVnc.js → useNodeUrlSelection-CfVGV8Yj.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-Ctg3L5lP.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CGyGOGfX.js} +2 -2
- package/dist/index.html +7 -7
- package/dist/server/addon.js +3 -1
- package/package.json +2 -2
- package/dist/assets/AdminPage-BGa6IwpR.js +0 -1
- package/dist/assets/AiProfiles-Bmr8Ii_9.js +0 -3
- package/dist/assets/CompositionEditorPage-DiSpMpz9.js +0 -1
- package/dist/assets/DeviceDetail-DHJ9hpXL.js +0 -1
- package/dist/assets/InstancesTable-dsVwH4u-.js +0 -1
- package/dist/assets/Integrations-BNgcJLme.js +0 -1
- package/dist/assets/Notifications-DEex-X-t.js +0 -1
- package/dist/assets/device-picker-model-Bopf0JEx.js +0 -1
- package/dist/assets/index-zqjSOnoV.css +0 -2
- package/dist/assets/mount-Bopf0JEx.js +0 -1
- package/dist/assets/remoteEntry-B1UIN5Qt.js +0 -1
- package/dist/assets/useEventInvalidation-Bopf0JEx.js +0 -1
|
@@ -1110,7 +1110,7 @@ ${d.map(({leaf:e,path:t})=>L_e(e,t)).join(`
|
|
|
1110
1110
|
for (const dispose of disposers) dispose()
|
|
1111
1111
|
}
|
|
1112
1112
|
}
|
|
1113
|
-
`}function J_e(e){return`subjects`in e?e.subjects:e.classes.map(u_)}var Y_e=new Set(Object.values(r_.mapping));function X_e(e){return r_.mapping[e]??e}function Z_e(e,t){let n=e.toLowerCase(),r=t.toLowerCase();return n===r?!0:Y_e.has(n)&&X_e(r)===n}function Q_e(e){return e===`start`||e===`update`||e===`end`}var $_e=class{trigger;fired=new Map;subjects;constructor(e){this.trigger=e,this.subjects=J_e(e)}get firedCount(){return this.fired.size}evaluate(e,t){let{deviceId:n,trackId:r,phase:i}=e;if(typeof n!=`number`||typeof r!=`string`||!Q_e(i))return{kind:`ignore`,why:`malformed track-lifecycle event`};if(!this.trigger.deviceIds.includes(n))return{kind:`ignore`,why:`device ${n} is not one of the trigger's devices`};let a=`${n}|${r}`;if(i===`end`)return this.fired.delete(a),{kind:`ignore`,why:`track ended`};this.expire(t);let o=typeof e.bestClassName==`string`?e.bestClassName:``,s=typeof e.bestConfidence==`number`?e.bestConfidence:0,c={deviceId:n,className:o,trackId:r,score:s,label:``};if(this.fired.has(a))return{kind:`reject`,reason:`already fired for track ${r}`,vars:c};let l=m_(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 eve(e){return`classes`in e}function tve(e){return e===`appeared`||e===`departed`}function nve(e,t){let{deviceId:n,entryId:r,phase:i}=t;if(typeof n!=`number`||typeof r!=`string`||!tve(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=eve(e)?e.classes?.map(u_):e.subjects;if(c!==void 0){let e=m_(c,{className:a});if(!e.matches)return{kind:`reject`,reason:e.reason,vars:s}}return e.zones!==void 0&&!e.zones.some(e=>o.includes(e))?{kind:`reject`,reason:`zone mismatch: in [${o.join(`, `)}], wanted [${e.zones.join(`, `)}]`,vars:s}:{kind:`fire`,reason:`${a} ${i} on device ${n}`,vars:s}}var Mb=x({deviceId:n(),eventType:l(),sourceId:l().optional(),data:m(l(),w()).nullable(),timestamp:n().meta(N(`none`)),seq:n().meta(N(`count`))}),Nb=x({eventTypes:C(l()),vocabulary:C(Pme).default([]),lastEvent:Mb.nullable(),eventCountSinceStart:n().meta(N(`count`))}),Pb={name:`event-emitter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.EventEmitter],methods:{},events:{onEvent:{data:Mb,trigger:{category:T.EventEmitted,label:F(`Fired an event`,`Ha generato un evento`),phrase:F(`When {device} fires an event`,`Quando {device} genera un evento`),icon:`zap`}}},status:{schema:Nb,kind:`push`},runtimeState:Nb,durability:`session`,history:`none`,vocabulary:{noun:F(`Event source`,`Sorgente di eventi`),order:5280}},rve=3,ive=32;function ave(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`}function Fb(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ib(e){let t={},n=(e,r,i)=>{if(!(Object.keys(t).length>=ive)){if(ave(e)){t[r]=e;return}if(!(!Fb(e)||i>=rve))for(let[t,a]of Object.entries(e))n(a,`${r}.${t}`,i+1)}};if(Fb(e))for(let[t,r]of Object.entries(e))n(r,`data.${t}`,1);return t}function ove(e,t){let n=e;for(let e of t.split(`.`)){if(!Fb(n))return;n=n[e]}return n}function Lb(e,t){return t===null?!0:e.timestamp===t.timestamp?e.seq>t.seq:e.timestamp>t.timestamp}var Rb=`recovered by reconcile`,sve=class{leaf;#e=null;#t=!1;#n=null;constructor(e){this.leaf=e}onEvent(e){let t=Mb.safeParse(e);if(!t.success)return{kind:`ignore`,why:`malformed event`};let n=t.data;return n.deviceId===this.leaf.deviceId?Lb(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=Nb.safeParse(e);if(!t.success)return{kind:`ignore`,why:`the event-emitter status is unreadable`};this.#n=Bme(t.data);let n=t.data.lastEvent,r=!this.#t;return this.#t=!0,n===null?{kind:`ignore`,why:`the device has not fired`}:Lb(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??Rme([e.eventType]);return(Ag(t,e.eventType,e.sourceId)??Ag(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=Ib(e.data);for(let t of a??[]){let n=ove(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} — ${Rb}`:l,vars:s,data:c}}},zb=6e4;function Bb(e){return(e/zb).toFixed(1)}var cve=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*zb;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 ${Bb(n)} min ago`};let r=`${Bb(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 ${Bb(n)} min ago, ${r}`}}},Vb=S([`string`,`number`,`boolean`,`select`]),lve=/^[A-Za-z_][A-Za-z0-9_]*$/,Hb=h([l(),n(),y()]),Ub=x({name:l().regex(lve),label:l().min(1).max(120).optional(),type:Vb,required:y().optional(),default:Hb.optional(),options:C(l().min(1)).min(1).optional()}).superRefine((e,t)=>{e.type===`select`&&e.options===void 0&&t.addIssue({code:`custom`,message:`a select variable needs options`,path:[`options`]}),e.default!==void 0&&Wb(e,e.default)!==null&&t.addIssue({code:`custom`,message:Wb(e,e.default)??`invalid default`,path:[`default`]})});function Wb(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 uve(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=Wb(e,t);if(n!==null)return{ok:!1,error:n};i[e.name]=t}return{ok:!0,values:i}}var Gb=S([`internal`,`addon`]),Kb=`internal:`;function dve(e){return`${Kb}${e}`}function qb(e){return e.startsWith(`internal:`)&&e.length>9}function Jb(e){if(qb(e))return null;let t=e.indexOf(`:`);return t>0&&t<e.length-1?e.slice(0,t):null}var Yb=x({isRunning:y(),lastRunAt:n().nullable(),lastError:l().nullable()}),fve={isRunning:!1,lastRunAt:null,lastError:null},Xb=n().int().min(0).max(86400),Zb=x({id:l().min(3),name:l().min(1).max(120),addonId:l().min(1),source:Gb,readOnly:y(),steps:C(bv).min(1).max(50).optional(),variables:C(Ub).max(20).optional(),minDelaySec:Xb.optional(),tags:Hh.optional(),status:Yb}).superRefine((e,t)=>{if(e.source===`internal`){qb(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`]}),Jb(e.id)===null&&t.addIssue({code:`custom`,message:`an addon action id is <addonId>:<localId>`,path:[`id`]})}),Qb=x({name:l().min(1).max(120),steps:C(bv).min(1).max(50),variables:C(Ub).max(20).optional(),minDelaySec:Xb.optional(),tags:Hh.optional()}),$b=x({blockId:l().min(1).optional()}),ex=h([xy,p(`started`),p(`timed-out`)]),tx=x({runId:l().min(1),outcome:ex,message:l().optional()}),pve=S([`not-found`,`read-only`,`invalid-variables`,`invalid-steps`,`not-linked`,`template-scope`,`busy`]),mve=class extends Error{code;constructor(e,t){super(`[${e}] ${t}`),this.name=`ActionError`,this.code=e}},nx=x({actionId:l(),runId:l(),isRunning:y(),outcome:xy.optional(),lastRunAt:n().nullable(),lastError:l().nullable()});function hve(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 rx(e){return[...e.kind===`command`&&e.target.kind===`devices`?[{actionId:e.actionId,ids:e.target.ids}]:[],...hve(e).flatMap(rx)]}async function gve(e,t){let n=e.flatMap(rx);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){Ba(e,void 0);for(let n of t)Gne(e,n,i.get(n)??[])}}async function _ve(e,t,n=Date.now,r,i,a){let o=r?.mirror??new fb(cb(e));await o.refresh(t);let s=yb(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 vve(e){try{return await e()}catch(e){return{result:`unknown`,reason:e instanceof Error?e.message:String(e)}}}async function yve(e){let t=e.now(),n=t+e.timeoutMs;for(;;){let r=await vve(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 bve(e,t){return`timed out after ${e} s: ${t}`}function ix(e){return fa(e)}function ax(e){let t=ix(e);if(t===void 0)return[];let n=Hl(t);return n===void 0?[t]:[t,...ql(n).filter(e=>e!==t)]}var ox=x({path:l(),deviceId:n().int().optional(),field:l(),value:n(),assumedUnit:l(),message:l()});function xve(e){let t=Jg(e);return t instanceof ce?t:void 0}function sx(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[...Yg(r.schema),...r.itemArray===void 0?[]:mhe(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=xve(i)?.shape[r];return a===void 0?void 0:xhe(a)}}}function cx(e){return Zg(e)??e}function lx(e){return ax(e).length>1}function ux(e){return{...e,message:`${e.field}: the bare number ${e.value} was taken as ${e.assumedUnit} — send { value, unit } to state the unit`}}function dx(e,t){n_({value:1,unit:e,target:t})}function Sve(e,t,n){let r=t.fieldQuantity(e.cap,e.fieldPath),i=r===void 0?void 0:ix(r),a=t_(e.value)||e.unit!==void 0;if(i===void 0||r===void 0){if(a)throw new $g(`no-quantity`,`${e.cap}.${e.fieldPath} is not a quantity — it takes no unit`);return{leaf:e,warnings:[]}}if(t_(e.value)){let t=n_({value:e.value.value,unit:e.value.unit,target:i});return{leaf:{...e,value:t,unit:cx(e.value.unit)},warnings:[]}}return typeof e.value==`number`?e.unit===void 0?lx(r)?{leaf:e,warnings:[ux({path:n,deviceId:e.deviceId,field:e.fieldPath,value:e.value,assumedUnit:i})]}:{leaf:e,warnings:[]}:(dx(e.unit,i),{leaf:e,warnings:[]}):{leaf:e,warnings:[]}}function fx(e,t,n=`when`){switch(e.kind){case`device-is`:{let{leaf:r,warnings:i}=Sve(e,t,n);return{value:r,warnings:i}}case`not`:{let r=fx(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)=>fx(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 Cve(e,t,n){if(Ia(e.actionId)===void 0)return{value:e,warnings:[]};let r=e.target.kind===`devices`&&e.target.ids.length===1?e.target.ids[0]:void 0,{cap:i,method:a}=Ba(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 $g(`no-quantity`,`${i}.${a}(${n}) is not a quantity — it takes no unit`);dx(r,e.unit)}for(let[l,u]of Object.entries(e.args??{})){let e=t.paramMeta(i,a,l);e!==void 0&&(t_(u)?(o[l]=n_({value:u.value,unit:u.unit,target:e.unit}),s[l]=cx(u.unit)):typeof u==`number`&&s[l]===void 0&&lx(e.quantity)&&c.push(ux({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 px(e,t,n=`steps`){let r=[],i=[];return e.forEach((e,a)=>{if(e.kind!==`command`){r.push(e);return}let o=Cve(e,t,`${n}.${a}`);r.push(o.value),i.push(...o.warnings)}),{value:r,warnings:i}}function mx(e,t){let n=fx(e.when,t,`when`),r=px(e.actions,t,`actions`);return{value:{...e,when:n.value,actions:r.value},warnings:[...n.warnings,...r.warnings]}}function hx(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||ax(n).length<2)return e;let r=ix(n);return r===void 0?e:{...e,unit:r}}case`not`:return{...e,child:hx(e.child,t)};case`all`:case`any`:return{...e,children:e.children.map(e=>hx(e,t))};default:return e}}function wve(e,t){if(e.kind!==`command`||e.args===void 0||Ia(e.actionId)===void 0)return e;let{cap:n,method:r}=Ba(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&&ax(e.quantity).length>1&&(i[a]=e.unit)}return Object.keys(i).length===0?e:{...e,argUnits:i}}function gx(e,t){let n={...e,when:hx(e.when,t),actions:e.actions.map(e=>wve(e,t))};try{return{ok:!0,recipe:mx(n,t).value}}catch(e){if(e instanceof $g)return{ok:!1,error:e.message};throw e}}var Tve=[`devices`,`time`,`cameras`,`events`,`logic`,`system`],_x=[`trigger`,`any`],vx=[`trigger`,`guard`,`any`],yx={detection:{kind:`detection`,category:`cameras`,role:`event`,allowedIn:_x,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:_x,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:_x,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:_x,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:_x,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:_x,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:_x,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:_x,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:vx,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:vx,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:vx,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:vx,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:vx,i18nKey:`automation.leafCatalog.expression`,keywords:[`formula`,`math`,`arithmetic`,`sum`,`compare`,`calculate`,`held`],needsDeviceValue:!1,seed:()=>({kind:`expression`,expr:``,bindings:{}})}},bx=[`detection`,`stationary`,`device-becomes`,`device-fired`,`device-event`,`schedule`,`interval`,`manual`,`device-is`,`stationary-present`,`time-is`,`triggered-by`,`expression`];function Eve(e){return yx[e]}function Dve(e){return yx[e].seed()}function Ove(e){return bx.filter(t=>yx[t].allowedIn.includes(e))}function xx(e){return e instanceof Error?e.message:String(e)}function kve(e){return e.startsWith(`[busy]`)?`already-running`:e.startsWith(`[not-found]`)?`not-found`:null}async function Ave(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=xx(e),i=kve(n);return i===null?(t.warn(`${r}: exported action failed`,{tags:a,meta:{message:n}}),{status:`failed`,message:n}):o(i,n)}}async function jve(e,t,n){let{exporter:r,targetId:i}=n,a={targetId:i};try{let{targets:o,unreadable:s}=await Ad(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:ed.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=xx(e);return t.warn(`${r}: exported notifier send failed`,{tags:a,meta:{message:n}}),{status:`failed`,message:n}}}function Mve(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 Sx=l().min(1),Cx=x({instanceId:Sx.optional()}),wx=x({instanceId:Sx,name:l(),enabled:y(),kind:l().optional(),nameRule:l().optional()}),Tx=`export-instance-unknown`,Ex=class extends Error{code=Tx;instanceId;constructor(e,t){super(`${Tx}: ${e} serves no instance "${t}"`),this.name=`ExportInstanceUnknownError`,this.instanceId=t}};function Dx(e){return`instanceId`in e?e.instanceId:void 0}function Nve(e,t,n){if(n!==void 0&&n!==t)throw new Ex(e,n)}var Pve=S([`unlinked`,`linked`,`error`]),Ox=x({label:l(),value:l(),secret:y().optional()}),kx=x({qr:l().optional(),fields:C(Ox).readonly().optional(),note:l().optional()}),Ax=x({linkState:Pve,exposedDeviceCount:n(),error:l().optional(),setup:kx.optional()}),Fve=l(),jx=x({deviceId:l(),exposedAs:l().optional(),exposedName:l().optional(),capabilities:C(l()).optional()}),Mx=x({instanceId:Sx,deviceId:l(),capabilities:C(l()).optional(),exposedName:l().nullable().optional()}),Nx=x({instanceId:Sx,deviceId:l(),name:l().nullable(),dryRun:y().optional()}),Px=`export-name-refused`,Fx=class extends Error{code=Px;instanceId;reason;constructor(e,t){super(`${Px}: ${t}`),this.name=`ExportNameRefusedError`,this.instanceId=e,this.reason=t}},Ix=x({instanceId:Sx,deviceId:l()}),Lx=S([`device`,`action`,`notifier`]),Rx=i(`kind`,[x({kind:p(`device`),deviceId:l()}),x({kind:p(`action`),actionId:l().min(1)}),x({kind:p(`notifier`),targetId:l().min(1)})]),zx=x({entity:Rx,exposedAs:l().optional()}),Bx=x({instanceId:Sx,entity:Rx}),Vx=x({instanceId:Sx,entity:Rx}),Hx={name:`device-export`,scope:`system`,mode:`collection`,providerKind:`device-export`,status:{schema:Ax,kind:`poll`},exposesDeviceSettings:!0,methods:{getStatus:A(Cx,Ax),listInstances:A(v(),C(wx)),listSupportedDeviceKinds:A(Cx,C(Fve)),listExposedDevices:A(Cx,C(jx)),exposeDevice:A(Mx,v(),{kind:`mutation`,auth:`admin`}),unexposeDevice:A(Ix,v(),{kind:`mutation`,auth:`admin`}),setExposedName:A(Nx,v(),{kind:`mutation`,auth:`admin`}),listSupportedEntityKinds:j(v(),C(Lx)),listExposedEntities:j(Cx,C(zx)),exposeEntity:j(Bx,v(),{kind:`mutation`,auth:`admin`}),unexposeEntity:j(Vx,v(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`exports to other ecosystems — configured on the export pages`}},Ux=`exposedNames`,Ive=m(l(),l());function Wx(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 Gx(e){let t=Ive.safeParse(e[Ux]);return t.success?t.data:{}}function Lve(e,t,n){let r=Gx(e)[t];if(r===void 0)return null;let i=Wx(r,n);return i.ok?i.name:null}function Kx(e,t,n){let r=Object.fromEntries(Object.entries(Gx(e)).filter(([e])=>e!==t));return{[Ux]:n===null?r:{...r,[t]:n}}}async function Rve(e){let t=Wx(e.raw,e.validate);if(!t.ok)throw new Fx(e.instanceId,t.reason);if(e.dryRun===!0)return{changed:!1,name:t.name};let n=await e.store.read(e.deviceId);return(Gx(n)[e.instanceId]??null)===t.name?{changed:!1,name:t.name}:(await e.store.write(e.deviceId,Kx(n,e.instanceId,t.name)),{changed:!0,name:t.name})}function zve(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 Bve(e,t){let n=await e.listDeviceStoreIds();if(n.length===0)return[];let r=[];for(let[i,a]of await e.readDeviceStoreBatch(n))Gx(a)[t]!==void 0&&(await e.writeDeviceStore(i,Kx(a,t,null)),r.push(i));return r}function Vve(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 qx=[`automation`,`action`,`scheduler`,`composition`],Hve=S(qx),Jx=x({id:n().int().nonnegative(),name:l().min(1),type:l().min(1),room:l().min(1).nullable(),addonId:l().min(1),stableId:l().min(1),caps:C(l().min(1)),zones:C(l().min(1)).optional()}),Uve=x({timeZone:l().min(1),location:x({latitude:n(),longitude:n()}).nullable(),rooms:C(l().min(1)),devices:C(Jx).min(1),actions:C(x({id:l().min(1),name:l().min(1)})).default([])}),Wve=60,Yx=x({childDeviceIds:C(n()).readonly(),hiddenChildIds:C(n()).readonly()}),Xx={name:`accessories`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera,E.Switch,E.Light,E.Sensor,E.Climate,E.Cover,E.Lock,E.Fan,E.MediaPlayer,E.AlarmPanel,E.Generic],methods:{setChildHidden:A(x({deviceId:n().int().nonnegative(),childDeviceId:n().int().nonnegative(),hidden:y()}),v(),{kind:`mutation`,auth:`admin`})},events:{onAccessoriesChanged:{data:x({deviceId:n(),childDeviceIds:C(n()).readonly(),hiddenChildIds:C(n()).readonly()}),notOperatorFacing:`the device’s child list changed — administration, not a happening`},onChildVisibilityChanged:{data:x({deviceId:n(),childDeviceId:n(),hidden:y()}),notOperatorFacing:`an operator hid or showed a child — administration, not a happening`}},status:{schema:Yx,kind:`command-driven`},vocabulary:{noun:F(`Accessories`,`Accessori`),order:3e3}},Zx={name:`action-source`,scope:`system`,mode:`collection`,methods:{listActions:A(x({}),C(Zb),{auth:`admin`}),runAction:A(x({actionId:l().min(1),variables:m(l(),Hb).optional()}),v(),{kind:`mutation`,auth:`admin`}),stopAction:A(x({actionId:l().min(1)}),v(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.INTERNAL}},Gve=60*6e4,Kve=3e4,Qx=363e4;function qve(e){let t=0;for(let n of e)n.kind===`wait`&&(t+=n.seconds*1e3);return t}var $x=x({actionId:l().min(1)}),eS=x({deviceId:n().int().nonnegative(),actionIds:C(l().min(1)).max(100)}),tS={name:`actions`,scope:`system`,mode:`singleton`,methods:{list:A(x({}),C(Zb),{auth:`admin`}),get:A(x({actionId:l().min(1),deviceId:n().int().nonnegative().optional()}),x({action:Zb.nullable()}),{role:`viewer`,auth:`protected`,kind:`query`,caller:`required`}),run:A(x({actionId:l().min(1),variables:m(l(),Hb).optional(),wait:y().optional(),origin:$b.optional(),deviceId:n().int().nonnegative().optional()}),tx,{role:`viewer`,auth:`protected`,kind:`mutation`,caller:`required`,timeoutMs:Qx}),stop:A($x,v(),{kind:`mutation`,auth:`admin`}),getTraces:A($x,x({traces:C(Ay)}),{auth:`admin`}),create:A(x({action:Qb}),x({action:Zb,warnings:C(ox).optional()}),{kind:`mutation`,auth:`admin`}),update:A(x({actionId:l().min(1),action:Qb.partial()}),x({action:Zb,warnings:C(ox).optional()}),{kind:`mutation`,auth:`admin`}),delete:A($x,v(),{kind:`mutation`,auth:`admin`}),listForCamera:A(x({deviceId:n().int().nonnegative()}),C(Zb),{role:`viewer`,auth:`protected`,kind:`query`}),getLinks:A(x({deviceId:n().int().nonnegative()}),eS,{auth:`admin`}),setLinks:A(eS,eS,{kind:`mutation`,auth:`admin`})},events:{onRunChanged:{data:nx}},vocabulary:{notOperatorFacing:`declared actions — run from the Actions page and from the cameras that link them`}},Jve=x({id:l(),label:l(),icon:l(),path:l(),remoteName:l(),bundle:l(),section:l().optional(),sectionLabel:l().optional()}),nS=x({addonId:l(),page:Jve,bundleUrl:l()}),rS={name:`addon-pages`,scope:`system`,mode:`singleton`,methods:{listPages:A(v(),C(nS).readonly())},vocabulary:{notOperatorFacing:M.UI_PLUMBING}},Yve=x({method:S([`GET`,`POST`,`PUT`,`DELETE`,`PATCH`]),path:l(),access:S([`public`,`authenticated`,`admin`]).optional(),description:l().optional(),rateLimit:S([`auth`]).optional(),perInstance:y().optional()}),Xve=x({method:l(),path:l(),params:m(l(),l()),query:m(l(),l()),body:w(),headers:m(l(),l()),instanceId:l().optional(),user:x({id:l(),username:l(),isAdmin:y()}).optional(),scopedToken:w().optional()}),Zve=x({status:n().int(),headers:m(l(),l()),redirectUrl:l().nullable(),body:w().optional(),contentType:l().optional()}),iS={name:`addon-routes`,scope:`system`,mode:`collection`,internal:!0,methods:{getRoutes:A(v(),C(Yve)),invoke:A(Xve,Zve,{kind:`mutation`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:M.UI_PLUMBING}},aS=x({id:l(),label:l(),icon:l(),order:n().optional()}),oS=x({id:l(),title:l(),titleKey:l().optional(),description:l().optional(),descriptionKey:l().optional(),style:S([`card`,`accordion`]).optional(),defaultCollapsed:y().optional(),columns:h([p(1),p(2),p(3),p(4)]).optional(),tab:l().optional(),location:S([`settings`,`top-tab`,`hero`]).optional(),order:n().optional(),fields:C(ge())}),sS=x({tabs:C(aS).optional(),sections:C(oS)}),cS=m(l(),w()),lS=S(cr),Qve=x({cap:l(),scope:lS,sectionIds:C(l())}),uS=x({success:p(!0)}),dS={name:`addon-settings`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,methods:{getScopedSettings:A(x({addonId:l(),cap:l(),scope:lS,nodeId:l().optional()}),sS.nullable()),listScopedSettings:A(x({addonId:l(),nodeId:l().optional()}),C(Qve).nullable()),updateScopedSettings:A(x({addonId:l(),cap:l(),scope:lS,nodeId:l().optional(),patch:cS}),uS,{kind:`mutation`,auth:`admin`}),readScopedValues:A(x({addonId:l(),cap:l(),scope:lS,nodeId:l().optional()}),m(l(),w()).nullable()),getDeclaredSettingsKeys:A(x({addonId:l(),nodeId:l().optional()}),x({keys:C(l())}).nullable(),{auth:`admin`}),unsetStoredSettingsKeys:A(x({addonId:l(),nodeId:l().optional(),keys:C(l())}),x({removed:C(l()),refused:C(x({key:l(),reason:l()})),secretsCleared:n()}),{kind:`mutation`,auth:`admin`}),getDeviceSettings:A(x({addonId:l(),deviceId:n(),nodeId:l().optional()}),sS.nullable()),updateDeviceSettings:A(x({addonId:l(),deviceId:n(),nodeId:l().optional(),patch:cS}),uS,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.ADDON_ADMIN}},fS=S([`device-tab`,`dashboard`,`integration-detail`]),pS=S([`xs`,`sm`,`md`,`lg`,`xl`]),mS=x({remoteName:l(),exposedModule:l(),componentKey:l().optional()}),hS=x({tab:l(),subTab:l().optional(),label:l(),order:n().optional(),kind:p(`remote`),remote:mS,stableId:l(),description:l().optional(),icon:l().optional(),bundle:l(),hosts:C(fS).readonly(),requires:x({deviceContext:y().default(!1),integrationContext:y().default(!1)}),preAuth:y().optional().default(!1),defaultSize:pS.default(`md`),allowedSizes:C(pS).readonly().default([`sm`,`md`,`lg`]),defaultColumns:n().int().min(1).max(12).default(6),defaultRows:n().int().min(1).max(12).default(1)}),gS={name:`addon-widgets-source`,scope:`system`,mode:`collection`,internal:!0,methods:{listWidgets:A(v(),C(hS).readonly(),{auth:`admin`})},vocabulary:{notOperatorFacing:M.UI_PLUMBING}},_S=hS.extend({addonId:l(),bundleUrl:l()}),vS={name:`addon-widgets`,scope:`system`,mode:`singleton`,methods:{listWidgets:A(v(),C(_S).readonly())},vocabulary:{notOperatorFacing:M.UI_PLUMBING}},yS=S([`install`,`update`,`uninstall`,`restart`]),bS=S([`queued`,`fetching`,`staged`,`validating`,`applying`,`restarting`,`applied`,`done`,`failed`,`skipped`]),xS=S([`framework`,`addon`]),SS=x({tsMs:n(),nodeId:l(),packageName:l(),phase:bS,message:l()}),CS=x({taskId:l(),nodeId:l(),packageName:l(),fromVersion:l().nullable(),toVersion:l(),target:xS,phase:bS,stagedPath:l().nullable(),attempts:n(),steps:C(SS),error:l().nullable(),startedAtMs:n().nullable(),finishedAtMs:n().nullable()}),wS=S([`running`,`completed`,`failed`,`partially-failed`,`cancelled`]),TS=S([`single`,`bulk`,`cluster`]),ES=x({jobId:l(),kind:yS,createdAtMs:n(),createdBy:l(),scope:TS,tasks:C(CS),state:wS,schemaVersion:p(1)}),DS=S([`debug`,`info`,`warn`,`error`]),OS=S([`off`,`latest`,`beta`]),kS=S([`off`,`latest`,`beta`,`inherit`]),$ve=x({id:l(),name:l().optional(),version:l().optional(),description:l().optional(),icon:l().optional(),color:l().optional(),capabilities:C(w()).readonly().optional(),packageName:l(),packageVersion:l(),packageDisplayName:l().optional(),bundle:x({displayName:l(),description:l().optional(),icon:l().optional()}).optional(),protected:y().optional(),removable:y().optional(),integrationSection:S([`system`,`providers`]).optional()}),eye=x({pid:n().optional(),mode:l(),state:l(),reason:l().optional()}),tye=x({phase:S([`pending`,`healthy`,`failed`]),retryCount:n(),firstFailureAt:n().nullable(),lastAttemptAt:n().nullable(),lastError:x({message:l(),stack:l().optional()}).nullable(),nextRetryAt:n().nullable(),alertEmitted:y(),retrying:y(),inGracePeriod:y()}),AS=x({manifest:$ve,declaration:w().optional(),source:l(),installSource:l().optional(),process:eye.optional(),hasBackup:y().optional(),health:tye.nullable().optional()}),jS=x({name:l(),version:l(),dir:l(),installSource:l().optional()}),MS=x({name:l(),currentVersion:l(),latestVersion:l(),category:S([`addon`,`core`]),requiresRestart:y(),isSystem:y(),blockedBy:C(Pu).readonly().optional()}),NS=x({version:l(),publishedAt:l(),deprecated:l().optional(),distTags:C(l()).readonly()}),PS=i(`status`,[x({status:p(`ok`),markdown:l()}),x({status:p(`missing`)}),x({status:p(`error`),message:l()})]),nye=x({name:l(),version:l(),readme:PS,changelog:PS}),FS=x({name:l(),version:l(),description:l(),keywords:C(l()).readonly(),publishedAt:l(),author:l(),installed:y(),installedVersion:l().optional(),capabilities:C(l()).readonly().nullable()}),IS=x({channel:OS,intervalSeconds:n(),updateCheckIntervalSeconds:n()}),LS=kS,rye=w(),iye=w(),aye=w(),RS=S([`uninstalled`,`not-installed`,`refused`,`failed`,`pending-reconnect`]),zS=x({nodeId:l(),outcome:RS,error:l().optional(),addonIds:C(l()).readonly(),runnersStopped:C(l()).readonly(),warnings:C(l()).readonly()}),BS=x({success:y(),packageName:l(),results:C(zS).readonly()}),VS=x({packageName:l(),nodeId:l(),nodeName:l(),isHub:y(),isOnline:y(),version:l().nullable(),addonIds:C(l()).readonly(),source:S([`live`,`recorded`]),onHub:y()}),HS=x({installations:C(VS).readonly(),unreachable:C(x({nodeId:l(),error:l()})).readonly()}),oye=S([`queued`,`updating`,`done`,`done-pending-restart`,`failed`]),sye=x({name:l(),isSystem:y(),fromVersion:l(),toVersion:l(),status:oye,error:l().optional(),startedAtMs:n().optional(),completedAtMs:n().optional()}),cye=S([`regular`,`system`,`restarting`,`finalizing`]);x({id:l(),nodeId:l(),startedAtMs:n(),completedAtMs:n().optional(),total:n(),completed:n(),failed:n(),current:l().nullable(),phase:cye,cancelled:y(),items:C(sye).readonly()});var lye=x({packageName:l(),currentVersion:l(),latestVersion:l().nullable(),hasUpdate:y(),description:l().optional(),buildId:l().nullable()}),US=x({timestamp:l(),level:l(),message:l(),scope:l().optional()}),uye=w(),WS=x({addonId:l().min(1),action:l().min(1),input:w()}),GS={name:`addons`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,methods:{list:A(x({nodeId:l().optional()}).optional(),C(AS).readonly()),getLogs:A(x({addonId:l(),limit:n().min(1).max(500).default(100),level:DS.optional()}),C(uye)),listPackages:A(v(),C(jS).readonly()),installPackage:A(x({packageName:l(),version:l().optional()}),iye,{kind:`mutation`,auth:`admin`}),uninstallPackage:A(x({packageName:l().min(1),nodeId:l().optional(),everywhere:y().optional()}),BS,{kind:`mutation`,auth:`admin`}),listInstallations:A(x({packageName:l().optional()}),HS,{auth:`admin`}),reloadPackages:A(v(),aye,{kind:`mutation`,auth:`admin`}),searchAvailable:A(x({query:l().optional(),capability:l().optional()}),C(FS)),listUpdates:A(x({nodeId:l().optional()}),C(MS).readonly(),{auth:`admin`}),updatePackage:A(x({name:l().min(1),version:l().optional(),nodeId:l().optional()}),w(),{kind:`mutation`,auth:`admin`}),rollbackPackage:A(x({name:l().min(1)}),x({rolledBackTo:l().nullable()}),{kind:`mutation`,auth:`admin`}),forceRefresh:A(x({nodeId:l().optional()}),w(),{kind:`mutation`,auth:`admin`}),restartServer:A(x({confirm:p(!0)}),w(),{kind:`mutation`,auth:`admin`}),getLastRestart:A(v(),x({kind:S([`framework-update`,`manual`,`system`,`framework-bulk-update`]),packageName:l().optional(),fromVersion:l().optional(),toVersion:l().optional(),requestedBy:l().optional(),requestedAt:n()}).nullable(),{auth:`admin`}),listFrameworkPackages:A(v(),C(lye).readonly(),{auth:`admin`}),listCapabilityProviders:A(x({capName:l().min(1)}),C(x({addonId:l(),mode:S([`singleton`,`collection`]),isActive:y()})).readonly()),setCapabilityProviderEnabled:A(x({capName:l().min(1),addonId:l().min(1),enabled:y()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getVersions:A(x({name:l()}),C(NS).readonly()),getPackageDocs:A(x({name:l().min(1),version:l().min(1).optional()}),nye,{auth:`admin`}),restartAddon:A(x({addonId:l()}),rye,{kind:`mutation`,auth:`admin`}),retryLoad:A(x({packageName:l()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getAutoUpdateSettings:A(v(),IS,{auth:`admin`}),setAutoUpdateSettings:A(x({channel:OS,intervalSeconds:n().min(300).max(86400).optional(),updateCheckIntervalSeconds:n().min(900).max(604800).optional()}),w(),{kind:`mutation`,auth:`admin`}),getAddonAutoUpdate:A(x({addonId:l()}),LS,{auth:`admin`}),setAddonAutoUpdate:A(x({addonId:l(),channel:kS}),w(),{kind:`mutation`,auth:`admin`}),applyAutoUpdateToAll:A(x({channel:OS}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),custom:A(WS,w(),{role:`viewer`,kind:`mutation`}),startJob:A(x({kind:S([`install`,`update`,`uninstall`,`restart`]),targets:C(x({name:l().min(1),version:l().min(1)})).min(1),nodeIds:C(l()).optional()}),x({jobId:l()}),{kind:`mutation`,auth:`admin`}),getJob:A(x({jobId:l()}),ES.nullable(),{auth:`admin`}),listJobs:A(x({activeOnly:y().optional()}),C(ES),{auth:`admin`}),cancelJob:A(x({jobId:l()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),onAddonLogs:A(x({addonId:l(),level:DS.optional()}),US,{kind:`subscription`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:M.ADDON_ADMIN}},KS=x({co2:n().min(0).optional().meta(N(`concentration-volume`)),voc:n().min(0).optional().meta(N(`concentration-ppb`)),pm25:n().min(0).optional().meta(N(`concentration-mass`)),pm10:n().min(0).optional().meta(N(`concentration-mass`)),aqi:n().optional().meta(N(`index`)),lastFetchedAt:n()}),qS={name:`air-quality-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:KS,kind:`push`},runtimeState:KS,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:F(`Air quality`,`Qualità dell’aria`),order:5e3,state:[{kind:`numeric`,field:`co2`,quantity:F(`the CO₂`,`la CO₂`),label:F(`CO₂`,`CO₂`),unit:`ppm`,icon:`wind`},{kind:`numeric`,field:`voc`,quantity:F(`the VOC level`,`il livello di COV`),label:F(`VOC`,`COV`),unit:`ppb`,icon:`wind`},{kind:`numeric`,field:`pm25`,quantity:F(`the PM2.5`,`il PM2,5`),label:F(`PM2.5`,`PM2,5`),unit:`µg/m³`,icon:`cloud-fog`},{kind:`numeric`,field:`pm10`,quantity:F(`the PM10`,`il PM10`),label:F(`PM10`,`PM10`),unit:`µg/m³`,icon:`cloud-fog`},{kind:`numeric`,field:`aqi`,quantity:F(`the air quality index`,`l’indice di qualità dell’aria`),label:F(`AQI`,`IQA`),icon:`wind`}]}},JS=S([`disarmed`,`armed_home`,`armed_away`,`armed_night`,`armed_vacation`,`armed_custom_bypass`,`arming`,`disarming`,`pending`,`triggered`]),YS=S([`home`,`away`,`night`,`vacation`,`custom_bypass`]),XS=x({state:JS,targetMode:YS.nullable().optional(),availableModes:C(YS),codeRequired:y().nullable(),lastChangedAt:n()}),ZS={name:`alarm-panel`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.AlarmPanel],methods:{trigger:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`alarm.trigger`,label:F(`Trigger alarm`,`Fai scattare l’allarme`),phrase:F(`Trigger the alarm on {device}`,`Fai scattare l’allarme su {device}`),icon:`siren`}]}),disarm:A(x({deviceId:n().int().nonnegative(),code:l().min(1).optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`alarm.disarm`,label:F(`Disarm`,`Disinserisci`),phrase:F(`Disarm {device}`,`Disinserisci {device}`),icon:`shield-off`,effect:{field:`state`,value:`disarmed`},hold:{effects:[{field:`state`,value:`disarming`,when:{field:`state`,notIn:[`disarmed`]}}]},openArgs:[{key:`code`,label:F(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]}),arm:A(x({deviceId:n().int().nonnegative(),mode:YS,code:l().min(1).optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`alarm.arm.home`,label:F(`Arm home`,`Inserisci in casa`),phrase:F(`Arm {device} for home`,`Inserisci {device} in modalità casa`),icon:`house`,effect:{field:`state`,value:`armed_home`},hold:{effects:[{field:`state`,value:`arming`,when:{field:`state`,notIn:[`armed_home`]}}]},args:{mode:`home`},openArgs:[{key:`code`,label:F(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.away`,label:F(`Arm away`,`Inserisci fuori casa`),phrase:F(`Arm {device} for away`,`Inserisci {device} in modalità fuori casa`),icon:`shield-check`,effect:{field:`state`,value:`armed_away`},hold:{effects:[{field:`state`,value:`arming`,when:{field:`state`,notIn:[`armed_away`]}}]},args:{mode:`away`},openArgs:[{key:`code`,label:F(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.night`,label:F(`Arm night`,`Inserisci notte`),phrase:F(`Arm {device} for the night`,`Inserisci {device} in modalità notte`),icon:`moon`,effect:{field:`state`,value:`armed_night`},hold:{effects:[{field:`state`,value:`arming`,when:{field:`state`,notIn:[`armed_night`]}}]},args:{mode:`night`},openArgs:[{key:`code`,label:F(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.vacation`,label:F(`Arm vacation`,`Inserisci vacanza`),phrase:F(`Arm {device} for vacation`,`Inserisci {device} in modalità vacanza`),icon:`plane`,effect:{field:`state`,value:`armed_vacation`},hold:{effects:[{field:`state`,value:`arming`,when:{field:`state`,notIn:[`armed_vacation`]}}]},args:{mode:`vacation`},openArgs:[{key:`code`,label:F(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.custom_bypass`,label:F(`Arm custom bypass`,`Inserisci con esclusioni`),phrase:F(`Arm {device} with its custom bypass`,`Inserisci {device} con le zone escluse`),icon:`shield-half`,effect:{field:`state`,value:`armed_custom_bypass`},hold:{effects:[{field:`state`,value:`arming`,when:{field:`state`,notIn:[`armed_custom_bypass`]}}]},args:{mode:`custom_bypass`},openArgs:[{key:`code`,label:F(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]})},status:{schema:XS,kind:`push`},runtimeState:XS,durability:`restored`,restoredFieldRenames:{requiresCode:`codeRequired`},history:{fields:{state:{kind:`enum`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Alarm panel`,`Centrale d’allarme`),order:1120,state:[{kind:`enum`,field:`state`,label:F(`Alarm state`,`Stato dell’allarme`),values:[{value:`disarmed`,label:F(`Disarmed`,`Disinserito`),phrase:F(`When {device} is disarmed`,`Quando {device} viene disinserito`)},{value:`armed_home`,label:F(`Armed home`,`Inserito in casa`),phrase:F(`When {device} is armed for home`,`Quando {device} viene inserito in modalità casa`)},{value:`armed_away`,label:F(`Armed away`,`Inserito fuori casa`),phrase:F(`When {device} is armed for away`,`Quando {device} viene inserito in modalità fuori casa`)},{value:`armed_night`,label:F(`Armed night`,`Inserito notte`),phrase:F(`When {device} is armed for the night`,`Quando {device} viene inserito in modalità notte`)},{value:`armed_vacation`,label:F(`Armed vacation`,`Inserito vacanza`)},{value:`armed_custom_bypass`,label:F(`Armed with bypass`,`Inserito con esclusioni`)},{value:`arming`,label:F(`Arming`,`In inserimento`)},{value:`disarming`,label:F(`Disarming`,`In disinserimento`)},{value:`pending`,label:F(`Entry delay`,`Ritardo d’ingresso`)},{value:`triggered`,label:F(`Triggered`,`In allarme`),phrase:F(`When {device} goes off`,`Quando {device} scatta`)}],icon:`shield`}]}},QS=S([`info`,`success`,`warning`,`error`,`critical`]),dye=x({addonId:l().min(1),action:l().min(1),input:m(l(),w()).optional()}),fye=x({label:l(),href:l().optional(),invoke:dye.optional(),navigation:S([`app`,`server`]).optional()}),$S=S([`active`,`in-progress`,`completed`,`failed`,`dismissed`]),eC=x({type:l(),id:l()}),tC=x({id:l(),category:l(),severity:QS,title:l(),message:l(),action:fye.optional(),status:$S,progress:n().optional(),read:y(),createdAt:n(),updatedAt:n(),source:eC.optional(),metadata:m(l(),w()).optional()}),nC={name:`alerts`,scope:`system`,mode:`singleton`,methods:{emit:A(tC,v(),{kind:`mutation`}),update:A(x({alertId:l(),patch:tC.partial()}),v(),{kind:`mutation`}),list:A(x({unreadOnly:y().optional(),limit:n().optional()}).optional(),C(tC).readonly()),getUnreadCount:A(v(),n()),markRead:A(x({alertId:l()}),v(),{kind:`mutation`}),markAllRead:A(v(),v(),{kind:`mutation`}),dismiss:A(x({alertId:l()}),v(),{kind:`mutation`})},vocabulary:{notOperatorFacing:`the alert centre — read and acknowledged on its own page`}},rC=x({illuminance:n().min(0).nullable().meta(N(`illuminance`,{precision:0,label:`Illuminance`})),lastFetchedAt:n()}),iC={name:`ambient-light-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:rC,kind:`push`},runtimeState:rC,durability:`restored`,history:{fields:{illuminance:{kind:`gauge`,unit:`lx`,deadbandPct:10,minIntervalMs:6e4}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Light level`,`Luminosità ambiente`),order:5010,state:[{kind:`numeric`,field:`illuminance`,quantity:F(`the light level`,`la luminosità`),label:F(`Illuminance`,`Illuminamento`),unit:`lx`,icon:`sun`}]}},aC={name:`audio-analysis`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[E.Camera],exposesDeviceSettings:!0,methods:{resolveDeviceSettings:A(x({deviceId:n()}),ve())},events:{onAudioLevel:ni(x({deviceId:n(),rms:n(),dbfs:n()}),{notOperatorFacing:`a sound-level sample at stream rate; loud-noise rules belong to the detection pipeline`})},vocabulary:{noun:F(`Audio analysis`,`Analisi audio`),order:3010}},pye=S([`jpeg`,`rgb`,`bgr`,`yuv420`,`gray`]),oC=x({data:ve(),format:pye,width:n(),height:n(),timestamp:n()}),sC=x({x:n(),y:n(),w:n(),h:n()}),mye=x({class:l(),originalClass:l(),score:n(),bbox:sC}),cC=x({data:b(Uint8Array),sampleRate:n(),channels:n(),timestamp:n(),deviceId:n().optional()}),lC=x({rms:n(),dbfs:n()}),uC=x({className:l(),originalClass:l().optional(),score:n()}),dC=[`superseded`,`error`,`timeout`,`disposed`],fC=i(`state`,[x({state:p(`classified`)}),x({state:p(`not-classified`),reason:S(dC)})]),pC=x({level:lC,classification:x({labels:C(uC).readonly(),inferenceMs:n()}).optional(),classifyOutcome:fC,timestamp:n()}),mC=x({minConfidence:n().min(0).max(1).default(.3),allowedClasses:C(l()).default([])}),hC=x({deviceId:n(),brokerId:l(),ingestNodeId:l(),settings:mC}),gC=x({attached:y(),replaced:y()}),_C=x({detached:y()}),vC=x({labels:C(uC).readonly(),rawLabels:C(uC).readonly().optional(),inferenceMs:n()}),hye=[{value:`auto`,label:`Auto (platform default)`},{value:`apple-soundanalysis`,label:`Apple SoundAnalysis (macOS 12+)`},{value:`yamnet-onnx`,label:`YAMNet ONNX (cross-platform)`}],gye={audioBackend:`auto`,probedBestAudioBackend:``},yC={name:`audio-analyzer`,scope:`system`,mode:`singleton`,methods:{analyseChunk:A(x({chunk:cC,settings:mC}),pC.nullable(),{kind:`mutation`}),classify:A(cC,vC,{timeoutMs:3e4}),attachDevice:A(hC,gC,{kind:`mutation`}),detachDevice:A(x({deviceId:n()}),_C,{kind:`mutation`}),isReady:A(v(),y()),dispose:A(v(),v(),{kind:`mutation`}),reprobeAudioEngine:A(v(),x({backend:l()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.PIPELINE}},bC=S([`f32le`,`s16le`]),xC=x({codec:l(),canDecode:y(),canEncode:y(),label:l().optional()}),SC=x({codec:l(),sourceSampleRate:n().int().positive(),sourceChannels:n().int().positive(),extraData:b(Uint8Array).optional(),targetSampleRate:n().int().positive(),targetChannels:n().int().positive(),targetFormat:bC.optional(),idleMs:n().int().positive().optional(),tag:l().optional()}),CC=x({codec:l(),sourceSampleRate:n().int().positive(),sourceChannels:n().int().positive(),sourceFormat:bC.optional(),targetSampleRate:n().int().positive(),targetChannels:n().int().positive(),bitrateKbps:n().int().positive().optional(),idleMs:n().int().positive().optional(),tag:l().optional()}),wC=x({data:b(Uint8Array),sampleRate:n().int().positive(),channels:n().int().positive(),format:bC,pts:n()}),TC=x({data:b(Uint8Array),codec:l(),pts:n(),frameComplete:y()}),_ye=x({sessionId:l(),kind:S([`decode`,`encode`]),codec:l(),sourceSampleRate:n(),sourceChannels:n(),targetSampleRate:n(),targetChannels:n(),format:bC,tag:l().optional(),createdAtMs:n(),lastActivityMs:n(),framesIn:n(),framesOut:n()}),EC={name:`audio-codec`,scope:`system`,mode:`singleton`,preferredProvider:`decoder-nodeav`,methods:{listSupportedCodecs:A(v(),C(xC).readonly()),canHandle:A(x({codec:l(),kind:S([`decode`,`encode`])}),y()),createDecodeSession:A(SC,x({sessionId:l(),nodeId:l()}),{kind:`mutation`}),createEncodeSession:A(CC,x({sessionId:l(),nodeId:l()}),{kind:`mutation`}),closeSession:A(x({sessionId:l(),nodeId:l().optional()}),v(),{kind:`mutation`}),pushEncodedFrame:A(x({sessionId:l(),nodeId:l().optional(),data:b(Uint8Array),pts:n().optional()}),v(),{kind:`mutation`}),pullPcm:A(x({sessionId:l(),nodeId:l().optional(),maxCount:n().int().positive().default(8)}),C(wC)),pushPcm:A(x({sessionId:l(),nodeId:l().optional(),data:b(Uint8Array),pts:n().optional()}),v(),{kind:`mutation`}),pullEncoded:A(x({sessionId:l(),nodeId:l().optional(),maxCount:n().int().positive().default(8)}),C(TC)),flushEncode:A(x({sessionId:l(),nodeId:l().optional()}),C(TC),{kind:`mutation`}),listActiveSessions:A(v(),C(_ye).readonly())},vocabulary:{notOperatorFacing:M.INTERNAL}},DC=x({className:l(),hits:n().int().nonnegative(),avgScore:n().min(0).max(1),peakScore:n().min(0).max(1)}),OC=x({ts:n().int(),windowSec:n().int().positive(),level:x({rms:n(),dbfs:n()}),peakDbfs:n(),avgDbfs:n(),current:x({className:l(),score:n().min(0).max(1),timestamp:n().int()}).nullable(),byClass:C(DC).readonly()}),kC=x({ts:n().int(),dbfs:n().nullable(),peakDbfs:n(),avgDbfs:n(),topClass:l().nullable(),topScore:n().min(0).max(1).nullable()}),AC=x({points:C(kC).readonly(),effectiveSampleEveryMs:n().int().positive(),windowMsActual:n().int().nonnegative()}),jC={name:`audio-metrics`,scope:`device`,mode:`singleton`,deviceTypes:[E.Camera],methods:{getCurrentSnapshot:A(x({deviceId:n()}),OC.nullable()),getHistory:A(x({deviceId:n(),windowSec:n().int().positive().optional(),sampleEveryMs:n().int().positive().optional()}),AC)},runtimeState:OC,durability:`session`,history:`none`,vocabulary:{noun:F(`Audio metrics`,`Metriche audio`),order:3020}},MC=x({userId:l(),username:l(),email:l().optional(),displayName:l().optional(),isAdmin:y().default(!1)}),NC={name:`auth-provider`,scope:`system`,mode:`collection`,internal:!0,methods:{validateCredentials:A(x({username:l(),password:l()}),MC.nullable(),{kind:`mutation`}),getLoginUrl:A(x({state:l()}),l()),handleCallback:A(m(l(),l()),MC,{kind:`mutation`}),validateToken:A(x({token:l()}),MC.nullable())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:M.IDENTITY}},PC=x({enabled:y(),isRunning:y(),lastTriggeredAt:n(),lastError:l().nullable(),lastChangedAt:n()}),FC={name:`automation-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Automation],methods:{enable:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`haAutomation.enable`,effect:{field:`enabled`,value:!0},label:F(`Enable automation`,`Abilita l’automazione`),phrase:F(`Enable {device}`,`Abilita {device}`),icon:`toggle-right`}]}),disable:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`haAutomation.disable`,effect:{field:`enabled`,value:!1},label:F(`Disable automation`,`Disabilita l’automazione`),phrase:F(`Disable {device}`,`Disabilita {device}`),icon:`toggle-left`}]}),trigger:A(x({deviceId:n().int().nonnegative(),skipCondition:y().optional()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`haAutomation.trigger`,label:F(`Trigger automation`,`Avvia l’automazione`),phrase:F(`Run {device} now`,`Esegui subito {device}`),icon:`workflow`}]})},status:{schema:PC,kind:`push`},runtimeState:PC,durability:`session`,history:`none`,vocabulary:{noun:F(`Automation`,`Automazione`),order:2100,state:[{kind:`boolean`,field:`enabled`,label:F(`Enabled`,`Abilitata`),whenTrue:F(`When {device} is enabled`,`Quando {device} viene abilitata`),whenFalse:F(`When {device} is disabled`,`Quando {device} viene disabilitata`),icon:`toggle-right`},{kind:`boolean`,field:`isRunning`,label:F(`Running`,`In esecuzione`),whenTrue:F(`When {device} starts running`,`Quando {device} parte`),whenFalse:F(`When {device} finishes`,`Quando {device} termina`),icon:`workflow`}]}},vye=`.backup-snapshot`,yye=`.backup-snapshot-partial`,IC=30*6e4,LC=x({databases:C(x({databaseId:yf,livePath:l()}))}),RC=x({name:l(),rows:n().int().nonnegative()}),zC=x({livePath:l(),snapshotPath:l(),sizeBytes:n().int().nonnegative(),pageCount:n().int().nonnegative(),pageSize:n().int().positive(),tables:C(RC),copyMs:n().nonnegative(),verifyMs:n().nonnegative(),takenAt:n()}),BC=zC.extend({databaseId:yf}),VC=x({databaseId:yf}),HC=zC.extend({livePath:l(),snapshotPath:l(),databaseId:yf.optional()}),UC={name:`database-snapshot`,scope:`system`,mode:`singleton`,internal:!0,methods:{listDatabases:A(x({}),LC,{auth:`admin`}),writeSnapshot:A(VC,BC,{kind:`mutation`,auth:`admin`,timeoutMs:IC})},vocabulary:{notOperatorFacing:M.INTERNAL}},WC=x({subId:l(),displayName:l(),description:l().optional(),kind:l(),triggerSupported:y(),restoreSupported:y()}).extend({id:l(),addonId:l(),enabled:y(),retentionCount:n(),label:l().optional(),lastSuccessAt:n().optional(),lastSuccessSizeBytes:n().optional(),cron:l().optional(),nextRunAt:n().optional(),lastAttemptAt:n().optional(),lastError:l().optional()}),GC=x({scheme:l(),keyId:l()}),KC=x({enabled:y(),active:x({keyId:l(),publicKey:l(),createdAt:n()}).nullable(),keys:C(x({keyId:l(),createdAt:n(),retiredAt:n().nullable()})).readonly()}),bye=x({id:l(),filename:l(),createdAt:n(),sizeBytes:n(),label:l().optional(),locations:C(l()).readonly(),encryption:GC.optional(),databases:C(yf).readonly().optional()}),qC=x({id:l(),destinationId:l().optional(),label:l().optional(),createdAt:n(),sizeBytes:n(),locations:C(l()).optional(),encryption:GC.optional()}),JC=x({path:l(),kind:S([`file`,`dir`,`symlink`]),sizeBytes:n(),mtime:n()}),YC=x({archiveVersion:p(1),createdAt:n(),dataDir:l(),locations:C(l()),entries:C(JC),totalBytes:n(),totalFiles:n(),sqliteSnapshots:C(HC).optional(),omittedDatabases:C(yf).optional()}),XC=x({name:l(),sizeBytes:n(),fileCount:n(),present:y()}),ZC=S([`queued`,`running`,`succeeded`,`failed`,`cancelled`]),QC=S([`queued`,`building`,`uploading`,`done`]),$C=x({id:l(),state:ZC,phase:QC,destinationIds:C(l()).readonly(),label:l().optional(),requestedAt:n(),startedAt:n().optional(),finishedAt:n().optional(),stagedBytes:n(),archiveSizeBytes:n().optional(),uploadedBytes:n(),completedDestinationIds:C(l()).readonly(),failedDestinationIds:C(l()).readonly(),error:l().optional(),queuePosition:n().int().min(1).optional()}),ew=x({runId:l(),queued:y(),joined:y(),cancelled:y(),entries:C(qC).readonly()}),tw=x({id:l(),label:l(),cron:l(),enabled:y(),locationIds:C(l()).readonly(),retentionCount:n().int().min(1).max(1e3),dataSources:C(l()).readonly().optional(),databases:C(yf).readonly().optional(),lastAttemptAt:n().optional(),lastSuccessAt:n().optional(),lastError:l().optional(),nextRunAt:n().optional()}),nw={name:`backup`,scope:`system`,mode:`singleton`,methods:{listDestinations:A(v(),C(WC).readonly(),{auth:`admin`}),trigger:A(x({destinations:C(l()).optional(),locations:C(l()).optional(),label:l().optional(),retentionCount:n().int().min(1).max(1e3).optional(),databases:C(yf).optional()}).optional(),ew,{kind:`mutation`,auth:`admin`}),listRuns:A(v(),C($C).readonly(),{auth:`admin`}),cancel:A(x({runId:l()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),list:A(v(),C(qC).readonly(),{auth:`admin`}),listLocations:A(v(),C(XC).readonly(),{auth:`admin`}),getEntries:A(x({destinationId:l(),backupId:l()}),YC.nullable(),{auth:`admin`}),restore:A(x({destinationId:l(),backupId:l(),locations:C(l()).optional(),backupSecretKey:l().optional()}),v(),{kind:`mutation`,auth:`admin`}),getEncryption:A(v(),KC,{auth:`admin`}),setupEncryption:A(x({}),x({keyId:l(),secretKey:l(),publicKey:l(),createdAt:n(),replacedKeyId:l().nullable()}),{kind:`mutation`,auth:`admin`}),disableEncryption:A(x({}),x({disabledKeyId:l().nullable()}),{kind:`mutation`,auth:`admin`}),checkBackupKey:A(x({backupSecretKey:l()}),x({valid:y(),keyId:l().nullable(),known:y(),active:y(),error:l().optional()}),{kind:`mutation`,auth:`admin`}),delete:A(x({destinationId:l(),backupId:l()}),v(),{kind:`mutation`,auth:`admin`}),listArchives:A(x({destinationId:l()}),C(bye).readonly(),{auth:`admin`}),upsertDestinationPolicy:A(x({locationId:l(),enabled:y(),retentionCount:n().int().min(1).max(1e3),label:l().optional()}),v(),{kind:`mutation`,auth:`admin`}),previewSchedule:A(x({cron:l(),count:n().int().min(1).max(20).optional()}),x({ok:y(),error:l().optional(),nextRuns:C(n()).readonly()})),listSchedules:A(v(),C(tw).readonly(),{auth:`admin`}),listAvailableDatabases:A(v(),x({answered:y(),databases:C(yf).readonly()}),{auth:`admin`}),upsertSchedule:A(x({id:l().optional(),label:l(),cron:l(),enabled:y(),locationIds:C(l()).readonly(),retentionCount:n().int().min(1).max(1e3),dataSources:C(l()).readonly().optional(),databases:C(yf).readonly().optional()}),tw,{kind:`mutation`,auth:`admin`}),deleteSchedule:A(x({id:l()}),v(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`system backups — run and restored from the Backups page`}},rw=x({level:n().min(0).max(100).nullable().meta(N(`percentage`,{label:`Charge`})),charging:S([`dc`,`solar`,`none`,`unknown`]).meta({label:`Charging source`}),sleeping:y().meta({label:`Sleeping`}),lastUpdated:n().meta(N(`none`)),voltage:n().nullable().optional().meta(N(`voltage`,{label:`Voltage`})),chargeState:S([`charging`,`full`,`idle`,`unknown`]).optional().meta({label:`Charge state`}),currentMa:n().nullable().optional().meta(N(`none`,{label:`Current (mA)`})),temperatureC:n().nullable().optional().meta(N(`temperature`,{label:`Temperature`})),lastContactAt:n().optional(),lastFullRefreshAt:n().optional(),binary:y().optional().meta({label:`Binary indicator`})}),iw=[E.Camera,E.Sensor,E.Button,E.Switch,E.PetFeeder,E.Container,E.Climate,E.EventEmitter],xye={version:1,targets:[{id:`level`,cardinality:`scalar`,vocabulary:{cap:`battery`,stateField:`level`},deviceTypes:iw,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}]},aw={name:`battery`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:iw,methods:{},events:{onStatusChanged:{data:x({deviceId:n(),status:rw}),notOperatorFacing:`the level / sleeping / charging state triggers each read one field of this change`}},status:{schema:rw,kind:`push`,empty:{level:null,charging:`unknown`,sleeping:!1,lastUpdated:0}},runtimeState:rw,durability:`restored`,history:{fields:{level:{kind:`gauge`,unit:`%`},voltage:{kind:`gauge`,unit:`V`},temperatureC:{kind:`gauge`,unit:`°C`}}},customize:xye,volatileStateFields:[`lastUpdated`],vocabulary:{noun:F(`Battery`,`Batteria`),order:5240,state:[{kind:`numeric`,field:`level`,quantity:F(`the battery level`,`il livello della batteria`),label:F(`Battery`,`Batteria`),unit:`%`,icon:`battery`},{kind:`boolean`,field:`sleeping`,label:F(`Asleep`,`In sospensione`),whenTrue:F(`When {device} goes to sleep`,`Quando {device} va in sospensione`),whenFalse:F(`When {device} wakes up`,`Quando {device} si risveglia`),icon:`moon`},{kind:`enum`,field:`charging`,label:F(`Charging`,`Ricarica`),values:[{value:`dc`,label:F(`Charging from mains`,`In carica da rete`),phrase:F(`When {device} starts charging`,`Quando {device} inizia a caricarsi`)},{value:`solar`,label:F(`Charging from solar`,`In carica dal pannello solare`),phrase:F(`When {device} charges from its solar panel`,`Quando {device} si carica dal pannello solare`)},{value:`none`,label:F(`Not charging`,`Non in carica`),phrase:F(`When {device} stops charging`,`Quando {device} smette di caricarsi`)},{value:`unknown`,label:F(`Unknown`,`Sconosciuto`)}],icon:`battery-charging`},{kind:`enum`,field:`chargeState`,label:F(`Charge state`,`Stato di carica`),values:[{value:`charging`,label:F(`Charging`,`In carica`)},{value:`full`,label:F(`Full`,`Carica completa`)},{value:`idle`,label:F(`Not charging`,`Non in carica`)},{value:`unknown`,label:F(`Unknown`,`Sconosciuto`)}],icon:`battery-charging`}],extraEvents:[{category:T.DeviceAwake,label:F(`Woke up`,`Risvegliato`),phrase:F(`When {device} wakes up`,`Quando {device} si risveglia`),icon:`sun`},{category:T.DeviceSleeping,label:F(`Went to sleep`,`In sospensione`),phrase:F(`When {device} goes to sleep`,`Quando {device} va in sospensione`),icon:`moon`}]}},ow=x({on:y().meta({label:`On`}),lastChangedAt:n()}),sw={name:`binary`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:ow,kind:`push`},runtimeState:ow,durability:`restored`,history:{fields:{on:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Binary sensor`,`Sensore binario`),order:5020,state:[{kind:`boolean`,field:`on`,label:F(`On`,`Acceso`),whenTrue:F(`When {device} turns active`,`Quando {device} si attiva`),whenFalse:F(`When {device} turns inactive`,`Quando {device} si disattiva`),icon:`toggle-right`}],overrides:{byRole:{[O.MotionSensor]:{state:{on:{label:F(`Motion`,`Movimento`),whenTrue:F(`When {device} detects motion`,`Quando {device} rileva movimento`),whenFalse:F(`When motion clears on {device}`,`Quando il movimento su {device} cessa`),icon:`activity`}}},[O.ContactSensor]:{state:{on:{label:F(`Open`,`Aperto`),whenTrue:F(`When {device} opens`,`Quando {device} si apre`),whenFalse:F(`When {device} closes`,`Quando {device} si chiude`),icon:`door-open`}}},[O.LeakSensor]:{state:{on:{label:F(`Leak`,`Perdita`),whenTrue:F(`When {device} detects a leak`,`Quando {device} rileva una perdita`),whenFalse:F(`When {device} is dry again`,`Quando {device} torna asciutto`),icon:`droplets`}}},[O.SmokeSensor]:{state:{on:{label:F(`Smoke`,`Fumo`),whenTrue:F(`When {device} detects smoke`,`Quando {device} rileva fumo`),whenFalse:F(`When smoke clears on {device}`,`Quando il fumo su {device} si dirada`),icon:`alarm-smoke`}}},[O.COSensor]:{state:{on:{label:F(`Carbon monoxide`,`Monossido di carbonio`),whenTrue:F(`When {device} detects carbon monoxide`,`Quando {device} rileva monossido di carbonio`),whenFalse:F(`When the carbon monoxide clears on {device}`,`Quando il monossido su {device} rientra`),icon:`cloud-alert`}}},[O.GasSensor]:{state:{on:{label:F(`Gas`,`Gas`),whenTrue:F(`When {device} detects gas`,`Quando {device} rileva gas`),whenFalse:F(`When the gas clears on {device}`,`Quando il gas su {device} rientra`),icon:`flame`}}},[O.TamperSensor]:{state:{on:{label:F(`Tampered`,`Manomesso`),whenTrue:F(`When {device} is tampered with`,`Quando {device} viene manomesso`),whenFalse:F(`When the tamper alert on {device} clears`,`Quando l’allarme di manomissione di {device} rientra`),icon:`shield-alert`}}},[O.VibrationSensor]:{state:{on:{label:F(`Vibration`,`Vibrazione`),whenTrue:F(`When {device} vibrates`,`Quando {device} vibra`),whenFalse:F(`When {device} is still again`,`Quando {device} torna fermo`),icon:`vibrate`}}},[O.ConnectivitySensor]:{state:{on:{label:F(`Connected`,`Connesso`),whenTrue:F(`When {device} connects`,`Quando {device} si connette`),whenFalse:F(`When {device} disconnects`,`Quando {device} si disconnette`),icon:`wifi`}}},[O.SoundSensor]:{state:{on:{label:F(`Sound`,`Suono`),whenTrue:F(`When {device} hears a sound`,`Quando {device} sente un suono`),whenFalse:F(`When {device} is quiet again`,`Quando {device} torna silenzioso`),icon:`ear`}}},[O.BatterySensor]:{state:{on:{label:F(`Battery low`,`Batteria scarica`),whenTrue:F(`When the battery of {device} runs low`,`Quando la batteria di {device} si scarica`),whenFalse:F(`When the battery of {device} is fine again`,`Quando la batteria di {device} torna a posto`),icon:`battery-low`}}},[O.BinaryHelper]:{state:{on:{label:F(`On`,`Acceso`),whenTrue:F(`When {device} turns on`,`Quando {device} si accende`),whenFalse:F(`When {device} turns off`,`Quando {device} si spegne`),icon:`toggle-right`}}}}}}},cw=S([`unknown-source`,`not-admin`,`no-builder`,`no-ingress-url`,`unreachable`,`unknown-board`,`no-encryption-key`,`unreadable-config`]),Sye=x({sourceId:l(),name:l()}),Cye=x({configuration:l(),name:l(),address:l().nullable()}),lw=x({ok:p(!1),reason:cw,detail:l().optional()}),wye=i(`ok`,[x({ok:p(!0),boards:C(Cye).readonly()}),lw]),Tye=i(`ok`,[x({ok:p(!0),key:l()}),lw]),uw={name:`board-key-source`,scope:`system`,mode:`collection`,methods:{listSources:A(v(),C(Sye).readonly(),{auth:`admin`}),listBoards:A(x({sourceId:l().min(1)}),wye,{auth:`admin`}),getBoardKey:A(x({sourceId:l().min(1),configuration:l().min(1)}),Tye,{auth:`admin`})},vocabulary:{notOperatorFacing:M.INTERNAL}},dw=x({level:n().min(0).max(100).meta(N(`percentage`)),lastChangedAt:n()}),fw={name:`brightness`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Light],methods:{setBrightness:A(x({deviceId:n().int().nonnegative(),level:n().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`brightness.full`,label:F(`Full brightness`,`Luminosità massima`),phrase:F(`Set {device} to full brightness`,`Porta {device} alla massima luminosità`),icon:`sun`,effect:{field:`level`,value:100},args:{level:100}},{id:`brightness.half`,label:F(`Half brightness`,`Luminosità a metà`),phrase:F(`Dim {device} to half`,`Abbassa {device} a metà luminosità`),icon:`sun-dim`,effect:{field:`level`,value:50},args:{level:50}},{id:`brightness.off`,label:F(`Brightness off`,`Luminosità a zero`),phrase:F(`Dim {device} to zero`,`Abbassa {device} a zero`),icon:`lightbulb-off`,effect:{field:`level`,value:0},args:{level:0}},{id:`brightness.set`,label:F(`Set brightness`,`Imposta la luminosità`),phrase:F(`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:F(`Percentage`,`Percentuale`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]})},events:{onBrightnessChanged:{data:x({deviceId:n(),level:n().min(0).max(100),lastChangedAt:n()}),notOperatorFacing:"the `level` state trigger reads the same change"}},status:{schema:dw,kind:`command-driven`},runtimeState:dw,durability:`session`,history:{fields:{level:{kind:`gauge`,unit:`%`,minIntervalMs:0}}},vocabulary:{noun:F(`Brightness`,`Luminosità`),order:1010,state:[{kind:`numeric`,field:`level`,quantity:F(`the brightness`,`la luminosità`),label:F(`Brightness`,`Luminosità`),unit:`%`,icon:`sun`}]}},Eye=S([`connected`,`disconnected`,`connecting`,`auth-failed`,`unreachable`,`error`]),pw=x({brokerCount:n().int().nonnegative(),connectedCount:n().int().nonnegative()}),Dye=x({id:l()}),Oye=m(l(),w()),mw=x({brokerId:l(),target:m(l(),w()),payload:w().optional()}),hw=x({brokerId:l(),filter:m(l(),w())}),gw=x({subscriptionId:l()}),_w=x({brokerId:l(),subscriptionId:l()}),vw=x({brokerId:l(),key:l()}),yw={name:`broker`,scope:`system`,mode:`collection`,providerKind:`broker`,status:{schema:pw,kind:`poll`},methods:{getBrokerConfig:A(Dye,Oye.nullable(),{auth:`admin`}),publish:A(mw,w(),{kind:`mutation`,auth:`admin`}),subscribe:A(hw,gw,{kind:`mutation`,auth:`admin`}),unsubscribe:A(_w,v(),{kind:`mutation`,auth:`admin`}),getState:A(vw,w().nullable(),{auth:`admin`}),getStatus:A(v(),pw)},vocabulary:{notOperatorFacing:`message-broker connections — configured, not actuated`}},bw={name:`button`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Button],methods:{press:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`button.press`,label:F(`Press`,`Premi`),phrase:F(`Press {device}`,`Premi {device}`),icon:`circle-dot`}]})},vocabulary:{noun:F(`Button`,`Pulsante`),order:1130}},xw=S([`ha`,`addon`]),Sw=x({id:l().min(1),name:l().min(1),source:xw,enabled:y(),instanceId:l().min(1).optional()}),Cw=x({id:l().min(1),calendarId:l().min(1),title:l(),startMs:n().int(),endMs:n().int(),allDay:y().optional(),description:l().optional(),location:l().optional()}),ww=x({calendarIds:C(l().min(1)).max(64).optional(),startMs:n().int(),endMs:n().int()}),Tw={name:`calendar-source`,scope:`system`,mode:`collection`,internal:!0,providerKind:`calendar`,methods:{listCalendars:A(v(),C(Sw).readonly(),{auth:`admin`}),listEvents:A(ww,C(Cw).readonly(),{auth:`admin`})},vocabulary:{notOperatorFacing:M.INTERNAL}};function Ew(e){let t=new Date(e);return new Date(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()).getTime()}function Dw(e){if(e.allDay!==!0)return{startMs:e.startMs,endMs:e.endMs};let t=Ew(e.startMs),n=Ew(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 kye(e,t){let n=new Date(t),r=new Date(n.getFullYear(),n.getMonth(),n.getDate()+1).getTime(),i=Dw(e);return i.startMs<r&&i.endMs>t}var Ow=l().regex(/^#[0-9A-Fa-f]{6}$/,`expected #RRGGBB`),kw=Sw.extend({id:l().min(1),providerAddonId:l().min(1).optional(),defaultColor:Ow,color:Ow,visible:y()}),Aw=x({visible:y().optional(),color:Ow.optional()}),jw=x({calendars:m(l(),Aw)}),Mw=x({calendarId:l().min(1),visible:y().optional(),color:Ow.nullable().optional()}),Nw={name:`calendars`,scope:`system`,mode:`singleton`,methods:{listCalendars:A(v(),C(kw).readonly(),{auth:`admin`}),listEvents:A(ww,C(Cw).readonly(),{auth:`admin`}),getPreferences:A(x({}),jw,{auth:`admin`,caller:`required`}),setCalendarPreference:A(Mw,jw,{auth:`admin`,kind:`mutation`,caller:`required`})},vocabulary:{notOperatorFacing:`calendars feed schedules and conditions, not device actions`}},Pw=x({host:l(),port:n().int().positive().optional(),onvifPort:n().int().positive().optional(),rtspPort:n().int().positive().optional(),https:y().optional(),username:l().optional(),password:l().optional(),onvifProfile:l().optional()}),Fw=x({host:l(),port:n().int().positive().nullable(),onvifPort:n().int().positive().nullable(),rtspPort:n().int().positive().nullable(),https:y().nullable(),hasUsername:y(),hasPassword:y(),onvifProfile:l().nullable()}),Iw={name:`camera-credentials`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],methods:{getCredentials:A(x({deviceId:n()}),Pw.nullable(),{kind:`query`,auth:`admin`})},status:{schema:Fw,kind:`command-driven`},vocabulary:{noun:F(`Camera credentials`,`Credenziali della telecamera`),order:3030}},Lw=x({x:n().min(0).max(1),y:n().min(0).max(1),width:n().gt(0).max(1),height:n().gt(0).max(1)}),Rw=x({deviceId:n().int().positive(),source:Lw,cell:Lw}),Aye=x({profile:S([`high`,`mid`,`low`]),offered:y(),missingSources:C(n().int().positive()),canvas:l(),published:y()}),zw=x({blockId:l(),deviceId:n().int().nonnegative(),name:l(),fps:n().int(),cells:C(Rw),profiles:C(Aye)}),Bw=x({deviceId:n().int().nonnegative(),fps:n().int().min(1).max(60).optional(),publishedProfiles:C(S([`high`,`mid`,`low`])).max(3).optional(),cells:C(Rw).max(16)}),Vw={name:`camera-grid-layout`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],exposesDeviceSettings:!0,methods:{getLayout:A(x({deviceId:n().int().nonnegative()}),zw.nullable(),{auth:`admin`}),saveLayout:A(Bw,zw,{kind:`mutation`,auth:`admin`})},vocabulary:{noun:F(`Grid layout`,`Layout a griglia`),order:3040}},Hw={name:`camera-pipeline-config`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[E.Camera],exposesDeviceSettings:!0,methods:{},vocabulary:{noun:F(`Detection settings`,`Impostazioni di rilevamento`),order:3050}},Uw=S([`webrtc`,`hls`,`mjpeg`,`rtsp`]),Ww=S([`mp4`,`gif`]),Gw=x({kind:Ww,handle:l(),nodeId:l(),mime:l(),bytes:n().int(),width:n().int(),height:n().int()}),Kw=x({fromTs:n(),toTs:n(),packets:n().int()}),qw=x({media:C(Gw).readonly(),coverage:Kw,profile:P,video:S([`copy`,`encode`])}),Jw=x({brokerId:l(),url:l(),mutedUrl:l(),enabled:y(),codec:l().optional(),resolution:x({width:n().int().positive(),height:n().int().positive()}).optional()}),Yw=x({sessionId:l(),remoteAddr:l(),userAgent:l().nullish(),playing:y(),muted:y(),connectedAt:n(),lastRtpAt:n(),bytesSent:n()}),Xw=x({tag:l(),subscribedAt:n(),chunksDelivered:n()}),Zw=S([`alexa`,`homekit`,`webrtc-browser`,`webrtc-mobile`,`webrtc-whep`,`rtsp-listen`,`derived-broker`,`recording`,`pipeline`,`snapshot`,`warmup`,`unknown`]),Qw=x({kind:Zw,label:l().optional(),media:S([`audio`,`video`,`both`]).optional(),targetCodec:l().optional(),transport:S([`passthrough`,`repacketize`,`transcode`]).optional(),remoteAddr:l().optional(),userAgent:l().optional(),userId:l().optional(),sessionId:l().optional(),extra:m(l(),l()).optional()}).readonly(),$w=x({id:l(),channel:S([`annexb`,`rtp`]),attribution:Qw,subscribedAt:n(),packetsDelivered:n()}),eT=x({rtsp:C(Yw).readonly(),audio:C(Xw).readonly(),encoded:C($w).readonly(),pipeClients:n(),encodedSubscribers:n()}),tT=x({deviceId:n().int().nonnegative(),viewers:n().int().positive()}),jye=S([`reconnecting`,`sleeping`,`offline`,`disabled`,`waking`]),Mye=S([`h264`,`h265`,`copy`]),Nye=S([`aac`,`opus`,`pcmu`,`copy`,`none`]),nT=x({deviceId:n().int().nonnegative(),video:Mye,audio:Nye.optional(),profile:P.optional(),targetResolution:x({width:n().int().positive(),height:n().int().positive()}).optional(),outputArgs:C(l()).optional(),audioEgress:y().optional(),hostname:l().optional(),tag:l().optional()}),rT=x({url:l(),sentryUrl:l().nullable().optional(),videoCodec:S([`H264`,`H265`]),audioCodec:l(),resolution:x({width:n().int().positive(),height:n().int().positive()}),transcoded:y(),encoder:l(),pipelineKey:l()}),iT=Nd.omit({inputArgs:!0,outputArgs:!0}),aT=S([`tight`,`relaxed`]),oT=x({deviceId:n().int().nonnegative(),source:i(`kind`,[x({kind:p(`profile`),profile:P}),x({kind:p(`cam-stream`),camStreamId:l().min(1)})]),encode:iT,rateControl:aT.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:l().optional(),tag:l().optional()}),sT=x({url:l(),pipelineKey:l(),videoCodec:S([`H264`,`H265`]),resolution:x({width:n().int().positive(),height:n().int().positive()}),transcoded:y(),encoder:l(),decodeHwAccel:l().nullable(),camStreamId:l().nullable()}),cT={name:`stream-broker`,scope:`system`,mode:`singleton`,exposesDeviceSettings:!0,methods:{reportStreamSignal:A(x({deviceId:n().int().nonnegative(),code:l().min(1),at:n().optional()}),x({accepted:y(),reason:S([`woke`,`hold-extended`,`not-enabled`,`no-consumer`,`unknown-code`])}),{kind:`mutation`}),publishCameraStream:A(x({deviceId:n().int().nonnegative(),camStreamId:l().min(1),kind:ga,url:l().optional(),codec:l().optional(),resolution:_a.optional(),fps:n().positive().optional(),label:l().optional(),deviceFeatures:C(l()).optional(),autoEligible:y().optional(),profileHint:P.optional(),metadata:m(l(),w()).optional(),sourceCamStreamId:l().min(1).optional(),encodeProfile:Nd.optional()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),retractCameraStream:A(x({deviceId:n().int().nonnegative(),camStreamId:l().min(1)}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),assignProfile:A(x({deviceId:n().int().nonnegative(),profile:P,camStreamId:l().min(1)}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),unassignProfile:A(x({deviceId:n().int().nonnegative(),profile:P}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),forgetDeviceHardware:A(x({deviceId:n().int().nonnegative()}),x({derivedStreamsDeleted:C(l()).readonly(),assignmentsPurged:y(),probeSnapshotsDropped:n().int().nonnegative(),rtspTokenRowsDeleted:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),renderPreBufferClip:A(x({deviceId:n(),profile:P.optional(),aroundMs:n(),preRollSec:n().min(0).max(20).default(3),postRollSec:n().min(0).max(20).default(5),format:S([`gif`,`mp4`]).default(`gif`),maxWidth:n().int().min(120).max(1920).default(480),fps:n().int().min(1).max(15).default(5),speed:n().min(1).max(8).default(2)}),x({base64:l(),mime:l(),bytes:n().int(),profile:P,durationMs:n()}),{kind:`mutation`,auth:`admin`}),produceEventMedia:A(x({deviceId:n(),profile:P.optional(),aroundMs:n(),preSeconds:n().min(0).max(20).default(4),postSeconds:n().min(0).max(20).default(6),kinds:C(Ww).min(1).default([`mp4`]),gifMaxWidth:n().int().min(120).max(1280).default(640),gifFps:n().int().min(1).max(15).default(12),gifSpeed:n().min(1).max(8).default(4),speed:n().min(1).max(8).default(4)}),qw,{kind:`mutation`,auth:`admin`}),fetchEventMedia:A(x({handle:l()}),x({base64:l(),mime:l(),bytes:n().int()}).nullable(),{kind:`mutation`,auth:`admin`}),listAllCameraStreams:A(v(),C(va).readonly()),listAllProfileSlots:A(v(),C(ba).readonly()),getBrokerStats:A(x({brokerId:l()}),One),previewDerivedEncode:A(x({deviceId:n().int().nonnegative(),profile:Nd,source:wne.optional()}),Dne),probeStream:A(x({brokerId:l()}),x({probed:y(),summary:l()}),{kind:`mutation`,auth:`admin`}),listClients:A(x({brokerId:l()}),eT),getLiveViewerCounts:A(v(),C(tT).readonly(),{role:`viewer`}),killClient:A(x({brokerId:l(),channel:S([`rtsp`,`audio`]),handle:l()}),x({killed:y()}),{kind:`mutation`,auth:`admin`}),restartProfile:A(x({deviceId:n().int().nonnegative(),profile:P}),x({success:y()}),{kind:`mutation`,auth:`admin`}),getStreamUrl:A(x({streamId:l(),format:Uw}),x({url:l()})),getStreamWithCodec:A(nT,rT,{kind:`mutation`,auth:`admin`}),releaseStreamWithCodec:A(x({pipelineKey:l()}),x({released:y(),refcount:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),acquireEgressTranscode:A(oT,sT,{kind:`mutation`,auth:`admin`}),releaseEgressTranscode:A(x({pipelineKey:l()}),x({released:y(),refcount:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),subscribeAudioChunks:A(xne,Sne,{kind:`mutation`}),pullAudioChunks:A(x({subscriptionId:l(),maxCount:n().int().positive().default(8)}),C(bne).readonly()),unsubscribeAudioChunks:A(x({subscriptionId:l()}),x({released:y()}),{kind:`mutation`}),setPreBufferDuration:A(x({brokerId:l(),seconds:n().min(0).max(30)}),v(),{kind:`mutation`,auth:`admin`}),getPreBufferInfo:A(x({brokerId:l()}),x({configuredSec:n(),bufferedMs:n(),packetCount:n()})),getRtspPort:A(v(),n()),getAllRtspEntries:A(x({hostname:l().optional()}),C(Jw).readonly()),getRtspEntry:A(x({brokerId:l(),hostname:l().optional()}),Jw.nullable()),regenerateRtspToken:A(x({brokerId:l()}),l().nullable(),{kind:`mutation`,auth:`admin`}),setRtspEnabled:A(x({brokerId:l(),enabled:y()}),v(),{kind:`mutation`,auth:`admin`}),isRtspEnabled:A(x({brokerId:l()}),y()),getDeviceAudioMute:A(x({deviceId:n().int()}),x({muted:y(),appliedBrokers:n().int().nonnegative()})),setDeviceAudioMute:A(x({deviceId:n().int(),muted:y()}),x({muted:y(),appliedBrokers:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`})},events:{onCamStreamDemand:ni(x({deviceId:n().int().nonnegative(),camStreamId:l(),profile:P})),onCamStreamIdle:ni(x({deviceId:n().int().nonnegative(),camStreamId:l()})),onRequestStreamSourceRefresh:ni(x({deviceId:n().int().nonnegative(),camStreamId:l(),brokerId:l()}))},vocabulary:{notOperatorFacing:M.PIPELINE}},lT=S([`h264`,`h265`,`hevc`,`av1`,`mjpeg`,`vp8`,`vp9`]),uT=x({acceptCodecs:C(lT).readonly().optional(),minHeight:n().int().positive().optional(),maxHeight:n().int().positive().optional(),minWidth:n().int().positive().optional(),excludeDerived:y().optional(),requireSiblingCodec:C(lT).readonly().optional(),allowTranscode:y().optional(),requireProfileBound:y().optional()}).readonly(),dT=x({preferredProviders:C(l()).readonly().optional(),resolutionPreference:S([`highest`,`lowest`]).optional(),targetHeight:n().int().positive().optional()}).readonly(),fT=x({camStreamId:l(),codec:l().optional(),resolution:_a.optional(),transcodes:y(),reason:l(),profile:P.optional(),brokerId:l().optional(),url:l().optional(),fps:n().positive().optional(),fpsSource:S([`published`,`measured`]).optional()}),pT={name:`camera-streams`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[E.Camera],methods:{getCameraStreams:A(x({deviceId:n().int().nonnegative()}),C(va).readonly()),getBrokerStreams:A(x({deviceId:n().int().nonnegative()}),C(ba).readonly()),getRtspEntries:A(x({deviceId:n().int().nonnegative(),hostname:l().optional()}),C(Jw).readonly()),getProfileRtspEntries:A(x({deviceId:n().int().nonnegative(),hostname:l().optional()}),C(kne).readonly()),pickStream:A(x({deviceId:n().int().nonnegative(),requirements:uT,preferences:dT.optional()}),fT.nullable())},events:{onCamStreamsChanged:ni(x({deviceId:n().int().nonnegative(),camStreams:C(va).readonly()}),{notOperatorFacing:`the stream catalog was rebuilt — plumbing, not a happening`}),onProfileSlotsChanged:ni(x({deviceId:n().int().nonnegative(),profileSlots:C(ba).readonly()}),{notOperatorFacing:`stream profiles were reassigned — plumbing, not a happening`})},runtimeState:x({online:y(),slotStatuses:x({high:ya.optional(),mid:ya.optional(),low:ya.optional()}),slotErrors:x({high:l().optional(),mid:l().optional(),low:l().optional()}),lastChangedAt:n()}),durability:`session`,history:`none`,vocabulary:{noun:F(`Camera streams`,`Flussi della telecamera`),order:3060}},mT=x({detected:y(),lastChangedAt:n()}),hT={name:`carbon-monoxide`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:mT,kind:`push`},runtimeState:mT,durability:`restored`,history:{fields:{detected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Carbon monoxide`,`Monossido di carbonio`),order:5030,state:[{kind:`boolean`,field:`detected`,label:F(`Detected`,`Rilevato`),whenTrue:F(`When {device} detects carbon monoxide`,`Quando {device} rileva monossido di carbonio`),whenFalse:F(`When the carbon monoxide clears on {device}`,`Quando il monossido su {device} rientra`),icon:`cloud-alert`}]}},gT=S([`off`,`heat`,`cool`,`auto`,`heat_cool`,`fan_only`,`dry`]),_T=S([`heating`,`cooling`,`drying`,`fan`,`idle`,`off`]),vT=x({mode:gT,action:_T.nullable().optional(),availableModes:C(gT),fanMode:l(),availableFanModes:C(l()),preset:l(),availablePresets:C(l()),target:n().nullable().meta(N(`temperature`)),targetHigh:n().nullable().meta(N(`temperature`)),targetLow:n().nullable().meta(N(`temperature`)),targetHumidity:n().min(0).max(100).nullable().meta(N(`humidity`)),currentTemp:n().nullable().meta(N(`temperature`)),currentHumidity:n().min(0).max(100).nullable().meta(N(`humidity`)),swingVertical:y().nullable(),swingHorizontal:y().nullable(),minTemp:n().nullable().optional().meta(N(`temperature`)),maxTemp:n().nullable().optional().meta(N(`temperature`)),tempStep:n().positive().nullable().optional().meta(N(`temperature`)),lastActiveMode:gT.exclude([`off`]).optional(),lastFetchedAt:n()}),Pye=[E.Climate];function yT(e,t){return{id:e,cardinality:`scalar`,vocabulary:{cap:`climate-control`,stateField:t},deviceTypes:Pye,apply:`replace`,path:t,sources:[{kind:`numeric`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}}var bT=[yT(`room-temperature`,`currentTemp`),yT(`room-humidity`,`currentHumidity`)],Fye={version:1,overridable:bT.map(e=>({path:e.path,by:e.id})),targets:bT},xT={name:`climate-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Climate],power:{kind:`mode`,field:`mode`,offValue:`off`,set:`setMode`,lastField:`lastActiveMode`},methods:{setMode:A(x({deviceId:n().int().nonnegative(),mode:gT}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.off`,label:F(`Climate off`,`Clima spento`),phrase:F(`Turn off {device}`,`Spegni {device}`),icon:`power-off`,effect:{field:`mode`,value:`off`},args:{mode:`off`}},{id:`climate.heat`,label:F(`Heat`,`Riscalda`),phrase:F(`Set {device} to heat`,`Metti {device} in riscaldamento`),icon:`flame`,effect:{field:`mode`,value:`heat`},args:{mode:`heat`}},{id:`climate.cool`,label:F(`Cool`,`Raffresca`),phrase:F(`Set {device} to cool`,`Metti {device} in raffrescamento`),icon:`snowflake`,effect:{field:`mode`,value:`cool`},args:{mode:`cool`}},{id:`climate.auto`,label:F(`Climate auto`,`Clima automatico`),phrase:F(`Set {device} to automatic`,`Metti {device} in automatico`),icon:`thermometer`,effect:{field:`mode`,value:`auto`},args:{mode:`auto`}},{id:`climate.mode`,label:F(`Set mode`,`Imposta la modalità`),phrase:F(`Set {device} to {mode}`,`Imposta {device} su {mode}`),icon:`thermometer`,effect:{field:`mode`,fromArg:`mode`},openArgs:[{key:`mode`,label:F(`Mode`,`Modalità`),offer:{kind:`enum`,values:[{value:`off`,label:F(`Off`,`Spento`)},{value:`heat`,label:F(`Heat`,`Riscaldamento`)},{value:`cool`,label:F(`Cool`,`Raffrescamento`)},{value:`auto`,label:F(`Automatic`,`Automatico`)},{value:`heat_cool`,label:F(`Heat and cool`,`Caldo e freddo`)},{value:`fan_only`,label:F(`Fan only`,`Solo ventilazione`)},{value:`dry`,label:F(`Dry`,`Deumidificazione`)}]}}]}]}),setTarget:A(x({deviceId:n().int().nonnegative(),target:n()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.target`,label:F(`Set temperature`,`Imposta la temperatura`),phrase:F(`Set {device} to {target}`,`Imposta {device} a {target}`),icon:`thermometer`,effect:{field:`target`,fromArg:`target`},openArgs:[{key:`target`,label:F(`Temperature`,`Temperatura`),offer:{kind:`number`,step:.5,unit:`°C`}}]}]}),setTargetRange:j(x({deviceId:n().int().nonnegative(),targetLow:n(),targetHigh:n()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.targetRange`,label:F(`Set temperature range`,`Imposta l’intervallo di temperatura`),phrase:F(`Keep {device} between {targetLow} and {targetHigh}`,`Mantieni {device} tra {targetLow} e {targetHigh}`),icon:`thermometer`,effect:{field:`targetLow`,fromArg:`targetLow`},sideEffects:[{field:`targetHigh`,fromArg:`targetHigh`}],openArgs:[{key:`targetLow`,label:F(`Lowest`,`Minima`),offer:{kind:`number`,step:.5,unit:`°C`}},{key:`targetHigh`,label:F(`Highest`,`Massima`),offer:{kind:`number`,step:.5,unit:`°C`}}]}]}),setTargetHumidity:j(x({deviceId:n().int().nonnegative(),targetHumidity:n().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.targetHumidity`,label:F(`Set humidity`,`Imposta l’umidità`),phrase:F(`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:F(`Humidity`,`Umidità`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setFanMode:j(x({deviceId:n().int().nonnegative(),fanMode:l().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.fanMode`,label:F(`Set fan mode`,`Imposta la ventilazione`),phrase:F(`Set the fan of {device} to {fanMode}`,`Imposta la ventilazione di {device} su {fanMode}`),icon:`fan`,effect:{field:`fanMode`,fromArg:`fanMode`},openArgs:[{key:`fanMode`,label:F(`Fan mode`,`Ventilazione`),offer:{kind:`dynamic`,from:`status`,field:`availableFanModes`}}]}]}),setPreset:j(x({deviceId:n().int().nonnegative(),preset:l().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.preset`,label:F(`Set preset`,`Imposta il preset`),phrase:F(`Set {device} to preset {preset}`,`Imposta {device} sul preset {preset}`),icon:`list`,effect:{field:`preset`,fromArg:`preset`},openArgs:[{key:`preset`,label:F(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`status`,field:`availablePresets`}}]}]}),setSwingVertical:j(x({deviceId:n().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.swingVerticalOn`,label:F(`Vertical swing on`,`Oscillazione verticale attiva`),phrase:F(`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:F(`Vertical swing off`,`Oscillazione verticale spenta`),phrase:F(`Stop the vertical swing of {device}`,`Ferma l’oscillazione verticale di {device}`),icon:`move-vertical`,effect:{field:`swingVertical`,value:!1},args:{on:!1}}]}),setSwingHorizontal:j(x({deviceId:n().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.swingHorizontalOn`,label:F(`Horizontal swing on`,`Oscillazione orizzontale attiva`),phrase:F(`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:F(`Horizontal swing off`,`Oscillazione orizzontale spenta`),phrase:F(`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:vT,kind:`push`},runtimeState:vT,customize:Fye,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:F(`Climate`,`Clima`),order:1070,state:[{kind:`enum`,field:`mode`,label:F(`Mode`,`Modalità`),values:[{value:`off`,label:F(`Off`,`Spento`),phrase:F(`When {device} turns off`,`Quando {device} si spegne`)},{value:`heat`,label:F(`Heat`,`Riscaldamento`),phrase:F(`When {device} starts heating`,`Quando {device} passa al riscaldamento`)},{value:`cool`,label:F(`Cool`,`Raffrescamento`),phrase:F(`When {device} starts cooling`,`Quando {device} passa al raffrescamento`)},{value:`auto`,label:F(`Automatic`,`Automatico`)},{value:`heat_cool`,label:F(`Heat and cool`,`Caldo e freddo`)},{value:`fan_only`,label:F(`Fan only`,`Solo ventilazione`)},{value:`dry`,label:F(`Dry`,`Deumidificazione`)}],icon:`thermometer`},{kind:`numeric`,field:`currentTemp`,quantity:F(`the temperature`,`la temperatura`),label:F(`Temperature`,`Temperatura`),unit:`°C`,icon:`thermometer`},{kind:`numeric`,field:`currentHumidity`,quantity:F(`the humidity`,`l’umidità`),label:F(`Humidity`,`Umidità`),unit:`%`,icon:`droplets`},{kind:`numeric`,field:`target`,quantity:F(`the set temperature`,`la temperatura impostata`),label:F(`Set temperature`,`Temperatura impostata`),unit:`°C`,icon:`thermometer`}]}},ST=S([`backup`,`hub-server`,`agent-server`,`addons`]),CT=S([`pending`,`running`,`ok`,`failed`,`skipped`]),wT=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`]),TT=x({kind:ST,nodeId:l().optional(),status:CT,detail:l(),reason:wT.optional(),fromVersion:l().nullable().optional(),packages:C(l()).readonly().optional(),startedAt:n().optional(),finishedAt:n().optional()}),ET=S([`running`,`succeeded`,`failed`]),DT=x({id:l(),state:ET,targetVersion:l(),requestedBy:l(),startedAt:n(),finishedAt:n().optional(),steps:C(TT).readonly(),stoppedAt:l().optional(),reason:wT.optional(),skippedOffline:C(l()).readonly()}),OT=x({version:l().optional(),addons:y().optional(),backup:y().optional()}),kT=S([`no-target`,`node-busy`,`job-running`,`nothing-to-do`,`status-unreadable`]),AT=x({targetVersion:l().nullable(),steps:C(TT).readonly(),skippedOffline:C(l()).readonly(),blocker:kT.nullable(),blockerDetail:l().nullable()}),jT=x({accepted:y(),jobId:l().nullable(),blocker:kT.nullable(),message:l()}),MT={name:`cluster-update`,scope:`system`,mode:`singleton`,methods:{previewClusterUpdate:A(OT,AT,{auth:`admin`}),startClusterUpdate:A(OT,jT,{kind:`mutation`,auth:`admin`}),getClusterUpdateJob:A(x({jobId:l().optional()}),DT.nullable(),{auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:M.CLUSTER}},NT=x({r:n().int().min(0).max(255).meta(N(`none`)),g:n().int().min(0).max(255).meta(N(`none`)),b:n().int().min(0).max(255).meta(N(`none`))}),PT=x({h:n().min(0).max(360).meta(N(`none`)),s:n().min(0).max(100).meta(N(`none`)),v:n().min(0).max(100).meta(N(`none`))}),FT=i(`mode`,[x({mode:p(`rgb`),rgb:NT}),x({mode:p(`hsv`),hsv:PT}),x({mode:p(`mired`),colorTemperature:n().int().min(50).max(1e3)})]),IT=x({mode:S([`rgb`,`hsv`,`mired`]),rgb:NT.optional(),hsv:PT.optional(),colorTemperature:n().int().optional().meta(N(`colour-temperature`)),lastChangedAt:n()});function Iye(e){let t=FT.safeParse(e);return t.success?t.data:null}var LT={name:`color`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Light],methods:{setColor:A(x({deviceId:n().int().nonnegative(),color:FT}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`color.warmWhite`,label:F(`Warm white`,`Bianco caldo`),phrase:F(`Set {device} to warm white`,`Imposta {device} su bianco caldo`),icon:`sun`,args:{color:{mode:`mired`,colorTemperature:370}}},{id:`color.coolWhite`,label:F(`Cool white`,`Bianco freddo`),phrase:F(`Set {device} to cool white`,`Imposta {device} su bianco freddo`),icon:`snowflake`,args:{color:{mode:`mired`,colorTemperature:200}}},{id:`color.red`,label:F(`Red`,`Rosso`),phrase:F(`Turn {device} red`,`Colora {device} di rosso`),icon:`palette`,args:{color:{mode:`rgb`,rgb:{r:255,g:0,b:0}}}},{id:`color.green`,label:F(`Green`,`Verde`),phrase:F(`Turn {device} green`,`Colora {device} di verde`),icon:`palette`,args:{color:{mode:`rgb`,rgb:{r:0,g:255,b:0}}}},{id:`color.blue`,label:F(`Blue`,`Blu`),phrase:F(`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:n(),mode:S([`rgb`,`hsv`,`mired`]),rgb:NT.optional(),hsv:PT.optional(),colorTemperature:n().int().optional(),lastChangedAt:n()}),notOperatorFacing:"a colour change is read through the `mode` state trigger"}},status:{schema:IT,kind:`command-driven`},runtimeState:IT,durability:`session`,history:`none`,vocabulary:{noun:F(`Colour`,`Colore`),order:1020,state:[{kind:`enum`,field:`mode`,label:F(`Colour mode`,`Modalità colore`),values:[{value:`rgb`,label:F(`RGB colour`,`Colore RGB`)},{value:`hsv`,label:F(`HSV colour`,`Colore HSV`)},{value:`mired`,label:F(`White temperature`,`Temperatura del bianco`)}],icon:`palette`}]}};function RT(e,t){let n=e;for(let e of t.split(`.`)){let t=Jg(n);if(!(t instanceof ce))return null;let r=t.shape[e];if(!(r instanceof ie))return null;n=r}return n}function zT(e,t){let n=Yg(e).find(e=>e.path===t);if(n===void 0)return null;let r=RT(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 BT(e){return new Map(Yg(e).filter(e=>!e.path.includes(`.`)).flatMap(t=>{let n=zT(e,t.path);return n===null?[]:[[t.path,n]]}))}function VT(e){let t=Jg(e);return t instanceof ce?Object.entries(t.shape).flatMap(([e,t])=>t instanceof ie&&!t.safeParse(void 0).success?[e]:[]):[]}function HT(e,t){let n=t.split(`.`);return n.slice(0,-1).flatMap((t,r)=>{let i=n.slice(0,r+1).join(`.`),a=RT(e,i);return a!==null&&a.safeParse(void 0).success?[i]:[]})}var UT={"doorbell.onPressed":T.DoorbellOnPressed},Lye=UT,WT=x({featureIndex:n().int().nonnegative(),cap:l(),eventName:l(),category:S(T),stateField:l(),fieldKey:l()});function GT(e,t,n){return{code:e,path:t,message:n}}function Rye(e){return e.issues.map(e=>`${e.path.length===0?`payload`:e.path.join(`.`)}: ${e.message}`).join(`; `)}function KT(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?zT(e.runtimeState,s.field):null;if(l===null){r.push(GT(`unknown-field`,c,`\`${e.name}.${a}\` derives from missing state field \`${s.field}\``));continue}if(l.kind!==`number`){r.push(GT(`kind-mismatch`,c,`\`${e.name}.${a}\` needs a numeric state field; \`${s.field}\` is ${l.kind}`));continue}let u=`${e.name}.${a}`,d=Lye[u];if(d===void 0){r.push(GT(`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(GT(`not-composable`,`features[${t.featureIndex}].cap`,`\`${u}\` cannot be derived from { deviceId, timestamp }: ${Rye(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(GT(`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 qT=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.link-contribution-removed`.split(`.`)),JT=x({code:qT,path:l(),message:l()}),YT=S([`string`,`number`,`boolean`,`enum`]),XT=S([`null`,`offline`,`unknown`,`release`,`omit`]),ZT=S([`derived`,`clock`,`constant`,`accumulator`]),QT=x({arrayPath:l(),key:l(),label:l(),resettable:y().optional()}),$T=x({cap:l(),path:l(),item:QT.optional(),featureIndex:n().int().nonnegative(),kind:YT,nullable:y(),required:y(),unavailable:XT,role:ZT,source:sl,reads:C($c)});function eE(e){let t=e.item===void 0?e.path:Pl(e.item.arrayPath,e.item.key,e.path);return`${e.cap}.${t}`}var tE=S([`new`,`add`,`replace`]),nE=x({featureIndex:n().int().nonnegative(),cap:l(),mode:tE}),rE=x({ok:y(),problems:C(JT),fields:C($T),features:C(nE),events:C(WT)}),iE=S([`stopped`,`starting`,`running`,`degraded`,`incomplete`,`failed`]),aE=S([`fresh`,`stale`,`unavailable`]),oE=x({cap:l(),path:l(),item:QT.optional(),state:aE,value:h([l(),n(),y(),ae()]),reason:l().optional()}),sE=x({blockId:l(),deviceId:n().nullable(),status:iE,reason:l().optional(),fields:C(oE)}),zye=Zc,cE=x({id:l().min(1),name:l().min(1).max(120),enabled:y(),updatedAt:n(),composition:Dl}),lE=x({id:l().min(1),name:l().nullable(),error:l()}),uE=x({deviceId:n().int(),capName:l(),owner:l(),error:l()}),dE=x({integrationId:l().nullable(),storeLoaded:y(),blocks:C(cE),restartBlockIds:C(l()),unreadableBlocks:C(lE),retiredBlockIds:C(l()).optional()}),fE=x({blockId:l(),status:iE,reason:l().optional()}),pE=x({blocks:C(fE),acted:y(),unreleasedClaims:C(uE).optional()}),mE={name:`composer`,scope:`system`,mode:`singleton`,internal:!0,methods:{applyBlocks:A(dE,pE,{kind:`mutation`,auth:`admin`}),getStates:A(x({blockIds:C(l())}),x({states:C(sE)}),{auth:`admin`})},vocabulary:{notOperatorFacing:`device composition — an authoring tool, not an action`}},hE=x({connected:y(),lastChangedAt:n()}),gE={name:`connectivity`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:hE,kind:`push`},runtimeState:hE,durability:`restored`,history:{fields:{connected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Connectivity`,`Connettività`),order:5040,state:[{kind:`boolean`,field:`connected`,label:F(`Connected`,`Connesso`),whenTrue:F(`When {device} connects`,`Quando {device} si connette`),whenFalse:F(`When {device} disconnects`,`Quando {device} si disconnette`),icon:`wifi`}]}},_E=S([`wear`,`supply`,`waste`]),vE=S([`part`,`tank`,`product`,`bin`]),yE=S([`ok`,`low`,`empty`,`full`,`replace`]),Bye=S([`ok`,`low`,`empty`,`full`]);function bE(e){return e.kind??`wear`}var Vye={wear:`part`,waste:`bin`,supply:`product`};function Hye(e){return e.form??Vye[bE(e)]}var xE=S([`duration`,`count`]),SE=x({value:n().min(0).nullable().meta(N(`device`)),kind:xE}),CE=x({key:l().min(1),label:l().min(1),level:n().min(0).max(100).nullable().meta(N(`percentage`)),status:yE.nullable(),kind:_E.optional(),form:vE.optional(),lastResetAt:n().nullable(),resettable:y(),remaining:SE.optional()}),wE=x({items:C(CE),lastChangedAt:n()}),Uye={items:[],lastChangedAt:0},Wye={version:1,targets:[{id:`items`,cardinality:`keyedArray`,vocabulary:{cap:`consumables`},deviceTypes:Object.values(E),apply:`add`,path:`items`,keyField:`key`,labelField:`label`,itemSchema:CE,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:[...xE.options]}]},{path:`status`,sources:[{kind:`enum`,transforms:[{kind:`enum-map`,outputValues:[...yE.options],unmapped:null}]}]}],traits:[{path:`kind`,values:[..._E.options],defaultValue:`wear`},{path:`form`,values:[...vE.options],defaultValue:`part`}],companions:[{kind:`clock`,path:`lastChangedAt`,when:`add`},{kind:`clock`,path:`lastFetchedAt`,when:`add`}],advancedExpression:!0}]},TE={name:`consumables`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:Object.values(E),methods:{reset:A(x({deviceId:n().int().nonnegative(),key:l().min(1)}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`consumables.reset`,label:F(`Mark as replaced`,`Segna come sostituito`),phrase:F(`Mark {key} as replaced on {device}`,`Segna {key} come sostituito su {device}`),icon:`refresh-cw`,openArgs:[{key:`key`,label:F(`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:wE,kind:`push`,empty:Uye,itemArray:{path:`items`,keyField:`key`,labelField:`label`,itemSchema:CE,emptyItem:{key:``,label:``,level:null,status:null,lastResetAt:null,resettable:!1}}},runtimeState:wE.extend({lastFetchedAt:n()}),durability:`restored`,customize:Wye,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:F(`Consumables`,`Materiali di consumo`),order:2070}},EE=x({entryOpen:y(),lastChangedAt:n()}),DE={name:`contact`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:EE,kind:`push`},runtimeState:EE,durability:`restored`,history:{fields:{entryOpen:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Contact`,`Contatto`),order:5050,state:[{kind:`boolean`,field:`entryOpen`,label:F(`Open`,`Aperto`),whenTrue:F(`When {device} opens`,`Quando {device} si apre`),whenFalse:F(`When {device} closes`,`Quando {device} si chiude`),icon:`door-open`}]}},OE=S([`numeric`,`select`,`text`,`datetime`]),kE=x({kind:OE,value:h([n().meta(N(`device`)),l()]),options:C(l()),lastChangedAt:n(),min:n().optional().meta(N(`device`)),max:n().optional().meta(N(`device`)),step:n().optional().meta(N(`device`))}),Gye=i(`kind`,[x({kind:p(`numeric`),value:n()}),x({kind:p(`select`),value:l().min(1)}),x({kind:p(`text`),value:l()}),x({kind:p(`datetime`),value:l().min(1)})]),AE=x({deviceId:n().int().nonnegative(),cycle:y().default(!0)}),jE=x({deviceId:n().int().nonnegative()}),ME={name:`control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Control],methods:{setValue:A(x({deviceId:n().int().nonnegative(),control:Gye}),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:j(AE,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.next`,label:F(`Next option`,`Opzione successiva`),phrase:F(`Select the next option on {device}`,`Seleziona l’opzione successiva su {device}`),icon:`skip-forward`,openArgs:[{key:`cycle`,label:F(`Wrap to the first option`,`Ricomincia dalla prima opzione`),offer:{kind:`boolean`}}]}]}),previous:j(AE,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.previous`,label:F(`Previous option`,`Opzione precedente`),phrase:F(`Select the previous option on {device}`,`Seleziona l’opzione precedente su {device}`),icon:`skip-back`,openArgs:[{key:`cycle`,label:F(`Wrap to the last option`,`Ricomincia dall’ultima opzione`),offer:{kind:`boolean`}}]}]}),first:j(jE,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.first`,label:F(`First option`,`Prima opzione`),phrase:F(`Select the first option on {device}`,`Seleziona la prima opzione su {device}`),icon:`chevron-first`}]}),last:j(jE,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.last`,label:F(`Last option`,`Ultima opzione`),phrase:F(`Select the last option on {device}`,`Seleziona l’ultima opzione su {device}`),icon:`chevron-last`}]})},status:{schema:kE,kind:`push`},runtimeState:kE,durability:`session`,history:`none`,vocabulary:{noun:F(`Control`,`Controllo`),order:1150,state:[{kind:`value`,field:`value`,label:F(`Value`,`Valore`),offer:{kind:`dynamic`,from:`status`,field:`options`},icon:`sliders-horizontal`}]}},V=class extends Error{code;constructor(e,t){super(t),this.name=`IrCodecError`,this.code=e}},NE=1024,PE=C(n().int()).min(2).max(NE).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]})})}),FE=x({carrierHz:n().int().positive().optional(),dutyCyclePercent:n().int().min(1).max(100).optional(),repeat:n().int().min(0).max(20).optional(),repeatDelayMs:n().int().min(0).optional()}),Kye=.241246,qye=0;function IE(e){let t=e.trim().split(/\s+/).filter(e=>e.length>0);if(t.length<4)throw new V(`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 V(`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 V(`pronto-malformed`,`Pronto header incomplete`);if(r!==qye)throw new V(`pronto-unsupported-form`,`Pronto form ${t[0]??``} is not supported, only the learned 0000 form`);if(i===0)throw new V(`pronto-malformed`,`Pronto frequency word is zero`);let s=a+o;if(s===0||n.length!==4+s*2)throw new V(`pronto-malformed`,`Pronto declares ${s} burst pairs but carries ${(n.length-4)/2} word pairs`);let c=i*Kye,l=n.slice(4).map((e,t)=>{let n=Math.max(1,Math.round(e*c));return t%2==0?n:-n}),u=PE.safeParse(l);if(!u.success)throw new V(`invalid-timings`,`Pronto decoded to invalid timings: ${u.error.message}`);return{timings:u.data,carrierHz:Math.round(1e6/c)}}var Jye=8192,LE=32,RE=3,Yye=264,zE=NE*2;function Xye(e){let t=[],n=0,r=e=>{if(t.length+e>zE)throw new V(`tuya-malformed`,`decompressed code is larger than any IR train`)},i=()=>{let t=e[n++];if(t===void 0)throw new V(`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 V(`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 V(`tuya-malformed`,`back-reference is invalid`);t.push(n)}}return Uint8Array.from(t)}function Zye(e){let t=[],n=new Map,r=0,i=n=>{for(let i=r;i<n;i+=LE){let r=Math.min(i+LE,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+RE<=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<=Jye){let t=0;for(;a+t<e.length&&t<Yye&&e[r+t]===e[a+t];)t++;t>=RE&&(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 BE=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Qye=65535;function $ye(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+=BE[o>>18&63],t+=BE[o>>12&63],t+=n+1<e.length?BE[o>>6&63]:`=`,t+=n+2<e.length?BE[o&63]:`=`}return t}function ebe(e){let t=e.trim().replace(/=+$/,``);if(t.length===0||t.length%4==1)throw new V(`tuya-malformed`,`not a base64 string`);let n=[],r=0,i=0;for(let e of t){let t=BE.indexOf(e);if(t<0)throw new V(`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 VE(e){let t=new Uint8Array(e.length*2);return e.forEach((e,n)=>{let r=Math.abs(e);if(r===0||r>Qye)throw new V(`invalid-timings`,`timing ${n} does not fit 16 bits`);t[n*2]=r&255,t[n*2+1]=r>>8}),$ye(Zye(t))}function HE(e){let t=Xye(ebe(e));if(t.length===0||t.length%2!=0)throw new V(`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=PE.safeParse(n);if(!r.success)throw new V(`tuya-malformed`,r.error.message);return r.data}var UE=S([`tuya`]),WE=Math.ceil((zE+Math.ceil(zE/32))/3)*4+256,GE=x({format:UE,code:l().min(1).max(WE)}),KE={tuya:{encode:VE,decode:HE}},qE=i(`kind`,[x({kind:p(`raw`),timings:C(n().int()),settings:FE.optional()}),x({kind:p(`pronto`),code:l()}),x({kind:p(`native`),format:UE,code:l()})]);function JE(e){if(e.kind===`pronto`){let t=IE(e.code);return{timings:t.timings,settings:{carrierHz:t.carrierHz}}}if(e.kind===`native`)return{timings:KE[e.format].decode(e.code),settings:{}};let t=PE.safeParse(e.timings);if(!t.success)throw new V(`invalid-timings`,t.error.message);return{timings:t.data,settings:e.settings??{}}}var YE=`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(`.`),XE=[`source_select`];function ZE(e){return XE.includes(e)}var QE=`custom:`,tbe=/^[a-z0-9][a-z0-9_]{0,47}$/,nbe=new Set(YE);function $E(e){return nbe.has(e)}function eD(e){return tbe.test(e)}function tD(e){return`${QE}${e}`}function nD(e){if(!e.startsWith(`custom:`))return null;let t=e.slice(7);return eD(t)?t:null}function rD(e){return $E(e)||nD(e)!==null}var iD=l().refine(rD,{message:`a role is one of the known roles or custom:<key> (lowercase letters, digits, _)`}),aD=[`digits`,`sequence`,`ir`],rbe=S(aD),ibe=200,abe=16,obe=6,sbe=/^[a-z0-9][a-z0-9_-]{0,47}$/,cbe=RegExp(`^[0-9]{1,6}$`),oD={id:l().regex(sbe,{message:`a lowercase slug`}),name:l().trim().min(1).max(60)},sD=x({...oD,kind:p(`digits`),number:l().regex(cbe,{message:`up to 6 digits`})}),cD=x({...oD,kind:p(`sequence`),steps:C(iD).min(1).max(16)}),lD=x({...oD,kind:p(`ir`),transmitterId:n().int().nonnegative().optional(),payload:qE}),uD=i(`kind`,[sD,cD,lD]),lbe=500,ube=100,dD=3e3;function fD(e){switch(e.kind){case`sequence`:return e.steps;case`digits`:return Array.from(e.number,e=>`digit_${e}`);case`ir`:return[]}}function pD(e){try{return JE(e.payload),null}catch(e){if(e instanceof V)return e.message;throw e}}function dbe(e,t){return e.trim().toLowerCase()===t.trim().toLowerCase()}function mD(e,t){let n=t.trim();for(let t of e)if(t.kind===`digits`&&t.number===n)return t;return null}function fbe(e,t){let n=e.find(e=>dbe(e.name,t));if(n!==void 0)return n;let r=e.find(e=>e.id===t.trim());return r===void 0?mD(e,t):r}var hD=S([`off`,`on`,`idle`,`playing`,`paused`,`buffering`,`standby`]),gD=S([`off`,`all`,`one`]),pbe=x({type:l(),title:l(),artist:l().optional(),album:l().optional(),imageUrl:l().optional()}),_D=S([`reported`,`assumed`]),vD=S([`state`,`volumeLevel`,`isMuted`,`source`]),yD=x({state:hD,stateSource:_D.default(`reported`),assumedFields:C(vD).default([]),volumeLevel:n().min(0).max(100).nullable().meta(N(`percentage`)),isMuted:y().nullable(),muteReadback:y().optional(),source:l(),availableSources:C(l()),declaredSources:C(x({name:l(),kind:S(aD),number:l().optional()})).optional(),currentMedia:pbe.nullable(),position:n().int().nonnegative().nullable().meta(N(`duration-ms`)),duration:n().int().nonnegative().nullable().meta(N(`duration-ms`)),shuffle:y().nullable(),repeat:gD.nullable(),positionUpdatedAt:n().nullable().default(null),lastChangedAt:n()}),mbe=50,bD=x({deviceId:n().int().nonnegative(),steps:n().int().min(1).max(50).default(1)}),xD=x({deviceId:n().int().nonnegative()}),SD={name:`media-player`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.MediaPlayer],power:{kind:`methods`,field:`state`,offValues:[`off`,`standby`],on:`turnOn`,off:`turnOff`},methods:{turnOn:j(xD,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.turnOn`,label:F(`Turn on`,`Accendi`),phrase:F(`Turn on {device}`,`Accendi {device}`),icon:`power`}]}),turnOff:j(xD,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.turnOff`,label:F(`Turn off`,`Spegni`),phrase:F(`Turn off {device}`,`Spegni {device}`),icon:`power`}]}),volumeUp:j(bD,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.volumeUp`,label:F(`Volume up`,`Alza il volume`),phrase:F(`Raise the volume of {device}`,`Alza il volume di {device}`),icon:`volume-2`}]}),volumeDown:j(bD,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.volumeDown`,label:F(`Volume down`,`Abbassa il volume`),phrase:F(`Lower the volume of {device}`,`Abbassa il volume di {device}`),icon:`volume-2`}]}),channelUp:j(bD,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.channelUp`,label:F(`Channel up`,`Canale successivo`),phrase:F(`Go to the next channel on {device}`,`Passa al canale successivo su {device}`),icon:`skip-forward`}]}),channelDown:j(bD,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.channelDown`,label:F(`Channel down`,`Canale precedente`),phrase:F(`Go to the previous channel on {device}`,`Torna al canale precedente su {device}`),icon:`skip-back`}]}),play:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.play`,effect:{field:`state`,value:`playing`},label:F(`Play`,`Riproduci`),phrase:F(`Play on {device}`,`Avvia la riproduzione su {device}`),icon:`play`}]}),pause:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.pause`,effect:{field:`state`,value:`paused`},label:F(`Pause media`,`Metti in pausa`),phrase:F(`Pause {device}`,`Metti in pausa {device}`),icon:`pause`}]}),stop:j(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.stop`,label:F(`Stop media`,`Ferma la riproduzione`),phrase:F(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),next:j(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.next`,label:F(`Next track`,`Brano successivo`),phrase:F(`Skip to the next track on {device}`,`Passa al brano successivo su {device}`),icon:`skip-forward`}]}),previous:j(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.previous`,label:F(`Previous track`,`Brano precedente`),phrase:F(`Go back to the previous track on {device}`,`Torna al brano precedente su {device}`),icon:`skip-back`}]}),setVolume:j(x({deviceId:n().int().nonnegative(),volumeLevel:n().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.volume`,effect:{field:`volumeLevel`,fromArg:`volumeLevel`},label:F(`Set volume`,`Imposta il volume`),phrase:F(`Set the volume of {device} to {volumeLevel}`,`Imposta il volume di {device} al {volumeLevel}`),icon:`volume-2`,openArgs:[{key:`volumeLevel`,label:F(`Volume`,`Volume`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setMute:j(x({deviceId:n().int().nonnegative(),muted:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.mute`,effect:{field:`isMuted`,value:!0},label:F(`Mute`,`Silenzia`),phrase:F(`Mute {device}`,`Silenzia {device}`),icon:`volume-x`,args:{muted:!0}},{id:`media.unmute`,effect:{field:`isMuted`,value:!1},label:F(`Unmute`,`Riattiva l’audio`),phrase:F(`Unmute {device}`,`Riattiva l’audio di {device}`),icon:`volume-2`,args:{muted:!1}}]}),setShuffle:j(x({deviceId:n().int().nonnegative(),shuffle:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.shuffleOn`,effect:{field:`shuffle`,value:!0},label:F(`Shuffle on`,`Riproduzione casuale attiva`),phrase:F(`Turn on shuffle on {device}`,`Attiva la riproduzione casuale su {device}`),icon:`shuffle`,args:{shuffle:!0}},{id:`media.shuffleOff`,effect:{field:`shuffle`,value:!1},label:F(`Shuffle off`,`Riproduzione casuale spenta`),phrase:F(`Turn off shuffle on {device}`,`Disattiva la riproduzione casuale su {device}`),icon:`shuffle`,args:{shuffle:!1}}]}),setRepeat:j(x({deviceId:n().int().nonnegative(),repeat:gD}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.repeat`,effect:{field:`repeat`,fromArg:`repeat`},label:F(`Set repeat`,`Imposta la ripetizione`),phrase:F(`Set repeat on {device} to {repeat}`,`Imposta la ripetizione di {device} su {repeat}`),icon:`repeat`,openArgs:[{key:`repeat`,label:F(`Repeat`,`Ripetizione`),offer:{kind:`enum`,values:[{value:`off`,label:F(`Off`,`Disattivata`)},{value:`all`,label:F(`All`,`Tutti i brani`)},{value:`one`,label:F(`One track`,`Un brano`)}]}}]}]}),selectSource:j(x({deviceId:n().int().nonnegative(),source:l().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.source`,effect:{field:`source`,fromArg:`source`},label:F(`Select source`,`Scegli la sorgente`),phrase:F(`Switch {device} to {source}`,`Passa {device} alla sorgente {source}`),icon:`cast`,openArgs:[{key:`source`,label:F(`Source`,`Sorgente`),offer:{kind:`dynamic`,from:`status`,field:`availableSources`}}]}]}),seek:j(x({deviceId:n().int().nonnegative(),position:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.seek`,label:F(`Seek`,`Vai al punto`),phrase:F(`Move {device} to {position}`,`Porta {device} al punto {position}`),icon:`fast-forward`,openArgs:[{key:`position`,label:F(`Position`,`Posizione`),offer:{kind:`number`,min:0,step:1e3,unit:`ms`}}]}]}),playMedia:j(x({deviceId:n().int().nonnegative(),mediaId:l().min(1),mediaType:l().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.playMedia`,label:F(`Play media`,`Riproduci un contenuto`),phrase:F(`Play {mediaId} on {device}`,`Riproduci {mediaId} su {device}`),icon:`music`,openArgs:[{key:`mediaId`,label:F(`Media`,`Contenuto`),offer:{kind:`text`}},{key:`mediaType`,label:F(`Media type`,`Tipo di contenuto`),offer:{kind:`text`}}]}]})},status:{schema:yD,kind:`push`},runtimeState:yD,durability:`session`,history:{fields:{volumeLevel:{kind:`gauge`,unit:`%`,deadband:1},isMuted:{kind:`boolean`}}},vocabulary:{noun:F(`Media player`,`Lettore multimediale`),order:2060,state:[{kind:`enum`,field:`state`,label:F(`Playback`,`Riproduzione`),values:[{value:`off`,label:F(`Off`,`Spento`),phrase:F(`When {device} turns off`,`Quando {device} si spegne`)},{value:`on`,label:F(`On`,`Acceso`),phrase:F(`When {device} turns on`,`Quando {device} si accende`)},{value:`idle`,label:F(`Idle`,`Inattivo`)},{value:`playing`,label:F(`Playing`,`In riproduzione`),phrase:F(`When {device} starts playing`,`Quando {device} inizia a riprodurre`)},{value:`paused`,label:F(`Paused`,`In pausa`),phrase:F(`When {device} is paused`,`Quando {device} va in pausa`)},{value:`buffering`,label:F(`Buffering`,`In caricamento`)},{value:`standby`,label:F(`Standby`,`In standby`)}],icon:`music`},{kind:`numeric`,field:`volumeLevel`,quantity:F(`the volume`,`il volume`),label:F(`Volume`,`Volume`),unit:`%`,icon:`volume-2`},{kind:`boolean`,field:`isMuted`,label:F(`Muted`,`Silenziato`),whenTrue:F(`When {device} is muted`,`Quando {device} viene silenziato`),whenFalse:F(`When {device} is unmuted`,`Quando l’audio di {device} torna attivo`),icon:`volume-x`},{kind:`value`,field:`source`,label:F(`Source`,`Sorgente`),offer:{kind:`dynamic`,from:`status`,field:`availableSources`},icon:`cast`}]}},CD={battery:{version:1,targets:[{id:`level`,cardinality:`scalar`,deviceTypes:[E.Camera,E.Sensor,E.Button,E.Switch,E.PetFeeder,E.Container,E.Climate,E.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:[E.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:[E.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:[E.Camera,E.Light,E.Siren,E.Switch,E.Sensor,E.Climate,E.Button,E.EventEmitter,E.Update,E.Generic,E.Notifier,E.Script,E.Automation,E.Lock,E.Cover,E.Valve,E.Humidifier,E.WaterHeater,E.Fan,E.MediaPlayer,E.AlarmPanel,E.Control,E.Presence,E.Weather,E.WeatherStation,E.Vacuum,E.LawnMower,E.Container,E.Image,E.PetFeeder,E.PetFountain,E.Dishwasher,E.Washer,E.Dryer,E.Gateway,E.HeatPump,E.EnergySystem,E.Workload],apply:`add`,vocabularyCap:`consumables`,sources:[],sourceReport:{status:`assignment-status`},advancedExpression:!0,path:`items`,keyField:`key`,labelField:`label`,nativeItems:`read-only`,fields:[{path:`level`,valueKind:`number`,nullable:!0,sources:[{kind:`numeric`,transformKinds:[`identity`,`linear`],transforms:[{kind:`identity`},{kind:`linear`,defaultScale:1,defaultOffset:0,clampMin:0,clampMax:100}]}]},{path:`remaining.value`,valueKind:`number`,nullable:!0,sources:[{kind:`numeric`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],literals:[{path:`remaining.kind`,values:[`duration`,`count`]}]},{path:`status`,valueKind:`enum`,nullable:!0,enumValues:[`ok`,`low`,`empty`,`full`,`replace`],sources:[{kind:`enum`,transformKinds:[`enum-map`],transforms:[{kind:`enum-map`,outputValues:[`ok`,`low`,`empty`,`full`,`replace`],unmapped:null}]}]}],traits:[{path:`kind`,values:[`wear`,`supply`,`waste`],defaultValue:`wear`},{path:`form`,values:[`part`,`tank`,`product`,`bin`],defaultValue:`part`}],companions:[{kind:`clock`,path:`lastChangedAt`,when:`add`},{kind:`clock`,path:`lastFetchedAt`,when:`add`}]}]},doorbell:{version:1,targets:[{id:`pressed`,cardinality:`event`,deviceTypes:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.Fan],apply:`add`,readMethod:`getPresets`,writeMethod:`setPresets`,vocabularyCap:`fan-presets`,sources:[],sourceReport:{status:`assignment-status`},advancedExpression:!1}]},"heat-pump-status":{version:1,targets:[{id:`electrical-power`,cardinality:`scalar`,deviceTypes:[E.HeatPump],apply:`replace`,vocabularyCap:`heat-pump-status`,sources:[{kind:`numeric`,requiredUnit:`W`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`power.electricalW`,valueKind:`number`,nullable:!0},{id:`electrical-energy`,cardinality:`scalar`,deviceTypes:[E.HeatPump],apply:`replace`,vocabularyCap:`heat-pump-status`,sources:[{kind:`numeric`,requiredUnit:`kWh`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`energy.electricalKwh`,valueKind:`number`,nullable:!0}],overridable:[{path:`power.electricalW`,by:`electrical-power`},{path:`energy.electricalKwh`,by:`electrical-energy`}]},"lock-control":{version:1,targets:[{id:`door-contact`,cardinality:`scalar`,deviceTypes:[E.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:[E.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:[E.Switch,E.Light,E.Fan,E.Climate,E.Humidifier,E.WaterHeater,E.MediaPlayer,E.Washer,E.Dryer,E.Dishwasher,E.Vacuum,E.LawnMower,E.PetFeeder,E.Workload],apply:`add`,vocabularyCap:`power-meter`,vocabularyStateField:`power`,sources:[{kind:`numeric`,requiredUnit:`W`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!0,path:`power`,valueKind:`number`,nullable:!1,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`always`}]},{id:`energy`,cardinality:`scalar`,deviceTypes:[E.Switch,E.Light,E.Fan,E.Climate,E.Humidifier,E.WaterHeater,E.MediaPlayer,E.Washer,E.Dryer,E.Dishwasher,E.Vacuum,E.LawnMower,E.PetFeeder,E.Workload],apply:`add`,vocabularyCap:`power-meter`,vocabularyStateField:`energy`,sources:[{kind:`numeric`,requiredUnit:`kWh`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!0,path:`energy`,valueKind:`number`,nullable:!1,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`always`}]},{id:`voltage`,cardinality:`scalar`,deviceTypes:[E.Switch,E.Light,E.Fan,E.Climate,E.Humidifier,E.WaterHeater,E.MediaPlayer,E.Washer,E.Dryer,E.Dishwasher,E.Vacuum,E.LawnMower,E.PetFeeder,E.Workload],apply:`add`,vocabularyCap:`power-meter`,vocabularyStateField:`voltage`,sources:[{kind:`numeric`,requiredUnit:`V`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!0,path:`voltage`,valueKind:`number`,nullable:!1,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`always`}]},{id:`current`,cardinality:`scalar`,deviceTypes:[E.Switch,E.Light,E.Fan,E.Climate,E.Humidifier,E.WaterHeater,E.MediaPlayer,E.Washer,E.Dryer,E.Dishwasher,E.Vacuum,E.LawnMower,E.PetFeeder,E.Workload],apply:`add`,vocabularyCap:`power-meter`,vocabularyStateField:`current`,sources:[{kind:`numeric`,requiredUnit:`A`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!0,path:`current`,valueKind:`number`,nullable:!1,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`always`}]}]},"power-source":{version:1,targets:[{id:`switch`,cardinality:`scalar`,deviceTypes:[E.Gateway,E.Camera,E.Sensor,E.MediaPlayer,E.Vacuum,E.Generic,E.Washer,E.Dryer,E.Dishwasher,E.PetFountain,E.Fan,E.Humidifier,E.Climate,E.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:[E.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:[E.Washer,E.Dryer,E.Dishwasher,E.Vacuum,E.LawnMower,E.MediaPlayer,E.WaterHeater,E.Humidifier,E.Fan,E.Climate,E.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:{[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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`}]}},wD={"ambient-light-sensor":{illuminance:`lx`},battery:{level:`%`,voltage:`V`,temperatureC:`°C`},"humidity-sensor":{humidity:`%`},"power-meter":{power:`W`,deliveredPower:`W`,energy:`kWh`,voltage:`V`,current:`A`},"temperature-sensor":{temperature:`°C`}};function H(e,t,n){return{code:e,path:t,message:n}}function TD(...e){return{problems:e,fields:[],features:[],events:[]}}function ED(e){let t=e.item===void 0?`fields`:`items.${e.item.key}.fields`;return`features[${e.featureIndex}].${t}.${e.path}`}var DD={kind:`fixed`,result:[`number`]},OD={kind:`fixed`,result:[`boolean`]},kD=Object.freeze({min:DD,max:DD,abs:DD,floor:DD,ceil:DD,sqrt:DD,round:DD,pow:DD,clamp:DD,avg:DD,sum:DD,age:DD,convert:DD,coalesce:{kind:`coalesce`},any:OD,all:OD,within:OD,latest:{kind:`fixed`,result:[`number`,`null`]},number:{kind:`fixed`,result:[`number`,`null`]},rose:{kind:`fixed`,result:[`number`,`null`]},count:DD,dwell:{kind:`fixed`,result:[`boolean`,`null`]},latchedAt:{kind:`fixed`,result:[`number`,`null`]},schmitt:{kind:`fixed`,result:[`boolean`,`null`]}}),AD=class extends Error{};function jD(e){return e===null?`null`:typeof e==`number`?`number`:typeof e==`string`?`string`:`boolean`}function MD(e){return new Set([e])}function ND(...e){return new Set(e.flatMap(e=>[...e]))}function hbe(e){return new Set([...e].filter(e=>e!==`null`))}function gbe(e,t,n){if(e===`+`){let e=[...t,...n];return e.every(e=>e===`string`)?MD(`string`):e.every(e=>e===`number`)?MD(`number`):new Set([`number`,`string`])}return MD(e===`-`||e===`*`||e===`/`||e===`%`?`number`:`boolean`)}function _be(e){return e.minArgs===e.maxArgs?`exactly ${e.minArgs}`:e.maxArgs===1/0?`at least ${e.minArgs}`:`${e.minArgs}–${e.maxArgs}`}function vbe(e,t){let n=ms[e];if(n!==void 0&&(t.length<n.minArgs||t.length>n.maxArgs))throw new AD(`${e}: wrong number of arguments (${t.length}); expected ${_be(n)}`);let r=kD[e];if(r===void 0)throw new AD(`no result-kind rule for builtin '${e}'`);if(r.kind===`fixed`)return new Set(r.result);let i=ND(...t.map(hbe));return t.every(e=>e.has(`null`))?ND(i,MD(`null`)):i}function PD(e,t){switch(e.kind){case`literal`:return MD(jD(e.value));case`identifier`:{if(e.name===`now`)return MD(`number`);let n=t.get(e.name);if(n===void 0)throw new AD(`unbound identifier '${e.name}'`);return n}case`unary`:return MD(e.op===`!`?`boolean`:`number`);case`binary`:return gbe(e.op,PD(e.left,t),PD(e.right,t));case`logical`:return ND(PD(e.left,t),PD(e.right,t));case`conditional`:return ND(PD(e.consequent,t),PD(e.alternate,t));case`call`:return vbe(e.callee,e.args.map(e=>PD(e,t)))}}function FD(e,t){switch(e.kind){case`literal`:case`identifier`:return!1;case`unary`:return FD(e.operand,t);case`binary`:case`logical`:return FD(e.left,t)||FD(e.right,t);case`conditional`:return FD(e.test,t)||FD(e.consequent,t)||FD(e.alternate,t);case`call`:return e.callee===t||e.args.some(e=>FD(e,t))}}function ID(e,t){let n=Ts(e);return n.ok&&FD(n.parsed.ast,t)}function LD(e){let t=Ts(e.expr);if(!t.ok)return{ok:!1,error:t.error};try{return{ok:!0,kinds:PD(t.parsed.ast,e.bindingKinds)}}catch(e){if(e instanceof AD)return{ok:!1,error:e.message};throw e}}function ybe(e){return e.publish===`value`&&e.empty===`null`?{ok:!0,kinds:new Set([`number`,`null`])}:{ok:!0,kinds:new Set([`number`])}}function bbe(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 RD(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=zT(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 zD(e,t,n){return H(`kind-mismatch`,n,`\`${e}.${t}\` is a union — it is read as a source, never written`)}function BD(e){return e.kind===`union`?null:e.kind===`enum`?`string`:e.kind}function VD(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=zT(a,e.fieldPath),s=BD(t);return o?.kind!==`union`||s===null||!n.has(s)?n:new Set(n.has(`null`)?[s,`null`]:[s])}function HD(e,t){if(e.kind===`from`)return RD(e,t);if(e.kind===`code`)return{ok:!1,code:`reserved-variant`,message:`code fields arrive in slice 4`};if(e.kind===`aggregate`)return bbe(e);if(e.kind===`series`)return ybe(e);let n=new Map;for(let[r,i]of Object.entries(e.bindings)){if(i.kind===`literal`){n.set(r,new Set([jD(i.value)]));continue}let e=RD(i,t);if(!e.ok)return{...e,message:`binding \`${r}\`: ${e.message}`};n.set(r,e.kinds)}let r=LD({expr:e.expr,bindingKinds:n});return r.ok?{ok:!0,kinds:r.kinds}:{ok:!1,code:`expression-invalid`,message:r.error}}function UD(e,t,n,r){let i=BD(t);if(i===null)return[zD(e,t.path,r)];let a=[...n].filter(e=>e!==`null`&&e!==i),o=[];return a.length>0&&o.push(H(`kind-mismatch`,r,`\`${e}.${t.path}\` is a ${t.kind}; this source can produce ${a.join(` or `)}`)),n.has(`null`)&&!t.nullable&&o.push(H(`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 xbe(e){if(e.kind!==`expression`)return null;let t=Ts(e.expr);if(!t.ok)return null;let n=t.parsed.ast;return n.kind===`literal`&&typeof n.value==`string`?n.value:null}function WD(e,t,n,r){if(t.kind!==`enum`||t.enumValues===void 0)return null;let i=xbe(n);if(i===null||t.enumValues.includes(i))return null;let a=t.enumValues.map(e=>`\`${e}\``).join(`, `);return H(`kind-mismatch`,r,`\`${e}.${t.path}\` accepts only ${a}; this source is the literal \`${i}\``)}function GD(e){if(e.kind!==`expression`)return`derived`;if(ID(e.expr,`count`))return`accumulator`;if(Nl(e).length>0)return`derived`;let t=Ts(e.expr);return t.ok&&t.parsed.identifiers.has(`now`)?`clock`:`constant`}function KD(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:H(`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 qD={resettable:!1};function Sbe(e){return new Set([e.keyField,...e.labelField===void 0?[]:[e.labelField],...Object.keys(qD)])}function Cbe(e,t,n){let r=zT(e.itemSchema,t);return r===null||!r.required?!1:HT(e.itemSchema,t).every(e=>n.some(t=>t.startsWith(`${e}.`)))}function wbe({capName:e,itemArray:t,reserved:n},r,i){let a=Object.keys(r.fields);return Yg(t.itemSchema).flatMap(o=>{if(n.has(o.path)||o.path in r.fields||!Cbe(t,o.path,a))return[];let s=zT(t.itemSchema,o.path);return s===null||s.nullable?[]:[H(`missing-field`,`${i}.fields.${o.path}`,`\`${e}.${t.path}[].${o.path}\` is required and has no source`)]})}function Tbe(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 TD(H(`item-field-reserved`,u,`\`${n}.${r.path}[].${c}\` is set by the composer itself — it takes no source`));let d=zT(r.itemSchema,c);if(d===null)return TD(H(`unknown-field`,u,`a \`${n}\` item has no field \`${c}\``));if(d.kind===`union`)return TD(zD(n,c,u));let f=HD(l,a);if(!f.ok)return TD(H(f.code,u,f.message));let p=GD(l),m=KD(d,p,e.mode,n,u);if(!m.ok)return TD(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:[...Nl(l)]},g=WD(n,d,l,u);return{problems:[...UD(n,d,VD(l,d,f.kinds,a),u),...g===null?[]:[g]],fields:[h],features:[],events:[]}}function JD(e,t,n,r,i=`new`){let a=`features[${n}].items`,o=e.status?.itemArray;if(o===void 0)return TD(H(`not-item-array`,a,`\`${e.name}\` has no item array — it takes no \`items\``));if(o.path!==`items`)return TD(H(`not-item-array`,a,`\`${e.name}\`'s item array is at \`${o.path}\`, not \`${gl}\` — not composable yet`));let s={capName:e.name,itemArray:o,reserved:Sbe(o),featureIndex:n,lookupCap:r,mode:i},c=Object.entries(t.items??{}).flatMap(([e,t])=>[{problems:wbe(s,t,`${a}.${e}`),fields:[],features:[],events:[]},...Object.entries(t.fields).map(([n,r])=>Tbe(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 YD=`deviceId`;function XD(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 ZD(e){let t=e.features.flatMap((e,t)=>e.kind===`fields`&&Sl(e)?XD(e,t).map(e=>e.command.source):[]);return[...new Map(t.map(e=>[Ol(e),e])).values()]}function Ebe(e,t){return e.name===`switch`&&t===`toggle`}function QD(e){return Object.entries(e.methods).filter(([t,n])=>n.systemOnly!==!0&&e.composedMethods?.[t]===void 0&&!Ebe(e,t)).map(([e])=>e)}function Dbe(){return Object.fromEntries(QD(SD).map(e=>[e,{kind:`extension`,target:`remote`}]))}var $D={all:new Set,required:new Set};function eO(e,t){let n=e.methods[t]?.input;if(n===void 0)return null;let r=Jg(n);if(!(r instanceof ce))return null;let i=Object.entries(r.shape).filter(([e])=>e!==YD);return{all:new Set(i.map(([e])=>e)),required:new Set(i.flatMap(([e,t])=>t instanceof ie&&!t.safeParse(void 0).success?[e]:[]))}}function tO(e){return typeof e==`object`?dl(e)?[e.$input]:Object.values(e).flatMap(tO):[]}function nO(e){return[...e].map(e=>`\`${e}\``).join(`, `)}function Obe(e,t){let{command:n,at:r}=e,i=t(n.cap);if(i===null)return{def:null,problems:[H(`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:[H(`command-source-unknown`,`${r}.method`,`\`${n.cap}\` has no method \`${n.method}\` to forward to`)]}:a.kind===`mutation`?{def:i,problems:[]}:{def:null,problems:[H(`command-source-unknown`,`${r}.method`,`\`${n.cap}.${n.method}\` is a query — a command calls a mutation of the source`)]}}function kbe(e,t,n,r){let{at:i,command:a}=e,o=`${a.cap}.${a.method}`,s=[];if(`deviceId`in r&&s.push(H(`command-input-unknown`,`${i}.args.${YD}`,`\`${YD}\` 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(H(`command-input-unknown`,`${i}.args.${e}`,`\`${o}\` has no input field \`${e}\` (it takes ${nO(n.all)})`));let e=[...n.required].filter(e=>!(e in r));e.length>0&&s.push(H(`command-input-missing`,`${i}.args`,`\`${o}\` needs ${nO(e)}, which \`args\` does not provide`))}let c=e.itemKey===void 0?t:$D;if(c!==null)for(let t of Object.values(r).flatMap(tO))c.all.has(t)||s.push(H(`command-input-unknown`,`${i}.args`,c===$D?`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 ${nO(c.all)})`));return s}function Abe(e,t,n){let{at:r,command:i}=e,a=`${i.cap}.${i.method}`,o=e.itemKey===void 0?t:$D;if(o===null||n===null)return[];let s=[];for(let t of[...o.all].filter(e=>!n.all.has(e)))s.push(H(`command-input-unknown`,`${r}.args`,`\`${e.method}\` takes \`${t}\`, which \`${a}\` does not (it takes ${nO(n.all)}) — add \`args\` to map it`));let c=[...n.required].filter(e=>!o.all.has(e));return c.length>0&&s.push(H(`command-input-missing`,`${r}.args`,`\`${a}\` needs ${nO(c)}, which \`${e.method}\` does not take — add \`args\` to provide it`)),s}function rO(e,t,n){let r=Obe(t,n);if(r.def===null)return r.problems;let i=eO(e,t.method),a=eO(r.def,t.command.method),o=t.command.args;return o===void 0?Abe(t,i,a):kbe(t,i,a,o)}function iO(e,t,n){let r=new Set(QD(e));return Object.keys(t.commands??{}).flatMap(t=>{if(r.has(t))return[];let i=e.composedMethods?.[t]!==void 0;return[H(`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 aO(e,t){return e.features.flatMap((e,n)=>e.kind!==`fields`||!Sl(e)?[]:XD(e,n).flatMap(e=>{let n=Ol(e.command.source),r=t.get(n),i=`${e.at}.source`;return r===void 0||r.kind===`unreadable`?[H(`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`?[H(`source-missing`,i,`source \`${n}\` does not exist`)]:r.caps.has(e.command.cap)?[]:[H(`source-capability-missing`,i,`source \`${n}\` (device ${r.deviceId}) has no \`${e.command.cap}\``)]}))}var oO={fieldPath:`lastFetchedAt`,expr:`now`},sO={fieldPath:`lastChangedAt`,expr:`now`};function cO(e){let{alsoFrom:t,...n}=e;return{...n,family:`numeric`,deviceType:E.Sensor,memberDeviceType:E.Sensor,memberDeviceTypes:[E.Sensor,...t?.deviceTypes??[]],activeWhen:void 0,commandCaps:[],baseUnit:fa(e.quantity),aggregates:Sc,accept:[{cap:e.outputCap,fieldPath:e.outputField},...t===void 0?[]:[t.accept]]}}var lO=[E.Climate];function uO(e){return{...e,family:`binary`,deviceType:E.Sensor,memberDeviceType:E.Sensor,memberDeviceTypes:[E.Sensor],activeWhen:void 0,commandCaps:[],quantity:`none`,baseUnit:void 0,aggregates:Cc,empty:`offline`}}var dO=[cO({id:`temperature`,summary:`Mean, median, min, max or sum of temperatures. Offline and unknown members are left out, never read as 0 °C.`,role:O.TemperatureSensor,outputCap:`temperature-sensor`,outputField:`temperature`,quantity:`temperature`,defaultAggregate:`mean`,empty:`null`,companions:[oO],alsoFrom:{deviceTypes:lO,accept:{cap:`climate-control`,fieldPath:`currentTemp`}}}),cO({id:`humidity`,summary:`Humidity in percent. Offline and unknown members are left out, never read as 0 %.`,role:O.HumiditySensor,outputCap:`humidity-sensor`,outputField:`humidity`,quantity:`humidity`,defaultAggregate:`mean`,empty:`null`,companions:[oO],alsoFrom:{deviceTypes:lO,accept:{cap:`climate-control`,fieldPath:`currentHumidity`}}}),cO({id:`pressure`,summary:`Pressure in hectopascals. Offline and unknown members are left out, never read as 0 hPa.`,role:O.PressureSensor,outputCap:`pressure-sensor`,outputField:`pressure`,quantity:`pressure`,defaultAggregate:`mean`,empty:`null`,companions:[oO]}),cO({id:`illuminance`,summary:`Illuminance in lux. Offline and unknown members are left out, never read as 0 lx.`,role:O.AmbientLightSensor,outputCap:`ambient-light-sensor`,outputField:`illuminance`,quantity:`illuminance`,defaultAggregate:`mean`,empty:`null`,companions:[oO]}),cO({id:`power`,summary:`Power in watts, summed by default. Nobody reporting omits the key rather than writing 0 W.`,role:O.PowerSensor,outputCap:`power-meter`,outputField:`power`,quantity:`power`,defaultAggregate:`sum`,empty:`omit`,companions:[oO]}),cO({id:`energy`,summary:`Energy in kilowatt-hours, summed by default. Nobody reporting omits the key rather than writing 0 kWh.`,role:O.EnergySensor,outputCap:`power-meter`,outputField:`energy`,quantity:`energy`,defaultAggregate:`sum`,empty:`omit`,companions:[oO]}),cO({id:`battery`,summary:`Battery charge in percent. Offline and unknown members are left out, never read as 0 %.`,role:O.BatterySensor,outputCap:`battery`,outputField:`level`,quantity:`percentage`,defaultAggregate:`mean`,empty:`null`,companions:[{fieldPath:`charging`,expr:`"unknown"`},{fieldPath:`sleeping`,expr:`false`},{fieldPath:`lastUpdated`,expr:`now`}]}),cO({id:`numeric`,summary:`A numeric reading in the members’ shared quantity. Mixed quantities are refused. Nobody reporting publishes null, not 0.`,role:O.NumericSensor,outputCap:`numeric-sensor`,outputField:`value`,quantity:`device`,defaultAggregate:`mean`,empty:`null`,companions:[oO]}),uO({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:O.MotionSensor,outputCap:`motion`,outputField:`detected`,defaultAggregate:`any`,accept:[{cap:`motion`,fieldPath:`detected`}],companions:[{fieldPath:`lastDetectedAt`,expr:`null`},{fieldPath:`autoClearAfterMs`,expr:`null`}]}),uO({id:`contact`,summary:`Any or all open contacts. Offline and unknown members are left out, never read as closed.`,role:O.ContactSensor,outputCap:`contact`,outputField:`entryOpen`,defaultAggregate:`any`,accept:[{cap:`contact`,fieldPath:`entryOpen`}],companions:[sO]}),uO({id:`leak`,summary:`Any or all leak detections. Offline and unknown members are left out, never read as dry.`,role:O.LeakSensor,outputCap:`flood`,outputField:`flooded`,defaultAggregate:`any`,accept:[{cap:`flood`,fieldPath:`flooded`}],companions:[sO]}),uO({id:`smoke`,summary:`Any or all smoke detections. Offline and unknown members are left out, never read as clear.`,role:O.SmokeSensor,outputCap:`smoke`,outputField:`detected`,defaultAggregate:`any`,accept:[{cap:`smoke`,fieldPath:`detected`}],companions:[sO]}),uO({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:O.BinarySensor,outputCap:`binary`,outputField:`on`,defaultAggregate:`any`,accept:[{cap:`motion`,fieldPath:`detected`},{cap:`binary`,fieldPath:`on`}],companions:[sO]}),uO({id:`binary`,summary:`Any or all generic binary sensors. Offline and unknown members are left out, never read as off.`,role:O.BinarySensor,outputCap:`binary`,outputField:`on`,defaultAggregate:`any`,accept:[{cap:`binary`,fieldPath:`on`}],companions:[sO]}),fO({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:E.Switch,outputCap:`switch`,outputField:`on`,member:{cap:`switch`,fieldPath:`on`},commandCaps:[`switch`]}),fO({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:E.Light,outputCap:`switch`,outputField:`on`,member:{cap:`switch`,fieldPath:`on`},commandCaps:[`switch`,`brightness`,`color`]}),fO({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:E.Fan,outputCap:`switch`,outputField:`on`,member:{cap:`switch`,fieldPath:`on`},commandCaps:[`switch`,`fan-control`]}),fO({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:E.Cover,outputCap:`group-active`,outputField:`active`,member:{cap:`cover`,fieldPath:`state`},activeWhen:[`open`,`opening`,`stopped`],commandCaps:[`cover`]}),fO({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:E.Valve,outputCap:`group-active`,outputField:`active`,member:{cap:`valve`,fieldPath:`state`},activeWhen:[`open`,`opening`,`stopped`],commandCaps:[`valve`]}),fO({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:E.Lock,outputCap:`group-active`,outputField:`active`,member:{cap:`lock-control`,fieldPath:`state`},activeWhen:[`locked`],commandCaps:[`lock-control`]}),fO({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:E.MediaPlayer,outputCap:`group-active`,outputField:`active`,member:{cap:`media-player`,fieldPath:`state`},activeWhen:[`playing`,`buffering`],commandCaps:[`media-player`]}),fO({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:E.Climate,memberDeviceTypes:[E.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 fO(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:Cc,defaultAggregate:`any`,empty:`offline`,accept:[e.member],companions:[sO]}}var jbe=new Map(dO.map(e=>[e.id,e]));function pO(e){return jbe.get(e)??null}var mO={"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`},temperatureC:{kind:`gauge`,unit:`°C`}},binary:{on:{kind:`boolean`}},brightness:{level:{kind:`gauge`,unit:`%`,minIntervalMs:0}},"carbon-monoxide":{detected:{kind:`boolean`}},"climate-control":{currentTemp:{group:`temperature`,kind:`gauge`,unit:`°C`,deadband:.1},currentHumidity:{kind:`gauge`,unit:`%`,deadband:.5},target:{group:`temperature`,kind:`gauge`,unit:`°C`,minIntervalMs:0},targetHigh:{group:`target-range`,kind:`gauge`,unit:`°C`,minIntervalMs:0},targetLow:{group:`target-range`,kind:`gauge`,unit:`°C`,minIntervalMs:0}},connectivity:{connected:{kind:`boolean`}},contact:{entryOpen:{kind:`boolean`}},cover:{position:{kind:`gauge`,unit:`%`,minIntervalMs:0}},"device-status":{online:{kind:`boolean`}},dishwasher:{progress:{kind:`gauge`,unit:`%`,deadband:2},state:{kind:`enum`,values:[`idle`,`running`,`paused`,`finished`,`error`,`unavailable`]},operationState:{kind:`enum`,values:[`Inactive`,`Ready`,`DelayedStart`,`Run`,`Pause`,`ActionRequired`,`Finished`,`Error`,`Aborting`]},remaining:{kind:`gauge`,unit:`s`,minIntervalMs:6e4},doorOpen:{kind:`boolean`},powerOn:{kind:`boolean`}},"do-not-disturb":{enabled:{kind:`boolean`}},"energy-system":{"solar.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Solar power`},"solar.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`Solar energy`},"grid.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Grid power`},"grid.importKwh":{kind:`counter`,unit:`kWh`,displayName:`Grid import`},"grid.exportKwh":{kind:`counter`,unit:`kWh`,displayName:`Grid export`},"house.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`House power`},"house.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`House energy`},"heatPump.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Heat pump power`},"heatPump.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`Heat pump energy`},"storage.stateOfChargePct":{kind:`gauge`,unit:`%`,deadband:1,displayName:`Storage charge`},"storage.storedKwh":{kind:`gauge`,unit:`kWh`,deadband:.05,displayName:`Stored energy`},"storage.capacityKwh":{kind:`gauge`,unit:`kWh`,deadband:.1,displayName:`Storage capacity`},"storage.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Storage power`},"storage.chargedKwh":{kind:`counter`,unit:`kWh`,displayName:`Storage charged`},"storage.dischargedKwh":{kind:`counter`,unit:`kWh`,displayName:`Storage discharged`},"storage.healthPct":{kind:`gauge`,unit:`%`,deadband:1,displayName:`Storage health`}},"enum-sensor":{value:{kind:`enum`,skipWhenSet:`timestamp`}},"fan-control":{speed:{kind:`gauge`,unit:`%`,minIntervalMs:0},oscillating:{kind:`boolean`}},flood:{flooded:{kind:`boolean`}},gas:{detected:{kind:`boolean`}},"heat-pump-status":{"power.thermalW":{group:`power`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Thermal power`},"power.electricalW":{group:`power`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Electrical power`},"power.compressorPct":{kind:`gauge`,unit:`%`,deadband:2,displayName:`Compressor`},"temperatures.supply":{group:`loop`,kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Supply`},"temperatures.return":{group:`loop`,kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Return`},"temperatures.outdoor":{kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Outdoor`},"energy.thermalKwh":{kind:`counter`,unit:`kWh`,displayName:`Thermal energy`},"energy.electricalKwh":{kind:`counter`,unit:`kWh`,displayName:`Electrical energy`}},"heating-valve":{position:{kind:`gauge`,unit:`%`,deadband:1}},humidifier:{currentHumidity:{kind:`gauge`,unit:`%`,deadband:.5},on:{kind:`boolean`}},"humidity-sensor":{humidity:{kind:`gauge`,unit:`%`,deadband:.5}},"lawn-mower-control":{batteryLevel:{kind:`gauge`,unit:`%`,deadband:2}},"lock-control":{state:{kind:`enum`,values:[`locked`,`unlocked`,`locking`,`unlocking`,`jammed`,`door-open`]}},"media-player":{volumeLevel:{kind:`gauge`,unit:`%`,deadband:1},isMuted:{kind:`boolean`}},meter:{value:{kind:`counter`,deadband:.001,minIntervalMs:6e4}},motion:{detected:{kind:`boolean`,excludeDeviceTypes:[E.Camera]}},"network-link":{signal:{kind:`gauge`,unit:`%`,deadband:3,minIntervalMs:6e4},rssi:{kind:`gauge`,unit:`dBm`,deadband:2,minIntervalMs:6e4}},"numeric-sensor":{value:{kind:`gauge`,minIntervalMs:3e4}},"pet-feeder":{feeding:{kind:`boolean`},eating:{kind:`boolean`},foodLevel:{kind:`gauge`},bowlFood:{kind:`gauge`},food1:{kind:`gauge`},food2:{kind:`gauge`},batteryPower:{kind:`gauge`,unit:`%`,deadband:2},desiccantLeftDays:{kind:`gauge`,unit:`s`}},"pet-fountain":{waterLevel:{kind:`gauge`,unit:`%`,deadband:1},waterVolume:{kind:`gauge`,unit:`L`}},"power-meter":{power:{kind:`gauge`,unit:`W`,deadband:1,minIntervalMs:3e4},energy:{kind:`counter`,unit:`kWh`,deadband:.01,minIntervalMs:6e4},voltage:{kind:`gauge`,unit:`V`,deadband:1,minIntervalMs:3e4},current:{kind:`gauge`,unit:`A`,deadband:.05,minIntervalMs:3e4},apparentPower:{kind:`gauge`,unit:`VA`,deadband:1,minIntervalMs:3e4},powerFactor:{kind:`gauge`,unit:`ratio`,deadband:.01,minIntervalMs:6e4}},"pressure-sensor":{pressure:{kind:`gauge`,unit:`hPa`,deadband:.1}},"running-state":{running:{kind:`boolean`}},smoke:{detected:{kind:`boolean`}},"stream-params":{"main.bitrate":{group:`bitrate`,kind:`gauge`,unit:`kbps`},"main.framerate":{group:`framerate`,kind:`gauge`,unit:`fps`},"sub.bitrate":{group:`bitrate`,kind:`gauge`,unit:`kbps`},"sub.framerate":{group:`framerate`,kind:`gauge`,unit:`fps`}},switch:{on:{kind:`boolean`}},tamper:{tampered:{kind:`boolean`}},"temperature-sensor":{temperature:{kind:`gauge`,unit:`°C`,deadband:.1}},"vacuum-control":{batteryLevel:{kind:`gauge`,unit:`%`,deadband:2}},valve:{position:{kind:`gauge`,unit:`%`,minIntervalMs:0}},vibration:{detected:{kind:`boolean`}},"water-heater":{currentTemp:{group:`temperature`,kind:`gauge`,unit:`°C`,deadband:.5},targetTemp:{group:`temperature`,kind:`gauge`,unit:`°C`,minIntervalMs:0}},weather:{temperature:{kind:`gauge`,unit:`°C`,deadband:.2},humidity:{kind:`gauge`,unit:`%`,deadband:1},pressure:{kind:`gauge`,unit:`hPa`,deadband:.5},windSpeed:{kind:`gauge`,unit:`m/s`,deadband:.5}},"weather-station":{temperature:{group:`temperature`,kind:`gauge`,unit:`°C`,deadband:.1},humidity:{kind:`gauge`,unit:`%`,deadband:1},pressure:{kind:`gauge`,unit:`hPa`,deadband:.2},windSpeed:{group:`wind-speed`,kind:`gauge`,unit:`m/s`,deadband:.2},windGust:{group:`wind-speed`,kind:`gauge`,unit:`m/s`,deadband:.2},windBearing:{group:`wind-bearing`,kind:`gauge`,unit:`°`,deadband:5},rainRate:{kind:`gauge`,unit:`mm/h`,deadband:.1},rainDaily:{kind:`gauge`,unit:`mm`,deadband:.1},rainEvent:{kind:`gauge`,unit:`mm`,deadband:.1},uv:{kind:`gauge`,unit:`index`,deadband:.1},solarRadiation:{kind:`gauge`,unit:`W/m²`,deadband:5},dewPoint:{group:`temperature`,kind:`gauge`,unit:`°C`,deadband:.1},feelsLike:{group:`temperature`,kind:`gauge`,unit:`°C`,deadband:.1},vpd:{kind:`gauge`,unit:`kPa`,deadband:.05},windGustMax:{group:`wind-speed`,kind:`gauge`,unit:`m/s`,deadband:.2},windBearingAvg:{group:`wind-bearing`,kind:`gauge`,unit:`°`,deadband:5},rain24h:{kind:`gauge`,unit:`mm`,deadband:.1},rainWeekly:{kind:`gauge`,unit:`mm`,deadband:.1},rainMonthly:{kind:`gauge`,unit:`mm`,deadband:.1},rainYearly:{kind:`gauge`,unit:`mm`,deadband:.1}},workload:{state:{kind:`enum`,values:[`running`,`paused`,`stopped`,`starting`,`stopping`,`crashed`]},"resources.cpuPercent":{kind:`gauge`,unit:`%`,deadband:2,displayName:`CPU`},"resources.memoryUsedBytes":{kind:`gauge`,unit:`bytes`,displayName:`Memory used`},"resources.memoryPercent":{kind:`gauge`,unit:`%`,deadband:2,displayName:`Memory`},"resources.netRxKbps":{group:`network`,kind:`gauge`,unit:`kbps`,displayName:`Network received`},"resources.netTxKbps":{group:`network`,kind:`gauge`,unit:`kbps`,displayName:`Network sent`}}},Mbe={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`}}}},hO={"climate-control":{field:`currentTemp`,priority:70},"energy-system":{field:`house.powerW`,priority:50},"humidity-sensor":{field:`humidity`,priority:90},"power-meter":{field:`power`,priority:80},"temperature-sensor":{field:`temperature`,priority:100},"weather-station":{field:`temperature`,priority:60},workload:{field:`resources.cpuPercent`,priority:40}},Nbe=`audio-metrics.automation-control.camera-streams.color.control.day-night.doorbell.error.event-emitter.feature-probe.group-active.group-commands.group-status.image.image-settings.intercom.ir-transmitter.low-power-sleep.motion-trigger.motion-zones.native-object-detection.navigation.notifier.power-source.presence.privacy-mask.ptz-autotrack.pump-cycle.recording-onboard.recording-signal.scene-monitor.script-runner.siren.stream-catalog.stream-signals.timed-run.update.zone-analytics.zone-rules.zones`.split(`.`);function gO(e){return mO[e]??{}}function Pbe(e,t,n){return _O(e.deviceTypes,t,n)}function _O(e,t,n){return e.length===0||e.some(e=>e===t)?!0:Ko(t,n)&&e.includes(E.Light)}function Fbe(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 vO(e){return{fieldChoice:`operator`,purpose:`historised`,multiple:!1,max:1,deviceTypes:[],accept:yO(e),history:{required:!0,minRetentionMs:null},mustBindCaps:[],exclude:[]}}function yO(e){let t=[];for(let n of Object.keys(mO))for(let[r,i]of Object.entries(gO(n)))i.kind!==`enum`&&(e===`integral`&&i.kind!==`gauge`||t.push({cap:n,fieldPath:r,valueKind:i.kind===`boolean`?`boolean`:`number`}));return t}function Ibe(e){if(e===`derivative`)return{...vO(`statistic`),accept:bO()};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:bO(),history:{required:!1,minRetentionMs:null},mustBindCaps:[],exclude:[]}}function bO(){return yO(`statistic`).filter(e=>e.valueKind===`number`)}var xO=[`switch`,`brightness`,`color`],Lbe=[D.LightColorRgb,D.LightColorHsv,D.LightColorMired],Rbe=4;function SO(e){return e===`all`?`all`:`any`}function zbe(e){return e===`all`?`all`:`at-least-one`}function Bbe(e){return e.length===0?[]:xO.filter(t=>e.every(e=>e.includes(t)))}function Vbe(e){return e.length===0?[]:Lbe.filter(t=>e.every(e=>e.includes(t)))}function Hbe(e,t,n,r){return e.flatMap(e=>e.caps.includes(t)?[{deviceId:e.deviceId,cap:t,method:n,args:{...r}}]:[])}async function Ube(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 Wbe={kind:`expression`,expr:`now`,bindings:{}};function CO(e,t,n){return{kind:`series`,read:{source:e.source,cap:e.cap,fieldPath:e.fieldPath},publish:t,empty:n}}function Gbe(e){return{included:CO(e,`included`,`offline`),excluded:CO(e,`excluded`,`offline`),total:CO(e,`total`,`offline`)}}var Kbe={second:`s`,minute:`min`,hour:`h`};function qbe(e){let t=gO(e.source.cap)[e.source.fieldPath]?.unit;return t===void 0?null:`${t}/${Kbe[e.per]}`}function wO(e){let t=gO(e.cap)[e.fieldPath];return t===void 0?null:t.kind}function TO(e){return wO(e)===null?[H(`member-constraint`,`helper.source`,`${e.cap}.${e.fieldPath} has no history declaration`)]:[]}function EO(e){return{target:{kind:`new`,type:E.Sensor,role:e.role},helper:e.spec,features:[{kind:`fields`,cap:e.cap,fields:{[e.field]:CO(e.member,`value`,e.empty),lastFetchedAt:Wbe}},{kind:`fields`,cap:`group-status`,fields:Gbe(e.member)}]}}function DO(e,t=nc){let n=[...TO(e.source)],r=wO(e.source);r===`enum`&&n.push(H(`kind-mismatch`,`helper.source`,`a statistic reads a number or a boolean, not a state`)),e.stat===`sum`&&r!==`counter`&&n.push(H(`kind-mismatch`,`helper.stat`,`a gauge has no sum — that is the integral template`));let i=vc(e.window,t);return i.ok||n.push(H(`retention`,`helper.window`,i.reason)),{problems:n,draft:EO({role:O.NumericSensor,cap:`numeric-sensor`,field:`value`,empty:`null`,spec:e,member:e.source})}}function OO(e,t=nc){let n=[...TO(e.source)],r=wO(e.source);(r===`enum`||r===`boolean`)&&n.push(H(`kind-mismatch`,`helper.source`,`a derivative reads a number that moves, not a yes/no or a state`));let i=vc(e.window,t);return i.ok||n.push(H(`retention`,`helper.window`,i.reason)),{problems:n,draft:EO({role:O.NumericSensor,cap:`numeric-sensor`,field:`value`,empty:`null`,spec:e,member:e.source})}}function kO(e,t=nc){let n=[...TO(e.source)],r=wO(e.source),i=e.source.cap===`power-meter`&&e.source.fieldPath===`power`;(r===`counter`||r===`boolean`||r===`enum`)&&n.push(H(`kind-mismatch`,`helper.source`,`an integral reads an instantaneous gauge, not a counter or a state`)),e.output===`energy`&&!i&&n.push(H(`kind-mismatch`,`helper.output`,`energy is the integral of power-meter.power; another reading uses the meter`)),e.output===`meter`&&i&&n.push(H(`kind-mismatch`,`helper.output`,`power integrates to power-meter.energy, which energy dashboards already read`));let a=yc(e.reset,t);a.ok||n.push(H(`retention`,`helper.reset`,a.reason));let o=e.output===`energy`;return{problems:n,draft:EO({role:o?O.EnergySensor:O.NumericSensor,cap:o?`power-meter`:`meter`,field:o?`energy`:`value`,empty:`offline`,spec:e,member:e.source})}}var Jbe=/^\d+(?:\.\d+)?$/,Ybe=/^-?\d+(?:\.\d+)?$/,Xbe=/^dwell\(x (>=|<=) (\d+(?:\.\d+)?), (\d+(?:\.\d+)?), (\d+(?:\.\d+)?)(?:, (\d+))?\)$/,Zbe=/^clamp\((x|number\(x\)) \* (-?\d+(?:\.\d+)?) \+ (-?\d+(?:\.\d+)?), (-?\d+(?:\.\d+)?), (-?\d+(?:\.\d+)?)\)$/,Qbe=/^(x|number\(x\)) \* (-?\d+(?:\.\d+)?) \+ (-?\d+(?:\.\d+)?)$/,$be=/^[A-Za-z_][A-Za-z0-9_]*$/;function AO(e){return BO(e,Jbe)}function jO(e){return BO(e,Ybe)}function MO(e){return typeof e==`string`?JSON.stringify(e):typeof e==`number`?jO(e):typeof e==`boolean`?e?`true`:`false`:`null`}function NO(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 PO(e){return $be.test(e)}function FO(e,t,n,r,i=1){return`dwell(x ${e===`gte`?`>=`:`<=`} ${t}, ${n}, ${r}${i>1?`, ${i}`:``})`}function IO(e,t,n,r,i){let a=`${e} * ${t} + ${n}`;return r===null||i===null?a:`clamp(${a}, ${r}, ${i})`}function LO(e){let t=Xbe.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 RO(e){let t=Zbe.exec(e);if(t!==null)return VO(t[1],t[2],t[3],t[4],t[5]);let n=Qbe.exec(e);return n===null?null:VO(n[1],n[2],n[3],void 0,void 0)}function zO(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 BO(e,t){if(!Number.isFinite(e))return null;let n=Object.is(e,-0)?`0`:String(e);return t.test(n)?n:null}function VO(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 HO={kind:`expression`,expr:`now`,bindings:{}};function UO(e){return{kind:`from`,source:e.source,cap:e.cap,fieldPath:e.fieldPath}}function WO(e,t){return{kind:`expression`,expr:e,bindings:t}}function exe(e,t){return e.source.addonId===t.source.addonId&&e.source.stableId===t.source.stableId&&e.cap===t.cap&&e.fieldPath===t.fieldPath}function GO(e,t,n=[]){return{target:{kind:`new`,type:E.Sensor,role:O.NumericSensor},helper:e,features:[{kind:`fields`,cap:`numeric-sensor`,fields:{value:t,lastFetchedAt:HO}},...n]}}function KO(e,t){return{target:{kind:`new`,type:E.Sensor,role:O.BinarySensor},helper:e,features:[{kind:`fields`,cap:`binary`,fields:{on:t,lastChangedAt:HO}}]}}function qO(e){let t=[],n=jO(e.high),r=jO(e.low);n===null&&t.push(H(`kind-mismatch`,`helper.high`,`the high edge is a finite number`)),r===null&&t.push(H(`kind-mismatch`,`helper.low`,`the low edge is a finite number`)),n!==null&&r!==null&&e.low>e.high&&t.push(H(`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=AO(e.onForMs),a=AO(e.offForMs);(i===null||a===null)&&t.push(H(`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:KO(e,WO(`coalesce(schmitt(x, ${n??`0`}, ${r??`0`}${o}), false)`,{x:UO(e.source)}))}}var txe=[`a`,`b`];function nxe(e){let t=[],n=e.op!==`sum`;return n&&e.inputs.length!==2&&t.push(H(`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(H(`member-constraint`,`helper.inputs`,`a sum takes two or more readings`)),e.inputs.forEach((n,r)=>{e.inputs.slice(0,r).some(e=>exe(e,n))&&t.push(H(`member-constraint`,`helper.inputs[${r}]`,`this reading is already an input`))}),t}var rxe=[`included`,`excluded`,`total`];function JO(e){let t=nxe(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(rxe.map(e=>[e,r(e)]));return{problems:t,draft:GO(e,r(`value`),[{kind:`fields`,cap:`group-status`,fields:i}])}}let n=Object.fromEntries(e.inputs.slice(0,2).map((e,t)=>[txe[t]??`a`,UO(e)]));return{problems:t,draft:GO(e,WO(e.op===`difference`?`a - b`:`b == 0 ? null : a / b`,n))}}function ixe(e){let t=[],n=new Set;if(e.inputs.forEach((e,r)=>{let i=`helper.inputs[${r}].name`;PO(e.name)||t.push(H(`expression-invalid`,i,`\`${e.name}\` is not a name — use letters, digits and _, starting with a letter`)),n.has(e.name)&&t.push(H(`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,UO(e.member)])),i=Fs({expr:e.expr,bindings:r});return i===null?[]:[H(`expression-invalid`,`helper.expr`,i)]}function YO(e){let t=ixe(e),n=Object.fromEntries(e.inputs.map(e=>[e.name,UO(e.member)])),r=WO(e.expr,n);return{problems:t,draft:e.output===`boolean`?KO(e,r):GO(e,r)}}function axe(e,t){return e.addonId===t.addonId&&e.stableId===t.stableId}function oxe(e,t){return axe(e.source,t.source)&&e.cap===t.cap&&e.fieldPath===t.fieldPath}function sxe(e,t){return e.accept.some(e=>e.cap===t.cap&&e.fieldPath===t.fieldPath)}function cxe(e,t){return t.members.flatMap((n,r)=>{let i=`helper.members[${r}]`,a=[];if(!sxe(e,n)){let t=e.accept.map(e=>`${e.cap}.${e.fieldPath}`).join(` or `);a.push(H(`member-constraint`,i,`a ${e.id} group reads ${t}; this member is ${n.cap}.${n.fieldPath}`))}return t.members.slice(0,r).some(e=>oxe(e,n))&&a.push(H(`member-constraint`,i,`this member is already in the group`)),a})}function XO(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 lxe(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,dxe(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]:XO(e,t,n,`value`),...r}},{kind:`fields`,cap:`group-status`,fields:{included:XO(e,t,n,`included`),excluded:XO(e,t,n,`excluded`),total:XO(e,t,n,`total`)}}]}}function uxe(e,t){if(e.family===`actuator`){if(t.active===void 0)return[H(`kind-mismatch`,`helper.active`,`a ${e.id} group needs an active criterion (at-least-one or all)`)];let n=SO(t.active);return t.aggregate===n?[]:[H(`kind-mismatch`,`helper.aggregate`,`active \`${t.active}\` aggregates by \`${n}\`, not \`${t.aggregate}\``)]}return t.active===void 0?[]:[H(`kind-mismatch`,`helper.active`,`a ${e.id} group has no active criterion — that belongs to an actuator group`)]}function ZO(e){let t=Dl.safeParse(e);return t.success?{ok:!0,composition:t.data}:{ok:!1,problems:[H(`helper-mismatch`,`helper`,`the template did not compile: ${t.error.issues.map(e=>e.message).join(`; `)}`)]}}function dxe(e,t={}){return{kind:`expression`,expr:e,bindings:t}}function QO(e,t=nc){switch(e.kind){case`group`:return pxe(e);case`statistic`:{let n=DO(e,t);return n.problems.length>0?{ok:!1,problems:n.problems}:ZO(n.draft)}case`integral`:{let n=kO(e,t);return n.problems.length>0?{ok:!1,problems:n.problems}:ZO(n.draft)}case`derivative`:{let n=OO(e,t);return n.problems.length>0?{ok:!1,problems:n.problems}:ZO(n.draft)}case`threshold`:return $O(qO(e));case`arithmetic`:return $O(JO(e));case`expression`:return $O(YO(e));case`grid`:case`crop`:case`terminal`:return ZO(fxe(e))}}function fxe(e){return{target:{kind:`new`,type:E.Camera},helper:e,features:[]}}function $O(e){return e.problems.length>0?{ok:!1,problems:e.problems}:ZO(e.draft)}function pxe(e){let t=pO(e.templateId);if(t===null)return{ok:!1,problems:[H(`member-constraint`,`helper.templateId`,`unknown template \`${e.templateId}\``)]};let n=uxe(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:[H(`kind-mismatch`,`helper.aggregate`,`a ${t.id} group aggregates by ${n}, not \`${e.aggregate}\``)]}}let r=cxe(t,e);return r.length>0?{ok:!1,problems:r}:ZO(lxe(t,e))}function ek(e,t){return JSON.stringify(e.target)===JSON.stringify(t.target)&&JSON.stringify(e.features)===JSON.stringify(t.features)}function mxe(e){return e.kind===`group`?pO(e.templateId)?.memberDeviceType??null:null}function hxe(e,t){if(e.kind!==`group`)return[];let n=pO(e.templateId);if(n===null||n.family!==`numeric`)return[];let r=e.members.flatMap((e,n)=>{let r=t.get(Ol(e.source))?.quantity;return r===void 0?[]:[{index:n,quantity:r}]});if(n.quantity!==`device`)return r.flatMap(e=>e.quantity===n.quantity?[]:[H(`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?[]:[H(`mixed-quantity`,`helper.members`,`a numeric group requires one quantity; members report ${i.join(` and `)}`)]}function gxe(e,t){if(e.kind!==`group`)return[];let n=pO(e.templateId);return n===null?[]:e.members.flatMap((e,r)=>{let i=t.get(Ol(e.source)),a=i?.deviceType;return a===void 0||_O(n.memberDeviceTypes,a,i?.role)?[]:[H(`member-constraint`,`helper.members[${r}]`,`a ${n.id} group takes ${n.memberDeviceTypes.join(` or `)} devices; this member is a ${a}`)]})}function tk(e,t){let n=e.helper;if(n===void 0)return[];let r=QO(n);return r.ok?ek(e,r.composition)?n.kind===`arithmetic`?_xe(n,t):n.kind===`group`?[...hxe(n,t),...gxe(n,t)]:[]:[H(`helper-mismatch`,`helper`,`the stored features are not this template — the helper spec is the only writer`)]:r.problems}function _xe(e,t){let n=e.inputs.flatMap(e=>{let n=t.get(Ol(e.source))?.quantity;return n===void 0?[]:[n]}),r=[...new Set(n)];return r.length<=1?[]:[H(`mixed-quantity`,`helper.inputs`,`a ${e.op} needs readings of one quantity; these inputs report ${r.join(` and `)}`)]}var nk=class extends Error{};function vxe(e){return new Set(e.composition.features.flatMap(e=>!Sl(e)||e.kind!==`fields`?[]:Fl(e).map(({fieldPath:t})=>`${e.cap}.${t}`)))}function yxe(e,t,n){if(Ol(n.source)!==Ol(e.target))return!0;let r=`${n.cap}.${n.fieldPath}`;return t.has(r)&&e.replaced?.has(r)!==!0}function bxe(e){let t=vxe(e);return e.composition.features.flatMap(n=>!Sl(n)||n.kind!==`fields`?[]:Fl(n).map(({fieldPath:r,source:i})=>[Al({source:e.target,cap:n.cap,fieldPath:r}),Nl(i).filter(n=>yxe(e,t,n)).map(Al)]))}function xxe(e,t){let n=Ol(e.target),r=new Map;for(let i of t){if(i.blockId===e.blockId)continue;let t=Ol(i.target);if(t===n)throw new nk(`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 nk(`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 rk(e,t){let n=xxe(e,t).flatMap(bxe);return new Map(n)}function Sxe(e,t){let n=rk(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 Cxe(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 wxe(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 ik(e,t){let n=rk(e,t),r=`${Ol(e.target)}#`;return Cxe(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:wxe(t,i,n),component:i}]})}var Txe=3,Exe=120,Dxe=10,ak=S([`no-power-source`,`switch-missing`,`switch-offline`,`switch-unknown`,`restart-in-progress`,`switch-call-failed`,`switch-options-unreadable`,`not-settable`,`switch-is-actuator`,`link-lost`,`link-unknown`]),ok=i(`accepted`,[x({accepted:p(!0)}),x({accepted:p(!1),reason:ak,message:l()})]),sk=x({linked:y(),switchDeviceId:n().nullable(),switchName:l().nullable(),switchOn:y().nullable(),switchOnline:y().nullable(),switchSettable:y().nullable().optional(),restartInProgress:y(),offSeconds:n().int()}),ck=x({switchOn:y().nullable(),offSeconds:n().int(),lastFetchedAt:n()}),lk=[E.Gateway,E.Camera,E.Sensor,E.MediaPlayer,E.Vacuum,E.Generic,E.Washer,E.Dryer,E.Dishwasher,E.PetFountain,E.Fan,E.Humidifier,E.Climate,E.WaterHeater],Oxe={version:1,targets:[{id:`switch`,cardinality:`scalar`,vocabulary:{cap:`power-source`,stateField:`switchOn`},deviceTypes:lk,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`}}]},uk=x({deviceId:n().int().nonnegative()}),dk={method:`getStatus`,field:`switchSettable`},fk={name:`power-source`,scope:`device`,mode:`singleton`,deviceTypes:lk,methods:{getStatus:ti(uk,sk,{auth:`protected`}),powerOn:ti(uk,ok,{kind:`mutation`,auth:`protected`,actions:[{id:`powerSource.on`,label:F(`Power on`,`Dai corrente`),phrase:F(`Power on {device}`,`Dai corrente a {device}`),icon:`power`,offeredWhen:dk}]}),powerOff:ti(uk,ok,{kind:`mutation`,auth:`protected`,actions:[{id:`powerSource.off`,label:F(`Power off`,`Togli corrente`),phrase:F(`Cut the power of {device}`,`Togli la corrente a {device}`),icon:`power-off`,offeredWhen:dk}]}),forceRestart:ti(uk,ok,{kind:`mutation`,auth:`protected`,actions:[{id:`powerSource.forceRestart`,label:F(`Force restart`,`Riavvio forzato`),phrase:F(`Force restart {device} by cutting its power`,`Riavvia {device} togliendo la corrente`),icon:`refresh-cw`}]})},runtimeState:ck,customize:Oxe,durability:`session`,history:`none`,vocabulary:{noun:F(`Power source`,`Alimentazione`),order:1050,state:[{kind:`boolean`,field:`switchOn`,label:F(`Power switch on`,`Presa accesa`),whenTrue:F(`When the power of {device} comes on`,`Quando arriva la corrente a {device}`),whenFalse:F(`When the power of {device} is cut`,`Quando manca la corrente a {device}`),icon:`power`}]}};function pk(e){return typeof e!=`number`||!Number.isFinite(e)?10:Math.min(120,Math.max(3,Math.round(e)))}function kxe(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 Axe(e,t){if(e===null)return null;let n;if(e.target.kind===`existing`)n=e.target.device;else if(t!==void 0)n=Ml(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=Nl(i).find(e=>e.cap===`switch`);return a===void 0?null:{device:n,switch:a.source,offSeconds:pk(kxe(e)),...r.contributedBy===void 0?{}:{contributedBy:r.contributedBy}}}var mk=`switch`;function jxe(e){let t=new Set;return e.target.kind===`existing`&&t.add(Ol(e.target.device)),e.features.forEach((e,n)=>{if(!(e.kind!==`fields`||e.cap!==mk)&&Sl(e)){for(let n of Il(e))for(let e of Nl(n))t.add(Ol(e.source));for(let r of XD(e,n))t.add(Ol(r.command.source))}}),t}function hk(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=jxe(e);return Nl(r).filter(e=>e.cap===mk&&i.has(Ol(e.source))).map(e=>({path:`features[${t}].fields.switchOn`,switch:e.source}))}function gk(e){let t=new Map(e.map(e=>[e.name,e]));return e=>t.get(e)??null}var _k=new Set([`device-status`,`feature-probe`]),Mxe={addonId:Zc,stableId:`${Te}(unsaved)`},Nxe=`(unsaved)`;function Pxe(e,t,n){let r=n(e.cap);if(r===null)return H(`unknown-capability`,`${t}.cap`,`no capability is named \`${e.cap}\``);if(_k.has(r.name))return H(`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?H(`not-composable`,`${t}.cap`,`\`${r.name}\` has no per-device state to compose`):{def:r,state:i,fields:BT(i)}}function Fxe(e){let t=e.helper;if(t===void 0||t.kind!==`group`)return new Set;let n=pO(t.templateId);return n===null||n.family!==`actuator`?new Set:new Set(n.commandCaps)}function Ixe(e,t){return e.name===SD.name&&Object.values(t.commands??{}).some(e=>e.kind===`extension`)}function Lxe({def:e,state:t,fields:n},r,i,a,o){let s=[];e.deviceTypes!==void 0&&!e.deviceTypes.includes(a)&&s.push(H(`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=QD(e).filter(e=>!c.has(e)).map(e=>`\`${e}\``);l.length>0&&!o.has(e.name)&&s.push(H(`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=Ixe(e,r);for(let a of d?[]:VT(t))a!==u&&(n.has(a)?a in r.fields||s.push(H(`missing-field`,`${i}.fields.${a}`,`\`${e.name}.${a}\` is required and has no source`)):s.push(H(`not-composable`,`${i}.fields`,`\`${e.name}.${a}\` is not a scalar — nested fields arrive in a later slice`)));return s}function Rxe({fields:e,state:t},n,r){return n.includes(`.`)?r===`replace`?zT(t,n)??void 0:`nested`:e.get(n)}function zxe(e,t,n,r){let{def:i}=e,{featureIndex:a,path:o,source:s}=t,c=`features[${a}].fields.${o}`,l=Rxe(e,o,n);if(l===`nested`)return TD(H(`nested-field`,c,`\`${o}\` is nested — a nested field is planned only on a declared replace (D1034)`));if(l===void 0)return TD(H(`unknown-field`,c,`\`${i.name}\` has no field \`${o}\``));if(l.kind===`union`)return TD(zD(i.name,o,c));let u=HD(s,r);if(!u.ok)return TD(H(u.code,c,u.message));let d=GD(s),f=KD(l,d,n,i.name,c);if(!f.ok)return TD(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:[...Nl(s)]},h=WD(i.name,l,s,c);return{problems:[...UD(i.name,l,VD(s,l,u.kinds,r),c),...h===null?[]:[h]],fields:[m],features:[],events:[]}}function Bxe(e,t,n,r,i){let a=`features[${n}]`,o=XD(t,n),s=Object.entries(t.commands??{}).filter(([,e])=>e.kind===`code`).map(([e])=>H(`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!==SD.name?[...s,...c.map(([t])=>H(`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,H(`reserved-variant`,`${a}.commands`,"commands (`forward`) are served only by a capability a NEW device builds — not on an existing device")]:[...s,...iO(e,t,a),...o.flatMap(t=>rO(e,t,i))]}function vk(e,t,n,r,i){let a=`features[${t}]`,o=Pxe(e,a,r);if(`code`in o)return TD(o);let s=n.mode===`replace`?[]:[...Lxe(o,e,a,n.deviceType,i)];s.push(...Bxe(o.def,e,t,n.mode,r));let c=Object.entries(e.fields).map(([e,i])=>zxe(o,{featureIndex:t,path:e,source:i},n.mode,r)),l=e.items===void 0?[]:[JD(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=KT(o.def,f,d);return{problems:[...s,...u.flatMap(e=>e.problems),...p.problems],fields:d,features:[f],events:p.events}}function yk(e,t){let n=e.nativeCaps.get(t);return n!==void 0&&n!==`composer`}function Vxe(e){return`code`in e}function Hxe(e,t){if(e.target.kind===`new`)return{kind:`new`,type:e.target.type};let n=Ol(e.target.device);return t===void 0?H(`target-unreadable`,`target`,`target device \`${n}\` was not read — the save is refused rather than stored unchecked`):t.kind===`absent`?H(`target-missing`,`target`,`target device \`${n}\` does not exist`):t.kind===`unreadable`?H(`target-unreadable`,`target`,`could not read target device \`${n}\` (${t.error}) — the save is refused rather than stored unchecked`):{kind:`existing`,found:t}}var Uxe=new Set([`not-composable`,`unknown-capability`,`reserved-variant`]);function Wxe(e,t){let n=t.problems.filter(e=>Uxe.has(e.code));return n.length>0?{problems:n,fields:[],features:[],events:[]}:TD(e)}var Gxe=CD;function Kxe(e){let t=Gxe[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 qxe(e,t,n){let r=t.cap;return e.kind===`new`?{mode:`new`,deviceType:e.type}:yk(e.found,r)?Kxe(t)?{mode:`replace`,deviceType:e.found.type}:H(`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 bk(e,t,n){let r=Hxe(e,n);if(`code`in r)return TD(r);let i=Fxe(e),a=e.features.map((e,n)=>{let a=`features[${n}]`;if(e.kind===`passthrough`)return TD(H(`reserved-variant`,a,`whole-capability passthrough of \`${e.cap}\` arrives in slice 3`));let o=qxe(r,e,a);if(Vxe(o))return!Sl(e)||r.kind!==`existing`?{problems:[],fields:[],features:[],events:[]}:Wxe(o,vk(e,n,{mode:`add`,deviceType:r.found.type},t,i));let s=vk(e,n,o,t,i);return Sl(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 Jxe(e){let t=e.features.flatMap(e=>Sl(e)&&e.kind===`fields`?Il(e).flatMap(Nl).map(e=>e.source):[]);return[...new Map([...t,...ZD(e)].map(e=>[Ol(e),e])).values()]}function Yxe(e,t){return e.features.flatMap(e=>Sl(e)&&e.kind===`fields`?Il(e).flatMap(e=>{if(e.kind!==`from`)return[];let n=t(e.cap),r=n?.runtimeState??n?.status?.schema;return r===void 0?[]:zT(r,e.fieldPath)?.kind===`union`?[e]:[]}):[])}function Xxe(e,t,n){return{ref:e.target.kind===`existing`?e.target.device:t.self??Mxe,native:e.target.kind===`existing`&&t.target?.kind===`found`?t.target:null,replaced:xk(n)}}function xk(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(eE))}function Zxe(e,t,n,r){let i=`${e.cap}.${e.fieldPath}`;return n.some(e=>eE(e)===i&&!r.replaced.has(i))?[]:r.native===null?[H(`source-field-unknown`,t,`this device has no composed field \`${e.cap}.${e.fieldPath}\``)]:yk(r.native,e.cap)?[]:[H(`source-capability-missing`,t,`the target device (device ${r.native.deviceId}) has no native \`${e.cap}\``)]}function Qxe(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?[]:[H(`source-kind-mismatch`,r,`\`${t.cap}.${t.fieldPath}\` of device ${n.deviceId} reads a ${i} now; \`${e.cap}.${e.path}\` takes a ${a}`)]}function $xe(e,t,n){let r=Ol(n.ref);return e.flatMap(i=>i.reads.flatMap(a=>{let o=ED(i),s=Ol(a.source);if(s===r)return Zxe(a,o,e,n);let c=t.sources.get(s);return c===void 0||c.kind===`unreadable`?[H(`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`?[H(`source-missing`,o,`source \`${s}\` does not exist`)]:c.caps.has(a.cap)?Qxe(i,a,c,o):[H(`source-capability-missing`,o,`source \`${s}\` (device ${c.deviceId}) has no \`${a.cap}\``)]}))}function eSe(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 tSe(e,t,n){for(let r of e){let e=eSe(r,t);if(e===null)continue;let i=`${e.cap}.${e.fieldPath}`,a=n.find(e=>eE(e)===i);if(a!==void 0)return ED(a)}return`features`}function nSe(e,t){for(let[n,r]of t)if(e.some(e=>e.startsWith(`${n}#`)))return{key:n,error:r};return null}function rSe(e,t,n,r){let i={blockId:t.blockId??`(unsaved)`,target:r.ref,composition:e,replaced:r.replaced},a=Ol(i.target),o=t.unreadTargets??new Map;try{return ik(i,t.peers).map(e=>{let t=tSe(e.path,a,n),r=nSe([...e.component],o);return r===null?H(`cycle`,t,`a field reads itself: ${e.path.join(` → `)}`):H(`cycle`,t,`possible cycle through \`${r.key}\` — its state could not be read (${r.error}): ${e.path.join(` → `)}`)})}catch(e){if(e instanceof nk)return[H(`duplicate-target`,`features`,e.message)];throw e}}function Sk(e,t){let n=bk(e,t.lookupCap,t.target??void 0),r=Xxe(e,t,n),i=n.problems.filter(e=>e.code===`native-capability-replace`).map(e=>e.path),a=rSe(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,...$xe(n.fields,t,r),...aO(e,t.sources),...a,...tk(e,o),...hk(e).map(e=>H(`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 Ck=x({path:l(),kind:YT,nullable:y(),required:y(),enumValues:C(l()).optional()}),wk=x({cap:l(),fields:C(Ck),itemArray:x({path:l(),keyField:l()}).optional()}),Tk=x({caps:C(wk)});function Ek(e,t){if(_k.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=BT(n),a=e.status?.itemArray?.path??null;return VT(n).some(e=>e!==a&&!i.has(e))&&r.push(`not-composable`),KT(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 iSe(e,t){return e.filter(e=>Ek(e,t).length===0).map(e=>{let t=e.runtimeState,n=t===void 0?[]:[...BT(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 Dk=x({addonId:l().min(1),stableId:l().min(1),cap:l().min(1),fieldPath:l().min(1)}),aSe=x({kind:p(`identity`)}),oSe=x({kind:p(`invert`)}),Ok=x({kind:p(`threshold`),comparison:S([`gte`,`lte`]),threshold:n(),startDwellMs:n().nonnegative(),stopDwellMs:n().nonnegative(),minSamples:n().int().min(1).optional()}),kk=i(`kind`,[aSe,oSe,Ok,x({kind:p(`linear`),scale:n(),offset:n(),clampMin:n().optional(),clampMax:n().optional()}),x({kind:p(`enum-map`),mapping:m(l(),l().nullable())}),x({kind:p(`number`)})]),sSe=x({kind:p(`scalar`),cap:l().min(1),targetId:l().min(1),source:Dk,transform:kk}),cSe=x({kind:p(`keyedArray`),cap:l().min(1),targetId:l().min(1),key:l().min(1),label:l().min(1),fieldPath:l().min(1),source:Dk,transform:kk}),lSe=x({kind:p(`pulse`),cap:l().min(1),targetId:l().min(1),enabled:y(),debounceMs:n().nonnegative(),edges:C(S([`rising`,`button`,`native-event`])).min(1).optional(),sources:C(Dk).min(1)}),uSe=Dk.extend({mode:S([`in-addition`,`confirm`,`replace`]).optional()}),dSe=i(`kind`,[sSe,cSe,lSe,x({kind:p(`span`),cap:l().min(1),targetId:l().min(1),timeoutMs:n().nonnegative(),cooldownMs:n().nonnegative().optional(),sources:C(uSe)})]),fSe=x({targetId:l().min(1),configured:y(),source:S([`native`,`assigned`]),state:S([`active`,`stale`,`released`,`unavailable`]),reason:l().nullable()}),Ak=S([`raw`,`5m`]),jk=S([`high`,`medium`,`low`]),Mk=S([`no-history`,`span-too-short`,`truncated`,`no-idle-floor`,`no-runs`,`no-separation`]),Nk=x({intervals:n().int().nonnegative(),extra:n().int().nonnegative(),missed:n().int().nonnegative()}),Pk=x({tier:Ak,spanMs:n().nonnegative(),from:n(),to:n(),points:n().int().nonnegative(),runsFound:n().int().nonnegative(),pausesFound:n().int().nonnegative(),longestPauseMs:n().nonnegative(),pulsesFound:n().int().nonnegative(),longestPulseMs:n().nonnegative(),idleFloorW:n(),noiseCeilingW:n(),plateauW:n(),replay:Nk}),Fk=x({spanMs:n().nonnegative(),points:n().int().nonnegative(),runsFound:n().int().nonnegative()}),Ik=i(`state`,[x({state:p(`proposal`),transform:Ok,evidence:Pk,confidence:jk,notes:C(l())}),x({state:p(`insufficient`),reason:Mk,evidence:Fk,fallback:Ok})]),Lk=x({apply:y()}),Rk=x({apply:y(),rows:n().int(),raw:n().int(),markers:n().int(),migrated:n().int(),failed:n().int(),remainingRaw:n().int(),unresolvedMarkers:n().int(),redundantCopies:n().int().optional(),verified:y()}),zk=`core-block-`,Bk=`core-blocks`;function pSe(e){return`${zk}${e}`}function mSe(e){if(!e.startsWith(`core-block-`))return null;let t=e.slice(11);return t.length>0?t:null}var Vk=h([p(`hub`),l().min(1)]),Hk=S([`stopped`,`starting`,`running`,`degraded`,`incomplete`,`failed`]),Uk=`main.ts`,Wk=m(l().min(1).max(260),l().max(2e5)),Gk=ve(),Kk=x({name:l().min(1).max(120),code:l().max(2e5).optional(),files:Wk.optional(),entry:l().min(1).max(260).optional(),enabled:y(),placement:Vk,integrationId:l().optional(),settingsSchema:Gk.optional(),tags:Hh.optional()}),qk=Kk.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 Jk(e){return e!==void 0&&e.length>0?e:Uk}function hSe(e){let t=Jk(e.entry);return e.files===void 0?{files:{[t]:e.code},entry:t}:{files:{...e.files},entry:t}}function gSe(e){if(e.files!==void 0){let t=Jk(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 Yk=i(`kind`,[x({kind:p(`code`)}),x({kind:p(`recipe`),recipe:Kv}),x({kind:p(`composition`),composition:Dl})]),Xk=x({name:l().min(1).max(120).optional(),enabled:y(),composition:Dl}),Zk=x({name:l().min(1).max(120),code:l().max(2e5),files:Wk.optional(),entry:l().min(1).max(260).optional(),enabled:y(),placement:Vk,integrationId:l().optional(),settingsSchema:Gk.optional(),tags:Hh.optional(),id:l(),createdAt:n(),updatedAt:n(),createdBy:l(),status:Hk,lastError:l().optional(),lastChangedAt:n(),source:Yk.optional()});function _Se(e){return e.source?.kind??`code`}function vSe(e){return e.source?.kind===`composition`?e.source.composition:null}var Qk=i(`kind`,[x({kind:p(`answered`),state:sE.nullable()}),x({kind:p(`unreachable`),error:l()})]),$k=x({block:Zk,state:Qk}),eA=x({state:p(`not-loaded`),reason:l()}),tA=i(`state`,[x({state:p(`loaded`),views:C($k)}),eA]),nA=i(`state`,[x({state:p(`loaded`),view:$k.nullable()}),eA]),rA=i(`state`,[x({state:p(`loaded`),view:$k.nullable()}),eA]),iA=x({ok:y(),error:l().optional(),line:n().optional(),column:n().optional()}),aA=x({code:l().optional(),files:Wk.optional(),entry:l().min(1).max(260).optional()}).superRefine((e,t)=>{if(e.files!==void 0){let n=e.entry??`main.ts`;e.files[n]===void 0&&t.addIssue({code:`custom`,message:`files must include the entry "${n}"`,path:[`files`]});return}e.code===void 0&&t.addIssue({code:`custom`,message:`code or files is required`,path:[`code`]})}),oA={name:`core-blocks`,scope:`system`,mode:`singleton`,methods:{list:A(x({}),x({blocks:C(Zk)}),{auth:`admin`}),get:A(x({blockId:l()}),x({block:Zk.nullable()}),{auth:`admin`}),create:A(x({block:qk}),x({block:Zk}),{kind:`mutation`,auth:`admin`,caller:`required`}),update:A(x({blockId:l(),block:Kk.partial()}),x({block:Zk}),{kind:`mutation`,auth:`admin`,caller:`required`}),delete:A(x({blockId:l()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setEnabled:A(x({blockId:l(),enabled:y()}),x({block:Zk}),{kind:`mutation`,auth:`admin`}),restart:A(x({blockId:l()}),x({block:Zk}),{kind:`mutation`,auth:`admin`}),compile:A(aA,iA,{kind:`mutation`,auth:`admin`}),getBlockSettings:A(x({blockId:l()}),sS.nullable(),{auth:`admin`}),updateBlockSettings:A(x({blockId:l(),patch:cS}),uS,{kind:`mutation`,auth:`admin`}),migrateRawSecrets:A(Lk,Rk,{kind:`mutation`,auth:`admin`}),getTypeDefs:A(x({}),x({libs:C(x({filePath:l(),content:l()}))}),{auth:`admin`}),createComposition:A(x({block:Xk}),x({block:Zk}),{kind:`mutation`,auth:`admin`,caller:`required`}),updateComposition:A(x({blockId:l(),expectedUpdatedAt:n(),block:Xk.partial()}),x({block:Zk}),{kind:`mutation`,auth:`admin`,caller:`required`}),getComposition:A(x({blockId:l()}),nA,{auth:`admin`}),listCompositions:A(x({}),tA,{auth:`admin`}),getCustomization:A(x({addonId:l().min(1),stableId:l().min(1)}),rA,{auth:`admin`}),listComposableCaps:A(x({deviceType:S(E)}),Tk,{auth:`admin`}),validateComposition:A(x({composition:Dl,blockId:l().optional()}),rE,{kind:`mutation`,auth:`admin`,access:`view`}),proposeRunningThreshold:A(x({deviceId:n().int(),cap:l().min(1),fieldPath:l().min(1),deviceType:S(E).optional()}),Ik,{auth:`admin`,access:`view`}),reportAutomationRun:A(x({blockId:l().min(1),trace:Ay.optional(),runStartedAt:n().optional(),keepTraces:n().int().min(1).max(100).optional()}),v(),{kind:`mutation`,auth:`admin`}),getAutomationRunState:A(x({blockId:l().min(1)}),jy,{auth:`admin`}),getTraces:A(x({blockId:l().min(1)}),x({traces:C(Ay),lastError:l().nullable()}),{auth:`admin`})},vocabulary:{notOperatorFacing:M.INTERNAL}},sA=S([`open`,`opening`,`closing`,`closed`,`stopped`]),cA=x({state:sA,position:n().min(0).max(100).nullable().meta(N(`percentage`)),tiltPosition:n().min(0).max(100).nullable().meta(N(`percentage`)),lastChangedAt:n()}),lA={name:`cover`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Cover],methods:{open:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.open`,label:F(`Open`,`Apri`),phrase:F(`Open {device}`,`Apri {device}`),icon:`arrow-up-to-line`,effect:{field:`state`,value:`open`}}]}),close:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.close`,label:F(`Close`,`Chiudi`),phrase:F(`Close {device}`,`Chiudi {device}`),icon:`arrow-down-to-line`,effect:{field:`state`,value:`closed`}}]}),stop:j(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.stop`,label:F(`Stop`,`Ferma`),phrase:F(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),setPosition:j(x({deviceId:n().int().nonnegative(),position:n().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.position`,label:F(`Set position`,`Imposta la posizione`),phrase:F(`Move {device} to {position} open`,`Porta {device} al {position} di apertura`),icon:`blinds`,effect:{field:`position`,fromArg:`position`},openArgs:[{key:`position`,label:F(`Position`,`Posizione`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setTiltPosition:j(x({deviceId:n().int().nonnegative(),tiltPosition:n().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.tilt`,label:F(`Set tilt`,`Imposta l’inclinazione`),phrase:F(`Tilt {device} to {tiltPosition}`,`Inclina {device} al {tiltPosition}`),icon:`blinds`,effect:{field:`tiltPosition`,fromArg:`tiltPosition`},openArgs:[{key:`tiltPosition`,label:F(`Tilt`,`Inclinazione`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]})},status:{schema:cA,kind:`push`},runtimeState:cA,durability:`restored`,history:{fields:{position:{kind:`gauge`,unit:`%`,minIntervalMs:0}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Cover`,`Copertura`),order:1030,state:[{kind:`enum`,field:`state`,label:F(`State`,`Stato`),values:[{value:`open`,label:F(`Open`,`Aperto`),phrase:F(`When {device} is fully open`,`Quando {device} è tutto aperto`)},{value:`opening`,label:F(`Opening`,`In apertura`),phrase:F(`When {device} starts opening`,`Quando {device} inizia ad aprirsi`)},{value:`closing`,label:F(`Closing`,`In chiusura`),phrase:F(`When {device} starts closing`,`Quando {device} inizia a chiudersi`)},{value:`closed`,label:F(`Closed`,`Chiuso`),phrase:F(`When {device} is fully closed`,`Quando {device} è tutto chiuso`)},{value:`stopped`,label:F(`Stopped`,`Fermo`),phrase:F(`When {device} stops part-way`,`Quando {device} si ferma a metà`)}],icon:`blinds`},{kind:`numeric`,field:`position`,quantity:F(`the opening`,`l’apertura`),label:F(`Position`,`Posizione`),unit:`%`,icon:`blinds`}],overrides:{byRole:{[O.CoverGarage]:{actions:{"cover.open":{phrase:F(`Open the garage door {device}`,`Apri il garage {device}`),icon:`warehouse`},"cover.close":{phrase:F(`Close the garage door {device}`,`Chiudi il garage {device}`),icon:`warehouse`}}},[O.CoverGate]:{actions:{"cover.open":{phrase:F(`Open the gate {device}`,`Apri il cancello {device}`),icon:`fence`},"cover.close":{phrase:F(`Close the gate {device}`,`Chiudi il cancello {device}`),icon:`fence`}}},[O.CoverDoor]:{actions:{"cover.open":{phrase:F(`Open the door {device}`,`Apri la porta {device}`),icon:`door-open`},"cover.close":{phrase:F(`Close the door {device}`,`Chiudi la porta {device}`),icon:`door-closed`}}},[O.CoverWindow]:{actions:{"cover.open":{phrase:F(`Open the window {device}`,`Apri la finestra {device}`),icon:`app-window`},"cover.close":{phrase:F(`Close the window {device}`,`Chiudi la finestra {device}`),icon:`app-window`}}},[O.CoverShutter]:{actions:{"cover.open":{phrase:F(`Raise the shutter {device}`,`Alza la tapparella {device}`)},"cover.close":{phrase:F(`Lower the shutter {device}`,`Abbassa la tapparella {device}`)}}},[O.CoverAwning]:{actions:{"cover.open":{phrase:F(`Extend the awning {device}`,`Apri la tenda da sole {device}`)},"cover.close":{phrase:F(`Retract the awning {device}`,`Chiudi la tenda da sole {device}`)}}}}}}},uA=x({stepId:l(),entry:rg}),dA=x({path:l().min(1),bytes:n().int().nonnegative(),sha256:l().regex(/^[0-9a-f]{64}$/)}),fA=x({addonId:l(),stepId:l().min(1),entries:C(rg).min(1).max(4),bundle:x({ticket:Si,bytes:n().int().positive(),sha256:l().regex(/^[0-9a-f]{64}$/)}),files:C(dA).min(1).max(64),distribute:y()}),pA=i(`kind`,[x({kind:p(`imported`),modelIds:C(l()).readonly(),distributed:C(x({modelId:l(),nodeId:l(),format:S(Na),ok:y(),error:l().optional()})).readonly()}),x({kind:p(`refused`),reason:S([`transfer-failed`,`checksum-mismatch`,`bundle-mismatch`,`invalid-entry`,`id-taken`]),detail:l()})]),mA={name:`custom-model-registry`,scope:`system`,mode:`collection`,internal:!0,methods:{listModels:A(v(),C(uA).readonly(),{auth:`admin`}),importModelBundle:A(fA,pA,{kind:`mutation`,auth:`admin`,timeoutMs:30*6e4})},vocabulary:{notOperatorFacing:M.ML}},hA=x({engineId:l(),kind:S([`relational`,`vector`]),displayName:l()}),gA={name:`data-store-provider`,scope:`system`,mode:`collection`,internal:!0,methods:{getEngineInfo:A(v(),hA,{auth:`admin`}),get:A(x({namespace:l().optional(),collection:l(),key:l()}),w(),{auth:`admin`}),set:A(x({namespace:l().optional(),collection:l(),key:l(),value:w()}),v(),{kind:`mutation`,auth:`admin`}),query:A(x({namespace:l().optional(),collection:l(),filter:pf.optional(),columns:C(l()).readonly().optional()}),C(_f).readonly(),{auth:`admin`}),insert:A(x({namespace:l().optional(),collection:l(),record:x({id:l().optional(),data:m(l(),w())})}),x({id:h([l(),n()])}),{kind:`mutation`,auth:`admin`}),upsert:A(x({namespace:l().optional(),collection:l(),conflict:C(l()).readonly(),record:vf}),x({id:h([l(),n()])}),{kind:`mutation`,auth:`admin`}),upsertMany:A(x({namespace:l().optional(),collection:l(),conflict:C(l()).readonly(),records:C(vf).readonly()}),x({upserted:n().int()}),{kind:`mutation`,auth:`admin`}),insertMany:A(x({namespace:l().optional(),collection:l(),records:C(vf).readonly()}),x({inserted:n().int()}),{kind:`mutation`,auth:`admin`}),transact:A(x({namespace:l().optional(),guard:xf.optional(),ops:C(bf).readonly()}),x({applied:y(),current:w().optional()}),{kind:`mutation`,auth:`admin`}),update:A(x({namespace:l().optional(),collection:l(),id:l(),data:m(l(),w())}),v(),{kind:`mutation`,auth:`admin`}),delete:A(x({namespace:l().optional(),collection:l(),key:l()}),v(),{kind:`mutation`,auth:`admin`}),deleteWhere:A(x({namespace:l().optional(),collection:l(),filter:mf}),x({deleted:n().int()}),{kind:`mutation`,auth:`admin`}),updateWhere:A(x({namespace:l().optional(),collection:l(),filter:mf,data:m(l(),w())}),x({updated:n().int()}),{kind:`mutation`,auth:`admin`}),count:A(x({namespace:l().optional(),collection:l(),filter:pf.optional()}),n(),{auth:`admin`}),aggregate:A(x({namespace:l().optional(),collection:l(),fields:C(hf).readonly(),filter:pf.optional()}),gf,{auth:`admin`}),histogram:A(x({namespace:l().optional(),collection:l(),field:l(),bucketSize:n().int().positive(),origin:n().int(),filter:pf.optional()}),C(x({bucket:n().int(),count:n().int()})).readonly(),{auth:`admin`}),isEmpty:A(x({namespace:l().optional(),collection:l()}),y(),{auth:`admin`}),declareCollection:A(wf,v(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.INTERNAL}},_A=S([`auto`,`day`,`night`,`schedule`]),vA=x({min:n(),max:n(),step:n()}),yA=x({mode:_A,sensitivity:n().optional().meta(N(`none`)),switchDelaySec:n().optional().meta(N(`duration`)),lastFetchedAt:n()}),bA=x({modes:C(_A),supportsSensitivity:y(),sensitivity:vA.optional(),supportsSwitchDelay:y(),switchDelaySec:vA.optional()}),xA=x({mode:_A.optional(),sensitivity:n().optional(),switchDelaySec:n().optional()}),SA={name:`day-night`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],deviceConfig:{ui:{kind:`derived-form`,builderId:`day-night`,tab:`image`}},methods:{getOptions:A(x({deviceId:n()}),bA),setSettings:A(x({deviceId:n(),settings:xA}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`dayNight.auto`,label:F(`Day/night auto`,`Giorno/notte automatico`),phrase:F(`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:F(`Day mode`,`Modalità giorno`),phrase:F(`Force {device} into day mode`,`Forza {device} in modalità giorno`),icon:`sun`,args:{settings:{mode:`day`}}},{id:`dayNight.night`,label:F(`Night mode`,`Modalità notte`),phrase:F(`Force {device} into night mode`,`Forza {device} in modalità notte`),icon:`moon`,args:{settings:{mode:`night`}}}]})},status:{schema:yA,kind:`poll`},runtimeState:yA,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Day/night`,`Giorno/notte`),order:3070,state:[{kind:`enum`,field:`mode`,label:F(`Day/night mode`,`Modalità giorno/notte`),values:[{value:`auto`,label:F(`Automatic`,`Automatica`)},{value:`day`,label:F(`Day`,`Giorno`),phrase:F(`When {device} switches to day mode`,`Quando {device} passa in modalità giorno`)},{value:`night`,label:F(`Night`,`Notte`),phrase:F(`When {device} switches to night mode`,`Quando {device} passa in modalità notte`)},{value:`schedule`,label:F(`Scheduled`,`Programmata`)}],icon:`sun-moon`}]}},ySe=[{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)`}],bSe={hwaccel:`auto`,probedBestHwaccel:``},CA={name:`decoder`,scope:`system`,mode:`singleton`,preferredProvider:`decoder-nodeav`,methods:{getInfo:A(v(),x({id:l(),name:l(),hwaccel:l().optional(),probedBestHwaccel:l().optional()})),reprobeHwaccel:A(v(),x({backend:l()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.PIPELINE}},wA={name:`detection-pipeline`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[E.Camera],exposesDeviceSettings:!0,methods:{},vocabulary:{noun:F(`Detection pipeline`,`Pipeline di rilevamento`),order:3080}},TA=S([`device`,`integration`]),EA=x({url:l(),label:l(),target:TA,host:l()}),DA={name:`device-admin-link`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{getAdminLink:A(x({deviceId:n().int().nonnegative()}),EA.nullable(),{auth:`admin`})},vocabulary:{noun:F(`Admin link`,`Link di amministrazione`),order:3090}},OA=S([`online`,`sleeping`,`offline`,`unknown`]),kA=a(()=>x({childNativeId:l(),name:l(),type:S(E),status:OA,metadata:x({model:l().optional(),serialNumber:l().optional(),uid:l().optional(),rtspChannel:n().int().nonnegative().optional(),isBattery:y().optional(),isDoorbell:y().optional(),isMultifocal:y().optional(),externalLocation:l().optional(),manufacturer:l().optional(),integration:l().optional()}).default({}),alreadyAdopted:y(),adoptedDeviceId:n().int().nonnegative().nullable(),capabilities:C(l()).readonly().optional(),features:C(l()).readonly().optional(),sourceInfo:Xg.optional(),children:C(kA).readonly().optional(),parentStableId:l().optional()})),AA=x({id:l(),label:l(),isDefault:y().optional()}),jA=x({search:l().optional(),area:l().optional(),manufacturer:l().optional(),adoptedOnly:y().optional(),unadoptedOnly:y().optional()}),MA=x({integrationId:l(),page:n().int().positive().default(1),pageSize:n().int().positive().max(2e4).default(50),filter:l().optional(),filterText:jA.optional()}),NA=x({candidates:C(kA).readonly(),totalCount:n().int().nonnegative(),page:n().int().positive(),pageSize:n().int().positive()}),PA=x({integrationId:l(),childNativeId:l()}),FA=x({lastDiscoveryAt:n().int().nonnegative().nullable(),candidateCount:n().int().nonnegative(),adoptedCount:n().int().nonnegative(),lastError:l().nullable()}),xSe=x({name:l().min(1).optional(),hiddenChildIds:C(l()).optional()}),IA=x({integrationId:l(),childNativeIds:C(l()).min(1),filter:l().optional(),importLocations:y().optional(),perCandidate:m(l(),xSe).optional()}),LA=x({adopted:C(x({childNativeId:l(),parentDeviceId:n().int().nonnegative(),accessoryDeviceIds:C(n().int().nonnegative()).readonly()})).readonly()}),RA=x({integrationId:l(),camDeviceId:n().int().nonnegative()}),zA=x({camDeviceId:n().int().nonnegative(),resetToSource:y().optional()}),BA=x({changed:y(),rebuiltChildren:n().int().nonnegative(),removedChildren:n().int().nonnegative().optional()}),VA={name:`device-adoption`,scope:`system`,mode:`collection`,status:{schema:FA,kind:`poll`},methods:{listCandidateFilters:A(x({integrationId:l()}),x({filters:C(AA)}),{auth:`admin`}),listCandidates:A(MA,NA,{auth:`admin`}),getCandidate:A(PA,kA.nullable(),{auth:`admin`}),refresh:A(x({integrationId:l()}),FA,{kind:`mutation`,auth:`admin`}),adopt:A(IA,LA,{kind:`mutation`,auth:`admin`}),release:A(RA,v(),{kind:`mutation`,auth:`admin`}),resync:A(zA,BA,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`device adoption — an onboarding flow, not an action`}},HA=i(`state`,[x({state:p(`absent`)}),x({state:p(`ready`),subject:l(),fingerprintSha256:l(),validTo:l()}),x({state:p(`unavailable`),reason:l()})]),UA=x({selfEnrollment:S([`allowed`,`disabled`])}),WA={name:`device-credentials`,scope:`system`,mode:`singleton`,methods:{listDeviceCredentials:A(x({userId:l().min(1).optional(),includeRevoked:y().default(!1)}),C(ume).readonly(),{auth:`admin`}),startEnrollment:A(x({userId:l().min(1),deviceName:l().min(1).max(80)}),dme,{kind:`mutation`,auth:`admin`,caller:`required`}),revokeDeviceCredential:A(x({id:l().min(1)}),x({revoked:y(),sessionsEnded:n().int(),status:wg}),{kind:`mutation`,auth:`admin`,caller:`required`}),getDeviceCertificateSettings:A(x({}),UA,{auth:`admin`}),setDeviceCertificateSettings:A(UA,UA,{kind:`mutation`,auth:`admin`}),deleteDeviceCredential:A(x({id:l().min(1)}),x({result:S([`deleted`,`live`,`unknown`])}),{kind:`mutation`,auth:`admin`,caller:`required`}),getDeviceCaStatus:A(x({}),HA,{auth:`admin`}),renameDeviceCredential:A(x({id:l().min(1),deviceName:l().min(1).max(80)}),x({renamed:y()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.IDENTITY}},SSe=64,GA=/^[a-z][a-z0-9_]*$/,CSe=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(`.`)),KA=l().max(64).regex(GA);function qA(e){return CSe.has(e)}function JA(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 wSe(e,t){let n=JA(e);if(!qA(n)&&!t(n))return n;for(let e=2;;e+=1){let r=`${n}_${e}`;if(!t(r))return r}}function TSe(e,t){return e.length===0?{ok:!1,reason:`empty`}:e.length>64?{ok:!1,reason:`too-long`}:GA.test(e)?qA(e)?{ok:!1,reason:`reserved`}:t(e)?{ok:!1,reason:`taken`}:{ok:!0,alias:e}:{ok:!1,reason:`grammar`}}var YA=4096,ESe=50,DSe=4096,OSe=`—`,XA=l().min(1).max(YA),kSe=`now`,ASe=`camera`,ZA=h([l(),n(),y()]),QA=x({deviceId:n().int(),values:m(l().min(1).max(64),ZA).optional()}),jSe=`values`,MSe=cu(),$A=[`too-long`,`syntax`,`forbidden-syntax`,`forbidden-member`,`unknown-filter`,`ambiguous-field`,`busy`,`budget-exceeded`,`timeout`,`output-too-large`,`render-failed`,`out-of-scope`,`unavailable`],ej=x({reason:S($A),message:l()}),tj=[`unknown-alias`,`unknown-field`,`no-field`,`unavailable`],nj=x({ref:l(),reason:S(tj)}),rj=i(`ok`,[x({ok:p(!0),text:l(),trace:C(nj)}),x({ok:p(!1),refusal:ej,trace:C(nj)})]);function ij(e){return e.replace(/-/g,`_`)}function aj(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function oj(e,t){let n=e;for(let e of t)if(Array.isArray(n)&&typeof e==`number`)n=n[e];else if(aj(n)&&Object.hasOwn(n,String(e)))n=n[String(e)];else return;return n}function NSe(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||ij(e)===n);if(i!==void 0){let n=t.slice(1);if(n.length===0)return{kind:`missing`,reason:`no-field`};let r=oj(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 aj(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=oj(e.slices[o],t);return s===void 0?{kind:`missing`,reason:`unknown-field`}:{kind:`value`,cap:o,fieldPath:t,value:s}}var sj=x({zoneKey:l(),label:l(),icon:Lh.nullable(),locationKeys:C(l())});function PSe(e){return e.trim().toLowerCase()}var cj=[`mac`,`serial`,`machine-uuid`,`vendor-uid`,`hostname`,`ip`],lj=S(cj),uj=S([`read`,`derived`]),FSe=/^[0-9a-f]{2}(?::[0-9a-f]{2}){5}$/,dj=/^[a-z0-9][a-z0-9._-]*:[^\sA-Z]+$/,fj=/^[0-9a-f][0-9a-f-]{7,}$/,pj=/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;function mj(e){return x({value:e,origin:uj,readAt:n().int().nonnegative()}).strict()}var ISe=mj(l().regex(FSe)),LSe=mj(l().regex(dj)),RSe=mj(l().regex(fj)),zSe=mj(l().regex(dj)),BSe=mj(l().regex(pj)),VSe=mj(h([_(),o()])),HSe=x({value:l().min(1),origin:uj,readAt:n().int().nonnegative()}).strict(),hj=x({mac:C(ISe).min(1).readonly().optional(),serial:LSe.optional(),"machine-uuid":RSe.optional(),"vendor-uid":zSe.optional(),hostname:BSe.optional(),ip:VSe.optional()}).strict(),USe={mac:`strong`,serial:`strong`,"machine-uuid":`strong`,"vendor-uid":`strong`,hostname:`weak`,ip:`weak`};function WSe(e){return USe[e]}function gj(e){return cj.every(t=>e[t]===void 0)}var GSe=/^(?:unknown|none|n\/?a|null|undefined|default|0+|-+)$/i,KSe=new Set([`00:00:00:00:00:00`,`ff:ff:ff:ff:ff:ff`]);function _j(e){return{ok:!1,reason:e}}function vj(e){let t=e.trim().toLowerCase().replace(/[\s:.-]/g,``);if(!/^[0-9a-f]{12}$/.test(t))return _j(`not a 48-bit MAC`);let n=(t.match(/../g)??[]).join(`:`);return KSe.has(n)?_j(`placeholder MAC`):{ok:!0,value:n}}function qSe(e){return e.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,`-`).replace(/^[-._]+|[-._]+$/g,``)}function yj(e,t,n){let r=qSe(e);if(r.length===0)return _j(`no ${n}`);let i=t.trim().toLowerCase().replace(/\s+/g,``);return i.length===0?_j(`blank value`):GSe.test(i)?_j(`placeholder value`):{ok:!0,value:`${r}:${i}`}}function JSe(e){let t=e.trim().toLowerCase().replace(/^\{|\}$/g,``);return fj.test(t)?/^[0-]+$/.test(t)||/^[f-]+$/.test(t)?_j(`placeholder uuid`):{ok:!0,value:t}:_j(`not a uuid`)}function bj(e){return h([_(),o()]).safeParse(e).success}function YSe(e){let t=e.trim().toLowerCase().replace(/\.$/,``);if(t.length===0)return _j(`blank hostname`);if(bj(t))return _j(`an address, not a hostname`);let n=t.split(`.`)[0]??``;return pj.test(n)?n===`localhost`?_j(`placeholder hostname`):{ok:!0,value:n}:_j(`not a hostname`)}function XSe(e){let t=e.trim().toLowerCase().replace(/^\[|\]$/g,``);return bj(t)?t===`0.0.0.0`||t===`::`||t===`::1`||t.startsWith(`127.`)?_j(`loopback or unspecified address`):{ok:!0,value:t}:_j(`not an IP address`)}function xj(e){return e==null||e.trim().length===0}function Sj(e,t={}){let n=t.readAt??Date.now(),r=e=>t.originByKey?.[e]??t.origin??`read`,i=(e,t)=>({value:t,origin:r(e),readAt:n}),a=[],o=(e,t,n)=>{if(n.ok)return i(e,n.value);a.push({key:e,value:t,reason:n.reason})},s=e.mac===null||e.mac===void 0?[]:[e.mac].flat(),c=[];for(let e of s){if(xj(e))continue;let t=o(`mac`,e,vj(e));t!==void 0&&!c.some(e=>e.value===t.value)&&c.push(t)}let l=e.serial===null||e.serial===void 0||xj(e.serial.serial)?void 0:o(`serial`,`${e.serial.manufacturer}:${e.serial.serial}`,yj(e.serial.manufacturer,e.serial.serial,`manufacturer`)),u=e.vendorUid===null||e.vendorUid===void 0||xj(e.vendorUid.id)?void 0:o(`vendor-uid`,`${e.vendorUid.vendor}:${e.vendorUid.id}`,yj(e.vendorUid.vendor,e.vendorUid.id,`vendor`)),d=xj(e.machineUuid)?void 0:o(`machine-uuid`,e.machineUuid,JSe(e.machineUuid)),f=xj(e.host)?null:e.host.trim(),p=f!==null&&bj(f.toLowerCase().replace(/^\[|\]$/g,``)),m=xj(e.hostname)?p?null:f:e.hostname,h=xj(e.ip)?p?f:null:e.ip,g=m===null?void 0:o(`hostname`,m,YSe(m)),_=h===null?void 0:o(`ip`,h,XSe(h));return{identifiers:{...c.length>0?{mac:c}:{},...l===void 0?{}:{serial:l},...d===void 0?{}:{"machine-uuid":d},...u===void 0?{}:{"vendor-uid":u},...g===void 0?{}:{hostname:g},..._===void 0?{}:{ip:_}},rejected:a}}function Cj(e,t){return e.value===t.value&&e.origin===t.origin}function wj(e,t){return t!==void 0&&Cj(e,t)?t:e}function ZSe(e,t,n=[]){let r=e??{},i=t??{},a=new Set(n),o=a.has(`mac`)?r.mac:i.mac?.map(e=>wj(e,r.mac?.find(t=>Cj(t,e)))),s=e=>{if(a.has(e))return r[e];let t=i[e];return t===void 0?void 0:wj(t,r[e])},c=s(`serial`),l=s(`machine-uuid`),u=s(`vendor-uid`),d=s(`hostname`),f=s(`ip`),p={...o!==void 0&&o.length>0?{mac:o}:{},...c===void 0?{}:{serial:c},...l===void 0?{}:{"machine-uuid":l},...u===void 0?{}:{"vendor-uid":u},...d===void 0?{}:{hostname:d},...f===void 0?{}:{ip:f}};return gj(p)?null:p}function QSe(e,t){let n=e=>e==null||gj(e)?``:JSON.stringify(cj.map(t=>[t,e[t]??null]).map(([e,t])=>[e,t===null?null:[t].flat().map(e=>[e.value,e.origin,e.readAt])]));return n(e)===n(t)}var Tj=S([`auto`,`proposal`]),Ej=x({key:lj,value:l()}),Dj=x({deviceId:n().int(),addonId:l(),integrationId:l().nullable()}),Oj=x({a:Dj,b:Dj,keys:C(Ej).readonly(),confidence:Tj}),kj=i(`status`,[x({status:p(`unknown`),reason:l()}),x({status:p(`answered`),pairs:C(Oj).readonly(),undeclaredDeviceIds:C(n().int()).readonly()})]),Aj=[`same-device`,`poe-power`],jj=S(Aj),Mj=S([`proposed`,`linked`,`dismissed`]),Nj=S([`auto`,`operator`]),Pj=x({addonId:l().min(1),stableId:l().min(1),deviceId:n().int()}),Fj=x({kind:jj,a:Pj,b:Pj,state:Mj,origin:Nj,evidence:C(Ej).readonly(),evidenceGone:p(!0).optional(),createdAt:n().int().nonnegative(),decidedAt:n().int().nonnegative().optional()}),Ij=Fj.extend({id:l().min(1)}),Lj={"same-device":{directional:!1,attachingRole:null,contributions:[]},"poe-power":{directional:!0,attachingRole:O.PoePort,contributions:[{cap:`power-source`,targetId:`switch`,host:`b`,source:`a`,sourceCap:`switch`,sourceField:`on`}]}};function $Se(e,t){let n=Lj[e].attachingRole;return n===null||t===n?null:`attaching-side-role`}function Rj(e){return`${e.addonId}/${e.stableId}`}function eCe(e,t,n){let r=Rj(t),i=Rj(n);return Lj[e].directional||r<=i?`${e}:${r}|${i}`:`${e}:${i}|${r}`}var zj=i(`status`,[x({status:p(`not-loaded`),reason:l()}),x({status:p(`answered`),links:C(Ij).readonly()})]),Bj=S([`not-loaded`,`unknown-link`,`wrong-state`]),Vj=i(`ok`,[x({ok:p(!0),link:Ij}),x({ok:p(!1),reason:Bj,message:l()})]),Hj=S([`evidence-gone`,`device-removed`,`operator-unlinked`]),tCe=x({linkId:l(),kind:jj,aDeviceId:n().int(),bDeviceId:n().int(),origin:Nj,reason:Hj.optional()}),nCe=50,rCe=200,Uj=x({caps:C(l()).readonly().optional(),actions:C(l()).readonly().optional(),mode:S([`any`,`all`]).optional()}),Wj=x({locations:C(l()).readonly().optional(),integrationIds:C(l()).readonly().optional(),types:C(l()).readonly().optional()}),Gj=x({text:l().optional(),requires:Uj.optional(),filters:Wj.optional(),includeIncompatible:y().optional(),contextDeviceId:n().optional(),ids:C(n()).readonly().optional(),cursor:l().nullable().optional(),limit:n().int().min(1).max(200).optional()}),Kj=x({cap:l(),path:l(),label:l(),reading:l().nullable(),unit:l().nullable().optional(),quantity:la.optional()}),qj=x({id:n(),name:l(),type:S(E),location:l().nullable(),integrationId:l().nullable(),integrationLabel:l().nullable(),online:y().nullable(),disabled:y(),compatible:y(),values:C(Kj).readonly()}),Jj=x({value:l(),count:n()}),Yj=x({id:l(),label:l(),count:n()}),Xj=x({locations:C(Jj).readonly(),integrations:C(Yj).readonly(),types:C(Jj).readonly()}),Zj=x({items:C(qj).readonly(),nextCursor:l().nullable(),total:n(),compatibleTotal:n(),fleetTotal:n(),hiddenIncompatible:n(),facets:Xj,suggested:C(qj).readonly(),missingIds:C(n()).readonly()}),Qj=x({connected:y(),deviceCount:n(),error:l().optional(),motionSliceWriter:p(`orchestrator`).optional()}),iCe=x({externalId:l(),name:l(),type:l(),metadata:m(l(),w()).optional()}),$j=i(`kind`,[x({kind:p(`mdns`),serviceType:l().min(1),instancePattern:l().optional()}),x({kind:p(`ws-discovery`),types:C(l()).optional()}),x({kind:p(`ssdp`),searchTarget:l().min(1)}),x({kind:p(`udp-broadcast`),port:n().int().min(1).max(65535),payloadHex:l().regex(/^([0-9a-fA-F]{2})*$/),listenPort:n().int().min(1).max(65535).optional()}),x({kind:p(`http-probe`),port:n().int().min(1).max(65535),path:l().startsWith(`/`),method:S([`GET`,`POST`]).default(`GET`),bodyText:l().optional(),contentType:l().optional(),tls:y().default(!1),acceptStatus:C(n().int()).optional()}),x({kind:p(`custom`),reason:l().min(1)})]),eM=x({modeIndex:n().int().min(0),host:l(),port:n().int(),http:x({status:n().int(),headers:m(l(),l()),bodyText:l()}).optional(),mdns:x({instance:l(),host:l(),port:n().int(),txt:m(l(),l())}).optional(),udp:x({payloadHex:l()}).optional(),wsd:x({xaddrs:C(l()),types:C(l()),scopes:C(l())}).optional()}),tM=x({stableId:l(),type:S(E),suggestedName:l(),prefilledConfig:m(l(),w()),sourceInfo:Xg.optional(),alreadyOnboarded:y().optional(),onboardedDeviceId:n().optional(),onboardedName:l().optional(),setupIntegration:y().optional(),parentStableId:l().optional(),selectable:y().optional(),needsParams:C(l()).optional()}),nM=x({id:n(),stableId:l(),addonId:l(),type:l(),name:l(),parentDeviceId:n().nullable(),online:y(),features:C(l()),config:m(l(),w()),sourceInfo:Xg.optional()}),rM=x({status:S([`ok`,`error`]),labels:C(l()).optional(),error:l().optional()}),iM=w(),aM={name:`device-provider`,scope:`system`,mode:`collection`,methods:{start:A(v(),v(),{kind:`mutation`}),stop:A(v(),v(),{kind:`mutation`}),getStatus:A(v(),Qj),getDevices:A(v(),C(x({id:l(),name:l(),type:l()}))),reloadDevice:A(x({stableId:l()}),x({deviceId:n()}),{kind:`mutation`,timeoutMs:3*6e4}),supportsDiscovery:A(x({}),y()),discoverDevices:A(x({params:m(l(),w()).optional()}),C(tM),{kind:`mutation`,auth:`admin`}),getDiscoveryModes:A(x({}),C($j)),classifyDiscoveryHits:A(x({hits:C(eM),params:m(l(),w()).optional()}),C(tM),{kind:`mutation`,auth:`admin`}),getDiscoveryParamsSchema:A(x({}),iM),getManualCreationType:A(x({integrationId:l().optional()}),x({deviceType:S(E).nullable()})),adoptDiscoveredDevice:A(x({candidate:tM,integrationId:l().optional()}),nM,{kind:`mutation`,auth:`admin`}),supportsManualCreation:A(x({}),y()),getChildCreationSchema:A(x({type:S(E),integrationId:l().optional()}),iM),createDevice:A(x({type:S(E),config:m(l(),w()),integrationId:l().optional()}),nM,{kind:`mutation`,auth:`admin`}),testCreationField:A(x({type:S(E),key:l(),value:w(),formValues:m(l(),w()).optional()}),rM,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.INTERNAL}},oM=i(`kind`,[x({kind:p(`mdns`),serviceType:l(),instance:l(),host:l(),address:l().nullable(),port:n().int(),txt:m(l(),l())}),x({kind:p(`ssdp`),host:l(),port:n().int(),target:l(),headers:m(l(),l())})]),aCe=x({addonId:l(),candidate:tM,firstSeenAt:n(),lastSeenAt:n(),dismissed:y()}),sM=x({id:l(),addonId:l(),candidate:tM,firstSeenAt:n(),lastSeenAt:n(),dismissed:y()}),cM=x({childKey:l(),section:l(),order:n().optional(),collapsed:y().optional()}),oCe=x({unit:l().min(1).optional(),precision:n().int().min(0).max(10).optional()}),lM=x({icon:l().min(1).optional(),label:l().min(1).optional(),unit:l().min(1).optional(),precision:n().int().min(0).max(10).optional(),hidden:y().optional(),perCap:m(l(),oCe).optional()}),uM=x({unit:l().min(1).optional(),precision:n().int().min(0).max(10).optional(),icon:l().min(1).optional()}),dM=x({id:n(),stableId:l(),addonId:l(),type:S(E),name:l(),alias:KA.optional(),location:l().nullable(),tags:Hh.optional(),disabled:y(),parentDeviceId:n().nullable(),role:l().nullable().optional(),online:y(),probed:y().optional(),features:C(l()),isCamera:y(),config:m(l(),w()),secretConfigPaths:C(l()).optional(),metadata:m(l(),w()).nullable().optional(),identifiers:hj.optional(),attachedIdentifiers:hj.optional(),sourceInfo:Xg.optional(),integrationId:l().optional(),linkDeviceId:n().nullable().optional(),primaryChildEntityId:l().nullable().optional(),childLayout:C(cM).readonly().optional(),primaryChildPreference:C(l()).readonly().optional(),display:lM.optional()}),fM=x({key:l(),value:w(),description:l().optional()}),pM=S([`manual`]),mM=x({deviceId:n(),name:l(),location:l().nullable(),features:C(l()),producesTrackedEvents:y().optional()}),hM=x({deviceIds:C(n().int().positive()),trackedDeviceIds:C(n().int().positive()).optional()}),gM={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:[E.Camera],sourceCaps:`any`,cardinality:`many`,value:hM},sCe=x({deviceId:n(),mode:pM,devices:C(mM)}),_M=x({deviceId:n(),entries:C(x({capName:l(),kind:S([`native`,`wrapped`]),providerAddonId:l(),providerNodeId:l(),nativeAddonId:l(),implementedMethods:C(l()).optional()}))}),vM=i(`kind`,[x({kind:p(`value`),wrapperAddonId:l().nullable()}),x({kind:p(`missing`)}),x({kind:p(`failed`),error:l()})]),cCe=x({id:n(),stableId:l(),type:l(),name:l(),location:l().nullable(),tags:Hh.optional(),disabled:y(),parentDeviceId:n().nullable(),role:l().nullable().optional()}),lCe=x({id:n(),stableId:l(),addonId:l(),type:l(),name:l(),userNamed:y().optional(),location:l().nullable(),tags:Hh.optional(),disabled:y(),parentDeviceId:n().nullable(),metadata:m(l(),w()).nullable().optional(),identifiers:hj.optional(),attachedIdentifiers:hj.optional(),sourceInfo:Xg.optional(),integrationId:l().optional(),linkDeviceId:n().nullable().optional(),primaryChildEntityId:l().nullable().optional(),childLayout:C(cM).readonly().optional(),primaryChildPreference:C(l()).readonly().optional(),role:l().nullable().optional(),display:lM.optional()}),uCe=w().nullable(),dCe=x({streamId:l(),width:n().optional(),height:n().optional(),codec:l().optional(),fps:n().optional(),bitrateKbps:n().optional()}),fCe=x({addonId:l(),stableId:l(),id:n(),type:l(),name:l(),location:l().nullable().optional(),disabled:y().optional(),parentDeviceId:n().nullable(),role:l().nullable().optional(),features:C(l()).optional(),config:m(l(),w()),secretConfigPaths:C(l()).optional()}),yM=x({deviceId:n().int().positive(),deletedAt:n(),providerAddonId:l()}),bM=2160*60*60*1e3,xM=x({deviceId:n().int().positive(),stores:m(l(),n().int().nonnegative())}),SM=x({status:S([`skipped`,`dry-run`,`cleaned`]),reason:l().nullable(),devices:C(xM),unreachable:C(l())}),pCe=x({deviceId:n()}),mCe=x({deviceId:n(),data:m(l(),w()),secretConfigPaths:C(l()).optional()}),CM=S([`off`,`on`,`not-offered`,`unreachable`]),wM=x({deviceId:n(),switchId:$d,outcome:CM,detail:l().optional()}),TM=x({sourceId:n(),targetId:n(),switches:C(wM).readonly(),sourceStillLive:C($d).readonly(),swapped:y()}),EM={name:`device-manager`,scope:`system`,mode:`singleton`,extensionSlots:[gM],methods:{allocateDeviceId:A(x({addonId:l(),stableId:l()}),x({id:n()}),{kind:`mutation`}),migrateDevice:A(x({sourceId:n(),targetId:n()}),TM,{kind:`mutation`,auth:`admin`,timeoutMs:12*6e4}),registerDevice:A(fCe,v(),{kind:`mutation`}),removeDevice:A(pCe,v(),{kind:`mutation`}),persistConfig:A(mCe,v(),{kind:`mutation`,auth:`admin`}),loadConfig:A(x({deviceId:n()}),m(l(),w()),{auth:`admin`}),loadRuntimeState:A(x({deviceId:n()}),m(l(),w()),{auth:`admin`}),loadMeta:A(x({deviceId:n()}),lCe.nullable()),setName:A(x({deviceId:n(),name:l(),stampUserNamed:y().optional()}),v(),{kind:`mutation`,auth:`admin`}),setAlias:A(x({deviceId:n(),alias:l()}),i(`ok`,[x({ok:p(!0),alias:KA}),x({ok:p(!1),reason:S([`empty`,`too-long`,`grammar`,`reserved`,`taken`]),takenBy:n().optional()})]),{kind:`mutation`,auth:`admin`}),renderDeviceTemplates:A(x({templates:C(XA).max(64),allowedDeviceIds:C(n().int()).optional(),thisDevice:QA.optional()}),x({results:C(rj)}),{auth:`admin`}),checkDeviceTemplates:A(x({templates:C(l()).max(64),allowedDeviceIds:C(n().int()).optional(),thisDevice:QA.optional()}),x({results:C(i(`ok`,[x({ok:p(!0),aliases:C(x({alias:l(),deviceId:n().int().nullable(),allowed:y(),reads:C(l())})),readsClock:y()}),x({ok:p(!1),refusal:ej})]))}),{auth:`admin`}),setLocation:A(x({deviceId:n(),location:l().nullable()}),v(),{kind:`mutation`,auth:`admin`}),setTags:A(x({deviceId:n(),tags:Hh}),v(),{kind:`mutation`,auth:`admin`}),setType:A(x({deviceId:n(),type:S(E)}),v(),{kind:`mutation`,auth:`admin`}),setIntegrationId:A(x({deviceId:n(),integrationId:l()}),v(),{kind:`mutation`,auth:`admin`}),setLinkDeviceId:A(x({deviceId:n(),linkDeviceId:n().nullable()}),v(),{kind:`mutation`,auth:`admin`}),setPrimaryChildEntityId:A(x({deviceId:n(),primaryChildEntityId:l().nullable()}),v(),{kind:`mutation`,auth:`admin`}),setChildLayout:A(x({deviceId:n(),childLayout:C(cM).readonly()}),v(),{kind:`mutation`,auth:`admin`}),setPrimaryChildPreference:A(x({deviceId:n(),primaryChildPreference:C(l()).readonly()}),v(),{kind:`mutation`,auth:`admin`}),setDisplay:A(x({deviceId:n(),display:lM.nullable()}),v(),{kind:`mutation`,auth:`admin`}),getRoleDisplayDefaults:A(x({}),x({defaults:m(l(),uM)}),{role:`viewer`,kind:`query`}),setRoleDisplayDefaults:A(x({defaults:m(l(),uM)}),v(),{kind:`mutation`,auth:`admin`}),getWireableFields:A(x({deviceId:n(),includeSynthesizable:y().optional()}),x({caps:C(x({cap:l(),fields:C(x({path:l(),kind:S([`string`,`number`,`boolean`,`enum`,`union`]),unionMembers:C(S([`string`,`number`,`boolean`])).optional(),enumValues:C(l()).optional(),item:y().optional(),quantity:la.optional()})).readonly(),itemArray:x({path:l(),keyField:l()}).optional()})).readonly()}),{kind:`query`}),setRole:A(x({deviceId:n(),role:l().nullable()}),v(),{kind:`mutation`,auth:`admin`}),applyInitialMeta:A(x({deviceId:n(),name:l().optional(),location:l().nullable().optional(),tags:Hh.optional(),type:S(E).optional(),integrationId:l().optional(),linkDeviceId:n().nullable().optional(),role:l().nullable().optional()}),v(),{kind:`mutation`,auth:`admin`}),setMetadata:A(x({deviceId:n(),patch:m(l(),w())}),v(),{kind:`mutation`,auth:`admin`}),setIdentifiers:A(x({deviceId:n(),identifiers:hj.nullable(),unread:C(lj).optional()}),v(),{kind:`mutation`,auth:`admin`}),listIdentityCandidates:A(x({}),kj,{kind:`query`,auth:`admin`}),setAttachedIdentifiers:A(x({deviceId:n(),identifiers:hj.nullable(),unread:C(lj).optional()}),v(),{kind:`mutation`,auth:`admin`}),listIdentityLinks:A(x({deviceId:n().int().optional()}),zj,{kind:`query`,auth:`admin`}),confirmIdentityLink:A(x({linkId:l().min(1)}),Vj,{kind:`mutation`,auth:`admin`}),dismissIdentityLink:A(x({linkId:l().min(1)}),Vj,{kind:`mutation`,auth:`admin`}),unlinkIdentity:A(x({linkId:l().min(1)}),Vj,{kind:`mutation`,auth:`admin`}),listLocations:A(v(),C(l())),addLocation:A(x({name:l()}),v(),{kind:`mutation`,auth:`admin`}),removeLocation:A(x({name:l(),cascade:y().optional()}),v(),{kind:`mutation`,auth:`admin`}),renameLocation:A(x({from:l(),to:l()}),x({moved:n()}),{kind:`mutation`,auth:`admin`}),listLocationIcons:A(v(),C(xme),{role:`viewer`}),setLocationIcon:A(x({location:l(),icon:Lh.nullable()}),v(),{kind:`mutation`,auth:`admin`}),listLocationDescriptions:A(v(),C(Cme)),setLocationDescription:A(x({location:l(),description:l().max(400).nullable()}),v(),{kind:`mutation`,auth:`admin`}),listSiteZones:A(v(),C(sj),{role:`viewer`}),setSiteZone:A(x({name:l(),icon:Lh.nullable().optional()}),v(),{kind:`mutation`,auth:`admin`}),removeSiteZone:A(x({name:l()}),v(),{kind:`mutation`,auth:`admin`}),renameSiteZone:A(x({from:l(),to:l()}),v(),{kind:`mutation`,auth:`admin`}),setLocationZone:A(x({location:l(),zone:l().nullable()}),v(),{kind:`mutation`,auth:`admin`}),setDisabled:A(x({deviceId:n(),disabled:y()}),v(),{kind:`mutation`,auth:`admin`}),listPersistedByAddon:A(x({addonId:l()}),C(cCe)),listAll:A(x({addonId:l().optional(),projection:S([`full`,`slim`]).optional(),isCamera:y().optional(),deviceIds:C(n()).optional()}),C(dM),{role:`viewer`}),search:A(Gj,Zj,{role:`viewer`}),getDevice:A(x({deviceId:n()}),dM.nullable()),getChildren:A(x({parentDeviceId:n()}),C(dM),{role:`viewer`}),getChildrenBatch:A(x({parentDeviceIds:C(n()).max(256)}),m(l(),C(dM))),getLinkedDevices:A(x({deviceId:n()}),x({mode:pM,devices:C(mM)}),{role:`viewer`}),getLinkedDevicesBatch:A(x({deviceIds:C(n())}),C(sCe),{role:`viewer`}),getStreamSources:A(x({deviceId:n()}),C(vne)),getConfigSchema:A(x({deviceId:n()}),C(fM)),getSettingsSchema:A(x({deviceId:n()}),uCe),updateConfig:A(x({deviceId:n(),values:m(l(),w())}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),enable:A(x({deviceId:n()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),disable:A(x({deviceId:n()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),remove:A(x({deviceId:n()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),listDeletedSince:A(x({sinceMs:n()}),C(yM).readonly(),{auth:`admin`}),cleanupDeletedDevicesData:A(x({confirm:y()}),SM,{kind:`mutation`,auth:`admin`}),removeByIntegration:A(x({integrationId:l()}),x({removed:n()}),{kind:`mutation`,auth:`admin`}),getStreamProfileMap:A(x({deviceId:n()}),m(l(),l().nullable())),setStreamProfileMap:A(x({deviceId:n(),profileMap:m(l(),l().nullable())}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),probeStreams:A(x({deviceId:n()}),C(dCe),{kind:`mutation`,auth:`admin`}),getBindings:A(x({deviceId:n()}),_M,{role:`viewer`}),getBindingsBatch:A(x({deviceIds:C(n())}),C(_M)),getAllBindings:A(x({}),C(_M)),listDeviceIdsByCaps:A(x({capNames:C(l().min(1)).min(1).max(16)}),C(n()),{role:`viewer`}),setWrapperActive:A(x({deviceId:n(),capName:l(),wrapperAddonId:l(),active:y()}),v(),{kind:`mutation`,auth:`admin`}),getWrapperActivation:A(x({deviceId:n(),capName:l().min(1)}),vM),listWrappersForCap:A(x({capName:l()}),C(l())),listBindableCapsForDeviceType:A(x({deviceType:l()}),C(x({capName:l(),wrappers:C(l())}))),getDeviceSettingsAggregate:A(x({deviceId:n()}),sS.nullable()),getDeviceLiveInfoAggregate:A(x({deviceId:n()}),sS.nullable(),{role:`viewer`}),getDeviceAggregate:A(x({deviceId:n()}),x({settings:sS.nullable(),live:sS.nullable()})),runDeviceAction:A(x({deviceId:n().int().nonnegative(),action:l().min(1),input:w()}),w(),{kind:`mutation`}),updateDeviceField:A(x({deviceId:n(),writerCapName:l(),writerAddonId:l(),key:l(),value:w()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),updateDeviceFieldsBatch:A(x({deviceId:n(),changes:C(x({writerCapName:l(),writerAddonId:l(),key:l(),value:w()}))}),x({success:p(!0),failures:C(x({writerCapName:l(),writerAddonId:l(),error:l()}))}),{kind:`mutation`,auth:`admin`}),discoverDevices:A(x({addonId:l()}),C(tM),{kind:`mutation`,auth:`admin`}),adoptDevice:A(x({addonId:l(),candidate:tM,integrationId:l().optional()}),nM,{kind:`mutation`,auth:`admin`}),getCreationSchema:A(x({addonId:l(),type:S(E),integrationId:l().optional()}),w().nullable()),createDevice:A(x({addonId:l(),type:S(E),config:m(l(),w()),integrationId:l().optional()}),nM,{kind:`mutation`,auth:`admin`}),testCreationField:A(x({addonId:l(),type:S(E),key:l(),value:w(),formValues:m(l(),w()).optional()}),rM,{kind:`mutation`,auth:`admin`}),adoptionListCandidateFilters:A(x({addonId:l(),integrationId:l()}),x({filters:C(AA)}),{auth:`admin`}),adoptionListCandidates:A(MA.extend({addonId:l()}),NA,{auth:`admin`}),adoptionRefresh:A(x({addonId:l(),integrationId:l()}),FA,{kind:`mutation`,auth:`admin`}),adoptionAdopt:A(IA.extend({addonId:l()}),LA,{kind:`mutation`,auth:`admin`}),adoptionRelease:A(RA.extend({addonId:l()}),v(),{kind:`mutation`,auth:`admin`}),adoptionStartJob:A(IA.extend({addonId:l()}),x({jobId:l()}),{kind:`mutation`,auth:`admin`}),adoptionListJobs:A(x({addonId:l(),integrationId:l().optional()}),C(Qd).readonly(),{auth:`admin`}),adoptionCancelJob:A(x({jobId:l()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),adoptionResync:A(zA,BA,{kind:`mutation`,auth:`admin`}),discoveryProviders:A(x({}),x({providers:C(x({addonId:l(),label:l()})).readonly()}),{auth:`admin`}),discoverAllProviders:A(x({subnets:C(l()).optional()}),x({groups:C(x({addonId:l(),label:l(),candidates:C(tM).readonly(),error:l().nullable()})).readonly()}),{kind:`mutation`,auth:`admin`}),discoverProvider:A(x({addonId:l(),params:m(l(),w()).optional(),subnets:C(l()).optional()}),x({candidates:C(tM).readonly()}),{kind:`mutation`,auth:`admin`}),listDiscoveryProposals:A(x({}),x({proposals:C(sM).readonly()}),{auth:`admin`}),dismissDiscoveryProposal:A(x({id:l()}),x({dismissed:y()}),{kind:`mutation`,auth:`admin`}),reportDiscoveryObservations:A(x({observations:C(oM).max(512)}),x({proposed:n().int()}),{kind:`mutation`,auth:`admin`}),runDiscoverySweep:A(x({}),x({providers:n().int(),proposed:n().int()}),{kind:`mutation`,auth:`admin`,timeoutMs:12e4}),providerCreationType:A(x({addonId:l(),integrationId:l().optional()}),x({deviceType:S(E).nullable()}),{auth:`admin`}),providerDiscoveryParamsSchema:A(x({addonId:l()}),w(),{auth:`admin`}),testField:A(x({deviceId:n(),key:l(),value:w()}),rM,{kind:`mutation`,auth:`admin`}),getDeviceStatusAggregate:A(x({deviceId:n(),caps:C(l()).readonly().optional()}),m(l(),w().nullable())),getDeviceStatusAggregateBatch:A(x({deviceIds:C(n()).readonly(),caps:C(l()).readonly().optional()}),m(l(),m(l(),w().nullable())),{role:`viewer`})},vocabulary:{notOperatorFacing:`the device registry itself — rename, move and remove are administration`}},DM=[`linked-devices`],OM=S(DM),kM={"linked-devices":{descriptor:gM,declaringCap:`device-manager`,hostDeviceTypes:[E.Camera]}},AM=i(`slot`,[hM.extend({slot:p(`linked-devices`)})]),jM=[E.Camera],hCe=`:`,gCe=`listSlots`,MM=i(`state`,[x({state:p(`ok`)}),x({state:p(`unreachable`),reason:l()})]),NM=x({source:l(),label:l(),addonId:l().optional(),availability:MM}),PM=S([`ok`,`missing`,`foreign`,`unavailable`]),FM=x({deviceId:n().int(),name:l().nullable(),health:PM,detail:l().optional()}),IM=x({state:S([`active`,`inactive`,`unknown`]),authority:l(),detail:l().optional()}),LM=x({state:p(`ok`),slotRef:l(),slot:OM,authority:l(),activation:IM.nullable(),value:AM,sources:C(FM),impliedSources:C(FM).optional()}),RM=x({state:p(`unreachable`),addonId:l(),reason:l()}),zM=i(`state`,[LM,RM]);function _Ce(e,t){return{state:`unreachable`,addonId:e,reason:t}}var BM=x({deviceId:n().int(),name:l(),type:l(),location:l().nullable(),parentName:l().nullable(),suggested:y(),reason:l().nullable()}),VM=x({candidates:C(BM)}),HM=x({applied:p(!0),reload:S([`none`,`host`,`parent`])}),UM=x({deviceId:n().int(),slotRef:l().min(1)}),WM=UM.extend({value:AM}),GM={name:`device-extension`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:jM,deviceConfig:{ui:{kind:`widget`,widgetId:`host/extensions-panel`,tab:`general`,label:`Extensions`,order:72}},methods:{listSources:A(x({deviceId:n().int()}),C(NM)),listSlots:A(x({deviceId:n().int()}),C(zM)),listCandidates:A(UM,VM),setSlot:A(WM,HM,{kind:`mutation`,auth:`admin`})},vocabulary:{noun:F(`Device extension`,`Estensione del dispositivo`),order:3100}},KM=i(`kind`,[x({kind:p(`device`),deviceId:n().int()}),x({kind:p(`node`),nodeId:l().min(1)})]),qM=S([`gauge`,`counter`,`boolean`,`enum`]),JM=S([`gauge`,`counter`,`boolean`]),vCe=`derived:energy.kwh`,YM=S([`raw`,`5m`,`1h`,`1d`]),XM=S([`undeclared`,`not-owner`,`opted-out`,`not-a-real-device`,`rate`,`ingest-mismatch`,`out-of-range`]),yCe=x({key:l(),reason:XM,count:n().int()}),ZM=x({accepted:n().int(),refused:C(yCe).readonly()}),QM=x({key:l(),scope:l(),kind:qM,unit:l().nullable(),displayName:l(),source:S([`cap`,`addon`,`derived`]),values:C(l()).readonly().nullable(),firstTs:n(),lastTs:n()}),bCe=x({t:n(),samples:n().int(),mean:n().nullable(),twMean:n().nullable(),min:n(),max:n(),last:n().nullable(),delta:n().nullable(),state:l().nullable(),states:m(l(),n()).nullable()}),xCe=x({scope:l(),before:x({t:n(),value:n().nullable(),state:l().nullable()}).nullable(),points:C(bCe).readonly(),derivedFrom:l().nullable()}),$M={key:l(),scope:l().optional(),from:n(),to:n(),resolution:h([YM,p(`auto`)]).default(`auto`),maxPoints:n().int().positive().max(5e3).default(1e3)},eN=x({resolution:YM,series:C(xCe).readonly(),truncated:y()}),SCe=24,CCe=h([x({deviceId:n().int(),key:l(),scope:l().optional()}),x({forNodeId:l().min(1),key:l(),scope:l().optional()})]),wCe=i(`ok`,[x({ok:p(!0),result:eN}),x({ok:p(!1),error:l()})]),TCe=x({tier:YM,rows:n().int().nullable(),approxBytes:n().nullable(),countedAt:n().nullable()}),tN=S([`device-gone`,`undeclared`]),nN=x({raw:n().int(),"5m":n().int(),"1h":n().int(),"1d":n().int()}),ECe=x({seriesId:n().int(),deviceId:n().int(),key:l(),scope:l(),displayName:l().nullable(),reason:tN,missingSince:n().nullable(),firstTs:n(),lastTs:n(),rows:nN}),DCe=200,OCe=50,rN=S([`not-found`,`not-orphan`,`failed`]),kCe=i(`ok`,[x({seriesId:n().int(),ok:p(!0),deleted:nN}),x({seriesId:n().int(),ok:p(!1),reason:rN})]),ACe=x({series:C(ECe).readonly(),truncated:y()}),iN=S([`invalid-range`,`range-too-large`,`series-not-found`,`not-a-point-series`]),jCe=x({"5m":n().int(),"1h":n().int(),"1d":n().int()}),MCe=i(`ok`,[x({ok:p(!0),dryRun:y(),seriesId:n().int(),rows:nN,rewritten:jCe.nullable()}),x({ok:p(!1),reason:iN})]),aN=x({startedAt:n(),ready:y(),series:n().int(),metrics:n().int(),optedOutDevices:n().int(),tiers:C(TCe).readonly(),capture:x({eventsSeen:n().int(),pointsEmitted:n().int(),pointsWritten:n().int(),pointsDropped:n().int(),bufferDepth:n().int(),trailingEmitted:n().int(),reconciledPoints:n().int(),reconcileRuns:n().int(),reconcileFailures:n().int(),lastReconcileAt:n().nullable(),lastFlushAt:n().nullable(),flushFailures:n().int(),skipped:m(l(),n().int())}),ingest:x({accepted:n().int(),refused:m(l(),n().int())}),rollup:x({last5mAt:n().nullable(),last1hAt:n().nullable(),last1dAt:n().nullable(),errors:n().int(),dirty5m:n().int(),dirty1h:n().int(),dirty1d:n().int()}),retention:x({lastRunAt:n().nullable(),deleted:m(l(),n().int()),purgedSeries:n().int()}),directory:x({devices:n().int(),lastRefreshAt:n().nullable()})}),oN={name:`device-history`,scope:`system`,mode:`singleton`,methods:{listSeries:A(x({deviceId:n().int()}),C(QM).readonly()),listNodeSeries:A(x({forNodeId:l().min(1)}),C(QM).readonly(),{auth:`admin`}),query:A(x({deviceId:n().int(),...$M}),eN),queryNode:A(x({forNodeId:l().min(1),...$M}),eN,{auth:`admin`}),queryMany:A(x({items:C(CCe).min(1).max(24),from:$M.from,to:$M.to,resolution:$M.resolution,maxPoints:$M.maxPoints}),x({results:C(wCe).readonly()}),{auth:`admin`}),declareSeries:A(x({name:l().regex(/^[a-z0-9-]+$/),subjectKind:S([`device`,`node`]),kind:JM,unit:l().optional(),displayName:l().min(1),ingest:S([`points`,`buckets`])}),x({key:l()}),{kind:`mutation`,auth:`admin`}),record:A(x({points:C(x({key:l(),subject:KM,scope:l().default(``),ts:n(),value:n()})).max(5e3)}),ZM,{kind:`mutation`,auth:`admin`}),recordBuckets:A(x({buckets:C(x({key:l(),subject:KM,scope:l().default(``),bucketStart:n(),samples:n().int().positive(),sum:n(),min:n(),max:n(),last:n().nullable(),lastTs:n().nullable()})).max(5e3)}),ZM,{kind:`mutation`,auth:`admin`}),getDeviceEnabled:A(x({deviceId:n().int()}),x({enabled:y()})),setDeviceEnabled:A(x({deviceId:n().int(),enabled:y()}),x({enabled:y()}),{kind:`mutation`,auth:`admin`}),getStatus:A(x({}),aN,{auth:`admin`}),listOrphanSeries:A(x({}),ACe,{auth:`admin`}),deleteOrphanSeries:A(x({seriesIds:C(n().int()).min(1).max(50)}),x({results:C(kCe).readonly()}),{kind:`mutation`,auth:`admin`}),deleteSeriesRange:A(x({deviceId:n().int(),key:l().min(1),scope:l(),fromMs:n().int().nonnegative(),toMs:n().int().nonnegative(),dryRun:y()}),MCe,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`recorded history of device state — read by charts, not actuated`}},sN=x({deviceId:n().int().positive(),deletedAt:n(),providerAddonId:l()}),cN=x({counts:m(l(),n().int().nonnegative())}),lN=x({store:l(),deviceId:n().int().positive(),count:n().int().nonnegative()}),uN={name:`device-removal-hook`,scope:`system`,mode:`collection`,internal:!0,methods:{onDeviceRemoved:A(sN,cN,{kind:`mutation`,auth:`admin`}),listDeviceData:A(v(),C(lN).readonly(),{auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:M.INTERNAL}},dN=S([`appliance`,`mower`,`vacuum`]),fN=S([`open`,`closed`]),pN=S([`completed`,`aborted`,`error`,`unknown`]),mN=S([`running-state`,`activity`,`reconcile`]),hN=S([`counter-delta`,`history-integral`]),gN=x({phase:l(),at:n()}),_N=x({kind:p(`appliance`),energyKwh:n().nullable().meta(N(`energy`)),energyMethod:hN.nullable(),peakW:n().nullable().meta(N(`power`)),avgW:n().nullable().meta(N(`power`)),program:l().nullable(),remainingAtStartSec:n().nullable().meta(N(`duration`)),finalPhase:l().nullable(),energyStartKwh:n().nullable().meta(N(`energy`)),powerObservedMs:n()}),vN=i(`kind`,[_N]),yN=x({runId:l(),deviceId:n().int(),kind:dN,state:fN,startedAt:n(),endedAt:n().nullable(),durationMs:n().nullable(),outcome:pN.nullable(),startSource:mN,endSource:mN.nullable(),runningSource:S([`native`,`assigned`]).nullable(),phases:C(gN),detail:vN}),NCe=[E.Washer,E.Dryer,E.Dishwasher],PCe=200,bN={name:`device-runs`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:NCe,methods:{listRuns:A(x({deviceId:n().int(),outcome:pN.optional(),atFrom:n().optional(),atTo:n().optional(),limit:n().int().positive().max(200).default(50),cursor:l().optional()}),x({runs:C(yN).readonly(),nextCursor:l().nullable()})),getRun:A(x({deviceId:n().int(),runId:l()}),yN.nullable()),getCurrentRun:A(x({deviceId:n().int()}),yN.nullable())},events:{onRunOpened:{data:yN,notOperatorFacing:`the durable record of a run that the running-state start flip already announces`},onRunClosed:{data:yN,notOperatorFacing:`the durable record of a run that the running-state finish flip already announces`}},vocabulary:{noun:F(`Runs`,`Esecuzioni`),order:2130}},xN=S([`replace`,`add`]),SN=i(`ok`,[x({ok:p(!0),changed:y()}),x({ok:p(!1),code:S([`owned-by-other`,`not-claimed`,`field-not-claimed`,`invalid-slice`,`unknown-device`,`row-unreadable`,`migration-in-flight`]),message:l()})]),CN=x({deviceId:n(),capName:l(),owner:l().min(1),mode:xN,fields:C(l().min(1)).min(1)}),wN=i(`state`,[x({state:p(`loaded`),claims:C(CN)}),x({state:p(`not-loaded`),reason:l()})]),TN={name:`device-state`,scope:`system`,mode:`singleton`,methods:{getSnapshot:A(x({deviceId:n()}),m(l(),m(l(),w()))),getCapSlice:A(x({deviceId:n(),capName:l(),confirmed:y().optional()}),m(l(),w()).nullable()),getAllSnapshots:A(x({confirmed:y().optional()}),m(l(),m(l(),m(l(),w())))),setCapSlice:A(x({deviceId:n(),capName:l(),slice:m(l(),w())}),v(),{kind:`mutation`}),claimFields:A(x({deviceId:n(),capName:l(),owner:l().min(1),mode:xN,fields:C(l().min(1)).min(1),values:m(l(),w())}),SN,{kind:`mutation`,auth:`admin`}),patchOwnedFields:A(x({deviceId:n(),capName:l(),owner:l().min(1),values:m(l(),w())}),SN,{kind:`mutation`,auth:`admin`}),releaseClaim:A(x({deviceId:n(),capName:l(),owner:l().min(1)}),SN,{kind:`mutation`,auth:`admin`}),listClaims:A(x({ownerPrefix:l().optional()}),wN,{auth:`admin`}),getNativeCapSlice:A(x({deviceId:n(),capName:l()}),m(l(),w()).nullable(),{auth:`admin`})},events:{onChanged:ni(x({deviceId:n(),capName:l(),slice:m(l(),w())}))},vocabulary:{notOperatorFacing:`the runtime-state mirror every trigger already reads through`}},EN=S([`schedule`,`command`,`burst`]),DN=S([`none`,`partial`,`full`]),ON=1e3,FCe=x({integrationId:l().min(1),minIntervalMs:n().int().min(ON),intervalMs:n().int().positive().optional(),batch:y(),push:DN,heartbeatMs:n().int().positive().optional(),connectionEpoch:n().int().nonnegative().optional()});function ICe(e){let t=e.intervalMs??0;return Math.max(e.minIntervalMs,t)}var kN=[3e3,1e4],AN=1e4,jN=2e3;function LCe(e){let t=kN.filter(t=>t<e),n=e-jN,r=(t[t.length-1]??0)+AN;for(;r<n;)t.push(r),r+=AN;let i=t[t.length-1];return(i===void 0?n>0:n-i>=1e3)&&t.push(n),t}var RCe=2500,MN=x({deviceId:n().int().nonnegative(),deviceIds:C(n().int().nonnegative()).min(1),reason:EN}),NN=x({deviceId:n().int().nonnegative()}),PN=x({ok:p(!0)}),FN=`the core schedules state refreshes itself; an operator never asks for one`,IN={name:`device-state-refresh`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{refresh:A(MN,PN,{kind:`mutation`,auth:`admin`,notOperatorFacing:FN}),resubscribe:A(NN,PN,{kind:`mutation`,auth:`admin`,notOperatorFacing:FN})},vocabulary:{noun:F(`State refresh`,`Aggiornamento dello stato`),order:3247}},LN=x({online:y(),lastChangedAt:n()}),RN={name:`device-status`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},events:{onStatusChanged:{data:x({deviceId:n(),status:LN}),notOperatorFacing:"the `online` state trigger phrases both edges of this change"}},status:{schema:LN,kind:`push`},runtimeState:LN,durability:`restored`,history:{fields:{online:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Reachability`,`Raggiungibilità`),order:5260,state:[{kind:`boolean`,field:`online`,label:F(`Online`,`Online`),whenTrue:F(`When {device} comes back online`,`Quando {device} torna online`),whenFalse:F(`When {device} goes offline`,`Quando {device} va offline`),icon:`wifi`}],extraEvents:[{category:T.DeviceOnline,label:F(`Came online`,`Tornato online`),phrase:F(`When {device} comes back online`,`Quando {device} torna online`),icon:`wifi`},{category:T.DeviceOffline,label:F(`Went offline`,`Andato offline`),phrase:F(`When {device} goes offline`,`Quando {device} va offline`),icon:`wifi-off`}]}},zCe=200,BCe=500,zN=S([`not-kernel`,`invalid`]),BN=x({written:n().int().nonnegative(),refused:C(x({id:l(),reason:zN})).readonly()}),VN=x({rows:n().int().nullable(),lastWriteAt:n().nullable(),refused:m(l(),n())}),HN={name:`device-transitions`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:Object.values(E).filter(e=>e!==E.Container),methods:{listTransitions:A(x({deviceId:n().int(),capName:l().optional(),actorKind:ia.optional(),outcome:aa.optional(),atFrom:n().optional(),atTo:n().optional(),limit:n().int().positive().max(200).default(50),cursor:l().optional()}),x({transitions:C(sa).readonly(),nextCursor:l().nullable()})),getTransition:A(x({deviceId:n().int(),id:l()}),sa.nullable()),listRecentTransitions:ti(x({actorKind:ia.optional(),outcome:aa.optional(),atFrom:n().optional(),atTo:n().optional(),limit:n().int().positive().max(200).default(50),cursor:l().optional()}),x({transitions:C(sa).readonly(),nextCursor:l().nullable()}),{auth:`admin`}),record:ti(x({transitions:C(sa).max(500)}),BN,{kind:`mutation`,auth:`admin`}),getStatus:ti(x({}),VN,{auth:`admin`})},vocabulary:{noun:F(`Transitions`,`Transizioni`),order:2140}},UN=S([`idle`,`running`,`paused`,`finished`,`error`,`unavailable`]),WN=S([`Inactive`,`Ready`,`DelayedStart`,`Run`,`Pause`,`ActionRequired`,`Finished`,`Error`,`Aborting`]),GN=S([`available`,`offline`,`description-missing`]),KN=x({availability:GN,state:UN,operationState:WN.nullable(),program:l().nullable(),selectedProgram:l().nullable(),availablePrograms:C(l()),remaining:n().int().nonnegative().nullable().meta(N(`duration`)),delayedStart:n().int().nonnegative().nullable().meta(N(`duration`)),progress:n().min(0).max(100).nullable().meta(N(`percentage`)),doorOpen:y().nullable(),doorLocked:y().nullable(),remoteStartAllowed:y().nullable(),remoteControlActive:y().nullable(),localControlActive:y().nullable(),powerOn:y().nullable(),powerState:l().nullable(),filterCleaningDue:y().nullable(),machineCareDue:y().nullable(),machineCareRemainingRuns:n().int().nonnegative().nullable().meta(N(`count`)),halfLoad:y().nullable(),hygienePlus:y().nullable(),extraDry:y().nullable(),intensiveZone:y().nullable(),varioSpeedPlus:y().nullable(),childLock:y().nullable(),activeEvents:C(l()),errorCode:n().nullable().meta(N(`none`)),errorLabel:l().nullable(),lastFetchedAt:n()}),qN=n().int().nonnegative(),JN=h([y(),l(),n()]),YN=S([`none`,`read`,`readWrite`,`writeOnly`,`readStatic`]),XN=x({key:l(),name:l(),type:S([`boolean`,`number`,`enum`,`string`]),access:YN,available:y(),unit:l().nullable(),min:n().nullable(),max:n().nullable(),step:n().nullable(),enumValues:C(l()).nullable(),defaultValue:JN.nullable()}),ZN=x({key:l(),name:l(),available:y(),options:C(XN)}),QN=x({availability:GN,supportsStart:y(),supportsPause:y(),supportsResume:y(),supportsStop:y(),supportsPower:y(),programs:C(ZN),options:C(XN)}),$N={name:`dishwasher`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Dishwasher],methods:{start:A(x({deviceId:qN,program:l().min(1).optional(),options:m(l(),JN).optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.start`,label:F(`Start cycle`,`Avvia il lavaggio`),phrase:F(`Start {device}`,`Avvia {device}`),icon:`play`,openArgs:[{key:`program`,label:F(`Programme`,`Programma`),offer:{kind:`dynamic`,from:`status`,field:`availablePrograms`},optional:!0}]}]}),pause:A(x({deviceId:qN}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.pause`,label:F(`Pause`,`Metti in pausa`),phrase:F(`Pause {device}`,`Metti in pausa {device}`),icon:`pause`}]}),resume:A(x({deviceId:qN}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.resume`,label:F(`Resume`,`Riprendi`),phrase:F(`Resume {device}`,`Riprendi il lavaggio di {device}`),icon:`play`}]}),stop:A(x({deviceId:qN}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.stop`,label:F(`Stop`,`Ferma`),phrase:F(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),setProgram:A(x({deviceId:qN,program:l().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.program`,label:F(`Choose programme`,`Scegli il programma`),phrase:F(`Select the {program} programme on {device}`,`Seleziona il programma {program} su {device}`),icon:`list`,openArgs:[{key:`program`,label:F(`Programme`,`Programma`),offer:{kind:`dynamic`,from:`status`,field:`availablePrograms`}}]}]}),setPower:A(x({deviceId:qN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.powerOn`,label:F(`Power on`,`Accendi`),phrase:F(`Turn on {device}`,`Accendi {device}`),icon:`power`,args:{on:!0}},{id:`dishwasher.powerOff`,label:F(`Power off`,`Spegni`),phrase:F(`Turn off {device}`,`Spegni {device}`),icon:`power-off`,args:{on:!1}}]}),setHalfLoad:A(x({deviceId:qN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.halfLoadOn`,label:F(`Half load on`,`Mezzo carico attivo`),phrase:F(`Turn on half load on {device}`,`Attiva il mezzo carico su {device}`),icon:`contrast`,args:{on:!0}},{id:`dishwasher.halfLoadOff`,label:F(`Half load off`,`Mezzo carico spento`),phrase:F(`Turn off half load on {device}`,`Disattiva il mezzo carico su {device}`),icon:`contrast`,args:{on:!1}}]}),setHygienePlus:A(x({deviceId:qN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.hygienePlusOn`,label:F(`Hygiene Plus on`,`Igiene Plus attiva`),phrase:F(`Turn on Hygiene Plus on {device}`,`Attiva Igiene Plus su {device}`),icon:`sparkles`,args:{on:!0}},{id:`dishwasher.hygienePlusOff`,label:F(`Hygiene Plus off`,`Igiene Plus spenta`),phrase:F(`Turn off Hygiene Plus on {device}`,`Disattiva Igiene Plus su {device}`),icon:`sparkles`,args:{on:!1}}]}),setExtraDry:A(x({deviceId:qN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.extraDryOn`,label:F(`Extra dry on`,`Asciugatura extra attiva`),phrase:F(`Turn on extra dry on {device}`,`Attiva l’asciugatura extra su {device}`),icon:`sun`,args:{on:!0}},{id:`dishwasher.extraDryOff`,label:F(`Extra dry off`,`Asciugatura extra spenta`),phrase:F(`Turn off extra dry on {device}`,`Disattiva l’asciugatura extra su {device}`),icon:`sun`,args:{on:!1}}]}),setIntensiveZone:A(x({deviceId:qN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.intensiveZoneOn`,label:F(`Intensive zone on`,`Zona intensiva attiva`),phrase:F(`Turn on the intensive zone on {device}`,`Attiva la zona intensiva su {device}`),icon:`flame`,args:{on:!0}},{id:`dishwasher.intensiveZoneOff`,label:F(`Intensive zone off`,`Zona intensiva spenta`),phrase:F(`Turn off the intensive zone on {device}`,`Disattiva la zona intensiva su {device}`),icon:`flame`,args:{on:!1}}]}),setVarioSpeedPlus:A(x({deviceId:qN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.varioSpeedOn`,label:F(`Speed boost on`,`Lavaggio rapido attivo`),phrase:F(`Turn on the speed boost on {device}`,`Attiva il lavaggio rapido su {device}`),icon:`zap`,args:{on:!0}},{id:`dishwasher.varioSpeedOff`,label:F(`Speed boost off`,`Lavaggio rapido spento`),phrase:F(`Turn off the speed boost on {device}`,`Disattiva il lavaggio rapido su {device}`),icon:`zap`,args:{on:!1}}]}),setChildLock:A(x({deviceId:qN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.childLockOn`,label:F(`Child lock on`,`Blocco bambini attivo`),phrase:F(`Turn on the child lock of {device}`,`Attiva il blocco bambini di {device}`),icon:`lock`,args:{on:!0}},{id:`dishwasher.childLockOff`,label:F(`Child lock off`,`Blocco bambini spento`),phrase:F(`Turn off the child lock of {device}`,`Disattiva il blocco bambini di {device}`),icon:`lock-open`,args:{on:!1}}]}),setOption:A(x({deviceId:qN,key:l().min(1),value:JN}),v(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`a raw appliance option key/value; every option worth naming has its own action above`}),getOptions:A(x({deviceId:qN}),QN,{auth:`protected`})},status:{schema:KN,kind:`poll`},runtimeState:KN,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:F(`Dishwasher`,`Lavastoviglie`),order:2020,state:[{kind:`enum`,field:`state`,label:F(`Cycle`,`Ciclo`),values:[{value:`idle`,label:F(`Idle`,`Inattiva`)},{value:`running`,label:F(`Running`,`In funzione`),phrase:F(`When {device} starts a cycle`,`Quando {device} inizia un lavaggio`)},{value:`paused`,label:F(`Paused`,`In pausa`)},{value:`finished`,label:F(`Finished`,`Terminato`),phrase:F(`When {device} finishes`,`Quando {device} finisce il lavaggio`)},{value:`error`,label:F(`Error`,`Errore`),phrase:F(`When {device} reports an error`,`Quando {device} segnala un errore`)},{value:`unavailable`,label:F(`Unavailable`,`Non disponibile`)}],icon:`washing-machine`},{kind:`numeric`,field:`progress`,quantity:F(`the cycle progress`,`l’avanzamento del lavaggio`),label:F(`Progress`,`Avanzamento`),unit:`%`,icon:`loader`},{kind:`boolean`,field:`doorOpen`,label:F(`Door open`,`Sportello aperto`),whenTrue:F(`When the door of {device} opens`,`Quando si apre lo sportello di {device}`),whenFalse:F(`When the door of {device} closes`,`Quando si chiude lo sportello di {device}`),icon:`door-open`},{kind:`boolean`,field:`filterCleaningDue`,label:F(`Filter cleaning due`,`Pulizia filtro da fare`),whenTrue:F(`When {device} asks for its filter to be cleaned`,`Quando {device} chiede di pulire il filtro`),whenFalse:F(`When the filter reminder of {device} clears`,`Quando l’avviso filtro di {device} rientra`),icon:`funnel`},{kind:`boolean`,field:`machineCareDue`,label:F(`Machine care due`,`Manutenzione da fare`),whenTrue:F(`When {device} asks for a machine-care cycle`,`Quando {device} chiede un ciclo di manutenzione`),whenFalse:F(`When the machine-care reminder of {device} clears`,`Quando l’avviso di manutenzione di {device} rientra`),icon:`wrench`}]}},eP=`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(`.`),tP=`audio`,nP=[.3,.42,.55,.7,.85,1],rP=[`camstack`,`high-contrast`,`okabe-ito`];function VCe(e){return eP.includes(e)}function HCe(e){return rP.includes(e)}var iP={dark:`#0c0a09`,light:`#fafaf9`},UCe=7,WCe=20,GCe=[`live`,`heatmapScrub`],KCe=3,aP=/^#[0-9a-fA-F]{6}$/;function oP(e,t){return Number.parseInt(e.slice(t,t+2),16)}function sP(e){let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function cP(e){let t=sP(oP(e,1)),n=sP(oP(e,3)),r=sP(oP(e,5));return .2126*t+.7152*n+.0722*r}function qCe(e,t){if(!aP.test(e)||!aP.test(t))return 0;let n=Math.max(cP(e),cP(t)),r=Math.min(cP(e),cP(t));return(n+.05)/(r+.05)}function lP(e){let t=sP(oP(e,1)),n=sP(oP(e,3)),r=sP(oP(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 uP(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 JCe(e,t){if(!aP.test(e)||!aP.test(t))return 0;let n=lP(e),r=lP(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=uP(o,n.b),d=uP(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),ee=30*Math.exp(-(((g-275)/25)**2)),v=h**7,te=2*Math.sqrt(v/(v+25**7)),y=1+.015*(m-50)**2/Math.sqrt(20+(m-50)**2),ne=1+.045*h,re=1+.015*h*_,ie=-Math.sin(2*ee*Math.PI/180)*te,ae=r.L-n.L,b=l-c;return Math.sqrt((ae/y)**2+(b/ne)**2+(p/re)**2+b/ne*ie*(p/re))}var YCe={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`},XCe=[`#b34dc7`,`#1d7d34`,`#db6b6c`,`#a43d29`,`#0e6ee6`,`#29a10b`,`#a98731`,`#0181c6`],ZCe={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`},QCe=[`#817f3b`,`#a0733e`,`#8658b2`,`#956301`,`#bc652d`,`#647331`,`#a14c9e`,`#d14e71`],$Ce={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`},ewe=[`#9a3784`,`#a7392c`,`#409d50`,`#6987e7`,`#ee5b3d`,`#c0430d`,`#af79b3`,`#4b6628`],dP=l().regex(/^#[0-9a-f]{6}$/),fP=i(`form`,[x({form:p(`solid`),hex:dP}),x({form:p(`gradient`),hex:dP,alphas:C(n().gt(0).lte(1)).length(nP.length)})]),pP=x({status:p(`ready`),presetId:S(rP),customized:y(),source:S([`stored`,`unconfigured`]),swatches:m(l(),fP),fallbacks:C(dP).length(8)}),mP=i(`status`,[pP,x({status:p(`unknown`),reason:l()})]),hP=h([x({presetId:l()}),x({presetId:l(),overrides:m(l(),fP)})]),gP=x({presetId:l(),overrides:m(l(),fP)});function twe(e){return{form:`solid`,hex:e}}function nwe(e){return{form:`gradient`,hex:e,alphas:[...nP]}}function rwe(e){let t={};for(let n of eP){let r=e[n];if(r===void 0)throw Error(`palette table missing ${n}`);t[n]=n===`audio`?nwe(r):twe(r)}return t}function _P(e,t,n,r){return{id:e,name:t,swatches:rwe(n),fallbacks:r}}var vP=[_P(`camstack`,`CamStack`,YCe,XCe),_P(`high-contrast`,`High contrast`,ZCe,QCe),_P(`okabe-ito`,`Colour-blind safe`,$Ce,ewe)];function yP(e){return vP.find(t=>t.id===e)}function bP(){let e=yP(`camstack`);if(e===void 0)throw Error(`CamStack preset missing`);return iwe(e,`unconfigured`,!1)}function iwe(e,t,n){return{status:`ready`,presetId:e.id,customized:n,source:t,swatches:e.swatches,fallbacks:[...e.fallbacks]}}function awe(e){return e.hex}function owe(e,t){let n=[];for(let t of eP){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 swe(e){let t=e[tP];return t===void 0||t.form===`gradient`&&nP.every((e,n)=>t.alphas[n]===e)?[]:[{code:`bad-gradient`,entry:tP}]}function cwe(e,t){let n=GCe;return n.includes(e)&&n.includes(t)}function xP(e,t){let n=[];for(let t of eP)e[t]===void 0&&n.push({code:`missing-entry`,entry:t});for(let t of Object.keys(e))VCe(t)||n.push({code:`unknown-entry`,entry:t});t.length!==8&&n.push({code:`bad-fallbacks`}),n.push(...swe(e));let r=owe(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=JCe(i.hex,a.hex);o<(cwe(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=qCe(e.hex,iP[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 lwe(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 SP(e){return e.map(lwe).join(`; `)}var CP=class extends Error{violations;constructor(e){super(SP(e)),this.name=`PaletteRejectedError`,this.violations=e}};function wP(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 TP(e,t,n){let r=n.trim().toLowerCase();if(r.startsWith(`audio-`)){let n=e[tP];return n===void 0?wP(r,t):n.hex}let i=e[r];return i===void 0?wP(r,t):i.hex}function EP(e,t){return{...e,...t}}function uwe(e){return`overrides`in e?e.overrides:{}}function dwe(e){let t=yP(e.presetId);if(t===void 0||!HCe(e.presetId))throw new CP([{code:`unknown-preset`,presetId:e.presetId}]);let n=uwe(e),r=EP(t.swatches,n),i=xP(r,t.fallbacks);if(!i.ok)throw new CP(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 fwe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.keys(e).length===0}function pwe(e){if(e==null||fwe(e))return bP();let t=gP.safeParse(e);if(!t.success)return{status:`unknown`,reason:`stored palette is unreadable`};let n=yP(t.data.presetId);if(n===void 0)return{status:`unknown`,reason:`unknown preset ${t.data.presetId}`};let r=EP(n.swatches,t.data.overrides),i=xP(r,n.fallbacks);if(!i.ok)return{status:`unknown`,reason:SP(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 mwe(e,t){return{presetId:e.presetId,overrides:{...t}}}var hwe=x({id:l(),name:l(),swatches:m(l(),fP),fallbacks:C(l())}),DP={name:`display-palette`,scope:`system`,mode:`singleton`,methods:{getPalette:A(v(),mP,{auth:`protected`,role:`viewer`}),listPresets:A(v(),C(hwe).readonly(),{auth:`protected`,role:`viewer`}),setPalette:A(hP,pP,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`the cluster display palette — one colour table for every client, not a device action`}},OP=x({enabled:y().nullable().meta({label:`Do not disturb`}),lastChangedAt:n()}),kP={name:`do-not-disturb`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.MediaPlayer],methods:{setEnabled:A(x({deviceId:n().int(),enabled:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dnd.on`,label:F(`Do not disturb on`,`Attiva Non disturbare`),phrase:F(`Turn on Do not disturb on {device}`,`Attiva Non disturbare su {device}`),icon:`bell-off`,args:{enabled:!0}},{id:`dnd.off`,label:F(`Do not disturb off`,`Disattiva Non disturbare`),phrase:F(`Turn off Do not disturb on {device}`,`Disattiva Non disturbare su {device}`),icon:`bell`,args:{enabled:!1}}]})},status:{schema:OP,kind:`push`},runtimeState:OP,durability:`session`,history:{fields:{enabled:{kind:`boolean`}}},vocabulary:{noun:F(`Do not disturb`,`Non disturbare`),order:2160,state:[{kind:`boolean`,field:`enabled`,label:F(`Do not disturb`,`Non disturbare`),whenTrue:F(`When Do not disturb turns on on {device}`,`Quando {device} attiva Non disturbare`),whenFalse:F(`When Do not disturb turns off on {device}`,`Quando {device} disattiva Non disturbare`),icon:`bell-off`}]}},AP=2e3,gwe={version:1,targets:[{id:`pressed`,cardinality:`event`,shape:`pulse`,vocabulary:{cap:`doorbell`,eventName:`onPressed`},deviceTypes:[E.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:AP,changedAtRequired:!0},sources:[{kind:`binary`},{kind:`switch`}],sourceReport:{status:`assignment-status`},advancedExpression:!0}]},jP=x({lastPressedAt:n().nullable(),pressCountSinceStart:n().meta(N(`count`))}),MP=x({deviceId:n(),timestamp:n()}),NP={name:`doorbell`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Button,E.Camera],methods:{},events:{onPressed:{data:MP,fromState:{field:`lastPressedAt`,on:`advance`},trigger:{category:T.DoorbellOnPressed,label:F(`Rang`,`Ha suonato`),phrase:F(`When someone rings {device}`,`Quando qualcuno suona a {device}`),icon:`bell-ring`}}},status:{schema:jP,kind:`push`},runtimeState:jP,durability:`restored`,history:`none`,customize:gwe,vocabulary:{noun:F(`Doorbell`,`Campanello`),order:5270}},PP=x({embedding:C(n()),inferenceMs:n()}),FP=S([`image`,`text`]),IP=x({modelId:l(),tower:FP,nodeId:l(),crashes:n(),windowMs:n(),sinceMs:n(),lastReason:l()}),LP=x({modelId:l(),tower:FP,nodeId:l(),attempts:n(),sinceMs:n(),lastReason:l()}),RP=x({modelId:l(),embeddingDim:n(),ready:y(),nodeId:l().optional(),failedModels:C(IP).optional(),failedRequirements:C(LP).optional()}),zP=`embedding-model-failed`,BP=`embedding-requirements-unavailable`,VP=`embedding-requirements-failed`,HP=S([zP,BP,VP]);function UP(e,t){return`[${e} model=${t.modelId} tower=${t.tower} node=${t.nodeId}]`}function _we(e){return Error(`${UP(zP,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 vwe(e,t){return Error(`${UP(BP,e)} ${e.modelId} (${e.tower} tower) on ${e.nodeId}: ${t}`)}function ywe(e){return Error(`${UP(VP,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 bwe=RegExp(`\\[(${zP}|${BP}|${VP}) model=([^\\s\\]]+) tower=(image|text) node=([^\\s\\]]+)\\]`);function WP(e){let t=e instanceof Error?e.message:String(e),n=bwe.exec(t);if(n===null)return null;let r=HP.safeParse(n[1]),i=FP.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 xwe(e){return GP(e)!==null}function GP(e){let t=WP(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 KP={name:`embedding-encoder`,scope:`system`,mode:`collection`,internal:!0,methods:{encode:A(x({crop:b(Uint8Array),width:n(),height:n()}),PP,{auth:`admin`}),encodeText:A(x({text:l(),modelId:l().min(1).optional()}),PP,{auth:`admin`}),getInfo:A(v(),RP,{auth:`admin`}),resetFailedModels:A(x({modelId:l().min(1).optional()}),x({cleared:C(l()),nodeId:l()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.ML}},qP=x({powerW:n().nullable().meta(N(`power`)),energyKwh:n().nullable().meta(N(`energy`)),todayKwh:n().nullable().meta(N(`energy`))}),JP=x({powerW:n().nullable().meta(N(`power`)),importKwh:n().nullable().meta(N(`energy`)),exportKwh:n().nullable().meta(N(`energy`)),importTodayKwh:n().nullable().meta(N(`energy`)),exportTodayKwh:n().nullable().meta(N(`energy`))}),YP=x({powerW:n().nullable().meta(N(`power`)),energyKwh:n().nullable().meta(N(`energy`)),todayKwh:n().nullable().meta(N(`energy`))}),XP=x({stateOfChargePct:n().nullable().meta(N(`percentage`)),storedKwh:n().nullable().meta(N(`energy`)),capacityKwh:n().nullable().meta(N(`energy`)),powerW:n().nullable().meta(N(`power`)),chargedKwh:n().nullable().meta(N(`energy`)),dischargedKwh:n().nullable().meta(N(`energy`)),chargedTodayKwh:n().nullable().meta(N(`energy`)),dischargedTodayKwh:n().nullable().meta(N(`energy`)),healthPct:n().nullable().meta(N(`percentage`))}),ZP=x({solar:qP.nullable(),grid:JP.nullable(),house:YP.nullable(),heatPump:YP.nullable(),storage:XP.nullable(),lastFetchedAt:n()});function Swe(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 QP={name:`energy-system`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.EnergySystem],methods:{},status:{schema:ZP,kind:`push`},runtimeState:ZP,durability:`session`,history:{primary:`house.powerW`,priority:50,fields:{"solar.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Solar power`},"solar.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`Solar energy`},"grid.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Grid power`},"grid.importKwh":{kind:`counter`,unit:`kWh`,displayName:`Grid import`},"grid.exportKwh":{kind:`counter`,unit:`kWh`,displayName:`Grid export`},"house.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`House power`},"house.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`House energy`},"heatPump.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Heat pump power`},"heatPump.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`Heat pump energy`},"storage.stateOfChargePct":{kind:`gauge`,unit:`%`,deadband:1,displayName:`Storage charge`},"storage.storedKwh":{kind:`gauge`,unit:`kWh`,deadband:.05,displayName:`Stored energy`},"storage.capacityKwh":{kind:`gauge`,unit:`kWh`,deadband:.1,displayName:`Storage capacity`},"storage.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Storage power`},"storage.chargedKwh":{kind:`counter`,unit:`kWh`,displayName:`Storage charged`},"storage.dischargedKwh":{kind:`counter`,unit:`kWh`,displayName:`Storage discharged`},"storage.healthPct":{kind:`gauge`,unit:`%`,deadband:1,displayName:`Storage health`}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Energy system`,`Sistema energetico`),order:4020}},Cwe=S([`date`,`time`,`datetime`]),$P=x({value:l(),timestamp:y().optional(),lastFetchedAt:n()}),eF={name:`enum-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:$P,kind:`push`},runtimeState:$P,durability:`restored`,history:{fields:{value:{kind:`enum`,skipWhenSet:`timestamp`}}},volatileStateFields:[`lastFetchedAt`,`timestamp`],vocabulary:{noun:F(`State sensor`,`Sensore di stato`),order:5060,state:[{kind:`value`,field:`value`,label:F(`State`,`Stato`),icon:`list`}]}},tF=S([`warning`,`error`]),nF=x({code:l(),label:l(),severity:tF}),rF=x({active:y().nullable(),code:l().nullable(),label:l().nullable(),severity:tF,since:n().nullable(),faults:C(nF).optional(),lastFetchedAt:n()}),iF={active:null,code:null,label:null,severity:`error`,since:null,lastFetchedAt:0},aF={name:`error`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},status:{schema:rF,kind:`push`,empty:iF},runtimeState:rF,durability:`restored`,volatileStateFields:[`lastFetchedAt`],history:`none`,vocabulary:{noun:F(`Fault`,`Guasto`),order:5265,state:[{kind:`boolean`,field:`active`,label:F(`Fault`,`Guasto`),whenTrue:F(`When {device} reports a fault`,`Quando {device} segnala un guasto`),whenFalse:F(`When the fault of {device} clears`,`Quando il guasto di {device} si risolve`),icon:`triangle-alert`}]}},oF=x({id:l(),name:l(),sampleCount:n().int().nonnegative(),coverMediaId:n().int().optional(),coverBase64:l().optional()}),wwe=x({id:l(),source:S([`detected`,`photo`]),addedAt:n().int(),deviceId:n().int().optional(),base64:l().optional(),mediaId:n().int().optional(),keyFrameMediaId:n().int().optional(),faceBbox:sC.optional()}),Twe=x({sampleId:l(),enrolledAt:n().int(),deviceId:n().int().optional(),source:S([`detected`,`photo`]),mediaId:n().int().optional(),comparable:y(),selfMean:n().nullable(),bestForeign:x({identityId:l(),name:l(),score:n()}).optional(),suspicion:n()}),Ewe=x({identityId:l(),name:l(),modelId:l(),totalSamples:n().int(),comparableSamples:n().int(),flagged:n().int(),flagThreshold:n(),rows:C(Twe).readonly()}),sF=x({faceId:l(),deviceId:n().int(),trackId:l(),timestamp:n().int(),recognizedIdentityId:l().optional(),identityName:l().optional(),assigned:y(),base64:l().optional(),cropUrl:l().optional(),faceBbox:sC.optional(),keyFrameMediaId:n().int().optional(),bestMatchScore:n().optional(),nativeFaceShortSidePx:n().optional(),suggestedIdentityId:l().optional(),suggestedMatchScore:n().optional()}),Dwe=S([`unassigned`,`recognized`,`identified`,`all`]),Owe=S([`timestamp`,`suggestionConfidence`]),kwe=S([`asc`,`desc`]),Awe=x({faceIds:C(l()).readonly(),representativeFaceId:l(),size:n().int(),cohesion:n()}),jwe=x({mediaId:n().int(),kind:l(),url:l(),sizeBytes:n(),timestamp:n()}),cF={name:`face-gallery`,role:{feature:`face-assignment`},scope:`system`,mode:`singleton`,methods:{listIdentities:A(x({includeCrops:y().optional()}).optional(),C(oF).readonly(),{role:`viewer`}),createIdentity:A(x({name:l().min(1)}),oF,{kind:`mutation`,auth:`admin`}),renameIdentity:A(x({id:l(),name:l().min(1)}),v(),{kind:`mutation`,auth:`admin`}),deleteIdentity:A(x({id:l()}),v(),{kind:`mutation`,auth:`admin`}),listIdentitySamples:A(x({identityId:l()}),C(wwe).readonly()),auditIdentitySamples:A(x({identityId:l().min(1)}),Ewe,{auth:`admin`}),removeSample:A(x({identityId:l(),sampleId:l()}),v(),{kind:`mutation`,auth:`admin`}),moveIdentitySample:A(x({sampleId:l().min(1),toIdentityId:l().min(1)}),v(),{kind:`mutation`,auth:`admin`}),listRecentFaces:A(x({deviceId:n().int().optional(),deviceIds:C(n().int()).optional(),limit:n().int().positive().optional(),filter:Dwe.optional(),since:n().int().optional(),until:n().int().optional(),sortBy:Owe.optional(),sortDirection:kwe.optional(),includeCrops:y().optional()}).optional(),C(sF).readonly()),getFaceByTrack:A(x({deviceId:n().int(),trackId:l()}),sF.nullable(),{role:`viewer`}),getFaceMedia:A(x({faceId:l()}),C(jwe).readonly()),assignFace:A(x({faceId:l(),identityId:l()}),v(),{kind:`mutation`,auth:`admin`}),unassignFace:A(x({faceId:l()}),v(),{kind:`mutation`,auth:`admin`}),deleteFace:A(x({faceId:l()}),v(),{kind:`mutation`,auth:`admin`}),assignFaces:A(x({faceIds:C(l()).min(1),identityId:l()}),x({assigned:n().int(),failed:C(l()).readonly()}),{kind:`mutation`,auth:`admin`}),unassignFaces:A(x({faceIds:C(l()).min(1)}),x({unassigned:n().int(),failed:C(l()).readonly()}),{kind:`mutation`,auth:`admin`}),suggestFaceClusters:A(x({threshold:n().min(0).max(1).optional(),minClusterSize:n().int().min(2).optional(),maxClusters:n().int().positive().optional(),limit:n().int().positive().optional(),maxFacesScanned:n().int().positive().optional()}).optional(),C(Awe).readonly())},vocabulary:{notOperatorFacing:`the face gallery — curated on its own page`}},lF=x({reason:l(),count:n().int().nonnegative()}),uF=x({family:l(),deviceId:n().int().positive(),variant:l().optional(),sinceMs:n(),atMs:n(),attempts:n().int().nonnegative(),succeeded:n().int().nonnegative(),reasons:C(lF).readonly()}),dF={name:`failure-contribution`,scope:`system`,mode:`collection`,internal:!0,methods:{list:A(v(),C(uF).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:M.INTERNAL}},fF=S([`forward`,`reverse`]),pF=[`horizontal`,`vertical`],mF=S(pF),hF=[`oscillating`,`angle`,`sweepFrom`,`sweepTo`],gF=S(hF),_F=[`min`,`max`,`step`],vF=x({oscillating:y().nullable().default(null),angle:n().nullable().default(null),sweepFrom:n().nullable().default(null),sweepTo:n().nullable().default(null),min:n().nullable().default(null),max:n().nullable().default(null),step:n().nullable().default(null)}),yF=x({horizontal:vF.nullable().default(null),vertical:vF.nullable().default(null)}),bF=[`nothing-to-set`,`axis-not-linked`,`out-of-range`,`source-gone`,`source-unknown`,`source-call-failed`],xF=S(bF),SF=i(`status`,[x({status:p(`applied`)}),x({status:p(`refused`),reason:xF,field:gF.optional(),detail:l(),applied:C(gF)})]),CF=x({deviceId:n().int().nonnegative(),axis:mF,oscillating:y().optional(),angle:n().optional(),sweepFrom:n().optional(),sweepTo:n().optional()});function wF(e,t){return`oscillationAxes.${e}.${t}`}var TF=x({speed:n().min(0).max(100).nullable().meta(N(`percentage`)),percentageStep:n().positive().optional().meta(N(`percentage`)),preset:l(),availablePresets:C(l()),direction:fF.nullable(),oscillating:y().nullable(),oscillationAxes:yF.optional(),lastChangedAt:n()});function Mwe(e){let t=e.oscillationAxes;if(t===void 0)return e.oscillating;let n=pF.flatMap(e=>{let n=t[e]?.oscillating;return n==null?[]:[n]});return n.length===0?e.oscillating:n.some(Boolean)}var EF=[E.Fan],DF=`oscillation-axes`;function Nwe(e){return{id:`${e}-oscillating`,cardinality:`scalar`,vocabulary:{cap:`fan-control`,stateField:`oscillating`},deviceTypes:EF,apply:`replace`,section:DF,path:wF(e,`oscillating`),sources:[{kind:`switch`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}}function OF(e,t){let n={id:`${e}-${t}`,cardinality:`scalar`,vocabulary:{cap:`fan-control`},deviceTypes:EF,apply:`replace`,section:DF,path:wF(e,t),sources:[{kind:`numeric`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}};return t===`angle`?{...n,companions:_F.map(t=>({kind:`source-field`,path:wF(e,t),field:t}))}:n}var Pwe=pF.flatMap(e=>[Nwe(e),OF(e,`angle`),OF(e,`sweepFrom`),OF(e,`sweepTo`)]),Fwe={id:`preset`,cardinality:`scalar`,vocabulary:{cap:`fan-control`},deviceTypes:EF,apply:`replace`,path:`preset`,sources:[{kind:`field`,valueKinds:[`string`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}},kF=[...Pwe,Fwe],Iwe={version:1,overridable:kF.map(e=>({path:e.path,by:e.id})),targets:kF},AF={name:`fan-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Fan],methods:{setPercentage:j(x({deviceId:n().int().nonnegative(),speed:n().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.off`,label:F(`Fan off`,`Ventilatore spento`),phrase:F(`Stop {device}`,`Ferma {device}`),icon:`power-off`,effect:{field:`speed`,value:0},args:{speed:0}},{id:`fan.full`,label:F(`Fan full`,`Ventilatore al massimo`),phrase:F(`Run {device} at full speed`,`Porta {device} alla massima velocità`),icon:`fan`,effect:{field:`speed`,value:100},args:{speed:100},sideEffects:[{field:`preset`,value:``,when:{field:`preset`,notIn:[``]}}]},{id:`fan.speed`,label:F(`Set speed`,`Imposta la velocità`),phrase:F(`Set the speed of {device} to {speed}`,`Imposta la velocità di {device} al {speed}`),icon:`fan`,effect:{field:`speed`,fromArg:`speed`},sideEffects:[{field:`preset`,value:``,when:{field:`preset`,notIn:[``]}}],openArgs:[{key:`speed`,label:F(`Speed`,`Velocità`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setPreset:j(x({deviceId:n().int().nonnegative(),preset:l().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.preset`,label:F(`Set preset`,`Imposta il preset`),phrase:F(`Set {device} to preset {preset}`,`Imposta {device} sul preset {preset}`),icon:`list`,effect:{field:`preset`,fromArg:`preset`},openArgs:[{key:`preset`,label:F(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`status`,field:`availablePresets`}}]}]}),setDirection:j(x({deviceId:n().int().nonnegative(),direction:fF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.forward`,label:F(`Spin forward`,`Rotazione avanti`),phrase:F(`Spin {device} forward`,`Fai girare {device} in avanti`),icon:`refresh-cw`,effect:{field:`direction`,value:`forward`},args:{direction:`forward`}},{id:`fan.reverse`,label:F(`Spin in reverse`,`Rotazione inversa`),phrase:F(`Spin {device} in reverse`,`Fai girare {device} al contrario`),icon:`rotate-ccw`,effect:{field:`direction`,value:`reverse`},args:{direction:`reverse`}}]}),setOscillating:j(x({deviceId:n().int().nonnegative(),oscillating:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.oscillateOn`,label:F(`Oscillate`,`Oscillazione attiva`),phrase:F(`Make {device} oscillate`,`Fai oscillare {device}`),icon:`move-horizontal`,effect:{field:`oscillating`,value:!0},args:{oscillating:!0}},{id:`fan.oscillateOff`,label:F(`Stop oscillating`,`Oscillazione spenta`),phrase:F(`Stop {device} oscillating`,`Ferma l’oscillazione di {device}`),icon:`move-horizontal`,effect:{field:`oscillating`,value:!1},args:{oscillating:!1}}]}),setOscillationAxis:j(CF,SF,{kind:`mutation`,auth:`protected`,actions:[{id:`fan.horizontalOscillateOn`,label:F(`Horizontal oscillation on`,`Oscillazione orizzontale attiva`),phrase:F(`Start the horizontal oscillation of {device}`,`Attiva l’oscillazione orizzontale di {device}`),icon:`move-horizontal`,args:{axis:`horizontal`,oscillating:!0}},{id:`fan.horizontalOscillateOff`,label:F(`Horizontal oscillation off`,`Oscillazione orizzontale spenta`),phrase:F(`Stop the horizontal oscillation of {device}`,`Ferma l’oscillazione orizzontale di {device}`),icon:`move-horizontal`,args:{axis:`horizontal`,oscillating:!1}},{id:`fan.verticalOscillateOn`,label:F(`Vertical oscillation on`,`Oscillazione verticale attiva`),phrase:F(`Start the vertical oscillation of {device}`,`Attiva l’oscillazione verticale di {device}`),icon:`move-vertical`,args:{axis:`vertical`,oscillating:!0}},{id:`fan.verticalOscillateOff`,label:F(`Vertical oscillation off`,`Oscillazione verticale spenta`),phrase:F(`Stop the vertical oscillation of {device}`,`Ferma l’oscillazione verticale di {device}`),icon:`move-vertical`,args:{axis:`vertical`,oscillating:!1}}]})},status:{schema:TF,kind:`push`},runtimeState:TF,customize:Iwe,durability:`session`,history:{fields:{speed:{kind:`gauge`,unit:`%`,minIntervalMs:0},oscillating:{kind:`boolean`}}},vocabulary:{noun:F(`Fan`,`Ventilatore`),order:1080,state:[{kind:`numeric`,field:`speed`,quantity:F(`the speed`,`la velocità`),label:F(`Speed`,`Velocità`),unit:`%`,icon:`fan`},{kind:`boolean`,field:`oscillating`,label:F(`Oscillating`,`Oscillazione`),whenTrue:F(`When {device} starts oscillating`,`Quando {device} inizia a oscillare`),whenFalse:F(`When {device} stops oscillating`,`Quando {device} smette di oscillare`),icon:`move-horizontal`}]}},Lwe=12,jF=x({oscillating:y().optional(),angle:n().optional(),sweepFrom:n().optional(),sweepTo:n().optional()}),MF=x({speed:n().min(0).max(100).optional(),preset:l().min(1).optional(),direction:fF.optional(),oscillationAxes:x({horizontal:jF.optional(),vertical:jF.optional()}).optional()}),NF=x({id:l().min(1).max(64),name:l().trim().min(1).max(40),state:MF}),PF=[`empty-state`,`duplicate-name`,`duplicate-id`,`too-many`,`not-a-fan`],FF=S(PF),IF=i(`status`,[x({status:p(`saved`),count:n().int().nonnegative()}),x({status:p(`refused`),reason:FF,detail:l()})]),LF=x({field:l(),outcome:S([`applied`,`failed`,`not-run`,`refused`]),message:l().optional()}),RF=x({status:S([`applied`,`partial`,`refused`]),fields:C(LF)}),zF=[`speed`,`direction`,`preset`,`oscillationAxes`],BF=S(zF),VF=x({what:l(),reason:l()}),HF=x({state:MF,omitted:C(VF)}),UF=x({deviceId:n().int().nonnegative()}),Rwe={version:1,targets:[{id:`presets`,cardinality:`config`,vocabulary:{cap:`fan-presets`},deviceTypes:[E.Fan],apply:`add`,readMethod:`getPresets`,writeMethod:`setPresets`}]},WF={name:`fan-presets`,scope:`system`,mode:`singleton`,methods:{getPresets:A(UF,C(NF),{auth:`protected`}),setPresets:A(UF.extend({presets:C(NF).max(12)}),IF,{kind:`mutation`,auth:`admin`}),applyPreset:A(UF.extend({presetId:l().min(1)}),RF,{kind:`mutation`,auth:`protected`}),capturePreset:A(UF.extend({fields:C(BF).optional()}),HF,{auth:`protected`})},customize:Rwe,vocabulary:{notOperatorFacing:`the per-fan presets — authored in the Customize presets editor, applied through the actions the exports list`}},GF=x({flags:m(l(),w()),deviceType:l().nullable(),model:l().nullable(),channelCount:n().nullable().meta(N(`count`)),lastProbedAt:n(),lastFetchedAt:n()}),KF={name:`feature-probe`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},events:{onProbeChanged:{data:x({deviceId:n(),status:GF}),notOperatorFacing:`the device’s capabilities were re-probed — plumbing, not a happening`}},status:{schema:GF,kind:`push`},runtimeState:GF,durability:`session`,history:`none`,vocabulary:{noun:F(`Feature probe`,`Rilevamento funzioni`),order:3120}},zwe=x({name:l(),path:l()}),Bwe=x({path:l(),entries:C(zwe).readonly(),freeBytes:n(),totalBytes:n()}),qF={name:`filesystem-browse`,scope:`system`,mode:`singleton`,internal:!0,methods:{listAllowedRoots:A(v(),C(l()).readonly(),{auth:`admin`}),browse:A(x({path:l()}),Bwe,{auth:`admin`}),createDir:A(x({path:l()}),x({path:l()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.INTERNAL}},JF=x({flooded:y(),lastChangedAt:n()}),YF={name:`flood`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:JF,kind:`push`},runtimeState:JF,durability:`restored`,history:{fields:{flooded:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Leak sensor`,`Sensore di allagamento`),order:5070,state:[{kind:`boolean`,field:`flooded`,label:F(`Leak`,`Perdita`),whenTrue:F(`When {device} detects a leak`,`Quando {device} rileva una perdita`),whenFalse:F(`When {device} is dry again`,`Quando {device} torna asciutto`),icon:`droplets`}]}},XF=x({detected:y(),lastChangedAt:n()}),ZF={name:`gas`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:XF,kind:`push`},runtimeState:XF,durability:`restored`,history:{fields:{detected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Gas sensor`,`Sensore di gas`),order:5080,state:[{kind:`boolean`,field:`detected`,label:F(`Detected`,`Rilevato`),whenTrue:F(`When {device} detects gas`,`Quando {device} rileva gas`),whenFalse:F(`When the gas clears on {device}`,`Quando il gas su {device} rientra`),icon:`flame`}]}},QF=x({active:y().meta({label:`Active`}),lastChangedAt:n()}),$F={name:`group-active`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Cover,E.Valve,E.Lock,E.MediaPlayer,E.Climate],methods:{},status:{schema:QF,kind:`push`},runtimeState:QF,durability:`session`,history:`none`,vocabulary:{noun:F(`Group state`,`Stato del gruppo`),order:5090}},eI=x({deviceId:n().int().nonnegative(),cap:l().min(1),method:l().min(1),ok:y(),error:l().optional(),at:n()}),tI=x({results:C(eI)}),nI={name:`group-commands`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Switch,E.Light,E.Fan,E.Cover,E.Valve,E.Lock,E.MediaPlayer,E.Climate],methods:{},status:{schema:tI,kind:`push`},runtimeState:tI,durability:`session`,history:`none`,vocabulary:{noun:F(`Group command`,`Comando di gruppo`),order:5100}},rI=x({included:n().int().nonnegative().meta(N(`count`,{precision:0,label:`Reporting`})),excluded:n().int().nonnegative().meta(N(`count`,{precision:0,label:`Excluded`})),total:n().int().nonnegative().meta(N(`count`,{precision:0,label:`Members`}))}),iI={name:`group-status`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor,E.Switch,E.Light,E.Fan,E.Cover,E.Valve,E.Lock,E.MediaPlayer,E.Climate],methods:{},status:{schema:rI,kind:`push`},runtimeState:rI,durability:`session`,history:`none`,vocabulary:{noun:F(`Group`,`Gruppo`),order:5110,state:[{kind:`numeric`,field:`included`,quantity:F(`the members reporting`,`i membri che rispondono`),label:F(`Reporting`,`Rispondono`),icon:`users`},{kind:`numeric`,field:`excluded`,quantity:F(`the members left out`,`i membri esclusi`),label:F(`Excluded`,`Esclusi`),icon:`users`},{kind:`numeric`,field:`total`,quantity:F(`the member count`,`il numero di membri`),label:F(`Members`,`Membri`),icon:`sigma`}]}},aI=n().int().nonnegative(),oI=l().min(1),sI=l().min(1),cI=n().finite(),lI={key:`circuitId`,label:F(`Circuit`,`Circuito`),offer:{kind:`dynamic`,from:`status`,cap:`heat-pump-status`,field:`circuits`,valueKey:`id`,labelKey:`label`,where:{key:`kind`,equals:`heating`}}},uI={...lI,label:F(`Hot water circuit`,`Circuito acqua calda`),offer:{...lI.offer,where:{key:`kind`,equals:`dhw`}}},dI={key:`mode`,label:F(`Mode`,`Modalità`),offer:{kind:`text`}},Vwe={key:`level`,label:F(`Level`,`Livello`),offer:{kind:`text`}},fI={key:`temp`,label:F(`Temperature`,`Temperatura`),offer:{kind:`number`,step:.5,unit:`°C`}},Hwe={key:`minutes`,label:F(`Minutes`,`Minuti`),offer:{kind:`number`,min:1,step:1,unit:`min`}},pI={name:`heat-pump-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.HeatPump],methods:{setSilentMode:A(x({deviceId:aI,mode:sI}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.silent`,label:F(`Set silent mode`,`Imposta la modalità silenziosa`),phrase:F(`Set silent mode of {device} to {mode}`,`Imposta la modalità silenziosa di {device} su {mode}`),icon:`volume-x`,openArgs:[{key:`mode`,label:F(`Silent mode`,`Modalità silenziosa`),offer:{kind:`enum`,values:[{value:`off`,label:F(`Off`,`Off`)},{value:`auto`,label:F(`Auto`,`Auto`)},{value:`on`,label:F(`On`,`On`)}]}}]}]}),setAwayMode:A(x({deviceId:aI,mode:sI}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.away`,label:F(`Set away mode`,`Imposta la modalità assente`),phrase:F(`Set away mode of {device} to {mode}`,`Imposta la modalità assente di {device} su {mode}`),icon:`plane`,openArgs:[{key:`mode`,label:F(`Away mode`,`Modalità assente`),offer:{kind:`enum`,values:[{value:`off`,label:F(`Off`,`Off`)},{value:`on`,label:F(`On`,`On`)}]}}]}]}),setAdditionalHeaterMode:A(x({deviceId:aI,mode:sI}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.additionalHeater`,label:F(`Set additional heater`,`Imposta il riscaldatore aggiuntivo`),phrase:F(`Set the additional heater of {device} to {mode}`,`Imposta il riscaldatore aggiuntivo di {device} su {mode}`),icon:`flame`,openArgs:[{key:`mode`,label:F(`Additional heater`,`Riscaldatore aggiuntivo`),offer:{kind:`enum`,values:[{value:`off`,label:F(`Off`,`Off`)},{value:`manual`,label:F(`Manual`,`Manuale`)},{value:`auto`,label:F(`Auto`,`Auto`)}]}}]}]}),setHolidayMode:A(x({deviceId:aI,mode:sI}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.holiday`,label:F(`Set holiday mode`,`Imposta la modalità vacanza`),phrase:F(`Set holiday mode of {device} to {mode}`,`Imposta la modalità vacanza di {device} su {mode}`),icon:`tree-palm`,openArgs:[{key:`mode`,label:F(`Holiday programme`,`Programma vacanza`),offer:{kind:`enum`,values:[{value:`off`,label:F(`Off`,`Off`)},{value:`hm1`,label:F(`Programme 1`,`Programma 1`)},{value:`hm2`,label:F(`Programme 2`,`Programma 2`)},{value:`hm3`,label:F(`Programme 3`,`Programma 3`)},{value:`hm4`,label:F(`Programme 4`,`Programma 4`)},{value:`hm5`,label:F(`Programme 5`,`Programma 5`)},{value:`hm6`,label:F(`Programme 6`,`Programma 6`)},{value:`hm7`,label:F(`Programme 7`,`Programma 7`)},{value:`hm8`,label:F(`Programme 8`,`Programma 8`)}]}}]}]}),setCircuitOperationMode:A(x({deviceId:aI,circuitId:oI,mode:sI}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitOperationMode`,label:F(`Set circuit operation mode`,`Imposta la modalità del circuito`),phrase:F(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`thermometer`,openArgs:[lI,dI]}]}),setCircuitHeatCoolMode:A(x({deviceId:aI,circuitId:oI,mode:sI}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitHeatCoolMode`,label:F(`Set circuit heat / cool`,`Imposta caldo / freddo del circuito`),phrase:F(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`sun-snow`,openArgs:[lI,dI]}]}),setCircuitSummerWinter:A(x({deviceId:aI,circuitId:oI,mode:sI}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitSummerWinter`,label:F(`Set circuit summer / winter`,`Imposta estate / inverno del circuito`),phrase:F(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`sun`,openArgs:[lI,dI]}]}),setCircuitComfortSetpoint:A(x({deviceId:aI,circuitId:oI,temp:cI}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitComfortSetpoint`,label:F(`Set comfort temperature`,`Imposta la temperatura comfort`),phrase:F(`Set the comfort temperature of {circuitId} on {device} to {temp}`,`Imposta la temperatura comfort di {circuitId} su {device} a {temp}`),icon:`thermometer-sun`,openArgs:[lI,fI]}]}),setCircuitEcoSetpoint:A(x({deviceId:aI,circuitId:oI,temp:cI}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitEcoSetpoint`,label:F(`Set eco temperature`,`Imposta la temperatura eco`),phrase:F(`Set the eco temperature of {circuitId} on {device} to {temp}`,`Imposta la temperatura eco di {circuitId} su {device} a {temp}`),icon:`leaf`,openArgs:[lI,fI]}]}),setCircuitMaxFlowTemp:A(x({deviceId:aI,circuitId:oI,temp:cI}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitMaxFlowTemp`,label:F(`Set maximum flow temperature`,`Imposta la temperatura massima di mandata`),phrase:F(`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:[lI,fI]}]}),setDhwOperationMode:A(x({deviceId:aI,circuitId:oI,mode:sI}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwOperationMode`,label:F(`Set hot water mode`,`Imposta la modalità acqua calda`),phrase:F(`Set hot water {circuitId} of {device} to {mode}`,`Imposta l'acqua calda {circuitId} di {device} su {mode}`),icon:`shower-head`,openArgs:[uI,dI]}]}),setDhwTemperatureLevel:A(x({deviceId:aI,circuitId:oI,level:sI}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwTemperatureLevel`,label:F(`Set hot water level`,`Imposta il livello acqua calda`),phrase:F(`Set hot water {circuitId} of {device} to level {level}`,`Imposta l'acqua calda {circuitId} di {device} al livello {level}`),icon:`droplet`,openArgs:[uI,Vwe]}]}),setDhwChargeDuration:A(x({deviceId:aI,circuitId:oI,minutes:n().int().positive()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwChargeDuration`,label:F(`Set hot water charge duration`,`Imposta la durata della carica acqua calda`),phrase:F(`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:[uI,Hwe]}]}),startExtraHotWater:A(x({deviceId:aI,circuitId:oI}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.extraHotWater`,label:F(`Start extra hot water`,`Avvia acqua calda extra`),phrase:F(`Start an extra hot water charge of {circuitId} on {device}`,`Avvia una carica extra di acqua calda {circuitId} su {device}`),icon:`droplets`,openArgs:[uI]}]})},vocabulary:{noun:F(`Heat pump settings`,`Impostazioni pompa di calore`),order:4010}},mI=[`heating`,`dhw`,`cooling`,`solar`],hI=S(mI),gI=x({value:l().nullable(),allowed:C(l())}),_I=x({value:n().nullable(),min:n().nullable(),max:n().nullable(),step:n().nullable()}),vI=x({id:l().min(1),kind:hI,label:l(),icon:Lh,currentTemp:n().nullable().meta(N(`temperature`)),targetTemp:n().nullable().meta(N(`temperature`)),mode:l().nullable(),active:y().nullable(),operationMode:gI.nullable(),heatCoolMode:gI.nullable(),summerWinter:gI.nullable(),comfortSetpoint:_I.nullable(),ecoSetpoint:_I.nullable(),maxFlowTemp:_I.nullable(),temperatureLevel:gI.nullable(),chargeDuration:_I.nullable(),extraHotWater:y().nullable()}),yI=x({silent:gI.nullable(),away:gI.nullable(),additionalHeater:gI.nullable(),holiday:gI.nullable()}),bI=x({thermalW:n().nullable().meta(N(`power`)),electricalW:n().nullable().meta(N(`power`)),compressorPct:n().nullable().meta(N(`percentage`))}),xI=x({supply:n().nullable().meta(N(`temperature`)),return:n().nullable().meta(N(`temperature`)),outdoor:n().nullable().meta(N(`temperature`))}),SI=x({thermalKwh:n().nullable().meta(N(`energy`)),electricalKwh:n().nullable().meta(N(`energy`))}),CI=x({circuits:C(vI),system:yI,power:bI,temperatures:xI,energy:SI,waterPressureBar:n().nullable(),starts:n().nullable(),lastFetchedAt:n()});function wI(e){let{thermalW:t,electricalW:n}=e;return t===null||n===null||n<=0?null:t/n}var Uwe=[E.HeatPump];function TI(e,t,n){return{id:e,cardinality:`scalar`,vocabulary:{cap:`heat-pump-status`},deviceTypes:Uwe,apply:`replace`,path:t,sources:[{kind:`numeric`,requiredUnit:n,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}}var EI=[TI(`electrical-power`,`power.electricalW`,`W`),TI(`electrical-energy`,`energy.electricalKwh`,`kWh`)],Wwe={version:1,overridable:EI.map(e=>({path:e.path,by:e.id})),targets:EI},DI={name:`heat-pump-status`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.HeatPump],methods:{},status:{schema:CI,kind:`push`},runtimeState:CI,durability:`session`,customize:Wwe,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:F(`Heat pump`,`Pompa di calore`),order:4e3}},OI=x({position:n().min(0).max(100).nullable().meta(N(`percentage`)),lastFetchedAt:n()}),kI={name:`heating-valve`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Climate],methods:{},status:{schema:OI,kind:`push`},runtimeState:OI,durability:`session`,history:{fields:{position:{kind:`gauge`,unit:`%`,deadband:1}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Radiator valve`,`Valvola termostatica`),order:1110,state:[{kind:`numeric`,field:`position`,quantity:F(`the valve opening`,`l’apertura della valvola`),label:F(`Valve opening`,`Apertura della valvola`),unit:`%`,icon:`heater`}]}},AI=S([`s`,`min`]),Gwe=S([`switch`,`pet-fountain`]),jI={actuator:`switch`,maxSeconds:10800,unit:`min`,quickRunDefault:30},MI={actuator:`pet-fountain`,maxSeconds:300,unit:`s`,quickRunDefault:60},NI=[E.Switch,E.PetFountain],PI={[E.Switch]:[O.SwitchHeater]};function FI(e,t){return e===E.PetFountain?MI:e===E.Switch&&t===O.SwitchHeater?jI:null}var Kwe=1e3,qwe=6e4;function II(e,t,n){let r=e-t;return r<=0?0:Math.max(1,Math.ceil(r/(n===`min`?qwe:Kwe)))}function Jwe(e,t){return t===`min`?e*60:e}function LI(e){return e.unit===`min`?Math.floor(e.maxSeconds/60):e.maxSeconds}var RI=x({duration:n().positive().finite(),unit:AI});function zI(e,t){let n=LI(e);return{duration:Math.min((t!==null&&Number.isFinite(t)&&t>0?t:null)??e.quickRunDefault,n),unit:e.unit}}var BI=S([`unsupported-device`,`over-max`,`command-failed`]),VI=i(`ok`,[x({ok:p(!0),activeUntil:n()}),x({ok:p(!1),reason:BI,maxSeconds:n().nullable()})]),HI=x({activeUntil:n().nullable(),requestedBy:l().nullable(),quickRun:RI.nullable(),lastFetchedAt:n()}),UI=x({unit:AI,maxDuration:n(),defaultDuration:n()}),WI=x({quickRunDuration:n().positive().finite().nullable().optional()}),GI={name:`timed-run`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:NI,deviceRoles:PI,deviceConfig:{ui:{kind:`derived-form`,builderId:`timed-run`,tab:`general`}},methods:{getOptions:A(x({deviceId:n().int()}),UI),setSettings:A(x({deviceId:n().int(),settings:WI}),v(),{kind:`mutation`,auth:`admin`}),runFor:A(x({deviceId:n().int(),duration:n().positive().finite(),unit:AI}),VI,{kind:`mutation`,auth:`protected`,actions:[{id:`timedRun.runForMinutes`,label:F(`Run for minutes`,`Accendi per alcuni minuti`),phrase:F(`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:F(`Minutes`,`Minuti`),offer:{kind:`number`,min:1,step:1,unit:`min`}}]},{id:`timedRun.runForSeconds`,label:F(`Run for seconds`,`Accendi per alcuni secondi`),phrase:F(`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:F(`Seconds`,`Secondi`),offer:{kind:`number`,min:1,step:1,unit:`s`}}]}]}),cancel:A(x({deviceId:n().int()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`timedRun.cancel`,label:F(`Cancel the timer`,`Annulla il timer`),phrase:F(`Cancel the pending switch-off of {device}`,`Annulla lo spegnimento programmato di {device}`),icon:`timer-off`}]})},status:{schema:HI,kind:`push`},runtimeState:HI,durability:`session`,history:`none`,vocabulary:{noun:F(`Timed run`,`Esecuzione a tempo`),order:2150}},KI=[`on`,`off`,`running`,`idle`,`standby`,`alert`,`offline`,`unknown`],qI=[`success`,`warning`,`danger`,`primary`,`info`,`muted`],JI=[`none`,`pulse`,`spin`,`glow`,`halo`,`wave`,`rise`,`fall`,`tumble`,`equalizer`,`blink`,`breathe`],YI=[`plain`,`heat-rise`,`cool-fall`,`glow`,`water`,`drum`,`sky`,`mist`,`alert-wash`],XI=S(KI),ZI=S(qI),Ywe=S(JI),QI=x({icon:Lh,tone:ZI,background:S(YI),animation:Ywe});function $I(e){let t=hO[e];return t===void 0?null:`cap:${e}.${t.field}`}function Xwe(e){return e.enabledCaps.flatMap(e=>{let t=$I(e),n=hO[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 eL=x({en:l(),it:l()}),tL={en:`—`,it:`—`};function Zwe(e){return e.en===tL.en&&e.it===tL.it}var nL=[`temperature`,`humidity`,`power`,`contact`,`text`],rL=[`hot`,`mild`,`cold`],iL=[`updated`,`changed`],aL=x({value:n(),quantity:la}),oL=x({quantity:S(nL),reading:aL.nullable(),icon:Lh.nullable(),value:eL,unit:l().nullable(),band:S(rL).nullable(),level:n().min(0).max(1).nullable(),word:eL,tone:S(qI),since:n().nullable(),sinceKind:S(iL),historyKey:l().nullable()}),Qwe=3e3,sL=e=>F(e,e),cL=e=>Math.min(1,Math.max(0,e)),$we=(e,t)=>String(Number(e.toFixed(t)));function lL(e){return e<12?`cold`:e>28?`hot`:`mild`}var eTe={hot:F(`Hot`,`Caldo`),mild:F(`Normal`,`Normale`),cold:F(`Cold`,`Freddo`)},tTe={hot:`warning`,mild:`muted`,cold:`info`};function uL(e,t){let n=lL(e);return{quantity:`temperature`,reading:{value:e,quantity:`temperature`},icon:`thermometer`,value:sL($we(e,1)),unit:`°C`,band:n,level:null,word:eTe[n],tone:tTe[n],since:t,sinceKind:`updated`,historyKey:$I(`temperature-sensor`)}}function dL(e,t){let n=e<30,r=e>70;return{quantity:`humidity`,reading:{value:e,quantity:`humidity`},icon:`droplets`,value:sL(String(Math.round(e))),unit:`%`,band:null,level:cL(e/100),word:n?F(`Dry`,`Secco`):r?F(`Humid`,`Umido`):F(`Normal`,`Normale`),tone:n||r?`warning`:`info`,since:t,sinceKind:`updated`,historyKey:$I(`humidity-sensor`)}}function fL(e,t){let n=e>0;return{quantity:`power`,reading:{value:e,quantity:`power`},icon:`zap`,value:sL(String(Math.round(e))),unit:`W`,band:null,level:cL(e/Qwe),word:n?F(`Active`,`Attivo`):F(`Idle`,`Inattivo`),tone:n?`primary`:`muted`,since:t,sinceKind:`updated`,historyKey:$I(`power-meter`)}}function pL(e,t){return{quantity:`contact`,reading:null,icon:e?`door-open`:`door-closed`,value:e?F(`Open`,`Aperto`):F(`Closed`,`Chiuso`),unit:null,band:null,level:+!!e,word:e?F(`Open`,`Aperto`):F(`Closed`,`Chiuso`),tone:e?`warning`:`success`,since:t,sinceKind:`changed`,historyKey:null}}function mL(e,t){return{quantity:`text`,reading:null,icon:null,value:sL(e),unit:null,band:null,level:null,word:F(`Changed`,`Cambiato`),tone:`muted`,since:t,sinceKind:`updated`,historyKey:null}}var nTe={temperature:{icon:`thermometer`,unit:`°C`,sinceKind:`updated`,historyKey:$I(`temperature-sensor`)},humidity:{icon:`droplets`,unit:`%`,sinceKind:`updated`,historyKey:$I(`humidity-sensor`)},power:{icon:`zap`,unit:`W`,sinceKind:`updated`,historyKey:$I(`power-meter`)},contact:{icon:null,unit:null,sinceKind:`changed`,historyKey:null},text:{icon:null,unit:null,sinceKind:`updated`,historyKey:null}};function hL(e){let t=nTe[e];return{quantity:e,reading:null,icon:t.icon,value:tL,unit:t.unit,band:null,level:null,word:tL,tone:`muted`,since:null,sinceKind:t.sinceKind,historyKey:t.historyKey}}var rTe={power:new Set([`energy-sensor`,`voltage-sensor`,`current-sensor`])};function gL(e,t){return t===null?!0:!(rTe[e.quantity]?.has(t)??!1)}var _L=`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(`.`),iTe=S(_L),vL=[`cool`,`heat`,`dry`,`fan`,`auto`,`playing`,`paused`,`open`,`closed`],yL=x({id:iTe,mode:S(vL).nullable(),level:n().min(0).max(1).nullable()}),bL={[E.Camera]:`camera`,[E.Light]:`light`,[E.Siren]:`siren`,[E.Switch]:`plug`,[E.Sensor]:`sensor-sparkline`,[E.Climate]:`thermostat`,[E.Button]:`button`,[E.EventEmitter]:`event-stream`,[E.Update]:`update`,[E.Generic]:`generic`,[E.Notifier]:`event-stream`,[E.Script]:`event-stream`,[E.Automation]:`event-stream`,[E.Lock]:`lock`,[E.Cover]:`cover`,[E.Valve]:`control-dial`,[E.Humidifier]:`control-dial`,[E.WaterHeater]:`heater`,[E.HeatPump]:`heat-pump`,[E.EnergySystem]:`generic`,[E.Workload]:`generic`,[E.Fan]:`fan`,[E.MediaPlayer]:`tv`,[E.AlarmPanel]:`alarm`,[E.Control]:`control-dial`,[E.Presence]:`presence`,[E.Weather]:`weather`,[E.WeatherStation]:`weather`,[E.Vacuum]:`vacuum`,[E.LawnMower]:`lawn-mower`,[E.Container]:`generic`,[E.Image]:`camera`,[E.PetFeeder]:`pet-feeder`,[E.PetFountain]:`pet-fountain`,[E.Dishwasher]:`dishwasher`,[E.Washer]:`washer`,[E.Dryer]:`dryer`,[E.Gateway]:`gateway`},xL={[O.Siren]:`siren`,[O.Floodlight]:`light`,[O.Spotlight]:`light`,[O.PirSensor]:`presence`,[O.Chime]:`speaker`,[O.Autotrack]:`inherit`,[O.Nightvision]:`inherit`,[O.PrivacyMask]:`inherit`,[O.Doorbell]:`inherit`,[O.CoverBlind]:`inherit`,[O.CoverShutter]:`inherit`,[O.CoverAwning]:`inherit`,[O.CoverCurtain]:`inherit`,[O.CoverGarage]:`inherit`,[O.CoverGate]:`inherit`,[O.CoverDoor]:`inherit`,[O.CoverWindow]:`inherit`,[O.BinaryHelper]:`inherit`,[O.Outlet]:`plug`,[O.SwitchHeater]:`heater`,[O.SwitchFan]:`fan`,[O.SwitchLight]:`light`,[O.PoePort]:`plug`,[O.ClimateAc]:`ac`,[O.ClimateThermostat]:`inherit`,[O.ClimateFloor]:`inherit`,[O.ClimateRadiator]:`inherit`,[O.ClimateHeater]:`inherit`,[O.ClimateHeatPumpCircuit]:`inherit`,[O.MotionSensor]:`presence`,[O.ContactSensor]:`contact`,[O.LeakSensor]:`inherit`,[O.SmokeSensor]:`alarm`,[O.COSensor]:`alarm`,[O.GasSensor]:`alarm`,[O.TamperSensor]:`inherit`,[O.VibrationSensor]:`inherit`,[O.ConnectivitySensor]:`inherit`,[O.SoundSensor]:`inherit`,[O.BinarySensor]:`inherit`,[O.TemperatureSensor]:`sensor-sparkline`,[O.HumiditySensor]:`sensor-sparkline`,[O.AmbientLightSensor]:`inherit`,[O.PressureSensor]:`weather`,[O.WindSensor]:`weather`,[O.RainSensor]:`weather`,[O.UvSensor]:`weather`,[O.SolarRadiationSensor]:`weather`,[O.SoilMoistureSensor]:`inherit`,[O.PowerSensor]:`plug`,[O.EnergySensor]:`plug`,[O.VoltageSensor]:`plug`,[O.CurrentSensor]:`plug`,[O.AirQualitySensor]:`inherit`,[O.BatterySensor]:`inherit`,[O.NumericSensor]:`inherit`,[O.EnumSensor]:`inherit`,[O.DateTimeSensor]:`inherit`,[O.GenericSensor]:`inherit`,[O.NumericControl]:`control-dial`,[O.SelectControl]:`control-dial`,[O.TextControl]:`inherit`,[O.DateTimeControl]:`inherit`,[O.MobilePushNotifier]:`inherit`,[O.MessagingNotifier]:`inherit`,[O.EmailNotifier]:`inherit`,[O.GenericNotifier]:`inherit`,[O.IrTransmitter]:`inherit`,[O.Vm]:`inherit`,[O.AppContainer]:`inherit`,[O.Lxc]:`inherit`,[O.App]:`inherit`,[O.Host]:`inherit`,[O.Ups]:`inherit`};function aTe(e){return Object.values(E).includes(e)}function oTe(e){return Object.values(O).includes(e)}function SL(e,t){let n=e!==null&&oTe(e)?xL[e]:void 0;return n!==void 0&&n!==`inherit`?n:aTe(t)?bL[t]:`generic`}var CL=`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(`.`),wL=S(CL),sTe={progress:F(`Progress`,`Avanzamento`),"run-for":F(`Run for`,`Avvia per`),cycle:F(`Cycle`,`Ciclo`),program:F(`Program`,`Programma`),"appliance-power":F(`Appliance`,`Elettrodomestico`),"now-playing":F(`Now playing`,`In riproduzione`),playback:F(`Playback`,`Riproduzione`),volume:F(`Volume`,`Volume`),source:F(`Source`,`Sorgente`),contact:F(`Door`,`Porta`),"motion-trigger":F(`Motion`,`Movimento`),lock:F(`Lock`,`Serratura`),alarm:F(`Alarm`,`Allarme`),fan:F(`Fan`,`Ventola`),vacuum:F(`Cleaning`,`Pulizia`),"vacuum-suction":F(`Suction`,`Aspirazione`),mower:F(`Mowing`,`Taglio`),feeder:F(`Feed now`,`Eroga ora`),fountain:F(`Pump`,`Pompa`),"pump-cycle":F(`Pump cycle`,`Ciclo pompa`),automation:F(`Automation`,`Automazione`),script:F(`Script`,`Script`),"do-not-disturb":F(`Do not disturb`,`Non disturbare`),brightness:F(`Brightness`,`Luminosità`),color:F(`Colour`,`Colore`),cover:F(`Position`,`Posizione`),valve:F(`Valve`,`Valvola`),humidifier:F(`Humidifier`,`Umidificatore`),update:F(`Firmware`,`Firmware`),button:F(`Action`,`Azione`),"climate-mode":F(`Mode`,`Modalità`),"climate-fan":F(`Fan`,`Ventola`),setpoint:F(`Setpoint`,`Temperatura`),channel:F(`Channel`,`Canale`),control:F(`Control`,`Controllo`),circuit:F(`Circuit`,`Circuito`),"heat-pump-power":F(`Power`,`Potenza`),"system-mode":F(`Mode`,`Modalità`)},TL=a(()=>h([l(),n(),y(),m(l(),TL)])),cTe=m(l(),TL);function EL(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]:EL(o,i,n)}}function lTe(e,t,n){return EL(e,t.split(`.`),n)}var DL=x({cap:l(),method:l(),args:cTe}),uTe=S([`off-while-running`,`unlock`,`install`,`press`]),OL=x({id:l(),label:eL,icon:Lh,call:DL,emphasis:S([`primary`,`normal`]),confirm:uTe.nullable()}),kL=i(`kind`,[x({kind:p(`action`),action:OL}),x({kind:p(`toggle`),id:l(),label:eL,on:y().nullable(),turnOn:OL,turnOff:OL}),x({kind:p(`slider`),id:l(),label:eL,value:n().nullable(),min:n(),max:n(),step:n(),unit:l(),call:DL,valueArg:l()}),x({kind:p(`picker`),id:l(),label:eL,current:l().nullable(),options:C(l()),optionLabels:m(l(),eL).optional(),call:DL,valueArg:l()}),x({kind:p(`number`),id:l(),label:eL,value:n().nullable(),step:n().nullable(),unit:l(),call:DL,valueArg:l()}),x({kind:p(`text`),id:l(),label:eL,value:l().nullable(),call:DL,valueArg:l()})]),dTe=x({icon:Lh.nullable(),text:eL,tone:ZI}),fTe=new Set([`cover`,`valve`,`lock`,`vacuum`,`playback`,`brightness`]),pTe=x({id:wL,placement:S([`row`,`scene`]).optional(),label:eL.optional(),group:eL.optional(),pills:C(dTe).optional(),icon:Lh,status:eL.nullable(),controls:C(kL),progress:n().min(0).max(1).nullable().optional()}),AL=x({label:eL,value:h([n(),l()]),unit:l().nullable()}),mTe=x({id:S([`battery`,`network-link`,`integration`]),icon:Lh,tone:ZI,value:n().nullable(),label:eL}),jL=`remote.open`,hTe=x({commands:n().int().nullable(),open:OL.optional()}),gTe=x({items:C(x({key:l(),label:l(),level:n().nullable(),needsAttention:y()})),attention:n().int()}),_Te=i(`kind`,[x({kind:p(`power`),watts:n(),detail:C(AL)}),x({kind:p(`running`),running:y().nullable(),since:n().nullable(),phase:l().nullable(),detail:C(AL)})]),vTe=x({source:S([`switch`,`media-player`,`climate-control`]),on:y().nullable(),assumed:y(),turnOn:OL,turnOff:OL}),yTe=x({activeUntil:n().nullable(),quickRun:RI,run:OL,cancel:OL,remaining:n().nullable()}),bTe=x({on:y().nullable(),confirmOffWhileRunning:y(),running:y().nullable(),powerOn:OL.nullable(),powerOff:OL.nullable(),restart:OL}),ML=x({token:S(YI),animation:S(JI)}),NL=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:Lh.nullable(),text:eL,tone:ZI}),PL=x({label:eL,value:eL,tone:ZI.optional(),at:n().optional()}),xTe=x({left:C(PL).max(2),right:C(PL).max(2)}),STe=i(`kind`,[x({kind:p(`artwork`),url:l(),fallback:ML}),x({kind:p(`state`),...ML.shape})]),CTe=x({partId:l(),cap:l()}),wTe=x({deviceId:n().int(),type:l(),role:l().nullable(),name:l(),state:XI,stateAssumed:y(),look:QI,background:STe,scene:yL,facts:C(NL),sideTiles:xTe,title:eL,caption:eL.optional(),badges:C(mTe),remote:hTe.nullable(),historyLabel:eL,consumables:gTe.nullable(),consumption:_Te.nullable(),ownPower:vTe.nullable(),timedRun:yTe.nullable(),powerSupply:bTe.nullable(),rows:C(pTe),measurement:oL.optional(),gated:C(l()),provenance:C(CTe)}),TTe=x({id:S([`timed-run.run`,`timed-run.cancel`]),duration:n(),unit:S([`min`,`s`])}),FL=x({deviceId:n().int(),name:l(),type:l(),state:XI,stateAssumed:y(),look:QI,scene:yL,statusLine:C(eL),primary:kL.nullable(),primaryGated:y().optional(),timedRun:TTe.nullable(),extras:C(kL).max(2).optional(),trailing:NL.nullable(),measurement:oL.optional()}),IL=[`temperature`,`humidity`,`pressure`,`illuminance`,`reading`,`air-quality`,`valve`],ETe=[`power`,`battery`,`consumables`],DTe=new Set(IL);function OTe(e){for(let t of ETe){let n=e.facts.find(e=>e.id===t);if(n!==void 0)return n}return e.facts.find(t=>DTe.has(t.id)&&t.text.en===e.title.en)??null}var kTe={[E.Climate]:`climate.mode`};function ATe(e){let t=kTe[e.type];if(t!==void 0){let n=RL(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 jTe={[E.Climate]:[`climate.target`],[E.Vacuum]:[`vacuum.base`],[E.LawnMower]:[`mower.dock`],[E.MediaPlayer]:[`volume.level`,jL],[E.Automation]:[`automation.enabled`]},LL=e=>e.kind===`action`?e.action.id:e.id;function RL(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=>LL(e)===t);if(r!==void 0)return r}return null}function MTe(e,t){let n=jTe[e.type]??[],r=t===null?null:LL(t);return n.filter(e=>e!==r).flatMap(t=>{let n=RL(e,t);return n===null?[]:[n]}).slice(0,2)}function NTe(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 PTe(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 FTe(e){let t=OTe(e),{control:n,gated:r}=ATe(e);return{deviceId:e.deviceId,name:e.name,type:e.type,state:e.state,stateAssumed:e.stateAssumed,look:e.look,scene:e.scene,statusLine:NTe(e,t),primary:n,primaryGated:r,timedRun:PTe(e),extras:MTe(e,n),trailing:t,...e.measurement===void 0?{}:{measurement:e.measurement}}}var ITe=x({deviceId:n().int().nonnegative(),canActuate:y().optional()}),LTe=500,RTe=x({deviceIds:C(n().int().nonnegative()).max(500),canActuate:y().optional()}),zL=x({type:l(),rows:C(wL)}),BL={name:`hero-layout`,scope:`system`,mode:`singleton`,methods:{getHeroModel:A(ITe,wTe.nullable(),{auth:`protected`,role:`viewer`}),getRowModels:A(RTe,C(FL.nullable()),{auth:`protected`,role:`viewer`}),getLayout:A(x({deviceType:l(),role:l().nullable().optional()}),zL,{auth:`protected`,role:`viewer`})},vocabulary:{notOperatorFacing:`the device hero model — read-only data the UI draws, never actuated`}},VL=x({on:y(),currentHumidity:n().min(0).max(100).nullable().meta(N(`humidity`)),targetHumidity:n().min(0).max(100).nullable().meta(N(`humidity`)),mode:l().nullable(),availableModes:C(l()),action:l().nullable(),minHumidity:n().nullable().meta(N(`humidity`)),maxHumidity:n().nullable().meta(N(`humidity`)),lastChangedAt:n()}),HL={name:`humidifier`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Humidifier],power:{kind:`field`,field:`on`,set:`setOn`},methods:{setOn:A(x({deviceId:n().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.on`,label:F(`Humidifier on`,`Umidificatore acceso`),phrase:F(`Turn on {device}`,`Accendi {device}`),icon:`power`,effect:{field:`on`,value:!0},args:{on:!0}},{id:`humidifier.off`,label:F(`Humidifier off`,`Umidificatore spento`),phrase:F(`Turn off {device}`,`Spegni {device}`),icon:`power-off`,effect:{field:`on`,value:!1},args:{on:!1}}]}),setTargetHumidity:A(x({deviceId:n().int().nonnegative(),humidity:n().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.target`,label:F(`Set humidity`,`Imposta l’umidità`),phrase:F(`Set {device} to {humidity} humidity`,`Imposta {device} al {humidity} di umidità`),icon:`droplets`,effect:{field:`targetHumidity`,fromArg:`humidity`},openArgs:[{key:`humidity`,label:F(`Humidity`,`Umidità`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setMode:A(x({deviceId:n().int().nonnegative(),mode:l().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.mode`,label:F(`Set mode`,`Imposta la modalità`),phrase:F(`Set {device} to {mode}`,`Imposta {device} su {mode}`),icon:`list`,effect:{field:`mode`,fromArg:`mode`},openArgs:[{key:`mode`,label:F(`Mode`,`Modalità`),offer:{kind:`dynamic`,from:`status`,field:`availableModes`}}]}]})},status:{schema:VL,kind:`push`},runtimeState:VL,durability:`session`,history:{fields:{currentHumidity:{kind:`gauge`,unit:`%`,deadband:.5},on:{kind:`boolean`}}},vocabulary:{noun:F(`Humidifier`,`Umidificatore`),order:1090,state:[{kind:`boolean`,field:`on`,label:F(`On`,`Acceso`),whenTrue:F(`When {device} turns on`,`Quando {device} si accende`),whenFalse:F(`When {device} turns off`,`Quando {device} si spegne`),icon:`power`},{kind:`numeric`,field:`currentHumidity`,quantity:F(`the humidity`,`l’umidità`),label:F(`Humidity`,`Umidità`),unit:`%`,icon:`droplets`}]}},UL=x({humidity:n().min(0).max(100).nullable().meta(N(`humidity`,{precision:0,label:`Humidity`})),lastFetchedAt:n()}),WL={name:`humidity-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor,E.Climate],methods:{},status:{schema:UL,kind:`push`},runtimeState:UL,durability:`restored`,history:{primary:`humidity`,priority:90,fields:{humidity:{kind:`gauge`,unit:`%`,deadband:.5}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Humidity`,`Umidità`),order:5120,state:[{kind:`numeric`,field:`humidity`,quantity:F(`the humidity`,`l’umidità`),label:F(`Humidity`,`Umidità`),unit:`%`,icon:`droplets`}]}},GL=x({url:l().nullable(),lastUpdated:n().nullable().meta(N(`none`))}),KL={name:`image`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Image],methods:{},status:{schema:GL,kind:`push`},runtimeState:GL,durability:`session`,history:`none`,vocabulary:{noun:F(`Image`,`Immagine`),order:3130}},qL=S([`0`,`90`,`180`,`270`]),JL=S([`auto`,`manual`]),YL=S([`auto`,`manual`]),XL=S([`off`,`blc`,`wdr`,`hlc`]),ZL=x({min:n(),max:n(),step:n()}),QL=x({brightness:n().optional().meta(N(`none`)),contrast:n().optional().meta(N(`none`)),saturation:n().optional().meta(N(`none`)),sharpness:n().optional().meta(N(`none`)),mirror:y().optional(),flip:y().optional(),rotate:qL.optional(),whiteBalance:JL.optional(),warmth:n().optional().meta(N(`none`)),exposureMode:YL.optional(),backlightMode:XL.optional(),lastFetchedAt:n()}),$L=x({supportsBrightness:y(),brightness:ZL.optional(),supportsContrast:y(),contrast:ZL.optional(),supportsSaturation:y(),saturation:ZL.optional(),supportsSharpness:y(),sharpness:ZL.optional(),supportsMirror:y(),supportsFlip:y(),rotateOptions:C(qL),whiteBalanceModes:C(JL),supportsWarmth:y(),warmth:ZL.optional(),exposureModes:C(YL),backlightModes:C(XL)}),eR=x({brightness:n().optional(),contrast:n().optional(),saturation:n().optional(),sharpness:n().optional(),mirror:y().optional(),flip:y().optional(),rotate:qL.optional(),whiteBalance:JL.optional(),warmth:n().optional(),exposureMode:YL.optional(),backlightMode:XL.optional()}),tR={name:`image-settings`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],deviceConfig:{ui:{kind:`derived-form`,builderId:`image-settings`,tab:`image`}},methods:{getOptions:A(x({deviceId:n()}),$L),setSettings:A(x({deviceId:n(),settings:eR}),v(),{kind:`mutation`,auth:`admin`})},status:{schema:QL,kind:`poll`},runtimeState:QL,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Image settings`,`Impostazioni immagine`),order:3140}},nR=x({id:l(),addonId:l(),name:l(),enabled:y(),info:m(l(),w()).readonly(),originStableId:l().optional(),createdAt:n(),updatedAt:n(),processState:l()}),rR=x({id:l(),addonId:l(),name:l(),enabled:y(),info:m(l(),w()).readonly(),originStableId:l().optional(),createdAt:n(),updatedAt:n()}),iR=x({addonId:l(),name:l(),providerLabel:l().optional(),description:l(),iconUrl:l().nullable(),color:l(),instanceMode:l(),mode:S([`standalone`,`account`,`broker`]),discoveryMode:l(),kind:S([`device-adoption`,`device-provider`]),brokerKind:l().nullable(),supportsLocationImport:y(),canTest:y(),existingInstances:C(x({id:l(),name:l()})),canAdd:y()}),aR=S([`validated`,`rejected`,`inconclusive`,`unsupported`]),oR=x({success:y(),error:l().optional(),status:aR.optional(),testedBy:l().nullable().optional(),latencyMs:n().nonnegative().optional(),detail:l().optional()}),sR=x({id:l(),name:l().optional(),enabled:y().optional(),info:m(l(),w()).optional()}),cR=x({success:y(),deletedId:l()}),lR={name:`integrations`,scope:`system`,mode:`singleton`,methods:{list:A(v(),C(nR)),get:A(x({id:l()}),nR),getByAddonId:A(x({addonId:l()}),rR.nullable()),listByAddon:A(x({addonId:l()}),C(rR)),adoptInstanceRows:A(x({addonId:l(),rows:C(x({id:l().min(1),name:l(),enabled:y(),stated:y()}))}),x({created:n().int(),updated:n().int(),conflicts:C(x({id:l(),ownerAddonId:l()}))}),{kind:`mutation`,auth:`admin`}),update:A(sR,rR,{kind:`mutation`,auth:`admin`}),delete:A(x({id:l()}),cR,{kind:`mutation`,auth:`admin`}),getAvailableTypes:A(v(),C(iR),{auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:M.ADDON_ADMIN}},zTe=ve(),uR=l().min(1),dR=S([`single`,`multiple`]),fR=S([`devices`,`services`]),pR=x({id:l().min(1),label:l().min(1),functionCap:l().min(1),brokerKind:l().min(1).optional(),alsoServes:C(l().min(1)).optional(),iconUrl:l().min(1).optional(),iconMediaType:l().min(1).optional(),role:fR.optional(),canTest:y().optional(),signIn:x({basePath:l().min(1),methods:C(S([`device-code`,`proxy`])).optional()}).optional(),connectPath:l().min(1).optional(),disconnectPath:l().min(1).optional(),widgets:C(x({id:l().min(1),placement:S([`connection`,`model`])})).optional()}),mR=x({mode:S([`none`,`lan`,`account`]),scopedToInstance:y()}),hR=x({kind:l().min(1),field:l().min(1),to:x({cap:l().min(1),kind:l().min(1).optional()})}),gR=x({role:fR,discovery:mR.optional(),instanceMode:dR,kind:l(),canTest:y(),kinds:C(pR).min(1),allowRestoreId:y().optional(),mintsId:y().optional(),links:C(hR).optional(),userScoped:y().optional()}),_R=x({state:S([`ok`,`off`,`error`,`unknown`]),detail:l().optional(),label:l().optional()}),vR=S([`scan`,`children`,`none`]),yR=x({id:uR,name:l(),configured:y(),enabled:y().optional(),kind:l().min(1),formValues:m(l(),w()),status:_R.optional(),lastCheckedAt:n().optional(),addDevice:vR.optional()}),bR=x({id:uR,name:l().min(1).optional(),values:m(l(),w())}),xR={name:`integration-instances`,scope:`system`,mode:`collection`,methods:{describe:A(v(),gR,{auth:`admin`}),instanceFormSchema:A(x({id:uR.nullable(),kind:l().min(1).optional(),mode:S([`standalone`,`account`,`broker`]).optional(),candidateStableId:l().min(1).optional()}),zTe,{auth:`admin`}),listInstances:A(se({}),C(yR).readonly(),{auth:`protected`,caller:`scoped`}),getInstance:A(x({id:uR}),yR.nullable(),{auth:`protected`,caller:`scoped`}),createInstance:A(x({id:uR.optional(),name:l().min(1),kind:l().min(1).optional(),values:m(l(),w()).optional(),originStableId:l().min(1).optional(),seed:x({info:m(l(),w())}).optional()}),x({id:l()}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),updateInstance:A(bR,x({ok:p(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),setInstanceEnabled:A(x({id:uR,enabled:y()}),x({ok:p(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),deleteInstance:A(x({id:uR}),x({ok:p(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),testInstance:j(x({id:uR.nullable(),values:m(l(),w()),kind:l().min(1).optional()}),oR,{kind:`mutation`,auth:`protected`,caller:`scoped`})},vocabulary:{notOperatorFacing:M.INTERNAL}},SR=x({codecs:C(l()),sampleRate:n().meta(N(`none`)),duplex:S([`half`,`full`]),maxBacklogMs:n().meta(N(`duration-ms`))}),CR=x({talking:y(),lastSessionAt:n().nullable(),ability:SR.nullable()}),BTe=S([`opus`,`s16le`,`g711ulaw`,`g711alaw`]),wR={name:`intercom`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],methods:{startSession:A(x({deviceId:n()}),x({sessionId:l(),sdpOffer:l()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),handleAnswer:A(x({deviceId:n(),sessionId:l(),sdpAnswer:l()}),v(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),stopSession:A(x({deviceId:n(),sessionId:l()}),v(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),startTalkSession:A(x({deviceId:n()}),x({sessionId:l()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`two-way talk is a person speaking through the viewer, not an automation step`}),pushTalkAudio:A(x({deviceId:n(),audioBase64:l(),codec:BTe.optional(),sampleRate:n().int().positive().optional(),channels:n().int().positive().optional(),sequenceNumber:n().int()}),x({accepted:y()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),endTalkSession:A(x({deviceId:n()}),v(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`})},events:{onStatusChanged:{data:x({deviceId:n(),status:CR}),notOperatorFacing:"the `talking` state trigger phrases both edges of this change"}},status:{schema:CR,kind:`command-driven`},runtimeState:CR,durability:`session`,history:`none`,vocabulary:{noun:F(`Intercom`,`Citofono`),order:3150,state:[{kind:`boolean`,field:`talking`,label:F(`Talking`,`In conversazione`),whenTrue:F(`When someone starts talking through {device}`,`Quando qualcuno inizia a parlare tramite {device}`),whenFalse:F(`When the conversation on {device} ends`,`Quando la conversazione su {device} finisce`),icon:`mic`}]}},TR=S([`carrierHz`,`dutyCyclePercent`,`repeat`,`repeatDelayMs`]),ER=S([`ir`,`rf`]),DR=x({ok:p(!0),ignoredSettings:C(l())}),OR=x({media:C(ER),settable:C(TR),maxTimings:n().int().positive(),learn:y().default(!1),formats:C(UE).default([])}),kR=2e4,AR=6e4,jR=x({native:GE.nullable(),timings:PE,carrierHz:n().int().positive().nullable()}),MR=x({at:n(),ok:y(),error:l().nullable()}),NR=MR.extend({medium:ER}),PR=x({lastSend:NR.nullable(),lastLearn:MR.nullable(),lastFetchedAt:n()});function FR(e){return!(e.kind===`learn`&&e.error===`ir-transmitter.learn-unsupported`)}function VTe(e,t,n){let r=e??{lastSend:null,lastLearn:null,lastFetchedAt:n};return FR(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 HTe(e){return qr(e)?.code??null}var IR={name:`ir-transmitter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Generic],methods:{send:A(x({deviceId:n().int().nonnegative(),timings:PE.optional(),native:GE.optional(),settings:FE.optional()}).refine(e=>e.timings===void 0!=(e.native===void 0),{message:`send takes exactly one of timings or native`}),DR,{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:A(x({deviceId:n().int().nonnegative(),timeoutMs:n().int().positive().max(AR).default(kR)}),jR,{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:A(x({deviceId:n().int().nonnegative()}),OR,{kind:`query`,auth:`protected`})},runtimeState:PR,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`IR / RF transmitter`,`Trasmettitore IR / RF`),order:1140}},LR=S([`key-missing`,`wrong-key`,`key-file-unreadable`,`store-unavailable`,`not-initialized`,`decrypt-failed`]),RR=i(`state`,[x({state:p(`ready`)}),x({state:p(`locked`),reason:LR})]),zR=i(`kind`,[x({kind:p(`value`),value:l(),version:n().int()}),x({kind:p(`missing`)}),x({kind:p(`unavailable`),reason:LR}),x({kind:p(`forbidden`)})]),BR=m(l(),zR),VR=x({ref:l(),owner:l(),scope:l(),fieldPath:l(),version:n().int(),createdAt:n(),updatedAt:n(),updatedBy:l(),lastReadAt:n().nullable()}),UTe=512,HR=C(l().min(1)).max(512),UR={name:`keychain`,scope:`system`,mode:`singleton`,internal:!0,methods:{put:A(x({ref:l().min(1),value:l().min(1)}),x({ref:l(),version:n().int()}),{kind:`mutation`,auth:`admin`}),resolve:A(x({refs:HR}),BR,{auth:`admin`}),delete:A(x({refs:HR}),x({deleted:n().int()}),{kind:`mutation`,auth:`admin`}),deleteDeviceScope:A(x({deviceId:n().int()}),x({refs:C(l()).readonly()}),{kind:`mutation`,auth:`admin`}),releaseRecordRefs:A(x({refs:HR,onBehalfOf:l().min(1)}),x({released:n().int()}),{kind:`mutation`,auth:`admin`}),listMeta:A(x({}),C(VR).readonly(),{auth:`admin`}),getState:A(x({}),RR,{auth:`admin`})},vocabulary:{notOperatorFacing:M.IDENTITY}},WR=S([`mounted-file`,`previous-mounted-file`,`platform`,`default-file`]),GR=x({kind:WR,path:l().optional(),sharesBackupWithDatabase:y()}),WTe=`trigger-file`,KR=x({id:l(),at:n(),actor:l(),lockedReason:l().nullable(),archived:n().int(),archivedCollection:l().nullable(),archivedKeysCollection:l().nullable(),clearedSettingsKeys:C(l()).readonly(),acknowledgedAt:n().nullable()}),qR=x({keychain:RR,keySource:GR.nullable(),configuredSource:GR,fingerprint:l().nullable(),activeKeyId:l().nullable(),rotationPending:y(),retiredWraps:n().int(),recoveryKeyDownloadedAt:n().nullable(),secretCount:n().int(),lastReset:KR.nullable()}),JR=S([`in-use`,`orphan`,`unknown`]),YR=VR.extend({usage:JR}),XR=S([`put`,`delete`,`reveal`,`rotate-master-key`,`purge-retired-keys`,`download-recovery-key`,`delete-orphans`,`reset`,`acknowledge-reset`,`initialize`]),ZR=x({id:l(),at:n(),action:XR,actor:l(),ref:l().nullable(),detail:l().nullable()}),QR=`RESET KEYCHAIN`,$R=S([`jwt-signing-key`]),ez={name:`keychain-admin`,scope:`system`,mode:`singleton`,methods:{status:A(x({}),qR,{auth:`admin`}),listSecrets:A(x({}),C(YR).readonly(),{auth:`admin`}),listAudit:A(x({limit:n().int().min(1).max(500).optional()}),C(ZR).readonly(),{auth:`admin`}),reveal:A(x({ref:l().min(1)}),x({value:l(),version:n().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),setSystemSecret:A(x({name:$R,value:l().min(16)}),x({ref:l(),version:n().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),importSecret:A(x({ref:l().min(1),value:l().min(1)}),x({ref:l(),version:n().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),deleteOrphans:A(x({refs:C(l().min(1)).max(1e3)}),x({deleted:C(l()).readonly(),kept:C(x({ref:l(),usage:JR})).readonly()}),{kind:`mutation`,auth:`admin`,caller:`required`}),rotateMasterKey:A(x({}),x({fingerprint:l(),keySource:GR}),{kind:`mutation`,auth:`admin`,caller:`required`}),purgeRetiredKeys:A(x({}),x({purged:n().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),downloadRecoveryKey:A(x({}),x({key:l(),fingerprint:l(),keySource:GR}),{kind:`mutation`,auth:`admin`,caller:`required`}),resetKeychain:A(x({confirm:p(QR)}),x({archivedCollection:l().nullable(),archived:n().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),resetReport:A(x({}),x({reset:KR.nullable(),pendingReentry:C(VR).readonly()}),{auth:`admin`}),acknowledgeReset:A(x({}),x({acknowledged:y()}),{kind:`mutation`,auth:`admin`,caller:`required`})},vocabulary:{notOperatorFacing:M.IDENTITY}},tz=S([`idle`,`mowing`,`paused`,`docked`,`error`]),nz=S([`info`,`warning`,`error`]),rz=x({activity:tz,batteryLevel:n().min(0).max(100).nullable().meta(N(`percentage`)),progress:n().min(0).max(100).nullable().meta(N(`percentage`)),currentCode:n().nullable().meta(N(`none`)),currentCodeLabel:l().nullable(),severity:nz,lastChangedAt:n()}),iz={name:`lawn-mower-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.LawnMower],methods:{startMowing:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.start`,label:F(`Start mowing`,`Avvia il taglio`),phrase:F(`Start {device} mowing`,`Fai partire il taglio di {device}`),icon:`play`}]}),pause:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.pause`,label:F(`Pause mower`,`Metti in pausa il tosaerba`),phrase:F(`Pause {device}`,`Metti in pausa {device}`),icon:`pause`}]}),dock:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.dock`,label:F(`Dock mower`,`Riporta alla base`),phrase:F(`Send {device} back to its dock`,`Rimanda {device} alla base`),icon:`house`}]})},status:{schema:rz,kind:`push`},runtimeState:rz,durability:`session`,history:{fields:{batteryLevel:{kind:`gauge`,unit:`%`,deadband:2}}},vocabulary:{noun:F(`Robot mower`,`Robot tosaerba`),order:2010,state:[{kind:`enum`,field:`activity`,label:F(`Activity`,`Attività`),values:[{value:`idle`,label:F(`Idle`,`Inattivo`)},{value:`mowing`,label:F(`Mowing`,`In taglio`),phrase:F(`When {device} starts mowing`,`Quando {device} inizia a tagliare`)},{value:`paused`,label:F(`Paused`,`In pausa`)},{value:`docked`,label:F(`Docked`,`Alla base`),phrase:F(`When {device} docks`,`Quando {device} arriva alla base`)},{value:`error`,label:F(`Error`,`Errore`),phrase:F(`When {device} reports an error`,`Quando {device} segnala un errore`)}],icon:`bot`},{kind:`numeric`,field:`batteryLevel`,quantity:F(`the battery level`,`il livello della batteria`),label:F(`Battery`,`Batteria`),unit:`%`,icon:`battery`}]}},az=6e5,GTe=60*6e4,oz=x({inputTokens:n(),outputTokens:n()}),sz=S([`timeout`,`rate-limited`,`auth`,`refusal`,`bad-request`,`unavailable`,`no-profile`,`budget-exceeded`,`adapter-error`]),cz=x({ok:p(!0),text:l(),model:l(),usage:oz,truncated:y(),latencyMs:n()}),lz=S([`guardrail`,`model`]),uz=x({ok:p(!1),code:sz,message:l(),retryAfterMs:n().optional(),refusalSource:lz.optional()}),dz=i(`ok`,[cz,uz]),fz=x({bytes:b(Uint8Array),mimeType:l()}),pz=x({enabled:y().default(!1),maxAttempts:n().int().min(1).max(5).default(1)}),KTe={totalMs:6e4,connectMs:1e4,firstTokenMs:12e4,idleMs:6e4},mz=x({addonId:l().optional(),profileId:l().optional(),consumer:l(),system:l().optional(),prompt:l(),jsonSchema:m(l(),w()).optional(),maxTokens:n().int().positive().optional(),temperature:n().optional(),topP:n().min(0).max(1).optional(),topK:n().int().positive().optional(),reasoningEffort:S([`off`,`low`,`medium`,`high`]).optional(),timeoutMs:n().int().positive().optional(),retry:pz.optional(),requestId:l().optional()}),hz=x({url:l(),filename:l(),sizeBytes:n(),sha256:l().optional()}),gz=i(`kind`,[x({kind:p(`catalog`),catalogId:l()}),x({kind:p(`url`),url:l(),sha256:l().optional(),label:l().optional(),sizeBytes:n().optional(),extraFiles:C(hz).optional()}),x({kind:p(`path`),path:l()})]),_z=x({nodeId:l(),engine:S([`llama-cpp`]),model:gz,contextSize:n().int().default(4096),gpuLayers:n().int().default(0),threads:n().int().optional(),parallel:n().int().default(1),batchSize:n().int().positive().optional(),ubatchSize:n().int().positive().optional(),flashAttention: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(l()).default([]),autoStart:y().default(!1),idleStopMinutes:n().int().default(30)}),vz=x({phase:S([`downloading`,`verifying`]),file:l(),fileIndex:n().int(),fileCount:n().int(),downloadedBytes:n(),totalBytes:n().optional()}),yz=x({nodeId:l(),state:S([`stopped`,`downloading`,`starting`,`ready`,`crashed`,`failed`]),pid:n().optional(),port:n().optional(),modelPath:l().optional(),modelId:l().optional(),downloadProgress:n().min(0).max(1).optional(),download:vz.optional(),lastError:l().optional(),crashesInWindow:n(),memoryBytes:n().optional(),vramBytes:n().optional()}),bz=x({file:l(),sizeBytes:n(),catalogId:l().optional(),installedAt:n().optional(),path:l().optional()}),xz=x({nodeId:l(),modelsBytes:n(),freeBytes:n().optional()}),Sz=mz.extend({images:C(fz).optional(),runtime:_z,timeoutMs:n().int().positive().optional()}),Cz=S([`deviceNotEligible`,`appleIntelligenceNotEnabled`,`modelNotReady`,`osTooOld`,`helperMissing`,`helperCrashed`]),wz=i(`state`,[x({state:p(`available`),osVersion:l(),contextSize:n().int().positive(),languages:C(l()),imageInput:y()}),x({state:p(`unavailable`),reason:Cz,osVersion:l().nullable(),detail:l()}),x({state:p(`unsupported-platform`),platform:l()}),x({state:p(`unknown`),error:l()})]),Tz=mz.extend({images:C(fz).optional(),timeoutMs:n().int().positive().optional()}),Ez=x({requestId:l()}),Dz={name:`llm-runtime`,scope:`system`,mode:`singleton`,internal:!0,methods:{complete:A(Sz,dz,{kind:`mutation`,auth:`admin`,timeoutMs:az}),ensureStarted:A(x({runtime:_z}),yz,{kind:`mutation`,auth:`admin`,timeoutMs:az}),stop:A(x({}),v(),{kind:`mutation`,auth:`admin`}),status:A(x({}),yz,{auth:`admin`}),installModel:A(x({model:gz}),v(),{kind:`mutation`,auth:`admin`,timeoutMs:GTe}),deleteModel:A(x({file:l()}),v(),{kind:`mutation`,auth:`admin`}),listLocalModels:A(x({}),C(bz),{auth:`admin`}),getDiskUsage:A(x({}),xz,{auth:`admin`}),cancel:A(Ez,v(),{kind:`mutation`,auth:`admin`}),appleAvailability:A(x({}),wz,{auth:`admin`}),completeApple:A(Tz,dz,{kind:`mutation`,auth:`admin`,timeoutMs:az})},vocabulary:{notOperatorFacing:M.ML}},Oz=/^[a-z0-9][a-z0-9-]{0,63}$/,kz=l().regex(Oz,`a kind id is lower-case letters, digits and dashes`),Az=x({vision:y(),tools:y(),streaming:y(),reasoning:y().nullable().optional()}),jz=x({id:l(),label:l().optional(),contextLength:n().int().positive().optional(),features:Az.partial().optional()}),Mz=m(l(),w()),qTe=x({id:l(),name:l(),kind:kz,addonId:l(),enabled:y(),model:l(),supportsVision:y(),temperature:n().min(0).max(2).optional(),topP:n().min(0).max(1).optional(),topK:n().int().positive().optional(),maxTokens:n().int().positive().optional(),reasoningEffort:S([`off`,`low`,`medium`,`high`]).optional(),contextLength:n().int().positive().optional(),systemPrompt:l().optional(),timeoutMs:n().int().positive().default(6e4),connectTimeoutMs:n().int().positive().default(1e4),firstTokenTimeoutMs:n().int().positive().default(12e4),idleTimeoutMs:n().int().positive().default(6e4),retry:pz.default({enabled:!1,maxAttempts:1}),toolsEnabled:y().default(!1),providerConfig:Mz.default({})}),Nz=S([`temperature`,`topP`,`topK`,`maxTokens`,`reasoningEffort`,`contextLength`,`systemPrompt`,`timeoutMs`,`connectTimeoutMs`,`firstTokenTimeoutMs`,`idleTimeoutMs`,`retry`,`toolsEnabled`]),Pz=x({id:l(),placement:S([`connection`,`model`]),requires:C(l()).optional()}),Fz=w(),JTe=x({kind:kz,label:l(),icon:l(),addonId:l(),connectionSchema:Fz,advancedSchema:Fz.optional(),features:Az,visionEditable:y(),modelCatalog:S([`fetch`,`static`,`none`]),staticModels:C(jz).optional(),profileFields:C(Nz),providerWidgets:C(Pz).optional()}),Iz=x({addonId:l(),kind:kz,profileId:l().optional(),connection:Mz.optional()}),Lz=S([`auth`,`network`,`unsupported`,`invalid`]),Rz=i(`ok`,[x({ok:p(!0),models:C(jz)}),x({ok:p(!1),code:Lz,message:l()})]),zz=h([x({consumer:l()}),x({purpose:S([`text`,`vision`])})]),Bz=x({selector:zz,profileId:l()}),Vz=x({day:l(),consumer:l(),profileId:l(),calls:n(),okCalls:n(),errorCalls:n(),inputTokens:n(),outputTokens:n(),avgLatencyMs:n()}),Hz=x({id:l(),label:l(),family:l(),purpose:S([`text`,`vision`]),url:l(),sha256:l(),sizeBytes:n(),quantization:l(),minRamBytes:n(),contextSizeDefault:n().int(),mmprojUrl:l().optional()}),Uz=i(`ok`,[x({ok:p(!0),model:gz,label:l(),repo:l(),quantization:l(),purpose:S([`text`,`vision`]),totalBytes:n(),extraFilenames:C(l())}),x({ok:p(!1),code:l(),message:l(),candidates:C(l()).optional(),requiredBytes:n().optional()})]),Wz=x({nodeId:l(),reachable:y(),status:yz.optional(),disk:xz.optional(),error:l().optional(),apple:wz.optional()}),YTe=mz.extend({images:C(fz).min(1)}),Gz=x({addonId:l(),profileId:l()}),Kz={name:`llm`,scope:`system`,mode:`collection`,internal:!1,providerKind:`ai`,nodeIdMode:`data`,methods:{generate:A(mz,dz,{kind:`mutation`,timeoutMs:az}),generateVision:A(YTe,dz,{kind:`mutation`,timeoutMs:az}),cancel:A(x({addonId:l().optional(),requestId:l()}),v(),{kind:`mutation`}),listModels:A(Iz,Rz,{kind:`mutation`,auth:`admin`}),getDefaults:A(x({}),C(Bz)),setDefault:A(x({selector:zz,profileId:l().nullable()}),v(),{kind:`mutation`,auth:`admin`}),getUsage:A(x({since:n().optional(),until:n().optional(),consumer:l().optional(),profileId:l().optional()}),C(Vz)),listModelCatalog:A(x({}),C(Hz)),listRuntimeNodes:A(x({}),C(Wz)),listNodeModels:A(x({nodeId:l()}),C(bz)),resolveModelRef:A(x({ref:l(),maxBytes:n().positive().optional()}),Uz,{kind:`mutation`,auth:`admin`}),installModel:A(x({nodeId:l(),model:gz}),v(),{kind:`mutation`,auth:`admin`}),deleteModel:A(x({nodeId:l(),file:l()}),v(),{kind:`mutation`,auth:`admin`}),getRuntimeStatus:A(Gz,yz),startRuntime:A(Gz,yz,{kind:`mutation`,auth:`admin`}),stopRuntime:A(Gz,v(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.ML}},qz=[`decode`,`transcode`,`recording`,`streaming`,`detection`],Jz=[`measured`,`accounted`,`unattributable`],Yz=x({role:S(qz),deviceId:n().int().positive().nullable(),attribution:S(Jz),unit:l(),pid:n().int().positive().optional(),startedAtMs:n().optional(),cpuSeconds:n().optional(),rssBytes:n().optional()}),Xz={name:`load-contribution`,scope:`system`,mode:`collection`,internal:!0,methods:{list:A(v(),C(Yz).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:M.INTERNAL}},Zz=`https://camstack.zentik.app`,Qz=`/viewer/camstack`;function $z(e){if(e==null||e===``)return!1;try{return new URL(e).origin===Zz}catch{return!1}}function XTe(e){let t=e.baseUrl??e.resolved;return $z(t)?{form:`app`,hubBaseUrl:e.appLinkHub??null}:{form:`hub`,hubBaseUrl:t}}function eB(e){let t;try{t=new URL(e)}catch{return null}return t.protocol!==`https:`&&t.protocol!==`http:`||t.username!==``||t.password!==``||t.hostname===``?null:t.origin}function ZTe(e){let t=e=>e.kind!==`public`||!e.baseUrl.startsWith(`https://`)?null:e.interfaceKind===`public`?0:e.interfaceKind===`vpn`?1:null;return e.flatMap(e=>{let n=t(e),r=eB(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 QTe(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 tB(e){return e.length===0?``:`?${e.map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join(`&`)}`}function $Te(e){let t=QTe(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:eB(r),n=e===null?t.query:[...t.query,[`hub`,e]];return`${Zz}${t.path}${tB(n)}`}return r===``||$z(r)?null:`${r}${Qz}${t.path}${tB(t.query)}`}var nB=[`appConnections`,`notificationTaps`,`internal`,`publicEndpoint`],eEe=[`notificationTaps`,`internal`,`publicEndpoint`];function tEe(e){return e!==`appConnections`}var nEe={appConnections:[],notificationTaps:null,internal:null,publicEndpoint:null},rEe=/^\d{1,3}(?:\.\d{1,3}){3}$/;function rB(e){try{let t=new URL(e).hostname;return t.length>0?t:null}catch{return null}}function iEe(e){return e.replace(/\/+$/,``)}function iB(e){return e.kind===`public`&&e.interfaceKind===`vpn`}function aEe(e){return e.kind===`public`&&e.interfaceKind===`public`}function aB(e){return(e.kind===`lan-ipv4`||e.kind===`lan-ipv6`)&&e.plausible}function oB(e){if(e.kind!==`lan-ipv4`||!e.plausible)return!1;let t=rB(e.baseUrl);return t!==null&&rEe.test(t)}function sB(e){return e.stable===!1}function oEe(e,t){return t.kind===`loopback`||t.kind===`app-link`||t.kind===`custom`||rB(t.baseUrl)===null||sB(t)?null:e===`internal`?oB(t)?0:aB(t)?1:iB(t)?2:null:aEe(t)?0:iB(t)?1:oB(t)?2:aB(t)?3:null}var sEe=new Set([`localhost`,`0.0.0.0`,`::1`,`[::1]`,`::`,`[::]`]);function cEe(e){let t=e.toLowerCase();return sEe.has(t)||t.endsWith(`.localhost`)?!0:/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(t)}function cB(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.`}:cEe(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 lB=`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 uB(e,t,n={}){if($z(t))return e===`notificationTaps`?{ok:!0,baseUrl:Zz}:{ok:!1,reason:`The CamStack app link is not a hub address — only notification taps can use it.`};let r=cB(t);return r.ok&&e===`publicEndpoint`&&r.baseUrl.startsWith(`http:`)&&n.acceptInsecureHttp!==!0?{ok:!1,reason:lB}:r}function dB(e,t){if(t===null||t===``)return null;let n=uB(e,t,{acceptInsecureHttp:!0});return n.ok?n.baseUrl:null}function lEe(e,t){let n=e.flatMap(e=>{let n=oEe(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:iEe(n.endpoint.baseUrl)}function fB(e,t,n){let r=dB(t,n);if(r!==null)return{flagged:r,resolved:r,source:`flagged`};let i=lEe(e,t);return{flagged:null,resolved:i,source:i===null?`none`:`auto`}}function pB(e,t){return fB(e,`internal`,t.internal)}function mB(e,t){return fB(e,`publicEndpoint`,t.publicEndpoint)}function hB(e){let t=dB(`notificationTaps`,e.notificationTaps);return t!==null&&!$z(t)?{flagged:t,resolved:t,source:`flagged`}:{flagged:null,resolved:Zz,source:`auto`}}function gB(e){return sB(e)?!1:e.kind===`lan-ipv4`?!0:e.kind===`public`&&e.interfaceKind===`public`}function _B(e,t){let n=e.filter(gB);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 vB(e,t){let n=new Set(t.appConnections),r=_B(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 uEe(e,t,n){return{appConnections:vB(e,n),notificationTaps:hB(n),internal:pB(t,n),publicEndpoint:mB(t,n)}}function dEe(e){return e===null?null:rB(e)}var fEe=`camstack`,pEe=`_camstack._tcp.local`,mEe={nodeId:`nodeId`,version:`version`,role:`role`,url:`url`,hubId:`hubId`},hEe=`hub`,yB=/^hub-[0-9a-f]{16}$/;function gEe(e){return typeof e==`string`&&yB.test(e)}var _Ee=`camstack-agent`,vEe=`_camstack-agent._tcp.local`,yEe={nodeId:`nodeId`,version:`version`,name:`name`,state:`state`,keyFingerprint:`fp`},bEe=S([`lan`,`wifi`,`docker`,`vpn`,`loopback`,`other`]),bB=x({name:l(),family:S([`IPv4`,`IPv6`]),address:l(),cidr:l(),netmask:l(),internal:y(),mac:l(),kind:bEe,preferred:y(),plausible:y(),plausibleReason:l()}),xEe=x({interfaces:C(bB).readonly(),probedAt:n()}),SEe=bB.nullable(),xB=x({label:l(),baseUrl:l(),kind:S([`lan-ipv4`,`lan-ipv6`,`public`,`loopback`,`app-link`,`custom`]),interfaceKind:S([`lan`,`wifi`,`docker`,`vpn`,`other`,`loopback`,`public`]),plausible:y(),plausibleReason:l(),priority:n(),stable:y().optional()}),CEe=S([`server-config`,`server-env`,`caller-hint`,`default`]),wEe=x({port:n().int().min(1).max(65535),source:CEe}),TEe=x({endpoints:C(xB).readonly(),localPort:wEe}),SB=x({baseUrl:l().nullable(),resolved:l().nullable(),appLinkHub:l().nullable()}),CB=x({baseUrls:C(l()).readonly(),resolved:C(l()).readonly()}),wB=x({override:l().nullable(),resolved:l().nullable(),source:S([`override`,`auto`,`none`])}),EEe=x({cluster:wB,browser:wB}),TB=S(nB),EB=S([`flagged`,`auto`,`none`]),DB=x({flagged:l().nullable(),resolved:l().nullable(),source:EB}),DEe=x({flagged:C(l()).readonly(),resolved:C(l()).readonly(),source:EB}),OB=x({rows:C(xB.extend({detected:y(),custom:y(),flags:C(TB).readonly(),inUse:C(TB).readonly(),eligible:C(TB).readonly()})).readonly(),roles:x({appConnections:DEe,notificationTaps:DB,internal:DB,publicEndpoint:DB}),appLinkHub:l().nullable(),listenerOrigins:C(l()).readonly().optional()}),kB=x({addresses:C(l()).readonly()}),AB=x({mode:S([`generated`,`uploaded`,`disabled`]),leafFingerprintSha256:l().nullable(),caFingerprintSha256:l().nullable(),validTo:l().nullable(),sans:C(l()),caCertPem:l().nullable(),reissueError:l().nullable(),restartRequired:y(),caMissing:y(),localCaConstrained:y().nullable(),caReplacedAt:l().nullable(),storedUpload:x({leafFingerprintSha256:l(),validTo:l(),hasCa:y()}).nullable()}),OEe=x({providerId:l().min(1),modes:C($j)}),kEe=x({providerId:l().optional(),mode:l().optional(),message:l()}),AEe=x({hostsProbed:n().int(),hits:n().int(),timeouts:n().int(),byMode:m(l(),x({probed:n().int(),hits:n().int(),timeouts:n().int()}))}),jEe=x({hits:C(x({providerId:l(),hit:eM})),subnetsScanned:C(l()),errors:C(kEe),stats:AEe}),jB={name:`local-network`,scope:`system`,mode:`singleton`,methods:{list:A(v(),xEe),getPreferred:A(v(),SEe),getConnectionEndpoints:A(x({port:n().int().min(1).max(65535).optional(),includeLoopback:y().optional(),ipv4Only:y().optional(),scheme:S([`http`,`https`]).optional(),includeAppLink:y().optional()}),TEe),getNotificationEndpoint:A(v(),SB),setNotificationEndpoint:A(x({baseUrl:l().nullable()}),SB,{kind:`mutation`}),getViewerEndpoints:A(v(),CB),setViewerEndpoints:A(x({baseUrls:C(l()).readonly()}),CB,{kind:`mutation`}),getAddresses:A(x({scheme:S([`http`,`https`]).optional()}).optional(),OB),addCustomAddress:A(x({baseUrl:l(),label:l().max(80)}),OB,{kind:`mutation`,auth:`admin`}),removeCustomAddress:A(x({baseUrl:l()}),OB,{kind:`mutation`,auth:`admin`}),setAddressRole:A(x({role:TB,baseUrl:l().nullable(),enabled:y(),acceptInsecureHttp:y().optional()}),OB,{kind:`mutation`,auth:`admin`}),getHubAddresses:A(v(),EEe),getAllowedAddresses:A(v(),kB),setAllowedAddresses:A(kB,x({success:p(!0)}),{kind:`mutation`}),resetAllowlistToBestMatch:A(v(),kB,{kind:`mutation`}),getTlsStatus:A(v(),AB),regenerateCertificate:A(x({reason:l().optional()}),AB,{kind:`mutation`,auth:`admin`}),uploadCertificate:A(x({certPem:l().min(1),keyPem:l().min(1),caPem:l().optional()}),AB,{kind:`mutation`,auth:`admin`}),downloadCa:A(v(),x({pem:l()})),useStoredUploadedCertificate:A(v(),AB,{kind:`mutation`,auth:`admin`}),scanNetwork:A(x({requests:C(OEe),subnets:C(l()).optional()}),jEe,{kind:`mutation`,auth:`admin`,timeoutMs:9e4}),getScanSubnets:A(v(),x({subnets:C(l())}),{auth:`admin`}),setScanSubnets:A(x({subnets:C(l())}),x({subnets:C(l())}),{kind:`mutation`,auth:`admin`}),revertToGeneratedCertificate:A(v(),AB,{kind:`mutation`,auth:`admin`})},mount:{kind:`hub-only`},vocabulary:{notOperatorFacing:M.NETWORK}},MB=S([`locked`,`unlocked`,`locking`,`unlocking`,`jammed`,`door-open`]),NB=x({state:MB,codeRequired:y().nullable().optional(),lastChangedAt:n()}),MEe={version:1,overridable:[{path:`state`,by:`door-contact`}],targets:[{id:`door-contact`,cardinality:`scalar`,vocabulary:{cap:`lock-control`,stateField:`state`},deviceTypes:[E.Lock],apply:`replace`,path:`state`,override:{whenSourceTrue:`door-open`,unlessNative:[`jammed`]},sources:[{kind:`binary`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}]},PB={name:`lock-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Lock],methods:{lock:A(x({deviceId:n().int().nonnegative(),code:l().min(1).optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.lock`,label:F(`Lock`,`Chiudi a chiave`),phrase:F(`Lock {device}`,`Chiudi a chiave {device}`),icon:`lock`,effect:{field:`state`,value:`locked`},hold:{effects:[{field:`state`,value:`locking`,when:{field:`state`,notIn:[`locked`]}}]},openArgs:[{key:`code`,label:F(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]}),unlock:A(x({deviceId:n().int().nonnegative(),code:l().min(1).optional(),confirm:y().optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.unlock`,label:F(`Unlock`,`Apri la serratura`),phrase:F(`Unlock {device}`,`Sblocca {device}`),icon:`lock-open`,effect:{field:`state`,value:`unlocked`},hold:{effects:[{field:`state`,value:`unlocking`,when:{field:`state`,notIn:[`unlocked`]}}]},openArgs:[{key:`code`,label:F(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]}),open:j(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.open`,label:F(`Open latch`,`Apri lo scrocco`),phrase:F(`Release the latch of {device}`,`Fai scattare lo scrocco di {device}`),icon:`door-open`}]})},status:{schema:NB,kind:`push`},runtimeState:NB,customize:MEe,durability:`restored`,history:{fields:{state:{kind:`enum`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Lock`,`Serratura`),order:1060,state:[{kind:`enum`,field:`state`,label:F(`Lock state`,`Stato della serratura`),values:[{value:`locked`,label:F(`Locked`,`Chiusa a chiave`),phrase:F(`When {device} locks`,`Quando {device} si chiude a chiave`)},{value:`unlocked`,label:F(`Unlocked`,`Sbloccata`),phrase:F(`When {device} unlocks`,`Quando {device} si sblocca`)},{value:`locking`,label:F(`Locking`,`In chiusura`),phrase:F(`When {device} starts locking`,`Quando {device} inizia a chiudersi`)},{value:`unlocking`,label:F(`Unlocking`,`In apertura`),phrase:F(`When {device} starts unlocking`,`Quando {device} inizia a sbloccarsi`)},{value:`jammed`,label:F(`Jammed`,`Inceppata`),phrase:F(`When {device} jams`,`Quando {device} si inceppa`)},{value:`door-open`,label:F(`Door open`,`Porta aperta`),phrase:F(`When the door of {device} opens`,`Quando la porta di {device} si apre`)}],icon:`lock`}]}},FB=x({armed:n().int().min(0),unknown:C(l()).readonly()}),IB={name:`log-channels`,scope:`system`,mode:`collection`,internal:!0,methods:{list:A(v(),C(kh).readonly()),apply:A(x({windows:C(Jle).readonly()}),FB,{kind:`mutation`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:M.INTERNAL}},LB=S([`debug`,`info`,`warn`,`error`]),RB=x({timestamp:g(),level:LB,scope:C(l()),message:l(),meta:m(l(),w()).optional(),tags:m(l(),l()).optional()}),zB=x({instanceId:l().min(1).max(200).optional(),requestId:l().min(1).max(64).optional(),deviceId:n().int().optional(),fromAddonId:l().min(1).max(200).optional(),fromNodeId:l().min(1).max(200).optional(),tags:m(l(),h([l(),n()])).optional(),level:LB.optional(),text:l().min(1).max(200).optional(),since:n().optional(),until:n().optional(),before:l().min(1).max(1024).optional(),after:l().min(1).max(1024).optional(),limit:n().int().min(1).max(1e3).optional(),budgetMs:n().int().min(50).max(1e4).optional()}),BB=x({id:l().optional(),timestamp:n(),level:LB,scope:l().optional(),message:l(),tags:m(l(),h([l(),n()])).optional(),meta:m(l(),w()).optional()}),VB=x({entries:C(BB),nextBefore:l().nullable(),nextAfter:l().nullable(),scannedBytes:n().int().nonnegative(),done:y(),cancelled:y().optional()}),NEe=x({instanceId:l().min(1).max(200).optional()}),HB=x({readable:y(),reason:l().nullable(),filters:x({deviceId:y(),addonId:y(),nodeId:y(),tags:y(),level:y(),text:y(),timeRange:y()}),retentionDays:n().nullable()}),UB={name:`log-destination`,scope:`system`,mode:`collection`,internal:!0,methods:{write:A(RB,v(),{kind:`mutation`}),describeRead:j(NEe,HB,{auth:`admin`}),read:j(zB,VB,{auth:`admin`}),cancelRead:j(x({requestId:l().min(1).max(64)}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:M.INTERNAL}},WB=S([`primary`,`second-factor`]),GB=x({kind:p(`redirect`),id:l(),label:l(),icon:l().optional(),startUrl:l(),stage:WB,linkable:y().optional(),app:gg.nullable().optional()}),KB=x({kind:p(`widget`),id:l(),addonId:l(),bundle:l(),remote:mS,stage:WB,app:gg.nullable().optional()}),qB=x({kind:p(`passkey`),id:l(),label:l(),stage:WB,rpId:l(),origin:l().nullable(),app:gg.nullable().optional()}),JB=i(`kind`,[GB,KB,qB]),YB={name:`login-method`,scope:`system`,mode:`collection`,internal:!0,methods:{getLoginMethods:A(v(),C(JB).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:M.IDENTITY}},XB=x({sleeping:y().meta({label:`Sleeping`}),lastContactAt:n().optional(),lastUpdated:n().meta(N(`none`))}),ZB={name:`low-power-sleep`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],methods:{wakeUp:A(x({deviceId:n(),timeoutMs:n().int().min(500).max(3e4).default(8e3)}),x({awoke:y(),durationMs:n()}),{kind:`mutation`,notOperatorFacing:`a stream consumer wakes a sleeping camera to watch it; an automation that wants footage asks for the footage`})},status:{schema:XB,kind:`push`,empty:{sleeping:!1,lastUpdated:0}},runtimeState:XB,durability:`restored`,history:`none`,volatileStateFields:[`lastUpdated`],vocabulary:{noun:F(`Low-power sleep`,`Sospensione a basso consumo`),order:5245}},PEe=x({id:l(),label:l(),scope:S([`mesh`,`public`]),url:l(),hostname:l(),port:n(),protocol:S([`http`,`https`])}),QB=x({id:l(),hostname:l(),magicDns:l(),addresses:C(l()).readonly(),os:l().optional(),online:y(),lastSeenMs:n(),isSelf:y(),connection:S([`direct`,`relay`,`idle`]),relay:l().nullable(),lastHandshakeMs:n(),rxBytes:n(),txBytes:n(),tags:C(l()).readonly(),exitNodeOption:y(),advertisedRoutes:C(l()).readonly(),userLogin:l().nullable(),keyExpiry:n().nullable()}),$B=x({joined:y(),meshIp:l(),magicDnsHostname:l(),peerCount:n(),endpoints:C(PEe).readonly(),error:l().optional(),tenantName:l(),magicDnsSuffix:l(),userLogin:l().nullable(),controlPlaneUrl:l(),keyExpiry:n().nullable(),daemonSocket:l().optional(),daemonCliPath:l().optional()}),eV={name:`mesh-network`,scope:`system`,mode:`collection`,providerKind:`mesh`,methods:{getStatus:A(v(),$B),join:A(x({authKey:l().min(8),hostname:l().optional()}),x({joined:p(!0)}),{kind:`mutation`}),startLogin:A(x({hostname:l().optional()}),x({loginUrl:l()}),{kind:`mutation`}),leave:A(v(),x({left:p(!0)}),{kind:`mutation`}),logout:A(v(),x({loggedOut:p(!0)}),{kind:`mutation`}),listPeers:A(v(),x({peers:C(QB).readonly()}))},vocabulary:{notOperatorFacing:M.NETWORK}},tV=x({value:n().nullable().meta(N(`device`,{label:`Total`})),lastFetchedAt:n()}),nV={name:`meter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:tV,kind:`push`},runtimeState:tV,durability:`restored`,history:{fields:{value:{kind:`counter`,deadband:.001,minIntervalMs:6e4}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Meter`,`Contatore`),order:5140,state:[{kind:`numeric`,field:`value`,quantity:F(`the total`,`il totale`),label:F(`Total`,`Totale`),icon:`gauge`}]}},FEe=x({total:n(),user:n(),system:n(),irq:n(),nice:n(),loadAvg:u([n(),n(),n()]),cores:n()}),IEe=x({percent:n().nullable(),totalBytes:n(),usedBytes:n().nullable(),availableBytes:n().nullable(),swapUsedBytes:n(),swapTotalBytes:n()}),LEe=x({readBytes:n(),writeBytes:n(),readOps:n(),writeOps:n(),timestampMs:n()}),REe=x({rxBytes:n(),txBytes:n(),rxPackets:n(),txPackets:n(),rxErrors:n(),txErrors:n(),timestampMs:n()}),rV=x({utilization:n(),model:l(),memoryUsedBytes:n(),memoryTotalBytes:n(),temperature:n().nullable()}),zEe=x({openFds:n(),threadCount:n(),activeHandles:n(),activeRequests:n()}),iV=x({avg10:n(),avg60:n(),avg300:n()}),aV=x({some:iV,full:iV.nullable()}),oV=x({cpu:FEe,memory:IEe,gpu:rV.nullable(),network:REe,disk:LEe,pressure:x({cpu:aV.nullable(),memory:aV.nullable(),io:aV.nullable()}),process:zEe,cpuTemperature:n().nullable(),timestampMs:n()}),BEe=x({path:l(),totalBytes:n(),usedBytes:n(),availableBytes:n(),percent:n()}),sV=x({pid:n(),cpu:n(),memory:n(),privateBytes:n().optional(),sharedBytes:n().optional()}),VEe=x({addonId:l(),nodeId:l(),role:S([`hub`,`worker`]),pid:n(),state:S([`starting`,`running`,`stopping`,`stopped`,`crashed`]),uptimeSec:n()}),HEe=x({pid:n(),ppid:n(),pgid:n(),classification:S([`root`,`managed`,`system`]),addonId:l().nullable(),nodeId:l().nullable(),command:l(),cpuPercent:n(),memoryRssBytes:n(),cpuMainPercent:n().nullable(),cpuGcPercent:n().nullable(),threadCount:n().nullable(),uptimeSec:n()}),UEe=x({source:S([`cgroup-v2`,`cgroup-v1`]),currentBytes:n(),limitBytes:n().nullable(),anonBytes:n().nullable(),fileBytes:n().nullable(),shmemBytes:n().nullable(),slabBytes:n().nullable(),gpuShmemBytes:n().nullable()}).extend({atMs:n()}),WEe=x({atMs:n(),samples:n().int(),cpuMainPercent:n().nullable(),cpuMainPercentMin:n().nullable(),cpuGcPercent:n().nullable(),cpuGcPercentMin:n().nullable(),cpuLifetimePercent:n(),cpuLifetimePercentMin:n(),memoryRssBytes:n(),memoryRssBytesMin:n(),processCount:n().int(),processCountMin:n().int()}),GEe=x({key:l(),kind:S([`addon`,`root`,`unattributed`]),points:C(WEe).readonly()}),KEe=x({nodeId:l(),series:C(GEe).readonly(),containerMemory:C(UEe).readonly(),bucketMs:n(),retainedSamples:n(),oldestAtMs:n().nullable(),cadenceMs:n(),durable:y()}),qEe=x({forNodeId:l(),sinceMs:n().optional(),maxPoints:n().int().positive().optional()}),cV=x({cpuPercent:n(),memoryPercent:n().nullable(),memoryUsedMB:n().nullable(),memoryTotalMB:n(),diskPercent:n().optional(),temperature:n().optional(),gpuPercent:n().optional(),gpuMemoryPercent:n().optional()}),lV={name:`metrics-provider`,scope:`system`,mode:`singleton`,methods:{collectSnapshot:A(v(),oV),getCached:A(v(),oV.nullable()),getCurrent:A(v(),cV),getDiskSpace:A(x({dirPath:l()}),BEe),getGpuInfo:A(v(),rV.nullable()),getCpuTemperature:A(v(),n().nullable()),getProcessStats:A(x({pids:C(n())}),C(sV)),listAddonInstances:A(v(),C(VEe).readonly()),getAddonStats:A(x({addonId:l()}),sV.nullable()),listNodeProcesses:A(v(),C(HEe).readonly()),getLoadSeries:A(qEe,KEe)},vocabulary:{notOperatorFacing:M.CLUSTER}},uV=l().min(1).max(256),dV=m(l(),w()),fV=x({id:uV,deviceId:n().int().optional(),at:n().int().optional(),expiresAt:n().int().optional(),data:dV}),pV=x({id:l(),deviceId:n().int().nullable(),at:n().nullable(),expiresAt:n().nullable(),rev:n().int(),updatedAt:n(),data:dV}),mV=m(si,h([l(),n(),y(),x({in:C(h([l(),n(),y()])).min(1).max(Ln)}),x({gt:h([l(),n()]).optional(),gte:h([l(),n()]).optional(),lt:h([l(),n()]).optional(),lte:h([l(),n()]).optional()}).refine(e=>Object.keys(e).length>0,{message:`name at least one bound`})])),hV={kind:pi},gV={deviceId:n().int().optional(),atFrom:n().optional(),atTo:n().optional()},_V=x({...hV,...gV,where:mV.optional(),order:S([`at`,`id`]).optional(),desc:y().optional(),limit:n().int().min(1).max(zn).default(100),cursor:l().min(1).optional()}),vV=x({records:C(pV),nextCursor:l().nullable()}),JEe=S([`created`,`unchanged`,`updated`]),yV=x({kindId:n().int(),state:JEe,createdIndexes:C(l())}),bV=C(l()),xV=i(`op`,[x({op:p(`put`),kind:pi,record:fV,ifRev:n().int().min(0).optional()}),x({op:p(`patch`),kind:pi,id:uV,data:dV,at:n().int().nullable().optional(),expiresAt:n().int().nullable().optional(),ifRev:n().int().min(1).optional()}),x({op:p(`delete`),kind:pi,id:uV})]),SV=m(l(),m(l(),l())),CV={name:`records`,scope:`system`,mode:`singleton`,internal:!0,methods:{declareKinds:A(x({kinds:m(pi,fi)}),x({kinds:m(l(),yV)}),{kind:`mutation`,auth:`admin`}),get:A(x({...hV,id:uV}),pV.nullable(),{auth:`admin`}),getMany:A(x({...hV,ids:C(uV).min(1).max(Ln)}),C(pV),{auth:`admin`}),secretRefs:A(x({...hV,ids:C(uV).min(1).max(Ln)}),SV,{auth:`admin`}),put:A(x({...hV,record:fV,ifRev:n().int().min(0).optional()}),x({rev:n().int(),releasedRefs:bV}),{kind:`mutation`,auth:`admin`}),putMany:A(x({...hV,records:C(fV).min(1).max(Ln)}),x({count:n().int(),releasedRefs:bV}),{kind:`mutation`,auth:`admin`}),patch:A(x({...hV,id:uV,data:dV,at:n().int().nullable().optional(),expiresAt:n().int().nullable().optional(),ifRev:n().int().min(1).optional()}),x({rev:n().int(),releasedRefs:bV}),{kind:`mutation`,auth:`admin`}),delete:A(x({...hV,id:uV}),x({deleted:y(),secretRefs:bV}),{kind:`mutation`,auth:`admin`}),deleteMany:A(x({...hV,ids:C(uV).min(1).max(Ln)}),x({deleted:n().int(),secretRefs:bV}),{kind:`mutation`,auth:`admin`}),query:A(_V,vV,{auth:`admin`}),count:A(x({...hV,...gV,where:mV.optional()}),x({count:n().int()}),{auth:`admin`}),histogram:A(x({...hV,deviceId:n().int().optional(),from:n(),to:n(),bucketMs:n().int().positive()}),x({buckets:C(x({bucketStart:n(),count:n().int()}))}),{auth:`admin`}),aggregate:A(x({...hV,op:S([`sum`,`min`,`max`,`count`]),field:si.optional(),groupBy:si.optional(),where:mV.optional()}),x({rows:C(x({group:h([l(),n(),ae()]),value:n().nullable()}))}),{auth:`admin`}),deleteWhere:A(x({...hV,deviceId:n().int().optional(),atBefore:n().optional(),where:mV.optional()}),x({deleted:n().int(),secretRefs:bV}),{kind:`mutation`,auth:`admin`}),transact:A(x({ops:C(xV).min(1).max(Ln)}),x({results:C(x({rev:n().int().nullable(),deleted:y()})),releasedRefs:bV,secretRefs:bV}),{kind:`mutation`,auth:`admin`}),deleteDevice:A(x({deviceId:n().int(),kinds:C(pi).optional()}),x({deleted:m(l(),n().int()),secretRefs:bV}),{kind:`mutation`,auth:`admin`}),allocateId:A(x(hV),x({id:n().int()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.INTERNAL}},wV=m(l(),w()),TV=x({integrationId:l().min(1)}),EV=x({id:l().min(1)}),DV=x({id:l(),deviceId:n().int().nullable(),at:n().nullable(),expiresAt:n().nullable(),rev:n().int(),updatedAt:n(),data:wV}),OV={id:l().min(1),deviceId:n().int().optional(),at:n().int().optional(),expiresAt:n().int().optional(),data:wV},kV=x({id:l(),addonId:l(),name:l(),info:wV,enabled:y().optional(),originStableId:l().optional()}),YEe=x({id:n().int(),integrationId:l().nullable().optional(),parentDeviceId:n().int().nullable().optional(),type:l().optional(),name:l().optional(),stableId:l().optional()}),AV=x({version:n().int(),methods:C(l())}),jV=x({message:l(),meta:wV.optional(),tags:x({deviceId:n().int().optional()}).optional()}),XEe={"ledger.declare":{input:x({owner:l().min(1),metas:C(Nf)}),output:x({bootId:l(),snapshot:S([`none`,`written`,`refused`]),steps:C(Jf),migrationApi:AV.optional()}),behaviours:[`ledger.declare.answers-steps-in-engine-order`,`ledger.declare.answers-the-migration-api`]},"ledger.start":{input:x({id:l().min(1)}),output:x({proceed:y(),state:h([p(`pending`),Wf]),reason:l().nullable()}),behaviours:[`ledger.start.proceeds-when-predecessors-applied`]},"ledger.finish":{input:x({id:l().min(1),result:Uf}),output:x({status:Wf,error:l().nullable(),rowsChanged:n().int().nonnegative()}),behaviours:[`ledger.finish.records-the-outcome`]},"legacyRows.read":{input:TV,output:wV,behaviours:[`legacyRows.read.returns-stored-rows`,`legacyRows.read.absent-store-is-empty`,`legacyRows.caller.sibling-package`]},"legacyRows.clear":{input:TV,output:x({rows:n().int().nonnegative(),secrets:n().int().nonnegative()}),behaviours:[`legacyRows.clear.deletes-the-rows`,`legacyRows.clear.absent-store-is-noop`]},"legacyRows.patch":{input:TV.extend({patch:wV}),output:x({written:y()}),behaviours:[`legacyRows.patch.upserts-keys-and-keeps-the-rest`,`legacyRows.patch.absent-store-writes-nothing`]},"legacyRows.deleteKeys":{input:TV.extend({keys:C(l().min(1))}),output:x({present:y(),removed:wV}),behaviours:[`legacyRows.deleteKeys.removes-the-named-keys`,`legacyRows.deleteKeys.absent-store-reports-not-present`]},"records.get":{input:EV,output:DV.nullable(),behaviours:[`records.get.returns-the-row-or-null`]},"records.getResolved":{input:EV,output:DV.nullable(),behaviours:[`records.getResolved.resolves-secret-fields`]},"records.put":{input:x({...OV,ifRev:n().int().optional()}),output:x({rev:n().int()}),behaviours:[`records.put.creates-and-replaces`,`records.put.if-rev-conflict-throws`]},"records.putMany":{input:x({records:C(x(OV))}),output:x({count:n().int().nonnegative()}),behaviours:[`records.putMany.writes-every-row`]},"records.patch":{input:EV.extend({partial:wV,ifRev:n().int().optional()}),output:x({rev:n().int()}),behaviours:[`records.patch.merges-and-null-removes`]},"records.delete":{input:EV,output:x({deleted:y()}),behaviours:[`records.delete.reports-whether-a-row-went`]},"records.query":{input:x({deviceId:n().int().optional(),atFrom:n().optional(),atTo:n().optional(),where:mV.optional(),limit:n().int().min(1).optional(),cursor:l().min(1).optional(),resolveSecrets:y().optional()}),output:x({records:C(DV),nextCursor:l().nullable()}),behaviours:[`records.query.pages-with-a-cursor`,`records.query.filters-on-a-declared-index`]},"records.deleteWhere":{input:x({deviceId:n().int().optional(),atBefore:n().optional(),where:mV.optional()}),output:x({count:n().int().nonnegative()}),behaviours:[`records.deleteWhere.deletes-the-matching-rows`]},"settings.read":{input:x({}),output:x({store:wV}),behaviours:[`settings.read.returns-the-addon-store`]},"settings.write":{input:x({patch:wV}),output:x({}),behaviours:[`settings.write.merges-and-keeps-other-keys`]},"settings.deleteKeys":{input:x({keys:C(l().min(1))}),output:x({removed:C(l())}),behaviours:[`settings.deleteKeys.removes-only-the-named-keys`]},"deviceSettings.listIds":{input:x({}),output:x({deviceIds:C(n().int())}),behaviours:[`deviceSettings.listIds.names-only-the-addons-own-devices`]},"deviceSettings.read":{input:x({deviceIds:C(n().int())}),output:x({blobs:m(l(),wV)}),behaviours:[`deviceSettings.read.returns-only-the-addons-own-blobs`]},"secrets.resolve":{input:x({refs:C(l())}),output:x({values:m(l(),l().nullable())}),behaviours:[`secrets.resolve.answers-null-for-a-missing-ref`]},"secrets.put":{input:x({ref:l().min(1),value:l()}),output:x({}),behaviours:[`secrets.put.stores-under-the-owner`]},"secrets.delete":{input:x({refs:C(l())}),output:x({deleted:n().int().nonnegative()}),behaviours:[`secrets.delete.ignores-unknown-refs`]},"integrations.list":{input:x({}),output:x({integrations:C(kV)}),behaviours:[`integrations.list.lists-every-integration`]},"integrations.get":{input:x({id:l().min(1)}),output:kV.nullable(),behaviours:[`integrations.get.null-for-an-unknown-id`]},"devices.list":{input:x({addonId:l().min(1),integrationId:l().min(1).optional()}),output:x({devices:C(YEe)}),behaviours:[`devices.list.scoped-to-the-addon`,`devices.list.filters-by-integration`]},"devices.get":{input:x({deviceId:n().int()}),output:x({id:n().int(),integrationId:l().nullable(),hasConfig:y()}).nullable(),behaviours:[`devices.get.null-for-an-unknown-id`,`devices.get.reports-link-and-config`]},"devices.aliases":{input:x({deviceIds:C(n().int())}),output:x({aliases:m(l(),l())}),behaviours:[`devices.aliases.answers-for-the-named-ids-only`]},"devices.setIntegrationId":{input:x({deviceId:n().int(),integrationId:l().min(1)}),output:x({}),behaviours:[`devices.setIntegrationId.links-the-device`]},"node.localNodeId":{input:x({}),output:x({nodeId:l()}),behaviours:[`node.localNodeId.names-this-node`]},"log.info":{input:jV,output:x({}),behaviours:[`log.info.writes-a-line`]},"log.warn":{input:jV,output:x({}),behaviours:[`log.warn.writes-a-line`]}},MV={name:`migrations`,scope:`system`,mode:`singleton`,internal:!0,methods:{listLedger:A(x({}),x({entries:C(Gf)}),{auth:`admin`}),listPending:A(x({owner:l().optional()}),x({pending:C(Kf)}),{auth:`admin`}),dryRun:A(x({id:l().min(1)}),qf,{auth:`admin`}),markFailed:A(x({id:l().min(1),error:l().min(1)}),Gf,{kind:`mutation`,auth:`admin`}),retry:A(x({id:l().min(1)}),x({entries:C(Gf)}),{kind:`mutation`,auth:`admin`}),restorePreMigration:A(x({database:yf,snapshotId:l().min(1)}),x({scheduled:y(),held:C(l()),restartRequired:y()}),{kind:`mutation`,auth:`admin`}),declareOwner:A(x({owner:l().min(1),metas:C(Nf),retired:C(l().min(1)).optional()}),x({bootId:l(),snapshot:S([`none`,`written`,`refused`]),steps:C(Jf),migrationApi:AV.optional()}),{kind:`mutation`,auth:`admin`}),startMigration:A(x({id:l().min(1)}),x({proceed:y(),state:h([p(`pending`),Wf]),reason:l().nullable()}),{kind:`mutation`,auth:`admin`}),finishMigration:A(x({id:l().min(1),result:Uf}),x({status:Wf,error:l().nullable(),rowsChanged:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),readLegacyIntegrationRows:A(x({integrationId:l().min(1)}),m(l(),w()),{auth:`admin`}),clearLegacyIntegrationRows:A(x({integrationId:l().min(1)}),x({rows:n().int().nonnegative(),secrets:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),patchLegacyIntegrationRows:A(x({integrationId:l().min(1),patch:m(l(),w())}),x({written:y()}),{kind:`mutation`,auth:`admin`}),deleteLegacyIntegrationRowKeys:A(x({integrationId:l().min(1),keys:C(l().min(1))}),x({present:y(),removed:m(l(),w())}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.INTERNAL}},NV=x({sourceUrl:l(),metadata:sfe,targets:C(ofe).min(1).readonly(),calibrationRef:l().optional(),sessionId:l().optional()}),PV={name:`model-convert`,scope:`system`,mode:`singleton`,internal:!0,methods:{convert:A(NV,lfe,{kind:`mutation`,auth:`admin`,timeoutMs:6e5})},vocabulary:{notOperatorFacing:M.ML}},FV=x({targetNodeId:l(),modelId:l(),format:S(Na),entry:rg}),IV=x({ok:y(),sha256:l(),bytes:n(),path:l()}),LV={name:`model-distributor`,scope:`system`,mode:`singleton`,internal:!0,methods:{distributeModel:A(FV,IV,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.ML}},RV=i(`kind`,[x({kind:p(`camera`)}),x({kind:p(`sensor`),deviceId:n().int().positive()})]),zV=Object.freeze({kind:`camera`});function ZEe(e){if(e===void 0)return{triggeredBy:zV,malformed:!1};let t=RV.safeParse(e);return t.success?{triggeredBy:t.data,malformed:!1}:{triggeredBy:zV,malformed:!0}}var QEe=`cameraSensors`,$Ee=8,BV=x({addonId:l().min(1),stableId:l().min(1)});function VV(e){return`${e.addonId}/${e.stableId}`}var HV=S([`in-addition`,`confirm`,`replace`]),UV=`in-addition`,WV=BV.extend({mode:HV.default(UV)}),GV=x({sensors:C(WV).min(1).max(8)}).superRefine((e,t)=>{let n=new Set;e.sensors.forEach((e,r)=>{let i=VV(e);n.has(i)&&t.addIssue({code:`custom`,path:[`sensors`,r],message:`duplicate camera sensor ${i}`}),n.add(i)})}),KV={addonId:l(),stableId:l(),mode:HV.default(UV)},qV=i(`state`,[x({...KV,state:p(`ready`),deviceId:n(),name:l(),caps:C(l()).readonly()}),x({...KV,state:p(`offline`),deviceId:n(),name:l(),reason:S([`offline`,`disabled`])}),x({...KV,state:p(`missing`),reason:l()}),x({...KV,state:p(`unsupported`),deviceId:n(),name:l(),reason:l()}),x({...KV,state:p(`unreadable`),reason:l()})]),JV=S([`onboard-not-listed`,`no-active-detection`]),YV=S([`always`,`when-confirmed`,`never`]),XV=S([`provider-not-split`]),ZV=x({detected:y(),atMs:n()}),QV=i(`state`,[x({state:p(`not-configured`),cameraLevel:ZV.optional()}),x({state:p(`unreadable`),reason:l(),cameraLevel:ZV.optional()}),x({state:p(`configured`),cameraLevel:ZV.optional(),sensors:C(qV).readonly(),cameraMotion:YV.optional(),notForwarded:JV.optional(),notEnforced:XV.optional()})]),eDe=Object.freeze({state:`unreadable`,reason:`camera sensor mappings not loaded`}),$V=x({bbox:sC,pixelCount:n(),intensity:n()}),eH=x({detected:y(),regionCount:n(),regions:C($V).readonly(),rawRegions:C($V).readonly(),frameWidth:n(),frameHeight:n(),analysisMs:n()}),tH={name:`motion-detection`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[E.Camera],exposesDeviceSettings:!0,methods:{analyze:A(x({deviceId:n(),frame:oC.optional(),frameHandle:xa.optional()}),eH,{role:`admin`,kind:`mutation`,notOperatorFacing:`the pipeline feeds it frames — an internal stage, never called by a person`}),removeCamera:A(x({deviceId:n()}),v(),{role:`admin`,kind:`mutation`,notOperatorFacing:`pipeline housekeeping when a camera leaves`}),reset:A(v(),v(),{role:`admin`,kind:`mutation`,notOperatorFacing:`pipeline housekeeping`})},events:{onMotion:{data:x({deviceId:n(),detected:y(),regionCount:n()}),notOperatorFacing:"the analyzer’s raw verdict; the operator signal is the `motion` cap’s `detected` state"}},vocabulary:{noun:F(`Motion analysis`,`Analisi del movimento`),order:3160}},nH=x({package:y(),confidence:n().min(0).max(1),reason:l().min(1)}),rH=x({x:n(),y:n()}),iH=x({kind:p(`rect`),x:n(),y:n(),width:n(),height:n()}),aH=x({kind:p(`polygon`),points:C(rH)}),oH=x({kind:p(`grid`),gridWidth:n().meta(N(`none`)),gridHeight:n().meta(N(`none`)),cells:C(y())}),sH=x({kind:p(`line`),points:C(rH)}),tDe=i(`kind`,[iH,aH,oH,sH]),cH=S([`rect`,`polygon`,`grid`,`line`]),lH=x({min:n(),max:n()}),uH=x({width:n(),height:n()}),dH=[`owner-not-ready`,`store-read-failed`,`three-way-read-unavailable`,`invalid-stored`,`not-cluster-scoped`],fH=[{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)`}]}],nDe=`cluster-step-models`;function pH(e){return`clusterModel:${e}`}function rDe(e){return fH.some(t=>t.stepId===e)}var mH=Object.freeze(Object.fromEntries(fH.map(e=>[e.stepId,e.defaultModelId])));function hH(e){return e==null||e===``?{kind:`absent`}:typeof e==`string`?{kind:`chosen`,modelId:e}:{kind:`invalid`,value:e}}function gH(e){let t=[];for(let n of fH){let r=hH(e[pH(n.stepId)]);r.kind===`invalid`&&t.push({stepId:n.stepId,value:r.value})}return t}function _H(e){let t={};for(let n of fH){let r=hH(e[pH(n.stepId)]);t[n.stepId]=r.kind===`chosen`?r.modelId:n.defaultModelId}return t}function iDe(e){return typeof e==`object`&&!!e&&`key`in e}function aDe(e){return e===null?mH:_H(yH(e,vH()))}function oDe(e){return e===null?[]:gH(yH(e,vH()))}function vH(){return new Set(fH.map(e=>pH(e.stepId)))}function yH(e,t){let n={};for(let r of e.sections)for(let e of r.fields)!iDe(e)||typeof e.key!=`string`||t.has(e.key)&&(n[e.key]=e.value);return n}function sDe(e,t){let n=fH.find(t=>t.stepId===e);if(n===void 0)return null;let r=t[e];return r!==void 0&&r!==``?r:n.defaultModelId}var cDe=24,bH=[{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 xH(e,t){return`clusterStepSetting:${e}:${t}`}function lDe(e){return bH.filter(t=>t.stepId===e)}var uDe=n().finite();function SH(e){let t={};for(let n of bH){let r=uDe.safeParse(e[xH(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 CH=SH({});function dDe(e){return e===null?CH:SH(yH(e,new Set(bH.map(e=>xH(e.stepId,e.key)))))}function fDe(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 wH=S([`new`,`entered`,`left`,`moving`,`idle`]),TH=S([`motion`,`object`,`audio`]),EH=i(`kind`,[iH,aH]),DH=S([`motion`,`audio`,`person`,`vehicle`,`animal`,`door`,`pir`,`smoke`,`water`,`button`,`package`,`generic`]),OH=S([`motion`,`audio`,`detection`,`sensor`,`control`,`custom`,`package`]),pDe=S([`macro`,`sub`]),kH=x({kind:l(),labelKey:l(),label:l(),color:l(),iconId:l(),icon:DH,category:OH,parentKind:l().nullable(),level:pDe,source:x({capName:l(),deviceId:n()})}),AH=x({deviceId:n(),kinds:C(kH).readonly()}),jH=x({id:l(),deviceId:n(),sourceDeviceId:n(),kind:l(),value:m(l(),w()).nullable(),timestamp:n()}),MH=x({x:n(),y:n(),timestamp:n(),bbox:sC,source:S([`frame`,`recovery`]).optional(),score:n().optional()}),mDe=x({timestamp:n(),position:MH,mediaId:n().int()}),NH=x({minX:n(),minY:n(),maxX:n(),maxY:n()}),PH=S([`full`,`slim`]),FH=x({label:l(),peakScore:n(),count:n(),firstAt:n(),lastAt:n()}),IH=S([`pipeline`,`onboard`,`sensor`,`audio`]),LH=S([`none`,`staging`,`trained`]),hDe=500,RH={markForTrain:y().optional(),debug:y().optional(),debugNote:l().max(500).optional(),favourited:y().optional()},zH={retrainStatus:LH.optional()},BH=x(RH),VH=x({trackId:l(),markForTrain:y(),debug:y(),debugNote:l(),favourited:y(),retrainStatus:LH}),gDe=h([p(1),p(2)]),HH=x({stepId:l(),modelId:l().optional(),decidedAt:n(),identityId:l().optional()}),UH={label:l().optional(),labelScore:n().optional(),labelMeta:HH.optional(),subLabel:l().optional(),subLabelScore:n().optional(),subLabelMeta:HH.optional()},WH=x({deviceId:n(),tracks:n().int(),files:n().int(),bytes:n().int()}),GH=x({generatedAt:n(),trackCount:n().int(),fileCount:n().int(),byteCount:n().int(),truncated:y(),devices:C(WH).readonly()}),KH=x({nodeId:l(),deviceKey:l().optional(),modelId:l().optional()}),qH=x({trackId:l(),deviceId:n(),className:l(),...UH,producingDeviceName:l().optional(),source:IH.optional(),firstSeen:n(),lastSeen:n(),positions:C(MH).readonly(),snapshots:C(mDe).readonly(),zonesVisited:C(l()).readonly(),zoneNames:C(l()).readonly().optional(),classes:C(l()).readonly().optional(),totalDistance:n(),state:wH,active:y(),importance:n().optional(),bestEventId:l().optional(),importanceReason:l().optional(),audioLabels:C(FH).readonly().optional(),envelope:NH.optional(),hasFace:y().optional(),hasEmbeddedFace:y().optional(),hasRider:y().optional(),previewMissReason:l().optional(),modelId:l().optional(),openedPlacement:KH.optional(),closedPlacement:KH.optional(),frameWidth:n().optional(),frameHeight:n().optional(),...RH,...zH}),JH={id:n().int(),deviceId:n(),timestamp:n()},YH=x({...JH,kind:p(`motion`),regionCount:n(),regions:C(x({bbox:sC,pixelCount:n(),intensity:n()})).readonly().optional(),frameWidth:n().optional(),frameHeight:n().optional(),mediaUrl:l().optional(),triggeredBy:RV.optional(),durationMs:n().nullable().optional(),edges:C(n()).readonly().optional()}),XH=S([`pipeline`,`onboard`]),ZH=S([`enter`,`exit`]),QH=x({direction:ZH,zoneId:l(),zoneName:l().optional()}),_De=x({zoneId:l(),zoneName:l().optional(),overlapPct:n()}),$H=x({...JH,kind:p(`object`),source:XH.optional(),frameId:l().optional(),idempotencyKey:l().optional(),trackId:l().optional(),className:l(),...UH,confidence:n().optional(),bbox:sC.optional(),zones:C(l()).readonly().optional(),zoneOverlaps:C(_De).readonly().optional(),spawnRefused:l().optional(),state:wH.optional(),zoneCrossing:QH.optional(),frameWidth:n().optional(),frameHeight:n().optional(),mediaId:n().int().optional(),keyFrameMediaId:n().int().optional(),mediaUrl:l().optional(),observedAt:n().optional(),packagePossible:y().optional(),packageLlmVerdict:nH.optional(),importance:n().optional()}),eU=x({...JH,kind:p(`audio`),rms:n(),dbfs:n(),classification:x({className:l(),originalClass:l().optional(),score:n()}).optional(),classifyOutcome:fC.optional(),mediaUrl:l().optional()}),tU=S([`crop`,`thumbnail`,`snapshot`,`firstFrame`,`lastFrame`,`fullFrame`,`fullFrameBoxed`,`faceCrop`,`plateCrop`,`keyFrame`,`keyFrameSmall`,`thumbnailSmall`,`confirmationCrop`,`debugCrop`,`sceneFrame`,`lastSceneFrame`]),nU=x({mediaId:n().int(),kind:tU,sizeBytes:n(),timestamp:n()}),rU=nU.extend({url:l(),base64:l()}),iU=rU.omit({base64:!0}),aU=S([`person`,`vehicle`,`animal`,`package`,`face`,`plate`]),oU=S([`subject`,`model_error`]),sU=S([`operator`,`assist`,`pipeline`,`llm`]),cU=x({x:n(),y:n(),w:n(),h:n()}),lU=x({source:sU,ref:l().min(1),bbox:cU,macroClass:aU,label:l().optional(),score:n().optional(),modelId:l().optional()}),uU=x({ref:l().min(1),snapshot:lU}),dU=S(Cp),fU=x({ref:l(),savedId:l().optional(),status:dU,approximate:y(),origin:lU.optional(),macroClass:aU.optional(),label:l().optional(),iou:n().optional()}),pU=x({boxes:C(fU).readonly(),summary:x({counts:m(dU,n().int()),total:n().int(),changed:n().int(),approximate:y()})}),mU=x({id:l(),trackId:l().optional(),deviceId:n(),mediaKey:l(),bbox:cU,macroClass:aU,label:l().optional(),subLabel:l().optional(),kind:oU,source:sU,assistModelId:l().optional(),assistScore:n().optional(),origin:lU.nullable().optional(),exportedInBatch:l().optional(),createdAt:n()}),hU=mU.omit({id:!0,trackId:!0,deviceId:!0,mediaKey:!0,createdAt:!0,exportedInBatch:!0}),gU=S([`correct`,`wrong`,`wrong-label`]),_U=x({verdict:gU,suggestedClass:l().optional(),suggestedMacroClass:aU.optional(),suggestedLabel:l().optional(),trackId:l(),at:n().optional()}),vU=x({trackId:l(),className:l(),label:l().optional(),bbox:cU.optional(),verdict:gU,suggestedClass:l().optional(),at:n().optional()}),yU=x({trackId:l(),deviceId:n(),className:l(),label:l().optional(),firstSeen:n(),lastSeen:n(),frameCount:n().int(),annotationCount:n().int(),verdict:_U.optional()}),bU=x({mediaId:n().int(),kind:tU,timestamp:n(),sizeBytes:n().int(),copied:y()}),xU=x({bbox:cU,macroClass:aU,label:l().optional(),subLabel:l().optional(),score:n().optional(),modelId:l().optional(),trackId:l(),basis:S([`subject-box`,`position`,`verdict`]),deltaMs:n()}),SU=S([`track`,`recording`]),CU=x({frameId:l(),deviceId:n(),origin:SU,trackId:l().optional(),sourceMediaId:n().int().optional(),epochMs:n().optional(),sourceKind:tU,sizeBytes:n().int(),width:n().int(),height:n().int(),copiedAt:n(),capturedAt:n().optional(),complete:y(),pipelineBoxes:C(xU).readonly().optional(),collectionIds:C(l()).readonly().optional(),verdict:_U.optional(),revision:n().int().optional(),dismissed:C(uU).readonly().optional(),review:pU.optional(),imageUrl:l().optional(),thumbnailUrl:l().optional()}),wU=S([`source-missing`,`unreadable-image`,`write-failed`]),TU=x({copied:C(CU).readonly(),refused:C(x({sourceMediaId:n().int(),reason:wU})).readonly()}),EU=x({candidates:C(bU).readonly(),copies:C(CU).readonly(),autoPickMediaId:n().int().optional()}),DU=S([`unannotated`,`annotated`,`complete`]),OU=x({workState:DU.optional(),deviceIds:C(n()).max(500).optional(),collectionId:l().optional(),classes:C(aU).optional(),page:n().int().positive().default(1),pageSize:n().int().positive().max(100).default(50)}),kU=CU.extend({workState:DU}),AU=x({frames:C(kU).readonly(),total:n().int().nonnegative(),page:n().int().positive(),pageSize:n().int().positive()}),jU=x({deviceId:n(),unannotated:n().int().nonnegative(),annotated:n().int().nonnegative(),complete:n().int().nonnegative(),pctOfCorpus:n().min(0).max(1).nullable()}),MU=x({total:n().int().nonnegative(),unannotated:n().int().nonnegative(),annotated:n().int().nonnegative(),complete:n().int().nonnegative(),cameras:C(jU).readonly()}),NU=x({deviceIds:C(n()).optional(),frameIds:C(l()).max(2e4).optional(),collectionIds:C(l()).max(200).optional(),collectionId:l().optional(),batchId:l().optional(),completeOnly:y().optional(),workState:DU.optional(),classes:C(aU).optional()}),PU=S([`frames`,`crops`]),FU=x({kind:p(`http`),method:S([`PUT`,`POST`]),url:l().url(),headers:m(l(),l()).optional()}),IU=x({batchId:l(),frames:n().int(),crops:n().int(),annotations:n().int(),missing:n().int(),bytes:n().int(),sha256:l(),status:n().int()}),LU=i(`kind`,[x({kind:p(`package`),zone:cU.optional()}),x({kind:p(`objects`),modelId:l(),minScore:n().optional()})]),RU=i(`kind`,[x({kind:p(`proposed`),modelId:l(),stepId:l(),minScore:n(),proposals:C(hU).readonly(),belowThreshold:n().int()}),x({kind:p(`refused`),reason:l(),detail:l().optional()})]),zU=x({id:l(),name:l(),createdAt:n(),frameCount:n().int()}),BU=i(`kind`,[x({kind:p(`created`),collection:zU}),x({kind:p(`refused`),reason:S([`empty-name`,`duplicate-name`])})]),VU=i(`kind`,[x({kind:p(`renamed`),collection:zU}),x({kind:p(`refused`),reason:S([`empty-name`,`duplicate-name`,`unknown-collection`])})]),HU=i(`kind`,[x({kind:p(`added`),collectionId:l(),frame:CU,reused:y()}),x({kind:p(`refused`),reason:S([`unknown-collection`,`still-unavailable`,`still-busy`,`unreadable-image`,`write-failed`]),detail:l().optional()})]),UU=x({id:l(),name:l(),model:l(),kind:l(),leavesHouse:y()}),WU=hU.extend({reason:l()}),GU=x({ref:l(),verdict:S([`confirmed`,`wrong-class`,`not-an-object`,`uncertain`]),suggestedClass:aU.optional(),reason:l()}),KU=i(`kind`,[x({kind:p(`proposed`),profileId:l(),model:l(),leftHouse:y(),proposals:C(WU).readonly(),reviews:C(GU).readonly(),rejected:n().int()}),x({kind:p(`refused`),reason:S([`unknown-frame`,`unreadable-frame`,`unknown-profile`,`profile-disabled`,`no-vision`,`cloud-not-confirmed`,`llm-error`,`malformed-answer`]),detail:l().optional()})]),qU=x({deviceIds:C(n()).readonly().optional(),collectionIds:C(l()).max(200).readonly().optional(),frameIds:C(l()).max(2e4).readonly().optional()}),JU=x({frames:n().int(),completeFrames:n().int(),completeness:n(),subjects:n().int(),modelErrors:n().int(),hardNegatives:n().int(),cells:C(x({macroClass:l(),deviceId:n(),lighting:S([`day`,`night`,`unknown`]),subjects:n().int(),frames:n().int()})).readonly(),cameras:C(x({deviceId:n(),frames:n().int(),completeFrames:n().int()})).readonly()}),vDe=x({id:l(),name:l(),createdAt:n(),selection:qU,layout:PU,completeOnly:y(),frameCount:n().int(),annotationHash:l(),manifestSchema:l(),stats:JU}),YU=x({collectionIds:C(l()).min(1),workState:S([`complete`,`annotated_or_complete`,`any_annotated`]).default(`complete`)}),XU=i(`kind`,[x({kind:p(`resolved`),frameIds:C(l()).max(2e4).readonly(),stats:JU,annotationHash:l(),layout:PU}),x({kind:p(`refused`),reason:S([`unknown-collection`,`no-frames`]),detail:l()})]),ZU=x({trackId:l(),retrainStatus:LH,changed:y(),reason:S([`unknown-track`,`no-frames-copied`,`not-staging`,`not-trained`,`unchanged`]).optional()}),QU=1e3,$U=5e3,eW=x({deviceId:n(),since:n().optional(),until:n().optional(),limit:n().int().min(1).max($U).default(QU),projection:S([`full`,`slim`]).optional()}),yDe=eW.extend({classFilter:l().optional()}),tW=x({deviceIds:C(n()),since:n().optional(),until:n().optional(),limit:n().int().min(1).max(1e3).default(200),cursor:l().optional(),projection:PH.optional(),includeStationary:y().optional(),classes:C(l()).optional(),excludeSources:C(IH).optional()}),nW=x({tracks:C(qH).readonly(),nextCursor:l().nullable()}),rW=50,iW=200,bDe=x({deviceId:n(),since:n(),until:n(),limit:n().int().min(1).max(iW).default(rW),minImportance:n().min(0).max(1).optional(),classFilter:l().optional()}),aW=x({id:l(),trackId:l(),timestamp:n(),className:l(),...UH,importance:n(),bestEventId:l(),windowMs:n().optional(),audioLabels:C(FH).readonly().optional(),...RH,...zH}),xDe=x({deviceIds:C(n()).min(1).max(200),since:n(),until:n(),limit:n().int().min(1).max(iW).default(rW),minImportance:n().min(0).max(1).optional(),classFilter:l().optional()}),SDe=x({deviceId:n(),events:C(aW).readonly()}),oW=x({bucketStart:n(),motion:n().int(),object:n().int(),audio:n().int(),audioDbfs:n().optional()}),CDe=200,sW=x({deviceId:n(),read:S([`read`,`unreadable`]),buckets:C(oW).readonly()}),wDe=x({trackId:l(),className:l(),confidence:n(),bbox:sC,zones:C(l()).readonly(),state:wH}),TDe=se({id:l(),kind:S([`first-level`,`detail`]),macroClass:l(),score:n(),bbox:x({x:n(),y:n(),width:n(),height:n()}),labels:C(se({label:l(),score:n()})).readonly(),parentId:l().optional()}),cW=$H.extend({score:n()}),EDe=x({text:l(),deviceId:n().optional(),since:n().optional(),until:n().optional(),classFilter:l().optional(),limit:n().default(50),minScore:n().min(0).max(1).optional(),strictness:Sde.optional(),modelId:l().min(1).optional()}),lW=x({tracks:n().int(),events:n().int(),media:n().int(),faces:n().int(),plates:n().int(),embeddings:n().int()}),DDe=x({mediaDropped:n().int(),tracks:n().int(),events:n().int()}),ODe=x({deviceId:n(),rows:n().int(),bytes:n().int()}),kDe=x({totalRows:n().int(),totalBytes:n().int(),devices:C(ODe).readonly()}),ADe=x({kind:tU,rows:n().int(),bytes:n().int()}),jDe=x({totalRows:n().int(),totalBytes:n().int(),kinds:C(ADe).readonly(),unaccountedRows:n().int(),unaccountedBytes:n().int()}),uW=x({motion:n().int(),object:n().int(),audio:n().int()}),MDe=x({deviceId:n().optional(),since:n().optional(),until:n().optional(),maxTracks:n().int().positive().optional(),executeOnNodeId:l().optional(),pacingMs:n().int().nonnegative().optional(),force:y().optional()}),NDe=x({deleted:n(),failedIndexes:C(l()).optional()}),dW=S([`stores-unavailable`,...dH,`method-unavailable`,`read-failed`,`reads-disagree`,`not-a-clip-model`,`force-requires-max-tracks`]),PDe=x({started:y(),alreadyRunning:y(),refusal:dW.optional(),modelId:l().optional(),index:l().optional()}),FDe=x({running:y(),scanned:n(),rebuilt:n(),missingKeyFrame:n(),missingEvent:n(),missingBbox:n(),boxSource:x({subjectBox:n(),positions:n(),event:n(),refused:n()}),alreadyInSpace:n(),force:y().nullable(),forcedInSpace:n(),notRunnable:n(),noCapableNode:n(),failed:n(),complete:y().nullable(),startedAtMs:n().nullable(),finishedAtMs:n().nullable(),error:l().nullable(),modelId:l().nullable(),index:l().nullable()}),IDe=x({started:y(),alreadyRunning:y()}),LDe=x({mode:S([`report`,`reclaim`]).default(`report`),scopes:C(S([`motion-still`,`track-filmstrip`])).min(1).optional(),deviceIds:C(n().int()).min(1).optional(),restart:y().optional(),pageSize:n().int().min(50).max(5e3).optional(),maxRowsPerDevice:n().int().min(1).max(5e5).optional(),maxReclaimPerDevice:n().int().min(1).max(5e5).optional(),maxBytesPerRun:n().int().min(1).optional(),budgetMinutes:n().int().min(1).max(720).optional(),throttleBytesPerSec:n().int().min(64*1024).optional(),graceMinutes:n().int().min(1).max(10080).optional()}),RDe=x({running:y(),mode:S([`report`,`reclaim`]).nullable(),totalExamined:n(),totalEligible:n(),totalReclaimed:n(),totalBytesReclaimed:n(),totalRefused:n(),devicesDone:n(),complete:y().nullable(),startedAtMs:n().nullable(),finishedAtMs:n().nullable(),error:l().nullable()}),fW=S([`motion`,`audio-dbfs`,`battery`,`occupancy`]),zDe=`|`;function BDe(e,t){let n=e??``;return t===void 0?n:`${n}|${t}`}function VDe(e){let t=e.indexOf(`|`);return t<0?{zoneId:e}:{zoneId:e.slice(0,t),className:e.slice(t+1)}}var pW=x({scope:l(),bucketStart:n().int(),samples:n().int().nonnegative(),sum:n(),min:n(),max:n()}),mW={name:`pipeline-analytics`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[E.Camera],exposesDeviceSettings:!0,methods:{getActiveTracks:A(x({deviceId:n()}),C(qH).readonly()),getTrack:A(x({deviceId:n(),trackId:l()}),qH.nullable()),listTracks:A(x({deviceId:n(),since:n().optional(),until:n().optional(),limit:n().optional(),zone:EH.optional(),projection:PH.optional(),includeStationary:y().optional(),classes:C(l()).optional(),excludeSources:C(IH).optional()}),C(qH).readonly()),listRecentTracks:A(tW,nW),clearTracks:A(x({deviceId:n()}),v(),{kind:`mutation`,auth:`admin`}),getMotionEvents:A(eW,C(YH).readonly()),getObjectEvents:A(yDe,C($H).readonly()),getAudioEvents:A(eW,C(eU).readonly()),listEventKinds:A(x({deviceId:n()}),C(kH).readonly()),listEventKindsBatch:A(x({deviceIds:C(n()).min(1).max(200)}),C(AH).readonly()),getSensorEvents:A(x({deviceId:n(),since:n().optional(),until:n().optional(),kinds:C(l()).optional(),limit:n().int().min(1).max($U).default(QU)}),C(jH).readonly()),getKeyEvents:A(bDe,C(aW).readonly()),getKeyEventsBatch:A(xDe,C(SDe).readonly()),readLongTermSeries:A(x({deviceId:n(),series:fW,scope:l().optional(),from:n(),to:n(),limit:n().int().positive().optional()}),C(pW).readonly()),getEventDensity:A(x({deviceId:n(),since:n(),until:n(),bucketMs:n().int().positive()}),C(oW).readonly()),getEventDensityBatch:A(x({deviceIds:C(n()).min(1).max(200),since:n(),until:n(),bucketMs:n().int().positive()}),C(sW).readonly()),pruneEventsBefore:A(x({deviceId:n(),cutoffMs:n()}),x({motion:n().int(),object:n().int(),audio:n().int()}),{kind:`mutation`,auth:`admin`}),pruneTracksBefore:A(x({deviceId:n(),cutoffMs:n()}),lW,{kind:`mutation`,auth:`admin`}),wipeAllAnalytics:A(x({deviceId:n()}),lW,{kind:`mutation`,auth:`admin`}),reconcileFromDisk:A(x({deviceId:n()}),DDe,{kind:`mutation`,auth:`admin`}),deleteTracks:A(x({deviceId:n(),trackIds:C(l()).min(1)}),x({deleted:n().int(),failed:C(l()).readonly(),sparedMediaIds:C(n().int()).readonly().optional()}),{kind:`mutation`,auth:`admin`}),setTrackFlags:A(x({deviceId:n(),trackId:l(),flags:BH}),VH,{kind:`mutation`,notOperatorFacing:`curating a recorded track in the review UI, not a live step`}),listArchivedDebugNotes:A(Pp,C(Np).readonly(),{kind:`query`}),setTrackRelation:A(Bp,Rp,{kind:`mutation`,notOperatorFacing:`curating recorded tracks in the review UI, not a live step`}),clearTrackRelation:A(Vp,Hp,{kind:`mutation`,notOperatorFacing:`curating recorded tracks in the review UI, not a live step`}),setTrackPurity:A(Up,Wp,{kind:`mutation`,notOperatorFacing:`curating a recorded track in the review UI, not a live step`}),listTrackRelations:A(Gp,Kp,{kind:`query`}),listBirthDecisions:A(Mp,C(jp).readonly(),{kind:`query`}),getEventStoreFootprint:A(x({}),kDe,{kind:`query`,auth:`admin`}),getEventMediaFootprintByKind:A(x({deviceId:n().int().optional()}),jDe,{kind:`query`,auth:`admin`}),pruneEvents:A(x({olderThanMs:n(),reason:em.optional()}),uW,{kind:`mutation`,auth:`admin`}),deleteDeviceEvents:A(x({deviceId:n()}),uW,{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:A(km,x({paused:p(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:A(km,x({resumed:p(!0)}),{kind:`mutation`,auth:`admin`}),refreshStorageLocationsForMigration:A(km,x({refreshed:p(!0)}),{kind:`mutation`,auth:`admin`}),startStorageMigrationMove:A(Rm,x({jobId:l()}),{kind:`mutation`,auth:`admin`}),getStorageMigrationMoveStatus:A(x({jobId:l()}),Em.nullable(),{auth:`admin`}),cancelStorageMigrationMove:A(x({jobId:l()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),relocateMedia:A(Mm,x({jobId:l()}),{kind:`mutation`,auth:`admin`}),countUnstampedEventMedia:A(x({}),Pm,{auth:`admin`}),getMediaLocationCensus:A(Fm,Lm,{kind:`query`,auth:`admin`}),countRelocatableMedia:A(uh,lh,{kind:`query`,auth:`admin`}),listRelocateMediaJobs:A(x({}),C(Em).readonly(),{kind:`query`,auth:`admin`}),cancelRelocateMedia:A(x({jobId:l()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),listOpsLog:A(nm,C(tm).readonly(),{kind:`query`,auth:`admin`}),reclaimDebugMedia:A(LDe,IDe,{kind:`mutation`,auth:`admin`}),getMediaReclaimStatus:A(x({}),RDe,{kind:`query`,auth:`admin`}),getTrainingExportSummary:A(x({deviceIds:C(n()).optional()}),GH,{kind:`query`,auth:`admin`}),getTrainingExportUrl:A(x({deviceIds:C(n()).optional()}),x({url:l()}),{kind:`query`,auth:`admin`}),listRetrainStaging:A(x({deviceIds:C(n()).optional(),limit:n().int().min(1).max(500).optional()}),C(yU).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),listRetrainCorpusPage:A(OU,AU,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),getRetrainCorpusKpi:A(x({}),MU,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),listRetrainFrames:A(x({trackId:l()}),EU,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),selectRetrainFrames:A(x({deviceId:n(),trackId:l(),mediaIds:C(n().int()).min(1)}),TU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),deselectRetrainFrame:A(x({deviceId:n(),trackId:l().optional(),frameId:l()}),x({removed:y(),removedAnnotations:n().int()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),getRetrainFrameImage:A(x({frameId:l()}),x({base64:l(),width:n().int(),height:n().int()}),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),proposeRetrainAnnotations:A(x({deviceId:n(),trackId:l().optional(),frameId:l(),subject:LU,nodeId:l().optional()}),RU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainAnnotations:A(x({trackId:l().optional(),frameIds:C(l()).max(2e3).optional()}),C(mU).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),saveRetrainAnnotations:A(x({deviceId:n(),trackId:l().optional(),frameId:l(),annotations:C(hU),expectedRevision:n().int().optional(),dismissed:C(uU).optional()}),C(mU).readonly(),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),backfillRetrainOrigins:A(x({deviceId:n(),trackId:l().optional(),frameId:l(),expectedRevision:n().int().optional(),origins:C(x({annotationId:l(),origin:lU})).min(1).max(500)}),x({updated:n().int(),skipped:n().int(),revision:n().int()}),{kind:`mutation`,auth:`admin`}),completeRetrainTrack:A(x({deviceId:n(),trackId:l()}),ZU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),restageRetrainTrack:A(x({deviceId:n(),trackId:l()}),ZU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),getRetrainExportUrl:A(NU.extend({layout:PU.optional()}),x({url:l()}),{kind:`query`,auth:`admin`}),setRetrainFrameComplete:A(x({deviceId:n(),trackId:l().optional(),frameId:l(),complete:y()}),CU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),writeRetrainArchive:A(x({filter:NU,layout:PU,target:FU}),IU,{kind:`mutation`,auth:`admin`,timeoutMs:60*6e4}),offerRetrainArchive:A(x({filter:NU,layout:PU}),x({ticket:Si,frames:n().int(),annotations:n().int()}),{kind:`mutation`,auth:`admin`,timeoutMs:12e4}),listRetrainAssistProfiles:A(x({}),C(UU).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),proposeRetrainAnnotationsWithLlm:A(x({deviceId:n(),trackId:l().optional(),frameId:l(),profileId:l(),classes:C(aU).min(1),boxes:C(x({ref:l(),bbox:cU,macroClass:aU,label:l().optional()})).max(50),allowCloud:y()}),KU,{kind:`mutation`,auth:`admin`,timeoutMs:18e4}),createRetrainCollection:A(x({name:l().max(120)}),BU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainCollections:A(x({}),C(zU).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),resolveRetrainTrainingCorpus:A(YU,XU,{kind:`query`,auth:`admin`,timeoutMs:6e4}),renameRetrainCollection:A(x({id:l(),name:l().max(120)}),VU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),deleteRetrainCollection:A(x({id:l()}),x({deleted:y(),removedFrames:n().int()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),addRetrainFrameFromRecording:A(x({collectionId:l(),deviceId:n(),epochMs:n(),verdictSubject:vU.optional()}),HU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`,timeoutMs:6e4}),addRetrainFramesToCollection:A(x({collectionId:l(),frameIds:C(l()).min(1).max(500)}),x({added:n().int(),alreadyMember:n().int(),unknownFrameIds:C(l()).readonly()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),removeRetrainFrameFromCollection:A(x({collectionId:l(),frameId:l()}),x({removed:y(),deletedFrame:y()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainCollectionFrames:A(x({collectionId:l()}),C(CU).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),getEventMedia:A(x({ownerType:Du,eventId:n().int(),kind:tU.optional(),deviceId:n()}),C(rU).readonly()),getTrackMedia:A(x({trackId:l(),kinds:C(tU).optional(),deviceId:n()}),C(rU).readonly()),listTrackMedia:A(x({trackId:l(),deviceId:n()}),C(iU).readonly()),listEventMedia:A(x({ownerType:Du,eventId:n().int(),deviceId:n()}),C(iU).readonly()),ownersWithMedia:A(x({deviceId:n(),ownerKind:ku,ownerIds:C(l()).max(5e3)}),C(l()).readonly()),searchObjectEvents:A(EDe,C(cW).readonly(),{caller:`required`}),wipeObjectEmbeddings:A(x({}),NDe,{kind:`mutation`,auth:`admin`}),rebuildObjectEmbeddings:A(MDe,PDe,{kind:`mutation`,auth:`admin`}),getObjectEmbeddingRebuildStatus:A(x({}),FDe)},events:{onFrameTracked:{data:x({deviceId:n(),timestamp:n(),frameWidth:n(),frameHeight:n(),detections:C(TDe).readonly()}),notOperatorFacing:`one tracker frame — stream rate, never an automation trigger`},onTrackStarted:{data:x({deviceId:n(),trackId:l(),className:l()}),trigger:{category:T.PipelineAnalyticsTrackStarted,label:F(`Subject appeared`,`Soggetto comparso`),phrase:F(`When {device} starts following a subject`,`Quando {device} inizia a seguire un soggetto`),icon:`scan-eye`}},onTrackEnded:{data:x({deviceId:n(),trackId:l(),className:l(),durationMs:n()}),trigger:{category:T.PipelineAnalyticsTrackEnded,label:F(`Subject left`,`Soggetto uscito`),phrase:F(`When a subject leaves the view of {device}`,`Quando un soggetto esce dall’inquadratura di {device}`),icon:`scan-eye`}},onDetectionEvent:{data:x({deviceId:n(),kind:TH,eventId:l(),timestamp:n()}),trigger:{category:T.PipelineAnalyticsDetectionEvent,label:F(`Detection event`,`Evento di rilevamento`),phrase:F(`When {device} records a detection event`,`Quando {device} registra un evento di rilevamento`),icon:`radar`}}},vocabulary:{noun:F(`Tracking`,`Tracciamento`),order:3200,extraEvents:[{category:T.PipelineAnalyticsPackageDelivered,label:F(`Package delivered`,`Pacco consegnato`),phrase:F(`When a package is left in front of {device}`,`Quando viene lasciato un pacco davanti a {device}`),icon:`package`},{category:T.PipelineAnalyticsPackagePickedUp,label:F(`Package picked up`,`Pacco ritirato`),phrase:F(`When a package is picked up in front of {device}`,`Quando viene ritirato un pacco davanti a {device}`),icon:`package-open`}]}},hW=x({x:n(),y:n(),w:n(),h:n()}),gW=x({stepId:l(),modelId:l(),detections:C(x({bbox:u([n(),n(),n(),n()]),score:n(),landmarks:C(x({x:n(),y:n()})).optional()})).min(1)}),_W=x({handle:xa,cropFrameSpace:x({x:n(),y:n(),w:n(),h:n()})});x({crop:x({left:n(),top:n(),width:n().positive(),height:n().positive()}).optional(),content:x({width:n().int().positive(),height:n().int().positive()}),fit:S([`stretch`,`contain`]),format:S([`rgb`,`gray`,`jpeg`])});var HDe=x({registryId:l().min(1),id:l().min(1),width:n().int().positive(),height:n().int().positive(),format:S([`rgb`,`gray`]),timestamp:n(),capturedAt:n().optional()}),vW=S([`onnx`,`coreml`,`openvino`,`tflite`,`pt`,`gguf`]),yW=S([`detector`,`cropper`,`classifier`,`refiner`,`audio-classifier`]),bW=x({runtime:p(`python`),backend:l(),format:vW,device:l().optional()}),xW=x({deviceKey:l().nullable(),runtime:l(),batchMode:l(),windowMs:n(),maxBatchSize:n(),concurrency:n(),numWorkers:n()}),UDe=x({engine:bW,devices:C(x({id:l(),label:l(),description:l().optional()})).readonly(),defaultDevice:l()}),SW=a(()=>x({addonId:l(),addonName:l(),slot:yW,inputClasses:C(l()).readonly(),outputClasses:C(l()).readonly(),enabled:y(),modelId:l(),children:C(SW).readonly(),group:l().optional(),settings:m(l(),w()).optional()})),WDe=x({id:l(),name:l(),formats:m(l(),$de),group:eg.optional(),legacy:y().optional(),provider:tg.optional(),defaultConfidence:n().optional(),suppliesSteps:C(ng).readonly().optional()}),GDe=ve(),KDe=x({id:l(),name:l(),slot:yW,inputClasses:C(l()).readonly(),outputClasses:C(l()).readonly(),childSlots:C(yW).readonly(),models:C(WDe).readonly(),defaultModelId:l(),defaultModelIdByFormat:m(l(),l()).optional(),enabledByDefault:y().optional(),defaultConfidence:n(),group:l().optional(),configSchema:C(GDe).readonly().optional()}),qDe=x({id:yW,label:l(),priority:n(),parentSlot:yW.nullable(),addons:C(KDe).readonly()}),JDe=x({availableEngines:C(UDe).readonly(),selectedEngine:bW,slots:C(qDe).readonly()}),YDe=x({runtimeId:S([`onnx`,`openvino`,`coreml`,`edgetpu`]).nullable(),device:l().nullable(),state:S([`idle`,`installing`,`verifying`,`ready`,`failed`]),progress:n().optional(),error:l().optional(),nextRetryAt:n().optional(),configIssues:C(l()).optional()}),CW=x({addonId:l(),chosen:l(),running:l(),format:l()}),wW=x({addonId:l(),kind:S([`unknown-addon`,`no-format-build`,`unknown-device`]),detail:l()}),TW=x({ok:y(),issues:C(wW).readonly(),substitutions:C(CW).readonly(),format:l()}),XDe=x({filename:l(),stepIds:C(l()).readonly().optional()}),ZDe=x({base64:l(),filename:l()}),QDe=x({filename:l(),sizeKb:n()}),$De=x({base64:l()}),eOe=x({id:l(),name:l(),description:l(),available:y(),rawLabels:C(l()).readonly().optional()}),tOe=x({activeBackend:l(),availableBackends:C(eOe).readonly(),sampleRate:n(),chunkDurationMs:n()}),nOe=x({filePath:l(),sizeMB:n(),durationMs:n()}),rOe=x({success:y(),error:l().optional(),frame:ve().optional()}),iOe=ve(),aOe=ve(),oOe=ve(),sOe=ve(),EW={name:`pipeline-executor`,scope:`system`,mode:`singleton`,methods:{getAvailableEngines:A(v(),C(bW)),getSelectedEngine:A(v(),bW),getEngineProvisioning:A(x({nodeId:l()}),YDe),getVideoPipelineSteps:A(v(),m(l(),x({modelId:l(),settings:m(l(),w()).readonly()}))),setVideoPipelineSteps:A(x({steps:m(l(),x({modelId:l(),settings:m(l(),w()).readonly()}))}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getInferenceDeviceHealth:A(x({nodeId:l()}),x({unhealthy:C(x({deviceKey:l(),state:S([`failed`,`backoff`]),since:n(),deaths:n(),lastError:l(),absentReason:S([`no-gpu-device`]).optional()})).readonly()})),rearmInferenceDevice:A(x({nodeId:l(),deviceKey:l()}),x({rearmed:y()}),{kind:`mutation`,auth:`admin`}),getSchema:A(v(),JDe),getOrchestratorConfigSchema:A(v(),iOe),validatePipeline:A(x({steps:C(Va),deviceKey:l().optional()}),TW),getCapabilities:A(v(),oOe),getAddonModels:A(x({addonId:l()}),sOe),downloadModel:A(x({addonId:l(),modelId:l(),format:vW}),nOe,{kind:`mutation`}),deleteModel:A(x({addonId:l(),modelId:l(),format:vW}),x({success:p(!0)}),{kind:`mutation`}),runPipeline:A(x({steps:C(Va).min(1),frame:oC.optional(),frameRef:HDe.optional(),frameHandle:xa.optional(),imageBase64:l().optional(),image:b(Uint8Array).optional(),referenceImage:l().optional(),deviceId:n().optional(),sessionId:l().optional(),plane:S([`full`,`frame`]).optional(),deviceKey:l().optional(),nativeCropRef:_W.optional(),replay:p(!0).optional(),suppliedRoot:gW.optional(),motionRegions:C(hW).optional()}),Ha,{kind:`mutation`}),runPipelineBatch:A(x({steps:C(Va).min(1),frames:C(oC).min(1).max(255),deviceId:n().optional(),sessionId:l().optional(),frameId:n().int().nonnegative().optional(),deviceKey:l().optional()}),x({results:C(Ha).readonly()}),{kind:`mutation`}),cacheFrameInPool:A(x({data:b(Uint8Array),width:n().int().positive(),height:n().int().positive(),format:S([`rgb`,`bgr`,`gray`])}),x({frameId:n(),width:n(),height:n()}),{kind:`mutation`}),inferCached:A(x({stepId:l(),frameId:n().int(),modelId:l().min(1)}),m(l(),w()),{kind:`mutation`}),uncacheFrame:A(x({frameId:n().int()}),v(),{kind:`mutation`}),getEffectiveTuning:A(x({deviceKey:l().optional()}),xW),listLoadedEngines:A(v(),C(x({engineKey:l(),engine:bW,modelsLoaded:C(l()).readonly(),inUseByCameras:C(n()).readonly(),kind:S([`runtime`,`device-pool`]),poolPid:n().nullable(),idleMs:n().nullable(),idleTtlMs:n().nullable()})).readonly()),spinEngine:A(x({engine:bW}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),killEngine:A(x({engine:bW,force:y().optional()}),x({success:y(),reason:l().optional()}),{kind:`mutation`,auth:`admin`}),listReferenceImages:A(v(),C(XDe).readonly()),getReferenceImage:A(x({filename:l()}),ZDe.nullable()),getReferenceAudioFiles:A(v(),C(QDe).readonly()),getReferenceAudio:A(x({filename:l()}),$De.nullable()),getAudioCapabilities:A(v(),tOe),runAudioTest:A(x({addonId:l(),modelId:l(),filename:l().optional(),settings:m(l(),w()).optional()}),rOe,{kind:`mutation`}),getDetectionConfigSchema:A(v(),aOe)},vocabulary:{notOperatorFacing:M.PIPELINE}},cOe=x({activeCameras:n(),throttledCameras:n(),avgInferenceTimeMs:n(),queueDepth:n()}),DW=x({detectionMode:S([`disabled`,`always-on`,`on-motion`]),configuredFps:n(),actualFps:n(),queueDepth:n(),avgInferenceTimeMs:n(),droppedFrames:n(),nativeCropMisses:n().optional(),phase:S([`idle`,`watching`,`active`])}),OW=DW.extend({deviceId:n()}),kW=S([`polygon`,`tripwire`]),AW=x({x:n(),y:n()}),jW=x({id:l(),name:l(),kind:kW.default(`polygon`),polygon:C(AW).readonly(),color:l().default(`#3b82f6`)}),MW={name:`zones`,scope:`device`,mode:`singleton`,deviceTypes:[E.Camera],methods:{listZones:A(x({deviceId:n()}),C(jW).readonly()),addZone:A(x({deviceId:n(),zone:jW}),v(),{kind:`mutation`,auth:`admin`}),removeZone:A(x({deviceId:n(),zoneId:l()}),v(),{kind:`mutation`,auth:`admin`}),updateZone:A(x({deviceId:n(),zone:jW}),v(),{kind:`mutation`,auth:`admin`})},runtimeState:x({zones:C(jW).readonly()}),durability:`restored`,history:`none`,vocabulary:{noun:F(`Zones`,`Zone`),order:3370}},NW={fpsPerStream:10,budgetMinutes:45,minBudgetMinutes:10,maxBudgetMinutes:120,staleAfterDays:30,settleSec:5,measureSec:20,drainTimeoutSec:120,maxModelsPerDevice:6},PW=S([`device`,`pipeline`]),FW=x({deviceKey:l().min(1),modelIds:C(l().min(1)).min(1).max(NW.maxModelsPerDevice)}),IW=x({nodeId:l().min(1),devices:C(FW).min(1),phases:C(PW).min(1).default([`device`,`pipeline`]),steps:C(l().min(1)).default([]),fpsPerStream:n().int().min(1).max(30).default(NW.fpsPerStream),budgetMinutes:n().int().min(NW.minBudgetMinutes).max(NW.maxBudgetMinutes).default(NW.budgetMinutes),keepDownloadedModels:y().default(!1),acceptInsufficientHeadroom:y().default(!1)}),LW=S([`benchmark-active`,`node-offline`,`unknown-device`,`no-phase`,`insufficient-headroom`]),RW=x({kind:LW,detail:l(),overridable:y()}),zW=x({deviceId:n(),placedOnNode:y(),pinnedToNode:y()}),BW=x({deviceId:n(),reason:p(`only-frame-source`)}),VW=x({nodeId:l(),online:y(),moving:C(zW).readonly(),staying:C(BW).readonly(),estimatedDurationMs:n(),budgetMs:n(),phases:C(PW).readonly(),steps:C(l()).readonly(),devices:C(FW).readonly(),headroom:x({sessionsNow:n(),otherNodesCapacitySessions:n().nullable()}),refusals:C(RW).readonly(),canStart:y()}),HW=x({phase:S([`preparing`,`device`,`pipeline`,`cleanup`]),deviceKey:l().nullable(),modelId:l().nullable(),load:n().nullable(),cellsDone:n(),cellsTotal:n(),message:l()}),UW=S([`p95`,`drops`,`errors`,`stall`,`cpu`,`ram`,`none`]),WW=x({load:n(),pass:y(),p95Ms:n(),dropRatio:n(),fps:n(),cpuPct:n().nullable(),ramFreePct:n().nullable(),failReasons:C(l()).readonly()}),GW=x({phase:p(`device`),deviceKey:l(),modelId:l(),p50Ms:n(),p95Ms:n(),p99Ms:n(),fps:n(),kMax:n(),limitedBy:UW,warmupMs:n(),ramp:C(WW).readonly()}),KW=x({phase:p(`pipeline`),deviceKey:l(),modelId:l(),steps:C(l()).readonly(),maxSessions:n(),limitedBy:UW,stepsFired:C(l()).readonly(),warmupMs:n(),ramp:C(WW).readonly()}),qW=i(`phase`,[GW,KW]),JW=x({pipelineVersion:l().nullable(),cpuModel:l().nullable(),ramGb:n().nullable(),os:l().nullable(),pools:m(l(),x({runtime:l(),numWorkers:n(),concurrency:n(),batchMode:l()})).default({})}),YW=x({id:l(),revision:l().nullable(),frames:n(),width:n(),height:n()}),XW=x({runId:l().min(1),devices:C(FW).min(1),phases:C(PW).min(1),steps:C(l()).default([]),fpsPerStream:n().int().min(1).max(30),deadlineAtMs:n(),settleSec:n().min(0).max(60).default(NW.settleSec),measureSec:n().min(2).max(300).default(NW.measureSec),keepDownloadedModels:y().default(!1)}),ZW=S([`running`,`done`,`failed`,`aborted`]),QW=x({runId:l(),nodeId:l(),state:ZW,progress:HW.nullable(),cells:C(qW).readonly(),fingerprint:JW.nullable(),clip:YW.nullable(),activeCameraIds:C(n()).readonly(),deletedModels:C(l()).readonly(),error:l().nullable(),startedAtMs:n(),finishedAtMs:n().nullable()}),$W=S([`draining`,`measuring`,`restoring`,`done`,`failed`,`aborted`]),eG=S([`completed`,`operator-abort`,`deadline`,`node-lost`,`runner-lost`,`hub-restart`,`drain-timeout`,`failed`]),tG=x({runId:l(),nodeId:l(),state:$W,plan:IW,startedAtMs:n(),deadlineAtMs:n(),finishedAtMs:n().nullable(),endReason:eG.nullable(),error:l().nullable(),moved:C(n()).readonly(),staying:C(n()).readonly(),contaminated:y(),progress:HW.nullable(),resultIds:C(l()).readonly()}),nG=x({modeNodeId:l().nullable(),run:tG.nullable()}),rG=x({id:l(),runId:l(),nodeId:l(),cell:qW,fpsPerStream:n(),fingerprint:JW.nullable(),clip:YW.nullable(),contaminated:y(),stayingCameras:C(n()).readonly(),partialRun:y(),measuredAtMs:n()}),iG=x({nodeId:l().optional(),deviceKey:l().optional()}),aG=rG.extend({standing:S([`fresh`,`stale`,`superseded`]),staleWhy:S([`age`,`runtime`,`pool-tuning`]).nullable()}),lOe=x({runId:l(),nodeId:l(),startedAtMs:n(),deadlineAtMs:n(),plan:IW,moved:C(n()).readonly(),staying:C(n()).readonly()}),oG=x({nodeId:l(),reachable:y(),devices:C(x({deviceKey:l(),enabled:y(),available:y(),suggested:C(l()).readonly(),all:C(l()).readonly(),currentModelId:l().nullable()})).readonly(),steps:C(x({id:l(),name:l(),slot:l()})).readonly()}),sG=x({x:n(),y:n(),w:n(),h:n()}),cG=x({bytes:b(Uint8Array).optional(),jpeg:l().optional(),jpegBytes:b(Uint8Array).optional(),width:n().int().positive(),height:n().int().positive(),tier:S([`native`,`ram-fullframe`]).optional()}),lG=S([`keyFrame`,`thumbnail`]),uG=S([`handle-gone`,`encode-failed`]),dG=i(`parked`,[x({parked:p(!0),nodeId:l(),width:n().int().positive(),height:n().int().positive(),bytes:n().int().nonnegative(),replaced:y()}),x({parked:p(!1),nodeId:l(),reason:uG,handleAgeMs:n().nullable(),detail:l().optional()})]),fG=x({jpeg:l().optional(),jpegBytes:b(Uint8Array).optional(),width:n().int().positive(),height:n().int().positive(),timestamp:n(),parkedAt:n()}),uOe=x({bbox:sG,className:l()}),pG=x({stepId:l(),className:l(),score:n(),bbox:sG.optional(),embedding:l().optional(),embeddingMagnitude:n().optional(),embeddingModelId:l().optional(),label:l().optional(),labelTier:h([p(1),p(2)]).optional(),labelModelId:l().optional(),alignedCropJpeg:l().optional(),nativeFaceShortSidePx:n().optional(),landmarks:C(x({x:n(),y:n()})).optional()}),dOe=S([`unknown-step`,`model-not-servable`,`unreadable-frame`,`execution-failed`,`no-eligible-device`]),fOe=i(`kind`,[x({kind:p(`ran`),nodeId:l(),modelId:l(),details:C(pG)}),x({kind:p(`refused`),nodeId:l(),reason:dOe,detail:l()})]),mG={min:0,max:6e4,default:3e4,step:500},hG={min:0,max:6e5,default:12e4,step:5e3},gG={min:5e3,max:6e5,default:9e4,step:5e3},_G={min:1,max:30,default:4,step:1},vG={min:1,max:30,default:10,step:1},yG={min:0,max:300,default:300,step:5},bG={min:1,max:10,default:4,step:1},xG={min:0,max:30,default:12,step:1},SG=S([`onboard`,`analyzer`,`device-activity`]),CG=x({source:SG,triggeredBy:RV,sensorName:l().optional()}),wG=C(SG),TG={analyzer:`Frame-diff Analyzer (motion addon)`,onboard:`Camera sensors`,"device-activity":`Device activity (the device says it is working)`};function pOe(e){let t=SG.safeParse(e);return t.success?TG[t.data]:e}var mOe=[`analyzer`,`onboard`,`device-activity`],EG=f(e=>Array.isArray(e)&&e.length>1?e.slice(0,1):e,C(XH).max(1)),DG=x({deviceId:n(),detected:y(),source:SG.default(`analyzer`),regions:C($V).readonly().optional()}),OG=i(`kind`,[x({kind:p(`local-broker`)}),x({kind:p(`remote-restream`),ownerNodeId:l(),ownerReachableHost:l().optional(),hubHostnameOverride:l().optional()})]).describe(`Per-camera frame-source mode for the runner (P2c)`),kG=x({modelId:l().optional(),settings:m(l(),w()).optional()}),AG=x({deviceKey:l(),weight:n().positive().default(1),maxSessions:n().int().positive().nullable().default(null),steps:m(l(),kG).optional(),disabledSteps:C(l()).readonly().optional()}),jG=x({deviceId:n(),detectionMode:S([`disabled`,`always-on`,`on-motion`]).default(`on-motion`),audioMode:S([`disabled`,`always-on`,`on-motion`]).default(`always-on`),motionCooldownMs:n().min(mG.min).default(mG.default),maxSessionHoldMs:n().min(hG.min).max(hG.max).optional(),audioMotionWindowMs:n().min(gG.min).max(gG.max).optional(),motionFps:n().min(_G.min).max(_G.max).default(_G.default),detectionFps:n().min(vG.min).max(vG.max).default(vG.default),motionStreamId:l(),detectionStreamId:l(),audioStreamPick:ha.optional(),motionSources:wG.default([`analyzer`]),sessionTrigger:CG.optional(),detectionSources:EG.default([`pipeline`]),pipelineEnabled:y().default(!0),steps:C(Va).readonly().optional(),audio:x({modelId:l().optional(),enabled:y()}).nullable().optional(),zones:C(jW).readonly().default([]),onboardMotionDrivesAnalyzer:y().default(!0),preRollInferenceEnabled:y().default(!0),preRollInferenceFrames:n().min(xG.min).max(xG.max).default(xG.default),occupancyRecheckEnabled:y().default(!0),occupancyRecheckSec:n().min(yG.min).max(yG.max).default(yG.default),occupancyRecheckFrames:n().min(bG.min).max(bG.max).default(bG.default),frameSource:OG.default({kind:`local-broker`}),deviceKey:l().optional(),inferenceDevices:C(AG).readonly().optional()}),hOe=[{key:`motionSources`,type:`multiselect`,label:`Motion Sources`,default:[`analyzer`],options:mOe.map(e=>e===`onboard`?{value:e,label:TG[e],description:`The camera's own motion, plus any sensor attached to it`}:{value:e,label:TG[e]})},{key:`motionFps`,type:`slider`,label:`Motion FPS (analyzer)`,min:_G.min,max:_G.max,step:_G.step,default:_G.default,showValue:!0,unit:`fps`,nullable:!0,nullLabel:`Default`,showWhen:{field:`motionSources`,includes:`analyzer`}},{key:`detectionFps`,type:`slider`,label:`Detection FPS`,min:vG.min,max:vG.max,step:vG.step,default:vG.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:mG.min,max:mG.max,step:mG.step,default:mG.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:hG.min,max:hG.max,step:hG.step,default:hG.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:gG.min,max:gG.max,step:gG.step,default:gG.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:xG.min,max:xG.max,step:xG.step,default:xG.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:yG.min,max:yG.max,step:yG.step,default:yG.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:bG.min,max:bG.max,step:bG.step,default:bG.default,showValue:!0,showWhen:{field:`occupancyRecheckEnabled`,equals:!0}}],MG=x({nodeId:l(),attachedCameras:n(),activeCameras:n(),avgInferenceFps:n(),avgInferenceTimeMs:n(),queueDepthTotal:n(),devices:C(x({deviceKey:l(),backend:l(),attachedCameras:n()})).default([]),hardware:x({hasGpu:y(),inferenceBackend:l().optional(),cpuCores:n().optional()}),motionSliceWriter:p(`orchestrator`).optional()}),NG=x({framesDecoded:n(),framesAdmitted:n(),framesDroppedPixelFree:n(),viewsMaterialized:n(),viewsSkipped:n(),workerToRunnerBytes:n(),runnerToPoolRawBytes:n(),runnerToPoolJpegBytes:n(),onDemandFullFrameRequests:n(),onDemandCropRequests:n(),nativeHits:n(),nativeMisses:n(),tileHits:n(),tileMisses:n(),fallbackHits:n(),fallbackMisses:n(),retainedWritesAvoided:n(),residentRefs:n(),residentBytes:n(),releases:n(),evictions:n(),staleMisses:n()}),PG=x({node:NG,cameras:C(NG.extend({deviceId:n()}))}),FG=x({nodeId:l(),activeCameras:n(),throttledCameras:n(),avgInferenceTimeMs:n(),queueDepth:n(),frameLazy:PG.optional()}),IG=S([`not-attached`,`battery-asleep`,`not-watching`,`already-bursting`]),LG={name:`pipeline-runner`,scope:`system`,mode:`singleton`,methods:{attachCamera:A(jG,x({success:p(!0)}),{kind:`mutation`}),detachCamera:A(x({deviceId:n()}),x({success:p(!0)}),{kind:`mutation`}),reportMotion:A(DG,x({success:p(!0)}),{kind:`mutation`}),getLocalLoad:A(v(),MG),getLocalMetrics:A(v(),FG),getCameraMetrics:A(x({deviceId:n()}),DW.nullable()),getAllCameraMetrics:A(v(),C(OW).readonly()),getLocalCameras:A(v(),C(n()).readonly()),requestOccupancyBurst:A(x({deviceId:n(),frames:n().int().positive().optional(),reason:l()}),x({started:y(),refusedBecause:IG.optional()}),{auth:`admin`,kind:`mutation`}),getNativeCrop:A(x({handle:xa,bbox:sG,maxWidth:n().int().positive().optional(),acceptJpegBytes:y().optional(),encodeJpeg:y().optional()}),cG.nullable()),runDetailSubtree:A(x({deviceId:n(),frameHandle:xa.optional(),frameJpeg:l().optional(),cropJpeg:l().optional(),parent:uOe,steps:C(l()).optional(),supplied:x({stepId:l(),modelId:l(),boxes:C(x({bbox:sG,score:n()})).min(1)}).optional()}),x({details:C(pG)}).nullable(),{kind:`mutation`}),runStatelessStep:A(x({stepId:l(),modelId:l(),frameJpeg:l(),bbox:sG,className:l(),sourceDeviceId:n()}),fOe,{kind:`mutation`}),parkTrackFrame:A(x({deviceId:n(),trackId:l(),kind:lG,handle:xa,bbox:sG,maxWidth:n().int().positive().optional(),timestamp:n()}),dG,{kind:`mutation`}),getParkedTrackFrame:A(x({deviceId:n(),trackId:l(),kind:lG,acceptJpegBytes:y().optional()}),fG.nullable()),releaseParkedTrackFrames:A(x({deviceId:n(),trackId:l()}),x({released:n().int().nonnegative()}),{kind:`mutation`}),startNodeBench:A(XW,x({accepted:p(!0),runId:l()}),{kind:`mutation`,auth:`admin`}),getNodeBenchStatus:A(x({runId:l()}),QW.nullable(),{auth:`admin`}),abortNodeBench:A(x({runId:l()}),x({aborted:y()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.PIPELINE}},RG=3e4,gOe={version:1,targets:[{id:`detected`,cardinality:`event`,shape:`span`,vocabulary:{cap:`motion`,eventName:`onMotionChanged`},deviceTypes:[E.Camera],apply:`add`,applyAuthority:{kind:`camera-sensors`,timeoutField:`motionCooldownMs`},eventName:`onMotionChanged`,start:`rising-edge`,end:`falling-edge-or-timeout`,timeoutMs:RG,combine:`any`,sourceModes:[`in-addition`,`confirm`,`replace`],sources:[{kind:`binary`},{kind:`switch`}],sourceReport:{status:`assignment-status`},advancedExpression:!1}]},_Oe=15e3,zG=x({detected:y(),lastDetectedAt:n().nullable(),autoClearAfterMs:n().nullable().meta(N(`duration-ms`))}),BG=x({deviceId:n(),detected:y(),timestamp:n(),source:SG,regions:C($V).readonly().optional(),triggeredBy:RV.optional()}),VG={name:`motion`,scope:`device`,mode:`singleton`,deviceNative:!0,deviceTypes:[E.Camera,E.Sensor],methods:{isDetected:A(x({deviceId:n()}),y())},composedMethods:{isDetected:{kind:`slice`,field:`detected`}},events:{onMotionChanged:{data:BG,notOperatorFacing:"the `detected` state trigger phrases both edges, from the mirror that survives a dropped event (D49)"}},status:{schema:zG,kind:`push`},runtimeState:zG,durability:`session`,history:{fields:{detected:{kind:`boolean`,excludeDeviceTypes:[E.Camera]}}},customize:gOe,vocabulary:{noun:F(`Motion`,`Movimento`),order:5130,state:[{kind:`boolean`,field:`detected`,label:F(`Motion`,`Movimento`),whenTrue:F(`When {device} detects motion`,`Quando {device} rileva movimento`),whenFalse:F(`When motion clears on {device}`,`Quando il movimento su {device} cessa`),icon:`activity`}]}},HG=x({enabled:y(),lastChangedAt:n()}),UG=HG.extend({lastFetchedAt:n()}),WG={name:`motion-trigger`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Light,E.Siren,E.Switch],methods:{setMotionTrigger:A(x({deviceId:n().int().nonnegative(),enabled:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`motionTrigger.on`,label:F(`Motion trigger on`,`Attivazione al movimento attiva`),phrase:F(`Let motion trigger {device}`,`Fai attivare {device} dal movimento`),icon:`activity`,effect:{field:`enabled`,value:!0},args:{enabled:!0}},{id:`motionTrigger.off`,label:F(`Motion trigger off`,`Attivazione al movimento spenta`),phrase:F(`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:n(),enabled:y(),lastChangedAt:n()}),notOperatorFacing:"the `enabled` state trigger phrases both edges of this change"}},status:{schema:HG,kind:`command-driven`},runtimeState:UG,durability:`session`,history:`none`,vocabulary:{noun:F(`Motion trigger`,`Attivazione al movimento`),order:1160,state:[{kind:`boolean`,field:`enabled`,label:F(`Motion trigger`,`Attivazione al movimento`),whenTrue:F(`When motion triggering is turned on for {device}`,`Quando si attiva l’attivazione al movimento di {device}`),whenFalse:F(`When motion triggering is turned off for {device}`,`Quando si disattiva l’attivazione al movimento di {device}`),icon:`activity`}]}},GG=x({id:n(),enabled:y(),shape:oH}),KG=x({enabled:y(),sensitivity:n().meta(N(`none`)),regions:C(GG),lastFetchedAt:n()}),qG=x({maxRegions:n(),supportedShapes:C(cH),grid:uH,sensitivity:x({min:n(),max:n(),step:n()})}),JG=x({enabled:y().optional(),sensitivity:n().optional(),regions:C(GG).optional()}),YG={name:`motion-zones`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/motion-zones-grid`,tab:`motion`,label:`Motion Zones`}},methods:{getOptions:A(x({deviceId:n()}),qG),setZone:A(x({deviceId:n(),patch:JG}),v(),{kind:`mutation`,auth:`admin`})},status:{schema:KG,kind:`poll`},runtimeState:KG,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Motion zones`,`Zone di movimento`),order:3170}},vOe=S([`external`,`embedded`]),yOe=S([`connected`,`disconnected`,`auth-failed`,`unreachable`,`tls-error`]),XG=x({id:l(),name:l(),url:l(),kind:vOe,status:yOe,latencyMs:n().nullable(),error:l().optional(),connectedClients:n().int().nonnegative().optional(),lastCheckedAt:n().optional()}),ZG=x({url:l(),username:l().optional(),password:l().optional(),clientIdPrefix:l().optional()}),QG=x({name:l().min(1),url:l().regex(/^(mqtt|mqtts|ws|wss):\/\//,`URL must start with mqtt(s):// or ws(s)://`),username:l().optional(),password:l().optional(),clientIdPrefix:l().optional()}),bOe=x({id:l()}),$G=x({id:l()}),eK=x({port:n().int().min(1).max(65535).default(1883),allowAnonymous:y().default(!1),username:l().optional(),password:l().optional()}),xOe=x({id:l(),url:l()}),tK=x({brokerCount:n(),embeddedRunning:y()}),nK={name:`mqtt-broker`,scope:`system`,mode:`collection`,providerKind:`broker`,status:{schema:tK,kind:`poll`},methods:{listBrokers:A(v(),C(XG)),getBrokerConfig:A($G,ZG,{auth:`admin`}),addBroker:A(QG,bOe,{kind:`mutation`,auth:`admin`}),removeBroker:A($G,v(),{kind:`mutation`,auth:`admin`}),startEmbeddedBroker:A(eK,xOe,{kind:`mutation`,auth:`admin`}),stopEmbeddedBroker:A($G,v(),{kind:`mutation`,auth:`admin`}),getStatus:A(v(),tK)},vocabulary:{notOperatorFacing:M.NETWORK}},rK=S([`person`,`vehicle`,`animal`,`face`,`package`,`other`]),iK=x({class:rK,timestamp:n(),confidence:n().min(0).max(1).optional()}),aK=x({lastByClass:d(rK,iK.nullable()),supportedClasses:C(rK).readonly(),enabled:y()}),oK=S([`boxed`,`while-streaming`,`flag-only`]),sK=x({supportedClasses:C(rK).readonly(),geometry:oK}),cK=x({enabled:y().optional()}),lK=aK.extend({lastFetchedAt:n()}),uK={name:`native-object-detection`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],methods:{getOptions:A(x({deviceId:n()}),sK),setSettings:A(x({deviceId:n(),settings:cK}),v(),{kind:`mutation`,auth:`admin`}),setEnabled:A(x({deviceId:n(),enabled:y()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`nativeDetection.on`,label:F(`On-camera detection on`,`Rilevamento a bordo attivo`),phrase:F(`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:F(`On-camera detection off`,`Rilevamento a bordo spento`),phrase:F(`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:n(),detection:iK}),trigger:{category:T.DetectionCameraNative,label:F(`Camera spotted something`,`La telecamera ha rilevato qualcosa`),phrase:F(`When {device} spots something with its own detector`,`Quando {device} rileva qualcosa con il proprio rilevatore`),icon:`scan-eye`}}},status:{schema:aK,kind:`push`},runtimeState:lK,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`On-camera detection`,`Rilevamento a bordo`),order:3180,state:[{kind:`boolean`,field:`enabled`,label:F(`On-camera detection`,`Rilevamento a bordo`),whenTrue:F(`When the on-camera detection of {device} is turned on`,`Quando si attiva il rilevamento a bordo di {device}`),whenFalse:F(`When the on-camera detection of {device} is turned off`,`Quando si disattiva il rilevamento a bordo di {device}`),icon:`scan-eye`}]}},dK=x({pan:n().min(-1).max(1).optional(),tilt:n().min(-1).max(1).optional(),speed:n().min(0).max(1).optional()}),fK=S([`goHome`,`locate`,`spotClean`,`findPet`,`personFollow`,`stop`,`startClean`,`pauseClean`,`dockWash`,`autoEmpty`,`flashOn`,`flashOff`]),pK=S([`action`,`sound`]),mK=x({id:l(),kind:pK,label:l(),icon:l(),soundId:n().int().optional(),enabled:y()}),SOe=[{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}],hK=x({x:n(),y:n()}),gK=x({move:y(),stop:y(),goToPoint:y(),runAction:y(),playSound:y(),light:y(),lightMode:y()}),_K=S([`auto`,`manual`]),COe=40,wOe=100,vK=S([`idle`,`cleaning`,`spot`,`following`,`goto`,`returning`,`paused`,`unknown`]),yK=x({mode:vK,following:y(),flash:y(),lightMode:_K,lightLevel:n().min(40).max(100).meta(N(`none`)),lastChangedAt:n()}),bK=yK.extend({lastFetchedAt:n()}),xK={name:`navigation`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/navigation-panel`,tab:`navigation`,topTab:!0,label:`Navigation`,order:0}},methods:{move:A(dK.extend({deviceId:n()}),v(),{kind:`mutation`,notOperatorFacing:`joystick control from the live view — continuous, not a discrete step`}),stop:A(x({deviceId:n()}),v(),{kind:`mutation`,actions:[{id:`navigation.stop`,label:F(`Stop`,`Ferma`),phrase:F(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),goToPoint:A(hK.extend({deviceId:n()}),v(),{kind:`mutation`,notOperatorFacing:`tap-to-go on the live map — the point only means something on that picture`}),listActions:A(x({deviceId:n()}),C(mK)),runAction:A(x({deviceId:n(),actionId:fK}),v(),{kind:`mutation`,actions:[{id:`navigation.runAction`,label:F(`Run a routine`,`Esegui una routine`),phrase:F(`Have {device} {actionId}`,`Fai eseguire a {device}: {actionId}`),icon:`bot`,openArgs:[{key:`actionId`,label:F(`Routine`,`Routine`),offer:{kind:`enum`,values:[{value:`goHome`,label:F(`go home`,`torna alla base`)},{value:`locate`,label:F(`beep so you can find it`,`suona per farsi trovare`)},{value:`spotClean`,label:F(`clean this spot`,`pulisci questo punto`)},{value:`findPet`,label:F(`find the pet`,`cerca l’animale`)},{value:`personFollow`,label:F(`follow a person`,`segui una persona`)},{value:`stop`,label:F(`stop`,`fermati`)},{value:`startClean`,label:F(`start cleaning`,`inizia a pulire`)},{value:`pauseClean`,label:F(`pause cleaning`,`metti in pausa la pulizia`)},{value:`dockWash`,label:F(`wash the mop at the dock`,`lava il mocio alla base`)},{value:`autoEmpty`,label:F(`empty the bin at the dock`,`svuota il contenitore alla base`)},{value:`flashOn`,label:F(`turn the flash on`,`accendi il flash`)},{value:`flashOff`,label:F(`turn the flash off`,`spegni il flash`)}]}}]}]}),playSound:A(x({deviceId:n(),soundId:n().int()}),v(),{kind:`mutation`,actions:[{id:`navigation.playSound`,label:F(`Play sound`,`Riproduci un suono`),phrase:F(`Play {soundId} on {device}`,`Riproduci {soundId} su {device}`),icon:`volume-2`,openArgs:[{key:`soundId`,label:F(`Sound`,`Suono`),offer:{kind:`dynamic`,from:`method`,method:`listActions`,valueKey:`soundId`,labelKey:`label`,where:{key:`kind`,equals:`sound`},valueKind:`number`}}]}]}),setLightOn:A(x({deviceId:n(),on:y()}),v(),{kind:`mutation`,actions:[{id:`navigation.lightOn`,label:F(`Light on`,`Luce accesa`),phrase:F(`Turn on the light of {device}`,`Accendi la luce di {device}`),icon:`lightbulb`,args:{on:!0}},{id:`navigation.lightOff`,label:F(`Light off`,`Luce spenta`),phrase:F(`Turn off the light of {device}`,`Spegni la luce di {device}`),icon:`lightbulb-off`,args:{on:!1}}]}),setLightMode:A(x({deviceId:n(),mode:_K,level:n().min(40).max(100).optional()}),v(),{kind:`mutation`,actions:[{id:`navigation.lightAuto`,label:F(`Light automatic`,`Luce automatica`),phrase:F(`Set the light of {device} to automatic`,`Metti la luce di {device} in automatico`),icon:`lightbulb`,args:{mode:`auto`}}]}),setLightLevel:A(x({deviceId:n(),level:n().min(40).max(100)}),v(),{kind:`mutation`,actions:[{id:`navigation.lightLevel`,label:F(`Set light level`,`Imposta la luce`),phrase:F(`Set the light of {device} to {level}`,`Imposta la luce di {device} al {level}`),icon:`sun-medium`,openArgs:[{key:`level`,label:F(`Level`,`Livello`),offer:{kind:`number`,min:40,max:100,step:1,unit:`%`}}]}]}),getFeatures:A(x({deviceId:n()}),gK)},events:{onStatusChanged:{data:x({deviceId:n(),status:yK}),notOperatorFacing:"the `mode` state trigger reads the same change"}},status:{schema:yK,kind:`push`},runtimeState:bK,durability:`session`,history:`none`,vocabulary:{noun:F(`Robot movement`,`Movimento del robot`),order:2080,state:[{kind:`enum`,field:`mode`,label:F(`Activity`,`Attività`),values:[{value:`idle`,label:F(`Idle`,`Inattivo`)},{value:`cleaning`,label:F(`Cleaning`,`In pulizia`)},{value:`spot`,label:F(`Spot cleaning`,`Pulizia localizzata`)},{value:`following`,label:F(`Following`,`In inseguimento`)},{value:`goto`,label:F(`Moving to a point`,`In movimento verso un punto`)},{value:`returning`,label:F(`Returning`,`In rientro`)},{value:`paused`,label:F(`Paused`,`In pausa`)},{value:`unknown`,label:F(`Unknown`,`Sconosciuto`)}],icon:`bot`}]}},SK=x({url:l(),hostname:l(),port:n(),protocol:S([`http`,`https`]),stable:y().optional()}),TOe=x({url:l(),stable:y().optional(),updated:y().optional()}),CK=x({connected:y(),endpoint:SK.nullable(),error:l().optional()}),EOe=SK.extend({id:l(),label:l(),mode:l().optional(),sourcePort:n().optional()}),wK={name:`network-access`,scope:`system`,mode:`collection`,providerKind:`ingress`,methods:{start:A(v(),SK,{kind:`mutation`}),stop:A(v(),v(),{kind:`mutation`}),getEndpoint:A(v(),SK.nullable()),getStatus:A(v(),CK),listEndpoints:A(v(),C(EOe).readonly())},vocabulary:{notOperatorFacing:M.NETWORK}},TK=[`wifi`,`ethernet`,`cellular`,`unknown`],EK=x({type:S(TK),signal:n().min(0).max(100).nullable().meta(N(`percentage`)),rssi:n().optional().meta(N(`signal-level`)),ssid:l().optional(),speedKbps:n().nonnegative().nullable().optional().meta(N(`bitrate`)),linkUp:y().nullable().optional(),lastUpdated:n().meta(N(`none`))}),DK={type:`unknown`,signal:null,lastUpdated:0};function DOe(e,t){return e===void 0||!Number.isFinite(e)||t<=0||e<0||e>t?null:Math.round(e/t*100)}function OOe(e){return e===void 0||!Number.isFinite(e)||e>0?null:Math.round((Math.min(-50,Math.max(-100,e))+100)*2)}var OK={name:`network-link`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera,E.Sensor,E.Button,E.Switch,E.Light,E.Lock,E.Siren],methods:{},events:{onStatusChanged:{data:x({deviceId:n(),status:EK}),notOperatorFacing:`the signal / link-type state triggers each read one field of this change`}},status:{schema:EK,kind:`push`,empty:DK},runtimeState:EK,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:F(`Network link`,`Collegamento di rete`),order:5250,state:[{kind:`numeric`,field:`signal`,quantity:F(`the signal strength`,`l’intensità del segnale`),label:F(`Signal`,`Segnale`),unit:`%`,icon:`wifi`},{kind:`enum`,field:`type`,label:F(`Link type`,`Tipo di collegamento`),values:[{value:`wifi`,label:F(`Wi-Fi`,`Wi-Fi`)},{value:`ethernet`,label:F(`Ethernet`,`Ethernet`)},{value:`cellular`,label:F(`Cellular`,`Rete mobile`)},{value:`unknown`,label:F(`Unknown`,`Sconosciuto`)}],icon:`network`}]}},kK=x({nominalBitrateKbps:n(),observedBitrateKbps:n(),peakBitrateKbps:n(),packetLossPercent:n(),lastUpdated:n()}),AK=x({rttMs:n(),jitterMs:n(),estimatedBandwidthKbps:n(),packetLossPercent:n().min(0).max(100),downlinkMbps:n().optional(),downlinkAgeMs:n().optional(),lastUpdated:n()}),jK=x({deviceId:n(),streams:m(l(),kK),client:AK.optional()}),MK={name:`network-quality`,scope:`system`,mode:`singleton`,methods:{getDeviceStats:A(x({deviceId:n()}),jK.nullable()),getAllStats:A(v(),C(jK).readonly()),reportClientStats:A(x({deviceId:n(),rttMs:n().min(0).max(6e4),jitterMs:n().min(0).max(1e4),estimatedBandwidthKbps:n().min(0).max(1e6),packetLossPercent:n().min(0).max(100),downlinkMbps:n().min(0).max(1e5).optional(),downlinkAgeMs:n().min(0).max(864e5).optional()}),v(),{role:`viewer`,kind:`mutation`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:M.NETWORK}},NK=x({cn:l(),serial:l(),fingerprintSha256:l(),notBefore:n(),notAfter:n()}),PK=x({fingerprintSha256:l(),issuer:l(),sans:C(l()),notBefore:n(),notAfter:n()}),FK=i(`state`,[x({state:p(`served`),leaf:PK}),x({state:p(`not-issued`),reason:l()})]),IK={name:`node-certificates`,scope:`system`,mode:`singleton`,internal:!0,methods:{getCertificates:A(x({}),x({nodeId:l(),mesh:NK.nullable(),https:FK}),{auth:`admin`}),prepareMeshRenewal:A(x({}),x({csrPem:l()}),{kind:`mutation`,auth:`admin`}),installMeshLeaf:A(x({certPem:l().min(1),caCertPem:l().min(1),confirmWithinMs:n().int().min(1e4).max(6e5)}),x({fingerprintSha256:l(),serial:l()}),{kind:`mutation`,auth:`admin`}),confirmMeshLeaf:A(x({fingerprintSha256:l()}),x({confirmed:y()}),{kind:`mutation`,auth:`admin`}),rollbackMeshLeaf:A(x({}),x({rolledBack:y()}),{kind:`mutation`,auth:`admin`}),prepareHttpsCertificate:A(x({}),x({csrPem:l(),hostnames:C(l()),addresses:C(l()),pinnedCaFingerprintSha256:l().nullable()}),{kind:`mutation`,auth:`admin`}),forgetHub:A(x({}),x({ok:p(!0)}),{kind:`mutation`,auth:`admin`}),installHttpsCertificate:A(x({certPem:l().min(1),caCertPem:l().min(1),caRotation:y().optional()}),PK,{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:M.IDENTITY}},LK=x({nodeId:l().min(1),removedAt:n()}),RK=x({counts:m(l(),n().int().nonnegative())}),zK={name:`node-removal-hook`,scope:`system`,mode:`collection`,internal:!0,methods:{onNodeRemoved:A(LK,RK,{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:M.INTERNAL}},BK=x({addonId:l(),capabilities:C(l()).readonly(),status:l()}),VK=x({pid:n(),name:l(),state:l(),cpuPercent:n(),memoryRss:n(),uptimeSeconds:n(),services:C(BK).readonly(),groupId:l().optional()}),kOe=x({id:l(),status:l(),cpuPercent:n(),memoryRss:n()}),AOe=x({category:l(),total:n(),healthy:n(),addons:C(kOe).readonly()}),jOe=x({name:l(),version:l()}),HK=x({id:l(),name:l(),hostname:l(),platform:l(),arch:l(),cpuModel:l().nullable(),cpuCores:n(),memoryMB:n(),engines:C(l()).readonly(),isHub:y(),isOnline:y(),cpuPercent:n(),memoryPercent:n().nullable(),uptime:n(),lastSeen:l(),localIps:C(l()).readonly(),addons:C(x({id:l(),capabilities:C(l()).readonly(),status:l()})).readonly(),processes:C(VK).readonly(),categories:C(AOe).readonly(),rootPackage:jOe.nullable(),meshTransport:S([`tls`,`clear`]).optional(),capabilitiesRegistered:y().optional()}),MOe=x({callerAddonId:l(),providerAddonId:l(),capName:l(),callsPerMin:n(),lastCallAtMs:n()}),UK=x({nodeId:l(),name:l(),version:l(),status:l(),synced:y()}),WK=x({hubVersion:l(),nodes:C(UK)}),GK=x({nodeId:l(),addonId:l()}),NOe=x({id:l(),status:l(),version:l().optional(),packageName:l().optional()}),KK=x({success:y()}),POe=x({success:y(),reason:l().optional()}),FOe=x({restarted:C(l()).readonly(),failed:C(l()).readonly()}),IOe=x({nodeId:l(),name:l()}),qK=x({id:l(),name:l(),isHub:y(),isOnline:y()}),JK=x({nodes:C(qK).readonly(),complete:y()}),YK={name:`nodes`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,methods:{topology:A(v(),C(HK).readonly(),{auth:`admin`}),directory:A(v(),JK,{auth:`admin`}),deployAddon:A(GK,KK,{kind:`mutation`,auth:`admin`}),undeployAddon:A(GK,KK,{kind:`mutation`,auth:`admin`}),restartAddon:A(GK,KK,{kind:`mutation`,auth:`admin`}),restartProcess:A(x({nodeId:l(),processName:l()}),POe,{kind:`mutation`,auth:`admin`}),restartNode:A(x({nodeId:l()}),FOe,{kind:`mutation`,auth:`admin`}),shutdownNode:A(x({nodeId:l()}),KK,{kind:`mutation`,auth:`admin`}),renameNode:A(x({nodeId:l(),name:l().min(1).max(64)}),IOe,{kind:`mutation`,auth:`admin`}),clusterAddonStatus:A(v(),m(l(),WK),{auth:`admin`}),getCapUsageGraph:A(x({windowSeconds:n().int().positive().max(300).default(60)}),C(MOe).readonly(),{auth:`admin`}),getNodeAddons:A(x({nodeId:l()}),C(NOe).readonly(),{auth:`admin`}),setProcessLogLevel:A(x({nodeId:l(),level:l()}),KK,{kind:`mutation`,auth:`admin`}),executeQuery:A(x({nodeId:l(),addonId:l(),queryName:l(),params:m(l(),w()).optional()}),w(),{kind:`mutation`,auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:M.CLUSTER}},XK=[{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`}],ZK={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},QK={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},$K=new Map;for(let[e,t]of Object.entries(ZK.mapping))$K.set(e.toLowerCase(),t);for(let[e,t]of Object.entries(QK.mapping))$K.set(e.toLowerCase(),t);function LOe(e){return $K.get(e.toLowerCase())??null}function ROe(){return XK.map(e=>e.id)}var eq=bP();function tq(e){return TP(eq.swatches,eq.fallbacks,e)}function zOe(e){let t=e[0];if(t===void 0)throw Error(`display palette has no fallback colour`);return t}var BOe=zOe(eq.fallbacks);function VOe(e){return e.split(/[-_ ]/).filter(e=>e.length>0).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}var nq=new Map;function rq(e,t,n,r){nq.set(e,{kind:e,parentKind:null,level:`macro`,category:t,color:tq(e),iconId:n,labelKey:`eventKind.${e}`,label:r})}function iq(e,t,n,r,i){nq.set(e,{kind:e,parentKind:t,level:`sub`,category:n,color:tq(e),iconId:r,labelKey:`eventKind.${e}`,label:i})}rq(`motion`,`motion`,`motion`,`Motion`),rq(`audio`,`audio`,`audio`,`Audio`),rq(`person`,`detection`,`person`,`Person`),rq(`vehicle`,`detection`,`vehicle`,`Vehicle`),rq(`animal`,`detection`,`animal`,`Animal`),rq(`package`,`package`,`package`,`Package`),rq(`sensor`,`sensor`,`sensor`,`Sensor`),rq(`control`,`control`,`control`,`Control`);for(let[e,t]of Object.entries(r_.mapping))t!==`vehicle`&&t!==`animal`||nq.has(e)||iq(e,t,`detection`,e,VOe(e));iq(`package-delivered`,`package`,`package`,`package`,`Package delivered`),iq(`package-picked-up`,`package`,`package`,`package`,`Package picked up`),iq(`contact`,`sensor`,`sensor`,`door`,`Contact`),iq(`motion-sensor`,`sensor`,`sensor`,`pir`,`Motion sensor`),iq(`smoke`,`sensor`,`sensor`,`smoke`,`Smoke`),iq(`flood`,`sensor`,`sensor`,`water`,`Water leak`),iq(`gas`,`sensor`,`sensor`,`gas`,`Gas`),iq(`carbon-monoxide`,`sensor`,`sensor`,`smoke`,`Carbon monoxide`),iq(`vibration`,`sensor`,`sensor`,`vibration`,`Vibration`),iq(`tamper`,`sensor`,`sensor`,`tamper`,`Tamper`),iq(`presence`,`sensor`,`sensor`,`presence`,`Presence`),iq(`enum-sensor`,`sensor`,`sensor`,`generic`,`Sensor state`),iq(`device-event`,`sensor`,`sensor`,`button`,`Device event`),iq(`lock`,`control`,`control`,`lock`,`Lock`),iq(`cover`,`control`,`control`,`door`,`Cover`),iq(`switch`,`control`,`control`,`switch`,`Switch`),iq(`siren`,`control`,`control`,`siren`,`Siren`),iq(`button`,`control`,`control`,`button`,`Button`),iq(`doorbell`,`control`,`control`,`doorbell`,`Doorbell`),iq(`appliance-cycle`,`control`,`control`,`switch`,`Appliance cycle`);for(let e of XK){let t=`audio-${e.id}`;nq.has(t)||iq(t,`audio`,`audio`,t,e.name)}var aq=Object.freeze(Object.fromEntries(nq));function oq(e){return aq[e]}function HOe(e){return tq(e)}function UOe(e){let t=[];for(let n of Object.values(aq))n.parentKind===e&&t.push(n);return t}var sq=x({kind:l(),label:l(),parentKind:l().nullable()}),cq=x({videoClasses:C(sq),audioKinds:C(sq),labels:C(sq)});function lq(e,t,n){return{kind:e,label:t,parentKind:n}}function uq(){let e=Object.values(aq);return{videoClasses:e.filter(e=>e.category===`detection`).map(e=>lq(e.kind,e.label,e.parentKind)),audioKinds:e.filter(e=>e.category===`audio`&&e.level===`sub`).map(e=>lq(e.kind,e.label,e.parentKind)),labels:e.filter(e=>e.category===`sensor`||e.category===`control`).map(e=>lq(e.kind,e.label,e.parentKind))}}var WOe=Object.freeze(uq()),dq=S([`immediate`,`track-end`,`device-event`,`package-event`,`system-event`]),fq=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(`.`)),pq=[`camera-online`,`camera-offline`,`camera-disabled`,`camera-enabled`],GOe=new Set(pq),KOe=fq.options.filter(e=>!GOe.has(e)),mq=[`alarm-arm-refused`,`alarm-check-failed`,`alarm-arming`,`alarm-armed`,`alarm-pending`,`alarm-triggered`,`alarm-rearmed`,`alarm-sensor-bypass`,`alarm-disarmed`],qOe=[`device-battery-low`,`device-battery-normal`,`device-consumable-low`,`device-consumable-normal`],hq=[`device-consumable-low`,`device-consumable-normal`],JOe=15,YOe=95,gq=[`confirmed`,`already`,`unconfirmed`,`failed`],_q=[`user`,`addon`,`action`,`scheduler`,`composition`,`node`],vq=x({kinds:C(fq).min(1),deviceIds:C(n().int()).min(1).optional(),deviceTypes:C(l().min(1)).min(1).optional(),excludeDeviceIds:C(n().int()).min(1).optional(),nodeIds:C(l().min(1)).min(1).optional(),packageNames:C(l().min(1)).min(1).optional(),commandActions:C(l().min(1)).min(1).optional(),commandOutcomes:C(S(gq)).min(1).optional(),commandActorKinds:C(S(_q)).min(1).optional(),consumableLowPercent:n().int().min(1).max(95).optional()});function XOe(e){return e.consumableLowPercent??15}var ZOe=1,yq=1440,QOe=[10,30,60],bq=x({days:C(n().int().min(0).max(6)).min(1),startMinute:n().int().min(0).max(1439),endMinute:n().int().min(0).max(1439)}),xq=x({windows:C(bq).min(1),timezone:l().optional(),invert:y().optional()}),Sq=S([`instant`,`summary`]),$Oe=S([`activation`,`deactivation`,`schedule`]),Cq=S([`rule`,`section`]),wq=i(`mode`,[x({mode:p(`instant`)}),x({mode:p(`summary`),schedule:xq,split:Cq.optional()}),x({mode:p(`modes`),onActivation:y(),onDeactivation:y(),onSchedule:x({schedule:xq,grouping:Cq}).optional()})]),Tq=x({values:C(l().min(1)),maxDistance:n().int().min(0).max(3).default(1)}),Eq=x({zoneId:l().optional(),className:l().optional(),op:S([`became-occupied`,`became-free`,`>=`,`<=`]).default(`became-occupied`),count:n().int().min(0).default(1),sustainSeconds:n().int().min(0).max(3600).default(15)}),eke=-96,Dq=x({labels:C(l().min(1)).min(1).optional(),dbThreshold:n().min(-96).max(0).optional(),hitPercent:n().int().min(1).max(100).default(60),samplingSeconds:n().int().min(1).max(300).default(10),confirmHits:n().int().min(1).max(20).optional(),confirmWindowSec:n().int().min(1).max(60).optional()}),Oq=S([`enter`,`exit`,`any`]),kq=S([`raised`,`cleared`]),Aq=x({ids:C(l().min(1)).min(1),match:S([`any`,`all`]).optional()}),jq=l().min(1),Mq=C(jq).max(4),Nq=x({id:l().min(1).max(64),label:l().min(1).max(40),actionId:jq,icon:Xu.optional(),destructive:y().optional()}),Pq=x({onActivation:Mq.optional(),onDeactivation:Mq.optional(),onTrigger:Mq.optional(),onTriggerOff:Mq.optional(),buttons:C(Nq).max(8).optional()}),Fq=x({deviceId:n().int(),states:C(l().min(1)).min(1)}),Iq=x({sceneId:l().min(1),deviceId:n().int().optional(),requiredState:S([`matched`,`diverged`]),latched:y().optional()}),Lq=x({deviceState:Fq.optional(),scene:Iq.optional(),devices:C(n()).optional(),devicesExclude:C(n()).min(1).optional(),classes:C(l().min(1)).optional(),classesExclude:C(l().min(1)).optional(),minConfidence:n().min(0).max(1).optional(),zones:Aq.optional(),zonesExclude:C(l().min(1)).optional(),crossing:Oq.optional(),labelEquals:C(l().min(1)).optional(),identities:C(l().min(1)).optional(),plates:Tq.optional(),identitiesExclude:C(l().min(1)).optional(),minImportance:n().min(0).max(1).optional(),minDwellSeconds:n().min(0).optional(),source:S([`pipeline`,`onboard`,`sensor`,`audio`,`any`]).optional(),minLabelConfidence:n().min(0).max(1).optional(),eventTypeTokens:C(l().min(1)).optional(),sensorKinds:C(l().min(1)).optional(),sensorTransition:kq.optional(),packagePhase:S([`delivered`,`picked-up`,`both`]).optional(),systemEvent:vq.optional(),customZones:C(aH).optional(),occupancy:Eq.optional(),audio:Dq.optional()}),Rq=x({targetId:l().min(1),params:m(l(),w()).optional()}),tke=500,zq=S([`none`,`image`,`clip`,`gif`]),Bq=x({template:x({title:l().max(500).optional(),body:l().max(2e3).optional()}).optional(),schedule:xq.optional(),priority:n().int().min(1).max(5).optional(),attachment:zq.optional(),actions:y().optional()}),Vq=m(l(),Bq),Hq=S([`scene-boxes`,`crop`,`clean`,`none`]),Uq=S([`cropped`,`full`,`boxed`]),Wq=S([`mosaic`,`each`]),nke=4,rke=6,Gq=x({image:Hq.optional(),showTriggerZone:y().optional(),showSubjectPath:y().optional(),attach:S([`best`,`best-matching`,`keyFrame`,`none`]).optional(),frame:Uq.optional(),zoneCrop:y().optional(),gif:y().optional(),clip:y().optional(),clipPreRollSec:n().int().min(0).max(30).optional(),clipPostRollSec:n().int().min(0).max(30).optional(),clipSpeed:n().min(1).max(8).optional(),profile:P.optional(),linkedCameras:Wq.optional(),wakeSleepingCamera:y().optional()}),Kq=S([`shared`,`per-class`]),qq=x({cooldownSec:n().int().min(0).max(86400).default(60),scope:S([`rule`,`rule-device`]).default(`rule-device`),granularity:Kq.optional()}),Jq=1e3,Yq=2e4,Xq=8e3,ike=448,Zq=x({op:S([`>=`,`>`,`<=`,`<`,`==`]),count:n().int().min(0).max(1e3)}),Qq=x({enabled:y().default(!1),profileId:l().optional(),prompt:l().max(1e3).optional(),expect:Zq.optional(),timeoutMs:n().int().min(Jq).max(Yq).default(Xq),onTimeout:S([`fire`,`suppress`]).default(`fire`),maxImagePx:n().int().min(64).max(2048).default(448)}),ake=5,oke=20,ske=60,cke=5,lke=0,uke=300,$q=x({name:l().min(1).max(200),enabled:y().default(!0),delivery:dq,conditions:Lq.default({}),schedule:xq.optional(),systemEventDelivery:wq.optional(),targets:C(Rq),targetUsers:C(l()).optional(),targetOverrides:Vq.optional(),media:Gq.default({}),throttle:qq.default({cooldownSec:60,scope:`rule-device`}),template:x({title:l().max(500).optional(),body:l().max(2e3).optional()}).optional(),priority:n().int().min(1).max(5).default(3),ownerUserId:l().optional(),snoozeAllowGlobal:y().optional(),snoozeOptions:C(n().int().min(1).max(yq)).max(4).optional(),actions:Pq.optional(),confirm:Qq.optional(),groupingSec:n().int().min(5).max(60).optional(),groupWithinSec:n().int().min(0).max(300).optional(),askVerdict:y().optional(),tags:Hh.optional()}),eJ=S([`event`,`summary`,`timelapse`,`calendar-events`]),tJ=x({kind:eJ,ruleId:l(),tags:C(l())}),nJ=$q.partial().extend({disabledTargetIds:C(l()).optional(),enabled:y().optional(),conditions:Lq.optional(),media:Gq.optional(),throttle:qq.optional(),priority:n().int().min(1).max(5).optional()}),rJ=[`waitForEnhancement`,`groupIdleSec`];function dke(e){return rJ.some(t=>t===e)}var iJ=[`template`,`schedule`,`targetUsers`,`snoozeOptions`,`snoozeAllowGlobal`,`actions`,`confirm`,`groupingSec`,`waitForEnhancement`,`groupIdleSec`],aJ=S(iJ),oJ=x({ruleId:l(),patch:nJ,clear:C(aJ).optional()}),sJ=$q.extend({id:l(),createdBy:l(),createdAt:n(),updatedAt:n(),disabledTargetIds:C(l()).default([])}),cJ=[`device-state`,`streams`,`battery`,`consumables`,`detection-blind`,`nodes`,`addons`,`addon-updates`,`updates`],lJ=S(cJ),uJ=x({id:lJ,status:S([`read`,`unavailable`]),items:n().int().nonnegative(),reason:l().optional()}),dJ=x({section:lJ.optional(),title:l(),text:l(),count:n().int().nonnegative()}),fJ=x({empty:y(),count:n().int().nonnegative(),text:l(),sections:C(uJ),dropped:m(l(),n().int().nonnegative()),excludedGroups:C(l()),split:Cq.optional(),rows:C(dJ).optional()}),pJ=x({recordId:l(),recordKind:S([`object-event`,`track`,`device-event`,`package-event`,`system-event`]),deviceId:n(),timestamp:n(),wouldFire:y(),failedCondition:l().optional(),className:l().optional(),label:l().optional()}),mJ=S([`detection`,`sensor`,`occupancy`,`sound`,`device-events`,`system`,`alarm`,`mixed`]),hJ=S([`detection`,`sensor`,`occupancy`,`sound`,`system`]),gJ=x({id:S([`appliance-cycle`]),kind:mJ,title:l(),body:l()}),_J=S([`rule`,`timelapse`,`summary`]),vJ=S([`title`,`body`,`previewText`,`captionText`]),yJ=S([`subject`,`place`,`time`,`rule`,`occupancy`,`sound`,`sensor`,`system`,`digest`,`ai`]),bJ=x({name:l().regex(/^\w+$/),label:l(),description:l().optional(),example:l(),group:yJ,families:C(_J).min(1),fields:C(vJ).optional(),kinds:C(hJ).optional(),deliveries:C(dq).optional(),systemEventKinds:C(fq).optional(),systemEventDeliveries:C(Sq).optional(),dynamic:x({prefix:p(`count_`),from:p(`classes`)}).optional()}),xJ=x({family:_J,field:vJ,kind:mJ.optional(),delivery:dq.optional(),systemEventKinds:C(fq).optional(),systemEventDelivery:Sq.optional()}),SJ=x({context:xJ,template:x({title:l().max(500).optional(),body:l().max(2e3).optional()})}),CJ=x({title:l().nullable(),body:l().nullable(),unknown:C(l())}),wJ=x({id:l(),group:S([`scope`,`class`,`zones`,`quality`,`label`,`schedule`,`device`,`package`,`occupancy`,`audio`,`system`]),label:l(),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(dq),phase:l(),description:l().optional(),options:C(x({value:l(),label:l(),hint:l().optional()})).readonly().optional()}),fke=[{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.`}],TJ=S([`pending`,`sent`,`dead`]),EJ=S([`object-event`,`track-end`,`device-event`,`package-event`,`system-event`]),DJ=x({className:l(),label:l().optional(),confidence:n().optional(),zones:C(l()),timestamp:n(),systemEvent:x({kind:fq,subject:l(),title:l(),body:l(),data:m(l(),w())}).optional()}),OJ=x({id:l(),ruleId:l(),ruleName:l(),delivery:dq,targetId:l(),deviceId:n(),recordKind:EJ,recordId:l(),trackId:l().optional(),status:TJ,attempts:n().int(),createdAt:n(),updatedAt:n(),error:l().optional(),subject:DJ,title:l().optional(),body:l().optional(),artifactIds:C(l().min(1)).optional(),groupedInto:l().min(1).optional()}),pke=100,mke=500,kJ=x({ruleId:l().optional(),deviceId:n().optional(),status:TJ.optional(),since:n().optional(),until:n().optional(),limit:n().int().min(1).max(500).default(100)}),AJ=x({ruleId:l(),lastAt:n(),status:TJ,deviceId:n()}),jJ=x({runs:C(AJ),horizonMs:n().nonnegative().nullable()}),MJ=S([`rule`,`device`,`all`]),NJ=x({scope:MJ,ruleId:l().optional(),deviceId:n().int().optional(),classes:C(l().min(1)).min(1).optional(),durationMinutes:n().int().min(1).max(yq),global:y().optional(),summary:y().optional()}),PJ=x({id:l(),userId:l(),scope:MJ,ruleId:l().optional(),deviceId:n().int().optional(),classes:C(l().min(1)).min(1).optional(),startedAt:n(),expiresAt:n(),global:y(),summary:y(),digestSentAt:n().optional()}),hke=x({snoozeId:l(),targetId:l(),ruleId:l(),ruleName:l(),deviceId:n().int(),count:n().int(),firstAt:n(),lastAt:n()}),gke=600,FJ=3600,_ke=200,IJ=n().int().min(0).max(600),LJ=n().int().min(0).max(FJ),RJ=e=>new Set(e.map(e=>e.mode)).size===e.length,zJ=S([`rearmAfter`,`disableAfter`,`doNothing`]),BJ=x({mode:YS,exitDelaySec:IJ.optional(),entryDelaySec:IJ.optional(),triggeredDurationSec:LJ.optional(),postTriggeredAction:zJ.optional(),schedule:xq.optional(),notifyDuringEntryDelay:y().optional(),notifySensorRewatched:y().optional(),notifySensorIgnored:y().optional()}),vke=C(BJ).max(8).refine(RJ,{message:`modeDelays: at most one entry per arm mode`}),VJ=x({mode:YS,exitDelaySec:IJ.nullable().optional(),entryDelaySec:IJ.nullable().optional(),triggeredDurationSec:LJ.nullable().optional(),postTriggeredAction:zJ.nullable().optional(),schedule:xq.nullable().optional(),notifyDuringEntryDelay:y().nullable().optional(),notifySensorRewatched:y().nullable().optional(),notifySensorIgnored:y().nullable().optional()}),yke=C(VJ).max(8).refine(RJ,{message:`modeDelays: at most one edit per arm mode`}),HJ=x({mode:YS,deviceId:n().int().positive(),nonBlocking:y()}),UJ=x({mode:YS,deviceId:n().int().positive(),blocking:y()}),WJ=x({mode:YS,deviceId:n().int().positive(),secureOnArm:y()}),GJ=x({mode:YS,deviceIds:C(n().int()).max(200)}),KJ=GJ,qJ=GJ,JJ=GJ,YJ=C(KJ).max(8).refine(RJ,{message:`nonBlocking: at most one list per arm mode`}),XJ=C(qJ).max(8).refine(RJ,{message:`blocking: at most one list per arm mode`}),ZJ=C(JJ).max(8).refine(RJ,{message:`secureOnArmOff: at most one list per arm mode`}),QJ=x({exitDelaySec:IJ,entryDelaySec:IJ,triggeredDurationSec:LJ,postTriggeredAction:zJ.optional(),announceArm:y().optional(),announceTargets:C(l().min(1)).max(16),nonBlocking:YJ.default([]),blocking:XJ.default([]),secureOnArmOff:ZJ.default([]),modeDelays:vke.default([])}),$J=x({id:l().min(1).max(64),name:l().min(1).max(64),isDefault:y()}),eY=x({activeId:l().min(1),items:C($J).min(1)}),tY=x({name:l().min(1).max(64),cloneFromId:l().min(1).max(64).optional()}),nY=x({id:l().min(1).max(64),name:l().min(1).max(64)}),rY=x({id:l().min(1).max(64)}),bke=QJ.extend({nonBlocking:YJ,blocking:XJ,secureOnArmOff:ZJ,modeDelays:yke,nonBlockingEdit:HJ,blockingEdit:UJ,secureOnArmEdit:WJ}).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`}),iY=S([`muted`,`detection-off`,`offline`]),aY=x({deviceId:n().int(),reason:iY}),oY=x({mode:YS,ruleCount:n().int().min(0),allDevices:y(),deviceIds:C(n().int()),allDevicesExcept:C(n().int()).default([]),skippedDevices:C(aY).default([])}),xke=x({deviceId:n().int(),name:l(),state:l(),blocking:y()}),Ske=x({deviceId:n().int(),name:l(),phase:S([`open`,`closed`])}),Cke=x({mode:YS,devices:C(xke),unknown:C(n().int())}),wke=x({ruleId:l(),ruleName:l(),deviceId:n().int(),name:l(),since:n(),dropped:n().int().min(0)}),Tke=x({state:JS,targetMode:YS.nullable(),availableModes:C(YS),openings:C(Cke),exclusions:C(Ske),bypassedInputs:C(wke).default([])}),sY=x({deviceId:n().int().nullable(),settings:QJ,profiles:eY.optional(),coverage:C(oY),live:Tke.optional()}),Eke=500,cY=S([`open`,`closed`,`unknown`,`not-opening`]),lY=x({deviceId:n().int().positive(),reading:cY,state:l().nullable(),unknownWhy:S([`read-failed`,`unknown-word`]).nullable(),online:y().nullable(),controllable:y().default(!1)}),uY=x({deviceIds:C(n().int().positive()).max(500)}),dY=x({sensors:C(lY),readAt:n().int().nonnegative()}),Dke=60,fY=x({deviceId:n().int().nonnegative().optional(),seconds:n().min(0).max(60),profile:P.optional(),ruleId:l(),ruleName:l(),reason:S([`window`,`occupancy`])}),pY=x({rulesLoaded:y(),asks:C(fY).readonly()}),mY={name:`notification-rules`,scope:`system`,mode:`singleton`,methods:{listRules:A(x({}),x({rules:C(sJ)}),{auth:`admin`}),getRule:A(x({ruleId:l()}),x({rule:sJ.nullable()}),{auth:`admin`}),createRule:A(x({rule:$q}),x({rule:sJ}),{kind:`mutation`,auth:`admin`,caller:`required`}),updateRule:A(oJ,x({rule:sJ}),{kind:`mutation`,auth:`admin`,caller:`required`}),deleteRule:A(x({ruleId:l()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setRuleEnabled:A(x({ruleId:l(),enabled:y()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),listRuleTags:A(x({}),x({rules:C(tJ)}),{kind:`query`,auth:`admin`}),setRuleTags:A(x({kind:eJ,ruleId:l(),tags:Hh}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getClipRetentionAsks:A(x({}),pY,{auth:`admin`}),listDeviceMutes:A(x({}),x({mutedDeviceIds:C(n().int()).readonly()}),{auth:`admin`}),setDeviceMuted:A(x({deviceId:n().int(),muted:y()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),testRule:A(x({rule:$q,lookbackMinutes:n().int().min(1).max(1440).default(60)}),x({results:C(pJ)}),{kind:`mutation`,auth:`admin`}),previewStateSummary:A(x({rule:$q}),fJ,{kind:`mutation`,auth:`admin`,access:`view`}),getConditionCatalog:A(x({}),x({catalog:C(wJ),taxonomy:cq.optional()})),getTemplateCatalog:A(x({}),x({vars:C(bJ),defaults:C(gJ)})),previewTemplate:A(SJ,CJ,{kind:`mutation`,access:`view`}),getHistory:A(x({filter:kJ.default({limit:100})}),x({entries:C(OJ)}),{auth:`admin`}),getRuleLastRuns:A(x({}),jJ,{auth:`admin`}),resolveArtifactUrl:A(x({artifactId:l().min(1)}),x({url:l().nullable()}),{auth:`admin`}),listSnoozes:A(x({}),x({snoozes:C(PJ)}),{caller:`required`}),createSnooze:A(x({snooze:NJ}),x({snooze:PJ}),{kind:`mutation`,caller:`required`}),cancelSnooze:A(x({snoozeId:l()}),x({success:p(!0)}),{kind:`mutation`,caller:`required`}),getAlarmConfig:A(x({}),sY,{auth:`admin`}),setAlarmConfig:A(x({patch:bke}),sY,{kind:`mutation`,auth:`admin`}),createAlarmProfile:A(tY,sY,{kind:`mutation`,auth:`admin`}),renameAlarmProfile:A(nY,sY,{kind:`mutation`,auth:`admin`}),deleteAlarmProfile:A(rY,sY,{kind:`mutation`,auth:`admin`}),activateAlarmProfile:A(rY,sY,{kind:`mutation`,auth:`admin`}),getAlarmSensors:A(uY,dY,{auth:`admin`})},vocabulary:{notOperatorFacing:`notification rules — authored on their own page`}},Oke=S([`min`,`low`,`normal`,`high`]),kke=x({id:l().min(1),title:l().min(1),uri:r().optional(),destructive:y().optional()}),Ake=x({image:y(),priority:y(),data:y(),actions:y(),recipients:y()}),hY=x({lastSentAt:n(),lastError:l().nullable(),queueDepth:n().int().nonnegative().meta(N(`count`)),supports:Ake}),jke=x({deviceId:n().int().nonnegative(),title:l().optional(),body:l().min(1),image:l().optional(),priority:Oke.optional(),channel:l().optional(),recipients:C(l()).optional(),actions:C(kke).optional(),data:m(l(),w()).optional()}),Mke=x({notificationId:l(),acceptedAt:n()}),gY={name:`notifier`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Notifier],methods:{send:A(jke,Mke,{kind:`mutation`,auth:`admin`,actions:[{id:`notifier.send`,label:F(`Send a notification`,`Invia una notifica`),phrase:F(`Send “{body}” through {device}`,`Invia «{body}» tramite {device}`),icon:`send`,openArgs:[{key:`title`,label:F(`Title`,`Titolo`),offer:{kind:`text`},optional:!0},{key:`body`,label:F(`Message`,`Messaggio`),offer:{kind:`text`}},{key:`priority`,label:F(`Priority`,`Priorità`),offer:{kind:`enum`,values:[{value:`min`,label:F(`Minimal`,`Minima`)},{value:`low`,label:F(`Low`,`Bassa`)},{value:`normal`,label:F(`Normal`,`Normale`)},{value:`high`,label:F(`High`,`Alta`)}]},optional:!0}]}]}),cancel:A(x({deviceId:n().int().nonnegative(),notificationId:l().min(1)}),v(),{kind:`mutation`,auth:`admin`})},events:{onSent:{data:x({deviceId:n(),notificationId:l(),success:y(),error:l().nullable(),acceptedAt:n()}),notOperatorFacing:`a delivery receipt of a send this system made — not a fact about the world`}},status:{schema:hY,kind:`command-driven`},runtimeState:hY,durability:`session`,history:`none`,vocabulary:{noun:F(`Notifier`,`Notificatore`),order:2110}},_Y=x({value:n().nullable().meta(N(`device`)),lastFetchedAt:n()}),vY={name:`numeric-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:_Y,kind:`push`},runtimeState:_Y,durability:`restored`,history:{fields:{value:{kind:`gauge`,minIntervalMs:3e4}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Sensor`,`Sensore`),order:5150,state:[{kind:`numeric`,field:`value`,quantity:F(`the reading`,`il valore`),label:F(`Reading`,`Valore`),icon:`gauge`}]}},yY=x({integrationId:l(),displayName:l(),requestedScopes:C(cg),allowedRedirectPrefixes:C(l()).min(1),allowedPrivateHostPaths:C(l()).optional(),requiresPkce:y().optional(),hubUrl:l().optional(),refreshTokenTtlSec:h([n().int().positive(),p(`never`)]).optional(),instances:C(x({id:l(),displayName:l()})).optional()}),bY={name:`oauth-integration`,scope:`system`,mode:`collection`,internal:!0,methods:{getDescriptor:A(v(),yY,{auth:`admin`})},vocabulary:{notOperatorFacing:M.IDENTITY}},xY=S([`text`,`timestamp`,`watermark`]),SY=S([`top-left`,`top-center`,`top-right`,`bottom-left`,`bottom-center`,`bottom-right`,`custom`]),CY=x({id:l(),kind:xY,enabled:y(),text:l().optional(),position:SY.optional(),availablePositions:C(SY).readonly(),readOnly:y().optional(),maxCharacters:n().int().positive().optional()}),wY=x({overlays:C(CY).readonly()}),TY=x({enabled:y().optional(),text:l().optional(),position:SY.optional()}).partial(),EY={name:`osd`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],methods:{setOverlay:A(x({deviceId:n(),overlayId:l(),patch:TY}),v(),{kind:`mutation`,auth:`admin`})},events:{onStatusChanged:{data:x({deviceId:n(),status:wY}),notOperatorFacing:`an overlay setting changed — configuration, not a happening`}},status:{schema:wY,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:F(`On-screen text`,`Testo in sovrimpressione`),order:3190}},DY=1024,OY=x({id:l().min(1).max(64),name:l().min(1).max(64),text:l().max(DY).default(``)}),kY=i(`kind`,[x({kind:p(`none`)}),x({kind:p(`static`),text:l().max(DY)}),x({kind:p(`template`),templateId:l().min(1).max(64)})]),AY=x({enabled:y().default(!0),source:kY,schedule:xq.optional(),conditions:Lq.optional()}),jY=x({slotId:l(),kind:xY,readOnly:y(),cameraEnabled:y(),cameraText:l().optional(),binding:AY.nullable()}),MY=S([`written`,`unchanged`,`gated`,`unreadable`,`disabled`,`unbound`,`failed`]),NY=x({slotId:l(),outcome:MY,text:l(),reason:l().optional()}),PY=x({ok:y(),text:l(),notes:C(l())}),FY={name:`osd-manager`,scope:`system`,mode:`singleton`,methods:{getDeviceOsd:A(x({deviceId:n().int()}),x({supported:y(),slots:C(jY)}),{auth:`admin`}),getConditionSupport:A(x({}),x({supported:C(l()),catalog:C(wJ)}),{auth:`admin`}),setSlotBinding:A(x({deviceId:n().int(),slotId:l().min(1),binding:AY}),x({slot:jY,render:NY}),{kind:`mutation`,auth:`admin`}),clearSlotBinding:A(x({deviceId:n().int(),slotId:l().min(1)}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setSlotCameraEnabled:A(x({deviceId:n().int(),slotId:l().min(1),enabled:y()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),copyDeviceConfiguration:A(x({sourceDeviceId:n().int(),targetDeviceId:n().int()}),x({copied:n().int().nonnegative(),skipped:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),previewSlot:A(x({deviceId:n().int(),slotId:l().min(1),binding:AY.optional()}),NY,{kind:`mutation`,auth:`admin`}),previewTemplate:A(x({deviceId:n().int(),text:l().max(DY)}),PY,{kind:`mutation`,auth:`admin`}),renderDevice:A(x({deviceId:n().int()}),x({results:C(NY)}),{kind:`mutation`,auth:`admin`}),listTemplates:A(x({}),x({templates:C(OY)}),{auth:`admin`}),upsertTemplate:A(x({template:OY}),x({template:OY}),{kind:`mutation`,auth:`admin`}),deleteTemplate:A(x({templateId:l().min(1).max(64)}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.PIPELINE}},IY=1e4,Nke=4,Pke=200,Fke=S([`normal`,`offline`,`on_batteries`]),LY=n().int().min(4).max(200),RY=LY.meta(vhe({quantity:`mass`,unit:`g`})),zY=x({foodLevel:n().nullable().meta(N(`none`)),bowlFood:n().nullable().meta(N(`mass`)),eating:y(),supportsMarkRefilled:y(),food1:n().nullable().meta(N(`none`)),food2:n().nullable().meta(N(`none`)),lowFood:y(),batteryPower:n().min(0).max(100).nullable().meta(N(`percentage`)),powerSource:S([`mains`,`battery`]).nullable(),desiccantLeftDays:n().nullable().meta(N(`duration`)),feeding:y(),status:Fke.nullable(),error:l().nullable(),errorCode:n().nullable().meta(N(`none`)),isDualHopper:y(),childLock:y(),indicatorLight:y(),feedSound:y(),volume:n().meta(N(`none`)),lastFeedGrams:LY.nullable(),lastFeedHopper1:LY.nullable(),lastFeedHopper2:LY.nullable(),lastFetchedAt:n()}),BY={name:`pet-feeder`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.PetFeeder],methods:{feed:A(x({deviceId:n().int().nonnegative(),grams:RY.optional(),hopper1:RY.optional(),hopper2:RY.optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.feed`,label:F(`Feed`,`Dai da mangiare`),phrase:F(`Dispense {grams} from {device}`,`Eroga {grams} da {device}`),icon:`paw-print`,hold:{effects:[{field:`feeding`,value:!0}],holdMs:IY},openArgs:[{key:`grams`,label:F(`Grams`,`Grammi`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0}]},{id:`petFeeder.feedHoppers`,label:F(`Feed from both hoppers`,`Eroga da entrambi i serbatoi`),phrase:F(`Dispense {hopper1} and {hopper2} from {device}`,`Eroga {hopper1} e {hopper2} da {device}`),icon:`paw-print`,hold:{effects:[{field:`feeding`,value:!0}],holdMs:IY},openArgs:[{key:`hopper1`,label:F(`Hopper 1`,`Serbatoio 1`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0},{key:`hopper2`,label:F(`Hopper 2`,`Serbatoio 2`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0}]}]}),cancelFeed:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.cancelFeed`,label:F(`Cancel feeding`,`Annulla l’erogazione`),phrase:F(`Cancel the feeding on {device}`,`Annulla l’erogazione di {device}`),icon:`circle-x`}]}),callPet:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.callPet`,label:F(`Call pet`,`Chiama l’animale`),phrase:F(`Call your pet with {device}`,`Chiama l’animale con {device}`),icon:`megaphone`}]}),playSound:A(x({deviceId:n().int().nonnegative(),soundId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.playSound`,label:F(`Play sound`,`Riproduci un suono`),phrase:F(`Play sound {soundId} on {device}`,`Riproduci il suono {soundId} su {device}`),icon:`volume-2`,openArgs:[{key:`soundId`,label:F(`Sound`,`Suono`),offer:{kind:`number`,min:0,step:1}}]}]}),resetDesiccant:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.resetDesiccant`,label:F(`Desiccant replaced`,`Essiccante sostituito`),phrase:F(`Mark the desiccant of {device} as replaced`,`Segna come sostituito l’essiccante di {device}`),icon:`refresh-cw`}]}),markFoodReplenished:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.foodReplenished`,label:F(`Food refilled`,`Cibo ricaricato`),phrase:F(`Mark {device} as refilled`,`Segna {device} come ricaricato`),icon:`package`}]}),setChildLock:A(x({deviceId:n().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.childLockOn`,effect:{field:`childLock`,value:!0},label:F(`Child lock on`,`Blocco bambini attivo`),phrase:F(`Turn on the child lock of {device}`,`Attiva il blocco bambini di {device}`),icon:`lock`,args:{on:!0}},{id:`petFeeder.childLockOff`,effect:{field:`childLock`,value:!1},label:F(`Child lock off`,`Blocco bambini spento`),phrase:F(`Turn off the child lock of {device}`,`Disattiva il blocco bambini di {device}`),icon:`lock-open`,args:{on:!1}}]}),setIndicatorLight:A(x({deviceId:n().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.lightOn`,effect:{field:`indicatorLight`,value:!0},label:F(`Indicator light on`,`Spia accesa`),phrase:F(`Turn on the indicator light of {device}`,`Accendi la spia di {device}`),icon:`lightbulb`,args:{on:!0}},{id:`petFeeder.lightOff`,effect:{field:`indicatorLight`,value:!1},label:F(`Indicator light off`,`Spia spenta`),phrase:F(`Turn off the indicator light of {device}`,`Spegni la spia di {device}`),icon:`lightbulb-off`,args:{on:!1}}]}),setFeedSound:A(x({deviceId:n().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.feedSoundOn`,effect:{field:`feedSound`,value:!0},label:F(`Feeding sound on`,`Suono di erogazione attivo`),phrase:F(`Turn on the feeding sound of {device}`,`Attiva il suono di erogazione di {device}`),icon:`volume-2`,args:{on:!0}},{id:`petFeeder.feedSoundOff`,effect:{field:`feedSound`,value:!1},label:F(`Feeding sound off`,`Suono di erogazione spento`),phrase:F(`Turn off the feeding sound of {device}`,`Disattiva il suono di erogazione di {device}`),icon:`volume-x`,args:{on:!1}}]}),setVolume:A(x({deviceId:n().int().nonnegative(),level:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.volume`,effect:{field:`volume`,fromArg:`level`},label:F(`Set volume`,`Imposta il volume`),phrase:F(`Set the volume of {device} to {level}`,`Imposta il volume di {device} a {level}`),icon:`volume-2`,openArgs:[{key:`level`,label:F(`Volume`,`Volume`),offer:{kind:`number`,min:0,step:1}}]}]})},status:{schema:zY,kind:`poll`},runtimeState:zY,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:F(`Pet feeder`,`Distributore di cibo`),order:2030,state:[{kind:`boolean`,field:`lowFood`,label:F(`Food low`,`Cibo in esaurimento`),whenTrue:F(`When {device} runs low on food`,`Quando il cibo di {device} sta finendo`),whenFalse:F(`When {device} has enough food again`,`Quando {device} ha di nuovo cibo a sufficienza`),icon:`package`},{kind:`boolean`,field:`feeding`,label:F(`Feeding`,`In erogazione`),whenTrue:F(`When {device} starts feeding`,`Quando {device} inizia a erogare`),whenFalse:F(`When {device} finishes feeding`,`Quando {device} finisce di erogare`),icon:`paw-print`},{kind:`numeric`,field:`desiccantLeftDays`,quantity:F(`the desiccant life`,`la durata dell’essiccante`),label:F(`Desiccant`,`Essiccante`),unit:`d`,icon:`calendar-clock`}]}},VY=x({waterLevel:n().min(0).max(100).nullable().meta(N(`percentage`)),waterVolume:n().min(0).nullable().meta(N(`volume`)),empty:y().nullable(),pumpRunning:y().nullable(),error:l().nullable(),lastFetchedAt:n()}),HY=`water`;function Ike(e){let t=e.waterLevel!==null||e.empty===null?null:e.empty?`empty`:`ok`;return{key:HY,label:`Water`,level:e.waterLevel,status:t,kind:`supply`,form:`tank`,lastResetAt:null,resettable:!1}}var Lke=n().int().nonnegative(),UY={name:`pet-fountain`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.PetFountain],power:{kind:`field`,field:`pumpRunning`,set:`setPump`},methods:{setPump:A(x({deviceId:Lke,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFountain.pumpOn`,effect:{field:`pumpRunning`,value:!0},label:F(`Pump on`,`Pompa accesa`),phrase:F(`Start the pump of {device}`,`Avvia la pompa di {device}`),icon:`play`,args:{on:!0}},{id:`petFountain.pumpOff`,effect:{field:`pumpRunning`,value:!1},label:F(`Pump off`,`Pompa spenta`),phrase:F(`Stop the pump of {device}`,`Ferma la pompa di {device}`),icon:`square`,args:{on:!1}}]})},status:{schema:VY,kind:`push`},runtimeState:VY,durability:`session`,history:{fields:{waterLevel:{kind:`gauge`,unit:`%`,deadband:1},waterVolume:{kind:`gauge`,unit:`L`}}},vocabulary:{noun:F(`Pet fountain`,`Fontana per animali`),order:2040,state:[{kind:`boolean`,field:`empty`,label:F(`Tank empty`,`Serbatoio vuoto`),whenTrue:F(`When the tank of {device} is empty`,`Quando il serbatoio di {device} è vuoto`),whenFalse:F(`When the tank of {device} is refilled`,`Quando il serbatoio di {device} viene riempito`),icon:`droplet`},{kind:`numeric`,field:`waterLevel`,quantity:F(`the water level`,`il livello dell’acqua`),label:F(`Water level`,`Livello dell’acqua`),unit:`%`,icon:`droplets`}]}},Rke=S(Na),zke=2,WY={min:1,max:8},GY=S([`intel-core-ultra`,`intel-n-series`,`apple-m-base`,`apple-m-pro`,`amd-phoenix`,`nvidia-gpu`,`unknown`]),KY=S([`intel-npu`,`intel-igpu`,`amd-igpu`,`amd-npu`,`nvidia-gpu`,`x86-cpu`,`arm-cpu`,`apple-ane`,`coral`]),qY=i(`kind`,[x({kind:p(`capacity`),sessions:n(),minSessions:n()}),x({kind:p(`tie-faster`),over:l(),recallDelta:n()}),x({kind:p(`stepped-down`),from:l(),to:l(),limitedBy:l()}),x({kind:p(`no-fit-lightest`),sessions:n(),minSessions:n()}),x({kind:p(`derived-latency`),modelId:l()}),x({kind:p(`cpu-device`)}),x({kind:p(`device-disabled`)}),x({kind:p(`device-unavailable`)}),x({kind:p(`node-offline`)}),x({kind:p(`no-hardware-facts`)}),x({kind:p(`no-measured-data`),hardwareClass:GY}),x({kind:p(`no-family-build`),format:Rke}),x({kind:p(`kept-custom-pin`),modelId:l(),deviceKey:l()})]),JY=S([`custom-pin`]),YY=i(`kind`,[x({kind:p(`table`)}),x({kind:p(`node-benchmark`),resultId:l(),measuredAtMs:n()}),x({kind:p(`estimated`),estimatedFrom:GY})]),XY=x({modelId:l(),p50Ms:n(),fps:n(),measured:y(),source:YY.optional(),estimatedFrom:GY.optional(),capacitySessions:n(),personRecall:n()}),ZY=x({deviceKey:l(),accelerator:KY.nullable(),enabled:y(),available:y(),chosen:XY.nullable(),kept:JY.optional(),reasons:C(qY).readonly()}),QY=x({nodeId:l(),reachable:y(),hardwareClass:GY.nullable(),cpuModel:l().nullable(),skipped:y(),acceleratorModelId:l().nullable(),devices:C(ZY).readonly(),reasons:C(qY).readonly()}),$Y=x({stepId:l(),before:l().nullable(),after:l().nullable()}),eX=x({nodeId:l(),deviceKey:l(),madeExplicit:y(),modelPins:C($Y).readonly(),thresholds:C(x({stepId:l(),keys:C(l()).readonly()})).readonly()}),tX=i(`kind`,[x({kind:p(`custom-pin-kept`),nodeId:l(),deviceKey:l(),modelId:l()}),x({kind:p(`custom-registry-unreadable`),error:l()})]),nX=x({headroom:n().min(.3).max(.5).default(.4),minSessionsPerDevice:n().int().min(WY.min).max(WY.max).default(2)}),rX=x({planHash:l(),family:p(`yolov9`),headroom:n(),minSessionsPerDevice:n(),cameraFps:n(),generatedAt:n(),nodes:C(QY).readonly(),nodeChanges:C(eX).readonly(),warnings:C(tX).readonly()}),iX=x({planHash:l(),headroom:n().min(.3).max(.5).default(.4),minSessionsPerDevice:n().int().min(WY.min).max(WY.max).default(2)}),aX=x({phase:S([`download`,`node-models`,`redispatch`]),ok:y(),detail:l()}),oX=i(`kind`,[x({kind:p(`applied`),planHash:l(),phases:C(aX).readonly()}),x({kind:p(`aborted`),phases:C(aX).readonly()}),x({kind:p(`stale`),plan:rX}),x({kind:p(`refused`),reason:S([`apply-in-progress`])})]),sX=S([`least-loaded`,`share`]),cX=`share`,Bke=`sessionPlacement`;function Vke(e){let t=sX.safeParse(e);return t.success?t.data:cX}var lX=x({nodes:m(l(),n().positive()).default({}),devices:m(l(),m(l(),n().positive())).default({})}),uX=x({windowMs:n().int().min(6e4).max(1440*60*1e3).default(3600*1e3)}),dX=x({deviceKey:l(),sessionsNow:n(),sessionsStarted:n(),observedShare:n().nullable()}),fX=x({nodeId:l(),sessionsNow:n(),sessionsStarted:n(),observedShare:n().nullable(),peakSessions:n(),yieldsAway:n(),devices:C(dX).readonly()}),pX=x({deviceId:n(),deviceKey:l(),reason:S([`disabled`,`absent`])}),mX=x({policy:sX,windowMs:n(),observedForMs:n(),sessionsNow:n(),clusterPeakSessions:n(),nodes:C(fX).readonly(),stalePins:C(pX).readonly()}),hX=S([`hardware`,`benchmark`]),gX=S([`no-benchmark-results`,`partial-benchmark-results`]),_X=x({headroom:n().min(.3).max(.5).default(.4),source:hX.default(`hardware`)}),vX=x({deviceKey:l(),share:n(),modelId:l().nullable(),fps:n().nullable(),measured:y(),suggestedMaxSessions:n().nullable()}),yX=x({nodeId:l(),share:n().nullable(),capacitySessions:n(),devices:C(vX).readonly(),skippedReason:l().nullable(),capacitySource:hX.nullable(),capacityFallback:gX.nullable()}),bX=x({headroom:n(),source:hX,cameraFps:n(),minSessionsPerDevice:n(),nodes:C(yX).readonly()}),xX=S([`hardware`,`benchmark`,`manual`]),SX=`benchmark`;function CX(e){return e!==`manual`}var Hke=.4,Uke=`shareSource`;function Wke(e){if(e===`auto`)return`hardware`;let t=xX.safeParse(e);return t.success?t.data:SX}var wX=x({source:xX}),Gke=x({nodes:m(l(),n()),devices:m(l(),m(l(),n()))}),TX=x({deviceKey:l(),eligible:y(),configuredPct:n(),effectivePct:n()}),EX=x({nodeId:l(),eligible:y(),configuredPct:n(),effectivePct:n(),capacitySource:hX.nullable(),capacityFallback:gX.nullable(),devices:C(TX).readonly()}),DX=x({source:xX,policy:sX,autoPending:y(),computedAt:n().nullable(),trigger:l().nullable(),nodes:C(EX).readonly(),nodeWeights:m(l(),n()),deviceWeights:m(l(),m(l(),n()))}),OX=[`motion-without-detections`,`detections-under-floor`,`inference-too-slow`,`frames-shed`,`inference-device-unusable`],kX=S(OX),AX=S([`info`,`warning`,`critical`]),jX=i(`type`,[x({type:p(`camera`),deviceId:n()}),x({type:p(`node`),nodeId:l()}),x({type:p(`inference-device`),nodeId:l(),deviceKey:l()})]),MX=x({id:l(),kind:kX,severity:AX,subject:jX,what:l(),evidence:m(l(),n().nullable()),action:l()}),NX=x({source:l(),entries:n().nullable()}),PX=x({nodeId:l(),sessionsNow:n(),unusableDevices:C(l()).readonly(),devices:C(x({deviceKey:l(),sessionsNow:n(),usable:y()})).readonly()}),FX=x({deviceId:n(),nativeCropMissesSincePreviousTick:n().nullable()}),IX=x({generatedAt:n(),tickMs:n(),camerasSeen:n().nullable(),findings:C(MX).readonly(),cameraSignals:C(FX).readonly(),nodes:C(PX).readonly(),sources:C(NX).readonly(),notCovered:C(l()).readonly()}),LX=x({history:n().int().min(1).max(24).default(1)}),RX=x({latest:IX.nullable(),previous:C(IX).readonly()}),Kke=x({engine:bW.optional(),steps:C(Va).readonly(),audio:x({engine:bW.optional(),modelId:l().optional(),enabled:y(),settings:m(l(),w()).readonly().optional()}).nullable().optional()}),zX=x({modelId:l().optional(),settings:m(l(),w()).optional(),jumpDeviceKey:l().optional(),enabled:y().optional()}),BX=x({maxCameras:n().int().nonnegative().nullable().default(null),detectWeight:n().positive().optional(),detect:y().optional(),decode:y().optional(),audio:y().optional(),ingest:y().optional(),decodeBudgetMb:n().int().min(1024).max(65536).optional(),maxLiveDecodeWorkers:n().int().min(1).max(32).optional(),reachableHost:l().optional(),color:Rl.optional(),stepSettings:m(l(),m(l(),w()).readonly()).optional(),stepEnabled:m(l(),y()).optional(),inferenceDevices:m(l(),x({enabled:y(),weight:n().positive().optional(),maxSessions:n().int().positive().optional(),steps:m(l(),zX).optional()})).optional()}),qke=m(l(),m(l(),w()).readonly()),VX=S([`pipeline`,`onboard`,`none`]),Jke=x({stepToggles:m(l(),y()).optional(),stepSettings:qke.optional()}),HX=x({deviceId:n(),agentNodeId:l(),pinned:y(),reason:S([`manual`,`capacity`,`hardware-affinity`,`failover`,`rebalance`]),assignedAt:n()}),UX=x({nodeId:l(),online:y(),load:MG,score:n(),decodeHwaccel:l().nullable()}),WX=x({totalAgents:n(),onlineAgents:n(),totalCameras:n(),attachedCameras:n(),activeCameras:n(),avgInferenceTimeMs:n(),queueDepth:n()}),GX=m(l(),l()),KX=x({ownerNodeId:l(),reachableHost:l().optional(),configIssue:l().optional()}),qX=x({camStreamId:l(),codec:l(),width:n(),height:n(),fps:n(),kind:l()}),JX=x({streams:C(qX).readonly()}),YX=x({detectionNodeId:l().nullable(),decoderNodeId:l().nullable(),audioNodeId:l().nullable(),sourceNodeId:l().nullable(),pinned:x({detection:y(),decoder:y(),audio:y()}),reasons:x({detection:l().optional(),decoder:l().optional(),audio:l().optional()})}),XX=x({profile:l(),status:l(),codec:l(),width:n(),height:n(),subscribers:n(),inFps:n().nullable()}),ZX=x({profiles:C(XX).readonly(),webrtcSessions:n(),rtspRestream:y()}),QX=x({nodeId:l()}),$X=x({enabled:y(),fps:n()}),eZ=S([`idle`,`installing`,`verifying`,`ready`,`failed`]),tZ=x({state:eZ,error:l().optional()}),nZ=S([`idle`,`watching`,`active`]),rZ=x({nodeId:l(),engine:x({backend:l(),device:l()}),phase:nZ,configuredFps:n(),actualFps:n(),queueDepth:n(),avgInferenceMs:n(),provisioning:tZ}),iZ=x({nodeId:l(),enabled:y()}),aZ=um,oZ=x({mode:aZ,active:y(),storageBytes:n()}),sZ=S([`source`,`broker`,`detection`,`recording`,`switches`]),cZ=S([`timeout`,`error`,`partial`]),lZ=x({stage:sZ,reason:cZ,elapsedMs:n()}),uZ=x({state:S([`idle`,`running`,`done`,`error`]),total:n().int().nonnegative(),completed:n().int().nonnegative(),currentDeviceId:n().int().nullable(),failed:C(n().int()).readonly(),mediaDropped:n().int().nonnegative(),tracks:n().int().nonnegative(),events:n().int().nonnegative(),startedAtMs:n().int().nullable(),finishedAtMs:n().int().nullable(),error:l().nullable()}),dZ=x({deviceId:n(),assignment:YX,source:JX,broker:ZX.nullable(),decoder:QX.nullable(),motion:$X.nullable(),detection:rZ.nullable(),audio:iZ.nullable(),recording:oZ.nullable(),switchedOff:C($d).readonly(),cameraSensors:QV.optional(),degraded:C(lZ).readonly(),fetchedAt:n()}),fZ=[`disabled`,`unavailable`,`cannot-host-camera-root`,`accelerator-preferred`,`root-switched-off`,`no-gpu-device`],pZ=S(fZ),Yke=x({key:l(),backend:l(),device:l(),format:S(Na),available:y(),presence:S([`present`,`absent`,`unknown`]).optional(),enabled:y(),weight:n(),maxSessions:n().nullable(),defaultModelId:l(),steps:m(l(),zX).optional(),exclusion:pZ.nullable()}),mZ=i(`kind`,[x({kind:p(`stored`),modelId:l()}),x({kind:p(`absent`),defaultModelId:l()}),x({kind:p(`unreadable`),reason:S(dH),error:l().optional()})]),Xke=x({nodeId:l(),reachable:y(),devices:C(Yke).readonly(),defaultPoolExcluded:y().optional()}),hZ=S([`off`,`on`,`opt-in`]),gZ=i(`kind`,[x({kind:p(`on`)}),x({kind:p(`off-cluster`)}),x({kind:p(`off-node`)}),x({kind:p(`off-device`)}),x({kind:p(`jump`),toDeviceKey:l()}),x({kind:p(`skip`),reason:S([`no-compatible-model`,`root-not-runnable-on-elected-device`])}),x({kind:p(`zone-driven`)}),x({kind:p(`supplied-by-root`),rootModelId:l()}),x({kind:p(`opt-in-unused`)})]),Zke=x({deviceKey:l(),format:S(Na),stepEnabled:y().nullable(),eligible:y(),cell:gZ}),Qke=x({nodeId:l(),reachable:y(),stepEnabled:y().nullable(),devices:C(Zke).readonly()}),_Z=x({steps:C(x({stepId:l(),name:l(),slot:l(),clusterMode:hZ.nullable(),effectiveMode:hZ,camerasEnabling:n().int().nonnegative(),camerasDisabling:n().int().nonnegative(),nodes:C(Qke).readonly()})).readonly()}),vZ=x({deviceId:n().int().nonnegative(),config:GV.nullable()}),yZ=S([`unknown-camera`,`out-of-range`,`no-burst-producer`,`already-looked`]),bZ=x({deviceId:n().int().nonnegative(),afterMs:n().finite(),reason:l()}),xZ=x({scheduled:y(),dueInMs:n().optional(),refusedBecause:yZ.optional()}),SZ={name:`pipeline-orchestrator`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,exposesDeviceSettings:!0,methods:{requestOccupancyLook:A(bZ,xZ,{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:A(km,x({paused:p(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:A(km,x({resumed:p(!0)}),{kind:`mutation`,auth:`admin`}),assignPipeline:A(x({deviceId:n(),agentNodeId:l()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),unassignPipeline:A(x({deviceId:n()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setPipelineDevicePin:A(x({deviceId:n(),deviceKey:l()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getPipelineDevicePin:A(x({deviceId:n()}),x({deviceKey:l().nullable()})),rebalance:A(v(),x({migrated:n(),skipped:C(x({deviceId:n(),targetNodeId:l(),reason:l()})).default([])}),{kind:`mutation`,auth:`admin`}),getPipelineAssignments:A(v(),C(HX).readonly()),getPipelineAssignment:A(x({deviceId:n()}),HX.nullable()),getAgentLoad:A(v(),C(UX).readonly()),getClusterModelChoice:A(x({stepId:l()}),mZ),getGlobalMetrics:A(v(),WX),getCameraMetrics:A(x({deviceId:n()}),DW.nullable()),getCapabilityBindings:A(x({nodeId:l()}),GX),setCapabilityBinding:A(x({nodeId:l(),capName:l(),addonId:l()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getIngestOwner:A(v(),KX),assignAudio:A(x({deviceId:n(),nodeId:l()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),unassignAudio:A(x({deviceId:n()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getAudioAssignment:A(x({deviceId:n()}),x({nodeId:l(),pinned:y(),assignedAt:n()}).nullable()),getAudioNodeLoad:A(v(),C(x({nodeId:l(),deviceCount:n()}))),getAudioAssignments:A(v(),C(x({deviceId:n(),nodeId:l(),pinned:y(),assignedAt:n()}))),getAgentSettings:A(x({agentNodeId:l()}),BX.nullable()),listAgentSettings:A(v(),C(x({nodeId:l(),settings:BX})).readonly()),removeAgentSettings:A(x({agentNodeId:l()}),x({success:y(),removed:y()}),{kind:`mutation`,auth:`admin`}),setAgentMaxCameras:A(x({agentNodeId:l(),maxCameras:n().int().nonnegative().nullable()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setAgentCapabilities:A(x({agentNodeId:l(),detect:y().nullable().optional(),audio:y().nullable().optional(),ingest:y().nullable().optional()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setAgentDecodeLimits:A(x({agentNodeId:l(),decodeBudgetMb:n().int().min(1024).max(65536).nullable().optional(),maxLiveDecodeWorkers:n().int().min(1).max(32).nullable().optional()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setAgentReachableHost:A(x({agentNodeId:l(),reachableHost:l().nullable().optional(),color:Rl.nullable().optional()}).refine(e=>e.reachableHost!==void 0||e.color!==void 0,{message:`reachableHost or color required`}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setAgentInferenceDevices:A(x({agentNodeId:l(),inferenceDevices:m(l(),x({enabled:y(),weight:n().positive().optional(),maxSessions:n().int().positive().optional(),steps:m(l(),zX).optional()}))}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setNodeStepSettings:A(x({agentNodeId:l(),addonId:l(),settings:m(l(),w()).nullable()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setClusterStepMode:A(x({stepId:l(),mode:hZ.nullable()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setNodeStepEnabled:A(x({agentNodeId:l(),stepId:l(),enabled:y().nullable()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setDeviceStepEnabled:A(x({agentNodeId:l(),deviceKey:l(),stepId:l(),enabled:y().nullable()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getStepSwitches:A(v(),_Z),getNodeInferenceDevices:A(x({nodeId:l()}),Xke),forgetInferenceDevice:A(x({agentNodeId:l(),deviceKey:l()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),resetNodePipelineDefaults:A(x({agentNodeId:l()}),x({success:p(!0),effectiveModelId:l().nullable()}),{kind:`mutation`,auth:`admin`}),planAutoTune:A(nX,rX,{auth:`admin`}),applyAutoTune:A(iX,oX,{kind:`mutation`,auth:`admin`}),setLoadBalancingShares:A(lX,x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getPlacementStats:A(uX,mX,{auth:`admin`}),getHealthDigest:A(LX,RX,{auth:`admin`}),suggestShares:A(_X,bX,{auth:`admin`}),getEffectiveShares:A(v(),DX,{auth:`admin`}),setShareSource:A(wX,x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkPreflight:A(IW,VW,{auth:`admin`}),startNodeBenchmark:A(IW,i(`kind`,[x({kind:p(`started`),runId:l()}),x({kind:p(`refused`),preflight:VW})]),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkStatus:A(v(),nG,{auth:`admin`}),abortNodeBenchmark:A(x({runId:l()}),x({aborted:y()}),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkCandidates:A(x({nodeId:l()}),oG,{auth:`admin`}),listNodeBenchmarkResults:A(iG,C(aG).readonly(),{auth:`admin`}),deleteNodeBenchmarkResult:A(x({id:l()}),x({deleted:y()}),{kind:`mutation`,auth:`admin`}),getCameraSettings:A(x({deviceId:n()}),Jke.nullable()),setCameraStepToggle:A(x({deviceId:n(),addonId:l(),enabled:y().nullable()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getCameraDetectionSource:A(x({deviceId:n()}),x({source:VX,explicit:y(),onboard:x({available:y(),geometry:S([`boxed`,`while-streaming`,`flag-only`,`unknown`])})})),setCameraDetectionSource:A(x({deviceId:n(),source:VX}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setCameraStepSettings:A(x({deviceId:n(),addonId:l(),settings:m(l(),w()).nullable()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),resolvePipeline:A(x({deviceId:n(),agentNodeId:l().optional()}),Kke),getCameraSwitches:A(x({deviceId:n()}),of,{role:`viewer`}),setCameraSwitch:A(x({deviceId:n(),switchId:$d,enabled:y()}),of,{kind:`mutation`,auth:`admin`}),getCameraStatus:A(x({deviceId:n()}),dZ),getCameraStatuses:A(x({deviceIds:C(n()).optional()}),C(dZ).readonly()),setCameraSensors:A(vZ,x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),reconcileFromDisk:A(v(),uZ,{kind:`mutation`,auth:`admin`}),getReconcileFromDiskStatus:A(v(),uZ,{auth:`admin`})},vocabulary:{notOperatorFacing:M.PIPELINE}},CZ=x({id:l(),name:l(),sampleCount:n().int().nonnegative(),coverMediaId:n().int().optional(),coverBase64:l().optional()}),$ke=x({id:l(),text:l(),score:n(),addedAt:n().int(),deviceId:n().int().optional(),base64:l().optional(),mediaId:n().int().optional(),keyFrameMediaId:n().int().optional(),plateBbox:sC.optional()}),wZ=x({plateId:l(),deviceId:n().int(),trackId:l(),timestamp:n().int(),text:l(),score:n(),corrected:y(),recognizedVehicleId:l().optional(),vehicleName:l().optional(),assigned:y(),plateBbox:sC.optional(),keyFrameMediaId:n().int().optional(),base64:l().optional(),cropUrl:l().optional(),cropMissReason:l().optional()}),eAe=x({mediaId:n().int(),kind:l(),url:l(),sizeBytes:n(),timestamp:n()}),tAe=x({plateIds:C(l()).readonly(),representativePlateId:l(),representativeText:l(),size:n().int(),cohesion:n()}),TZ={name:`plate-gallery`,role:{feature:`plate-assignment`},scope:`system`,mode:`singleton`,methods:{listPlates:A(x({deviceId:n().int().optional(),limit:n().int().positive().optional(),includeCrops:y().optional()}).optional(),C(wZ).readonly()),getPlateByTrack:A(x({deviceId:n().int(),trackId:l()}),wZ.nullable(),{role:`viewer`}),getPlateMedia:A(x({plateId:l()}),C(eAe).readonly()),searchPlates:A(x({text:l().min(1),maxDistance:n().int().min(0).optional(),limit:n().int().positive().optional(),includeCrops:y().optional()}),C(wZ).readonly()),suggestPlateClusters:A(x({maxDistance:n().int().min(0).optional(),minClusterSize:n().int().min(2).optional(),limit:n().int().positive().optional()}).optional(),C(tAe).readonly()),correctPlateText:A(x({plateId:l(),text:l().min(1)}),v(),{kind:`mutation`,auth:`admin`}),deletePlate:A(x({plateId:l()}),v(),{kind:`mutation`,auth:`admin`}),listVehicles:A(x({includeCrops:y().optional()}).optional(),C(CZ).readonly()),createVehicle:A(x({name:l().min(1)}),CZ,{kind:`mutation`,auth:`admin`}),renameVehicle:A(x({id:l(),name:l().min(1)}),v(),{kind:`mutation`,auth:`admin`}),deleteVehicle:A(x({id:l()}),v(),{kind:`mutation`,auth:`admin`}),listVehicleSamples:A(x({vehicleId:l()}),C($ke).readonly()),removeVehicleSample:A(x({vehicleId:l(),sampleId:l()}),v(),{kind:`mutation`,auth:`admin`}),moveVehicleSample:A(x({sampleId:l().min(1),toVehicleId:l().min(1)}),v(),{kind:`mutation`,auth:`admin`}),assignPlate:A(x({plateId:l(),vehicleId:l()}),v(),{kind:`mutation`,auth:`admin`}),unassignPlate:A(x({plateId:l()}),v(),{kind:`mutation`,auth:`admin`}),assignPlates:A(x({plateIds:C(l()).min(1),vehicleId:l()}),x({assigned:n().int(),failed:C(l()).readonly()}),{kind:`mutation`,auth:`admin`}),unassignPlates:A(x({plateIds:C(l()).min(1)}),x({unassigned:n().int(),failed:C(l()).readonly()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`the plate gallery — curated on its own page`}},EZ={"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}}},"nvidia-gpu":{"nvidia-gpu":{"yolov9t-320":{p50Ms:12,fps:83,measured:!1},"yolov9t-640":{p50Ms:16,fps:62,measured:!1},"yolov9s-320":{p50Ms:13,fps:77,measured:!1},"yolov9s-640":{p50Ms:20,fps:50,measured:!1},"yolov9m-320":{p50Ms:16,fps:62,measured:!1},"yolov9m-640":{p50Ms:32,fps:31,measured:!1}}},"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}}}},DZ={"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}},OZ=.5,nAe=2,rAe=.05,iAe=24,aAe=750,oAe=64,kZ=2e3,sAe=12,AZ=n().nullable().transform(e=>e!==null&&Number.isFinite(e)&&e>0?e:null),jZ=l().nullable().transform(e=>e!==null&&e.trim()!==``?e:null),MZ=x({int8:AZ,fp16:AZ}),NZ=x({deviceKey:l(),fullDeviceName:jZ,executionUnits:AZ,clockMHz:AZ,gops:MZ.nullable(),architecture:jZ,npuName:jZ,tops:AZ,vendor:jZ,webgpuArchitecture:jZ,webgpuDevice:jZ,computeUnits:AZ}),cAe=x({accelerators:C(NZ).nullable()}),PZ=[{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*kZ}},{hardwareClass:`amd-phoenix`,accelerator:`amd-igpu`,score:{metric:`cu`,value:12}}];function lAe(e){let t=cAe.safeParse(e);return!t.success||t.data.accelerators===null?null:t.data.accelerators}function FZ(e){return e!==null&&e>0?e:null}function IZ(e){let t=[],n=FZ(e.gops?.int8??null);n!==null&&t.push({metric:`gops-int8`,value:n});let r=FZ(e.gops?.fp16??null);r!==null&&t.push({metric:`gops-fp16`,value:r});let i=FZ(e.executionUnits),a=FZ(e.clockMHz);i!==null&&a!==null&&t.push({metric:`eu-mhz`,value:i*a});let o=FZ(e.computeUnits);o!==null&&t.push({metric:`cu`,value:o});let s=FZ(e.tops);return s!==null&&t.push({metric:`tops`,value:s}),t}function LZ(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 RZ(e,t,n){for(let r of IZ(e))if(LZ(t,r,n)!==null)return r;return null}function zZ(e,t,n=PZ){return RZ(e,t,n)!==null}function BZ(e,t,n){if(t!==`unknown`)return e[t]?.[n]}function uAe(e){return Math.round(e*10)/10}function dAe(e){return Math.min(2,Math.max(OZ,e))}function fAe(e,t,n){let r={};for(let[i,a]of Object.entries(e))r[i]={p50Ms:uAe(a.p50Ms/t),fps:Math.max(1,Math.round(a.fps*t)),measured:!1,estimatedFrom:n};return r}function VZ(e){let t=e.perf??EZ,n=e.references??PZ;if(e.accelerator===`nvidia-gpu`){let e=BZ(t,`nvidia-gpu`,`nvidia-gpu`);return e===void 0?null:{column:e,estimatedFrom:null}}let r=BZ(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:RZ(e.report,e.accelerator,n);if(i===null)return r===void 0?null:{column:r,estimatedFrom:null};let a=LZ(e.accelerator,i,n),o=a===null?void 0:BZ(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:fAe(o,dAe(s),a.hardwareClass),estimatedFrom:a.hardwareClass}}var HZ=S(Na),pAe=S([`videotoolbox`,`cuda`,`nvdec`,`vaapi`,`qsv`,`d3d11va`,`dxva2`,`amf`,`vdpau`,`drm`,`coreml`,`tensorrt`,`openvino`,`directml`,`webgpu`,`none`]).nullable().optional(),mAe=x({preferred:C(l()).readonly(),rationale:l()}),UZ=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:UZ,codec:S([`H264`,`H265`]),family:S([`videotoolbox`,`vaapi`,`nvenc`,`qsv`,`amf`,`software`]),available:y(),reason:l().optional()})).readonly(),defaultH264:UZ,defaultH265:UZ,probedAt:n()}),x({methods:C(l()).readonly(),probedAt:n()});var hAe=S([`darwin`,`linux`,`win32`]),gAe=S([`arm64`,`x64`]),_Ae=x({type:S([`nvidia`,`amd`,`intel`,`apple`]),name:l(),memoryMB:n().optional()}),vAe=x({type:S([`apple-ane`,`intel-npu`,`amd-xdna`]),name:l().optional(),generation:S([`xdna1`,`xdna2`]).optional()}),WZ=S([`usb`,`pci`]),yAe=x({type:p(`coral-edgetpu`),bus:l().optional(),count:n().int().nonnegative().optional(),units:C(x({bus:WZ,count:n().int().nonnegative()})).readonly().optional(),unavailable:C(x({bus:WZ,count:n().int().nonnegative(),reason:S([`driver-missing`,`device-not-accessible`])})).readonly().optional()}),GZ=x({type:p(`nvidia`),name:l(),memoryMB:n().optional()}),bAe=i(`usable`,[GZ.extend({usable:p(!0)}),GZ.extend({usable:p(!1),reason:S([`no-cuda-execution-provider`])})]),KZ=x({platform:hAe,arch:gAe,cpuModel:l(),cpuCores:n(),totalRAM_MB:n(),availableRAM_MB:n(),gpu:_Ae.nullable(),npu:vAe.nullable(),coral:yAe.nullable().optional(),nvidia:bAe.nullable().optional(),accelerators:C(NZ).readonly().optional()}),qZ=x({runtime:p(`python`),backend:l(),format:S([`onnx`,`coreml`,`openvino`,`tflite`]),score:n(),reason:l(),available:y()}),JZ=x({key:l(),backend:l(),device:l(),format:HZ,runtime:p(`python`),score:n(),available:y()}),xAe=x({hardware:KZ,scores:C(qZ).readonly(),bestScore:qZ,pythonPath:l().nullable(),devices:C(JZ).readonly()}),SAe=x({modelId:l(),name:l(),minRAM_MB:n(),accuracyScore:n(),formats:C(l()).readonly()}),CAe=x({modelId:l(),runtime:p(`python`),backend:l(),format:HZ,reason:l()}),wAe=x({devices:C(JZ).readonly(),appeared:C(l()).readonly(),disappeared:C(l()).readonly(),usbBus:S([`observed`,`unobservable`]),decidedBy:S([`usb-ids`,`pci`,`delegate-fallback`,`none`])}),YZ={name:`platform-probe`,scope:`system`,mode:`singleton`,methods:{getCapabilities:A(v(),xAe),getHardware:A(v(),KZ),resolveInferenceConfig:A(x({requirements:C(SAe).readonly()}),CAe),resolveHwAccel:A(x({prefer:pAe}),mAe),rescanAccelerators:A(v(),wAe,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.CLUSTER}},XZ=x({power:n().optional().meta(N(`power`,{label:`Power`})),deliveredPower:n().optional().meta(N(`power`,{label:`Delivered`})),energy:n().optional().meta(N(`energy`,{label:`Energy`})),voltage:n().optional().meta(N(`voltage`,{label:`Voltage`})),current:n().optional().meta(N(`current`,{label:`Current`})),apparentPower:n().optional().meta(N(`apparent-power`)),powerFactor:n().min(0).max(1).optional().meta(N(`ratio`)),lastFetchedAt:n()});function TAe(e){if(e.power===void 0)return;let t=e.power-(e.deliveredPower??0);return t<0?void 0:t}var ZZ=[E.Sensor,E.Switch,E.Light,E.Fan,E.Climate,E.Humidifier,E.WaterHeater,E.MediaPlayer,E.Washer,E.Dryer,E.Dishwasher,E.Vacuum,E.LawnMower,E.PetFeeder,E.Workload],EAe=ZZ.filter(e=>e!==E.Sensor);function QZ(e,t){return{id:e,cardinality:`scalar`,vocabulary:{cap:`power-meter`,stateField:e},deviceTypes:EAe,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 DAe={version:1,targets:[QZ(`power`,`W`),QZ(`energy`,`kWh`),QZ(`voltage`,`V`),QZ(`current`,`A`)]},$Z={name:`power-meter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:ZZ,deviceConfig:{ui:{kind:`widget`,widgetId:`host/power-meter-line`,tab:`power`,placement:`hero`,label:`Power`,order:4}},methods:{},status:{schema:XZ,kind:`push`},runtimeState:XZ,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:DAe,vocabulary:{noun:F(`Power meter`,`Misuratore di energia`),order:5160,state:[{kind:`numeric`,field:`power`,quantity:F(`the power draw`,`il consumo`),label:F(`Power`,`Potenza`),unit:`W`,icon:`zap`},{kind:`numeric`,field:`energy`,quantity:F(`the energy used`,`l’energia consumata`),label:F(`Energy`,`Energia`),unit:`kWh`,icon:`zap`},{kind:`numeric`,field:`voltage`,quantity:F(`the voltage`,`la tensione`),label:F(`Voltage`,`Tensione`),unit:`V`,icon:`zap`},{kind:`numeric`,field:`current`,quantity:F(`the current`,`la corrente`),label:F(`Current`,`Corrente`),unit:`A`,icon:`zap`}]}},OAe=x({latitude:n().min(-90).max(90).meta(N(`angle`)),longitude:n().min(-180).max(180).meta(N(`angle`)),accuracyMeters:n().nonnegative().meta(N(`length`))}),eQ=x({state:l(),location:l().nullable(),gps:OAe.nullable(),lastChangedAt:n()}),tQ={name:`presence`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Presence],methods:{},status:{schema:eQ,kind:`push`},runtimeState:eQ,durability:`restored`,history:`none`,volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Presence`,`Presenza`),order:5170,state:[{kind:`value`,field:`state`,label:F(`Where`,`Posizione`),phrase:F(`When {device} is at {value}`,`Quando {device} è in {value}`),icon:`map-pin`}]}},nQ=x({pressure:n().nullable().meta(N(`pressure`,{precision:0})),lastFetchedAt:n()}),rQ={name:`pressure-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:nQ,kind:`push`},runtimeState:nQ,durability:`restored`,history:{fields:{pressure:{kind:`gauge`,unit:`hPa`,deadband:.1}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Pressure`,`Pressione`),order:5180,state:[{kind:`numeric`,field:`pressure`,quantity:F(`the pressure`,`la pressione`),label:F(`Pressure`,`Pressione`),unit:`hPa`,icon:`gauge`}]}},iQ=i(`kind`,[iH,aH]),aQ=x({id:n(),enabled:y(),shape:iQ}),oQ=x({enabled:y(),regions:C(aQ).nullable(),audioEnabled:y().nullable(),lastFetchedAt:n()}),sQ=x({maxRegions:n(),supportedShapes:C(cH),polygonVertices:lH.optional(),supportsAudioMute:y()}),cQ=x({enabled:y().optional(),regions:C(aQ).optional()}),lQ={name:`privacy-mask`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/privacy-mask-grid`,tab:`image`,label:`Privacy Mask`}},methods:{getOptions:A(x({deviceId:n()}),sQ),setMask:A(x({deviceId:n(),patch:cQ}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`privacy.maskOn`,label:F(`Privacy mask on`,`Maschera privacy attiva`),phrase:F(`Cover the privacy zones of {device}`,`Oscura le zone private di {device}`),icon:`eye-off`,args:{patch:{enabled:!0}}},{id:`privacy.maskOff`,label:F(`Privacy mask off`,`Maschera privacy spenta`),phrase:F(`Uncover the privacy zones of {device}`,`Scopri le zone private di {device}`),icon:`eye`,args:{patch:{enabled:!1}}}]}),setAudioEnabled:A(x({deviceId:n(),enabled:y()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`privacy.micOn`,label:F(`Microphone on`,`Microfono attivo`),phrase:F(`Turn on the microphone of {device}`,`Attiva il microfono di {device}`),icon:`mic`,args:{enabled:!0}},{id:`privacy.micOff`,label:F(`Microphone off`,`Microfono spento`),phrase:F(`Turn off the microphone of {device}`,`Disattiva il microfono di {device}`),icon:`mic-off`,args:{enabled:!1}}]})},status:{schema:oQ,kind:`poll`},runtimeState:oQ,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Privacy`,`Privacy`),order:3210,state:[{kind:`boolean`,field:`enabled`,label:F(`Privacy mask`,`Maschera privacy`),whenTrue:F(`When the privacy mask of {device} is turned on`,`Quando si attiva la maschera privacy di {device}`),whenFalse:F(`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:F(`Microphone`,`Microfono`),whenTrue:F(`When the microphone of {device} is turned on`,`Quando si attiva il microfono di {device}`),whenFalse:F(`When the microphone of {device} is turned off`,`Quando si disattiva il microfono di {device}`),icon:`mic`}]}};function kAe(e){return e.length===0?null:e.some(e=>e.audioEnabled)}var uQ=S([`home`,`day-mode`,`night-mode`,`day-night-auto`,`set-limits`,`save-limits`,`reboot`,`osd-menu`]),dQ=x({id:l(),name:l(),fn:uQ.nullable(),writable:y()}),fQ=x({pan:n().nullable(),tilt:n().nullable(),zoom:n().nullable()}),pQ=x({pan:n().optional(),tilt:n().optional(),zoom:n().optional(),speed:n().optional()}),mQ=fQ.extend({autofocus:y()}),hQ=x({hasPan:y(),hasTilt:y(),hasZoom:y(),supportsPresets:y(),maxPresets:n().optional(),hasAutofocus:y(),speedSteps:n().int().positive().nullable(),moveImpulseMs:n().int().positive().nullable()}),gQ=x({presetId:l().nullable(),source:S([`operator`,`firmware`,`native`,`none`])}),_Q=x({enabled:y(),seconds:n().int()}),vQ={name:`ptz`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/ptz-panel`,tab:`ptz`,topTab:!0,label:`PTZ`,order:0}},methods:{move:A(pQ.extend({deviceId:n()}),v(),{kind:`mutation`,notOperatorFacing:`a relative nudge from the live-view joystick; a fixed place is a preset`}),continuousMove:A(pQ.extend({deviceId:n()}),v(),{kind:`mutation`,notOperatorFacing:`joystick motion held until released — continuous, not a discrete step`}),goHome:A(x({deviceId:n()}),v(),{kind:`mutation`,actions:[{id:`ptz.goHome`,label:F(`PTZ go home`,`Torna alla posizione iniziale`),phrase:F(`Send {device} to its home position`,`Riporta {device} alla posizione iniziale`),icon:`house`}]}),getPresets:A(x({deviceId:n()}),C(dQ)),goToPreset:A(x({deviceId:n(),presetId:l()}),v(),{kind:`mutation`,actions:[{id:`ptz.goToPreset`,label:F(`PTZ go to preset`,`Vai a un preset`),phrase:F(`Move {device} to {presetId}`,`Sposta {device} su {presetId}`),icon:`move`,openArgs:[{key:`presetId`,label:F(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}}]}]}),savePreset:A(x({deviceId:n(),presetId:l(),name:l()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.savePreset`,label:F(`Save PTZ preset here`,`Salva qui un preset`),phrase:F(`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:F(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}},{key:`name`,label:F(`Name`,`Nome`),offer:{kind:`text`}}]}]}),deletePreset:A(x({deviceId:n(),presetId:l()}),v(),{kind:`mutation`,auth:`admin`}),getOptions:A(x({deviceId:n()}),hQ),stop:A(x({deviceId:n()}),v(),{kind:`mutation`,actions:[{id:`ptz.stop`,label:F(`Stop moving`,`Ferma il movimento`),phrase:F(`Stop {device} moving`,`Ferma il movimento di {device}`),icon:`square`}]}),getHomePreset:A(x({deviceId:n()}),gQ),setHomePreset:A(x({deviceId:n(),presetId:l().nullable()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.setHomePreset`,label:F(`Set PTZ home preset`,`Imposta il preset iniziale`),phrase:F(`Make {presetId} the home position of {device}`,`Rendi {presetId} la posizione iniziale di {device}`),icon:`house`,openArgs:[{key:`presetId`,label:F(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}}]}]}),captureHomeHere:A(x({deviceId:n()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.captureHomeHere`,label:F(`Set PTZ home here`,`Imposta qui la posizione iniziale`),phrase:F(`Make where {device} points now its home position`,`Rendi la posizione attuale di {device} la sua posizione iniziale`),icon:`map-pin`}]}),getHomeReturn:A(x({deviceId:n()}),_Q.nullable()),setHomeReturn:A(x({deviceId:n(),enabled:y(),seconds:n().int().min(0).max(3600)}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.setHomeReturn`,label:F(`Set PTZ return home`,`Imposta il ritorno alla posizione iniziale`),phrase:F(`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:F(`Return home`,`Torna alla posizione iniziale`),offer:{kind:`boolean`}},{key:`seconds`,label:F(`Idle seconds`,`Secondi da fermo`),offer:{kind:`number`,min:0,max:3600,step:1,unit:`s`}}]}]}),getPosition:A(x({deviceId:n()}),fQ),setAutofocus:A(x({deviceId:n(),enabled:y()}),v(),{kind:`mutation`,actions:[{id:`ptz.autofocusOn`,label:F(`Autofocus on`,`Autofocus attivo`),phrase:F(`Turn on autofocus on {device}`,`Attiva l’autofocus su {device}`),icon:`focus`,args:{enabled:!0}},{id:`ptz.autofocusOff`,label:F(`Autofocus off`,`Autofocus spento`),phrase:F(`Turn off autofocus on {device}`,`Disattiva l’autofocus su {device}`),icon:`focus`,args:{enabled:!1}}]})},status:{schema:mQ,kind:`command-driven`},vocabulary:{noun:F(`Pan / tilt / zoom`,`Brandeggio`),order:3220}},yQ=x({targetType:l().describe(`Vendor target string (people/vehicle/pet); empty = camera default`),stopDelaySeconds:n().int().min(0).max(300).meta(N(`duration`)),disappearDelaySeconds:n().int().min(0).max(300).meta(N(`duration`))}),bQ=x({value:l(),label:l()}),xQ=x({enabled:y(),lastChangedAt:n(),currentSettings:yQ.nullable(),supportedTargetTypes:C(bQ)}),SQ=xQ.extend({lastFetchedAt:n()}),CQ={name:`ptz-autotrack`,scope:`device`,deviceNative:!0,mode:`singleton`,kind:`wrapper`,defaultActive:!1,deviceTypes:[E.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/ptz-autotrack`,tab:`ptz`,topTab:!0,label:`Auto-Tracking`,order:5}},methods:{getStatus:A(x({deviceId:n()}),xQ),setEnabled:A(x({deviceId:n(),enabled:y()}),v(),{kind:`mutation`,actions:[{id:`ptz.autotrackOn`,label:F(`Autotrack on`,`Inseguimento attivo`),phrase:F(`Start autotracking on {device}`,`Attiva l’inseguimento automatico su {device}`),icon:`crosshair`,args:{enabled:!0}},{id:`ptz.autotrackOff`,label:F(`Autotrack off`,`Inseguimento spento`),phrase:F(`Stop autotracking on {device}`,`Disattiva l’inseguimento automatico su {device}`),icon:`crosshair`,args:{enabled:!1}}]}),getSettings:A(x({deviceId:n()}),yQ.nullable()),setSettings:A(x({deviceId:n(),settings:yQ.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:n(),status:xQ}),notOperatorFacing:"the `enabled` state trigger phrases both edges of this change"}},status:{schema:xQ,kind:`command-driven`},runtimeState:SQ,durability:`session`,history:`none`,vocabulary:{noun:F(`Autotracking`,`Inseguimento automatico`),order:3230,state:[{kind:`boolean`,field:`enabled`,label:F(`Autotracking`,`Inseguimento automatico`),whenTrue:F(`When autotracking is turned on for {device}`,`Quando si attiva l’inseguimento automatico di {device}`),whenFalse:F(`When autotracking is turned off for {device}`,`Quando si disattiva l’inseguimento automatico di {device}`),icon:`crosshair`}]}},wQ=x({enabled:y().nullable(),onTime:n().min(0).nullable().meta(N(`duration`)),offTime:n().min(0).nullable().meta(N(`duration`)),lastFetchedAt:n()}),TQ=n().int().nonnegative(),EQ=n().int().min(0),DQ={name:`pump-cycle`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.PetFountain],methods:{setEnabled:A(x({deviceId:TQ,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.on`,effect:{field:`enabled`,value:!0},label:F(`Pump cycle on`,`Ciclo pompa attivo`),phrase:F(`Run the pump of {device} on its on/off cycle`,`Fai lavorare la pompa di {device} a ciclo acceso/spento`),icon:`timer`,args:{on:!0}},{id:`pumpCycle.off`,effect:{field:`enabled`,value:!1},label:F(`Pump cycle off`,`Ciclo pompa spento`),phrase:F(`Run the pump of {device} continuously`,`Fai lavorare la pompa di {device} in continuo`),icon:`timer-off`,args:{on:!1}}]}),setOnMinutes:A(x({deviceId:TQ,minutes:EQ}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.onMinutes`,label:F(`Set pump run time`,`Imposta il tempo di lavoro della pompa`),phrase:F(`Set the pump of {device} to run {minutes} minutes per cycle`,`Imposta la pompa di {device} a lavorare {minutes} minuti per ciclo`),icon:`timer`,effect:{field:`onTime`,fromArg:`minutes`,scale:60},openArgs:[{key:`minutes`,label:F(`Minutes`,`Minuti`),offer:{kind:`number`,min:0,step:1,unit:`min`}}]}]}),setOffMinutes:A(x({deviceId:TQ,minutes:EQ}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.offMinutes`,label:F(`Set pump rest time`,`Imposta il tempo di riposo della pompa`),phrase:F(`Set the pump of {device} to rest {minutes} minutes per cycle`,`Imposta la pompa di {device} a riposare {minutes} minuti per ciclo`),icon:`timer-off`,effect:{field:`offTime`,fromArg:`minutes`,scale:60},openArgs:[{key:`minutes`,label:F(`Minutes`,`Minuti`),offer:{kind:`number`,min:0,step:1,unit:`min`}}]}]})},status:{schema:wQ,kind:`push`},runtimeState:wQ,durability:`session`,history:`none`,vocabulary:{noun:F(`Pump cycle`,`Ciclo della pompa`),order:2050,state:[{kind:`boolean`,field:`enabled`,label:F(`Pump cycle`,`Ciclo pompa`),whenTrue:F(`When {device} starts running its pump on a cycle`,`Quando {device} inizia a far lavorare la pompa a ciclo`),whenFalse:F(`When {device} runs its pump continuously`,`Quando {device} fa lavorare la pompa in continuo`),icon:`timer`}]}},OQ={name:`reboot`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera,E.Sensor,E.Switch,E.Gateway],methods:{reboot:A(x({deviceId:n().int().nonnegative()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`,actions:[{id:`reboot.reboot`,label:F(`Reboot device`,`Riavvia il dispositivo`),phrase:F(`Reboot {device}`,`Riavvia {device}`),icon:`refresh-cw`}]})},vocabulary:{noun:F(`Reboot`,`Riavvio`),order:3240}},kQ=x({owner:l(),kind:pi,title:l(),nameField:l(),fields:m(l(),w()),secretPaths:C(l()),rows:n().int().nonnegative()}),AQ=x({id:uV,name:l(),rev:n().int(),updatedAt:n(),data:dV}),jQ={owner:l().min(1),kind:pi},MQ={name:`record-entries`,scope:`system`,mode:`singleton`,methods:{listEntryKinds:A(x({}),x({kinds:C(kQ)}),{auth:`admin`}),listEntries:A(x({...jQ}),x({entries:C(AQ)}),{auth:`admin`}),putEntry:A(x({...jQ,id:uV.optional(),data:dV,ifRev:n().int().min(1).optional()}),x({id:l(),rev:n().int()}),{kind:`mutation`,auth:`admin`}),deleteEntry:A(x({...jQ,id:uV}),x({deleted:y()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.INTERNAL}},AAe=`camstack`,jAe=`recorder`,NQ=x({profile:l(),startMs:n(),endMs:n()}),PQ=S([`read`,`unreadable`]),FQ=x({deviceId:n(),read:PQ,ranges:C(NQ),profilesWithFootage:C(l())}),IQ=x({deviceId:n(),read:PQ,days:C(n())}),LQ=x({deviceId:n(),localMasterPath:l().nullable(),playbackUrl:l().nullable(),playbackEndpoints:C(l())}),RQ=x({state:S([`ok`,`sleeping`,`unreachable`,`no-storage`,`index-empty`]),reason:l().optional(),coverageAsOf:n().optional()}),zQ=x({source:l(),label:l(),addonId:l().optional(),availability:RQ}),BQ=x({transport:S([`archive`,`stream`,`realtime`]),coverage:S([`continuous`,`sparse`]),seek:S([`free`,`forward`,`segment`]),stepBack:y(),scrub:y(),rates:C(n().positive()).min(1).readonly(),exclusive:y()}),VQ=i(`kind`,[x({kind:p(`hls`),manifest:LQ}),x({kind:p(`clip`),source:l(),clipId:l(),startsAtMs:n()}),x({kind:p(`none`),reason:l()})]),HQ={name:`recording`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:[E.Camera],methods:{listSources:A(x({deviceId:n()}),C(zQ).readonly(),{kind:`query`,auth:`protected`}),getAvailability:A(x({deviceId:n(),provider:l().min(1),fromMs:n(),toMs:n(),profile:l().optional()}),FQ,{kind:`query`,auth:`protected`}),getDaysWithRecordings:A(x({deviceId:n(),provider:l().min(1),fromMs:n(),toMs:n(),tzOffsetMinutes:n()}),IQ,{kind:`query`,auth:`protected`}),getPlayback:A(x({deviceId:n(),provider:l().min(1),fromMs:n(),toMs:n(),profile:P.optional()}),VQ,{kind:`query`,auth:`protected`}),getPlaybackOptions:A(x({deviceId:n(),provider:l().min(1)}),BQ,{kind:`query`,auth:`protected`})},vocabulary:{noun:F(`Recording`,`Registrazione`),order:3250}},UQ=x({deviceId:n(),enabled:y(),activeMode:um,nodeId:l(),storageBytes:n()}),MAe=200,WQ=x({deviceId:n(),read:S([`read`,`unreadable`]),ranges:C(NQ).readonly(),profilesWithFootage:C(l()).readonly()}),GQ=x({deviceId:n(),read:S([`read`,`unreadable`]),days:C(n()).readonly()}),KQ=x({deviceId:n(),usedBytes:n(),oldestMs:n().nullable().optional(),segments:n().optional(),residentBytes:n().optional(),residentOldestMs:n().nullable().optional()}),qQ=x({locationId:l().nullable(),locationIds:C(l()).optional(),root:l().optional(),usedBytes:n(),availableBytes:n().nullable(),totalBytes:n().nullable()}),JQ=x({nodeId:l(),totalUsedBytes:n(),devices:C(KQ),devicesRead:S([`archive`,`unavailable`]).optional(),complete:y().optional(),locations:C(qQ).optional()}),YQ=x({deviceId:n(),profile:l(),fromLocationId:l(),toLocationId:l(),bytes:n(),files:n().int()}),XQ=S([`unassigned`,`target-not-writable`,`below-threshold`,`no-headroom`]),ZQ=x({deviceId:n(),profile:l(),fromLocationId:l(),toLocationId:l().nullable(),bytes:n(),reason:XQ}),QQ=x({moves:C(YQ),skipped:C(ZQ),bytesToMove:n(),jobIds:C(l())}),$Q=x({throttleMbps:n().min(1).max(1e3).optional(),minMoveGb:n().min(0).optional()}),NAe=x({deviceId:n().int(),profile:l(),locationId:l()}),PAe=x({deviceId:n().int(),locationId:l()}),FAe=x({assignments:C(NAe),pins:C(PAe),defaultLocations:m(l(),l())}),IAe=x({deviceId:n().int(),locationId:l().nullable()}),e$=i(`kind`,[x({kind:p(`segment`),startMs:n(),durMs:n(),bytes:n()}),x({kind:p(`gap`),nearestEdgeMs:n().nullable(),prevEndMs:n().nullable().optional()})]),t$=x({data:b(Uint8Array)}),n$=x({data:b(Uint8Array),gopStartMs:n(),gopDurMs:n()}),r$=i(`kind`,[x({kind:p(`ok`),data:b(Uint8Array),gopStartMs:n(),gopDurMs:n(),reachesRequestedEnd:y()}),x({kind:p(`spans-multiple-segments`),segmentEndMs:n()})]),i$={name:`recording-archive`,scope:`system`,mode:`singleton`,exposesDeviceSettings:!0,status:{schema:UQ,kind:`command-driven`},methods:{getAvailabilityBatch:A(x({deviceIds:C(n()).min(1).max(200),fromMs:n(),toMs:n()}),C(WQ).readonly(),{role:`viewer`,kind:`query`,auth:`protected`}),getDaysWithRecordingsBatch:A(x({deviceIds:C(n()).min(1).max(200),fromMs:n(),toMs:n(),tzOffsetMinutes:n()}),C(GQ).readonly(),{role:`viewer`,kind:`query`,auth:`protected`}),getStorageUsage:A(x({}),JQ,{kind:`query`,auth:`admin`}),getDeviceConfig:A(x({deviceId:n()}),xm,{role:`viewer`,kind:`query`,auth:`protected`}),locateSegment:A(x({deviceId:n(),profile:l(),epochMs:n()}),e$,{kind:`query`,auth:`admin`}),readSegmentBytes:A(x({deviceId:n(),profile:l(),startMs:n()}),t$,{kind:`query`,auth:`admin`}),readGopBytes:A(x({deviceId:n(),profile:l(),startMs:n(),epochMs:n()}),n$,{kind:`query`,auth:`admin`}),readWindowBytes:A(x({deviceId:n(),profile:l(),startMs:n(),fromMs:n(),toMs:n()}),r$,{kind:`query`,auth:`admin`}),setDeviceConfig:A(x({deviceId:n(),config:xm}),xm,{kind:`mutation`,auth:`admin`}),rescanStorage:A(x({deviceId:n()}),UQ,{kind:`mutation`,auth:`admin`}),pruneFootage:A(x({deviceId:n(),reason:em.optional()}),x({floorMs:n().nullable(),deletedBuckets:n().int(),reclaimedBytes:n().int()}),{kind:`mutation`,auth:`admin`}),deleteFootprint:A(x({deviceId:n(),fromMs:n().optional(),toMs:n().optional()}),x({deletedBuckets:n().int(),reclaimedBytes:n().int()}),{kind:`mutation`,auth:`admin`}),listOpsLog:A(nm,C(tm).readonly(),{kind:`query`,auth:`admin`}),renderGif:A(x({deviceId:n(),aroundMs:n(),preRollSec:n().min(0).max(30).default(2),postRollSec:n().min(0).max(30).default(5),maxWidth:n().int().min(120).max(1280).default(480),fps:n().int().min(1).max(15).default(5)}),x({gifBase64:l(),fromMs:n(),toMs:n()}),{kind:`mutation`,auth:`admin`}),renderClip:A(x({deviceId:n(),aroundMs:n(),preRollSec:n().min(0).max(30).default(3),postRollSec:n().min(0).max(30).default(7),maxWidth:n().int().min(160).max(1920).default(640)}),x({clipBase64:l(),mime:l(),fromMs:n(),toMs:n(),bytes:n().int()}),{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:A(km,x({paused:p(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:A(km,x({resumed:p(!0)}),{kind:`mutation`,auth:`admin`}),refreshStorageLocationsForMigration:A(km,x({refreshed:p(!0)}),{kind:`mutation`,auth:`admin`}),startStorageMigrationMove:A(Am,x({jobId:l()}),{kind:`mutation`,auth:`admin`}),getStorageMigrationMoveStatus:A(x({jobId:l()}),Em.nullable(),{auth:`admin`}),cancelStorageMigrationMove:A(x({jobId:l()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),relocateFootage:A(Om,x({jobId:l()}),{kind:`mutation`,auth:`admin`}),listRelocateJobs:A(x({}),C(Em).readonly(),{kind:`query`,auth:`admin`}),getRelocateResidue:A(nh,rh,{kind:`query`,auth:`admin`}),reconcileLedgerAgainstDisk:A(ih,ch,{kind:`mutation`,auth:`admin`}),cancelRelocateJob:A(x({jobId:l()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),planStorageRebalance:A($Q,QQ,{kind:`query`,auth:`admin`}),startStorageRebalance:A($Q,QQ,{kind:`mutation`,auth:`admin`}),getPlacement:A(x({}),FAe,{kind:`query`,auth:`admin`}),setDevicePlacement:A(IAe,x({ok:p(!0)}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.STORAGE}},LAe=24,RAe=3,zAe=S([`queue-full`,`camera-backoff`,`sleeping`,`camera-refused`,`no-keyframe`,`decode-failed`,`no-catalog-row`,`unsupported`,`unknown-device`,`uid-missing`]),BAe=S([`deferred`,`final`]),VAe=`x-camstack-reason`,HAe=500;function UAe(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 WAe=`x-camstack-reason-code`,GAe=`x-camstack-disposition`,KAe=`x-camstack-clip-transport`,a$=x({id:l(),source:l(),kind:S([`motion`,`object`,`audio`,`native`]),timeRange:x({startMs:n(),endMs:n()}),labels:C(l()).max(3).optional(),thumbnail:l().optional(),stillAtMs:n().optional(),eventIds:C(l()).optional(),eventCount:n().int().nonnegative().optional(),holes:C(x({startMs:n(),endMs:n()})).optional(),thumbnailMint:l().optional(),thumbnailUnavailable:x({reason:S([`sleeping`,`camera-refused`,`no-keyframe`,`unsupported`])}).optional(),catalogAsOf:n().optional(),nativeTypes:C(l()).optional(),behaviours:C(l()).optional(),streams:x({sub:x({id:l(),bytes:n().optional()}).optional(),main:x({id:l(),bytes:n().optional()}).optional()}).optional(),supportSub:y().optional(),playable:y().optional(),unplayableReason:l().optional(),inProgress:y().optional()}),o$=x({playbackUrl:l(),format:S([`hls`,`mp4`]).optional(),served:P.optional(),playbackEndpoints:C(l()).optional(),token:l().optional()}),s$=S([`authorised`]),qAe=50*1024*1024,JAe=500*1024*1024,c$=x({base64:l(),contentType:l(),name:l(),bytes:n().int().nonnegative(),served:P,durationMs:n().positive().optional()}),l$=x({ticket:Si,contentType:l(),name:l(),served:P,durationMs:n().positive().optional()}),u$=S([`opus`,`pcmu`,`none`]),d$=S([`not-requested`,`unsupported-ask`]),f$=x({url:l().min(1),expiresAtMs:n(),transport:p(`forward-only`),served:P,servedAudio:u$,audioReason:d$.optional()}),p$=[.25,.5,1,1.5,2,4,8],m$=[.25,.5,1,1.5,2,4],h$=[.25,.5,1],g$=x({transport:S([`stream`,`file`]),seek:S([`forward`,`free`]),stepBack:y(),scrub:y(),rates:C(n().positive()).min(1).readonly()}),_$=x({state:S([`ok`,`sleeping`,`unreachable`,`no-storage`,`index-empty`]),reason:l().optional(),catalogAsOf:n().optional()}),v$=x({source:l(),label:l(),addonId:l().optional(),availability:_$}),y$={name:`videoclips`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:[E.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/clips-browser`,tab:`recording`,topTab:!0,label:`Clips`,order:100}},methods:{listClips:A(x({deviceId:n(),since:n(),until:n(),limit:n().int().positive().optional(),provider:l().min(1)}),C(a$).readonly(),{kind:`query`,auth:`protected`}),listSources:A(x({deviceId:n()}),C(v$).readonly(),{kind:`query`,auth:`protected`}),getClipPlayback:A(x({deviceId:n(),clipId:l(),profile:P.optional()}),o$,{kind:`query`,auth:`protected`}),readClipBytes:j(x({deviceId:n(),clipId:l().min(1),provider:l().min(1),profile:P.optional(),maxBytes:n().int().positive().optional(),wake:s$.optional()}),c$,{kind:`query`,auth:`protected`}),offerClipBytes:j(x({deviceId:n(),clipId:l().min(1),provider:l().min(1),profile:P.optional(),maxBytes:n().int().positive().optional(),wake:s$.optional()}),l$,{kind:`query`,auth:`protected`}),dialClipStream:j(x({deviceId:n(),clipId:l().min(1),provider:l().min(1),profile:P.optional(),audio:u$.optional(),wake:s$.optional()}),f$,{kind:`query`,auth:`protected`}),getPlaybackOptions:j(x({deviceId:n(),provider:l().min(1)}),g$,{kind:`query`,auth:`protected`})},vocabulary:{noun:F(`Video clips`,`Clip video`),order:3330}},YAe={stream:{transport:`stream`,seek:`forward`,stepBack:!1,scrub:!1,rates:m$},realtimeStream:{transport:`stream`,seek:`forward`,stepBack:!1,scrub:!1,rates:h$},file:{transport:`file`,seek:`free`,stepBack:!0,scrub:!0,rates:p$}},b$=n().min(.25).max(32),x$=x({fromSec:n().nonnegative(),toSec:n().nonnegative()}).refine(e=>e.toSec>e.fromSec,{message:`dense range must have toSec > fromSec`}),XAe=200,S$=x({everyMs:n().int().positive(),ranges:C(x$).min(1).max(200)}),C$=x({everyMs:n().int().positive(),outputFps:n().int().min(1).max(60).optional(),dense:S$.optional()}).superRefine((e,t)=>{e.dense!==void 0&&e.dense.everyMs>=e.everyMs&&t.addIssue({code:le.custom,message:`dense.everyMs must be strictly smaller than the base everyMs`,path:[`dense`,`everyMs`]})}),w$=x({speed:b$.optional(),timelapse:C$.optional(),includeAudio:y(),maxLifeMs:n().int().positive(),deleteAfterDownload:y(),title:l().max(200).optional(),notifyTargetIds:C(l().min(1)).max(20).optional()}).superRefine((e,t)=>{e.speed!==void 0&&e.timelapse!==void 0&&t.addIssue({code:le.custom,message:`speed and timelapse are mutually exclusive`,path:[`timelapse`]})}),T$=S([`queued`,`rendering`,`ready`,`failed`,`expired`,`deleted`]),E$=x({kind:p(`footage`),deviceId:n(),profiles:C(l()).min(1),fromMs:n(),toMs:n()}),D$=x({kind:p(`clip`),deviceId:n(),provider:l().min(1),source:l().min(1),sourceLabel:l().min(1),clipId:l().min(1),catalogWindow:x({sinceMs:n(),untilMs:n()}),profile:S([`high`,`mid`,`low`]),wake:s$.optional()}),O$=i(`kind`,[E$,D$]),k$=x({id:l(),deviceId:n(),profile:l(),fromMs:n(),toMs:n(),subject:O$.optional(),options:w$,state:T$,progressPct:n().nullable(),fileBytes:n().nullable(),expiresAt:n(),deleteAfterDownload:y(),downloadedAt:n().nullable(),createdAt:n(),createdBy:l(),error:l().nullable()}),A$=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`,`wake-timeout`]);function ZAe(e,t){return t.length>0?`${e}: ${t}`:e}function QAe(e){if(e===null)return null;let t=e.split(`:`,1)[0]??``,n=A$.safeParse(t.trim());return n.success?n.data:null}var j$=x({url:l(),endpoints:C(l())}),$Ae=50*1024*1024,M$=x({base64:l(),contentType:l(),name:l(),bytes:n().int().nonnegative()});function N$(e){return e.profiles!==void 0&&e.profiles.length>0?[...e.profiles]:typeof e.profile==`string`&&e.profile.length>0?[e.profile]:[]}var eje=x({deviceId:n(),profile:l().optional(),profiles:C(l()).min(1).optional(),fromMs:n().optional(),toMs:n().optional(),subject:O$.optional(),options:w$}).superRefine((e,t)=>{if(e.subject?.kind===`clip`){e.subject.deviceId!==e.deviceId&&t.addIssue({code:le.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:le.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:le.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:le.custom,message:`a footage export needs fromMs and toMs`,path:[`fromMs`]}),(e.subject?.kind===`footage`?[...e.subject.profiles]:N$(e)).length<1&&t.addIssue({code:le.custom,message:`pass profiles[] (min 1) or legacy profile`,path:[`profiles`]})});function tje(e){if(e.subject!==void 0)return e.subject;let t=N$(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 nje(e){return e.subject===void 0?{kind:`footage`,deviceId:e.deviceId,profiles:[e.profile],fromMs:e.fromMs,toMs:e.toMs}:e.subject}var P$={name:`recording-export`,scope:`system`,mode:`singleton`,methods:{createExport:A(eje,k$,{role:`viewer`,kind:`mutation`,auth:`protected`}),listExports:A(x({deviceId:n().optional()}),C(k$),{role:`viewer`,kind:`query`,auth:`protected`}),getExport:A(x({exportId:l()}),k$,{role:`viewer`,kind:`query`,auth:`protected`}),cancelExport:A(x({exportId:l()}),k$,{role:`viewer`,kind:`mutation`,auth:`protected`}),deleteExport:A(x({exportId:l()}),k$,{role:`viewer`,kind:`mutation`,auth:`protected`}),getDownloadUrl:A(x({exportId:l()}),j$,{role:`viewer`,kind:`query`,auth:`protected`}),readExportBytes:A(x({exportId:l()}),M$,{kind:`query`,auth:`protected`})},vocabulary:{notOperatorFacing:`recording exports — requested from the timeline, not an automation step`}},F$=S([`continuous`,`motion`,`person`,`vehicle`,`animal`,`lineCrossing`,`intrusion`,`loitering`,`alarmInput`]),I$=x({trigger:F$,day:n().int().min(0).max(6).meta(N(`none`)),startMinute:n().int().min(0).max(1439).meta(N(`none`)),endMinute:n().int().min(1).max(1440).meta(N(`none`))}),L$=x({id:l(),label:l().optional(),status:S([`ok`,`unformatted`,`error`,`offline`,`unknown`]),capacityMb:n().nullable(),freeMb:n().nullable(),writable:y().optional()}),R$=i(`kind`,[x({kind:p(`present`),volumes:C(L$)}),x({kind:p(`absent`),reason:l()}),x({kind:p(`unknown`),reason:l()})]),z$=x({id:l(),enabled:y(),isVideo:y(),codec:l().nullable(),resolution:l().nullable(),overwriteWhenFull:y().nullable()}),B$=x({storage:R$,tracks:C(z$),primaryTrackId:l().nullable(),enabled:y().nullable(),overwriteWhenFull:y().nullable(),preRecordSec:n().nullable().meta(N(`duration`)),postRecordSec:n().nullable().meta(N(`duration`)),segmentMinutes:n().nullable().meta(N(`none`)),windows:C(I$),unreadableWindows:n().meta(N(`count`)),recordingToNowhere:y(),lastFetchedAt:n()}),V$=x({min:n(),max:n(),step:n()}),H$=x({values:C(n()).min(1),sentinel:x({value:n(),meaning:S([`no-limit`,`disabled`])}).optional()}),U$=x({readable:y(),writable:y(),reason:l().optional()}),W$=x({support:U$,granularityMinutes:n(),triggers:C(F$),supportsOverlappingTriggers:y()}),G$=x({enabled:U$,overwriteWhenFull:U$,preRecordSec:U$,preRecordSecRange:V$.optional(),preRecordSecAllowed:H$.optional(),postRecordSec:U$,postRecordSecRange:V$.optional(),postRecordSecAllowed:H$.optional(),segmentMinutes:U$,segmentMinutesRange:V$.optional(),segmentMinutesAllowed:H$.optional(),schedule:W$}),K$=x({enabled:y().optional(),overwriteWhenFull:y().optional(),preRecordSec:n().optional(),postRecordSec:n().optional(),segmentMinutes:n().optional(),windows:C(I$).optional()}),q$={name:`recording-onboard`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],deviceConfig:{ui:{kind:`derived-form`,builderId:`recording-onboard`,tab:`recording`}},methods:{getOptions:A(x({deviceId:n()}),G$),setSettings:A(x({deviceId:n(),settings:K$}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`recordingOnboard.on`,label:F(`On-camera recording on`,`Registrazione a bordo attiva`),phrase:F(`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:F(`On-camera recording off`,`Registrazione a bordo spenta`),phrase:F(`Turn off recording to the card of {device}`,`Disattiva la registrazione sulla scheda di {device}`),icon:`hard-drive`,args:{settings:{enabled:!1}}}]})},status:{schema:B$,kind:`poll`},runtimeState:B$,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`On-camera recording`,`Registrazione a bordo`),order:3260,state:[{kind:`boolean`,field:`recordingToNowhere`,label:F(`Recording to nowhere`,`Registra nel vuoto`),whenTrue:F(`When {device} is recording with no card to write to`,`Quando {device} registra senza una scheda su cui scrivere`),whenFalse:F(`When {device} has a card to record to again`,`Quando {device} ha di nuovo una scheda su cui registrare`),icon:`hard-drive`}]}},J$=x({active:y(),reason:l(),lastChangedAt:n()}),Y$=J$.extend({lastFetchedAt:n()}),X$={name:`recording-signal`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],methods:{getStatus:A(x({deviceId:n()}),J$)},status:{schema:J$,kind:`push`,empty:{active:!1,reason:`unknown`,lastChangedAt:0}},runtimeState:Y$,durability:`session`,history:`none`,vocabulary:{noun:F(`Recording signal`,`Segnale di registrazione`),order:3270,state:[{kind:`boolean`,field:`active`,label:F(`Recording`,`In registrazione`),whenTrue:F(`When {device} starts recording`,`Quando {device} inizia a registrare`),whenFalse:F(`When {device} stops recording`,`Quando {device} smette di registrare`),icon:`circle-dot`}]}},Z$=x({kind:p(`cap`),deviceId:n().int().nonnegative(),cap:l().min(1),method:l().min(1),args:m(l(),w()).optional(),argUnits:m(l(),l().min(1)).optional()}),Q$=x({action:Z$}),$$=x({key:l().refine(eD,{message:`a lowercase slug`}),name:l().min(1).max(60)}),rje=200,ije=100;function aje(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=pD(a);e!==null&&s(e,`payload`)}for(let t of fD(a))ZE(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 e1=x({index:n().int().nonnegative(),id:l().nullable(),name:l().nullable(),reason:l()}),t1=x({layoutTemplateId:l().min(1).nullable(),defaultTransmitterId:n().int().nonnegative().nullable().default(null),bindings:m(l(),Q$),customButtons:C($$).max(100),sources:C(uD).max(200).default([]),stepDelayMs:n().int().min(100).max(dD).default(500),refusedSources:C(e1).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)ZE(e)?t.addIssue({code:`custom`,message:`"${e}" is a layout widget, not a command: it cannot be bound`,path:[`bindings`,e]}):rD(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=nD(e);n!==null&&!r.has(n)&&t.addIssue({code:`custom`,message:`${e} is bound but has no entry in customButtons`,path:[`bindings`,e]})}aje(e,t)}),oje=se({sources:C(w())}),sje=x({id:l(),name:l()}).partial();function cje(e){let t=oje.safeParse(e);if(!t.success)return n1(t1.safeParse(e));let n=[],r=[];t.data.sources.forEach((e,t)=>{let i=uD.safeParse(e),a=i.success&&i.data.kind===`ir`?pD(i.data):null;if(i.success&&a===null){n.push(e);return}let o=sje.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=n1(t1.safeParse({...t.data,sources:n}));return!i.success||r.length===0?i:{success:!0,data:{...i.data,refusedSources:r}}}function n1(e){return e.success?{success:!0,data:e.data}:{success:!1,issues:e.error.issues.length}}var lje={layoutTemplateId:null,defaultTransmitterId:null,bindings:{},customButtons:[],sources:[],stepDelayMs:500},uje=x({power:x({state:S([`on`,`off`]),at:n()}).nullable(),muted:x({value:y(),at:n()}).nullable(),source:x({name:l(),at:n()}).nullable().default(null)}),dje={power:null,muted:null,source:null},fje=24,pje=50,r1=[`rect`,`rounded`,`round`,`pill`],i1=S(r1),a1=[`neutral`,`accent`,`danger`,`red`,`green`,`yellow`,`blue`],o1=S(a1),s1=[`none`,`panel`,`divider`,`dpad`,`rocker-v`,`rocker-h`,`keypad`],c1=S(s1),l1=x({id:l().min(1).max(40),row:n().int().min(0).max(24),col:n().int().min(0).max(24),rowSpan:n().int().min(1).max(24),colSpan:n().int().min(1).max(24),icon:l().min(1).max(60).optional(),label:l().min(1).max(40).optional(),role:iD,shape:i1.optional(),tone:o1.optional(),showLegend:y().optional(),groupId:l().min(1).max(40).optional()}),u1=x({id:l().min(1).max(40),componentId:l().min(1).max(80),frame:c1,row:n().int().min(0).max(24),col:n().int().min(0).max(24),rowSpan:n().int().min(1).max(24),colSpan:n().int().min(1).max(24),title:l().min(1).max(40).optional(),size:S([`compact`,`normal`]).optional(),hideTitle:y().optional()});function d1(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 f1(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 mje(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&&d1(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`]),f1(n,e)||i(`button "${e.id}" lies outside its group "${n.id}"`,[`buttons`,t]);return}let a=n.find(t=>d1(t,e));a!==void 0&&i(`button "${e.id}" lies inside group "${a.id}" but is not a member`,[`buttons`,t])})}var p1=x({columns:n().int().min(1).max(24),rows:n().int().min(1).max(24),buttons:C(l1).max(200),groups:C(u1).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)}}),mje(e,t)}),hje=50,m1=x({role:iD,label:l().optional(),custom:y()}),h1=x({layoutTemplateId:l().nullable(),commands:C(m1),sources:C(uD)}),g1=[`no-remote`,`unbound-role`,`action-failed`,`unknown-source`,`unbound-step`,`undeclared-channel`,`press-timeout`,`no-transmitter`],_1=S(g1),v1=i(`status`,[x({status:p(`sent`),sends:n().int().min(1)}),x({status:p(`skipped`),reason:p(`already-in-state`)}),x({status:p(`refused`),reason:_1,detail:l().optional(),step:x({index:n().int().min(1),role:l()}).optional()})]),y1=[`play`,`pause`,`stop`,`next`,`previous`,`setMute`,`selectSource`,`playMedia`,`turnOn`,`turnOff`,`volumeUp`,`volumeDown`,`channelUp`,`channelDown`],b1=S(y1),x1=i(`status`,[...v1.options,x({status:p(`not-routed`)})]),S1=[`unknown-template`,`not-a-media-player`],C1=i(`status`,[x({status:p(`saved`)}),x({status:p(`refused`),reason:S(S1),detail:l()})]),w1=x({deviceId:n().int().nonnegative()}),gje={version:1,targets:[{id:`remote`,cardinality:`config`,vocabulary:{cap:`remote`},deviceTypes:[E.MediaPlayer],apply:`add`,readMethod:`getConfig`,writeMethod:`setConfig`}]},T1={name:`remote`,scope:`system`,mode:`singleton`,methods:{getConfig:A(w1,t1,{auth:`admin`}),setConfig:A(w1.extend({config:t1}),C1,{kind:`mutation`,auth:`admin`}),listCommands:A(w1,h1,{auth:`protected`}),sendCommand:A(w1.extend({role:iD,repeat:n().int().min(1).max(50).default(1)}),v1,{kind:`mutation`,auth:`protected`}),getAssumedStatus:A(w1,yD.nullable(),{auth:`protected`}),sendMediaCommand:A(w1.extend({command:b1,muted:y().optional(),source:l().optional(),mediaType:l().optional(),mediaId:l().optional(),repeat:n().int().min(1).max(50).default(1)}),x1,{kind:`mutation`,auth:`protected`})},customize:gje,vocabulary:{notOperatorFacing:`the per-device remote setup — authored in the Customize remote editor, sent through the remote UI`}},E1=[`power`,`navigation`,`volume`,`numbers`,`media`,`colour`,`apps`,`layout`],D1=S(E1),_je=40,vje=/^[a-z0-9][a-z0-9_.-]*:[a-z0-9][a-z0-9_-]*$/,O1=x({idSuffix:l().regex(/^[a-z0-9][a-z0-9_-]{0,19}$/,{message:`a short lowercase slug`}),row:n().int().min(0).max(24),col:n().int().min(0).max(24),rowSpan:n().int().min(1).max(24),colSpan:n().int().min(1).max(24),role:iD,icon:l().min(1).max(60).optional(),label:l().min(1).max(40).optional(),shape:i1.optional(),tone:o1.optional(),showLegend:y().optional()}),k1=x({id:l().max(80).regex(vje,{message:`<namespace>:<name>, lowercase`}),name:l().min(1).max(60),nameI18n:x({en:l().min(1).max(60),it:l().min(1).max(60)}).optional(),icon:l().min(1).max(60),category:D1,size:x({rows:n().int().min(1).max(24),cols:n().int().min(1).max(24)}),group:x({frame:c1,title:l().min(1).max(40).optional()}).nullable(),buttons:C(O1).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&&d1(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`]})}),A1={name:`remote-layout-components`,scope:`system`,mode:`collection`,methods:{listComponents:A(x({}),C(k1),{auth:`protected`})},vocabulary:{notOperatorFacing:`the palette of the remote template editor — read-only data, never actuated`}},j1=x({deviceId:n().int().nonnegative(),resetToSource:y().optional()}),M1={name:`resync`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Container,E.Workload,E.WeatherStation],methods:{resync:A(j1,BA,{kind:`mutation`,auth:`admin`,notOperatorFacing:`device adoption — re-aligning a device with its source is an onboarding step, not an automation action`})},vocabulary:{noun:F(`Re-sync`,`Risincronizzazione`),order:3245}},yje=5,bje=2,N1=3e4,P1=18e4,F1={startDwellMs:N1,stopDwellMs:P1,minSamples:2},I1={[E.MediaPlayer]:{startDwellMs:1e4,stopDwellMs:1e4,minSamples:1}};function L1(e){return e!==void 0&&I1[e]!==void 0}function R1(e){return e===void 0?F1:I1[e]??F1}var xje={running:null,since:null,source:`native`,phase:null,lastFetchedAt:null},z1=S([`native`,`assigned`]),B1=x({running:y().nullable(),since:n().nullable().meta(N(`none`)),source:z1.meta({label:`Source`}),phase:l().nullable(),lastFetchedAt:n().nullable()}),V1=x({deviceId:n(),since:n().nullable(),phase:l().nullable()}),Sje=Object.values(E),H1=[E.Washer,E.Dryer,E.Dishwasher,E.Vacuum,E.LawnMower,E.MediaPlayer,E.WaterHeater,E.Humidifier,E.Fan,E.Climate,E.PetFeeder],Cje={version:1,overridable:[{path:`running`,by:`running`}],targets:[{id:`running`,cardinality:`scalar`,vocabulary:{cap:`running-state`,stateField:`running`},deviceTypes:H1,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:N1,defaultStopDwellMs:P1,deviceTypeDefaults:I1,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}]},U1={name:`running-state`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:Sje,methods:{},events:{onStarted:{data:V1,trigger:{category:T.RunningStarted,label:F(`Started running`,`Ha iniziato a funzionare`),phrase:F(`When {device} starts running`,`Quando {device} inizia a funzionare`),icon:`play`}},onFinished:{data:V1,trigger:{category:T.RunningFinished,label:F(`Finished`,`Ha finito`),phrase:F(`When {device} finishes`,`Quando {device} finisce`),icon:`square`}}},status:{schema:B1,kind:`push`},runtimeState:B1,durability:`restored`,history:{fields:{running:{kind:`boolean`}}},volatileStateFields:[`lastFetchedAt`],customize:Cje,vocabulary:{noun:F(`Running`,`In funzione`),order:2120,state:[{kind:`boolean`,field:`running`,label:F(`Running`,`In funzione`),whenTrue:F(`When {device} starts`,`Quando {device} inizia`),whenFalse:F(`When {device} finishes`,`Quando {device} finisce`),icon:`play`}],overrides:{byType:{[E.Washer]:{state:{running:{whenTrue:F(`When the washing machine starts`,`Quando la lavatrice inizia`),whenFalse:F(`When the washing machine has finished`,`Quando la lavatrice ha finito`)}},events:{onStarted:{phrase:F(`When the washing machine starts`,`Quando la lavatrice inizia`)},onFinished:{phrase:F(`When the washing machine has finished`,`Quando la lavatrice ha finito`)}}},[E.Dryer]:{state:{running:{whenTrue:F(`When the dryer starts`,`Quando l'asciugatrice inizia`),whenFalse:F(`When the dryer has finished`,`Quando l'asciugatrice ha finito`)}},events:{onStarted:{phrase:F(`When the dryer starts`,`Quando l'asciugatrice inizia`)},onFinished:{phrase:F(`When the dryer has finished`,`Quando l'asciugatrice ha finito`)}}},[E.Dishwasher]:{state:{running:{whenTrue:F(`When the dishwasher starts`,`Quando la lavastoviglie inizia`),whenFalse:F(`When the dishwasher has finished`,`Quando la lavastoviglie ha finito`)}},events:{onStarted:{phrase:F(`When the dishwasher starts`,`Quando la lavastoviglie inizia`)},onFinished:{phrase:F(`When the dishwasher has finished`,`Quando la lavastoviglie ha finito`)}}}}}}},W1=l(),wje=[`day`,`ir`,`night`,`dawn`,`dusk`],G1=S([`skip`,`judge-anyway`]),Tje=`__diverged__`,K1=S([`matched`,`diverged`,`unknown`]),q1=S([`no-reference-for-condition`,`view-shifted`,`no-vision-profile`,`encoder-model-changed`,`no-snapshot`]),J1=x({embedding:C(n()),modelId:l(),condition:W1,capturedAt:n(),thumbnailMediaId:n().int().optional(),anchorEmbedding:C(n()).optional()}),Y1=x({id:l(),label:l(),references:C(J1),textPrompts:C(l()).optional(),referenceCount:n(),currentlyMatched:y()}),X1=i(`mode`,[x({mode:p(`similarity`),threshold:n().min(0).max(1),hysteresisCount:n().int().positive()}),x({mode:p(`llm`),prompt:l(),profileId:l().optional(),hysteresisCount:n().int().positive()})]),Eje=60,Dje=120,Oje=60,Z1=.85,Q1=`skip`,$1=8e3,kje=448,Aje=!0,e0=x({enabled:y().default(!1),prompt:l().min(1).max(1e3),profileId:l().optional(),timeoutMs:n().int().min(1e3).max(2e4).default($1),maxImagePx:n().int().min(64).max(2048).default(448),onTimeout:S([`flip`,`hold`]).default(`hold`)}),t0=x({id:l(),label:l(),roi:iH,enabled:y(),triggerMode:S([`periodic`,`on-motion`,`both`]),checkIntervalSec:n().optional(),check:X1,states:C(Y1),currentStateId:l().nullable(),lastCheckedAt:n().nullable(),lastConfidence:n().nullable(),currentCondition:W1.nullable(),availability:S([`ok`,`unavailable`]),unavailableReason:l().nullable(),baselineStateId:l().nullable(),emit:S([`latched`,`live`]).default(`latched`),verdict:K1,latched:y(),armedAt:n(),divergedAt:n().nullable(),restoredAt:n().nullable(),quietSeconds:n().int().min(0).max(3600).default(60),minObservationSpacingSec:n().int().min(0).max(3600).default(120),confirm:e0.optional(),anchorThreshold:n().min(0).max(1).default(Z1),autoRestore:y().default(!1),onUncoveredCondition:G1.default(Q1),suspendedCondition:W1.nullable().default(null),unavailable:q1.nullable(),coveredConditions:C(W1)}),n0=x({monitors:C(t0),lastFetchedAt:n()}),r0=x({deviceId:n(),status:n0.nullable()}),i0={name:`scene-monitor`,role:{feature:`scenes`},scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[E.Camera],methods:{listScenes:A(x({deviceId:n()}),n0),listScenesBatch:A(x({deviceIds:C(n()).min(1).max(200)}),C(r0).readonly()),createScene:A(x({deviceId:n(),label:l(),roi:iH,check:X1,triggerMode:S([`periodic`,`on-motion`,`both`]).optional(),checkIntervalSec:n().optional()}),t0,{kind:`mutation`,auth:`admin`}),updateScene:A(x({deviceId:n(),monitorId:l(),patch:x({label:l().optional(),roi:iH.optional(),enabled:y().optional(),triggerMode:S([`periodic`,`on-motion`,`both`]).optional(),checkIntervalSec:n().optional(),check:X1.optional(),emit:S([`latched`,`live`]).optional(),quietSeconds:n().int().min(0).max(3600).optional(),minObservationSpacingSec:n().int().min(0).max(3600).optional(),anchorThreshold:n().min(0).max(1).optional(),autoRestore:y().optional(),onUncoveredCondition:G1.optional(),confirm:e0.nullable().optional()})}),v(),{kind:`mutation`,auth:`admin`}),deleteScene:A(x({deviceId:n(),monitorId:l()}),v(),{kind:`mutation`,auth:`admin`}),captureReference:A(x({deviceId:n(),monitorId:l(),stateId:l().optional(),label:l().optional(),condition:W1.optional()}),x({stateId:l(),referenceCount:n()}),{kind:`mutation`,auth:`admin`}),deleteReference:A(x({deviceId:n(),monitorId:l(),stateId:l(),index:n()}),v(),{kind:`mutation`,auth:`admin`}),recheckNow:A(x({deviceId:n(),monitorId:l()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`sceneMonitor.recheck`,label:F(`Re-check a scene`,`Ricontrolla una scena`),phrase:F(`Re-check {monitorId} on {device} now`,`Ricontrolla subito {monitorId} su {device}`),icon:`scan-search`,openArgs:[{key:`monitorId`,label:F(`Scene`,`Scena`),offer:{kind:`dynamic`,from:`status`,field:`monitors`,valueKey:`id`,labelKey:`label`}}]}]}),resetScene:A(x({deviceId:n(),monitorId:l(),recapture:y().optional()}),v(),{kind:`mutation`,auth:`admin`})},status:{schema:n0,kind:`push`},runtimeState:n0,durability:`session`,history:`none`,vocabulary:{noun:F(`Scene watch`,`Controllo della scena`),order:3280,extraEvents:[{category:T.EnrichmentSceneStateChanged,label:F(`Scene changed`,`Scena cambiata`),phrase:F(`When a watched scene on {device} changes`,`Quando cambia una scena controllata su {device}`),icon:`scan-search`}]}},a0=x({schedulerId:l().min(1)}),o0={name:`schedulers`,scope:`system`,mode:`singleton`,methods:{list:A(x({}),C(cy),{auth:`admin`}),get:A(a0,x({scheduler:cy.nullable()}),{auth:`admin`}),create:A(x({scheduler:sy}),x({scheduler:cy}),{kind:`mutation`,auth:`admin`}),update:A(x({schedulerId:l().min(1),scheduler:sy}),x({scheduler:cy}),{kind:`mutation`,auth:`admin`}),delete:A(a0,v(),{kind:`mutation`,auth:`admin`}),setEnabled:A(x({schedulerId:l().min(1),profileId:l().min(1).optional(),enabled:y()}),x({scheduler:cy}),{kind:`mutation`,auth:`admin`}),preview:A(x({schedulerId:l().min(1),date:l().regex(my).optional()}),gy,{auth:`admin`}),conflicts:A(x({scheduler:sy,schedulerId:l().min(1).optional()}),x({conflicts:C(_y)}),{auth:`admin`}),getStatus:A(x({}),C(yy),{auth:`admin`}),getTraces:A(a0,x({traces:C(Ay)}),{auth:`admin`})},vocabulary:{notOperatorFacing:`time schedulers — authored on their own page, not device actions`}},s0=x({isRunning:y(),lastRunAt:n(),lastRunSuccess:y().nullable(),lastError:l().nullable(),lastChangedAt:n()}),c0={name:`script-runner`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Script],methods:{run:A(x({deviceId:n().int().nonnegative(),variables:m(l(),w()).optional()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`script.run`,label:F(`Run script`,`Esegui lo script`),phrase:F(`Run {device}`,`Esegui {device}`),icon:`scroll-text`,hold:{effects:[{field:`isRunning`,value:!0}],holdMs:IY}}]}),stop:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`script.stop`,effect:{field:`isRunning`,value:!1},label:F(`Stop script`,`Ferma lo script`),phrase:F(`Stop {device}`,`Ferma {device}`),icon:`square`}]})},status:{schema:s0,kind:`push`},runtimeState:s0,durability:`session`,history:`none`,vocabulary:{noun:F(`Script`,`Script`),order:2090,state:[{kind:`boolean`,field:`isRunning`,label:F(`Running`,`In esecuzione`),whenTrue:F(`When {device} starts running`,`Quando {device} parte`),whenFalse:F(`When {device} finishes`,`Quando {device} termina`),icon:`scroll-text`}]}},l0=S([`workspace`,`baked`,`data-root`]),u0=S([`idle`,`checking`,`staging`,`pending-restart`,`awaiting-confirmation`]),d0=S([`in-sync`,`behind-patch`,`behind-series`,`ahead`,`unknown`]),f0=x({state:d0,seedVersion:l().nullable(),contractVersion:l().nullable(),contractSource:S([`registry`,`running`]).nullable(),message:l()}),p0=S([`docker`,`electron`,`native`,`contradictory`,`unknown`]),m0=x({fact:S([`dockerenv-file`,`proc-1-cgroup`,`platform`,`electron-app-version-env`]),mode:S([`observed`,`declared`]),holds:y(),detail:l()}),h0=x({kind:p0,evidence:C(m0),currentVersion:l().nullable()}),g0=x({fromVersion:l(),toVersion:l().nullable(),atMs:n(),reason:l()}),_0=x({version:l(),update:x({available:y(),downloaded:y(),version:l().nullable(),checking:y(),error:l().nullable()}),stateAtMs:n(),stale:y()}),v0=S([`not-electron`,`no-app-state`,`app-state-stale`,`not-downloaded`]),y0=x({accepted:y(),reason:v0.nullable()}),b0=x({runnerId:l(),addonIds:C(l()),reason:l()}),x0=x({checkedAtMs:n(),expected:n(),running:n(),failed:C(l()),refused:C(b0),missing:C(l()),pending:C(l()).optional(),planKnown:y()}),S0=x({packageName:l(),runningVersion:l().nullable(),nodeRuntimeVersion:l().nullable(),activeVersion:l().nullable(),installedVersion:l().nullable().optional(),restartRequired:y().optional(),previousVersion:l().nullable(),seedVersion:l().nullable(),latestVersion:l().nullable(),updateAvailable:y(),bootMode:l0,updateState:u0,pendingVersion:l().nullable(),rolledBack:g0.nullable(),stateFileCorrupt:y(),lastCheckedAtMs:n().nullable(),imageContract:f0.optional(),wrapper:h0.optional(),runners:x0.optional(),desktopApp:_0.optional()}),C0=x({packageName:l(),runningVersion:l().nullable(),latestVersion:l().nullable(),updateAvailable:y(),checkedAtMs:n(),error:l().nullable(),pendingVersion:l().nullable().optional(),restartRequired:y().optional()}),w0=S([`staged`,`restart-scheduled`,`already-current`,`refused`,`failed`]),T0=x({addonId:l(),reason:l(),remedy:l()}),E0=x({accepted:y(),targetVersion:l().nullable(),restarting:y(),message:l(),outcome:w0.optional(),reason:l().nullable().optional(),error:l().nullable().optional(),blockers:C(T0).optional(),unmet:C(Pu).optional(),requiredAddonUpdates:C(Fu).optional()}),D0=x({heapMb:n().int().nullable(),rssBudgetMb:n().int().nullable()}),jje=x({heapMb:n().int().min(512).max(65536).nullable(),rssBudgetMb:n().int().min(512).max(65536).nullable().optional()}),Mje=D0.extend({restartRequired:y()}),O0={name:`server-management`,scope:`system`,mode:`singleton`,methods:{getServerPackageStatus:A(v(),S0,{auth:`admin`}),checkServerUpdate:A(v(),C0,{kind:`mutation`,auth:`admin`}),applyServerUpdate:A(x({version:l().optional(),acknowledgeRefusals:y().optional()}),E0,{kind:`mutation`,auth:`admin`,timeoutMs:16*6e4}),installDesktopUpdate:A(v(),y0,{kind:`mutation`,auth:`admin`}),rollbackServerUpdate:A(v(),E0,{kind:`mutation`,auth:`admin`}),restartServer:A(v(),E0,{kind:`mutation`,auth:`admin`}),getLaunchOverrides:A(v(),D0,{auth:`admin`}),setLaunchOverrides:A(jje,Mje,{kind:`mutation`,auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:M.CLUSTER}},k0={Seconds:`seconds`,Plays:`plays`},A0={Camera:`camera`,Fallback:`fallback`},j0=x({min:n().positive(),max:n().positive(),step:n().positive()}),M0=x({allowedSeconds:C(n().positive()).nullable(),rangeSeconds:j0.nullable(),defaultSeconds:n().positive(),allowedPlays:C(n().int().positive()).nullable().default(null),rangePlays:j0.nullable().default(null),defaultPlays:n().int().positive().nullable().default(null),unit:S([k0.Seconds,k0.Plays]),secondsPerPlay:n().positive().nullable(),source:S([A0.Camera,A0.Fallback]),fetchedAt:n()}),N0=x({active:y(),activeUntil:n().nullable(),durationSeconds:n().nullable(),plays:n().int().positive().nullable().default(null),activeUntilEstimated:y().default(!1),lastTriggeredAt:n()}),P0=x({deviceId:n().int().nonnegative(),durationSeconds:n().positive().optional(),plays:n().int().positive().optional()}).refine(e=>e.durationSeconds===void 0||e.plays===void 0,{message:`a siren trigger takes durationSeconds or plays, not both`,path:[`plays`]}),F0=N0.extend({lastFetchedAt:n()}),I0={name:`siren`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Siren],methods:{getOptions:A(x({deviceId:n().int().nonnegative()}),M0,{kind:`query`,auth:`protected`}),getPlayChoices:A(x({deviceId:n().int().nonnegative()}),C(n().int().positive()),{kind:`query`,auth:`protected`}),trigger:A(P0,N0,{kind:`mutation`,auth:`protected`,actions:[{id:`siren.trigger`,label:F(`Sound the siren`,`Fai suonare la sirena`),phrase:F(`Sound {device}`,`Fai suonare {device}`),icon:`siren`,args:{}},{id:`siren.triggerPlays`,label:F(`Sound the siren N times`,`Fai suonare la sirena N volte`),phrase:F(`Sound {device} {plays} times`,`Fai suonare {device} {plays} volte`),icon:`siren`,openArgs:[{key:`plays`,label:F(`Plays`,`Riproduzioni`),offer:{kind:`dynamic`,from:`method`,method:`getPlayChoices`,valueKind:`number`}}]}]}),stop:A(x({deviceId:n().int().nonnegative()}),N0,{kind:`mutation`,auth:`protected`,actions:[{id:`siren.stop`,label:F(`Silence the siren`,`Zittisci la sirena`),phrase:F(`Silence {device}`,`Zittisci {device}`),icon:`siren`,effect:{field:`active`,value:!1},args:{}}]})},events:{onSirenChanged:{data:x({deviceId:n(),active:y(),activeUntil:n().nullable()}),notOperatorFacing:"the `active` state trigger phrases both edges of this change"}},status:{schema:N0,kind:`command-driven`},runtimeState:F0,durability:`session`,history:`none`,vocabulary:{noun:F(`Siren`,`Sirena`),order:1170,state:[{kind:`boolean`,field:`active`,label:F(`Siren sounding`,`Sirena in funzione`),whenTrue:F(`When {device} starts sounding`,`Quando {device} inizia a suonare`),whenFalse:F(`When {device} falls silent`,`Quando {device} smette di suonare`),icon:`siren`}]}},L0=x({detected:y(),lastChangedAt:n()}),R0={name:`smoke`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:L0,kind:`push`},runtimeState:L0,durability:`restored`,history:{fields:{detected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Smoke detector`,`Rilevatore di fumo`),order:5190,state:[{kind:`boolean`,field:`detected`,label:F(`Detected`,`Rilevato`),whenTrue:F(`When {device} detects smoke`,`Quando {device} rileva fumo`),whenFalse:F(`When smoke clears on {device}`,`Quando il fumo su {device} si dirada`),icon:`alarm-smoke`}]}},Nje=3,z0=5*1024*1024,B0=`<!--camstack-images-->`,V0=x({ticket:Si,mime:l().min(1),name:l().min(1),contentId:l().min(1),placement:S([`inline`,`attachment`]),deviceId:n().int().nonnegative().optional()}),H0=0;function U0(e){return H0+=1,`camstack_${e}_${H0.toString(36)}_${Date.now().toString(36)}`}function Pje(e){return/^[\x20-\x7E]*$/.test(e)?e:`=?UTF-8?B?${Buffer.from(e,`utf8`).toString(`base64`)}?=`}function W0(e){return(Array.isArray(e)?e:[e]).join(`, `)}function Fje(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}function G0(e,t){let n=e.replace(/[\r\n"]/g,``).trim();return n.length>0?n:t}function Ije(e){let t=Buffer.from(e).toString(`base64`),n=[];for(let e=0;e<t.length;e+=76)n.push(t.slice(e,e+76));return n.join(`\r
|
|
1113
|
+
`}function J_e(e){return`subjects`in e?e.subjects:e.classes.map(u_)}var Y_e=new Set(Object.values(r_.mapping));function X_e(e){return r_.mapping[e]??e}function Z_e(e,t){let n=e.toLowerCase(),r=t.toLowerCase();return n===r?!0:Y_e.has(n)&&X_e(r)===n}function Q_e(e){return e===`start`||e===`update`||e===`end`}var $_e=class{trigger;fired=new Map;subjects;constructor(e){this.trigger=e,this.subjects=J_e(e)}get firedCount(){return this.fired.size}evaluate(e,t){let{deviceId:n,trackId:r,phase:i}=e;if(typeof n!=`number`||typeof r!=`string`||!Q_e(i))return{kind:`ignore`,why:`malformed track-lifecycle event`};if(!this.trigger.deviceIds.includes(n))return{kind:`ignore`,why:`device ${n} is not one of the trigger's devices`};let a=`${n}|${r}`;if(i===`end`)return this.fired.delete(a),{kind:`ignore`,why:`track ended`};this.expire(t);let o=typeof e.bestClassName==`string`?e.bestClassName:``,s=typeof e.bestConfidence==`number`?e.bestConfidence:0,c={deviceId:n,className:o,trackId:r,score:s,label:``};if(this.fired.has(a))return{kind:`reject`,reason:`already fired for track ${r}`,vars:c};let l=m_(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 eve(e){return`classes`in e}function tve(e){return e===`appeared`||e===`departed`}function nve(e,t){let{deviceId:n,entryId:r,phase:i}=t;if(typeof n!=`number`||typeof r!=`string`||!tve(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=eve(e)?e.classes?.map(u_):e.subjects;if(c!==void 0){let e=m_(c,{className:a});if(!e.matches)return{kind:`reject`,reason:e.reason,vars:s}}return e.zones!==void 0&&!e.zones.some(e=>o.includes(e))?{kind:`reject`,reason:`zone mismatch: in [${o.join(`, `)}], wanted [${e.zones.join(`, `)}]`,vars:s}:{kind:`fire`,reason:`${a} ${i} on device ${n}`,vars:s}}var Mb=x({deviceId:n(),eventType:l(),sourceId:l().optional(),data:m(l(),w()).nullable(),timestamp:n().meta(N(`none`)),seq:n().meta(N(`count`))}),Nb=x({eventTypes:C(l()),vocabulary:C(Pme).default([]),lastEvent:Mb.nullable(),eventCountSinceStart:n().meta(N(`count`))}),Pb={name:`event-emitter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.EventEmitter],methods:{},events:{onEvent:{data:Mb,trigger:{category:T.EventEmitted,label:F(`Fired an event`,`Ha generato un evento`),phrase:F(`When {device} fires an event`,`Quando {device} genera un evento`),icon:`zap`}}},status:{schema:Nb,kind:`push`},runtimeState:Nb,durability:`session`,history:`none`,vocabulary:{noun:F(`Event source`,`Sorgente di eventi`),order:5280}},rve=3,ive=32;function ave(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`}function Fb(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ib(e){let t={},n=(e,r,i)=>{if(!(Object.keys(t).length>=ive)){if(ave(e)){t[r]=e;return}if(!(!Fb(e)||i>=rve))for(let[t,a]of Object.entries(e))n(a,`${r}.${t}`,i+1)}};if(Fb(e))for(let[t,r]of Object.entries(e))n(r,`data.${t}`,1);return t}function ove(e,t){let n=e;for(let e of t.split(`.`)){if(!Fb(n))return;n=n[e]}return n}function Lb(e,t){return t===null?!0:e.timestamp===t.timestamp?e.seq>t.seq:e.timestamp>t.timestamp}var Rb=`recovered by reconcile`,sve=class{leaf;#e=null;#t=!1;#n=null;constructor(e){this.leaf=e}onEvent(e){let t=Mb.safeParse(e);if(!t.success)return{kind:`ignore`,why:`malformed event`};let n=t.data;return n.deviceId===this.leaf.deviceId?Lb(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=Nb.safeParse(e);if(!t.success)return{kind:`ignore`,why:`the event-emitter status is unreadable`};this.#n=Bme(t.data);let n=t.data.lastEvent,r=!this.#t;return this.#t=!0,n===null?{kind:`ignore`,why:`the device has not fired`}:Lb(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??Rme([e.eventType]);return(Ag(t,e.eventType,e.sourceId)??Ag(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=Ib(e.data);for(let t of a??[]){let n=ove(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} — ${Rb}`:l,vars:s,data:c}}},zb=6e4;function Bb(e){return(e/zb).toFixed(1)}var cve=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*zb;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 ${Bb(n)} min ago`};let r=`${Bb(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 ${Bb(n)} min ago, ${r}`}}},Vb=S([`string`,`number`,`boolean`,`select`]),lve=/^[A-Za-z_][A-Za-z0-9_]*$/,Hb=h([l(),n(),y()]),Ub=x({name:l().regex(lve),label:l().min(1).max(120).optional(),type:Vb,required:y().optional(),default:Hb.optional(),options:C(l().min(1)).min(1).optional()}).superRefine((e,t)=>{e.type===`select`&&e.options===void 0&&t.addIssue({code:`custom`,message:`a select variable needs options`,path:[`options`]}),e.default!==void 0&&Wb(e,e.default)!==null&&t.addIssue({code:`custom`,message:Wb(e,e.default)??`invalid default`,path:[`default`]})});function Wb(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 uve(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=Wb(e,t);if(n!==null)return{ok:!1,error:n};i[e.name]=t}return{ok:!0,values:i}}var Gb=S([`internal`,`addon`]),Kb=`internal:`;function dve(e){return`${Kb}${e}`}function qb(e){return e.startsWith(`internal:`)&&e.length>9}function Jb(e){if(qb(e))return null;let t=e.indexOf(`:`);return t>0&&t<e.length-1?e.slice(0,t):null}var Yb=x({isRunning:y(),lastRunAt:n().nullable(),lastError:l().nullable()}),fve={isRunning:!1,lastRunAt:null,lastError:null},Xb=n().int().min(0).max(86400),Zb=x({id:l().min(3),name:l().min(1).max(120),addonId:l().min(1),source:Gb,readOnly:y(),steps:C(bv).min(1).max(50).optional(),variables:C(Ub).max(20).optional(),minDelaySec:Xb.optional(),tags:Hh.optional(),status:Yb}).superRefine((e,t)=>{if(e.source===`internal`){qb(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`]}),Jb(e.id)===null&&t.addIssue({code:`custom`,message:`an addon action id is <addonId>:<localId>`,path:[`id`]})}),Qb=x({name:l().min(1).max(120),steps:C(bv).min(1).max(50),variables:C(Ub).max(20).optional(),minDelaySec:Xb.optional(),tags:Hh.optional()}),$b=x({blockId:l().min(1).optional()}),ex=h([xy,p(`started`),p(`timed-out`)]),tx=x({runId:l().min(1),outcome:ex,message:l().optional()}),pve=S([`not-found`,`read-only`,`invalid-variables`,`invalid-steps`,`not-linked`,`template-scope`,`busy`]),mve=class extends Error{code;constructor(e,t){super(`[${e}] ${t}`),this.name=`ActionError`,this.code=e}},nx=x({actionId:l(),runId:l(),isRunning:y(),outcome:xy.optional(),lastRunAt:n().nullable(),lastError:l().nullable()});function hve(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 rx(e){return[...e.kind===`command`&&e.target.kind===`devices`?[{actionId:e.actionId,ids:e.target.ids}]:[],...hve(e).flatMap(rx)]}async function gve(e,t){let n=e.flatMap(rx);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){Ba(e,void 0);for(let n of t)Gne(e,n,i.get(n)??[])}}async function _ve(e,t,n=Date.now,r,i,a){let o=r?.mirror??new fb(cb(e));await o.refresh(t);let s=yb(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 vve(e){try{return await e()}catch(e){return{result:`unknown`,reason:e instanceof Error?e.message:String(e)}}}async function yve(e){let t=e.now(),n=t+e.timeoutMs;for(;;){let r=await vve(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 bve(e,t){return`timed out after ${e} s: ${t}`}function ix(e){return fa(e)}function ax(e){let t=ix(e);if(t===void 0)return[];let n=Hl(t);return n===void 0?[t]:[t,...ql(n).filter(e=>e!==t)]}var ox=x({path:l(),deviceId:n().int().optional(),field:l(),value:n(),assumedUnit:l(),message:l()});function xve(e){let t=Jg(e);return t instanceof ce?t:void 0}function sx(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[...Yg(r.schema),...r.itemArray===void 0?[]:mhe(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=xve(i)?.shape[r];return a===void 0?void 0:xhe(a)}}}function cx(e){return Zg(e)??e}function lx(e){return ax(e).length>1}function ux(e){return{...e,message:`${e.field}: the bare number ${e.value} was taken as ${e.assumedUnit} — send { value, unit } to state the unit`}}function dx(e,t){n_({value:1,unit:e,target:t})}function Sve(e,t,n){let r=t.fieldQuantity(e.cap,e.fieldPath),i=r===void 0?void 0:ix(r),a=t_(e.value)||e.unit!==void 0;if(i===void 0||r===void 0){if(a)throw new $g(`no-quantity`,`${e.cap}.${e.fieldPath} is not a quantity — it takes no unit`);return{leaf:e,warnings:[]}}if(t_(e.value)){let t=n_({value:e.value.value,unit:e.value.unit,target:i});return{leaf:{...e,value:t,unit:cx(e.value.unit)},warnings:[]}}return typeof e.value==`number`?e.unit===void 0?lx(r)?{leaf:e,warnings:[ux({path:n,deviceId:e.deviceId,field:e.fieldPath,value:e.value,assumedUnit:i})]}:{leaf:e,warnings:[]}:(dx(e.unit,i),{leaf:e,warnings:[]}):{leaf:e,warnings:[]}}function fx(e,t,n=`when`){switch(e.kind){case`device-is`:{let{leaf:r,warnings:i}=Sve(e,t,n);return{value:r,warnings:i}}case`not`:{let r=fx(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)=>fx(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 Cve(e,t,n){if(Ia(e.actionId)===void 0)return{value:e,warnings:[]};let r=e.target.kind===`devices`&&e.target.ids.length===1?e.target.ids[0]:void 0,{cap:i,method:a}=Ba(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 $g(`no-quantity`,`${i}.${a}(${n}) is not a quantity — it takes no unit`);dx(r,e.unit)}for(let[l,u]of Object.entries(e.args??{})){let e=t.paramMeta(i,a,l);e!==void 0&&(t_(u)?(o[l]=n_({value:u.value,unit:u.unit,target:e.unit}),s[l]=cx(u.unit)):typeof u==`number`&&s[l]===void 0&&lx(e.quantity)&&c.push(ux({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 px(e,t,n=`steps`){let r=[],i=[];return e.forEach((e,a)=>{if(e.kind!==`command`){r.push(e);return}let o=Cve(e,t,`${n}.${a}`);r.push(o.value),i.push(...o.warnings)}),{value:r,warnings:i}}function mx(e,t){let n=fx(e.when,t,`when`),r=px(e.actions,t,`actions`);return{value:{...e,when:n.value,actions:r.value},warnings:[...n.warnings,...r.warnings]}}function hx(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||ax(n).length<2)return e;let r=ix(n);return r===void 0?e:{...e,unit:r}}case`not`:return{...e,child:hx(e.child,t)};case`all`:case`any`:return{...e,children:e.children.map(e=>hx(e,t))};default:return e}}function wve(e,t){if(e.kind!==`command`||e.args===void 0||Ia(e.actionId)===void 0)return e;let{cap:n,method:r}=Ba(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&&ax(e.quantity).length>1&&(i[a]=e.unit)}return Object.keys(i).length===0?e:{...e,argUnits:i}}function gx(e,t){let n={...e,when:hx(e.when,t),actions:e.actions.map(e=>wve(e,t))};try{return{ok:!0,recipe:mx(n,t).value}}catch(e){if(e instanceof $g)return{ok:!1,error:e.message};throw e}}var Tve=[`devices`,`time`,`cameras`,`events`,`logic`,`system`],_x=[`trigger`,`any`],vx=[`trigger`,`guard`,`any`],yx={detection:{kind:`detection`,category:`cameras`,role:`event`,allowedIn:_x,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:_x,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:_x,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:_x,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:_x,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:_x,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:_x,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:_x,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:vx,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:vx,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:vx,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:vx,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:vx,i18nKey:`automation.leafCatalog.expression`,keywords:[`formula`,`math`,`arithmetic`,`sum`,`compare`,`calculate`,`held`],needsDeviceValue:!1,seed:()=>({kind:`expression`,expr:``,bindings:{}})}},bx=[`detection`,`stationary`,`device-becomes`,`device-fired`,`device-event`,`schedule`,`interval`,`manual`,`device-is`,`stationary-present`,`time-is`,`triggered-by`,`expression`];function Eve(e){return yx[e]}function Dve(e){return yx[e].seed()}function Ove(e){return bx.filter(t=>yx[t].allowedIn.includes(e))}function xx(e){return e instanceof Error?e.message:String(e)}function kve(e){return e.startsWith(`[busy]`)?`already-running`:e.startsWith(`[not-found]`)?`not-found`:null}async function Ave(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=xx(e),i=kve(n);return i===null?(t.warn(`${r}: exported action failed`,{tags:a,meta:{message:n}}),{status:`failed`,message:n}):o(i,n)}}async function jve(e,t,n){let{exporter:r,targetId:i}=n,a={targetId:i};try{let{targets:o,unreadable:s}=await Ad(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:ed.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=xx(e);return t.warn(`${r}: exported notifier send failed`,{tags:a,meta:{message:n}}),{status:`failed`,message:n}}}function Mve(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 Sx=l().min(1),Cx=x({instanceId:Sx.optional()}),wx=x({instanceId:Sx,name:l(),enabled:y(),kind:l().optional(),nameRule:l().optional()}),Tx=`export-instance-unknown`,Ex=class extends Error{code=Tx;instanceId;constructor(e,t){super(`${Tx}: ${e} serves no instance "${t}"`),this.name=`ExportInstanceUnknownError`,this.instanceId=t}};function Dx(e){return`instanceId`in e?e.instanceId:void 0}function Nve(e,t,n){if(n!==void 0&&n!==t)throw new Ex(e,n)}var Pve=S([`unlinked`,`linked`,`error`]),Ox=x({label:l(),value:l(),secret:y().optional()}),kx=x({qr:l().optional(),fields:C(Ox).readonly().optional(),note:l().optional()}),Ax=x({linkState:Pve,exposedDeviceCount:n(),error:l().optional(),setup:kx.optional()}),Fve=l(),jx=x({deviceId:l(),exposedAs:l().optional(),exposedName:l().optional(),capabilities:C(l()).optional()}),Mx=x({instanceId:Sx,deviceId:l(),capabilities:C(l()).optional(),exposedName:l().nullable().optional()}),Nx=x({instanceId:Sx,deviceId:l(),name:l().nullable(),dryRun:y().optional()}),Px=`export-name-refused`,Fx=class extends Error{code=Px;instanceId;reason;constructor(e,t){super(`${Px}: ${t}`),this.name=`ExportNameRefusedError`,this.instanceId=e,this.reason=t}},Ix=x({instanceId:Sx,deviceId:l()}),Lx=S([`device`,`action`,`notifier`]),Rx=i(`kind`,[x({kind:p(`device`),deviceId:l()}),x({kind:p(`action`),actionId:l().min(1)}),x({kind:p(`notifier`),targetId:l().min(1)})]),zx=x({entity:Rx,exposedAs:l().optional()}),Bx=x({instanceId:Sx,entity:Rx}),Vx=x({instanceId:Sx,entity:Rx}),Hx={name:`device-export`,scope:`system`,mode:`collection`,providerKind:`device-export`,status:{schema:Ax,kind:`poll`},exposesDeviceSettings:!0,methods:{getStatus:A(Cx,Ax),listInstances:A(v(),C(wx)),listSupportedDeviceKinds:A(Cx,C(Fve)),listExposedDevices:A(Cx,C(jx)),exposeDevice:A(Mx,v(),{kind:`mutation`,auth:`admin`}),unexposeDevice:A(Ix,v(),{kind:`mutation`,auth:`admin`}),setExposedName:A(Nx,v(),{kind:`mutation`,auth:`admin`}),listSupportedEntityKinds:j(v(),C(Lx)),listExposedEntities:j(Cx,C(zx)),exposeEntity:j(Bx,v(),{kind:`mutation`,auth:`admin`}),unexposeEntity:j(Vx,v(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`exports to other ecosystems — configured on the export pages`}},Ux=`exposedNames`,Ive=m(l(),l());function Wx(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 Gx(e){let t=Ive.safeParse(e[Ux]);return t.success?t.data:{}}function Lve(e,t,n){let r=Gx(e)[t];if(r===void 0)return null;let i=Wx(r,n);return i.ok?i.name:null}function Kx(e,t,n){let r=Object.fromEntries(Object.entries(Gx(e)).filter(([e])=>e!==t));return{[Ux]:n===null?r:{...r,[t]:n}}}async function Rve(e){let t=Wx(e.raw,e.validate);if(!t.ok)throw new Fx(e.instanceId,t.reason);if(e.dryRun===!0)return{changed:!1,name:t.name};let n=await e.store.read(e.deviceId);return(Gx(n)[e.instanceId]??null)===t.name?{changed:!1,name:t.name}:(await e.store.write(e.deviceId,Kx(n,e.instanceId,t.name)),{changed:!0,name:t.name})}function zve(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 Bve(e,t){let n=await e.listDeviceStoreIds();if(n.length===0)return[];let r=[];for(let[i,a]of await e.readDeviceStoreBatch(n))Gx(a)[t]!==void 0&&(await e.writeDeviceStore(i,Kx(a,t,null)),r.push(i));return r}function Vve(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 qx=[`automation`,`action`,`scheduler`,`composition`],Hve=S(qx),Jx=x({id:n().int().nonnegative(),name:l().min(1),type:l().min(1),room:l().min(1).nullable(),addonId:l().min(1),stableId:l().min(1),caps:C(l().min(1)),zones:C(l().min(1)).optional()}),Uve=x({timeZone:l().min(1),location:x({latitude:n(),longitude:n()}).nullable(),rooms:C(l().min(1)),devices:C(Jx).min(1),actions:C(x({id:l().min(1),name:l().min(1)})).default([])}),Wve=60,Yx=x({childDeviceIds:C(n()).readonly(),hiddenChildIds:C(n()).readonly()}),Xx={name:`accessories`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera,E.Switch,E.Light,E.Sensor,E.Climate,E.Cover,E.Lock,E.Fan,E.MediaPlayer,E.AlarmPanel,E.Generic],methods:{setChildHidden:A(x({deviceId:n().int().nonnegative(),childDeviceId:n().int().nonnegative(),hidden:y()}),v(),{kind:`mutation`,auth:`admin`})},events:{onAccessoriesChanged:{data:x({deviceId:n(),childDeviceIds:C(n()).readonly(),hiddenChildIds:C(n()).readonly()}),notOperatorFacing:`the device’s child list changed — administration, not a happening`},onChildVisibilityChanged:{data:x({deviceId:n(),childDeviceId:n(),hidden:y()}),notOperatorFacing:`an operator hid or showed a child — administration, not a happening`}},status:{schema:Yx,kind:`command-driven`},vocabulary:{noun:F(`Accessories`,`Accessori`),order:3e3}},Zx={name:`action-source`,scope:`system`,mode:`collection`,methods:{listActions:A(x({}),C(Zb),{auth:`admin`}),runAction:A(x({actionId:l().min(1),variables:m(l(),Hb).optional()}),v(),{kind:`mutation`,auth:`admin`}),stopAction:A(x({actionId:l().min(1)}),v(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.INTERNAL}},Gve=60*6e4,Kve=3e4,Qx=363e4;function qve(e){let t=0;for(let n of e)n.kind===`wait`&&(t+=n.seconds*1e3);return t}var $x=x({actionId:l().min(1)}),eS=x({deviceId:n().int().nonnegative(),actionIds:C(l().min(1)).max(100)}),tS={name:`actions`,scope:`system`,mode:`singleton`,methods:{list:A(x({}),C(Zb),{auth:`admin`}),get:A(x({actionId:l().min(1),deviceId:n().int().nonnegative().optional()}),x({action:Zb.nullable()}),{role:`viewer`,auth:`protected`,kind:`query`,caller:`required`}),run:A(x({actionId:l().min(1),variables:m(l(),Hb).optional(),wait:y().optional(),origin:$b.optional(),deviceId:n().int().nonnegative().optional()}),tx,{role:`viewer`,auth:`protected`,kind:`mutation`,caller:`required`,timeoutMs:Qx}),stop:A($x,v(),{kind:`mutation`,auth:`admin`}),getTraces:A($x,x({traces:C(Ay)}),{auth:`admin`}),create:A(x({action:Qb}),x({action:Zb,warnings:C(ox).optional()}),{kind:`mutation`,auth:`admin`}),update:A(x({actionId:l().min(1),action:Qb.partial()}),x({action:Zb,warnings:C(ox).optional()}),{kind:`mutation`,auth:`admin`}),delete:A($x,v(),{kind:`mutation`,auth:`admin`}),listForCamera:A(x({deviceId:n().int().nonnegative()}),C(Zb),{role:`viewer`,auth:`protected`,kind:`query`}),getLinks:A(x({deviceId:n().int().nonnegative()}),eS,{auth:`admin`}),setLinks:A(eS,eS,{kind:`mutation`,auth:`admin`})},events:{onRunChanged:{data:nx}},vocabulary:{notOperatorFacing:`declared actions — run from the Actions page and from the cameras that link them`}},Jve=x({id:l(),label:l(),icon:l(),path:l(),remoteName:l(),bundle:l(),section:l().optional(),sectionLabel:l().optional()}),nS=x({addonId:l(),page:Jve,bundleUrl:l()}),rS={name:`addon-pages`,scope:`system`,mode:`singleton`,methods:{listPages:A(v(),C(nS).readonly())},vocabulary:{notOperatorFacing:M.UI_PLUMBING}},Yve=x({method:S([`GET`,`POST`,`PUT`,`DELETE`,`PATCH`]),path:l(),access:S([`public`,`authenticated`,`admin`]).optional(),description:l().optional(),rateLimit:S([`auth`]).optional(),perInstance:y().optional()}),Xve=x({method:l(),path:l(),params:m(l(),l()),query:m(l(),l()),body:w(),headers:m(l(),l()),instanceId:l().optional(),user:x({id:l(),username:l(),isAdmin:y()}).optional(),scopedToken:w().optional()}),Zve=x({status:n().int(),headers:m(l(),l()),redirectUrl:l().nullable(),body:w().optional(),contentType:l().optional()}),iS={name:`addon-routes`,scope:`system`,mode:`collection`,internal:!0,methods:{getRoutes:A(v(),C(Yve)),invoke:A(Xve,Zve,{kind:`mutation`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:M.UI_PLUMBING}},aS=x({id:l(),label:l(),icon:l(),order:n().optional()}),oS=x({id:l(),title:l(),titleKey:l().optional(),description:l().optional(),descriptionKey:l().optional(),style:S([`card`,`accordion`]).optional(),defaultCollapsed:y().optional(),columns:h([p(1),p(2),p(3),p(4)]).optional(),tab:l().optional(),location:S([`settings`,`top-tab`,`hero`]).optional(),order:n().optional(),fields:C(ge())}),sS=x({tabs:C(aS).optional(),sections:C(oS)}),cS=m(l(),w()),lS=S(cr),Qve=x({cap:l(),scope:lS,sectionIds:C(l())}),uS=x({success:p(!0)}),dS={name:`addon-settings`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,methods:{getScopedSettings:A(x({addonId:l(),cap:l(),scope:lS,nodeId:l().optional()}),sS.nullable()),listScopedSettings:A(x({addonId:l(),nodeId:l().optional()}),C(Qve).nullable()),updateScopedSettings:A(x({addonId:l(),cap:l(),scope:lS,nodeId:l().optional(),patch:cS}),uS,{kind:`mutation`,auth:`admin`}),readScopedValues:A(x({addonId:l(),cap:l(),scope:lS,nodeId:l().optional()}),m(l(),w()).nullable()),getDeclaredSettingsKeys:A(x({addonId:l(),nodeId:l().optional()}),x({keys:C(l())}).nullable(),{auth:`admin`}),unsetStoredSettingsKeys:A(x({addonId:l(),nodeId:l().optional(),keys:C(l())}),x({removed:C(l()),refused:C(x({key:l(),reason:l()})),secretsCleared:n()}),{kind:`mutation`,auth:`admin`}),getDeviceSettings:A(x({addonId:l(),deviceId:n(),nodeId:l().optional()}),sS.nullable()),updateDeviceSettings:A(x({addonId:l(),deviceId:n(),nodeId:l().optional(),patch:cS}),uS,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.ADDON_ADMIN}},fS=S([`device-tab`,`dashboard`,`integration-detail`]),pS=S([`xs`,`sm`,`md`,`lg`,`xl`]),mS=x({remoteName:l(),exposedModule:l(),componentKey:l().optional()}),hS=x({tab:l(),subTab:l().optional(),label:l(),order:n().optional(),kind:p(`remote`),remote:mS,stableId:l(),description:l().optional(),icon:l().optional(),bundle:l(),hosts:C(fS).readonly(),requires:x({deviceContext:y().default(!1),integrationContext:y().default(!1)}),preAuth:y().optional().default(!1),defaultSize:pS.default(`md`),allowedSizes:C(pS).readonly().default([`sm`,`md`,`lg`]),defaultColumns:n().int().min(1).max(12).default(6),defaultRows:n().int().min(1).max(12).default(1)}),gS={name:`addon-widgets-source`,scope:`system`,mode:`collection`,internal:!0,methods:{listWidgets:A(v(),C(hS).readonly(),{auth:`admin`})},vocabulary:{notOperatorFacing:M.UI_PLUMBING}},_S=hS.extend({addonId:l(),bundleUrl:l()}),vS={name:`addon-widgets`,scope:`system`,mode:`singleton`,methods:{listWidgets:A(v(),C(_S).readonly())},vocabulary:{notOperatorFacing:M.UI_PLUMBING}},yS=S([`install`,`update`,`uninstall`,`restart`]),bS=S([`queued`,`fetching`,`staged`,`validating`,`applying`,`restarting`,`applied`,`done`,`failed`,`skipped`]),xS=S([`framework`,`addon`]),SS=x({tsMs:n(),nodeId:l(),packageName:l(),phase:bS,message:l()}),CS=x({taskId:l(),nodeId:l(),packageName:l(),fromVersion:l().nullable(),toVersion:l(),target:xS,phase:bS,stagedPath:l().nullable(),attempts:n(),steps:C(SS),error:l().nullable(),startedAtMs:n().nullable(),finishedAtMs:n().nullable()}),wS=S([`running`,`completed`,`failed`,`partially-failed`,`cancelled`]),TS=S([`single`,`bulk`,`cluster`]),ES=x({jobId:l(),kind:yS,createdAtMs:n(),createdBy:l(),scope:TS,tasks:C(CS),state:wS,schemaVersion:p(1)}),DS=S([`debug`,`info`,`warn`,`error`]),OS=S([`off`,`latest`,`beta`]),kS=S([`off`,`latest`,`beta`,`inherit`]),$ve=x({id:l(),name:l().optional(),version:l().optional(),description:l().optional(),icon:l().optional(),color:l().optional(),capabilities:C(w()).readonly().optional(),packageName:l(),packageVersion:l(),packageDisplayName:l().optional(),bundle:x({displayName:l(),description:l().optional(),icon:l().optional()}).optional(),protected:y().optional(),removable:y().optional(),integrationSection:S([`system`,`providers`]).optional()}),eye=x({pid:n().optional(),mode:l(),state:l(),reason:l().optional()}),tye=x({phase:S([`pending`,`healthy`,`failed`]),retryCount:n(),firstFailureAt:n().nullable(),lastAttemptAt:n().nullable(),lastError:x({message:l(),stack:l().optional()}).nullable(),nextRetryAt:n().nullable(),alertEmitted:y(),retrying:y(),inGracePeriod:y()}),AS=x({manifest:$ve,declaration:w().optional(),source:l(),installSource:l().optional(),process:eye.optional(),hasBackup:y().optional(),health:tye.nullable().optional()}),jS=x({name:l(),version:l(),dir:l(),installSource:l().optional()}),MS=x({name:l(),currentVersion:l(),latestVersion:l(),category:S([`addon`,`core`]),requiresRestart:y(),isSystem:y(),blockedBy:C(Pu).readonly().optional()}),NS=x({version:l(),publishedAt:l(),deprecated:l().optional(),distTags:C(l()).readonly()}),PS=i(`status`,[x({status:p(`ok`),markdown:l()}),x({status:p(`missing`)}),x({status:p(`error`),message:l()})]),nye=x({name:l(),version:l(),readme:PS,changelog:PS}),FS=x({name:l(),version:l(),description:l(),keywords:C(l()).readonly(),publishedAt:l(),author:l(),installed:y(),installedVersion:l().optional(),capabilities:C(l()).readonly().nullable()}),IS=x({channel:OS,intervalSeconds:n(),updateCheckIntervalSeconds:n()}),LS=kS,rye=w(),iye=w(),aye=w(),RS=S([`uninstalled`,`not-installed`,`refused`,`failed`,`pending-reconnect`]),zS=x({nodeId:l(),outcome:RS,error:l().optional(),addonIds:C(l()).readonly(),runnersStopped:C(l()).readonly(),warnings:C(l()).readonly()}),BS=x({success:y(),packageName:l(),results:C(zS).readonly()}),VS=x({packageName:l(),nodeId:l(),nodeName:l(),isHub:y(),isOnline:y(),version:l().nullable(),addonIds:C(l()).readonly(),source:S([`live`,`recorded`]),onHub:y()}),HS=x({installations:C(VS).readonly(),unreachable:C(x({nodeId:l(),error:l()})).readonly()}),oye=S([`queued`,`updating`,`done`,`done-pending-restart`,`failed`]),sye=x({name:l(),isSystem:y(),fromVersion:l(),toVersion:l(),status:oye,error:l().optional(),startedAtMs:n().optional(),completedAtMs:n().optional()}),cye=S([`regular`,`system`,`restarting`,`finalizing`]);x({id:l(),nodeId:l(),startedAtMs:n(),completedAtMs:n().optional(),total:n(),completed:n(),failed:n(),current:l().nullable(),phase:cye,cancelled:y(),items:C(sye).readonly()});var lye=x({packageName:l(),currentVersion:l(),latestVersion:l().nullable(),hasUpdate:y(),description:l().optional(),buildId:l().nullable()}),US=x({timestamp:l(),level:l(),message:l(),scope:l().optional()}),uye=w(),WS=x({addonId:l().min(1),action:l().min(1),input:w()}),GS={name:`addons`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,methods:{list:A(x({nodeId:l().optional()}).optional(),C(AS).readonly()),getLogs:A(x({addonId:l(),limit:n().min(1).max(500).default(100),level:DS.optional()}),C(uye)),listPackages:A(v(),C(jS).readonly()),installPackage:A(x({packageName:l(),version:l().optional()}),iye,{kind:`mutation`,auth:`admin`}),uninstallPackage:A(x({packageName:l().min(1),nodeId:l().optional(),everywhere:y().optional()}),BS,{kind:`mutation`,auth:`admin`}),listInstallations:A(x({packageName:l().optional()}),HS,{auth:`admin`}),reloadPackages:A(v(),aye,{kind:`mutation`,auth:`admin`}),searchAvailable:A(x({query:l().optional(),capability:l().optional()}),C(FS)),listUpdates:A(x({nodeId:l().optional()}),C(MS).readonly(),{auth:`admin`}),updatePackage:A(x({name:l().min(1),version:l().optional(),nodeId:l().optional()}),w(),{kind:`mutation`,auth:`admin`}),rollbackPackage:A(x({name:l().min(1)}),x({rolledBackTo:l().nullable()}),{kind:`mutation`,auth:`admin`}),forceRefresh:A(x({nodeId:l().optional()}),w(),{kind:`mutation`,auth:`admin`}),restartServer:A(x({confirm:p(!0)}),w(),{kind:`mutation`,auth:`admin`}),getLastRestart:A(v(),x({kind:S([`framework-update`,`manual`,`system`,`framework-bulk-update`]),packageName:l().optional(),fromVersion:l().optional(),toVersion:l().optional(),requestedBy:l().optional(),requestedAt:n()}).nullable(),{auth:`admin`}),listFrameworkPackages:A(v(),C(lye).readonly(),{auth:`admin`}),listCapabilityProviders:A(x({capName:l().min(1)}),C(x({addonId:l(),mode:S([`singleton`,`collection`]),isActive:y()})).readonly()),setCapabilityProviderEnabled:A(x({capName:l().min(1),addonId:l().min(1),enabled:y()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getVersions:A(x({name:l()}),C(NS).readonly()),getPackageDocs:A(x({name:l().min(1),version:l().min(1).optional()}),nye,{auth:`admin`}),restartAddon:A(x({addonId:l()}),rye,{kind:`mutation`,auth:`admin`}),retryLoad:A(x({packageName:l()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getAutoUpdateSettings:A(v(),IS,{auth:`admin`}),setAutoUpdateSettings:A(x({channel:OS,intervalSeconds:n().min(300).max(86400).optional(),updateCheckIntervalSeconds:n().min(900).max(604800).optional()}),w(),{kind:`mutation`,auth:`admin`}),getAddonAutoUpdate:A(x({addonId:l()}),LS,{auth:`admin`}),setAddonAutoUpdate:A(x({addonId:l(),channel:kS}),w(),{kind:`mutation`,auth:`admin`}),applyAutoUpdateToAll:A(x({channel:OS}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),custom:A(WS,w(),{role:`viewer`,kind:`mutation`}),startJob:A(x({kind:S([`install`,`update`,`uninstall`,`restart`]),targets:C(x({name:l().min(1),version:l().min(1)})).min(1),nodeIds:C(l()).optional()}),x({jobId:l()}),{kind:`mutation`,auth:`admin`}),getJob:A(x({jobId:l()}),ES.nullable(),{auth:`admin`}),listJobs:A(x({activeOnly:y().optional()}),C(ES),{auth:`admin`}),cancelJob:A(x({jobId:l()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),onAddonLogs:A(x({addonId:l(),level:DS.optional()}),US,{kind:`subscription`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:M.ADDON_ADMIN}},KS=x({co2:n().min(0).optional().meta(N(`concentration-volume`)),voc:n().min(0).optional().meta(N(`concentration-ppb`)),pm25:n().min(0).optional().meta(N(`concentration-mass`)),pm10:n().min(0).optional().meta(N(`concentration-mass`)),aqi:n().optional().meta(N(`index`)),lastFetchedAt:n()}),qS={name:`air-quality-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:KS,kind:`push`},runtimeState:KS,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:F(`Air quality`,`Qualità dell’aria`),order:5e3,state:[{kind:`numeric`,field:`co2`,quantity:F(`the CO₂`,`la CO₂`),label:F(`CO₂`,`CO₂`),unit:`ppm`,icon:`wind`},{kind:`numeric`,field:`voc`,quantity:F(`the VOC level`,`il livello di COV`),label:F(`VOC`,`COV`),unit:`ppb`,icon:`wind`},{kind:`numeric`,field:`pm25`,quantity:F(`the PM2.5`,`il PM2,5`),label:F(`PM2.5`,`PM2,5`),unit:`µg/m³`,icon:`cloud-fog`},{kind:`numeric`,field:`pm10`,quantity:F(`the PM10`,`il PM10`),label:F(`PM10`,`PM10`),unit:`µg/m³`,icon:`cloud-fog`},{kind:`numeric`,field:`aqi`,quantity:F(`the air quality index`,`l’indice di qualità dell’aria`),label:F(`AQI`,`IQA`),icon:`wind`}]}},JS=S([`disarmed`,`armed_home`,`armed_away`,`armed_night`,`armed_vacation`,`armed_custom_bypass`,`arming`,`disarming`,`pending`,`triggered`]),YS=S([`home`,`away`,`night`,`vacation`,`custom_bypass`]),XS=x({state:JS,targetMode:YS.nullable().optional(),availableModes:C(YS),codeRequired:y().nullable(),lastChangedAt:n()}),ZS={name:`alarm-panel`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.AlarmPanel],methods:{trigger:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`alarm.trigger`,label:F(`Trigger alarm`,`Fai scattare l’allarme`),phrase:F(`Trigger the alarm on {device}`,`Fai scattare l’allarme su {device}`),icon:`siren`}]}),disarm:A(x({deviceId:n().int().nonnegative(),code:l().min(1).optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`alarm.disarm`,label:F(`Disarm`,`Disinserisci`),phrase:F(`Disarm {device}`,`Disinserisci {device}`),icon:`shield-off`,effect:{field:`state`,value:`disarmed`},hold:{effects:[{field:`state`,value:`disarming`,when:{field:`state`,notIn:[`disarmed`]}}]},openArgs:[{key:`code`,label:F(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]}),arm:A(x({deviceId:n().int().nonnegative(),mode:YS,code:l().min(1).optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`alarm.arm.home`,label:F(`Arm home`,`Inserisci in casa`),phrase:F(`Arm {device} for home`,`Inserisci {device} in modalità casa`),icon:`house`,effect:{field:`state`,value:`armed_home`},hold:{effects:[{field:`state`,value:`arming`,when:{field:`state`,notIn:[`armed_home`]}}]},args:{mode:`home`},openArgs:[{key:`code`,label:F(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.away`,label:F(`Arm away`,`Inserisci fuori casa`),phrase:F(`Arm {device} for away`,`Inserisci {device} in modalità fuori casa`),icon:`shield-check`,effect:{field:`state`,value:`armed_away`},hold:{effects:[{field:`state`,value:`arming`,when:{field:`state`,notIn:[`armed_away`]}}]},args:{mode:`away`},openArgs:[{key:`code`,label:F(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.night`,label:F(`Arm night`,`Inserisci notte`),phrase:F(`Arm {device} for the night`,`Inserisci {device} in modalità notte`),icon:`moon`,effect:{field:`state`,value:`armed_night`},hold:{effects:[{field:`state`,value:`arming`,when:{field:`state`,notIn:[`armed_night`]}}]},args:{mode:`night`},openArgs:[{key:`code`,label:F(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.vacation`,label:F(`Arm vacation`,`Inserisci vacanza`),phrase:F(`Arm {device} for vacation`,`Inserisci {device} in modalità vacanza`),icon:`plane`,effect:{field:`state`,value:`armed_vacation`},hold:{effects:[{field:`state`,value:`arming`,when:{field:`state`,notIn:[`armed_vacation`]}}]},args:{mode:`vacation`},openArgs:[{key:`code`,label:F(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.custom_bypass`,label:F(`Arm custom bypass`,`Inserisci con esclusioni`),phrase:F(`Arm {device} with its custom bypass`,`Inserisci {device} con le zone escluse`),icon:`shield-half`,effect:{field:`state`,value:`armed_custom_bypass`},hold:{effects:[{field:`state`,value:`arming`,when:{field:`state`,notIn:[`armed_custom_bypass`]}}]},args:{mode:`custom_bypass`},openArgs:[{key:`code`,label:F(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]})},status:{schema:XS,kind:`push`},runtimeState:XS,durability:`restored`,restoredFieldRenames:{requiresCode:`codeRequired`},history:{fields:{state:{kind:`enum`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Alarm panel`,`Centrale d’allarme`),order:1120,state:[{kind:`enum`,field:`state`,label:F(`Alarm state`,`Stato dell’allarme`),values:[{value:`disarmed`,label:F(`Disarmed`,`Disinserito`),phrase:F(`When {device} is disarmed`,`Quando {device} viene disinserito`)},{value:`armed_home`,label:F(`Armed home`,`Inserito in casa`),phrase:F(`When {device} is armed for home`,`Quando {device} viene inserito in modalità casa`)},{value:`armed_away`,label:F(`Armed away`,`Inserito fuori casa`),phrase:F(`When {device} is armed for away`,`Quando {device} viene inserito in modalità fuori casa`)},{value:`armed_night`,label:F(`Armed night`,`Inserito notte`),phrase:F(`When {device} is armed for the night`,`Quando {device} viene inserito in modalità notte`)},{value:`armed_vacation`,label:F(`Armed vacation`,`Inserito vacanza`)},{value:`armed_custom_bypass`,label:F(`Armed with bypass`,`Inserito con esclusioni`)},{value:`arming`,label:F(`Arming`,`In inserimento`)},{value:`disarming`,label:F(`Disarming`,`In disinserimento`)},{value:`pending`,label:F(`Entry delay`,`Ritardo d’ingresso`)},{value:`triggered`,label:F(`Triggered`,`In allarme`),phrase:F(`When {device} goes off`,`Quando {device} scatta`)}],icon:`shield`}]}},QS=S([`info`,`success`,`warning`,`error`,`critical`]),dye=x({addonId:l().min(1),action:l().min(1),input:m(l(),w()).optional()}),fye=x({label:l(),href:l().optional(),invoke:dye.optional(),navigation:S([`app`,`server`]).optional()}),$S=S([`active`,`in-progress`,`completed`,`failed`,`dismissed`]),eC=x({type:l(),id:l()}),tC=x({id:l(),category:l(),severity:QS,title:l(),message:l(),action:fye.optional(),status:$S,progress:n().optional(),read:y(),createdAt:n(),updatedAt:n(),source:eC.optional(),metadata:m(l(),w()).optional()}),nC={name:`alerts`,scope:`system`,mode:`singleton`,methods:{emit:A(tC,v(),{kind:`mutation`}),update:A(x({alertId:l(),patch:tC.partial()}),v(),{kind:`mutation`}),list:A(x({unreadOnly:y().optional(),limit:n().optional()}).optional(),C(tC).readonly()),getUnreadCount:A(v(),n()),markRead:A(x({alertId:l()}),v(),{kind:`mutation`}),markAllRead:A(v(),v(),{kind:`mutation`}),dismiss:A(x({alertId:l()}),v(),{kind:`mutation`})},vocabulary:{notOperatorFacing:`the alert centre — read and acknowledged on its own page`}},rC=x({illuminance:n().min(0).nullable().meta(N(`illuminance`,{precision:0,label:`Illuminance`})),lastFetchedAt:n()}),iC={name:`ambient-light-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:rC,kind:`push`},runtimeState:rC,durability:`restored`,history:{fields:{illuminance:{kind:`gauge`,unit:`lx`,deadbandPct:10,minIntervalMs:6e4}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Light level`,`Luminosità ambiente`),order:5010,state:[{kind:`numeric`,field:`illuminance`,quantity:F(`the light level`,`la luminosità`),label:F(`Illuminance`,`Illuminamento`),unit:`lx`,icon:`sun`}]}},aC={name:`audio-analysis`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[E.Camera],exposesDeviceSettings:!0,methods:{resolveDeviceSettings:A(x({deviceId:n()}),ve())},events:{onAudioLevel:ni(x({deviceId:n(),rms:n(),dbfs:n()}),{notOperatorFacing:`a sound-level sample at stream rate; loud-noise rules belong to the detection pipeline`})},vocabulary:{noun:F(`Audio analysis`,`Analisi audio`),order:3010}},pye=S([`jpeg`,`rgb`,`bgr`,`yuv420`,`gray`]),oC=x({data:ve(),format:pye,width:n(),height:n(),timestamp:n()}),sC=x({x:n(),y:n(),w:n(),h:n()}),mye=x({class:l(),originalClass:l(),score:n(),bbox:sC}),cC=x({data:b(Uint8Array),sampleRate:n(),channels:n(),timestamp:n(),deviceId:n().optional()}),lC=x({rms:n(),dbfs:n()}),uC=x({className:l(),originalClass:l().optional(),score:n()}),dC=[`superseded`,`error`,`timeout`,`disposed`],fC=i(`state`,[x({state:p(`classified`)}),x({state:p(`not-classified`),reason:S(dC)})]),pC=x({level:lC,classification:x({labels:C(uC).readonly(),inferenceMs:n()}).optional(),classifyOutcome:fC,timestamp:n()}),mC=x({minConfidence:n().min(0).max(1).default(.3),allowedClasses:C(l()).default([])}),hC=x({deviceId:n(),brokerId:l(),ingestNodeId:l(),settings:mC}),gC=x({attached:y(),replaced:y()}),_C=x({detached:y()}),vC=x({labels:C(uC).readonly(),rawLabels:C(uC).readonly().optional(),inferenceMs:n()}),hye=[{value:`auto`,label:`Auto (platform default)`},{value:`apple-soundanalysis`,label:`Apple SoundAnalysis (macOS 12+)`},{value:`yamnet-onnx`,label:`YAMNet ONNX (cross-platform)`}],gye={audioBackend:`auto`,probedBestAudioBackend:``},yC={name:`audio-analyzer`,scope:`system`,mode:`singleton`,methods:{analyseChunk:A(x({chunk:cC,settings:mC}),pC.nullable(),{kind:`mutation`}),classify:A(cC,vC,{timeoutMs:3e4}),attachDevice:A(hC,gC,{kind:`mutation`}),detachDevice:A(x({deviceId:n()}),_C,{kind:`mutation`}),isReady:A(v(),y()),dispose:A(v(),v(),{kind:`mutation`}),reprobeAudioEngine:A(v(),x({backend:l()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.PIPELINE}},bC=S([`f32le`,`s16le`]),xC=x({codec:l(),canDecode:y(),canEncode:y(),label:l().optional()}),SC=x({codec:l(),sourceSampleRate:n().int().positive(),sourceChannels:n().int().positive(),extraData:b(Uint8Array).optional(),targetSampleRate:n().int().positive(),targetChannels:n().int().positive(),targetFormat:bC.optional(),idleMs:n().int().positive().optional(),tag:l().optional()}),CC=x({codec:l(),sourceSampleRate:n().int().positive(),sourceChannels:n().int().positive(),sourceFormat:bC.optional(),targetSampleRate:n().int().positive(),targetChannels:n().int().positive(),bitrateKbps:n().int().positive().optional(),idleMs:n().int().positive().optional(),tag:l().optional()}),wC=x({data:b(Uint8Array),sampleRate:n().int().positive(),channels:n().int().positive(),format:bC,pts:n()}),TC=x({data:b(Uint8Array),codec:l(),pts:n(),frameComplete:y()}),_ye=x({sessionId:l(),kind:S([`decode`,`encode`]),codec:l(),sourceSampleRate:n(),sourceChannels:n(),targetSampleRate:n(),targetChannels:n(),format:bC,tag:l().optional(),createdAtMs:n(),lastActivityMs:n(),framesIn:n(),framesOut:n()}),EC={name:`audio-codec`,scope:`system`,mode:`singleton`,preferredProvider:`decoder-nodeav`,methods:{listSupportedCodecs:A(v(),C(xC).readonly()),canHandle:A(x({codec:l(),kind:S([`decode`,`encode`])}),y()),createDecodeSession:A(SC,x({sessionId:l(),nodeId:l()}),{kind:`mutation`}),createEncodeSession:A(CC,x({sessionId:l(),nodeId:l()}),{kind:`mutation`}),closeSession:A(x({sessionId:l(),nodeId:l().optional()}),v(),{kind:`mutation`}),pushEncodedFrame:A(x({sessionId:l(),nodeId:l().optional(),data:b(Uint8Array),pts:n().optional()}),v(),{kind:`mutation`}),pullPcm:A(x({sessionId:l(),nodeId:l().optional(),maxCount:n().int().positive().default(8)}),C(wC)),pushPcm:A(x({sessionId:l(),nodeId:l().optional(),data:b(Uint8Array),pts:n().optional()}),v(),{kind:`mutation`}),pullEncoded:A(x({sessionId:l(),nodeId:l().optional(),maxCount:n().int().positive().default(8)}),C(TC)),flushEncode:A(x({sessionId:l(),nodeId:l().optional()}),C(TC),{kind:`mutation`}),listActiveSessions:A(v(),C(_ye).readonly())},vocabulary:{notOperatorFacing:M.INTERNAL}},DC=x({className:l(),hits:n().int().nonnegative(),avgScore:n().min(0).max(1),peakScore:n().min(0).max(1)}),OC=x({ts:n().int(),windowSec:n().int().positive(),level:x({rms:n(),dbfs:n()}),peakDbfs:n(),avgDbfs:n(),current:x({className:l(),score:n().min(0).max(1),timestamp:n().int()}).nullable(),byClass:C(DC).readonly()}),kC=x({ts:n().int(),dbfs:n().nullable(),peakDbfs:n(),avgDbfs:n(),topClass:l().nullable(),topScore:n().min(0).max(1).nullable()}),AC=x({points:C(kC).readonly(),effectiveSampleEveryMs:n().int().positive(),windowMsActual:n().int().nonnegative()}),jC={name:`audio-metrics`,scope:`device`,mode:`singleton`,deviceTypes:[E.Camera],methods:{getCurrentSnapshot:A(x({deviceId:n()}),OC.nullable()),getHistory:A(x({deviceId:n(),windowSec:n().int().positive().optional(),sampleEveryMs:n().int().positive().optional()}),AC)},runtimeState:OC,durability:`session`,history:`none`,vocabulary:{noun:F(`Audio metrics`,`Metriche audio`),order:3020}},MC=x({userId:l(),username:l(),email:l().optional(),displayName:l().optional(),isAdmin:y().default(!1)}),NC={name:`auth-provider`,scope:`system`,mode:`collection`,internal:!0,methods:{validateCredentials:A(x({username:l(),password:l()}),MC.nullable(),{kind:`mutation`}),getLoginUrl:A(x({state:l()}),l()),handleCallback:A(m(l(),l()),MC,{kind:`mutation`}),validateToken:A(x({token:l()}),MC.nullable())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:M.IDENTITY}},PC=x({enabled:y(),isRunning:y(),lastTriggeredAt:n(),lastError:l().nullable(),lastChangedAt:n()}),FC={name:`automation-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Automation],methods:{enable:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`haAutomation.enable`,effect:{field:`enabled`,value:!0},label:F(`Enable automation`,`Abilita l’automazione`),phrase:F(`Enable {device}`,`Abilita {device}`),icon:`toggle-right`}]}),disable:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`haAutomation.disable`,effect:{field:`enabled`,value:!1},label:F(`Disable automation`,`Disabilita l’automazione`),phrase:F(`Disable {device}`,`Disabilita {device}`),icon:`toggle-left`}]}),trigger:A(x({deviceId:n().int().nonnegative(),skipCondition:y().optional()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`haAutomation.trigger`,label:F(`Trigger automation`,`Avvia l’automazione`),phrase:F(`Run {device} now`,`Esegui subito {device}`),icon:`workflow`}]})},status:{schema:PC,kind:`push`},runtimeState:PC,durability:`session`,history:`none`,vocabulary:{noun:F(`Automation`,`Automazione`),order:2100,state:[{kind:`boolean`,field:`enabled`,label:F(`Enabled`,`Abilitata`),whenTrue:F(`When {device} is enabled`,`Quando {device} viene abilitata`),whenFalse:F(`When {device} is disabled`,`Quando {device} viene disabilitata`),icon:`toggle-right`},{kind:`boolean`,field:`isRunning`,label:F(`Running`,`In esecuzione`),whenTrue:F(`When {device} starts running`,`Quando {device} parte`),whenFalse:F(`When {device} finishes`,`Quando {device} termina`),icon:`workflow`}]}},vye=`.backup-snapshot`,yye=`.backup-snapshot-partial`,IC=30*6e4,LC=x({databases:C(x({databaseId:yf,livePath:l()}))}),RC=x({name:l(),rows:n().int().nonnegative()}),zC=x({livePath:l(),snapshotPath:l(),sizeBytes:n().int().nonnegative(),pageCount:n().int().nonnegative(),pageSize:n().int().positive(),tables:C(RC),copyMs:n().nonnegative(),verifyMs:n().nonnegative(),takenAt:n()}),BC=zC.extend({databaseId:yf}),VC=x({databaseId:yf}),HC=zC.extend({livePath:l(),snapshotPath:l(),databaseId:yf.optional()}),UC={name:`database-snapshot`,scope:`system`,mode:`singleton`,internal:!0,methods:{listDatabases:A(x({}),LC,{auth:`admin`}),writeSnapshot:A(VC,BC,{kind:`mutation`,auth:`admin`,timeoutMs:IC})},vocabulary:{notOperatorFacing:M.INTERNAL}},WC=x({subId:l(),displayName:l(),description:l().optional(),kind:l(),triggerSupported:y(),restoreSupported:y()}).extend({id:l(),addonId:l(),enabled:y(),retentionCount:n(),label:l().optional(),lastSuccessAt:n().optional(),lastSuccessSizeBytes:n().optional(),cron:l().optional(),nextRunAt:n().optional(),lastAttemptAt:n().optional(),lastError:l().optional()}),GC=x({scheme:l(),keyId:l()}),KC=x({enabled:y(),active:x({keyId:l(),publicKey:l(),createdAt:n()}).nullable(),keys:C(x({keyId:l(),createdAt:n(),retiredAt:n().nullable()})).readonly()}),bye=x({id:l(),filename:l(),createdAt:n(),sizeBytes:n(),label:l().optional(),locations:C(l()).readonly(),encryption:GC.optional(),databases:C(yf).readonly().optional()}),qC=x({id:l(),destinationId:l().optional(),label:l().optional(),createdAt:n(),sizeBytes:n(),locations:C(l()).optional(),encryption:GC.optional()}),JC=x({path:l(),kind:S([`file`,`dir`,`symlink`]),sizeBytes:n(),mtime:n()}),YC=x({archiveVersion:p(1),createdAt:n(),dataDir:l(),locations:C(l()),entries:C(JC),totalBytes:n(),totalFiles:n(),sqliteSnapshots:C(HC).optional(),omittedDatabases:C(yf).optional()}),XC=x({name:l(),sizeBytes:n(),fileCount:n(),present:y()}),ZC=S([`queued`,`running`,`succeeded`,`failed`,`cancelled`]),QC=S([`queued`,`building`,`uploading`,`done`]),$C=x({id:l(),state:ZC,phase:QC,destinationIds:C(l()).readonly(),label:l().optional(),requestedAt:n(),startedAt:n().optional(),finishedAt:n().optional(),stagedBytes:n(),archiveSizeBytes:n().optional(),uploadedBytes:n(),completedDestinationIds:C(l()).readonly(),failedDestinationIds:C(l()).readonly(),error:l().optional(),queuePosition:n().int().min(1).optional()}),ew=x({runId:l(),queued:y(),joined:y(),cancelled:y(),entries:C(qC).readonly()}),tw=x({id:l(),label:l(),cron:l(),enabled:y(),locationIds:C(l()).readonly(),retentionCount:n().int().min(1).max(1e3),dataSources:C(l()).readonly().optional(),databases:C(yf).readonly().optional(),lastAttemptAt:n().optional(),lastSuccessAt:n().optional(),lastError:l().optional(),nextRunAt:n().optional()}),nw={name:`backup`,scope:`system`,mode:`singleton`,methods:{listDestinations:A(v(),C(WC).readonly(),{auth:`admin`}),trigger:A(x({destinations:C(l()).optional(),locations:C(l()).optional(),label:l().optional(),retentionCount:n().int().min(1).max(1e3).optional(),databases:C(yf).optional()}).optional(),ew,{kind:`mutation`,auth:`admin`}),listRuns:A(v(),C($C).readonly(),{auth:`admin`}),cancel:A(x({runId:l()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),list:A(v(),C(qC).readonly(),{auth:`admin`}),listLocations:A(v(),C(XC).readonly(),{auth:`admin`}),getEntries:A(x({destinationId:l(),backupId:l()}),YC.nullable(),{auth:`admin`}),restore:A(x({destinationId:l(),backupId:l(),locations:C(l()).optional(),backupSecretKey:l().optional()}),v(),{kind:`mutation`,auth:`admin`}),getEncryption:A(v(),KC,{auth:`admin`}),setupEncryption:A(x({}),x({keyId:l(),secretKey:l(),publicKey:l(),createdAt:n(),replacedKeyId:l().nullable()}),{kind:`mutation`,auth:`admin`}),disableEncryption:A(x({}),x({disabledKeyId:l().nullable()}),{kind:`mutation`,auth:`admin`}),checkBackupKey:A(x({backupSecretKey:l()}),x({valid:y(),keyId:l().nullable(),known:y(),active:y(),error:l().optional()}),{kind:`mutation`,auth:`admin`}),delete:A(x({destinationId:l(),backupId:l()}),v(),{kind:`mutation`,auth:`admin`}),listArchives:A(x({destinationId:l()}),C(bye).readonly(),{auth:`admin`}),upsertDestinationPolicy:A(x({locationId:l(),enabled:y(),retentionCount:n().int().min(1).max(1e3),label:l().optional()}),v(),{kind:`mutation`,auth:`admin`}),previewSchedule:A(x({cron:l(),count:n().int().min(1).max(20).optional()}),x({ok:y(),error:l().optional(),nextRuns:C(n()).readonly()})),listSchedules:A(v(),C(tw).readonly(),{auth:`admin`}),listAvailableDatabases:A(v(),x({answered:y(),databases:C(yf).readonly()}),{auth:`admin`}),upsertSchedule:A(x({id:l().optional(),label:l(),cron:l(),enabled:y(),locationIds:C(l()).readonly(),retentionCount:n().int().min(1).max(1e3),dataSources:C(l()).readonly().optional(),databases:C(yf).readonly().optional()}),tw,{kind:`mutation`,auth:`admin`}),deleteSchedule:A(x({id:l()}),v(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`system backups — run and restored from the Backups page`}},rw=x({level:n().min(0).max(100).nullable().meta(N(`percentage`,{label:`Charge`})),charging:S([`dc`,`solar`,`none`,`unknown`]).meta({label:`Charging source`}),sleeping:y().meta({label:`Sleeping`}),lastUpdated:n().meta(N(`none`)),voltage:n().nullable().optional().meta(N(`voltage`,{label:`Voltage`})),chargeState:S([`charging`,`full`,`idle`,`unknown`]).optional().meta({label:`Charge state`}),currentMa:n().nullable().optional().meta(N(`none`,{label:`Current (mA)`})),temperatureC:n().nullable().optional().meta(N(`temperature`,{label:`Temperature`})),lastContactAt:n().optional(),lastFullRefreshAt:n().optional(),binary:y().optional().meta({label:`Binary indicator`})}),iw=[E.Camera,E.Sensor,E.Button,E.Switch,E.PetFeeder,E.Container,E.Climate,E.EventEmitter],xye={version:1,targets:[{id:`level`,cardinality:`scalar`,vocabulary:{cap:`battery`,stateField:`level`},deviceTypes:iw,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}]},aw={name:`battery`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:iw,methods:{},events:{onStatusChanged:{data:x({deviceId:n(),status:rw}),notOperatorFacing:`the level / sleeping / charging state triggers each read one field of this change`}},status:{schema:rw,kind:`push`,empty:{level:null,charging:`unknown`,sleeping:!1,lastUpdated:0}},runtimeState:rw,durability:`restored`,history:{fields:{level:{kind:`gauge`,unit:`%`},voltage:{kind:`gauge`,unit:`V`},temperatureC:{kind:`gauge`,unit:`°C`}}},customize:xye,volatileStateFields:[`lastUpdated`],vocabulary:{noun:F(`Battery`,`Batteria`),order:5240,state:[{kind:`numeric`,field:`level`,quantity:F(`the battery level`,`il livello della batteria`),label:F(`Battery`,`Batteria`),unit:`%`,icon:`battery`},{kind:`boolean`,field:`sleeping`,label:F(`Asleep`,`In sospensione`),whenTrue:F(`When {device} goes to sleep`,`Quando {device} va in sospensione`),whenFalse:F(`When {device} wakes up`,`Quando {device} si risveglia`),icon:`moon`},{kind:`enum`,field:`charging`,label:F(`Charging`,`Ricarica`),values:[{value:`dc`,label:F(`Charging from mains`,`In carica da rete`),phrase:F(`When {device} starts charging`,`Quando {device} inizia a caricarsi`)},{value:`solar`,label:F(`Charging from solar`,`In carica dal pannello solare`),phrase:F(`When {device} charges from its solar panel`,`Quando {device} si carica dal pannello solare`)},{value:`none`,label:F(`Not charging`,`Non in carica`),phrase:F(`When {device} stops charging`,`Quando {device} smette di caricarsi`)},{value:`unknown`,label:F(`Unknown`,`Sconosciuto`)}],icon:`battery-charging`},{kind:`enum`,field:`chargeState`,label:F(`Charge state`,`Stato di carica`),values:[{value:`charging`,label:F(`Charging`,`In carica`)},{value:`full`,label:F(`Full`,`Carica completa`)},{value:`idle`,label:F(`Not charging`,`Non in carica`)},{value:`unknown`,label:F(`Unknown`,`Sconosciuto`)}],icon:`battery-charging`}],extraEvents:[{category:T.DeviceAwake,label:F(`Woke up`,`Risvegliato`),phrase:F(`When {device} wakes up`,`Quando {device} si risveglia`),icon:`sun`},{category:T.DeviceSleeping,label:F(`Went to sleep`,`In sospensione`),phrase:F(`When {device} goes to sleep`,`Quando {device} va in sospensione`),icon:`moon`}]}},ow=x({on:y().meta({label:`On`}),lastChangedAt:n()}),sw={name:`binary`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:ow,kind:`push`},runtimeState:ow,durability:`restored`,history:{fields:{on:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Binary sensor`,`Sensore binario`),order:5020,state:[{kind:`boolean`,field:`on`,label:F(`On`,`Acceso`),whenTrue:F(`When {device} turns active`,`Quando {device} si attiva`),whenFalse:F(`When {device} turns inactive`,`Quando {device} si disattiva`),icon:`toggle-right`}],overrides:{byRole:{[O.MotionSensor]:{state:{on:{label:F(`Motion`,`Movimento`),whenTrue:F(`When {device} detects motion`,`Quando {device} rileva movimento`),whenFalse:F(`When motion clears on {device}`,`Quando il movimento su {device} cessa`),icon:`activity`}}},[O.ContactSensor]:{state:{on:{label:F(`Open`,`Aperto`),whenTrue:F(`When {device} opens`,`Quando {device} si apre`),whenFalse:F(`When {device} closes`,`Quando {device} si chiude`),icon:`door-open`}}},[O.LeakSensor]:{state:{on:{label:F(`Leak`,`Perdita`),whenTrue:F(`When {device} detects a leak`,`Quando {device} rileva una perdita`),whenFalse:F(`When {device} is dry again`,`Quando {device} torna asciutto`),icon:`droplets`}}},[O.SmokeSensor]:{state:{on:{label:F(`Smoke`,`Fumo`),whenTrue:F(`When {device} detects smoke`,`Quando {device} rileva fumo`),whenFalse:F(`When smoke clears on {device}`,`Quando il fumo su {device} si dirada`),icon:`alarm-smoke`}}},[O.COSensor]:{state:{on:{label:F(`Carbon monoxide`,`Monossido di carbonio`),whenTrue:F(`When {device} detects carbon monoxide`,`Quando {device} rileva monossido di carbonio`),whenFalse:F(`When the carbon monoxide clears on {device}`,`Quando il monossido su {device} rientra`),icon:`cloud-alert`}}},[O.GasSensor]:{state:{on:{label:F(`Gas`,`Gas`),whenTrue:F(`When {device} detects gas`,`Quando {device} rileva gas`),whenFalse:F(`When the gas clears on {device}`,`Quando il gas su {device} rientra`),icon:`flame`}}},[O.TamperSensor]:{state:{on:{label:F(`Tampered`,`Manomesso`),whenTrue:F(`When {device} is tampered with`,`Quando {device} viene manomesso`),whenFalse:F(`When the tamper alert on {device} clears`,`Quando l’allarme di manomissione di {device} rientra`),icon:`shield-alert`}}},[O.VibrationSensor]:{state:{on:{label:F(`Vibration`,`Vibrazione`),whenTrue:F(`When {device} vibrates`,`Quando {device} vibra`),whenFalse:F(`When {device} is still again`,`Quando {device} torna fermo`),icon:`vibrate`}}},[O.ConnectivitySensor]:{state:{on:{label:F(`Connected`,`Connesso`),whenTrue:F(`When {device} connects`,`Quando {device} si connette`),whenFalse:F(`When {device} disconnects`,`Quando {device} si disconnette`),icon:`wifi`}}},[O.SoundSensor]:{state:{on:{label:F(`Sound`,`Suono`),whenTrue:F(`When {device} hears a sound`,`Quando {device} sente un suono`),whenFalse:F(`When {device} is quiet again`,`Quando {device} torna silenzioso`),icon:`ear`}}},[O.BatterySensor]:{state:{on:{label:F(`Battery low`,`Batteria scarica`),whenTrue:F(`When the battery of {device} runs low`,`Quando la batteria di {device} si scarica`),whenFalse:F(`When the battery of {device} is fine again`,`Quando la batteria di {device} torna a posto`),icon:`battery-low`}}},[O.BinaryHelper]:{state:{on:{label:F(`On`,`Acceso`),whenTrue:F(`When {device} turns on`,`Quando {device} si accende`),whenFalse:F(`When {device} turns off`,`Quando {device} si spegne`),icon:`toggle-right`}}}}}}},cw=S([`unknown-source`,`not-admin`,`no-builder`,`no-ingress-url`,`unreachable`,`unknown-board`,`no-encryption-key`,`unreadable-config`]),Sye=x({sourceId:l(),name:l()}),Cye=x({configuration:l(),name:l(),address:l().nullable()}),lw=x({ok:p(!1),reason:cw,detail:l().optional()}),wye=i(`ok`,[x({ok:p(!0),boards:C(Cye).readonly()}),lw]),Tye=i(`ok`,[x({ok:p(!0),key:l()}),lw]),uw={name:`board-key-source`,scope:`system`,mode:`collection`,methods:{listSources:A(v(),C(Sye).readonly(),{auth:`admin`}),listBoards:A(x({sourceId:l().min(1)}),wye,{auth:`admin`}),getBoardKey:A(x({sourceId:l().min(1),configuration:l().min(1)}),Tye,{auth:`admin`})},vocabulary:{notOperatorFacing:M.INTERNAL}},dw=x({level:n().min(0).max(100).meta(N(`percentage`)),lastChangedAt:n()}),fw={name:`brightness`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Light],methods:{setBrightness:A(x({deviceId:n().int().nonnegative(),level:n().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`brightness.full`,label:F(`Full brightness`,`Luminosità massima`),phrase:F(`Set {device} to full brightness`,`Porta {device} alla massima luminosità`),icon:`sun`,effect:{field:`level`,value:100},args:{level:100}},{id:`brightness.half`,label:F(`Half brightness`,`Luminosità a metà`),phrase:F(`Dim {device} to half`,`Abbassa {device} a metà luminosità`),icon:`sun-dim`,effect:{field:`level`,value:50},args:{level:50}},{id:`brightness.off`,label:F(`Brightness off`,`Luminosità a zero`),phrase:F(`Dim {device} to zero`,`Abbassa {device} a zero`),icon:`lightbulb-off`,effect:{field:`level`,value:0},args:{level:0}},{id:`brightness.set`,label:F(`Set brightness`,`Imposta la luminosità`),phrase:F(`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:F(`Percentage`,`Percentuale`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]})},events:{onBrightnessChanged:{data:x({deviceId:n(),level:n().min(0).max(100),lastChangedAt:n()}),notOperatorFacing:"the `level` state trigger reads the same change"}},status:{schema:dw,kind:`command-driven`},runtimeState:dw,durability:`session`,history:{fields:{level:{kind:`gauge`,unit:`%`,minIntervalMs:0}}},vocabulary:{noun:F(`Brightness`,`Luminosità`),order:1010,state:[{kind:`numeric`,field:`level`,quantity:F(`the brightness`,`la luminosità`),label:F(`Brightness`,`Luminosità`),unit:`%`,icon:`sun`}]}},Eye=S([`connected`,`disconnected`,`connecting`,`auth-failed`,`unreachable`,`error`]),pw=x({brokerCount:n().int().nonnegative(),connectedCount:n().int().nonnegative()}),Dye=x({id:l()}),Oye=m(l(),w()),mw=x({brokerId:l(),target:m(l(),w()),payload:w().optional()}),hw=x({brokerId:l(),filter:m(l(),w())}),gw=x({subscriptionId:l()}),_w=x({brokerId:l(),subscriptionId:l()}),vw=x({brokerId:l(),key:l()}),yw={name:`broker`,scope:`system`,mode:`collection`,providerKind:`broker`,status:{schema:pw,kind:`poll`},methods:{getBrokerConfig:A(Dye,Oye.nullable(),{auth:`admin`}),publish:A(mw,w(),{kind:`mutation`,auth:`admin`}),subscribe:A(hw,gw,{kind:`mutation`,auth:`admin`}),unsubscribe:A(_w,v(),{kind:`mutation`,auth:`admin`}),getState:A(vw,w().nullable(),{auth:`admin`}),getStatus:A(v(),pw)},vocabulary:{notOperatorFacing:`message-broker connections — configured, not actuated`}},bw={name:`button`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Button],methods:{press:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`button.press`,label:F(`Press`,`Premi`),phrase:F(`Press {device}`,`Premi {device}`),icon:`circle-dot`}]})},vocabulary:{noun:F(`Button`,`Pulsante`),order:1130}},xw=S([`ha`,`addon`]),Sw=x({id:l().min(1),name:l().min(1),source:xw,enabled:y(),instanceId:l().min(1).optional()}),Cw=x({id:l().min(1),calendarId:l().min(1),title:l(),startMs:n().int(),endMs:n().int(),allDay:y().optional(),description:l().optional(),location:l().optional()}),ww=x({calendarIds:C(l().min(1)).max(64).optional(),startMs:n().int(),endMs:n().int()}),Tw={name:`calendar-source`,scope:`system`,mode:`collection`,internal:!0,providerKind:`calendar`,methods:{listCalendars:A(v(),C(Sw).readonly(),{auth:`admin`}),listEvents:A(ww,C(Cw).readonly(),{auth:`admin`})},vocabulary:{notOperatorFacing:M.INTERNAL}};function Ew(e){let t=new Date(e);return new Date(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()).getTime()}function Dw(e){if(e.allDay!==!0)return{startMs:e.startMs,endMs:e.endMs};let t=Ew(e.startMs),n=Ew(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 kye(e,t){let n=new Date(t),r=new Date(n.getFullYear(),n.getMonth(),n.getDate()+1).getTime(),i=Dw(e);return i.startMs<r&&i.endMs>t}var Ow=l().regex(/^#[0-9A-Fa-f]{6}$/,`expected #RRGGBB`),kw=Sw.extend({id:l().min(1),providerAddonId:l().min(1).optional(),defaultColor:Ow,color:Ow,visible:y()}),Aw=x({visible:y().optional(),color:Ow.optional()}),jw=x({calendars:m(l(),Aw)}),Mw=x({calendarId:l().min(1),visible:y().optional(),color:Ow.nullable().optional()}),Nw={name:`calendars`,scope:`system`,mode:`singleton`,methods:{listCalendars:A(v(),C(kw).readonly(),{auth:`admin`}),listEvents:A(ww,C(Cw).readonly(),{auth:`admin`}),getPreferences:A(x({}),jw,{auth:`admin`,caller:`required`}),setCalendarPreference:A(Mw,jw,{auth:`admin`,kind:`mutation`,caller:`required`})},vocabulary:{notOperatorFacing:`calendars feed schedules and conditions, not device actions`}},Pw=x({host:l(),port:n().int().positive().optional(),onvifPort:n().int().positive().optional(),rtspPort:n().int().positive().optional(),https:y().optional(),username:l().optional(),password:l().optional(),onvifProfile:l().optional()}),Fw=x({host:l(),port:n().int().positive().nullable(),onvifPort:n().int().positive().nullable(),rtspPort:n().int().positive().nullable(),https:y().nullable(),hasUsername:y(),hasPassword:y(),onvifProfile:l().nullable()}),Iw={name:`camera-credentials`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],methods:{getCredentials:A(x({deviceId:n()}),Pw.nullable(),{kind:`query`,auth:`admin`})},status:{schema:Fw,kind:`command-driven`},vocabulary:{noun:F(`Camera credentials`,`Credenziali della telecamera`),order:3030}},Lw=x({x:n().min(0).max(1),y:n().min(0).max(1),width:n().gt(0).max(1),height:n().gt(0).max(1)}),Rw=x({deviceId:n().int().positive(),source:Lw,cell:Lw}),Aye=x({profile:S([`high`,`mid`,`low`]),offered:y(),missingSources:C(n().int().positive()),canvas:l(),published:y()}),zw=x({blockId:l(),deviceId:n().int().nonnegative(),name:l(),fps:n().int(),cells:C(Rw),profiles:C(Aye)}),Bw=x({deviceId:n().int().nonnegative(),fps:n().int().min(1).max(60).optional(),publishedProfiles:C(S([`high`,`mid`,`low`])).max(3).optional(),cells:C(Rw).max(16)}),Vw={name:`camera-grid-layout`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],exposesDeviceSettings:!0,methods:{getLayout:A(x({deviceId:n().int().nonnegative()}),zw.nullable(),{auth:`admin`}),saveLayout:A(Bw,zw,{kind:`mutation`,auth:`admin`})},vocabulary:{noun:F(`Grid layout`,`Layout a griglia`),order:3040}},Hw={name:`camera-pipeline-config`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[E.Camera],exposesDeviceSettings:!0,methods:{},vocabulary:{noun:F(`Detection settings`,`Impostazioni di rilevamento`),order:3050}},Uw=S([`webrtc`,`hls`,`mjpeg`,`rtsp`]),Ww=S([`mp4`,`gif`]),Gw=x({kind:Ww,handle:l(),nodeId:l(),mime:l(),bytes:n().int(),width:n().int(),height:n().int()}),Kw=x({fromTs:n(),toTs:n(),packets:n().int()}),qw=x({media:C(Gw).readonly(),coverage:Kw,profile:P,video:S([`copy`,`encode`])}),Jw=x({brokerId:l(),url:l(),mutedUrl:l(),enabled:y(),codec:l().optional(),resolution:x({width:n().int().positive(),height:n().int().positive()}).optional()}),Yw=x({sessionId:l(),remoteAddr:l(),userAgent:l().nullish(),playing:y(),muted:y(),connectedAt:n(),lastRtpAt:n(),bytesSent:n()}),Xw=x({tag:l(),subscribedAt:n(),chunksDelivered:n()}),Zw=S([`alexa`,`homekit`,`webrtc-browser`,`webrtc-mobile`,`webrtc-whep`,`rtsp-listen`,`derived-broker`,`recording`,`pipeline`,`snapshot`,`warmup`,`unknown`]),Qw=x({kind:Zw,label:l().optional(),media:S([`audio`,`video`,`both`]).optional(),targetCodec:l().optional(),transport:S([`passthrough`,`repacketize`,`transcode`]).optional(),remoteAddr:l().optional(),userAgent:l().optional(),userId:l().optional(),sessionId:l().optional(),extra:m(l(),l()).optional()}).readonly(),$w=x({id:l(),channel:S([`annexb`,`rtp`]),attribution:Qw,subscribedAt:n(),packetsDelivered:n()}),eT=x({rtsp:C(Yw).readonly(),audio:C(Xw).readonly(),encoded:C($w).readonly(),pipeClients:n(),encodedSubscribers:n()}),tT=x({deviceId:n().int().nonnegative(),viewers:n().int().positive()}),jye=S([`reconnecting`,`sleeping`,`offline`,`disabled`,`waking`]),Mye=S([`h264`,`h265`,`copy`]),Nye=S([`aac`,`opus`,`pcmu`,`copy`,`none`]),nT=x({deviceId:n().int().nonnegative(),video:Mye,audio:Nye.optional(),profile:P.optional(),targetResolution:x({width:n().int().positive(),height:n().int().positive()}).optional(),outputArgs:C(l()).optional(),audioEgress:y().optional(),hostname:l().optional(),tag:l().optional()}),rT=x({url:l(),sentryUrl:l().nullable().optional(),videoCodec:S([`H264`,`H265`]),audioCodec:l(),resolution:x({width:n().int().positive(),height:n().int().positive()}),transcoded:y(),encoder:l(),pipelineKey:l()}),iT=Nd.omit({inputArgs:!0,outputArgs:!0}),aT=S([`tight`,`relaxed`]),oT=x({deviceId:n().int().nonnegative(),source:i(`kind`,[x({kind:p(`profile`),profile:P}),x({kind:p(`cam-stream`),camStreamId:l().min(1)})]),encode:iT,rateControl:aT.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:l().optional(),tag:l().optional()}),sT=x({url:l(),pipelineKey:l(),videoCodec:S([`H264`,`H265`]),resolution:x({width:n().int().positive(),height:n().int().positive()}),transcoded:y(),encoder:l(),decodeHwAccel:l().nullable(),camStreamId:l().nullable()}),cT={name:`stream-broker`,scope:`system`,mode:`singleton`,exposesDeviceSettings:!0,methods:{reportStreamSignal:A(x({deviceId:n().int().nonnegative(),code:l().min(1),at:n().optional()}),x({accepted:y(),reason:S([`woke`,`hold-extended`,`not-enabled`,`no-consumer`,`unknown-code`])}),{kind:`mutation`}),publishCameraStream:A(x({deviceId:n().int().nonnegative(),camStreamId:l().min(1),kind:ga,url:l().optional(),codec:l().optional(),resolution:_a.optional(),fps:n().positive().optional(),label:l().optional(),deviceFeatures:C(l()).optional(),autoEligible:y().optional(),profileHint:P.optional(),metadata:m(l(),w()).optional(),sourceCamStreamId:l().min(1).optional(),encodeProfile:Nd.optional()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),retractCameraStream:A(x({deviceId:n().int().nonnegative(),camStreamId:l().min(1)}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),assignProfile:A(x({deviceId:n().int().nonnegative(),profile:P,camStreamId:l().min(1)}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),unassignProfile:A(x({deviceId:n().int().nonnegative(),profile:P}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),forgetDeviceHardware:A(x({deviceId:n().int().nonnegative()}),x({derivedStreamsDeleted:C(l()).readonly(),assignmentsPurged:y(),probeSnapshotsDropped:n().int().nonnegative(),rtspTokenRowsDeleted:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),renderPreBufferClip:A(x({deviceId:n(),profile:P.optional(),aroundMs:n(),preRollSec:n().min(0).max(20).default(3),postRollSec:n().min(0).max(20).default(5),format:S([`gif`,`mp4`]).default(`gif`),maxWidth:n().int().min(120).max(1920).default(480),fps:n().int().min(1).max(15).default(5),speed:n().min(1).max(8).default(2)}),x({base64:l(),mime:l(),bytes:n().int(),profile:P,durationMs:n()}),{kind:`mutation`,auth:`admin`}),produceEventMedia:A(x({deviceId:n(),profile:P.optional(),aroundMs:n(),preSeconds:n().min(0).max(20).default(4),postSeconds:n().min(0).max(20).default(6),kinds:C(Ww).min(1).default([`mp4`]),gifMaxWidth:n().int().min(120).max(1280).default(640),gifFps:n().int().min(1).max(15).default(12),gifSpeed:n().min(1).max(8).default(4),speed:n().min(1).max(8).default(4)}),qw,{kind:`mutation`,auth:`admin`}),fetchEventMedia:A(x({handle:l()}),x({base64:l(),mime:l(),bytes:n().int()}).nullable(),{kind:`mutation`,auth:`admin`}),listAllCameraStreams:A(v(),C(va).readonly()),listAllProfileSlots:A(v(),C(ba).readonly()),getBrokerStats:A(x({brokerId:l()}),One),previewDerivedEncode:A(x({deviceId:n().int().nonnegative(),profile:Nd,source:wne.optional()}),Dne),probeStream:A(x({brokerId:l()}),x({probed:y(),summary:l()}),{kind:`mutation`,auth:`admin`}),listClients:A(x({brokerId:l()}),eT),getLiveViewerCounts:A(v(),C(tT).readonly(),{role:`viewer`}),killClient:A(x({brokerId:l(),channel:S([`rtsp`,`audio`]),handle:l()}),x({killed:y()}),{kind:`mutation`,auth:`admin`}),restartProfile:A(x({deviceId:n().int().nonnegative(),profile:P}),x({success:y()}),{kind:`mutation`,auth:`admin`}),getStreamUrl:A(x({streamId:l(),format:Uw}),x({url:l()})),getStreamWithCodec:A(nT,rT,{kind:`mutation`,auth:`admin`}),releaseStreamWithCodec:A(x({pipelineKey:l()}),x({released:y(),refcount:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),acquireEgressTranscode:A(oT,sT,{kind:`mutation`,auth:`admin`}),releaseEgressTranscode:A(x({pipelineKey:l()}),x({released:y(),refcount:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),subscribeAudioChunks:A(xne,Sne,{kind:`mutation`}),pullAudioChunks:A(x({subscriptionId:l(),maxCount:n().int().positive().default(8)}),C(bne).readonly()),unsubscribeAudioChunks:A(x({subscriptionId:l()}),x({released:y()}),{kind:`mutation`}),setPreBufferDuration:A(x({brokerId:l(),seconds:n().min(0).max(30)}),v(),{kind:`mutation`,auth:`admin`}),getPreBufferInfo:A(x({brokerId:l()}),x({configuredSec:n(),bufferedMs:n(),packetCount:n()})),getRtspPort:A(v(),n()),getAllRtspEntries:A(x({hostname:l().optional()}),C(Jw).readonly()),getRtspEntry:A(x({brokerId:l(),hostname:l().optional()}),Jw.nullable()),regenerateRtspToken:A(x({brokerId:l()}),l().nullable(),{kind:`mutation`,auth:`admin`}),setRtspEnabled:A(x({brokerId:l(),enabled:y()}),v(),{kind:`mutation`,auth:`admin`}),isRtspEnabled:A(x({brokerId:l()}),y()),getDeviceAudioMute:A(x({deviceId:n().int()}),x({muted:y(),appliedBrokers:n().int().nonnegative()})),setDeviceAudioMute:A(x({deviceId:n().int(),muted:y()}),x({muted:y(),appliedBrokers:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`})},events:{onCamStreamDemand:ni(x({deviceId:n().int().nonnegative(),camStreamId:l(),profile:P})),onCamStreamIdle:ni(x({deviceId:n().int().nonnegative(),camStreamId:l()})),onRequestStreamSourceRefresh:ni(x({deviceId:n().int().nonnegative(),camStreamId:l(),brokerId:l()}))},vocabulary:{notOperatorFacing:M.PIPELINE}},lT=S([`h264`,`h265`,`hevc`,`av1`,`mjpeg`,`vp8`,`vp9`]),uT=x({acceptCodecs:C(lT).readonly().optional(),minHeight:n().int().positive().optional(),maxHeight:n().int().positive().optional(),minWidth:n().int().positive().optional(),excludeDerived:y().optional(),requireSiblingCodec:C(lT).readonly().optional(),allowTranscode:y().optional(),requireProfileBound:y().optional()}).readonly(),dT=x({preferredProviders:C(l()).readonly().optional(),resolutionPreference:S([`highest`,`lowest`]).optional(),targetHeight:n().int().positive().optional()}).readonly(),fT=x({camStreamId:l(),codec:l().optional(),resolution:_a.optional(),transcodes:y(),reason:l(),profile:P.optional(),brokerId:l().optional(),url:l().optional(),fps:n().positive().optional(),fpsSource:S([`published`,`measured`]).optional()}),pT={name:`camera-streams`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[E.Camera],methods:{getCameraStreams:A(x({deviceId:n().int().nonnegative()}),C(va).readonly()),getBrokerStreams:A(x({deviceId:n().int().nonnegative()}),C(ba).readonly()),getRtspEntries:A(x({deviceId:n().int().nonnegative(),hostname:l().optional()}),C(Jw).readonly()),getProfileRtspEntries:A(x({deviceId:n().int().nonnegative(),hostname:l().optional()}),C(kne).readonly()),pickStream:A(x({deviceId:n().int().nonnegative(),requirements:uT,preferences:dT.optional()}),fT.nullable())},events:{onCamStreamsChanged:ni(x({deviceId:n().int().nonnegative(),camStreams:C(va).readonly()}),{notOperatorFacing:`the stream catalog was rebuilt — plumbing, not a happening`}),onProfileSlotsChanged:ni(x({deviceId:n().int().nonnegative(),profileSlots:C(ba).readonly()}),{notOperatorFacing:`stream profiles were reassigned — plumbing, not a happening`})},runtimeState:x({online:y(),slotStatuses:x({high:ya.optional(),mid:ya.optional(),low:ya.optional()}),slotErrors:x({high:l().optional(),mid:l().optional(),low:l().optional()}),lastChangedAt:n()}),durability:`session`,history:`none`,vocabulary:{noun:F(`Camera streams`,`Flussi della telecamera`),order:3060}},mT=x({detected:y(),lastChangedAt:n()}),hT={name:`carbon-monoxide`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:mT,kind:`push`},runtimeState:mT,durability:`restored`,history:{fields:{detected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Carbon monoxide`,`Monossido di carbonio`),order:5030,state:[{kind:`boolean`,field:`detected`,label:F(`Detected`,`Rilevato`),whenTrue:F(`When {device} detects carbon monoxide`,`Quando {device} rileva monossido di carbonio`),whenFalse:F(`When the carbon monoxide clears on {device}`,`Quando il monossido su {device} rientra`),icon:`cloud-alert`}]}},gT=S([`off`,`heat`,`cool`,`auto`,`heat_cool`,`fan_only`,`dry`]),_T=S([`heating`,`cooling`,`drying`,`fan`,`idle`,`off`]),vT=x({mode:gT,action:_T.nullable().optional(),availableModes:C(gT),fanMode:l(),availableFanModes:C(l()),preset:l(),availablePresets:C(l()),target:n().nullable().meta(N(`temperature`)),targetHigh:n().nullable().meta(N(`temperature`)),targetLow:n().nullable().meta(N(`temperature`)),targetHumidity:n().min(0).max(100).nullable().meta(N(`humidity`)),currentTemp:n().nullable().meta(N(`temperature`)),currentHumidity:n().min(0).max(100).nullable().meta(N(`humidity`)),swingVertical:y().nullable(),swingHorizontal:y().nullable(),minTemp:n().nullable().optional().meta(N(`temperature`)),maxTemp:n().nullable().optional().meta(N(`temperature`)),tempStep:n().positive().nullable().optional().meta(N(`temperature`)),lastActiveMode:gT.exclude([`off`]).optional(),lastFetchedAt:n()}),Pye=[E.Climate];function yT(e,t){return{id:e,cardinality:`scalar`,vocabulary:{cap:`climate-control`,stateField:t},deviceTypes:Pye,apply:`replace`,path:t,sources:[{kind:`numeric`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}}var bT=[yT(`room-temperature`,`currentTemp`),yT(`room-humidity`,`currentHumidity`)],Fye={version:1,overridable:bT.map(e=>({path:e.path,by:e.id})),targets:bT},xT={name:`climate-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Climate],power:{kind:`mode`,field:`mode`,offValue:`off`,set:`setMode`,lastField:`lastActiveMode`},methods:{setMode:A(x({deviceId:n().int().nonnegative(),mode:gT}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.off`,label:F(`Climate off`,`Clima spento`),phrase:F(`Turn off {device}`,`Spegni {device}`),icon:`power-off`,effect:{field:`mode`,value:`off`},args:{mode:`off`}},{id:`climate.heat`,label:F(`Heat`,`Riscalda`),phrase:F(`Set {device} to heat`,`Metti {device} in riscaldamento`),icon:`flame`,effect:{field:`mode`,value:`heat`},args:{mode:`heat`}},{id:`climate.cool`,label:F(`Cool`,`Raffresca`),phrase:F(`Set {device} to cool`,`Metti {device} in raffrescamento`),icon:`snowflake`,effect:{field:`mode`,value:`cool`},args:{mode:`cool`}},{id:`climate.auto`,label:F(`Climate auto`,`Clima automatico`),phrase:F(`Set {device} to automatic`,`Metti {device} in automatico`),icon:`thermometer`,effect:{field:`mode`,value:`auto`},args:{mode:`auto`}},{id:`climate.mode`,label:F(`Set mode`,`Imposta la modalità`),phrase:F(`Set {device} to {mode}`,`Imposta {device} su {mode}`),icon:`thermometer`,effect:{field:`mode`,fromArg:`mode`},openArgs:[{key:`mode`,label:F(`Mode`,`Modalità`),offer:{kind:`enum`,values:[{value:`off`,label:F(`Off`,`Spento`)},{value:`heat`,label:F(`Heat`,`Riscaldamento`)},{value:`cool`,label:F(`Cool`,`Raffrescamento`)},{value:`auto`,label:F(`Automatic`,`Automatico`)},{value:`heat_cool`,label:F(`Heat and cool`,`Caldo e freddo`)},{value:`fan_only`,label:F(`Fan only`,`Solo ventilazione`)},{value:`dry`,label:F(`Dry`,`Deumidificazione`)}]}}]}]}),setTarget:A(x({deviceId:n().int().nonnegative(),target:n()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.target`,label:F(`Set temperature`,`Imposta la temperatura`),phrase:F(`Set {device} to {target}`,`Imposta {device} a {target}`),icon:`thermometer`,effect:{field:`target`,fromArg:`target`},openArgs:[{key:`target`,label:F(`Temperature`,`Temperatura`),offer:{kind:`number`,step:.5,unit:`°C`}}]}]}),setTargetRange:j(x({deviceId:n().int().nonnegative(),targetLow:n(),targetHigh:n()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.targetRange`,label:F(`Set temperature range`,`Imposta l’intervallo di temperatura`),phrase:F(`Keep {device} between {targetLow} and {targetHigh}`,`Mantieni {device} tra {targetLow} e {targetHigh}`),icon:`thermometer`,effect:{field:`targetLow`,fromArg:`targetLow`},sideEffects:[{field:`targetHigh`,fromArg:`targetHigh`}],openArgs:[{key:`targetLow`,label:F(`Lowest`,`Minima`),offer:{kind:`number`,step:.5,unit:`°C`}},{key:`targetHigh`,label:F(`Highest`,`Massima`),offer:{kind:`number`,step:.5,unit:`°C`}}]}]}),setTargetHumidity:j(x({deviceId:n().int().nonnegative(),targetHumidity:n().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.targetHumidity`,label:F(`Set humidity`,`Imposta l’umidità`),phrase:F(`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:F(`Humidity`,`Umidità`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setFanMode:j(x({deviceId:n().int().nonnegative(),fanMode:l().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.fanMode`,label:F(`Set fan mode`,`Imposta la ventilazione`),phrase:F(`Set the fan of {device} to {fanMode}`,`Imposta la ventilazione di {device} su {fanMode}`),icon:`fan`,effect:{field:`fanMode`,fromArg:`fanMode`},openArgs:[{key:`fanMode`,label:F(`Fan mode`,`Ventilazione`),offer:{kind:`dynamic`,from:`status`,field:`availableFanModes`}}]}]}),setPreset:j(x({deviceId:n().int().nonnegative(),preset:l().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.preset`,label:F(`Set preset`,`Imposta il preset`),phrase:F(`Set {device} to preset {preset}`,`Imposta {device} sul preset {preset}`),icon:`list`,effect:{field:`preset`,fromArg:`preset`},openArgs:[{key:`preset`,label:F(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`status`,field:`availablePresets`}}]}]}),setSwingVertical:j(x({deviceId:n().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.swingVerticalOn`,label:F(`Vertical swing on`,`Oscillazione verticale attiva`),phrase:F(`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:F(`Vertical swing off`,`Oscillazione verticale spenta`),phrase:F(`Stop the vertical swing of {device}`,`Ferma l’oscillazione verticale di {device}`),icon:`move-vertical`,effect:{field:`swingVertical`,value:!1},args:{on:!1}}]}),setSwingHorizontal:j(x({deviceId:n().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.swingHorizontalOn`,label:F(`Horizontal swing on`,`Oscillazione orizzontale attiva`),phrase:F(`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:F(`Horizontal swing off`,`Oscillazione orizzontale spenta`),phrase:F(`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:vT,kind:`push`},runtimeState:vT,customize:Fye,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:F(`Climate`,`Clima`),order:1070,state:[{kind:`enum`,field:`mode`,label:F(`Mode`,`Modalità`),values:[{value:`off`,label:F(`Off`,`Spento`),phrase:F(`When {device} turns off`,`Quando {device} si spegne`)},{value:`heat`,label:F(`Heat`,`Riscaldamento`),phrase:F(`When {device} starts heating`,`Quando {device} passa al riscaldamento`)},{value:`cool`,label:F(`Cool`,`Raffrescamento`),phrase:F(`When {device} starts cooling`,`Quando {device} passa al raffrescamento`)},{value:`auto`,label:F(`Automatic`,`Automatico`)},{value:`heat_cool`,label:F(`Heat and cool`,`Caldo e freddo`)},{value:`fan_only`,label:F(`Fan only`,`Solo ventilazione`)},{value:`dry`,label:F(`Dry`,`Deumidificazione`)}],icon:`thermometer`},{kind:`numeric`,field:`currentTemp`,quantity:F(`the temperature`,`la temperatura`),label:F(`Temperature`,`Temperatura`),unit:`°C`,icon:`thermometer`},{kind:`numeric`,field:`currentHumidity`,quantity:F(`the humidity`,`l’umidità`),label:F(`Humidity`,`Umidità`),unit:`%`,icon:`droplets`},{kind:`numeric`,field:`target`,quantity:F(`the set temperature`,`la temperatura impostata`),label:F(`Set temperature`,`Temperatura impostata`),unit:`°C`,icon:`thermometer`}]}},ST=S([`backup`,`hub-server`,`agent-server`,`addons`]),CT=S([`pending`,`running`,`ok`,`failed`,`skipped`]),wT=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`]),TT=x({kind:ST,nodeId:l().optional(),status:CT,detail:l(),reason:wT.optional(),fromVersion:l().nullable().optional(),packages:C(l()).readonly().optional(),startedAt:n().optional(),finishedAt:n().optional()}),ET=S([`running`,`succeeded`,`failed`]),DT=x({id:l(),state:ET,targetVersion:l(),requestedBy:l(),startedAt:n(),finishedAt:n().optional(),steps:C(TT).readonly(),stoppedAt:l().optional(),reason:wT.optional(),skippedOffline:C(l()).readonly()}),OT=x({version:l().optional(),addons:y().optional(),backup:y().optional()}),kT=S([`no-target`,`node-busy`,`job-running`,`nothing-to-do`,`status-unreadable`]),AT=x({targetVersion:l().nullable(),steps:C(TT).readonly(),skippedOffline:C(l()).readonly(),blocker:kT.nullable(),blockerDetail:l().nullable()}),jT=x({accepted:y(),jobId:l().nullable(),blocker:kT.nullable(),message:l()}),MT={name:`cluster-update`,scope:`system`,mode:`singleton`,methods:{previewClusterUpdate:A(OT,AT,{auth:`admin`}),startClusterUpdate:A(OT,jT,{kind:`mutation`,auth:`admin`}),getClusterUpdateJob:A(x({jobId:l().optional()}),DT.nullable(),{auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:M.CLUSTER}},NT=x({r:n().int().min(0).max(255).meta(N(`none`)),g:n().int().min(0).max(255).meta(N(`none`)),b:n().int().min(0).max(255).meta(N(`none`))}),PT=x({h:n().min(0).max(360).meta(N(`none`)),s:n().min(0).max(100).meta(N(`none`)),v:n().min(0).max(100).meta(N(`none`))}),FT=i(`mode`,[x({mode:p(`rgb`),rgb:NT}),x({mode:p(`hsv`),hsv:PT}),x({mode:p(`mired`),colorTemperature:n().int().min(50).max(1e3)})]),IT=x({mode:S([`rgb`,`hsv`,`mired`]),rgb:NT.optional(),hsv:PT.optional(),colorTemperature:n().int().optional().meta(N(`colour-temperature`)),lastChangedAt:n()});function Iye(e){let t=FT.safeParse(e);return t.success?t.data:null}var LT={name:`color`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Light],methods:{setColor:A(x({deviceId:n().int().nonnegative(),color:FT}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`color.warmWhite`,label:F(`Warm white`,`Bianco caldo`),phrase:F(`Set {device} to warm white`,`Imposta {device} su bianco caldo`),icon:`sun`,args:{color:{mode:`mired`,colorTemperature:370}}},{id:`color.coolWhite`,label:F(`Cool white`,`Bianco freddo`),phrase:F(`Set {device} to cool white`,`Imposta {device} su bianco freddo`),icon:`snowflake`,args:{color:{mode:`mired`,colorTemperature:200}}},{id:`color.red`,label:F(`Red`,`Rosso`),phrase:F(`Turn {device} red`,`Colora {device} di rosso`),icon:`palette`,args:{color:{mode:`rgb`,rgb:{r:255,g:0,b:0}}}},{id:`color.green`,label:F(`Green`,`Verde`),phrase:F(`Turn {device} green`,`Colora {device} di verde`),icon:`palette`,args:{color:{mode:`rgb`,rgb:{r:0,g:255,b:0}}}},{id:`color.blue`,label:F(`Blue`,`Blu`),phrase:F(`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:n(),mode:S([`rgb`,`hsv`,`mired`]),rgb:NT.optional(),hsv:PT.optional(),colorTemperature:n().int().optional(),lastChangedAt:n()}),notOperatorFacing:"a colour change is read through the `mode` state trigger"}},status:{schema:IT,kind:`command-driven`},runtimeState:IT,durability:`session`,history:`none`,vocabulary:{noun:F(`Colour`,`Colore`),order:1020,state:[{kind:`enum`,field:`mode`,label:F(`Colour mode`,`Modalità colore`),values:[{value:`rgb`,label:F(`RGB colour`,`Colore RGB`)},{value:`hsv`,label:F(`HSV colour`,`Colore HSV`)},{value:`mired`,label:F(`White temperature`,`Temperatura del bianco`)}],icon:`palette`}]}};function RT(e,t){let n=e;for(let e of t.split(`.`)){let t=Jg(n);if(!(t instanceof ce))return null;let r=t.shape[e];if(!(r instanceof ie))return null;n=r}return n}function zT(e,t){let n=Yg(e).find(e=>e.path===t);if(n===void 0)return null;let r=RT(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 BT(e){return new Map(Yg(e).filter(e=>!e.path.includes(`.`)).flatMap(t=>{let n=zT(e,t.path);return n===null?[]:[[t.path,n]]}))}function VT(e){let t=Jg(e);return t instanceof ce?Object.entries(t.shape).flatMap(([e,t])=>t instanceof ie&&!t.safeParse(void 0).success?[e]:[]):[]}function HT(e,t){let n=t.split(`.`);return n.slice(0,-1).flatMap((t,r)=>{let i=n.slice(0,r+1).join(`.`),a=RT(e,i);return a!==null&&a.safeParse(void 0).success?[i]:[]})}var UT={"doorbell.onPressed":T.DoorbellOnPressed},Lye=UT,WT=x({featureIndex:n().int().nonnegative(),cap:l(),eventName:l(),category:S(T),stateField:l(),fieldKey:l()});function GT(e,t,n){return{code:e,path:t,message:n}}function Rye(e){return e.issues.map(e=>`${e.path.length===0?`payload`:e.path.join(`.`)}: ${e.message}`).join(`; `)}function KT(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?zT(e.runtimeState,s.field):null;if(l===null){r.push(GT(`unknown-field`,c,`\`${e.name}.${a}\` derives from missing state field \`${s.field}\``));continue}if(l.kind!==`number`){r.push(GT(`kind-mismatch`,c,`\`${e.name}.${a}\` needs a numeric state field; \`${s.field}\` is ${l.kind}`));continue}let u=`${e.name}.${a}`,d=Lye[u];if(d===void 0){r.push(GT(`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(GT(`not-composable`,`features[${t.featureIndex}].cap`,`\`${u}\` cannot be derived from { deviceId, timestamp }: ${Rye(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(GT(`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 qT=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.link-contribution-removed`.split(`.`)),JT=x({code:qT,path:l(),message:l()}),YT=S([`string`,`number`,`boolean`,`enum`]),XT=S([`null`,`offline`,`unknown`,`release`,`omit`]),ZT=S([`derived`,`clock`,`constant`,`accumulator`]),QT=x({arrayPath:l(),key:l(),label:l(),resettable:y().optional()}),$T=x({cap:l(),path:l(),item:QT.optional(),featureIndex:n().int().nonnegative(),kind:YT,nullable:y(),required:y(),unavailable:XT,role:ZT,source:sl,reads:C($c)});function eE(e){let t=e.item===void 0?e.path:Pl(e.item.arrayPath,e.item.key,e.path);return`${e.cap}.${t}`}var tE=S([`new`,`add`,`replace`]),nE=x({featureIndex:n().int().nonnegative(),cap:l(),mode:tE}),rE=x({ok:y(),problems:C(JT),fields:C($T),features:C(nE),events:C(WT)}),iE=S([`stopped`,`starting`,`running`,`degraded`,`incomplete`,`failed`]),aE=S([`fresh`,`stale`,`unavailable`]),oE=x({cap:l(),path:l(),item:QT.optional(),state:aE,value:h([l(),n(),y(),ae()]),reason:l().optional()}),sE=x({blockId:l(),deviceId:n().nullable(),status:iE,reason:l().optional(),fields:C(oE)}),zye=Zc,cE=x({id:l().min(1),name:l().min(1).max(120),enabled:y(),updatedAt:n(),composition:Dl}),lE=x({id:l().min(1),name:l().nullable(),error:l()}),uE=x({deviceId:n().int(),capName:l(),owner:l(),error:l()}),dE=x({integrationId:l().nullable(),storeLoaded:y(),blocks:C(cE),restartBlockIds:C(l()),unreadableBlocks:C(lE),retiredBlockIds:C(l()).optional()}),fE=x({blockId:l(),status:iE,reason:l().optional()}),pE=x({blocks:C(fE),acted:y(),unreleasedClaims:C(uE).optional()}),mE={name:`composer`,scope:`system`,mode:`singleton`,internal:!0,methods:{applyBlocks:A(dE,pE,{kind:`mutation`,auth:`admin`}),getStates:A(x({blockIds:C(l())}),x({states:C(sE)}),{auth:`admin`})},vocabulary:{notOperatorFacing:`device composition — an authoring tool, not an action`}},hE=x({connected:y(),lastChangedAt:n()}),gE={name:`connectivity`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:hE,kind:`push`},runtimeState:hE,durability:`restored`,history:{fields:{connected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Connectivity`,`Connettività`),order:5040,state:[{kind:`boolean`,field:`connected`,label:F(`Connected`,`Connesso`),whenTrue:F(`When {device} connects`,`Quando {device} si connette`),whenFalse:F(`When {device} disconnects`,`Quando {device} si disconnette`),icon:`wifi`}]}},_E=S([`wear`,`supply`,`waste`]),vE=S([`part`,`tank`,`product`,`bin`]),yE=S([`ok`,`low`,`empty`,`full`,`replace`]),Bye=S([`ok`,`low`,`empty`,`full`]);function bE(e){return e.kind??`wear`}var Vye={wear:`part`,waste:`bin`,supply:`product`};function Hye(e){return e.form??Vye[bE(e)]}var xE=S([`duration`,`count`]),SE=x({value:n().min(0).nullable().meta(N(`device`)),kind:xE}),CE=x({key:l().min(1),label:l().min(1),level:n().min(0).max(100).nullable().meta(N(`percentage`)),status:yE.nullable(),kind:_E.optional(),form:vE.optional(),lastResetAt:n().nullable(),resettable:y(),remaining:SE.optional()}),wE=x({items:C(CE),lastChangedAt:n()}),Uye={items:[],lastChangedAt:0},Wye={version:1,targets:[{id:`items`,cardinality:`keyedArray`,vocabulary:{cap:`consumables`},deviceTypes:Object.values(E),apply:`add`,path:`items`,keyField:`key`,labelField:`label`,itemSchema:CE,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:[...xE.options]}]},{path:`status`,sources:[{kind:`enum`,transforms:[{kind:`enum-map`,outputValues:[...yE.options],unmapped:null}]}]}],traits:[{path:`kind`,values:[..._E.options],defaultValue:`wear`},{path:`form`,values:[...vE.options],defaultValue:`part`}],companions:[{kind:`clock`,path:`lastChangedAt`,when:`add`},{kind:`clock`,path:`lastFetchedAt`,when:`add`}],advancedExpression:!0}]},TE={name:`consumables`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:Object.values(E),methods:{reset:A(x({deviceId:n().int().nonnegative(),key:l().min(1)}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`consumables.reset`,label:F(`Mark as replaced`,`Segna come sostituito`),phrase:F(`Mark {key} as replaced on {device}`,`Segna {key} come sostituito su {device}`),icon:`refresh-cw`,openArgs:[{key:`key`,label:F(`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:wE,kind:`push`,empty:Uye,itemArray:{path:`items`,keyField:`key`,labelField:`label`,itemSchema:CE,emptyItem:{key:``,label:``,level:null,status:null,lastResetAt:null,resettable:!1}}},runtimeState:wE.extend({lastFetchedAt:n()}),durability:`restored`,customize:Wye,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:F(`Consumables`,`Materiali di consumo`),order:2070}},EE=x({entryOpen:y(),lastChangedAt:n()}),DE={name:`contact`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:EE,kind:`push`},runtimeState:EE,durability:`restored`,history:{fields:{entryOpen:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Contact`,`Contatto`),order:5050,state:[{kind:`boolean`,field:`entryOpen`,label:F(`Open`,`Aperto`),whenTrue:F(`When {device} opens`,`Quando {device} si apre`),whenFalse:F(`When {device} closes`,`Quando {device} si chiude`),icon:`door-open`}]}},OE=S([`numeric`,`select`,`text`,`datetime`]),kE=x({kind:OE,value:h([n().meta(N(`device`)),l()]),options:C(l()),lastChangedAt:n(),min:n().optional().meta(N(`device`)),max:n().optional().meta(N(`device`)),step:n().optional().meta(N(`device`))}),Gye=i(`kind`,[x({kind:p(`numeric`),value:n()}),x({kind:p(`select`),value:l().min(1)}),x({kind:p(`text`),value:l()}),x({kind:p(`datetime`),value:l().min(1)})]),AE=x({deviceId:n().int().nonnegative(),cycle:y().default(!0)}),jE=x({deviceId:n().int().nonnegative()}),ME={name:`control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Control],methods:{setValue:A(x({deviceId:n().int().nonnegative(),control:Gye}),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:j(AE,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.next`,label:F(`Next option`,`Opzione successiva`),phrase:F(`Select the next option on {device}`,`Seleziona l’opzione successiva su {device}`),icon:`skip-forward`,openArgs:[{key:`cycle`,label:F(`Wrap to the first option`,`Ricomincia dalla prima opzione`),offer:{kind:`boolean`}}]}]}),previous:j(AE,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.previous`,label:F(`Previous option`,`Opzione precedente`),phrase:F(`Select the previous option on {device}`,`Seleziona l’opzione precedente su {device}`),icon:`skip-back`,openArgs:[{key:`cycle`,label:F(`Wrap to the last option`,`Ricomincia dall’ultima opzione`),offer:{kind:`boolean`}}]}]}),first:j(jE,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.first`,label:F(`First option`,`Prima opzione`),phrase:F(`Select the first option on {device}`,`Seleziona la prima opzione su {device}`),icon:`chevron-first`}]}),last:j(jE,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.last`,label:F(`Last option`,`Ultima opzione`),phrase:F(`Select the last option on {device}`,`Seleziona l’ultima opzione su {device}`),icon:`chevron-last`}]})},status:{schema:kE,kind:`push`},runtimeState:kE,durability:`session`,history:`none`,vocabulary:{noun:F(`Control`,`Controllo`),order:1150,state:[{kind:`value`,field:`value`,label:F(`Value`,`Valore`),offer:{kind:`dynamic`,from:`status`,field:`options`},icon:`sliders-horizontal`}]}},V=class extends Error{code;constructor(e,t){super(t),this.name=`IrCodecError`,this.code=e}},NE=1024,PE=C(n().int()).min(2).max(NE).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]})})}),FE=x({carrierHz:n().int().positive().optional(),dutyCyclePercent:n().int().min(1).max(100).optional(),repeat:n().int().min(0).max(20).optional(),repeatDelayMs:n().int().min(0).optional()}),Kye=.241246,qye=0;function IE(e){let t=e.trim().split(/\s+/).filter(e=>e.length>0);if(t.length<4)throw new V(`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 V(`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 V(`pronto-malformed`,`Pronto header incomplete`);if(r!==qye)throw new V(`pronto-unsupported-form`,`Pronto form ${t[0]??``} is not supported, only the learned 0000 form`);if(i===0)throw new V(`pronto-malformed`,`Pronto frequency word is zero`);let s=a+o;if(s===0||n.length!==4+s*2)throw new V(`pronto-malformed`,`Pronto declares ${s} burst pairs but carries ${(n.length-4)/2} word pairs`);let c=i*Kye,l=n.slice(4).map((e,t)=>{let n=Math.max(1,Math.round(e*c));return t%2==0?n:-n}),u=PE.safeParse(l);if(!u.success)throw new V(`invalid-timings`,`Pronto decoded to invalid timings: ${u.error.message}`);return{timings:u.data,carrierHz:Math.round(1e6/c)}}var Jye=8192,LE=32,RE=3,Yye=264,zE=NE*2;function Xye(e){let t=[],n=0,r=e=>{if(t.length+e>zE)throw new V(`tuya-malformed`,`decompressed code is larger than any IR train`)},i=()=>{let t=e[n++];if(t===void 0)throw new V(`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 V(`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 V(`tuya-malformed`,`back-reference is invalid`);t.push(n)}}return Uint8Array.from(t)}function Zye(e){let t=[],n=new Map,r=0,i=n=>{for(let i=r;i<n;i+=LE){let r=Math.min(i+LE,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+RE<=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<=Jye){let t=0;for(;a+t<e.length&&t<Yye&&e[r+t]===e[a+t];)t++;t>=RE&&(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 BE=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Qye=65535;function $ye(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+=BE[o>>18&63],t+=BE[o>>12&63],t+=n+1<e.length?BE[o>>6&63]:`=`,t+=n+2<e.length?BE[o&63]:`=`}return t}function ebe(e){let t=e.trim().replace(/=+$/,``);if(t.length===0||t.length%4==1)throw new V(`tuya-malformed`,`not a base64 string`);let n=[],r=0,i=0;for(let e of t){let t=BE.indexOf(e);if(t<0)throw new V(`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 VE(e){let t=new Uint8Array(e.length*2);return e.forEach((e,n)=>{let r=Math.abs(e);if(r===0||r>Qye)throw new V(`invalid-timings`,`timing ${n} does not fit 16 bits`);t[n*2]=r&255,t[n*2+1]=r>>8}),$ye(Zye(t))}function HE(e){let t=Xye(ebe(e));if(t.length===0||t.length%2!=0)throw new V(`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=PE.safeParse(n);if(!r.success)throw new V(`tuya-malformed`,r.error.message);return r.data}var UE=S([`tuya`]),WE=Math.ceil((zE+Math.ceil(zE/32))/3)*4+256,GE=x({format:UE,code:l().min(1).max(WE)}),KE={tuya:{encode:VE,decode:HE}},qE=i(`kind`,[x({kind:p(`raw`),timings:C(n().int()),settings:FE.optional()}),x({kind:p(`pronto`),code:l()}),x({kind:p(`native`),format:UE,code:l()})]);function JE(e){if(e.kind===`pronto`){let t=IE(e.code);return{timings:t.timings,settings:{carrierHz:t.carrierHz}}}if(e.kind===`native`)return{timings:KE[e.format].decode(e.code),settings:{}};let t=PE.safeParse(e.timings);if(!t.success)throw new V(`invalid-timings`,t.error.message);return{timings:t.data,settings:e.settings??{}}}var YE=`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(`.`),XE=[`source_select`];function ZE(e){return XE.includes(e)}var QE=`custom:`,tbe=/^[a-z0-9][a-z0-9_]{0,47}$/,nbe=new Set(YE);function $E(e){return nbe.has(e)}function eD(e){return tbe.test(e)}function tD(e){return`${QE}${e}`}function nD(e){if(!e.startsWith(`custom:`))return null;let t=e.slice(7);return eD(t)?t:null}function rD(e){return $E(e)||nD(e)!==null}var iD=l().refine(rD,{message:`a role is one of the known roles or custom:<key> (lowercase letters, digits, _)`}),aD=[`digits`,`sequence`,`ir`],rbe=S(aD),ibe=200,abe=16,obe=6,sbe=/^[a-z0-9][a-z0-9_-]{0,47}$/,cbe=RegExp(`^[0-9]{1,6}$`),oD={id:l().regex(sbe,{message:`a lowercase slug`}),name:l().trim().min(1).max(60)},sD=x({...oD,kind:p(`digits`),number:l().regex(cbe,{message:`up to 6 digits`})}),cD=x({...oD,kind:p(`sequence`),steps:C(iD).min(1).max(16)}),lD=x({...oD,kind:p(`ir`),transmitterId:n().int().nonnegative().optional(),payload:qE}),uD=i(`kind`,[sD,cD,lD]),lbe=500,ube=100,dD=3e3;function fD(e){switch(e.kind){case`sequence`:return e.steps;case`digits`:return Array.from(e.number,e=>`digit_${e}`);case`ir`:return[]}}function pD(e){try{return JE(e.payload),null}catch(e){if(e instanceof V)return e.message;throw e}}function dbe(e,t){return e.trim().toLowerCase()===t.trim().toLowerCase()}function mD(e,t){let n=t.trim();for(let t of e)if(t.kind===`digits`&&t.number===n)return t;return null}function fbe(e,t){let n=e.find(e=>dbe(e.name,t));if(n!==void 0)return n;let r=e.find(e=>e.id===t.trim());return r===void 0?mD(e,t):r}var hD=S([`off`,`on`,`idle`,`playing`,`paused`,`buffering`,`standby`]),gD=S([`off`,`all`,`one`]),pbe=x({type:l(),title:l(),artist:l().optional(),album:l().optional(),imageUrl:l().optional()}),_D=S([`reported`,`assumed`]),vD=S([`state`,`volumeLevel`,`isMuted`,`source`]),yD=x({state:hD,stateSource:_D.default(`reported`),assumedFields:C(vD).default([]),volumeLevel:n().min(0).max(100).nullable().meta(N(`percentage`)),isMuted:y().nullable(),muteReadback:y().optional(),source:l(),availableSources:C(l()),declaredSources:C(x({name:l(),kind:S(aD),number:l().optional()})).optional(),currentMedia:pbe.nullable(),position:n().int().nonnegative().nullable().meta(N(`duration-ms`)),duration:n().int().nonnegative().nullable().meta(N(`duration-ms`)),shuffle:y().nullable(),repeat:gD.nullable(),positionUpdatedAt:n().nullable().default(null),lastChangedAt:n()}),mbe=50,bD=x({deviceId:n().int().nonnegative(),steps:n().int().min(1).max(50).default(1)}),xD=x({deviceId:n().int().nonnegative()}),SD={name:`media-player`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.MediaPlayer],power:{kind:`methods`,field:`state`,offValues:[`off`,`standby`],on:`turnOn`,off:`turnOff`},methods:{turnOn:j(xD,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.turnOn`,label:F(`Turn on`,`Accendi`),phrase:F(`Turn on {device}`,`Accendi {device}`),icon:`power`}]}),turnOff:j(xD,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.turnOff`,label:F(`Turn off`,`Spegni`),phrase:F(`Turn off {device}`,`Spegni {device}`),icon:`power`}]}),volumeUp:j(bD,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.volumeUp`,label:F(`Volume up`,`Alza il volume`),phrase:F(`Raise the volume of {device}`,`Alza il volume di {device}`),icon:`volume-2`}]}),volumeDown:j(bD,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.volumeDown`,label:F(`Volume down`,`Abbassa il volume`),phrase:F(`Lower the volume of {device}`,`Abbassa il volume di {device}`),icon:`volume-2`}]}),channelUp:j(bD,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.channelUp`,label:F(`Channel up`,`Canale successivo`),phrase:F(`Go to the next channel on {device}`,`Passa al canale successivo su {device}`),icon:`skip-forward`}]}),channelDown:j(bD,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.channelDown`,label:F(`Channel down`,`Canale precedente`),phrase:F(`Go to the previous channel on {device}`,`Torna al canale precedente su {device}`),icon:`skip-back`}]}),play:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.play`,effect:{field:`state`,value:`playing`},label:F(`Play`,`Riproduci`),phrase:F(`Play on {device}`,`Avvia la riproduzione su {device}`),icon:`play`}]}),pause:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.pause`,effect:{field:`state`,value:`paused`},label:F(`Pause media`,`Metti in pausa`),phrase:F(`Pause {device}`,`Metti in pausa {device}`),icon:`pause`}]}),stop:j(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.stop`,label:F(`Stop media`,`Ferma la riproduzione`),phrase:F(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),next:j(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.next`,label:F(`Next track`,`Brano successivo`),phrase:F(`Skip to the next track on {device}`,`Passa al brano successivo su {device}`),icon:`skip-forward`}]}),previous:j(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.previous`,label:F(`Previous track`,`Brano precedente`),phrase:F(`Go back to the previous track on {device}`,`Torna al brano precedente su {device}`),icon:`skip-back`}]}),setVolume:j(x({deviceId:n().int().nonnegative(),volumeLevel:n().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.volume`,effect:{field:`volumeLevel`,fromArg:`volumeLevel`},label:F(`Set volume`,`Imposta il volume`),phrase:F(`Set the volume of {device} to {volumeLevel}`,`Imposta il volume di {device} al {volumeLevel}`),icon:`volume-2`,openArgs:[{key:`volumeLevel`,label:F(`Volume`,`Volume`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setMute:j(x({deviceId:n().int().nonnegative(),muted:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.mute`,effect:{field:`isMuted`,value:!0},label:F(`Mute`,`Silenzia`),phrase:F(`Mute {device}`,`Silenzia {device}`),icon:`volume-x`,args:{muted:!0}},{id:`media.unmute`,effect:{field:`isMuted`,value:!1},label:F(`Unmute`,`Riattiva l’audio`),phrase:F(`Unmute {device}`,`Riattiva l’audio di {device}`),icon:`volume-2`,args:{muted:!1}}]}),setShuffle:j(x({deviceId:n().int().nonnegative(),shuffle:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.shuffleOn`,effect:{field:`shuffle`,value:!0},label:F(`Shuffle on`,`Riproduzione casuale attiva`),phrase:F(`Turn on shuffle on {device}`,`Attiva la riproduzione casuale su {device}`),icon:`shuffle`,args:{shuffle:!0}},{id:`media.shuffleOff`,effect:{field:`shuffle`,value:!1},label:F(`Shuffle off`,`Riproduzione casuale spenta`),phrase:F(`Turn off shuffle on {device}`,`Disattiva la riproduzione casuale su {device}`),icon:`shuffle`,args:{shuffle:!1}}]}),setRepeat:j(x({deviceId:n().int().nonnegative(),repeat:gD}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.repeat`,effect:{field:`repeat`,fromArg:`repeat`},label:F(`Set repeat`,`Imposta la ripetizione`),phrase:F(`Set repeat on {device} to {repeat}`,`Imposta la ripetizione di {device} su {repeat}`),icon:`repeat`,openArgs:[{key:`repeat`,label:F(`Repeat`,`Ripetizione`),offer:{kind:`enum`,values:[{value:`off`,label:F(`Off`,`Disattivata`)},{value:`all`,label:F(`All`,`Tutti i brani`)},{value:`one`,label:F(`One track`,`Un brano`)}]}}]}]}),selectSource:j(x({deviceId:n().int().nonnegative(),source:l().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.source`,effect:{field:`source`,fromArg:`source`},label:F(`Select source`,`Scegli la sorgente`),phrase:F(`Switch {device} to {source}`,`Passa {device} alla sorgente {source}`),icon:`cast`,openArgs:[{key:`source`,label:F(`Source`,`Sorgente`),offer:{kind:`dynamic`,from:`status`,field:`availableSources`}}]}]}),seek:j(x({deviceId:n().int().nonnegative(),position:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.seek`,label:F(`Seek`,`Vai al punto`),phrase:F(`Move {device} to {position}`,`Porta {device} al punto {position}`),icon:`fast-forward`,openArgs:[{key:`position`,label:F(`Position`,`Posizione`),offer:{kind:`number`,min:0,step:1e3,unit:`ms`}}]}]}),playMedia:j(x({deviceId:n().int().nonnegative(),mediaId:l().min(1),mediaType:l().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.playMedia`,label:F(`Play media`,`Riproduci un contenuto`),phrase:F(`Play {mediaId} on {device}`,`Riproduci {mediaId} su {device}`),icon:`music`,openArgs:[{key:`mediaId`,label:F(`Media`,`Contenuto`),offer:{kind:`text`}},{key:`mediaType`,label:F(`Media type`,`Tipo di contenuto`),offer:{kind:`text`}}]}]})},status:{schema:yD,kind:`push`},runtimeState:yD,durability:`session`,history:{fields:{volumeLevel:{kind:`gauge`,unit:`%`,deadband:1},isMuted:{kind:`boolean`}}},vocabulary:{noun:F(`Media player`,`Lettore multimediale`),order:2060,state:[{kind:`enum`,field:`state`,label:F(`Playback`,`Riproduzione`),values:[{value:`off`,label:F(`Off`,`Spento`),phrase:F(`When {device} turns off`,`Quando {device} si spegne`)},{value:`on`,label:F(`On`,`Acceso`),phrase:F(`When {device} turns on`,`Quando {device} si accende`)},{value:`idle`,label:F(`Idle`,`Inattivo`)},{value:`playing`,label:F(`Playing`,`In riproduzione`),phrase:F(`When {device} starts playing`,`Quando {device} inizia a riprodurre`)},{value:`paused`,label:F(`Paused`,`In pausa`),phrase:F(`When {device} is paused`,`Quando {device} va in pausa`)},{value:`buffering`,label:F(`Buffering`,`In caricamento`)},{value:`standby`,label:F(`Standby`,`In standby`)}],icon:`music`},{kind:`numeric`,field:`volumeLevel`,quantity:F(`the volume`,`il volume`),label:F(`Volume`,`Volume`),unit:`%`,icon:`volume-2`},{kind:`boolean`,field:`isMuted`,label:F(`Muted`,`Silenziato`),whenTrue:F(`When {device} is muted`,`Quando {device} viene silenziato`),whenFalse:F(`When {device} is unmuted`,`Quando l’audio di {device} torna attivo`),icon:`volume-x`},{kind:`value`,field:`source`,label:F(`Source`,`Sorgente`),offer:{kind:`dynamic`,from:`status`,field:`availableSources`},icon:`cast`}]}},CD={battery:{version:1,targets:[{id:`level`,cardinality:`scalar`,deviceTypes:[E.Camera,E.Sensor,E.Button,E.Switch,E.PetFeeder,E.Container,E.Climate,E.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:[E.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:[E.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:[E.Camera,E.Light,E.Siren,E.Switch,E.Sensor,E.Climate,E.Button,E.EventEmitter,E.Update,E.Generic,E.Notifier,E.Script,E.Automation,E.Lock,E.Cover,E.Valve,E.Humidifier,E.WaterHeater,E.Fan,E.MediaPlayer,E.AlarmPanel,E.Control,E.Presence,E.Weather,E.WeatherStation,E.Vacuum,E.LawnMower,E.Container,E.Image,E.PetFeeder,E.PetFountain,E.Dishwasher,E.Washer,E.Dryer,E.Gateway,E.HeatPump,E.EnergySystem,E.Workload],apply:`add`,vocabularyCap:`consumables`,sources:[],sourceReport:{status:`assignment-status`},advancedExpression:!0,path:`items`,keyField:`key`,labelField:`label`,nativeItems:`read-only`,fields:[{path:`level`,valueKind:`number`,nullable:!0,sources:[{kind:`numeric`,transformKinds:[`identity`,`linear`],transforms:[{kind:`identity`},{kind:`linear`,defaultScale:1,defaultOffset:0,clampMin:0,clampMax:100}]}]},{path:`remaining.value`,valueKind:`number`,nullable:!0,sources:[{kind:`numeric`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],literals:[{path:`remaining.kind`,values:[`duration`,`count`]}]},{path:`status`,valueKind:`enum`,nullable:!0,enumValues:[`ok`,`low`,`empty`,`full`,`replace`],sources:[{kind:`enum`,transformKinds:[`enum-map`],transforms:[{kind:`enum-map`,outputValues:[`ok`,`low`,`empty`,`full`,`replace`],unmapped:null}]}]}],traits:[{path:`kind`,values:[`wear`,`supply`,`waste`],defaultValue:`wear`},{path:`form`,values:[`part`,`tank`,`product`,`bin`],defaultValue:`part`}],companions:[{kind:`clock`,path:`lastChangedAt`,when:`add`},{kind:`clock`,path:`lastFetchedAt`,when:`add`}]}]},doorbell:{version:1,targets:[{id:`pressed`,cardinality:`event`,deviceTypes:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.Fan],apply:`add`,readMethod:`getPresets`,writeMethod:`setPresets`,vocabularyCap:`fan-presets`,sources:[],sourceReport:{status:`assignment-status`},advancedExpression:!1}]},"heat-pump-status":{version:1,targets:[{id:`electrical-power`,cardinality:`scalar`,deviceTypes:[E.HeatPump],apply:`replace`,vocabularyCap:`heat-pump-status`,sources:[{kind:`numeric`,requiredUnit:`W`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`power.electricalW`,valueKind:`number`,nullable:!0},{id:`electrical-energy`,cardinality:`scalar`,deviceTypes:[E.HeatPump],apply:`replace`,vocabularyCap:`heat-pump-status`,sources:[{kind:`numeric`,requiredUnit:`kWh`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`energy.electricalKwh`,valueKind:`number`,nullable:!0}],overridable:[{path:`power.electricalW`,by:`electrical-power`},{path:`energy.electricalKwh`,by:`electrical-energy`}]},"lock-control":{version:1,targets:[{id:`door-contact`,cardinality:`scalar`,deviceTypes:[E.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:[E.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:[E.Switch,E.Light,E.Fan,E.Climate,E.Humidifier,E.WaterHeater,E.MediaPlayer,E.Washer,E.Dryer,E.Dishwasher,E.Vacuum,E.LawnMower,E.PetFeeder,E.Workload],apply:`add`,vocabularyCap:`power-meter`,vocabularyStateField:`power`,sources:[{kind:`numeric`,requiredUnit:`W`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!0,path:`power`,valueKind:`number`,nullable:!1,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`always`}]},{id:`energy`,cardinality:`scalar`,deviceTypes:[E.Switch,E.Light,E.Fan,E.Climate,E.Humidifier,E.WaterHeater,E.MediaPlayer,E.Washer,E.Dryer,E.Dishwasher,E.Vacuum,E.LawnMower,E.PetFeeder,E.Workload],apply:`add`,vocabularyCap:`power-meter`,vocabularyStateField:`energy`,sources:[{kind:`numeric`,requiredUnit:`kWh`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!0,path:`energy`,valueKind:`number`,nullable:!1,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`always`}]},{id:`voltage`,cardinality:`scalar`,deviceTypes:[E.Switch,E.Light,E.Fan,E.Climate,E.Humidifier,E.WaterHeater,E.MediaPlayer,E.Washer,E.Dryer,E.Dishwasher,E.Vacuum,E.LawnMower,E.PetFeeder,E.Workload],apply:`add`,vocabularyCap:`power-meter`,vocabularyStateField:`voltage`,sources:[{kind:`numeric`,requiredUnit:`V`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!0,path:`voltage`,valueKind:`number`,nullable:!1,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`always`}]},{id:`current`,cardinality:`scalar`,deviceTypes:[E.Switch,E.Light,E.Fan,E.Climate,E.Humidifier,E.WaterHeater,E.MediaPlayer,E.Washer,E.Dryer,E.Dishwasher,E.Vacuum,E.LawnMower,E.PetFeeder,E.Workload],apply:`add`,vocabularyCap:`power-meter`,vocabularyStateField:`current`,sources:[{kind:`numeric`,requiredUnit:`A`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!0,path:`current`,valueKind:`number`,nullable:!1,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`always`}]}]},"power-source":{version:1,targets:[{id:`switch`,cardinality:`scalar`,deviceTypes:[E.Gateway,E.Camera,E.Sensor,E.MediaPlayer,E.Vacuum,E.Generic,E.Washer,E.Dryer,E.Dishwasher,E.PetFountain,E.Fan,E.Humidifier,E.Climate,E.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:[E.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:[E.Washer,E.Dryer,E.Dishwasher,E.Vacuum,E.LawnMower,E.MediaPlayer,E.WaterHeater,E.Humidifier,E.Fan,E.Climate,E.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:{[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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`}]}},wD={"ambient-light-sensor":{illuminance:`lx`},battery:{level:`%`,voltage:`V`,temperatureC:`°C`},"humidity-sensor":{humidity:`%`},"power-meter":{power:`W`,deliveredPower:`W`,energy:`kWh`,voltage:`V`,current:`A`},"temperature-sensor":{temperature:`°C`}};function H(e,t,n){return{code:e,path:t,message:n}}function TD(...e){return{problems:e,fields:[],features:[],events:[]}}function ED(e){let t=e.item===void 0?`fields`:`items.${e.item.key}.fields`;return`features[${e.featureIndex}].${t}.${e.path}`}var DD={kind:`fixed`,result:[`number`]},OD={kind:`fixed`,result:[`boolean`]},kD=Object.freeze({min:DD,max:DD,abs:DD,floor:DD,ceil:DD,sqrt:DD,round:DD,pow:DD,clamp:DD,avg:DD,sum:DD,age:DD,convert:DD,coalesce:{kind:`coalesce`},any:OD,all:OD,within:OD,latest:{kind:`fixed`,result:[`number`,`null`]},number:{kind:`fixed`,result:[`number`,`null`]},rose:{kind:`fixed`,result:[`number`,`null`]},count:DD,dwell:{kind:`fixed`,result:[`boolean`,`null`]},latchedAt:{kind:`fixed`,result:[`number`,`null`]},schmitt:{kind:`fixed`,result:[`boolean`,`null`]}}),AD=class extends Error{};function jD(e){return e===null?`null`:typeof e==`number`?`number`:typeof e==`string`?`string`:`boolean`}function MD(e){return new Set([e])}function ND(...e){return new Set(e.flatMap(e=>[...e]))}function hbe(e){return new Set([...e].filter(e=>e!==`null`))}function gbe(e,t,n){if(e===`+`){let e=[...t,...n];return e.every(e=>e===`string`)?MD(`string`):e.every(e=>e===`number`)?MD(`number`):new Set([`number`,`string`])}return MD(e===`-`||e===`*`||e===`/`||e===`%`?`number`:`boolean`)}function _be(e){return e.minArgs===e.maxArgs?`exactly ${e.minArgs}`:e.maxArgs===1/0?`at least ${e.minArgs}`:`${e.minArgs}–${e.maxArgs}`}function vbe(e,t){let n=ms[e];if(n!==void 0&&(t.length<n.minArgs||t.length>n.maxArgs))throw new AD(`${e}: wrong number of arguments (${t.length}); expected ${_be(n)}`);let r=kD[e];if(r===void 0)throw new AD(`no result-kind rule for builtin '${e}'`);if(r.kind===`fixed`)return new Set(r.result);let i=ND(...t.map(hbe));return t.every(e=>e.has(`null`))?ND(i,MD(`null`)):i}function PD(e,t){switch(e.kind){case`literal`:return MD(jD(e.value));case`identifier`:{if(e.name===`now`)return MD(`number`);let n=t.get(e.name);if(n===void 0)throw new AD(`unbound identifier '${e.name}'`);return n}case`unary`:return MD(e.op===`!`?`boolean`:`number`);case`binary`:return gbe(e.op,PD(e.left,t),PD(e.right,t));case`logical`:return ND(PD(e.left,t),PD(e.right,t));case`conditional`:return ND(PD(e.consequent,t),PD(e.alternate,t));case`call`:return vbe(e.callee,e.args.map(e=>PD(e,t)))}}function FD(e,t){switch(e.kind){case`literal`:case`identifier`:return!1;case`unary`:return FD(e.operand,t);case`binary`:case`logical`:return FD(e.left,t)||FD(e.right,t);case`conditional`:return FD(e.test,t)||FD(e.consequent,t)||FD(e.alternate,t);case`call`:return e.callee===t||e.args.some(e=>FD(e,t))}}function ID(e,t){let n=Ts(e);return n.ok&&FD(n.parsed.ast,t)}function LD(e){let t=Ts(e.expr);if(!t.ok)return{ok:!1,error:t.error};try{return{ok:!0,kinds:PD(t.parsed.ast,e.bindingKinds)}}catch(e){if(e instanceof AD)return{ok:!1,error:e.message};throw e}}function ybe(e){return e.publish===`value`&&e.empty===`null`?{ok:!0,kinds:new Set([`number`,`null`])}:{ok:!0,kinds:new Set([`number`])}}function bbe(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 RD(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=zT(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 zD(e,t,n){return H(`kind-mismatch`,n,`\`${e}.${t}\` is a union — it is read as a source, never written`)}function BD(e){return e.kind===`union`?null:e.kind===`enum`?`string`:e.kind}function VD(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=zT(a,e.fieldPath),s=BD(t);return o?.kind!==`union`||s===null||!n.has(s)?n:new Set(n.has(`null`)?[s,`null`]:[s])}function HD(e,t){if(e.kind===`from`)return RD(e,t);if(e.kind===`code`)return{ok:!1,code:`reserved-variant`,message:`code fields arrive in slice 4`};if(e.kind===`aggregate`)return bbe(e);if(e.kind===`series`)return ybe(e);let n=new Map;for(let[r,i]of Object.entries(e.bindings)){if(i.kind===`literal`){n.set(r,new Set([jD(i.value)]));continue}let e=RD(i,t);if(!e.ok)return{...e,message:`binding \`${r}\`: ${e.message}`};n.set(r,e.kinds)}let r=LD({expr:e.expr,bindingKinds:n});return r.ok?{ok:!0,kinds:r.kinds}:{ok:!1,code:`expression-invalid`,message:r.error}}function UD(e,t,n,r){let i=BD(t);if(i===null)return[zD(e,t.path,r)];let a=[...n].filter(e=>e!==`null`&&e!==i),o=[];return a.length>0&&o.push(H(`kind-mismatch`,r,`\`${e}.${t.path}\` is a ${t.kind}; this source can produce ${a.join(` or `)}`)),n.has(`null`)&&!t.nullable&&o.push(H(`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 xbe(e){if(e.kind!==`expression`)return null;let t=Ts(e.expr);if(!t.ok)return null;let n=t.parsed.ast;return n.kind===`literal`&&typeof n.value==`string`?n.value:null}function WD(e,t,n,r){if(t.kind!==`enum`||t.enumValues===void 0)return null;let i=xbe(n);if(i===null||t.enumValues.includes(i))return null;let a=t.enumValues.map(e=>`\`${e}\``).join(`, `);return H(`kind-mismatch`,r,`\`${e}.${t.path}\` accepts only ${a}; this source is the literal \`${i}\``)}function GD(e){if(e.kind!==`expression`)return`derived`;if(ID(e.expr,`count`))return`accumulator`;if(Nl(e).length>0)return`derived`;let t=Ts(e.expr);return t.ok&&t.parsed.identifiers.has(`now`)?`clock`:`constant`}function KD(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:H(`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 qD={resettable:!1};function Sbe(e){return new Set([e.keyField,...e.labelField===void 0?[]:[e.labelField],...Object.keys(qD)])}function Cbe(e,t,n){let r=zT(e.itemSchema,t);return r===null||!r.required?!1:HT(e.itemSchema,t).every(e=>n.some(t=>t.startsWith(`${e}.`)))}function wbe({capName:e,itemArray:t,reserved:n},r,i){let a=Object.keys(r.fields);return Yg(t.itemSchema).flatMap(o=>{if(n.has(o.path)||o.path in r.fields||!Cbe(t,o.path,a))return[];let s=zT(t.itemSchema,o.path);return s===null||s.nullable?[]:[H(`missing-field`,`${i}.fields.${o.path}`,`\`${e}.${t.path}[].${o.path}\` is required and has no source`)]})}function Tbe(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 TD(H(`item-field-reserved`,u,`\`${n}.${r.path}[].${c}\` is set by the composer itself — it takes no source`));let d=zT(r.itemSchema,c);if(d===null)return TD(H(`unknown-field`,u,`a \`${n}\` item has no field \`${c}\``));if(d.kind===`union`)return TD(zD(n,c,u));let f=HD(l,a);if(!f.ok)return TD(H(f.code,u,f.message));let p=GD(l),m=KD(d,p,e.mode,n,u);if(!m.ok)return TD(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:[...Nl(l)]},g=WD(n,d,l,u);return{problems:[...UD(n,d,VD(l,d,f.kinds,a),u),...g===null?[]:[g]],fields:[h],features:[],events:[]}}function JD(e,t,n,r,i=`new`){let a=`features[${n}].items`,o=e.status?.itemArray;if(o===void 0)return TD(H(`not-item-array`,a,`\`${e.name}\` has no item array — it takes no \`items\``));if(o.path!==`items`)return TD(H(`not-item-array`,a,`\`${e.name}\`'s item array is at \`${o.path}\`, not \`${gl}\` — not composable yet`));let s={capName:e.name,itemArray:o,reserved:Sbe(o),featureIndex:n,lookupCap:r,mode:i},c=Object.entries(t.items??{}).flatMap(([e,t])=>[{problems:wbe(s,t,`${a}.${e}`),fields:[],features:[],events:[]},...Object.entries(t.fields).map(([n,r])=>Tbe(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 YD=`deviceId`;function XD(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 ZD(e){let t=e.features.flatMap((e,t)=>e.kind===`fields`&&Sl(e)?XD(e,t).map(e=>e.command.source):[]);return[...new Map(t.map(e=>[Ol(e),e])).values()]}function Ebe(e,t){return e.name===`switch`&&t===`toggle`}function QD(e){return Object.entries(e.methods).filter(([t,n])=>n.systemOnly!==!0&&e.composedMethods?.[t]===void 0&&!Ebe(e,t)).map(([e])=>e)}function Dbe(){return Object.fromEntries(QD(SD).map(e=>[e,{kind:`extension`,target:`remote`}]))}var $D={all:new Set,required:new Set};function eO(e,t){let n=e.methods[t]?.input;if(n===void 0)return null;let r=Jg(n);if(!(r instanceof ce))return null;let i=Object.entries(r.shape).filter(([e])=>e!==YD);return{all:new Set(i.map(([e])=>e)),required:new Set(i.flatMap(([e,t])=>t instanceof ie&&!t.safeParse(void 0).success?[e]:[]))}}function tO(e){return typeof e==`object`?dl(e)?[e.$input]:Object.values(e).flatMap(tO):[]}function nO(e){return[...e].map(e=>`\`${e}\``).join(`, `)}function Obe(e,t){let{command:n,at:r}=e,i=t(n.cap);if(i===null)return{def:null,problems:[H(`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:[H(`command-source-unknown`,`${r}.method`,`\`${n.cap}\` has no method \`${n.method}\` to forward to`)]}:a.kind===`mutation`?{def:i,problems:[]}:{def:null,problems:[H(`command-source-unknown`,`${r}.method`,`\`${n.cap}.${n.method}\` is a query — a command calls a mutation of the source`)]}}function kbe(e,t,n,r){let{at:i,command:a}=e,o=`${a.cap}.${a.method}`,s=[];if(`deviceId`in r&&s.push(H(`command-input-unknown`,`${i}.args.${YD}`,`\`${YD}\` 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(H(`command-input-unknown`,`${i}.args.${e}`,`\`${o}\` has no input field \`${e}\` (it takes ${nO(n.all)})`));let e=[...n.required].filter(e=>!(e in r));e.length>0&&s.push(H(`command-input-missing`,`${i}.args`,`\`${o}\` needs ${nO(e)}, which \`args\` does not provide`))}let c=e.itemKey===void 0?t:$D;if(c!==null)for(let t of Object.values(r).flatMap(tO))c.all.has(t)||s.push(H(`command-input-unknown`,`${i}.args`,c===$D?`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 ${nO(c.all)})`));return s}function Abe(e,t,n){let{at:r,command:i}=e,a=`${i.cap}.${i.method}`,o=e.itemKey===void 0?t:$D;if(o===null||n===null)return[];let s=[];for(let t of[...o.all].filter(e=>!n.all.has(e)))s.push(H(`command-input-unknown`,`${r}.args`,`\`${e.method}\` takes \`${t}\`, which \`${a}\` does not (it takes ${nO(n.all)}) — add \`args\` to map it`));let c=[...n.required].filter(e=>!o.all.has(e));return c.length>0&&s.push(H(`command-input-missing`,`${r}.args`,`\`${a}\` needs ${nO(c)}, which \`${e.method}\` does not take — add \`args\` to provide it`)),s}function rO(e,t,n){let r=Obe(t,n);if(r.def===null)return r.problems;let i=eO(e,t.method),a=eO(r.def,t.command.method),o=t.command.args;return o===void 0?Abe(t,i,a):kbe(t,i,a,o)}function iO(e,t,n){let r=new Set(QD(e));return Object.keys(t.commands??{}).flatMap(t=>{if(r.has(t))return[];let i=e.composedMethods?.[t]!==void 0;return[H(`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 aO(e,t){return e.features.flatMap((e,n)=>e.kind!==`fields`||!Sl(e)?[]:XD(e,n).flatMap(e=>{let n=Ol(e.command.source),r=t.get(n),i=`${e.at}.source`;return r===void 0||r.kind===`unreadable`?[H(`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`?[H(`source-missing`,i,`source \`${n}\` does not exist`)]:r.caps.has(e.command.cap)?[]:[H(`source-capability-missing`,i,`source \`${n}\` (device ${r.deviceId}) has no \`${e.command.cap}\``)]}))}var oO={fieldPath:`lastFetchedAt`,expr:`now`},sO={fieldPath:`lastChangedAt`,expr:`now`};function cO(e){let{alsoFrom:t,...n}=e;return{...n,family:`numeric`,deviceType:E.Sensor,memberDeviceType:E.Sensor,memberDeviceTypes:[E.Sensor,...t?.deviceTypes??[]],activeWhen:void 0,commandCaps:[],baseUnit:fa(e.quantity),aggregates:Sc,accept:[{cap:e.outputCap,fieldPath:e.outputField},...t===void 0?[]:[t.accept]]}}var lO=[E.Climate];function uO(e){return{...e,family:`binary`,deviceType:E.Sensor,memberDeviceType:E.Sensor,memberDeviceTypes:[E.Sensor],activeWhen:void 0,commandCaps:[],quantity:`none`,baseUnit:void 0,aggregates:Cc,empty:`offline`}}var dO=[cO({id:`temperature`,summary:`Mean, median, min, max or sum of temperatures. Offline and unknown members are left out, never read as 0 °C.`,role:O.TemperatureSensor,outputCap:`temperature-sensor`,outputField:`temperature`,quantity:`temperature`,defaultAggregate:`mean`,empty:`null`,companions:[oO],alsoFrom:{deviceTypes:lO,accept:{cap:`climate-control`,fieldPath:`currentTemp`}}}),cO({id:`humidity`,summary:`Humidity in percent. Offline and unknown members are left out, never read as 0 %.`,role:O.HumiditySensor,outputCap:`humidity-sensor`,outputField:`humidity`,quantity:`humidity`,defaultAggregate:`mean`,empty:`null`,companions:[oO],alsoFrom:{deviceTypes:lO,accept:{cap:`climate-control`,fieldPath:`currentHumidity`}}}),cO({id:`pressure`,summary:`Pressure in hectopascals. Offline and unknown members are left out, never read as 0 hPa.`,role:O.PressureSensor,outputCap:`pressure-sensor`,outputField:`pressure`,quantity:`pressure`,defaultAggregate:`mean`,empty:`null`,companions:[oO]}),cO({id:`illuminance`,summary:`Illuminance in lux. Offline and unknown members are left out, never read as 0 lx.`,role:O.AmbientLightSensor,outputCap:`ambient-light-sensor`,outputField:`illuminance`,quantity:`illuminance`,defaultAggregate:`mean`,empty:`null`,companions:[oO]}),cO({id:`power`,summary:`Power in watts, summed by default. Nobody reporting omits the key rather than writing 0 W.`,role:O.PowerSensor,outputCap:`power-meter`,outputField:`power`,quantity:`power`,defaultAggregate:`sum`,empty:`omit`,companions:[oO]}),cO({id:`energy`,summary:`Energy in kilowatt-hours, summed by default. Nobody reporting omits the key rather than writing 0 kWh.`,role:O.EnergySensor,outputCap:`power-meter`,outputField:`energy`,quantity:`energy`,defaultAggregate:`sum`,empty:`omit`,companions:[oO]}),cO({id:`battery`,summary:`Battery charge in percent. Offline and unknown members are left out, never read as 0 %.`,role:O.BatterySensor,outputCap:`battery`,outputField:`level`,quantity:`percentage`,defaultAggregate:`mean`,empty:`null`,companions:[{fieldPath:`charging`,expr:`"unknown"`},{fieldPath:`sleeping`,expr:`false`},{fieldPath:`lastUpdated`,expr:`now`}]}),cO({id:`numeric`,summary:`A numeric reading in the members’ shared quantity. Mixed quantities are refused. Nobody reporting publishes null, not 0.`,role:O.NumericSensor,outputCap:`numeric-sensor`,outputField:`value`,quantity:`device`,defaultAggregate:`mean`,empty:`null`,companions:[oO]}),uO({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:O.MotionSensor,outputCap:`motion`,outputField:`detected`,defaultAggregate:`any`,accept:[{cap:`motion`,fieldPath:`detected`}],companions:[{fieldPath:`lastDetectedAt`,expr:`null`},{fieldPath:`autoClearAfterMs`,expr:`null`}]}),uO({id:`contact`,summary:`Any or all open contacts. Offline and unknown members are left out, never read as closed.`,role:O.ContactSensor,outputCap:`contact`,outputField:`entryOpen`,defaultAggregate:`any`,accept:[{cap:`contact`,fieldPath:`entryOpen`}],companions:[sO]}),uO({id:`leak`,summary:`Any or all leak detections. Offline and unknown members are left out, never read as dry.`,role:O.LeakSensor,outputCap:`flood`,outputField:`flooded`,defaultAggregate:`any`,accept:[{cap:`flood`,fieldPath:`flooded`}],companions:[sO]}),uO({id:`smoke`,summary:`Any or all smoke detections. Offline and unknown members are left out, never read as clear.`,role:O.SmokeSensor,outputCap:`smoke`,outputField:`detected`,defaultAggregate:`any`,accept:[{cap:`smoke`,fieldPath:`detected`}],companions:[sO]}),uO({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:O.BinarySensor,outputCap:`binary`,outputField:`on`,defaultAggregate:`any`,accept:[{cap:`motion`,fieldPath:`detected`},{cap:`binary`,fieldPath:`on`}],companions:[sO]}),uO({id:`binary`,summary:`Any or all generic binary sensors. Offline and unknown members are left out, never read as off.`,role:O.BinarySensor,outputCap:`binary`,outputField:`on`,defaultAggregate:`any`,accept:[{cap:`binary`,fieldPath:`on`}],companions:[sO]}),fO({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:E.Switch,outputCap:`switch`,outputField:`on`,member:{cap:`switch`,fieldPath:`on`},commandCaps:[`switch`]}),fO({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:E.Light,outputCap:`switch`,outputField:`on`,member:{cap:`switch`,fieldPath:`on`},commandCaps:[`switch`,`brightness`,`color`]}),fO({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:E.Fan,outputCap:`switch`,outputField:`on`,member:{cap:`switch`,fieldPath:`on`},commandCaps:[`switch`,`fan-control`]}),fO({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:E.Cover,outputCap:`group-active`,outputField:`active`,member:{cap:`cover`,fieldPath:`state`},activeWhen:[`open`,`opening`,`stopped`],commandCaps:[`cover`]}),fO({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:E.Valve,outputCap:`group-active`,outputField:`active`,member:{cap:`valve`,fieldPath:`state`},activeWhen:[`open`,`opening`,`stopped`],commandCaps:[`valve`]}),fO({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:E.Lock,outputCap:`group-active`,outputField:`active`,member:{cap:`lock-control`,fieldPath:`state`},activeWhen:[`locked`],commandCaps:[`lock-control`]}),fO({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:E.MediaPlayer,outputCap:`group-active`,outputField:`active`,member:{cap:`media-player`,fieldPath:`state`},activeWhen:[`playing`,`buffering`],commandCaps:[`media-player`]}),fO({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:E.Climate,memberDeviceTypes:[E.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 fO(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:Cc,defaultAggregate:`any`,empty:`offline`,accept:[e.member],companions:[sO]}}var jbe=new Map(dO.map(e=>[e.id,e]));function pO(e){return jbe.get(e)??null}var mO={"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`},temperatureC:{kind:`gauge`,unit:`°C`}},binary:{on:{kind:`boolean`}},brightness:{level:{kind:`gauge`,unit:`%`,minIntervalMs:0}},"carbon-monoxide":{detected:{kind:`boolean`}},"climate-control":{currentTemp:{group:`temperature`,kind:`gauge`,unit:`°C`,deadband:.1},currentHumidity:{kind:`gauge`,unit:`%`,deadband:.5},target:{group:`temperature`,kind:`gauge`,unit:`°C`,minIntervalMs:0},targetHigh:{group:`target-range`,kind:`gauge`,unit:`°C`,minIntervalMs:0},targetLow:{group:`target-range`,kind:`gauge`,unit:`°C`,minIntervalMs:0}},connectivity:{connected:{kind:`boolean`}},contact:{entryOpen:{kind:`boolean`}},cover:{position:{kind:`gauge`,unit:`%`,minIntervalMs:0}},"device-status":{online:{kind:`boolean`}},dishwasher:{progress:{kind:`gauge`,unit:`%`,deadband:2},state:{kind:`enum`,values:[`idle`,`running`,`paused`,`finished`,`error`,`unavailable`]},operationState:{kind:`enum`,values:[`Inactive`,`Ready`,`DelayedStart`,`Run`,`Pause`,`ActionRequired`,`Finished`,`Error`,`Aborting`]},remaining:{kind:`gauge`,unit:`s`,minIntervalMs:6e4},doorOpen:{kind:`boolean`},powerOn:{kind:`boolean`}},"do-not-disturb":{enabled:{kind:`boolean`}},"energy-system":{"solar.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Solar power`},"solar.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`Solar energy`},"grid.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Grid power`},"grid.importKwh":{kind:`counter`,unit:`kWh`,displayName:`Grid import`},"grid.exportKwh":{kind:`counter`,unit:`kWh`,displayName:`Grid export`},"house.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`House power`},"house.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`House energy`},"heatPump.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Heat pump power`},"heatPump.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`Heat pump energy`},"storage.stateOfChargePct":{kind:`gauge`,unit:`%`,deadband:1,displayName:`Storage charge`},"storage.storedKwh":{kind:`gauge`,unit:`kWh`,deadband:.05,displayName:`Stored energy`},"storage.capacityKwh":{kind:`gauge`,unit:`kWh`,deadband:.1,displayName:`Storage capacity`},"storage.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Storage power`},"storage.chargedKwh":{kind:`counter`,unit:`kWh`,displayName:`Storage charged`},"storage.dischargedKwh":{kind:`counter`,unit:`kWh`,displayName:`Storage discharged`},"storage.healthPct":{kind:`gauge`,unit:`%`,deadband:1,displayName:`Storage health`}},"enum-sensor":{value:{kind:`enum`,skipWhenSet:`timestamp`}},"fan-control":{speed:{kind:`gauge`,unit:`%`,minIntervalMs:0},oscillating:{kind:`boolean`}},flood:{flooded:{kind:`boolean`}},gas:{detected:{kind:`boolean`}},"heat-pump-status":{"power.thermalW":{group:`power`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Thermal power`},"power.electricalW":{group:`power`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Electrical power`},"power.compressorPct":{kind:`gauge`,unit:`%`,deadband:2,displayName:`Compressor`},"temperatures.supply":{group:`loop`,kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Supply`},"temperatures.return":{group:`loop`,kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Return`},"temperatures.outdoor":{kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Outdoor`},"energy.thermalKwh":{kind:`counter`,unit:`kWh`,displayName:`Thermal energy`},"energy.electricalKwh":{kind:`counter`,unit:`kWh`,displayName:`Electrical energy`}},"heating-valve":{position:{kind:`gauge`,unit:`%`,deadband:1}},humidifier:{currentHumidity:{kind:`gauge`,unit:`%`,deadband:.5},on:{kind:`boolean`}},"humidity-sensor":{humidity:{kind:`gauge`,unit:`%`,deadband:.5}},"lawn-mower-control":{batteryLevel:{kind:`gauge`,unit:`%`,deadband:2}},"lock-control":{state:{kind:`enum`,values:[`locked`,`unlocked`,`locking`,`unlocking`,`jammed`,`door-open`]}},"media-player":{volumeLevel:{kind:`gauge`,unit:`%`,deadband:1},isMuted:{kind:`boolean`}},meter:{value:{kind:`counter`,deadband:.001,minIntervalMs:6e4}},motion:{detected:{kind:`boolean`,excludeDeviceTypes:[E.Camera]}},"network-link":{signal:{kind:`gauge`,unit:`%`,deadband:3,minIntervalMs:6e4},rssi:{kind:`gauge`,unit:`dBm`,deadband:2,minIntervalMs:6e4}},"numeric-sensor":{value:{kind:`gauge`,minIntervalMs:3e4}},"pet-feeder":{feeding:{kind:`boolean`},eating:{kind:`boolean`},foodLevel:{kind:`gauge`},bowlFood:{kind:`gauge`},food1:{kind:`gauge`},food2:{kind:`gauge`},batteryPower:{kind:`gauge`,unit:`%`,deadband:2},desiccantLeftDays:{kind:`gauge`,unit:`s`}},"pet-fountain":{waterLevel:{kind:`gauge`,unit:`%`,deadband:1},waterVolume:{kind:`gauge`,unit:`L`}},"power-meter":{power:{kind:`gauge`,unit:`W`,deadband:1,minIntervalMs:3e4},energy:{kind:`counter`,unit:`kWh`,deadband:.01,minIntervalMs:6e4},voltage:{kind:`gauge`,unit:`V`,deadband:1,minIntervalMs:3e4},current:{kind:`gauge`,unit:`A`,deadband:.05,minIntervalMs:3e4},apparentPower:{kind:`gauge`,unit:`VA`,deadband:1,minIntervalMs:3e4},powerFactor:{kind:`gauge`,unit:`ratio`,deadband:.01,minIntervalMs:6e4}},"pressure-sensor":{pressure:{kind:`gauge`,unit:`hPa`,deadband:.1}},"running-state":{running:{kind:`boolean`}},smoke:{detected:{kind:`boolean`}},"stream-params":{"main.bitrate":{group:`bitrate`,kind:`gauge`,unit:`kbps`},"main.framerate":{group:`framerate`,kind:`gauge`,unit:`fps`},"sub.bitrate":{group:`bitrate`,kind:`gauge`,unit:`kbps`},"sub.framerate":{group:`framerate`,kind:`gauge`,unit:`fps`}},switch:{on:{kind:`boolean`}},tamper:{tampered:{kind:`boolean`}},"temperature-sensor":{temperature:{kind:`gauge`,unit:`°C`,deadband:.1}},"vacuum-control":{batteryLevel:{kind:`gauge`,unit:`%`,deadband:2}},valve:{position:{kind:`gauge`,unit:`%`,minIntervalMs:0}},vibration:{detected:{kind:`boolean`}},"water-heater":{currentTemp:{group:`temperature`,kind:`gauge`,unit:`°C`,deadband:.5},targetTemp:{group:`temperature`,kind:`gauge`,unit:`°C`,minIntervalMs:0}},weather:{temperature:{kind:`gauge`,unit:`°C`,deadband:.2},humidity:{kind:`gauge`,unit:`%`,deadband:1},pressure:{kind:`gauge`,unit:`hPa`,deadband:.5},windSpeed:{kind:`gauge`,unit:`m/s`,deadband:.5}},"weather-station":{temperature:{group:`temperature`,kind:`gauge`,unit:`°C`,deadband:.1},humidity:{kind:`gauge`,unit:`%`,deadband:1},pressure:{kind:`gauge`,unit:`hPa`,deadband:.2},windSpeed:{group:`wind-speed`,kind:`gauge`,unit:`m/s`,deadband:.2},windGust:{group:`wind-speed`,kind:`gauge`,unit:`m/s`,deadband:.2},windBearing:{group:`wind-bearing`,kind:`gauge`,unit:`°`,deadband:5},rainRate:{kind:`gauge`,unit:`mm/h`,deadband:.1},rainDaily:{kind:`gauge`,unit:`mm`,deadband:.1},rainEvent:{kind:`gauge`,unit:`mm`,deadband:.1},uv:{kind:`gauge`,unit:`index`,deadband:.1},solarRadiation:{kind:`gauge`,unit:`W/m²`,deadband:5},dewPoint:{group:`temperature`,kind:`gauge`,unit:`°C`,deadband:.1},feelsLike:{group:`temperature`,kind:`gauge`,unit:`°C`,deadband:.1},vpd:{kind:`gauge`,unit:`kPa`,deadband:.05},windGustMax:{group:`wind-speed`,kind:`gauge`,unit:`m/s`,deadband:.2},windBearingAvg:{group:`wind-bearing`,kind:`gauge`,unit:`°`,deadband:5},rain24h:{kind:`gauge`,unit:`mm`,deadband:.1},rainWeekly:{kind:`gauge`,unit:`mm`,deadband:.1},rainMonthly:{kind:`gauge`,unit:`mm`,deadband:.1},rainYearly:{kind:`gauge`,unit:`mm`,deadband:.1}},workload:{state:{kind:`enum`,values:[`running`,`paused`,`stopped`,`starting`,`stopping`,`crashed`]},"resources.cpuPercent":{kind:`gauge`,unit:`%`,deadband:2,displayName:`CPU`},"resources.memoryUsedBytes":{kind:`gauge`,unit:`bytes`,displayName:`Memory used`},"resources.memoryPercent":{kind:`gauge`,unit:`%`,deadband:2,displayName:`Memory`},"resources.netRxKbps":{group:`network`,kind:`gauge`,unit:`kbps`,displayName:`Network received`},"resources.netTxKbps":{group:`network`,kind:`gauge`,unit:`kbps`,displayName:`Network sent`}}},Mbe={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`}}}},hO={"climate-control":{field:`currentTemp`,priority:70},"energy-system":{field:`house.powerW`,priority:50},"humidity-sensor":{field:`humidity`,priority:90},"power-meter":{field:`power`,priority:80},"temperature-sensor":{field:`temperature`,priority:100},"weather-station":{field:`temperature`,priority:60},workload:{field:`resources.cpuPercent`,priority:40}},Nbe=`audio-metrics.automation-control.camera-streams.color.control.day-night.doorbell.error.event-emitter.feature-probe.group-active.group-commands.group-status.image.image-settings.intercom.ir-transmitter.low-power-sleep.motion-trigger.motion-zones.native-object-detection.navigation.notifier.power-source.presence.privacy-mask.ptz-autotrack.pump-cycle.recording-onboard.recording-signal.scene-monitor.script-runner.siren.stream-catalog.stream-signals.timed-run.update.zone-analytics.zone-rules.zones`.split(`.`);function gO(e){return mO[e]??{}}function Pbe(e,t,n){return _O(e.deviceTypes,t,n)}function _O(e,t,n){return e.length===0||e.some(e=>e===t)?!0:Ko(t,n)&&e.includes(E.Light)}function Fbe(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 vO(e){return{fieldChoice:`operator`,purpose:`historised`,multiple:!1,max:1,deviceTypes:[],accept:yO(e),history:{required:!0,minRetentionMs:null},mustBindCaps:[],exclude:[]}}function yO(e){let t=[];for(let n of Object.keys(mO))for(let[r,i]of Object.entries(gO(n)))i.kind!==`enum`&&(e===`integral`&&i.kind!==`gauge`||t.push({cap:n,fieldPath:r,valueKind:i.kind===`boolean`?`boolean`:`number`}));return t}function Ibe(e){if(e===`derivative`)return{...vO(`statistic`),accept:bO()};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:bO(),history:{required:!1,minRetentionMs:null},mustBindCaps:[],exclude:[]}}function bO(){return yO(`statistic`).filter(e=>e.valueKind===`number`)}var xO=[`switch`,`brightness`,`color`],Lbe=[D.LightColorRgb,D.LightColorHsv,D.LightColorMired],Rbe=4;function SO(e){return e===`all`?`all`:`any`}function zbe(e){return e===`all`?`all`:`at-least-one`}function Bbe(e){return e.length===0?[]:xO.filter(t=>e.every(e=>e.includes(t)))}function Vbe(e){return e.length===0?[]:Lbe.filter(t=>e.every(e=>e.includes(t)))}function Hbe(e,t,n,r){return e.flatMap(e=>e.caps.includes(t)?[{deviceId:e.deviceId,cap:t,method:n,args:{...r}}]:[])}async function Ube(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 Wbe={kind:`expression`,expr:`now`,bindings:{}};function CO(e,t,n){return{kind:`series`,read:{source:e.source,cap:e.cap,fieldPath:e.fieldPath},publish:t,empty:n}}function Gbe(e){return{included:CO(e,`included`,`offline`),excluded:CO(e,`excluded`,`offline`),total:CO(e,`total`,`offline`)}}var Kbe={second:`s`,minute:`min`,hour:`h`};function qbe(e){let t=gO(e.source.cap)[e.source.fieldPath]?.unit;return t===void 0?null:`${t}/${Kbe[e.per]}`}function wO(e){let t=gO(e.cap)[e.fieldPath];return t===void 0?null:t.kind}function TO(e){return wO(e)===null?[H(`member-constraint`,`helper.source`,`${e.cap}.${e.fieldPath} has no history declaration`)]:[]}function EO(e){return{target:{kind:`new`,type:E.Sensor,role:e.role},helper:e.spec,features:[{kind:`fields`,cap:e.cap,fields:{[e.field]:CO(e.member,`value`,e.empty),lastFetchedAt:Wbe}},{kind:`fields`,cap:`group-status`,fields:Gbe(e.member)}]}}function DO(e,t=nc){let n=[...TO(e.source)],r=wO(e.source);r===`enum`&&n.push(H(`kind-mismatch`,`helper.source`,`a statistic reads a number or a boolean, not a state`)),e.stat===`sum`&&r!==`counter`&&n.push(H(`kind-mismatch`,`helper.stat`,`a gauge has no sum — that is the integral template`));let i=vc(e.window,t);return i.ok||n.push(H(`retention`,`helper.window`,i.reason)),{problems:n,draft:EO({role:O.NumericSensor,cap:`numeric-sensor`,field:`value`,empty:`null`,spec:e,member:e.source})}}function OO(e,t=nc){let n=[...TO(e.source)],r=wO(e.source);(r===`enum`||r===`boolean`)&&n.push(H(`kind-mismatch`,`helper.source`,`a derivative reads a number that moves, not a yes/no or a state`));let i=vc(e.window,t);return i.ok||n.push(H(`retention`,`helper.window`,i.reason)),{problems:n,draft:EO({role:O.NumericSensor,cap:`numeric-sensor`,field:`value`,empty:`null`,spec:e,member:e.source})}}function kO(e,t=nc){let n=[...TO(e.source)],r=wO(e.source),i=e.source.cap===`power-meter`&&e.source.fieldPath===`power`;(r===`counter`||r===`boolean`||r===`enum`)&&n.push(H(`kind-mismatch`,`helper.source`,`an integral reads an instantaneous gauge, not a counter or a state`)),e.output===`energy`&&!i&&n.push(H(`kind-mismatch`,`helper.output`,`energy is the integral of power-meter.power; another reading uses the meter`)),e.output===`meter`&&i&&n.push(H(`kind-mismatch`,`helper.output`,`power integrates to power-meter.energy, which energy dashboards already read`));let a=yc(e.reset,t);a.ok||n.push(H(`retention`,`helper.reset`,a.reason));let o=e.output===`energy`;return{problems:n,draft:EO({role:o?O.EnergySensor:O.NumericSensor,cap:o?`power-meter`:`meter`,field:o?`energy`:`value`,empty:`offline`,spec:e,member:e.source})}}var Jbe=/^\d+(?:\.\d+)?$/,Ybe=/^-?\d+(?:\.\d+)?$/,Xbe=/^dwell\(x (>=|<=) (\d+(?:\.\d+)?), (\d+(?:\.\d+)?), (\d+(?:\.\d+)?)(?:, (\d+))?\)$/,Zbe=/^clamp\((x|number\(x\)) \* (-?\d+(?:\.\d+)?) \+ (-?\d+(?:\.\d+)?), (-?\d+(?:\.\d+)?), (-?\d+(?:\.\d+)?)\)$/,Qbe=/^(x|number\(x\)) \* (-?\d+(?:\.\d+)?) \+ (-?\d+(?:\.\d+)?)$/,$be=/^[A-Za-z_][A-Za-z0-9_]*$/;function AO(e){return BO(e,Jbe)}function jO(e){return BO(e,Ybe)}function MO(e){return typeof e==`string`?JSON.stringify(e):typeof e==`number`?jO(e):typeof e==`boolean`?e?`true`:`false`:`null`}function NO(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 PO(e){return $be.test(e)}function FO(e,t,n,r,i=1){return`dwell(x ${e===`gte`?`>=`:`<=`} ${t}, ${n}, ${r}${i>1?`, ${i}`:``})`}function IO(e,t,n,r,i){let a=`${e} * ${t} + ${n}`;return r===null||i===null?a:`clamp(${a}, ${r}, ${i})`}function LO(e){let t=Xbe.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 RO(e){let t=Zbe.exec(e);if(t!==null)return VO(t[1],t[2],t[3],t[4],t[5]);let n=Qbe.exec(e);return n===null?null:VO(n[1],n[2],n[3],void 0,void 0)}function zO(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 BO(e,t){if(!Number.isFinite(e))return null;let n=Object.is(e,-0)?`0`:String(e);return t.test(n)?n:null}function VO(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 HO={kind:`expression`,expr:`now`,bindings:{}};function UO(e){return{kind:`from`,source:e.source,cap:e.cap,fieldPath:e.fieldPath}}function WO(e,t){return{kind:`expression`,expr:e,bindings:t}}function exe(e,t){return e.source.addonId===t.source.addonId&&e.source.stableId===t.source.stableId&&e.cap===t.cap&&e.fieldPath===t.fieldPath}function GO(e,t,n=[]){return{target:{kind:`new`,type:E.Sensor,role:O.NumericSensor},helper:e,features:[{kind:`fields`,cap:`numeric-sensor`,fields:{value:t,lastFetchedAt:HO}},...n]}}function KO(e,t){return{target:{kind:`new`,type:E.Sensor,role:O.BinarySensor},helper:e,features:[{kind:`fields`,cap:`binary`,fields:{on:t,lastChangedAt:HO}}]}}function qO(e){let t=[],n=jO(e.high),r=jO(e.low);n===null&&t.push(H(`kind-mismatch`,`helper.high`,`the high edge is a finite number`)),r===null&&t.push(H(`kind-mismatch`,`helper.low`,`the low edge is a finite number`)),n!==null&&r!==null&&e.low>e.high&&t.push(H(`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=AO(e.onForMs),a=AO(e.offForMs);(i===null||a===null)&&t.push(H(`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:KO(e,WO(`coalesce(schmitt(x, ${n??`0`}, ${r??`0`}${o}), false)`,{x:UO(e.source)}))}}var txe=[`a`,`b`];function nxe(e){let t=[],n=e.op!==`sum`;return n&&e.inputs.length!==2&&t.push(H(`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(H(`member-constraint`,`helper.inputs`,`a sum takes two or more readings`)),e.inputs.forEach((n,r)=>{e.inputs.slice(0,r).some(e=>exe(e,n))&&t.push(H(`member-constraint`,`helper.inputs[${r}]`,`this reading is already an input`))}),t}var rxe=[`included`,`excluded`,`total`];function JO(e){let t=nxe(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(rxe.map(e=>[e,r(e)]));return{problems:t,draft:GO(e,r(`value`),[{kind:`fields`,cap:`group-status`,fields:i}])}}let n=Object.fromEntries(e.inputs.slice(0,2).map((e,t)=>[txe[t]??`a`,UO(e)]));return{problems:t,draft:GO(e,WO(e.op===`difference`?`a - b`:`b == 0 ? null : a / b`,n))}}function ixe(e){let t=[],n=new Set;if(e.inputs.forEach((e,r)=>{let i=`helper.inputs[${r}].name`;PO(e.name)||t.push(H(`expression-invalid`,i,`\`${e.name}\` is not a name — use letters, digits and _, starting with a letter`)),n.has(e.name)&&t.push(H(`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,UO(e.member)])),i=Fs({expr:e.expr,bindings:r});return i===null?[]:[H(`expression-invalid`,`helper.expr`,i)]}function YO(e){let t=ixe(e),n=Object.fromEntries(e.inputs.map(e=>[e.name,UO(e.member)])),r=WO(e.expr,n);return{problems:t,draft:e.output===`boolean`?KO(e,r):GO(e,r)}}function axe(e,t){return e.addonId===t.addonId&&e.stableId===t.stableId}function oxe(e,t){return axe(e.source,t.source)&&e.cap===t.cap&&e.fieldPath===t.fieldPath}function sxe(e,t){return e.accept.some(e=>e.cap===t.cap&&e.fieldPath===t.fieldPath)}function cxe(e,t){return t.members.flatMap((n,r)=>{let i=`helper.members[${r}]`,a=[];if(!sxe(e,n)){let t=e.accept.map(e=>`${e.cap}.${e.fieldPath}`).join(` or `);a.push(H(`member-constraint`,i,`a ${e.id} group reads ${t}; this member is ${n.cap}.${n.fieldPath}`))}return t.members.slice(0,r).some(e=>oxe(e,n))&&a.push(H(`member-constraint`,i,`this member is already in the group`)),a})}function XO(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 lxe(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,dxe(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]:XO(e,t,n,`value`),...r}},{kind:`fields`,cap:`group-status`,fields:{included:XO(e,t,n,`included`),excluded:XO(e,t,n,`excluded`),total:XO(e,t,n,`total`)}}]}}function uxe(e,t){if(e.family===`actuator`){if(t.active===void 0)return[H(`kind-mismatch`,`helper.active`,`a ${e.id} group needs an active criterion (at-least-one or all)`)];let n=SO(t.active);return t.aggregate===n?[]:[H(`kind-mismatch`,`helper.aggregate`,`active \`${t.active}\` aggregates by \`${n}\`, not \`${t.aggregate}\``)]}return t.active===void 0?[]:[H(`kind-mismatch`,`helper.active`,`a ${e.id} group has no active criterion — that belongs to an actuator group`)]}function ZO(e){let t=Dl.safeParse(e);return t.success?{ok:!0,composition:t.data}:{ok:!1,problems:[H(`helper-mismatch`,`helper`,`the template did not compile: ${t.error.issues.map(e=>e.message).join(`; `)}`)]}}function dxe(e,t={}){return{kind:`expression`,expr:e,bindings:t}}function QO(e,t=nc){switch(e.kind){case`group`:return pxe(e);case`statistic`:{let n=DO(e,t);return n.problems.length>0?{ok:!1,problems:n.problems}:ZO(n.draft)}case`integral`:{let n=kO(e,t);return n.problems.length>0?{ok:!1,problems:n.problems}:ZO(n.draft)}case`derivative`:{let n=OO(e,t);return n.problems.length>0?{ok:!1,problems:n.problems}:ZO(n.draft)}case`threshold`:return $O(qO(e));case`arithmetic`:return $O(JO(e));case`expression`:return $O(YO(e));case`grid`:case`crop`:case`terminal`:return ZO(fxe(e))}}function fxe(e){return{target:{kind:`new`,type:E.Camera},helper:e,features:[]}}function $O(e){return e.problems.length>0?{ok:!1,problems:e.problems}:ZO(e.draft)}function pxe(e){let t=pO(e.templateId);if(t===null)return{ok:!1,problems:[H(`member-constraint`,`helper.templateId`,`unknown template \`${e.templateId}\``)]};let n=uxe(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:[H(`kind-mismatch`,`helper.aggregate`,`a ${t.id} group aggregates by ${n}, not \`${e.aggregate}\``)]}}let r=cxe(t,e);return r.length>0?{ok:!1,problems:r}:ZO(lxe(t,e))}function ek(e,t){return JSON.stringify(e.target)===JSON.stringify(t.target)&&JSON.stringify(e.features)===JSON.stringify(t.features)}function mxe(e){return e.kind===`group`?pO(e.templateId)?.memberDeviceType??null:null}function hxe(e,t){if(e.kind!==`group`)return[];let n=pO(e.templateId);if(n===null||n.family!==`numeric`)return[];let r=e.members.flatMap((e,n)=>{let r=t.get(Ol(e.source))?.quantity;return r===void 0?[]:[{index:n,quantity:r}]});if(n.quantity!==`device`)return r.flatMap(e=>e.quantity===n.quantity?[]:[H(`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?[]:[H(`mixed-quantity`,`helper.members`,`a numeric group requires one quantity; members report ${i.join(` and `)}`)]}function gxe(e,t){if(e.kind!==`group`)return[];let n=pO(e.templateId);return n===null?[]:e.members.flatMap((e,r)=>{let i=t.get(Ol(e.source)),a=i?.deviceType;return a===void 0||_O(n.memberDeviceTypes,a,i?.role)?[]:[H(`member-constraint`,`helper.members[${r}]`,`a ${n.id} group takes ${n.memberDeviceTypes.join(` or `)} devices; this member is a ${a}`)]})}function tk(e,t){let n=e.helper;if(n===void 0)return[];let r=QO(n);return r.ok?ek(e,r.composition)?n.kind===`arithmetic`?_xe(n,t):n.kind===`group`?[...hxe(n,t),...gxe(n,t)]:[]:[H(`helper-mismatch`,`helper`,`the stored features are not this template — the helper spec is the only writer`)]:r.problems}function _xe(e,t){let n=e.inputs.flatMap(e=>{let n=t.get(Ol(e.source))?.quantity;return n===void 0?[]:[n]}),r=[...new Set(n)];return r.length<=1?[]:[H(`mixed-quantity`,`helper.inputs`,`a ${e.op} needs readings of one quantity; these inputs report ${r.join(` and `)}`)]}var nk=class extends Error{};function vxe(e){return new Set(e.composition.features.flatMap(e=>!Sl(e)||e.kind!==`fields`?[]:Fl(e).map(({fieldPath:t})=>`${e.cap}.${t}`)))}function yxe(e,t,n){if(Ol(n.source)!==Ol(e.target))return!0;let r=`${n.cap}.${n.fieldPath}`;return t.has(r)&&e.replaced?.has(r)!==!0}function bxe(e){let t=vxe(e);return e.composition.features.flatMap(n=>!Sl(n)||n.kind!==`fields`?[]:Fl(n).map(({fieldPath:r,source:i})=>[Al({source:e.target,cap:n.cap,fieldPath:r}),Nl(i).filter(n=>yxe(e,t,n)).map(Al)]))}function xxe(e,t){let n=Ol(e.target),r=new Map;for(let i of t){if(i.blockId===e.blockId)continue;let t=Ol(i.target);if(t===n)throw new nk(`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 nk(`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 rk(e,t){let n=xxe(e,t).flatMap(bxe);return new Map(n)}function Sxe(e,t){let n=rk(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 Cxe(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 wxe(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 ik(e,t){let n=rk(e,t),r=`${Ol(e.target)}#`;return Cxe(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:wxe(t,i,n),component:i}]})}var Txe=3,Exe=120,Dxe=10,ak=S([`no-power-source`,`switch-missing`,`switch-offline`,`switch-unknown`,`restart-in-progress`,`switch-call-failed`,`switch-options-unreadable`,`not-settable`,`switch-is-actuator`,`link-lost`,`link-unknown`]),ok=i(`accepted`,[x({accepted:p(!0)}),x({accepted:p(!1),reason:ak,message:l()})]),sk=x({linked:y(),switchDeviceId:n().nullable(),switchName:l().nullable(),switchOn:y().nullable(),switchOnline:y().nullable(),switchSettable:y().nullable().optional(),restartInProgress:y(),offSeconds:n().int()}),ck=x({switchOn:y().nullable(),offSeconds:n().int(),lastFetchedAt:n()}),lk=[E.Gateway,E.Camera,E.Sensor,E.MediaPlayer,E.Vacuum,E.Generic,E.Washer,E.Dryer,E.Dishwasher,E.PetFountain,E.Fan,E.Humidifier,E.Climate,E.WaterHeater],Oxe={version:1,targets:[{id:`switch`,cardinality:`scalar`,vocabulary:{cap:`power-source`,stateField:`switchOn`},deviceTypes:lk,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`}}]},uk=x({deviceId:n().int().nonnegative()}),dk={method:`getStatus`,field:`switchSettable`},fk={name:`power-source`,scope:`device`,mode:`singleton`,deviceTypes:lk,methods:{getStatus:ti(uk,sk,{auth:`protected`}),powerOn:ti(uk,ok,{kind:`mutation`,auth:`protected`,actions:[{id:`powerSource.on`,label:F(`Power on`,`Dai corrente`),phrase:F(`Power on {device}`,`Dai corrente a {device}`),icon:`power`,offeredWhen:dk}]}),powerOff:ti(uk,ok,{kind:`mutation`,auth:`protected`,actions:[{id:`powerSource.off`,label:F(`Power off`,`Togli corrente`),phrase:F(`Cut the power of {device}`,`Togli la corrente a {device}`),icon:`power-off`,offeredWhen:dk}]}),forceRestart:ti(uk,ok,{kind:`mutation`,auth:`protected`,actions:[{id:`powerSource.forceRestart`,label:F(`Force restart`,`Riavvio forzato`),phrase:F(`Force restart {device} by cutting its power`,`Riavvia {device} togliendo la corrente`),icon:`refresh-cw`}]})},runtimeState:ck,customize:Oxe,durability:`session`,history:`none`,vocabulary:{noun:F(`Power source`,`Alimentazione`),order:1050,state:[{kind:`boolean`,field:`switchOn`,label:F(`Power switch on`,`Presa accesa`),whenTrue:F(`When the power of {device} comes on`,`Quando arriva la corrente a {device}`),whenFalse:F(`When the power of {device} is cut`,`Quando manca la corrente a {device}`),icon:`power`}]}};function pk(e){return typeof e!=`number`||!Number.isFinite(e)?10:Math.min(120,Math.max(3,Math.round(e)))}function kxe(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 Axe(e,t){if(e===null)return null;let n;if(e.target.kind===`existing`)n=e.target.device;else if(t!==void 0)n=Ml(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=Nl(i).find(e=>e.cap===`switch`);return a===void 0?null:{device:n,switch:a.source,offSeconds:pk(kxe(e)),...r.contributedBy===void 0?{}:{contributedBy:r.contributedBy}}}var mk=`switch`;function jxe(e){let t=new Set;return e.target.kind===`existing`&&t.add(Ol(e.target.device)),e.features.forEach((e,n)=>{if(!(e.kind!==`fields`||e.cap!==mk)&&Sl(e)){for(let n of Il(e))for(let e of Nl(n))t.add(Ol(e.source));for(let r of XD(e,n))t.add(Ol(r.command.source))}}),t}function hk(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=jxe(e);return Nl(r).filter(e=>e.cap===mk&&i.has(Ol(e.source))).map(e=>({path:`features[${t}].fields.switchOn`,switch:e.source}))}function gk(e){let t=new Map(e.map(e=>[e.name,e]));return e=>t.get(e)??null}var _k=new Set([`device-status`,`feature-probe`]),Mxe={addonId:Zc,stableId:`${Te}(unsaved)`},Nxe=`(unsaved)`;function Pxe(e,t,n){let r=n(e.cap);if(r===null)return H(`unknown-capability`,`${t}.cap`,`no capability is named \`${e.cap}\``);if(_k.has(r.name))return H(`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?H(`not-composable`,`${t}.cap`,`\`${r.name}\` has no per-device state to compose`):{def:r,state:i,fields:BT(i)}}function Fxe(e){let t=e.helper;if(t===void 0||t.kind!==`group`)return new Set;let n=pO(t.templateId);return n===null||n.family!==`actuator`?new Set:new Set(n.commandCaps)}function Ixe(e,t){return e.name===SD.name&&Object.values(t.commands??{}).some(e=>e.kind===`extension`)}function Lxe({def:e,state:t,fields:n},r,i,a,o){let s=[];e.deviceTypes!==void 0&&!e.deviceTypes.includes(a)&&s.push(H(`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=QD(e).filter(e=>!c.has(e)).map(e=>`\`${e}\``);l.length>0&&!o.has(e.name)&&s.push(H(`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=Ixe(e,r);for(let a of d?[]:VT(t))a!==u&&(n.has(a)?a in r.fields||s.push(H(`missing-field`,`${i}.fields.${a}`,`\`${e.name}.${a}\` is required and has no source`)):s.push(H(`not-composable`,`${i}.fields`,`\`${e.name}.${a}\` is not a scalar — nested fields arrive in a later slice`)));return s}function Rxe({fields:e,state:t},n,r){return n.includes(`.`)?r===`replace`?zT(t,n)??void 0:`nested`:e.get(n)}function zxe(e,t,n,r){let{def:i}=e,{featureIndex:a,path:o,source:s}=t,c=`features[${a}].fields.${o}`,l=Rxe(e,o,n);if(l===`nested`)return TD(H(`nested-field`,c,`\`${o}\` is nested — a nested field is planned only on a declared replace (D1034)`));if(l===void 0)return TD(H(`unknown-field`,c,`\`${i.name}\` has no field \`${o}\``));if(l.kind===`union`)return TD(zD(i.name,o,c));let u=HD(s,r);if(!u.ok)return TD(H(u.code,c,u.message));let d=GD(s),f=KD(l,d,n,i.name,c);if(!f.ok)return TD(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:[...Nl(s)]},h=WD(i.name,l,s,c);return{problems:[...UD(i.name,l,VD(s,l,u.kinds,r),c),...h===null?[]:[h]],fields:[m],features:[],events:[]}}function Bxe(e,t,n,r,i){let a=`features[${n}]`,o=XD(t,n),s=Object.entries(t.commands??{}).filter(([,e])=>e.kind===`code`).map(([e])=>H(`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!==SD.name?[...s,...c.map(([t])=>H(`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,H(`reserved-variant`,`${a}.commands`,"commands (`forward`) are served only by a capability a NEW device builds — not on an existing device")]:[...s,...iO(e,t,a),...o.flatMap(t=>rO(e,t,i))]}function vk(e,t,n,r,i){let a=`features[${t}]`,o=Pxe(e,a,r);if(`code`in o)return TD(o);let s=n.mode===`replace`?[]:[...Lxe(o,e,a,n.deviceType,i)];s.push(...Bxe(o.def,e,t,n.mode,r));let c=Object.entries(e.fields).map(([e,i])=>zxe(o,{featureIndex:t,path:e,source:i},n.mode,r)),l=e.items===void 0?[]:[JD(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=KT(o.def,f,d);return{problems:[...s,...u.flatMap(e=>e.problems),...p.problems],fields:d,features:[f],events:p.events}}function yk(e,t){let n=e.nativeCaps.get(t);return n!==void 0&&n!==`composer`}function Vxe(e){return`code`in e}function Hxe(e,t){if(e.target.kind===`new`)return{kind:`new`,type:e.target.type};let n=Ol(e.target.device);return t===void 0?H(`target-unreadable`,`target`,`target device \`${n}\` was not read — the save is refused rather than stored unchecked`):t.kind===`absent`?H(`target-missing`,`target`,`target device \`${n}\` does not exist`):t.kind===`unreadable`?H(`target-unreadable`,`target`,`could not read target device \`${n}\` (${t.error}) — the save is refused rather than stored unchecked`):{kind:`existing`,found:t}}var Uxe=new Set([`not-composable`,`unknown-capability`,`reserved-variant`]);function Wxe(e,t){let n=t.problems.filter(e=>Uxe.has(e.code));return n.length>0?{problems:n,fields:[],features:[],events:[]}:TD(e)}var Gxe=CD;function Kxe(e){let t=Gxe[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 qxe(e,t,n){let r=t.cap;return e.kind===`new`?{mode:`new`,deviceType:e.type}:yk(e.found,r)?Kxe(t)?{mode:`replace`,deviceType:e.found.type}:H(`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 bk(e,t,n){let r=Hxe(e,n);if(`code`in r)return TD(r);let i=Fxe(e),a=e.features.map((e,n)=>{let a=`features[${n}]`;if(e.kind===`passthrough`)return TD(H(`reserved-variant`,a,`whole-capability passthrough of \`${e.cap}\` arrives in slice 3`));let o=qxe(r,e,a);if(Vxe(o))return!Sl(e)||r.kind!==`existing`?{problems:[],fields:[],features:[],events:[]}:Wxe(o,vk(e,n,{mode:`add`,deviceType:r.found.type},t,i));let s=vk(e,n,o,t,i);return Sl(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 Jxe(e){let t=e.features.flatMap(e=>Sl(e)&&e.kind===`fields`?Il(e).flatMap(Nl).map(e=>e.source):[]);return[...new Map([...t,...ZD(e)].map(e=>[Ol(e),e])).values()]}function Yxe(e,t){return e.features.flatMap(e=>Sl(e)&&e.kind===`fields`?Il(e).flatMap(e=>{if(e.kind!==`from`)return[];let n=t(e.cap),r=n?.runtimeState??n?.status?.schema;return r===void 0?[]:zT(r,e.fieldPath)?.kind===`union`?[e]:[]}):[])}function Xxe(e,t,n){return{ref:e.target.kind===`existing`?e.target.device:t.self??Mxe,native:e.target.kind===`existing`&&t.target?.kind===`found`?t.target:null,replaced:xk(n)}}function xk(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(eE))}function Zxe(e,t,n,r){let i=`${e.cap}.${e.fieldPath}`;return n.some(e=>eE(e)===i&&!r.replaced.has(i))?[]:r.native===null?[H(`source-field-unknown`,t,`this device has no composed field \`${e.cap}.${e.fieldPath}\``)]:yk(r.native,e.cap)?[]:[H(`source-capability-missing`,t,`the target device (device ${r.native.deviceId}) has no native \`${e.cap}\``)]}function Qxe(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?[]:[H(`source-kind-mismatch`,r,`\`${t.cap}.${t.fieldPath}\` of device ${n.deviceId} reads a ${i} now; \`${e.cap}.${e.path}\` takes a ${a}`)]}function $xe(e,t,n){let r=Ol(n.ref);return e.flatMap(i=>i.reads.flatMap(a=>{let o=ED(i),s=Ol(a.source);if(s===r)return Zxe(a,o,e,n);let c=t.sources.get(s);return c===void 0||c.kind===`unreadable`?[H(`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`?[H(`source-missing`,o,`source \`${s}\` does not exist`)]:c.caps.has(a.cap)?Qxe(i,a,c,o):[H(`source-capability-missing`,o,`source \`${s}\` (device ${c.deviceId}) has no \`${a.cap}\``)]}))}function eSe(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 tSe(e,t,n){for(let r of e){let e=eSe(r,t);if(e===null)continue;let i=`${e.cap}.${e.fieldPath}`,a=n.find(e=>eE(e)===i);if(a!==void 0)return ED(a)}return`features`}function nSe(e,t){for(let[n,r]of t)if(e.some(e=>e.startsWith(`${n}#`)))return{key:n,error:r};return null}function rSe(e,t,n,r){let i={blockId:t.blockId??`(unsaved)`,target:r.ref,composition:e,replaced:r.replaced},a=Ol(i.target),o=t.unreadTargets??new Map;try{return ik(i,t.peers).map(e=>{let t=tSe(e.path,a,n),r=nSe([...e.component],o);return r===null?H(`cycle`,t,`a field reads itself: ${e.path.join(` → `)}`):H(`cycle`,t,`possible cycle through \`${r.key}\` — its state could not be read (${r.error}): ${e.path.join(` → `)}`)})}catch(e){if(e instanceof nk)return[H(`duplicate-target`,`features`,e.message)];throw e}}function Sk(e,t){let n=bk(e,t.lookupCap,t.target??void 0),r=Xxe(e,t,n),i=n.problems.filter(e=>e.code===`native-capability-replace`).map(e=>e.path),a=rSe(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,...$xe(n.fields,t,r),...aO(e,t.sources),...a,...tk(e,o),...hk(e).map(e=>H(`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 Ck=x({path:l(),kind:YT,nullable:y(),required:y(),enumValues:C(l()).optional()}),wk=x({cap:l(),fields:C(Ck),itemArray:x({path:l(),keyField:l()}).optional()}),Tk=x({caps:C(wk)});function Ek(e,t){if(_k.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=BT(n),a=e.status?.itemArray?.path??null;return VT(n).some(e=>e!==a&&!i.has(e))&&r.push(`not-composable`),KT(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 iSe(e,t){return e.filter(e=>Ek(e,t).length===0).map(e=>{let t=e.runtimeState,n=t===void 0?[]:[...BT(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 Dk=x({addonId:l().min(1),stableId:l().min(1),cap:l().min(1),fieldPath:l().min(1)}),aSe=x({kind:p(`identity`)}),oSe=x({kind:p(`invert`)}),Ok=x({kind:p(`threshold`),comparison:S([`gte`,`lte`]),threshold:n(),startDwellMs:n().nonnegative(),stopDwellMs:n().nonnegative(),minSamples:n().int().min(1).optional()}),kk=i(`kind`,[aSe,oSe,Ok,x({kind:p(`linear`),scale:n(),offset:n(),clampMin:n().optional(),clampMax:n().optional()}),x({kind:p(`enum-map`),mapping:m(l(),l().nullable())}),x({kind:p(`number`)})]),sSe=x({kind:p(`scalar`),cap:l().min(1),targetId:l().min(1),source:Dk,transform:kk}),cSe=x({kind:p(`keyedArray`),cap:l().min(1),targetId:l().min(1),key:l().min(1),label:l().min(1),fieldPath:l().min(1),source:Dk,transform:kk}),lSe=x({kind:p(`pulse`),cap:l().min(1),targetId:l().min(1),enabled:y(),debounceMs:n().nonnegative(),edges:C(S([`rising`,`button`,`native-event`])).min(1).optional(),sources:C(Dk).min(1)}),uSe=Dk.extend({mode:S([`in-addition`,`confirm`,`replace`]).optional()}),dSe=i(`kind`,[sSe,cSe,lSe,x({kind:p(`span`),cap:l().min(1),targetId:l().min(1),timeoutMs:n().nonnegative(),cooldownMs:n().nonnegative().optional(),sources:C(uSe)})]),fSe=x({targetId:l().min(1),configured:y(),source:S([`native`,`assigned`]),state:S([`active`,`stale`,`released`,`unavailable`]),reason:l().nullable()}),Ak=S([`raw`,`5m`]),jk=S([`high`,`medium`,`low`]),Mk=S([`no-history`,`span-too-short`,`truncated`,`no-idle-floor`,`no-runs`,`no-separation`]),Nk=x({intervals:n().int().nonnegative(),extra:n().int().nonnegative(),missed:n().int().nonnegative()}),Pk=x({tier:Ak,spanMs:n().nonnegative(),from:n(),to:n(),points:n().int().nonnegative(),runsFound:n().int().nonnegative(),pausesFound:n().int().nonnegative(),longestPauseMs:n().nonnegative(),pulsesFound:n().int().nonnegative(),longestPulseMs:n().nonnegative(),idleFloorW:n(),noiseCeilingW:n(),plateauW:n(),replay:Nk}),Fk=x({spanMs:n().nonnegative(),points:n().int().nonnegative(),runsFound:n().int().nonnegative()}),Ik=i(`state`,[x({state:p(`proposal`),transform:Ok,evidence:Pk,confidence:jk,notes:C(l())}),x({state:p(`insufficient`),reason:Mk,evidence:Fk,fallback:Ok})]),Lk=x({apply:y()}),Rk=x({apply:y(),rows:n().int(),raw:n().int(),markers:n().int(),migrated:n().int(),failed:n().int(),remainingRaw:n().int(),unresolvedMarkers:n().int(),redundantCopies:n().int().optional(),verified:y()}),zk=`core-block-`,Bk=`core-blocks`;function pSe(e){return`${zk}${e}`}function mSe(e){if(!e.startsWith(`core-block-`))return null;let t=e.slice(11);return t.length>0?t:null}var Vk=h([p(`hub`),l().min(1)]),Hk=S([`stopped`,`starting`,`running`,`degraded`,`incomplete`,`failed`]),Uk=`main.ts`,Wk=m(l().min(1).max(260),l().max(2e5)),Gk=ve(),Kk=x({name:l().min(1).max(120),code:l().max(2e5).optional(),files:Wk.optional(),entry:l().min(1).max(260).optional(),enabled:y(),placement:Vk,integrationId:l().optional(),settingsSchema:Gk.optional(),tags:Hh.optional()}),qk=Kk.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 Jk(e){return e!==void 0&&e.length>0?e:Uk}function hSe(e){let t=Jk(e.entry);return e.files===void 0?{files:{[t]:e.code},entry:t}:{files:{...e.files},entry:t}}function gSe(e){if(e.files!==void 0){let t=Jk(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 Yk=i(`kind`,[x({kind:p(`code`)}),x({kind:p(`recipe`),recipe:Kv}),x({kind:p(`composition`),composition:Dl})]),Xk=x({name:l().min(1).max(120).optional(),enabled:y(),composition:Dl}),Zk=x({name:l().min(1).max(120),code:l().max(2e5),files:Wk.optional(),entry:l().min(1).max(260).optional(),enabled:y(),placement:Vk,integrationId:l().optional(),settingsSchema:Gk.optional(),tags:Hh.optional(),id:l(),createdAt:n(),updatedAt:n(),createdBy:l(),status:Hk,lastError:l().optional(),lastChangedAt:n(),source:Yk.optional()});function _Se(e){return e.source?.kind??`code`}function vSe(e){return e.source?.kind===`composition`?e.source.composition:null}var Qk=i(`kind`,[x({kind:p(`answered`),state:sE.nullable()}),x({kind:p(`unreachable`),error:l()})]),$k=x({block:Zk,state:Qk}),eA=x({state:p(`not-loaded`),reason:l()}),tA=i(`state`,[x({state:p(`loaded`),views:C($k)}),eA]),nA=i(`state`,[x({state:p(`loaded`),view:$k.nullable()}),eA]),rA=i(`state`,[x({state:p(`loaded`),view:$k.nullable()}),eA]),iA=x({ok:y(),error:l().optional(),line:n().optional(),column:n().optional()}),aA=x({code:l().optional(),files:Wk.optional(),entry:l().min(1).max(260).optional()}).superRefine((e,t)=>{if(e.files!==void 0){let n=e.entry??`main.ts`;e.files[n]===void 0&&t.addIssue({code:`custom`,message:`files must include the entry "${n}"`,path:[`files`]});return}e.code===void 0&&t.addIssue({code:`custom`,message:`code or files is required`,path:[`code`]})}),oA={name:`core-blocks`,scope:`system`,mode:`singleton`,methods:{list:A(x({}),x({blocks:C(Zk)}),{auth:`admin`}),get:A(x({blockId:l()}),x({block:Zk.nullable()}),{auth:`admin`}),create:A(x({block:qk}),x({block:Zk}),{kind:`mutation`,auth:`admin`,caller:`required`}),update:A(x({blockId:l(),block:Kk.partial()}),x({block:Zk}),{kind:`mutation`,auth:`admin`,caller:`required`}),delete:A(x({blockId:l()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setEnabled:A(x({blockId:l(),enabled:y()}),x({block:Zk}),{kind:`mutation`,auth:`admin`}),restart:A(x({blockId:l()}),x({block:Zk}),{kind:`mutation`,auth:`admin`}),compile:A(aA,iA,{kind:`mutation`,auth:`admin`}),getBlockSettings:A(x({blockId:l()}),sS.nullable(),{auth:`admin`}),updateBlockSettings:A(x({blockId:l(),patch:cS}),uS,{kind:`mutation`,auth:`admin`}),migrateRawSecrets:A(Lk,Rk,{kind:`mutation`,auth:`admin`}),getTypeDefs:A(x({}),x({libs:C(x({filePath:l(),content:l()}))}),{auth:`admin`}),createComposition:A(x({block:Xk}),x({block:Zk}),{kind:`mutation`,auth:`admin`,caller:`required`}),updateComposition:A(x({blockId:l(),expectedUpdatedAt:n(),block:Xk.partial()}),x({block:Zk}),{kind:`mutation`,auth:`admin`,caller:`required`}),getComposition:A(x({blockId:l()}),nA,{auth:`admin`}),listCompositions:A(x({}),tA,{auth:`admin`}),getCustomization:A(x({addonId:l().min(1),stableId:l().min(1)}),rA,{auth:`admin`}),listComposableCaps:A(x({deviceType:S(E)}),Tk,{auth:`admin`}),validateComposition:A(x({composition:Dl,blockId:l().optional()}),rE,{kind:`mutation`,auth:`admin`,access:`view`}),proposeRunningThreshold:A(x({deviceId:n().int(),cap:l().min(1),fieldPath:l().min(1),deviceType:S(E).optional()}),Ik,{auth:`admin`,access:`view`}),reportAutomationRun:A(x({blockId:l().min(1),trace:Ay.optional(),runStartedAt:n().optional(),keepTraces:n().int().min(1).max(100).optional()}),v(),{kind:`mutation`,auth:`admin`}),getAutomationRunState:A(x({blockId:l().min(1)}),jy,{auth:`admin`}),getTraces:A(x({blockId:l().min(1)}),x({traces:C(Ay),lastError:l().nullable()}),{auth:`admin`})},vocabulary:{notOperatorFacing:M.INTERNAL}},sA=S([`open`,`opening`,`closing`,`closed`,`stopped`]),cA=x({state:sA,position:n().min(0).max(100).nullable().meta(N(`percentage`)),tiltPosition:n().min(0).max(100).nullable().meta(N(`percentage`)),lastChangedAt:n()}),lA={name:`cover`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Cover],methods:{open:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.open`,label:F(`Open`,`Apri`),phrase:F(`Open {device}`,`Apri {device}`),icon:`arrow-up-to-line`,effect:{field:`state`,value:`open`}}]}),close:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.close`,label:F(`Close`,`Chiudi`),phrase:F(`Close {device}`,`Chiudi {device}`),icon:`arrow-down-to-line`,effect:{field:`state`,value:`closed`}}]}),stop:j(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.stop`,label:F(`Stop`,`Ferma`),phrase:F(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),setPosition:j(x({deviceId:n().int().nonnegative(),position:n().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.position`,label:F(`Set position`,`Imposta la posizione`),phrase:F(`Move {device} to {position} open`,`Porta {device} al {position} di apertura`),icon:`blinds`,effect:{field:`position`,fromArg:`position`},openArgs:[{key:`position`,label:F(`Position`,`Posizione`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setTiltPosition:j(x({deviceId:n().int().nonnegative(),tiltPosition:n().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.tilt`,label:F(`Set tilt`,`Imposta l’inclinazione`),phrase:F(`Tilt {device} to {tiltPosition}`,`Inclina {device} al {tiltPosition}`),icon:`blinds`,effect:{field:`tiltPosition`,fromArg:`tiltPosition`},openArgs:[{key:`tiltPosition`,label:F(`Tilt`,`Inclinazione`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]})},status:{schema:cA,kind:`push`},runtimeState:cA,durability:`restored`,history:{fields:{position:{kind:`gauge`,unit:`%`,minIntervalMs:0}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Cover`,`Copertura`),order:1030,state:[{kind:`enum`,field:`state`,label:F(`State`,`Stato`),values:[{value:`open`,label:F(`Open`,`Aperto`),phrase:F(`When {device} is fully open`,`Quando {device} è tutto aperto`)},{value:`opening`,label:F(`Opening`,`In apertura`),phrase:F(`When {device} starts opening`,`Quando {device} inizia ad aprirsi`)},{value:`closing`,label:F(`Closing`,`In chiusura`),phrase:F(`When {device} starts closing`,`Quando {device} inizia a chiudersi`)},{value:`closed`,label:F(`Closed`,`Chiuso`),phrase:F(`When {device} is fully closed`,`Quando {device} è tutto chiuso`)},{value:`stopped`,label:F(`Stopped`,`Fermo`),phrase:F(`When {device} stops part-way`,`Quando {device} si ferma a metà`)}],icon:`blinds`},{kind:`numeric`,field:`position`,quantity:F(`the opening`,`l’apertura`),label:F(`Position`,`Posizione`),unit:`%`,icon:`blinds`}],overrides:{byRole:{[O.CoverGarage]:{actions:{"cover.open":{phrase:F(`Open the garage door {device}`,`Apri il garage {device}`),icon:`warehouse`},"cover.close":{phrase:F(`Close the garage door {device}`,`Chiudi il garage {device}`),icon:`warehouse`}}},[O.CoverGate]:{actions:{"cover.open":{phrase:F(`Open the gate {device}`,`Apri il cancello {device}`),icon:`fence`},"cover.close":{phrase:F(`Close the gate {device}`,`Chiudi il cancello {device}`),icon:`fence`}}},[O.CoverDoor]:{actions:{"cover.open":{phrase:F(`Open the door {device}`,`Apri la porta {device}`),icon:`door-open`},"cover.close":{phrase:F(`Close the door {device}`,`Chiudi la porta {device}`),icon:`door-closed`}}},[O.CoverWindow]:{actions:{"cover.open":{phrase:F(`Open the window {device}`,`Apri la finestra {device}`),icon:`app-window`},"cover.close":{phrase:F(`Close the window {device}`,`Chiudi la finestra {device}`),icon:`app-window`}}},[O.CoverShutter]:{actions:{"cover.open":{phrase:F(`Raise the shutter {device}`,`Alza la tapparella {device}`)},"cover.close":{phrase:F(`Lower the shutter {device}`,`Abbassa la tapparella {device}`)}}},[O.CoverAwning]:{actions:{"cover.open":{phrase:F(`Extend the awning {device}`,`Apri la tenda da sole {device}`)},"cover.close":{phrase:F(`Retract the awning {device}`,`Chiudi la tenda da sole {device}`)}}}}}}},uA=x({stepId:l(),entry:rg}),dA=x({path:l().min(1),bytes:n().int().nonnegative(),sha256:l().regex(/^[0-9a-f]{64}$/)}),fA=x({addonId:l(),stepId:l().min(1),entries:C(rg).min(1).max(4),bundle:x({ticket:Si,bytes:n().int().positive(),sha256:l().regex(/^[0-9a-f]{64}$/)}),files:C(dA).min(1).max(64),distribute:y()}),pA=i(`kind`,[x({kind:p(`imported`),modelIds:C(l()).readonly(),distributed:C(x({modelId:l(),nodeId:l(),format:S(Na),ok:y(),error:l().optional()})).readonly()}),x({kind:p(`refused`),reason:S([`transfer-failed`,`checksum-mismatch`,`bundle-mismatch`,`invalid-entry`,`id-taken`]),detail:l()})]),mA={name:`custom-model-registry`,scope:`system`,mode:`collection`,internal:!0,methods:{listModels:A(v(),C(uA).readonly(),{auth:`admin`}),importModelBundle:A(fA,pA,{kind:`mutation`,auth:`admin`,timeoutMs:30*6e4})},vocabulary:{notOperatorFacing:M.ML}},hA=x({engineId:l(),kind:S([`relational`,`vector`]),displayName:l()}),gA={name:`data-store-provider`,scope:`system`,mode:`collection`,internal:!0,methods:{getEngineInfo:A(v(),hA,{auth:`admin`}),get:A(x({namespace:l().optional(),collection:l(),key:l()}),w(),{auth:`admin`}),set:A(x({namespace:l().optional(),collection:l(),key:l(),value:w()}),v(),{kind:`mutation`,auth:`admin`}),query:A(x({namespace:l().optional(),collection:l(),filter:pf.optional(),columns:C(l()).readonly().optional()}),C(_f).readonly(),{auth:`admin`}),insert:A(x({namespace:l().optional(),collection:l(),record:x({id:l().optional(),data:m(l(),w())})}),x({id:h([l(),n()])}),{kind:`mutation`,auth:`admin`}),upsert:A(x({namespace:l().optional(),collection:l(),conflict:C(l()).readonly(),record:vf}),x({id:h([l(),n()])}),{kind:`mutation`,auth:`admin`}),upsertMany:A(x({namespace:l().optional(),collection:l(),conflict:C(l()).readonly(),records:C(vf).readonly()}),x({upserted:n().int()}),{kind:`mutation`,auth:`admin`}),insertMany:A(x({namespace:l().optional(),collection:l(),records:C(vf).readonly()}),x({inserted:n().int()}),{kind:`mutation`,auth:`admin`}),transact:A(x({namespace:l().optional(),guard:xf.optional(),ops:C(bf).readonly()}),x({applied:y(),current:w().optional()}),{kind:`mutation`,auth:`admin`}),update:A(x({namespace:l().optional(),collection:l(),id:l(),data:m(l(),w())}),v(),{kind:`mutation`,auth:`admin`}),delete:A(x({namespace:l().optional(),collection:l(),key:l()}),v(),{kind:`mutation`,auth:`admin`}),deleteWhere:A(x({namespace:l().optional(),collection:l(),filter:mf}),x({deleted:n().int()}),{kind:`mutation`,auth:`admin`}),updateWhere:A(x({namespace:l().optional(),collection:l(),filter:mf,data:m(l(),w())}),x({updated:n().int()}),{kind:`mutation`,auth:`admin`}),count:A(x({namespace:l().optional(),collection:l(),filter:pf.optional()}),n(),{auth:`admin`}),aggregate:A(x({namespace:l().optional(),collection:l(),fields:C(hf).readonly(),filter:pf.optional()}),gf,{auth:`admin`}),histogram:A(x({namespace:l().optional(),collection:l(),field:l(),bucketSize:n().int().positive(),origin:n().int(),filter:pf.optional()}),C(x({bucket:n().int(),count:n().int()})).readonly(),{auth:`admin`}),isEmpty:A(x({namespace:l().optional(),collection:l()}),y(),{auth:`admin`}),declareCollection:A(wf,v(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.INTERNAL}},_A=S([`auto`,`day`,`night`,`schedule`]),vA=x({min:n(),max:n(),step:n()}),yA=x({mode:_A,sensitivity:n().optional().meta(N(`none`)),switchDelaySec:n().optional().meta(N(`duration`)),lastFetchedAt:n()}),bA=x({modes:C(_A),supportsSensitivity:y(),sensitivity:vA.optional(),supportsSwitchDelay:y(),switchDelaySec:vA.optional()}),xA=x({mode:_A.optional(),sensitivity:n().optional(),switchDelaySec:n().optional()}),SA={name:`day-night`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],deviceConfig:{ui:{kind:`derived-form`,builderId:`day-night`,tab:`image`}},methods:{getOptions:A(x({deviceId:n()}),bA),setSettings:A(x({deviceId:n(),settings:xA}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`dayNight.auto`,label:F(`Day/night auto`,`Giorno/notte automatico`),phrase:F(`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:F(`Day mode`,`Modalità giorno`),phrase:F(`Force {device} into day mode`,`Forza {device} in modalità giorno`),icon:`sun`,args:{settings:{mode:`day`}}},{id:`dayNight.night`,label:F(`Night mode`,`Modalità notte`),phrase:F(`Force {device} into night mode`,`Forza {device} in modalità notte`),icon:`moon`,args:{settings:{mode:`night`}}}]})},status:{schema:yA,kind:`poll`},runtimeState:yA,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Day/night`,`Giorno/notte`),order:3070,state:[{kind:`enum`,field:`mode`,label:F(`Day/night mode`,`Modalità giorno/notte`),values:[{value:`auto`,label:F(`Automatic`,`Automatica`)},{value:`day`,label:F(`Day`,`Giorno`),phrase:F(`When {device} switches to day mode`,`Quando {device} passa in modalità giorno`)},{value:`night`,label:F(`Night`,`Notte`),phrase:F(`When {device} switches to night mode`,`Quando {device} passa in modalità notte`)},{value:`schedule`,label:F(`Scheduled`,`Programmata`)}],icon:`sun-moon`}]}},ySe=[{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)`}],bSe={hwaccel:`auto`,probedBestHwaccel:``},CA={name:`decoder`,scope:`system`,mode:`singleton`,preferredProvider:`decoder-nodeav`,methods:{getInfo:A(v(),x({id:l(),name:l(),hwaccel:l().optional(),probedBestHwaccel:l().optional()})),reprobeHwaccel:A(v(),x({backend:l()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.PIPELINE}},wA={name:`detection-pipeline`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[E.Camera],exposesDeviceSettings:!0,methods:{},vocabulary:{noun:F(`Detection pipeline`,`Pipeline di rilevamento`),order:3080}},TA=S([`device`,`integration`]),EA=x({url:l(),label:l(),target:TA,host:l()}),DA={name:`device-admin-link`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{getAdminLink:A(x({deviceId:n().int().nonnegative()}),EA.nullable(),{auth:`admin`})},vocabulary:{noun:F(`Admin link`,`Link di amministrazione`),order:3090}},OA=S([`online`,`sleeping`,`offline`,`unknown`]),kA=a(()=>x({childNativeId:l(),name:l(),type:S(E),status:OA,metadata:x({model:l().optional(),serialNumber:l().optional(),uid:l().optional(),rtspChannel:n().int().nonnegative().optional(),isBattery:y().optional(),isDoorbell:y().optional(),isMultifocal:y().optional(),externalLocation:l().optional(),manufacturer:l().optional(),integration:l().optional()}).default({}),alreadyAdopted:y(),adoptedDeviceId:n().int().nonnegative().nullable(),capabilities:C(l()).readonly().optional(),features:C(l()).readonly().optional(),sourceInfo:Xg.optional(),children:C(kA).readonly().optional(),parentStableId:l().optional()})),AA=x({id:l(),label:l(),isDefault:y().optional()}),jA=x({search:l().optional(),area:l().optional(),manufacturer:l().optional(),adoptedOnly:y().optional(),unadoptedOnly:y().optional()}),MA=x({integrationId:l(),page:n().int().positive().default(1),pageSize:n().int().positive().max(2e4).default(50),filter:l().optional(),filterText:jA.optional()}),NA=x({candidates:C(kA).readonly(),totalCount:n().int().nonnegative(),page:n().int().positive(),pageSize:n().int().positive()}),PA=x({integrationId:l(),childNativeId:l()}),FA=x({lastDiscoveryAt:n().int().nonnegative().nullable(),candidateCount:n().int().nonnegative(),adoptedCount:n().int().nonnegative(),lastError:l().nullable()}),xSe=x({name:l().min(1).optional(),hiddenChildIds:C(l()).optional()}),IA=x({integrationId:l(),childNativeIds:C(l()).min(1),filter:l().optional(),importLocations:y().optional(),perCandidate:m(l(),xSe).optional()}),LA=x({adopted:C(x({childNativeId:l(),parentDeviceId:n().int().nonnegative(),accessoryDeviceIds:C(n().int().nonnegative()).readonly()})).readonly()}),RA=x({integrationId:l(),camDeviceId:n().int().nonnegative()}),zA=x({camDeviceId:n().int().nonnegative(),resetToSource:y().optional()}),BA=x({changed:y(),rebuiltChildren:n().int().nonnegative(),removedChildren:n().int().nonnegative().optional()}),VA={name:`device-adoption`,scope:`system`,mode:`collection`,status:{schema:FA,kind:`poll`},methods:{listCandidateFilters:A(x({integrationId:l()}),x({filters:C(AA)}),{auth:`admin`}),listCandidates:A(MA,NA,{auth:`admin`}),getCandidate:A(PA,kA.nullable(),{auth:`admin`}),refresh:A(x({integrationId:l()}),FA,{kind:`mutation`,auth:`admin`}),adopt:A(IA,LA,{kind:`mutation`,auth:`admin`}),release:A(RA,v(),{kind:`mutation`,auth:`admin`}),resync:A(zA,BA,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`device adoption — an onboarding flow, not an action`}},HA=i(`state`,[x({state:p(`absent`)}),x({state:p(`ready`),subject:l(),fingerprintSha256:l(),validTo:l()}),x({state:p(`unavailable`),reason:l()})]),UA=x({selfEnrollment:S([`allowed`,`disabled`])}),WA={name:`device-credentials`,scope:`system`,mode:`singleton`,methods:{listDeviceCredentials:A(x({userId:l().min(1).optional(),includeRevoked:y().default(!1)}),C(ume).readonly(),{auth:`admin`}),startEnrollment:A(x({userId:l().min(1),deviceName:l().min(1).max(80)}),dme,{kind:`mutation`,auth:`admin`,caller:`required`}),revokeDeviceCredential:A(x({id:l().min(1)}),x({revoked:y(),sessionsEnded:n().int(),status:wg}),{kind:`mutation`,auth:`admin`,caller:`required`}),getDeviceCertificateSettings:A(x({}),UA,{auth:`admin`}),setDeviceCertificateSettings:A(UA,UA,{kind:`mutation`,auth:`admin`}),deleteDeviceCredential:A(x({id:l().min(1)}),x({result:S([`deleted`,`live`,`unknown`])}),{kind:`mutation`,auth:`admin`,caller:`required`}),getDeviceCaStatus:A(x({}),HA,{auth:`admin`}),renameDeviceCredential:A(x({id:l().min(1),deviceName:l().min(1).max(80)}),x({renamed:y()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.IDENTITY}},SSe=64,GA=/^[a-z][a-z0-9_]*$/,CSe=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(`.`)),KA=l().max(64).regex(GA);function qA(e){return CSe.has(e)}function JA(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 wSe(e,t){let n=JA(e);if(!qA(n)&&!t(n))return n;for(let e=2;;e+=1){let r=`${n}_${e}`;if(!t(r))return r}}function TSe(e,t){return e.length===0?{ok:!1,reason:`empty`}:e.length>64?{ok:!1,reason:`too-long`}:GA.test(e)?qA(e)?{ok:!1,reason:`reserved`}:t(e)?{ok:!1,reason:`taken`}:{ok:!0,alias:e}:{ok:!1,reason:`grammar`}}var YA=4096,ESe=50,DSe=4096,OSe=`—`,XA=l().min(1).max(YA),kSe=`now`,ASe=`camera`,ZA=h([l(),n(),y()]),QA=x({deviceId:n().int(),values:m(l().min(1).max(64),ZA).optional()}),jSe=`values`,MSe=cu(),$A=[`too-long`,`syntax`,`forbidden-syntax`,`forbidden-member`,`unknown-filter`,`ambiguous-field`,`busy`,`budget-exceeded`,`timeout`,`output-too-large`,`render-failed`,`out-of-scope`,`unavailable`],ej=x({reason:S($A),message:l()}),tj=[`unknown-alias`,`unknown-field`,`no-field`,`unavailable`],nj=x({ref:l(),reason:S(tj)}),rj=i(`ok`,[x({ok:p(!0),text:l(),trace:C(nj)}),x({ok:p(!1),refusal:ej,trace:C(nj)})]);function ij(e){return e.replace(/-/g,`_`)}function aj(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function oj(e,t){let n=e;for(let e of t)if(Array.isArray(n)&&typeof e==`number`)n=n[e];else if(aj(n)&&Object.hasOwn(n,String(e)))n=n[String(e)];else return;return n}function NSe(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||ij(e)===n);if(i!==void 0){let n=t.slice(1);if(n.length===0)return{kind:`missing`,reason:`no-field`};let r=oj(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 aj(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=oj(e.slices[o],t);return s===void 0?{kind:`missing`,reason:`unknown-field`}:{kind:`value`,cap:o,fieldPath:t,value:s}}var sj=x({zoneKey:l(),label:l(),icon:Lh.nullable(),locationKeys:C(l())});function PSe(e){return e.trim().toLowerCase()}var cj=[`mac`,`serial`,`machine-uuid`,`vendor-uid`,`hostname`,`ip`],lj=S(cj),uj=S([`read`,`derived`]),FSe=/^[0-9a-f]{2}(?::[0-9a-f]{2}){5}$/,dj=/^[a-z0-9][a-z0-9._-]*:[^\sA-Z]+$/,fj=/^[0-9a-f][0-9a-f-]{7,}$/,pj=/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;function mj(e){return x({value:e,origin:uj,readAt:n().int().nonnegative()}).strict()}var ISe=mj(l().regex(FSe)),LSe=mj(l().regex(dj)),RSe=mj(l().regex(fj)),zSe=mj(l().regex(dj)),BSe=mj(l().regex(pj)),VSe=mj(h([_(),o()])),HSe=x({value:l().min(1),origin:uj,readAt:n().int().nonnegative()}).strict(),hj=x({mac:C(ISe).min(1).readonly().optional(),serial:LSe.optional(),"machine-uuid":RSe.optional(),"vendor-uid":zSe.optional(),hostname:BSe.optional(),ip:VSe.optional()}).strict(),USe={mac:`strong`,serial:`strong`,"machine-uuid":`strong`,"vendor-uid":`strong`,hostname:`weak`,ip:`weak`};function WSe(e){return USe[e]}function gj(e){return cj.every(t=>e[t]===void 0)}var GSe=/^(?:unknown|none|n\/?a|null|undefined|default|0+|-+)$/i,KSe=new Set([`00:00:00:00:00:00`,`ff:ff:ff:ff:ff:ff`]);function _j(e){return{ok:!1,reason:e}}function vj(e){let t=e.trim().toLowerCase().replace(/[\s:.-]/g,``);if(!/^[0-9a-f]{12}$/.test(t))return _j(`not a 48-bit MAC`);let n=(t.match(/../g)??[]).join(`:`);return KSe.has(n)?_j(`placeholder MAC`):{ok:!0,value:n}}function qSe(e){return e.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,`-`).replace(/^[-._]+|[-._]+$/g,``)}function yj(e,t,n){let r=qSe(e);if(r.length===0)return _j(`no ${n}`);let i=t.trim().toLowerCase().replace(/\s+/g,``);return i.length===0?_j(`blank value`):GSe.test(i)?_j(`placeholder value`):{ok:!0,value:`${r}:${i}`}}function JSe(e){let t=e.trim().toLowerCase().replace(/^\{|\}$/g,``);return fj.test(t)?/^[0-]+$/.test(t)||/^[f-]+$/.test(t)?_j(`placeholder uuid`):{ok:!0,value:t}:_j(`not a uuid`)}function bj(e){return h([_(),o()]).safeParse(e).success}function YSe(e){let t=e.trim().toLowerCase().replace(/\.$/,``);if(t.length===0)return _j(`blank hostname`);if(bj(t))return _j(`an address, not a hostname`);let n=t.split(`.`)[0]??``;return pj.test(n)?n===`localhost`?_j(`placeholder hostname`):{ok:!0,value:n}:_j(`not a hostname`)}function XSe(e){let t=e.trim().toLowerCase().replace(/^\[|\]$/g,``);return bj(t)?t===`0.0.0.0`||t===`::`||t===`::1`||t.startsWith(`127.`)?_j(`loopback or unspecified address`):{ok:!0,value:t}:_j(`not an IP address`)}function xj(e){return e==null||e.trim().length===0}function Sj(e,t={}){let n=t.readAt??Date.now(),r=e=>t.originByKey?.[e]??t.origin??`read`,i=(e,t)=>({value:t,origin:r(e),readAt:n}),a=[],o=(e,t,n)=>{if(n.ok)return i(e,n.value);a.push({key:e,value:t,reason:n.reason})},s=e.mac===null||e.mac===void 0?[]:[e.mac].flat(),c=[];for(let e of s){if(xj(e))continue;let t=o(`mac`,e,vj(e));t!==void 0&&!c.some(e=>e.value===t.value)&&c.push(t)}let l=e.serial===null||e.serial===void 0||xj(e.serial.serial)?void 0:o(`serial`,`${e.serial.manufacturer}:${e.serial.serial}`,yj(e.serial.manufacturer,e.serial.serial,`manufacturer`)),u=e.vendorUid===null||e.vendorUid===void 0||xj(e.vendorUid.id)?void 0:o(`vendor-uid`,`${e.vendorUid.vendor}:${e.vendorUid.id}`,yj(e.vendorUid.vendor,e.vendorUid.id,`vendor`)),d=xj(e.machineUuid)?void 0:o(`machine-uuid`,e.machineUuid,JSe(e.machineUuid)),f=xj(e.host)?null:e.host.trim(),p=f!==null&&bj(f.toLowerCase().replace(/^\[|\]$/g,``)),m=xj(e.hostname)?p?null:f:e.hostname,h=xj(e.ip)?p?f:null:e.ip,g=m===null?void 0:o(`hostname`,m,YSe(m)),_=h===null?void 0:o(`ip`,h,XSe(h));return{identifiers:{...c.length>0?{mac:c}:{},...l===void 0?{}:{serial:l},...d===void 0?{}:{"machine-uuid":d},...u===void 0?{}:{"vendor-uid":u},...g===void 0?{}:{hostname:g},..._===void 0?{}:{ip:_}},rejected:a}}function Cj(e,t){return e.value===t.value&&e.origin===t.origin}function wj(e,t){return t!==void 0&&Cj(e,t)?t:e}function ZSe(e,t,n=[]){let r=e??{},i=t??{},a=new Set(n),o=a.has(`mac`)?r.mac:i.mac?.map(e=>wj(e,r.mac?.find(t=>Cj(t,e)))),s=e=>{if(a.has(e))return r[e];let t=i[e];return t===void 0?void 0:wj(t,r[e])},c=s(`serial`),l=s(`machine-uuid`),u=s(`vendor-uid`),d=s(`hostname`),f=s(`ip`),p={...o!==void 0&&o.length>0?{mac:o}:{},...c===void 0?{}:{serial:c},...l===void 0?{}:{"machine-uuid":l},...u===void 0?{}:{"vendor-uid":u},...d===void 0?{}:{hostname:d},...f===void 0?{}:{ip:f}};return gj(p)?null:p}function QSe(e,t){let n=e=>e==null||gj(e)?``:JSON.stringify(cj.map(t=>[t,e[t]??null]).map(([e,t])=>[e,t===null?null:[t].flat().map(e=>[e.value,e.origin,e.readAt])]));return n(e)===n(t)}var Tj=S([`auto`,`proposal`]),Ej=x({key:lj,value:l()}),Dj=x({deviceId:n().int(),addonId:l(),integrationId:l().nullable()}),Oj=x({a:Dj,b:Dj,keys:C(Ej).readonly(),confidence:Tj}),kj=i(`status`,[x({status:p(`unknown`),reason:l()}),x({status:p(`answered`),pairs:C(Oj).readonly(),undeclaredDeviceIds:C(n().int()).readonly()})]),Aj=[`same-device`,`poe-power`],jj=S(Aj),Mj=S([`proposed`,`linked`,`dismissed`]),Nj=S([`auto`,`operator`]),Pj=x({addonId:l().min(1),stableId:l().min(1),deviceId:n().int()}),Fj=x({kind:jj,a:Pj,b:Pj,state:Mj,origin:Nj,evidence:C(Ej).readonly(),evidenceGone:p(!0).optional(),createdAt:n().int().nonnegative(),decidedAt:n().int().nonnegative().optional()}),Ij=Fj.extend({id:l().min(1)}),Lj={"same-device":{directional:!1,attachingRole:null,contributions:[]},"poe-power":{directional:!0,attachingRole:O.PoePort,contributions:[{cap:`power-source`,targetId:`switch`,host:`b`,source:`a`,sourceCap:`switch`,sourceField:`on`}]}};function $Se(e,t){let n=Lj[e].attachingRole;return n===null||t===n?null:`attaching-side-role`}function Rj(e){return`${e.addonId}/${e.stableId}`}function eCe(e,t,n){let r=Rj(t),i=Rj(n);return Lj[e].directional||r<=i?`${e}:${r}|${i}`:`${e}:${i}|${r}`}var zj=i(`status`,[x({status:p(`not-loaded`),reason:l()}),x({status:p(`answered`),links:C(Ij).readonly()})]),Bj=S([`not-loaded`,`unknown-link`,`wrong-state`]),Vj=i(`ok`,[x({ok:p(!0),link:Ij}),x({ok:p(!1),reason:Bj,message:l()})]),Hj=S([`evidence-gone`,`device-removed`,`operator-unlinked`]),tCe=x({linkId:l(),kind:jj,aDeviceId:n().int(),bDeviceId:n().int(),origin:Nj,reason:Hj.optional()}),nCe=50,rCe=200,Uj=x({caps:C(l()).readonly().optional(),actions:C(l()).readonly().optional(),mode:S([`any`,`all`]).optional()}),Wj=x({locations:C(l()).readonly().optional(),integrationIds:C(l()).readonly().optional(),types:C(l()).readonly().optional()}),Gj=x({text:l().optional(),requires:Uj.optional(),filters:Wj.optional(),includeIncompatible:y().optional(),contextDeviceId:n().optional(),ids:C(n()).readonly().optional(),cursor:l().nullable().optional(),limit:n().int().min(1).max(200).optional()}),Kj=x({cap:l(),path:l(),label:l(),reading:l().nullable(),unit:l().nullable().optional(),quantity:la.optional()}),qj=x({id:n(),name:l(),type:S(E),location:l().nullable(),integrationId:l().nullable(),integrationLabel:l().nullable(),online:y().nullable(),disabled:y(),compatible:y(),values:C(Kj).readonly()}),Jj=x({value:l(),count:n()}),Yj=x({id:l(),label:l(),count:n()}),Xj=x({locations:C(Jj).readonly(),integrations:C(Yj).readonly(),types:C(Jj).readonly()}),Zj=x({items:C(qj).readonly(),nextCursor:l().nullable(),total:n(),compatibleTotal:n(),fleetTotal:n(),hiddenIncompatible:n(),facets:Xj,suggested:C(qj).readonly(),missingIds:C(n()).readonly()}),Qj=x({connected:y(),deviceCount:n(),error:l().optional(),motionSliceWriter:p(`orchestrator`).optional()}),iCe=x({externalId:l(),name:l(),type:l(),metadata:m(l(),w()).optional()}),$j=i(`kind`,[x({kind:p(`mdns`),serviceType:l().min(1),instancePattern:l().optional()}),x({kind:p(`ws-discovery`),types:C(l()).optional()}),x({kind:p(`ssdp`),searchTarget:l().min(1)}),x({kind:p(`udp-broadcast`),port:n().int().min(1).max(65535),payloadHex:l().regex(/^([0-9a-fA-F]{2})*$/),listenPort:n().int().min(1).max(65535).optional()}),x({kind:p(`http-probe`),port:n().int().min(1).max(65535),path:l().startsWith(`/`),method:S([`GET`,`POST`]).default(`GET`),bodyText:l().optional(),contentType:l().optional(),tls:y().default(!1),acceptStatus:C(n().int()).optional()}),x({kind:p(`custom`),reason:l().min(1)})]),eM=x({modeIndex:n().int().min(0),host:l(),port:n().int(),http:x({status:n().int(),headers:m(l(),l()),bodyText:l()}).optional(),mdns:x({instance:l(),host:l(),port:n().int(),txt:m(l(),l())}).optional(),udp:x({payloadHex:l()}).optional(),wsd:x({xaddrs:C(l()),types:C(l()),scopes:C(l())}).optional()}),tM=x({stableId:l(),type:S(E),suggestedName:l(),prefilledConfig:m(l(),w()),sourceInfo:Xg.optional(),alreadyOnboarded:y().optional(),onboardedDeviceId:n().optional(),onboardedName:l().optional(),setupIntegration:y().optional(),parentStableId:l().optional(),selectable:y().optional(),needsParams:C(l()).optional()}),nM=x({id:n(),stableId:l(),addonId:l(),type:l(),name:l(),parentDeviceId:n().nullable(),online:y(),features:C(l()),config:m(l(),w()),sourceInfo:Xg.optional()}),rM=x({status:S([`ok`,`error`]),labels:C(l()).optional(),error:l().optional()}),iM=w(),aM={name:`device-provider`,scope:`system`,mode:`collection`,methods:{start:A(v(),v(),{kind:`mutation`}),stop:A(v(),v(),{kind:`mutation`}),getStatus:A(v(),Qj),getDevices:A(v(),C(x({id:l(),name:l(),type:l()}))),reloadDevice:A(x({stableId:l()}),x({deviceId:n()}),{kind:`mutation`,timeoutMs:3*6e4}),supportsDiscovery:A(x({}),y()),discoverDevices:A(x({params:m(l(),w()).optional()}),C(tM),{kind:`mutation`,auth:`admin`}),getDiscoveryModes:A(x({}),C($j)),classifyDiscoveryHits:A(x({hits:C(eM),params:m(l(),w()).optional()}),C(tM),{kind:`mutation`,auth:`admin`}),getDiscoveryParamsSchema:A(x({}),iM),getManualCreationType:A(x({integrationId:l().optional()}),x({deviceType:S(E).nullable()})),adoptDiscoveredDevice:A(x({candidate:tM,integrationId:l().optional()}),nM,{kind:`mutation`,auth:`admin`}),supportsManualCreation:A(x({}),y()),getChildCreationSchema:A(x({type:S(E),integrationId:l().optional()}),iM),createDevice:A(x({type:S(E),config:m(l(),w()),integrationId:l().optional()}),nM,{kind:`mutation`,auth:`admin`}),testCreationField:A(x({type:S(E),key:l(),value:w(),formValues:m(l(),w()).optional()}),rM,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.INTERNAL}},oM=i(`kind`,[x({kind:p(`mdns`),serviceType:l(),instance:l(),host:l(),address:l().nullable(),port:n().int(),txt:m(l(),l())}),x({kind:p(`ssdp`),host:l(),port:n().int(),target:l(),headers:m(l(),l())})]),aCe=x({addonId:l(),candidate:tM,firstSeenAt:n(),lastSeenAt:n(),dismissed:y()}),sM=x({id:l(),addonId:l(),candidate:tM,firstSeenAt:n(),lastSeenAt:n(),dismissed:y()}),cM=x({childKey:l(),section:l(),order:n().optional(),collapsed:y().optional()}),oCe=x({unit:l().min(1).optional(),precision:n().int().min(0).max(10).optional()}),lM=x({icon:l().min(1).optional(),label:l().min(1).optional(),unit:l().min(1).optional(),precision:n().int().min(0).max(10).optional(),hidden:y().optional(),perCap:m(l(),oCe).optional()}),uM=x({unit:l().min(1).optional(),precision:n().int().min(0).max(10).optional(),icon:l().min(1).optional()}),dM=x({id:n(),stableId:l(),addonId:l(),type:S(E),name:l(),alias:KA.optional(),location:l().nullable(),tags:Hh.optional(),disabled:y(),parentDeviceId:n().nullable(),role:l().nullable().optional(),online:y(),probed:y().optional(),features:C(l()),isCamera:y(),config:m(l(),w()),secretConfigPaths:C(l()).optional(),metadata:m(l(),w()).nullable().optional(),identifiers:hj.optional(),attachedIdentifiers:hj.optional(),sourceInfo:Xg.optional(),integrationId:l().optional(),linkDeviceId:n().nullable().optional(),primaryChildEntityId:l().nullable().optional(),childLayout:C(cM).readonly().optional(),primaryChildPreference:C(l()).readonly().optional(),display:lM.optional()}),fM=x({key:l(),value:w(),description:l().optional()}),pM=S([`manual`]),mM=x({deviceId:n(),name:l(),location:l().nullable(),features:C(l()),producesTrackedEvents:y().optional()}),hM=x({deviceIds:C(n().int().positive()),trackedDeviceIds:C(n().int().positive()).optional()}),gM={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:[E.Camera],sourceCaps:`any`,cardinality:`many`,value:hM},sCe=x({deviceId:n(),mode:pM,devices:C(mM)}),_M=x({deviceId:n(),entries:C(x({capName:l(),kind:S([`native`,`wrapped`]),providerAddonId:l(),providerNodeId:l(),nativeAddonId:l(),implementedMethods:C(l()).optional()}))}),vM=i(`kind`,[x({kind:p(`value`),wrapperAddonId:l().nullable()}),x({kind:p(`missing`)}),x({kind:p(`failed`),error:l()})]),cCe=x({id:n(),stableId:l(),type:l(),name:l(),location:l().nullable(),tags:Hh.optional(),disabled:y(),parentDeviceId:n().nullable(),role:l().nullable().optional()}),lCe=x({id:n(),stableId:l(),addonId:l(),type:l(),name:l(),userNamed:y().optional(),location:l().nullable(),tags:Hh.optional(),disabled:y(),parentDeviceId:n().nullable(),metadata:m(l(),w()).nullable().optional(),identifiers:hj.optional(),attachedIdentifiers:hj.optional(),sourceInfo:Xg.optional(),integrationId:l().optional(),linkDeviceId:n().nullable().optional(),primaryChildEntityId:l().nullable().optional(),childLayout:C(cM).readonly().optional(),primaryChildPreference:C(l()).readonly().optional(),role:l().nullable().optional(),display:lM.optional()}),uCe=w().nullable(),dCe=x({streamId:l(),width:n().optional(),height:n().optional(),codec:l().optional(),fps:n().optional(),bitrateKbps:n().optional()}),fCe=x({addonId:l(),stableId:l(),id:n(),type:l(),name:l(),location:l().nullable().optional(),disabled:y().optional(),parentDeviceId:n().nullable(),role:l().nullable().optional(),features:C(l()).optional(),config:m(l(),w()),secretConfigPaths:C(l()).optional()}),yM=x({deviceId:n().int().positive(),deletedAt:n(),providerAddonId:l()}),bM=2160*60*60*1e3,xM=x({deviceId:n().int().positive(),stores:m(l(),n().int().nonnegative())}),SM=x({status:S([`skipped`,`dry-run`,`cleaned`]),reason:l().nullable(),devices:C(xM),unreachable:C(l())}),pCe=x({deviceId:n()}),mCe=x({deviceId:n(),data:m(l(),w()),secretConfigPaths:C(l()).optional()}),CM=S([`off`,`on`,`not-offered`,`unreachable`]),wM=x({deviceId:n(),switchId:$d,outcome:CM,detail:l().optional()}),TM=x({sourceId:n(),targetId:n(),switches:C(wM).readonly(),sourceStillLive:C($d).readonly(),swapped:y()}),EM={name:`device-manager`,scope:`system`,mode:`singleton`,extensionSlots:[gM],methods:{allocateDeviceId:A(x({addonId:l(),stableId:l()}),x({id:n()}),{kind:`mutation`}),migrateDevice:A(x({sourceId:n(),targetId:n()}),TM,{kind:`mutation`,auth:`admin`,timeoutMs:12*6e4}),registerDevice:A(fCe,v(),{kind:`mutation`}),removeDevice:A(pCe,v(),{kind:`mutation`}),persistConfig:A(mCe,v(),{kind:`mutation`,auth:`admin`}),loadConfig:A(x({deviceId:n()}),m(l(),w()),{auth:`admin`}),loadRuntimeState:A(x({deviceId:n()}),m(l(),w()),{auth:`admin`}),loadMeta:A(x({deviceId:n()}),lCe.nullable()),setName:A(x({deviceId:n(),name:l(),stampUserNamed:y().optional()}),v(),{kind:`mutation`,auth:`admin`}),setAlias:A(x({deviceId:n(),alias:l()}),i(`ok`,[x({ok:p(!0),alias:KA}),x({ok:p(!1),reason:S([`empty`,`too-long`,`grammar`,`reserved`,`taken`]),takenBy:n().optional()})]),{kind:`mutation`,auth:`admin`}),renderDeviceTemplates:A(x({templates:C(XA).max(64),allowedDeviceIds:C(n().int()).optional(),thisDevice:QA.optional()}),x({results:C(rj)}),{auth:`admin`}),checkDeviceTemplates:A(x({templates:C(l()).max(64),allowedDeviceIds:C(n().int()).optional(),thisDevice:QA.optional()}),x({results:C(i(`ok`,[x({ok:p(!0),aliases:C(x({alias:l(),deviceId:n().int().nullable(),allowed:y(),reads:C(l())})),readsClock:y()}),x({ok:p(!1),refusal:ej})]))}),{auth:`admin`}),setLocation:A(x({deviceId:n(),location:l().nullable()}),v(),{kind:`mutation`,auth:`admin`}),setTags:A(x({deviceId:n(),tags:Hh}),v(),{kind:`mutation`,auth:`admin`}),setType:A(x({deviceId:n(),type:S(E)}),v(),{kind:`mutation`,auth:`admin`}),setIntegrationId:A(x({deviceId:n(),integrationId:l()}),v(),{kind:`mutation`,auth:`admin`}),setLinkDeviceId:A(x({deviceId:n(),linkDeviceId:n().nullable()}),v(),{kind:`mutation`,auth:`admin`}),setPrimaryChildEntityId:A(x({deviceId:n(),primaryChildEntityId:l().nullable()}),v(),{kind:`mutation`,auth:`admin`}),setChildLayout:A(x({deviceId:n(),childLayout:C(cM).readonly()}),v(),{kind:`mutation`,auth:`admin`}),setPrimaryChildPreference:A(x({deviceId:n(),primaryChildPreference:C(l()).readonly()}),v(),{kind:`mutation`,auth:`admin`}),setDisplay:A(x({deviceId:n(),display:lM.nullable()}),v(),{kind:`mutation`,auth:`admin`}),getRoleDisplayDefaults:A(x({}),x({defaults:m(l(),uM)}),{role:`viewer`,kind:`query`}),setRoleDisplayDefaults:A(x({defaults:m(l(),uM)}),v(),{kind:`mutation`,auth:`admin`}),getWireableFields:A(x({deviceId:n(),includeSynthesizable:y().optional()}),x({caps:C(x({cap:l(),fields:C(x({path:l(),kind:S([`string`,`number`,`boolean`,`enum`,`union`]),unionMembers:C(S([`string`,`number`,`boolean`])).optional(),enumValues:C(l()).optional(),item:y().optional(),quantity:la.optional()})).readonly(),itemArray:x({path:l(),keyField:l()}).optional()})).readonly()}),{kind:`query`}),setRole:A(x({deviceId:n(),role:l().nullable()}),v(),{kind:`mutation`,auth:`admin`}),applyInitialMeta:A(x({deviceId:n(),name:l().optional(),location:l().nullable().optional(),tags:Hh.optional(),type:S(E).optional(),integrationId:l().optional(),linkDeviceId:n().nullable().optional(),role:l().nullable().optional()}),v(),{kind:`mutation`,auth:`admin`}),setMetadata:A(x({deviceId:n(),patch:m(l(),w())}),v(),{kind:`mutation`,auth:`admin`}),setIdentifiers:A(x({deviceId:n(),identifiers:hj.nullable(),unread:C(lj).optional()}),v(),{kind:`mutation`,auth:`admin`}),listIdentityCandidates:A(x({}),kj,{kind:`query`,auth:`admin`}),setAttachedIdentifiers:A(x({deviceId:n(),identifiers:hj.nullable(),unread:C(lj).optional()}),v(),{kind:`mutation`,auth:`admin`}),listIdentityLinks:A(x({deviceId:n().int().optional()}),zj,{kind:`query`,auth:`admin`}),confirmIdentityLink:A(x({linkId:l().min(1)}),Vj,{kind:`mutation`,auth:`admin`}),dismissIdentityLink:A(x({linkId:l().min(1)}),Vj,{kind:`mutation`,auth:`admin`}),unlinkIdentity:A(x({linkId:l().min(1)}),Vj,{kind:`mutation`,auth:`admin`}),listLocations:A(v(),C(l())),addLocation:A(x({name:l()}),v(),{kind:`mutation`,auth:`admin`}),removeLocation:A(x({name:l(),cascade:y().optional()}),v(),{kind:`mutation`,auth:`admin`}),renameLocation:A(x({from:l(),to:l()}),x({moved:n()}),{kind:`mutation`,auth:`admin`}),listLocationIcons:A(v(),C(xme),{role:`viewer`}),setLocationIcon:A(x({location:l(),icon:Lh.nullable()}),v(),{kind:`mutation`,auth:`admin`}),listLocationDescriptions:A(v(),C(Cme)),setLocationDescription:A(x({location:l(),description:l().max(400).nullable()}),v(),{kind:`mutation`,auth:`admin`}),listSiteZones:A(v(),C(sj),{role:`viewer`}),setSiteZone:A(x({name:l(),icon:Lh.nullable().optional()}),v(),{kind:`mutation`,auth:`admin`}),removeSiteZone:A(x({name:l()}),v(),{kind:`mutation`,auth:`admin`}),renameSiteZone:A(x({from:l(),to:l()}),v(),{kind:`mutation`,auth:`admin`}),setLocationZone:A(x({location:l(),zone:l().nullable()}),v(),{kind:`mutation`,auth:`admin`}),setDisabled:A(x({deviceId:n(),disabled:y()}),v(),{kind:`mutation`,auth:`admin`}),listPersistedByAddon:A(x({addonId:l()}),C(cCe)),listAll:A(x({addonId:l().optional(),projection:S([`full`,`slim`]).optional(),isCamera:y().optional(),deviceIds:C(n()).optional()}),C(dM),{role:`viewer`}),search:A(Gj,Zj,{role:`viewer`}),getDevice:A(x({deviceId:n()}),dM.nullable()),getChildren:A(x({parentDeviceId:n()}),C(dM),{role:`viewer`}),getChildrenBatch:A(x({parentDeviceIds:C(n()).max(256)}),m(l(),C(dM))),getLinkedDevices:A(x({deviceId:n()}),x({mode:pM,devices:C(mM)}),{role:`viewer`}),getLinkedDevicesBatch:A(x({deviceIds:C(n())}),C(sCe),{role:`viewer`}),getStreamSources:A(x({deviceId:n()}),C(vne)),getConfigSchema:A(x({deviceId:n()}),C(fM)),getSettingsSchema:A(x({deviceId:n()}),uCe),updateConfig:A(x({deviceId:n(),values:m(l(),w())}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),enable:A(x({deviceId:n()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),disable:A(x({deviceId:n()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),remove:A(x({deviceId:n()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),listDeletedSince:A(x({sinceMs:n()}),C(yM).readonly(),{auth:`admin`}),cleanupDeletedDevicesData:A(x({confirm:y()}),SM,{kind:`mutation`,auth:`admin`}),removeByIntegration:A(x({integrationId:l()}),x({removed:n()}),{kind:`mutation`,auth:`admin`}),getStreamProfileMap:A(x({deviceId:n()}),m(l(),l().nullable())),setStreamProfileMap:A(x({deviceId:n(),profileMap:m(l(),l().nullable())}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),probeStreams:A(x({deviceId:n()}),C(dCe),{kind:`mutation`,auth:`admin`}),getBindings:A(x({deviceId:n()}),_M,{role:`viewer`}),getBindingsBatch:A(x({deviceIds:C(n())}),C(_M)),getAllBindings:A(x({}),C(_M)),listDeviceIdsByCaps:A(x({capNames:C(l().min(1)).min(1).max(16)}),C(n()),{role:`viewer`}),setWrapperActive:A(x({deviceId:n(),capName:l(),wrapperAddonId:l(),active:y()}),v(),{kind:`mutation`,auth:`admin`}),getWrapperActivation:A(x({deviceId:n(),capName:l().min(1)}),vM),listWrappersForCap:A(x({capName:l()}),C(l())),listBindableCapsForDeviceType:A(x({deviceType:l()}),C(x({capName:l(),wrappers:C(l())}))),getDeviceSettingsAggregate:A(x({deviceId:n()}),sS.nullable()),getDeviceLiveInfoAggregate:A(x({deviceId:n()}),sS.nullable(),{role:`viewer`}),getDeviceAggregate:A(x({deviceId:n()}),x({settings:sS.nullable(),live:sS.nullable()})),runDeviceAction:A(x({deviceId:n().int().nonnegative(),action:l().min(1),input:w()}),w(),{kind:`mutation`}),updateDeviceField:A(x({deviceId:n(),writerCapName:l(),writerAddonId:l(),key:l(),value:w()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),updateDeviceFieldsBatch:A(x({deviceId:n(),changes:C(x({writerCapName:l(),writerAddonId:l(),key:l(),value:w()}))}),x({success:p(!0),failures:C(x({writerCapName:l(),writerAddonId:l(),error:l()}))}),{kind:`mutation`,auth:`admin`}),discoverDevices:A(x({addonId:l()}),C(tM),{kind:`mutation`,auth:`admin`}),adoptDevice:A(x({addonId:l(),candidate:tM,integrationId:l().optional()}),nM,{kind:`mutation`,auth:`admin`}),getCreationSchema:A(x({addonId:l(),type:S(E),integrationId:l().optional()}),w().nullable()),createDevice:A(x({addonId:l(),type:S(E),config:m(l(),w()),integrationId:l().optional()}),nM,{kind:`mutation`,auth:`admin`}),testCreationField:A(x({addonId:l(),type:S(E),key:l(),value:w(),formValues:m(l(),w()).optional()}),rM,{kind:`mutation`,auth:`admin`}),adoptionListCandidateFilters:A(x({addonId:l(),integrationId:l()}),x({filters:C(AA)}),{auth:`admin`}),adoptionListCandidates:A(MA.extend({addonId:l()}),NA,{auth:`admin`}),adoptionRefresh:A(x({addonId:l(),integrationId:l()}),FA,{kind:`mutation`,auth:`admin`}),adoptionAdopt:A(IA.extend({addonId:l()}),LA,{kind:`mutation`,auth:`admin`}),adoptionRelease:A(RA.extend({addonId:l()}),v(),{kind:`mutation`,auth:`admin`}),adoptionStartJob:A(IA.extend({addonId:l()}),x({jobId:l()}),{kind:`mutation`,auth:`admin`}),adoptionListJobs:A(x({addonId:l(),integrationId:l().optional()}),C(Qd).readonly(),{auth:`admin`}),adoptionCancelJob:A(x({jobId:l()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),adoptionResync:A(zA,BA,{kind:`mutation`,auth:`admin`}),discoveryProviders:A(x({}),x({providers:C(x({addonId:l(),label:l()})).readonly()}),{auth:`admin`}),discoverAllProviders:A(x({subnets:C(l()).optional()}),x({groups:C(x({addonId:l(),label:l(),candidates:C(tM).readonly(),error:l().nullable()})).readonly()}),{kind:`mutation`,auth:`admin`}),discoverProvider:A(x({addonId:l(),params:m(l(),w()).optional(),subnets:C(l()).optional()}),x({candidates:C(tM).readonly()}),{kind:`mutation`,auth:`admin`}),listDiscoveryProposals:A(x({}),x({proposals:C(sM).readonly()}),{auth:`admin`}),dismissDiscoveryProposal:A(x({id:l()}),x({dismissed:y()}),{kind:`mutation`,auth:`admin`}),reportDiscoveryObservations:A(x({observations:C(oM).max(512)}),x({proposed:n().int()}),{kind:`mutation`,auth:`admin`}),runDiscoverySweep:A(x({}),x({providers:n().int(),proposed:n().int()}),{kind:`mutation`,auth:`admin`,timeoutMs:12e4}),providerCreationType:A(x({addonId:l(),integrationId:l().optional()}),x({deviceType:S(E).nullable()}),{auth:`admin`}),providerDiscoveryParamsSchema:A(x({addonId:l()}),w(),{auth:`admin`}),testField:A(x({deviceId:n(),key:l(),value:w()}),rM,{kind:`mutation`,auth:`admin`}),getDeviceStatusAggregate:A(x({deviceId:n(),caps:C(l()).readonly().optional()}),m(l(),w().nullable())),getDeviceStatusAggregateBatch:A(x({deviceIds:C(n()).readonly(),caps:C(l()).readonly().optional()}),m(l(),m(l(),w().nullable())),{role:`viewer`})},vocabulary:{notOperatorFacing:`the device registry itself — rename, move and remove are administration`}},DM=[`linked-devices`],OM=S(DM),kM={"linked-devices":{descriptor:gM,declaringCap:`device-manager`,hostDeviceTypes:[E.Camera]}},AM=i(`slot`,[hM.extend({slot:p(`linked-devices`)})]),jM=[E.Camera],hCe=`:`,gCe=`listSlots`,MM=i(`state`,[x({state:p(`ok`)}),x({state:p(`unreachable`),reason:l()})]),NM=x({source:l(),label:l(),addonId:l().optional(),availability:MM}),PM=S([`ok`,`missing`,`foreign`,`unavailable`]),FM=x({deviceId:n().int(),name:l().nullable(),health:PM,detail:l().optional()}),IM=x({state:S([`active`,`inactive`,`unknown`]),authority:l(),detail:l().optional()}),LM=x({state:p(`ok`),slotRef:l(),slot:OM,authority:l(),activation:IM.nullable(),value:AM,sources:C(FM),impliedSources:C(FM).optional()}),RM=x({state:p(`unreachable`),addonId:l(),reason:l()}),zM=i(`state`,[LM,RM]);function _Ce(e,t){return{state:`unreachable`,addonId:e,reason:t}}var BM=x({deviceId:n().int(),name:l(),type:l(),location:l().nullable(),parentName:l().nullable(),suggested:y(),reason:l().nullable()}),VM=x({candidates:C(BM)}),HM=x({applied:p(!0),reload:S([`none`,`host`,`parent`])}),UM=x({deviceId:n().int(),slotRef:l().min(1)}),WM=UM.extend({value:AM}),GM={name:`device-extension`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:jM,deviceConfig:{ui:{kind:`widget`,widgetId:`host/extensions-panel`,tab:`general`,label:`Extensions`,order:72}},methods:{listSources:A(x({deviceId:n().int()}),C(NM)),listSlots:A(x({deviceId:n().int()}),C(zM)),listCandidates:A(UM,VM),setSlot:A(WM,HM,{kind:`mutation`,auth:`admin`})},vocabulary:{noun:F(`Device extension`,`Estensione del dispositivo`),order:3100}},KM=i(`kind`,[x({kind:p(`device`),deviceId:n().int()}),x({kind:p(`node`),nodeId:l().min(1)})]),qM=S([`gauge`,`counter`,`boolean`,`enum`]),JM=S([`gauge`,`counter`,`boolean`]),vCe=`derived:energy.kwh`,YM=S([`raw`,`5m`,`1h`,`1d`]),XM=S([`undeclared`,`not-owner`,`opted-out`,`not-a-real-device`,`rate`,`ingest-mismatch`,`out-of-range`]),yCe=x({key:l(),reason:XM,count:n().int()}),ZM=x({accepted:n().int(),refused:C(yCe).readonly()}),QM=x({key:l(),scope:l(),kind:qM,unit:l().nullable(),displayName:l(),source:S([`cap`,`addon`,`derived`]),values:C(l()).readonly().nullable(),firstTs:n(),lastTs:n()}),bCe=x({t:n(),samples:n().int(),mean:n().nullable(),twMean:n().nullable(),min:n(),max:n(),last:n().nullable(),delta:n().nullable(),state:l().nullable(),states:m(l(),n()).nullable()}),xCe=x({scope:l(),before:x({t:n(),value:n().nullable(),state:l().nullable()}).nullable(),points:C(bCe).readonly(),derivedFrom:l().nullable()}),$M={key:l(),scope:l().optional(),from:n(),to:n(),resolution:h([YM,p(`auto`)]).default(`auto`),maxPoints:n().int().positive().max(5e3).default(1e3)},eN=x({resolution:YM,series:C(xCe).readonly(),truncated:y()}),SCe=24,CCe=h([x({deviceId:n().int(),key:l(),scope:l().optional()}),x({forNodeId:l().min(1),key:l(),scope:l().optional()})]),wCe=i(`ok`,[x({ok:p(!0),result:eN}),x({ok:p(!1),error:l()})]),TCe=x({tier:YM,rows:n().int().nullable(),approxBytes:n().nullable(),countedAt:n().nullable()}),tN=S([`device-gone`,`undeclared`]),nN=x({raw:n().int(),"5m":n().int(),"1h":n().int(),"1d":n().int()}),ECe=x({seriesId:n().int(),deviceId:n().int(),key:l(),scope:l(),displayName:l().nullable(),reason:tN,missingSince:n().nullable(),firstTs:n(),lastTs:n(),rows:nN}),DCe=200,OCe=50,rN=S([`not-found`,`not-orphan`,`failed`]),kCe=i(`ok`,[x({seriesId:n().int(),ok:p(!0),deleted:nN}),x({seriesId:n().int(),ok:p(!1),reason:rN})]),ACe=x({series:C(ECe).readonly(),truncated:y()}),iN=S([`invalid-range`,`range-too-large`,`series-not-found`,`not-a-point-series`]),jCe=x({"5m":n().int(),"1h":n().int(),"1d":n().int()}),MCe=i(`ok`,[x({ok:p(!0),dryRun:y(),seriesId:n().int(),rows:nN,rewritten:jCe.nullable()}),x({ok:p(!1),reason:iN})]),aN=x({startedAt:n(),ready:y(),series:n().int(),metrics:n().int(),optedOutDevices:n().int(),tiers:C(TCe).readonly(),capture:x({eventsSeen:n().int(),pointsEmitted:n().int(),pointsWritten:n().int(),pointsDropped:n().int(),bufferDepth:n().int(),trailingEmitted:n().int(),reconciledPoints:n().int(),reconcileRuns:n().int(),reconcileFailures:n().int(),lastReconcileAt:n().nullable(),lastFlushAt:n().nullable(),flushFailures:n().int(),skipped:m(l(),n().int())}),ingest:x({accepted:n().int(),refused:m(l(),n().int())}),rollup:x({last5mAt:n().nullable(),last1hAt:n().nullable(),last1dAt:n().nullable(),errors:n().int(),dirty5m:n().int(),dirty1h:n().int(),dirty1d:n().int()}),retention:x({lastRunAt:n().nullable(),deleted:m(l(),n().int()),purgedSeries:n().int()}),directory:x({devices:n().int(),lastRefreshAt:n().nullable()})}),oN={name:`device-history`,scope:`system`,mode:`singleton`,methods:{listSeries:A(x({deviceId:n().int()}),C(QM).readonly()),listNodeSeries:A(x({forNodeId:l().min(1)}),C(QM).readonly(),{auth:`admin`}),query:A(x({deviceId:n().int(),...$M}),eN),queryNode:A(x({forNodeId:l().min(1),...$M}),eN,{auth:`admin`}),queryMany:A(x({items:C(CCe).min(1).max(24),from:$M.from,to:$M.to,resolution:$M.resolution,maxPoints:$M.maxPoints}),x({results:C(wCe).readonly()}),{auth:`admin`}),declareSeries:A(x({name:l().regex(/^[a-z0-9-]+$/),subjectKind:S([`device`,`node`]),kind:JM,unit:l().optional(),displayName:l().min(1),ingest:S([`points`,`buckets`])}),x({key:l()}),{kind:`mutation`,auth:`admin`}),record:A(x({points:C(x({key:l(),subject:KM,scope:l().default(``),ts:n(),value:n()})).max(5e3)}),ZM,{kind:`mutation`,auth:`admin`}),recordBuckets:A(x({buckets:C(x({key:l(),subject:KM,scope:l().default(``),bucketStart:n(),samples:n().int().positive(),sum:n(),min:n(),max:n(),last:n().nullable(),lastTs:n().nullable()})).max(5e3)}),ZM,{kind:`mutation`,auth:`admin`}),getDeviceEnabled:A(x({deviceId:n().int()}),x({enabled:y()})),setDeviceEnabled:A(x({deviceId:n().int(),enabled:y()}),x({enabled:y()}),{kind:`mutation`,auth:`admin`}),getStatus:A(x({}),aN,{auth:`admin`}),listOrphanSeries:A(x({}),ACe,{auth:`admin`}),deleteOrphanSeries:A(x({seriesIds:C(n().int()).min(1).max(50)}),x({results:C(kCe).readonly()}),{kind:`mutation`,auth:`admin`}),deleteSeriesRange:A(x({deviceId:n().int(),key:l().min(1),scope:l(),fromMs:n().int().nonnegative(),toMs:n().int().nonnegative(),dryRun:y()}),MCe,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`recorded history of device state — read by charts, not actuated`}},sN=x({deviceId:n().int().positive(),deletedAt:n(),providerAddonId:l()}),cN=x({counts:m(l(),n().int().nonnegative())}),lN=x({store:l(),deviceId:n().int().positive(),count:n().int().nonnegative()}),uN={name:`device-removal-hook`,scope:`system`,mode:`collection`,internal:!0,methods:{onDeviceRemoved:A(sN,cN,{kind:`mutation`,auth:`admin`}),listDeviceData:A(v(),C(lN).readonly(),{auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:M.INTERNAL}},dN=S([`appliance`,`mower`,`vacuum`]),fN=S([`open`,`closed`]),pN=S([`completed`,`aborted`,`error`,`unknown`]),mN=S([`running-state`,`activity`,`reconcile`]),hN=S([`counter-delta`,`history-integral`]),gN=x({phase:l(),at:n()}),_N=x({kind:p(`appliance`),energyKwh:n().nullable().meta(N(`energy`)),energyMethod:hN.nullable(),peakW:n().nullable().meta(N(`power`)),avgW:n().nullable().meta(N(`power`)),program:l().nullable(),remainingAtStartSec:n().nullable().meta(N(`duration`)),finalPhase:l().nullable(),energyStartKwh:n().nullable().meta(N(`energy`)),powerObservedMs:n()}),vN=i(`kind`,[_N]),yN=x({runId:l(),deviceId:n().int(),kind:dN,state:fN,startedAt:n(),endedAt:n().nullable(),durationMs:n().nullable(),outcome:pN.nullable(),startSource:mN,endSource:mN.nullable(),runningSource:S([`native`,`assigned`]).nullable(),phases:C(gN),detail:vN}),NCe=[E.Washer,E.Dryer,E.Dishwasher],PCe=200,bN={name:`device-runs`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:NCe,methods:{listRuns:A(x({deviceId:n().int(),outcome:pN.optional(),atFrom:n().optional(),atTo:n().optional(),limit:n().int().positive().max(200).default(50),cursor:l().optional()}),x({runs:C(yN).readonly(),nextCursor:l().nullable()})),getRun:A(x({deviceId:n().int(),runId:l()}),yN.nullable()),getCurrentRun:A(x({deviceId:n().int()}),yN.nullable())},events:{onRunOpened:{data:yN,notOperatorFacing:`the durable record of a run that the running-state start flip already announces`},onRunClosed:{data:yN,notOperatorFacing:`the durable record of a run that the running-state finish flip already announces`}},vocabulary:{noun:F(`Runs`,`Esecuzioni`),order:2130}},xN=S([`replace`,`add`]),SN=i(`ok`,[x({ok:p(!0),changed:y()}),x({ok:p(!1),code:S([`owned-by-other`,`not-claimed`,`field-not-claimed`,`invalid-slice`,`unknown-device`,`row-unreadable`,`migration-in-flight`]),message:l()})]),CN=x({deviceId:n(),capName:l(),owner:l().min(1),mode:xN,fields:C(l().min(1)).min(1)}),wN=i(`state`,[x({state:p(`loaded`),claims:C(CN)}),x({state:p(`not-loaded`),reason:l()})]),TN={name:`device-state`,scope:`system`,mode:`singleton`,methods:{getSnapshot:A(x({deviceId:n()}),m(l(),m(l(),w()))),getCapSlice:A(x({deviceId:n(),capName:l(),confirmed:y().optional()}),m(l(),w()).nullable()),getAllSnapshots:A(x({confirmed:y().optional()}),m(l(),m(l(),m(l(),w())))),setCapSlice:A(x({deviceId:n(),capName:l(),slice:m(l(),w())}),v(),{kind:`mutation`}),claimFields:A(x({deviceId:n(),capName:l(),owner:l().min(1),mode:xN,fields:C(l().min(1)).min(1),values:m(l(),w())}),SN,{kind:`mutation`,auth:`admin`}),patchOwnedFields:A(x({deviceId:n(),capName:l(),owner:l().min(1),values:m(l(),w())}),SN,{kind:`mutation`,auth:`admin`}),releaseClaim:A(x({deviceId:n(),capName:l(),owner:l().min(1)}),SN,{kind:`mutation`,auth:`admin`}),listClaims:A(x({ownerPrefix:l().optional()}),wN,{auth:`admin`}),getNativeCapSlice:A(x({deviceId:n(),capName:l()}),m(l(),w()).nullable(),{auth:`admin`})},events:{onChanged:ni(x({deviceId:n(),capName:l(),slice:m(l(),w())}))},vocabulary:{notOperatorFacing:`the runtime-state mirror every trigger already reads through`}},EN=S([`schedule`,`command`,`burst`]),DN=S([`none`,`partial`,`full`]),ON=1e3,FCe=x({integrationId:l().min(1),minIntervalMs:n().int().min(ON),intervalMs:n().int().positive().optional(),batch:y(),push:DN,heartbeatMs:n().int().positive().optional(),connectionEpoch:n().int().nonnegative().optional()});function ICe(e){let t=e.intervalMs??0;return Math.max(e.minIntervalMs,t)}var kN=[3e3,1e4],AN=1e4,jN=2e3;function LCe(e){let t=kN.filter(t=>t<e),n=e-jN,r=(t[t.length-1]??0)+AN;for(;r<n;)t.push(r),r+=AN;let i=t[t.length-1];return(i===void 0?n>0:n-i>=1e3)&&t.push(n),t}var RCe=2500,MN=x({deviceId:n().int().nonnegative(),deviceIds:C(n().int().nonnegative()).min(1),reason:EN}),NN=x({deviceId:n().int().nonnegative()}),PN=x({ok:p(!0)}),FN=`the core schedules state refreshes itself; an operator never asks for one`,IN={name:`device-state-refresh`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{refresh:A(MN,PN,{kind:`mutation`,auth:`admin`,notOperatorFacing:FN}),resubscribe:A(NN,PN,{kind:`mutation`,auth:`admin`,notOperatorFacing:FN})},vocabulary:{noun:F(`State refresh`,`Aggiornamento dello stato`),order:3247}},LN=x({online:y(),lastChangedAt:n()}),RN={name:`device-status`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},events:{onStatusChanged:{data:x({deviceId:n(),status:LN}),notOperatorFacing:"the `online` state trigger phrases both edges of this change"}},status:{schema:LN,kind:`push`},runtimeState:LN,durability:`restored`,history:{fields:{online:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Reachability`,`Raggiungibilità`),order:5260,state:[{kind:`boolean`,field:`online`,label:F(`Online`,`Online`),whenTrue:F(`When {device} comes back online`,`Quando {device} torna online`),whenFalse:F(`When {device} goes offline`,`Quando {device} va offline`),icon:`wifi`}],extraEvents:[{category:T.DeviceOnline,label:F(`Came online`,`Tornato online`),phrase:F(`When {device} comes back online`,`Quando {device} torna online`),icon:`wifi`},{category:T.DeviceOffline,label:F(`Went offline`,`Andato offline`),phrase:F(`When {device} goes offline`,`Quando {device} va offline`),icon:`wifi-off`}]}},zCe=200,BCe=500,zN=S([`not-kernel`,`invalid`]),BN=x({written:n().int().nonnegative(),refused:C(x({id:l(),reason:zN})).readonly()}),VN=x({rows:n().int().nullable(),lastWriteAt:n().nullable(),refused:m(l(),n())}),HN={name:`device-transitions`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:Object.values(E).filter(e=>e!==E.Container),methods:{listTransitions:A(x({deviceId:n().int(),capName:l().optional(),actorKind:ia.optional(),outcome:aa.optional(),atFrom:n().optional(),atTo:n().optional(),limit:n().int().positive().max(200).default(50),cursor:l().optional()}),x({transitions:C(sa).readonly(),nextCursor:l().nullable()})),getTransition:A(x({deviceId:n().int(),id:l()}),sa.nullable()),listRecentTransitions:ti(x({actorKind:ia.optional(),outcome:aa.optional(),atFrom:n().optional(),atTo:n().optional(),limit:n().int().positive().max(200).default(50),cursor:l().optional()}),x({transitions:C(sa).readonly(),nextCursor:l().nullable()}),{auth:`admin`}),record:ti(x({transitions:C(sa).max(500)}),BN,{kind:`mutation`,auth:`admin`}),getStatus:ti(x({}),VN,{auth:`admin`})},vocabulary:{noun:F(`Transitions`,`Transizioni`),order:2140}},UN=S([`idle`,`running`,`paused`,`finished`,`error`,`unavailable`]),WN=S([`Inactive`,`Ready`,`DelayedStart`,`Run`,`Pause`,`ActionRequired`,`Finished`,`Error`,`Aborting`]),GN=S([`available`,`offline`,`description-missing`]),KN=x({availability:GN,state:UN,operationState:WN.nullable(),program:l().nullable(),selectedProgram:l().nullable(),availablePrograms:C(l()),remaining:n().int().nonnegative().nullable().meta(N(`duration`)),delayedStart:n().int().nonnegative().nullable().meta(N(`duration`)),progress:n().min(0).max(100).nullable().meta(N(`percentage`)),doorOpen:y().nullable(),doorLocked:y().nullable(),remoteStartAllowed:y().nullable(),remoteControlActive:y().nullable(),localControlActive:y().nullable(),powerOn:y().nullable(),powerState:l().nullable(),filterCleaningDue:y().nullable(),machineCareDue:y().nullable(),machineCareRemainingRuns:n().int().nonnegative().nullable().meta(N(`count`)),halfLoad:y().nullable(),hygienePlus:y().nullable(),extraDry:y().nullable(),intensiveZone:y().nullable(),varioSpeedPlus:y().nullable(),childLock:y().nullable(),activeEvents:C(l()),errorCode:n().nullable().meta(N(`none`)),errorLabel:l().nullable(),lastFetchedAt:n()}),qN=n().int().nonnegative(),JN=h([y(),l(),n()]),YN=S([`none`,`read`,`readWrite`,`writeOnly`,`readStatic`]),XN=x({key:l(),name:l(),type:S([`boolean`,`number`,`enum`,`string`]),access:YN,available:y(),unit:l().nullable(),min:n().nullable(),max:n().nullable(),step:n().nullable(),enumValues:C(l()).nullable(),defaultValue:JN.nullable()}),ZN=x({key:l(),name:l(),available:y(),options:C(XN)}),QN=x({availability:GN,supportsStart:y(),supportsPause:y(),supportsResume:y(),supportsStop:y(),supportsPower:y(),programs:C(ZN),options:C(XN)}),$N={name:`dishwasher`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Dishwasher],methods:{start:A(x({deviceId:qN,program:l().min(1).optional(),options:m(l(),JN).optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.start`,label:F(`Start cycle`,`Avvia il lavaggio`),phrase:F(`Start {device}`,`Avvia {device}`),icon:`play`,openArgs:[{key:`program`,label:F(`Programme`,`Programma`),offer:{kind:`dynamic`,from:`status`,field:`availablePrograms`},optional:!0}]}]}),pause:A(x({deviceId:qN}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.pause`,label:F(`Pause`,`Metti in pausa`),phrase:F(`Pause {device}`,`Metti in pausa {device}`),icon:`pause`}]}),resume:A(x({deviceId:qN}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.resume`,label:F(`Resume`,`Riprendi`),phrase:F(`Resume {device}`,`Riprendi il lavaggio di {device}`),icon:`play`}]}),stop:A(x({deviceId:qN}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.stop`,label:F(`Stop`,`Ferma`),phrase:F(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),setProgram:A(x({deviceId:qN,program:l().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.program`,label:F(`Choose programme`,`Scegli il programma`),phrase:F(`Select the {program} programme on {device}`,`Seleziona il programma {program} su {device}`),icon:`list`,openArgs:[{key:`program`,label:F(`Programme`,`Programma`),offer:{kind:`dynamic`,from:`status`,field:`availablePrograms`}}]}]}),setPower:A(x({deviceId:qN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.powerOn`,label:F(`Power on`,`Accendi`),phrase:F(`Turn on {device}`,`Accendi {device}`),icon:`power`,args:{on:!0}},{id:`dishwasher.powerOff`,label:F(`Power off`,`Spegni`),phrase:F(`Turn off {device}`,`Spegni {device}`),icon:`power-off`,args:{on:!1}}]}),setHalfLoad:A(x({deviceId:qN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.halfLoadOn`,label:F(`Half load on`,`Mezzo carico attivo`),phrase:F(`Turn on half load on {device}`,`Attiva il mezzo carico su {device}`),icon:`contrast`,args:{on:!0}},{id:`dishwasher.halfLoadOff`,label:F(`Half load off`,`Mezzo carico spento`),phrase:F(`Turn off half load on {device}`,`Disattiva il mezzo carico su {device}`),icon:`contrast`,args:{on:!1}}]}),setHygienePlus:A(x({deviceId:qN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.hygienePlusOn`,label:F(`Hygiene Plus on`,`Igiene Plus attiva`),phrase:F(`Turn on Hygiene Plus on {device}`,`Attiva Igiene Plus su {device}`),icon:`sparkles`,args:{on:!0}},{id:`dishwasher.hygienePlusOff`,label:F(`Hygiene Plus off`,`Igiene Plus spenta`),phrase:F(`Turn off Hygiene Plus on {device}`,`Disattiva Igiene Plus su {device}`),icon:`sparkles`,args:{on:!1}}]}),setExtraDry:A(x({deviceId:qN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.extraDryOn`,label:F(`Extra dry on`,`Asciugatura extra attiva`),phrase:F(`Turn on extra dry on {device}`,`Attiva l’asciugatura extra su {device}`),icon:`sun`,args:{on:!0}},{id:`dishwasher.extraDryOff`,label:F(`Extra dry off`,`Asciugatura extra spenta`),phrase:F(`Turn off extra dry on {device}`,`Disattiva l’asciugatura extra su {device}`),icon:`sun`,args:{on:!1}}]}),setIntensiveZone:A(x({deviceId:qN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.intensiveZoneOn`,label:F(`Intensive zone on`,`Zona intensiva attiva`),phrase:F(`Turn on the intensive zone on {device}`,`Attiva la zona intensiva su {device}`),icon:`flame`,args:{on:!0}},{id:`dishwasher.intensiveZoneOff`,label:F(`Intensive zone off`,`Zona intensiva spenta`),phrase:F(`Turn off the intensive zone on {device}`,`Disattiva la zona intensiva su {device}`),icon:`flame`,args:{on:!1}}]}),setVarioSpeedPlus:A(x({deviceId:qN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.varioSpeedOn`,label:F(`Speed boost on`,`Lavaggio rapido attivo`),phrase:F(`Turn on the speed boost on {device}`,`Attiva il lavaggio rapido su {device}`),icon:`zap`,args:{on:!0}},{id:`dishwasher.varioSpeedOff`,label:F(`Speed boost off`,`Lavaggio rapido spento`),phrase:F(`Turn off the speed boost on {device}`,`Disattiva il lavaggio rapido su {device}`),icon:`zap`,args:{on:!1}}]}),setChildLock:A(x({deviceId:qN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.childLockOn`,label:F(`Child lock on`,`Blocco bambini attivo`),phrase:F(`Turn on the child lock of {device}`,`Attiva il blocco bambini di {device}`),icon:`lock`,args:{on:!0}},{id:`dishwasher.childLockOff`,label:F(`Child lock off`,`Blocco bambini spento`),phrase:F(`Turn off the child lock of {device}`,`Disattiva il blocco bambini di {device}`),icon:`lock-open`,args:{on:!1}}]}),setOption:A(x({deviceId:qN,key:l().min(1),value:JN}),v(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`a raw appliance option key/value; every option worth naming has its own action above`}),getOptions:A(x({deviceId:qN}),QN,{auth:`protected`})},status:{schema:KN,kind:`poll`},runtimeState:KN,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:F(`Dishwasher`,`Lavastoviglie`),order:2020,state:[{kind:`enum`,field:`state`,label:F(`Cycle`,`Ciclo`),values:[{value:`idle`,label:F(`Idle`,`Inattiva`)},{value:`running`,label:F(`Running`,`In funzione`),phrase:F(`When {device} starts a cycle`,`Quando {device} inizia un lavaggio`)},{value:`paused`,label:F(`Paused`,`In pausa`)},{value:`finished`,label:F(`Finished`,`Terminato`),phrase:F(`When {device} finishes`,`Quando {device} finisce il lavaggio`)},{value:`error`,label:F(`Error`,`Errore`),phrase:F(`When {device} reports an error`,`Quando {device} segnala un errore`)},{value:`unavailable`,label:F(`Unavailable`,`Non disponibile`)}],icon:`washing-machine`},{kind:`numeric`,field:`progress`,quantity:F(`the cycle progress`,`l’avanzamento del lavaggio`),label:F(`Progress`,`Avanzamento`),unit:`%`,icon:`loader`},{kind:`boolean`,field:`doorOpen`,label:F(`Door open`,`Sportello aperto`),whenTrue:F(`When the door of {device} opens`,`Quando si apre lo sportello di {device}`),whenFalse:F(`When the door of {device} closes`,`Quando si chiude lo sportello di {device}`),icon:`door-open`},{kind:`boolean`,field:`filterCleaningDue`,label:F(`Filter cleaning due`,`Pulizia filtro da fare`),whenTrue:F(`When {device} asks for its filter to be cleaned`,`Quando {device} chiede di pulire il filtro`),whenFalse:F(`When the filter reminder of {device} clears`,`Quando l’avviso filtro di {device} rientra`),icon:`funnel`},{kind:`boolean`,field:`machineCareDue`,label:F(`Machine care due`,`Manutenzione da fare`),whenTrue:F(`When {device} asks for a machine-care cycle`,`Quando {device} chiede un ciclo di manutenzione`),whenFalse:F(`When the machine-care reminder of {device} clears`,`Quando l’avviso di manutenzione di {device} rientra`),icon:`wrench`}]}},eP=`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(`.`),tP=`audio`,nP=[.3,.42,.55,.7,.85,1],rP=[`camstack`,`high-contrast`,`okabe-ito`];function VCe(e){return eP.includes(e)}function HCe(e){return rP.includes(e)}var iP={dark:`#0c0a09`,light:`#fafaf9`},UCe=7,WCe=20,GCe=[`live`,`heatmapScrub`],KCe=3,aP=/^#[0-9a-fA-F]{6}$/;function oP(e,t){return Number.parseInt(e.slice(t,t+2),16)}function sP(e){let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function cP(e){let t=sP(oP(e,1)),n=sP(oP(e,3)),r=sP(oP(e,5));return .2126*t+.7152*n+.0722*r}function qCe(e,t){if(!aP.test(e)||!aP.test(t))return 0;let n=Math.max(cP(e),cP(t)),r=Math.min(cP(e),cP(t));return(n+.05)/(r+.05)}function lP(e){let t=sP(oP(e,1)),n=sP(oP(e,3)),r=sP(oP(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 uP(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 JCe(e,t){if(!aP.test(e)||!aP.test(t))return 0;let n=lP(e),r=lP(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=uP(o,n.b),d=uP(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),ee=30*Math.exp(-(((g-275)/25)**2)),v=h**7,te=2*Math.sqrt(v/(v+25**7)),y=1+.015*(m-50)**2/Math.sqrt(20+(m-50)**2),ne=1+.045*h,re=1+.015*h*_,ie=-Math.sin(2*ee*Math.PI/180)*te,ae=r.L-n.L,b=l-c;return Math.sqrt((ae/y)**2+(b/ne)**2+(p/re)**2+b/ne*ie*(p/re))}var YCe={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`},XCe=[`#b34dc7`,`#1d7d34`,`#db6b6c`,`#a43d29`,`#0e6ee6`,`#29a10b`,`#a98731`,`#0181c6`],ZCe={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`},QCe=[`#817f3b`,`#a0733e`,`#8658b2`,`#956301`,`#bc652d`,`#647331`,`#a14c9e`,`#d14e71`],$Ce={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`},ewe=[`#9a3784`,`#a7392c`,`#409d50`,`#6987e7`,`#ee5b3d`,`#c0430d`,`#af79b3`,`#4b6628`],dP=l().regex(/^#[0-9a-f]{6}$/),fP=i(`form`,[x({form:p(`solid`),hex:dP}),x({form:p(`gradient`),hex:dP,alphas:C(n().gt(0).lte(1)).length(nP.length)})]),pP=x({status:p(`ready`),presetId:S(rP),customized:y(),source:S([`stored`,`unconfigured`]),swatches:m(l(),fP),fallbacks:C(dP).length(8)}),mP=i(`status`,[pP,x({status:p(`unknown`),reason:l()})]),hP=h([x({presetId:l()}),x({presetId:l(),overrides:m(l(),fP)})]),gP=x({presetId:l(),overrides:m(l(),fP)});function twe(e){return{form:`solid`,hex:e}}function nwe(e){return{form:`gradient`,hex:e,alphas:[...nP]}}function rwe(e){let t={};for(let n of eP){let r=e[n];if(r===void 0)throw Error(`palette table missing ${n}`);t[n]=n===`audio`?nwe(r):twe(r)}return t}function _P(e,t,n,r){return{id:e,name:t,swatches:rwe(n),fallbacks:r}}var vP=[_P(`camstack`,`CamStack`,YCe,XCe),_P(`high-contrast`,`High contrast`,ZCe,QCe),_P(`okabe-ito`,`Colour-blind safe`,$Ce,ewe)];function yP(e){return vP.find(t=>t.id===e)}function bP(){let e=yP(`camstack`);if(e===void 0)throw Error(`CamStack preset missing`);return iwe(e,`unconfigured`,!1)}function iwe(e,t,n){return{status:`ready`,presetId:e.id,customized:n,source:t,swatches:e.swatches,fallbacks:[...e.fallbacks]}}function awe(e){return e.hex}function owe(e,t){let n=[];for(let t of eP){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 swe(e){let t=e[tP];return t===void 0||t.form===`gradient`&&nP.every((e,n)=>t.alphas[n]===e)?[]:[{code:`bad-gradient`,entry:tP}]}function cwe(e,t){let n=GCe;return n.includes(e)&&n.includes(t)}function xP(e,t){let n=[];for(let t of eP)e[t]===void 0&&n.push({code:`missing-entry`,entry:t});for(let t of Object.keys(e))VCe(t)||n.push({code:`unknown-entry`,entry:t});t.length!==8&&n.push({code:`bad-fallbacks`}),n.push(...swe(e));let r=owe(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=JCe(i.hex,a.hex);o<(cwe(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=qCe(e.hex,iP[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 lwe(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 SP(e){return e.map(lwe).join(`; `)}var CP=class extends Error{violations;constructor(e){super(SP(e)),this.name=`PaletteRejectedError`,this.violations=e}};function wP(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 TP(e,t,n){let r=n.trim().toLowerCase();if(r.startsWith(`audio-`)){let n=e[tP];return n===void 0?wP(r,t):n.hex}let i=e[r];return i===void 0?wP(r,t):i.hex}function EP(e,t){return{...e,...t}}function uwe(e){return`overrides`in e?e.overrides:{}}function dwe(e){let t=yP(e.presetId);if(t===void 0||!HCe(e.presetId))throw new CP([{code:`unknown-preset`,presetId:e.presetId}]);let n=uwe(e),r=EP(t.swatches,n),i=xP(r,t.fallbacks);if(!i.ok)throw new CP(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 fwe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.keys(e).length===0}function pwe(e){if(e==null||fwe(e))return bP();let t=gP.safeParse(e);if(!t.success)return{status:`unknown`,reason:`stored palette is unreadable`};let n=yP(t.data.presetId);if(n===void 0)return{status:`unknown`,reason:`unknown preset ${t.data.presetId}`};let r=EP(n.swatches,t.data.overrides),i=xP(r,n.fallbacks);if(!i.ok)return{status:`unknown`,reason:SP(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 mwe(e,t){return{presetId:e.presetId,overrides:{...t}}}var hwe=x({id:l(),name:l(),swatches:m(l(),fP),fallbacks:C(l())}),DP={name:`display-palette`,scope:`system`,mode:`singleton`,methods:{getPalette:A(v(),mP,{auth:`protected`,role:`viewer`}),listPresets:A(v(),C(hwe).readonly(),{auth:`protected`,role:`viewer`}),setPalette:A(hP,pP,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`the cluster display palette — one colour table for every client, not a device action`}},OP=x({enabled:y().nullable().meta({label:`Do not disturb`}),lastChangedAt:n()}),kP={name:`do-not-disturb`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.MediaPlayer],methods:{setEnabled:A(x({deviceId:n().int(),enabled:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dnd.on`,label:F(`Do not disturb on`,`Attiva Non disturbare`),phrase:F(`Turn on Do not disturb on {device}`,`Attiva Non disturbare su {device}`),icon:`bell-off`,args:{enabled:!0}},{id:`dnd.off`,label:F(`Do not disturb off`,`Disattiva Non disturbare`),phrase:F(`Turn off Do not disturb on {device}`,`Disattiva Non disturbare su {device}`),icon:`bell`,args:{enabled:!1}}]})},status:{schema:OP,kind:`push`},runtimeState:OP,durability:`session`,history:{fields:{enabled:{kind:`boolean`}}},vocabulary:{noun:F(`Do not disturb`,`Non disturbare`),order:2160,state:[{kind:`boolean`,field:`enabled`,label:F(`Do not disturb`,`Non disturbare`),whenTrue:F(`When Do not disturb turns on on {device}`,`Quando {device} attiva Non disturbare`),whenFalse:F(`When Do not disturb turns off on {device}`,`Quando {device} disattiva Non disturbare`),icon:`bell-off`}]}},AP=2e3,gwe={version:1,targets:[{id:`pressed`,cardinality:`event`,shape:`pulse`,vocabulary:{cap:`doorbell`,eventName:`onPressed`},deviceTypes:[E.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:AP,changedAtRequired:!0},sources:[{kind:`binary`},{kind:`switch`}],sourceReport:{status:`assignment-status`},advancedExpression:!0}]},jP=x({lastPressedAt:n().nullable(),pressCountSinceStart:n().meta(N(`count`))}),MP=x({deviceId:n(),timestamp:n()}),NP={name:`doorbell`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Button,E.Camera],methods:{},events:{onPressed:{data:MP,fromState:{field:`lastPressedAt`,on:`advance`},trigger:{category:T.DoorbellOnPressed,label:F(`Rang`,`Ha suonato`),phrase:F(`When someone rings {device}`,`Quando qualcuno suona a {device}`),icon:`bell-ring`}}},status:{schema:jP,kind:`push`},runtimeState:jP,durability:`restored`,history:`none`,customize:gwe,vocabulary:{noun:F(`Doorbell`,`Campanello`),order:5270}},PP=x({embedding:C(n()),inferenceMs:n()}),FP=S([`image`,`text`]),IP=x({modelId:l(),tower:FP,nodeId:l(),crashes:n(),windowMs:n(),sinceMs:n(),lastReason:l()}),LP=x({modelId:l(),tower:FP,nodeId:l(),attempts:n(),sinceMs:n(),lastReason:l()}),RP=x({modelId:l(),embeddingDim:n(),ready:y(),nodeId:l().optional(),failedModels:C(IP).optional(),failedRequirements:C(LP).optional()}),zP=`embedding-model-failed`,BP=`embedding-requirements-unavailable`,VP=`embedding-requirements-failed`,HP=S([zP,BP,VP]);function UP(e,t){return`[${e} model=${t.modelId} tower=${t.tower} node=${t.nodeId}]`}function _we(e){return Error(`${UP(zP,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 vwe(e,t){return Error(`${UP(BP,e)} ${e.modelId} (${e.tower} tower) on ${e.nodeId}: ${t}`)}function ywe(e){return Error(`${UP(VP,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 bwe=RegExp(`\\[(${zP}|${BP}|${VP}) model=([^\\s\\]]+) tower=(image|text) node=([^\\s\\]]+)\\]`);function WP(e){let t=e instanceof Error?e.message:String(e),n=bwe.exec(t);if(n===null)return null;let r=HP.safeParse(n[1]),i=FP.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 xwe(e){return GP(e)!==null}function GP(e){let t=WP(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 KP={name:`embedding-encoder`,scope:`system`,mode:`collection`,internal:!0,methods:{encode:A(x({crop:b(Uint8Array),width:n(),height:n()}),PP,{auth:`admin`}),encodeText:A(x({text:l(),modelId:l().min(1).optional()}),PP,{auth:`admin`}),getInfo:A(v(),RP,{auth:`admin`}),resetFailedModels:A(x({modelId:l().min(1).optional()}),x({cleared:C(l()),nodeId:l()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.ML}},qP=x({powerW:n().nullable().meta(N(`power`)),energyKwh:n().nullable().meta(N(`energy`)),todayKwh:n().nullable().meta(N(`energy`))}),JP=x({powerW:n().nullable().meta(N(`power`)),importKwh:n().nullable().meta(N(`energy`)),exportKwh:n().nullable().meta(N(`energy`)),importTodayKwh:n().nullable().meta(N(`energy`)),exportTodayKwh:n().nullable().meta(N(`energy`))}),YP=x({powerW:n().nullable().meta(N(`power`)),energyKwh:n().nullable().meta(N(`energy`)),todayKwh:n().nullable().meta(N(`energy`))}),XP=x({stateOfChargePct:n().nullable().meta(N(`percentage`)),storedKwh:n().nullable().meta(N(`energy`)),capacityKwh:n().nullable().meta(N(`energy`)),powerW:n().nullable().meta(N(`power`)),chargedKwh:n().nullable().meta(N(`energy`)),dischargedKwh:n().nullable().meta(N(`energy`)),chargedTodayKwh:n().nullable().meta(N(`energy`)),dischargedTodayKwh:n().nullable().meta(N(`energy`)),healthPct:n().nullable().meta(N(`percentage`))}),ZP=x({solar:qP.nullable(),grid:JP.nullable(),house:YP.nullable(),heatPump:YP.nullable(),storage:XP.nullable(),lastFetchedAt:n()});function Swe(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 QP={name:`energy-system`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.EnergySystem],methods:{},status:{schema:ZP,kind:`push`},runtimeState:ZP,durability:`session`,history:{primary:`house.powerW`,priority:50,fields:{"solar.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Solar power`},"solar.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`Solar energy`},"grid.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Grid power`},"grid.importKwh":{kind:`counter`,unit:`kWh`,displayName:`Grid import`},"grid.exportKwh":{kind:`counter`,unit:`kWh`,displayName:`Grid export`},"house.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`House power`},"house.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`House energy`},"heatPump.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Heat pump power`},"heatPump.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`Heat pump energy`},"storage.stateOfChargePct":{kind:`gauge`,unit:`%`,deadband:1,displayName:`Storage charge`},"storage.storedKwh":{kind:`gauge`,unit:`kWh`,deadband:.05,displayName:`Stored energy`},"storage.capacityKwh":{kind:`gauge`,unit:`kWh`,deadband:.1,displayName:`Storage capacity`},"storage.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Storage power`},"storage.chargedKwh":{kind:`counter`,unit:`kWh`,displayName:`Storage charged`},"storage.dischargedKwh":{kind:`counter`,unit:`kWh`,displayName:`Storage discharged`},"storage.healthPct":{kind:`gauge`,unit:`%`,deadband:1,displayName:`Storage health`}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Energy system`,`Sistema energetico`),order:4020}},Cwe=S([`date`,`time`,`datetime`]),$P=x({value:l(),timestamp:y().optional(),lastFetchedAt:n()}),eF={name:`enum-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:$P,kind:`push`},runtimeState:$P,durability:`restored`,history:{fields:{value:{kind:`enum`,skipWhenSet:`timestamp`}}},volatileStateFields:[`lastFetchedAt`,`timestamp`],vocabulary:{noun:F(`State sensor`,`Sensore di stato`),order:5060,state:[{kind:`value`,field:`value`,label:F(`State`,`Stato`),icon:`list`}]}},tF=S([`warning`,`error`]),nF=x({code:l(),label:l(),severity:tF}),rF=x({active:y().nullable(),code:l().nullable(),label:l().nullable(),severity:tF,since:n().nullable(),faults:C(nF).optional(),lastFetchedAt:n()}),iF={active:null,code:null,label:null,severity:`error`,since:null,lastFetchedAt:0},aF={name:`error`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},status:{schema:rF,kind:`push`,empty:iF},runtimeState:rF,durability:`restored`,volatileStateFields:[`lastFetchedAt`],history:`none`,vocabulary:{noun:F(`Fault`,`Guasto`),order:5265,state:[{kind:`boolean`,field:`active`,label:F(`Fault`,`Guasto`),whenTrue:F(`When {device} reports a fault`,`Quando {device} segnala un guasto`),whenFalse:F(`When the fault of {device} clears`,`Quando il guasto di {device} si risolve`),icon:`triangle-alert`}]}},oF=x({id:l(),name:l(),sampleCount:n().int().nonnegative(),coverMediaId:n().int().optional(),coverBase64:l().optional()}),wwe=x({id:l(),source:S([`detected`,`photo`]),addedAt:n().int(),deviceId:n().int().optional(),base64:l().optional(),mediaId:n().int().optional(),keyFrameMediaId:n().int().optional(),faceBbox:sC.optional()}),Twe=x({sampleId:l(),enrolledAt:n().int(),deviceId:n().int().optional(),source:S([`detected`,`photo`]),mediaId:n().int().optional(),comparable:y(),selfMean:n().nullable(),bestForeign:x({identityId:l(),name:l(),score:n()}).optional(),suspicion:n()}),Ewe=x({identityId:l(),name:l(),modelId:l(),totalSamples:n().int(),comparableSamples:n().int(),flagged:n().int(),flagThreshold:n(),rows:C(Twe).readonly()}),sF=x({faceId:l(),deviceId:n().int(),trackId:l(),timestamp:n().int(),recognizedIdentityId:l().optional(),identityName:l().optional(),assigned:y(),base64:l().optional(),cropUrl:l().optional(),faceBbox:sC.optional(),keyFrameMediaId:n().int().optional(),bestMatchScore:n().optional(),nativeFaceShortSidePx:n().optional(),suggestedIdentityId:l().optional(),suggestedMatchScore:n().optional()}),Dwe=S([`unassigned`,`recognized`,`identified`,`all`]),Owe=S([`timestamp`,`suggestionConfidence`]),kwe=S([`asc`,`desc`]),Awe=x({faceIds:C(l()).readonly(),representativeFaceId:l(),size:n().int(),cohesion:n()}),jwe=x({mediaId:n().int(),kind:l(),url:l(),sizeBytes:n(),timestamp:n()}),cF={name:`face-gallery`,role:{feature:`face-assignment`},scope:`system`,mode:`singleton`,methods:{listIdentities:A(x({includeCrops:y().optional()}).optional(),C(oF).readonly(),{role:`viewer`}),createIdentity:A(x({name:l().min(1)}),oF,{kind:`mutation`,auth:`admin`}),renameIdentity:A(x({id:l(),name:l().min(1)}),v(),{kind:`mutation`,auth:`admin`}),deleteIdentity:A(x({id:l()}),v(),{kind:`mutation`,auth:`admin`}),listIdentitySamples:A(x({identityId:l()}),C(wwe).readonly()),auditIdentitySamples:A(x({identityId:l().min(1)}),Ewe,{auth:`admin`}),removeSample:A(x({identityId:l(),sampleId:l()}),v(),{kind:`mutation`,auth:`admin`}),moveIdentitySample:A(x({sampleId:l().min(1),toIdentityId:l().min(1)}),v(),{kind:`mutation`,auth:`admin`}),listRecentFaces:A(x({deviceId:n().int().optional(),deviceIds:C(n().int()).optional(),limit:n().int().positive().optional(),filter:Dwe.optional(),since:n().int().optional(),until:n().int().optional(),sortBy:Owe.optional(),sortDirection:kwe.optional(),includeCrops:y().optional()}).optional(),C(sF).readonly()),getFaceByTrack:A(x({deviceId:n().int(),trackId:l()}),sF.nullable(),{role:`viewer`}),getFaceMedia:A(x({faceId:l()}),C(jwe).readonly()),assignFace:A(x({faceId:l(),identityId:l()}),v(),{kind:`mutation`,auth:`admin`}),unassignFace:A(x({faceId:l()}),v(),{kind:`mutation`,auth:`admin`}),deleteFace:A(x({faceId:l()}),v(),{kind:`mutation`,auth:`admin`}),assignFaces:A(x({faceIds:C(l()).min(1),identityId:l()}),x({assigned:n().int(),failed:C(l()).readonly()}),{kind:`mutation`,auth:`admin`}),unassignFaces:A(x({faceIds:C(l()).min(1)}),x({unassigned:n().int(),failed:C(l()).readonly()}),{kind:`mutation`,auth:`admin`}),suggestFaceClusters:A(x({threshold:n().min(0).max(1).optional(),minClusterSize:n().int().min(2).optional(),maxClusters:n().int().positive().optional(),limit:n().int().positive().optional(),maxFacesScanned:n().int().positive().optional()}).optional(),C(Awe).readonly())},vocabulary:{notOperatorFacing:`the face gallery — curated on its own page`}},lF=x({reason:l(),count:n().int().nonnegative()}),uF=x({family:l(),deviceId:n().int().positive(),variant:l().optional(),sinceMs:n(),atMs:n(),attempts:n().int().nonnegative(),succeeded:n().int().nonnegative(),reasons:C(lF).readonly()}),dF={name:`failure-contribution`,scope:`system`,mode:`collection`,internal:!0,methods:{list:A(v(),C(uF).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:M.INTERNAL}},fF=S([`forward`,`reverse`]),pF=[`horizontal`,`vertical`],mF=S(pF),hF=[`oscillating`,`angle`,`sweepFrom`,`sweepTo`],gF=S(hF),_F=[`min`,`max`,`step`],vF=x({oscillating:y().nullable().default(null),angle:n().nullable().default(null),sweepFrom:n().nullable().default(null),sweepTo:n().nullable().default(null),min:n().nullable().default(null),max:n().nullable().default(null),step:n().nullable().default(null)}),yF=x({horizontal:vF.nullable().default(null),vertical:vF.nullable().default(null)}),bF=[`nothing-to-set`,`axis-not-linked`,`out-of-range`,`source-gone`,`source-unknown`,`source-call-failed`],xF=S(bF),SF=i(`status`,[x({status:p(`applied`)}),x({status:p(`refused`),reason:xF,field:gF.optional(),detail:l(),applied:C(gF)})]),CF=x({deviceId:n().int().nonnegative(),axis:mF,oscillating:y().optional(),angle:n().optional(),sweepFrom:n().optional(),sweepTo:n().optional()});function wF(e,t){return`oscillationAxes.${e}.${t}`}var TF=x({speed:n().min(0).max(100).nullable().meta(N(`percentage`)),percentageStep:n().positive().optional().meta(N(`percentage`)),preset:l(),availablePresets:C(l()),direction:fF.nullable(),oscillating:y().nullable(),oscillationAxes:yF.optional(),lastChangedAt:n()});function Mwe(e){let t=e.oscillationAxes;if(t===void 0)return e.oscillating;let n=pF.flatMap(e=>{let n=t[e]?.oscillating;return n==null?[]:[n]});return n.length===0?e.oscillating:n.some(Boolean)}var EF=[E.Fan],DF=`oscillation-axes`;function Nwe(e){return{id:`${e}-oscillating`,cardinality:`scalar`,vocabulary:{cap:`fan-control`,stateField:`oscillating`},deviceTypes:EF,apply:`replace`,section:DF,path:wF(e,`oscillating`),sources:[{kind:`switch`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}}function OF(e,t){let n={id:`${e}-${t}`,cardinality:`scalar`,vocabulary:{cap:`fan-control`},deviceTypes:EF,apply:`replace`,section:DF,path:wF(e,t),sources:[{kind:`numeric`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}};return t===`angle`?{...n,companions:_F.map(t=>({kind:`source-field`,path:wF(e,t),field:t}))}:n}var Pwe=pF.flatMap(e=>[Nwe(e),OF(e,`angle`),OF(e,`sweepFrom`),OF(e,`sweepTo`)]),Fwe={id:`preset`,cardinality:`scalar`,vocabulary:{cap:`fan-control`},deviceTypes:EF,apply:`replace`,path:`preset`,sources:[{kind:`field`,valueKinds:[`string`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}},kF=[...Pwe,Fwe],Iwe={version:1,overridable:kF.map(e=>({path:e.path,by:e.id})),targets:kF},AF={name:`fan-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Fan],methods:{setPercentage:j(x({deviceId:n().int().nonnegative(),speed:n().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.off`,label:F(`Fan off`,`Ventilatore spento`),phrase:F(`Stop {device}`,`Ferma {device}`),icon:`power-off`,effect:{field:`speed`,value:0},args:{speed:0}},{id:`fan.full`,label:F(`Fan full`,`Ventilatore al massimo`),phrase:F(`Run {device} at full speed`,`Porta {device} alla massima velocità`),icon:`fan`,effect:{field:`speed`,value:100},args:{speed:100},sideEffects:[{field:`preset`,value:``,when:{field:`preset`,notIn:[``]}}]},{id:`fan.speed`,label:F(`Set speed`,`Imposta la velocità`),phrase:F(`Set the speed of {device} to {speed}`,`Imposta la velocità di {device} al {speed}`),icon:`fan`,effect:{field:`speed`,fromArg:`speed`},sideEffects:[{field:`preset`,value:``,when:{field:`preset`,notIn:[``]}}],openArgs:[{key:`speed`,label:F(`Speed`,`Velocità`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setPreset:j(x({deviceId:n().int().nonnegative(),preset:l().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.preset`,label:F(`Set preset`,`Imposta il preset`),phrase:F(`Set {device} to preset {preset}`,`Imposta {device} sul preset {preset}`),icon:`list`,effect:{field:`preset`,fromArg:`preset`},openArgs:[{key:`preset`,label:F(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`status`,field:`availablePresets`}}]}]}),setDirection:j(x({deviceId:n().int().nonnegative(),direction:fF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.forward`,label:F(`Spin forward`,`Rotazione avanti`),phrase:F(`Spin {device} forward`,`Fai girare {device} in avanti`),icon:`refresh-cw`,effect:{field:`direction`,value:`forward`},args:{direction:`forward`}},{id:`fan.reverse`,label:F(`Spin in reverse`,`Rotazione inversa`),phrase:F(`Spin {device} in reverse`,`Fai girare {device} al contrario`),icon:`rotate-ccw`,effect:{field:`direction`,value:`reverse`},args:{direction:`reverse`}}]}),setOscillating:j(x({deviceId:n().int().nonnegative(),oscillating:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.oscillateOn`,label:F(`Oscillate`,`Oscillazione attiva`),phrase:F(`Make {device} oscillate`,`Fai oscillare {device}`),icon:`move-horizontal`,effect:{field:`oscillating`,value:!0},args:{oscillating:!0}},{id:`fan.oscillateOff`,label:F(`Stop oscillating`,`Oscillazione spenta`),phrase:F(`Stop {device} oscillating`,`Ferma l’oscillazione di {device}`),icon:`move-horizontal`,effect:{field:`oscillating`,value:!1},args:{oscillating:!1}}]}),setOscillationAxis:j(CF,SF,{kind:`mutation`,auth:`protected`,actions:[{id:`fan.horizontalOscillateOn`,label:F(`Horizontal oscillation on`,`Oscillazione orizzontale attiva`),phrase:F(`Start the horizontal oscillation of {device}`,`Attiva l’oscillazione orizzontale di {device}`),icon:`move-horizontal`,args:{axis:`horizontal`,oscillating:!0}},{id:`fan.horizontalOscillateOff`,label:F(`Horizontal oscillation off`,`Oscillazione orizzontale spenta`),phrase:F(`Stop the horizontal oscillation of {device}`,`Ferma l’oscillazione orizzontale di {device}`),icon:`move-horizontal`,args:{axis:`horizontal`,oscillating:!1}},{id:`fan.verticalOscillateOn`,label:F(`Vertical oscillation on`,`Oscillazione verticale attiva`),phrase:F(`Start the vertical oscillation of {device}`,`Attiva l’oscillazione verticale di {device}`),icon:`move-vertical`,args:{axis:`vertical`,oscillating:!0}},{id:`fan.verticalOscillateOff`,label:F(`Vertical oscillation off`,`Oscillazione verticale spenta`),phrase:F(`Stop the vertical oscillation of {device}`,`Ferma l’oscillazione verticale di {device}`),icon:`move-vertical`,args:{axis:`vertical`,oscillating:!1}}]})},status:{schema:TF,kind:`push`},runtimeState:TF,customize:Iwe,durability:`session`,history:{fields:{speed:{kind:`gauge`,unit:`%`,minIntervalMs:0},oscillating:{kind:`boolean`}}},vocabulary:{noun:F(`Fan`,`Ventilatore`),order:1080,state:[{kind:`numeric`,field:`speed`,quantity:F(`the speed`,`la velocità`),label:F(`Speed`,`Velocità`),unit:`%`,icon:`fan`},{kind:`boolean`,field:`oscillating`,label:F(`Oscillating`,`Oscillazione`),whenTrue:F(`When {device} starts oscillating`,`Quando {device} inizia a oscillare`),whenFalse:F(`When {device} stops oscillating`,`Quando {device} smette di oscillare`),icon:`move-horizontal`}]}},Lwe=12,jF=x({oscillating:y().optional(),angle:n().optional(),sweepFrom:n().optional(),sweepTo:n().optional()}),MF=x({speed:n().min(0).max(100).optional(),preset:l().min(1).optional(),direction:fF.optional(),oscillationAxes:x({horizontal:jF.optional(),vertical:jF.optional()}).optional()}),NF=x({id:l().min(1).max(64),name:l().trim().min(1).max(40),state:MF}),PF=[`empty-state`,`duplicate-name`,`duplicate-id`,`too-many`,`not-a-fan`],FF=S(PF),IF=i(`status`,[x({status:p(`saved`),count:n().int().nonnegative()}),x({status:p(`refused`),reason:FF,detail:l()})]),LF=x({field:l(),outcome:S([`applied`,`failed`,`not-run`,`refused`]),message:l().optional()}),RF=x({status:S([`applied`,`partial`,`refused`]),fields:C(LF)}),zF=[`speed`,`direction`,`preset`,`oscillationAxes`],BF=S(zF),VF=x({what:l(),reason:l()}),HF=x({state:MF,omitted:C(VF)}),UF=x({deviceId:n().int().nonnegative()}),Rwe={version:1,targets:[{id:`presets`,cardinality:`config`,vocabulary:{cap:`fan-presets`},deviceTypes:[E.Fan],apply:`add`,readMethod:`getPresets`,writeMethod:`setPresets`}]},WF={name:`fan-presets`,scope:`system`,mode:`singleton`,methods:{getPresets:A(UF,C(NF),{auth:`protected`}),setPresets:A(UF.extend({presets:C(NF).max(12)}),IF,{kind:`mutation`,auth:`admin`}),applyPreset:A(UF.extend({presetId:l().min(1)}),RF,{kind:`mutation`,auth:`protected`}),capturePreset:A(UF.extend({fields:C(BF).optional()}),HF,{auth:`protected`})},customize:Rwe,vocabulary:{notOperatorFacing:`the per-fan presets — authored in the Customize presets editor, applied through the actions the exports list`}},GF=x({flags:m(l(),w()),deviceType:l().nullable(),model:l().nullable(),channelCount:n().nullable().meta(N(`count`)),lastProbedAt:n(),lastFetchedAt:n()}),KF={name:`feature-probe`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},events:{onProbeChanged:{data:x({deviceId:n(),status:GF}),notOperatorFacing:`the device’s capabilities were re-probed — plumbing, not a happening`}},status:{schema:GF,kind:`push`},runtimeState:GF,durability:`session`,history:`none`,vocabulary:{noun:F(`Feature probe`,`Rilevamento funzioni`),order:3120}},zwe=x({name:l(),path:l()}),Bwe=x({path:l(),entries:C(zwe).readonly(),freeBytes:n(),totalBytes:n()}),qF={name:`filesystem-browse`,scope:`system`,mode:`singleton`,internal:!0,methods:{listAllowedRoots:A(v(),C(l()).readonly(),{auth:`admin`}),browse:A(x({path:l()}),Bwe,{auth:`admin`}),createDir:A(x({path:l()}),x({path:l()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.INTERNAL}},JF=x({flooded:y(),lastChangedAt:n()}),YF={name:`flood`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:JF,kind:`push`},runtimeState:JF,durability:`restored`,history:{fields:{flooded:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Leak sensor`,`Sensore di allagamento`),order:5070,state:[{kind:`boolean`,field:`flooded`,label:F(`Leak`,`Perdita`),whenTrue:F(`When {device} detects a leak`,`Quando {device} rileva una perdita`),whenFalse:F(`When {device} is dry again`,`Quando {device} torna asciutto`),icon:`droplets`}]}},XF=x({detected:y(),lastChangedAt:n()}),ZF={name:`gas`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:XF,kind:`push`},runtimeState:XF,durability:`restored`,history:{fields:{detected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Gas sensor`,`Sensore di gas`),order:5080,state:[{kind:`boolean`,field:`detected`,label:F(`Detected`,`Rilevato`),whenTrue:F(`When {device} detects gas`,`Quando {device} rileva gas`),whenFalse:F(`When the gas clears on {device}`,`Quando il gas su {device} rientra`),icon:`flame`}]}},QF=x({active:y().meta({label:`Active`}),lastChangedAt:n()}),$F={name:`group-active`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Cover,E.Valve,E.Lock,E.MediaPlayer,E.Climate],methods:{},status:{schema:QF,kind:`push`},runtimeState:QF,durability:`session`,history:`none`,vocabulary:{noun:F(`Group state`,`Stato del gruppo`),order:5090}},eI=x({deviceId:n().int().nonnegative(),cap:l().min(1),method:l().min(1),ok:y(),error:l().optional(),at:n()}),tI=x({results:C(eI)}),nI={name:`group-commands`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Switch,E.Light,E.Fan,E.Cover,E.Valve,E.Lock,E.MediaPlayer,E.Climate],methods:{},status:{schema:tI,kind:`push`},runtimeState:tI,durability:`session`,history:`none`,vocabulary:{noun:F(`Group command`,`Comando di gruppo`),order:5100}},rI=x({included:n().int().nonnegative().meta(N(`count`,{precision:0,label:`Reporting`})),excluded:n().int().nonnegative().meta(N(`count`,{precision:0,label:`Excluded`})),total:n().int().nonnegative().meta(N(`count`,{precision:0,label:`Members`}))}),iI={name:`group-status`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor,E.Switch,E.Light,E.Fan,E.Cover,E.Valve,E.Lock,E.MediaPlayer,E.Climate],methods:{},status:{schema:rI,kind:`push`},runtimeState:rI,durability:`session`,history:`none`,vocabulary:{noun:F(`Group`,`Gruppo`),order:5110,state:[{kind:`numeric`,field:`included`,quantity:F(`the members reporting`,`i membri che rispondono`),label:F(`Reporting`,`Rispondono`),icon:`users`},{kind:`numeric`,field:`excluded`,quantity:F(`the members left out`,`i membri esclusi`),label:F(`Excluded`,`Esclusi`),icon:`users`},{kind:`numeric`,field:`total`,quantity:F(`the member count`,`il numero di membri`),label:F(`Members`,`Membri`),icon:`sigma`}]}},aI=n().int().nonnegative(),oI=l().min(1),sI=l().min(1),cI=n().finite(),lI={key:`circuitId`,label:F(`Circuit`,`Circuito`),offer:{kind:`dynamic`,from:`status`,cap:`heat-pump-status`,field:`circuits`,valueKey:`id`,labelKey:`label`,where:{key:`kind`,equals:`heating`}}},uI={...lI,label:F(`Hot water circuit`,`Circuito acqua calda`),offer:{...lI.offer,where:{key:`kind`,equals:`dhw`}}},dI={key:`mode`,label:F(`Mode`,`Modalità`),offer:{kind:`text`}},Vwe={key:`level`,label:F(`Level`,`Livello`),offer:{kind:`text`}},fI={key:`temp`,label:F(`Temperature`,`Temperatura`),offer:{kind:`number`,step:.5,unit:`°C`}},Hwe={key:`minutes`,label:F(`Minutes`,`Minuti`),offer:{kind:`number`,min:1,step:1,unit:`min`}},pI={name:`heat-pump-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.HeatPump],methods:{setSilentMode:A(x({deviceId:aI,mode:sI}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.silent`,label:F(`Set silent mode`,`Imposta la modalità silenziosa`),phrase:F(`Set silent mode of {device} to {mode}`,`Imposta la modalità silenziosa di {device} su {mode}`),icon:`volume-x`,openArgs:[{key:`mode`,label:F(`Silent mode`,`Modalità silenziosa`),offer:{kind:`enum`,values:[{value:`off`,label:F(`Off`,`Off`)},{value:`auto`,label:F(`Auto`,`Auto`)},{value:`on`,label:F(`On`,`On`)}]}}]}]}),setAwayMode:A(x({deviceId:aI,mode:sI}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.away`,label:F(`Set away mode`,`Imposta la modalità assente`),phrase:F(`Set away mode of {device} to {mode}`,`Imposta la modalità assente di {device} su {mode}`),icon:`plane`,openArgs:[{key:`mode`,label:F(`Away mode`,`Modalità assente`),offer:{kind:`enum`,values:[{value:`off`,label:F(`Off`,`Off`)},{value:`on`,label:F(`On`,`On`)}]}}]}]}),setAdditionalHeaterMode:A(x({deviceId:aI,mode:sI}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.additionalHeater`,label:F(`Set additional heater`,`Imposta il riscaldatore aggiuntivo`),phrase:F(`Set the additional heater of {device} to {mode}`,`Imposta il riscaldatore aggiuntivo di {device} su {mode}`),icon:`flame`,openArgs:[{key:`mode`,label:F(`Additional heater`,`Riscaldatore aggiuntivo`),offer:{kind:`enum`,values:[{value:`off`,label:F(`Off`,`Off`)},{value:`manual`,label:F(`Manual`,`Manuale`)},{value:`auto`,label:F(`Auto`,`Auto`)}]}}]}]}),setHolidayMode:A(x({deviceId:aI,mode:sI}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.holiday`,label:F(`Set holiday mode`,`Imposta la modalità vacanza`),phrase:F(`Set holiday mode of {device} to {mode}`,`Imposta la modalità vacanza di {device} su {mode}`),icon:`tree-palm`,openArgs:[{key:`mode`,label:F(`Holiday programme`,`Programma vacanza`),offer:{kind:`enum`,values:[{value:`off`,label:F(`Off`,`Off`)},{value:`hm1`,label:F(`Programme 1`,`Programma 1`)},{value:`hm2`,label:F(`Programme 2`,`Programma 2`)},{value:`hm3`,label:F(`Programme 3`,`Programma 3`)},{value:`hm4`,label:F(`Programme 4`,`Programma 4`)},{value:`hm5`,label:F(`Programme 5`,`Programma 5`)},{value:`hm6`,label:F(`Programme 6`,`Programma 6`)},{value:`hm7`,label:F(`Programme 7`,`Programma 7`)},{value:`hm8`,label:F(`Programme 8`,`Programma 8`)}]}}]}]}),setCircuitOperationMode:A(x({deviceId:aI,circuitId:oI,mode:sI}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitOperationMode`,label:F(`Set circuit operation mode`,`Imposta la modalità del circuito`),phrase:F(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`thermometer`,openArgs:[lI,dI]}]}),setCircuitHeatCoolMode:A(x({deviceId:aI,circuitId:oI,mode:sI}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitHeatCoolMode`,label:F(`Set circuit heat / cool`,`Imposta caldo / freddo del circuito`),phrase:F(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`sun-snow`,openArgs:[lI,dI]}]}),setCircuitSummerWinter:A(x({deviceId:aI,circuitId:oI,mode:sI}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitSummerWinter`,label:F(`Set circuit summer / winter`,`Imposta estate / inverno del circuito`),phrase:F(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`sun`,openArgs:[lI,dI]}]}),setCircuitComfortSetpoint:A(x({deviceId:aI,circuitId:oI,temp:cI}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitComfortSetpoint`,label:F(`Set comfort temperature`,`Imposta la temperatura comfort`),phrase:F(`Set the comfort temperature of {circuitId} on {device} to {temp}`,`Imposta la temperatura comfort di {circuitId} su {device} a {temp}`),icon:`thermometer-sun`,openArgs:[lI,fI]}]}),setCircuitEcoSetpoint:A(x({deviceId:aI,circuitId:oI,temp:cI}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitEcoSetpoint`,label:F(`Set eco temperature`,`Imposta la temperatura eco`),phrase:F(`Set the eco temperature of {circuitId} on {device} to {temp}`,`Imposta la temperatura eco di {circuitId} su {device} a {temp}`),icon:`leaf`,openArgs:[lI,fI]}]}),setCircuitMaxFlowTemp:A(x({deviceId:aI,circuitId:oI,temp:cI}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitMaxFlowTemp`,label:F(`Set maximum flow temperature`,`Imposta la temperatura massima di mandata`),phrase:F(`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:[lI,fI]}]}),setDhwOperationMode:A(x({deviceId:aI,circuitId:oI,mode:sI}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwOperationMode`,label:F(`Set hot water mode`,`Imposta la modalità acqua calda`),phrase:F(`Set hot water {circuitId} of {device} to {mode}`,`Imposta l'acqua calda {circuitId} di {device} su {mode}`),icon:`shower-head`,openArgs:[uI,dI]}]}),setDhwTemperatureLevel:A(x({deviceId:aI,circuitId:oI,level:sI}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwTemperatureLevel`,label:F(`Set hot water level`,`Imposta il livello acqua calda`),phrase:F(`Set hot water {circuitId} of {device} to level {level}`,`Imposta l'acqua calda {circuitId} di {device} al livello {level}`),icon:`droplet`,openArgs:[uI,Vwe]}]}),setDhwChargeDuration:A(x({deviceId:aI,circuitId:oI,minutes:n().int().positive()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwChargeDuration`,label:F(`Set hot water charge duration`,`Imposta la durata della carica acqua calda`),phrase:F(`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:[uI,Hwe]}]}),startExtraHotWater:A(x({deviceId:aI,circuitId:oI}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.extraHotWater`,label:F(`Start extra hot water`,`Avvia acqua calda extra`),phrase:F(`Start an extra hot water charge of {circuitId} on {device}`,`Avvia una carica extra di acqua calda {circuitId} su {device}`),icon:`droplets`,openArgs:[uI]}]})},vocabulary:{noun:F(`Heat pump settings`,`Impostazioni pompa di calore`),order:4010}},mI=[`heating`,`dhw`,`cooling`,`solar`],hI=S(mI),gI=x({value:l().nullable(),allowed:C(l())}),_I=x({value:n().nullable(),min:n().nullable(),max:n().nullable(),step:n().nullable()}),vI=x({id:l().min(1),kind:hI,label:l(),icon:Lh,currentTemp:n().nullable().meta(N(`temperature`)),targetTemp:n().nullable().meta(N(`temperature`)),mode:l().nullable(),active:y().nullable(),operationMode:gI.nullable(),heatCoolMode:gI.nullable(),summerWinter:gI.nullable(),comfortSetpoint:_I.nullable(),ecoSetpoint:_I.nullable(),maxFlowTemp:_I.nullable(),temperatureLevel:gI.nullable(),chargeDuration:_I.nullable(),extraHotWater:y().nullable()}),yI=x({silent:gI.nullable(),away:gI.nullable(),additionalHeater:gI.nullable(),holiday:gI.nullable()}),bI=x({thermalW:n().nullable().meta(N(`power`)),electricalW:n().nullable().meta(N(`power`)),compressorPct:n().nullable().meta(N(`percentage`))}),xI=x({supply:n().nullable().meta(N(`temperature`)),return:n().nullable().meta(N(`temperature`)),outdoor:n().nullable().meta(N(`temperature`))}),SI=x({thermalKwh:n().nullable().meta(N(`energy`)),electricalKwh:n().nullable().meta(N(`energy`))}),CI=x({circuits:C(vI),system:yI,power:bI,temperatures:xI,energy:SI,waterPressureBar:n().nullable(),starts:n().nullable(),lastFetchedAt:n()});function wI(e){let{thermalW:t,electricalW:n}=e;return t===null||n===null||n<=0?null:t/n}var Uwe=[E.HeatPump];function TI(e,t,n){return{id:e,cardinality:`scalar`,vocabulary:{cap:`heat-pump-status`},deviceTypes:Uwe,apply:`replace`,path:t,sources:[{kind:`numeric`,requiredUnit:n,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}}var EI=[TI(`electrical-power`,`power.electricalW`,`W`),TI(`electrical-energy`,`energy.electricalKwh`,`kWh`)],Wwe={version:1,overridable:EI.map(e=>({path:e.path,by:e.id})),targets:EI},DI={name:`heat-pump-status`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.HeatPump],methods:{},status:{schema:CI,kind:`push`},runtimeState:CI,durability:`session`,customize:Wwe,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:F(`Heat pump`,`Pompa di calore`),order:4e3}},OI=x({position:n().min(0).max(100).nullable().meta(N(`percentage`)),lastFetchedAt:n()}),kI={name:`heating-valve`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Climate],methods:{},status:{schema:OI,kind:`push`},runtimeState:OI,durability:`session`,history:{fields:{position:{kind:`gauge`,unit:`%`,deadband:1}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Radiator valve`,`Valvola termostatica`),order:1110,state:[{kind:`numeric`,field:`position`,quantity:F(`the valve opening`,`l’apertura della valvola`),label:F(`Valve opening`,`Apertura della valvola`),unit:`%`,icon:`heater`}]}},AI=S([`s`,`min`]),Gwe=S([`switch`,`pet-fountain`]),jI={actuator:`switch`,maxSeconds:10800,unit:`min`,quickRunDefault:30},MI={actuator:`pet-fountain`,maxSeconds:300,unit:`s`,quickRunDefault:60},NI=[E.Switch,E.PetFountain],PI={[E.Switch]:[O.SwitchHeater]};function FI(e,t){return e===E.PetFountain?MI:e===E.Switch&&t===O.SwitchHeater?jI:null}var Kwe=1e3,qwe=6e4;function II(e,t,n){let r=e-t;return r<=0?0:Math.max(1,Math.ceil(r/(n===`min`?qwe:Kwe)))}function Jwe(e,t){return t===`min`?e*60:e}function LI(e){return e.unit===`min`?Math.floor(e.maxSeconds/60):e.maxSeconds}var RI=x({duration:n().positive().finite(),unit:AI});function zI(e,t){let n=LI(e);return{duration:Math.min((t!==null&&Number.isFinite(t)&&t>0?t:null)??e.quickRunDefault,n),unit:e.unit}}var BI=S([`unsupported-device`,`over-max`,`command-failed`]),VI=i(`ok`,[x({ok:p(!0),activeUntil:n()}),x({ok:p(!1),reason:BI,maxSeconds:n().nullable()})]),HI=x({activeUntil:n().nullable(),requestedBy:l().nullable(),quickRun:RI.nullable(),lastFetchedAt:n()}),UI=x({unit:AI,maxDuration:n(),defaultDuration:n()}),WI=x({quickRunDuration:n().positive().finite().nullable().optional()}),GI={name:`timed-run`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:NI,deviceRoles:PI,deviceConfig:{ui:{kind:`derived-form`,builderId:`timed-run`,tab:`general`}},methods:{getOptions:A(x({deviceId:n().int()}),UI),setSettings:A(x({deviceId:n().int(),settings:WI}),v(),{kind:`mutation`,auth:`admin`}),runFor:A(x({deviceId:n().int(),duration:n().positive().finite(),unit:AI}),VI,{kind:`mutation`,auth:`protected`,actions:[{id:`timedRun.runForMinutes`,label:F(`Run for minutes`,`Accendi per alcuni minuti`),phrase:F(`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:F(`Minutes`,`Minuti`),offer:{kind:`number`,min:1,step:1,unit:`min`}}]},{id:`timedRun.runForSeconds`,label:F(`Run for seconds`,`Accendi per alcuni secondi`),phrase:F(`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:F(`Seconds`,`Secondi`),offer:{kind:`number`,min:1,step:1,unit:`s`}}]}]}),cancel:A(x({deviceId:n().int()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`timedRun.cancel`,label:F(`Cancel the timer`,`Annulla il timer`),phrase:F(`Cancel the pending switch-off of {device}`,`Annulla lo spegnimento programmato di {device}`),icon:`timer-off`}]})},status:{schema:HI,kind:`push`},runtimeState:HI,durability:`session`,history:`none`,vocabulary:{noun:F(`Timed run`,`Esecuzione a tempo`),order:2150}},KI=[`on`,`off`,`running`,`idle`,`standby`,`alert`,`offline`,`unknown`],qI=[`success`,`warning`,`danger`,`primary`,`info`,`muted`],JI=[`none`,`pulse`,`spin`,`glow`,`halo`,`wave`,`rise`,`fall`,`tumble`,`equalizer`,`blink`,`breathe`],YI=[`plain`,`heat-rise`,`cool-fall`,`glow`,`water`,`drum`,`sky`,`mist`,`alert-wash`],XI=S(KI),ZI=S(qI),Ywe=S(JI),QI=x({icon:Lh,tone:ZI,background:S(YI),animation:Ywe});function $I(e){let t=hO[e];return t===void 0?null:`cap:${e}.${t.field}`}function Xwe(e){return e.enabledCaps.flatMap(e=>{let t=$I(e),n=hO[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 eL=x({en:l(),it:l()}),tL={en:`—`,it:`—`};function Zwe(e){return e.en===tL.en&&e.it===tL.it}var nL=[`temperature`,`humidity`,`power`,`contact`,`text`],rL=[`hot`,`mild`,`cold`],iL=[`updated`,`changed`],aL=x({value:n(),quantity:la}),oL=x({quantity:S(nL),reading:aL.nullable(),icon:Lh.nullable(),value:eL,unit:l().nullable(),band:S(rL).nullable(),level:n().min(0).max(1).nullable(),word:eL,tone:S(qI),since:n().nullable(),sinceKind:S(iL),historyKey:l().nullable()}),Qwe=3e3,sL=e=>F(e,e),cL=e=>Math.min(1,Math.max(0,e)),$we=(e,t)=>String(Number(e.toFixed(t)));function lL(e){return e<12?`cold`:e>28?`hot`:`mild`}var eTe={hot:F(`Hot`,`Caldo`),mild:F(`Normal`,`Normale`),cold:F(`Cold`,`Freddo`)},tTe={hot:`warning`,mild:`muted`,cold:`info`};function uL(e,t){let n=lL(e);return{quantity:`temperature`,reading:{value:e,quantity:`temperature`},icon:`thermometer`,value:sL($we(e,1)),unit:`°C`,band:n,level:null,word:eTe[n],tone:tTe[n],since:t,sinceKind:`updated`,historyKey:$I(`temperature-sensor`)}}function dL(e,t){let n=e<30,r=e>70;return{quantity:`humidity`,reading:{value:e,quantity:`humidity`},icon:`droplets`,value:sL(String(Math.round(e))),unit:`%`,band:null,level:cL(e/100),word:n?F(`Dry`,`Secco`):r?F(`Humid`,`Umido`):F(`Normal`,`Normale`),tone:n||r?`warning`:`info`,since:t,sinceKind:`updated`,historyKey:$I(`humidity-sensor`)}}function fL(e,t){let n=e>0;return{quantity:`power`,reading:{value:e,quantity:`power`},icon:`zap`,value:sL(String(Math.round(e))),unit:`W`,band:null,level:cL(e/Qwe),word:n?F(`Active`,`Attivo`):F(`Idle`,`Inattivo`),tone:n?`primary`:`muted`,since:t,sinceKind:`updated`,historyKey:$I(`power-meter`)}}function pL(e,t){return{quantity:`contact`,reading:null,icon:e?`door-open`:`door-closed`,value:e?F(`Open`,`Aperto`):F(`Closed`,`Chiuso`),unit:null,band:null,level:+!!e,word:e?F(`Open`,`Aperto`):F(`Closed`,`Chiuso`),tone:e?`warning`:`success`,since:t,sinceKind:`changed`,historyKey:null}}function mL(e,t){return{quantity:`text`,reading:null,icon:null,value:sL(e),unit:null,band:null,level:null,word:F(`Changed`,`Cambiato`),tone:`muted`,since:t,sinceKind:`updated`,historyKey:null}}var nTe={temperature:{icon:`thermometer`,unit:`°C`,sinceKind:`updated`,historyKey:$I(`temperature-sensor`)},humidity:{icon:`droplets`,unit:`%`,sinceKind:`updated`,historyKey:$I(`humidity-sensor`)},power:{icon:`zap`,unit:`W`,sinceKind:`updated`,historyKey:$I(`power-meter`)},contact:{icon:null,unit:null,sinceKind:`changed`,historyKey:null},text:{icon:null,unit:null,sinceKind:`updated`,historyKey:null}};function hL(e){let t=nTe[e];return{quantity:e,reading:null,icon:t.icon,value:tL,unit:t.unit,band:null,level:null,word:tL,tone:`muted`,since:null,sinceKind:t.sinceKind,historyKey:t.historyKey}}var rTe={power:new Set([`energy-sensor`,`voltage-sensor`,`current-sensor`])};function gL(e,t){return t===null?!0:!(rTe[e.quantity]?.has(t)??!1)}var _L=`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(`.`),iTe=S(_L),vL=[`cool`,`heat`,`dry`,`fan`,`auto`,`playing`,`paused`,`open`,`closed`],yL=x({id:iTe,mode:S(vL).nullable(),level:n().min(0).max(1).nullable()}),bL={[E.Camera]:`camera`,[E.Light]:`light`,[E.Siren]:`siren`,[E.Switch]:`plug`,[E.Sensor]:`sensor-sparkline`,[E.Climate]:`thermostat`,[E.Button]:`button`,[E.EventEmitter]:`event-stream`,[E.Update]:`update`,[E.Generic]:`generic`,[E.Notifier]:`event-stream`,[E.Script]:`event-stream`,[E.Automation]:`event-stream`,[E.Lock]:`lock`,[E.Cover]:`cover`,[E.Valve]:`control-dial`,[E.Humidifier]:`control-dial`,[E.WaterHeater]:`heater`,[E.HeatPump]:`heat-pump`,[E.EnergySystem]:`generic`,[E.Workload]:`generic`,[E.Fan]:`fan`,[E.MediaPlayer]:`tv`,[E.AlarmPanel]:`alarm`,[E.Control]:`control-dial`,[E.Presence]:`presence`,[E.Weather]:`weather`,[E.WeatherStation]:`weather`,[E.Vacuum]:`vacuum`,[E.LawnMower]:`lawn-mower`,[E.Container]:`generic`,[E.Image]:`camera`,[E.PetFeeder]:`pet-feeder`,[E.PetFountain]:`pet-fountain`,[E.Dishwasher]:`dishwasher`,[E.Washer]:`washer`,[E.Dryer]:`dryer`,[E.Gateway]:`gateway`},xL={[O.Siren]:`siren`,[O.Floodlight]:`light`,[O.Spotlight]:`light`,[O.PirSensor]:`presence`,[O.Chime]:`speaker`,[O.Autotrack]:`inherit`,[O.Nightvision]:`inherit`,[O.PrivacyMask]:`inherit`,[O.Doorbell]:`inherit`,[O.CoverBlind]:`inherit`,[O.CoverShutter]:`inherit`,[O.CoverAwning]:`inherit`,[O.CoverCurtain]:`inherit`,[O.CoverGarage]:`inherit`,[O.CoverGate]:`inherit`,[O.CoverDoor]:`inherit`,[O.CoverWindow]:`inherit`,[O.BinaryHelper]:`inherit`,[O.Outlet]:`plug`,[O.SwitchHeater]:`heater`,[O.SwitchFan]:`fan`,[O.SwitchLight]:`light`,[O.PoePort]:`plug`,[O.ClimateAc]:`ac`,[O.ClimateThermostat]:`inherit`,[O.ClimateFloor]:`inherit`,[O.ClimateRadiator]:`inherit`,[O.ClimateHeater]:`inherit`,[O.ClimateHeatPumpCircuit]:`inherit`,[O.MotionSensor]:`presence`,[O.ContactSensor]:`contact`,[O.LeakSensor]:`inherit`,[O.SmokeSensor]:`alarm`,[O.COSensor]:`alarm`,[O.GasSensor]:`alarm`,[O.TamperSensor]:`inherit`,[O.VibrationSensor]:`inherit`,[O.ConnectivitySensor]:`inherit`,[O.SoundSensor]:`inherit`,[O.BinarySensor]:`inherit`,[O.TemperatureSensor]:`sensor-sparkline`,[O.HumiditySensor]:`sensor-sparkline`,[O.AmbientLightSensor]:`inherit`,[O.PressureSensor]:`weather`,[O.WindSensor]:`weather`,[O.RainSensor]:`weather`,[O.UvSensor]:`weather`,[O.SolarRadiationSensor]:`weather`,[O.SoilMoistureSensor]:`inherit`,[O.PowerSensor]:`plug`,[O.EnergySensor]:`plug`,[O.VoltageSensor]:`plug`,[O.CurrentSensor]:`plug`,[O.AirQualitySensor]:`inherit`,[O.BatterySensor]:`inherit`,[O.NumericSensor]:`inherit`,[O.EnumSensor]:`inherit`,[O.DateTimeSensor]:`inherit`,[O.GenericSensor]:`inherit`,[O.NumericControl]:`control-dial`,[O.SelectControl]:`control-dial`,[O.TextControl]:`inherit`,[O.DateTimeControl]:`inherit`,[O.MobilePushNotifier]:`inherit`,[O.MessagingNotifier]:`inherit`,[O.EmailNotifier]:`inherit`,[O.GenericNotifier]:`inherit`,[O.IrTransmitter]:`inherit`,[O.Vm]:`inherit`,[O.AppContainer]:`inherit`,[O.Lxc]:`inherit`,[O.App]:`inherit`,[O.Host]:`inherit`,[O.Ups]:`inherit`};function aTe(e){return Object.values(E).includes(e)}function oTe(e){return Object.values(O).includes(e)}function SL(e,t){let n=e!==null&&oTe(e)?xL[e]:void 0;return n!==void 0&&n!==`inherit`?n:aTe(t)?bL[t]:`generic`}var CL=`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(`.`),wL=S(CL),sTe={progress:F(`Progress`,`Avanzamento`),"run-for":F(`Run for`,`Avvia per`),cycle:F(`Cycle`,`Ciclo`),program:F(`Program`,`Programma`),"appliance-power":F(`Appliance`,`Elettrodomestico`),"now-playing":F(`Now playing`,`In riproduzione`),playback:F(`Playback`,`Riproduzione`),volume:F(`Volume`,`Volume`),source:F(`Source`,`Sorgente`),contact:F(`Door`,`Porta`),"motion-trigger":F(`Motion`,`Movimento`),lock:F(`Lock`,`Serratura`),alarm:F(`Alarm`,`Allarme`),fan:F(`Fan`,`Ventola`),vacuum:F(`Cleaning`,`Pulizia`),"vacuum-suction":F(`Suction`,`Aspirazione`),mower:F(`Mowing`,`Taglio`),feeder:F(`Feed now`,`Eroga ora`),fountain:F(`Pump`,`Pompa`),"pump-cycle":F(`Pump cycle`,`Ciclo pompa`),automation:F(`Automation`,`Automazione`),script:F(`Script`,`Script`),"do-not-disturb":F(`Do not disturb`,`Non disturbare`),brightness:F(`Brightness`,`Luminosità`),color:F(`Colour`,`Colore`),cover:F(`Position`,`Posizione`),valve:F(`Valve`,`Valvola`),humidifier:F(`Humidifier`,`Umidificatore`),update:F(`Firmware`,`Firmware`),button:F(`Action`,`Azione`),"climate-mode":F(`Mode`,`Modalità`),"climate-fan":F(`Fan`,`Ventola`),setpoint:F(`Setpoint`,`Temperatura`),channel:F(`Channel`,`Canale`),control:F(`Control`,`Controllo`),circuit:F(`Circuit`,`Circuito`),"heat-pump-power":F(`Power`,`Potenza`),"system-mode":F(`Mode`,`Modalità`)},TL=a(()=>h([l(),n(),y(),m(l(),TL)])),cTe=m(l(),TL);function EL(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]:EL(o,i,n)}}function lTe(e,t,n){return EL(e,t.split(`.`),n)}var DL=x({cap:l(),method:l(),args:cTe}),uTe=S([`off-while-running`,`unlock`,`install`,`press`]),OL=x({id:l(),label:eL,icon:Lh,call:DL,emphasis:S([`primary`,`normal`]),confirm:uTe.nullable()}),kL=i(`kind`,[x({kind:p(`action`),action:OL}),x({kind:p(`toggle`),id:l(),label:eL,on:y().nullable(),turnOn:OL,turnOff:OL}),x({kind:p(`slider`),id:l(),label:eL,value:n().nullable(),min:n(),max:n(),step:n(),unit:l(),call:DL,valueArg:l()}),x({kind:p(`picker`),id:l(),label:eL,current:l().nullable(),options:C(l()),optionLabels:m(l(),eL).optional(),call:DL,valueArg:l()}),x({kind:p(`number`),id:l(),label:eL,value:n().nullable(),step:n().nullable(),unit:l(),call:DL,valueArg:l()}),x({kind:p(`text`),id:l(),label:eL,value:l().nullable(),call:DL,valueArg:l()})]),dTe=x({icon:Lh.nullable(),text:eL,tone:ZI}),fTe=new Set([`cover`,`valve`,`lock`,`vacuum`,`playback`,`brightness`]),pTe=x({id:wL,placement:S([`row`,`scene`]).optional(),label:eL.optional(),group:eL.optional(),pills:C(dTe).optional(),icon:Lh,status:eL.nullable(),controls:C(kL),progress:n().min(0).max(1).nullable().optional()}),AL=x({label:eL,value:h([n(),l()]),unit:l().nullable()}),mTe=x({id:S([`battery`,`network-link`,`integration`]),icon:Lh,tone:ZI,value:n().nullable(),label:eL}),jL=`remote.open`,hTe=x({commands:n().int().nullable(),open:OL.optional()}),gTe=x({items:C(x({key:l(),label:l(),level:n().nullable(),needsAttention:y()})),attention:n().int()}),_Te=i(`kind`,[x({kind:p(`power`),watts:n(),detail:C(AL)}),x({kind:p(`running`),running:y().nullable(),since:n().nullable(),phase:l().nullable(),detail:C(AL)})]),vTe=x({source:S([`switch`,`media-player`,`climate-control`]),on:y().nullable(),assumed:y(),turnOn:OL,turnOff:OL}),yTe=x({activeUntil:n().nullable(),quickRun:RI,run:OL,cancel:OL,remaining:n().nullable()}),bTe=x({on:y().nullable(),confirmOffWhileRunning:y(),running:y().nullable(),powerOn:OL.nullable(),powerOff:OL.nullable(),restart:OL}),ML=x({token:S(YI),animation:S(JI)}),NL=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:Lh.nullable(),text:eL,tone:ZI}),PL=x({label:eL,value:eL,tone:ZI.optional(),at:n().optional()}),xTe=x({left:C(PL).max(2),right:C(PL).max(2)}),STe=i(`kind`,[x({kind:p(`artwork`),url:l(),fallback:ML}),x({kind:p(`state`),...ML.shape})]),CTe=x({partId:l(),cap:l()}),wTe=x({deviceId:n().int(),type:l(),role:l().nullable(),name:l(),state:XI,stateAssumed:y(),look:QI,background:STe,scene:yL,facts:C(NL),sideTiles:xTe,title:eL,caption:eL.optional(),badges:C(mTe),remote:hTe.nullable(),historyLabel:eL,consumables:gTe.nullable(),consumption:_Te.nullable(),ownPower:vTe.nullable(),timedRun:yTe.nullable(),powerSupply:bTe.nullable(),rows:C(pTe),measurement:oL.optional(),gated:C(l()),provenance:C(CTe)}),TTe=x({id:S([`timed-run.run`,`timed-run.cancel`]),duration:n(),unit:S([`min`,`s`])}),FL=x({deviceId:n().int(),name:l(),type:l(),state:XI,stateAssumed:y(),look:QI,scene:yL,statusLine:C(eL),primary:kL.nullable(),primaryGated:y().optional(),timedRun:TTe.nullable(),extras:C(kL).max(2).optional(),trailing:NL.nullable(),measurement:oL.optional()}),IL=[`temperature`,`humidity`,`pressure`,`illuminance`,`reading`,`air-quality`,`valve`],ETe=[`power`,`battery`,`consumables`],DTe=new Set(IL);function OTe(e){for(let t of ETe){let n=e.facts.find(e=>e.id===t);if(n!==void 0)return n}return e.facts.find(t=>DTe.has(t.id)&&t.text.en===e.title.en)??null}var kTe={[E.Climate]:`climate.mode`};function ATe(e){let t=kTe[e.type];if(t!==void 0){let n=RL(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 jTe={[E.Climate]:[`climate.target`],[E.Vacuum]:[`vacuum.base`],[E.LawnMower]:[`mower.dock`],[E.MediaPlayer]:[`volume.level`,jL],[E.Automation]:[`automation.enabled`]},LL=e=>e.kind===`action`?e.action.id:e.id;function RL(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=>LL(e)===t);if(r!==void 0)return r}return null}function MTe(e,t){let n=jTe[e.type]??[],r=t===null?null:LL(t);return n.filter(e=>e!==r).flatMap(t=>{let n=RL(e,t);return n===null?[]:[n]}).slice(0,2)}function NTe(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 PTe(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 FTe(e){let t=OTe(e),{control:n,gated:r}=ATe(e);return{deviceId:e.deviceId,name:e.name,type:e.type,state:e.state,stateAssumed:e.stateAssumed,look:e.look,scene:e.scene,statusLine:NTe(e,t),primary:n,primaryGated:r,timedRun:PTe(e),extras:MTe(e,n),trailing:t,...e.measurement===void 0?{}:{measurement:e.measurement}}}var ITe=x({deviceId:n().int().nonnegative(),canActuate:y().optional()}),LTe=500,RTe=x({deviceIds:C(n().int().nonnegative()).max(500),canActuate:y().optional()}),zL=x({type:l(),rows:C(wL)}),BL={name:`hero-layout`,scope:`system`,mode:`singleton`,methods:{getHeroModel:A(ITe,wTe.nullable(),{auth:`protected`,role:`viewer`}),getRowModels:A(RTe,C(FL.nullable()),{auth:`protected`,role:`viewer`}),getLayout:A(x({deviceType:l(),role:l().nullable().optional()}),zL,{auth:`protected`,role:`viewer`})},vocabulary:{notOperatorFacing:`the device hero model — read-only data the UI draws, never actuated`}},VL=x({on:y(),currentHumidity:n().min(0).max(100).nullable().meta(N(`humidity`)),targetHumidity:n().min(0).max(100).nullable().meta(N(`humidity`)),mode:l().nullable(),availableModes:C(l()),action:l().nullable(),minHumidity:n().nullable().meta(N(`humidity`)),maxHumidity:n().nullable().meta(N(`humidity`)),lastChangedAt:n()}),HL={name:`humidifier`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Humidifier],power:{kind:`field`,field:`on`,set:`setOn`},methods:{setOn:A(x({deviceId:n().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.on`,label:F(`Humidifier on`,`Umidificatore acceso`),phrase:F(`Turn on {device}`,`Accendi {device}`),icon:`power`,effect:{field:`on`,value:!0},args:{on:!0}},{id:`humidifier.off`,label:F(`Humidifier off`,`Umidificatore spento`),phrase:F(`Turn off {device}`,`Spegni {device}`),icon:`power-off`,effect:{field:`on`,value:!1},args:{on:!1}}]}),setTargetHumidity:A(x({deviceId:n().int().nonnegative(),humidity:n().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.target`,label:F(`Set humidity`,`Imposta l’umidità`),phrase:F(`Set {device} to {humidity} humidity`,`Imposta {device} al {humidity} di umidità`),icon:`droplets`,effect:{field:`targetHumidity`,fromArg:`humidity`},openArgs:[{key:`humidity`,label:F(`Humidity`,`Umidità`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setMode:A(x({deviceId:n().int().nonnegative(),mode:l().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.mode`,label:F(`Set mode`,`Imposta la modalità`),phrase:F(`Set {device} to {mode}`,`Imposta {device} su {mode}`),icon:`list`,effect:{field:`mode`,fromArg:`mode`},openArgs:[{key:`mode`,label:F(`Mode`,`Modalità`),offer:{kind:`dynamic`,from:`status`,field:`availableModes`}}]}]})},status:{schema:VL,kind:`push`},runtimeState:VL,durability:`session`,history:{fields:{currentHumidity:{kind:`gauge`,unit:`%`,deadband:.5},on:{kind:`boolean`}}},vocabulary:{noun:F(`Humidifier`,`Umidificatore`),order:1090,state:[{kind:`boolean`,field:`on`,label:F(`On`,`Acceso`),whenTrue:F(`When {device} turns on`,`Quando {device} si accende`),whenFalse:F(`When {device} turns off`,`Quando {device} si spegne`),icon:`power`},{kind:`numeric`,field:`currentHumidity`,quantity:F(`the humidity`,`l’umidità`),label:F(`Humidity`,`Umidità`),unit:`%`,icon:`droplets`}]}},UL=x({humidity:n().min(0).max(100).nullable().meta(N(`humidity`,{precision:0,label:`Humidity`})),lastFetchedAt:n()}),WL={name:`humidity-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor,E.Climate],methods:{},status:{schema:UL,kind:`push`},runtimeState:UL,durability:`restored`,history:{primary:`humidity`,priority:90,fields:{humidity:{kind:`gauge`,unit:`%`,deadband:.5}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Humidity`,`Umidità`),order:5120,state:[{kind:`numeric`,field:`humidity`,quantity:F(`the humidity`,`l’umidità`),label:F(`Humidity`,`Umidità`),unit:`%`,icon:`droplets`}]}},GL=x({url:l().nullable(),lastUpdated:n().nullable().meta(N(`none`))}),KL={name:`image`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Image],methods:{},status:{schema:GL,kind:`push`},runtimeState:GL,durability:`session`,history:`none`,vocabulary:{noun:F(`Image`,`Immagine`),order:3130}},qL=S([`0`,`90`,`180`,`270`]),JL=S([`auto`,`manual`]),YL=S([`auto`,`manual`]),XL=S([`off`,`blc`,`wdr`,`hlc`]),ZL=x({min:n(),max:n(),step:n()}),QL=x({brightness:n().optional().meta(N(`none`)),contrast:n().optional().meta(N(`none`)),saturation:n().optional().meta(N(`none`)),sharpness:n().optional().meta(N(`none`)),mirror:y().optional(),flip:y().optional(),rotate:qL.optional(),whiteBalance:JL.optional(),warmth:n().optional().meta(N(`none`)),exposureMode:YL.optional(),backlightMode:XL.optional(),lastFetchedAt:n()}),$L=x({supportsBrightness:y(),brightness:ZL.optional(),supportsContrast:y(),contrast:ZL.optional(),supportsSaturation:y(),saturation:ZL.optional(),supportsSharpness:y(),sharpness:ZL.optional(),supportsMirror:y(),supportsFlip:y(),rotateOptions:C(qL),whiteBalanceModes:C(JL),supportsWarmth:y(),warmth:ZL.optional(),exposureModes:C(YL),backlightModes:C(XL)}),eR=x({brightness:n().optional(),contrast:n().optional(),saturation:n().optional(),sharpness:n().optional(),mirror:y().optional(),flip:y().optional(),rotate:qL.optional(),whiteBalance:JL.optional(),warmth:n().optional(),exposureMode:YL.optional(),backlightMode:XL.optional()}),tR={name:`image-settings`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],deviceConfig:{ui:{kind:`derived-form`,builderId:`image-settings`,tab:`image`}},methods:{getOptions:A(x({deviceId:n()}),$L),setSettings:A(x({deviceId:n(),settings:eR}),v(),{kind:`mutation`,auth:`admin`})},status:{schema:QL,kind:`poll`},runtimeState:QL,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Image settings`,`Impostazioni immagine`),order:3140}},nR=x({id:l(),addonId:l(),name:l(),enabled:y(),info:m(l(),w()).readonly(),originStableId:l().optional(),createdAt:n(),updatedAt:n(),processState:l()}),rR=x({id:l(),addonId:l(),name:l(),enabled:y(),info:m(l(),w()).readonly(),originStableId:l().optional(),createdAt:n(),updatedAt:n()}),iR=x({addonId:l(),name:l(),providerLabel:l().optional(),description:l(),iconUrl:l().nullable(),color:l(),instanceMode:l(),mode:S([`standalone`,`account`,`broker`]),discoveryMode:l(),kind:S([`device-adoption`,`device-provider`]),brokerKind:l().nullable(),supportsLocationImport:y(),canTest:y(),existingInstances:C(x({id:l(),name:l()})),canAdd:y()}),aR=S([`validated`,`rejected`,`inconclusive`,`unsupported`]),oR=x({success:y(),error:l().optional(),status:aR.optional(),testedBy:l().nullable().optional(),latencyMs:n().nonnegative().optional(),detail:l().optional()}),sR=x({id:l(),name:l().optional(),enabled:y().optional(),info:m(l(),w()).optional()}),cR=x({success:y(),deletedId:l()}),lR={name:`integrations`,scope:`system`,mode:`singleton`,methods:{list:A(v(),C(nR)),get:A(x({id:l()}),nR),getByAddonId:A(x({addonId:l()}),rR.nullable()),listByAddon:A(x({addonId:l()}),C(rR)),adoptInstanceRows:A(x({addonId:l(),rows:C(x({id:l().min(1),name:l(),enabled:y(),stated:y()}))}),x({created:n().int(),updated:n().int(),conflicts:C(x({id:l(),ownerAddonId:l()}))}),{kind:`mutation`,auth:`admin`}),update:A(sR,rR,{kind:`mutation`,auth:`admin`}),delete:A(x({id:l()}),cR,{kind:`mutation`,auth:`admin`}),getAvailableTypes:A(v(),C(iR),{auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:M.ADDON_ADMIN}},zTe=ve(),uR=l().min(1),dR=S([`single`,`multiple`]),fR=S([`devices`,`services`]),pR=x({id:l().min(1),label:l().min(1),functionCap:l().min(1),brokerKind:l().min(1).optional(),alsoServes:C(l().min(1)).optional(),iconUrl:l().min(1).optional(),iconMediaType:l().min(1).optional(),role:fR.optional(),canTest:y().optional(),creatable:y().optional(),signIn:x({basePath:l().min(1),methods:C(S([`device-code`,`proxy`])).optional()}).optional(),connectPath:l().min(1).optional(),disconnectPath:l().min(1).optional(),widgets:C(x({id:l().min(1),placement:S([`connection`,`model`])})).optional()}),mR=x({mode:S([`none`,`lan`,`account`]),scopedToInstance:y()}),hR=x({kind:l().min(1),field:l().min(1),to:x({cap:l().min(1),kind:l().min(1).optional()})}),gR=x({role:fR,discovery:mR.optional(),instanceMode:dR,kind:l(),canTest:y(),kinds:C(pR).min(1),allowRestoreId:y().optional(),mintsId:y().optional(),links:C(hR).optional(),userScoped:y().optional()}),_R=x({state:S([`ok`,`off`,`error`,`unknown`]),detail:l().optional(),label:l().optional()}),vR=S([`scan`,`children`,`none`]),yR=x({id:uR,name:l(),configured:y(),enabled:y().optional(),kind:l().min(1),formValues:m(l(),w()),status:_R.optional(),lastCheckedAt:n().optional(),addDevice:vR.optional()}),bR=x({id:uR,name:l().min(1).optional(),values:m(l(),w())}),xR={name:`integration-instances`,scope:`system`,mode:`collection`,methods:{describe:A(v(),gR,{auth:`admin`}),instanceFormSchema:A(x({id:uR.nullable(),kind:l().min(1).optional(),mode:S([`standalone`,`account`,`broker`]).optional(),candidateStableId:l().min(1).optional()}),zTe,{auth:`admin`}),listInstances:A(se({}),C(yR).readonly(),{auth:`protected`,caller:`scoped`}),getInstance:A(x({id:uR}),yR.nullable(),{auth:`protected`,caller:`scoped`}),createInstance:A(x({id:uR.optional(),name:l().min(1),kind:l().min(1).optional(),values:m(l(),w()).optional(),originStableId:l().min(1).optional(),seed:x({info:m(l(),w())}).optional()}),x({id:l()}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),updateInstance:A(bR,x({ok:p(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),setInstanceEnabled:A(x({id:uR,enabled:y()}),x({ok:p(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),deleteInstance:A(x({id:uR}),x({ok:p(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),testInstance:j(x({id:uR.nullable(),values:m(l(),w()),kind:l().min(1).optional()}),oR,{kind:`mutation`,auth:`protected`,caller:`scoped`})},vocabulary:{notOperatorFacing:M.INTERNAL}},SR=x({codecs:C(l()),sampleRate:n().meta(N(`none`)),duplex:S([`half`,`full`]),maxBacklogMs:n().meta(N(`duration-ms`))}),CR=x({talking:y(),lastSessionAt:n().nullable(),ability:SR.nullable()}),BTe=S([`opus`,`s16le`,`g711ulaw`,`g711alaw`]),wR={name:`intercom`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],methods:{startSession:A(x({deviceId:n()}),x({sessionId:l(),sdpOffer:l()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),handleAnswer:A(x({deviceId:n(),sessionId:l(),sdpAnswer:l()}),v(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),stopSession:A(x({deviceId:n(),sessionId:l()}),v(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),startTalkSession:A(x({deviceId:n()}),x({sessionId:l()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`two-way talk is a person speaking through the viewer, not an automation step`}),pushTalkAudio:A(x({deviceId:n(),audioBase64:l(),codec:BTe.optional(),sampleRate:n().int().positive().optional(),channels:n().int().positive().optional(),sequenceNumber:n().int()}),x({accepted:y()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),endTalkSession:A(x({deviceId:n()}),v(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`})},events:{onStatusChanged:{data:x({deviceId:n(),status:CR}),notOperatorFacing:"the `talking` state trigger phrases both edges of this change"}},status:{schema:CR,kind:`command-driven`},runtimeState:CR,durability:`session`,history:`none`,vocabulary:{noun:F(`Intercom`,`Citofono`),order:3150,state:[{kind:`boolean`,field:`talking`,label:F(`Talking`,`In conversazione`),whenTrue:F(`When someone starts talking through {device}`,`Quando qualcuno inizia a parlare tramite {device}`),whenFalse:F(`When the conversation on {device} ends`,`Quando la conversazione su {device} finisce`),icon:`mic`}]}},TR=S([`carrierHz`,`dutyCyclePercent`,`repeat`,`repeatDelayMs`]),ER=S([`ir`,`rf`]),DR=x({ok:p(!0),ignoredSettings:C(l())}),OR=x({media:C(ER),settable:C(TR),maxTimings:n().int().positive(),learn:y().default(!1),formats:C(UE).default([])}),kR=2e4,AR=6e4,jR=x({native:GE.nullable(),timings:PE,carrierHz:n().int().positive().nullable()}),MR=x({at:n(),ok:y(),error:l().nullable()}),NR=MR.extend({medium:ER}),PR=x({lastSend:NR.nullable(),lastLearn:MR.nullable(),lastFetchedAt:n()});function FR(e){return!(e.kind===`learn`&&e.error===`ir-transmitter.learn-unsupported`)}function VTe(e,t,n){let r=e??{lastSend:null,lastLearn:null,lastFetchedAt:n};return FR(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 HTe(e){return qr(e)?.code??null}var IR={name:`ir-transmitter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Generic],methods:{send:A(x({deviceId:n().int().nonnegative(),timings:PE.optional(),native:GE.optional(),settings:FE.optional()}).refine(e=>e.timings===void 0!=(e.native===void 0),{message:`send takes exactly one of timings or native`}),DR,{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:A(x({deviceId:n().int().nonnegative(),timeoutMs:n().int().positive().max(AR).default(kR)}),jR,{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:A(x({deviceId:n().int().nonnegative()}),OR,{kind:`query`,auth:`protected`})},runtimeState:PR,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`IR / RF transmitter`,`Trasmettitore IR / RF`),order:1140}},LR=S([`key-missing`,`wrong-key`,`key-file-unreadable`,`store-unavailable`,`not-initialized`,`decrypt-failed`]),RR=i(`state`,[x({state:p(`ready`)}),x({state:p(`locked`),reason:LR})]),zR=i(`kind`,[x({kind:p(`value`),value:l(),version:n().int()}),x({kind:p(`missing`)}),x({kind:p(`unavailable`),reason:LR}),x({kind:p(`forbidden`)})]),BR=m(l(),zR),VR=x({ref:l(),owner:l(),scope:l(),fieldPath:l(),version:n().int(),createdAt:n(),updatedAt:n(),updatedBy:l(),lastReadAt:n().nullable()}),UTe=512,HR=C(l().min(1)).max(512),UR={name:`keychain`,scope:`system`,mode:`singleton`,internal:!0,methods:{put:A(x({ref:l().min(1),value:l().min(1)}),x({ref:l(),version:n().int()}),{kind:`mutation`,auth:`admin`}),resolve:A(x({refs:HR}),BR,{auth:`admin`}),delete:A(x({refs:HR}),x({deleted:n().int()}),{kind:`mutation`,auth:`admin`}),deleteDeviceScope:A(x({deviceId:n().int()}),x({refs:C(l()).readonly()}),{kind:`mutation`,auth:`admin`}),releaseRecordRefs:A(x({refs:HR,onBehalfOf:l().min(1)}),x({released:n().int()}),{kind:`mutation`,auth:`admin`}),listMeta:A(x({}),C(VR).readonly(),{auth:`admin`}),getState:A(x({}),RR,{auth:`admin`})},vocabulary:{notOperatorFacing:M.IDENTITY}},WR=S([`mounted-file`,`previous-mounted-file`,`platform`,`default-file`]),GR=x({kind:WR,path:l().optional(),sharesBackupWithDatabase:y()}),WTe=`trigger-file`,KR=x({id:l(),at:n(),actor:l(),lockedReason:l().nullable(),archived:n().int(),archivedCollection:l().nullable(),archivedKeysCollection:l().nullable(),clearedSettingsKeys:C(l()).readonly(),acknowledgedAt:n().nullable()}),qR=x({keychain:RR,keySource:GR.nullable(),configuredSource:GR,fingerprint:l().nullable(),activeKeyId:l().nullable(),rotationPending:y(),retiredWraps:n().int(),recoveryKeyDownloadedAt:n().nullable(),secretCount:n().int(),lastReset:KR.nullable()}),JR=S([`in-use`,`orphan`,`unknown`]),YR=VR.extend({usage:JR}),XR=S([`put`,`delete`,`reveal`,`rotate-master-key`,`purge-retired-keys`,`download-recovery-key`,`delete-orphans`,`reset`,`acknowledge-reset`,`initialize`]),ZR=x({id:l(),at:n(),action:XR,actor:l(),ref:l().nullable(),detail:l().nullable()}),QR=`RESET KEYCHAIN`,$R=S([`jwt-signing-key`]),ez={name:`keychain-admin`,scope:`system`,mode:`singleton`,methods:{status:A(x({}),qR,{auth:`admin`}),listSecrets:A(x({}),C(YR).readonly(),{auth:`admin`}),listAudit:A(x({limit:n().int().min(1).max(500).optional()}),C(ZR).readonly(),{auth:`admin`}),reveal:A(x({ref:l().min(1)}),x({value:l(),version:n().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),setSystemSecret:A(x({name:$R,value:l().min(16)}),x({ref:l(),version:n().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),importSecret:A(x({ref:l().min(1),value:l().min(1)}),x({ref:l(),version:n().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),deleteOrphans:A(x({refs:C(l().min(1)).max(1e3)}),x({deleted:C(l()).readonly(),kept:C(x({ref:l(),usage:JR})).readonly()}),{kind:`mutation`,auth:`admin`,caller:`required`}),rotateMasterKey:A(x({}),x({fingerprint:l(),keySource:GR}),{kind:`mutation`,auth:`admin`,caller:`required`}),purgeRetiredKeys:A(x({}),x({purged:n().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),downloadRecoveryKey:A(x({}),x({key:l(),fingerprint:l(),keySource:GR}),{kind:`mutation`,auth:`admin`,caller:`required`}),resetKeychain:A(x({confirm:p(QR)}),x({archivedCollection:l().nullable(),archived:n().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),resetReport:A(x({}),x({reset:KR.nullable(),pendingReentry:C(VR).readonly()}),{auth:`admin`}),acknowledgeReset:A(x({}),x({acknowledged:y()}),{kind:`mutation`,auth:`admin`,caller:`required`})},vocabulary:{notOperatorFacing:M.IDENTITY}},tz=S([`idle`,`mowing`,`paused`,`docked`,`error`]),nz=S([`info`,`warning`,`error`]),rz=x({activity:tz,batteryLevel:n().min(0).max(100).nullable().meta(N(`percentage`)),progress:n().min(0).max(100).nullable().meta(N(`percentage`)),currentCode:n().nullable().meta(N(`none`)),currentCodeLabel:l().nullable(),severity:nz,lastChangedAt:n()}),iz={name:`lawn-mower-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.LawnMower],methods:{startMowing:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.start`,label:F(`Start mowing`,`Avvia il taglio`),phrase:F(`Start {device} mowing`,`Fai partire il taglio di {device}`),icon:`play`}]}),pause:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.pause`,label:F(`Pause mower`,`Metti in pausa il tosaerba`),phrase:F(`Pause {device}`,`Metti in pausa {device}`),icon:`pause`}]}),dock:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.dock`,label:F(`Dock mower`,`Riporta alla base`),phrase:F(`Send {device} back to its dock`,`Rimanda {device} alla base`),icon:`house`}]})},status:{schema:rz,kind:`push`},runtimeState:rz,durability:`session`,history:{fields:{batteryLevel:{kind:`gauge`,unit:`%`,deadband:2}}},vocabulary:{noun:F(`Robot mower`,`Robot tosaerba`),order:2010,state:[{kind:`enum`,field:`activity`,label:F(`Activity`,`Attività`),values:[{value:`idle`,label:F(`Idle`,`Inattivo`)},{value:`mowing`,label:F(`Mowing`,`In taglio`),phrase:F(`When {device} starts mowing`,`Quando {device} inizia a tagliare`)},{value:`paused`,label:F(`Paused`,`In pausa`)},{value:`docked`,label:F(`Docked`,`Alla base`),phrase:F(`When {device} docks`,`Quando {device} arriva alla base`)},{value:`error`,label:F(`Error`,`Errore`),phrase:F(`When {device} reports an error`,`Quando {device} segnala un errore`)}],icon:`bot`},{kind:`numeric`,field:`batteryLevel`,quantity:F(`the battery level`,`il livello della batteria`),label:F(`Battery`,`Batteria`),unit:`%`,icon:`battery`}]}},az=6e5,GTe=60*6e4,oz=x({inputTokens:n(),outputTokens:n()}),sz=S([`timeout`,`rate-limited`,`auth`,`refusal`,`bad-request`,`unavailable`,`no-profile`,`budget-exceeded`,`adapter-error`]),cz=x({ok:p(!0),text:l(),model:l(),usage:oz,truncated:y(),latencyMs:n()}),lz=S([`guardrail`,`model`]),uz=x({ok:p(!1),code:sz,message:l(),retryAfterMs:n().optional(),refusalSource:lz.optional()}),dz=i(`ok`,[cz,uz]),fz=x({bytes:b(Uint8Array),mimeType:l()}),pz=x({enabled:y().default(!1),maxAttempts:n().int().min(1).max(5).default(1)}),KTe={totalMs:6e4,connectMs:1e4,firstTokenMs:12e4,idleMs:6e4},mz=x({addonId:l().optional(),profileId:l().optional(),consumer:l(),system:l().optional(),prompt:l(),jsonSchema:m(l(),w()).optional(),maxTokens:n().int().positive().optional(),temperature:n().optional(),topP:n().min(0).max(1).optional(),topK:n().int().positive().optional(),reasoningEffort:S([`off`,`low`,`medium`,`high`]).optional(),timeoutMs:n().int().positive().optional(),retry:pz.optional(),requestId:l().optional()}),hz=x({url:l(),filename:l(),sizeBytes:n(),sha256:l().optional()}),gz=i(`kind`,[x({kind:p(`catalog`),catalogId:l()}),x({kind:p(`url`),url:l(),sha256:l().optional(),label:l().optional(),sizeBytes:n().optional(),extraFiles:C(hz).optional()}),x({kind:p(`path`),path:l()})]),_z=x({nodeId:l(),engine:S([`llama-cpp`]),model:gz,contextSize:n().int().default(4096),gpuLayers:n().int().default(0),threads:n().int().optional(),parallel:n().int().default(1),batchSize:n().int().positive().optional(),ubatchSize:n().int().positive().optional(),flashAttention: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(l()).default([]),autoStart:y().default(!1),idleStopMinutes:n().int().default(30)}),vz=x({phase:S([`downloading`,`verifying`]),file:l(),fileIndex:n().int(),fileCount:n().int(),downloadedBytes:n(),totalBytes:n().optional()}),yz=x({nodeId:l(),state:S([`stopped`,`downloading`,`starting`,`ready`,`crashed`,`failed`]),pid:n().optional(),port:n().optional(),modelPath:l().optional(),modelId:l().optional(),downloadProgress:n().min(0).max(1).optional(),download:vz.optional(),lastError:l().optional(),crashesInWindow:n(),memoryBytes:n().optional(),vramBytes:n().optional()}),bz=x({file:l(),sizeBytes:n(),catalogId:l().optional(),installedAt:n().optional(),path:l().optional()}),xz=x({nodeId:l(),modelsBytes:n(),freeBytes:n().optional()}),Sz=mz.extend({images:C(fz).optional(),runtime:_z,timeoutMs:n().int().positive().optional()}),Cz=S([`deviceNotEligible`,`appleIntelligenceNotEnabled`,`modelNotReady`,`osTooOld`,`helperMissing`,`helperCrashed`]),wz=i(`state`,[x({state:p(`available`),osVersion:l(),contextSize:n().int().positive(),languages:C(l()),imageInput:y()}),x({state:p(`unavailable`),reason:Cz,osVersion:l().nullable(),detail:l()}),x({state:p(`unsupported-platform`),platform:l()}),x({state:p(`unknown`),error:l()})]),Tz=mz.extend({images:C(fz).optional(),timeoutMs:n().int().positive().optional()}),Ez=x({requestId:l()}),Dz={name:`llm-runtime`,scope:`system`,mode:`singleton`,internal:!0,methods:{complete:A(Sz,dz,{kind:`mutation`,auth:`admin`,timeoutMs:az}),ensureStarted:A(x({runtime:_z}),yz,{kind:`mutation`,auth:`admin`,timeoutMs:az}),stop:A(x({}),v(),{kind:`mutation`,auth:`admin`}),status:A(x({}),yz,{auth:`admin`}),installModel:A(x({model:gz}),v(),{kind:`mutation`,auth:`admin`,timeoutMs:GTe}),deleteModel:A(x({file:l()}),v(),{kind:`mutation`,auth:`admin`}),listLocalModels:A(x({}),C(bz),{auth:`admin`}),getDiskUsage:A(x({}),xz,{auth:`admin`}),cancel:A(Ez,v(),{kind:`mutation`,auth:`admin`}),appleAvailability:A(x({}),wz,{auth:`admin`}),completeApple:A(Tz,dz,{kind:`mutation`,auth:`admin`,timeoutMs:az})},vocabulary:{notOperatorFacing:M.ML}},Oz=/^[a-z0-9][a-z0-9-]{0,63}$/,kz=l().regex(Oz,`a kind id is lower-case letters, digits and dashes`),Az=x({vision:y(),tools:y(),streaming:y(),reasoning:y().nullable().optional()}),jz=x({id:l(),label:l().optional(),contextLength:n().int().positive().optional(),features:Az.partial().optional()}),Mz=m(l(),w()),qTe=x({id:l(),name:l(),kind:kz,addonId:l(),enabled:y(),model:l(),supportsVision:y(),temperature:n().min(0).max(2).optional(),topP:n().min(0).max(1).optional(),topK:n().int().positive().optional(),maxTokens:n().int().positive().optional(),reasoningEffort:S([`off`,`low`,`medium`,`high`]).optional(),contextLength:n().int().positive().optional(),systemPrompt:l().optional(),timeoutMs:n().int().positive().default(6e4),connectTimeoutMs:n().int().positive().default(1e4),firstTokenTimeoutMs:n().int().positive().default(12e4),idleTimeoutMs:n().int().positive().default(6e4),retry:pz.default({enabled:!1,maxAttempts:1}),toolsEnabled:y().default(!1),providerConfig:Mz.default({})}),Nz=S([`temperature`,`topP`,`topK`,`maxTokens`,`reasoningEffort`,`contextLength`,`systemPrompt`,`timeoutMs`,`connectTimeoutMs`,`firstTokenTimeoutMs`,`idleTimeoutMs`,`retry`,`toolsEnabled`]),Pz=x({id:l(),placement:S([`connection`,`model`]),requires:C(l()).optional()}),Fz=w(),JTe=x({kind:kz,label:l(),icon:l(),addonId:l(),connectionSchema:Fz,advancedSchema:Fz.optional(),features:Az,visionEditable:y(),modelCatalog:S([`fetch`,`static`,`none`]),staticModels:C(jz).optional(),profileFields:C(Nz),providerWidgets:C(Pz).optional()}),Iz=x({addonId:l(),kind:kz,profileId:l().optional(),connection:Mz.optional()}),Lz=S([`auth`,`network`,`unsupported`,`invalid`]),Rz=i(`ok`,[x({ok:p(!0),models:C(jz)}),x({ok:p(!1),code:Lz,message:l()})]),zz=h([x({consumer:l()}),x({purpose:S([`text`,`vision`])})]),Bz=x({selector:zz,profileId:l()}),Vz=x({day:l(),consumer:l(),profileId:l(),calls:n(),okCalls:n(),errorCalls:n(),inputTokens:n(),outputTokens:n(),avgLatencyMs:n()}),Hz=x({id:l(),label:l(),family:l(),purpose:S([`text`,`vision`]),url:l(),sha256:l(),sizeBytes:n(),quantization:l(),minRamBytes:n(),contextSizeDefault:n().int(),mmprojUrl:l().optional()}),Uz=i(`ok`,[x({ok:p(!0),model:gz,label:l(),repo:l(),quantization:l(),purpose:S([`text`,`vision`]),totalBytes:n(),extraFilenames:C(l())}),x({ok:p(!1),code:l(),message:l(),candidates:C(l()).optional(),requiredBytes:n().optional()})]),Wz=x({nodeId:l(),reachable:y(),status:yz.optional(),disk:xz.optional(),error:l().optional(),apple:wz.optional()}),YTe=mz.extend({images:C(fz).min(1)}),Gz=x({addonId:l(),profileId:l()}),Kz={name:`llm`,scope:`system`,mode:`collection`,internal:!1,providerKind:`ai`,nodeIdMode:`data`,methods:{generate:A(mz,dz,{kind:`mutation`,timeoutMs:az}),generateVision:A(YTe,dz,{kind:`mutation`,timeoutMs:az}),cancel:A(x({addonId:l().optional(),requestId:l()}),v(),{kind:`mutation`}),listModels:A(Iz,Rz,{kind:`mutation`,auth:`admin`}),getDefaults:A(x({}),C(Bz)),setDefault:A(x({selector:zz,profileId:l().nullable()}),v(),{kind:`mutation`,auth:`admin`}),getUsage:A(x({since:n().optional(),until:n().optional(),consumer:l().optional(),profileId:l().optional()}),C(Vz)),listModelCatalog:A(x({}),C(Hz)),listRuntimeNodes:A(x({}),C(Wz)),listNodeModels:A(x({nodeId:l()}),C(bz)),resolveModelRef:A(x({ref:l(),maxBytes:n().positive().optional()}),Uz,{kind:`mutation`,auth:`admin`}),installModel:A(x({nodeId:l(),model:gz}),v(),{kind:`mutation`,auth:`admin`}),deleteModel:A(x({nodeId:l(),file:l()}),v(),{kind:`mutation`,auth:`admin`}),getRuntimeStatus:A(Gz,yz),startRuntime:A(Gz,yz,{kind:`mutation`,auth:`admin`}),stopRuntime:A(Gz,v(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.ML}},qz=[`decode`,`transcode`,`recording`,`streaming`,`detection`],Jz=[`measured`,`accounted`,`unattributable`],Yz=x({role:S(qz),deviceId:n().int().positive().nullable(),attribution:S(Jz),unit:l(),pid:n().int().positive().optional(),startedAtMs:n().optional(),cpuSeconds:n().optional(),rssBytes:n().optional()}),Xz={name:`load-contribution`,scope:`system`,mode:`collection`,internal:!0,methods:{list:A(v(),C(Yz).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:M.INTERNAL}},Zz=`https://camstack.zentik.app`,Qz=`/viewer/camstack`;function $z(e){if(e==null||e===``)return!1;try{return new URL(e).origin===Zz}catch{return!1}}function XTe(e){let t=e.baseUrl??e.resolved;return $z(t)?{form:`app`,hubBaseUrl:e.appLinkHub??null}:{form:`hub`,hubBaseUrl:t}}function eB(e){let t;try{t=new URL(e)}catch{return null}return t.protocol!==`https:`&&t.protocol!==`http:`||t.username!==``||t.password!==``||t.hostname===``?null:t.origin}function ZTe(e){let t=e=>e.kind!==`public`||!e.baseUrl.startsWith(`https://`)?null:e.interfaceKind===`public`?0:e.interfaceKind===`vpn`?1:null;return e.flatMap(e=>{let n=t(e),r=eB(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 QTe(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 tB(e){return e.length===0?``:`?${e.map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join(`&`)}`}function $Te(e){let t=QTe(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:eB(r),n=e===null?t.query:[...t.query,[`hub`,e]];return`${Zz}${t.path}${tB(n)}`}return r===``||$z(r)?null:`${r}${Qz}${t.path}${tB(t.query)}`}var nB=[`appConnections`,`notificationTaps`,`internal`,`publicEndpoint`],eEe=[`notificationTaps`,`internal`,`publicEndpoint`];function tEe(e){return e!==`appConnections`}var nEe={appConnections:[],notificationTaps:null,internal:null,publicEndpoint:null},rEe=/^\d{1,3}(?:\.\d{1,3}){3}$/;function rB(e){try{let t=new URL(e).hostname;return t.length>0?t:null}catch{return null}}function iEe(e){return e.replace(/\/+$/,``)}function iB(e){return e.kind===`public`&&e.interfaceKind===`vpn`}function aEe(e){return e.kind===`public`&&e.interfaceKind===`public`}function aB(e){return(e.kind===`lan-ipv4`||e.kind===`lan-ipv6`)&&e.plausible}function oB(e){if(e.kind!==`lan-ipv4`||!e.plausible)return!1;let t=rB(e.baseUrl);return t!==null&&rEe.test(t)}function sB(e){return e.stable===!1}function oEe(e,t){return t.kind===`loopback`||t.kind===`app-link`||t.kind===`custom`||rB(t.baseUrl)===null||sB(t)?null:e===`internal`?oB(t)?0:aB(t)?1:iB(t)?2:null:aEe(t)?0:iB(t)?1:oB(t)?2:aB(t)?3:null}var sEe=new Set([`localhost`,`0.0.0.0`,`::1`,`[::1]`,`::`,`[::]`]);function cEe(e){let t=e.toLowerCase();return sEe.has(t)||t.endsWith(`.localhost`)?!0:/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(t)}function cB(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.`}:cEe(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 lB=`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 uB(e,t,n={}){if($z(t))return e===`notificationTaps`?{ok:!0,baseUrl:Zz}:{ok:!1,reason:`The CamStack app link is not a hub address — only notification taps can use it.`};let r=cB(t);return r.ok&&e===`publicEndpoint`&&r.baseUrl.startsWith(`http:`)&&n.acceptInsecureHttp!==!0?{ok:!1,reason:lB}:r}function dB(e,t){if(t===null||t===``)return null;let n=uB(e,t,{acceptInsecureHttp:!0});return n.ok?n.baseUrl:null}function lEe(e,t){let n=e.flatMap(e=>{let n=oEe(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:iEe(n.endpoint.baseUrl)}function fB(e,t,n){let r=dB(t,n);if(r!==null)return{flagged:r,resolved:r,source:`flagged`};let i=lEe(e,t);return{flagged:null,resolved:i,source:i===null?`none`:`auto`}}function pB(e,t){return fB(e,`internal`,t.internal)}function mB(e,t){return fB(e,`publicEndpoint`,t.publicEndpoint)}function hB(e){let t=dB(`notificationTaps`,e.notificationTaps);return t!==null&&!$z(t)?{flagged:t,resolved:t,source:`flagged`}:{flagged:null,resolved:Zz,source:`auto`}}function gB(e){return sB(e)?!1:e.kind===`lan-ipv4`?!0:e.kind===`public`&&e.interfaceKind===`public`}function _B(e,t){let n=e.filter(gB);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 vB(e,t){let n=new Set(t.appConnections),r=_B(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 uEe(e,t,n){return{appConnections:vB(e,n),notificationTaps:hB(n),internal:pB(t,n),publicEndpoint:mB(t,n)}}function dEe(e){return e===null?null:rB(e)}var fEe=`camstack`,pEe=`_camstack._tcp.local`,mEe={nodeId:`nodeId`,version:`version`,role:`role`,url:`url`,hubId:`hubId`},hEe=`hub`,yB=/^hub-[0-9a-f]{16}$/;function gEe(e){return typeof e==`string`&&yB.test(e)}var _Ee=`camstack-agent`,vEe=`_camstack-agent._tcp.local`,yEe={nodeId:`nodeId`,version:`version`,name:`name`,state:`state`,keyFingerprint:`fp`},bEe=S([`lan`,`wifi`,`docker`,`vpn`,`loopback`,`other`]),bB=x({name:l(),family:S([`IPv4`,`IPv6`]),address:l(),cidr:l(),netmask:l(),internal:y(),mac:l(),kind:bEe,preferred:y(),plausible:y(),plausibleReason:l()}),xEe=x({interfaces:C(bB).readonly(),probedAt:n()}),SEe=bB.nullable(),xB=x({label:l(),baseUrl:l(),kind:S([`lan-ipv4`,`lan-ipv6`,`public`,`loopback`,`app-link`,`custom`]),interfaceKind:S([`lan`,`wifi`,`docker`,`vpn`,`other`,`loopback`,`public`]),plausible:y(),plausibleReason:l(),priority:n(),stable:y().optional()}),CEe=S([`server-config`,`server-env`,`caller-hint`,`default`]),wEe=x({port:n().int().min(1).max(65535),source:CEe}),TEe=x({endpoints:C(xB).readonly(),localPort:wEe}),SB=x({baseUrl:l().nullable(),resolved:l().nullable(),appLinkHub:l().nullable()}),CB=x({baseUrls:C(l()).readonly(),resolved:C(l()).readonly()}),wB=x({override:l().nullable(),resolved:l().nullable(),source:S([`override`,`auto`,`none`])}),EEe=x({cluster:wB,browser:wB}),TB=S(nB),EB=S([`flagged`,`auto`,`none`]),DB=x({flagged:l().nullable(),resolved:l().nullable(),source:EB}),DEe=x({flagged:C(l()).readonly(),resolved:C(l()).readonly(),source:EB}),OB=x({rows:C(xB.extend({detected:y(),custom:y(),flags:C(TB).readonly(),inUse:C(TB).readonly(),eligible:C(TB).readonly()})).readonly(),roles:x({appConnections:DEe,notificationTaps:DB,internal:DB,publicEndpoint:DB}),appLinkHub:l().nullable(),listenerOrigins:C(l()).readonly().optional()}),kB=x({addresses:C(l()).readonly()}),AB=x({mode:S([`generated`,`uploaded`,`disabled`]),leafFingerprintSha256:l().nullable(),caFingerprintSha256:l().nullable(),validTo:l().nullable(),sans:C(l()),caCertPem:l().nullable(),reissueError:l().nullable(),restartRequired:y(),caMissing:y(),localCaConstrained:y().nullable(),caReplacedAt:l().nullable(),storedUpload:x({leafFingerprintSha256:l(),validTo:l(),hasCa:y()}).nullable()}),OEe=x({providerId:l().min(1),modes:C($j)}),kEe=x({providerId:l().optional(),mode:l().optional(),message:l()}),AEe=x({hostsProbed:n().int(),hits:n().int(),timeouts:n().int(),byMode:m(l(),x({probed:n().int(),hits:n().int(),timeouts:n().int()}))}),jEe=x({hits:C(x({providerId:l(),hit:eM})),subnetsScanned:C(l()),errors:C(kEe),stats:AEe}),jB={name:`local-network`,scope:`system`,mode:`singleton`,methods:{list:A(v(),xEe),getPreferred:A(v(),SEe),getConnectionEndpoints:A(x({port:n().int().min(1).max(65535).optional(),includeLoopback:y().optional(),ipv4Only:y().optional(),scheme:S([`http`,`https`]).optional(),includeAppLink:y().optional()}),TEe),getNotificationEndpoint:A(v(),SB),setNotificationEndpoint:A(x({baseUrl:l().nullable()}),SB,{kind:`mutation`}),getViewerEndpoints:A(v(),CB),setViewerEndpoints:A(x({baseUrls:C(l()).readonly()}),CB,{kind:`mutation`}),getAddresses:A(x({scheme:S([`http`,`https`]).optional()}).optional(),OB),addCustomAddress:A(x({baseUrl:l(),label:l().max(80)}),OB,{kind:`mutation`,auth:`admin`}),removeCustomAddress:A(x({baseUrl:l()}),OB,{kind:`mutation`,auth:`admin`}),setAddressRole:A(x({role:TB,baseUrl:l().nullable(),enabled:y(),acceptInsecureHttp:y().optional()}),OB,{kind:`mutation`,auth:`admin`}),getHubAddresses:A(v(),EEe),getAllowedAddresses:A(v(),kB),setAllowedAddresses:A(kB,x({success:p(!0)}),{kind:`mutation`}),resetAllowlistToBestMatch:A(v(),kB,{kind:`mutation`}),getTlsStatus:A(v(),AB),regenerateCertificate:A(x({reason:l().optional()}),AB,{kind:`mutation`,auth:`admin`}),uploadCertificate:A(x({certPem:l().min(1),keyPem:l().min(1),caPem:l().optional()}),AB,{kind:`mutation`,auth:`admin`}),downloadCa:A(v(),x({pem:l()})),useStoredUploadedCertificate:A(v(),AB,{kind:`mutation`,auth:`admin`}),scanNetwork:A(x({requests:C(OEe),subnets:C(l()).optional()}),jEe,{kind:`mutation`,auth:`admin`,timeoutMs:9e4}),getScanSubnets:A(v(),x({subnets:C(l())}),{auth:`admin`}),setScanSubnets:A(x({subnets:C(l())}),x({subnets:C(l())}),{kind:`mutation`,auth:`admin`}),revertToGeneratedCertificate:A(v(),AB,{kind:`mutation`,auth:`admin`})},mount:{kind:`hub-only`},vocabulary:{notOperatorFacing:M.NETWORK}},MB=S([`locked`,`unlocked`,`locking`,`unlocking`,`jammed`,`door-open`]),NB=x({state:MB,codeRequired:y().nullable().optional(),lastChangedAt:n()}),MEe={version:1,overridable:[{path:`state`,by:`door-contact`}],targets:[{id:`door-contact`,cardinality:`scalar`,vocabulary:{cap:`lock-control`,stateField:`state`},deviceTypes:[E.Lock],apply:`replace`,path:`state`,override:{whenSourceTrue:`door-open`,unlessNative:[`jammed`]},sources:[{kind:`binary`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}]},PB={name:`lock-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Lock],methods:{lock:A(x({deviceId:n().int().nonnegative(),code:l().min(1).optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.lock`,label:F(`Lock`,`Chiudi a chiave`),phrase:F(`Lock {device}`,`Chiudi a chiave {device}`),icon:`lock`,effect:{field:`state`,value:`locked`},hold:{effects:[{field:`state`,value:`locking`,when:{field:`state`,notIn:[`locked`]}}]},openArgs:[{key:`code`,label:F(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]}),unlock:A(x({deviceId:n().int().nonnegative(),code:l().min(1).optional(),confirm:y().optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.unlock`,label:F(`Unlock`,`Apri la serratura`),phrase:F(`Unlock {device}`,`Sblocca {device}`),icon:`lock-open`,effect:{field:`state`,value:`unlocked`},hold:{effects:[{field:`state`,value:`unlocking`,when:{field:`state`,notIn:[`unlocked`]}}]},openArgs:[{key:`code`,label:F(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]}),open:j(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.open`,label:F(`Open latch`,`Apri lo scrocco`),phrase:F(`Release the latch of {device}`,`Fai scattare lo scrocco di {device}`),icon:`door-open`}]})},status:{schema:NB,kind:`push`},runtimeState:NB,customize:MEe,durability:`restored`,history:{fields:{state:{kind:`enum`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Lock`,`Serratura`),order:1060,state:[{kind:`enum`,field:`state`,label:F(`Lock state`,`Stato della serratura`),values:[{value:`locked`,label:F(`Locked`,`Chiusa a chiave`),phrase:F(`When {device} locks`,`Quando {device} si chiude a chiave`)},{value:`unlocked`,label:F(`Unlocked`,`Sbloccata`),phrase:F(`When {device} unlocks`,`Quando {device} si sblocca`)},{value:`locking`,label:F(`Locking`,`In chiusura`),phrase:F(`When {device} starts locking`,`Quando {device} inizia a chiudersi`)},{value:`unlocking`,label:F(`Unlocking`,`In apertura`),phrase:F(`When {device} starts unlocking`,`Quando {device} inizia a sbloccarsi`)},{value:`jammed`,label:F(`Jammed`,`Inceppata`),phrase:F(`When {device} jams`,`Quando {device} si inceppa`)},{value:`door-open`,label:F(`Door open`,`Porta aperta`),phrase:F(`When the door of {device} opens`,`Quando la porta di {device} si apre`)}],icon:`lock`}]}},FB=x({armed:n().int().min(0),unknown:C(l()).readonly()}),IB={name:`log-channels`,scope:`system`,mode:`collection`,internal:!0,methods:{list:A(v(),C(kh).readonly()),apply:A(x({windows:C(Jle).readonly()}),FB,{kind:`mutation`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:M.INTERNAL}},LB=S([`debug`,`info`,`warn`,`error`]),RB=x({timestamp:g(),level:LB,scope:C(l()),message:l(),meta:m(l(),w()).optional(),tags:m(l(),l()).optional()}),zB=x({instanceId:l().min(1).max(200).optional(),requestId:l().min(1).max(64).optional(),deviceId:n().int().optional(),fromAddonId:l().min(1).max(200).optional(),fromNodeId:l().min(1).max(200).optional(),tags:m(l(),h([l(),n()])).optional(),level:LB.optional(),text:l().min(1).max(200).optional(),since:n().optional(),until:n().optional(),before:l().min(1).max(1024).optional(),after:l().min(1).max(1024).optional(),limit:n().int().min(1).max(1e3).optional(),budgetMs:n().int().min(50).max(1e4).optional()}),BB=x({id:l().optional(),timestamp:n(),level:LB,scope:l().optional(),message:l(),tags:m(l(),h([l(),n()])).optional(),meta:m(l(),w()).optional()}),VB=x({entries:C(BB),nextBefore:l().nullable(),nextAfter:l().nullable(),scannedBytes:n().int().nonnegative(),done:y(),cancelled:y().optional()}),NEe=x({instanceId:l().min(1).max(200).optional()}),HB=x({readable:y(),reason:l().nullable(),filters:x({deviceId:y(),addonId:y(),nodeId:y(),tags:y(),level:y(),text:y(),timeRange:y()}),retentionDays:n().nullable()}),UB={name:`log-destination`,scope:`system`,mode:`collection`,internal:!0,methods:{write:A(RB,v(),{kind:`mutation`}),describeRead:j(NEe,HB,{auth:`admin`}),read:j(zB,VB,{auth:`admin`}),cancelRead:j(x({requestId:l().min(1).max(64)}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:M.INTERNAL}},WB=S([`primary`,`second-factor`]),GB=x({kind:p(`redirect`),id:l(),label:l(),icon:l().optional(),startUrl:l(),stage:WB,linkable:y().optional(),app:gg.nullable().optional()}),KB=x({kind:p(`widget`),id:l(),addonId:l(),bundle:l(),remote:mS,stage:WB,app:gg.nullable().optional()}),qB=x({kind:p(`passkey`),id:l(),label:l(),stage:WB,rpId:l(),origin:l().nullable(),app:gg.nullable().optional()}),JB=i(`kind`,[GB,KB,qB]),YB={name:`login-method`,scope:`system`,mode:`collection`,internal:!0,methods:{getLoginMethods:A(v(),C(JB).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:M.IDENTITY}},XB=x({sleeping:y().meta({label:`Sleeping`}),lastContactAt:n().optional(),lastUpdated:n().meta(N(`none`))}),ZB={name:`low-power-sleep`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],methods:{wakeUp:A(x({deviceId:n(),timeoutMs:n().int().min(500).max(3e4).default(8e3)}),x({awoke:y(),durationMs:n()}),{kind:`mutation`,notOperatorFacing:`a stream consumer wakes a sleeping camera to watch it; an automation that wants footage asks for the footage`})},status:{schema:XB,kind:`push`,empty:{sleeping:!1,lastUpdated:0}},runtimeState:XB,durability:`restored`,history:`none`,volatileStateFields:[`lastUpdated`],vocabulary:{noun:F(`Low-power sleep`,`Sospensione a basso consumo`),order:5245}},PEe=x({id:l(),label:l(),scope:S([`mesh`,`public`]),url:l(),hostname:l(),port:n(),protocol:S([`http`,`https`])}),QB=x({id:l(),hostname:l(),magicDns:l(),addresses:C(l()).readonly(),os:l().optional(),online:y(),lastSeenMs:n(),isSelf:y(),connection:S([`direct`,`relay`,`idle`]),relay:l().nullable(),lastHandshakeMs:n(),rxBytes:n(),txBytes:n(),tags:C(l()).readonly(),exitNodeOption:y(),advertisedRoutes:C(l()).readonly(),userLogin:l().nullable(),keyExpiry:n().nullable()}),$B=x({joined:y(),meshIp:l(),magicDnsHostname:l(),peerCount:n(),endpoints:C(PEe).readonly(),error:l().optional(),tenantName:l(),magicDnsSuffix:l(),userLogin:l().nullable(),controlPlaneUrl:l(),keyExpiry:n().nullable(),daemonSocket:l().optional(),daemonCliPath:l().optional()}),eV={name:`mesh-network`,scope:`system`,mode:`collection`,providerKind:`mesh`,methods:{getStatus:A(v(),$B),join:A(x({authKey:l().min(8),hostname:l().optional()}),x({joined:p(!0)}),{kind:`mutation`}),startLogin:A(x({hostname:l().optional()}),x({loginUrl:l()}),{kind:`mutation`}),leave:A(v(),x({left:p(!0)}),{kind:`mutation`}),logout:A(v(),x({loggedOut:p(!0)}),{kind:`mutation`}),listPeers:A(v(),x({peers:C(QB).readonly()}))},vocabulary:{notOperatorFacing:M.NETWORK}},tV=x({value:n().nullable().meta(N(`device`,{label:`Total`})),lastFetchedAt:n()}),nV={name:`meter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:tV,kind:`push`},runtimeState:tV,durability:`restored`,history:{fields:{value:{kind:`counter`,deadband:.001,minIntervalMs:6e4}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Meter`,`Contatore`),order:5140,state:[{kind:`numeric`,field:`value`,quantity:F(`the total`,`il totale`),label:F(`Total`,`Totale`),icon:`gauge`}]}},FEe=x({total:n(),user:n(),system:n(),irq:n(),nice:n(),loadAvg:u([n(),n(),n()]),cores:n()}),IEe=x({percent:n().nullable(),totalBytes:n(),usedBytes:n().nullable(),availableBytes:n().nullable(),swapUsedBytes:n(),swapTotalBytes:n()}),LEe=x({readBytes:n(),writeBytes:n(),readOps:n(),writeOps:n(),timestampMs:n()}),REe=x({rxBytes:n(),txBytes:n(),rxPackets:n(),txPackets:n(),rxErrors:n(),txErrors:n(),timestampMs:n()}),rV=x({utilization:n(),model:l(),memoryUsedBytes:n(),memoryTotalBytes:n(),temperature:n().nullable()}),zEe=x({openFds:n(),threadCount:n(),activeHandles:n(),activeRequests:n()}),iV=x({avg10:n(),avg60:n(),avg300:n()}),aV=x({some:iV,full:iV.nullable()}),oV=x({cpu:FEe,memory:IEe,gpu:rV.nullable(),network:REe,disk:LEe,pressure:x({cpu:aV.nullable(),memory:aV.nullable(),io:aV.nullable()}),process:zEe,cpuTemperature:n().nullable(),timestampMs:n()}),BEe=x({path:l(),totalBytes:n(),usedBytes:n(),availableBytes:n(),percent:n()}),sV=x({pid:n(),cpu:n(),memory:n(),privateBytes:n().optional(),sharedBytes:n().optional()}),VEe=x({addonId:l(),nodeId:l(),role:S([`hub`,`worker`]),pid:n(),state:S([`starting`,`running`,`stopping`,`stopped`,`crashed`]),uptimeSec:n()}),HEe=x({pid:n(),ppid:n(),pgid:n(),classification:S([`root`,`managed`,`system`]),addonId:l().nullable(),nodeId:l().nullable(),command:l(),cpuPercent:n(),memoryRssBytes:n(),cpuMainPercent:n().nullable(),cpuGcPercent:n().nullable(),threadCount:n().nullable(),uptimeSec:n()}),UEe=x({source:S([`cgroup-v2`,`cgroup-v1`]),currentBytes:n(),limitBytes:n().nullable(),anonBytes:n().nullable(),fileBytes:n().nullable(),shmemBytes:n().nullable(),slabBytes:n().nullable(),gpuShmemBytes:n().nullable()}).extend({atMs:n()}),WEe=x({atMs:n(),samples:n().int(),cpuMainPercent:n().nullable(),cpuMainPercentMin:n().nullable(),cpuGcPercent:n().nullable(),cpuGcPercentMin:n().nullable(),cpuLifetimePercent:n(),cpuLifetimePercentMin:n(),memoryRssBytes:n(),memoryRssBytesMin:n(),processCount:n().int(),processCountMin:n().int()}),GEe=x({key:l(),kind:S([`addon`,`root`,`unattributed`]),points:C(WEe).readonly()}),KEe=x({nodeId:l(),series:C(GEe).readonly(),containerMemory:C(UEe).readonly(),bucketMs:n(),retainedSamples:n(),oldestAtMs:n().nullable(),cadenceMs:n(),durable:y()}),qEe=x({forNodeId:l(),sinceMs:n().optional(),maxPoints:n().int().positive().optional()}),cV=x({cpuPercent:n(),memoryPercent:n().nullable(),memoryUsedMB:n().nullable(),memoryTotalMB:n(),diskPercent:n().optional(),temperature:n().optional(),gpuPercent:n().optional(),gpuMemoryPercent:n().optional()}),lV={name:`metrics-provider`,scope:`system`,mode:`singleton`,methods:{collectSnapshot:A(v(),oV),getCached:A(v(),oV.nullable()),getCurrent:A(v(),cV),getDiskSpace:A(x({dirPath:l()}),BEe),getGpuInfo:A(v(),rV.nullable()),getCpuTemperature:A(v(),n().nullable()),getProcessStats:A(x({pids:C(n())}),C(sV)),listAddonInstances:A(v(),C(VEe).readonly()),getAddonStats:A(x({addonId:l()}),sV.nullable()),listNodeProcesses:A(v(),C(HEe).readonly()),getLoadSeries:A(qEe,KEe)},vocabulary:{notOperatorFacing:M.CLUSTER}},uV=l().min(1).max(256),dV=m(l(),w()),fV=x({id:uV,deviceId:n().int().optional(),at:n().int().optional(),expiresAt:n().int().optional(),data:dV}),pV=x({id:l(),deviceId:n().int().nullable(),at:n().nullable(),expiresAt:n().nullable(),rev:n().int(),updatedAt:n(),data:dV}),mV=m(si,h([l(),n(),y(),x({in:C(h([l(),n(),y()])).min(1).max(Ln)}),x({gt:h([l(),n()]).optional(),gte:h([l(),n()]).optional(),lt:h([l(),n()]).optional(),lte:h([l(),n()]).optional()}).refine(e=>Object.keys(e).length>0,{message:`name at least one bound`})])),hV={kind:pi},gV={deviceId:n().int().optional(),atFrom:n().optional(),atTo:n().optional()},_V=x({...hV,...gV,where:mV.optional(),order:S([`at`,`id`]).optional(),desc:y().optional(),limit:n().int().min(1).max(zn).default(100),cursor:l().min(1).optional()}),vV=x({records:C(pV),nextCursor:l().nullable()}),JEe=S([`created`,`unchanged`,`updated`]),yV=x({kindId:n().int(),state:JEe,createdIndexes:C(l())}),bV=C(l()),xV=i(`op`,[x({op:p(`put`),kind:pi,record:fV,ifRev:n().int().min(0).optional()}),x({op:p(`patch`),kind:pi,id:uV,data:dV,at:n().int().nullable().optional(),expiresAt:n().int().nullable().optional(),ifRev:n().int().min(1).optional()}),x({op:p(`delete`),kind:pi,id:uV})]),SV=m(l(),m(l(),l())),CV={name:`records`,scope:`system`,mode:`singleton`,internal:!0,methods:{declareKinds:A(x({kinds:m(pi,fi)}),x({kinds:m(l(),yV)}),{kind:`mutation`,auth:`admin`}),get:A(x({...hV,id:uV}),pV.nullable(),{auth:`admin`}),getMany:A(x({...hV,ids:C(uV).min(1).max(Ln)}),C(pV),{auth:`admin`}),secretRefs:A(x({...hV,ids:C(uV).min(1).max(Ln)}),SV,{auth:`admin`}),put:A(x({...hV,record:fV,ifRev:n().int().min(0).optional()}),x({rev:n().int(),releasedRefs:bV}),{kind:`mutation`,auth:`admin`}),putMany:A(x({...hV,records:C(fV).min(1).max(Ln)}),x({count:n().int(),releasedRefs:bV}),{kind:`mutation`,auth:`admin`}),patch:A(x({...hV,id:uV,data:dV,at:n().int().nullable().optional(),expiresAt:n().int().nullable().optional(),ifRev:n().int().min(1).optional()}),x({rev:n().int(),releasedRefs:bV}),{kind:`mutation`,auth:`admin`}),delete:A(x({...hV,id:uV}),x({deleted:y(),secretRefs:bV}),{kind:`mutation`,auth:`admin`}),deleteMany:A(x({...hV,ids:C(uV).min(1).max(Ln)}),x({deleted:n().int(),secretRefs:bV}),{kind:`mutation`,auth:`admin`}),query:A(_V,vV,{auth:`admin`}),count:A(x({...hV,...gV,where:mV.optional()}),x({count:n().int()}),{auth:`admin`}),histogram:A(x({...hV,deviceId:n().int().optional(),from:n(),to:n(),bucketMs:n().int().positive()}),x({buckets:C(x({bucketStart:n(),count:n().int()}))}),{auth:`admin`}),aggregate:A(x({...hV,op:S([`sum`,`min`,`max`,`count`]),field:si.optional(),groupBy:si.optional(),where:mV.optional()}),x({rows:C(x({group:h([l(),n(),ae()]),value:n().nullable()}))}),{auth:`admin`}),deleteWhere:A(x({...hV,deviceId:n().int().optional(),atBefore:n().optional(),where:mV.optional()}),x({deleted:n().int(),secretRefs:bV}),{kind:`mutation`,auth:`admin`}),transact:A(x({ops:C(xV).min(1).max(Ln)}),x({results:C(x({rev:n().int().nullable(),deleted:y()})),releasedRefs:bV,secretRefs:bV}),{kind:`mutation`,auth:`admin`}),deleteDevice:A(x({deviceId:n().int(),kinds:C(pi).optional()}),x({deleted:m(l(),n().int()),secretRefs:bV}),{kind:`mutation`,auth:`admin`}),allocateId:A(x(hV),x({id:n().int()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.INTERNAL}},wV=m(l(),w()),TV=x({integrationId:l().min(1)}),EV=x({id:l().min(1)}),DV=x({id:l(),deviceId:n().int().nullable(),at:n().nullable(),expiresAt:n().nullable(),rev:n().int(),updatedAt:n(),data:wV}),OV={id:l().min(1),deviceId:n().int().optional(),at:n().int().optional(),expiresAt:n().int().optional(),data:wV},kV=x({id:l(),addonId:l(),name:l(),info:wV,enabled:y().optional(),originStableId:l().optional()}),YEe=x({id:n().int(),integrationId:l().nullable().optional(),parentDeviceId:n().int().nullable().optional(),type:l().optional(),name:l().optional(),stableId:l().optional()}),AV=x({version:n().int(),methods:C(l())}),jV=x({message:l(),meta:wV.optional(),tags:x({deviceId:n().int().optional()}).optional()}),XEe={"ledger.declare":{input:x({owner:l().min(1),metas:C(Nf)}),output:x({bootId:l(),snapshot:S([`none`,`written`,`refused`]),steps:C(Jf),migrationApi:AV.optional()}),behaviours:[`ledger.declare.answers-steps-in-engine-order`,`ledger.declare.answers-the-migration-api`]},"ledger.start":{input:x({id:l().min(1)}),output:x({proceed:y(),state:h([p(`pending`),Wf]),reason:l().nullable()}),behaviours:[`ledger.start.proceeds-when-predecessors-applied`]},"ledger.finish":{input:x({id:l().min(1),result:Uf}),output:x({status:Wf,error:l().nullable(),rowsChanged:n().int().nonnegative()}),behaviours:[`ledger.finish.records-the-outcome`]},"legacyRows.read":{input:TV,output:wV,behaviours:[`legacyRows.read.returns-stored-rows`,`legacyRows.read.absent-store-is-empty`,`legacyRows.caller.sibling-package`]},"legacyRows.clear":{input:TV,output:x({rows:n().int().nonnegative(),secrets:n().int().nonnegative()}),behaviours:[`legacyRows.clear.deletes-the-rows`,`legacyRows.clear.absent-store-is-noop`]},"legacyRows.patch":{input:TV.extend({patch:wV}),output:x({written:y()}),behaviours:[`legacyRows.patch.upserts-keys-and-keeps-the-rest`,`legacyRows.patch.absent-store-writes-nothing`]},"legacyRows.deleteKeys":{input:TV.extend({keys:C(l().min(1))}),output:x({present:y(),removed:wV}),behaviours:[`legacyRows.deleteKeys.removes-the-named-keys`,`legacyRows.deleteKeys.absent-store-reports-not-present`]},"records.get":{input:EV,output:DV.nullable(),behaviours:[`records.get.returns-the-row-or-null`]},"records.getResolved":{input:EV,output:DV.nullable(),behaviours:[`records.getResolved.resolves-secret-fields`]},"records.put":{input:x({...OV,ifRev:n().int().optional()}),output:x({rev:n().int()}),behaviours:[`records.put.creates-and-replaces`,`records.put.if-rev-conflict-throws`]},"records.putMany":{input:x({records:C(x(OV))}),output:x({count:n().int().nonnegative()}),behaviours:[`records.putMany.writes-every-row`]},"records.patch":{input:EV.extend({partial:wV,ifRev:n().int().optional()}),output:x({rev:n().int()}),behaviours:[`records.patch.merges-and-null-removes`]},"records.delete":{input:EV,output:x({deleted:y()}),behaviours:[`records.delete.reports-whether-a-row-went`]},"records.query":{input:x({deviceId:n().int().optional(),atFrom:n().optional(),atTo:n().optional(),where:mV.optional(),limit:n().int().min(1).optional(),cursor:l().min(1).optional(),resolveSecrets:y().optional()}),output:x({records:C(DV),nextCursor:l().nullable()}),behaviours:[`records.query.pages-with-a-cursor`,`records.query.filters-on-a-declared-index`]},"records.deleteWhere":{input:x({deviceId:n().int().optional(),atBefore:n().optional(),where:mV.optional()}),output:x({count:n().int().nonnegative()}),behaviours:[`records.deleteWhere.deletes-the-matching-rows`]},"settings.read":{input:x({}),output:x({store:wV}),behaviours:[`settings.read.returns-the-addon-store`]},"settings.write":{input:x({patch:wV}),output:x({}),behaviours:[`settings.write.merges-and-keeps-other-keys`]},"settings.deleteKeys":{input:x({keys:C(l().min(1))}),output:x({removed:C(l())}),behaviours:[`settings.deleteKeys.removes-only-the-named-keys`]},"deviceSettings.listIds":{input:x({}),output:x({deviceIds:C(n().int())}),behaviours:[`deviceSettings.listIds.names-only-the-addons-own-devices`]},"deviceSettings.read":{input:x({deviceIds:C(n().int())}),output:x({blobs:m(l(),wV)}),behaviours:[`deviceSettings.read.returns-only-the-addons-own-blobs`]},"secrets.resolve":{input:x({refs:C(l())}),output:x({values:m(l(),l().nullable())}),behaviours:[`secrets.resolve.answers-null-for-a-missing-ref`]},"secrets.put":{input:x({ref:l().min(1),value:l()}),output:x({}),behaviours:[`secrets.put.stores-under-the-owner`]},"secrets.delete":{input:x({refs:C(l())}),output:x({deleted:n().int().nonnegative()}),behaviours:[`secrets.delete.ignores-unknown-refs`]},"integrations.list":{input:x({}),output:x({integrations:C(kV)}),behaviours:[`integrations.list.lists-every-integration`]},"integrations.get":{input:x({id:l().min(1)}),output:kV.nullable(),behaviours:[`integrations.get.null-for-an-unknown-id`]},"devices.list":{input:x({addonId:l().min(1),integrationId:l().min(1).optional()}),output:x({devices:C(YEe)}),behaviours:[`devices.list.scoped-to-the-addon`,`devices.list.filters-by-integration`]},"devices.get":{input:x({deviceId:n().int()}),output:x({id:n().int(),integrationId:l().nullable(),hasConfig:y()}).nullable(),behaviours:[`devices.get.null-for-an-unknown-id`,`devices.get.reports-link-and-config`]},"devices.aliases":{input:x({deviceIds:C(n().int())}),output:x({aliases:m(l(),l())}),behaviours:[`devices.aliases.answers-for-the-named-ids-only`]},"devices.setIntegrationId":{input:x({deviceId:n().int(),integrationId:l().min(1)}),output:x({}),behaviours:[`devices.setIntegrationId.links-the-device`]},"node.localNodeId":{input:x({}),output:x({nodeId:l()}),behaviours:[`node.localNodeId.names-this-node`]},"log.info":{input:jV,output:x({}),behaviours:[`log.info.writes-a-line`]},"log.warn":{input:jV,output:x({}),behaviours:[`log.warn.writes-a-line`]}},MV={name:`migrations`,scope:`system`,mode:`singleton`,internal:!0,methods:{listLedger:A(x({}),x({entries:C(Gf)}),{auth:`admin`}),listPending:A(x({owner:l().optional()}),x({pending:C(Kf)}),{auth:`admin`}),dryRun:A(x({id:l().min(1)}),qf,{auth:`admin`}),markFailed:A(x({id:l().min(1),error:l().min(1)}),Gf,{kind:`mutation`,auth:`admin`}),retry:A(x({id:l().min(1)}),x({entries:C(Gf)}),{kind:`mutation`,auth:`admin`}),restorePreMigration:A(x({database:yf,snapshotId:l().min(1)}),x({scheduled:y(),held:C(l()),restartRequired:y()}),{kind:`mutation`,auth:`admin`}),declareOwner:A(x({owner:l().min(1),metas:C(Nf),retired:C(l().min(1)).optional()}),x({bootId:l(),snapshot:S([`none`,`written`,`refused`]),steps:C(Jf),migrationApi:AV.optional()}),{kind:`mutation`,auth:`admin`}),startMigration:A(x({id:l().min(1)}),x({proceed:y(),state:h([p(`pending`),Wf]),reason:l().nullable()}),{kind:`mutation`,auth:`admin`}),finishMigration:A(x({id:l().min(1),result:Uf}),x({status:Wf,error:l().nullable(),rowsChanged:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),readLegacyIntegrationRows:A(x({integrationId:l().min(1)}),m(l(),w()),{auth:`admin`}),clearLegacyIntegrationRows:A(x({integrationId:l().min(1)}),x({rows:n().int().nonnegative(),secrets:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),patchLegacyIntegrationRows:A(x({integrationId:l().min(1),patch:m(l(),w())}),x({written:y()}),{kind:`mutation`,auth:`admin`}),deleteLegacyIntegrationRowKeys:A(x({integrationId:l().min(1),keys:C(l().min(1))}),x({present:y(),removed:m(l(),w())}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.INTERNAL}},NV=x({sourceUrl:l(),metadata:sfe,targets:C(ofe).min(1).readonly(),calibrationRef:l().optional(),sessionId:l().optional()}),PV={name:`model-convert`,scope:`system`,mode:`singleton`,internal:!0,methods:{convert:A(NV,lfe,{kind:`mutation`,auth:`admin`,timeoutMs:6e5})},vocabulary:{notOperatorFacing:M.ML}},FV=x({targetNodeId:l(),modelId:l(),format:S(Na),entry:rg}),IV=x({ok:y(),sha256:l(),bytes:n(),path:l()}),LV={name:`model-distributor`,scope:`system`,mode:`singleton`,internal:!0,methods:{distributeModel:A(FV,IV,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.ML}},RV=i(`kind`,[x({kind:p(`camera`)}),x({kind:p(`sensor`),deviceId:n().int().positive()})]),zV=Object.freeze({kind:`camera`});function ZEe(e){if(e===void 0)return{triggeredBy:zV,malformed:!1};let t=RV.safeParse(e);return t.success?{triggeredBy:t.data,malformed:!1}:{triggeredBy:zV,malformed:!0}}var QEe=`cameraSensors`,$Ee=8,BV=x({addonId:l().min(1),stableId:l().min(1)});function VV(e){return`${e.addonId}/${e.stableId}`}var HV=S([`in-addition`,`confirm`,`replace`]),UV=`in-addition`,WV=BV.extend({mode:HV.default(UV)}),GV=x({sensors:C(WV).min(1).max(8)}).superRefine((e,t)=>{let n=new Set;e.sensors.forEach((e,r)=>{let i=VV(e);n.has(i)&&t.addIssue({code:`custom`,path:[`sensors`,r],message:`duplicate camera sensor ${i}`}),n.add(i)})}),KV={addonId:l(),stableId:l(),mode:HV.default(UV)},qV=i(`state`,[x({...KV,state:p(`ready`),deviceId:n(),name:l(),caps:C(l()).readonly()}),x({...KV,state:p(`offline`),deviceId:n(),name:l(),reason:S([`offline`,`disabled`])}),x({...KV,state:p(`missing`),reason:l()}),x({...KV,state:p(`unsupported`),deviceId:n(),name:l(),reason:l()}),x({...KV,state:p(`unreadable`),reason:l()})]),JV=S([`onboard-not-listed`,`no-active-detection`]),YV=S([`always`,`when-confirmed`,`never`]),XV=S([`provider-not-split`]),ZV=x({detected:y(),atMs:n()}),QV=i(`state`,[x({state:p(`not-configured`),cameraLevel:ZV.optional()}),x({state:p(`unreadable`),reason:l(),cameraLevel:ZV.optional()}),x({state:p(`configured`),cameraLevel:ZV.optional(),sensors:C(qV).readonly(),cameraMotion:YV.optional(),notForwarded:JV.optional(),notEnforced:XV.optional()})]),eDe=Object.freeze({state:`unreadable`,reason:`camera sensor mappings not loaded`}),$V=x({bbox:sC,pixelCount:n(),intensity:n()}),eH=x({detected:y(),regionCount:n(),regions:C($V).readonly(),rawRegions:C($V).readonly(),frameWidth:n(),frameHeight:n(),analysisMs:n()}),tH={name:`motion-detection`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[E.Camera],exposesDeviceSettings:!0,methods:{analyze:A(x({deviceId:n(),frame:oC.optional(),frameHandle:xa.optional()}),eH,{role:`admin`,kind:`mutation`,notOperatorFacing:`the pipeline feeds it frames — an internal stage, never called by a person`}),removeCamera:A(x({deviceId:n()}),v(),{role:`admin`,kind:`mutation`,notOperatorFacing:`pipeline housekeeping when a camera leaves`}),reset:A(v(),v(),{role:`admin`,kind:`mutation`,notOperatorFacing:`pipeline housekeeping`})},events:{onMotion:{data:x({deviceId:n(),detected:y(),regionCount:n()}),notOperatorFacing:"the analyzer’s raw verdict; the operator signal is the `motion` cap’s `detected` state"}},vocabulary:{noun:F(`Motion analysis`,`Analisi del movimento`),order:3160}},nH=x({package:y(),confidence:n().min(0).max(1),reason:l().min(1)}),rH=x({x:n(),y:n()}),iH=x({kind:p(`rect`),x:n(),y:n(),width:n(),height:n()}),aH=x({kind:p(`polygon`),points:C(rH)}),oH=x({kind:p(`grid`),gridWidth:n().meta(N(`none`)),gridHeight:n().meta(N(`none`)),cells:C(y())}),sH=x({kind:p(`line`),points:C(rH)}),tDe=i(`kind`,[iH,aH,oH,sH]),cH=S([`rect`,`polygon`,`grid`,`line`]),lH=x({min:n(),max:n()}),uH=x({width:n(),height:n()}),dH=[`owner-not-ready`,`store-read-failed`,`three-way-read-unavailable`,`invalid-stored`,`not-cluster-scoped`],fH=[{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)`}]}],nDe=`cluster-step-models`;function pH(e){return`clusterModel:${e}`}function rDe(e){return fH.some(t=>t.stepId===e)}var mH=Object.freeze(Object.fromEntries(fH.map(e=>[e.stepId,e.defaultModelId])));function hH(e){return e==null||e===``?{kind:`absent`}:typeof e==`string`?{kind:`chosen`,modelId:e}:{kind:`invalid`,value:e}}function gH(e){let t=[];for(let n of fH){let r=hH(e[pH(n.stepId)]);r.kind===`invalid`&&t.push({stepId:n.stepId,value:r.value})}return t}function _H(e){let t={};for(let n of fH){let r=hH(e[pH(n.stepId)]);t[n.stepId]=r.kind===`chosen`?r.modelId:n.defaultModelId}return t}function iDe(e){return typeof e==`object`&&!!e&&`key`in e}function aDe(e){return e===null?mH:_H(yH(e,vH()))}function oDe(e){return e===null?[]:gH(yH(e,vH()))}function vH(){return new Set(fH.map(e=>pH(e.stepId)))}function yH(e,t){let n={};for(let r of e.sections)for(let e of r.fields)!iDe(e)||typeof e.key!=`string`||t.has(e.key)&&(n[e.key]=e.value);return n}function sDe(e,t){let n=fH.find(t=>t.stepId===e);if(n===void 0)return null;let r=t[e];return r!==void 0&&r!==``?r:n.defaultModelId}var cDe=24,bH=[{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 xH(e,t){return`clusterStepSetting:${e}:${t}`}function lDe(e){return bH.filter(t=>t.stepId===e)}var uDe=n().finite();function SH(e){let t={};for(let n of bH){let r=uDe.safeParse(e[xH(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 CH=SH({});function dDe(e){return e===null?CH:SH(yH(e,new Set(bH.map(e=>xH(e.stepId,e.key)))))}function fDe(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 wH=S([`new`,`entered`,`left`,`moving`,`idle`]),TH=S([`motion`,`object`,`audio`]),EH=i(`kind`,[iH,aH]),DH=S([`motion`,`audio`,`person`,`vehicle`,`animal`,`door`,`pir`,`smoke`,`water`,`button`,`package`,`generic`]),OH=S([`motion`,`audio`,`detection`,`sensor`,`control`,`custom`,`package`]),pDe=S([`macro`,`sub`]),kH=x({kind:l(),labelKey:l(),label:l(),color:l(),iconId:l(),icon:DH,category:OH,parentKind:l().nullable(),level:pDe,source:x({capName:l(),deviceId:n()})}),AH=x({deviceId:n(),kinds:C(kH).readonly()}),jH=x({id:l(),deviceId:n(),sourceDeviceId:n(),kind:l(),value:m(l(),w()).nullable(),timestamp:n()}),MH=x({x:n(),y:n(),timestamp:n(),bbox:sC,source:S([`frame`,`recovery`]).optional(),score:n().optional()}),mDe=x({timestamp:n(),position:MH,mediaId:n().int()}),NH=x({minX:n(),minY:n(),maxX:n(),maxY:n()}),PH=S([`full`,`slim`]),FH=x({label:l(),peakScore:n(),count:n(),firstAt:n(),lastAt:n()}),IH=S([`pipeline`,`onboard`,`sensor`,`audio`]),LH=S([`none`,`staging`,`trained`]),hDe=500,RH={markForTrain:y().optional(),debug:y().optional(),debugNote:l().max(500).optional(),favourited:y().optional()},zH={retrainStatus:LH.optional()},BH=x(RH),VH=x({trackId:l(),markForTrain:y(),debug:y(),debugNote:l(),favourited:y(),retrainStatus:LH}),gDe=h([p(1),p(2)]),HH=x({stepId:l(),modelId:l().optional(),decidedAt:n(),identityId:l().optional()}),UH={label:l().optional(),labelScore:n().optional(),labelMeta:HH.optional(),subLabel:l().optional(),subLabelScore:n().optional(),subLabelMeta:HH.optional()},WH=x({deviceId:n(),tracks:n().int(),files:n().int(),bytes:n().int()}),GH=x({generatedAt:n(),trackCount:n().int(),fileCount:n().int(),byteCount:n().int(),truncated:y(),devices:C(WH).readonly()}),KH=x({nodeId:l(),deviceKey:l().optional(),modelId:l().optional()}),qH=x({trackId:l(),deviceId:n(),className:l(),...UH,producingDeviceName:l().optional(),source:IH.optional(),firstSeen:n(),lastSeen:n(),positions:C(MH).readonly(),snapshots:C(mDe).readonly(),zonesVisited:C(l()).readonly(),zoneNames:C(l()).readonly().optional(),classes:C(l()).readonly().optional(),totalDistance:n(),state:wH,active:y(),importance:n().optional(),bestEventId:l().optional(),importanceReason:l().optional(),audioLabels:C(FH).readonly().optional(),envelope:NH.optional(),hasFace:y().optional(),hasEmbeddedFace:y().optional(),hasRider:y().optional(),previewMissReason:l().optional(),modelId:l().optional(),openedPlacement:KH.optional(),closedPlacement:KH.optional(),frameWidth:n().optional(),frameHeight:n().optional(),...RH,...zH}),JH={id:n().int(),deviceId:n(),timestamp:n()},YH=x({...JH,kind:p(`motion`),regionCount:n(),regions:C(x({bbox:sC,pixelCount:n(),intensity:n()})).readonly().optional(),frameWidth:n().optional(),frameHeight:n().optional(),mediaUrl:l().optional(),triggeredBy:RV.optional(),durationMs:n().nullable().optional(),edges:C(n()).readonly().optional()}),XH=S([`pipeline`,`onboard`]),ZH=S([`enter`,`exit`]),QH=x({direction:ZH,zoneId:l(),zoneName:l().optional()}),_De=x({zoneId:l(),zoneName:l().optional(),overlapPct:n()}),$H=x({...JH,kind:p(`object`),source:XH.optional(),frameId:l().optional(),idempotencyKey:l().optional(),trackId:l().optional(),className:l(),...UH,confidence:n().optional(),bbox:sC.optional(),zones:C(l()).readonly().optional(),zoneOverlaps:C(_De).readonly().optional(),spawnRefused:l().optional(),state:wH.optional(),zoneCrossing:QH.optional(),frameWidth:n().optional(),frameHeight:n().optional(),mediaId:n().int().optional(),keyFrameMediaId:n().int().optional(),mediaUrl:l().optional(),observedAt:n().optional(),packagePossible:y().optional(),packageLlmVerdict:nH.optional(),importance:n().optional()}),eU=x({...JH,kind:p(`audio`),rms:n(),dbfs:n(),classification:x({className:l(),originalClass:l().optional(),score:n()}).optional(),classifyOutcome:fC.optional(),mediaUrl:l().optional()}),tU=S([`crop`,`thumbnail`,`snapshot`,`firstFrame`,`lastFrame`,`fullFrame`,`fullFrameBoxed`,`faceCrop`,`plateCrop`,`keyFrame`,`keyFrameSmall`,`thumbnailSmall`,`confirmationCrop`,`debugCrop`,`sceneFrame`,`lastSceneFrame`]),nU=x({mediaId:n().int(),kind:tU,sizeBytes:n(),timestamp:n()}),rU=nU.extend({url:l(),base64:l()}),iU=rU.omit({base64:!0}),aU=S([`person`,`vehicle`,`animal`,`package`,`face`,`plate`]),oU=S([`subject`,`model_error`]),sU=S([`operator`,`assist`,`pipeline`,`llm`]),cU=x({x:n(),y:n(),w:n(),h:n()}),lU=x({source:sU,ref:l().min(1),bbox:cU,macroClass:aU,label:l().optional(),score:n().optional(),modelId:l().optional()}),uU=x({ref:l().min(1),snapshot:lU}),dU=S(Cp),fU=x({ref:l(),savedId:l().optional(),status:dU,approximate:y(),origin:lU.optional(),macroClass:aU.optional(),label:l().optional(),iou:n().optional()}),pU=x({boxes:C(fU).readonly(),summary:x({counts:m(dU,n().int()),total:n().int(),changed:n().int(),approximate:y()})}),mU=x({id:l(),trackId:l().optional(),deviceId:n(),mediaKey:l(),bbox:cU,macroClass:aU,label:l().optional(),subLabel:l().optional(),kind:oU,source:sU,assistModelId:l().optional(),assistScore:n().optional(),origin:lU.nullable().optional(),exportedInBatch:l().optional(),createdAt:n()}),hU=mU.omit({id:!0,trackId:!0,deviceId:!0,mediaKey:!0,createdAt:!0,exportedInBatch:!0}),gU=S([`correct`,`wrong`,`wrong-label`]),_U=x({verdict:gU,suggestedClass:l().optional(),suggestedMacroClass:aU.optional(),suggestedLabel:l().optional(),trackId:l(),at:n().optional()}),vU=x({trackId:l(),className:l(),label:l().optional(),bbox:cU.optional(),verdict:gU,suggestedClass:l().optional(),at:n().optional()}),yU=x({trackId:l(),deviceId:n(),className:l(),label:l().optional(),firstSeen:n(),lastSeen:n(),frameCount:n().int(),annotationCount:n().int(),verdict:_U.optional()}),bU=x({mediaId:n().int(),kind:tU,timestamp:n(),sizeBytes:n().int(),copied:y()}),xU=x({bbox:cU,macroClass:aU,label:l().optional(),subLabel:l().optional(),score:n().optional(),modelId:l().optional(),trackId:l(),basis:S([`subject-box`,`position`,`verdict`]),deltaMs:n()}),SU=S([`track`,`recording`]),CU=x({frameId:l(),deviceId:n(),origin:SU,trackId:l().optional(),sourceMediaId:n().int().optional(),epochMs:n().optional(),sourceKind:tU,sizeBytes:n().int(),width:n().int(),height:n().int(),copiedAt:n(),capturedAt:n().optional(),complete:y(),pipelineBoxes:C(xU).readonly().optional(),collectionIds:C(l()).readonly().optional(),verdict:_U.optional(),revision:n().int().optional(),dismissed:C(uU).readonly().optional(),review:pU.optional(),imageUrl:l().optional(),thumbnailUrl:l().optional()}),wU=S([`source-missing`,`unreadable-image`,`write-failed`]),TU=x({copied:C(CU).readonly(),refused:C(x({sourceMediaId:n().int(),reason:wU})).readonly()}),EU=x({candidates:C(bU).readonly(),copies:C(CU).readonly(),autoPickMediaId:n().int().optional()}),DU=S([`unannotated`,`annotated`,`complete`]),OU=x({workState:DU.optional(),deviceIds:C(n()).max(500).optional(),collectionId:l().optional(),classes:C(aU).optional(),page:n().int().positive().default(1),pageSize:n().int().positive().max(100).default(50)}),kU=CU.extend({workState:DU}),AU=x({frames:C(kU).readonly(),total:n().int().nonnegative(),page:n().int().positive(),pageSize:n().int().positive()}),jU=x({deviceId:n(),unannotated:n().int().nonnegative(),annotated:n().int().nonnegative(),complete:n().int().nonnegative(),pctOfCorpus:n().min(0).max(1).nullable()}),MU=x({total:n().int().nonnegative(),unannotated:n().int().nonnegative(),annotated:n().int().nonnegative(),complete:n().int().nonnegative(),cameras:C(jU).readonly()}),NU=x({deviceIds:C(n()).optional(),frameIds:C(l()).max(2e4).optional(),collectionIds:C(l()).max(200).optional(),collectionId:l().optional(),batchId:l().optional(),completeOnly:y().optional(),workState:DU.optional(),classes:C(aU).optional()}),PU=S([`frames`,`crops`]),FU=x({kind:p(`http`),method:S([`PUT`,`POST`]),url:l().url(),headers:m(l(),l()).optional()}),IU=x({batchId:l(),frames:n().int(),crops:n().int(),annotations:n().int(),missing:n().int(),bytes:n().int(),sha256:l(),status:n().int()}),LU=i(`kind`,[x({kind:p(`package`),zone:cU.optional()}),x({kind:p(`objects`),modelId:l(),minScore:n().optional()})]),RU=i(`kind`,[x({kind:p(`proposed`),modelId:l(),stepId:l(),minScore:n(),proposals:C(hU).readonly(),belowThreshold:n().int()}),x({kind:p(`refused`),reason:l(),detail:l().optional()})]),zU=x({id:l(),name:l(),createdAt:n(),frameCount:n().int()}),BU=i(`kind`,[x({kind:p(`created`),collection:zU}),x({kind:p(`refused`),reason:S([`empty-name`,`duplicate-name`])})]),VU=i(`kind`,[x({kind:p(`renamed`),collection:zU}),x({kind:p(`refused`),reason:S([`empty-name`,`duplicate-name`,`unknown-collection`])})]),HU=i(`kind`,[x({kind:p(`added`),collectionId:l(),frame:CU,reused:y()}),x({kind:p(`refused`),reason:S([`unknown-collection`,`still-unavailable`,`still-busy`,`unreadable-image`,`write-failed`]),detail:l().optional()})]),UU=x({id:l(),name:l(),model:l(),kind:l(),leavesHouse:y()}),WU=hU.extend({reason:l()}),GU=x({ref:l(),verdict:S([`confirmed`,`wrong-class`,`not-an-object`,`uncertain`]),suggestedClass:aU.optional(),reason:l()}),KU=i(`kind`,[x({kind:p(`proposed`),profileId:l(),model:l(),leftHouse:y(),proposals:C(WU).readonly(),reviews:C(GU).readonly(),rejected:n().int()}),x({kind:p(`refused`),reason:S([`unknown-frame`,`unreadable-frame`,`unknown-profile`,`profile-disabled`,`no-vision`,`cloud-not-confirmed`,`llm-error`,`malformed-answer`]),detail:l().optional()})]),qU=x({deviceIds:C(n()).readonly().optional(),collectionIds:C(l()).max(200).readonly().optional(),frameIds:C(l()).max(2e4).readonly().optional()}),JU=x({frames:n().int(),completeFrames:n().int(),completeness:n(),subjects:n().int(),modelErrors:n().int(),hardNegatives:n().int(),cells:C(x({macroClass:l(),deviceId:n(),lighting:S([`day`,`night`,`unknown`]),subjects:n().int(),frames:n().int()})).readonly(),cameras:C(x({deviceId:n(),frames:n().int(),completeFrames:n().int()})).readonly()}),vDe=x({id:l(),name:l(),createdAt:n(),selection:qU,layout:PU,completeOnly:y(),frameCount:n().int(),annotationHash:l(),manifestSchema:l(),stats:JU}),YU=x({collectionIds:C(l()).min(1),workState:S([`complete`,`annotated_or_complete`,`any_annotated`]).default(`complete`)}),XU=i(`kind`,[x({kind:p(`resolved`),frameIds:C(l()).max(2e4).readonly(),stats:JU,annotationHash:l(),layout:PU}),x({kind:p(`refused`),reason:S([`unknown-collection`,`no-frames`]),detail:l()})]),ZU=x({trackId:l(),retrainStatus:LH,changed:y(),reason:S([`unknown-track`,`no-frames-copied`,`not-staging`,`not-trained`,`unchanged`]).optional()}),QU=1e3,$U=5e3,eW=x({deviceId:n(),since:n().optional(),until:n().optional(),limit:n().int().min(1).max($U).default(QU),projection:S([`full`,`slim`]).optional()}),yDe=eW.extend({classFilter:l().optional()}),tW=x({deviceIds:C(n()),since:n().optional(),until:n().optional(),limit:n().int().min(1).max(1e3).default(200),cursor:l().optional(),projection:PH.optional(),includeStationary:y().optional(),classes:C(l()).optional(),excludeSources:C(IH).optional()}),nW=x({tracks:C(qH).readonly(),nextCursor:l().nullable()}),rW=50,iW=200,bDe=x({deviceId:n(),since:n(),until:n(),limit:n().int().min(1).max(iW).default(rW),minImportance:n().min(0).max(1).optional(),classFilter:l().optional()}),aW=x({id:l(),trackId:l(),timestamp:n(),className:l(),...UH,importance:n(),bestEventId:l(),windowMs:n().optional(),audioLabels:C(FH).readonly().optional(),...RH,...zH}),xDe=x({deviceIds:C(n()).min(1).max(200),since:n(),until:n(),limit:n().int().min(1).max(iW).default(rW),minImportance:n().min(0).max(1).optional(),classFilter:l().optional()}),SDe=x({deviceId:n(),events:C(aW).readonly()}),oW=x({bucketStart:n(),motion:n().int(),object:n().int(),audio:n().int(),audioDbfs:n().optional()}),CDe=200,sW=x({deviceId:n(),read:S([`read`,`unreadable`]),buckets:C(oW).readonly()}),wDe=x({trackId:l(),className:l(),confidence:n(),bbox:sC,zones:C(l()).readonly(),state:wH}),TDe=se({id:l(),kind:S([`first-level`,`detail`]),macroClass:l(),score:n(),bbox:x({x:n(),y:n(),width:n(),height:n()}),labels:C(se({label:l(),score:n()})).readonly(),parentId:l().optional()}),cW=$H.extend({score:n()}),EDe=x({text:l(),deviceId:n().optional(),since:n().optional(),until:n().optional(),classFilter:l().optional(),limit:n().default(50),minScore:n().min(0).max(1).optional(),strictness:Sde.optional(),modelId:l().min(1).optional()}),lW=x({tracks:n().int(),events:n().int(),media:n().int(),faces:n().int(),plates:n().int(),embeddings:n().int()}),DDe=x({mediaDropped:n().int(),tracks:n().int(),events:n().int()}),ODe=x({deviceId:n(),rows:n().int(),bytes:n().int()}),kDe=x({totalRows:n().int(),totalBytes:n().int(),devices:C(ODe).readonly()}),ADe=x({kind:tU,rows:n().int(),bytes:n().int()}),jDe=x({totalRows:n().int(),totalBytes:n().int(),kinds:C(ADe).readonly(),unaccountedRows:n().int(),unaccountedBytes:n().int()}),uW=x({motion:n().int(),object:n().int(),audio:n().int()}),MDe=x({deviceId:n().optional(),since:n().optional(),until:n().optional(),maxTracks:n().int().positive().optional(),executeOnNodeId:l().optional(),pacingMs:n().int().nonnegative().optional(),force:y().optional()}),NDe=x({deleted:n(),failedIndexes:C(l()).optional()}),dW=S([`stores-unavailable`,...dH,`method-unavailable`,`read-failed`,`reads-disagree`,`not-a-clip-model`,`force-requires-max-tracks`]),PDe=x({started:y(),alreadyRunning:y(),refusal:dW.optional(),modelId:l().optional(),index:l().optional()}),FDe=x({running:y(),scanned:n(),rebuilt:n(),missingKeyFrame:n(),missingEvent:n(),missingBbox:n(),boxSource:x({subjectBox:n(),positions:n(),event:n(),refused:n()}),alreadyInSpace:n(),force:y().nullable(),forcedInSpace:n(),notRunnable:n(),noCapableNode:n(),failed:n(),complete:y().nullable(),startedAtMs:n().nullable(),finishedAtMs:n().nullable(),error:l().nullable(),modelId:l().nullable(),index:l().nullable()}),IDe=x({started:y(),alreadyRunning:y()}),LDe=x({mode:S([`report`,`reclaim`]).default(`report`),scopes:C(S([`motion-still`,`track-filmstrip`])).min(1).optional(),deviceIds:C(n().int()).min(1).optional(),restart:y().optional(),pageSize:n().int().min(50).max(5e3).optional(),maxRowsPerDevice:n().int().min(1).max(5e5).optional(),maxReclaimPerDevice:n().int().min(1).max(5e5).optional(),maxBytesPerRun:n().int().min(1).optional(),budgetMinutes:n().int().min(1).max(720).optional(),throttleBytesPerSec:n().int().min(64*1024).optional(),graceMinutes:n().int().min(1).max(10080).optional()}),RDe=x({running:y(),mode:S([`report`,`reclaim`]).nullable(),totalExamined:n(),totalEligible:n(),totalReclaimed:n(),totalBytesReclaimed:n(),totalRefused:n(),devicesDone:n(),complete:y().nullable(),startedAtMs:n().nullable(),finishedAtMs:n().nullable(),error:l().nullable()}),fW=S([`motion`,`audio-dbfs`,`battery`,`occupancy`]),zDe=`|`;function BDe(e,t){let n=e??``;return t===void 0?n:`${n}|${t}`}function VDe(e){let t=e.indexOf(`|`);return t<0?{zoneId:e}:{zoneId:e.slice(0,t),className:e.slice(t+1)}}var pW=x({scope:l(),bucketStart:n().int(),samples:n().int().nonnegative(),sum:n(),min:n(),max:n()}),mW={name:`pipeline-analytics`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[E.Camera],exposesDeviceSettings:!0,methods:{getActiveTracks:A(x({deviceId:n()}),C(qH).readonly()),getTrack:A(x({deviceId:n(),trackId:l()}),qH.nullable()),listTracks:A(x({deviceId:n(),since:n().optional(),until:n().optional(),limit:n().optional(),zone:EH.optional(),projection:PH.optional(),includeStationary:y().optional(),classes:C(l()).optional(),excludeSources:C(IH).optional()}),C(qH).readonly()),listRecentTracks:A(tW,nW),clearTracks:A(x({deviceId:n()}),v(),{kind:`mutation`,auth:`admin`}),getMotionEvents:A(eW,C(YH).readonly()),getObjectEvents:A(yDe,C($H).readonly()),getAudioEvents:A(eW,C(eU).readonly()),listEventKinds:A(x({deviceId:n()}),C(kH).readonly()),listEventKindsBatch:A(x({deviceIds:C(n()).min(1).max(200)}),C(AH).readonly()),getSensorEvents:A(x({deviceId:n(),since:n().optional(),until:n().optional(),kinds:C(l()).optional(),limit:n().int().min(1).max($U).default(QU)}),C(jH).readonly()),getKeyEvents:A(bDe,C(aW).readonly()),getKeyEventsBatch:A(xDe,C(SDe).readonly()),readLongTermSeries:A(x({deviceId:n(),series:fW,scope:l().optional(),from:n(),to:n(),limit:n().int().positive().optional()}),C(pW).readonly()),getEventDensity:A(x({deviceId:n(),since:n(),until:n(),bucketMs:n().int().positive()}),C(oW).readonly()),getEventDensityBatch:A(x({deviceIds:C(n()).min(1).max(200),since:n(),until:n(),bucketMs:n().int().positive()}),C(sW).readonly()),pruneEventsBefore:A(x({deviceId:n(),cutoffMs:n()}),x({motion:n().int(),object:n().int(),audio:n().int()}),{kind:`mutation`,auth:`admin`}),pruneTracksBefore:A(x({deviceId:n(),cutoffMs:n()}),lW,{kind:`mutation`,auth:`admin`}),wipeAllAnalytics:A(x({deviceId:n()}),lW,{kind:`mutation`,auth:`admin`}),reconcileFromDisk:A(x({deviceId:n()}),DDe,{kind:`mutation`,auth:`admin`}),deleteTracks:A(x({deviceId:n(),trackIds:C(l()).min(1)}),x({deleted:n().int(),failed:C(l()).readonly(),sparedMediaIds:C(n().int()).readonly().optional()}),{kind:`mutation`,auth:`admin`}),setTrackFlags:A(x({deviceId:n(),trackId:l(),flags:BH}),VH,{kind:`mutation`,notOperatorFacing:`curating a recorded track in the review UI, not a live step`}),listArchivedDebugNotes:A(Pp,C(Np).readonly(),{kind:`query`}),setTrackRelation:A(Bp,Rp,{kind:`mutation`,notOperatorFacing:`curating recorded tracks in the review UI, not a live step`}),clearTrackRelation:A(Vp,Hp,{kind:`mutation`,notOperatorFacing:`curating recorded tracks in the review UI, not a live step`}),setTrackPurity:A(Up,Wp,{kind:`mutation`,notOperatorFacing:`curating a recorded track in the review UI, not a live step`}),listTrackRelations:A(Gp,Kp,{kind:`query`}),listBirthDecisions:A(Mp,C(jp).readonly(),{kind:`query`}),getEventStoreFootprint:A(x({}),kDe,{kind:`query`,auth:`admin`}),getEventMediaFootprintByKind:A(x({deviceId:n().int().optional()}),jDe,{kind:`query`,auth:`admin`}),pruneEvents:A(x({olderThanMs:n(),reason:em.optional()}),uW,{kind:`mutation`,auth:`admin`}),deleteDeviceEvents:A(x({deviceId:n()}),uW,{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:A(km,x({paused:p(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:A(km,x({resumed:p(!0)}),{kind:`mutation`,auth:`admin`}),refreshStorageLocationsForMigration:A(km,x({refreshed:p(!0)}),{kind:`mutation`,auth:`admin`}),startStorageMigrationMove:A(Rm,x({jobId:l()}),{kind:`mutation`,auth:`admin`}),getStorageMigrationMoveStatus:A(x({jobId:l()}),Em.nullable(),{auth:`admin`}),cancelStorageMigrationMove:A(x({jobId:l()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),relocateMedia:A(Mm,x({jobId:l()}),{kind:`mutation`,auth:`admin`}),countUnstampedEventMedia:A(x({}),Pm,{auth:`admin`}),getMediaLocationCensus:A(Fm,Lm,{kind:`query`,auth:`admin`}),countRelocatableMedia:A(uh,lh,{kind:`query`,auth:`admin`}),listRelocateMediaJobs:A(x({}),C(Em).readonly(),{kind:`query`,auth:`admin`}),cancelRelocateMedia:A(x({jobId:l()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),listOpsLog:A(nm,C(tm).readonly(),{kind:`query`,auth:`admin`}),reclaimDebugMedia:A(LDe,IDe,{kind:`mutation`,auth:`admin`}),getMediaReclaimStatus:A(x({}),RDe,{kind:`query`,auth:`admin`}),getTrainingExportSummary:A(x({deviceIds:C(n()).optional()}),GH,{kind:`query`,auth:`admin`}),getTrainingExportUrl:A(x({deviceIds:C(n()).optional()}),x({url:l()}),{kind:`query`,auth:`admin`}),listRetrainStaging:A(x({deviceIds:C(n()).optional(),limit:n().int().min(1).max(500).optional()}),C(yU).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),listRetrainCorpusPage:A(OU,AU,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),getRetrainCorpusKpi:A(x({}),MU,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),listRetrainFrames:A(x({trackId:l()}),EU,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),selectRetrainFrames:A(x({deviceId:n(),trackId:l(),mediaIds:C(n().int()).min(1)}),TU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),deselectRetrainFrame:A(x({deviceId:n(),trackId:l().optional(),frameId:l()}),x({removed:y(),removedAnnotations:n().int()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),getRetrainFrameImage:A(x({frameId:l()}),x({base64:l(),width:n().int(),height:n().int()}),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),proposeRetrainAnnotations:A(x({deviceId:n(),trackId:l().optional(),frameId:l(),subject:LU,nodeId:l().optional()}),RU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainAnnotations:A(x({trackId:l().optional(),frameIds:C(l()).max(2e3).optional()}),C(mU).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),saveRetrainAnnotations:A(x({deviceId:n(),trackId:l().optional(),frameId:l(),annotations:C(hU),expectedRevision:n().int().optional(),dismissed:C(uU).optional()}),C(mU).readonly(),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),backfillRetrainOrigins:A(x({deviceId:n(),trackId:l().optional(),frameId:l(),expectedRevision:n().int().optional(),origins:C(x({annotationId:l(),origin:lU})).min(1).max(500)}),x({updated:n().int(),skipped:n().int(),revision:n().int()}),{kind:`mutation`,auth:`admin`}),completeRetrainTrack:A(x({deviceId:n(),trackId:l()}),ZU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),restageRetrainTrack:A(x({deviceId:n(),trackId:l()}),ZU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),getRetrainExportUrl:A(NU.extend({layout:PU.optional()}),x({url:l()}),{kind:`query`,auth:`admin`}),setRetrainFrameComplete:A(x({deviceId:n(),trackId:l().optional(),frameId:l(),complete:y()}),CU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),writeRetrainArchive:A(x({filter:NU,layout:PU,target:FU}),IU,{kind:`mutation`,auth:`admin`,timeoutMs:60*6e4}),offerRetrainArchive:A(x({filter:NU,layout:PU}),x({ticket:Si,frames:n().int(),annotations:n().int()}),{kind:`mutation`,auth:`admin`,timeoutMs:12e4}),listRetrainAssistProfiles:A(x({}),C(UU).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),proposeRetrainAnnotationsWithLlm:A(x({deviceId:n(),trackId:l().optional(),frameId:l(),profileId:l(),classes:C(aU).min(1),boxes:C(x({ref:l(),bbox:cU,macroClass:aU,label:l().optional()})).max(50),allowCloud:y()}),KU,{kind:`mutation`,auth:`admin`,timeoutMs:18e4}),createRetrainCollection:A(x({name:l().max(120)}),BU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainCollections:A(x({}),C(zU).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),resolveRetrainTrainingCorpus:A(YU,XU,{kind:`query`,auth:`admin`,timeoutMs:6e4}),renameRetrainCollection:A(x({id:l(),name:l().max(120)}),VU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),deleteRetrainCollection:A(x({id:l()}),x({deleted:y(),removedFrames:n().int()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),addRetrainFrameFromRecording:A(x({collectionId:l(),deviceId:n(),epochMs:n(),verdictSubject:vU.optional()}),HU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`,timeoutMs:6e4}),addRetrainFramesToCollection:A(x({collectionId:l(),frameIds:C(l()).min(1).max(500)}),x({added:n().int(),alreadyMember:n().int(),unknownFrameIds:C(l()).readonly()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),removeRetrainFrameFromCollection:A(x({collectionId:l(),frameId:l()}),x({removed:y(),deletedFrame:y()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainCollectionFrames:A(x({collectionId:l()}),C(CU).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),getEventMedia:A(x({ownerType:Du,eventId:n().int(),kind:tU.optional(),deviceId:n()}),C(rU).readonly()),getTrackMedia:A(x({trackId:l(),kinds:C(tU).optional(),deviceId:n()}),C(rU).readonly()),listTrackMedia:A(x({trackId:l(),deviceId:n()}),C(iU).readonly()),listEventMedia:A(x({ownerType:Du,eventId:n().int(),deviceId:n()}),C(iU).readonly()),ownersWithMedia:A(x({deviceId:n(),ownerKind:ku,ownerIds:C(l()).max(5e3)}),C(l()).readonly()),searchObjectEvents:A(EDe,C(cW).readonly(),{caller:`required`}),wipeObjectEmbeddings:A(x({}),NDe,{kind:`mutation`,auth:`admin`}),rebuildObjectEmbeddings:A(MDe,PDe,{kind:`mutation`,auth:`admin`}),getObjectEmbeddingRebuildStatus:A(x({}),FDe)},events:{onFrameTracked:{data:x({deviceId:n(),timestamp:n(),frameWidth:n(),frameHeight:n(),detections:C(TDe).readonly()}),notOperatorFacing:`one tracker frame — stream rate, never an automation trigger`},onTrackStarted:{data:x({deviceId:n(),trackId:l(),className:l()}),trigger:{category:T.PipelineAnalyticsTrackStarted,label:F(`Subject appeared`,`Soggetto comparso`),phrase:F(`When {device} starts following a subject`,`Quando {device} inizia a seguire un soggetto`),icon:`scan-eye`}},onTrackEnded:{data:x({deviceId:n(),trackId:l(),className:l(),durationMs:n()}),trigger:{category:T.PipelineAnalyticsTrackEnded,label:F(`Subject left`,`Soggetto uscito`),phrase:F(`When a subject leaves the view of {device}`,`Quando un soggetto esce dall’inquadratura di {device}`),icon:`scan-eye`}},onDetectionEvent:{data:x({deviceId:n(),kind:TH,eventId:l(),timestamp:n()}),trigger:{category:T.PipelineAnalyticsDetectionEvent,label:F(`Detection event`,`Evento di rilevamento`),phrase:F(`When {device} records a detection event`,`Quando {device} registra un evento di rilevamento`),icon:`radar`}}},vocabulary:{noun:F(`Tracking`,`Tracciamento`),order:3200,extraEvents:[{category:T.PipelineAnalyticsPackageDelivered,label:F(`Package delivered`,`Pacco consegnato`),phrase:F(`When a package is left in front of {device}`,`Quando viene lasciato un pacco davanti a {device}`),icon:`package`},{category:T.PipelineAnalyticsPackagePickedUp,label:F(`Package picked up`,`Pacco ritirato`),phrase:F(`When a package is picked up in front of {device}`,`Quando viene ritirato un pacco davanti a {device}`),icon:`package-open`}]}},hW=x({x:n(),y:n(),w:n(),h:n()}),gW=x({stepId:l(),modelId:l(),detections:C(x({bbox:u([n(),n(),n(),n()]),score:n(),landmarks:C(x({x:n(),y:n()})).optional()})).min(1)}),_W=x({handle:xa,cropFrameSpace:x({x:n(),y:n(),w:n(),h:n()})});x({crop:x({left:n(),top:n(),width:n().positive(),height:n().positive()}).optional(),content:x({width:n().int().positive(),height:n().int().positive()}),fit:S([`stretch`,`contain`]),format:S([`rgb`,`gray`,`jpeg`])});var HDe=x({registryId:l().min(1),id:l().min(1),width:n().int().positive(),height:n().int().positive(),format:S([`rgb`,`gray`]),timestamp:n(),capturedAt:n().optional()}),vW=S([`onnx`,`coreml`,`openvino`,`tflite`,`pt`,`gguf`]),yW=S([`detector`,`cropper`,`classifier`,`refiner`,`audio-classifier`]),bW=x({runtime:p(`python`),backend:l(),format:vW,device:l().optional()}),xW=x({deviceKey:l().nullable(),runtime:l(),batchMode:l(),windowMs:n(),maxBatchSize:n(),concurrency:n(),numWorkers:n()}),UDe=x({engine:bW,devices:C(x({id:l(),label:l(),description:l().optional()})).readonly(),defaultDevice:l()}),SW=a(()=>x({addonId:l(),addonName:l(),slot:yW,inputClasses:C(l()).readonly(),outputClasses:C(l()).readonly(),enabled:y(),modelId:l(),children:C(SW).readonly(),group:l().optional(),settings:m(l(),w()).optional()})),WDe=x({id:l(),name:l(),formats:m(l(),$de),group:eg.optional(),legacy:y().optional(),provider:tg.optional(),defaultConfidence:n().optional(),suppliesSteps:C(ng).readonly().optional()}),GDe=ve(),KDe=x({id:l(),name:l(),slot:yW,inputClasses:C(l()).readonly(),outputClasses:C(l()).readonly(),childSlots:C(yW).readonly(),models:C(WDe).readonly(),defaultModelId:l(),defaultModelIdByFormat:m(l(),l()).optional(),enabledByDefault:y().optional(),defaultConfidence:n(),group:l().optional(),configSchema:C(GDe).readonly().optional()}),qDe=x({id:yW,label:l(),priority:n(),parentSlot:yW.nullable(),addons:C(KDe).readonly()}),JDe=x({availableEngines:C(UDe).readonly(),selectedEngine:bW,slots:C(qDe).readonly()}),YDe=x({runtimeId:S([`onnx`,`openvino`,`coreml`,`edgetpu`]).nullable(),device:l().nullable(),state:S([`idle`,`installing`,`verifying`,`ready`,`failed`]),progress:n().optional(),error:l().optional(),nextRetryAt:n().optional(),configIssues:C(l()).optional()}),CW=x({addonId:l(),chosen:l(),running:l(),format:l()}),wW=x({addonId:l(),kind:S([`unknown-addon`,`no-format-build`,`unknown-device`]),detail:l()}),TW=x({ok:y(),issues:C(wW).readonly(),substitutions:C(CW).readonly(),format:l()}),XDe=x({filename:l(),stepIds:C(l()).readonly().optional()}),ZDe=x({base64:l(),filename:l()}),QDe=x({filename:l(),sizeKb:n()}),$De=x({base64:l()}),eOe=x({id:l(),name:l(),description:l(),available:y(),rawLabels:C(l()).readonly().optional()}),tOe=x({activeBackend:l(),availableBackends:C(eOe).readonly(),sampleRate:n(),chunkDurationMs:n()}),nOe=x({filePath:l(),sizeMB:n(),durationMs:n()}),rOe=x({success:y(),error:l().optional(),frame:ve().optional()}),iOe=ve(),aOe=ve(),oOe=ve(),sOe=ve(),EW={name:`pipeline-executor`,scope:`system`,mode:`singleton`,methods:{getAvailableEngines:A(v(),C(bW)),getSelectedEngine:A(v(),bW),getEngineProvisioning:A(x({nodeId:l()}),YDe),getVideoPipelineSteps:A(v(),m(l(),x({modelId:l(),settings:m(l(),w()).readonly()}))),setVideoPipelineSteps:A(x({steps:m(l(),x({modelId:l(),settings:m(l(),w()).readonly()}))}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getInferenceDeviceHealth:A(x({nodeId:l()}),x({unhealthy:C(x({deviceKey:l(),state:S([`failed`,`backoff`]),since:n(),deaths:n(),lastError:l(),absentReason:S([`no-gpu-device`]).optional()})).readonly()})),rearmInferenceDevice:A(x({nodeId:l(),deviceKey:l()}),x({rearmed:y()}),{kind:`mutation`,auth:`admin`}),getSchema:A(v(),JDe),getOrchestratorConfigSchema:A(v(),iOe),validatePipeline:A(x({steps:C(Va),deviceKey:l().optional()}),TW),getCapabilities:A(v(),oOe),getAddonModels:A(x({addonId:l()}),sOe),downloadModel:A(x({addonId:l(),modelId:l(),format:vW}),nOe,{kind:`mutation`}),deleteModel:A(x({addonId:l(),modelId:l(),format:vW}),x({success:p(!0)}),{kind:`mutation`}),runPipeline:A(x({steps:C(Va).min(1),frame:oC.optional(),frameRef:HDe.optional(),frameHandle:xa.optional(),imageBase64:l().optional(),image:b(Uint8Array).optional(),referenceImage:l().optional(),deviceId:n().optional(),sessionId:l().optional(),plane:S([`full`,`frame`]).optional(),deviceKey:l().optional(),nativeCropRef:_W.optional(),replay:p(!0).optional(),suppliedRoot:gW.optional(),motionRegions:C(hW).optional()}),Ha,{kind:`mutation`}),runPipelineBatch:A(x({steps:C(Va).min(1),frames:C(oC).min(1).max(255),deviceId:n().optional(),sessionId:l().optional(),frameId:n().int().nonnegative().optional(),deviceKey:l().optional()}),x({results:C(Ha).readonly()}),{kind:`mutation`}),cacheFrameInPool:A(x({data:b(Uint8Array),width:n().int().positive(),height:n().int().positive(),format:S([`rgb`,`bgr`,`gray`])}),x({frameId:n(),width:n(),height:n()}),{kind:`mutation`}),inferCached:A(x({stepId:l(),frameId:n().int(),modelId:l().min(1)}),m(l(),w()),{kind:`mutation`}),uncacheFrame:A(x({frameId:n().int()}),v(),{kind:`mutation`}),getEffectiveTuning:A(x({deviceKey:l().optional()}),xW),listLoadedEngines:A(v(),C(x({engineKey:l(),engine:bW,modelsLoaded:C(l()).readonly(),inUseByCameras:C(n()).readonly(),kind:S([`runtime`,`device-pool`]),poolPid:n().nullable(),idleMs:n().nullable(),idleTtlMs:n().nullable()})).readonly()),spinEngine:A(x({engine:bW}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),killEngine:A(x({engine:bW,force:y().optional()}),x({success:y(),reason:l().optional()}),{kind:`mutation`,auth:`admin`}),listReferenceImages:A(v(),C(XDe).readonly()),getReferenceImage:A(x({filename:l()}),ZDe.nullable()),getReferenceAudioFiles:A(v(),C(QDe).readonly()),getReferenceAudio:A(x({filename:l()}),$De.nullable()),getAudioCapabilities:A(v(),tOe),runAudioTest:A(x({addonId:l(),modelId:l(),filename:l().optional(),settings:m(l(),w()).optional()}),rOe,{kind:`mutation`}),getDetectionConfigSchema:A(v(),aOe)},vocabulary:{notOperatorFacing:M.PIPELINE}},cOe=x({activeCameras:n(),throttledCameras:n(),avgInferenceTimeMs:n(),queueDepth:n()}),DW=x({detectionMode:S([`disabled`,`always-on`,`on-motion`]),configuredFps:n(),actualFps:n(),queueDepth:n(),avgInferenceTimeMs:n(),droppedFrames:n(),nativeCropMisses:n().optional(),phase:S([`idle`,`watching`,`active`])}),OW=DW.extend({deviceId:n()}),kW=S([`polygon`,`tripwire`]),AW=x({x:n(),y:n()}),jW=x({id:l(),name:l(),kind:kW.default(`polygon`),polygon:C(AW).readonly(),color:l().default(`#3b82f6`)}),MW={name:`zones`,scope:`device`,mode:`singleton`,deviceTypes:[E.Camera],methods:{listZones:A(x({deviceId:n()}),C(jW).readonly()),addZone:A(x({deviceId:n(),zone:jW}),v(),{kind:`mutation`,auth:`admin`}),removeZone:A(x({deviceId:n(),zoneId:l()}),v(),{kind:`mutation`,auth:`admin`}),updateZone:A(x({deviceId:n(),zone:jW}),v(),{kind:`mutation`,auth:`admin`})},runtimeState:x({zones:C(jW).readonly()}),durability:`restored`,history:`none`,vocabulary:{noun:F(`Zones`,`Zone`),order:3370}},NW={fpsPerStream:10,budgetMinutes:45,minBudgetMinutes:10,maxBudgetMinutes:120,staleAfterDays:30,settleSec:5,measureSec:20,drainTimeoutSec:120,maxModelsPerDevice:6},PW=S([`device`,`pipeline`]),FW=x({deviceKey:l().min(1),modelIds:C(l().min(1)).min(1).max(NW.maxModelsPerDevice)}),IW=x({nodeId:l().min(1),devices:C(FW).min(1),phases:C(PW).min(1).default([`device`,`pipeline`]),steps:C(l().min(1)).default([]),fpsPerStream:n().int().min(1).max(30).default(NW.fpsPerStream),budgetMinutes:n().int().min(NW.minBudgetMinutes).max(NW.maxBudgetMinutes).default(NW.budgetMinutes),keepDownloadedModels:y().default(!1),acceptInsufficientHeadroom:y().default(!1)}),LW=S([`benchmark-active`,`node-offline`,`unknown-device`,`no-phase`,`insufficient-headroom`]),RW=x({kind:LW,detail:l(),overridable:y()}),zW=x({deviceId:n(),placedOnNode:y(),pinnedToNode:y()}),BW=x({deviceId:n(),reason:p(`only-frame-source`)}),VW=x({nodeId:l(),online:y(),moving:C(zW).readonly(),staying:C(BW).readonly(),estimatedDurationMs:n(),budgetMs:n(),phases:C(PW).readonly(),steps:C(l()).readonly(),devices:C(FW).readonly(),headroom:x({sessionsNow:n(),otherNodesCapacitySessions:n().nullable()}),refusals:C(RW).readonly(),canStart:y()}),HW=x({phase:S([`preparing`,`device`,`pipeline`,`cleanup`]),deviceKey:l().nullable(),modelId:l().nullable(),load:n().nullable(),cellsDone:n(),cellsTotal:n(),message:l()}),UW=S([`p95`,`drops`,`errors`,`stall`,`cpu`,`ram`,`none`]),WW=x({load:n(),pass:y(),p95Ms:n(),dropRatio:n(),fps:n(),cpuPct:n().nullable(),ramFreePct:n().nullable(),failReasons:C(l()).readonly()}),GW=x({phase:p(`device`),deviceKey:l(),modelId:l(),p50Ms:n(),p95Ms:n(),p99Ms:n(),fps:n(),kMax:n(),limitedBy:UW,warmupMs:n(),ramp:C(WW).readonly()}),KW=x({phase:p(`pipeline`),deviceKey:l(),modelId:l(),steps:C(l()).readonly(),maxSessions:n(),limitedBy:UW,stepsFired:C(l()).readonly(),warmupMs:n(),ramp:C(WW).readonly()}),qW=i(`phase`,[GW,KW]),JW=x({pipelineVersion:l().nullable(),cpuModel:l().nullable(),ramGb:n().nullable(),os:l().nullable(),pools:m(l(),x({runtime:l(),numWorkers:n(),concurrency:n(),batchMode:l()})).default({})}),YW=x({id:l(),revision:l().nullable(),frames:n(),width:n(),height:n()}),XW=x({runId:l().min(1),devices:C(FW).min(1),phases:C(PW).min(1),steps:C(l()).default([]),fpsPerStream:n().int().min(1).max(30),deadlineAtMs:n(),settleSec:n().min(0).max(60).default(NW.settleSec),measureSec:n().min(2).max(300).default(NW.measureSec),keepDownloadedModels:y().default(!1)}),ZW=S([`running`,`done`,`failed`,`aborted`]),QW=x({runId:l(),nodeId:l(),state:ZW,progress:HW.nullable(),cells:C(qW).readonly(),fingerprint:JW.nullable(),clip:YW.nullable(),activeCameraIds:C(n()).readonly(),deletedModels:C(l()).readonly(),error:l().nullable(),startedAtMs:n(),finishedAtMs:n().nullable()}),$W=S([`draining`,`measuring`,`restoring`,`done`,`failed`,`aborted`]),eG=S([`completed`,`operator-abort`,`deadline`,`node-lost`,`runner-lost`,`hub-restart`,`drain-timeout`,`failed`]),tG=x({runId:l(),nodeId:l(),state:$W,plan:IW,startedAtMs:n(),deadlineAtMs:n(),finishedAtMs:n().nullable(),endReason:eG.nullable(),error:l().nullable(),moved:C(n()).readonly(),staying:C(n()).readonly(),contaminated:y(),progress:HW.nullable(),resultIds:C(l()).readonly()}),nG=x({modeNodeId:l().nullable(),run:tG.nullable()}),rG=x({id:l(),runId:l(),nodeId:l(),cell:qW,fpsPerStream:n(),fingerprint:JW.nullable(),clip:YW.nullable(),contaminated:y(),stayingCameras:C(n()).readonly(),partialRun:y(),measuredAtMs:n()}),iG=x({nodeId:l().optional(),deviceKey:l().optional()}),aG=rG.extend({standing:S([`fresh`,`stale`,`superseded`]),staleWhy:S([`age`,`runtime`,`pool-tuning`]).nullable()}),lOe=x({runId:l(),nodeId:l(),startedAtMs:n(),deadlineAtMs:n(),plan:IW,moved:C(n()).readonly(),staying:C(n()).readonly()}),oG=x({nodeId:l(),reachable:y(),devices:C(x({deviceKey:l(),enabled:y(),available:y(),suggested:C(l()).readonly(),all:C(l()).readonly(),currentModelId:l().nullable()})).readonly(),steps:C(x({id:l(),name:l(),slot:l()})).readonly()}),sG=x({x:n(),y:n(),w:n(),h:n()}),cG=x({bytes:b(Uint8Array).optional(),jpeg:l().optional(),jpegBytes:b(Uint8Array).optional(),width:n().int().positive(),height:n().int().positive(),tier:S([`native`,`ram-fullframe`]).optional()}),lG=S([`keyFrame`,`thumbnail`]),uG=S([`handle-gone`,`encode-failed`]),dG=i(`parked`,[x({parked:p(!0),nodeId:l(),width:n().int().positive(),height:n().int().positive(),bytes:n().int().nonnegative(),replaced:y()}),x({parked:p(!1),nodeId:l(),reason:uG,handleAgeMs:n().nullable(),detail:l().optional()})]),fG=x({jpeg:l().optional(),jpegBytes:b(Uint8Array).optional(),width:n().int().positive(),height:n().int().positive(),timestamp:n(),parkedAt:n()}),uOe=x({bbox:sG,className:l()}),pG=x({stepId:l(),className:l(),score:n(),bbox:sG.optional(),embedding:l().optional(),embeddingMagnitude:n().optional(),embeddingModelId:l().optional(),label:l().optional(),labelTier:h([p(1),p(2)]).optional(),labelModelId:l().optional(),alignedCropJpeg:l().optional(),nativeFaceShortSidePx:n().optional(),landmarks:C(x({x:n(),y:n()})).optional()}),dOe=S([`unknown-step`,`model-not-servable`,`unreadable-frame`,`execution-failed`,`no-eligible-device`]),fOe=i(`kind`,[x({kind:p(`ran`),nodeId:l(),modelId:l(),details:C(pG)}),x({kind:p(`refused`),nodeId:l(),reason:dOe,detail:l()})]),mG={min:0,max:6e4,default:3e4,step:500},hG={min:0,max:6e5,default:12e4,step:5e3},gG={min:5e3,max:6e5,default:9e4,step:5e3},_G={min:1,max:30,default:4,step:1},vG={min:1,max:30,default:10,step:1},yG={min:0,max:300,default:300,step:5},bG={min:1,max:10,default:4,step:1},xG={min:0,max:30,default:12,step:1},SG=S([`onboard`,`analyzer`,`device-activity`]),CG=x({source:SG,triggeredBy:RV,sensorName:l().optional()}),wG=C(SG),TG={analyzer:`Frame-diff Analyzer (motion addon)`,onboard:`Camera sensors`,"device-activity":`Device activity (the device says it is working)`};function pOe(e){let t=SG.safeParse(e);return t.success?TG[t.data]:e}var mOe=[`analyzer`,`onboard`,`device-activity`],EG=f(e=>Array.isArray(e)&&e.length>1?e.slice(0,1):e,C(XH).max(1)),DG=x({deviceId:n(),detected:y(),source:SG.default(`analyzer`),regions:C($V).readonly().optional()}),OG=i(`kind`,[x({kind:p(`local-broker`)}),x({kind:p(`remote-restream`),ownerNodeId:l(),ownerReachableHost:l().optional(),hubHostnameOverride:l().optional()})]).describe(`Per-camera frame-source mode for the runner (P2c)`),kG=x({modelId:l().optional(),settings:m(l(),w()).optional()}),AG=x({deviceKey:l(),weight:n().positive().default(1),maxSessions:n().int().positive().nullable().default(null),steps:m(l(),kG).optional(),disabledSteps:C(l()).readonly().optional()}),jG=x({deviceId:n(),detectionMode:S([`disabled`,`always-on`,`on-motion`]).default(`on-motion`),audioMode:S([`disabled`,`always-on`,`on-motion`]).default(`always-on`),motionCooldownMs:n().min(mG.min).default(mG.default),maxSessionHoldMs:n().min(hG.min).max(hG.max).optional(),audioMotionWindowMs:n().min(gG.min).max(gG.max).optional(),motionFps:n().min(_G.min).max(_G.max).default(_G.default),detectionFps:n().min(vG.min).max(vG.max).default(vG.default),motionStreamId:l(),detectionStreamId:l(),audioStreamPick:ha.optional(),motionSources:wG.default([`analyzer`]),sessionTrigger:CG.optional(),detectionSources:EG.default([`pipeline`]),pipelineEnabled:y().default(!0),steps:C(Va).readonly().optional(),audio:x({modelId:l().optional(),enabled:y()}).nullable().optional(),zones:C(jW).readonly().default([]),onboardMotionDrivesAnalyzer:y().default(!0),preRollInferenceEnabled:y().default(!0),preRollInferenceFrames:n().min(xG.min).max(xG.max).default(xG.default),occupancyRecheckEnabled:y().default(!0),occupancyRecheckSec:n().min(yG.min).max(yG.max).default(yG.default),occupancyRecheckFrames:n().min(bG.min).max(bG.max).default(bG.default),frameSource:OG.default({kind:`local-broker`}),deviceKey:l().optional(),inferenceDevices:C(AG).readonly().optional()}),hOe=[{key:`motionSources`,type:`multiselect`,label:`Motion Sources`,default:[`analyzer`],options:mOe.map(e=>e===`onboard`?{value:e,label:TG[e],description:`The camera's own motion, plus any sensor attached to it`}:{value:e,label:TG[e]})},{key:`motionFps`,type:`slider`,label:`Motion FPS (analyzer)`,min:_G.min,max:_G.max,step:_G.step,default:_G.default,showValue:!0,unit:`fps`,nullable:!0,nullLabel:`Default`,showWhen:{field:`motionSources`,includes:`analyzer`}},{key:`detectionFps`,type:`slider`,label:`Detection FPS`,min:vG.min,max:vG.max,step:vG.step,default:vG.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:mG.min,max:mG.max,step:mG.step,default:mG.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:hG.min,max:hG.max,step:hG.step,default:hG.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:gG.min,max:gG.max,step:gG.step,default:gG.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:xG.min,max:xG.max,step:xG.step,default:xG.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:yG.min,max:yG.max,step:yG.step,default:yG.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:bG.min,max:bG.max,step:bG.step,default:bG.default,showValue:!0,showWhen:{field:`occupancyRecheckEnabled`,equals:!0}}],MG=x({nodeId:l(),attachedCameras:n(),activeCameras:n(),avgInferenceFps:n(),avgInferenceTimeMs:n(),queueDepthTotal:n(),devices:C(x({deviceKey:l(),backend:l(),attachedCameras:n()})).default([]),hardware:x({hasGpu:y(),inferenceBackend:l().optional(),cpuCores:n().optional()}),motionSliceWriter:p(`orchestrator`).optional()}),NG=x({framesDecoded:n(),framesAdmitted:n(),framesDroppedPixelFree:n(),viewsMaterialized:n(),viewsSkipped:n(),workerToRunnerBytes:n(),runnerToPoolRawBytes:n(),runnerToPoolJpegBytes:n(),onDemandFullFrameRequests:n(),onDemandCropRequests:n(),nativeHits:n(),nativeMisses:n(),tileHits:n(),tileMisses:n(),fallbackHits:n(),fallbackMisses:n(),retainedWritesAvoided:n(),residentRefs:n(),residentBytes:n(),releases:n(),evictions:n(),staleMisses:n()}),PG=x({node:NG,cameras:C(NG.extend({deviceId:n()}))}),FG=x({nodeId:l(),activeCameras:n(),throttledCameras:n(),avgInferenceTimeMs:n(),queueDepth:n(),frameLazy:PG.optional()}),IG=S([`not-attached`,`battery-asleep`,`not-watching`,`already-bursting`]),LG={name:`pipeline-runner`,scope:`system`,mode:`singleton`,methods:{attachCamera:A(jG,x({success:p(!0)}),{kind:`mutation`}),detachCamera:A(x({deviceId:n()}),x({success:p(!0)}),{kind:`mutation`}),reportMotion:A(DG,x({success:p(!0)}),{kind:`mutation`}),getLocalLoad:A(v(),MG),getLocalMetrics:A(v(),FG),getCameraMetrics:A(x({deviceId:n()}),DW.nullable()),getAllCameraMetrics:A(v(),C(OW).readonly()),getLocalCameras:A(v(),C(n()).readonly()),requestOccupancyBurst:A(x({deviceId:n(),frames:n().int().positive().optional(),reason:l()}),x({started:y(),refusedBecause:IG.optional()}),{auth:`admin`,kind:`mutation`}),getNativeCrop:A(x({handle:xa,bbox:sG,maxWidth:n().int().positive().optional(),acceptJpegBytes:y().optional(),encodeJpeg:y().optional()}),cG.nullable()),runDetailSubtree:A(x({deviceId:n(),frameHandle:xa.optional(),frameJpeg:l().optional(),cropJpeg:l().optional(),parent:uOe,steps:C(l()).optional(),supplied:x({stepId:l(),modelId:l(),boxes:C(x({bbox:sG,score:n()})).min(1)}).optional()}),x({details:C(pG)}).nullable(),{kind:`mutation`}),runStatelessStep:A(x({stepId:l(),modelId:l(),frameJpeg:l(),bbox:sG,className:l(),sourceDeviceId:n()}),fOe,{kind:`mutation`}),parkTrackFrame:A(x({deviceId:n(),trackId:l(),kind:lG,handle:xa,bbox:sG,maxWidth:n().int().positive().optional(),timestamp:n()}),dG,{kind:`mutation`}),getParkedTrackFrame:A(x({deviceId:n(),trackId:l(),kind:lG,acceptJpegBytes:y().optional()}),fG.nullable()),releaseParkedTrackFrames:A(x({deviceId:n(),trackId:l()}),x({released:n().int().nonnegative()}),{kind:`mutation`}),startNodeBench:A(XW,x({accepted:p(!0),runId:l()}),{kind:`mutation`,auth:`admin`}),getNodeBenchStatus:A(x({runId:l()}),QW.nullable(),{auth:`admin`}),abortNodeBench:A(x({runId:l()}),x({aborted:y()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.PIPELINE}},RG=3e4,gOe={version:1,targets:[{id:`detected`,cardinality:`event`,shape:`span`,vocabulary:{cap:`motion`,eventName:`onMotionChanged`},deviceTypes:[E.Camera],apply:`add`,applyAuthority:{kind:`camera-sensors`,timeoutField:`motionCooldownMs`},eventName:`onMotionChanged`,start:`rising-edge`,end:`falling-edge-or-timeout`,timeoutMs:RG,combine:`any`,sourceModes:[`in-addition`,`confirm`,`replace`],sources:[{kind:`binary`},{kind:`switch`}],sourceReport:{status:`assignment-status`},advancedExpression:!1}]},_Oe=15e3,zG=x({detected:y(),lastDetectedAt:n().nullable(),autoClearAfterMs:n().nullable().meta(N(`duration-ms`))}),BG=x({deviceId:n(),detected:y(),timestamp:n(),source:SG,regions:C($V).readonly().optional(),triggeredBy:RV.optional()}),VG={name:`motion`,scope:`device`,mode:`singleton`,deviceNative:!0,deviceTypes:[E.Camera,E.Sensor],methods:{isDetected:A(x({deviceId:n()}),y())},composedMethods:{isDetected:{kind:`slice`,field:`detected`}},events:{onMotionChanged:{data:BG,notOperatorFacing:"the `detected` state trigger phrases both edges, from the mirror that survives a dropped event (D49)"}},status:{schema:zG,kind:`push`},runtimeState:zG,durability:`session`,history:{fields:{detected:{kind:`boolean`,excludeDeviceTypes:[E.Camera]}}},customize:gOe,vocabulary:{noun:F(`Motion`,`Movimento`),order:5130,state:[{kind:`boolean`,field:`detected`,label:F(`Motion`,`Movimento`),whenTrue:F(`When {device} detects motion`,`Quando {device} rileva movimento`),whenFalse:F(`When motion clears on {device}`,`Quando il movimento su {device} cessa`),icon:`activity`}]}},HG=x({enabled:y(),lastChangedAt:n()}),UG=HG.extend({lastFetchedAt:n()}),WG={name:`motion-trigger`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Light,E.Siren,E.Switch],methods:{setMotionTrigger:A(x({deviceId:n().int().nonnegative(),enabled:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`motionTrigger.on`,label:F(`Motion trigger on`,`Attivazione al movimento attiva`),phrase:F(`Let motion trigger {device}`,`Fai attivare {device} dal movimento`),icon:`activity`,effect:{field:`enabled`,value:!0},args:{enabled:!0}},{id:`motionTrigger.off`,label:F(`Motion trigger off`,`Attivazione al movimento spenta`),phrase:F(`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:n(),enabled:y(),lastChangedAt:n()}),notOperatorFacing:"the `enabled` state trigger phrases both edges of this change"}},status:{schema:HG,kind:`command-driven`},runtimeState:UG,durability:`session`,history:`none`,vocabulary:{noun:F(`Motion trigger`,`Attivazione al movimento`),order:1160,state:[{kind:`boolean`,field:`enabled`,label:F(`Motion trigger`,`Attivazione al movimento`),whenTrue:F(`When motion triggering is turned on for {device}`,`Quando si attiva l’attivazione al movimento di {device}`),whenFalse:F(`When motion triggering is turned off for {device}`,`Quando si disattiva l’attivazione al movimento di {device}`),icon:`activity`}]}},GG=x({id:n(),enabled:y(),shape:oH}),KG=x({enabled:y(),sensitivity:n().meta(N(`none`)),regions:C(GG),lastFetchedAt:n()}),qG=x({maxRegions:n(),supportedShapes:C(cH),grid:uH,sensitivity:x({min:n(),max:n(),step:n()})}),JG=x({enabled:y().optional(),sensitivity:n().optional(),regions:C(GG).optional()}),YG={name:`motion-zones`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/motion-zones-grid`,tab:`motion`,label:`Motion Zones`}},methods:{getOptions:A(x({deviceId:n()}),qG),setZone:A(x({deviceId:n(),patch:JG}),v(),{kind:`mutation`,auth:`admin`})},status:{schema:KG,kind:`poll`},runtimeState:KG,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Motion zones`,`Zone di movimento`),order:3170}},vOe=S([`external`,`embedded`]),yOe=S([`connected`,`disconnected`,`auth-failed`,`unreachable`,`tls-error`]),XG=x({id:l(),name:l(),url:l(),kind:vOe,status:yOe,latencyMs:n().nullable(),error:l().optional(),connectedClients:n().int().nonnegative().optional(),lastCheckedAt:n().optional()}),ZG=x({url:l(),username:l().optional(),password:l().optional(),clientIdPrefix:l().optional()}),QG=x({name:l().min(1),url:l().regex(/^(mqtt|mqtts|ws|wss):\/\//,`URL must start with mqtt(s):// or ws(s)://`),username:l().optional(),password:l().optional(),clientIdPrefix:l().optional()}),bOe=x({id:l()}),$G=x({id:l()}),eK=x({port:n().int().min(1).max(65535).default(1883),allowAnonymous:y().default(!1),username:l().optional(),password:l().optional()}),xOe=x({id:l(),url:l()}),tK=x({brokerCount:n(),embeddedRunning:y()}),nK={name:`mqtt-broker`,scope:`system`,mode:`collection`,providerKind:`broker`,status:{schema:tK,kind:`poll`},methods:{listBrokers:A(v(),C(XG)),getBrokerConfig:A($G,ZG,{auth:`admin`}),addBroker:A(QG,bOe,{kind:`mutation`,auth:`admin`}),removeBroker:A($G,v(),{kind:`mutation`,auth:`admin`}),startEmbeddedBroker:A(eK,xOe,{kind:`mutation`,auth:`admin`}),stopEmbeddedBroker:A($G,v(),{kind:`mutation`,auth:`admin`}),getStatus:A(v(),tK)},vocabulary:{notOperatorFacing:M.NETWORK}},rK=S([`person`,`vehicle`,`animal`,`face`,`package`,`other`]),iK=x({class:rK,timestamp:n(),confidence:n().min(0).max(1).optional()}),aK=x({lastByClass:d(rK,iK.nullable()),supportedClasses:C(rK).readonly(),enabled:y()}),oK=S([`boxed`,`while-streaming`,`flag-only`]),sK=x({supportedClasses:C(rK).readonly(),geometry:oK}),cK=x({enabled:y().optional()}),lK=aK.extend({lastFetchedAt:n()}),uK={name:`native-object-detection`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],methods:{getOptions:A(x({deviceId:n()}),sK),setSettings:A(x({deviceId:n(),settings:cK}),v(),{kind:`mutation`,auth:`admin`}),setEnabled:A(x({deviceId:n(),enabled:y()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`nativeDetection.on`,label:F(`On-camera detection on`,`Rilevamento a bordo attivo`),phrase:F(`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:F(`On-camera detection off`,`Rilevamento a bordo spento`),phrase:F(`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:n(),detection:iK}),trigger:{category:T.DetectionCameraNative,label:F(`Camera spotted something`,`La telecamera ha rilevato qualcosa`),phrase:F(`When {device} spots something with its own detector`,`Quando {device} rileva qualcosa con il proprio rilevatore`),icon:`scan-eye`}}},status:{schema:aK,kind:`push`},runtimeState:lK,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`On-camera detection`,`Rilevamento a bordo`),order:3180,state:[{kind:`boolean`,field:`enabled`,label:F(`On-camera detection`,`Rilevamento a bordo`),whenTrue:F(`When the on-camera detection of {device} is turned on`,`Quando si attiva il rilevamento a bordo di {device}`),whenFalse:F(`When the on-camera detection of {device} is turned off`,`Quando si disattiva il rilevamento a bordo di {device}`),icon:`scan-eye`}]}},dK=x({pan:n().min(-1).max(1).optional(),tilt:n().min(-1).max(1).optional(),speed:n().min(0).max(1).optional()}),fK=S([`goHome`,`locate`,`spotClean`,`findPet`,`personFollow`,`stop`,`startClean`,`pauseClean`,`dockWash`,`autoEmpty`,`flashOn`,`flashOff`]),pK=S([`action`,`sound`]),mK=x({id:l(),kind:pK,label:l(),icon:l(),soundId:n().int().optional(),enabled:y()}),SOe=[{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}],hK=x({x:n(),y:n()}),gK=x({move:y(),stop:y(),goToPoint:y(),runAction:y(),playSound:y(),light:y(),lightMode:y()}),_K=S([`auto`,`manual`]),COe=40,wOe=100,vK=S([`idle`,`cleaning`,`spot`,`following`,`goto`,`returning`,`paused`,`unknown`]),yK=x({mode:vK,following:y(),flash:y(),lightMode:_K,lightLevel:n().min(40).max(100).meta(N(`none`)),lastChangedAt:n()}),bK=yK.extend({lastFetchedAt:n()}),xK={name:`navigation`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/navigation-panel`,tab:`navigation`,topTab:!0,label:`Navigation`,order:0}},methods:{move:A(dK.extend({deviceId:n()}),v(),{kind:`mutation`,notOperatorFacing:`joystick control from the live view — continuous, not a discrete step`}),stop:A(x({deviceId:n()}),v(),{kind:`mutation`,actions:[{id:`navigation.stop`,label:F(`Stop`,`Ferma`),phrase:F(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),goToPoint:A(hK.extend({deviceId:n()}),v(),{kind:`mutation`,notOperatorFacing:`tap-to-go on the live map — the point only means something on that picture`}),listActions:A(x({deviceId:n()}),C(mK)),runAction:A(x({deviceId:n(),actionId:fK}),v(),{kind:`mutation`,actions:[{id:`navigation.runAction`,label:F(`Run a routine`,`Esegui una routine`),phrase:F(`Have {device} {actionId}`,`Fai eseguire a {device}: {actionId}`),icon:`bot`,openArgs:[{key:`actionId`,label:F(`Routine`,`Routine`),offer:{kind:`enum`,values:[{value:`goHome`,label:F(`go home`,`torna alla base`)},{value:`locate`,label:F(`beep so you can find it`,`suona per farsi trovare`)},{value:`spotClean`,label:F(`clean this spot`,`pulisci questo punto`)},{value:`findPet`,label:F(`find the pet`,`cerca l’animale`)},{value:`personFollow`,label:F(`follow a person`,`segui una persona`)},{value:`stop`,label:F(`stop`,`fermati`)},{value:`startClean`,label:F(`start cleaning`,`inizia a pulire`)},{value:`pauseClean`,label:F(`pause cleaning`,`metti in pausa la pulizia`)},{value:`dockWash`,label:F(`wash the mop at the dock`,`lava il mocio alla base`)},{value:`autoEmpty`,label:F(`empty the bin at the dock`,`svuota il contenitore alla base`)},{value:`flashOn`,label:F(`turn the flash on`,`accendi il flash`)},{value:`flashOff`,label:F(`turn the flash off`,`spegni il flash`)}]}}]}]}),playSound:A(x({deviceId:n(),soundId:n().int()}),v(),{kind:`mutation`,actions:[{id:`navigation.playSound`,label:F(`Play sound`,`Riproduci un suono`),phrase:F(`Play {soundId} on {device}`,`Riproduci {soundId} su {device}`),icon:`volume-2`,openArgs:[{key:`soundId`,label:F(`Sound`,`Suono`),offer:{kind:`dynamic`,from:`method`,method:`listActions`,valueKey:`soundId`,labelKey:`label`,where:{key:`kind`,equals:`sound`},valueKind:`number`}}]}]}),setLightOn:A(x({deviceId:n(),on:y()}),v(),{kind:`mutation`,actions:[{id:`navigation.lightOn`,label:F(`Light on`,`Luce accesa`),phrase:F(`Turn on the light of {device}`,`Accendi la luce di {device}`),icon:`lightbulb`,args:{on:!0}},{id:`navigation.lightOff`,label:F(`Light off`,`Luce spenta`),phrase:F(`Turn off the light of {device}`,`Spegni la luce di {device}`),icon:`lightbulb-off`,args:{on:!1}}]}),setLightMode:A(x({deviceId:n(),mode:_K,level:n().min(40).max(100).optional()}),v(),{kind:`mutation`,actions:[{id:`navigation.lightAuto`,label:F(`Light automatic`,`Luce automatica`),phrase:F(`Set the light of {device} to automatic`,`Metti la luce di {device} in automatico`),icon:`lightbulb`,args:{mode:`auto`}}]}),setLightLevel:A(x({deviceId:n(),level:n().min(40).max(100)}),v(),{kind:`mutation`,actions:[{id:`navigation.lightLevel`,label:F(`Set light level`,`Imposta la luce`),phrase:F(`Set the light of {device} to {level}`,`Imposta la luce di {device} al {level}`),icon:`sun-medium`,openArgs:[{key:`level`,label:F(`Level`,`Livello`),offer:{kind:`number`,min:40,max:100,step:1,unit:`%`}}]}]}),getFeatures:A(x({deviceId:n()}),gK)},events:{onStatusChanged:{data:x({deviceId:n(),status:yK}),notOperatorFacing:"the `mode` state trigger reads the same change"}},status:{schema:yK,kind:`push`},runtimeState:bK,durability:`session`,history:`none`,vocabulary:{noun:F(`Robot movement`,`Movimento del robot`),order:2080,state:[{kind:`enum`,field:`mode`,label:F(`Activity`,`Attività`),values:[{value:`idle`,label:F(`Idle`,`Inattivo`)},{value:`cleaning`,label:F(`Cleaning`,`In pulizia`)},{value:`spot`,label:F(`Spot cleaning`,`Pulizia localizzata`)},{value:`following`,label:F(`Following`,`In inseguimento`)},{value:`goto`,label:F(`Moving to a point`,`In movimento verso un punto`)},{value:`returning`,label:F(`Returning`,`In rientro`)},{value:`paused`,label:F(`Paused`,`In pausa`)},{value:`unknown`,label:F(`Unknown`,`Sconosciuto`)}],icon:`bot`}]}},SK=x({url:l(),hostname:l(),port:n(),protocol:S([`http`,`https`]),stable:y().optional()}),TOe=x({url:l(),stable:y().optional(),updated:y().optional()}),CK=x({connected:y(),endpoint:SK.nullable(),error:l().optional()}),EOe=SK.extend({id:l(),label:l(),mode:l().optional(),sourcePort:n().optional()}),wK={name:`network-access`,scope:`system`,mode:`collection`,providerKind:`ingress`,methods:{start:A(v(),SK,{kind:`mutation`}),stop:A(v(),v(),{kind:`mutation`}),getEndpoint:A(v(),SK.nullable()),getStatus:A(v(),CK),listEndpoints:A(v(),C(EOe).readonly())},vocabulary:{notOperatorFacing:M.NETWORK}},TK=[`wifi`,`ethernet`,`cellular`,`unknown`],EK=x({type:S(TK),signal:n().min(0).max(100).nullable().meta(N(`percentage`)),rssi:n().optional().meta(N(`signal-level`)),ssid:l().optional(),speedKbps:n().nonnegative().nullable().optional().meta(N(`bitrate`)),linkUp:y().nullable().optional(),lastUpdated:n().meta(N(`none`))}),DK={type:`unknown`,signal:null,lastUpdated:0};function DOe(e,t){return e===void 0||!Number.isFinite(e)||t<=0||e<0||e>t?null:Math.round(e/t*100)}function OOe(e){return e===void 0||!Number.isFinite(e)||e>0?null:Math.round((Math.min(-50,Math.max(-100,e))+100)*2)}var OK={name:`network-link`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera,E.Sensor,E.Button,E.Switch,E.Light,E.Lock,E.Siren],methods:{},events:{onStatusChanged:{data:x({deviceId:n(),status:EK}),notOperatorFacing:`the signal / link-type state triggers each read one field of this change`}},status:{schema:EK,kind:`push`,empty:DK},runtimeState:EK,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:F(`Network link`,`Collegamento di rete`),order:5250,state:[{kind:`numeric`,field:`signal`,quantity:F(`the signal strength`,`l’intensità del segnale`),label:F(`Signal`,`Segnale`),unit:`%`,icon:`wifi`},{kind:`enum`,field:`type`,label:F(`Link type`,`Tipo di collegamento`),values:[{value:`wifi`,label:F(`Wi-Fi`,`Wi-Fi`)},{value:`ethernet`,label:F(`Ethernet`,`Ethernet`)},{value:`cellular`,label:F(`Cellular`,`Rete mobile`)},{value:`unknown`,label:F(`Unknown`,`Sconosciuto`)}],icon:`network`}]}},kK=x({nominalBitrateKbps:n(),observedBitrateKbps:n(),peakBitrateKbps:n(),packetLossPercent:n(),lastUpdated:n()}),AK=x({rttMs:n(),jitterMs:n(),estimatedBandwidthKbps:n(),packetLossPercent:n().min(0).max(100),downlinkMbps:n().optional(),downlinkAgeMs:n().optional(),lastUpdated:n()}),jK=x({deviceId:n(),streams:m(l(),kK),client:AK.optional()}),MK={name:`network-quality`,scope:`system`,mode:`singleton`,methods:{getDeviceStats:A(x({deviceId:n()}),jK.nullable()),getAllStats:A(v(),C(jK).readonly()),reportClientStats:A(x({deviceId:n(),rttMs:n().min(0).max(6e4),jitterMs:n().min(0).max(1e4),estimatedBandwidthKbps:n().min(0).max(1e6),packetLossPercent:n().min(0).max(100),downlinkMbps:n().min(0).max(1e5).optional(),downlinkAgeMs:n().min(0).max(864e5).optional()}),v(),{role:`viewer`,kind:`mutation`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:M.NETWORK}},NK=x({cn:l(),serial:l(),fingerprintSha256:l(),notBefore:n(),notAfter:n()}),PK=x({fingerprintSha256:l(),issuer:l(),sans:C(l()),notBefore:n(),notAfter:n()}),FK=i(`state`,[x({state:p(`served`),leaf:PK}),x({state:p(`not-issued`),reason:l()})]),IK={name:`node-certificates`,scope:`system`,mode:`singleton`,internal:!0,methods:{getCertificates:A(x({}),x({nodeId:l(),mesh:NK.nullable(),https:FK}),{auth:`admin`}),prepareMeshRenewal:A(x({}),x({csrPem:l()}),{kind:`mutation`,auth:`admin`}),installMeshLeaf:A(x({certPem:l().min(1),caCertPem:l().min(1),confirmWithinMs:n().int().min(1e4).max(6e5)}),x({fingerprintSha256:l(),serial:l()}),{kind:`mutation`,auth:`admin`}),confirmMeshLeaf:A(x({fingerprintSha256:l()}),x({confirmed:y()}),{kind:`mutation`,auth:`admin`}),rollbackMeshLeaf:A(x({}),x({rolledBack:y()}),{kind:`mutation`,auth:`admin`}),prepareHttpsCertificate:A(x({}),x({csrPem:l(),hostnames:C(l()),addresses:C(l()),pinnedCaFingerprintSha256:l().nullable()}),{kind:`mutation`,auth:`admin`}),forgetHub:A(x({}),x({ok:p(!0)}),{kind:`mutation`,auth:`admin`}),installHttpsCertificate:A(x({certPem:l().min(1),caCertPem:l().min(1),caRotation:y().optional()}),PK,{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:M.IDENTITY}},LK=x({nodeId:l().min(1),removedAt:n()}),RK=x({counts:m(l(),n().int().nonnegative())}),zK={name:`node-removal-hook`,scope:`system`,mode:`collection`,internal:!0,methods:{onNodeRemoved:A(LK,RK,{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:M.INTERNAL}},BK=x({addonId:l(),capabilities:C(l()).readonly(),status:l()}),VK=x({pid:n(),name:l(),state:l(),cpuPercent:n(),memoryRss:n(),uptimeSeconds:n(),services:C(BK).readonly(),groupId:l().optional()}),kOe=x({id:l(),status:l(),cpuPercent:n(),memoryRss:n()}),AOe=x({category:l(),total:n(),healthy:n(),addons:C(kOe).readonly()}),jOe=x({name:l(),version:l()}),HK=x({id:l(),name:l(),hostname:l(),platform:l(),arch:l(),cpuModel:l().nullable(),cpuCores:n(),memoryMB:n(),engines:C(l()).readonly(),isHub:y(),isOnline:y(),cpuPercent:n(),memoryPercent:n().nullable(),uptime:n(),lastSeen:l(),localIps:C(l()).readonly(),addons:C(x({id:l(),capabilities:C(l()).readonly(),status:l()})).readonly(),processes:C(VK).readonly(),categories:C(AOe).readonly(),rootPackage:jOe.nullable(),meshTransport:S([`tls`,`clear`]).optional(),capabilitiesRegistered:y().optional()}),MOe=x({callerAddonId:l(),providerAddonId:l(),capName:l(),callsPerMin:n(),lastCallAtMs:n()}),UK=x({nodeId:l(),name:l(),version:l(),status:l(),synced:y()}),WK=x({hubVersion:l(),nodes:C(UK)}),GK=x({nodeId:l(),addonId:l()}),NOe=x({id:l(),status:l(),version:l().optional(),packageName:l().optional()}),KK=x({success:y()}),POe=x({success:y(),reason:l().optional()}),FOe=x({restarted:C(l()).readonly(),failed:C(l()).readonly()}),IOe=x({nodeId:l(),name:l()}),qK=x({id:l(),name:l(),isHub:y(),isOnline:y()}),JK=x({nodes:C(qK).readonly(),complete:y()}),YK={name:`nodes`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,methods:{topology:A(v(),C(HK).readonly(),{auth:`admin`}),directory:A(v(),JK,{auth:`admin`}),deployAddon:A(GK,KK,{kind:`mutation`,auth:`admin`}),undeployAddon:A(GK,KK,{kind:`mutation`,auth:`admin`}),restartAddon:A(GK,KK,{kind:`mutation`,auth:`admin`}),restartProcess:A(x({nodeId:l(),processName:l()}),POe,{kind:`mutation`,auth:`admin`}),restartNode:A(x({nodeId:l()}),FOe,{kind:`mutation`,auth:`admin`}),shutdownNode:A(x({nodeId:l()}),KK,{kind:`mutation`,auth:`admin`}),renameNode:A(x({nodeId:l(),name:l().min(1).max(64)}),IOe,{kind:`mutation`,auth:`admin`}),clusterAddonStatus:A(v(),m(l(),WK),{auth:`admin`}),getCapUsageGraph:A(x({windowSeconds:n().int().positive().max(300).default(60)}),C(MOe).readonly(),{auth:`admin`}),getNodeAddons:A(x({nodeId:l()}),C(NOe).readonly(),{auth:`admin`}),setProcessLogLevel:A(x({nodeId:l(),level:l()}),KK,{kind:`mutation`,auth:`admin`}),executeQuery:A(x({nodeId:l(),addonId:l(),queryName:l(),params:m(l(),w()).optional()}),w(),{kind:`mutation`,auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:M.CLUSTER}},XK=[{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`}],ZK={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},QK={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},$K=new Map;for(let[e,t]of Object.entries(ZK.mapping))$K.set(e.toLowerCase(),t);for(let[e,t]of Object.entries(QK.mapping))$K.set(e.toLowerCase(),t);function LOe(e){return $K.get(e.toLowerCase())??null}function ROe(){return XK.map(e=>e.id)}var eq=bP();function tq(e){return TP(eq.swatches,eq.fallbacks,e)}function zOe(e){let t=e[0];if(t===void 0)throw Error(`display palette has no fallback colour`);return t}var BOe=zOe(eq.fallbacks);function VOe(e){return e.split(/[-_ ]/).filter(e=>e.length>0).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}var nq=new Map;function rq(e,t,n,r){nq.set(e,{kind:e,parentKind:null,level:`macro`,category:t,color:tq(e),iconId:n,labelKey:`eventKind.${e}`,label:r})}function iq(e,t,n,r,i){nq.set(e,{kind:e,parentKind:t,level:`sub`,category:n,color:tq(e),iconId:r,labelKey:`eventKind.${e}`,label:i})}rq(`motion`,`motion`,`motion`,`Motion`),rq(`audio`,`audio`,`audio`,`Audio`),rq(`person`,`detection`,`person`,`Person`),rq(`vehicle`,`detection`,`vehicle`,`Vehicle`),rq(`animal`,`detection`,`animal`,`Animal`),rq(`package`,`package`,`package`,`Package`),rq(`sensor`,`sensor`,`sensor`,`Sensor`),rq(`control`,`control`,`control`,`Control`);for(let[e,t]of Object.entries(r_.mapping))t!==`vehicle`&&t!==`animal`||nq.has(e)||iq(e,t,`detection`,e,VOe(e));iq(`package-delivered`,`package`,`package`,`package`,`Package delivered`),iq(`package-picked-up`,`package`,`package`,`package`,`Package picked up`),iq(`contact`,`sensor`,`sensor`,`door`,`Contact`),iq(`motion-sensor`,`sensor`,`sensor`,`pir`,`Motion sensor`),iq(`smoke`,`sensor`,`sensor`,`smoke`,`Smoke`),iq(`flood`,`sensor`,`sensor`,`water`,`Water leak`),iq(`gas`,`sensor`,`sensor`,`gas`,`Gas`),iq(`carbon-monoxide`,`sensor`,`sensor`,`smoke`,`Carbon monoxide`),iq(`vibration`,`sensor`,`sensor`,`vibration`,`Vibration`),iq(`tamper`,`sensor`,`sensor`,`tamper`,`Tamper`),iq(`presence`,`sensor`,`sensor`,`presence`,`Presence`),iq(`enum-sensor`,`sensor`,`sensor`,`generic`,`Sensor state`),iq(`device-event`,`sensor`,`sensor`,`button`,`Device event`),iq(`lock`,`control`,`control`,`lock`,`Lock`),iq(`cover`,`control`,`control`,`door`,`Cover`),iq(`switch`,`control`,`control`,`switch`,`Switch`),iq(`siren`,`control`,`control`,`siren`,`Siren`),iq(`button`,`control`,`control`,`button`,`Button`),iq(`doorbell`,`control`,`control`,`doorbell`,`Doorbell`),iq(`appliance-cycle`,`control`,`control`,`switch`,`Appliance cycle`);for(let e of XK){let t=`audio-${e.id}`;nq.has(t)||iq(t,`audio`,`audio`,t,e.name)}var aq=Object.freeze(Object.fromEntries(nq));function oq(e){return aq[e]}function HOe(e){return tq(e)}function UOe(e){let t=[];for(let n of Object.values(aq))n.parentKind===e&&t.push(n);return t}var sq=x({kind:l(),label:l(),parentKind:l().nullable()}),cq=x({videoClasses:C(sq),audioKinds:C(sq),labels:C(sq)});function lq(e,t,n){return{kind:e,label:t,parentKind:n}}function uq(){let e=Object.values(aq);return{videoClasses:e.filter(e=>e.category===`detection`).map(e=>lq(e.kind,e.label,e.parentKind)),audioKinds:e.filter(e=>e.category===`audio`&&e.level===`sub`).map(e=>lq(e.kind,e.label,e.parentKind)),labels:e.filter(e=>e.category===`sensor`||e.category===`control`).map(e=>lq(e.kind,e.label,e.parentKind))}}var WOe=Object.freeze(uq()),dq=S([`immediate`,`track-end`,`device-event`,`package-event`,`system-event`]),fq=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(`.`)),pq=[`camera-online`,`camera-offline`,`camera-disabled`,`camera-enabled`],GOe=new Set(pq),KOe=fq.options.filter(e=>!GOe.has(e)),mq=[`alarm-arm-refused`,`alarm-check-failed`,`alarm-arming`,`alarm-armed`,`alarm-pending`,`alarm-triggered`,`alarm-rearmed`,`alarm-sensor-bypass`,`alarm-disarmed`],qOe=[`device-battery-low`,`device-battery-normal`,`device-consumable-low`,`device-consumable-normal`],hq=[`device-consumable-low`,`device-consumable-normal`],JOe=15,YOe=95,gq=[`confirmed`,`already`,`unconfirmed`,`failed`],_q=[`user`,`addon`,`action`,`scheduler`,`composition`,`node`],vq=x({kinds:C(fq).min(1),deviceIds:C(n().int()).min(1).optional(),deviceTypes:C(l().min(1)).min(1).optional(),excludeDeviceIds:C(n().int()).min(1).optional(),nodeIds:C(l().min(1)).min(1).optional(),packageNames:C(l().min(1)).min(1).optional(),commandActions:C(l().min(1)).min(1).optional(),commandOutcomes:C(S(gq)).min(1).optional(),commandActorKinds:C(S(_q)).min(1).optional(),consumableLowPercent:n().int().min(1).max(95).optional()});function XOe(e){return e.consumableLowPercent??15}var ZOe=1,yq=1440,QOe=[10,30,60],bq=x({days:C(n().int().min(0).max(6)).min(1),startMinute:n().int().min(0).max(1439),endMinute:n().int().min(0).max(1439)}),xq=x({windows:C(bq).min(1),timezone:l().optional(),invert:y().optional()}),Sq=S([`instant`,`summary`]),$Oe=S([`activation`,`deactivation`,`schedule`]),Cq=S([`rule`,`section`]),wq=i(`mode`,[x({mode:p(`instant`)}),x({mode:p(`summary`),schedule:xq,split:Cq.optional()}),x({mode:p(`modes`),onActivation:y(),onDeactivation:y(),onSchedule:x({schedule:xq,grouping:Cq}).optional()})]),Tq=x({values:C(l().min(1)),maxDistance:n().int().min(0).max(3).default(1)}),Eq=x({zoneId:l().optional(),className:l().optional(),op:S([`became-occupied`,`became-free`,`>=`,`<=`]).default(`became-occupied`),count:n().int().min(0).default(1),sustainSeconds:n().int().min(0).max(3600).default(15)}),eke=-96,Dq=x({labels:C(l().min(1)).min(1).optional(),dbThreshold:n().min(-96).max(0).optional(),hitPercent:n().int().min(1).max(100).default(60),samplingSeconds:n().int().min(1).max(300).default(10),confirmHits:n().int().min(1).max(20).optional(),confirmWindowSec:n().int().min(1).max(60).optional()}),Oq=S([`enter`,`exit`,`any`]),kq=S([`raised`,`cleared`]),Aq=x({ids:C(l().min(1)).min(1),match:S([`any`,`all`]).optional()}),jq=l().min(1),Mq=C(jq).max(4),Nq=x({id:l().min(1).max(64),label:l().min(1).max(40),actionId:jq,icon:Xu.optional(),destructive:y().optional()}),Pq=x({onActivation:Mq.optional(),onDeactivation:Mq.optional(),onTrigger:Mq.optional(),onTriggerOff:Mq.optional(),buttons:C(Nq).max(8).optional()}),Fq=x({deviceId:n().int(),states:C(l().min(1)).min(1)}),Iq=x({sceneId:l().min(1),deviceId:n().int().optional(),requiredState:S([`matched`,`diverged`]),latched:y().optional()}),Lq=x({deviceState:Fq.optional(),scene:Iq.optional(),devices:C(n()).optional(),devicesExclude:C(n()).min(1).optional(),classes:C(l().min(1)).optional(),classesExclude:C(l().min(1)).optional(),minConfidence:n().min(0).max(1).optional(),zones:Aq.optional(),zonesExclude:C(l().min(1)).optional(),crossing:Oq.optional(),labelEquals:C(l().min(1)).optional(),identities:C(l().min(1)).optional(),plates:Tq.optional(),identitiesExclude:C(l().min(1)).optional(),minImportance:n().min(0).max(1).optional(),minDwellSeconds:n().min(0).optional(),source:S([`pipeline`,`onboard`,`sensor`,`audio`,`any`]).optional(),minLabelConfidence:n().min(0).max(1).optional(),eventTypeTokens:C(l().min(1)).optional(),sensorKinds:C(l().min(1)).optional(),sensorTransition:kq.optional(),packagePhase:S([`delivered`,`picked-up`,`both`]).optional(),systemEvent:vq.optional(),customZones:C(aH).optional(),occupancy:Eq.optional(),audio:Dq.optional()}),Rq=x({targetId:l().min(1),params:m(l(),w()).optional()}),tke=500,zq=S([`none`,`image`,`clip`,`gif`]),Bq=x({template:x({title:l().max(500).optional(),body:l().max(2e3).optional()}).optional(),schedule:xq.optional(),priority:n().int().min(1).max(5).optional(),attachment:zq.optional(),actions:y().optional()}),Vq=m(l(),Bq),Hq=S([`scene-boxes`,`crop`,`clean`,`none`]),Uq=S([`cropped`,`full`,`boxed`]),Wq=S([`mosaic`,`each`]),nke=4,rke=6,Gq=x({image:Hq.optional(),showTriggerZone:y().optional(),showSubjectPath:y().optional(),attach:S([`best`,`best-matching`,`keyFrame`,`none`]).optional(),frame:Uq.optional(),zoneCrop:y().optional(),gif:y().optional(),clip:y().optional(),clipPreRollSec:n().int().min(0).max(30).optional(),clipPostRollSec:n().int().min(0).max(30).optional(),clipSpeed:n().min(1).max(8).optional(),profile:P.optional(),linkedCameras:Wq.optional(),wakeSleepingCamera:y().optional()}),Kq=S([`shared`,`per-class`]),qq=x({cooldownSec:n().int().min(0).max(86400).default(60),scope:S([`rule`,`rule-device`]).default(`rule-device`),granularity:Kq.optional()}),Jq=1e3,Yq=2e4,Xq=8e3,ike=448,Zq=x({op:S([`>=`,`>`,`<=`,`<`,`==`]),count:n().int().min(0).max(1e3)}),Qq=x({enabled:y().default(!1),profileId:l().optional(),prompt:l().max(1e3).optional(),expect:Zq.optional(),timeoutMs:n().int().min(Jq).max(Yq).default(Xq),onTimeout:S([`fire`,`suppress`]).default(`fire`),maxImagePx:n().int().min(64).max(2048).default(448)}),ake=5,oke=20,ske=60,cke=5,lke=0,uke=300,$q=x({name:l().min(1).max(200),enabled:y().default(!0),delivery:dq,conditions:Lq.default({}),schedule:xq.optional(),systemEventDelivery:wq.optional(),targets:C(Rq),targetUsers:C(l()).optional(),targetOverrides:Vq.optional(),media:Gq.default({}),throttle:qq.default({cooldownSec:60,scope:`rule-device`}),template:x({title:l().max(500).optional(),body:l().max(2e3).optional()}).optional(),priority:n().int().min(1).max(5).default(3),ownerUserId:l().optional(),snoozeAllowGlobal:y().optional(),snoozeOptions:C(n().int().min(1).max(yq)).max(4).optional(),actions:Pq.optional(),confirm:Qq.optional(),groupingSec:n().int().min(5).max(60).optional(),groupWithinSec:n().int().min(0).max(300).optional(),askVerdict:y().optional(),tags:Hh.optional()}),eJ=S([`event`,`summary`,`timelapse`,`calendar-events`]),tJ=x({kind:eJ,ruleId:l(),tags:C(l())}),nJ=$q.partial().extend({disabledTargetIds:C(l()).optional(),enabled:y().optional(),conditions:Lq.optional(),media:Gq.optional(),throttle:qq.optional(),priority:n().int().min(1).max(5).optional()}),rJ=[`waitForEnhancement`,`groupIdleSec`];function dke(e){return rJ.some(t=>t===e)}var iJ=[`template`,`schedule`,`targetUsers`,`snoozeOptions`,`snoozeAllowGlobal`,`actions`,`confirm`,`groupingSec`,`waitForEnhancement`,`groupIdleSec`],aJ=S(iJ),oJ=x({ruleId:l(),patch:nJ,clear:C(aJ).optional()}),sJ=$q.extend({id:l(),createdBy:l(),createdAt:n(),updatedAt:n(),disabledTargetIds:C(l()).default([])}),cJ=[`device-state`,`streams`,`battery`,`consumables`,`detection-blind`,`nodes`,`addons`,`addon-updates`,`updates`],lJ=S(cJ),uJ=x({id:lJ,status:S([`read`,`unavailable`]),items:n().int().nonnegative(),reason:l().optional()}),dJ=x({section:lJ.optional(),title:l(),text:l(),count:n().int().nonnegative()}),fJ=x({empty:y(),count:n().int().nonnegative(),text:l(),sections:C(uJ),dropped:m(l(),n().int().nonnegative()),excludedGroups:C(l()),split:Cq.optional(),rows:C(dJ).optional()}),pJ=x({recordId:l(),recordKind:S([`object-event`,`track`,`device-event`,`package-event`,`system-event`]),deviceId:n(),timestamp:n(),wouldFire:y(),failedCondition:l().optional(),className:l().optional(),label:l().optional()}),mJ=S([`detection`,`sensor`,`occupancy`,`sound`,`device-events`,`system`,`alarm`,`mixed`]),hJ=S([`detection`,`sensor`,`occupancy`,`sound`,`system`]),gJ=x({id:S([`appliance-cycle`]),kind:mJ,title:l(),body:l()}),_J=S([`rule`,`timelapse`,`summary`]),vJ=S([`title`,`body`,`previewText`,`captionText`]),yJ=S([`subject`,`place`,`time`,`rule`,`occupancy`,`sound`,`sensor`,`system`,`digest`,`ai`]),bJ=x({name:l().regex(/^\w+$/),label:l(),description:l().optional(),example:l(),group:yJ,families:C(_J).min(1),fields:C(vJ).optional(),kinds:C(hJ).optional(),deliveries:C(dq).optional(),systemEventKinds:C(fq).optional(),systemEventDeliveries:C(Sq).optional(),dynamic:x({prefix:p(`count_`),from:p(`classes`)}).optional()}),xJ=x({family:_J,field:vJ,kind:mJ.optional(),delivery:dq.optional(),systemEventKinds:C(fq).optional(),systemEventDelivery:Sq.optional()}),SJ=x({context:xJ,template:x({title:l().max(500).optional(),body:l().max(2e3).optional()})}),CJ=x({title:l().nullable(),body:l().nullable(),unknown:C(l())}),wJ=x({id:l(),group:S([`scope`,`class`,`zones`,`quality`,`label`,`schedule`,`device`,`package`,`occupancy`,`audio`,`system`]),label:l(),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(dq),phase:l(),description:l().optional(),options:C(x({value:l(),label:l(),hint:l().optional()})).readonly().optional()}),fke=[{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.`}],TJ=S([`pending`,`sent`,`dead`]),EJ=S([`object-event`,`track-end`,`device-event`,`package-event`,`system-event`]),DJ=x({className:l(),label:l().optional(),confidence:n().optional(),zones:C(l()),timestamp:n(),systemEvent:x({kind:fq,subject:l(),title:l(),body:l(),data:m(l(),w())}).optional()}),OJ=x({id:l(),ruleId:l(),ruleName:l(),delivery:dq,targetId:l(),deviceId:n(),recordKind:EJ,recordId:l(),trackId:l().optional(),status:TJ,attempts:n().int(),createdAt:n(),updatedAt:n(),error:l().optional(),subject:DJ,title:l().optional(),body:l().optional(),artifactIds:C(l().min(1)).optional(),groupedInto:l().min(1).optional()}),pke=100,mke=500,kJ=x({ruleId:l().optional(),deviceId:n().optional(),status:TJ.optional(),since:n().optional(),until:n().optional(),limit:n().int().min(1).max(500).default(100)}),AJ=x({ruleId:l(),lastAt:n(),status:TJ,deviceId:n()}),jJ=x({runs:C(AJ),horizonMs:n().nonnegative().nullable()}),MJ=S([`rule`,`device`,`all`]),NJ=x({scope:MJ,ruleId:l().optional(),deviceId:n().int().optional(),classes:C(l().min(1)).min(1).optional(),durationMinutes:n().int().min(1).max(yq),global:y().optional(),summary:y().optional()}),PJ=x({id:l(),userId:l(),scope:MJ,ruleId:l().optional(),deviceId:n().int().optional(),classes:C(l().min(1)).min(1).optional(),startedAt:n(),expiresAt:n(),global:y(),summary:y(),digestSentAt:n().optional()}),hke=x({snoozeId:l(),targetId:l(),ruleId:l(),ruleName:l(),deviceId:n().int(),count:n().int(),firstAt:n(),lastAt:n()}),gke=600,FJ=3600,_ke=200,IJ=n().int().min(0).max(600),LJ=n().int().min(0).max(FJ),RJ=e=>new Set(e.map(e=>e.mode)).size===e.length,zJ=S([`rearmAfter`,`disableAfter`,`doNothing`]),BJ=x({mode:YS,exitDelaySec:IJ.optional(),entryDelaySec:IJ.optional(),triggeredDurationSec:LJ.optional(),postTriggeredAction:zJ.optional(),schedule:xq.optional(),notifyDuringEntryDelay:y().optional(),notifySensorRewatched:y().optional(),notifySensorIgnored:y().optional()}),vke=C(BJ).max(8).refine(RJ,{message:`modeDelays: at most one entry per arm mode`}),VJ=x({mode:YS,exitDelaySec:IJ.nullable().optional(),entryDelaySec:IJ.nullable().optional(),triggeredDurationSec:LJ.nullable().optional(),postTriggeredAction:zJ.nullable().optional(),schedule:xq.nullable().optional(),notifyDuringEntryDelay:y().nullable().optional(),notifySensorRewatched:y().nullable().optional(),notifySensorIgnored:y().nullable().optional()}),yke=C(VJ).max(8).refine(RJ,{message:`modeDelays: at most one edit per arm mode`}),HJ=x({mode:YS,deviceId:n().int().positive(),nonBlocking:y()}),UJ=x({mode:YS,deviceId:n().int().positive(),blocking:y()}),WJ=x({mode:YS,deviceId:n().int().positive(),secureOnArm:y()}),GJ=x({mode:YS,deviceIds:C(n().int()).max(200)}),KJ=GJ,qJ=GJ,JJ=GJ,YJ=C(KJ).max(8).refine(RJ,{message:`nonBlocking: at most one list per arm mode`}),XJ=C(qJ).max(8).refine(RJ,{message:`blocking: at most one list per arm mode`}),ZJ=C(JJ).max(8).refine(RJ,{message:`secureOnArmOff: at most one list per arm mode`}),QJ=x({exitDelaySec:IJ,entryDelaySec:IJ,triggeredDurationSec:LJ,postTriggeredAction:zJ.optional(),announceArm:y().optional(),announceTargets:C(l().min(1)).max(16),nonBlocking:YJ.default([]),blocking:XJ.default([]),secureOnArmOff:ZJ.default([]),modeDelays:vke.default([])}),$J=x({id:l().min(1).max(64),name:l().min(1).max(64),isDefault:y()}),eY=x({activeId:l().min(1),items:C($J).min(1)}),tY=x({name:l().min(1).max(64),cloneFromId:l().min(1).max(64).optional()}),nY=x({id:l().min(1).max(64),name:l().min(1).max(64)}),rY=x({id:l().min(1).max(64)}),bke=QJ.extend({nonBlocking:YJ,blocking:XJ,secureOnArmOff:ZJ,modeDelays:yke,nonBlockingEdit:HJ,blockingEdit:UJ,secureOnArmEdit:WJ}).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`}),iY=S([`muted`,`detection-off`,`offline`]),aY=x({deviceId:n().int(),reason:iY}),oY=x({mode:YS,ruleCount:n().int().min(0),allDevices:y(),deviceIds:C(n().int()),allDevicesExcept:C(n().int()).default([]),skippedDevices:C(aY).default([])}),xke=x({deviceId:n().int(),name:l(),state:l(),blocking:y()}),Ske=x({deviceId:n().int(),name:l(),phase:S([`open`,`closed`])}),Cke=x({mode:YS,devices:C(xke),unknown:C(n().int())}),wke=x({ruleId:l(),ruleName:l(),deviceId:n().int(),name:l(),since:n(),dropped:n().int().min(0)}),Tke=x({state:JS,targetMode:YS.nullable(),availableModes:C(YS),openings:C(Cke),exclusions:C(Ske),bypassedInputs:C(wke).default([])}),sY=x({deviceId:n().int().nullable(),settings:QJ,profiles:eY.optional(),coverage:C(oY),live:Tke.optional()}),Eke=500,cY=S([`open`,`closed`,`unknown`,`not-opening`]),lY=x({deviceId:n().int().positive(),reading:cY,state:l().nullable(),unknownWhy:S([`read-failed`,`unknown-word`]).nullable(),online:y().nullable(),controllable:y().default(!1)}),uY=x({deviceIds:C(n().int().positive()).max(500)}),dY=x({sensors:C(lY),readAt:n().int().nonnegative()}),Dke=60,fY=x({deviceId:n().int().nonnegative().optional(),seconds:n().min(0).max(60),profile:P.optional(),ruleId:l(),ruleName:l(),reason:S([`window`,`occupancy`])}),pY=x({rulesLoaded:y(),asks:C(fY).readonly()}),mY={name:`notification-rules`,scope:`system`,mode:`singleton`,methods:{listRules:A(x({}),x({rules:C(sJ)}),{auth:`admin`}),getRule:A(x({ruleId:l()}),x({rule:sJ.nullable()}),{auth:`admin`}),createRule:A(x({rule:$q}),x({rule:sJ}),{kind:`mutation`,auth:`admin`,caller:`required`}),updateRule:A(oJ,x({rule:sJ}),{kind:`mutation`,auth:`admin`,caller:`required`}),deleteRule:A(x({ruleId:l()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setRuleEnabled:A(x({ruleId:l(),enabled:y()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),listRuleTags:A(x({}),x({rules:C(tJ)}),{kind:`query`,auth:`admin`}),setRuleTags:A(x({kind:eJ,ruleId:l(),tags:Hh}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getClipRetentionAsks:A(x({}),pY,{auth:`admin`}),listDeviceMutes:A(x({}),x({mutedDeviceIds:C(n().int()).readonly()}),{auth:`admin`}),setDeviceMuted:A(x({deviceId:n().int(),muted:y()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),testRule:A(x({rule:$q,lookbackMinutes:n().int().min(1).max(1440).default(60)}),x({results:C(pJ)}),{kind:`mutation`,auth:`admin`}),previewStateSummary:A(x({rule:$q}),fJ,{kind:`mutation`,auth:`admin`,access:`view`}),getConditionCatalog:A(x({}),x({catalog:C(wJ),taxonomy:cq.optional()})),getTemplateCatalog:A(x({}),x({vars:C(bJ),defaults:C(gJ)})),previewTemplate:A(SJ,CJ,{kind:`mutation`,access:`view`}),getHistory:A(x({filter:kJ.default({limit:100})}),x({entries:C(OJ)}),{auth:`admin`}),getRuleLastRuns:A(x({}),jJ,{auth:`admin`}),resolveArtifactUrl:A(x({artifactId:l().min(1)}),x({url:l().nullable()}),{auth:`admin`}),listSnoozes:A(x({}),x({snoozes:C(PJ)}),{caller:`required`}),createSnooze:A(x({snooze:NJ}),x({snooze:PJ}),{kind:`mutation`,caller:`required`}),cancelSnooze:A(x({snoozeId:l()}),x({success:p(!0)}),{kind:`mutation`,caller:`required`}),getAlarmConfig:A(x({}),sY,{auth:`admin`}),setAlarmConfig:A(x({patch:bke}),sY,{kind:`mutation`,auth:`admin`}),createAlarmProfile:A(tY,sY,{kind:`mutation`,auth:`admin`}),renameAlarmProfile:A(nY,sY,{kind:`mutation`,auth:`admin`}),deleteAlarmProfile:A(rY,sY,{kind:`mutation`,auth:`admin`}),activateAlarmProfile:A(rY,sY,{kind:`mutation`,auth:`admin`}),getAlarmSensors:A(uY,dY,{auth:`admin`})},vocabulary:{notOperatorFacing:`notification rules — authored on their own page`}},Oke=S([`min`,`low`,`normal`,`high`]),kke=x({id:l().min(1),title:l().min(1),uri:r().optional(),destructive:y().optional()}),Ake=x({image:y(),priority:y(),data:y(),actions:y(),recipients:y()}),hY=x({lastSentAt:n(),lastError:l().nullable(),queueDepth:n().int().nonnegative().meta(N(`count`)),supports:Ake}),jke=x({deviceId:n().int().nonnegative(),title:l().optional(),body:l().min(1),image:l().optional(),priority:Oke.optional(),channel:l().optional(),recipients:C(l()).optional(),actions:C(kke).optional(),data:m(l(),w()).optional()}),Mke=x({notificationId:l(),acceptedAt:n()}),gY={name:`notifier`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Notifier],methods:{send:A(jke,Mke,{kind:`mutation`,auth:`admin`,actions:[{id:`notifier.send`,label:F(`Send a notification`,`Invia una notifica`),phrase:F(`Send “{body}” through {device}`,`Invia «{body}» tramite {device}`),icon:`send`,openArgs:[{key:`title`,label:F(`Title`,`Titolo`),offer:{kind:`text`},optional:!0},{key:`body`,label:F(`Message`,`Messaggio`),offer:{kind:`text`}},{key:`priority`,label:F(`Priority`,`Priorità`),offer:{kind:`enum`,values:[{value:`min`,label:F(`Minimal`,`Minima`)},{value:`low`,label:F(`Low`,`Bassa`)},{value:`normal`,label:F(`Normal`,`Normale`)},{value:`high`,label:F(`High`,`Alta`)}]},optional:!0}]}]}),cancel:A(x({deviceId:n().int().nonnegative(),notificationId:l().min(1)}),v(),{kind:`mutation`,auth:`admin`})},events:{onSent:{data:x({deviceId:n(),notificationId:l(),success:y(),error:l().nullable(),acceptedAt:n()}),notOperatorFacing:`a delivery receipt of a send this system made — not a fact about the world`}},status:{schema:hY,kind:`command-driven`},runtimeState:hY,durability:`session`,history:`none`,vocabulary:{noun:F(`Notifier`,`Notificatore`),order:2110}},_Y=x({value:n().nullable().meta(N(`device`)),lastFetchedAt:n()}),vY={name:`numeric-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:_Y,kind:`push`},runtimeState:_Y,durability:`restored`,history:{fields:{value:{kind:`gauge`,minIntervalMs:3e4}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Sensor`,`Sensore`),order:5150,state:[{kind:`numeric`,field:`value`,quantity:F(`the reading`,`il valore`),label:F(`Reading`,`Valore`),icon:`gauge`}]}},yY=x({integrationId:l(),displayName:l(),requestedScopes:C(cg),allowedRedirectPrefixes:C(l()).min(1),allowedPrivateHostPaths:C(l()).optional(),requiresPkce:y().optional(),hubUrl:l().optional(),refreshTokenTtlSec:h([n().int().positive(),p(`never`)]).optional(),instances:C(x({id:l(),displayName:l()})).optional()}),bY={name:`oauth-integration`,scope:`system`,mode:`collection`,internal:!0,methods:{getDescriptor:A(v(),yY,{auth:`admin`})},vocabulary:{notOperatorFacing:M.IDENTITY}},xY=S([`text`,`timestamp`,`watermark`]),SY=S([`top-left`,`top-center`,`top-right`,`bottom-left`,`bottom-center`,`bottom-right`,`custom`]),CY=x({id:l(),kind:xY,enabled:y(),text:l().optional(),position:SY.optional(),availablePositions:C(SY).readonly(),readOnly:y().optional(),maxCharacters:n().int().positive().optional()}),wY=x({overlays:C(CY).readonly()}),TY=x({enabled:y().optional(),text:l().optional(),position:SY.optional()}).partial(),EY={name:`osd`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],methods:{setOverlay:A(x({deviceId:n(),overlayId:l(),patch:TY}),v(),{kind:`mutation`,auth:`admin`})},events:{onStatusChanged:{data:x({deviceId:n(),status:wY}),notOperatorFacing:`an overlay setting changed — configuration, not a happening`}},status:{schema:wY,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:F(`On-screen text`,`Testo in sovrimpressione`),order:3190}},DY=1024,OY=x({id:l().min(1).max(64),name:l().min(1).max(64),text:l().max(DY).default(``)}),kY=i(`kind`,[x({kind:p(`none`)}),x({kind:p(`static`),text:l().max(DY)}),x({kind:p(`template`),templateId:l().min(1).max(64)})]),AY=x({enabled:y().default(!0),source:kY,schedule:xq.optional(),conditions:Lq.optional()}),jY=x({slotId:l(),kind:xY,readOnly:y(),cameraEnabled:y(),cameraText:l().optional(),binding:AY.nullable()}),MY=S([`written`,`unchanged`,`gated`,`unreadable`,`disabled`,`unbound`,`failed`]),NY=x({slotId:l(),outcome:MY,text:l(),reason:l().optional()}),PY=x({ok:y(),text:l(),notes:C(l())}),FY={name:`osd-manager`,scope:`system`,mode:`singleton`,methods:{getDeviceOsd:A(x({deviceId:n().int()}),x({supported:y(),slots:C(jY)}),{auth:`admin`}),getConditionSupport:A(x({}),x({supported:C(l()),catalog:C(wJ)}),{auth:`admin`}),setSlotBinding:A(x({deviceId:n().int(),slotId:l().min(1),binding:AY}),x({slot:jY,render:NY}),{kind:`mutation`,auth:`admin`}),clearSlotBinding:A(x({deviceId:n().int(),slotId:l().min(1)}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setSlotCameraEnabled:A(x({deviceId:n().int(),slotId:l().min(1),enabled:y()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),copyDeviceConfiguration:A(x({sourceDeviceId:n().int(),targetDeviceId:n().int()}),x({copied:n().int().nonnegative(),skipped:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),previewSlot:A(x({deviceId:n().int(),slotId:l().min(1),binding:AY.optional()}),NY,{kind:`mutation`,auth:`admin`}),previewTemplate:A(x({deviceId:n().int(),text:l().max(DY)}),PY,{kind:`mutation`,auth:`admin`}),renderDevice:A(x({deviceId:n().int()}),x({results:C(NY)}),{kind:`mutation`,auth:`admin`}),listTemplates:A(x({}),x({templates:C(OY)}),{auth:`admin`}),upsertTemplate:A(x({template:OY}),x({template:OY}),{kind:`mutation`,auth:`admin`}),deleteTemplate:A(x({templateId:l().min(1).max(64)}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.PIPELINE}},IY=1e4,Nke=4,Pke=200,Fke=S([`normal`,`offline`,`on_batteries`]),LY=n().int().min(4).max(200),RY=LY.meta(vhe({quantity:`mass`,unit:`g`})),zY=x({foodLevel:n().nullable().meta(N(`none`)),bowlFood:n().nullable().meta(N(`mass`)),eating:y(),supportsMarkRefilled:y(),food1:n().nullable().meta(N(`none`)),food2:n().nullable().meta(N(`none`)),lowFood:y(),batteryPower:n().min(0).max(100).nullable().meta(N(`percentage`)),powerSource:S([`mains`,`battery`]).nullable(),desiccantLeftDays:n().nullable().meta(N(`duration`)),feeding:y(),status:Fke.nullable(),error:l().nullable(),errorCode:n().nullable().meta(N(`none`)),isDualHopper:y(),childLock:y(),indicatorLight:y(),feedSound:y(),volume:n().meta(N(`none`)),lastFeedGrams:LY.nullable(),lastFeedHopper1:LY.nullable(),lastFeedHopper2:LY.nullable(),lastFetchedAt:n()}),BY={name:`pet-feeder`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.PetFeeder],methods:{feed:A(x({deviceId:n().int().nonnegative(),grams:RY.optional(),hopper1:RY.optional(),hopper2:RY.optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.feed`,label:F(`Feed`,`Dai da mangiare`),phrase:F(`Dispense {grams} from {device}`,`Eroga {grams} da {device}`),icon:`paw-print`,hold:{effects:[{field:`feeding`,value:!0}],holdMs:IY},openArgs:[{key:`grams`,label:F(`Grams`,`Grammi`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0}]},{id:`petFeeder.feedHoppers`,label:F(`Feed from both hoppers`,`Eroga da entrambi i serbatoi`),phrase:F(`Dispense {hopper1} and {hopper2} from {device}`,`Eroga {hopper1} e {hopper2} da {device}`),icon:`paw-print`,hold:{effects:[{field:`feeding`,value:!0}],holdMs:IY},openArgs:[{key:`hopper1`,label:F(`Hopper 1`,`Serbatoio 1`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0},{key:`hopper2`,label:F(`Hopper 2`,`Serbatoio 2`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0}]}]}),cancelFeed:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.cancelFeed`,label:F(`Cancel feeding`,`Annulla l’erogazione`),phrase:F(`Cancel the feeding on {device}`,`Annulla l’erogazione di {device}`),icon:`circle-x`}]}),callPet:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.callPet`,label:F(`Call pet`,`Chiama l’animale`),phrase:F(`Call your pet with {device}`,`Chiama l’animale con {device}`),icon:`megaphone`}]}),playSound:A(x({deviceId:n().int().nonnegative(),soundId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.playSound`,label:F(`Play sound`,`Riproduci un suono`),phrase:F(`Play sound {soundId} on {device}`,`Riproduci il suono {soundId} su {device}`),icon:`volume-2`,openArgs:[{key:`soundId`,label:F(`Sound`,`Suono`),offer:{kind:`number`,min:0,step:1}}]}]}),resetDesiccant:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.resetDesiccant`,label:F(`Desiccant replaced`,`Essiccante sostituito`),phrase:F(`Mark the desiccant of {device} as replaced`,`Segna come sostituito l’essiccante di {device}`),icon:`refresh-cw`}]}),markFoodReplenished:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.foodReplenished`,label:F(`Food refilled`,`Cibo ricaricato`),phrase:F(`Mark {device} as refilled`,`Segna {device} come ricaricato`),icon:`package`}]}),setChildLock:A(x({deviceId:n().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.childLockOn`,effect:{field:`childLock`,value:!0},label:F(`Child lock on`,`Blocco bambini attivo`),phrase:F(`Turn on the child lock of {device}`,`Attiva il blocco bambini di {device}`),icon:`lock`,args:{on:!0}},{id:`petFeeder.childLockOff`,effect:{field:`childLock`,value:!1},label:F(`Child lock off`,`Blocco bambini spento`),phrase:F(`Turn off the child lock of {device}`,`Disattiva il blocco bambini di {device}`),icon:`lock-open`,args:{on:!1}}]}),setIndicatorLight:A(x({deviceId:n().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.lightOn`,effect:{field:`indicatorLight`,value:!0},label:F(`Indicator light on`,`Spia accesa`),phrase:F(`Turn on the indicator light of {device}`,`Accendi la spia di {device}`),icon:`lightbulb`,args:{on:!0}},{id:`petFeeder.lightOff`,effect:{field:`indicatorLight`,value:!1},label:F(`Indicator light off`,`Spia spenta`),phrase:F(`Turn off the indicator light of {device}`,`Spegni la spia di {device}`),icon:`lightbulb-off`,args:{on:!1}}]}),setFeedSound:A(x({deviceId:n().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.feedSoundOn`,effect:{field:`feedSound`,value:!0},label:F(`Feeding sound on`,`Suono di erogazione attivo`),phrase:F(`Turn on the feeding sound of {device}`,`Attiva il suono di erogazione di {device}`),icon:`volume-2`,args:{on:!0}},{id:`petFeeder.feedSoundOff`,effect:{field:`feedSound`,value:!1},label:F(`Feeding sound off`,`Suono di erogazione spento`),phrase:F(`Turn off the feeding sound of {device}`,`Disattiva il suono di erogazione di {device}`),icon:`volume-x`,args:{on:!1}}]}),setVolume:A(x({deviceId:n().int().nonnegative(),level:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.volume`,effect:{field:`volume`,fromArg:`level`},label:F(`Set volume`,`Imposta il volume`),phrase:F(`Set the volume of {device} to {level}`,`Imposta il volume di {device} a {level}`),icon:`volume-2`,openArgs:[{key:`level`,label:F(`Volume`,`Volume`),offer:{kind:`number`,min:0,step:1}}]}]})},status:{schema:zY,kind:`poll`},runtimeState:zY,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:F(`Pet feeder`,`Distributore di cibo`),order:2030,state:[{kind:`boolean`,field:`lowFood`,label:F(`Food low`,`Cibo in esaurimento`),whenTrue:F(`When {device} runs low on food`,`Quando il cibo di {device} sta finendo`),whenFalse:F(`When {device} has enough food again`,`Quando {device} ha di nuovo cibo a sufficienza`),icon:`package`},{kind:`boolean`,field:`feeding`,label:F(`Feeding`,`In erogazione`),whenTrue:F(`When {device} starts feeding`,`Quando {device} inizia a erogare`),whenFalse:F(`When {device} finishes feeding`,`Quando {device} finisce di erogare`),icon:`paw-print`},{kind:`numeric`,field:`desiccantLeftDays`,quantity:F(`the desiccant life`,`la durata dell’essiccante`),label:F(`Desiccant`,`Essiccante`),unit:`d`,icon:`calendar-clock`}]}},VY=x({waterLevel:n().min(0).max(100).nullable().meta(N(`percentage`)),waterVolume:n().min(0).nullable().meta(N(`volume`)),empty:y().nullable(),pumpRunning:y().nullable(),error:l().nullable(),lastFetchedAt:n()}),HY=`water`;function Ike(e){let t=e.waterLevel!==null||e.empty===null?null:e.empty?`empty`:`ok`;return{key:HY,label:`Water`,level:e.waterLevel,status:t,kind:`supply`,form:`tank`,lastResetAt:null,resettable:!1}}var Lke=n().int().nonnegative(),UY={name:`pet-fountain`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.PetFountain],power:{kind:`field`,field:`pumpRunning`,set:`setPump`},methods:{setPump:A(x({deviceId:Lke,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFountain.pumpOn`,effect:{field:`pumpRunning`,value:!0},label:F(`Pump on`,`Pompa accesa`),phrase:F(`Start the pump of {device}`,`Avvia la pompa di {device}`),icon:`play`,args:{on:!0}},{id:`petFountain.pumpOff`,effect:{field:`pumpRunning`,value:!1},label:F(`Pump off`,`Pompa spenta`),phrase:F(`Stop the pump of {device}`,`Ferma la pompa di {device}`),icon:`square`,args:{on:!1}}]})},status:{schema:VY,kind:`push`},runtimeState:VY,durability:`session`,history:{fields:{waterLevel:{kind:`gauge`,unit:`%`,deadband:1},waterVolume:{kind:`gauge`,unit:`L`}}},vocabulary:{noun:F(`Pet fountain`,`Fontana per animali`),order:2040,state:[{kind:`boolean`,field:`empty`,label:F(`Tank empty`,`Serbatoio vuoto`),whenTrue:F(`When the tank of {device} is empty`,`Quando il serbatoio di {device} è vuoto`),whenFalse:F(`When the tank of {device} is refilled`,`Quando il serbatoio di {device} viene riempito`),icon:`droplet`},{kind:`numeric`,field:`waterLevel`,quantity:F(`the water level`,`il livello dell’acqua`),label:F(`Water level`,`Livello dell’acqua`),unit:`%`,icon:`droplets`}]}},Rke=S(Na),zke=2,WY={min:1,max:8},GY=S([`intel-core-ultra`,`intel-n-series`,`apple-m-base`,`apple-m-pro`,`amd-phoenix`,`nvidia-gpu`,`unknown`]),KY=S([`intel-npu`,`intel-igpu`,`amd-igpu`,`amd-npu`,`nvidia-gpu`,`x86-cpu`,`arm-cpu`,`apple-ane`,`coral`]),qY=i(`kind`,[x({kind:p(`capacity`),sessions:n(),minSessions:n()}),x({kind:p(`tie-faster`),over:l(),recallDelta:n()}),x({kind:p(`stepped-down`),from:l(),to:l(),limitedBy:l()}),x({kind:p(`no-fit-lightest`),sessions:n(),minSessions:n()}),x({kind:p(`derived-latency`),modelId:l()}),x({kind:p(`cpu-device`)}),x({kind:p(`device-disabled`)}),x({kind:p(`device-unavailable`)}),x({kind:p(`node-offline`)}),x({kind:p(`no-hardware-facts`)}),x({kind:p(`no-measured-data`),hardwareClass:GY}),x({kind:p(`no-family-build`),format:Rke}),x({kind:p(`kept-custom-pin`),modelId:l(),deviceKey:l()})]),JY=S([`custom-pin`]),YY=i(`kind`,[x({kind:p(`table`)}),x({kind:p(`node-benchmark`),resultId:l(),measuredAtMs:n()}),x({kind:p(`estimated`),estimatedFrom:GY})]),XY=x({modelId:l(),p50Ms:n(),fps:n(),measured:y(),source:YY.optional(),estimatedFrom:GY.optional(),capacitySessions:n(),personRecall:n()}),ZY=x({deviceKey:l(),accelerator:KY.nullable(),enabled:y(),available:y(),chosen:XY.nullable(),kept:JY.optional(),reasons:C(qY).readonly()}),QY=x({nodeId:l(),reachable:y(),hardwareClass:GY.nullable(),cpuModel:l().nullable(),skipped:y(),acceleratorModelId:l().nullable(),devices:C(ZY).readonly(),reasons:C(qY).readonly()}),$Y=x({stepId:l(),before:l().nullable(),after:l().nullable()}),eX=x({nodeId:l(),deviceKey:l(),madeExplicit:y(),modelPins:C($Y).readonly(),thresholds:C(x({stepId:l(),keys:C(l()).readonly()})).readonly()}),tX=i(`kind`,[x({kind:p(`custom-pin-kept`),nodeId:l(),deviceKey:l(),modelId:l()}),x({kind:p(`custom-registry-unreadable`),error:l()})]),nX=x({headroom:n().min(.3).max(.5).default(.4),minSessionsPerDevice:n().int().min(WY.min).max(WY.max).default(2)}),rX=x({planHash:l(),family:p(`yolov9`),headroom:n(),minSessionsPerDevice:n(),cameraFps:n(),generatedAt:n(),nodes:C(QY).readonly(),nodeChanges:C(eX).readonly(),warnings:C(tX).readonly()}),iX=x({planHash:l(),headroom:n().min(.3).max(.5).default(.4),minSessionsPerDevice:n().int().min(WY.min).max(WY.max).default(2)}),aX=x({phase:S([`download`,`node-models`,`redispatch`]),ok:y(),detail:l()}),oX=i(`kind`,[x({kind:p(`applied`),planHash:l(),phases:C(aX).readonly()}),x({kind:p(`aborted`),phases:C(aX).readonly()}),x({kind:p(`stale`),plan:rX}),x({kind:p(`refused`),reason:S([`apply-in-progress`])})]),sX=S([`least-loaded`,`share`]),cX=`share`,Bke=`sessionPlacement`;function Vke(e){let t=sX.safeParse(e);return t.success?t.data:cX}var lX=x({nodes:m(l(),n().positive()).default({}),devices:m(l(),m(l(),n().positive())).default({})}),uX=x({windowMs:n().int().min(6e4).max(1440*60*1e3).default(3600*1e3)}),dX=x({deviceKey:l(),sessionsNow:n(),sessionsStarted:n(),observedShare:n().nullable()}),fX=x({nodeId:l(),sessionsNow:n(),sessionsStarted:n(),observedShare:n().nullable(),peakSessions:n(),yieldsAway:n(),devices:C(dX).readonly()}),pX=x({deviceId:n(),deviceKey:l(),reason:S([`disabled`,`absent`])}),mX=x({policy:sX,windowMs:n(),observedForMs:n(),sessionsNow:n(),clusterPeakSessions:n(),nodes:C(fX).readonly(),stalePins:C(pX).readonly()}),hX=S([`hardware`,`benchmark`]),gX=S([`no-benchmark-results`,`partial-benchmark-results`]),_X=x({headroom:n().min(.3).max(.5).default(.4),source:hX.default(`hardware`)}),vX=x({deviceKey:l(),share:n(),modelId:l().nullable(),fps:n().nullable(),measured:y(),suggestedMaxSessions:n().nullable()}),yX=x({nodeId:l(),share:n().nullable(),capacitySessions:n(),devices:C(vX).readonly(),skippedReason:l().nullable(),capacitySource:hX.nullable(),capacityFallback:gX.nullable()}),bX=x({headroom:n(),source:hX,cameraFps:n(),minSessionsPerDevice:n(),nodes:C(yX).readonly()}),xX=S([`hardware`,`benchmark`,`manual`]),SX=`benchmark`;function CX(e){return e!==`manual`}var Hke=.4,Uke=`shareSource`;function Wke(e){if(e===`auto`)return`hardware`;let t=xX.safeParse(e);return t.success?t.data:SX}var wX=x({source:xX}),Gke=x({nodes:m(l(),n()),devices:m(l(),m(l(),n()))}),TX=x({deviceKey:l(),eligible:y(),configuredPct:n(),effectivePct:n()}),EX=x({nodeId:l(),eligible:y(),configuredPct:n(),effectivePct:n(),capacitySource:hX.nullable(),capacityFallback:gX.nullable(),devices:C(TX).readonly()}),DX=x({source:xX,policy:sX,autoPending:y(),computedAt:n().nullable(),trigger:l().nullable(),nodes:C(EX).readonly(),nodeWeights:m(l(),n()),deviceWeights:m(l(),m(l(),n()))}),OX=[`motion-without-detections`,`detections-under-floor`,`inference-too-slow`,`frames-shed`,`inference-device-unusable`],kX=S(OX),AX=S([`info`,`warning`,`critical`]),jX=i(`type`,[x({type:p(`camera`),deviceId:n()}),x({type:p(`node`),nodeId:l()}),x({type:p(`inference-device`),nodeId:l(),deviceKey:l()})]),MX=x({id:l(),kind:kX,severity:AX,subject:jX,what:l(),evidence:m(l(),n().nullable()),action:l()}),NX=x({source:l(),entries:n().nullable()}),PX=x({nodeId:l(),sessionsNow:n(),unusableDevices:C(l()).readonly(),devices:C(x({deviceKey:l(),sessionsNow:n(),usable:y()})).readonly()}),FX=x({deviceId:n(),nativeCropMissesSincePreviousTick:n().nullable()}),IX=x({generatedAt:n(),tickMs:n(),camerasSeen:n().nullable(),findings:C(MX).readonly(),cameraSignals:C(FX).readonly(),nodes:C(PX).readonly(),sources:C(NX).readonly(),notCovered:C(l()).readonly()}),LX=x({history:n().int().min(1).max(24).default(1)}),RX=x({latest:IX.nullable(),previous:C(IX).readonly()}),Kke=x({engine:bW.optional(),steps:C(Va).readonly(),audio:x({engine:bW.optional(),modelId:l().optional(),enabled:y(),settings:m(l(),w()).readonly().optional()}).nullable().optional()}),zX=x({modelId:l().optional(),settings:m(l(),w()).optional(),jumpDeviceKey:l().optional(),enabled:y().optional()}),BX=x({maxCameras:n().int().nonnegative().nullable().default(null),detectWeight:n().positive().optional(),detect:y().optional(),decode:y().optional(),audio:y().optional(),ingest:y().optional(),decodeBudgetMb:n().int().min(1024).max(65536).optional(),maxLiveDecodeWorkers:n().int().min(1).max(32).optional(),reachableHost:l().optional(),color:Rl.optional(),stepSettings:m(l(),m(l(),w()).readonly()).optional(),stepEnabled:m(l(),y()).optional(),inferenceDevices:m(l(),x({enabled:y(),weight:n().positive().optional(),maxSessions:n().int().positive().optional(),steps:m(l(),zX).optional()})).optional()}),qke=m(l(),m(l(),w()).readonly()),VX=S([`pipeline`,`onboard`,`none`]),Jke=x({stepToggles:m(l(),y()).optional(),stepSettings:qke.optional()}),HX=x({deviceId:n(),agentNodeId:l(),pinned:y(),reason:S([`manual`,`capacity`,`hardware-affinity`,`failover`,`rebalance`]),assignedAt:n()}),UX=x({nodeId:l(),online:y(),load:MG,score:n(),decodeHwaccel:l().nullable()}),WX=x({totalAgents:n(),onlineAgents:n(),totalCameras:n(),attachedCameras:n(),activeCameras:n(),avgInferenceTimeMs:n(),queueDepth:n()}),GX=m(l(),l()),KX=x({ownerNodeId:l(),reachableHost:l().optional(),configIssue:l().optional()}),qX=x({camStreamId:l(),codec:l(),width:n(),height:n(),fps:n(),kind:l()}),JX=x({streams:C(qX).readonly()}),YX=x({detectionNodeId:l().nullable(),decoderNodeId:l().nullable(),audioNodeId:l().nullable(),sourceNodeId:l().nullable(),pinned:x({detection:y(),decoder:y(),audio:y()}),reasons:x({detection:l().optional(),decoder:l().optional(),audio:l().optional()})}),XX=x({profile:l(),status:l(),codec:l(),width:n(),height:n(),subscribers:n(),inFps:n().nullable()}),ZX=x({profiles:C(XX).readonly(),webrtcSessions:n(),rtspRestream:y()}),QX=x({nodeId:l()}),$X=x({enabled:y(),fps:n()}),eZ=S([`idle`,`installing`,`verifying`,`ready`,`failed`]),tZ=x({state:eZ,error:l().optional()}),nZ=S([`idle`,`watching`,`active`]),rZ=x({nodeId:l(),engine:x({backend:l(),device:l()}),phase:nZ,configuredFps:n(),actualFps:n(),queueDepth:n(),avgInferenceMs:n(),provisioning:tZ}),iZ=x({nodeId:l(),enabled:y()}),aZ=um,oZ=x({mode:aZ,active:y(),storageBytes:n()}),sZ=S([`source`,`broker`,`detection`,`recording`,`switches`]),cZ=S([`timeout`,`error`,`partial`]),lZ=x({stage:sZ,reason:cZ,elapsedMs:n()}),uZ=x({state:S([`idle`,`running`,`done`,`error`]),total:n().int().nonnegative(),completed:n().int().nonnegative(),currentDeviceId:n().int().nullable(),failed:C(n().int()).readonly(),mediaDropped:n().int().nonnegative(),tracks:n().int().nonnegative(),events:n().int().nonnegative(),startedAtMs:n().int().nullable(),finishedAtMs:n().int().nullable(),error:l().nullable()}),dZ=x({deviceId:n(),assignment:YX,source:JX,broker:ZX.nullable(),decoder:QX.nullable(),motion:$X.nullable(),detection:rZ.nullable(),audio:iZ.nullable(),recording:oZ.nullable(),switchedOff:C($d).readonly(),cameraSensors:QV.optional(),degraded:C(lZ).readonly(),fetchedAt:n()}),fZ=[`disabled`,`unavailable`,`cannot-host-camera-root`,`accelerator-preferred`,`root-switched-off`,`no-gpu-device`],pZ=S(fZ),Yke=x({key:l(),backend:l(),device:l(),format:S(Na),available:y(),presence:S([`present`,`absent`,`unknown`]).optional(),enabled:y(),weight:n(),maxSessions:n().nullable(),defaultModelId:l(),steps:m(l(),zX).optional(),exclusion:pZ.nullable()}),mZ=i(`kind`,[x({kind:p(`stored`),modelId:l()}),x({kind:p(`absent`),defaultModelId:l()}),x({kind:p(`unreadable`),reason:S(dH),error:l().optional()})]),Xke=x({nodeId:l(),reachable:y(),devices:C(Yke).readonly(),defaultPoolExcluded:y().optional()}),hZ=S([`off`,`on`,`opt-in`]),gZ=i(`kind`,[x({kind:p(`on`)}),x({kind:p(`off-cluster`)}),x({kind:p(`off-node`)}),x({kind:p(`off-device`)}),x({kind:p(`jump`),toDeviceKey:l()}),x({kind:p(`skip`),reason:S([`no-compatible-model`,`root-not-runnable-on-elected-device`])}),x({kind:p(`zone-driven`)}),x({kind:p(`supplied-by-root`),rootModelId:l()}),x({kind:p(`opt-in-unused`)})]),Zke=x({deviceKey:l(),format:S(Na),stepEnabled:y().nullable(),eligible:y(),cell:gZ}),Qke=x({nodeId:l(),reachable:y(),stepEnabled:y().nullable(),devices:C(Zke).readonly()}),_Z=x({steps:C(x({stepId:l(),name:l(),slot:l(),clusterMode:hZ.nullable(),effectiveMode:hZ,camerasEnabling:n().int().nonnegative(),camerasDisabling:n().int().nonnegative(),nodes:C(Qke).readonly()})).readonly()}),vZ=x({deviceId:n().int().nonnegative(),config:GV.nullable()}),yZ=S([`unknown-camera`,`out-of-range`,`no-burst-producer`,`already-looked`]),bZ=x({deviceId:n().int().nonnegative(),afterMs:n().finite(),reason:l()}),xZ=x({scheduled:y(),dueInMs:n().optional(),refusedBecause:yZ.optional()}),SZ={name:`pipeline-orchestrator`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,exposesDeviceSettings:!0,methods:{requestOccupancyLook:A(bZ,xZ,{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:A(km,x({paused:p(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:A(km,x({resumed:p(!0)}),{kind:`mutation`,auth:`admin`}),assignPipeline:A(x({deviceId:n(),agentNodeId:l()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),unassignPipeline:A(x({deviceId:n()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setPipelineDevicePin:A(x({deviceId:n(),deviceKey:l()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getPipelineDevicePin:A(x({deviceId:n()}),x({deviceKey:l().nullable()})),rebalance:A(v(),x({migrated:n(),skipped:C(x({deviceId:n(),targetNodeId:l(),reason:l()})).default([])}),{kind:`mutation`,auth:`admin`}),getPipelineAssignments:A(v(),C(HX).readonly()),getPipelineAssignment:A(x({deviceId:n()}),HX.nullable()),getAgentLoad:A(v(),C(UX).readonly()),getClusterModelChoice:A(x({stepId:l()}),mZ),getGlobalMetrics:A(v(),WX),getCameraMetrics:A(x({deviceId:n()}),DW.nullable()),getCapabilityBindings:A(x({nodeId:l()}),GX),setCapabilityBinding:A(x({nodeId:l(),capName:l(),addonId:l()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getIngestOwner:A(v(),KX),assignAudio:A(x({deviceId:n(),nodeId:l()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),unassignAudio:A(x({deviceId:n()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getAudioAssignment:A(x({deviceId:n()}),x({nodeId:l(),pinned:y(),assignedAt:n()}).nullable()),getAudioNodeLoad:A(v(),C(x({nodeId:l(),deviceCount:n()}))),getAudioAssignments:A(v(),C(x({deviceId:n(),nodeId:l(),pinned:y(),assignedAt:n()}))),getAgentSettings:A(x({agentNodeId:l()}),BX.nullable()),listAgentSettings:A(v(),C(x({nodeId:l(),settings:BX})).readonly()),removeAgentSettings:A(x({agentNodeId:l()}),x({success:y(),removed:y()}),{kind:`mutation`,auth:`admin`}),setAgentMaxCameras:A(x({agentNodeId:l(),maxCameras:n().int().nonnegative().nullable()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setAgentCapabilities:A(x({agentNodeId:l(),detect:y().nullable().optional(),audio:y().nullable().optional(),ingest:y().nullable().optional()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setAgentDecodeLimits:A(x({agentNodeId:l(),decodeBudgetMb:n().int().min(1024).max(65536).nullable().optional(),maxLiveDecodeWorkers:n().int().min(1).max(32).nullable().optional()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setAgentReachableHost:A(x({agentNodeId:l(),reachableHost:l().nullable().optional(),color:Rl.nullable().optional()}).refine(e=>e.reachableHost!==void 0||e.color!==void 0,{message:`reachableHost or color required`}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setAgentInferenceDevices:A(x({agentNodeId:l(),inferenceDevices:m(l(),x({enabled:y(),weight:n().positive().optional(),maxSessions:n().int().positive().optional(),steps:m(l(),zX).optional()}))}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setNodeStepSettings:A(x({agentNodeId:l(),addonId:l(),settings:m(l(),w()).nullable()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setClusterStepMode:A(x({stepId:l(),mode:hZ.nullable()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setNodeStepEnabled:A(x({agentNodeId:l(),stepId:l(),enabled:y().nullable()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setDeviceStepEnabled:A(x({agentNodeId:l(),deviceKey:l(),stepId:l(),enabled:y().nullable()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getStepSwitches:A(v(),_Z),getNodeInferenceDevices:A(x({nodeId:l()}),Xke),forgetInferenceDevice:A(x({agentNodeId:l(),deviceKey:l()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),resetNodePipelineDefaults:A(x({agentNodeId:l()}),x({success:p(!0),effectiveModelId:l().nullable()}),{kind:`mutation`,auth:`admin`}),planAutoTune:A(nX,rX,{auth:`admin`}),applyAutoTune:A(iX,oX,{kind:`mutation`,auth:`admin`}),setLoadBalancingShares:A(lX,x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getPlacementStats:A(uX,mX,{auth:`admin`}),getHealthDigest:A(LX,RX,{auth:`admin`}),suggestShares:A(_X,bX,{auth:`admin`}),getEffectiveShares:A(v(),DX,{auth:`admin`}),setShareSource:A(wX,x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkPreflight:A(IW,VW,{auth:`admin`}),startNodeBenchmark:A(IW,i(`kind`,[x({kind:p(`started`),runId:l()}),x({kind:p(`refused`),preflight:VW})]),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkStatus:A(v(),nG,{auth:`admin`}),abortNodeBenchmark:A(x({runId:l()}),x({aborted:y()}),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkCandidates:A(x({nodeId:l()}),oG,{auth:`admin`}),listNodeBenchmarkResults:A(iG,C(aG).readonly(),{auth:`admin`}),deleteNodeBenchmarkResult:A(x({id:l()}),x({deleted:y()}),{kind:`mutation`,auth:`admin`}),getCameraSettings:A(x({deviceId:n()}),Jke.nullable()),setCameraStepToggle:A(x({deviceId:n(),addonId:l(),enabled:y().nullable()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getCameraDetectionSource:A(x({deviceId:n()}),x({source:VX,explicit:y(),onboard:x({available:y(),geometry:S([`boxed`,`while-streaming`,`flag-only`,`unknown`])})})),setCameraDetectionSource:A(x({deviceId:n(),source:VX}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setCameraStepSettings:A(x({deviceId:n(),addonId:l(),settings:m(l(),w()).nullable()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),resolvePipeline:A(x({deviceId:n(),agentNodeId:l().optional()}),Kke),getCameraSwitches:A(x({deviceId:n()}),of,{role:`viewer`}),setCameraSwitch:A(x({deviceId:n(),switchId:$d,enabled:y()}),of,{kind:`mutation`,auth:`admin`}),getCameraStatus:A(x({deviceId:n()}),dZ),getCameraStatuses:A(x({deviceIds:C(n()).optional()}),C(dZ).readonly()),setCameraSensors:A(vZ,x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),reconcileFromDisk:A(v(),uZ,{kind:`mutation`,auth:`admin`}),getReconcileFromDiskStatus:A(v(),uZ,{auth:`admin`})},vocabulary:{notOperatorFacing:M.PIPELINE}},CZ=x({id:l(),name:l(),sampleCount:n().int().nonnegative(),coverMediaId:n().int().optional(),coverBase64:l().optional()}),$ke=x({id:l(),text:l(),score:n(),addedAt:n().int(),deviceId:n().int().optional(),base64:l().optional(),mediaId:n().int().optional(),keyFrameMediaId:n().int().optional(),plateBbox:sC.optional()}),wZ=x({plateId:l(),deviceId:n().int(),trackId:l(),timestamp:n().int(),text:l(),score:n(),corrected:y(),recognizedVehicleId:l().optional(),vehicleName:l().optional(),assigned:y(),plateBbox:sC.optional(),keyFrameMediaId:n().int().optional(),base64:l().optional(),cropUrl:l().optional(),cropMissReason:l().optional()}),eAe=x({mediaId:n().int(),kind:l(),url:l(),sizeBytes:n(),timestamp:n()}),tAe=x({plateIds:C(l()).readonly(),representativePlateId:l(),representativeText:l(),size:n().int(),cohesion:n()}),TZ={name:`plate-gallery`,role:{feature:`plate-assignment`},scope:`system`,mode:`singleton`,methods:{listPlates:A(x({deviceId:n().int().optional(),limit:n().int().positive().optional(),includeCrops:y().optional()}).optional(),C(wZ).readonly()),getPlateByTrack:A(x({deviceId:n().int(),trackId:l()}),wZ.nullable(),{role:`viewer`}),getPlateMedia:A(x({plateId:l()}),C(eAe).readonly()),searchPlates:A(x({text:l().min(1),maxDistance:n().int().min(0).optional(),limit:n().int().positive().optional(),includeCrops:y().optional()}),C(wZ).readonly()),suggestPlateClusters:A(x({maxDistance:n().int().min(0).optional(),minClusterSize:n().int().min(2).optional(),limit:n().int().positive().optional()}).optional(),C(tAe).readonly()),correctPlateText:A(x({plateId:l(),text:l().min(1)}),v(),{kind:`mutation`,auth:`admin`}),deletePlate:A(x({plateId:l()}),v(),{kind:`mutation`,auth:`admin`}),listVehicles:A(x({includeCrops:y().optional()}).optional(),C(CZ).readonly()),createVehicle:A(x({name:l().min(1)}),CZ,{kind:`mutation`,auth:`admin`}),renameVehicle:A(x({id:l(),name:l().min(1)}),v(),{kind:`mutation`,auth:`admin`}),deleteVehicle:A(x({id:l()}),v(),{kind:`mutation`,auth:`admin`}),listVehicleSamples:A(x({vehicleId:l()}),C($ke).readonly()),removeVehicleSample:A(x({vehicleId:l(),sampleId:l()}),v(),{kind:`mutation`,auth:`admin`}),moveVehicleSample:A(x({sampleId:l().min(1),toVehicleId:l().min(1)}),v(),{kind:`mutation`,auth:`admin`}),assignPlate:A(x({plateId:l(),vehicleId:l()}),v(),{kind:`mutation`,auth:`admin`}),unassignPlate:A(x({plateId:l()}),v(),{kind:`mutation`,auth:`admin`}),assignPlates:A(x({plateIds:C(l()).min(1),vehicleId:l()}),x({assigned:n().int(),failed:C(l()).readonly()}),{kind:`mutation`,auth:`admin`}),unassignPlates:A(x({plateIds:C(l()).min(1)}),x({unassigned:n().int(),failed:C(l()).readonly()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`the plate gallery — curated on its own page`}},EZ={"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}}},"nvidia-gpu":{"nvidia-gpu":{"yolov9t-320":{p50Ms:12,fps:83,measured:!1},"yolov9t-640":{p50Ms:16,fps:62,measured:!1},"yolov9s-320":{p50Ms:13,fps:77,measured:!1},"yolov9s-640":{p50Ms:20,fps:50,measured:!1},"yolov9m-320":{p50Ms:16,fps:62,measured:!1},"yolov9m-640":{p50Ms:32,fps:31,measured:!1}}},"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}}}},DZ={"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}},OZ=.5,nAe=2,rAe=.05,iAe=24,aAe=750,oAe=64,kZ=2e3,sAe=12,AZ=n().nullable().transform(e=>e!==null&&Number.isFinite(e)&&e>0?e:null),jZ=l().nullable().transform(e=>e!==null&&e.trim()!==``?e:null),MZ=x({int8:AZ,fp16:AZ}),NZ=x({deviceKey:l(),fullDeviceName:jZ,executionUnits:AZ,clockMHz:AZ,gops:MZ.nullable(),architecture:jZ,npuName:jZ,tops:AZ,vendor:jZ,webgpuArchitecture:jZ,webgpuDevice:jZ,computeUnits:AZ}),cAe=x({accelerators:C(NZ).nullable()}),PZ=[{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*kZ}},{hardwareClass:`amd-phoenix`,accelerator:`amd-igpu`,score:{metric:`cu`,value:12}}];function lAe(e){let t=cAe.safeParse(e);return!t.success||t.data.accelerators===null?null:t.data.accelerators}function FZ(e){return e!==null&&e>0?e:null}function IZ(e){let t=[],n=FZ(e.gops?.int8??null);n!==null&&t.push({metric:`gops-int8`,value:n});let r=FZ(e.gops?.fp16??null);r!==null&&t.push({metric:`gops-fp16`,value:r});let i=FZ(e.executionUnits),a=FZ(e.clockMHz);i!==null&&a!==null&&t.push({metric:`eu-mhz`,value:i*a});let o=FZ(e.computeUnits);o!==null&&t.push({metric:`cu`,value:o});let s=FZ(e.tops);return s!==null&&t.push({metric:`tops`,value:s}),t}function LZ(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 RZ(e,t,n){for(let r of IZ(e))if(LZ(t,r,n)!==null)return r;return null}function zZ(e,t,n=PZ){return RZ(e,t,n)!==null}function BZ(e,t,n){if(t!==`unknown`)return e[t]?.[n]}function uAe(e){return Math.round(e*10)/10}function dAe(e){return Math.min(2,Math.max(OZ,e))}function fAe(e,t,n){let r={};for(let[i,a]of Object.entries(e))r[i]={p50Ms:uAe(a.p50Ms/t),fps:Math.max(1,Math.round(a.fps*t)),measured:!1,estimatedFrom:n};return r}function VZ(e){let t=e.perf??EZ,n=e.references??PZ;if(e.accelerator===`nvidia-gpu`){let e=BZ(t,`nvidia-gpu`,`nvidia-gpu`);return e===void 0?null:{column:e,estimatedFrom:null}}let r=BZ(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:RZ(e.report,e.accelerator,n);if(i===null)return r===void 0?null:{column:r,estimatedFrom:null};let a=LZ(e.accelerator,i,n),o=a===null?void 0:BZ(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:fAe(o,dAe(s),a.hardwareClass),estimatedFrom:a.hardwareClass}}var HZ=S(Na),pAe=S([`videotoolbox`,`cuda`,`nvdec`,`vaapi`,`qsv`,`d3d11va`,`dxva2`,`amf`,`vdpau`,`drm`,`coreml`,`tensorrt`,`openvino`,`directml`,`webgpu`,`none`]).nullable().optional(),mAe=x({preferred:C(l()).readonly(),rationale:l()}),UZ=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:UZ,codec:S([`H264`,`H265`]),family:S([`videotoolbox`,`vaapi`,`nvenc`,`qsv`,`amf`,`software`]),available:y(),reason:l().optional()})).readonly(),defaultH264:UZ,defaultH265:UZ,probedAt:n()}),x({methods:C(l()).readonly(),probedAt:n()});var hAe=S([`darwin`,`linux`,`win32`]),gAe=S([`arm64`,`x64`]),_Ae=x({type:S([`nvidia`,`amd`,`intel`,`apple`]),name:l(),memoryMB:n().optional()}),vAe=x({type:S([`apple-ane`,`intel-npu`,`amd-xdna`]),name:l().optional(),generation:S([`xdna1`,`xdna2`]).optional()}),WZ=S([`usb`,`pci`]),yAe=x({type:p(`coral-edgetpu`),bus:l().optional(),count:n().int().nonnegative().optional(),units:C(x({bus:WZ,count:n().int().nonnegative()})).readonly().optional(),unavailable:C(x({bus:WZ,count:n().int().nonnegative(),reason:S([`driver-missing`,`device-not-accessible`])})).readonly().optional()}),GZ=x({type:p(`nvidia`),name:l(),memoryMB:n().optional()}),bAe=i(`usable`,[GZ.extend({usable:p(!0)}),GZ.extend({usable:p(!1),reason:S([`no-cuda-execution-provider`])})]),KZ=x({platform:hAe,arch:gAe,cpuModel:l(),cpuCores:n(),totalRAM_MB:n(),availableRAM_MB:n(),gpu:_Ae.nullable(),npu:vAe.nullable(),coral:yAe.nullable().optional(),nvidia:bAe.nullable().optional(),accelerators:C(NZ).readonly().optional()}),qZ=x({runtime:p(`python`),backend:l(),format:S([`onnx`,`coreml`,`openvino`,`tflite`]),score:n(),reason:l(),available:y()}),JZ=x({key:l(),backend:l(),device:l(),format:HZ,runtime:p(`python`),score:n(),available:y()}),xAe=x({hardware:KZ,scores:C(qZ).readonly(),bestScore:qZ,pythonPath:l().nullable(),devices:C(JZ).readonly()}),SAe=x({modelId:l(),name:l(),minRAM_MB:n(),accuracyScore:n(),formats:C(l()).readonly()}),CAe=x({modelId:l(),runtime:p(`python`),backend:l(),format:HZ,reason:l()}),wAe=x({devices:C(JZ).readonly(),appeared:C(l()).readonly(),disappeared:C(l()).readonly(),usbBus:S([`observed`,`unobservable`]),decidedBy:S([`usb-ids`,`pci`,`delegate-fallback`,`none`])}),YZ={name:`platform-probe`,scope:`system`,mode:`singleton`,methods:{getCapabilities:A(v(),xAe),getHardware:A(v(),KZ),resolveInferenceConfig:A(x({requirements:C(SAe).readonly()}),CAe),resolveHwAccel:A(x({prefer:pAe}),mAe),rescanAccelerators:A(v(),wAe,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.CLUSTER}},XZ=x({power:n().optional().meta(N(`power`,{label:`Power`})),deliveredPower:n().optional().meta(N(`power`,{label:`Delivered`})),energy:n().optional().meta(N(`energy`,{label:`Energy`})),voltage:n().optional().meta(N(`voltage`,{label:`Voltage`})),current:n().optional().meta(N(`current`,{label:`Current`})),apparentPower:n().optional().meta(N(`apparent-power`)),powerFactor:n().min(0).max(1).optional().meta(N(`ratio`)),lastFetchedAt:n()});function TAe(e){if(e.power===void 0)return;let t=e.power-(e.deliveredPower??0);return t<0?void 0:t}var ZZ=[E.Sensor,E.Switch,E.Light,E.Fan,E.Climate,E.Humidifier,E.WaterHeater,E.MediaPlayer,E.Washer,E.Dryer,E.Dishwasher,E.Vacuum,E.LawnMower,E.PetFeeder,E.Workload],EAe=ZZ.filter(e=>e!==E.Sensor);function QZ(e,t){return{id:e,cardinality:`scalar`,vocabulary:{cap:`power-meter`,stateField:e},deviceTypes:EAe,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 DAe={version:1,targets:[QZ(`power`,`W`),QZ(`energy`,`kWh`),QZ(`voltage`,`V`),QZ(`current`,`A`)]},$Z={name:`power-meter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:ZZ,deviceConfig:{ui:{kind:`widget`,widgetId:`host/power-meter-line`,tab:`power`,placement:`hero`,label:`Power`,order:4}},methods:{},status:{schema:XZ,kind:`push`},runtimeState:XZ,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:DAe,vocabulary:{noun:F(`Power meter`,`Misuratore di energia`),order:5160,state:[{kind:`numeric`,field:`power`,quantity:F(`the power draw`,`il consumo`),label:F(`Power`,`Potenza`),unit:`W`,icon:`zap`},{kind:`numeric`,field:`energy`,quantity:F(`the energy used`,`l’energia consumata`),label:F(`Energy`,`Energia`),unit:`kWh`,icon:`zap`},{kind:`numeric`,field:`voltage`,quantity:F(`the voltage`,`la tensione`),label:F(`Voltage`,`Tensione`),unit:`V`,icon:`zap`},{kind:`numeric`,field:`current`,quantity:F(`the current`,`la corrente`),label:F(`Current`,`Corrente`),unit:`A`,icon:`zap`}]}},OAe=x({latitude:n().min(-90).max(90).meta(N(`angle`)),longitude:n().min(-180).max(180).meta(N(`angle`)),accuracyMeters:n().nonnegative().meta(N(`length`))}),eQ=x({state:l(),location:l().nullable(),gps:OAe.nullable(),lastChangedAt:n()}),tQ={name:`presence`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Presence],methods:{},status:{schema:eQ,kind:`push`},runtimeState:eQ,durability:`restored`,history:`none`,volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Presence`,`Presenza`),order:5170,state:[{kind:`value`,field:`state`,label:F(`Where`,`Posizione`),phrase:F(`When {device} is at {value}`,`Quando {device} è in {value}`),icon:`map-pin`}]}},nQ=x({pressure:n().nullable().meta(N(`pressure`,{precision:0})),lastFetchedAt:n()}),rQ={name:`pressure-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:nQ,kind:`push`},runtimeState:nQ,durability:`restored`,history:{fields:{pressure:{kind:`gauge`,unit:`hPa`,deadband:.1}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Pressure`,`Pressione`),order:5180,state:[{kind:`numeric`,field:`pressure`,quantity:F(`the pressure`,`la pressione`),label:F(`Pressure`,`Pressione`),unit:`hPa`,icon:`gauge`}]}},iQ=i(`kind`,[iH,aH]),aQ=x({id:n(),enabled:y(),shape:iQ}),oQ=x({enabled:y(),regions:C(aQ).nullable(),audioEnabled:y().nullable(),lastFetchedAt:n()}),sQ=x({maxRegions:n(),supportedShapes:C(cH),polygonVertices:lH.optional(),supportsAudioMute:y()}),cQ=x({enabled:y().optional(),regions:C(aQ).optional()}),lQ={name:`privacy-mask`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/privacy-mask-grid`,tab:`image`,label:`Privacy Mask`}},methods:{getOptions:A(x({deviceId:n()}),sQ),setMask:A(x({deviceId:n(),patch:cQ}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`privacy.maskOn`,label:F(`Privacy mask on`,`Maschera privacy attiva`),phrase:F(`Cover the privacy zones of {device}`,`Oscura le zone private di {device}`),icon:`eye-off`,args:{patch:{enabled:!0}}},{id:`privacy.maskOff`,label:F(`Privacy mask off`,`Maschera privacy spenta`),phrase:F(`Uncover the privacy zones of {device}`,`Scopri le zone private di {device}`),icon:`eye`,args:{patch:{enabled:!1}}}]}),setAudioEnabled:A(x({deviceId:n(),enabled:y()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`privacy.micOn`,label:F(`Microphone on`,`Microfono attivo`),phrase:F(`Turn on the microphone of {device}`,`Attiva il microfono di {device}`),icon:`mic`,args:{enabled:!0}},{id:`privacy.micOff`,label:F(`Microphone off`,`Microfono spento`),phrase:F(`Turn off the microphone of {device}`,`Disattiva il microfono di {device}`),icon:`mic-off`,args:{enabled:!1}}]})},status:{schema:oQ,kind:`poll`},runtimeState:oQ,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Privacy`,`Privacy`),order:3210,state:[{kind:`boolean`,field:`enabled`,label:F(`Privacy mask`,`Maschera privacy`),whenTrue:F(`When the privacy mask of {device} is turned on`,`Quando si attiva la maschera privacy di {device}`),whenFalse:F(`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:F(`Microphone`,`Microfono`),whenTrue:F(`When the microphone of {device} is turned on`,`Quando si attiva il microfono di {device}`),whenFalse:F(`When the microphone of {device} is turned off`,`Quando si disattiva il microfono di {device}`),icon:`mic`}]}};function kAe(e){return e.length===0?null:e.some(e=>e.audioEnabled)}var uQ=S([`home`,`day-mode`,`night-mode`,`day-night-auto`,`set-limits`,`save-limits`,`reboot`,`osd-menu`]),dQ=x({id:l(),name:l(),fn:uQ.nullable(),writable:y()}),fQ=x({pan:n().nullable(),tilt:n().nullable(),zoom:n().nullable()}),pQ=x({pan:n().optional(),tilt:n().optional(),zoom:n().optional(),speed:n().optional()}),mQ=fQ.extend({autofocus:y()}),hQ=x({hasPan:y(),hasTilt:y(),hasZoom:y(),supportsPresets:y(),maxPresets:n().optional(),hasAutofocus:y(),speedSteps:n().int().positive().nullable(),moveImpulseMs:n().int().positive().nullable()}),gQ=x({presetId:l().nullable(),source:S([`operator`,`firmware`,`native`,`none`])}),_Q=x({enabled:y(),seconds:n().int()}),vQ={name:`ptz`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/ptz-panel`,tab:`ptz`,topTab:!0,label:`PTZ`,order:0}},methods:{move:A(pQ.extend({deviceId:n()}),v(),{kind:`mutation`,notOperatorFacing:`a relative nudge from the live-view joystick; a fixed place is a preset`}),continuousMove:A(pQ.extend({deviceId:n()}),v(),{kind:`mutation`,notOperatorFacing:`joystick motion held until released — continuous, not a discrete step`}),goHome:A(x({deviceId:n()}),v(),{kind:`mutation`,actions:[{id:`ptz.goHome`,label:F(`PTZ go home`,`Torna alla posizione iniziale`),phrase:F(`Send {device} to its home position`,`Riporta {device} alla posizione iniziale`),icon:`house`}]}),getPresets:A(x({deviceId:n()}),C(dQ)),goToPreset:A(x({deviceId:n(),presetId:l()}),v(),{kind:`mutation`,actions:[{id:`ptz.goToPreset`,label:F(`PTZ go to preset`,`Vai a un preset`),phrase:F(`Move {device} to {presetId}`,`Sposta {device} su {presetId}`),icon:`move`,openArgs:[{key:`presetId`,label:F(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}}]}]}),savePreset:A(x({deviceId:n(),presetId:l(),name:l()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.savePreset`,label:F(`Save PTZ preset here`,`Salva qui un preset`),phrase:F(`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:F(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}},{key:`name`,label:F(`Name`,`Nome`),offer:{kind:`text`}}]}]}),deletePreset:A(x({deviceId:n(),presetId:l()}),v(),{kind:`mutation`,auth:`admin`}),getOptions:A(x({deviceId:n()}),hQ),stop:A(x({deviceId:n()}),v(),{kind:`mutation`,actions:[{id:`ptz.stop`,label:F(`Stop moving`,`Ferma il movimento`),phrase:F(`Stop {device} moving`,`Ferma il movimento di {device}`),icon:`square`}]}),getHomePreset:A(x({deviceId:n()}),gQ),setHomePreset:A(x({deviceId:n(),presetId:l().nullable()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.setHomePreset`,label:F(`Set PTZ home preset`,`Imposta il preset iniziale`),phrase:F(`Make {presetId} the home position of {device}`,`Rendi {presetId} la posizione iniziale di {device}`),icon:`house`,openArgs:[{key:`presetId`,label:F(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}}]}]}),captureHomeHere:A(x({deviceId:n()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.captureHomeHere`,label:F(`Set PTZ home here`,`Imposta qui la posizione iniziale`),phrase:F(`Make where {device} points now its home position`,`Rendi la posizione attuale di {device} la sua posizione iniziale`),icon:`map-pin`}]}),getHomeReturn:A(x({deviceId:n()}),_Q.nullable()),setHomeReturn:A(x({deviceId:n(),enabled:y(),seconds:n().int().min(0).max(3600)}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.setHomeReturn`,label:F(`Set PTZ return home`,`Imposta il ritorno alla posizione iniziale`),phrase:F(`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:F(`Return home`,`Torna alla posizione iniziale`),offer:{kind:`boolean`}},{key:`seconds`,label:F(`Idle seconds`,`Secondi da fermo`),offer:{kind:`number`,min:0,max:3600,step:1,unit:`s`}}]}]}),getPosition:A(x({deviceId:n()}),fQ),setAutofocus:A(x({deviceId:n(),enabled:y()}),v(),{kind:`mutation`,actions:[{id:`ptz.autofocusOn`,label:F(`Autofocus on`,`Autofocus attivo`),phrase:F(`Turn on autofocus on {device}`,`Attiva l’autofocus su {device}`),icon:`focus`,args:{enabled:!0}},{id:`ptz.autofocusOff`,label:F(`Autofocus off`,`Autofocus spento`),phrase:F(`Turn off autofocus on {device}`,`Disattiva l’autofocus su {device}`),icon:`focus`,args:{enabled:!1}}]})},status:{schema:mQ,kind:`command-driven`},vocabulary:{noun:F(`Pan / tilt / zoom`,`Brandeggio`),order:3220}},yQ=x({targetType:l().describe(`Vendor target string (people/vehicle/pet); empty = camera default`),stopDelaySeconds:n().int().min(0).max(300).meta(N(`duration`)),disappearDelaySeconds:n().int().min(0).max(300).meta(N(`duration`))}),bQ=x({value:l(),label:l()}),xQ=x({enabled:y(),lastChangedAt:n(),currentSettings:yQ.nullable(),supportedTargetTypes:C(bQ)}),SQ=xQ.extend({lastFetchedAt:n()}),CQ={name:`ptz-autotrack`,scope:`device`,deviceNative:!0,mode:`singleton`,kind:`wrapper`,defaultActive:!1,deviceTypes:[E.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/ptz-autotrack`,tab:`ptz`,topTab:!0,label:`Auto-Tracking`,order:5}},methods:{getStatus:A(x({deviceId:n()}),xQ),setEnabled:A(x({deviceId:n(),enabled:y()}),v(),{kind:`mutation`,actions:[{id:`ptz.autotrackOn`,label:F(`Autotrack on`,`Inseguimento attivo`),phrase:F(`Start autotracking on {device}`,`Attiva l’inseguimento automatico su {device}`),icon:`crosshair`,args:{enabled:!0}},{id:`ptz.autotrackOff`,label:F(`Autotrack off`,`Inseguimento spento`),phrase:F(`Stop autotracking on {device}`,`Disattiva l’inseguimento automatico su {device}`),icon:`crosshair`,args:{enabled:!1}}]}),getSettings:A(x({deviceId:n()}),yQ.nullable()),setSettings:A(x({deviceId:n(),settings:yQ.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:n(),status:xQ}),notOperatorFacing:"the `enabled` state trigger phrases both edges of this change"}},status:{schema:xQ,kind:`command-driven`},runtimeState:SQ,durability:`session`,history:`none`,vocabulary:{noun:F(`Autotracking`,`Inseguimento automatico`),order:3230,state:[{kind:`boolean`,field:`enabled`,label:F(`Autotracking`,`Inseguimento automatico`),whenTrue:F(`When autotracking is turned on for {device}`,`Quando si attiva l’inseguimento automatico di {device}`),whenFalse:F(`When autotracking is turned off for {device}`,`Quando si disattiva l’inseguimento automatico di {device}`),icon:`crosshair`}]}},wQ=x({enabled:y().nullable(),onTime:n().min(0).nullable().meta(N(`duration`)),offTime:n().min(0).nullable().meta(N(`duration`)),lastFetchedAt:n()}),TQ=n().int().nonnegative(),EQ=n().int().min(0),DQ={name:`pump-cycle`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.PetFountain],methods:{setEnabled:A(x({deviceId:TQ,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.on`,effect:{field:`enabled`,value:!0},label:F(`Pump cycle on`,`Ciclo pompa attivo`),phrase:F(`Run the pump of {device} on its on/off cycle`,`Fai lavorare la pompa di {device} a ciclo acceso/spento`),icon:`timer`,args:{on:!0}},{id:`pumpCycle.off`,effect:{field:`enabled`,value:!1},label:F(`Pump cycle off`,`Ciclo pompa spento`),phrase:F(`Run the pump of {device} continuously`,`Fai lavorare la pompa di {device} in continuo`),icon:`timer-off`,args:{on:!1}}]}),setOnMinutes:A(x({deviceId:TQ,minutes:EQ}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.onMinutes`,label:F(`Set pump run time`,`Imposta il tempo di lavoro della pompa`),phrase:F(`Set the pump of {device} to run {minutes} minutes per cycle`,`Imposta la pompa di {device} a lavorare {minutes} minuti per ciclo`),icon:`timer`,effect:{field:`onTime`,fromArg:`minutes`,scale:60},openArgs:[{key:`minutes`,label:F(`Minutes`,`Minuti`),offer:{kind:`number`,min:0,step:1,unit:`min`}}]}]}),setOffMinutes:A(x({deviceId:TQ,minutes:EQ}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.offMinutes`,label:F(`Set pump rest time`,`Imposta il tempo di riposo della pompa`),phrase:F(`Set the pump of {device} to rest {minutes} minutes per cycle`,`Imposta la pompa di {device} a riposare {minutes} minuti per ciclo`),icon:`timer-off`,effect:{field:`offTime`,fromArg:`minutes`,scale:60},openArgs:[{key:`minutes`,label:F(`Minutes`,`Minuti`),offer:{kind:`number`,min:0,step:1,unit:`min`}}]}]})},status:{schema:wQ,kind:`push`},runtimeState:wQ,durability:`session`,history:`none`,vocabulary:{noun:F(`Pump cycle`,`Ciclo della pompa`),order:2050,state:[{kind:`boolean`,field:`enabled`,label:F(`Pump cycle`,`Ciclo pompa`),whenTrue:F(`When {device} starts running its pump on a cycle`,`Quando {device} inizia a far lavorare la pompa a ciclo`),whenFalse:F(`When {device} runs its pump continuously`,`Quando {device} fa lavorare la pompa in continuo`),icon:`timer`}]}},OQ={name:`reboot`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera,E.Sensor,E.Switch,E.Gateway],methods:{reboot:A(x({deviceId:n().int().nonnegative()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`,actions:[{id:`reboot.reboot`,label:F(`Reboot device`,`Riavvia il dispositivo`),phrase:F(`Reboot {device}`,`Riavvia {device}`),icon:`refresh-cw`}]})},vocabulary:{noun:F(`Reboot`,`Riavvio`),order:3240}},kQ=x({owner:l(),kind:pi,title:l(),nameField:l(),fields:m(l(),w()),secretPaths:C(l()),rows:n().int().nonnegative()}),AQ=x({id:uV,name:l(),rev:n().int(),updatedAt:n(),data:dV}),jQ={owner:l().min(1),kind:pi},MQ={name:`record-entries`,scope:`system`,mode:`singleton`,methods:{listEntryKinds:A(x({}),x({kinds:C(kQ)}),{auth:`admin`}),listEntries:A(x({...jQ}),x({entries:C(AQ)}),{auth:`admin`}),putEntry:A(x({...jQ,id:uV.optional(),data:dV,ifRev:n().int().min(1).optional()}),x({id:l(),rev:n().int()}),{kind:`mutation`,auth:`admin`}),deleteEntry:A(x({...jQ,id:uV}),x({deleted:y()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.INTERNAL}},AAe=`camstack`,jAe=`recorder`,NQ=x({profile:l(),startMs:n(),endMs:n()}),PQ=S([`read`,`unreadable`]),FQ=x({deviceId:n(),read:PQ,ranges:C(NQ),profilesWithFootage:C(l())}),IQ=x({deviceId:n(),read:PQ,days:C(n())}),LQ=x({deviceId:n(),localMasterPath:l().nullable(),playbackUrl:l().nullable(),playbackEndpoints:C(l())}),RQ=x({state:S([`ok`,`sleeping`,`unreachable`,`no-storage`,`index-empty`]),reason:l().optional(),coverageAsOf:n().optional()}),zQ=x({source:l(),label:l(),addonId:l().optional(),availability:RQ}),BQ=x({transport:S([`archive`,`stream`,`realtime`]),coverage:S([`continuous`,`sparse`]),seek:S([`free`,`forward`,`segment`]),stepBack:y(),scrub:y(),rates:C(n().positive()).min(1).readonly(),exclusive:y()}),VQ=i(`kind`,[x({kind:p(`hls`),manifest:LQ}),x({kind:p(`clip`),source:l(),clipId:l(),startsAtMs:n()}),x({kind:p(`none`),reason:l()})]),HQ={name:`recording`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:[E.Camera],methods:{listSources:A(x({deviceId:n()}),C(zQ).readonly(),{kind:`query`,auth:`protected`}),getAvailability:A(x({deviceId:n(),provider:l().min(1),fromMs:n(),toMs:n(),profile:l().optional()}),FQ,{kind:`query`,auth:`protected`}),getDaysWithRecordings:A(x({deviceId:n(),provider:l().min(1),fromMs:n(),toMs:n(),tzOffsetMinutes:n()}),IQ,{kind:`query`,auth:`protected`}),getPlayback:A(x({deviceId:n(),provider:l().min(1),fromMs:n(),toMs:n(),profile:P.optional()}),VQ,{kind:`query`,auth:`protected`}),getPlaybackOptions:A(x({deviceId:n(),provider:l().min(1)}),BQ,{kind:`query`,auth:`protected`})},vocabulary:{noun:F(`Recording`,`Registrazione`),order:3250}},UQ=x({deviceId:n(),enabled:y(),activeMode:um,nodeId:l(),storageBytes:n()}),MAe=200,WQ=x({deviceId:n(),read:S([`read`,`unreadable`]),ranges:C(NQ).readonly(),profilesWithFootage:C(l()).readonly()}),GQ=x({deviceId:n(),read:S([`read`,`unreadable`]),days:C(n()).readonly()}),KQ=x({deviceId:n(),usedBytes:n(),oldestMs:n().nullable().optional(),segments:n().optional(),residentBytes:n().optional(),residentOldestMs:n().nullable().optional()}),qQ=x({locationId:l().nullable(),locationIds:C(l()).optional(),root:l().optional(),usedBytes:n(),availableBytes:n().nullable(),totalBytes:n().nullable()}),JQ=x({nodeId:l(),totalUsedBytes:n(),devices:C(KQ),devicesRead:S([`archive`,`unavailable`]).optional(),complete:y().optional(),locations:C(qQ).optional()}),YQ=x({deviceId:n(),profile:l(),fromLocationId:l(),toLocationId:l(),bytes:n(),files:n().int()}),XQ=S([`unassigned`,`target-not-writable`,`below-threshold`,`no-headroom`]),ZQ=x({deviceId:n(),profile:l(),fromLocationId:l(),toLocationId:l().nullable(),bytes:n(),reason:XQ}),QQ=x({moves:C(YQ),skipped:C(ZQ),bytesToMove:n(),jobIds:C(l())}),$Q=x({throttleMbps:n().min(1).max(1e3).optional(),minMoveGb:n().min(0).optional()}),NAe=x({deviceId:n().int(),profile:l(),locationId:l()}),PAe=x({deviceId:n().int(),locationId:l()}),FAe=x({assignments:C(NAe),pins:C(PAe),defaultLocations:m(l(),l())}),IAe=x({deviceId:n().int(),locationId:l().nullable()}),e$=i(`kind`,[x({kind:p(`segment`),startMs:n(),durMs:n(),bytes:n()}),x({kind:p(`gap`),nearestEdgeMs:n().nullable(),prevEndMs:n().nullable().optional()})]),t$=x({data:b(Uint8Array)}),n$=x({data:b(Uint8Array),gopStartMs:n(),gopDurMs:n()}),r$=i(`kind`,[x({kind:p(`ok`),data:b(Uint8Array),gopStartMs:n(),gopDurMs:n(),reachesRequestedEnd:y()}),x({kind:p(`spans-multiple-segments`),segmentEndMs:n()})]),i$={name:`recording-archive`,scope:`system`,mode:`singleton`,exposesDeviceSettings:!0,status:{schema:UQ,kind:`command-driven`},methods:{getAvailabilityBatch:A(x({deviceIds:C(n()).min(1).max(200),fromMs:n(),toMs:n()}),C(WQ).readonly(),{role:`viewer`,kind:`query`,auth:`protected`}),getDaysWithRecordingsBatch:A(x({deviceIds:C(n()).min(1).max(200),fromMs:n(),toMs:n(),tzOffsetMinutes:n()}),C(GQ).readonly(),{role:`viewer`,kind:`query`,auth:`protected`}),getStorageUsage:A(x({}),JQ,{kind:`query`,auth:`admin`}),getDeviceConfig:A(x({deviceId:n()}),xm,{role:`viewer`,kind:`query`,auth:`protected`}),locateSegment:A(x({deviceId:n(),profile:l(),epochMs:n()}),e$,{kind:`query`,auth:`admin`}),readSegmentBytes:A(x({deviceId:n(),profile:l(),startMs:n()}),t$,{kind:`query`,auth:`admin`}),readGopBytes:A(x({deviceId:n(),profile:l(),startMs:n(),epochMs:n()}),n$,{kind:`query`,auth:`admin`}),readWindowBytes:A(x({deviceId:n(),profile:l(),startMs:n(),fromMs:n(),toMs:n()}),r$,{kind:`query`,auth:`admin`}),setDeviceConfig:A(x({deviceId:n(),config:xm}),xm,{kind:`mutation`,auth:`admin`}),rescanStorage:A(x({deviceId:n()}),UQ,{kind:`mutation`,auth:`admin`}),pruneFootage:A(x({deviceId:n(),reason:em.optional()}),x({floorMs:n().nullable(),deletedBuckets:n().int(),reclaimedBytes:n().int()}),{kind:`mutation`,auth:`admin`}),deleteFootprint:A(x({deviceId:n(),fromMs:n().optional(),toMs:n().optional()}),x({deletedBuckets:n().int(),reclaimedBytes:n().int()}),{kind:`mutation`,auth:`admin`}),listOpsLog:A(nm,C(tm).readonly(),{kind:`query`,auth:`admin`}),renderGif:A(x({deviceId:n(),aroundMs:n(),preRollSec:n().min(0).max(30).default(2),postRollSec:n().min(0).max(30).default(5),maxWidth:n().int().min(120).max(1280).default(480),fps:n().int().min(1).max(15).default(5)}),x({gifBase64:l(),fromMs:n(),toMs:n()}),{kind:`mutation`,auth:`admin`}),renderClip:A(x({deviceId:n(),aroundMs:n(),preRollSec:n().min(0).max(30).default(3),postRollSec:n().min(0).max(30).default(7),maxWidth:n().int().min(160).max(1920).default(640)}),x({clipBase64:l(),mime:l(),fromMs:n(),toMs:n(),bytes:n().int()}),{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:A(km,x({paused:p(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:A(km,x({resumed:p(!0)}),{kind:`mutation`,auth:`admin`}),refreshStorageLocationsForMigration:A(km,x({refreshed:p(!0)}),{kind:`mutation`,auth:`admin`}),startStorageMigrationMove:A(Am,x({jobId:l()}),{kind:`mutation`,auth:`admin`}),getStorageMigrationMoveStatus:A(x({jobId:l()}),Em.nullable(),{auth:`admin`}),cancelStorageMigrationMove:A(x({jobId:l()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),relocateFootage:A(Om,x({jobId:l()}),{kind:`mutation`,auth:`admin`}),listRelocateJobs:A(x({}),C(Em).readonly(),{kind:`query`,auth:`admin`}),getRelocateResidue:A(nh,rh,{kind:`query`,auth:`admin`}),reconcileLedgerAgainstDisk:A(ih,ch,{kind:`mutation`,auth:`admin`}),cancelRelocateJob:A(x({jobId:l()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),planStorageRebalance:A($Q,QQ,{kind:`query`,auth:`admin`}),startStorageRebalance:A($Q,QQ,{kind:`mutation`,auth:`admin`}),getPlacement:A(x({}),FAe,{kind:`query`,auth:`admin`}),setDevicePlacement:A(IAe,x({ok:p(!0)}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.STORAGE}},LAe=24,RAe=3,zAe=S([`queue-full`,`camera-backoff`,`sleeping`,`camera-refused`,`no-keyframe`,`decode-failed`,`no-catalog-row`,`unsupported`,`unknown-device`,`uid-missing`]),BAe=S([`deferred`,`final`]),VAe=`x-camstack-reason`,HAe=500;function UAe(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 WAe=`x-camstack-reason-code`,GAe=`x-camstack-disposition`,KAe=`x-camstack-clip-transport`,a$=x({id:l(),source:l(),kind:S([`motion`,`object`,`audio`,`native`]),timeRange:x({startMs:n(),endMs:n()}),labels:C(l()).max(3).optional(),thumbnail:l().optional(),stillAtMs:n().optional(),eventIds:C(l()).optional(),eventCount:n().int().nonnegative().optional(),holes:C(x({startMs:n(),endMs:n()})).optional(),thumbnailMint:l().optional(),thumbnailUnavailable:x({reason:S([`sleeping`,`camera-refused`,`no-keyframe`,`unsupported`])}).optional(),catalogAsOf:n().optional(),nativeTypes:C(l()).optional(),behaviours:C(l()).optional(),streams:x({sub:x({id:l(),bytes:n().optional()}).optional(),main:x({id:l(),bytes:n().optional()}).optional()}).optional(),supportSub:y().optional(),playable:y().optional(),unplayableReason:l().optional(),inProgress:y().optional()}),o$=x({playbackUrl:l(),format:S([`hls`,`mp4`]).optional(),served:P.optional(),playbackEndpoints:C(l()).optional(),token:l().optional()}),s$=S([`authorised`]),qAe=50*1024*1024,JAe=500*1024*1024,c$=x({base64:l(),contentType:l(),name:l(),bytes:n().int().nonnegative(),served:P,durationMs:n().positive().optional()}),l$=x({ticket:Si,contentType:l(),name:l(),served:P,durationMs:n().positive().optional()}),u$=S([`opus`,`pcmu`,`none`]),d$=S([`not-requested`,`unsupported-ask`]),f$=x({url:l().min(1),expiresAtMs:n(),transport:p(`forward-only`),served:P,servedAudio:u$,audioReason:d$.optional()}),p$=[.25,.5,1,1.5,2,4,8],m$=[.25,.5,1,1.5,2,4],h$=[.25,.5,1],g$=x({transport:S([`stream`,`file`]),seek:S([`forward`,`free`]),stepBack:y(),scrub:y(),rates:C(n().positive()).min(1).readonly()}),_$=x({state:S([`ok`,`sleeping`,`unreachable`,`no-storage`,`index-empty`]),reason:l().optional(),catalogAsOf:n().optional()}),v$=x({source:l(),label:l(),addonId:l().optional(),availability:_$}),y$={name:`videoclips`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:[E.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/clips-browser`,tab:`recording`,topTab:!0,label:`Clips`,order:100}},methods:{listClips:A(x({deviceId:n(),since:n(),until:n(),limit:n().int().positive().optional(),provider:l().min(1)}),C(a$).readonly(),{kind:`query`,auth:`protected`}),listSources:A(x({deviceId:n()}),C(v$).readonly(),{kind:`query`,auth:`protected`}),getClipPlayback:A(x({deviceId:n(),clipId:l(),profile:P.optional()}),o$,{kind:`query`,auth:`protected`}),readClipBytes:j(x({deviceId:n(),clipId:l().min(1),provider:l().min(1),profile:P.optional(),maxBytes:n().int().positive().optional(),wake:s$.optional()}),c$,{kind:`query`,auth:`protected`}),offerClipBytes:j(x({deviceId:n(),clipId:l().min(1),provider:l().min(1),profile:P.optional(),maxBytes:n().int().positive().optional(),wake:s$.optional()}),l$,{kind:`query`,auth:`protected`}),dialClipStream:j(x({deviceId:n(),clipId:l().min(1),provider:l().min(1),profile:P.optional(),audio:u$.optional(),wake:s$.optional()}),f$,{kind:`query`,auth:`protected`}),getPlaybackOptions:j(x({deviceId:n(),provider:l().min(1)}),g$,{kind:`query`,auth:`protected`})},vocabulary:{noun:F(`Video clips`,`Clip video`),order:3330}},YAe={stream:{transport:`stream`,seek:`forward`,stepBack:!1,scrub:!1,rates:m$},realtimeStream:{transport:`stream`,seek:`forward`,stepBack:!1,scrub:!1,rates:h$},file:{transport:`file`,seek:`free`,stepBack:!0,scrub:!0,rates:p$}},b$=n().min(.25).max(32),x$=x({fromSec:n().nonnegative(),toSec:n().nonnegative()}).refine(e=>e.toSec>e.fromSec,{message:`dense range must have toSec > fromSec`}),XAe=200,S$=x({everyMs:n().int().positive(),ranges:C(x$).min(1).max(200)}),C$=x({everyMs:n().int().positive(),outputFps:n().int().min(1).max(60).optional(),dense:S$.optional()}).superRefine((e,t)=>{e.dense!==void 0&&e.dense.everyMs>=e.everyMs&&t.addIssue({code:le.custom,message:`dense.everyMs must be strictly smaller than the base everyMs`,path:[`dense`,`everyMs`]})}),w$=x({speed:b$.optional(),timelapse:C$.optional(),includeAudio:y(),maxLifeMs:n().int().positive(),deleteAfterDownload:y(),title:l().max(200).optional(),notifyTargetIds:C(l().min(1)).max(20).optional()}).superRefine((e,t)=>{e.speed!==void 0&&e.timelapse!==void 0&&t.addIssue({code:le.custom,message:`speed and timelapse are mutually exclusive`,path:[`timelapse`]})}),T$=S([`queued`,`rendering`,`ready`,`failed`,`expired`,`deleted`]),E$=x({kind:p(`footage`),deviceId:n(),profiles:C(l()).min(1),fromMs:n(),toMs:n()}),D$=x({kind:p(`clip`),deviceId:n(),provider:l().min(1),source:l().min(1),sourceLabel:l().min(1),clipId:l().min(1),catalogWindow:x({sinceMs:n(),untilMs:n()}),profile:S([`high`,`mid`,`low`]),wake:s$.optional()}),O$=i(`kind`,[E$,D$]),k$=x({id:l(),deviceId:n(),profile:l(),fromMs:n(),toMs:n(),subject:O$.optional(),options:w$,state:T$,progressPct:n().nullable(),fileBytes:n().nullable(),expiresAt:n(),deleteAfterDownload:y(),downloadedAt:n().nullable(),createdAt:n(),createdBy:l(),error:l().nullable()}),A$=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`,`wake-timeout`]);function ZAe(e,t){return t.length>0?`${e}: ${t}`:e}function QAe(e){if(e===null)return null;let t=e.split(`:`,1)[0]??``,n=A$.safeParse(t.trim());return n.success?n.data:null}var j$=x({url:l(),endpoints:C(l())}),$Ae=50*1024*1024,M$=x({base64:l(),contentType:l(),name:l(),bytes:n().int().nonnegative()});function N$(e){return e.profiles!==void 0&&e.profiles.length>0?[...e.profiles]:typeof e.profile==`string`&&e.profile.length>0?[e.profile]:[]}var eje=x({deviceId:n(),profile:l().optional(),profiles:C(l()).min(1).optional(),fromMs:n().optional(),toMs:n().optional(),subject:O$.optional(),options:w$}).superRefine((e,t)=>{if(e.subject?.kind===`clip`){e.subject.deviceId!==e.deviceId&&t.addIssue({code:le.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:le.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:le.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:le.custom,message:`a footage export needs fromMs and toMs`,path:[`fromMs`]}),(e.subject?.kind===`footage`?[...e.subject.profiles]:N$(e)).length<1&&t.addIssue({code:le.custom,message:`pass profiles[] (min 1) or legacy profile`,path:[`profiles`]})});function tje(e){if(e.subject!==void 0)return e.subject;let t=N$(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 nje(e){return e.subject===void 0?{kind:`footage`,deviceId:e.deviceId,profiles:[e.profile],fromMs:e.fromMs,toMs:e.toMs}:e.subject}var P$={name:`recording-export`,scope:`system`,mode:`singleton`,methods:{createExport:A(eje,k$,{role:`viewer`,kind:`mutation`,auth:`protected`}),listExports:A(x({deviceId:n().optional()}),C(k$),{role:`viewer`,kind:`query`,auth:`protected`}),getExport:A(x({exportId:l()}),k$,{role:`viewer`,kind:`query`,auth:`protected`}),cancelExport:A(x({exportId:l()}),k$,{role:`viewer`,kind:`mutation`,auth:`protected`}),deleteExport:A(x({exportId:l()}),k$,{role:`viewer`,kind:`mutation`,auth:`protected`}),getDownloadUrl:A(x({exportId:l()}),j$,{role:`viewer`,kind:`query`,auth:`protected`}),readExportBytes:A(x({exportId:l()}),M$,{kind:`query`,auth:`protected`})},vocabulary:{notOperatorFacing:`recording exports — requested from the timeline, not an automation step`}},F$=S([`continuous`,`motion`,`person`,`vehicle`,`animal`,`lineCrossing`,`intrusion`,`loitering`,`alarmInput`]),I$=x({trigger:F$,day:n().int().min(0).max(6).meta(N(`none`)),startMinute:n().int().min(0).max(1439).meta(N(`none`)),endMinute:n().int().min(1).max(1440).meta(N(`none`))}),L$=x({id:l(),label:l().optional(),status:S([`ok`,`unformatted`,`error`,`offline`,`unknown`]),capacityMb:n().nullable(),freeMb:n().nullable(),writable:y().optional()}),R$=i(`kind`,[x({kind:p(`present`),volumes:C(L$)}),x({kind:p(`absent`),reason:l()}),x({kind:p(`unknown`),reason:l()})]),z$=x({id:l(),enabled:y(),isVideo:y(),codec:l().nullable(),resolution:l().nullable(),overwriteWhenFull:y().nullable()}),B$=x({storage:R$,tracks:C(z$),primaryTrackId:l().nullable(),enabled:y().nullable(),overwriteWhenFull:y().nullable(),preRecordSec:n().nullable().meta(N(`duration`)),postRecordSec:n().nullable().meta(N(`duration`)),segmentMinutes:n().nullable().meta(N(`none`)),windows:C(I$),unreadableWindows:n().meta(N(`count`)),recordingToNowhere:y(),lastFetchedAt:n()}),V$=x({min:n(),max:n(),step:n()}),H$=x({values:C(n()).min(1),sentinel:x({value:n(),meaning:S([`no-limit`,`disabled`])}).optional()}),U$=x({readable:y(),writable:y(),reason:l().optional()}),W$=x({support:U$,granularityMinutes:n(),triggers:C(F$),supportsOverlappingTriggers:y()}),G$=x({enabled:U$,overwriteWhenFull:U$,preRecordSec:U$,preRecordSecRange:V$.optional(),preRecordSecAllowed:H$.optional(),postRecordSec:U$,postRecordSecRange:V$.optional(),postRecordSecAllowed:H$.optional(),segmentMinutes:U$,segmentMinutesRange:V$.optional(),segmentMinutesAllowed:H$.optional(),schedule:W$}),K$=x({enabled:y().optional(),overwriteWhenFull:y().optional(),preRecordSec:n().optional(),postRecordSec:n().optional(),segmentMinutes:n().optional(),windows:C(I$).optional()}),q$={name:`recording-onboard`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],deviceConfig:{ui:{kind:`derived-form`,builderId:`recording-onboard`,tab:`recording`}},methods:{getOptions:A(x({deviceId:n()}),G$),setSettings:A(x({deviceId:n(),settings:K$}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`recordingOnboard.on`,label:F(`On-camera recording on`,`Registrazione a bordo attiva`),phrase:F(`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:F(`On-camera recording off`,`Registrazione a bordo spenta`),phrase:F(`Turn off recording to the card of {device}`,`Disattiva la registrazione sulla scheda di {device}`),icon:`hard-drive`,args:{settings:{enabled:!1}}}]})},status:{schema:B$,kind:`poll`},runtimeState:B$,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`On-camera recording`,`Registrazione a bordo`),order:3260,state:[{kind:`boolean`,field:`recordingToNowhere`,label:F(`Recording to nowhere`,`Registra nel vuoto`),whenTrue:F(`When {device} is recording with no card to write to`,`Quando {device} registra senza una scheda su cui scrivere`),whenFalse:F(`When {device} has a card to record to again`,`Quando {device} ha di nuovo una scheda su cui registrare`),icon:`hard-drive`}]}},J$=x({active:y(),reason:l(),lastChangedAt:n()}),Y$=J$.extend({lastFetchedAt:n()}),X$={name:`recording-signal`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],methods:{getStatus:A(x({deviceId:n()}),J$)},status:{schema:J$,kind:`push`,empty:{active:!1,reason:`unknown`,lastChangedAt:0}},runtimeState:Y$,durability:`session`,history:`none`,vocabulary:{noun:F(`Recording signal`,`Segnale di registrazione`),order:3270,state:[{kind:`boolean`,field:`active`,label:F(`Recording`,`In registrazione`),whenTrue:F(`When {device} starts recording`,`Quando {device} inizia a registrare`),whenFalse:F(`When {device} stops recording`,`Quando {device} smette di registrare`),icon:`circle-dot`}]}},Z$=x({kind:p(`cap`),deviceId:n().int().nonnegative(),cap:l().min(1),method:l().min(1),args:m(l(),w()).optional(),argUnits:m(l(),l().min(1)).optional()}),Q$=x({action:Z$}),$$=x({key:l().refine(eD,{message:`a lowercase slug`}),name:l().min(1).max(60)}),rje=200,ije=100;function aje(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=pD(a);e!==null&&s(e,`payload`)}for(let t of fD(a))ZE(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 e1=x({index:n().int().nonnegative(),id:l().nullable(),name:l().nullable(),reason:l()}),t1=x({layoutTemplateId:l().min(1).nullable(),defaultTransmitterId:n().int().nonnegative().nullable().default(null),bindings:m(l(),Q$),customButtons:C($$).max(100),sources:C(uD).max(200).default([]),stepDelayMs:n().int().min(100).max(dD).default(500),refusedSources:C(e1).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)ZE(e)?t.addIssue({code:`custom`,message:`"${e}" is a layout widget, not a command: it cannot be bound`,path:[`bindings`,e]}):rD(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=nD(e);n!==null&&!r.has(n)&&t.addIssue({code:`custom`,message:`${e} is bound but has no entry in customButtons`,path:[`bindings`,e]})}aje(e,t)}),oje=se({sources:C(w())}),sje=x({id:l(),name:l()}).partial();function cje(e){let t=oje.safeParse(e);if(!t.success)return n1(t1.safeParse(e));let n=[],r=[];t.data.sources.forEach((e,t)=>{let i=uD.safeParse(e),a=i.success&&i.data.kind===`ir`?pD(i.data):null;if(i.success&&a===null){n.push(e);return}let o=sje.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=n1(t1.safeParse({...t.data,sources:n}));return!i.success||r.length===0?i:{success:!0,data:{...i.data,refusedSources:r}}}function n1(e){return e.success?{success:!0,data:e.data}:{success:!1,issues:e.error.issues.length}}var lje={layoutTemplateId:null,defaultTransmitterId:null,bindings:{},customButtons:[],sources:[],stepDelayMs:500},uje=x({power:x({state:S([`on`,`off`]),at:n()}).nullable(),muted:x({value:y(),at:n()}).nullable(),source:x({name:l(),at:n()}).nullable().default(null)}),dje={power:null,muted:null,source:null},fje=24,pje=50,r1=[`rect`,`rounded`,`round`,`pill`],i1=S(r1),a1=[`neutral`,`accent`,`danger`,`red`,`green`,`yellow`,`blue`],o1=S(a1),s1=[`none`,`panel`,`divider`,`dpad`,`rocker-v`,`rocker-h`,`keypad`],c1=S(s1),l1=x({id:l().min(1).max(40),row:n().int().min(0).max(24),col:n().int().min(0).max(24),rowSpan:n().int().min(1).max(24),colSpan:n().int().min(1).max(24),icon:l().min(1).max(60).optional(),label:l().min(1).max(40).optional(),role:iD,shape:i1.optional(),tone:o1.optional(),showLegend:y().optional(),groupId:l().min(1).max(40).optional()}),u1=x({id:l().min(1).max(40),componentId:l().min(1).max(80),frame:c1,row:n().int().min(0).max(24),col:n().int().min(0).max(24),rowSpan:n().int().min(1).max(24),colSpan:n().int().min(1).max(24),title:l().min(1).max(40).optional(),size:S([`compact`,`normal`]).optional(),hideTitle:y().optional()});function d1(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 f1(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 mje(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&&d1(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`]),f1(n,e)||i(`button "${e.id}" lies outside its group "${n.id}"`,[`buttons`,t]);return}let a=n.find(t=>d1(t,e));a!==void 0&&i(`button "${e.id}" lies inside group "${a.id}" but is not a member`,[`buttons`,t])})}var p1=x({columns:n().int().min(1).max(24),rows:n().int().min(1).max(24),buttons:C(l1).max(200),groups:C(u1).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)}}),mje(e,t)}),hje=50,m1=x({role:iD,label:l().optional(),custom:y()}),h1=x({layoutTemplateId:l().nullable(),commands:C(m1),sources:C(uD)}),g1=[`no-remote`,`unbound-role`,`action-failed`,`unknown-source`,`unbound-step`,`undeclared-channel`,`press-timeout`,`no-transmitter`],_1=S(g1),v1=i(`status`,[x({status:p(`sent`),sends:n().int().min(1)}),x({status:p(`skipped`),reason:p(`already-in-state`)}),x({status:p(`refused`),reason:_1,detail:l().optional(),step:x({index:n().int().min(1),role:l()}).optional()})]),y1=[`play`,`pause`,`stop`,`next`,`previous`,`setMute`,`selectSource`,`playMedia`,`turnOn`,`turnOff`,`volumeUp`,`volumeDown`,`channelUp`,`channelDown`],b1=S(y1),x1=i(`status`,[...v1.options,x({status:p(`not-routed`)})]),S1=[`unknown-template`,`not-a-media-player`],C1=i(`status`,[x({status:p(`saved`)}),x({status:p(`refused`),reason:S(S1),detail:l()})]),w1=x({deviceId:n().int().nonnegative()}),gje={version:1,targets:[{id:`remote`,cardinality:`config`,vocabulary:{cap:`remote`},deviceTypes:[E.MediaPlayer],apply:`add`,readMethod:`getConfig`,writeMethod:`setConfig`}]},T1={name:`remote`,scope:`system`,mode:`singleton`,methods:{getConfig:A(w1,t1,{auth:`admin`}),setConfig:A(w1.extend({config:t1}),C1,{kind:`mutation`,auth:`admin`}),listCommands:A(w1,h1,{auth:`protected`}),sendCommand:A(w1.extend({role:iD,repeat:n().int().min(1).max(50).default(1)}),v1,{kind:`mutation`,auth:`protected`}),getAssumedStatus:A(w1,yD.nullable(),{auth:`protected`}),sendMediaCommand:A(w1.extend({command:b1,muted:y().optional(),source:l().optional(),mediaType:l().optional(),mediaId:l().optional(),repeat:n().int().min(1).max(50).default(1)}),x1,{kind:`mutation`,auth:`protected`})},customize:gje,vocabulary:{notOperatorFacing:`the per-device remote setup — authored in the Customize remote editor, sent through the remote UI`}},E1=[`power`,`navigation`,`volume`,`numbers`,`media`,`colour`,`apps`,`layout`],D1=S(E1),_je=40,vje=/^[a-z0-9][a-z0-9_.-]*:[a-z0-9][a-z0-9_-]*$/,O1=x({idSuffix:l().regex(/^[a-z0-9][a-z0-9_-]{0,19}$/,{message:`a short lowercase slug`}),row:n().int().min(0).max(24),col:n().int().min(0).max(24),rowSpan:n().int().min(1).max(24),colSpan:n().int().min(1).max(24),role:iD,icon:l().min(1).max(60).optional(),label:l().min(1).max(40).optional(),shape:i1.optional(),tone:o1.optional(),showLegend:y().optional()}),k1=x({id:l().max(80).regex(vje,{message:`<namespace>:<name>, lowercase`}),name:l().min(1).max(60),nameI18n:x({en:l().min(1).max(60),it:l().min(1).max(60)}).optional(),icon:l().min(1).max(60),category:D1,size:x({rows:n().int().min(1).max(24),cols:n().int().min(1).max(24)}),group:x({frame:c1,title:l().min(1).max(40).optional()}).nullable(),buttons:C(O1).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&&d1(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`]})}),A1={name:`remote-layout-components`,scope:`system`,mode:`collection`,methods:{listComponents:A(x({}),C(k1),{auth:`protected`})},vocabulary:{notOperatorFacing:`the palette of the remote template editor — read-only data, never actuated`}},j1=x({deviceId:n().int().nonnegative(),resetToSource:y().optional()}),M1={name:`resync`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Container,E.Workload,E.WeatherStation],methods:{resync:A(j1,BA,{kind:`mutation`,auth:`admin`,notOperatorFacing:`device adoption — re-aligning a device with its source is an onboarding step, not an automation action`})},vocabulary:{noun:F(`Re-sync`,`Risincronizzazione`),order:3245}},yje=5,bje=2,N1=3e4,P1=18e4,F1={startDwellMs:N1,stopDwellMs:P1,minSamples:2},I1={[E.MediaPlayer]:{startDwellMs:1e4,stopDwellMs:1e4,minSamples:1}};function L1(e){return e!==void 0&&I1[e]!==void 0}function R1(e){return e===void 0?F1:I1[e]??F1}var xje={running:null,since:null,source:`native`,phase:null,lastFetchedAt:null},z1=S([`native`,`assigned`]),B1=x({running:y().nullable(),since:n().nullable().meta(N(`none`)),source:z1.meta({label:`Source`}),phase:l().nullable(),lastFetchedAt:n().nullable()}),V1=x({deviceId:n(),since:n().nullable(),phase:l().nullable()}),Sje=Object.values(E),H1=[E.Washer,E.Dryer,E.Dishwasher,E.Vacuum,E.LawnMower,E.MediaPlayer,E.WaterHeater,E.Humidifier,E.Fan,E.Climate,E.PetFeeder],Cje={version:1,overridable:[{path:`running`,by:`running`}],targets:[{id:`running`,cardinality:`scalar`,vocabulary:{cap:`running-state`,stateField:`running`},deviceTypes:H1,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:N1,defaultStopDwellMs:P1,deviceTypeDefaults:I1,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}]},U1={name:`running-state`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:Sje,methods:{},events:{onStarted:{data:V1,trigger:{category:T.RunningStarted,label:F(`Started running`,`Ha iniziato a funzionare`),phrase:F(`When {device} starts running`,`Quando {device} inizia a funzionare`),icon:`play`}},onFinished:{data:V1,trigger:{category:T.RunningFinished,label:F(`Finished`,`Ha finito`),phrase:F(`When {device} finishes`,`Quando {device} finisce`),icon:`square`}}},status:{schema:B1,kind:`push`},runtimeState:B1,durability:`restored`,history:{fields:{running:{kind:`boolean`}}},volatileStateFields:[`lastFetchedAt`],customize:Cje,vocabulary:{noun:F(`Running`,`In funzione`),order:2120,state:[{kind:`boolean`,field:`running`,label:F(`Running`,`In funzione`),whenTrue:F(`When {device} starts`,`Quando {device} inizia`),whenFalse:F(`When {device} finishes`,`Quando {device} finisce`),icon:`play`}],overrides:{byType:{[E.Washer]:{state:{running:{whenTrue:F(`When the washing machine starts`,`Quando la lavatrice inizia`),whenFalse:F(`When the washing machine has finished`,`Quando la lavatrice ha finito`)}},events:{onStarted:{phrase:F(`When the washing machine starts`,`Quando la lavatrice inizia`)},onFinished:{phrase:F(`When the washing machine has finished`,`Quando la lavatrice ha finito`)}}},[E.Dryer]:{state:{running:{whenTrue:F(`When the dryer starts`,`Quando l'asciugatrice inizia`),whenFalse:F(`When the dryer has finished`,`Quando l'asciugatrice ha finito`)}},events:{onStarted:{phrase:F(`When the dryer starts`,`Quando l'asciugatrice inizia`)},onFinished:{phrase:F(`When the dryer has finished`,`Quando l'asciugatrice ha finito`)}}},[E.Dishwasher]:{state:{running:{whenTrue:F(`When the dishwasher starts`,`Quando la lavastoviglie inizia`),whenFalse:F(`When the dishwasher has finished`,`Quando la lavastoviglie ha finito`)}},events:{onStarted:{phrase:F(`When the dishwasher starts`,`Quando la lavastoviglie inizia`)},onFinished:{phrase:F(`When the dishwasher has finished`,`Quando la lavastoviglie ha finito`)}}}}}}},W1=l(),wje=[`day`,`ir`,`night`,`dawn`,`dusk`],G1=S([`skip`,`judge-anyway`]),Tje=`__diverged__`,K1=S([`matched`,`diverged`,`unknown`]),q1=S([`no-reference-for-condition`,`view-shifted`,`no-vision-profile`,`encoder-model-changed`,`no-snapshot`]),J1=x({embedding:C(n()),modelId:l(),condition:W1,capturedAt:n(),thumbnailMediaId:n().int().optional(),anchorEmbedding:C(n()).optional()}),Y1=x({id:l(),label:l(),references:C(J1),textPrompts:C(l()).optional(),referenceCount:n(),currentlyMatched:y()}),X1=i(`mode`,[x({mode:p(`similarity`),threshold:n().min(0).max(1),hysteresisCount:n().int().positive()}),x({mode:p(`llm`),prompt:l(),profileId:l().optional(),hysteresisCount:n().int().positive()})]),Eje=60,Dje=120,Oje=60,Z1=.85,Q1=`skip`,$1=8e3,kje=448,Aje=!0,e0=x({enabled:y().default(!1),prompt:l().min(1).max(1e3),profileId:l().optional(),timeoutMs:n().int().min(1e3).max(2e4).default($1),maxImagePx:n().int().min(64).max(2048).default(448),onTimeout:S([`flip`,`hold`]).default(`hold`)}),t0=x({id:l(),label:l(),roi:iH,enabled:y(),triggerMode:S([`periodic`,`on-motion`,`both`]),checkIntervalSec:n().optional(),check:X1,states:C(Y1),currentStateId:l().nullable(),lastCheckedAt:n().nullable(),lastConfidence:n().nullable(),currentCondition:W1.nullable(),availability:S([`ok`,`unavailable`]),unavailableReason:l().nullable(),baselineStateId:l().nullable(),emit:S([`latched`,`live`]).default(`latched`),verdict:K1,latched:y(),armedAt:n(),divergedAt:n().nullable(),restoredAt:n().nullable(),quietSeconds:n().int().min(0).max(3600).default(60),minObservationSpacingSec:n().int().min(0).max(3600).default(120),confirm:e0.optional(),anchorThreshold:n().min(0).max(1).default(Z1),autoRestore:y().default(!1),onUncoveredCondition:G1.default(Q1),suspendedCondition:W1.nullable().default(null),unavailable:q1.nullable(),coveredConditions:C(W1)}),n0=x({monitors:C(t0),lastFetchedAt:n()}),r0=x({deviceId:n(),status:n0.nullable()}),i0={name:`scene-monitor`,role:{feature:`scenes`},scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[E.Camera],methods:{listScenes:A(x({deviceId:n()}),n0),listScenesBatch:A(x({deviceIds:C(n()).min(1).max(200)}),C(r0).readonly()),createScene:A(x({deviceId:n(),label:l(),roi:iH,check:X1,triggerMode:S([`periodic`,`on-motion`,`both`]).optional(),checkIntervalSec:n().optional()}),t0,{kind:`mutation`,auth:`admin`}),updateScene:A(x({deviceId:n(),monitorId:l(),patch:x({label:l().optional(),roi:iH.optional(),enabled:y().optional(),triggerMode:S([`periodic`,`on-motion`,`both`]).optional(),checkIntervalSec:n().optional(),check:X1.optional(),emit:S([`latched`,`live`]).optional(),quietSeconds:n().int().min(0).max(3600).optional(),minObservationSpacingSec:n().int().min(0).max(3600).optional(),anchorThreshold:n().min(0).max(1).optional(),autoRestore:y().optional(),onUncoveredCondition:G1.optional(),confirm:e0.nullable().optional()})}),v(),{kind:`mutation`,auth:`admin`}),deleteScene:A(x({deviceId:n(),monitorId:l()}),v(),{kind:`mutation`,auth:`admin`}),captureReference:A(x({deviceId:n(),monitorId:l(),stateId:l().optional(),label:l().optional(),condition:W1.optional()}),x({stateId:l(),referenceCount:n()}),{kind:`mutation`,auth:`admin`}),deleteReference:A(x({deviceId:n(),monitorId:l(),stateId:l(),index:n()}),v(),{kind:`mutation`,auth:`admin`}),recheckNow:A(x({deviceId:n(),monitorId:l()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`sceneMonitor.recheck`,label:F(`Re-check a scene`,`Ricontrolla una scena`),phrase:F(`Re-check {monitorId} on {device} now`,`Ricontrolla subito {monitorId} su {device}`),icon:`scan-search`,openArgs:[{key:`monitorId`,label:F(`Scene`,`Scena`),offer:{kind:`dynamic`,from:`status`,field:`monitors`,valueKey:`id`,labelKey:`label`}}]}]}),resetScene:A(x({deviceId:n(),monitorId:l(),recapture:y().optional()}),v(),{kind:`mutation`,auth:`admin`})},status:{schema:n0,kind:`push`},runtimeState:n0,durability:`session`,history:`none`,vocabulary:{noun:F(`Scene watch`,`Controllo della scena`),order:3280,extraEvents:[{category:T.EnrichmentSceneStateChanged,label:F(`Scene changed`,`Scena cambiata`),phrase:F(`When a watched scene on {device} changes`,`Quando cambia una scena controllata su {device}`),icon:`scan-search`}]}},a0=x({schedulerId:l().min(1)}),o0={name:`schedulers`,scope:`system`,mode:`singleton`,methods:{list:A(x({}),C(cy),{auth:`admin`}),get:A(a0,x({scheduler:cy.nullable()}),{auth:`admin`}),create:A(x({scheduler:sy}),x({scheduler:cy}),{kind:`mutation`,auth:`admin`}),update:A(x({schedulerId:l().min(1),scheduler:sy}),x({scheduler:cy}),{kind:`mutation`,auth:`admin`}),delete:A(a0,v(),{kind:`mutation`,auth:`admin`}),setEnabled:A(x({schedulerId:l().min(1),profileId:l().min(1).optional(),enabled:y()}),x({scheduler:cy}),{kind:`mutation`,auth:`admin`}),preview:A(x({schedulerId:l().min(1),date:l().regex(my).optional()}),gy,{auth:`admin`}),conflicts:A(x({scheduler:sy,schedulerId:l().min(1).optional()}),x({conflicts:C(_y)}),{auth:`admin`}),getStatus:A(x({}),C(yy),{auth:`admin`}),getTraces:A(a0,x({traces:C(Ay)}),{auth:`admin`})},vocabulary:{notOperatorFacing:`time schedulers — authored on their own page, not device actions`}},s0=x({isRunning:y(),lastRunAt:n(),lastRunSuccess:y().nullable(),lastError:l().nullable(),lastChangedAt:n()}),c0={name:`script-runner`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Script],methods:{run:A(x({deviceId:n().int().nonnegative(),variables:m(l(),w()).optional()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`script.run`,label:F(`Run script`,`Esegui lo script`),phrase:F(`Run {device}`,`Esegui {device}`),icon:`scroll-text`,hold:{effects:[{field:`isRunning`,value:!0}],holdMs:IY}}]}),stop:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`script.stop`,effect:{field:`isRunning`,value:!1},label:F(`Stop script`,`Ferma lo script`),phrase:F(`Stop {device}`,`Ferma {device}`),icon:`square`}]})},status:{schema:s0,kind:`push`},runtimeState:s0,durability:`session`,history:`none`,vocabulary:{noun:F(`Script`,`Script`),order:2090,state:[{kind:`boolean`,field:`isRunning`,label:F(`Running`,`In esecuzione`),whenTrue:F(`When {device} starts running`,`Quando {device} parte`),whenFalse:F(`When {device} finishes`,`Quando {device} termina`),icon:`scroll-text`}]}},l0=S([`workspace`,`baked`,`data-root`]),u0=S([`idle`,`checking`,`staging`,`pending-restart`,`awaiting-confirmation`]),d0=S([`in-sync`,`behind-patch`,`behind-series`,`ahead`,`unknown`]),f0=x({state:d0,seedVersion:l().nullable(),contractVersion:l().nullable(),contractSource:S([`registry`,`running`]).nullable(),message:l()}),p0=S([`docker`,`electron`,`native`,`contradictory`,`unknown`]),m0=x({fact:S([`dockerenv-file`,`proc-1-cgroup`,`platform`,`electron-app-version-env`]),mode:S([`observed`,`declared`]),holds:y(),detail:l()}),h0=x({kind:p0,evidence:C(m0),currentVersion:l().nullable()}),g0=x({fromVersion:l(),toVersion:l().nullable(),atMs:n(),reason:l()}),_0=x({version:l(),update:x({available:y(),downloaded:y(),version:l().nullable(),checking:y(),error:l().nullable()}),stateAtMs:n(),stale:y()}),v0=S([`not-electron`,`no-app-state`,`app-state-stale`,`not-downloaded`]),y0=x({accepted:y(),reason:v0.nullable()}),b0=x({runnerId:l(),addonIds:C(l()),reason:l()}),x0=x({checkedAtMs:n(),expected:n(),running:n(),failed:C(l()),refused:C(b0),missing:C(l()),pending:C(l()).optional(),planKnown:y()}),S0=x({packageName:l(),runningVersion:l().nullable(),nodeRuntimeVersion:l().nullable(),activeVersion:l().nullable(),installedVersion:l().nullable().optional(),restartRequired:y().optional(),previousVersion:l().nullable(),seedVersion:l().nullable(),latestVersion:l().nullable(),updateAvailable:y(),bootMode:l0,updateState:u0,pendingVersion:l().nullable(),rolledBack:g0.nullable(),stateFileCorrupt:y(),lastCheckedAtMs:n().nullable(),imageContract:f0.optional(),wrapper:h0.optional(),runners:x0.optional(),desktopApp:_0.optional()}),C0=x({packageName:l(),runningVersion:l().nullable(),latestVersion:l().nullable(),updateAvailable:y(),checkedAtMs:n(),error:l().nullable(),pendingVersion:l().nullable().optional(),restartRequired:y().optional()}),w0=S([`staged`,`restart-scheduled`,`already-current`,`refused`,`failed`]),T0=x({addonId:l(),reason:l(),remedy:l()}),E0=x({accepted:y(),targetVersion:l().nullable(),restarting:y(),message:l(),outcome:w0.optional(),reason:l().nullable().optional(),error:l().nullable().optional(),blockers:C(T0).optional(),unmet:C(Pu).optional(),requiredAddonUpdates:C(Fu).optional()}),D0=x({heapMb:n().int().nullable(),rssBudgetMb:n().int().nullable()}),jje=x({heapMb:n().int().min(512).max(65536).nullable(),rssBudgetMb:n().int().min(512).max(65536).nullable().optional()}),Mje=D0.extend({restartRequired:y()}),O0={name:`server-management`,scope:`system`,mode:`singleton`,methods:{getServerPackageStatus:A(v(),S0,{auth:`admin`}),checkServerUpdate:A(v(),C0,{kind:`mutation`,auth:`admin`}),applyServerUpdate:A(x({version:l().optional(),acknowledgeRefusals:y().optional()}),E0,{kind:`mutation`,auth:`admin`,timeoutMs:16*6e4}),installDesktopUpdate:A(v(),y0,{kind:`mutation`,auth:`admin`}),rollbackServerUpdate:A(v(),E0,{kind:`mutation`,auth:`admin`}),restartServer:A(v(),E0,{kind:`mutation`,auth:`admin`}),getLaunchOverrides:A(v(),D0,{auth:`admin`}),setLaunchOverrides:A(jje,Mje,{kind:`mutation`,auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:M.CLUSTER}},k0={Seconds:`seconds`,Plays:`plays`},A0={Camera:`camera`,Fallback:`fallback`},j0=x({min:n().positive(),max:n().positive(),step:n().positive()}),M0=x({allowedSeconds:C(n().positive()).nullable(),rangeSeconds:j0.nullable(),defaultSeconds:n().positive(),allowedPlays:C(n().int().positive()).nullable().default(null),rangePlays:j0.nullable().default(null),defaultPlays:n().int().positive().nullable().default(null),unit:S([k0.Seconds,k0.Plays]),secondsPerPlay:n().positive().nullable(),source:S([A0.Camera,A0.Fallback]),fetchedAt:n()}),N0=x({active:y(),activeUntil:n().nullable(),durationSeconds:n().nullable(),plays:n().int().positive().nullable().default(null),activeUntilEstimated:y().default(!1),lastTriggeredAt:n()}),P0=x({deviceId:n().int().nonnegative(),durationSeconds:n().positive().optional(),plays:n().int().positive().optional()}).refine(e=>e.durationSeconds===void 0||e.plays===void 0,{message:`a siren trigger takes durationSeconds or plays, not both`,path:[`plays`]}),F0=N0.extend({lastFetchedAt:n()}),I0={name:`siren`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Siren],methods:{getOptions:A(x({deviceId:n().int().nonnegative()}),M0,{kind:`query`,auth:`protected`}),getPlayChoices:A(x({deviceId:n().int().nonnegative()}),C(n().int().positive()),{kind:`query`,auth:`protected`}),trigger:A(P0,N0,{kind:`mutation`,auth:`protected`,actions:[{id:`siren.trigger`,label:F(`Sound the siren`,`Fai suonare la sirena`),phrase:F(`Sound {device}`,`Fai suonare {device}`),icon:`siren`,args:{}},{id:`siren.triggerPlays`,label:F(`Sound the siren N times`,`Fai suonare la sirena N volte`),phrase:F(`Sound {device} {plays} times`,`Fai suonare {device} {plays} volte`),icon:`siren`,openArgs:[{key:`plays`,label:F(`Plays`,`Riproduzioni`),offer:{kind:`dynamic`,from:`method`,method:`getPlayChoices`,valueKind:`number`}}]}]}),stop:A(x({deviceId:n().int().nonnegative()}),N0,{kind:`mutation`,auth:`protected`,actions:[{id:`siren.stop`,label:F(`Silence the siren`,`Zittisci la sirena`),phrase:F(`Silence {device}`,`Zittisci {device}`),icon:`siren`,effect:{field:`active`,value:!1},args:{}}]})},events:{onSirenChanged:{data:x({deviceId:n(),active:y(),activeUntil:n().nullable()}),notOperatorFacing:"the `active` state trigger phrases both edges of this change"}},status:{schema:N0,kind:`command-driven`},runtimeState:F0,durability:`session`,history:`none`,vocabulary:{noun:F(`Siren`,`Sirena`),order:1170,state:[{kind:`boolean`,field:`active`,label:F(`Siren sounding`,`Sirena in funzione`),whenTrue:F(`When {device} starts sounding`,`Quando {device} inizia a suonare`),whenFalse:F(`When {device} falls silent`,`Quando {device} smette di suonare`),icon:`siren`}]}},L0=x({detected:y(),lastChangedAt:n()}),R0={name:`smoke`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:L0,kind:`push`},runtimeState:L0,durability:`restored`,history:{fields:{detected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Smoke detector`,`Rilevatore di fumo`),order:5190,state:[{kind:`boolean`,field:`detected`,label:F(`Detected`,`Rilevato`),whenTrue:F(`When {device} detects smoke`,`Quando {device} rileva fumo`),whenFalse:F(`When smoke clears on {device}`,`Quando il fumo su {device} si dirada`),icon:`alarm-smoke`}]}},Nje=3,z0=5*1024*1024,B0=`<!--camstack-images-->`,V0=x({ticket:Si,mime:l().min(1),name:l().min(1),contentId:l().min(1),placement:S([`inline`,`attachment`]),deviceId:n().int().nonnegative().optional()}),H0=0;function U0(e){return H0+=1,`camstack_${e}_${H0.toString(36)}_${Date.now().toString(36)}`}function Pje(e){return/^[\x20-\x7E]*$/.test(e)?e:`=?UTF-8?B?${Buffer.from(e,`utf8`).toString(`base64`)}?=`}function W0(e){return(Array.isArray(e)?e:[e]).join(`, `)}function Fje(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}function G0(e,t){let n=e.replace(/[\r\n"]/g,``).trim();return n.length>0?n:t}function Ije(e){let t=Buffer.from(e).toString(`base64`),n=[];for(let e=0;e<t.length;e+=76)n.push(t.slice(e,e+76));return n.join(`\r
|
|
1114
1114
|
`)}function Lje(e){return`<img src="cid:${Fje(e.contentId)}" alt="">`}function Rje(e,t){return e.replaceAll(B0,t.map(Lje).join(``))}function K0(e){let t=[`From: ${e.from}`,`To: ${W0(e.to)}`];return e.cc!==void 0&&e.cc.length>0&&t.push(`Cc: ${W0(e.cc)}`),e.bcc!==void 0&&e.bcc.length>0&&t.push(`Bcc: ${W0(e.bcc)}`),e.replyTo!==void 0&&e.replyTo.length>0&&t.push(`Reply-To: ${e.replyTo}`),t.push(`Subject: ${Pje(e.subject)}`),t.push(`MIME-Version: 1.0`),t}function q0(e,t){return[`--${e}`,`Content-Type: text/plain; charset="UTF-8"`,`Content-Transfer-Encoding: 8bit`,``,t]}function J0(e,t){return[`--${e}`,`Content-Type: text/html; charset="UTF-8"`,`Content-Transfer-Encoding: 8bit`,``,t]}function Y0(e,t){let n=G0(t.mime,`image/jpeg`),r=G0(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: <${G0(t.contentId,`image`)}>`),a.push(``,Ije(t.bytes)),a}function X0(e,t,n){let r=U0(`alt`);return[`--${e}`,`Content-Type: multipart/alternative; boundary="${r}"`,``,...q0(r,t),...J0(r,n),`--${r}--`]}function zje(e,t){let n=K0(e);if(t!==void 0){let r=U0(`alt`);return n.push(`Content-Type: multipart/alternative; boundary="${r}"`,``),n.push(...q0(r,e.text),...J0(r,t),`--${r}--`),n}return n.push(`Content-Type: text/plain; charset="UTF-8"`,`Content-Transfer-Encoding: 8bit`,``,e.text),n}function Bje(e,t,n){let r=U0(`mix`),i=K0(e);i.push(`Content-Type: multipart/mixed; boundary="${r}"`,``),t===void 0?i.push(...q0(r,e.text)):i.push(...X0(r,e.text,t));for(let e of n)i.push(...Y0(r,e));return i.push(`--${r}--`),i}function Vje(e,t,n,r){let i=U0(`rel`),a=K0(e);a.push(`Content-Type: multipart/related; boundary="${i}"; type="multipart/alternative"`,``,...X0(i,e.text,t));for(let e of n)a.push(...Y0(i,e));for(let e of r)a.push(...Y0(i,e));return a.push(`--${i}--`),a}function Z0(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?Rje(e.html,n):void 0;return i!==void 0&&n.length>0?Vje(e,i,n,r).join(`\r
|
|
1115
1115
|
`):r.length>0||n.length>0?Bje(e,i,r.length>0?r:n).join(`\r
|
|
1116
1116
|
`):zje(e,i).join(`\r
|