@camstack/addon-admin-ui 1.2.688 → 1.2.689
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/dist/assets/{Addons-2wfM1edN.js → Addons-DY29xpxZ.js} +1 -1
- package/dist/assets/{AdminPage-BGtK1GBq.js → AdminPage-BZ0d3KIi.js} +1 -1
- package/dist/assets/{AdminSectionedPage-CRtQpSxT.js → AdminSectionedPage-CivTk-bE.js} +1 -1
- package/dist/assets/{AiProfiles-BHwb3nSo.js → AiProfiles-tt4dx8wK.js} +1 -1
- package/dist/assets/{BootstrapSettingsForm-BS87l0cS.js → BootstrapSettingsForm-Cyk46Mh8.js} +1 -1
- package/dist/assets/{Build-DIVuAKYP.js → Build-CDp7r2o2.js} +1 -1
- package/dist/assets/{Calendars-CF3LuetJ.js → Calendars-DcanbjM1.js} +1 -1
- package/dist/assets/{CameraGrids-6UFohBNL.js → CameraGrids-D0rLrR4c.js} +1 -1
- package/dist/assets/{Cluster-mnQtI40N.js → Cluster-Dr-johc0.js} +1 -1
- package/dist/assets/{CompositionBlockEditor-CY2C2J8Z.js → CompositionBlockEditor-Dm8WVd7r.js} +1 -1
- package/dist/assets/{CompositionEditorPage-B37HL2Dz.js → CompositionEditorPage-BQzbI-bs.js} +1 -1
- package/dist/assets/{Data-C7m-cbr4.js → Data-DLn1T8hw.js} +1 -1
- package/dist/assets/{DeviceDetail-BBiCkxxi.js → DeviceDetail-BiT7xDfc.js} +1 -1
- package/dist/assets/{Devices-MX4ikexb.js → Devices-Dn8t45Xi.js} +1 -1
- package/dist/assets/EmbedDevicePage-BtrHGVT2.js +1 -0
- package/dist/assets/{EmbedPlayerPage-DRlowAOp.js → EmbedPlayerPage-Cpe5M1Q-.js} +1 -1
- package/dist/assets/{History-DqZqNlZz.js → History-BbdiSj1c.js} +1 -1
- package/dist/assets/{Identity-CM4Ortr-.js → Identity-C0GPwuiI.js} +1 -1
- package/dist/assets/InstancesTable-j-4OK4zO.js +1 -0
- package/dist/assets/{IntegrationDetail-CsdGAa7R.js → IntegrationDetail-jfy5nNNW.js} +1 -1
- package/dist/assets/{Integrations-DpijggGk.js → Integrations-BDNPovWf.js} +1 -1
- package/dist/assets/{Integrations-Dl7VYw1x.js → Integrations-beSlWUhd.js} +1 -1
- package/dist/assets/{Library-Bp85cSAL.js → Library-B2A58WTO.js} +1 -1
- package/dist/assets/{Locations-IZq43PGv.js → Locations-CisH18lP.js} +1 -1
- package/dist/assets/{Logs-CrDOCX6k.js → Logs-D7jdjIJK.js} +1 -1
- package/dist/assets/{MaskShapeCanvas-DjZ_ENJI.js → MaskShapeCanvas-CkL1-Z2p.js} +1 -1
- package/dist/assets/{MotionZonesSettings-BRV1q6cp.js → MotionZonesSettings-CglI9jLC.js} +1 -1
- package/dist/assets/{MyAccess-d5w8yPDS.js → MyAccess-BaeZoW7T.js} +1 -1
- package/dist/assets/{Network-A8Hzlr9I.js → Network-BRESDnEF.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-CFTTKJTW.js → NodeAddonsSettingsPanel-Cs-4A2nm.js} +1 -1
- package/dist/assets/{Notifications-yofgwGYi.js → Notifications-BLIvNXbr.js} +1 -1
- package/dist/assets/{Pipeline-C58uJw5q.js → Pipeline-DQlV8HzY.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-YvPDriCm.js → PrivacyMaskSettings-Cfst7tBt.js} +1 -1
- package/dist/assets/{Recordings-CNS2YQnv.js → Recordings-BoAz9UAs.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-DH2-nekM.js → SceneMonitorEditor-DPm4jF5N.js} +1 -1
- package/dist/assets/{ServerShell-W8Wp5cGt.js → ServerShell-CTyuWz03.js} +1 -1
- package/dist/assets/{SessionsList-CYvDTfln.js → SessionsList-CKIbxGRm.js} +1 -1
- package/dist/assets/{Showroom-DFesEW-P.js → Showroom-Ca4Y5ZQK.js} +1 -1
- package/dist/assets/StorageLocationsTable-C4W7zsGI.js +1 -0
- package/dist/assets/{System-B8KmJqiE.js → System-JFcPuvVK.js} +1 -1
- package/dist/assets/{TemplateEditorDialog-DTAAJR9z.js → TemplateEditorDialog-BqcmsBtt.js} +1 -1
- package/dist/assets/{Terminal-D0cZGsnW.js → Terminal-DpsQgC9x.js} +1 -1
- package/dist/assets/{TerminalPanel-J1w2vmDS.js → TerminalPanel-CGquUW8j.js} +1 -1
- package/dist/assets/{TrainingProviders-BFbXHvOM.js → TrainingProviders-CPNjxb58.js} +1 -1
- package/dist/assets/{Viewer-ZYjr8fFf.js → Viewer-CO1F-6xh.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-D3ruWlC-.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-D0G_tF_l.js} +1 -1
- package/dist/assets/{action-draft-DNplCdnd.js → action-draft-Bg11zRAj.js} +1 -1
- package/dist/assets/{ai-page.helpers-CLp_BM_b.js → ai-page.helpers-CB1jbKz_.js} +1 -1
- package/dist/assets/{assignment-candidates-Cs1bHYCE.js → assignment-candidates-B6H3O80X.js} +1 -1
- package/dist/assets/{authed-media-D3P2p3qZ.js → authed-media-xniEMsSm.js} +1 -1
- package/dist/assets/{board-model-CEczoawG.js → board-model-B2JiEhiD.js} +1 -1
- package/dist/assets/{client-DIFc5Ulp.js → client-CuXMhtQa.js} +1 -1
- package/dist/assets/{command-vocab-Dp8EnV9z.js → command-vocab-CnGweFaG.js} +1 -1
- package/dist/assets/{device-detail-D28nIlrx.js → device-detail-DJ7UsGNh.js} +1 -1
- package/dist/assets/{device-integration-icon-CGnRiBbM.js → device-integration-icon-BL4OR8Tu.js} +1 -1
- package/dist/assets/device-picker-model-CmD_rtEB.js +1 -0
- package/dist/assets/{dist-GJ2aJJ7U.js → dist-BIKSreSn.js} +1 -1
- package/dist/assets/{dist-DVUXvJ_X.js → dist-b4Z4Rn9L.js} +1 -1
- package/dist/assets/{format-BqZcr5Z7.js → format-D-lO-1j1.js} +1 -1
- package/dist/assets/{hostInit-BCFIcylY.js → hostInit-DVaasUc0.js} +1 -1
- package/dist/assets/i18n-BXCE99oN.js +1 -0
- package/dist/assets/{icons-Cjxpx-EC.js → icons-C8z46zRV.js} +1 -1
- package/dist/assets/{index-CqFqTrNf.js → index-DltGFPYA.js} +3 -3
- package/dist/assets/{linked-devices-model-BIS0JhHd.js → linked-devices-model-Bz36XHKW.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-8782dcf2.js → mf-entry-bootstrap-0-a6b7ded2.js} +2 -2
- package/dist/assets/mount-CmD_rtEB.js +1 -0
- package/dist/assets/{notification-rule-status-ikR-6LJe.js → notification-rule-status-BprPUtT4.js} +1 -1
- package/dist/assets/{player-overlays-Cro1Q2AX.js → player-overlays-6CqWKNYt.js} +1 -1
- package/dist/assets/remoteEntry-DKzXIU3g.js +1 -0
- package/dist/assets/src-Ddt5cb2R.js +279 -0
- package/dist/assets/{sso-popup-Dd0yy6b3.js → sso-popup-CTYyuiaU.js} +1 -1
- package/dist/assets/{step-inspector-model-Dbe3pGib.js → step-inspector-model-BBqHZ2d-.js} +1 -1
- package/dist/assets/{use-scenes-feed-Cbr4UyCd.js → use-scenes-feed-Ci4MtEAr.js} +1 -1
- package/dist/assets/{use-stationary-objects-tm2lHAjw.js → use-stationary-objects-DK2HFw6V.js} +1 -1
- package/dist/assets/{useAdminDeviceRemoval-DNwUFqF2.js → useAdminDeviceRemoval-C2ITjRTs.js} +1 -1
- package/dist/assets/useEventInvalidation-CmD_rtEB.js +1 -0
- package/dist/assets/{useNodeUrlSelection-Cbif6CY8.js → useNodeUrlSelection-Dfowz4k5.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CExmog1q.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-D4WQjLc3.js} +2 -2
- package/dist/index.html +8 -8
- package/dist/server/addon.js +7 -1
- package/package.json +2 -2
- package/dist/assets/EmbedDevicePage-DHBOCKzI.js +0 -1
- package/dist/assets/InstancesTable-CT4Kr3zo.js +0 -1
- package/dist/assets/StorageLocationsTable-D7z9VM03.js +0 -1
- package/dist/assets/device-picker-model-DMqoJA3J.js +0 -1
- package/dist/assets/i18n-CmzYiG85.js +0 -1
- package/dist/assets/mount-DMqoJA3J.js +0 -1
- package/dist/assets/remoteEntry-Cr4tLhkx.js +0 -1
- package/dist/assets/src-o5EApxkv.js +0 -279
- package/dist/assets/useEventInvalidation-DMqoJA3J.js +0 -1
|
@@ -1105,7 +1105,7 @@ ${d.map(({leaf:e,path:t})=>nge(e,t)).join(`
|
|
|
1105
1105
|
for (const dispose of disposers) dispose()
|
|
1106
1106
|
}
|
|
1107
1107
|
}
|
|
1108
|
-
`}function pge(e){return`subjects`in e?e.subjects:e.classes.map(Ig)}var mge=new Set(Object.values(Ng.mapping));function hge(e){return Ng.mapping[e]??e}function gge(e,t){let n=e.toLowerCase(),r=t.toLowerCase();return n===r?!0:mge.has(n)&&hge(r)===n}function _ge(e){return e===`start`||e===`update`||e===`end`}var vge=class{trigger;fired=new Map;subjects;constructor(e){this.trigger=e,this.subjects=pge(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`||!_ge(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=Lg(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 yge(e){return`classes`in e}function bge(e){return e===`appeared`||e===`departed`}function xge(e,t){let{deviceId:n,entryId:r,phase:i}=t;if(typeof n!=`number`||typeof r!=`string`||!bge(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=yge(e)?e.classes?.map(Ig):e.subjects;if(c!==void 0){let e=Lg(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 Gy=b({deviceId:f(),eventType:p(),sourceId:p().optional(),data:u(p(),l()).nullable(),timestamp:f().meta(j(`none`)),seq:f().meta(j(`count`))}),Ky=b({eventTypes:S(p()),vocabulary:S(Rfe).default([]),lastEvent:Gy.nullable(),eventCountSinceStart:f().meta(j(`count`))}),qy={name:`event-emitter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.EventEmitter],methods:{},events:{onEvent:{data:Gy,trigger:{category:C.EventEmitted,label:N(`Fired an event`,`Ha generato un evento`),phrase:N(`When {device} fires an event`,`Quando {device} genera un evento`),icon:`zap`}}},status:{schema:Ky,kind:`push`},runtimeState:Ky,durability:`session`,history:`none`,vocabulary:{noun:N(`Event source`,`Sorgente di eventi`),order:5280}},Sge=3,Cge=32;function wge(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`}function Jy(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Yy(e){let t={},n=(e,r,i)=>{if(!(Object.keys(t).length>=Cge)){if(wge(e)){t[r]=e;return}if(!(!Jy(e)||i>=Sge))for(let[t,a]of Object.entries(e))n(a,`${r}.${t}`,i+1)}};if(Jy(e))for(let[t,r]of Object.entries(e))n(r,`data.${t}`,1);return t}function Tge(e,t){let n=e;for(let e of t.split(`.`)){if(!Jy(n))return;n=n[e]}return n}function Xy(e,t){return t===null?!0:e.timestamp===t.timestamp?e.seq>t.seq:e.timestamp>t.timestamp}var Zy=`recovered by reconcile`,Ege=class{leaf;#e=null;#t=!1;#n=null;constructor(e){this.leaf=e}onEvent(e){let t=Gy.safeParse(e);if(!t.success)return{kind:`ignore`,why:`malformed event`};let n=t.data;return n.deviceId===this.leaf.deviceId?Xy(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=Ky.safeParse(e);if(!t.success)return{kind:`ignore`,why:`the event-emitter status is unreadable`};this.#n=Wfe(t.data);let n=t.data.lastEvent,r=!this.#t;return this.#t=!0,n===null?{kind:`ignore`,why:`the device has not fired`}:Xy(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??Hfe([e.eventType]);return(og(t,e.eventType,e.sourceId)??og(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=Yy(e.data);for(let t of a??[]){let n=Tge(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} — ${Zy}`:l,vars:s,data:c}}},Qy=6e4;function $y(e){return(e/Qy).toFixed(1)}var Dge=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*Qy;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 ${$y(n)} min ago`};let r=`${$y(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 ${$y(n)} min ago, ${r}`}}},eb=x([`string`,`number`,`boolean`,`select`]),Oge=/^[A-Za-z_][A-Za-z0-9_]*$/,tb=c([p(),f(),v()]),nb=b({name:p().regex(Oge),label:p().min(1).max(120).optional(),type:eb,required:v().optional(),default:tb.optional(),options:S(p().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&&rb(e,e.default)!==null&&t.addIssue({code:`custom`,message:rb(e,e.default)??`invalid default`,path:[`default`]})});function rb(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 kge(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=rb(e,t);if(n!==null)return{ok:!1,error:n};i[e.name]=t}return{ok:!0,values:i}}var ib=x([`internal`,`addon`]),ab=`internal:`;function Age(e){return`${ab}${e}`}function ob(e){return e.startsWith(`internal:`)&&e.length>9}function sb(e){if(ob(e))return null;let t=e.indexOf(`:`);return t>0&&t<e.length-1?e.slice(0,t):null}var cb=b({isRunning:v(),lastRunAt:f().nullable(),lastError:p().nullable()}),jge={isRunning:!1,lastRunAt:null,lastError:null},lb=f().int().min(0).max(86400),ub=b({id:p().min(3),name:p().min(1).max(120),addonId:p().min(1),source:ib,readOnly:v(),steps:S(F_).min(1).max(50).optional(),variables:S(nb).max(20).optional(),minDelaySec:lb.optional(),tags:oh.optional(),status:cb}).superRefine((e,t)=>{if(e.source===`internal`){ob(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`]}),sb(e.id)===null&&t.addIssue({code:`custom`,message:`an addon action id is <addonId>:<localId>`,path:[`id`]})}),db=b({name:p().min(1).max(120),steps:S(F_).min(1).max(50),variables:S(nb).max(20).optional(),minDelaySec:lb.optional(),tags:oh.optional()}),fb=b({blockId:p().min(1).optional()}),pb=c([Iv,o(`started`),o(`timed-out`)]),mb=b({runId:p().min(1),outcome:pb,message:p().optional()}),Mge=x([`not-found`,`read-only`,`invalid-variables`,`invalid-steps`,`not-linked`,`template-scope`,`busy`]),Nge=class extends Error{code;constructor(e,t){super(`[${e}] ${t}`),this.name=`ActionError`,this.code=e}},hb=b({actionId:p(),runId:p(),isRunning:v(),outcome:Iv.optional(),lastRunAt:f().nullable(),lastError:p().nullable()});function Pge(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 gb(e){return[...e.kind===`command`&&e.target.kind===`devices`?[{actionId:e.actionId,ids:e.target.ids}]:[],...Pge(e).flatMap(gb)]}async function Fge(e,t){let n=e.flatMap(gb);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){Ea(e,void 0);for(let n of t)xne(e,n,i.get(n)??[])}}async function Ige(e,t,n=Date.now,r,i,a){let o=r?.mirror??new Ty(xy(e));await o.refresh(t);let s=My(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 Lge(e){try{return await e()}catch(e){return{result:`unknown`,reason:e instanceof Error?e.message:String(e)}}}async function Rge(e){let t=e.now(),n=t+e.timeoutMs;for(;;){let r=await Lge(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 zge(e,t){return`timed out after ${e} s: ${t}`}function _b(e){return Gi(e)}function vb(e){let t=_b(e);if(t===void 0)return[];let n=qc(t);return n===void 0?[t]:[t,...Qc(n).filter(e=>e!==t)]}var yb=b({path:p(),deviceId:f().int().optional(),field:p(),value:f(),assumedUnit:p(),message:p()});function Bge(e){let t=wg(e);return t instanceof se?t:void 0}function bb(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[...Tg(r.schema),...r.itemArray===void 0?[]:vpe(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=Bge(i)?.shape[r];return a===void 0?void 0:Tpe(a)}}}function xb(e){return Dg(e)??e}function Sb(e){return vb(e).length>1}function Cb(e){return{...e,message:`${e.field}: the bare number ${e.value} was taken as ${e.assumedUnit} — send { value, unit } to state the unit`}}function wb(e,t){Mg({value:1,unit:e,target:t})}function Vge(e,t,n){let r=t.fieldQuantity(e.cap,e.fieldPath),i=r===void 0?void 0:_b(r),a=jg(e.value)||e.unit!==void 0;if(i===void 0||r===void 0){if(a)throw new kg(`no-quantity`,`${e.cap}.${e.fieldPath} is not a quantity — it takes no unit`);return{leaf:e,warnings:[]}}if(jg(e.value)){let t=Mg({value:e.value.value,unit:e.value.unit,target:i});return{leaf:{...e,value:t,unit:xb(e.value.unit)},warnings:[]}}return typeof e.value==`number`?e.unit===void 0?Sb(r)?{leaf:e,warnings:[Cb({path:n,deviceId:e.deviceId,field:e.fieldPath,value:e.value,assumedUnit:i})]}:{leaf:e,warnings:[]}:(wb(e.unit,i),{leaf:e,warnings:[]}):{leaf:e,warnings:[]}}function Tb(e,t,n=`when`){switch(e.kind){case`device-is`:{let{leaf:r,warnings:i}=Vge(e,t,n);return{value:r,warnings:i}}case`not`:{let r=Tb(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)=>Tb(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 Hge(e,t,n){let r=e.target.kind===`devices`&&e.target.ids.length===1?e.target.ids[0]:void 0,{cap:i,method:a}=Ea(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 kg(`no-quantity`,`${i}.${a}(${n}) is not a quantity — it takes no unit`);wb(r,e.unit)}for(let[l,u]of Object.entries(e.args??{})){let e=t.paramMeta(i,a,l);e!==void 0&&(jg(u)?(o[l]=Mg({value:u.value,unit:u.unit,target:e.unit}),s[l]=xb(u.unit)):typeof u==`number`&&s[l]===void 0&&Sb(e.quantity)&&c.push(Cb({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 Eb(e,t,n=`steps`){let r=[],i=[];return e.forEach((e,a)=>{if(e.kind!==`command`){r.push(e);return}let o=Hge(e,t,`${n}.${a}`);r.push(o.value),i.push(...o.warnings)}),{value:r,warnings:i}}function Db(e,t){let n=Tb(e.when,t,`when`),r=Eb(e.actions,t,`actions`);return{value:{...e,when:n.value,actions:r.value},warnings:[...n.warnings,...r.warnings]}}function Ob(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||vb(n).length<2)return e;let r=_b(n);return r===void 0?e:{...e,unit:r}}case`not`:return{...e,child:Ob(e.child,t)};case`all`:case`any`:return{...e,children:e.children.map(e=>Ob(e,t))};default:return e}}function Uge(e,t){if(e.kind!==`command`||e.args===void 0)return e;let{cap:n,method:r}=Ea(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&&vb(e.quantity).length>1&&(i[a]=e.unit)}return Object.keys(i).length===0?e:{...e,argUnits:i}}function kb(e,t){let n={...e,when:Ob(e.when,t),actions:e.actions.map(e=>Uge(e,t))};try{return{ok:!0,recipe:Db(n,t).value}}catch(e){if(e instanceof kg)return{ok:!1,error:e.message};throw e}}var Wge=[`devices`,`time`,`cameras`,`events`,`logic`,`system`],Ab=[`trigger`,`any`],jb=[`trigger`,`guard`,`any`],Mb={detection:{kind:`detection`,category:`cameras`,role:`event`,allowedIn:Ab,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:Ab,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:Ab,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:Ab,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:Ab,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:Ab,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:Ab,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:Ab,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:jb,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:jb,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:jb,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:jb,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:jb,i18nKey:`automation.leafCatalog.expression`,keywords:[`formula`,`math`,`arithmetic`,`sum`,`compare`,`calculate`,`held`],needsDeviceValue:!1,seed:()=>({kind:`expression`,expr:``,bindings:{}})}},Nb=[`detection`,`stationary`,`device-becomes`,`device-fired`,`device-event`,`schedule`,`interval`,`manual`,`device-is`,`stationary-present`,`time-is`,`triggered-by`,`expression`];function Gge(e){return Mb[e]}function Kge(e){return Mb[e].seed()}function qge(e){return Nb.filter(t=>Mb[t].allowedIn.includes(e))}function Pb(e){return e instanceof Error?e.message:String(e)}function Jge(e){return e.startsWith(`[busy]`)?`already-running`:e.startsWith(`[not-found]`)?`not-found`:null}async function Yge(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=Pb(e),i=Jge(n);return i===null?(t.warn(`${r}: exported action failed`,{tags:a,meta:{message:n}}),{status:`failed`,message:n}):o(i,n)}}async function Xge(e,t,n){let{exporter:r,targetId:i}=n,a={targetId:i};try{let{targets:o,unreadable:s}=await Mu(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:nu.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=Pb(e);return t.warn(`${r}: exported notifier send failed`,{tags:a,meta:{message:n}}),{status:`failed`,message:n}}}function Zge(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 Fb=p().min(1),Ib=b({instanceId:Fb.optional()}),Lb=b({instanceId:Fb,name:p(),enabled:v(),kind:p().optional(),nameRule:p().optional()}),Rb=`export-instance-unknown`,zb=class extends Error{code=Rb;instanceId;constructor(e,t){super(`${Rb}: ${e} serves no instance "${t}"`),this.name=`ExportInstanceUnknownError`,this.instanceId=t}};function Bb(e){return`instanceId`in e?e.instanceId:void 0}function Qge(e,t,n){if(n!==void 0&&n!==t)throw new zb(e,n)}var $ge=x([`unlinked`,`linked`,`error`]),Vb=b({label:p(),value:p(),secret:v().optional()}),Hb=b({qr:p().optional(),fields:S(Vb).readonly().optional(),note:p().optional()}),Ub=b({linkState:$ge,exposedDeviceCount:f(),error:p().optional(),setup:Hb.optional()}),e_e=p(),Wb=b({deviceId:p(),exposedAs:p().optional(),exposedName:p().optional(),capabilities:S(p()).optional()}),Gb=b({instanceId:Fb,deviceId:p(),capabilities:S(p()).optional(),exposedName:p().nullable().optional()}),Kb=b({instanceId:Fb,deviceId:p(),name:p().nullable(),dryRun:v().optional()}),qb=`export-name-refused`,Jb=class extends Error{code=qb;instanceId;reason;constructor(e,t){super(`${qb}: ${t}`),this.name=`ExportNameRefusedError`,this.instanceId=e,this.reason=t}},Yb=b({instanceId:Fb,deviceId:p()}),Xb=x([`device`,`action`,`notifier`]),Zb=i(`kind`,[b({kind:o(`device`),deviceId:p()}),b({kind:o(`action`),actionId:p().min(1)}),b({kind:o(`notifier`),targetId:p().min(1)})]),Qb=b({entity:Zb,exposedAs:p().optional()}),$b=b({instanceId:Fb,entity:Zb}),ex=b({instanceId:Fb,entity:Zb}),tx={name:`device-export`,scope:`system`,mode:`collection`,providerKind:`device-export`,status:{schema:Ub,kind:`poll`},exposesDeviceSettings:!0,methods:{getStatus:O(Ib,Ub),listInstances:O(_(),S(Lb)),listSupportedDeviceKinds:O(Ib,S(e_e)),listExposedDevices:O(Ib,S(Wb)),exposeDevice:O(Gb,_(),{kind:`mutation`,auth:`admin`}),unexposeDevice:O(Yb,_(),{kind:`mutation`,auth:`admin`}),setExposedName:O(Kb,_(),{kind:`mutation`,auth:`admin`}),listSupportedEntityKinds:k(_(),S(Xb)),listExposedEntities:k(Ib,S(Qb)),exposeEntity:k($b,_(),{kind:`mutation`,auth:`admin`}),unexposeEntity:k(ex,_(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`exports to other ecosystems — configured on the export pages`}},nx=`exposedNames`,t_e=u(p(),p());function rx(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 ix(e){let t=t_e.safeParse(e[nx]);return t.success?t.data:{}}function n_e(e,t,n){let r=ix(e)[t];if(r===void 0)return null;let i=rx(r,n);return i.ok?i.name:null}function ax(e,t,n){let r=Object.fromEntries(Object.entries(ix(e)).filter(([e])=>e!==t));return{[nx]:n===null?r:{...r,[t]:n}}}async function r_e(e){let t=rx(e.raw,e.validate);if(!t.ok)throw new Jb(e.instanceId,t.reason);if(e.dryRun===!0)return{changed:!1,name:t.name};let n=await e.store.read(e.deviceId);return(ix(n)[e.instanceId]??null)===t.name?{changed:!1,name:t.name}:(await e.store.write(e.deviceId,ax(n,e.instanceId,t.name)),{changed:!0,name:t.name})}function i_e(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 a_e(e,t){let n=await e.listDeviceStoreIds();if(n.length===0)return[];let r=[];for(let[i,a]of await e.readDeviceStoreBatch(n))ix(a)[t]!==void 0&&(await e.writeDeviceStore(i,ax(a,t,null)),r.push(i));return r}function o_e(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 ox=[`automation`,`action`,`scheduler`,`composition`],s_e=x(ox),sx=b({id:f().int().nonnegative(),name:p().min(1),type:p().min(1),room:p().min(1).nullable(),addonId:p().min(1),stableId:p().min(1),caps:S(p().min(1)),zones:S(p().min(1)).optional()}),c_e=b({timeZone:p().min(1),location:b({latitude:f(),longitude:f()}).nullable(),rooms:S(p().min(1)),devices:S(sx).min(1),actions:S(b({id:p().min(1),name:p().min(1)})).default([])}),l_e=60,cx=b({childDeviceIds:S(f()).readonly(),hiddenChildIds:S(f()).readonly()}),lx={name:`accessories`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Camera,w.Switch,w.Light,w.Sensor,w.Climate,w.Cover,w.Lock,w.Fan,w.MediaPlayer,w.AlarmPanel,w.Generic],methods:{setChildHidden:O(b({deviceId:f().int().nonnegative(),childDeviceId:f().int().nonnegative(),hidden:v()}),_(),{kind:`mutation`,auth:`admin`})},events:{onAccessoriesChanged:{data:b({deviceId:f(),childDeviceIds:S(f()).readonly(),hiddenChildIds:S(f()).readonly()}),notOperatorFacing:`the device’s child list changed — administration, not a happening`},onChildVisibilityChanged:{data:b({deviceId:f(),childDeviceId:f(),hidden:v()}),notOperatorFacing:`an operator hid or showed a child — administration, not a happening`}},status:{schema:cx,kind:`command-driven`},vocabulary:{noun:N(`Accessories`,`Accessori`),order:3e3}},ux={name:`action-source`,scope:`system`,mode:`collection`,methods:{listActions:O(b({}),S(ub),{auth:`admin`}),runAction:O(b({actionId:p().min(1),variables:u(p(),tb).optional()}),_(),{kind:`mutation`,auth:`admin`}),stopAction:O(b({actionId:p().min(1)}),_(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:A.INTERNAL}},u_e=60*6e4,d_e=3e4,dx=363e4;function f_e(e){let t=0;for(let n of e)n.kind===`wait`&&(t+=n.seconds*1e3);return t}var fx=b({actionId:p().min(1)}),px=b({deviceId:f().int().nonnegative(),actionIds:S(p().min(1)).max(100)}),mx={name:`actions`,scope:`system`,mode:`singleton`,methods:{list:O(b({}),S(ub),{auth:`admin`}),get:O(b({actionId:p().min(1),deviceId:f().int().nonnegative().optional()}),b({action:ub.nullable()}),{role:`viewer`,auth:`protected`,kind:`query`,caller:`required`}),run:O(b({actionId:p().min(1),variables:u(p(),tb).optional(),wait:v().optional(),origin:fb.optional(),deviceId:f().int().nonnegative().optional()}),mb,{role:`viewer`,auth:`protected`,kind:`mutation`,caller:`required`,timeoutMs:dx}),stop:O(fx,_(),{kind:`mutation`,auth:`admin`}),getTraces:O(fx,b({traces:S(Gv)}),{auth:`admin`}),create:O(b({action:db}),b({action:ub,warnings:S(yb).optional()}),{kind:`mutation`,auth:`admin`}),update:O(b({actionId:p().min(1),action:db.partial()}),b({action:ub,warnings:S(yb).optional()}),{kind:`mutation`,auth:`admin`}),delete:O(fx,_(),{kind:`mutation`,auth:`admin`}),listForCamera:O(b({deviceId:f().int().nonnegative()}),S(ub),{role:`viewer`,auth:`protected`,kind:`query`}),getLinks:O(b({deviceId:f().int().nonnegative()}),px,{auth:`admin`}),setLinks:O(px,px,{kind:`mutation`,auth:`admin`})},events:{onRunChanged:{data:hb}},vocabulary:{notOperatorFacing:`declared actions — run from the Actions page and from the cameras that link them`}},p_e=b({id:p(),label:p(),icon:p(),path:p(),remoteName:p(),bundle:p(),section:p().optional(),sectionLabel:p().optional()}),hx=b({addonId:p(),page:p_e,bundleUrl:p()}),gx={name:`addon-pages`,scope:`system`,mode:`singleton`,methods:{listPages:O(_(),S(hx).readonly())},vocabulary:{notOperatorFacing:A.UI_PLUMBING}},m_e=b({method:x([`GET`,`POST`,`PUT`,`DELETE`,`PATCH`]),path:p(),access:x([`public`,`authenticated`,`admin`]).optional(),description:p().optional(),rateLimit:x([`auth`]).optional(),perInstance:v().optional()}),h_e=b({method:p(),path:p(),params:u(p(),p()),query:u(p(),p()),body:l(),headers:u(p(),p()),instanceId:p().optional(),user:b({id:p(),username:p(),isAdmin:v()}).optional(),scopedToken:l().optional()}),g_e=b({status:f().int(),headers:u(p(),p()),redirectUrl:p().nullable(),body:l().optional(),contentType:p().optional()}),_x={name:`addon-routes`,scope:`system`,mode:`collection`,internal:!0,methods:{getRoutes:O(_(),S(m_e)),invoke:O(h_e,g_e,{kind:`mutation`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:A.UI_PLUMBING}},vx=b({id:p(),label:p(),icon:p(),order:f().optional()}),yx=b({id:p(),title:p(),titleKey:p().optional(),description:p().optional(),descriptionKey:p().optional(),style:x([`card`,`accordion`]).optional(),defaultCollapsed:v().optional(),columns:c([o(1),o(2),o(3),o(4)]).optional(),tab:p().optional(),location:x([`settings`,`top-tab`,`hero`]).optional(),order:f().optional(),fields:S(he())}),bx=b({tabs:S(vx).optional(),sections:S(yx)}),xx=u(p(),l()),Sx=x(Gn),__e=b({cap:p(),scope:Sx,sectionIds:S(p())}),Cx=b({success:o(!0)}),wx={name:`addon-settings`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,methods:{getScopedSettings:O(b({addonId:p(),cap:p(),scope:Sx,nodeId:p().optional()}),bx.nullable()),listScopedSettings:O(b({addonId:p(),nodeId:p().optional()}),S(__e).nullable()),updateScopedSettings:O(b({addonId:p(),cap:p(),scope:Sx,nodeId:p().optional(),patch:xx}),Cx,{kind:`mutation`,auth:`admin`}),readScopedValues:O(b({addonId:p(),cap:p(),scope:Sx,nodeId:p().optional()}),u(p(),l()).nullable()),getDeclaredSettingsKeys:O(b({addonId:p(),nodeId:p().optional()}),b({keys:S(p())}).nullable(),{auth:`admin`}),unsetStoredSettingsKeys:O(b({addonId:p(),nodeId:p().optional(),keys:S(p())}),b({removed:S(p()),refused:S(b({key:p(),reason:p()})),secretsCleared:f()}),{kind:`mutation`,auth:`admin`}),getDeviceSettings:O(b({addonId:p(),deviceId:f(),nodeId:p().optional()}),bx.nullable()),updateDeviceSettings:O(b({addonId:p(),deviceId:f(),nodeId:p().optional(),patch:xx}),Cx,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:A.ADDON_ADMIN}},Tx=x([`device-tab`,`dashboard`,`integration-detail`]),Ex=x([`xs`,`sm`,`md`,`lg`,`xl`]),Dx=b({remoteName:p(),exposedModule:p(),componentKey:p().optional()}),Ox=b({tab:p(),subTab:p().optional(),label:p(),order:f().optional(),kind:o(`remote`),remote:Dx,stableId:p(),description:p().optional(),icon:p().optional(),bundle:p(),hosts:S(Tx).readonly(),requires:b({deviceContext:v().default(!1),integrationContext:v().default(!1)}),preAuth:v().optional().default(!1),defaultSize:Ex.default(`md`),allowedSizes:S(Ex).readonly().default([`sm`,`md`,`lg`]),defaultColumns:f().int().min(1).max(12).default(6),defaultRows:f().int().min(1).max(12).default(1)}),kx={name:`addon-widgets-source`,scope:`system`,mode:`collection`,internal:!0,methods:{listWidgets:O(_(),S(Ox).readonly(),{auth:`admin`})},vocabulary:{notOperatorFacing:A.UI_PLUMBING}},Ax=Ox.extend({addonId:p(),bundleUrl:p()}),jx={name:`addon-widgets`,scope:`system`,mode:`singleton`,methods:{listWidgets:O(_(),S(Ax).readonly())},vocabulary:{notOperatorFacing:A.UI_PLUMBING}},Mx=x([`install`,`update`,`uninstall`,`restart`]),Nx=x([`queued`,`fetching`,`staged`,`validating`,`applying`,`restarting`,`applied`,`done`,`failed`,`skipped`]),Px=x([`framework`,`addon`]),Fx=b({tsMs:f(),nodeId:p(),packageName:p(),phase:Nx,message:p()}),Ix=b({taskId:p(),nodeId:p(),packageName:p(),fromVersion:p().nullable(),toVersion:p(),target:Px,phase:Nx,stagedPath:p().nullable(),attempts:f(),steps:S(Fx),error:p().nullable(),startedAtMs:f().nullable(),finishedAtMs:f().nullable()}),Lx=x([`running`,`completed`,`failed`,`partially-failed`,`cancelled`]),Rx=x([`single`,`bulk`,`cluster`]),zx=b({jobId:p(),kind:Mx,createdAtMs:f(),createdBy:p(),scope:Rx,tasks:S(Ix),state:Lx,schemaVersion:o(1)}),Bx=x([`debug`,`info`,`warn`,`error`]),Vx=x([`off`,`latest`,`beta`]),Hx=x([`off`,`latest`,`beta`,`inherit`]),v_e=b({id:p(),name:p().optional(),version:p().optional(),description:p().optional(),icon:p().optional(),color:p().optional(),capabilities:S(l()).readonly().optional(),packageName:p(),packageVersion:p(),packageDisplayName:p().optional(),bundle:b({displayName:p(),description:p().optional(),icon:p().optional()}).optional(),protected:v().optional(),removable:v().optional(),integrationSection:x([`system`,`providers`]).optional()}),y_e=b({pid:f().optional(),mode:p(),state:p(),reason:p().optional()}),b_e=b({phase:x([`pending`,`healthy`,`failed`]),retryCount:f(),firstFailureAt:f().nullable(),lastAttemptAt:f().nullable(),lastError:b({message:p(),stack:p().optional()}).nullable(),nextRetryAt:f().nullable(),alertEmitted:v(),retrying:v(),inGracePeriod:v()}),Ux=b({manifest:v_e,declaration:l().optional(),source:p(),installSource:p().optional(),process:y_e.optional(),hasBackup:v().optional(),health:b_e.nullable().optional()}),Wx=b({name:p(),version:p(),dir:p(),installSource:p().optional()}),Gx=b({name:p(),currentVersion:p(),latestVersion:p(),category:x([`addon`,`core`]),requiresRestart:v(),isSystem:v(),blockedBy:S(Il).readonly().optional()}),Kx=b({version:p(),publishedAt:p(),deprecated:p().optional(),distTags:S(p()).readonly()}),qx=i(`status`,[b({status:o(`ok`),markdown:p()}),b({status:o(`missing`)}),b({status:o(`error`),message:p()})]),x_e=b({name:p(),version:p(),readme:qx,changelog:qx}),Jx=b({name:p(),version:p(),description:p(),keywords:S(p()).readonly(),publishedAt:p(),author:p(),installed:v(),installedVersion:p().optional(),capabilities:S(p()).readonly().nullable()}),Yx=b({channel:Vx,intervalSeconds:f(),updateCheckIntervalSeconds:f()}),Xx=Hx,S_e=l(),C_e=l(),w_e=l(),Zx=x([`uninstalled`,`not-installed`,`refused`,`failed`,`pending-reconnect`]),Qx=b({nodeId:p(),outcome:Zx,error:p().optional(),addonIds:S(p()).readonly(),runnersStopped:S(p()).readonly(),warnings:S(p()).readonly()}),$x=b({success:v(),packageName:p(),results:S(Qx).readonly()}),eS=b({packageName:p(),nodeId:p(),nodeName:p(),isHub:v(),isOnline:v(),version:p().nullable(),addonIds:S(p()).readonly(),source:x([`live`,`recorded`]),onHub:v()}),tS=b({installations:S(eS).readonly(),unreachable:S(b({nodeId:p(),error:p()})).readonly()}),T_e=x([`queued`,`updating`,`done`,`done-pending-restart`,`failed`]),E_e=b({name:p(),isSystem:v(),fromVersion:p(),toVersion:p(),status:T_e,error:p().optional(),startedAtMs:f().optional(),completedAtMs:f().optional()}),D_e=x([`regular`,`system`,`restarting`,`finalizing`]);b({id:p(),nodeId:p(),startedAtMs:f(),completedAtMs:f().optional(),total:f(),completed:f(),failed:f(),current:p().nullable(),phase:D_e,cancelled:v(),items:S(E_e).readonly()});var O_e=b({packageName:p(),currentVersion:p(),latestVersion:p().nullable(),hasUpdate:v(),description:p().optional(),buildId:p().nullable()}),nS=b({timestamp:p(),level:p(),message:p(),scope:p().optional()}),k_e=l(),rS=b({addonId:p().min(1),action:p().min(1),input:l()}),iS={name:`addons`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,methods:{list:O(b({nodeId:p().optional()}).optional(),S(Ux).readonly()),getLogs:O(b({addonId:p(),limit:f().min(1).max(500).default(100),level:Bx.optional()}),S(k_e)),listPackages:O(_(),S(Wx).readonly()),installPackage:O(b({packageName:p(),version:p().optional()}),C_e,{kind:`mutation`,auth:`admin`}),uninstallPackage:O(b({packageName:p().min(1),nodeId:p().optional(),everywhere:v().optional()}),$x,{kind:`mutation`,auth:`admin`}),listInstallations:O(b({packageName:p().optional()}),tS,{auth:`admin`}),reloadPackages:O(_(),w_e,{kind:`mutation`,auth:`admin`}),searchAvailable:O(b({query:p().optional(),capability:p().optional()}),S(Jx)),listUpdates:O(b({nodeId:p().optional()}),S(Gx).readonly(),{auth:`admin`}),updatePackage:O(b({name:p().min(1),version:p().optional(),nodeId:p().optional()}),l(),{kind:`mutation`,auth:`admin`}),rollbackPackage:O(b({name:p().min(1)}),b({rolledBackTo:p().nullable()}),{kind:`mutation`,auth:`admin`}),forceRefresh:O(b({nodeId:p().optional()}),l(),{kind:`mutation`,auth:`admin`}),restartServer:O(b({confirm:o(!0)}),l(),{kind:`mutation`,auth:`admin`}),getLastRestart:O(_(),b({kind:x([`framework-update`,`manual`,`system`,`framework-bulk-update`]),packageName:p().optional(),fromVersion:p().optional(),toVersion:p().optional(),requestedBy:p().optional(),requestedAt:f()}).nullable(),{auth:`admin`}),listFrameworkPackages:O(_(),S(O_e).readonly(),{auth:`admin`}),listCapabilityProviders:O(b({capName:p().min(1)}),S(b({addonId:p(),mode:x([`singleton`,`collection`]),isActive:v()})).readonly()),setCapabilityProviderEnabled:O(b({capName:p().min(1),addonId:p().min(1),enabled:v()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),getVersions:O(b({name:p()}),S(Kx).readonly()),getPackageDocs:O(b({name:p().min(1),version:p().min(1).optional()}),x_e,{auth:`admin`}),restartAddon:O(b({addonId:p()}),S_e,{kind:`mutation`,auth:`admin`}),retryLoad:O(b({packageName:p()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),getAutoUpdateSettings:O(_(),Yx,{auth:`admin`}),setAutoUpdateSettings:O(b({channel:Vx,intervalSeconds:f().min(300).max(86400).optional(),updateCheckIntervalSeconds:f().min(900).max(604800).optional()}),l(),{kind:`mutation`,auth:`admin`}),getAddonAutoUpdate:O(b({addonId:p()}),Xx,{auth:`admin`}),setAddonAutoUpdate:O(b({addonId:p(),channel:Hx}),l(),{kind:`mutation`,auth:`admin`}),applyAutoUpdateToAll:O(b({channel:Vx}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),custom:O(rS,l(),{role:`viewer`,kind:`mutation`}),startJob:O(b({kind:x([`install`,`update`,`uninstall`,`restart`]),targets:S(b({name:p().min(1),version:p().min(1)})).min(1),nodeIds:S(p()).optional()}),b({jobId:p()}),{kind:`mutation`,auth:`admin`}),getJob:O(b({jobId:p()}),zx.nullable(),{auth:`admin`}),listJobs:O(b({activeOnly:v().optional()}),S(zx),{auth:`admin`}),cancelJob:O(b({jobId:p()}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`}),onAddonLogs:O(b({addonId:p(),level:Bx.optional()}),nS,{kind:`subscription`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:A.ADDON_ADMIN}},aS=b({co2:f().min(0).optional().meta(j(`concentration-volume`)),voc:f().min(0).optional().meta(j(`concentration-ppb`)),pm25:f().min(0).optional().meta(j(`concentration-mass`)),pm10:f().min(0).optional().meta(j(`concentration-mass`)),aqi:f().optional().meta(j(`index`)),lastFetchedAt:f()}),oS={name:`air-quality-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Sensor],methods:{},status:{schema:aS,kind:`push`},runtimeState:aS,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:N(`Air quality`,`Qualità dell’aria`),order:5e3,state:[{kind:`numeric`,field:`co2`,quantity:N(`the CO₂`,`la CO₂`),label:N(`CO₂`,`CO₂`),unit:`ppm`,icon:`wind`},{kind:`numeric`,field:`voc`,quantity:N(`the VOC level`,`il livello di COV`),label:N(`VOC`,`COV`),unit:`ppb`,icon:`wind`},{kind:`numeric`,field:`pm25`,quantity:N(`the PM2.5`,`il PM2,5`),label:N(`PM2.5`,`PM2,5`),unit:`µg/m³`,icon:`cloud-fog`},{kind:`numeric`,field:`pm10`,quantity:N(`the PM10`,`il PM10`),label:N(`PM10`,`PM10`),unit:`µg/m³`,icon:`cloud-fog`},{kind:`numeric`,field:`aqi`,quantity:N(`the air quality index`,`l’indice di qualità dell’aria`),label:N(`AQI`,`IQA`),icon:`wind`}]}},sS=x([`disarmed`,`armed_home`,`armed_away`,`armed_night`,`armed_vacation`,`armed_custom_bypass`,`arming`,`disarming`,`pending`,`triggered`]),cS=x([`home`,`away`,`night`,`vacation`,`custom_bypass`]),lS=b({state:sS,targetMode:cS.nullable().optional(),availableModes:S(cS),requiresCode:v(),lastChangedAt:f()}),uS={name:`alarm-panel`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.AlarmPanel],methods:{trigger:O(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`alarm.trigger`,label:N(`Trigger alarm`,`Fai scattare l’allarme`),phrase:N(`Trigger the alarm on {device}`,`Fai scattare l’allarme su {device}`),icon:`siren`}]}),disarm:O(b({deviceId:f().int().nonnegative(),code:p().min(1).optional()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`alarm.disarm`,label:N(`Disarm`,`Disinserisci`),phrase:N(`Disarm {device}`,`Disinserisci {device}`),icon:`shield-off`,effect:{field:`state`,value:`disarmed`},openArgs:[{key:`code`,label:N(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]}),arm:O(b({deviceId:f().int().nonnegative(),mode:cS,code:p().min(1).optional()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`alarm.arm.home`,label:N(`Arm home`,`Inserisci in casa`),phrase:N(`Arm {device} for home`,`Inserisci {device} in modalità casa`),icon:`house`,effect:{field:`state`,value:`armed_home`},args:{mode:`home`},openArgs:[{key:`code`,label:N(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.away`,label:N(`Arm away`,`Inserisci fuori casa`),phrase:N(`Arm {device} for away`,`Inserisci {device} in modalità fuori casa`),icon:`shield-check`,effect:{field:`state`,value:`armed_away`},args:{mode:`away`},openArgs:[{key:`code`,label:N(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.night`,label:N(`Arm night`,`Inserisci notte`),phrase:N(`Arm {device} for the night`,`Inserisci {device} in modalità notte`),icon:`moon`,effect:{field:`state`,value:`armed_night`},args:{mode:`night`},openArgs:[{key:`code`,label:N(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.vacation`,label:N(`Arm vacation`,`Inserisci vacanza`),phrase:N(`Arm {device} for vacation`,`Inserisci {device} in modalità vacanza`),icon:`plane`,effect:{field:`state`,value:`armed_vacation`},args:{mode:`vacation`},openArgs:[{key:`code`,label:N(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.custom_bypass`,label:N(`Arm custom bypass`,`Inserisci con esclusioni`),phrase:N(`Arm {device} with its custom bypass`,`Inserisci {device} con le zone escluse`),icon:`shield-half`,effect:{field:`state`,value:`armed_custom_bypass`},args:{mode:`custom_bypass`},openArgs:[{key:`code`,label:N(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]})},status:{schema:lS,kind:`push`},runtimeState:lS,durability:`restored`,history:{fields:{state:{kind:`enum`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:N(`Alarm panel`,`Centrale d’allarme`),order:1120,state:[{kind:`enum`,field:`state`,label:N(`Alarm state`,`Stato dell’allarme`),values:[{value:`disarmed`,label:N(`Disarmed`,`Disinserito`),phrase:N(`When {device} is disarmed`,`Quando {device} viene disinserito`)},{value:`armed_home`,label:N(`Armed home`,`Inserito in casa`),phrase:N(`When {device} is armed for home`,`Quando {device} viene inserito in modalità casa`)},{value:`armed_away`,label:N(`Armed away`,`Inserito fuori casa`),phrase:N(`When {device} is armed for away`,`Quando {device} viene inserito in modalità fuori casa`)},{value:`armed_night`,label:N(`Armed night`,`Inserito notte`),phrase:N(`When {device} is armed for the night`,`Quando {device} viene inserito in modalità notte`)},{value:`armed_vacation`,label:N(`Armed vacation`,`Inserito vacanza`)},{value:`armed_custom_bypass`,label:N(`Armed with bypass`,`Inserito con esclusioni`)},{value:`arming`,label:N(`Arming`,`In inserimento`)},{value:`disarming`,label:N(`Disarming`,`In disinserimento`)},{value:`pending`,label:N(`Entry delay`,`Ritardo d’ingresso`)},{value:`triggered`,label:N(`Triggered`,`In allarme`),phrase:N(`When {device} goes off`,`Quando {device} scatta`)}],icon:`shield`}]}},dS=x([`info`,`success`,`warning`,`error`,`critical`]),A_e=b({addonId:p().min(1),action:p().min(1),input:u(p(),l()).optional()}),j_e=b({label:p(),href:p().optional(),invoke:A_e.optional(),navigation:x([`app`,`server`]).optional()}),fS=x([`active`,`in-progress`,`completed`,`failed`,`dismissed`]),pS=b({type:p(),id:p()}),mS=b({id:p(),category:p(),severity:dS,title:p(),message:p(),action:j_e.optional(),status:fS,progress:f().optional(),read:v(),createdAt:f(),updatedAt:f(),source:pS.optional(),metadata:u(p(),l()).optional()}),hS={name:`alerts`,scope:`system`,mode:`singleton`,methods:{emit:O(mS,_(),{kind:`mutation`}),update:O(b({alertId:p(),patch:mS.partial()}),_(),{kind:`mutation`}),list:O(b({unreadOnly:v().optional(),limit:f().optional()}).optional(),S(mS).readonly()),getUnreadCount:O(_(),f()),markRead:O(b({alertId:p()}),_(),{kind:`mutation`}),markAllRead:O(_(),_(),{kind:`mutation`}),dismiss:O(b({alertId:p()}),_(),{kind:`mutation`})},vocabulary:{notOperatorFacing:`the alert centre — read and acknowledged on its own page`}},gS=b({illuminance:f().min(0).nullable().meta(j(`illuminance`,{precision:0,label:`Illuminance`})),lastFetchedAt:f()}),_S={name:`ambient-light-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Sensor],methods:{},status:{schema:gS,kind:`push`},runtimeState:gS,durability:`restored`,history:{fields:{illuminance:{kind:`gauge`,unit:`lx`,deadbandPct:10,minIntervalMs:6e4}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:N(`Light level`,`Luminosità ambiente`),order:5010,state:[{kind:`numeric`,field:`illuminance`,quantity:N(`the light level`,`la luminosità`),label:N(`Illuminance`,`Illuminamento`),unit:`lx`,icon:`sun`}]}},vS={name:`audio-analysis`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[w.Camera],exposesDeviceSettings:!0,methods:{resolveDeviceSettings:O(b({deviceId:f()}),ge())},events:{onAudioLevel:Rr(b({deviceId:f(),rms:f(),dbfs:f()}),{notOperatorFacing:`a sound-level sample at stream rate; loud-noise rules belong to the detection pipeline`})},vocabulary:{noun:N(`Audio analysis`,`Analisi audio`),order:3010}},M_e=x([`jpeg`,`rgb`,`bgr`,`yuv420`,`gray`]),yS=b({data:ge(),format:M_e,width:f(),height:f(),timestamp:f()}),bS=b({x:f(),y:f(),w:f(),h:f()}),N_e=b({class:p(),originalClass:p(),score:f(),bbox:bS}),xS=b({data:y(Uint8Array),sampleRate:f(),channels:f(),timestamp:f(),deviceId:f().optional()}),SS=b({rms:f(),dbfs:f()}),CS=b({className:p(),originalClass:p().optional(),score:f()}),wS=[`superseded`,`error`,`timeout`,`disposed`],TS=i(`state`,[b({state:o(`classified`)}),b({state:o(`not-classified`),reason:x(wS)})]),ES=b({level:SS,classification:b({labels:S(CS).readonly(),inferenceMs:f()}).optional(),classifyOutcome:TS,timestamp:f()}),DS=b({minConfidence:f().min(0).max(1).default(.3),allowedClasses:S(p()).default([])}),OS=b({deviceId:f(),brokerId:p(),ingestNodeId:p(),settings:DS}),kS=b({attached:v(),replaced:v()}),AS=b({detached:v()}),jS=b({labels:S(CS).readonly(),rawLabels:S(CS).readonly().optional(),inferenceMs:f()}),P_e=[{value:`auto`,label:`Auto (platform default)`},{value:`apple-soundanalysis`,label:`Apple SoundAnalysis (macOS 12+)`},{value:`yamnet-onnx`,label:`YAMNet ONNX (cross-platform)`}],F_e={audioBackend:`auto`,probedBestAudioBackend:``},MS={name:`audio-analyzer`,scope:`system`,mode:`singleton`,methods:{analyseChunk:O(b({chunk:xS,settings:DS}),ES.nullable(),{kind:`mutation`}),classify:O(xS,jS,{timeoutMs:3e4}),attachDevice:O(OS,kS,{kind:`mutation`}),detachDevice:O(b({deviceId:f()}),AS,{kind:`mutation`}),isReady:O(_(),v()),dispose:O(_(),_(),{kind:`mutation`}),reprobeAudioEngine:O(_(),b({backend:p()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:A.PIPELINE}},NS=x([`f32le`,`s16le`]),PS=b({codec:p(),canDecode:v(),canEncode:v(),label:p().optional()}),FS=b({codec:p(),sourceSampleRate:f().int().positive(),sourceChannels:f().int().positive(),extraData:y(Uint8Array).optional(),targetSampleRate:f().int().positive(),targetChannels:f().int().positive(),targetFormat:NS.optional(),idleMs:f().int().positive().optional(),tag:p().optional()}),IS=b({codec:p(),sourceSampleRate:f().int().positive(),sourceChannels:f().int().positive(),sourceFormat:NS.optional(),targetSampleRate:f().int().positive(),targetChannels:f().int().positive(),bitrateKbps:f().int().positive().optional(),idleMs:f().int().positive().optional(),tag:p().optional()}),LS=b({data:y(Uint8Array),sampleRate:f().int().positive(),channels:f().int().positive(),format:NS,pts:f()}),RS=b({data:y(Uint8Array),codec:p(),pts:f(),frameComplete:v()}),I_e=b({sessionId:p(),kind:x([`decode`,`encode`]),codec:p(),sourceSampleRate:f(),sourceChannels:f(),targetSampleRate:f(),targetChannels:f(),format:NS,tag:p().optional(),createdAtMs:f(),lastActivityMs:f(),framesIn:f(),framesOut:f()}),zS={name:`audio-codec`,scope:`system`,mode:`singleton`,preferredProvider:`decoder-nodeav`,methods:{listSupportedCodecs:O(_(),S(PS).readonly()),canHandle:O(b({codec:p(),kind:x([`decode`,`encode`])}),v()),createDecodeSession:O(FS,b({sessionId:p(),nodeId:p()}),{kind:`mutation`}),createEncodeSession:O(IS,b({sessionId:p(),nodeId:p()}),{kind:`mutation`}),closeSession:O(b({sessionId:p(),nodeId:p().optional()}),_(),{kind:`mutation`}),pushEncodedFrame:O(b({sessionId:p(),nodeId:p().optional(),data:y(Uint8Array),pts:f().optional()}),_(),{kind:`mutation`}),pullPcm:O(b({sessionId:p(),nodeId:p().optional(),maxCount:f().int().positive().default(8)}),S(LS)),pushPcm:O(b({sessionId:p(),nodeId:p().optional(),data:y(Uint8Array),pts:f().optional()}),_(),{kind:`mutation`}),pullEncoded:O(b({sessionId:p(),nodeId:p().optional(),maxCount:f().int().positive().default(8)}),S(RS)),flushEncode:O(b({sessionId:p(),nodeId:p().optional()}),S(RS),{kind:`mutation`}),listActiveSessions:O(_(),S(I_e).readonly())},vocabulary:{notOperatorFacing:A.INTERNAL}},BS=b({className:p(),hits:f().int().nonnegative(),avgScore:f().min(0).max(1),peakScore:f().min(0).max(1)}),VS=b({ts:f().int(),windowSec:f().int().positive(),level:b({rms:f(),dbfs:f()}),peakDbfs:f(),avgDbfs:f(),current:b({className:p(),score:f().min(0).max(1),timestamp:f().int()}).nullable(),byClass:S(BS).readonly()}),HS=b({ts:f().int(),dbfs:f().nullable(),peakDbfs:f(),avgDbfs:f(),topClass:p().nullable(),topScore:f().min(0).max(1).nullable()}),US=b({points:S(HS).readonly(),effectiveSampleEveryMs:f().int().positive(),windowMsActual:f().int().nonnegative()}),WS={name:`audio-metrics`,scope:`device`,mode:`singleton`,deviceTypes:[w.Camera],methods:{getCurrentSnapshot:O(b({deviceId:f()}),VS.nullable()),getHistory:O(b({deviceId:f(),windowSec:f().int().positive().optional(),sampleEveryMs:f().int().positive().optional()}),US)},runtimeState:VS,durability:`session`,history:`none`,vocabulary:{noun:N(`Audio metrics`,`Metriche audio`),order:3020}},GS=b({userId:p(),username:p(),email:p().optional(),displayName:p().optional(),isAdmin:v().default(!1)}),KS={name:`auth-provider`,scope:`system`,mode:`collection`,internal:!0,methods:{validateCredentials:O(b({username:p(),password:p()}),GS.nullable(),{kind:`mutation`}),getLoginUrl:O(b({state:p()}),p()),handleCallback:O(u(p(),p()),GS,{kind:`mutation`}),validateToken:O(b({token:p()}),GS.nullable())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:A.IDENTITY}},qS=b({enabled:v(),isRunning:v(),lastTriggeredAt:f(),lastError:p().nullable(),lastChangedAt:f()}),JS={name:`automation-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Automation],methods:{enable:O(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`haAutomation.enable`,label:N(`Enable automation`,`Abilita l’automazione`),phrase:N(`Enable {device}`,`Abilita {device}`),icon:`toggle-right`}]}),disable:O(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`haAutomation.disable`,label:N(`Disable automation`,`Disabilita l’automazione`),phrase:N(`Disable {device}`,`Disabilita {device}`),icon:`toggle-left`}]}),trigger:O(b({deviceId:f().int().nonnegative(),skipCondition:v().optional()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`haAutomation.trigger`,label:N(`Trigger automation`,`Avvia l’automazione`),phrase:N(`Run {device} now`,`Esegui subito {device}`),icon:`workflow`}]})},status:{schema:qS,kind:`push`},runtimeState:qS,durability:`session`,history:`none`,vocabulary:{noun:N(`Automation`,`Automazione`),order:2100,state:[{kind:`boolean`,field:`enabled`,label:N(`Enabled`,`Abilitata`),whenTrue:N(`When {device} is enabled`,`Quando {device} viene abilitata`),whenFalse:N(`When {device} is disabled`,`Quando {device} viene disabilitata`),icon:`toggle-right`},{kind:`boolean`,field:`isRunning`,label:N(`Running`,`In esecuzione`),whenTrue:N(`When {device} starts running`,`Quando {device} parte`),whenFalse:N(`When {device} finishes`,`Quando {device} termina`),icon:`workflow`}]}},L_e=`.backup-snapshot`,R_e=`.backup-snapshot-partial`,YS=30*6e4,XS=b({databases:S(b({databaseId:bd,livePath:p()}))}),ZS=b({name:p(),rows:f().int().nonnegative()}),QS=b({livePath:p(),snapshotPath:p(),sizeBytes:f().int().nonnegative(),pageCount:f().int().nonnegative(),pageSize:f().int().positive(),tables:S(ZS),copyMs:f().nonnegative(),verifyMs:f().nonnegative(),takenAt:f()}),$S=QS.extend({databaseId:bd}),eC=b({databaseId:bd}),tC=QS.extend({livePath:p(),snapshotPath:p(),databaseId:bd.optional()}),nC={name:`database-snapshot`,scope:`system`,mode:`singleton`,internal:!0,methods:{listDatabases:O(b({}),XS,{auth:`admin`}),writeSnapshot:O(eC,$S,{kind:`mutation`,auth:`admin`,timeoutMs:YS})},vocabulary:{notOperatorFacing:A.INTERNAL}},rC=b({subId:p(),displayName:p(),description:p().optional(),kind:p(),triggerSupported:v(),restoreSupported:v()}).extend({id:p(),addonId:p(),enabled:v(),retentionCount:f(),label:p().optional(),lastSuccessAt:f().optional(),lastSuccessSizeBytes:f().optional(),cron:p().optional(),nextRunAt:f().optional(),lastAttemptAt:f().optional(),lastError:p().optional()}),iC=b({scheme:p(),keyId:p()}),aC=b({enabled:v(),active:b({keyId:p(),publicKey:p(),createdAt:f()}).nullable(),keys:S(b({keyId:p(),createdAt:f(),retiredAt:f().nullable()})).readonly()}),z_e=b({id:p(),filename:p(),createdAt:f(),sizeBytes:f(),label:p().optional(),locations:S(p()).readonly(),encryption:iC.optional(),databases:S(bd).readonly().optional()}),oC=b({id:p(),destinationId:p().optional(),label:p().optional(),createdAt:f(),sizeBytes:f(),locations:S(p()).optional(),encryption:iC.optional()}),sC=b({path:p(),kind:x([`file`,`dir`,`symlink`]),sizeBytes:f(),mtime:f()}),cC=b({archiveVersion:o(1),createdAt:f(),dataDir:p(),locations:S(p()),entries:S(sC),totalBytes:f(),totalFiles:f(),sqliteSnapshots:S(tC).optional(),omittedDatabases:S(bd).optional()}),lC=b({name:p(),sizeBytes:f(),fileCount:f(),present:v()}),uC=x([`queued`,`running`,`succeeded`,`failed`,`cancelled`]),dC=x([`queued`,`building`,`uploading`,`done`]),fC=b({id:p(),state:uC,phase:dC,destinationIds:S(p()).readonly(),label:p().optional(),requestedAt:f(),startedAt:f().optional(),finishedAt:f().optional(),stagedBytes:f(),archiveSizeBytes:f().optional(),uploadedBytes:f(),completedDestinationIds:S(p()).readonly(),failedDestinationIds:S(p()).readonly(),error:p().optional(),queuePosition:f().int().min(1).optional()}),pC=b({runId:p(),queued:v(),joined:v(),cancelled:v(),entries:S(oC).readonly()}),mC=b({id:p(),label:p(),cron:p(),enabled:v(),locationIds:S(p()).readonly(),retentionCount:f().int().min(1).max(1e3),dataSources:S(p()).readonly().optional(),databases:S(bd).readonly().optional(),lastAttemptAt:f().optional(),lastSuccessAt:f().optional(),lastError:p().optional(),nextRunAt:f().optional()}),hC={name:`backup`,scope:`system`,mode:`singleton`,methods:{listDestinations:O(_(),S(rC).readonly(),{auth:`admin`}),trigger:O(b({destinations:S(p()).optional(),locations:S(p()).optional(),label:p().optional(),retentionCount:f().int().min(1).max(1e3).optional(),databases:S(bd).optional()}).optional(),pC,{kind:`mutation`,auth:`admin`}),listRuns:O(_(),S(fC).readonly(),{auth:`admin`}),cancel:O(b({runId:p()}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`}),list:O(_(),S(oC).readonly(),{auth:`admin`}),listLocations:O(_(),S(lC).readonly(),{auth:`admin`}),getEntries:O(b({destinationId:p(),backupId:p()}),cC.nullable(),{auth:`admin`}),restore:O(b({destinationId:p(),backupId:p(),locations:S(p()).optional(),backupSecretKey:p().optional()}),_(),{kind:`mutation`,auth:`admin`}),getEncryption:O(_(),aC,{auth:`admin`}),setupEncryption:O(b({}),b({keyId:p(),secretKey:p(),publicKey:p(),createdAt:f(),replacedKeyId:p().nullable()}),{kind:`mutation`,auth:`admin`}),disableEncryption:O(b({}),b({disabledKeyId:p().nullable()}),{kind:`mutation`,auth:`admin`}),checkBackupKey:O(b({backupSecretKey:p()}),b({valid:v(),keyId:p().nullable(),known:v(),active:v(),error:p().optional()}),{kind:`mutation`,auth:`admin`}),delete:O(b({destinationId:p(),backupId:p()}),_(),{kind:`mutation`,auth:`admin`}),listArchives:O(b({destinationId:p()}),S(z_e).readonly(),{auth:`admin`}),upsertDestinationPolicy:O(b({locationId:p(),enabled:v(),retentionCount:f().int().min(1).max(1e3),label:p().optional()}),_(),{kind:`mutation`,auth:`admin`}),previewSchedule:O(b({cron:p(),count:f().int().min(1).max(20).optional()}),b({ok:v(),error:p().optional(),nextRuns:S(f()).readonly()})),listSchedules:O(_(),S(mC).readonly(),{auth:`admin`}),listAvailableDatabases:O(_(),b({answered:v(),databases:S(bd).readonly()}),{auth:`admin`}),upsertSchedule:O(b({id:p().optional(),label:p(),cron:p(),enabled:v(),locationIds:S(p()).readonly(),retentionCount:f().int().min(1).max(1e3),dataSources:S(p()).readonly().optional(),databases:S(bd).readonly().optional()}),mC,{kind:`mutation`,auth:`admin`}),deleteSchedule:O(b({id:p()}),_(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`system backups — run and restored from the Backups page`}},gC=b({level:f().min(0).max(100).nullable().meta(j(`percentage`,{label:`Charge`})),charging:x([`dc`,`solar`,`none`,`unknown`]).meta({label:`Charging source`}),sleeping:v().meta({label:`Sleeping`}),lastUpdated:f().meta(j(`none`)),voltage:f().nullable().optional().meta(j(`voltage`,{label:`Voltage`})),lastContactAt:f().optional(),lastFullRefreshAt:f().optional(),binary:v().optional().meta({label:`Binary indicator`})}),_C=[w.Camera,w.Sensor,w.Button,w.Switch,w.PetFeeder,w.Container,w.Climate,w.EventEmitter],B_e={version:1,targets:[{id:`level`,cardinality:`scalar`,vocabulary:{cap:`battery`,stateField:`level`},deviceTypes:_C,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}]},vC={name:`battery`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:_C,methods:{wakeForStream:O(b({deviceId:f(),timeoutMs:f().int().min(500).max(3e4).default(8e3)}),b({awoke:v(),durationMs:f()}),{kind:`mutation`,notOperatorFacing:`a stream consumer wakes a sleeping camera to watch it; an automation that wants footage asks for the footage`})},composedMethods:{wakeForStream:{kind:`answer`,value:{awoke:!1,durationMs:0}}},events:{onStatusChanged:{data:b({deviceId:f(),status:gC}),notOperatorFacing:`the level / sleeping / charging state triggers each read one field of this change`}},status:{schema:gC,kind:`push`,empty:{level:null,charging:`unknown`,sleeping:!1,lastUpdated:0}},runtimeState:gC,durability:`restored`,history:{fields:{level:{kind:`gauge`,unit:`%`},voltage:{kind:`gauge`,unit:`V`}}},customize:B_e,volatileStateFields:[`lastUpdated`],vocabulary:{noun:N(`Battery`,`Batteria`),order:5240,state:[{kind:`numeric`,field:`level`,quantity:N(`the battery level`,`il livello della batteria`),label:N(`Battery`,`Batteria`),unit:`%`,icon:`battery`},{kind:`boolean`,field:`sleeping`,label:N(`Asleep`,`In sospensione`),whenTrue:N(`When {device} goes to sleep`,`Quando {device} va in sospensione`),whenFalse:N(`When {device} wakes up`,`Quando {device} si risveglia`),icon:`moon`},{kind:`enum`,field:`charging`,label:N(`Charging`,`Ricarica`),values:[{value:`dc`,label:N(`Charging from mains`,`In carica da rete`),phrase:N(`When {device} starts charging`,`Quando {device} inizia a caricarsi`)},{value:`solar`,label:N(`Charging from solar`,`In carica dal pannello solare`),phrase:N(`When {device} charges from its solar panel`,`Quando {device} si carica dal pannello solare`)},{value:`none`,label:N(`Not charging`,`Non in carica`),phrase:N(`When {device} stops charging`,`Quando {device} smette di caricarsi`)},{value:`unknown`,label:N(`Unknown`,`Sconosciuto`)}],icon:`battery-charging`}],extraEvents:[{category:C.DeviceAwake,label:N(`Woke up`,`Risvegliato`),phrase:N(`When {device} wakes up`,`Quando {device} si risveglia`),icon:`sun`},{category:C.DeviceSleeping,label:N(`Went to sleep`,`In sospensione`),phrase:N(`When {device} goes to sleep`,`Quando {device} va in sospensione`),icon:`moon`}]}},yC=b({on:v().meta({label:`On`}),lastChangedAt:f()}),bC={name:`binary`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Sensor],methods:{},status:{schema:yC,kind:`push`},runtimeState:yC,durability:`restored`,history:{fields:{on:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:N(`Binary sensor`,`Sensore binario`),order:5020,state:[{kind:`boolean`,field:`on`,label:N(`On`,`Acceso`),whenTrue:N(`When {device} turns active`,`Quando {device} si attiva`),whenFalse:N(`When {device} turns inactive`,`Quando {device} si disattiva`),icon:`toggle-right`}],overrides:{byRole:{[E.MotionSensor]:{state:{on:{label:N(`Motion`,`Movimento`),whenTrue:N(`When {device} detects motion`,`Quando {device} rileva movimento`),whenFalse:N(`When motion clears on {device}`,`Quando il movimento su {device} cessa`),icon:`activity`}}},[E.ContactSensor]:{state:{on:{label:N(`Open`,`Aperto`),whenTrue:N(`When {device} opens`,`Quando {device} si apre`),whenFalse:N(`When {device} closes`,`Quando {device} si chiude`),icon:`door-open`}}},[E.LeakSensor]:{state:{on:{label:N(`Leak`,`Perdita`),whenTrue:N(`When {device} detects a leak`,`Quando {device} rileva una perdita`),whenFalse:N(`When {device} is dry again`,`Quando {device} torna asciutto`),icon:`droplets`}}},[E.SmokeSensor]:{state:{on:{label:N(`Smoke`,`Fumo`),whenTrue:N(`When {device} detects smoke`,`Quando {device} rileva fumo`),whenFalse:N(`When smoke clears on {device}`,`Quando il fumo su {device} si dirada`),icon:`alarm-smoke`}}},[E.COSensor]:{state:{on:{label:N(`Carbon monoxide`,`Monossido di carbonio`),whenTrue:N(`When {device} detects carbon monoxide`,`Quando {device} rileva monossido di carbonio`),whenFalse:N(`When the carbon monoxide clears on {device}`,`Quando il monossido su {device} rientra`),icon:`cloud-alert`}}},[E.GasSensor]:{state:{on:{label:N(`Gas`,`Gas`),whenTrue:N(`When {device} detects gas`,`Quando {device} rileva gas`),whenFalse:N(`When the gas clears on {device}`,`Quando il gas su {device} rientra`),icon:`flame`}}},[E.TamperSensor]:{state:{on:{label:N(`Tampered`,`Manomesso`),whenTrue:N(`When {device} is tampered with`,`Quando {device} viene manomesso`),whenFalse:N(`When the tamper alert on {device} clears`,`Quando l’allarme di manomissione di {device} rientra`),icon:`shield-alert`}}},[E.VibrationSensor]:{state:{on:{label:N(`Vibration`,`Vibrazione`),whenTrue:N(`When {device} vibrates`,`Quando {device} vibra`),whenFalse:N(`When {device} is still again`,`Quando {device} torna fermo`),icon:`vibrate`}}},[E.ConnectivitySensor]:{state:{on:{label:N(`Connected`,`Connesso`),whenTrue:N(`When {device} connects`,`Quando {device} si connette`),whenFalse:N(`When {device} disconnects`,`Quando {device} si disconnette`),icon:`wifi`}}},[E.SoundSensor]:{state:{on:{label:N(`Sound`,`Suono`),whenTrue:N(`When {device} hears a sound`,`Quando {device} sente un suono`),whenFalse:N(`When {device} is quiet again`,`Quando {device} torna silenzioso`),icon:`ear`}}},[E.BatterySensor]:{state:{on:{label:N(`Battery low`,`Batteria scarica`),whenTrue:N(`When the battery of {device} runs low`,`Quando la batteria di {device} si scarica`),whenFalse:N(`When the battery of {device} is fine again`,`Quando la batteria di {device} torna a posto`),icon:`battery-low`}}},[E.BinaryHelper]:{state:{on:{label:N(`On`,`Acceso`),whenTrue:N(`When {device} turns on`,`Quando {device} si accende`),whenFalse:N(`When {device} turns off`,`Quando {device} si spegne`),icon:`toggle-right`}}}}}}},xC=x([`unknown-source`,`not-admin`,`no-builder`,`no-ingress-url`,`unreachable`,`unknown-board`,`no-encryption-key`,`unreadable-config`]),V_e=b({sourceId:p(),name:p()}),H_e=b({configuration:p(),name:p(),address:p().nullable()}),SC=b({ok:o(!1),reason:xC,detail:p().optional()}),U_e=i(`ok`,[b({ok:o(!0),boards:S(H_e).readonly()}),SC]),W_e=i(`ok`,[b({ok:o(!0),key:p()}),SC]),CC={name:`board-key-source`,scope:`system`,mode:`collection`,methods:{listSources:O(_(),S(V_e).readonly(),{auth:`admin`}),listBoards:O(b({sourceId:p().min(1)}),U_e,{auth:`admin`}),getBoardKey:O(b({sourceId:p().min(1),configuration:p().min(1)}),W_e,{auth:`admin`})},vocabulary:{notOperatorFacing:A.INTERNAL}},wC=b({level:f().min(0).max(100).meta(j(`percentage`)),lastChangedAt:f()}),TC={name:`brightness`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Light],methods:{setBrightness:O(b({deviceId:f().int().nonnegative(),level:f().min(0).max(100)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`brightness.full`,label:N(`Full brightness`,`Luminosità massima`),phrase:N(`Set {device} to full brightness`,`Porta {device} alla massima luminosità`),icon:`sun`,effect:{field:`level`,value:100},args:{level:100}},{id:`brightness.half`,label:N(`Half brightness`,`Luminosità a metà`),phrase:N(`Dim {device} to half`,`Abbassa {device} a metà luminosità`),icon:`sun-dim`,effect:{field:`level`,value:50},args:{level:50}},{id:`brightness.off`,label:N(`Brightness off`,`Luminosità a zero`),phrase:N(`Dim {device} to zero`,`Abbassa {device} a zero`),icon:`lightbulb-off`,effect:{field:`level`,value:0},args:{level:0}},{id:`brightness.set`,label:N(`Set brightness`,`Imposta la luminosità`),phrase:N(`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:N(`Percentage`,`Percentuale`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]})},events:{onBrightnessChanged:{data:b({deviceId:f(),level:f().min(0).max(100),lastChangedAt:f()}),notOperatorFacing:"the `level` state trigger reads the same change"}},status:{schema:wC,kind:`command-driven`},runtimeState:wC,durability:`session`,history:{fields:{level:{kind:`gauge`,unit:`%`,minIntervalMs:0}}},vocabulary:{noun:N(`Brightness`,`Luminosità`),order:1010,state:[{kind:`numeric`,field:`level`,quantity:N(`the brightness`,`la luminosità`),label:N(`Brightness`,`Luminosità`),unit:`%`,icon:`sun`}]}},G_e=x([`connected`,`disconnected`,`connecting`,`auth-failed`,`unreachable`,`error`]),EC=b({brokerCount:f().int().nonnegative(),connectedCount:f().int().nonnegative()}),K_e=b({id:p()}),q_e=u(p(),l()),DC=b({brokerId:p(),target:u(p(),l()),payload:l().optional()}),OC=b({brokerId:p(),filter:u(p(),l())}),kC=b({subscriptionId:p()}),AC=b({brokerId:p(),subscriptionId:p()}),jC=b({brokerId:p(),key:p()}),MC={name:`broker`,scope:`system`,mode:`collection`,providerKind:`broker`,status:{schema:EC,kind:`poll`},methods:{getBrokerConfig:O(K_e,q_e.nullable(),{auth:`admin`}),publish:O(DC,l(),{kind:`mutation`,auth:`admin`}),subscribe:O(OC,kC,{kind:`mutation`,auth:`admin`}),unsubscribe:O(AC,_(),{kind:`mutation`,auth:`admin`}),getState:O(jC,l().nullable(),{auth:`admin`}),getStatus:O(_(),EC)},vocabulary:{notOperatorFacing:`message-broker connections — configured, not actuated`}},NC={name:`button`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Button],methods:{press:O(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`button.press`,label:N(`Press`,`Premi`),phrase:N(`Press {device}`,`Premi {device}`),icon:`circle-dot`}]})},vocabulary:{noun:N(`Button`,`Pulsante`),order:1130}},PC=x([`ha`,`addon`]),FC=b({id:p().min(1),name:p().min(1),source:PC,enabled:v(),instanceId:p().min(1).optional()}),IC=b({id:p().min(1),calendarId:p().min(1),title:p(),startMs:f().int(),endMs:f().int(),allDay:v().optional(),description:p().optional(),location:p().optional()}),LC=b({calendarIds:S(p().min(1)).max(64).optional(),startMs:f().int(),endMs:f().int()}),RC={name:`calendar-source`,scope:`system`,mode:`collection`,internal:!0,providerKind:`calendar`,methods:{listCalendars:O(_(),S(FC).readonly(),{auth:`admin`}),listEvents:O(LC,S(IC).readonly(),{auth:`admin`})},vocabulary:{notOperatorFacing:A.INTERNAL}};function zC(e){let t=new Date(e);return new Date(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()).getTime()}function BC(e){if(e.allDay!==!0)return{startMs:e.startMs,endMs:e.endMs};let t=zC(e.startMs),n=zC(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 J_e(e,t){let n=new Date(t),r=new Date(n.getFullYear(),n.getMonth(),n.getDate()+1).getTime(),i=BC(e);return i.startMs<r&&i.endMs>t}var VC=p().regex(/^#[0-9A-Fa-f]{6}$/,`expected #RRGGBB`),HC=FC.extend({id:p().min(1),providerAddonId:p().min(1).optional(),defaultColor:VC,color:VC,visible:v()}),UC=b({visible:v().optional(),color:VC.optional()}),WC=b({calendars:u(p(),UC)}),GC=b({calendarId:p().min(1),visible:v().optional(),color:VC.nullable().optional()}),KC={name:`calendars`,scope:`system`,mode:`singleton`,methods:{listCalendars:O(_(),S(HC).readonly(),{auth:`admin`}),listEvents:O(LC,S(IC).readonly(),{auth:`admin`}),getPreferences:O(b({}),WC,{auth:`admin`,caller:`required`}),setCalendarPreference:O(GC,WC,{auth:`admin`,kind:`mutation`,caller:`required`})},vocabulary:{notOperatorFacing:`calendars feed schedules and conditions, not device actions`}},qC=b({host:p(),port:f().int().positive().optional(),onvifPort:f().int().positive().optional(),rtspPort:f().int().positive().optional(),https:v().optional(),username:p().optional(),password:p().optional(),onvifProfile:p().optional()}),JC=b({host:p(),port:f().int().positive().nullable(),onvifPort:f().int().positive().nullable(),rtspPort:f().int().positive().nullable(),https:v().nullable(),hasUsername:v(),hasPassword:v(),onvifProfile:p().nullable()}),YC={name:`camera-credentials`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Camera],methods:{getCredentials:O(b({deviceId:f()}),qC.nullable(),{kind:`query`,auth:`admin`})},status:{schema:JC,kind:`command-driven`},vocabulary:{noun:N(`Camera credentials`,`Credenziali della telecamera`),order:3030}},XC=b({x:f().min(0).max(1),y:f().min(0).max(1),width:f().gt(0).max(1),height:f().gt(0).max(1)}),ZC=b({deviceId:f().int().positive(),source:XC,cell:XC}),Y_e=b({profile:x([`high`,`mid`,`low`]),offered:v(),missingSources:S(f().int().positive()),canvas:p(),published:v()}),QC=b({instanceId:p(),deviceId:f().int().nonnegative(),name:p(),fps:f().int(),cells:S(ZC),profiles:S(Y_e)}),$C=b({deviceId:f().int().nonnegative(),name:p().min(1).max(160).optional(),fps:f().int().min(1).max(60).optional(),publishedProfiles:S(x([`high`,`mid`,`low`])).max(3).optional(),cells:S(ZC).max(16)}),ew={name:`camera-grid-layout`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Camera],exposesDeviceSettings:!0,methods:{getLayout:O(b({deviceId:f().int().nonnegative()}),QC.nullable(),{auth:`admin`}),saveLayout:O($C,QC,{kind:`mutation`,auth:`admin`})},vocabulary:{noun:N(`Grid layout`,`Layout a griglia`),order:3040}},tw={name:`camera-pipeline-config`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[w.Camera],exposesDeviceSettings:!0,methods:{},vocabulary:{noun:N(`Detection settings`,`Impostazioni di rilevamento`),order:3050}},nw=x([`webrtc`,`hls`,`mjpeg`,`rtsp`]),rw=x([`mp4`,`gif`]),iw=b({kind:rw,handle:p(),nodeId:p(),mime:p(),bytes:f().int(),width:f().int(),height:f().int()}),aw=b({fromTs:f(),toTs:f(),packets:f().int()}),ow=b({media:S(iw).readonly(),coverage:aw,profile:M,video:x([`copy`,`encode`])}),sw=b({brokerId:p(),url:p(),mutedUrl:p(),enabled:v(),codec:p().optional(),resolution:b({width:f().int().positive(),height:f().int().positive()}).optional()}),cw=b({sessionId:p(),remoteAddr:p(),userAgent:p().nullish(),playing:v(),muted:v(),connectedAt:f(),lastRtpAt:f(),bytesSent:f()}),lw=b({tag:p(),subscribedAt:f(),chunksDelivered:f()}),uw=x([`alexa`,`homekit`,`webrtc-browser`,`webrtc-mobile`,`webrtc-whep`,`rtsp-listen`,`derived-broker`,`recording`,`pipeline`,`snapshot`,`warmup`,`unknown`]),dw=b({kind:uw,label:p().optional(),media:x([`audio`,`video`,`both`]).optional(),targetCodec:p().optional(),transport:x([`passthrough`,`repacketize`,`transcode`]).optional(),remoteAddr:p().optional(),userAgent:p().optional(),userId:p().optional(),sessionId:p().optional(),extra:u(p(),p()).optional()}).readonly(),fw=b({id:p(),channel:x([`annexb`,`rtp`]),attribution:dw,subscribedAt:f(),packetsDelivered:f()}),pw=b({rtsp:S(cw).readonly(),audio:S(lw).readonly(),encoded:S(fw).readonly(),pipeClients:f(),encodedSubscribers:f()}),mw=b({deviceId:f().int().nonnegative(),viewers:f().int().positive()}),X_e=x([`reconnecting`,`sleeping`,`offline`,`disabled`,`waking`]),Z_e=x([`h264`,`h265`,`copy`]),Q_e=x([`aac`,`opus`,`pcmu`,`copy`,`none`]),hw=b({deviceId:f().int().nonnegative(),video:Z_e,audio:Q_e.optional(),profile:M.optional(),targetResolution:b({width:f().int().positive(),height:f().int().positive()}).optional(),outputArgs:S(p()).optional(),audioEgress:v().optional(),hostname:p().optional(),tag:p().optional()}),gw=b({url:p(),sentryUrl:p().nullable().optional(),videoCodec:x([`H264`,`H265`]),audioCodec:p(),resolution:b({width:f().int().positive(),height:f().int().positive()}),transcoded:v(),encoder:p(),pipelineKey:p()}),_w=Fu.omit({inputArgs:!0,outputArgs:!0}),vw=x([`tight`,`relaxed`]),yw=b({deviceId:f().int().nonnegative(),source:i(`kind`,[b({kind:o(`profile`),profile:M}),b({kind:o(`cam-stream`),camStreamId:p().min(1)})]),encode:_w,rateControl:vw.optional(),bitstreamFilter:x([`dump_extra`,`h264_mp4toannexb`,`hevc_mp4toannexb`]).optional(),publishLocally:v().optional(),pixelFormat:x([`yuv420p`,`nv12`]).optional(),decodeHwAccel:x([`auto`,`none`,`videotoolbox`,`vaapi`,`qsv`,`cuda`]).optional(),hostname:p().optional(),tag:p().optional()}),bw=b({url:p(),pipelineKey:p(),videoCodec:x([`H264`,`H265`]),resolution:b({width:f().int().positive(),height:f().int().positive()}),transcoded:v(),encoder:p(),decodeHwAccel:p().nullable(),camStreamId:p().nullable()}),xw={name:`stream-broker`,scope:`system`,mode:`singleton`,exposesDeviceSettings:!0,methods:{reportStreamSignal:O(b({deviceId:f().int().nonnegative(),code:p().min(1),at:f().optional()}),b({accepted:v(),reason:x([`woke`,`hold-extended`,`not-enabled`,`no-consumer`,`unknown-code`])}),{kind:`mutation`}),publishCameraStream:O(b({deviceId:f().int().nonnegative(),camStreamId:p().min(1),kind:Yi,url:p().optional(),codec:p().optional(),resolution:Xi.optional(),fps:f().positive().optional(),label:p().optional(),deviceFeatures:S(p()).optional(),autoEligible:v().optional(),profileHint:M.optional(),metadata:u(p(),l()).optional(),sourceCamStreamId:p().min(1).optional(),encodeProfile:Fu.optional()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),retractCameraStream:O(b({deviceId:f().int().nonnegative(),camStreamId:p().min(1)}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),assignProfile:O(b({deviceId:f().int().nonnegative(),profile:M,camStreamId:p().min(1)}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),unassignProfile:O(b({deviceId:f().int().nonnegative(),profile:M}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),forgetDeviceHardware:O(b({deviceId:f().int().nonnegative()}),b({derivedStreamsDeleted:S(p()).readonly(),assignmentsPurged:v(),probeSnapshotsDropped:f().int().nonnegative(),rtspTokenRowsDeleted:f().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),renderPreBufferClip:O(b({deviceId:f(),profile:M.optional(),aroundMs:f(),preRollSec:f().min(0).max(20).default(3),postRollSec:f().min(0).max(20).default(5),format:x([`gif`,`mp4`]).default(`gif`),maxWidth:f().int().min(120).max(1920).default(480),fps:f().int().min(1).max(15).default(5),speed:f().min(1).max(8).default(2)}),b({base64:p(),mime:p(),bytes:f().int(),profile:M,durationMs:f()}),{kind:`mutation`,auth:`admin`}),produceEventMedia:O(b({deviceId:f(),profile:M.optional(),aroundMs:f(),preSeconds:f().min(0).max(20).default(4),postSeconds:f().min(0).max(20).default(6),kinds:S(rw).min(1).default([`mp4`]),gifMaxWidth:f().int().min(120).max(1280).default(640),gifFps:f().int().min(1).max(15).default(12),gifSpeed:f().min(1).max(8).default(4),speed:f().min(1).max(8).default(4)}),ow,{kind:`mutation`,auth:`admin`}),fetchEventMedia:O(b({handle:p()}),b({base64:p(),mime:p(),bytes:f().int()}).nullable(),{kind:`mutation`,auth:`admin`}),listAllCameraStreams:O(_(),S(Zi).readonly()),listAllProfileSlots:O(_(),S($i).readonly()),getBrokerStats:O(b({brokerId:p()}),sa),probeStream:O(b({brokerId:p()}),b({probed:v(),summary:p()}),{kind:`mutation`,auth:`admin`}),listClients:O(b({brokerId:p()}),pw),getLiveViewerCounts:O(_(),S(mw).readonly(),{role:`viewer`}),killClient:O(b({brokerId:p(),channel:x([`rtsp`,`audio`]),handle:p()}),b({killed:v()}),{kind:`mutation`,auth:`admin`}),restartProfile:O(b({deviceId:f().int().nonnegative(),profile:M}),b({success:v()}),{kind:`mutation`,auth:`admin`}),getStreamUrl:O(b({streamId:p(),format:nw}),b({url:p()})),getStreamWithCodec:O(hw,gw,{kind:`mutation`,auth:`admin`}),releaseStreamWithCodec:O(b({pipelineKey:p()}),b({released:v(),refcount:f().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),acquireEgressTranscode:O(yw,bw,{kind:`mutation`,auth:`admin`}),releaseEgressTranscode:O(b({pipelineKey:p()}),b({released:v(),refcount:f().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),subscribeAudioChunks:O(ia,aa,{kind:`mutation`}),pullAudioChunks:O(b({subscriptionId:p(),maxCount:f().int().positive().default(8)}),S(ra).readonly()),unsubscribeAudioChunks:O(b({subscriptionId:p()}),b({released:v()}),{kind:`mutation`}),setPreBufferDuration:O(b({brokerId:p(),seconds:f().min(0).max(30)}),_(),{kind:`mutation`,auth:`admin`}),getPreBufferInfo:O(b({brokerId:p()}),b({configuredSec:f(),bufferedMs:f(),packetCount:f()})),getRtspPort:O(_(),f()),getAllRtspEntries:O(b({hostname:p().optional()}),S(sw).readonly()),getRtspEntry:O(b({brokerId:p(),hostname:p().optional()}),sw.nullable()),regenerateRtspToken:O(b({brokerId:p()}),p().nullable(),{kind:`mutation`,auth:`admin`}),setRtspEnabled:O(b({brokerId:p(),enabled:v()}),_(),{kind:`mutation`,auth:`admin`}),isRtspEnabled:O(b({brokerId:p()}),v()),getDeviceAudioMute:O(b({deviceId:f().int()}),b({muted:v(),appliedBrokers:f().int().nonnegative()})),setDeviceAudioMute:O(b({deviceId:f().int(),muted:v()}),b({muted:v(),appliedBrokers:f().int().nonnegative()}),{kind:`mutation`,auth:`admin`})},events:{onCamStreamDemand:Rr(b({deviceId:f().int().nonnegative(),camStreamId:p(),profile:M})),onCamStreamIdle:Rr(b({deviceId:f().int().nonnegative(),camStreamId:p()})),onRequestStreamSourceRefresh:Rr(b({deviceId:f().int().nonnegative(),camStreamId:p(),brokerId:p()}))},vocabulary:{notOperatorFacing:A.PIPELINE}},Sw=x([`h264`,`h265`,`hevc`,`av1`,`mjpeg`,`vp8`,`vp9`]),Cw=b({acceptCodecs:S(Sw).readonly().optional(),minHeight:f().int().positive().optional(),maxHeight:f().int().positive().optional(),minWidth:f().int().positive().optional(),excludeDerived:v().optional(),requireSiblingCodec:S(Sw).readonly().optional(),allowTranscode:v().optional(),requireProfileBound:v().optional()}).readonly(),ww=b({preferredProviders:S(p()).readonly().optional(),resolutionPreference:x([`highest`,`lowest`]).optional(),targetHeight:f().int().positive().optional()}).readonly(),Tw=b({camStreamId:p(),codec:p().optional(),resolution:Xi.optional(),transcodes:v(),reason:p(),profile:M.optional(),brokerId:p().optional(),url:p().optional(),fps:f().positive().optional(),fpsSource:x([`published`,`measured`]).optional()}),Ew={name:`camera-streams`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[w.Camera],methods:{getCameraStreams:O(b({deviceId:f().int().nonnegative()}),S(Zi).readonly()),getBrokerStreams:O(b({deviceId:f().int().nonnegative()}),S($i).readonly()),getRtspEntries:O(b({deviceId:f().int().nonnegative(),hostname:p().optional()}),S(sw).readonly()),getProfileRtspEntries:O(b({deviceId:f().int().nonnegative(),hostname:p().optional()}),S(ca).readonly()),pickStream:O(b({deviceId:f().int().nonnegative(),requirements:Cw,preferences:ww.optional()}),Tw.nullable())},events:{onCamStreamsChanged:Rr(b({deviceId:f().int().nonnegative(),camStreams:S(Zi).readonly()}),{notOperatorFacing:`the stream catalog was rebuilt — plumbing, not a happening`}),onProfileSlotsChanged:Rr(b({deviceId:f().int().nonnegative(),profileSlots:S($i).readonly()}),{notOperatorFacing:`stream profiles were reassigned — plumbing, not a happening`})},runtimeState:b({online:v(),slotStatuses:b({high:Qi.optional(),mid:Qi.optional(),low:Qi.optional()}),slotErrors:b({high:p().optional(),mid:p().optional(),low:p().optional()}),lastChangedAt:f()}),durability:`session`,history:`none`,vocabulary:{noun:N(`Camera streams`,`Flussi della telecamera`),order:3060}},Dw=b({detected:v(),lastChangedAt:f()}),Ow={name:`carbon-monoxide`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Sensor],methods:{},status:{schema:Dw,kind:`push`},runtimeState:Dw,durability:`restored`,history:{fields:{detected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:N(`Carbon monoxide`,`Monossido di carbonio`),order:5030,state:[{kind:`boolean`,field:`detected`,label:N(`Detected`,`Rilevato`),whenTrue:N(`When {device} detects carbon monoxide`,`Quando {device} rileva monossido di carbonio`),whenFalse:N(`When the carbon monoxide clears on {device}`,`Quando il monossido su {device} rientra`),icon:`cloud-alert`}]}},kw=x([`off`,`heat`,`cool`,`auto`,`heat_cool`,`fan_only`,`dry`]),Aw=x([`heating`,`cooling`,`drying`,`fan`,`idle`,`off`]),jw=b({mode:kw,action:Aw.nullable().optional(),availableModes:S(kw),fanMode:p(),availableFanModes:S(p()),preset:p(),availablePresets:S(p()),target:f().nullable().meta(j(`temperature`)),targetHigh:f().nullable().meta(j(`temperature`)),targetLow:f().nullable().meta(j(`temperature`)),targetHumidity:f().min(0).max(100).nullable().meta(j(`humidity`)),currentTemp:f().nullable().meta(j(`temperature`)),currentHumidity:f().min(0).max(100).nullable().meta(j(`humidity`)),swingVertical:v().nullable(),swingHorizontal:v().nullable(),minTemp:f().nullable().optional().meta(j(`temperature`)),maxTemp:f().nullable().optional().meta(j(`temperature`)),tempStep:f().positive().nullable().optional().meta(j(`temperature`)),lastActiveMode:kw.exclude([`off`]).optional(),lastFetchedAt:f()}),$_e=[w.Climate];function Mw(e,t){return{id:e,cardinality:`scalar`,vocabulary:{cap:`climate-control`,stateField:t},deviceTypes:$_e,apply:`replace`,path:t,sources:[{kind:`numeric`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}}var Nw=[Mw(`room-temperature`,`currentTemp`),Mw(`room-humidity`,`currentHumidity`)],eve={version:1,overridable:Nw.map(e=>({path:e.path,by:e.id})),targets:Nw},Pw={name:`climate-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Climate],power:{kind:`mode`,field:`mode`,offValue:`off`,set:`setMode`,lastField:`lastActiveMode`},methods:{setMode:O(b({deviceId:f().int().nonnegative(),mode:kw}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.off`,label:N(`Climate off`,`Clima spento`),phrase:N(`Turn off {device}`,`Spegni {device}`),icon:`power-off`,effect:{field:`mode`,value:`off`},args:{mode:`off`}},{id:`climate.heat`,label:N(`Heat`,`Riscalda`),phrase:N(`Set {device} to heat`,`Metti {device} in riscaldamento`),icon:`flame`,effect:{field:`mode`,value:`heat`},args:{mode:`heat`}},{id:`climate.cool`,label:N(`Cool`,`Raffresca`),phrase:N(`Set {device} to cool`,`Metti {device} in raffrescamento`),icon:`snowflake`,effect:{field:`mode`,value:`cool`},args:{mode:`cool`}},{id:`climate.auto`,label:N(`Climate auto`,`Clima automatico`),phrase:N(`Set {device} to automatic`,`Metti {device} in automatico`),icon:`thermometer`,effect:{field:`mode`,value:`auto`},args:{mode:`auto`}},{id:`climate.mode`,label:N(`Set mode`,`Imposta la modalità`),phrase:N(`Set {device} to {mode}`,`Imposta {device} su {mode}`),icon:`thermometer`,effect:{field:`mode`,fromArg:`mode`},openArgs:[{key:`mode`,label:N(`Mode`,`Modalità`),offer:{kind:`enum`,values:[{value:`off`,label:N(`Off`,`Spento`)},{value:`heat`,label:N(`Heat`,`Riscaldamento`)},{value:`cool`,label:N(`Cool`,`Raffrescamento`)},{value:`auto`,label:N(`Automatic`,`Automatico`)},{value:`heat_cool`,label:N(`Heat and cool`,`Caldo e freddo`)},{value:`fan_only`,label:N(`Fan only`,`Solo ventilazione`)},{value:`dry`,label:N(`Dry`,`Deumidificazione`)}]}}]}]}),setTarget:O(b({deviceId:f().int().nonnegative(),target:f()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.target`,label:N(`Set temperature`,`Imposta la temperatura`),phrase:N(`Set {device} to {target}`,`Imposta {device} a {target}`),icon:`thermometer`,effect:{field:`target`,fromArg:`target`},openArgs:[{key:`target`,label:N(`Temperature`,`Temperatura`),offer:{kind:`number`,step:.5,unit:`°C`}}]}]}),setTargetRange:k(b({deviceId:f().int().nonnegative(),targetLow:f(),targetHigh:f()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.targetRange`,label:N(`Set temperature range`,`Imposta l’intervallo di temperatura`),phrase:N(`Keep {device} between {targetLow} and {targetHigh}`,`Mantieni {device} tra {targetLow} e {targetHigh}`),icon:`thermometer`,openArgs:[{key:`targetLow`,label:N(`Lowest`,`Minima`),offer:{kind:`number`,step:.5,unit:`°C`}},{key:`targetHigh`,label:N(`Highest`,`Massima`),offer:{kind:`number`,step:.5,unit:`°C`}}]}]}),setTargetHumidity:k(b({deviceId:f().int().nonnegative(),targetHumidity:f().min(0).max(100)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.targetHumidity`,label:N(`Set humidity`,`Imposta l’umidità`),phrase:N(`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:N(`Humidity`,`Umidità`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setFanMode:k(b({deviceId:f().int().nonnegative(),fanMode:p().min(1)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.fanMode`,label:N(`Set fan mode`,`Imposta la ventilazione`),phrase:N(`Set the fan of {device} to {fanMode}`,`Imposta la ventilazione di {device} su {fanMode}`),icon:`fan`,openArgs:[{key:`fanMode`,label:N(`Fan mode`,`Ventilazione`),offer:{kind:`dynamic`,from:`status`,field:`availableFanModes`}}]}]}),setPreset:k(b({deviceId:f().int().nonnegative(),preset:p().min(1)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.preset`,label:N(`Set preset`,`Imposta il preset`),phrase:N(`Set {device} to preset {preset}`,`Imposta {device} sul preset {preset}`),icon:`list`,openArgs:[{key:`preset`,label:N(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`status`,field:`availablePresets`}}]}]}),setSwingVertical:k(b({deviceId:f().int().nonnegative(),on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.swingVerticalOn`,label:N(`Vertical swing on`,`Oscillazione verticale attiva`),phrase:N(`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:N(`Vertical swing off`,`Oscillazione verticale spenta`),phrase:N(`Stop the vertical swing of {device}`,`Ferma l’oscillazione verticale di {device}`),icon:`move-vertical`,effect:{field:`swingVertical`,value:!1},args:{on:!1}}]}),setSwingHorizontal:k(b({deviceId:f().int().nonnegative(),on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.swingHorizontalOn`,label:N(`Horizontal swing on`,`Oscillazione orizzontale attiva`),phrase:N(`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:N(`Horizontal swing off`,`Oscillazione orizzontale spenta`),phrase:N(`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:jw,kind:`push`},runtimeState:jw,customize:eve,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:N(`Climate`,`Clima`),order:1070,state:[{kind:`enum`,field:`mode`,label:N(`Mode`,`Modalità`),values:[{value:`off`,label:N(`Off`,`Spento`),phrase:N(`When {device} turns off`,`Quando {device} si spegne`)},{value:`heat`,label:N(`Heat`,`Riscaldamento`),phrase:N(`When {device} starts heating`,`Quando {device} passa al riscaldamento`)},{value:`cool`,label:N(`Cool`,`Raffrescamento`),phrase:N(`When {device} starts cooling`,`Quando {device} passa al raffrescamento`)},{value:`auto`,label:N(`Automatic`,`Automatico`)},{value:`heat_cool`,label:N(`Heat and cool`,`Caldo e freddo`)},{value:`fan_only`,label:N(`Fan only`,`Solo ventilazione`)},{value:`dry`,label:N(`Dry`,`Deumidificazione`)}],icon:`thermometer`},{kind:`numeric`,field:`currentTemp`,quantity:N(`the temperature`,`la temperatura`),label:N(`Temperature`,`Temperatura`),unit:`°C`,icon:`thermometer`},{kind:`numeric`,field:`currentHumidity`,quantity:N(`the humidity`,`l’umidità`),label:N(`Humidity`,`Umidità`),unit:`%`,icon:`droplets`},{kind:`numeric`,field:`target`,quantity:N(`the set temperature`,`la temperatura impostata`),label:N(`Set temperature`,`Temperatura impostata`),unit:`°C`,icon:`thermometer`}]}},Fw=x([`backup`,`hub-server`,`agent-server`,`addons`]),Iw=x([`pending`,`running`,`ok`,`failed`,`skipped`]),Lw=x([`backup-unavailable`,`backup-failed`,`server-refused`,`server-not-on-target`,`node-capless`,`status-unreadable`,`addon-update-failed`,`addons-not-converged`,`interrupted`,`timeout-stall`,`timeout-ceiling`]),Rw=b({kind:Fw,nodeId:p().optional(),status:Iw,detail:p(),reason:Lw.optional(),fromVersion:p().nullable().optional(),packages:S(p()).readonly().optional(),startedAt:f().optional(),finishedAt:f().optional()}),zw=x([`running`,`succeeded`,`failed`]),Bw=b({id:p(),state:zw,targetVersion:p(),requestedBy:p(),startedAt:f(),finishedAt:f().optional(),steps:S(Rw).readonly(),stoppedAt:p().optional(),reason:Lw.optional(),skippedOffline:S(p()).readonly()}),Vw=b({version:p().optional(),addons:v().optional(),backup:v().optional()}),Hw=x([`no-target`,`node-busy`,`job-running`,`nothing-to-do`,`status-unreadable`]),Uw=b({targetVersion:p().nullable(),steps:S(Rw).readonly(),skippedOffline:S(p()).readonly(),blocker:Hw.nullable(),blockerDetail:p().nullable()}),Ww=b({accepted:v(),jobId:p().nullable(),blocker:Hw.nullable(),message:p()}),Gw={name:`cluster-update`,scope:`system`,mode:`singleton`,methods:{previewClusterUpdate:O(Vw,Uw,{auth:`admin`}),startClusterUpdate:O(Vw,Ww,{kind:`mutation`,auth:`admin`}),getClusterUpdateJob:O(b({jobId:p().optional()}),Bw.nullable(),{auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:A.CLUSTER}},Kw=b({r:f().int().min(0).max(255).meta(j(`none`)),g:f().int().min(0).max(255).meta(j(`none`)),b:f().int().min(0).max(255).meta(j(`none`))}),qw=b({h:f().min(0).max(360).meta(j(`none`)),s:f().min(0).max(100).meta(j(`none`)),v:f().min(0).max(100).meta(j(`none`))}),Jw=i(`mode`,[b({mode:o(`rgb`),rgb:Kw}),b({mode:o(`hsv`),hsv:qw}),b({mode:o(`mired`),colorTemperature:f().int().min(50).max(1e3)})]),Yw=b({mode:x([`rgb`,`hsv`,`mired`]),rgb:Kw.optional(),hsv:qw.optional(),colorTemperature:f().int().optional().meta(j(`colour-temperature`)),lastChangedAt:f()});function tve(e){let t=Jw.safeParse(e);return t.success?t.data:null}var Xw={name:`color`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Light],methods:{setColor:O(b({deviceId:f().int().nonnegative(),color:Jw}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`color.warmWhite`,label:N(`Warm white`,`Bianco caldo`),phrase:N(`Set {device} to warm white`,`Imposta {device} su bianco caldo`),icon:`sun`,args:{color:{mode:`mired`,colorTemperature:370}}},{id:`color.coolWhite`,label:N(`Cool white`,`Bianco freddo`),phrase:N(`Set {device} to cool white`,`Imposta {device} su bianco freddo`),icon:`snowflake`,args:{color:{mode:`mired`,colorTemperature:200}}},{id:`color.red`,label:N(`Red`,`Rosso`),phrase:N(`Turn {device} red`,`Colora {device} di rosso`),icon:`palette`,args:{color:{mode:`rgb`,rgb:{r:255,g:0,b:0}}}},{id:`color.green`,label:N(`Green`,`Verde`),phrase:N(`Turn {device} green`,`Colora {device} di verde`),icon:`palette`,args:{color:{mode:`rgb`,rgb:{r:0,g:255,b:0}}}},{id:`color.blue`,label:N(`Blue`,`Blu`),phrase:N(`Turn {device} blue`,`Colora {device} di blu`),icon:`palette`,args:{color:{mode:`rgb`,rgb:{r:0,g:0,b:255}}}}]})},events:{onColorChanged:{data:b({deviceId:f(),mode:x([`rgb`,`hsv`,`mired`]),rgb:Kw.optional(),hsv:qw.optional(),colorTemperature:f().int().optional(),lastChangedAt:f()}),notOperatorFacing:"a colour change is read through the `mode` state trigger"}},status:{schema:Yw,kind:`command-driven`},runtimeState:Yw,durability:`session`,history:`none`,vocabulary:{noun:N(`Colour`,`Colore`),order:1020,state:[{kind:`enum`,field:`mode`,label:N(`Colour mode`,`Modalità colore`),values:[{value:`rgb`,label:N(`RGB colour`,`Colore RGB`)},{value:`hsv`,label:N(`HSV colour`,`Colore HSV`)},{value:`mired`,label:N(`White temperature`,`Temperatura del bianco`)}],icon:`palette`}]}};function Zw(e,t){let n=e;for(let e of t.split(`.`)){let t=wg(n);if(!(t instanceof se))return null;let r=t.shape[e];if(!(r instanceof re))return null;n=r}return n}function Qw(e,t){let n=Tg(e).find(e=>e.path===t);if(n===void 0)return null;let r=Zw(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 $w(e){return new Map(Tg(e).filter(e=>!e.path.includes(`.`)).flatMap(t=>{let n=Qw(e,t.path);return n===null?[]:[[t.path,n]]}))}function eT(e){let t=wg(e);return t instanceof se?Object.entries(t.shape).flatMap(([e,t])=>t instanceof re&&!t.safeParse(void 0).success?[e]:[]):[]}function tT(e,t){let n=t.split(`.`);return n.slice(0,-1).flatMap((t,r)=>{let i=n.slice(0,r+1).join(`.`),a=Zw(e,i);return a!==null&&a.safeParse(void 0).success?[i]:[]})}var nT={"doorbell.onPressed":C.DoorbellOnPressed},nve=nT,rT=b({featureIndex:f().int().nonnegative(),cap:p(),eventName:p(),category:x(C),stateField:p(),fieldKey:p()});function iT(e,t,n){return{code:e,path:t,message:n}}function rve(e){return e.issues.map(e=>`${e.path.length===0?`payload`:e.path.join(`.`)}: ${e.message}`).join(`; `)}function aT(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?Qw(e.runtimeState,s.field):null;if(l===null){r.push(iT(`unknown-field`,c,`\`${e.name}.${a}\` derives from missing state field \`${s.field}\``));continue}if(l.kind!==`number`){r.push(iT(`kind-mismatch`,c,`\`${e.name}.${a}\` needs a numeric state field; \`${s.field}\` is ${l.kind}`));continue}let u=`${e.name}.${a}`,d=nve[u];if(d===void 0){r.push(iT(`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(iT(`not-composable`,`features[${t.featureIndex}].cap`,`\`${u}\` cannot be derived from { deviceId, timestamp }: ${rve(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(iT(`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 oT=x(`reserved-variant.unknown-capability.not-composable.wrong-device-type.has-commands.unknown-field.nested-field.missing-field.kind-mismatch.source-kind-mismatch.may-be-null.source-missing.source-unreadable.source-capability-missing.source-field-unknown.expression-invalid.cycle.duplicate-target.not-item-array.item-field-reserved.target-missing.target-unreadable.not-replaceable.native-capability-replace.mixed-quantity.helper-mismatch.member-constraint.retention.command-method-unknown.command-source-unknown.command-input-unknown.command-input-missing.power-source-is-actuator`.split(`.`)),sT=b({code:oT,path:p(),message:p()}),cT=x([`string`,`number`,`boolean`,`enum`]),lT=x([`null`,`offline`,`unknown`,`release`,`omit`]),uT=x([`derived`,`clock`,`constant`,`accumulator`]),dT=b({arrayPath:p(),key:p(),label:p(),resettable:v().optional()}),fT=b({cap:p(),path:p(),item:dT.optional(),featureIndex:f().int().nonnegative(),kind:cT,nullable:v(),required:v(),unavailable:lT,role:uT,source:pc,reads:S(ac)});function pT(e){let t=e.item===void 0?e.path:zc(e.item.arrayPath,e.item.key,e.path);return`${e.cap}.${t}`}var mT=x([`new`,`add`,`replace`]),hT=b({featureIndex:f().int().nonnegative(),cap:p(),mode:mT}),gT=b({ok:v(),problems:S(sT),fields:S(fT),features:S(hT),events:S(rT)}),_T=x([`stopped`,`starting`,`running`,`degraded`,`incomplete`,`failed`]),vT=x([`fresh`,`stale`,`unavailable`]),yT=b({cap:p(),path:p(),item:dT.optional(),state:vT,value:c([p(),f(),v(),ie()]),reason:p().optional()}),bT=b({blockId:p(),deviceId:f().nullable(),status:_T,reason:p().optional(),fields:S(yT)}),ive=rc,xT=b({id:p().min(1),name:p().min(1).max(120),enabled:v(),updatedAt:f(),composition:Mc}),ST=b({id:p().min(1),name:p().nullable(),error:p()}),CT=b({deviceId:f().int(),capName:p(),owner:p(),error:p()}),wT=b({integrationId:p().nullable(),storeLoaded:v(),blocks:S(xT),restartBlockIds:S(p()),unreadableBlocks:S(ST),retiredBlockIds:S(p()).optional()}),TT=b({blockId:p(),status:_T,reason:p().optional()}),ET=b({blocks:S(TT),acted:v(),unreleasedClaims:S(CT).optional()}),DT={name:`composer`,scope:`system`,mode:`singleton`,internal:!0,methods:{applyBlocks:O(wT,ET,{kind:`mutation`,auth:`admin`}),getStates:O(b({blockIds:S(p())}),b({states:S(bT)}),{auth:`admin`})},vocabulary:{notOperatorFacing:`device composition — an authoring tool, not an action`}},OT=b({connected:v(),lastChangedAt:f()}),kT={name:`connectivity`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Sensor],methods:{},status:{schema:OT,kind:`push`},runtimeState:OT,durability:`restored`,history:{fields:{connected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:N(`Connectivity`,`Connettività`),order:5040,state:[{kind:`boolean`,field:`connected`,label:N(`Connected`,`Connesso`),whenTrue:N(`When {device} connects`,`Quando {device} si connette`),whenFalse:N(`When {device} disconnects`,`Quando {device} si disconnette`),icon:`wifi`}]}},AT=x([`wear`,`supply`,`waste`]),jT=x([`part`,`tank`,`product`,`bin`]),MT=x([`ok`,`low`,`empty`,`full`,`replace`]),ave=x([`ok`,`low`,`empty`,`full`]);function NT(e){return e.kind??`wear`}var ove={wear:`part`,waste:`bin`,supply:`product`};function sve(e){return e.form??ove[NT(e)]}var PT=x([`duration`,`count`]),FT=b({value:f().min(0).nullable().meta(j(`device`)),kind:PT}),IT=b({key:p().min(1),label:p().min(1),level:f().min(0).max(100).nullable().meta(j(`percentage`)),status:MT.nullable(),kind:AT.optional(),form:jT.optional(),lastResetAt:f().nullable(),resettable:v(),remaining:FT.optional()}),LT=b({items:S(IT),lastChangedAt:f()}),cve={items:[],lastChangedAt:0},lve={version:1,targets:[{id:`items`,cardinality:`keyedArray`,vocabulary:{cap:`consumables`},deviceTypes:Object.values(w),apply:`add`,path:`items`,keyField:`key`,labelField:`label`,itemSchema:IT,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:[...PT.options]}]},{path:`status`,sources:[{kind:`enum`,transforms:[{kind:`enum-map`,outputValues:[...MT.options],unmapped:null}]}]}],traits:[{path:`kind`,values:[...AT.options],defaultValue:`wear`},{path:`form`,values:[...jT.options],defaultValue:`part`}],companions:[{kind:`clock`,path:`lastChangedAt`,when:`add`},{kind:`clock`,path:`lastFetchedAt`,when:`add`}],advancedExpression:!0}]},RT={name:`consumables`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:Object.values(w),methods:{reset:O(b({deviceId:f().int().nonnegative(),key:p().min(1)}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`consumables.reset`,label:N(`Mark as replaced`,`Segna come sostituito`),phrase:N(`Mark {key} as replaced on {device}`,`Segna {key} come sostituito su {device}`),icon:`refresh-cw`,openArgs:[{key:`key`,label:N(`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:LT,kind:`push`,empty:cve,itemArray:{path:`items`,keyField:`key`,labelField:`label`,itemSchema:IT,emptyItem:{key:``,label:``,level:null,status:null,lastResetAt:null,resettable:!1}}},runtimeState:LT.extend({lastFetchedAt:f()}),durability:`restored`,customize:lve,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:N(`Consumables`,`Materiali di consumo`),order:2070}},zT=b({entryOpen:v(),lastChangedAt:f()}),BT={name:`contact`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Sensor],methods:{},status:{schema:zT,kind:`push`},runtimeState:zT,durability:`restored`,history:{fields:{entryOpen:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:N(`Contact`,`Contatto`),order:5050,state:[{kind:`boolean`,field:`entryOpen`,label:N(`Open`,`Aperto`),whenTrue:N(`When {device} opens`,`Quando {device} si apre`),whenFalse:N(`When {device} closes`,`Quando {device} si chiude`),icon:`door-open`}]}},VT=x([`numeric`,`select`,`text`,`datetime`]),HT=b({kind:VT,value:c([f().meta(j(`device`)),p()]),options:S(p()),lastChangedAt:f(),min:f().optional().meta(j(`device`)),max:f().optional().meta(j(`device`)),step:f().optional().meta(j(`device`))}),uve=i(`kind`,[b({kind:o(`numeric`),value:f()}),b({kind:o(`select`),value:p().min(1)}),b({kind:o(`text`),value:p()}),b({kind:o(`datetime`),value:p().min(1)})]),UT=b({deviceId:f().int().nonnegative(),cycle:v().default(!0)}),WT=b({deviceId:f().int().nonnegative()}),GT={name:`control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Control],methods:{setValue:O(b({deviceId:f().int().nonnegative(),control:uve}),_(),{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:k(UT,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.next`,label:N(`Next option`,`Opzione successiva`),phrase:N(`Select the next option on {device}`,`Seleziona l’opzione successiva su {device}`),icon:`skip-forward`,openArgs:[{key:`cycle`,label:N(`Wrap to the first option`,`Ricomincia dalla prima opzione`),offer:{kind:`boolean`}}]}]}),previous:k(UT,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.previous`,label:N(`Previous option`,`Opzione precedente`),phrase:N(`Select the previous option on {device}`,`Seleziona l’opzione precedente su {device}`),icon:`skip-back`,openArgs:[{key:`cycle`,label:N(`Wrap to the last option`,`Ricomincia dall’ultima opzione`),offer:{kind:`boolean`}}]}]}),first:k(WT,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.first`,label:N(`First option`,`Prima opzione`),phrase:N(`Select the first option on {device}`,`Seleziona la prima opzione su {device}`),icon:`chevron-first`}]}),last:k(WT,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.last`,label:N(`Last option`,`Ultima opzione`),phrase:N(`Select the last option on {device}`,`Seleziona l’ultima opzione su {device}`),icon:`chevron-last`}]})},status:{schema:HT,kind:`push`},runtimeState:HT,durability:`session`,history:`none`,vocabulary:{noun:N(`Control`,`Controllo`),order:1150,state:[{kind:`value`,field:`value`,label:N(`Value`,`Valore`),offer:{kind:`dynamic`,from:`status`,field:`options`},icon:`sliders-horizontal`}]}},R=class extends Error{code;constructor(e,t){super(t),this.name=`IrCodecError`,this.code=e}},KT=1024,qT=S(f().int()).min(2).max(KT).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]})})}),JT=b({carrierHz:f().int().positive().optional(),dutyCyclePercent:f().int().min(1).max(100).optional(),repeat:f().int().min(0).max(20).optional(),repeatDelayMs:f().int().min(0).optional()}),dve=.241246,fve=0;function YT(e){let t=e.trim().split(/\s+/).filter(e=>e.length>0);if(t.length<4)throw new R(`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 R(`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 R(`pronto-malformed`,`Pronto header incomplete`);if(r!==fve)throw new R(`pronto-unsupported-form`,`Pronto form ${t[0]??``} is not supported, only the learned 0000 form`);if(i===0)throw new R(`pronto-malformed`,`Pronto frequency word is zero`);let s=a+o;if(s===0||n.length!==4+s*2)throw new R(`pronto-malformed`,`Pronto declares ${s} burst pairs but carries ${(n.length-4)/2} word pairs`);let c=i*dve,l=n.slice(4).map((e,t)=>{let n=Math.max(1,Math.round(e*c));return t%2==0?n:-n}),u=qT.safeParse(l);if(!u.success)throw new R(`invalid-timings`,`Pronto decoded to invalid timings: ${u.error.message}`);return{timings:u.data,carrierHz:Math.round(1e6/c)}}var pve=8192,XT=32,ZT=3,mve=264,QT=KT*2;function hve(e){let t=[],n=0,r=e=>{if(t.length+e>QT)throw new R(`tuya-malformed`,`decompressed code is larger than any IR train`)},i=()=>{let t=e[n++];if(t===void 0)throw new R(`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 R(`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 R(`tuya-malformed`,`back-reference is invalid`);t.push(n)}}return Uint8Array.from(t)}function gve(e){let t=[],n=new Map,r=0,i=n=>{for(let i=r;i<n;i+=XT){let r=Math.min(i+XT,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+ZT<=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<=pve){let t=0;for(;a+t<e.length&&t<mve&&e[r+t]===e[a+t];)t++;t>=ZT&&(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 $T=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,_ve=65535;function vve(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+=$T[o>>18&63],t+=$T[o>>12&63],t+=n+1<e.length?$T[o>>6&63]:`=`,t+=n+2<e.length?$T[o&63]:`=`}return t}function yve(e){let t=e.trim().replace(/=+$/,``);if(t.length===0||t.length%4==1)throw new R(`tuya-malformed`,`not a base64 string`);let n=[],r=0,i=0;for(let e of t){let t=$T.indexOf(e);if(t<0)throw new R(`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 eE(e){let t=new Uint8Array(e.length*2);return e.forEach((e,n)=>{let r=Math.abs(e);if(r===0||r>_ve)throw new R(`invalid-timings`,`timing ${n} does not fit 16 bits`);t[n*2]=r&255,t[n*2+1]=r>>8}),vve(gve(t))}function tE(e){let t=hve(yve(e));if(t.length===0||t.length%2!=0)throw new R(`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=qT.safeParse(n);if(!r.success)throw new R(`tuya-malformed`,r.error.message);return r.data}var nE=x([`tuya`]),rE=Math.ceil((QT+Math.ceil(QT/32))/3)*4+256,iE=b({format:nE,code:p().min(1).max(rE)}),aE={tuya:{encode:eE,decode:tE}},oE=i(`kind`,[b({kind:o(`raw`),timings:S(f().int()),settings:JT.optional()}),b({kind:o(`pronto`),code:p()}),b({kind:o(`native`),format:nE,code:p()})]);function sE(e){if(e.kind===`pronto`){let t=YT(e.code);return{timings:t.timings,settings:{carrierHz:t.carrierHz}}}if(e.kind===`native`)return{timings:aE[e.format].decode(e.code),settings:{}};let t=qT.safeParse(e.timings);if(!t.success)throw new R(`invalid-timings`,t.error.message);return{timings:t.data,settings:e.settings??{}}}var cE=`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(`.`),lE=[`source_select`];function uE(e){return lE.includes(e)}var dE=`custom:`,bve=/^[a-z0-9][a-z0-9_]{0,47}$/,xve=new Set(cE);function fE(e){return xve.has(e)}function pE(e){return bve.test(e)}function mE(e){return`${dE}${e}`}function hE(e){if(!e.startsWith(`custom:`))return null;let t=e.slice(7);return pE(t)?t:null}function gE(e){return fE(e)||hE(e)!==null}var _E=p().refine(gE,{message:`a role is one of the known roles or custom:<key> (lowercase letters, digits, _)`}),vE=[`digits`,`sequence`,`ir`],Sve=x(vE),Cve=200,wve=16,Tve=6,Eve=/^[a-z0-9][a-z0-9_-]{0,47}$/,Dve=RegExp(`^[0-9]{1,6}$`),yE={id:p().regex(Eve,{message:`a lowercase slug`}),name:p().trim().min(1).max(60)},bE=b({...yE,kind:o(`digits`),number:p().regex(Dve,{message:`up to 6 digits`})}),xE=b({...yE,kind:o(`sequence`),steps:S(_E).min(1).max(16)}),SE=b({...yE,kind:o(`ir`),transmitterId:f().int().nonnegative().optional(),payload:oE}),CE=i(`kind`,[bE,xE,SE]),Ove=500,kve=100,wE=3e3;function TE(e){switch(e.kind){case`sequence`:return e.steps;case`digits`:return Array.from(e.number,e=>`digit_${e}`);case`ir`:return[]}}function EE(e){try{return sE(e.payload),null}catch(e){if(e instanceof R)return e.message;throw e}}function Ave(e,t){return e.trim().toLowerCase()===t.trim().toLowerCase()}function DE(e,t){let n=t.trim();for(let t of e)if(t.kind===`digits`&&t.number===n)return t;return null}function jve(e,t){let n=e.find(e=>Ave(e.name,t));if(n!==void 0)return n;let r=e.find(e=>e.id===t.trim());return r===void 0?DE(e,t):r}var OE=x([`off`,`on`,`idle`,`playing`,`paused`,`buffering`,`standby`]),kE=x([`off`,`all`,`one`]),Mve=b({type:p(),title:p(),artist:p().optional(),album:p().optional(),imageUrl:p().optional()}),AE=x([`reported`,`assumed`]),jE=x([`state`,`volumeLevel`,`isMuted`,`source`]),ME=b({state:OE,stateSource:AE.default(`reported`),assumedFields:S(jE).default([]),volumeLevel:f().min(0).max(100).nullable().meta(j(`percentage`)),isMuted:v().nullable(),muteReadback:v().optional(),source:p(),availableSources:S(p()),declaredSources:S(b({name:p(),kind:x(vE),number:p().optional()})).optional(),currentMedia:Mve.nullable(),position:f().int().nonnegative().nullable().meta(j(`duration-ms`)),duration:f().int().nonnegative().nullable().meta(j(`duration-ms`)),shuffle:v().nullable(),repeat:kE.nullable(),positionUpdatedAt:f().nullable().default(null),lastChangedAt:f()}),Nve=50,NE=b({deviceId:f().int().nonnegative(),steps:f().int().min(1).max(50).default(1)}),PE=b({deviceId:f().int().nonnegative()}),FE={name:`media-player`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.MediaPlayer],power:{kind:`methods`,field:`state`,offValues:[`off`,`standby`],on:`turnOn`,off:`turnOff`},methods:{turnOn:k(PE,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.turnOn`,label:N(`Turn on`,`Accendi`),phrase:N(`Turn on {device}`,`Accendi {device}`),icon:`power`}]}),turnOff:k(PE,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.turnOff`,label:N(`Turn off`,`Spegni`),phrase:N(`Turn off {device}`,`Spegni {device}`),icon:`power`}]}),volumeUp:k(NE,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.volumeUp`,label:N(`Volume up`,`Alza il volume`),phrase:N(`Raise the volume of {device}`,`Alza il volume di {device}`),icon:`volume-2`}]}),volumeDown:k(NE,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.volumeDown`,label:N(`Volume down`,`Abbassa il volume`),phrase:N(`Lower the volume of {device}`,`Abbassa il volume di {device}`),icon:`volume-2`}]}),channelUp:k(NE,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.channelUp`,label:N(`Channel up`,`Canale successivo`),phrase:N(`Go to the next channel on {device}`,`Passa al canale successivo su {device}`),icon:`skip-forward`}]}),channelDown:k(NE,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.channelDown`,label:N(`Channel down`,`Canale precedente`),phrase:N(`Go to the previous channel on {device}`,`Torna al canale precedente su {device}`),icon:`skip-back`}]}),play:O(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.play`,label:N(`Play`,`Riproduci`),phrase:N(`Play on {device}`,`Avvia la riproduzione su {device}`),icon:`play`}]}),pause:O(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.pause`,label:N(`Pause media`,`Metti in pausa`),phrase:N(`Pause {device}`,`Metti in pausa {device}`),icon:`pause`}]}),stop:k(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.stop`,label:N(`Stop media`,`Ferma la riproduzione`),phrase:N(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),next:k(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.next`,label:N(`Next track`,`Brano successivo`),phrase:N(`Skip to the next track on {device}`,`Passa al brano successivo su {device}`),icon:`skip-forward`}]}),previous:k(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.previous`,label:N(`Previous track`,`Brano precedente`),phrase:N(`Go back to the previous track on {device}`,`Torna al brano precedente su {device}`),icon:`skip-back`}]}),setVolume:k(b({deviceId:f().int().nonnegative(),volumeLevel:f().min(0).max(100)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.volume`,label:N(`Set volume`,`Imposta il volume`),phrase:N(`Set the volume of {device} to {volumeLevel}`,`Imposta il volume di {device} al {volumeLevel}`),icon:`volume-2`,openArgs:[{key:`volumeLevel`,label:N(`Volume`,`Volume`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setMute:k(b({deviceId:f().int().nonnegative(),muted:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.mute`,label:N(`Mute`,`Silenzia`),phrase:N(`Mute {device}`,`Silenzia {device}`),icon:`volume-x`,args:{muted:!0}},{id:`media.unmute`,label:N(`Unmute`,`Riattiva l’audio`),phrase:N(`Unmute {device}`,`Riattiva l’audio di {device}`),icon:`volume-2`,args:{muted:!1}}]}),setShuffle:k(b({deviceId:f().int().nonnegative(),shuffle:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.shuffleOn`,label:N(`Shuffle on`,`Riproduzione casuale attiva`),phrase:N(`Turn on shuffle on {device}`,`Attiva la riproduzione casuale su {device}`),icon:`shuffle`,args:{shuffle:!0}},{id:`media.shuffleOff`,label:N(`Shuffle off`,`Riproduzione casuale spenta`),phrase:N(`Turn off shuffle on {device}`,`Disattiva la riproduzione casuale su {device}`),icon:`shuffle`,args:{shuffle:!1}}]}),setRepeat:k(b({deviceId:f().int().nonnegative(),repeat:kE}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.repeat`,label:N(`Set repeat`,`Imposta la ripetizione`),phrase:N(`Set repeat on {device} to {repeat}`,`Imposta la ripetizione di {device} su {repeat}`),icon:`repeat`,openArgs:[{key:`repeat`,label:N(`Repeat`,`Ripetizione`),offer:{kind:`enum`,values:[{value:`off`,label:N(`Off`,`Disattivata`)},{value:`all`,label:N(`All`,`Tutti i brani`)},{value:`one`,label:N(`One track`,`Un brano`)}]}}]}]}),selectSource:k(b({deviceId:f().int().nonnegative(),source:p().min(1)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.source`,label:N(`Select source`,`Scegli la sorgente`),phrase:N(`Switch {device} to {source}`,`Passa {device} alla sorgente {source}`),icon:`cast`,openArgs:[{key:`source`,label:N(`Source`,`Sorgente`),offer:{kind:`dynamic`,from:`status`,field:`availableSources`}}]}]}),seek:k(b({deviceId:f().int().nonnegative(),position:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.seek`,label:N(`Seek`,`Vai al punto`),phrase:N(`Move {device} to {position}`,`Porta {device} al punto {position}`),icon:`fast-forward`,openArgs:[{key:`position`,label:N(`Position`,`Posizione`),offer:{kind:`number`,min:0,step:1e3,unit:`ms`}}]}]}),playMedia:k(b({deviceId:f().int().nonnegative(),mediaId:p().min(1),mediaType:p().min(1)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.playMedia`,label:N(`Play media`,`Riproduci un contenuto`),phrase:N(`Play {mediaId} on {device}`,`Riproduci {mediaId} su {device}`),icon:`music`,openArgs:[{key:`mediaId`,label:N(`Media`,`Contenuto`),offer:{kind:`text`}},{key:`mediaType`,label:N(`Media type`,`Tipo di contenuto`),offer:{kind:`text`}}]}]})},status:{schema:ME,kind:`push`},runtimeState:ME,durability:`session`,history:{fields:{volumeLevel:{kind:`gauge`,unit:`%`,deadband:1},isMuted:{kind:`boolean`}}},vocabulary:{noun:N(`Media player`,`Lettore multimediale`),order:2060,state:[{kind:`enum`,field:`state`,label:N(`Playback`,`Riproduzione`),values:[{value:`off`,label:N(`Off`,`Spento`),phrase:N(`When {device} turns off`,`Quando {device} si spegne`)},{value:`on`,label:N(`On`,`Acceso`),phrase:N(`When {device} turns on`,`Quando {device} si accende`)},{value:`idle`,label:N(`Idle`,`Inattivo`)},{value:`playing`,label:N(`Playing`,`In riproduzione`),phrase:N(`When {device} starts playing`,`Quando {device} inizia a riprodurre`)},{value:`paused`,label:N(`Paused`,`In pausa`),phrase:N(`When {device} is paused`,`Quando {device} va in pausa`)},{value:`buffering`,label:N(`Buffering`,`In caricamento`)},{value:`standby`,label:N(`Standby`,`In standby`)}],icon:`music`},{kind:`numeric`,field:`volumeLevel`,quantity:N(`the volume`,`il volume`),label:N(`Volume`,`Volume`),unit:`%`,icon:`volume-2`},{kind:`boolean`,field:`isMuted`,label:N(`Muted`,`Silenziato`),whenTrue:N(`When {device} is muted`,`Quando {device} viene silenziato`),whenFalse:N(`When {device} is unmuted`,`Quando l’audio di {device} torna attivo`),icon:`volume-x`},{kind:`value`,field:`source`,label:N(`Source`,`Sorgente`),offer:{kind:`dynamic`,from:`status`,field:`availableSources`},icon:`cast`}]}},IE={battery:{version:1,targets:[{id:`level`,cardinality:`scalar`,deviceTypes:[w.Camera,w.Sensor,w.Button,w.Switch,w.PetFeeder,w.Container,w.Climate,w.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:[w.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:[w.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:[w.Camera,w.Light,w.Siren,w.Switch,w.Sensor,w.Climate,w.Button,w.EventEmitter,w.Update,w.Generic,w.Notifier,w.Script,w.Automation,w.Lock,w.Cover,w.Valve,w.Humidifier,w.WaterHeater,w.Fan,w.MediaPlayer,w.AlarmPanel,w.Control,w.Presence,w.Weather,w.WeatherStation,w.Vacuum,w.LawnMower,w.Container,w.Image,w.PetFeeder,w.PetFountain,w.Dishwasher,w.Washer,w.Dryer,w.Gateway,w.HeatPump,w.EnergySystem],apply:`add`,vocabularyCap:`consumables`,sources:[],sourceReport:{status:`assignment-status`},advancedExpression:!0,path:`items`,keyField:`key`,labelField:`label`,nativeItems:`read-only`,fields:[{path:`level`,valueKind:`number`,nullable:!0,sources:[{kind:`numeric`,transformKinds:[`identity`,`linear`],transforms:[{kind:`identity`},{kind:`linear`,defaultScale:1,defaultOffset:0,clampMin:0,clampMax:100}]}]},{path:`remaining.value`,valueKind:`number`,nullable:!0,sources:[{kind:`numeric`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],literals:[{path:`remaining.kind`,values:[`duration`,`count`]}]},{path:`status`,valueKind:`enum`,nullable:!0,enumValues:[`ok`,`low`,`empty`,`full`,`replace`],sources:[{kind:`enum`,transformKinds:[`enum-map`],transforms:[{kind:`enum-map`,outputValues:[`ok`,`low`,`empty`,`full`,`replace`],unmapped:null}]}]}],traits:[{path:`kind`,values:[`wear`,`supply`,`waste`],defaultValue:`wear`},{path:`form`,values:[`part`,`tank`,`product`,`bin`],defaultValue:`part`}],companions:[{kind:`clock`,path:`lastChangedAt`,when:`add`},{kind:`clock`,path:`lastFetchedAt`,when:`add`}]}]},doorbell:{version:1,targets:[{id:`pressed`,cardinality:`event`,deviceTypes:[w.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:[w.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:[w.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:[w.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:[w.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:[w.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:[w.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:[w.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:[w.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:[w.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:[w.Fan],apply:`add`,readMethod:`getPresets`,writeMethod:`setPresets`,vocabularyCap:`fan-presets`,sources:[],sourceReport:{status:`assignment-status`},advancedExpression:!1}]},"lock-control":{version:1,targets:[{id:`door-contact`,cardinality:`scalar`,deviceTypes:[w.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:[w.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:[w.Switch,w.Light,w.Fan,w.Climate,w.Humidifier,w.WaterHeater,w.MediaPlayer,w.Washer,w.Dryer,w.Dishwasher,w.Vacuum,w.LawnMower,w.PetFeeder],apply:`add`,vocabularyCap:`power-meter`,vocabularyStateField:`power`,sources:[{kind:`numeric`,requiredUnit:`W`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!0,path:`power`,valueKind:`number`,nullable:!1,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`always`}]},{id:`energy`,cardinality:`scalar`,deviceTypes:[w.Switch,w.Light,w.Fan,w.Climate,w.Humidifier,w.WaterHeater,w.MediaPlayer,w.Washer,w.Dryer,w.Dishwasher,w.Vacuum,w.LawnMower,w.PetFeeder],apply:`add`,vocabularyCap:`power-meter`,vocabularyStateField:`energy`,sources:[{kind:`numeric`,requiredUnit:`kWh`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!0,path:`energy`,valueKind:`number`,nullable:!1,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`always`}]},{id:`voltage`,cardinality:`scalar`,deviceTypes:[w.Switch,w.Light,w.Fan,w.Climate,w.Humidifier,w.WaterHeater,w.MediaPlayer,w.Washer,w.Dryer,w.Dishwasher,w.Vacuum,w.LawnMower,w.PetFeeder],apply:`add`,vocabularyCap:`power-meter`,vocabularyStateField:`voltage`,sources:[{kind:`numeric`,requiredUnit:`V`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!0,path:`voltage`,valueKind:`number`,nullable:!1,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`always`}]},{id:`current`,cardinality:`scalar`,deviceTypes:[w.Switch,w.Light,w.Fan,w.Climate,w.Humidifier,w.WaterHeater,w.MediaPlayer,w.Washer,w.Dryer,w.Dishwasher,w.Vacuum,w.LawnMower,w.PetFeeder],apply:`add`,vocabularyCap:`power-meter`,vocabularyStateField:`current`,sources:[{kind:`numeric`,requiredUnit:`A`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!0,path:`current`,valueKind:`number`,nullable:!1,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`always`}]}]},"power-source":{version:1,targets:[{id:`switch`,cardinality:`scalar`,deviceTypes:[w.Gateway,w.Camera,w.Sensor,w.MediaPlayer,w.Vacuum,w.Generic,w.Washer,w.Dryer,w.Dishwasher,w.PetFountain,w.Fan,w.Humidifier,w.Climate,w.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:[w.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:[w.Washer,w.Dryer,w.Dishwasher,w.Vacuum,w.LawnMower,w.MediaPlayer,w.WaterHeater,w.Humidifier,w.Fan,w.Climate,w.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:{[w.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:[w.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:[w.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:[w.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:[w.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:[w.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:[w.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:[w.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:[w.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:[w.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:[w.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:[w.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:[w.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:[w.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:[w.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:[w.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:[w.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:[w.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:[w.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:[w.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:[w.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`}]}},LE={"ambient-light-sensor":{illuminance:`lx`},battery:{level:`%`,voltage:`V`},"humidity-sensor":{humidity:`%`},"power-meter":{power:`W`,energy:`kWh`,voltage:`V`,current:`A`},"temperature-sensor":{temperature:`°C`}};function z(e,t,n){return{code:e,path:t,message:n}}function RE(...e){return{problems:e,fields:[],features:[],events:[]}}function zE(e){let t=e.item===void 0?`fields`:`items.${e.item.key}.fields`;return`features[${e.featureIndex}].${t}.${e.path}`}var BE={kind:`fixed`,result:[`number`]},VE={kind:`fixed`,result:[`boolean`]},HE=Object.freeze({min:BE,max:BE,abs:BE,floor:BE,ceil:BE,sqrt:BE,round:BE,pow:BE,clamp:BE,avg:BE,sum:BE,age:BE,convert:BE,coalesce:{kind:`coalesce`},any:VE,all:VE,within:VE,latest:{kind:`fixed`,result:[`number`,`null`]},number:{kind:`fixed`,result:[`number`,`null`]},rose:{kind:`fixed`,result:[`number`,`null`]},count:BE,dwell:{kind:`fixed`,result:[`boolean`,`null`]},latchedAt:{kind:`fixed`,result:[`number`,`null`]},schmitt:{kind:`fixed`,result:[`boolean`,`null`]}}),UE=class extends Error{};function WE(e){return e===null?`null`:typeof e==`number`?`number`:typeof e==`string`?`string`:`boolean`}function GE(e){return new Set([e])}function KE(...e){return new Set(e.flatMap(e=>[...e]))}function Pve(e){return new Set([...e].filter(e=>e!==`null`))}function Fve(e,t,n){if(e===`+`){let e=[...t,...n];return e.every(e=>e===`string`)?GE(`string`):e.every(e=>e===`number`)?GE(`number`):new Set([`number`,`string`])}return GE(e===`-`||e===`*`||e===`/`||e===`%`?`number`:`boolean`)}function Ive(e){return e.minArgs===e.maxArgs?`exactly ${e.minArgs}`:e.maxArgs===1/0?`at least ${e.minArgs}`:`${e.minArgs}–${e.maxArgs}`}function Lve(e,t){let n=ko[e];if(n!==void 0&&(t.length<n.minArgs||t.length>n.maxArgs))throw new UE(`${e}: wrong number of arguments (${t.length}); expected ${Ive(n)}`);let r=HE[e];if(r===void 0)throw new UE(`no result-kind rule for builtin '${e}'`);if(r.kind===`fixed`)return new Set(r.result);let i=KE(...t.map(Pve));return t.every(e=>e.has(`null`))?KE(i,GE(`null`)):i}function qE(e,t){switch(e.kind){case`literal`:return GE(WE(e.value));case`identifier`:{if(e.name===`now`)return GE(`number`);let n=t.get(e.name);if(n===void 0)throw new UE(`unbound identifier '${e.name}'`);return n}case`unary`:return GE(e.op===`!`?`boolean`:`number`);case`binary`:return Fve(e.op,qE(e.left,t),qE(e.right,t));case`logical`:return KE(qE(e.left,t),qE(e.right,t));case`conditional`:return KE(qE(e.consequent,t),qE(e.alternate,t));case`call`:return Lve(e.callee,e.args.map(e=>qE(e,t)))}}function JE(e,t){switch(e.kind){case`literal`:case`identifier`:return!1;case`unary`:return JE(e.operand,t);case`binary`:case`logical`:return JE(e.left,t)||JE(e.right,t);case`conditional`:return JE(e.test,t)||JE(e.consequent,t)||JE(e.alternate,t);case`call`:return e.callee===t||e.args.some(e=>JE(e,t))}}function YE(e,t){let n=Bo(e);return n.ok&&JE(n.parsed.ast,t)}function XE(e){let t=Bo(e.expr);if(!t.ok)return{ok:!1,error:t.error};try{return{ok:!0,kinds:qE(t.parsed.ast,e.bindingKinds)}}catch(e){if(e instanceof UE)return{ok:!1,error:e.message};throw e}}function Rve(e){return e.publish===`value`&&e.empty===`null`?{ok:!0,kinds:new Set([`number`,`null`])}:{ok:!0,kinds:new Set([`number`])}}function zve(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 ZE(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=Qw(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 QE(e,t,n){return z(`kind-mismatch`,n,`\`${e}.${t}\` is a union — it is read as a source, never written`)}function $E(e){return e.kind===`union`?null:e.kind===`enum`?`string`:e.kind}function eD(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=Qw(a,e.fieldPath),s=$E(t);return o?.kind!==`union`||s===null||!n.has(s)?n:new Set(n.has(`null`)?[s,`null`]:[s])}function tD(e,t){if(e.kind===`from`)return ZE(e,t);if(e.kind===`code`)return{ok:!1,code:`reserved-variant`,message:`code fields arrive in slice 4`};if(e.kind===`aggregate`)return zve(e);if(e.kind===`series`)return Rve(e);let n=new Map;for(let[r,i]of Object.entries(e.bindings)){if(i.kind===`literal`){n.set(r,new Set([WE(i.value)]));continue}let e=ZE(i,t);if(!e.ok)return{...e,message:`binding \`${r}\`: ${e.message}`};n.set(r,e.kinds)}let r=XE({expr:e.expr,bindingKinds:n});return r.ok?{ok:!0,kinds:r.kinds}:{ok:!1,code:`expression-invalid`,message:r.error}}function nD(e,t,n,r){let i=$E(t);if(i===null)return[QE(e,t.path,r)];let a=[...n].filter(e=>e!==`null`&&e!==i),o=[];return a.length>0&&o.push(z(`kind-mismatch`,r,`\`${e}.${t.path}\` is a ${t.kind}; this source can produce ${a.join(` or `)}`)),n.has(`null`)&&!t.nullable&&o.push(z(`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 Bve(e){if(e.kind!==`expression`)return null;let t=Bo(e.expr);if(!t.ok)return null;let n=t.parsed.ast;return n.kind===`literal`&&typeof n.value==`string`?n.value:null}function rD(e,t,n,r){if(t.kind!==`enum`||t.enumValues===void 0)return null;let i=Bve(n);if(i===null||t.enumValues.includes(i))return null;let a=t.enumValues.map(e=>`\`${e}\``).join(`, `);return z(`kind-mismatch`,r,`\`${e}.${t.path}\` accepts only ${a}; this source is the literal \`${i}\``)}function iD(e){if(e.kind!==`expression`)return`derived`;if(YE(e.expr,`count`))return`accumulator`;if(Rc(e).length>0)return`derived`;let t=Bo(e.expr);return t.ok&&t.parsed.identifiers.has(`now`)?`clock`:`constant`}function aD(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:z(`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 oD={resettable:!1};function Vve(e){return new Set([e.keyField,...e.labelField===void 0?[]:[e.labelField],...Object.keys(oD)])}function Hve(e,t,n){let r=Qw(e.itemSchema,t);return r===null||!r.required?!1:tT(e.itemSchema,t).every(e=>n.some(t=>t.startsWith(`${e}.`)))}function Uve({capName:e,itemArray:t,reserved:n},r,i){let a=Object.keys(r.fields);return Tg(t.itemSchema).flatMap(o=>{if(n.has(o.path)||o.path in r.fields||!Hve(t,o.path,a))return[];let s=Qw(t.itemSchema,o.path);return s===null||s.nullable?[]:[z(`missing-field`,`${i}.fields.${o.path}`,`\`${e}.${t.path}[].${o.path}\` is required and has no source`)]})}function Wve(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 RE(z(`item-field-reserved`,u,`\`${n}.${r.path}[].${c}\` is set by the composer itself — it takes no source`));let d=Qw(r.itemSchema,c);if(d===null)return RE(z(`unknown-field`,u,`a \`${n}\` item has no field \`${c}\``));if(d.kind===`union`)return RE(QE(n,c,u));let f=tD(l,a);if(!f.ok)return RE(z(f.code,u,f.message));let p=iD(l),m=aD(d,p,e.mode,n,u);if(!m.ok)return RE(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:[...Rc(l)]},g=rD(n,d,l,u);return{problems:[...nD(n,d,eD(l,d,f.kinds,a),u),...g===null?[]:[g]],fields:[h],features:[],events:[]}}function sD(e,t,n,r,i=`new`){let a=`features[${n}].items`,o=e.status?.itemArray;if(o===void 0)return RE(z(`not-item-array`,a,`\`${e.name}\` has no item array — it takes no \`items\``));if(o.path!==`items`)return RE(z(`not-item-array`,a,`\`${e.name}\`'s item array is at \`${o.path}\`, not \`${Sc}\` — not composable yet`));let s={capName:e.name,itemArray:o,reserved:Vve(o),featureIndex:n,lookupCap:r,mode:i},c=Object.entries(t.items??{}).flatMap(([e,t])=>[{problems:Uve(s,t,`${a}.${e}`),fields:[],features:[],events:[]},...Object.entries(t.fields).map(([n,r])=>Wve(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 cD=`deviceId`;function lD(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 uD(e){let t=e.features.flatMap((e,t)=>e.kind===`fields`&&Dc(e)?lD(e,t).map(e=>e.command.source):[]);return[...new Map(t.map(e=>[Nc(e),e])).values()]}function Gve(e,t){return e.name===`switch`&&t===`toggle`}function dD(e){return Object.entries(e.methods).filter(([t,n])=>n.systemOnly!==!0&&e.composedMethods?.[t]===void 0&&!Gve(e,t)).map(([e])=>e)}function Kve(){return Object.fromEntries(dD(FE).map(e=>[e,{kind:`extension`,target:`remote`}]))}var fD={all:new Set,required:new Set};function pD(e,t){let n=e.methods[t]?.input;if(n===void 0)return null;let r=wg(n);if(!(r instanceof se))return null;let i=Object.entries(r.shape).filter(([e])=>e!==cD);return{all:new Set(i.map(([e])=>e)),required:new Set(i.flatMap(([e,t])=>t instanceof re&&!t.safeParse(void 0).success?[e]:[]))}}function mD(e){return typeof e==`object`?_c(e)?[e.$input]:Object.values(e).flatMap(mD):[]}function hD(e){return[...e].map(e=>`\`${e}\``).join(`, `)}function qve(e,t){let{command:n,at:r}=e,i=t(n.cap);if(i===null)return{def:null,problems:[z(`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:[z(`command-source-unknown`,`${r}.method`,`\`${n.cap}\` has no method \`${n.method}\` to forward to`)]}:a.kind===`mutation`?{def:i,problems:[]}:{def:null,problems:[z(`command-source-unknown`,`${r}.method`,`\`${n.cap}.${n.method}\` is a query — a command calls a mutation of the source`)]}}function Jve(e,t,n,r){let{at:i,command:a}=e,o=`${a.cap}.${a.method}`,s=[];if(`deviceId`in r&&s.push(z(`command-input-unknown`,`${i}.args.${cD}`,`\`${cD}\` 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(z(`command-input-unknown`,`${i}.args.${e}`,`\`${o}\` has no input field \`${e}\` (it takes ${hD(n.all)})`));let e=[...n.required].filter(e=>!(e in r));e.length>0&&s.push(z(`command-input-missing`,`${i}.args`,`\`${o}\` needs ${hD(e)}, which \`args\` does not provide`))}let c=e.itemKey===void 0?t:fD;if(c!==null)for(let t of Object.values(r).flatMap(mD))c.all.has(t)||s.push(z(`command-input-unknown`,`${i}.args`,c===fD?`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 ${hD(c.all)})`));return s}function Yve(e,t,n){let{at:r,command:i}=e,a=`${i.cap}.${i.method}`,o=e.itemKey===void 0?t:fD;if(o===null||n===null)return[];let s=[];for(let t of[...o.all].filter(e=>!n.all.has(e)))s.push(z(`command-input-unknown`,`${r}.args`,`\`${e.method}\` takes \`${t}\`, which \`${a}\` does not (it takes ${hD(n.all)}) — add \`args\` to map it`));let c=[...n.required].filter(e=>!o.all.has(e));return c.length>0&&s.push(z(`command-input-missing`,`${r}.args`,`\`${a}\` needs ${hD(c)}, which \`${e.method}\` does not take — add \`args\` to provide it`)),s}function gD(e,t,n){let r=qve(t,n);if(r.def===null)return r.problems;let i=pD(e,t.method),a=pD(r.def,t.command.method),o=t.command.args;return o===void 0?Yve(t,i,a):Jve(t,i,a,o)}function _D(e,t,n){let r=new Set(dD(e));return Object.keys(t.commands??{}).flatMap(t=>{if(r.has(t))return[];let i=e.composedMethods?.[t]!==void 0;return[z(`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 vD(e,t){return e.features.flatMap((e,n)=>e.kind!==`fields`||!Dc(e)?[]:lD(e,n).flatMap(e=>{let n=Nc(e.command.source),r=t.get(n),i=`${e.at}.source`;return r===void 0||r.kind===`unreadable`?[z(`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`?[z(`source-missing`,i,`source \`${n}\` does not exist`)]:r.caps.has(e.command.cap)?[]:[z(`source-capability-missing`,i,`source \`${n}\` (device ${r.deviceId}) has no \`${e.command.cap}\``)]}))}var yD={fieldPath:`lastFetchedAt`,expr:`now`},bD={fieldPath:`lastChangedAt`,expr:`now`};function xD(e){let{alsoFrom:t,...n}=e;return{...n,family:`numeric`,deviceType:w.Sensor,memberDeviceType:w.Sensor,memberDeviceTypes:[w.Sensor,...t?.deviceTypes??[]],activeWhen:void 0,commandCaps:[],baseUnit:Gi(e.quantity),aggregates:Ls,accept:[{cap:e.outputCap,fieldPath:e.outputField},...t===void 0?[]:[t.accept]]}}var SD=[w.Climate];function CD(e){return{...e,family:`binary`,deviceType:w.Sensor,memberDeviceType:w.Sensor,memberDeviceTypes:[w.Sensor],activeWhen:void 0,commandCaps:[],quantity:`none`,baseUnit:void 0,aggregates:Rs,empty:`offline`}}var wD=[xD({id:`temperature`,summary:`Mean, median, min, max or sum of temperatures. Offline and unknown members are left out, never read as 0 °C.`,role:E.TemperatureSensor,outputCap:`temperature-sensor`,outputField:`temperature`,quantity:`temperature`,defaultAggregate:`mean`,empty:`null`,companions:[yD],alsoFrom:{deviceTypes:SD,accept:{cap:`climate-control`,fieldPath:`currentTemp`}}}),xD({id:`humidity`,summary:`Humidity in percent. Offline and unknown members are left out, never read as 0 %.`,role:E.HumiditySensor,outputCap:`humidity-sensor`,outputField:`humidity`,quantity:`humidity`,defaultAggregate:`mean`,empty:`null`,companions:[yD],alsoFrom:{deviceTypes:SD,accept:{cap:`climate-control`,fieldPath:`currentHumidity`}}}),xD({id:`pressure`,summary:`Pressure in hectopascals. Offline and unknown members are left out, never read as 0 hPa.`,role:E.PressureSensor,outputCap:`pressure-sensor`,outputField:`pressure`,quantity:`pressure`,defaultAggregate:`mean`,empty:`null`,companions:[yD]}),xD({id:`illuminance`,summary:`Illuminance in lux. Offline and unknown members are left out, never read as 0 lx.`,role:E.AmbientLightSensor,outputCap:`ambient-light-sensor`,outputField:`illuminance`,quantity:`illuminance`,defaultAggregate:`mean`,empty:`null`,companions:[yD]}),xD({id:`power`,summary:`Power in watts, summed by default. Nobody reporting omits the key rather than writing 0 W.`,role:E.PowerSensor,outputCap:`power-meter`,outputField:`power`,quantity:`power`,defaultAggregate:`sum`,empty:`omit`,companions:[yD]}),xD({id:`energy`,summary:`Energy in kilowatt-hours, summed by default. Nobody reporting omits the key rather than writing 0 kWh.`,role:E.EnergySensor,outputCap:`power-meter`,outputField:`energy`,quantity:`energy`,defaultAggregate:`sum`,empty:`omit`,companions:[yD]}),xD({id:`battery`,summary:`Battery charge in percent. Offline and unknown members are left out, never read as 0 %.`,role:E.BatterySensor,outputCap:`battery`,outputField:`level`,quantity:`percentage`,defaultAggregate:`mean`,empty:`null`,companions:[{fieldPath:`charging`,expr:`"unknown"`},{fieldPath:`sleeping`,expr:`false`},{fieldPath:`lastUpdated`,expr:`now`}]}),xD({id:`numeric`,summary:`A numeric reading in the members’ shared quantity. Mixed quantities are refused. Nobody reporting publishes null, not 0.`,role:E.NumericSensor,outputCap:`numeric-sensor`,outputField:`value`,quantity:`device`,defaultAggregate:`mean`,empty:`null`,companions:[yD]}),CD({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:E.MotionSensor,outputCap:`motion`,outputField:`detected`,defaultAggregate:`any`,accept:[{cap:`motion`,fieldPath:`detected`}],companions:[{fieldPath:`lastDetectedAt`,expr:`null`},{fieldPath:`autoClearAfterMs`,expr:`null`}]}),CD({id:`contact`,summary:`Any or all open contacts. Offline and unknown members are left out, never read as closed.`,role:E.ContactSensor,outputCap:`contact`,outputField:`entryOpen`,defaultAggregate:`any`,accept:[{cap:`contact`,fieldPath:`entryOpen`}],companions:[bD]}),CD({id:`leak`,summary:`Any or all leak detections. Offline and unknown members are left out, never read as dry.`,role:E.LeakSensor,outputCap:`flood`,outputField:`flooded`,defaultAggregate:`any`,accept:[{cap:`flood`,fieldPath:`flooded`}],companions:[bD]}),CD({id:`smoke`,summary:`Any or all smoke detections. Offline and unknown members are left out, never read as clear.`,role:E.SmokeSensor,outputCap:`smoke`,outputField:`detected`,defaultAggregate:`any`,accept:[{cap:`smoke`,fieldPath:`detected`}],companions:[bD]}),CD({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:E.BinarySensor,outputCap:`binary`,outputField:`on`,defaultAggregate:`any`,accept:[{cap:`motion`,fieldPath:`detected`},{cap:`binary`,fieldPath:`on`}],companions:[bD]}),CD({id:`binary`,summary:`Any or all generic binary sensors. Offline and unknown members are left out, never read as off.`,role:E.BinarySensor,outputCap:`binary`,outputField:`on`,defaultAggregate:`any`,accept:[{cap:`binary`,fieldPath:`on`}],companions:[bD]}),TD({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:w.Switch,outputCap:`switch`,outputField:`on`,member:{cap:`switch`,fieldPath:`on`},commandCaps:[`switch`]}),TD({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:w.Light,outputCap:`switch`,outputField:`on`,member:{cap:`switch`,fieldPath:`on`},commandCaps:[`switch`,`brightness`,`color`]}),TD({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:w.Fan,outputCap:`switch`,outputField:`on`,member:{cap:`switch`,fieldPath:`on`},commandCaps:[`switch`,`fan-control`]}),TD({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:w.Cover,outputCap:`group-active`,outputField:`active`,member:{cap:`cover`,fieldPath:`state`},activeWhen:[`open`,`opening`,`stopped`],commandCaps:[`cover`]}),TD({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:w.Valve,outputCap:`group-active`,outputField:`active`,member:{cap:`valve`,fieldPath:`state`},activeWhen:[`open`,`opening`,`stopped`],commandCaps:[`valve`]}),TD({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:w.Lock,outputCap:`group-active`,outputField:`active`,member:{cap:`lock-control`,fieldPath:`state`},activeWhen:[`locked`],commandCaps:[`lock-control`]}),TD({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:w.MediaPlayer,outputCap:`group-active`,outputField:`active`,member:{cap:`media-player`,fieldPath:`state`},activeWhen:[`playing`,`buffering`],commandCaps:[`media-player`]}),TD({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:w.Climate,memberDeviceTypes:[w.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 TD(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:Rs,defaultAggregate:`any`,empty:`offline`,accept:[e.member],companions:[bD]}}var Xve=new Map(wD.map(e=>[e.id,e]));function ED(e){return Xve.get(e)??null}var DD={"air-quality-sensor":{co2:{kind:`gauge`,unit:`ppm`,deadband:5},voc:{kind:`gauge`,unit:`ppb`,deadband:5},pm25:{group:`particulates`,kind:`gauge`,unit:`µg/m³`,deadband:1},pm10:{group:`particulates`,kind:`gauge`,unit:`µg/m³`,deadband:1},aqi:{kind:`gauge`,unit:`count`,deadband:1}},"alarm-panel":{state:{kind:`enum`,values:[`disarmed`,`armed_home`,`armed_away`,`armed_night`,`armed_vacation`,`armed_custom_bypass`,`arming`,`disarming`,`pending`,`triggered`]}},"ambient-light-sensor":{illuminance:{kind:`gauge`,unit:`lx`,deadbandPct:10,minIntervalMs:6e4}},battery:{level:{kind:`gauge`,unit:`%`},voltage:{kind:`gauge`,unit:`V`}},binary:{on:{kind:`boolean`}},brightness:{level:{kind:`gauge`,unit:`%`,minIntervalMs:0}},"carbon-monoxide":{detected:{kind:`boolean`}},"climate-control":{currentTemp:{group:`temperature`,kind:`gauge`,unit:`°C`,deadband:.1},currentHumidity:{kind:`gauge`,unit:`%`,deadband:.5},target:{group:`temperature`,kind:`gauge`,unit:`°C`,minIntervalMs:0},targetHigh:{group:`target-range`,kind:`gauge`,unit:`°C`,minIntervalMs:0},targetLow:{group:`target-range`,kind:`gauge`,unit:`°C`,minIntervalMs:0}},connectivity:{connected:{kind:`boolean`}},contact:{entryOpen:{kind:`boolean`}},cover:{position:{kind:`gauge`,unit:`%`,minIntervalMs:0}},"device-status":{online:{kind:`boolean`}},dishwasher:{progress:{kind:`gauge`,unit:`%`,deadband:2},state:{kind:`enum`,values:[`idle`,`running`,`paused`,`finished`,`error`,`unavailable`]},operationState:{kind:`enum`,values:[`Inactive`,`Ready`,`DelayedStart`,`Run`,`Pause`,`ActionRequired`,`Finished`,`Error`,`Aborting`]},remaining:{kind:`gauge`,unit:`s`,minIntervalMs:6e4},doorOpen:{kind:`boolean`},powerOn:{kind:`boolean`}},"do-not-disturb":{enabled:{kind:`boolean`}},"energy-system":{"solar.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Solar power`},"solar.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`Solar energy`},"grid.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Grid power`},"grid.importKwh":{kind:`counter`,unit:`kWh`,displayName:`Grid import`},"grid.exportKwh":{kind:`counter`,unit:`kWh`,displayName:`Grid export`},"house.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`House power`},"house.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`House energy`},"heatPump.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Heat pump power`},"heatPump.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`Heat pump energy`},"storage.stateOfChargePct":{kind:`gauge`,unit:`%`,deadband:1,displayName:`Storage charge`},"storage.storedKwh":{kind:`gauge`,unit:`kWh`,deadband:.05,displayName:`Stored energy`},"storage.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Storage power`},"storage.chargedKwh":{kind:`counter`,unit:`kWh`,displayName:`Storage charged`},"storage.dischargedKwh":{kind:`counter`,unit:`kWh`,displayName:`Storage discharged`},"storage.healthPct":{kind:`gauge`,unit:`%`,deadband:1,displayName:`Storage health`}},"enum-sensor":{value:{kind:`enum`,skipWhenSet:`timestamp`}},"fan-control":{speed:{kind:`gauge`,unit:`%`,minIntervalMs:0},oscillating:{kind:`boolean`}},flood:{flooded:{kind:`boolean`}},gas:{detected:{kind:`boolean`}},"heat-pump-status":{"power.thermalW":{group:`power`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Thermal power`},"power.electricalW":{group:`power`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Electrical power`},"power.compressorPct":{kind:`gauge`,unit:`%`,deadband:2,displayName:`Compressor`},"temperatures.supply":{group:`loop`,kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Supply`},"temperatures.return":{group:`loop`,kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Return`},"temperatures.outdoor":{kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Outdoor`},"energy.thermalKwh":{kind:`counter`,unit:`kWh`,displayName:`Thermal energy`},"energy.electricalKwh":{kind:`counter`,unit:`kWh`,displayName:`Electrical energy`}},"heating-valve":{position:{kind:`gauge`,unit:`%`,deadband:1}},humidifier:{currentHumidity:{kind:`gauge`,unit:`%`,deadband:.5},on:{kind:`boolean`}},"humidity-sensor":{humidity:{kind:`gauge`,unit:`%`,deadband:.5}},"lawn-mower-control":{batteryLevel:{kind:`gauge`,unit:`%`,deadband:2}},"lock-control":{state:{kind:`enum`,values:[`locked`,`unlocked`,`locking`,`unlocking`,`jammed`,`door-open`]}},"media-player":{volumeLevel:{kind:`gauge`,unit:`%`,deadband:1},isMuted:{kind:`boolean`}},meter:{value:{kind:`counter`,deadband:.001,minIntervalMs:6e4}},motion:{detected:{kind:`boolean`,excludeDeviceTypes:[w.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}}},Zve={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`}}}},OD={"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}},Qve=`audio-metrics.automation-control.camera-streams.color.control.day-night.doorbell.error.event-emitter.feature-probe.group-active.group-commands.group-status.image.image-settings.intercom.ir-transmitter.motion-trigger.motion-zones.native-object-detection.navigation.notifier.power-source.presence.privacy-mask.ptz-autotrack.pump-cycle.recording-onboard.recording-signal.scene-monitor.script-runner.stream-catalog.stream-signals.timed-run.update.zone-analytics.zone-rules.zones`.split(`.`);function kD(e){return DD[e]??{}}function $ve(e,t,n){return AD(e.deviceTypes,t,n)}function AD(e,t,n){return e.length===0||e.some(e=>e===t)?!0:oo(t,n)&&e.includes(w.Light)}function eye(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 jD(e){return{fieldChoice:`operator`,purpose:`historised`,multiple:!1,max:1,deviceTypes:[],accept:MD(e),history:{required:!0,minRetentionMs:null},mustBindCaps:[],exclude:[]}}function MD(e){let t=[];for(let n of Object.keys(DD))for(let[r,i]of Object.entries(kD(n)))i.kind!==`enum`&&(e===`integral`&&i.kind!==`gauge`||t.push({cap:n,fieldPath:r,valueKind:i.kind===`boolean`?`boolean`:`number`}));return t}function tye(e){if(e===`derivative`)return{...jD(`statistic`),accept:ND()};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:ND(),history:{required:!1,minRetentionMs:null},mustBindCaps:[],exclude:[]}}function ND(){return MD(`statistic`).filter(e=>e.valueKind===`number`)}var PD=[`switch`,`brightness`,`color`],nye=[T.LightColorRgb,T.LightColorHsv,T.LightColorMired],rye=4;function FD(e){return e===`all`?`all`:`any`}function iye(e){return e===`all`?`all`:`at-least-one`}function aye(e){return e.length===0?[]:PD.filter(t=>e.every(e=>e.includes(t)))}function oye(e){return e.length===0?[]:nye.filter(t=>e.every(e=>e.includes(t)))}function sye(e,t,n,r){return e.flatMap(e=>e.caps.includes(t)?[{deviceId:e.deviceId,cap:t,method:n,args:{...r}}]:[])}async function cye(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 lye={kind:`expression`,expr:`now`,bindings:{}};function ID(e,t,n){return{kind:`series`,read:{source:e.source,cap:e.cap,fieldPath:e.fieldPath},publish:t,empty:n}}function uye(e){return{included:ID(e,`included`,`offline`),excluded:ID(e,`excluded`,`offline`),total:ID(e,`total`,`offline`)}}var dye={second:`s`,minute:`min`,hour:`h`};function fye(e){let t=kD(e.source.cap)[e.source.fieldPath]?.unit;return t===void 0?null:`${t}/${dye[e.per]}`}function LD(e){let t=kD(e.cap)[e.fieldPath];return t===void 0?null:t.kind}function RD(e){return LD(e)===null?[z(`member-constraint`,`helper.source`,`${e.cap}.${e.fieldPath} has no history declaration`)]:[]}function zD(e){return{target:{kind:`new`,type:w.Sensor,role:e.role},helper:e.spec,features:[{kind:`fields`,cap:e.cap,fields:{[e.field]:ID(e.member,`value`,e.empty),lastFetchedAt:lye}},{kind:`fields`,cap:`group-status`,fields:uye(e.member)}]}}function BD(e,t=_s){let n=[...RD(e.source)],r=LD(e.source);r===`enum`&&n.push(z(`kind-mismatch`,`helper.source`,`a statistic reads a number or a boolean, not a state`)),e.stat===`sum`&&r!==`counter`&&n.push(z(`kind-mismatch`,`helper.stat`,`a gauge has no sum — that is the integral template`));let i=Ns(e.window,t);return i.ok||n.push(z(`retention`,`helper.window`,i.reason)),{problems:n,draft:zD({role:E.NumericSensor,cap:`numeric-sensor`,field:`value`,empty:`null`,spec:e,member:e.source})}}function VD(e,t=_s){let n=[...RD(e.source)],r=LD(e.source);(r===`enum`||r===`boolean`)&&n.push(z(`kind-mismatch`,`helper.source`,`a derivative reads a number that moves, not a yes/no or a state`));let i=Ns(e.window,t);return i.ok||n.push(z(`retention`,`helper.window`,i.reason)),{problems:n,draft:zD({role:E.NumericSensor,cap:`numeric-sensor`,field:`value`,empty:`null`,spec:e,member:e.source})}}function HD(e,t=_s){let n=[...RD(e.source)],r=LD(e.source),i=e.source.cap===`power-meter`&&e.source.fieldPath===`power`;(r===`counter`||r===`boolean`||r===`enum`)&&n.push(z(`kind-mismatch`,`helper.source`,`an integral reads an instantaneous gauge, not a counter or a state`)),e.output===`energy`&&!i&&n.push(z(`kind-mismatch`,`helper.output`,`energy is the integral of power-meter.power; another reading uses the meter`)),e.output===`meter`&&i&&n.push(z(`kind-mismatch`,`helper.output`,`power integrates to power-meter.energy, which energy dashboards already read`));let a=Ps(e.reset,t);a.ok||n.push(z(`retention`,`helper.reset`,a.reason));let o=e.output===`energy`;return{problems:n,draft:zD({role:o?E.EnergySensor:E.NumericSensor,cap:o?`power-meter`:`meter`,field:o?`energy`:`value`,empty:`offline`,spec:e,member:e.source})}}var pye=/^\d+(?:\.\d+)?$/,mye=/^-?\d+(?:\.\d+)?$/,hye=/^dwell\(x (>=|<=) (\d+(?:\.\d+)?), (\d+(?:\.\d+)?), (\d+(?:\.\d+)?)(?:, (\d+))?\)$/,gye=/^clamp\((x|number\(x\)) \* (-?\d+(?:\.\d+)?) \+ (-?\d+(?:\.\d+)?), (-?\d+(?:\.\d+)?), (-?\d+(?:\.\d+)?)\)$/,_ye=/^(x|number\(x\)) \* (-?\d+(?:\.\d+)?) \+ (-?\d+(?:\.\d+)?)$/,vye=/^[A-Za-z_][A-Za-z0-9_]*$/;function UD(e){return $D(e,pye)}function WD(e){return $D(e,mye)}function GD(e){return typeof e==`string`?JSON.stringify(e):typeof e==`number`?WD(e):typeof e==`boolean`?e?`true`:`false`:`null`}function KD(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 qD(e){return vye.test(e)}function JD(e,t,n,r,i=1){return`dwell(x ${e===`gte`?`>=`:`<=`} ${t}, ${n}, ${r}${i>1?`, ${i}`:``})`}function YD(e,t,n,r,i){let a=`${e} * ${t} + ${n}`;return r===null||i===null?a:`clamp(${a}, ${r}, ${i})`}function XD(e){let t=hye.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 ZD(e){let t=gye.exec(e);if(t!==null)return eO(t[1],t[2],t[3],t[4],t[5]);let n=_ye.exec(e);return n===null?null:eO(n[1],n[2],n[3],void 0,void 0)}function QD(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 $D(e,t){if(!Number.isFinite(e))return null;let n=Object.is(e,-0)?`0`:String(e);return t.test(n)?n:null}function eO(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 tO={kind:`expression`,expr:`now`,bindings:{}};function nO(e){return{kind:`from`,source:e.source,cap:e.cap,fieldPath:e.fieldPath}}function rO(e,t){return{kind:`expression`,expr:e,bindings:t}}function yye(e,t){return e.source.addonId===t.source.addonId&&e.source.stableId===t.source.stableId&&e.cap===t.cap&&e.fieldPath===t.fieldPath}function iO(e,t,n=[]){return{target:{kind:`new`,type:w.Sensor,role:E.NumericSensor},helper:e,features:[{kind:`fields`,cap:`numeric-sensor`,fields:{value:t,lastFetchedAt:tO}},...n]}}function aO(e,t){return{target:{kind:`new`,type:w.Sensor,role:E.BinarySensor},helper:e,features:[{kind:`fields`,cap:`binary`,fields:{on:t,lastChangedAt:tO}}]}}function oO(e){let t=[],n=WD(e.high),r=WD(e.low);n===null&&t.push(z(`kind-mismatch`,`helper.high`,`the high edge is a finite number`)),r===null&&t.push(z(`kind-mismatch`,`helper.low`,`the low edge is a finite number`)),n!==null&&r!==null&&e.low>e.high&&t.push(z(`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=UD(e.onForMs),a=UD(e.offForMs);(i===null||a===null)&&t.push(z(`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:aO(e,rO(`coalesce(schmitt(x, ${n??`0`}, ${r??`0`}${o}), false)`,{x:nO(e.source)}))}}var bye=[`a`,`b`];function xye(e){let t=[],n=e.op!==`sum`;return n&&e.inputs.length!==2&&t.push(z(`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(z(`member-constraint`,`helper.inputs`,`a sum takes two or more readings`)),e.inputs.forEach((n,r)=>{e.inputs.slice(0,r).some(e=>yye(e,n))&&t.push(z(`member-constraint`,`helper.inputs[${r}]`,`this reading is already an input`))}),t}var Sye=[`included`,`excluded`,`total`];function sO(e){let t=xye(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(Sye.map(e=>[e,r(e)]));return{problems:t,draft:iO(e,r(`value`),[{kind:`fields`,cap:`group-status`,fields:i}])}}let n=Object.fromEntries(e.inputs.slice(0,2).map((e,t)=>[bye[t]??`a`,nO(e)]));return{problems:t,draft:iO(e,rO(e.op===`difference`?`a - b`:`b == 0 ? null : a / b`,n))}}function Cye(e){let t=[],n=new Set;if(e.inputs.forEach((e,r)=>{let i=`helper.inputs[${r}].name`;qD(e.name)||t.push(z(`expression-invalid`,i,`\`${e.name}\` is not a name — use letters, digits and _, starting with a letter`)),n.has(e.name)&&t.push(z(`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,nO(e.member)])),i=Xo({expr:e.expr,bindings:r});return i===null?[]:[z(`expression-invalid`,`helper.expr`,i)]}function cO(e){let t=Cye(e),n=Object.fromEntries(e.inputs.map(e=>[e.name,nO(e.member)])),r=rO(e.expr,n);return{problems:t,draft:e.output===`boolean`?aO(e,r):iO(e,r)}}function wye(e,t){return e.addonId===t.addonId&&e.stableId===t.stableId}function Tye(e,t){return wye(e.source,t.source)&&e.cap===t.cap&&e.fieldPath===t.fieldPath}function Eye(e,t){return e.accept.some(e=>e.cap===t.cap&&e.fieldPath===t.fieldPath)}function Dye(e,t){return t.members.flatMap((n,r)=>{let i=`helper.members[${r}]`,a=[];if(!Eye(e,n)){let t=e.accept.map(e=>`${e.cap}.${e.fieldPath}`).join(` or `);a.push(z(`member-constraint`,i,`a ${e.id} group reads ${t}; this member is ${n.cap}.${n.fieldPath}`))}return t.members.slice(0,r).some(e=>Tye(e,n))&&a.push(z(`member-constraint`,i,`this member is already in the group`)),a})}function lO(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 Oye(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,Aye(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]:lO(e,t,n,`value`),...r}},{kind:`fields`,cap:`group-status`,fields:{included:lO(e,t,n,`included`),excluded:lO(e,t,n,`excluded`),total:lO(e,t,n,`total`)}}]}}function kye(e,t){if(e.family===`actuator`){if(t.active===void 0)return[z(`kind-mismatch`,`helper.active`,`a ${e.id} group needs an active criterion (at-least-one or all)`)];let n=FD(t.active);return t.aggregate===n?[]:[z(`kind-mismatch`,`helper.aggregate`,`active \`${t.active}\` aggregates by \`${n}\`, not \`${t.aggregate}\``)]}return t.active===void 0?[]:[z(`kind-mismatch`,`helper.active`,`a ${e.id} group has no active criterion — that belongs to an actuator group`)]}function uO(e){let t=Mc.safeParse(e);return t.success?{ok:!0,composition:t.data}:{ok:!1,problems:[z(`helper-mismatch`,`helper`,`the template did not compile: ${t.error.issues.map(e=>e.message).join(`; `)}`)]}}function Aye(e,t={}){return{kind:`expression`,expr:e,bindings:t}}function dO(e,t=_s){switch(e.kind){case`group`:return jye(e);case`statistic`:{let n=BD(e,t);return n.problems.length>0?{ok:!1,problems:n.problems}:uO(n.draft)}case`integral`:{let n=HD(e,t);return n.problems.length>0?{ok:!1,problems:n.problems}:uO(n.draft)}case`derivative`:{let n=VD(e,t);return n.problems.length>0?{ok:!1,problems:n.problems}:uO(n.draft)}case`threshold`:return fO(oO(e));case`arithmetic`:return fO(sO(e));case`expression`:return fO(cO(e))}}function fO(e){return e.problems.length>0?{ok:!1,problems:e.problems}:uO(e.draft)}function jye(e){let t=ED(e.templateId);if(t===null)return{ok:!1,problems:[z(`member-constraint`,`helper.templateId`,`unknown template \`${e.templateId}\``)]};let n=kye(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:[z(`kind-mismatch`,`helper.aggregate`,`a ${t.id} group aggregates by ${n}, not \`${e.aggregate}\``)]}}let r=Dye(t,e);return r.length>0?{ok:!1,problems:r}:uO(Oye(t,e))}function pO(e,t){return JSON.stringify(e.target)===JSON.stringify(t.target)&&JSON.stringify(e.features)===JSON.stringify(t.features)}function Mye(e){return e.kind===`group`?ED(e.templateId)?.memberDeviceType??null:null}function Nye(e,t){if(e.kind!==`group`)return[];let n=ED(e.templateId);if(n===null||n.family!==`numeric`)return[];let r=e.members.flatMap((e,n)=>{let r=t.get(Nc(e.source))?.quantity;return r===void 0?[]:[{index:n,quantity:r}]});if(n.quantity!==`device`)return r.flatMap(e=>e.quantity===n.quantity?[]:[z(`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?[]:[z(`mixed-quantity`,`helper.members`,`a numeric group requires one quantity; members report ${i.join(` and `)}`)]}function Pye(e,t){if(e.kind!==`group`)return[];let n=ED(e.templateId);return n===null?[]:e.members.flatMap((e,r)=>{let i=t.get(Nc(e.source)),a=i?.deviceType;return a===void 0||AD(n.memberDeviceTypes,a,i?.role)?[]:[z(`member-constraint`,`helper.members[${r}]`,`a ${n.id} group takes ${n.memberDeviceTypes.join(` or `)} devices; this member is a ${a}`)]})}function mO(e,t){let n=e.helper;if(n===void 0)return[];let r=dO(n);return r.ok?pO(e,r.composition)?n.kind===`arithmetic`?Fye(n,t):n.kind===`group`?[...Nye(n,t),...Pye(n,t)]:[]:[z(`helper-mismatch`,`helper`,`the stored features are not this template — the helper spec is the only writer`)]:r.problems}function Fye(e,t){let n=e.inputs.flatMap(e=>{let n=t.get(Nc(e.source))?.quantity;return n===void 0?[]:[n]}),r=[...new Set(n)];return r.length<=1?[]:[z(`mixed-quantity`,`helper.inputs`,`a ${e.op} needs readings of one quantity; these inputs report ${r.join(` and `)}`)]}var hO=class extends Error{};function Iye(e){return new Set(e.composition.features.flatMap(e=>!Dc(e)||e.kind!==`fields`?[]:Bc(e).map(({fieldPath:t})=>`${e.cap}.${t}`)))}function Lye(e,t,n){if(Nc(n.source)!==Nc(e.target))return!0;let r=`${n.cap}.${n.fieldPath}`;return t.has(r)&&e.replaced?.has(r)!==!0}function Rye(e){let t=Iye(e);return e.composition.features.flatMap(n=>!Dc(n)||n.kind!==`fields`?[]:Bc(n).map(({fieldPath:r,source:i})=>[Fc({source:e.target,cap:n.cap,fieldPath:r}),Rc(i).filter(n=>Lye(e,t,n)).map(Fc)]))}function zye(e,t){let n=Nc(e.target),r=new Map;for(let i of t){if(i.blockId===e.blockId)continue;let t=Nc(i.target);if(t===n)throw new hO(`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 hO(`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 gO(e,t){let n=zye(e,t).flatMap(Rye);return new Map(n)}function Bye(e,t){let n=gO(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 Vye(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 Hye(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 _O(e,t){let n=gO(e,t),r=`${Nc(e.target)}#`;return Vye(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:Hye(t,i,n),component:i}]})}var Uye=3,Wye=120,Gye=10,vO=x([`no-power-source`,`switch-missing`,`switch-offline`,`switch-unknown`,`restart-in-progress`,`switch-call-failed`,`switch-is-actuator`]),yO=i(`accepted`,[b({accepted:o(!0)}),b({accepted:o(!1),reason:vO,message:p()})]),bO=b({linked:v(),switchDeviceId:f().nullable(),switchName:p().nullable(),switchOn:v().nullable(),switchOnline:v().nullable(),restartInProgress:v(),offSeconds:f().int()}),xO=b({switchOn:v().nullable(),offSeconds:f().int(),lastFetchedAt:f()}),SO=[w.Gateway,w.Camera,w.Sensor,w.MediaPlayer,w.Vacuum,w.Generic,w.Washer,w.Dryer,w.Dishwasher,w.PetFountain,w.Fan,w.Humidifier,w.Climate,w.WaterHeater],Kye={version:1,targets:[{id:`switch`,cardinality:`scalar`,vocabulary:{cap:`power-source`,stateField:`switchOn`},deviceTypes:SO,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`}}]},CO=b({deviceId:f().int().nonnegative()}),wO={name:`power-source`,scope:`device`,mode:`singleton`,deviceTypes:SO,methods:{getStatus:Lr(CO,bO,{auth:`protected`}),powerOn:Lr(CO,yO,{kind:`mutation`,auth:`protected`,actions:[{id:`powerSource.on`,label:N(`Power on`,`Dai corrente`),phrase:N(`Power on {device}`,`Dai corrente a {device}`),icon:`power`}]}),powerOff:Lr(CO,yO,{kind:`mutation`,auth:`protected`,actions:[{id:`powerSource.off`,label:N(`Power off`,`Togli corrente`),phrase:N(`Cut the power of {device}`,`Togli la corrente a {device}`),icon:`power-off`}]}),forceRestart:Lr(CO,yO,{kind:`mutation`,auth:`protected`,actions:[{id:`powerSource.forceRestart`,label:N(`Force restart`,`Riavvio forzato`),phrase:N(`Force restart {device} by cutting its power`,`Riavvia {device} togliendo la corrente`),icon:`refresh-cw`}]})},runtimeState:xO,customize:Kye,durability:`session`,history:`none`,vocabulary:{noun:N(`Power source`,`Alimentazione`),order:1050,state:[{kind:`boolean`,field:`switchOn`,label:N(`Power switch on`,`Presa accesa`),whenTrue:N(`When the power of {device} comes on`,`Quando arriva la corrente a {device}`),whenFalse:N(`When the power of {device} is cut`,`Quando manca la corrente a {device}`),icon:`power`}]}};function TO(e){return typeof e!=`number`||!Number.isFinite(e)?10:Math.min(120,Math.max(3,Math.round(e)))}function qye(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 Jye(e,t){if(e===null)return null;let n;if(e.target.kind===`existing`)n=e.target.device;else if(t!==void 0)n=Lc(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=Rc(i).find(e=>e.cap===`switch`);return a===void 0?null:{device:n,switch:a.source,offSeconds:TO(qye(e))}}var EO=`switch`;function Yye(e){let t=new Set;return e.target.kind===`existing`&&t.add(Nc(e.target.device)),e.features.forEach((e,n)=>{if(!(e.kind!==`fields`||e.cap!==EO)&&Dc(e)){for(let n of Vc(e))for(let e of Rc(n))t.add(Nc(e.source));for(let r of lD(e,n))t.add(Nc(r.command.source))}}),t}function DO(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=Yye(e);return Rc(r).filter(e=>e.cap===EO&&i.has(Nc(e.source))).map(e=>({path:`features[${t}].fields.switchOn`,switch:e.source}))}function OO(e){let t=new Map(e.map(e=>[e.name,e]));return e=>t.get(e)??null}var kO=new Set([`device-status`,`feature-probe`]),Xye={addonId:rc,stableId:`${Ce}(unsaved)`},Zye=`(unsaved)`;function Qye(e,t,n){let r=n(e.cap);if(r===null)return z(`unknown-capability`,`${t}.cap`,`no capability is named \`${e.cap}\``);if(kO.has(r.name))return z(`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?z(`not-composable`,`${t}.cap`,`\`${r.name}\` has no per-device state to compose`):{def:r,state:i,fields:$w(i)}}function $ye(e){let t=e.helper;if(t===void 0||t.kind!==`group`)return new Set;let n=ED(t.templateId);return n===null||n.family!==`actuator`?new Set:new Set(n.commandCaps)}function ebe(e,t){return e.name===FE.name&&Object.values(t.commands??{}).some(e=>e.kind===`extension`)}function tbe({def:e,state:t,fields:n},r,i,a,o){let s=[];e.deviceTypes!==void 0&&!e.deviceTypes.includes(a)&&s.push(z(`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=dD(e).filter(e=>!c.has(e)).map(e=>`\`${e}\``);l.length>0&&!o.has(e.name)&&s.push(z(`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=ebe(e,r);for(let a of d?[]:eT(t))a!==u&&(n.has(a)?a in r.fields||s.push(z(`missing-field`,`${i}.fields.${a}`,`\`${e.name}.${a}\` is required and has no source`)):s.push(z(`not-composable`,`${i}.fields`,`\`${e.name}.${a}\` is not a scalar — nested fields arrive in a later slice`)));return s}function nbe({fields:e,state:t},n,r){return n.includes(`.`)?r===`replace`?Qw(t,n)??void 0:`nested`:e.get(n)}function rbe(e,t,n,r){let{def:i}=e,{featureIndex:a,path:o,source:s}=t,c=`features[${a}].fields.${o}`,l=nbe(e,o,n);if(l===`nested`)return RE(z(`nested-field`,c,`\`${o}\` is nested — a nested field is planned only on a declared replace (D1034)`));if(l===void 0)return RE(z(`unknown-field`,c,`\`${i.name}\` has no field \`${o}\``));if(l.kind===`union`)return RE(QE(i.name,o,c));let u=tD(s,r);if(!u.ok)return RE(z(u.code,c,u.message));let d=iD(s),f=aD(l,d,n,i.name,c);if(!f.ok)return RE(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:[...Rc(s)]},h=rD(i.name,l,s,c);return{problems:[...nD(i.name,l,eD(s,l,u.kinds,r),c),...h===null?[]:[h]],fields:[m],features:[],events:[]}}function ibe(e,t,n,r,i){let a=`features[${n}]`,o=lD(t,n),s=Object.entries(t.commands??{}).filter(([,e])=>e.kind===`code`).map(([e])=>z(`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!==FE.name?[...s,...c.map(([t])=>z(`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,z(`reserved-variant`,`${a}.commands`,"commands (`forward`) are served only by a capability a NEW device builds — not on an existing device")]:[...s,..._D(e,t,a),...o.flatMap(t=>gD(e,t,i))]}function AO(e,t,n,r,i){let a=`features[${t}]`,o=Qye(e,a,r);if(`code`in o)return RE(o);let s=n.mode===`replace`?[]:[...tbe(o,e,a,n.deviceType,i)];s.push(...ibe(o.def,e,t,n.mode,r));let c=Object.entries(e.fields).map(([e,i])=>rbe(o,{featureIndex:t,path:e,source:i},n.mode,r)),l=e.items===void 0?[]:[sD(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=aT(o.def,f,d);return{problems:[...s,...u.flatMap(e=>e.problems),...p.problems],fields:d,features:[f],events:p.events}}function jO(e,t){let n=e.nativeCaps.get(t);return n!==void 0&&n!==`composer`}function abe(e){return`code`in e}function obe(e,t){if(e.target.kind===`new`)return{kind:`new`,type:e.target.type};let n=Nc(e.target.device);return t===void 0?z(`target-unreadable`,`target`,`target device \`${n}\` was not read — the save is refused rather than stored unchecked`):t.kind===`absent`?z(`target-missing`,`target`,`target device \`${n}\` does not exist`):t.kind===`unreadable`?z(`target-unreadable`,`target`,`could not read target device \`${n}\` (${t.error}) — the save is refused rather than stored unchecked`):{kind:`existing`,found:t}}var sbe=new Set([`not-composable`,`unknown-capability`,`reserved-variant`]);function cbe(e,t){let n=t.problems.filter(e=>sbe.has(e.code));return n.length>0?{problems:n,fields:[],features:[],events:[]}:RE(e)}var lbe=IE;function ube(e){let t=lbe[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 dbe(e,t,n){let r=t.cap;return e.kind===`new`?{mode:`new`,deviceType:e.type}:jO(e.found,r)?ube(t)?{mode:`replace`,deviceType:e.found.type}:z(`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 MO(e,t,n){let r=obe(e,n);if(`code`in r)return RE(r);let i=$ye(e),a=e.features.map((e,n)=>{let a=`features[${n}]`;if(e.kind===`passthrough`)return RE(z(`reserved-variant`,a,`whole-capability passthrough of \`${e.cap}\` arrives in slice 3`));let o=dbe(r,e,a);if(abe(o))return!Dc(e)||r.kind!==`existing`?{problems:[],fields:[],features:[],events:[]}:cbe(o,AO(e,n,{mode:`add`,deviceType:r.found.type},t,i));let s=AO(e,n,o,t,i);return Dc(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 fbe(e){let t=e.features.flatMap(e=>Dc(e)&&e.kind===`fields`?Vc(e).flatMap(Rc).map(e=>e.source):[]);return[...new Map([...t,...uD(e)].map(e=>[Nc(e),e])).values()]}function pbe(e,t){return e.features.flatMap(e=>Dc(e)&&e.kind===`fields`?Vc(e).flatMap(e=>{if(e.kind!==`from`)return[];let n=t(e.cap),r=n?.runtimeState??n?.status?.schema;return r===void 0?[]:Qw(r,e.fieldPath)?.kind===`union`?[e]:[]}):[])}function mbe(e,t,n){return{ref:e.target.kind===`existing`?e.target.device:t.self??Xye,native:e.target.kind===`existing`&&t.target?.kind===`found`?t.target:null,replaced:NO(n)}}function NO(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(pT))}function hbe(e,t,n,r){let i=`${e.cap}.${e.fieldPath}`;return n.some(e=>pT(e)===i&&!r.replaced.has(i))?[]:r.native===null?[z(`source-field-unknown`,t,`this device has no composed field \`${e.cap}.${e.fieldPath}\``)]:jO(r.native,e.cap)?[]:[z(`source-capability-missing`,t,`the target device (device ${r.native.deviceId}) has no native \`${e.cap}\``)]}function gbe(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?[]:[z(`source-kind-mismatch`,r,`\`${t.cap}.${t.fieldPath}\` of device ${n.deviceId} reads a ${i} now; \`${e.cap}.${e.path}\` takes a ${a}`)]}function _be(e,t,n){let r=Nc(n.ref);return e.flatMap(i=>i.reads.flatMap(a=>{let o=zE(i),s=Nc(a.source);if(s===r)return hbe(a,o,e,n);let c=t.sources.get(s);return c===void 0||c.kind===`unreadable`?[z(`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`?[z(`source-missing`,o,`source \`${s}\` does not exist`)]:c.caps.has(a.cap)?gbe(i,a,c,o):[z(`source-capability-missing`,o,`source \`${s}\` (device ${c.deviceId}) has no \`${a.cap}\``)]}))}function vbe(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 ybe(e,t,n){for(let r of e){let e=vbe(r,t);if(e===null)continue;let i=`${e.cap}.${e.fieldPath}`,a=n.find(e=>pT(e)===i);if(a!==void 0)return zE(a)}return`features`}function bbe(e,t){for(let[n,r]of t)if(e.some(e=>e.startsWith(`${n}#`)))return{key:n,error:r};return null}function xbe(e,t,n,r){let i={blockId:t.blockId??`(unsaved)`,target:r.ref,composition:e,replaced:r.replaced},a=Nc(i.target),o=t.unreadTargets??new Map;try{return _O(i,t.peers).map(e=>{let t=ybe(e.path,a,n),r=bbe([...e.component],o);return r===null?z(`cycle`,t,`a field reads itself: ${e.path.join(` → `)}`):z(`cycle`,t,`possible cycle through \`${r.key}\` — its state could not be read (${r.error}): ${e.path.join(` → `)}`)})}catch(e){if(e instanceof hO)return[z(`duplicate-target`,`features`,e.message)];throw e}}function PO(e,t){let n=MO(e,t.lookupCap,t.target??void 0),r=mbe(e,t,n),i=n.problems.filter(e=>e.code===`native-capability-replace`).map(e=>e.path),a=xbe(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,..._be(n.fields,t,r),...vD(e,t.sources),...a,...mO(e,o),...DO(e).map(e=>z(`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 FO=b({path:p(),kind:cT,nullable:v(),required:v(),enumValues:S(p()).optional()}),IO=b({cap:p(),fields:S(FO),itemArray:b({path:p(),keyField:p()}).optional()}),LO=b({caps:S(IO)});function RO(e,t){if(kO.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=$w(n),a=e.status?.itemArray?.path??null;return eT(n).some(e=>e!==a&&!i.has(e))&&r.push(`not-composable`),aT(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 Sbe(e,t){return e.filter(e=>RO(e,t).length===0).map(e=>{let t=e.runtimeState,n=t===void 0?[]:[...$w(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 zO=b({addonId:p().min(1),stableId:p().min(1),cap:p().min(1),fieldPath:p().min(1)}),Cbe=b({kind:o(`identity`)}),wbe=b({kind:o(`invert`)}),BO=b({kind:o(`threshold`),comparison:x([`gte`,`lte`]),threshold:f(),startDwellMs:f().nonnegative(),stopDwellMs:f().nonnegative(),minSamples:f().int().min(1).optional()}),VO=i(`kind`,[Cbe,wbe,BO,b({kind:o(`linear`),scale:f(),offset:f(),clampMin:f().optional(),clampMax:f().optional()}),b({kind:o(`enum-map`),mapping:u(p(),p().nullable())}),b({kind:o(`number`)})]),Tbe=b({kind:o(`scalar`),cap:p().min(1),targetId:p().min(1),source:zO,transform:VO}),Ebe=b({kind:o(`keyedArray`),cap:p().min(1),targetId:p().min(1),key:p().min(1),label:p().min(1),fieldPath:p().min(1),source:zO,transform:VO}),Dbe=b({kind:o(`pulse`),cap:p().min(1),targetId:p().min(1),enabled:v(),debounceMs:f().nonnegative(),edges:S(x([`rising`,`button`,`native-event`])).min(1).optional(),sources:S(zO).min(1)}),Obe=zO.extend({mode:x([`in-addition`,`confirm`,`replace`]).optional()}),kbe=i(`kind`,[Tbe,Ebe,Dbe,b({kind:o(`span`),cap:p().min(1),targetId:p().min(1),timeoutMs:f().nonnegative(),cooldownMs:f().nonnegative().optional(),sources:S(Obe)})]),Abe=b({targetId:p().min(1),configured:v(),source:x([`native`,`assigned`]),state:x([`active`,`stale`,`released`,`unavailable`]),reason:p().nullable()}),HO=x([`raw`,`5m`]),UO=x([`high`,`medium`,`low`]),WO=x([`no-history`,`span-too-short`,`truncated`,`no-idle-floor`,`no-runs`,`no-separation`]),GO=b({intervals:f().int().nonnegative(),extra:f().int().nonnegative(),missed:f().int().nonnegative()}),KO=b({tier:HO,spanMs:f().nonnegative(),from:f(),to:f(),points:f().int().nonnegative(),runsFound:f().int().nonnegative(),pausesFound:f().int().nonnegative(),longestPauseMs:f().nonnegative(),pulsesFound:f().int().nonnegative(),longestPulseMs:f().nonnegative(),idleFloorW:f(),noiseCeilingW:f(),plateauW:f(),replay:GO}),qO=b({spanMs:f().nonnegative(),points:f().int().nonnegative(),runsFound:f().int().nonnegative()}),JO=i(`state`,[b({state:o(`proposal`),transform:BO,evidence:KO,confidence:UO,notes:S(p())}),b({state:o(`insufficient`),reason:WO,evidence:qO,fallback:BO})]),YO=b({apply:v()}),XO=b({apply:v(),rows:f().int(),raw:f().int(),markers:f().int(),migrated:f().int(),failed:f().int(),remainingRaw:f().int(),unresolvedMarkers:f().int(),redundantCopies:f().int().optional(),verified:v()}),ZO=`core-block-`,QO=`core-blocks`;function jbe(e){return`${ZO}${e}`}function Mbe(e){if(!e.startsWith(`core-block-`))return null;let t=e.slice(11);return t.length>0?t:null}var $O=c([o(`hub`),p().min(1)]),ek=x([`stopped`,`starting`,`running`,`degraded`,`incomplete`,`failed`]),tk=`main.ts`,nk=u(p().min(1).max(260),p().max(2e5)),rk=ge(),ik=b({name:p().min(1).max(120),code:p().max(2e5).optional(),files:nk.optional(),entry:p().min(1).max(260).optional(),enabled:v(),placement:$O,integrationId:p().optional(),settingsSchema:rk.optional(),tags:oh.optional()}),ak=ik.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 ok(e){return e!==void 0&&e.length>0?e:tk}function Nbe(e){let t=ok(e.entry);return e.files===void 0?{files:{[t]:e.code},entry:t}:{files:{...e.files},entry:t}}function Pbe(e){if(e.files!==void 0){let t=ok(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 sk=i(`kind`,[b({kind:o(`code`)}),b({kind:o(`recipe`),recipe:sv}),b({kind:o(`composition`),composition:Mc})]),ck=b({name:p().min(1).max(120).optional(),enabled:v(),composition:Mc}),lk=b({name:p().min(1).max(120),code:p().max(2e5),files:nk.optional(),entry:p().min(1).max(260).optional(),enabled:v(),placement:$O,integrationId:p().optional(),settingsSchema:rk.optional(),tags:oh.optional(),id:p(),createdAt:f(),updatedAt:f(),createdBy:p(),status:ek,lastError:p().optional(),lastChangedAt:f(),source:sk.optional()});function Fbe(e){return e.source?.kind??`code`}function Ibe(e){return e.source?.kind===`composition`?e.source.composition:null}var uk=i(`kind`,[b({kind:o(`answered`),state:bT.nullable()}),b({kind:o(`unreachable`),error:p()})]),dk=b({block:lk,state:uk}),fk=b({state:o(`not-loaded`),reason:p()}),pk=i(`state`,[b({state:o(`loaded`),views:S(dk)}),fk]),mk=i(`state`,[b({state:o(`loaded`),view:dk.nullable()}),fk]),hk=i(`state`,[b({state:o(`loaded`),view:dk.nullable()}),fk]),gk=b({ok:v(),error:p().optional(),line:f().optional(),column:f().optional()}),_k=b({code:p().optional(),files:nk.optional(),entry:p().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`]})}),vk={name:`core-blocks`,scope:`system`,mode:`singleton`,methods:{list:O(b({}),b({blocks:S(lk)}),{auth:`admin`}),get:O(b({blockId:p()}),b({block:lk.nullable()}),{auth:`admin`}),create:O(b({block:ak}),b({block:lk}),{kind:`mutation`,auth:`admin`,caller:`required`}),update:O(b({blockId:p(),block:ik.partial()}),b({block:lk}),{kind:`mutation`,auth:`admin`,caller:`required`}),delete:O(b({blockId:p()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),setEnabled:O(b({blockId:p(),enabled:v()}),b({block:lk}),{kind:`mutation`,auth:`admin`}),restart:O(b({blockId:p()}),b({block:lk}),{kind:`mutation`,auth:`admin`}),compile:O(_k,gk,{kind:`mutation`,auth:`admin`}),getBlockSettings:O(b({blockId:p()}),bx.nullable(),{auth:`admin`}),updateBlockSettings:O(b({blockId:p(),patch:xx}),Cx,{kind:`mutation`,auth:`admin`}),migrateRawSecrets:O(YO,XO,{kind:`mutation`,auth:`admin`}),getTypeDefs:O(b({}),b({libs:S(b({filePath:p(),content:p()}))}),{auth:`admin`}),createComposition:O(b({block:ck}),b({block:lk}),{kind:`mutation`,auth:`admin`,caller:`required`}),updateComposition:O(b({blockId:p(),expectedUpdatedAt:f(),block:ck.partial()}),b({block:lk}),{kind:`mutation`,auth:`admin`,caller:`required`}),getComposition:O(b({blockId:p()}),mk,{auth:`admin`}),listCompositions:O(b({}),pk,{auth:`admin`}),getCustomization:O(b({addonId:p().min(1),stableId:p().min(1)}),hk,{auth:`admin`}),listComposableCaps:O(b({deviceType:x(w)}),LO,{auth:`admin`}),validateComposition:O(b({composition:Mc,blockId:p().optional()}),gT,{kind:`mutation`,auth:`admin`,access:`view`}),proposeRunningThreshold:O(b({deviceId:f().int(),cap:p().min(1),fieldPath:p().min(1),deviceType:x(w).optional()}),JO,{auth:`admin`,access:`view`}),reportAutomationRun:O(b({blockId:p().min(1),trace:Gv.optional(),runStartedAt:f().optional(),keepTraces:f().int().min(1).max(100).optional()}),_(),{kind:`mutation`,auth:`admin`}),getAutomationRunState:O(b({blockId:p().min(1)}),Kv,{auth:`admin`}),getTraces:O(b({blockId:p().min(1)}),b({traces:S(Gv),lastError:p().nullable()}),{auth:`admin`})},vocabulary:{notOperatorFacing:A.INTERNAL}},yk=x([`open`,`opening`,`closing`,`closed`,`stopped`]),bk=b({state:yk,position:f().min(0).max(100).nullable().meta(j(`percentage`)),tiltPosition:f().min(0).max(100).nullable().meta(j(`percentage`)),lastChangedAt:f()}),xk={name:`cover`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Cover],methods:{open:O(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.open`,label:N(`Open`,`Apri`),phrase:N(`Open {device}`,`Apri {device}`),icon:`arrow-up-to-line`,effect:{field:`state`,value:`open`}}]}),close:O(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.close`,label:N(`Close`,`Chiudi`),phrase:N(`Close {device}`,`Chiudi {device}`),icon:`arrow-down-to-line`,effect:{field:`state`,value:`closed`}}]}),stop:k(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.stop`,label:N(`Stop`,`Ferma`),phrase:N(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),setPosition:k(b({deviceId:f().int().nonnegative(),position:f().min(0).max(100)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.position`,label:N(`Set position`,`Imposta la posizione`),phrase:N(`Move {device} to {position} open`,`Porta {device} al {position} di apertura`),icon:`blinds`,effect:{field:`position`,fromArg:`position`},openArgs:[{key:`position`,label:N(`Position`,`Posizione`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setTiltPosition:k(b({deviceId:f().int().nonnegative(),tiltPosition:f().min(0).max(100)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.tilt`,label:N(`Set tilt`,`Imposta l’inclinazione`),phrase:N(`Tilt {device} to {tiltPosition}`,`Inclina {device} al {tiltPosition}`),icon:`blinds`,effect:{field:`tiltPosition`,fromArg:`tiltPosition`},openArgs:[{key:`tiltPosition`,label:N(`Tilt`,`Inclinazione`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]})},status:{schema:bk,kind:`push`},runtimeState:bk,durability:`restored`,history:{fields:{position:{kind:`gauge`,unit:`%`,minIntervalMs:0}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:N(`Cover`,`Copertura`),order:1030,state:[{kind:`enum`,field:`state`,label:N(`State`,`Stato`),values:[{value:`open`,label:N(`Open`,`Aperto`),phrase:N(`When {device} is fully open`,`Quando {device} è tutto aperto`)},{value:`opening`,label:N(`Opening`,`In apertura`),phrase:N(`When {device} starts opening`,`Quando {device} inizia ad aprirsi`)},{value:`closing`,label:N(`Closing`,`In chiusura`),phrase:N(`When {device} starts closing`,`Quando {device} inizia a chiudersi`)},{value:`closed`,label:N(`Closed`,`Chiuso`),phrase:N(`When {device} is fully closed`,`Quando {device} è tutto chiuso`)},{value:`stopped`,label:N(`Stopped`,`Fermo`),phrase:N(`When {device} stops part-way`,`Quando {device} si ferma a metà`)}],icon:`blinds`},{kind:`numeric`,field:`position`,quantity:N(`the opening`,`l’apertura`),label:N(`Position`,`Posizione`),unit:`%`,icon:`blinds`}],overrides:{byRole:{[E.CoverGarage]:{actions:{"cover.open":{phrase:N(`Open the garage door {device}`,`Apri il garage {device}`),icon:`warehouse`},"cover.close":{phrase:N(`Close the garage door {device}`,`Chiudi il garage {device}`),icon:`warehouse`}}},[E.CoverGate]:{actions:{"cover.open":{phrase:N(`Open the gate {device}`,`Apri il cancello {device}`),icon:`fence`},"cover.close":{phrase:N(`Close the gate {device}`,`Chiudi il cancello {device}`),icon:`fence`}}},[E.CoverDoor]:{actions:{"cover.open":{phrase:N(`Open the door {device}`,`Apri la porta {device}`),icon:`door-open`},"cover.close":{phrase:N(`Close the door {device}`,`Chiudi la porta {device}`),icon:`door-closed`}}},[E.CoverWindow]:{actions:{"cover.open":{phrase:N(`Open the window {device}`,`Apri la finestra {device}`),icon:`app-window`},"cover.close":{phrase:N(`Close the window {device}`,`Chiudi la finestra {device}`),icon:`app-window`}}},[E.CoverShutter]:{actions:{"cover.open":{phrase:N(`Raise the shutter {device}`,`Alza la tapparella {device}`)},"cover.close":{phrase:N(`Lower the shutter {device}`,`Abbassa la tapparella {device}`)}}},[E.CoverAwning]:{actions:{"cover.open":{phrase:N(`Extend the awning {device}`,`Apri la tenda da sole {device}`)},"cover.close":{phrase:N(`Retract the awning {device}`,`Chiudi la tenda da sole {device}`)}}}}}}},Sk=b({stepId:p(),entry:Nh}),Ck=b({path:p().min(1),bytes:f().int().nonnegative(),sha256:p().regex(/^[0-9a-f]{64}$/)}),wk=b({addonId:p(),stepId:p().min(1),entries:S(Nh).min(1).max(4),bundle:b({ticket:ii,bytes:f().int().positive(),sha256:p().regex(/^[0-9a-f]{64}$/)}),files:S(Ck).min(1).max(64),distribute:v()}),Tk=i(`kind`,[b({kind:o(`imported`),modelIds:S(p()).readonly(),distributed:S(b({modelId:p(),nodeId:p(),format:x(ba),ok:v(),error:p().optional()})).readonly()}),b({kind:o(`refused`),reason:x([`transfer-failed`,`checksum-mismatch`,`bundle-mismatch`,`invalid-entry`,`id-taken`]),detail:p()})]),Ek={name:`custom-model-registry`,scope:`system`,mode:`collection`,internal:!0,methods:{listModels:O(_(),S(Sk).readonly(),{auth:`admin`}),importModelBundle:O(wk,Tk,{kind:`mutation`,auth:`admin`,timeoutMs:30*6e4})},vocabulary:{notOperatorFacing:A.ML}},Dk=b({engineId:p(),kind:x([`relational`,`vector`]),displayName:p()}),Ok={name:`data-store-provider`,scope:`system`,mode:`collection`,internal:!0,methods:{getEngineInfo:O(_(),Dk,{auth:`admin`}),get:O(b({namespace:p().optional(),collection:p(),key:p()}),l(),{auth:`admin`}),set:O(b({namespace:p().optional(),collection:p(),key:p(),value:l()}),_(),{kind:`mutation`,auth:`admin`}),query:O(b({namespace:p().optional(),collection:p(),filter:md.optional(),columns:S(p()).readonly().optional()}),S(vd).readonly(),{auth:`admin`}),insert:O(b({namespace:p().optional(),collection:p(),record:b({id:p().optional(),data:u(p(),l())})}),b({id:c([p(),f()])}),{kind:`mutation`,auth:`admin`}),upsert:O(b({namespace:p().optional(),collection:p(),conflict:S(p()).readonly(),record:yd}),b({id:c([p(),f()])}),{kind:`mutation`,auth:`admin`}),upsertMany:O(b({namespace:p().optional(),collection:p(),conflict:S(p()).readonly(),records:S(yd).readonly()}),b({upserted:f().int()}),{kind:`mutation`,auth:`admin`}),insertMany:O(b({namespace:p().optional(),collection:p(),records:S(yd).readonly()}),b({inserted:f().int()}),{kind:`mutation`,auth:`admin`}),transact:O(b({namespace:p().optional(),guard:Sd.optional(),ops:S(xd).readonly()}),b({applied:v(),current:l().optional()}),{kind:`mutation`,auth:`admin`}),update:O(b({namespace:p().optional(),collection:p(),id:p(),data:u(p(),l())}),_(),{kind:`mutation`,auth:`admin`}),delete:O(b({namespace:p().optional(),collection:p(),key:p()}),_(),{kind:`mutation`,auth:`admin`}),deleteWhere:O(b({namespace:p().optional(),collection:p(),filter:hd}),b({deleted:f().int()}),{kind:`mutation`,auth:`admin`}),updateWhere:O(b({namespace:p().optional(),collection:p(),filter:hd,data:u(p(),l())}),b({updated:f().int()}),{kind:`mutation`,auth:`admin`}),count:O(b({namespace:p().optional(),collection:p(),filter:md.optional()}),f(),{auth:`admin`}),aggregate:O(b({namespace:p().optional(),collection:p(),fields:S(gd).readonly(),filter:md.optional()}),_d,{auth:`admin`}),histogram:O(b({namespace:p().optional(),collection:p(),field:p(),bucketSize:f().int().positive(),origin:f().int(),filter:md.optional()}),S(b({bucket:f().int(),count:f().int()})).readonly(),{auth:`admin`}),isEmpty:O(b({namespace:p().optional(),collection:p()}),v(),{auth:`admin`}),declareCollection:O(Td,_(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:A.INTERNAL}},kk=x([`auto`,`day`,`night`,`schedule`]),Ak=b({min:f(),max:f(),step:f()}),jk=b({mode:kk,sensitivity:f().optional().meta(j(`none`)),switchDelaySec:f().optional().meta(j(`duration`)),lastFetchedAt:f()}),Mk=b({modes:S(kk),supportsSensitivity:v(),sensitivity:Ak.optional(),supportsSwitchDelay:v(),switchDelaySec:Ak.optional()}),Nk=b({mode:kk.optional(),sensitivity:f().optional(),switchDelaySec:f().optional()}),Pk={name:`day-night`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Camera],deviceConfig:{ui:{kind:`derived-form`,builderId:`day-night`,tab:`image`}},methods:{getOptions:O(b({deviceId:f()}),Mk),setSettings:O(b({deviceId:f(),settings:Nk}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`dayNight.auto`,label:N(`Day/night auto`,`Giorno/notte automatico`),phrase:N(`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:N(`Day mode`,`Modalità giorno`),phrase:N(`Force {device} into day mode`,`Forza {device} in modalità giorno`),icon:`sun`,args:{settings:{mode:`day`}}},{id:`dayNight.night`,label:N(`Night mode`,`Modalità notte`),phrase:N(`Force {device} into night mode`,`Forza {device} in modalità notte`),icon:`moon`,args:{settings:{mode:`night`}}}]})},status:{schema:jk,kind:`poll`},runtimeState:jk,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:N(`Day/night`,`Giorno/notte`),order:3070,state:[{kind:`enum`,field:`mode`,label:N(`Day/night mode`,`Modalità giorno/notte`),values:[{value:`auto`,label:N(`Automatic`,`Automatica`)},{value:`day`,label:N(`Day`,`Giorno`),phrase:N(`When {device} switches to day mode`,`Quando {device} passa in modalità giorno`)},{value:`night`,label:N(`Night`,`Notte`),phrase:N(`When {device} switches to night mode`,`Quando {device} passa in modalità notte`)},{value:`schedule`,label:N(`Scheduled`,`Programmata`)}],icon:`sun-moon`}]}},Lbe=[{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)`}],Rbe={hwaccel:`auto`,probedBestHwaccel:``},Fk={name:`decoder`,scope:`system`,mode:`singleton`,preferredProvider:`decoder-nodeav`,methods:{getInfo:O(_(),b({id:p(),name:p(),hwaccel:p().optional(),probedBestHwaccel:p().optional()})),reprobeHwaccel:O(_(),b({backend:p()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:A.PIPELINE}},Ik={name:`detection-pipeline`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[w.Camera],exposesDeviceSettings:!0,methods:{},vocabulary:{noun:N(`Detection pipeline`,`Pipeline di rilevamento`),order:3080}},Lk=x([`device`,`integration`]),Rk=b({url:p(),label:p(),target:Lk,host:p()}),zk={name:`device-admin-link`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{getAdminLink:O(b({deviceId:f().int().nonnegative()}),Rk.nullable(),{auth:`admin`})},vocabulary:{noun:N(`Admin link`,`Link di amministrazione`),order:3090}},Bk=x([`online`,`sleeping`,`offline`,`unknown`]),Vk=g(()=>b({childNativeId:p(),name:p(),type:x(w),status:Bk,metadata:b({model:p().optional(),serialNumber:p().optional(),uid:p().optional(),rtspChannel:f().int().nonnegative().optional(),isBattery:v().optional(),isDoorbell:v().optional(),isMultifocal:v().optional(),externalLocation:p().optional(),manufacturer:p().optional(),integration:p().optional()}).default({}),alreadyAdopted:v(),adoptedDeviceId:f().int().nonnegative().nullable(),capabilities:S(p()).readonly().optional(),features:S(p()).readonly().optional(),sourceInfo:Eg.optional(),children:S(Vk).readonly().optional(),parentStableId:p().optional()})),Hk=b({id:p(),label:p(),isDefault:v().optional()}),Uk=b({search:p().optional(),area:p().optional(),manufacturer:p().optional(),adoptedOnly:v().optional(),unadoptedOnly:v().optional()}),Wk=b({integrationId:p(),page:f().int().positive().default(1),pageSize:f().int().positive().max(2e4).default(50),filter:p().optional(),filterText:Uk.optional()}),Gk=b({candidates:S(Vk).readonly(),totalCount:f().int().nonnegative(),page:f().int().positive(),pageSize:f().int().positive()}),Kk=b({integrationId:p(),childNativeId:p()}),qk=b({lastDiscoveryAt:f().int().nonnegative().nullable(),candidateCount:f().int().nonnegative(),adoptedCount:f().int().nonnegative(),lastError:p().nullable()}),zbe=b({name:p().min(1).optional(),hiddenChildIds:S(p()).optional()}),Jk=b({integrationId:p(),childNativeIds:S(p()).min(1),filter:p().optional(),importLocations:v().optional(),perCandidate:u(p(),zbe).optional()}),Yk=b({adopted:S(b({childNativeId:p(),parentDeviceId:f().int().nonnegative(),accessoryDeviceIds:S(f().int().nonnegative()).readonly()})).readonly()}),Xk=b({integrationId:p(),camDeviceId:f().int().nonnegative()}),Zk=b({camDeviceId:f().int().nonnegative(),resetToSource:v().optional()}),Qk=b({changed:v(),rebuiltChildren:f().int().nonnegative(),removedChildren:f().int().nonnegative().optional()}),$k={name:`device-adoption`,scope:`system`,mode:`collection`,status:{schema:qk,kind:`poll`},methods:{listCandidateFilters:O(b({integrationId:p()}),b({filters:S(Hk)}),{auth:`admin`}),listCandidates:O(Wk,Gk,{auth:`admin`}),getCandidate:O(Kk,Vk.nullable(),{auth:`admin`}),refresh:O(b({integrationId:p()}),qk,{kind:`mutation`,auth:`admin`}),adopt:O(Jk,Yk,{kind:`mutation`,auth:`admin`}),release:O(Xk,_(),{kind:`mutation`,auth:`admin`}),resync:O(Zk,Qk,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`device adoption — an onboarding flow, not an action`}},eA=i(`state`,[b({state:o(`absent`)}),b({state:o(`ready`),subject:p(),fingerprintSha256:p(),validTo:p()}),b({state:o(`unavailable`),reason:p()})]),tA=b({selfEnrollment:x([`allowed`,`disabled`])}),nA={name:`device-credentials`,scope:`system`,mode:`singleton`,methods:{listDeviceCredentials:O(b({userId:p().min(1).optional(),includeRevoked:v().default(!1)}),S(mfe).readonly(),{auth:`admin`}),startEnrollment:O(b({userId:p().min(1),deviceName:p().min(1).max(80)}),hfe,{kind:`mutation`,auth:`admin`,caller:`required`}),revokeDeviceCredential:O(b({id:p().min(1)}),b({revoked:v(),sessionsEnded:f().int(),status:eg}),{kind:`mutation`,auth:`admin`,caller:`required`}),getDeviceCertificateSettings:O(b({}),tA,{auth:`admin`}),setDeviceCertificateSettings:O(tA,tA,{kind:`mutation`,auth:`admin`}),deleteDeviceCredential:O(b({id:p().min(1)}),b({result:x([`deleted`,`live`,`unknown`])}),{kind:`mutation`,auth:`admin`,caller:`required`}),getDeviceCaStatus:O(b({}),eA,{auth:`admin`}),renameDeviceCredential:O(b({id:p().min(1),deviceName:p().min(1).max(80)}),b({renamed:v()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:A.IDENTITY}},Bbe=64,rA=/^[a-z][a-z0-9_]*$/,Vbe=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(`.`)),iA=p().max(64).regex(rA);function aA(e){return Vbe.has(e)}function oA(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 Hbe(e,t){let n=oA(e);if(!aA(n)&&!t(n))return n;for(let e=2;;e+=1){let r=`${n}_${e}`;if(!t(r))return r}}function Ube(e,t){return e.length===0?{ok:!1,reason:`empty`}:e.length>64?{ok:!1,reason:`too-long`}:rA.test(e)?aA(e)?{ok:!1,reason:`reserved`}:t(e)?{ok:!1,reason:`taken`}:{ok:!0,alias:e}:{ok:!1,reason:`grammar`}}var sA=4096,Wbe=50,Gbe=4096,Kbe=`—`,cA=p().min(1).max(sA),qbe=`now`,Jbe=`camera`,lA=c([p(),f(),v()]),uA=b({deviceId:f().int(),values:u(p().min(1).max(64),lA).optional()}),Ybe=`values`,Xbe=pl(),dA=[`too-long`,`syntax`,`forbidden-syntax`,`forbidden-member`,`unknown-filter`,`ambiguous-field`,`busy`,`budget-exceeded`,`timeout`,`output-too-large`,`render-failed`,`out-of-scope`,`unavailable`],fA=b({reason:x(dA),message:p()}),pA=[`unknown-alias`,`unknown-field`,`no-field`,`unavailable`],mA=b({ref:p(),reason:x(pA)}),hA=i(`ok`,[b({ok:o(!0),text:p(),trace:S(mA)}),b({ok:o(!1),refusal:fA,trace:S(mA)})]);function gA(e){return e.replace(/-/g,`_`)}function _A(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function vA(e,t){let n=e;for(let e of t)if(Array.isArray(n)&&typeof e==`number`)n=n[e];else if(_A(n)&&Object.hasOwn(n,String(e)))n=n[String(e)];else return;return n}function Zbe(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||gA(e)===n);if(i!==void 0){let n=t.slice(1);if(n.length===0)return{kind:`missing`,reason:`no-field`};let r=vA(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 _A(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=vA(e.slices[o],t);return s===void 0?{kind:`missing`,reason:`unknown-field`}:{kind:`value`,cap:o,fieldPath:t,value:s}}var yA=b({zoneKey:p(),label:p(),icon:$m.nullable(),locationKeys:S(p())});function Qbe(e){return e.trim().toLowerCase()}var $be=50,exe=200,bA=b({caps:S(p()).readonly().optional(),actions:S(p()).readonly().optional(),mode:x([`any`,`all`]).optional()}),xA=b({locations:S(p()).readonly().optional(),integrationIds:S(p()).readonly().optional(),types:S(p()).readonly().optional()}),SA=b({text:p().optional(),requires:bA.optional(),filters:xA.optional(),includeIncompatible:v().optional(),contextDeviceId:f().optional(),ids:S(f()).readonly().optional(),cursor:p().nullable().optional(),limit:f().int().min(1).max(200).optional()}),CA=b({cap:p(),path:p(),label:p(),reading:p().nullable(),unit:p().nullable().optional(),quantity:Hi.optional()}),wA=b({id:f(),name:p(),type:x(w),location:p().nullable(),integrationId:p().nullable(),integrationLabel:p().nullable(),online:v().nullable(),disabled:v(),compatible:v(),values:S(CA).readonly()}),TA=b({value:p(),count:f()}),EA=b({id:p(),label:p(),count:f()}),DA=b({locations:S(TA).readonly(),integrations:S(EA).readonly(),types:S(TA).readonly()}),OA=b({items:S(wA).readonly(),nextCursor:p().nullable(),total:f(),compatibleTotal:f(),fleetTotal:f(),hiddenIncompatible:f(),facets:DA,suggested:S(wA).readonly(),missingIds:S(f()).readonly()}),kA=b({connected:v(),deviceCount:f(),error:p().optional(),motionSliceWriter:o(`orchestrator`).optional()}),txe=b({externalId:p(),name:p(),type:p(),metadata:u(p(),l()).optional()}),AA=i(`kind`,[b({kind:o(`mdns`),serviceType:p().min(1),instancePattern:p().optional()}),b({kind:o(`ws-discovery`),types:S(p()).optional()}),b({kind:o(`ssdp`),searchTarget:p().min(1)}),b({kind:o(`udp-broadcast`),port:f().int().min(1).max(65535),payloadHex:p().regex(/^([0-9a-fA-F]{2})*$/),listenPort:f().int().min(1).max(65535).optional()}),b({kind:o(`http-probe`),port:f().int().min(1).max(65535),path:p().startsWith(`/`),method:x([`GET`,`POST`]).default(`GET`),bodyText:p().optional(),contentType:p().optional(),tls:v().default(!1),acceptStatus:S(f().int()).optional()}),b({kind:o(`custom`),reason:p().min(1)})]),jA=b({modeIndex:f().int().min(0),host:p(),port:f().int(),http:b({status:f().int(),headers:u(p(),p()),bodyText:p()}).optional(),mdns:b({instance:p(),host:p(),port:f().int(),txt:u(p(),p())}).optional(),udp:b({payloadHex:p()}).optional(),wsd:b({xaddrs:S(p()),types:S(p()),scopes:S(p())}).optional()}),MA=b({stableId:p(),type:x(w),suggestedName:p(),prefilledConfig:u(p(),l()),sourceInfo:Eg.optional(),alreadyOnboarded:v().optional(),onboardedDeviceId:f().optional(),onboardedName:p().optional(),setupIntegration:v().optional(),parentStableId:p().optional(),selectable:v().optional(),needsParams:S(p()).optional()}),NA=b({id:f(),stableId:p(),addonId:p(),type:p(),name:p(),parentDeviceId:f().nullable(),online:v(),features:S(p()),config:u(p(),l()),sourceInfo:Eg.optional()}),PA=b({status:x([`ok`,`error`]),labels:S(p()).optional(),error:p().optional()}),FA=l(),IA={name:`device-provider`,scope:`system`,mode:`collection`,methods:{start:O(_(),_(),{kind:`mutation`}),stop:O(_(),_(),{kind:`mutation`}),getStatus:O(_(),kA),getDevices:O(_(),S(b({id:p(),name:p(),type:p()}))),reloadDevice:O(b({stableId:p()}),b({deviceId:f()}),{kind:`mutation`,timeoutMs:3*6e4}),supportsDiscovery:O(b({}),v()),discoverDevices:O(b({params:u(p(),l()).optional()}),S(MA),{kind:`mutation`,auth:`admin`}),getDiscoveryModes:O(b({}),S(AA)),classifyDiscoveryHits:O(b({hits:S(jA),params:u(p(),l()).optional()}),S(MA),{kind:`mutation`,auth:`admin`}),getDiscoveryParamsSchema:O(b({}),FA),getManualCreationType:O(b({integrationId:p().optional()}),b({deviceType:x(w).nullable()})),adoptDiscoveredDevice:O(b({candidate:MA,integrationId:p().optional()}),NA,{kind:`mutation`,auth:`admin`}),supportsManualCreation:O(b({}),v()),getChildCreationSchema:O(b({type:x(w),integrationId:p().optional()}),FA),createDevice:O(b({type:x(w),config:u(p(),l()),integrationId:p().optional()}),NA,{kind:`mutation`,auth:`admin`}),testCreationField:O(b({type:x(w),key:p(),value:l(),formValues:u(p(),l()).optional()}),PA,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:A.INTERNAL}},LA=i(`kind`,[b({kind:o(`mdns`),serviceType:p(),instance:p(),host:p(),address:p().nullable(),port:f().int(),txt:u(p(),p())}),b({kind:o(`ssdp`),host:p(),port:f().int(),target:p(),headers:u(p(),p())})]),nxe=b({addonId:p(),candidate:MA,firstSeenAt:f(),lastSeenAt:f(),dismissed:v()}),RA=b({id:p(),addonId:p(),candidate:MA,firstSeenAt:f(),lastSeenAt:f(),dismissed:v()}),zA=b({childKey:p(),section:p(),order:f().optional(),collapsed:v().optional()}),rxe=b({unit:p().min(1).optional(),precision:f().int().min(0).max(10).optional()}),BA=b({icon:p().min(1).optional(),label:p().min(1).optional(),unit:p().min(1).optional(),precision:f().int().min(0).max(10).optional(),hidden:v().optional(),perCap:u(p(),rxe).optional()}),VA=b({unit:p().min(1).optional(),precision:f().int().min(0).max(10).optional(),icon:p().min(1).optional()}),HA=b({id:f(),stableId:p(),addonId:p(),type:x(w),name:p(),alias:iA.optional(),location:p().nullable(),tags:oh.optional(),disabled:v(),parentDeviceId:f().nullable(),role:p().nullable().optional(),online:v(),probed:v().optional(),features:S(p()),isCamera:v(),config:u(p(),l()),secretConfigPaths:S(p()).optional(),metadata:u(p(),l()).nullable().optional(),sourceInfo:Eg.optional(),integrationId:p().optional(),linkDeviceId:f().nullable().optional(),primaryChildEntityId:p().nullable().optional(),childLayout:S(zA).readonly().optional(),primaryChildPreference:S(p()).readonly().optional(),display:BA.optional()}),UA=b({key:p(),value:l(),description:p().optional()}),WA=x([`manual`]),GA=b({deviceId:f(),name:p(),location:p().nullable(),features:S(p()),producesTrackedEvents:v().optional()}),KA=b({deviceIds:S(f().int().positive()),trackedDeviceIds:S(f().int().positive()).optional()}),qA={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:[w.Camera],sourceCaps:`any`,cardinality:`many`,value:KA},ixe=b({deviceId:f(),mode:WA,devices:S(GA)}),JA=b({deviceId:f(),entries:S(b({capName:p(),kind:x([`native`,`wrapped`]),providerAddonId:p(),providerNodeId:p(),nativeAddonId:p(),implementedMethods:S(p()).optional()}))}),YA=i(`kind`,[b({kind:o(`value`),wrapperAddonId:p().nullable()}),b({kind:o(`missing`)}),b({kind:o(`failed`),error:p()})]),axe=b({id:f(),stableId:p(),type:p(),name:p(),location:p().nullable(),tags:oh.optional(),disabled:v(),parentDeviceId:f().nullable(),role:p().nullable().optional()}),oxe=b({id:f(),stableId:p(),addonId:p(),type:p(),name:p(),userNamed:v().optional(),location:p().nullable(),tags:oh.optional(),disabled:v(),parentDeviceId:f().nullable(),metadata:u(p(),l()).nullable().optional(),sourceInfo:Eg.optional(),integrationId:p().optional(),linkDeviceId:f().nullable().optional(),primaryChildEntityId:p().nullable().optional(),childLayout:S(zA).readonly().optional(),primaryChildPreference:S(p()).readonly().optional(),role:p().nullable().optional(),display:BA.optional()}),sxe=l().nullable(),cxe=b({streamId:p(),width:f().optional(),height:f().optional(),codec:p().optional(),fps:f().optional(),bitrateKbps:f().optional()}),lxe=b({addonId:p(),stableId:p(),id:f(),type:p(),name:p(),location:p().nullable().optional(),disabled:v().optional(),parentDeviceId:f().nullable(),role:p().nullable().optional(),features:S(p()).optional(),config:u(p(),l()),secretConfigPaths:S(p()).optional()}),XA=b({deviceId:f().int().positive(),deletedAt:f(),providerAddonId:p()}),ZA=2160*60*60*1e3,QA=b({deviceId:f().int().positive(),stores:u(p(),f().int().nonnegative())}),$A=b({status:x([`skipped`,`dry-run`,`cleaned`]),reason:p().nullable(),devices:S(QA),unreachable:S(p())}),uxe=b({deviceId:f()}),dxe=b({deviceId:f(),data:u(p(),l()),secretConfigPaths:S(p()).optional()}),ej=x([`off`,`on`,`not-offered`,`unreachable`]),tj=b({deviceId:f(),switchId:td,outcome:ej,detail:p().optional()}),nj=b({sourceId:f(),targetId:f(),switches:S(tj).readonly(),sourceStillLive:S(td).readonly(),swapped:v()}),rj={name:`device-manager`,scope:`system`,mode:`singleton`,extensionSlots:[qA],methods:{allocateDeviceId:O(b({addonId:p(),stableId:p()}),b({id:f()}),{kind:`mutation`}),migrateDevice:O(b({sourceId:f(),targetId:f()}),nj,{kind:`mutation`,auth:`admin`,timeoutMs:12*6e4}),registerDevice:O(lxe,_(),{kind:`mutation`}),removeDevice:O(uxe,_(),{kind:`mutation`}),persistConfig:O(dxe,_(),{kind:`mutation`,auth:`admin`}),loadConfig:O(b({deviceId:f()}),u(p(),l()),{auth:`admin`}),loadRuntimeState:O(b({deviceId:f()}),u(p(),l()),{auth:`admin`}),loadMeta:O(b({deviceId:f()}),oxe.nullable()),setName:O(b({deviceId:f(),name:p(),stampUserNamed:v().optional()}),_(),{kind:`mutation`,auth:`admin`}),setAlias:O(b({deviceId:f(),alias:p()}),i(`ok`,[b({ok:o(!0),alias:iA}),b({ok:o(!1),reason:x([`empty`,`too-long`,`grammar`,`reserved`,`taken`]),takenBy:f().optional()})]),{kind:`mutation`,auth:`admin`}),renderDeviceTemplates:O(b({templates:S(cA).max(64),allowedDeviceIds:S(f().int()).optional(),thisDevice:uA.optional()}),b({results:S(hA)}),{auth:`admin`}),checkDeviceTemplates:O(b({templates:S(p()).max(64),allowedDeviceIds:S(f().int()).optional(),thisDevice:uA.optional()}),b({results:S(i(`ok`,[b({ok:o(!0),aliases:S(b({alias:p(),deviceId:f().int().nullable(),allowed:v(),reads:S(p())})),readsClock:v()}),b({ok:o(!1),refusal:fA})]))}),{auth:`admin`}),setLocation:O(b({deviceId:f(),location:p().nullable()}),_(),{kind:`mutation`,auth:`admin`}),setTags:O(b({deviceId:f(),tags:oh}),_(),{kind:`mutation`,auth:`admin`}),setType:O(b({deviceId:f(),type:x(w)}),_(),{kind:`mutation`,auth:`admin`}),setIntegrationId:O(b({deviceId:f(),integrationId:p()}),_(),{kind:`mutation`,auth:`admin`}),setLinkDeviceId:O(b({deviceId:f(),linkDeviceId:f().nullable()}),_(),{kind:`mutation`,auth:`admin`}),setPrimaryChildEntityId:O(b({deviceId:f(),primaryChildEntityId:p().nullable()}),_(),{kind:`mutation`,auth:`admin`}),setChildLayout:O(b({deviceId:f(),childLayout:S(zA).readonly()}),_(),{kind:`mutation`,auth:`admin`}),setPrimaryChildPreference:O(b({deviceId:f(),primaryChildPreference:S(p()).readonly()}),_(),{kind:`mutation`,auth:`admin`}),setDisplay:O(b({deviceId:f(),display:BA.nullable()}),_(),{kind:`mutation`,auth:`admin`}),getRoleDisplayDefaults:O(b({}),b({defaults:u(p(),VA)}),{role:`viewer`,kind:`query`}),setRoleDisplayDefaults:O(b({defaults:u(p(),VA)}),_(),{kind:`mutation`,auth:`admin`}),getWireableFields:O(b({deviceId:f(),includeSynthesizable:v().optional()}),b({caps:S(b({cap:p(),fields:S(b({path:p(),kind:x([`string`,`number`,`boolean`,`enum`,`union`]),unionMembers:S(x([`string`,`number`,`boolean`])).optional(),enumValues:S(p()).optional(),item:v().optional(),quantity:Hi.optional()})).readonly(),itemArray:b({path:p(),keyField:p()}).optional()})).readonly()}),{kind:`query`}),setRole:O(b({deviceId:f(),role:p().nullable()}),_(),{kind:`mutation`,auth:`admin`}),applyInitialMeta:O(b({deviceId:f(),name:p().optional(),location:p().nullable().optional(),tags:oh.optional(),type:x(w).optional(),integrationId:p().optional(),linkDeviceId:f().nullable().optional(),role:p().nullable().optional()}),_(),{kind:`mutation`,auth:`admin`}),setMetadata:O(b({deviceId:f(),patch:u(p(),l())}),_(),{kind:`mutation`,auth:`admin`}),listLocations:O(_(),S(p())),addLocation:O(b({name:p()}),_(),{kind:`mutation`,auth:`admin`}),removeLocation:O(b({name:p(),cascade:v().optional()}),_(),{kind:`mutation`,auth:`admin`}),renameLocation:O(b({from:p(),to:p()}),b({moved:f()}),{kind:`mutation`,auth:`admin`}),listLocationIcons:O(_(),S(Tfe),{role:`viewer`}),setLocationIcon:O(b({location:p(),icon:$m.nullable()}),_(),{kind:`mutation`,auth:`admin`}),listLocationDescriptions:O(_(),S(Dfe)),setLocationDescription:O(b({location:p(),description:p().max(400).nullable()}),_(),{kind:`mutation`,auth:`admin`}),listSiteZones:O(_(),S(yA),{role:`viewer`}),setSiteZone:O(b({name:p(),icon:$m.nullable().optional()}),_(),{kind:`mutation`,auth:`admin`}),removeSiteZone:O(b({name:p()}),_(),{kind:`mutation`,auth:`admin`}),renameSiteZone:O(b({from:p(),to:p()}),_(),{kind:`mutation`,auth:`admin`}),setLocationZone:O(b({location:p(),zone:p().nullable()}),_(),{kind:`mutation`,auth:`admin`}),setDisabled:O(b({deviceId:f(),disabled:v()}),_(),{kind:`mutation`,auth:`admin`}),listPersistedByAddon:O(b({addonId:p()}),S(axe)),listAll:O(b({addonId:p().optional(),projection:x([`full`,`slim`]).optional(),isCamera:v().optional(),deviceIds:S(f()).optional()}),S(HA),{role:`viewer`}),search:O(SA,OA,{role:`viewer`}),getDevice:O(b({deviceId:f()}),HA.nullable()),getChildren:O(b({parentDeviceId:f()}),S(HA),{role:`viewer`}),getChildrenBatch:O(b({parentDeviceIds:S(f()).max(256)}),u(p(),S(HA))),getLinkedDevices:O(b({deviceId:f()}),b({mode:WA,devices:S(GA)}),{role:`viewer`}),getLinkedDevicesBatch:O(b({deviceIds:S(f())}),S(ixe),{role:`viewer`}),getStreamSources:O(b({deviceId:f()}),S(ea)),getConfigSchema:O(b({deviceId:f()}),S(UA)),getSettingsSchema:O(b({deviceId:f()}),sxe),updateConfig:O(b({deviceId:f(),values:u(p(),l())}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),enable:O(b({deviceId:f()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),disable:O(b({deviceId:f()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),remove:O(b({deviceId:f()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),listDeletedSince:O(b({sinceMs:f()}),S(XA).readonly(),{auth:`admin`}),cleanupDeletedDevicesData:O(b({confirm:v()}),$A,{kind:`mutation`,auth:`admin`}),removeByIntegration:O(b({integrationId:p()}),b({removed:f()}),{kind:`mutation`,auth:`admin`}),getStreamProfileMap:O(b({deviceId:f()}),u(p(),p().nullable())),setStreamProfileMap:O(b({deviceId:f(),profileMap:u(p(),p().nullable())}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),probeStreams:O(b({deviceId:f()}),S(cxe),{kind:`mutation`,auth:`admin`}),getBindings:O(b({deviceId:f()}),JA,{role:`viewer`}),getBindingsBatch:O(b({deviceIds:S(f())}),S(JA)),getAllBindings:O(b({}),S(JA)),listDeviceIdsByCaps:O(b({capNames:S(p().min(1)).min(1).max(16)}),S(f()),{role:`viewer`}),setWrapperActive:O(b({deviceId:f(),capName:p(),wrapperAddonId:p(),active:v()}),_(),{kind:`mutation`,auth:`admin`}),getWrapperActivation:O(b({deviceId:f(),capName:p().min(1)}),YA),listWrappersForCap:O(b({capName:p()}),S(p())),listBindableCapsForDeviceType:O(b({deviceType:p()}),S(b({capName:p(),wrappers:S(p())}))),getDeviceSettingsAggregate:O(b({deviceId:f()}),bx.nullable()),getDeviceLiveInfoAggregate:O(b({deviceId:f()}),bx.nullable(),{role:`viewer`}),getDeviceAggregate:O(b({deviceId:f()}),b({settings:bx.nullable(),live:bx.nullable()})),runDeviceAction:O(b({deviceId:f().int().nonnegative(),action:p().min(1),input:l()}),l(),{kind:`mutation`}),updateDeviceField:O(b({deviceId:f(),writerCapName:p(),writerAddonId:p(),key:p(),value:l()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),updateDeviceFieldsBatch:O(b({deviceId:f(),changes:S(b({writerCapName:p(),writerAddonId:p(),key:p(),value:l()}))}),b({success:o(!0),failures:S(b({writerCapName:p(),writerAddonId:p(),error:p()}))}),{kind:`mutation`,auth:`admin`}),discoverDevices:O(b({addonId:p()}),S(MA),{kind:`mutation`,auth:`admin`}),adoptDevice:O(b({addonId:p(),candidate:MA,integrationId:p().optional()}),NA,{kind:`mutation`,auth:`admin`}),getCreationSchema:O(b({addonId:p(),type:x(w),integrationId:p().optional()}),l().nullable()),createDevice:O(b({addonId:p(),type:x(w),config:u(p(),l()),integrationId:p().optional()}),NA,{kind:`mutation`,auth:`admin`}),testCreationField:O(b({addonId:p(),type:x(w),key:p(),value:l(),formValues:u(p(),l()).optional()}),PA,{kind:`mutation`,auth:`admin`}),adoptionListCandidateFilters:O(b({addonId:p(),integrationId:p()}),b({filters:S(Hk)}),{auth:`admin`}),adoptionListCandidates:O(Wk.extend({addonId:p()}),Gk,{auth:`admin`}),adoptionRefresh:O(b({addonId:p(),integrationId:p()}),qk,{kind:`mutation`,auth:`admin`}),adoptionAdopt:O(Jk.extend({addonId:p()}),Yk,{kind:`mutation`,auth:`admin`}),adoptionRelease:O(Xk.extend({addonId:p()}),_(),{kind:`mutation`,auth:`admin`}),adoptionStartJob:O(Jk.extend({addonId:p()}),b({jobId:p()}),{kind:`mutation`,auth:`admin`}),adoptionListJobs:O(b({addonId:p(),integrationId:p().optional()}),S(ed).readonly(),{auth:`admin`}),adoptionCancelJob:O(b({jobId:p()}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`}),adoptionResync:O(Zk,Qk,{kind:`mutation`,auth:`admin`}),discoveryProviders:O(b({}),b({providers:S(b({addonId:p(),label:p()})).readonly()}),{auth:`admin`}),discoverAllProviders:O(b({subnets:S(p()).optional()}),b({groups:S(b({addonId:p(),label:p(),candidates:S(MA).readonly(),error:p().nullable()})).readonly()}),{kind:`mutation`,auth:`admin`}),discoverProvider:O(b({addonId:p(),params:u(p(),l()).optional(),subnets:S(p()).optional()}),b({candidates:S(MA).readonly()}),{kind:`mutation`,auth:`admin`}),listDiscoveryProposals:O(b({}),b({proposals:S(RA).readonly()}),{auth:`admin`}),dismissDiscoveryProposal:O(b({id:p()}),b({dismissed:v()}),{kind:`mutation`,auth:`admin`}),reportDiscoveryObservations:O(b({observations:S(LA).max(512)}),b({proposed:f().int()}),{kind:`mutation`,auth:`admin`}),runDiscoverySweep:O(b({}),b({providers:f().int(),proposed:f().int()}),{kind:`mutation`,auth:`admin`,timeoutMs:12e4}),providerCreationType:O(b({addonId:p(),integrationId:p().optional()}),b({deviceType:x(w).nullable()}),{auth:`admin`}),providerDiscoveryParamsSchema:O(b({addonId:p()}),l(),{auth:`admin`}),testField:O(b({deviceId:f(),key:p(),value:l()}),PA,{kind:`mutation`,auth:`admin`}),getDeviceStatusAggregate:O(b({deviceId:f(),caps:S(p()).readonly().optional()}),u(p(),l().nullable())),getDeviceStatusAggregateBatch:O(b({deviceIds:S(f()).readonly(),caps:S(p()).readonly().optional()}),u(p(),u(p(),l().nullable())),{role:`viewer`})},vocabulary:{notOperatorFacing:`the device registry itself — rename, move and remove are administration`}},ij=[`linked-devices`],aj=x(ij),oj={"linked-devices":{descriptor:qA,declaringCap:`device-manager`,hostDeviceTypes:[w.Camera]}},sj=i(`slot`,[KA.extend({slot:o(`linked-devices`)})]),cj=[w.Camera],fxe=`:`,pxe=`listSlots`,lj=i(`state`,[b({state:o(`ok`)}),b({state:o(`unreachable`),reason:p()})]),uj=b({source:p(),label:p(),addonId:p().optional(),availability:lj}),dj=x([`ok`,`missing`,`foreign`,`unavailable`]),fj=b({deviceId:f().int(),name:p().nullable(),health:dj,detail:p().optional()}),pj=b({state:x([`active`,`inactive`,`unknown`]),authority:p(),detail:p().optional()}),mj=b({state:o(`ok`),slotRef:p(),slot:aj,authority:p(),activation:pj.nullable(),value:sj,sources:S(fj),impliedSources:S(fj).optional()}),hj=b({state:o(`unreachable`),addonId:p(),reason:p()}),gj=i(`state`,[mj,hj]);function mxe(e,t){return{state:`unreachable`,addonId:e,reason:t}}var _j=b({deviceId:f().int(),name:p(),type:p(),location:p().nullable(),parentName:p().nullable(),suggested:v(),reason:p().nullable()}),vj=b({candidates:S(_j)}),yj=b({applied:o(!0),reload:x([`none`,`host`,`parent`])}),bj=b({deviceId:f().int(),slotRef:p().min(1)}),xj=bj.extend({value:sj}),Sj={name:`device-extension`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:cj,deviceConfig:{ui:{kind:`widget`,widgetId:`host/extensions-panel`,tab:`general`,label:`Extensions`,order:72}},methods:{listSources:O(b({deviceId:f().int()}),S(uj)),listSlots:O(b({deviceId:f().int()}),S(gj)),listCandidates:O(bj,vj),setSlot:O(xj,yj,{kind:`mutation`,auth:`admin`})},vocabulary:{noun:N(`Device extension`,`Estensione del dispositivo`),order:3100}},Cj=i(`kind`,[b({kind:o(`device`),deviceId:f().int()}),b({kind:o(`node`),nodeId:p().min(1)})]),wj=x([`gauge`,`counter`,`boolean`,`enum`]),Tj=x([`gauge`,`counter`,`boolean`]),hxe=`derived:energy.kwh`,Ej=x([`raw`,`5m`,`1h`,`1d`]),Dj=x([`undeclared`,`not-owner`,`opted-out`,`not-a-real-device`,`rate`,`ingest-mismatch`,`out-of-range`]),gxe=b({key:p(),reason:Dj,count:f().int()}),Oj=b({accepted:f().int(),refused:S(gxe).readonly()}),kj=b({key:p(),scope:p(),kind:wj,unit:p().nullable(),displayName:p(),source:x([`cap`,`addon`,`derived`]),values:S(p()).readonly().nullable(),firstTs:f(),lastTs:f()}),_xe=b({t:f(),samples:f().int(),mean:f().nullable(),twMean:f().nullable(),min:f(),max:f(),last:f().nullable(),delta:f().nullable(),state:p().nullable(),states:u(p(),f()).nullable()}),vxe=b({scope:p(),before:b({t:f(),value:f().nullable(),state:p().nullable()}).nullable(),points:S(_xe).readonly(),derivedFrom:p().nullable()}),Aj={key:p(),scope:p().optional(),from:f(),to:f(),resolution:c([Ej,o(`auto`)]).default(`auto`),maxPoints:f().int().positive().max(5e3).default(1e3)},jj=b({resolution:Ej,series:S(vxe).readonly(),truncated:v()}),yxe=24,bxe=c([b({deviceId:f().int(),key:p(),scope:p().optional()}),b({forNodeId:p().min(1),key:p(),scope:p().optional()})]),xxe=i(`ok`,[b({ok:o(!0),result:jj}),b({ok:o(!1),error:p()})]),Sxe=b({tier:Ej,rows:f().int().nullable(),approxBytes:f().nullable(),countedAt:f().nullable()}),Mj=x([`device-gone`,`undeclared`]),Nj=b({raw:f().int(),"5m":f().int(),"1h":f().int(),"1d":f().int()}),Cxe=b({seriesId:f().int(),deviceId:f().int(),key:p(),scope:p(),displayName:p().nullable(),reason:Mj,missingSince:f().nullable(),firstTs:f(),lastTs:f(),rows:Nj}),wxe=200,Txe=50,Pj=x([`not-found`,`not-orphan`,`failed`]),Exe=i(`ok`,[b({seriesId:f().int(),ok:o(!0),deleted:Nj}),b({seriesId:f().int(),ok:o(!1),reason:Pj})]),Dxe=b({series:S(Cxe).readonly(),truncated:v()}),Fj=x([`invalid-range`,`range-too-large`,`series-not-found`,`not-a-point-series`]),Oxe=b({"5m":f().int(),"1h":f().int(),"1d":f().int()}),kxe=i(`ok`,[b({ok:o(!0),dryRun:v(),seriesId:f().int(),rows:Nj,rewritten:Oxe.nullable()}),b({ok:o(!1),reason:Fj})]),Ij=b({startedAt:f(),ready:v(),series:f().int(),metrics:f().int(),optedOutDevices:f().int(),tiers:S(Sxe).readonly(),capture:b({eventsSeen:f().int(),pointsEmitted:f().int(),pointsWritten:f().int(),pointsDropped:f().int(),bufferDepth:f().int(),trailingEmitted:f().int(),reconciledPoints:f().int(),reconcileRuns:f().int(),reconcileFailures:f().int(),lastReconcileAt:f().nullable(),lastFlushAt:f().nullable(),flushFailures:f().int(),skipped:u(p(),f().int())}),ingest:b({accepted:f().int(),refused:u(p(),f().int())}),rollup:b({last5mAt:f().nullable(),last1hAt:f().nullable(),last1dAt:f().nullable(),errors:f().int(),dirty5m:f().int(),dirty1h:f().int(),dirty1d:f().int()}),retention:b({lastRunAt:f().nullable(),deleted:u(p(),f().int()),purgedSeries:f().int()}),directory:b({devices:f().int(),lastRefreshAt:f().nullable()})}),Lj={name:`device-history`,scope:`system`,mode:`singleton`,methods:{listSeries:O(b({deviceId:f().int()}),S(kj).readonly()),listNodeSeries:O(b({forNodeId:p().min(1)}),S(kj).readonly(),{auth:`admin`}),query:O(b({deviceId:f().int(),...Aj}),jj),queryNode:O(b({forNodeId:p().min(1),...Aj}),jj,{auth:`admin`}),queryMany:O(b({items:S(bxe).min(1).max(24),from:Aj.from,to:Aj.to,resolution:Aj.resolution,maxPoints:Aj.maxPoints}),b({results:S(xxe).readonly()}),{auth:`admin`}),declareSeries:O(b({name:p().regex(/^[a-z0-9-]+$/),subjectKind:x([`device`,`node`]),kind:Tj,unit:p().optional(),displayName:p().min(1),ingest:x([`points`,`buckets`])}),b({key:p()}),{kind:`mutation`,auth:`admin`}),record:O(b({points:S(b({key:p(),subject:Cj,scope:p().default(``),ts:f(),value:f()})).max(5e3)}),Oj,{kind:`mutation`,auth:`admin`}),recordBuckets:O(b({buckets:S(b({key:p(),subject:Cj,scope:p().default(``),bucketStart:f(),samples:f().int().positive(),sum:f(),min:f(),max:f(),last:f().nullable(),lastTs:f().nullable()})).max(5e3)}),Oj,{kind:`mutation`,auth:`admin`}),getDeviceEnabled:O(b({deviceId:f().int()}),b({enabled:v()})),setDeviceEnabled:O(b({deviceId:f().int(),enabled:v()}),b({enabled:v()}),{kind:`mutation`,auth:`admin`}),getStatus:O(b({}),Ij,{auth:`admin`}),listOrphanSeries:O(b({}),Dxe,{auth:`admin`}),deleteOrphanSeries:O(b({seriesIds:S(f().int()).min(1).max(50)}),b({results:S(Exe).readonly()}),{kind:`mutation`,auth:`admin`}),deleteSeriesRange:O(b({deviceId:f().int(),key:p().min(1),scope:p(),fromMs:f().int().nonnegative(),toMs:f().int().nonnegative(),dryRun:v()}),kxe,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`recorded history of device state — read by charts, not actuated`}},Rj=b({deviceId:f().int().positive(),deletedAt:f(),providerAddonId:p()}),zj=b({counts:u(p(),f().int().nonnegative())}),Bj=b({store:p(),deviceId:f().int().positive(),count:f().int().nonnegative()}),Vj={name:`device-removal-hook`,scope:`system`,mode:`collection`,internal:!0,methods:{onDeviceRemoved:O(Rj,zj,{kind:`mutation`,auth:`admin`}),listDeviceData:O(_(),S(Bj).readonly(),{auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:A.INTERNAL}},Hj=x([`appliance`,`mower`,`vacuum`]),Uj=x([`open`,`closed`]),Wj=x([`completed`,`aborted`,`error`,`unknown`]),Gj=x([`running-state`,`activity`,`reconcile`]),Kj=x([`counter-delta`,`history-integral`]),qj=b({phase:p(),at:f()}),Jj=b({kind:o(`appliance`),energyKwh:f().nullable().meta(j(`energy`)),energyMethod:Kj.nullable(),peakW:f().nullable().meta(j(`power`)),avgW:f().nullable().meta(j(`power`)),program:p().nullable(),remainingAtStartSec:f().nullable().meta(j(`duration`)),finalPhase:p().nullable(),energyStartKwh:f().nullable().meta(j(`energy`)),powerObservedMs:f()}),Yj=i(`kind`,[Jj]),Xj=b({runId:p(),deviceId:f().int(),kind:Hj,state:Uj,startedAt:f(),endedAt:f().nullable(),durationMs:f().nullable(),outcome:Wj.nullable(),startSource:Gj,endSource:Gj.nullable(),runningSource:x([`native`,`assigned`]).nullable(),phases:S(qj),detail:Yj}),Axe=[w.Washer,w.Dryer,w.Dishwasher],jxe=200,Zj={name:`device-runs`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:Axe,methods:{listRuns:O(b({deviceId:f().int(),outcome:Wj.optional(),atFrom:f().optional(),atTo:f().optional(),limit:f().int().positive().max(200).default(50),cursor:p().optional()}),b({runs:S(Xj).readonly(),nextCursor:p().nullable()})),getRun:O(b({deviceId:f().int(),runId:p()}),Xj.nullable()),getCurrentRun:O(b({deviceId:f().int()}),Xj.nullable())},events:{onRunOpened:{data:Xj,notOperatorFacing:`the durable record of a run that the running-state start flip already announces`},onRunClosed:{data:Xj,notOperatorFacing:`the durable record of a run that the running-state finish flip already announces`}},vocabulary:{noun:N(`Runs`,`Esecuzioni`),order:2130}},Qj=x([`replace`,`add`]),$j=i(`ok`,[b({ok:o(!0),changed:v()}),b({ok:o(!1),code:x([`owned-by-other`,`not-claimed`,`field-not-claimed`,`invalid-slice`,`unknown-device`,`row-unreadable`,`migration-in-flight`]),message:p()})]),eM=b({deviceId:f(),capName:p(),owner:p().min(1),mode:Qj,fields:S(p().min(1)).min(1)}),tM=i(`state`,[b({state:o(`loaded`),claims:S(eM)}),b({state:o(`not-loaded`),reason:p()})]),nM={name:`device-state`,scope:`system`,mode:`singleton`,methods:{getSnapshot:O(b({deviceId:f()}),u(p(),u(p(),l()))),getCapSlice:O(b({deviceId:f(),capName:p()}),u(p(),l()).nullable()),getAllSnapshots:O(b({}),u(p(),u(p(),u(p(),l())))),setCapSlice:O(b({deviceId:f(),capName:p(),slice:u(p(),l())}),_(),{kind:`mutation`}),claimFields:O(b({deviceId:f(),capName:p(),owner:p().min(1),mode:Qj,fields:S(p().min(1)).min(1),values:u(p(),l())}),$j,{kind:`mutation`,auth:`admin`}),patchOwnedFields:O(b({deviceId:f(),capName:p(),owner:p().min(1),values:u(p(),l())}),$j,{kind:`mutation`,auth:`admin`}),releaseClaim:O(b({deviceId:f(),capName:p(),owner:p().min(1)}),$j,{kind:`mutation`,auth:`admin`}),listClaims:O(b({ownerPrefix:p().optional()}),tM,{auth:`admin`}),getNativeCapSlice:O(b({deviceId:f(),capName:p()}),u(p(),l()).nullable(),{auth:`admin`})},events:{onChanged:Rr(b({deviceId:f(),capName:p(),slice:u(p(),l())}))},vocabulary:{notOperatorFacing:`the runtime-state mirror every trigger already reads through`}},rM=b({online:v(),lastChangedAt:f()}),iM={name:`device-status`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},events:{onStatusChanged:{data:b({deviceId:f(),status:rM}),notOperatorFacing:"the `online` state trigger phrases both edges of this change"}},status:{schema:rM,kind:`push`},runtimeState:rM,durability:`restored`,history:{fields:{online:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:N(`Reachability`,`Raggiungibilità`),order:5260,state:[{kind:`boolean`,field:`online`,label:N(`Online`,`Online`),whenTrue:N(`When {device} comes back online`,`Quando {device} torna online`),whenFalse:N(`When {device} goes offline`,`Quando {device} va offline`),icon:`wifi`}],extraEvents:[{category:C.DeviceOnline,label:N(`Came online`,`Tornato online`),phrase:N(`When {device} comes back online`,`Quando {device} torna online`),icon:`wifi`},{category:C.DeviceOffline,label:N(`Went offline`,`Andato offline`),phrase:N(`When {device} goes offline`,`Quando {device} va offline`),icon:`wifi-off`}]}},Mxe=200,Nxe=500,aM=x([`not-kernel`,`invalid`]),oM=b({written:f().int().nonnegative(),refused:S(b({id:p(),reason:aM})).readonly()}),sM=b({rows:f().int().nullable(),lastWriteAt:f().nullable(),refused:u(p(),f())}),cM={name:`device-transitions`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:Object.values(w).filter(e=>e!==w.Container),methods:{listTransitions:O(b({deviceId:f().int(),capName:p().optional(),actorKind:Li.optional(),outcome:Ri.optional(),atFrom:f().optional(),atTo:f().optional(),limit:f().int().positive().max(200).default(50),cursor:p().optional()}),b({transitions:S(Bi).readonly(),nextCursor:p().nullable()})),getTransition:O(b({deviceId:f().int(),id:p()}),Bi.nullable()),listRecentTransitions:Lr(b({actorKind:Li.optional(),outcome:Ri.optional(),atFrom:f().optional(),atTo:f().optional(),limit:f().int().positive().max(200).default(50),cursor:p().optional()}),b({transitions:S(Bi).readonly(),nextCursor:p().nullable()}),{auth:`admin`}),record:Lr(b({transitions:S(Bi).max(500)}),oM,{kind:`mutation`,auth:`admin`}),getStatus:Lr(b({}),sM,{auth:`admin`})},vocabulary:{noun:N(`Transitions`,`Transizioni`),order:2140}},lM=x([`idle`,`running`,`paused`,`finished`,`error`,`unavailable`]),uM=x([`Inactive`,`Ready`,`DelayedStart`,`Run`,`Pause`,`ActionRequired`,`Finished`,`Error`,`Aborting`]),dM=x([`available`,`offline`,`description-missing`]),fM=b({availability:dM,state:lM,operationState:uM.nullable(),program:p().nullable(),selectedProgram:p().nullable(),availablePrograms:S(p()),remaining:f().int().nonnegative().nullable().meta(j(`duration`)),delayedStart:f().int().nonnegative().nullable().meta(j(`duration`)),progress:f().min(0).max(100).nullable().meta(j(`percentage`)),doorOpen:v().nullable(),doorLocked:v().nullable(),remoteStartAllowed:v().nullable(),remoteControlActive:v().nullable(),localControlActive:v().nullable(),powerOn:v().nullable(),powerState:p().nullable(),filterCleaningDue:v().nullable(),machineCareDue:v().nullable(),machineCareRemainingRuns:f().int().nonnegative().nullable().meta(j(`count`)),halfLoad:v().nullable(),hygienePlus:v().nullable(),extraDry:v().nullable(),intensiveZone:v().nullable(),varioSpeedPlus:v().nullable(),childLock:v().nullable(),activeEvents:S(p()),errorCode:f().nullable().meta(j(`none`)),errorLabel:p().nullable(),lastFetchedAt:f()}),pM=f().int().nonnegative(),mM=c([v(),p(),f()]),hM=x([`none`,`read`,`readWrite`,`writeOnly`,`readStatic`]),gM=b({key:p(),name:p(),type:x([`boolean`,`number`,`enum`,`string`]),access:hM,available:v(),unit:p().nullable(),min:f().nullable(),max:f().nullable(),step:f().nullable(),enumValues:S(p()).nullable(),defaultValue:mM.nullable()}),_M=b({key:p(),name:p(),available:v(),options:S(gM)}),vM=b({availability:dM,supportsStart:v(),supportsPause:v(),supportsResume:v(),supportsStop:v(),supportsPower:v(),programs:S(_M),options:S(gM)}),yM={name:`dishwasher`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Dishwasher],methods:{start:O(b({deviceId:pM,program:p().min(1).optional(),options:u(p(),mM).optional()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.start`,label:N(`Start cycle`,`Avvia il lavaggio`),phrase:N(`Start {device}`,`Avvia {device}`),icon:`play`,openArgs:[{key:`program`,label:N(`Programme`,`Programma`),offer:{kind:`dynamic`,from:`status`,field:`availablePrograms`},optional:!0}]}]}),pause:O(b({deviceId:pM}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.pause`,label:N(`Pause`,`Metti in pausa`),phrase:N(`Pause {device}`,`Metti in pausa {device}`),icon:`pause`}]}),resume:O(b({deviceId:pM}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.resume`,label:N(`Resume`,`Riprendi`),phrase:N(`Resume {device}`,`Riprendi il lavaggio di {device}`),icon:`play`}]}),stop:O(b({deviceId:pM}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.stop`,label:N(`Stop`,`Ferma`),phrase:N(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),setProgram:O(b({deviceId:pM,program:p().min(1)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.program`,label:N(`Choose programme`,`Scegli il programma`),phrase:N(`Select the {program} programme on {device}`,`Seleziona il programma {program} su {device}`),icon:`list`,openArgs:[{key:`program`,label:N(`Programme`,`Programma`),offer:{kind:`dynamic`,from:`status`,field:`availablePrograms`}}]}]}),setPower:O(b({deviceId:pM,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.powerOn`,label:N(`Power on`,`Accendi`),phrase:N(`Turn on {device}`,`Accendi {device}`),icon:`power`,args:{on:!0}},{id:`dishwasher.powerOff`,label:N(`Power off`,`Spegni`),phrase:N(`Turn off {device}`,`Spegni {device}`),icon:`power-off`,args:{on:!1}}]}),setHalfLoad:O(b({deviceId:pM,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.halfLoadOn`,label:N(`Half load on`,`Mezzo carico attivo`),phrase:N(`Turn on half load on {device}`,`Attiva il mezzo carico su {device}`),icon:`contrast`,args:{on:!0}},{id:`dishwasher.halfLoadOff`,label:N(`Half load off`,`Mezzo carico spento`),phrase:N(`Turn off half load on {device}`,`Disattiva il mezzo carico su {device}`),icon:`contrast`,args:{on:!1}}]}),setHygienePlus:O(b({deviceId:pM,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.hygienePlusOn`,label:N(`Hygiene Plus on`,`Igiene Plus attiva`),phrase:N(`Turn on Hygiene Plus on {device}`,`Attiva Igiene Plus su {device}`),icon:`sparkles`,args:{on:!0}},{id:`dishwasher.hygienePlusOff`,label:N(`Hygiene Plus off`,`Igiene Plus spenta`),phrase:N(`Turn off Hygiene Plus on {device}`,`Disattiva Igiene Plus su {device}`),icon:`sparkles`,args:{on:!1}}]}),setExtraDry:O(b({deviceId:pM,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.extraDryOn`,label:N(`Extra dry on`,`Asciugatura extra attiva`),phrase:N(`Turn on extra dry on {device}`,`Attiva l’asciugatura extra su {device}`),icon:`sun`,args:{on:!0}},{id:`dishwasher.extraDryOff`,label:N(`Extra dry off`,`Asciugatura extra spenta`),phrase:N(`Turn off extra dry on {device}`,`Disattiva l’asciugatura extra su {device}`),icon:`sun`,args:{on:!1}}]}),setIntensiveZone:O(b({deviceId:pM,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.intensiveZoneOn`,label:N(`Intensive zone on`,`Zona intensiva attiva`),phrase:N(`Turn on the intensive zone on {device}`,`Attiva la zona intensiva su {device}`),icon:`flame`,args:{on:!0}},{id:`dishwasher.intensiveZoneOff`,label:N(`Intensive zone off`,`Zona intensiva spenta`),phrase:N(`Turn off the intensive zone on {device}`,`Disattiva la zona intensiva su {device}`),icon:`flame`,args:{on:!1}}]}),setVarioSpeedPlus:O(b({deviceId:pM,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.varioSpeedOn`,label:N(`Speed boost on`,`Lavaggio rapido attivo`),phrase:N(`Turn on the speed boost on {device}`,`Attiva il lavaggio rapido su {device}`),icon:`zap`,args:{on:!0}},{id:`dishwasher.varioSpeedOff`,label:N(`Speed boost off`,`Lavaggio rapido spento`),phrase:N(`Turn off the speed boost on {device}`,`Disattiva il lavaggio rapido su {device}`),icon:`zap`,args:{on:!1}}]}),setChildLock:O(b({deviceId:pM,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.childLockOn`,label:N(`Child lock on`,`Blocco bambini attivo`),phrase:N(`Turn on the child lock of {device}`,`Attiva il blocco bambini di {device}`),icon:`lock`,args:{on:!0}},{id:`dishwasher.childLockOff`,label:N(`Child lock off`,`Blocco bambini spento`),phrase:N(`Turn off the child lock of {device}`,`Disattiva il blocco bambini di {device}`),icon:`lock-open`,args:{on:!1}}]}),setOption:O(b({deviceId:pM,key:p().min(1),value:mM}),_(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`a raw appliance option key/value; every option worth naming has its own action above`}),getOptions:O(b({deviceId:pM}),vM,{auth:`protected`})},status:{schema:fM,kind:`poll`},runtimeState:fM,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:N(`Dishwasher`,`Lavastoviglie`),order:2020,state:[{kind:`enum`,field:`state`,label:N(`Cycle`,`Ciclo`),values:[{value:`idle`,label:N(`Idle`,`Inattiva`)},{value:`running`,label:N(`Running`,`In funzione`),phrase:N(`When {device} starts a cycle`,`Quando {device} inizia un lavaggio`)},{value:`paused`,label:N(`Paused`,`In pausa`)},{value:`finished`,label:N(`Finished`,`Terminato`),phrase:N(`When {device} finishes`,`Quando {device} finisce il lavaggio`)},{value:`error`,label:N(`Error`,`Errore`),phrase:N(`When {device} reports an error`,`Quando {device} segnala un errore`)},{value:`unavailable`,label:N(`Unavailable`,`Non disponibile`)}],icon:`washing-machine`},{kind:`numeric`,field:`progress`,quantity:N(`the cycle progress`,`l’avanzamento del lavaggio`),label:N(`Progress`,`Avanzamento`),unit:`%`,icon:`loader`},{kind:`boolean`,field:`doorOpen`,label:N(`Door open`,`Sportello aperto`),whenTrue:N(`When the door of {device} opens`,`Quando si apre lo sportello di {device}`),whenFalse:N(`When the door of {device} closes`,`Quando si chiude lo sportello di {device}`),icon:`door-open`},{kind:`boolean`,field:`filterCleaningDue`,label:N(`Filter cleaning due`,`Pulizia filtro da fare`),whenTrue:N(`When {device} asks for its filter to be cleaned`,`Quando {device} chiede di pulire il filtro`),whenFalse:N(`When the filter reminder of {device} clears`,`Quando l’avviso filtro di {device} rientra`),icon:`funnel`},{kind:`boolean`,field:`machineCareDue`,label:N(`Machine care due`,`Manutenzione da fare`),whenTrue:N(`When {device} asks for a machine-care cycle`,`Quando {device} chiede un ciclo di manutenzione`),whenFalse:N(`When the machine-care reminder of {device} clears`,`Quando l’avviso di manutenzione di {device} rientra`),icon:`wrench`}]}},bM=`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(`.`),xM=`audio`,SM=[.3,.42,.55,.7,.85,1],CM=[`camstack`,`high-contrast`,`okabe-ito`];function Pxe(e){return bM.includes(e)}function Fxe(e){return CM.includes(e)}var wM={dark:`#0c0a09`,light:`#fafaf9`},Ixe=7,Lxe=20,Rxe=[`live`,`heatmapScrub`],zxe=3,TM=/^#[0-9a-fA-F]{6}$/;function EM(e,t){return Number.parseInt(e.slice(t,t+2),16)}function DM(e){let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function OM(e){let t=DM(EM(e,1)),n=DM(EM(e,3)),r=DM(EM(e,5));return .2126*t+.7152*n+.0722*r}function Bxe(e,t){if(!TM.test(e)||!TM.test(t))return 0;let n=Math.max(OM(e),OM(t)),r=Math.min(OM(e),OM(t));return(n+.05)/(r+.05)}function kM(e){let t=DM(EM(e,1)),n=DM(EM(e,3)),r=DM(EM(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 AM(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 Vxe(e,t){if(!TM.test(e)||!TM.test(t))return 0;let n=kM(e),r=kM(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=AM(o,n.b),d=AM(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)),ne=1+.015*(m-50)**2/Math.sqrt(20+(m-50)**2),re=1+.045*h,ie=1+.015*h*_,y=-Math.sin(2*ee*Math.PI/180)*te,ae=r.L-n.L,oe=l-c;return Math.sqrt((ae/ne)**2+(oe/re)**2+(p/ie)**2+oe/re*y*(p/ie))}var Hxe={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`},Uxe=[`#b34dc7`,`#1d7d34`,`#db6b6c`,`#a43d29`,`#0e6ee6`,`#29a10b`,`#a98731`,`#0181c6`],Wxe={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`},Gxe=[`#817f3b`,`#a0733e`,`#8658b2`,`#956301`,`#bc652d`,`#647331`,`#a14c9e`,`#d14e71`],Kxe={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`},qxe=[`#9a3784`,`#a7392c`,`#409d50`,`#6987e7`,`#ee5b3d`,`#c0430d`,`#af79b3`,`#4b6628`],jM=p().regex(/^#[0-9a-f]{6}$/),MM=i(`form`,[b({form:o(`solid`),hex:jM}),b({form:o(`gradient`),hex:jM,alphas:S(f().gt(0).lte(1)).length(SM.length)})]),NM=b({status:o(`ready`),presetId:x(CM),customized:v(),source:x([`stored`,`unconfigured`]),swatches:u(p(),MM),fallbacks:S(jM).length(8)}),PM=i(`status`,[NM,b({status:o(`unknown`),reason:p()})]),FM=c([b({presetId:p()}),b({presetId:p(),overrides:u(p(),MM)})]),IM=b({presetId:p(),overrides:u(p(),MM)});function Jxe(e){return{form:`solid`,hex:e}}function Yxe(e){return{form:`gradient`,hex:e,alphas:[...SM]}}function Xxe(e){let t={};for(let n of bM){let r=e[n];if(r===void 0)throw Error(`palette table missing ${n}`);t[n]=n===`audio`?Yxe(r):Jxe(r)}return t}function LM(e,t,n,r){return{id:e,name:t,swatches:Xxe(n),fallbacks:r}}var RM=[LM(`camstack`,`CamStack`,Hxe,Uxe),LM(`high-contrast`,`High contrast`,Wxe,Gxe),LM(`okabe-ito`,`Colour-blind safe`,Kxe,qxe)];function zM(e){return RM.find(t=>t.id===e)}function BM(){let e=zM(`camstack`);if(e===void 0)throw Error(`CamStack preset missing`);return Zxe(e,`unconfigured`,!1)}function Zxe(e,t,n){return{status:`ready`,presetId:e.id,customized:n,source:t,swatches:e.swatches,fallbacks:[...e.fallbacks]}}function Qxe(e){return e.hex}function $xe(e,t){let n=[];for(let t of bM){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 eSe(e){let t=e[xM];return t===void 0||t.form===`gradient`&&SM.every((e,n)=>t.alphas[n]===e)?[]:[{code:`bad-gradient`,entry:xM}]}function tSe(e,t){let n=Rxe;return n.includes(e)&&n.includes(t)}function VM(e,t){let n=[];for(let t of bM)e[t]===void 0&&n.push({code:`missing-entry`,entry:t});for(let t of Object.keys(e))Pxe(t)||n.push({code:`unknown-entry`,entry:t});t.length!==8&&n.push({code:`bad-fallbacks`}),n.push(...eSe(e));let r=$xe(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=Vxe(i.hex,a.hex);o<(tSe(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=Bxe(e.hex,wM[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 nSe(e){switch(e.code){case`too-close`:return`${e.left} vs ${e.right} (ΔE ${e.deltaE.toFixed(1)})`;case`low-contrast`:return`${e.entry} on ${e.background} (${e.contrast.toFixed(1)}:1)`;case`missing-entry`:return`${e.entry} is missing`;case`unknown-entry`:return`${e.entry} is not a palette entry`;case`bad-gradient`:return`${e.entry} gradient is not the six canonical steps`;case`bad-fallbacks`:return`fallback list must hold eight colours`;case`unknown-preset`:return`${e.presetId} is not a preset`}}function HM(e){return e.map(nSe).join(`; `)}var UM=class extends Error{violations;constructor(e){super(HM(e)),this.name=`PaletteRejectedError`,this.violations=e}};function WM(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 GM(e,t,n){let r=n.trim().toLowerCase();if(r.startsWith(`audio-`)){let n=e[xM];return n===void 0?WM(r,t):n.hex}let i=e[r];return i===void 0?WM(r,t):i.hex}function KM(e,t){return{...e,...t}}function rSe(e){return`overrides`in e?e.overrides:{}}function iSe(e){let t=zM(e.presetId);if(t===void 0||!Fxe(e.presetId))throw new UM([{code:`unknown-preset`,presetId:e.presetId}]);let n=rSe(e),r=KM(t.swatches,n),i=VM(r,t.fallbacks);if(!i.ok)throw new UM(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 aSe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.keys(e).length===0}function oSe(e){if(e==null||aSe(e))return BM();let t=IM.safeParse(e);if(!t.success)return{status:`unknown`,reason:`stored palette is unreadable`};let n=zM(t.data.presetId);if(n===void 0)return{status:`unknown`,reason:`unknown preset ${t.data.presetId}`};let r=KM(n.swatches,t.data.overrides),i=VM(r,n.fallbacks);if(!i.ok)return{status:`unknown`,reason:HM(i.violations)};let a=Object.keys(t.data.overrides).length>0;return{status:`ready`,presetId:n.id,customized:a,source:`stored`,swatches:r,fallbacks:[...n.fallbacks]}}function sSe(e,t){return{presetId:e.presetId,overrides:{...t}}}var cSe=b({id:p(),name:p(),swatches:u(p(),MM),fallbacks:S(p())}),qM={name:`display-palette`,scope:`system`,mode:`singleton`,methods:{getPalette:O(_(),PM,{auth:`protected`,role:`viewer`}),listPresets:O(_(),S(cSe).readonly(),{auth:`protected`,role:`viewer`}),setPalette:O(FM,NM,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`the cluster display palette — one colour table for every client, not a device action`}},JM=b({enabled:v().nullable().meta({label:`Do not disturb`}),lastChangedAt:f()}),YM={name:`do-not-disturb`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.MediaPlayer],methods:{setEnabled:O(b({deviceId:f().int(),enabled:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dnd.on`,label:N(`Do not disturb on`,`Attiva Non disturbare`),phrase:N(`Turn on Do not disturb on {device}`,`Attiva Non disturbare su {device}`),icon:`bell-off`,args:{enabled:!0}},{id:`dnd.off`,label:N(`Do not disturb off`,`Disattiva Non disturbare`),phrase:N(`Turn off Do not disturb on {device}`,`Disattiva Non disturbare su {device}`),icon:`bell`,args:{enabled:!1}}]})},status:{schema:JM,kind:`push`},runtimeState:JM,durability:`session`,history:{fields:{enabled:{kind:`boolean`}}},vocabulary:{noun:N(`Do not disturb`,`Non disturbare`),order:2160,state:[{kind:`boolean`,field:`enabled`,label:N(`Do not disturb`,`Non disturbare`),whenTrue:N(`When Do not disturb turns on on {device}`,`Quando {device} attiva Non disturbare`),whenFalse:N(`When Do not disturb turns off on {device}`,`Quando {device} disattiva Non disturbare`),icon:`bell-off`}]}},XM=2e3,lSe={version:1,targets:[{id:`pressed`,cardinality:`event`,shape:`pulse`,vocabulary:{cap:`doorbell`,eventName:`onPressed`},deviceTypes:[w.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:XM,changedAtRequired:!0},sources:[{kind:`binary`},{kind:`switch`}],sourceReport:{status:`assignment-status`},advancedExpression:!0}]},ZM=b({lastPressedAt:f().nullable(),pressCountSinceStart:f().meta(j(`count`))}),QM=b({deviceId:f(),timestamp:f()}),$M={name:`doorbell`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Button,w.Camera],methods:{},events:{onPressed:{data:QM,fromState:{field:`lastPressedAt`,on:`advance`},trigger:{category:C.DoorbellOnPressed,label:N(`Rang`,`Ha suonato`),phrase:N(`When someone rings {device}`,`Quando qualcuno suona a {device}`),icon:`bell-ring`}}},status:{schema:ZM,kind:`push`},runtimeState:ZM,durability:`restored`,history:`none`,customize:lSe,vocabulary:{noun:N(`Doorbell`,`Campanello`),order:5270}},eN=b({embedding:S(f()),inferenceMs:f()}),tN=x([`image`,`text`]),nN=b({modelId:p(),tower:tN,nodeId:p(),crashes:f(),windowMs:f(),sinceMs:f(),lastReason:p()}),rN=b({modelId:p(),tower:tN,nodeId:p(),attempts:f(),sinceMs:f(),lastReason:p()}),iN=b({modelId:p(),embeddingDim:f(),ready:v(),nodeId:p().optional(),failedModels:S(nN).optional(),failedRequirements:S(rN).optional()}),aN=`embedding-model-failed`,oN=`embedding-requirements-unavailable`,sN=`embedding-requirements-failed`,cN=x([aN,oN,sN]);function lN(e,t){return`[${e} model=${t.modelId} tower=${t.tower} node=${t.nodeId}]`}function uSe(e){return Error(`${lN(aN,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 dSe(e,t){return Error(`${lN(oN,e)} ${e.modelId} (${e.tower} tower) on ${e.nodeId}: ${t}`)}function fSe(e){return Error(`${lN(sN,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 pSe=RegExp(`\\[(${aN}|${oN}|${sN}) model=([^\\s\\]]+) tower=(image|text) node=([^\\s\\]]+)\\]`);function uN(e){let t=e instanceof Error?e.message:String(e),n=pSe.exec(t);if(n===null)return null;let r=cN.safeParse(n[1]),i=tN.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 mSe(e){return dN(e)!==null}function dN(e){let t=uN(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 fN={name:`embedding-encoder`,scope:`system`,mode:`collection`,internal:!0,methods:{encode:O(b({crop:y(Uint8Array),width:f(),height:f()}),eN,{auth:`admin`}),encodeText:O(b({text:p(),modelId:p().min(1).optional()}),eN,{auth:`admin`}),getInfo:O(_(),iN,{auth:`admin`}),resetFailedModels:O(b({modelId:p().min(1).optional()}),b({cleared:S(p()),nodeId:p()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:A.ML}},pN=b({powerW:f().nullable().meta(j(`power`)),energyKwh:f().nullable().meta(j(`energy`)),todayKwh:f().nullable().meta(j(`energy`))}),mN=b({powerW:f().nullable().meta(j(`power`)),importKwh:f().nullable().meta(j(`energy`)),exportKwh:f().nullable().meta(j(`energy`)),importTodayKwh:f().nullable().meta(j(`energy`)),exportTodayKwh:f().nullable().meta(j(`energy`))}),hN=b({powerW:f().nullable().meta(j(`power`)),energyKwh:f().nullable().meta(j(`energy`)),todayKwh:f().nullable().meta(j(`energy`))}),gN=b({stateOfChargePct:f().nullable().meta(j(`percentage`)),storedKwh:f().nullable().meta(j(`energy`)),capacityKwh:f().nullable().meta(j(`energy`)),powerW:f().nullable().meta(j(`power`)),chargedKwh:f().nullable().meta(j(`energy`)),dischargedKwh:f().nullable().meta(j(`energy`)),chargedTodayKwh:f().nullable().meta(j(`energy`)),dischargedTodayKwh:f().nullable().meta(j(`energy`)),healthPct:f().nullable().meta(j(`percentage`))}),_N=b({solar:pN.nullable(),grid:mN.nullable(),house:hN.nullable(),heatPump:hN.nullable(),storage:gN.nullable(),lastFetchedAt:f()});function hSe(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 vN={name:`energy-system`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.EnergySystem],methods:{},status:{schema:_N,kind:`push`},runtimeState:_N,durability:`session`,history:{primary:`house.powerW`,priority:50,fields:{"solar.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Solar power`},"solar.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`Solar energy`},"grid.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Grid power`},"grid.importKwh":{kind:`counter`,unit:`kWh`,displayName:`Grid import`},"grid.exportKwh":{kind:`counter`,unit:`kWh`,displayName:`Grid export`},"house.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`House power`},"house.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`House energy`},"heatPump.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Heat pump power`},"heatPump.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`Heat pump energy`},"storage.stateOfChargePct":{kind:`gauge`,unit:`%`,deadband:1,displayName:`Storage charge`},"storage.storedKwh":{kind:`gauge`,unit:`kWh`,deadband:.05,displayName:`Stored energy`},"storage.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Storage power`},"storage.chargedKwh":{kind:`counter`,unit:`kWh`,displayName:`Storage charged`},"storage.dischargedKwh":{kind:`counter`,unit:`kWh`,displayName:`Storage discharged`},"storage.healthPct":{kind:`gauge`,unit:`%`,deadband:1,displayName:`Storage health`}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:N(`Energy system`,`Sistema energetico`),order:4020}},gSe=x([`date`,`time`,`datetime`]),yN=b({value:p(),timestamp:v().optional(),lastFetchedAt:f()}),bN={name:`enum-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Sensor],methods:{},status:{schema:yN,kind:`push`},runtimeState:yN,durability:`restored`,history:{fields:{value:{kind:`enum`,skipWhenSet:`timestamp`}}},volatileStateFields:[`lastFetchedAt`,`timestamp`],vocabulary:{noun:N(`State sensor`,`Sensore di stato`),order:5060,state:[{kind:`value`,field:`value`,label:N(`State`,`Stato`),icon:`list`}]}},xN=x([`warning`,`error`]),SN=b({code:p(),label:p(),severity:xN}),CN=b({active:v().nullable(),code:p().nullable(),label:p().nullable(),severity:xN,since:f().nullable(),faults:S(SN).optional(),lastFetchedAt:f()}),wN={active:null,code:null,label:null,severity:`error`,since:null,lastFetchedAt:0},TN={name:`error`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},status:{schema:CN,kind:`push`,empty:wN},runtimeState:CN,durability:`restored`,volatileStateFields:[`lastFetchedAt`],history:`none`,vocabulary:{noun:N(`Fault`,`Guasto`),order:5265,state:[{kind:`boolean`,field:`active`,label:N(`Fault`,`Guasto`),whenTrue:N(`When {device} reports a fault`,`Quando {device} segnala un guasto`),whenFalse:N(`When the fault of {device} clears`,`Quando il guasto di {device} si risolve`),icon:`triangle-alert`}]}},EN=b({id:p(),name:p(),sampleCount:f().int().nonnegative(),coverMediaId:f().int().optional(),coverBase64:p().optional()}),_Se=b({id:p(),source:x([`detected`,`photo`]),addedAt:f().int(),deviceId:f().int().optional(),base64:p().optional(),mediaId:f().int().optional(),keyFrameMediaId:f().int().optional(),faceBbox:bS.optional()}),vSe=b({sampleId:p(),enrolledAt:f().int(),deviceId:f().int().optional(),source:x([`detected`,`photo`]),mediaId:f().int().optional(),comparable:v(),selfMean:f().nullable(),bestForeign:b({identityId:p(),name:p(),score:f()}).optional(),suspicion:f()}),ySe=b({identityId:p(),name:p(),modelId:p(),totalSamples:f().int(),comparableSamples:f().int(),flagged:f().int(),flagThreshold:f(),rows:S(vSe).readonly()}),DN=b({faceId:p(),deviceId:f().int(),trackId:p(),timestamp:f().int(),recognizedIdentityId:p().optional(),identityName:p().optional(),assigned:v(),base64:p().optional(),cropUrl:p().optional(),faceBbox:bS.optional(),keyFrameMediaId:f().int().optional(),bestMatchScore:f().optional(),nativeFaceShortSidePx:f().optional(),suggestedIdentityId:p().optional(),suggestedMatchScore:f().optional()}),bSe=x([`unassigned`,`recognized`,`identified`,`all`]),xSe=x([`timestamp`,`suggestionConfidence`]),SSe=x([`asc`,`desc`]),CSe=b({faceIds:S(p()).readonly(),representativeFaceId:p(),size:f().int(),cohesion:f()}),wSe=b({mediaId:f().int(),kind:p(),url:p(),sizeBytes:f(),timestamp:f()}),ON={name:`face-gallery`,role:{feature:`face-assignment`},scope:`system`,mode:`singleton`,methods:{listIdentities:O(b({includeCrops:v().optional()}).optional(),S(EN).readonly(),{role:`viewer`}),createIdentity:O(b({name:p().min(1)}),EN,{kind:`mutation`,auth:`admin`}),renameIdentity:O(b({id:p(),name:p().min(1)}),_(),{kind:`mutation`,auth:`admin`}),deleteIdentity:O(b({id:p()}),_(),{kind:`mutation`,auth:`admin`}),listIdentitySamples:O(b({identityId:p()}),S(_Se).readonly()),auditIdentitySamples:O(b({identityId:p().min(1)}),ySe,{auth:`admin`}),removeSample:O(b({identityId:p(),sampleId:p()}),_(),{kind:`mutation`,auth:`admin`}),moveIdentitySample:O(b({sampleId:p().min(1),toIdentityId:p().min(1)}),_(),{kind:`mutation`,auth:`admin`}),listRecentFaces:O(b({deviceId:f().int().optional(),deviceIds:S(f().int()).optional(),limit:f().int().positive().optional(),filter:bSe.optional(),since:f().int().optional(),until:f().int().optional(),sortBy:xSe.optional(),sortDirection:SSe.optional(),includeCrops:v().optional()}).optional(),S(DN).readonly()),getFaceByTrack:O(b({deviceId:f().int(),trackId:p()}),DN.nullable(),{role:`viewer`}),getFaceMedia:O(b({faceId:p()}),S(wSe).readonly()),assignFace:O(b({faceId:p(),identityId:p()}),_(),{kind:`mutation`,auth:`admin`}),unassignFace:O(b({faceId:p()}),_(),{kind:`mutation`,auth:`admin`}),deleteFace:O(b({faceId:p()}),_(),{kind:`mutation`,auth:`admin`}),assignFaces:O(b({faceIds:S(p()).min(1),identityId:p()}),b({assigned:f().int(),failed:S(p()).readonly()}),{kind:`mutation`,auth:`admin`}),unassignFaces:O(b({faceIds:S(p()).min(1)}),b({unassigned:f().int(),failed:S(p()).readonly()}),{kind:`mutation`,auth:`admin`}),suggestFaceClusters:O(b({threshold:f().min(0).max(1).optional(),minClusterSize:f().int().min(2).optional(),maxClusters:f().int().positive().optional(),limit:f().int().positive().optional(),maxFacesScanned:f().int().positive().optional()}).optional(),S(CSe).readonly())},vocabulary:{notOperatorFacing:`the face gallery — curated on its own page`}},kN=b({reason:p(),count:f().int().nonnegative()}),AN=b({family:p(),deviceId:f().int().positive(),variant:p().optional(),sinceMs:f(),atMs:f(),attempts:f().int().nonnegative(),succeeded:f().int().nonnegative(),reasons:S(kN).readonly()}),jN={name:`failure-contribution`,scope:`system`,mode:`collection`,internal:!0,methods:{list:O(_(),S(AN).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:A.INTERNAL}},MN=x([`forward`,`reverse`]),NN=[`horizontal`,`vertical`],PN=x(NN),FN=[`oscillating`,`angle`,`sweepFrom`,`sweepTo`],IN=x(FN),LN=[`min`,`max`,`step`],RN=b({oscillating:v().nullable().default(null),angle:f().nullable().default(null),sweepFrom:f().nullable().default(null),sweepTo:f().nullable().default(null),min:f().nullable().default(null),max:f().nullable().default(null),step:f().nullable().default(null)}),zN=b({horizontal:RN.nullable().default(null),vertical:RN.nullable().default(null)}),BN=[`nothing-to-set`,`axis-not-linked`,`out-of-range`,`source-gone`,`source-unknown`,`source-call-failed`],VN=x(BN),HN=i(`status`,[b({status:o(`applied`)}),b({status:o(`refused`),reason:VN,field:IN.optional(),detail:p(),applied:S(IN)})]),UN=b({deviceId:f().int().nonnegative(),axis:PN,oscillating:v().optional(),angle:f().optional(),sweepFrom:f().optional(),sweepTo:f().optional()});function WN(e,t){return`oscillationAxes.${e}.${t}`}var GN=b({speed:f().min(0).max(100).nullable().meta(j(`percentage`)),percentageStep:f().positive().optional().meta(j(`percentage`)),preset:p(),availablePresets:S(p()),direction:MN.nullable(),oscillating:v().nullable(),oscillationAxes:zN.optional(),lastChangedAt:f()});function TSe(e){let t=e.oscillationAxes;if(t===void 0)return e.oscillating;let n=NN.flatMap(e=>{let n=t[e]?.oscillating;return n==null?[]:[n]});return n.length===0?e.oscillating:n.some(Boolean)}var KN=[w.Fan],qN=`oscillation-axes`;function ESe(e){return{id:`${e}-oscillating`,cardinality:`scalar`,vocabulary:{cap:`fan-control`,stateField:`oscillating`},deviceTypes:KN,apply:`replace`,section:qN,path:WN(e,`oscillating`),sources:[{kind:`switch`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}}function JN(e,t){let n={id:`${e}-${t}`,cardinality:`scalar`,vocabulary:{cap:`fan-control`},deviceTypes:KN,apply:`replace`,section:qN,path:WN(e,t),sources:[{kind:`numeric`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}};return t===`angle`?{...n,companions:LN.map(t=>({kind:`source-field`,path:WN(e,t),field:t}))}:n}var DSe=NN.flatMap(e=>[ESe(e),JN(e,`angle`),JN(e,`sweepFrom`),JN(e,`sweepTo`)]),OSe={id:`preset`,cardinality:`scalar`,vocabulary:{cap:`fan-control`},deviceTypes:KN,apply:`replace`,path:`preset`,sources:[{kind:`field`,valueKinds:[`string`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}},YN=[...DSe,OSe],kSe={version:1,overridable:YN.map(e=>({path:e.path,by:e.id})),targets:YN},XN={name:`fan-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Fan],methods:{setPercentage:k(b({deviceId:f().int().nonnegative(),speed:f().min(0).max(100)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.off`,label:N(`Fan off`,`Ventilatore spento`),phrase:N(`Stop {device}`,`Ferma {device}`),icon:`power-off`,effect:{field:`speed`,value:0},args:{speed:0}},{id:`fan.full`,label:N(`Fan full`,`Ventilatore al massimo`),phrase:N(`Run {device} at full speed`,`Porta {device} alla massima velocità`),icon:`fan`,effect:{field:`speed`,value:100},args:{speed:100}},{id:`fan.speed`,label:N(`Set speed`,`Imposta la velocità`),phrase:N(`Set the speed of {device} to {speed}`,`Imposta la velocità di {device} al {speed}`),icon:`fan`,effect:{field:`speed`,fromArg:`speed`},openArgs:[{key:`speed`,label:N(`Speed`,`Velocità`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setPreset:k(b({deviceId:f().int().nonnegative(),preset:p().min(1)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.preset`,label:N(`Set preset`,`Imposta il preset`),phrase:N(`Set {device} to preset {preset}`,`Imposta {device} sul preset {preset}`),icon:`list`,openArgs:[{key:`preset`,label:N(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`status`,field:`availablePresets`}}]}]}),setDirection:k(b({deviceId:f().int().nonnegative(),direction:MN}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.forward`,label:N(`Spin forward`,`Rotazione avanti`),phrase:N(`Spin {device} forward`,`Fai girare {device} in avanti`),icon:`refresh-cw`,effect:{field:`direction`,value:`forward`},args:{direction:`forward`}},{id:`fan.reverse`,label:N(`Spin in reverse`,`Rotazione inversa`),phrase:N(`Spin {device} in reverse`,`Fai girare {device} al contrario`),icon:`rotate-ccw`,effect:{field:`direction`,value:`reverse`},args:{direction:`reverse`}}]}),setOscillating:k(b({deviceId:f().int().nonnegative(),oscillating:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.oscillateOn`,label:N(`Oscillate`,`Oscillazione attiva`),phrase:N(`Make {device} oscillate`,`Fai oscillare {device}`),icon:`move-horizontal`,effect:{field:`oscillating`,value:!0},args:{oscillating:!0}},{id:`fan.oscillateOff`,label:N(`Stop oscillating`,`Oscillazione spenta`),phrase:N(`Stop {device} oscillating`,`Ferma l’oscillazione di {device}`),icon:`move-horizontal`,effect:{field:`oscillating`,value:!1},args:{oscillating:!1}}]}),setOscillationAxis:k(UN,HN,{kind:`mutation`,auth:`protected`,actions:[{id:`fan.horizontalOscillateOn`,label:N(`Horizontal oscillation on`,`Oscillazione orizzontale attiva`),phrase:N(`Start the horizontal oscillation of {device}`,`Attiva l’oscillazione orizzontale di {device}`),icon:`move-horizontal`,args:{axis:`horizontal`,oscillating:!0}},{id:`fan.horizontalOscillateOff`,label:N(`Horizontal oscillation off`,`Oscillazione orizzontale spenta`),phrase:N(`Stop the horizontal oscillation of {device}`,`Ferma l’oscillazione orizzontale di {device}`),icon:`move-horizontal`,args:{axis:`horizontal`,oscillating:!1}},{id:`fan.verticalOscillateOn`,label:N(`Vertical oscillation on`,`Oscillazione verticale attiva`),phrase:N(`Start the vertical oscillation of {device}`,`Attiva l’oscillazione verticale di {device}`),icon:`move-vertical`,args:{axis:`vertical`,oscillating:!0}},{id:`fan.verticalOscillateOff`,label:N(`Vertical oscillation off`,`Oscillazione verticale spenta`),phrase:N(`Stop the vertical oscillation of {device}`,`Ferma l’oscillazione verticale di {device}`),icon:`move-vertical`,args:{axis:`vertical`,oscillating:!1}}]})},status:{schema:GN,kind:`push`},runtimeState:GN,customize:kSe,durability:`session`,history:{fields:{speed:{kind:`gauge`,unit:`%`,minIntervalMs:0},oscillating:{kind:`boolean`}}},vocabulary:{noun:N(`Fan`,`Ventilatore`),order:1080,state:[{kind:`numeric`,field:`speed`,quantity:N(`the speed`,`la velocità`),label:N(`Speed`,`Velocità`),unit:`%`,icon:`fan`},{kind:`boolean`,field:`oscillating`,label:N(`Oscillating`,`Oscillazione`),whenTrue:N(`When {device} starts oscillating`,`Quando {device} inizia a oscillare`),whenFalse:N(`When {device} stops oscillating`,`Quando {device} smette di oscillare`),icon:`move-horizontal`}]}},ASe=12,ZN=b({oscillating:v().optional(),angle:f().optional(),sweepFrom:f().optional(),sweepTo:f().optional()}),QN=b({speed:f().min(0).max(100).optional(),preset:p().min(1).optional(),direction:MN.optional(),oscillationAxes:b({horizontal:ZN.optional(),vertical:ZN.optional()}).optional()}),$N=b({id:p().min(1).max(64),name:p().trim().min(1).max(40),state:QN}),eP=[`empty-state`,`duplicate-name`,`duplicate-id`,`too-many`,`not-a-fan`],tP=x(eP),nP=i(`status`,[b({status:o(`saved`),count:f().int().nonnegative()}),b({status:o(`refused`),reason:tP,detail:p()})]),rP=b({field:p(),outcome:x([`applied`,`failed`,`not-run`,`refused`]),message:p().optional()}),iP=b({status:x([`applied`,`partial`,`refused`]),fields:S(rP)}),aP=[`speed`,`direction`,`preset`,`oscillationAxes`],oP=x(aP),sP=b({what:p(),reason:p()}),cP=b({state:QN,omitted:S(sP)}),lP=b({deviceId:f().int().nonnegative()}),jSe={version:1,targets:[{id:`presets`,cardinality:`config`,vocabulary:{cap:`fan-presets`},deviceTypes:[w.Fan],apply:`add`,readMethod:`getPresets`,writeMethod:`setPresets`}]},uP={name:`fan-presets`,scope:`system`,mode:`singleton`,methods:{getPresets:O(lP,S($N),{auth:`protected`}),setPresets:O(lP.extend({presets:S($N).max(12)}),nP,{kind:`mutation`,auth:`admin`}),applyPreset:O(lP.extend({presetId:p().min(1)}),iP,{kind:`mutation`,auth:`protected`}),capturePreset:O(lP.extend({fields:S(oP).optional()}),cP,{auth:`protected`})},customize:jSe,vocabulary:{notOperatorFacing:`the per-fan presets — authored in the Customize presets editor, applied through the actions the exports list`}},dP=b({flags:u(p(),l()),deviceType:p().nullable(),model:p().nullable(),channelCount:f().nullable().meta(j(`count`)),lastProbedAt:f(),lastFetchedAt:f()}),fP={name:`feature-probe`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},events:{onProbeChanged:{data:b({deviceId:f(),status:dP}),notOperatorFacing:`the device’s capabilities were re-probed — plumbing, not a happening`}},status:{schema:dP,kind:`push`},runtimeState:dP,durability:`session`,history:`none`,vocabulary:{noun:N(`Feature probe`,`Rilevamento funzioni`),order:3120}},MSe=b({name:p(),path:p()}),NSe=b({path:p(),entries:S(MSe).readonly(),freeBytes:f(),totalBytes:f()}),pP={name:`filesystem-browse`,scope:`system`,mode:`singleton`,internal:!0,methods:{listAllowedRoots:O(_(),S(p()).readonly(),{auth:`admin`}),browse:O(b({path:p()}),NSe,{auth:`admin`}),createDir:O(b({path:p()}),b({path:p()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:A.INTERNAL}},mP=b({flooded:v(),lastChangedAt:f()}),hP={name:`flood`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Sensor],methods:{},status:{schema:mP,kind:`push`},runtimeState:mP,durability:`restored`,history:{fields:{flooded:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:N(`Leak sensor`,`Sensore di allagamento`),order:5070,state:[{kind:`boolean`,field:`flooded`,label:N(`Leak`,`Perdita`),whenTrue:N(`When {device} detects a leak`,`Quando {device} rileva una perdita`),whenFalse:N(`When {device} is dry again`,`Quando {device} torna asciutto`),icon:`droplets`}]}},gP=b({detected:v(),lastChangedAt:f()}),_P={name:`gas`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Sensor],methods:{},status:{schema:gP,kind:`push`},runtimeState:gP,durability:`restored`,history:{fields:{detected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:N(`Gas sensor`,`Sensore di gas`),order:5080,state:[{kind:`boolean`,field:`detected`,label:N(`Detected`,`Rilevato`),whenTrue:N(`When {device} detects gas`,`Quando {device} rileva gas`),whenFalse:N(`When the gas clears on {device}`,`Quando il gas su {device} rientra`),icon:`flame`}]}},vP=b({active:v().meta({label:`Active`}),lastChangedAt:f()}),yP={name:`group-active`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Cover,w.Valve,w.Lock,w.MediaPlayer,w.Climate],methods:{},status:{schema:vP,kind:`push`},runtimeState:vP,durability:`session`,history:`none`,vocabulary:{noun:N(`Group state`,`Stato del gruppo`),order:5090}},bP=b({deviceId:f().int().nonnegative(),cap:p().min(1),method:p().min(1),ok:v(),error:p().optional(),at:f()}),xP=b({results:S(bP)}),SP={name:`group-commands`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Switch,w.Light,w.Fan,w.Cover,w.Valve,w.Lock,w.MediaPlayer,w.Climate],methods:{},status:{schema:xP,kind:`push`},runtimeState:xP,durability:`session`,history:`none`,vocabulary:{noun:N(`Group command`,`Comando di gruppo`),order:5100}},CP=b({included:f().int().nonnegative().meta(j(`count`,{precision:0,label:`Reporting`})),excluded:f().int().nonnegative().meta(j(`count`,{precision:0,label:`Excluded`})),total:f().int().nonnegative().meta(j(`count`,{precision:0,label:`Members`}))}),wP={name:`group-status`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Sensor,w.Switch,w.Light,w.Fan,w.Cover,w.Valve,w.Lock,w.MediaPlayer,w.Climate],methods:{},status:{schema:CP,kind:`push`},runtimeState:CP,durability:`session`,history:`none`,vocabulary:{noun:N(`Group`,`Gruppo`),order:5110,state:[{kind:`numeric`,field:`included`,quantity:N(`the members reporting`,`i membri che rispondono`),label:N(`Reporting`,`Rispondono`),icon:`users`},{kind:`numeric`,field:`excluded`,quantity:N(`the members left out`,`i membri esclusi`),label:N(`Excluded`,`Esclusi`),icon:`users`},{kind:`numeric`,field:`total`,quantity:N(`the member count`,`il numero di membri`),label:N(`Members`,`Membri`),icon:`sigma`}]}},TP=f().int().nonnegative(),EP=p().min(1),DP=p().min(1),OP=f().finite(),kP={key:`circuitId`,label:N(`Circuit`,`Circuito`),offer:{kind:`dynamic`,from:`status`,cap:`heat-pump-status`,field:`circuits`,valueKey:`id`,labelKey:`label`,where:{key:`kind`,equals:`heating`}}},AP={...kP,label:N(`Hot water circuit`,`Circuito acqua calda`),offer:{...kP.offer,where:{key:`kind`,equals:`dhw`}}},jP={key:`mode`,label:N(`Mode`,`Modalità`),offer:{kind:`text`}},PSe={key:`level`,label:N(`Level`,`Livello`),offer:{kind:`text`}},MP={key:`temp`,label:N(`Temperature`,`Temperatura`),offer:{kind:`number`,step:.5,unit:`°C`}},FSe={key:`minutes`,label:N(`Minutes`,`Minuti`),offer:{kind:`number`,min:1,step:1,unit:`min`}},NP={name:`heat-pump-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.HeatPump],methods:{setSilentMode:O(b({deviceId:TP,mode:DP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.silent`,label:N(`Set silent mode`,`Imposta la modalità silenziosa`),phrase:N(`Set silent mode of {device} to {mode}`,`Imposta la modalità silenziosa di {device} su {mode}`),icon:`volume-x`,openArgs:[{key:`mode`,label:N(`Silent mode`,`Modalità silenziosa`),offer:{kind:`enum`,values:[{value:`off`,label:N(`Off`,`Off`)},{value:`auto`,label:N(`Auto`,`Auto`)},{value:`on`,label:N(`On`,`On`)}]}}]}]}),setAwayMode:O(b({deviceId:TP,mode:DP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.away`,label:N(`Set away mode`,`Imposta la modalità assente`),phrase:N(`Set away mode of {device} to {mode}`,`Imposta la modalità assente di {device} su {mode}`),icon:`plane`,openArgs:[{key:`mode`,label:N(`Away mode`,`Modalità assente`),offer:{kind:`enum`,values:[{value:`off`,label:N(`Off`,`Off`)},{value:`on`,label:N(`On`,`On`)}]}}]}]}),setAdditionalHeaterMode:O(b({deviceId:TP,mode:DP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.additionalHeater`,label:N(`Set additional heater`,`Imposta il riscaldatore aggiuntivo`),phrase:N(`Set the additional heater of {device} to {mode}`,`Imposta il riscaldatore aggiuntivo di {device} su {mode}`),icon:`flame`,openArgs:[{key:`mode`,label:N(`Additional heater`,`Riscaldatore aggiuntivo`),offer:{kind:`enum`,values:[{value:`off`,label:N(`Off`,`Off`)},{value:`manual`,label:N(`Manual`,`Manuale`)},{value:`auto`,label:N(`Auto`,`Auto`)}]}}]}]}),setHolidayMode:O(b({deviceId:TP,mode:DP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.holiday`,label:N(`Set holiday mode`,`Imposta la modalità vacanza`),phrase:N(`Set holiday mode of {device} to {mode}`,`Imposta la modalità vacanza di {device} su {mode}`),icon:`tree-palm`,openArgs:[{key:`mode`,label:N(`Holiday programme`,`Programma vacanza`),offer:{kind:`enum`,values:[{value:`off`,label:N(`Off`,`Off`)},{value:`hm1`,label:N(`Programme 1`,`Programma 1`)},{value:`hm2`,label:N(`Programme 2`,`Programma 2`)},{value:`hm3`,label:N(`Programme 3`,`Programma 3`)},{value:`hm4`,label:N(`Programme 4`,`Programma 4`)},{value:`hm5`,label:N(`Programme 5`,`Programma 5`)},{value:`hm6`,label:N(`Programme 6`,`Programma 6`)},{value:`hm7`,label:N(`Programme 7`,`Programma 7`)},{value:`hm8`,label:N(`Programme 8`,`Programma 8`)}]}}]}]}),setCircuitOperationMode:O(b({deviceId:TP,circuitId:EP,mode:DP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitOperationMode`,label:N(`Set circuit operation mode`,`Imposta la modalità del circuito`),phrase:N(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`thermometer`,openArgs:[kP,jP]}]}),setCircuitHeatCoolMode:O(b({deviceId:TP,circuitId:EP,mode:DP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitHeatCoolMode`,label:N(`Set circuit heat / cool`,`Imposta caldo / freddo del circuito`),phrase:N(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`sun-snow`,openArgs:[kP,jP]}]}),setCircuitSummerWinter:O(b({deviceId:TP,circuitId:EP,mode:DP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitSummerWinter`,label:N(`Set circuit summer / winter`,`Imposta estate / inverno del circuito`),phrase:N(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`sun`,openArgs:[kP,jP]}]}),setCircuitComfortSetpoint:O(b({deviceId:TP,circuitId:EP,temp:OP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitComfortSetpoint`,label:N(`Set comfort temperature`,`Imposta la temperatura comfort`),phrase:N(`Set the comfort temperature of {circuitId} on {device} to {temp}`,`Imposta la temperatura comfort di {circuitId} su {device} a {temp}`),icon:`thermometer-sun`,openArgs:[kP,MP]}]}),setCircuitEcoSetpoint:O(b({deviceId:TP,circuitId:EP,temp:OP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitEcoSetpoint`,label:N(`Set eco temperature`,`Imposta la temperatura eco`),phrase:N(`Set the eco temperature of {circuitId} on {device} to {temp}`,`Imposta la temperatura eco di {circuitId} su {device} a {temp}`),icon:`leaf`,openArgs:[kP,MP]}]}),setCircuitMaxFlowTemp:O(b({deviceId:TP,circuitId:EP,temp:OP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitMaxFlowTemp`,label:N(`Set maximum flow temperature`,`Imposta la temperatura massima di mandata`),phrase:N(`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:[kP,MP]}]}),setDhwOperationMode:O(b({deviceId:TP,circuitId:EP,mode:DP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwOperationMode`,label:N(`Set hot water mode`,`Imposta la modalità acqua calda`),phrase:N(`Set hot water {circuitId} of {device} to {mode}`,`Imposta l'acqua calda {circuitId} di {device} su {mode}`),icon:`shower-head`,openArgs:[AP,jP]}]}),setDhwTemperatureLevel:O(b({deviceId:TP,circuitId:EP,level:DP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwTemperatureLevel`,label:N(`Set hot water level`,`Imposta il livello acqua calda`),phrase:N(`Set hot water {circuitId} of {device} to level {level}`,`Imposta l'acqua calda {circuitId} di {device} al livello {level}`),icon:`droplet`,openArgs:[AP,PSe]}]}),setDhwChargeDuration:O(b({deviceId:TP,circuitId:EP,minutes:f().int().positive()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwChargeDuration`,label:N(`Set hot water charge duration`,`Imposta la durata della carica acqua calda`),phrase:N(`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:[AP,FSe]}]}),startExtraHotWater:O(b({deviceId:TP,circuitId:EP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.extraHotWater`,label:N(`Start extra hot water`,`Avvia acqua calda extra`),phrase:N(`Start an extra hot water charge of {circuitId} on {device}`,`Avvia una carica extra di acqua calda {circuitId} su {device}`),icon:`droplets`,openArgs:[AP]}]})},vocabulary:{noun:N(`Heat pump settings`,`Impostazioni pompa di calore`),order:4010}},PP=[`heating`,`dhw`,`cooling`,`solar`],FP=x(PP),IP=b({value:p().nullable(),allowed:S(p())}),LP=b({value:f().nullable(),min:f().nullable(),max:f().nullable(),step:f().nullable()}),RP=b({id:p().min(1),kind:FP,label:p(),icon:$m,currentTemp:f().nullable().meta(j(`temperature`)),targetTemp:f().nullable().meta(j(`temperature`)),mode:p().nullable(),active:v().nullable(),operationMode:IP.nullable(),heatCoolMode:IP.nullable(),summerWinter:IP.nullable(),comfortSetpoint:LP.nullable(),ecoSetpoint:LP.nullable(),maxFlowTemp:LP.nullable(),temperatureLevel:IP.nullable(),chargeDuration:LP.nullable(),extraHotWater:v().nullable()}),zP=b({silent:IP.nullable(),away:IP.nullable(),additionalHeater:IP.nullable(),holiday:IP.nullable()}),BP=b({thermalW:f().nullable().meta(j(`power`)),electricalW:f().nullable().meta(j(`power`)),compressorPct:f().nullable().meta(j(`percentage`))}),VP=b({supply:f().nullable().meta(j(`temperature`)),return:f().nullable().meta(j(`temperature`)),outdoor:f().nullable().meta(j(`temperature`))}),HP=b({thermalKwh:f().nullable().meta(j(`energy`)),electricalKwh:f().nullable().meta(j(`energy`))}),UP=b({circuits:S(RP),system:zP,power:BP,temperatures:VP,energy:HP,waterPressureBar:f().nullable(),starts:f().nullable(),lastFetchedAt:f()});function WP(e){let{thermalW:t,electricalW:n}=e;return t===null||n===null||n<=0?null:t/n}var GP={name:`heat-pump-status`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.HeatPump],methods:{},status:{schema:UP,kind:`push`},runtimeState:UP,durability:`session`,history:{fields:{"power.thermalW":{group:`power`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Thermal power`},"power.electricalW":{group:`power`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Electrical power`},"power.compressorPct":{kind:`gauge`,unit:`%`,deadband:2,displayName:`Compressor`},"temperatures.supply":{group:`loop`,kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Supply`},"temperatures.return":{group:`loop`,kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Return`},"temperatures.outdoor":{kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Outdoor`},"energy.thermalKwh":{kind:`counter`,unit:`kWh`,displayName:`Thermal energy`},"energy.electricalKwh":{kind:`counter`,unit:`kWh`,displayName:`Electrical energy`}},items:{path:`circuits`,key:`id`,label:`label`,fields:{currentTemp:{kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Temperature`},targetTemp:{kind:`gauge`,unit:`°C`,minIntervalMs:0,displayName:`Setpoint`},mode:{kind:`enum`,displayName:`Mode`}}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:N(`Heat pump`,`Pompa di calore`),order:4e3}},KP=b({position:f().min(0).max(100).nullable().meta(j(`percentage`)),lastFetchedAt:f()}),qP={name:`heating-valve`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Climate],methods:{},status:{schema:KP,kind:`push`},runtimeState:KP,durability:`session`,history:{fields:{position:{kind:`gauge`,unit:`%`,deadband:1}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:N(`Radiator valve`,`Valvola termostatica`),order:1110,state:[{kind:`numeric`,field:`position`,quantity:N(`the valve opening`,`l’apertura della valvola`),label:N(`Valve opening`,`Apertura della valvola`),unit:`%`,icon:`heater`}]}},JP=x([`s`,`min`]),ISe=x([`switch`,`pet-fountain`]),YP={actuator:`switch`,maxSeconds:10800,unit:`min`,quickRunDefault:30},XP={actuator:`pet-fountain`,maxSeconds:300,unit:`s`,quickRunDefault:60},ZP=[w.Switch,w.PetFountain],QP={[w.Switch]:[E.SwitchHeater]};function $P(e,t){return e===w.PetFountain?XP:e===w.Switch&&t===E.SwitchHeater?YP:null}var LSe=1e3,RSe=6e4;function eF(e,t,n){let r=e-t;return r<=0?0:Math.max(1,Math.ceil(r/(n===`min`?RSe:LSe)))}function zSe(e,t){return t===`min`?e*60:e}function tF(e){return e.unit===`min`?Math.floor(e.maxSeconds/60):e.maxSeconds}var nF=b({duration:f().positive().finite(),unit:JP});function rF(e,t){let n=tF(e);return{duration:Math.min((t!==null&&Number.isFinite(t)&&t>0?t:null)??e.quickRunDefault,n),unit:e.unit}}var iF=x([`unsupported-device`,`over-max`,`command-failed`]),aF=i(`ok`,[b({ok:o(!0),activeUntil:f()}),b({ok:o(!1),reason:iF,maxSeconds:f().nullable()})]),oF=b({activeUntil:f().nullable(),requestedBy:p().nullable(),quickRun:nF.nullable(),lastFetchedAt:f()}),sF=b({unit:JP,maxDuration:f(),defaultDuration:f()}),cF=b({quickRunDuration:f().positive().finite().nullable().optional()}),lF={name:`timed-run`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:ZP,deviceRoles:QP,deviceConfig:{ui:{kind:`derived-form`,builderId:`timed-run`,tab:`general`}},methods:{getOptions:O(b({deviceId:f().int()}),sF),setSettings:O(b({deviceId:f().int(),settings:cF}),_(),{kind:`mutation`,auth:`admin`}),runFor:O(b({deviceId:f().int(),duration:f().positive().finite(),unit:JP}),aF,{kind:`mutation`,auth:`protected`,actions:[{id:`timedRun.runForMinutes`,label:N(`Run for minutes`,`Accendi per alcuni minuti`),phrase:N(`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:N(`Minutes`,`Minuti`),offer:{kind:`number`,min:1,step:1,unit:`min`}}]},{id:`timedRun.runForSeconds`,label:N(`Run for seconds`,`Accendi per alcuni secondi`),phrase:N(`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:N(`Seconds`,`Secondi`),offer:{kind:`number`,min:1,step:1,unit:`s`}}]}]}),cancel:O(b({deviceId:f().int()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`timedRun.cancel`,label:N(`Cancel the timer`,`Annulla il timer`),phrase:N(`Cancel the pending switch-off of {device}`,`Annulla lo spegnimento programmato di {device}`),icon:`timer-off`}]})},status:{schema:oF,kind:`push`},runtimeState:oF,durability:`session`,history:`none`,vocabulary:{noun:N(`Timed run`,`Esecuzione a tempo`),order:2150}},uF=[`on`,`off`,`running`,`idle`,`standby`,`alert`,`offline`,`unknown`],dF=[`success`,`warning`,`danger`,`primary`,`info`,`muted`],fF=[`none`,`pulse`,`spin`,`glow`,`halo`,`wave`,`rise`,`fall`,`tumble`,`equalizer`,`blink`,`breathe`],pF=[`plain`,`heat-rise`,`cool-fall`,`glow`,`water`,`drum`,`sky`,`mist`,`alert-wash`],mF=x(uF),hF=x(dF),BSe=x(fF),gF=b({icon:$m,tone:hF,background:x(pF),animation:BSe});function _F(e){let t=OD[e];return t===void 0?null:`cap:${e}.${t.field}`}function VSe(e){return e.enabledCaps.flatMap(e=>{let t=_F(e),n=OD[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 vF=b({en:p(),it:p()}),yF={en:`—`,it:`—`};function HSe(e){return e.en===yF.en&&e.it===yF.it}var bF=[`temperature`,`humidity`,`power`,`contact`,`text`],xF=[`hot`,`mild`,`cold`],SF=[`updated`,`changed`],CF=b({value:f(),quantity:Hi}),wF=b({quantity:x(bF),reading:CF.nullable(),icon:$m.nullable(),value:vF,unit:p().nullable(),band:x(xF).nullable(),level:f().min(0).max(1).nullable(),word:vF,tone:x(dF),since:f().nullable(),sinceKind:x(SF),historyKey:p().nullable()}),USe=3e3,TF=e=>N(e,e),EF=e=>Math.min(1,Math.max(0,e)),WSe=(e,t)=>String(Number(e.toFixed(t)));function DF(e){return e<12?`cold`:e>28?`hot`:`mild`}var GSe={hot:N(`Hot`,`Caldo`),mild:N(`Normal`,`Normale`),cold:N(`Cold`,`Freddo`)},KSe={hot:`warning`,mild:`muted`,cold:`info`};function OF(e,t){let n=DF(e);return{quantity:`temperature`,reading:{value:e,quantity:`temperature`},icon:`thermometer`,value:TF(WSe(e,1)),unit:`°C`,band:n,level:null,word:GSe[n],tone:KSe[n],since:t,sinceKind:`updated`,historyKey:_F(`temperature-sensor`)}}function kF(e,t){let n=e<30,r=e>70;return{quantity:`humidity`,reading:{value:e,quantity:`humidity`},icon:`droplets`,value:TF(String(Math.round(e))),unit:`%`,band:null,level:EF(e/100),word:n?N(`Dry`,`Secco`):r?N(`Humid`,`Umido`):N(`Normal`,`Normale`),tone:n||r?`warning`:`info`,since:t,sinceKind:`updated`,historyKey:_F(`humidity-sensor`)}}function AF(e,t){let n=e>0;return{quantity:`power`,reading:{value:e,quantity:`power`},icon:`zap`,value:TF(String(Math.round(e))),unit:`W`,band:null,level:EF(e/USe),word:n?N(`Active`,`Attivo`):N(`Idle`,`Inattivo`),tone:n?`primary`:`muted`,since:t,sinceKind:`updated`,historyKey:_F(`power-meter`)}}function jF(e,t){return{quantity:`contact`,reading:null,icon:e?`door-open`:`door-closed`,value:e?N(`Open`,`Aperto`):N(`Closed`,`Chiuso`),unit:null,band:null,level:+!!e,word:e?N(`Open`,`Aperto`):N(`Closed`,`Chiuso`),tone:e?`warning`:`success`,since:t,sinceKind:`changed`,historyKey:null}}function MF(e,t){return{quantity:`text`,reading:null,icon:null,value:TF(e),unit:null,band:null,level:null,word:N(`Changed`,`Cambiato`),tone:`muted`,since:t,sinceKind:`updated`,historyKey:null}}var qSe={temperature:{icon:`thermometer`,unit:`°C`,sinceKind:`updated`,historyKey:_F(`temperature-sensor`)},humidity:{icon:`droplets`,unit:`%`,sinceKind:`updated`,historyKey:_F(`humidity-sensor`)},power:{icon:`zap`,unit:`W`,sinceKind:`updated`,historyKey:_F(`power-meter`)},contact:{icon:null,unit:null,sinceKind:`changed`,historyKey:null},text:{icon:null,unit:null,sinceKind:`updated`,historyKey:null}};function NF(e){let t=qSe[e];return{quantity:e,reading:null,icon:t.icon,value:yF,unit:t.unit,band:null,level:null,word:yF,tone:`muted`,since:null,sinceKind:t.sinceKind,historyKey:t.historyKey}}var JSe={power:new Set([`energy-sensor`,`voltage-sensor`,`current-sensor`])};function PF(e,t){return t===null?!0:!(JSe[e.quantity]?.has(t)??!1)}var FF=`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(`.`),YSe=x(FF),IF=[`cool`,`heat`,`dry`,`fan`,`auto`,`playing`,`paused`,`open`,`closed`],LF=b({id:YSe,mode:x(IF).nullable(),level:f().min(0).max(1).nullable()}),RF={[w.Camera]:`camera`,[w.Light]:`light`,[w.Siren]:`siren`,[w.Switch]:`plug`,[w.Sensor]:`sensor-sparkline`,[w.Climate]:`thermostat`,[w.Button]:`button`,[w.EventEmitter]:`event-stream`,[w.Update]:`update`,[w.Generic]:`generic`,[w.Notifier]:`event-stream`,[w.Script]:`event-stream`,[w.Automation]:`event-stream`,[w.Lock]:`lock`,[w.Cover]:`cover`,[w.Valve]:`control-dial`,[w.Humidifier]:`control-dial`,[w.WaterHeater]:`heater`,[w.HeatPump]:`heat-pump`,[w.EnergySystem]:`generic`,[w.Fan]:`fan`,[w.MediaPlayer]:`tv`,[w.AlarmPanel]:`alarm`,[w.Control]:`control-dial`,[w.Presence]:`presence`,[w.Weather]:`weather`,[w.WeatherStation]:`weather`,[w.Vacuum]:`vacuum`,[w.LawnMower]:`lawn-mower`,[w.Container]:`generic`,[w.Image]:`camera`,[w.PetFeeder]:`pet-feeder`,[w.PetFountain]:`pet-fountain`,[w.Dishwasher]:`dishwasher`,[w.Washer]:`washer`,[w.Dryer]:`dryer`,[w.Gateway]:`gateway`},zF={[E.Siren]:`siren`,[E.Floodlight]:`light`,[E.Spotlight]:`light`,[E.PirSensor]:`presence`,[E.Chime]:`speaker`,[E.Autotrack]:`inherit`,[E.Nightvision]:`inherit`,[E.PrivacyMask]:`inherit`,[E.Doorbell]:`inherit`,[E.CoverBlind]:`inherit`,[E.CoverShutter]:`inherit`,[E.CoverAwning]:`inherit`,[E.CoverCurtain]:`inherit`,[E.CoverGarage]:`inherit`,[E.CoverGate]:`inherit`,[E.CoverDoor]:`inherit`,[E.CoverWindow]:`inherit`,[E.BinaryHelper]:`inherit`,[E.Outlet]:`plug`,[E.SwitchHeater]:`heater`,[E.SwitchFan]:`fan`,[E.SwitchLight]:`light`,[E.ClimateAc]:`ac`,[E.ClimateThermostat]:`inherit`,[E.ClimateFloor]:`inherit`,[E.ClimateRadiator]:`inherit`,[E.ClimateHeater]:`inherit`,[E.ClimateHeatPumpCircuit]:`inherit`,[E.MotionSensor]:`presence`,[E.ContactSensor]:`contact`,[E.LeakSensor]:`inherit`,[E.SmokeSensor]:`alarm`,[E.COSensor]:`alarm`,[E.GasSensor]:`alarm`,[E.TamperSensor]:`inherit`,[E.VibrationSensor]:`inherit`,[E.ConnectivitySensor]:`inherit`,[E.SoundSensor]:`inherit`,[E.BinarySensor]:`inherit`,[E.TemperatureSensor]:`sensor-sparkline`,[E.HumiditySensor]:`sensor-sparkline`,[E.AmbientLightSensor]:`inherit`,[E.PressureSensor]:`weather`,[E.WindSensor]:`weather`,[E.RainSensor]:`weather`,[E.UvSensor]:`weather`,[E.SolarRadiationSensor]:`weather`,[E.SoilMoistureSensor]:`inherit`,[E.PowerSensor]:`plug`,[E.EnergySensor]:`plug`,[E.VoltageSensor]:`plug`,[E.CurrentSensor]:`plug`,[E.AirQualitySensor]:`inherit`,[E.BatterySensor]:`inherit`,[E.NumericSensor]:`inherit`,[E.EnumSensor]:`inherit`,[E.DateTimeSensor]:`inherit`,[E.GenericSensor]:`inherit`,[E.NumericControl]:`control-dial`,[E.SelectControl]:`control-dial`,[E.TextControl]:`inherit`,[E.DateTimeControl]:`inherit`,[E.MobilePushNotifier]:`inherit`,[E.MessagingNotifier]:`inherit`,[E.EmailNotifier]:`inherit`,[E.GenericNotifier]:`inherit`,[E.IrTransmitter]:`inherit`};function XSe(e){return Object.values(w).includes(e)}function ZSe(e){return Object.values(E).includes(e)}function BF(e,t){let n=e!==null&&ZSe(e)?zF[e]:void 0;return n!==void 0&&n!==`inherit`?n:XSe(t)?RF[t]:`generic`}var VF=`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(`.`),HF=x(VF),QSe={progress:N(`Progress`,`Avanzamento`),"run-for":N(`Run for`,`Avvia per`),cycle:N(`Cycle`,`Ciclo`),program:N(`Program`,`Programma`),"appliance-power":N(`Appliance`,`Elettrodomestico`),"now-playing":N(`Now playing`,`In riproduzione`),playback:N(`Playback`,`Riproduzione`),volume:N(`Volume`,`Volume`),source:N(`Source`,`Sorgente`),contact:N(`Door`,`Porta`),"motion-trigger":N(`Motion`,`Movimento`),lock:N(`Lock`,`Serratura`),alarm:N(`Alarm`,`Allarme`),fan:N(`Fan`,`Ventola`),vacuum:N(`Cleaning`,`Pulizia`),"vacuum-suction":N(`Suction`,`Aspirazione`),mower:N(`Mowing`,`Taglio`),feeder:N(`Feed now`,`Eroga ora`),fountain:N(`Pump`,`Pompa`),"pump-cycle":N(`Pump cycle`,`Ciclo pompa`),automation:N(`Automation`,`Automazione`),script:N(`Script`,`Script`),"do-not-disturb":N(`Do not disturb`,`Non disturbare`),brightness:N(`Brightness`,`Luminosità`),color:N(`Colour`,`Colore`),cover:N(`Position`,`Posizione`),valve:N(`Valve`,`Valvola`),humidifier:N(`Humidifier`,`Umidificatore`),update:N(`Firmware`,`Firmware`),button:N(`Action`,`Azione`),"climate-mode":N(`Mode`,`Modalità`),"climate-fan":N(`Fan`,`Ventola`),setpoint:N(`Setpoint`,`Temperatura`),channel:N(`Channel`,`Canale`),control:N(`Control`,`Controllo`),circuit:N(`Circuit`,`Circuito`),"heat-pump-power":N(`Power`,`Potenza`),"system-mode":N(`Mode`,`Modalità`)},UF=g(()=>c([p(),f(),v(),u(p(),UF)])),$Se=u(p(),UF);function WF(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]:WF(o,i,n)}}function eCe(e,t,n){return WF(e,t.split(`.`),n)}var GF=b({cap:p(),method:p(),args:$Se}),tCe=x([`off-while-running`,`unlock`,`install`,`press`]),KF=b({id:p(),label:vF,icon:$m,call:GF,emphasis:x([`primary`,`normal`]),confirm:tCe.nullable()}),qF=i(`kind`,[b({kind:o(`action`),action:KF}),b({kind:o(`toggle`),id:p(),label:vF,on:v().nullable(),turnOn:KF,turnOff:KF}),b({kind:o(`slider`),id:p(),label:vF,value:f().nullable(),min:f(),max:f(),step:f(),unit:p(),call:GF,valueArg:p()}),b({kind:o(`picker`),id:p(),label:vF,current:p().nullable(),options:S(p()),optionLabels:u(p(),vF).optional(),call:GF,valueArg:p()}),b({kind:o(`number`),id:p(),label:vF,value:f().nullable(),step:f().nullable(),unit:p(),call:GF,valueArg:p()}),b({kind:o(`text`),id:p(),label:vF,value:p().nullable(),call:GF,valueArg:p()})]),nCe=b({icon:$m.nullable(),text:vF,tone:hF}),rCe=new Set([`cover`,`valve`,`lock`,`vacuum`,`playback`,`brightness`]),iCe=b({id:HF,placement:x([`row`,`scene`]).optional(),label:vF.optional(),group:vF.optional(),pills:S(nCe).optional(),icon:$m,status:vF.nullable(),controls:S(qF),progress:f().min(0).max(1).nullable().optional()}),JF=b({label:vF,value:c([f(),p()]),unit:p().nullable()}),aCe=b({id:x([`battery`,`network-link`,`integration`]),icon:$m,tone:hF,value:f().nullable(),label:vF}),YF=`remote.open`,oCe=b({commands:f().int().nullable(),open:KF.optional()}),sCe=b({items:S(b({key:p(),label:p(),level:f().nullable(),needsAttention:v()})),attention:f().int()}),cCe=i(`kind`,[b({kind:o(`power`),watts:f(),detail:S(JF)}),b({kind:o(`running`),running:v().nullable(),since:f().nullable(),phase:p().nullable(),detail:S(JF)})]),lCe=b({source:x([`switch`,`media-player`,`climate-control`]),on:v().nullable(),assumed:v(),turnOn:KF,turnOff:KF}),uCe=b({activeUntil:f().nullable(),quickRun:nF,run:KF,cancel:KF,remaining:f().nullable()}),dCe=b({on:v().nullable(),confirmOffWhileRunning:v(),running:v().nullable(),powerOn:KF,powerOff:KF,restart:KF}),XF=b({token:x(pF),animation:x(fF)}),ZF=b({id:x([`power`,`energy`,`battery`,`link`,`phase`,`remaining`,`volume`,`source`,`consumables`,`since`,`speed`,`progress`,`level`,`last-run`,`event`,`members`,`failures`,`reading`,`climate`,`temperature`,`humidity`,`pressure`,`air-quality`,`illuminance`,`valve`]),icon:$m.nullable(),text:vF,tone:hF}),QF=b({label:vF,value:vF,tone:hF.optional(),at:f().optional()}),fCe=b({left:S(QF).max(2),right:S(QF).max(2)}),pCe=i(`kind`,[b({kind:o(`artwork`),url:p(),fallback:XF}),b({kind:o(`state`),...XF.shape})]),mCe=b({partId:p(),cap:p()}),hCe=b({deviceId:f().int(),type:p(),role:p().nullable(),name:p(),state:mF,stateAssumed:v(),look:gF,background:pCe,scene:LF,facts:S(ZF),sideTiles:fCe,title:vF,caption:vF.optional(),badges:S(aCe),remote:oCe.nullable(),historyLabel:vF,consumables:sCe.nullable(),consumption:cCe.nullable(),ownPower:lCe.nullable(),timedRun:uCe.nullable(),powerSupply:dCe.nullable(),rows:S(iCe),measurement:wF.optional(),gated:S(p()),provenance:S(mCe)}),gCe=b({id:x([`timed-run.run`,`timed-run.cancel`]),duration:f(),unit:x([`min`,`s`])}),$F=b({deviceId:f().int(),name:p(),type:p(),state:mF,stateAssumed:v(),look:gF,scene:LF,statusLine:S(vF),primary:qF.nullable(),timedRun:gCe.nullable(),extras:S(qF).max(2).optional(),trailing:ZF.nullable(),measurement:wF.optional()}),eI=[`temperature`,`humidity`,`pressure`,`illuminance`,`reading`,`air-quality`,`valve`],_Ce=[`power`,`battery`,`consumables`],vCe=new Set(eI);function yCe(e){for(let t of _Ce){let n=e.facts.find(e=>e.id===t);if(n!==void 0)return n}return e.facts.find(t=>vCe.has(t.id)&&t.text.en===e.title.en)??null}var bCe={[w.Climate]:`climate.mode`};function xCe(e){let t=bCe[e.type];if(t!==void 0){let n=nI(e,t);if(n!==null)return n}let n=e.ownPower;if(n!==null)return e.gated.includes(`own-power`)?null:{kind:`toggle`,id:`own-power`,label:n.turnOn.label,on:n.on,turnOn:n.turnOn,turnOff:n.turnOff};for(let t of e.rows){let n=t.controls[0];if(n!==void 0)return e.gated.includes(t.id)?null:n}return null}var SCe={[w.Climate]:[`climate.target`],[w.Vacuum]:[`vacuum.base`],[w.LawnMower]:[`mower.dock`],[w.MediaPlayer]:[`volume.level`,YF],[w.Automation]:[`automation.enabled`]},tI=e=>e.kind===`action`?e.action.id:e.id;function nI(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=>tI(e)===t);if(r!==void 0)return r}return null}function CCe(e,t){let n=SCe[e.type]??[],r=t===null?null:tI(t);return n.filter(e=>e!==r).flatMap(t=>{let n=nI(e,t);return n===null?[]:[n]}).slice(0,2)}function wCe(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 TCe(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 ECe(e){let t=yCe(e),n=xCe(e);return{deviceId:e.deviceId,name:e.name,type:e.type,state:e.state,stateAssumed:e.stateAssumed,look:e.look,scene:e.scene,statusLine:wCe(e,t),primary:n,timedRun:TCe(e),extras:CCe(e,n),trailing:t,...e.measurement===void 0?{}:{measurement:e.measurement}}}var DCe=b({deviceId:f().int().nonnegative(),canActuate:v().optional()}),OCe=500,kCe=b({deviceIds:S(f().int().nonnegative()).max(500),canActuate:v().optional()}),rI=b({type:p(),rows:S(HF)}),iI={name:`hero-layout`,scope:`system`,mode:`singleton`,methods:{getHeroModel:O(DCe,hCe.nullable(),{auth:`protected`,role:`viewer`}),getRowModels:O(kCe,S($F.nullable()),{auth:`protected`,role:`viewer`}),getLayout:O(b({deviceType:p(),role:p().nullable().optional()}),rI,{auth:`protected`,role:`viewer`})},vocabulary:{notOperatorFacing:`the device hero model — read-only data the UI draws, never actuated`}},aI=b({on:v(),currentHumidity:f().min(0).max(100).nullable().meta(j(`humidity`)),targetHumidity:f().min(0).max(100).nullable().meta(j(`humidity`)),mode:p().nullable(),availableModes:S(p()),action:p().nullable(),minHumidity:f().nullable().meta(j(`humidity`)),maxHumidity:f().nullable().meta(j(`humidity`)),lastChangedAt:f()}),oI={name:`humidifier`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Humidifier],power:{kind:`field`,field:`on`,set:`setOn`},methods:{setOn:O(b({deviceId:f().int().nonnegative(),on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.on`,label:N(`Humidifier on`,`Umidificatore acceso`),phrase:N(`Turn on {device}`,`Accendi {device}`),icon:`power`,effect:{field:`on`,value:!0},args:{on:!0}},{id:`humidifier.off`,label:N(`Humidifier off`,`Umidificatore spento`),phrase:N(`Turn off {device}`,`Spegni {device}`),icon:`power-off`,effect:{field:`on`,value:!1},args:{on:!1}}]}),setTargetHumidity:O(b({deviceId:f().int().nonnegative(),humidity:f().min(0).max(100)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.target`,label:N(`Set humidity`,`Imposta l’umidità`),phrase:N(`Set {device} to {humidity} humidity`,`Imposta {device} al {humidity} di umidità`),icon:`droplets`,effect:{field:`targetHumidity`,fromArg:`humidity`},openArgs:[{key:`humidity`,label:N(`Humidity`,`Umidità`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setMode:O(b({deviceId:f().int().nonnegative(),mode:p().min(1)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.mode`,label:N(`Set mode`,`Imposta la modalità`),phrase:N(`Set {device} to {mode}`,`Imposta {device} su {mode}`),icon:`list`,effect:{field:`mode`,fromArg:`mode`},openArgs:[{key:`mode`,label:N(`Mode`,`Modalità`),offer:{kind:`dynamic`,from:`status`,field:`availableModes`}}]}]})},status:{schema:aI,kind:`push`},runtimeState:aI,durability:`session`,history:{fields:{currentHumidity:{kind:`gauge`,unit:`%`,deadband:.5},on:{kind:`boolean`}}},vocabulary:{noun:N(`Humidifier`,`Umidificatore`),order:1090,state:[{kind:`boolean`,field:`on`,label:N(`On`,`Acceso`),whenTrue:N(`When {device} turns on`,`Quando {device} si accende`),whenFalse:N(`When {device} turns off`,`Quando {device} si spegne`),icon:`power`},{kind:`numeric`,field:`currentHumidity`,quantity:N(`the humidity`,`l’umidità`),label:N(`Humidity`,`Umidità`),unit:`%`,icon:`droplets`}]}},sI=b({humidity:f().min(0).max(100).nullable().meta(j(`humidity`,{precision:0,label:`Humidity`})),lastFetchedAt:f()}),cI={name:`humidity-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Sensor,w.Climate],methods:{},status:{schema:sI,kind:`push`},runtimeState:sI,durability:`restored`,history:{primary:`humidity`,priority:90,fields:{humidity:{kind:`gauge`,unit:`%`,deadband:.5}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:N(`Humidity`,`Umidità`),order:5120,state:[{kind:`numeric`,field:`humidity`,quantity:N(`the humidity`,`l’umidità`),label:N(`Humidity`,`Umidità`),unit:`%`,icon:`droplets`}]}},lI=b({url:p().nullable(),lastUpdated:f().nullable().meta(j(`none`))}),uI={name:`image`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Image],methods:{},status:{schema:lI,kind:`push`},runtimeState:lI,durability:`session`,history:`none`,vocabulary:{noun:N(`Image`,`Immagine`),order:3130}},dI=x([`0`,`90`,`180`,`270`]),fI=x([`auto`,`manual`]),pI=x([`auto`,`manual`]),mI=x([`off`,`blc`,`wdr`,`hlc`]),hI=b({min:f(),max:f(),step:f()}),gI=b({brightness:f().optional().meta(j(`none`)),contrast:f().optional().meta(j(`none`)),saturation:f().optional().meta(j(`none`)),sharpness:f().optional().meta(j(`none`)),mirror:v().optional(),flip:v().optional(),rotate:dI.optional(),whiteBalance:fI.optional(),warmth:f().optional().meta(j(`none`)),exposureMode:pI.optional(),backlightMode:mI.optional(),lastFetchedAt:f()}),_I=b({supportsBrightness:v(),brightness:hI.optional(),supportsContrast:v(),contrast:hI.optional(),supportsSaturation:v(),saturation:hI.optional(),supportsSharpness:v(),sharpness:hI.optional(),supportsMirror:v(),supportsFlip:v(),rotateOptions:S(dI),whiteBalanceModes:S(fI),supportsWarmth:v(),warmth:hI.optional(),exposureModes:S(pI),backlightModes:S(mI)}),vI=b({brightness:f().optional(),contrast:f().optional(),saturation:f().optional(),sharpness:f().optional(),mirror:v().optional(),flip:v().optional(),rotate:dI.optional(),whiteBalance:fI.optional(),warmth:f().optional(),exposureMode:pI.optional(),backlightMode:mI.optional()}),yI={name:`image-settings`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Camera],deviceConfig:{ui:{kind:`derived-form`,builderId:`image-settings`,tab:`image`}},methods:{getOptions:O(b({deviceId:f()}),_I),setSettings:O(b({deviceId:f(),settings:vI}),_(),{kind:`mutation`,auth:`admin`})},status:{schema:gI,kind:`poll`},runtimeState:gI,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:N(`Image settings`,`Impostazioni immagine`),order:3140}},bI=b({id:p(),addonId:p(),name:p(),enabled:v(),switchUnknown:o(!0).optional(),info:u(p(),l()).readonly(),originStableId:p().optional(),createdAt:f(),updatedAt:f(),processState:p()}),xI=b({id:p(),addonId:p(),name:p(),enabled:v(),switchUnknown:o(!0).optional(),info:u(p(),l()).readonly(),originStableId:p().optional(),createdAt:f(),updatedAt:f()}),SI=b({addonId:p(),name:p(),providerLabel:p().optional(),description:p(),iconUrl:p().nullable(),color:p(),instanceMode:p(),mode:x([`standalone`,`account`,`broker`]),discoveryMode:p(),kind:x([`device-adoption`,`device-provider`]),brokerKind:p().nullable(),supportsLocationImport:v(),canTest:v(),existingInstances:S(b({id:p(),name:p()})),canAdd:v()}),CI=x([`validated`,`rejected`,`inconclusive`,`unsupported`]),wI=b({success:v(),error:p().optional(),status:CI.optional(),testedBy:p().nullable().optional(),latencyMs:f().nonnegative().optional(),detail:p().optional()}),TI=b({id:p(),name:p().optional(),enabled:v().optional(),info:u(p(),l()).optional()}),EI=b({success:v(),deletedId:p()}),DI={name:`integrations`,scope:`system`,mode:`singleton`,methods:{list:O(_(),S(bI)),get:O(b({id:p()}),bI),getByAddonId:O(b({addonId:p()}),xI.nullable()),update:O(TI,xI,{kind:`mutation`,auth:`admin`}),delete:O(b({id:p()}),EI,{kind:`mutation`,auth:`admin`}),getAvailableTypes:O(_(),S(SI),{auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:A.ADDON_ADMIN}},ACe=ge(),OI=p().min(1),kI=x([`single`,`multiple`]),AI=x([`devices`,`services`]),jI=b({id:p().min(1),label:p().min(1),functionCap:p().min(1),brokerKind:p().min(1).optional(),alsoServes:S(p().min(1)).optional(),iconUrl:p().min(1).optional(),iconMediaType:p().min(1).optional(),role:AI.optional(),canTest:v().optional(),signIn:b({basePath:p().min(1),methods:S(x([`device-code`,`proxy`])).optional()}).optional(),connectPath:p().min(1).optional(),disconnectPath:p().min(1).optional(),widgets:S(b({id:p().min(1),placement:x([`connection`,`model`])})).optional()}),MI=b({mode:x([`none`,`lan`,`account`]),scopedToInstance:v()}),NI=b({kind:p().min(1),field:p().min(1),to:b({cap:p().min(1),kind:p().min(1).optional()})}),PI=b({role:AI,discovery:MI.optional(),instanceMode:kI,kind:p(),canTest:v(),kinds:S(jI).min(1),allowRestoreId:v().optional(),mintsId:v().optional(),links:S(NI).optional(),userScoped:v().optional()}),FI=b({state:x([`ok`,`off`,`error`,`unknown`]),detail:p().optional(),label:p().optional()}),II=b({id:OI,name:p(),configured:v(),enabled:v().optional(),kind:p().min(1),formValues:u(p(),l()),status:FI.optional(),lastCheckedAt:f().optional()}),LI=b({id:OI,name:p().min(1).optional(),values:u(p(),l())}),RI={name:`integration-instances`,scope:`system`,mode:`collection`,methods:{describe:O(_(),PI,{auth:`admin`}),instanceFormSchema:O(b({id:OI.nullable(),kind:p().min(1).optional(),mode:x([`standalone`,`account`,`broker`]).optional(),candidateStableId:p().min(1).optional()}),ACe,{auth:`admin`}),listInstances:O(a({}),S(II).readonly(),{auth:`protected`,caller:`scoped`}),getInstance:O(b({id:OI}),II.nullable(),{auth:`protected`,caller:`scoped`}),createInstance:O(b({id:OI.optional(),name:p().min(1),kind:p().min(1).optional(),values:u(p(),l()).optional(),originStableId:p().min(1).optional(),seed:b({info:u(p(),l())}).optional()}),b({id:p()}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),updateInstance:O(LI,b({ok:o(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),setInstanceEnabled:O(b({id:OI,enabled:v()}),b({ok:o(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),deleteInstance:O(b({id:OI}),b({ok:o(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),testInstance:k(b({id:OI.nullable(),values:u(p(),l()),kind:p().min(1).optional()}),wI,{kind:`mutation`,auth:`protected`,caller:`scoped`})},vocabulary:{notOperatorFacing:A.INTERNAL}},zI=b({codecs:S(p()),sampleRate:f().meta(j(`none`)),duplex:x([`half`,`full`]),maxBacklogMs:f().meta(j(`duration-ms`))}),BI=b({talking:v(),lastSessionAt:f().nullable(),ability:zI.nullable()}),jCe=x([`opus`,`s16le`,`g711ulaw`,`g711alaw`]),VI={name:`intercom`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Camera],methods:{startSession:O(b({deviceId:f()}),b({sessionId:p(),sdpOffer:p()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),handleAnswer:O(b({deviceId:f(),sessionId:p(),sdpAnswer:p()}),_(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),stopSession:O(b({deviceId:f(),sessionId:p()}),_(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),startTalkSession:O(b({deviceId:f()}),b({sessionId:p()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`two-way talk is a person speaking through the viewer, not an automation step`}),pushTalkAudio:O(b({deviceId:f(),audioBase64:p(),codec:jCe.optional(),sampleRate:f().int().positive().optional(),channels:f().int().positive().optional(),sequenceNumber:f().int()}),b({accepted:v()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),endTalkSession:O(b({deviceId:f()}),_(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`})},events:{onStatusChanged:{data:b({deviceId:f(),status:BI}),notOperatorFacing:"the `talking` state trigger phrases both edges of this change"}},status:{schema:BI,kind:`command-driven`},runtimeState:BI,durability:`session`,history:`none`,vocabulary:{noun:N(`Intercom`,`Citofono`),order:3150,state:[{kind:`boolean`,field:`talking`,label:N(`Talking`,`In conversazione`),whenTrue:N(`When someone starts talking through {device}`,`Quando qualcuno inizia a parlare tramite {device}`),whenFalse:N(`When the conversation on {device} ends`,`Quando la conversazione su {device} finisce`),icon:`mic`}]}},HI=x([`carrierHz`,`dutyCyclePercent`,`repeat`,`repeatDelayMs`]),UI=x([`ir`,`rf`]),WI=b({ok:o(!0),ignoredSettings:S(p())}),GI=b({media:S(UI),settable:S(HI),maxTimings:f().int().positive(),learn:v().default(!1),formats:S(nE).default([])}),KI=2e4,qI=6e4,JI=b({native:iE.nullable(),timings:qT,carrierHz:f().int().positive().nullable()}),YI=b({at:f(),ok:v(),error:p().nullable()}),XI=YI.extend({medium:UI}),ZI=b({lastSend:XI.nullable(),lastLearn:YI.nullable(),lastFetchedAt:f()});function QI(e){return!(e.kind===`learn`&&e.error===`ir-transmitter.learn-unsupported`)}function MCe(e,t,n){let r=e??{lastSend:null,lastLearn:null,lastFetchedAt:n};return QI(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 NCe(e){return kr(e)?.code??null}var $I={name:`ir-transmitter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Generic],methods:{send:O(b({deviceId:f().int().nonnegative(),timings:qT.optional(),native:iE.optional(),settings:JT.optional()}).refine(e=>e.timings===void 0!=(e.native===void 0),{message:`send takes exactly one of timings or native`}),WI,{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:O(b({deviceId:f().int().nonnegative(),timeoutMs:f().int().positive().max(qI).default(KI)}),JI,{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:O(b({deviceId:f().int().nonnegative()}),GI,{kind:`query`,auth:`protected`})},runtimeState:ZI,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:N(`IR / RF transmitter`,`Trasmettitore IR / RF`),order:1140}},eL=x([`key-missing`,`wrong-key`,`key-file-unreadable`,`store-unavailable`,`not-initialized`,`decrypt-failed`]),tL=i(`state`,[b({state:o(`ready`)}),b({state:o(`locked`),reason:eL})]),nL=i(`kind`,[b({kind:o(`value`),value:p(),version:f().int()}),b({kind:o(`missing`)}),b({kind:o(`unavailable`),reason:eL}),b({kind:o(`forbidden`)})]),rL=u(p(),nL),iL=b({ref:p(),owner:p(),scope:p(),fieldPath:p(),version:f().int(),createdAt:f(),updatedAt:f(),updatedBy:p(),lastReadAt:f().nullable()}),PCe=512,aL=S(p().min(1)).max(512),oL={name:`keychain`,scope:`system`,mode:`singleton`,internal:!0,methods:{put:O(b({ref:p().min(1),value:p().min(1)}),b({ref:p(),version:f().int()}),{kind:`mutation`,auth:`admin`}),resolve:O(b({refs:aL}),rL,{auth:`admin`}),delete:O(b({refs:aL}),b({deleted:f().int()}),{kind:`mutation`,auth:`admin`}),deleteDeviceScope:O(b({deviceId:f().int()}),b({refs:S(p()).readonly()}),{kind:`mutation`,auth:`admin`}),releaseRecordRefs:O(b({refs:aL,onBehalfOf:p().min(1)}),b({released:f().int()}),{kind:`mutation`,auth:`admin`}),listMeta:O(b({}),S(iL).readonly(),{auth:`admin`}),getState:O(b({}),tL,{auth:`admin`})},vocabulary:{notOperatorFacing:A.IDENTITY}},sL=x([`mounted-file`,`previous-mounted-file`,`platform`,`default-file`]),cL=b({kind:sL,path:p().optional(),sharesBackupWithDatabase:v()}),FCe=`trigger-file`,lL=b({id:p(),at:f(),actor:p(),lockedReason:p().nullable(),archived:f().int(),archivedCollection:p().nullable(),archivedKeysCollection:p().nullable(),clearedSettingsKeys:S(p()).readonly(),acknowledgedAt:f().nullable()}),uL=b({keychain:tL,keySource:cL.nullable(),configuredSource:cL,fingerprint:p().nullable(),activeKeyId:p().nullable(),rotationPending:v(),retiredWraps:f().int(),recoveryKeyDownloadedAt:f().nullable(),secretCount:f().int(),lastReset:lL.nullable()}),dL=x([`in-use`,`orphan`,`unknown`]),fL=iL.extend({usage:dL}),pL=x([`put`,`delete`,`reveal`,`rotate-master-key`,`purge-retired-keys`,`download-recovery-key`,`delete-orphans`,`reset`,`acknowledge-reset`,`initialize`]),mL=b({id:p(),at:f(),action:pL,actor:p(),ref:p().nullable(),detail:p().nullable()}),hL=`RESET KEYCHAIN`,gL=x([`jwt-signing-key`]),_L={name:`keychain-admin`,scope:`system`,mode:`singleton`,methods:{status:O(b({}),uL,{auth:`admin`}),listSecrets:O(b({}),S(fL).readonly(),{auth:`admin`}),listAudit:O(b({limit:f().int().min(1).max(500).optional()}),S(mL).readonly(),{auth:`admin`}),reveal:O(b({ref:p().min(1)}),b({value:p(),version:f().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),setSystemSecret:O(b({name:gL,value:p().min(16)}),b({ref:p(),version:f().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),importSecret:O(b({ref:p().min(1),value:p().min(1)}),b({ref:p(),version:f().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),deleteOrphans:O(b({refs:S(p().min(1)).max(1e3)}),b({deleted:S(p()).readonly(),kept:S(b({ref:p(),usage:dL})).readonly()}),{kind:`mutation`,auth:`admin`,caller:`required`}),rotateMasterKey:O(b({}),b({fingerprint:p(),keySource:cL}),{kind:`mutation`,auth:`admin`,caller:`required`}),purgeRetiredKeys:O(b({}),b({purged:f().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),downloadRecoveryKey:O(b({}),b({key:p(),fingerprint:p(),keySource:cL}),{kind:`mutation`,auth:`admin`,caller:`required`}),resetKeychain:O(b({confirm:o(hL)}),b({archivedCollection:p().nullable(),archived:f().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),resetReport:O(b({}),b({reset:lL.nullable(),pendingReentry:S(iL).readonly()}),{auth:`admin`}),acknowledgeReset:O(b({}),b({acknowledged:v()}),{kind:`mutation`,auth:`admin`,caller:`required`})},vocabulary:{notOperatorFacing:A.IDENTITY}},vL=x([`idle`,`mowing`,`paused`,`docked`,`error`]),yL=x([`info`,`warning`,`error`]),bL=b({activity:vL,batteryLevel:f().min(0).max(100).nullable().meta(j(`percentage`)),progress:f().min(0).max(100).nullable().meta(j(`percentage`)),currentCode:f().nullable().meta(j(`none`)),currentCodeLabel:p().nullable(),severity:yL,lastChangedAt:f()}),xL={name:`lawn-mower-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.LawnMower],methods:{startMowing:O(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.start`,label:N(`Start mowing`,`Avvia il taglio`),phrase:N(`Start {device} mowing`,`Fai partire il taglio di {device}`),icon:`play`}]}),pause:O(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.pause`,label:N(`Pause mower`,`Metti in pausa il tosaerba`),phrase:N(`Pause {device}`,`Metti in pausa {device}`),icon:`pause`}]}),dock:O(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.dock`,label:N(`Dock mower`,`Riporta alla base`),phrase:N(`Send {device} back to its dock`,`Rimanda {device} alla base`),icon:`house`}]})},status:{schema:bL,kind:`push`},runtimeState:bL,durability:`session`,history:{fields:{batteryLevel:{kind:`gauge`,unit:`%`,deadband:2}}},vocabulary:{noun:N(`Robot mower`,`Robot tosaerba`),order:2010,state:[{kind:`enum`,field:`activity`,label:N(`Activity`,`Attività`),values:[{value:`idle`,label:N(`Idle`,`Inattivo`)},{value:`mowing`,label:N(`Mowing`,`In taglio`),phrase:N(`When {device} starts mowing`,`Quando {device} inizia a tagliare`)},{value:`paused`,label:N(`Paused`,`In pausa`)},{value:`docked`,label:N(`Docked`,`Alla base`),phrase:N(`When {device} docks`,`Quando {device} arriva alla base`)},{value:`error`,label:N(`Error`,`Errore`),phrase:N(`When {device} reports an error`,`Quando {device} segnala un errore`)}],icon:`bot`},{kind:`numeric`,field:`batteryLevel`,quantity:N(`the battery level`,`il livello della batteria`),label:N(`Battery`,`Batteria`),unit:`%`,icon:`battery`}]}},SL=6e5,ICe=60*6e4,CL=b({inputTokens:f(),outputTokens:f()}),wL=x([`timeout`,`rate-limited`,`auth`,`refusal`,`bad-request`,`unavailable`,`no-profile`,`budget-exceeded`,`adapter-error`]),TL=b({ok:o(!0),text:p(),model:p(),usage:CL,truncated:v(),latencyMs:f()}),EL=x([`guardrail`,`model`]),DL=b({ok:o(!1),code:wL,message:p(),retryAfterMs:f().optional(),refusalSource:EL.optional()}),OL=i(`ok`,[TL,DL]),kL=b({bytes:y(Uint8Array),mimeType:p()}),AL=b({enabled:v().default(!1),maxAttempts:f().int().min(1).max(5).default(1)}),LCe={totalMs:6e4,connectMs:1e4,firstTokenMs:12e4,idleMs:6e4},jL=b({addonId:p().optional(),profileId:p().optional(),consumer:p(),system:p().optional(),prompt:p(),jsonSchema:u(p(),l()).optional(),maxTokens:f().int().positive().optional(),temperature:f().optional(),topP:f().min(0).max(1).optional(),topK:f().int().positive().optional(),reasoningEffort:x([`off`,`low`,`medium`,`high`]).optional(),timeoutMs:f().int().positive().optional(),retry:AL.optional(),requestId:p().optional()}),ML=b({url:p(),filename:p(),sizeBytes:f(),sha256:p().optional()}),NL=i(`kind`,[b({kind:o(`catalog`),catalogId:p()}),b({kind:o(`url`),url:p(),sha256:p().optional(),label:p().optional(),sizeBytes:f().optional(),extraFiles:S(ML).optional()}),b({kind:o(`path`),path:p()})]),PL=b({nodeId:p(),engine:x([`llama-cpp`]),model:NL,contextSize:f().int().default(4096),gpuLayers:f().int().default(0),threads:f().int().optional(),parallel:f().int().default(1),batchSize:f().int().positive().optional(),ubatchSize:f().int().positive().optional(),flashAttention:v().default(!1),mlock:v().default(!1),noMmap:v().default(!1),cacheTypeK:x([`f32`,`f16`,`q8_0`,`q5_1`,`q5_0`,`q4_1`,`q4_0`]).optional(),cacheTypeV:x([`f32`,`f16`,`q8_0`,`q5_1`,`q5_0`,`q4_1`,`q4_0`]).optional(),extraArgs:S(p()).default([]),autoStart:v().default(!1),idleStopMinutes:f().int().default(30)}),FL=b({phase:x([`downloading`,`verifying`]),file:p(),fileIndex:f().int(),fileCount:f().int(),downloadedBytes:f(),totalBytes:f().optional()}),IL=b({nodeId:p(),state:x([`stopped`,`downloading`,`starting`,`ready`,`crashed`,`failed`]),pid:f().optional(),port:f().optional(),modelPath:p().optional(),modelId:p().optional(),downloadProgress:f().min(0).max(1).optional(),download:FL.optional(),lastError:p().optional(),crashesInWindow:f(),memoryBytes:f().optional(),vramBytes:f().optional()}),LL=b({file:p(),sizeBytes:f(),catalogId:p().optional(),installedAt:f().optional(),path:p().optional()}),RL=b({nodeId:p(),modelsBytes:f(),freeBytes:f().optional()}),zL=jL.extend({images:S(kL).optional(),runtime:PL,timeoutMs:f().int().positive().optional()}),BL=x([`deviceNotEligible`,`appleIntelligenceNotEnabled`,`modelNotReady`,`osTooOld`,`helperMissing`,`helperCrashed`]),VL=i(`state`,[b({state:o(`available`),osVersion:p(),contextSize:f().int().positive(),languages:S(p()),imageInput:v()}),b({state:o(`unavailable`),reason:BL,osVersion:p().nullable(),detail:p()}),b({state:o(`unsupported-platform`),platform:p()}),b({state:o(`unknown`),error:p()})]),HL=jL.extend({images:S(kL).optional(),timeoutMs:f().int().positive().optional()}),UL=b({requestId:p()}),WL={name:`llm-runtime`,scope:`system`,mode:`singleton`,internal:!0,methods:{complete:O(zL,OL,{kind:`mutation`,auth:`admin`,timeoutMs:SL}),ensureStarted:O(b({runtime:PL}),IL,{kind:`mutation`,auth:`admin`,timeoutMs:SL}),stop:O(b({}),_(),{kind:`mutation`,auth:`admin`}),status:O(b({}),IL,{auth:`admin`}),installModel:O(b({model:NL}),_(),{kind:`mutation`,auth:`admin`,timeoutMs:ICe}),deleteModel:O(b({file:p()}),_(),{kind:`mutation`,auth:`admin`}),listLocalModels:O(b({}),S(LL),{auth:`admin`}),getDiskUsage:O(b({}),RL,{auth:`admin`}),cancel:O(UL,_(),{kind:`mutation`,auth:`admin`}),appleAvailability:O(b({}),VL,{auth:`admin`}),completeApple:O(HL,OL,{kind:`mutation`,auth:`admin`,timeoutMs:SL})},vocabulary:{notOperatorFacing:A.ML}},GL=/^[a-z0-9][a-z0-9-]{0,63}$/,KL=p().regex(GL,`a kind id is lower-case letters, digits and dashes`),qL=b({vision:v(),tools:v(),streaming:v(),reasoning:v().nullable().optional()}),JL=b({id:p(),label:p().optional(),contextLength:f().int().positive().optional(),features:qL.partial().optional()}),YL=u(p(),l()),RCe=b({id:p(),name:p(),kind:KL,addonId:p(),enabled:v(),model:p(),supportsVision:v(),temperature:f().min(0).max(2).optional(),topP:f().min(0).max(1).optional(),topK:f().int().positive().optional(),maxTokens:f().int().positive().optional(),reasoningEffort:x([`off`,`low`,`medium`,`high`]).optional(),contextLength:f().int().positive().optional(),systemPrompt:p().optional(),timeoutMs:f().int().positive().default(6e4),connectTimeoutMs:f().int().positive().default(1e4),firstTokenTimeoutMs:f().int().positive().default(12e4),idleTimeoutMs:f().int().positive().default(6e4),retry:AL.default({enabled:!1,maxAttempts:1}),toolsEnabled:v().default(!1),providerConfig:YL.default({})}),XL=x([`temperature`,`topP`,`topK`,`maxTokens`,`reasoningEffort`,`contextLength`,`systemPrompt`,`timeoutMs`,`connectTimeoutMs`,`firstTokenTimeoutMs`,`idleTimeoutMs`,`retry`,`toolsEnabled`]),ZL=b({id:p(),placement:x([`connection`,`model`]),requires:S(p()).optional()}),QL=l(),zCe=b({kind:KL,label:p(),icon:p(),addonId:p(),connectionSchema:QL,advancedSchema:QL.optional(),features:qL,visionEditable:v(),modelCatalog:x([`fetch`,`static`,`none`]),staticModels:S(JL).optional(),profileFields:S(XL),providerWidgets:S(ZL).optional()}),$L=b({addonId:p(),kind:KL,profileId:p().optional(),connection:YL.optional()}),eR=x([`auth`,`network`,`unsupported`,`invalid`]),tR=i(`ok`,[b({ok:o(!0),models:S(JL)}),b({ok:o(!1),code:eR,message:p()})]),nR=c([b({consumer:p()}),b({purpose:x([`text`,`vision`])})]),rR=b({selector:nR,profileId:p()}),iR=b({day:p(),consumer:p(),profileId:p(),calls:f(),okCalls:f(),errorCalls:f(),inputTokens:f(),outputTokens:f(),avgLatencyMs:f()}),aR=b({id:p(),label:p(),family:p(),purpose:x([`text`,`vision`]),url:p(),sha256:p(),sizeBytes:f(),quantization:p(),minRamBytes:f(),contextSizeDefault:f().int(),mmprojUrl:p().optional()}),oR=i(`ok`,[b({ok:o(!0),model:NL,label:p(),repo:p(),quantization:p(),purpose:x([`text`,`vision`]),totalBytes:f(),extraFilenames:S(p())}),b({ok:o(!1),code:p(),message:p(),candidates:S(p()).optional(),requiredBytes:f().optional()})]),sR=b({nodeId:p(),reachable:v(),status:IL.optional(),disk:RL.optional(),error:p().optional(),apple:VL.optional()}),BCe=jL.extend({images:S(kL).min(1)}),cR=b({addonId:p(),profileId:p()}),lR={name:`llm`,scope:`system`,mode:`collection`,internal:!1,providerKind:`ai`,nodeIdMode:`data`,methods:{generate:O(jL,OL,{kind:`mutation`,timeoutMs:SL}),generateVision:O(BCe,OL,{kind:`mutation`,timeoutMs:SL}),cancel:O(b({addonId:p().optional(),requestId:p()}),_(),{kind:`mutation`}),listModels:O($L,tR,{kind:`mutation`,auth:`admin`}),getDefaults:O(b({}),S(rR)),setDefault:O(b({selector:nR,profileId:p().nullable()}),_(),{kind:`mutation`,auth:`admin`}),getUsage:O(b({since:f().optional(),until:f().optional(),consumer:p().optional(),profileId:p().optional()}),S(iR)),listModelCatalog:O(b({}),S(aR)),listRuntimeNodes:O(b({}),S(sR)),listNodeModels:O(b({nodeId:p()}),S(LL)),resolveModelRef:O(b({ref:p(),maxBytes:f().positive().optional()}),oR,{kind:`mutation`,auth:`admin`}),installModel:O(b({nodeId:p(),model:NL}),_(),{kind:`mutation`,auth:`admin`}),deleteModel:O(b({nodeId:p(),file:p()}),_(),{kind:`mutation`,auth:`admin`}),getRuntimeStatus:O(cR,IL),startRuntime:O(cR,IL,{kind:`mutation`,auth:`admin`}),stopRuntime:O(cR,_(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:A.ML}},uR=[`decode`,`transcode`,`recording`,`streaming`,`detection`],dR=[`measured`,`accounted`,`unattributable`],fR=b({role:x(uR),deviceId:f().int().positive().nullable(),attribution:x(dR),unit:p(),pid:f().int().positive().optional(),startedAtMs:f().optional(),cpuSeconds:f().optional(),rssBytes:f().optional()}),pR={name:`load-contribution`,scope:`system`,mode:`collection`,internal:!0,methods:{list:O(_(),S(fR).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:A.INTERNAL}},mR=`https://camstack.zentik.app`,hR=`/viewer/camstack`;function gR(e){if(e==null||e===``)return!1;try{return new URL(e).origin===mR}catch{return!1}}function VCe(e){let t=e.baseUrl??e.resolved;return gR(t)?{form:`app`,hubBaseUrl:e.appLinkHub??null}:{form:`hub`,hubBaseUrl:t}}function _R(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 HCe(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=_R(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 UCe(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 vR(e){return e.length===0?``:`?${e.map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join(`&`)}`}function WCe(e){let t=UCe(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:_R(r),n=e===null?t.query:[...t.query,[`hub`,e]];return`${mR}${t.path}${vR(n)}`}return r===``||gR(r)?null:`${r}${hR}${t.path}${vR(t.query)}`}var yR=[`appConnections`,`notificationTaps`,`internal`,`publicEndpoint`],GCe=[`notificationTaps`,`internal`,`publicEndpoint`];function KCe(e){return e!==`appConnections`}var qCe={appConnections:[],notificationTaps:null,internal:null,publicEndpoint:null},JCe=/^\d{1,3}(?:\.\d{1,3}){3}$/;function bR(e){try{let t=new URL(e).hostname;return t.length>0?t:null}catch{return null}}function YCe(e){return e.replace(/\/+$/,``)}function xR(e){return e.kind===`public`&&e.interfaceKind===`vpn`}function XCe(e){return e.kind===`public`&&e.interfaceKind===`public`}function SR(e){return(e.kind===`lan-ipv4`||e.kind===`lan-ipv6`)&&e.plausible}function CR(e){if(e.kind!==`lan-ipv4`||!e.plausible)return!1;let t=bR(e.baseUrl);return t!==null&&JCe.test(t)}function wR(e){return e.stable===!1}function ZCe(e,t){return t.kind===`loopback`||t.kind===`app-link`||t.kind===`custom`||bR(t.baseUrl)===null||wR(t)?null:e===`internal`?CR(t)?0:SR(t)?1:xR(t)?2:null:XCe(t)?0:xR(t)?1:CR(t)?2:SR(t)?3:null}var QCe=new Set([`localhost`,`0.0.0.0`,`::1`,`[::1]`,`::`,`[::]`]);function $Ce(e){let t=e.toLowerCase();return QCe.has(t)||t.endsWith(`.localhost`)?!0:/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(t)}function TR(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.`}:$Ce(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 ER=`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 DR(e,t,n={}){if(gR(t))return e===`notificationTaps`?{ok:!0,baseUrl:mR}:{ok:!1,reason:`The CamStack app link is not a hub address — only notification taps can use it.`};let r=TR(t);return r.ok&&e===`publicEndpoint`&&r.baseUrl.startsWith(`http:`)&&n.acceptInsecureHttp!==!0?{ok:!1,reason:ER}:r}function OR(e,t){if(t===null||t===``)return null;let n=DR(e,t,{acceptInsecureHttp:!0});return n.ok?n.baseUrl:null}function ewe(e,t){let n=e.flatMap(e=>{let n=ZCe(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:YCe(n.endpoint.baseUrl)}function kR(e,t,n){let r=OR(t,n);if(r!==null)return{flagged:r,resolved:r,source:`flagged`};let i=ewe(e,t);return{flagged:null,resolved:i,source:i===null?`none`:`auto`}}function AR(e,t){return kR(e,`internal`,t.internal)}function jR(e,t){return kR(e,`publicEndpoint`,t.publicEndpoint)}function MR(e){let t=OR(`notificationTaps`,e.notificationTaps);return t!==null&&!gR(t)?{flagged:t,resolved:t,source:`flagged`}:{flagged:null,resolved:mR,source:`auto`}}function NR(e){return wR(e)?!1:e.kind===`lan-ipv4`?!0:e.kind===`public`&&e.interfaceKind===`public`}function PR(e,t){let n=e.filter(NR);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 FR(e,t){let n=new Set(t.appConnections),r=PR(e,t),i=r.some(e=>n.has(e.baseUrl));return{flagged:t.appConnections,resolved:r.map(e=>e.baseUrl),source:r.length===0?`none`:i?`flagged`:`auto`}}function twe(e,t,n){return{appConnections:FR(e,n),notificationTaps:MR(n),internal:AR(t,n),publicEndpoint:jR(t,n)}}function nwe(e){return e===null?null:bR(e)}var rwe=`camstack`,iwe=`_camstack._tcp.local`,awe={nodeId:`nodeId`,version:`version`,role:`role`,url:`url`,hubId:`hubId`},owe=`hub`,IR=/^hub-[0-9a-f]{16}$/;function swe(e){return typeof e==`string`&&IR.test(e)}var cwe=`camstack-agent`,lwe=`_camstack-agent._tcp.local`,uwe={nodeId:`nodeId`,version:`version`,name:`name`,state:`state`,keyFingerprint:`fp`},dwe=x([`lan`,`wifi`,`docker`,`vpn`,`loopback`,`other`]),LR=b({name:p(),family:x([`IPv4`,`IPv6`]),address:p(),cidr:p(),netmask:p(),internal:v(),mac:p(),kind:dwe,preferred:v(),plausible:v(),plausibleReason:p()}),fwe=b({interfaces:S(LR).readonly(),probedAt:f()}),pwe=LR.nullable(),RR=b({label:p(),baseUrl:p(),kind:x([`lan-ipv4`,`lan-ipv6`,`public`,`loopback`,`app-link`,`custom`]),interfaceKind:x([`lan`,`wifi`,`docker`,`vpn`,`other`,`loopback`,`public`]),plausible:v(),plausibleReason:p(),priority:f(),stable:v().optional()}),mwe=x([`server-config`,`server-env`,`caller-hint`,`default`]),hwe=b({port:f().int().min(1).max(65535),source:mwe}),gwe=b({endpoints:S(RR).readonly(),localPort:hwe}),zR=b({baseUrl:p().nullable(),resolved:p().nullable(),appLinkHub:p().nullable()}),BR=b({baseUrls:S(p()).readonly(),resolved:S(p()).readonly()}),VR=b({override:p().nullable(),resolved:p().nullable(),source:x([`override`,`auto`,`none`])}),_we=b({cluster:VR,browser:VR}),HR=x(yR),UR=x([`flagged`,`auto`,`none`]),WR=b({flagged:p().nullable(),resolved:p().nullable(),source:UR}),vwe=b({flagged:S(p()).readonly(),resolved:S(p()).readonly(),source:UR}),GR=b({rows:S(RR.extend({detected:v(),custom:v(),flags:S(HR).readonly(),inUse:S(HR).readonly(),eligible:S(HR).readonly()})).readonly(),roles:b({appConnections:vwe,notificationTaps:WR,internal:WR,publicEndpoint:WR}),appLinkHub:p().nullable(),listenerOrigins:S(p()).readonly().optional()}),KR=b({addresses:S(p()).readonly()}),qR=b({mode:x([`generated`,`uploaded`,`disabled`]),leafFingerprintSha256:p().nullable(),caFingerprintSha256:p().nullable(),validTo:p().nullable(),sans:S(p()),caCertPem:p().nullable(),reissueError:p().nullable(),restartRequired:v(),caMissing:v(),localCaConstrained:v().nullable(),caReplacedAt:p().nullable(),storedUpload:b({leafFingerprintSha256:p(),validTo:p(),hasCa:v()}).nullable()}),ywe=b({providerId:p().min(1),modes:S(AA)}),bwe=b({providerId:p().optional(),mode:p().optional(),message:p()}),xwe=b({hostsProbed:f().int(),hits:f().int(),timeouts:f().int(),byMode:u(p(),b({probed:f().int(),hits:f().int(),timeouts:f().int()}))}),Swe=b({hits:S(b({providerId:p(),hit:jA})),subnetsScanned:S(p()),errors:S(bwe),stats:xwe}),JR={name:`local-network`,scope:`system`,mode:`singleton`,methods:{list:O(_(),fwe),getPreferred:O(_(),pwe),getConnectionEndpoints:O(b({port:f().int().min(1).max(65535).optional(),includeLoopback:v().optional(),ipv4Only:v().optional(),scheme:x([`http`,`https`]).optional(),includeAppLink:v().optional()}),gwe),getNotificationEndpoint:O(_(),zR),setNotificationEndpoint:O(b({baseUrl:p().nullable()}),zR,{kind:`mutation`}),getViewerEndpoints:O(_(),BR),setViewerEndpoints:O(b({baseUrls:S(p()).readonly()}),BR,{kind:`mutation`}),getAddresses:O(b({scheme:x([`http`,`https`]).optional()}).optional(),GR),addCustomAddress:O(b({baseUrl:p(),label:p().max(80)}),GR,{kind:`mutation`,auth:`admin`}),removeCustomAddress:O(b({baseUrl:p()}),GR,{kind:`mutation`,auth:`admin`}),setAddressRole:O(b({role:HR,baseUrl:p().nullable(),enabled:v(),acceptInsecureHttp:v().optional()}),GR,{kind:`mutation`,auth:`admin`}),getHubAddresses:O(_(),_we),getAllowedAddresses:O(_(),KR),setAllowedAddresses:O(KR,b({success:o(!0)}),{kind:`mutation`}),resetAllowlistToBestMatch:O(_(),KR,{kind:`mutation`}),getTlsStatus:O(_(),qR),regenerateCertificate:O(b({reason:p().optional()}),qR,{kind:`mutation`,auth:`admin`}),uploadCertificate:O(b({certPem:p().min(1),keyPem:p().min(1),caPem:p().optional()}),qR,{kind:`mutation`,auth:`admin`}),downloadCa:O(_(),b({pem:p()})),useStoredUploadedCertificate:O(_(),qR,{kind:`mutation`,auth:`admin`}),scanNetwork:O(b({requests:S(ywe),subnets:S(p()).optional()}),Swe,{kind:`mutation`,auth:`admin`,timeoutMs:9e4}),getScanSubnets:O(_(),b({subnets:S(p())}),{auth:`admin`}),setScanSubnets:O(b({subnets:S(p())}),b({subnets:S(p())}),{kind:`mutation`,auth:`admin`}),revertToGeneratedCertificate:O(_(),qR,{kind:`mutation`,auth:`admin`})},mount:{kind:`hub-only`},vocabulary:{notOperatorFacing:A.NETWORK}},YR=x([`locked`,`unlocked`,`locking`,`unlocking`,`jammed`,`door-open`]),XR=b({state:YR,lastChangedAt:f()}),Cwe={version:1,overridable:[{path:`state`,by:`door-contact`}],targets:[{id:`door-contact`,cardinality:`scalar`,vocabulary:{cap:`lock-control`,stateField:`state`},deviceTypes:[w.Lock],apply:`replace`,path:`state`,override:{whenSourceTrue:`door-open`,unlessNative:[`jammed`]},sources:[{kind:`binary`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}]},ZR={name:`lock-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Lock],methods:{lock:O(b({deviceId:f().int().nonnegative(),code:p().min(1).optional()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.lock`,label:N(`Lock`,`Chiudi a chiave`),phrase:N(`Lock {device}`,`Chiudi a chiave {device}`),icon:`lock`,effect:{field:`state`,value:`locked`},openArgs:[{key:`code`,label:N(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]}),unlock:O(b({deviceId:f().int().nonnegative(),code:p().min(1).optional(),confirm:v().optional()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.unlock`,label:N(`Unlock`,`Apri la serratura`),phrase:N(`Unlock {device}`,`Sblocca {device}`),icon:`lock-open`,effect:{field:`state`,value:`unlocked`},openArgs:[{key:`code`,label:N(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]}),open:k(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.open`,label:N(`Open latch`,`Apri lo scrocco`),phrase:N(`Release the latch of {device}`,`Fai scattare lo scrocco di {device}`),icon:`door-open`}]})},status:{schema:XR,kind:`push`},runtimeState:XR,customize:Cwe,durability:`restored`,history:{fields:{state:{kind:`enum`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:N(`Lock`,`Serratura`),order:1060,state:[{kind:`enum`,field:`state`,label:N(`Lock state`,`Stato della serratura`),values:[{value:`locked`,label:N(`Locked`,`Chiusa a chiave`),phrase:N(`When {device} locks`,`Quando {device} si chiude a chiave`)},{value:`unlocked`,label:N(`Unlocked`,`Sbloccata`),phrase:N(`When {device} unlocks`,`Quando {device} si sblocca`)},{value:`locking`,label:N(`Locking`,`In chiusura`),phrase:N(`When {device} starts locking`,`Quando {device} inizia a chiudersi`)},{value:`unlocking`,label:N(`Unlocking`,`In apertura`),phrase:N(`When {device} starts unlocking`,`Quando {device} inizia a sbloccarsi`)},{value:`jammed`,label:N(`Jammed`,`Inceppata`),phrase:N(`When {device} jams`,`Quando {device} si inceppa`)},{value:`door-open`,label:N(`Door open`,`Porta aperta`),phrase:N(`When the door of {device} opens`,`Quando la porta di {device} si apre`)}],icon:`lock`}]}},QR=b({armed:f().int().min(0),unknown:S(p()).readonly()}),$R={name:`log-channels`,scope:`system`,mode:`collection`,internal:!0,methods:{list:O(_(),S(Fm).readonly()),apply:O(b({windows:S(Im).readonly()}),QR,{kind:`mutation`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:A.INTERNAL}},ez=x([`debug`,`info`,`warn`,`error`]),tz=b({timestamp:h(),level:ez,scope:S(p()),message:p(),meta:u(p(),l()).optional(),tags:u(p(),p()).optional()}),nz=b({instanceId:p().min(1).max(200).optional(),requestId:p().min(1).max(64).optional(),deviceId:f().int().optional(),fromAddonId:p().min(1).max(200).optional(),fromNodeId:p().min(1).max(200).optional(),tags:u(p(),c([p(),f()])).optional(),level:ez.optional(),text:p().min(1).max(200).optional(),since:f().optional(),until:f().optional(),before:p().min(1).max(1024).optional(),after:p().min(1).max(1024).optional(),limit:f().int().min(1).max(1e3).optional(),budgetMs:f().int().min(50).max(1e4).optional()}),rz=b({id:p().optional(),timestamp:f(),level:ez,scope:p().optional(),message:p(),tags:u(p(),c([p(),f()])).optional(),meta:u(p(),l()).optional()}),iz=b({entries:S(rz),nextBefore:p().nullable(),nextAfter:p().nullable(),scannedBytes:f().int().nonnegative(),done:v(),cancelled:v().optional()}),wwe=b({instanceId:p().min(1).max(200).optional()}),az=b({readable:v(),reason:p().nullable(),filters:b({deviceId:v(),addonId:v(),nodeId:v(),tags:v(),level:v(),text:v(),timeRange:v()}),retentionDays:f().nullable()}),oz={name:`log-destination`,scope:`system`,mode:`collection`,internal:!0,methods:{write:O(tz,_(),{kind:`mutation`}),describeRead:k(wwe,az,{auth:`admin`}),read:k(nz,iz,{auth:`admin`}),cancelRead:k(b({requestId:p().min(1).max(64)}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:A.INTERNAL}},sz=x([`primary`,`second-factor`]),cz=b({kind:o(`redirect`),id:p(),label:p(),icon:p().optional(),startUrl:p(),stage:sz,linkable:v().optional(),app:Kh.nullable().optional()}),lz=b({kind:o(`widget`),id:p(),addonId:p(),bundle:p(),remote:Dx,stage:sz,app:Kh.nullable().optional()}),uz=b({kind:o(`passkey`),id:p(),label:p(),stage:sz,rpId:p(),origin:p().nullable(),app:Kh.nullable().optional()}),dz=i(`kind`,[cz,lz,uz]),fz={name:`login-method`,scope:`system`,mode:`collection`,internal:!0,methods:{getLoginMethods:O(_(),S(dz).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:A.IDENTITY}},Twe=b({id:p(),label:p(),scope:x([`mesh`,`public`]),url:p(),hostname:p(),port:f(),protocol:x([`http`,`https`])}),pz=b({id:p(),hostname:p(),magicDns:p(),addresses:S(p()).readonly(),os:p().optional(),online:v(),lastSeenMs:f(),isSelf:v(),connection:x([`direct`,`relay`,`idle`]),relay:p().nullable(),lastHandshakeMs:f(),rxBytes:f(),txBytes:f(),tags:S(p()).readonly(),exitNodeOption:v(),advertisedRoutes:S(p()).readonly(),userLogin:p().nullable(),keyExpiry:f().nullable()}),mz=b({joined:v(),meshIp:p(),magicDnsHostname:p(),peerCount:f(),endpoints:S(Twe).readonly(),error:p().optional(),tenantName:p(),magicDnsSuffix:p(),userLogin:p().nullable(),controlPlaneUrl:p(),keyExpiry:f().nullable(),daemonSocket:p().optional(),daemonCliPath:p().optional()}),hz={name:`mesh-network`,scope:`system`,mode:`collection`,providerKind:`mesh`,methods:{getStatus:O(_(),mz),join:O(b({authKey:p().min(8),hostname:p().optional()}),b({joined:o(!0)}),{kind:`mutation`}),startLogin:O(b({hostname:p().optional()}),b({loginUrl:p()}),{kind:`mutation`}),leave:O(_(),b({left:o(!0)}),{kind:`mutation`}),logout:O(_(),b({loggedOut:o(!0)}),{kind:`mutation`}),listPeers:O(_(),b({peers:S(pz).readonly()}))},vocabulary:{notOperatorFacing:A.NETWORK}},gz=b({value:f().nullable().meta(j(`device`,{label:`Total`})),lastFetchedAt:f()}),_z={name:`meter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Sensor],methods:{},status:{schema:gz,kind:`push`},runtimeState:gz,durability:`restored`,history:{fields:{value:{kind:`counter`,deadband:.001,minIntervalMs:6e4}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:N(`Meter`,`Contatore`),order:5140,state:[{kind:`numeric`,field:`value`,quantity:N(`the total`,`il totale`),label:N(`Total`,`Totale`),icon:`gauge`}]}},Ewe=b({total:f(),user:f(),system:f(),irq:f(),nice:f(),loadAvg:s([f(),f(),f()]),cores:f()}),Dwe=b({percent:f().nullable(),totalBytes:f(),usedBytes:f().nullable(),availableBytes:f().nullable(),swapUsedBytes:f(),swapTotalBytes:f()}),Owe=b({readBytes:f(),writeBytes:f(),readOps:f(),writeOps:f(),timestampMs:f()}),kwe=b({rxBytes:f(),txBytes:f(),rxPackets:f(),txPackets:f(),rxErrors:f(),txErrors:f(),timestampMs:f()}),vz=b({utilization:f(),model:p(),memoryUsedBytes:f(),memoryTotalBytes:f(),temperature:f().nullable()}),Awe=b({openFds:f(),threadCount:f(),activeHandles:f(),activeRequests:f()}),yz=b({avg10:f(),avg60:f(),avg300:f()}),bz=b({some:yz,full:yz.nullable()}),xz=b({cpu:Ewe,memory:Dwe,gpu:vz.nullable(),network:kwe,disk:Owe,pressure:b({cpu:bz.nullable(),memory:bz.nullable(),io:bz.nullable()}),process:Awe,cpuTemperature:f().nullable(),timestampMs:f()}),jwe=b({path:p(),totalBytes:f(),usedBytes:f(),availableBytes:f(),percent:f()}),Sz=b({pid:f(),cpu:f(),memory:f(),privateBytes:f().optional(),sharedBytes:f().optional()}),Mwe=b({addonId:p(),nodeId:p(),role:x([`hub`,`worker`]),pid:f(),state:x([`starting`,`running`,`stopping`,`stopped`,`crashed`]),uptimeSec:f()}),Nwe=b({pid:f(),ppid:f(),pgid:f(),classification:x([`root`,`managed`,`system`]),addonId:p().nullable(),nodeId:p().nullable(),command:p(),cpuPercent:f(),memoryRssBytes:f(),cpuMainPercent:f().nullable(),cpuGcPercent:f().nullable(),threadCount:f().nullable(),uptimeSec:f()}),Pwe=b({source:x([`cgroup-v2`,`cgroup-v1`]),currentBytes:f(),limitBytes:f().nullable(),anonBytes:f().nullable(),fileBytes:f().nullable(),shmemBytes:f().nullable(),slabBytes:f().nullable(),gpuShmemBytes:f().nullable()}).extend({atMs:f()}),Fwe=b({atMs:f(),samples:f().int(),cpuMainPercent:f().nullable(),cpuMainPercentMin:f().nullable(),cpuGcPercent:f().nullable(),cpuGcPercentMin:f().nullable(),cpuLifetimePercent:f(),cpuLifetimePercentMin:f(),memoryRssBytes:f(),memoryRssBytesMin:f(),processCount:f().int(),processCountMin:f().int()}),Iwe=b({key:p(),kind:x([`addon`,`root`,`unattributed`]),points:S(Fwe).readonly()}),Lwe=b({nodeId:p(),series:S(Iwe).readonly(),containerMemory:S(Pwe).readonly(),bucketMs:f(),retainedSamples:f(),oldestAtMs:f().nullable(),cadenceMs:f(),durable:v()}),Rwe=b({forNodeId:p(),sinceMs:f().optional(),maxPoints:f().int().positive().optional()}),Cz=b({cpuPercent:f(),memoryPercent:f().nullable(),memoryUsedMB:f().nullable(),memoryTotalMB:f(),diskPercent:f().optional(),temperature:f().optional(),gpuPercent:f().optional(),gpuMemoryPercent:f().optional()}),wz={name:`metrics-provider`,scope:`system`,mode:`singleton`,methods:{collectSnapshot:O(_(),xz),getCached:O(_(),xz.nullable()),getCurrent:O(_(),Cz),getDiskSpace:O(b({dirPath:p()}),jwe),getGpuInfo:O(_(),vz.nullable()),getCpuTemperature:O(_(),f().nullable()),getProcessStats:O(b({pids:S(f())}),S(Sz)),listAddonInstances:O(_(),S(Mwe).readonly()),getAddonStats:O(b({addonId:p()}),Sz.nullable()),listNodeProcesses:O(_(),S(Nwe).readonly()),getLoadSeries:O(Rwe,Lwe)},vocabulary:{notOperatorFacing:A.CLUSTER}},Tz=p().min(1).max(256),Ez=u(p(),l()),Dz=b({id:Tz,deviceId:f().int().optional(),at:f().int().optional(),expiresAt:f().int().optional(),data:Ez}),Oz=b({id:p(),deviceId:f().int().nullable(),at:f().nullable(),expiresAt:f().nullable(),rev:f().int(),updatedAt:f(),data:Ez}),kz=u(Ur,c([p(),f(),v(),b({in:S(c([p(),f(),v()])).min(1).max(_n)}),b({gt:c([p(),f()]).optional(),gte:c([p(),f()]).optional(),lt:c([p(),f()]).optional(),lte:c([p(),f()]).optional()}).refine(e=>Object.keys(e).length>0,{message:`name at least one bound`})])),Az={kind:Yr},jz={deviceId:f().int().optional(),atFrom:f().optional(),atTo:f().optional()},Mz=b({...Az,...jz,where:kz.optional(),order:x([`at`,`id`]).optional(),desc:v().optional(),limit:f().int().min(1).max(yn).default(100),cursor:p().min(1).optional()}),Nz=b({records:S(Oz),nextCursor:p().nullable()}),zwe=x([`created`,`unchanged`,`updated`]),Pz=b({kindId:f().int(),state:zwe,createdIndexes:S(p())}),Fz=S(p()),Iz=i(`op`,[b({op:o(`put`),kind:Yr,record:Dz,ifRev:f().int().min(0).optional()}),b({op:o(`patch`),kind:Yr,id:Tz,data:Ez,at:f().int().nullable().optional(),expiresAt:f().int().nullable().optional(),ifRev:f().int().min(1).optional()}),b({op:o(`delete`),kind:Yr,id:Tz})]),Lz=u(p(),u(p(),p())),Rz={name:`records`,scope:`system`,mode:`singleton`,internal:!0,methods:{declareKinds:O(b({kinds:u(Yr,Jr)}),b({kinds:u(p(),Pz)}),{kind:`mutation`,auth:`admin`}),get:O(b({...Az,id:Tz}),Oz.nullable(),{auth:`admin`}),getMany:O(b({...Az,ids:S(Tz).min(1).max(_n)}),S(Oz),{auth:`admin`}),secretRefs:O(b({...Az,ids:S(Tz).min(1).max(_n)}),Lz,{auth:`admin`}),put:O(b({...Az,record:Dz,ifRev:f().int().min(0).optional()}),b({rev:f().int(),releasedRefs:Fz}),{kind:`mutation`,auth:`admin`}),putMany:O(b({...Az,records:S(Dz).min(1).max(_n)}),b({count:f().int(),releasedRefs:Fz}),{kind:`mutation`,auth:`admin`}),patch:O(b({...Az,id:Tz,data:Ez,at:f().int().nullable().optional(),expiresAt:f().int().nullable().optional(),ifRev:f().int().min(1).optional()}),b({rev:f().int(),releasedRefs:Fz}),{kind:`mutation`,auth:`admin`}),delete:O(b({...Az,id:Tz}),b({deleted:v(),secretRefs:Fz}),{kind:`mutation`,auth:`admin`}),deleteMany:O(b({...Az,ids:S(Tz).min(1).max(_n)}),b({deleted:f().int(),secretRefs:Fz}),{kind:`mutation`,auth:`admin`}),query:O(Mz,Nz,{auth:`admin`}),count:O(b({...Az,...jz,where:kz.optional()}),b({count:f().int()}),{auth:`admin`}),histogram:O(b({...Az,deviceId:f().int().optional(),from:f(),to:f(),bucketMs:f().int().positive()}),b({buckets:S(b({bucketStart:f(),count:f().int()}))}),{auth:`admin`}),aggregate:O(b({...Az,op:x([`sum`,`min`,`max`,`count`]),field:Ur.optional(),groupBy:Ur.optional(),where:kz.optional()}),b({rows:S(b({group:c([p(),f(),ie()]),value:f().nullable()}))}),{auth:`admin`}),deleteWhere:O(b({...Az,deviceId:f().int().optional(),atBefore:f().optional(),where:kz.optional()}),b({deleted:f().int(),secretRefs:Fz}),{kind:`mutation`,auth:`admin`}),transact:O(b({ops:S(Iz).min(1).max(_n)}),b({results:S(b({rev:f().int().nullable(),deleted:v()})),releasedRefs:Fz,secretRefs:Fz}),{kind:`mutation`,auth:`admin`}),deleteDevice:O(b({deviceId:f().int(),kinds:S(Yr).optional()}),b({deleted:u(p(),f().int()),secretRefs:Fz}),{kind:`mutation`,auth:`admin`}),allocateId:O(b(Az),b({id:f().int()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:A.INTERNAL}},zz=u(p(),l()),Bz=b({integrationId:p().min(1)}),Vz=b({id:p().min(1)}),Hz=b({id:p(),deviceId:f().int().nullable(),at:f().nullable(),expiresAt:f().nullable(),rev:f().int(),updatedAt:f(),data:zz}),Uz={id:p().min(1),deviceId:f().int().optional(),at:f().int().optional(),expiresAt:f().int().optional(),data:zz},Wz=b({id:p(),addonId:p(),name:p(),info:zz,enabled:v().optional(),originStableId:p().optional()}),Bwe=b({id:f().int(),integrationId:p().nullable().optional(),parentDeviceId:f().int().nullable().optional(),type:p().optional(),name:p().optional(),stableId:p().optional()}),Gz=b({version:f().int(),methods:S(p())}),Kz=b({message:p(),meta:zz.optional(),tags:b({deviceId:f().int().optional()}).optional()}),Vwe={"ledger.declare":{input:b({owner:p().min(1),metas:S(Pd)}),output:b({bootId:p(),snapshot:x([`none`,`written`,`refused`]),steps:S(Jd),migrationApi:Gz.optional()}),behaviours:[`ledger.declare.answers-steps-in-engine-order`,`ledger.declare.answers-the-migration-api`]},"ledger.start":{input:b({id:p().min(1)}),output:b({proceed:v(),state:c([o(`pending`),Wd]),reason:p().nullable()}),behaviours:[`ledger.start.proceeds-when-predecessors-applied`]},"ledger.finish":{input:b({id:p().min(1),result:Ud}),output:b({status:Wd,error:p().nullable(),rowsChanged:f().int().nonnegative()}),behaviours:[`ledger.finish.records-the-outcome`]},"legacyRows.read":{input:Bz,output:zz,behaviours:[`legacyRows.read.returns-stored-rows`,`legacyRows.read.absent-store-is-empty`,`legacyRows.caller.sibling-package`]},"legacyRows.clear":{input:Bz,output:b({rows:f().int().nonnegative(),secrets:f().int().nonnegative()}),behaviours:[`legacyRows.clear.deletes-the-rows`,`legacyRows.clear.absent-store-is-noop`]},"legacyRows.patch":{input:Bz.extend({patch:zz}),output:b({written:v()}),behaviours:[`legacyRows.patch.upserts-keys-and-keeps-the-rest`,`legacyRows.patch.absent-store-writes-nothing`]},"legacyRows.deleteKeys":{input:Bz.extend({keys:S(p().min(1))}),output:b({present:v(),removed:zz}),behaviours:[`legacyRows.deleteKeys.removes-the-named-keys`,`legacyRows.deleteKeys.absent-store-reports-not-present`]},"records.get":{input:Vz,output:Hz.nullable(),behaviours:[`records.get.returns-the-row-or-null`]},"records.getResolved":{input:Vz,output:Hz.nullable(),behaviours:[`records.getResolved.resolves-secret-fields`]},"records.put":{input:b({...Uz,ifRev:f().int().optional()}),output:b({rev:f().int()}),behaviours:[`records.put.creates-and-replaces`,`records.put.if-rev-conflict-throws`]},"records.putMany":{input:b({records:S(b(Uz))}),output:b({count:f().int().nonnegative()}),behaviours:[`records.putMany.writes-every-row`]},"records.patch":{input:Vz.extend({partial:zz,ifRev:f().int().optional()}),output:b({rev:f().int()}),behaviours:[`records.patch.merges-and-null-removes`]},"records.delete":{input:Vz,output:b({deleted:v()}),behaviours:[`records.delete.reports-whether-a-row-went`]},"records.query":{input:b({deviceId:f().int().optional(),atFrom:f().optional(),atTo:f().optional(),where:kz.optional(),limit:f().int().min(1).optional(),cursor:p().min(1).optional(),resolveSecrets:v().optional()}),output:b({records:S(Hz),nextCursor:p().nullable()}),behaviours:[`records.query.pages-with-a-cursor`,`records.query.filters-on-a-declared-index`]},"records.deleteWhere":{input:b({deviceId:f().int().optional(),atBefore:f().optional(),where:kz.optional()}),output:b({count:f().int().nonnegative()}),behaviours:[`records.deleteWhere.deletes-the-matching-rows`]},"settings.read":{input:b({}),output:b({store:zz}),behaviours:[`settings.read.returns-the-addon-store`]},"settings.write":{input:b({patch:zz}),output:b({}),behaviours:[`settings.write.merges-and-keeps-other-keys`]},"settings.deleteKeys":{input:b({keys:S(p().min(1))}),output:b({removed:S(p())}),behaviours:[`settings.deleteKeys.removes-only-the-named-keys`]},"deviceSettings.listIds":{input:b({}),output:b({deviceIds:S(f().int())}),behaviours:[`deviceSettings.listIds.names-only-the-addons-own-devices`]},"deviceSettings.read":{input:b({deviceIds:S(f().int())}),output:b({blobs:u(p(),zz)}),behaviours:[`deviceSettings.read.returns-only-the-addons-own-blobs`]},"secrets.resolve":{input:b({refs:S(p())}),output:b({values:u(p(),p().nullable())}),behaviours:[`secrets.resolve.answers-null-for-a-missing-ref`]},"secrets.put":{input:b({ref:p().min(1),value:p()}),output:b({}),behaviours:[`secrets.put.stores-under-the-owner`]},"secrets.delete":{input:b({refs:S(p())}),output:b({deleted:f().int().nonnegative()}),behaviours:[`secrets.delete.ignores-unknown-refs`]},"integrations.list":{input:b({}),output:b({integrations:S(Wz)}),behaviours:[`integrations.list.lists-every-integration`]},"integrations.get":{input:b({id:p().min(1)}),output:Wz.nullable(),behaviours:[`integrations.get.null-for-an-unknown-id`]},"devices.list":{input:b({addonId:p().min(1),integrationId:p().min(1).optional()}),output:b({devices:S(Bwe)}),behaviours:[`devices.list.scoped-to-the-addon`,`devices.list.filters-by-integration`]},"devices.get":{input:b({deviceId:f().int()}),output:b({id:f().int(),integrationId:p().nullable(),hasConfig:v()}).nullable(),behaviours:[`devices.get.null-for-an-unknown-id`,`devices.get.reports-link-and-config`]},"devices.aliases":{input:b({deviceIds:S(f().int())}),output:b({aliases:u(p(),p())}),behaviours:[`devices.aliases.answers-for-the-named-ids-only`]},"devices.setIntegrationId":{input:b({deviceId:f().int(),integrationId:p().min(1)}),output:b({}),behaviours:[`devices.setIntegrationId.links-the-device`]},"node.localNodeId":{input:b({}),output:b({nodeId:p()}),behaviours:[`node.localNodeId.names-this-node`]},"log.info":{input:Kz,output:b({}),behaviours:[`log.info.writes-a-line`]},"log.warn":{input:Kz,output:b({}),behaviours:[`log.warn.writes-a-line`]}},qz={name:`migrations`,scope:`system`,mode:`singleton`,internal:!0,methods:{listLedger:O(b({}),b({entries:S(Gd)}),{auth:`admin`}),listPending:O(b({owner:p().optional()}),b({pending:S(Kd)}),{auth:`admin`}),dryRun:O(b({id:p().min(1)}),qd,{auth:`admin`}),markFailed:O(b({id:p().min(1),error:p().min(1)}),Gd,{kind:`mutation`,auth:`admin`}),retry:O(b({id:p().min(1)}),b({entries:S(Gd)}),{kind:`mutation`,auth:`admin`}),restorePreMigration:O(b({database:bd,snapshotId:p().min(1)}),b({scheduled:v(),held:S(p()),restartRequired:v()}),{kind:`mutation`,auth:`admin`}),declareOwner:O(b({owner:p().min(1),metas:S(Pd),retired:S(p().min(1)).optional()}),b({bootId:p(),snapshot:x([`none`,`written`,`refused`]),steps:S(Jd),migrationApi:Gz.optional()}),{kind:`mutation`,auth:`admin`}),startMigration:O(b({id:p().min(1)}),b({proceed:v(),state:c([o(`pending`),Wd]),reason:p().nullable()}),{kind:`mutation`,auth:`admin`}),finishMigration:O(b({id:p().min(1),result:Ud}),b({status:Wd,error:p().nullable(),rowsChanged:f().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),readLegacyIntegrationRows:O(b({integrationId:p().min(1)}),u(p(),l()),{auth:`admin`}),clearLegacyIntegrationRows:O(b({integrationId:p().min(1)}),b({rows:f().int().nonnegative(),secrets:f().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),patchLegacyIntegrationRows:O(b({integrationId:p().min(1),patch:u(p(),l())}),b({written:v()}),{kind:`mutation`,auth:`admin`}),deleteLegacyIntegrationRowKeys:O(b({integrationId:p().min(1),keys:S(p().min(1))}),b({present:v(),removed:u(p(),l())}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:A.INTERNAL}},Jz=b({sourceUrl:p(),metadata:bue,targets:S(yue).min(1).readonly(),calibrationRef:p().optional(),sessionId:p().optional()}),Yz={name:`model-convert`,scope:`system`,mode:`singleton`,internal:!0,methods:{convert:O(Jz,Sue,{kind:`mutation`,auth:`admin`,timeoutMs:6e5})},vocabulary:{notOperatorFacing:A.ML}},Xz=b({targetNodeId:p(),modelId:p(),format:x(ba),entry:Nh}),Zz=b({ok:v(),sha256:p(),bytes:f(),path:p()}),Qz={name:`model-distributor`,scope:`system`,mode:`singleton`,internal:!0,methods:{distributeModel:O(Xz,Zz,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:A.ML}},$z=i(`kind`,[b({kind:o(`camera`)}),b({kind:o(`sensor`),deviceId:f().int().positive()})]),eB=Object.freeze({kind:`camera`});function Hwe(e){if(e===void 0)return{triggeredBy:eB,malformed:!1};let t=$z.safeParse(e);return t.success?{triggeredBy:t.data,malformed:!1}:{triggeredBy:eB,malformed:!0}}var Uwe=`cameraSensors`,Wwe=8,tB=b({addonId:p().min(1),stableId:p().min(1)});function nB(e){return`${e.addonId}/${e.stableId}`}var rB=x([`in-addition`,`confirm`,`replace`]),iB=`in-addition`,aB=tB.extend({mode:rB.default(iB)}),oB=b({sensors:S(aB).min(1).max(8)}).superRefine((e,t)=>{let n=new Set;e.sensors.forEach((e,r)=>{let i=nB(e);n.has(i)&&t.addIssue({code:`custom`,path:[`sensors`,r],message:`duplicate camera sensor ${i}`}),n.add(i)})}),sB={addonId:p(),stableId:p(),mode:rB.default(iB)},cB=i(`state`,[b({...sB,state:o(`ready`),deviceId:f(),name:p(),caps:S(p()).readonly()}),b({...sB,state:o(`offline`),deviceId:f(),name:p(),reason:x([`offline`,`disabled`])}),b({...sB,state:o(`missing`),reason:p()}),b({...sB,state:o(`unsupported`),deviceId:f(),name:p(),reason:p()}),b({...sB,state:o(`unreadable`),reason:p()})]),lB=x([`onboard-not-listed`,`no-active-detection`]),uB=x([`always`,`when-confirmed`,`never`]),dB=x([`provider-not-split`]),fB=b({detected:v(),atMs:f()}),pB=i(`state`,[b({state:o(`not-configured`),cameraLevel:fB.optional()}),b({state:o(`unreadable`),reason:p(),cameraLevel:fB.optional()}),b({state:o(`configured`),cameraLevel:fB.optional(),sensors:S(cB).readonly(),cameraMotion:uB.optional(),notForwarded:lB.optional(),notEnforced:dB.optional()})]),Gwe=Object.freeze({state:`unreadable`,reason:`camera sensor mappings not loaded`}),mB=b({bbox:bS,pixelCount:f(),intensity:f()}),hB=b({detected:v(),regionCount:f(),regions:S(mB).readonly(),rawRegions:S(mB).readonly(),frameWidth:f(),frameHeight:f(),analysisMs:f()}),gB={name:`motion-detection`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[w.Camera],exposesDeviceSettings:!0,methods:{analyze:O(b({deviceId:f(),frame:yS.optional(),frameHandle:ta.optional()}),hB,{role:`admin`,kind:`mutation`,notOperatorFacing:`the pipeline feeds it frames — an internal stage, never called by a person`}),removeCamera:O(b({deviceId:f()}),_(),{role:`admin`,kind:`mutation`,notOperatorFacing:`pipeline housekeeping when a camera leaves`}),reset:O(_(),_(),{role:`admin`,kind:`mutation`,notOperatorFacing:`pipeline housekeeping`})},events:{onMotion:{data:b({deviceId:f(),detected:v(),regionCount:f()}),notOperatorFacing:"the analyzer’s raw verdict; the operator signal is the `motion` cap’s `detected` state"}},vocabulary:{noun:N(`Motion analysis`,`Analisi del movimento`),order:3160}},_B=b({package:v(),confidence:f().min(0).max(1),reason:p().min(1)}),vB=b({x:f(),y:f()}),yB=b({kind:o(`rect`),x:f(),y:f(),width:f(),height:f()}),bB=b({kind:o(`polygon`),points:S(vB)}),xB=b({kind:o(`grid`),gridWidth:f().meta(j(`none`)),gridHeight:f().meta(j(`none`)),cells:S(v())}),SB=b({kind:o(`line`),points:S(vB)}),Kwe=i(`kind`,[yB,bB,xB,SB]),CB=x([`rect`,`polygon`,`grid`,`line`]),wB=b({min:f(),max:f()}),TB=b({width:f(),height:f()}),EB=[`owner-not-ready`,`store-read-failed`,`three-way-read-unavailable`,`invalid-stored`,`not-cluster-scoped`],DB=[{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)`}]}],qwe=`cluster-step-models`;function OB(e){return`clusterModel:${e}`}function Jwe(e){return DB.some(t=>t.stepId===e)}var kB=Object.freeze(Object.fromEntries(DB.map(e=>[e.stepId,e.defaultModelId])));function AB(e){return e==null||e===``?{kind:`absent`}:typeof e==`string`?{kind:`chosen`,modelId:e}:{kind:`invalid`,value:e}}function jB(e){let t=[];for(let n of DB){let r=AB(e[OB(n.stepId)]);r.kind===`invalid`&&t.push({stepId:n.stepId,value:r.value})}return t}function MB(e){let t={};for(let n of DB){let r=AB(e[OB(n.stepId)]);t[n.stepId]=r.kind===`chosen`?r.modelId:n.defaultModelId}return t}function Ywe(e){return typeof e==`object`&&!!e&&`key`in e}function Xwe(e){return e===null?kB:MB(PB(e,NB()))}function Zwe(e){return e===null?[]:jB(PB(e,NB()))}function NB(){return new Set(DB.map(e=>OB(e.stepId)))}function PB(e,t){let n={};for(let r of e.sections)for(let e of r.fields)!Ywe(e)||typeof e.key!=`string`||t.has(e.key)&&(n[e.key]=e.value);return n}function Qwe(e,t){let n=DB.find(t=>t.stepId===e);if(n===void 0)return null;let r=t[e];return r!==void 0&&r!==``?r:n.defaultModelId}var $we=24,FB=[{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 IB(e,t){return`clusterStepSetting:${e}:${t}`}function eTe(e){return FB.filter(t=>t.stepId===e)}var tTe=f().finite();function LB(e){let t={};for(let n of FB){let r=tTe.safeParse(e[IB(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 RB=LB({});function nTe(e){return e===null?RB:LB(PB(e,new Set(FB.map(e=>IB(e.stepId,e.key)))))}function rTe(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 zB=x([`new`,`entered`,`left`,`moving`,`idle`]),BB=x([`motion`,`object`,`audio`]),VB=i(`kind`,[yB,bB]),HB=x([`motion`,`audio`,`person`,`vehicle`,`animal`,`door`,`pir`,`smoke`,`water`,`button`,`package`,`generic`]),UB=x([`motion`,`audio`,`detection`,`sensor`,`control`,`custom`,`package`]),iTe=x([`macro`,`sub`]),WB=b({kind:p(),labelKey:p(),label:p(),color:p(),iconId:p(),icon:HB,category:UB,parentKind:p().nullable(),level:iTe,source:b({capName:p(),deviceId:f()})}),GB=b({deviceId:f(),kinds:S(WB).readonly()}),KB=b({id:p(),deviceId:f(),sourceDeviceId:f(),kind:p(),value:u(p(),l()).nullable(),timestamp:f()}),qB=b({x:f(),y:f(),timestamp:f(),bbox:bS,source:x([`frame`,`recovery`]).optional(),score:f().optional()}),aTe=b({timestamp:f(),position:qB,mediaId:f().int()}),JB=b({minX:f(),minY:f(),maxX:f(),maxY:f()}),YB=x([`full`,`slim`]),XB=b({label:p(),peakScore:f(),count:f(),firstAt:f(),lastAt:f()}),ZB=x([`pipeline`,`onboard`,`sensor`,`audio`]),QB=x([`none`,`staging`,`trained`]),oTe=500,$B={markForTrain:v().optional(),debug:v().optional(),debugNote:p().max(500).optional(),favourited:v().optional()},eV={retrainStatus:QB.optional()},tV=b($B),nV=b({trackId:p(),markForTrain:v(),debug:v(),debugNote:p(),favourited:v(),retrainStatus:QB}),sTe=c([o(1),o(2)]),rV=b({stepId:p(),modelId:p().optional(),decidedAt:f(),identityId:p().optional()}),iV={label:p().optional(),labelScore:f().optional(),labelMeta:rV.optional(),subLabel:p().optional(),subLabelScore:f().optional(),subLabelMeta:rV.optional()},aV=b({deviceId:f(),tracks:f().int(),files:f().int(),bytes:f().int()}),oV=b({generatedAt:f(),trackCount:f().int(),fileCount:f().int(),byteCount:f().int(),truncated:v(),devices:S(aV).readonly()}),sV=b({nodeId:p(),deviceKey:p().optional(),modelId:p().optional()}),cV=b({trackId:p(),deviceId:f(),className:p(),...iV,producingDeviceName:p().optional(),source:ZB.optional(),firstSeen:f(),lastSeen:f(),positions:S(qB).readonly(),snapshots:S(aTe).readonly(),zonesVisited:S(p()).readonly(),zoneNames:S(p()).readonly().optional(),classes:S(p()).readonly().optional(),totalDistance:f(),state:zB,active:v(),importance:f().optional(),bestEventId:p().optional(),importanceReason:p().optional(),audioLabels:S(XB).readonly().optional(),envelope:JB.optional(),hasFace:v().optional(),hasEmbeddedFace:v().optional(),hasRider:v().optional(),previewMissReason:p().optional(),modelId:p().optional(),openedPlacement:sV.optional(),closedPlacement:sV.optional(),frameWidth:f().optional(),frameHeight:f().optional(),...$B,...eV}),lV={id:f().int(),deviceId:f(),timestamp:f()},uV=b({...lV,kind:o(`motion`),regionCount:f(),regions:S(b({bbox:bS,pixelCount:f(),intensity:f()})).readonly().optional(),frameWidth:f().optional(),frameHeight:f().optional(),mediaUrl:p().optional(),triggeredBy:$z.optional(),durationMs:f().nullable().optional(),edges:S(f()).readonly().optional()}),dV=x([`pipeline`,`onboard`]),fV=x([`enter`,`exit`]),pV=b({direction:fV,zoneId:p(),zoneName:p().optional()}),cTe=b({zoneId:p(),zoneName:p().optional(),overlapPct:f()}),mV=b({...lV,kind:o(`object`),source:dV.optional(),frameId:p().optional(),idempotencyKey:p().optional(),trackId:p().optional(),className:p(),...iV,confidence:f().optional(),bbox:bS.optional(),zones:S(p()).readonly().optional(),zoneOverlaps:S(cTe).readonly().optional(),spawnRefused:p().optional(),state:zB.optional(),zoneCrossing:pV.optional(),frameWidth:f().optional(),frameHeight:f().optional(),mediaId:f().int().optional(),keyFrameMediaId:f().int().optional(),mediaUrl:p().optional(),observedAt:f().optional(),packagePossible:v().optional(),packageLlmVerdict:_B.optional(),importance:f().optional()}),hV=b({...lV,kind:o(`audio`),rms:f(),dbfs:f(),classification:b({className:p(),originalClass:p().optional(),score:f()}).optional(),classifyOutcome:TS.optional(),mediaUrl:p().optional()}),gV=x([`crop`,`thumbnail`,`snapshot`,`firstFrame`,`lastFrame`,`fullFrame`,`fullFrameBoxed`,`faceCrop`,`plateCrop`,`keyFrame`,`keyFrameSmall`,`thumbnailSmall`,`confirmationCrop`,`debugCrop`,`sceneFrame`,`lastSceneFrame`]),_V=b({mediaId:f().int(),kind:gV,sizeBytes:f(),timestamp:f()}),vV=_V.extend({url:p(),base64:p()}),yV=vV.omit({base64:!0}),bV=x([`person`,`vehicle`,`animal`,`package`,`face`,`plate`]),xV=x([`subject`,`model_error`]),SV=x([`operator`,`assist`,`pipeline`,`llm`]),CV=b({x:f(),y:f(),w:f(),h:f()}),wV=b({source:SV,ref:p().min(1),bbox:CV,macroClass:bV,label:p().optional(),score:f().optional(),modelId:p().optional()}),TV=b({ref:p().min(1),snapshot:wV}),EV=x(Sf),DV=b({ref:p(),savedId:p().optional(),status:EV,approximate:v(),origin:wV.optional(),macroClass:bV.optional(),label:p().optional(),iou:f().optional()}),OV=b({boxes:S(DV).readonly(),summary:b({counts:u(EV,f().int()),total:f().int(),changed:f().int(),approximate:v()})}),kV=b({id:p(),trackId:p().optional(),deviceId:f(),mediaKey:p(),bbox:CV,macroClass:bV,label:p().optional(),subLabel:p().optional(),kind:xV,source:SV,assistModelId:p().optional(),assistScore:f().optional(),origin:wV.nullable().optional(),exportedInBatch:p().optional(),createdAt:f()}),AV=kV.omit({id:!0,trackId:!0,deviceId:!0,mediaKey:!0,createdAt:!0,exportedInBatch:!0}),jV=x([`correct`,`wrong`,`wrong-label`]),MV=b({verdict:jV,suggestedClass:p().optional(),suggestedMacroClass:bV.optional(),suggestedLabel:p().optional(),trackId:p(),at:f().optional()}),NV=b({trackId:p(),className:p(),label:p().optional(),bbox:CV.optional(),verdict:jV,suggestedClass:p().optional(),at:f().optional()}),PV=b({trackId:p(),deviceId:f(),className:p(),label:p().optional(),firstSeen:f(),lastSeen:f(),frameCount:f().int(),annotationCount:f().int(),verdict:MV.optional()}),FV=b({mediaId:f().int(),kind:gV,timestamp:f(),sizeBytes:f().int(),copied:v()}),IV=b({bbox:CV,macroClass:bV,label:p().optional(),subLabel:p().optional(),score:f().optional(),modelId:p().optional(),trackId:p(),basis:x([`subject-box`,`position`,`verdict`]),deltaMs:f()}),LV=x([`track`,`recording`]),RV=b({frameId:p(),deviceId:f(),origin:LV,trackId:p().optional(),sourceMediaId:f().int().optional(),epochMs:f().optional(),sourceKind:gV,sizeBytes:f().int(),width:f().int(),height:f().int(),copiedAt:f(),capturedAt:f().optional(),complete:v(),pipelineBoxes:S(IV).readonly().optional(),collectionIds:S(p()).readonly().optional(),verdict:MV.optional(),revision:f().int().optional(),dismissed:S(TV).readonly().optional(),review:OV.optional(),imageUrl:p().optional(),thumbnailUrl:p().optional()}),zV=x([`source-missing`,`unreadable-image`,`write-failed`]),BV=b({copied:S(RV).readonly(),refused:S(b({sourceMediaId:f().int(),reason:zV})).readonly()}),VV=b({candidates:S(FV).readonly(),copies:S(RV).readonly(),autoPickMediaId:f().int().optional()}),HV=x([`unannotated`,`annotated`,`complete`]),UV=b({workState:HV.optional(),deviceIds:S(f()).max(500).optional(),collectionId:p().optional(),classes:S(bV).optional(),page:f().int().positive().default(1),pageSize:f().int().positive().max(100).default(50)}),WV=RV.extend({workState:HV}),GV=b({frames:S(WV).readonly(),total:f().int().nonnegative(),page:f().int().positive(),pageSize:f().int().positive()}),KV=b({deviceId:f(),unannotated:f().int().nonnegative(),annotated:f().int().nonnegative(),complete:f().int().nonnegative(),pctOfCorpus:f().min(0).max(1).nullable()}),qV=b({total:f().int().nonnegative(),unannotated:f().int().nonnegative(),annotated:f().int().nonnegative(),complete:f().int().nonnegative(),cameras:S(KV).readonly()}),JV=b({deviceIds:S(f()).optional(),frameIds:S(p()).max(2e4).optional(),collectionIds:S(p()).max(200).optional(),collectionId:p().optional(),batchId:p().optional(),completeOnly:v().optional(),workState:HV.optional(),classes:S(bV).optional()}),YV=x([`frames`,`crops`]),XV=b({kind:o(`http`),method:x([`PUT`,`POST`]),url:p().url(),headers:u(p(),p()).optional()}),ZV=b({batchId:p(),frames:f().int(),crops:f().int(),annotations:f().int(),missing:f().int(),bytes:f().int(),sha256:p(),status:f().int()}),QV=i(`kind`,[b({kind:o(`package`),zone:CV.optional()}),b({kind:o(`objects`),modelId:p(),minScore:f().optional()})]),$V=i(`kind`,[b({kind:o(`proposed`),modelId:p(),stepId:p(),minScore:f(),proposals:S(AV).readonly(),belowThreshold:f().int()}),b({kind:o(`refused`),reason:p(),detail:p().optional()})]),eH=b({id:p(),name:p(),createdAt:f(),frameCount:f().int()}),tH=i(`kind`,[b({kind:o(`created`),collection:eH}),b({kind:o(`refused`),reason:x([`empty-name`,`duplicate-name`])})]),nH=i(`kind`,[b({kind:o(`renamed`),collection:eH}),b({kind:o(`refused`),reason:x([`empty-name`,`duplicate-name`,`unknown-collection`])})]),rH=i(`kind`,[b({kind:o(`added`),collectionId:p(),frame:RV,reused:v()}),b({kind:o(`refused`),reason:x([`unknown-collection`,`still-unavailable`,`still-busy`,`unreadable-image`,`write-failed`]),detail:p().optional()})]),iH=b({id:p(),name:p(),model:p(),kind:p(),leavesHouse:v()}),aH=AV.extend({reason:p()}),oH=b({ref:p(),verdict:x([`confirmed`,`wrong-class`,`not-an-object`,`uncertain`]),suggestedClass:bV.optional(),reason:p()}),sH=i(`kind`,[b({kind:o(`proposed`),profileId:p(),model:p(),leftHouse:v(),proposals:S(aH).readonly(),reviews:S(oH).readonly(),rejected:f().int()}),b({kind:o(`refused`),reason:x([`unknown-frame`,`unreadable-frame`,`unknown-profile`,`profile-disabled`,`no-vision`,`cloud-not-confirmed`,`llm-error`,`malformed-answer`]),detail:p().optional()})]),cH=b({deviceIds:S(f()).readonly().optional(),collectionIds:S(p()).max(200).readonly().optional(),frameIds:S(p()).max(2e4).readonly().optional()}),lH=b({frames:f().int(),completeFrames:f().int(),completeness:f(),subjects:f().int(),modelErrors:f().int(),hardNegatives:f().int(),cells:S(b({macroClass:p(),deviceId:f(),lighting:x([`day`,`night`,`unknown`]),subjects:f().int(),frames:f().int()})).readonly(),cameras:S(b({deviceId:f(),frames:f().int(),completeFrames:f().int()})).readonly()}),lTe=b({id:p(),name:p(),createdAt:f(),selection:cH,layout:YV,completeOnly:v(),frameCount:f().int(),annotationHash:p(),manifestSchema:p(),stats:lH}),uH=b({collectionIds:S(p()).min(1),workState:x([`complete`,`annotated_or_complete`,`any_annotated`]).default(`complete`)}),dH=i(`kind`,[b({kind:o(`resolved`),frameIds:S(p()).max(2e4).readonly(),stats:lH,annotationHash:p(),layout:YV}),b({kind:o(`refused`),reason:x([`unknown-collection`,`no-frames`]),detail:p()})]),fH=b({trackId:p(),retrainStatus:QB,changed:v(),reason:x([`unknown-track`,`no-frames-copied`,`not-staging`,`not-trained`,`unchanged`]).optional()}),pH=1e3,mH=5e3,hH=b({deviceId:f(),since:f().optional(),until:f().optional(),limit:f().int().min(1).max(mH).default(pH),projection:x([`full`,`slim`]).optional()}),uTe=hH.extend({classFilter:p().optional()}),gH=b({deviceIds:S(f()),since:f().optional(),until:f().optional(),limit:f().int().min(1).max(1e3).default(200),cursor:p().optional(),projection:YB.optional(),includeStationary:v().optional(),classes:S(p()).optional(),excludeSources:S(ZB).optional()}),_H=b({tracks:S(cV).readonly(),nextCursor:p().nullable()}),vH=50,yH=200,dTe=b({deviceId:f(),since:f(),until:f(),limit:f().int().min(1).max(yH).default(vH),minImportance:f().min(0).max(1).optional(),classFilter:p().optional()}),bH=b({id:p(),trackId:p(),timestamp:f(),className:p(),...iV,importance:f(),bestEventId:p(),windowMs:f().optional(),audioLabels:S(XB).readonly().optional(),...$B,...eV}),fTe=b({deviceIds:S(f()).min(1).max(200),since:f(),until:f(),limit:f().int().min(1).max(yH).default(vH),minImportance:f().min(0).max(1).optional(),classFilter:p().optional()}),pTe=b({deviceId:f(),events:S(bH).readonly()}),xH=b({bucketStart:f(),motion:f().int(),object:f().int(),audio:f().int(),audioDbfs:f().optional()}),mTe=200,SH=b({deviceId:f(),read:x([`read`,`unreadable`]),buckets:S(xH).readonly()}),hTe=b({trackId:p(),className:p(),confidence:f(),bbox:bS,zones:S(p()).readonly(),state:zB}),gTe=a({id:p(),kind:x([`first-level`,`detail`]),macroClass:p(),score:f(),bbox:b({x:f(),y:f(),width:f(),height:f()}),labels:S(a({label:p(),score:f()})).readonly(),parentId:p().optional()}),CH=mV.extend({score:f()}),_Te=b({text:p(),deviceId:f().optional(),since:f().optional(),until:f().optional(),classFilter:p().optional(),limit:f().default(50),minScore:f().min(0).max(1).optional(),strictness:yh.optional(),modelId:p().min(1).optional()}),wH=b({tracks:f().int(),events:f().int(),media:f().int(),faces:f().int(),plates:f().int(),embeddings:f().int()}),vTe=b({mediaDropped:f().int(),tracks:f().int(),events:f().int()}),yTe=b({deviceId:f(),rows:f().int(),bytes:f().int()}),bTe=b({totalRows:f().int(),totalBytes:f().int(),devices:S(yTe).readonly()}),xTe=b({kind:gV,rows:f().int(),bytes:f().int()}),STe=b({totalRows:f().int(),totalBytes:f().int(),kinds:S(xTe).readonly(),unaccountedRows:f().int(),unaccountedBytes:f().int()}),TH=b({motion:f().int(),object:f().int(),audio:f().int()}),CTe=b({deviceId:f().optional(),since:f().optional(),until:f().optional(),maxTracks:f().int().positive().optional(),executeOnNodeId:p().optional(),pacingMs:f().int().nonnegative().optional(),force:v().optional()}),wTe=b({deleted:f(),failedIndexes:S(p()).optional()}),EH=x([`stores-unavailable`,...EB,`method-unavailable`,`read-failed`,`reads-disagree`,`not-a-clip-model`,`force-requires-max-tracks`]),TTe=b({started:v(),alreadyRunning:v(),refusal:EH.optional(),modelId:p().optional(),index:p().optional()}),ETe=b({running:v(),scanned:f(),rebuilt:f(),missingKeyFrame:f(),missingEvent:f(),missingBbox:f(),boxSource:b({subjectBox:f(),positions:f(),event:f(),refused:f()}),alreadyInSpace:f(),force:v().nullable(),forcedInSpace:f(),notRunnable:f(),noCapableNode:f(),failed:f(),complete:v().nullable(),startedAtMs:f().nullable(),finishedAtMs:f().nullable(),error:p().nullable(),modelId:p().nullable(),index:p().nullable()}),DTe=b({started:v(),alreadyRunning:v()}),OTe=b({mode:x([`report`,`reclaim`]).default(`report`),scopes:S(x([`motion-still`,`track-filmstrip`])).min(1).optional(),deviceIds:S(f().int()).min(1).optional(),restart:v().optional(),pageSize:f().int().min(50).max(5e3).optional(),maxRowsPerDevice:f().int().min(1).max(5e5).optional(),maxReclaimPerDevice:f().int().min(1).max(5e5).optional(),maxBytesPerRun:f().int().min(1).optional(),budgetMinutes:f().int().min(1).max(720).optional(),throttleBytesPerSec:f().int().min(64*1024).optional(),graceMinutes:f().int().min(1).max(10080).optional()}),kTe=b({running:v(),mode:x([`report`,`reclaim`]).nullable(),totalExamined:f(),totalEligible:f(),totalReclaimed:f(),totalBytesReclaimed:f(),totalRefused:f(),devicesDone:f(),complete:v().nullable(),startedAtMs:f().nullable(),finishedAtMs:f().nullable(),error:p().nullable()}),DH=x([`motion`,`audio-dbfs`,`battery`,`occupancy`]),ATe=`|`;function jTe(e,t){let n=e??``;return t===void 0?n:`${n}|${t}`}function MTe(e){let t=e.indexOf(`|`);return t<0?{zoneId:e}:{zoneId:e.slice(0,t),className:e.slice(t+1)}}var OH=b({scope:p(),bucketStart:f().int(),samples:f().int().nonnegative(),sum:f(),min:f(),max:f()}),kH={name:`pipeline-analytics`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[w.Camera],exposesDeviceSettings:!0,methods:{getActiveTracks:O(b({deviceId:f()}),S(cV).readonly()),getTrack:O(b({deviceId:f(),trackId:p()}),cV.nullable()),listTracks:O(b({deviceId:f(),since:f().optional(),until:f().optional(),limit:f().optional(),zone:VB.optional(),projection:YB.optional(),includeStationary:v().optional(),classes:S(p()).optional(),excludeSources:S(ZB).optional()}),S(cV).readonly()),listRecentTracks:O(gH,_H),clearTracks:O(b({deviceId:f()}),_(),{kind:`mutation`,auth:`admin`}),getMotionEvents:O(hH,S(uV).readonly()),getObjectEvents:O(uTe,S(mV).readonly()),getAudioEvents:O(hH,S(hV).readonly()),listEventKinds:O(b({deviceId:f()}),S(WB).readonly()),listEventKindsBatch:O(b({deviceIds:S(f()).min(1).max(200)}),S(GB).readonly()),getSensorEvents:O(b({deviceId:f(),since:f().optional(),until:f().optional(),kinds:S(p()).optional(),limit:f().int().min(1).max(mH).default(pH)}),S(KB).readonly()),getKeyEvents:O(dTe,S(bH).readonly()),getKeyEventsBatch:O(fTe,S(pTe).readonly()),readLongTermSeries:O(b({deviceId:f(),series:DH,scope:p().optional(),from:f(),to:f(),limit:f().int().positive().optional()}),S(OH).readonly()),getEventDensity:O(b({deviceId:f(),since:f(),until:f(),bucketMs:f().int().positive()}),S(xH).readonly()),getEventDensityBatch:O(b({deviceIds:S(f()).min(1).max(200),since:f(),until:f(),bucketMs:f().int().positive()}),S(SH).readonly()),pruneEventsBefore:O(b({deviceId:f(),cutoffMs:f()}),b({motion:f().int(),object:f().int(),audio:f().int()}),{kind:`mutation`,auth:`admin`}),pruneTracksBefore:O(b({deviceId:f(),cutoffMs:f()}),wH,{kind:`mutation`,auth:`admin`}),wipeAllAnalytics:O(b({deviceId:f()}),wH,{kind:`mutation`,auth:`admin`}),reconcileFromDisk:O(b({deviceId:f()}),vTe,{kind:`mutation`,auth:`admin`}),deleteTracks:O(b({deviceId:f(),trackIds:S(p()).min(1)}),b({deleted:f().int(),failed:S(p()).readonly(),sparedMediaIds:S(f().int()).readonly().optional()}),{kind:`mutation`,auth:`admin`}),setTrackFlags:O(b({deviceId:f(),trackId:p(),flags:tV}),nV,{kind:`mutation`,notOperatorFacing:`curating a recorded track in the review UI, not a live step`}),listArchivedDebugNotes:O(Nf,S(Mf).readonly(),{kind:`query`}),setTrackRelation:O(zf,Lf,{kind:`mutation`,notOperatorFacing:`curating recorded tracks in the review UI, not a live step`}),clearTrackRelation:O(Bf,Vf,{kind:`mutation`,notOperatorFacing:`curating recorded tracks in the review UI, not a live step`}),setTrackPurity:O(Hf,Uf,{kind:`mutation`,notOperatorFacing:`curating a recorded track in the review UI, not a live step`}),listTrackRelations:O(Wf,Gf,{kind:`query`}),listBirthDecisions:O(jf,S(Af).readonly(),{kind:`query`}),getEventStoreFootprint:O(b({}),bTe,{kind:`query`,auth:`admin`}),getEventMediaFootprintByKind:O(b({deviceId:f().int().optional()}),STe,{kind:`query`,auth:`admin`}),pruneEvents:O(b({olderThanMs:f(),reason:$f.optional()}),TH,{kind:`mutation`,auth:`admin`}),deleteDeviceEvents:O(b({deviceId:f()}),TH,{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:O(Dp,b({paused:o(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:O(Dp,b({resumed:o(!0)}),{kind:`mutation`,auth:`admin`}),refreshStorageLocationsForMigration:O(Dp,b({refreshed:o(!0)}),{kind:`mutation`,auth:`admin`}),startStorageMigrationMove:O(Ip,b({jobId:p()}),{kind:`mutation`,auth:`admin`}),getStorageMigrationMoveStatus:O(b({jobId:p()}),wp.nullable(),{auth:`admin`}),cancelStorageMigrationMove:O(b({jobId:p()}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`}),relocateMedia:O(Ap,b({jobId:p()}),{kind:`mutation`,auth:`admin`}),countUnstampedEventMedia:O(b({}),Mp,{auth:`admin`}),getMediaLocationCensus:O(Np,Fp,{kind:`query`,auth:`admin`}),countRelocatableMedia:O(cm,sm,{kind:`query`,auth:`admin`}),listRelocateMediaJobs:O(b({}),S(wp).readonly(),{kind:`query`,auth:`admin`}),cancelRelocateMedia:O(b({jobId:p()}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`}),listOpsLog:O(tp,S(ep).readonly(),{kind:`query`,auth:`admin`}),reclaimDebugMedia:O(OTe,DTe,{kind:`mutation`,auth:`admin`}),getMediaReclaimStatus:O(b({}),kTe,{kind:`query`,auth:`admin`}),getTrainingExportSummary:O(b({deviceIds:S(f()).optional()}),oV,{kind:`query`,auth:`admin`}),getTrainingExportUrl:O(b({deviceIds:S(f()).optional()}),b({url:p()}),{kind:`query`,auth:`admin`}),listRetrainStaging:O(b({deviceIds:S(f()).optional(),limit:f().int().min(1).max(500).optional()}),S(PV).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),listRetrainCorpusPage:O(UV,GV,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),getRetrainCorpusKpi:O(b({}),qV,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),listRetrainFrames:O(b({trackId:p()}),VV,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),selectRetrainFrames:O(b({deviceId:f(),trackId:p(),mediaIds:S(f().int()).min(1)}),BV,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),deselectRetrainFrame:O(b({deviceId:f(),trackId:p().optional(),frameId:p()}),b({removed:v(),removedAnnotations:f().int()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),getRetrainFrameImage:O(b({frameId:p()}),b({base64:p(),width:f().int(),height:f().int()}),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),proposeRetrainAnnotations:O(b({deviceId:f(),trackId:p().optional(),frameId:p(),subject:QV,nodeId:p().optional()}),$V,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainAnnotations:O(b({trackId:p().optional(),frameIds:S(p()).max(2e3).optional()}),S(kV).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),saveRetrainAnnotations:O(b({deviceId:f(),trackId:p().optional(),frameId:p(),annotations:S(AV),expectedRevision:f().int().optional(),dismissed:S(TV).optional()}),S(kV).readonly(),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),backfillRetrainOrigins:O(b({deviceId:f(),trackId:p().optional(),frameId:p(),expectedRevision:f().int().optional(),origins:S(b({annotationId:p(),origin:wV})).min(1).max(500)}),b({updated:f().int(),skipped:f().int(),revision:f().int()}),{kind:`mutation`,auth:`admin`}),completeRetrainTrack:O(b({deviceId:f(),trackId:p()}),fH,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),restageRetrainTrack:O(b({deviceId:f(),trackId:p()}),fH,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),getRetrainExportUrl:O(JV.extend({layout:YV.optional()}),b({url:p()}),{kind:`query`,auth:`admin`}),setRetrainFrameComplete:O(b({deviceId:f(),trackId:p().optional(),frameId:p(),complete:v()}),RV,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),writeRetrainArchive:O(b({filter:JV,layout:YV,target:XV}),ZV,{kind:`mutation`,auth:`admin`,timeoutMs:60*6e4}),offerRetrainArchive:O(b({filter:JV,layout:YV}),b({ticket:ii,frames:f().int(),annotations:f().int()}),{kind:`mutation`,auth:`admin`,timeoutMs:12e4}),listRetrainAssistProfiles:O(b({}),S(iH).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),proposeRetrainAnnotationsWithLlm:O(b({deviceId:f(),trackId:p().optional(),frameId:p(),profileId:p(),classes:S(bV).min(1),boxes:S(b({ref:p(),bbox:CV,macroClass:bV,label:p().optional()})).max(50),allowCloud:v()}),sH,{kind:`mutation`,auth:`admin`,timeoutMs:18e4}),createRetrainCollection:O(b({name:p().max(120)}),tH,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainCollections:O(b({}),S(eH).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),resolveRetrainTrainingCorpus:O(uH,dH,{kind:`query`,auth:`admin`,timeoutMs:6e4}),renameRetrainCollection:O(b({id:p(),name:p().max(120)}),nH,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),deleteRetrainCollection:O(b({id:p()}),b({deleted:v(),removedFrames:f().int()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),addRetrainFrameFromRecording:O(b({collectionId:p(),deviceId:f(),epochMs:f(),verdictSubject:NV.optional()}),rH,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`,timeoutMs:6e4}),addRetrainFramesToCollection:O(b({collectionId:p(),frameIds:S(p()).min(1).max(500)}),b({added:f().int(),alreadyMember:f().int(),unknownFrameIds:S(p()).readonly()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),removeRetrainFrameFromCollection:O(b({collectionId:p(),frameId:p()}),b({removed:v(),deletedFrame:v()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainCollectionFrames:O(b({collectionId:p()}),S(RV).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),getEventMedia:O(b({ownerType:kl,eventId:f().int(),kind:gV.optional(),deviceId:f()}),S(vV).readonly()),getTrackMedia:O(b({trackId:p(),kinds:S(gV).optional(),deviceId:f()}),S(vV).readonly()),listTrackMedia:O(b({trackId:p(),deviceId:f()}),S(yV).readonly()),listEventMedia:O(b({ownerType:kl,eventId:f().int(),deviceId:f()}),S(yV).readonly()),ownersWithMedia:O(b({deviceId:f(),ownerKind:jl,ownerIds:S(p()).max(5e3)}),S(p()).readonly()),searchObjectEvents:O(_Te,S(CH).readonly(),{caller:`required`}),wipeObjectEmbeddings:O(b({}),wTe,{kind:`mutation`,auth:`admin`}),rebuildObjectEmbeddings:O(CTe,TTe,{kind:`mutation`,auth:`admin`}),getObjectEmbeddingRebuildStatus:O(b({}),ETe)},events:{onFrameTracked:{data:b({deviceId:f(),timestamp:f(),frameWidth:f(),frameHeight:f(),detections:S(gTe).readonly()}),notOperatorFacing:`one tracker frame — stream rate, never an automation trigger`},onTrackStarted:{data:b({deviceId:f(),trackId:p(),className:p()}),trigger:{category:C.PipelineAnalyticsTrackStarted,label:N(`Subject appeared`,`Soggetto comparso`),phrase:N(`When {device} starts following a subject`,`Quando {device} inizia a seguire un soggetto`),icon:`scan-eye`}},onTrackEnded:{data:b({deviceId:f(),trackId:p(),className:p(),durationMs:f()}),trigger:{category:C.PipelineAnalyticsTrackEnded,label:N(`Subject left`,`Soggetto uscito`),phrase:N(`When a subject leaves the view of {device}`,`Quando un soggetto esce dall’inquadratura di {device}`),icon:`scan-eye`}},onDetectionEvent:{data:b({deviceId:f(),kind:BB,eventId:p(),timestamp:f()}),trigger:{category:C.PipelineAnalyticsDetectionEvent,label:N(`Detection event`,`Evento di rilevamento`),phrase:N(`When {device} records a detection event`,`Quando {device} registra un evento di rilevamento`),icon:`radar`}}},vocabulary:{noun:N(`Tracking`,`Tracciamento`),order:3200,extraEvents:[{category:C.PipelineAnalyticsPackageDelivered,label:N(`Package delivered`,`Pacco consegnato`),phrase:N(`When a package is left in front of {device}`,`Quando viene lasciato un pacco davanti a {device}`),icon:`package`},{category:C.PipelineAnalyticsPackagePickedUp,label:N(`Package picked up`,`Pacco ritirato`),phrase:N(`When a package is picked up in front of {device}`,`Quando viene ritirato un pacco davanti a {device}`),icon:`package-open`}]}},AH=b({stepId:p(),modelId:p(),detections:S(b({bbox:s([f(),f(),f(),f()]),score:f(),landmarks:S(b({x:f(),y:f()})).optional()})).min(1)}),jH=b({handle:ta,cropFrameSpace:b({x:f(),y:f(),w:f(),h:f()})});b({crop:b({left:f(),top:f(),width:f().positive(),height:f().positive()}).optional(),content:b({width:f().int().positive(),height:f().int().positive()}),fit:x([`stretch`,`contain`]),format:x([`rgb`,`gray`,`jpeg`])});var NTe=b({registryId:p().min(1),id:p().min(1),width:f().int().positive(),height:f().int().positive(),format:x([`rgb`,`gray`]),timestamp:f(),capturedAt:f().optional()}),MH=x([`onnx`,`coreml`,`openvino`,`tflite`,`pt`,`gguf`]),NH=x([`detector`,`cropper`,`classifier`,`refiner`,`audio-classifier`]),PH=b({runtime:o(`python`),backend:p(),format:MH,device:p().optional()}),FH=b({deviceKey:p().nullable(),runtime:p(),batchMode:p(),windowMs:f(),maxBatchSize:f(),concurrency:f(),numWorkers:f()}),PTe=b({engine:PH,devices:S(b({id:p(),label:p(),description:p().optional()})).readonly(),defaultDevice:p()}),IH=g(()=>b({addonId:p(),addonName:p(),slot:NH,inputClasses:S(p()).readonly(),outputClasses:S(p()).readonly(),enabled:v(),modelId:p(),children:S(IH).readonly(),group:p().optional(),settings:u(p(),l()).optional()})),FTe=b({id:p(),name:p(),formats:u(p(),fue),group:Ah.optional(),legacy:v().optional(),provider:jh.optional(),defaultConfidence:f().optional(),suppliesSteps:S(Mh).readonly().optional()}),ITe=ge(),LTe=b({id:p(),name:p(),slot:NH,inputClasses:S(p()).readonly(),outputClasses:S(p()).readonly(),childSlots:S(NH).readonly(),models:S(FTe).readonly(),defaultModelId:p(),defaultModelIdByFormat:u(p(),p()).optional(),enabledByDefault:v().optional(),defaultConfidence:f(),group:p().optional(),configSchema:S(ITe).readonly().optional()}),RTe=b({id:NH,label:p(),priority:f(),parentSlot:NH.nullable(),addons:S(LTe).readonly()}),zTe=b({availableEngines:S(PTe).readonly(),selectedEngine:PH,slots:S(RTe).readonly()}),BTe=b({runtimeId:x([`onnx`,`openvino`,`coreml`,`edgetpu`]).nullable(),device:p().nullable(),state:x([`idle`,`installing`,`verifying`,`ready`,`failed`]),progress:f().optional(),error:p().optional(),nextRetryAt:f().optional(),configIssues:S(p()).optional()}),LH=b({addonId:p(),chosen:p(),running:p(),format:p()}),RH=b({addonId:p(),kind:x([`unknown-addon`,`no-format-build`,`unknown-device`]),detail:p()}),zH=b({ok:v(),issues:S(RH).readonly(),substitutions:S(LH).readonly(),format:p()}),VTe=b({filename:p(),stepIds:S(p()).readonly().optional()}),HTe=b({base64:p(),filename:p()}),UTe=b({filename:p(),sizeKb:f()}),WTe=b({base64:p()}),GTe=b({id:p(),name:p(),description:p(),available:v(),rawLabels:S(p()).readonly().optional()}),KTe=b({activeBackend:p(),availableBackends:S(GTe).readonly(),sampleRate:f(),chunkDurationMs:f()}),qTe=b({filePath:p(),sizeMB:f(),durationMs:f()}),JTe=b({success:v(),error:p().optional(),frame:ge().optional()}),YTe=ge(),XTe=ge(),ZTe=ge(),QTe=ge(),BH={name:`pipeline-executor`,scope:`system`,mode:`singleton`,methods:{getAvailableEngines:O(_(),S(PH)),getSelectedEngine:O(_(),PH),getEngineProvisioning:O(b({nodeId:p()}),BTe),getVideoPipelineSteps:O(_(),u(p(),b({modelId:p(),settings:u(p(),l()).readonly()}))),setVideoPipelineSteps:O(b({steps:u(p(),b({modelId:p(),settings:u(p(),l()).readonly()}))}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),getInferenceDeviceHealth:O(b({nodeId:p()}),b({unhealthy:S(b({deviceKey:p(),state:x([`failed`,`backoff`]),since:f(),deaths:f(),lastError:p()})).readonly()})),rearmInferenceDevice:O(b({nodeId:p(),deviceKey:p()}),b({rearmed:v()}),{kind:`mutation`,auth:`admin`}),getSchema:O(_(),zTe),getOrchestratorConfigSchema:O(_(),YTe),validatePipeline:O(b({steps:S(Da),deviceKey:p().optional()}),zH),getCapabilities:O(_(),ZTe),getAddonModels:O(b({addonId:p()}),QTe),downloadModel:O(b({addonId:p(),modelId:p(),format:MH}),qTe,{kind:`mutation`}),deleteModel:O(b({addonId:p(),modelId:p(),format:MH}),b({success:o(!0)}),{kind:`mutation`}),runPipeline:O(b({steps:S(Da).min(1),frame:yS.optional(),frameRef:NTe.optional(),frameHandle:ta.optional(),imageBase64:p().optional(),image:y(Uint8Array).optional(),referenceImage:p().optional(),deviceId:f().optional(),sessionId:p().optional(),plane:x([`full`,`frame`]).optional(),deviceKey:p().optional(),nativeCropRef:jH.optional(),replay:o(!0).optional(),suppliedRoot:AH.optional()}),Oa,{kind:`mutation`}),runPipelineBatch:O(b({steps:S(Da).min(1),frames:S(yS).min(1).max(255),deviceId:f().optional(),sessionId:p().optional(),frameId:f().int().nonnegative().optional(),deviceKey:p().optional()}),b({results:S(Oa).readonly()}),{kind:`mutation`}),cacheFrameInPool:O(b({data:y(Uint8Array),width:f().int().positive(),height:f().int().positive(),format:x([`rgb`,`bgr`,`gray`])}),b({frameId:f(),width:f(),height:f()}),{kind:`mutation`}),inferCached:O(b({stepId:p(),frameId:f().int(),modelId:p().min(1)}),u(p(),l()),{kind:`mutation`}),uncacheFrame:O(b({frameId:f().int()}),_(),{kind:`mutation`}),getEffectiveTuning:O(b({deviceKey:p().optional()}),FH),listLoadedEngines:O(_(),S(b({engineKey:p(),engine:PH,modelsLoaded:S(p()).readonly(),inUseByCameras:S(f()).readonly(),kind:x([`runtime`,`device-pool`]),poolPid:f().nullable(),idleMs:f().nullable(),idleTtlMs:f().nullable()})).readonly()),spinEngine:O(b({engine:PH}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),killEngine:O(b({engine:PH,force:v().optional()}),b({success:v(),reason:p().optional()}),{kind:`mutation`,auth:`admin`}),listReferenceImages:O(_(),S(VTe).readonly()),getReferenceImage:O(b({filename:p()}),HTe.nullable()),getReferenceAudioFiles:O(_(),S(UTe).readonly()),getReferenceAudio:O(b({filename:p()}),WTe.nullable()),getAudioCapabilities:O(_(),KTe),runAudioTest:O(b({addonId:p(),modelId:p(),filename:p().optional(),settings:u(p(),l()).optional()}),JTe,{kind:`mutation`}),getDetectionConfigSchema:O(_(),XTe)},vocabulary:{notOperatorFacing:A.PIPELINE}},$Te=b({activeCameras:f(),throttledCameras:f(),avgInferenceTimeMs:f(),queueDepth:f()}),VH=b({detectionMode:x([`disabled`,`always-on`,`on-motion`]),configuredFps:f(),actualFps:f(),queueDepth:f(),avgInferenceTimeMs:f(),droppedFrames:f(),nativeCropMisses:f().optional(),phase:x([`idle`,`watching`,`active`])}),HH=VH.extend({deviceId:f()}),UH=x([`polygon`,`tripwire`]),WH=b({x:f(),y:f()}),GH=b({id:p(),name:p(),kind:UH.default(`polygon`),polygon:S(WH).readonly(),color:p().default(`#3b82f6`)}),KH={name:`zones`,scope:`device`,mode:`singleton`,deviceTypes:[w.Camera],methods:{listZones:O(b({deviceId:f()}),S(GH).readonly()),addZone:O(b({deviceId:f(),zone:GH}),_(),{kind:`mutation`,auth:`admin`}),removeZone:O(b({deviceId:f(),zoneId:p()}),_(),{kind:`mutation`,auth:`admin`}),updateZone:O(b({deviceId:f(),zone:GH}),_(),{kind:`mutation`,auth:`admin`})},runtimeState:b({zones:S(GH).readonly()}),durability:`restored`,history:`none`,vocabulary:{noun:N(`Zones`,`Zone`),order:3370}},qH={fpsPerStream:10,budgetMinutes:45,minBudgetMinutes:10,maxBudgetMinutes:120,staleAfterDays:30,settleSec:5,measureSec:20,drainTimeoutSec:120,maxModelsPerDevice:6},JH=x([`device`,`pipeline`]),YH=b({deviceKey:p().min(1),modelIds:S(p().min(1)).min(1).max(qH.maxModelsPerDevice)}),XH=b({nodeId:p().min(1),devices:S(YH).min(1),phases:S(JH).min(1).default([`device`,`pipeline`]),steps:S(p().min(1)).default([]),fpsPerStream:f().int().min(1).max(30).default(qH.fpsPerStream),budgetMinutes:f().int().min(qH.minBudgetMinutes).max(qH.maxBudgetMinutes).default(qH.budgetMinutes),keepDownloadedModels:v().default(!1),acceptInsufficientHeadroom:v().default(!1)}),ZH=x([`benchmark-active`,`node-offline`,`unknown-device`,`no-phase`,`insufficient-headroom`]),QH=b({kind:ZH,detail:p(),overridable:v()}),$H=b({deviceId:f(),placedOnNode:v(),pinnedToNode:v()}),eU=b({deviceId:f(),reason:o(`only-frame-source`)}),tU=b({nodeId:p(),online:v(),moving:S($H).readonly(),staying:S(eU).readonly(),estimatedDurationMs:f(),budgetMs:f(),phases:S(JH).readonly(),steps:S(p()).readonly(),devices:S(YH).readonly(),headroom:b({sessionsNow:f(),otherNodesCapacitySessions:f().nullable()}),refusals:S(QH).readonly(),canStart:v()}),nU=b({phase:x([`preparing`,`device`,`pipeline`,`cleanup`]),deviceKey:p().nullable(),modelId:p().nullable(),load:f().nullable(),cellsDone:f(),cellsTotal:f(),message:p()}),rU=x([`p95`,`drops`,`errors`,`stall`,`cpu`,`ram`,`none`]),iU=b({load:f(),pass:v(),p95Ms:f(),dropRatio:f(),fps:f(),cpuPct:f().nullable(),ramFreePct:f().nullable(),failReasons:S(p()).readonly()}),aU=b({phase:o(`device`),deviceKey:p(),modelId:p(),p50Ms:f(),p95Ms:f(),p99Ms:f(),fps:f(),kMax:f(),limitedBy:rU,warmupMs:f(),ramp:S(iU).readonly()}),oU=b({phase:o(`pipeline`),deviceKey:p(),modelId:p(),steps:S(p()).readonly(),maxSessions:f(),limitedBy:rU,stepsFired:S(p()).readonly(),warmupMs:f(),ramp:S(iU).readonly()}),sU=i(`phase`,[aU,oU]),cU=b({pipelineVersion:p().nullable(),cpuModel:p().nullable(),ramGb:f().nullable(),os:p().nullable(),pools:u(p(),b({runtime:p(),numWorkers:f(),concurrency:f(),batchMode:p()})).default({})}),lU=b({id:p(),revision:p().nullable(),frames:f(),width:f(),height:f()}),uU=b({runId:p().min(1),devices:S(YH).min(1),phases:S(JH).min(1),steps:S(p()).default([]),fpsPerStream:f().int().min(1).max(30),deadlineAtMs:f(),settleSec:f().min(0).max(60).default(qH.settleSec),measureSec:f().min(2).max(300).default(qH.measureSec),keepDownloadedModels:v().default(!1)}),dU=x([`running`,`done`,`failed`,`aborted`]),fU=b({runId:p(),nodeId:p(),state:dU,progress:nU.nullable(),cells:S(sU).readonly(),fingerprint:cU.nullable(),clip:lU.nullable(),activeCameraIds:S(f()).readonly(),deletedModels:S(p()).readonly(),error:p().nullable(),startedAtMs:f(),finishedAtMs:f().nullable()}),pU=x([`draining`,`measuring`,`restoring`,`done`,`failed`,`aborted`]),mU=x([`completed`,`operator-abort`,`deadline`,`node-lost`,`runner-lost`,`hub-restart`,`drain-timeout`,`failed`]),hU=b({runId:p(),nodeId:p(),state:pU,plan:XH,startedAtMs:f(),deadlineAtMs:f(),finishedAtMs:f().nullable(),endReason:mU.nullable(),error:p().nullable(),moved:S(f()).readonly(),staying:S(f()).readonly(),contaminated:v(),progress:nU.nullable(),resultIds:S(p()).readonly()}),gU=b({modeNodeId:p().nullable(),run:hU.nullable()}),_U=b({id:p(),runId:p(),nodeId:p(),cell:sU,fpsPerStream:f(),fingerprint:cU.nullable(),clip:lU.nullable(),contaminated:v(),stayingCameras:S(f()).readonly(),partialRun:v(),measuredAtMs:f()}),vU=b({nodeId:p().optional(),deviceKey:p().optional()}),yU=_U.extend({standing:x([`fresh`,`stale`,`superseded`]),staleWhy:x([`age`,`runtime`,`pool-tuning`]).nullable()}),eEe=b({runId:p(),nodeId:p(),startedAtMs:f(),deadlineAtMs:f(),plan:XH,moved:S(f()).readonly(),staying:S(f()).readonly()}),bU=b({nodeId:p(),reachable:v(),devices:S(b({deviceKey:p(),enabled:v(),available:v(),suggested:S(p()).readonly(),all:S(p()).readonly(),currentModelId:p().nullable()})).readonly(),steps:S(b({id:p(),name:p(),slot:p()})).readonly()}),xU=b({x:f(),y:f(),w:f(),h:f()}),SU=b({bytes:y(Uint8Array).optional(),jpeg:p().optional(),jpegBytes:y(Uint8Array).optional(),width:f().int().positive(),height:f().int().positive(),tier:x([`native`,`ram-fullframe`]).optional()}),CU=x([`keyFrame`,`thumbnail`]),wU=x([`handle-gone`,`encode-failed`]),TU=i(`parked`,[b({parked:o(!0),nodeId:p(),width:f().int().positive(),height:f().int().positive(),bytes:f().int().nonnegative(),replaced:v()}),b({parked:o(!1),nodeId:p(),reason:wU,handleAgeMs:f().nullable(),detail:p().optional()})]),EU=b({jpeg:p().optional(),jpegBytes:y(Uint8Array).optional(),width:f().int().positive(),height:f().int().positive(),timestamp:f(),parkedAt:f()}),tEe=b({bbox:xU,className:p()}),DU=b({stepId:p(),className:p(),score:f(),bbox:xU.optional(),embedding:p().optional(),embeddingMagnitude:f().optional(),embeddingModelId:p().optional(),label:p().optional(),labelTier:c([o(1),o(2)]).optional(),labelModelId:p().optional(),alignedCropJpeg:p().optional(),nativeFaceShortSidePx:f().optional(),landmarks:S(b({x:f(),y:f()})).optional()}),nEe=x([`unknown-step`,`model-not-servable`,`unreadable-frame`,`execution-failed`]),rEe=i(`kind`,[b({kind:o(`ran`),nodeId:p(),modelId:p(),details:S(DU)}),b({kind:o(`refused`),nodeId:p(),reason:nEe,detail:p()})]),OU={min:0,max:6e4,default:3e4,step:500},kU={min:0,max:6e5,default:12e4,step:5e3},AU={min:5e3,max:6e5,default:9e4,step:5e3},jU={min:1,max:30,default:4,step:1},MU={min:1,max:30,default:10,step:1},NU={min:0,max:300,default:300,step:5},PU={min:1,max:10,default:4,step:1},FU={min:0,max:30,default:12,step:1},IU=x([`onboard`,`analyzer`,`device-activity`]),LU=b({source:IU,triggeredBy:$z,sensorName:p().optional()}),RU=S(IU),zU={analyzer:`Frame-diff Analyzer (motion addon)`,onboard:`Camera sensors`,"device-activity":`Device activity (the device says it is working)`};function iEe(e){let t=IU.safeParse(e);return t.success?zU[t.data]:e}var aEe=[`analyzer`,`onboard`,`device-activity`],BU=oe(e=>Array.isArray(e)&&e.length>1?e.slice(0,1):e,S(dV).max(1)),VU=b({deviceId:f(),detected:v(),source:IU.default(`analyzer`),regions:S(mB).readonly().optional()}),HU=i(`kind`,[b({kind:o(`local-broker`)}),b({kind:o(`remote-restream`),ownerNodeId:p(),ownerReachableHost:p().optional(),hubHostnameOverride:p().optional()})]).describe(`Per-camera frame-source mode for the runner (P2c)`),UU=b({modelId:p().optional(),settings:u(p(),l()).optional()}),WU=b({deviceKey:p(),weight:f().positive().default(1),maxSessions:f().int().positive().nullable().default(null),steps:u(p(),UU).optional()}),GU=b({deviceId:f(),detectionMode:x([`disabled`,`always-on`,`on-motion`]).default(`on-motion`),audioMode:x([`disabled`,`always-on`,`on-motion`]).default(`always-on`),motionCooldownMs:f().min(OU.min).default(OU.default),maxSessionHoldMs:f().min(kU.min).max(kU.max).optional(),audioMotionWindowMs:f().min(AU.min).max(AU.max).optional(),motionFps:f().min(jU.min).max(jU.max).default(jU.default),detectionFps:f().min(MU.min).max(MU.max).default(MU.default),motionStreamId:p(),detectionStreamId:p(),audioStreamPick:Ji.optional(),motionSources:RU.default([`analyzer`]),sessionTrigger:LU.optional(),detectionSources:BU.default([`pipeline`]),pipelineEnabled:v().default(!0),steps:S(Da).readonly().optional(),audio:b({modelId:p().optional(),enabled:v()}).nullable().optional(),zones:S(GH).readonly().default([]),onboardMotionDrivesAnalyzer:v().default(!0),preRollInferenceEnabled:v().default(!0),preRollInferenceFrames:f().min(FU.min).max(FU.max).default(FU.default),occupancyRecheckEnabled:v().default(!0),occupancyRecheckSec:f().min(NU.min).max(NU.max).default(NU.default),occupancyRecheckFrames:f().min(PU.min).max(PU.max).default(PU.default),frameSource:HU.default({kind:`local-broker`}),deviceKey:p().optional(),inferenceDevices:S(WU).readonly().optional()}),oEe=[{key:`motionSources`,type:`multiselect`,label:`Motion Sources`,default:[`analyzer`],options:aEe.map(e=>e===`onboard`?{value:e,label:zU[e],description:`The camera's own motion, plus any sensor attached to it`}:{value:e,label:zU[e]})},{key:`motionFps`,type:`slider`,label:`Motion FPS (analyzer)`,min:jU.min,max:jU.max,step:jU.step,default:jU.default,showValue:!0,unit:`fps`,nullable:!0,nullLabel:`Default`,showWhen:{field:`motionSources`,includes:`analyzer`}},{key:`detectionFps`,type:`slider`,label:`Detection FPS`,min:MU.min,max:MU.max,step:MU.step,default:MU.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:OU.min,max:OU.max,step:OU.step,default:OU.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:kU.min,max:kU.max,step:kU.step,default:kU.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:AU.min,max:AU.max,step:AU.step,default:AU.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:FU.min,max:FU.max,step:FU.step,default:FU.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:NU.min,max:NU.max,step:NU.step,default:NU.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:PU.min,max:PU.max,step:PU.step,default:PU.default,showValue:!0,showWhen:{field:`occupancyRecheckEnabled`,equals:!0}}],KU=b({nodeId:p(),attachedCameras:f(),activeCameras:f(),avgInferenceFps:f(),avgInferenceTimeMs:f(),queueDepthTotal:f(),devices:S(b({deviceKey:p(),backend:p(),attachedCameras:f()})).default([]),hardware:b({hasGpu:v(),inferenceBackend:p().optional(),cpuCores:f().optional()}),motionSliceWriter:o(`orchestrator`).optional()}),qU=b({framesDecoded:f(),framesAdmitted:f(),framesDroppedPixelFree:f(),viewsMaterialized:f(),viewsSkipped:f(),workerToRunnerBytes:f(),runnerToPoolRawBytes:f(),runnerToPoolJpegBytes:f(),onDemandFullFrameRequests:f(),onDemandCropRequests:f(),nativeHits:f(),nativeMisses:f(),tileHits:f(),tileMisses:f(),fallbackHits:f(),fallbackMisses:f(),retainedWritesAvoided:f(),residentRefs:f(),residentBytes:f(),releases:f(),evictions:f(),staleMisses:f()}),JU=b({node:qU,cameras:S(qU.extend({deviceId:f()}))}),YU=b({nodeId:p(),activeCameras:f(),throttledCameras:f(),avgInferenceTimeMs:f(),queueDepth:f(),frameLazy:JU.optional()}),XU=x([`not-attached`,`battery-asleep`,`not-watching`,`already-bursting`]),ZU={name:`pipeline-runner`,scope:`system`,mode:`singleton`,methods:{attachCamera:O(GU,b({success:o(!0)}),{kind:`mutation`}),detachCamera:O(b({deviceId:f()}),b({success:o(!0)}),{kind:`mutation`}),reportMotion:O(VU,b({success:o(!0)}),{kind:`mutation`}),getLocalLoad:O(_(),KU),getLocalMetrics:O(_(),YU),getCameraMetrics:O(b({deviceId:f()}),VH.nullable()),getAllCameraMetrics:O(_(),S(HH).readonly()),getLocalCameras:O(_(),S(f()).readonly()),requestOccupancyBurst:O(b({deviceId:f(),frames:f().int().positive().optional(),reason:p()}),b({started:v(),refusedBecause:XU.optional()}),{auth:`admin`,kind:`mutation`}),getNativeCrop:O(b({handle:ta,bbox:xU,maxWidth:f().int().positive().optional(),acceptJpegBytes:v().optional(),encodeJpeg:v().optional()}),SU.nullable()),runDetailSubtree:O(b({deviceId:f(),frameHandle:ta.optional(),frameJpeg:p().optional(),cropJpeg:p().optional(),parent:tEe,steps:S(p()).optional(),supplied:b({stepId:p(),modelId:p(),boxes:S(b({bbox:xU,score:f()})).min(1)}).optional()}),b({details:S(DU)}).nullable(),{kind:`mutation`}),runStatelessStep:O(b({stepId:p(),modelId:p(),frameJpeg:p(),bbox:xU,className:p(),sourceDeviceId:f()}),rEe,{kind:`mutation`}),parkTrackFrame:O(b({deviceId:f(),trackId:p(),kind:CU,handle:ta,bbox:xU,maxWidth:f().int().positive().optional(),timestamp:f()}),TU,{kind:`mutation`}),getParkedTrackFrame:O(b({deviceId:f(),trackId:p(),kind:CU,acceptJpegBytes:v().optional()}),EU.nullable()),releaseParkedTrackFrames:O(b({deviceId:f(),trackId:p()}),b({released:f().int().nonnegative()}),{kind:`mutation`}),startNodeBench:O(uU,b({accepted:o(!0),runId:p()}),{kind:`mutation`,auth:`admin`}),getNodeBenchStatus:O(b({runId:p()}),fU.nullable(),{auth:`admin`}),abortNodeBench:O(b({runId:p()}),b({aborted:v()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:A.PIPELINE}},QU=3e4,sEe={version:1,targets:[{id:`detected`,cardinality:`event`,shape:`span`,vocabulary:{cap:`motion`,eventName:`onMotionChanged`},deviceTypes:[w.Camera],apply:`add`,applyAuthority:{kind:`camera-sensors`,timeoutField:`motionCooldownMs`},eventName:`onMotionChanged`,start:`rising-edge`,end:`falling-edge-or-timeout`,timeoutMs:QU,combine:`any`,sourceModes:[`in-addition`,`confirm`,`replace`],sources:[{kind:`binary`},{kind:`switch`}],sourceReport:{status:`assignment-status`},advancedExpression:!1}]},cEe=15e3,$U=b({detected:v(),lastDetectedAt:f().nullable(),autoClearAfterMs:f().nullable().meta(j(`duration-ms`))}),eW=b({deviceId:f(),detected:v(),timestamp:f(),source:IU,regions:S(mB).readonly().optional(),triggeredBy:$z.optional()}),tW={name:`motion`,scope:`device`,mode:`singleton`,deviceNative:!0,deviceTypes:[w.Camera,w.Sensor],methods:{isDetected:O(b({deviceId:f()}),v())},composedMethods:{isDetected:{kind:`slice`,field:`detected`}},events:{onMotionChanged:{data:eW,notOperatorFacing:"the `detected` state trigger phrases both edges, from the mirror that survives a dropped event (D49)"}},status:{schema:$U,kind:`push`},runtimeState:$U,durability:`session`,history:{fields:{detected:{kind:`boolean`,excludeDeviceTypes:[w.Camera]}}},customize:sEe,vocabulary:{noun:N(`Motion`,`Movimento`),order:5130,state:[{kind:`boolean`,field:`detected`,label:N(`Motion`,`Movimento`),whenTrue:N(`When {device} detects motion`,`Quando {device} rileva movimento`),whenFalse:N(`When motion clears on {device}`,`Quando il movimento su {device} cessa`),icon:`activity`}]}},nW=b({enabled:v(),lastChangedAt:f()}),rW=nW.extend({lastFetchedAt:f()}),iW={name:`motion-trigger`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Light,w.Siren,w.Switch],methods:{setMotionTrigger:O(b({deviceId:f().int().nonnegative(),enabled:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`motionTrigger.on`,label:N(`Motion trigger on`,`Attivazione al movimento attiva`),phrase:N(`Let motion trigger {device}`,`Fai attivare {device} dal movimento`),icon:`activity`,effect:{field:`enabled`,value:!0},args:{enabled:!0}},{id:`motionTrigger.off`,label:N(`Motion trigger off`,`Attivazione al movimento spenta`),phrase:N(`Stop motion triggering {device}`,`Non far più attivare {device} dal movimento`),icon:`activity`,effect:{field:`enabled`,value:!1},args:{enabled:!1}}]})},events:{onMotionTriggerChanged:{data:b({deviceId:f(),enabled:v(),lastChangedAt:f()}),notOperatorFacing:"the `enabled` state trigger phrases both edges of this change"}},status:{schema:nW,kind:`command-driven`},runtimeState:rW,durability:`session`,history:`none`,vocabulary:{noun:N(`Motion trigger`,`Attivazione al movimento`),order:1160,state:[{kind:`boolean`,field:`enabled`,label:N(`Motion trigger`,`Attivazione al movimento`),whenTrue:N(`When motion triggering is turned on for {device}`,`Quando si attiva l’attivazione al movimento di {device}`),whenFalse:N(`When motion triggering is turned off for {device}`,`Quando si disattiva l’attivazione al movimento di {device}`),icon:`activity`}]}},aW=b({id:f(),enabled:v(),shape:xB}),oW=b({enabled:v(),sensitivity:f().meta(j(`none`)),regions:S(aW),lastFetchedAt:f()}),sW=b({maxRegions:f(),supportedShapes:S(CB),grid:TB,sensitivity:b({min:f(),max:f(),step:f()})}),cW=b({enabled:v().optional(),sensitivity:f().optional(),regions:S(aW).optional()}),lW={name:`motion-zones`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/motion-zones-grid`,tab:`motion`,label:`Motion Zones`}},methods:{getOptions:O(b({deviceId:f()}),sW),setZone:O(b({deviceId:f(),patch:cW}),_(),{kind:`mutation`,auth:`admin`})},status:{schema:oW,kind:`poll`},runtimeState:oW,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:N(`Motion zones`,`Zone di movimento`),order:3170}},lEe=x([`external`,`embedded`]),uEe=x([`connected`,`disconnected`,`auth-failed`,`unreachable`,`tls-error`]),uW=b({id:p(),name:p(),url:p(),kind:lEe,status:uEe,latencyMs:f().nullable(),error:p().optional(),connectedClients:f().int().nonnegative().optional(),lastCheckedAt:f().optional()}),dW=b({url:p(),username:p().optional(),password:p().optional(),clientIdPrefix:p().optional()}),fW=b({name:p().min(1),url:p().regex(/^(mqtt|mqtts|ws|wss):\/\//,`URL must start with mqtt(s):// or ws(s)://`),username:p().optional(),password:p().optional(),clientIdPrefix:p().optional()}),dEe=b({id:p()}),pW=b({id:p()}),mW=b({port:f().int().min(1).max(65535).default(1883),allowAnonymous:v().default(!1),username:p().optional(),password:p().optional()}),fEe=b({id:p(),url:p()}),hW=b({brokerCount:f(),embeddedRunning:v()}),gW={name:`mqtt-broker`,scope:`system`,mode:`collection`,providerKind:`broker`,status:{schema:hW,kind:`poll`},methods:{listBrokers:O(_(),S(uW)),getBrokerConfig:O(pW,dW,{auth:`admin`}),addBroker:O(fW,dEe,{kind:`mutation`,auth:`admin`}),removeBroker:O(pW,_(),{kind:`mutation`,auth:`admin`}),startEmbeddedBroker:O(mW,fEe,{kind:`mutation`,auth:`admin`}),stopEmbeddedBroker:O(pW,_(),{kind:`mutation`,auth:`admin`}),getStatus:O(_(),hW)},vocabulary:{notOperatorFacing:A.NETWORK}},_W=x([`person`,`vehicle`,`animal`,`face`,`package`,`other`]),vW=b({class:_W,timestamp:f(),confidence:f().min(0).max(1).optional()}),yW=b({lastByClass:n(_W,vW.nullable()),supportedClasses:S(_W).readonly(),enabled:v()}),bW=x([`boxed`,`while-streaming`,`flag-only`]),xW=b({supportedClasses:S(_W).readonly(),geometry:bW}),SW=b({enabled:v().optional()}),CW=yW.extend({lastFetchedAt:f()}),wW={name:`native-object-detection`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Camera],methods:{getOptions:O(b({deviceId:f()}),xW),setSettings:O(b({deviceId:f(),settings:SW}),_(),{kind:`mutation`,auth:`admin`}),setEnabled:O(b({deviceId:f(),enabled:v()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`nativeDetection.on`,label:N(`On-camera detection on`,`Rilevamento a bordo attivo`),phrase:N(`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:N(`On-camera detection off`,`Rilevamento a bordo spento`),phrase:N(`Turn off the on-camera detection of {device}`,`Disattiva il rilevamento a bordo di {device}`),icon:`scan-eye`,args:{enabled:!1}}]})},events:{onDetected:{data:b({deviceId:f(),detection:vW}),trigger:{category:C.DetectionCameraNative,label:N(`Camera spotted something`,`La telecamera ha rilevato qualcosa`),phrase:N(`When {device} spots something with its own detector`,`Quando {device} rileva qualcosa con il proprio rilevatore`),icon:`scan-eye`}}},status:{schema:yW,kind:`push`},runtimeState:CW,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:N(`On-camera detection`,`Rilevamento a bordo`),order:3180,state:[{kind:`boolean`,field:`enabled`,label:N(`On-camera detection`,`Rilevamento a bordo`),whenTrue:N(`When the on-camera detection of {device} is turned on`,`Quando si attiva il rilevamento a bordo di {device}`),whenFalse:N(`When the on-camera detection of {device} is turned off`,`Quando si disattiva il rilevamento a bordo di {device}`),icon:`scan-eye`}]}},TW=b({pan:f().min(-1).max(1).optional(),tilt:f().min(-1).max(1).optional(),speed:f().min(0).max(1).optional()}),EW=x([`goHome`,`locate`,`spotClean`,`findPet`,`personFollow`,`stop`,`startClean`,`pauseClean`,`dockWash`,`autoEmpty`,`flashOn`,`flashOff`]),DW=x([`action`,`sound`]),OW=b({id:p(),kind:DW,label:p(),icon:p(),soundId:f().int().optional(),enabled:v()}),pEe=[{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}],kW=b({x:f(),y:f()}),AW=b({move:v(),stop:v(),goToPoint:v(),runAction:v(),playSound:v(),light:v(),lightMode:v()}),jW=x([`auto`,`manual`]),mEe=40,hEe=100,MW=x([`idle`,`cleaning`,`spot`,`following`,`goto`,`returning`,`paused`,`unknown`]),NW=b({mode:MW,following:v(),flash:v(),lightMode:jW,lightLevel:f().min(40).max(100).meta(j(`none`)),lastChangedAt:f()}),PW=NW.extend({lastFetchedAt:f()}),FW={name:`navigation`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/navigation-panel`,tab:`navigation`,topTab:!0,label:`Navigation`,order:0}},methods:{move:O(TW.extend({deviceId:f()}),_(),{kind:`mutation`,notOperatorFacing:`joystick control from the live view — continuous, not a discrete step`}),stop:O(b({deviceId:f()}),_(),{kind:`mutation`,actions:[{id:`navigation.stop`,label:N(`Stop`,`Ferma`),phrase:N(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),goToPoint:O(kW.extend({deviceId:f()}),_(),{kind:`mutation`,notOperatorFacing:`tap-to-go on the live map — the point only means something on that picture`}),listActions:O(b({deviceId:f()}),S(OW)),runAction:O(b({deviceId:f(),actionId:EW}),_(),{kind:`mutation`,actions:[{id:`navigation.runAction`,label:N(`Run a routine`,`Esegui una routine`),phrase:N(`Have {device} {actionId}`,`Fai eseguire a {device}: {actionId}`),icon:`bot`,openArgs:[{key:`actionId`,label:N(`Routine`,`Routine`),offer:{kind:`enum`,values:[{value:`goHome`,label:N(`go home`,`torna alla base`)},{value:`locate`,label:N(`beep so you can find it`,`suona per farsi trovare`)},{value:`spotClean`,label:N(`clean this spot`,`pulisci questo punto`)},{value:`findPet`,label:N(`find the pet`,`cerca l’animale`)},{value:`personFollow`,label:N(`follow a person`,`segui una persona`)},{value:`stop`,label:N(`stop`,`fermati`)},{value:`startClean`,label:N(`start cleaning`,`inizia a pulire`)},{value:`pauseClean`,label:N(`pause cleaning`,`metti in pausa la pulizia`)},{value:`dockWash`,label:N(`wash the mop at the dock`,`lava il mocio alla base`)},{value:`autoEmpty`,label:N(`empty the bin at the dock`,`svuota il contenitore alla base`)},{value:`flashOn`,label:N(`turn the flash on`,`accendi il flash`)},{value:`flashOff`,label:N(`turn the flash off`,`spegni il flash`)}]}}]}]}),playSound:O(b({deviceId:f(),soundId:f().int()}),_(),{kind:`mutation`,actions:[{id:`navigation.playSound`,label:N(`Play sound`,`Riproduci un suono`),phrase:N(`Play {soundId} on {device}`,`Riproduci {soundId} su {device}`),icon:`volume-2`,openArgs:[{key:`soundId`,label:N(`Sound`,`Suono`),offer:{kind:`dynamic`,from:`method`,method:`listActions`,valueKey:`soundId`,labelKey:`label`,where:{key:`kind`,equals:`sound`},valueKind:`number`}}]}]}),setLightOn:O(b({deviceId:f(),on:v()}),_(),{kind:`mutation`,actions:[{id:`navigation.lightOn`,label:N(`Light on`,`Luce accesa`),phrase:N(`Turn on the light of {device}`,`Accendi la luce di {device}`),icon:`lightbulb`,args:{on:!0}},{id:`navigation.lightOff`,label:N(`Light off`,`Luce spenta`),phrase:N(`Turn off the light of {device}`,`Spegni la luce di {device}`),icon:`lightbulb-off`,args:{on:!1}}]}),setLightMode:O(b({deviceId:f(),mode:jW,level:f().min(40).max(100).optional()}),_(),{kind:`mutation`,actions:[{id:`navigation.lightAuto`,label:N(`Light automatic`,`Luce automatica`),phrase:N(`Set the light of {device} to automatic`,`Metti la luce di {device} in automatico`),icon:`lightbulb`,args:{mode:`auto`}}]}),setLightLevel:O(b({deviceId:f(),level:f().min(40).max(100)}),_(),{kind:`mutation`,actions:[{id:`navigation.lightLevel`,label:N(`Set light level`,`Imposta la luce`),phrase:N(`Set the light of {device} to {level}`,`Imposta la luce di {device} al {level}`),icon:`sun-medium`,openArgs:[{key:`level`,label:N(`Level`,`Livello`),offer:{kind:`number`,min:40,max:100,step:1,unit:`%`}}]}]}),getFeatures:O(b({deviceId:f()}),AW)},events:{onStatusChanged:{data:b({deviceId:f(),status:NW}),notOperatorFacing:"the `mode` state trigger reads the same change"}},status:{schema:NW,kind:`push`},runtimeState:PW,durability:`session`,history:`none`,vocabulary:{noun:N(`Robot movement`,`Movimento del robot`),order:2080,state:[{kind:`enum`,field:`mode`,label:N(`Activity`,`Attività`),values:[{value:`idle`,label:N(`Idle`,`Inattivo`)},{value:`cleaning`,label:N(`Cleaning`,`In pulizia`)},{value:`spot`,label:N(`Spot cleaning`,`Pulizia localizzata`)},{value:`following`,label:N(`Following`,`In inseguimento`)},{value:`goto`,label:N(`Moving to a point`,`In movimento verso un punto`)},{value:`returning`,label:N(`Returning`,`In rientro`)},{value:`paused`,label:N(`Paused`,`In pausa`)},{value:`unknown`,label:N(`Unknown`,`Sconosciuto`)}],icon:`bot`}]}},IW=b({url:p(),hostname:p(),port:f(),protocol:x([`http`,`https`]),stable:v().optional()}),gEe=b({url:p(),stable:v().optional(),updated:v().optional()}),LW=b({connected:v(),endpoint:IW.nullable(),error:p().optional()}),_Ee=IW.extend({id:p(),label:p(),mode:p().optional(),sourcePort:f().optional()}),RW={name:`network-access`,scope:`system`,mode:`collection`,providerKind:`ingress`,methods:{start:O(_(),IW,{kind:`mutation`}),stop:O(_(),_(),{kind:`mutation`}),getEndpoint:O(_(),IW.nullable()),getStatus:O(_(),LW),listEndpoints:O(_(),S(_Ee).readonly())},vocabulary:{notOperatorFacing:A.NETWORK}},zW=[`wifi`,`ethernet`,`cellular`,`unknown`],BW=b({type:x(zW),signal:f().min(0).max(100).nullable().meta(j(`percentage`)),rssi:f().optional().meta(j(`signal-level`)),ssid:p().optional(),lastUpdated:f().meta(j(`none`))}),VW={type:`unknown`,signal:null,lastUpdated:0};function vEe(e,t){return e===void 0||!Number.isFinite(e)||t<=0||e<0||e>t?null:Math.round(e/t*100)}function yEe(e){return e===void 0||!Number.isFinite(e)||e>0?null:Math.round((Math.min(-50,Math.max(-100,e))+100)*2)}var HW={name:`network-link`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Camera,w.Sensor,w.Button,w.Switch,w.Light,w.Lock,w.Siren],methods:{},events:{onStatusChanged:{data:b({deviceId:f(),status:BW}),notOperatorFacing:`the signal / link-type state triggers each read one field of this change`}},status:{schema:BW,kind:`push`,empty:VW},runtimeState:BW,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:N(`Network link`,`Collegamento di rete`),order:5250,state:[{kind:`numeric`,field:`signal`,quantity:N(`the signal strength`,`l’intensità del segnale`),label:N(`Signal`,`Segnale`),unit:`%`,icon:`wifi`},{kind:`enum`,field:`type`,label:N(`Link type`,`Tipo di collegamento`),values:[{value:`wifi`,label:N(`Wi-Fi`,`Wi-Fi`)},{value:`ethernet`,label:N(`Ethernet`,`Ethernet`)},{value:`cellular`,label:N(`Cellular`,`Rete mobile`)},{value:`unknown`,label:N(`Unknown`,`Sconosciuto`)}],icon:`network`}]}},UW=b({nominalBitrateKbps:f(),observedBitrateKbps:f(),peakBitrateKbps:f(),packetLossPercent:f(),lastUpdated:f()}),WW=b({rttMs:f(),jitterMs:f(),estimatedBandwidthKbps:f(),packetLossPercent:f().min(0).max(100),downlinkMbps:f().optional(),downlinkAgeMs:f().optional(),lastUpdated:f()}),GW=b({deviceId:f(),streams:u(p(),UW),client:WW.optional()}),KW={name:`network-quality`,scope:`system`,mode:`singleton`,methods:{getDeviceStats:O(b({deviceId:f()}),GW.nullable()),getAllStats:O(_(),S(GW).readonly()),reportClientStats:O(b({deviceId:f(),rttMs:f().min(0).max(6e4),jitterMs:f().min(0).max(1e4),estimatedBandwidthKbps:f().min(0).max(1e6),packetLossPercent:f().min(0).max(100),downlinkMbps:f().min(0).max(1e5).optional(),downlinkAgeMs:f().min(0).max(864e5).optional()}),_(),{role:`viewer`,kind:`mutation`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:A.NETWORK}},qW=b({cn:p(),serial:p(),fingerprintSha256:p(),notBefore:f(),notAfter:f()}),JW=b({fingerprintSha256:p(),issuer:p(),sans:S(p()),notBefore:f(),notAfter:f()}),YW=i(`state`,[b({state:o(`served`),leaf:JW}),b({state:o(`not-issued`),reason:p()})]),XW={name:`node-certificates`,scope:`system`,mode:`singleton`,internal:!0,methods:{getCertificates:O(b({}),b({nodeId:p(),mesh:qW.nullable(),https:YW}),{auth:`admin`}),prepareMeshRenewal:O(b({}),b({csrPem:p()}),{kind:`mutation`,auth:`admin`}),installMeshLeaf:O(b({certPem:p().min(1),caCertPem:p().min(1),confirmWithinMs:f().int().min(1e4).max(6e5)}),b({fingerprintSha256:p(),serial:p()}),{kind:`mutation`,auth:`admin`}),confirmMeshLeaf:O(b({fingerprintSha256:p()}),b({confirmed:v()}),{kind:`mutation`,auth:`admin`}),rollbackMeshLeaf:O(b({}),b({rolledBack:v()}),{kind:`mutation`,auth:`admin`}),prepareHttpsCertificate:O(b({}),b({csrPem:p(),hostnames:S(p()),addresses:S(p()),pinnedCaFingerprintSha256:p().nullable()}),{kind:`mutation`,auth:`admin`}),forgetHub:O(b({}),b({ok:o(!0)}),{kind:`mutation`,auth:`admin`}),installHttpsCertificate:O(b({certPem:p().min(1),caCertPem:p().min(1),caRotation:v().optional()}),JW,{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:A.IDENTITY}},ZW=b({nodeId:p().min(1),removedAt:f()}),QW=b({counts:u(p(),f().int().nonnegative())}),$W={name:`node-removal-hook`,scope:`system`,mode:`collection`,internal:!0,methods:{onNodeRemoved:O(ZW,QW,{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:A.INTERNAL}},eG=b({addonId:p(),capabilities:S(p()).readonly(),status:p()}),tG=b({pid:f(),name:p(),state:p(),cpuPercent:f(),memoryRss:f(),uptimeSeconds:f(),services:S(eG).readonly(),groupId:p().optional()}),bEe=b({id:p(),status:p(),cpuPercent:f(),memoryRss:f()}),xEe=b({category:p(),total:f(),healthy:f(),addons:S(bEe).readonly()}),SEe=b({name:p(),version:p()}),nG=b({id:p(),name:p(),hostname:p(),platform:p(),arch:p(),cpuModel:p().nullable(),cpuCores:f(),memoryMB:f(),engines:S(p()).readonly(),isHub:v(),isOnline:v(),cpuPercent:f(),memoryPercent:f().nullable(),uptime:f(),lastSeen:p(),localIps:S(p()).readonly(),addons:S(b({id:p(),capabilities:S(p()).readonly(),status:p()})).readonly(),processes:S(tG).readonly(),categories:S(xEe).readonly(),rootPackage:SEe.nullable(),meshTransport:x([`tls`,`clear`]).optional(),capabilitiesRegistered:v().optional()}),CEe=b({callerAddonId:p(),providerAddonId:p(),capName:p(),callsPerMin:f(),lastCallAtMs:f()}),rG=b({nodeId:p(),name:p(),version:p(),status:p(),synced:v()}),iG=b({hubVersion:p(),nodes:S(rG)}),aG=b({nodeId:p(),addonId:p()}),wEe=b({id:p(),status:p(),version:p().optional(),packageName:p().optional()}),oG=b({success:v()}),TEe=b({success:v(),reason:p().optional()}),EEe=b({restarted:S(p()).readonly(),failed:S(p()).readonly()}),DEe=b({nodeId:p(),name:p()}),sG=b({id:p(),name:p(),isHub:v(),isOnline:v()}),cG=b({nodes:S(sG).readonly(),complete:v()}),lG={name:`nodes`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,methods:{topology:O(_(),S(nG).readonly(),{auth:`admin`}),directory:O(_(),cG,{auth:`admin`}),deployAddon:O(aG,oG,{kind:`mutation`,auth:`admin`}),undeployAddon:O(aG,oG,{kind:`mutation`,auth:`admin`}),restartAddon:O(aG,oG,{kind:`mutation`,auth:`admin`}),restartProcess:O(b({nodeId:p(),processName:p()}),TEe,{kind:`mutation`,auth:`admin`}),restartNode:O(b({nodeId:p()}),EEe,{kind:`mutation`,auth:`admin`}),shutdownNode:O(b({nodeId:p()}),oG,{kind:`mutation`,auth:`admin`}),renameNode:O(b({nodeId:p(),name:p().min(1).max(64)}),DEe,{kind:`mutation`,auth:`admin`}),clusterAddonStatus:O(_(),u(p(),iG),{auth:`admin`}),getCapUsageGraph:O(b({windowSeconds:f().int().positive().max(300).default(60)}),S(CEe).readonly(),{auth:`admin`}),getNodeAddons:O(b({nodeId:p()}),S(wEe).readonly(),{auth:`admin`}),setProcessLogLevel:O(b({nodeId:p(),level:p()}),oG,{kind:`mutation`,auth:`admin`}),executeQuery:O(b({nodeId:p(),addonId:p(),queryName:p(),params:u(p(),l()).optional()}),l(),{kind:`mutation`,auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:A.CLUSTER}},uG=[{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`}],dG={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},fG={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},pG=new Map;for(let[e,t]of Object.entries(dG.mapping))pG.set(e.toLowerCase(),t);for(let[e,t]of Object.entries(fG.mapping))pG.set(e.toLowerCase(),t);function OEe(e){return pG.get(e.toLowerCase())??null}function kEe(){return uG.map(e=>e.id)}var mG=BM();function hG(e){return GM(mG.swatches,mG.fallbacks,e)}function AEe(e){let t=e[0];if(t===void 0)throw Error(`display palette has no fallback colour`);return t}var jEe=AEe(mG.fallbacks);function MEe(e){return e.split(/[-_ ]/).filter(e=>e.length>0).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}var gG=new Map;function _G(e,t,n,r){gG.set(e,{kind:e,parentKind:null,level:`macro`,category:t,color:hG(e),iconId:n,labelKey:`eventKind.${e}`,label:r})}function vG(e,t,n,r,i){gG.set(e,{kind:e,parentKind:t,level:`sub`,category:n,color:hG(e),iconId:r,labelKey:`eventKind.${e}`,label:i})}_G(`motion`,`motion`,`motion`,`Motion`),_G(`audio`,`audio`,`audio`,`Audio`),_G(`person`,`detection`,`person`,`Person`),_G(`vehicle`,`detection`,`vehicle`,`Vehicle`),_G(`animal`,`detection`,`animal`,`Animal`),_G(`package`,`package`,`package`,`Package`),_G(`sensor`,`sensor`,`sensor`,`Sensor`),_G(`control`,`control`,`control`,`Control`);for(let[e,t]of Object.entries(Ng.mapping))t!==`vehicle`&&t!==`animal`||gG.has(e)||vG(e,t,`detection`,e,MEe(e));vG(`package-delivered`,`package`,`package`,`package`,`Package delivered`),vG(`package-picked-up`,`package`,`package`,`package`,`Package picked up`),vG(`contact`,`sensor`,`sensor`,`door`,`Contact`),vG(`motion-sensor`,`sensor`,`sensor`,`pir`,`Motion sensor`),vG(`smoke`,`sensor`,`sensor`,`smoke`,`Smoke`),vG(`flood`,`sensor`,`sensor`,`water`,`Water leak`),vG(`gas`,`sensor`,`sensor`,`gas`,`Gas`),vG(`carbon-monoxide`,`sensor`,`sensor`,`smoke`,`Carbon monoxide`),vG(`vibration`,`sensor`,`sensor`,`vibration`,`Vibration`),vG(`tamper`,`sensor`,`sensor`,`tamper`,`Tamper`),vG(`presence`,`sensor`,`sensor`,`presence`,`Presence`),vG(`enum-sensor`,`sensor`,`sensor`,`generic`,`Sensor state`),vG(`device-event`,`sensor`,`sensor`,`button`,`Device event`),vG(`lock`,`control`,`control`,`lock`,`Lock`),vG(`cover`,`control`,`control`,`door`,`Cover`),vG(`switch`,`control`,`control`,`switch`,`Switch`),vG(`siren`,`control`,`control`,`siren`,`Siren`),vG(`button`,`control`,`control`,`button`,`Button`),vG(`doorbell`,`control`,`control`,`doorbell`,`Doorbell`),vG(`appliance-cycle`,`control`,`control`,`switch`,`Appliance cycle`);for(let e of uG){let t=`audio-${e.id}`;gG.has(t)||vG(t,`audio`,`audio`,t,e.name)}var yG=Object.freeze(Object.fromEntries(gG));function bG(e){return yG[e]}function NEe(e){return hG(e)}function PEe(e){let t=[];for(let n of Object.values(yG))n.parentKind===e&&t.push(n);return t}var xG=b({kind:p(),label:p(),parentKind:p().nullable()}),SG=b({videoClasses:S(xG),audioKinds:S(xG),labels:S(xG)});function CG(e,t,n){return{kind:e,label:t,parentKind:n}}function wG(){let e=Object.values(yG);return{videoClasses:e.filter(e=>e.category===`detection`).map(e=>CG(e.kind,e.label,e.parentKind)),audioKinds:e.filter(e=>e.category===`audio`&&e.level===`sub`).map(e=>CG(e.kind,e.label,e.parentKind)),labels:e.filter(e=>e.category===`sensor`||e.category===`control`).map(e=>CG(e.kind,e.label,e.parentKind))}}var FEe=Object.freeze(wG()),TG=x([`immediate`,`track-end`,`device-event`,`package-event`,`system-event`]),EG=x(`device-online.device-offline.device-disabled.device-enabled.device-battery-low.device-battery-normal.device-consumable-low.device-consumable-normal.stream-online.stream-offline.node-online.node-offline.node-restarting.node-updating.node-inference-unavailable.detection-blind.motion-noisy.motion-calm.package-llm-silent.package-llm-answered.recording-stalled.recording-healthy.recording-degraded.device-attention-required.device-attention-resolved.device-command.storage-location-low.storage-location-critical.storage-location-ok.storage-drain-progress.storage-drain-complete.addon-crash-loop.addon-update-available.server-update-available.wrapper-update-available.alarm-triggered.alarm-armed.alarm-disarmed.alarm-arming.alarm-arm-refused.alarm-pending.alarm-rearmed.alarm-sensor-bypass.alarm-check-failed.addon-updated.server-updated.export-completed.backup-completed.alert-critical.alert-error.alert-critical-resolved.rule-broken.rule-repaired.camera-online.camera-offline.camera-disabled.camera-enabled`.split(`.`)),DG=[`camera-online`,`camera-offline`,`camera-disabled`,`camera-enabled`],IEe=new Set(DG),LEe=EG.options.filter(e=>!IEe.has(e)),OG=[`alarm-arm-refused`,`alarm-check-failed`,`alarm-arming`,`alarm-armed`,`alarm-pending`,`alarm-triggered`,`alarm-rearmed`,`alarm-sensor-bypass`,`alarm-disarmed`],REe=[`device-battery-low`,`device-battery-normal`,`device-consumable-low`,`device-consumable-normal`],kG=[`device-consumable-low`,`device-consumable-normal`],zEe=15,BEe=95,AG=[`confirmed`,`already`,`unconfirmed`,`failed`],jG=[`user`,`addon`,`action`,`scheduler`,`composition`,`node`],MG=b({kinds:S(EG).min(1),deviceIds:S(f().int()).min(1).optional(),deviceTypes:S(p().min(1)).min(1).optional(),excludeDeviceIds:S(f().int()).min(1).optional(),nodeIds:S(p().min(1)).min(1).optional(),packageNames:S(p().min(1)).min(1).optional(),commandActions:S(p().min(1)).min(1).optional(),commandOutcomes:S(x(AG)).min(1).optional(),commandActorKinds:S(x(jG)).min(1).optional(),consumableLowPercent:f().int().min(1).max(95).optional()});function VEe(e){return e.consumableLowPercent??15}var HEe=1,NG=1440,UEe=[10,30,60],PG=b({days:S(f().int().min(0).max(6)).min(1),startMinute:f().int().min(0).max(1439),endMinute:f().int().min(0).max(1439)}),FG=b({windows:S(PG).min(1),timezone:p().optional(),invert:v().optional()}),IG=x([`instant`,`summary`]),WEe=x([`activation`,`deactivation`,`schedule`]),LG=x([`rule`,`section`]),RG=i(`mode`,[b({mode:o(`instant`)}),b({mode:o(`summary`),schedule:FG,split:LG.optional()}),b({mode:o(`modes`),onActivation:v(),onDeactivation:v(),onSchedule:b({schedule:FG,grouping:LG}).optional()})]),zG=b({values:S(p().min(1)),maxDistance:f().int().min(0).max(3).default(1)}),BG=b({zoneId:p().optional(),className:p().optional(),op:x([`became-occupied`,`became-free`,`>=`,`<=`]).default(`became-occupied`),count:f().int().min(0).default(1),sustainSeconds:f().int().min(0).max(3600).default(15)}),GEe=-96,VG=b({labels:S(p().min(1)).min(1).optional(),dbThreshold:f().min(-96).max(0).optional(),hitPercent:f().int().min(1).max(100).default(60),samplingSeconds:f().int().min(1).max(300).default(10),confirmHits:f().int().min(1).max(20).optional(),confirmWindowSec:f().int().min(1).max(60).optional()}),HG=x([`enter`,`exit`,`any`]),UG=x([`raised`,`cleared`]),WG=b({ids:S(p().min(1)).min(1),match:x([`any`,`all`]).optional()}),GG=p().min(1),KG=S(GG).max(4),qG=b({id:p().min(1).max(64),label:p().min(1).max(40),actionId:GG,icon:Ql.optional(),destructive:v().optional()}),JG=b({onActivation:KG.optional(),onDeactivation:KG.optional(),onTrigger:KG.optional(),onTriggerOff:KG.optional(),buttons:S(qG).max(8).optional()}),YG=b({deviceId:f().int(),states:S(p().min(1)).min(1)}),XG=b({sceneId:p().min(1),deviceId:f().int().optional(),requiredState:x([`matched`,`diverged`]),latched:v().optional()}),ZG=b({deviceState:YG.optional(),scene:XG.optional(),devices:S(f()).optional(),devicesExclude:S(f()).min(1).optional(),classes:S(p().min(1)).optional(),classesExclude:S(p().min(1)).optional(),minConfidence:f().min(0).max(1).optional(),zones:WG.optional(),zonesExclude:S(p().min(1)).optional(),crossing:HG.optional(),labelEquals:S(p().min(1)).optional(),identities:S(p().min(1)).optional(),plates:zG.optional(),identitiesExclude:S(p().min(1)).optional(),minImportance:f().min(0).max(1).optional(),minDwellSeconds:f().min(0).optional(),source:x([`pipeline`,`onboard`,`sensor`,`audio`,`any`]).optional(),minLabelConfidence:f().min(0).max(1).optional(),eventTypeTokens:S(p().min(1)).optional(),sensorKinds:S(p().min(1)).optional(),sensorTransition:UG.optional(),packagePhase:x([`delivered`,`picked-up`,`both`]).optional(),systemEvent:MG.optional(),customZones:S(bB).optional(),occupancy:BG.optional(),audio:VG.optional()}),QG=b({targetId:p().min(1),params:u(p(),l()).optional()}),KEe=500,$G=x([`none`,`image`,`clip`,`gif`]),eK=b({template:b({title:p().max(500).optional(),body:p().max(2e3).optional()}).optional(),schedule:FG.optional(),priority:f().int().min(1).max(5).optional(),attachment:$G.optional(),actions:v().optional()}),tK=u(p(),eK),nK=x([`scene-boxes`,`crop`,`clean`,`none`]),rK=x([`cropped`,`full`,`boxed`]),iK=x([`mosaic`,`each`]),qEe=4,JEe=6,aK=b({image:nK.optional(),showTriggerZone:v().optional(),showSubjectPath:v().optional(),attach:x([`best`,`best-matching`,`keyFrame`,`none`]).optional(),frame:rK.optional(),zoneCrop:v().optional(),gif:v().optional(),clip:v().optional(),clipPreRollSec:f().int().min(0).max(30).optional(),clipPostRollSec:f().int().min(0).max(30).optional(),clipSpeed:f().min(1).max(8).optional(),profile:M.optional(),linkedCameras:iK.optional(),wakeSleepingCamera:v().optional()}),oK=x([`shared`,`per-class`]),sK=b({cooldownSec:f().int().min(0).max(86400).default(60),scope:x([`rule`,`rule-device`]).default(`rule-device`),granularity:oK.optional()}),cK=1e3,lK=2e4,uK=8e3,YEe=448,dK=b({op:x([`>=`,`>`,`<=`,`<`,`==`]),count:f().int().min(0).max(1e3)}),fK=b({enabled:v().default(!1),profileId:p().optional(),prompt:p().max(1e3).optional(),expect:dK.optional(),timeoutMs:f().int().min(cK).max(lK).default(uK),onTimeout:x([`fire`,`suppress`]).default(`fire`),maxImagePx:f().int().min(64).max(2048).default(448)}),XEe=5,ZEe=20,QEe=60,$Ee=5,eDe=0,tDe=300,pK=b({name:p().min(1).max(200),enabled:v().default(!0),delivery:TG,conditions:ZG.default({}),schedule:FG.optional(),systemEventDelivery:RG.optional(),targets:S(QG),targetUsers:S(p()).optional(),targetOverrides:tK.optional(),media:aK.default({}),throttle:sK.default({cooldownSec:60,scope:`rule-device`}),template:b({title:p().max(500).optional(),body:p().max(2e3).optional()}).optional(),priority:f().int().min(1).max(5).default(3),ownerUserId:p().optional(),snoozeAllowGlobal:v().optional(),snoozeOptions:S(f().int().min(1).max(NG)).max(4).optional(),actions:JG.optional(),confirm:fK.optional(),groupingSec:f().int().min(5).max(60).optional(),groupWithinSec:f().int().min(0).max(300).optional(),askVerdict:v().optional()}),mK=pK.partial().extend({disabledTargetIds:S(p()).optional(),enabled:v().optional(),conditions:ZG.optional(),media:aK.optional(),throttle:sK.optional(),priority:f().int().min(1).max(5).optional()}),hK=[`waitForEnhancement`,`groupIdleSec`];function nDe(e){return hK.some(t=>t===e)}var gK=[`template`,`schedule`,`targetUsers`,`snoozeOptions`,`snoozeAllowGlobal`,`actions`,`confirm`,`groupingSec`,`waitForEnhancement`,`groupIdleSec`],_K=x(gK),vK=b({ruleId:p(),patch:mK,clear:S(_K).optional()}),yK=pK.extend({id:p(),createdBy:p(),createdAt:f(),updatedAt:f(),disabledTargetIds:S(p()).default([])}),bK=[`device-state`,`streams`,`battery`,`consumables`,`detection-blind`,`nodes`,`addons`,`addon-updates`,`updates`],xK=x(bK),SK=b({id:xK,status:x([`read`,`unavailable`]),items:f().int().nonnegative(),reason:p().optional()}),CK=b({section:xK.optional(),title:p(),text:p(),count:f().int().nonnegative()}),wK=b({empty:v(),count:f().int().nonnegative(),text:p(),sections:S(SK),dropped:u(p(),f().int().nonnegative()),excludedGroups:S(p()),split:LG.optional(),rows:S(CK).optional()}),TK=b({recordId:p(),recordKind:x([`object-event`,`track`,`device-event`,`package-event`,`system-event`]),deviceId:f(),timestamp:f(),wouldFire:v(),failedCondition:p().optional(),className:p().optional(),label:p().optional()}),EK=x([`detection`,`sensor`,`occupancy`,`sound`,`device-events`,`system`,`alarm`,`mixed`]),DK=x([`detection`,`sensor`,`occupancy`,`sound`,`system`]),OK=b({id:x([`appliance-cycle`]),kind:EK,title:p(),body:p()}),kK=x([`rule`,`timelapse`,`summary`]),AK=x([`title`,`body`,`previewText`,`captionText`]),jK=x([`subject`,`place`,`time`,`rule`,`occupancy`,`sound`,`sensor`,`system`,`digest`,`ai`]),MK=b({name:p().regex(/^\w+$/),label:p(),description:p().optional(),example:p(),group:jK,families:S(kK).min(1),fields:S(AK).optional(),kinds:S(DK).optional(),deliveries:S(TG).optional(),systemEventKinds:S(EG).optional(),systemEventDeliveries:S(IG).optional(),dynamic:b({prefix:o(`count_`),from:o(`classes`)}).optional()}),NK=b({family:kK,field:AK,kind:EK.optional(),delivery:TG.optional(),systemEventKinds:S(EG).optional(),systemEventDelivery:IG.optional()}),PK=b({context:NK,template:b({title:p().max(500).optional(),body:p().max(2e3).optional()})}),FK=b({title:p().nullable(),body:p().nullable(),unknown:S(p())}),IK=b({id:p(),group:x([`scope`,`class`,`zones`,`quality`,`label`,`schedule`,`device`,`package`,`occupancy`,`audio`,`system`]),label:p(),valueType:x([`deviceIdList`,`deviceIdExcludeList`,`stringList`,`number01`,`number`,`sourceSelect`,`zoneSelection`,`zoneIdList`,`schedule`,`plateMatcher`,`packagePhase`,`crossingSelect`,`sensorTransition`,`polygonDraw`,`occupancy`,`audio`,`deviceState`,`scene`,`systemEvent`]),operator:x([`in`,`notIn`,`anyOf`,`allOf`,`gte`,`fuzzyIn`,`withinSchedule`]),appliesTo:S(TG),phase:p(),description:p().optional(),options:S(b({value:p(),label:p(),hint:p().optional()})).readonly().optional()}),rDe=[{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.`}],LK=x([`pending`,`sent`,`dead`]),RK=x([`object-event`,`track-end`,`device-event`,`package-event`,`system-event`]),zK=b({className:p(),label:p().optional(),confidence:f().optional(),zones:S(p()),timestamp:f(),systemEvent:b({kind:EG,subject:p(),title:p(),body:p(),data:u(p(),l())}).optional()}),BK=b({id:p(),ruleId:p(),ruleName:p(),delivery:TG,targetId:p(),deviceId:f(),recordKind:RK,recordId:p(),trackId:p().optional(),status:LK,attempts:f().int(),createdAt:f(),updatedAt:f(),error:p().optional(),subject:zK,title:p().optional(),body:p().optional(),artifactIds:S(p().min(1)).optional(),groupedInto:p().min(1).optional()}),iDe=100,aDe=500,VK=b({ruleId:p().optional(),deviceId:f().optional(),status:LK.optional(),since:f().optional(),until:f().optional(),limit:f().int().min(1).max(500).default(100)}),HK=b({ruleId:p(),lastAt:f(),status:LK,deviceId:f()}),UK=b({runs:S(HK),horizonMs:f().nonnegative().nullable()}),WK=x([`rule`,`device`,`all`]),GK=b({scope:WK,ruleId:p().optional(),deviceId:f().int().optional(),classes:S(p().min(1)).min(1).optional(),durationMinutes:f().int().min(1).max(NG),global:v().optional(),summary:v().optional()}),KK=b({id:p(),userId:p(),scope:WK,ruleId:p().optional(),deviceId:f().int().optional(),classes:S(p().min(1)).min(1).optional(),startedAt:f(),expiresAt:f(),global:v(),summary:v(),digestSentAt:f().optional()}),oDe=b({snoozeId:p(),targetId:p(),ruleId:p(),ruleName:p(),deviceId:f().int(),count:f().int(),firstAt:f(),lastAt:f()}),sDe=600,qK=3600,cDe=200,JK=f().int().min(0).max(600),YK=f().int().min(0).max(qK),XK=e=>new Set(e.map(e=>e.mode)).size===e.length,ZK=x([`rearmAfter`,`disableAfter`,`doNothing`]),QK=b({mode:cS,exitDelaySec:JK.optional(),entryDelaySec:JK.optional(),triggeredDurationSec:YK.optional(),postTriggeredAction:ZK.optional(),schedule:FG.optional(),notifyDuringEntryDelay:v().optional(),notifySensorRewatched:v().optional(),notifySensorIgnored:v().optional()}),lDe=S(QK).max(8).refine(XK,{message:`modeDelays: at most one entry per arm mode`}),$K=b({mode:cS,exitDelaySec:JK.nullable().optional(),entryDelaySec:JK.nullable().optional(),triggeredDurationSec:YK.nullable().optional(),postTriggeredAction:ZK.nullable().optional(),schedule:FG.nullable().optional(),notifyDuringEntryDelay:v().nullable().optional(),notifySensorRewatched:v().nullable().optional(),notifySensorIgnored:v().nullable().optional()}),uDe=S($K).max(8).refine(XK,{message:`modeDelays: at most one edit per arm mode`}),eq=b({mode:cS,deviceId:f().int().positive(),nonBlocking:v()}),tq=b({mode:cS,deviceId:f().int().positive(),blocking:v()}),nq=b({mode:cS,deviceId:f().int().positive(),secureOnArm:v()}),rq=b({mode:cS,deviceIds:S(f().int()).max(200)}),iq=rq,aq=rq,oq=rq,sq=S(iq).max(8).refine(XK,{message:`nonBlocking: at most one list per arm mode`}),cq=S(aq).max(8).refine(XK,{message:`blocking: at most one list per arm mode`}),lq=S(oq).max(8).refine(XK,{message:`secureOnArmOff: at most one list per arm mode`}),uq=b({exitDelaySec:JK,entryDelaySec:JK,triggeredDurationSec:YK,postTriggeredAction:ZK.optional(),announceArm:v().optional(),announceTargets:S(p().min(1)).max(16),nonBlocking:sq.default([]),blocking:cq.default([]),secureOnArmOff:lq.default([]),modeDelays:lDe.default([])}),dq=b({id:p().min(1).max(64),name:p().min(1).max(64),isDefault:v()}),fq=b({activeId:p().min(1),items:S(dq).min(1)}),pq=b({name:p().min(1).max(64),cloneFromId:p().min(1).max(64).optional()}),mq=b({id:p().min(1).max(64),name:p().min(1).max(64)}),hq=b({id:p().min(1).max(64)}),gq=uq.extend({nonBlocking:sq,blocking:cq,secureOnArmOff:lq,modeDelays:uDe,nonBlockingEdit:eq,blockingEdit:tq,secureOnArmEdit:nq}).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`}),dDe=x([`muted`,`detection-off`,`offline`]),_q=b({deviceId:f().int(),reason:dDe}),vq=b({mode:cS,ruleCount:f().int().min(0),allDevices:v(),deviceIds:S(f().int()),allDevicesExcept:S(f().int()).default([]),skippedDevices:S(_q).default([])}),fDe=b({deviceId:f().int(),name:p(),state:p(),blocking:v()}),pDe=b({deviceId:f().int(),name:p(),phase:x([`open`,`closed`])}),mDe=b({mode:cS,devices:S(fDe),unknown:S(f().int())}),hDe=b({ruleId:p(),ruleName:p(),deviceId:f().int(),name:p(),since:f(),dropped:f().int().min(0)}),gDe=b({state:sS,targetMode:cS.nullable(),availableModes:S(cS),openings:S(mDe),exclusions:S(pDe),bypassedInputs:S(hDe).default([])}),yq=b({deviceId:f().int().nullable(),settings:uq,profiles:fq.optional(),coverage:S(vq),live:gDe.optional()}),_De=500,bq=x([`open`,`closed`,`unknown`,`not-opening`]),xq=b({deviceId:f().int().positive(),reading:bq,state:p().nullable(),unknownWhy:x([`read-failed`,`unknown-word`]).nullable(),online:v().nullable(),controllable:v().default(!1)}),Sq=b({deviceIds:S(f().int().positive()).max(500)}),Cq=b({sensors:S(xq),readAt:f().int().nonnegative()}),vDe=60,wq=b({deviceId:f().int().nonnegative().optional(),seconds:f().min(0).max(60),profile:M.optional(),ruleId:p(),ruleName:p(),reason:x([`window`,`occupancy`])}),Tq=b({rulesLoaded:v(),asks:S(wq).readonly()}),Eq={name:`notification-rules`,scope:`system`,mode:`singleton`,methods:{listRules:O(b({}),b({rules:S(yK)}),{auth:`admin`}),getRule:O(b({ruleId:p()}),b({rule:yK.nullable()}),{auth:`admin`}),createRule:O(b({rule:pK}),b({rule:yK}),{kind:`mutation`,auth:`admin`,caller:`required`}),updateRule:O(vK,b({rule:yK}),{kind:`mutation`,auth:`admin`,caller:`required`}),deleteRule:O(b({ruleId:p()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),setRuleEnabled:O(b({ruleId:p(),enabled:v()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),getClipRetentionAsks:O(b({}),Tq,{auth:`admin`}),listDeviceMutes:O(b({}),b({mutedDeviceIds:S(f().int()).readonly()}),{auth:`admin`}),setDeviceMuted:O(b({deviceId:f().int(),muted:v()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),testRule:O(b({rule:pK,lookbackMinutes:f().int().min(1).max(1440).default(60)}),b({results:S(TK)}),{kind:`mutation`,auth:`admin`}),previewStateSummary:O(b({rule:pK}),wK,{kind:`mutation`,auth:`admin`,access:`view`}),getConditionCatalog:O(b({}),b({catalog:S(IK),taxonomy:SG.optional()})),getTemplateCatalog:O(b({}),b({vars:S(MK),defaults:S(OK)})),previewTemplate:O(PK,FK,{kind:`mutation`,access:`view`}),getHistory:O(b({filter:VK.default({limit:100})}),b({entries:S(BK)}),{auth:`admin`}),getRuleLastRuns:O(b({}),UK,{auth:`admin`}),resolveArtifactUrl:O(b({artifactId:p().min(1)}),b({url:p().nullable()}),{auth:`admin`}),listSnoozes:O(b({}),b({snoozes:S(KK)}),{caller:`required`}),createSnooze:O(b({snooze:GK}),b({snooze:KK}),{kind:`mutation`,caller:`required`}),cancelSnooze:O(b({snoozeId:p()}),b({success:o(!0)}),{kind:`mutation`,caller:`required`}),getAlarmConfig:O(b({}),yq,{auth:`admin`}),setAlarmConfig:O(b({patch:gq}),yq,{kind:`mutation`,auth:`admin`}),createAlarmProfile:O(pq,yq,{kind:`mutation`,auth:`admin`}),renameAlarmProfile:O(mq,yq,{kind:`mutation`,auth:`admin`}),deleteAlarmProfile:O(hq,yq,{kind:`mutation`,auth:`admin`}),activateAlarmProfile:O(hq,yq,{kind:`mutation`,auth:`admin`}),getAlarmSensors:O(Sq,Cq,{auth:`admin`})},vocabulary:{notOperatorFacing:`notification rules — authored on their own page`}},yDe=x([`min`,`low`,`normal`,`high`]),bDe=b({id:p().min(1),title:p().min(1),uri:m().optional(),destructive:v().optional()}),xDe=b({image:v(),priority:v(),data:v(),actions:v(),recipients:v()}),Dq=b({lastSentAt:f(),lastError:p().nullable(),queueDepth:f().int().nonnegative().meta(j(`count`)),supports:xDe}),SDe=b({deviceId:f().int().nonnegative(),title:p().optional(),body:p().min(1),image:p().optional(),priority:yDe.optional(),channel:p().optional(),recipients:S(p()).optional(),actions:S(bDe).optional(),data:u(p(),l()).optional()}),CDe=b({notificationId:p(),acceptedAt:f()}),Oq={name:`notifier`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Notifier],methods:{send:O(SDe,CDe,{kind:`mutation`,auth:`admin`,actions:[{id:`notifier.send`,label:N(`Send a notification`,`Invia una notifica`),phrase:N(`Send “{body}” through {device}`,`Invia «{body}» tramite {device}`),icon:`send`,openArgs:[{key:`title`,label:N(`Title`,`Titolo`),offer:{kind:`text`},optional:!0},{key:`body`,label:N(`Message`,`Messaggio`),offer:{kind:`text`}},{key:`priority`,label:N(`Priority`,`Priorità`),offer:{kind:`enum`,values:[{value:`min`,label:N(`Minimal`,`Minima`)},{value:`low`,label:N(`Low`,`Bassa`)},{value:`normal`,label:N(`Normal`,`Normale`)},{value:`high`,label:N(`High`,`Alta`)}]},optional:!0}]}]}),cancel:O(b({deviceId:f().int().nonnegative(),notificationId:p().min(1)}),_(),{kind:`mutation`,auth:`admin`})},events:{onSent:{data:b({deviceId:f(),notificationId:p(),success:v(),error:p().nullable(),acceptedAt:f()}),notOperatorFacing:`a delivery receipt of a send this system made — not a fact about the world`}},status:{schema:Dq,kind:`command-driven`},runtimeState:Dq,durability:`session`,history:`none`,vocabulary:{noun:N(`Notifier`,`Notificatore`),order:2110}},kq=b({value:f().nullable().meta(j(`device`)),lastFetchedAt:f()}),Aq={name:`numeric-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Sensor],methods:{},status:{schema:kq,kind:`push`},runtimeState:kq,durability:`restored`,history:{fields:{value:{kind:`gauge`,minIntervalMs:3e4}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:N(`Sensor`,`Sensore`),order:5150,state:[{kind:`numeric`,field:`value`,quantity:N(`the reading`,`il valore`),label:N(`Reading`,`Valore`),icon:`gauge`}]}},jq=b({integrationId:p(),displayName:p(),requestedScopes:S(Rh),allowedRedirectPrefixes:S(p()).min(1),allowedPrivateHostPaths:S(p()).optional(),requiresPkce:v().optional(),hubUrl:p().optional(),refreshTokenTtlSec:c([f().int().positive(),o(`never`)]).optional(),instances:S(b({id:p(),displayName:p()})).optional()}),Mq={name:`oauth-integration`,scope:`system`,mode:`collection`,internal:!0,methods:{getDescriptor:O(_(),jq,{auth:`admin`})},vocabulary:{notOperatorFacing:A.IDENTITY}},Nq=x([`text`,`timestamp`,`watermark`]),Pq=x([`top-left`,`top-center`,`top-right`,`bottom-left`,`bottom-center`,`bottom-right`,`custom`]),Fq=b({id:p(),kind:Nq,enabled:v(),text:p().optional(),position:Pq.optional(),availablePositions:S(Pq).readonly(),readOnly:v().optional(),maxCharacters:f().int().positive().optional()}),Iq=b({overlays:S(Fq).readonly()}),Lq=b({enabled:v().optional(),text:p().optional(),position:Pq.optional()}).partial(),Rq={name:`osd`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Camera],methods:{setOverlay:O(b({deviceId:f(),overlayId:p(),patch:Lq}),_(),{kind:`mutation`,auth:`admin`})},events:{onStatusChanged:{data:b({deviceId:f(),status:Iq}),notOperatorFacing:`an overlay setting changed — configuration, not a happening`}},status:{schema:Iq,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:N(`On-screen text`,`Testo in sovrimpressione`),order:3190}},zq=1024,Bq=b({id:p().min(1).max(64),name:p().min(1).max(64),text:p().max(zq).default(``)}),Vq=i(`kind`,[b({kind:o(`none`)}),b({kind:o(`static`),text:p().max(zq)}),b({kind:o(`template`),templateId:p().min(1).max(64)})]),Hq=b({enabled:v().default(!0),source:Vq,schedule:FG.optional(),conditions:ZG.optional()}),Uq=b({slotId:p(),kind:Nq,readOnly:v(),cameraEnabled:v(),cameraText:p().optional(),binding:Hq.nullable()}),Wq=x([`written`,`unchanged`,`gated`,`unreadable`,`disabled`,`unbound`,`failed`]),Gq=b({slotId:p(),outcome:Wq,text:p(),reason:p().optional()}),Kq=b({ok:v(),text:p(),notes:S(p())}),qq={name:`osd-manager`,scope:`system`,mode:`singleton`,methods:{getDeviceOsd:O(b({deviceId:f().int()}),b({supported:v(),slots:S(Uq)}),{auth:`admin`}),getConditionSupport:O(b({}),b({supported:S(p()),catalog:S(IK)}),{auth:`admin`}),setSlotBinding:O(b({deviceId:f().int(),slotId:p().min(1),binding:Hq}),b({slot:Uq,render:Gq}),{kind:`mutation`,auth:`admin`}),clearSlotBinding:O(b({deviceId:f().int(),slotId:p().min(1)}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),setSlotCameraEnabled:O(b({deviceId:f().int(),slotId:p().min(1),enabled:v()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),copyDeviceConfiguration:O(b({sourceDeviceId:f().int(),targetDeviceId:f().int()}),b({copied:f().int().nonnegative(),skipped:f().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),previewSlot:O(b({deviceId:f().int(),slotId:p().min(1),binding:Hq.optional()}),Gq,{kind:`mutation`,auth:`admin`}),previewTemplate:O(b({deviceId:f().int(),text:p().max(zq)}),Kq,{kind:`mutation`,auth:`admin`}),renderDevice:O(b({deviceId:f().int()}),b({results:S(Gq)}),{kind:`mutation`,auth:`admin`}),listTemplates:O(b({}),b({templates:S(Bq)}),{auth:`admin`}),upsertTemplate:O(b({template:Bq}),b({template:Bq}),{kind:`mutation`,auth:`admin`}),deleteTemplate:O(b({templateId:p().min(1).max(64)}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:A.PIPELINE}},wDe=4,TDe=200,EDe=x([`normal`,`offline`,`on_batteries`]),Jq=f().int().min(4).max(200),Yq=Jq.meta(Spe({quantity:`mass`,unit:`g`})),Xq=b({foodLevel:f().nullable().meta(j(`none`)),bowlFood:f().nullable().meta(j(`mass`)),eating:v(),supportsMarkRefilled:v(),food1:f().nullable().meta(j(`none`)),food2:f().nullable().meta(j(`none`)),lowFood:v(),batteryPower:f().min(0).max(100).nullable().meta(j(`percentage`)),powerSource:x([`mains`,`battery`]).nullable(),desiccantLeftDays:f().nullable().meta(j(`duration`)),feeding:v(),status:EDe.nullable(),error:p().nullable(),errorCode:f().nullable().meta(j(`none`)),isDualHopper:v(),childLock:v(),indicatorLight:v(),feedSound:v(),volume:f().meta(j(`none`)),lastFeedGrams:Jq.nullable(),lastFeedHopper1:Jq.nullable(),lastFeedHopper2:Jq.nullable(),lastFetchedAt:f()}),Zq={name:`pet-feeder`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.PetFeeder],methods:{feed:O(b({deviceId:f().int().nonnegative(),grams:Yq.optional(),hopper1:Yq.optional(),hopper2:Yq.optional()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.feed`,label:N(`Feed`,`Dai da mangiare`),phrase:N(`Dispense {grams} from {device}`,`Eroga {grams} da {device}`),icon:`paw-print`,openArgs:[{key:`grams`,label:N(`Grams`,`Grammi`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0}]},{id:`petFeeder.feedHoppers`,label:N(`Feed from both hoppers`,`Eroga da entrambi i serbatoi`),phrase:N(`Dispense {hopper1} and {hopper2} from {device}`,`Eroga {hopper1} e {hopper2} da {device}`),icon:`paw-print`,openArgs:[{key:`hopper1`,label:N(`Hopper 1`,`Serbatoio 1`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0},{key:`hopper2`,label:N(`Hopper 2`,`Serbatoio 2`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0}]}]}),cancelFeed:O(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.cancelFeed`,label:N(`Cancel feeding`,`Annulla l’erogazione`),phrase:N(`Cancel the feeding on {device}`,`Annulla l’erogazione di {device}`),icon:`circle-x`}]}),callPet:O(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.callPet`,label:N(`Call pet`,`Chiama l’animale`),phrase:N(`Call your pet with {device}`,`Chiama l’animale con {device}`),icon:`megaphone`}]}),playSound:O(b({deviceId:f().int().nonnegative(),soundId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.playSound`,label:N(`Play sound`,`Riproduci un suono`),phrase:N(`Play sound {soundId} on {device}`,`Riproduci il suono {soundId} su {device}`),icon:`volume-2`,openArgs:[{key:`soundId`,label:N(`Sound`,`Suono`),offer:{kind:`number`,min:0,step:1}}]}]}),resetDesiccant:O(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.resetDesiccant`,label:N(`Desiccant replaced`,`Essiccante sostituito`),phrase:N(`Mark the desiccant of {device} as replaced`,`Segna come sostituito l’essiccante di {device}`),icon:`refresh-cw`}]}),markFoodReplenished:O(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.foodReplenished`,label:N(`Food refilled`,`Cibo ricaricato`),phrase:N(`Mark {device} as refilled`,`Segna {device} come ricaricato`),icon:`package`}]}),setChildLock:O(b({deviceId:f().int().nonnegative(),on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.childLockOn`,label:N(`Child lock on`,`Blocco bambini attivo`),phrase:N(`Turn on the child lock of {device}`,`Attiva il blocco bambini di {device}`),icon:`lock`,args:{on:!0}},{id:`petFeeder.childLockOff`,label:N(`Child lock off`,`Blocco bambini spento`),phrase:N(`Turn off the child lock of {device}`,`Disattiva il blocco bambini di {device}`),icon:`lock-open`,args:{on:!1}}]}),setIndicatorLight:O(b({deviceId:f().int().nonnegative(),on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.lightOn`,label:N(`Indicator light on`,`Spia accesa`),phrase:N(`Turn on the indicator light of {device}`,`Accendi la spia di {device}`),icon:`lightbulb`,args:{on:!0}},{id:`petFeeder.lightOff`,label:N(`Indicator light off`,`Spia spenta`),phrase:N(`Turn off the indicator light of {device}`,`Spegni la spia di {device}`),icon:`lightbulb-off`,args:{on:!1}}]}),setFeedSound:O(b({deviceId:f().int().nonnegative(),on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.feedSoundOn`,label:N(`Feeding sound on`,`Suono di erogazione attivo`),phrase:N(`Turn on the feeding sound of {device}`,`Attiva il suono di erogazione di {device}`),icon:`volume-2`,args:{on:!0}},{id:`petFeeder.feedSoundOff`,label:N(`Feeding sound off`,`Suono di erogazione spento`),phrase:N(`Turn off the feeding sound of {device}`,`Disattiva il suono di erogazione di {device}`),icon:`volume-x`,args:{on:!1}}]}),setVolume:O(b({deviceId:f().int().nonnegative(),level:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.volume`,label:N(`Set volume`,`Imposta il volume`),phrase:N(`Set the volume of {device} to {level}`,`Imposta il volume di {device} a {level}`),icon:`volume-2`,openArgs:[{key:`level`,label:N(`Volume`,`Volume`),offer:{kind:`number`,min:0,step:1}}]}]})},status:{schema:Xq,kind:`poll`},runtimeState:Xq,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:N(`Pet feeder`,`Distributore di cibo`),order:2030,state:[{kind:`boolean`,field:`lowFood`,label:N(`Food low`,`Cibo in esaurimento`),whenTrue:N(`When {device} runs low on food`,`Quando il cibo di {device} sta finendo`),whenFalse:N(`When {device} has enough food again`,`Quando {device} ha di nuovo cibo a sufficienza`),icon:`package`},{kind:`boolean`,field:`feeding`,label:N(`Feeding`,`In erogazione`),whenTrue:N(`When {device} starts feeding`,`Quando {device} inizia a erogare`),whenFalse:N(`When {device} finishes feeding`,`Quando {device} finisce di erogare`),icon:`paw-print`},{kind:`numeric`,field:`desiccantLeftDays`,quantity:N(`the desiccant life`,`la durata dell’essiccante`),label:N(`Desiccant`,`Essiccante`),unit:`d`,icon:`calendar-clock`}]}},Qq=b({waterLevel:f().min(0).max(100).nullable().meta(j(`percentage`)),waterVolume:f().min(0).nullable().meta(j(`volume`)),empty:v().nullable(),pumpRunning:v().nullable(),error:p().nullable(),lastFetchedAt:f()}),$q=`water`;function DDe(e){let t=e.waterLevel!==null||e.empty===null?null:e.empty?`empty`:`ok`;return{key:$q,label:`Water`,level:e.waterLevel,status:t,kind:`supply`,form:`tank`,lastResetAt:null,resettable:!1}}var ODe=f().int().nonnegative(),eJ={name:`pet-fountain`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.PetFountain],power:{kind:`field`,field:`pumpRunning`,set:`setPump`},methods:{setPump:O(b({deviceId:ODe,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFountain.pumpOn`,label:N(`Pump on`,`Pompa accesa`),phrase:N(`Start the pump of {device}`,`Avvia la pompa di {device}`),icon:`play`,args:{on:!0}},{id:`petFountain.pumpOff`,label:N(`Pump off`,`Pompa spenta`),phrase:N(`Stop the pump of {device}`,`Ferma la pompa di {device}`),icon:`square`,args:{on:!1}}]})},status:{schema:Qq,kind:`push`},runtimeState:Qq,durability:`session`,history:{fields:{waterLevel:{kind:`gauge`,unit:`%`,deadband:1},waterVolume:{kind:`gauge`,unit:`L`}}},vocabulary:{noun:N(`Pet fountain`,`Fontana per animali`),order:2040,state:[{kind:`boolean`,field:`empty`,label:N(`Tank empty`,`Serbatoio vuoto`),whenTrue:N(`When the tank of {device} is empty`,`Quando il serbatoio di {device} è vuoto`),whenFalse:N(`When the tank of {device} is refilled`,`Quando il serbatoio di {device} viene riempito`),icon:`droplet`},{kind:`numeric`,field:`waterLevel`,quantity:N(`the water level`,`il livello dell’acqua`),label:N(`Water level`,`Livello dell’acqua`),unit:`%`,icon:`droplets`}]}},kDe=x(ba),ADe=2,tJ={min:1,max:8},nJ=x([`intel-core-ultra`,`intel-n-series`,`apple-m-base`,`apple-m-pro`,`amd-phoenix`,`unknown`]),rJ=x([`intel-npu`,`intel-igpu`,`amd-igpu`,`amd-npu`,`x86-cpu`,`arm-cpu`,`apple-ane`,`coral`]),iJ=i(`kind`,[b({kind:o(`capacity`),sessions:f(),minSessions:f()}),b({kind:o(`tie-faster`),over:p(),recallDelta:f()}),b({kind:o(`stepped-down`),from:p(),to:p(),limitedBy:p()}),b({kind:o(`no-fit-lightest`),sessions:f(),minSessions:f()}),b({kind:o(`derived-latency`),modelId:p()}),b({kind:o(`cpu-device`)}),b({kind:o(`device-disabled`)}),b({kind:o(`device-unavailable`)}),b({kind:o(`node-offline`)}),b({kind:o(`no-hardware-facts`)}),b({kind:o(`no-measured-data`),hardwareClass:nJ}),b({kind:o(`no-family-build`),format:kDe}),b({kind:o(`kept-custom-pin`),modelId:p(),deviceKey:p()})]),aJ=x([`custom-pin`]),oJ=i(`kind`,[b({kind:o(`table`)}),b({kind:o(`node-benchmark`),resultId:p(),measuredAtMs:f()}),b({kind:o(`estimated`),estimatedFrom:nJ})]),sJ=b({modelId:p(),p50Ms:f(),fps:f(),measured:v(),source:oJ.optional(),estimatedFrom:nJ.optional(),capacitySessions:f(),personRecall:f()}),cJ=b({deviceKey:p(),accelerator:rJ.nullable(),enabled:v(),available:v(),chosen:sJ.nullable(),kept:aJ.optional(),reasons:S(iJ).readonly()}),lJ=b({nodeId:p(),reachable:v(),hardwareClass:nJ.nullable(),cpuModel:p().nullable(),skipped:v(),acceleratorModelId:p().nullable(),devices:S(cJ).readonly(),reasons:S(iJ).readonly()}),uJ=b({stepId:p(),before:p().nullable(),after:p().nullable()}),dJ=b({nodeId:p(),deviceKey:p(),madeExplicit:v(),modelPins:S(uJ).readonly(),thresholds:S(b({stepId:p(),keys:S(p()).readonly()})).readonly()}),fJ=i(`kind`,[b({kind:o(`custom-pin-kept`),nodeId:p(),deviceKey:p(),modelId:p()}),b({kind:o(`custom-registry-unreadable`),error:p()})]),pJ=b({headroom:f().min(.3).max(.5).default(.4),minSessionsPerDevice:f().int().min(tJ.min).max(tJ.max).default(2)}),mJ=b({planHash:p(),family:o(`yolov9`),headroom:f(),minSessionsPerDevice:f(),cameraFps:f(),generatedAt:f(),nodes:S(lJ).readonly(),nodeChanges:S(dJ).readonly(),warnings:S(fJ).readonly()}),hJ=b({planHash:p(),headroom:f().min(.3).max(.5).default(.4),minSessionsPerDevice:f().int().min(tJ.min).max(tJ.max).default(2)}),gJ=b({phase:x([`download`,`node-models`,`redispatch`]),ok:v(),detail:p()}),_J=i(`kind`,[b({kind:o(`applied`),planHash:p(),phases:S(gJ).readonly()}),b({kind:o(`aborted`),phases:S(gJ).readonly()}),b({kind:o(`stale`),plan:mJ}),b({kind:o(`refused`),reason:x([`apply-in-progress`])})]),vJ=x([`least-loaded`,`share`]),yJ=`share`,jDe=`sessionPlacement`;function MDe(e){let t=vJ.safeParse(e);return t.success?t.data:yJ}var bJ=b({nodes:u(p(),f().positive()).default({}),devices:u(p(),u(p(),f().positive())).default({})}),xJ=b({windowMs:f().int().min(6e4).max(1440*60*1e3).default(3600*1e3)}),SJ=b({deviceKey:p(),sessionsNow:f(),sessionsStarted:f(),observedShare:f().nullable()}),CJ=b({nodeId:p(),sessionsNow:f(),sessionsStarted:f(),observedShare:f().nullable(),peakSessions:f(),yieldsAway:f(),devices:S(SJ).readonly()}),wJ=b({deviceId:f(),deviceKey:p(),reason:x([`disabled`,`absent`])}),TJ=b({policy:vJ,windowMs:f(),observedForMs:f(),sessionsNow:f(),clusterPeakSessions:f(),nodes:S(CJ).readonly(),stalePins:S(wJ).readonly()}),EJ=x([`hardware`,`benchmark`]),DJ=x([`no-benchmark-results`,`partial-benchmark-results`]),OJ=b({headroom:f().min(.3).max(.5).default(.4),source:EJ.default(`hardware`)}),kJ=b({deviceKey:p(),share:f(),modelId:p().nullable(),fps:f().nullable(),measured:v(),suggestedMaxSessions:f().nullable()}),AJ=b({nodeId:p(),share:f().nullable(),capacitySessions:f(),devices:S(kJ).readonly(),skippedReason:p().nullable(),capacitySource:EJ.nullable(),capacityFallback:DJ.nullable()}),jJ=b({headroom:f(),source:EJ,cameraFps:f(),minSessionsPerDevice:f(),nodes:S(AJ).readonly()}),MJ=x([`hardware`,`benchmark`,`manual`]),NJ=`benchmark`;function PJ(e){return e!==`manual`}var NDe=.4,PDe=`shareSource`;function FDe(e){if(e===`auto`)return`hardware`;let t=MJ.safeParse(e);return t.success?t.data:NJ}var FJ=b({source:MJ}),IDe=b({nodes:u(p(),f()),devices:u(p(),u(p(),f()))}),IJ=b({deviceKey:p(),eligible:v(),configuredPct:f(),effectivePct:f()}),LJ=b({nodeId:p(),eligible:v(),configuredPct:f(),effectivePct:f(),capacitySource:EJ.nullable(),capacityFallback:DJ.nullable(),devices:S(IJ).readonly()}),RJ=b({source:MJ,policy:vJ,autoPending:v(),computedAt:f().nullable(),trigger:p().nullable(),nodes:S(LJ).readonly(),nodeWeights:u(p(),f()),deviceWeights:u(p(),u(p(),f()))}),zJ=[`motion-without-detections`,`detections-under-floor`,`inference-too-slow`,`frames-shed`,`inference-device-unusable`],BJ=x(zJ),VJ=x([`info`,`warning`,`critical`]),HJ=i(`type`,[b({type:o(`camera`),deviceId:f()}),b({type:o(`node`),nodeId:p()}),b({type:o(`inference-device`),nodeId:p(),deviceKey:p()})]),UJ=b({id:p(),kind:BJ,severity:VJ,subject:HJ,what:p(),evidence:u(p(),f().nullable()),action:p()}),WJ=b({source:p(),entries:f().nullable()}),GJ=b({nodeId:p(),sessionsNow:f(),unusableDevices:S(p()).readonly(),devices:S(b({deviceKey:p(),sessionsNow:f(),usable:v()})).readonly()}),KJ=b({deviceId:f(),nativeCropMissesSincePreviousTick:f().nullable()}),qJ=b({generatedAt:f(),tickMs:f(),camerasSeen:f().nullable(),findings:S(UJ).readonly(),cameraSignals:S(KJ).readonly(),nodes:S(GJ).readonly(),sources:S(WJ).readonly(),notCovered:S(p()).readonly()}),JJ=b({history:f().int().min(1).max(24).default(1)}),YJ=b({latest:qJ.nullable(),previous:S(qJ).readonly()}),LDe=b({engine:PH.optional(),steps:S(Da).readonly(),audio:b({engine:PH.optional(),modelId:p().optional(),enabled:v(),settings:u(p(),l()).readonly().optional()}).nullable().optional()}),XJ=b({modelId:p().optional(),settings:u(p(),l()).optional(),jumpDeviceKey:p().optional()}),ZJ=b({maxCameras:f().int().nonnegative().nullable().default(null),detectWeight:f().positive().optional(),detect:v().optional(),decode:v().optional(),audio:v().optional(),ingest:v().optional(),decodeBudgetMb:f().int().min(1024).max(65536).optional(),maxLiveDecodeWorkers:f().int().min(1).max(32).optional(),reachableHost:p().optional(),color:Uc.optional(),stepSettings:u(p(),u(p(),l()).readonly()).optional(),inferenceDevices:u(p(),b({enabled:v(),weight:f().positive().optional(),maxSessions:f().int().positive().optional(),steps:u(p(),XJ).optional()})).optional()}),RDe=u(p(),u(p(),l()).readonly()),QJ=x([`pipeline`,`onboard`,`none`]),zDe=b({stepToggles:u(p(),v()).optional(),stepSettings:RDe.optional()}),$J=b({deviceId:f(),agentNodeId:p(),pinned:v(),reason:x([`manual`,`capacity`,`hardware-affinity`,`failover`,`rebalance`]),assignedAt:f()}),eY=b({nodeId:p(),online:v(),load:KU,score:f(),decodeHwaccel:p().nullable()}),tY=b({totalAgents:f(),onlineAgents:f(),totalCameras:f(),attachedCameras:f(),activeCameras:f(),avgInferenceTimeMs:f(),queueDepth:f()}),nY=u(p(),p()),rY=b({ownerNodeId:p(),reachableHost:p().optional(),configIssue:p().optional()}),iY=b({camStreamId:p(),codec:p(),width:f(),height:f(),fps:f(),kind:p()}),aY=b({streams:S(iY).readonly()}),oY=b({detectionNodeId:p().nullable(),decoderNodeId:p().nullable(),audioNodeId:p().nullable(),sourceNodeId:p().nullable(),pinned:b({detection:v(),decoder:v(),audio:v()}),reasons:b({detection:p().optional(),decoder:p().optional(),audio:p().optional()})}),sY=b({profile:p(),status:p(),codec:p(),width:f(),height:f(),subscribers:f(),inFps:f().nullable()}),cY=b({profiles:S(sY).readonly(),webrtcSessions:f(),rtspRestream:v()}),lY=b({nodeId:p()}),uY=b({enabled:v(),fps:f()}),dY=x([`idle`,`installing`,`verifying`,`ready`,`failed`]),fY=b({state:dY,error:p().optional()}),pY=x([`idle`,`watching`,`active`]),mY=b({nodeId:p(),engine:b({backend:p(),device:p()}),phase:pY,configuredFps:f(),actualFps:f(),queueDepth:f(),avgInferenceMs:f(),provisioning:fY}),hY=b({nodeId:p(),enabled:v()}),gY=lp,_Y=b({mode:gY,active:v(),storageBytes:f()}),vY=x([`source`,`broker`,`detection`,`recording`,`switches`]),yY=x([`timeout`,`error`,`partial`]),bY=b({stage:vY,reason:yY,elapsedMs:f()}),xY=b({state:x([`idle`,`running`,`done`,`error`]),total:f().int().nonnegative(),completed:f().int().nonnegative(),currentDeviceId:f().int().nullable(),failed:S(f().int()).readonly(),mediaDropped:f().int().nonnegative(),tracks:f().int().nonnegative(),events:f().int().nonnegative(),startedAtMs:f().int().nullable(),finishedAtMs:f().int().nullable(),error:p().nullable()}),SY=b({deviceId:f(),assignment:oY,source:aY,broker:cY.nullable(),decoder:lY.nullable(),motion:uY.nullable(),detection:mY.nullable(),audio:hY.nullable(),recording:_Y.nullable(),switchedOff:S(td).readonly(),cameraSensors:pB.optional(),degraded:S(bY).readonly(),fetchedAt:f()}),CY=[`disabled`,`unavailable`,`cannot-host-camera-root`,`accelerator-preferred`],wY=x(CY),BDe=b({key:p(),backend:p(),device:p(),format:x(ba),available:v(),presence:x([`present`,`absent`,`unknown`]).optional(),enabled:v(),weight:f(),maxSessions:f().nullable(),defaultModelId:p(),steps:u(p(),XJ).optional(),exclusion:wY.nullable()}),TY=i(`kind`,[b({kind:o(`stored`),modelId:p()}),b({kind:o(`absent`),defaultModelId:p()}),b({kind:o(`unreadable`),reason:x(EB),error:p().optional()})]),VDe=b({nodeId:p(),reachable:v(),devices:S(BDe).readonly()}),EY=b({deviceId:f().int().nonnegative(),config:oB.nullable()}),DY=x([`unknown-camera`,`out-of-range`,`no-burst-producer`,`already-looked`]),OY=b({deviceId:f().int().nonnegative(),afterMs:f().finite(),reason:p()}),kY=b({scheduled:v(),dueInMs:f().optional(),refusedBecause:DY.optional()}),AY={name:`pipeline-orchestrator`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,exposesDeviceSettings:!0,methods:{requestOccupancyLook:O(OY,kY,{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:O(Dp,b({paused:o(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:O(Dp,b({resumed:o(!0)}),{kind:`mutation`,auth:`admin`}),assignPipeline:O(b({deviceId:f(),agentNodeId:p()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),unassignPipeline:O(b({deviceId:f()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),setPipelineDevicePin:O(b({deviceId:f(),deviceKey:p()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),getPipelineDevicePin:O(b({deviceId:f()}),b({deviceKey:p().nullable()})),rebalance:O(_(),b({migrated:f(),skipped:S(b({deviceId:f(),targetNodeId:p(),reason:p()})).default([])}),{kind:`mutation`,auth:`admin`}),getPipelineAssignments:O(_(),S($J).readonly()),getPipelineAssignment:O(b({deviceId:f()}),$J.nullable()),getAgentLoad:O(_(),S(eY).readonly()),getClusterModelChoice:O(b({stepId:p()}),TY),getGlobalMetrics:O(_(),tY),getCameraMetrics:O(b({deviceId:f()}),VH.nullable()),getCapabilityBindings:O(b({nodeId:p()}),nY),setCapabilityBinding:O(b({nodeId:p(),capName:p(),addonId:p()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),getIngestOwner:O(_(),rY),assignAudio:O(b({deviceId:f(),nodeId:p()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),unassignAudio:O(b({deviceId:f()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),getAudioAssignment:O(b({deviceId:f()}),b({nodeId:p(),pinned:v(),assignedAt:f()}).nullable()),getAudioNodeLoad:O(_(),S(b({nodeId:p(),deviceCount:f()}))),getAudioAssignments:O(_(),S(b({deviceId:f(),nodeId:p(),pinned:v(),assignedAt:f()}))),getAgentSettings:O(b({agentNodeId:p()}),ZJ.nullable()),listAgentSettings:O(_(),S(b({nodeId:p(),settings:ZJ})).readonly()),removeAgentSettings:O(b({agentNodeId:p()}),b({success:v(),removed:v()}),{kind:`mutation`,auth:`admin`}),setAgentMaxCameras:O(b({agentNodeId:p(),maxCameras:f().int().nonnegative().nullable()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),setAgentCapabilities:O(b({agentNodeId:p(),detect:v().nullable().optional(),audio:v().nullable().optional(),ingest:v().nullable().optional()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),setAgentDecodeLimits:O(b({agentNodeId:p(),decodeBudgetMb:f().int().min(1024).max(65536).nullable().optional(),maxLiveDecodeWorkers:f().int().min(1).max(32).nullable().optional()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),setAgentReachableHost:O(b({agentNodeId:p(),reachableHost:p().nullable().optional(),color:Uc.nullable().optional()}).refine(e=>e.reachableHost!==void 0||e.color!==void 0,{message:`reachableHost or color required`}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),setAgentInferenceDevices:O(b({agentNodeId:p(),inferenceDevices:u(p(),b({enabled:v(),weight:f().positive().optional(),maxSessions:f().int().positive().optional(),steps:u(p(),XJ).optional()}))}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),setNodeStepSettings:O(b({agentNodeId:p(),addonId:p(),settings:u(p(),l()).nullable()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),getNodeInferenceDevices:O(b({nodeId:p()}),VDe),forgetInferenceDevice:O(b({agentNodeId:p(),deviceKey:p()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),resetNodePipelineDefaults:O(b({agentNodeId:p()}),b({success:o(!0),effectiveModelId:p().nullable()}),{kind:`mutation`,auth:`admin`}),planAutoTune:O(pJ,mJ,{auth:`admin`}),applyAutoTune:O(hJ,_J,{kind:`mutation`,auth:`admin`}),setLoadBalancingShares:O(bJ,b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),getPlacementStats:O(xJ,TJ,{auth:`admin`}),getHealthDigest:O(JJ,YJ,{auth:`admin`}),suggestShares:O(OJ,jJ,{auth:`admin`}),getEffectiveShares:O(_(),RJ,{auth:`admin`}),setShareSource:O(FJ,b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkPreflight:O(XH,tU,{auth:`admin`}),startNodeBenchmark:O(XH,i(`kind`,[b({kind:o(`started`),runId:p()}),b({kind:o(`refused`),preflight:tU})]),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkStatus:O(_(),gU,{auth:`admin`}),abortNodeBenchmark:O(b({runId:p()}),b({aborted:v()}),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkCandidates:O(b({nodeId:p()}),bU,{auth:`admin`}),listNodeBenchmarkResults:O(vU,S(yU).readonly(),{auth:`admin`}),deleteNodeBenchmarkResult:O(b({id:p()}),b({deleted:v()}),{kind:`mutation`,auth:`admin`}),getCameraSettings:O(b({deviceId:f()}),zDe.nullable()),setCameraStepToggle:O(b({deviceId:f(),addonId:p(),enabled:v().nullable()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),getCameraDetectionSource:O(b({deviceId:f()}),b({source:QJ,explicit:v(),onboard:b({available:v(),geometry:x([`boxed`,`while-streaming`,`flag-only`,`unknown`])})})),setCameraDetectionSource:O(b({deviceId:f(),source:QJ}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),setCameraStepSettings:O(b({deviceId:f(),addonId:p(),settings:u(p(),l()).nullable()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),resolvePipeline:O(b({deviceId:f(),agentNodeId:p().optional()}),LDe),getCameraSwitches:O(b({deviceId:f()}),sd,{role:`viewer`}),setCameraSwitch:O(b({deviceId:f(),switchId:td,enabled:v()}),sd,{kind:`mutation`,auth:`admin`}),getCameraStatus:O(b({deviceId:f()}),SY),getCameraStatuses:O(b({deviceIds:S(f()).optional()}),S(SY).readonly()),setCameraSensors:O(EY,b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),reconcileFromDisk:O(_(),xY,{kind:`mutation`,auth:`admin`}),getReconcileFromDiskStatus:O(_(),xY,{auth:`admin`})},vocabulary:{notOperatorFacing:A.PIPELINE}},jY=b({id:p(),name:p(),sampleCount:f().int().nonnegative(),coverMediaId:f().int().optional(),coverBase64:p().optional()}),HDe=b({id:p(),text:p(),score:f(),addedAt:f().int(),deviceId:f().int().optional(),base64:p().optional(),mediaId:f().int().optional(),keyFrameMediaId:f().int().optional(),plateBbox:bS.optional()}),MY=b({plateId:p(),deviceId:f().int(),trackId:p(),timestamp:f().int(),text:p(),score:f(),corrected:v(),recognizedVehicleId:p().optional(),vehicleName:p().optional(),assigned:v(),plateBbox:bS.optional(),keyFrameMediaId:f().int().optional(),base64:p().optional(),cropUrl:p().optional(),cropMissReason:p().optional()}),UDe=b({mediaId:f().int(),kind:p(),url:p(),sizeBytes:f(),timestamp:f()}),WDe=b({plateIds:S(p()).readonly(),representativePlateId:p(),representativeText:p(),size:f().int(),cohesion:f()}),NY={name:`plate-gallery`,role:{feature:`plate-assignment`},scope:`system`,mode:`singleton`,methods:{listPlates:O(b({deviceId:f().int().optional(),limit:f().int().positive().optional(),includeCrops:v().optional()}).optional(),S(MY).readonly()),getPlateByTrack:O(b({deviceId:f().int(),trackId:p()}),MY.nullable(),{role:`viewer`}),getPlateMedia:O(b({plateId:p()}),S(UDe).readonly()),searchPlates:O(b({text:p().min(1),maxDistance:f().int().min(0).optional(),limit:f().int().positive().optional(),includeCrops:v().optional()}),S(MY).readonly()),suggestPlateClusters:O(b({maxDistance:f().int().min(0).optional(),minClusterSize:f().int().min(2).optional(),limit:f().int().positive().optional()}).optional(),S(WDe).readonly()),correctPlateText:O(b({plateId:p(),text:p().min(1)}),_(),{kind:`mutation`,auth:`admin`}),deletePlate:O(b({plateId:p()}),_(),{kind:`mutation`,auth:`admin`}),listVehicles:O(b({includeCrops:v().optional()}).optional(),S(jY).readonly()),createVehicle:O(b({name:p().min(1)}),jY,{kind:`mutation`,auth:`admin`}),renameVehicle:O(b({id:p(),name:p().min(1)}),_(),{kind:`mutation`,auth:`admin`}),deleteVehicle:O(b({id:p()}),_(),{kind:`mutation`,auth:`admin`}),listVehicleSamples:O(b({vehicleId:p()}),S(HDe).readonly()),removeVehicleSample:O(b({vehicleId:p(),sampleId:p()}),_(),{kind:`mutation`,auth:`admin`}),moveVehicleSample:O(b({sampleId:p().min(1),toVehicleId:p().min(1)}),_(),{kind:`mutation`,auth:`admin`}),assignPlate:O(b({plateId:p(),vehicleId:p()}),_(),{kind:`mutation`,auth:`admin`}),unassignPlate:O(b({plateId:p()}),_(),{kind:`mutation`,auth:`admin`}),assignPlates:O(b({plateIds:S(p()).min(1),vehicleId:p()}),b({assigned:f().int(),failed:S(p()).readonly()}),{kind:`mutation`,auth:`admin`}),unassignPlates:O(b({plateIds:S(p()).min(1)}),b({unassigned:f().int(),failed:S(p()).readonly()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`the plate gallery — curated on its own page`}},PY={"intel-core-ultra":{"intel-npu":{"yolov9t-320":{p50Ms:2.9,fps:383,measured:!0},"yolov9t-320-int8":{p50Ms:3.8,fps:333,measured:!0},"yolov9t-640":{p50Ms:7.4,fps:139,measured:!0},"yolov9t-640-int8":{p50Ms:7.5,fps:144,measured:!0},"yolov9s-320":{p50Ms:4.4,fps:241,measured:!0},"yolov9s-320-int8":{p50Ms:4.1,fps:264,measured:!0},"yolov9s-640":{p50Ms:12.7,fps:82,measured:!0},"yolov9s-640-int8":{p50Ms:10.7,fps:99,measured:!0},"yolov9m-320":{p50Ms:8.4,fps:123,measured:!0},"yolov9m-320-int8":{p50Ms:6.5,fps:165,measured:!0},"yolov9m-640":{p50Ms:29.5,fps:32,measured:!0},"yolov9m-640-int8":{p50Ms:19.5,fps:52,measured:!0}},"intel-igpu":{"yolov9t-320":{p50Ms:2.6,fps:405,measured:!0},"yolov9t-320-int8":{p50Ms:2.8,fps:324,measured:!0},"yolov9t-640":{p50Ms:6.5,fps:157,measured:!0},"yolov9t-640-int8":{p50Ms:5.6,fps:185,measured:!0},"yolov9s-320":{p50Ms:4.6,fps:200,measured:!0},"yolov9s-320-int8":{p50Ms:4.1,fps:239,measured:!0},"yolov9s-640":{p50Ms:15.2,fps:69,measured:!0},"yolov9s-640-int8":{p50Ms:10.5,fps:99,measured:!0},"yolov9m-320":{p50Ms:11.4,fps:88,measured:!0},"yolov9m-320-int8":{p50Ms:7,fps:127,measured:!0},"yolov9m-640":{p50Ms:40,fps:25,measured:!0},"yolov9m-640-int8":{p50Ms:23.5,fps:44,measured:!0}},"x86-cpu":{"yolov9t-320":{p50Ms:6.9,fps:145,measured:!0},"yolov9t-320-int8":{p50Ms:2.7,fps:405,measured:!0},"yolov9t-640":{p50Ms:23,fps:44,measured:!0},"yolov9t-640-int8":{p50Ms:8.8,fps:124,measured:!0},"yolov9s-320":{p50Ms:15.8,fps:63,measured:!0},"yolov9s-320-int8":{p50Ms:6.5,fps:180,measured:!0},"yolov9s-640":{p50Ms:58.2,fps:17,measured:!0},"yolov9s-640-int8":{p50Ms:20.1,fps:52,measured:!0},"yolov9m-320":{p50Ms:40,fps:25,measured:!0},"yolov9m-320-int8":{p50Ms:14.2,fps:74,measured:!0},"yolov9m-640":{p50Ms:155.8,fps:6,measured:!0},"yolov9m-640-int8":{p50Ms:52.4,fps:19,measured:!0}},coral:{"yolov9s-320-edgetpu":{p50Ms:32,fps:31,measured:!1}}},"intel-n-series":{"intel-igpu":{"yolov9t-320":{p50Ms:15,fps:48,measured:!0},"yolov9t-320-int8":{p50Ms:14.1,fps:67,measured:!0},"yolov9t-640":{p50Ms:38.5,fps:26,measured:!0},"yolov9t-640-int8":{p50Ms:50,fps:20,measured:!0},"yolov9s-320":{p50Ms:41.4,fps:24,measured:!0},"yolov9s-320-int8":{p50Ms:23.3,fps:34,measured:!0},"yolov9s-640":{p50Ms:127.4,fps:8,measured:!0},"yolov9s-640-int8":{p50Ms:81,fps:12,measured:!0},"yolov9m-320":{p50Ms:63.5,fps:16,measured:!0},"yolov9m-320-int8":{p50Ms:66,fps:15,measured:!0},"yolov9m-640":{p50Ms:215.5,fps:5,measured:!0},"yolov9m-640-int8":{p50Ms:163,fps:6,measured:!0}},"x86-cpu":{"yolov9t-320":{p50Ms:86.2,fps:12,measured:!0},"yolov9t-320-int8":{p50Ms:52.7,fps:20,measured:!0},"yolov9t-640":{p50Ms:322.1,fps:3,measured:!0},"yolov9t-640-int8":{p50Ms:205.6,fps:5,measured:!0},"yolov9s-320":{p50Ms:164.4,fps:6,measured:!0},"yolov9s-320-int8":{p50Ms:86.9,fps:12,measured:!0},"yolov9s-640":{p50Ms:341.3,fps:3,measured:!0},"yolov9s-640-int8":{p50Ms:185.3,fps:5,measured:!0},"yolov9m-320":{p50Ms:166.8,fps:6,measured:!0},"yolov9m-320-int8":{p50Ms:226.3,fps:4,measured:!0},"yolov9m-640":{p50Ms:663.5,fps:2,measured:!0},"yolov9m-640-int8":{p50Ms:324.4,fps:3,measured:!0}},coral:{"yolov9s-320-edgetpu":{p50Ms:32,fps:31,measured:!1}}},"amd-phoenix":{"x86-cpu":{"yolov9t-320":{p50Ms:24,fps:42,measured:!0},"yolov9t-320-int8":{p50Ms:12,fps:83,measured:!0},"yolov9t-640":{p50Ms:50,fps:20,measured:!0},"yolov9t-640-int8":{p50Ms:20,fps:50,measured:!0},"yolov9s-320":{p50Ms:30,fps:33,measured:!0},"yolov9s-320-int8":{p50Ms:15,fps:67,measured:!0},"yolov9s-640":{p50Ms:92,fps:11,measured:!0},"yolov9s-640-int8":{p50Ms:27,fps:37,measured:!0},"yolov9m-320":{p50Ms:67,fps:15,measured:!0},"yolov9m-320-int8":{p50Ms:21,fps:48,measured:!0},"yolov9m-640":{p50Ms:229,fps:4,measured:!0},"yolov9m-640-int8":{p50Ms:48,fps:21,measured:!0}},"amd-igpu":{"yolov9t-320":{p50Ms:40,fps:25,measured:!0},"yolov9t-640":{p50Ms:89,fps:11,measured:!0},"yolov9s-320":{p50Ms:65,fps:15,measured:!0},"yolov9s-640":{p50Ms:125,fps:8,measured:!0},"yolov9m-320":{p50Ms:85,fps:12,measured:!0},"yolov9m-640":{p50Ms:228,fps:4,measured:!0}},coral:{"yolov9s-320-edgetpu":{p50Ms:32,fps:31,measured:!0}}},"apple-m-pro":{"apple-ane":{"yolov9t-320":{p50Ms:1.1,fps:952,measured:!0},"yolov9t-640":{p50Ms:3,fps:333,measured:!0},"yolov9s-320":{p50Ms:1.5,fps:667,measured:!0},"yolov9s-640":{p50Ms:5.1,fps:196,measured:!0},"yolov9m-320":{p50Ms:3.2,fps:312,measured:!0},"yolov9m-640":{p50Ms:10.2,fps:98,measured:!0}},coral:{"yolov9s-320-edgetpu":{p50Ms:32,fps:31,measured:!1}}},"apple-m-base":{"apple-ane":{"yolov9t-320":{p50Ms:1.32,fps:758,measured:!1},"yolov9t-640":{p50Ms:3.45,fps:290,measured:!0},"yolov9s-320":{p50Ms:1.8,fps:556,measured:!1},"yolov9s-640":{p50Ms:5.46,fps:183,measured:!0},"yolov9m-320":{p50Ms:3.79,fps:264,measured:!0},"yolov9m-640":{p50Ms:10.34,fps:97,measured:!0}},coral:{"yolov9s-320-edgetpu":{p50Ms:32,fps:31,measured:!1}}}},FY={"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}},IY=.5,GDe=2,KDe=.05,qDe=24,JDe=750,YDe=64,LY=2e3,XDe=12,RY=f().nullable().transform(e=>e!==null&&Number.isFinite(e)&&e>0?e:null),zY=p().nullable().transform(e=>e!==null&&e.trim()!==``?e:null),BY=b({int8:RY,fp16:RY}),VY=b({deviceKey:p(),fullDeviceName:zY,executionUnits:RY,clockMHz:RY,gops:BY.nullable(),architecture:zY,npuName:zY,tops:RY,vendor:zY,webgpuArchitecture:zY,webgpuDevice:zY,computeUnits:RY}),ZDe=b({accelerators:S(VY).nullable()}),HY=[{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*LY}},{hardwareClass:`amd-phoenix`,accelerator:`amd-igpu`,score:{metric:`cu`,value:12}}];function QDe(e){let t=ZDe.safeParse(e);return!t.success||t.data.accelerators===null?null:t.data.accelerators}function UY(e){return e!==null&&e>0?e:null}function WY(e){let t=[],n=UY(e.gops?.int8??null);n!==null&&t.push({metric:`gops-int8`,value:n});let r=UY(e.gops?.fp16??null);r!==null&&t.push({metric:`gops-fp16`,value:r});let i=UY(e.executionUnits),a=UY(e.clockMHz);i!==null&&a!==null&&t.push({metric:`eu-mhz`,value:i*a});let o=UY(e.computeUnits);o!==null&&t.push({metric:`cu`,value:o});let s=UY(e.tops);return s!==null&&t.push({metric:`tops`,value:s}),t}function GY(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 KY(e,t,n){for(let r of WY(e))if(GY(t,r,n)!==null)return r;return null}function qY(e,t,n=HY){return KY(e,t,n)!==null}function JY(e,t,n){if(t!==`unknown`)return e[t]?.[n]}function $De(e){return Math.round(e*10)/10}function eOe(e){return Math.min(2,Math.max(IY,e))}function tOe(e,t,n){let r={};for(let[i,a]of Object.entries(e))r[i]={p50Ms:$De(a.p50Ms/t),fps:Math.max(1,Math.round(a.fps*t)),measured:!1,estimatedFrom:n};return r}function YY(e){let t=e.perf??PY,n=e.references??HY,r=JY(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:KY(e.report,e.accelerator,n);if(i===null)return r===void 0?null:{column:r,estimatedFrom:null};let a=GY(e.accelerator,i,n),o=a===null?void 0:JY(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:tOe(o,eOe(s),a.hardwareClass),estimatedFrom:a.hardwareClass}}var XY=x(ba),nOe=x([`videotoolbox`,`cuda`,`nvdec`,`vaapi`,`qsv`,`d3d11va`,`dxva2`,`amf`,`vdpau`,`drm`,`coreml`,`tensorrt`,`openvino`,`directml`,`webgpu`,`none`]).nullable().optional(),rOe=b({preferred:S(p()).readonly(),rationale:p()}),ZY=x([`h264_videotoolbox`,`hevc_videotoolbox`,`h264_vaapi`,`hevc_vaapi`,`h264_nvenc`,`hevc_nvenc`,`h264_qsv`,`hevc_qsv`,`h264_amf`,`hevc_amf`,`libx264`,`libx265`]);b({encoders:S(b({encoder:ZY,codec:x([`H264`,`H265`]),family:x([`videotoolbox`,`vaapi`,`nvenc`,`qsv`,`amf`,`software`]),available:v(),reason:p().optional()})).readonly(),defaultH264:ZY,defaultH265:ZY,probedAt:f()}),b({methods:S(p()).readonly(),probedAt:f()});var iOe=x([`darwin`,`linux`,`win32`]),aOe=x([`arm64`,`x64`]),oOe=b({type:x([`nvidia`,`amd`,`intel`,`apple`]),name:p(),memoryMB:f().optional()}),sOe=b({type:x([`apple-ane`,`intel-npu`,`amd-xdna`]),name:p().optional(),generation:x([`xdna1`,`xdna2`]).optional()}),QY=x([`usb`,`pci`]),cOe=b({type:o(`coral-edgetpu`),bus:p().optional(),count:f().int().nonnegative().optional(),units:S(b({bus:QY,count:f().int().nonnegative()})).readonly().optional(),unavailable:S(b({bus:QY,count:f().int().nonnegative(),reason:x([`driver-missing`,`device-not-accessible`])})).readonly().optional()}),$Y=b({platform:iOe,arch:aOe,cpuModel:p(),cpuCores:f(),totalRAM_MB:f(),availableRAM_MB:f(),gpu:oOe.nullable(),npu:sOe.nullable(),coral:cOe.nullable().optional(),accelerators:S(VY).readonly().optional()}),eX=b({runtime:o(`python`),backend:p(),format:x([`onnx`,`coreml`,`openvino`,`tflite`]),score:f(),reason:p(),available:v()}),tX=b({key:p(),backend:p(),device:p(),format:XY,runtime:o(`python`),score:f(),available:v()}),lOe=b({hardware:$Y,scores:S(eX).readonly(),bestScore:eX,pythonPath:p().nullable(),devices:S(tX).readonly()}),uOe=b({modelId:p(),name:p(),minRAM_MB:f(),accuracyScore:f(),formats:S(p()).readonly()}),dOe=b({modelId:p(),runtime:o(`python`),backend:p(),format:XY,reason:p()}),fOe=b({devices:S(tX).readonly(),appeared:S(p()).readonly(),disappeared:S(p()).readonly(),usbBus:x([`observed`,`unobservable`]),decidedBy:x([`usb-ids`,`pci`,`delegate-fallback`,`none`])}),nX={name:`platform-probe`,scope:`system`,mode:`singleton`,methods:{getCapabilities:O(_(),lOe),getHardware:O(_(),$Y),resolveInferenceConfig:O(b({requirements:S(uOe).readonly()}),dOe),resolveHwAccel:O(b({prefer:nOe}),rOe),rescanAccelerators:O(_(),fOe,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:A.CLUSTER}},rX=b({power:f().optional().meta(j(`power`,{label:`Power`})),energy:f().optional().meta(j(`energy`,{label:`Energy`})),voltage:f().optional().meta(j(`voltage`,{label:`Voltage`})),current:f().optional().meta(j(`current`,{label:`Current`})),apparentPower:f().optional().meta(j(`apparent-power`)),powerFactor:f().min(0).max(1).optional().meta(j(`ratio`)),lastFetchedAt:f()}),iX=[w.Sensor,w.Switch,w.Light,w.Fan,w.Climate,w.Humidifier,w.WaterHeater,w.MediaPlayer,w.Washer,w.Dryer,w.Dishwasher,w.Vacuum,w.LawnMower,w.PetFeeder],pOe=iX.filter(e=>e!==w.Sensor);function aX(e,t){return{id:e,cardinality:`scalar`,vocabulary:{cap:`power-meter`,stateField:e},deviceTypes:pOe,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 mOe={version:1,targets:[aX(`power`,`W`),aX(`energy`,`kWh`),aX(`voltage`,`V`),aX(`current`,`A`)]},oX={name:`power-meter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:iX,deviceConfig:{ui:{kind:`widget`,widgetId:`host/power-meter-line`,tab:`power`,placement:`hero`,label:`Power`,order:4}},methods:{},status:{schema:rX,kind:`push`},runtimeState:rX,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:mOe,vocabulary:{noun:N(`Power meter`,`Misuratore di energia`),order:5160,state:[{kind:`numeric`,field:`power`,quantity:N(`the power draw`,`il consumo`),label:N(`Power`,`Potenza`),unit:`W`,icon:`zap`},{kind:`numeric`,field:`energy`,quantity:N(`the energy used`,`l’energia consumata`),label:N(`Energy`,`Energia`),unit:`kWh`,icon:`zap`},{kind:`numeric`,field:`voltage`,quantity:N(`the voltage`,`la tensione`),label:N(`Voltage`,`Tensione`),unit:`V`,icon:`zap`},{kind:`numeric`,field:`current`,quantity:N(`the current`,`la corrente`),label:N(`Current`,`Corrente`),unit:`A`,icon:`zap`}]}},hOe=b({latitude:f().min(-90).max(90).meta(j(`angle`)),longitude:f().min(-180).max(180).meta(j(`angle`)),accuracyMeters:f().nonnegative().meta(j(`length`))}),sX=b({state:p(),location:p().nullable(),gps:hOe.nullable(),lastChangedAt:f()}),cX={name:`presence`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Presence],methods:{},status:{schema:sX,kind:`push`},runtimeState:sX,durability:`restored`,history:`none`,volatileStateFields:[`lastChangedAt`],vocabulary:{noun:N(`Presence`,`Presenza`),order:5170,state:[{kind:`value`,field:`state`,label:N(`Where`,`Posizione`),phrase:N(`When {device} is at {value}`,`Quando {device} è in {value}`),icon:`map-pin`}]}},lX=b({pressure:f().nullable().meta(j(`pressure`,{precision:0})),lastFetchedAt:f()}),uX={name:`pressure-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Sensor],methods:{},status:{schema:lX,kind:`push`},runtimeState:lX,durability:`restored`,history:{fields:{pressure:{kind:`gauge`,unit:`hPa`,deadband:.1}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:N(`Pressure`,`Pressione`),order:5180,state:[{kind:`numeric`,field:`pressure`,quantity:N(`the pressure`,`la pressione`),label:N(`Pressure`,`Pressione`),unit:`hPa`,icon:`gauge`}]}},dX=i(`kind`,[yB,bB]),fX=b({id:f(),enabled:v(),shape:dX}),pX=b({enabled:v(),regions:S(fX).nullable(),audioEnabled:v().nullable(),lastFetchedAt:f()}),mX=b({maxRegions:f(),supportedShapes:S(CB),polygonVertices:wB.optional(),supportsAudioMute:v()}),hX=b({enabled:v().optional(),regions:S(fX).optional()}),gX={name:`privacy-mask`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/privacy-mask-grid`,tab:`image`,label:`Privacy Mask`}},methods:{getOptions:O(b({deviceId:f()}),mX),setMask:O(b({deviceId:f(),patch:hX}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`privacy.maskOn`,label:N(`Privacy mask on`,`Maschera privacy attiva`),phrase:N(`Cover the privacy zones of {device}`,`Oscura le zone private di {device}`),icon:`eye-off`,args:{patch:{enabled:!0}}},{id:`privacy.maskOff`,label:N(`Privacy mask off`,`Maschera privacy spenta`),phrase:N(`Uncover the privacy zones of {device}`,`Scopri le zone private di {device}`),icon:`eye`,args:{patch:{enabled:!1}}}]}),setAudioEnabled:O(b({deviceId:f(),enabled:v()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`privacy.micOn`,label:N(`Microphone on`,`Microfono attivo`),phrase:N(`Turn on the microphone of {device}`,`Attiva il microfono di {device}`),icon:`mic`,args:{enabled:!0}},{id:`privacy.micOff`,label:N(`Microphone off`,`Microfono spento`),phrase:N(`Turn off the microphone of {device}`,`Disattiva il microfono di {device}`),icon:`mic-off`,args:{enabled:!1}}]})},status:{schema:pX,kind:`poll`},runtimeState:pX,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:N(`Privacy`,`Privacy`),order:3210,state:[{kind:`boolean`,field:`enabled`,label:N(`Privacy mask`,`Maschera privacy`),whenTrue:N(`When the privacy mask of {device} is turned on`,`Quando si attiva la maschera privacy di {device}`),whenFalse:N(`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:N(`Microphone`,`Microfono`),whenTrue:N(`When the microphone of {device} is turned on`,`Quando si attiva il microfono di {device}`),whenFalse:N(`When the microphone of {device} is turned off`,`Quando si disattiva il microfono di {device}`),icon:`mic`}]}};function gOe(e){return e.length===0?null:e.some(e=>e.audioEnabled)}var _X=x([`home`,`day-mode`,`night-mode`,`day-night-auto`,`set-limits`,`save-limits`,`reboot`,`osd-menu`]),vX=b({id:p(),name:p(),fn:_X.nullable(),writable:v()}),yX=b({pan:f().nullable(),tilt:f().nullable(),zoom:f().nullable()}),bX=b({pan:f().optional(),tilt:f().optional(),zoom:f().optional(),speed:f().optional()}),xX=yX.extend({autofocus:v()}),SX=b({hasPan:v(),hasTilt:v(),hasZoom:v(),supportsPresets:v(),maxPresets:f().optional(),hasAutofocus:v(),speedSteps:f().int().positive().nullable(),moveImpulseMs:f().int().positive().nullable()}),CX=b({presetId:p().nullable(),source:x([`operator`,`firmware`,`native`,`none`])}),wX=b({enabled:v(),seconds:f().int()}),TX={name:`ptz`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/ptz-panel`,tab:`ptz`,topTab:!0,label:`PTZ`,order:0}},methods:{move:O(bX.extend({deviceId:f()}),_(),{kind:`mutation`,notOperatorFacing:`a relative nudge from the live-view joystick; a fixed place is a preset`}),continuousMove:O(bX.extend({deviceId:f()}),_(),{kind:`mutation`,notOperatorFacing:`joystick motion held until released — continuous, not a discrete step`}),goHome:O(b({deviceId:f()}),_(),{kind:`mutation`,actions:[{id:`ptz.goHome`,label:N(`PTZ go home`,`Torna alla posizione iniziale`),phrase:N(`Send {device} to its home position`,`Riporta {device} alla posizione iniziale`),icon:`house`}]}),getPresets:O(b({deviceId:f()}),S(vX)),goToPreset:O(b({deviceId:f(),presetId:p()}),_(),{kind:`mutation`,actions:[{id:`ptz.goToPreset`,label:N(`PTZ go to preset`,`Vai a un preset`),phrase:N(`Move {device} to {presetId}`,`Sposta {device} su {presetId}`),icon:`move`,openArgs:[{key:`presetId`,label:N(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}}]}]}),savePreset:O(b({deviceId:f(),presetId:p(),name:p()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.savePreset`,label:N(`Save PTZ preset here`,`Salva qui un preset`),phrase:N(`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:N(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}},{key:`name`,label:N(`Name`,`Nome`),offer:{kind:`text`}}]}]}),deletePreset:O(b({deviceId:f(),presetId:p()}),_(),{kind:`mutation`,auth:`admin`}),getOptions:O(b({deviceId:f()}),SX),stop:O(b({deviceId:f()}),_(),{kind:`mutation`,actions:[{id:`ptz.stop`,label:N(`Stop moving`,`Ferma il movimento`),phrase:N(`Stop {device} moving`,`Ferma il movimento di {device}`),icon:`square`}]}),getHomePreset:O(b({deviceId:f()}),CX),setHomePreset:O(b({deviceId:f(),presetId:p().nullable()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.setHomePreset`,label:N(`Set PTZ home preset`,`Imposta il preset iniziale`),phrase:N(`Make {presetId} the home position of {device}`,`Rendi {presetId} la posizione iniziale di {device}`),icon:`house`,openArgs:[{key:`presetId`,label:N(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}}]}]}),captureHomeHere:O(b({deviceId:f()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.captureHomeHere`,label:N(`Set PTZ home here`,`Imposta qui la posizione iniziale`),phrase:N(`Make where {device} points now its home position`,`Rendi la posizione attuale di {device} la sua posizione iniziale`),icon:`map-pin`}]}),getHomeReturn:O(b({deviceId:f()}),wX.nullable()),setHomeReturn:O(b({deviceId:f(),enabled:v(),seconds:f().int().min(0).max(3600)}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.setHomeReturn`,label:N(`Set PTZ return home`,`Imposta il ritorno alla posizione iniziale`),phrase:N(`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:N(`Return home`,`Torna alla posizione iniziale`),offer:{kind:`boolean`}},{key:`seconds`,label:N(`Idle seconds`,`Secondi da fermo`),offer:{kind:`number`,min:0,max:3600,step:1,unit:`s`}}]}]}),getPosition:O(b({deviceId:f()}),yX),setAutofocus:O(b({deviceId:f(),enabled:v()}),_(),{kind:`mutation`,actions:[{id:`ptz.autofocusOn`,label:N(`Autofocus on`,`Autofocus attivo`),phrase:N(`Turn on autofocus on {device}`,`Attiva l’autofocus su {device}`),icon:`focus`,args:{enabled:!0}},{id:`ptz.autofocusOff`,label:N(`Autofocus off`,`Autofocus spento`),phrase:N(`Turn off autofocus on {device}`,`Disattiva l’autofocus su {device}`),icon:`focus`,args:{enabled:!1}}]})},status:{schema:xX,kind:`command-driven`},vocabulary:{noun:N(`Pan / tilt / zoom`,`Brandeggio`),order:3220}},EX=b({targetType:p().describe(`Vendor target string (people/vehicle/pet); empty = camera default`),stopDelaySeconds:f().int().min(0).max(300).meta(j(`duration`)),disappearDelaySeconds:f().int().min(0).max(300).meta(j(`duration`))}),DX=b({value:p(),label:p()}),OX=b({enabled:v(),lastChangedAt:f(),currentSettings:EX.nullable(),supportedTargetTypes:S(DX)}),kX=OX.extend({lastFetchedAt:f()}),AX={name:`ptz-autotrack`,scope:`device`,deviceNative:!0,mode:`singleton`,kind:`wrapper`,defaultActive:!1,deviceTypes:[w.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/ptz-autotrack`,tab:`ptz`,topTab:!0,label:`Auto-Tracking`,order:5}},methods:{getStatus:O(b({deviceId:f()}),OX),setEnabled:O(b({deviceId:f(),enabled:v()}),_(),{kind:`mutation`,actions:[{id:`ptz.autotrackOn`,label:N(`Autotrack on`,`Inseguimento attivo`),phrase:N(`Start autotracking on {device}`,`Attiva l’inseguimento automatico su {device}`),icon:`crosshair`,args:{enabled:!0}},{id:`ptz.autotrackOff`,label:N(`Autotrack off`,`Inseguimento spento`),phrase:N(`Stop autotracking on {device}`,`Disattiva l’inseguimento automatico su {device}`),icon:`crosshair`,args:{enabled:!1}}]}),getSettings:O(b({deviceId:f()}),EX.nullable()),setSettings:O(b({deviceId:f(),settings:EX.partial()}),_(),{role:`admin`,kind:`mutation`,notOperatorFacing:`tracking tuning (target type, delays) — set once on the camera’s PTZ page`})},events:{onStatusChanged:{data:b({deviceId:f(),status:OX}),notOperatorFacing:"the `enabled` state trigger phrases both edges of this change"}},status:{schema:OX,kind:`command-driven`},runtimeState:kX,durability:`session`,history:`none`,vocabulary:{noun:N(`Autotracking`,`Inseguimento automatico`),order:3230,state:[{kind:`boolean`,field:`enabled`,label:N(`Autotracking`,`Inseguimento automatico`),whenTrue:N(`When autotracking is turned on for {device}`,`Quando si attiva l’inseguimento automatico di {device}`),whenFalse:N(`When autotracking is turned off for {device}`,`Quando si disattiva l’inseguimento automatico di {device}`),icon:`crosshair`}]}},jX=b({enabled:v().nullable(),onTime:f().min(0).nullable().meta(j(`duration`)),offTime:f().min(0).nullable().meta(j(`duration`)),lastFetchedAt:f()}),MX=f().int().nonnegative(),NX=f().int().min(0),PX={name:`pump-cycle`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.PetFountain],methods:{setEnabled:O(b({deviceId:MX,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.on`,label:N(`Pump cycle on`,`Ciclo pompa attivo`),phrase:N(`Run the pump of {device} on its on/off cycle`,`Fai lavorare la pompa di {device} a ciclo acceso/spento`),icon:`timer`,args:{on:!0}},{id:`pumpCycle.off`,label:N(`Pump cycle off`,`Ciclo pompa spento`),phrase:N(`Run the pump of {device} continuously`,`Fai lavorare la pompa di {device} in continuo`),icon:`timer-off`,args:{on:!1}}]}),setOnMinutes:O(b({deviceId:MX,minutes:NX}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.onMinutes`,label:N(`Set pump run time`,`Imposta il tempo di lavoro della pompa`),phrase:N(`Set the pump of {device} to run {minutes} minutes per cycle`,`Imposta la pompa di {device} a lavorare {minutes} minuti per ciclo`),icon:`timer`,openArgs:[{key:`minutes`,label:N(`Minutes`,`Minuti`),offer:{kind:`number`,min:0,step:1,unit:`min`}}]}]}),setOffMinutes:O(b({deviceId:MX,minutes:NX}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.offMinutes`,label:N(`Set pump rest time`,`Imposta il tempo di riposo della pompa`),phrase:N(`Set the pump of {device} to rest {minutes} minutes per cycle`,`Imposta la pompa di {device} a riposare {minutes} minuti per ciclo`),icon:`timer-off`,openArgs:[{key:`minutes`,label:N(`Minutes`,`Minuti`),offer:{kind:`number`,min:0,step:1,unit:`min`}}]}]})},status:{schema:jX,kind:`push`},runtimeState:jX,durability:`session`,history:`none`,vocabulary:{noun:N(`Pump cycle`,`Ciclo della pompa`),order:2050,state:[{kind:`boolean`,field:`enabled`,label:N(`Pump cycle`,`Ciclo pompa`),whenTrue:N(`When {device} starts running its pump on a cycle`,`Quando {device} inizia a far lavorare la pompa a ciclo`),whenFalse:N(`When {device} runs its pump continuously`,`Quando {device} fa lavorare la pompa in continuo`),icon:`timer`}]}},FX={name:`reboot`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Camera,w.Sensor,w.Switch,w.Gateway],methods:{reboot:O(b({deviceId:f().int().nonnegative()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`,actions:[{id:`reboot.reboot`,label:N(`Reboot device`,`Riavvia il dispositivo`),phrase:N(`Reboot {device}`,`Riavvia {device}`),icon:`refresh-cw`}]})},vocabulary:{noun:N(`Reboot`,`Riavvio`),order:3240}},IX=b({owner:p(),kind:Yr,title:p(),nameField:p(),fields:u(p(),l()),secretPaths:S(p()),rows:f().int().nonnegative()}),LX=b({id:Tz,name:p(),rev:f().int(),updatedAt:f(),data:Ez}),RX={owner:p().min(1),kind:Yr},zX={name:`record-entries`,scope:`system`,mode:`singleton`,methods:{listEntryKinds:O(b({}),b({kinds:S(IX)}),{auth:`admin`}),listEntries:O(b({...RX}),b({entries:S(LX)}),{auth:`admin`}),putEntry:O(b({...RX,id:Tz.optional(),data:Ez,ifRev:f().int().min(1).optional()}),b({id:p(),rev:f().int()}),{kind:`mutation`,auth:`admin`}),deleteEntry:O(b({...RX,id:Tz}),b({deleted:v()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:A.INTERNAL}},_Oe=`camstack`,vOe=`recorder`,BX=b({profile:p(),startMs:f(),endMs:f()}),VX=x([`read`,`unreadable`]),HX=b({deviceId:f(),read:VX,ranges:S(BX),profilesWithFootage:S(p())}),UX=b({deviceId:f(),read:VX,days:S(f())}),WX=b({deviceId:f(),localMasterPath:p().nullable(),playbackUrl:p().nullable(),playbackEndpoints:S(p())}),GX=b({state:x([`ok`,`sleeping`,`unreachable`,`no-storage`,`index-empty`]),reason:p().optional(),coverageAsOf:f().optional()}),KX=b({source:p(),label:p(),addonId:p().optional(),availability:GX}),qX=b({transport:x([`archive`,`stream`,`realtime`]),coverage:x([`continuous`,`sparse`]),seek:x([`free`,`forward`,`segment`]),stepBack:v(),scrub:v(),rates:S(f().positive()).min(1).readonly(),exclusive:v()}),JX=i(`kind`,[b({kind:o(`hls`),manifest:WX}),b({kind:o(`clip`),source:p(),clipId:p(),startsAtMs:f()}),b({kind:o(`none`),reason:p()})]),YX={name:`recording`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:[w.Camera],methods:{listSources:O(b({deviceId:f()}),S(KX).readonly(),{kind:`query`,auth:`protected`}),getAvailability:O(b({deviceId:f(),provider:p().min(1),fromMs:f(),toMs:f(),profile:p().optional()}),HX,{kind:`query`,auth:`protected`}),getDaysWithRecordings:O(b({deviceId:f(),provider:p().min(1),fromMs:f(),toMs:f(),tzOffsetMinutes:f()}),UX,{kind:`query`,auth:`protected`}),getPlayback:O(b({deviceId:f(),provider:p().min(1),fromMs:f(),toMs:f(),profile:M.optional()}),JX,{kind:`query`,auth:`protected`}),getPlaybackOptions:O(b({deviceId:f(),provider:p().min(1)}),qX,{kind:`query`,auth:`protected`})},vocabulary:{noun:N(`Recording`,`Registrazione`),order:3250}},XX=b({deviceId:f(),enabled:v(),activeMode:lp,nodeId:p(),storageBytes:f()}),yOe=200,ZX=b({deviceId:f(),read:x([`read`,`unreadable`]),ranges:S(BX).readonly(),profilesWithFootage:S(p()).readonly()}),QX=b({deviceId:f(),read:x([`read`,`unreadable`]),days:S(f()).readonly()}),$X=b({deviceId:f(),usedBytes:f(),oldestMs:f().nullable().optional(),segments:f().optional(),residentBytes:f().optional(),residentOldestMs:f().nullable().optional()}),eZ=b({locationId:p().nullable(),locationIds:S(p()).optional(),root:p().optional(),usedBytes:f(),availableBytes:f().nullable(),totalBytes:f().nullable()}),tZ=b({nodeId:p(),totalUsedBytes:f(),devices:S($X),devicesRead:x([`archive`,`unavailable`]).optional(),complete:v().optional(),locations:S(eZ).optional()}),nZ=b({deviceId:f(),profile:p(),fromLocationId:p(),toLocationId:p(),bytes:f(),files:f().int()}),rZ=x([`unassigned`,`target-not-writable`,`below-threshold`,`no-headroom`]),iZ=b({deviceId:f(),profile:p(),fromLocationId:p(),toLocationId:p().nullable(),bytes:f(),reason:rZ}),aZ=b({moves:S(nZ),skipped:S(iZ),bytesToMove:f(),jobIds:S(p())}),oZ=b({throttleMbps:f().min(1).max(1e3).optional(),minMoveGb:f().min(0).optional()}),bOe=b({deviceId:f().int(),profile:p(),locationId:p()}),xOe=b({deviceId:f().int(),locationId:p()}),SOe=b({assignments:S(bOe),pins:S(xOe),defaultLocations:u(p(),p())}),COe=b({deviceId:f().int(),locationId:p().nullable()}),sZ=i(`kind`,[b({kind:o(`segment`),startMs:f(),durMs:f(),bytes:f()}),b({kind:o(`gap`),nearestEdgeMs:f().nullable(),prevEndMs:f().nullable().optional()})]),cZ=b({data:y(Uint8Array)}),lZ=b({data:y(Uint8Array),gopStartMs:f(),gopDurMs:f()}),uZ=i(`kind`,[b({kind:o(`ok`),data:y(Uint8Array),gopStartMs:f(),gopDurMs:f(),reachesRequestedEnd:v()}),b({kind:o(`spans-multiple-segments`),segmentEndMs:f()})]),dZ={name:`recording-archive`,scope:`system`,mode:`singleton`,exposesDeviceSettings:!0,status:{schema:XX,kind:`command-driven`},methods:{getAvailabilityBatch:O(b({deviceIds:S(f()).min(1).max(200),fromMs:f(),toMs:f()}),S(ZX).readonly(),{role:`viewer`,kind:`query`,auth:`protected`}),getDaysWithRecordingsBatch:O(b({deviceIds:S(f()).min(1).max(200),fromMs:f(),toMs:f(),tzOffsetMinutes:f()}),S(QX).readonly(),{role:`viewer`,kind:`query`,auth:`protected`}),getStorageUsage:O(b({}),tZ,{kind:`query`,auth:`admin`}),getDeviceConfig:O(b({deviceId:f()}),yp,{role:`viewer`,kind:`query`,auth:`protected`}),locateSegment:O(b({deviceId:f(),profile:p(),epochMs:f()}),sZ,{kind:`query`,auth:`admin`}),readSegmentBytes:O(b({deviceId:f(),profile:p(),startMs:f()}),cZ,{kind:`query`,auth:`admin`}),readGopBytes:O(b({deviceId:f(),profile:p(),startMs:f(),epochMs:f()}),lZ,{kind:`query`,auth:`admin`}),readWindowBytes:O(b({deviceId:f(),profile:p(),startMs:f(),fromMs:f(),toMs:f()}),uZ,{kind:`query`,auth:`admin`}),setDeviceConfig:O(b({deviceId:f(),config:yp}),yp,{kind:`mutation`,auth:`admin`}),rescanStorage:O(b({deviceId:f()}),XX,{kind:`mutation`,auth:`admin`}),pruneFootage:O(b({deviceId:f(),reason:$f.optional()}),b({floorMs:f().nullable(),deletedBuckets:f().int(),reclaimedBytes:f().int()}),{kind:`mutation`,auth:`admin`}),deleteFootprint:O(b({deviceId:f(),fromMs:f().optional(),toMs:f().optional()}),b({deletedBuckets:f().int(),reclaimedBytes:f().int()}),{kind:`mutation`,auth:`admin`}),listOpsLog:O(tp,S(ep).readonly(),{kind:`query`,auth:`admin`}),renderGif:O(b({deviceId:f(),aroundMs:f(),preRollSec:f().min(0).max(30).default(2),postRollSec:f().min(0).max(30).default(5),maxWidth:f().int().min(120).max(1280).default(480),fps:f().int().min(1).max(15).default(5)}),b({gifBase64:p(),fromMs:f(),toMs:f()}),{kind:`mutation`,auth:`admin`}),renderClip:O(b({deviceId:f(),aroundMs:f(),preRollSec:f().min(0).max(30).default(3),postRollSec:f().min(0).max(30).default(7),maxWidth:f().int().min(160).max(1920).default(640)}),b({clipBase64:p(),mime:p(),fromMs:f(),toMs:f(),bytes:f().int()}),{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:O(Dp,b({paused:o(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:O(Dp,b({resumed:o(!0)}),{kind:`mutation`,auth:`admin`}),refreshStorageLocationsForMigration:O(Dp,b({refreshed:o(!0)}),{kind:`mutation`,auth:`admin`}),startStorageMigrationMove:O(Op,b({jobId:p()}),{kind:`mutation`,auth:`admin`}),getStorageMigrationMoveStatus:O(b({jobId:p()}),wp.nullable(),{auth:`admin`}),cancelStorageMigrationMove:O(b({jobId:p()}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`}),relocateFootage:O(Ep,b({jobId:p()}),{kind:`mutation`,auth:`admin`}),listRelocateJobs:O(b({}),S(wp).readonly(),{kind:`query`,auth:`admin`}),getRelocateResidue:O(em,tm,{kind:`query`,auth:`admin`}),reconcileLedgerAgainstDisk:O(nm,om,{kind:`mutation`,auth:`admin`}),cancelRelocateJob:O(b({jobId:p()}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`}),planStorageRebalance:O(oZ,aZ,{kind:`query`,auth:`admin`}),startStorageRebalance:O(oZ,aZ,{kind:`mutation`,auth:`admin`}),getPlacement:O(b({}),SOe,{kind:`query`,auth:`admin`}),setDevicePlacement:O(COe,b({ok:o(!0)}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:A.STORAGE}},wOe=24,TOe=3,EOe=x([`queue-full`,`camera-backoff`,`sleeping`,`camera-refused`,`no-keyframe`,`decode-failed`,`no-catalog-row`,`unsupported`,`unknown-device`,`uid-missing`]),DOe=x([`deferred`,`final`]),OOe=`x-camstack-reason`,kOe=500;function AOe(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 jOe=`x-camstack-reason-code`,MOe=`x-camstack-disposition`,NOe=`x-camstack-clip-transport`,fZ=b({id:p(),source:p(),kind:x([`motion`,`object`,`audio`,`native`]),timeRange:b({startMs:f(),endMs:f()}),labels:S(p()).max(3).optional(),thumbnail:p().optional(),stillAtMs:f().optional(),eventIds:S(p()).optional(),eventCount:f().int().nonnegative().optional(),holes:S(b({startMs:f(),endMs:f()})).optional(),thumbnailMint:p().optional(),thumbnailUnavailable:b({reason:x([`sleeping`,`camera-refused`,`no-keyframe`,`unsupported`])}).optional(),catalogAsOf:f().optional(),nativeTypes:S(p()).optional(),behaviours:S(p()).optional(),streams:b({sub:b({id:p(),bytes:f().optional()}).optional(),main:b({id:p(),bytes:f().optional()}).optional()}).optional(),supportSub:v().optional(),playable:v().optional(),unplayableReason:p().optional(),inProgress:v().optional()}),pZ=b({playbackUrl:p(),format:x([`hls`,`mp4`]).optional(),served:M.optional(),playbackEndpoints:S(p()).optional(),token:p().optional()}),mZ=x([`authorised`]),POe=50*1024*1024,FOe=500*1024*1024,hZ=b({base64:p(),contentType:p(),name:p(),bytes:f().int().nonnegative(),served:M,durationMs:f().positive().optional()}),gZ=b({ticket:ii,contentType:p(),name:p(),served:M,durationMs:f().positive().optional()}),_Z=x([`opus`,`pcmu`,`none`]),vZ=x([`not-requested`,`unsupported-ask`]),yZ=b({url:p().min(1),expiresAtMs:f(),transport:o(`forward-only`),served:M,servedAudio:_Z,audioReason:vZ.optional()}),bZ=[.25,.5,1,1.5,2,4,8],xZ=[.25,.5,1,1.5,2,4],SZ=[.25,.5,1],CZ=b({transport:x([`stream`,`file`]),seek:x([`forward`,`free`]),stepBack:v(),scrub:v(),rates:S(f().positive()).min(1).readonly()}),wZ=b({state:x([`ok`,`sleeping`,`unreachable`,`no-storage`,`index-empty`]),reason:p().optional(),catalogAsOf:f().optional()}),TZ=b({source:p(),label:p(),addonId:p().optional(),availability:wZ}),EZ={name:`videoclips`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:[w.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/clips-browser`,tab:`recording`,topTab:!0,label:`Clips`,order:100}},methods:{listClips:O(b({deviceId:f(),since:f(),until:f(),limit:f().int().positive().optional(),provider:p().min(1)}),S(fZ).readonly(),{kind:`query`,auth:`protected`}),listSources:O(b({deviceId:f()}),S(TZ).readonly(),{kind:`query`,auth:`protected`}),getClipPlayback:O(b({deviceId:f(),clipId:p(),profile:M.optional()}),pZ,{kind:`query`,auth:`protected`}),readClipBytes:k(b({deviceId:f(),clipId:p().min(1),provider:p().min(1),profile:M.optional(),maxBytes:f().int().positive().optional(),wake:mZ.optional()}),hZ,{kind:`query`,auth:`protected`}),offerClipBytes:k(b({deviceId:f(),clipId:p().min(1),provider:p().min(1),profile:M.optional(),maxBytes:f().int().positive().optional(),wake:mZ.optional()}),gZ,{kind:`query`,auth:`protected`}),dialClipStream:k(b({deviceId:f(),clipId:p().min(1),provider:p().min(1),profile:M.optional(),audio:_Z.optional()}),yZ,{kind:`query`,auth:`protected`}),getPlaybackOptions:k(b({deviceId:f(),provider:p().min(1)}),CZ,{kind:`query`,auth:`protected`})},vocabulary:{noun:N(`Video clips`,`Clip video`),order:3330}},IOe={stream:{transport:`stream`,seek:`forward`,stepBack:!1,scrub:!1,rates:xZ},realtimeStream:{transport:`stream`,seek:`forward`,stepBack:!1,scrub:!1,rates:SZ},file:{transport:`file`,seek:`free`,stepBack:!0,scrub:!0,rates:bZ}},DZ=f().min(.25).max(32),OZ=b({fromSec:f().nonnegative(),toSec:f().nonnegative()}).refine(e=>e.toSec>e.fromSec,{message:`dense range must have toSec > fromSec`}),LOe=200,kZ=b({everyMs:f().int().positive(),ranges:S(OZ).min(1).max(200)}),AZ=b({everyMs:f().int().positive(),outputFps:f().int().min(1).max(60).optional(),dense:kZ.optional()}).superRefine((e,t)=>{e.dense!==void 0&&e.dense.everyMs>=e.everyMs&&t.addIssue({code:ce.custom,message:`dense.everyMs must be strictly smaller than the base everyMs`,path:[`dense`,`everyMs`]})}),jZ=b({speed:DZ.optional(),timelapse:AZ.optional(),includeAudio:v(),maxLifeMs:f().int().positive(),deleteAfterDownload:v(),title:p().max(200).optional(),notifyTargetIds:S(p().min(1)).max(20).optional()}).superRefine((e,t)=>{e.speed!==void 0&&e.timelapse!==void 0&&t.addIssue({code:ce.custom,message:`speed and timelapse are mutually exclusive`,path:[`timelapse`]})}),MZ=x([`queued`,`rendering`,`ready`,`failed`,`expired`,`deleted`]),NZ=b({kind:o(`footage`),deviceId:f(),profiles:S(p()).min(1),fromMs:f(),toMs:f()}),PZ=b({kind:o(`clip`),deviceId:f(),provider:p().min(1),source:p().min(1),sourceLabel:p().min(1),clipId:p().min(1),catalogWindow:b({sinceMs:f(),untilMs:f()}),profile:x([`high`,`mid`,`low`]),wake:mZ.optional()}),FZ=i(`kind`,[NZ,PZ]),IZ=b({id:p(),deviceId:f(),profile:p(),fromMs:f(),toMs:f(),subject:FZ.optional(),options:jZ,state:MZ,progressPct:f().nullable(),fileBytes:f().nullable(),expiresAt:f(),deleteAfterDownload:v(),downloadedAt:f().nullable(),createdAt:f(),createdBy:p(),error:p().nullable()}),LZ=x([`catalog-miss`,`catalog-unreachable`,`no-file-for-window`,`clip-in-progress`,`unsupported-option`,`sleeping`,`camera-refused`,`fetch-failed`,`too-large-to-transfer`,`wake-expired`]);function ROe(e,t){return t.length>0?`${e}: ${t}`:e}function zOe(e){if(e===null)return null;let t=e.split(`:`,1)[0]??``,n=LZ.safeParse(t.trim());return n.success?n.data:null}var RZ=b({url:p(),endpoints:S(p())}),BOe=50*1024*1024,zZ=b({base64:p(),contentType:p(),name:p(),bytes:f().int().nonnegative()});function BZ(e){return e.profiles!==void 0&&e.profiles.length>0?[...e.profiles]:typeof e.profile==`string`&&e.profile.length>0?[e.profile]:[]}var VOe=b({deviceId:f(),profile:p().optional(),profiles:S(p()).min(1).optional(),fromMs:f().optional(),toMs:f().optional(),subject:FZ.optional(),options:jZ}).superRefine((e,t)=>{if(e.subject?.kind===`clip`){e.subject.deviceId!==e.deviceId&&t.addIssue({code:ce.custom,message:`subject.deviceId (${e.subject.deviceId}) must equal deviceId (${e.deviceId}) — the top-level field is what per-device scope enforcement reads`,path:[`subject`,`deviceId`]}),(e.fromMs!==void 0||e.toMs!==void 0)&&t.addIssue({code:ce.custom,message:`a clip export asks for no time range: the camera chose the boundaries and they are read from the catalog row`,path:[`fromMs`]});return}e.subject?.kind===`footage`&&e.subject.deviceId!==e.deviceId&&t.addIssue({code:ce.custom,message:`subject.deviceId (${e.subject.deviceId}) must equal deviceId (${e.deviceId})`,path:[`subject`,`deviceId`]});let n=e.subject?.kind===`footage`?e.subject.fromMs:e.fromMs,r=e.subject?.kind===`footage`?e.subject.toMs:e.toMs;(typeof n!=`number`||typeof r!=`number`)&&t.addIssue({code:ce.custom,message:`a footage export needs fromMs and toMs`,path:[`fromMs`]}),(e.subject?.kind===`footage`?[...e.subject.profiles]:BZ(e)).length<1&&t.addIssue({code:ce.custom,message:`pass profiles[] (min 1) or legacy profile`,path:[`profiles`]})});function HOe(e){if(e.subject!==void 0)return e.subject;let t=BZ(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 UOe(e){return e.subject===void 0?{kind:`footage`,deviceId:e.deviceId,profiles:[e.profile],fromMs:e.fromMs,toMs:e.toMs}:e.subject}var VZ={name:`recording-export`,scope:`system`,mode:`singleton`,methods:{createExport:O(VOe,IZ,{role:`viewer`,kind:`mutation`,auth:`protected`}),listExports:O(b({deviceId:f().optional()}),S(IZ),{role:`viewer`,kind:`query`,auth:`protected`}),getExport:O(b({exportId:p()}),IZ,{role:`viewer`,kind:`query`,auth:`protected`}),cancelExport:O(b({exportId:p()}),IZ,{role:`viewer`,kind:`mutation`,auth:`protected`}),deleteExport:O(b({exportId:p()}),IZ,{role:`viewer`,kind:`mutation`,auth:`protected`}),getDownloadUrl:O(b({exportId:p()}),RZ,{role:`viewer`,kind:`query`,auth:`protected`}),readExportBytes:O(b({exportId:p()}),zZ,{kind:`query`,auth:`protected`})},vocabulary:{notOperatorFacing:`recording exports — requested from the timeline, not an automation step`}},HZ=x([`continuous`,`motion`,`person`,`vehicle`,`animal`,`lineCrossing`,`intrusion`,`loitering`,`alarmInput`]),UZ=b({trigger:HZ,day:f().int().min(0).max(6).meta(j(`none`)),startMinute:f().int().min(0).max(1439).meta(j(`none`)),endMinute:f().int().min(1).max(1440).meta(j(`none`))}),WZ=b({id:p(),label:p().optional(),status:x([`ok`,`unformatted`,`error`,`offline`,`unknown`]),capacityMb:f().nullable(),freeMb:f().nullable(),writable:v().optional()}),GZ=i(`kind`,[b({kind:o(`present`),volumes:S(WZ)}),b({kind:o(`absent`),reason:p()}),b({kind:o(`unknown`),reason:p()})]),KZ=b({id:p(),enabled:v(),isVideo:v(),codec:p().nullable(),resolution:p().nullable(),overwriteWhenFull:v().nullable()}),qZ=b({storage:GZ,tracks:S(KZ),primaryTrackId:p().nullable(),enabled:v().nullable(),overwriteWhenFull:v().nullable(),preRecordSec:f().nullable().meta(j(`duration`)),postRecordSec:f().nullable().meta(j(`duration`)),segmentMinutes:f().nullable().meta(j(`none`)),windows:S(UZ),unreadableWindows:f().meta(j(`count`)),recordingToNowhere:v(),lastFetchedAt:f()}),JZ=b({min:f(),max:f(),step:f()}),YZ=b({values:S(f()).min(1),sentinel:b({value:f(),meaning:x([`no-limit`,`disabled`])}).optional()}),XZ=b({readable:v(),writable:v(),reason:p().optional()}),ZZ=b({support:XZ,granularityMinutes:f(),triggers:S(HZ),supportsOverlappingTriggers:v()}),QZ=b({enabled:XZ,overwriteWhenFull:XZ,preRecordSec:XZ,preRecordSecRange:JZ.optional(),preRecordSecAllowed:YZ.optional(),postRecordSec:XZ,postRecordSecRange:JZ.optional(),postRecordSecAllowed:YZ.optional(),segmentMinutes:XZ,segmentMinutesRange:JZ.optional(),segmentMinutesAllowed:YZ.optional(),schedule:ZZ}),$Z=b({enabled:v().optional(),overwriteWhenFull:v().optional(),preRecordSec:f().optional(),postRecordSec:f().optional(),segmentMinutes:f().optional(),windows:S(UZ).optional()}),eQ={name:`recording-onboard`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Camera],deviceConfig:{ui:{kind:`derived-form`,builderId:`recording-onboard`,tab:`recording`}},methods:{getOptions:O(b({deviceId:f()}),QZ),setSettings:O(b({deviceId:f(),settings:$Z}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`recordingOnboard.on`,label:N(`On-camera recording on`,`Registrazione a bordo attiva`),phrase:N(`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:N(`On-camera recording off`,`Registrazione a bordo spenta`),phrase:N(`Turn off recording to the card of {device}`,`Disattiva la registrazione sulla scheda di {device}`),icon:`hard-drive`,args:{settings:{enabled:!1}}}]})},status:{schema:qZ,kind:`poll`},runtimeState:qZ,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:N(`On-camera recording`,`Registrazione a bordo`),order:3260,state:[{kind:`boolean`,field:`recordingToNowhere`,label:N(`Recording to nowhere`,`Registra nel vuoto`),whenTrue:N(`When {device} is recording with no card to write to`,`Quando {device} registra senza una scheda su cui scrivere`),whenFalse:N(`When {device} has a card to record to again`,`Quando {device} ha di nuovo una scheda su cui registrare`),icon:`hard-drive`}]}},tQ=b({active:v(),reason:p(),lastChangedAt:f()}),nQ=tQ.extend({lastFetchedAt:f()}),rQ={name:`recording-signal`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Camera],methods:{getStatus:O(b({deviceId:f()}),tQ)},status:{schema:tQ,kind:`push`,empty:{active:!1,reason:`unknown`,lastChangedAt:0}},runtimeState:nQ,durability:`session`,history:`none`,vocabulary:{noun:N(`Recording signal`,`Segnale di registrazione`),order:3270,state:[{kind:`boolean`,field:`active`,label:N(`Recording`,`In registrazione`),whenTrue:N(`When {device} starts recording`,`Quando {device} inizia a registrare`),whenFalse:N(`When {device} stops recording`,`Quando {device} smette di registrare`),icon:`circle-dot`}]}},iQ=b({kind:o(`cap`),deviceId:f().int().nonnegative(),cap:p().min(1),method:p().min(1),args:u(p(),l()).optional(),argUnits:u(p(),p().min(1)).optional()}),aQ=b({action:iQ}),oQ=b({key:p().refine(pE,{message:`a lowercase slug`}),name:p().min(1).max(60)}),WOe=200,GOe=100;function KOe(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=EE(a);e!==null&&s(e,`payload`)}for(let t of TE(a))uE(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 sQ=b({index:f().int().nonnegative(),id:p().nullable(),name:p().nullable(),reason:p()}),cQ=b({layoutTemplateId:p().min(1).nullable(),defaultTransmitterId:f().int().nonnegative().nullable().default(null),bindings:u(p(),aQ),customButtons:S(oQ).max(100),sources:S(CE).max(200).default([]),stepDelayMs:f().int().min(100).max(wE).default(500),refusedSources:S(sQ).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)uE(e)?t.addIssue({code:`custom`,message:`"${e}" is a layout widget, not a command: it cannot be bound`,path:[`bindings`,e]}):gE(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=hE(e);n!==null&&!r.has(n)&&t.addIssue({code:`custom`,message:`${e} is bound but has no entry in customButtons`,path:[`bindings`,e]})}KOe(e,t)}),qOe=a({sources:S(l())}),JOe=b({id:p(),name:p()}).partial();function YOe(e){let t=qOe.safeParse(e);if(!t.success)return lQ(cQ.safeParse(e));let n=[],r=[];t.data.sources.forEach((e,t)=>{let i=CE.safeParse(e),a=i.success&&i.data.kind===`ir`?EE(i.data):null;if(i.success&&a===null){n.push(e);return}let o=JOe.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=lQ(cQ.safeParse({...t.data,sources:n}));return!i.success||r.length===0?i:{success:!0,data:{...i.data,refusedSources:r}}}function lQ(e){return e.success?{success:!0,data:e.data}:{success:!1,issues:e.error.issues.length}}var XOe={layoutTemplateId:null,defaultTransmitterId:null,bindings:{},customButtons:[],sources:[],stepDelayMs:500},ZOe=b({power:b({state:x([`on`,`off`]),at:f()}).nullable(),muted:b({value:v(),at:f()}).nullable(),source:b({name:p(),at:f()}).nullable().default(null)}),QOe={power:null,muted:null,source:null},$Oe=24,eke=50,uQ=[`rect`,`rounded`,`round`,`pill`],dQ=x(uQ),fQ=[`neutral`,`accent`,`danger`,`red`,`green`,`yellow`,`blue`],pQ=x(fQ),mQ=[`none`,`panel`,`divider`,`dpad`,`rocker-v`,`rocker-h`,`keypad`],hQ=x(mQ),gQ=b({id:p().min(1).max(40),row:f().int().min(0).max(24),col:f().int().min(0).max(24),rowSpan:f().int().min(1).max(24),colSpan:f().int().min(1).max(24),icon:p().min(1).max(60).optional(),label:p().min(1).max(40).optional(),role:_E,shape:dQ.optional(),tone:pQ.optional(),showLegend:v().optional(),groupId:p().min(1).max(40).optional()}),_Q=b({id:p().min(1).max(40),componentId:p().min(1).max(80),frame:hQ,row:f().int().min(0).max(24),col:f().int().min(0).max(24),rowSpan:f().int().min(1).max(24),colSpan:f().int().min(1).max(24),title:p().min(1).max(40).optional(),size:x([`compact`,`normal`]).optional(),hideTitle:v().optional()});function vQ(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 yQ(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 tke(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&&vQ(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`]),yQ(n,e)||i(`button "${e.id}" lies outside its group "${n.id}"`,[`buttons`,t]);return}let a=n.find(t=>vQ(t,e));a!==void 0&&i(`button "${e.id}" lies inside group "${a.id}" but is not a member`,[`buttons`,t])})}var bQ=b({columns:f().int().min(1).max(24),rows:f().int().min(1).max(24),buttons:S(gQ).max(200),groups:S(_Q).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)}}),tke(e,t)}),nke=50,xQ=b({role:_E,label:p().optional(),custom:v()}),SQ=b({layoutTemplateId:p().nullable(),commands:S(xQ),sources:S(CE)}),CQ=[`no-remote`,`unbound-role`,`action-failed`,`unknown-source`,`unbound-step`,`undeclared-channel`,`press-timeout`,`no-transmitter`],wQ=x(CQ),TQ=i(`status`,[b({status:o(`sent`),sends:f().int().min(1)}),b({status:o(`skipped`),reason:o(`already-in-state`)}),b({status:o(`refused`),reason:wQ,detail:p().optional(),step:b({index:f().int().min(1),role:p()}).optional()})]),EQ=[`play`,`pause`,`stop`,`next`,`previous`,`setMute`,`selectSource`,`playMedia`,`turnOn`,`turnOff`,`volumeUp`,`volumeDown`,`channelUp`,`channelDown`],DQ=x(EQ),OQ=i(`status`,[...TQ.options,b({status:o(`not-routed`)})]),kQ=[`unknown-template`,`not-a-media-player`],AQ=i(`status`,[b({status:o(`saved`)}),b({status:o(`refused`),reason:x(kQ),detail:p()})]),jQ=b({deviceId:f().int().nonnegative()}),rke={version:1,targets:[{id:`remote`,cardinality:`config`,vocabulary:{cap:`remote`},deviceTypes:[w.MediaPlayer],apply:`add`,readMethod:`getConfig`,writeMethod:`setConfig`}]},MQ={name:`remote`,scope:`system`,mode:`singleton`,methods:{getConfig:O(jQ,cQ,{auth:`admin`}),setConfig:O(jQ.extend({config:cQ}),AQ,{kind:`mutation`,auth:`admin`}),listCommands:O(jQ,SQ,{auth:`protected`}),sendCommand:O(jQ.extend({role:_E,repeat:f().int().min(1).max(50).default(1)}),TQ,{kind:`mutation`,auth:`protected`}),getAssumedStatus:O(jQ,ME.nullable(),{auth:`protected`}),sendMediaCommand:O(jQ.extend({command:DQ,muted:v().optional(),source:p().optional(),mediaType:p().optional(),mediaId:p().optional(),repeat:f().int().min(1).max(50).default(1)}),OQ,{kind:`mutation`,auth:`protected`})},customize:rke,vocabulary:{notOperatorFacing:`the per-device remote setup — authored in the Customize remote editor, sent through the remote UI`}},NQ=[`power`,`navigation`,`volume`,`numbers`,`media`,`colour`,`apps`,`layout`],PQ=x(NQ),ike=40,ake=/^[a-z0-9][a-z0-9_.-]*:[a-z0-9][a-z0-9_-]*$/,FQ=b({idSuffix:p().regex(/^[a-z0-9][a-z0-9_-]{0,19}$/,{message:`a short lowercase slug`}),row:f().int().min(0).max(24),col:f().int().min(0).max(24),rowSpan:f().int().min(1).max(24),colSpan:f().int().min(1).max(24),role:_E,icon:p().min(1).max(60).optional(),label:p().min(1).max(40).optional(),shape:dQ.optional(),tone:pQ.optional(),showLegend:v().optional()}),IQ=b({id:p().max(80).regex(ake,{message:`<namespace>:<name>, lowercase`}),name:p().min(1).max(60),nameI18n:b({en:p().min(1).max(60),it:p().min(1).max(60)}).optional(),icon:p().min(1).max(60),category:PQ,size:b({rows:f().int().min(1).max(24),cols:f().int().min(1).max(24)}),group:b({frame:hQ,title:p().min(1).max(40).optional()}).nullable(),buttons:S(FQ).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&&vQ(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`]})}),LQ={name:`remote-layout-components`,scope:`system`,mode:`collection`,methods:{listComponents:O(b({}),S(IQ),{auth:`protected`})},vocabulary:{notOperatorFacing:`the palette of the remote template editor — read-only data, never actuated`}},oke=5,ske=2,RQ=3e4,zQ=18e4,BQ={startDwellMs:RQ,stopDwellMs:zQ,minSamples:2},VQ={[w.MediaPlayer]:{startDwellMs:1e4,stopDwellMs:1e4,minSamples:1}};function HQ(e){return e!==void 0&&VQ[e]!==void 0}function UQ(e){return e===void 0?BQ:VQ[e]??BQ}var cke={running:null,since:null,source:`native`,phase:null,lastFetchedAt:null},WQ=x([`native`,`assigned`]),GQ=b({running:v().nullable(),since:f().nullable().meta(j(`none`)),source:WQ.meta({label:`Source`}),phase:p().nullable(),lastFetchedAt:f().nullable()}),KQ=b({deviceId:f(),since:f().nullable(),phase:p().nullable()}),lke=Object.values(w),qQ=[w.Washer,w.Dryer,w.Dishwasher,w.Vacuum,w.LawnMower,w.MediaPlayer,w.WaterHeater,w.Humidifier,w.Fan,w.Climate,w.PetFeeder],uke={version:1,overridable:[{path:`running`,by:`running`}],targets:[{id:`running`,cardinality:`scalar`,vocabulary:{cap:`running-state`,stateField:`running`},deviceTypes:qQ,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:RQ,defaultStopDwellMs:zQ,deviceTypeDefaults:VQ,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}]},JQ={name:`running-state`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:lke,methods:{},events:{onStarted:{data:KQ,trigger:{category:C.RunningStarted,label:N(`Started running`,`Ha iniziato a funzionare`),phrase:N(`When {device} starts running`,`Quando {device} inizia a funzionare`),icon:`play`}},onFinished:{data:KQ,trigger:{category:C.RunningFinished,label:N(`Finished`,`Ha finito`),phrase:N(`When {device} finishes`,`Quando {device} finisce`),icon:`square`}}},status:{schema:GQ,kind:`push`},runtimeState:GQ,durability:`restored`,history:{fields:{running:{kind:`boolean`}}},volatileStateFields:[`lastFetchedAt`],customize:uke,vocabulary:{noun:N(`Running`,`In funzione`),order:2120,state:[{kind:`boolean`,field:`running`,label:N(`Running`,`In funzione`),whenTrue:N(`When {device} starts`,`Quando {device} inizia`),whenFalse:N(`When {device} finishes`,`Quando {device} finisce`),icon:`play`}],overrides:{byType:{[w.Washer]:{state:{running:{whenTrue:N(`When the washing machine starts`,`Quando la lavatrice inizia`),whenFalse:N(`When the washing machine has finished`,`Quando la lavatrice ha finito`)}},events:{onStarted:{phrase:N(`When the washing machine starts`,`Quando la lavatrice inizia`)},onFinished:{phrase:N(`When the washing machine has finished`,`Quando la lavatrice ha finito`)}}},[w.Dryer]:{state:{running:{whenTrue:N(`When the dryer starts`,`Quando l'asciugatrice inizia`),whenFalse:N(`When the dryer has finished`,`Quando l'asciugatrice ha finito`)}},events:{onStarted:{phrase:N(`When the dryer starts`,`Quando l'asciugatrice inizia`)},onFinished:{phrase:N(`When the dryer has finished`,`Quando l'asciugatrice ha finito`)}}},[w.Dishwasher]:{state:{running:{whenTrue:N(`When the dishwasher starts`,`Quando la lavastoviglie inizia`),whenFalse:N(`When the dishwasher has finished`,`Quando la lavastoviglie ha finito`)}},events:{onStarted:{phrase:N(`When the dishwasher starts`,`Quando la lavastoviglie inizia`)},onFinished:{phrase:N(`When the dishwasher has finished`,`Quando la lavastoviglie ha finito`)}}}}}}},YQ=p(),dke=[`day`,`ir`,`night`,`dawn`,`dusk`],XQ=x([`skip`,`judge-anyway`]),fke=`__diverged__`,ZQ=x([`matched`,`diverged`,`unknown`]),QQ=x([`no-reference-for-condition`,`view-shifted`,`no-vision-profile`,`encoder-model-changed`,`no-snapshot`]),$Q=b({embedding:S(f()),modelId:p(),condition:YQ,capturedAt:f(),thumbnailMediaId:f().int().optional(),anchorEmbedding:S(f()).optional()}),e$=b({id:p(),label:p(),references:S($Q),textPrompts:S(p()).optional(),referenceCount:f(),currentlyMatched:v()}),t$=i(`mode`,[b({mode:o(`similarity`),threshold:f().min(0).max(1),hysteresisCount:f().int().positive()}),b({mode:o(`llm`),prompt:p(),profileId:p().optional(),hysteresisCount:f().int().positive()})]),pke=60,mke=120,hke=60,n$=.85,r$=`skip`,i$=8e3,gke=448,_ke=!0,a$=b({enabled:v().default(!1),prompt:p().min(1).max(1e3),profileId:p().optional(),timeoutMs:f().int().min(1e3).max(2e4).default(i$),maxImagePx:f().int().min(64).max(2048).default(448),onTimeout:x([`flip`,`hold`]).default(`hold`)}),o$=b({id:p(),label:p(),roi:yB,enabled:v(),triggerMode:x([`periodic`,`on-motion`,`both`]),checkIntervalSec:f().optional(),check:t$,states:S(e$),currentStateId:p().nullable(),lastCheckedAt:f().nullable(),lastConfidence:f().nullable(),currentCondition:YQ.nullable(),availability:x([`ok`,`unavailable`]),unavailableReason:p().nullable(),baselineStateId:p().nullable(),emit:x([`latched`,`live`]).default(`latched`),verdict:ZQ,latched:v(),armedAt:f(),divergedAt:f().nullable(),restoredAt:f().nullable(),quietSeconds:f().int().min(0).max(3600).default(60),minObservationSpacingSec:f().int().min(0).max(3600).default(120),confirm:a$.optional(),anchorThreshold:f().min(0).max(1).default(n$),autoRestore:v().default(!1),onUncoveredCondition:XQ.default(r$),suspendedCondition:YQ.nullable().default(null),unavailable:QQ.nullable(),coveredConditions:S(YQ)}),s$=b({monitors:S(o$),lastFetchedAt:f()}),c$=b({deviceId:f(),status:s$.nullable()}),l$={name:`scene-monitor`,role:{feature:`scenes`},scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[w.Camera],methods:{listScenes:O(b({deviceId:f()}),s$),listScenesBatch:O(b({deviceIds:S(f()).min(1).max(200)}),S(c$).readonly()),createScene:O(b({deviceId:f(),label:p(),roi:yB,check:t$,triggerMode:x([`periodic`,`on-motion`,`both`]).optional(),checkIntervalSec:f().optional()}),o$,{kind:`mutation`,auth:`admin`}),updateScene:O(b({deviceId:f(),monitorId:p(),patch:b({label:p().optional(),roi:yB.optional(),enabled:v().optional(),triggerMode:x([`periodic`,`on-motion`,`both`]).optional(),checkIntervalSec:f().optional(),check:t$.optional(),emit:x([`latched`,`live`]).optional(),quietSeconds:f().int().min(0).max(3600).optional(),minObservationSpacingSec:f().int().min(0).max(3600).optional(),anchorThreshold:f().min(0).max(1).optional(),autoRestore:v().optional(),onUncoveredCondition:XQ.optional(),confirm:a$.nullable().optional()})}),_(),{kind:`mutation`,auth:`admin`}),deleteScene:O(b({deviceId:f(),monitorId:p()}),_(),{kind:`mutation`,auth:`admin`}),captureReference:O(b({deviceId:f(),monitorId:p(),stateId:p().optional(),label:p().optional(),condition:YQ.optional()}),b({stateId:p(),referenceCount:f()}),{kind:`mutation`,auth:`admin`}),deleteReference:O(b({deviceId:f(),monitorId:p(),stateId:p(),index:f()}),_(),{kind:`mutation`,auth:`admin`}),recheckNow:O(b({deviceId:f(),monitorId:p()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`sceneMonitor.recheck`,label:N(`Re-check a scene`,`Ricontrolla una scena`),phrase:N(`Re-check {monitorId} on {device} now`,`Ricontrolla subito {monitorId} su {device}`),icon:`scan-search`,openArgs:[{key:`monitorId`,label:N(`Scene`,`Scena`),offer:{kind:`dynamic`,from:`status`,field:`monitors`,valueKey:`id`,labelKey:`label`}}]}]}),resetScene:O(b({deviceId:f(),monitorId:p(),recapture:v().optional()}),_(),{kind:`mutation`,auth:`admin`})},status:{schema:s$,kind:`push`},runtimeState:s$,durability:`session`,history:`none`,vocabulary:{noun:N(`Scene watch`,`Controllo della scena`),order:3280,extraEvents:[{category:C.EnrichmentSceneStateChanged,label:N(`Scene changed`,`Scena cambiata`),phrase:N(`When a watched scene on {device} changes`,`Quando cambia una scena controllata su {device}`),icon:`scan-search`}]}},u$=b({schedulerId:p().min(1)}),d$={name:`schedulers`,scope:`system`,mode:`singleton`,methods:{list:O(b({}),S(Cv),{auth:`admin`}),get:O(u$,b({scheduler:Cv.nullable()}),{auth:`admin`}),create:O(b({scheduler:Sv}),b({scheduler:Cv}),{kind:`mutation`,auth:`admin`}),update:O(b({schedulerId:p().min(1),scheduler:Sv}),b({scheduler:Cv}),{kind:`mutation`,auth:`admin`}),delete:O(u$,_(),{kind:`mutation`,auth:`admin`}),setEnabled:O(b({schedulerId:p().min(1),profileId:p().min(1).optional(),enabled:v()}),b({scheduler:Cv}),{kind:`mutation`,auth:`admin`}),preview:O(b({schedulerId:p().min(1),date:p().regex(kv).optional()}),jv,{auth:`admin`}),conflicts:O(b({scheduler:Sv,schedulerId:p().min(1).optional()}),b({conflicts:S(Mv)}),{auth:`admin`}),getStatus:O(b({}),S(Pv),{auth:`admin`}),getTraces:O(u$,b({traces:S(Gv)}),{auth:`admin`})},vocabulary:{notOperatorFacing:`time schedulers — authored on their own page, not device actions`}},f$=b({isRunning:v(),lastRunAt:f(),lastRunSuccess:v().nullable(),lastError:p().nullable(),lastChangedAt:f()}),p$={name:`script-runner`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Script],methods:{run:O(b({deviceId:f().int().nonnegative(),variables:u(p(),l()).optional()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`script.run`,label:N(`Run script`,`Esegui lo script`),phrase:N(`Run {device}`,`Esegui {device}`),icon:`scroll-text`}]}),stop:O(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`script.stop`,label:N(`Stop script`,`Ferma lo script`),phrase:N(`Stop {device}`,`Ferma {device}`),icon:`square`}]})},status:{schema:f$,kind:`push`},runtimeState:f$,durability:`session`,history:`none`,vocabulary:{noun:N(`Script`,`Script`),order:2090,state:[{kind:`boolean`,field:`isRunning`,label:N(`Running`,`In esecuzione`),whenTrue:N(`When {device} starts running`,`Quando {device} parte`),whenFalse:N(`When {device} finishes`,`Quando {device} termina`),icon:`scroll-text`}]}},m$=x([`workspace`,`baked`,`data-root`]),h$=x([`idle`,`checking`,`staging`,`pending-restart`,`awaiting-confirmation`]),g$=x([`in-sync`,`behind-patch`,`behind-series`,`ahead`,`unknown`]),_$=b({state:g$,seedVersion:p().nullable(),contractVersion:p().nullable(),contractSource:x([`registry`,`running`]).nullable(),message:p()}),v$=x([`docker`,`electron`,`native`,`contradictory`,`unknown`]),y$=b({fact:x([`dockerenv-file`,`proc-1-cgroup`,`platform`,`electron-app-version-env`]),mode:x([`observed`,`declared`]),holds:v(),detail:p()}),b$=b({kind:v$,evidence:S(y$),currentVersion:p().nullable()}),x$=b({fromVersion:p(),toVersion:p().nullable(),atMs:f(),reason:p()}),S$=b({version:p(),update:b({available:v(),downloaded:v(),version:p().nullable(),checking:v(),error:p().nullable()}),stateAtMs:f(),stale:v()}),C$=x([`not-electron`,`no-app-state`,`app-state-stale`,`not-downloaded`]),w$=b({accepted:v(),reason:C$.nullable()}),T$=b({runnerId:p(),addonIds:S(p()),reason:p()}),E$=b({checkedAtMs:f(),expected:f(),running:f(),failed:S(p()),refused:S(T$),missing:S(p()),pending:S(p()).optional(),planKnown:v()}),D$=b({packageName:p(),runningVersion:p().nullable(),nodeRuntimeVersion:p().nullable(),activeVersion:p().nullable(),installedVersion:p().nullable().optional(),restartRequired:v().optional(),previousVersion:p().nullable(),seedVersion:p().nullable(),latestVersion:p().nullable(),updateAvailable:v(),bootMode:m$,updateState:h$,pendingVersion:p().nullable(),rolledBack:x$.nullable(),stateFileCorrupt:v(),lastCheckedAtMs:f().nullable(),imageContract:_$.optional(),wrapper:b$.optional(),runners:E$.optional(),desktopApp:S$.optional()}),O$=b({packageName:p(),runningVersion:p().nullable(),latestVersion:p().nullable(),updateAvailable:v(),checkedAtMs:f(),error:p().nullable(),pendingVersion:p().nullable().optional(),restartRequired:v().optional()}),k$=x([`staged`,`restart-scheduled`,`already-current`,`refused`,`failed`]),A$=b({addonId:p(),reason:p(),remedy:p()}),j$=b({accepted:v(),targetVersion:p().nullable(),restarting:v(),message:p(),outcome:k$.optional(),reason:p().nullable().optional(),error:p().nullable().optional(),blockers:S(A$).optional(),unmet:S(Il).optional(),requiredAddonUpdates:S(Ll).optional()}),M$=b({heapMb:f().int().nullable(),rssBudgetMb:f().int().nullable()}),vke=b({heapMb:f().int().min(512).max(65536).nullable(),rssBudgetMb:f().int().min(512).max(65536).nullable().optional()}),yke=M$.extend({restartRequired:v()}),N$={name:`server-management`,scope:`system`,mode:`singleton`,methods:{getServerPackageStatus:O(_(),D$,{auth:`admin`}),checkServerUpdate:O(_(),O$,{kind:`mutation`,auth:`admin`}),applyServerUpdate:O(b({version:p().optional(),acknowledgeRefusals:v().optional()}),j$,{kind:`mutation`,auth:`admin`,timeoutMs:16*6e4}),installDesktopUpdate:O(_(),w$,{kind:`mutation`,auth:`admin`}),rollbackServerUpdate:O(_(),j$,{kind:`mutation`,auth:`admin`}),restartServer:O(_(),j$,{kind:`mutation`,auth:`admin`}),getLaunchOverrides:O(_(),M$,{auth:`admin`}),setLaunchOverrides:O(vke,yke,{kind:`mutation`,auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:A.CLUSTER}},P$=b({detected:v(),lastChangedAt:f()}),F$={name:`smoke`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Sensor],methods:{},status:{schema:P$,kind:`push`},runtimeState:P$,durability:`restored`,history:{fields:{detected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:N(`Smoke detector`,`Rilevatore di fumo`),order:5190,state:[{kind:`boolean`,field:`detected`,label:N(`Detected`,`Rilevato`),whenTrue:N(`When {device} detects smoke`,`Quando {device} rileva fumo`),whenFalse:N(`When smoke clears on {device}`,`Quando il fumo su {device} si dirada`),icon:`alarm-smoke`}]}},bke=3,I$=5*1024*1024,L$=`<!--camstack-images-->`,R$=b({ticket:ii,mime:p().min(1),name:p().min(1),contentId:p().min(1),placement:x([`inline`,`attachment`]),deviceId:f().int().nonnegative().optional()}),z$=0;function B$(e){return z$+=1,`camstack_${e}_${z$.toString(36)}_${Date.now().toString(36)}`}function xke(e){return/^[\x20-\x7E]*$/.test(e)?e:`=?UTF-8?B?${Buffer.from(e,`utf8`).toString(`base64`)}?=`}function V$(e){return(Array.isArray(e)?e:[e]).join(`, `)}function Ske(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}function H$(e,t){let n=e.replace(/[\r\n"]/g,``).trim();return n.length>0?n:t}function Cke(e){let t=Buffer.from(e).toString(`base64`),n=[];for(let e=0;e<t.length;e+=76)n.push(t.slice(e,e+76));return n.join(`\r
|
|
1108
|
+
`}function pge(e){return`subjects`in e?e.subjects:e.classes.map(Ig)}var mge=new Set(Object.values(Ng.mapping));function hge(e){return Ng.mapping[e]??e}function gge(e,t){let n=e.toLowerCase(),r=t.toLowerCase();return n===r?!0:mge.has(n)&&hge(r)===n}function _ge(e){return e===`start`||e===`update`||e===`end`}var vge=class{trigger;fired=new Map;subjects;constructor(e){this.trigger=e,this.subjects=pge(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`||!_ge(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=Lg(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 yge(e){return`classes`in e}function bge(e){return e===`appeared`||e===`departed`}function xge(e,t){let{deviceId:n,entryId:r,phase:i}=t;if(typeof n!=`number`||typeof r!=`string`||!bge(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=yge(e)?e.classes?.map(Ig):e.subjects;if(c!==void 0){let e=Lg(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 Gy=b({deviceId:f(),eventType:p(),sourceId:p().optional(),data:u(p(),l()).nullable(),timestamp:f().meta(j(`none`)),seq:f().meta(j(`count`))}),Ky=b({eventTypes:S(p()),vocabulary:S(Rfe).default([]),lastEvent:Gy.nullable(),eventCountSinceStart:f().meta(j(`count`))}),qy={name:`event-emitter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.EventEmitter],methods:{},events:{onEvent:{data:Gy,trigger:{category:C.EventEmitted,label:N(`Fired an event`,`Ha generato un evento`),phrase:N(`When {device} fires an event`,`Quando {device} genera un evento`),icon:`zap`}}},status:{schema:Ky,kind:`push`},runtimeState:Ky,durability:`session`,history:`none`,vocabulary:{noun:N(`Event source`,`Sorgente di eventi`),order:5280}},Sge=3,Cge=32;function wge(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`}function Jy(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Yy(e){let t={},n=(e,r,i)=>{if(!(Object.keys(t).length>=Cge)){if(wge(e)){t[r]=e;return}if(!(!Jy(e)||i>=Sge))for(let[t,a]of Object.entries(e))n(a,`${r}.${t}`,i+1)}};if(Jy(e))for(let[t,r]of Object.entries(e))n(r,`data.${t}`,1);return t}function Tge(e,t){let n=e;for(let e of t.split(`.`)){if(!Jy(n))return;n=n[e]}return n}function Xy(e,t){return t===null?!0:e.timestamp===t.timestamp?e.seq>t.seq:e.timestamp>t.timestamp}var Zy=`recovered by reconcile`,Ege=class{leaf;#e=null;#t=!1;#n=null;constructor(e){this.leaf=e}onEvent(e){let t=Gy.safeParse(e);if(!t.success)return{kind:`ignore`,why:`malformed event`};let n=t.data;return n.deviceId===this.leaf.deviceId?Xy(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=Ky.safeParse(e);if(!t.success)return{kind:`ignore`,why:`the event-emitter status is unreadable`};this.#n=Wfe(t.data);let n=t.data.lastEvent,r=!this.#t;return this.#t=!0,n===null?{kind:`ignore`,why:`the device has not fired`}:Xy(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??Hfe([e.eventType]);return(og(t,e.eventType,e.sourceId)??og(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=Yy(e.data);for(let t of a??[]){let n=Tge(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} — ${Zy}`:l,vars:s,data:c}}},Qy=6e4;function $y(e){return(e/Qy).toFixed(1)}var Dge=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*Qy;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 ${$y(n)} min ago`};let r=`${$y(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 ${$y(n)} min ago, ${r}`}}},eb=x([`string`,`number`,`boolean`,`select`]),Oge=/^[A-Za-z_][A-Za-z0-9_]*$/,tb=c([p(),f(),v()]),nb=b({name:p().regex(Oge),label:p().min(1).max(120).optional(),type:eb,required:v().optional(),default:tb.optional(),options:S(p().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&&rb(e,e.default)!==null&&t.addIssue({code:`custom`,message:rb(e,e.default)??`invalid default`,path:[`default`]})});function rb(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 kge(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=rb(e,t);if(n!==null)return{ok:!1,error:n};i[e.name]=t}return{ok:!0,values:i}}var ib=x([`internal`,`addon`]),ab=`internal:`;function Age(e){return`${ab}${e}`}function ob(e){return e.startsWith(`internal:`)&&e.length>9}function sb(e){if(ob(e))return null;let t=e.indexOf(`:`);return t>0&&t<e.length-1?e.slice(0,t):null}var cb=b({isRunning:v(),lastRunAt:f().nullable(),lastError:p().nullable()}),jge={isRunning:!1,lastRunAt:null,lastError:null},lb=f().int().min(0).max(86400),ub=b({id:p().min(3),name:p().min(1).max(120),addonId:p().min(1),source:ib,readOnly:v(),steps:S(F_).min(1).max(50).optional(),variables:S(nb).max(20).optional(),minDelaySec:lb.optional(),tags:oh.optional(),status:cb}).superRefine((e,t)=>{if(e.source===`internal`){ob(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`]}),sb(e.id)===null&&t.addIssue({code:`custom`,message:`an addon action id is <addonId>:<localId>`,path:[`id`]})}),db=b({name:p().min(1).max(120),steps:S(F_).min(1).max(50),variables:S(nb).max(20).optional(),minDelaySec:lb.optional(),tags:oh.optional()}),fb=b({blockId:p().min(1).optional()}),pb=c([Iv,o(`started`),o(`timed-out`)]),mb=b({runId:p().min(1),outcome:pb,message:p().optional()}),Mge=x([`not-found`,`read-only`,`invalid-variables`,`invalid-steps`,`not-linked`,`template-scope`,`busy`]),Nge=class extends Error{code;constructor(e,t){super(`[${e}] ${t}`),this.name=`ActionError`,this.code=e}},hb=b({actionId:p(),runId:p(),isRunning:v(),outcome:Iv.optional(),lastRunAt:f().nullable(),lastError:p().nullable()});function Pge(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 gb(e){return[...e.kind===`command`&&e.target.kind===`devices`?[{actionId:e.actionId,ids:e.target.ids}]:[],...Pge(e).flatMap(gb)]}async function Fge(e,t){let n=e.flatMap(gb);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){Ea(e,void 0);for(let n of t)xne(e,n,i.get(n)??[])}}async function Ige(e,t,n=Date.now,r,i,a){let o=r?.mirror??new Ty(xy(e));await o.refresh(t);let s=My(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 Lge(e){try{return await e()}catch(e){return{result:`unknown`,reason:e instanceof Error?e.message:String(e)}}}async function Rge(e){let t=e.now(),n=t+e.timeoutMs;for(;;){let r=await Lge(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 zge(e,t){return`timed out after ${e} s: ${t}`}function _b(e){return Gi(e)}function vb(e){let t=_b(e);if(t===void 0)return[];let n=qc(t);return n===void 0?[t]:[t,...Qc(n).filter(e=>e!==t)]}var yb=b({path:p(),deviceId:f().int().optional(),field:p(),value:f(),assumedUnit:p(),message:p()});function Bge(e){let t=wg(e);return t instanceof se?t:void 0}function bb(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[...Tg(r.schema),...r.itemArray===void 0?[]:vpe(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=Bge(i)?.shape[r];return a===void 0?void 0:Tpe(a)}}}function xb(e){return Dg(e)??e}function Sb(e){return vb(e).length>1}function Cb(e){return{...e,message:`${e.field}: the bare number ${e.value} was taken as ${e.assumedUnit} — send { value, unit } to state the unit`}}function wb(e,t){Mg({value:1,unit:e,target:t})}function Vge(e,t,n){let r=t.fieldQuantity(e.cap,e.fieldPath),i=r===void 0?void 0:_b(r),a=jg(e.value)||e.unit!==void 0;if(i===void 0||r===void 0){if(a)throw new kg(`no-quantity`,`${e.cap}.${e.fieldPath} is not a quantity — it takes no unit`);return{leaf:e,warnings:[]}}if(jg(e.value)){let t=Mg({value:e.value.value,unit:e.value.unit,target:i});return{leaf:{...e,value:t,unit:xb(e.value.unit)},warnings:[]}}return typeof e.value==`number`?e.unit===void 0?Sb(r)?{leaf:e,warnings:[Cb({path:n,deviceId:e.deviceId,field:e.fieldPath,value:e.value,assumedUnit:i})]}:{leaf:e,warnings:[]}:(wb(e.unit,i),{leaf:e,warnings:[]}):{leaf:e,warnings:[]}}function Tb(e,t,n=`when`){switch(e.kind){case`device-is`:{let{leaf:r,warnings:i}=Vge(e,t,n);return{value:r,warnings:i}}case`not`:{let r=Tb(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)=>Tb(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 Hge(e,t,n){let r=e.target.kind===`devices`&&e.target.ids.length===1?e.target.ids[0]:void 0,{cap:i,method:a}=Ea(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 kg(`no-quantity`,`${i}.${a}(${n}) is not a quantity — it takes no unit`);wb(r,e.unit)}for(let[l,u]of Object.entries(e.args??{})){let e=t.paramMeta(i,a,l);e!==void 0&&(jg(u)?(o[l]=Mg({value:u.value,unit:u.unit,target:e.unit}),s[l]=xb(u.unit)):typeof u==`number`&&s[l]===void 0&&Sb(e.quantity)&&c.push(Cb({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 Eb(e,t,n=`steps`){let r=[],i=[];return e.forEach((e,a)=>{if(e.kind!==`command`){r.push(e);return}let o=Hge(e,t,`${n}.${a}`);r.push(o.value),i.push(...o.warnings)}),{value:r,warnings:i}}function Db(e,t){let n=Tb(e.when,t,`when`),r=Eb(e.actions,t,`actions`);return{value:{...e,when:n.value,actions:r.value},warnings:[...n.warnings,...r.warnings]}}function Ob(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||vb(n).length<2)return e;let r=_b(n);return r===void 0?e:{...e,unit:r}}case`not`:return{...e,child:Ob(e.child,t)};case`all`:case`any`:return{...e,children:e.children.map(e=>Ob(e,t))};default:return e}}function Uge(e,t){if(e.kind!==`command`||e.args===void 0)return e;let{cap:n,method:r}=Ea(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&&vb(e.quantity).length>1&&(i[a]=e.unit)}return Object.keys(i).length===0?e:{...e,argUnits:i}}function kb(e,t){let n={...e,when:Ob(e.when,t),actions:e.actions.map(e=>Uge(e,t))};try{return{ok:!0,recipe:Db(n,t).value}}catch(e){if(e instanceof kg)return{ok:!1,error:e.message};throw e}}var Wge=[`devices`,`time`,`cameras`,`events`,`logic`,`system`],Ab=[`trigger`,`any`],jb=[`trigger`,`guard`,`any`],Mb={detection:{kind:`detection`,category:`cameras`,role:`event`,allowedIn:Ab,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:Ab,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:Ab,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:Ab,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:Ab,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:Ab,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:Ab,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:Ab,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:jb,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:jb,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:jb,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:jb,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:jb,i18nKey:`automation.leafCatalog.expression`,keywords:[`formula`,`math`,`arithmetic`,`sum`,`compare`,`calculate`,`held`],needsDeviceValue:!1,seed:()=>({kind:`expression`,expr:``,bindings:{}})}},Nb=[`detection`,`stationary`,`device-becomes`,`device-fired`,`device-event`,`schedule`,`interval`,`manual`,`device-is`,`stationary-present`,`time-is`,`triggered-by`,`expression`];function Gge(e){return Mb[e]}function Kge(e){return Mb[e].seed()}function qge(e){return Nb.filter(t=>Mb[t].allowedIn.includes(e))}function Pb(e){return e instanceof Error?e.message:String(e)}function Jge(e){return e.startsWith(`[busy]`)?`already-running`:e.startsWith(`[not-found]`)?`not-found`:null}async function Yge(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=Pb(e),i=Jge(n);return i===null?(t.warn(`${r}: exported action failed`,{tags:a,meta:{message:n}}),{status:`failed`,message:n}):o(i,n)}}async function Xge(e,t,n){let{exporter:r,targetId:i}=n,a={targetId:i};try{let{targets:o,unreadable:s}=await Mu(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:nu.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=Pb(e);return t.warn(`${r}: exported notifier send failed`,{tags:a,meta:{message:n}}),{status:`failed`,message:n}}}function Zge(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 Fb=p().min(1),Ib=b({instanceId:Fb.optional()}),Lb=b({instanceId:Fb,name:p(),enabled:v(),kind:p().optional(),nameRule:p().optional()}),Rb=`export-instance-unknown`,zb=class extends Error{code=Rb;instanceId;constructor(e,t){super(`${Rb}: ${e} serves no instance "${t}"`),this.name=`ExportInstanceUnknownError`,this.instanceId=t}};function Bb(e){return`instanceId`in e?e.instanceId:void 0}function Qge(e,t,n){if(n!==void 0&&n!==t)throw new zb(e,n)}var $ge=x([`unlinked`,`linked`,`error`]),Vb=b({label:p(),value:p(),secret:v().optional()}),Hb=b({qr:p().optional(),fields:S(Vb).readonly().optional(),note:p().optional()}),Ub=b({linkState:$ge,exposedDeviceCount:f(),error:p().optional(),setup:Hb.optional()}),e_e=p(),Wb=b({deviceId:p(),exposedAs:p().optional(),exposedName:p().optional(),capabilities:S(p()).optional()}),Gb=b({instanceId:Fb,deviceId:p(),capabilities:S(p()).optional(),exposedName:p().nullable().optional()}),Kb=b({instanceId:Fb,deviceId:p(),name:p().nullable(),dryRun:v().optional()}),qb=`export-name-refused`,Jb=class extends Error{code=qb;instanceId;reason;constructor(e,t){super(`${qb}: ${t}`),this.name=`ExportNameRefusedError`,this.instanceId=e,this.reason=t}},Yb=b({instanceId:Fb,deviceId:p()}),Xb=x([`device`,`action`,`notifier`]),Zb=i(`kind`,[b({kind:o(`device`),deviceId:p()}),b({kind:o(`action`),actionId:p().min(1)}),b({kind:o(`notifier`),targetId:p().min(1)})]),Qb=b({entity:Zb,exposedAs:p().optional()}),$b=b({instanceId:Fb,entity:Zb}),ex=b({instanceId:Fb,entity:Zb}),tx={name:`device-export`,scope:`system`,mode:`collection`,providerKind:`device-export`,status:{schema:Ub,kind:`poll`},exposesDeviceSettings:!0,methods:{getStatus:O(Ib,Ub),listInstances:O(_(),S(Lb)),listSupportedDeviceKinds:O(Ib,S(e_e)),listExposedDevices:O(Ib,S(Wb)),exposeDevice:O(Gb,_(),{kind:`mutation`,auth:`admin`}),unexposeDevice:O(Yb,_(),{kind:`mutation`,auth:`admin`}),setExposedName:O(Kb,_(),{kind:`mutation`,auth:`admin`}),listSupportedEntityKinds:k(_(),S(Xb)),listExposedEntities:k(Ib,S(Qb)),exposeEntity:k($b,_(),{kind:`mutation`,auth:`admin`}),unexposeEntity:k(ex,_(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`exports to other ecosystems — configured on the export pages`}},nx=`exposedNames`,t_e=u(p(),p());function rx(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 ix(e){let t=t_e.safeParse(e[nx]);return t.success?t.data:{}}function n_e(e,t,n){let r=ix(e)[t];if(r===void 0)return null;let i=rx(r,n);return i.ok?i.name:null}function ax(e,t,n){let r=Object.fromEntries(Object.entries(ix(e)).filter(([e])=>e!==t));return{[nx]:n===null?r:{...r,[t]:n}}}async function r_e(e){let t=rx(e.raw,e.validate);if(!t.ok)throw new Jb(e.instanceId,t.reason);if(e.dryRun===!0)return{changed:!1,name:t.name};let n=await e.store.read(e.deviceId);return(ix(n)[e.instanceId]??null)===t.name?{changed:!1,name:t.name}:(await e.store.write(e.deviceId,ax(n,e.instanceId,t.name)),{changed:!0,name:t.name})}function i_e(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 a_e(e,t){let n=await e.listDeviceStoreIds();if(n.length===0)return[];let r=[];for(let[i,a]of await e.readDeviceStoreBatch(n))ix(a)[t]!==void 0&&(await e.writeDeviceStore(i,ax(a,t,null)),r.push(i));return r}function o_e(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 ox=[`automation`,`action`,`scheduler`,`composition`],s_e=x(ox),sx=b({id:f().int().nonnegative(),name:p().min(1),type:p().min(1),room:p().min(1).nullable(),addonId:p().min(1),stableId:p().min(1),caps:S(p().min(1)),zones:S(p().min(1)).optional()}),c_e=b({timeZone:p().min(1),location:b({latitude:f(),longitude:f()}).nullable(),rooms:S(p().min(1)),devices:S(sx).min(1),actions:S(b({id:p().min(1),name:p().min(1)})).default([])}),l_e=60,cx=b({childDeviceIds:S(f()).readonly(),hiddenChildIds:S(f()).readonly()}),lx={name:`accessories`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Camera,w.Switch,w.Light,w.Sensor,w.Climate,w.Cover,w.Lock,w.Fan,w.MediaPlayer,w.AlarmPanel,w.Generic],methods:{setChildHidden:O(b({deviceId:f().int().nonnegative(),childDeviceId:f().int().nonnegative(),hidden:v()}),_(),{kind:`mutation`,auth:`admin`})},events:{onAccessoriesChanged:{data:b({deviceId:f(),childDeviceIds:S(f()).readonly(),hiddenChildIds:S(f()).readonly()}),notOperatorFacing:`the device’s child list changed — administration, not a happening`},onChildVisibilityChanged:{data:b({deviceId:f(),childDeviceId:f(),hidden:v()}),notOperatorFacing:`an operator hid or showed a child — administration, not a happening`}},status:{schema:cx,kind:`command-driven`},vocabulary:{noun:N(`Accessories`,`Accessori`),order:3e3}},ux={name:`action-source`,scope:`system`,mode:`collection`,methods:{listActions:O(b({}),S(ub),{auth:`admin`}),runAction:O(b({actionId:p().min(1),variables:u(p(),tb).optional()}),_(),{kind:`mutation`,auth:`admin`}),stopAction:O(b({actionId:p().min(1)}),_(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:A.INTERNAL}},u_e=60*6e4,d_e=3e4,dx=363e4;function f_e(e){let t=0;for(let n of e)n.kind===`wait`&&(t+=n.seconds*1e3);return t}var fx=b({actionId:p().min(1)}),px=b({deviceId:f().int().nonnegative(),actionIds:S(p().min(1)).max(100)}),mx={name:`actions`,scope:`system`,mode:`singleton`,methods:{list:O(b({}),S(ub),{auth:`admin`}),get:O(b({actionId:p().min(1),deviceId:f().int().nonnegative().optional()}),b({action:ub.nullable()}),{role:`viewer`,auth:`protected`,kind:`query`,caller:`required`}),run:O(b({actionId:p().min(1),variables:u(p(),tb).optional(),wait:v().optional(),origin:fb.optional(),deviceId:f().int().nonnegative().optional()}),mb,{role:`viewer`,auth:`protected`,kind:`mutation`,caller:`required`,timeoutMs:dx}),stop:O(fx,_(),{kind:`mutation`,auth:`admin`}),getTraces:O(fx,b({traces:S(Gv)}),{auth:`admin`}),create:O(b({action:db}),b({action:ub,warnings:S(yb).optional()}),{kind:`mutation`,auth:`admin`}),update:O(b({actionId:p().min(1),action:db.partial()}),b({action:ub,warnings:S(yb).optional()}),{kind:`mutation`,auth:`admin`}),delete:O(fx,_(),{kind:`mutation`,auth:`admin`}),listForCamera:O(b({deviceId:f().int().nonnegative()}),S(ub),{role:`viewer`,auth:`protected`,kind:`query`}),getLinks:O(b({deviceId:f().int().nonnegative()}),px,{auth:`admin`}),setLinks:O(px,px,{kind:`mutation`,auth:`admin`})},events:{onRunChanged:{data:hb}},vocabulary:{notOperatorFacing:`declared actions — run from the Actions page and from the cameras that link them`}},p_e=b({id:p(),label:p(),icon:p(),path:p(),remoteName:p(),bundle:p(),section:p().optional(),sectionLabel:p().optional()}),hx=b({addonId:p(),page:p_e,bundleUrl:p()}),gx={name:`addon-pages`,scope:`system`,mode:`singleton`,methods:{listPages:O(_(),S(hx).readonly())},vocabulary:{notOperatorFacing:A.UI_PLUMBING}},m_e=b({method:x([`GET`,`POST`,`PUT`,`DELETE`,`PATCH`]),path:p(),access:x([`public`,`authenticated`,`admin`]).optional(),description:p().optional(),rateLimit:x([`auth`]).optional(),perInstance:v().optional()}),h_e=b({method:p(),path:p(),params:u(p(),p()),query:u(p(),p()),body:l(),headers:u(p(),p()),instanceId:p().optional(),user:b({id:p(),username:p(),isAdmin:v()}).optional(),scopedToken:l().optional()}),g_e=b({status:f().int(),headers:u(p(),p()),redirectUrl:p().nullable(),body:l().optional(),contentType:p().optional()}),_x={name:`addon-routes`,scope:`system`,mode:`collection`,internal:!0,methods:{getRoutes:O(_(),S(m_e)),invoke:O(h_e,g_e,{kind:`mutation`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:A.UI_PLUMBING}},vx=b({id:p(),label:p(),icon:p(),order:f().optional()}),yx=b({id:p(),title:p(),titleKey:p().optional(),description:p().optional(),descriptionKey:p().optional(),style:x([`card`,`accordion`]).optional(),defaultCollapsed:v().optional(),columns:c([o(1),o(2),o(3),o(4)]).optional(),tab:p().optional(),location:x([`settings`,`top-tab`,`hero`]).optional(),order:f().optional(),fields:S(he())}),bx=b({tabs:S(vx).optional(),sections:S(yx)}),xx=u(p(),l()),Sx=x(Gn),__e=b({cap:p(),scope:Sx,sectionIds:S(p())}),Cx=b({success:o(!0)}),wx={name:`addon-settings`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,methods:{getScopedSettings:O(b({addonId:p(),cap:p(),scope:Sx,nodeId:p().optional()}),bx.nullable()),listScopedSettings:O(b({addonId:p(),nodeId:p().optional()}),S(__e).nullable()),updateScopedSettings:O(b({addonId:p(),cap:p(),scope:Sx,nodeId:p().optional(),patch:xx}),Cx,{kind:`mutation`,auth:`admin`}),readScopedValues:O(b({addonId:p(),cap:p(),scope:Sx,nodeId:p().optional()}),u(p(),l()).nullable()),getDeclaredSettingsKeys:O(b({addonId:p(),nodeId:p().optional()}),b({keys:S(p())}).nullable(),{auth:`admin`}),unsetStoredSettingsKeys:O(b({addonId:p(),nodeId:p().optional(),keys:S(p())}),b({removed:S(p()),refused:S(b({key:p(),reason:p()})),secretsCleared:f()}),{kind:`mutation`,auth:`admin`}),getDeviceSettings:O(b({addonId:p(),deviceId:f(),nodeId:p().optional()}),bx.nullable()),updateDeviceSettings:O(b({addonId:p(),deviceId:f(),nodeId:p().optional(),patch:xx}),Cx,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:A.ADDON_ADMIN}},Tx=x([`device-tab`,`dashboard`,`integration-detail`]),Ex=x([`xs`,`sm`,`md`,`lg`,`xl`]),Dx=b({remoteName:p(),exposedModule:p(),componentKey:p().optional()}),Ox=b({tab:p(),subTab:p().optional(),label:p(),order:f().optional(),kind:o(`remote`),remote:Dx,stableId:p(),description:p().optional(),icon:p().optional(),bundle:p(),hosts:S(Tx).readonly(),requires:b({deviceContext:v().default(!1),integrationContext:v().default(!1)}),preAuth:v().optional().default(!1),defaultSize:Ex.default(`md`),allowedSizes:S(Ex).readonly().default([`sm`,`md`,`lg`]),defaultColumns:f().int().min(1).max(12).default(6),defaultRows:f().int().min(1).max(12).default(1)}),kx={name:`addon-widgets-source`,scope:`system`,mode:`collection`,internal:!0,methods:{listWidgets:O(_(),S(Ox).readonly(),{auth:`admin`})},vocabulary:{notOperatorFacing:A.UI_PLUMBING}},Ax=Ox.extend({addonId:p(),bundleUrl:p()}),jx={name:`addon-widgets`,scope:`system`,mode:`singleton`,methods:{listWidgets:O(_(),S(Ax).readonly())},vocabulary:{notOperatorFacing:A.UI_PLUMBING}},Mx=x([`install`,`update`,`uninstall`,`restart`]),Nx=x([`queued`,`fetching`,`staged`,`validating`,`applying`,`restarting`,`applied`,`done`,`failed`,`skipped`]),Px=x([`framework`,`addon`]),Fx=b({tsMs:f(),nodeId:p(),packageName:p(),phase:Nx,message:p()}),Ix=b({taskId:p(),nodeId:p(),packageName:p(),fromVersion:p().nullable(),toVersion:p(),target:Px,phase:Nx,stagedPath:p().nullable(),attempts:f(),steps:S(Fx),error:p().nullable(),startedAtMs:f().nullable(),finishedAtMs:f().nullable()}),Lx=x([`running`,`completed`,`failed`,`partially-failed`,`cancelled`]),Rx=x([`single`,`bulk`,`cluster`]),zx=b({jobId:p(),kind:Mx,createdAtMs:f(),createdBy:p(),scope:Rx,tasks:S(Ix),state:Lx,schemaVersion:o(1)}),Bx=x([`debug`,`info`,`warn`,`error`]),Vx=x([`off`,`latest`,`beta`]),Hx=x([`off`,`latest`,`beta`,`inherit`]),v_e=b({id:p(),name:p().optional(),version:p().optional(),description:p().optional(),icon:p().optional(),color:p().optional(),capabilities:S(l()).readonly().optional(),packageName:p(),packageVersion:p(),packageDisplayName:p().optional(),bundle:b({displayName:p(),description:p().optional(),icon:p().optional()}).optional(),protected:v().optional(),removable:v().optional(),integrationSection:x([`system`,`providers`]).optional()}),y_e=b({pid:f().optional(),mode:p(),state:p(),reason:p().optional()}),b_e=b({phase:x([`pending`,`healthy`,`failed`]),retryCount:f(),firstFailureAt:f().nullable(),lastAttemptAt:f().nullable(),lastError:b({message:p(),stack:p().optional()}).nullable(),nextRetryAt:f().nullable(),alertEmitted:v(),retrying:v(),inGracePeriod:v()}),Ux=b({manifest:v_e,declaration:l().optional(),source:p(),installSource:p().optional(),process:y_e.optional(),hasBackup:v().optional(),health:b_e.nullable().optional()}),Wx=b({name:p(),version:p(),dir:p(),installSource:p().optional()}),Gx=b({name:p(),currentVersion:p(),latestVersion:p(),category:x([`addon`,`core`]),requiresRestart:v(),isSystem:v(),blockedBy:S(Il).readonly().optional()}),Kx=b({version:p(),publishedAt:p(),deprecated:p().optional(),distTags:S(p()).readonly()}),qx=i(`status`,[b({status:o(`ok`),markdown:p()}),b({status:o(`missing`)}),b({status:o(`error`),message:p()})]),x_e=b({name:p(),version:p(),readme:qx,changelog:qx}),Jx=b({name:p(),version:p(),description:p(),keywords:S(p()).readonly(),publishedAt:p(),author:p(),installed:v(),installedVersion:p().optional(),capabilities:S(p()).readonly().nullable()}),Yx=b({channel:Vx,intervalSeconds:f(),updateCheckIntervalSeconds:f()}),Xx=Hx,S_e=l(),C_e=l(),w_e=l(),Zx=x([`uninstalled`,`not-installed`,`refused`,`failed`,`pending-reconnect`]),Qx=b({nodeId:p(),outcome:Zx,error:p().optional(),addonIds:S(p()).readonly(),runnersStopped:S(p()).readonly(),warnings:S(p()).readonly()}),$x=b({success:v(),packageName:p(),results:S(Qx).readonly()}),eS=b({packageName:p(),nodeId:p(),nodeName:p(),isHub:v(),isOnline:v(),version:p().nullable(),addonIds:S(p()).readonly(),source:x([`live`,`recorded`]),onHub:v()}),tS=b({installations:S(eS).readonly(),unreachable:S(b({nodeId:p(),error:p()})).readonly()}),T_e=x([`queued`,`updating`,`done`,`done-pending-restart`,`failed`]),E_e=b({name:p(),isSystem:v(),fromVersion:p(),toVersion:p(),status:T_e,error:p().optional(),startedAtMs:f().optional(),completedAtMs:f().optional()}),D_e=x([`regular`,`system`,`restarting`,`finalizing`]);b({id:p(),nodeId:p(),startedAtMs:f(),completedAtMs:f().optional(),total:f(),completed:f(),failed:f(),current:p().nullable(),phase:D_e,cancelled:v(),items:S(E_e).readonly()});var O_e=b({packageName:p(),currentVersion:p(),latestVersion:p().nullable(),hasUpdate:v(),description:p().optional(),buildId:p().nullable()}),nS=b({timestamp:p(),level:p(),message:p(),scope:p().optional()}),k_e=l(),rS=b({addonId:p().min(1),action:p().min(1),input:l()}),iS={name:`addons`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,methods:{list:O(b({nodeId:p().optional()}).optional(),S(Ux).readonly()),getLogs:O(b({addonId:p(),limit:f().min(1).max(500).default(100),level:Bx.optional()}),S(k_e)),listPackages:O(_(),S(Wx).readonly()),installPackage:O(b({packageName:p(),version:p().optional()}),C_e,{kind:`mutation`,auth:`admin`}),uninstallPackage:O(b({packageName:p().min(1),nodeId:p().optional(),everywhere:v().optional()}),$x,{kind:`mutation`,auth:`admin`}),listInstallations:O(b({packageName:p().optional()}),tS,{auth:`admin`}),reloadPackages:O(_(),w_e,{kind:`mutation`,auth:`admin`}),searchAvailable:O(b({query:p().optional(),capability:p().optional()}),S(Jx)),listUpdates:O(b({nodeId:p().optional()}),S(Gx).readonly(),{auth:`admin`}),updatePackage:O(b({name:p().min(1),version:p().optional(),nodeId:p().optional()}),l(),{kind:`mutation`,auth:`admin`}),rollbackPackage:O(b({name:p().min(1)}),b({rolledBackTo:p().nullable()}),{kind:`mutation`,auth:`admin`}),forceRefresh:O(b({nodeId:p().optional()}),l(),{kind:`mutation`,auth:`admin`}),restartServer:O(b({confirm:o(!0)}),l(),{kind:`mutation`,auth:`admin`}),getLastRestart:O(_(),b({kind:x([`framework-update`,`manual`,`system`,`framework-bulk-update`]),packageName:p().optional(),fromVersion:p().optional(),toVersion:p().optional(),requestedBy:p().optional(),requestedAt:f()}).nullable(),{auth:`admin`}),listFrameworkPackages:O(_(),S(O_e).readonly(),{auth:`admin`}),listCapabilityProviders:O(b({capName:p().min(1)}),S(b({addonId:p(),mode:x([`singleton`,`collection`]),isActive:v()})).readonly()),setCapabilityProviderEnabled:O(b({capName:p().min(1),addonId:p().min(1),enabled:v()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),getVersions:O(b({name:p()}),S(Kx).readonly()),getPackageDocs:O(b({name:p().min(1),version:p().min(1).optional()}),x_e,{auth:`admin`}),restartAddon:O(b({addonId:p()}),S_e,{kind:`mutation`,auth:`admin`}),retryLoad:O(b({packageName:p()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),getAutoUpdateSettings:O(_(),Yx,{auth:`admin`}),setAutoUpdateSettings:O(b({channel:Vx,intervalSeconds:f().min(300).max(86400).optional(),updateCheckIntervalSeconds:f().min(900).max(604800).optional()}),l(),{kind:`mutation`,auth:`admin`}),getAddonAutoUpdate:O(b({addonId:p()}),Xx,{auth:`admin`}),setAddonAutoUpdate:O(b({addonId:p(),channel:Hx}),l(),{kind:`mutation`,auth:`admin`}),applyAutoUpdateToAll:O(b({channel:Vx}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),custom:O(rS,l(),{role:`viewer`,kind:`mutation`}),startJob:O(b({kind:x([`install`,`update`,`uninstall`,`restart`]),targets:S(b({name:p().min(1),version:p().min(1)})).min(1),nodeIds:S(p()).optional()}),b({jobId:p()}),{kind:`mutation`,auth:`admin`}),getJob:O(b({jobId:p()}),zx.nullable(),{auth:`admin`}),listJobs:O(b({activeOnly:v().optional()}),S(zx),{auth:`admin`}),cancelJob:O(b({jobId:p()}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`}),onAddonLogs:O(b({addonId:p(),level:Bx.optional()}),nS,{kind:`subscription`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:A.ADDON_ADMIN}},aS=b({co2:f().min(0).optional().meta(j(`concentration-volume`)),voc:f().min(0).optional().meta(j(`concentration-ppb`)),pm25:f().min(0).optional().meta(j(`concentration-mass`)),pm10:f().min(0).optional().meta(j(`concentration-mass`)),aqi:f().optional().meta(j(`index`)),lastFetchedAt:f()}),oS={name:`air-quality-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Sensor],methods:{},status:{schema:aS,kind:`push`},runtimeState:aS,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:N(`Air quality`,`Qualità dell’aria`),order:5e3,state:[{kind:`numeric`,field:`co2`,quantity:N(`the CO₂`,`la CO₂`),label:N(`CO₂`,`CO₂`),unit:`ppm`,icon:`wind`},{kind:`numeric`,field:`voc`,quantity:N(`the VOC level`,`il livello di COV`),label:N(`VOC`,`COV`),unit:`ppb`,icon:`wind`},{kind:`numeric`,field:`pm25`,quantity:N(`the PM2.5`,`il PM2,5`),label:N(`PM2.5`,`PM2,5`),unit:`µg/m³`,icon:`cloud-fog`},{kind:`numeric`,field:`pm10`,quantity:N(`the PM10`,`il PM10`),label:N(`PM10`,`PM10`),unit:`µg/m³`,icon:`cloud-fog`},{kind:`numeric`,field:`aqi`,quantity:N(`the air quality index`,`l’indice di qualità dell’aria`),label:N(`AQI`,`IQA`),icon:`wind`}]}},sS=x([`disarmed`,`armed_home`,`armed_away`,`armed_night`,`armed_vacation`,`armed_custom_bypass`,`arming`,`disarming`,`pending`,`triggered`]),cS=x([`home`,`away`,`night`,`vacation`,`custom_bypass`]),lS=b({state:sS,targetMode:cS.nullable().optional(),availableModes:S(cS),requiresCode:v(),lastChangedAt:f()}),uS={name:`alarm-panel`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.AlarmPanel],methods:{trigger:O(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`alarm.trigger`,label:N(`Trigger alarm`,`Fai scattare l’allarme`),phrase:N(`Trigger the alarm on {device}`,`Fai scattare l’allarme su {device}`),icon:`siren`}]}),disarm:O(b({deviceId:f().int().nonnegative(),code:p().min(1).optional()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`alarm.disarm`,label:N(`Disarm`,`Disinserisci`),phrase:N(`Disarm {device}`,`Disinserisci {device}`),icon:`shield-off`,effect:{field:`state`,value:`disarmed`},openArgs:[{key:`code`,label:N(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]}),arm:O(b({deviceId:f().int().nonnegative(),mode:cS,code:p().min(1).optional()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`alarm.arm.home`,label:N(`Arm home`,`Inserisci in casa`),phrase:N(`Arm {device} for home`,`Inserisci {device} in modalità casa`),icon:`house`,effect:{field:`state`,value:`armed_home`},args:{mode:`home`},openArgs:[{key:`code`,label:N(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.away`,label:N(`Arm away`,`Inserisci fuori casa`),phrase:N(`Arm {device} for away`,`Inserisci {device} in modalità fuori casa`),icon:`shield-check`,effect:{field:`state`,value:`armed_away`},args:{mode:`away`},openArgs:[{key:`code`,label:N(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.night`,label:N(`Arm night`,`Inserisci notte`),phrase:N(`Arm {device} for the night`,`Inserisci {device} in modalità notte`),icon:`moon`,effect:{field:`state`,value:`armed_night`},args:{mode:`night`},openArgs:[{key:`code`,label:N(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.vacation`,label:N(`Arm vacation`,`Inserisci vacanza`),phrase:N(`Arm {device} for vacation`,`Inserisci {device} in modalità vacanza`),icon:`plane`,effect:{field:`state`,value:`armed_vacation`},args:{mode:`vacation`},openArgs:[{key:`code`,label:N(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.custom_bypass`,label:N(`Arm custom bypass`,`Inserisci con esclusioni`),phrase:N(`Arm {device} with its custom bypass`,`Inserisci {device} con le zone escluse`),icon:`shield-half`,effect:{field:`state`,value:`armed_custom_bypass`},args:{mode:`custom_bypass`},openArgs:[{key:`code`,label:N(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]})},status:{schema:lS,kind:`push`},runtimeState:lS,durability:`restored`,history:{fields:{state:{kind:`enum`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:N(`Alarm panel`,`Centrale d’allarme`),order:1120,state:[{kind:`enum`,field:`state`,label:N(`Alarm state`,`Stato dell’allarme`),values:[{value:`disarmed`,label:N(`Disarmed`,`Disinserito`),phrase:N(`When {device} is disarmed`,`Quando {device} viene disinserito`)},{value:`armed_home`,label:N(`Armed home`,`Inserito in casa`),phrase:N(`When {device} is armed for home`,`Quando {device} viene inserito in modalità casa`)},{value:`armed_away`,label:N(`Armed away`,`Inserito fuori casa`),phrase:N(`When {device} is armed for away`,`Quando {device} viene inserito in modalità fuori casa`)},{value:`armed_night`,label:N(`Armed night`,`Inserito notte`),phrase:N(`When {device} is armed for the night`,`Quando {device} viene inserito in modalità notte`)},{value:`armed_vacation`,label:N(`Armed vacation`,`Inserito vacanza`)},{value:`armed_custom_bypass`,label:N(`Armed with bypass`,`Inserito con esclusioni`)},{value:`arming`,label:N(`Arming`,`In inserimento`)},{value:`disarming`,label:N(`Disarming`,`In disinserimento`)},{value:`pending`,label:N(`Entry delay`,`Ritardo d’ingresso`)},{value:`triggered`,label:N(`Triggered`,`In allarme`),phrase:N(`When {device} goes off`,`Quando {device} scatta`)}],icon:`shield`}]}},dS=x([`info`,`success`,`warning`,`error`,`critical`]),A_e=b({addonId:p().min(1),action:p().min(1),input:u(p(),l()).optional()}),j_e=b({label:p(),href:p().optional(),invoke:A_e.optional(),navigation:x([`app`,`server`]).optional()}),fS=x([`active`,`in-progress`,`completed`,`failed`,`dismissed`]),pS=b({type:p(),id:p()}),mS=b({id:p(),category:p(),severity:dS,title:p(),message:p(),action:j_e.optional(),status:fS,progress:f().optional(),read:v(),createdAt:f(),updatedAt:f(),source:pS.optional(),metadata:u(p(),l()).optional()}),hS={name:`alerts`,scope:`system`,mode:`singleton`,methods:{emit:O(mS,_(),{kind:`mutation`}),update:O(b({alertId:p(),patch:mS.partial()}),_(),{kind:`mutation`}),list:O(b({unreadOnly:v().optional(),limit:f().optional()}).optional(),S(mS).readonly()),getUnreadCount:O(_(),f()),markRead:O(b({alertId:p()}),_(),{kind:`mutation`}),markAllRead:O(_(),_(),{kind:`mutation`}),dismiss:O(b({alertId:p()}),_(),{kind:`mutation`})},vocabulary:{notOperatorFacing:`the alert centre — read and acknowledged on its own page`}},gS=b({illuminance:f().min(0).nullable().meta(j(`illuminance`,{precision:0,label:`Illuminance`})),lastFetchedAt:f()}),_S={name:`ambient-light-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Sensor],methods:{},status:{schema:gS,kind:`push`},runtimeState:gS,durability:`restored`,history:{fields:{illuminance:{kind:`gauge`,unit:`lx`,deadbandPct:10,minIntervalMs:6e4}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:N(`Light level`,`Luminosità ambiente`),order:5010,state:[{kind:`numeric`,field:`illuminance`,quantity:N(`the light level`,`la luminosità`),label:N(`Illuminance`,`Illuminamento`),unit:`lx`,icon:`sun`}]}},vS={name:`audio-analysis`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[w.Camera],exposesDeviceSettings:!0,methods:{resolveDeviceSettings:O(b({deviceId:f()}),ge())},events:{onAudioLevel:Rr(b({deviceId:f(),rms:f(),dbfs:f()}),{notOperatorFacing:`a sound-level sample at stream rate; loud-noise rules belong to the detection pipeline`})},vocabulary:{noun:N(`Audio analysis`,`Analisi audio`),order:3010}},M_e=x([`jpeg`,`rgb`,`bgr`,`yuv420`,`gray`]),yS=b({data:ge(),format:M_e,width:f(),height:f(),timestamp:f()}),bS=b({x:f(),y:f(),w:f(),h:f()}),N_e=b({class:p(),originalClass:p(),score:f(),bbox:bS}),xS=b({data:y(Uint8Array),sampleRate:f(),channels:f(),timestamp:f(),deviceId:f().optional()}),SS=b({rms:f(),dbfs:f()}),CS=b({className:p(),originalClass:p().optional(),score:f()}),wS=[`superseded`,`error`,`timeout`,`disposed`],TS=i(`state`,[b({state:o(`classified`)}),b({state:o(`not-classified`),reason:x(wS)})]),ES=b({level:SS,classification:b({labels:S(CS).readonly(),inferenceMs:f()}).optional(),classifyOutcome:TS,timestamp:f()}),DS=b({minConfidence:f().min(0).max(1).default(.3),allowedClasses:S(p()).default([])}),OS=b({deviceId:f(),brokerId:p(),ingestNodeId:p(),settings:DS}),kS=b({attached:v(),replaced:v()}),AS=b({detached:v()}),jS=b({labels:S(CS).readonly(),rawLabels:S(CS).readonly().optional(),inferenceMs:f()}),P_e=[{value:`auto`,label:`Auto (platform default)`},{value:`apple-soundanalysis`,label:`Apple SoundAnalysis (macOS 12+)`},{value:`yamnet-onnx`,label:`YAMNet ONNX (cross-platform)`}],F_e={audioBackend:`auto`,probedBestAudioBackend:``},MS={name:`audio-analyzer`,scope:`system`,mode:`singleton`,methods:{analyseChunk:O(b({chunk:xS,settings:DS}),ES.nullable(),{kind:`mutation`}),classify:O(xS,jS,{timeoutMs:3e4}),attachDevice:O(OS,kS,{kind:`mutation`}),detachDevice:O(b({deviceId:f()}),AS,{kind:`mutation`}),isReady:O(_(),v()),dispose:O(_(),_(),{kind:`mutation`}),reprobeAudioEngine:O(_(),b({backend:p()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:A.PIPELINE}},NS=x([`f32le`,`s16le`]),PS=b({codec:p(),canDecode:v(),canEncode:v(),label:p().optional()}),FS=b({codec:p(),sourceSampleRate:f().int().positive(),sourceChannels:f().int().positive(),extraData:y(Uint8Array).optional(),targetSampleRate:f().int().positive(),targetChannels:f().int().positive(),targetFormat:NS.optional(),idleMs:f().int().positive().optional(),tag:p().optional()}),IS=b({codec:p(),sourceSampleRate:f().int().positive(),sourceChannels:f().int().positive(),sourceFormat:NS.optional(),targetSampleRate:f().int().positive(),targetChannels:f().int().positive(),bitrateKbps:f().int().positive().optional(),idleMs:f().int().positive().optional(),tag:p().optional()}),LS=b({data:y(Uint8Array),sampleRate:f().int().positive(),channels:f().int().positive(),format:NS,pts:f()}),RS=b({data:y(Uint8Array),codec:p(),pts:f(),frameComplete:v()}),I_e=b({sessionId:p(),kind:x([`decode`,`encode`]),codec:p(),sourceSampleRate:f(),sourceChannels:f(),targetSampleRate:f(),targetChannels:f(),format:NS,tag:p().optional(),createdAtMs:f(),lastActivityMs:f(),framesIn:f(),framesOut:f()}),zS={name:`audio-codec`,scope:`system`,mode:`singleton`,preferredProvider:`decoder-nodeav`,methods:{listSupportedCodecs:O(_(),S(PS).readonly()),canHandle:O(b({codec:p(),kind:x([`decode`,`encode`])}),v()),createDecodeSession:O(FS,b({sessionId:p(),nodeId:p()}),{kind:`mutation`}),createEncodeSession:O(IS,b({sessionId:p(),nodeId:p()}),{kind:`mutation`}),closeSession:O(b({sessionId:p(),nodeId:p().optional()}),_(),{kind:`mutation`}),pushEncodedFrame:O(b({sessionId:p(),nodeId:p().optional(),data:y(Uint8Array),pts:f().optional()}),_(),{kind:`mutation`}),pullPcm:O(b({sessionId:p(),nodeId:p().optional(),maxCount:f().int().positive().default(8)}),S(LS)),pushPcm:O(b({sessionId:p(),nodeId:p().optional(),data:y(Uint8Array),pts:f().optional()}),_(),{kind:`mutation`}),pullEncoded:O(b({sessionId:p(),nodeId:p().optional(),maxCount:f().int().positive().default(8)}),S(RS)),flushEncode:O(b({sessionId:p(),nodeId:p().optional()}),S(RS),{kind:`mutation`}),listActiveSessions:O(_(),S(I_e).readonly())},vocabulary:{notOperatorFacing:A.INTERNAL}},BS=b({className:p(),hits:f().int().nonnegative(),avgScore:f().min(0).max(1),peakScore:f().min(0).max(1)}),VS=b({ts:f().int(),windowSec:f().int().positive(),level:b({rms:f(),dbfs:f()}),peakDbfs:f(),avgDbfs:f(),current:b({className:p(),score:f().min(0).max(1),timestamp:f().int()}).nullable(),byClass:S(BS).readonly()}),HS=b({ts:f().int(),dbfs:f().nullable(),peakDbfs:f(),avgDbfs:f(),topClass:p().nullable(),topScore:f().min(0).max(1).nullable()}),US=b({points:S(HS).readonly(),effectiveSampleEveryMs:f().int().positive(),windowMsActual:f().int().nonnegative()}),WS={name:`audio-metrics`,scope:`device`,mode:`singleton`,deviceTypes:[w.Camera],methods:{getCurrentSnapshot:O(b({deviceId:f()}),VS.nullable()),getHistory:O(b({deviceId:f(),windowSec:f().int().positive().optional(),sampleEveryMs:f().int().positive().optional()}),US)},runtimeState:VS,durability:`session`,history:`none`,vocabulary:{noun:N(`Audio metrics`,`Metriche audio`),order:3020}},GS=b({userId:p(),username:p(),email:p().optional(),displayName:p().optional(),isAdmin:v().default(!1)}),KS={name:`auth-provider`,scope:`system`,mode:`collection`,internal:!0,methods:{validateCredentials:O(b({username:p(),password:p()}),GS.nullable(),{kind:`mutation`}),getLoginUrl:O(b({state:p()}),p()),handleCallback:O(u(p(),p()),GS,{kind:`mutation`}),validateToken:O(b({token:p()}),GS.nullable())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:A.IDENTITY}},qS=b({enabled:v(),isRunning:v(),lastTriggeredAt:f(),lastError:p().nullable(),lastChangedAt:f()}),JS={name:`automation-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Automation],methods:{enable:O(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`haAutomation.enable`,label:N(`Enable automation`,`Abilita l’automazione`),phrase:N(`Enable {device}`,`Abilita {device}`),icon:`toggle-right`}]}),disable:O(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`haAutomation.disable`,label:N(`Disable automation`,`Disabilita l’automazione`),phrase:N(`Disable {device}`,`Disabilita {device}`),icon:`toggle-left`}]}),trigger:O(b({deviceId:f().int().nonnegative(),skipCondition:v().optional()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`haAutomation.trigger`,label:N(`Trigger automation`,`Avvia l’automazione`),phrase:N(`Run {device} now`,`Esegui subito {device}`),icon:`workflow`}]})},status:{schema:qS,kind:`push`},runtimeState:qS,durability:`session`,history:`none`,vocabulary:{noun:N(`Automation`,`Automazione`),order:2100,state:[{kind:`boolean`,field:`enabled`,label:N(`Enabled`,`Abilitata`),whenTrue:N(`When {device} is enabled`,`Quando {device} viene abilitata`),whenFalse:N(`When {device} is disabled`,`Quando {device} viene disabilitata`),icon:`toggle-right`},{kind:`boolean`,field:`isRunning`,label:N(`Running`,`In esecuzione`),whenTrue:N(`When {device} starts running`,`Quando {device} parte`),whenFalse:N(`When {device} finishes`,`Quando {device} termina`),icon:`workflow`}]}},L_e=`.backup-snapshot`,R_e=`.backup-snapshot-partial`,YS=30*6e4,XS=b({databases:S(b({databaseId:bd,livePath:p()}))}),ZS=b({name:p(),rows:f().int().nonnegative()}),QS=b({livePath:p(),snapshotPath:p(),sizeBytes:f().int().nonnegative(),pageCount:f().int().nonnegative(),pageSize:f().int().positive(),tables:S(ZS),copyMs:f().nonnegative(),verifyMs:f().nonnegative(),takenAt:f()}),$S=QS.extend({databaseId:bd}),eC=b({databaseId:bd}),tC=QS.extend({livePath:p(),snapshotPath:p(),databaseId:bd.optional()}),nC={name:`database-snapshot`,scope:`system`,mode:`singleton`,internal:!0,methods:{listDatabases:O(b({}),XS,{auth:`admin`}),writeSnapshot:O(eC,$S,{kind:`mutation`,auth:`admin`,timeoutMs:YS})},vocabulary:{notOperatorFacing:A.INTERNAL}},rC=b({subId:p(),displayName:p(),description:p().optional(),kind:p(),triggerSupported:v(),restoreSupported:v()}).extend({id:p(),addonId:p(),enabled:v(),retentionCount:f(),label:p().optional(),lastSuccessAt:f().optional(),lastSuccessSizeBytes:f().optional(),cron:p().optional(),nextRunAt:f().optional(),lastAttemptAt:f().optional(),lastError:p().optional()}),iC=b({scheme:p(),keyId:p()}),aC=b({enabled:v(),active:b({keyId:p(),publicKey:p(),createdAt:f()}).nullable(),keys:S(b({keyId:p(),createdAt:f(),retiredAt:f().nullable()})).readonly()}),z_e=b({id:p(),filename:p(),createdAt:f(),sizeBytes:f(),label:p().optional(),locations:S(p()).readonly(),encryption:iC.optional(),databases:S(bd).readonly().optional()}),oC=b({id:p(),destinationId:p().optional(),label:p().optional(),createdAt:f(),sizeBytes:f(),locations:S(p()).optional(),encryption:iC.optional()}),sC=b({path:p(),kind:x([`file`,`dir`,`symlink`]),sizeBytes:f(),mtime:f()}),cC=b({archiveVersion:o(1),createdAt:f(),dataDir:p(),locations:S(p()),entries:S(sC),totalBytes:f(),totalFiles:f(),sqliteSnapshots:S(tC).optional(),omittedDatabases:S(bd).optional()}),lC=b({name:p(),sizeBytes:f(),fileCount:f(),present:v()}),uC=x([`queued`,`running`,`succeeded`,`failed`,`cancelled`]),dC=x([`queued`,`building`,`uploading`,`done`]),fC=b({id:p(),state:uC,phase:dC,destinationIds:S(p()).readonly(),label:p().optional(),requestedAt:f(),startedAt:f().optional(),finishedAt:f().optional(),stagedBytes:f(),archiveSizeBytes:f().optional(),uploadedBytes:f(),completedDestinationIds:S(p()).readonly(),failedDestinationIds:S(p()).readonly(),error:p().optional(),queuePosition:f().int().min(1).optional()}),pC=b({runId:p(),queued:v(),joined:v(),cancelled:v(),entries:S(oC).readonly()}),mC=b({id:p(),label:p(),cron:p(),enabled:v(),locationIds:S(p()).readonly(),retentionCount:f().int().min(1).max(1e3),dataSources:S(p()).readonly().optional(),databases:S(bd).readonly().optional(),lastAttemptAt:f().optional(),lastSuccessAt:f().optional(),lastError:p().optional(),nextRunAt:f().optional()}),hC={name:`backup`,scope:`system`,mode:`singleton`,methods:{listDestinations:O(_(),S(rC).readonly(),{auth:`admin`}),trigger:O(b({destinations:S(p()).optional(),locations:S(p()).optional(),label:p().optional(),retentionCount:f().int().min(1).max(1e3).optional(),databases:S(bd).optional()}).optional(),pC,{kind:`mutation`,auth:`admin`}),listRuns:O(_(),S(fC).readonly(),{auth:`admin`}),cancel:O(b({runId:p()}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`}),list:O(_(),S(oC).readonly(),{auth:`admin`}),listLocations:O(_(),S(lC).readonly(),{auth:`admin`}),getEntries:O(b({destinationId:p(),backupId:p()}),cC.nullable(),{auth:`admin`}),restore:O(b({destinationId:p(),backupId:p(),locations:S(p()).optional(),backupSecretKey:p().optional()}),_(),{kind:`mutation`,auth:`admin`}),getEncryption:O(_(),aC,{auth:`admin`}),setupEncryption:O(b({}),b({keyId:p(),secretKey:p(),publicKey:p(),createdAt:f(),replacedKeyId:p().nullable()}),{kind:`mutation`,auth:`admin`}),disableEncryption:O(b({}),b({disabledKeyId:p().nullable()}),{kind:`mutation`,auth:`admin`}),checkBackupKey:O(b({backupSecretKey:p()}),b({valid:v(),keyId:p().nullable(),known:v(),active:v(),error:p().optional()}),{kind:`mutation`,auth:`admin`}),delete:O(b({destinationId:p(),backupId:p()}),_(),{kind:`mutation`,auth:`admin`}),listArchives:O(b({destinationId:p()}),S(z_e).readonly(),{auth:`admin`}),upsertDestinationPolicy:O(b({locationId:p(),enabled:v(),retentionCount:f().int().min(1).max(1e3),label:p().optional()}),_(),{kind:`mutation`,auth:`admin`}),previewSchedule:O(b({cron:p(),count:f().int().min(1).max(20).optional()}),b({ok:v(),error:p().optional(),nextRuns:S(f()).readonly()})),listSchedules:O(_(),S(mC).readonly(),{auth:`admin`}),listAvailableDatabases:O(_(),b({answered:v(),databases:S(bd).readonly()}),{auth:`admin`}),upsertSchedule:O(b({id:p().optional(),label:p(),cron:p(),enabled:v(),locationIds:S(p()).readonly(),retentionCount:f().int().min(1).max(1e3),dataSources:S(p()).readonly().optional(),databases:S(bd).readonly().optional()}),mC,{kind:`mutation`,auth:`admin`}),deleteSchedule:O(b({id:p()}),_(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`system backups — run and restored from the Backups page`}},gC=b({level:f().min(0).max(100).nullable().meta(j(`percentage`,{label:`Charge`})),charging:x([`dc`,`solar`,`none`,`unknown`]).meta({label:`Charging source`}),sleeping:v().meta({label:`Sleeping`}),lastUpdated:f().meta(j(`none`)),voltage:f().nullable().optional().meta(j(`voltage`,{label:`Voltage`})),lastContactAt:f().optional(),lastFullRefreshAt:f().optional(),binary:v().optional().meta({label:`Binary indicator`})}),_C=[w.Camera,w.Sensor,w.Button,w.Switch,w.PetFeeder,w.Container,w.Climate,w.EventEmitter],B_e={version:1,targets:[{id:`level`,cardinality:`scalar`,vocabulary:{cap:`battery`,stateField:`level`},deviceTypes:_C,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}]},vC={name:`battery`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:_C,methods:{wakeForStream:O(b({deviceId:f(),timeoutMs:f().int().min(500).max(3e4).default(8e3)}),b({awoke:v(),durationMs:f()}),{kind:`mutation`,notOperatorFacing:`a stream consumer wakes a sleeping camera to watch it; an automation that wants footage asks for the footage`})},composedMethods:{wakeForStream:{kind:`answer`,value:{awoke:!1,durationMs:0}}},events:{onStatusChanged:{data:b({deviceId:f(),status:gC}),notOperatorFacing:`the level / sleeping / charging state triggers each read one field of this change`}},status:{schema:gC,kind:`push`,empty:{level:null,charging:`unknown`,sleeping:!1,lastUpdated:0}},runtimeState:gC,durability:`restored`,history:{fields:{level:{kind:`gauge`,unit:`%`},voltage:{kind:`gauge`,unit:`V`}}},customize:B_e,volatileStateFields:[`lastUpdated`],vocabulary:{noun:N(`Battery`,`Batteria`),order:5240,state:[{kind:`numeric`,field:`level`,quantity:N(`the battery level`,`il livello della batteria`),label:N(`Battery`,`Batteria`),unit:`%`,icon:`battery`},{kind:`boolean`,field:`sleeping`,label:N(`Asleep`,`In sospensione`),whenTrue:N(`When {device} goes to sleep`,`Quando {device} va in sospensione`),whenFalse:N(`When {device} wakes up`,`Quando {device} si risveglia`),icon:`moon`},{kind:`enum`,field:`charging`,label:N(`Charging`,`Ricarica`),values:[{value:`dc`,label:N(`Charging from mains`,`In carica da rete`),phrase:N(`When {device} starts charging`,`Quando {device} inizia a caricarsi`)},{value:`solar`,label:N(`Charging from solar`,`In carica dal pannello solare`),phrase:N(`When {device} charges from its solar panel`,`Quando {device} si carica dal pannello solare`)},{value:`none`,label:N(`Not charging`,`Non in carica`),phrase:N(`When {device} stops charging`,`Quando {device} smette di caricarsi`)},{value:`unknown`,label:N(`Unknown`,`Sconosciuto`)}],icon:`battery-charging`}],extraEvents:[{category:C.DeviceAwake,label:N(`Woke up`,`Risvegliato`),phrase:N(`When {device} wakes up`,`Quando {device} si risveglia`),icon:`sun`},{category:C.DeviceSleeping,label:N(`Went to sleep`,`In sospensione`),phrase:N(`When {device} goes to sleep`,`Quando {device} va in sospensione`),icon:`moon`}]}},yC=b({on:v().meta({label:`On`}),lastChangedAt:f()}),bC={name:`binary`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Sensor],methods:{},status:{schema:yC,kind:`push`},runtimeState:yC,durability:`restored`,history:{fields:{on:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:N(`Binary sensor`,`Sensore binario`),order:5020,state:[{kind:`boolean`,field:`on`,label:N(`On`,`Acceso`),whenTrue:N(`When {device} turns active`,`Quando {device} si attiva`),whenFalse:N(`When {device} turns inactive`,`Quando {device} si disattiva`),icon:`toggle-right`}],overrides:{byRole:{[E.MotionSensor]:{state:{on:{label:N(`Motion`,`Movimento`),whenTrue:N(`When {device} detects motion`,`Quando {device} rileva movimento`),whenFalse:N(`When motion clears on {device}`,`Quando il movimento su {device} cessa`),icon:`activity`}}},[E.ContactSensor]:{state:{on:{label:N(`Open`,`Aperto`),whenTrue:N(`When {device} opens`,`Quando {device} si apre`),whenFalse:N(`When {device} closes`,`Quando {device} si chiude`),icon:`door-open`}}},[E.LeakSensor]:{state:{on:{label:N(`Leak`,`Perdita`),whenTrue:N(`When {device} detects a leak`,`Quando {device} rileva una perdita`),whenFalse:N(`When {device} is dry again`,`Quando {device} torna asciutto`),icon:`droplets`}}},[E.SmokeSensor]:{state:{on:{label:N(`Smoke`,`Fumo`),whenTrue:N(`When {device} detects smoke`,`Quando {device} rileva fumo`),whenFalse:N(`When smoke clears on {device}`,`Quando il fumo su {device} si dirada`),icon:`alarm-smoke`}}},[E.COSensor]:{state:{on:{label:N(`Carbon monoxide`,`Monossido di carbonio`),whenTrue:N(`When {device} detects carbon monoxide`,`Quando {device} rileva monossido di carbonio`),whenFalse:N(`When the carbon monoxide clears on {device}`,`Quando il monossido su {device} rientra`),icon:`cloud-alert`}}},[E.GasSensor]:{state:{on:{label:N(`Gas`,`Gas`),whenTrue:N(`When {device} detects gas`,`Quando {device} rileva gas`),whenFalse:N(`When the gas clears on {device}`,`Quando il gas su {device} rientra`),icon:`flame`}}},[E.TamperSensor]:{state:{on:{label:N(`Tampered`,`Manomesso`),whenTrue:N(`When {device} is tampered with`,`Quando {device} viene manomesso`),whenFalse:N(`When the tamper alert on {device} clears`,`Quando l’allarme di manomissione di {device} rientra`),icon:`shield-alert`}}},[E.VibrationSensor]:{state:{on:{label:N(`Vibration`,`Vibrazione`),whenTrue:N(`When {device} vibrates`,`Quando {device} vibra`),whenFalse:N(`When {device} is still again`,`Quando {device} torna fermo`),icon:`vibrate`}}},[E.ConnectivitySensor]:{state:{on:{label:N(`Connected`,`Connesso`),whenTrue:N(`When {device} connects`,`Quando {device} si connette`),whenFalse:N(`When {device} disconnects`,`Quando {device} si disconnette`),icon:`wifi`}}},[E.SoundSensor]:{state:{on:{label:N(`Sound`,`Suono`),whenTrue:N(`When {device} hears a sound`,`Quando {device} sente un suono`),whenFalse:N(`When {device} is quiet again`,`Quando {device} torna silenzioso`),icon:`ear`}}},[E.BatterySensor]:{state:{on:{label:N(`Battery low`,`Batteria scarica`),whenTrue:N(`When the battery of {device} runs low`,`Quando la batteria di {device} si scarica`),whenFalse:N(`When the battery of {device} is fine again`,`Quando la batteria di {device} torna a posto`),icon:`battery-low`}}},[E.BinaryHelper]:{state:{on:{label:N(`On`,`Acceso`),whenTrue:N(`When {device} turns on`,`Quando {device} si accende`),whenFalse:N(`When {device} turns off`,`Quando {device} si spegne`),icon:`toggle-right`}}}}}}},xC=x([`unknown-source`,`not-admin`,`no-builder`,`no-ingress-url`,`unreachable`,`unknown-board`,`no-encryption-key`,`unreadable-config`]),V_e=b({sourceId:p(),name:p()}),H_e=b({configuration:p(),name:p(),address:p().nullable()}),SC=b({ok:o(!1),reason:xC,detail:p().optional()}),U_e=i(`ok`,[b({ok:o(!0),boards:S(H_e).readonly()}),SC]),W_e=i(`ok`,[b({ok:o(!0),key:p()}),SC]),CC={name:`board-key-source`,scope:`system`,mode:`collection`,methods:{listSources:O(_(),S(V_e).readonly(),{auth:`admin`}),listBoards:O(b({sourceId:p().min(1)}),U_e,{auth:`admin`}),getBoardKey:O(b({sourceId:p().min(1),configuration:p().min(1)}),W_e,{auth:`admin`})},vocabulary:{notOperatorFacing:A.INTERNAL}},wC=b({level:f().min(0).max(100).meta(j(`percentage`)),lastChangedAt:f()}),TC={name:`brightness`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Light],methods:{setBrightness:O(b({deviceId:f().int().nonnegative(),level:f().min(0).max(100)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`brightness.full`,label:N(`Full brightness`,`Luminosità massima`),phrase:N(`Set {device} to full brightness`,`Porta {device} alla massima luminosità`),icon:`sun`,effect:{field:`level`,value:100},args:{level:100}},{id:`brightness.half`,label:N(`Half brightness`,`Luminosità a metà`),phrase:N(`Dim {device} to half`,`Abbassa {device} a metà luminosità`),icon:`sun-dim`,effect:{field:`level`,value:50},args:{level:50}},{id:`brightness.off`,label:N(`Brightness off`,`Luminosità a zero`),phrase:N(`Dim {device} to zero`,`Abbassa {device} a zero`),icon:`lightbulb-off`,effect:{field:`level`,value:0},args:{level:0}},{id:`brightness.set`,label:N(`Set brightness`,`Imposta la luminosità`),phrase:N(`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:N(`Percentage`,`Percentuale`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]})},events:{onBrightnessChanged:{data:b({deviceId:f(),level:f().min(0).max(100),lastChangedAt:f()}),notOperatorFacing:"the `level` state trigger reads the same change"}},status:{schema:wC,kind:`command-driven`},runtimeState:wC,durability:`session`,history:{fields:{level:{kind:`gauge`,unit:`%`,minIntervalMs:0}}},vocabulary:{noun:N(`Brightness`,`Luminosità`),order:1010,state:[{kind:`numeric`,field:`level`,quantity:N(`the brightness`,`la luminosità`),label:N(`Brightness`,`Luminosità`),unit:`%`,icon:`sun`}]}},G_e=x([`connected`,`disconnected`,`connecting`,`auth-failed`,`unreachable`,`error`]),EC=b({brokerCount:f().int().nonnegative(),connectedCount:f().int().nonnegative()}),K_e=b({id:p()}),q_e=u(p(),l()),DC=b({brokerId:p(),target:u(p(),l()),payload:l().optional()}),OC=b({brokerId:p(),filter:u(p(),l())}),kC=b({subscriptionId:p()}),AC=b({brokerId:p(),subscriptionId:p()}),jC=b({brokerId:p(),key:p()}),MC={name:`broker`,scope:`system`,mode:`collection`,providerKind:`broker`,status:{schema:EC,kind:`poll`},methods:{getBrokerConfig:O(K_e,q_e.nullable(),{auth:`admin`}),publish:O(DC,l(),{kind:`mutation`,auth:`admin`}),subscribe:O(OC,kC,{kind:`mutation`,auth:`admin`}),unsubscribe:O(AC,_(),{kind:`mutation`,auth:`admin`}),getState:O(jC,l().nullable(),{auth:`admin`}),getStatus:O(_(),EC)},vocabulary:{notOperatorFacing:`message-broker connections — configured, not actuated`}},NC={name:`button`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Button],methods:{press:O(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`button.press`,label:N(`Press`,`Premi`),phrase:N(`Press {device}`,`Premi {device}`),icon:`circle-dot`}]})},vocabulary:{noun:N(`Button`,`Pulsante`),order:1130}},PC=x([`ha`,`addon`]),FC=b({id:p().min(1),name:p().min(1),source:PC,enabled:v(),instanceId:p().min(1).optional()}),IC=b({id:p().min(1),calendarId:p().min(1),title:p(),startMs:f().int(),endMs:f().int(),allDay:v().optional(),description:p().optional(),location:p().optional()}),LC=b({calendarIds:S(p().min(1)).max(64).optional(),startMs:f().int(),endMs:f().int()}),RC={name:`calendar-source`,scope:`system`,mode:`collection`,internal:!0,providerKind:`calendar`,methods:{listCalendars:O(_(),S(FC).readonly(),{auth:`admin`}),listEvents:O(LC,S(IC).readonly(),{auth:`admin`})},vocabulary:{notOperatorFacing:A.INTERNAL}};function zC(e){let t=new Date(e);return new Date(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()).getTime()}function BC(e){if(e.allDay!==!0)return{startMs:e.startMs,endMs:e.endMs};let t=zC(e.startMs),n=zC(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 J_e(e,t){let n=new Date(t),r=new Date(n.getFullYear(),n.getMonth(),n.getDate()+1).getTime(),i=BC(e);return i.startMs<r&&i.endMs>t}var VC=p().regex(/^#[0-9A-Fa-f]{6}$/,`expected #RRGGBB`),HC=FC.extend({id:p().min(1),providerAddonId:p().min(1).optional(),defaultColor:VC,color:VC,visible:v()}),UC=b({visible:v().optional(),color:VC.optional()}),WC=b({calendars:u(p(),UC)}),GC=b({calendarId:p().min(1),visible:v().optional(),color:VC.nullable().optional()}),KC={name:`calendars`,scope:`system`,mode:`singleton`,methods:{listCalendars:O(_(),S(HC).readonly(),{auth:`admin`}),listEvents:O(LC,S(IC).readonly(),{auth:`admin`}),getPreferences:O(b({}),WC,{auth:`admin`,caller:`required`}),setCalendarPreference:O(GC,WC,{auth:`admin`,kind:`mutation`,caller:`required`})},vocabulary:{notOperatorFacing:`calendars feed schedules and conditions, not device actions`}},qC=b({host:p(),port:f().int().positive().optional(),onvifPort:f().int().positive().optional(),rtspPort:f().int().positive().optional(),https:v().optional(),username:p().optional(),password:p().optional(),onvifProfile:p().optional()}),JC=b({host:p(),port:f().int().positive().nullable(),onvifPort:f().int().positive().nullable(),rtspPort:f().int().positive().nullable(),https:v().nullable(),hasUsername:v(),hasPassword:v(),onvifProfile:p().nullable()}),YC={name:`camera-credentials`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Camera],methods:{getCredentials:O(b({deviceId:f()}),qC.nullable(),{kind:`query`,auth:`admin`})},status:{schema:JC,kind:`command-driven`},vocabulary:{noun:N(`Camera credentials`,`Credenziali della telecamera`),order:3030}},XC=b({x:f().min(0).max(1),y:f().min(0).max(1),width:f().gt(0).max(1),height:f().gt(0).max(1)}),ZC=b({deviceId:f().int().positive(),source:XC,cell:XC}),Y_e=b({profile:x([`high`,`mid`,`low`]),offered:v(),missingSources:S(f().int().positive()),canvas:p(),published:v()}),QC=b({instanceId:p(),deviceId:f().int().nonnegative(),name:p(),fps:f().int(),cells:S(ZC),profiles:S(Y_e)}),$C=b({deviceId:f().int().nonnegative(),name:p().min(1).max(160).optional(),fps:f().int().min(1).max(60).optional(),publishedProfiles:S(x([`high`,`mid`,`low`])).max(3).optional(),cells:S(ZC).max(16)}),ew={name:`camera-grid-layout`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Camera],exposesDeviceSettings:!0,methods:{getLayout:O(b({deviceId:f().int().nonnegative()}),QC.nullable(),{auth:`admin`}),saveLayout:O($C,QC,{kind:`mutation`,auth:`admin`})},vocabulary:{noun:N(`Grid layout`,`Layout a griglia`),order:3040}},tw={name:`camera-pipeline-config`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[w.Camera],exposesDeviceSettings:!0,methods:{},vocabulary:{noun:N(`Detection settings`,`Impostazioni di rilevamento`),order:3050}},nw=x([`webrtc`,`hls`,`mjpeg`,`rtsp`]),rw=x([`mp4`,`gif`]),iw=b({kind:rw,handle:p(),nodeId:p(),mime:p(),bytes:f().int(),width:f().int(),height:f().int()}),aw=b({fromTs:f(),toTs:f(),packets:f().int()}),ow=b({media:S(iw).readonly(),coverage:aw,profile:M,video:x([`copy`,`encode`])}),sw=b({brokerId:p(),url:p(),mutedUrl:p(),enabled:v(),codec:p().optional(),resolution:b({width:f().int().positive(),height:f().int().positive()}).optional()}),cw=b({sessionId:p(),remoteAddr:p(),userAgent:p().nullish(),playing:v(),muted:v(),connectedAt:f(),lastRtpAt:f(),bytesSent:f()}),lw=b({tag:p(),subscribedAt:f(),chunksDelivered:f()}),uw=x([`alexa`,`homekit`,`webrtc-browser`,`webrtc-mobile`,`webrtc-whep`,`rtsp-listen`,`derived-broker`,`recording`,`pipeline`,`snapshot`,`warmup`,`unknown`]),dw=b({kind:uw,label:p().optional(),media:x([`audio`,`video`,`both`]).optional(),targetCodec:p().optional(),transport:x([`passthrough`,`repacketize`,`transcode`]).optional(),remoteAddr:p().optional(),userAgent:p().optional(),userId:p().optional(),sessionId:p().optional(),extra:u(p(),p()).optional()}).readonly(),fw=b({id:p(),channel:x([`annexb`,`rtp`]),attribution:dw,subscribedAt:f(),packetsDelivered:f()}),pw=b({rtsp:S(cw).readonly(),audio:S(lw).readonly(),encoded:S(fw).readonly(),pipeClients:f(),encodedSubscribers:f()}),mw=b({deviceId:f().int().nonnegative(),viewers:f().int().positive()}),X_e=x([`reconnecting`,`sleeping`,`offline`,`disabled`,`waking`]),Z_e=x([`h264`,`h265`,`copy`]),Q_e=x([`aac`,`opus`,`pcmu`,`copy`,`none`]),hw=b({deviceId:f().int().nonnegative(),video:Z_e,audio:Q_e.optional(),profile:M.optional(),targetResolution:b({width:f().int().positive(),height:f().int().positive()}).optional(),outputArgs:S(p()).optional(),audioEgress:v().optional(),hostname:p().optional(),tag:p().optional()}),gw=b({url:p(),sentryUrl:p().nullable().optional(),videoCodec:x([`H264`,`H265`]),audioCodec:p(),resolution:b({width:f().int().positive(),height:f().int().positive()}),transcoded:v(),encoder:p(),pipelineKey:p()}),_w=Fu.omit({inputArgs:!0,outputArgs:!0}),vw=x([`tight`,`relaxed`]),yw=b({deviceId:f().int().nonnegative(),source:i(`kind`,[b({kind:o(`profile`),profile:M}),b({kind:o(`cam-stream`),camStreamId:p().min(1)})]),encode:_w,rateControl:vw.optional(),bitstreamFilter:x([`dump_extra`,`h264_mp4toannexb`,`hevc_mp4toannexb`]).optional(),publishLocally:v().optional(),pixelFormat:x([`yuv420p`,`nv12`]).optional(),decodeHwAccel:x([`auto`,`none`,`videotoolbox`,`vaapi`,`qsv`,`cuda`]).optional(),hostname:p().optional(),tag:p().optional()}),bw=b({url:p(),pipelineKey:p(),videoCodec:x([`H264`,`H265`]),resolution:b({width:f().int().positive(),height:f().int().positive()}),transcoded:v(),encoder:p(),decodeHwAccel:p().nullable(),camStreamId:p().nullable()}),xw={name:`stream-broker`,scope:`system`,mode:`singleton`,exposesDeviceSettings:!0,methods:{reportStreamSignal:O(b({deviceId:f().int().nonnegative(),code:p().min(1),at:f().optional()}),b({accepted:v(),reason:x([`woke`,`hold-extended`,`not-enabled`,`no-consumer`,`unknown-code`])}),{kind:`mutation`}),publishCameraStream:O(b({deviceId:f().int().nonnegative(),camStreamId:p().min(1),kind:Yi,url:p().optional(),codec:p().optional(),resolution:Xi.optional(),fps:f().positive().optional(),label:p().optional(),deviceFeatures:S(p()).optional(),autoEligible:v().optional(),profileHint:M.optional(),metadata:u(p(),l()).optional(),sourceCamStreamId:p().min(1).optional(),encodeProfile:Fu.optional()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),retractCameraStream:O(b({deviceId:f().int().nonnegative(),camStreamId:p().min(1)}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),assignProfile:O(b({deviceId:f().int().nonnegative(),profile:M,camStreamId:p().min(1)}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),unassignProfile:O(b({deviceId:f().int().nonnegative(),profile:M}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),forgetDeviceHardware:O(b({deviceId:f().int().nonnegative()}),b({derivedStreamsDeleted:S(p()).readonly(),assignmentsPurged:v(),probeSnapshotsDropped:f().int().nonnegative(),rtspTokenRowsDeleted:f().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),renderPreBufferClip:O(b({deviceId:f(),profile:M.optional(),aroundMs:f(),preRollSec:f().min(0).max(20).default(3),postRollSec:f().min(0).max(20).default(5),format:x([`gif`,`mp4`]).default(`gif`),maxWidth:f().int().min(120).max(1920).default(480),fps:f().int().min(1).max(15).default(5),speed:f().min(1).max(8).default(2)}),b({base64:p(),mime:p(),bytes:f().int(),profile:M,durationMs:f()}),{kind:`mutation`,auth:`admin`}),produceEventMedia:O(b({deviceId:f(),profile:M.optional(),aroundMs:f(),preSeconds:f().min(0).max(20).default(4),postSeconds:f().min(0).max(20).default(6),kinds:S(rw).min(1).default([`mp4`]),gifMaxWidth:f().int().min(120).max(1280).default(640),gifFps:f().int().min(1).max(15).default(12),gifSpeed:f().min(1).max(8).default(4),speed:f().min(1).max(8).default(4)}),ow,{kind:`mutation`,auth:`admin`}),fetchEventMedia:O(b({handle:p()}),b({base64:p(),mime:p(),bytes:f().int()}).nullable(),{kind:`mutation`,auth:`admin`}),listAllCameraStreams:O(_(),S(Zi).readonly()),listAllProfileSlots:O(_(),S($i).readonly()),getBrokerStats:O(b({brokerId:p()}),sa),probeStream:O(b({brokerId:p()}),b({probed:v(),summary:p()}),{kind:`mutation`,auth:`admin`}),listClients:O(b({brokerId:p()}),pw),getLiveViewerCounts:O(_(),S(mw).readonly(),{role:`viewer`}),killClient:O(b({brokerId:p(),channel:x([`rtsp`,`audio`]),handle:p()}),b({killed:v()}),{kind:`mutation`,auth:`admin`}),restartProfile:O(b({deviceId:f().int().nonnegative(),profile:M}),b({success:v()}),{kind:`mutation`,auth:`admin`}),getStreamUrl:O(b({streamId:p(),format:nw}),b({url:p()})),getStreamWithCodec:O(hw,gw,{kind:`mutation`,auth:`admin`}),releaseStreamWithCodec:O(b({pipelineKey:p()}),b({released:v(),refcount:f().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),acquireEgressTranscode:O(yw,bw,{kind:`mutation`,auth:`admin`}),releaseEgressTranscode:O(b({pipelineKey:p()}),b({released:v(),refcount:f().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),subscribeAudioChunks:O(ia,aa,{kind:`mutation`}),pullAudioChunks:O(b({subscriptionId:p(),maxCount:f().int().positive().default(8)}),S(ra).readonly()),unsubscribeAudioChunks:O(b({subscriptionId:p()}),b({released:v()}),{kind:`mutation`}),setPreBufferDuration:O(b({brokerId:p(),seconds:f().min(0).max(30)}),_(),{kind:`mutation`,auth:`admin`}),getPreBufferInfo:O(b({brokerId:p()}),b({configuredSec:f(),bufferedMs:f(),packetCount:f()})),getRtspPort:O(_(),f()),getAllRtspEntries:O(b({hostname:p().optional()}),S(sw).readonly()),getRtspEntry:O(b({brokerId:p(),hostname:p().optional()}),sw.nullable()),regenerateRtspToken:O(b({brokerId:p()}),p().nullable(),{kind:`mutation`,auth:`admin`}),setRtspEnabled:O(b({brokerId:p(),enabled:v()}),_(),{kind:`mutation`,auth:`admin`}),isRtspEnabled:O(b({brokerId:p()}),v()),getDeviceAudioMute:O(b({deviceId:f().int()}),b({muted:v(),appliedBrokers:f().int().nonnegative()})),setDeviceAudioMute:O(b({deviceId:f().int(),muted:v()}),b({muted:v(),appliedBrokers:f().int().nonnegative()}),{kind:`mutation`,auth:`admin`})},events:{onCamStreamDemand:Rr(b({deviceId:f().int().nonnegative(),camStreamId:p(),profile:M})),onCamStreamIdle:Rr(b({deviceId:f().int().nonnegative(),camStreamId:p()})),onRequestStreamSourceRefresh:Rr(b({deviceId:f().int().nonnegative(),camStreamId:p(),brokerId:p()}))},vocabulary:{notOperatorFacing:A.PIPELINE}},Sw=x([`h264`,`h265`,`hevc`,`av1`,`mjpeg`,`vp8`,`vp9`]),Cw=b({acceptCodecs:S(Sw).readonly().optional(),minHeight:f().int().positive().optional(),maxHeight:f().int().positive().optional(),minWidth:f().int().positive().optional(),excludeDerived:v().optional(),requireSiblingCodec:S(Sw).readonly().optional(),allowTranscode:v().optional(),requireProfileBound:v().optional()}).readonly(),ww=b({preferredProviders:S(p()).readonly().optional(),resolutionPreference:x([`highest`,`lowest`]).optional(),targetHeight:f().int().positive().optional()}).readonly(),Tw=b({camStreamId:p(),codec:p().optional(),resolution:Xi.optional(),transcodes:v(),reason:p(),profile:M.optional(),brokerId:p().optional(),url:p().optional(),fps:f().positive().optional(),fpsSource:x([`published`,`measured`]).optional()}),Ew={name:`camera-streams`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[w.Camera],methods:{getCameraStreams:O(b({deviceId:f().int().nonnegative()}),S(Zi).readonly()),getBrokerStreams:O(b({deviceId:f().int().nonnegative()}),S($i).readonly()),getRtspEntries:O(b({deviceId:f().int().nonnegative(),hostname:p().optional()}),S(sw).readonly()),getProfileRtspEntries:O(b({deviceId:f().int().nonnegative(),hostname:p().optional()}),S(ca).readonly()),pickStream:O(b({deviceId:f().int().nonnegative(),requirements:Cw,preferences:ww.optional()}),Tw.nullable())},events:{onCamStreamsChanged:Rr(b({deviceId:f().int().nonnegative(),camStreams:S(Zi).readonly()}),{notOperatorFacing:`the stream catalog was rebuilt — plumbing, not a happening`}),onProfileSlotsChanged:Rr(b({deviceId:f().int().nonnegative(),profileSlots:S($i).readonly()}),{notOperatorFacing:`stream profiles were reassigned — plumbing, not a happening`})},runtimeState:b({online:v(),slotStatuses:b({high:Qi.optional(),mid:Qi.optional(),low:Qi.optional()}),slotErrors:b({high:p().optional(),mid:p().optional(),low:p().optional()}),lastChangedAt:f()}),durability:`session`,history:`none`,vocabulary:{noun:N(`Camera streams`,`Flussi della telecamera`),order:3060}},Dw=b({detected:v(),lastChangedAt:f()}),Ow={name:`carbon-monoxide`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Sensor],methods:{},status:{schema:Dw,kind:`push`},runtimeState:Dw,durability:`restored`,history:{fields:{detected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:N(`Carbon monoxide`,`Monossido di carbonio`),order:5030,state:[{kind:`boolean`,field:`detected`,label:N(`Detected`,`Rilevato`),whenTrue:N(`When {device} detects carbon monoxide`,`Quando {device} rileva monossido di carbonio`),whenFalse:N(`When the carbon monoxide clears on {device}`,`Quando il monossido su {device} rientra`),icon:`cloud-alert`}]}},kw=x([`off`,`heat`,`cool`,`auto`,`heat_cool`,`fan_only`,`dry`]),Aw=x([`heating`,`cooling`,`drying`,`fan`,`idle`,`off`]),jw=b({mode:kw,action:Aw.nullable().optional(),availableModes:S(kw),fanMode:p(),availableFanModes:S(p()),preset:p(),availablePresets:S(p()),target:f().nullable().meta(j(`temperature`)),targetHigh:f().nullable().meta(j(`temperature`)),targetLow:f().nullable().meta(j(`temperature`)),targetHumidity:f().min(0).max(100).nullable().meta(j(`humidity`)),currentTemp:f().nullable().meta(j(`temperature`)),currentHumidity:f().min(0).max(100).nullable().meta(j(`humidity`)),swingVertical:v().nullable(),swingHorizontal:v().nullable(),minTemp:f().nullable().optional().meta(j(`temperature`)),maxTemp:f().nullable().optional().meta(j(`temperature`)),tempStep:f().positive().nullable().optional().meta(j(`temperature`)),lastActiveMode:kw.exclude([`off`]).optional(),lastFetchedAt:f()}),$_e=[w.Climate];function Mw(e,t){return{id:e,cardinality:`scalar`,vocabulary:{cap:`climate-control`,stateField:t},deviceTypes:$_e,apply:`replace`,path:t,sources:[{kind:`numeric`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}}var Nw=[Mw(`room-temperature`,`currentTemp`),Mw(`room-humidity`,`currentHumidity`)],eve={version:1,overridable:Nw.map(e=>({path:e.path,by:e.id})),targets:Nw},Pw={name:`climate-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Climate],power:{kind:`mode`,field:`mode`,offValue:`off`,set:`setMode`,lastField:`lastActiveMode`},methods:{setMode:O(b({deviceId:f().int().nonnegative(),mode:kw}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.off`,label:N(`Climate off`,`Clima spento`),phrase:N(`Turn off {device}`,`Spegni {device}`),icon:`power-off`,effect:{field:`mode`,value:`off`},args:{mode:`off`}},{id:`climate.heat`,label:N(`Heat`,`Riscalda`),phrase:N(`Set {device} to heat`,`Metti {device} in riscaldamento`),icon:`flame`,effect:{field:`mode`,value:`heat`},args:{mode:`heat`}},{id:`climate.cool`,label:N(`Cool`,`Raffresca`),phrase:N(`Set {device} to cool`,`Metti {device} in raffrescamento`),icon:`snowflake`,effect:{field:`mode`,value:`cool`},args:{mode:`cool`}},{id:`climate.auto`,label:N(`Climate auto`,`Clima automatico`),phrase:N(`Set {device} to automatic`,`Metti {device} in automatico`),icon:`thermometer`,effect:{field:`mode`,value:`auto`},args:{mode:`auto`}},{id:`climate.mode`,label:N(`Set mode`,`Imposta la modalità`),phrase:N(`Set {device} to {mode}`,`Imposta {device} su {mode}`),icon:`thermometer`,effect:{field:`mode`,fromArg:`mode`},openArgs:[{key:`mode`,label:N(`Mode`,`Modalità`),offer:{kind:`enum`,values:[{value:`off`,label:N(`Off`,`Spento`)},{value:`heat`,label:N(`Heat`,`Riscaldamento`)},{value:`cool`,label:N(`Cool`,`Raffrescamento`)},{value:`auto`,label:N(`Automatic`,`Automatico`)},{value:`heat_cool`,label:N(`Heat and cool`,`Caldo e freddo`)},{value:`fan_only`,label:N(`Fan only`,`Solo ventilazione`)},{value:`dry`,label:N(`Dry`,`Deumidificazione`)}]}}]}]}),setTarget:O(b({deviceId:f().int().nonnegative(),target:f()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.target`,label:N(`Set temperature`,`Imposta la temperatura`),phrase:N(`Set {device} to {target}`,`Imposta {device} a {target}`),icon:`thermometer`,effect:{field:`target`,fromArg:`target`},openArgs:[{key:`target`,label:N(`Temperature`,`Temperatura`),offer:{kind:`number`,step:.5,unit:`°C`}}]}]}),setTargetRange:k(b({deviceId:f().int().nonnegative(),targetLow:f(),targetHigh:f()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.targetRange`,label:N(`Set temperature range`,`Imposta l’intervallo di temperatura`),phrase:N(`Keep {device} between {targetLow} and {targetHigh}`,`Mantieni {device} tra {targetLow} e {targetHigh}`),icon:`thermometer`,openArgs:[{key:`targetLow`,label:N(`Lowest`,`Minima`),offer:{kind:`number`,step:.5,unit:`°C`}},{key:`targetHigh`,label:N(`Highest`,`Massima`),offer:{kind:`number`,step:.5,unit:`°C`}}]}]}),setTargetHumidity:k(b({deviceId:f().int().nonnegative(),targetHumidity:f().min(0).max(100)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.targetHumidity`,label:N(`Set humidity`,`Imposta l’umidità`),phrase:N(`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:N(`Humidity`,`Umidità`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setFanMode:k(b({deviceId:f().int().nonnegative(),fanMode:p().min(1)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.fanMode`,label:N(`Set fan mode`,`Imposta la ventilazione`),phrase:N(`Set the fan of {device} to {fanMode}`,`Imposta la ventilazione di {device} su {fanMode}`),icon:`fan`,openArgs:[{key:`fanMode`,label:N(`Fan mode`,`Ventilazione`),offer:{kind:`dynamic`,from:`status`,field:`availableFanModes`}}]}]}),setPreset:k(b({deviceId:f().int().nonnegative(),preset:p().min(1)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.preset`,label:N(`Set preset`,`Imposta il preset`),phrase:N(`Set {device} to preset {preset}`,`Imposta {device} sul preset {preset}`),icon:`list`,openArgs:[{key:`preset`,label:N(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`status`,field:`availablePresets`}}]}]}),setSwingVertical:k(b({deviceId:f().int().nonnegative(),on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.swingVerticalOn`,label:N(`Vertical swing on`,`Oscillazione verticale attiva`),phrase:N(`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:N(`Vertical swing off`,`Oscillazione verticale spenta`),phrase:N(`Stop the vertical swing of {device}`,`Ferma l’oscillazione verticale di {device}`),icon:`move-vertical`,effect:{field:`swingVertical`,value:!1},args:{on:!1}}]}),setSwingHorizontal:k(b({deviceId:f().int().nonnegative(),on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.swingHorizontalOn`,label:N(`Horizontal swing on`,`Oscillazione orizzontale attiva`),phrase:N(`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:N(`Horizontal swing off`,`Oscillazione orizzontale spenta`),phrase:N(`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:jw,kind:`push`},runtimeState:jw,customize:eve,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:N(`Climate`,`Clima`),order:1070,state:[{kind:`enum`,field:`mode`,label:N(`Mode`,`Modalità`),values:[{value:`off`,label:N(`Off`,`Spento`),phrase:N(`When {device} turns off`,`Quando {device} si spegne`)},{value:`heat`,label:N(`Heat`,`Riscaldamento`),phrase:N(`When {device} starts heating`,`Quando {device} passa al riscaldamento`)},{value:`cool`,label:N(`Cool`,`Raffrescamento`),phrase:N(`When {device} starts cooling`,`Quando {device} passa al raffrescamento`)},{value:`auto`,label:N(`Automatic`,`Automatico`)},{value:`heat_cool`,label:N(`Heat and cool`,`Caldo e freddo`)},{value:`fan_only`,label:N(`Fan only`,`Solo ventilazione`)},{value:`dry`,label:N(`Dry`,`Deumidificazione`)}],icon:`thermometer`},{kind:`numeric`,field:`currentTemp`,quantity:N(`the temperature`,`la temperatura`),label:N(`Temperature`,`Temperatura`),unit:`°C`,icon:`thermometer`},{kind:`numeric`,field:`currentHumidity`,quantity:N(`the humidity`,`l’umidità`),label:N(`Humidity`,`Umidità`),unit:`%`,icon:`droplets`},{kind:`numeric`,field:`target`,quantity:N(`the set temperature`,`la temperatura impostata`),label:N(`Set temperature`,`Temperatura impostata`),unit:`°C`,icon:`thermometer`}]}},Fw=x([`backup`,`hub-server`,`agent-server`,`addons`]),Iw=x([`pending`,`running`,`ok`,`failed`,`skipped`]),Lw=x([`backup-unavailable`,`backup-failed`,`server-refused`,`server-not-on-target`,`node-capless`,`status-unreadable`,`addon-update-failed`,`addons-not-converged`,`interrupted`,`timeout-stall`,`timeout-ceiling`]),Rw=b({kind:Fw,nodeId:p().optional(),status:Iw,detail:p(),reason:Lw.optional(),fromVersion:p().nullable().optional(),packages:S(p()).readonly().optional(),startedAt:f().optional(),finishedAt:f().optional()}),zw=x([`running`,`succeeded`,`failed`]),Bw=b({id:p(),state:zw,targetVersion:p(),requestedBy:p(),startedAt:f(),finishedAt:f().optional(),steps:S(Rw).readonly(),stoppedAt:p().optional(),reason:Lw.optional(),skippedOffline:S(p()).readonly()}),Vw=b({version:p().optional(),addons:v().optional(),backup:v().optional()}),Hw=x([`no-target`,`node-busy`,`job-running`,`nothing-to-do`,`status-unreadable`]),Uw=b({targetVersion:p().nullable(),steps:S(Rw).readonly(),skippedOffline:S(p()).readonly(),blocker:Hw.nullable(),blockerDetail:p().nullable()}),Ww=b({accepted:v(),jobId:p().nullable(),blocker:Hw.nullable(),message:p()}),Gw={name:`cluster-update`,scope:`system`,mode:`singleton`,methods:{previewClusterUpdate:O(Vw,Uw,{auth:`admin`}),startClusterUpdate:O(Vw,Ww,{kind:`mutation`,auth:`admin`}),getClusterUpdateJob:O(b({jobId:p().optional()}),Bw.nullable(),{auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:A.CLUSTER}},Kw=b({r:f().int().min(0).max(255).meta(j(`none`)),g:f().int().min(0).max(255).meta(j(`none`)),b:f().int().min(0).max(255).meta(j(`none`))}),qw=b({h:f().min(0).max(360).meta(j(`none`)),s:f().min(0).max(100).meta(j(`none`)),v:f().min(0).max(100).meta(j(`none`))}),Jw=i(`mode`,[b({mode:o(`rgb`),rgb:Kw}),b({mode:o(`hsv`),hsv:qw}),b({mode:o(`mired`),colorTemperature:f().int().min(50).max(1e3)})]),Yw=b({mode:x([`rgb`,`hsv`,`mired`]),rgb:Kw.optional(),hsv:qw.optional(),colorTemperature:f().int().optional().meta(j(`colour-temperature`)),lastChangedAt:f()});function tve(e){let t=Jw.safeParse(e);return t.success?t.data:null}var Xw={name:`color`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Light],methods:{setColor:O(b({deviceId:f().int().nonnegative(),color:Jw}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`color.warmWhite`,label:N(`Warm white`,`Bianco caldo`),phrase:N(`Set {device} to warm white`,`Imposta {device} su bianco caldo`),icon:`sun`,args:{color:{mode:`mired`,colorTemperature:370}}},{id:`color.coolWhite`,label:N(`Cool white`,`Bianco freddo`),phrase:N(`Set {device} to cool white`,`Imposta {device} su bianco freddo`),icon:`snowflake`,args:{color:{mode:`mired`,colorTemperature:200}}},{id:`color.red`,label:N(`Red`,`Rosso`),phrase:N(`Turn {device} red`,`Colora {device} di rosso`),icon:`palette`,args:{color:{mode:`rgb`,rgb:{r:255,g:0,b:0}}}},{id:`color.green`,label:N(`Green`,`Verde`),phrase:N(`Turn {device} green`,`Colora {device} di verde`),icon:`palette`,args:{color:{mode:`rgb`,rgb:{r:0,g:255,b:0}}}},{id:`color.blue`,label:N(`Blue`,`Blu`),phrase:N(`Turn {device} blue`,`Colora {device} di blu`),icon:`palette`,args:{color:{mode:`rgb`,rgb:{r:0,g:0,b:255}}}}]})},events:{onColorChanged:{data:b({deviceId:f(),mode:x([`rgb`,`hsv`,`mired`]),rgb:Kw.optional(),hsv:qw.optional(),colorTemperature:f().int().optional(),lastChangedAt:f()}),notOperatorFacing:"a colour change is read through the `mode` state trigger"}},status:{schema:Yw,kind:`command-driven`},runtimeState:Yw,durability:`session`,history:`none`,vocabulary:{noun:N(`Colour`,`Colore`),order:1020,state:[{kind:`enum`,field:`mode`,label:N(`Colour mode`,`Modalità colore`),values:[{value:`rgb`,label:N(`RGB colour`,`Colore RGB`)},{value:`hsv`,label:N(`HSV colour`,`Colore HSV`)},{value:`mired`,label:N(`White temperature`,`Temperatura del bianco`)}],icon:`palette`}]}};function Zw(e,t){let n=e;for(let e of t.split(`.`)){let t=wg(n);if(!(t instanceof se))return null;let r=t.shape[e];if(!(r instanceof re))return null;n=r}return n}function Qw(e,t){let n=Tg(e).find(e=>e.path===t);if(n===void 0)return null;let r=Zw(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 $w(e){return new Map(Tg(e).filter(e=>!e.path.includes(`.`)).flatMap(t=>{let n=Qw(e,t.path);return n===null?[]:[[t.path,n]]}))}function eT(e){let t=wg(e);return t instanceof se?Object.entries(t.shape).flatMap(([e,t])=>t instanceof re&&!t.safeParse(void 0).success?[e]:[]):[]}function tT(e,t){let n=t.split(`.`);return n.slice(0,-1).flatMap((t,r)=>{let i=n.slice(0,r+1).join(`.`),a=Zw(e,i);return a!==null&&a.safeParse(void 0).success?[i]:[]})}var nT={"doorbell.onPressed":C.DoorbellOnPressed},nve=nT,rT=b({featureIndex:f().int().nonnegative(),cap:p(),eventName:p(),category:x(C),stateField:p(),fieldKey:p()});function iT(e,t,n){return{code:e,path:t,message:n}}function rve(e){return e.issues.map(e=>`${e.path.length===0?`payload`:e.path.join(`.`)}: ${e.message}`).join(`; `)}function aT(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?Qw(e.runtimeState,s.field):null;if(l===null){r.push(iT(`unknown-field`,c,`\`${e.name}.${a}\` derives from missing state field \`${s.field}\``));continue}if(l.kind!==`number`){r.push(iT(`kind-mismatch`,c,`\`${e.name}.${a}\` needs a numeric state field; \`${s.field}\` is ${l.kind}`));continue}let u=`${e.name}.${a}`,d=nve[u];if(d===void 0){r.push(iT(`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(iT(`not-composable`,`features[${t.featureIndex}].cap`,`\`${u}\` cannot be derived from { deviceId, timestamp }: ${rve(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(iT(`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 oT=x(`reserved-variant.unknown-capability.not-composable.wrong-device-type.has-commands.unknown-field.nested-field.missing-field.kind-mismatch.source-kind-mismatch.may-be-null.source-missing.source-unreadable.source-capability-missing.source-field-unknown.expression-invalid.cycle.duplicate-target.not-item-array.item-field-reserved.target-missing.target-unreadable.not-replaceable.native-capability-replace.mixed-quantity.helper-mismatch.member-constraint.retention.command-method-unknown.command-source-unknown.command-input-unknown.command-input-missing.power-source-is-actuator`.split(`.`)),sT=b({code:oT,path:p(),message:p()}),cT=x([`string`,`number`,`boolean`,`enum`]),lT=x([`null`,`offline`,`unknown`,`release`,`omit`]),uT=x([`derived`,`clock`,`constant`,`accumulator`]),dT=b({arrayPath:p(),key:p(),label:p(),resettable:v().optional()}),fT=b({cap:p(),path:p(),item:dT.optional(),featureIndex:f().int().nonnegative(),kind:cT,nullable:v(),required:v(),unavailable:lT,role:uT,source:pc,reads:S(ac)});function pT(e){let t=e.item===void 0?e.path:zc(e.item.arrayPath,e.item.key,e.path);return`${e.cap}.${t}`}var mT=x([`new`,`add`,`replace`]),hT=b({featureIndex:f().int().nonnegative(),cap:p(),mode:mT}),gT=b({ok:v(),problems:S(sT),fields:S(fT),features:S(hT),events:S(rT)}),_T=x([`stopped`,`starting`,`running`,`degraded`,`incomplete`,`failed`]),vT=x([`fresh`,`stale`,`unavailable`]),yT=b({cap:p(),path:p(),item:dT.optional(),state:vT,value:c([p(),f(),v(),ie()]),reason:p().optional()}),bT=b({blockId:p(),deviceId:f().nullable(),status:_T,reason:p().optional(),fields:S(yT)}),ive=rc,xT=b({id:p().min(1),name:p().min(1).max(120),enabled:v(),updatedAt:f(),composition:Mc}),ST=b({id:p().min(1),name:p().nullable(),error:p()}),CT=b({deviceId:f().int(),capName:p(),owner:p(),error:p()}),wT=b({integrationId:p().nullable(),storeLoaded:v(),blocks:S(xT),restartBlockIds:S(p()),unreadableBlocks:S(ST),retiredBlockIds:S(p()).optional()}),TT=b({blockId:p(),status:_T,reason:p().optional()}),ET=b({blocks:S(TT),acted:v(),unreleasedClaims:S(CT).optional()}),DT={name:`composer`,scope:`system`,mode:`singleton`,internal:!0,methods:{applyBlocks:O(wT,ET,{kind:`mutation`,auth:`admin`}),getStates:O(b({blockIds:S(p())}),b({states:S(bT)}),{auth:`admin`})},vocabulary:{notOperatorFacing:`device composition — an authoring tool, not an action`}},OT=b({connected:v(),lastChangedAt:f()}),kT={name:`connectivity`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Sensor],methods:{},status:{schema:OT,kind:`push`},runtimeState:OT,durability:`restored`,history:{fields:{connected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:N(`Connectivity`,`Connettività`),order:5040,state:[{kind:`boolean`,field:`connected`,label:N(`Connected`,`Connesso`),whenTrue:N(`When {device} connects`,`Quando {device} si connette`),whenFalse:N(`When {device} disconnects`,`Quando {device} si disconnette`),icon:`wifi`}]}},AT=x([`wear`,`supply`,`waste`]),jT=x([`part`,`tank`,`product`,`bin`]),MT=x([`ok`,`low`,`empty`,`full`,`replace`]),ave=x([`ok`,`low`,`empty`,`full`]);function NT(e){return e.kind??`wear`}var ove={wear:`part`,waste:`bin`,supply:`product`};function sve(e){return e.form??ove[NT(e)]}var PT=x([`duration`,`count`]),FT=b({value:f().min(0).nullable().meta(j(`device`)),kind:PT}),IT=b({key:p().min(1),label:p().min(1),level:f().min(0).max(100).nullable().meta(j(`percentage`)),status:MT.nullable(),kind:AT.optional(),form:jT.optional(),lastResetAt:f().nullable(),resettable:v(),remaining:FT.optional()}),LT=b({items:S(IT),lastChangedAt:f()}),cve={items:[],lastChangedAt:0},lve={version:1,targets:[{id:`items`,cardinality:`keyedArray`,vocabulary:{cap:`consumables`},deviceTypes:Object.values(w),apply:`add`,path:`items`,keyField:`key`,labelField:`label`,itemSchema:IT,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:[...PT.options]}]},{path:`status`,sources:[{kind:`enum`,transforms:[{kind:`enum-map`,outputValues:[...MT.options],unmapped:null}]}]}],traits:[{path:`kind`,values:[...AT.options],defaultValue:`wear`},{path:`form`,values:[...jT.options],defaultValue:`part`}],companions:[{kind:`clock`,path:`lastChangedAt`,when:`add`},{kind:`clock`,path:`lastFetchedAt`,when:`add`}],advancedExpression:!0}]},RT={name:`consumables`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:Object.values(w),methods:{reset:O(b({deviceId:f().int().nonnegative(),key:p().min(1)}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`consumables.reset`,label:N(`Mark as replaced`,`Segna come sostituito`),phrase:N(`Mark {key} as replaced on {device}`,`Segna {key} come sostituito su {device}`),icon:`refresh-cw`,openArgs:[{key:`key`,label:N(`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:LT,kind:`push`,empty:cve,itemArray:{path:`items`,keyField:`key`,labelField:`label`,itemSchema:IT,emptyItem:{key:``,label:``,level:null,status:null,lastResetAt:null,resettable:!1}}},runtimeState:LT.extend({lastFetchedAt:f()}),durability:`restored`,customize:lve,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:N(`Consumables`,`Materiali di consumo`),order:2070}},zT=b({entryOpen:v(),lastChangedAt:f()}),BT={name:`contact`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Sensor],methods:{},status:{schema:zT,kind:`push`},runtimeState:zT,durability:`restored`,history:{fields:{entryOpen:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:N(`Contact`,`Contatto`),order:5050,state:[{kind:`boolean`,field:`entryOpen`,label:N(`Open`,`Aperto`),whenTrue:N(`When {device} opens`,`Quando {device} si apre`),whenFalse:N(`When {device} closes`,`Quando {device} si chiude`),icon:`door-open`}]}},VT=x([`numeric`,`select`,`text`,`datetime`]),HT=b({kind:VT,value:c([f().meta(j(`device`)),p()]),options:S(p()),lastChangedAt:f(),min:f().optional().meta(j(`device`)),max:f().optional().meta(j(`device`)),step:f().optional().meta(j(`device`))}),uve=i(`kind`,[b({kind:o(`numeric`),value:f()}),b({kind:o(`select`),value:p().min(1)}),b({kind:o(`text`),value:p()}),b({kind:o(`datetime`),value:p().min(1)})]),UT=b({deviceId:f().int().nonnegative(),cycle:v().default(!0)}),WT=b({deviceId:f().int().nonnegative()}),GT={name:`control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Control],methods:{setValue:O(b({deviceId:f().int().nonnegative(),control:uve}),_(),{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:k(UT,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.next`,label:N(`Next option`,`Opzione successiva`),phrase:N(`Select the next option on {device}`,`Seleziona l’opzione successiva su {device}`),icon:`skip-forward`,openArgs:[{key:`cycle`,label:N(`Wrap to the first option`,`Ricomincia dalla prima opzione`),offer:{kind:`boolean`}}]}]}),previous:k(UT,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.previous`,label:N(`Previous option`,`Opzione precedente`),phrase:N(`Select the previous option on {device}`,`Seleziona l’opzione precedente su {device}`),icon:`skip-back`,openArgs:[{key:`cycle`,label:N(`Wrap to the last option`,`Ricomincia dall’ultima opzione`),offer:{kind:`boolean`}}]}]}),first:k(WT,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.first`,label:N(`First option`,`Prima opzione`),phrase:N(`Select the first option on {device}`,`Seleziona la prima opzione su {device}`),icon:`chevron-first`}]}),last:k(WT,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.last`,label:N(`Last option`,`Ultima opzione`),phrase:N(`Select the last option on {device}`,`Seleziona l’ultima opzione su {device}`),icon:`chevron-last`}]})},status:{schema:HT,kind:`push`},runtimeState:HT,durability:`session`,history:`none`,vocabulary:{noun:N(`Control`,`Controllo`),order:1150,state:[{kind:`value`,field:`value`,label:N(`Value`,`Valore`),offer:{kind:`dynamic`,from:`status`,field:`options`},icon:`sliders-horizontal`}]}},R=class extends Error{code;constructor(e,t){super(t),this.name=`IrCodecError`,this.code=e}},KT=1024,qT=S(f().int()).min(2).max(KT).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]})})}),JT=b({carrierHz:f().int().positive().optional(),dutyCyclePercent:f().int().min(1).max(100).optional(),repeat:f().int().min(0).max(20).optional(),repeatDelayMs:f().int().min(0).optional()}),dve=.241246,fve=0;function YT(e){let t=e.trim().split(/\s+/).filter(e=>e.length>0);if(t.length<4)throw new R(`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 R(`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 R(`pronto-malformed`,`Pronto header incomplete`);if(r!==fve)throw new R(`pronto-unsupported-form`,`Pronto form ${t[0]??``} is not supported, only the learned 0000 form`);if(i===0)throw new R(`pronto-malformed`,`Pronto frequency word is zero`);let s=a+o;if(s===0||n.length!==4+s*2)throw new R(`pronto-malformed`,`Pronto declares ${s} burst pairs but carries ${(n.length-4)/2} word pairs`);let c=i*dve,l=n.slice(4).map((e,t)=>{let n=Math.max(1,Math.round(e*c));return t%2==0?n:-n}),u=qT.safeParse(l);if(!u.success)throw new R(`invalid-timings`,`Pronto decoded to invalid timings: ${u.error.message}`);return{timings:u.data,carrierHz:Math.round(1e6/c)}}var pve=8192,XT=32,ZT=3,mve=264,QT=KT*2;function hve(e){let t=[],n=0,r=e=>{if(t.length+e>QT)throw new R(`tuya-malformed`,`decompressed code is larger than any IR train`)},i=()=>{let t=e[n++];if(t===void 0)throw new R(`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 R(`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 R(`tuya-malformed`,`back-reference is invalid`);t.push(n)}}return Uint8Array.from(t)}function gve(e){let t=[],n=new Map,r=0,i=n=>{for(let i=r;i<n;i+=XT){let r=Math.min(i+XT,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+ZT<=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<=pve){let t=0;for(;a+t<e.length&&t<mve&&e[r+t]===e[a+t];)t++;t>=ZT&&(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 $T=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,_ve=65535;function vve(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+=$T[o>>18&63],t+=$T[o>>12&63],t+=n+1<e.length?$T[o>>6&63]:`=`,t+=n+2<e.length?$T[o&63]:`=`}return t}function yve(e){let t=e.trim().replace(/=+$/,``);if(t.length===0||t.length%4==1)throw new R(`tuya-malformed`,`not a base64 string`);let n=[],r=0,i=0;for(let e of t){let t=$T.indexOf(e);if(t<0)throw new R(`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 eE(e){let t=new Uint8Array(e.length*2);return e.forEach((e,n)=>{let r=Math.abs(e);if(r===0||r>_ve)throw new R(`invalid-timings`,`timing ${n} does not fit 16 bits`);t[n*2]=r&255,t[n*2+1]=r>>8}),vve(gve(t))}function tE(e){let t=hve(yve(e));if(t.length===0||t.length%2!=0)throw new R(`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=qT.safeParse(n);if(!r.success)throw new R(`tuya-malformed`,r.error.message);return r.data}var nE=x([`tuya`]),rE=Math.ceil((QT+Math.ceil(QT/32))/3)*4+256,iE=b({format:nE,code:p().min(1).max(rE)}),aE={tuya:{encode:eE,decode:tE}},oE=i(`kind`,[b({kind:o(`raw`),timings:S(f().int()),settings:JT.optional()}),b({kind:o(`pronto`),code:p()}),b({kind:o(`native`),format:nE,code:p()})]);function sE(e){if(e.kind===`pronto`){let t=YT(e.code);return{timings:t.timings,settings:{carrierHz:t.carrierHz}}}if(e.kind===`native`)return{timings:aE[e.format].decode(e.code),settings:{}};let t=qT.safeParse(e.timings);if(!t.success)throw new R(`invalid-timings`,t.error.message);return{timings:t.data,settings:e.settings??{}}}var cE=`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(`.`),lE=[`source_select`];function uE(e){return lE.includes(e)}var dE=`custom:`,bve=/^[a-z0-9][a-z0-9_]{0,47}$/,xve=new Set(cE);function fE(e){return xve.has(e)}function pE(e){return bve.test(e)}function mE(e){return`${dE}${e}`}function hE(e){if(!e.startsWith(`custom:`))return null;let t=e.slice(7);return pE(t)?t:null}function gE(e){return fE(e)||hE(e)!==null}var _E=p().refine(gE,{message:`a role is one of the known roles or custom:<key> (lowercase letters, digits, _)`}),vE=[`digits`,`sequence`,`ir`],Sve=x(vE),Cve=200,wve=16,Tve=6,Eve=/^[a-z0-9][a-z0-9_-]{0,47}$/,Dve=RegExp(`^[0-9]{1,6}$`),yE={id:p().regex(Eve,{message:`a lowercase slug`}),name:p().trim().min(1).max(60)},bE=b({...yE,kind:o(`digits`),number:p().regex(Dve,{message:`up to 6 digits`})}),xE=b({...yE,kind:o(`sequence`),steps:S(_E).min(1).max(16)}),SE=b({...yE,kind:o(`ir`),transmitterId:f().int().nonnegative().optional(),payload:oE}),CE=i(`kind`,[bE,xE,SE]),Ove=500,kve=100,wE=3e3;function TE(e){switch(e.kind){case`sequence`:return e.steps;case`digits`:return Array.from(e.number,e=>`digit_${e}`);case`ir`:return[]}}function EE(e){try{return sE(e.payload),null}catch(e){if(e instanceof R)return e.message;throw e}}function Ave(e,t){return e.trim().toLowerCase()===t.trim().toLowerCase()}function DE(e,t){let n=t.trim();for(let t of e)if(t.kind===`digits`&&t.number===n)return t;return null}function jve(e,t){let n=e.find(e=>Ave(e.name,t));if(n!==void 0)return n;let r=e.find(e=>e.id===t.trim());return r===void 0?DE(e,t):r}var OE=x([`off`,`on`,`idle`,`playing`,`paused`,`buffering`,`standby`]),kE=x([`off`,`all`,`one`]),Mve=b({type:p(),title:p(),artist:p().optional(),album:p().optional(),imageUrl:p().optional()}),AE=x([`reported`,`assumed`]),jE=x([`state`,`volumeLevel`,`isMuted`,`source`]),ME=b({state:OE,stateSource:AE.default(`reported`),assumedFields:S(jE).default([]),volumeLevel:f().min(0).max(100).nullable().meta(j(`percentage`)),isMuted:v().nullable(),muteReadback:v().optional(),source:p(),availableSources:S(p()),declaredSources:S(b({name:p(),kind:x(vE),number:p().optional()})).optional(),currentMedia:Mve.nullable(),position:f().int().nonnegative().nullable().meta(j(`duration-ms`)),duration:f().int().nonnegative().nullable().meta(j(`duration-ms`)),shuffle:v().nullable(),repeat:kE.nullable(),positionUpdatedAt:f().nullable().default(null),lastChangedAt:f()}),Nve=50,NE=b({deviceId:f().int().nonnegative(),steps:f().int().min(1).max(50).default(1)}),PE=b({deviceId:f().int().nonnegative()}),FE={name:`media-player`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.MediaPlayer],power:{kind:`methods`,field:`state`,offValues:[`off`,`standby`],on:`turnOn`,off:`turnOff`},methods:{turnOn:k(PE,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.turnOn`,label:N(`Turn on`,`Accendi`),phrase:N(`Turn on {device}`,`Accendi {device}`),icon:`power`}]}),turnOff:k(PE,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.turnOff`,label:N(`Turn off`,`Spegni`),phrase:N(`Turn off {device}`,`Spegni {device}`),icon:`power`}]}),volumeUp:k(NE,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.volumeUp`,label:N(`Volume up`,`Alza il volume`),phrase:N(`Raise the volume of {device}`,`Alza il volume di {device}`),icon:`volume-2`}]}),volumeDown:k(NE,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.volumeDown`,label:N(`Volume down`,`Abbassa il volume`),phrase:N(`Lower the volume of {device}`,`Abbassa il volume di {device}`),icon:`volume-2`}]}),channelUp:k(NE,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.channelUp`,label:N(`Channel up`,`Canale successivo`),phrase:N(`Go to the next channel on {device}`,`Passa al canale successivo su {device}`),icon:`skip-forward`}]}),channelDown:k(NE,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.channelDown`,label:N(`Channel down`,`Canale precedente`),phrase:N(`Go to the previous channel on {device}`,`Torna al canale precedente su {device}`),icon:`skip-back`}]}),play:O(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.play`,label:N(`Play`,`Riproduci`),phrase:N(`Play on {device}`,`Avvia la riproduzione su {device}`),icon:`play`}]}),pause:O(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.pause`,label:N(`Pause media`,`Metti in pausa`),phrase:N(`Pause {device}`,`Metti in pausa {device}`),icon:`pause`}]}),stop:k(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.stop`,label:N(`Stop media`,`Ferma la riproduzione`),phrase:N(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),next:k(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.next`,label:N(`Next track`,`Brano successivo`),phrase:N(`Skip to the next track on {device}`,`Passa al brano successivo su {device}`),icon:`skip-forward`}]}),previous:k(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.previous`,label:N(`Previous track`,`Brano precedente`),phrase:N(`Go back to the previous track on {device}`,`Torna al brano precedente su {device}`),icon:`skip-back`}]}),setVolume:k(b({deviceId:f().int().nonnegative(),volumeLevel:f().min(0).max(100)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.volume`,label:N(`Set volume`,`Imposta il volume`),phrase:N(`Set the volume of {device} to {volumeLevel}`,`Imposta il volume di {device} al {volumeLevel}`),icon:`volume-2`,openArgs:[{key:`volumeLevel`,label:N(`Volume`,`Volume`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setMute:k(b({deviceId:f().int().nonnegative(),muted:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.mute`,label:N(`Mute`,`Silenzia`),phrase:N(`Mute {device}`,`Silenzia {device}`),icon:`volume-x`,args:{muted:!0}},{id:`media.unmute`,label:N(`Unmute`,`Riattiva l’audio`),phrase:N(`Unmute {device}`,`Riattiva l’audio di {device}`),icon:`volume-2`,args:{muted:!1}}]}),setShuffle:k(b({deviceId:f().int().nonnegative(),shuffle:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.shuffleOn`,label:N(`Shuffle on`,`Riproduzione casuale attiva`),phrase:N(`Turn on shuffle on {device}`,`Attiva la riproduzione casuale su {device}`),icon:`shuffle`,args:{shuffle:!0}},{id:`media.shuffleOff`,label:N(`Shuffle off`,`Riproduzione casuale spenta`),phrase:N(`Turn off shuffle on {device}`,`Disattiva la riproduzione casuale su {device}`),icon:`shuffle`,args:{shuffle:!1}}]}),setRepeat:k(b({deviceId:f().int().nonnegative(),repeat:kE}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.repeat`,label:N(`Set repeat`,`Imposta la ripetizione`),phrase:N(`Set repeat on {device} to {repeat}`,`Imposta la ripetizione di {device} su {repeat}`),icon:`repeat`,openArgs:[{key:`repeat`,label:N(`Repeat`,`Ripetizione`),offer:{kind:`enum`,values:[{value:`off`,label:N(`Off`,`Disattivata`)},{value:`all`,label:N(`All`,`Tutti i brani`)},{value:`one`,label:N(`One track`,`Un brano`)}]}}]}]}),selectSource:k(b({deviceId:f().int().nonnegative(),source:p().min(1)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.source`,label:N(`Select source`,`Scegli la sorgente`),phrase:N(`Switch {device} to {source}`,`Passa {device} alla sorgente {source}`),icon:`cast`,openArgs:[{key:`source`,label:N(`Source`,`Sorgente`),offer:{kind:`dynamic`,from:`status`,field:`availableSources`}}]}]}),seek:k(b({deviceId:f().int().nonnegative(),position:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.seek`,label:N(`Seek`,`Vai al punto`),phrase:N(`Move {device} to {position}`,`Porta {device} al punto {position}`),icon:`fast-forward`,openArgs:[{key:`position`,label:N(`Position`,`Posizione`),offer:{kind:`number`,min:0,step:1e3,unit:`ms`}}]}]}),playMedia:k(b({deviceId:f().int().nonnegative(),mediaId:p().min(1),mediaType:p().min(1)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.playMedia`,label:N(`Play media`,`Riproduci un contenuto`),phrase:N(`Play {mediaId} on {device}`,`Riproduci {mediaId} su {device}`),icon:`music`,openArgs:[{key:`mediaId`,label:N(`Media`,`Contenuto`),offer:{kind:`text`}},{key:`mediaType`,label:N(`Media type`,`Tipo di contenuto`),offer:{kind:`text`}}]}]})},status:{schema:ME,kind:`push`},runtimeState:ME,durability:`session`,history:{fields:{volumeLevel:{kind:`gauge`,unit:`%`,deadband:1},isMuted:{kind:`boolean`}}},vocabulary:{noun:N(`Media player`,`Lettore multimediale`),order:2060,state:[{kind:`enum`,field:`state`,label:N(`Playback`,`Riproduzione`),values:[{value:`off`,label:N(`Off`,`Spento`),phrase:N(`When {device} turns off`,`Quando {device} si spegne`)},{value:`on`,label:N(`On`,`Acceso`),phrase:N(`When {device} turns on`,`Quando {device} si accende`)},{value:`idle`,label:N(`Idle`,`Inattivo`)},{value:`playing`,label:N(`Playing`,`In riproduzione`),phrase:N(`When {device} starts playing`,`Quando {device} inizia a riprodurre`)},{value:`paused`,label:N(`Paused`,`In pausa`),phrase:N(`When {device} is paused`,`Quando {device} va in pausa`)},{value:`buffering`,label:N(`Buffering`,`In caricamento`)},{value:`standby`,label:N(`Standby`,`In standby`)}],icon:`music`},{kind:`numeric`,field:`volumeLevel`,quantity:N(`the volume`,`il volume`),label:N(`Volume`,`Volume`),unit:`%`,icon:`volume-2`},{kind:`boolean`,field:`isMuted`,label:N(`Muted`,`Silenziato`),whenTrue:N(`When {device} is muted`,`Quando {device} viene silenziato`),whenFalse:N(`When {device} is unmuted`,`Quando l’audio di {device} torna attivo`),icon:`volume-x`},{kind:`value`,field:`source`,label:N(`Source`,`Sorgente`),offer:{kind:`dynamic`,from:`status`,field:`availableSources`},icon:`cast`}]}},IE={battery:{version:1,targets:[{id:`level`,cardinality:`scalar`,deviceTypes:[w.Camera,w.Sensor,w.Button,w.Switch,w.PetFeeder,w.Container,w.Climate,w.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:[w.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:[w.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:[w.Camera,w.Light,w.Siren,w.Switch,w.Sensor,w.Climate,w.Button,w.EventEmitter,w.Update,w.Generic,w.Notifier,w.Script,w.Automation,w.Lock,w.Cover,w.Valve,w.Humidifier,w.WaterHeater,w.Fan,w.MediaPlayer,w.AlarmPanel,w.Control,w.Presence,w.Weather,w.WeatherStation,w.Vacuum,w.LawnMower,w.Container,w.Image,w.PetFeeder,w.PetFountain,w.Dishwasher,w.Washer,w.Dryer,w.Gateway,w.HeatPump,w.EnergySystem],apply:`add`,vocabularyCap:`consumables`,sources:[],sourceReport:{status:`assignment-status`},advancedExpression:!0,path:`items`,keyField:`key`,labelField:`label`,nativeItems:`read-only`,fields:[{path:`level`,valueKind:`number`,nullable:!0,sources:[{kind:`numeric`,transformKinds:[`identity`,`linear`],transforms:[{kind:`identity`},{kind:`linear`,defaultScale:1,defaultOffset:0,clampMin:0,clampMax:100}]}]},{path:`remaining.value`,valueKind:`number`,nullable:!0,sources:[{kind:`numeric`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],literals:[{path:`remaining.kind`,values:[`duration`,`count`]}]},{path:`status`,valueKind:`enum`,nullable:!0,enumValues:[`ok`,`low`,`empty`,`full`,`replace`],sources:[{kind:`enum`,transformKinds:[`enum-map`],transforms:[{kind:`enum-map`,outputValues:[`ok`,`low`,`empty`,`full`,`replace`],unmapped:null}]}]}],traits:[{path:`kind`,values:[`wear`,`supply`,`waste`],defaultValue:`wear`},{path:`form`,values:[`part`,`tank`,`product`,`bin`],defaultValue:`part`}],companions:[{kind:`clock`,path:`lastChangedAt`,when:`add`},{kind:`clock`,path:`lastFetchedAt`,when:`add`}]}]},doorbell:{version:1,targets:[{id:`pressed`,cardinality:`event`,deviceTypes:[w.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:[w.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:[w.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:[w.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:[w.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:[w.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:[w.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:[w.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:[w.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:[w.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:[w.Fan],apply:`add`,readMethod:`getPresets`,writeMethod:`setPresets`,vocabularyCap:`fan-presets`,sources:[],sourceReport:{status:`assignment-status`},advancedExpression:!1}]},"lock-control":{version:1,targets:[{id:`door-contact`,cardinality:`scalar`,deviceTypes:[w.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:[w.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:[w.Switch,w.Light,w.Fan,w.Climate,w.Humidifier,w.WaterHeater,w.MediaPlayer,w.Washer,w.Dryer,w.Dishwasher,w.Vacuum,w.LawnMower,w.PetFeeder],apply:`add`,vocabularyCap:`power-meter`,vocabularyStateField:`power`,sources:[{kind:`numeric`,requiredUnit:`W`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!0,path:`power`,valueKind:`number`,nullable:!1,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`always`}]},{id:`energy`,cardinality:`scalar`,deviceTypes:[w.Switch,w.Light,w.Fan,w.Climate,w.Humidifier,w.WaterHeater,w.MediaPlayer,w.Washer,w.Dryer,w.Dishwasher,w.Vacuum,w.LawnMower,w.PetFeeder],apply:`add`,vocabularyCap:`power-meter`,vocabularyStateField:`energy`,sources:[{kind:`numeric`,requiredUnit:`kWh`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!0,path:`energy`,valueKind:`number`,nullable:!1,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`always`}]},{id:`voltage`,cardinality:`scalar`,deviceTypes:[w.Switch,w.Light,w.Fan,w.Climate,w.Humidifier,w.WaterHeater,w.MediaPlayer,w.Washer,w.Dryer,w.Dishwasher,w.Vacuum,w.LawnMower,w.PetFeeder],apply:`add`,vocabularyCap:`power-meter`,vocabularyStateField:`voltage`,sources:[{kind:`numeric`,requiredUnit:`V`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!0,path:`voltage`,valueKind:`number`,nullable:!1,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`always`}]},{id:`current`,cardinality:`scalar`,deviceTypes:[w.Switch,w.Light,w.Fan,w.Climate,w.Humidifier,w.WaterHeater,w.MediaPlayer,w.Washer,w.Dryer,w.Dishwasher,w.Vacuum,w.LawnMower,w.PetFeeder],apply:`add`,vocabularyCap:`power-meter`,vocabularyStateField:`current`,sources:[{kind:`numeric`,requiredUnit:`A`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!0,path:`current`,valueKind:`number`,nullable:!1,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`always`}]}]},"power-source":{version:1,targets:[{id:`switch`,cardinality:`scalar`,deviceTypes:[w.Gateway,w.Camera,w.Sensor,w.MediaPlayer,w.Vacuum,w.Generic,w.Washer,w.Dryer,w.Dishwasher,w.PetFountain,w.Fan,w.Humidifier,w.Climate,w.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:[w.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:[w.Washer,w.Dryer,w.Dishwasher,w.Vacuum,w.LawnMower,w.MediaPlayer,w.WaterHeater,w.Humidifier,w.Fan,w.Climate,w.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:{[w.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:[w.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:[w.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:[w.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:[w.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:[w.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:[w.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:[w.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:[w.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:[w.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:[w.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:[w.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:[w.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:[w.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:[w.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:[w.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:[w.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:[w.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:[w.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:[w.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:[w.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`}]}},LE={"ambient-light-sensor":{illuminance:`lx`},battery:{level:`%`,voltage:`V`},"humidity-sensor":{humidity:`%`},"power-meter":{power:`W`,energy:`kWh`,voltage:`V`,current:`A`},"temperature-sensor":{temperature:`°C`}};function z(e,t,n){return{code:e,path:t,message:n}}function RE(...e){return{problems:e,fields:[],features:[],events:[]}}function zE(e){let t=e.item===void 0?`fields`:`items.${e.item.key}.fields`;return`features[${e.featureIndex}].${t}.${e.path}`}var BE={kind:`fixed`,result:[`number`]},VE={kind:`fixed`,result:[`boolean`]},HE=Object.freeze({min:BE,max:BE,abs:BE,floor:BE,ceil:BE,sqrt:BE,round:BE,pow:BE,clamp:BE,avg:BE,sum:BE,age:BE,convert:BE,coalesce:{kind:`coalesce`},any:VE,all:VE,within:VE,latest:{kind:`fixed`,result:[`number`,`null`]},number:{kind:`fixed`,result:[`number`,`null`]},rose:{kind:`fixed`,result:[`number`,`null`]},count:BE,dwell:{kind:`fixed`,result:[`boolean`,`null`]},latchedAt:{kind:`fixed`,result:[`number`,`null`]},schmitt:{kind:`fixed`,result:[`boolean`,`null`]}}),UE=class extends Error{};function WE(e){return e===null?`null`:typeof e==`number`?`number`:typeof e==`string`?`string`:`boolean`}function GE(e){return new Set([e])}function KE(...e){return new Set(e.flatMap(e=>[...e]))}function Pve(e){return new Set([...e].filter(e=>e!==`null`))}function Fve(e,t,n){if(e===`+`){let e=[...t,...n];return e.every(e=>e===`string`)?GE(`string`):e.every(e=>e===`number`)?GE(`number`):new Set([`number`,`string`])}return GE(e===`-`||e===`*`||e===`/`||e===`%`?`number`:`boolean`)}function Ive(e){return e.minArgs===e.maxArgs?`exactly ${e.minArgs}`:e.maxArgs===1/0?`at least ${e.minArgs}`:`${e.minArgs}–${e.maxArgs}`}function Lve(e,t){let n=ko[e];if(n!==void 0&&(t.length<n.minArgs||t.length>n.maxArgs))throw new UE(`${e}: wrong number of arguments (${t.length}); expected ${Ive(n)}`);let r=HE[e];if(r===void 0)throw new UE(`no result-kind rule for builtin '${e}'`);if(r.kind===`fixed`)return new Set(r.result);let i=KE(...t.map(Pve));return t.every(e=>e.has(`null`))?KE(i,GE(`null`)):i}function qE(e,t){switch(e.kind){case`literal`:return GE(WE(e.value));case`identifier`:{if(e.name===`now`)return GE(`number`);let n=t.get(e.name);if(n===void 0)throw new UE(`unbound identifier '${e.name}'`);return n}case`unary`:return GE(e.op===`!`?`boolean`:`number`);case`binary`:return Fve(e.op,qE(e.left,t),qE(e.right,t));case`logical`:return KE(qE(e.left,t),qE(e.right,t));case`conditional`:return KE(qE(e.consequent,t),qE(e.alternate,t));case`call`:return Lve(e.callee,e.args.map(e=>qE(e,t)))}}function JE(e,t){switch(e.kind){case`literal`:case`identifier`:return!1;case`unary`:return JE(e.operand,t);case`binary`:case`logical`:return JE(e.left,t)||JE(e.right,t);case`conditional`:return JE(e.test,t)||JE(e.consequent,t)||JE(e.alternate,t);case`call`:return e.callee===t||e.args.some(e=>JE(e,t))}}function YE(e,t){let n=Bo(e);return n.ok&&JE(n.parsed.ast,t)}function XE(e){let t=Bo(e.expr);if(!t.ok)return{ok:!1,error:t.error};try{return{ok:!0,kinds:qE(t.parsed.ast,e.bindingKinds)}}catch(e){if(e instanceof UE)return{ok:!1,error:e.message};throw e}}function Rve(e){return e.publish===`value`&&e.empty===`null`?{ok:!0,kinds:new Set([`number`,`null`])}:{ok:!0,kinds:new Set([`number`])}}function zve(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 ZE(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=Qw(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 QE(e,t,n){return z(`kind-mismatch`,n,`\`${e}.${t}\` is a union — it is read as a source, never written`)}function $E(e){return e.kind===`union`?null:e.kind===`enum`?`string`:e.kind}function eD(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=Qw(a,e.fieldPath),s=$E(t);return o?.kind!==`union`||s===null||!n.has(s)?n:new Set(n.has(`null`)?[s,`null`]:[s])}function tD(e,t){if(e.kind===`from`)return ZE(e,t);if(e.kind===`code`)return{ok:!1,code:`reserved-variant`,message:`code fields arrive in slice 4`};if(e.kind===`aggregate`)return zve(e);if(e.kind===`series`)return Rve(e);let n=new Map;for(let[r,i]of Object.entries(e.bindings)){if(i.kind===`literal`){n.set(r,new Set([WE(i.value)]));continue}let e=ZE(i,t);if(!e.ok)return{...e,message:`binding \`${r}\`: ${e.message}`};n.set(r,e.kinds)}let r=XE({expr:e.expr,bindingKinds:n});return r.ok?{ok:!0,kinds:r.kinds}:{ok:!1,code:`expression-invalid`,message:r.error}}function nD(e,t,n,r){let i=$E(t);if(i===null)return[QE(e,t.path,r)];let a=[...n].filter(e=>e!==`null`&&e!==i),o=[];return a.length>0&&o.push(z(`kind-mismatch`,r,`\`${e}.${t.path}\` is a ${t.kind}; this source can produce ${a.join(` or `)}`)),n.has(`null`)&&!t.nullable&&o.push(z(`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 Bve(e){if(e.kind!==`expression`)return null;let t=Bo(e.expr);if(!t.ok)return null;let n=t.parsed.ast;return n.kind===`literal`&&typeof n.value==`string`?n.value:null}function rD(e,t,n,r){if(t.kind!==`enum`||t.enumValues===void 0)return null;let i=Bve(n);if(i===null||t.enumValues.includes(i))return null;let a=t.enumValues.map(e=>`\`${e}\``).join(`, `);return z(`kind-mismatch`,r,`\`${e}.${t.path}\` accepts only ${a}; this source is the literal \`${i}\``)}function iD(e){if(e.kind!==`expression`)return`derived`;if(YE(e.expr,`count`))return`accumulator`;if(Rc(e).length>0)return`derived`;let t=Bo(e.expr);return t.ok&&t.parsed.identifiers.has(`now`)?`clock`:`constant`}function aD(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:z(`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 oD={resettable:!1};function Vve(e){return new Set([e.keyField,...e.labelField===void 0?[]:[e.labelField],...Object.keys(oD)])}function Hve(e,t,n){let r=Qw(e.itemSchema,t);return r===null||!r.required?!1:tT(e.itemSchema,t).every(e=>n.some(t=>t.startsWith(`${e}.`)))}function Uve({capName:e,itemArray:t,reserved:n},r,i){let a=Object.keys(r.fields);return Tg(t.itemSchema).flatMap(o=>{if(n.has(o.path)||o.path in r.fields||!Hve(t,o.path,a))return[];let s=Qw(t.itemSchema,o.path);return s===null||s.nullable?[]:[z(`missing-field`,`${i}.fields.${o.path}`,`\`${e}.${t.path}[].${o.path}\` is required and has no source`)]})}function Wve(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 RE(z(`item-field-reserved`,u,`\`${n}.${r.path}[].${c}\` is set by the composer itself — it takes no source`));let d=Qw(r.itemSchema,c);if(d===null)return RE(z(`unknown-field`,u,`a \`${n}\` item has no field \`${c}\``));if(d.kind===`union`)return RE(QE(n,c,u));let f=tD(l,a);if(!f.ok)return RE(z(f.code,u,f.message));let p=iD(l),m=aD(d,p,e.mode,n,u);if(!m.ok)return RE(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:[...Rc(l)]},g=rD(n,d,l,u);return{problems:[...nD(n,d,eD(l,d,f.kinds,a),u),...g===null?[]:[g]],fields:[h],features:[],events:[]}}function sD(e,t,n,r,i=`new`){let a=`features[${n}].items`,o=e.status?.itemArray;if(o===void 0)return RE(z(`not-item-array`,a,`\`${e.name}\` has no item array — it takes no \`items\``));if(o.path!==`items`)return RE(z(`not-item-array`,a,`\`${e.name}\`'s item array is at \`${o.path}\`, not \`${Sc}\` — not composable yet`));let s={capName:e.name,itemArray:o,reserved:Vve(o),featureIndex:n,lookupCap:r,mode:i},c=Object.entries(t.items??{}).flatMap(([e,t])=>[{problems:Uve(s,t,`${a}.${e}`),fields:[],features:[],events:[]},...Object.entries(t.fields).map(([n,r])=>Wve(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 cD=`deviceId`;function lD(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 uD(e){let t=e.features.flatMap((e,t)=>e.kind===`fields`&&Dc(e)?lD(e,t).map(e=>e.command.source):[]);return[...new Map(t.map(e=>[Nc(e),e])).values()]}function Gve(e,t){return e.name===`switch`&&t===`toggle`}function dD(e){return Object.entries(e.methods).filter(([t,n])=>n.systemOnly!==!0&&e.composedMethods?.[t]===void 0&&!Gve(e,t)).map(([e])=>e)}function Kve(){return Object.fromEntries(dD(FE).map(e=>[e,{kind:`extension`,target:`remote`}]))}var fD={all:new Set,required:new Set};function pD(e,t){let n=e.methods[t]?.input;if(n===void 0)return null;let r=wg(n);if(!(r instanceof se))return null;let i=Object.entries(r.shape).filter(([e])=>e!==cD);return{all:new Set(i.map(([e])=>e)),required:new Set(i.flatMap(([e,t])=>t instanceof re&&!t.safeParse(void 0).success?[e]:[]))}}function mD(e){return typeof e==`object`?_c(e)?[e.$input]:Object.values(e).flatMap(mD):[]}function hD(e){return[...e].map(e=>`\`${e}\``).join(`, `)}function qve(e,t){let{command:n,at:r}=e,i=t(n.cap);if(i===null)return{def:null,problems:[z(`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:[z(`command-source-unknown`,`${r}.method`,`\`${n.cap}\` has no method \`${n.method}\` to forward to`)]}:a.kind===`mutation`?{def:i,problems:[]}:{def:null,problems:[z(`command-source-unknown`,`${r}.method`,`\`${n.cap}.${n.method}\` is a query — a command calls a mutation of the source`)]}}function Jve(e,t,n,r){let{at:i,command:a}=e,o=`${a.cap}.${a.method}`,s=[];if(`deviceId`in r&&s.push(z(`command-input-unknown`,`${i}.args.${cD}`,`\`${cD}\` 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(z(`command-input-unknown`,`${i}.args.${e}`,`\`${o}\` has no input field \`${e}\` (it takes ${hD(n.all)})`));let e=[...n.required].filter(e=>!(e in r));e.length>0&&s.push(z(`command-input-missing`,`${i}.args`,`\`${o}\` needs ${hD(e)}, which \`args\` does not provide`))}let c=e.itemKey===void 0?t:fD;if(c!==null)for(let t of Object.values(r).flatMap(mD))c.all.has(t)||s.push(z(`command-input-unknown`,`${i}.args`,c===fD?`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 ${hD(c.all)})`));return s}function Yve(e,t,n){let{at:r,command:i}=e,a=`${i.cap}.${i.method}`,o=e.itemKey===void 0?t:fD;if(o===null||n===null)return[];let s=[];for(let t of[...o.all].filter(e=>!n.all.has(e)))s.push(z(`command-input-unknown`,`${r}.args`,`\`${e.method}\` takes \`${t}\`, which \`${a}\` does not (it takes ${hD(n.all)}) — add \`args\` to map it`));let c=[...n.required].filter(e=>!o.all.has(e));return c.length>0&&s.push(z(`command-input-missing`,`${r}.args`,`\`${a}\` needs ${hD(c)}, which \`${e.method}\` does not take — add \`args\` to provide it`)),s}function gD(e,t,n){let r=qve(t,n);if(r.def===null)return r.problems;let i=pD(e,t.method),a=pD(r.def,t.command.method),o=t.command.args;return o===void 0?Yve(t,i,a):Jve(t,i,a,o)}function _D(e,t,n){let r=new Set(dD(e));return Object.keys(t.commands??{}).flatMap(t=>{if(r.has(t))return[];let i=e.composedMethods?.[t]!==void 0;return[z(`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 vD(e,t){return e.features.flatMap((e,n)=>e.kind!==`fields`||!Dc(e)?[]:lD(e,n).flatMap(e=>{let n=Nc(e.command.source),r=t.get(n),i=`${e.at}.source`;return r===void 0||r.kind===`unreadable`?[z(`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`?[z(`source-missing`,i,`source \`${n}\` does not exist`)]:r.caps.has(e.command.cap)?[]:[z(`source-capability-missing`,i,`source \`${n}\` (device ${r.deviceId}) has no \`${e.command.cap}\``)]}))}var yD={fieldPath:`lastFetchedAt`,expr:`now`},bD={fieldPath:`lastChangedAt`,expr:`now`};function xD(e){let{alsoFrom:t,...n}=e;return{...n,family:`numeric`,deviceType:w.Sensor,memberDeviceType:w.Sensor,memberDeviceTypes:[w.Sensor,...t?.deviceTypes??[]],activeWhen:void 0,commandCaps:[],baseUnit:Gi(e.quantity),aggregates:Ls,accept:[{cap:e.outputCap,fieldPath:e.outputField},...t===void 0?[]:[t.accept]]}}var SD=[w.Climate];function CD(e){return{...e,family:`binary`,deviceType:w.Sensor,memberDeviceType:w.Sensor,memberDeviceTypes:[w.Sensor],activeWhen:void 0,commandCaps:[],quantity:`none`,baseUnit:void 0,aggregates:Rs,empty:`offline`}}var wD=[xD({id:`temperature`,summary:`Mean, median, min, max or sum of temperatures. Offline and unknown members are left out, never read as 0 °C.`,role:E.TemperatureSensor,outputCap:`temperature-sensor`,outputField:`temperature`,quantity:`temperature`,defaultAggregate:`mean`,empty:`null`,companions:[yD],alsoFrom:{deviceTypes:SD,accept:{cap:`climate-control`,fieldPath:`currentTemp`}}}),xD({id:`humidity`,summary:`Humidity in percent. Offline and unknown members are left out, never read as 0 %.`,role:E.HumiditySensor,outputCap:`humidity-sensor`,outputField:`humidity`,quantity:`humidity`,defaultAggregate:`mean`,empty:`null`,companions:[yD],alsoFrom:{deviceTypes:SD,accept:{cap:`climate-control`,fieldPath:`currentHumidity`}}}),xD({id:`pressure`,summary:`Pressure in hectopascals. Offline and unknown members are left out, never read as 0 hPa.`,role:E.PressureSensor,outputCap:`pressure-sensor`,outputField:`pressure`,quantity:`pressure`,defaultAggregate:`mean`,empty:`null`,companions:[yD]}),xD({id:`illuminance`,summary:`Illuminance in lux. Offline and unknown members are left out, never read as 0 lx.`,role:E.AmbientLightSensor,outputCap:`ambient-light-sensor`,outputField:`illuminance`,quantity:`illuminance`,defaultAggregate:`mean`,empty:`null`,companions:[yD]}),xD({id:`power`,summary:`Power in watts, summed by default. Nobody reporting omits the key rather than writing 0 W.`,role:E.PowerSensor,outputCap:`power-meter`,outputField:`power`,quantity:`power`,defaultAggregate:`sum`,empty:`omit`,companions:[yD]}),xD({id:`energy`,summary:`Energy in kilowatt-hours, summed by default. Nobody reporting omits the key rather than writing 0 kWh.`,role:E.EnergySensor,outputCap:`power-meter`,outputField:`energy`,quantity:`energy`,defaultAggregate:`sum`,empty:`omit`,companions:[yD]}),xD({id:`battery`,summary:`Battery charge in percent. Offline and unknown members are left out, never read as 0 %.`,role:E.BatterySensor,outputCap:`battery`,outputField:`level`,quantity:`percentage`,defaultAggregate:`mean`,empty:`null`,companions:[{fieldPath:`charging`,expr:`"unknown"`},{fieldPath:`sleeping`,expr:`false`},{fieldPath:`lastUpdated`,expr:`now`}]}),xD({id:`numeric`,summary:`A numeric reading in the members’ shared quantity. Mixed quantities are refused. Nobody reporting publishes null, not 0.`,role:E.NumericSensor,outputCap:`numeric-sensor`,outputField:`value`,quantity:`device`,defaultAggregate:`mean`,empty:`null`,companions:[yD]}),CD({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:E.MotionSensor,outputCap:`motion`,outputField:`detected`,defaultAggregate:`any`,accept:[{cap:`motion`,fieldPath:`detected`}],companions:[{fieldPath:`lastDetectedAt`,expr:`null`},{fieldPath:`autoClearAfterMs`,expr:`null`}]}),CD({id:`contact`,summary:`Any or all open contacts. Offline and unknown members are left out, never read as closed.`,role:E.ContactSensor,outputCap:`contact`,outputField:`entryOpen`,defaultAggregate:`any`,accept:[{cap:`contact`,fieldPath:`entryOpen`}],companions:[bD]}),CD({id:`leak`,summary:`Any or all leak detections. Offline and unknown members are left out, never read as dry.`,role:E.LeakSensor,outputCap:`flood`,outputField:`flooded`,defaultAggregate:`any`,accept:[{cap:`flood`,fieldPath:`flooded`}],companions:[bD]}),CD({id:`smoke`,summary:`Any or all smoke detections. Offline and unknown members are left out, never read as clear.`,role:E.SmokeSensor,outputCap:`smoke`,outputField:`detected`,defaultAggregate:`any`,accept:[{cap:`smoke`,fieldPath:`detected`}],companions:[bD]}),CD({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:E.BinarySensor,outputCap:`binary`,outputField:`on`,defaultAggregate:`any`,accept:[{cap:`motion`,fieldPath:`detected`},{cap:`binary`,fieldPath:`on`}],companions:[bD]}),CD({id:`binary`,summary:`Any or all generic binary sensors. Offline and unknown members are left out, never read as off.`,role:E.BinarySensor,outputCap:`binary`,outputField:`on`,defaultAggregate:`any`,accept:[{cap:`binary`,fieldPath:`on`}],companions:[bD]}),TD({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:w.Switch,outputCap:`switch`,outputField:`on`,member:{cap:`switch`,fieldPath:`on`},commandCaps:[`switch`]}),TD({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:w.Light,outputCap:`switch`,outputField:`on`,member:{cap:`switch`,fieldPath:`on`},commandCaps:[`switch`,`brightness`,`color`]}),TD({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:w.Fan,outputCap:`switch`,outputField:`on`,member:{cap:`switch`,fieldPath:`on`},commandCaps:[`switch`,`fan-control`]}),TD({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:w.Cover,outputCap:`group-active`,outputField:`active`,member:{cap:`cover`,fieldPath:`state`},activeWhen:[`open`,`opening`,`stopped`],commandCaps:[`cover`]}),TD({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:w.Valve,outputCap:`group-active`,outputField:`active`,member:{cap:`valve`,fieldPath:`state`},activeWhen:[`open`,`opening`,`stopped`],commandCaps:[`valve`]}),TD({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:w.Lock,outputCap:`group-active`,outputField:`active`,member:{cap:`lock-control`,fieldPath:`state`},activeWhen:[`locked`],commandCaps:[`lock-control`]}),TD({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:w.MediaPlayer,outputCap:`group-active`,outputField:`active`,member:{cap:`media-player`,fieldPath:`state`},activeWhen:[`playing`,`buffering`],commandCaps:[`media-player`]}),TD({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:w.Climate,memberDeviceTypes:[w.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 TD(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:Rs,defaultAggregate:`any`,empty:`offline`,accept:[e.member],companions:[bD]}}var Xve=new Map(wD.map(e=>[e.id,e]));function ED(e){return Xve.get(e)??null}var DD={"air-quality-sensor":{co2:{kind:`gauge`,unit:`ppm`,deadband:5},voc:{kind:`gauge`,unit:`ppb`,deadband:5},pm25:{group:`particulates`,kind:`gauge`,unit:`µg/m³`,deadband:1},pm10:{group:`particulates`,kind:`gauge`,unit:`µg/m³`,deadband:1},aqi:{kind:`gauge`,unit:`count`,deadband:1}},"alarm-panel":{state:{kind:`enum`,values:[`disarmed`,`armed_home`,`armed_away`,`armed_night`,`armed_vacation`,`armed_custom_bypass`,`arming`,`disarming`,`pending`,`triggered`]}},"ambient-light-sensor":{illuminance:{kind:`gauge`,unit:`lx`,deadbandPct:10,minIntervalMs:6e4}},battery:{level:{kind:`gauge`,unit:`%`},voltage:{kind:`gauge`,unit:`V`}},binary:{on:{kind:`boolean`}},brightness:{level:{kind:`gauge`,unit:`%`,minIntervalMs:0}},"carbon-monoxide":{detected:{kind:`boolean`}},"climate-control":{currentTemp:{group:`temperature`,kind:`gauge`,unit:`°C`,deadband:.1},currentHumidity:{kind:`gauge`,unit:`%`,deadband:.5},target:{group:`temperature`,kind:`gauge`,unit:`°C`,minIntervalMs:0},targetHigh:{group:`target-range`,kind:`gauge`,unit:`°C`,minIntervalMs:0},targetLow:{group:`target-range`,kind:`gauge`,unit:`°C`,minIntervalMs:0}},connectivity:{connected:{kind:`boolean`}},contact:{entryOpen:{kind:`boolean`}},cover:{position:{kind:`gauge`,unit:`%`,minIntervalMs:0}},"device-status":{online:{kind:`boolean`}},dishwasher:{progress:{kind:`gauge`,unit:`%`,deadband:2},state:{kind:`enum`,values:[`idle`,`running`,`paused`,`finished`,`error`,`unavailable`]},operationState:{kind:`enum`,values:[`Inactive`,`Ready`,`DelayedStart`,`Run`,`Pause`,`ActionRequired`,`Finished`,`Error`,`Aborting`]},remaining:{kind:`gauge`,unit:`s`,minIntervalMs:6e4},doorOpen:{kind:`boolean`},powerOn:{kind:`boolean`}},"do-not-disturb":{enabled:{kind:`boolean`}},"energy-system":{"solar.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Solar power`},"solar.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`Solar energy`},"grid.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Grid power`},"grid.importKwh":{kind:`counter`,unit:`kWh`,displayName:`Grid import`},"grid.exportKwh":{kind:`counter`,unit:`kWh`,displayName:`Grid export`},"house.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`House power`},"house.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`House energy`},"heatPump.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Heat pump power`},"heatPump.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`Heat pump energy`},"storage.stateOfChargePct":{kind:`gauge`,unit:`%`,deadband:1,displayName:`Storage charge`},"storage.storedKwh":{kind:`gauge`,unit:`kWh`,deadband:.05,displayName:`Stored energy`},"storage.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Storage power`},"storage.chargedKwh":{kind:`counter`,unit:`kWh`,displayName:`Storage charged`},"storage.dischargedKwh":{kind:`counter`,unit:`kWh`,displayName:`Storage discharged`},"storage.healthPct":{kind:`gauge`,unit:`%`,deadband:1,displayName:`Storage health`}},"enum-sensor":{value:{kind:`enum`,skipWhenSet:`timestamp`}},"fan-control":{speed:{kind:`gauge`,unit:`%`,minIntervalMs:0},oscillating:{kind:`boolean`}},flood:{flooded:{kind:`boolean`}},gas:{detected:{kind:`boolean`}},"heat-pump-status":{"power.thermalW":{group:`power`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Thermal power`},"power.electricalW":{group:`power`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Electrical power`},"power.compressorPct":{kind:`gauge`,unit:`%`,deadband:2,displayName:`Compressor`},"temperatures.supply":{group:`loop`,kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Supply`},"temperatures.return":{group:`loop`,kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Return`},"temperatures.outdoor":{kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Outdoor`},"energy.thermalKwh":{kind:`counter`,unit:`kWh`,displayName:`Thermal energy`},"energy.electricalKwh":{kind:`counter`,unit:`kWh`,displayName:`Electrical energy`}},"heating-valve":{position:{kind:`gauge`,unit:`%`,deadband:1}},humidifier:{currentHumidity:{kind:`gauge`,unit:`%`,deadband:.5},on:{kind:`boolean`}},"humidity-sensor":{humidity:{kind:`gauge`,unit:`%`,deadband:.5}},"lawn-mower-control":{batteryLevel:{kind:`gauge`,unit:`%`,deadband:2}},"lock-control":{state:{kind:`enum`,values:[`locked`,`unlocked`,`locking`,`unlocking`,`jammed`,`door-open`]}},"media-player":{volumeLevel:{kind:`gauge`,unit:`%`,deadband:1},isMuted:{kind:`boolean`}},meter:{value:{kind:`counter`,deadband:.001,minIntervalMs:6e4}},motion:{detected:{kind:`boolean`,excludeDeviceTypes:[w.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}}},Zve={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`}}}},OD={"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}},Qve=`audio-metrics.automation-control.camera-streams.color.control.day-night.doorbell.error.event-emitter.feature-probe.group-active.group-commands.group-status.image.image-settings.intercom.ir-transmitter.motion-trigger.motion-zones.native-object-detection.navigation.notifier.power-source.presence.privacy-mask.ptz-autotrack.pump-cycle.recording-onboard.recording-signal.scene-monitor.script-runner.stream-catalog.stream-signals.timed-run.update.zone-analytics.zone-rules.zones`.split(`.`);function kD(e){return DD[e]??{}}function $ve(e,t,n){return AD(e.deviceTypes,t,n)}function AD(e,t,n){return e.length===0||e.some(e=>e===t)?!0:oo(t,n)&&e.includes(w.Light)}function eye(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 jD(e){return{fieldChoice:`operator`,purpose:`historised`,multiple:!1,max:1,deviceTypes:[],accept:MD(e),history:{required:!0,minRetentionMs:null},mustBindCaps:[],exclude:[]}}function MD(e){let t=[];for(let n of Object.keys(DD))for(let[r,i]of Object.entries(kD(n)))i.kind!==`enum`&&(e===`integral`&&i.kind!==`gauge`||t.push({cap:n,fieldPath:r,valueKind:i.kind===`boolean`?`boolean`:`number`}));return t}function tye(e){if(e===`derivative`)return{...jD(`statistic`),accept:ND()};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:ND(),history:{required:!1,minRetentionMs:null},mustBindCaps:[],exclude:[]}}function ND(){return MD(`statistic`).filter(e=>e.valueKind===`number`)}var PD=[`switch`,`brightness`,`color`],nye=[T.LightColorRgb,T.LightColorHsv,T.LightColorMired],rye=4;function FD(e){return e===`all`?`all`:`any`}function iye(e){return e===`all`?`all`:`at-least-one`}function aye(e){return e.length===0?[]:PD.filter(t=>e.every(e=>e.includes(t)))}function oye(e){return e.length===0?[]:nye.filter(t=>e.every(e=>e.includes(t)))}function sye(e,t,n,r){return e.flatMap(e=>e.caps.includes(t)?[{deviceId:e.deviceId,cap:t,method:n,args:{...r}}]:[])}async function cye(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 lye={kind:`expression`,expr:`now`,bindings:{}};function ID(e,t,n){return{kind:`series`,read:{source:e.source,cap:e.cap,fieldPath:e.fieldPath},publish:t,empty:n}}function uye(e){return{included:ID(e,`included`,`offline`),excluded:ID(e,`excluded`,`offline`),total:ID(e,`total`,`offline`)}}var dye={second:`s`,minute:`min`,hour:`h`};function fye(e){let t=kD(e.source.cap)[e.source.fieldPath]?.unit;return t===void 0?null:`${t}/${dye[e.per]}`}function LD(e){let t=kD(e.cap)[e.fieldPath];return t===void 0?null:t.kind}function RD(e){return LD(e)===null?[z(`member-constraint`,`helper.source`,`${e.cap}.${e.fieldPath} has no history declaration`)]:[]}function zD(e){return{target:{kind:`new`,type:w.Sensor,role:e.role},helper:e.spec,features:[{kind:`fields`,cap:e.cap,fields:{[e.field]:ID(e.member,`value`,e.empty),lastFetchedAt:lye}},{kind:`fields`,cap:`group-status`,fields:uye(e.member)}]}}function BD(e,t=_s){let n=[...RD(e.source)],r=LD(e.source);r===`enum`&&n.push(z(`kind-mismatch`,`helper.source`,`a statistic reads a number or a boolean, not a state`)),e.stat===`sum`&&r!==`counter`&&n.push(z(`kind-mismatch`,`helper.stat`,`a gauge has no sum — that is the integral template`));let i=Ns(e.window,t);return i.ok||n.push(z(`retention`,`helper.window`,i.reason)),{problems:n,draft:zD({role:E.NumericSensor,cap:`numeric-sensor`,field:`value`,empty:`null`,spec:e,member:e.source})}}function VD(e,t=_s){let n=[...RD(e.source)],r=LD(e.source);(r===`enum`||r===`boolean`)&&n.push(z(`kind-mismatch`,`helper.source`,`a derivative reads a number that moves, not a yes/no or a state`));let i=Ns(e.window,t);return i.ok||n.push(z(`retention`,`helper.window`,i.reason)),{problems:n,draft:zD({role:E.NumericSensor,cap:`numeric-sensor`,field:`value`,empty:`null`,spec:e,member:e.source})}}function HD(e,t=_s){let n=[...RD(e.source)],r=LD(e.source),i=e.source.cap===`power-meter`&&e.source.fieldPath===`power`;(r===`counter`||r===`boolean`||r===`enum`)&&n.push(z(`kind-mismatch`,`helper.source`,`an integral reads an instantaneous gauge, not a counter or a state`)),e.output===`energy`&&!i&&n.push(z(`kind-mismatch`,`helper.output`,`energy is the integral of power-meter.power; another reading uses the meter`)),e.output===`meter`&&i&&n.push(z(`kind-mismatch`,`helper.output`,`power integrates to power-meter.energy, which energy dashboards already read`));let a=Ps(e.reset,t);a.ok||n.push(z(`retention`,`helper.reset`,a.reason));let o=e.output===`energy`;return{problems:n,draft:zD({role:o?E.EnergySensor:E.NumericSensor,cap:o?`power-meter`:`meter`,field:o?`energy`:`value`,empty:`offline`,spec:e,member:e.source})}}var pye=/^\d+(?:\.\d+)?$/,mye=/^-?\d+(?:\.\d+)?$/,hye=/^dwell\(x (>=|<=) (\d+(?:\.\d+)?), (\d+(?:\.\d+)?), (\d+(?:\.\d+)?)(?:, (\d+))?\)$/,gye=/^clamp\((x|number\(x\)) \* (-?\d+(?:\.\d+)?) \+ (-?\d+(?:\.\d+)?), (-?\d+(?:\.\d+)?), (-?\d+(?:\.\d+)?)\)$/,_ye=/^(x|number\(x\)) \* (-?\d+(?:\.\d+)?) \+ (-?\d+(?:\.\d+)?)$/,vye=/^[A-Za-z_][A-Za-z0-9_]*$/;function UD(e){return $D(e,pye)}function WD(e){return $D(e,mye)}function GD(e){return typeof e==`string`?JSON.stringify(e):typeof e==`number`?WD(e):typeof e==`boolean`?e?`true`:`false`:`null`}function KD(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 qD(e){return vye.test(e)}function JD(e,t,n,r,i=1){return`dwell(x ${e===`gte`?`>=`:`<=`} ${t}, ${n}, ${r}${i>1?`, ${i}`:``})`}function YD(e,t,n,r,i){let a=`${e} * ${t} + ${n}`;return r===null||i===null?a:`clamp(${a}, ${r}, ${i})`}function XD(e){let t=hye.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 ZD(e){let t=gye.exec(e);if(t!==null)return eO(t[1],t[2],t[3],t[4],t[5]);let n=_ye.exec(e);return n===null?null:eO(n[1],n[2],n[3],void 0,void 0)}function QD(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 $D(e,t){if(!Number.isFinite(e))return null;let n=Object.is(e,-0)?`0`:String(e);return t.test(n)?n:null}function eO(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 tO={kind:`expression`,expr:`now`,bindings:{}};function nO(e){return{kind:`from`,source:e.source,cap:e.cap,fieldPath:e.fieldPath}}function rO(e,t){return{kind:`expression`,expr:e,bindings:t}}function yye(e,t){return e.source.addonId===t.source.addonId&&e.source.stableId===t.source.stableId&&e.cap===t.cap&&e.fieldPath===t.fieldPath}function iO(e,t,n=[]){return{target:{kind:`new`,type:w.Sensor,role:E.NumericSensor},helper:e,features:[{kind:`fields`,cap:`numeric-sensor`,fields:{value:t,lastFetchedAt:tO}},...n]}}function aO(e,t){return{target:{kind:`new`,type:w.Sensor,role:E.BinarySensor},helper:e,features:[{kind:`fields`,cap:`binary`,fields:{on:t,lastChangedAt:tO}}]}}function oO(e){let t=[],n=WD(e.high),r=WD(e.low);n===null&&t.push(z(`kind-mismatch`,`helper.high`,`the high edge is a finite number`)),r===null&&t.push(z(`kind-mismatch`,`helper.low`,`the low edge is a finite number`)),n!==null&&r!==null&&e.low>e.high&&t.push(z(`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=UD(e.onForMs),a=UD(e.offForMs);(i===null||a===null)&&t.push(z(`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:aO(e,rO(`coalesce(schmitt(x, ${n??`0`}, ${r??`0`}${o}), false)`,{x:nO(e.source)}))}}var bye=[`a`,`b`];function xye(e){let t=[],n=e.op!==`sum`;return n&&e.inputs.length!==2&&t.push(z(`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(z(`member-constraint`,`helper.inputs`,`a sum takes two or more readings`)),e.inputs.forEach((n,r)=>{e.inputs.slice(0,r).some(e=>yye(e,n))&&t.push(z(`member-constraint`,`helper.inputs[${r}]`,`this reading is already an input`))}),t}var Sye=[`included`,`excluded`,`total`];function sO(e){let t=xye(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(Sye.map(e=>[e,r(e)]));return{problems:t,draft:iO(e,r(`value`),[{kind:`fields`,cap:`group-status`,fields:i}])}}let n=Object.fromEntries(e.inputs.slice(0,2).map((e,t)=>[bye[t]??`a`,nO(e)]));return{problems:t,draft:iO(e,rO(e.op===`difference`?`a - b`:`b == 0 ? null : a / b`,n))}}function Cye(e){let t=[],n=new Set;if(e.inputs.forEach((e,r)=>{let i=`helper.inputs[${r}].name`;qD(e.name)||t.push(z(`expression-invalid`,i,`\`${e.name}\` is not a name — use letters, digits and _, starting with a letter`)),n.has(e.name)&&t.push(z(`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,nO(e.member)])),i=Xo({expr:e.expr,bindings:r});return i===null?[]:[z(`expression-invalid`,`helper.expr`,i)]}function cO(e){let t=Cye(e),n=Object.fromEntries(e.inputs.map(e=>[e.name,nO(e.member)])),r=rO(e.expr,n);return{problems:t,draft:e.output===`boolean`?aO(e,r):iO(e,r)}}function wye(e,t){return e.addonId===t.addonId&&e.stableId===t.stableId}function Tye(e,t){return wye(e.source,t.source)&&e.cap===t.cap&&e.fieldPath===t.fieldPath}function Eye(e,t){return e.accept.some(e=>e.cap===t.cap&&e.fieldPath===t.fieldPath)}function Dye(e,t){return t.members.flatMap((n,r)=>{let i=`helper.members[${r}]`,a=[];if(!Eye(e,n)){let t=e.accept.map(e=>`${e.cap}.${e.fieldPath}`).join(` or `);a.push(z(`member-constraint`,i,`a ${e.id} group reads ${t}; this member is ${n.cap}.${n.fieldPath}`))}return t.members.slice(0,r).some(e=>Tye(e,n))&&a.push(z(`member-constraint`,i,`this member is already in the group`)),a})}function lO(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 Oye(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,Aye(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]:lO(e,t,n,`value`),...r}},{kind:`fields`,cap:`group-status`,fields:{included:lO(e,t,n,`included`),excluded:lO(e,t,n,`excluded`),total:lO(e,t,n,`total`)}}]}}function kye(e,t){if(e.family===`actuator`){if(t.active===void 0)return[z(`kind-mismatch`,`helper.active`,`a ${e.id} group needs an active criterion (at-least-one or all)`)];let n=FD(t.active);return t.aggregate===n?[]:[z(`kind-mismatch`,`helper.aggregate`,`active \`${t.active}\` aggregates by \`${n}\`, not \`${t.aggregate}\``)]}return t.active===void 0?[]:[z(`kind-mismatch`,`helper.active`,`a ${e.id} group has no active criterion — that belongs to an actuator group`)]}function uO(e){let t=Mc.safeParse(e);return t.success?{ok:!0,composition:t.data}:{ok:!1,problems:[z(`helper-mismatch`,`helper`,`the template did not compile: ${t.error.issues.map(e=>e.message).join(`; `)}`)]}}function Aye(e,t={}){return{kind:`expression`,expr:e,bindings:t}}function dO(e,t=_s){switch(e.kind){case`group`:return jye(e);case`statistic`:{let n=BD(e,t);return n.problems.length>0?{ok:!1,problems:n.problems}:uO(n.draft)}case`integral`:{let n=HD(e,t);return n.problems.length>0?{ok:!1,problems:n.problems}:uO(n.draft)}case`derivative`:{let n=VD(e,t);return n.problems.length>0?{ok:!1,problems:n.problems}:uO(n.draft)}case`threshold`:return fO(oO(e));case`arithmetic`:return fO(sO(e));case`expression`:return fO(cO(e))}}function fO(e){return e.problems.length>0?{ok:!1,problems:e.problems}:uO(e.draft)}function jye(e){let t=ED(e.templateId);if(t===null)return{ok:!1,problems:[z(`member-constraint`,`helper.templateId`,`unknown template \`${e.templateId}\``)]};let n=kye(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:[z(`kind-mismatch`,`helper.aggregate`,`a ${t.id} group aggregates by ${n}, not \`${e.aggregate}\``)]}}let r=Dye(t,e);return r.length>0?{ok:!1,problems:r}:uO(Oye(t,e))}function pO(e,t){return JSON.stringify(e.target)===JSON.stringify(t.target)&&JSON.stringify(e.features)===JSON.stringify(t.features)}function Mye(e){return e.kind===`group`?ED(e.templateId)?.memberDeviceType??null:null}function Nye(e,t){if(e.kind!==`group`)return[];let n=ED(e.templateId);if(n===null||n.family!==`numeric`)return[];let r=e.members.flatMap((e,n)=>{let r=t.get(Nc(e.source))?.quantity;return r===void 0?[]:[{index:n,quantity:r}]});if(n.quantity!==`device`)return r.flatMap(e=>e.quantity===n.quantity?[]:[z(`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?[]:[z(`mixed-quantity`,`helper.members`,`a numeric group requires one quantity; members report ${i.join(` and `)}`)]}function Pye(e,t){if(e.kind!==`group`)return[];let n=ED(e.templateId);return n===null?[]:e.members.flatMap((e,r)=>{let i=t.get(Nc(e.source)),a=i?.deviceType;return a===void 0||AD(n.memberDeviceTypes,a,i?.role)?[]:[z(`member-constraint`,`helper.members[${r}]`,`a ${n.id} group takes ${n.memberDeviceTypes.join(` or `)} devices; this member is a ${a}`)]})}function mO(e,t){let n=e.helper;if(n===void 0)return[];let r=dO(n);return r.ok?pO(e,r.composition)?n.kind===`arithmetic`?Fye(n,t):n.kind===`group`?[...Nye(n,t),...Pye(n,t)]:[]:[z(`helper-mismatch`,`helper`,`the stored features are not this template — the helper spec is the only writer`)]:r.problems}function Fye(e,t){let n=e.inputs.flatMap(e=>{let n=t.get(Nc(e.source))?.quantity;return n===void 0?[]:[n]}),r=[...new Set(n)];return r.length<=1?[]:[z(`mixed-quantity`,`helper.inputs`,`a ${e.op} needs readings of one quantity; these inputs report ${r.join(` and `)}`)]}var hO=class extends Error{};function Iye(e){return new Set(e.composition.features.flatMap(e=>!Dc(e)||e.kind!==`fields`?[]:Bc(e).map(({fieldPath:t})=>`${e.cap}.${t}`)))}function Lye(e,t,n){if(Nc(n.source)!==Nc(e.target))return!0;let r=`${n.cap}.${n.fieldPath}`;return t.has(r)&&e.replaced?.has(r)!==!0}function Rye(e){let t=Iye(e);return e.composition.features.flatMap(n=>!Dc(n)||n.kind!==`fields`?[]:Bc(n).map(({fieldPath:r,source:i})=>[Fc({source:e.target,cap:n.cap,fieldPath:r}),Rc(i).filter(n=>Lye(e,t,n)).map(Fc)]))}function zye(e,t){let n=Nc(e.target),r=new Map;for(let i of t){if(i.blockId===e.blockId)continue;let t=Nc(i.target);if(t===n)throw new hO(`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 hO(`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 gO(e,t){let n=zye(e,t).flatMap(Rye);return new Map(n)}function Bye(e,t){let n=gO(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 Vye(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 Hye(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 _O(e,t){let n=gO(e,t),r=`${Nc(e.target)}#`;return Vye(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:Hye(t,i,n),component:i}]})}var Uye=3,Wye=120,Gye=10,vO=x([`no-power-source`,`switch-missing`,`switch-offline`,`switch-unknown`,`restart-in-progress`,`switch-call-failed`,`switch-is-actuator`]),yO=i(`accepted`,[b({accepted:o(!0)}),b({accepted:o(!1),reason:vO,message:p()})]),bO=b({linked:v(),switchDeviceId:f().nullable(),switchName:p().nullable(),switchOn:v().nullable(),switchOnline:v().nullable(),restartInProgress:v(),offSeconds:f().int()}),xO=b({switchOn:v().nullable(),offSeconds:f().int(),lastFetchedAt:f()}),SO=[w.Gateway,w.Camera,w.Sensor,w.MediaPlayer,w.Vacuum,w.Generic,w.Washer,w.Dryer,w.Dishwasher,w.PetFountain,w.Fan,w.Humidifier,w.Climate,w.WaterHeater],Kye={version:1,targets:[{id:`switch`,cardinality:`scalar`,vocabulary:{cap:`power-source`,stateField:`switchOn`},deviceTypes:SO,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`}}]},CO=b({deviceId:f().int().nonnegative()}),wO={name:`power-source`,scope:`device`,mode:`singleton`,deviceTypes:SO,methods:{getStatus:Lr(CO,bO,{auth:`protected`}),powerOn:Lr(CO,yO,{kind:`mutation`,auth:`protected`,actions:[{id:`powerSource.on`,label:N(`Power on`,`Dai corrente`),phrase:N(`Power on {device}`,`Dai corrente a {device}`),icon:`power`}]}),powerOff:Lr(CO,yO,{kind:`mutation`,auth:`protected`,actions:[{id:`powerSource.off`,label:N(`Power off`,`Togli corrente`),phrase:N(`Cut the power of {device}`,`Togli la corrente a {device}`),icon:`power-off`}]}),forceRestart:Lr(CO,yO,{kind:`mutation`,auth:`protected`,actions:[{id:`powerSource.forceRestart`,label:N(`Force restart`,`Riavvio forzato`),phrase:N(`Force restart {device} by cutting its power`,`Riavvia {device} togliendo la corrente`),icon:`refresh-cw`}]})},runtimeState:xO,customize:Kye,durability:`session`,history:`none`,vocabulary:{noun:N(`Power source`,`Alimentazione`),order:1050,state:[{kind:`boolean`,field:`switchOn`,label:N(`Power switch on`,`Presa accesa`),whenTrue:N(`When the power of {device} comes on`,`Quando arriva la corrente a {device}`),whenFalse:N(`When the power of {device} is cut`,`Quando manca la corrente a {device}`),icon:`power`}]}};function TO(e){return typeof e!=`number`||!Number.isFinite(e)?10:Math.min(120,Math.max(3,Math.round(e)))}function qye(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 Jye(e,t){if(e===null)return null;let n;if(e.target.kind===`existing`)n=e.target.device;else if(t!==void 0)n=Lc(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=Rc(i).find(e=>e.cap===`switch`);return a===void 0?null:{device:n,switch:a.source,offSeconds:TO(qye(e))}}var EO=`switch`;function Yye(e){let t=new Set;return e.target.kind===`existing`&&t.add(Nc(e.target.device)),e.features.forEach((e,n)=>{if(!(e.kind!==`fields`||e.cap!==EO)&&Dc(e)){for(let n of Vc(e))for(let e of Rc(n))t.add(Nc(e.source));for(let r of lD(e,n))t.add(Nc(r.command.source))}}),t}function DO(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=Yye(e);return Rc(r).filter(e=>e.cap===EO&&i.has(Nc(e.source))).map(e=>({path:`features[${t}].fields.switchOn`,switch:e.source}))}function OO(e){let t=new Map(e.map(e=>[e.name,e]));return e=>t.get(e)??null}var kO=new Set([`device-status`,`feature-probe`]),Xye={addonId:rc,stableId:`${Ce}(unsaved)`},Zye=`(unsaved)`;function Qye(e,t,n){let r=n(e.cap);if(r===null)return z(`unknown-capability`,`${t}.cap`,`no capability is named \`${e.cap}\``);if(kO.has(r.name))return z(`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?z(`not-composable`,`${t}.cap`,`\`${r.name}\` has no per-device state to compose`):{def:r,state:i,fields:$w(i)}}function $ye(e){let t=e.helper;if(t===void 0||t.kind!==`group`)return new Set;let n=ED(t.templateId);return n===null||n.family!==`actuator`?new Set:new Set(n.commandCaps)}function ebe(e,t){return e.name===FE.name&&Object.values(t.commands??{}).some(e=>e.kind===`extension`)}function tbe({def:e,state:t,fields:n},r,i,a,o){let s=[];e.deviceTypes!==void 0&&!e.deviceTypes.includes(a)&&s.push(z(`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=dD(e).filter(e=>!c.has(e)).map(e=>`\`${e}\``);l.length>0&&!o.has(e.name)&&s.push(z(`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=ebe(e,r);for(let a of d?[]:eT(t))a!==u&&(n.has(a)?a in r.fields||s.push(z(`missing-field`,`${i}.fields.${a}`,`\`${e.name}.${a}\` is required and has no source`)):s.push(z(`not-composable`,`${i}.fields`,`\`${e.name}.${a}\` is not a scalar — nested fields arrive in a later slice`)));return s}function nbe({fields:e,state:t},n,r){return n.includes(`.`)?r===`replace`?Qw(t,n)??void 0:`nested`:e.get(n)}function rbe(e,t,n,r){let{def:i}=e,{featureIndex:a,path:o,source:s}=t,c=`features[${a}].fields.${o}`,l=nbe(e,o,n);if(l===`nested`)return RE(z(`nested-field`,c,`\`${o}\` is nested — a nested field is planned only on a declared replace (D1034)`));if(l===void 0)return RE(z(`unknown-field`,c,`\`${i.name}\` has no field \`${o}\``));if(l.kind===`union`)return RE(QE(i.name,o,c));let u=tD(s,r);if(!u.ok)return RE(z(u.code,c,u.message));let d=iD(s),f=aD(l,d,n,i.name,c);if(!f.ok)return RE(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:[...Rc(s)]},h=rD(i.name,l,s,c);return{problems:[...nD(i.name,l,eD(s,l,u.kinds,r),c),...h===null?[]:[h]],fields:[m],features:[],events:[]}}function ibe(e,t,n,r,i){let a=`features[${n}]`,o=lD(t,n),s=Object.entries(t.commands??{}).filter(([,e])=>e.kind===`code`).map(([e])=>z(`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!==FE.name?[...s,...c.map(([t])=>z(`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,z(`reserved-variant`,`${a}.commands`,"commands (`forward`) are served only by a capability a NEW device builds — not on an existing device")]:[...s,..._D(e,t,a),...o.flatMap(t=>gD(e,t,i))]}function AO(e,t,n,r,i){let a=`features[${t}]`,o=Qye(e,a,r);if(`code`in o)return RE(o);let s=n.mode===`replace`?[]:[...tbe(o,e,a,n.deviceType,i)];s.push(...ibe(o.def,e,t,n.mode,r));let c=Object.entries(e.fields).map(([e,i])=>rbe(o,{featureIndex:t,path:e,source:i},n.mode,r)),l=e.items===void 0?[]:[sD(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=aT(o.def,f,d);return{problems:[...s,...u.flatMap(e=>e.problems),...p.problems],fields:d,features:[f],events:p.events}}function jO(e,t){let n=e.nativeCaps.get(t);return n!==void 0&&n!==`composer`}function abe(e){return`code`in e}function obe(e,t){if(e.target.kind===`new`)return{kind:`new`,type:e.target.type};let n=Nc(e.target.device);return t===void 0?z(`target-unreadable`,`target`,`target device \`${n}\` was not read — the save is refused rather than stored unchecked`):t.kind===`absent`?z(`target-missing`,`target`,`target device \`${n}\` does not exist`):t.kind===`unreadable`?z(`target-unreadable`,`target`,`could not read target device \`${n}\` (${t.error}) — the save is refused rather than stored unchecked`):{kind:`existing`,found:t}}var sbe=new Set([`not-composable`,`unknown-capability`,`reserved-variant`]);function cbe(e,t){let n=t.problems.filter(e=>sbe.has(e.code));return n.length>0?{problems:n,fields:[],features:[],events:[]}:RE(e)}var lbe=IE;function ube(e){let t=lbe[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 dbe(e,t,n){let r=t.cap;return e.kind===`new`?{mode:`new`,deviceType:e.type}:jO(e.found,r)?ube(t)?{mode:`replace`,deviceType:e.found.type}:z(`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 MO(e,t,n){let r=obe(e,n);if(`code`in r)return RE(r);let i=$ye(e),a=e.features.map((e,n)=>{let a=`features[${n}]`;if(e.kind===`passthrough`)return RE(z(`reserved-variant`,a,`whole-capability passthrough of \`${e.cap}\` arrives in slice 3`));let o=dbe(r,e,a);if(abe(o))return!Dc(e)||r.kind!==`existing`?{problems:[],fields:[],features:[],events:[]}:cbe(o,AO(e,n,{mode:`add`,deviceType:r.found.type},t,i));let s=AO(e,n,o,t,i);return Dc(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 fbe(e){let t=e.features.flatMap(e=>Dc(e)&&e.kind===`fields`?Vc(e).flatMap(Rc).map(e=>e.source):[]);return[...new Map([...t,...uD(e)].map(e=>[Nc(e),e])).values()]}function pbe(e,t){return e.features.flatMap(e=>Dc(e)&&e.kind===`fields`?Vc(e).flatMap(e=>{if(e.kind!==`from`)return[];let n=t(e.cap),r=n?.runtimeState??n?.status?.schema;return r===void 0?[]:Qw(r,e.fieldPath)?.kind===`union`?[e]:[]}):[])}function mbe(e,t,n){return{ref:e.target.kind===`existing`?e.target.device:t.self??Xye,native:e.target.kind===`existing`&&t.target?.kind===`found`?t.target:null,replaced:NO(n)}}function NO(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(pT))}function hbe(e,t,n,r){let i=`${e.cap}.${e.fieldPath}`;return n.some(e=>pT(e)===i&&!r.replaced.has(i))?[]:r.native===null?[z(`source-field-unknown`,t,`this device has no composed field \`${e.cap}.${e.fieldPath}\``)]:jO(r.native,e.cap)?[]:[z(`source-capability-missing`,t,`the target device (device ${r.native.deviceId}) has no native \`${e.cap}\``)]}function gbe(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?[]:[z(`source-kind-mismatch`,r,`\`${t.cap}.${t.fieldPath}\` of device ${n.deviceId} reads a ${i} now; \`${e.cap}.${e.path}\` takes a ${a}`)]}function _be(e,t,n){let r=Nc(n.ref);return e.flatMap(i=>i.reads.flatMap(a=>{let o=zE(i),s=Nc(a.source);if(s===r)return hbe(a,o,e,n);let c=t.sources.get(s);return c===void 0||c.kind===`unreadable`?[z(`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`?[z(`source-missing`,o,`source \`${s}\` does not exist`)]:c.caps.has(a.cap)?gbe(i,a,c,o):[z(`source-capability-missing`,o,`source \`${s}\` (device ${c.deviceId}) has no \`${a.cap}\``)]}))}function vbe(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 ybe(e,t,n){for(let r of e){let e=vbe(r,t);if(e===null)continue;let i=`${e.cap}.${e.fieldPath}`,a=n.find(e=>pT(e)===i);if(a!==void 0)return zE(a)}return`features`}function bbe(e,t){for(let[n,r]of t)if(e.some(e=>e.startsWith(`${n}#`)))return{key:n,error:r};return null}function xbe(e,t,n,r){let i={blockId:t.blockId??`(unsaved)`,target:r.ref,composition:e,replaced:r.replaced},a=Nc(i.target),o=t.unreadTargets??new Map;try{return _O(i,t.peers).map(e=>{let t=ybe(e.path,a,n),r=bbe([...e.component],o);return r===null?z(`cycle`,t,`a field reads itself: ${e.path.join(` → `)}`):z(`cycle`,t,`possible cycle through \`${r.key}\` — its state could not be read (${r.error}): ${e.path.join(` → `)}`)})}catch(e){if(e instanceof hO)return[z(`duplicate-target`,`features`,e.message)];throw e}}function PO(e,t){let n=MO(e,t.lookupCap,t.target??void 0),r=mbe(e,t,n),i=n.problems.filter(e=>e.code===`native-capability-replace`).map(e=>e.path),a=xbe(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,..._be(n.fields,t,r),...vD(e,t.sources),...a,...mO(e,o),...DO(e).map(e=>z(`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 FO=b({path:p(),kind:cT,nullable:v(),required:v(),enumValues:S(p()).optional()}),IO=b({cap:p(),fields:S(FO),itemArray:b({path:p(),keyField:p()}).optional()}),LO=b({caps:S(IO)});function RO(e,t){if(kO.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=$w(n),a=e.status?.itemArray?.path??null;return eT(n).some(e=>e!==a&&!i.has(e))&&r.push(`not-composable`),aT(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 Sbe(e,t){return e.filter(e=>RO(e,t).length===0).map(e=>{let t=e.runtimeState,n=t===void 0?[]:[...$w(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 zO=b({addonId:p().min(1),stableId:p().min(1),cap:p().min(1),fieldPath:p().min(1)}),Cbe=b({kind:o(`identity`)}),wbe=b({kind:o(`invert`)}),BO=b({kind:o(`threshold`),comparison:x([`gte`,`lte`]),threshold:f(),startDwellMs:f().nonnegative(),stopDwellMs:f().nonnegative(),minSamples:f().int().min(1).optional()}),VO=i(`kind`,[Cbe,wbe,BO,b({kind:o(`linear`),scale:f(),offset:f(),clampMin:f().optional(),clampMax:f().optional()}),b({kind:o(`enum-map`),mapping:u(p(),p().nullable())}),b({kind:o(`number`)})]),Tbe=b({kind:o(`scalar`),cap:p().min(1),targetId:p().min(1),source:zO,transform:VO}),Ebe=b({kind:o(`keyedArray`),cap:p().min(1),targetId:p().min(1),key:p().min(1),label:p().min(1),fieldPath:p().min(1),source:zO,transform:VO}),Dbe=b({kind:o(`pulse`),cap:p().min(1),targetId:p().min(1),enabled:v(),debounceMs:f().nonnegative(),edges:S(x([`rising`,`button`,`native-event`])).min(1).optional(),sources:S(zO).min(1)}),Obe=zO.extend({mode:x([`in-addition`,`confirm`,`replace`]).optional()}),kbe=i(`kind`,[Tbe,Ebe,Dbe,b({kind:o(`span`),cap:p().min(1),targetId:p().min(1),timeoutMs:f().nonnegative(),cooldownMs:f().nonnegative().optional(),sources:S(Obe)})]),Abe=b({targetId:p().min(1),configured:v(),source:x([`native`,`assigned`]),state:x([`active`,`stale`,`released`,`unavailable`]),reason:p().nullable()}),HO=x([`raw`,`5m`]),UO=x([`high`,`medium`,`low`]),WO=x([`no-history`,`span-too-short`,`truncated`,`no-idle-floor`,`no-runs`,`no-separation`]),GO=b({intervals:f().int().nonnegative(),extra:f().int().nonnegative(),missed:f().int().nonnegative()}),KO=b({tier:HO,spanMs:f().nonnegative(),from:f(),to:f(),points:f().int().nonnegative(),runsFound:f().int().nonnegative(),pausesFound:f().int().nonnegative(),longestPauseMs:f().nonnegative(),pulsesFound:f().int().nonnegative(),longestPulseMs:f().nonnegative(),idleFloorW:f(),noiseCeilingW:f(),plateauW:f(),replay:GO}),qO=b({spanMs:f().nonnegative(),points:f().int().nonnegative(),runsFound:f().int().nonnegative()}),JO=i(`state`,[b({state:o(`proposal`),transform:BO,evidence:KO,confidence:UO,notes:S(p())}),b({state:o(`insufficient`),reason:WO,evidence:qO,fallback:BO})]),YO=b({apply:v()}),XO=b({apply:v(),rows:f().int(),raw:f().int(),markers:f().int(),migrated:f().int(),failed:f().int(),remainingRaw:f().int(),unresolvedMarkers:f().int(),redundantCopies:f().int().optional(),verified:v()}),ZO=`core-block-`,QO=`core-blocks`;function jbe(e){return`${ZO}${e}`}function Mbe(e){if(!e.startsWith(`core-block-`))return null;let t=e.slice(11);return t.length>0?t:null}var $O=c([o(`hub`),p().min(1)]),ek=x([`stopped`,`starting`,`running`,`degraded`,`incomplete`,`failed`]),tk=`main.ts`,nk=u(p().min(1).max(260),p().max(2e5)),rk=ge(),ik=b({name:p().min(1).max(120),code:p().max(2e5).optional(),files:nk.optional(),entry:p().min(1).max(260).optional(),enabled:v(),placement:$O,integrationId:p().optional(),settingsSchema:rk.optional(),tags:oh.optional()}),ak=ik.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 ok(e){return e!==void 0&&e.length>0?e:tk}function Nbe(e){let t=ok(e.entry);return e.files===void 0?{files:{[t]:e.code},entry:t}:{files:{...e.files},entry:t}}function Pbe(e){if(e.files!==void 0){let t=ok(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 sk=i(`kind`,[b({kind:o(`code`)}),b({kind:o(`recipe`),recipe:sv}),b({kind:o(`composition`),composition:Mc})]),ck=b({name:p().min(1).max(120).optional(),enabled:v(),composition:Mc}),lk=b({name:p().min(1).max(120),code:p().max(2e5),files:nk.optional(),entry:p().min(1).max(260).optional(),enabled:v(),placement:$O,integrationId:p().optional(),settingsSchema:rk.optional(),tags:oh.optional(),id:p(),createdAt:f(),updatedAt:f(),createdBy:p(),status:ek,lastError:p().optional(),lastChangedAt:f(),source:sk.optional()});function Fbe(e){return e.source?.kind??`code`}function Ibe(e){return e.source?.kind===`composition`?e.source.composition:null}var uk=i(`kind`,[b({kind:o(`answered`),state:bT.nullable()}),b({kind:o(`unreachable`),error:p()})]),dk=b({block:lk,state:uk}),fk=b({state:o(`not-loaded`),reason:p()}),pk=i(`state`,[b({state:o(`loaded`),views:S(dk)}),fk]),mk=i(`state`,[b({state:o(`loaded`),view:dk.nullable()}),fk]),hk=i(`state`,[b({state:o(`loaded`),view:dk.nullable()}),fk]),gk=b({ok:v(),error:p().optional(),line:f().optional(),column:f().optional()}),_k=b({code:p().optional(),files:nk.optional(),entry:p().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`]})}),vk={name:`core-blocks`,scope:`system`,mode:`singleton`,methods:{list:O(b({}),b({blocks:S(lk)}),{auth:`admin`}),get:O(b({blockId:p()}),b({block:lk.nullable()}),{auth:`admin`}),create:O(b({block:ak}),b({block:lk}),{kind:`mutation`,auth:`admin`,caller:`required`}),update:O(b({blockId:p(),block:ik.partial()}),b({block:lk}),{kind:`mutation`,auth:`admin`,caller:`required`}),delete:O(b({blockId:p()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),setEnabled:O(b({blockId:p(),enabled:v()}),b({block:lk}),{kind:`mutation`,auth:`admin`}),restart:O(b({blockId:p()}),b({block:lk}),{kind:`mutation`,auth:`admin`}),compile:O(_k,gk,{kind:`mutation`,auth:`admin`}),getBlockSettings:O(b({blockId:p()}),bx.nullable(),{auth:`admin`}),updateBlockSettings:O(b({blockId:p(),patch:xx}),Cx,{kind:`mutation`,auth:`admin`}),migrateRawSecrets:O(YO,XO,{kind:`mutation`,auth:`admin`}),getTypeDefs:O(b({}),b({libs:S(b({filePath:p(),content:p()}))}),{auth:`admin`}),createComposition:O(b({block:ck}),b({block:lk}),{kind:`mutation`,auth:`admin`,caller:`required`}),updateComposition:O(b({blockId:p(),expectedUpdatedAt:f(),block:ck.partial()}),b({block:lk}),{kind:`mutation`,auth:`admin`,caller:`required`}),getComposition:O(b({blockId:p()}),mk,{auth:`admin`}),listCompositions:O(b({}),pk,{auth:`admin`}),getCustomization:O(b({addonId:p().min(1),stableId:p().min(1)}),hk,{auth:`admin`}),listComposableCaps:O(b({deviceType:x(w)}),LO,{auth:`admin`}),validateComposition:O(b({composition:Mc,blockId:p().optional()}),gT,{kind:`mutation`,auth:`admin`,access:`view`}),proposeRunningThreshold:O(b({deviceId:f().int(),cap:p().min(1),fieldPath:p().min(1),deviceType:x(w).optional()}),JO,{auth:`admin`,access:`view`}),reportAutomationRun:O(b({blockId:p().min(1),trace:Gv.optional(),runStartedAt:f().optional(),keepTraces:f().int().min(1).max(100).optional()}),_(),{kind:`mutation`,auth:`admin`}),getAutomationRunState:O(b({blockId:p().min(1)}),Kv,{auth:`admin`}),getTraces:O(b({blockId:p().min(1)}),b({traces:S(Gv),lastError:p().nullable()}),{auth:`admin`})},vocabulary:{notOperatorFacing:A.INTERNAL}},yk=x([`open`,`opening`,`closing`,`closed`,`stopped`]),bk=b({state:yk,position:f().min(0).max(100).nullable().meta(j(`percentage`)),tiltPosition:f().min(0).max(100).nullable().meta(j(`percentage`)),lastChangedAt:f()}),xk={name:`cover`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Cover],methods:{open:O(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.open`,label:N(`Open`,`Apri`),phrase:N(`Open {device}`,`Apri {device}`),icon:`arrow-up-to-line`,effect:{field:`state`,value:`open`}}]}),close:O(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.close`,label:N(`Close`,`Chiudi`),phrase:N(`Close {device}`,`Chiudi {device}`),icon:`arrow-down-to-line`,effect:{field:`state`,value:`closed`}}]}),stop:k(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.stop`,label:N(`Stop`,`Ferma`),phrase:N(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),setPosition:k(b({deviceId:f().int().nonnegative(),position:f().min(0).max(100)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.position`,label:N(`Set position`,`Imposta la posizione`),phrase:N(`Move {device} to {position} open`,`Porta {device} al {position} di apertura`),icon:`blinds`,effect:{field:`position`,fromArg:`position`},openArgs:[{key:`position`,label:N(`Position`,`Posizione`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setTiltPosition:k(b({deviceId:f().int().nonnegative(),tiltPosition:f().min(0).max(100)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.tilt`,label:N(`Set tilt`,`Imposta l’inclinazione`),phrase:N(`Tilt {device} to {tiltPosition}`,`Inclina {device} al {tiltPosition}`),icon:`blinds`,effect:{field:`tiltPosition`,fromArg:`tiltPosition`},openArgs:[{key:`tiltPosition`,label:N(`Tilt`,`Inclinazione`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]})},status:{schema:bk,kind:`push`},runtimeState:bk,durability:`restored`,history:{fields:{position:{kind:`gauge`,unit:`%`,minIntervalMs:0}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:N(`Cover`,`Copertura`),order:1030,state:[{kind:`enum`,field:`state`,label:N(`State`,`Stato`),values:[{value:`open`,label:N(`Open`,`Aperto`),phrase:N(`When {device} is fully open`,`Quando {device} è tutto aperto`)},{value:`opening`,label:N(`Opening`,`In apertura`),phrase:N(`When {device} starts opening`,`Quando {device} inizia ad aprirsi`)},{value:`closing`,label:N(`Closing`,`In chiusura`),phrase:N(`When {device} starts closing`,`Quando {device} inizia a chiudersi`)},{value:`closed`,label:N(`Closed`,`Chiuso`),phrase:N(`When {device} is fully closed`,`Quando {device} è tutto chiuso`)},{value:`stopped`,label:N(`Stopped`,`Fermo`),phrase:N(`When {device} stops part-way`,`Quando {device} si ferma a metà`)}],icon:`blinds`},{kind:`numeric`,field:`position`,quantity:N(`the opening`,`l’apertura`),label:N(`Position`,`Posizione`),unit:`%`,icon:`blinds`}],overrides:{byRole:{[E.CoverGarage]:{actions:{"cover.open":{phrase:N(`Open the garage door {device}`,`Apri il garage {device}`),icon:`warehouse`},"cover.close":{phrase:N(`Close the garage door {device}`,`Chiudi il garage {device}`),icon:`warehouse`}}},[E.CoverGate]:{actions:{"cover.open":{phrase:N(`Open the gate {device}`,`Apri il cancello {device}`),icon:`fence`},"cover.close":{phrase:N(`Close the gate {device}`,`Chiudi il cancello {device}`),icon:`fence`}}},[E.CoverDoor]:{actions:{"cover.open":{phrase:N(`Open the door {device}`,`Apri la porta {device}`),icon:`door-open`},"cover.close":{phrase:N(`Close the door {device}`,`Chiudi la porta {device}`),icon:`door-closed`}}},[E.CoverWindow]:{actions:{"cover.open":{phrase:N(`Open the window {device}`,`Apri la finestra {device}`),icon:`app-window`},"cover.close":{phrase:N(`Close the window {device}`,`Chiudi la finestra {device}`),icon:`app-window`}}},[E.CoverShutter]:{actions:{"cover.open":{phrase:N(`Raise the shutter {device}`,`Alza la tapparella {device}`)},"cover.close":{phrase:N(`Lower the shutter {device}`,`Abbassa la tapparella {device}`)}}},[E.CoverAwning]:{actions:{"cover.open":{phrase:N(`Extend the awning {device}`,`Apri la tenda da sole {device}`)},"cover.close":{phrase:N(`Retract the awning {device}`,`Chiudi la tenda da sole {device}`)}}}}}}},Sk=b({stepId:p(),entry:Nh}),Ck=b({path:p().min(1),bytes:f().int().nonnegative(),sha256:p().regex(/^[0-9a-f]{64}$/)}),wk=b({addonId:p(),stepId:p().min(1),entries:S(Nh).min(1).max(4),bundle:b({ticket:ii,bytes:f().int().positive(),sha256:p().regex(/^[0-9a-f]{64}$/)}),files:S(Ck).min(1).max(64),distribute:v()}),Tk=i(`kind`,[b({kind:o(`imported`),modelIds:S(p()).readonly(),distributed:S(b({modelId:p(),nodeId:p(),format:x(ba),ok:v(),error:p().optional()})).readonly()}),b({kind:o(`refused`),reason:x([`transfer-failed`,`checksum-mismatch`,`bundle-mismatch`,`invalid-entry`,`id-taken`]),detail:p()})]),Ek={name:`custom-model-registry`,scope:`system`,mode:`collection`,internal:!0,methods:{listModels:O(_(),S(Sk).readonly(),{auth:`admin`}),importModelBundle:O(wk,Tk,{kind:`mutation`,auth:`admin`,timeoutMs:30*6e4})},vocabulary:{notOperatorFacing:A.ML}},Dk=b({engineId:p(),kind:x([`relational`,`vector`]),displayName:p()}),Ok={name:`data-store-provider`,scope:`system`,mode:`collection`,internal:!0,methods:{getEngineInfo:O(_(),Dk,{auth:`admin`}),get:O(b({namespace:p().optional(),collection:p(),key:p()}),l(),{auth:`admin`}),set:O(b({namespace:p().optional(),collection:p(),key:p(),value:l()}),_(),{kind:`mutation`,auth:`admin`}),query:O(b({namespace:p().optional(),collection:p(),filter:md.optional(),columns:S(p()).readonly().optional()}),S(vd).readonly(),{auth:`admin`}),insert:O(b({namespace:p().optional(),collection:p(),record:b({id:p().optional(),data:u(p(),l())})}),b({id:c([p(),f()])}),{kind:`mutation`,auth:`admin`}),upsert:O(b({namespace:p().optional(),collection:p(),conflict:S(p()).readonly(),record:yd}),b({id:c([p(),f()])}),{kind:`mutation`,auth:`admin`}),upsertMany:O(b({namespace:p().optional(),collection:p(),conflict:S(p()).readonly(),records:S(yd).readonly()}),b({upserted:f().int()}),{kind:`mutation`,auth:`admin`}),insertMany:O(b({namespace:p().optional(),collection:p(),records:S(yd).readonly()}),b({inserted:f().int()}),{kind:`mutation`,auth:`admin`}),transact:O(b({namespace:p().optional(),guard:Sd.optional(),ops:S(xd).readonly()}),b({applied:v(),current:l().optional()}),{kind:`mutation`,auth:`admin`}),update:O(b({namespace:p().optional(),collection:p(),id:p(),data:u(p(),l())}),_(),{kind:`mutation`,auth:`admin`}),delete:O(b({namespace:p().optional(),collection:p(),key:p()}),_(),{kind:`mutation`,auth:`admin`}),deleteWhere:O(b({namespace:p().optional(),collection:p(),filter:hd}),b({deleted:f().int()}),{kind:`mutation`,auth:`admin`}),updateWhere:O(b({namespace:p().optional(),collection:p(),filter:hd,data:u(p(),l())}),b({updated:f().int()}),{kind:`mutation`,auth:`admin`}),count:O(b({namespace:p().optional(),collection:p(),filter:md.optional()}),f(),{auth:`admin`}),aggregate:O(b({namespace:p().optional(),collection:p(),fields:S(gd).readonly(),filter:md.optional()}),_d,{auth:`admin`}),histogram:O(b({namespace:p().optional(),collection:p(),field:p(),bucketSize:f().int().positive(),origin:f().int(),filter:md.optional()}),S(b({bucket:f().int(),count:f().int()})).readonly(),{auth:`admin`}),isEmpty:O(b({namespace:p().optional(),collection:p()}),v(),{auth:`admin`}),declareCollection:O(Td,_(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:A.INTERNAL}},kk=x([`auto`,`day`,`night`,`schedule`]),Ak=b({min:f(),max:f(),step:f()}),jk=b({mode:kk,sensitivity:f().optional().meta(j(`none`)),switchDelaySec:f().optional().meta(j(`duration`)),lastFetchedAt:f()}),Mk=b({modes:S(kk),supportsSensitivity:v(),sensitivity:Ak.optional(),supportsSwitchDelay:v(),switchDelaySec:Ak.optional()}),Nk=b({mode:kk.optional(),sensitivity:f().optional(),switchDelaySec:f().optional()}),Pk={name:`day-night`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Camera],deviceConfig:{ui:{kind:`derived-form`,builderId:`day-night`,tab:`image`}},methods:{getOptions:O(b({deviceId:f()}),Mk),setSettings:O(b({deviceId:f(),settings:Nk}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`dayNight.auto`,label:N(`Day/night auto`,`Giorno/notte automatico`),phrase:N(`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:N(`Day mode`,`Modalità giorno`),phrase:N(`Force {device} into day mode`,`Forza {device} in modalità giorno`),icon:`sun`,args:{settings:{mode:`day`}}},{id:`dayNight.night`,label:N(`Night mode`,`Modalità notte`),phrase:N(`Force {device} into night mode`,`Forza {device} in modalità notte`),icon:`moon`,args:{settings:{mode:`night`}}}]})},status:{schema:jk,kind:`poll`},runtimeState:jk,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:N(`Day/night`,`Giorno/notte`),order:3070,state:[{kind:`enum`,field:`mode`,label:N(`Day/night mode`,`Modalità giorno/notte`),values:[{value:`auto`,label:N(`Automatic`,`Automatica`)},{value:`day`,label:N(`Day`,`Giorno`),phrase:N(`When {device} switches to day mode`,`Quando {device} passa in modalità giorno`)},{value:`night`,label:N(`Night`,`Notte`),phrase:N(`When {device} switches to night mode`,`Quando {device} passa in modalità notte`)},{value:`schedule`,label:N(`Scheduled`,`Programmata`)}],icon:`sun-moon`}]}},Lbe=[{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)`}],Rbe={hwaccel:`auto`,probedBestHwaccel:``},Fk={name:`decoder`,scope:`system`,mode:`singleton`,preferredProvider:`decoder-nodeav`,methods:{getInfo:O(_(),b({id:p(),name:p(),hwaccel:p().optional(),probedBestHwaccel:p().optional()})),reprobeHwaccel:O(_(),b({backend:p()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:A.PIPELINE}},Ik={name:`detection-pipeline`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[w.Camera],exposesDeviceSettings:!0,methods:{},vocabulary:{noun:N(`Detection pipeline`,`Pipeline di rilevamento`),order:3080}},Lk=x([`device`,`integration`]),Rk=b({url:p(),label:p(),target:Lk,host:p()}),zk={name:`device-admin-link`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{getAdminLink:O(b({deviceId:f().int().nonnegative()}),Rk.nullable(),{auth:`admin`})},vocabulary:{noun:N(`Admin link`,`Link di amministrazione`),order:3090}},Bk=x([`online`,`sleeping`,`offline`,`unknown`]),Vk=g(()=>b({childNativeId:p(),name:p(),type:x(w),status:Bk,metadata:b({model:p().optional(),serialNumber:p().optional(),uid:p().optional(),rtspChannel:f().int().nonnegative().optional(),isBattery:v().optional(),isDoorbell:v().optional(),isMultifocal:v().optional(),externalLocation:p().optional(),manufacturer:p().optional(),integration:p().optional()}).default({}),alreadyAdopted:v(),adoptedDeviceId:f().int().nonnegative().nullable(),capabilities:S(p()).readonly().optional(),features:S(p()).readonly().optional(),sourceInfo:Eg.optional(),children:S(Vk).readonly().optional(),parentStableId:p().optional()})),Hk=b({id:p(),label:p(),isDefault:v().optional()}),Uk=b({search:p().optional(),area:p().optional(),manufacturer:p().optional(),adoptedOnly:v().optional(),unadoptedOnly:v().optional()}),Wk=b({integrationId:p(),page:f().int().positive().default(1),pageSize:f().int().positive().max(2e4).default(50),filter:p().optional(),filterText:Uk.optional()}),Gk=b({candidates:S(Vk).readonly(),totalCount:f().int().nonnegative(),page:f().int().positive(),pageSize:f().int().positive()}),Kk=b({integrationId:p(),childNativeId:p()}),qk=b({lastDiscoveryAt:f().int().nonnegative().nullable(),candidateCount:f().int().nonnegative(),adoptedCount:f().int().nonnegative(),lastError:p().nullable()}),zbe=b({name:p().min(1).optional(),hiddenChildIds:S(p()).optional()}),Jk=b({integrationId:p(),childNativeIds:S(p()).min(1),filter:p().optional(),importLocations:v().optional(),perCandidate:u(p(),zbe).optional()}),Yk=b({adopted:S(b({childNativeId:p(),parentDeviceId:f().int().nonnegative(),accessoryDeviceIds:S(f().int().nonnegative()).readonly()})).readonly()}),Xk=b({integrationId:p(),camDeviceId:f().int().nonnegative()}),Zk=b({camDeviceId:f().int().nonnegative(),resetToSource:v().optional()}),Qk=b({changed:v(),rebuiltChildren:f().int().nonnegative(),removedChildren:f().int().nonnegative().optional()}),$k={name:`device-adoption`,scope:`system`,mode:`collection`,status:{schema:qk,kind:`poll`},methods:{listCandidateFilters:O(b({integrationId:p()}),b({filters:S(Hk)}),{auth:`admin`}),listCandidates:O(Wk,Gk,{auth:`admin`}),getCandidate:O(Kk,Vk.nullable(),{auth:`admin`}),refresh:O(b({integrationId:p()}),qk,{kind:`mutation`,auth:`admin`}),adopt:O(Jk,Yk,{kind:`mutation`,auth:`admin`}),release:O(Xk,_(),{kind:`mutation`,auth:`admin`}),resync:O(Zk,Qk,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`device adoption — an onboarding flow, not an action`}},eA=i(`state`,[b({state:o(`absent`)}),b({state:o(`ready`),subject:p(),fingerprintSha256:p(),validTo:p()}),b({state:o(`unavailable`),reason:p()})]),tA=b({selfEnrollment:x([`allowed`,`disabled`])}),nA={name:`device-credentials`,scope:`system`,mode:`singleton`,methods:{listDeviceCredentials:O(b({userId:p().min(1).optional(),includeRevoked:v().default(!1)}),S(mfe).readonly(),{auth:`admin`}),startEnrollment:O(b({userId:p().min(1),deviceName:p().min(1).max(80)}),hfe,{kind:`mutation`,auth:`admin`,caller:`required`}),revokeDeviceCredential:O(b({id:p().min(1)}),b({revoked:v(),sessionsEnded:f().int(),status:eg}),{kind:`mutation`,auth:`admin`,caller:`required`}),getDeviceCertificateSettings:O(b({}),tA,{auth:`admin`}),setDeviceCertificateSettings:O(tA,tA,{kind:`mutation`,auth:`admin`}),deleteDeviceCredential:O(b({id:p().min(1)}),b({result:x([`deleted`,`live`,`unknown`])}),{kind:`mutation`,auth:`admin`,caller:`required`}),getDeviceCaStatus:O(b({}),eA,{auth:`admin`}),renameDeviceCredential:O(b({id:p().min(1),deviceName:p().min(1).max(80)}),b({renamed:v()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:A.IDENTITY}},Bbe=64,rA=/^[a-z][a-z0-9_]*$/,Vbe=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(`.`)),iA=p().max(64).regex(rA);function aA(e){return Vbe.has(e)}function oA(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 Hbe(e,t){let n=oA(e);if(!aA(n)&&!t(n))return n;for(let e=2;;e+=1){let r=`${n}_${e}`;if(!t(r))return r}}function Ube(e,t){return e.length===0?{ok:!1,reason:`empty`}:e.length>64?{ok:!1,reason:`too-long`}:rA.test(e)?aA(e)?{ok:!1,reason:`reserved`}:t(e)?{ok:!1,reason:`taken`}:{ok:!0,alias:e}:{ok:!1,reason:`grammar`}}var sA=4096,Wbe=50,Gbe=4096,Kbe=`—`,cA=p().min(1).max(sA),qbe=`now`,Jbe=`camera`,lA=c([p(),f(),v()]),uA=b({deviceId:f().int(),values:u(p().min(1).max(64),lA).optional()}),Ybe=`values`,Xbe=pl(),dA=[`too-long`,`syntax`,`forbidden-syntax`,`forbidden-member`,`unknown-filter`,`ambiguous-field`,`busy`,`budget-exceeded`,`timeout`,`output-too-large`,`render-failed`,`out-of-scope`,`unavailable`],fA=b({reason:x(dA),message:p()}),pA=[`unknown-alias`,`unknown-field`,`no-field`,`unavailable`],mA=b({ref:p(),reason:x(pA)}),hA=i(`ok`,[b({ok:o(!0),text:p(),trace:S(mA)}),b({ok:o(!1),refusal:fA,trace:S(mA)})]);function gA(e){return e.replace(/-/g,`_`)}function _A(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function vA(e,t){let n=e;for(let e of t)if(Array.isArray(n)&&typeof e==`number`)n=n[e];else if(_A(n)&&Object.hasOwn(n,String(e)))n=n[String(e)];else return;return n}function Zbe(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||gA(e)===n);if(i!==void 0){let n=t.slice(1);if(n.length===0)return{kind:`missing`,reason:`no-field`};let r=vA(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 _A(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=vA(e.slices[o],t);return s===void 0?{kind:`missing`,reason:`unknown-field`}:{kind:`value`,cap:o,fieldPath:t,value:s}}var yA=b({zoneKey:p(),label:p(),icon:$m.nullable(),locationKeys:S(p())});function Qbe(e){return e.trim().toLowerCase()}var $be=50,exe=200,bA=b({caps:S(p()).readonly().optional(),actions:S(p()).readonly().optional(),mode:x([`any`,`all`]).optional()}),xA=b({locations:S(p()).readonly().optional(),integrationIds:S(p()).readonly().optional(),types:S(p()).readonly().optional()}),SA=b({text:p().optional(),requires:bA.optional(),filters:xA.optional(),includeIncompatible:v().optional(),contextDeviceId:f().optional(),ids:S(f()).readonly().optional(),cursor:p().nullable().optional(),limit:f().int().min(1).max(200).optional()}),CA=b({cap:p(),path:p(),label:p(),reading:p().nullable(),unit:p().nullable().optional(),quantity:Hi.optional()}),wA=b({id:f(),name:p(),type:x(w),location:p().nullable(),integrationId:p().nullable(),integrationLabel:p().nullable(),online:v().nullable(),disabled:v(),compatible:v(),values:S(CA).readonly()}),TA=b({value:p(),count:f()}),EA=b({id:p(),label:p(),count:f()}),DA=b({locations:S(TA).readonly(),integrations:S(EA).readonly(),types:S(TA).readonly()}),OA=b({items:S(wA).readonly(),nextCursor:p().nullable(),total:f(),compatibleTotal:f(),fleetTotal:f(),hiddenIncompatible:f(),facets:DA,suggested:S(wA).readonly(),missingIds:S(f()).readonly()}),kA=b({connected:v(),deviceCount:f(),error:p().optional(),motionSliceWriter:o(`orchestrator`).optional()}),txe=b({externalId:p(),name:p(),type:p(),metadata:u(p(),l()).optional()}),AA=i(`kind`,[b({kind:o(`mdns`),serviceType:p().min(1),instancePattern:p().optional()}),b({kind:o(`ws-discovery`),types:S(p()).optional()}),b({kind:o(`ssdp`),searchTarget:p().min(1)}),b({kind:o(`udp-broadcast`),port:f().int().min(1).max(65535),payloadHex:p().regex(/^([0-9a-fA-F]{2})*$/),listenPort:f().int().min(1).max(65535).optional()}),b({kind:o(`http-probe`),port:f().int().min(1).max(65535),path:p().startsWith(`/`),method:x([`GET`,`POST`]).default(`GET`),bodyText:p().optional(),contentType:p().optional(),tls:v().default(!1),acceptStatus:S(f().int()).optional()}),b({kind:o(`custom`),reason:p().min(1)})]),jA=b({modeIndex:f().int().min(0),host:p(),port:f().int(),http:b({status:f().int(),headers:u(p(),p()),bodyText:p()}).optional(),mdns:b({instance:p(),host:p(),port:f().int(),txt:u(p(),p())}).optional(),udp:b({payloadHex:p()}).optional(),wsd:b({xaddrs:S(p()),types:S(p()),scopes:S(p())}).optional()}),MA=b({stableId:p(),type:x(w),suggestedName:p(),prefilledConfig:u(p(),l()),sourceInfo:Eg.optional(),alreadyOnboarded:v().optional(),onboardedDeviceId:f().optional(),onboardedName:p().optional(),setupIntegration:v().optional(),parentStableId:p().optional(),selectable:v().optional(),needsParams:S(p()).optional()}),NA=b({id:f(),stableId:p(),addonId:p(),type:p(),name:p(),parentDeviceId:f().nullable(),online:v(),features:S(p()),config:u(p(),l()),sourceInfo:Eg.optional()}),PA=b({status:x([`ok`,`error`]),labels:S(p()).optional(),error:p().optional()}),FA=l(),IA={name:`device-provider`,scope:`system`,mode:`collection`,methods:{start:O(_(),_(),{kind:`mutation`}),stop:O(_(),_(),{kind:`mutation`}),getStatus:O(_(),kA),getDevices:O(_(),S(b({id:p(),name:p(),type:p()}))),reloadDevice:O(b({stableId:p()}),b({deviceId:f()}),{kind:`mutation`,timeoutMs:3*6e4}),supportsDiscovery:O(b({}),v()),discoverDevices:O(b({params:u(p(),l()).optional()}),S(MA),{kind:`mutation`,auth:`admin`}),getDiscoveryModes:O(b({}),S(AA)),classifyDiscoveryHits:O(b({hits:S(jA),params:u(p(),l()).optional()}),S(MA),{kind:`mutation`,auth:`admin`}),getDiscoveryParamsSchema:O(b({}),FA),getManualCreationType:O(b({integrationId:p().optional()}),b({deviceType:x(w).nullable()})),adoptDiscoveredDevice:O(b({candidate:MA,integrationId:p().optional()}),NA,{kind:`mutation`,auth:`admin`}),supportsManualCreation:O(b({}),v()),getChildCreationSchema:O(b({type:x(w),integrationId:p().optional()}),FA),createDevice:O(b({type:x(w),config:u(p(),l()),integrationId:p().optional()}),NA,{kind:`mutation`,auth:`admin`}),testCreationField:O(b({type:x(w),key:p(),value:l(),formValues:u(p(),l()).optional()}),PA,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:A.INTERNAL}},LA=i(`kind`,[b({kind:o(`mdns`),serviceType:p(),instance:p(),host:p(),address:p().nullable(),port:f().int(),txt:u(p(),p())}),b({kind:o(`ssdp`),host:p(),port:f().int(),target:p(),headers:u(p(),p())})]),nxe=b({addonId:p(),candidate:MA,firstSeenAt:f(),lastSeenAt:f(),dismissed:v()}),RA=b({id:p(),addonId:p(),candidate:MA,firstSeenAt:f(),lastSeenAt:f(),dismissed:v()}),zA=b({childKey:p(),section:p(),order:f().optional(),collapsed:v().optional()}),rxe=b({unit:p().min(1).optional(),precision:f().int().min(0).max(10).optional()}),BA=b({icon:p().min(1).optional(),label:p().min(1).optional(),unit:p().min(1).optional(),precision:f().int().min(0).max(10).optional(),hidden:v().optional(),perCap:u(p(),rxe).optional()}),VA=b({unit:p().min(1).optional(),precision:f().int().min(0).max(10).optional(),icon:p().min(1).optional()}),HA=b({id:f(),stableId:p(),addonId:p(),type:x(w),name:p(),alias:iA.optional(),location:p().nullable(),tags:oh.optional(),disabled:v(),parentDeviceId:f().nullable(),role:p().nullable().optional(),online:v(),probed:v().optional(),features:S(p()),isCamera:v(),config:u(p(),l()),secretConfigPaths:S(p()).optional(),metadata:u(p(),l()).nullable().optional(),sourceInfo:Eg.optional(),integrationId:p().optional(),linkDeviceId:f().nullable().optional(),primaryChildEntityId:p().nullable().optional(),childLayout:S(zA).readonly().optional(),primaryChildPreference:S(p()).readonly().optional(),display:BA.optional()}),UA=b({key:p(),value:l(),description:p().optional()}),WA=x([`manual`]),GA=b({deviceId:f(),name:p(),location:p().nullable(),features:S(p()),producesTrackedEvents:v().optional()}),KA=b({deviceIds:S(f().int().positive()),trackedDeviceIds:S(f().int().positive()).optional()}),qA={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:[w.Camera],sourceCaps:`any`,cardinality:`many`,value:KA},ixe=b({deviceId:f(),mode:WA,devices:S(GA)}),JA=b({deviceId:f(),entries:S(b({capName:p(),kind:x([`native`,`wrapped`]),providerAddonId:p(),providerNodeId:p(),nativeAddonId:p(),implementedMethods:S(p()).optional()}))}),YA=i(`kind`,[b({kind:o(`value`),wrapperAddonId:p().nullable()}),b({kind:o(`missing`)}),b({kind:o(`failed`),error:p()})]),axe=b({id:f(),stableId:p(),type:p(),name:p(),location:p().nullable(),tags:oh.optional(),disabled:v(),parentDeviceId:f().nullable(),role:p().nullable().optional()}),oxe=b({id:f(),stableId:p(),addonId:p(),type:p(),name:p(),userNamed:v().optional(),location:p().nullable(),tags:oh.optional(),disabled:v(),parentDeviceId:f().nullable(),metadata:u(p(),l()).nullable().optional(),sourceInfo:Eg.optional(),integrationId:p().optional(),linkDeviceId:f().nullable().optional(),primaryChildEntityId:p().nullable().optional(),childLayout:S(zA).readonly().optional(),primaryChildPreference:S(p()).readonly().optional(),role:p().nullable().optional(),display:BA.optional()}),sxe=l().nullable(),cxe=b({streamId:p(),width:f().optional(),height:f().optional(),codec:p().optional(),fps:f().optional(),bitrateKbps:f().optional()}),lxe=b({addonId:p(),stableId:p(),id:f(),type:p(),name:p(),location:p().nullable().optional(),disabled:v().optional(),parentDeviceId:f().nullable(),role:p().nullable().optional(),features:S(p()).optional(),config:u(p(),l()),secretConfigPaths:S(p()).optional()}),XA=b({deviceId:f().int().positive(),deletedAt:f(),providerAddonId:p()}),ZA=2160*60*60*1e3,QA=b({deviceId:f().int().positive(),stores:u(p(),f().int().nonnegative())}),$A=b({status:x([`skipped`,`dry-run`,`cleaned`]),reason:p().nullable(),devices:S(QA),unreachable:S(p())}),uxe=b({deviceId:f()}),dxe=b({deviceId:f(),data:u(p(),l()),secretConfigPaths:S(p()).optional()}),ej=x([`off`,`on`,`not-offered`,`unreachable`]),tj=b({deviceId:f(),switchId:td,outcome:ej,detail:p().optional()}),nj=b({sourceId:f(),targetId:f(),switches:S(tj).readonly(),sourceStillLive:S(td).readonly(),swapped:v()}),rj={name:`device-manager`,scope:`system`,mode:`singleton`,extensionSlots:[qA],methods:{allocateDeviceId:O(b({addonId:p(),stableId:p()}),b({id:f()}),{kind:`mutation`}),migrateDevice:O(b({sourceId:f(),targetId:f()}),nj,{kind:`mutation`,auth:`admin`,timeoutMs:12*6e4}),registerDevice:O(lxe,_(),{kind:`mutation`}),removeDevice:O(uxe,_(),{kind:`mutation`}),persistConfig:O(dxe,_(),{kind:`mutation`,auth:`admin`}),loadConfig:O(b({deviceId:f()}),u(p(),l()),{auth:`admin`}),loadRuntimeState:O(b({deviceId:f()}),u(p(),l()),{auth:`admin`}),loadMeta:O(b({deviceId:f()}),oxe.nullable()),setName:O(b({deviceId:f(),name:p(),stampUserNamed:v().optional()}),_(),{kind:`mutation`,auth:`admin`}),setAlias:O(b({deviceId:f(),alias:p()}),i(`ok`,[b({ok:o(!0),alias:iA}),b({ok:o(!1),reason:x([`empty`,`too-long`,`grammar`,`reserved`,`taken`]),takenBy:f().optional()})]),{kind:`mutation`,auth:`admin`}),renderDeviceTemplates:O(b({templates:S(cA).max(64),allowedDeviceIds:S(f().int()).optional(),thisDevice:uA.optional()}),b({results:S(hA)}),{auth:`admin`}),checkDeviceTemplates:O(b({templates:S(p()).max(64),allowedDeviceIds:S(f().int()).optional(),thisDevice:uA.optional()}),b({results:S(i(`ok`,[b({ok:o(!0),aliases:S(b({alias:p(),deviceId:f().int().nullable(),allowed:v(),reads:S(p())})),readsClock:v()}),b({ok:o(!1),refusal:fA})]))}),{auth:`admin`}),setLocation:O(b({deviceId:f(),location:p().nullable()}),_(),{kind:`mutation`,auth:`admin`}),setTags:O(b({deviceId:f(),tags:oh}),_(),{kind:`mutation`,auth:`admin`}),setType:O(b({deviceId:f(),type:x(w)}),_(),{kind:`mutation`,auth:`admin`}),setIntegrationId:O(b({deviceId:f(),integrationId:p()}),_(),{kind:`mutation`,auth:`admin`}),setLinkDeviceId:O(b({deviceId:f(),linkDeviceId:f().nullable()}),_(),{kind:`mutation`,auth:`admin`}),setPrimaryChildEntityId:O(b({deviceId:f(),primaryChildEntityId:p().nullable()}),_(),{kind:`mutation`,auth:`admin`}),setChildLayout:O(b({deviceId:f(),childLayout:S(zA).readonly()}),_(),{kind:`mutation`,auth:`admin`}),setPrimaryChildPreference:O(b({deviceId:f(),primaryChildPreference:S(p()).readonly()}),_(),{kind:`mutation`,auth:`admin`}),setDisplay:O(b({deviceId:f(),display:BA.nullable()}),_(),{kind:`mutation`,auth:`admin`}),getRoleDisplayDefaults:O(b({}),b({defaults:u(p(),VA)}),{role:`viewer`,kind:`query`}),setRoleDisplayDefaults:O(b({defaults:u(p(),VA)}),_(),{kind:`mutation`,auth:`admin`}),getWireableFields:O(b({deviceId:f(),includeSynthesizable:v().optional()}),b({caps:S(b({cap:p(),fields:S(b({path:p(),kind:x([`string`,`number`,`boolean`,`enum`,`union`]),unionMembers:S(x([`string`,`number`,`boolean`])).optional(),enumValues:S(p()).optional(),item:v().optional(),quantity:Hi.optional()})).readonly(),itemArray:b({path:p(),keyField:p()}).optional()})).readonly()}),{kind:`query`}),setRole:O(b({deviceId:f(),role:p().nullable()}),_(),{kind:`mutation`,auth:`admin`}),applyInitialMeta:O(b({deviceId:f(),name:p().optional(),location:p().nullable().optional(),tags:oh.optional(),type:x(w).optional(),integrationId:p().optional(),linkDeviceId:f().nullable().optional(),role:p().nullable().optional()}),_(),{kind:`mutation`,auth:`admin`}),setMetadata:O(b({deviceId:f(),patch:u(p(),l())}),_(),{kind:`mutation`,auth:`admin`}),listLocations:O(_(),S(p())),addLocation:O(b({name:p()}),_(),{kind:`mutation`,auth:`admin`}),removeLocation:O(b({name:p(),cascade:v().optional()}),_(),{kind:`mutation`,auth:`admin`}),renameLocation:O(b({from:p(),to:p()}),b({moved:f()}),{kind:`mutation`,auth:`admin`}),listLocationIcons:O(_(),S(Tfe),{role:`viewer`}),setLocationIcon:O(b({location:p(),icon:$m.nullable()}),_(),{kind:`mutation`,auth:`admin`}),listLocationDescriptions:O(_(),S(Dfe)),setLocationDescription:O(b({location:p(),description:p().max(400).nullable()}),_(),{kind:`mutation`,auth:`admin`}),listSiteZones:O(_(),S(yA),{role:`viewer`}),setSiteZone:O(b({name:p(),icon:$m.nullable().optional()}),_(),{kind:`mutation`,auth:`admin`}),removeSiteZone:O(b({name:p()}),_(),{kind:`mutation`,auth:`admin`}),renameSiteZone:O(b({from:p(),to:p()}),_(),{kind:`mutation`,auth:`admin`}),setLocationZone:O(b({location:p(),zone:p().nullable()}),_(),{kind:`mutation`,auth:`admin`}),setDisabled:O(b({deviceId:f(),disabled:v()}),_(),{kind:`mutation`,auth:`admin`}),listPersistedByAddon:O(b({addonId:p()}),S(axe)),listAll:O(b({addonId:p().optional(),projection:x([`full`,`slim`]).optional(),isCamera:v().optional(),deviceIds:S(f()).optional()}),S(HA),{role:`viewer`}),search:O(SA,OA,{role:`viewer`}),getDevice:O(b({deviceId:f()}),HA.nullable()),getChildren:O(b({parentDeviceId:f()}),S(HA),{role:`viewer`}),getChildrenBatch:O(b({parentDeviceIds:S(f()).max(256)}),u(p(),S(HA))),getLinkedDevices:O(b({deviceId:f()}),b({mode:WA,devices:S(GA)}),{role:`viewer`}),getLinkedDevicesBatch:O(b({deviceIds:S(f())}),S(ixe),{role:`viewer`}),getStreamSources:O(b({deviceId:f()}),S(ea)),getConfigSchema:O(b({deviceId:f()}),S(UA)),getSettingsSchema:O(b({deviceId:f()}),sxe),updateConfig:O(b({deviceId:f(),values:u(p(),l())}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),enable:O(b({deviceId:f()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),disable:O(b({deviceId:f()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),remove:O(b({deviceId:f()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),listDeletedSince:O(b({sinceMs:f()}),S(XA).readonly(),{auth:`admin`}),cleanupDeletedDevicesData:O(b({confirm:v()}),$A,{kind:`mutation`,auth:`admin`}),removeByIntegration:O(b({integrationId:p()}),b({removed:f()}),{kind:`mutation`,auth:`admin`}),getStreamProfileMap:O(b({deviceId:f()}),u(p(),p().nullable())),setStreamProfileMap:O(b({deviceId:f(),profileMap:u(p(),p().nullable())}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),probeStreams:O(b({deviceId:f()}),S(cxe),{kind:`mutation`,auth:`admin`}),getBindings:O(b({deviceId:f()}),JA,{role:`viewer`}),getBindingsBatch:O(b({deviceIds:S(f())}),S(JA)),getAllBindings:O(b({}),S(JA)),listDeviceIdsByCaps:O(b({capNames:S(p().min(1)).min(1).max(16)}),S(f()),{role:`viewer`}),setWrapperActive:O(b({deviceId:f(),capName:p(),wrapperAddonId:p(),active:v()}),_(),{kind:`mutation`,auth:`admin`}),getWrapperActivation:O(b({deviceId:f(),capName:p().min(1)}),YA),listWrappersForCap:O(b({capName:p()}),S(p())),listBindableCapsForDeviceType:O(b({deviceType:p()}),S(b({capName:p(),wrappers:S(p())}))),getDeviceSettingsAggregate:O(b({deviceId:f()}),bx.nullable()),getDeviceLiveInfoAggregate:O(b({deviceId:f()}),bx.nullable(),{role:`viewer`}),getDeviceAggregate:O(b({deviceId:f()}),b({settings:bx.nullable(),live:bx.nullable()})),runDeviceAction:O(b({deviceId:f().int().nonnegative(),action:p().min(1),input:l()}),l(),{kind:`mutation`}),updateDeviceField:O(b({deviceId:f(),writerCapName:p(),writerAddonId:p(),key:p(),value:l()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),updateDeviceFieldsBatch:O(b({deviceId:f(),changes:S(b({writerCapName:p(),writerAddonId:p(),key:p(),value:l()}))}),b({success:o(!0),failures:S(b({writerCapName:p(),writerAddonId:p(),error:p()}))}),{kind:`mutation`,auth:`admin`}),discoverDevices:O(b({addonId:p()}),S(MA),{kind:`mutation`,auth:`admin`}),adoptDevice:O(b({addonId:p(),candidate:MA,integrationId:p().optional()}),NA,{kind:`mutation`,auth:`admin`}),getCreationSchema:O(b({addonId:p(),type:x(w),integrationId:p().optional()}),l().nullable()),createDevice:O(b({addonId:p(),type:x(w),config:u(p(),l()),integrationId:p().optional()}),NA,{kind:`mutation`,auth:`admin`}),testCreationField:O(b({addonId:p(),type:x(w),key:p(),value:l(),formValues:u(p(),l()).optional()}),PA,{kind:`mutation`,auth:`admin`}),adoptionListCandidateFilters:O(b({addonId:p(),integrationId:p()}),b({filters:S(Hk)}),{auth:`admin`}),adoptionListCandidates:O(Wk.extend({addonId:p()}),Gk,{auth:`admin`}),adoptionRefresh:O(b({addonId:p(),integrationId:p()}),qk,{kind:`mutation`,auth:`admin`}),adoptionAdopt:O(Jk.extend({addonId:p()}),Yk,{kind:`mutation`,auth:`admin`}),adoptionRelease:O(Xk.extend({addonId:p()}),_(),{kind:`mutation`,auth:`admin`}),adoptionStartJob:O(Jk.extend({addonId:p()}),b({jobId:p()}),{kind:`mutation`,auth:`admin`}),adoptionListJobs:O(b({addonId:p(),integrationId:p().optional()}),S(ed).readonly(),{auth:`admin`}),adoptionCancelJob:O(b({jobId:p()}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`}),adoptionResync:O(Zk,Qk,{kind:`mutation`,auth:`admin`}),discoveryProviders:O(b({}),b({providers:S(b({addonId:p(),label:p()})).readonly()}),{auth:`admin`}),discoverAllProviders:O(b({subnets:S(p()).optional()}),b({groups:S(b({addonId:p(),label:p(),candidates:S(MA).readonly(),error:p().nullable()})).readonly()}),{kind:`mutation`,auth:`admin`}),discoverProvider:O(b({addonId:p(),params:u(p(),l()).optional(),subnets:S(p()).optional()}),b({candidates:S(MA).readonly()}),{kind:`mutation`,auth:`admin`}),listDiscoveryProposals:O(b({}),b({proposals:S(RA).readonly()}),{auth:`admin`}),dismissDiscoveryProposal:O(b({id:p()}),b({dismissed:v()}),{kind:`mutation`,auth:`admin`}),reportDiscoveryObservations:O(b({observations:S(LA).max(512)}),b({proposed:f().int()}),{kind:`mutation`,auth:`admin`}),runDiscoverySweep:O(b({}),b({providers:f().int(),proposed:f().int()}),{kind:`mutation`,auth:`admin`,timeoutMs:12e4}),providerCreationType:O(b({addonId:p(),integrationId:p().optional()}),b({deviceType:x(w).nullable()}),{auth:`admin`}),providerDiscoveryParamsSchema:O(b({addonId:p()}),l(),{auth:`admin`}),testField:O(b({deviceId:f(),key:p(),value:l()}),PA,{kind:`mutation`,auth:`admin`}),getDeviceStatusAggregate:O(b({deviceId:f(),caps:S(p()).readonly().optional()}),u(p(),l().nullable())),getDeviceStatusAggregateBatch:O(b({deviceIds:S(f()).readonly(),caps:S(p()).readonly().optional()}),u(p(),u(p(),l().nullable())),{role:`viewer`})},vocabulary:{notOperatorFacing:`the device registry itself — rename, move and remove are administration`}},ij=[`linked-devices`],aj=x(ij),oj={"linked-devices":{descriptor:qA,declaringCap:`device-manager`,hostDeviceTypes:[w.Camera]}},sj=i(`slot`,[KA.extend({slot:o(`linked-devices`)})]),cj=[w.Camera],fxe=`:`,pxe=`listSlots`,lj=i(`state`,[b({state:o(`ok`)}),b({state:o(`unreachable`),reason:p()})]),uj=b({source:p(),label:p(),addonId:p().optional(),availability:lj}),dj=x([`ok`,`missing`,`foreign`,`unavailable`]),fj=b({deviceId:f().int(),name:p().nullable(),health:dj,detail:p().optional()}),pj=b({state:x([`active`,`inactive`,`unknown`]),authority:p(),detail:p().optional()}),mj=b({state:o(`ok`),slotRef:p(),slot:aj,authority:p(),activation:pj.nullable(),value:sj,sources:S(fj),impliedSources:S(fj).optional()}),hj=b({state:o(`unreachable`),addonId:p(),reason:p()}),gj=i(`state`,[mj,hj]);function mxe(e,t){return{state:`unreachable`,addonId:e,reason:t}}var _j=b({deviceId:f().int(),name:p(),type:p(),location:p().nullable(),parentName:p().nullable(),suggested:v(),reason:p().nullable()}),vj=b({candidates:S(_j)}),yj=b({applied:o(!0),reload:x([`none`,`host`,`parent`])}),bj=b({deviceId:f().int(),slotRef:p().min(1)}),xj=bj.extend({value:sj}),Sj={name:`device-extension`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:cj,deviceConfig:{ui:{kind:`widget`,widgetId:`host/extensions-panel`,tab:`general`,label:`Extensions`,order:72}},methods:{listSources:O(b({deviceId:f().int()}),S(uj)),listSlots:O(b({deviceId:f().int()}),S(gj)),listCandidates:O(bj,vj),setSlot:O(xj,yj,{kind:`mutation`,auth:`admin`})},vocabulary:{noun:N(`Device extension`,`Estensione del dispositivo`),order:3100}},Cj=i(`kind`,[b({kind:o(`device`),deviceId:f().int()}),b({kind:o(`node`),nodeId:p().min(1)})]),wj=x([`gauge`,`counter`,`boolean`,`enum`]),Tj=x([`gauge`,`counter`,`boolean`]),hxe=`derived:energy.kwh`,Ej=x([`raw`,`5m`,`1h`,`1d`]),Dj=x([`undeclared`,`not-owner`,`opted-out`,`not-a-real-device`,`rate`,`ingest-mismatch`,`out-of-range`]),gxe=b({key:p(),reason:Dj,count:f().int()}),Oj=b({accepted:f().int(),refused:S(gxe).readonly()}),kj=b({key:p(),scope:p(),kind:wj,unit:p().nullable(),displayName:p(),source:x([`cap`,`addon`,`derived`]),values:S(p()).readonly().nullable(),firstTs:f(),lastTs:f()}),_xe=b({t:f(),samples:f().int(),mean:f().nullable(),twMean:f().nullable(),min:f(),max:f(),last:f().nullable(),delta:f().nullable(),state:p().nullable(),states:u(p(),f()).nullable()}),vxe=b({scope:p(),before:b({t:f(),value:f().nullable(),state:p().nullable()}).nullable(),points:S(_xe).readonly(),derivedFrom:p().nullable()}),Aj={key:p(),scope:p().optional(),from:f(),to:f(),resolution:c([Ej,o(`auto`)]).default(`auto`),maxPoints:f().int().positive().max(5e3).default(1e3)},jj=b({resolution:Ej,series:S(vxe).readonly(),truncated:v()}),yxe=24,bxe=c([b({deviceId:f().int(),key:p(),scope:p().optional()}),b({forNodeId:p().min(1),key:p(),scope:p().optional()})]),xxe=i(`ok`,[b({ok:o(!0),result:jj}),b({ok:o(!1),error:p()})]),Sxe=b({tier:Ej,rows:f().int().nullable(),approxBytes:f().nullable(),countedAt:f().nullable()}),Mj=x([`device-gone`,`undeclared`]),Nj=b({raw:f().int(),"5m":f().int(),"1h":f().int(),"1d":f().int()}),Cxe=b({seriesId:f().int(),deviceId:f().int(),key:p(),scope:p(),displayName:p().nullable(),reason:Mj,missingSince:f().nullable(),firstTs:f(),lastTs:f(),rows:Nj}),wxe=200,Txe=50,Pj=x([`not-found`,`not-orphan`,`failed`]),Exe=i(`ok`,[b({seriesId:f().int(),ok:o(!0),deleted:Nj}),b({seriesId:f().int(),ok:o(!1),reason:Pj})]),Dxe=b({series:S(Cxe).readonly(),truncated:v()}),Fj=x([`invalid-range`,`range-too-large`,`series-not-found`,`not-a-point-series`]),Oxe=b({"5m":f().int(),"1h":f().int(),"1d":f().int()}),kxe=i(`ok`,[b({ok:o(!0),dryRun:v(),seriesId:f().int(),rows:Nj,rewritten:Oxe.nullable()}),b({ok:o(!1),reason:Fj})]),Ij=b({startedAt:f(),ready:v(),series:f().int(),metrics:f().int(),optedOutDevices:f().int(),tiers:S(Sxe).readonly(),capture:b({eventsSeen:f().int(),pointsEmitted:f().int(),pointsWritten:f().int(),pointsDropped:f().int(),bufferDepth:f().int(),trailingEmitted:f().int(),reconciledPoints:f().int(),reconcileRuns:f().int(),reconcileFailures:f().int(),lastReconcileAt:f().nullable(),lastFlushAt:f().nullable(),flushFailures:f().int(),skipped:u(p(),f().int())}),ingest:b({accepted:f().int(),refused:u(p(),f().int())}),rollup:b({last5mAt:f().nullable(),last1hAt:f().nullable(),last1dAt:f().nullable(),errors:f().int(),dirty5m:f().int(),dirty1h:f().int(),dirty1d:f().int()}),retention:b({lastRunAt:f().nullable(),deleted:u(p(),f().int()),purgedSeries:f().int()}),directory:b({devices:f().int(),lastRefreshAt:f().nullable()})}),Lj={name:`device-history`,scope:`system`,mode:`singleton`,methods:{listSeries:O(b({deviceId:f().int()}),S(kj).readonly()),listNodeSeries:O(b({forNodeId:p().min(1)}),S(kj).readonly(),{auth:`admin`}),query:O(b({deviceId:f().int(),...Aj}),jj),queryNode:O(b({forNodeId:p().min(1),...Aj}),jj,{auth:`admin`}),queryMany:O(b({items:S(bxe).min(1).max(24),from:Aj.from,to:Aj.to,resolution:Aj.resolution,maxPoints:Aj.maxPoints}),b({results:S(xxe).readonly()}),{auth:`admin`}),declareSeries:O(b({name:p().regex(/^[a-z0-9-]+$/),subjectKind:x([`device`,`node`]),kind:Tj,unit:p().optional(),displayName:p().min(1),ingest:x([`points`,`buckets`])}),b({key:p()}),{kind:`mutation`,auth:`admin`}),record:O(b({points:S(b({key:p(),subject:Cj,scope:p().default(``),ts:f(),value:f()})).max(5e3)}),Oj,{kind:`mutation`,auth:`admin`}),recordBuckets:O(b({buckets:S(b({key:p(),subject:Cj,scope:p().default(``),bucketStart:f(),samples:f().int().positive(),sum:f(),min:f(),max:f(),last:f().nullable(),lastTs:f().nullable()})).max(5e3)}),Oj,{kind:`mutation`,auth:`admin`}),getDeviceEnabled:O(b({deviceId:f().int()}),b({enabled:v()})),setDeviceEnabled:O(b({deviceId:f().int(),enabled:v()}),b({enabled:v()}),{kind:`mutation`,auth:`admin`}),getStatus:O(b({}),Ij,{auth:`admin`}),listOrphanSeries:O(b({}),Dxe,{auth:`admin`}),deleteOrphanSeries:O(b({seriesIds:S(f().int()).min(1).max(50)}),b({results:S(Exe).readonly()}),{kind:`mutation`,auth:`admin`}),deleteSeriesRange:O(b({deviceId:f().int(),key:p().min(1),scope:p(),fromMs:f().int().nonnegative(),toMs:f().int().nonnegative(),dryRun:v()}),kxe,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`recorded history of device state — read by charts, not actuated`}},Rj=b({deviceId:f().int().positive(),deletedAt:f(),providerAddonId:p()}),zj=b({counts:u(p(),f().int().nonnegative())}),Bj=b({store:p(),deviceId:f().int().positive(),count:f().int().nonnegative()}),Vj={name:`device-removal-hook`,scope:`system`,mode:`collection`,internal:!0,methods:{onDeviceRemoved:O(Rj,zj,{kind:`mutation`,auth:`admin`}),listDeviceData:O(_(),S(Bj).readonly(),{auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:A.INTERNAL}},Hj=x([`appliance`,`mower`,`vacuum`]),Uj=x([`open`,`closed`]),Wj=x([`completed`,`aborted`,`error`,`unknown`]),Gj=x([`running-state`,`activity`,`reconcile`]),Kj=x([`counter-delta`,`history-integral`]),qj=b({phase:p(),at:f()}),Jj=b({kind:o(`appliance`),energyKwh:f().nullable().meta(j(`energy`)),energyMethod:Kj.nullable(),peakW:f().nullable().meta(j(`power`)),avgW:f().nullable().meta(j(`power`)),program:p().nullable(),remainingAtStartSec:f().nullable().meta(j(`duration`)),finalPhase:p().nullable(),energyStartKwh:f().nullable().meta(j(`energy`)),powerObservedMs:f()}),Yj=i(`kind`,[Jj]),Xj=b({runId:p(),deviceId:f().int(),kind:Hj,state:Uj,startedAt:f(),endedAt:f().nullable(),durationMs:f().nullable(),outcome:Wj.nullable(),startSource:Gj,endSource:Gj.nullable(),runningSource:x([`native`,`assigned`]).nullable(),phases:S(qj),detail:Yj}),Axe=[w.Washer,w.Dryer,w.Dishwasher],jxe=200,Zj={name:`device-runs`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:Axe,methods:{listRuns:O(b({deviceId:f().int(),outcome:Wj.optional(),atFrom:f().optional(),atTo:f().optional(),limit:f().int().positive().max(200).default(50),cursor:p().optional()}),b({runs:S(Xj).readonly(),nextCursor:p().nullable()})),getRun:O(b({deviceId:f().int(),runId:p()}),Xj.nullable()),getCurrentRun:O(b({deviceId:f().int()}),Xj.nullable())},events:{onRunOpened:{data:Xj,notOperatorFacing:`the durable record of a run that the running-state start flip already announces`},onRunClosed:{data:Xj,notOperatorFacing:`the durable record of a run that the running-state finish flip already announces`}},vocabulary:{noun:N(`Runs`,`Esecuzioni`),order:2130}},Qj=x([`replace`,`add`]),$j=i(`ok`,[b({ok:o(!0),changed:v()}),b({ok:o(!1),code:x([`owned-by-other`,`not-claimed`,`field-not-claimed`,`invalid-slice`,`unknown-device`,`row-unreadable`,`migration-in-flight`]),message:p()})]),eM=b({deviceId:f(),capName:p(),owner:p().min(1),mode:Qj,fields:S(p().min(1)).min(1)}),tM=i(`state`,[b({state:o(`loaded`),claims:S(eM)}),b({state:o(`not-loaded`),reason:p()})]),nM={name:`device-state`,scope:`system`,mode:`singleton`,methods:{getSnapshot:O(b({deviceId:f()}),u(p(),u(p(),l()))),getCapSlice:O(b({deviceId:f(),capName:p()}),u(p(),l()).nullable()),getAllSnapshots:O(b({}),u(p(),u(p(),u(p(),l())))),setCapSlice:O(b({deviceId:f(),capName:p(),slice:u(p(),l())}),_(),{kind:`mutation`}),claimFields:O(b({deviceId:f(),capName:p(),owner:p().min(1),mode:Qj,fields:S(p().min(1)).min(1),values:u(p(),l())}),$j,{kind:`mutation`,auth:`admin`}),patchOwnedFields:O(b({deviceId:f(),capName:p(),owner:p().min(1),values:u(p(),l())}),$j,{kind:`mutation`,auth:`admin`}),releaseClaim:O(b({deviceId:f(),capName:p(),owner:p().min(1)}),$j,{kind:`mutation`,auth:`admin`}),listClaims:O(b({ownerPrefix:p().optional()}),tM,{auth:`admin`}),getNativeCapSlice:O(b({deviceId:f(),capName:p()}),u(p(),l()).nullable(),{auth:`admin`})},events:{onChanged:Rr(b({deviceId:f(),capName:p(),slice:u(p(),l())}))},vocabulary:{notOperatorFacing:`the runtime-state mirror every trigger already reads through`}},rM=b({online:v(),lastChangedAt:f()}),iM={name:`device-status`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},events:{onStatusChanged:{data:b({deviceId:f(),status:rM}),notOperatorFacing:"the `online` state trigger phrases both edges of this change"}},status:{schema:rM,kind:`push`},runtimeState:rM,durability:`restored`,history:{fields:{online:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:N(`Reachability`,`Raggiungibilità`),order:5260,state:[{kind:`boolean`,field:`online`,label:N(`Online`,`Online`),whenTrue:N(`When {device} comes back online`,`Quando {device} torna online`),whenFalse:N(`When {device} goes offline`,`Quando {device} va offline`),icon:`wifi`}],extraEvents:[{category:C.DeviceOnline,label:N(`Came online`,`Tornato online`),phrase:N(`When {device} comes back online`,`Quando {device} torna online`),icon:`wifi`},{category:C.DeviceOffline,label:N(`Went offline`,`Andato offline`),phrase:N(`When {device} goes offline`,`Quando {device} va offline`),icon:`wifi-off`}]}},Mxe=200,Nxe=500,aM=x([`not-kernel`,`invalid`]),oM=b({written:f().int().nonnegative(),refused:S(b({id:p(),reason:aM})).readonly()}),sM=b({rows:f().int().nullable(),lastWriteAt:f().nullable(),refused:u(p(),f())}),cM={name:`device-transitions`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:Object.values(w).filter(e=>e!==w.Container),methods:{listTransitions:O(b({deviceId:f().int(),capName:p().optional(),actorKind:Li.optional(),outcome:Ri.optional(),atFrom:f().optional(),atTo:f().optional(),limit:f().int().positive().max(200).default(50),cursor:p().optional()}),b({transitions:S(Bi).readonly(),nextCursor:p().nullable()})),getTransition:O(b({deviceId:f().int(),id:p()}),Bi.nullable()),listRecentTransitions:Lr(b({actorKind:Li.optional(),outcome:Ri.optional(),atFrom:f().optional(),atTo:f().optional(),limit:f().int().positive().max(200).default(50),cursor:p().optional()}),b({transitions:S(Bi).readonly(),nextCursor:p().nullable()}),{auth:`admin`}),record:Lr(b({transitions:S(Bi).max(500)}),oM,{kind:`mutation`,auth:`admin`}),getStatus:Lr(b({}),sM,{auth:`admin`})},vocabulary:{noun:N(`Transitions`,`Transizioni`),order:2140}},lM=x([`idle`,`running`,`paused`,`finished`,`error`,`unavailable`]),uM=x([`Inactive`,`Ready`,`DelayedStart`,`Run`,`Pause`,`ActionRequired`,`Finished`,`Error`,`Aborting`]),dM=x([`available`,`offline`,`description-missing`]),fM=b({availability:dM,state:lM,operationState:uM.nullable(),program:p().nullable(),selectedProgram:p().nullable(),availablePrograms:S(p()),remaining:f().int().nonnegative().nullable().meta(j(`duration`)),delayedStart:f().int().nonnegative().nullable().meta(j(`duration`)),progress:f().min(0).max(100).nullable().meta(j(`percentage`)),doorOpen:v().nullable(),doorLocked:v().nullable(),remoteStartAllowed:v().nullable(),remoteControlActive:v().nullable(),localControlActive:v().nullable(),powerOn:v().nullable(),powerState:p().nullable(),filterCleaningDue:v().nullable(),machineCareDue:v().nullable(),machineCareRemainingRuns:f().int().nonnegative().nullable().meta(j(`count`)),halfLoad:v().nullable(),hygienePlus:v().nullable(),extraDry:v().nullable(),intensiveZone:v().nullable(),varioSpeedPlus:v().nullable(),childLock:v().nullable(),activeEvents:S(p()),errorCode:f().nullable().meta(j(`none`)),errorLabel:p().nullable(),lastFetchedAt:f()}),pM=f().int().nonnegative(),mM=c([v(),p(),f()]),hM=x([`none`,`read`,`readWrite`,`writeOnly`,`readStatic`]),gM=b({key:p(),name:p(),type:x([`boolean`,`number`,`enum`,`string`]),access:hM,available:v(),unit:p().nullable(),min:f().nullable(),max:f().nullable(),step:f().nullable(),enumValues:S(p()).nullable(),defaultValue:mM.nullable()}),_M=b({key:p(),name:p(),available:v(),options:S(gM)}),vM=b({availability:dM,supportsStart:v(),supportsPause:v(),supportsResume:v(),supportsStop:v(),supportsPower:v(),programs:S(_M),options:S(gM)}),yM={name:`dishwasher`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Dishwasher],methods:{start:O(b({deviceId:pM,program:p().min(1).optional(),options:u(p(),mM).optional()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.start`,label:N(`Start cycle`,`Avvia il lavaggio`),phrase:N(`Start {device}`,`Avvia {device}`),icon:`play`,openArgs:[{key:`program`,label:N(`Programme`,`Programma`),offer:{kind:`dynamic`,from:`status`,field:`availablePrograms`},optional:!0}]}]}),pause:O(b({deviceId:pM}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.pause`,label:N(`Pause`,`Metti in pausa`),phrase:N(`Pause {device}`,`Metti in pausa {device}`),icon:`pause`}]}),resume:O(b({deviceId:pM}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.resume`,label:N(`Resume`,`Riprendi`),phrase:N(`Resume {device}`,`Riprendi il lavaggio di {device}`),icon:`play`}]}),stop:O(b({deviceId:pM}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.stop`,label:N(`Stop`,`Ferma`),phrase:N(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),setProgram:O(b({deviceId:pM,program:p().min(1)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.program`,label:N(`Choose programme`,`Scegli il programma`),phrase:N(`Select the {program} programme on {device}`,`Seleziona il programma {program} su {device}`),icon:`list`,openArgs:[{key:`program`,label:N(`Programme`,`Programma`),offer:{kind:`dynamic`,from:`status`,field:`availablePrograms`}}]}]}),setPower:O(b({deviceId:pM,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.powerOn`,label:N(`Power on`,`Accendi`),phrase:N(`Turn on {device}`,`Accendi {device}`),icon:`power`,args:{on:!0}},{id:`dishwasher.powerOff`,label:N(`Power off`,`Spegni`),phrase:N(`Turn off {device}`,`Spegni {device}`),icon:`power-off`,args:{on:!1}}]}),setHalfLoad:O(b({deviceId:pM,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.halfLoadOn`,label:N(`Half load on`,`Mezzo carico attivo`),phrase:N(`Turn on half load on {device}`,`Attiva il mezzo carico su {device}`),icon:`contrast`,args:{on:!0}},{id:`dishwasher.halfLoadOff`,label:N(`Half load off`,`Mezzo carico spento`),phrase:N(`Turn off half load on {device}`,`Disattiva il mezzo carico su {device}`),icon:`contrast`,args:{on:!1}}]}),setHygienePlus:O(b({deviceId:pM,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.hygienePlusOn`,label:N(`Hygiene Plus on`,`Igiene Plus attiva`),phrase:N(`Turn on Hygiene Plus on {device}`,`Attiva Igiene Plus su {device}`),icon:`sparkles`,args:{on:!0}},{id:`dishwasher.hygienePlusOff`,label:N(`Hygiene Plus off`,`Igiene Plus spenta`),phrase:N(`Turn off Hygiene Plus on {device}`,`Disattiva Igiene Plus su {device}`),icon:`sparkles`,args:{on:!1}}]}),setExtraDry:O(b({deviceId:pM,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.extraDryOn`,label:N(`Extra dry on`,`Asciugatura extra attiva`),phrase:N(`Turn on extra dry on {device}`,`Attiva l’asciugatura extra su {device}`),icon:`sun`,args:{on:!0}},{id:`dishwasher.extraDryOff`,label:N(`Extra dry off`,`Asciugatura extra spenta`),phrase:N(`Turn off extra dry on {device}`,`Disattiva l’asciugatura extra su {device}`),icon:`sun`,args:{on:!1}}]}),setIntensiveZone:O(b({deviceId:pM,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.intensiveZoneOn`,label:N(`Intensive zone on`,`Zona intensiva attiva`),phrase:N(`Turn on the intensive zone on {device}`,`Attiva la zona intensiva su {device}`),icon:`flame`,args:{on:!0}},{id:`dishwasher.intensiveZoneOff`,label:N(`Intensive zone off`,`Zona intensiva spenta`),phrase:N(`Turn off the intensive zone on {device}`,`Disattiva la zona intensiva su {device}`),icon:`flame`,args:{on:!1}}]}),setVarioSpeedPlus:O(b({deviceId:pM,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.varioSpeedOn`,label:N(`Speed boost on`,`Lavaggio rapido attivo`),phrase:N(`Turn on the speed boost on {device}`,`Attiva il lavaggio rapido su {device}`),icon:`zap`,args:{on:!0}},{id:`dishwasher.varioSpeedOff`,label:N(`Speed boost off`,`Lavaggio rapido spento`),phrase:N(`Turn off the speed boost on {device}`,`Disattiva il lavaggio rapido su {device}`),icon:`zap`,args:{on:!1}}]}),setChildLock:O(b({deviceId:pM,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.childLockOn`,label:N(`Child lock on`,`Blocco bambini attivo`),phrase:N(`Turn on the child lock of {device}`,`Attiva il blocco bambini di {device}`),icon:`lock`,args:{on:!0}},{id:`dishwasher.childLockOff`,label:N(`Child lock off`,`Blocco bambini spento`),phrase:N(`Turn off the child lock of {device}`,`Disattiva il blocco bambini di {device}`),icon:`lock-open`,args:{on:!1}}]}),setOption:O(b({deviceId:pM,key:p().min(1),value:mM}),_(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`a raw appliance option key/value; every option worth naming has its own action above`}),getOptions:O(b({deviceId:pM}),vM,{auth:`protected`})},status:{schema:fM,kind:`poll`},runtimeState:fM,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:N(`Dishwasher`,`Lavastoviglie`),order:2020,state:[{kind:`enum`,field:`state`,label:N(`Cycle`,`Ciclo`),values:[{value:`idle`,label:N(`Idle`,`Inattiva`)},{value:`running`,label:N(`Running`,`In funzione`),phrase:N(`When {device} starts a cycle`,`Quando {device} inizia un lavaggio`)},{value:`paused`,label:N(`Paused`,`In pausa`)},{value:`finished`,label:N(`Finished`,`Terminato`),phrase:N(`When {device} finishes`,`Quando {device} finisce il lavaggio`)},{value:`error`,label:N(`Error`,`Errore`),phrase:N(`When {device} reports an error`,`Quando {device} segnala un errore`)},{value:`unavailable`,label:N(`Unavailable`,`Non disponibile`)}],icon:`washing-machine`},{kind:`numeric`,field:`progress`,quantity:N(`the cycle progress`,`l’avanzamento del lavaggio`),label:N(`Progress`,`Avanzamento`),unit:`%`,icon:`loader`},{kind:`boolean`,field:`doorOpen`,label:N(`Door open`,`Sportello aperto`),whenTrue:N(`When the door of {device} opens`,`Quando si apre lo sportello di {device}`),whenFalse:N(`When the door of {device} closes`,`Quando si chiude lo sportello di {device}`),icon:`door-open`},{kind:`boolean`,field:`filterCleaningDue`,label:N(`Filter cleaning due`,`Pulizia filtro da fare`),whenTrue:N(`When {device} asks for its filter to be cleaned`,`Quando {device} chiede di pulire il filtro`),whenFalse:N(`When the filter reminder of {device} clears`,`Quando l’avviso filtro di {device} rientra`),icon:`funnel`},{kind:`boolean`,field:`machineCareDue`,label:N(`Machine care due`,`Manutenzione da fare`),whenTrue:N(`When {device} asks for a machine-care cycle`,`Quando {device} chiede un ciclo di manutenzione`),whenFalse:N(`When the machine-care reminder of {device} clears`,`Quando l’avviso di manutenzione di {device} rientra`),icon:`wrench`}]}},bM=`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(`.`),xM=`audio`,SM=[.3,.42,.55,.7,.85,1],CM=[`camstack`,`high-contrast`,`okabe-ito`];function Pxe(e){return bM.includes(e)}function Fxe(e){return CM.includes(e)}var wM={dark:`#0c0a09`,light:`#fafaf9`},Ixe=7,Lxe=20,Rxe=[`live`,`heatmapScrub`],zxe=3,TM=/^#[0-9a-fA-F]{6}$/;function EM(e,t){return Number.parseInt(e.slice(t,t+2),16)}function DM(e){let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function OM(e){let t=DM(EM(e,1)),n=DM(EM(e,3)),r=DM(EM(e,5));return .2126*t+.7152*n+.0722*r}function Bxe(e,t){if(!TM.test(e)||!TM.test(t))return 0;let n=Math.max(OM(e),OM(t)),r=Math.min(OM(e),OM(t));return(n+.05)/(r+.05)}function kM(e){let t=DM(EM(e,1)),n=DM(EM(e,3)),r=DM(EM(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 AM(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 Vxe(e,t){if(!TM.test(e)||!TM.test(t))return 0;let n=kM(e),r=kM(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=AM(o,n.b),d=AM(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)),ne=1+.015*(m-50)**2/Math.sqrt(20+(m-50)**2),re=1+.045*h,ie=1+.015*h*_,y=-Math.sin(2*ee*Math.PI/180)*te,ae=r.L-n.L,oe=l-c;return Math.sqrt((ae/ne)**2+(oe/re)**2+(p/ie)**2+oe/re*y*(p/ie))}var Hxe={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`},Uxe=[`#b34dc7`,`#1d7d34`,`#db6b6c`,`#a43d29`,`#0e6ee6`,`#29a10b`,`#a98731`,`#0181c6`],Wxe={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`},Gxe=[`#817f3b`,`#a0733e`,`#8658b2`,`#956301`,`#bc652d`,`#647331`,`#a14c9e`,`#d14e71`],Kxe={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`},qxe=[`#9a3784`,`#a7392c`,`#409d50`,`#6987e7`,`#ee5b3d`,`#c0430d`,`#af79b3`,`#4b6628`],jM=p().regex(/^#[0-9a-f]{6}$/),MM=i(`form`,[b({form:o(`solid`),hex:jM}),b({form:o(`gradient`),hex:jM,alphas:S(f().gt(0).lte(1)).length(SM.length)})]),NM=b({status:o(`ready`),presetId:x(CM),customized:v(),source:x([`stored`,`unconfigured`]),swatches:u(p(),MM),fallbacks:S(jM).length(8)}),PM=i(`status`,[NM,b({status:o(`unknown`),reason:p()})]),FM=c([b({presetId:p()}),b({presetId:p(),overrides:u(p(),MM)})]),IM=b({presetId:p(),overrides:u(p(),MM)});function Jxe(e){return{form:`solid`,hex:e}}function Yxe(e){return{form:`gradient`,hex:e,alphas:[...SM]}}function Xxe(e){let t={};for(let n of bM){let r=e[n];if(r===void 0)throw Error(`palette table missing ${n}`);t[n]=n===`audio`?Yxe(r):Jxe(r)}return t}function LM(e,t,n,r){return{id:e,name:t,swatches:Xxe(n),fallbacks:r}}var RM=[LM(`camstack`,`CamStack`,Hxe,Uxe),LM(`high-contrast`,`High contrast`,Wxe,Gxe),LM(`okabe-ito`,`Colour-blind safe`,Kxe,qxe)];function zM(e){return RM.find(t=>t.id===e)}function BM(){let e=zM(`camstack`);if(e===void 0)throw Error(`CamStack preset missing`);return Zxe(e,`unconfigured`,!1)}function Zxe(e,t,n){return{status:`ready`,presetId:e.id,customized:n,source:t,swatches:e.swatches,fallbacks:[...e.fallbacks]}}function Qxe(e){return e.hex}function $xe(e,t){let n=[];for(let t of bM){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 eSe(e){let t=e[xM];return t===void 0||t.form===`gradient`&&SM.every((e,n)=>t.alphas[n]===e)?[]:[{code:`bad-gradient`,entry:xM}]}function tSe(e,t){let n=Rxe;return n.includes(e)&&n.includes(t)}function VM(e,t){let n=[];for(let t of bM)e[t]===void 0&&n.push({code:`missing-entry`,entry:t});for(let t of Object.keys(e))Pxe(t)||n.push({code:`unknown-entry`,entry:t});t.length!==8&&n.push({code:`bad-fallbacks`}),n.push(...eSe(e));let r=$xe(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=Vxe(i.hex,a.hex);o<(tSe(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=Bxe(e.hex,wM[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 nSe(e){switch(e.code){case`too-close`:return`${e.left} vs ${e.right} (ΔE ${e.deltaE.toFixed(1)})`;case`low-contrast`:return`${e.entry} on ${e.background} (${e.contrast.toFixed(1)}:1)`;case`missing-entry`:return`${e.entry} is missing`;case`unknown-entry`:return`${e.entry} is not a palette entry`;case`bad-gradient`:return`${e.entry} gradient is not the six canonical steps`;case`bad-fallbacks`:return`fallback list must hold eight colours`;case`unknown-preset`:return`${e.presetId} is not a preset`}}function HM(e){return e.map(nSe).join(`; `)}var UM=class extends Error{violations;constructor(e){super(HM(e)),this.name=`PaletteRejectedError`,this.violations=e}};function WM(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 GM(e,t,n){let r=n.trim().toLowerCase();if(r.startsWith(`audio-`)){let n=e[xM];return n===void 0?WM(r,t):n.hex}let i=e[r];return i===void 0?WM(r,t):i.hex}function KM(e,t){return{...e,...t}}function rSe(e){return`overrides`in e?e.overrides:{}}function iSe(e){let t=zM(e.presetId);if(t===void 0||!Fxe(e.presetId))throw new UM([{code:`unknown-preset`,presetId:e.presetId}]);let n=rSe(e),r=KM(t.swatches,n),i=VM(r,t.fallbacks);if(!i.ok)throw new UM(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 aSe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.keys(e).length===0}function oSe(e){if(e==null||aSe(e))return BM();let t=IM.safeParse(e);if(!t.success)return{status:`unknown`,reason:`stored palette is unreadable`};let n=zM(t.data.presetId);if(n===void 0)return{status:`unknown`,reason:`unknown preset ${t.data.presetId}`};let r=KM(n.swatches,t.data.overrides),i=VM(r,n.fallbacks);if(!i.ok)return{status:`unknown`,reason:HM(i.violations)};let a=Object.keys(t.data.overrides).length>0;return{status:`ready`,presetId:n.id,customized:a,source:`stored`,swatches:r,fallbacks:[...n.fallbacks]}}function sSe(e,t){return{presetId:e.presetId,overrides:{...t}}}var cSe=b({id:p(),name:p(),swatches:u(p(),MM),fallbacks:S(p())}),qM={name:`display-palette`,scope:`system`,mode:`singleton`,methods:{getPalette:O(_(),PM,{auth:`protected`,role:`viewer`}),listPresets:O(_(),S(cSe).readonly(),{auth:`protected`,role:`viewer`}),setPalette:O(FM,NM,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`the cluster display palette — one colour table for every client, not a device action`}},JM=b({enabled:v().nullable().meta({label:`Do not disturb`}),lastChangedAt:f()}),YM={name:`do-not-disturb`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.MediaPlayer],methods:{setEnabled:O(b({deviceId:f().int(),enabled:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dnd.on`,label:N(`Do not disturb on`,`Attiva Non disturbare`),phrase:N(`Turn on Do not disturb on {device}`,`Attiva Non disturbare su {device}`),icon:`bell-off`,args:{enabled:!0}},{id:`dnd.off`,label:N(`Do not disturb off`,`Disattiva Non disturbare`),phrase:N(`Turn off Do not disturb on {device}`,`Disattiva Non disturbare su {device}`),icon:`bell`,args:{enabled:!1}}]})},status:{schema:JM,kind:`push`},runtimeState:JM,durability:`session`,history:{fields:{enabled:{kind:`boolean`}}},vocabulary:{noun:N(`Do not disturb`,`Non disturbare`),order:2160,state:[{kind:`boolean`,field:`enabled`,label:N(`Do not disturb`,`Non disturbare`),whenTrue:N(`When Do not disturb turns on on {device}`,`Quando {device} attiva Non disturbare`),whenFalse:N(`When Do not disturb turns off on {device}`,`Quando {device} disattiva Non disturbare`),icon:`bell-off`}]}},XM=2e3,lSe={version:1,targets:[{id:`pressed`,cardinality:`event`,shape:`pulse`,vocabulary:{cap:`doorbell`,eventName:`onPressed`},deviceTypes:[w.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:XM,changedAtRequired:!0},sources:[{kind:`binary`},{kind:`switch`}],sourceReport:{status:`assignment-status`},advancedExpression:!0}]},ZM=b({lastPressedAt:f().nullable(),pressCountSinceStart:f().meta(j(`count`))}),QM=b({deviceId:f(),timestamp:f()}),$M={name:`doorbell`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Button,w.Camera],methods:{},events:{onPressed:{data:QM,fromState:{field:`lastPressedAt`,on:`advance`},trigger:{category:C.DoorbellOnPressed,label:N(`Rang`,`Ha suonato`),phrase:N(`When someone rings {device}`,`Quando qualcuno suona a {device}`),icon:`bell-ring`}}},status:{schema:ZM,kind:`push`},runtimeState:ZM,durability:`restored`,history:`none`,customize:lSe,vocabulary:{noun:N(`Doorbell`,`Campanello`),order:5270}},eN=b({embedding:S(f()),inferenceMs:f()}),tN=x([`image`,`text`]),nN=b({modelId:p(),tower:tN,nodeId:p(),crashes:f(),windowMs:f(),sinceMs:f(),lastReason:p()}),rN=b({modelId:p(),tower:tN,nodeId:p(),attempts:f(),sinceMs:f(),lastReason:p()}),iN=b({modelId:p(),embeddingDim:f(),ready:v(),nodeId:p().optional(),failedModels:S(nN).optional(),failedRequirements:S(rN).optional()}),aN=`embedding-model-failed`,oN=`embedding-requirements-unavailable`,sN=`embedding-requirements-failed`,cN=x([aN,oN,sN]);function lN(e,t){return`[${e} model=${t.modelId} tower=${t.tower} node=${t.nodeId}]`}function uSe(e){return Error(`${lN(aN,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 dSe(e,t){return Error(`${lN(oN,e)} ${e.modelId} (${e.tower} tower) on ${e.nodeId}: ${t}`)}function fSe(e){return Error(`${lN(sN,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 pSe=RegExp(`\\[(${aN}|${oN}|${sN}) model=([^\\s\\]]+) tower=(image|text) node=([^\\s\\]]+)\\]`);function uN(e){let t=e instanceof Error?e.message:String(e),n=pSe.exec(t);if(n===null)return null;let r=cN.safeParse(n[1]),i=tN.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 mSe(e){return dN(e)!==null}function dN(e){let t=uN(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 fN={name:`embedding-encoder`,scope:`system`,mode:`collection`,internal:!0,methods:{encode:O(b({crop:y(Uint8Array),width:f(),height:f()}),eN,{auth:`admin`}),encodeText:O(b({text:p(),modelId:p().min(1).optional()}),eN,{auth:`admin`}),getInfo:O(_(),iN,{auth:`admin`}),resetFailedModels:O(b({modelId:p().min(1).optional()}),b({cleared:S(p()),nodeId:p()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:A.ML}},pN=b({powerW:f().nullable().meta(j(`power`)),energyKwh:f().nullable().meta(j(`energy`)),todayKwh:f().nullable().meta(j(`energy`))}),mN=b({powerW:f().nullable().meta(j(`power`)),importKwh:f().nullable().meta(j(`energy`)),exportKwh:f().nullable().meta(j(`energy`)),importTodayKwh:f().nullable().meta(j(`energy`)),exportTodayKwh:f().nullable().meta(j(`energy`))}),hN=b({powerW:f().nullable().meta(j(`power`)),energyKwh:f().nullable().meta(j(`energy`)),todayKwh:f().nullable().meta(j(`energy`))}),gN=b({stateOfChargePct:f().nullable().meta(j(`percentage`)),storedKwh:f().nullable().meta(j(`energy`)),capacityKwh:f().nullable().meta(j(`energy`)),powerW:f().nullable().meta(j(`power`)),chargedKwh:f().nullable().meta(j(`energy`)),dischargedKwh:f().nullable().meta(j(`energy`)),chargedTodayKwh:f().nullable().meta(j(`energy`)),dischargedTodayKwh:f().nullable().meta(j(`energy`)),healthPct:f().nullable().meta(j(`percentage`))}),_N=b({solar:pN.nullable(),grid:mN.nullable(),house:hN.nullable(),heatPump:hN.nullable(),storage:gN.nullable(),lastFetchedAt:f()});function hSe(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 vN={name:`energy-system`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.EnergySystem],methods:{},status:{schema:_N,kind:`push`},runtimeState:_N,durability:`session`,history:{primary:`house.powerW`,priority:50,fields:{"solar.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Solar power`},"solar.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`Solar energy`},"grid.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Grid power`},"grid.importKwh":{kind:`counter`,unit:`kWh`,displayName:`Grid import`},"grid.exportKwh":{kind:`counter`,unit:`kWh`,displayName:`Grid export`},"house.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`House power`},"house.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`House energy`},"heatPump.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Heat pump power`},"heatPump.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`Heat pump energy`},"storage.stateOfChargePct":{kind:`gauge`,unit:`%`,deadband:1,displayName:`Storage charge`},"storage.storedKwh":{kind:`gauge`,unit:`kWh`,deadband:.05,displayName:`Stored energy`},"storage.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Storage power`},"storage.chargedKwh":{kind:`counter`,unit:`kWh`,displayName:`Storage charged`},"storage.dischargedKwh":{kind:`counter`,unit:`kWh`,displayName:`Storage discharged`},"storage.healthPct":{kind:`gauge`,unit:`%`,deadband:1,displayName:`Storage health`}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:N(`Energy system`,`Sistema energetico`),order:4020}},gSe=x([`date`,`time`,`datetime`]),yN=b({value:p(),timestamp:v().optional(),lastFetchedAt:f()}),bN={name:`enum-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Sensor],methods:{},status:{schema:yN,kind:`push`},runtimeState:yN,durability:`restored`,history:{fields:{value:{kind:`enum`,skipWhenSet:`timestamp`}}},volatileStateFields:[`lastFetchedAt`,`timestamp`],vocabulary:{noun:N(`State sensor`,`Sensore di stato`),order:5060,state:[{kind:`value`,field:`value`,label:N(`State`,`Stato`),icon:`list`}]}},xN=x([`warning`,`error`]),SN=b({code:p(),label:p(),severity:xN}),CN=b({active:v().nullable(),code:p().nullable(),label:p().nullable(),severity:xN,since:f().nullable(),faults:S(SN).optional(),lastFetchedAt:f()}),wN={active:null,code:null,label:null,severity:`error`,since:null,lastFetchedAt:0},TN={name:`error`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},status:{schema:CN,kind:`push`,empty:wN},runtimeState:CN,durability:`restored`,volatileStateFields:[`lastFetchedAt`],history:`none`,vocabulary:{noun:N(`Fault`,`Guasto`),order:5265,state:[{kind:`boolean`,field:`active`,label:N(`Fault`,`Guasto`),whenTrue:N(`When {device} reports a fault`,`Quando {device} segnala un guasto`),whenFalse:N(`When the fault of {device} clears`,`Quando il guasto di {device} si risolve`),icon:`triangle-alert`}]}},EN=b({id:p(),name:p(),sampleCount:f().int().nonnegative(),coverMediaId:f().int().optional(),coverBase64:p().optional()}),_Se=b({id:p(),source:x([`detected`,`photo`]),addedAt:f().int(),deviceId:f().int().optional(),base64:p().optional(),mediaId:f().int().optional(),keyFrameMediaId:f().int().optional(),faceBbox:bS.optional()}),vSe=b({sampleId:p(),enrolledAt:f().int(),deviceId:f().int().optional(),source:x([`detected`,`photo`]),mediaId:f().int().optional(),comparable:v(),selfMean:f().nullable(),bestForeign:b({identityId:p(),name:p(),score:f()}).optional(),suspicion:f()}),ySe=b({identityId:p(),name:p(),modelId:p(),totalSamples:f().int(),comparableSamples:f().int(),flagged:f().int(),flagThreshold:f(),rows:S(vSe).readonly()}),DN=b({faceId:p(),deviceId:f().int(),trackId:p(),timestamp:f().int(),recognizedIdentityId:p().optional(),identityName:p().optional(),assigned:v(),base64:p().optional(),cropUrl:p().optional(),faceBbox:bS.optional(),keyFrameMediaId:f().int().optional(),bestMatchScore:f().optional(),nativeFaceShortSidePx:f().optional(),suggestedIdentityId:p().optional(),suggestedMatchScore:f().optional()}),bSe=x([`unassigned`,`recognized`,`identified`,`all`]),xSe=x([`timestamp`,`suggestionConfidence`]),SSe=x([`asc`,`desc`]),CSe=b({faceIds:S(p()).readonly(),representativeFaceId:p(),size:f().int(),cohesion:f()}),wSe=b({mediaId:f().int(),kind:p(),url:p(),sizeBytes:f(),timestamp:f()}),ON={name:`face-gallery`,role:{feature:`face-assignment`},scope:`system`,mode:`singleton`,methods:{listIdentities:O(b({includeCrops:v().optional()}).optional(),S(EN).readonly(),{role:`viewer`}),createIdentity:O(b({name:p().min(1)}),EN,{kind:`mutation`,auth:`admin`}),renameIdentity:O(b({id:p(),name:p().min(1)}),_(),{kind:`mutation`,auth:`admin`}),deleteIdentity:O(b({id:p()}),_(),{kind:`mutation`,auth:`admin`}),listIdentitySamples:O(b({identityId:p()}),S(_Se).readonly()),auditIdentitySamples:O(b({identityId:p().min(1)}),ySe,{auth:`admin`}),removeSample:O(b({identityId:p(),sampleId:p()}),_(),{kind:`mutation`,auth:`admin`}),moveIdentitySample:O(b({sampleId:p().min(1),toIdentityId:p().min(1)}),_(),{kind:`mutation`,auth:`admin`}),listRecentFaces:O(b({deviceId:f().int().optional(),deviceIds:S(f().int()).optional(),limit:f().int().positive().optional(),filter:bSe.optional(),since:f().int().optional(),until:f().int().optional(),sortBy:xSe.optional(),sortDirection:SSe.optional(),includeCrops:v().optional()}).optional(),S(DN).readonly()),getFaceByTrack:O(b({deviceId:f().int(),trackId:p()}),DN.nullable(),{role:`viewer`}),getFaceMedia:O(b({faceId:p()}),S(wSe).readonly()),assignFace:O(b({faceId:p(),identityId:p()}),_(),{kind:`mutation`,auth:`admin`}),unassignFace:O(b({faceId:p()}),_(),{kind:`mutation`,auth:`admin`}),deleteFace:O(b({faceId:p()}),_(),{kind:`mutation`,auth:`admin`}),assignFaces:O(b({faceIds:S(p()).min(1),identityId:p()}),b({assigned:f().int(),failed:S(p()).readonly()}),{kind:`mutation`,auth:`admin`}),unassignFaces:O(b({faceIds:S(p()).min(1)}),b({unassigned:f().int(),failed:S(p()).readonly()}),{kind:`mutation`,auth:`admin`}),suggestFaceClusters:O(b({threshold:f().min(0).max(1).optional(),minClusterSize:f().int().min(2).optional(),maxClusters:f().int().positive().optional(),limit:f().int().positive().optional(),maxFacesScanned:f().int().positive().optional()}).optional(),S(CSe).readonly())},vocabulary:{notOperatorFacing:`the face gallery — curated on its own page`}},kN=b({reason:p(),count:f().int().nonnegative()}),AN=b({family:p(),deviceId:f().int().positive(),variant:p().optional(),sinceMs:f(),atMs:f(),attempts:f().int().nonnegative(),succeeded:f().int().nonnegative(),reasons:S(kN).readonly()}),jN={name:`failure-contribution`,scope:`system`,mode:`collection`,internal:!0,methods:{list:O(_(),S(AN).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:A.INTERNAL}},MN=x([`forward`,`reverse`]),NN=[`horizontal`,`vertical`],PN=x(NN),FN=[`oscillating`,`angle`,`sweepFrom`,`sweepTo`],IN=x(FN),LN=[`min`,`max`,`step`],RN=b({oscillating:v().nullable().default(null),angle:f().nullable().default(null),sweepFrom:f().nullable().default(null),sweepTo:f().nullable().default(null),min:f().nullable().default(null),max:f().nullable().default(null),step:f().nullable().default(null)}),zN=b({horizontal:RN.nullable().default(null),vertical:RN.nullable().default(null)}),BN=[`nothing-to-set`,`axis-not-linked`,`out-of-range`,`source-gone`,`source-unknown`,`source-call-failed`],VN=x(BN),HN=i(`status`,[b({status:o(`applied`)}),b({status:o(`refused`),reason:VN,field:IN.optional(),detail:p(),applied:S(IN)})]),UN=b({deviceId:f().int().nonnegative(),axis:PN,oscillating:v().optional(),angle:f().optional(),sweepFrom:f().optional(),sweepTo:f().optional()});function WN(e,t){return`oscillationAxes.${e}.${t}`}var GN=b({speed:f().min(0).max(100).nullable().meta(j(`percentage`)),percentageStep:f().positive().optional().meta(j(`percentage`)),preset:p(),availablePresets:S(p()),direction:MN.nullable(),oscillating:v().nullable(),oscillationAxes:zN.optional(),lastChangedAt:f()});function TSe(e){let t=e.oscillationAxes;if(t===void 0)return e.oscillating;let n=NN.flatMap(e=>{let n=t[e]?.oscillating;return n==null?[]:[n]});return n.length===0?e.oscillating:n.some(Boolean)}var KN=[w.Fan],qN=`oscillation-axes`;function ESe(e){return{id:`${e}-oscillating`,cardinality:`scalar`,vocabulary:{cap:`fan-control`,stateField:`oscillating`},deviceTypes:KN,apply:`replace`,section:qN,path:WN(e,`oscillating`),sources:[{kind:`switch`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}}function JN(e,t){let n={id:`${e}-${t}`,cardinality:`scalar`,vocabulary:{cap:`fan-control`},deviceTypes:KN,apply:`replace`,section:qN,path:WN(e,t),sources:[{kind:`numeric`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}};return t===`angle`?{...n,companions:LN.map(t=>({kind:`source-field`,path:WN(e,t),field:t}))}:n}var DSe=NN.flatMap(e=>[ESe(e),JN(e,`angle`),JN(e,`sweepFrom`),JN(e,`sweepTo`)]),OSe={id:`preset`,cardinality:`scalar`,vocabulary:{cap:`fan-control`},deviceTypes:KN,apply:`replace`,path:`preset`,sources:[{kind:`field`,valueKinds:[`string`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}},YN=[...DSe,OSe],kSe={version:1,overridable:YN.map(e=>({path:e.path,by:e.id})),targets:YN},XN={name:`fan-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Fan],methods:{setPercentage:k(b({deviceId:f().int().nonnegative(),speed:f().min(0).max(100)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.off`,label:N(`Fan off`,`Ventilatore spento`),phrase:N(`Stop {device}`,`Ferma {device}`),icon:`power-off`,effect:{field:`speed`,value:0},args:{speed:0}},{id:`fan.full`,label:N(`Fan full`,`Ventilatore al massimo`),phrase:N(`Run {device} at full speed`,`Porta {device} alla massima velocità`),icon:`fan`,effect:{field:`speed`,value:100},args:{speed:100}},{id:`fan.speed`,label:N(`Set speed`,`Imposta la velocità`),phrase:N(`Set the speed of {device} to {speed}`,`Imposta la velocità di {device} al {speed}`),icon:`fan`,effect:{field:`speed`,fromArg:`speed`},openArgs:[{key:`speed`,label:N(`Speed`,`Velocità`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setPreset:k(b({deviceId:f().int().nonnegative(),preset:p().min(1)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.preset`,label:N(`Set preset`,`Imposta il preset`),phrase:N(`Set {device} to preset {preset}`,`Imposta {device} sul preset {preset}`),icon:`list`,openArgs:[{key:`preset`,label:N(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`status`,field:`availablePresets`}}]}]}),setDirection:k(b({deviceId:f().int().nonnegative(),direction:MN}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.forward`,label:N(`Spin forward`,`Rotazione avanti`),phrase:N(`Spin {device} forward`,`Fai girare {device} in avanti`),icon:`refresh-cw`,effect:{field:`direction`,value:`forward`},args:{direction:`forward`}},{id:`fan.reverse`,label:N(`Spin in reverse`,`Rotazione inversa`),phrase:N(`Spin {device} in reverse`,`Fai girare {device} al contrario`),icon:`rotate-ccw`,effect:{field:`direction`,value:`reverse`},args:{direction:`reverse`}}]}),setOscillating:k(b({deviceId:f().int().nonnegative(),oscillating:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.oscillateOn`,label:N(`Oscillate`,`Oscillazione attiva`),phrase:N(`Make {device} oscillate`,`Fai oscillare {device}`),icon:`move-horizontal`,effect:{field:`oscillating`,value:!0},args:{oscillating:!0}},{id:`fan.oscillateOff`,label:N(`Stop oscillating`,`Oscillazione spenta`),phrase:N(`Stop {device} oscillating`,`Ferma l’oscillazione di {device}`),icon:`move-horizontal`,effect:{field:`oscillating`,value:!1},args:{oscillating:!1}}]}),setOscillationAxis:k(UN,HN,{kind:`mutation`,auth:`protected`,actions:[{id:`fan.horizontalOscillateOn`,label:N(`Horizontal oscillation on`,`Oscillazione orizzontale attiva`),phrase:N(`Start the horizontal oscillation of {device}`,`Attiva l’oscillazione orizzontale di {device}`),icon:`move-horizontal`,args:{axis:`horizontal`,oscillating:!0}},{id:`fan.horizontalOscillateOff`,label:N(`Horizontal oscillation off`,`Oscillazione orizzontale spenta`),phrase:N(`Stop the horizontal oscillation of {device}`,`Ferma l’oscillazione orizzontale di {device}`),icon:`move-horizontal`,args:{axis:`horizontal`,oscillating:!1}},{id:`fan.verticalOscillateOn`,label:N(`Vertical oscillation on`,`Oscillazione verticale attiva`),phrase:N(`Start the vertical oscillation of {device}`,`Attiva l’oscillazione verticale di {device}`),icon:`move-vertical`,args:{axis:`vertical`,oscillating:!0}},{id:`fan.verticalOscillateOff`,label:N(`Vertical oscillation off`,`Oscillazione verticale spenta`),phrase:N(`Stop the vertical oscillation of {device}`,`Ferma l’oscillazione verticale di {device}`),icon:`move-vertical`,args:{axis:`vertical`,oscillating:!1}}]})},status:{schema:GN,kind:`push`},runtimeState:GN,customize:kSe,durability:`session`,history:{fields:{speed:{kind:`gauge`,unit:`%`,minIntervalMs:0},oscillating:{kind:`boolean`}}},vocabulary:{noun:N(`Fan`,`Ventilatore`),order:1080,state:[{kind:`numeric`,field:`speed`,quantity:N(`the speed`,`la velocità`),label:N(`Speed`,`Velocità`),unit:`%`,icon:`fan`},{kind:`boolean`,field:`oscillating`,label:N(`Oscillating`,`Oscillazione`),whenTrue:N(`When {device} starts oscillating`,`Quando {device} inizia a oscillare`),whenFalse:N(`When {device} stops oscillating`,`Quando {device} smette di oscillare`),icon:`move-horizontal`}]}},ASe=12,ZN=b({oscillating:v().optional(),angle:f().optional(),sweepFrom:f().optional(),sweepTo:f().optional()}),QN=b({speed:f().min(0).max(100).optional(),preset:p().min(1).optional(),direction:MN.optional(),oscillationAxes:b({horizontal:ZN.optional(),vertical:ZN.optional()}).optional()}),$N=b({id:p().min(1).max(64),name:p().trim().min(1).max(40),state:QN}),eP=[`empty-state`,`duplicate-name`,`duplicate-id`,`too-many`,`not-a-fan`],tP=x(eP),nP=i(`status`,[b({status:o(`saved`),count:f().int().nonnegative()}),b({status:o(`refused`),reason:tP,detail:p()})]),rP=b({field:p(),outcome:x([`applied`,`failed`,`not-run`,`refused`]),message:p().optional()}),iP=b({status:x([`applied`,`partial`,`refused`]),fields:S(rP)}),aP=[`speed`,`direction`,`preset`,`oscillationAxes`],oP=x(aP),sP=b({what:p(),reason:p()}),cP=b({state:QN,omitted:S(sP)}),lP=b({deviceId:f().int().nonnegative()}),jSe={version:1,targets:[{id:`presets`,cardinality:`config`,vocabulary:{cap:`fan-presets`},deviceTypes:[w.Fan],apply:`add`,readMethod:`getPresets`,writeMethod:`setPresets`}]},uP={name:`fan-presets`,scope:`system`,mode:`singleton`,methods:{getPresets:O(lP,S($N),{auth:`protected`}),setPresets:O(lP.extend({presets:S($N).max(12)}),nP,{kind:`mutation`,auth:`admin`}),applyPreset:O(lP.extend({presetId:p().min(1)}),iP,{kind:`mutation`,auth:`protected`}),capturePreset:O(lP.extend({fields:S(oP).optional()}),cP,{auth:`protected`})},customize:jSe,vocabulary:{notOperatorFacing:`the per-fan presets — authored in the Customize presets editor, applied through the actions the exports list`}},dP=b({flags:u(p(),l()),deviceType:p().nullable(),model:p().nullable(),channelCount:f().nullable().meta(j(`count`)),lastProbedAt:f(),lastFetchedAt:f()}),fP={name:`feature-probe`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},events:{onProbeChanged:{data:b({deviceId:f(),status:dP}),notOperatorFacing:`the device’s capabilities were re-probed — plumbing, not a happening`}},status:{schema:dP,kind:`push`},runtimeState:dP,durability:`session`,history:`none`,vocabulary:{noun:N(`Feature probe`,`Rilevamento funzioni`),order:3120}},MSe=b({name:p(),path:p()}),NSe=b({path:p(),entries:S(MSe).readonly(),freeBytes:f(),totalBytes:f()}),pP={name:`filesystem-browse`,scope:`system`,mode:`singleton`,internal:!0,methods:{listAllowedRoots:O(_(),S(p()).readonly(),{auth:`admin`}),browse:O(b({path:p()}),NSe,{auth:`admin`}),createDir:O(b({path:p()}),b({path:p()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:A.INTERNAL}},mP=b({flooded:v(),lastChangedAt:f()}),hP={name:`flood`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Sensor],methods:{},status:{schema:mP,kind:`push`},runtimeState:mP,durability:`restored`,history:{fields:{flooded:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:N(`Leak sensor`,`Sensore di allagamento`),order:5070,state:[{kind:`boolean`,field:`flooded`,label:N(`Leak`,`Perdita`),whenTrue:N(`When {device} detects a leak`,`Quando {device} rileva una perdita`),whenFalse:N(`When {device} is dry again`,`Quando {device} torna asciutto`),icon:`droplets`}]}},gP=b({detected:v(),lastChangedAt:f()}),_P={name:`gas`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Sensor],methods:{},status:{schema:gP,kind:`push`},runtimeState:gP,durability:`restored`,history:{fields:{detected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:N(`Gas sensor`,`Sensore di gas`),order:5080,state:[{kind:`boolean`,field:`detected`,label:N(`Detected`,`Rilevato`),whenTrue:N(`When {device} detects gas`,`Quando {device} rileva gas`),whenFalse:N(`When the gas clears on {device}`,`Quando il gas su {device} rientra`),icon:`flame`}]}},vP=b({active:v().meta({label:`Active`}),lastChangedAt:f()}),yP={name:`group-active`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Cover,w.Valve,w.Lock,w.MediaPlayer,w.Climate],methods:{},status:{schema:vP,kind:`push`},runtimeState:vP,durability:`session`,history:`none`,vocabulary:{noun:N(`Group state`,`Stato del gruppo`),order:5090}},bP=b({deviceId:f().int().nonnegative(),cap:p().min(1),method:p().min(1),ok:v(),error:p().optional(),at:f()}),xP=b({results:S(bP)}),SP={name:`group-commands`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Switch,w.Light,w.Fan,w.Cover,w.Valve,w.Lock,w.MediaPlayer,w.Climate],methods:{},status:{schema:xP,kind:`push`},runtimeState:xP,durability:`session`,history:`none`,vocabulary:{noun:N(`Group command`,`Comando di gruppo`),order:5100}},CP=b({included:f().int().nonnegative().meta(j(`count`,{precision:0,label:`Reporting`})),excluded:f().int().nonnegative().meta(j(`count`,{precision:0,label:`Excluded`})),total:f().int().nonnegative().meta(j(`count`,{precision:0,label:`Members`}))}),wP={name:`group-status`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Sensor,w.Switch,w.Light,w.Fan,w.Cover,w.Valve,w.Lock,w.MediaPlayer,w.Climate],methods:{},status:{schema:CP,kind:`push`},runtimeState:CP,durability:`session`,history:`none`,vocabulary:{noun:N(`Group`,`Gruppo`),order:5110,state:[{kind:`numeric`,field:`included`,quantity:N(`the members reporting`,`i membri che rispondono`),label:N(`Reporting`,`Rispondono`),icon:`users`},{kind:`numeric`,field:`excluded`,quantity:N(`the members left out`,`i membri esclusi`),label:N(`Excluded`,`Esclusi`),icon:`users`},{kind:`numeric`,field:`total`,quantity:N(`the member count`,`il numero di membri`),label:N(`Members`,`Membri`),icon:`sigma`}]}},TP=f().int().nonnegative(),EP=p().min(1),DP=p().min(1),OP=f().finite(),kP={key:`circuitId`,label:N(`Circuit`,`Circuito`),offer:{kind:`dynamic`,from:`status`,cap:`heat-pump-status`,field:`circuits`,valueKey:`id`,labelKey:`label`,where:{key:`kind`,equals:`heating`}}},AP={...kP,label:N(`Hot water circuit`,`Circuito acqua calda`),offer:{...kP.offer,where:{key:`kind`,equals:`dhw`}}},jP={key:`mode`,label:N(`Mode`,`Modalità`),offer:{kind:`text`}},PSe={key:`level`,label:N(`Level`,`Livello`),offer:{kind:`text`}},MP={key:`temp`,label:N(`Temperature`,`Temperatura`),offer:{kind:`number`,step:.5,unit:`°C`}},FSe={key:`minutes`,label:N(`Minutes`,`Minuti`),offer:{kind:`number`,min:1,step:1,unit:`min`}},NP={name:`heat-pump-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.HeatPump],methods:{setSilentMode:O(b({deviceId:TP,mode:DP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.silent`,label:N(`Set silent mode`,`Imposta la modalità silenziosa`),phrase:N(`Set silent mode of {device} to {mode}`,`Imposta la modalità silenziosa di {device} su {mode}`),icon:`volume-x`,openArgs:[{key:`mode`,label:N(`Silent mode`,`Modalità silenziosa`),offer:{kind:`enum`,values:[{value:`off`,label:N(`Off`,`Off`)},{value:`auto`,label:N(`Auto`,`Auto`)},{value:`on`,label:N(`On`,`On`)}]}}]}]}),setAwayMode:O(b({deviceId:TP,mode:DP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.away`,label:N(`Set away mode`,`Imposta la modalità assente`),phrase:N(`Set away mode of {device} to {mode}`,`Imposta la modalità assente di {device} su {mode}`),icon:`plane`,openArgs:[{key:`mode`,label:N(`Away mode`,`Modalità assente`),offer:{kind:`enum`,values:[{value:`off`,label:N(`Off`,`Off`)},{value:`on`,label:N(`On`,`On`)}]}}]}]}),setAdditionalHeaterMode:O(b({deviceId:TP,mode:DP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.additionalHeater`,label:N(`Set additional heater`,`Imposta il riscaldatore aggiuntivo`),phrase:N(`Set the additional heater of {device} to {mode}`,`Imposta il riscaldatore aggiuntivo di {device} su {mode}`),icon:`flame`,openArgs:[{key:`mode`,label:N(`Additional heater`,`Riscaldatore aggiuntivo`),offer:{kind:`enum`,values:[{value:`off`,label:N(`Off`,`Off`)},{value:`manual`,label:N(`Manual`,`Manuale`)},{value:`auto`,label:N(`Auto`,`Auto`)}]}}]}]}),setHolidayMode:O(b({deviceId:TP,mode:DP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.holiday`,label:N(`Set holiday mode`,`Imposta la modalità vacanza`),phrase:N(`Set holiday mode of {device} to {mode}`,`Imposta la modalità vacanza di {device} su {mode}`),icon:`tree-palm`,openArgs:[{key:`mode`,label:N(`Holiday programme`,`Programma vacanza`),offer:{kind:`enum`,values:[{value:`off`,label:N(`Off`,`Off`)},{value:`hm1`,label:N(`Programme 1`,`Programma 1`)},{value:`hm2`,label:N(`Programme 2`,`Programma 2`)},{value:`hm3`,label:N(`Programme 3`,`Programma 3`)},{value:`hm4`,label:N(`Programme 4`,`Programma 4`)},{value:`hm5`,label:N(`Programme 5`,`Programma 5`)},{value:`hm6`,label:N(`Programme 6`,`Programma 6`)},{value:`hm7`,label:N(`Programme 7`,`Programma 7`)},{value:`hm8`,label:N(`Programme 8`,`Programma 8`)}]}}]}]}),setCircuitOperationMode:O(b({deviceId:TP,circuitId:EP,mode:DP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitOperationMode`,label:N(`Set circuit operation mode`,`Imposta la modalità del circuito`),phrase:N(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`thermometer`,openArgs:[kP,jP]}]}),setCircuitHeatCoolMode:O(b({deviceId:TP,circuitId:EP,mode:DP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitHeatCoolMode`,label:N(`Set circuit heat / cool`,`Imposta caldo / freddo del circuito`),phrase:N(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`sun-snow`,openArgs:[kP,jP]}]}),setCircuitSummerWinter:O(b({deviceId:TP,circuitId:EP,mode:DP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitSummerWinter`,label:N(`Set circuit summer / winter`,`Imposta estate / inverno del circuito`),phrase:N(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`sun`,openArgs:[kP,jP]}]}),setCircuitComfortSetpoint:O(b({deviceId:TP,circuitId:EP,temp:OP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitComfortSetpoint`,label:N(`Set comfort temperature`,`Imposta la temperatura comfort`),phrase:N(`Set the comfort temperature of {circuitId} on {device} to {temp}`,`Imposta la temperatura comfort di {circuitId} su {device} a {temp}`),icon:`thermometer-sun`,openArgs:[kP,MP]}]}),setCircuitEcoSetpoint:O(b({deviceId:TP,circuitId:EP,temp:OP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitEcoSetpoint`,label:N(`Set eco temperature`,`Imposta la temperatura eco`),phrase:N(`Set the eco temperature of {circuitId} on {device} to {temp}`,`Imposta la temperatura eco di {circuitId} su {device} a {temp}`),icon:`leaf`,openArgs:[kP,MP]}]}),setCircuitMaxFlowTemp:O(b({deviceId:TP,circuitId:EP,temp:OP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitMaxFlowTemp`,label:N(`Set maximum flow temperature`,`Imposta la temperatura massima di mandata`),phrase:N(`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:[kP,MP]}]}),setDhwOperationMode:O(b({deviceId:TP,circuitId:EP,mode:DP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwOperationMode`,label:N(`Set hot water mode`,`Imposta la modalità acqua calda`),phrase:N(`Set hot water {circuitId} of {device} to {mode}`,`Imposta l'acqua calda {circuitId} di {device} su {mode}`),icon:`shower-head`,openArgs:[AP,jP]}]}),setDhwTemperatureLevel:O(b({deviceId:TP,circuitId:EP,level:DP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwTemperatureLevel`,label:N(`Set hot water level`,`Imposta il livello acqua calda`),phrase:N(`Set hot water {circuitId} of {device} to level {level}`,`Imposta l'acqua calda {circuitId} di {device} al livello {level}`),icon:`droplet`,openArgs:[AP,PSe]}]}),setDhwChargeDuration:O(b({deviceId:TP,circuitId:EP,minutes:f().int().positive()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwChargeDuration`,label:N(`Set hot water charge duration`,`Imposta la durata della carica acqua calda`),phrase:N(`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:[AP,FSe]}]}),startExtraHotWater:O(b({deviceId:TP,circuitId:EP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.extraHotWater`,label:N(`Start extra hot water`,`Avvia acqua calda extra`),phrase:N(`Start an extra hot water charge of {circuitId} on {device}`,`Avvia una carica extra di acqua calda {circuitId} su {device}`),icon:`droplets`,openArgs:[AP]}]})},vocabulary:{noun:N(`Heat pump settings`,`Impostazioni pompa di calore`),order:4010}},PP=[`heating`,`dhw`,`cooling`,`solar`],FP=x(PP),IP=b({value:p().nullable(),allowed:S(p())}),LP=b({value:f().nullable(),min:f().nullable(),max:f().nullable(),step:f().nullable()}),RP=b({id:p().min(1),kind:FP,label:p(),icon:$m,currentTemp:f().nullable().meta(j(`temperature`)),targetTemp:f().nullable().meta(j(`temperature`)),mode:p().nullable(),active:v().nullable(),operationMode:IP.nullable(),heatCoolMode:IP.nullable(),summerWinter:IP.nullable(),comfortSetpoint:LP.nullable(),ecoSetpoint:LP.nullable(),maxFlowTemp:LP.nullable(),temperatureLevel:IP.nullable(),chargeDuration:LP.nullable(),extraHotWater:v().nullable()}),zP=b({silent:IP.nullable(),away:IP.nullable(),additionalHeater:IP.nullable(),holiday:IP.nullable()}),BP=b({thermalW:f().nullable().meta(j(`power`)),electricalW:f().nullable().meta(j(`power`)),compressorPct:f().nullable().meta(j(`percentage`))}),VP=b({supply:f().nullable().meta(j(`temperature`)),return:f().nullable().meta(j(`temperature`)),outdoor:f().nullable().meta(j(`temperature`))}),HP=b({thermalKwh:f().nullable().meta(j(`energy`)),electricalKwh:f().nullable().meta(j(`energy`))}),UP=b({circuits:S(RP),system:zP,power:BP,temperatures:VP,energy:HP,waterPressureBar:f().nullable(),starts:f().nullable(),lastFetchedAt:f()});function WP(e){let{thermalW:t,electricalW:n}=e;return t===null||n===null||n<=0?null:t/n}var GP={name:`heat-pump-status`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.HeatPump],methods:{},status:{schema:UP,kind:`push`},runtimeState:UP,durability:`session`,history:{fields:{"power.thermalW":{group:`power`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Thermal power`},"power.electricalW":{group:`power`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Electrical power`},"power.compressorPct":{kind:`gauge`,unit:`%`,deadband:2,displayName:`Compressor`},"temperatures.supply":{group:`loop`,kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Supply`},"temperatures.return":{group:`loop`,kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Return`},"temperatures.outdoor":{kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Outdoor`},"energy.thermalKwh":{kind:`counter`,unit:`kWh`,displayName:`Thermal energy`},"energy.electricalKwh":{kind:`counter`,unit:`kWh`,displayName:`Electrical energy`}},items:{path:`circuits`,key:`id`,label:`label`,fields:{currentTemp:{kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Temperature`},targetTemp:{kind:`gauge`,unit:`°C`,minIntervalMs:0,displayName:`Setpoint`},mode:{kind:`enum`,displayName:`Mode`}}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:N(`Heat pump`,`Pompa di calore`),order:4e3}},KP=b({position:f().min(0).max(100).nullable().meta(j(`percentage`)),lastFetchedAt:f()}),qP={name:`heating-valve`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Climate],methods:{},status:{schema:KP,kind:`push`},runtimeState:KP,durability:`session`,history:{fields:{position:{kind:`gauge`,unit:`%`,deadband:1}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:N(`Radiator valve`,`Valvola termostatica`),order:1110,state:[{kind:`numeric`,field:`position`,quantity:N(`the valve opening`,`l’apertura della valvola`),label:N(`Valve opening`,`Apertura della valvola`),unit:`%`,icon:`heater`}]}},JP=x([`s`,`min`]),ISe=x([`switch`,`pet-fountain`]),YP={actuator:`switch`,maxSeconds:10800,unit:`min`,quickRunDefault:30},XP={actuator:`pet-fountain`,maxSeconds:300,unit:`s`,quickRunDefault:60},ZP=[w.Switch,w.PetFountain],QP={[w.Switch]:[E.SwitchHeater]};function $P(e,t){return e===w.PetFountain?XP:e===w.Switch&&t===E.SwitchHeater?YP:null}var LSe=1e3,RSe=6e4;function eF(e,t,n){let r=e-t;return r<=0?0:Math.max(1,Math.ceil(r/(n===`min`?RSe:LSe)))}function zSe(e,t){return t===`min`?e*60:e}function tF(e){return e.unit===`min`?Math.floor(e.maxSeconds/60):e.maxSeconds}var nF=b({duration:f().positive().finite(),unit:JP});function rF(e,t){let n=tF(e);return{duration:Math.min((t!==null&&Number.isFinite(t)&&t>0?t:null)??e.quickRunDefault,n),unit:e.unit}}var iF=x([`unsupported-device`,`over-max`,`command-failed`]),aF=i(`ok`,[b({ok:o(!0),activeUntil:f()}),b({ok:o(!1),reason:iF,maxSeconds:f().nullable()})]),oF=b({activeUntil:f().nullable(),requestedBy:p().nullable(),quickRun:nF.nullable(),lastFetchedAt:f()}),sF=b({unit:JP,maxDuration:f(),defaultDuration:f()}),cF=b({quickRunDuration:f().positive().finite().nullable().optional()}),lF={name:`timed-run`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:ZP,deviceRoles:QP,deviceConfig:{ui:{kind:`derived-form`,builderId:`timed-run`,tab:`general`}},methods:{getOptions:O(b({deviceId:f().int()}),sF),setSettings:O(b({deviceId:f().int(),settings:cF}),_(),{kind:`mutation`,auth:`admin`}),runFor:O(b({deviceId:f().int(),duration:f().positive().finite(),unit:JP}),aF,{kind:`mutation`,auth:`protected`,actions:[{id:`timedRun.runForMinutes`,label:N(`Run for minutes`,`Accendi per alcuni minuti`),phrase:N(`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:N(`Minutes`,`Minuti`),offer:{kind:`number`,min:1,step:1,unit:`min`}}]},{id:`timedRun.runForSeconds`,label:N(`Run for seconds`,`Accendi per alcuni secondi`),phrase:N(`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:N(`Seconds`,`Secondi`),offer:{kind:`number`,min:1,step:1,unit:`s`}}]}]}),cancel:O(b({deviceId:f().int()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`timedRun.cancel`,label:N(`Cancel the timer`,`Annulla il timer`),phrase:N(`Cancel the pending switch-off of {device}`,`Annulla lo spegnimento programmato di {device}`),icon:`timer-off`}]})},status:{schema:oF,kind:`push`},runtimeState:oF,durability:`session`,history:`none`,vocabulary:{noun:N(`Timed run`,`Esecuzione a tempo`),order:2150}},uF=[`on`,`off`,`running`,`idle`,`standby`,`alert`,`offline`,`unknown`],dF=[`success`,`warning`,`danger`,`primary`,`info`,`muted`],fF=[`none`,`pulse`,`spin`,`glow`,`halo`,`wave`,`rise`,`fall`,`tumble`,`equalizer`,`blink`,`breathe`],pF=[`plain`,`heat-rise`,`cool-fall`,`glow`,`water`,`drum`,`sky`,`mist`,`alert-wash`],mF=x(uF),hF=x(dF),BSe=x(fF),gF=b({icon:$m,tone:hF,background:x(pF),animation:BSe});function _F(e){let t=OD[e];return t===void 0?null:`cap:${e}.${t.field}`}function VSe(e){return e.enabledCaps.flatMap(e=>{let t=_F(e),n=OD[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 vF=b({en:p(),it:p()}),yF={en:`—`,it:`—`};function HSe(e){return e.en===yF.en&&e.it===yF.it}var bF=[`temperature`,`humidity`,`power`,`contact`,`text`],xF=[`hot`,`mild`,`cold`],SF=[`updated`,`changed`],CF=b({value:f(),quantity:Hi}),wF=b({quantity:x(bF),reading:CF.nullable(),icon:$m.nullable(),value:vF,unit:p().nullable(),band:x(xF).nullable(),level:f().min(0).max(1).nullable(),word:vF,tone:x(dF),since:f().nullable(),sinceKind:x(SF),historyKey:p().nullable()}),USe=3e3,TF=e=>N(e,e),EF=e=>Math.min(1,Math.max(0,e)),WSe=(e,t)=>String(Number(e.toFixed(t)));function DF(e){return e<12?`cold`:e>28?`hot`:`mild`}var GSe={hot:N(`Hot`,`Caldo`),mild:N(`Normal`,`Normale`),cold:N(`Cold`,`Freddo`)},KSe={hot:`warning`,mild:`muted`,cold:`info`};function OF(e,t){let n=DF(e);return{quantity:`temperature`,reading:{value:e,quantity:`temperature`},icon:`thermometer`,value:TF(WSe(e,1)),unit:`°C`,band:n,level:null,word:GSe[n],tone:KSe[n],since:t,sinceKind:`updated`,historyKey:_F(`temperature-sensor`)}}function kF(e,t){let n=e<30,r=e>70;return{quantity:`humidity`,reading:{value:e,quantity:`humidity`},icon:`droplets`,value:TF(String(Math.round(e))),unit:`%`,band:null,level:EF(e/100),word:n?N(`Dry`,`Secco`):r?N(`Humid`,`Umido`):N(`Normal`,`Normale`),tone:n||r?`warning`:`info`,since:t,sinceKind:`updated`,historyKey:_F(`humidity-sensor`)}}function AF(e,t){let n=e>0;return{quantity:`power`,reading:{value:e,quantity:`power`},icon:`zap`,value:TF(String(Math.round(e))),unit:`W`,band:null,level:EF(e/USe),word:n?N(`Active`,`Attivo`):N(`Idle`,`Inattivo`),tone:n?`primary`:`muted`,since:t,sinceKind:`updated`,historyKey:_F(`power-meter`)}}function jF(e,t){return{quantity:`contact`,reading:null,icon:e?`door-open`:`door-closed`,value:e?N(`Open`,`Aperto`):N(`Closed`,`Chiuso`),unit:null,band:null,level:+!!e,word:e?N(`Open`,`Aperto`):N(`Closed`,`Chiuso`),tone:e?`warning`:`success`,since:t,sinceKind:`changed`,historyKey:null}}function MF(e,t){return{quantity:`text`,reading:null,icon:null,value:TF(e),unit:null,band:null,level:null,word:N(`Changed`,`Cambiato`),tone:`muted`,since:t,sinceKind:`updated`,historyKey:null}}var qSe={temperature:{icon:`thermometer`,unit:`°C`,sinceKind:`updated`,historyKey:_F(`temperature-sensor`)},humidity:{icon:`droplets`,unit:`%`,sinceKind:`updated`,historyKey:_F(`humidity-sensor`)},power:{icon:`zap`,unit:`W`,sinceKind:`updated`,historyKey:_F(`power-meter`)},contact:{icon:null,unit:null,sinceKind:`changed`,historyKey:null},text:{icon:null,unit:null,sinceKind:`updated`,historyKey:null}};function NF(e){let t=qSe[e];return{quantity:e,reading:null,icon:t.icon,value:yF,unit:t.unit,band:null,level:null,word:yF,tone:`muted`,since:null,sinceKind:t.sinceKind,historyKey:t.historyKey}}var JSe={power:new Set([`energy-sensor`,`voltage-sensor`,`current-sensor`])};function PF(e,t){return t===null?!0:!(JSe[e.quantity]?.has(t)??!1)}var FF=`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(`.`),YSe=x(FF),IF=[`cool`,`heat`,`dry`,`fan`,`auto`,`playing`,`paused`,`open`,`closed`],LF=b({id:YSe,mode:x(IF).nullable(),level:f().min(0).max(1).nullable()}),RF={[w.Camera]:`camera`,[w.Light]:`light`,[w.Siren]:`siren`,[w.Switch]:`plug`,[w.Sensor]:`sensor-sparkline`,[w.Climate]:`thermostat`,[w.Button]:`button`,[w.EventEmitter]:`event-stream`,[w.Update]:`update`,[w.Generic]:`generic`,[w.Notifier]:`event-stream`,[w.Script]:`event-stream`,[w.Automation]:`event-stream`,[w.Lock]:`lock`,[w.Cover]:`cover`,[w.Valve]:`control-dial`,[w.Humidifier]:`control-dial`,[w.WaterHeater]:`heater`,[w.HeatPump]:`heat-pump`,[w.EnergySystem]:`generic`,[w.Fan]:`fan`,[w.MediaPlayer]:`tv`,[w.AlarmPanel]:`alarm`,[w.Control]:`control-dial`,[w.Presence]:`presence`,[w.Weather]:`weather`,[w.WeatherStation]:`weather`,[w.Vacuum]:`vacuum`,[w.LawnMower]:`lawn-mower`,[w.Container]:`generic`,[w.Image]:`camera`,[w.PetFeeder]:`pet-feeder`,[w.PetFountain]:`pet-fountain`,[w.Dishwasher]:`dishwasher`,[w.Washer]:`washer`,[w.Dryer]:`dryer`,[w.Gateway]:`gateway`},zF={[E.Siren]:`siren`,[E.Floodlight]:`light`,[E.Spotlight]:`light`,[E.PirSensor]:`presence`,[E.Chime]:`speaker`,[E.Autotrack]:`inherit`,[E.Nightvision]:`inherit`,[E.PrivacyMask]:`inherit`,[E.Doorbell]:`inherit`,[E.CoverBlind]:`inherit`,[E.CoverShutter]:`inherit`,[E.CoverAwning]:`inherit`,[E.CoverCurtain]:`inherit`,[E.CoverGarage]:`inherit`,[E.CoverGate]:`inherit`,[E.CoverDoor]:`inherit`,[E.CoverWindow]:`inherit`,[E.BinaryHelper]:`inherit`,[E.Outlet]:`plug`,[E.SwitchHeater]:`heater`,[E.SwitchFan]:`fan`,[E.SwitchLight]:`light`,[E.ClimateAc]:`ac`,[E.ClimateThermostat]:`inherit`,[E.ClimateFloor]:`inherit`,[E.ClimateRadiator]:`inherit`,[E.ClimateHeater]:`inherit`,[E.ClimateHeatPumpCircuit]:`inherit`,[E.MotionSensor]:`presence`,[E.ContactSensor]:`contact`,[E.LeakSensor]:`inherit`,[E.SmokeSensor]:`alarm`,[E.COSensor]:`alarm`,[E.GasSensor]:`alarm`,[E.TamperSensor]:`inherit`,[E.VibrationSensor]:`inherit`,[E.ConnectivitySensor]:`inherit`,[E.SoundSensor]:`inherit`,[E.BinarySensor]:`inherit`,[E.TemperatureSensor]:`sensor-sparkline`,[E.HumiditySensor]:`sensor-sparkline`,[E.AmbientLightSensor]:`inherit`,[E.PressureSensor]:`weather`,[E.WindSensor]:`weather`,[E.RainSensor]:`weather`,[E.UvSensor]:`weather`,[E.SolarRadiationSensor]:`weather`,[E.SoilMoistureSensor]:`inherit`,[E.PowerSensor]:`plug`,[E.EnergySensor]:`plug`,[E.VoltageSensor]:`plug`,[E.CurrentSensor]:`plug`,[E.AirQualitySensor]:`inherit`,[E.BatterySensor]:`inherit`,[E.NumericSensor]:`inherit`,[E.EnumSensor]:`inherit`,[E.DateTimeSensor]:`inherit`,[E.GenericSensor]:`inherit`,[E.NumericControl]:`control-dial`,[E.SelectControl]:`control-dial`,[E.TextControl]:`inherit`,[E.DateTimeControl]:`inherit`,[E.MobilePushNotifier]:`inherit`,[E.MessagingNotifier]:`inherit`,[E.EmailNotifier]:`inherit`,[E.GenericNotifier]:`inherit`,[E.IrTransmitter]:`inherit`};function XSe(e){return Object.values(w).includes(e)}function ZSe(e){return Object.values(E).includes(e)}function BF(e,t){let n=e!==null&&ZSe(e)?zF[e]:void 0;return n!==void 0&&n!==`inherit`?n:XSe(t)?RF[t]:`generic`}var VF=`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(`.`),HF=x(VF),QSe={progress:N(`Progress`,`Avanzamento`),"run-for":N(`Run for`,`Avvia per`),cycle:N(`Cycle`,`Ciclo`),program:N(`Program`,`Programma`),"appliance-power":N(`Appliance`,`Elettrodomestico`),"now-playing":N(`Now playing`,`In riproduzione`),playback:N(`Playback`,`Riproduzione`),volume:N(`Volume`,`Volume`),source:N(`Source`,`Sorgente`),contact:N(`Door`,`Porta`),"motion-trigger":N(`Motion`,`Movimento`),lock:N(`Lock`,`Serratura`),alarm:N(`Alarm`,`Allarme`),fan:N(`Fan`,`Ventola`),vacuum:N(`Cleaning`,`Pulizia`),"vacuum-suction":N(`Suction`,`Aspirazione`),mower:N(`Mowing`,`Taglio`),feeder:N(`Feed now`,`Eroga ora`),fountain:N(`Pump`,`Pompa`),"pump-cycle":N(`Pump cycle`,`Ciclo pompa`),automation:N(`Automation`,`Automazione`),script:N(`Script`,`Script`),"do-not-disturb":N(`Do not disturb`,`Non disturbare`),brightness:N(`Brightness`,`Luminosità`),color:N(`Colour`,`Colore`),cover:N(`Position`,`Posizione`),valve:N(`Valve`,`Valvola`),humidifier:N(`Humidifier`,`Umidificatore`),update:N(`Firmware`,`Firmware`),button:N(`Action`,`Azione`),"climate-mode":N(`Mode`,`Modalità`),"climate-fan":N(`Fan`,`Ventola`),setpoint:N(`Setpoint`,`Temperatura`),channel:N(`Channel`,`Canale`),control:N(`Control`,`Controllo`),circuit:N(`Circuit`,`Circuito`),"heat-pump-power":N(`Power`,`Potenza`),"system-mode":N(`Mode`,`Modalità`)},UF=g(()=>c([p(),f(),v(),u(p(),UF)])),$Se=u(p(),UF);function WF(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]:WF(o,i,n)}}function eCe(e,t,n){return WF(e,t.split(`.`),n)}var GF=b({cap:p(),method:p(),args:$Se}),tCe=x([`off-while-running`,`unlock`,`install`,`press`]),KF=b({id:p(),label:vF,icon:$m,call:GF,emphasis:x([`primary`,`normal`]),confirm:tCe.nullable()}),qF=i(`kind`,[b({kind:o(`action`),action:KF}),b({kind:o(`toggle`),id:p(),label:vF,on:v().nullable(),turnOn:KF,turnOff:KF}),b({kind:o(`slider`),id:p(),label:vF,value:f().nullable(),min:f(),max:f(),step:f(),unit:p(),call:GF,valueArg:p()}),b({kind:o(`picker`),id:p(),label:vF,current:p().nullable(),options:S(p()),optionLabels:u(p(),vF).optional(),call:GF,valueArg:p()}),b({kind:o(`number`),id:p(),label:vF,value:f().nullable(),step:f().nullable(),unit:p(),call:GF,valueArg:p()}),b({kind:o(`text`),id:p(),label:vF,value:p().nullable(),call:GF,valueArg:p()})]),nCe=b({icon:$m.nullable(),text:vF,tone:hF}),rCe=new Set([`cover`,`valve`,`lock`,`vacuum`,`playback`,`brightness`]),iCe=b({id:HF,placement:x([`row`,`scene`]).optional(),label:vF.optional(),group:vF.optional(),pills:S(nCe).optional(),icon:$m,status:vF.nullable(),controls:S(qF),progress:f().min(0).max(1).nullable().optional()}),JF=b({label:vF,value:c([f(),p()]),unit:p().nullable()}),aCe=b({id:x([`battery`,`network-link`,`integration`]),icon:$m,tone:hF,value:f().nullable(),label:vF}),YF=`remote.open`,oCe=b({commands:f().int().nullable(),open:KF.optional()}),sCe=b({items:S(b({key:p(),label:p(),level:f().nullable(),needsAttention:v()})),attention:f().int()}),cCe=i(`kind`,[b({kind:o(`power`),watts:f(),detail:S(JF)}),b({kind:o(`running`),running:v().nullable(),since:f().nullable(),phase:p().nullable(),detail:S(JF)})]),lCe=b({source:x([`switch`,`media-player`,`climate-control`]),on:v().nullable(),assumed:v(),turnOn:KF,turnOff:KF}),uCe=b({activeUntil:f().nullable(),quickRun:nF,run:KF,cancel:KF,remaining:f().nullable()}),dCe=b({on:v().nullable(),confirmOffWhileRunning:v(),running:v().nullable(),powerOn:KF,powerOff:KF,restart:KF}),XF=b({token:x(pF),animation:x(fF)}),ZF=b({id:x([`power`,`energy`,`battery`,`link`,`phase`,`remaining`,`volume`,`source`,`consumables`,`since`,`speed`,`progress`,`level`,`last-run`,`event`,`members`,`failures`,`reading`,`climate`,`temperature`,`humidity`,`pressure`,`air-quality`,`illuminance`,`valve`]),icon:$m.nullable(),text:vF,tone:hF}),QF=b({label:vF,value:vF,tone:hF.optional(),at:f().optional()}),fCe=b({left:S(QF).max(2),right:S(QF).max(2)}),pCe=i(`kind`,[b({kind:o(`artwork`),url:p(),fallback:XF}),b({kind:o(`state`),...XF.shape})]),mCe=b({partId:p(),cap:p()}),hCe=b({deviceId:f().int(),type:p(),role:p().nullable(),name:p(),state:mF,stateAssumed:v(),look:gF,background:pCe,scene:LF,facts:S(ZF),sideTiles:fCe,title:vF,caption:vF.optional(),badges:S(aCe),remote:oCe.nullable(),historyLabel:vF,consumables:sCe.nullable(),consumption:cCe.nullable(),ownPower:lCe.nullable(),timedRun:uCe.nullable(),powerSupply:dCe.nullable(),rows:S(iCe),measurement:wF.optional(),gated:S(p()),provenance:S(mCe)}),gCe=b({id:x([`timed-run.run`,`timed-run.cancel`]),duration:f(),unit:x([`min`,`s`])}),$F=b({deviceId:f().int(),name:p(),type:p(),state:mF,stateAssumed:v(),look:gF,scene:LF,statusLine:S(vF),primary:qF.nullable(),primaryGated:v().optional(),timedRun:gCe.nullable(),extras:S(qF).max(2).optional(),trailing:ZF.nullable(),measurement:wF.optional()}),eI=[`temperature`,`humidity`,`pressure`,`illuminance`,`reading`,`air-quality`,`valve`],_Ce=[`power`,`battery`,`consumables`],vCe=new Set(eI);function yCe(e){for(let t of _Ce){let n=e.facts.find(e=>e.id===t);if(n!==void 0)return n}return e.facts.find(t=>vCe.has(t.id)&&t.text.en===e.title.en)??null}var bCe={[w.Climate]:`climate.mode`};function xCe(e){let t=bCe[e.type];if(t!==void 0){let n=nI(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 SCe={[w.Climate]:[`climate.target`],[w.Vacuum]:[`vacuum.base`],[w.LawnMower]:[`mower.dock`],[w.MediaPlayer]:[`volume.level`,YF],[w.Automation]:[`automation.enabled`]},tI=e=>e.kind===`action`?e.action.id:e.id;function nI(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=>tI(e)===t);if(r!==void 0)return r}return null}function CCe(e,t){let n=SCe[e.type]??[],r=t===null?null:tI(t);return n.filter(e=>e!==r).flatMap(t=>{let n=nI(e,t);return n===null?[]:[n]}).slice(0,2)}function wCe(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 TCe(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 ECe(e){let t=yCe(e),{control:n,gated:r}=xCe(e);return{deviceId:e.deviceId,name:e.name,type:e.type,state:e.state,stateAssumed:e.stateAssumed,look:e.look,scene:e.scene,statusLine:wCe(e,t),primary:n,primaryGated:r,timedRun:TCe(e),extras:CCe(e,n),trailing:t,...e.measurement===void 0?{}:{measurement:e.measurement}}}var DCe=b({deviceId:f().int().nonnegative(),canActuate:v().optional()}),OCe=500,kCe=b({deviceIds:S(f().int().nonnegative()).max(500),canActuate:v().optional()}),rI=b({type:p(),rows:S(HF)}),iI={name:`hero-layout`,scope:`system`,mode:`singleton`,methods:{getHeroModel:O(DCe,hCe.nullable(),{auth:`protected`,role:`viewer`}),getRowModels:O(kCe,S($F.nullable()),{auth:`protected`,role:`viewer`}),getLayout:O(b({deviceType:p(),role:p().nullable().optional()}),rI,{auth:`protected`,role:`viewer`})},vocabulary:{notOperatorFacing:`the device hero model — read-only data the UI draws, never actuated`}},aI=b({on:v(),currentHumidity:f().min(0).max(100).nullable().meta(j(`humidity`)),targetHumidity:f().min(0).max(100).nullable().meta(j(`humidity`)),mode:p().nullable(),availableModes:S(p()),action:p().nullable(),minHumidity:f().nullable().meta(j(`humidity`)),maxHumidity:f().nullable().meta(j(`humidity`)),lastChangedAt:f()}),oI={name:`humidifier`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Humidifier],power:{kind:`field`,field:`on`,set:`setOn`},methods:{setOn:O(b({deviceId:f().int().nonnegative(),on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.on`,label:N(`Humidifier on`,`Umidificatore acceso`),phrase:N(`Turn on {device}`,`Accendi {device}`),icon:`power`,effect:{field:`on`,value:!0},args:{on:!0}},{id:`humidifier.off`,label:N(`Humidifier off`,`Umidificatore spento`),phrase:N(`Turn off {device}`,`Spegni {device}`),icon:`power-off`,effect:{field:`on`,value:!1},args:{on:!1}}]}),setTargetHumidity:O(b({deviceId:f().int().nonnegative(),humidity:f().min(0).max(100)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.target`,label:N(`Set humidity`,`Imposta l’umidità`),phrase:N(`Set {device} to {humidity} humidity`,`Imposta {device} al {humidity} di umidità`),icon:`droplets`,effect:{field:`targetHumidity`,fromArg:`humidity`},openArgs:[{key:`humidity`,label:N(`Humidity`,`Umidità`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setMode:O(b({deviceId:f().int().nonnegative(),mode:p().min(1)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.mode`,label:N(`Set mode`,`Imposta la modalità`),phrase:N(`Set {device} to {mode}`,`Imposta {device} su {mode}`),icon:`list`,effect:{field:`mode`,fromArg:`mode`},openArgs:[{key:`mode`,label:N(`Mode`,`Modalità`),offer:{kind:`dynamic`,from:`status`,field:`availableModes`}}]}]})},status:{schema:aI,kind:`push`},runtimeState:aI,durability:`session`,history:{fields:{currentHumidity:{kind:`gauge`,unit:`%`,deadband:.5},on:{kind:`boolean`}}},vocabulary:{noun:N(`Humidifier`,`Umidificatore`),order:1090,state:[{kind:`boolean`,field:`on`,label:N(`On`,`Acceso`),whenTrue:N(`When {device} turns on`,`Quando {device} si accende`),whenFalse:N(`When {device} turns off`,`Quando {device} si spegne`),icon:`power`},{kind:`numeric`,field:`currentHumidity`,quantity:N(`the humidity`,`l’umidità`),label:N(`Humidity`,`Umidità`),unit:`%`,icon:`droplets`}]}},sI=b({humidity:f().min(0).max(100).nullable().meta(j(`humidity`,{precision:0,label:`Humidity`})),lastFetchedAt:f()}),cI={name:`humidity-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Sensor,w.Climate],methods:{},status:{schema:sI,kind:`push`},runtimeState:sI,durability:`restored`,history:{primary:`humidity`,priority:90,fields:{humidity:{kind:`gauge`,unit:`%`,deadband:.5}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:N(`Humidity`,`Umidità`),order:5120,state:[{kind:`numeric`,field:`humidity`,quantity:N(`the humidity`,`l’umidità`),label:N(`Humidity`,`Umidità`),unit:`%`,icon:`droplets`}]}},lI=b({url:p().nullable(),lastUpdated:f().nullable().meta(j(`none`))}),uI={name:`image`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Image],methods:{},status:{schema:lI,kind:`push`},runtimeState:lI,durability:`session`,history:`none`,vocabulary:{noun:N(`Image`,`Immagine`),order:3130}},dI=x([`0`,`90`,`180`,`270`]),fI=x([`auto`,`manual`]),pI=x([`auto`,`manual`]),mI=x([`off`,`blc`,`wdr`,`hlc`]),hI=b({min:f(),max:f(),step:f()}),gI=b({brightness:f().optional().meta(j(`none`)),contrast:f().optional().meta(j(`none`)),saturation:f().optional().meta(j(`none`)),sharpness:f().optional().meta(j(`none`)),mirror:v().optional(),flip:v().optional(),rotate:dI.optional(),whiteBalance:fI.optional(),warmth:f().optional().meta(j(`none`)),exposureMode:pI.optional(),backlightMode:mI.optional(),lastFetchedAt:f()}),_I=b({supportsBrightness:v(),brightness:hI.optional(),supportsContrast:v(),contrast:hI.optional(),supportsSaturation:v(),saturation:hI.optional(),supportsSharpness:v(),sharpness:hI.optional(),supportsMirror:v(),supportsFlip:v(),rotateOptions:S(dI),whiteBalanceModes:S(fI),supportsWarmth:v(),warmth:hI.optional(),exposureModes:S(pI),backlightModes:S(mI)}),vI=b({brightness:f().optional(),contrast:f().optional(),saturation:f().optional(),sharpness:f().optional(),mirror:v().optional(),flip:v().optional(),rotate:dI.optional(),whiteBalance:fI.optional(),warmth:f().optional(),exposureMode:pI.optional(),backlightMode:mI.optional()}),yI={name:`image-settings`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Camera],deviceConfig:{ui:{kind:`derived-form`,builderId:`image-settings`,tab:`image`}},methods:{getOptions:O(b({deviceId:f()}),_I),setSettings:O(b({deviceId:f(),settings:vI}),_(),{kind:`mutation`,auth:`admin`})},status:{schema:gI,kind:`poll`},runtimeState:gI,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:N(`Image settings`,`Impostazioni immagine`),order:3140}},bI=b({id:p(),addonId:p(),name:p(),enabled:v(),switchUnknown:o(!0).optional(),info:u(p(),l()).readonly(),originStableId:p().optional(),createdAt:f(),updatedAt:f(),processState:p()}),xI=b({id:p(),addonId:p(),name:p(),enabled:v(),switchUnknown:o(!0).optional(),info:u(p(),l()).readonly(),originStableId:p().optional(),createdAt:f(),updatedAt:f()}),SI=b({addonId:p(),name:p(),providerLabel:p().optional(),description:p(),iconUrl:p().nullable(),color:p(),instanceMode:p(),mode:x([`standalone`,`account`,`broker`]),discoveryMode:p(),kind:x([`device-adoption`,`device-provider`]),brokerKind:p().nullable(),supportsLocationImport:v(),canTest:v(),existingInstances:S(b({id:p(),name:p()})),canAdd:v()}),CI=x([`validated`,`rejected`,`inconclusive`,`unsupported`]),wI=b({success:v(),error:p().optional(),status:CI.optional(),testedBy:p().nullable().optional(),latencyMs:f().nonnegative().optional(),detail:p().optional()}),TI=b({id:p(),name:p().optional(),enabled:v().optional(),info:u(p(),l()).optional()}),EI=b({success:v(),deletedId:p()}),DI={name:`integrations`,scope:`system`,mode:`singleton`,methods:{list:O(_(),S(bI)),get:O(b({id:p()}),bI),getByAddonId:O(b({addonId:p()}),xI.nullable()),update:O(TI,xI,{kind:`mutation`,auth:`admin`}),delete:O(b({id:p()}),EI,{kind:`mutation`,auth:`admin`}),getAvailableTypes:O(_(),S(SI),{auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:A.ADDON_ADMIN}},ACe=ge(),OI=p().min(1),kI=x([`single`,`multiple`]),AI=x([`devices`,`services`]),jI=b({id:p().min(1),label:p().min(1),functionCap:p().min(1),brokerKind:p().min(1).optional(),alsoServes:S(p().min(1)).optional(),iconUrl:p().min(1).optional(),iconMediaType:p().min(1).optional(),role:AI.optional(),canTest:v().optional(),signIn:b({basePath:p().min(1),methods:S(x([`device-code`,`proxy`])).optional()}).optional(),connectPath:p().min(1).optional(),disconnectPath:p().min(1).optional(),widgets:S(b({id:p().min(1),placement:x([`connection`,`model`])})).optional()}),MI=b({mode:x([`none`,`lan`,`account`]),scopedToInstance:v()}),NI=b({kind:p().min(1),field:p().min(1),to:b({cap:p().min(1),kind:p().min(1).optional()})}),PI=b({role:AI,discovery:MI.optional(),instanceMode:kI,kind:p(),canTest:v(),kinds:S(jI).min(1),allowRestoreId:v().optional(),mintsId:v().optional(),links:S(NI).optional(),userScoped:v().optional()}),FI=b({state:x([`ok`,`off`,`error`,`unknown`]),detail:p().optional(),label:p().optional()}),II=b({id:OI,name:p(),configured:v(),enabled:v().optional(),kind:p().min(1),formValues:u(p(),l()),status:FI.optional(),lastCheckedAt:f().optional()}),LI=b({id:OI,name:p().min(1).optional(),values:u(p(),l())}),RI={name:`integration-instances`,scope:`system`,mode:`collection`,methods:{describe:O(_(),PI,{auth:`admin`}),instanceFormSchema:O(b({id:OI.nullable(),kind:p().min(1).optional(),mode:x([`standalone`,`account`,`broker`]).optional(),candidateStableId:p().min(1).optional()}),ACe,{auth:`admin`}),listInstances:O(a({}),S(II).readonly(),{auth:`protected`,caller:`scoped`}),getInstance:O(b({id:OI}),II.nullable(),{auth:`protected`,caller:`scoped`}),createInstance:O(b({id:OI.optional(),name:p().min(1),kind:p().min(1).optional(),values:u(p(),l()).optional(),originStableId:p().min(1).optional(),seed:b({info:u(p(),l())}).optional()}),b({id:p()}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),updateInstance:O(LI,b({ok:o(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),setInstanceEnabled:O(b({id:OI,enabled:v()}),b({ok:o(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),deleteInstance:O(b({id:OI}),b({ok:o(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),testInstance:k(b({id:OI.nullable(),values:u(p(),l()),kind:p().min(1).optional()}),wI,{kind:`mutation`,auth:`protected`,caller:`scoped`})},vocabulary:{notOperatorFacing:A.INTERNAL}},zI=b({codecs:S(p()),sampleRate:f().meta(j(`none`)),duplex:x([`half`,`full`]),maxBacklogMs:f().meta(j(`duration-ms`))}),BI=b({talking:v(),lastSessionAt:f().nullable(),ability:zI.nullable()}),jCe=x([`opus`,`s16le`,`g711ulaw`,`g711alaw`]),VI={name:`intercom`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Camera],methods:{startSession:O(b({deviceId:f()}),b({sessionId:p(),sdpOffer:p()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),handleAnswer:O(b({deviceId:f(),sessionId:p(),sdpAnswer:p()}),_(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),stopSession:O(b({deviceId:f(),sessionId:p()}),_(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),startTalkSession:O(b({deviceId:f()}),b({sessionId:p()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`two-way talk is a person speaking through the viewer, not an automation step`}),pushTalkAudio:O(b({deviceId:f(),audioBase64:p(),codec:jCe.optional(),sampleRate:f().int().positive().optional(),channels:f().int().positive().optional(),sequenceNumber:f().int()}),b({accepted:v()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),endTalkSession:O(b({deviceId:f()}),_(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`})},events:{onStatusChanged:{data:b({deviceId:f(),status:BI}),notOperatorFacing:"the `talking` state trigger phrases both edges of this change"}},status:{schema:BI,kind:`command-driven`},runtimeState:BI,durability:`session`,history:`none`,vocabulary:{noun:N(`Intercom`,`Citofono`),order:3150,state:[{kind:`boolean`,field:`talking`,label:N(`Talking`,`In conversazione`),whenTrue:N(`When someone starts talking through {device}`,`Quando qualcuno inizia a parlare tramite {device}`),whenFalse:N(`When the conversation on {device} ends`,`Quando la conversazione su {device} finisce`),icon:`mic`}]}},HI=x([`carrierHz`,`dutyCyclePercent`,`repeat`,`repeatDelayMs`]),UI=x([`ir`,`rf`]),WI=b({ok:o(!0),ignoredSettings:S(p())}),GI=b({media:S(UI),settable:S(HI),maxTimings:f().int().positive(),learn:v().default(!1),formats:S(nE).default([])}),KI=2e4,qI=6e4,JI=b({native:iE.nullable(),timings:qT,carrierHz:f().int().positive().nullable()}),YI=b({at:f(),ok:v(),error:p().nullable()}),XI=YI.extend({medium:UI}),ZI=b({lastSend:XI.nullable(),lastLearn:YI.nullable(),lastFetchedAt:f()});function QI(e){return!(e.kind===`learn`&&e.error===`ir-transmitter.learn-unsupported`)}function MCe(e,t,n){let r=e??{lastSend:null,lastLearn:null,lastFetchedAt:n};return QI(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 NCe(e){return kr(e)?.code??null}var $I={name:`ir-transmitter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Generic],methods:{send:O(b({deviceId:f().int().nonnegative(),timings:qT.optional(),native:iE.optional(),settings:JT.optional()}).refine(e=>e.timings===void 0!=(e.native===void 0),{message:`send takes exactly one of timings or native`}),WI,{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:O(b({deviceId:f().int().nonnegative(),timeoutMs:f().int().positive().max(qI).default(KI)}),JI,{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:O(b({deviceId:f().int().nonnegative()}),GI,{kind:`query`,auth:`protected`})},runtimeState:ZI,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:N(`IR / RF transmitter`,`Trasmettitore IR / RF`),order:1140}},eL=x([`key-missing`,`wrong-key`,`key-file-unreadable`,`store-unavailable`,`not-initialized`,`decrypt-failed`]),tL=i(`state`,[b({state:o(`ready`)}),b({state:o(`locked`),reason:eL})]),nL=i(`kind`,[b({kind:o(`value`),value:p(),version:f().int()}),b({kind:o(`missing`)}),b({kind:o(`unavailable`),reason:eL}),b({kind:o(`forbidden`)})]),rL=u(p(),nL),iL=b({ref:p(),owner:p(),scope:p(),fieldPath:p(),version:f().int(),createdAt:f(),updatedAt:f(),updatedBy:p(),lastReadAt:f().nullable()}),PCe=512,aL=S(p().min(1)).max(512),oL={name:`keychain`,scope:`system`,mode:`singleton`,internal:!0,methods:{put:O(b({ref:p().min(1),value:p().min(1)}),b({ref:p(),version:f().int()}),{kind:`mutation`,auth:`admin`}),resolve:O(b({refs:aL}),rL,{auth:`admin`}),delete:O(b({refs:aL}),b({deleted:f().int()}),{kind:`mutation`,auth:`admin`}),deleteDeviceScope:O(b({deviceId:f().int()}),b({refs:S(p()).readonly()}),{kind:`mutation`,auth:`admin`}),releaseRecordRefs:O(b({refs:aL,onBehalfOf:p().min(1)}),b({released:f().int()}),{kind:`mutation`,auth:`admin`}),listMeta:O(b({}),S(iL).readonly(),{auth:`admin`}),getState:O(b({}),tL,{auth:`admin`})},vocabulary:{notOperatorFacing:A.IDENTITY}},sL=x([`mounted-file`,`previous-mounted-file`,`platform`,`default-file`]),cL=b({kind:sL,path:p().optional(),sharesBackupWithDatabase:v()}),FCe=`trigger-file`,lL=b({id:p(),at:f(),actor:p(),lockedReason:p().nullable(),archived:f().int(),archivedCollection:p().nullable(),archivedKeysCollection:p().nullable(),clearedSettingsKeys:S(p()).readonly(),acknowledgedAt:f().nullable()}),uL=b({keychain:tL,keySource:cL.nullable(),configuredSource:cL,fingerprint:p().nullable(),activeKeyId:p().nullable(),rotationPending:v(),retiredWraps:f().int(),recoveryKeyDownloadedAt:f().nullable(),secretCount:f().int(),lastReset:lL.nullable()}),dL=x([`in-use`,`orphan`,`unknown`]),fL=iL.extend({usage:dL}),pL=x([`put`,`delete`,`reveal`,`rotate-master-key`,`purge-retired-keys`,`download-recovery-key`,`delete-orphans`,`reset`,`acknowledge-reset`,`initialize`]),mL=b({id:p(),at:f(),action:pL,actor:p(),ref:p().nullable(),detail:p().nullable()}),hL=`RESET KEYCHAIN`,gL=x([`jwt-signing-key`]),_L={name:`keychain-admin`,scope:`system`,mode:`singleton`,methods:{status:O(b({}),uL,{auth:`admin`}),listSecrets:O(b({}),S(fL).readonly(),{auth:`admin`}),listAudit:O(b({limit:f().int().min(1).max(500).optional()}),S(mL).readonly(),{auth:`admin`}),reveal:O(b({ref:p().min(1)}),b({value:p(),version:f().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),setSystemSecret:O(b({name:gL,value:p().min(16)}),b({ref:p(),version:f().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),importSecret:O(b({ref:p().min(1),value:p().min(1)}),b({ref:p(),version:f().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),deleteOrphans:O(b({refs:S(p().min(1)).max(1e3)}),b({deleted:S(p()).readonly(),kept:S(b({ref:p(),usage:dL})).readonly()}),{kind:`mutation`,auth:`admin`,caller:`required`}),rotateMasterKey:O(b({}),b({fingerprint:p(),keySource:cL}),{kind:`mutation`,auth:`admin`,caller:`required`}),purgeRetiredKeys:O(b({}),b({purged:f().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),downloadRecoveryKey:O(b({}),b({key:p(),fingerprint:p(),keySource:cL}),{kind:`mutation`,auth:`admin`,caller:`required`}),resetKeychain:O(b({confirm:o(hL)}),b({archivedCollection:p().nullable(),archived:f().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),resetReport:O(b({}),b({reset:lL.nullable(),pendingReentry:S(iL).readonly()}),{auth:`admin`}),acknowledgeReset:O(b({}),b({acknowledged:v()}),{kind:`mutation`,auth:`admin`,caller:`required`})},vocabulary:{notOperatorFacing:A.IDENTITY}},vL=x([`idle`,`mowing`,`paused`,`docked`,`error`]),yL=x([`info`,`warning`,`error`]),bL=b({activity:vL,batteryLevel:f().min(0).max(100).nullable().meta(j(`percentage`)),progress:f().min(0).max(100).nullable().meta(j(`percentage`)),currentCode:f().nullable().meta(j(`none`)),currentCodeLabel:p().nullable(),severity:yL,lastChangedAt:f()}),xL={name:`lawn-mower-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.LawnMower],methods:{startMowing:O(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.start`,label:N(`Start mowing`,`Avvia il taglio`),phrase:N(`Start {device} mowing`,`Fai partire il taglio di {device}`),icon:`play`}]}),pause:O(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.pause`,label:N(`Pause mower`,`Metti in pausa il tosaerba`),phrase:N(`Pause {device}`,`Metti in pausa {device}`),icon:`pause`}]}),dock:O(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.dock`,label:N(`Dock mower`,`Riporta alla base`),phrase:N(`Send {device} back to its dock`,`Rimanda {device} alla base`),icon:`house`}]})},status:{schema:bL,kind:`push`},runtimeState:bL,durability:`session`,history:{fields:{batteryLevel:{kind:`gauge`,unit:`%`,deadband:2}}},vocabulary:{noun:N(`Robot mower`,`Robot tosaerba`),order:2010,state:[{kind:`enum`,field:`activity`,label:N(`Activity`,`Attività`),values:[{value:`idle`,label:N(`Idle`,`Inattivo`)},{value:`mowing`,label:N(`Mowing`,`In taglio`),phrase:N(`When {device} starts mowing`,`Quando {device} inizia a tagliare`)},{value:`paused`,label:N(`Paused`,`In pausa`)},{value:`docked`,label:N(`Docked`,`Alla base`),phrase:N(`When {device} docks`,`Quando {device} arriva alla base`)},{value:`error`,label:N(`Error`,`Errore`),phrase:N(`When {device} reports an error`,`Quando {device} segnala un errore`)}],icon:`bot`},{kind:`numeric`,field:`batteryLevel`,quantity:N(`the battery level`,`il livello della batteria`),label:N(`Battery`,`Batteria`),unit:`%`,icon:`battery`}]}},SL=6e5,ICe=60*6e4,CL=b({inputTokens:f(),outputTokens:f()}),wL=x([`timeout`,`rate-limited`,`auth`,`refusal`,`bad-request`,`unavailable`,`no-profile`,`budget-exceeded`,`adapter-error`]),TL=b({ok:o(!0),text:p(),model:p(),usage:CL,truncated:v(),latencyMs:f()}),EL=x([`guardrail`,`model`]),DL=b({ok:o(!1),code:wL,message:p(),retryAfterMs:f().optional(),refusalSource:EL.optional()}),OL=i(`ok`,[TL,DL]),kL=b({bytes:y(Uint8Array),mimeType:p()}),AL=b({enabled:v().default(!1),maxAttempts:f().int().min(1).max(5).default(1)}),LCe={totalMs:6e4,connectMs:1e4,firstTokenMs:12e4,idleMs:6e4},jL=b({addonId:p().optional(),profileId:p().optional(),consumer:p(),system:p().optional(),prompt:p(),jsonSchema:u(p(),l()).optional(),maxTokens:f().int().positive().optional(),temperature:f().optional(),topP:f().min(0).max(1).optional(),topK:f().int().positive().optional(),reasoningEffort:x([`off`,`low`,`medium`,`high`]).optional(),timeoutMs:f().int().positive().optional(),retry:AL.optional(),requestId:p().optional()}),ML=b({url:p(),filename:p(),sizeBytes:f(),sha256:p().optional()}),NL=i(`kind`,[b({kind:o(`catalog`),catalogId:p()}),b({kind:o(`url`),url:p(),sha256:p().optional(),label:p().optional(),sizeBytes:f().optional(),extraFiles:S(ML).optional()}),b({kind:o(`path`),path:p()})]),PL=b({nodeId:p(),engine:x([`llama-cpp`]),model:NL,contextSize:f().int().default(4096),gpuLayers:f().int().default(0),threads:f().int().optional(),parallel:f().int().default(1),batchSize:f().int().positive().optional(),ubatchSize:f().int().positive().optional(),flashAttention:v().default(!1),mlock:v().default(!1),noMmap:v().default(!1),cacheTypeK:x([`f32`,`f16`,`q8_0`,`q5_1`,`q5_0`,`q4_1`,`q4_0`]).optional(),cacheTypeV:x([`f32`,`f16`,`q8_0`,`q5_1`,`q5_0`,`q4_1`,`q4_0`]).optional(),extraArgs:S(p()).default([]),autoStart:v().default(!1),idleStopMinutes:f().int().default(30)}),FL=b({phase:x([`downloading`,`verifying`]),file:p(),fileIndex:f().int(),fileCount:f().int(),downloadedBytes:f(),totalBytes:f().optional()}),IL=b({nodeId:p(),state:x([`stopped`,`downloading`,`starting`,`ready`,`crashed`,`failed`]),pid:f().optional(),port:f().optional(),modelPath:p().optional(),modelId:p().optional(),downloadProgress:f().min(0).max(1).optional(),download:FL.optional(),lastError:p().optional(),crashesInWindow:f(),memoryBytes:f().optional(),vramBytes:f().optional()}),LL=b({file:p(),sizeBytes:f(),catalogId:p().optional(),installedAt:f().optional(),path:p().optional()}),RL=b({nodeId:p(),modelsBytes:f(),freeBytes:f().optional()}),zL=jL.extend({images:S(kL).optional(),runtime:PL,timeoutMs:f().int().positive().optional()}),BL=x([`deviceNotEligible`,`appleIntelligenceNotEnabled`,`modelNotReady`,`osTooOld`,`helperMissing`,`helperCrashed`]),VL=i(`state`,[b({state:o(`available`),osVersion:p(),contextSize:f().int().positive(),languages:S(p()),imageInput:v()}),b({state:o(`unavailable`),reason:BL,osVersion:p().nullable(),detail:p()}),b({state:o(`unsupported-platform`),platform:p()}),b({state:o(`unknown`),error:p()})]),HL=jL.extend({images:S(kL).optional(),timeoutMs:f().int().positive().optional()}),UL=b({requestId:p()}),WL={name:`llm-runtime`,scope:`system`,mode:`singleton`,internal:!0,methods:{complete:O(zL,OL,{kind:`mutation`,auth:`admin`,timeoutMs:SL}),ensureStarted:O(b({runtime:PL}),IL,{kind:`mutation`,auth:`admin`,timeoutMs:SL}),stop:O(b({}),_(),{kind:`mutation`,auth:`admin`}),status:O(b({}),IL,{auth:`admin`}),installModel:O(b({model:NL}),_(),{kind:`mutation`,auth:`admin`,timeoutMs:ICe}),deleteModel:O(b({file:p()}),_(),{kind:`mutation`,auth:`admin`}),listLocalModels:O(b({}),S(LL),{auth:`admin`}),getDiskUsage:O(b({}),RL,{auth:`admin`}),cancel:O(UL,_(),{kind:`mutation`,auth:`admin`}),appleAvailability:O(b({}),VL,{auth:`admin`}),completeApple:O(HL,OL,{kind:`mutation`,auth:`admin`,timeoutMs:SL})},vocabulary:{notOperatorFacing:A.ML}},GL=/^[a-z0-9][a-z0-9-]{0,63}$/,KL=p().regex(GL,`a kind id is lower-case letters, digits and dashes`),qL=b({vision:v(),tools:v(),streaming:v(),reasoning:v().nullable().optional()}),JL=b({id:p(),label:p().optional(),contextLength:f().int().positive().optional(),features:qL.partial().optional()}),YL=u(p(),l()),RCe=b({id:p(),name:p(),kind:KL,addonId:p(),enabled:v(),model:p(),supportsVision:v(),temperature:f().min(0).max(2).optional(),topP:f().min(0).max(1).optional(),topK:f().int().positive().optional(),maxTokens:f().int().positive().optional(),reasoningEffort:x([`off`,`low`,`medium`,`high`]).optional(),contextLength:f().int().positive().optional(),systemPrompt:p().optional(),timeoutMs:f().int().positive().default(6e4),connectTimeoutMs:f().int().positive().default(1e4),firstTokenTimeoutMs:f().int().positive().default(12e4),idleTimeoutMs:f().int().positive().default(6e4),retry:AL.default({enabled:!1,maxAttempts:1}),toolsEnabled:v().default(!1),providerConfig:YL.default({})}),XL=x([`temperature`,`topP`,`topK`,`maxTokens`,`reasoningEffort`,`contextLength`,`systemPrompt`,`timeoutMs`,`connectTimeoutMs`,`firstTokenTimeoutMs`,`idleTimeoutMs`,`retry`,`toolsEnabled`]),ZL=b({id:p(),placement:x([`connection`,`model`]),requires:S(p()).optional()}),QL=l(),zCe=b({kind:KL,label:p(),icon:p(),addonId:p(),connectionSchema:QL,advancedSchema:QL.optional(),features:qL,visionEditable:v(),modelCatalog:x([`fetch`,`static`,`none`]),staticModels:S(JL).optional(),profileFields:S(XL),providerWidgets:S(ZL).optional()}),$L=b({addonId:p(),kind:KL,profileId:p().optional(),connection:YL.optional()}),eR=x([`auth`,`network`,`unsupported`,`invalid`]),tR=i(`ok`,[b({ok:o(!0),models:S(JL)}),b({ok:o(!1),code:eR,message:p()})]),nR=c([b({consumer:p()}),b({purpose:x([`text`,`vision`])})]),rR=b({selector:nR,profileId:p()}),iR=b({day:p(),consumer:p(),profileId:p(),calls:f(),okCalls:f(),errorCalls:f(),inputTokens:f(),outputTokens:f(),avgLatencyMs:f()}),aR=b({id:p(),label:p(),family:p(),purpose:x([`text`,`vision`]),url:p(),sha256:p(),sizeBytes:f(),quantization:p(),minRamBytes:f(),contextSizeDefault:f().int(),mmprojUrl:p().optional()}),oR=i(`ok`,[b({ok:o(!0),model:NL,label:p(),repo:p(),quantization:p(),purpose:x([`text`,`vision`]),totalBytes:f(),extraFilenames:S(p())}),b({ok:o(!1),code:p(),message:p(),candidates:S(p()).optional(),requiredBytes:f().optional()})]),sR=b({nodeId:p(),reachable:v(),status:IL.optional(),disk:RL.optional(),error:p().optional(),apple:VL.optional()}),BCe=jL.extend({images:S(kL).min(1)}),cR=b({addonId:p(),profileId:p()}),lR={name:`llm`,scope:`system`,mode:`collection`,internal:!1,providerKind:`ai`,nodeIdMode:`data`,methods:{generate:O(jL,OL,{kind:`mutation`,timeoutMs:SL}),generateVision:O(BCe,OL,{kind:`mutation`,timeoutMs:SL}),cancel:O(b({addonId:p().optional(),requestId:p()}),_(),{kind:`mutation`}),listModels:O($L,tR,{kind:`mutation`,auth:`admin`}),getDefaults:O(b({}),S(rR)),setDefault:O(b({selector:nR,profileId:p().nullable()}),_(),{kind:`mutation`,auth:`admin`}),getUsage:O(b({since:f().optional(),until:f().optional(),consumer:p().optional(),profileId:p().optional()}),S(iR)),listModelCatalog:O(b({}),S(aR)),listRuntimeNodes:O(b({}),S(sR)),listNodeModels:O(b({nodeId:p()}),S(LL)),resolveModelRef:O(b({ref:p(),maxBytes:f().positive().optional()}),oR,{kind:`mutation`,auth:`admin`}),installModel:O(b({nodeId:p(),model:NL}),_(),{kind:`mutation`,auth:`admin`}),deleteModel:O(b({nodeId:p(),file:p()}),_(),{kind:`mutation`,auth:`admin`}),getRuntimeStatus:O(cR,IL),startRuntime:O(cR,IL,{kind:`mutation`,auth:`admin`}),stopRuntime:O(cR,_(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:A.ML}},uR=[`decode`,`transcode`,`recording`,`streaming`,`detection`],dR=[`measured`,`accounted`,`unattributable`],fR=b({role:x(uR),deviceId:f().int().positive().nullable(),attribution:x(dR),unit:p(),pid:f().int().positive().optional(),startedAtMs:f().optional(),cpuSeconds:f().optional(),rssBytes:f().optional()}),pR={name:`load-contribution`,scope:`system`,mode:`collection`,internal:!0,methods:{list:O(_(),S(fR).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:A.INTERNAL}},mR=`https://camstack.zentik.app`,hR=`/viewer/camstack`;function gR(e){if(e==null||e===``)return!1;try{return new URL(e).origin===mR}catch{return!1}}function VCe(e){let t=e.baseUrl??e.resolved;return gR(t)?{form:`app`,hubBaseUrl:e.appLinkHub??null}:{form:`hub`,hubBaseUrl:t}}function _R(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 HCe(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=_R(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 UCe(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 vR(e){return e.length===0?``:`?${e.map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join(`&`)}`}function WCe(e){let t=UCe(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:_R(r),n=e===null?t.query:[...t.query,[`hub`,e]];return`${mR}${t.path}${vR(n)}`}return r===``||gR(r)?null:`${r}${hR}${t.path}${vR(t.query)}`}var yR=[`appConnections`,`notificationTaps`,`internal`,`publicEndpoint`],GCe=[`notificationTaps`,`internal`,`publicEndpoint`];function KCe(e){return e!==`appConnections`}var qCe={appConnections:[],notificationTaps:null,internal:null,publicEndpoint:null},JCe=/^\d{1,3}(?:\.\d{1,3}){3}$/;function bR(e){try{let t=new URL(e).hostname;return t.length>0?t:null}catch{return null}}function YCe(e){return e.replace(/\/+$/,``)}function xR(e){return e.kind===`public`&&e.interfaceKind===`vpn`}function XCe(e){return e.kind===`public`&&e.interfaceKind===`public`}function SR(e){return(e.kind===`lan-ipv4`||e.kind===`lan-ipv6`)&&e.plausible}function CR(e){if(e.kind!==`lan-ipv4`||!e.plausible)return!1;let t=bR(e.baseUrl);return t!==null&&JCe.test(t)}function wR(e){return e.stable===!1}function ZCe(e,t){return t.kind===`loopback`||t.kind===`app-link`||t.kind===`custom`||bR(t.baseUrl)===null||wR(t)?null:e===`internal`?CR(t)?0:SR(t)?1:xR(t)?2:null:XCe(t)?0:xR(t)?1:CR(t)?2:SR(t)?3:null}var QCe=new Set([`localhost`,`0.0.0.0`,`::1`,`[::1]`,`::`,`[::]`]);function $Ce(e){let t=e.toLowerCase();return QCe.has(t)||t.endsWith(`.localhost`)?!0:/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(t)}function TR(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.`}:$Ce(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 ER=`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 DR(e,t,n={}){if(gR(t))return e===`notificationTaps`?{ok:!0,baseUrl:mR}:{ok:!1,reason:`The CamStack app link is not a hub address — only notification taps can use it.`};let r=TR(t);return r.ok&&e===`publicEndpoint`&&r.baseUrl.startsWith(`http:`)&&n.acceptInsecureHttp!==!0?{ok:!1,reason:ER}:r}function OR(e,t){if(t===null||t===``)return null;let n=DR(e,t,{acceptInsecureHttp:!0});return n.ok?n.baseUrl:null}function ewe(e,t){let n=e.flatMap(e=>{let n=ZCe(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:YCe(n.endpoint.baseUrl)}function kR(e,t,n){let r=OR(t,n);if(r!==null)return{flagged:r,resolved:r,source:`flagged`};let i=ewe(e,t);return{flagged:null,resolved:i,source:i===null?`none`:`auto`}}function AR(e,t){return kR(e,`internal`,t.internal)}function jR(e,t){return kR(e,`publicEndpoint`,t.publicEndpoint)}function MR(e){let t=OR(`notificationTaps`,e.notificationTaps);return t!==null&&!gR(t)?{flagged:t,resolved:t,source:`flagged`}:{flagged:null,resolved:mR,source:`auto`}}function NR(e){return wR(e)?!1:e.kind===`lan-ipv4`?!0:e.kind===`public`&&e.interfaceKind===`public`}function PR(e,t){let n=e.filter(NR);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 FR(e,t){let n=new Set(t.appConnections),r=PR(e,t),i=r.some(e=>n.has(e.baseUrl));return{flagged:t.appConnections,resolved:r.map(e=>e.baseUrl),source:r.length===0?`none`:i?`flagged`:`auto`}}function twe(e,t,n){return{appConnections:FR(e,n),notificationTaps:MR(n),internal:AR(t,n),publicEndpoint:jR(t,n)}}function nwe(e){return e===null?null:bR(e)}var rwe=`camstack`,iwe=`_camstack._tcp.local`,awe={nodeId:`nodeId`,version:`version`,role:`role`,url:`url`,hubId:`hubId`},owe=`hub`,IR=/^hub-[0-9a-f]{16}$/;function swe(e){return typeof e==`string`&&IR.test(e)}var cwe=`camstack-agent`,lwe=`_camstack-agent._tcp.local`,uwe={nodeId:`nodeId`,version:`version`,name:`name`,state:`state`,keyFingerprint:`fp`},dwe=x([`lan`,`wifi`,`docker`,`vpn`,`loopback`,`other`]),LR=b({name:p(),family:x([`IPv4`,`IPv6`]),address:p(),cidr:p(),netmask:p(),internal:v(),mac:p(),kind:dwe,preferred:v(),plausible:v(),plausibleReason:p()}),fwe=b({interfaces:S(LR).readonly(),probedAt:f()}),pwe=LR.nullable(),RR=b({label:p(),baseUrl:p(),kind:x([`lan-ipv4`,`lan-ipv6`,`public`,`loopback`,`app-link`,`custom`]),interfaceKind:x([`lan`,`wifi`,`docker`,`vpn`,`other`,`loopback`,`public`]),plausible:v(),plausibleReason:p(),priority:f(),stable:v().optional()}),mwe=x([`server-config`,`server-env`,`caller-hint`,`default`]),hwe=b({port:f().int().min(1).max(65535),source:mwe}),gwe=b({endpoints:S(RR).readonly(),localPort:hwe}),zR=b({baseUrl:p().nullable(),resolved:p().nullable(),appLinkHub:p().nullable()}),BR=b({baseUrls:S(p()).readonly(),resolved:S(p()).readonly()}),VR=b({override:p().nullable(),resolved:p().nullable(),source:x([`override`,`auto`,`none`])}),_we=b({cluster:VR,browser:VR}),HR=x(yR),UR=x([`flagged`,`auto`,`none`]),WR=b({flagged:p().nullable(),resolved:p().nullable(),source:UR}),vwe=b({flagged:S(p()).readonly(),resolved:S(p()).readonly(),source:UR}),GR=b({rows:S(RR.extend({detected:v(),custom:v(),flags:S(HR).readonly(),inUse:S(HR).readonly(),eligible:S(HR).readonly()})).readonly(),roles:b({appConnections:vwe,notificationTaps:WR,internal:WR,publicEndpoint:WR}),appLinkHub:p().nullable(),listenerOrigins:S(p()).readonly().optional()}),KR=b({addresses:S(p()).readonly()}),qR=b({mode:x([`generated`,`uploaded`,`disabled`]),leafFingerprintSha256:p().nullable(),caFingerprintSha256:p().nullable(),validTo:p().nullable(),sans:S(p()),caCertPem:p().nullable(),reissueError:p().nullable(),restartRequired:v(),caMissing:v(),localCaConstrained:v().nullable(),caReplacedAt:p().nullable(),storedUpload:b({leafFingerprintSha256:p(),validTo:p(),hasCa:v()}).nullable()}),ywe=b({providerId:p().min(1),modes:S(AA)}),bwe=b({providerId:p().optional(),mode:p().optional(),message:p()}),xwe=b({hostsProbed:f().int(),hits:f().int(),timeouts:f().int(),byMode:u(p(),b({probed:f().int(),hits:f().int(),timeouts:f().int()}))}),Swe=b({hits:S(b({providerId:p(),hit:jA})),subnetsScanned:S(p()),errors:S(bwe),stats:xwe}),JR={name:`local-network`,scope:`system`,mode:`singleton`,methods:{list:O(_(),fwe),getPreferred:O(_(),pwe),getConnectionEndpoints:O(b({port:f().int().min(1).max(65535).optional(),includeLoopback:v().optional(),ipv4Only:v().optional(),scheme:x([`http`,`https`]).optional(),includeAppLink:v().optional()}),gwe),getNotificationEndpoint:O(_(),zR),setNotificationEndpoint:O(b({baseUrl:p().nullable()}),zR,{kind:`mutation`}),getViewerEndpoints:O(_(),BR),setViewerEndpoints:O(b({baseUrls:S(p()).readonly()}),BR,{kind:`mutation`}),getAddresses:O(b({scheme:x([`http`,`https`]).optional()}).optional(),GR),addCustomAddress:O(b({baseUrl:p(),label:p().max(80)}),GR,{kind:`mutation`,auth:`admin`}),removeCustomAddress:O(b({baseUrl:p()}),GR,{kind:`mutation`,auth:`admin`}),setAddressRole:O(b({role:HR,baseUrl:p().nullable(),enabled:v(),acceptInsecureHttp:v().optional()}),GR,{kind:`mutation`,auth:`admin`}),getHubAddresses:O(_(),_we),getAllowedAddresses:O(_(),KR),setAllowedAddresses:O(KR,b({success:o(!0)}),{kind:`mutation`}),resetAllowlistToBestMatch:O(_(),KR,{kind:`mutation`}),getTlsStatus:O(_(),qR),regenerateCertificate:O(b({reason:p().optional()}),qR,{kind:`mutation`,auth:`admin`}),uploadCertificate:O(b({certPem:p().min(1),keyPem:p().min(1),caPem:p().optional()}),qR,{kind:`mutation`,auth:`admin`}),downloadCa:O(_(),b({pem:p()})),useStoredUploadedCertificate:O(_(),qR,{kind:`mutation`,auth:`admin`}),scanNetwork:O(b({requests:S(ywe),subnets:S(p()).optional()}),Swe,{kind:`mutation`,auth:`admin`,timeoutMs:9e4}),getScanSubnets:O(_(),b({subnets:S(p())}),{auth:`admin`}),setScanSubnets:O(b({subnets:S(p())}),b({subnets:S(p())}),{kind:`mutation`,auth:`admin`}),revertToGeneratedCertificate:O(_(),qR,{kind:`mutation`,auth:`admin`})},mount:{kind:`hub-only`},vocabulary:{notOperatorFacing:A.NETWORK}},YR=x([`locked`,`unlocked`,`locking`,`unlocking`,`jammed`,`door-open`]),XR=b({state:YR,lastChangedAt:f()}),Cwe={version:1,overridable:[{path:`state`,by:`door-contact`}],targets:[{id:`door-contact`,cardinality:`scalar`,vocabulary:{cap:`lock-control`,stateField:`state`},deviceTypes:[w.Lock],apply:`replace`,path:`state`,override:{whenSourceTrue:`door-open`,unlessNative:[`jammed`]},sources:[{kind:`binary`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}]},ZR={name:`lock-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Lock],methods:{lock:O(b({deviceId:f().int().nonnegative(),code:p().min(1).optional()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.lock`,label:N(`Lock`,`Chiudi a chiave`),phrase:N(`Lock {device}`,`Chiudi a chiave {device}`),icon:`lock`,effect:{field:`state`,value:`locked`},openArgs:[{key:`code`,label:N(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]}),unlock:O(b({deviceId:f().int().nonnegative(),code:p().min(1).optional(),confirm:v().optional()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.unlock`,label:N(`Unlock`,`Apri la serratura`),phrase:N(`Unlock {device}`,`Sblocca {device}`),icon:`lock-open`,effect:{field:`state`,value:`unlocked`},openArgs:[{key:`code`,label:N(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]}),open:k(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.open`,label:N(`Open latch`,`Apri lo scrocco`),phrase:N(`Release the latch of {device}`,`Fai scattare lo scrocco di {device}`),icon:`door-open`}]})},status:{schema:XR,kind:`push`},runtimeState:XR,customize:Cwe,durability:`restored`,history:{fields:{state:{kind:`enum`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:N(`Lock`,`Serratura`),order:1060,state:[{kind:`enum`,field:`state`,label:N(`Lock state`,`Stato della serratura`),values:[{value:`locked`,label:N(`Locked`,`Chiusa a chiave`),phrase:N(`When {device} locks`,`Quando {device} si chiude a chiave`)},{value:`unlocked`,label:N(`Unlocked`,`Sbloccata`),phrase:N(`When {device} unlocks`,`Quando {device} si sblocca`)},{value:`locking`,label:N(`Locking`,`In chiusura`),phrase:N(`When {device} starts locking`,`Quando {device} inizia a chiudersi`)},{value:`unlocking`,label:N(`Unlocking`,`In apertura`),phrase:N(`When {device} starts unlocking`,`Quando {device} inizia a sbloccarsi`)},{value:`jammed`,label:N(`Jammed`,`Inceppata`),phrase:N(`When {device} jams`,`Quando {device} si inceppa`)},{value:`door-open`,label:N(`Door open`,`Porta aperta`),phrase:N(`When the door of {device} opens`,`Quando la porta di {device} si apre`)}],icon:`lock`}]}},QR=b({armed:f().int().min(0),unknown:S(p()).readonly()}),$R={name:`log-channels`,scope:`system`,mode:`collection`,internal:!0,methods:{list:O(_(),S(Fm).readonly()),apply:O(b({windows:S(Im).readonly()}),QR,{kind:`mutation`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:A.INTERNAL}},ez=x([`debug`,`info`,`warn`,`error`]),tz=b({timestamp:h(),level:ez,scope:S(p()),message:p(),meta:u(p(),l()).optional(),tags:u(p(),p()).optional()}),nz=b({instanceId:p().min(1).max(200).optional(),requestId:p().min(1).max(64).optional(),deviceId:f().int().optional(),fromAddonId:p().min(1).max(200).optional(),fromNodeId:p().min(1).max(200).optional(),tags:u(p(),c([p(),f()])).optional(),level:ez.optional(),text:p().min(1).max(200).optional(),since:f().optional(),until:f().optional(),before:p().min(1).max(1024).optional(),after:p().min(1).max(1024).optional(),limit:f().int().min(1).max(1e3).optional(),budgetMs:f().int().min(50).max(1e4).optional()}),rz=b({id:p().optional(),timestamp:f(),level:ez,scope:p().optional(),message:p(),tags:u(p(),c([p(),f()])).optional(),meta:u(p(),l()).optional()}),iz=b({entries:S(rz),nextBefore:p().nullable(),nextAfter:p().nullable(),scannedBytes:f().int().nonnegative(),done:v(),cancelled:v().optional()}),wwe=b({instanceId:p().min(1).max(200).optional()}),az=b({readable:v(),reason:p().nullable(),filters:b({deviceId:v(),addonId:v(),nodeId:v(),tags:v(),level:v(),text:v(),timeRange:v()}),retentionDays:f().nullable()}),oz={name:`log-destination`,scope:`system`,mode:`collection`,internal:!0,methods:{write:O(tz,_(),{kind:`mutation`}),describeRead:k(wwe,az,{auth:`admin`}),read:k(nz,iz,{auth:`admin`}),cancelRead:k(b({requestId:p().min(1).max(64)}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:A.INTERNAL}},sz=x([`primary`,`second-factor`]),cz=b({kind:o(`redirect`),id:p(),label:p(),icon:p().optional(),startUrl:p(),stage:sz,linkable:v().optional(),app:Kh.nullable().optional()}),lz=b({kind:o(`widget`),id:p(),addonId:p(),bundle:p(),remote:Dx,stage:sz,app:Kh.nullable().optional()}),uz=b({kind:o(`passkey`),id:p(),label:p(),stage:sz,rpId:p(),origin:p().nullable(),app:Kh.nullable().optional()}),dz=i(`kind`,[cz,lz,uz]),fz={name:`login-method`,scope:`system`,mode:`collection`,internal:!0,methods:{getLoginMethods:O(_(),S(dz).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:A.IDENTITY}},Twe=b({id:p(),label:p(),scope:x([`mesh`,`public`]),url:p(),hostname:p(),port:f(),protocol:x([`http`,`https`])}),pz=b({id:p(),hostname:p(),magicDns:p(),addresses:S(p()).readonly(),os:p().optional(),online:v(),lastSeenMs:f(),isSelf:v(),connection:x([`direct`,`relay`,`idle`]),relay:p().nullable(),lastHandshakeMs:f(),rxBytes:f(),txBytes:f(),tags:S(p()).readonly(),exitNodeOption:v(),advertisedRoutes:S(p()).readonly(),userLogin:p().nullable(),keyExpiry:f().nullable()}),mz=b({joined:v(),meshIp:p(),magicDnsHostname:p(),peerCount:f(),endpoints:S(Twe).readonly(),error:p().optional(),tenantName:p(),magicDnsSuffix:p(),userLogin:p().nullable(),controlPlaneUrl:p(),keyExpiry:f().nullable(),daemonSocket:p().optional(),daemonCliPath:p().optional()}),hz={name:`mesh-network`,scope:`system`,mode:`collection`,providerKind:`mesh`,methods:{getStatus:O(_(),mz),join:O(b({authKey:p().min(8),hostname:p().optional()}),b({joined:o(!0)}),{kind:`mutation`}),startLogin:O(b({hostname:p().optional()}),b({loginUrl:p()}),{kind:`mutation`}),leave:O(_(),b({left:o(!0)}),{kind:`mutation`}),logout:O(_(),b({loggedOut:o(!0)}),{kind:`mutation`}),listPeers:O(_(),b({peers:S(pz).readonly()}))},vocabulary:{notOperatorFacing:A.NETWORK}},gz=b({value:f().nullable().meta(j(`device`,{label:`Total`})),lastFetchedAt:f()}),_z={name:`meter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Sensor],methods:{},status:{schema:gz,kind:`push`},runtimeState:gz,durability:`restored`,history:{fields:{value:{kind:`counter`,deadband:.001,minIntervalMs:6e4}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:N(`Meter`,`Contatore`),order:5140,state:[{kind:`numeric`,field:`value`,quantity:N(`the total`,`il totale`),label:N(`Total`,`Totale`),icon:`gauge`}]}},Ewe=b({total:f(),user:f(),system:f(),irq:f(),nice:f(),loadAvg:s([f(),f(),f()]),cores:f()}),Dwe=b({percent:f().nullable(),totalBytes:f(),usedBytes:f().nullable(),availableBytes:f().nullable(),swapUsedBytes:f(),swapTotalBytes:f()}),Owe=b({readBytes:f(),writeBytes:f(),readOps:f(),writeOps:f(),timestampMs:f()}),kwe=b({rxBytes:f(),txBytes:f(),rxPackets:f(),txPackets:f(),rxErrors:f(),txErrors:f(),timestampMs:f()}),vz=b({utilization:f(),model:p(),memoryUsedBytes:f(),memoryTotalBytes:f(),temperature:f().nullable()}),Awe=b({openFds:f(),threadCount:f(),activeHandles:f(),activeRequests:f()}),yz=b({avg10:f(),avg60:f(),avg300:f()}),bz=b({some:yz,full:yz.nullable()}),xz=b({cpu:Ewe,memory:Dwe,gpu:vz.nullable(),network:kwe,disk:Owe,pressure:b({cpu:bz.nullable(),memory:bz.nullable(),io:bz.nullable()}),process:Awe,cpuTemperature:f().nullable(),timestampMs:f()}),jwe=b({path:p(),totalBytes:f(),usedBytes:f(),availableBytes:f(),percent:f()}),Sz=b({pid:f(),cpu:f(),memory:f(),privateBytes:f().optional(),sharedBytes:f().optional()}),Mwe=b({addonId:p(),nodeId:p(),role:x([`hub`,`worker`]),pid:f(),state:x([`starting`,`running`,`stopping`,`stopped`,`crashed`]),uptimeSec:f()}),Nwe=b({pid:f(),ppid:f(),pgid:f(),classification:x([`root`,`managed`,`system`]),addonId:p().nullable(),nodeId:p().nullable(),command:p(),cpuPercent:f(),memoryRssBytes:f(),cpuMainPercent:f().nullable(),cpuGcPercent:f().nullable(),threadCount:f().nullable(),uptimeSec:f()}),Pwe=b({source:x([`cgroup-v2`,`cgroup-v1`]),currentBytes:f(),limitBytes:f().nullable(),anonBytes:f().nullable(),fileBytes:f().nullable(),shmemBytes:f().nullable(),slabBytes:f().nullable(),gpuShmemBytes:f().nullable()}).extend({atMs:f()}),Fwe=b({atMs:f(),samples:f().int(),cpuMainPercent:f().nullable(),cpuMainPercentMin:f().nullable(),cpuGcPercent:f().nullable(),cpuGcPercentMin:f().nullable(),cpuLifetimePercent:f(),cpuLifetimePercentMin:f(),memoryRssBytes:f(),memoryRssBytesMin:f(),processCount:f().int(),processCountMin:f().int()}),Iwe=b({key:p(),kind:x([`addon`,`root`,`unattributed`]),points:S(Fwe).readonly()}),Lwe=b({nodeId:p(),series:S(Iwe).readonly(),containerMemory:S(Pwe).readonly(),bucketMs:f(),retainedSamples:f(),oldestAtMs:f().nullable(),cadenceMs:f(),durable:v()}),Rwe=b({forNodeId:p(),sinceMs:f().optional(),maxPoints:f().int().positive().optional()}),Cz=b({cpuPercent:f(),memoryPercent:f().nullable(),memoryUsedMB:f().nullable(),memoryTotalMB:f(),diskPercent:f().optional(),temperature:f().optional(),gpuPercent:f().optional(),gpuMemoryPercent:f().optional()}),wz={name:`metrics-provider`,scope:`system`,mode:`singleton`,methods:{collectSnapshot:O(_(),xz),getCached:O(_(),xz.nullable()),getCurrent:O(_(),Cz),getDiskSpace:O(b({dirPath:p()}),jwe),getGpuInfo:O(_(),vz.nullable()),getCpuTemperature:O(_(),f().nullable()),getProcessStats:O(b({pids:S(f())}),S(Sz)),listAddonInstances:O(_(),S(Mwe).readonly()),getAddonStats:O(b({addonId:p()}),Sz.nullable()),listNodeProcesses:O(_(),S(Nwe).readonly()),getLoadSeries:O(Rwe,Lwe)},vocabulary:{notOperatorFacing:A.CLUSTER}},Tz=p().min(1).max(256),Ez=u(p(),l()),Dz=b({id:Tz,deviceId:f().int().optional(),at:f().int().optional(),expiresAt:f().int().optional(),data:Ez}),Oz=b({id:p(),deviceId:f().int().nullable(),at:f().nullable(),expiresAt:f().nullable(),rev:f().int(),updatedAt:f(),data:Ez}),kz=u(Ur,c([p(),f(),v(),b({in:S(c([p(),f(),v()])).min(1).max(_n)}),b({gt:c([p(),f()]).optional(),gte:c([p(),f()]).optional(),lt:c([p(),f()]).optional(),lte:c([p(),f()]).optional()}).refine(e=>Object.keys(e).length>0,{message:`name at least one bound`})])),Az={kind:Yr},jz={deviceId:f().int().optional(),atFrom:f().optional(),atTo:f().optional()},Mz=b({...Az,...jz,where:kz.optional(),order:x([`at`,`id`]).optional(),desc:v().optional(),limit:f().int().min(1).max(yn).default(100),cursor:p().min(1).optional()}),Nz=b({records:S(Oz),nextCursor:p().nullable()}),zwe=x([`created`,`unchanged`,`updated`]),Pz=b({kindId:f().int(),state:zwe,createdIndexes:S(p())}),Fz=S(p()),Iz=i(`op`,[b({op:o(`put`),kind:Yr,record:Dz,ifRev:f().int().min(0).optional()}),b({op:o(`patch`),kind:Yr,id:Tz,data:Ez,at:f().int().nullable().optional(),expiresAt:f().int().nullable().optional(),ifRev:f().int().min(1).optional()}),b({op:o(`delete`),kind:Yr,id:Tz})]),Lz=u(p(),u(p(),p())),Rz={name:`records`,scope:`system`,mode:`singleton`,internal:!0,methods:{declareKinds:O(b({kinds:u(Yr,Jr)}),b({kinds:u(p(),Pz)}),{kind:`mutation`,auth:`admin`}),get:O(b({...Az,id:Tz}),Oz.nullable(),{auth:`admin`}),getMany:O(b({...Az,ids:S(Tz).min(1).max(_n)}),S(Oz),{auth:`admin`}),secretRefs:O(b({...Az,ids:S(Tz).min(1).max(_n)}),Lz,{auth:`admin`}),put:O(b({...Az,record:Dz,ifRev:f().int().min(0).optional()}),b({rev:f().int(),releasedRefs:Fz}),{kind:`mutation`,auth:`admin`}),putMany:O(b({...Az,records:S(Dz).min(1).max(_n)}),b({count:f().int(),releasedRefs:Fz}),{kind:`mutation`,auth:`admin`}),patch:O(b({...Az,id:Tz,data:Ez,at:f().int().nullable().optional(),expiresAt:f().int().nullable().optional(),ifRev:f().int().min(1).optional()}),b({rev:f().int(),releasedRefs:Fz}),{kind:`mutation`,auth:`admin`}),delete:O(b({...Az,id:Tz}),b({deleted:v(),secretRefs:Fz}),{kind:`mutation`,auth:`admin`}),deleteMany:O(b({...Az,ids:S(Tz).min(1).max(_n)}),b({deleted:f().int(),secretRefs:Fz}),{kind:`mutation`,auth:`admin`}),query:O(Mz,Nz,{auth:`admin`}),count:O(b({...Az,...jz,where:kz.optional()}),b({count:f().int()}),{auth:`admin`}),histogram:O(b({...Az,deviceId:f().int().optional(),from:f(),to:f(),bucketMs:f().int().positive()}),b({buckets:S(b({bucketStart:f(),count:f().int()}))}),{auth:`admin`}),aggregate:O(b({...Az,op:x([`sum`,`min`,`max`,`count`]),field:Ur.optional(),groupBy:Ur.optional(),where:kz.optional()}),b({rows:S(b({group:c([p(),f(),ie()]),value:f().nullable()}))}),{auth:`admin`}),deleteWhere:O(b({...Az,deviceId:f().int().optional(),atBefore:f().optional(),where:kz.optional()}),b({deleted:f().int(),secretRefs:Fz}),{kind:`mutation`,auth:`admin`}),transact:O(b({ops:S(Iz).min(1).max(_n)}),b({results:S(b({rev:f().int().nullable(),deleted:v()})),releasedRefs:Fz,secretRefs:Fz}),{kind:`mutation`,auth:`admin`}),deleteDevice:O(b({deviceId:f().int(),kinds:S(Yr).optional()}),b({deleted:u(p(),f().int()),secretRefs:Fz}),{kind:`mutation`,auth:`admin`}),allocateId:O(b(Az),b({id:f().int()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:A.INTERNAL}},zz=u(p(),l()),Bz=b({integrationId:p().min(1)}),Vz=b({id:p().min(1)}),Hz=b({id:p(),deviceId:f().int().nullable(),at:f().nullable(),expiresAt:f().nullable(),rev:f().int(),updatedAt:f(),data:zz}),Uz={id:p().min(1),deviceId:f().int().optional(),at:f().int().optional(),expiresAt:f().int().optional(),data:zz},Wz=b({id:p(),addonId:p(),name:p(),info:zz,enabled:v().optional(),originStableId:p().optional()}),Bwe=b({id:f().int(),integrationId:p().nullable().optional(),parentDeviceId:f().int().nullable().optional(),type:p().optional(),name:p().optional(),stableId:p().optional()}),Gz=b({version:f().int(),methods:S(p())}),Kz=b({message:p(),meta:zz.optional(),tags:b({deviceId:f().int().optional()}).optional()}),Vwe={"ledger.declare":{input:b({owner:p().min(1),metas:S(Pd)}),output:b({bootId:p(),snapshot:x([`none`,`written`,`refused`]),steps:S(Jd),migrationApi:Gz.optional()}),behaviours:[`ledger.declare.answers-steps-in-engine-order`,`ledger.declare.answers-the-migration-api`]},"ledger.start":{input:b({id:p().min(1)}),output:b({proceed:v(),state:c([o(`pending`),Wd]),reason:p().nullable()}),behaviours:[`ledger.start.proceeds-when-predecessors-applied`]},"ledger.finish":{input:b({id:p().min(1),result:Ud}),output:b({status:Wd,error:p().nullable(),rowsChanged:f().int().nonnegative()}),behaviours:[`ledger.finish.records-the-outcome`]},"legacyRows.read":{input:Bz,output:zz,behaviours:[`legacyRows.read.returns-stored-rows`,`legacyRows.read.absent-store-is-empty`,`legacyRows.caller.sibling-package`]},"legacyRows.clear":{input:Bz,output:b({rows:f().int().nonnegative(),secrets:f().int().nonnegative()}),behaviours:[`legacyRows.clear.deletes-the-rows`,`legacyRows.clear.absent-store-is-noop`]},"legacyRows.patch":{input:Bz.extend({patch:zz}),output:b({written:v()}),behaviours:[`legacyRows.patch.upserts-keys-and-keeps-the-rest`,`legacyRows.patch.absent-store-writes-nothing`]},"legacyRows.deleteKeys":{input:Bz.extend({keys:S(p().min(1))}),output:b({present:v(),removed:zz}),behaviours:[`legacyRows.deleteKeys.removes-the-named-keys`,`legacyRows.deleteKeys.absent-store-reports-not-present`]},"records.get":{input:Vz,output:Hz.nullable(),behaviours:[`records.get.returns-the-row-or-null`]},"records.getResolved":{input:Vz,output:Hz.nullable(),behaviours:[`records.getResolved.resolves-secret-fields`]},"records.put":{input:b({...Uz,ifRev:f().int().optional()}),output:b({rev:f().int()}),behaviours:[`records.put.creates-and-replaces`,`records.put.if-rev-conflict-throws`]},"records.putMany":{input:b({records:S(b(Uz))}),output:b({count:f().int().nonnegative()}),behaviours:[`records.putMany.writes-every-row`]},"records.patch":{input:Vz.extend({partial:zz,ifRev:f().int().optional()}),output:b({rev:f().int()}),behaviours:[`records.patch.merges-and-null-removes`]},"records.delete":{input:Vz,output:b({deleted:v()}),behaviours:[`records.delete.reports-whether-a-row-went`]},"records.query":{input:b({deviceId:f().int().optional(),atFrom:f().optional(),atTo:f().optional(),where:kz.optional(),limit:f().int().min(1).optional(),cursor:p().min(1).optional(),resolveSecrets:v().optional()}),output:b({records:S(Hz),nextCursor:p().nullable()}),behaviours:[`records.query.pages-with-a-cursor`,`records.query.filters-on-a-declared-index`]},"records.deleteWhere":{input:b({deviceId:f().int().optional(),atBefore:f().optional(),where:kz.optional()}),output:b({count:f().int().nonnegative()}),behaviours:[`records.deleteWhere.deletes-the-matching-rows`]},"settings.read":{input:b({}),output:b({store:zz}),behaviours:[`settings.read.returns-the-addon-store`]},"settings.write":{input:b({patch:zz}),output:b({}),behaviours:[`settings.write.merges-and-keeps-other-keys`]},"settings.deleteKeys":{input:b({keys:S(p().min(1))}),output:b({removed:S(p())}),behaviours:[`settings.deleteKeys.removes-only-the-named-keys`]},"deviceSettings.listIds":{input:b({}),output:b({deviceIds:S(f().int())}),behaviours:[`deviceSettings.listIds.names-only-the-addons-own-devices`]},"deviceSettings.read":{input:b({deviceIds:S(f().int())}),output:b({blobs:u(p(),zz)}),behaviours:[`deviceSettings.read.returns-only-the-addons-own-blobs`]},"secrets.resolve":{input:b({refs:S(p())}),output:b({values:u(p(),p().nullable())}),behaviours:[`secrets.resolve.answers-null-for-a-missing-ref`]},"secrets.put":{input:b({ref:p().min(1),value:p()}),output:b({}),behaviours:[`secrets.put.stores-under-the-owner`]},"secrets.delete":{input:b({refs:S(p())}),output:b({deleted:f().int().nonnegative()}),behaviours:[`secrets.delete.ignores-unknown-refs`]},"integrations.list":{input:b({}),output:b({integrations:S(Wz)}),behaviours:[`integrations.list.lists-every-integration`]},"integrations.get":{input:b({id:p().min(1)}),output:Wz.nullable(),behaviours:[`integrations.get.null-for-an-unknown-id`]},"devices.list":{input:b({addonId:p().min(1),integrationId:p().min(1).optional()}),output:b({devices:S(Bwe)}),behaviours:[`devices.list.scoped-to-the-addon`,`devices.list.filters-by-integration`]},"devices.get":{input:b({deviceId:f().int()}),output:b({id:f().int(),integrationId:p().nullable(),hasConfig:v()}).nullable(),behaviours:[`devices.get.null-for-an-unknown-id`,`devices.get.reports-link-and-config`]},"devices.aliases":{input:b({deviceIds:S(f().int())}),output:b({aliases:u(p(),p())}),behaviours:[`devices.aliases.answers-for-the-named-ids-only`]},"devices.setIntegrationId":{input:b({deviceId:f().int(),integrationId:p().min(1)}),output:b({}),behaviours:[`devices.setIntegrationId.links-the-device`]},"node.localNodeId":{input:b({}),output:b({nodeId:p()}),behaviours:[`node.localNodeId.names-this-node`]},"log.info":{input:Kz,output:b({}),behaviours:[`log.info.writes-a-line`]},"log.warn":{input:Kz,output:b({}),behaviours:[`log.warn.writes-a-line`]}},qz={name:`migrations`,scope:`system`,mode:`singleton`,internal:!0,methods:{listLedger:O(b({}),b({entries:S(Gd)}),{auth:`admin`}),listPending:O(b({owner:p().optional()}),b({pending:S(Kd)}),{auth:`admin`}),dryRun:O(b({id:p().min(1)}),qd,{auth:`admin`}),markFailed:O(b({id:p().min(1),error:p().min(1)}),Gd,{kind:`mutation`,auth:`admin`}),retry:O(b({id:p().min(1)}),b({entries:S(Gd)}),{kind:`mutation`,auth:`admin`}),restorePreMigration:O(b({database:bd,snapshotId:p().min(1)}),b({scheduled:v(),held:S(p()),restartRequired:v()}),{kind:`mutation`,auth:`admin`}),declareOwner:O(b({owner:p().min(1),metas:S(Pd),retired:S(p().min(1)).optional()}),b({bootId:p(),snapshot:x([`none`,`written`,`refused`]),steps:S(Jd),migrationApi:Gz.optional()}),{kind:`mutation`,auth:`admin`}),startMigration:O(b({id:p().min(1)}),b({proceed:v(),state:c([o(`pending`),Wd]),reason:p().nullable()}),{kind:`mutation`,auth:`admin`}),finishMigration:O(b({id:p().min(1),result:Ud}),b({status:Wd,error:p().nullable(),rowsChanged:f().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),readLegacyIntegrationRows:O(b({integrationId:p().min(1)}),u(p(),l()),{auth:`admin`}),clearLegacyIntegrationRows:O(b({integrationId:p().min(1)}),b({rows:f().int().nonnegative(),secrets:f().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),patchLegacyIntegrationRows:O(b({integrationId:p().min(1),patch:u(p(),l())}),b({written:v()}),{kind:`mutation`,auth:`admin`}),deleteLegacyIntegrationRowKeys:O(b({integrationId:p().min(1),keys:S(p().min(1))}),b({present:v(),removed:u(p(),l())}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:A.INTERNAL}},Jz=b({sourceUrl:p(),metadata:bue,targets:S(yue).min(1).readonly(),calibrationRef:p().optional(),sessionId:p().optional()}),Yz={name:`model-convert`,scope:`system`,mode:`singleton`,internal:!0,methods:{convert:O(Jz,Sue,{kind:`mutation`,auth:`admin`,timeoutMs:6e5})},vocabulary:{notOperatorFacing:A.ML}},Xz=b({targetNodeId:p(),modelId:p(),format:x(ba),entry:Nh}),Zz=b({ok:v(),sha256:p(),bytes:f(),path:p()}),Qz={name:`model-distributor`,scope:`system`,mode:`singleton`,internal:!0,methods:{distributeModel:O(Xz,Zz,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:A.ML}},$z=i(`kind`,[b({kind:o(`camera`)}),b({kind:o(`sensor`),deviceId:f().int().positive()})]),eB=Object.freeze({kind:`camera`});function Hwe(e){if(e===void 0)return{triggeredBy:eB,malformed:!1};let t=$z.safeParse(e);return t.success?{triggeredBy:t.data,malformed:!1}:{triggeredBy:eB,malformed:!0}}var Uwe=`cameraSensors`,Wwe=8,tB=b({addonId:p().min(1),stableId:p().min(1)});function nB(e){return`${e.addonId}/${e.stableId}`}var rB=x([`in-addition`,`confirm`,`replace`]),iB=`in-addition`,aB=tB.extend({mode:rB.default(iB)}),oB=b({sensors:S(aB).min(1).max(8)}).superRefine((e,t)=>{let n=new Set;e.sensors.forEach((e,r)=>{let i=nB(e);n.has(i)&&t.addIssue({code:`custom`,path:[`sensors`,r],message:`duplicate camera sensor ${i}`}),n.add(i)})}),sB={addonId:p(),stableId:p(),mode:rB.default(iB)},cB=i(`state`,[b({...sB,state:o(`ready`),deviceId:f(),name:p(),caps:S(p()).readonly()}),b({...sB,state:o(`offline`),deviceId:f(),name:p(),reason:x([`offline`,`disabled`])}),b({...sB,state:o(`missing`),reason:p()}),b({...sB,state:o(`unsupported`),deviceId:f(),name:p(),reason:p()}),b({...sB,state:o(`unreadable`),reason:p()})]),lB=x([`onboard-not-listed`,`no-active-detection`]),uB=x([`always`,`when-confirmed`,`never`]),dB=x([`provider-not-split`]),fB=b({detected:v(),atMs:f()}),pB=i(`state`,[b({state:o(`not-configured`),cameraLevel:fB.optional()}),b({state:o(`unreadable`),reason:p(),cameraLevel:fB.optional()}),b({state:o(`configured`),cameraLevel:fB.optional(),sensors:S(cB).readonly(),cameraMotion:uB.optional(),notForwarded:lB.optional(),notEnforced:dB.optional()})]),Gwe=Object.freeze({state:`unreadable`,reason:`camera sensor mappings not loaded`}),mB=b({bbox:bS,pixelCount:f(),intensity:f()}),hB=b({detected:v(),regionCount:f(),regions:S(mB).readonly(),rawRegions:S(mB).readonly(),frameWidth:f(),frameHeight:f(),analysisMs:f()}),gB={name:`motion-detection`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[w.Camera],exposesDeviceSettings:!0,methods:{analyze:O(b({deviceId:f(),frame:yS.optional(),frameHandle:ta.optional()}),hB,{role:`admin`,kind:`mutation`,notOperatorFacing:`the pipeline feeds it frames — an internal stage, never called by a person`}),removeCamera:O(b({deviceId:f()}),_(),{role:`admin`,kind:`mutation`,notOperatorFacing:`pipeline housekeeping when a camera leaves`}),reset:O(_(),_(),{role:`admin`,kind:`mutation`,notOperatorFacing:`pipeline housekeeping`})},events:{onMotion:{data:b({deviceId:f(),detected:v(),regionCount:f()}),notOperatorFacing:"the analyzer’s raw verdict; the operator signal is the `motion` cap’s `detected` state"}},vocabulary:{noun:N(`Motion analysis`,`Analisi del movimento`),order:3160}},_B=b({package:v(),confidence:f().min(0).max(1),reason:p().min(1)}),vB=b({x:f(),y:f()}),yB=b({kind:o(`rect`),x:f(),y:f(),width:f(),height:f()}),bB=b({kind:o(`polygon`),points:S(vB)}),xB=b({kind:o(`grid`),gridWidth:f().meta(j(`none`)),gridHeight:f().meta(j(`none`)),cells:S(v())}),SB=b({kind:o(`line`),points:S(vB)}),Kwe=i(`kind`,[yB,bB,xB,SB]),CB=x([`rect`,`polygon`,`grid`,`line`]),wB=b({min:f(),max:f()}),TB=b({width:f(),height:f()}),EB=[`owner-not-ready`,`store-read-failed`,`three-way-read-unavailable`,`invalid-stored`,`not-cluster-scoped`],DB=[{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)`}]}],qwe=`cluster-step-models`;function OB(e){return`clusterModel:${e}`}function Jwe(e){return DB.some(t=>t.stepId===e)}var kB=Object.freeze(Object.fromEntries(DB.map(e=>[e.stepId,e.defaultModelId])));function AB(e){return e==null||e===``?{kind:`absent`}:typeof e==`string`?{kind:`chosen`,modelId:e}:{kind:`invalid`,value:e}}function jB(e){let t=[];for(let n of DB){let r=AB(e[OB(n.stepId)]);r.kind===`invalid`&&t.push({stepId:n.stepId,value:r.value})}return t}function MB(e){let t={};for(let n of DB){let r=AB(e[OB(n.stepId)]);t[n.stepId]=r.kind===`chosen`?r.modelId:n.defaultModelId}return t}function Ywe(e){return typeof e==`object`&&!!e&&`key`in e}function Xwe(e){return e===null?kB:MB(PB(e,NB()))}function Zwe(e){return e===null?[]:jB(PB(e,NB()))}function NB(){return new Set(DB.map(e=>OB(e.stepId)))}function PB(e,t){let n={};for(let r of e.sections)for(let e of r.fields)!Ywe(e)||typeof e.key!=`string`||t.has(e.key)&&(n[e.key]=e.value);return n}function Qwe(e,t){let n=DB.find(t=>t.stepId===e);if(n===void 0)return null;let r=t[e];return r!==void 0&&r!==``?r:n.defaultModelId}var $we=24,FB=[{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 IB(e,t){return`clusterStepSetting:${e}:${t}`}function eTe(e){return FB.filter(t=>t.stepId===e)}var tTe=f().finite();function LB(e){let t={};for(let n of FB){let r=tTe.safeParse(e[IB(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 RB=LB({});function nTe(e){return e===null?RB:LB(PB(e,new Set(FB.map(e=>IB(e.stepId,e.key)))))}function rTe(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 zB=x([`new`,`entered`,`left`,`moving`,`idle`]),BB=x([`motion`,`object`,`audio`]),VB=i(`kind`,[yB,bB]),HB=x([`motion`,`audio`,`person`,`vehicle`,`animal`,`door`,`pir`,`smoke`,`water`,`button`,`package`,`generic`]),UB=x([`motion`,`audio`,`detection`,`sensor`,`control`,`custom`,`package`]),iTe=x([`macro`,`sub`]),WB=b({kind:p(),labelKey:p(),label:p(),color:p(),iconId:p(),icon:HB,category:UB,parentKind:p().nullable(),level:iTe,source:b({capName:p(),deviceId:f()})}),GB=b({deviceId:f(),kinds:S(WB).readonly()}),KB=b({id:p(),deviceId:f(),sourceDeviceId:f(),kind:p(),value:u(p(),l()).nullable(),timestamp:f()}),qB=b({x:f(),y:f(),timestamp:f(),bbox:bS,source:x([`frame`,`recovery`]).optional(),score:f().optional()}),aTe=b({timestamp:f(),position:qB,mediaId:f().int()}),JB=b({minX:f(),minY:f(),maxX:f(),maxY:f()}),YB=x([`full`,`slim`]),XB=b({label:p(),peakScore:f(),count:f(),firstAt:f(),lastAt:f()}),ZB=x([`pipeline`,`onboard`,`sensor`,`audio`]),QB=x([`none`,`staging`,`trained`]),oTe=500,$B={markForTrain:v().optional(),debug:v().optional(),debugNote:p().max(500).optional(),favourited:v().optional()},eV={retrainStatus:QB.optional()},tV=b($B),nV=b({trackId:p(),markForTrain:v(),debug:v(),debugNote:p(),favourited:v(),retrainStatus:QB}),sTe=c([o(1),o(2)]),rV=b({stepId:p(),modelId:p().optional(),decidedAt:f(),identityId:p().optional()}),iV={label:p().optional(),labelScore:f().optional(),labelMeta:rV.optional(),subLabel:p().optional(),subLabelScore:f().optional(),subLabelMeta:rV.optional()},aV=b({deviceId:f(),tracks:f().int(),files:f().int(),bytes:f().int()}),oV=b({generatedAt:f(),trackCount:f().int(),fileCount:f().int(),byteCount:f().int(),truncated:v(),devices:S(aV).readonly()}),sV=b({nodeId:p(),deviceKey:p().optional(),modelId:p().optional()}),cV=b({trackId:p(),deviceId:f(),className:p(),...iV,producingDeviceName:p().optional(),source:ZB.optional(),firstSeen:f(),lastSeen:f(),positions:S(qB).readonly(),snapshots:S(aTe).readonly(),zonesVisited:S(p()).readonly(),zoneNames:S(p()).readonly().optional(),classes:S(p()).readonly().optional(),totalDistance:f(),state:zB,active:v(),importance:f().optional(),bestEventId:p().optional(),importanceReason:p().optional(),audioLabels:S(XB).readonly().optional(),envelope:JB.optional(),hasFace:v().optional(),hasEmbeddedFace:v().optional(),hasRider:v().optional(),previewMissReason:p().optional(),modelId:p().optional(),openedPlacement:sV.optional(),closedPlacement:sV.optional(),frameWidth:f().optional(),frameHeight:f().optional(),...$B,...eV}),lV={id:f().int(),deviceId:f(),timestamp:f()},uV=b({...lV,kind:o(`motion`),regionCount:f(),regions:S(b({bbox:bS,pixelCount:f(),intensity:f()})).readonly().optional(),frameWidth:f().optional(),frameHeight:f().optional(),mediaUrl:p().optional(),triggeredBy:$z.optional(),durationMs:f().nullable().optional(),edges:S(f()).readonly().optional()}),dV=x([`pipeline`,`onboard`]),fV=x([`enter`,`exit`]),pV=b({direction:fV,zoneId:p(),zoneName:p().optional()}),cTe=b({zoneId:p(),zoneName:p().optional(),overlapPct:f()}),mV=b({...lV,kind:o(`object`),source:dV.optional(),frameId:p().optional(),idempotencyKey:p().optional(),trackId:p().optional(),className:p(),...iV,confidence:f().optional(),bbox:bS.optional(),zones:S(p()).readonly().optional(),zoneOverlaps:S(cTe).readonly().optional(),spawnRefused:p().optional(),state:zB.optional(),zoneCrossing:pV.optional(),frameWidth:f().optional(),frameHeight:f().optional(),mediaId:f().int().optional(),keyFrameMediaId:f().int().optional(),mediaUrl:p().optional(),observedAt:f().optional(),packagePossible:v().optional(),packageLlmVerdict:_B.optional(),importance:f().optional()}),hV=b({...lV,kind:o(`audio`),rms:f(),dbfs:f(),classification:b({className:p(),originalClass:p().optional(),score:f()}).optional(),classifyOutcome:TS.optional(),mediaUrl:p().optional()}),gV=x([`crop`,`thumbnail`,`snapshot`,`firstFrame`,`lastFrame`,`fullFrame`,`fullFrameBoxed`,`faceCrop`,`plateCrop`,`keyFrame`,`keyFrameSmall`,`thumbnailSmall`,`confirmationCrop`,`debugCrop`,`sceneFrame`,`lastSceneFrame`]),_V=b({mediaId:f().int(),kind:gV,sizeBytes:f(),timestamp:f()}),vV=_V.extend({url:p(),base64:p()}),yV=vV.omit({base64:!0}),bV=x([`person`,`vehicle`,`animal`,`package`,`face`,`plate`]),xV=x([`subject`,`model_error`]),SV=x([`operator`,`assist`,`pipeline`,`llm`]),CV=b({x:f(),y:f(),w:f(),h:f()}),wV=b({source:SV,ref:p().min(1),bbox:CV,macroClass:bV,label:p().optional(),score:f().optional(),modelId:p().optional()}),TV=b({ref:p().min(1),snapshot:wV}),EV=x(Sf),DV=b({ref:p(),savedId:p().optional(),status:EV,approximate:v(),origin:wV.optional(),macroClass:bV.optional(),label:p().optional(),iou:f().optional()}),OV=b({boxes:S(DV).readonly(),summary:b({counts:u(EV,f().int()),total:f().int(),changed:f().int(),approximate:v()})}),kV=b({id:p(),trackId:p().optional(),deviceId:f(),mediaKey:p(),bbox:CV,macroClass:bV,label:p().optional(),subLabel:p().optional(),kind:xV,source:SV,assistModelId:p().optional(),assistScore:f().optional(),origin:wV.nullable().optional(),exportedInBatch:p().optional(),createdAt:f()}),AV=kV.omit({id:!0,trackId:!0,deviceId:!0,mediaKey:!0,createdAt:!0,exportedInBatch:!0}),jV=x([`correct`,`wrong`,`wrong-label`]),MV=b({verdict:jV,suggestedClass:p().optional(),suggestedMacroClass:bV.optional(),suggestedLabel:p().optional(),trackId:p(),at:f().optional()}),NV=b({trackId:p(),className:p(),label:p().optional(),bbox:CV.optional(),verdict:jV,suggestedClass:p().optional(),at:f().optional()}),PV=b({trackId:p(),deviceId:f(),className:p(),label:p().optional(),firstSeen:f(),lastSeen:f(),frameCount:f().int(),annotationCount:f().int(),verdict:MV.optional()}),FV=b({mediaId:f().int(),kind:gV,timestamp:f(),sizeBytes:f().int(),copied:v()}),IV=b({bbox:CV,macroClass:bV,label:p().optional(),subLabel:p().optional(),score:f().optional(),modelId:p().optional(),trackId:p(),basis:x([`subject-box`,`position`,`verdict`]),deltaMs:f()}),LV=x([`track`,`recording`]),RV=b({frameId:p(),deviceId:f(),origin:LV,trackId:p().optional(),sourceMediaId:f().int().optional(),epochMs:f().optional(),sourceKind:gV,sizeBytes:f().int(),width:f().int(),height:f().int(),copiedAt:f(),capturedAt:f().optional(),complete:v(),pipelineBoxes:S(IV).readonly().optional(),collectionIds:S(p()).readonly().optional(),verdict:MV.optional(),revision:f().int().optional(),dismissed:S(TV).readonly().optional(),review:OV.optional(),imageUrl:p().optional(),thumbnailUrl:p().optional()}),zV=x([`source-missing`,`unreadable-image`,`write-failed`]),BV=b({copied:S(RV).readonly(),refused:S(b({sourceMediaId:f().int(),reason:zV})).readonly()}),VV=b({candidates:S(FV).readonly(),copies:S(RV).readonly(),autoPickMediaId:f().int().optional()}),HV=x([`unannotated`,`annotated`,`complete`]),UV=b({workState:HV.optional(),deviceIds:S(f()).max(500).optional(),collectionId:p().optional(),classes:S(bV).optional(),page:f().int().positive().default(1),pageSize:f().int().positive().max(100).default(50)}),WV=RV.extend({workState:HV}),GV=b({frames:S(WV).readonly(),total:f().int().nonnegative(),page:f().int().positive(),pageSize:f().int().positive()}),KV=b({deviceId:f(),unannotated:f().int().nonnegative(),annotated:f().int().nonnegative(),complete:f().int().nonnegative(),pctOfCorpus:f().min(0).max(1).nullable()}),qV=b({total:f().int().nonnegative(),unannotated:f().int().nonnegative(),annotated:f().int().nonnegative(),complete:f().int().nonnegative(),cameras:S(KV).readonly()}),JV=b({deviceIds:S(f()).optional(),frameIds:S(p()).max(2e4).optional(),collectionIds:S(p()).max(200).optional(),collectionId:p().optional(),batchId:p().optional(),completeOnly:v().optional(),workState:HV.optional(),classes:S(bV).optional()}),YV=x([`frames`,`crops`]),XV=b({kind:o(`http`),method:x([`PUT`,`POST`]),url:p().url(),headers:u(p(),p()).optional()}),ZV=b({batchId:p(),frames:f().int(),crops:f().int(),annotations:f().int(),missing:f().int(),bytes:f().int(),sha256:p(),status:f().int()}),QV=i(`kind`,[b({kind:o(`package`),zone:CV.optional()}),b({kind:o(`objects`),modelId:p(),minScore:f().optional()})]),$V=i(`kind`,[b({kind:o(`proposed`),modelId:p(),stepId:p(),minScore:f(),proposals:S(AV).readonly(),belowThreshold:f().int()}),b({kind:o(`refused`),reason:p(),detail:p().optional()})]),eH=b({id:p(),name:p(),createdAt:f(),frameCount:f().int()}),tH=i(`kind`,[b({kind:o(`created`),collection:eH}),b({kind:o(`refused`),reason:x([`empty-name`,`duplicate-name`])})]),nH=i(`kind`,[b({kind:o(`renamed`),collection:eH}),b({kind:o(`refused`),reason:x([`empty-name`,`duplicate-name`,`unknown-collection`])})]),rH=i(`kind`,[b({kind:o(`added`),collectionId:p(),frame:RV,reused:v()}),b({kind:o(`refused`),reason:x([`unknown-collection`,`still-unavailable`,`still-busy`,`unreadable-image`,`write-failed`]),detail:p().optional()})]),iH=b({id:p(),name:p(),model:p(),kind:p(),leavesHouse:v()}),aH=AV.extend({reason:p()}),oH=b({ref:p(),verdict:x([`confirmed`,`wrong-class`,`not-an-object`,`uncertain`]),suggestedClass:bV.optional(),reason:p()}),sH=i(`kind`,[b({kind:o(`proposed`),profileId:p(),model:p(),leftHouse:v(),proposals:S(aH).readonly(),reviews:S(oH).readonly(),rejected:f().int()}),b({kind:o(`refused`),reason:x([`unknown-frame`,`unreadable-frame`,`unknown-profile`,`profile-disabled`,`no-vision`,`cloud-not-confirmed`,`llm-error`,`malformed-answer`]),detail:p().optional()})]),cH=b({deviceIds:S(f()).readonly().optional(),collectionIds:S(p()).max(200).readonly().optional(),frameIds:S(p()).max(2e4).readonly().optional()}),lH=b({frames:f().int(),completeFrames:f().int(),completeness:f(),subjects:f().int(),modelErrors:f().int(),hardNegatives:f().int(),cells:S(b({macroClass:p(),deviceId:f(),lighting:x([`day`,`night`,`unknown`]),subjects:f().int(),frames:f().int()})).readonly(),cameras:S(b({deviceId:f(),frames:f().int(),completeFrames:f().int()})).readonly()}),lTe=b({id:p(),name:p(),createdAt:f(),selection:cH,layout:YV,completeOnly:v(),frameCount:f().int(),annotationHash:p(),manifestSchema:p(),stats:lH}),uH=b({collectionIds:S(p()).min(1),workState:x([`complete`,`annotated_or_complete`,`any_annotated`]).default(`complete`)}),dH=i(`kind`,[b({kind:o(`resolved`),frameIds:S(p()).max(2e4).readonly(),stats:lH,annotationHash:p(),layout:YV}),b({kind:o(`refused`),reason:x([`unknown-collection`,`no-frames`]),detail:p()})]),fH=b({trackId:p(),retrainStatus:QB,changed:v(),reason:x([`unknown-track`,`no-frames-copied`,`not-staging`,`not-trained`,`unchanged`]).optional()}),pH=1e3,mH=5e3,hH=b({deviceId:f(),since:f().optional(),until:f().optional(),limit:f().int().min(1).max(mH).default(pH),projection:x([`full`,`slim`]).optional()}),uTe=hH.extend({classFilter:p().optional()}),gH=b({deviceIds:S(f()),since:f().optional(),until:f().optional(),limit:f().int().min(1).max(1e3).default(200),cursor:p().optional(),projection:YB.optional(),includeStationary:v().optional(),classes:S(p()).optional(),excludeSources:S(ZB).optional()}),_H=b({tracks:S(cV).readonly(),nextCursor:p().nullable()}),vH=50,yH=200,dTe=b({deviceId:f(),since:f(),until:f(),limit:f().int().min(1).max(yH).default(vH),minImportance:f().min(0).max(1).optional(),classFilter:p().optional()}),bH=b({id:p(),trackId:p(),timestamp:f(),className:p(),...iV,importance:f(),bestEventId:p(),windowMs:f().optional(),audioLabels:S(XB).readonly().optional(),...$B,...eV}),fTe=b({deviceIds:S(f()).min(1).max(200),since:f(),until:f(),limit:f().int().min(1).max(yH).default(vH),minImportance:f().min(0).max(1).optional(),classFilter:p().optional()}),pTe=b({deviceId:f(),events:S(bH).readonly()}),xH=b({bucketStart:f(),motion:f().int(),object:f().int(),audio:f().int(),audioDbfs:f().optional()}),mTe=200,SH=b({deviceId:f(),read:x([`read`,`unreadable`]),buckets:S(xH).readonly()}),hTe=b({trackId:p(),className:p(),confidence:f(),bbox:bS,zones:S(p()).readonly(),state:zB}),gTe=a({id:p(),kind:x([`first-level`,`detail`]),macroClass:p(),score:f(),bbox:b({x:f(),y:f(),width:f(),height:f()}),labels:S(a({label:p(),score:f()})).readonly(),parentId:p().optional()}),CH=mV.extend({score:f()}),_Te=b({text:p(),deviceId:f().optional(),since:f().optional(),until:f().optional(),classFilter:p().optional(),limit:f().default(50),minScore:f().min(0).max(1).optional(),strictness:yh.optional(),modelId:p().min(1).optional()}),wH=b({tracks:f().int(),events:f().int(),media:f().int(),faces:f().int(),plates:f().int(),embeddings:f().int()}),vTe=b({mediaDropped:f().int(),tracks:f().int(),events:f().int()}),yTe=b({deviceId:f(),rows:f().int(),bytes:f().int()}),bTe=b({totalRows:f().int(),totalBytes:f().int(),devices:S(yTe).readonly()}),xTe=b({kind:gV,rows:f().int(),bytes:f().int()}),STe=b({totalRows:f().int(),totalBytes:f().int(),kinds:S(xTe).readonly(),unaccountedRows:f().int(),unaccountedBytes:f().int()}),TH=b({motion:f().int(),object:f().int(),audio:f().int()}),CTe=b({deviceId:f().optional(),since:f().optional(),until:f().optional(),maxTracks:f().int().positive().optional(),executeOnNodeId:p().optional(),pacingMs:f().int().nonnegative().optional(),force:v().optional()}),wTe=b({deleted:f(),failedIndexes:S(p()).optional()}),EH=x([`stores-unavailable`,...EB,`method-unavailable`,`read-failed`,`reads-disagree`,`not-a-clip-model`,`force-requires-max-tracks`]),TTe=b({started:v(),alreadyRunning:v(),refusal:EH.optional(),modelId:p().optional(),index:p().optional()}),ETe=b({running:v(),scanned:f(),rebuilt:f(),missingKeyFrame:f(),missingEvent:f(),missingBbox:f(),boxSource:b({subjectBox:f(),positions:f(),event:f(),refused:f()}),alreadyInSpace:f(),force:v().nullable(),forcedInSpace:f(),notRunnable:f(),noCapableNode:f(),failed:f(),complete:v().nullable(),startedAtMs:f().nullable(),finishedAtMs:f().nullable(),error:p().nullable(),modelId:p().nullable(),index:p().nullable()}),DTe=b({started:v(),alreadyRunning:v()}),OTe=b({mode:x([`report`,`reclaim`]).default(`report`),scopes:S(x([`motion-still`,`track-filmstrip`])).min(1).optional(),deviceIds:S(f().int()).min(1).optional(),restart:v().optional(),pageSize:f().int().min(50).max(5e3).optional(),maxRowsPerDevice:f().int().min(1).max(5e5).optional(),maxReclaimPerDevice:f().int().min(1).max(5e5).optional(),maxBytesPerRun:f().int().min(1).optional(),budgetMinutes:f().int().min(1).max(720).optional(),throttleBytesPerSec:f().int().min(64*1024).optional(),graceMinutes:f().int().min(1).max(10080).optional()}),kTe=b({running:v(),mode:x([`report`,`reclaim`]).nullable(),totalExamined:f(),totalEligible:f(),totalReclaimed:f(),totalBytesReclaimed:f(),totalRefused:f(),devicesDone:f(),complete:v().nullable(),startedAtMs:f().nullable(),finishedAtMs:f().nullable(),error:p().nullable()}),DH=x([`motion`,`audio-dbfs`,`battery`,`occupancy`]),ATe=`|`;function jTe(e,t){let n=e??``;return t===void 0?n:`${n}|${t}`}function MTe(e){let t=e.indexOf(`|`);return t<0?{zoneId:e}:{zoneId:e.slice(0,t),className:e.slice(t+1)}}var OH=b({scope:p(),bucketStart:f().int(),samples:f().int().nonnegative(),sum:f(),min:f(),max:f()}),kH={name:`pipeline-analytics`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[w.Camera],exposesDeviceSettings:!0,methods:{getActiveTracks:O(b({deviceId:f()}),S(cV).readonly()),getTrack:O(b({deviceId:f(),trackId:p()}),cV.nullable()),listTracks:O(b({deviceId:f(),since:f().optional(),until:f().optional(),limit:f().optional(),zone:VB.optional(),projection:YB.optional(),includeStationary:v().optional(),classes:S(p()).optional(),excludeSources:S(ZB).optional()}),S(cV).readonly()),listRecentTracks:O(gH,_H),clearTracks:O(b({deviceId:f()}),_(),{kind:`mutation`,auth:`admin`}),getMotionEvents:O(hH,S(uV).readonly()),getObjectEvents:O(uTe,S(mV).readonly()),getAudioEvents:O(hH,S(hV).readonly()),listEventKinds:O(b({deviceId:f()}),S(WB).readonly()),listEventKindsBatch:O(b({deviceIds:S(f()).min(1).max(200)}),S(GB).readonly()),getSensorEvents:O(b({deviceId:f(),since:f().optional(),until:f().optional(),kinds:S(p()).optional(),limit:f().int().min(1).max(mH).default(pH)}),S(KB).readonly()),getKeyEvents:O(dTe,S(bH).readonly()),getKeyEventsBatch:O(fTe,S(pTe).readonly()),readLongTermSeries:O(b({deviceId:f(),series:DH,scope:p().optional(),from:f(),to:f(),limit:f().int().positive().optional()}),S(OH).readonly()),getEventDensity:O(b({deviceId:f(),since:f(),until:f(),bucketMs:f().int().positive()}),S(xH).readonly()),getEventDensityBatch:O(b({deviceIds:S(f()).min(1).max(200),since:f(),until:f(),bucketMs:f().int().positive()}),S(SH).readonly()),pruneEventsBefore:O(b({deviceId:f(),cutoffMs:f()}),b({motion:f().int(),object:f().int(),audio:f().int()}),{kind:`mutation`,auth:`admin`}),pruneTracksBefore:O(b({deviceId:f(),cutoffMs:f()}),wH,{kind:`mutation`,auth:`admin`}),wipeAllAnalytics:O(b({deviceId:f()}),wH,{kind:`mutation`,auth:`admin`}),reconcileFromDisk:O(b({deviceId:f()}),vTe,{kind:`mutation`,auth:`admin`}),deleteTracks:O(b({deviceId:f(),trackIds:S(p()).min(1)}),b({deleted:f().int(),failed:S(p()).readonly(),sparedMediaIds:S(f().int()).readonly().optional()}),{kind:`mutation`,auth:`admin`}),setTrackFlags:O(b({deviceId:f(),trackId:p(),flags:tV}),nV,{kind:`mutation`,notOperatorFacing:`curating a recorded track in the review UI, not a live step`}),listArchivedDebugNotes:O(Nf,S(Mf).readonly(),{kind:`query`}),setTrackRelation:O(zf,Lf,{kind:`mutation`,notOperatorFacing:`curating recorded tracks in the review UI, not a live step`}),clearTrackRelation:O(Bf,Vf,{kind:`mutation`,notOperatorFacing:`curating recorded tracks in the review UI, not a live step`}),setTrackPurity:O(Hf,Uf,{kind:`mutation`,notOperatorFacing:`curating a recorded track in the review UI, not a live step`}),listTrackRelations:O(Wf,Gf,{kind:`query`}),listBirthDecisions:O(jf,S(Af).readonly(),{kind:`query`}),getEventStoreFootprint:O(b({}),bTe,{kind:`query`,auth:`admin`}),getEventMediaFootprintByKind:O(b({deviceId:f().int().optional()}),STe,{kind:`query`,auth:`admin`}),pruneEvents:O(b({olderThanMs:f(),reason:$f.optional()}),TH,{kind:`mutation`,auth:`admin`}),deleteDeviceEvents:O(b({deviceId:f()}),TH,{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:O(Dp,b({paused:o(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:O(Dp,b({resumed:o(!0)}),{kind:`mutation`,auth:`admin`}),refreshStorageLocationsForMigration:O(Dp,b({refreshed:o(!0)}),{kind:`mutation`,auth:`admin`}),startStorageMigrationMove:O(Ip,b({jobId:p()}),{kind:`mutation`,auth:`admin`}),getStorageMigrationMoveStatus:O(b({jobId:p()}),wp.nullable(),{auth:`admin`}),cancelStorageMigrationMove:O(b({jobId:p()}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`}),relocateMedia:O(Ap,b({jobId:p()}),{kind:`mutation`,auth:`admin`}),countUnstampedEventMedia:O(b({}),Mp,{auth:`admin`}),getMediaLocationCensus:O(Np,Fp,{kind:`query`,auth:`admin`}),countRelocatableMedia:O(cm,sm,{kind:`query`,auth:`admin`}),listRelocateMediaJobs:O(b({}),S(wp).readonly(),{kind:`query`,auth:`admin`}),cancelRelocateMedia:O(b({jobId:p()}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`}),listOpsLog:O(tp,S(ep).readonly(),{kind:`query`,auth:`admin`}),reclaimDebugMedia:O(OTe,DTe,{kind:`mutation`,auth:`admin`}),getMediaReclaimStatus:O(b({}),kTe,{kind:`query`,auth:`admin`}),getTrainingExportSummary:O(b({deviceIds:S(f()).optional()}),oV,{kind:`query`,auth:`admin`}),getTrainingExportUrl:O(b({deviceIds:S(f()).optional()}),b({url:p()}),{kind:`query`,auth:`admin`}),listRetrainStaging:O(b({deviceIds:S(f()).optional(),limit:f().int().min(1).max(500).optional()}),S(PV).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),listRetrainCorpusPage:O(UV,GV,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),getRetrainCorpusKpi:O(b({}),qV,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),listRetrainFrames:O(b({trackId:p()}),VV,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),selectRetrainFrames:O(b({deviceId:f(),trackId:p(),mediaIds:S(f().int()).min(1)}),BV,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),deselectRetrainFrame:O(b({deviceId:f(),trackId:p().optional(),frameId:p()}),b({removed:v(),removedAnnotations:f().int()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),getRetrainFrameImage:O(b({frameId:p()}),b({base64:p(),width:f().int(),height:f().int()}),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),proposeRetrainAnnotations:O(b({deviceId:f(),trackId:p().optional(),frameId:p(),subject:QV,nodeId:p().optional()}),$V,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainAnnotations:O(b({trackId:p().optional(),frameIds:S(p()).max(2e3).optional()}),S(kV).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),saveRetrainAnnotations:O(b({deviceId:f(),trackId:p().optional(),frameId:p(),annotations:S(AV),expectedRevision:f().int().optional(),dismissed:S(TV).optional()}),S(kV).readonly(),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),backfillRetrainOrigins:O(b({deviceId:f(),trackId:p().optional(),frameId:p(),expectedRevision:f().int().optional(),origins:S(b({annotationId:p(),origin:wV})).min(1).max(500)}),b({updated:f().int(),skipped:f().int(),revision:f().int()}),{kind:`mutation`,auth:`admin`}),completeRetrainTrack:O(b({deviceId:f(),trackId:p()}),fH,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),restageRetrainTrack:O(b({deviceId:f(),trackId:p()}),fH,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),getRetrainExportUrl:O(JV.extend({layout:YV.optional()}),b({url:p()}),{kind:`query`,auth:`admin`}),setRetrainFrameComplete:O(b({deviceId:f(),trackId:p().optional(),frameId:p(),complete:v()}),RV,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),writeRetrainArchive:O(b({filter:JV,layout:YV,target:XV}),ZV,{kind:`mutation`,auth:`admin`,timeoutMs:60*6e4}),offerRetrainArchive:O(b({filter:JV,layout:YV}),b({ticket:ii,frames:f().int(),annotations:f().int()}),{kind:`mutation`,auth:`admin`,timeoutMs:12e4}),listRetrainAssistProfiles:O(b({}),S(iH).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),proposeRetrainAnnotationsWithLlm:O(b({deviceId:f(),trackId:p().optional(),frameId:p(),profileId:p(),classes:S(bV).min(1),boxes:S(b({ref:p(),bbox:CV,macroClass:bV,label:p().optional()})).max(50),allowCloud:v()}),sH,{kind:`mutation`,auth:`admin`,timeoutMs:18e4}),createRetrainCollection:O(b({name:p().max(120)}),tH,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainCollections:O(b({}),S(eH).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),resolveRetrainTrainingCorpus:O(uH,dH,{kind:`query`,auth:`admin`,timeoutMs:6e4}),renameRetrainCollection:O(b({id:p(),name:p().max(120)}),nH,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),deleteRetrainCollection:O(b({id:p()}),b({deleted:v(),removedFrames:f().int()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),addRetrainFrameFromRecording:O(b({collectionId:p(),deviceId:f(),epochMs:f(),verdictSubject:NV.optional()}),rH,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`,timeoutMs:6e4}),addRetrainFramesToCollection:O(b({collectionId:p(),frameIds:S(p()).min(1).max(500)}),b({added:f().int(),alreadyMember:f().int(),unknownFrameIds:S(p()).readonly()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),removeRetrainFrameFromCollection:O(b({collectionId:p(),frameId:p()}),b({removed:v(),deletedFrame:v()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainCollectionFrames:O(b({collectionId:p()}),S(RV).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),getEventMedia:O(b({ownerType:kl,eventId:f().int(),kind:gV.optional(),deviceId:f()}),S(vV).readonly()),getTrackMedia:O(b({trackId:p(),kinds:S(gV).optional(),deviceId:f()}),S(vV).readonly()),listTrackMedia:O(b({trackId:p(),deviceId:f()}),S(yV).readonly()),listEventMedia:O(b({ownerType:kl,eventId:f().int(),deviceId:f()}),S(yV).readonly()),ownersWithMedia:O(b({deviceId:f(),ownerKind:jl,ownerIds:S(p()).max(5e3)}),S(p()).readonly()),searchObjectEvents:O(_Te,S(CH).readonly(),{caller:`required`}),wipeObjectEmbeddings:O(b({}),wTe,{kind:`mutation`,auth:`admin`}),rebuildObjectEmbeddings:O(CTe,TTe,{kind:`mutation`,auth:`admin`}),getObjectEmbeddingRebuildStatus:O(b({}),ETe)},events:{onFrameTracked:{data:b({deviceId:f(),timestamp:f(),frameWidth:f(),frameHeight:f(),detections:S(gTe).readonly()}),notOperatorFacing:`one tracker frame — stream rate, never an automation trigger`},onTrackStarted:{data:b({deviceId:f(),trackId:p(),className:p()}),trigger:{category:C.PipelineAnalyticsTrackStarted,label:N(`Subject appeared`,`Soggetto comparso`),phrase:N(`When {device} starts following a subject`,`Quando {device} inizia a seguire un soggetto`),icon:`scan-eye`}},onTrackEnded:{data:b({deviceId:f(),trackId:p(),className:p(),durationMs:f()}),trigger:{category:C.PipelineAnalyticsTrackEnded,label:N(`Subject left`,`Soggetto uscito`),phrase:N(`When a subject leaves the view of {device}`,`Quando un soggetto esce dall’inquadratura di {device}`),icon:`scan-eye`}},onDetectionEvent:{data:b({deviceId:f(),kind:BB,eventId:p(),timestamp:f()}),trigger:{category:C.PipelineAnalyticsDetectionEvent,label:N(`Detection event`,`Evento di rilevamento`),phrase:N(`When {device} records a detection event`,`Quando {device} registra un evento di rilevamento`),icon:`radar`}}},vocabulary:{noun:N(`Tracking`,`Tracciamento`),order:3200,extraEvents:[{category:C.PipelineAnalyticsPackageDelivered,label:N(`Package delivered`,`Pacco consegnato`),phrase:N(`When a package is left in front of {device}`,`Quando viene lasciato un pacco davanti a {device}`),icon:`package`},{category:C.PipelineAnalyticsPackagePickedUp,label:N(`Package picked up`,`Pacco ritirato`),phrase:N(`When a package is picked up in front of {device}`,`Quando viene ritirato un pacco davanti a {device}`),icon:`package-open`}]}},AH=b({stepId:p(),modelId:p(),detections:S(b({bbox:s([f(),f(),f(),f()]),score:f(),landmarks:S(b({x:f(),y:f()})).optional()})).min(1)}),jH=b({handle:ta,cropFrameSpace:b({x:f(),y:f(),w:f(),h:f()})});b({crop:b({left:f(),top:f(),width:f().positive(),height:f().positive()}).optional(),content:b({width:f().int().positive(),height:f().int().positive()}),fit:x([`stretch`,`contain`]),format:x([`rgb`,`gray`,`jpeg`])});var NTe=b({registryId:p().min(1),id:p().min(1),width:f().int().positive(),height:f().int().positive(),format:x([`rgb`,`gray`]),timestamp:f(),capturedAt:f().optional()}),MH=x([`onnx`,`coreml`,`openvino`,`tflite`,`pt`,`gguf`]),NH=x([`detector`,`cropper`,`classifier`,`refiner`,`audio-classifier`]),PH=b({runtime:o(`python`),backend:p(),format:MH,device:p().optional()}),FH=b({deviceKey:p().nullable(),runtime:p(),batchMode:p(),windowMs:f(),maxBatchSize:f(),concurrency:f(),numWorkers:f()}),PTe=b({engine:PH,devices:S(b({id:p(),label:p(),description:p().optional()})).readonly(),defaultDevice:p()}),IH=g(()=>b({addonId:p(),addonName:p(),slot:NH,inputClasses:S(p()).readonly(),outputClasses:S(p()).readonly(),enabled:v(),modelId:p(),children:S(IH).readonly(),group:p().optional(),settings:u(p(),l()).optional()})),FTe=b({id:p(),name:p(),formats:u(p(),fue),group:Ah.optional(),legacy:v().optional(),provider:jh.optional(),defaultConfidence:f().optional(),suppliesSteps:S(Mh).readonly().optional()}),ITe=ge(),LTe=b({id:p(),name:p(),slot:NH,inputClasses:S(p()).readonly(),outputClasses:S(p()).readonly(),childSlots:S(NH).readonly(),models:S(FTe).readonly(),defaultModelId:p(),defaultModelIdByFormat:u(p(),p()).optional(),enabledByDefault:v().optional(),defaultConfidence:f(),group:p().optional(),configSchema:S(ITe).readonly().optional()}),RTe=b({id:NH,label:p(),priority:f(),parentSlot:NH.nullable(),addons:S(LTe).readonly()}),zTe=b({availableEngines:S(PTe).readonly(),selectedEngine:PH,slots:S(RTe).readonly()}),BTe=b({runtimeId:x([`onnx`,`openvino`,`coreml`,`edgetpu`]).nullable(),device:p().nullable(),state:x([`idle`,`installing`,`verifying`,`ready`,`failed`]),progress:f().optional(),error:p().optional(),nextRetryAt:f().optional(),configIssues:S(p()).optional()}),LH=b({addonId:p(),chosen:p(),running:p(),format:p()}),RH=b({addonId:p(),kind:x([`unknown-addon`,`no-format-build`,`unknown-device`]),detail:p()}),zH=b({ok:v(),issues:S(RH).readonly(),substitutions:S(LH).readonly(),format:p()}),VTe=b({filename:p(),stepIds:S(p()).readonly().optional()}),HTe=b({base64:p(),filename:p()}),UTe=b({filename:p(),sizeKb:f()}),WTe=b({base64:p()}),GTe=b({id:p(),name:p(),description:p(),available:v(),rawLabels:S(p()).readonly().optional()}),KTe=b({activeBackend:p(),availableBackends:S(GTe).readonly(),sampleRate:f(),chunkDurationMs:f()}),qTe=b({filePath:p(),sizeMB:f(),durationMs:f()}),JTe=b({success:v(),error:p().optional(),frame:ge().optional()}),YTe=ge(),XTe=ge(),ZTe=ge(),QTe=ge(),BH={name:`pipeline-executor`,scope:`system`,mode:`singleton`,methods:{getAvailableEngines:O(_(),S(PH)),getSelectedEngine:O(_(),PH),getEngineProvisioning:O(b({nodeId:p()}),BTe),getVideoPipelineSteps:O(_(),u(p(),b({modelId:p(),settings:u(p(),l()).readonly()}))),setVideoPipelineSteps:O(b({steps:u(p(),b({modelId:p(),settings:u(p(),l()).readonly()}))}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),getInferenceDeviceHealth:O(b({nodeId:p()}),b({unhealthy:S(b({deviceKey:p(),state:x([`failed`,`backoff`]),since:f(),deaths:f(),lastError:p()})).readonly()})),rearmInferenceDevice:O(b({nodeId:p(),deviceKey:p()}),b({rearmed:v()}),{kind:`mutation`,auth:`admin`}),getSchema:O(_(),zTe),getOrchestratorConfigSchema:O(_(),YTe),validatePipeline:O(b({steps:S(Da),deviceKey:p().optional()}),zH),getCapabilities:O(_(),ZTe),getAddonModels:O(b({addonId:p()}),QTe),downloadModel:O(b({addonId:p(),modelId:p(),format:MH}),qTe,{kind:`mutation`}),deleteModel:O(b({addonId:p(),modelId:p(),format:MH}),b({success:o(!0)}),{kind:`mutation`}),runPipeline:O(b({steps:S(Da).min(1),frame:yS.optional(),frameRef:NTe.optional(),frameHandle:ta.optional(),imageBase64:p().optional(),image:y(Uint8Array).optional(),referenceImage:p().optional(),deviceId:f().optional(),sessionId:p().optional(),plane:x([`full`,`frame`]).optional(),deviceKey:p().optional(),nativeCropRef:jH.optional(),replay:o(!0).optional(),suppliedRoot:AH.optional()}),Oa,{kind:`mutation`}),runPipelineBatch:O(b({steps:S(Da).min(1),frames:S(yS).min(1).max(255),deviceId:f().optional(),sessionId:p().optional(),frameId:f().int().nonnegative().optional(),deviceKey:p().optional()}),b({results:S(Oa).readonly()}),{kind:`mutation`}),cacheFrameInPool:O(b({data:y(Uint8Array),width:f().int().positive(),height:f().int().positive(),format:x([`rgb`,`bgr`,`gray`])}),b({frameId:f(),width:f(),height:f()}),{kind:`mutation`}),inferCached:O(b({stepId:p(),frameId:f().int(),modelId:p().min(1)}),u(p(),l()),{kind:`mutation`}),uncacheFrame:O(b({frameId:f().int()}),_(),{kind:`mutation`}),getEffectiveTuning:O(b({deviceKey:p().optional()}),FH),listLoadedEngines:O(_(),S(b({engineKey:p(),engine:PH,modelsLoaded:S(p()).readonly(),inUseByCameras:S(f()).readonly(),kind:x([`runtime`,`device-pool`]),poolPid:f().nullable(),idleMs:f().nullable(),idleTtlMs:f().nullable()})).readonly()),spinEngine:O(b({engine:PH}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),killEngine:O(b({engine:PH,force:v().optional()}),b({success:v(),reason:p().optional()}),{kind:`mutation`,auth:`admin`}),listReferenceImages:O(_(),S(VTe).readonly()),getReferenceImage:O(b({filename:p()}),HTe.nullable()),getReferenceAudioFiles:O(_(),S(UTe).readonly()),getReferenceAudio:O(b({filename:p()}),WTe.nullable()),getAudioCapabilities:O(_(),KTe),runAudioTest:O(b({addonId:p(),modelId:p(),filename:p().optional(),settings:u(p(),l()).optional()}),JTe,{kind:`mutation`}),getDetectionConfigSchema:O(_(),XTe)},vocabulary:{notOperatorFacing:A.PIPELINE}},$Te=b({activeCameras:f(),throttledCameras:f(),avgInferenceTimeMs:f(),queueDepth:f()}),VH=b({detectionMode:x([`disabled`,`always-on`,`on-motion`]),configuredFps:f(),actualFps:f(),queueDepth:f(),avgInferenceTimeMs:f(),droppedFrames:f(),nativeCropMisses:f().optional(),phase:x([`idle`,`watching`,`active`])}),HH=VH.extend({deviceId:f()}),UH=x([`polygon`,`tripwire`]),WH=b({x:f(),y:f()}),GH=b({id:p(),name:p(),kind:UH.default(`polygon`),polygon:S(WH).readonly(),color:p().default(`#3b82f6`)}),KH={name:`zones`,scope:`device`,mode:`singleton`,deviceTypes:[w.Camera],methods:{listZones:O(b({deviceId:f()}),S(GH).readonly()),addZone:O(b({deviceId:f(),zone:GH}),_(),{kind:`mutation`,auth:`admin`}),removeZone:O(b({deviceId:f(),zoneId:p()}),_(),{kind:`mutation`,auth:`admin`}),updateZone:O(b({deviceId:f(),zone:GH}),_(),{kind:`mutation`,auth:`admin`})},runtimeState:b({zones:S(GH).readonly()}),durability:`restored`,history:`none`,vocabulary:{noun:N(`Zones`,`Zone`),order:3370}},qH={fpsPerStream:10,budgetMinutes:45,minBudgetMinutes:10,maxBudgetMinutes:120,staleAfterDays:30,settleSec:5,measureSec:20,drainTimeoutSec:120,maxModelsPerDevice:6},JH=x([`device`,`pipeline`]),YH=b({deviceKey:p().min(1),modelIds:S(p().min(1)).min(1).max(qH.maxModelsPerDevice)}),XH=b({nodeId:p().min(1),devices:S(YH).min(1),phases:S(JH).min(1).default([`device`,`pipeline`]),steps:S(p().min(1)).default([]),fpsPerStream:f().int().min(1).max(30).default(qH.fpsPerStream),budgetMinutes:f().int().min(qH.minBudgetMinutes).max(qH.maxBudgetMinutes).default(qH.budgetMinutes),keepDownloadedModels:v().default(!1),acceptInsufficientHeadroom:v().default(!1)}),ZH=x([`benchmark-active`,`node-offline`,`unknown-device`,`no-phase`,`insufficient-headroom`]),QH=b({kind:ZH,detail:p(),overridable:v()}),$H=b({deviceId:f(),placedOnNode:v(),pinnedToNode:v()}),eU=b({deviceId:f(),reason:o(`only-frame-source`)}),tU=b({nodeId:p(),online:v(),moving:S($H).readonly(),staying:S(eU).readonly(),estimatedDurationMs:f(),budgetMs:f(),phases:S(JH).readonly(),steps:S(p()).readonly(),devices:S(YH).readonly(),headroom:b({sessionsNow:f(),otherNodesCapacitySessions:f().nullable()}),refusals:S(QH).readonly(),canStart:v()}),nU=b({phase:x([`preparing`,`device`,`pipeline`,`cleanup`]),deviceKey:p().nullable(),modelId:p().nullable(),load:f().nullable(),cellsDone:f(),cellsTotal:f(),message:p()}),rU=x([`p95`,`drops`,`errors`,`stall`,`cpu`,`ram`,`none`]),iU=b({load:f(),pass:v(),p95Ms:f(),dropRatio:f(),fps:f(),cpuPct:f().nullable(),ramFreePct:f().nullable(),failReasons:S(p()).readonly()}),aU=b({phase:o(`device`),deviceKey:p(),modelId:p(),p50Ms:f(),p95Ms:f(),p99Ms:f(),fps:f(),kMax:f(),limitedBy:rU,warmupMs:f(),ramp:S(iU).readonly()}),oU=b({phase:o(`pipeline`),deviceKey:p(),modelId:p(),steps:S(p()).readonly(),maxSessions:f(),limitedBy:rU,stepsFired:S(p()).readonly(),warmupMs:f(),ramp:S(iU).readonly()}),sU=i(`phase`,[aU,oU]),cU=b({pipelineVersion:p().nullable(),cpuModel:p().nullable(),ramGb:f().nullable(),os:p().nullable(),pools:u(p(),b({runtime:p(),numWorkers:f(),concurrency:f(),batchMode:p()})).default({})}),lU=b({id:p(),revision:p().nullable(),frames:f(),width:f(),height:f()}),uU=b({runId:p().min(1),devices:S(YH).min(1),phases:S(JH).min(1),steps:S(p()).default([]),fpsPerStream:f().int().min(1).max(30),deadlineAtMs:f(),settleSec:f().min(0).max(60).default(qH.settleSec),measureSec:f().min(2).max(300).default(qH.measureSec),keepDownloadedModels:v().default(!1)}),dU=x([`running`,`done`,`failed`,`aborted`]),fU=b({runId:p(),nodeId:p(),state:dU,progress:nU.nullable(),cells:S(sU).readonly(),fingerprint:cU.nullable(),clip:lU.nullable(),activeCameraIds:S(f()).readonly(),deletedModels:S(p()).readonly(),error:p().nullable(),startedAtMs:f(),finishedAtMs:f().nullable()}),pU=x([`draining`,`measuring`,`restoring`,`done`,`failed`,`aborted`]),mU=x([`completed`,`operator-abort`,`deadline`,`node-lost`,`runner-lost`,`hub-restart`,`drain-timeout`,`failed`]),hU=b({runId:p(),nodeId:p(),state:pU,plan:XH,startedAtMs:f(),deadlineAtMs:f(),finishedAtMs:f().nullable(),endReason:mU.nullable(),error:p().nullable(),moved:S(f()).readonly(),staying:S(f()).readonly(),contaminated:v(),progress:nU.nullable(),resultIds:S(p()).readonly()}),gU=b({modeNodeId:p().nullable(),run:hU.nullable()}),_U=b({id:p(),runId:p(),nodeId:p(),cell:sU,fpsPerStream:f(),fingerprint:cU.nullable(),clip:lU.nullable(),contaminated:v(),stayingCameras:S(f()).readonly(),partialRun:v(),measuredAtMs:f()}),vU=b({nodeId:p().optional(),deviceKey:p().optional()}),yU=_U.extend({standing:x([`fresh`,`stale`,`superseded`]),staleWhy:x([`age`,`runtime`,`pool-tuning`]).nullable()}),eEe=b({runId:p(),nodeId:p(),startedAtMs:f(),deadlineAtMs:f(),plan:XH,moved:S(f()).readonly(),staying:S(f()).readonly()}),bU=b({nodeId:p(),reachable:v(),devices:S(b({deviceKey:p(),enabled:v(),available:v(),suggested:S(p()).readonly(),all:S(p()).readonly(),currentModelId:p().nullable()})).readonly(),steps:S(b({id:p(),name:p(),slot:p()})).readonly()}),xU=b({x:f(),y:f(),w:f(),h:f()}),SU=b({bytes:y(Uint8Array).optional(),jpeg:p().optional(),jpegBytes:y(Uint8Array).optional(),width:f().int().positive(),height:f().int().positive(),tier:x([`native`,`ram-fullframe`]).optional()}),CU=x([`keyFrame`,`thumbnail`]),wU=x([`handle-gone`,`encode-failed`]),TU=i(`parked`,[b({parked:o(!0),nodeId:p(),width:f().int().positive(),height:f().int().positive(),bytes:f().int().nonnegative(),replaced:v()}),b({parked:o(!1),nodeId:p(),reason:wU,handleAgeMs:f().nullable(),detail:p().optional()})]),EU=b({jpeg:p().optional(),jpegBytes:y(Uint8Array).optional(),width:f().int().positive(),height:f().int().positive(),timestamp:f(),parkedAt:f()}),tEe=b({bbox:xU,className:p()}),DU=b({stepId:p(),className:p(),score:f(),bbox:xU.optional(),embedding:p().optional(),embeddingMagnitude:f().optional(),embeddingModelId:p().optional(),label:p().optional(),labelTier:c([o(1),o(2)]).optional(),labelModelId:p().optional(),alignedCropJpeg:p().optional(),nativeFaceShortSidePx:f().optional(),landmarks:S(b({x:f(),y:f()})).optional()}),nEe=x([`unknown-step`,`model-not-servable`,`unreadable-frame`,`execution-failed`]),rEe=i(`kind`,[b({kind:o(`ran`),nodeId:p(),modelId:p(),details:S(DU)}),b({kind:o(`refused`),nodeId:p(),reason:nEe,detail:p()})]),OU={min:0,max:6e4,default:3e4,step:500},kU={min:0,max:6e5,default:12e4,step:5e3},AU={min:5e3,max:6e5,default:9e4,step:5e3},jU={min:1,max:30,default:4,step:1},MU={min:1,max:30,default:10,step:1},NU={min:0,max:300,default:300,step:5},PU={min:1,max:10,default:4,step:1},FU={min:0,max:30,default:12,step:1},IU=x([`onboard`,`analyzer`,`device-activity`]),LU=b({source:IU,triggeredBy:$z,sensorName:p().optional()}),RU=S(IU),zU={analyzer:`Frame-diff Analyzer (motion addon)`,onboard:`Camera sensors`,"device-activity":`Device activity (the device says it is working)`};function iEe(e){let t=IU.safeParse(e);return t.success?zU[t.data]:e}var aEe=[`analyzer`,`onboard`,`device-activity`],BU=oe(e=>Array.isArray(e)&&e.length>1?e.slice(0,1):e,S(dV).max(1)),VU=b({deviceId:f(),detected:v(),source:IU.default(`analyzer`),regions:S(mB).readonly().optional()}),HU=i(`kind`,[b({kind:o(`local-broker`)}),b({kind:o(`remote-restream`),ownerNodeId:p(),ownerReachableHost:p().optional(),hubHostnameOverride:p().optional()})]).describe(`Per-camera frame-source mode for the runner (P2c)`),UU=b({modelId:p().optional(),settings:u(p(),l()).optional()}),WU=b({deviceKey:p(),weight:f().positive().default(1),maxSessions:f().int().positive().nullable().default(null),steps:u(p(),UU).optional()}),GU=b({deviceId:f(),detectionMode:x([`disabled`,`always-on`,`on-motion`]).default(`on-motion`),audioMode:x([`disabled`,`always-on`,`on-motion`]).default(`always-on`),motionCooldownMs:f().min(OU.min).default(OU.default),maxSessionHoldMs:f().min(kU.min).max(kU.max).optional(),audioMotionWindowMs:f().min(AU.min).max(AU.max).optional(),motionFps:f().min(jU.min).max(jU.max).default(jU.default),detectionFps:f().min(MU.min).max(MU.max).default(MU.default),motionStreamId:p(),detectionStreamId:p(),audioStreamPick:Ji.optional(),motionSources:RU.default([`analyzer`]),sessionTrigger:LU.optional(),detectionSources:BU.default([`pipeline`]),pipelineEnabled:v().default(!0),steps:S(Da).readonly().optional(),audio:b({modelId:p().optional(),enabled:v()}).nullable().optional(),zones:S(GH).readonly().default([]),onboardMotionDrivesAnalyzer:v().default(!0),preRollInferenceEnabled:v().default(!0),preRollInferenceFrames:f().min(FU.min).max(FU.max).default(FU.default),occupancyRecheckEnabled:v().default(!0),occupancyRecheckSec:f().min(NU.min).max(NU.max).default(NU.default),occupancyRecheckFrames:f().min(PU.min).max(PU.max).default(PU.default),frameSource:HU.default({kind:`local-broker`}),deviceKey:p().optional(),inferenceDevices:S(WU).readonly().optional()}),oEe=[{key:`motionSources`,type:`multiselect`,label:`Motion Sources`,default:[`analyzer`],options:aEe.map(e=>e===`onboard`?{value:e,label:zU[e],description:`The camera's own motion, plus any sensor attached to it`}:{value:e,label:zU[e]})},{key:`motionFps`,type:`slider`,label:`Motion FPS (analyzer)`,min:jU.min,max:jU.max,step:jU.step,default:jU.default,showValue:!0,unit:`fps`,nullable:!0,nullLabel:`Default`,showWhen:{field:`motionSources`,includes:`analyzer`}},{key:`detectionFps`,type:`slider`,label:`Detection FPS`,min:MU.min,max:MU.max,step:MU.step,default:MU.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:OU.min,max:OU.max,step:OU.step,default:OU.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:kU.min,max:kU.max,step:kU.step,default:kU.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:AU.min,max:AU.max,step:AU.step,default:AU.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:FU.min,max:FU.max,step:FU.step,default:FU.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:NU.min,max:NU.max,step:NU.step,default:NU.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:PU.min,max:PU.max,step:PU.step,default:PU.default,showValue:!0,showWhen:{field:`occupancyRecheckEnabled`,equals:!0}}],KU=b({nodeId:p(),attachedCameras:f(),activeCameras:f(),avgInferenceFps:f(),avgInferenceTimeMs:f(),queueDepthTotal:f(),devices:S(b({deviceKey:p(),backend:p(),attachedCameras:f()})).default([]),hardware:b({hasGpu:v(),inferenceBackend:p().optional(),cpuCores:f().optional()}),motionSliceWriter:o(`orchestrator`).optional()}),qU=b({framesDecoded:f(),framesAdmitted:f(),framesDroppedPixelFree:f(),viewsMaterialized:f(),viewsSkipped:f(),workerToRunnerBytes:f(),runnerToPoolRawBytes:f(),runnerToPoolJpegBytes:f(),onDemandFullFrameRequests:f(),onDemandCropRequests:f(),nativeHits:f(),nativeMisses:f(),tileHits:f(),tileMisses:f(),fallbackHits:f(),fallbackMisses:f(),retainedWritesAvoided:f(),residentRefs:f(),residentBytes:f(),releases:f(),evictions:f(),staleMisses:f()}),JU=b({node:qU,cameras:S(qU.extend({deviceId:f()}))}),YU=b({nodeId:p(),activeCameras:f(),throttledCameras:f(),avgInferenceTimeMs:f(),queueDepth:f(),frameLazy:JU.optional()}),XU=x([`not-attached`,`battery-asleep`,`not-watching`,`already-bursting`]),ZU={name:`pipeline-runner`,scope:`system`,mode:`singleton`,methods:{attachCamera:O(GU,b({success:o(!0)}),{kind:`mutation`}),detachCamera:O(b({deviceId:f()}),b({success:o(!0)}),{kind:`mutation`}),reportMotion:O(VU,b({success:o(!0)}),{kind:`mutation`}),getLocalLoad:O(_(),KU),getLocalMetrics:O(_(),YU),getCameraMetrics:O(b({deviceId:f()}),VH.nullable()),getAllCameraMetrics:O(_(),S(HH).readonly()),getLocalCameras:O(_(),S(f()).readonly()),requestOccupancyBurst:O(b({deviceId:f(),frames:f().int().positive().optional(),reason:p()}),b({started:v(),refusedBecause:XU.optional()}),{auth:`admin`,kind:`mutation`}),getNativeCrop:O(b({handle:ta,bbox:xU,maxWidth:f().int().positive().optional(),acceptJpegBytes:v().optional(),encodeJpeg:v().optional()}),SU.nullable()),runDetailSubtree:O(b({deviceId:f(),frameHandle:ta.optional(),frameJpeg:p().optional(),cropJpeg:p().optional(),parent:tEe,steps:S(p()).optional(),supplied:b({stepId:p(),modelId:p(),boxes:S(b({bbox:xU,score:f()})).min(1)}).optional()}),b({details:S(DU)}).nullable(),{kind:`mutation`}),runStatelessStep:O(b({stepId:p(),modelId:p(),frameJpeg:p(),bbox:xU,className:p(),sourceDeviceId:f()}),rEe,{kind:`mutation`}),parkTrackFrame:O(b({deviceId:f(),trackId:p(),kind:CU,handle:ta,bbox:xU,maxWidth:f().int().positive().optional(),timestamp:f()}),TU,{kind:`mutation`}),getParkedTrackFrame:O(b({deviceId:f(),trackId:p(),kind:CU,acceptJpegBytes:v().optional()}),EU.nullable()),releaseParkedTrackFrames:O(b({deviceId:f(),trackId:p()}),b({released:f().int().nonnegative()}),{kind:`mutation`}),startNodeBench:O(uU,b({accepted:o(!0),runId:p()}),{kind:`mutation`,auth:`admin`}),getNodeBenchStatus:O(b({runId:p()}),fU.nullable(),{auth:`admin`}),abortNodeBench:O(b({runId:p()}),b({aborted:v()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:A.PIPELINE}},QU=3e4,sEe={version:1,targets:[{id:`detected`,cardinality:`event`,shape:`span`,vocabulary:{cap:`motion`,eventName:`onMotionChanged`},deviceTypes:[w.Camera],apply:`add`,applyAuthority:{kind:`camera-sensors`,timeoutField:`motionCooldownMs`},eventName:`onMotionChanged`,start:`rising-edge`,end:`falling-edge-or-timeout`,timeoutMs:QU,combine:`any`,sourceModes:[`in-addition`,`confirm`,`replace`],sources:[{kind:`binary`},{kind:`switch`}],sourceReport:{status:`assignment-status`},advancedExpression:!1}]},cEe=15e3,$U=b({detected:v(),lastDetectedAt:f().nullable(),autoClearAfterMs:f().nullable().meta(j(`duration-ms`))}),eW=b({deviceId:f(),detected:v(),timestamp:f(),source:IU,regions:S(mB).readonly().optional(),triggeredBy:$z.optional()}),tW={name:`motion`,scope:`device`,mode:`singleton`,deviceNative:!0,deviceTypes:[w.Camera,w.Sensor],methods:{isDetected:O(b({deviceId:f()}),v())},composedMethods:{isDetected:{kind:`slice`,field:`detected`}},events:{onMotionChanged:{data:eW,notOperatorFacing:"the `detected` state trigger phrases both edges, from the mirror that survives a dropped event (D49)"}},status:{schema:$U,kind:`push`},runtimeState:$U,durability:`session`,history:{fields:{detected:{kind:`boolean`,excludeDeviceTypes:[w.Camera]}}},customize:sEe,vocabulary:{noun:N(`Motion`,`Movimento`),order:5130,state:[{kind:`boolean`,field:`detected`,label:N(`Motion`,`Movimento`),whenTrue:N(`When {device} detects motion`,`Quando {device} rileva movimento`),whenFalse:N(`When motion clears on {device}`,`Quando il movimento su {device} cessa`),icon:`activity`}]}},nW=b({enabled:v(),lastChangedAt:f()}),rW=nW.extend({lastFetchedAt:f()}),iW={name:`motion-trigger`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Light,w.Siren,w.Switch],methods:{setMotionTrigger:O(b({deviceId:f().int().nonnegative(),enabled:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`motionTrigger.on`,label:N(`Motion trigger on`,`Attivazione al movimento attiva`),phrase:N(`Let motion trigger {device}`,`Fai attivare {device} dal movimento`),icon:`activity`,effect:{field:`enabled`,value:!0},args:{enabled:!0}},{id:`motionTrigger.off`,label:N(`Motion trigger off`,`Attivazione al movimento spenta`),phrase:N(`Stop motion triggering {device}`,`Non far più attivare {device} dal movimento`),icon:`activity`,effect:{field:`enabled`,value:!1},args:{enabled:!1}}]})},events:{onMotionTriggerChanged:{data:b({deviceId:f(),enabled:v(),lastChangedAt:f()}),notOperatorFacing:"the `enabled` state trigger phrases both edges of this change"}},status:{schema:nW,kind:`command-driven`},runtimeState:rW,durability:`session`,history:`none`,vocabulary:{noun:N(`Motion trigger`,`Attivazione al movimento`),order:1160,state:[{kind:`boolean`,field:`enabled`,label:N(`Motion trigger`,`Attivazione al movimento`),whenTrue:N(`When motion triggering is turned on for {device}`,`Quando si attiva l’attivazione al movimento di {device}`),whenFalse:N(`When motion triggering is turned off for {device}`,`Quando si disattiva l’attivazione al movimento di {device}`),icon:`activity`}]}},aW=b({id:f(),enabled:v(),shape:xB}),oW=b({enabled:v(),sensitivity:f().meta(j(`none`)),regions:S(aW),lastFetchedAt:f()}),sW=b({maxRegions:f(),supportedShapes:S(CB),grid:TB,sensitivity:b({min:f(),max:f(),step:f()})}),cW=b({enabled:v().optional(),sensitivity:f().optional(),regions:S(aW).optional()}),lW={name:`motion-zones`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/motion-zones-grid`,tab:`motion`,label:`Motion Zones`}},methods:{getOptions:O(b({deviceId:f()}),sW),setZone:O(b({deviceId:f(),patch:cW}),_(),{kind:`mutation`,auth:`admin`})},status:{schema:oW,kind:`poll`},runtimeState:oW,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:N(`Motion zones`,`Zone di movimento`),order:3170}},lEe=x([`external`,`embedded`]),uEe=x([`connected`,`disconnected`,`auth-failed`,`unreachable`,`tls-error`]),uW=b({id:p(),name:p(),url:p(),kind:lEe,status:uEe,latencyMs:f().nullable(),error:p().optional(),connectedClients:f().int().nonnegative().optional(),lastCheckedAt:f().optional()}),dW=b({url:p(),username:p().optional(),password:p().optional(),clientIdPrefix:p().optional()}),fW=b({name:p().min(1),url:p().regex(/^(mqtt|mqtts|ws|wss):\/\//,`URL must start with mqtt(s):// or ws(s)://`),username:p().optional(),password:p().optional(),clientIdPrefix:p().optional()}),dEe=b({id:p()}),pW=b({id:p()}),mW=b({port:f().int().min(1).max(65535).default(1883),allowAnonymous:v().default(!1),username:p().optional(),password:p().optional()}),fEe=b({id:p(),url:p()}),hW=b({brokerCount:f(),embeddedRunning:v()}),gW={name:`mqtt-broker`,scope:`system`,mode:`collection`,providerKind:`broker`,status:{schema:hW,kind:`poll`},methods:{listBrokers:O(_(),S(uW)),getBrokerConfig:O(pW,dW,{auth:`admin`}),addBroker:O(fW,dEe,{kind:`mutation`,auth:`admin`}),removeBroker:O(pW,_(),{kind:`mutation`,auth:`admin`}),startEmbeddedBroker:O(mW,fEe,{kind:`mutation`,auth:`admin`}),stopEmbeddedBroker:O(pW,_(),{kind:`mutation`,auth:`admin`}),getStatus:O(_(),hW)},vocabulary:{notOperatorFacing:A.NETWORK}},_W=x([`person`,`vehicle`,`animal`,`face`,`package`,`other`]),vW=b({class:_W,timestamp:f(),confidence:f().min(0).max(1).optional()}),yW=b({lastByClass:n(_W,vW.nullable()),supportedClasses:S(_W).readonly(),enabled:v()}),bW=x([`boxed`,`while-streaming`,`flag-only`]),xW=b({supportedClasses:S(_W).readonly(),geometry:bW}),SW=b({enabled:v().optional()}),CW=yW.extend({lastFetchedAt:f()}),wW={name:`native-object-detection`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Camera],methods:{getOptions:O(b({deviceId:f()}),xW),setSettings:O(b({deviceId:f(),settings:SW}),_(),{kind:`mutation`,auth:`admin`}),setEnabled:O(b({deviceId:f(),enabled:v()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`nativeDetection.on`,label:N(`On-camera detection on`,`Rilevamento a bordo attivo`),phrase:N(`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:N(`On-camera detection off`,`Rilevamento a bordo spento`),phrase:N(`Turn off the on-camera detection of {device}`,`Disattiva il rilevamento a bordo di {device}`),icon:`scan-eye`,args:{enabled:!1}}]})},events:{onDetected:{data:b({deviceId:f(),detection:vW}),trigger:{category:C.DetectionCameraNative,label:N(`Camera spotted something`,`La telecamera ha rilevato qualcosa`),phrase:N(`When {device} spots something with its own detector`,`Quando {device} rileva qualcosa con il proprio rilevatore`),icon:`scan-eye`}}},status:{schema:yW,kind:`push`},runtimeState:CW,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:N(`On-camera detection`,`Rilevamento a bordo`),order:3180,state:[{kind:`boolean`,field:`enabled`,label:N(`On-camera detection`,`Rilevamento a bordo`),whenTrue:N(`When the on-camera detection of {device} is turned on`,`Quando si attiva il rilevamento a bordo di {device}`),whenFalse:N(`When the on-camera detection of {device} is turned off`,`Quando si disattiva il rilevamento a bordo di {device}`),icon:`scan-eye`}]}},TW=b({pan:f().min(-1).max(1).optional(),tilt:f().min(-1).max(1).optional(),speed:f().min(0).max(1).optional()}),EW=x([`goHome`,`locate`,`spotClean`,`findPet`,`personFollow`,`stop`,`startClean`,`pauseClean`,`dockWash`,`autoEmpty`,`flashOn`,`flashOff`]),DW=x([`action`,`sound`]),OW=b({id:p(),kind:DW,label:p(),icon:p(),soundId:f().int().optional(),enabled:v()}),pEe=[{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}],kW=b({x:f(),y:f()}),AW=b({move:v(),stop:v(),goToPoint:v(),runAction:v(),playSound:v(),light:v(),lightMode:v()}),jW=x([`auto`,`manual`]),mEe=40,hEe=100,MW=x([`idle`,`cleaning`,`spot`,`following`,`goto`,`returning`,`paused`,`unknown`]),NW=b({mode:MW,following:v(),flash:v(),lightMode:jW,lightLevel:f().min(40).max(100).meta(j(`none`)),lastChangedAt:f()}),PW=NW.extend({lastFetchedAt:f()}),FW={name:`navigation`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/navigation-panel`,tab:`navigation`,topTab:!0,label:`Navigation`,order:0}},methods:{move:O(TW.extend({deviceId:f()}),_(),{kind:`mutation`,notOperatorFacing:`joystick control from the live view — continuous, not a discrete step`}),stop:O(b({deviceId:f()}),_(),{kind:`mutation`,actions:[{id:`navigation.stop`,label:N(`Stop`,`Ferma`),phrase:N(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),goToPoint:O(kW.extend({deviceId:f()}),_(),{kind:`mutation`,notOperatorFacing:`tap-to-go on the live map — the point only means something on that picture`}),listActions:O(b({deviceId:f()}),S(OW)),runAction:O(b({deviceId:f(),actionId:EW}),_(),{kind:`mutation`,actions:[{id:`navigation.runAction`,label:N(`Run a routine`,`Esegui una routine`),phrase:N(`Have {device} {actionId}`,`Fai eseguire a {device}: {actionId}`),icon:`bot`,openArgs:[{key:`actionId`,label:N(`Routine`,`Routine`),offer:{kind:`enum`,values:[{value:`goHome`,label:N(`go home`,`torna alla base`)},{value:`locate`,label:N(`beep so you can find it`,`suona per farsi trovare`)},{value:`spotClean`,label:N(`clean this spot`,`pulisci questo punto`)},{value:`findPet`,label:N(`find the pet`,`cerca l’animale`)},{value:`personFollow`,label:N(`follow a person`,`segui una persona`)},{value:`stop`,label:N(`stop`,`fermati`)},{value:`startClean`,label:N(`start cleaning`,`inizia a pulire`)},{value:`pauseClean`,label:N(`pause cleaning`,`metti in pausa la pulizia`)},{value:`dockWash`,label:N(`wash the mop at the dock`,`lava il mocio alla base`)},{value:`autoEmpty`,label:N(`empty the bin at the dock`,`svuota il contenitore alla base`)},{value:`flashOn`,label:N(`turn the flash on`,`accendi il flash`)},{value:`flashOff`,label:N(`turn the flash off`,`spegni il flash`)}]}}]}]}),playSound:O(b({deviceId:f(),soundId:f().int()}),_(),{kind:`mutation`,actions:[{id:`navigation.playSound`,label:N(`Play sound`,`Riproduci un suono`),phrase:N(`Play {soundId} on {device}`,`Riproduci {soundId} su {device}`),icon:`volume-2`,openArgs:[{key:`soundId`,label:N(`Sound`,`Suono`),offer:{kind:`dynamic`,from:`method`,method:`listActions`,valueKey:`soundId`,labelKey:`label`,where:{key:`kind`,equals:`sound`},valueKind:`number`}}]}]}),setLightOn:O(b({deviceId:f(),on:v()}),_(),{kind:`mutation`,actions:[{id:`navigation.lightOn`,label:N(`Light on`,`Luce accesa`),phrase:N(`Turn on the light of {device}`,`Accendi la luce di {device}`),icon:`lightbulb`,args:{on:!0}},{id:`navigation.lightOff`,label:N(`Light off`,`Luce spenta`),phrase:N(`Turn off the light of {device}`,`Spegni la luce di {device}`),icon:`lightbulb-off`,args:{on:!1}}]}),setLightMode:O(b({deviceId:f(),mode:jW,level:f().min(40).max(100).optional()}),_(),{kind:`mutation`,actions:[{id:`navigation.lightAuto`,label:N(`Light automatic`,`Luce automatica`),phrase:N(`Set the light of {device} to automatic`,`Metti la luce di {device} in automatico`),icon:`lightbulb`,args:{mode:`auto`}}]}),setLightLevel:O(b({deviceId:f(),level:f().min(40).max(100)}),_(),{kind:`mutation`,actions:[{id:`navigation.lightLevel`,label:N(`Set light level`,`Imposta la luce`),phrase:N(`Set the light of {device} to {level}`,`Imposta la luce di {device} al {level}`),icon:`sun-medium`,openArgs:[{key:`level`,label:N(`Level`,`Livello`),offer:{kind:`number`,min:40,max:100,step:1,unit:`%`}}]}]}),getFeatures:O(b({deviceId:f()}),AW)},events:{onStatusChanged:{data:b({deviceId:f(),status:NW}),notOperatorFacing:"the `mode` state trigger reads the same change"}},status:{schema:NW,kind:`push`},runtimeState:PW,durability:`session`,history:`none`,vocabulary:{noun:N(`Robot movement`,`Movimento del robot`),order:2080,state:[{kind:`enum`,field:`mode`,label:N(`Activity`,`Attività`),values:[{value:`idle`,label:N(`Idle`,`Inattivo`)},{value:`cleaning`,label:N(`Cleaning`,`In pulizia`)},{value:`spot`,label:N(`Spot cleaning`,`Pulizia localizzata`)},{value:`following`,label:N(`Following`,`In inseguimento`)},{value:`goto`,label:N(`Moving to a point`,`In movimento verso un punto`)},{value:`returning`,label:N(`Returning`,`In rientro`)},{value:`paused`,label:N(`Paused`,`In pausa`)},{value:`unknown`,label:N(`Unknown`,`Sconosciuto`)}],icon:`bot`}]}},IW=b({url:p(),hostname:p(),port:f(),protocol:x([`http`,`https`]),stable:v().optional()}),gEe=b({url:p(),stable:v().optional(),updated:v().optional()}),LW=b({connected:v(),endpoint:IW.nullable(),error:p().optional()}),_Ee=IW.extend({id:p(),label:p(),mode:p().optional(),sourcePort:f().optional()}),RW={name:`network-access`,scope:`system`,mode:`collection`,providerKind:`ingress`,methods:{start:O(_(),IW,{kind:`mutation`}),stop:O(_(),_(),{kind:`mutation`}),getEndpoint:O(_(),IW.nullable()),getStatus:O(_(),LW),listEndpoints:O(_(),S(_Ee).readonly())},vocabulary:{notOperatorFacing:A.NETWORK}},zW=[`wifi`,`ethernet`,`cellular`,`unknown`],BW=b({type:x(zW),signal:f().min(0).max(100).nullable().meta(j(`percentage`)),rssi:f().optional().meta(j(`signal-level`)),ssid:p().optional(),lastUpdated:f().meta(j(`none`))}),VW={type:`unknown`,signal:null,lastUpdated:0};function vEe(e,t){return e===void 0||!Number.isFinite(e)||t<=0||e<0||e>t?null:Math.round(e/t*100)}function yEe(e){return e===void 0||!Number.isFinite(e)||e>0?null:Math.round((Math.min(-50,Math.max(-100,e))+100)*2)}var HW={name:`network-link`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Camera,w.Sensor,w.Button,w.Switch,w.Light,w.Lock,w.Siren],methods:{},events:{onStatusChanged:{data:b({deviceId:f(),status:BW}),notOperatorFacing:`the signal / link-type state triggers each read one field of this change`}},status:{schema:BW,kind:`push`,empty:VW},runtimeState:BW,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:N(`Network link`,`Collegamento di rete`),order:5250,state:[{kind:`numeric`,field:`signal`,quantity:N(`the signal strength`,`l’intensità del segnale`),label:N(`Signal`,`Segnale`),unit:`%`,icon:`wifi`},{kind:`enum`,field:`type`,label:N(`Link type`,`Tipo di collegamento`),values:[{value:`wifi`,label:N(`Wi-Fi`,`Wi-Fi`)},{value:`ethernet`,label:N(`Ethernet`,`Ethernet`)},{value:`cellular`,label:N(`Cellular`,`Rete mobile`)},{value:`unknown`,label:N(`Unknown`,`Sconosciuto`)}],icon:`network`}]}},UW=b({nominalBitrateKbps:f(),observedBitrateKbps:f(),peakBitrateKbps:f(),packetLossPercent:f(),lastUpdated:f()}),WW=b({rttMs:f(),jitterMs:f(),estimatedBandwidthKbps:f(),packetLossPercent:f().min(0).max(100),downlinkMbps:f().optional(),downlinkAgeMs:f().optional(),lastUpdated:f()}),GW=b({deviceId:f(),streams:u(p(),UW),client:WW.optional()}),KW={name:`network-quality`,scope:`system`,mode:`singleton`,methods:{getDeviceStats:O(b({deviceId:f()}),GW.nullable()),getAllStats:O(_(),S(GW).readonly()),reportClientStats:O(b({deviceId:f(),rttMs:f().min(0).max(6e4),jitterMs:f().min(0).max(1e4),estimatedBandwidthKbps:f().min(0).max(1e6),packetLossPercent:f().min(0).max(100),downlinkMbps:f().min(0).max(1e5).optional(),downlinkAgeMs:f().min(0).max(864e5).optional()}),_(),{role:`viewer`,kind:`mutation`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:A.NETWORK}},qW=b({cn:p(),serial:p(),fingerprintSha256:p(),notBefore:f(),notAfter:f()}),JW=b({fingerprintSha256:p(),issuer:p(),sans:S(p()),notBefore:f(),notAfter:f()}),YW=i(`state`,[b({state:o(`served`),leaf:JW}),b({state:o(`not-issued`),reason:p()})]),XW={name:`node-certificates`,scope:`system`,mode:`singleton`,internal:!0,methods:{getCertificates:O(b({}),b({nodeId:p(),mesh:qW.nullable(),https:YW}),{auth:`admin`}),prepareMeshRenewal:O(b({}),b({csrPem:p()}),{kind:`mutation`,auth:`admin`}),installMeshLeaf:O(b({certPem:p().min(1),caCertPem:p().min(1),confirmWithinMs:f().int().min(1e4).max(6e5)}),b({fingerprintSha256:p(),serial:p()}),{kind:`mutation`,auth:`admin`}),confirmMeshLeaf:O(b({fingerprintSha256:p()}),b({confirmed:v()}),{kind:`mutation`,auth:`admin`}),rollbackMeshLeaf:O(b({}),b({rolledBack:v()}),{kind:`mutation`,auth:`admin`}),prepareHttpsCertificate:O(b({}),b({csrPem:p(),hostnames:S(p()),addresses:S(p()),pinnedCaFingerprintSha256:p().nullable()}),{kind:`mutation`,auth:`admin`}),forgetHub:O(b({}),b({ok:o(!0)}),{kind:`mutation`,auth:`admin`}),installHttpsCertificate:O(b({certPem:p().min(1),caCertPem:p().min(1),caRotation:v().optional()}),JW,{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:A.IDENTITY}},ZW=b({nodeId:p().min(1),removedAt:f()}),QW=b({counts:u(p(),f().int().nonnegative())}),$W={name:`node-removal-hook`,scope:`system`,mode:`collection`,internal:!0,methods:{onNodeRemoved:O(ZW,QW,{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:A.INTERNAL}},eG=b({addonId:p(),capabilities:S(p()).readonly(),status:p()}),tG=b({pid:f(),name:p(),state:p(),cpuPercent:f(),memoryRss:f(),uptimeSeconds:f(),services:S(eG).readonly(),groupId:p().optional()}),bEe=b({id:p(),status:p(),cpuPercent:f(),memoryRss:f()}),xEe=b({category:p(),total:f(),healthy:f(),addons:S(bEe).readonly()}),SEe=b({name:p(),version:p()}),nG=b({id:p(),name:p(),hostname:p(),platform:p(),arch:p(),cpuModel:p().nullable(),cpuCores:f(),memoryMB:f(),engines:S(p()).readonly(),isHub:v(),isOnline:v(),cpuPercent:f(),memoryPercent:f().nullable(),uptime:f(),lastSeen:p(),localIps:S(p()).readonly(),addons:S(b({id:p(),capabilities:S(p()).readonly(),status:p()})).readonly(),processes:S(tG).readonly(),categories:S(xEe).readonly(),rootPackage:SEe.nullable(),meshTransport:x([`tls`,`clear`]).optional(),capabilitiesRegistered:v().optional()}),CEe=b({callerAddonId:p(),providerAddonId:p(),capName:p(),callsPerMin:f(),lastCallAtMs:f()}),rG=b({nodeId:p(),name:p(),version:p(),status:p(),synced:v()}),iG=b({hubVersion:p(),nodes:S(rG)}),aG=b({nodeId:p(),addonId:p()}),wEe=b({id:p(),status:p(),version:p().optional(),packageName:p().optional()}),oG=b({success:v()}),TEe=b({success:v(),reason:p().optional()}),EEe=b({restarted:S(p()).readonly(),failed:S(p()).readonly()}),DEe=b({nodeId:p(),name:p()}),sG=b({id:p(),name:p(),isHub:v(),isOnline:v()}),cG=b({nodes:S(sG).readonly(),complete:v()}),lG={name:`nodes`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,methods:{topology:O(_(),S(nG).readonly(),{auth:`admin`}),directory:O(_(),cG,{auth:`admin`}),deployAddon:O(aG,oG,{kind:`mutation`,auth:`admin`}),undeployAddon:O(aG,oG,{kind:`mutation`,auth:`admin`}),restartAddon:O(aG,oG,{kind:`mutation`,auth:`admin`}),restartProcess:O(b({nodeId:p(),processName:p()}),TEe,{kind:`mutation`,auth:`admin`}),restartNode:O(b({nodeId:p()}),EEe,{kind:`mutation`,auth:`admin`}),shutdownNode:O(b({nodeId:p()}),oG,{kind:`mutation`,auth:`admin`}),renameNode:O(b({nodeId:p(),name:p().min(1).max(64)}),DEe,{kind:`mutation`,auth:`admin`}),clusterAddonStatus:O(_(),u(p(),iG),{auth:`admin`}),getCapUsageGraph:O(b({windowSeconds:f().int().positive().max(300).default(60)}),S(CEe).readonly(),{auth:`admin`}),getNodeAddons:O(b({nodeId:p()}),S(wEe).readonly(),{auth:`admin`}),setProcessLogLevel:O(b({nodeId:p(),level:p()}),oG,{kind:`mutation`,auth:`admin`}),executeQuery:O(b({nodeId:p(),addonId:p(),queryName:p(),params:u(p(),l()).optional()}),l(),{kind:`mutation`,auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:A.CLUSTER}},uG=[{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`}],dG={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},fG={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},pG=new Map;for(let[e,t]of Object.entries(dG.mapping))pG.set(e.toLowerCase(),t);for(let[e,t]of Object.entries(fG.mapping))pG.set(e.toLowerCase(),t);function OEe(e){return pG.get(e.toLowerCase())??null}function kEe(){return uG.map(e=>e.id)}var mG=BM();function hG(e){return GM(mG.swatches,mG.fallbacks,e)}function AEe(e){let t=e[0];if(t===void 0)throw Error(`display palette has no fallback colour`);return t}var jEe=AEe(mG.fallbacks);function MEe(e){return e.split(/[-_ ]/).filter(e=>e.length>0).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}var gG=new Map;function _G(e,t,n,r){gG.set(e,{kind:e,parentKind:null,level:`macro`,category:t,color:hG(e),iconId:n,labelKey:`eventKind.${e}`,label:r})}function vG(e,t,n,r,i){gG.set(e,{kind:e,parentKind:t,level:`sub`,category:n,color:hG(e),iconId:r,labelKey:`eventKind.${e}`,label:i})}_G(`motion`,`motion`,`motion`,`Motion`),_G(`audio`,`audio`,`audio`,`Audio`),_G(`person`,`detection`,`person`,`Person`),_G(`vehicle`,`detection`,`vehicle`,`Vehicle`),_G(`animal`,`detection`,`animal`,`Animal`),_G(`package`,`package`,`package`,`Package`),_G(`sensor`,`sensor`,`sensor`,`Sensor`),_G(`control`,`control`,`control`,`Control`);for(let[e,t]of Object.entries(Ng.mapping))t!==`vehicle`&&t!==`animal`||gG.has(e)||vG(e,t,`detection`,e,MEe(e));vG(`package-delivered`,`package`,`package`,`package`,`Package delivered`),vG(`package-picked-up`,`package`,`package`,`package`,`Package picked up`),vG(`contact`,`sensor`,`sensor`,`door`,`Contact`),vG(`motion-sensor`,`sensor`,`sensor`,`pir`,`Motion sensor`),vG(`smoke`,`sensor`,`sensor`,`smoke`,`Smoke`),vG(`flood`,`sensor`,`sensor`,`water`,`Water leak`),vG(`gas`,`sensor`,`sensor`,`gas`,`Gas`),vG(`carbon-monoxide`,`sensor`,`sensor`,`smoke`,`Carbon monoxide`),vG(`vibration`,`sensor`,`sensor`,`vibration`,`Vibration`),vG(`tamper`,`sensor`,`sensor`,`tamper`,`Tamper`),vG(`presence`,`sensor`,`sensor`,`presence`,`Presence`),vG(`enum-sensor`,`sensor`,`sensor`,`generic`,`Sensor state`),vG(`device-event`,`sensor`,`sensor`,`button`,`Device event`),vG(`lock`,`control`,`control`,`lock`,`Lock`),vG(`cover`,`control`,`control`,`door`,`Cover`),vG(`switch`,`control`,`control`,`switch`,`Switch`),vG(`siren`,`control`,`control`,`siren`,`Siren`),vG(`button`,`control`,`control`,`button`,`Button`),vG(`doorbell`,`control`,`control`,`doorbell`,`Doorbell`),vG(`appliance-cycle`,`control`,`control`,`switch`,`Appliance cycle`);for(let e of uG){let t=`audio-${e.id}`;gG.has(t)||vG(t,`audio`,`audio`,t,e.name)}var yG=Object.freeze(Object.fromEntries(gG));function bG(e){return yG[e]}function NEe(e){return hG(e)}function PEe(e){let t=[];for(let n of Object.values(yG))n.parentKind===e&&t.push(n);return t}var xG=b({kind:p(),label:p(),parentKind:p().nullable()}),SG=b({videoClasses:S(xG),audioKinds:S(xG),labels:S(xG)});function CG(e,t,n){return{kind:e,label:t,parentKind:n}}function wG(){let e=Object.values(yG);return{videoClasses:e.filter(e=>e.category===`detection`).map(e=>CG(e.kind,e.label,e.parentKind)),audioKinds:e.filter(e=>e.category===`audio`&&e.level===`sub`).map(e=>CG(e.kind,e.label,e.parentKind)),labels:e.filter(e=>e.category===`sensor`||e.category===`control`).map(e=>CG(e.kind,e.label,e.parentKind))}}var FEe=Object.freeze(wG()),TG=x([`immediate`,`track-end`,`device-event`,`package-event`,`system-event`]),EG=x(`device-online.device-offline.device-disabled.device-enabled.device-battery-low.device-battery-normal.device-consumable-low.device-consumable-normal.stream-online.stream-offline.node-online.node-offline.node-restarting.node-updating.node-inference-unavailable.detection-blind.motion-noisy.motion-calm.package-llm-silent.package-llm-answered.recording-stalled.recording-healthy.recording-degraded.device-attention-required.device-attention-resolved.device-command.storage-location-low.storage-location-critical.storage-location-ok.storage-drain-progress.storage-drain-complete.addon-crash-loop.addon-update-available.server-update-available.wrapper-update-available.alarm-triggered.alarm-armed.alarm-disarmed.alarm-arming.alarm-arm-refused.alarm-pending.alarm-rearmed.alarm-sensor-bypass.alarm-check-failed.addon-updated.server-updated.export-completed.backup-completed.alert-critical.alert-error.alert-critical-resolved.rule-broken.rule-repaired.camera-online.camera-offline.camera-disabled.camera-enabled`.split(`.`)),DG=[`camera-online`,`camera-offline`,`camera-disabled`,`camera-enabled`],IEe=new Set(DG),LEe=EG.options.filter(e=>!IEe.has(e)),OG=[`alarm-arm-refused`,`alarm-check-failed`,`alarm-arming`,`alarm-armed`,`alarm-pending`,`alarm-triggered`,`alarm-rearmed`,`alarm-sensor-bypass`,`alarm-disarmed`],REe=[`device-battery-low`,`device-battery-normal`,`device-consumable-low`,`device-consumable-normal`],kG=[`device-consumable-low`,`device-consumable-normal`],zEe=15,BEe=95,AG=[`confirmed`,`already`,`unconfirmed`,`failed`],jG=[`user`,`addon`,`action`,`scheduler`,`composition`,`node`],MG=b({kinds:S(EG).min(1),deviceIds:S(f().int()).min(1).optional(),deviceTypes:S(p().min(1)).min(1).optional(),excludeDeviceIds:S(f().int()).min(1).optional(),nodeIds:S(p().min(1)).min(1).optional(),packageNames:S(p().min(1)).min(1).optional(),commandActions:S(p().min(1)).min(1).optional(),commandOutcomes:S(x(AG)).min(1).optional(),commandActorKinds:S(x(jG)).min(1).optional(),consumableLowPercent:f().int().min(1).max(95).optional()});function VEe(e){return e.consumableLowPercent??15}var HEe=1,NG=1440,UEe=[10,30,60],PG=b({days:S(f().int().min(0).max(6)).min(1),startMinute:f().int().min(0).max(1439),endMinute:f().int().min(0).max(1439)}),FG=b({windows:S(PG).min(1),timezone:p().optional(),invert:v().optional()}),IG=x([`instant`,`summary`]),WEe=x([`activation`,`deactivation`,`schedule`]),LG=x([`rule`,`section`]),RG=i(`mode`,[b({mode:o(`instant`)}),b({mode:o(`summary`),schedule:FG,split:LG.optional()}),b({mode:o(`modes`),onActivation:v(),onDeactivation:v(),onSchedule:b({schedule:FG,grouping:LG}).optional()})]),zG=b({values:S(p().min(1)),maxDistance:f().int().min(0).max(3).default(1)}),BG=b({zoneId:p().optional(),className:p().optional(),op:x([`became-occupied`,`became-free`,`>=`,`<=`]).default(`became-occupied`),count:f().int().min(0).default(1),sustainSeconds:f().int().min(0).max(3600).default(15)}),GEe=-96,VG=b({labels:S(p().min(1)).min(1).optional(),dbThreshold:f().min(-96).max(0).optional(),hitPercent:f().int().min(1).max(100).default(60),samplingSeconds:f().int().min(1).max(300).default(10),confirmHits:f().int().min(1).max(20).optional(),confirmWindowSec:f().int().min(1).max(60).optional()}),HG=x([`enter`,`exit`,`any`]),UG=x([`raised`,`cleared`]),WG=b({ids:S(p().min(1)).min(1),match:x([`any`,`all`]).optional()}),GG=p().min(1),KG=S(GG).max(4),qG=b({id:p().min(1).max(64),label:p().min(1).max(40),actionId:GG,icon:Ql.optional(),destructive:v().optional()}),JG=b({onActivation:KG.optional(),onDeactivation:KG.optional(),onTrigger:KG.optional(),onTriggerOff:KG.optional(),buttons:S(qG).max(8).optional()}),YG=b({deviceId:f().int(),states:S(p().min(1)).min(1)}),XG=b({sceneId:p().min(1),deviceId:f().int().optional(),requiredState:x([`matched`,`diverged`]),latched:v().optional()}),ZG=b({deviceState:YG.optional(),scene:XG.optional(),devices:S(f()).optional(),devicesExclude:S(f()).min(1).optional(),classes:S(p().min(1)).optional(),classesExclude:S(p().min(1)).optional(),minConfidence:f().min(0).max(1).optional(),zones:WG.optional(),zonesExclude:S(p().min(1)).optional(),crossing:HG.optional(),labelEquals:S(p().min(1)).optional(),identities:S(p().min(1)).optional(),plates:zG.optional(),identitiesExclude:S(p().min(1)).optional(),minImportance:f().min(0).max(1).optional(),minDwellSeconds:f().min(0).optional(),source:x([`pipeline`,`onboard`,`sensor`,`audio`,`any`]).optional(),minLabelConfidence:f().min(0).max(1).optional(),eventTypeTokens:S(p().min(1)).optional(),sensorKinds:S(p().min(1)).optional(),sensorTransition:UG.optional(),packagePhase:x([`delivered`,`picked-up`,`both`]).optional(),systemEvent:MG.optional(),customZones:S(bB).optional(),occupancy:BG.optional(),audio:VG.optional()}),QG=b({targetId:p().min(1),params:u(p(),l()).optional()}),KEe=500,$G=x([`none`,`image`,`clip`,`gif`]),eK=b({template:b({title:p().max(500).optional(),body:p().max(2e3).optional()}).optional(),schedule:FG.optional(),priority:f().int().min(1).max(5).optional(),attachment:$G.optional(),actions:v().optional()}),tK=u(p(),eK),nK=x([`scene-boxes`,`crop`,`clean`,`none`]),rK=x([`cropped`,`full`,`boxed`]),iK=x([`mosaic`,`each`]),qEe=4,JEe=6,aK=b({image:nK.optional(),showTriggerZone:v().optional(),showSubjectPath:v().optional(),attach:x([`best`,`best-matching`,`keyFrame`,`none`]).optional(),frame:rK.optional(),zoneCrop:v().optional(),gif:v().optional(),clip:v().optional(),clipPreRollSec:f().int().min(0).max(30).optional(),clipPostRollSec:f().int().min(0).max(30).optional(),clipSpeed:f().min(1).max(8).optional(),profile:M.optional(),linkedCameras:iK.optional(),wakeSleepingCamera:v().optional()}),oK=x([`shared`,`per-class`]),sK=b({cooldownSec:f().int().min(0).max(86400).default(60),scope:x([`rule`,`rule-device`]).default(`rule-device`),granularity:oK.optional()}),cK=1e3,lK=2e4,uK=8e3,YEe=448,dK=b({op:x([`>=`,`>`,`<=`,`<`,`==`]),count:f().int().min(0).max(1e3)}),fK=b({enabled:v().default(!1),profileId:p().optional(),prompt:p().max(1e3).optional(),expect:dK.optional(),timeoutMs:f().int().min(cK).max(lK).default(uK),onTimeout:x([`fire`,`suppress`]).default(`fire`),maxImagePx:f().int().min(64).max(2048).default(448)}),XEe=5,ZEe=20,QEe=60,$Ee=5,eDe=0,tDe=300,pK=b({name:p().min(1).max(200),enabled:v().default(!0),delivery:TG,conditions:ZG.default({}),schedule:FG.optional(),systemEventDelivery:RG.optional(),targets:S(QG),targetUsers:S(p()).optional(),targetOverrides:tK.optional(),media:aK.default({}),throttle:sK.default({cooldownSec:60,scope:`rule-device`}),template:b({title:p().max(500).optional(),body:p().max(2e3).optional()}).optional(),priority:f().int().min(1).max(5).default(3),ownerUserId:p().optional(),snoozeAllowGlobal:v().optional(),snoozeOptions:S(f().int().min(1).max(NG)).max(4).optional(),actions:JG.optional(),confirm:fK.optional(),groupingSec:f().int().min(5).max(60).optional(),groupWithinSec:f().int().min(0).max(300).optional(),askVerdict:v().optional()}),mK=pK.partial().extend({disabledTargetIds:S(p()).optional(),enabled:v().optional(),conditions:ZG.optional(),media:aK.optional(),throttle:sK.optional(),priority:f().int().min(1).max(5).optional()}),hK=[`waitForEnhancement`,`groupIdleSec`];function nDe(e){return hK.some(t=>t===e)}var gK=[`template`,`schedule`,`targetUsers`,`snoozeOptions`,`snoozeAllowGlobal`,`actions`,`confirm`,`groupingSec`,`waitForEnhancement`,`groupIdleSec`],_K=x(gK),vK=b({ruleId:p(),patch:mK,clear:S(_K).optional()}),yK=pK.extend({id:p(),createdBy:p(),createdAt:f(),updatedAt:f(),disabledTargetIds:S(p()).default([])}),bK=[`device-state`,`streams`,`battery`,`consumables`,`detection-blind`,`nodes`,`addons`,`addon-updates`,`updates`],xK=x(bK),SK=b({id:xK,status:x([`read`,`unavailable`]),items:f().int().nonnegative(),reason:p().optional()}),CK=b({section:xK.optional(),title:p(),text:p(),count:f().int().nonnegative()}),wK=b({empty:v(),count:f().int().nonnegative(),text:p(),sections:S(SK),dropped:u(p(),f().int().nonnegative()),excludedGroups:S(p()),split:LG.optional(),rows:S(CK).optional()}),TK=b({recordId:p(),recordKind:x([`object-event`,`track`,`device-event`,`package-event`,`system-event`]),deviceId:f(),timestamp:f(),wouldFire:v(),failedCondition:p().optional(),className:p().optional(),label:p().optional()}),EK=x([`detection`,`sensor`,`occupancy`,`sound`,`device-events`,`system`,`alarm`,`mixed`]),DK=x([`detection`,`sensor`,`occupancy`,`sound`,`system`]),OK=b({id:x([`appliance-cycle`]),kind:EK,title:p(),body:p()}),kK=x([`rule`,`timelapse`,`summary`]),AK=x([`title`,`body`,`previewText`,`captionText`]),jK=x([`subject`,`place`,`time`,`rule`,`occupancy`,`sound`,`sensor`,`system`,`digest`,`ai`]),MK=b({name:p().regex(/^\w+$/),label:p(),description:p().optional(),example:p(),group:jK,families:S(kK).min(1),fields:S(AK).optional(),kinds:S(DK).optional(),deliveries:S(TG).optional(),systemEventKinds:S(EG).optional(),systemEventDeliveries:S(IG).optional(),dynamic:b({prefix:o(`count_`),from:o(`classes`)}).optional()}),NK=b({family:kK,field:AK,kind:EK.optional(),delivery:TG.optional(),systemEventKinds:S(EG).optional(),systemEventDelivery:IG.optional()}),PK=b({context:NK,template:b({title:p().max(500).optional(),body:p().max(2e3).optional()})}),FK=b({title:p().nullable(),body:p().nullable(),unknown:S(p())}),IK=b({id:p(),group:x([`scope`,`class`,`zones`,`quality`,`label`,`schedule`,`device`,`package`,`occupancy`,`audio`,`system`]),label:p(),valueType:x([`deviceIdList`,`deviceIdExcludeList`,`stringList`,`number01`,`number`,`sourceSelect`,`zoneSelection`,`zoneIdList`,`schedule`,`plateMatcher`,`packagePhase`,`crossingSelect`,`sensorTransition`,`polygonDraw`,`occupancy`,`audio`,`deviceState`,`scene`,`systemEvent`]),operator:x([`in`,`notIn`,`anyOf`,`allOf`,`gte`,`fuzzyIn`,`withinSchedule`]),appliesTo:S(TG),phase:p(),description:p().optional(),options:S(b({value:p(),label:p(),hint:p().optional()})).readonly().optional()}),rDe=[{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.`}],LK=x([`pending`,`sent`,`dead`]),RK=x([`object-event`,`track-end`,`device-event`,`package-event`,`system-event`]),zK=b({className:p(),label:p().optional(),confidence:f().optional(),zones:S(p()),timestamp:f(),systemEvent:b({kind:EG,subject:p(),title:p(),body:p(),data:u(p(),l())}).optional()}),BK=b({id:p(),ruleId:p(),ruleName:p(),delivery:TG,targetId:p(),deviceId:f(),recordKind:RK,recordId:p(),trackId:p().optional(),status:LK,attempts:f().int(),createdAt:f(),updatedAt:f(),error:p().optional(),subject:zK,title:p().optional(),body:p().optional(),artifactIds:S(p().min(1)).optional(),groupedInto:p().min(1).optional()}),iDe=100,aDe=500,VK=b({ruleId:p().optional(),deviceId:f().optional(),status:LK.optional(),since:f().optional(),until:f().optional(),limit:f().int().min(1).max(500).default(100)}),HK=b({ruleId:p(),lastAt:f(),status:LK,deviceId:f()}),UK=b({runs:S(HK),horizonMs:f().nonnegative().nullable()}),WK=x([`rule`,`device`,`all`]),GK=b({scope:WK,ruleId:p().optional(),deviceId:f().int().optional(),classes:S(p().min(1)).min(1).optional(),durationMinutes:f().int().min(1).max(NG),global:v().optional(),summary:v().optional()}),KK=b({id:p(),userId:p(),scope:WK,ruleId:p().optional(),deviceId:f().int().optional(),classes:S(p().min(1)).min(1).optional(),startedAt:f(),expiresAt:f(),global:v(),summary:v(),digestSentAt:f().optional()}),oDe=b({snoozeId:p(),targetId:p(),ruleId:p(),ruleName:p(),deviceId:f().int(),count:f().int(),firstAt:f(),lastAt:f()}),sDe=600,qK=3600,cDe=200,JK=f().int().min(0).max(600),YK=f().int().min(0).max(qK),XK=e=>new Set(e.map(e=>e.mode)).size===e.length,ZK=x([`rearmAfter`,`disableAfter`,`doNothing`]),QK=b({mode:cS,exitDelaySec:JK.optional(),entryDelaySec:JK.optional(),triggeredDurationSec:YK.optional(),postTriggeredAction:ZK.optional(),schedule:FG.optional(),notifyDuringEntryDelay:v().optional(),notifySensorRewatched:v().optional(),notifySensorIgnored:v().optional()}),lDe=S(QK).max(8).refine(XK,{message:`modeDelays: at most one entry per arm mode`}),$K=b({mode:cS,exitDelaySec:JK.nullable().optional(),entryDelaySec:JK.nullable().optional(),triggeredDurationSec:YK.nullable().optional(),postTriggeredAction:ZK.nullable().optional(),schedule:FG.nullable().optional(),notifyDuringEntryDelay:v().nullable().optional(),notifySensorRewatched:v().nullable().optional(),notifySensorIgnored:v().nullable().optional()}),uDe=S($K).max(8).refine(XK,{message:`modeDelays: at most one edit per arm mode`}),eq=b({mode:cS,deviceId:f().int().positive(),nonBlocking:v()}),tq=b({mode:cS,deviceId:f().int().positive(),blocking:v()}),nq=b({mode:cS,deviceId:f().int().positive(),secureOnArm:v()}),rq=b({mode:cS,deviceIds:S(f().int()).max(200)}),iq=rq,aq=rq,oq=rq,sq=S(iq).max(8).refine(XK,{message:`nonBlocking: at most one list per arm mode`}),cq=S(aq).max(8).refine(XK,{message:`blocking: at most one list per arm mode`}),lq=S(oq).max(8).refine(XK,{message:`secureOnArmOff: at most one list per arm mode`}),uq=b({exitDelaySec:JK,entryDelaySec:JK,triggeredDurationSec:YK,postTriggeredAction:ZK.optional(),announceArm:v().optional(),announceTargets:S(p().min(1)).max(16),nonBlocking:sq.default([]),blocking:cq.default([]),secureOnArmOff:lq.default([]),modeDelays:lDe.default([])}),dq=b({id:p().min(1).max(64),name:p().min(1).max(64),isDefault:v()}),fq=b({activeId:p().min(1),items:S(dq).min(1)}),pq=b({name:p().min(1).max(64),cloneFromId:p().min(1).max(64).optional()}),mq=b({id:p().min(1).max(64),name:p().min(1).max(64)}),hq=b({id:p().min(1).max(64)}),gq=uq.extend({nonBlocking:sq,blocking:cq,secureOnArmOff:lq,modeDelays:uDe,nonBlockingEdit:eq,blockingEdit:tq,secureOnArmEdit:nq}).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`}),dDe=x([`muted`,`detection-off`,`offline`]),_q=b({deviceId:f().int(),reason:dDe}),vq=b({mode:cS,ruleCount:f().int().min(0),allDevices:v(),deviceIds:S(f().int()),allDevicesExcept:S(f().int()).default([]),skippedDevices:S(_q).default([])}),fDe=b({deviceId:f().int(),name:p(),state:p(),blocking:v()}),pDe=b({deviceId:f().int(),name:p(),phase:x([`open`,`closed`])}),mDe=b({mode:cS,devices:S(fDe),unknown:S(f().int())}),hDe=b({ruleId:p(),ruleName:p(),deviceId:f().int(),name:p(),since:f(),dropped:f().int().min(0)}),gDe=b({state:sS,targetMode:cS.nullable(),availableModes:S(cS),openings:S(mDe),exclusions:S(pDe),bypassedInputs:S(hDe).default([])}),yq=b({deviceId:f().int().nullable(),settings:uq,profiles:fq.optional(),coverage:S(vq),live:gDe.optional()}),_De=500,bq=x([`open`,`closed`,`unknown`,`not-opening`]),xq=b({deviceId:f().int().positive(),reading:bq,state:p().nullable(),unknownWhy:x([`read-failed`,`unknown-word`]).nullable(),online:v().nullable(),controllable:v().default(!1)}),Sq=b({deviceIds:S(f().int().positive()).max(500)}),Cq=b({sensors:S(xq),readAt:f().int().nonnegative()}),vDe=60,wq=b({deviceId:f().int().nonnegative().optional(),seconds:f().min(0).max(60),profile:M.optional(),ruleId:p(),ruleName:p(),reason:x([`window`,`occupancy`])}),Tq=b({rulesLoaded:v(),asks:S(wq).readonly()}),Eq={name:`notification-rules`,scope:`system`,mode:`singleton`,methods:{listRules:O(b({}),b({rules:S(yK)}),{auth:`admin`}),getRule:O(b({ruleId:p()}),b({rule:yK.nullable()}),{auth:`admin`}),createRule:O(b({rule:pK}),b({rule:yK}),{kind:`mutation`,auth:`admin`,caller:`required`}),updateRule:O(vK,b({rule:yK}),{kind:`mutation`,auth:`admin`,caller:`required`}),deleteRule:O(b({ruleId:p()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),setRuleEnabled:O(b({ruleId:p(),enabled:v()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),getClipRetentionAsks:O(b({}),Tq,{auth:`admin`}),listDeviceMutes:O(b({}),b({mutedDeviceIds:S(f().int()).readonly()}),{auth:`admin`}),setDeviceMuted:O(b({deviceId:f().int(),muted:v()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),testRule:O(b({rule:pK,lookbackMinutes:f().int().min(1).max(1440).default(60)}),b({results:S(TK)}),{kind:`mutation`,auth:`admin`}),previewStateSummary:O(b({rule:pK}),wK,{kind:`mutation`,auth:`admin`,access:`view`}),getConditionCatalog:O(b({}),b({catalog:S(IK),taxonomy:SG.optional()})),getTemplateCatalog:O(b({}),b({vars:S(MK),defaults:S(OK)})),previewTemplate:O(PK,FK,{kind:`mutation`,access:`view`}),getHistory:O(b({filter:VK.default({limit:100})}),b({entries:S(BK)}),{auth:`admin`}),getRuleLastRuns:O(b({}),UK,{auth:`admin`}),resolveArtifactUrl:O(b({artifactId:p().min(1)}),b({url:p().nullable()}),{auth:`admin`}),listSnoozes:O(b({}),b({snoozes:S(KK)}),{caller:`required`}),createSnooze:O(b({snooze:GK}),b({snooze:KK}),{kind:`mutation`,caller:`required`}),cancelSnooze:O(b({snoozeId:p()}),b({success:o(!0)}),{kind:`mutation`,caller:`required`}),getAlarmConfig:O(b({}),yq,{auth:`admin`}),setAlarmConfig:O(b({patch:gq}),yq,{kind:`mutation`,auth:`admin`}),createAlarmProfile:O(pq,yq,{kind:`mutation`,auth:`admin`}),renameAlarmProfile:O(mq,yq,{kind:`mutation`,auth:`admin`}),deleteAlarmProfile:O(hq,yq,{kind:`mutation`,auth:`admin`}),activateAlarmProfile:O(hq,yq,{kind:`mutation`,auth:`admin`}),getAlarmSensors:O(Sq,Cq,{auth:`admin`})},vocabulary:{notOperatorFacing:`notification rules — authored on their own page`}},yDe=x([`min`,`low`,`normal`,`high`]),bDe=b({id:p().min(1),title:p().min(1),uri:m().optional(),destructive:v().optional()}),xDe=b({image:v(),priority:v(),data:v(),actions:v(),recipients:v()}),Dq=b({lastSentAt:f(),lastError:p().nullable(),queueDepth:f().int().nonnegative().meta(j(`count`)),supports:xDe}),SDe=b({deviceId:f().int().nonnegative(),title:p().optional(),body:p().min(1),image:p().optional(),priority:yDe.optional(),channel:p().optional(),recipients:S(p()).optional(),actions:S(bDe).optional(),data:u(p(),l()).optional()}),CDe=b({notificationId:p(),acceptedAt:f()}),Oq={name:`notifier`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Notifier],methods:{send:O(SDe,CDe,{kind:`mutation`,auth:`admin`,actions:[{id:`notifier.send`,label:N(`Send a notification`,`Invia una notifica`),phrase:N(`Send “{body}” through {device}`,`Invia «{body}» tramite {device}`),icon:`send`,openArgs:[{key:`title`,label:N(`Title`,`Titolo`),offer:{kind:`text`},optional:!0},{key:`body`,label:N(`Message`,`Messaggio`),offer:{kind:`text`}},{key:`priority`,label:N(`Priority`,`Priorità`),offer:{kind:`enum`,values:[{value:`min`,label:N(`Minimal`,`Minima`)},{value:`low`,label:N(`Low`,`Bassa`)},{value:`normal`,label:N(`Normal`,`Normale`)},{value:`high`,label:N(`High`,`Alta`)}]},optional:!0}]}]}),cancel:O(b({deviceId:f().int().nonnegative(),notificationId:p().min(1)}),_(),{kind:`mutation`,auth:`admin`})},events:{onSent:{data:b({deviceId:f(),notificationId:p(),success:v(),error:p().nullable(),acceptedAt:f()}),notOperatorFacing:`a delivery receipt of a send this system made — not a fact about the world`}},status:{schema:Dq,kind:`command-driven`},runtimeState:Dq,durability:`session`,history:`none`,vocabulary:{noun:N(`Notifier`,`Notificatore`),order:2110}},kq=b({value:f().nullable().meta(j(`device`)),lastFetchedAt:f()}),Aq={name:`numeric-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Sensor],methods:{},status:{schema:kq,kind:`push`},runtimeState:kq,durability:`restored`,history:{fields:{value:{kind:`gauge`,minIntervalMs:3e4}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:N(`Sensor`,`Sensore`),order:5150,state:[{kind:`numeric`,field:`value`,quantity:N(`the reading`,`il valore`),label:N(`Reading`,`Valore`),icon:`gauge`}]}},jq=b({integrationId:p(),displayName:p(),requestedScopes:S(Rh),allowedRedirectPrefixes:S(p()).min(1),allowedPrivateHostPaths:S(p()).optional(),requiresPkce:v().optional(),hubUrl:p().optional(),refreshTokenTtlSec:c([f().int().positive(),o(`never`)]).optional(),instances:S(b({id:p(),displayName:p()})).optional()}),Mq={name:`oauth-integration`,scope:`system`,mode:`collection`,internal:!0,methods:{getDescriptor:O(_(),jq,{auth:`admin`})},vocabulary:{notOperatorFacing:A.IDENTITY}},Nq=x([`text`,`timestamp`,`watermark`]),Pq=x([`top-left`,`top-center`,`top-right`,`bottom-left`,`bottom-center`,`bottom-right`,`custom`]),Fq=b({id:p(),kind:Nq,enabled:v(),text:p().optional(),position:Pq.optional(),availablePositions:S(Pq).readonly(),readOnly:v().optional(),maxCharacters:f().int().positive().optional()}),Iq=b({overlays:S(Fq).readonly()}),Lq=b({enabled:v().optional(),text:p().optional(),position:Pq.optional()}).partial(),Rq={name:`osd`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Camera],methods:{setOverlay:O(b({deviceId:f(),overlayId:p(),patch:Lq}),_(),{kind:`mutation`,auth:`admin`})},events:{onStatusChanged:{data:b({deviceId:f(),status:Iq}),notOperatorFacing:`an overlay setting changed — configuration, not a happening`}},status:{schema:Iq,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:N(`On-screen text`,`Testo in sovrimpressione`),order:3190}},zq=1024,Bq=b({id:p().min(1).max(64),name:p().min(1).max(64),text:p().max(zq).default(``)}),Vq=i(`kind`,[b({kind:o(`none`)}),b({kind:o(`static`),text:p().max(zq)}),b({kind:o(`template`),templateId:p().min(1).max(64)})]),Hq=b({enabled:v().default(!0),source:Vq,schedule:FG.optional(),conditions:ZG.optional()}),Uq=b({slotId:p(),kind:Nq,readOnly:v(),cameraEnabled:v(),cameraText:p().optional(),binding:Hq.nullable()}),Wq=x([`written`,`unchanged`,`gated`,`unreadable`,`disabled`,`unbound`,`failed`]),Gq=b({slotId:p(),outcome:Wq,text:p(),reason:p().optional()}),Kq=b({ok:v(),text:p(),notes:S(p())}),qq={name:`osd-manager`,scope:`system`,mode:`singleton`,methods:{getDeviceOsd:O(b({deviceId:f().int()}),b({supported:v(),slots:S(Uq)}),{auth:`admin`}),getConditionSupport:O(b({}),b({supported:S(p()),catalog:S(IK)}),{auth:`admin`}),setSlotBinding:O(b({deviceId:f().int(),slotId:p().min(1),binding:Hq}),b({slot:Uq,render:Gq}),{kind:`mutation`,auth:`admin`}),clearSlotBinding:O(b({deviceId:f().int(),slotId:p().min(1)}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),setSlotCameraEnabled:O(b({deviceId:f().int(),slotId:p().min(1),enabled:v()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),copyDeviceConfiguration:O(b({sourceDeviceId:f().int(),targetDeviceId:f().int()}),b({copied:f().int().nonnegative(),skipped:f().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),previewSlot:O(b({deviceId:f().int(),slotId:p().min(1),binding:Hq.optional()}),Gq,{kind:`mutation`,auth:`admin`}),previewTemplate:O(b({deviceId:f().int(),text:p().max(zq)}),Kq,{kind:`mutation`,auth:`admin`}),renderDevice:O(b({deviceId:f().int()}),b({results:S(Gq)}),{kind:`mutation`,auth:`admin`}),listTemplates:O(b({}),b({templates:S(Bq)}),{auth:`admin`}),upsertTemplate:O(b({template:Bq}),b({template:Bq}),{kind:`mutation`,auth:`admin`}),deleteTemplate:O(b({templateId:p().min(1).max(64)}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:A.PIPELINE}},wDe=4,TDe=200,EDe=x([`normal`,`offline`,`on_batteries`]),Jq=f().int().min(4).max(200),Yq=Jq.meta(Spe({quantity:`mass`,unit:`g`})),Xq=b({foodLevel:f().nullable().meta(j(`none`)),bowlFood:f().nullable().meta(j(`mass`)),eating:v(),supportsMarkRefilled:v(),food1:f().nullable().meta(j(`none`)),food2:f().nullable().meta(j(`none`)),lowFood:v(),batteryPower:f().min(0).max(100).nullable().meta(j(`percentage`)),powerSource:x([`mains`,`battery`]).nullable(),desiccantLeftDays:f().nullable().meta(j(`duration`)),feeding:v(),status:EDe.nullable(),error:p().nullable(),errorCode:f().nullable().meta(j(`none`)),isDualHopper:v(),childLock:v(),indicatorLight:v(),feedSound:v(),volume:f().meta(j(`none`)),lastFeedGrams:Jq.nullable(),lastFeedHopper1:Jq.nullable(),lastFeedHopper2:Jq.nullable(),lastFetchedAt:f()}),Zq={name:`pet-feeder`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.PetFeeder],methods:{feed:O(b({deviceId:f().int().nonnegative(),grams:Yq.optional(),hopper1:Yq.optional(),hopper2:Yq.optional()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.feed`,label:N(`Feed`,`Dai da mangiare`),phrase:N(`Dispense {grams} from {device}`,`Eroga {grams} da {device}`),icon:`paw-print`,openArgs:[{key:`grams`,label:N(`Grams`,`Grammi`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0}]},{id:`petFeeder.feedHoppers`,label:N(`Feed from both hoppers`,`Eroga da entrambi i serbatoi`),phrase:N(`Dispense {hopper1} and {hopper2} from {device}`,`Eroga {hopper1} e {hopper2} da {device}`),icon:`paw-print`,openArgs:[{key:`hopper1`,label:N(`Hopper 1`,`Serbatoio 1`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0},{key:`hopper2`,label:N(`Hopper 2`,`Serbatoio 2`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0}]}]}),cancelFeed:O(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.cancelFeed`,label:N(`Cancel feeding`,`Annulla l’erogazione`),phrase:N(`Cancel the feeding on {device}`,`Annulla l’erogazione di {device}`),icon:`circle-x`}]}),callPet:O(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.callPet`,label:N(`Call pet`,`Chiama l’animale`),phrase:N(`Call your pet with {device}`,`Chiama l’animale con {device}`),icon:`megaphone`}]}),playSound:O(b({deviceId:f().int().nonnegative(),soundId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.playSound`,label:N(`Play sound`,`Riproduci un suono`),phrase:N(`Play sound {soundId} on {device}`,`Riproduci il suono {soundId} su {device}`),icon:`volume-2`,openArgs:[{key:`soundId`,label:N(`Sound`,`Suono`),offer:{kind:`number`,min:0,step:1}}]}]}),resetDesiccant:O(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.resetDesiccant`,label:N(`Desiccant replaced`,`Essiccante sostituito`),phrase:N(`Mark the desiccant of {device} as replaced`,`Segna come sostituito l’essiccante di {device}`),icon:`refresh-cw`}]}),markFoodReplenished:O(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.foodReplenished`,label:N(`Food refilled`,`Cibo ricaricato`),phrase:N(`Mark {device} as refilled`,`Segna {device} come ricaricato`),icon:`package`}]}),setChildLock:O(b({deviceId:f().int().nonnegative(),on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.childLockOn`,label:N(`Child lock on`,`Blocco bambini attivo`),phrase:N(`Turn on the child lock of {device}`,`Attiva il blocco bambini di {device}`),icon:`lock`,args:{on:!0}},{id:`petFeeder.childLockOff`,label:N(`Child lock off`,`Blocco bambini spento`),phrase:N(`Turn off the child lock of {device}`,`Disattiva il blocco bambini di {device}`),icon:`lock-open`,args:{on:!1}}]}),setIndicatorLight:O(b({deviceId:f().int().nonnegative(),on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.lightOn`,label:N(`Indicator light on`,`Spia accesa`),phrase:N(`Turn on the indicator light of {device}`,`Accendi la spia di {device}`),icon:`lightbulb`,args:{on:!0}},{id:`petFeeder.lightOff`,label:N(`Indicator light off`,`Spia spenta`),phrase:N(`Turn off the indicator light of {device}`,`Spegni la spia di {device}`),icon:`lightbulb-off`,args:{on:!1}}]}),setFeedSound:O(b({deviceId:f().int().nonnegative(),on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.feedSoundOn`,label:N(`Feeding sound on`,`Suono di erogazione attivo`),phrase:N(`Turn on the feeding sound of {device}`,`Attiva il suono di erogazione di {device}`),icon:`volume-2`,args:{on:!0}},{id:`petFeeder.feedSoundOff`,label:N(`Feeding sound off`,`Suono di erogazione spento`),phrase:N(`Turn off the feeding sound of {device}`,`Disattiva il suono di erogazione di {device}`),icon:`volume-x`,args:{on:!1}}]}),setVolume:O(b({deviceId:f().int().nonnegative(),level:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.volume`,label:N(`Set volume`,`Imposta il volume`),phrase:N(`Set the volume of {device} to {level}`,`Imposta il volume di {device} a {level}`),icon:`volume-2`,openArgs:[{key:`level`,label:N(`Volume`,`Volume`),offer:{kind:`number`,min:0,step:1}}]}]})},status:{schema:Xq,kind:`poll`},runtimeState:Xq,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:N(`Pet feeder`,`Distributore di cibo`),order:2030,state:[{kind:`boolean`,field:`lowFood`,label:N(`Food low`,`Cibo in esaurimento`),whenTrue:N(`When {device} runs low on food`,`Quando il cibo di {device} sta finendo`),whenFalse:N(`When {device} has enough food again`,`Quando {device} ha di nuovo cibo a sufficienza`),icon:`package`},{kind:`boolean`,field:`feeding`,label:N(`Feeding`,`In erogazione`),whenTrue:N(`When {device} starts feeding`,`Quando {device} inizia a erogare`),whenFalse:N(`When {device} finishes feeding`,`Quando {device} finisce di erogare`),icon:`paw-print`},{kind:`numeric`,field:`desiccantLeftDays`,quantity:N(`the desiccant life`,`la durata dell’essiccante`),label:N(`Desiccant`,`Essiccante`),unit:`d`,icon:`calendar-clock`}]}},Qq=b({waterLevel:f().min(0).max(100).nullable().meta(j(`percentage`)),waterVolume:f().min(0).nullable().meta(j(`volume`)),empty:v().nullable(),pumpRunning:v().nullable(),error:p().nullable(),lastFetchedAt:f()}),$q=`water`;function DDe(e){let t=e.waterLevel!==null||e.empty===null?null:e.empty?`empty`:`ok`;return{key:$q,label:`Water`,level:e.waterLevel,status:t,kind:`supply`,form:`tank`,lastResetAt:null,resettable:!1}}var ODe=f().int().nonnegative(),eJ={name:`pet-fountain`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.PetFountain],power:{kind:`field`,field:`pumpRunning`,set:`setPump`},methods:{setPump:O(b({deviceId:ODe,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFountain.pumpOn`,label:N(`Pump on`,`Pompa accesa`),phrase:N(`Start the pump of {device}`,`Avvia la pompa di {device}`),icon:`play`,args:{on:!0}},{id:`petFountain.pumpOff`,label:N(`Pump off`,`Pompa spenta`),phrase:N(`Stop the pump of {device}`,`Ferma la pompa di {device}`),icon:`square`,args:{on:!1}}]})},status:{schema:Qq,kind:`push`},runtimeState:Qq,durability:`session`,history:{fields:{waterLevel:{kind:`gauge`,unit:`%`,deadband:1},waterVolume:{kind:`gauge`,unit:`L`}}},vocabulary:{noun:N(`Pet fountain`,`Fontana per animali`),order:2040,state:[{kind:`boolean`,field:`empty`,label:N(`Tank empty`,`Serbatoio vuoto`),whenTrue:N(`When the tank of {device} is empty`,`Quando il serbatoio di {device} è vuoto`),whenFalse:N(`When the tank of {device} is refilled`,`Quando il serbatoio di {device} viene riempito`),icon:`droplet`},{kind:`numeric`,field:`waterLevel`,quantity:N(`the water level`,`il livello dell’acqua`),label:N(`Water level`,`Livello dell’acqua`),unit:`%`,icon:`droplets`}]}},kDe=x(ba),ADe=2,tJ={min:1,max:8},nJ=x([`intel-core-ultra`,`intel-n-series`,`apple-m-base`,`apple-m-pro`,`amd-phoenix`,`unknown`]),rJ=x([`intel-npu`,`intel-igpu`,`amd-igpu`,`amd-npu`,`x86-cpu`,`arm-cpu`,`apple-ane`,`coral`]),iJ=i(`kind`,[b({kind:o(`capacity`),sessions:f(),minSessions:f()}),b({kind:o(`tie-faster`),over:p(),recallDelta:f()}),b({kind:o(`stepped-down`),from:p(),to:p(),limitedBy:p()}),b({kind:o(`no-fit-lightest`),sessions:f(),minSessions:f()}),b({kind:o(`derived-latency`),modelId:p()}),b({kind:o(`cpu-device`)}),b({kind:o(`device-disabled`)}),b({kind:o(`device-unavailable`)}),b({kind:o(`node-offline`)}),b({kind:o(`no-hardware-facts`)}),b({kind:o(`no-measured-data`),hardwareClass:nJ}),b({kind:o(`no-family-build`),format:kDe}),b({kind:o(`kept-custom-pin`),modelId:p(),deviceKey:p()})]),aJ=x([`custom-pin`]),oJ=i(`kind`,[b({kind:o(`table`)}),b({kind:o(`node-benchmark`),resultId:p(),measuredAtMs:f()}),b({kind:o(`estimated`),estimatedFrom:nJ})]),sJ=b({modelId:p(),p50Ms:f(),fps:f(),measured:v(),source:oJ.optional(),estimatedFrom:nJ.optional(),capacitySessions:f(),personRecall:f()}),cJ=b({deviceKey:p(),accelerator:rJ.nullable(),enabled:v(),available:v(),chosen:sJ.nullable(),kept:aJ.optional(),reasons:S(iJ).readonly()}),lJ=b({nodeId:p(),reachable:v(),hardwareClass:nJ.nullable(),cpuModel:p().nullable(),skipped:v(),acceleratorModelId:p().nullable(),devices:S(cJ).readonly(),reasons:S(iJ).readonly()}),uJ=b({stepId:p(),before:p().nullable(),after:p().nullable()}),dJ=b({nodeId:p(),deviceKey:p(),madeExplicit:v(),modelPins:S(uJ).readonly(),thresholds:S(b({stepId:p(),keys:S(p()).readonly()})).readonly()}),fJ=i(`kind`,[b({kind:o(`custom-pin-kept`),nodeId:p(),deviceKey:p(),modelId:p()}),b({kind:o(`custom-registry-unreadable`),error:p()})]),pJ=b({headroom:f().min(.3).max(.5).default(.4),minSessionsPerDevice:f().int().min(tJ.min).max(tJ.max).default(2)}),mJ=b({planHash:p(),family:o(`yolov9`),headroom:f(),minSessionsPerDevice:f(),cameraFps:f(),generatedAt:f(),nodes:S(lJ).readonly(),nodeChanges:S(dJ).readonly(),warnings:S(fJ).readonly()}),hJ=b({planHash:p(),headroom:f().min(.3).max(.5).default(.4),minSessionsPerDevice:f().int().min(tJ.min).max(tJ.max).default(2)}),gJ=b({phase:x([`download`,`node-models`,`redispatch`]),ok:v(),detail:p()}),_J=i(`kind`,[b({kind:o(`applied`),planHash:p(),phases:S(gJ).readonly()}),b({kind:o(`aborted`),phases:S(gJ).readonly()}),b({kind:o(`stale`),plan:mJ}),b({kind:o(`refused`),reason:x([`apply-in-progress`])})]),vJ=x([`least-loaded`,`share`]),yJ=`share`,jDe=`sessionPlacement`;function MDe(e){let t=vJ.safeParse(e);return t.success?t.data:yJ}var bJ=b({nodes:u(p(),f().positive()).default({}),devices:u(p(),u(p(),f().positive())).default({})}),xJ=b({windowMs:f().int().min(6e4).max(1440*60*1e3).default(3600*1e3)}),SJ=b({deviceKey:p(),sessionsNow:f(),sessionsStarted:f(),observedShare:f().nullable()}),CJ=b({nodeId:p(),sessionsNow:f(),sessionsStarted:f(),observedShare:f().nullable(),peakSessions:f(),yieldsAway:f(),devices:S(SJ).readonly()}),wJ=b({deviceId:f(),deviceKey:p(),reason:x([`disabled`,`absent`])}),TJ=b({policy:vJ,windowMs:f(),observedForMs:f(),sessionsNow:f(),clusterPeakSessions:f(),nodes:S(CJ).readonly(),stalePins:S(wJ).readonly()}),EJ=x([`hardware`,`benchmark`]),DJ=x([`no-benchmark-results`,`partial-benchmark-results`]),OJ=b({headroom:f().min(.3).max(.5).default(.4),source:EJ.default(`hardware`)}),kJ=b({deviceKey:p(),share:f(),modelId:p().nullable(),fps:f().nullable(),measured:v(),suggestedMaxSessions:f().nullable()}),AJ=b({nodeId:p(),share:f().nullable(),capacitySessions:f(),devices:S(kJ).readonly(),skippedReason:p().nullable(),capacitySource:EJ.nullable(),capacityFallback:DJ.nullable()}),jJ=b({headroom:f(),source:EJ,cameraFps:f(),minSessionsPerDevice:f(),nodes:S(AJ).readonly()}),MJ=x([`hardware`,`benchmark`,`manual`]),NJ=`benchmark`;function PJ(e){return e!==`manual`}var NDe=.4,PDe=`shareSource`;function FDe(e){if(e===`auto`)return`hardware`;let t=MJ.safeParse(e);return t.success?t.data:NJ}var FJ=b({source:MJ}),IDe=b({nodes:u(p(),f()),devices:u(p(),u(p(),f()))}),IJ=b({deviceKey:p(),eligible:v(),configuredPct:f(),effectivePct:f()}),LJ=b({nodeId:p(),eligible:v(),configuredPct:f(),effectivePct:f(),capacitySource:EJ.nullable(),capacityFallback:DJ.nullable(),devices:S(IJ).readonly()}),RJ=b({source:MJ,policy:vJ,autoPending:v(),computedAt:f().nullable(),trigger:p().nullable(),nodes:S(LJ).readonly(),nodeWeights:u(p(),f()),deviceWeights:u(p(),u(p(),f()))}),zJ=[`motion-without-detections`,`detections-under-floor`,`inference-too-slow`,`frames-shed`,`inference-device-unusable`],BJ=x(zJ),VJ=x([`info`,`warning`,`critical`]),HJ=i(`type`,[b({type:o(`camera`),deviceId:f()}),b({type:o(`node`),nodeId:p()}),b({type:o(`inference-device`),nodeId:p(),deviceKey:p()})]),UJ=b({id:p(),kind:BJ,severity:VJ,subject:HJ,what:p(),evidence:u(p(),f().nullable()),action:p()}),WJ=b({source:p(),entries:f().nullable()}),GJ=b({nodeId:p(),sessionsNow:f(),unusableDevices:S(p()).readonly(),devices:S(b({deviceKey:p(),sessionsNow:f(),usable:v()})).readonly()}),KJ=b({deviceId:f(),nativeCropMissesSincePreviousTick:f().nullable()}),qJ=b({generatedAt:f(),tickMs:f(),camerasSeen:f().nullable(),findings:S(UJ).readonly(),cameraSignals:S(KJ).readonly(),nodes:S(GJ).readonly(),sources:S(WJ).readonly(),notCovered:S(p()).readonly()}),JJ=b({history:f().int().min(1).max(24).default(1)}),YJ=b({latest:qJ.nullable(),previous:S(qJ).readonly()}),LDe=b({engine:PH.optional(),steps:S(Da).readonly(),audio:b({engine:PH.optional(),modelId:p().optional(),enabled:v(),settings:u(p(),l()).readonly().optional()}).nullable().optional()}),XJ=b({modelId:p().optional(),settings:u(p(),l()).optional(),jumpDeviceKey:p().optional()}),ZJ=b({maxCameras:f().int().nonnegative().nullable().default(null),detectWeight:f().positive().optional(),detect:v().optional(),decode:v().optional(),audio:v().optional(),ingest:v().optional(),decodeBudgetMb:f().int().min(1024).max(65536).optional(),maxLiveDecodeWorkers:f().int().min(1).max(32).optional(),reachableHost:p().optional(),color:Uc.optional(),stepSettings:u(p(),u(p(),l()).readonly()).optional(),inferenceDevices:u(p(),b({enabled:v(),weight:f().positive().optional(),maxSessions:f().int().positive().optional(),steps:u(p(),XJ).optional()})).optional()}),RDe=u(p(),u(p(),l()).readonly()),QJ=x([`pipeline`,`onboard`,`none`]),zDe=b({stepToggles:u(p(),v()).optional(),stepSettings:RDe.optional()}),$J=b({deviceId:f(),agentNodeId:p(),pinned:v(),reason:x([`manual`,`capacity`,`hardware-affinity`,`failover`,`rebalance`]),assignedAt:f()}),eY=b({nodeId:p(),online:v(),load:KU,score:f(),decodeHwaccel:p().nullable()}),tY=b({totalAgents:f(),onlineAgents:f(),totalCameras:f(),attachedCameras:f(),activeCameras:f(),avgInferenceTimeMs:f(),queueDepth:f()}),nY=u(p(),p()),rY=b({ownerNodeId:p(),reachableHost:p().optional(),configIssue:p().optional()}),iY=b({camStreamId:p(),codec:p(),width:f(),height:f(),fps:f(),kind:p()}),aY=b({streams:S(iY).readonly()}),oY=b({detectionNodeId:p().nullable(),decoderNodeId:p().nullable(),audioNodeId:p().nullable(),sourceNodeId:p().nullable(),pinned:b({detection:v(),decoder:v(),audio:v()}),reasons:b({detection:p().optional(),decoder:p().optional(),audio:p().optional()})}),sY=b({profile:p(),status:p(),codec:p(),width:f(),height:f(),subscribers:f(),inFps:f().nullable()}),cY=b({profiles:S(sY).readonly(),webrtcSessions:f(),rtspRestream:v()}),lY=b({nodeId:p()}),uY=b({enabled:v(),fps:f()}),dY=x([`idle`,`installing`,`verifying`,`ready`,`failed`]),fY=b({state:dY,error:p().optional()}),pY=x([`idle`,`watching`,`active`]),mY=b({nodeId:p(),engine:b({backend:p(),device:p()}),phase:pY,configuredFps:f(),actualFps:f(),queueDepth:f(),avgInferenceMs:f(),provisioning:fY}),hY=b({nodeId:p(),enabled:v()}),gY=lp,_Y=b({mode:gY,active:v(),storageBytes:f()}),vY=x([`source`,`broker`,`detection`,`recording`,`switches`]),yY=x([`timeout`,`error`,`partial`]),bY=b({stage:vY,reason:yY,elapsedMs:f()}),xY=b({state:x([`idle`,`running`,`done`,`error`]),total:f().int().nonnegative(),completed:f().int().nonnegative(),currentDeviceId:f().int().nullable(),failed:S(f().int()).readonly(),mediaDropped:f().int().nonnegative(),tracks:f().int().nonnegative(),events:f().int().nonnegative(),startedAtMs:f().int().nullable(),finishedAtMs:f().int().nullable(),error:p().nullable()}),SY=b({deviceId:f(),assignment:oY,source:aY,broker:cY.nullable(),decoder:lY.nullable(),motion:uY.nullable(),detection:mY.nullable(),audio:hY.nullable(),recording:_Y.nullable(),switchedOff:S(td).readonly(),cameraSensors:pB.optional(),degraded:S(bY).readonly(),fetchedAt:f()}),CY=[`disabled`,`unavailable`,`cannot-host-camera-root`,`accelerator-preferred`],wY=x(CY),BDe=b({key:p(),backend:p(),device:p(),format:x(ba),available:v(),presence:x([`present`,`absent`,`unknown`]).optional(),enabled:v(),weight:f(),maxSessions:f().nullable(),defaultModelId:p(),steps:u(p(),XJ).optional(),exclusion:wY.nullable()}),TY=i(`kind`,[b({kind:o(`stored`),modelId:p()}),b({kind:o(`absent`),defaultModelId:p()}),b({kind:o(`unreadable`),reason:x(EB),error:p().optional()})]),VDe=b({nodeId:p(),reachable:v(),devices:S(BDe).readonly()}),EY=b({deviceId:f().int().nonnegative(),config:oB.nullable()}),DY=x([`unknown-camera`,`out-of-range`,`no-burst-producer`,`already-looked`]),OY=b({deviceId:f().int().nonnegative(),afterMs:f().finite(),reason:p()}),kY=b({scheduled:v(),dueInMs:f().optional(),refusedBecause:DY.optional()}),AY={name:`pipeline-orchestrator`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,exposesDeviceSettings:!0,methods:{requestOccupancyLook:O(OY,kY,{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:O(Dp,b({paused:o(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:O(Dp,b({resumed:o(!0)}),{kind:`mutation`,auth:`admin`}),assignPipeline:O(b({deviceId:f(),agentNodeId:p()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),unassignPipeline:O(b({deviceId:f()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),setPipelineDevicePin:O(b({deviceId:f(),deviceKey:p()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),getPipelineDevicePin:O(b({deviceId:f()}),b({deviceKey:p().nullable()})),rebalance:O(_(),b({migrated:f(),skipped:S(b({deviceId:f(),targetNodeId:p(),reason:p()})).default([])}),{kind:`mutation`,auth:`admin`}),getPipelineAssignments:O(_(),S($J).readonly()),getPipelineAssignment:O(b({deviceId:f()}),$J.nullable()),getAgentLoad:O(_(),S(eY).readonly()),getClusterModelChoice:O(b({stepId:p()}),TY),getGlobalMetrics:O(_(),tY),getCameraMetrics:O(b({deviceId:f()}),VH.nullable()),getCapabilityBindings:O(b({nodeId:p()}),nY),setCapabilityBinding:O(b({nodeId:p(),capName:p(),addonId:p()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),getIngestOwner:O(_(),rY),assignAudio:O(b({deviceId:f(),nodeId:p()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),unassignAudio:O(b({deviceId:f()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),getAudioAssignment:O(b({deviceId:f()}),b({nodeId:p(),pinned:v(),assignedAt:f()}).nullable()),getAudioNodeLoad:O(_(),S(b({nodeId:p(),deviceCount:f()}))),getAudioAssignments:O(_(),S(b({deviceId:f(),nodeId:p(),pinned:v(),assignedAt:f()}))),getAgentSettings:O(b({agentNodeId:p()}),ZJ.nullable()),listAgentSettings:O(_(),S(b({nodeId:p(),settings:ZJ})).readonly()),removeAgentSettings:O(b({agentNodeId:p()}),b({success:v(),removed:v()}),{kind:`mutation`,auth:`admin`}),setAgentMaxCameras:O(b({agentNodeId:p(),maxCameras:f().int().nonnegative().nullable()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),setAgentCapabilities:O(b({agentNodeId:p(),detect:v().nullable().optional(),audio:v().nullable().optional(),ingest:v().nullable().optional()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),setAgentDecodeLimits:O(b({agentNodeId:p(),decodeBudgetMb:f().int().min(1024).max(65536).nullable().optional(),maxLiveDecodeWorkers:f().int().min(1).max(32).nullable().optional()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),setAgentReachableHost:O(b({agentNodeId:p(),reachableHost:p().nullable().optional(),color:Uc.nullable().optional()}).refine(e=>e.reachableHost!==void 0||e.color!==void 0,{message:`reachableHost or color required`}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),setAgentInferenceDevices:O(b({agentNodeId:p(),inferenceDevices:u(p(),b({enabled:v(),weight:f().positive().optional(),maxSessions:f().int().positive().optional(),steps:u(p(),XJ).optional()}))}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),setNodeStepSettings:O(b({agentNodeId:p(),addonId:p(),settings:u(p(),l()).nullable()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),getNodeInferenceDevices:O(b({nodeId:p()}),VDe),forgetInferenceDevice:O(b({agentNodeId:p(),deviceKey:p()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),resetNodePipelineDefaults:O(b({agentNodeId:p()}),b({success:o(!0),effectiveModelId:p().nullable()}),{kind:`mutation`,auth:`admin`}),planAutoTune:O(pJ,mJ,{auth:`admin`}),applyAutoTune:O(hJ,_J,{kind:`mutation`,auth:`admin`}),setLoadBalancingShares:O(bJ,b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),getPlacementStats:O(xJ,TJ,{auth:`admin`}),getHealthDigest:O(JJ,YJ,{auth:`admin`}),suggestShares:O(OJ,jJ,{auth:`admin`}),getEffectiveShares:O(_(),RJ,{auth:`admin`}),setShareSource:O(FJ,b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkPreflight:O(XH,tU,{auth:`admin`}),startNodeBenchmark:O(XH,i(`kind`,[b({kind:o(`started`),runId:p()}),b({kind:o(`refused`),preflight:tU})]),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkStatus:O(_(),gU,{auth:`admin`}),abortNodeBenchmark:O(b({runId:p()}),b({aborted:v()}),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkCandidates:O(b({nodeId:p()}),bU,{auth:`admin`}),listNodeBenchmarkResults:O(vU,S(yU).readonly(),{auth:`admin`}),deleteNodeBenchmarkResult:O(b({id:p()}),b({deleted:v()}),{kind:`mutation`,auth:`admin`}),getCameraSettings:O(b({deviceId:f()}),zDe.nullable()),setCameraStepToggle:O(b({deviceId:f(),addonId:p(),enabled:v().nullable()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),getCameraDetectionSource:O(b({deviceId:f()}),b({source:QJ,explicit:v(),onboard:b({available:v(),geometry:x([`boxed`,`while-streaming`,`flag-only`,`unknown`])})})),setCameraDetectionSource:O(b({deviceId:f(),source:QJ}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),setCameraStepSettings:O(b({deviceId:f(),addonId:p(),settings:u(p(),l()).nullable()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),resolvePipeline:O(b({deviceId:f(),agentNodeId:p().optional()}),LDe),getCameraSwitches:O(b({deviceId:f()}),sd,{role:`viewer`}),setCameraSwitch:O(b({deviceId:f(),switchId:td,enabled:v()}),sd,{kind:`mutation`,auth:`admin`}),getCameraStatus:O(b({deviceId:f()}),SY),getCameraStatuses:O(b({deviceIds:S(f()).optional()}),S(SY).readonly()),setCameraSensors:O(EY,b({success:o(!0)}),{kind:`mutation`,auth:`admin`}),reconcileFromDisk:O(_(),xY,{kind:`mutation`,auth:`admin`}),getReconcileFromDiskStatus:O(_(),xY,{auth:`admin`})},vocabulary:{notOperatorFacing:A.PIPELINE}},jY=b({id:p(),name:p(),sampleCount:f().int().nonnegative(),coverMediaId:f().int().optional(),coverBase64:p().optional()}),HDe=b({id:p(),text:p(),score:f(),addedAt:f().int(),deviceId:f().int().optional(),base64:p().optional(),mediaId:f().int().optional(),keyFrameMediaId:f().int().optional(),plateBbox:bS.optional()}),MY=b({plateId:p(),deviceId:f().int(),trackId:p(),timestamp:f().int(),text:p(),score:f(),corrected:v(),recognizedVehicleId:p().optional(),vehicleName:p().optional(),assigned:v(),plateBbox:bS.optional(),keyFrameMediaId:f().int().optional(),base64:p().optional(),cropUrl:p().optional(),cropMissReason:p().optional()}),UDe=b({mediaId:f().int(),kind:p(),url:p(),sizeBytes:f(),timestamp:f()}),WDe=b({plateIds:S(p()).readonly(),representativePlateId:p(),representativeText:p(),size:f().int(),cohesion:f()}),NY={name:`plate-gallery`,role:{feature:`plate-assignment`},scope:`system`,mode:`singleton`,methods:{listPlates:O(b({deviceId:f().int().optional(),limit:f().int().positive().optional(),includeCrops:v().optional()}).optional(),S(MY).readonly()),getPlateByTrack:O(b({deviceId:f().int(),trackId:p()}),MY.nullable(),{role:`viewer`}),getPlateMedia:O(b({plateId:p()}),S(UDe).readonly()),searchPlates:O(b({text:p().min(1),maxDistance:f().int().min(0).optional(),limit:f().int().positive().optional(),includeCrops:v().optional()}),S(MY).readonly()),suggestPlateClusters:O(b({maxDistance:f().int().min(0).optional(),minClusterSize:f().int().min(2).optional(),limit:f().int().positive().optional()}).optional(),S(WDe).readonly()),correctPlateText:O(b({plateId:p(),text:p().min(1)}),_(),{kind:`mutation`,auth:`admin`}),deletePlate:O(b({plateId:p()}),_(),{kind:`mutation`,auth:`admin`}),listVehicles:O(b({includeCrops:v().optional()}).optional(),S(jY).readonly()),createVehicle:O(b({name:p().min(1)}),jY,{kind:`mutation`,auth:`admin`}),renameVehicle:O(b({id:p(),name:p().min(1)}),_(),{kind:`mutation`,auth:`admin`}),deleteVehicle:O(b({id:p()}),_(),{kind:`mutation`,auth:`admin`}),listVehicleSamples:O(b({vehicleId:p()}),S(HDe).readonly()),removeVehicleSample:O(b({vehicleId:p(),sampleId:p()}),_(),{kind:`mutation`,auth:`admin`}),moveVehicleSample:O(b({sampleId:p().min(1),toVehicleId:p().min(1)}),_(),{kind:`mutation`,auth:`admin`}),assignPlate:O(b({plateId:p(),vehicleId:p()}),_(),{kind:`mutation`,auth:`admin`}),unassignPlate:O(b({plateId:p()}),_(),{kind:`mutation`,auth:`admin`}),assignPlates:O(b({plateIds:S(p()).min(1),vehicleId:p()}),b({assigned:f().int(),failed:S(p()).readonly()}),{kind:`mutation`,auth:`admin`}),unassignPlates:O(b({plateIds:S(p()).min(1)}),b({unassigned:f().int(),failed:S(p()).readonly()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`the plate gallery — curated on its own page`}},PY={"intel-core-ultra":{"intel-npu":{"yolov9t-320":{p50Ms:2.9,fps:383,measured:!0},"yolov9t-320-int8":{p50Ms:3.8,fps:333,measured:!0},"yolov9t-640":{p50Ms:7.4,fps:139,measured:!0},"yolov9t-640-int8":{p50Ms:7.5,fps:144,measured:!0},"yolov9s-320":{p50Ms:4.4,fps:241,measured:!0},"yolov9s-320-int8":{p50Ms:4.1,fps:264,measured:!0},"yolov9s-640":{p50Ms:12.7,fps:82,measured:!0},"yolov9s-640-int8":{p50Ms:10.7,fps:99,measured:!0},"yolov9m-320":{p50Ms:8.4,fps:123,measured:!0},"yolov9m-320-int8":{p50Ms:6.5,fps:165,measured:!0},"yolov9m-640":{p50Ms:29.5,fps:32,measured:!0},"yolov9m-640-int8":{p50Ms:19.5,fps:52,measured:!0}},"intel-igpu":{"yolov9t-320":{p50Ms:2.6,fps:405,measured:!0},"yolov9t-320-int8":{p50Ms:2.8,fps:324,measured:!0},"yolov9t-640":{p50Ms:6.5,fps:157,measured:!0},"yolov9t-640-int8":{p50Ms:5.6,fps:185,measured:!0},"yolov9s-320":{p50Ms:4.6,fps:200,measured:!0},"yolov9s-320-int8":{p50Ms:4.1,fps:239,measured:!0},"yolov9s-640":{p50Ms:15.2,fps:69,measured:!0},"yolov9s-640-int8":{p50Ms:10.5,fps:99,measured:!0},"yolov9m-320":{p50Ms:11.4,fps:88,measured:!0},"yolov9m-320-int8":{p50Ms:7,fps:127,measured:!0},"yolov9m-640":{p50Ms:40,fps:25,measured:!0},"yolov9m-640-int8":{p50Ms:23.5,fps:44,measured:!0}},"x86-cpu":{"yolov9t-320":{p50Ms:6.9,fps:145,measured:!0},"yolov9t-320-int8":{p50Ms:2.7,fps:405,measured:!0},"yolov9t-640":{p50Ms:23,fps:44,measured:!0},"yolov9t-640-int8":{p50Ms:8.8,fps:124,measured:!0},"yolov9s-320":{p50Ms:15.8,fps:63,measured:!0},"yolov9s-320-int8":{p50Ms:6.5,fps:180,measured:!0},"yolov9s-640":{p50Ms:58.2,fps:17,measured:!0},"yolov9s-640-int8":{p50Ms:20.1,fps:52,measured:!0},"yolov9m-320":{p50Ms:40,fps:25,measured:!0},"yolov9m-320-int8":{p50Ms:14.2,fps:74,measured:!0},"yolov9m-640":{p50Ms:155.8,fps:6,measured:!0},"yolov9m-640-int8":{p50Ms:52.4,fps:19,measured:!0}},coral:{"yolov9s-320-edgetpu":{p50Ms:32,fps:31,measured:!1}}},"intel-n-series":{"intel-igpu":{"yolov9t-320":{p50Ms:15,fps:48,measured:!0},"yolov9t-320-int8":{p50Ms:14.1,fps:67,measured:!0},"yolov9t-640":{p50Ms:38.5,fps:26,measured:!0},"yolov9t-640-int8":{p50Ms:50,fps:20,measured:!0},"yolov9s-320":{p50Ms:41.4,fps:24,measured:!0},"yolov9s-320-int8":{p50Ms:23.3,fps:34,measured:!0},"yolov9s-640":{p50Ms:127.4,fps:8,measured:!0},"yolov9s-640-int8":{p50Ms:81,fps:12,measured:!0},"yolov9m-320":{p50Ms:63.5,fps:16,measured:!0},"yolov9m-320-int8":{p50Ms:66,fps:15,measured:!0},"yolov9m-640":{p50Ms:215.5,fps:5,measured:!0},"yolov9m-640-int8":{p50Ms:163,fps:6,measured:!0}},"x86-cpu":{"yolov9t-320":{p50Ms:86.2,fps:12,measured:!0},"yolov9t-320-int8":{p50Ms:52.7,fps:20,measured:!0},"yolov9t-640":{p50Ms:322.1,fps:3,measured:!0},"yolov9t-640-int8":{p50Ms:205.6,fps:5,measured:!0},"yolov9s-320":{p50Ms:164.4,fps:6,measured:!0},"yolov9s-320-int8":{p50Ms:86.9,fps:12,measured:!0},"yolov9s-640":{p50Ms:341.3,fps:3,measured:!0},"yolov9s-640-int8":{p50Ms:185.3,fps:5,measured:!0},"yolov9m-320":{p50Ms:166.8,fps:6,measured:!0},"yolov9m-320-int8":{p50Ms:226.3,fps:4,measured:!0},"yolov9m-640":{p50Ms:663.5,fps:2,measured:!0},"yolov9m-640-int8":{p50Ms:324.4,fps:3,measured:!0}},coral:{"yolov9s-320-edgetpu":{p50Ms:32,fps:31,measured:!1}}},"amd-phoenix":{"x86-cpu":{"yolov9t-320":{p50Ms:24,fps:42,measured:!0},"yolov9t-320-int8":{p50Ms:12,fps:83,measured:!0},"yolov9t-640":{p50Ms:50,fps:20,measured:!0},"yolov9t-640-int8":{p50Ms:20,fps:50,measured:!0},"yolov9s-320":{p50Ms:30,fps:33,measured:!0},"yolov9s-320-int8":{p50Ms:15,fps:67,measured:!0},"yolov9s-640":{p50Ms:92,fps:11,measured:!0},"yolov9s-640-int8":{p50Ms:27,fps:37,measured:!0},"yolov9m-320":{p50Ms:67,fps:15,measured:!0},"yolov9m-320-int8":{p50Ms:21,fps:48,measured:!0},"yolov9m-640":{p50Ms:229,fps:4,measured:!0},"yolov9m-640-int8":{p50Ms:48,fps:21,measured:!0}},"amd-igpu":{"yolov9t-320":{p50Ms:40,fps:25,measured:!0},"yolov9t-640":{p50Ms:89,fps:11,measured:!0},"yolov9s-320":{p50Ms:65,fps:15,measured:!0},"yolov9s-640":{p50Ms:125,fps:8,measured:!0},"yolov9m-320":{p50Ms:85,fps:12,measured:!0},"yolov9m-640":{p50Ms:228,fps:4,measured:!0}},coral:{"yolov9s-320-edgetpu":{p50Ms:32,fps:31,measured:!0}}},"apple-m-pro":{"apple-ane":{"yolov9t-320":{p50Ms:1.1,fps:952,measured:!0},"yolov9t-640":{p50Ms:3,fps:333,measured:!0},"yolov9s-320":{p50Ms:1.5,fps:667,measured:!0},"yolov9s-640":{p50Ms:5.1,fps:196,measured:!0},"yolov9m-320":{p50Ms:3.2,fps:312,measured:!0},"yolov9m-640":{p50Ms:10.2,fps:98,measured:!0}},coral:{"yolov9s-320-edgetpu":{p50Ms:32,fps:31,measured:!1}}},"apple-m-base":{"apple-ane":{"yolov9t-320":{p50Ms:1.32,fps:758,measured:!1},"yolov9t-640":{p50Ms:3.45,fps:290,measured:!0},"yolov9s-320":{p50Ms:1.8,fps:556,measured:!1},"yolov9s-640":{p50Ms:5.46,fps:183,measured:!0},"yolov9m-320":{p50Ms:3.79,fps:264,measured:!0},"yolov9m-640":{p50Ms:10.34,fps:97,measured:!0}},coral:{"yolov9s-320-edgetpu":{p50Ms:32,fps:31,measured:!1}}}},FY={"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}},IY=.5,GDe=2,KDe=.05,qDe=24,JDe=750,YDe=64,LY=2e3,XDe=12,RY=f().nullable().transform(e=>e!==null&&Number.isFinite(e)&&e>0?e:null),zY=p().nullable().transform(e=>e!==null&&e.trim()!==``?e:null),BY=b({int8:RY,fp16:RY}),VY=b({deviceKey:p(),fullDeviceName:zY,executionUnits:RY,clockMHz:RY,gops:BY.nullable(),architecture:zY,npuName:zY,tops:RY,vendor:zY,webgpuArchitecture:zY,webgpuDevice:zY,computeUnits:RY}),ZDe=b({accelerators:S(VY).nullable()}),HY=[{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*LY}},{hardwareClass:`amd-phoenix`,accelerator:`amd-igpu`,score:{metric:`cu`,value:12}}];function QDe(e){let t=ZDe.safeParse(e);return!t.success||t.data.accelerators===null?null:t.data.accelerators}function UY(e){return e!==null&&e>0?e:null}function WY(e){let t=[],n=UY(e.gops?.int8??null);n!==null&&t.push({metric:`gops-int8`,value:n});let r=UY(e.gops?.fp16??null);r!==null&&t.push({metric:`gops-fp16`,value:r});let i=UY(e.executionUnits),a=UY(e.clockMHz);i!==null&&a!==null&&t.push({metric:`eu-mhz`,value:i*a});let o=UY(e.computeUnits);o!==null&&t.push({metric:`cu`,value:o});let s=UY(e.tops);return s!==null&&t.push({metric:`tops`,value:s}),t}function GY(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 KY(e,t,n){for(let r of WY(e))if(GY(t,r,n)!==null)return r;return null}function qY(e,t,n=HY){return KY(e,t,n)!==null}function JY(e,t,n){if(t!==`unknown`)return e[t]?.[n]}function $De(e){return Math.round(e*10)/10}function eOe(e){return Math.min(2,Math.max(IY,e))}function tOe(e,t,n){let r={};for(let[i,a]of Object.entries(e))r[i]={p50Ms:$De(a.p50Ms/t),fps:Math.max(1,Math.round(a.fps*t)),measured:!1,estimatedFrom:n};return r}function YY(e){let t=e.perf??PY,n=e.references??HY,r=JY(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:KY(e.report,e.accelerator,n);if(i===null)return r===void 0?null:{column:r,estimatedFrom:null};let a=GY(e.accelerator,i,n),o=a===null?void 0:JY(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:tOe(o,eOe(s),a.hardwareClass),estimatedFrom:a.hardwareClass}}var XY=x(ba),nOe=x([`videotoolbox`,`cuda`,`nvdec`,`vaapi`,`qsv`,`d3d11va`,`dxva2`,`amf`,`vdpau`,`drm`,`coreml`,`tensorrt`,`openvino`,`directml`,`webgpu`,`none`]).nullable().optional(),rOe=b({preferred:S(p()).readonly(),rationale:p()}),ZY=x([`h264_videotoolbox`,`hevc_videotoolbox`,`h264_vaapi`,`hevc_vaapi`,`h264_nvenc`,`hevc_nvenc`,`h264_qsv`,`hevc_qsv`,`h264_amf`,`hevc_amf`,`libx264`,`libx265`]);b({encoders:S(b({encoder:ZY,codec:x([`H264`,`H265`]),family:x([`videotoolbox`,`vaapi`,`nvenc`,`qsv`,`amf`,`software`]),available:v(),reason:p().optional()})).readonly(),defaultH264:ZY,defaultH265:ZY,probedAt:f()}),b({methods:S(p()).readonly(),probedAt:f()});var iOe=x([`darwin`,`linux`,`win32`]),aOe=x([`arm64`,`x64`]),oOe=b({type:x([`nvidia`,`amd`,`intel`,`apple`]),name:p(),memoryMB:f().optional()}),sOe=b({type:x([`apple-ane`,`intel-npu`,`amd-xdna`]),name:p().optional(),generation:x([`xdna1`,`xdna2`]).optional()}),QY=x([`usb`,`pci`]),cOe=b({type:o(`coral-edgetpu`),bus:p().optional(),count:f().int().nonnegative().optional(),units:S(b({bus:QY,count:f().int().nonnegative()})).readonly().optional(),unavailable:S(b({bus:QY,count:f().int().nonnegative(),reason:x([`driver-missing`,`device-not-accessible`])})).readonly().optional()}),$Y=b({platform:iOe,arch:aOe,cpuModel:p(),cpuCores:f(),totalRAM_MB:f(),availableRAM_MB:f(),gpu:oOe.nullable(),npu:sOe.nullable(),coral:cOe.nullable().optional(),accelerators:S(VY).readonly().optional()}),eX=b({runtime:o(`python`),backend:p(),format:x([`onnx`,`coreml`,`openvino`,`tflite`]),score:f(),reason:p(),available:v()}),tX=b({key:p(),backend:p(),device:p(),format:XY,runtime:o(`python`),score:f(),available:v()}),lOe=b({hardware:$Y,scores:S(eX).readonly(),bestScore:eX,pythonPath:p().nullable(),devices:S(tX).readonly()}),uOe=b({modelId:p(),name:p(),minRAM_MB:f(),accuracyScore:f(),formats:S(p()).readonly()}),dOe=b({modelId:p(),runtime:o(`python`),backend:p(),format:XY,reason:p()}),fOe=b({devices:S(tX).readonly(),appeared:S(p()).readonly(),disappeared:S(p()).readonly(),usbBus:x([`observed`,`unobservable`]),decidedBy:x([`usb-ids`,`pci`,`delegate-fallback`,`none`])}),nX={name:`platform-probe`,scope:`system`,mode:`singleton`,methods:{getCapabilities:O(_(),lOe),getHardware:O(_(),$Y),resolveInferenceConfig:O(b({requirements:S(uOe).readonly()}),dOe),resolveHwAccel:O(b({prefer:nOe}),rOe),rescanAccelerators:O(_(),fOe,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:A.CLUSTER}},rX=b({power:f().optional().meta(j(`power`,{label:`Power`})),energy:f().optional().meta(j(`energy`,{label:`Energy`})),voltage:f().optional().meta(j(`voltage`,{label:`Voltage`})),current:f().optional().meta(j(`current`,{label:`Current`})),apparentPower:f().optional().meta(j(`apparent-power`)),powerFactor:f().min(0).max(1).optional().meta(j(`ratio`)),lastFetchedAt:f()}),iX=[w.Sensor,w.Switch,w.Light,w.Fan,w.Climate,w.Humidifier,w.WaterHeater,w.MediaPlayer,w.Washer,w.Dryer,w.Dishwasher,w.Vacuum,w.LawnMower,w.PetFeeder],pOe=iX.filter(e=>e!==w.Sensor);function aX(e,t){return{id:e,cardinality:`scalar`,vocabulary:{cap:`power-meter`,stateField:e},deviceTypes:pOe,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 mOe={version:1,targets:[aX(`power`,`W`),aX(`energy`,`kWh`),aX(`voltage`,`V`),aX(`current`,`A`)]},oX={name:`power-meter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:iX,deviceConfig:{ui:{kind:`widget`,widgetId:`host/power-meter-line`,tab:`power`,placement:`hero`,label:`Power`,order:4}},methods:{},status:{schema:rX,kind:`push`},runtimeState:rX,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:mOe,vocabulary:{noun:N(`Power meter`,`Misuratore di energia`),order:5160,state:[{kind:`numeric`,field:`power`,quantity:N(`the power draw`,`il consumo`),label:N(`Power`,`Potenza`),unit:`W`,icon:`zap`},{kind:`numeric`,field:`energy`,quantity:N(`the energy used`,`l’energia consumata`),label:N(`Energy`,`Energia`),unit:`kWh`,icon:`zap`},{kind:`numeric`,field:`voltage`,quantity:N(`the voltage`,`la tensione`),label:N(`Voltage`,`Tensione`),unit:`V`,icon:`zap`},{kind:`numeric`,field:`current`,quantity:N(`the current`,`la corrente`),label:N(`Current`,`Corrente`),unit:`A`,icon:`zap`}]}},hOe=b({latitude:f().min(-90).max(90).meta(j(`angle`)),longitude:f().min(-180).max(180).meta(j(`angle`)),accuracyMeters:f().nonnegative().meta(j(`length`))}),sX=b({state:p(),location:p().nullable(),gps:hOe.nullable(),lastChangedAt:f()}),cX={name:`presence`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Presence],methods:{},status:{schema:sX,kind:`push`},runtimeState:sX,durability:`restored`,history:`none`,volatileStateFields:[`lastChangedAt`],vocabulary:{noun:N(`Presence`,`Presenza`),order:5170,state:[{kind:`value`,field:`state`,label:N(`Where`,`Posizione`),phrase:N(`When {device} is at {value}`,`Quando {device} è in {value}`),icon:`map-pin`}]}},lX=b({pressure:f().nullable().meta(j(`pressure`,{precision:0})),lastFetchedAt:f()}),uX={name:`pressure-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Sensor],methods:{},status:{schema:lX,kind:`push`},runtimeState:lX,durability:`restored`,history:{fields:{pressure:{kind:`gauge`,unit:`hPa`,deadband:.1}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:N(`Pressure`,`Pressione`),order:5180,state:[{kind:`numeric`,field:`pressure`,quantity:N(`the pressure`,`la pressione`),label:N(`Pressure`,`Pressione`),unit:`hPa`,icon:`gauge`}]}},dX=i(`kind`,[yB,bB]),fX=b({id:f(),enabled:v(),shape:dX}),pX=b({enabled:v(),regions:S(fX).nullable(),audioEnabled:v().nullable(),lastFetchedAt:f()}),mX=b({maxRegions:f(),supportedShapes:S(CB),polygonVertices:wB.optional(),supportsAudioMute:v()}),hX=b({enabled:v().optional(),regions:S(fX).optional()}),gX={name:`privacy-mask`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/privacy-mask-grid`,tab:`image`,label:`Privacy Mask`}},methods:{getOptions:O(b({deviceId:f()}),mX),setMask:O(b({deviceId:f(),patch:hX}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`privacy.maskOn`,label:N(`Privacy mask on`,`Maschera privacy attiva`),phrase:N(`Cover the privacy zones of {device}`,`Oscura le zone private di {device}`),icon:`eye-off`,args:{patch:{enabled:!0}}},{id:`privacy.maskOff`,label:N(`Privacy mask off`,`Maschera privacy spenta`),phrase:N(`Uncover the privacy zones of {device}`,`Scopri le zone private di {device}`),icon:`eye`,args:{patch:{enabled:!1}}}]}),setAudioEnabled:O(b({deviceId:f(),enabled:v()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`privacy.micOn`,label:N(`Microphone on`,`Microfono attivo`),phrase:N(`Turn on the microphone of {device}`,`Attiva il microfono di {device}`),icon:`mic`,args:{enabled:!0}},{id:`privacy.micOff`,label:N(`Microphone off`,`Microfono spento`),phrase:N(`Turn off the microphone of {device}`,`Disattiva il microfono di {device}`),icon:`mic-off`,args:{enabled:!1}}]})},status:{schema:pX,kind:`poll`},runtimeState:pX,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:N(`Privacy`,`Privacy`),order:3210,state:[{kind:`boolean`,field:`enabled`,label:N(`Privacy mask`,`Maschera privacy`),whenTrue:N(`When the privacy mask of {device} is turned on`,`Quando si attiva la maschera privacy di {device}`),whenFalse:N(`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:N(`Microphone`,`Microfono`),whenTrue:N(`When the microphone of {device} is turned on`,`Quando si attiva il microfono di {device}`),whenFalse:N(`When the microphone of {device} is turned off`,`Quando si disattiva il microfono di {device}`),icon:`mic`}]}};function gOe(e){return e.length===0?null:e.some(e=>e.audioEnabled)}var _X=x([`home`,`day-mode`,`night-mode`,`day-night-auto`,`set-limits`,`save-limits`,`reboot`,`osd-menu`]),vX=b({id:p(),name:p(),fn:_X.nullable(),writable:v()}),yX=b({pan:f().nullable(),tilt:f().nullable(),zoom:f().nullable()}),bX=b({pan:f().optional(),tilt:f().optional(),zoom:f().optional(),speed:f().optional()}),xX=yX.extend({autofocus:v()}),SX=b({hasPan:v(),hasTilt:v(),hasZoom:v(),supportsPresets:v(),maxPresets:f().optional(),hasAutofocus:v(),speedSteps:f().int().positive().nullable(),moveImpulseMs:f().int().positive().nullable()}),CX=b({presetId:p().nullable(),source:x([`operator`,`firmware`,`native`,`none`])}),wX=b({enabled:v(),seconds:f().int()}),TX={name:`ptz`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/ptz-panel`,tab:`ptz`,topTab:!0,label:`PTZ`,order:0}},methods:{move:O(bX.extend({deviceId:f()}),_(),{kind:`mutation`,notOperatorFacing:`a relative nudge from the live-view joystick; a fixed place is a preset`}),continuousMove:O(bX.extend({deviceId:f()}),_(),{kind:`mutation`,notOperatorFacing:`joystick motion held until released — continuous, not a discrete step`}),goHome:O(b({deviceId:f()}),_(),{kind:`mutation`,actions:[{id:`ptz.goHome`,label:N(`PTZ go home`,`Torna alla posizione iniziale`),phrase:N(`Send {device} to its home position`,`Riporta {device} alla posizione iniziale`),icon:`house`}]}),getPresets:O(b({deviceId:f()}),S(vX)),goToPreset:O(b({deviceId:f(),presetId:p()}),_(),{kind:`mutation`,actions:[{id:`ptz.goToPreset`,label:N(`PTZ go to preset`,`Vai a un preset`),phrase:N(`Move {device} to {presetId}`,`Sposta {device} su {presetId}`),icon:`move`,openArgs:[{key:`presetId`,label:N(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}}]}]}),savePreset:O(b({deviceId:f(),presetId:p(),name:p()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.savePreset`,label:N(`Save PTZ preset here`,`Salva qui un preset`),phrase:N(`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:N(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}},{key:`name`,label:N(`Name`,`Nome`),offer:{kind:`text`}}]}]}),deletePreset:O(b({deviceId:f(),presetId:p()}),_(),{kind:`mutation`,auth:`admin`}),getOptions:O(b({deviceId:f()}),SX),stop:O(b({deviceId:f()}),_(),{kind:`mutation`,actions:[{id:`ptz.stop`,label:N(`Stop moving`,`Ferma il movimento`),phrase:N(`Stop {device} moving`,`Ferma il movimento di {device}`),icon:`square`}]}),getHomePreset:O(b({deviceId:f()}),CX),setHomePreset:O(b({deviceId:f(),presetId:p().nullable()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.setHomePreset`,label:N(`Set PTZ home preset`,`Imposta il preset iniziale`),phrase:N(`Make {presetId} the home position of {device}`,`Rendi {presetId} la posizione iniziale di {device}`),icon:`house`,openArgs:[{key:`presetId`,label:N(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}}]}]}),captureHomeHere:O(b({deviceId:f()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.captureHomeHere`,label:N(`Set PTZ home here`,`Imposta qui la posizione iniziale`),phrase:N(`Make where {device} points now its home position`,`Rendi la posizione attuale di {device} la sua posizione iniziale`),icon:`map-pin`}]}),getHomeReturn:O(b({deviceId:f()}),wX.nullable()),setHomeReturn:O(b({deviceId:f(),enabled:v(),seconds:f().int().min(0).max(3600)}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.setHomeReturn`,label:N(`Set PTZ return home`,`Imposta il ritorno alla posizione iniziale`),phrase:N(`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:N(`Return home`,`Torna alla posizione iniziale`),offer:{kind:`boolean`}},{key:`seconds`,label:N(`Idle seconds`,`Secondi da fermo`),offer:{kind:`number`,min:0,max:3600,step:1,unit:`s`}}]}]}),getPosition:O(b({deviceId:f()}),yX),setAutofocus:O(b({deviceId:f(),enabled:v()}),_(),{kind:`mutation`,actions:[{id:`ptz.autofocusOn`,label:N(`Autofocus on`,`Autofocus attivo`),phrase:N(`Turn on autofocus on {device}`,`Attiva l’autofocus su {device}`),icon:`focus`,args:{enabled:!0}},{id:`ptz.autofocusOff`,label:N(`Autofocus off`,`Autofocus spento`),phrase:N(`Turn off autofocus on {device}`,`Disattiva l’autofocus su {device}`),icon:`focus`,args:{enabled:!1}}]})},status:{schema:xX,kind:`command-driven`},vocabulary:{noun:N(`Pan / tilt / zoom`,`Brandeggio`),order:3220}},EX=b({targetType:p().describe(`Vendor target string (people/vehicle/pet); empty = camera default`),stopDelaySeconds:f().int().min(0).max(300).meta(j(`duration`)),disappearDelaySeconds:f().int().min(0).max(300).meta(j(`duration`))}),DX=b({value:p(),label:p()}),OX=b({enabled:v(),lastChangedAt:f(),currentSettings:EX.nullable(),supportedTargetTypes:S(DX)}),kX=OX.extend({lastFetchedAt:f()}),AX={name:`ptz-autotrack`,scope:`device`,deviceNative:!0,mode:`singleton`,kind:`wrapper`,defaultActive:!1,deviceTypes:[w.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/ptz-autotrack`,tab:`ptz`,topTab:!0,label:`Auto-Tracking`,order:5}},methods:{getStatus:O(b({deviceId:f()}),OX),setEnabled:O(b({deviceId:f(),enabled:v()}),_(),{kind:`mutation`,actions:[{id:`ptz.autotrackOn`,label:N(`Autotrack on`,`Inseguimento attivo`),phrase:N(`Start autotracking on {device}`,`Attiva l’inseguimento automatico su {device}`),icon:`crosshair`,args:{enabled:!0}},{id:`ptz.autotrackOff`,label:N(`Autotrack off`,`Inseguimento spento`),phrase:N(`Stop autotracking on {device}`,`Disattiva l’inseguimento automatico su {device}`),icon:`crosshair`,args:{enabled:!1}}]}),getSettings:O(b({deviceId:f()}),EX.nullable()),setSettings:O(b({deviceId:f(),settings:EX.partial()}),_(),{role:`admin`,kind:`mutation`,notOperatorFacing:`tracking tuning (target type, delays) — set once on the camera’s PTZ page`})},events:{onStatusChanged:{data:b({deviceId:f(),status:OX}),notOperatorFacing:"the `enabled` state trigger phrases both edges of this change"}},status:{schema:OX,kind:`command-driven`},runtimeState:kX,durability:`session`,history:`none`,vocabulary:{noun:N(`Autotracking`,`Inseguimento automatico`),order:3230,state:[{kind:`boolean`,field:`enabled`,label:N(`Autotracking`,`Inseguimento automatico`),whenTrue:N(`When autotracking is turned on for {device}`,`Quando si attiva l’inseguimento automatico di {device}`),whenFalse:N(`When autotracking is turned off for {device}`,`Quando si disattiva l’inseguimento automatico di {device}`),icon:`crosshair`}]}},jX=b({enabled:v().nullable(),onTime:f().min(0).nullable().meta(j(`duration`)),offTime:f().min(0).nullable().meta(j(`duration`)),lastFetchedAt:f()}),MX=f().int().nonnegative(),NX=f().int().min(0),PX={name:`pump-cycle`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.PetFountain],methods:{setEnabled:O(b({deviceId:MX,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.on`,label:N(`Pump cycle on`,`Ciclo pompa attivo`),phrase:N(`Run the pump of {device} on its on/off cycle`,`Fai lavorare la pompa di {device} a ciclo acceso/spento`),icon:`timer`,args:{on:!0}},{id:`pumpCycle.off`,label:N(`Pump cycle off`,`Ciclo pompa spento`),phrase:N(`Run the pump of {device} continuously`,`Fai lavorare la pompa di {device} in continuo`),icon:`timer-off`,args:{on:!1}}]}),setOnMinutes:O(b({deviceId:MX,minutes:NX}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.onMinutes`,label:N(`Set pump run time`,`Imposta il tempo di lavoro della pompa`),phrase:N(`Set the pump of {device} to run {minutes} minutes per cycle`,`Imposta la pompa di {device} a lavorare {minutes} minuti per ciclo`),icon:`timer`,openArgs:[{key:`minutes`,label:N(`Minutes`,`Minuti`),offer:{kind:`number`,min:0,step:1,unit:`min`}}]}]}),setOffMinutes:O(b({deviceId:MX,minutes:NX}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.offMinutes`,label:N(`Set pump rest time`,`Imposta il tempo di riposo della pompa`),phrase:N(`Set the pump of {device} to rest {minutes} minutes per cycle`,`Imposta la pompa di {device} a riposare {minutes} minuti per ciclo`),icon:`timer-off`,openArgs:[{key:`minutes`,label:N(`Minutes`,`Minuti`),offer:{kind:`number`,min:0,step:1,unit:`min`}}]}]})},status:{schema:jX,kind:`push`},runtimeState:jX,durability:`session`,history:`none`,vocabulary:{noun:N(`Pump cycle`,`Ciclo della pompa`),order:2050,state:[{kind:`boolean`,field:`enabled`,label:N(`Pump cycle`,`Ciclo pompa`),whenTrue:N(`When {device} starts running its pump on a cycle`,`Quando {device} inizia a far lavorare la pompa a ciclo`),whenFalse:N(`When {device} runs its pump continuously`,`Quando {device} fa lavorare la pompa in continuo`),icon:`timer`}]}},FX={name:`reboot`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Camera,w.Sensor,w.Switch,w.Gateway],methods:{reboot:O(b({deviceId:f().int().nonnegative()}),b({success:o(!0)}),{kind:`mutation`,auth:`admin`,actions:[{id:`reboot.reboot`,label:N(`Reboot device`,`Riavvia il dispositivo`),phrase:N(`Reboot {device}`,`Riavvia {device}`),icon:`refresh-cw`}]})},vocabulary:{noun:N(`Reboot`,`Riavvio`),order:3240}},IX=b({owner:p(),kind:Yr,title:p(),nameField:p(),fields:u(p(),l()),secretPaths:S(p()),rows:f().int().nonnegative()}),LX=b({id:Tz,name:p(),rev:f().int(),updatedAt:f(),data:Ez}),RX={owner:p().min(1),kind:Yr},zX={name:`record-entries`,scope:`system`,mode:`singleton`,methods:{listEntryKinds:O(b({}),b({kinds:S(IX)}),{auth:`admin`}),listEntries:O(b({...RX}),b({entries:S(LX)}),{auth:`admin`}),putEntry:O(b({...RX,id:Tz.optional(),data:Ez,ifRev:f().int().min(1).optional()}),b({id:p(),rev:f().int()}),{kind:`mutation`,auth:`admin`}),deleteEntry:O(b({...RX,id:Tz}),b({deleted:v()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:A.INTERNAL}},_Oe=`camstack`,vOe=`recorder`,BX=b({profile:p(),startMs:f(),endMs:f()}),VX=x([`read`,`unreadable`]),HX=b({deviceId:f(),read:VX,ranges:S(BX),profilesWithFootage:S(p())}),UX=b({deviceId:f(),read:VX,days:S(f())}),WX=b({deviceId:f(),localMasterPath:p().nullable(),playbackUrl:p().nullable(),playbackEndpoints:S(p())}),GX=b({state:x([`ok`,`sleeping`,`unreachable`,`no-storage`,`index-empty`]),reason:p().optional(),coverageAsOf:f().optional()}),KX=b({source:p(),label:p(),addonId:p().optional(),availability:GX}),qX=b({transport:x([`archive`,`stream`,`realtime`]),coverage:x([`continuous`,`sparse`]),seek:x([`free`,`forward`,`segment`]),stepBack:v(),scrub:v(),rates:S(f().positive()).min(1).readonly(),exclusive:v()}),JX=i(`kind`,[b({kind:o(`hls`),manifest:WX}),b({kind:o(`clip`),source:p(),clipId:p(),startsAtMs:f()}),b({kind:o(`none`),reason:p()})]),YX={name:`recording`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:[w.Camera],methods:{listSources:O(b({deviceId:f()}),S(KX).readonly(),{kind:`query`,auth:`protected`}),getAvailability:O(b({deviceId:f(),provider:p().min(1),fromMs:f(),toMs:f(),profile:p().optional()}),HX,{kind:`query`,auth:`protected`}),getDaysWithRecordings:O(b({deviceId:f(),provider:p().min(1),fromMs:f(),toMs:f(),tzOffsetMinutes:f()}),UX,{kind:`query`,auth:`protected`}),getPlayback:O(b({deviceId:f(),provider:p().min(1),fromMs:f(),toMs:f(),profile:M.optional()}),JX,{kind:`query`,auth:`protected`}),getPlaybackOptions:O(b({deviceId:f(),provider:p().min(1)}),qX,{kind:`query`,auth:`protected`})},vocabulary:{noun:N(`Recording`,`Registrazione`),order:3250}},XX=b({deviceId:f(),enabled:v(),activeMode:lp,nodeId:p(),storageBytes:f()}),yOe=200,ZX=b({deviceId:f(),read:x([`read`,`unreadable`]),ranges:S(BX).readonly(),profilesWithFootage:S(p()).readonly()}),QX=b({deviceId:f(),read:x([`read`,`unreadable`]),days:S(f()).readonly()}),$X=b({deviceId:f(),usedBytes:f(),oldestMs:f().nullable().optional(),segments:f().optional(),residentBytes:f().optional(),residentOldestMs:f().nullable().optional()}),eZ=b({locationId:p().nullable(),locationIds:S(p()).optional(),root:p().optional(),usedBytes:f(),availableBytes:f().nullable(),totalBytes:f().nullable()}),tZ=b({nodeId:p(),totalUsedBytes:f(),devices:S($X),devicesRead:x([`archive`,`unavailable`]).optional(),complete:v().optional(),locations:S(eZ).optional()}),nZ=b({deviceId:f(),profile:p(),fromLocationId:p(),toLocationId:p(),bytes:f(),files:f().int()}),rZ=x([`unassigned`,`target-not-writable`,`below-threshold`,`no-headroom`]),iZ=b({deviceId:f(),profile:p(),fromLocationId:p(),toLocationId:p().nullable(),bytes:f(),reason:rZ}),aZ=b({moves:S(nZ),skipped:S(iZ),bytesToMove:f(),jobIds:S(p())}),oZ=b({throttleMbps:f().min(1).max(1e3).optional(),minMoveGb:f().min(0).optional()}),bOe=b({deviceId:f().int(),profile:p(),locationId:p()}),xOe=b({deviceId:f().int(),locationId:p()}),SOe=b({assignments:S(bOe),pins:S(xOe),defaultLocations:u(p(),p())}),COe=b({deviceId:f().int(),locationId:p().nullable()}),sZ=i(`kind`,[b({kind:o(`segment`),startMs:f(),durMs:f(),bytes:f()}),b({kind:o(`gap`),nearestEdgeMs:f().nullable(),prevEndMs:f().nullable().optional()})]),cZ=b({data:y(Uint8Array)}),lZ=b({data:y(Uint8Array),gopStartMs:f(),gopDurMs:f()}),uZ=i(`kind`,[b({kind:o(`ok`),data:y(Uint8Array),gopStartMs:f(),gopDurMs:f(),reachesRequestedEnd:v()}),b({kind:o(`spans-multiple-segments`),segmentEndMs:f()})]),dZ={name:`recording-archive`,scope:`system`,mode:`singleton`,exposesDeviceSettings:!0,status:{schema:XX,kind:`command-driven`},methods:{getAvailabilityBatch:O(b({deviceIds:S(f()).min(1).max(200),fromMs:f(),toMs:f()}),S(ZX).readonly(),{role:`viewer`,kind:`query`,auth:`protected`}),getDaysWithRecordingsBatch:O(b({deviceIds:S(f()).min(1).max(200),fromMs:f(),toMs:f(),tzOffsetMinutes:f()}),S(QX).readonly(),{role:`viewer`,kind:`query`,auth:`protected`}),getStorageUsage:O(b({}),tZ,{kind:`query`,auth:`admin`}),getDeviceConfig:O(b({deviceId:f()}),yp,{role:`viewer`,kind:`query`,auth:`protected`}),locateSegment:O(b({deviceId:f(),profile:p(),epochMs:f()}),sZ,{kind:`query`,auth:`admin`}),readSegmentBytes:O(b({deviceId:f(),profile:p(),startMs:f()}),cZ,{kind:`query`,auth:`admin`}),readGopBytes:O(b({deviceId:f(),profile:p(),startMs:f(),epochMs:f()}),lZ,{kind:`query`,auth:`admin`}),readWindowBytes:O(b({deviceId:f(),profile:p(),startMs:f(),fromMs:f(),toMs:f()}),uZ,{kind:`query`,auth:`admin`}),setDeviceConfig:O(b({deviceId:f(),config:yp}),yp,{kind:`mutation`,auth:`admin`}),rescanStorage:O(b({deviceId:f()}),XX,{kind:`mutation`,auth:`admin`}),pruneFootage:O(b({deviceId:f(),reason:$f.optional()}),b({floorMs:f().nullable(),deletedBuckets:f().int(),reclaimedBytes:f().int()}),{kind:`mutation`,auth:`admin`}),deleteFootprint:O(b({deviceId:f(),fromMs:f().optional(),toMs:f().optional()}),b({deletedBuckets:f().int(),reclaimedBytes:f().int()}),{kind:`mutation`,auth:`admin`}),listOpsLog:O(tp,S(ep).readonly(),{kind:`query`,auth:`admin`}),renderGif:O(b({deviceId:f(),aroundMs:f(),preRollSec:f().min(0).max(30).default(2),postRollSec:f().min(0).max(30).default(5),maxWidth:f().int().min(120).max(1280).default(480),fps:f().int().min(1).max(15).default(5)}),b({gifBase64:p(),fromMs:f(),toMs:f()}),{kind:`mutation`,auth:`admin`}),renderClip:O(b({deviceId:f(),aroundMs:f(),preRollSec:f().min(0).max(30).default(3),postRollSec:f().min(0).max(30).default(7),maxWidth:f().int().min(160).max(1920).default(640)}),b({clipBase64:p(),mime:p(),fromMs:f(),toMs:f(),bytes:f().int()}),{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:O(Dp,b({paused:o(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:O(Dp,b({resumed:o(!0)}),{kind:`mutation`,auth:`admin`}),refreshStorageLocationsForMigration:O(Dp,b({refreshed:o(!0)}),{kind:`mutation`,auth:`admin`}),startStorageMigrationMove:O(Op,b({jobId:p()}),{kind:`mutation`,auth:`admin`}),getStorageMigrationMoveStatus:O(b({jobId:p()}),wp.nullable(),{auth:`admin`}),cancelStorageMigrationMove:O(b({jobId:p()}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`}),relocateFootage:O(Ep,b({jobId:p()}),{kind:`mutation`,auth:`admin`}),listRelocateJobs:O(b({}),S(wp).readonly(),{kind:`query`,auth:`admin`}),getRelocateResidue:O(em,tm,{kind:`query`,auth:`admin`}),reconcileLedgerAgainstDisk:O(nm,om,{kind:`mutation`,auth:`admin`}),cancelRelocateJob:O(b({jobId:p()}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`}),planStorageRebalance:O(oZ,aZ,{kind:`query`,auth:`admin`}),startStorageRebalance:O(oZ,aZ,{kind:`mutation`,auth:`admin`}),getPlacement:O(b({}),SOe,{kind:`query`,auth:`admin`}),setDevicePlacement:O(COe,b({ok:o(!0)}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:A.STORAGE}},wOe=24,TOe=3,EOe=x([`queue-full`,`camera-backoff`,`sleeping`,`camera-refused`,`no-keyframe`,`decode-failed`,`no-catalog-row`,`unsupported`,`unknown-device`,`uid-missing`]),DOe=x([`deferred`,`final`]),OOe=`x-camstack-reason`,kOe=500;function AOe(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 jOe=`x-camstack-reason-code`,MOe=`x-camstack-disposition`,NOe=`x-camstack-clip-transport`,fZ=b({id:p(),source:p(),kind:x([`motion`,`object`,`audio`,`native`]),timeRange:b({startMs:f(),endMs:f()}),labels:S(p()).max(3).optional(),thumbnail:p().optional(),stillAtMs:f().optional(),eventIds:S(p()).optional(),eventCount:f().int().nonnegative().optional(),holes:S(b({startMs:f(),endMs:f()})).optional(),thumbnailMint:p().optional(),thumbnailUnavailable:b({reason:x([`sleeping`,`camera-refused`,`no-keyframe`,`unsupported`])}).optional(),catalogAsOf:f().optional(),nativeTypes:S(p()).optional(),behaviours:S(p()).optional(),streams:b({sub:b({id:p(),bytes:f().optional()}).optional(),main:b({id:p(),bytes:f().optional()}).optional()}).optional(),supportSub:v().optional(),playable:v().optional(),unplayableReason:p().optional(),inProgress:v().optional()}),pZ=b({playbackUrl:p(),format:x([`hls`,`mp4`]).optional(),served:M.optional(),playbackEndpoints:S(p()).optional(),token:p().optional()}),mZ=x([`authorised`]),POe=50*1024*1024,FOe=500*1024*1024,hZ=b({base64:p(),contentType:p(),name:p(),bytes:f().int().nonnegative(),served:M,durationMs:f().positive().optional()}),gZ=b({ticket:ii,contentType:p(),name:p(),served:M,durationMs:f().positive().optional()}),_Z=x([`opus`,`pcmu`,`none`]),vZ=x([`not-requested`,`unsupported-ask`]),yZ=b({url:p().min(1),expiresAtMs:f(),transport:o(`forward-only`),served:M,servedAudio:_Z,audioReason:vZ.optional()}),bZ=[.25,.5,1,1.5,2,4,8],xZ=[.25,.5,1,1.5,2,4],SZ=[.25,.5,1],CZ=b({transport:x([`stream`,`file`]),seek:x([`forward`,`free`]),stepBack:v(),scrub:v(),rates:S(f().positive()).min(1).readonly()}),wZ=b({state:x([`ok`,`sleeping`,`unreachable`,`no-storage`,`index-empty`]),reason:p().optional(),catalogAsOf:f().optional()}),TZ=b({source:p(),label:p(),addonId:p().optional(),availability:wZ}),EZ={name:`videoclips`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:[w.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/clips-browser`,tab:`recording`,topTab:!0,label:`Clips`,order:100}},methods:{listClips:O(b({deviceId:f(),since:f(),until:f(),limit:f().int().positive().optional(),provider:p().min(1)}),S(fZ).readonly(),{kind:`query`,auth:`protected`}),listSources:O(b({deviceId:f()}),S(TZ).readonly(),{kind:`query`,auth:`protected`}),getClipPlayback:O(b({deviceId:f(),clipId:p(),profile:M.optional()}),pZ,{kind:`query`,auth:`protected`}),readClipBytes:k(b({deviceId:f(),clipId:p().min(1),provider:p().min(1),profile:M.optional(),maxBytes:f().int().positive().optional(),wake:mZ.optional()}),hZ,{kind:`query`,auth:`protected`}),offerClipBytes:k(b({deviceId:f(),clipId:p().min(1),provider:p().min(1),profile:M.optional(),maxBytes:f().int().positive().optional(),wake:mZ.optional()}),gZ,{kind:`query`,auth:`protected`}),dialClipStream:k(b({deviceId:f(),clipId:p().min(1),provider:p().min(1),profile:M.optional(),audio:_Z.optional()}),yZ,{kind:`query`,auth:`protected`}),getPlaybackOptions:k(b({deviceId:f(),provider:p().min(1)}),CZ,{kind:`query`,auth:`protected`})},vocabulary:{noun:N(`Video clips`,`Clip video`),order:3330}},IOe={stream:{transport:`stream`,seek:`forward`,stepBack:!1,scrub:!1,rates:xZ},realtimeStream:{transport:`stream`,seek:`forward`,stepBack:!1,scrub:!1,rates:SZ},file:{transport:`file`,seek:`free`,stepBack:!0,scrub:!0,rates:bZ}},DZ=f().min(.25).max(32),OZ=b({fromSec:f().nonnegative(),toSec:f().nonnegative()}).refine(e=>e.toSec>e.fromSec,{message:`dense range must have toSec > fromSec`}),LOe=200,kZ=b({everyMs:f().int().positive(),ranges:S(OZ).min(1).max(200)}),AZ=b({everyMs:f().int().positive(),outputFps:f().int().min(1).max(60).optional(),dense:kZ.optional()}).superRefine((e,t)=>{e.dense!==void 0&&e.dense.everyMs>=e.everyMs&&t.addIssue({code:ce.custom,message:`dense.everyMs must be strictly smaller than the base everyMs`,path:[`dense`,`everyMs`]})}),jZ=b({speed:DZ.optional(),timelapse:AZ.optional(),includeAudio:v(),maxLifeMs:f().int().positive(),deleteAfterDownload:v(),title:p().max(200).optional(),notifyTargetIds:S(p().min(1)).max(20).optional()}).superRefine((e,t)=>{e.speed!==void 0&&e.timelapse!==void 0&&t.addIssue({code:ce.custom,message:`speed and timelapse are mutually exclusive`,path:[`timelapse`]})}),MZ=x([`queued`,`rendering`,`ready`,`failed`,`expired`,`deleted`]),NZ=b({kind:o(`footage`),deviceId:f(),profiles:S(p()).min(1),fromMs:f(),toMs:f()}),PZ=b({kind:o(`clip`),deviceId:f(),provider:p().min(1),source:p().min(1),sourceLabel:p().min(1),clipId:p().min(1),catalogWindow:b({sinceMs:f(),untilMs:f()}),profile:x([`high`,`mid`,`low`]),wake:mZ.optional()}),FZ=i(`kind`,[NZ,PZ]),IZ=b({id:p(),deviceId:f(),profile:p(),fromMs:f(),toMs:f(),subject:FZ.optional(),options:jZ,state:MZ,progressPct:f().nullable(),fileBytes:f().nullable(),expiresAt:f(),deleteAfterDownload:v(),downloadedAt:f().nullable(),createdAt:f(),createdBy:p(),error:p().nullable()}),LZ=x([`catalog-miss`,`catalog-unreachable`,`no-file-for-window`,`clip-in-progress`,`unsupported-option`,`sleeping`,`camera-refused`,`fetch-failed`,`too-large-to-transfer`,`wake-expired`]);function ROe(e,t){return t.length>0?`${e}: ${t}`:e}function zOe(e){if(e===null)return null;let t=e.split(`:`,1)[0]??``,n=LZ.safeParse(t.trim());return n.success?n.data:null}var RZ=b({url:p(),endpoints:S(p())}),BOe=50*1024*1024,zZ=b({base64:p(),contentType:p(),name:p(),bytes:f().int().nonnegative()});function BZ(e){return e.profiles!==void 0&&e.profiles.length>0?[...e.profiles]:typeof e.profile==`string`&&e.profile.length>0?[e.profile]:[]}var VOe=b({deviceId:f(),profile:p().optional(),profiles:S(p()).min(1).optional(),fromMs:f().optional(),toMs:f().optional(),subject:FZ.optional(),options:jZ}).superRefine((e,t)=>{if(e.subject?.kind===`clip`){e.subject.deviceId!==e.deviceId&&t.addIssue({code:ce.custom,message:`subject.deviceId (${e.subject.deviceId}) must equal deviceId (${e.deviceId}) — the top-level field is what per-device scope enforcement reads`,path:[`subject`,`deviceId`]}),(e.fromMs!==void 0||e.toMs!==void 0)&&t.addIssue({code:ce.custom,message:`a clip export asks for no time range: the camera chose the boundaries and they are read from the catalog row`,path:[`fromMs`]});return}e.subject?.kind===`footage`&&e.subject.deviceId!==e.deviceId&&t.addIssue({code:ce.custom,message:`subject.deviceId (${e.subject.deviceId}) must equal deviceId (${e.deviceId})`,path:[`subject`,`deviceId`]});let n=e.subject?.kind===`footage`?e.subject.fromMs:e.fromMs,r=e.subject?.kind===`footage`?e.subject.toMs:e.toMs;(typeof n!=`number`||typeof r!=`number`)&&t.addIssue({code:ce.custom,message:`a footage export needs fromMs and toMs`,path:[`fromMs`]}),(e.subject?.kind===`footage`?[...e.subject.profiles]:BZ(e)).length<1&&t.addIssue({code:ce.custom,message:`pass profiles[] (min 1) or legacy profile`,path:[`profiles`]})});function HOe(e){if(e.subject!==void 0)return e.subject;let t=BZ(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 UOe(e){return e.subject===void 0?{kind:`footage`,deviceId:e.deviceId,profiles:[e.profile],fromMs:e.fromMs,toMs:e.toMs}:e.subject}var VZ={name:`recording-export`,scope:`system`,mode:`singleton`,methods:{createExport:O(VOe,IZ,{role:`viewer`,kind:`mutation`,auth:`protected`}),listExports:O(b({deviceId:f().optional()}),S(IZ),{role:`viewer`,kind:`query`,auth:`protected`}),getExport:O(b({exportId:p()}),IZ,{role:`viewer`,kind:`query`,auth:`protected`}),cancelExport:O(b({exportId:p()}),IZ,{role:`viewer`,kind:`mutation`,auth:`protected`}),deleteExport:O(b({exportId:p()}),IZ,{role:`viewer`,kind:`mutation`,auth:`protected`}),getDownloadUrl:O(b({exportId:p()}),RZ,{role:`viewer`,kind:`query`,auth:`protected`}),readExportBytes:O(b({exportId:p()}),zZ,{kind:`query`,auth:`protected`})},vocabulary:{notOperatorFacing:`recording exports — requested from the timeline, not an automation step`}},HZ=x([`continuous`,`motion`,`person`,`vehicle`,`animal`,`lineCrossing`,`intrusion`,`loitering`,`alarmInput`]),UZ=b({trigger:HZ,day:f().int().min(0).max(6).meta(j(`none`)),startMinute:f().int().min(0).max(1439).meta(j(`none`)),endMinute:f().int().min(1).max(1440).meta(j(`none`))}),WZ=b({id:p(),label:p().optional(),status:x([`ok`,`unformatted`,`error`,`offline`,`unknown`]),capacityMb:f().nullable(),freeMb:f().nullable(),writable:v().optional()}),GZ=i(`kind`,[b({kind:o(`present`),volumes:S(WZ)}),b({kind:o(`absent`),reason:p()}),b({kind:o(`unknown`),reason:p()})]),KZ=b({id:p(),enabled:v(),isVideo:v(),codec:p().nullable(),resolution:p().nullable(),overwriteWhenFull:v().nullable()}),qZ=b({storage:GZ,tracks:S(KZ),primaryTrackId:p().nullable(),enabled:v().nullable(),overwriteWhenFull:v().nullable(),preRecordSec:f().nullable().meta(j(`duration`)),postRecordSec:f().nullable().meta(j(`duration`)),segmentMinutes:f().nullable().meta(j(`none`)),windows:S(UZ),unreadableWindows:f().meta(j(`count`)),recordingToNowhere:v(),lastFetchedAt:f()}),JZ=b({min:f(),max:f(),step:f()}),YZ=b({values:S(f()).min(1),sentinel:b({value:f(),meaning:x([`no-limit`,`disabled`])}).optional()}),XZ=b({readable:v(),writable:v(),reason:p().optional()}),ZZ=b({support:XZ,granularityMinutes:f(),triggers:S(HZ),supportsOverlappingTriggers:v()}),QZ=b({enabled:XZ,overwriteWhenFull:XZ,preRecordSec:XZ,preRecordSecRange:JZ.optional(),preRecordSecAllowed:YZ.optional(),postRecordSec:XZ,postRecordSecRange:JZ.optional(),postRecordSecAllowed:YZ.optional(),segmentMinutes:XZ,segmentMinutesRange:JZ.optional(),segmentMinutesAllowed:YZ.optional(),schedule:ZZ}),$Z=b({enabled:v().optional(),overwriteWhenFull:v().optional(),preRecordSec:f().optional(),postRecordSec:f().optional(),segmentMinutes:f().optional(),windows:S(UZ).optional()}),eQ={name:`recording-onboard`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Camera],deviceConfig:{ui:{kind:`derived-form`,builderId:`recording-onboard`,tab:`recording`}},methods:{getOptions:O(b({deviceId:f()}),QZ),setSettings:O(b({deviceId:f(),settings:$Z}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`recordingOnboard.on`,label:N(`On-camera recording on`,`Registrazione a bordo attiva`),phrase:N(`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:N(`On-camera recording off`,`Registrazione a bordo spenta`),phrase:N(`Turn off recording to the card of {device}`,`Disattiva la registrazione sulla scheda di {device}`),icon:`hard-drive`,args:{settings:{enabled:!1}}}]})},status:{schema:qZ,kind:`poll`},runtimeState:qZ,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:N(`On-camera recording`,`Registrazione a bordo`),order:3260,state:[{kind:`boolean`,field:`recordingToNowhere`,label:N(`Recording to nowhere`,`Registra nel vuoto`),whenTrue:N(`When {device} is recording with no card to write to`,`Quando {device} registra senza una scheda su cui scrivere`),whenFalse:N(`When {device} has a card to record to again`,`Quando {device} ha di nuovo una scheda su cui registrare`),icon:`hard-drive`}]}},tQ=b({active:v(),reason:p(),lastChangedAt:f()}),nQ=tQ.extend({lastFetchedAt:f()}),rQ={name:`recording-signal`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Camera],methods:{getStatus:O(b({deviceId:f()}),tQ)},status:{schema:tQ,kind:`push`,empty:{active:!1,reason:`unknown`,lastChangedAt:0}},runtimeState:nQ,durability:`session`,history:`none`,vocabulary:{noun:N(`Recording signal`,`Segnale di registrazione`),order:3270,state:[{kind:`boolean`,field:`active`,label:N(`Recording`,`In registrazione`),whenTrue:N(`When {device} starts recording`,`Quando {device} inizia a registrare`),whenFalse:N(`When {device} stops recording`,`Quando {device} smette di registrare`),icon:`circle-dot`}]}},iQ=b({kind:o(`cap`),deviceId:f().int().nonnegative(),cap:p().min(1),method:p().min(1),args:u(p(),l()).optional(),argUnits:u(p(),p().min(1)).optional()}),aQ=b({action:iQ}),oQ=b({key:p().refine(pE,{message:`a lowercase slug`}),name:p().min(1).max(60)}),WOe=200,GOe=100;function KOe(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=EE(a);e!==null&&s(e,`payload`)}for(let t of TE(a))uE(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 sQ=b({index:f().int().nonnegative(),id:p().nullable(),name:p().nullable(),reason:p()}),cQ=b({layoutTemplateId:p().min(1).nullable(),defaultTransmitterId:f().int().nonnegative().nullable().default(null),bindings:u(p(),aQ),customButtons:S(oQ).max(100),sources:S(CE).max(200).default([]),stepDelayMs:f().int().min(100).max(wE).default(500),refusedSources:S(sQ).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)uE(e)?t.addIssue({code:`custom`,message:`"${e}" is a layout widget, not a command: it cannot be bound`,path:[`bindings`,e]}):gE(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=hE(e);n!==null&&!r.has(n)&&t.addIssue({code:`custom`,message:`${e} is bound but has no entry in customButtons`,path:[`bindings`,e]})}KOe(e,t)}),qOe=a({sources:S(l())}),JOe=b({id:p(),name:p()}).partial();function YOe(e){let t=qOe.safeParse(e);if(!t.success)return lQ(cQ.safeParse(e));let n=[],r=[];t.data.sources.forEach((e,t)=>{let i=CE.safeParse(e),a=i.success&&i.data.kind===`ir`?EE(i.data):null;if(i.success&&a===null){n.push(e);return}let o=JOe.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=lQ(cQ.safeParse({...t.data,sources:n}));return!i.success||r.length===0?i:{success:!0,data:{...i.data,refusedSources:r}}}function lQ(e){return e.success?{success:!0,data:e.data}:{success:!1,issues:e.error.issues.length}}var XOe={layoutTemplateId:null,defaultTransmitterId:null,bindings:{},customButtons:[],sources:[],stepDelayMs:500},ZOe=b({power:b({state:x([`on`,`off`]),at:f()}).nullable(),muted:b({value:v(),at:f()}).nullable(),source:b({name:p(),at:f()}).nullable().default(null)}),QOe={power:null,muted:null,source:null},$Oe=24,eke=50,uQ=[`rect`,`rounded`,`round`,`pill`],dQ=x(uQ),fQ=[`neutral`,`accent`,`danger`,`red`,`green`,`yellow`,`blue`],pQ=x(fQ),mQ=[`none`,`panel`,`divider`,`dpad`,`rocker-v`,`rocker-h`,`keypad`],hQ=x(mQ),gQ=b({id:p().min(1).max(40),row:f().int().min(0).max(24),col:f().int().min(0).max(24),rowSpan:f().int().min(1).max(24),colSpan:f().int().min(1).max(24),icon:p().min(1).max(60).optional(),label:p().min(1).max(40).optional(),role:_E,shape:dQ.optional(),tone:pQ.optional(),showLegend:v().optional(),groupId:p().min(1).max(40).optional()}),_Q=b({id:p().min(1).max(40),componentId:p().min(1).max(80),frame:hQ,row:f().int().min(0).max(24),col:f().int().min(0).max(24),rowSpan:f().int().min(1).max(24),colSpan:f().int().min(1).max(24),title:p().min(1).max(40).optional(),size:x([`compact`,`normal`]).optional(),hideTitle:v().optional()});function vQ(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 yQ(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 tke(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&&vQ(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`]),yQ(n,e)||i(`button "${e.id}" lies outside its group "${n.id}"`,[`buttons`,t]);return}let a=n.find(t=>vQ(t,e));a!==void 0&&i(`button "${e.id}" lies inside group "${a.id}" but is not a member`,[`buttons`,t])})}var bQ=b({columns:f().int().min(1).max(24),rows:f().int().min(1).max(24),buttons:S(gQ).max(200),groups:S(_Q).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)}}),tke(e,t)}),nke=50,xQ=b({role:_E,label:p().optional(),custom:v()}),SQ=b({layoutTemplateId:p().nullable(),commands:S(xQ),sources:S(CE)}),CQ=[`no-remote`,`unbound-role`,`action-failed`,`unknown-source`,`unbound-step`,`undeclared-channel`,`press-timeout`,`no-transmitter`],wQ=x(CQ),TQ=i(`status`,[b({status:o(`sent`),sends:f().int().min(1)}),b({status:o(`skipped`),reason:o(`already-in-state`)}),b({status:o(`refused`),reason:wQ,detail:p().optional(),step:b({index:f().int().min(1),role:p()}).optional()})]),EQ=[`play`,`pause`,`stop`,`next`,`previous`,`setMute`,`selectSource`,`playMedia`,`turnOn`,`turnOff`,`volumeUp`,`volumeDown`,`channelUp`,`channelDown`],DQ=x(EQ),OQ=i(`status`,[...TQ.options,b({status:o(`not-routed`)})]),kQ=[`unknown-template`,`not-a-media-player`],AQ=i(`status`,[b({status:o(`saved`)}),b({status:o(`refused`),reason:x(kQ),detail:p()})]),jQ=b({deviceId:f().int().nonnegative()}),rke={version:1,targets:[{id:`remote`,cardinality:`config`,vocabulary:{cap:`remote`},deviceTypes:[w.MediaPlayer],apply:`add`,readMethod:`getConfig`,writeMethod:`setConfig`}]},MQ={name:`remote`,scope:`system`,mode:`singleton`,methods:{getConfig:O(jQ,cQ,{auth:`admin`}),setConfig:O(jQ.extend({config:cQ}),AQ,{kind:`mutation`,auth:`admin`}),listCommands:O(jQ,SQ,{auth:`protected`}),sendCommand:O(jQ.extend({role:_E,repeat:f().int().min(1).max(50).default(1)}),TQ,{kind:`mutation`,auth:`protected`}),getAssumedStatus:O(jQ,ME.nullable(),{auth:`protected`}),sendMediaCommand:O(jQ.extend({command:DQ,muted:v().optional(),source:p().optional(),mediaType:p().optional(),mediaId:p().optional(),repeat:f().int().min(1).max(50).default(1)}),OQ,{kind:`mutation`,auth:`protected`})},customize:rke,vocabulary:{notOperatorFacing:`the per-device remote setup — authored in the Customize remote editor, sent through the remote UI`}},NQ=[`power`,`navigation`,`volume`,`numbers`,`media`,`colour`,`apps`,`layout`],PQ=x(NQ),ike=40,ake=/^[a-z0-9][a-z0-9_.-]*:[a-z0-9][a-z0-9_-]*$/,FQ=b({idSuffix:p().regex(/^[a-z0-9][a-z0-9_-]{0,19}$/,{message:`a short lowercase slug`}),row:f().int().min(0).max(24),col:f().int().min(0).max(24),rowSpan:f().int().min(1).max(24),colSpan:f().int().min(1).max(24),role:_E,icon:p().min(1).max(60).optional(),label:p().min(1).max(40).optional(),shape:dQ.optional(),tone:pQ.optional(),showLegend:v().optional()}),IQ=b({id:p().max(80).regex(ake,{message:`<namespace>:<name>, lowercase`}),name:p().min(1).max(60),nameI18n:b({en:p().min(1).max(60),it:p().min(1).max(60)}).optional(),icon:p().min(1).max(60),category:PQ,size:b({rows:f().int().min(1).max(24),cols:f().int().min(1).max(24)}),group:b({frame:hQ,title:p().min(1).max(40).optional()}).nullable(),buttons:S(FQ).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&&vQ(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`]})}),LQ={name:`remote-layout-components`,scope:`system`,mode:`collection`,methods:{listComponents:O(b({}),S(IQ),{auth:`protected`})},vocabulary:{notOperatorFacing:`the palette of the remote template editor — read-only data, never actuated`}},oke=5,ske=2,RQ=3e4,zQ=18e4,BQ={startDwellMs:RQ,stopDwellMs:zQ,minSamples:2},VQ={[w.MediaPlayer]:{startDwellMs:1e4,stopDwellMs:1e4,minSamples:1}};function HQ(e){return e!==void 0&&VQ[e]!==void 0}function UQ(e){return e===void 0?BQ:VQ[e]??BQ}var cke={running:null,since:null,source:`native`,phase:null,lastFetchedAt:null},WQ=x([`native`,`assigned`]),GQ=b({running:v().nullable(),since:f().nullable().meta(j(`none`)),source:WQ.meta({label:`Source`}),phase:p().nullable(),lastFetchedAt:f().nullable()}),KQ=b({deviceId:f(),since:f().nullable(),phase:p().nullable()}),lke=Object.values(w),qQ=[w.Washer,w.Dryer,w.Dishwasher,w.Vacuum,w.LawnMower,w.MediaPlayer,w.WaterHeater,w.Humidifier,w.Fan,w.Climate,w.PetFeeder],uke={version:1,overridable:[{path:`running`,by:`running`}],targets:[{id:`running`,cardinality:`scalar`,vocabulary:{cap:`running-state`,stateField:`running`},deviceTypes:qQ,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:RQ,defaultStopDwellMs:zQ,deviceTypeDefaults:VQ,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}]},JQ={name:`running-state`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:lke,methods:{},events:{onStarted:{data:KQ,trigger:{category:C.RunningStarted,label:N(`Started running`,`Ha iniziato a funzionare`),phrase:N(`When {device} starts running`,`Quando {device} inizia a funzionare`),icon:`play`}},onFinished:{data:KQ,trigger:{category:C.RunningFinished,label:N(`Finished`,`Ha finito`),phrase:N(`When {device} finishes`,`Quando {device} finisce`),icon:`square`}}},status:{schema:GQ,kind:`push`},runtimeState:GQ,durability:`restored`,history:{fields:{running:{kind:`boolean`}}},volatileStateFields:[`lastFetchedAt`],customize:uke,vocabulary:{noun:N(`Running`,`In funzione`),order:2120,state:[{kind:`boolean`,field:`running`,label:N(`Running`,`In funzione`),whenTrue:N(`When {device} starts`,`Quando {device} inizia`),whenFalse:N(`When {device} finishes`,`Quando {device} finisce`),icon:`play`}],overrides:{byType:{[w.Washer]:{state:{running:{whenTrue:N(`When the washing machine starts`,`Quando la lavatrice inizia`),whenFalse:N(`When the washing machine has finished`,`Quando la lavatrice ha finito`)}},events:{onStarted:{phrase:N(`When the washing machine starts`,`Quando la lavatrice inizia`)},onFinished:{phrase:N(`When the washing machine has finished`,`Quando la lavatrice ha finito`)}}},[w.Dryer]:{state:{running:{whenTrue:N(`When the dryer starts`,`Quando l'asciugatrice inizia`),whenFalse:N(`When the dryer has finished`,`Quando l'asciugatrice ha finito`)}},events:{onStarted:{phrase:N(`When the dryer starts`,`Quando l'asciugatrice inizia`)},onFinished:{phrase:N(`When the dryer has finished`,`Quando l'asciugatrice ha finito`)}}},[w.Dishwasher]:{state:{running:{whenTrue:N(`When the dishwasher starts`,`Quando la lavastoviglie inizia`),whenFalse:N(`When the dishwasher has finished`,`Quando la lavastoviglie ha finito`)}},events:{onStarted:{phrase:N(`When the dishwasher starts`,`Quando la lavastoviglie inizia`)},onFinished:{phrase:N(`When the dishwasher has finished`,`Quando la lavastoviglie ha finito`)}}}}}}},YQ=p(),dke=[`day`,`ir`,`night`,`dawn`,`dusk`],XQ=x([`skip`,`judge-anyway`]),fke=`__diverged__`,ZQ=x([`matched`,`diverged`,`unknown`]),QQ=x([`no-reference-for-condition`,`view-shifted`,`no-vision-profile`,`encoder-model-changed`,`no-snapshot`]),$Q=b({embedding:S(f()),modelId:p(),condition:YQ,capturedAt:f(),thumbnailMediaId:f().int().optional(),anchorEmbedding:S(f()).optional()}),e$=b({id:p(),label:p(),references:S($Q),textPrompts:S(p()).optional(),referenceCount:f(),currentlyMatched:v()}),t$=i(`mode`,[b({mode:o(`similarity`),threshold:f().min(0).max(1),hysteresisCount:f().int().positive()}),b({mode:o(`llm`),prompt:p(),profileId:p().optional(),hysteresisCount:f().int().positive()})]),pke=60,mke=120,hke=60,n$=.85,r$=`skip`,i$=8e3,gke=448,_ke=!0,a$=b({enabled:v().default(!1),prompt:p().min(1).max(1e3),profileId:p().optional(),timeoutMs:f().int().min(1e3).max(2e4).default(i$),maxImagePx:f().int().min(64).max(2048).default(448),onTimeout:x([`flip`,`hold`]).default(`hold`)}),o$=b({id:p(),label:p(),roi:yB,enabled:v(),triggerMode:x([`periodic`,`on-motion`,`both`]),checkIntervalSec:f().optional(),check:t$,states:S(e$),currentStateId:p().nullable(),lastCheckedAt:f().nullable(),lastConfidence:f().nullable(),currentCondition:YQ.nullable(),availability:x([`ok`,`unavailable`]),unavailableReason:p().nullable(),baselineStateId:p().nullable(),emit:x([`latched`,`live`]).default(`latched`),verdict:ZQ,latched:v(),armedAt:f(),divergedAt:f().nullable(),restoredAt:f().nullable(),quietSeconds:f().int().min(0).max(3600).default(60),minObservationSpacingSec:f().int().min(0).max(3600).default(120),confirm:a$.optional(),anchorThreshold:f().min(0).max(1).default(n$),autoRestore:v().default(!1),onUncoveredCondition:XQ.default(r$),suspendedCondition:YQ.nullable().default(null),unavailable:QQ.nullable(),coveredConditions:S(YQ)}),s$=b({monitors:S(o$),lastFetchedAt:f()}),c$=b({deviceId:f(),status:s$.nullable()}),l$={name:`scene-monitor`,role:{feature:`scenes`},scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[w.Camera],methods:{listScenes:O(b({deviceId:f()}),s$),listScenesBatch:O(b({deviceIds:S(f()).min(1).max(200)}),S(c$).readonly()),createScene:O(b({deviceId:f(),label:p(),roi:yB,check:t$,triggerMode:x([`periodic`,`on-motion`,`both`]).optional(),checkIntervalSec:f().optional()}),o$,{kind:`mutation`,auth:`admin`}),updateScene:O(b({deviceId:f(),monitorId:p(),patch:b({label:p().optional(),roi:yB.optional(),enabled:v().optional(),triggerMode:x([`periodic`,`on-motion`,`both`]).optional(),checkIntervalSec:f().optional(),check:t$.optional(),emit:x([`latched`,`live`]).optional(),quietSeconds:f().int().min(0).max(3600).optional(),minObservationSpacingSec:f().int().min(0).max(3600).optional(),anchorThreshold:f().min(0).max(1).optional(),autoRestore:v().optional(),onUncoveredCondition:XQ.optional(),confirm:a$.nullable().optional()})}),_(),{kind:`mutation`,auth:`admin`}),deleteScene:O(b({deviceId:f(),monitorId:p()}),_(),{kind:`mutation`,auth:`admin`}),captureReference:O(b({deviceId:f(),monitorId:p(),stateId:p().optional(),label:p().optional(),condition:YQ.optional()}),b({stateId:p(),referenceCount:f()}),{kind:`mutation`,auth:`admin`}),deleteReference:O(b({deviceId:f(),monitorId:p(),stateId:p(),index:f()}),_(),{kind:`mutation`,auth:`admin`}),recheckNow:O(b({deviceId:f(),monitorId:p()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`sceneMonitor.recheck`,label:N(`Re-check a scene`,`Ricontrolla una scena`),phrase:N(`Re-check {monitorId} on {device} now`,`Ricontrolla subito {monitorId} su {device}`),icon:`scan-search`,openArgs:[{key:`monitorId`,label:N(`Scene`,`Scena`),offer:{kind:`dynamic`,from:`status`,field:`monitors`,valueKey:`id`,labelKey:`label`}}]}]}),resetScene:O(b({deviceId:f(),monitorId:p(),recapture:v().optional()}),_(),{kind:`mutation`,auth:`admin`})},status:{schema:s$,kind:`push`},runtimeState:s$,durability:`session`,history:`none`,vocabulary:{noun:N(`Scene watch`,`Controllo della scena`),order:3280,extraEvents:[{category:C.EnrichmentSceneStateChanged,label:N(`Scene changed`,`Scena cambiata`),phrase:N(`When a watched scene on {device} changes`,`Quando cambia una scena controllata su {device}`),icon:`scan-search`}]}},u$=b({schedulerId:p().min(1)}),d$={name:`schedulers`,scope:`system`,mode:`singleton`,methods:{list:O(b({}),S(Cv),{auth:`admin`}),get:O(u$,b({scheduler:Cv.nullable()}),{auth:`admin`}),create:O(b({scheduler:Sv}),b({scheduler:Cv}),{kind:`mutation`,auth:`admin`}),update:O(b({schedulerId:p().min(1),scheduler:Sv}),b({scheduler:Cv}),{kind:`mutation`,auth:`admin`}),delete:O(u$,_(),{kind:`mutation`,auth:`admin`}),setEnabled:O(b({schedulerId:p().min(1),profileId:p().min(1).optional(),enabled:v()}),b({scheduler:Cv}),{kind:`mutation`,auth:`admin`}),preview:O(b({schedulerId:p().min(1),date:p().regex(kv).optional()}),jv,{auth:`admin`}),conflicts:O(b({scheduler:Sv,schedulerId:p().min(1).optional()}),b({conflicts:S(Mv)}),{auth:`admin`}),getStatus:O(b({}),S(Pv),{auth:`admin`}),getTraces:O(u$,b({traces:S(Gv)}),{auth:`admin`})},vocabulary:{notOperatorFacing:`time schedulers — authored on their own page, not device actions`}},f$=b({isRunning:v(),lastRunAt:f(),lastRunSuccess:v().nullable(),lastError:p().nullable(),lastChangedAt:f()}),p$={name:`script-runner`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Script],methods:{run:O(b({deviceId:f().int().nonnegative(),variables:u(p(),l()).optional()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`script.run`,label:N(`Run script`,`Esegui lo script`),phrase:N(`Run {device}`,`Esegui {device}`),icon:`scroll-text`}]}),stop:O(b({deviceId:f().int().nonnegative()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`script.stop`,label:N(`Stop script`,`Ferma lo script`),phrase:N(`Stop {device}`,`Ferma {device}`),icon:`square`}]})},status:{schema:f$,kind:`push`},runtimeState:f$,durability:`session`,history:`none`,vocabulary:{noun:N(`Script`,`Script`),order:2090,state:[{kind:`boolean`,field:`isRunning`,label:N(`Running`,`In esecuzione`),whenTrue:N(`When {device} starts running`,`Quando {device} parte`),whenFalse:N(`When {device} finishes`,`Quando {device} termina`),icon:`scroll-text`}]}},m$=x([`workspace`,`baked`,`data-root`]),h$=x([`idle`,`checking`,`staging`,`pending-restart`,`awaiting-confirmation`]),g$=x([`in-sync`,`behind-patch`,`behind-series`,`ahead`,`unknown`]),_$=b({state:g$,seedVersion:p().nullable(),contractVersion:p().nullable(),contractSource:x([`registry`,`running`]).nullable(),message:p()}),v$=x([`docker`,`electron`,`native`,`contradictory`,`unknown`]),y$=b({fact:x([`dockerenv-file`,`proc-1-cgroup`,`platform`,`electron-app-version-env`]),mode:x([`observed`,`declared`]),holds:v(),detail:p()}),b$=b({kind:v$,evidence:S(y$),currentVersion:p().nullable()}),x$=b({fromVersion:p(),toVersion:p().nullable(),atMs:f(),reason:p()}),S$=b({version:p(),update:b({available:v(),downloaded:v(),version:p().nullable(),checking:v(),error:p().nullable()}),stateAtMs:f(),stale:v()}),C$=x([`not-electron`,`no-app-state`,`app-state-stale`,`not-downloaded`]),w$=b({accepted:v(),reason:C$.nullable()}),T$=b({runnerId:p(),addonIds:S(p()),reason:p()}),E$=b({checkedAtMs:f(),expected:f(),running:f(),failed:S(p()),refused:S(T$),missing:S(p()),pending:S(p()).optional(),planKnown:v()}),D$=b({packageName:p(),runningVersion:p().nullable(),nodeRuntimeVersion:p().nullable(),activeVersion:p().nullable(),installedVersion:p().nullable().optional(),restartRequired:v().optional(),previousVersion:p().nullable(),seedVersion:p().nullable(),latestVersion:p().nullable(),updateAvailable:v(),bootMode:m$,updateState:h$,pendingVersion:p().nullable(),rolledBack:x$.nullable(),stateFileCorrupt:v(),lastCheckedAtMs:f().nullable(),imageContract:_$.optional(),wrapper:b$.optional(),runners:E$.optional(),desktopApp:S$.optional()}),O$=b({packageName:p(),runningVersion:p().nullable(),latestVersion:p().nullable(),updateAvailable:v(),checkedAtMs:f(),error:p().nullable(),pendingVersion:p().nullable().optional(),restartRequired:v().optional()}),k$=x([`staged`,`restart-scheduled`,`already-current`,`refused`,`failed`]),A$=b({addonId:p(),reason:p(),remedy:p()}),j$=b({accepted:v(),targetVersion:p().nullable(),restarting:v(),message:p(),outcome:k$.optional(),reason:p().nullable().optional(),error:p().nullable().optional(),blockers:S(A$).optional(),unmet:S(Il).optional(),requiredAddonUpdates:S(Ll).optional()}),M$=b({heapMb:f().int().nullable(),rssBudgetMb:f().int().nullable()}),vke=b({heapMb:f().int().min(512).max(65536).nullable(),rssBudgetMb:f().int().min(512).max(65536).nullable().optional()}),yke=M$.extend({restartRequired:v()}),N$={name:`server-management`,scope:`system`,mode:`singleton`,methods:{getServerPackageStatus:O(_(),D$,{auth:`admin`}),checkServerUpdate:O(_(),O$,{kind:`mutation`,auth:`admin`}),applyServerUpdate:O(b({version:p().optional(),acknowledgeRefusals:v().optional()}),j$,{kind:`mutation`,auth:`admin`,timeoutMs:16*6e4}),installDesktopUpdate:O(_(),w$,{kind:`mutation`,auth:`admin`}),rollbackServerUpdate:O(_(),j$,{kind:`mutation`,auth:`admin`}),restartServer:O(_(),j$,{kind:`mutation`,auth:`admin`}),getLaunchOverrides:O(_(),M$,{auth:`admin`}),setLaunchOverrides:O(vke,yke,{kind:`mutation`,auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:A.CLUSTER}},P$=b({detected:v(),lastChangedAt:f()}),F$={name:`smoke`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[w.Sensor],methods:{},status:{schema:P$,kind:`push`},runtimeState:P$,durability:`restored`,history:{fields:{detected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:N(`Smoke detector`,`Rilevatore di fumo`),order:5190,state:[{kind:`boolean`,field:`detected`,label:N(`Detected`,`Rilevato`),whenTrue:N(`When {device} detects smoke`,`Quando {device} rileva fumo`),whenFalse:N(`When smoke clears on {device}`,`Quando il fumo su {device} si dirada`),icon:`alarm-smoke`}]}},bke=3,I$=5*1024*1024,L$=`<!--camstack-images-->`,R$=b({ticket:ii,mime:p().min(1),name:p().min(1),contentId:p().min(1),placement:x([`inline`,`attachment`]),deviceId:f().int().nonnegative().optional()}),z$=0;function B$(e){return z$+=1,`camstack_${e}_${z$.toString(36)}_${Date.now().toString(36)}`}function xke(e){return/^[\x20-\x7E]*$/.test(e)?e:`=?UTF-8?B?${Buffer.from(e,`utf8`).toString(`base64`)}?=`}function V$(e){return(Array.isArray(e)?e:[e]).join(`, `)}function Ske(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}function H$(e,t){let n=e.replace(/[\r\n"]/g,``).trim();return n.length>0?n:t}function Cke(e){let t=Buffer.from(e).toString(`base64`),n=[];for(let e=0;e<t.length;e+=76)n.push(t.slice(e,e+76));return n.join(`\r
|
|
1109
1109
|
`)}function wke(e){return`<img src="cid:${Ske(e.contentId)}" alt="">`}function Tke(e,t){return e.replaceAll(L$,t.map(wke).join(``))}function U$(e){let t=[`From: ${e.from}`,`To: ${V$(e.to)}`];return e.cc!==void 0&&e.cc.length>0&&t.push(`Cc: ${V$(e.cc)}`),e.bcc!==void 0&&e.bcc.length>0&&t.push(`Bcc: ${V$(e.bcc)}`),e.replyTo!==void 0&&e.replyTo.length>0&&t.push(`Reply-To: ${e.replyTo}`),t.push(`Subject: ${xke(e.subject)}`),t.push(`MIME-Version: 1.0`),t}function W$(e,t){return[`--${e}`,`Content-Type: text/plain; charset="UTF-8"`,`Content-Transfer-Encoding: 8bit`,``,t]}function G$(e,t){return[`--${e}`,`Content-Type: text/html; charset="UTF-8"`,`Content-Transfer-Encoding: 8bit`,``,t]}function K$(e,t){let n=H$(t.mime,`image/jpeg`),r=H$(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: <${H$(t.contentId,`image`)}>`),a.push(``,Cke(t.bytes)),a}function q$(e,t,n){let r=B$(`alt`);return[`--${e}`,`Content-Type: multipart/alternative; boundary="${r}"`,``,...W$(r,t),...G$(r,n),`--${r}--`]}function Eke(e,t){let n=U$(e);if(t!==void 0){let r=B$(`alt`);return n.push(`Content-Type: multipart/alternative; boundary="${r}"`,``),n.push(...W$(r,e.text),...G$(r,t),`--${r}--`),n}return n.push(`Content-Type: text/plain; charset="UTF-8"`,`Content-Transfer-Encoding: 8bit`,``,e.text),n}function Dke(e,t,n){let r=B$(`mix`),i=U$(e);i.push(`Content-Type: multipart/mixed; boundary="${r}"`,``),t===void 0?i.push(...W$(r,e.text)):i.push(...q$(r,e.text,t));for(let e of n)i.push(...K$(r,e));return i.push(`--${r}--`),i}function Oke(e,t,n,r){let i=B$(`rel`),a=U$(e);a.push(`Content-Type: multipart/related; boundary="${i}"; type="multipart/alternative"`,``,...q$(i,e.text,t));for(let e of n)a.push(...K$(i,e));for(let e of r)a.push(...K$(i,e));return a.push(`--${i}--`),a}function J$(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?Tke(e.html,n):void 0;return i!==void 0&&n.length>0?Oke(e,i,n,r).join(`\r
|
|
1110
1110
|
`):r.length>0||n.length>0?Dke(e,i,r.length>0?r:n).join(`\r
|
|
1111
1111
|
`):Eke(e,i).join(`\r
|